diff --git a/.circleci/config.yml b/.circleci/config.yml index 1784ba1ea..8ecee2b19 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,13 @@ jobs: - run: name: Add i386 arch command: dpkg --add-architecture i386 + - run: + name: Add STJr PPA + command: | + apt-get -qq update + apt-get -qq -y install dirmngr + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6 + echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" >> /etc/apt/sources.list - run: name: Update APT listing command: apt-get -qq update @@ -36,15 +43,16 @@ jobs: - v1-SRB2-APT - run: name: Install SDK - command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 gettext ccache wget gcc-multilib upx openssh-client + command: apt-get -qq -y --no-install-recommends install git build-essential nasm libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client + - save_cache: key: v1-SRB2-APT paths: - /var/cache/apt/archives - checkout - run: - name: Compile without network support and BLUA - command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1 + name: Compile without network support + command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 - run: name: wipe build command: make -C src LINUX=1 cleandep @@ -63,4 +71,4 @@ jobs: - save_cache: key: v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }} paths: - - /root/.ccache + - /root/.ccache \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index d45620912..7751149ac 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,12 @@ +#Source code +/src/*.c text=auto +/src/*.h text=auto +/src/*.s text=auto +/src/*.m text=auto +/src/*.xpm text=auto +/src/Makefile text=auto +/src/Make*.cfg text=auto +/src/CMakeLists.txt text=auto # Windows EOL *.cs -crlf -whitespace *.mk -crlf -whitespace diff --git a/.gitignore b/.gitignore index 922fac4aa..3090417dd 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,5 @@ Win32_LIB_ASM_Release *.db *.opendb /.vs +/debian +/assets/debian diff --git a/.travis.yml b/.travis.yml index 15a3c844c..9d91b77df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,57 +1,323 @@ +# Travis-CI Config +# +# You may use the Deployer to upload packages and builds to external servers. +# See deployer/travis/deployer_defaults.sh for environment variables to configure. + language: c sudo: required dist: trusty matrix: include: +################################ +# Test Buildbots +# Deployer does not operate on these. See Deployer Buildbots, below. +# These bots are disabled when a deployment is triggered by 'deployer' branch name AND DPL_TERMINATE_TESTS=1. +# These bots remain enabled when a deployment is triggered by release tag. +################################ - os: linux addons: apt: + sources: + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - gcc-4.4 compiler: gcc-4.4 env: GCC44=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7 - os: linux addons: apt: + sources: + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - gcc-4.6 compiler: gcc-4.6 env: GCC46=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4 - os: linux addons: apt: + sources: + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - gcc-4.7 compiler: gcc-4.7 env: GCC47=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc-4.7 - os: linux compiler: gcc env: GCC48=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ #gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4 - os: linux addons: apt: sources: - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + env: GCC48=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - gcc-7 + compiler: gcc-7 + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - gcc-8 + compiler: gcc-8 + env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow -Wno-error=format-truncation" GCC81=1 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0 + - os: linux + compiler: clang + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #clang version 3.5.0 (tags/RELEASE_350/final) + - os: linux + addons: + apt: + sources: + - llvm-toolchain-precise-3.5 + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - clang-3.5 + compiler: clang-3.5 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) + - os: linux + addons: + apt: + sources: + - llvm-toolchain-precise-3.6 + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - clang-3.6 + compiler: clang-3.6 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) + - os: linux + addons: + apt: + sources: + - llvm-toolchain-precise-3.7 + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - clang-3.7 + compiler: clang-3.7 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #Ubuntu clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) + - os: linux + addons: + apt: + sources: + - llvm-toolchain-precise-3.8 + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - clang-3.8 + compiler: clang-3.8 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #clang version 3.8.1-svn271127-1~exp1 (branches/release_38) + - os: linux + addons: + apt: + sources: + - llvm-toolchain-precise-3.9 + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - clang-3.9 + compiler: clang-3.9 + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #clang version 3.9.X +# - os: linux +# addons: +# apt: +# sources: +# - llvm-toolchain-precise-4.0 +# - ubuntu-toolchain-r-test +# - sourceline: 'ppa:stjr/srb2' +# packages: +# - libsdl2-mixer-dev +# - libpng-dev +# - libgl1-mesa-dev +# - libgme-dev +# - libopenmpt-dev +# - p7zip-full +# - clang-4.0 +# compiler: clang-4.0 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #clang version 4.0.X +# - os: linux +# addons: +# apt: +# sources: +# - llvm-toolchain-precise-5.0 +# - ubuntu-toolchain-r-test +# - sourceline: 'ppa:stjr/srb2' +# packages: +# - libsdl2-mixer-dev +# - libpng-dev +# - libgl1-mesa-dev +# - libgme-dev +# - libopenmpt-dev +# - p7zip-full +# - clang-5.0 +# compiler: clang-5.0 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #clang version 5.0.X +# - os: osx +# osx_image: beta-xcode6.1 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) +# - os: osx +# osx_image: beta-xcode6.2 +# compiler: gcc +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) +## - os: osx +## osx_image: beta-xcode6.3 +## if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +## #I think xcode.6.3 VM is broken, it does not boot +# - os: osx +# osx_image: xcode6.4 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) +# - os: osx +# osx_image: xcode7 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #Apple LLVM version 7.0.0 (clang-700.0.72) +# - os: osx +# osx_image: xcode7.1 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #Apple LLVM version 7.0.0 (clang-700.1.76) +# - os: osx +# osx_image: xcode7.2 +# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ +# #Apple LLVM version 7.0.2 (clang-700.1.81) +# - os: osx +# osx_image: xcode7.3 +# #Apple LLVM version 7.3.0 (clang-703.0.31) +# - os: osx +# osx_image: xcode7.3 +# #Apple LLVM version 7.3.0 (clang-703.0.31) + - os: osx + if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/ + #Default: macOS 10.13 and Xcode 9.4.1 + + +################################ +# Deployer Buildbots - OSX +################################ + - os: osx + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=osx + - _DPL_FTP_TARGET=1 + - _DPL_PACKAGE_BINARY=1 + #Apple LLVM version 7.3.0 (clang-703.0.31) + + +################################ +# Deployer Buildbots - Linux assets +# Set DPL_TERMINATE_ASSETS to disable all of these +# List Ubuntu LTS next, newest to oldest +# Then list non-LTS, newest to oldest +################################ + - os: linux + addons: + apt: packages: - libsdl2-mixer-dev - libpng-dev @@ -60,172 +326,271 @@ matrix: - p7zip-full - gcc-4.8 compiler: gcc-4.8 - env: GCC48=1 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_ASSETS) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=bionic-asset + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - _DPL_PACKAGE_MAIN=0 + - _DPL_PACKAGE_ASSET=1 + - PACKAGE_DISTRO=bionic + #- PACKAGE_SUBVERSION=~18.04bionic + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + + ################################ + # The below asset bots produce packages that occupy too much space. + # It would be nice if the asset files were not included in the source package itself, + # so these can deploy to each Ubuntu target without manual intervention. + # + # Currently, to get around Launchpad's space limitation, + # copy the packages from *one* bot and the space usage is not increased. + ################################ + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: trusty + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=trusty-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=trusty + # #- PACKAGE_SUBVERSION=~14.04trusty + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: xenial + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=disco-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=disco + # #- PACKAGE_SUBVERSION=~19.04disco + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: xenial + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=cosmic-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=cosmic + # #- PACKAGE_SUBVERSION=~18.10cosmic + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + # - os: linux + # addons: + # apt: + # packages: + # - libsdl2-mixer-dev + # - libpng-dev + # - libgl1-mesa-dev + # - libgme-dev + # - p7zip-full + # - gcc-4.8 + # compiler: gcc-4.8 + # dist: xenial + # if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + # AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + # AND env(DPL_TERMINATE_ASSETS) != "1" + # env: + # - _DPL_JOB_ENABLED=1 + # - _DPL_JOB_NAME=xenial-asset + # - _DPL_DPUT_TARGET=1 + # - _DPL_PACKAGE_SOURCE=1 + # - _DPL_PACKAGE_MAIN=0 + # - _DPL_PACKAGE_ASSET=1 + # - PACKAGE_DISTRO=xenial + # #- PACKAGE_SUBVERSION=~16.04xenial + # #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 + + +################################ +# Deployer Buildbots - Linux binaries +# List Ubuntu LTS, newest to oldest +# Then list non-LTS, newest to oldest +################################ + - os: linux + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' + packages: + - libsdl2-mixer-dev + - libpng-dev + - libgl1-mesa-dev + - libgme-dev + - libopenmpt-dev + - p7zip-full + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=eoan + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=eoan + - PACKAGE_SUBVERSION=~19.10eoan #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 - os: linux addons: apt: sources: - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - - gcc-7 - compiler: gcc-7 - env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1 - #gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802 + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=disco + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=disco + - PACKAGE_SUBVERSION=~19.04disco + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 - os: linux addons: apt: sources: - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - - gcc-8 - compiler: gcc-8 - env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow" GCC81=1 - #gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0 - - os: linux - compiler: clang - #clang version 3.5.0 (tags/RELEASE_350/final) + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=bionic + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=bionic + - PACKAGE_SUBVERSION=~18.04bionic + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 - os: linux addons: apt: sources: - - llvm-toolchain-precise-3.5 - packages: - - libsdl2-mixer-dev - - libpng-dev - - libgl1-mesa-dev - - libgme-dev - - p7zip-full - - clang-3.5 - compiler: clang-3.5 - #Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0) - - os: linux - addons: - apt: - sources: - - llvm-toolchain-precise-3.6 - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - - clang-3.6 - compiler: clang-3.6 - #Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2) + - gcc-4.8 + compiler: gcc-4.8 + dist: xenial + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=xenial + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=xenial + - PACKAGE_SUBVERSION=~16.04xenial + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 - os: linux addons: apt: sources: - - llvm-toolchain-precise-3.7 - ubuntu-toolchain-r-test + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - libopenmpt-dev - p7zip-full - - clang-3.7 - compiler: clang-3.7 - #Ubuntu clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1) - - os: linux - addons: - apt: - sources: - - llvm-toolchain-precise-3.8 - - ubuntu-toolchain-r-test - packages: - - libsdl2-mixer-dev - - libpng-dev - - libgl1-mesa-dev - - libgme-dev - - p7zip-full - - clang-3.8 - compiler: clang-3.8 - #clang version 3.8.1-svn271127-1~exp1 (branches/release_38) - - os: linux - addons: - apt: - sources: - - llvm-toolchain-precise-3.9 - - ubuntu-toolchain-r-test - packages: - - libsdl2-mixer-dev - - libpng-dev - - libgl1-mesa-dev - - libgme-dev - - p7zip-full - - clang-3.9 - compiler: clang-3.9 - #clang version 3.9.X -# - os: linux -# addons: -# apt: -# sources: -# - llvm-toolchain-precise-4.0 -# - ubuntu-toolchain-r-test -# packages: -# - libsdl2-mixer-dev -# - libpng-dev -# - libgl1-mesa-dev -# - libgme-dev -# - p7zip-full -# - clang-4.0 -# compiler: clang-4.0 -# #clang version 4.0.X -# - os: linux -# addons: -# apt: -# sources: -# - llvm-toolchain-precise-5.0 -# - ubuntu-toolchain-r-test -# packages: -# - libsdl2-mixer-dev -# - libpng-dev -# - libgl1-mesa-dev -# - libgme-dev -# - p7zip-full -# - clang-5.0 -# compiler: clang-5.0 -# #clang version 5.0.X -# - os: osx -# osx_image: beta-xcode6.1 -# #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) -# - os: osx -# osx_image: beta-xcode6.2 -# compiler: gcc -# #Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) -## - os: osx -## osx_image: beta-xcode6.3 -## #I think xcode.6.3 VM is broken, it does not boot -# - os: osx -# osx_image: xcode6.4 -# #Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) -# - os: osx -# osx_image: xcode7 -# #Apple LLVM version 7.0.0 (clang-700.0.72) -# - os: osx -# osx_image: xcode7.1 -# #Apple LLVM version 7.0.0 (clang-700.1.76) -# - os: osx -# osx_image: xcode7.2 -# #Apple LLVM version 7.0.2 (clang-700.1.81) -# - os: osx -# osx_image: xcode7.3 -# #Apple LLVM version 7.3.0 (clang-703.0.31) - - os: osx - #Default: macOS 10.13 and Xcode 9.4.1 + - gcc-4.8 + compiler: gcc-4.8 + dist: trusty + if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1") + AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1")) + AND env(DPL_TERMINATE_MAIN) != "1" + env: + - _DPL_JOB_ENABLED=1 + - _DPL_JOB_NAME=trusty + - _DPL_DPUT_TARGET=1 + - _DPL_PACKAGE_SOURCE=1 + - PACKAGE_DISTRO=trusty + - PACKAGE_SUBVERSION=~14.04trusty + #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5 allow_failures: - compiler: clang-3.5 - compiler: clang-3.6 @@ -235,19 +600,25 @@ matrix: - compiler: clang-4.0 - compiler: clang-5.0 + cache: apt: true ccache: true directories: - $HOME/srb2_cache + addons: apt: + sources: + - sourceline: 'ppa:stjr/srb2' packages: - libsdl2-mixer-dev - libpng-dev - libgl1-mesa-dev - libgme-dev + - zlib1g-dev + - libopenmpt-dev - p7zip-full homebrew: taps: @@ -256,22 +627,120 @@ addons: - sdl2_mixer - game-music-emu - p7zip + - libopenmpt - cmake update: true -before_script: - - wget --verbose --server-response -c http://rosenthalcastle.org/srb2/SRB2-v2115-assets-2.7z -O $HOME/srb2_cache/SRB2-v2115-assets-2.7z - - 7z x $HOME/srb2_cache/SRB2-v2115-assets-2.7z -oassets - - mkdir build - - cd build - - export CFLAGS="-Wall -W -Werror $WFLAGS" - - export CCACHE_COMPRESS=true - - cmake .. -DCMAKE_BUILD_TYPE=Release before_install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/release/SDL2-2.0.6.dmg; hdiutil attach SDL2-2.0.6.dmg; sudo cp -a /Volumes/SDL2/SDL2.framework /Library/Frameworks/; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -O -L https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.dmg; hdiutil attach SDL2_mixer-2.0.1.dmg; sudo cp -a /Volumes/SDL2_mixer/SDL2_mixer.framework /Library/Frameworks/; fi + # Initialize Deployer defaults + - . ./deployer/travis/deployer_defaults.sh + + # Initialize Deployer; check if Deployer is enabled + # This needs to be run in the current shell so that $__DPL_ACTIVE is set for this session + - . ./deployer/travis/deployer.sh + + # Also check if we should now terminate -- see `deployer.sh` for conditions. + # This should never happen on non-release buildbots when Deployer is not triggered. + - if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]]; then + if [[ "$__DPL_ACTIVE" != "1" ]]; then + echo "Exiting early because this job is not deploying."; + exit; + fi; + fi + + # If we're triggered by release tag, force ASSET_FILES_OPTIONAL_GET=1 + - if [[ "$__DPL_TAG_ELIGIBLE" = "1" ]]; then + ASSET_FILES_OPTIONAL_GET=1; + fi; + + +install: + # Install OS X library dependencies via Homebrew + # Do this differently for release buildbots: + # * `brew install --build-bottle` builds libraries for x86_64's lowest common denominator CPU, core2 + # * `sdl2_mixer` requires options from the formula tap https://github.com/mazmazz/homebrew-srb2 + # * `brew postinstall` runs post-install scripts after building a bottle + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + if [[ "$__DPL_ACTIVE" == "1" ]]; then + brew install --build-bottle sdl2 game-music-emu; + brew install --build-bottle mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123; + brew postinstall sdl2 game-music-emu mazmazz/srb2/sdl2_mixer; + fi; + fi - mkdir -p $HOME/srb2_cache -script: make -k + +before_script: + # OLDPWD is root repo folder + - OLDPWD=$PWD + - __ASSET_DIRECTORY="$OLDPWD/assets/installer" + - mkdir -p "$__ASSET_DIRECTORY" + - cd "$HOME/srb2_cache" + + # Get stat command so we know what the cached archive date is. + # stat is different for OSX + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + STATCMD="stat -f %m"; + else + STATCMD="stat -c %y"; + fi + + # Get asset files (required for MD5) + # See `deployer_defaults.sh` for asset download path + - if [[ "$ASSET_ARCHIVE_PATH" != "" ]]; then + if [ -f "$(basename $ASSET_ARCHIVE_PATH)" ]; then + echo "$(basename $ASSET_ARCHIVE_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_PATH))"; + fi; + wget --verbose --server-response -N "$ASSET_ARCHIVE_PATH"; + 7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$__ASSET_DIRECTORY" -aos; + fi; + + # Get optional files too + - if [[ "$__DPL_ACTIVE" == "1" ]] && [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]] && [[ "$ASSET_ARCHIVE_OPTIONAL_PATH" != "" ]]; then + if [ -f "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" ]; then + echo "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_OPTIONAL_PATH))"; + fi; + wget --verbose --server-response -N "$ASSET_ARCHIVE_OPTIONAL_PATH"; + 7z x "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" -o"$__ASSET_DIRECTORY" -aos; + fi; + + # Go back to root repo folder + - cd "$OLDPWD" + + # Prepare CMake asset lists + - SRB2_ASSET_HASHED=$(echo ${ASSET_FILES_HASHED// /\;}) + - SRB2_ASSET_DOCS=$(echo ${ASSET_FILES_DOCS// /\;}) + - SRB2_ASSET_DIRECTORY="$__ASSET_DIRECTORY" + + # Prepare CMake + - mkdir build + - cd build + - mkdir package + - export CFLAGS="-Wall -W -Werror $WFLAGS" + - export CCACHE_COMPRESS=true + # If OS X, set -march=core2 to build compatible binaries with old Macs + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + export CFLAGS="${CFLAGS} -march=core2"; + fi; + - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/bin -DCPACK_PACKAGE_DIRECTORY=$PWD/package + -DSRB2_ASSET_HASHED="${SRB2_ASSET_HASHED}" -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}" + -DSRB2_ASSET_DIRECTORY="${SRB2_ASSET_DIRECTORY}" + -DCPACK_PACKAGE_DESCRIPTION_SUMMARY="${PROGRAM_NAME}" + -DCPACK_PACKAGE_VENDOR="${PROGRAM_VENDOR}" + -DSRB2_SDL2_EXE_NAME="${PROGRAM_FILENAME}" + +script: + # Build our Makefile from Cmake! + - if [[ "$__DPL_ACTIVE" == "1" ]]; then + . ../deployer/travis/deployer_build.sh; + else + make -k; + fi; + +after_success: + # Run the upload scripts + # These do nothing if Deployer is not triggered + - . ../deployer/travis/deployer_ftp.sh + - . ../deployer/travis/deployer_dput.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a5507b92..abec11087 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.0) +# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string. +# Version change is fine. project(SRB2 - VERSION 2.1.23 + VERSION 2.2.2 LANGUAGES C) if(${PROJECT_SOURCE_DIR} MATCHES ${PROJECT_BINARY_DIR}) @@ -92,8 +94,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") # Set EXE names so the assets CMakeLists can refer to its target -set(SRB2_SDL2_EXE_NAME srb2) -set(SRB2_WIN_EXE_NAME srb2dd) +set(SRB2_SDL2_EXE_NAME srb2 CACHE STRING "Executable binary output name") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) @@ -122,8 +123,8 @@ if(${CMAKE_SYSTEM} MATCHES "Darwin") set(CPACK_GENERATOR "DragNDrop") endif() -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2") -set(CPACK_PACKAGE_VENDOR "Sonic Team Jr.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Sonic Robo Blast 2" CACHE STRING "Program name for display purposes") +set(CPACK_PACKAGE_VENDOR "Sonic Team Jr." CACHE STRING "Vendor name for display purposes") #set(CPACK_PACKAGE_DESCRIPTION_FILE ) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION_MAJOR ${SRB2_VERSION_MAJOR}) diff --git a/README.md b/README.md index 7d92ab303..8a5ca1a1f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ - SDL2-Mixer (Linux/OS X only) - libupnp (Linux/OS X only) - libgme (Linux/OS X only) +- libopenmpt (Linux/OS X only) ## Compiling diff --git a/appveyor.yml b/appveyor.yml index f0f843fbb..a28935f63 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,145 +1,141 @@ -version: 2.1.23.{branch}-{build} -os: MinGW - -environment: - CC: ccache - CCACHE_CC: i686-w64-mingw32-gcc - CCACHE_CC_64: x86_64-w64-mingw32-gcc - WINDRES: windres - # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead - MINGW_SDK: c:\msys64\mingw32 - # c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead - MINGW_SDK_64: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64 - CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn - NASM_ZIP: nasm-2.12.01 - NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip - UPX_ZIP: upx391w - UPX_URL: http://upx.sourceforge.net/download/upx391w.zip - CCACHE_EXE: ccache.exe - CCACHE_URL: http://alam.srb2.org/ccache.exe - CCACHE_COMPRESS: true - CCACHE_DIR: C:\Users\appveyor\.ccache - # Disable UPX by default. The user can override this in their Appveyor project settings - NOUPX: 1 - ############################## - # DEPLOYER VARIABLES - # DPL_ENABLED=1 builds installers for branch names starting with `deployer`. - # DPL_TAG_ENABLED=1 will also build installers for release tags. DPL_ENABLED=1 must also be set. - # Set these in the Appveyor project settings - ############################## - DPL_ENABLED: 0 - DPL_TAG_ENABLED: 0 - DPL_INSTALLER_NAME: SRB2-v2123 - # Asset handling is barebones vs. Travis Deployer. We operate on 7z only. - # Include the README files and the OpenGL batch in the main and patch archives. - # The x86/x64 archives contain the DLL binaries. - ASSET_ARCHIVE_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-assets.7z - ASSET_ARCHIVE_PATCH_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-patch-assets.7z - ASSET_ARCHIVE_X86_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-x86-assets.7z - ASSET_ARCHIVE_X64_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-x64-assets.7z - ASSET_ARCHIVE_OPTIONAL_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets/SRB2-v2122-optional-assets.7z - # This is overridden to 1 for release tag builds - ASSET_FILES_OPTIONAL_GET: 0 - # For patches, also include the X86/X64 DLLs. - PACKAGE_PATCH_DLL_GET: 0 - # Delete all asset downloads so they can be redownloaded - ASSET_CLEAN: 0 - -cache: -- nasm-2.12.01.zip -- upx391w.zip -- ccache.exe -- C:\Users\appveyor\.ccache -- C:\Users\appveyor\srb2_cache - -install: -- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" ) -- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" ) -- if [%CONFIGURATION%] == [DD64] ( set "X86_64=1" ) -- if [%CONFIGURATION%] == [DD64] ( set "CONFIGURATION=DD" ) -- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" ) -- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" ) - -- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip" -- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null -- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0 - -- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip" -- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null -- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0 - -- if not exist "%CCACHE_EXE%" appveyor DownloadFile "%CCACHE_URL%" -FileName "%CCACHE_EXE%" -- ccache -M 99M -- xcopy /Y /V /I ccache.exe "%MINGW_SDK%\bin" - -configuration: -- SDL -- SDL64 -- DD -- DD64 - -matrix: - allow_failures: - - configuration: DD - - configuration: DD64 - -before_build: -- set "Path=%MINGW_SDK%\bin;%Path%" -- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version ) -- mingw32-make --version -- if not [%X86_64%] == [1] ( nasm -v ) -- if not [%NOUPX%] == [1] ( upx -V ) -- ccache -V -- ccache -s -- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" ) -- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 GCC72=1 NOOBJDUMP=1 %NOUPX%" -- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1" ) else ( set "MINGW_FLAGS=MINGW=1" ) -- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" - -build_script: -- cmd: mingw32-make.exe %SRB2_MFLAGS% clean -- cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k - -after_build: -- if [%X86_64%] == [1] ( - set "BUILD_PATH=bin\Mingw64\Release" - ) else ( - set "BUILD_PATH=bin\Mingw\Release" - ) -- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" ) -- ccache -s -- cmd: git rev-parse --short %APPVEYOR_REPO_COMMIT%>%TMP%/gitshort.txt -- cmd: set /P GITSHORT=<%TMP%/gitshort.txt -- set BUILD_ARCHIVE=%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%.7z -- set BUILDSARCHIVE=%APPVEYOR_REPO_BRANCH%-%CONFIGURATION%.7z -- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore -- appveyor PushArtifact %BUILD_ARCHIVE% -- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE% -- appveyor PushArtifact %BUILDSARCHIVE% -############################## -# DEPLOYER SCRIPT -############################## -- if [%DPL_ENABLED%] == [1] ( call "deployer\appveyor\deployer.bat" ) - -test: off - -#deploy: -# - provider: FTP -# protocol: ftps -# host: -# secure: NsLJEPIBvmwCOj8Tg8RoRQ== -# username: -# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA= -# password: -# secure: Hbn6Uy3lT0YZ88yFJ3aW4w== -# folder: appveyor -# application: -# active_mode: false -# on: -# branch: master -# appveyor_repo_tag: true - - -on_finish: -#- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:: -#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +version: 2.2.2.{branch}-{build} +os: MinGW + +environment: + CC: ccache + CCACHE_CC: i686-w64-mingw32-gcc + CCACHE_CC_64: x86_64-w64-mingw32-gcc + WINDRES: windres + # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead + MINGW_SDK: c:\msys64\mingw32 + # c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead + MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64 + CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn + NASM_ZIP: nasm-2.12.01 + NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip + UPX_ZIP: upx391w + UPX_URL: http://upx.sourceforge.net/download/upx391w.zip + CCACHE_EXE: ccache.exe + CCACHE_URL: http://alam.srb2.org/ccache.exe + CCACHE_COMPRESS: true + CCACHE_DIR: C:\Users\appveyor\.ccache + # Disable UPX by default. The user can override this in their Appveyor project settings + NOUPX: 1 + ############################## + # DEPLOYER VARIABLES + # DPL_ENABLED=1 builds installers for branch names starting with `deployer`. + # DPL_TAG_ENABLED=1 will also build installers for release tags. DPL_ENABLED=1 must also be set. + # Set these in the Appveyor project settings + ############################## + DPL_ENABLED: 0 + DPL_TAG_ENABLED: 0 + DPL_INSTALLER_NAME: SRB2-v220 + # Asset handling is barebones vs. Travis Deployer. We operate on 7z only. + # Include the README files and the OpenGL batch in the main and patch archives. + # The x86/x64 archives contain the DLL binaries. + ASSET_ARCHIVE_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-assets.7z + ASSET_ARCHIVE_PATCH_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-patch-assets.7z + ASSET_ARCHIVE_X86_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-x86-assets.7z + ASSET_ARCHIVE_X64_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-x64-assets.7z + ASSET_ARCHIVE_OPTIONAL_PATH: https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-optional-assets.7z + # This is overridden to 1 for release tag builds + ASSET_FILES_OPTIONAL_GET: 0 + # For patches, also include the X86/X64 DLLs. + PACKAGE_PATCH_DLL_GET: 0 + # Delete all asset downloads so they can be redownloaded + ASSET_CLEAN: 0 + +cache: +- nasm-2.12.01.zip +- upx391w.zip +- ccache.exe +- C:\Users\appveyor\.ccache +- C:\Users\appveyor\srb2_cache + +install: +- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" ) +- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" ) +- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" ) +- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" ) + +- if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip" +- 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null +- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0 + +- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip" +- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null +- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0 + +- if not exist "%CCACHE_EXE%" appveyor DownloadFile "%CCACHE_URL%" -FileName "%CCACHE_EXE%" +- ccache -M 99M +- xcopy /Y /V /I ccache.exe "%MINGW_SDK%\bin" + +configuration: +- SDL +- SDL64 + +before_build: +- set "Path=%MINGW_SDK%\bin;%Path%" +- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version ) +- mingw32-make --version +- if not [%X86_64%] == [1] ( nasm -v ) +- if not [%NOUPX%] == [1] ( upx -V ) +- ccache -V +- ccache -s +- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" ) +- if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" ) +- cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt +- cmd: set /P GITSHORT=<%TMP%/gitshort.txt +# for pull requests, take the owner's name only, if this isn't the same repo of course +- set "REPO=%APPVEYOR_REPO_BRANCH%" +- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) ) +- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe" +- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%" +- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" ) +- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" + +build_script: +- cmd: mingw32-make.exe %SRB2_MFLAGS% clean +- cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k + +after_build: +- if [%X86_64%] == [1] ( + set "BUILD_PATH=bin\Mingw64\Release" + ) else ( + set "BUILD_PATH=bin\Mingw\Release" + ) +- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" ) +- ccache -s +- set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z +- set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z +- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore +- appveyor PushArtifact %BUILD_ARCHIVE% +- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE% +- appveyor PushArtifact %BUILDSARCHIVE% +############################## +# DEPLOYER SCRIPT +############################## +- if [%DPL_ENABLED%] == [1] ( call "deployer\appveyor\deployer.bat" ) + +test: off + +#deploy: +# - provider: FTP +# protocol: ftps +# host: +# secure: NsLJEPIBvmwCOj8Tg8RoRQ== +# username: +# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA= +# password: +# secure: Hbn6Uy3lT0YZ88yFJ3aW4w== +# folder: appveyor +# application: +# active_mode: false +# on: +# branch: master +# appveyor_repo_tag: true + + +on_finish: +#- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:: +#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) diff --git a/assets/.gitignore b/assets/.gitignore index 9ed61ca1a..d6e46a75b 100644 --- a/assets/.gitignore +++ b/assets/.gitignore @@ -1,5 +1,10 @@ -* -*.* +*.srb +*.pk3 +*.dta +*.wad +*.txt !README.txt !LICENSE.txt -!LICENSE-3RD-PARTY.txt \ No newline at end of file +!LICENSE-3RD-PARTY.txt +!CMakeLists.txt +!debian-template/* diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index 6edb3df13..095349418 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,40 +1,62 @@ ## Assets Target Configuration ## -# MD5 generation -set(SRB2_ASSET_ALL - ${CMAKE_CURRENT_SOURCE_DIR}/srb2.srb - ${CMAKE_CURRENT_SOURCE_DIR}/player.dta - ${CMAKE_CURRENT_SOURCE_DIR}/rings.dta - ${CMAKE_CURRENT_SOURCE_DIR}/zones.dta - ${CMAKE_CURRENT_SOURCE_DIR}/patch.dta - ${CMAKE_CURRENT_SOURCE_DIR}/music.dta - ${CMAKE_CURRENT_SOURCE_DIR}/README.txt - ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt - ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE-3RD-PARTY.txt -) +# For prepending the current source path, later +FUNCTION(PREPEND var prefix) + SET(listVar "") + FOREACH(f ${ARGN}) + LIST(APPEND listVar "${prefix}/${f}") + ENDFOREACH(f) + SET(${var} "${listVar}" PARENT_SCOPE) +ENDFUNCTION(PREPEND) + +set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" + CACHE STRING "Path to directory that contains all asset files for the installer.") + +#################### +# POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list! +#################### set(SRB2_ASSET_HASHED - srb2.srb - player.dta - rings.dta - zones.dta - patch.dta +"srb2.pk3;\ +player.dta;\ +zones.pk3;\ +patch.pk3" + CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" ) +set(SRB2_ASSET_DOCS +"README.txt;\ +LICENSE.txt;\ +LICENSE-3RD-PARTY.txt;\ +README-SDL.txt" + CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!" +) + +PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS}) + foreach(SRB2_ASSET ${SRB2_ASSET_HASHED}) - file(MD5 ${CMAKE_CURRENT_SOURCE_DIR}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") + file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE) endforeach() # Installation -if(CLANG) +if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - install(FILES ${SRB2_ASSET_ALL} + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" DESTINATION "${outname}.app/Contents/Resources" ) + install(FILES ${SRB2_ASSET_DOCS} + DESTINATION . + OPTIONAL + ) else() - install(FILES ${SRB2_ASSET_ALL} + install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" DESTINATION . ) + # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install again + #install(FILES ${SRB2_ASSET_DOCS} + # DESTINATION . + # OPTIONAL + #) endif() diff --git a/assets/README.txt b/assets/README.txt index 37f7d8f29..8d2fefa54 100644 --- a/assets/README.txt +++ b/assets/README.txt @@ -34,11 +34,11 @@ SRB2 Message Board: https://mb.srb2.org SRB2 Official Discord: -https://discord.gg/pYDXzpX +https://discord.gg/pYDXzpX (13+) COPYRIGHT AND DISCLAIMER -Design and content on SRB2 is copyright 1998-2018 by Sonic Team Junior. +Design and content on SRB2 is copyright 1998-2019 by Sonic Team Junior. All non-original material on SRB2.ORG is copyrighted by their respective owners, and no copyright infringement is intended. The owner of the SRB2.ORG domain is only acting as an ISP, and is therefore not diff --git a/assets/debian/README.Debian b/assets/debian-template/README.Debian similarity index 59% rename from assets/debian/README.Debian rename to assets/debian-template/README.Debian index 68c952a4e..f3fe90030 100644 --- a/assets/debian/README.Debian +++ b/assets/debian-template/README.Debian @@ -12,9 +12,39 @@ with apt-key add. Thanks! -- Callum Dickinson Fri, 26 Nov 2010 18:25:31 +1300 +--------------- + + +Templating + +Note that you MUST run [repo-root]/debian_template.sh before running debuild +on these scripts! debian_template.sh fills these template files with working values. + +You should also set PACKAGE_NAME_EMAIL="John Doe " to match +the identity of the key you will use to sign the package. + + +Building for Launchpad PPA + +Run this step first: + + 1. source [repo-root]/debian_template.sh + * Initializes defaults for the package variables and fills in templates. + +Use these steps to prepare building a source package for Launchpad: + + 1. cd [repo-root]/assets/ + 2. debuild -T clean-all (optional; if you already have asset files, this clears them) + +Build the source package: + + 1. debuild -T build (this downloads the asset files from srb2.org if necessary) + 2. debuild -S (builds the source package for Launchpad, including the asset files) + + Signing for Launchpad PPA -First, follow the above instructions to generate a GnuPG key with your identity. You will need +First, follow Callum's instructions to generate a GnuPG key with your identity. You will need to publish the fingerprint of that key to Ubuntu's key server. https://help.ubuntu.com/community/GnuPrivacyGuardHowto#Uploading_the_key_to_Ubuntu_keyserver @@ -26,22 +56,18 @@ upload signed source packages and publish them onto your PPA. IF YOU UPLOAD A PACKAGE and Launchpad does NOT send you a confirmation or rejection email, that means your key is not set up correctly with your Launchpad account. +Finally, if your packages have not already been signed, follow these steps: -Building for Launchpad PPA + 1. cd .. + * Packages are located in the parent folder of where debuild was called + 2. debsign "srb2-data_[version]_source.changes" + * You may need to specify -k [key-fingerprint] -Use these steps to prepare building a source package for Launchpad: - 1. Highly recommend copying the assets/ folder to outside your repo folder, or else the asset - files may be included in the main source package, when you build that. - 2. cd [wherever-your-assets-folder-is]/assets/ - 3. debuild -T clean (optional, if you already have asset files) +Uploading for Launchpad PPA -Building the source package is a two-step process: - - 1. debuild -T build (this downloads the asset files from srb2.org if necessary) - 2. debuild -S (builds the source package for Launchpad, including the asset files) - -Then follow the instructions at to upload +Follow the instructions at to upload to your PPA and have Launchpad build your binary deb packages. + -- Marco Zafra Mon, 26 Nov 2018 21:13:00 -0500 diff --git a/assets/debian/README.source b/assets/debian-template/README.source similarity index 100% rename from assets/debian/README.source rename to assets/debian-template/README.source diff --git a/assets/debian-template/changelog b/assets/debian-template/changelog new file mode 100644 index 000000000..64562e2a3 --- /dev/null +++ b/assets/debian-template/changelog @@ -0,0 +1,5 @@ +${PACKAGE_NAME}-data (${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}) ${PACKAGE_DISTRO}; urgency=${PACKAGE_URGENCY} + + * ${PROGRAM_NAME} v${PROGRAM_VERSION} asset data + + -- ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} diff --git a/assets/debian/compat b/assets/debian-template/compat similarity index 100% rename from assets/debian/compat rename to assets/debian-template/compat diff --git a/assets/debian/control b/assets/debian-template/control similarity index 84% rename from assets/debian/control rename to assets/debian-template/control index 22d9643ee..ae5c0ce67 100644 --- a/assets/debian/control +++ b/assets/debian-template/control @@ -1,15 +1,15 @@ # SRB2-data Debian package control file. -Source: srb2-data +Source: ${PACKAGE_NAME}-data Section: games Priority: extra -Maintainer: Sonic Team Junior +Maintainer: ${PACKAGE_GROUP_NAME_EMAIL} Build-Depends: debhelper (>= 7.0.50~), wget Standards-Version: 3.8.4 -Homepage: http://www.srb2.org +Homepage: ${PACKAGE_WEBSITE} -Package: srb2-data +Package: ${PACKAGE_NAME}-data Architecture: all Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog diff --git a/debian/copyright b/assets/debian-template/copyright similarity index 57% rename from debian/copyright rename to assets/debian-template/copyright index 97d606b0f..cc47c453b 100644 --- a/debian/copyright +++ b/assets/debian-template/copyright @@ -1,18 +1,18 @@ This work was packaged for Debian by: - Marco Zafra Mon, 26 Nov 2018 14:31:00 -0500 + ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} It was downloaded from: - + ${PACKAGE_WEBSITE} Upstream Author(s): - Sonic Team Junior + ${PACKAGE_GROUP_NAME_EMAIL} Copyright: - Copyright (C) 1998-2018 Sonic Team Junior + Copyright (C) 1998-2018 by Sonic Team Junior License: @@ -21,7 +21,7 @@ License: The Debian packaging is: Copyright (C) 2010 Callum Dickinson - Copyright (C) 2010-2018 Sonic Team Junior + Copyright (C) 2010-2018 by Sonic Team Junior and is licensed under the GPL version 2, see "/usr/share/common-licenses/GPL-2". diff --git a/assets/debian/rules b/assets/debian-template/rules old mode 100755 new mode 100644 similarity index 70% rename from assets/debian/rules rename to assets/debian-template/rules index a34a3393f..c2d19922d --- a/assets/debian/rules +++ b/assets/debian-template/rules @@ -23,6 +23,16 @@ # ############################################################################# +############################################################################# +# +# !!!!!!!!!! DEPLOYER NOTE !!!!!!!!!! +# +# Variables to be templated are curly-braced ${PACKAGE_INSTALL_PATH} +# Variables used by the rules script are parenthese'd $(DATADIR) +# See [repo-root]/debian_template.sh +# +############################################################################# + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 @@ -37,30 +47,32 @@ RM := rm -rf DIR := $(shell pwd) PACKAGE := $(shell cat $(DIR)/debian/control | grep 'Package:' | sed -e 's/Package: //g') -DATAFILES := srb2.srb zones.dta player.dta rings.dta music.dta patch.dta README.txt LICENSE.txt LICENSE-3RD-PARTY.txt +ARCHIVEPATH := ${ASSET_ARCHIVE_PATH} +ARCHIVEOPTIONALPATH := ${ASSET_ARCHIVE_OPTIONAL_PATH} +GETOPTIONALFILES := ${ASSET_FILES_OPTIONAL_GET} -DATADIR := usr/games/SRB2 +DATADIR := $(shell echo "${PACKAGE_INSTALL_PATH}" | sed -e 's/^\///') RESOURCEDIR := . +STAGINGDIR := $(RESOURCEDIR)/installer WGET := wget -P $(RESOURCEDIR) -c -nc build: $(MKDIR) $(DIR)/debian/tmp/$(DATADIR) > $(DIR)/debian/source/include-binaries - # This will need to be updated every time SRB2 official version is # Copy data files to their install locations, and add data files to include-binaries - for file in $(DATAFILES); do \ - if [ ! -f $(RESOURCEDIR)/$$file ]; then \ - $(WGET) http://alam.srb2.org/SRB2/2.1.21-Final/Resources/$$file; \ + if [ ! -d $(STAGINGDIR) ]; then \ + mkdir -p "$(STAGINGDIR)"; \ + $(WGET) $(ARCHIVEPATH); \ + 7z x "$(RESOURCEDIR)/$(shell basename $(ARCHIVEPATH))" -aos; \ + if [ "$(GETOPTIONALFILES)" = "1" ]; then \ + $(WGET) $(ARCHIVEOPTIONALPATH); \ + 7z x "$(RESOURCEDIR)/$(shell basename $(ARCHIVEOPTIONALPATH))" -aos; \ fi; \ - if [ -f $(RESOURCEDIR)/$$file ]; then \ - $(INSTALL) $(RESOURCEDIR)/$$file $(DIR)/debian/tmp/$(DATADIR)/$$file; \ - echo $(RESOURCEDIR)/$$file >> $(DIR)/debian/source/include-binaries; \ - fi; \ - if [ ! -f $(DIR)/debian/tmp/$(DATADIR)/$$file ]; then \ - echo $(DIR)/debian/tmp/$(DATADIR)/$$file not found and could not be downloaded!; \ - return 1; \ - fi; \ - done + fi + # Install asset directory and add asset file to include-binaries + cp -vr "$(STAGINGDIR)/." "$(DIR)/debian/tmp/$(DATADIR)" + find "$(STAGINGDIR)" >> $(DIR)/debian/source/include-binaries + binary-indep: # Generate install folder file diff --git a/assets/debian/source/format b/assets/debian-template/source/format similarity index 100% rename from assets/debian/source/format rename to assets/debian-template/source/format diff --git a/assets/debian/source/options b/assets/debian-template/source/options similarity index 100% rename from assets/debian/source/options rename to assets/debian-template/source/options diff --git a/assets/debian/changelog b/assets/debian/changelog deleted file mode 100644 index f3a92e1cd..000000000 --- a/assets/debian/changelog +++ /dev/null @@ -1,19 +0,0 @@ -srb2-data (2.1.21~7) trusty; urgency=high - - * Updated for SRB2 v2.1.21 - - -- Marco Zafra Mon, 26 Nov 2018 14:31:00 -0500 - - -srb2-data (2.1.14~1) unstable; urgency=low - - * Updated for SRB2 v2.1.14 - - -- Alam Arias Sat, 6 Jan 2016 11:00:00 -0500 - - -srb2-data (2.0.6-2) maverick; urgency=high - - * Initial proper release.. - - -- Callum Dickinson Sat, 29 Jan 2011 01:18:42 +1300 diff --git a/bin/DC/.gitignore b/bin/DC/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/DC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/Mingw/Release/.gitignore b/bin/Mingw/Release/.gitignore index 834f313e3..3458ff764 100644 --- a/bin/Mingw/Release/.gitignore +++ b/bin/Mingw/Release/.gitignore @@ -1,3 +1,4 @@ *.exe *.mo r_opengl.dll +*.bat diff --git a/bin/PS3/Debug/.gitignore b/bin/PS3/Debug/.gitignore deleted file mode 100644 index c4dcd19e5..000000000 --- a/bin/PS3/Debug/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/*.elf -/*.self -/*.pkg -/*.BIN -/pkg diff --git a/bin/PS3/Release/.gitignore b/bin/PS3/Release/.gitignore deleted file mode 100644 index c4dcd19e5..000000000 --- a/bin/PS3/Release/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -/*.elf -/*.self -/*.pkg -/*.BIN -/pkg diff --git a/bin/PSP/Release/.gitignore b/bin/PSP/Release/.gitignore deleted file mode 100644 index 98d08e695..000000000 --- a/bin/PSP/Release/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/EBOOT.PBP -/PARAM.SFO -/SRB2PSP.PBP -/SRB2PSP.elf diff --git a/bin/Wii/Debug/.gitignore b/bin/Wii/Debug/.gitignore deleted file mode 100644 index 200eea51f..000000000 --- a/bin/Wii/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/*.elf -/*.dol -/apps diff --git a/bin/Wii/Release/.gitignore b/bin/Wii/Release/.gitignore deleted file mode 100644 index 200eea51f..000000000 --- a/bin/Wii/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/*.elf -/*.dol -/apps diff --git a/bin/WinCE/ARMV4Dbg/.gitignore b/bin/WinCE/ARMV4Dbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/ARMV4Dbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4IDbg/.gitignore b/bin/WinCE/ARMV4IDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/ARMV4IDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4IRel/.gitignore b/bin/WinCE/ARMV4IRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/ARMV4IRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4Rel/.gitignore b/bin/WinCE/ARMV4Rel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/ARMV4Rel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4TDbg/.gitignore b/bin/WinCE/ARMV4TDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/ARMV4TDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/ARMV4TRel/.gitignore b/bin/WinCE/ARMV4TRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/ARMV4TRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPS16Dbg/.gitignore b/bin/WinCE/MIPS16Dbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPS16Dbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPS16Rel/.gitignore b/bin/WinCE/MIPS16Rel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPS16Rel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIIDbg/.gitignore b/bin/WinCE/MIPSIIDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSIIDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIIRel/.gitignore b/bin/WinCE/MIPSIIRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSIIRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSII_FPDbg/.gitignore b/bin/WinCE/MIPSII_FPDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSII_FPDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSII_FPRel/.gitignore b/bin/WinCE/MIPSII_FPRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSII_FPRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIVDbg/.gitignore b/bin/WinCE/MIPSIVDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSIVDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIVRel/.gitignore b/bin/WinCE/MIPSIVRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSIVRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIV_FPDbg/.gitignore b/bin/WinCE/MIPSIV_FPDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSIV_FPDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/MIPSIV_FPRel/.gitignore b/bin/WinCE/MIPSIV_FPRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/MIPSIV_FPRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/Release/.gitignore b/bin/WinCE/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/SH3Dbg/.gitignore b/bin/WinCE/SH3Dbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/SH3Dbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/SH3Rel/.gitignore b/bin/WinCE/SH3Rel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/SH3Rel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/SH4Dbg/.gitignore b/bin/WinCE/SH4Dbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/SH4Dbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/SH4Rel/.gitignore b/bin/WinCE/SH4Rel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/SH4Rel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/X86Dbg/.gitignore b/bin/WinCE/X86Dbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/X86Dbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/X86Rel/.gitignore b/bin/WinCE/X86Rel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/X86Rel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/emulatorDbg/.gitignore b/bin/WinCE/emulatorDbg/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/emulatorDbg/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/WinCE/emulatorRel/.gitignore b/bin/WinCE/emulatorRel/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/WinCE/emulatorRel/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/nds/Debug/.gitignore b/bin/nds/Debug/.gitignore deleted file mode 100644 index 9bfc4a51d..000000000 --- a/bin/nds/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.arm9 -*.elf* -*.nds diff --git a/bin/nds/Release/.gitignore b/bin/nds/Release/.gitignore deleted file mode 100644 index 9bfc4a51d..000000000 --- a/bin/nds/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.arm9 -*.elf* -*.nds diff --git a/cmake/Modules/FindOPENMPT.cmake b/cmake/Modules/FindOPENMPT.cmake new file mode 100644 index 000000000..2d334b6f0 --- /dev/null +++ b/cmake/Modules/FindOPENMPT.cmake @@ -0,0 +1,23 @@ +include(LibFindMacros) + +libfind_pkg_check_modules(OPENMPT_PKGCONF OPENMPT) + +find_path(OPENMPT_INCLUDE_DIR + NAMES libopenmpt.h + PATHS + ${OPENMPT_PKGCONF_INCLUDE_DIRS} + "/usr/include/libopenmpt" + "/usr/local/include/libopenmpt" +) + +find_library(OPENMPT_LIBRARY + NAMES openmpt + PATHS + ${OPENMPT_PKGCONF_LIBRARY_DIRS} + "/usr/lib" + "/usr/local/lib" +) + +set(OPENMPT_PROCESS_INCLUDES OPENMPT_INCLUDE_DIR) +set(OPENMPT_PROCESS_LIBS OPENMPT_LIBRARY) +libfind_process(OPENMPT) \ No newline at end of file diff --git a/debian/README.Debian b/debian-template/README.Debian similarity index 62% rename from debian/README.Debian rename to debian-template/README.Debian index 4b724816e..3aa52787e 100644 --- a/debian/README.Debian +++ b/debian-template/README.Debian @@ -10,10 +10,38 @@ and give them to your users to install with apt-key add. Thanks! -- Callum Dickinson Fri, 26 Nov 2010 18:25:31 +1300 +--------------- + + +Templating + +Note that you MUST run [repo-root]/debian_template.sh before running debuild +on these scripts! debian_template.sh fills these template files with working values. + +You should also set PACKAGE_NAME_EMAIL="John Doe " to match +the identity of the key you will use to sign the package. + + +Building for Launchpad PPA + +Use these steps to prepare building a source package for Launchpad: + + 1. cd [repo-root] + 2. git reset --hard; git clean -fd; git clean -fx; + * Resets your repo folder to a committed state and removes untracked files + * If you built srb2-data in the assets/ folder, MAKE SURE THAT FOLDER DOES NOT HAVE ASSETS, + OR THEY MAY BE INCLUDED IN THE MAIN SOURCE PACKAGE! + +Build the source package: + + 1. source [repo-root]/debian_template.sh + * Initializes defaults for the package variables and fills in templates. + 2. debuild -S (builds the source package for Launchpad) + Signing for Launchpad PPA -First, follow the above instructions to generate a GnuPG key with your identity. You will need +First, follow Callum's instructions to generate a GnuPG key with your identity. You will need to publish the fingerprint of that key to Ubuntu's key server. https://help.ubuntu.com/community/GnuPrivacyGuardHowto#Uploading_the_key_to_Ubuntu_keyserver @@ -25,22 +53,18 @@ upload signed source packages and publish them onto your PPA. IF YOU UPLOAD A PACKAGE and Launchpad does NOT send you a confirmation or rejection email, that means your key is not set up correctly with your Launchpad account. +Finally, if your packages have not already been signed, follow these steps: -Building for Launchpad PPA + 1. cd .. + * Packages are located in the parent folder of where debuild was called + 2. debsign "srb2_[version]_source.changes" + * You may need to specify -k [key-fingerprint] -Use these steps to prepare building a source package for Launchpad: - 1. cd [srb2repo] - 2. git reset --hard; git clean -fd; git clean -fx; - * Resets your repo folder to a committed state and removes untracked files - * If you built srb2-data in the assets/ folder, MAKE SURE THAT FOLDER DOES NOT HAVE ASSETS, - OR THEY MAY BE INCLUDED IN THE MAIN SOURCE PACKAGE! +Uploading for Launchpad PPA -Building the source package takes just one step: - - 1. debuild -S (builds the source package for Launchpad) - -Then follow the instructions at to upload +Follow the instructions at to upload to your PPA and have Launchpad build your binary deb packages. + -- Marco Zafra Mon, 26 Nov 2018 21:13:00 -0500 diff --git a/debian/README.source b/debian-template/README.source similarity index 100% rename from debian/README.source rename to debian-template/README.source diff --git a/debian-template/changelog b/debian-template/changelog new file mode 100644 index 000000000..fb08908cd --- /dev/null +++ b/debian-template/changelog @@ -0,0 +1,5 @@ +${PACKAGE_NAME} (${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}) ${PACKAGE_DISTRO}; urgency=${PACKAGE_URGENCY} + + * ${PROGRAM_NAME} v${PROGRAM_VERSION} program build + + -- ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} diff --git a/debian/compat b/debian-template/compat similarity index 100% rename from debian/compat rename to debian-template/compat diff --git a/debian/control b/debian-template/control similarity index 64% rename from debian/control rename to debian-template/control index 0f2d8062b..74d11ae90 100644 --- a/debian/control +++ b/debian-template/control @@ -1,24 +1,32 @@ # SRB2 Debian package control file. -Source: srb2 +Source: ${PACKAGE_NAME} Section: games Priority: extra -Maintainer: Sonic Team Junior +Maintainer: ${PACKAGE_GROUP_NAME_EMAIL} Build-Depends: debhelper (>= 7.0.50~), libsdl2-dev, libsdl2-mixer-dev, - libpng12-dev (>= 1.2.7) | libpng-dev, + libpng-dev | libpng16-dev | libpng12-dev (>= 1.2.7), zlib1g-dev, libgme-dev, + libopenmpt-dev, libglu1-dev | libglu-dev, libosmesa6-dev | libgl-dev, nasm [i386] Standards-Version: 3.8.4 -Homepage: http://www.srb2.org +Homepage: ${PACKAGE_WEBSITE} -Package: srb2 +Package: ${PACKAGE_NAME} Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.23) +Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS}, + ${PACKAGE_NAME}-data (>> ${PACKAGE_ASSET_MINVERSION}), ${PACKAGE_NAME}-data (<< ${PACKAGE_ASSET_MAXVERSION}), + libsdl2-2.0-0, + libsdl2-mixer-2.0-0, + zlib1g, + libgme0, + libopenmpt | libopenmpt0, + libpng | libpng16-16 | libpng12-0 Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame built using a modified version of the Doom Legacy @@ -28,10 +36,10 @@ Description: A cross-platform 3D Sonic fangame and quite a lot of the fun that the original Sonic games provided. -Package: srb2-dbg +Package: ${PACKAGE_NAME}-dbg Architecture: any -# FIXME: should be Depends: ${shlibs:Depends}, ${misc:Depends}, srb2-data (= 2.1.14), srb2 but dh_shlibdeps is being an asshat -Depends: libc6, ${misc:Depends}, srb2-data (>= 2.1.15), srb2-data (<= 2.1.23), srb2 +# FIXME: should be Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS}, srb2-data (= 2.1.14), srb2 but dh_shlibdeps is being an asshat +Depends: libc6, ${MISC_DEPENDS}, ${PACKAGE_NAME}-data (>> ${PACKAGE_ASSET_MINVERSION}), ${PACKAGE_NAME}-data (<< ${PACKAGE_ASSET_MAXVERSION}), ${PACKAGE_NAME} Description: A cross-platform 3D Sonic fangame Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog fangame built using a modified version of the Doom Legacy diff --git a/assets/debian/copyright b/debian-template/copyright similarity index 57% rename from assets/debian/copyright rename to debian-template/copyright index 97d606b0f..cc47c453b 100644 --- a/assets/debian/copyright +++ b/debian-template/copyright @@ -1,18 +1,18 @@ This work was packaged for Debian by: - Marco Zafra Mon, 26 Nov 2018 14:31:00 -0500 + ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME} It was downloaded from: - + ${PACKAGE_WEBSITE} Upstream Author(s): - Sonic Team Junior + ${PACKAGE_GROUP_NAME_EMAIL} Copyright: - Copyright (C) 1998-2018 Sonic Team Junior + Copyright (C) 1998-2018 by Sonic Team Junior License: @@ -21,7 +21,7 @@ License: The Debian packaging is: Copyright (C) 2010 Callum Dickinson - Copyright (C) 2010-2018 Sonic Team Junior + Copyright (C) 2010-2018 by Sonic Team Junior and is licensed under the GPL version 2, see "/usr/share/common-licenses/GPL-2". diff --git a/debian/docs b/debian-template/docs similarity index 100% rename from debian/docs rename to debian-template/docs diff --git a/debian/rules b/debian-template/rules old mode 100755 new mode 100644 similarity index 87% rename from debian/rules rename to debian-template/rules index ff80d50bf..0a77624cb --- a/debian/rules +++ b/debian-template/rules @@ -23,6 +23,16 @@ # ############################################################################# +############################################################################# +# +# !!!!!!!!!! DEPLOYER NOTE !!!!!!!!!! +# +# Variables to be templated are curly-braced ${PACKAGE_INSTALL_PATH} +# Variables used by the rules script are parenthese'd $(PKGDIR) +# See [repo-root]/debian_template.sh +# +############################################################################# + # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 @@ -50,16 +60,16 @@ DIR := $(shell pwd) # FIXME: hate hate hate head/tail hack :( CONTROLF = $(DIR)/debian/control -PACKAGE = srb2 -DBGPKG = $(PACKAGE)-dbg -TITLE = Sonic Robo Blast 2 +PACKAGE = ${PACKAGE_NAME} +DBGPKG = ${PACKAGE}-dbg +TITLE = ${PROGRAM_NAME} SECTION = Games/Action -EXENAME = srb2 +EXENAME = ${PROGRAM_FILENAME} DBGNAME = debug/$(EXENAME) -PKGDIR = usr/games/SRB2 +PKGDIR = $(shell echo "${PACKAGE_INSTALL_PATH}" | sed -e 's/^\///') DBGDIR = usr/lib/debug/$(PKGDIR) -LINKDIR = usr/games +LINKDIR = $(shell echo "${PACKAGE_LINK_PATH}" | sed -e 's/^\///') PIXMAPS_DIR = usr/share/pixmaps DESKTOP_DIR = usr/share/applications PREFIX = $(shell test "$(CROSS_COMPILE_BUILD)" != "$(CROSS_COMPILE_HOST)" && echo "PREFIX=$(CROSS_COMPILE_HOST)") @@ -102,8 +112,8 @@ binary-arch: $(INSTALL) $(BINDIR)/$(EXENAME) $(DIR)/debian/tmp/$(PKGDIR)/$(PACKAGE) $(INSTALL) $(BINDIR)/$(DBGNAME) $(DIR)/debian/tmp/$(DBGDIR)/$(PACKAGE) # Install desktop file and banner image - $(INSTALL) $(DIR)/srb2.png $(DIR)/debian/tmp/usr/share/pixmaps - $(INSTALL) $(DIR)/debian/srb2.desktop $(DIR)/debian/tmp/usr/share/applications + $(INSTALL) $(DIR)/srb2.png $(DIR)/debian/tmp/usr/share/pixmaps/${PROGRAM_FILENAME}.png + $(INSTALL) $(DIR)/debian/srb2.desktop $(DIR)/debian/tmp/usr/share/applications/${PROGRAM_FILENAME}.desktop # add compiled binaries to include-binaries echo $(BINDIR)/$(EXENAME) >> $(DIR)/debian/source/include-binaries echo $(BINDIR)/$(EXENAME) >> $(DIR)/debian/source/include-binaries diff --git a/debian/source/format b/debian-template/source/format similarity index 100% rename from debian/source/format rename to debian-template/source/format diff --git a/debian/source/options b/debian-template/source/options similarity index 81% rename from debian/source/options rename to debian-template/source/options index 841c65a6f..1ef771ddf 100644 --- a/debian/source/options +++ b/debian-template/source/options @@ -2,7 +2,7 @@ tar-ignore = "assets/*.srb" tar-ignore = "assets/*.pk3" tar-ignore = "assets/*.dta" tar-ignore = "assets/*.wad" -tar-ignore = "assets/debian/srb2-data/*" +tar-ignore = "assets/debian/${PACKAGE_NAME}-data/*" tar-ignore = "assets/debian/tmp/*" tar-ignore = "*.obj" tar-ignore = "*.dep" diff --git a/debian-template/srb2.desktop b/debian-template/srb2.desktop new file mode 100644 index 000000000..07c7906e0 --- /dev/null +++ b/debian-template/srb2.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=${PROGRAM_NAME} +Comment=${PROGRAM_DESCRIPTION} +Encoding=UTF-8 +Exec=${PACKAGE_INSTALL_PATH}/${PROGRAM_FILENAME} +Icon=/usr/share/pixmaps/${PROGRAM_FILENAME}.png +Terminal=false +Type=Application +StartupNotify=false +Categories=Application;Game; diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index b06a78e2b..000000000 --- a/debian/changelog +++ /dev/null @@ -1,12 +0,0 @@ -srb2 (2.1.23~9) trusty; urgency=high - - * SRB2 v2.1.23 release - - -- Marco Zafra Mon, 27 Nov 2018 16:45:00 -0500 - - -srb2 (2.0.6-5) maverick; urgency=high - - * Initial proper release.. - - -- Callum Dickinson Sat, 29 Jan 2011 01:18:42 +1300 diff --git a/debian/srb2.desktop b/debian/srb2.desktop deleted file mode 100644 index 3a1cac9f6..000000000 --- a/debian/srb2.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Name=Sonic Robo Blast 2 -Comment=A free 3D Sonic the Hedgehog fangame closely inspired by the original Sonic games on the Sega Genesis. -Encoding=UTF-8 -Exec=/usr/games/SRB2/srb2 -Icon=/usr/share/pixmaps/srb2.png -Terminal=false -Type=Application -StartupNotify=false -Categories=Application;Game; diff --git a/debian_template.sh b/debian_template.sh new file mode 100644 index 000000000..c1af3c19f --- /dev/null +++ b/debian_template.sh @@ -0,0 +1,166 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Debian package templating +# +# Call this script BEFORE running debuild! +# source ./debian_template.sh [clean] [main/asset] +# +# Before running this script, +# you should also set PACKAGE_NAME_EMAIL="John Doe " to match +# the identity of the key you will use to sign the package. +# + +# Get script's actual path +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +# Recursive function for directory crawling +# $1 = Directory root to crawl +# $2 = Code to eval on file +# $3 = Code to eval on directory +# Exposes $dirtails, $dirlevel, and $dirtailname +dirlevel=0 # initialize +dirtails=() + +# Utility function to make dira/dirb/dirc string +makedirtailname () { + dirtailname="" + for tail in $dirtails; do + if [[ "$dirtailname" == "" ]]; then + dirtailname="/$tail"; + else + dirtailname="$dirtailname/$tail"; + fi; + done; +} + +evaldirectory () { + if [ -d "$1" ]; then + # Set contextual variables + # dirtails is an array of directory basenames after the crawl root + if (( $dirlevel > 0 )); then + dirtails+=( "$(basename $1)" ); + else + dirtails=(); + fi; + dirlevel=$((dirlevel+1)); + + # Generate directory path after the crawl root + makedirtailname; + + # Eval our directory with the latest contextual info + # Don't eval on root + if (( $dirlevel > 1 )) && [[ "$3" != "" ]]; then + eval "$3"; + fi; + + # Iterate entries + for name in $1/*; do + if [ -d "$name" ]; then + # Name is a directory, but don't eval yet + # Recurse so our vars are updated + evaldirectory "$name" "$2" "$3"; + + # Decrement our directory level and remove a dirtail + unset 'dirtails[ ${#dirtails[@]}-1 ]'; + dirlevel=$((dirlevel-1)); + makedirtailname; + else + # Name is a file + if [ -f "$name" ] && [[ "$2" != "" ]]; then + eval "$2"; + fi; + fi; + done; + + # Reset our variables; we're done iterating + if (( $dirlevel == 1 )); then + dirlevel=0; + fi; + fi; +} + +# +# Initialize package parameter defaults +# +if [[ "$__DEBIAN_PARAMETERS_INITIALIZED" != "1" ]]; then + . ${DIR}/deployer/travis/deployer_defaults.sh; +fi; + +# Clean up after ourselves; we only expect to run this script once +# during buildboting +__DEBIAN_PARAMETERS_INITIALIZED=0 + +# for envsubst +export __PACKAGE_DATETIME="$(date '+%a, %d %b %Y %H:%M:%S %z')" +export __PACKAGE_DATETIME_DIGIT="$(date -u '+%Y%m%d%H%M%S')" + +if [[ "$PACKAGE_REVISION" == "" ]]; then + PACKAGE_REVISION="-$__PACKAGE_DATETIME_DIGIT"; + __PACKAGE_REVISION_BY_DATE=1; + export PACKAGE_REVISION=${PACKAGE_REVISION}; # for envsubst +fi; + +# +# Clean the old debian/ directories +# +if [[ "$1" == "clean" ]]; then + toclean=$2; +else + toclean=$1; +fi; + +if [[ "$toclean" == "" ]] || [[ "$toclean" == "main" ]]; then + echo "Cleaning main package scripts"; + if [[ ! -f ${DIR}/debian ]]; then + rm -rf ${DIR}/debian; + fi; +fi; +if [[ "$toclean" == "" ]] || [[ "$toclean" == "asset" ]]; then + echo "Cleaning asset package scripts"; + if [[ ! -f ${DIR}/assets/debian ]]; then + rm -rf ${DIR}/assets/debian; + fi; +fi; + +# +# Make new templates +# +if [[ "$1" != "clean" ]]; then + totemplate=$1; + + # HACK: ${shlibs:Depends} in the templates make the templating fail + # So just define replacemment variables + export SHLIBS_DEPENDS=${SHLIBS_DEPENDS}; + export MISC_DEPENDS=${MISC_DEPENDS}; + export DEBFILEVAR='$$file'; # used in assets/debian/rules + + # Package parameters are exported for envsubst in deployer_defaults.sh + + if [[ "$totemplate" == "" ]] || [[ "$totemplate" == "main" ]]; then + echo "Generating main package scripts"; + fromroot=${DIR}/debian-template; + toroot=${DIR}/debian; + mkdir ${toroot}; + + evaldirectory ${fromroot} \ + "cat \$name | envsubst > ${toroot}\${dirtailname}/\$( basename \$name )" \ + "mkdir \"${toroot}\${dirtailname}\""; + fi; + + if [[ "$totemplate" == "" ]] || [[ "$totemplate" == "asset" ]]; then + echo "Generating asset package scripts"; + fromroot=${DIR}/assets/debian-template; + toroot=${DIR}/assets/debian; + mkdir ${toroot}; + + # Root dir to crawl; file eval; directory eval + evaldirectory ${fromroot} \ + "cat \$name | envsubst > ${toroot}\${dirtailname}/\$( basename \$name )" \ + "mkdir \"${toroot}\${dirtailname}\""; + fi; +fi; + +if [[ "$__DPL_ACTIVE" != "1" ]] && [[ "$__PACKAGE_REVISION_BY_DATE" == "1" ]]; then + unset PACKAGE_REVISION; # so we can reset the date on subsequent runs +fi; diff --git a/deployer/travis/deployer.sh b/deployer/travis/deployer.sh new file mode 100644 index 000000000..c88155d21 --- /dev/null +++ b/deployer/travis/deployer.sh @@ -0,0 +1,157 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Initialization +# +# Performs validity checks to ensure that Deployer is allowed to run +# e.g., is an FTP hostname specified? Are we whitelisted by OSNAMES and BRANCHES? +# +# Set these environment variables in your Travis-CI settings, where they are stored securely. +# See other shell scripts for more options. +# +# DPL_ENABLED = 1 (leave blank to disable) +# DPL_TAG_ENABLED = 1 (run Deployer on all tags) +# DPL_JOB_ENABLE_ALL = 1 (run Deployer on all jobs; leave blank to act on specific jobs, see below) +# DPL_JOBNAMES = name1,name2 (whitelist of job names to allow uploading; leave blank to upload from all jobs) +# DPL_OSNAMES = osx (whitelist of OS names to allow uploading; leave blank to upload from all OSes) +# DPL_BRANCHES = master,branch1,branch2 (whitelist of branches to upload; leave blank to upload all branches) +# +# To enable Deployer on specific jobs, set _DPL_JOB_ENABLED=1 for that job. Example: +# - matrix: +# - os: osx +# env: +# - _DPL_JOB_ENABLED=1 +# +# DO NOT set __DPL_ACTIVE, because that would bypass these validity checks. + +# Validate Deployer state +if [[ "$DPL_ENABLED" == "1" ]] && [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then + # Test for base eligibility: + # Are we in a deployer branch? Or + # Are we in a release tag AND DPL_TAG_ENABLED=1? + if [[ $TRAVIS_BRANCH == *"deployer"* ]]; then + __DPL_BASE_ELIGIBLE=1; + __DPL_TERMINATE_EARLY_ELIGIBLE=1; + fi; + + if [[ "$TRAVIS_TAG" != "" ]] && [[ "$DPL_TAG_ENABLED" == "1" ]]; then + __DPL_BASE_ELIGIBLE=1; + __DPL_TAG_ELIGIBLE=1; + __DPL_TERMINATE_EARLY_ELIGIBLE=1; + fi; + + # Logging message for trigger word + if [[ "$__DPL_TAG_ELIGIBLE" != "1" ]] && [[ "$DPL_TRIGGER" != "" ]]; then + echo "Testing for trigger $DPL_TRIGGER, commit message: $TRAVIS_COMMIT_MESSAGE"; + echo "[${DPL_TRIGGER}]"; + echo "[${DPL_TRIGGER}-${_DPL_JOB_NAME}]"; + echo "[${DPL_TRIGGER}-${TRAVIS_OS_NAME}]"; + fi; + + # + # Search for the trigger word + # Force enable if release tags are eligible + # + if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_TRIGGER" == "" ]] \ + || [[ $TRAVIS_COMMIT_MESSAGE == *"[$DPL_TRIGGER]"* ]] \ + || [[ $TRAVIS_COMMIT_MESSAGE == *"[${DPL_TRIGGER}-${_DPL_JOB_NAME}]"* ]] \ + || [[ $TRAVIS_COMMIT_MESSAGE == *"[${DPL_TRIGGER}-${TRAVIS_OS_NAME}]"* ]]; then + # + # Whitelist by branch name + # Force enable if release tags are eligible + # + if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_BRANCHES" == "" ]] || [[ $DPL_BRANCHES == *"$TRAVIS_BRANCH"* ]]; then + # Set this so we only early-terminate builds when we are specifically deploying + # Trigger string and branch are encompassing conditions; the rest are job-specific + # This check only matters for deployer branches and when DPL_TERMINATE_TESTS=1, + # because we're filtering non-deployer jobs. + # + # __DPL_TRY_TERMINATE_EARLY is invalidated in .travis.yml if __DPL_ACTIVE=1 + if [[ "$__DPL_TERMINATE_EARLY_ELIGIBLE" == "1" ]] && [[ "$DPL_TERMINATE_TESTS" == "1" ]]; then + __DPL_TRY_TERMINATE_EARLY=1; + fi; + + # + # Is the job enabled for deployment? + # + if [[ "$DPL_JOB_ENABLE_ALL" == "1" ]] || [[ "$_DPL_JOB_ENABLED" == "1" ]]; then + # + # Whitelist by job names + # + if [[ "$DPL_JOBNAMES" == "" ]] || [[ "$_DPL_JOB_NAME" == "" ]] || [[ $DPL_JOBNAMES == *"$_DPL_JOB_NAME"* ]]; then + # + # Whitelist by OS names + # + if [[ "$DPL_OSNAMES" == "" ]] || [[ $DPL_OSNAMES == *"$TRAVIS_OS_NAME"* ]]; then + # Base Deployer is eligible for becoming active + + # Are we building for Linux? + if [[ "$_DPL_PACKAGE_BINARY" == "1" ]] || [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]] || [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then + if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + __DPL_DEBIAN_ACTIVE=1; + fi; + fi; + fi; + + # Now check for deployment targets + if [[ "$_DPL_FTP_TARGET" == "1" ]] && [[ "$DPL_FTP_HOSTNAME" != "" ]]; then + if [[ "$TRAVIS_OS_HOST" == "linux" ]] && [[ "$DPL_FTP_PROTOCOL" == "ftp" ]]; then + echo "Non-secure FTP will not work on Linux Travis-CI jobs!"; + echo "Try SFTP or another target. Details:"; + echo "https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci"; + else + if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]] || [[ "$_DPL_PACKAGE_BINARY" == "1" ]] || [[ "$_DPL_BINARY" == "1" ]]; then + echo "Deployer FTP target is enabled"; + __DPL_FTP_ACTIVE=1; + else + echo "Deployer FTP target cannot be enabled: You must specify _DPL_PACKAGE_BINARY=1,"; + echo "and/or _DPL_BINARY=1 in your job's environment variables."; + fi; + fi; + fi; + + if [[ "$_DPL_DPUT_TARGET" == "1" ]] && [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]] \ + && [[ "$DPL_DPUT_INCOMING" != "" ]]; then + if [[ "$DPL_DPUT_METHOD" == "ftp" ]]; then + echo "DPUT will not work with non-secure FTP on Linux Travis-CI jobs!"; + echo "Try SFTP or another method for DPUT. Details:"; + echo "https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci"; + else + echo "Deployer DPUT target is enabled"; + __DPL_DPUT_ACTIVE=1; + fi; + fi; + + # If any deployment targets are active, then so is the Deployer at large + if [[ "$__DPL_FTP_ACTIVE" == "1" ]] || [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then + __DPL_ACTIVE=1; + fi; + fi; + fi; + fi; + fi; + else + if [[ "$DPL_TRIGGER" != "" ]]; then + echo "Testing for global trigger [$DPL_TRIGGER, commit message: $TRAVIS_COMMIT_MESSAGE"; + fi; + if [[ "$DPL_TRIGGER" != "" ]] && [[ $TRAVIS_COMMIT_MESSAGE == *"[$DPL_TRIGGER"* ]]; then + if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_BRANCHES" == "" ]] || [[ $DPL_BRANCHES == *"$TRAVIS_BRANCH"* ]]; then + # This check only matters for deployer branches and when DPL_TERMINATE_TESTS=1, + # because we're filtering non-deployer jobs. + if [[ "$__DPL_TERMINATE_EARLY_ELIGIBLE" == "1" ]] && [[ "$DPL_TERMINATE_TESTS" == "1" ]]; then + # Assume that some job received the trigger, so mark this for early termination + __DPL_TRY_TERMINATE_EARLY=1; + fi; + fi; + fi; + fi; +fi; + +if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]] && [[ "$__DPL_ACTIVE" != "1" ]]; then + echo "Deployer is active in another job"; +fi; + +if [[ "$__DPL_TRY_TERMINATE_EARLY" != "1" ]] && [[ "$__DPL_ACTIVE" != "1" ]]; then + echo "Deployer is not active"; +fi; diff --git a/deployer/travis/deployer_build.sh b/deployer/travis/deployer_build.sh new file mode 100644 index 000000000..3817f025d --- /dev/null +++ b/deployer/travis/deployer_build.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Build Script +# +# Builds the required targets depending on which sub-modules are enabled + +if [[ "$__DPL_FTP_ACTIVE" == "1" ]] || [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then + if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]]; then + echo "Building Debian package(s)" + + sudo apt-get install devscripts debhelper fakeroot secure-delete expect; + + # Build source packages first, since they zip up the entire source folder, + # binaries and all + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + . ../debian_template.sh main; + OLDPWD=$PWD; # [repo]/build + cd ..; # repo root + + if [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then + echo "Building main source Debian package"; + expect <(cat < key.asc; + echo "$DPL_PGP_KEY_PASSPHRASE" > phrase.txt; + gpg --import key.asc; + + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + echo "Signing main package(s)"; + + PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + $PACKAGEDBGFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGENIGHTLYDBGFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHDBGFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + #$PACKAGEPATCHNIGHTLYDBGFILENAME + ); + + # Main packages are in parent of root repo folder + OLDPWD=$PWD; # [repo]/build + cd ../..; # parent of repo root + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*.changes; do + debsign --no-re-sign -p"gpg --passphrase-file $OLDPWD/phrase.txt --batch" "$f"; + done; + done; + + cd $OLDPWD; + fi; + + if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then + echo "Signing asset package(s)"; + + PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + ) + + # Asset packages are in root repo folder + OLDPWD=$PWD; # [repo]/build + cd ..; # repo root + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*.changes; do + debsign --no-re-sign -p"gpg --passphrase-file $OLDPWD/phrase.txt --batch" "$f"; + done; + done; + + cd $OLDPWD; + fi; + + # Delete the keys :eyes: + srm key.asc; + srm phrase.txt; + fi; + fi; + + # all other OSes + if [[ "$TRAVIS_OS_NAME" != "linux" ]]; then + # + # Check for binary building + # + if [[ "$_DPL_BINARY" == "1" ]]; then + echo "Building a Binary"; + make -k; + fi; + + # + # Check for package building + # + if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then + echo "Building a Package"; + + # Make an OSX package; superuser is required for library bundling + # + # HACK: OSX packaging can't write libraries to .app package unless we're superuser + # because the original library files don't have WRITE permission + # Bug may be sidestepped by using CHMOD_BUNDLE_ITEMS=TRUE + # But I don't know where this is set. Not `cmake -D...` because this var is ignored. + # https://cmake.org/Bug/view.php?id=9284 + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + sudo make -k package; + else + # Some day, when Windows is supported, we'll just make a standard package + make -k package; + fi; + fi; + fi; +fi; diff --git a/deployer/travis/deployer_defaults.sh b/deployer/travis/deployer_defaults.sh new file mode 100644 index 000000000..fe7ba6993 --- /dev/null +++ b/deployer/travis/deployer_defaults.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +# Deployer for Travis-CI +# Default Variables +# +# Here are all of the user-set variables used by Deployer. +# See the "Cross-platform deployment" page on SRB2 Wiki for documentation. + +# Core Parameters +: ${DPL_ENABLED} # Enable Deployer behavior; must be set for any deployment activity +: ${DPL_TAG_ENABLED} # Trigger Deployer for all tag releases +: ${DPL_JOB_ENABLE_ALL} # Enable all jobs for deployment +: ${DPL_TERMINATE_TESTS} # Terminate all build test jobs (used in .travis.yml) +: ${DPL_TRIGGER} # Use a [word] in the commit message to trigger Deployer +: ${DPL_JOBNAMES} # Trigger Deployer by job name +: ${DPL_OSNAMES} # Trigger Deployer by OS name (osx,linux) +: ${DPL_BRANCHES} # Trigger Deployer by git branch name + +# Job Parameters +: ${_DPL_JOB_ENABLED} # Enable Deployer for this specific job. DPL_ENABLED must be set too. +: ${_DPL_JOB_NAME} # Identifier for the job, used for logging and trigger word matching +: ${_DPL_FTP_TARGET} # Deploy to FTP +: ${_DPL_DPUT_TARGET} # Deploy to DPUT +: ${_DPL_PACKAGE_SOURCE} # Build packages into a Source distribution. Linux only. +: ${_DPL_PACKAGE_BINARY} # Build packages into a Binary distribution. +: ${_DPL_PACKAGE_MAIN:=1} # Build main installation package. Linux only; OS X assumes this. +: ${_DPL_PACKAGE_ASSET} # Build asset installation package. Linux only. + +# Asset File Parameters +: ${ASSET_ARCHIVE_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-assets.7z} +: ${ASSET_ARCHIVE_OPTIONAL_PATH:=https://github.com/mazmazz/SRB2/releases/download/SRB2_assets_220/SRB2-v220-optional-assets.7z} +: ${ASSET_FILES_HASHED:=srb2.pk3 zones.pk3 player.dta} # POST v2.2 NOTE: Don't forget to add patch.pk3! +: ${ASSET_FILES_DOCS:=README.txt LICENSE.txt LICENSE-3RD-PARTY.txt README-SDL.txt} +: ${ASSET_FILES_OPTIONAL_GET:=0} + +# FTP Parameters +: ${DPL_FTP_PROTOCOL} +: ${DPL_FTP_USER} +: ${DPL_FTP_PASS} +: ${DPL_FTP_HOSTNAME} +: ${DPL_FTP_PORT} +: ${DPL_FTP_PATH} + +# DPUT Parameters +: ${DPL_DPUT_DOMAIN:=ppa.launchpad.net} +: ${DPL_DPUT_METHOD:=sftp} +: ${DPL_DPUT_INCOMING} +: ${DPL_DPUT_LOGIN:=anonymous} +: ${DPL_SSH_KEY_PRIVATE} # Base64-encoded private key file. Used to sign repository uploads +: ${DPL_SSH_KEY_PASSPHRASE} # Decodes the private key file. + +# Package Parameters +: ${PACKAGE_NAME:=srb2} +: ${PACKAGE_VERSION:=2.2.0} +: ${PACKAGE_SUBVERSION} # Highly recommended to set this to reflect the distro series target (e.g., ~18.04bionic) +: ${PACKAGE_REVISION} # Defaults to UTC timestamp +: ${PACKAGE_INSTALL_PATH:=/usr/games/SRB2} +: ${PACKAGE_LINK_PATH:=/usr/games} +: ${PACKAGE_DISTRO:=trusty} +: ${PACKAGE_URGENCY:=high} +: ${PACKAGE_NAME_EMAIL:=Sonic Team Junior } +: ${PACKAGE_GROUP_NAME_EMAIL:=Sonic Team Junior } +: ${PACKAGE_WEBSITE:=} + +: ${PACKAGE_ASSET_MINVERSION:=2.1.26} # Number this the version BEFORE the actual required version, because we do a > check +: ${PACKAGE_ASSET_MAXVERSION:=2.2.1} # Number this the version AFTER the actual required version, because we do a < check + +: ${PROGRAM_NAME:=Sonic Robo Blast 2} +: ${PROGRAM_VENDOR:=Sonic Team Junior} +: ${PROGRAM_VERSION:=2.2.0} +: ${PROGRAM_DESCRIPTION:=A free 3D Sonic the Hedgehog fangame closely inspired by the original Sonic games on the Sega Genesis.} +: ${PROGRAM_FILENAME:=srb2} + +: ${DPL_PGP_KEY_PRIVATE} # Base64-encoded private key file. Used to sign Debian packages +: ${DPL_PGP_KEY_PASSPHRASE} # Decodes the private key file. + +# Export Asset and Package Parameters for envsubst templating + +export ASSET_ARCHIVE_PATH="${ASSET_ARCHIVE_PATH}" +export ASSET_ARCHIVE_OPTIONAL_PATH="${ASSET_ARCHIVE_OPTIONAL_PATH}" +export ASSET_FILES_HASHED="${ASSET_FILES_HASHED}" +export ASSET_FILES_DOCS="${ASSET_FILES_DOCS}" +export ASSET_FILES_OPTIONAL_GET="${ASSET_FILES_OPTIONAL_GET}" + +export PACKAGE_NAME="${PACKAGE_NAME}" +export PACKAGE_VERSION="${PACKAGE_VERSION}" +export PACKAGE_SUBVERSION="${PACKAGE_SUBVERSION}" # in case we have this +export PACKAGE_REVISION="${PACKAGE_REVISION}" +export PACKAGE_ASSET_MINVERSION="${PACKAGE_ASSET_MINVERSION}" +export PACKAGE_ASSET_MAXVERSION="${PACKAGE_ASSET_MAXVERSION}" +export PACKAGE_INSTALL_PATH="${PACKAGE_INSTALL_PATH}" +export PACKAGE_LINK_PATH="${PACKAGE_LINK_PATH}" +export PACKAGE_DISTRO="${PACKAGE_DISTRO}" +export PACKAGE_URGENCY="${PACKAGE_URGENCY}" +export PACKAGE_NAME_EMAIL="${PACKAGE_NAME_EMAIL}" +export PACKAGE_GROUP_NAME_EMAIL="${PACKAGE_GROUP_NAME_EMAIL}" +export PACKAGE_WEBSITE="${PACKAGE_WEBSITE}" + +export PROGRAM_NAME="${PROGRAM_NAME}" +export PROGRAM_VERSION="${PROGRAM_VERSION}" +export PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION}" +export PROGRAM_FILENAME="${PROGRAM_FILENAME}" + +# This file is called in debian_template.sh, so mark our completion so we don't run it again +__DEBIAN_PARAMETERS_INITIALIZED=1 diff --git a/deployer/travis/deployer_dput.sh b/deployer/travis/deployer_dput.sh new file mode 100644 index 000000000..863a928cd --- /dev/null +++ b/deployer/travis/deployer_dput.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +# Deployer for Travis-CI +# DPUT uploader (e.g., Launchpad PPA) +# + +if [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then + # Install APT dependencies + # paramiko required for ssh + sudo apt-get install python-paramiko expect dput; # python-pip + #pip install paramiko; + + # Output the DPUT config + # Dput only works if you're using secure FTP, so that's what we default to. + cat > "./dput.cf" << EOM +[deployer] +fqdn = ${DPL_DPUT_DOMAIN} +method = ${DPL_DPUT_METHOD} +incoming = ${DPL_DPUT_INCOMING} +login = ${DPL_DPUT_LOGIN} +allow_unsigned_uploads = 0 +EOM + + # Output SSH config + # Don't let SSH prompt us for untrusted hosts + cat >> "./ssh_config" << EOM + +Host * + StrictHostKeyChecking no + UserKnownHostsFile=/dev/null + PubKeyAuthentication yes + IdentityFile ${PWD}/key.private + IdentitiesOnly yes +EOM + sudo sh -c "cat < ${PWD}/ssh_config >> /etc/ssh/ssh_config"; + + # Get the private key + echo "$DPL_SSH_KEY_PRIVATE" | base64 --decode > key.private; + chmod 700 ./key.private; + + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + $PACKAGEDBGFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGENIGHTLYDBGFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHDBGFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + #$PACKAGEPATCHNIGHTLYDBGFILENAME + ); + + # Main packages are in parent of root repo folder + OLDPWD=$PWD; # [repo]/build + cd ../..; + + # Enter passphrase if required + for n in ${PACKAGEFILENAMES}; do + for f in $n*.changes; do + # Binary builds also generate source builds, so exclude the source + # builds if desired + if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then + if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then + continue; + fi; + fi; + + expect <(cat < "commit.txt"; + echo "Job ID $TRAVIS_JOB_ID" >> "commit.txt"; + echo "" >> "commit.txt"; + echo "Commit $TRAVIS_COMMIT" >> "commit.txt"; + echo "$TRAVIS_COMMIT_MESSAGE" >> "commit.txt"; + echo "" >> "commit.txt"; + + # Initialize FTP parameters + if [[ "$DPL_FTP_PORT" == "" ]]; then + DPL_FTP_PORT=21; + fi; + if [[ "$DPL_FTP_PROTOCOL" == "" ]]; then + DPL_FTP_PROTOCOL=ftp; + fi; + __DPL_FTP_LOCATION=$DPL_FTP_PROTOCOL://$DPL_FTP_HOSTNAME:$DPL_FTP_PORT/$DPL_FTP_PATH/$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH/$TRAVIS_JOB_ID-$TRAVIS_JOB_NUMBER-$JOBNAME; + + # Upload to FTP! + echo "Uploading to FTP..."; + curl --ftp-create-dirs -T "commit.txt" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/commit.txt"; + + if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]]; then + if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then + PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + $PACKAGEDBGFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGENIGHTLYDBGFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHDBGFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + #$PACKAGEPATCHNIGHTLYDBGFILENAME + ); + + # Main packages are in parent of root repo folder + OLDPWD=$PWD; # [repo]/build + cd ../..; + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*; do + # Binary builds also generate source builds, so exclude the source + # builds if desired + if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then + if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then + continue; + fi; + fi; + curl --ftp-create-dirs -T "$f" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/package/main/$f"; + done; + done; + + # Go back to [repo]/build folder + cd $OLDPWD; + fi; + + if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then + PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + #PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}; + + PACKAGEFILENAMES=( + $PACKAGEFILENAME + #$PACKAGENIGHTLYFILENAME + #$PACKAGEPATCHFILENAME + #$PACKAGEPATCHNIGHTLYFILENAME + ) + + # Asset packages are in root repo folder + OLDPWD=$PWD; # [repo]/build + cd ..; + + for n in ${PACKAGEFILENAMES}; do + for f in ./$n*; do + # Binary builds also generate source builds, so exclude the source + # builds if desired + if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then + if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then + continue; + fi; + fi; + curl --ftp-create-dirs -T "$f" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/package/asset/$f"; + done; + done; + + # Go back to [repo]/build folder + cd $OLDPWD; + fi; + else + if [[ "$_DPL_BINARY" == "1" ]]; then + find bin -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;; + fi; + + if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then + sudo rm -r package/_CPack_Packages + find package -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;; + fi; + fi; +fi diff --git a/extras/conf/Includes/Game_SRB222.cfg b/extras/conf/Includes/Game_SRB222.cfg new file mode 100644 index 000000000..3c4b11e9f --- /dev/null +++ b/extras/conf/Includes/Game_SRB222.cfg @@ -0,0 +1,77 @@ +// Default lump name for new map +defaultlumpname = "MAP01"; +//GZDB specific. Don't try to load lumps that don't exist. +basegame = 0; + +//Sky textures for vanilla maps +defaultskytextures +{ + SKY1 = "MAP01,MAP02,MAP03,MAP33,MAP50,MAP60,MAPF0,MAPM0"; + SKY2 = "MAPM7,MAPMB"; + SKY4 = "MAP04,MAP06,MAP61,MAPF6,MAPM1"; + SKY6 = "MAP05,MAP51,MAPMA"; + SKY7 = "MAPM2,MAPM5"; + SKY8 = "MAP07,MAP08,MAP09,MAP52,MAP62,MAPF1"; + SKY10 = "MAP10,MAP12,MAP53,MAP63,MAPM3"; + SKY11 = "MAP11,MAPF7"; + SKY13 = "MAP13,MAP64"; + SKY14 = "MAP14"; + SKY15 = "MAP15,MAP54"; + SKY17 = "MAP70"; + SKY20 = "MAP32,MAP55,MAP65,MAPF2,MAPF5"; + SKY21 = "MAPM4"; + SKY22 = "MAP22,MAP23,MAP25,MAP26,MAP27,MAP56,MAP66,MAPF4,MAPM6"; + SKY30 = "MAP30"; + SKY31 = "MAP31"; + SKY35 = "MAP42"; + SKY40 = "MAP41,MAP71,MAPM9"; + SKY55 = "MAPF3,MAPM8"; + SKY68 = "MAPF8"; + SKY99 = "MAP57,MAPZ0"; + SKY159 = "MAP16"; + SKY172 = "MAP40"; + SKY300 = "MAP72"; + SKY301 = "MAP73"; +} + +// Skill levels +skills +{ + 1 = "Normal"; +} + +// Skins +skins +{ + Sonic; + Tails; + Knuckles; + Amy; + Fang; + Metalsonic; +} + +// Gametypes +gametypes +{ + -1 = "Single Player"; + 0 = "Co-op"; + 1 = "Competition"; + 2 = "Race"; + 3 = "Match"; + 4 = "Team Match"; + 5 = "Tag"; + 6 = "Hide and Seek"; + 7 = "CTF"; +} + +// Texture loading options +defaultwalltexture = "GFZROCK"; +defaultfloortexture = "GFZFLR01"; +defaultceilingtexture = "F_SKY1"; + +// Default texture sets +// (these are not required, but useful for new users) +texturesets +{ +} \ No newline at end of file diff --git a/extras/conf/Includes/SRB222_common.cfg b/extras/conf/Includes/SRB222_common.cfg new file mode 100644 index 000000000..a832e6cef --- /dev/null +++ b/extras/conf/Includes/SRB222_common.cfg @@ -0,0 +1,309 @@ +common +{ + // Some common settings + + + + // Default testing parameters + testparameters = "-file \"%AP\" \"%F\" -warp %L"; + testshortpaths = true; + + // Action special help (mxd) + actionspecialhelp = "https://wiki.srb2.org/wiki/Linedef_type_%K"; + + // Default nodebuilder configurations + defaultsavecompiler = "zennode_normal"; + defaulttestcompiler = "zennode_fast"; + + // Generalized actions + generalizedlinedefs = false; + generalizedsectors = true; + + mixtexturesflats = true; + defaulttexturescale = 1.0f; + defaultflatscale = 1.0f; + scaledtextureoffsets = true; + + // Thing number for start position in 3D Mode + start3dmode = 3328; + + // Texture sources + textures + { + include("SRB222_misc.cfg", "textures"); + } + + // Patch sources + patches + { + include("SRB222_misc.cfg", "patches"); + } + + // Sprite sources + sprites + { + include("SRB222_misc.cfg", "sprites"); + } + + // Flat sources + flats + { + include("SRB222_misc.cfg", "flats"); + } +} + +mapformat_doom +{ + // The format interface handles the map data format - DoomMapSetIO for SRB2DB2, SRB2MapSetIO for Zone Builder + formatinterface = "SRB2MapSetIO"; + + /* + GAME DETECT PATTERN + Used to guess the game for which a WAD file is made. + + 1 = One of these lumps must exist + 2 = None of these lumps must exist + 3 = All of these lumps must exist + */ + + gamedetect + { + EXTENDED = 2; + + + BEHAVIOR = 2; + + E#M# = 2; + + MAP?? = 1; + } + + /* + MAP LUMP NAMES + Map lumps are loaded with the map as long as they are right after each other. When the editor + meets a lump which is not defined in this list it will ignore the map if not satisfied. + The order of items defines the order in which lumps will be written to WAD file on save. + To indicate the map header lump, use ~MAP + + Legenda: + required = Lump is required to exist. + blindcopy = Lump will be copied along with the map blindly. (usefull for lumps Doom Builder doesn't use) + nodebuild = The nodebuilder generates this lump. + allowempty = The nodebuilder is allowed to leave this lump empty. + script = This lump is a text-based script. Specify the filename of the script configuration to use. + */ + + maplumpnames + { + include("SRB222_misc.cfg", "doommaplumpnames"); + } + + // When this is set to true, sectors with the same tag will light up when a line is highlighted + linetagindicatesectors = true; + + // Special linedefs + include("SRB222_misc.cfg", "speciallinedefs"); + + // Default flags for first new thing (As far as 2.2 goes, they're empty just like in 2.1) + defaultthingflags + { + } + + // DEFAULT SECTOR BRIGHTNESS LEVELS + sectorbrightness + { + include("SRB222_misc.cfg", "sectorbrightness"); + } + + // SECTOR TYPES----------------------------------------------------------------- + sectortypes + { + include("SRB222_sectors.cfg", "sectortypes"); + } + + // GENERALISED SECTOR TYPES----------------------------------------------------------------- + gen_sectortypes + { + include("SRB222_sectors.cfg", "gen_sectortypes"); + } + + // LINEDEF FLAGS + linedefflags + { + include("SRB222_misc.cfg", "linedefflags"); + } + + // Linedef flags UDMF translation table + // This is needed for copy/paste and prefabs to work properly + // When the UDMF field name is prefixed with ! it is inverted + linedefflagstranslation + { + include("SRB222_misc.cfg", "linedefflagstranslation"); + } + + // LINEDEF ACTIVATIONS + linedefactivations + { + } + + // LINEDEF TYPES + linedeftypes + { + include("SRB222_linedefs.cfg", "doom"); + } + + // THING FLAGS + thingflags + { + include("SRB222_misc.cfg", "thingflags"); + } + + // Thing flags UDMF translation table + // This is needed for copy/paste and prefabs to work properly + // When the UDMF field name is prefixed with ! it is inverted + thingflagstranslation + { + include("SRB222_misc.cfg", "thingflagstranslation"); + } + + // THING FLAGS ERROR MASK + // Mask for the thing flags which indicates the options + // that make the same thing appear in the same modes + thingflagsmask1 = 7; // 1 + 2 + 4 + thingflagsmask2 = 0; +} + +mapformat_udmf +{ + // The format interface handles the map data format + formatinterface = "UniversalMapSetIO"; + + // Enables support for long (> 8 chars) texture names + // WARNING: this should only be enabled for UDMF game configurations! + // WARNING: enabling this will make maps incompatible with Doom Builder 2 and can lead to problems in Slade 3! + longtexturenames = false; + + // Default nodebuilder configurations + defaultsavecompiler = "zdbsp_udmf_normal"; + defaulttestcompiler = "zdbsp_udmf_fast"; + + engine = "srb2"; // override that so that DB2 uses the correct namespace + + maplumpnames + { + include("UDMF_misc.cfg", "udmfmaplumpnames_begin"); + include("SRB222_misc.cfg", "udmfmaplumpnames"); + include("UDMF_misc.cfg", "udmfmaplumpnames_end"); + } + + universalfields + { +// include("SRB222_misc.cfg", "universalfields"); + } + + // When this is set to true, sectors with the same tag will light up when a line is highlighted + linetagindicatesectors = false; + + // Special linedefs + include("SRB222_misc.cfg", "speciallinedefs_udmf"); + + // Default flags for first new thing (As far as 2.2 goes, they're empty just like in 2.1) + defaultthingflags + { + } + + // Generalized actions + generalizedlinedefs = false; + + // SECTOR FLAGS + sectorflags + { +// include("SRB222_misc.cfg", "sectorflags"); + } + + // DEFAULT SECTOR BRIGHTNESS LEVELS + sectorbrightness + { + include("SRB222_misc.cfg", "sectorbrightness"); + } + + // SECTOR TYPES + sectortypes + { + include("SRB222_sectors.cfg", "sectortypes"); + } + + // SECTOR RENSERSTYLES +/* sectorrenderstyles + { + include("SRB222_misc.cfg", "sectorrenderstyles"); + }*/ + + // LINEDEF FLAGS + linedefflags + { + include("SRB222_misc.cfg", "linedefflags_udmf"); + } + + // LINEDEF ACTIVATIONS + linedefactivations + { + include("SRB222_misc.cfg", "linedefactivations_udmf"); + } + + linedefflagstranslation + { + } + + + // LINEDEF RENSERSTYLES + linedefrenderstyles + { + include("SRB222_misc.cfg", "linedefrenderstyles"); + } + + //SIDEDEF FLAGS +/* sidedefflags + { + include("UDMF_misc.cfg", "sidedefflags"); + }*/ + + // THING FLAGS + thingflags + { + include("SRB222_misc.cfg", "thingflags_udmf"); + } + + // Thing flags UDMF translation table + // This is needed for copy/paste and prefabs to work properly + // When the UDMF field name is prefixed with ! it is inverted + thingflagstranslation + { + include("SRB222_misc.cfg", "thingflagstranslation"); + } + + // THING RENSERSTYLES +/* thingrenderstyles + { + include("SRB222_misc.cfg", "thingrenderstyles"); + }*/ + + // How to compare thing flags (for the stuck things error checker) +/* thingflagscompare + { + include("UDMF_misc.cfg", "thingflagscompare"); + }*/ + + //mxd. Thing flags UDMF translation table + // This is needed for copy/paste and prefabs to work properly + // When the UDMF field name is prefixed with ! it is inverted + thingflagstranslation + { + } + + // LINEDEF TYPES + linedeftypes + { + include("SRB222_linedefs.cfg", "udmf"); + } +} \ No newline at end of file diff --git a/extras/conf/Includes/SRB222_linedefs.cfg b/extras/conf/Includes/SRB222_linedefs.cfg new file mode 100644 index 000000000..fdf191850 --- /dev/null +++ b/extras/conf/Includes/SRB222_linedefs.cfg @@ -0,0 +1,2486 @@ +doom +{ + misc + { + title = "Miscellaneous"; + + 0 + { + title = "None"; + prefix = "(0)"; + } + + 1 + { + title = "Per-Sector Gravity"; + prefix = "(1)"; + flags64text = "[6] Flip in reverse gravity"; + } + + 5 + { + title = "Camera Scanner"; + prefix = "(5)"; + } + + 7 + { + title = "Sector Flat Alignment"; + prefix = "(7)"; + flags2048text = "[11] Don't align floor"; + flags4096text = "[12] Don't align ceiling"; + flags8192text = "[13] Use texture offsets"; + } + + 10 + { + title = "Culling Plane"; + prefix = "(10)"; + flags64text = "[6] Cull only while in sector"; + } + + 13 + { + title = "Heat Wave Effect"; + prefix = "(13)"; + } + + 40 + { + title = "Visual Portal Between Tagged Linedefs"; + prefix = "(40)"; + } + + 41 + { + title = "Horizon Effect"; + prefix = "(41)"; + } + + 50 + { + title = "Instantly Lower Floor on Level Load"; + prefix = "(50)"; + } + + 51 + { + title = "Instantly Raise Ceiling on Level Load"; + prefix = "(51)"; + } + + 63 + { + title = "Fake Floor/Ceiling Planes"; + prefix = "(63)"; + } + + 540 + { + title = "Floor Friction"; + prefix = "(540)"; + } + } + + parameters + { + title = "Parameters"; + + 2 + { + title = "Custom Exit"; + prefix = "(2)"; + flags2text = "[1] Check emeralds"; + flags64text = "[6] Skip score tally"; + } + + 3 + { + title = "Zoom Tube Parameters"; + prefix = "(3)"; + flags512text = "[9] Ignore player direction"; + } + + 4 + { + title = "Speed Pad Parameters"; + prefix = "(4)"; + flags512text = "[9] No teleport to center"; + flags1024text = "[10] Force spinning frames"; + } + + 8 + { + title = "Special Sector Properties"; + prefix = "(8)"; + flags32text = "[5] Invert precipitation"; + flags64text = "[6] Touch only ceiling"; + flags128text = "[7] Allow opposite gravity"; + flags256text = "[8] Touch sector edge"; + flags512text = "[9] Touch floor or ceiling"; + } + + 9 + { + title = "Chain Parameters"; + prefix = "(9)"; + flags32text = "[5] Swing instead of spin"; + flags64text = "[6] Player-turnable chain"; + flags128text = "[7] Make chain from end item"; + flags256text = "[8] Spawn link at origin"; + flags512text = "[9] Don't clip inside ground"; + flags1024text = "[10] No distance check"; + } + + 11 + { + title = "Rope Hang Parameters"; + prefix = "(11)"; + flags32text = "[5] Don't loop"; + flags64text = "[6] Static"; + } + + 12 + { + title = "Rock Spawner Parameters"; + prefix = "(12)"; + flags64text = "[6] Randomize speed"; + } + + 14 + { + title = "Bustable Block Parameters"; + prefix = "(14)"; + flags32text = "[5] Particles launch from center"; + } + + 15 + { + title = "Fan Particle Spawner Parameters"; + prefix = "(15)"; + } + + 16 + { + title = "Minecart Parameters"; + prefix = "(16)"; + } + + 64 + { + title = "Continuously Appearing/Disappearing FOF"; + prefix = "(64)"; + flags2text = "[1] Use control sector tag"; + flags64text = "[6] No sound effect"; + } + + 65 + { + title = "Bridge Thinker "; + prefix = "(65)"; + } + } + + polyobject + { + title = "PolyObject"; + + 20 + { + title = "First Line"; + prefix = "(20)"; + } + + 21 + { + title = "Explicitly Include Line "; + prefix = "(21)"; + } + + 22 + { + title = "Parameters"; + prefix = "(22)"; + flags64text = "[6] Trigger linedef executor"; + flags128text = "[7] Intangible"; + flags256text = "[8] Stopped by pushables"; + flags512text = "[9] Render flats"; + } + + 30 + { + title = "Waving Flag"; + prefix = "(30)"; + } + + 31 + { + title = "Displacement by Front Sector"; + prefix = "(31)"; + } + + 32 + { + title = "Angular Displacement by Front Sector"; + prefix = "(32)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + } + + planemove + { + title = "Plane Movement"; + + 52 + { + title = "Continuously Falling Sector"; + prefix = "(52)"; + flags64text = "[6] Continuously rising"; + } + + 53 + { + title = "Continuous Floor/Ceiling Mover"; + prefix = "(53)"; + } + + 54 + { + title = "Continuous Floor Mover"; + prefix = "(54)"; + } + + 55 + { + title = "Continuous Ceiling Mover"; + prefix = "(55)"; + } + + 56 + { + title = "Continuous Two-Speed Floor/Ceiling Mover"; + prefix = "(56)"; + } + + 57 + { + title = "Continuous Two-Speed Floor Mover"; + prefix = "(57)"; + } + + 58 + { + title = "Continuous Two-Speed Ceiling Mover"; + prefix = "(58)"; + } + + 59 + { + title = "Activate Moving Platform"; + prefix = "(59)"; + flags64text = "[6] Move upwards at start"; + } + + 60 + { + title = "Activate Moving Platform (Adjustable Speed)"; + prefix = "(60)"; + flags64text = "[6] Move upwards at start"; + } + + 61 + { + title = "Crusher (Ceiling to Floor)"; + prefix = "(61)"; + flags512text = "[9] Double, constant speed"; + } + + 62 + { + title = "Crusher (Floor to Ceiling)"; + prefix = "(62)"; + flags512text = "[9] Double, constant speed"; + } + + 66 + { + title = "Move Floor by Displacement"; + prefix = "(66)"; + flags64text = "[6] Inverse movement"; + } + + 67 + { + title = "Move Ceiling by Displacement"; + prefix = "(67)"; + flags64text = "[6] Inverse movement"; + } + + 68 + { + title = "Move Floor and Ceiling by Displacement"; + prefix = "(68)"; + flags64text = "[6] Inverse movement"; + } + } + + fofsolid + { + title = "FOF (solid)"; + + 100 + { + title = "Solid, Opaque"; + prefix = "(100)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 101 + { + title = "Solid, Opaque, No Shadow"; + prefix = "(101)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1DF"; + } + + 102 + { + title = "Solid, Translucent"; + prefix = "(102)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Render insides"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "195F"; + flags643dfloorflagsadd = "7C80"; + } + + 103 + { + title = "Solid, Sides Only"; + prefix = "(103)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1CF"; + } + + 104 + { + title = "Solid, No Sides"; + prefix = "(104)"; + flags32text = "[5] Only block player"; + flags64text = "[6] Cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1D7"; + flags643dfloorflagsremove = "40"; + } + + 105 + { + title = "Solid, Invisible"; + prefix = "(105)"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "47"; + } + + 140 + { + title = "Intangible from Bottom, Opaque"; + prefix = "(140)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "200841F"; + flags643dfloorflagsadd = "40"; + } + + 141 + { + title = "Intangible from Bottom, Translucent"; + prefix = "(141)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "200191F"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 142 + { + title = "Intangible from Bottom, Translucent, No Sides"; + prefix = "(142)"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "2001917"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 143 + { + title = "Intangible from Top, Opaque"; + prefix = "(143)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "400841F"; + flags643dfloorflagsadd = "40"; + } + + 144 + { + title = "Intangible from Top, Translucent"; + prefix = "(144)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "400191F"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 145 + { + title = "Intangible from Top, Translucent, No Sides"; + prefix = "(145)"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "4001917"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 146 + { + title = "Only Tangible from Sides"; + prefix = "(146)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "600800F"; + } + } + + fofintangible + { + title = "FOF (intangible)"; + + 120 + { + title = "Water, Opaque"; + prefix = "(120)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "8F39"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 121 + { + title = "Water, Translucent"; + prefix = "(121)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "9F39"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 122 + { + title = "Water, Opaque, No Sides"; + prefix = "(122)"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "F31"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 123 + { + title = "Water, Translucent, No Sides"; + prefix = "(123)"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "1F31"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 124 + { + title = "Goo Water, Translucent"; + prefix = "(124)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "209F39"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 125 + { + title = "Goo Water, Translucent, No Sides"; + prefix = "(125)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "201F31"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 220 + { + title = "Intangible, Opaque"; + prefix = "(220)"; + flags8text = "[3] Slope skew sides"; + 3dfloor = true; + 3dfloorflags = "8F19"; + } + + 221 + { + title = "Intangible, Translucent"; + prefix = "(221)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Cast shadow"; + 3dfloor = true; + 3dfloorflags = "1B59"; + flags643dfloorflagsremove = "40"; + } + + 222 + { + title = "Intangible, Sides Only"; + prefix = "(222)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Cast shadow"; + 3dfloor = true; + 3dfloorflags = "8249"; + flags643dfloorflagsremove = "240"; + } + + 223 + { + title = "Intangible, Invisible"; + prefix = "(223)"; + 3dfloor = true; + 3dfloorflags = "41"; + } + } + + fofmoving + { + title = "FOF (moving)"; + + 150 + { + title = "Air Bobbing"; + prefix = "(150)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 151 + { + title = "Air Bobbing (Adjustable)"; + prefix = "(151)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 152 + { + title = "Reverse Air Bobbing (Adjustable)"; + prefix = "(152)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 160 + { + title = "Floating, Bobbing"; + prefix = "(160)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "4019F"; + } + + 190 + { + title = "Rising Platform, Solid, Opaque"; + prefix = "(190)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 191 + { + title = "Rising Platform, Solid, Opaque, No Shadow"; + prefix = "(191)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1DF"; + } + + 192 + { + title = "Rising Platform, Solid, Translucent"; + prefix = "(192)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "195F"; + } + + 193 + { + title = "Rising Platform, Solid, Invisible"; + prefix = "(193)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "47"; + } + + 194 + { + title = "Rising Platform, Intangible from Bottom, Opaque"; + prefix = "(194)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash, no shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "200841F"; + flags643dfloorflagsadd = "40"; + } + + 195 + { + title = "Rising Platform, Intangible from Bottom, Translucent"; + prefix = "(195)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash, no shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "2009D1F"; + flags643dfloorflagsadd = "40"; + } + } + + fofcrumbling + { + title = "FOF (crumbling)"; + + 170 + { + title = "Crumbling, Respawn"; + prefix = "(170)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "10019F"; + } + + 171 + { + title = "Crumbling, No Respawn"; + prefix = "(171)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "80019F"; + } + + 172 + { + title = "Crumbling, Respawn, Intangible from Bottom"; + prefix = "(172)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "210841F"; + flags643dfloorflagsadd = "40"; + } + + 173 + { + title = "Crumbling, No Respawn, Intangible from Bottom"; + prefix = "(173)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "218841F"; + flags643dfloorflagsadd = "40"; + } + + 174 + { + title = "Crumbling, Respawn, Int. from Bottom, Translucent"; + prefix = "(174)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "210959F"; + flags643dfloorflagsadd = "40"; + } + + 175 + { + title = "Crumbling, No Respawn, Int. from Bottom, Translucent"; + prefix = "(175)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "218959F"; + flags643dfloorflagsadd = "40"; + } + + 176 + { + title = "Crumbling, Respawn, Floating, Bobbing"; + prefix = "(176)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "14019F"; + } + + 177 + { + title = "Crumbling, No Respawn, Floating, Bobbing"; + prefix = "(177)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1C019F"; + } + + 178 + { + title = "Crumbling, Respawn, Floating"; + prefix = "(178)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "14019F"; + } + + 179 + { + title = "Crumbling, No Respawn, Floating"; + prefix = "(179)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1C019F"; + } + + 180 + { + title = "Crumbling, Respawn, Air Bobbing"; + prefix = "(180)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "10019F"; + } + } + + fofspecial + { + title = "FOF (special)"; + + 200 + { + title = "Light Block"; + prefix = "(200)"; + 3dfloor = true; + 3dfloorflags = "20201"; + } + + 201 + { + title = "Half Light Block"; + prefix = "(201)"; + 3dfloor = true; + 3dfloorflags = "201"; + } + + 202 + { + title = "Fog Block"; + prefix = "(202)"; + 3dfloor = true; + 3dfloorflags = "3EF19"; + } + + 250 + { + title = "Mario Block"; + prefix = "(250)"; + flags32text = "[5] Invisible block"; + flags64text = "[6] Brick block"; + 3dfloor = true; + 3dfloorflags = "40019F"; + } + + 251 + { + title = "Thwomp Block"; + prefix = "(251)"; + flags512text = "[9] Custom crushing sound"; + flags1024text = "[10] Custom speed"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 252 + { + title = "Shatter Block"; + prefix = "(252)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Shatter only from below"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "8800019"; + flags643dfloorflagsadd = "200006"; + } + + 253 + { + title = "Shatter Block, Translucent"; + prefix = "(253)"; + flags8text = "[3] Slope skew sides"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "8801019"; + } + + 254 + { + title = "Bustable Block"; + prefix = "(254)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Strong characters only"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "80001F"; + flags643dfloorflagsadd = "20000000"; + } + + 255 + { + title = "Spin-Bustable Block"; + prefix = "(255)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "1080001F"; + } + + 256 + { + title = "Spin-Bustable Block, Translucent"; + prefix = "(256)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "1080101F"; + } + + 257 + { + title = "Quicksand"; + prefix = "(257)"; + flags8text = "[3] Slope skew sides"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "1008219"; + flags10243dfloorflagsadd = "40000000"; + } + + 258 + { + title = "Laser"; + prefix = "(258)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Don't damage bosses"; + 3dfloor = true; + 3dfloorflags = "959"; + } + + 259 + { + title = "Custom FOF"; + prefix = "(259)"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorcustom = true; + } + } + + linedeftrigger + { + title = "Linedef Executor Trigger"; + + 300 + { + title = "Continuous"; + prefix = "(300)"; + } + + 301 + { + title = "Each Time"; + prefix = "(301)"; + flags16384text = "[14] Also trigger on exit"; + } + + 302 + { + title = "Once"; + prefix = "(302)"; + } + + 303 + { + title = "Ring Count - Continuous"; + prefix = "(303)"; + flags2text = "[1] Rings greater or equal"; + flags64text = "[6] Rings less or equal"; + flags512text = "[9] Consider all players"; + } + + 304 + { + title = "Ring Count - Once"; + prefix = "(304)"; + flags2text = "[1] Rings greater or equal"; + flags64text = "[6] Rings less or equal"; + flags512text = "[9] Consider all players"; + } + + 305 + { + title = "Character Ability - Continuous"; + prefix = "(305)"; + } + + 306 + { + title = "Character Ability - Each Time"; + prefix = "(306)"; + flags16384text = "[14] Also trigger on exit"; + } + + 307 + { + title = "Character Ability - Once"; + prefix = "(307)"; + } + + 308 + { + title = "Race Only - Once"; + prefix = "(308)"; + } + + 309 + { + title = "CTF Red Team - Continuous"; + prefix = "(309)"; + } + + 310 + { + title = "CTF Red Team - Each Time"; + prefix = "(310)"; + flags16384text = "[14] Also trigger on exit"; + } + + 311 + { + title = "CTF Blue Team - Continuous"; + prefix = "(311)"; + } + + 312 + { + title = "CTF Blue Team - Each Time"; + prefix = "(312)"; + flags16384text = "[14] Also trigger on exit"; + } + + 313 + { + title = "No More Enemies - Once"; + prefix = "(313)"; + } + + 314 + { + title = "Number of Pushables - Continuous"; + prefix = "(314)"; + flags64text = "[6] Number greater or equal"; + flags512text = "[9] Number less"; + } + + 315 + { + title = "Number of Pushables - Once"; + prefix = "(315)"; + flags64text = "[6] Number greater or equal"; + flags512text = "[9] Number less"; + } + + 317 + { + title = "Condition Set Trigger - Continuous"; + prefix = "(317)"; + } + + 318 + { + title = "Condition Set Trigger - Once"; + prefix = "(318)"; + } + + 319 + { + title = "Unlockable - Continuous"; + prefix = "(319)"; + } + + 320 + { + title = "Unlockable - Once"; + prefix = "(320)"; + } + + 321 + { + title = "Trigger After X Calls - Continuous"; + prefix = "(321)"; + flags64text = "[6] Trigger more than once"; + + } + + 322 + { + title = "Trigger After X Calls - Each Time"; + prefix = "(322)"; + flags64text = "[6] Trigger more than once"; + } + + 323 + { + title = "NiGHTSerize - Each Time"; + prefix = "(323)"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run only if player is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Run if no more mares"; + flags32768text = "[15] Run if player is not NiGHTS"; + } + + 324 + { + title = "NiGHTSerize - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run only if player is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Run if no more mares"; + flags32768text = "[15] Run if player is not NiGHTS"; + prefix = "(324)"; + } + + 325 + { + title = "De-NiGHTSerize - Each Time"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run if anyone is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags32768text = "[15] Run if no one is NiGHTS"; + prefix = "(325)"; + } + + 326 + { + title = "De-NiGHTSerize - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run if anyone is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags32768text = "[15] Run if no one is NiGHTS"; + prefix = "(326)"; + } + + 327 + { + title = "NiGHTS Lap - Each Time"; + flags2text = "[1] Mare >= Front X Offset"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + prefix = "(327)"; + } + + 328 + { + title = "NiGHTS Lap - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + prefix = "(328)"; + } + + 329 + { + title = "Ideya Capture Touch - Each Time"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run regardless of spheres"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Only if not enough spheres"; + flags32768text = "[15] Run when entering Capture"; + prefix = "(329)"; + } + + 330 + { + title = "Ideya Capture Touch - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run regardless of spheres"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Only if not enough spheres"; + flags32768text = "[15] Run when entering Capture"; + prefix = "(330)"; + } + + 331 + { + title = "Player Skin - Continuous"; + flags64text = "[6] Disable for this skin"; + prefix = "(331)"; + } + + 332 + { + title = "Player Skin - Each Time"; + flags64text = "[6] Disable for this skin"; + prefix = "(332)"; + } + + 333 + { + title = "Player Skin - Once"; + flags64text = "[6] Disable for this skin"; + prefix = "(333)"; + } + + 399 + { + title = "Level Load"; + prefix = "(399)"; + } + } + + linedefexecsector + { + title = "Linedef Executor (sector)"; + + 400 + { + title = "Set Tagged Sector's Floor Height/Texture"; + prefix = "(400)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Keep floor flat"; + } + + 401 + { + title = "Set Tagged Sector's Ceiling Height/Texture"; + prefix = "(401)"; + flags8text = "[3] Set delay by backside sector"; + } + + 402 + { + title = "Set Tagged Sector's Light Level"; + prefix = "(402)"; + flags8text = "[3] Set delay by backside sector"; + } + + 409 + { + title = "Change Tagged Sector's Tag"; + prefix = "(409)"; + flags8text = "[3] Set delay by backside sector"; + } + + 410 + { + title = "Change Front Sector's Tag"; + prefix = "(410)"; + flags8text = "[3] Set delay by backside sector"; + } + + 416 + { + title = "Start Adjustable Flickering Light"; + prefix = "(416)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 417 + { + title = "Start Adjustable Pulsating Light"; + prefix = "(417)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 418 + { + title = "Start Adjustable Blinking Light (unsynchronized)"; + prefix = "(418)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 419 + { + title = "Start Adjustable Blinking Light (synchronized)"; + prefix = "(419)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 420 + { + title = "Fade Light Level"; + prefix = "(420)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Set params by X/Y offsets"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + } + + 421 + { + title = "Stop Lighting Effect"; + prefix = "(421)"; + flags8text = "[3] Set delay by backside sector"; + } + + 435 + { + title = "Change Plane Scroller Direction"; + prefix = "(435)"; + flags8text = "[3] Set delay by backside sector"; + } + } + + linedefexecplane + { + title = "Linedef Executor (plane movement)"; + + 403 + { + title = "Move Tagged Sector's Floor"; + prefix = "(403)"; + flags2text = "[1] Trigger linedef executor"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Change floor flat"; + } + + 404 + { + title = "Move Tagged Sector's Ceiling"; + prefix = "(404)"; + flags2text = "[1] Trigger linedef executor"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Change ceiling flat"; + } + + 405 + { + title = "Move Floor According to Front Texture Offsets"; + prefix = "(405)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Move instantly"; + } + + 407 + { + title = "Move Ceiling According to Front Texture Offsets"; + prefix = "(407)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Move instantly"; + } + + 411 + { + title = "Stop Plane Movement"; + prefix = "(411)"; + flags8text = "[3] Set delay by backside sector"; + } + + 428 + { + title = "Start Platform Movement"; + prefix = "(428)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Move upwards at start"; + } + + 429 + { + title = "Crush Ceiling Once"; + prefix = "(429)"; + flags8text = "[3] Set delay by backside sector"; + flags512text = "[9] Double, constant speed"; + } + + 430 + { + title = "Crush Floor Once"; + prefix = "(430)"; + flags8text = "[3] Set delay by backside sector"; + } + + 431 + { + title = "Crush Floor and Ceiling Once"; + prefix = "(431)"; + flags8text = "[3] Set delay by backside sector"; + flags512text = "[9] Double, constant speed"; + } + } + + linedefexecplayer + { + title = "Linedef Executor (player/object)"; + + 412 + { + title = "Teleporter"; + prefix = "(412)"; + flags2text = "[1] Silent"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Retain angle"; + flags256text = "[8] Relative, silent"; + flags512text = "[9] Retain momentum"; + } + + 425 + { + title = "Change Object State"; + prefix = "(425)"; + flags8text = "[3] Set delay by backside sector"; + } + + 426 + { + title = "Stop Object"; + prefix = "(426)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Teleport to sector center"; + } + + 427 + { + title = "Award Score"; + prefix = "(427)"; + flags8text = "[3] Set delay by backside sector"; + } + + 432 + { + title = "Enable/Disable 2D Mode"; + prefix = "(432)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Return to 3D"; + } + + 433 + { + title = "Enable/Disable Gravity Flip"; + prefix = "(433)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Return to normal"; + } + + 434 + { + title = "Award Power-Up"; + prefix = "(434)"; + flags2text = "[1] Use back upper texture"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] No time limit"; + } + + 437 + { + title = "Disable Player Control"; + prefix = "(437)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Allow jumping"; + } + + 438 + { + title = "Change Object Size"; + prefix = "(438)"; + flags8text = "[3] Set delay by backside sector"; + } + + 442 + { + title = "Change Object Type State"; + prefix = "(442)"; + flags8text = "[3] Set delay by backside sector"; + } + + 457 + { + title = "Track Object's Angle"; + prefix = "(457)"; + flags8text = "[3] Set delay by backside sector"; + flags128text = "[7] Don't stop after first fail"; + } + + 458 + { + title = "Stop Tracking Object's Angle"; + prefix = "(458)"; + flags8text = "[3] Set delay by backside sector"; + } + + 460 + { + title = "Award Rings"; + prefix = "(460)"; + } + + 461 + { + title = "Spawn Object"; + prefix = "(461)"; + flags64text = "[6] Spawn inside a range"; + } + + 462 + { + title = "Stop Timer/Exit Stage in Record Attack"; + prefix = "(462)"; + } + } + + linedefexecmisc + { + title = "Linedef Executor (misc.)"; + + 413 + { + title = "Change Music"; + prefix = "(413)"; + flags2text = "[1] Keep after death"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] Seek to current song position"; + flags64text = "[6] For everyone"; + flags128text = "[7] Fade to custom volume"; + flags512text = "[9] Don't loop"; + flags16384text = "[14] Force music reload"; + } + + 414 + { + title = "Play Sound Effect"; + prefix = "(414)"; + flags2text = "[1] From calling sector"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] From nowhere for triggerer"; + flags512text = "[9] For everyone"; + flags1024text = "[10] From tagged sectors"; + } + + 415 + { + title = "Run Script"; + prefix = "(415)"; + flags8text = "[3] Set delay by backside sector"; + } + + 422 + { + title = "Switch to Cut-Away View"; + prefix = "(422)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Adjust pitch"; + } + + 423 + { + title = "Change Sky"; + prefix = "(423)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] For everyone"; + } + + 424 + { + title = "Change Weather"; + prefix = "(424)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] For everyone"; + } + + 436 + { + title = "Shatter FOF"; + prefix = "(436)"; + flags8text = "[3] Set delay by backside sector"; + } + + 439 + { + title = "Change Tagged Linedef's Textures"; + prefix = "(439)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Only existing"; + } + + 440 + { + title = "Start Metal Sonic Race"; + prefix = "(440)"; + flags8text = "[3] Set delay by backside sector"; + } + + 441 + { + title = "Condition Set Trigger"; + prefix = "(441)"; + flags8text = "[3] Set delay by backside sector"; + } + + 443 + { + title = "Call Lua Function"; + prefix = "(443)"; + flags8text = "[3] Set delay by backside sector"; + } + + 444 + { + title = "Earthquake"; + prefix = "(444)"; + flags8text = "[3] Set delay by backside sector"; + } + + + 445 + { + title = "Make FOF Disappear/Reappear"; + prefix = "(445)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Reappear"; + } + + 446 + { + title = "Make FOF Crumble"; + prefix = "(446)"; + flags2text = "[1] Flags determine respawn"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't respawn"; + } + + 447 + { + title = "Change Tagged Sector's Colormap"; + prefix = "(447)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Front X/Y = Alpha"; + flags32text = "[5] Subtract Red value"; + flags64text = "[6] Subtract Green value"; + flags128text = "[7] Subtract Blue value"; + flags256text = "[8] Calc relative values"; + flags32768text = "[15] Use back side colormap"; + } + + 448 + { + title = "Change Skybox"; + prefix = "(448)"; + flags2text = "[1] Change centerpoint"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] For everyone"; + flags512text = "[9] Don't change viewpoint"; + } + + 450 + { + title = "Execute Linedef Executor (specific tag)"; + prefix = "(450)"; + flags8text = "[3] Set delay by backside sector"; + } + + 451 + { + title = "Execute Linedef Executor (random tag in range)"; + prefix = "(451)"; + flags8text = "[3] Set delay by backside sector"; + } + + 452 + { + title = "Set FOF Translucency"; + prefix = "(452)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Do not handle FF_TRANS"; + flags256text = "[8] Set relative to current val"; + } + + 453 + { + title = "Fade FOF"; + prefix = "(453)"; + flags2text = "[1] Do not handle FF_EXISTS"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] No collision during fade"; + flags64text = "[6] Do not handle FF_TRANS"; + flags128text = "[7] Do not handle lighting"; + flags256text = "[8] Set relative to current val"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + flags16384text = "[14] Do not handle collision"; + flags32768text = "[15] Use exact alpha in OGL"; + } + + 454 + { + title = "Stop Fading FOF"; + prefix = "(454)"; + flags2text = "[1] Do not finalize collision"; + flags8text = "[3] Set delay by backside sector"; + } + + 455 + { + title = "Fade Tagged Sector's Colormap"; + prefix = "(455)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Front X/Y = Alpha"; + flags32text = "[5] Subtract Red value"; + flags64text = "[6] Subtract Green value"; + flags128text = "[7] Subtract Blue value"; + flags256text = "[8] Calc relative values"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + flags16384text = "[14] Fade from invisible black"; + flags32768text = "[15] Use back side colormap"; + } + + 456 + { + title = "Stop Fading Tagged Sector's Colormap"; + prefix = "(456)"; + flags8text = "[3] Set delay by backside sector"; + } + + 459 + { + title = "Control Text Prompt"; + prefix = "(459)"; + flags2text = "[1] Close text prompt"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] Run executor tag on close"; + flags64text = "[6] For everyone"; + flags128text = "[7] Do not block controls"; + flags256text = "[8] Do not freeze time"; + flags32768text = "[15] Find prompt by name"; + } + } + + linedefexecpoly + { + title = "Linedef Executor (polyobject)"; + + 480 + { + title = "Door Slide"; + prefix = "(480)"; + flags8text = "[3] Set delay by backside sector"; + } + + 481 + { + title = "Door Swing"; + prefix = "(481)"; + flags8text = "[3] Set delay by backside sector"; + } + + 482 + { + title = "Move"; + prefix = "(482)"; + flags8text = "[3] Set delay by backside sector"; + } + + 483 + { + title = "Move, Override"; + prefix = "(483)"; + flags8text = "[3] Set delay by backside sector"; + } + + 484 + { + title = "Rotate Right"; + prefix = "(484)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 485 + { + title = "Rotate Right, Override"; + prefix = "(485)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 486 + { + title = "Rotate Left"; + prefix = "(486)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 487 + { + title = "Rotate Left, Override"; + prefix = "(487)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 488 + { + title = "Move by Waypoints"; + prefix = "(488)"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] Reverse order"; + flags128text = "[7] There and back"; + flags256text = "[8] Return when done"; + flags512text = "[9] Loop movement"; + } + + 489 + { + title = "Turn Invisible, Intangible"; + prefix = "(489)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Only invisible"; + } + + 490 + { + title = "Turn Visible, Tangible"; + prefix = "(490)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Only visible"; + } + + 491 + { + title = "Set Translucency"; + prefix = "(491)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Set raw alpha by Front X"; + flags256text = "[8] Calc relative values"; + } + + 492 + { + title = "Fade Translucency"; + prefix = "(492)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Set raw alpha by Front X"; + flags32text = "[5] No collision during fade"; + flags256text = "[8] Calc relative values"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + flags16384text = "[14] Do not handle collision"; + } + } + + wallscroll + { + title = "Wall Scrolling"; + + 500 + { + title = "Scroll Wall Front Side Left"; + prefix = "(500)"; + } + + 501 + { + title = "Scroll Wall Front Side Right"; + prefix = "(501)"; + } + + 502 + { + title = "Scroll Wall According to Linedef"; + prefix = "(502)"; + } + + 503 + { + title = "Scroll Wall According to Linedef (Accelerative)"; + prefix = "(503)"; + } + + 504 + { + title = "Scroll Wall According to Linedef (Displacement)"; + prefix = "(504)"; + } + + 505 + { + title = "Scroll Texture by Front Side Offsets"; + prefix = "(505)"; + } + + 506 + { + title = "Scroll Texture by Back Side Offsets"; + prefix = "(506)"; + } + } + + planescroll + { + title = "Plane Scrolling"; + + 510 + { + title = "Scroll Floor Texture"; + prefix = "(510)"; + } + + 511 + { + title = "Scroll Floor Texture (Accelerative)"; + prefix = "(511)"; + } + + 512 + { + title = "Scroll Floor Texture (Displacement)"; + prefix = "(512)"; + } + + 513 + { + title = "Scroll Ceiling Texture"; + prefix = "(513)"; + } + + 514 + { + title = "Scroll Ceiling Texture (Accelerative)"; + prefix = "(514)"; + } + + 515 + { + title = "Scroll Ceiling Texture (Displacement)"; + prefix = "(515)"; + } + + 520 + { + title = "Carry Objects on Floor"; + prefix = "(520)"; + } + + 521 + { + title = "Carry Objects on Floor (Accelerative)"; + prefix = "(521)"; + flags64text = "[6] Even across edges"; + } + + 522 + { + title = "Carry Objects on Floor (Displacement)"; + prefix = "(522)"; + } + + 523 + { + title = "Carry Objects on Ceiling"; + prefix = "(523)"; + flags64text = "[6] Even across edges"; + } + + 524 + { + title = "Carry Objects on Ceiling (Accelerative)"; + prefix = "(524)"; + } + + 525 + { + title = "Carry Objects on Ceiling (Displacement)"; + prefix = "(525)"; + } + + 530 + { + title = "Scroll Floor Texture and Carry Objects"; + prefix = "(530)"; + flags64text = "[6] Even across edges"; + } + + 531 + { + title = "Scroll Floor Texture and Carry Objects (Accelerative)"; + prefix = "(531)"; + } + + 532 + { + title = "Scroll Floor Texture and Carry Objects (Displacement)"; + prefix = "(532)"; + } + + 533 + { + title = "Scroll Ceiling Texture and Carry Objects"; + prefix = "(533)"; + flags64text = "[6] Even across edges"; + } + + 534 + { + title = "Scroll Ceiling Texture and Carry Objects (Accelerative)"; + prefix = "(534)"; + } + + 535 + { + title = "Scroll Ceiling Texture and Carry Objects (Displacement)"; + prefix = "(535)"; + } + } + + pusher + { + title = "Pusher"; + + 541 + { + title = "Wind"; + prefix = "(541)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 542 + { + title = "Upwards Wind"; + prefix = "(542)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 543 + { + title = "Downwards Wind"; + prefix = "(543)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 544 + { + title = "Current"; + prefix = "(544)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 545 + { + title = "Upwards Current"; + prefix = "(545)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 546 + { + title = "Downwards Current"; + prefix = "(546)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 547 + { + title = "Push/Pull"; + prefix = "(547)"; + } + } + + light + { + title = "Lighting"; + + 600 + { + title = "Floor Lighting"; + prefix = "(600)"; + } + + 601 + { + title = "Ceiling Lighting"; + prefix = "(601)"; + } + + 602 + { + title = "Adjustable Pulsating Light"; + prefix = "(602)"; + } + + 603 + { + title = "Adjustable Flickering Light"; + prefix = "(603)"; + } + + 604 + { + title = "Adjustable Blinking Light (unsynchronized)"; + prefix = "(604)"; + } + + 605 + { + title = "Adjustable Blinking Light (synchronized)"; + prefix = "(605)"; + } + + 606 + { + title = "Colormap"; + prefix = "(606)"; + } + } + + slope + { + title = "Slope"; + + 700 + { + title = "Slope Frontside Floor"; + prefix = "(700)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 1; + } + + 701 + { + title = "Slope Frontside Ceiling"; + prefix = "(701)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 2; + } + + 702 + { + title = "Slope Frontside Floor and Ceiling"; + prefix = "(702)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 3; + } + + 703 + { + title = "Slope Frontside Floor and Backside Ceiling"; + prefix = "(703)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 9; + } + + 704 + { + title = "Slope Frontside Floor by 3 Tagged Vertex Things"; + prefix = "(704)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 0; + } + + 705 + { + title = "Slope Frontside Ceiling by 3 Tagged Vertex Things"; + prefix = "(705)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 1; + } + + 710 + { + title = "Slope Backside Floor"; + prefix = "(710)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 4; + } + + 711 + { + title = "Slope Backside Ceiling"; + prefix = "(711)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 8; + } + + 712 + { + title = "Slope Backside Floor and Ceiling"; + prefix = "(712)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 12; + } + + 713 + { + title = "Slope Backside Floor and Frontside Ceiling"; + prefix = "(713)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 6; + } + + 714 + { + title = "Slope Backside Floor by 3 Tagged Vertex Things"; + prefix = "(714)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 2; + } + + 715 + { + title = "Slope Backside Ceiling by 3 Tagged Vertex Things"; + prefix = "(715)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 3; + } + + 720 + { + title = "Copy Frontside Floor Slope from Line Tag"; + prefix = "(720)"; + slope = "copy"; + slopeargs = 1; + } + + 721 + { + title = "Copy Frontside Ceiling Slope from Line Tag"; + prefix = "(721)"; + slope = "copy"; + slopeargs = 2; + } + + 722 + { + title = "Copy Frontside Floor and Ceiling Slope from Line Tag"; + prefix = "(722)"; + slope = "copy"; + slopeargs = 3; + } + + 799 + { + title = "Set Tagged Dynamic Slope Vertex to Front Sector Height"; + prefix = "(799)"; + } + } + + transwall + { + title = "Translucent Wall"; + + 900 + { + title = "90% Opaque"; + prefix = "(900)"; + } + + 901 + { + title = "80% Opaque"; + prefix = "(901)"; + } + + 902 + { + title = "70% Opaque"; + prefix = "(902)"; + } + + 903 + { + title = "60% Opaque"; + prefix = "(903)"; + } + + 904 + { + title = "50% Opaque"; + prefix = "(904)"; + } + + 905 + { + title = "40% Opaque"; + prefix = "(905)"; + } + + 906 + { + title = "30% Opaque"; + prefix = "(906)"; + } + + 907 + { + title = "20% Opaque"; + prefix = "(907)"; + } + + 908 + { + title = "10% Opaque"; + prefix = "(908)"; + } + + 909 + { + title = "Fog Wall"; + prefix = "(909)"; + } + } +} + +udmf +{ + misc + { + title = "Miscellaneous"; + + 0 + { + title = "None"; + prefix = "(0)"; + } + } +} \ No newline at end of file diff --git a/extras/conf/Includes/SRB222_misc.cfg b/extras/conf/Includes/SRB222_misc.cfg new file mode 100644 index 000000000..ce23388b2 --- /dev/null +++ b/extras/conf/Includes/SRB222_misc.cfg @@ -0,0 +1,726 @@ +linedefflags +{ + 1 = "[0] Impassable"; + 2 = "[1] Block Enemies"; + 4 = "[2] Double-Sided"; + 8 = "[3] Upper Unpegged"; + 16 = "[4] Lower Unpegged"; + 32 = "[5] Slope Skew (E1)"; + 64 = "[6] Not Climbable"; + 128 = "[7] No Midtexture Skew (E2)"; + 256 = "[8] Peg Midtexture (E3)"; + 512 = "[9] Solid Midtexture (E4)"; + 1024 = "[10] Repeat Midtexture (E5)"; + 2048 = "[11] Netgame Only"; + 4096 = "[12] No Netgame"; + 8192 = "[13] Effect 6"; + 16384 = "[14] Bouncy Wall"; + 32768 = "[15] Transfer Line"; +} + + +// LINEDEF ACTIVATIONS +// Make sure these are in order from lowest value to highest value +linedefactivations +{ +} + + +// Linedef flags UDMF translation table +// This is needed for copy/paste and prefabs to work properly +// When the UDMF field name is prefixed with ! it is inverted +linedefflagstranslation +{ + 1 = "blocking"; + 2 = "blockmonsters"; + 4 = "twosided"; + 8 = "dontpegtop"; + 16 = "dontpegbottom"; + 32 = "skewtd"; + 64 = "noclimb"; + 128 = "noskew"; + 256 = "midpeg"; + 512 = "midsolid"; + 1024 = "wrapmidtex"; + 2048 = "netonly"; + 4096 = "nonet"; + 8192 = "effect6"; + 16384 = "bouncy"; + 32768 = "transfer"; +} + + +linedefflags_udmf +{ + blocking = "Impassable"; + blockmonsters = "Block Enemies"; + twosided = "Double-Sided"; + dontpegtop = "Upper Unpegged"; + dontpegbottom = "Lower Unpegged"; + skewtd = "Slope Skew"; + noclimb = "Not Climbable"; + noskew = "No Midtexture Skew"; + midpeg = "Peg Midtexture"; + midsolid = "Solid Midtexture"; + wrapmidtex = "Repeat Midtexture"; +// netonly = "Netgame-Only special"; +// nonet = "No netgame special"; +// effect6 = "Effect 6"; + bouncy = "Bouncy Wall"; +// transfer = "Transfer Line"; +} + + +linedefactivations_udmf +{ + notriggerorder = "Out of Order"; + netonly = "Netgame-Only"; + nonet = "No netgame"; +} + +sidedefflags +{ + clipmidtex = "Clip middle texture"; + wrapmidtex = "Wrap middle texture"; + smoothlighting = "Smooth lighting"; + nofakecontrast = "Even lighting"; + nodecals = "No decals"; + lightfog = "Use sidedef brightness on fogged walls"; +} + +//RENDER STYLES +thingrenderstyles +{ +} + +linedefrenderstyles +{ + translucent = "Translucent"; + fog = "Fog"; +} + +sectorrenderstyles +{ +} + +thingflags +{ + 1 = "[1] Extra"; + 2 = "[2] Flip"; + 4 = "[4] Special"; + 8 = "[8] Ambush"; +} + +// THING FLAGS +thingflags_udmf +{ + extra = "Extra"; + flip = "Flip"; + special = "Special"; + ambush = "Ambush"; +} + + +// Thing flags UDMF translation table +// This is needed for copy/paste and prefabs to work properly +// When the UDMF field name is prefixed with ! it is inverted +thingflagstranslation +{ + 1 = "extra"; + 2 = "flip"; + 4 = "special"; + 8 = "ambush"; +} + + +// DEFAULT SECTOR BRIGHTNESS LEVELS +sectorbrightness +{ + 255; + 248; + 240; + 232; + 224; + 216; + 208; + 200; + 192; + 184; + 176; + 168; + 160; + 152; + 144; + 136; + 128; + 120; + 112; + 104; + 96; + 88; + 80; + 72; + 64; + 56; + 48; + 40; + 32; + 24; + 16; + 8; + 0; +} + +/* +TEXTURES AND FLAT SOURCES +This tells Doom Builder where to find the information for textures +and flats in the IWAD file, Addition WAD file and Map WAD file. + +Start and end lumps must be given in a structure (of which the +key name doesnt matter) and any textures or flats in between them +are loaded in either the textures category or flats category. + +For textures: PNAMES, TEXTURE1 and TEXTURE2 are loaded by default. +*/ +textures +{ + zdoom1 + { + start = "TX_START"; + end = "TX_END"; + } +} + +/* +ADDITIONAL UNIVERSAL DOOM MAP FORMAT FIELD DEFINITIONS +Only add fields here that Doom Builder does not edit with its own user-interface! +The "default" field must match the UDMF specifications! + +Field data types: +0 = integer * +1 = float +2 = string +3 = bool +4 = linedef action (integer) * +5 = sector effect (integer) * +6 = texture (string) +7 = flat (string) +8 = angle in degrees (integer) +9 = angle in radians (float) +10 = XXRRGGBB color (integer) +11 = enum option (integer) * +12 = enum bits (integer) * +13 = sector tag (integer) * +14 = thing tag (integer) * +15 = linedef tag (integer) * +16 = enum option (string) +17 = angle in degrees (float) +22 = byte angle (integer) +*/ +universalfields +{ + sector + { + friction + { + name = "Friction"; + type = 1; + default = 1; + } + + specialeffectplanes + { + type = 11; + enum = "floorceiling"; + default = 0; + } + + colormapbegin + { + type = 0; + default = 0; + } + + colormapend + { + type = 0; + default = 33; + } + + foglighting + { + type = 3; + default = false; + } + + teambase + { + type = 11; + enum = "ctfteam"; + default = 0; + } + + triggersector + { + type = 3; + default = false; + } + + triggerobject + { + type = 11; + enum = "triggerobjects"; + default = 0; + } + + triggersurface + { + type = 11; + enum = "triggersurfaces"; + default = 0; + } + + ringdrain + { + type = 1; + default = 0; + } + } + + linedef + { + executordelay + { + type = 0; + default = 0; + } + midtexrepetitions + { + type = 0; + default = 0; + } + arg5 + { + type = 0; + default = 0; + } + arg1str + { + type = 2; + default = ""; + } + } + + thing + { + } +} + +/* +MAP LUMP NAMES +Map lumps are loaded with the map as long as they are right after each other. When the editor +meets a lump which is not defined in this list it will ignore the map if not satisfied. +The order of items defines the order in which lumps will be written to WAD file on save. +To indicate the map header lump, use ~MAP + +Legenda: +required = Lump is required to exist. +blindcopy = Lump will be copied along with the map blindly. (useful for lumps Doom Builder doesn't use) +nodebuild = The nodebuilder generates this lump. +allowempty = The nodebuilder is allowed to leave this lump empty. +scriptbuild = This lump is a text-based script, which should be compiled using current script compiler; +script = This lump is a text-based script. Specify the filename of the script configuration to use. +*/ + +doommaplumpnames +{ + ~MAP + { + required = true; + blindcopy = true; + nodebuild = false; + } + + THINGS + { + required = true; + nodebuild = true; + allowempty = true; + } + + LINEDEFS + { + required = true; + nodebuild = true; + allowempty = false; + } + + SIDEDEFS + { + required = true; + nodebuild = true; + allowempty = false; + } + + VERTEXES + { + required = true; + nodebuild = true; + allowempty = false; + } + + SEGS + { + required = false; + nodebuild = true; + allowempty = false; + } + + SSECTORS + { + required = false; + nodebuild = true; + allowempty = false; + } + + NODES + { + required = false; + nodebuild = true; + allowempty = false; + } + + SECTORS + { + required = true; + nodebuild = true; + allowempty = false; + } + + REJECT + { + required = false; + nodebuild = true; + allowempty = false; + } + + BLOCKMAP + { + required = false; + nodebuild = true; + allowempty = true; + } +} + +udmfmaplumpnames +{ + ZNODES + { + required = false; + nodebuild = true; + allowempty = false; + } + + REJECT + { + required = false; + nodebuild = true; + allowempty = false; + } + + BLOCKMAP + { + required = false; + nodebuild = true; + allowempty = true; + } +} + +// ENUMERATIONS +// These are enumerated lists for linedef types and UDMF fields. +// Reserved names are: angledeg, anglerad, color, texture, flat +enums +{ + falsetrue + { + 0 = "False"; + 1 = "True"; + } + + yesno + { + 0 = "Yes"; + 1 = "No"; + } + + noyes + { + 0 = "No"; + 1 = "Yes"; + } + + onoff + { + 0 = "On"; + 1 = "Off"; + } + + offon + { + 0 = "Off"; + 1 = "On"; + } + + updown + { + 0 = "Up"; + 1 = "Down"; + } + + downup + { + 0 = "Down"; + 1 = "Up"; + } + + addset + { + 0 = "Add"; + 1 = "Set"; + } + + floorceiling + { + 0 = "Floor"; + 1 = "Ceiling"; + 2 = "Floor and ceiling"; + } + + triggertype + { + 0 = "Continuous"; + 1 = "Each Time (Enter)"; + 2 = "Each Time (Enter and leave)"; + 3 = "Once"; + } + + frontback + { + 0 = "None"; + 1 = "Front"; + 2 = "Back"; + } + + ctfteam + { + 0 = "None"; + 1 = "Red"; + 2 = "Blue"; + } + + triggerobjects + { + 0 = "Any player"; + 1 = "All players"; + 2 = "Pushable object"; + 3 = "Any object with thinker"; + } + + triggersurfaces + { + 0 = "Floor touch"; + 1 = "Ceiling touch"; + 2 = "Floor or ceiling touch"; + 3 = "Anywhere in sector"; + } + + tangibility + { + 1 = "Intangible from top"; + 2 = "Intangible from bottom"; + 4 = "Don't block players"; + 8 = "Don't block non-players"; + } +} + +//Default things filters +thingsfilters +{ + + filter0 + { + name = "Player starts"; + category = "starts"; + type = -1; + } + + + filter1 + { + name = "Enemies"; + category = "enemies"; + type = -1; + + } + + + filter2 + { + name = "NiGHTS Track"; + category = "nightstrk"; + type = -1; + + } + + + filter3 + { + name = "Normal Gravity"; + category = ""; + type = -1; + + fields + { + 2 = false; + } + + } + + + filter4 + { + name = "Reverse Gravity"; + category = ""; + type = -1; + + fields + { + 2 = true; + } + + } +} + +thingsfilters_udmf +{ +} + +// Special linedefs +speciallinedefs +{ + soundlinedefflag = 64; // See linedefflags + singlesidedflag = 1; // See linedefflags + doublesidedflag = 4; // See linedefflags + impassableflag = 1; + upperunpeggedflag = 8; + lowerunpeggedflag = 16; + repeatmidtextureflag = 1024; + pegmidtextureflag = 256; +} + +speciallinedefs_udmf +{ + soundlinedefflag = "noclimb"; + singlesidedflag = "blocking"; + doublesidedflag = "twosided"; + impassableflag = "blocking"; + upperunpeggedflag = "dontpegtop"; + lowerunpeggedflag = "dontpegbottom"; + repeatmidtextureflag = "wrapmidtex"; + pegmidtextureflag = "midpeg"; +} + +scriptlumpnames +{ + MAINCFG + { + script = "SOC.cfg"; + } + + OBJCTCFG + { + script = "SOC.cfg"; + } + + SOC_ + { + script = "SOC.cfg"; + isprefix = true; + } + + LUA_ + { + script = "Lua.cfg"; + isprefix = true; + } +} + +// Texture sources +textures +{ + zdoom1 + { + start = "TX_START"; + end = "TX_END"; + } +} + +// Patch sources +patches +{ + standard1 + { + start = "P_START"; + end = "P_END"; + } + + standard2 + { + start = "PP_START"; + end = "PP_END"; + } +} + +// Sprite sources +sprites +{ + standard1 + { + start = "S_START"; + end = "S_END"; + } + + standard2 + { + start = "SS_START"; + end = "SS_END"; + } +} + +// Flat sources +flats +{ + standard1 + { + start = "F_START"; + end = "F_END"; + } + + standard2 + { + start = "FF_START"; + end = "FF_END"; + } + + standard3 + { + start = "FF_START"; + end = "F_END"; + } + + standard4 + { + start = "F_START"; + end = "FF_END"; + } +} \ No newline at end of file diff --git a/extras/conf/Includes/SRB222_sectors.cfg b/extras/conf/Includes/SRB222_sectors.cfg new file mode 100644 index 000000000..3bcbeb1b1 --- /dev/null +++ b/extras/conf/Includes/SRB222_sectors.cfg @@ -0,0 +1,109 @@ +sectortypes +{ + 0 = "Normal"; + 1 = "Damage"; + 2 = "Damage (Water)"; + 3 = "Damage (Fire)"; + 4 = "Damage (Electrical)"; + 5 = "Spikes"; + 6 = "Death Pit (Camera Tilt)"; + 7 = "Death Pit (No Camera Tilt)"; + 8 = "Instant Kill"; + 9 = "Ring Drainer (Floor Touch)"; + 10 = "Ring Drainer (Anywhere in Sector)"; + 11 = "Special Stage Damage"; + 12 = "Space Countdown"; + 13 = "Ramp Sector (double step-up/down)"; + 14 = "Non-Ramp Sector (no step-down)"; + 15 = "Bouncy FOF"; + 16 = "Trigger Line Ex. (Pushable Objects)"; + 32 = "Trigger Line Ex. (Anywhere, All Players)"; + 48 = "Trigger Line Ex. (Floor Touch, All Players)"; + 64 = "Trigger Line Ex. (Anywhere in Sector)"; + 80 = "Trigger Line Ex. (Floor Touch)"; + 96 = "Trigger Line Ex. (Emerald Check)"; + 112 = "Trigger Line Ex. (NiGHTS Mare)"; + 128 = "Check for Linedef Executor on FOFs"; + 144 = "Egg Capsule"; + 160 = "Special Stage Time/Rings Parameters"; + 176 = "Custom Global Gravity"; + 512 = "Wind/Current"; + 1024 = "Conveyor Belt"; + 1280 = "Speed Pad"; + 4096 = "Star Post Activator"; + 8192 = "Exit/Special Stage Pit/Return Flag"; + 12288 = "CTF Red Team Base"; + 16384 = "CTF Blue Team Base"; + 20480 = "Fan Sector"; + 24576 = "Super Sonic Transform"; + 28672 = "Force Spin"; + 32768 = "Zoom Tube Start"; + 36864 = "Zoom Tube End"; + 40960 = "Circuit Finish Line"; + 45056 = "Rope Hang"; + 49152 = "Intangible to the Camera"; +} + +gen_sectortypes +{ + first + { + 0 = "Normal"; + 1 = "Damage"; + 2 = "Damage (Water)"; + 3 = "Damage (Fire)"; + 4 = "Damage (Electrical)"; + 5 = "Spikes"; + 6 = "Death Pit (Camera Tilt)"; + 7 = "Death Pit (No Camera Tilt)"; + 8 = "Instant Kill"; + 9 = "Ring Drainer (Floor Touch)"; + 10 = "Ring Drainer (Anywhere in Sector)"; + 11 = "Special Stage Damage"; + 12 = "Space Countdown"; + 13 = "Ramp Sector (double step-up/down)"; + 14 = "Non-Ramp Sector (no step-down)"; + 15 = "Bouncy FOF"; + } + + second + { + 0 = "Normal"; + 16 = "Trigger Line Ex. (Pushable Objects)"; + 32 = "Trigger Line Ex. (Anywhere, All Players)"; + 48 = "Trigger Line Ex. (Floor Touch, All Players)"; + 64 = "Trigger Line Ex. (Anywhere in Sector)"; + 80 = "Trigger Line Ex. (Floor Touch)"; + 96 = "Trigger Line Ex. (Emerald Check)"; + 112 = "Trigger Line Ex. (NiGHTS Mare)"; + 128 = "Check for Linedef Executor on FOFs"; + 144 = "Egg Capsule"; + 160 = "Special Stage Time/Rings Parameters"; + 176 = "Custom Global Gravity"; + } + + third + { + 0 = "Normal"; + 512 = "Wind/Current"; + 1024 = "Conveyor Belt"; + 1280 = "Speed Pad"; + } + + fourth + { + 0 = "Normal"; + 4096 = "Star Post Activator"; + 8192 = "Exit/Special Stage Pit/Return Flag"; + 12288 = "CTF Red Team Base"; + 16384 = "CTF Blue Team Base"; + 20480 = "Fan Sector"; + 24576 = "Super Sonic Transform"; + 28672 = "Force Spin"; + 32768 = "Zoom Tube Start"; + 36864 = "Zoom Tube End"; + 40960 = "Circuit Finish Line"; + 45056 = "Rope Hang"; + 49152 = "Intangible to the Camera"; + } +} \ No newline at end of file diff --git a/extras/conf/Includes/SRB222_things.cfg b/extras/conf/Includes/SRB222_things.cfg new file mode 100644 index 000000000..194e43630 --- /dev/null +++ b/extras/conf/Includes/SRB222_things.cfg @@ -0,0 +1,3398 @@ +// THING TYPES------------------------------------------------------------------ +// Color values: 1-Dark_Blue 2-Dark_Green 3-Turqoise 4-Dark_Red 5-Purple 6-Brown 7-Gray +// 8-Dark_Gray 9-Blue 10-Green 11-Cyan 12-Red 13-Magenta +// 14-Yellow 15-White 16-Pink 17-Orange 18-Gold 19-Cream + +editor +{ + color = 15; // White + arrow = 1; + title = ""; + error = -1; + width = 8; + height = 16; + sort = 1; + + 3328 = "3D Mode Start"; +} + +starts +{ + color = 1; // Blue + arrow = 1; + title = "Player Starts"; + width = 16; + height = 48; + flags8text = "[8] Spawn on ceiling"; + sprite = "PLAYA0"; + + 1 + { + title = "Player 01 Start"; + sprite = "PLAYA0"; + } + 2 + { + title = "Player 02 Start"; + sprite = "PLAYA0"; + } + 3 + { + title = "Player 03 Start"; + sprite = "PLAYA0"; + } + 4 + { + title = "Player 04 Start"; + sprite = "PLAYA0"; + } + 5 + { + title = "Player 05 Start"; + sprite = "PLAYA0"; + } + 6 + { + title = "Player 06 Start"; + sprite = "PLAYA0"; + } + 7 + { + title = "Player 07 Start"; + sprite = "PLAYA0"; + } + 8 + { + title = "Player 08 Start"; + sprite = "PLAYA0"; + } + 9 + { + title = "Player 09 Start"; + sprite = "PLAYA0"; + } + 10 + { + title = "Player 10 Start"; + sprite = "PLAYA0"; + } + 11 + { + title = "Player 11 Start"; + sprite = "PLAYA0"; + } + 12 + { + title = "Player 12 Start"; + sprite = "PLAYA0"; + } + 13 + { + title = "Player 13 Start"; + sprite = "PLAYA0"; + } + 14 + { + title = "Player 14 Start"; + sprite = "PLAYA0"; + } + 15 + { + title = "Player 15 Start"; + sprite = "PLAYA0"; + } + 16 + { + title = "Player 16 Start"; + sprite = "PLAYA0"; + } + 17 + { + title = "Player 17 Start"; + sprite = "PLAYA0"; + } + 18 + { + title = "Player 18 Start"; + sprite = "PLAYA0"; + } + 19 + { + title = "Player 19 Start"; + sprite = "PLAYA0"; + } + 20 + { + title = "Player 20 Start"; + sprite = "PLAYA0"; + } + 21 + { + title = "Player 21 Start"; + sprite = "PLAYA0"; + } + 22 + { + title = "Player 22 Start"; + sprite = "PLAYA0"; + } + 23 + { + title = "Player 23 Start"; + sprite = "PLAYA0"; + } + 24 + { + title = "Player 24 Start"; + sprite = "PLAYA0"; + } + 25 + { + title = "Player 25 Start"; + sprite = "PLAYA0"; + } + 26 + { + title = "Player 26 Start"; + sprite = "PLAYA0"; + } + 27 + { + title = "Player 27 Start"; + sprite = "PLAYA0"; + } + 28 + { + title = "Player 28 Start"; + sprite = "PLAYA0"; + } + 29 + { + title = "Player 29 Start"; + sprite = "PLAYA0"; + } + 30 + { + title = "Player 30 Start"; + sprite = "PLAYA0"; + } + 31 + { + title = "Player 31 Start"; + sprite = "PLAYA0"; + } + 32 + { + title = "Player 32 Start"; + sprite = "PLAYA0"; + } + 33 + { + title = "Match Start"; + sprite = "NDRNA2A8"; + } + 34 + { + title = "CTF Red Team Start"; + sprite = "SIGNG0"; + } + 35 + { + title = "CTF Blue Team Start"; + sprite = "SIGNE0"; + } +} + +enemies +{ + color = 9; // Light_Blue + arrow = 1; + title = "Enemies"; + + 100 + { + title = "Crawla (Blue)"; + sprite = "POSSA1"; + width = 24; + height = 32; + } + 101 + { + title = "Crawla (Red)"; + sprite = "SPOSA1"; + width = 24; + height = 32; + } + 102 + { + title = "Stupid Dumb Unnamed RoboFish"; + sprite = "FISHA0"; + width = 8; + height = 28; + angletext = "Jump strength"; + } + 103 + { + title = "Buzz (Gold)"; + sprite = "BUZZA1"; + width = 28; + height = 40; + flags8text = "[8] Cannot move"; + } + 104 + { + title = "Buzz (Red)"; + sprite = "RBUZA1"; + width = 28; + height = 40; + flags8text = "[8] Cannot move"; + } + 108 + { + title = "Deton"; + sprite = "DETNA1"; + width = 20; + height = 32; + } + 110 + { + title = "Turret"; + sprite = "TRETA1"; + width = 16; + height = 32; + } + 111 + { + title = "Pop-up Turret"; + sprite = "TURRI1"; + width = 12; + height = 64; + angletext = "Firing delay"; + } + 122 + { + title = "Spring Shell (Green)"; + sprite = "SSHLA1"; + width = 24; + height = 40; + } + 125 + { + title = "Spring Shell (Yellow)"; + sprite = "SSHLI1"; + width = 24; + height = 40; + } + 109 + { + title = "Skim"; + sprite = "SKIMA1"; + width = 16; + height = 24; + } + 113 + { + title = "Jet Jaw"; + sprite = "JJAWA3A7"; + width = 12; + height = 20; + } + 126 + { + title = "Crushstacean"; + sprite = "CRABA0"; + width = 24; + height = 32; + flags8text = "[8] Move left from spawn"; + } + 138 + { + title = "Banpyura"; + sprite = "CR2BA0"; + width = 24; + height = 32; + flags8text = "[8] Move left from spawn"; + } + 117 + { + title = "Robo-Hood"; + sprite = "ARCHA1"; + width = 24; + height = 32; + } + 118 + { + title = "Lance-a-Bot"; + sprite = "CBFSA1"; + width = 32; + height = 72; + } + 1113 + { + title = "Suspicious Lance-a-Bot Statue"; + sprite = "CBBSA1"; + width = 32; + height = 72; + } + 119 + { + title = "Egg Guard"; + sprite = "ESHIA1"; + width = 16; + height = 48; + flags1text = "[1] 90 degrees counter-clockwise"; + flags4text = "[4] 90 degrees clockwise"; + flags8text = "[8] Double speed"; + } + 115 + { + title = "Bird Aircraft Strike Hazard"; + sprite = "VLTRF1"; + width = 12; + height = 24; + } + 120 + { + title = "Green Snapper"; + sprite = "GSNPA1"; + width = 24; + height = 24; + } + 121 + { + title = "Minus"; + sprite = "MNUSA0"; + width = 24; + height = 32; + } + 134 + { + title = "Canarivore"; + sprite = "CANAA0"; + width = 12; + height = 80; + hangs = 1; + } + 123 + { + title = "Unidus"; + sprite = "UNIDA1"; + width = 18; + height = 36; + } + 135 + { + title = "Pterabyte Spawner"; + sprite = "PTERA2A8"; + width = 16; + height = 16; + parametertext = "No. Pterabytes"; + } + 136 + { + title = "Pyre Fly"; + sprite = "PYREA0"; + width = 24; + height = 34; + flags8text = "[8] Start on fire"; + } + 137 + { + title = "Dragonbomber"; + sprite = "DRABA1"; + width = 28; + height = 48; + } + 105 + { + title = "Jetty-Syn Bomber"; + sprite = "JETBB1"; + width = 20; + height = 50; + flags8text = "[8] Cannot move"; + } + 106 + { + title = "Jetty-Syn Gunner"; + sprite = "JETGB1"; + width = 20; + height = 48; + flags8text = "[8] Cannot move"; + } + 112 + { + title = "Spincushion"; + sprite = "SHRPA1"; + width = 16; + height = 24; + } + 114 + { + title = "Snailer"; + sprite = "SNLRA3A7"; + width = 24; + height = 48; + } + 129 + { + title = "Penguinator"; + sprite = "PENGA1"; + width = 24; + height = 32; + } + 130 + { + title = "Pophat"; + sprite = "POPHA1"; + width = 24; + height = 32; + } + 107 + { + title = "Crawla Commander"; + sprite = "CCOMA1"; + width = 16; + height = 32; + } + 131 + { + title = "Spinbobert"; + sprite = "SBOBB0"; + width = 32; + height = 32; + } + 132 + { + title = "Cacolantern"; + sprite = "CACOA0"; + width = 32; + height = 32; + flags8text = "[8] Cannot move"; + } + 133 + { + title = "Hangster"; + sprite = "HBATC1"; + width = 24; + height = 24; + hangs = 1; + } + 127 + { + title = "Hive Elemental"; + sprite = "HIVEA0"; + width = 32; + height = 80; + parametertext = "No. bees"; + } + 128 + { + title = "Bumblebore"; + sprite = "BUMBA1"; + width = 16; + height = 32; + } + 124 + { + title = "Buggle"; + sprite = "BBUZA1"; + width = 20; + height = 24; + } + 116 + { + title = "Pointy"; + sprite = "PNTYA1"; + width = 8; + height = 16; + } +} + +bosses +{ + color = 8; // Dark_Gray + arrow = 1; + title = "Bosses"; + + 200 + { + title = "Egg Mobile"; + sprite = "EGGMA1"; + width = 24; + height = 76; + flags4text = "[4] End level on death"; + flags8text = "[8] Alternate laser attack"; + } + 201 + { + title = "Egg Slimer"; + sprite = "EGGNA1"; + width = 24; + height = 76; + flags4text = "[4] End level on death"; + flags8text = "[8] Speed up when hit"; + } + 202 + { + title = "Sea Egg"; + sprite = "EGGOA1"; + width = 32; + height = 116; + flags4text = "[4] End level on death"; + } + 203 + { + title = "Egg Colosseum"; + sprite = "EGGPA1"; + width = 24; + height = 76; + flags4text = "[4] End level on death"; + } + 204 + { + title = "Fang"; + sprite = "FANGA1"; + width = 24; + height = 60; + flags1text = "[1] Grayscale mode"; + flags4text = "[4] End level on death"; + } + 206 + { + title = "Brak Eggman (Old)"; + sprite = "BRAKB1"; + width = 48; + height = 160; + flags4text = "[4] End level on death"; + } + 207 + { + title = "Metal Sonic (Race)"; + sprite = "METLI1"; + width = 16; + height = 48; + flags1text = "[1] Grayscale mode"; + } + 208 + { + title = "Metal Sonic (Battle)"; + sprite = "METLC1"; + width = 16; + height = 48; + flags1text = "[1] Grayscale mode"; + flags4text = "[4] End level on death"; + } + 209 + { + title = "Brak Eggman"; + sprite = "BRAK01"; + width = 48; + height = 160; + flags1text = "[1] No origin-fling death"; + flags4text = "[4] End level on death"; + flags8text = "[8] Electric barrier"; + } + 290 + { + arrow = 0; + title = "Boss Escape Point"; + width = 8; + height = 16; + sprite = "internal:eggmanend"; + } + 291 + { + arrow = 0; + title = "Egg Capsule Center"; + width = 8; + height = 16; + sprite = "internal:capsule"; + } + 292 + { + arrow = 0; + title = "Boss Waypoint"; + width = 8; + height = 16; + flags8text = "[8] Sea Egg shooting point"; + sprite = "internal:eggmanway"; + angletext = "No. (Sea Egg)"; + flagsvaluetext = "No. (Brak)"; + parametertext = "Next"; + } + 293 + { + title = "Metal Sonic Gather Point"; + sprite = "internal:metal"; + width = 8; + height = 16; + } + 294 + { + title = "Fang Waypoint"; + flags8text = "[8] Center waypoint"; + sprite = "internal:eggmanway"; + width = 8; + height = 16; + } +} + +rings +{ + color = 14; // Yellow + title = "Rings and Weapon Panels"; + width = 24; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + sprite = "RINGA0"; + + 300 + { + title = "Ring"; + sprite = "RINGA0"; + width = 16; + } + 301 + { + title = "Bounce Ring"; + sprite = "internal:RNGBA0"; + } + 302 + { + title = "Rail Ring"; + sprite = "internal:RNGRA0"; + } + 303 + { + title = "Infinity Ring"; + sprite = "internal:RNGIA0"; + } + 304 + { + title = "Automatic Ring"; + sprite = "internal:RNGAA0"; + } + 305 + { + title = "Explosion Ring"; + sprite = "internal:RNGEA0"; + } + 306 + { + title = "Scatter Ring"; + sprite = "internal:RNGSA0"; + } + 307 + { + title = "Grenade Ring"; + sprite = "internal:RNGGA0"; + } + 308 + { + title = "CTF Team Ring (Red)"; + sprite = "internal:RRNGA0"; + width = 16; + } + 309 + { + title = "CTF Team Ring (Blue)"; + sprite = "internal:BRNGA0"; + width = 16; + } + 330 + { + title = "Bounce Ring Panel"; + sprite = "internal:PIKBA0"; + } + 331 + { + title = "Rail Ring Panel"; + sprite = "internal:PIKRA0"; + } + 332 + { + title = "Automatic Ring Panel"; + sprite = "internal:PIKAA0"; + } + 333 + { + title = "Explosion Ring Panel"; + sprite = "internal:PIKEA0"; + } + 334 + { + title = "Scatter Ring Panel"; + sprite = "internal:PIKSA0"; + } + 335 + { + title = "Grenade Ring Panel"; + sprite = "internal:PIKGA0"; + } +} + +collectibles +{ + color = 10; // Light_Green + title = "Other Collectibles"; + width = 16; + height = 32; + sort = 1; + sprite = "CEMGA0"; + + 310 + { + title = "CTF Red Flag"; + sprite = "RFLGA0"; + width = 24; + height = 64; + } + 311 + { + title = "CTF Blue Flag"; + sprite = "BFLGA0"; + width = 24; + height = 64; + } + 312 + { + title = "Emerald Token"; + sprite = "TOKEA0"; + width = 16; + height = 32; + flags8height = 24; + flags8text = "[8] Float"; + } + 313 + { + title = "Chaos Emerald 1 (Green)"; + sprite = "CEMGA0"; + } + 314 + { + title = "Chaos Emerald 2 (Purple)"; + sprite = "CEMGB0"; + } + 315 + { + title = "Chaos Emerald 3 (Blue)"; + sprite = "CEMGC0"; + } + 316 + { + title = "Chaos Emerald 4 (Cyan)"; + sprite = "CEMGD0"; + } + 317 + { + title = "Chaos Emerald 5 (Orange)"; + sprite = "CEMGE0"; + } + 318 + { + title = "Chaos Emerald 6 (Red)"; + sprite = "CEMGF0"; + } + 319 + { + title = "Chaos Emerald 7 (Gray)"; + sprite = "CEMGG0"; + } + 320 + { + title = "Emerald Hunt Location"; + sprite = "SHRDA0"; + } + 321 + { + title = "Match Chaos Emerald Spawn"; + sprite = "CEMGA0"; + flags8height = 24; + flags8text = "[8] Float"; + } + 322 + { + title = "Emblem"; + sprite = "EMBMA0"; + width = 16; + height = 30; + flags8height = 24; + flags8text = "[8] Float"; + angletext = "Tag"; + } +} + +boxes +{ + color = 7; // Gray + blocking = 2; + title = "Monitors"; + width = 18; + height = 40; + flags1text = "[1] Run Linedef Executor on pop"; + flags4text = "[4] Random (Strong)"; + flags8text = "[8] Random (Weak)"; + + 400 + { + title = "Super Ring (10 Rings)"; + sprite = "TVRIA0"; + } + 401 + { + title = "Pity Shield"; + sprite = "TVPIA0"; + } + 402 + { + title = "Attraction Shield"; + sprite = "TVATA0"; + } + 403 + { + title = "Force Shield"; + sprite = "TVFOA0"; + } + 404 + { + title = "Armageddon Shield"; + sprite = "TVARA0"; + } + 405 + { + title = "Whirlwind Shield"; + sprite = "TVWWA0"; + } + 406 + { + title = "Elemental Shield"; + sprite = "TVELA0"; + } + 407 + { + title = "Super Sneakers"; + sprite = "TVSSA0"; + } + 408 + { + title = "Invincibility"; + sprite = "TVIVA0"; + } + 409 + { + title = "Extra Life"; + sprite = "TV1UA0"; + flags4text = "[4] Random (Strong) / 10k points"; + flags8text = "[8] Random (Weak) / 10k points"; + } + 410 + { + title = "Eggman"; + sprite = "TVEGA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 411 + { + title = "Teleporter"; + sprite = "TVMXA0"; + } + 413 + { + title = "Gravity Boots"; + sprite = "TVGVA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 414 + { + title = "CTF Team Ring Monitor (Red)"; + sprite = "TRRIA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 415 + { + title = "CTF Team Ring Monitor (Blue)"; + sprite = "TBRIA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 416 + { + title = "Recycler"; + sprite = "TVRCA0"; + } + 418 + { + title = "Score (1,000 Points)"; + sprite = "TV1KA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 419 + { + title = "Score (10,000 Points)"; + sprite = "TVTKA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 420 + { + title = "Flame Shield"; + sprite = "TVFLA0"; + } + 421 + { + title = "Water Shield"; + sprite = "TVBBA0"; + } + 422 + { + title = "Lightning Shield"; + sprite = "TVZPA0"; + } +} + +boxes2 +{ + color = 18; // Gold + blocking = 2; + title = "Monitors (Respawning)"; + width = 20; + height = 44; + flags1text = "[1] Run Linedef Executor on pop"; + + 431 + { + title = "Pity Shield (Respawn)"; + sprite = "TVPIB0"; + } + 432 + { + title = "Attraction Shield (Respawn)"; + sprite = "TVATB0"; + } + 433 + { + title = "Force Shield (Respawn)"; + sprite = "TVFOB0"; + } + 434 + { + title = "Armageddon Shield (Respawn)"; + sprite = "TVARB0"; + } + 435 + { + title = "Whirlwind Shield (Respawn)"; + sprite = "TVWWB0"; + } + 436 + { + title = "Elemental Shield (Respawn)"; + sprite = "TVELB0"; + } + 437 + { + title = "Super Sneakers (Respawn)"; + sprite = "TVSSB0"; + } + 438 + { + title = "Invincibility (Respawn)"; + sprite = "TVIVB0"; + } + 440 + { + title = "Eggman (Respawn)"; + sprite = "TVEGB0"; + } + 443 + { + title = "Gravity Boots (Respawn)"; + sprite = "TVGVB0"; + } + 450 + { + title = "Flame Shield (Respawn)"; + sprite = "TVFLB0"; + } + 451 + { + title = "Water Shield (Respawn)"; + sprite = "TVBBB0"; + } + 452 + { + title = "Lightning Shield (Respawn)"; + sprite = "TVZPB0"; + } +} + +generic +{ + color = 11; // Light_Cyan + title = "Generic Items & Hazards"; + + 500 + { + title = "Air Bubble Patch"; + sprite = "BUBLE0"; + width = 8; + height = 16; + flags8text = "[8] No distance check"; + } + 501 + { + title = "Signpost"; + sprite = "SIGND0"; + width = 8; + height = 32; + } + 502 + { + arrow = 1; + title = "Star Post"; + sprite = "STPTA0M0"; + width = 64; + height = 128; + angletext = "Angle/Order"; + } + 520 + { + title = "Bomb Sphere"; + sprite = "SPHRD0"; + width = 16; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + unflippable = true; + } + 521 + { + title = "Spikeball"; + sprite = "SPIKA0"; + width = 12; + height = 8; + flags8height = 24; + flags8text = "[8] Float"; + } + 522 + { + title = "Wall Spike"; + sprite = "WSPKALAR"; + width = 16; + height = 14; + flags1text = "[1] Start retracted"; + flags4text = "[4] Retractable"; + flags8text = "[8] Intangible"; + parametertext = "Initial delay"; + } + 523 + { + title = "Spike"; + sprite = "USPKA0"; + width = 8; + height = 32; + flags1text = "[1] Start retracted"; + flags4text = "[4] Retractable"; + flags8text = "[8] Intangible"; + angletext = "Retraction interval"; + parametertext = "Initial delay"; + } + 1130 + { + title = "Small Mace"; + sprite = "SMCEA0"; + width = 17; + height = 34; + } + 1131 + { + title = "Big Mace"; + sprite = "BMCEA0"; + width = 34; + height = 68; + } + 1136 + { + title = "Small Fireball"; + sprite = "SFBRA0"; + width = 17; + height = 34; + } + 1137 + { + title = "Large Fireball"; + sprite = "BFBRA0"; + width = 34; + height = 68; + } +} + +springs +{ + color = 12; // Light_Red + title = "Springs and Fans"; + width = 20; + height = 16; + sprite = "RSPRD2"; + + 540 + { + title = "Fan"; + sprite = "FANSA0D0"; + width = 16; + height = 8; + flags4text = "[4] Invisible"; + flags8text = "[8] No distance check"; + angletext = "Lift height"; + } + 541 + { + title = "Gas Jet"; + sprite = "STEMD0"; + flags8text = "[8] No sounds"; + width = 32; + } + 542 + { + title = "Bumper"; + sprite = "BUMPA0"; + width = 32; + height = 64; + angletext = "Strength"; + } + 543 + { + title = "Balloon"; + sprite = "BLONA0"; + width = 32; + height = 64; + flags8text = "[8] Respawn"; + angletext = "Color"; + } + 550 + { + title = "Yellow Spring"; + sprite = "SPRYA0"; + } + 551 + { + title = "Red Spring"; + sprite = "SPRRA0"; + } + 552 + { + title = "Blue Spring"; + sprite = "SPRBA0"; + } + 555 + { + arrow = 1; + title = "Diagonal Yellow Spring"; + sprite = "YSPRD2"; + width = 16; + flags4text = "[4] Ignore gravity"; + flags8text = "[8] Rotate 22.5° CCW"; + } + 556 + { + arrow = 1; + title = "Diagonal Red Spring"; + sprite = "RSPRD2"; + width = 16; + flags4text = "[4] Ignore gravity"; + flags8text = "[8] Rotate 22.5° CCW"; + } + 557 + { + arrow = 1; + title = "Diagonal Blue Spring"; + sprite = "BSPRD2"; + width = 16; + flags4text = "[4] Ignore gravity"; + flags8text = "[8] Rotate 22.5° CCW"; + } + 558 + { + arrow = 1; + title = "Horizontal Yellow Spring"; + sprite = "SSWYD2D8"; + flags8height = 16; + flags8text = "[8] Float"; + width = 16; + height = 32; + } + 559 + { + arrow = 1; + title = "Horizontal Red Spring"; + sprite = "SSWRD2D8"; + flags8height = 16; + flags8text = "[8] Float"; + width = 16; + height = 32; + } + 560 + { + arrow = 1; + title = "Horizontal Blue Spring"; + sprite = "SSWBD2D8"; + flags8height = 16; + flags8text = "[8] Float"; + width = 16; + height = 32; + } + 1134 + { + title = "Yellow Spring Ball"; + sprite = "YSPBA0"; + width = 17; + height = 34; + } + 1135 + { + title = "Red Spring Ball"; + sprite = "RSPBA0"; + width = 17; + height = 34; + } + 544 + { + arrow = 1; + title = "Yellow Boost Panel"; + sprite = "BSTYA0"; + flags8text = "[8] Force spin"; + width = 28; + height = 2; + } + 545 + { + arrow = 1; + title = "Red Boost Panel"; + sprite = "BSTRA0"; + flags8text = "[8] Force spin"; + width = 28; + height = 2; + } +} + +patterns +{ + color = 5; // Magenta + arrow = 1; + title = "Special Placement Patterns"; + width = 16; + height = 384; + sprite = "RINGA0"; + + 600 + { + arrow = 0; + title = "5 Vertical Rings (Yellow Spring)"; + sprite = "RINGA0"; + } + 601 + { + arrow = 0; + title = "5 Vertical Rings (Red Spring)"; + sprite = "RINGA0"; + height = 1024; + } + 602 + { + title = "5 Diagonal Rings (Yellow Spring)"; + sprite = "RINGA0"; + height = 32; + } + 603 + { + title = "10 Diagonal Rings (Red Spring)"; + sprite = "RINGA0"; + height = 32; + } + 604 + { + title = "Circle of Rings"; + sprite = "RINGA0"; + width = 96; + height = 192; + unflippable = true; + centerHitbox = true; + } + 605 + { + title = "Circle of Rings (Big)"; + sprite = "RINGA0"; + width = 192; + unflippable = true; + centerHitbox = true; + } + 606 + { + title = "Circle of Blue Spheres"; + sprite = "SPHRA0"; + width = 96; + height = 192; + unflippable = true; + centerHitbox = true; + } + 607 + { + title = "Circle of Blue Spheres (Big)"; + sprite = "SPHRA0"; + width = 192; + unflippable = true; + centerHitbox = true; + } + 608 + { + title = "Circle of Rings and Spheres"; + sprite = "SPHRA0"; + width = 96; + height = 192; + unflippable = true; + centerHitbox = true; + } + 609 + { + title = "Circle of Rings and Spheres (Big)"; + sprite = "SPHRA0"; + width = 192; + unflippable = true; + centerHitbox = true; + } +} + +invisible +{ + color = 15; // White + title = "Misc. Invisible"; + width = 0; + height = 0; + sprite = "UNKNA0"; + sort = 1; + fixedsize = true; + blocking = 0; + + 700 + { + title = "Water Ambience A (Large)"; + sprite = "internal:ambiance"; + } + + 701 + { + title = "Water Ambience B (Large)"; + sprite = "internal:ambiance"; + } + + 702 + { + title = "Water Ambience C (Medium)"; + sprite = "internal:ambiance"; + } + + 703 + { + title = "Water Ambience D (Medium)"; + sprite = "internal:ambiance"; + } + + 704 + { + title = "Water Ambience E (Small)"; + sprite = "internal:ambiance"; + } + + 705 + { + title = "Water Ambience F (Small)"; + sprite = "internal:ambiance"; + } + + 706 + { + title = "Water Ambience G (Extra Large)"; + sprite = "internal:ambiance"; + } + + 707 + { + title = "Water Ambience H (Extra Large)"; + sprite = "internal:ambiance"; + } + + 708 + { + title = "Disco Ambience"; + sprite = "internal:ambiance"; + } + + 709 + { + title = "Volcano Ambience"; + sprite = "internal:ambiance"; + } + + 710 + { + title = "Machine Ambience"; + sprite = "internal:ambiance"; + } + + 750 + { + title = "Slope Vertex"; + sprite = "internal:vertexslope"; + angletext = "Tag"; + } + + 751 + { + arrow = 1; + title = "Teleport Destination"; + sprite = "internal:tele"; + } + + 752 + { + arrow = 1; + title = "Alternate View Point"; + sprite = "internal:view"; + } + + 753 + { + title = "Zoom Tube Waypoint"; + sprite = "internal:zoom"; + angletext = "Order"; + } + + 754 + { + title = "Push Point"; + flags4text = "[4] Fades using XY"; + flags8text = "[8] Push using XYZ"; + sprite = "GWLGA0"; + angletext = "Radius"; + } + 755 + { + title = "Pull Point"; + flags4text = "[4] Fades using XY"; + flags8text = "[8] Pull using XYZ"; + sprite = "GWLRA0"; + angletext = "Radius"; + } + 756 + { + title = "Blast Linedef Executor"; + sprite = "TOADA0"; + width = 32; + height = 16; + } + 757 + { + title = "Fan Particle Generator"; + sprite = "PRTLA0"; + width = 8; + height = 16; + angletext = "Tag"; + } + 758 + { + title = "Object Angle Anchor"; + sprite = "internal:view"; + } + 760 + { + title = "PolyObject Anchor"; + sprite = "internal:polyanchor"; + angletext = "ID"; + } + + 761 + { + title = "PolyObject Spawn Point"; + sprite = "internal:polycenter"; + angletext = "ID"; + } + + 762 + { + title = "PolyObject Spawn Point (Crush)"; + sprite = "internal:polycentercrush"; + angletext = "ID"; + } + 780 + { + title = "Skybox View Point"; + sprite = "internal:skyb"; + flags4text = "[4] In-map centerpoint"; + parametertext = "ID"; + } +} + +greenflower +{ + color = 10; // Green + title = "Greenflower"; + + 800 + { + title = "GFZ Flower"; + sprite = "FWR1A0"; + width = 16; + height = 40; + } + 801 + { + title = "Sunflower"; + sprite = "FWR2A0"; + width = 16; + height = 96; + } + 802 + { + title = "Budding Flower"; + sprite = "FWR3A0"; + width = 8; + height = 32; + } + 803 + { + title = "Blueberry Bush"; + sprite = "BUS3A0"; + width = 16; + height = 32; + } + 804 + { + title = "Berry Bush"; + sprite = "BUS1A0"; + width = 16; + height = 32; + } + 805 + { + title = "Bush"; + sprite = "BUS2A0"; + width = 16; + height = 32; + } + 806 + { + title = "GFZ Tree"; + sprite = "TRE1A0"; + width = 20; + height = 128; + } + 807 + { + title = "GFZ Berry Tree"; + sprite = "TRE1B0"; + width = 20; + height = 128; + } + 808 + { + title = "GFZ Cherry Tree"; + sprite = "TRE1C0"; + width = 20; + height = 128; + } + 809 + { + title = "Checkered Tree"; + sprite = "TRE2A0"; + width = 20; + height = 200; + } + 810 + { + title = "Checkered Tree (Sunset)"; + sprite = "TRE2B0"; + width = 20; + height = 200; + } + 811 + { + title = "Polygon Tree"; + sprite = "TRE4A0"; + width = 20; + height = 200; + } + 812 + { + title = "Bush Tree"; + sprite = "TRE5A0"; + width = 20; + height = 200; + } + 813 + { + title = "Red Bush Tree"; + sprite = "TRE5B0"; + width = 20; + height = 200; + } +} + +technohill +{ + color = 10; // Green + title = "Techno Hill"; + + 900 + { + title = "THZ Steam Flower"; + sprite = "THZPA0"; + width = 8; + height = 32; + } + 901 + { + title = "Alarm"; + sprite = "ALRMA0"; + width = 8; + height = 16; + hangs = 1; + } + 902 + { + title = "THZ Spin Flower (Red)"; + sprite = "FWR5A0"; + width = 16; + height = 64; + } + 903 + { + title = "THZ Spin Flower (Yellow)"; + sprite = "FWR6A0"; + width = 16; + height = 64; + } + 904 + { + arrow = 1; + title = "Whistlebush"; + sprite = "THZTA0"; + width = 16; + height = 64; + } +} + +deepsea +{ + color = 10; // Green + title = "Deep Sea"; + + 1000 + { + arrow = 1; + blocking = 2; + title = "Gargoyle"; + sprite = "GARGA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1009 + { + arrow = 1; + blocking = 2; + title = "Gargoyle (Big)"; + sprite = "GARGB1"; + width = 32; + height = 80; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1001 + { + title = "Seaweed"; + sprite = "SEWEA0"; + width = 24; + height = 56; + } + 1002 + { + title = "Dripping Water"; + sprite = "DRIPD0"; + width = 8; + height = 16; + hangs = 1; + angletext = "Dripping interval"; + } + 1003 + { + title = "Coral (Green)"; + sprite = "CORLA0"; + width = 29; + height = 40; + } + 1004 + { + title = "Coral (Red)"; + sprite = "CORLB0"; + width = 30; + height = 53; + } + 1005 + { + title = "Coral (Orange)"; + sprite = "CORLC0"; + width = 28; + height = 41; + } + 1006 + { + title = "Blue Crystal"; + sprite = "BCRYA1"; + width = 8; + height = 16; + } + 1007 + { + title = "Kelp"; + sprite = "KELPA0"; + width = 16; + height = 292; + flags4text = "[4] Double size"; + } + 1008 + { + title = "Stalagmite (DSZ1)"; + sprite = "DSTGA0"; + width = 8; + height = 116; + flags4text = "[4] Double size"; + } + 1010 + { + arrow = 1; + title = "Light Beam"; + sprite = "LIBEARAL"; + width = 16; + height = 16; + } + 1011 + { + title = "Stalagmite (DSZ2)"; + sprite = "DSTGA0"; + width = 8; + height = 116; + flags4text = "[4] Double size"; + } + 1012 + { + arrow = 1; + title = "Big Floating Mine"; + width = 28; + height = 56; + sprite = "BMNEA1"; + } + 1013 + { + title = "Animated Kelp"; + sprite = "ALGAA0"; + width = 48; + height = 120; + } + 1014 + { + title = "Large Coral (Brown)"; + sprite = "CORLD0"; + width = 56; + height = 112; + } + 1015 + { + title = "Large Coral (Beige)"; + sprite = "CORLE0"; + width = 56; + height = 112; + } +} + +castleeggman +{ + color = 10; // Green + title = "Castle Eggman"; + + 1100 + { + title = "Chain (Decorative)"; + sprite = "CHANA0"; + width = 4; + height = 128; + hangs = 1; + } + 1101 + { + title = "Torch"; + sprite = "FLAMA0E0"; + width = 8; + height = 32; + flags1text = "[1] Add corona"; + } + 1102 + { + arrow = 1; + blocking = 2; + title = "Eggman Statue"; + sprite = "ESTAA1"; + width = 32; + height = 240; + flags1text = "[1] Solid gold"; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1103 + { + title = "CEZ Flower"; + sprite = "FWR4A0"; + width = 16; + height = 40; + } + 1104 + { + title = "Mace Spawnpoint"; + sprite = "SMCEA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1105 + { + title = "Chain with Maces Spawnpoint"; + sprite = "SMCEA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1106 + { + title = "Chained Spring Spawnpoint"; + sprite = "YSPBA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Red spring"; + angletext = "Tag"; + } + 1107 + { + title = "Chain Spawnpoint"; + sprite = "BMCHA0"; + width = 17; + height = 34; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1108 + { + arrow = 1; + title = "Hidden Chain Spawnpoint"; + sprite = "internal:chain3"; + width = 17; + height = 34; + flags8text = "[8] Double size"; + } + 1109 + { + title = "Firebar Spawnpoint"; + sprite = "BFBRA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1110 + { + title = "Custom Mace Spawnpoint"; + sprite = "SMCEA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + angletext = "Tag"; + } + 1111 + { + arrow = 1; + blocking = 2; + title = "Crawla Statue"; + sprite = "CSTAA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1112 + { + arrow = 1; + blocking = 2; + title = "Lance-a-Bot Statue"; + sprite = "CBBSA1"; + width = 32; + height = 72; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1114 + { + title = "Pine Tree"; + sprite = "PINEA0"; + width = 16; + height = 628; + } + 1115 + { + title = "CEZ Shrub (Small)"; + sprite = "CEZBA0"; + width = 16; + height = 24; + } + 1116 + { + title = "CEZ Shrub (Large)"; + sprite = "CEZBB0"; + width = 32; + height = 48; + } + 1117 + { + arrow = 1; + title = "Pole Banner (Red)"; + sprite = "BANRA0"; + width = 40; + height = 224; + } + 1118 + { + arrow = 1; + title = "Pole Banner (Blue)"; + sprite = "BANRA0"; + width = 40; + height = 224; + } + 1119 + { + title = "Candle"; + sprite = "CNDLA0"; + width = 8; + height = 48; + flags1text = "[1] Add corona"; + } + 1120 + { + title = "Candle Pricket"; + sprite = "CNDLB0"; + width = 8; + height = 176; + flags1text = "[1] Add corona"; + } + 1121 + { + title = "Flame Holder"; + sprite = "FLMHA0"; + width = 24; + height = 80; + flags1text = "[1] Add corona"; + flags4text = "[4] No flame"; + } + 1122 + { + title = "Fire Torch"; + sprite = "CTRCA0"; + width = 16; + height = 80; + } + 1123 + { + title = "Cannonball Launcher"; + sprite = "internal:cannonball"; + width = 8; + height = 16; + } + 1124 + { + blocking = 2; + title = "Cannonball"; + sprite = "CBLLA0"; + width = 20; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1125 + { + title = "Brambles"; + sprite = "CABRALAR"; + width = 48; + height = 32; + } + 1126 + { + title = "Invisible Lockon Object"; + sprite = "LCKNC0"; + width = 16; + height = 32; + } + 1127 + { + title = "Spectator Eggrobo"; + sprite = "EGR1A1"; + width = 20; + height = 72; + } + 1128 + { + arrow = 1; + title = "Waving Flag (Red)"; + sprite = "CFLGA0"; + width = 8; + height = 208; + } + 1129 + { + arrow = 1; + title = "Waving Flag (Blue)"; + sprite = "CFLGA0"; + width = 8; + height = 208; + } +} + +aridcanyon +{ + color = 10; // Green + title = "Arid Canyon"; + + 1200 + { + title = "Tumbleweed (Big)"; + sprite = "BTBLA0"; + width = 24; + height = 48; + flags8text = "[8] Moves perpetually"; + } + 1201 + { + title = "Tumbleweed (Small)"; + sprite = "STBLA0"; + width = 12; + height = 24; + flags8text = "[8] Moves perpetually"; + } + 1202 + { + arrow = 1; + title = "Rock Spawner"; + sprite = "ROIAA0"; + width = 8; + height = 16; + angletext = "Tag"; + } + 1203 + { + title = "Tiny Red Flower Cactus"; + sprite = "CACTA0"; + width = 13; + height = 24; + } + 1204 + { + title = "Small Red Flower Cactus"; + sprite = "CACTB0"; + width = 15; + height = 52; + } + 1205 + { + title = "Tiny Blue Flower Cactus"; + sprite = "CACTC0"; + width = 13; + height = 24; + } + 1206 + { + title = "Small Blue Flower Cactus"; + sprite = "CACTD0"; + width = 15; + height = 52; + } + 1207 + { + title = "Prickly Pear"; + sprite = "CACTE0"; + width = 32; + height = 96; + } + 1208 + { + title = "Barrel Cactus"; + sprite = "CACTF0"; + width = 20; + height = 128; + } + 1209 + { + title = "Tall Barrel Cactus"; + sprite = "CACTG0"; + width = 24; + height = 224; + } + 1210 + { + title = "Armed Cactus"; + sprite = "CACTH0"; + width = 24; + height = 256; + } + 1211 + { + title = "Ball Cactus"; + sprite = "CACTI0"; + width = 48; + height = 96; + } + 1212 + { + title = "Caution Sign"; + sprite = "WWSGAR"; + width = 22; + height = 64; + } + 1213 + { + title = "Cacti Sign"; + sprite = "WWS2AR"; + width = 22; + height = 64; + } + 1214 + { + title = "Sharp Turn Sign"; + sprite = "WWS3ALAR"; + width = 16; + height = 192; + } + 1215 + { + title = "Mine Oil Lamp"; + sprite = "OILLA0"; + width = 22; + height = 64; + hangs = 1; + } + 1216 + { + title = "TNT Barrel"; + sprite = "BARRA1"; + width = 24; + height = 63; + } + 1217 + { + title = "TNT Proximity Shell"; + sprite = "REMTA0"; + width = 64; + height = 40; + } + 1218 + { + title = "Dust Devil"; + sprite = "TAZDCR"; + width = 80; + height = 416; + } + 1219 + { + title = "Minecart Spawner"; + sprite = "MCRTCLFR"; + width = 22; + height = 32; + } + 1220 + { + title = "Minecart Stopper"; + sprite = "MCRTIR"; + width = 32; + height = 32; + } + 1221 + { + title = "Minecart Saloon Door"; + sprite = "SALDARAL"; + width = 96; + height = 160; + flags8text = "[8] Allow non-minecart players"; + } + 1222 + { + title = "Train Cameo Spawner"; + sprite = "TRAEBRBL"; + width = 28; + height = 32; + } + 1223 + { + title = "Train Dust Spawner"; + sprite = "ADSTA0"; + width = 4; + height = 4; + } + 1224 + { + title = "Train Steam Spawner"; + sprite = "STEAA0"; + width = 4; + height = 4; + } + 1229 + { + title = "Minecart Switch Point"; + sprite = "internal:zoom"; + width = 8; + height = 16; + flags8text = "[8] Enable switching"; + } + 1230 + { + title = "Tiny Cactus"; + sprite = "CACTJ0"; + width = 13; + height = 28; + } + 1231 + { + title = "Small Cactus"; + sprite = "CACTK0"; + width = 15; + height = 60; + } +} + +redvolcano +{ + color = 10; // Green + title = "Red Volcano"; + + 1300 + { + arrow = 1; + title = "Flame Jet (Horizontal)"; + sprite = "internal:flameh"; + width = 16; + height = 40; + flags8text = "[8] Waves vertically"; + angletext = "On/Off time"; + parametertext = "Strength"; + } + 1301 + { + title = "Flame Jet (Vertical)"; + sprite = "internal:flamev"; + width = 16; + height = 40; + flags8text = "[8] Shoot downwards"; + angletext = "On/Off time"; + parametertext = "Strength"; + } + 1302 + { + title = "Spinning Flame Jet (Counter-Clockwise)"; + sprite = "internal:flame2"; + width = 16; + height = 24; + } + 1303 + { + title = "Spinning Flame Jet (Clockwise)"; + sprite = "internal:flame1"; + width = 16; + height = 24; + } + 1304 + { + title = "Lavafall"; + sprite = "LFALF0"; + width = 30; + height = 32; + angletext = "Initial delay"; + flags8text = "[8] Double size"; + } + 1305 + { + title = "Rollout Rock"; + sprite = "PUMIA1A5"; + width = 30; + height = 60; + flags8text = "[8] Non-buoyant"; + } + 1306 + { + title = "Big Fern"; + sprite = "JPLAB0"; + width = 32; + height = 48; + } + 1307 + { + title = "Jungle Palm"; + sprite = "JPLAC0"; + width = 32; + height = 48; + } + 1308 + { + title = "Torch Flower"; + sprite = "TFLOA0"; + width = 14; + height = 110; + } + 1309 + { + title = "RVZ1 Wall Vine (Long)"; + sprite = "WVINALAR"; + width = 1; + height = 288; + } + 1310 + { + title = "RVZ1 Wall Vine (Short)"; + sprite = "WVINBLBR"; + width = 1; + height = 288; + } +} + +botanicserenity +{ + color = 10; // Green + title = "Botanic Serenity"; + width = 16; + height = 32; + sprite = "BSZ1A0"; + 1400 + { + title = "Tall Flower (Red)"; + sprite = "BSZ1A0"; + } + 1401 + { + title = "Tall Flower (Purple)"; + sprite = "BSZ1B0"; + } + 1402 + { + title = "Tall Flower (Blue)"; + sprite = "BSZ1C0"; + } + 1403 + { + title = "Tall Flower (Cyan)"; + sprite = "BSZ1D0"; + } + 1404 + { + title = "Tall Flower (Yellow)"; + sprite = "BSZ1E0"; + } + 1405 + { + title = "Tall Flower (Orange)"; + sprite = "BSZ1F0"; + } + 1410 + { + title = "Medium Flower (Red)"; + sprite = "BSZ2A0"; + } + 1411 + { + title = "Medium Flower (Purple)"; + sprite = "BSZ2B0"; + } + 1412 + { + title = "Medium Flower (Blue)"; + sprite = "BSZ2C0"; + } + 1413 + { + title = "Medium Flower (Cyan)"; + sprite = "BSZ2D0"; + } + 1414 + { + title = "Medium Flower (Yellow)"; + sprite = "BSZ2E0"; + } + 1415 + { + title = "Medium Flower (Orange)"; + sprite = "BSZ2F0"; + } + 1420 + { + title = "Short Flower (Red)"; + sprite = "BSZ3A0"; + } + 1421 + { + title = "Short Flower (Purple)"; + sprite = "BSZ3B0"; + } + 1422 + { + title = "Short Flower (Blue)"; + sprite = "BSZ3C0"; + } + 1423 + { + title = "Short Flower (Cyan)"; + sprite = "BSZ3D0"; + } + 1424 + { + title = "Short Flower (Yellow)"; + sprite = "BSZ3E0"; + } + 1425 + { + title = "Short Flower (Orange)"; + sprite = "BSZ3F0"; + } + 1430 + { + title = "Tulip (Red)"; + sprite = "BST1A0"; + } + 1431 + { + title = "Tulip (Purple)"; + sprite = "BST2A0"; + } + 1432 + { + title = "Tulip (Blue)"; + sprite = "BST3A0"; + } + 1433 + { + title = "Tulip (Cyan)"; + sprite = "BST4A0"; + } + 1434 + { + title = "Tulip (Yellow)"; + sprite = "BST5A0"; + } + 1435 + { + title = "Tulip (Orange)"; + sprite = "BST6A0"; + } + 1440 + { + title = "Cluster (Red)"; + sprite = "BSZ5A0"; + } + 1441 + { + title = "Cluster (Purple)"; + sprite = "BSZ5B0"; + } + 1442 + { + title = "Cluster (Blue)"; + sprite = "BSZ5C0"; + } + 1443 + { + title = "Cluster (Cyan)"; + sprite = "BSZ5D0"; + } + 1444 + { + title = "Cluster (Yellow)"; + sprite = "BSZ5E0"; + } + 1445 + { + title = "Cluster (Orange)"; + sprite = "BSZ5F0"; + } + 1450 + { + title = "Bush (Red)"; + sprite = "BSZ6A0"; + } + 1451 + { + title = "Bush (Purple)"; + sprite = "BSZ6B0"; + } + 1452 + { + title = "Bush (Blue)"; + sprite = "BSZ6C0"; + } + 1453 + { + title = "Bush (Cyan)"; + sprite = "BSZ6D0"; + } + 1454 + { + title = "Bush (Yellow)"; + sprite = "BSZ6E0"; + } + 1455 + { + title = "Bush (Orange)"; + sprite = "BSZ6F0"; + } + 1460 + { + title = "Vine (Red)"; + sprite = "BSZ7A0"; + } + 1461 + { + title = "Vine (Purple)"; + sprite = "BSZ7B0"; + } + 1462 + { + title = "Vine (Blue)"; + sprite = "BSZ7C0"; + } + 1463 + { + title = "Vine (Cyan)"; + sprite = "BSZ7D0"; + } + 1464 + { + title = "Vine (Yellow)"; + sprite = "BSZ7E0"; + } + 1465 + { + title = "Vine (Orange)"; + sprite = "BSZ7F0"; + } + 1470 + { + title = "BSZ Shrub"; + sprite = "BSZ8A0"; + } + 1471 + { + title = "BSZ Clover"; + sprite = "BSZ8B0"; + } + 1473 + { + title = "Palm Tree (Big)"; + width = 16; + height = 160; + sprite = "BSZ8D0"; + } + 1475 + { + title = "Palm Tree (Small)"; + width = 16; + height = 80; + sprite = "BSZ8F0"; + } +} + +azuretemple +{ + color = 10; // Green + title = "Azure Temple"; + + 1500 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1501 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle (Up)"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1502 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle (Down)"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1503 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle (Long)"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1504 + { + title = "ATZ Target"; + sprite = "RCRYB0"; + width = 24; + height = 32; + } + 1505 + { + title = "Green Flame"; + sprite = "CFLMA0E0"; + width = 8; + height = 32; + } + 1506 + { + arrow = 1; + blocking = 2; + title = "Blue Gargoyle"; + sprite = "BGARD1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } +} + +dreamhill +{ + color = 10; // Green + title = "Dream Hill"; + + 1600 + { + title = "Spring Tree"; + sprite = "TRE6A0"; + width = 16; + height = 32; + } + 1601 + { + title = "Shleep"; + sprite = "SHLPA0"; + width = 24; + height = 32; + } + 1602 + { + title = "Pian"; + sprite = "NTPNALAR"; + width = 16; + height = 32; + } +} + +nightstrk +{ + color = 13; // Pink + title = "NiGHTS Track"; + width = 8; + height = 4096; + sprite = "UNKNA0"; + + 1700 + { + title = "Axis"; + sprite = "internal:axis1"; + circle = 1; + unflippable = true; + ignoreZ = true; + flagsvaluetext = "Order"; + angletext = "Radius/Direction"; + parametertext = "Mare"; + } + 1701 + { + title = "Axis Transfer"; + sprite = "internal:axis2"; + unflippable = true; + ignoreZ = true; + flagsvaluetext = "Order"; + parametertext = "Mare"; + } + 1702 + { + title = "Axis Transfer Line"; + sprite = "internal:axis3"; + unflippable = true; + ignoreZ = true; + flagsvaluetext = "Order"; + parametertext = "Mare"; + } + 1710 + { + title = "Ideya Capture"; + sprite = "CAPSA0"; + width = 72; + height = 144; + angletext = "Rings"; + parametertext = "Mare"; + } +} + +nights +{ + color = 13; // Pink + title = "NiGHTS Items"; + width = 16; + height = 32; + + 1703 + { + title = "Ideya Drone"; + sprite = "NDRNA1"; + width = 16; + height = 56; + flags1text = "[1] Align player to middle"; + flags4text = "[4] Align player to top"; + flags8text = "[8] Die upon time up"; + angletext = "Time limit"; + parametertext = "Height"; + } + 1704 + { + arrow = 1; + title = "NiGHTS Bumper"; + sprite = "NBMPG3G7"; + width = 32; + height = 64; + unflippable = true; + flagsvaluetext = "Pitch"; + angletext = "Yaw"; + } + 1705 + { + arrow = 1; + title = "Hoop (Generic)"; + sprite = "HOOPA0"; + width = 80; + height = 160; + unflippable = true; + centerHitbox = true; + flagsvaluetext = "Height"; + angletext = "Pitch/Yaw"; + } + 1706 + { + title = "Blue Sphere"; + sprite = "SPHRA0"; + width = 16; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + unflippable = true; + } + 1707 + { + title = "Super Paraloop"; + sprite = "NPRUA0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1708 + { + title = "Drill Refill"; + sprite = "NPRUB0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1709 + { + title = "Nightopian Helper"; + sprite = "NPRUC0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1711 + { + title = "Extra Time"; + sprite = "NPRUD0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1712 + { + title = "Link Freeze"; + sprite = "NPRUE0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1713 + { + arrow = 1; + title = "Hoop (Customizable)"; + flags1text = "[1] Radius +16"; + flags2text = "[2] Radius +32"; + flags4text = "[4] Radius +64"; + flags8text = "[8] Radius +128"; + sprite = "HOOPA0"; + width = 80; + height = 160; + unflippable = true; + centerHitbox = true; + } + 1714 + { + title = "Ideya Anchor Point"; + sprite = "internal:axis1"; + width = 8; + height = 16; + parametertext = "Ideya"; + } +} + +mario +{ + color = 6; // Brown + title = "Mario"; + + 1800 + { + title = "Coin"; + sprite = "COINA0"; + width = 16; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + } + 1801 + { + arrow = 1; + title = "Goomba"; + sprite = "GOOMA0"; + width = 24; + height = 32; + } + 1802 + { + arrow = 1; + title = "Goomba (Blue)"; + sprite = "BGOMA0"; + width = 24; + height = 32; + } + 1803 + { + title = "Fire Flower"; + sprite = "FFWRB0"; + width = 16; + height = 32; + } + 1804 + { + title = "Koopa Shell"; + sprite = "SHLLA1"; + width = 16; + height = 20; + } + 1805 + { + title = "Puma (Jumping Fireball)"; + sprite = "PUMAA0"; + width = 8; + height = 16; + angletext = "Jump strength"; + } + 1806 + { + title = "King Bowser"; + sprite = "KOOPA0"; + width = 16; + height = 48; + } + 1807 + { + title = "Axe"; + sprite = "MAXEA0"; + width = 8; + height = 16; + } + 1808 + { + title = "Bush (Short)"; + sprite = "MUS1A0"; + width = 16; + height = 32; + } + 1809 + { + title = "Bush (Tall)"; + sprite = "MUS2A0"; + width = 16; + height = 32; + } + 1810 + { + title = "Toad"; + sprite = "TOADA0"; + width = 8; + height = 32; + } +} + +christmasdisco +{ + color = 10; // Green + title = "Christmas & Disco"; + + 1850 + { + title = "Christmas Pole"; + sprite = "XMS1A0"; + width = 16; + height = 40; + } + 1851 + { + title = "Candy Cane"; + sprite = "XMS2A0"; + width = 8; + height = 32; + } + 1852 + { + blocking = 2; + title = "Snowman"; + sprite = "XMS3A0"; + width = 16; + height = 64; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1853 + { + blocking = 2; + title = "Snowman (With Hat)"; + sprite = "XMS3B0"; + width = 16; + height = 80; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1854 + { + title = "Lamp Post"; + sprite = "XMS4A0"; + width = 8; + height = 120; + } + 1855 + { + title = "Lamp Post (Snow)"; + sprite = "XMS4B0"; + width = 8; + height = 120; + } + 1856 + { + title = "Hanging Star"; + sprite = "XMS5A0"; + width = 4; + height = 80; + hangs = 1; + } + 1857 + { + title = "Berry Bush (Snow)"; + sprite = "BUS1B0"; + width = 16; + height = 32; + } + 1858 + { + title = "Bush (Snow)"; + sprite = "BUS2B0"; + width = 16; + height = 32; + } + 1859 + { + title = "Blueberry Bush (Snow)"; + sprite = "BUS3B0"; + width = 16; + height = 32; + } + 1875 + { + title = "Disco Ball"; + sprite = "DBALA0"; + width = 16; + height = 54; + hangs = 1; + } + 1876 + { + arrow = 1; + blocking = 2; + title = "Eggman Disco Statue"; + sprite = "ESTAB1"; + width = 20; + height = 96; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } +} + +stalagmites +{ + color = 10; // Green + title = "Stalagmites"; + width = 16; + height = 40; + + 1900 + { + title = "Brown Stalagmite (Tall)"; + sprite = "STLGA0"; + width = 16; + height = 40; + } + 1901 + { + title = "Brown Stalagmite"; + sprite = "STLGB0"; + width = 16; + height = 40; + } + 1902 + { + title = "Orange Stalagmite (Tall)"; + sprite = "STLGC0"; + width = 16; + height = 40; + } + 1903 + { + title = "Orange Stalagmite"; + sprite = "STLGD0"; + width = 16; + height = 40; + } + 1904 + { + title = "Red Stalagmite (Tall)"; + sprite = "STLGE0"; + width = 16; + height = 40; + } + 1905 + { + title = "Red Stalagmite"; + sprite = "STLGF0"; + width = 16; + height = 40; + } + 1906 + { + title = "Gray Stalagmite (Tall)"; + sprite = "STLGG0"; + width = 24; + height = 96; + } + 1907 + { + title = "Gray Stalagmite"; + sprite = "STLGH0"; + width = 16; + height = 40; + } + 1908 + { + title = "Blue Stalagmite (Tall)"; + sprite = "STLGI0"; + width = 16; + height = 40; + } + 1909 + { + title = "Blue Stalagmite"; + sprite = "STLGJ0"; + width = 16; + height = 40; + } +} + +hauntedheights +{ + color = 10; // Green + title = "Haunted Heights"; + + 2000 + { + title = "Smashing Spikeball"; + sprite = "FMCEA0"; + width = 18; + height = 28; + angletext = "Initial delay"; + } + 2001 + { + title = "HHZ Grass"; + sprite = "HHZMA0"; + width = 16; + height = 40; + } + 2002 + { + title = "HHZ Tentacle 1"; + sprite = "HHZMB0"; + width = 16; + height = 40; + } + 2003 + { + title = "HHZ Tentacle 2"; + sprite = "HHZMC0"; + width = 16; + height = 40; + } + 2004 + { + title = "HHZ Stalagmite (Tall)"; + sprite = "HHZME0"; + width = 16; + height = 40; + } + 2005 + { + title = "HHZ Stalagmite (Short)"; + sprite = "HHZMF0"; + width = 16; + height = 40; + } + 2006 + { + title = "Jack-o'-lantern 1"; + sprite = "PUMKA0"; + width = 16; + height = 40; + flags1text = "Don't flicker"; + } + 2007 + { + title = "Jack-o'-lantern 2"; + sprite = "PUMKB0"; + width = 16; + height = 40; + flags1text = "Don't flicker"; + } + 2008 + { + title = "Jack-o'-lantern 3"; + sprite = "PUMKC0"; + width = 16; + height = 40; + flags1text = "Don't flicker"; + } + 2009 + { + title = "Purple Mushroom"; + sprite = "SHRMD0"; + width = 16; + height = 48; + } + 2010 + { + title = "HHZ Tree"; + sprite = "HHPLC0"; + width = 12; + height = 40; + } +} + +frozenhillside +{ + color = 10; // Green + title = "Frozen Hillside"; + + 2100 + { + title = "Ice Shard (Small)"; + sprite = "FHZIA0"; + width = 8; + height = 32; + } + 2101 + { + title = "Ice Shard (Large)"; + sprite = "FHZIB0"; + width = 8; + height = 32; + } + 2102 + { + title = "Crystal Tree (Aqua)"; + sprite = "TRE3A0"; + width = 20; + height = 200; + } + 2103 + { + title = "Crystal Tree (Pink)"; + sprite = "TRE3B0"; + width = 20; + height = 200; + } + 2104 + { + title = "Amy Cameo"; + sprite = "ROSYA1"; + width = 16; + height = 48; + flags1text = "[1] Grayscale mode"; + } + 2105 + { + title = "Mistletoe"; + sprite = "XMS6A0"; + width = 52; + height = 106; + } +} + +flickies +{ + color = 10; // Green + title = "Flickies"; + width = 8; + height = 20; + flags1text = "[1] Move aimlessly"; + flags4text = "[4] No movement"; + flags8text = "[8] Hop"; + angletext = "Radius"; + + 2200 + { + title = "Bluebird"; + sprite = "FL01A1"; + } + 2201 + { + title = "Rabbit"; + sprite = "FL02A1"; + } + 2202 + { + title = "Chicken"; + sprite = "FL03A1"; + } + 2203 + { + title = "Seal"; + sprite = "FL04A1"; + } + 2204 + { + title = "Pig"; + sprite = "FL05A1"; + } + 2205 + { + title = "Chipmunk"; + sprite = "FL06A1"; + } + 2206 + { + title = "Penguin"; + sprite = "FL07A1"; + } + 2207 + { + title = "Fish"; + sprite = "FL08A1"; + parametertext = "Color"; + } + 2208 + { + title = "Ram"; + sprite = "FL09A1"; + } + 2209 + { + title = "Puffin"; + sprite = "FL10A1"; + } + 2210 + { + title = "Cow"; + sprite = "FL11A1"; + } + 2211 + { + title = "Rat"; + sprite = "FL12A1"; + } + 2212 + { + title = "Bear"; + sprite = "FL13A1"; + } + 2213 + { + title = "Dove"; + sprite = "FL14A1"; + } + 2214 + { + title = "Cat"; + sprite = "FL15A1"; + } + 2215 + { + title = "Canary"; + sprite = "FL16A1"; + } + 2216 + { + title = "Spider"; + sprite = "FS01A1"; + } + 2217 + { + title = "Bat"; + sprite = "FS02A0"; + } +} \ No newline at end of file diff --git a/extras/conf/SRB2-22.cfg b/extras/conf/SRB2-22.cfg new file mode 100644 index 000000000..ec318321d --- /dev/null +++ b/extras/conf/SRB2-22.cfg @@ -0,0 +1,6521 @@ +/*********************************************************\ + Zone Builder Game Configuration + For Sonic Robo Blast 2 Version 2.2 + Contributors (alphabetical): + * Foxboy + * FuriousFox + * JJames19119 + * Kalaron + * Kristos + * MascaraSnake + * mazmazz + * Morpheus + * Neo Chaotikal + * Nev3r + * Oogaland + * Rob + * Shadow Hog + * Spherallic + * SRB2-Playah + * SSNTails + * SteelT + * ST218 + * toaster + * Viola +\*********************************************************/ + +// This is required to prevent accidental use of a different configuration +type = "Doom Builder 2 Game Configuration"; + +// This is the title to show for this game +game = "Sonic Robo Blast 2 - 2.2"; + +//GZDB specific. Don't try to load lumps that don't exist. +basegame = 0; + +// This is the simplified game engine/sourceport name +engine = "zdoom"; + +// When this is set to true, sectors with the same tag will light up when a line is highlighted +linetagindicatesectors = true; + +// The format interface handles the map data format - DoomMapSetIO for SRB2DB2, SRB2MapSetIO for Zone Builder +formatinterface = "SRB2MapSetIO"; + +//Sky textures for vanilla maps +defaultskytextures +{ + SKY1 = "MAP01,MAP02,MAP03,MAP33,MAP50,MAP60,MAPF0,MAPM0"; + SKY2 = "MAPM7,MAPMB"; + SKY4 = "MAP04,MAP06,MAP61,MAPF6,MAPM1"; + SKY6 = "MAP05,MAP51,MAPMA"; + SKY7 = "MAPM2,MAPM5"; + SKY8 = "MAP07,MAP08,MAP09,MAP52,MAP62,MAPF1"; + SKY10 = "MAP10,MAP12,MAP53,MAP63,MAPM3"; + SKY11 = "MAP11,MAPF7"; + SKY13 = "MAP13,MAP64"; + SKY14 = "MAP14"; + SKY15 = "MAP15,MAP54"; + SKY17 = "MAP70"; + SKY20 = "MAP32,MAP55,MAP65,MAPF2,MAPF5"; + SKY21 = "MAPM4"; + SKY22 = "MAP22,MAP23,MAP25,MAP26,MAP27,MAP56,MAP66,MAPF4,MAPM6"; + SKY30 = "MAP30"; + SKY31 = "MAP31"; + SKY35 = "MAP42"; + SKY40 = "MAP41,MAP71,MAPM9"; + SKY55 = "MAPF3,MAPM8"; + SKY68 = "MAPF8"; + SKY99 = "MAP57,MAPZ0"; + SKY159 = "MAP16"; + SKY172 = "MAP40"; + SKY300 = "MAP72"; + SKY301 = "MAP73"; +} + +// Default lump name for new map +defaultlumpname = "MAP01"; + +// Default testing parameters +testparameters = "-file \"%AP\" \"%F\" -warp %L"; +testshortpaths = true; + +// Default nodebuilder configurations +defaultsavecompiler = "zennode_normal"; +defaulttestcompiler = "zennode_fast"; + +// Skill levels +skills +{ + 1 = "Normal"; +} + +// Skins +skins +{ + Sonic; + Tails; + Knuckles; + Amy; + Fang; + Metalsonic; +} + +// Gametypes +gametypes +{ + -1 = "Single Player"; + 0 = "Co-op"; + 1 = "Competition"; + 2 = "Race"; + 3 = "Match"; + 4 = "Team Match"; + 5 = "Tag"; + 6 = "Hide and Seek"; + 7 = "CTF"; +} + +// Special linedefs +soundlinedefflag = 64; // See linedefflags +singlesidedflag = 1; // See linedefflags +doublesidedflag = 4; // See linedefflags +impassableflag = 1; +upperunpeggedflag = 8; +lowerunpeggedflag = 16; +repeatmidtextureflag = 1024; +pegmidtextureflag = 256; + +// Generalized actions +generalizedlinedefs = false; +generalizedsectors = true; + +// Texture loading options +defaultwalltexture = "GFZROCK"; +defaultfloortexture = "GFZFLR01"; +defaultceilingtexture = "F_SKY1"; +mixtexturesflats = true; +defaulttexturescale = 1.0f; +defaultflatscale = 1.0f; + +// Thing number for start position in 3D Mode +start3dmode = 3328; + + + + +/* +TEXTURES AND FLAT SOURCES +This tells Doom Builder where to find the information for textures +and flats in the IWAD file, Addition WAD file and Map WAD file. + +Start and end lumps must be given in a structure (of which the +key name doesnt matter) and any textures or flats in between them +are loaded in either the textures category or flats category. + +For textures: PNAMES, TEXTURE1 and TEXTURE2 are loaded by default. +Kalaron: and now TX_START +*/ + +// Texture sources +textures +{ + zdoom1 + { + start = "TX_START"; + end = "TX_END"; + } +} + +// Patch sources +patches +{ + standard1 + { + start = "P_START"; + end = "P_END"; + } + + standard2 + { + start = "PP_START"; + end = "PP_END"; + } +} + +// Sprite sources +sprites +{ + standard1 + { + start = "S_START"; + end = "S_END"; + } + + standard2 + { + start = "SS_START"; + end = "SS_END"; + } +} + +// Flat sources +flats +{ + standard1 + { + start = "F_START"; + end = "F_END"; + } + + standard2 + { + start = "FF_START"; + end = "FF_END"; + } + + standard3 + { + start = "FF_START"; + end = "F_END"; + } + + standard4 + { + start = "F_START"; + end = "FF_END"; + } +} + + +/* +GAME DETECT PATTERN +Used to guess the game for which a WAD file is made. + +1 = One of these lumps must exist +2 = None of these lumps must exist +3 = All of these lumps must exist +*/ + +gamedetect +{ + EXTENDED = 2; + + + BEHAVIOR = 2; + + E#M# = 2; + + MAP?? = 1; +} + + +/* +MAP LUMP NAMES +Map lumps are loaded with the map as long as they are right after each other. When the editor +meets a lump which is not defined in this list it will ignore the map if not satisfied. +The order of items defines the order in which lumps will be written to WAD file on save. +To indicate the map header lump, use ~MAP + +Legenda: +required = Lump is required to exist. +blindcopy = Lump will be copied along with the map blindly. (usefull for lumps Doom Builder doesn't use) +nodebuild = The nodebuilder generates this lump. +allowempty = The nodebuilder is allowed to leave this lump empty. +script = This lump is a text-based script. Specify the filename of the script configuration to use. +*/ + +maplumpnames +{ + ~MAP + { + required = true; + blindcopy = true; + nodebuild = false; + } + + THINGS + { + required = true; + nodebuild = true; + allowempty = true; + } + + LINEDEFS + { + required = true; + nodebuild = true; + allowempty = false; + } + + SIDEDEFS + { + required = true; + nodebuild = true; + allowempty = false; + } + + VERTEXES + { + required = true; + nodebuild = true; + allowempty = false; + } + + SEGS + { + required = false; + nodebuild = true; + allowempty = false; + } + + SSECTORS + { + required = false; + nodebuild = true; + allowempty = false; + } + + NODES + { + required = false; + nodebuild = true; + allowempty = false; + } + + SECTORS + { + required = true; + nodebuild = true; + allowempty = false; + } + + REJECT + { + required = false; + nodebuild = true; + allowempty = false; + } + + BLOCKMAP + { + required = false; + nodebuild = true; + allowempty = true; + } +} + +scriptlumpnames +{ + MAINCFG + { + script = "SOC.cfg"; + } + + OBJCTCFG + { + script = "SOC.cfg"; + } + + SOC_ + { + script = "SOC.cfg"; + isprefix = true; + } + + LUA_ + { + script = "Lua.cfg"; + isprefix = true; + } +} + +// DEFAULT SECTOR BRIGHTNESS LEVELS +sectorbrightness +{ + 255; + 248; + 240; + 232; + 224; + 216; + 208; + 200; + 192; + 184; + 176; + 168; + 160; + 152; + 144; + 136; + 128; + 120; + 112; + 104; + 96; + 88; + 80; + 72; + 64; + 56; + 48; + 40; + 32; + 24; + 16; + 8; + 0; +} + +// SECTOR TYPES----------------------------------------------------------------- +sectortypes +{ + 0 = "Normal"; + 1 = "Damage"; + 2 = "Damage (Water)"; + 3 = "Damage (Fire)"; + 4 = "Damage (Electrical)"; + 5 = "Spikes"; + 6 = "Death Pit (Camera Tilt)"; + 7 = "Death Pit (No Camera Tilt)"; + 8 = "Instant Kill"; + 9 = "Ring Drainer (Floor Touch)"; + 10 = "Ring Drainer (Anywhere in Sector)"; + 11 = "Special Stage Damage"; + 12 = "Space Countdown"; + 13 = "Ramp Sector (double step-up/down)"; + 14 = "Non-Ramp Sector (no step-down)"; + 15 = "Bouncy FOF"; + 16 = "Trigger Line Ex. (Pushable Objects)"; + 32 = "Trigger Line Ex. (Anywhere, All Players)"; + 48 = "Trigger Line Ex. (Floor Touch, All Players)"; + 64 = "Trigger Line Ex. (Anywhere in Sector)"; + 80 = "Trigger Line Ex. (Floor Touch)"; + 96 = "Trigger Line Ex. (Emerald Check)"; + 112 = "Trigger Line Ex. (NiGHTS Mare)"; + 128 = "Check for Linedef Executor on FOFs"; + 144 = "Egg Capsule"; + 160 = "Special Stage Time/Rings Parameters"; + 176 = "Custom Global Gravity"; + 512 = "Wind/Current"; + 1024 = "Conveyor Belt"; + 1280 = "Speed Pad"; + 4096 = "Star Post Activator"; + 8192 = "Exit/Special Stage Pit/Return Flag"; + 12288 = "CTF Red Team Base"; + 16384 = "CTF Blue Team Base"; + 20480 = "Fan Sector"; + 24576 = "Super Sonic Transform"; + 28672 = "Force Spin"; + 32768 = "Zoom Tube Start"; + 36864 = "Zoom Tube End"; + 40960 = "Circuit Finish Line"; + 45056 = "Rope Hang"; + 49152 = "Intangible to the Camera"; +} + + +// GENERALISED SECTOR TYPES----------------------------------------------------------------- +gen_sectortypes +{ + first + { + 0 = "Normal"; + 1 = "Damage"; + 2 = "Damage (Water)"; + 3 = "Damage (Fire)"; + 4 = "Damage (Electrical)"; + 5 = "Spikes"; + 6 = "Death Pit (Camera Tilt)"; + 7 = "Death Pit (No Camera Tilt)"; + 8 = "Instant Kill"; + 9 = "Ring Drainer (Floor Touch)"; + 10 = "Ring Drainer (Anywhere in Sector)"; + 11 = "Special Stage Damage"; + 12 = "Space Countdown"; + 13 = "Ramp Sector (double step-up/down)"; + 14 = "Non-Ramp Sector (no step-down)"; + 15 = "Bouncy FOF"; + } + + second + { + 0 = "Normal"; + 16 = "Trigger Line Ex. (Pushable Objects)"; + 32 = "Trigger Line Ex. (Anywhere, All Players)"; + 48 = "Trigger Line Ex. (Floor Touch, All Players)"; + 64 = "Trigger Line Ex. (Anywhere in Sector)"; + 80 = "Trigger Line Ex. (Floor Touch)"; + 96 = "Trigger Line Ex. (Emerald Check)"; + 112 = "Trigger Line Ex. (NiGHTS Mare)"; + 128 = "Check for Linedef Executor on FOFs"; + 144 = "Egg Capsule"; + 160 = "Special Stage Time/Rings Parameters"; + 176 = "Custom Global Gravity"; + } + + third + { + 0 = "Normal"; + 512 = "Wind/Current"; + 1024 = "Conveyor Belt"; + 1280 = "Speed Pad"; + } + + fourth + { + 0 = "Normal"; + 4096 = "Star Post Activator"; + 8192 = "Exit/Special Stage Pit/Return Flag"; + 12288 = "CTF Red Team Base"; + 16384 = "CTF Blue Team Base"; + 20480 = "Fan Sector"; + 24576 = "Super Sonic Transform"; + 28672 = "Force Spin"; + 32768 = "Zoom Tube Start"; + 36864 = "Zoom Tube End"; + 40960 = "Circuit Finish Line"; + 45056 = "Rope Hang"; + 49152 = "Intangible to the Camera"; + } +} + +// LINEDEF FLAGS +linedefflags +{ + 1 = "[0] Impassable"; + 2 = "[1] Block Enemies"; + 4 = "[2] Double-Sided"; + 8 = "[3] Upper Unpegged"; + 16 = "[4] Lower Unpegged"; + 32 = "[5] Slope Skew (E1)"; + 64 = "[6] Not Climbable"; + 128 = "[7] No Midtexture Skew (E2)"; + 256 = "[8] Peg Midtexture (E3)"; + 512 = "[9] Solid Midtexture (E4)"; + 1024 = "[10] Repeat Midtexture (E5)"; + 2048 = "[11] Netgame Only"; + 4096 = "[12] No Netgame"; + 8192 = "[13] Effect 6"; + 16384 = "[14] Bouncy Wall"; + 32768 = "[15] Transfer Line"; +} + +// Linedef flags UDMF translation table +// This is needed for copy/paste and prefabs to work properly +// When the UDMF field name is prefixed with ! it is inverted +linedefflagstranslation +{ + 1 = "blocking"; + 2 = "blockmonsters"; + 4 = "twosided"; + 8 = "dontpegtop"; + 16 = "dontpegbottom"; + 32 = "secret"; + 64 = "blocksound"; + 128 = "dontdraw"; + 256 = "mapped"; +} + +// LINEDEF ACTIVATIONS +linedefactivations +{ +} + +// LINEDEF TYPES +linedeftypes +{ + misc + { + title = "Miscellaneous"; + + 0 + { + title = "None"; + prefix = "(0)"; + } + + 1 + { + title = "Per-Sector Gravity"; + prefix = "(1)"; + flags64text = "[6] Flip in reverse gravity"; + } + + 5 + { + title = "Camera Scanner"; + prefix = "(5)"; + } + + 7 + { + title = "Sector Flat Alignment"; + prefix = "(7)"; + flags2048text = "[11] Don't align floor"; + flags4096text = "[12] Don't align ceiling"; + flags8192text = "[13] Use texture offsets"; + } + + 10 + { + title = "Culling Plane"; + prefix = "(10)"; + flags64text = "[6] Cull only while in sector"; + } + + 13 + { + title = "Heat Wave Effect"; + prefix = "(13)"; + } + + 40 + { + title = "Visual Portal Between Tagged Linedefs"; + prefix = "(40)"; + } + + 41 + { + title = "Horizon Effect"; + prefix = "(41)"; + } + + 50 + { + title = "Instantly Lower Floor on Level Load"; + prefix = "(50)"; + } + + 51 + { + title = "Instantly Raise Ceiling on Level Load"; + prefix = "(51)"; + } + + 63 + { + title = "Fake Floor/Ceiling Planes"; + prefix = "(63)"; + } + + 540 + { + title = "Floor Friction"; + prefix = "(540)"; + } + } + + parameters + { + title = "Parameters"; + + 2 + { + title = "Custom Exit"; + prefix = "(2)"; + flags2text = "[1] Check emeralds"; + flags64text = "[6] Skip score tally"; + } + + 3 + { + title = "Zoom Tube Parameters"; + prefix = "(3)"; + flags512text = "[9] Ignore player direction"; + } + + 4 + { + title = "Speed Pad Parameters"; + prefix = "(4)"; + flags512text = "[9] No teleport to center"; + flags1024text = "[10] Force spinning frames"; + } + + 8 + { + title = "Special Sector Properties"; + prefix = "(8)"; + flags32text = "[5] Invert precipitation"; + flags64text = "[6] Touch only ceiling"; + flags128text = "[7] Allow opposite gravity"; + flags256text = "[8] Touch sector edge"; + flags512text = "[9] Touch floor or ceiling"; + } + + 9 + { + title = "Chain Parameters"; + prefix = "(9)"; + flags32text = "[5] Swing instead of spin"; + flags128text = "[7] Make chain from end item"; + flags64text = "[6] Player-turnable chain"; + flags256text = "[8] Spawn link at origin"; + flags512text = "[9] Don't clip inside ground"; + flags1024text = "[10] No distance check"; + } + + 11 + { + title = "Rope Hang Parameters"; + prefix = "(11)"; + flags32text = "[5] Don't loop"; + flags64text = "[6] Static"; + } + + 12 + { + title = "Rock Spawner Parameters"; + prefix = "(12)"; + flags64text = "[6] Randomize speed"; + } + + 14 + { + title = "Bustable Block Parameters"; + prefix = "(14)"; + flags32text = "[5] Particles launch from center"; + } + + 15 + { + title = "Fan Particle Spawner Parameters"; + prefix = "(15)"; + } + + 16 + { + title = "Minecart Parameters"; + prefix = "(16)"; + } + + 64 + { + title = "Continuously Appearing/Disappearing FOF"; + prefix = "(64)"; + flags2text = "[1] Use control sector tag"; + flags64text = "[6] No sound effect"; + } + + 65 + { + title = "Bridge Thinker "; + prefix = "(65)"; + } + } + + polyobject + { + title = "PolyObject"; + + 20 + { + title = "First Line"; + prefix = "(20)"; + } + + 21 + { + title = "Explicitly Include Line "; + prefix = "(21)"; + } + + 22 + { + title = "Parameters"; + prefix = "(22)"; + flags64text = "[6] Trigger linedef executor"; + flags128text = "[7] Intangible"; + flags256text = "[8] Stopped by pushables"; + flags512text = "[9] Render flats"; + } + + 30 + { + title = "Waving Flag"; + prefix = "(30)"; + } + + 31 + { + title = "Displacement by Front Sector"; + prefix = "(31)"; + } + + 32 + { + title = "Angular Displacement by Front Sector"; + prefix = "(32)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + } + + planemove + { + title = "Plane Movement"; + + 52 + { + title = "Continuously Falling Sector"; + prefix = "(52)"; + flags64text = "[6] Continuously rising"; + } + + 53 + { + title = "Continuous Floor/Ceiling Mover"; + prefix = "(53)"; + } + + 54 + { + title = "Continuous Floor Mover"; + prefix = "(54)"; + } + + 55 + { + title = "Continuous Ceiling Mover"; + prefix = "(55)"; + } + + 56 + { + title = "Continuous Two-Speed Floor/Ceiling Mover"; + prefix = "(56)"; + } + + 57 + { + title = "Continuous Two-Speed Floor Mover"; + prefix = "(57)"; + } + + 58 + { + title = "Continuous Two-Speed Ceiling Mover"; + prefix = "(58)"; + } + + 59 + { + title = "Activate Moving Platform"; + prefix = "(59)"; + flags64text = "[6] Move upwards at start"; + } + + 60 + { + title = "Activate Moving Platform (Adjustable Speed)"; + prefix = "(60)"; + flags64text = "[6] Move upwards at start"; + } + + 61 + { + title = "Crusher (Ceiling to Floor)"; + prefix = "(61)"; + flags512text = "[9] Double, constant speed"; + } + + 62 + { + title = "Crusher (Floor to Ceiling)"; + prefix = "(62)"; + flags512text = "[9] Double, constant speed"; + } + + 66 + { + title = "Move Floor by Displacement"; + prefix = "(66)"; + flags64text = "[6] Inverse movement"; + } + + 67 + { + title = "Move Ceiling by Displacement"; + prefix = "(67)"; + flags64text = "[6] Inverse movement"; + } + + 68 + { + title = "Move Floor and Ceiling by Displacement"; + prefix = "(68)"; + flags64text = "[6] Inverse movement"; + } + } + + fofsolid + { + title = "FOF (solid)"; + + 100 + { + title = "Solid, Opaque"; + prefix = "(100)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 101 + { + title = "Solid, Opaque, No Shadow"; + prefix = "(101)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1DF"; + } + + 102 + { + title = "Solid, Translucent"; + prefix = "(102)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Render insides"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "195F"; + flags643dfloorflagsadd = "7C80"; + } + + 103 + { + title = "Solid, Sides Only"; + prefix = "(103)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1CF"; + } + + 104 + { + title = "Solid, No Sides"; + prefix = "(104)"; + flags32text = "[5] Only block player"; + flags64text = "[6] Cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1D7"; + flags643dfloorflagsremove = "40"; + } + + 105 + { + title = "Solid, Invisible"; + prefix = "(105)"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "47"; + } + + 140 + { + title = "Intangible from Bottom, Opaque"; + prefix = "(140)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "200841F"; + flags643dfloorflagsadd = "40"; + } + + 141 + { + title = "Intangible from Bottom, Translucent"; + prefix = "(141)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "200191F"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 142 + { + title = "Intangible from Bottom, Translucent, No Sides"; + prefix = "(142)"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "2001917"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 143 + { + title = "Intangible from Top, Opaque"; + prefix = "(143)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "400841F"; + flags643dfloorflagsadd = "40"; + } + + 144 + { + title = "Intangible from Top, Translucent"; + prefix = "(144)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "400191F"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 145 + { + title = "Intangible from Top, Translucent, No Sides"; + prefix = "(145)"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Render insides/block non-plr"; + 3dfloor = true; + 3dfloorflags = "4001917"; + flags1283dfloorflagsadd = "7C80"; + flags643dfloorflagsadd = "40"; + } + + 146 + { + title = "Only Tangible from Sides"; + prefix = "(146)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "600800F"; + } + } + + fofintangible + { + title = "FOF (intangible)"; + + 120 + { + title = "Water, Opaque"; + prefix = "(120)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "8F39"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 121 + { + title = "Water, Translucent"; + prefix = "(121)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "9F39"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 122 + { + title = "Water, Opaque, No Sides"; + prefix = "(122)"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "F31"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 123 + { + title = "Water, Translucent, No Sides"; + prefix = "(123)"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "1F31"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 124 + { + title = "Goo Water, Translucent"; + prefix = "(124)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "209F39"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 125 + { + title = "Goo Water, Translucent, No Sides"; + prefix = "(125)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Use two light levels"; + flags512text = "[9] Use target light level"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "201F31"; + flags643dfloorflagsadd = "20000"; + flags5123dfloorflagsadd = "80000000"; + flags10243dfloorflagsadd = "40000000"; + } + + 220 + { + title = "Intangible, Opaque"; + prefix = "(220)"; + flags8text = "[3] Slope skew sides"; + 3dfloor = true; + 3dfloorflags = "8F19"; + } + + 221 + { + title = "Intangible, Translucent"; + prefix = "(221)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Cast shadow"; + 3dfloor = true; + 3dfloorflags = "1B59"; + flags643dfloorflagsremove = "40"; + } + + 222 + { + title = "Intangible, Sides Only"; + prefix = "(222)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Cast shadow"; + 3dfloor = true; + 3dfloorflags = "8249"; + flags643dfloorflagsremove = "240"; + } + + 223 + { + title = "Intangible, Invisible"; + prefix = "(223)"; + 3dfloor = true; + 3dfloorflags = "41"; + } + } + + fofmoving + { + title = "FOF (moving)"; + + 150 + { + title = "Air Bobbing"; + prefix = "(150)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 151 + { + title = "Air Bobbing (Adjustable)"; + prefix = "(151)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 152 + { + title = "Reverse Air Bobbing (Adjustable)"; + prefix = "(152)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 160 + { + title = "Floating, Bobbing"; + prefix = "(160)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "4019F"; + } + + 190 + { + title = "Rising Platform, Solid, Opaque"; + prefix = "(190)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 191 + { + title = "Rising Platform, Solid, Opaque, No Shadow"; + prefix = "(191)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1DF"; + } + + 192 + { + title = "Rising Platform, Solid, Translucent"; + prefix = "(192)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "195F"; + } + + 193 + { + title = "Rising Platform, Solid, Invisible"; + prefix = "(193)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "47"; + } + + 194 + { + title = "Rising Platform, Intangible from Bottom, Opaque"; + prefix = "(194)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash, no shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "200841F"; + flags643dfloorflagsadd = "40"; + } + + 195 + { + title = "Rising Platform, Intangible from Bottom, Translucent"; + prefix = "(195)"; + flags2text = "[1] Sink when stepped on"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash, no shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "2009D1F"; + flags643dfloorflagsadd = "40"; + } + } + + fofcrumbling + { + title = "FOF (crumbling)"; + + 170 + { + title = "Crumbling, Respawn"; + prefix = "(170)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "10019F"; + } + + 171 + { + title = "Crumbling, No Respawn"; + prefix = "(171)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "80019F"; + } + + 172 + { + title = "Crumbling, Respawn, Intangible from Bottom"; + prefix = "(172)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "210841F"; + flags643dfloorflagsadd = "40"; + } + + 173 + { + title = "Crumbling, No Respawn, Intangible from Bottom"; + prefix = "(173)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "218841F"; + flags643dfloorflagsadd = "40"; + } + + 174 + { + title = "Crumbling, Respawn, Int. from Bottom, Translucent"; + prefix = "(174)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "210959F"; + flags643dfloorflagsadd = "40"; + } + + 175 + { + title = "Crumbling, No Respawn, Int. from Bottom, Translucent"; + prefix = "(175)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Don't cast shadow"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "218959F"; + flags643dfloorflagsadd = "40"; + } + + 176 + { + title = "Crumbling, Respawn, Floating, Bobbing"; + prefix = "(176)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "14019F"; + } + + 177 + { + title = "Crumbling, No Respawn, Floating, Bobbing"; + prefix = "(177)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1C019F"; + } + + 178 + { + title = "Crumbling, Respawn, Floating"; + prefix = "(178)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "14019F"; + } + + 179 + { + title = "Crumbling, No Respawn, Floating"; + prefix = "(179)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "1C019F"; + } + + 180 + { + title = "Crumbling, Respawn, Air Bobbing"; + prefix = "(180)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags64text = "[6] Spindash to move"; + flags128text = "[7] Only block non-players"; + 3dfloor = true; + 3dfloorflags = "10019F"; + } + } + + fofspecial + { + title = "FOF (special)"; + + 200 + { + title = "Light Block"; + prefix = "(200)"; + 3dfloor = true; + 3dfloorflags = "20201"; + } + + 201 + { + title = "Half Light Block"; + prefix = "(201)"; + 3dfloor = true; + 3dfloorflags = "201"; + } + + 202 + { + title = "Fog Block"; + prefix = "(202)"; + 3dfloor = true; + 3dfloorflags = "3EF19"; + } + + 250 + { + title = "Mario Block"; + prefix = "(250)"; + flags32text = "[5] Invisible block"; + flags64text = "[6] Brick block"; + 3dfloor = true; + 3dfloorflags = "40019F"; + } + + 251 + { + title = "Thwomp Block"; + prefix = "(251)"; + flags512text = "[9] Custom crushing sound"; + flags1024text = "[10] Custom speed"; + 3dfloor = true; + 3dfloorflags = "19F"; + } + + 252 + { + title = "Shatter Block"; + prefix = "(252)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Shatter only from below"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "8800019"; + flags643dfloorflagsadd = "200006"; + } + + 253 + { + title = "Shatter Block, Translucent"; + prefix = "(253)"; + flags8text = "[3] Slope skew sides"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "8801019"; + } + + 254 + { + title = "Bustable Block"; + prefix = "(254)"; + flags8text = "[3] Slope skew sides"; + flags64text = "[6] Strong characters only"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "80001F"; + flags643dfloorflagsadd = "20000000"; + } + + 255 + { + title = "Spin-Bustable Block"; + prefix = "(255)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "1080001F"; + } + + 256 + { + title = "Spin-Bustable Block, Translucent"; + prefix = "(256)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorflags = "1080101F"; + } + + 257 + { + title = "Quicksand"; + prefix = "(257)"; + flags8text = "[3] Slope skew sides"; + flags1024text = "[10] Ripple effect"; + 3dfloor = true; + 3dfloorflags = "1008219"; + flags10243dfloorflagsadd = "40000000"; + } + + 258 + { + title = "Laser"; + prefix = "(258)"; + flags8text = "[3] Slope skew sides"; + flags32text = "[5] Don't damage bosses"; + 3dfloor = true; + 3dfloorflags = "959"; + } + + 259 + { + title = "Custom FOF"; + prefix = "(259)"; + flags32text = "[5] Only block player"; + flags128text = "[7] Only block non-players"; + flags512text = "[9] Shattered by pushables"; + flags1024text = "[10] Trigger linedef executor"; + 3dfloor = true; + 3dfloorcustom = true; + } + } + + linedeftrigger + { + title = "Linedef Executor Trigger"; + + 300 + { + title = "Continuous"; + prefix = "(300)"; + } + + 301 + { + title = "Each Time"; + prefix = "(301)"; + flags16384text = "[14] Also trigger on exit"; + } + + 302 + { + title = "Once"; + prefix = "(302)"; + } + + 303 + { + title = "Ring Count - Continuous"; + prefix = "(303)"; + flags2text = "[1] Rings greater or equal"; + flags64text = "[6] Rings less or equal"; + flags512text = "[9] Consider all players"; + } + + 304 + { + title = "Ring Count - Once"; + prefix = "(304)"; + flags2text = "[1] Rings greater or equal"; + flags64text = "[6] Rings less or equal"; + flags512text = "[9] Consider all players"; + } + + 305 + { + title = "Character Ability - Continuous"; + prefix = "(305)"; + } + + 306 + { + title = "Character Ability - Each Time"; + prefix = "(306)"; + flags16384text = "[14] Also trigger on exit"; + } + + 307 + { + title = "Character Ability - Once"; + prefix = "(307)"; + } + + 308 + { + title = "Race Only - Once"; + prefix = "(308)"; + } + + 309 + { + title = "CTF Red Team - Continuous"; + prefix = "(309)"; + } + + 310 + { + title = "CTF Red Team - Each Time"; + prefix = "(310)"; + flags16384text = "[14] Also trigger on exit"; + } + + 311 + { + title = "CTF Blue Team - Continuous"; + prefix = "(311)"; + } + + 312 + { + title = "CTF Blue Team - Each Time"; + prefix = "(312)"; + flags16384text = "[14] Also trigger on exit"; + } + + 313 + { + title = "No More Enemies - Once"; + prefix = "(313)"; + } + + 314 + { + title = "Number of Pushables - Continuous"; + prefix = "(314)"; + flags64text = "[6] Number greater or equal"; + flags512text = "[9] Number less"; + } + + 315 + { + title = "Number of Pushables - Once"; + prefix = "(315)"; + flags64text = "[6] Number greater or equal"; + flags512text = "[9] Number less"; + } + + 317 + { + title = "Condition Set Trigger - Continuous"; + prefix = "(317)"; + } + + 318 + { + title = "Condition Set Trigger - Once"; + prefix = "(318)"; + } + + 319 + { + title = "Unlockable - Continuous"; + prefix = "(319)"; + } + + 320 + { + title = "Unlockable - Once"; + prefix = "(320)"; + } + + 321 + { + title = "Trigger After X Calls - Continuous"; + prefix = "(321)"; + flags64text = "[6] Trigger more than once"; + + } + + 322 + { + title = "Trigger After X Calls - Each Time"; + prefix = "(322)"; + flags64text = "[6] Trigger more than once"; + } + + 323 + { + title = "NiGHTSerize - Each Time"; + prefix = "(323)"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run only if player is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Run if no more mares"; + flags32768text = "[15] Run if player is not NiGHTS"; + } + + 324 + { + title = "NiGHTSerize - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run only if player is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Run if no more mares"; + flags32768text = "[15] Run if player is not NiGHTS"; + prefix = "(324)"; + } + + 325 + { + title = "De-NiGHTSerize - Each Time"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run if anyone is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags32768text = "[15] Run if no one is NiGHTS"; + prefix = "(325)"; + } + + 326 + { + title = "De-NiGHTSerize - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run if anyone is NiGHTS"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags32768text = "[15] Run if no one is NiGHTS"; + prefix = "(326)"; + } + + 327 + { + title = "NiGHTS Lap - Each Time"; + flags2text = "[1] Mare >= Front X Offset"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + prefix = "(327)"; + } + + 328 + { + title = "NiGHTS Lap - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + prefix = "(328)"; + } + + 329 + { + title = "Ideya Capture Touch - Each Time"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run regardless of spheres"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Only if not enough spheres"; + flags32768text = "[15] Run when entering Capture"; + prefix = "(329)"; + } + + 330 + { + title = "Ideya Capture Touch - Once"; + flags2text = "[1] Mare >= Front X Offset"; + flags8text = "[3] Run regardless of spheres"; + flags16text = "[4] Count from lowest of players"; + flags32text = "[5] Lap <= Front Y Offset"; + flags64text = "[6] Mare <= Front X Offset"; + flags128text = "[7] Lap >= Front Y Offset"; + flags256text = "[8] Count laps from Bonus Time"; + flags512text = "[9] Count from triggering player"; + flags16384text = "[14] Only if not enough spheres"; + flags32768text = "[15] Run when entering Capture"; + prefix = "(330)"; + } + + 331 + { + title = "Player Skin - Continuous"; + flags64text = "[6] Disable for this skin"; + prefix = "(331)"; + } + + 332 + { + title = "Player Skin - Each Time"; + flags64text = "[6] Disable for this skin"; + prefix = "(332)"; + } + + 333 + { + title = "Player Skin - Once"; + flags64text = "[6] Disable for this skin"; + prefix = "(333)"; + } + + 399 + { + title = "Level Load"; + prefix = "(399)"; + } + } + + linedefexecsector + { + title = "Linedef Executor (sector)"; + + 400 + { + title = "Set Tagged Sector's Floor Height/Texture"; + prefix = "(400)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Keep floor flat"; + } + + 401 + { + title = "Set Tagged Sector's Ceiling Height/Texture"; + prefix = "(401)"; + flags8text = "[3] Set delay by backside sector"; + } + + 402 + { + title = "Set Tagged Sector's Light Level"; + prefix = "(402)"; + flags8text = "[3] Set delay by backside sector"; + } + + 409 + { + title = "Change Tagged Sector's Tag"; + prefix = "(409)"; + flags8text = "[3] Set delay by backside sector"; + } + + 410 + { + title = "Change Front Sector's Tag"; + prefix = "(410)"; + flags8text = "[3] Set delay by backside sector"; + } + + 416 + { + title = "Start Adjustable Flickering Light"; + prefix = "(416)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 417 + { + title = "Start Adjustable Pulsating Light"; + prefix = "(417)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 418 + { + title = "Start Adjustable Blinking Light (unsynchronized)"; + prefix = "(418)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 419 + { + title = "Start Adjustable Blinking Light (synchronized)"; + prefix = "(419)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Second level from back"; + } + + 420 + { + title = "Fade Light Level"; + prefix = "(420)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Set params by X/Y offsets"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + } + + 421 + { + title = "Stop Lighting Effect"; + prefix = "(421)"; + flags8text = "[3] Set delay by backside sector"; + } + + 435 + { + title = "Change Plane Scroller Direction"; + prefix = "(435)"; + flags8text = "[3] Set delay by backside sector"; + } + } + + linedefexecplane + { + title = "Linedef Executor (plane movement)"; + + 403 + { + title = "Move Tagged Sector's Floor"; + prefix = "(403)"; + flags2text = "[1] Trigger linedef executor"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Change floor flat"; + } + + 404 + { + title = "Move Tagged Sector's Ceiling"; + prefix = "(404)"; + flags2text = "[1] Trigger linedef executor"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Change ceiling flat"; + } + + 405 + { + title = "Move Floor According to Front Texture Offsets"; + prefix = "(405)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Move instantly"; + } + + 407 + { + title = "Move Ceiling According to Front Texture Offsets"; + prefix = "(407)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Move instantly"; + } + + 411 + { + title = "Stop Plane Movement"; + prefix = "(411)"; + flags8text = "[3] Set delay by backside sector"; + } + + 428 + { + title = "Start Platform Movement"; + prefix = "(428)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Move upwards at start"; + } + + 429 + { + title = "Crush Ceiling Once"; + prefix = "(429)"; + flags8text = "[3] Set delay by backside sector"; + flags512text = "[9] Double, constant speed"; + } + + 430 + { + title = "Crush Floor Once"; + prefix = "(430)"; + flags8text = "[3] Set delay by backside sector"; + } + + 431 + { + title = "Crush Floor and Ceiling Once"; + prefix = "(431)"; + flags8text = "[3] Set delay by backside sector"; + flags512text = "[9] Double, constant speed"; + } + } + + linedefexecplayer + { + title = "Linedef Executor (player/object)"; + + 412 + { + title = "Teleporter"; + prefix = "(412)"; + flags2text = "[1] Silent"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Retain angle"; + flags256text = "[8] Relative, silent"; + flags512text = "[9] Retain momentum"; + } + + 425 + { + title = "Change Object State"; + prefix = "(425)"; + flags8text = "[3] Set delay by backside sector"; + } + + 426 + { + title = "Stop Object"; + prefix = "(426)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Teleport to sector center"; + } + + 427 + { + title = "Award Score"; + prefix = "(427)"; + flags8text = "[3] Set delay by backside sector"; + } + + 432 + { + title = "Enable/Disable 2D Mode"; + prefix = "(432)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Return to 3D"; + } + + 433 + { + title = "Enable/Disable Gravity Flip"; + prefix = "(433)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Return to normal"; + } + + 434 + { + title = "Award Power-Up"; + prefix = "(434)"; + flags2text = "[1] Use back upper texture"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] No time limit"; + } + + 437 + { + title = "Disable Player Control"; + prefix = "(437)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Allow jumping"; + } + + 438 + { + title = "Change Object Size"; + prefix = "(438)"; + flags8text = "[3] Set delay by backside sector"; + } + + 442 + { + title = "Change Object Type State"; + prefix = "(442)"; + flags8text = "[3] Set delay by backside sector"; + } + + 457 + { + title = "Track Object's Angle"; + prefix = "(457)"; + flags8text = "[3] Set delay by backside sector"; + flags128text = "[7] Don't stop after first fail"; + } + + 458 + { + title = "Stop Tracking Object's Angle"; + prefix = "(458)"; + flags8text = "[3] Set delay by backside sector"; + } + + 460 + { + title = "Award Rings"; + prefix = "(460)"; + } + + 461 + { + title = "Spawn Object"; + prefix = "(461)"; + flags64text = "[6] Spawn inside a range"; + } + + 462 + { + title = "Stop Timer/Exit Stage in Record Attack"; + prefix = "(462)"; + } + } + + linedefexecmisc + { + title = "Linedef Executor (misc.)"; + + 413 + { + title = "Change Music"; + prefix = "(413)"; + flags2text = "[1] Keep after death"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] Seek to current song position"; + flags64text = "[6] For everyone"; + flags128text = "[7] Fade to custom volume"; + flags512text = "[9] Don't loop"; + flags16384text = "[14] Force music reload"; + } + + 414 + { + title = "Play Sound Effect"; + prefix = "(414)"; + flags2text = "[1] From calling sector"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] From nowhere for triggerer"; + flags512text = "[9] For everyone"; + flags1024text = "[10] From tagged sectors"; + } + + 415 + { + title = "Run Script"; + prefix = "(415)"; + flags8text = "[3] Set delay by backside sector"; + } + + 422 + { + title = "Switch to Cut-Away View"; + prefix = "(422)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Adjust pitch"; + } + + 423 + { + title = "Change Sky"; + prefix = "(423)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] For everyone"; + } + + 424 + { + title = "Change Weather"; + prefix = "(424)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] For everyone"; + } + + 436 + { + title = "Shatter FOF"; + prefix = "(436)"; + flags8text = "[3] Set delay by backside sector"; + } + + 439 + { + title = "Change Tagged Linedef's Textures"; + prefix = "(439)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Only existing"; + } + + 440 + { + title = "Start Metal Sonic Race"; + prefix = "(440)"; + flags8text = "[3] Set delay by backside sector"; + } + + 441 + { + title = "Condition Set Trigger"; + prefix = "(441)"; + flags8text = "[3] Set delay by backside sector"; + } + + 443 + { + title = "Call Lua Function"; + prefix = "(443)"; + flags8text = "[3] Set delay by backside sector"; + } + + 444 + { + title = "Earthquake"; + prefix = "(444)"; + flags8text = "[3] Set delay by backside sector"; + } + + + 445 + { + title = "Make FOF Disappear/Reappear"; + prefix = "(445)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Reappear"; + } + + 446 + { + title = "Make FOF Crumble"; + prefix = "(446)"; + flags2text = "[1] Flags determine respawn"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't respawn"; + } + + 447 + { + title = "Change Tagged Sector's Colormap"; + prefix = "(447)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Front X/Y = Alpha"; + flags32text = "[5] Subtract Red value"; + flags64text = "[6] Subtract Green value"; + flags128text = "[7] Subtract Blue value"; + flags256text = "[8] Calc relative values"; + flags32768text = "[15] Use back side colormap"; + } + + 448 + { + title = "Change Skybox"; + prefix = "(448)"; + flags2text = "[1] Change centerpoint"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] For everyone"; + flags512text = "[9] Don't change viewpoint"; + } + + 450 + { + title = "Execute Linedef Executor (specific tag)"; + prefix = "(450)"; + flags8text = "[3] Set delay by backside sector"; + } + + 451 + { + title = "Execute Linedef Executor (random tag in range)"; + prefix = "(451)"; + flags8text = "[3] Set delay by backside sector"; + } + + 452 + { + title = "Set FOF Translucency"; + prefix = "(452)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Do not handle FF_TRANS"; + flags256text = "[8] Set relative to current val"; + } + + 453 + { + title = "Fade FOF"; + prefix = "(453)"; + flags2text = "[1] Do not handle FF_EXISTS"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] No collision during fade"; + flags64text = "[6] Do not handle FF_TRANS"; + flags128text = "[7] Do not handle lighting"; + flags256text = "[8] Set relative to current val"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + flags16384text = "[14] Do not handle collision"; + flags32768text = "[15] Use exact alpha in OGL"; + } + + 454 + { + title = "Stop Fading FOF"; + prefix = "(454)"; + flags2text = "[1] Do not finalize collision"; + flags8text = "[3] Set delay by backside sector"; + } + + 455 + { + title = "Fade Tagged Sector's Colormap"; + prefix = "(455)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Front X/Y = Alpha"; + flags32text = "[5] Subtract Red value"; + flags64text = "[6] Subtract Green value"; + flags128text = "[7] Subtract Blue value"; + flags256text = "[8] Calc relative values"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + flags16384text = "[14] Fade from invisible black"; + flags32768text = "[15] Use back side colormap"; + } + + 456 + { + title = "Stop Fading Tagged Sector's Colormap"; + prefix = "(456)"; + flags8text = "[3] Set delay by backside sector"; + } + + 459 + { + title = "Control Text Prompt"; + prefix = "(459)"; + flags2text = "[1] Close text prompt"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] Run executor tag on close"; + flags64text = "[6] For everyone"; + flags128text = "[7] Do not block controls"; + flags256text = "[8] Do not freeze time"; + flags32768text = "[15] Find prompt by name"; + } + } + + linedefexecpoly + { + title = "Linedef Executor (polyobject)"; + + 480 + { + title = "Door Slide"; + prefix = "(480)"; + flags8text = "[3] Set delay by backside sector"; + } + + 481 + { + title = "Door Swing"; + prefix = "(481)"; + flags8text = "[3] Set delay by backside sector"; + } + + 482 + { + title = "Move"; + prefix = "(482)"; + flags8text = "[3] Set delay by backside sector"; + } + + 483 + { + title = "Move, Override"; + prefix = "(483)"; + flags8text = "[3] Set delay by backside sector"; + } + + 484 + { + title = "Rotate Right"; + prefix = "(484)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 485 + { + title = "Rotate Right, Override"; + prefix = "(485)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 486 + { + title = "Rotate Left"; + prefix = "(486)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 487 + { + title = "Rotate Left, Override"; + prefix = "(487)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Don't turn players"; + flags512text = "[9] Turn all objects"; + } + + 488 + { + title = "Move by Waypoints"; + prefix = "(488)"; + flags8text = "[3] Set delay by backside sector"; + flags32text = "[5] Reverse order"; + flags128text = "[7] There and back"; + flags256text = "[8] Return when done"; + flags512text = "[9] Loop movement"; + } + + 489 + { + title = "Turn Invisible, Intangible"; + prefix = "(489)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Only invisible"; + } + + 490 + { + title = "Turn Visible, Tangible"; + prefix = "(490)"; + flags8text = "[3] Set delay by backside sector"; + flags64text = "[6] Only visible"; + } + + 491 + { + title = "Set Translucency"; + prefix = "(491)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Set raw alpha by Front X"; + flags256text = "[8] Calc relative values"; + } + + 492 + { + title = "Fade Translucency"; + prefix = "(492)"; + flags8text = "[3] Set delay by backside sector"; + flags16text = "[4] Set raw alpha by Front X"; + flags32text = "[5] No collision during fade"; + flags256text = "[8] Calc relative values"; + flags512text = "[9] Speed = Tic Duration"; + flags1024text = "[10] Override existing fade"; + flags16384text = "[14] Do not handle collision"; + } + } + + wallscroll + { + title = "Wall Scrolling"; + + 500 + { + title = "Scroll Wall Front Side Left"; + prefix = "(500)"; + } + + 501 + { + title = "Scroll Wall Front Side Right"; + prefix = "(501)"; + } + + 502 + { + title = "Scroll Wall According to Linedef"; + prefix = "(502)"; + } + + 503 + { + title = "Scroll Wall According to Linedef (Accelerative)"; + prefix = "(503)"; + } + + 504 + { + title = "Scroll Wall According to Linedef (Displacement)"; + prefix = "(504)"; + } + + 505 + { + title = "Scroll Texture by Front Side Offsets"; + prefix = "(505)"; + } + + 506 + { + title = "Scroll Texture by Back Side Offsets"; + prefix = "(506)"; + } + } + + planescroll + { + title = "Plane Scrolling"; + + 510 + { + title = "Scroll Floor Texture"; + prefix = "(510)"; + } + + 511 + { + title = "Scroll Floor Texture (Accelerative)"; + prefix = "(511)"; + } + + 512 + { + title = "Scroll Floor Texture (Displacement)"; + prefix = "(512)"; + } + + 513 + { + title = "Scroll Ceiling Texture"; + prefix = "(513)"; + } + + 514 + { + title = "Scroll Ceiling Texture (Accelerative)"; + prefix = "(514)"; + } + + 515 + { + title = "Scroll Ceiling Texture (Displacement)"; + prefix = "(515)"; + } + + 520 + { + title = "Carry Objects on Floor"; + prefix = "(520)"; + } + + 521 + { + title = "Carry Objects on Floor (Accelerative)"; + prefix = "(521)"; + flags64text = "[6] Even across edges"; + } + + 522 + { + title = "Carry Objects on Floor (Displacement)"; + prefix = "(522)"; + } + + 523 + { + title = "Carry Objects on Ceiling"; + prefix = "(523)"; + flags64text = "[6] Even across edges"; + } + + 524 + { + title = "Carry Objects on Ceiling (Accelerative)"; + prefix = "(524)"; + } + + 525 + { + title = "Carry Objects on Ceiling (Displacement)"; + prefix = "(525)"; + } + + 530 + { + title = "Scroll Floor Texture and Carry Objects"; + prefix = "(530)"; + flags64text = "[6] Even across edges"; + } + + 531 + { + title = "Scroll Floor Texture and Carry Objects (Accelerative)"; + prefix = "(531)"; + } + + 532 + { + title = "Scroll Floor Texture and Carry Objects (Displacement)"; + prefix = "(532)"; + } + + 533 + { + title = "Scroll Ceiling Texture and Carry Objects"; + prefix = "(533)"; + flags64text = "[6] Even across edges"; + } + + 534 + { + title = "Scroll Ceiling Texture and Carry Objects (Accelerative)"; + prefix = "(534)"; + } + + 535 + { + title = "Scroll Ceiling Texture and Carry Objects (Displacement)"; + prefix = "(535)"; + } + } + + pusher + { + title = "Pusher"; + + 541 + { + title = "Wind"; + prefix = "(541)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 542 + { + title = "Upwards Wind"; + prefix = "(542)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 543 + { + title = "Downwards Wind"; + prefix = "(543)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 544 + { + title = "Current"; + prefix = "(544)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 545 + { + title = "Upwards Current"; + prefix = "(545)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 546 + { + title = "Downwards Current"; + prefix = "(546)"; + flags512text = "[9] Player slides"; + flags64text = "[6] Even across edges"; + } + + 547 + { + title = "Push/Pull"; + prefix = "(547)"; + } + } + + light + { + title = "Lighting"; + + 600 + { + title = "Floor Lighting"; + prefix = "(600)"; + } + + 601 + { + title = "Ceiling Lighting"; + prefix = "(601)"; + } + + 602 + { + title = "Adjustable Pulsating Light"; + prefix = "(602)"; + } + + 603 + { + title = "Adjustable Flickering Light"; + prefix = "(603)"; + } + + 604 + { + title = "Adjustable Blinking Light (unsynchronized)"; + prefix = "(604)"; + } + + 605 + { + title = "Adjustable Blinking Light (synchronized)"; + prefix = "(605)"; + } + + 606 + { + title = "Colormap"; + prefix = "(606)"; + } + } + + slope + { + title = "Slope"; + + 700 + { + title = "Slope Frontside Floor"; + prefix = "(700)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 1; + } + + 701 + { + title = "Slope Frontside Ceiling"; + prefix = "(701)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 2; + } + + 702 + { + title = "Slope Frontside Floor and Ceiling"; + prefix = "(702)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 3; + } + + 703 + { + title = "Slope Frontside Floor and Backside Ceiling"; + prefix = "(703)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 9; + } + + 704 + { + title = "Slope Frontside Floor by 3 Tagged Vertex Things"; + prefix = "(704)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 0; + } + + 705 + { + title = "Slope Frontside Ceiling by 3 Tagged Vertex Things"; + prefix = "(705)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 1; + } + + 710 + { + title = "Slope Backside Floor"; + prefix = "(710)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 4; + } + + 711 + { + title = "Slope Backside Ceiling"; + prefix = "(711)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 8; + } + + 712 + { + title = "Slope Backside Floor and Ceiling"; + prefix = "(712)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 12; + } + + 713 + { + title = "Slope Backside Floor and Frontside Ceiling"; + prefix = "(713)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + slope = "regular"; + slopeargs = 6; + } + + 714 + { + title = "Slope Backside Floor by 3 Tagged Vertex Things"; + prefix = "(714)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 2; + } + + 715 + { + title = "Slope Backside Ceiling by 3 Tagged Vertex Things"; + prefix = "(715)"; + flags2048text = "[11] No physics"; + flags4096text = "[12] Dynamic"; + flags8192text = "[13] Use tag and offsets"; + slope = "vertex"; + slopeargs = 3; + } + + 720 + { + title = "Copy Frontside Floor Slope from Line Tag"; + prefix = "(720)"; + slope = "copy"; + slopeargs = 1; + } + + 721 + { + title = "Copy Frontside Ceiling Slope from Line Tag"; + prefix = "(721)"; + slope = "copy"; + slopeargs = 2; + } + + 722 + { + title = "Copy Frontside Floor and Ceiling Slope from Line Tag"; + prefix = "(722)"; + slope = "copy"; + slopeargs = 3; + } + + 799 + { + title = "Set Tagged Dynamic Slope Vertex to Front Sector Height"; + prefix = "(799)"; + } + } + + transwall + { + title = "Translucent Wall"; + + 900 + { + title = "90% Opaque"; + prefix = "(900)"; + } + + 901 + { + title = "80% Opaque"; + prefix = "(901)"; + } + + 902 + { + title = "70% Opaque"; + prefix = "(902)"; + } + + 903 + { + title = "60% Opaque"; + prefix = "(903)"; + } + + 904 + { + title = "50% Opaque"; + prefix = "(904)"; + } + + 905 + { + title = "40% Opaque"; + prefix = "(905)"; + } + + 906 + { + title = "30% Opaque"; + prefix = "(906)"; + } + + 907 + { + title = "20% Opaque"; + prefix = "(907)"; + } + + 908 + { + title = "10% Opaque"; + prefix = "(908)"; + } + + 909 + { + title = "Fog Wall"; + prefix = "(909)"; + } + } +} + + +// THING FLAGS +thingflags +{ + 1 = "[1] Extra"; + 2 = "[2] Flip"; + 4 = "[4] Special"; + 8 = "[8] Ambush"; +} + +// Thing flags UDMF translation table +// This is needed for copy/paste and prefabs to work properly +// When the UDMF field name is prefixed with ! it is inverted +thingflagstranslation +{ + 1 = "skill1"; + 2 = "skill2"; + 4 = "skill3"; + 8 = "ambush"; +} + +// THING FLAGS ERROR MASK +// Mask for the thing flags which indicates the options +// that make the same thing appear in the same modes +thingflagsmask1 = 7; // 1 + 2 + 4 +thingflagsmask2 = 0; + + +// THING TYPES------------------------------------------------------------------ +// Color values: 1-Dark_Blue 2-Dark_Green 3-Turqoise 4-Dark_Red 5-Purple 6-Brown 7-Gray +// 8-Dark_Gray 9-Blue 10-Green 11-Cyan 12-Red 13-Magenta +// 14-Yellow 15-White 16-Pink 17-Orange 18-Gold 19-Cream +thingtypes +{ + editor + { + color = 15; // White + arrow = 1; + title = ""; + error = -1; + width = 8; + height = 16; + sort = 1; + + 3328 = "3D Mode Start"; + } + + starts + { + color = 1; // Blue + arrow = 1; + title = "Player Starts"; + width = 16; + height = 48; + flags8text = "[8] Spawn on ceiling"; + sprite = "PLAYA0"; + + 1 + { + title = "Player 01 Start"; + sprite = "PLAYA0"; + } + 2 + { + title = "Player 02 Start"; + sprite = "PLAYA0"; + } + 3 + { + title = "Player 03 Start"; + sprite = "PLAYA0"; + } + 4 + { + title = "Player 04 Start"; + sprite = "PLAYA0"; + } + 5 + { + title = "Player 05 Start"; + sprite = "PLAYA0"; + } + 6 + { + title = "Player 06 Start"; + sprite = "PLAYA0"; + } + 7 + { + title = "Player 07 Start"; + sprite = "PLAYA0"; + } + 8 + { + title = "Player 08 Start"; + sprite = "PLAYA0"; + } + 9 + { + title = "Player 09 Start"; + sprite = "PLAYA0"; + } + 10 + { + title = "Player 10 Start"; + sprite = "PLAYA0"; + } + 11 + { + title = "Player 11 Start"; + sprite = "PLAYA0"; + } + 12 + { + title = "Player 12 Start"; + sprite = "PLAYA0"; + } + 13 + { + title = "Player 13 Start"; + sprite = "PLAYA0"; + } + 14 + { + title = "Player 14 Start"; + sprite = "PLAYA0"; + } + 15 + { + title = "Player 15 Start"; + sprite = "PLAYA0"; + } + 16 + { + title = "Player 16 Start"; + sprite = "PLAYA0"; + } + 17 + { + title = "Player 17 Start"; + sprite = "PLAYA0"; + } + 18 + { + title = "Player 18 Start"; + sprite = "PLAYA0"; + } + 19 + { + title = "Player 19 Start"; + sprite = "PLAYA0"; + } + 20 + { + title = "Player 20 Start"; + sprite = "PLAYA0"; + } + 21 + { + title = "Player 21 Start"; + sprite = "PLAYA0"; + } + 22 + { + title = "Player 22 Start"; + sprite = "PLAYA0"; + } + 23 + { + title = "Player 23 Start"; + sprite = "PLAYA0"; + } + 24 + { + title = "Player 24 Start"; + sprite = "PLAYA0"; + } + 25 + { + title = "Player 25 Start"; + sprite = "PLAYA0"; + } + 26 + { + title = "Player 26 Start"; + sprite = "PLAYA0"; + } + 27 + { + title = "Player 27 Start"; + sprite = "PLAYA0"; + } + 28 + { + title = "Player 28 Start"; + sprite = "PLAYA0"; + } + 29 + { + title = "Player 29 Start"; + sprite = "PLAYA0"; + } + 30 + { + title = "Player 30 Start"; + sprite = "PLAYA0"; + } + 31 + { + title = "Player 31 Start"; + sprite = "PLAYA0"; + } + 32 + { + title = "Player 32 Start"; + sprite = "PLAYA0"; + } + 33 + { + title = "Match Start"; + sprite = "NDRNA2A8"; + } + 34 + { + title = "CTF Red Team Start"; + sprite = "SIGNG0"; + } + 35 + { + title = "CTF Blue Team Start"; + sprite = "SIGNE0"; + } + } + + enemies + { + color = 9; // Light_Blue + arrow = 1; + title = "Enemies"; + + 100 + { + title = "Crawla (Blue)"; + sprite = "POSSA1"; + width = 24; + height = 32; + } + 101 + { + title = "Crawla (Red)"; + sprite = "SPOSA1"; + width = 24; + height = 32; + } + 102 + { + title = "Stupid Dumb Unnamed RoboFish"; + sprite = "FISHA0"; + width = 8; + height = 28; + angletext = "Jump strength"; + } + 103 + { + title = "Buzz (Gold)"; + sprite = "BUZZA1"; + width = 28; + height = 40; + flags8text = "[8] Cannot move"; + } + 104 + { + title = "Buzz (Red)"; + sprite = "RBUZA1"; + width = 28; + height = 40; + flags8text = "[8] Cannot move"; + } + 108 + { + title = "Deton"; + sprite = "DETNA1"; + width = 20; + height = 32; + } + 110 + { + title = "Turret"; + sprite = "TRETA1"; + width = 16; + height = 32; + } + 111 + { + title = "Pop-up Turret"; + sprite = "TURRI1"; + width = 12; + height = 64; + angletext = "Firing delay"; + } + 122 + { + title = "Spring Shell (Green)"; + sprite = "SSHLA1"; + width = 24; + height = 40; + } + 125 + { + title = "Spring Shell (Yellow)"; + sprite = "SSHLI1"; + width = 24; + height = 40; + } + 109 + { + title = "Skim"; + sprite = "SKIMA1"; + width = 16; + height = 24; + } + 113 + { + title = "Jet Jaw"; + sprite = "JJAWA3A7"; + width = 12; + height = 20; + } + 126 + { + title = "Crushstacean"; + sprite = "CRABA0"; + width = 24; + height = 32; + flags8text = "[8] Move left from spawn"; + } + 138 + { + title = "Banpyura"; + sprite = "CR2BA0"; + width = 24; + height = 32; + flags8text = "[8] Move left from spawn"; + } + 117 + { + title = "Robo-Hood"; + sprite = "ARCHA1"; + width = 24; + height = 32; + } + 118 + { + title = "Lance-a-Bot"; + sprite = "CBFSA1"; + width = 32; + height = 72; + } + 1113 + { + title = "Suspicious Lance-a-Bot Statue"; + sprite = "CBBSA1"; + width = 32; + height = 72; + } + 119 + { + title = "Egg Guard"; + sprite = "ESHIA1"; + width = 16; + height = 48; + flags1text = "[1] 90 degrees counter-clockwise"; + flags4text = "[4] 90 degrees clockwise"; + flags8text = "[8] Double speed"; + } + 115 + { + title = "Bird Aircraft Strike Hazard"; + sprite = "VLTRF1"; + width = 12; + height = 24; + } + 120 + { + title = "Green Snapper"; + sprite = "GSNPA1"; + width = 24; + height = 24; + } + 121 + { + title = "Minus"; + sprite = "MNUSA0"; + width = 24; + height = 32; + } + 134 + { + title = "Canarivore"; + sprite = "CANAA0"; + width = 12; + height = 80; + hangs = 1; + } + 123 + { + title = "Unidus"; + sprite = "UNIDA1"; + width = 18; + height = 36; + } + 135 + { + title = "Pterabyte Spawner"; + sprite = "PTERA2A8"; + width = 16; + height = 16; + parametertext = "No. Pterabytes"; + } + 136 + { + title = "Pyre Fly"; + sprite = "PYREA0"; + width = 24; + height = 34; + flags8text = "[8] Start on fire"; + } + 137 + { + title = "Dragonbomber"; + sprite = "DRABA1"; + width = 28; + height = 48; + } + 105 + { + title = "Jetty-Syn Bomber"; + sprite = "JETBB1"; + width = 20; + height = 50; + flags8text = "[8] Cannot move"; + } + 106 + { + title = "Jetty-Syn Gunner"; + sprite = "JETGB1"; + width = 20; + height = 48; + flags8text = "[8] Cannot move"; + } + 112 + { + title = "Spincushion"; + sprite = "SHRPA1"; + width = 16; + height = 24; + } + 114 + { + title = "Snailer"; + sprite = "SNLRA3A7"; + width = 24; + height = 48; + } + 129 + { + title = "Penguinator"; + sprite = "PENGA1"; + width = 24; + height = 32; + } + 130 + { + title = "Pophat"; + sprite = "POPHA1"; + width = 24; + height = 32; + } + 107 + { + title = "Crawla Commander"; + sprite = "CCOMA1"; + width = 16; + height = 32; + } + 131 + { + title = "Spinbobert"; + sprite = "SBOBB0"; + width = 32; + height = 32; + } + 132 + { + title = "Cacolantern"; + sprite = "CACOA0"; + width = 32; + height = 32; + flags8text = "[8] Cannot move"; + } + 133 + { + title = "Hangster"; + sprite = "HBATC1"; + width = 24; + height = 24; + hangs = 1; + } + 127 + { + title = "Hive Elemental"; + sprite = "HIVEA0"; + width = 32; + height = 80; + parametertext = "No. bees"; + } + 128 + { + title = "Bumblebore"; + sprite = "BUMBA1"; + width = 16; + height = 32; + } + 124 + { + title = "Buggle"; + sprite = "BBUZA1"; + width = 20; + height = 24; + } + 116 + { + title = "Pointy"; + sprite = "PNTYA1"; + width = 8; + height = 16; + } + } + + bosses + { + color = 8; // Dark_Gray + arrow = 1; + title = "Bosses"; + + 200 + { + title = "Egg Mobile"; + sprite = "EGGMA1"; + width = 24; + height = 76; + flags4text = "[4] End level on death"; + flags8text = "[8] Alternate laser attack"; + } + 201 + { + title = "Egg Slimer"; + sprite = "EGGNA1"; + width = 24; + height = 76; + flags4text = "[4] End level on death"; + flags8text = "[8] Speed up when hit"; + } + 202 + { + title = "Sea Egg"; + sprite = "EGGOA1"; + width = 32; + height = 116; + flags4text = "[4] End level on death"; + } + 203 + { + title = "Egg Colosseum"; + sprite = "EGGPA1"; + width = 24; + height = 76; + flags4text = "[4] End level on death"; + } + 204 + { + title = "Fang"; + sprite = "FANGA1"; + width = 24; + height = 60; + flags1text = "[1] Grayscale mode"; + flags4text = "[4] End level on death"; + } + 206 + { + title = "Brak Eggman (Old)"; + sprite = "BRAKB1"; + width = 48; + height = 160; + flags4text = "[4] End level on death"; + } + 207 + { + title = "Metal Sonic (Race)"; + sprite = "METLI1"; + width = 16; + height = 48; + flags1text = "[1] Grayscale mode"; + } + 208 + { + title = "Metal Sonic (Battle)"; + sprite = "METLC1"; + width = 16; + height = 48; + flags1text = "[1] Grayscale mode"; + flags4text = "[4] End level on death"; + } + 209 + { + title = "Brak Eggman"; + sprite = "BRAK01"; + width = 48; + height = 160; + flags1text = "[1] No origin-fling death"; + flags4text = "[4] End level on death"; + flags8text = "[8] Electric barrier"; + } + 290 + { + arrow = 0; + title = "Boss Escape Point"; + width = 8; + height = 16; + sprite = "internal:eggmanend"; + } + 291 + { + arrow = 0; + title = "Egg Capsule Center"; + width = 8; + height = 16; + sprite = "internal:capsule"; + } + 292 + { + arrow = 0; + title = "Boss Waypoint"; + width = 8; + height = 16; + flags8text = "[8] Sea Egg shooting point"; + sprite = "internal:eggmanway"; + angletext = "No. (Sea Egg)"; + flagsvaluetext = "No. (Brak)"; + parametertext = "Next"; + } + 293 + { + title = "Metal Sonic Gather Point"; + sprite = "internal:metal"; + width = 8; + height = 16; + } + 294 + { + title = "Fang Waypoint"; + flags8text = "[8] Center waypoint"; + sprite = "internal:eggmanway"; + width = 8; + height = 16; + } + } + + rings + { + color = 14; // Yellow + title = "Rings and Weapon Panels"; + width = 24; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + sprite = "RINGA0"; + + 300 + { + title = "Ring"; + sprite = "RINGA0"; + width = 16; + } + 301 + { + title = "Bounce Ring"; + sprite = "internal:RNGBA0"; + } + 302 + { + title = "Rail Ring"; + sprite = "internal:RNGRA0"; + } + 303 + { + title = "Infinity Ring"; + sprite = "internal:RNGIA0"; + } + 304 + { + title = "Automatic Ring"; + sprite = "internal:RNGAA0"; + } + 305 + { + title = "Explosion Ring"; + sprite = "internal:RNGEA0"; + } + 306 + { + title = "Scatter Ring"; + sprite = "internal:RNGSA0"; + } + 307 + { + title = "Grenade Ring"; + sprite = "internal:RNGGA0"; + } + 308 + { + title = "CTF Team Ring (Red)"; + sprite = "internal:RRNGA0"; + width = 16; + } + 309 + { + title = "CTF Team Ring (Blue)"; + sprite = "internal:BRNGA0"; + width = 16; + } + 330 + { + title = "Bounce Ring Panel"; + sprite = "internal:PIKBA0"; + } + 331 + { + title = "Rail Ring Panel"; + sprite = "internal:PIKRA0"; + } + 332 + { + title = "Automatic Ring Panel"; + sprite = "internal:PIKAA0"; + } + 333 + { + title = "Explosion Ring Panel"; + sprite = "internal:PIKEA0"; + } + 334 + { + title = "Scatter Ring Panel"; + sprite = "internal:PIKSA0"; + } + 335 + { + title = "Grenade Ring Panel"; + sprite = "internal:PIKGA0"; + } + } + + collectibles + { + color = 10; // Light_Green + title = "Other Collectibles"; + width = 16; + height = 32; + sort = 1; + sprite = "CEMGA0"; + + 310 + { + title = "CTF Red Flag"; + sprite = "RFLGA0"; + width = 24; + height = 64; + } + 311 + { + title = "CTF Blue Flag"; + sprite = "BFLGA0"; + width = 24; + height = 64; + } + 312 + { + title = "Emerald Token"; + sprite = "TOKEA0"; + width = 16; + height = 32; + flags8height = 24; + flags8text = "[8] Float"; + } + 313 + { + title = "Chaos Emerald 1 (Green)"; + sprite = "CEMGA0"; + } + 314 + { + title = "Chaos Emerald 2 (Purple)"; + sprite = "CEMGB0"; + } + 315 + { + title = "Chaos Emerald 3 (Blue)"; + sprite = "CEMGC0"; + } + 316 + { + title = "Chaos Emerald 4 (Cyan)"; + sprite = "CEMGD0"; + } + 317 + { + title = "Chaos Emerald 5 (Orange)"; + sprite = "CEMGE0"; + } + 318 + { + title = "Chaos Emerald 6 (Red)"; + sprite = "CEMGF0"; + } + 319 + { + title = "Chaos Emerald 7 (Gray)"; + sprite = "CEMGG0"; + } + 320 + { + title = "Emerald Hunt Location"; + sprite = "SHRDA0"; + } + 321 + { + title = "Match Chaos Emerald Spawn"; + sprite = "CEMGA0"; + flags8height = 24; + flags8text = "[8] Float"; + } + 322 + { + title = "Emblem"; + sprite = "EMBMA0"; + width = 16; + height = 30; + flags8height = 24; + flags8text = "[8] Float"; + angletext = "Tag"; + } + } + + boxes + { + color = 7; // Gray + blocking = 2; + title = "Monitors"; + width = 18; + height = 40; + flags1text = "[1] Run Linedef Executor on pop"; + flags4text = "[4] Random (Strong)"; + flags8text = "[8] Random (Weak)"; + + 400 + { + title = "Super Ring (10 Rings)"; + sprite = "TVRIA0"; + } + 401 + { + title = "Pity Shield"; + sprite = "TVPIA0"; + } + 402 + { + title = "Attraction Shield"; + sprite = "TVATA0"; + } + 403 + { + title = "Force Shield"; + sprite = "TVFOA0"; + } + 404 + { + title = "Armageddon Shield"; + sprite = "TVARA0"; + } + 405 + { + title = "Whirlwind Shield"; + sprite = "TVWWA0"; + } + 406 + { + title = "Elemental Shield"; + sprite = "TVELA0"; + } + 407 + { + title = "Super Sneakers"; + sprite = "TVSSA0"; + } + 408 + { + title = "Invincibility"; + sprite = "TVIVA0"; + } + 409 + { + title = "Extra Life"; + sprite = "TV1UA0"; + flags4text = "[4] Random (Strong) / 10k points"; + flags8text = "[8] Random (Weak) / 10k points"; + } + 410 + { + title = "Eggman"; + sprite = "TVEGA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 411 + { + title = "Teleporter"; + sprite = "TVMXA0"; + } + 413 + { + title = "Gravity Boots"; + sprite = "TVGVA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 414 + { + title = "CTF Team Ring Monitor (Red)"; + sprite = "TRRIA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 415 + { + title = "CTF Team Ring Monitor (Blue)"; + sprite = "TBRIA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 416 + { + title = "Recycler"; + sprite = "TVRCA0"; + } + 418 + { + title = "Score (1,000 Points)"; + sprite = "TV1KA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 419 + { + title = "Score (10,000 Points)"; + sprite = "TVTKA0"; + flags4text = "[4] Special"; + flags8text = "[8] Ambush"; + } + 420 + { + title = "Flame Shield"; + sprite = "TVFLA0"; + } + 421 + { + title = "Water Shield"; + sprite = "TVBBA0"; + } + 422 + { + title = "Lightning Shield"; + sprite = "TVZPA0"; + } + } + + boxes2 + { + color = 18; // Gold + blocking = 2; + title = "Monitors (Respawning)"; + width = 20; + height = 44; + flags1text = "[1] Run Linedef Executor on pop"; + + 431 + { + title = "Pity Shield (Respawn)"; + sprite = "TVPIB0"; + } + 432 + { + title = "Attraction Shield (Respawn)"; + sprite = "TVATB0"; + } + 433 + { + title = "Force Shield (Respawn)"; + sprite = "TVFOB0"; + } + 434 + { + title = "Armageddon Shield (Respawn)"; + sprite = "TVARB0"; + } + 435 + { + title = "Whirlwind Shield (Respawn)"; + sprite = "TVWWB0"; + } + 436 + { + title = "Elemental Shield (Respawn)"; + sprite = "TVELB0"; + } + 437 + { + title = "Super Sneakers (Respawn)"; + sprite = "TVSSB0"; + } + 438 + { + title = "Invincibility (Respawn)"; + sprite = "TVIVB0"; + } + 440 + { + title = "Eggman (Respawn)"; + sprite = "TVEGB0"; + } + 443 + { + title = "Gravity Boots (Respawn)"; + sprite = "TVGVB0"; + } + 450 + { + title = "Flame Shield (Respawn)"; + sprite = "TVFLB0"; + } + 451 + { + title = "Water Shield (Respawn)"; + sprite = "TVBBB0"; + } + 452 + { + title = "Lightning Shield (Respawn)"; + sprite = "TVZPB0"; + } + } + + generic + { + color = 11; // Light_Cyan + title = "Generic Items & Hazards"; + + 500 + { + title = "Air Bubble Patch"; + sprite = "BUBLE0"; + width = 8; + height = 16; + flags8text = "[8] No distance check"; + } + 501 + { + title = "Signpost"; + sprite = "SIGND0"; + width = 8; + height = 32; + } + 502 + { + arrow = 1; + title = "Star Post"; + sprite = "STPTA0M0"; + width = 64; + height = 128; + angletext = "Angle/Order"; + } + 520 + { + title = "Bomb Sphere"; + sprite = "SPHRD0"; + width = 16; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + unflippable = true; + } + 521 + { + title = "Spikeball"; + sprite = "SPIKA0"; + width = 12; + height = 8; + flags8height = 24; + flags8text = "[8] Float"; + } + 522 + { + title = "Wall Spike"; + sprite = "WSPKALAR"; + width = 16; + height = 14; + flags1text = "[1] Start retracted"; + flags4text = "[4] Retractable"; + flags8text = "[8] Intangible"; + parametertext = "Initial delay"; + } + 523 + { + title = "Spike"; + sprite = "USPKA0"; + width = 8; + height = 32; + flags1text = "[1] Start retracted"; + flags4text = "[4] Retractable"; + flags8text = "[8] Intangible"; + angletext = "Retraction interval"; + parametertext = "Initial delay"; + } + 1130 + { + title = "Small Mace"; + sprite = "SMCEA0"; + width = 17; + height = 34; + } + 1131 + { + title = "Big Mace"; + sprite = "BMCEA0"; + width = 34; + height = 68; + } + 1136 + { + title = "Small Fireball"; + sprite = "SFBRA0"; + width = 17; + height = 34; + } + 1137 + { + title = "Large Fireball"; + sprite = "BFBRA0"; + width = 34; + height = 68; + } + } + + springs + { + color = 12; // Light_Red + title = "Springs and Fans"; + width = 20; + height = 16; + sprite = "RSPRD2"; + + 540 + { + title = "Fan"; + sprite = "FANSA0D0"; + width = 16; + height = 8; + flags4text = "[4] Invisible"; + flags8text = "[8] No distance check"; + angletext = "Lift height"; + } + 541 + { + title = "Gas Jet"; + sprite = "STEMD0"; + flags8text = "[8] No sounds"; + width = 32; + } + 542 + { + title = "Bumper"; + sprite = "BUMPA0"; + width = 32; + height = 64; + angletext = "Strength"; + } + 543 + { + title = "Balloon"; + sprite = "BLONA0"; + width = 32; + height = 64; + flags8text = "[8] Respawn"; + angletext = "Color"; + } + 550 + { + title = "Yellow Spring"; + sprite = "SPRYA0"; + } + 551 + { + title = "Red Spring"; + sprite = "SPRRA0"; + } + 552 + { + title = "Blue Spring"; + sprite = "SPRBA0"; + } + 555 + { + arrow = 1; + title = "Diagonal Yellow Spring"; + sprite = "YSPRD2"; + width = 16; + flags4text = "[4] Ignore gravity"; + flags8text = "[8] Rotate 22.5° CCW"; + } + 556 + { + arrow = 1; + title = "Diagonal Red Spring"; + sprite = "RSPRD2"; + width = 16; + flags4text = "[4] Ignore gravity"; + flags8text = "[8] Rotate 22.5° CCW"; + } + 557 + { + arrow = 1; + title = "Diagonal Blue Spring"; + sprite = "BSPRD2"; + width = 16; + flags4text = "[4] Ignore gravity"; + flags8text = "[8] Rotate 22.5° CCW"; + } + 558 + { + arrow = 1; + title = "Horizontal Yellow Spring"; + sprite = "SSWYD2D8"; + flags8height = 16; + flags8text = "[8] Float"; + width = 16; + height = 32; + } + 559 + { + arrow = 1; + title = "Horizontal Red Spring"; + sprite = "SSWRD2D8"; + flags8height = 16; + flags8text = "[8] Float"; + width = 16; + height = 32; + } + 560 + { + arrow = 1; + title = "Horizontal Blue Spring"; + sprite = "SSWBD2D8"; + flags8height = 16; + flags8text = "[8] Float"; + width = 16; + height = 32; + } + 1134 + { + title = "Yellow Spring Ball"; + sprite = "YSPBA0"; + width = 17; + height = 34; + } + 1135 + { + title = "Red Spring Ball"; + sprite = "RSPBA0"; + width = 17; + height = 34; + } + 544 + { + arrow = 1; + title = "Yellow Boost Panel"; + sprite = "BSTYA0"; + flags8text = "[8] Force spin"; + width = 28; + height = 2; + } + 545 + { + arrow = 1; + title = "Red Boost Panel"; + sprite = "BSTRA0"; + flags8text = "[8] Force spin"; + width = 28; + height = 2; + } + } + + patterns + { + color = 5; // Magenta + arrow = 1; + title = "Special Placement Patterns"; + width = 16; + height = 384; + sprite = "RINGA0"; + + 600 + { + arrow = 0; + title = "5 Vertical Rings (Yellow Spring)"; + sprite = "RINGA0"; + } + 601 + { + arrow = 0; + title = "5 Vertical Rings (Red Spring)"; + sprite = "RINGA0"; + height = 1024; + } + 602 + { + title = "5 Diagonal Rings (Yellow Spring)"; + sprite = "RINGA0"; + height = 32; + } + 603 + { + title = "10 Diagonal Rings (Red Spring)"; + sprite = "RINGA0"; + height = 32; + } + 604 + { + title = "Circle of Rings"; + sprite = "RINGA0"; + width = 96; + height = 192; + unflippable = true; + centerHitbox = true; + } + 605 + { + title = "Circle of Rings (Big)"; + sprite = "RINGA0"; + width = 192; + unflippable = true; + centerHitbox = true; + } + 606 + { + title = "Circle of Blue Spheres"; + sprite = "SPHRA0"; + width = 96; + height = 192; + unflippable = true; + centerHitbox = true; + } + 607 + { + title = "Circle of Blue Spheres (Big)"; + sprite = "SPHRA0"; + width = 192; + unflippable = true; + centerHitbox = true; + } + 608 + { + title = "Circle of Rings and Spheres"; + sprite = "SPHRA0"; + width = 96; + height = 192; + unflippable = true; + centerHitbox = true; + } + 609 + { + title = "Circle of Rings and Spheres (Big)"; + sprite = "SPHRA0"; + width = 192; + unflippable = true; + centerHitbox = true; + } + } + + invisible + { + color = 15; // White + title = "Misc. Invisible"; + width = 8; + height = 16; + sprite = "UNKNA0"; + + 700 + { + title = "Water Ambience A (Large)"; + sprite = "internal:ambiance"; + } + + 701 + { + title = "Water Ambience B (Large)"; + sprite = "internal:ambiance"; + } + + 702 + { + title = "Water Ambience C (Medium)"; + sprite = "internal:ambiance"; + } + + 703 + { + title = "Water Ambience D (Medium)"; + sprite = "internal:ambiance"; + } + + 704 + { + title = "Water Ambience E (Small)"; + sprite = "internal:ambiance"; + } + + 705 + { + title = "Water Ambience F (Small)"; + sprite = "internal:ambiance"; + } + + 706 + { + title = "Water Ambience G (Extra Large)"; + sprite = "internal:ambiance"; + } + + 707 + { + title = "Water Ambience H (Extra Large)"; + sprite = "internal:ambiance"; + } + + 708 + { + title = "Disco Ambience"; + sprite = "internal:ambiance"; + } + + 709 + { + title = "Volcano Ambience"; + sprite = "internal:ambiance"; + } + + 710 + { + title = "Machine Ambience"; + sprite = "internal:ambiance"; + } + + 750 + { + title = "Slope Vertex"; + sprite = "internal:vertexslope"; + angletext = "Tag"; + } + + 751 + { + arrow = 1; + title = "Teleport Destination"; + sprite = "internal:tele"; + } + + 752 + { + arrow = 1; + title = "Alternate View Point"; + sprite = "internal:view"; + } + + 753 + { + title = "Zoom Tube Waypoint"; + sprite = "internal:zoom"; + angletext = "Order"; + } + + 754 + { + title = "Push Point"; + flags4text = "[4] Fades using XY"; + flags8text = "[8] Push using XYZ"; + sprite = "GWLGA0"; + angletext = "Radius"; + } + 755 + { + title = "Pull Point"; + flags4text = "[4] Fades using XY"; + flags8text = "[8] Pull using XYZ"; + sprite = "GWLRA0"; + angletext = "Radius"; + } + 756 + { + title = "Blast Linedef Executor"; + sprite = "TOADA0"; + width = 32; + height = 16; + } + 757 + { + title = "Fan Particle Generator"; + sprite = "PRTLA0"; + width = 8; + height = 16; + angletext = "Tag"; + } + 758 + { + title = "Object Angle Anchor"; + sprite = "internal:view"; + } + 760 + { + title = "PolyObject Anchor"; + sprite = "internal:polyanchor"; + angletext = "ID"; + } + + 761 + { + title = "PolyObject Spawn Point"; + sprite = "internal:polycenter"; + angletext = "ID"; + } + + 762 + { + title = "PolyObject Spawn Point (Crush)"; + sprite = "internal:polycentercrush"; + angletext = "ID"; + } + 780 + { + title = "Skybox View Point"; + sprite = "internal:skyb"; + flags4text = "[4] In-map centerpoint"; + parametertext = "ID"; + } + } + + greenflower + { + color = 10; // Green + title = "Greenflower"; + + 800 + { + title = "GFZ Flower"; + sprite = "FWR1A0"; + width = 16; + height = 40; + } + 801 + { + title = "Sunflower"; + sprite = "FWR2A0"; + width = 16; + height = 96; + } + 802 + { + title = "Budding Flower"; + sprite = "FWR3A0"; + width = 8; + height = 32; + } + 803 + { + title = "Blueberry Bush"; + sprite = "BUS3A0"; + width = 16; + height = 32; + } + 804 + { + title = "Berry Bush"; + sprite = "BUS1A0"; + width = 16; + height = 32; + } + 805 + { + title = "Bush"; + sprite = "BUS2A0"; + width = 16; + height = 32; + } + 806 + { + title = "GFZ Tree"; + sprite = "TRE1A0"; + width = 20; + height = 128; + } + 807 + { + title = "GFZ Berry Tree"; + sprite = "TRE1B0"; + width = 20; + height = 128; + } + 808 + { + title = "GFZ Cherry Tree"; + sprite = "TRE1C0"; + width = 20; + height = 128; + } + 809 + { + title = "Checkered Tree"; + sprite = "TRE2A0"; + width = 20; + height = 200; + } + 810 + { + title = "Checkered Tree (Sunset)"; + sprite = "TRE2B0"; + width = 20; + height = 200; + } + 811 + { + title = "Polygon Tree"; + sprite = "TRE4A0"; + width = 20; + height = 200; + } + 812 + { + title = "Bush Tree"; + sprite = "TRE5A0"; + width = 20; + height = 200; + } + 813 + { + title = "Red Bush Tree"; + sprite = "TRE5B0"; + width = 20; + height = 200; + } + } + + technohill + { + color = 10; // Green + title = "Techno Hill"; + + 900 + { + title = "THZ Steam Flower"; + sprite = "THZPA0"; + width = 8; + height = 32; + } + 901 + { + title = "Alarm"; + sprite = "ALRMA0"; + width = 8; + height = 16; + hangs = 1; + } + 902 + { + title = "THZ Spin Flower (Red)"; + sprite = "FWR5A0"; + width = 16; + height = 64; + } + 903 + { + title = "THZ Spin Flower (Yellow)"; + sprite = "FWR6A0"; + width = 16; + height = 64; + } + 904 + { + arrow = 1; + title = "Whistlebush"; + sprite = "THZTA0"; + width = 16; + height = 64; + } + } + + deepsea + { + color = 10; // Green + title = "Deep Sea"; + + 1000 + { + arrow = 1; + blocking = 2; + title = "Gargoyle"; + sprite = "GARGA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1009 + { + arrow = 1; + blocking = 2; + title = "Gargoyle (Big)"; + sprite = "GARGB1"; + width = 32; + height = 80; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1001 + { + title = "Seaweed"; + sprite = "SEWEA0"; + width = 24; + height = 56; + } + 1002 + { + title = "Dripping Water"; + sprite = "DRIPD0"; + width = 8; + height = 16; + hangs = 1; + angletext = "Dripping interval"; + } + 1003 + { + title = "Coral (Green)"; + sprite = "CORLA0"; + width = 29; + height = 40; + } + 1004 + { + title = "Coral (Red)"; + sprite = "CORLB0"; + width = 30; + height = 53; + } + 1005 + { + title = "Coral (Orange)"; + sprite = "CORLC0"; + width = 28; + height = 41; + } + 1006 + { + title = "Blue Crystal"; + sprite = "BCRYA1"; + width = 8; + height = 16; + } + 1007 + { + title = "Kelp"; + sprite = "KELPA0"; + width = 16; + height = 292; + flags4text = "[4] Double size"; + } + 1008 + { + title = "Stalagmite (DSZ1)"; + sprite = "DSTGA0"; + width = 8; + height = 116; + flags4text = "[4] Double size"; + } + 1010 + { + arrow = 1; + title = "Light Beam"; + sprite = "LIBEARAL"; + width = 16; + height = 16; + } + 1011 + { + title = "Stalagmite (DSZ2)"; + sprite = "DSTGA0"; + width = 8; + height = 116; + flags4text = "[4] Double size"; + } + 1012 + { + arrow = 1; + title = "Big Floating Mine"; + width = 28; + height = 56; + sprite = "BMNEA1"; + } + 1013 + { + title = "Animated Kelp"; + sprite = "ALGAA0"; + width = 48; + height = 120; + } + 1014 + { + title = "Large Coral (Brown)"; + sprite = "CORLD0"; + width = 56; + height = 112; + } + 1015 + { + title = "Large Coral (Beige)"; + sprite = "CORLE0"; + width = 56; + height = 112; + } + } + + castleeggman + { + color = 10; // Green + title = "Castle Eggman"; + + 1100 + { + title = "Chain (Decorative)"; + sprite = "CHANA0"; + width = 4; + height = 128; + hangs = 1; + } + 1101 + { + title = "Torch"; + sprite = "FLAMA0E0"; + width = 8; + height = 32; + flags1text = "[1] Add corona"; + } + 1102 + { + arrow = 1; + blocking = 2; + title = "Eggman Statue"; + sprite = "ESTAA1"; + width = 32; + height = 240; + flags1text = "[1] Solid gold"; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1103 + { + title = "CEZ Flower"; + sprite = "FWR4A0"; + width = 16; + height = 40; + } + 1104 + { + title = "Mace Spawnpoint"; + sprite = "SMCEA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1105 + { + title = "Chain with Maces Spawnpoint"; + sprite = "SMCEA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1106 + { + title = "Chained Spring Spawnpoint"; + sprite = "YSPBA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Red spring"; + angletext = "Tag"; + } + 1107 + { + title = "Chain Spawnpoint"; + sprite = "BMCHA0"; + width = 17; + height = 34; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1108 + { + arrow = 1; + title = "Hidden Chain Spawnpoint"; + sprite = "internal:chain3"; + width = 17; + height = 34; + flags8text = "[8] Double size"; + } + 1109 + { + title = "Firebar Spawnpoint"; + sprite = "BFBRA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + flags8text = "[8] Double size"; + angletext = "Tag"; + } + 1110 + { + title = "Custom Mace Spawnpoint"; + sprite = "SMCEA0"; + width = 17; + height = 34; + flags4text = "[4] No sounds"; + angletext = "Tag"; + } + 1111 + { + arrow = 1; + blocking = 2; + title = "Crawla Statue"; + sprite = "CSTAA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1112 + { + arrow = 1; + blocking = 2; + title = "Lance-a-Bot Statue"; + sprite = "CBBSA1"; + width = 32; + height = 72; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1114 + { + title = "Pine Tree"; + sprite = "PINEA0"; + width = 16; + height = 628; + } + 1115 + { + title = "CEZ Shrub (Small)"; + sprite = "CEZBA0"; + width = 16; + height = 24; + } + 1116 + { + title = "CEZ Shrub (Large)"; + sprite = "CEZBB0"; + width = 32; + height = 48; + } + 1117 + { + arrow = 1; + title = "Pole Banner (Red)"; + sprite = "BANRA0"; + width = 40; + height = 224; + } + 1118 + { + arrow = 1; + title = "Pole Banner (Blue)"; + sprite = "BANRA0"; + width = 40; + height = 224; + } + 1119 + { + title = "Candle"; + sprite = "CNDLA0"; + width = 8; + height = 48; + flags1text = "[1] Add corona"; + } + 1120 + { + title = "Candle Pricket"; + sprite = "CNDLB0"; + width = 8; + height = 176; + flags1text = "[1] Add corona"; + } + 1121 + { + title = "Flame Holder"; + sprite = "FLMHA0"; + width = 24; + height = 80; + flags1text = "[1] Add corona"; + flags4text = "[4] No flame"; + } + 1122 + { + title = "Fire Torch"; + sprite = "CTRCA0"; + width = 16; + height = 80; + } + 1123 + { + title = "Cannonball Launcher"; + sprite = "internal:cannonball"; + width = 8; + height = 16; + } + 1124 + { + blocking = 2; + title = "Cannonball"; + sprite = "CBLLA0"; + width = 20; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1125 + { + title = "Brambles"; + sprite = "CABRALAR"; + width = 48; + height = 32; + } + 1126 + { + title = "Invisible Lockon Object"; + sprite = "LCKNC0"; + width = 16; + height = 32; + } + 1127 + { + title = "Spectator Eggrobo"; + sprite = "EGR1A1"; + width = 20; + height = 72; + } + 1128 + { + arrow = 1; + title = "Waving Flag (Red)"; + sprite = "CFLGA0"; + width = 8; + height = 208; + } + 1129 + { + arrow = 1; + title = "Waving Flag (Blue)"; + sprite = "CFLGA0"; + width = 8; + height = 208; + } + } + + aridcanyon + { + color = 10; // Green + title = "Arid Canyon"; + + 1200 + { + title = "Tumbleweed (Big)"; + sprite = "BTBLA0"; + width = 24; + height = 48; + flags8text = "[8] Moves perpetually"; + } + 1201 + { + title = "Tumbleweed (Small)"; + sprite = "STBLA0"; + width = 12; + height = 24; + flags8text = "[8] Moves perpetually"; + } + 1202 + { + arrow = 1; + title = "Rock Spawner"; + sprite = "ROIAA0"; + width = 8; + height = 16; + angletext = "Tag"; + } + 1203 + { + title = "Tiny Red Flower Cactus"; + sprite = "CACTA0"; + width = 13; + height = 24; + } + 1204 + { + title = "Small Red Flower Cactus"; + sprite = "CACTB0"; + width = 15; + height = 52; + } + 1205 + { + title = "Tiny Blue Flower Cactus"; + sprite = "CACTC0"; + width = 13; + height = 24; + } + 1206 + { + title = "Small Blue Flower Cactus"; + sprite = "CACTD0"; + width = 15; + height = 52; + } + 1207 + { + title = "Prickly Pear"; + sprite = "CACTE0"; + width = 32; + height = 96; + } + 1208 + { + title = "Barrel Cactus"; + sprite = "CACTF0"; + width = 20; + height = 128; + } + 1209 + { + title = "Tall Barrel Cactus"; + sprite = "CACTG0"; + width = 24; + height = 224; + } + 1210 + { + title = "Armed Cactus"; + sprite = "CACTH0"; + width = 24; + height = 256; + } + 1211 + { + title = "Ball Cactus"; + sprite = "CACTI0"; + width = 48; + height = 96; + } + 1212 + { + title = "Caution Sign"; + sprite = "WWSGAR"; + width = 22; + height = 64; + } + 1213 + { + title = "Cacti Sign"; + sprite = "WWS2AR"; + width = 22; + height = 64; + } + 1214 + { + title = "Sharp Turn Sign"; + sprite = "WWS3ALAR"; + width = 16; + height = 192; + } + 1215 + { + title = "Mine Oil Lamp"; + sprite = "OILLA0"; + width = 22; + height = 64; + hangs = 1; + } + 1216 + { + title = "TNT Barrel"; + sprite = "BARRA1"; + width = 24; + height = 63; + } + 1217 + { + title = "TNT Proximity Shell"; + sprite = "REMTA0"; + width = 64; + height = 40; + } + 1218 + { + title = "Dust Devil"; + sprite = "TAZDCR"; + width = 80; + height = 416; + } + 1219 + { + title = "Minecart Spawner"; + sprite = "MCRTCLFR"; + width = 22; + height = 32; + } + 1220 + { + title = "Minecart Stopper"; + sprite = "MCRTIR"; + width = 32; + height = 32; + } + 1221 + { + title = "Minecart Saloon Door"; + sprite = "SALDARAL"; + width = 96; + height = 160; + flags8text = "[8] Allow non-minecart players"; + } + 1222 + { + title = "Train Cameo Spawner"; + sprite = "TRAEBRBL"; + width = 28; + height = 32; + } + 1223 + { + title = "Train Dust Spawner"; + sprite = "ADSTA0"; + width = 4; + height = 4; + } + 1224 + { + title = "Train Steam Spawner"; + sprite = "STEAA0"; + width = 4; + height = 4; + } + 1229 + { + title = "Minecart Switch Point"; + sprite = "internal:zoom"; + width = 8; + height = 16; + flags8text = "[8] Enable switching"; + } + 1230 + { + title = "Tiny Cactus"; + sprite = "CACTJ0"; + width = 13; + height = 28; + } + 1231 + { + title = "Small Cactus"; + sprite = "CACTK0"; + width = 15; + height = 60; + } + } + + redvolcano + { + color = 10; // Green + title = "Red Volcano"; + + 1300 + { + arrow = 1; + title = "Flame Jet (Horizontal)"; + sprite = "internal:flameh"; + width = 16; + height = 40; + flags8text = "[8] Waves vertically"; + angletext = "On/Off time"; + parametertext = "Strength"; + } + 1301 + { + title = "Flame Jet (Vertical)"; + sprite = "internal:flamev"; + width = 16; + height = 40; + flags8text = "[8] Shoot downwards"; + angletext = "On/Off time"; + parametertext = "Strength"; + } + 1302 + { + title = "Spinning Flame Jet (Counter-Clockwise)"; + sprite = "internal:flame2"; + width = 16; + height = 24; + } + 1303 + { + title = "Spinning Flame Jet (Clockwise)"; + sprite = "internal:flame1"; + width = 16; + height = 24; + } + 1304 + { + title = "Lavafall"; + sprite = "LFALF0"; + width = 30; + height = 32; + angletext = "Initial delay"; + flags8text = "[8] Double size"; + } + 1305 + { + title = "Rollout Rock"; + sprite = "PUMIA1A5"; + width = 30; + height = 60; + flags8text = "[8] Non-buoyant"; + } + 1306 + { + title = "Big Fern"; + sprite = "JPLAB0"; + width = 32; + height = 48; + } + 1307 + { + title = "Jungle Palm"; + sprite = "JPLAC0"; + width = 32; + height = 48; + } + 1308 + { + title = "Torch Flower"; + sprite = "TFLOA0"; + width = 14; + height = 110; + } + 1309 + { + title = "RVZ1 Wall Vine (Long)"; + sprite = "WVINALAR"; + width = 1; + height = 288; + } + 1310 + { + title = "RVZ1 Wall Vine (Short)"; + sprite = "WVINBLBR"; + width = 1; + height = 288; + } + } + + botanicserenity + { + color = 10; // Green + title = "Botanic Serenity"; + width = 16; + height = 32; + sprite = "BSZ1A0"; + 1400 + { + title = "Tall Flower (Red)"; + sprite = "BSZ1A0"; + } + 1401 + { + title = "Tall Flower (Purple)"; + sprite = "BSZ1B0"; + } + 1402 + { + title = "Tall Flower (Blue)"; + sprite = "BSZ1C0"; + } + 1403 + { + title = "Tall Flower (Cyan)"; + sprite = "BSZ1D0"; + } + 1404 + { + title = "Tall Flower (Yellow)"; + sprite = "BSZ1E0"; + } + 1405 + { + title = "Tall Flower (Orange)"; + sprite = "BSZ1F0"; + } + 1410 + { + title = "Medium Flower (Red)"; + sprite = "BSZ2A0"; + } + 1411 + { + title = "Medium Flower (Purple)"; + sprite = "BSZ2B0"; + } + 1412 + { + title = "Medium Flower (Blue)"; + sprite = "BSZ2C0"; + } + 1413 + { + title = "Medium Flower (Cyan)"; + sprite = "BSZ2D0"; + } + 1414 + { + title = "Medium Flower (Yellow)"; + sprite = "BSZ2E0"; + } + 1415 + { + title = "Medium Flower (Orange)"; + sprite = "BSZ2F0"; + } + 1420 + { + title = "Short Flower (Red)"; + sprite = "BSZ3A0"; + } + 1421 + { + title = "Short Flower (Purple)"; + sprite = "BSZ3B0"; + } + 1422 + { + title = "Short Flower (Blue)"; + sprite = "BSZ3C0"; + } + 1423 + { + title = "Short Flower (Cyan)"; + sprite = "BSZ3D0"; + } + 1424 + { + title = "Short Flower (Yellow)"; + sprite = "BSZ3E0"; + } + 1425 + { + title = "Short Flower (Orange)"; + sprite = "BSZ3F0"; + } + 1430 + { + title = "Tulip (Red)"; + sprite = "BST1A0"; + } + 1431 + { + title = "Tulip (Purple)"; + sprite = "BST2A0"; + } + 1432 + { + title = "Tulip (Blue)"; + sprite = "BST3A0"; + } + 1433 + { + title = "Tulip (Cyan)"; + sprite = "BST4A0"; + } + 1434 + { + title = "Tulip (Yellow)"; + sprite = "BST5A0"; + } + 1435 + { + title = "Tulip (Orange)"; + sprite = "BST6A0"; + } + 1440 + { + title = "Cluster (Red)"; + sprite = "BSZ5A0"; + } + 1441 + { + title = "Cluster (Purple)"; + sprite = "BSZ5B0"; + } + 1442 + { + title = "Cluster (Blue)"; + sprite = "BSZ5C0"; + } + 1443 + { + title = "Cluster (Cyan)"; + sprite = "BSZ5D0"; + } + 1444 + { + title = "Cluster (Yellow)"; + sprite = "BSZ5E0"; + } + 1445 + { + title = "Cluster (Orange)"; + sprite = "BSZ5F0"; + } + 1450 + { + title = "Bush (Red)"; + sprite = "BSZ6A0"; + } + 1451 + { + title = "Bush (Purple)"; + sprite = "BSZ6B0"; + } + 1452 + { + title = "Bush (Blue)"; + sprite = "BSZ6C0"; + } + 1453 + { + title = "Bush (Cyan)"; + sprite = "BSZ6D0"; + } + 1454 + { + title = "Bush (Yellow)"; + sprite = "BSZ6E0"; + } + 1455 + { + title = "Bush (Orange)"; + sprite = "BSZ6F0"; + } + 1460 + { + title = "Vine (Red)"; + sprite = "BSZ7A0"; + } + 1461 + { + title = "Vine (Purple)"; + sprite = "BSZ7B0"; + } + 1462 + { + title = "Vine (Blue)"; + sprite = "BSZ7C0"; + } + 1463 + { + title = "Vine (Cyan)"; + sprite = "BSZ7D0"; + } + 1464 + { + title = "Vine (Yellow)"; + sprite = "BSZ7E0"; + } + 1465 + { + title = "Vine (Orange)"; + sprite = "BSZ7F0"; + } + 1470 + { + title = "BSZ Shrub"; + sprite = "BSZ8A0"; + } + 1471 + { + title = "BSZ Clover"; + sprite = "BSZ8B0"; + } + 1473 + { + title = "Palm Tree (Big)"; + width = 16; + height = 160; + sprite = "BSZ8D0"; + } + 1475 + { + title = "Palm Tree (Small)"; + width = 16; + height = 80; + sprite = "BSZ8F0"; + } + } + + azuretemple + { + color = 10; // Green + title = "Azure Temple"; + + 1500 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1501 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle (Up)"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1502 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle (Down)"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1503 + { + arrow = 1; + blocking = 2; + title = "Glaregoyle (Long)"; + sprite = "BGARA1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1504 + { + title = "ATZ Target"; + sprite = "RCRYB0"; + width = 24; + height = 32; + } + 1505 + { + title = "Green Flame"; + sprite = "CFLMA0E0"; + width = 8; + height = 32; + } + 1506 + { + arrow = 1; + blocking = 2; + title = "Blue Gargoyle"; + sprite = "BGARD1"; + width = 16; + height = 40; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + } + + dreamhill + { + color = 10; // Green + title = "Dream Hill"; + + 1600 + { + title = "Spring Tree"; + sprite = "TRE6A0"; + width = 16; + height = 32; + } + 1601 + { + title = "Shleep"; + sprite = "SHLPA0"; + width = 24; + height = 32; + } + 1602 + { + title = "Pian"; + sprite = "NTPNALAR"; + width = 16; + height = 32; + } + } + + nightstrk + { + color = 13; // Pink + title = "NiGHTS Track"; + width = 8; + height = 4096; + sprite = "UNKNA0"; + + 1700 + { + title = "Axis"; + sprite = "internal:axis1"; + circle = 1; + unflippable = true; + ignoreZ = true; + flagsvaluetext = "Order"; + angletext = "Radius/Direction"; + parametertext = "Mare"; + } + 1701 + { + title = "Axis Transfer"; + sprite = "internal:axis2"; + unflippable = true; + ignoreZ = true; + flagsvaluetext = "Order"; + parametertext = "Mare"; + } + 1702 + { + title = "Axis Transfer Line"; + sprite = "internal:axis3"; + unflippable = true; + ignoreZ = true; + flagsvaluetext = "Order"; + parametertext = "Mare"; + } + 1710 + { + title = "Ideya Capture"; + sprite = "CAPSA0"; + width = 72; + height = 144; + angletext = "Rings"; + parametertext = "Mare"; + } + } + + nights + { + color = 13; // Pink + title = "NiGHTS Items"; + width = 16; + height = 32; + + 1703 + { + title = "Ideya Drone"; + sprite = "NDRNA1"; + width = 16; + height = 56; + flags1text = "[1] Align player to middle"; + flags4text = "[4] Align player to top"; + flags8text = "[8] Die upon time up"; + angletext = "Time limit"; + parametertext = "Height"; + } + 1704 + { + arrow = 1; + title = "NiGHTS Bumper"; + sprite = "NBMPG3G7"; + width = 32; + height = 64; + unflippable = true; + flagsvaluetext = "Pitch"; + angletext = "Yaw"; + } + 1705 + { + arrow = 1; + title = "Hoop (Generic)"; + sprite = "HOOPA0"; + width = 80; + height = 160; + unflippable = true; + centerHitbox = true; + flagsvaluetext = "Height"; + angletext = "Pitch/Yaw"; + } + 1706 + { + title = "Blue Sphere"; + sprite = "SPHRA0"; + width = 16; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + unflippable = true; + } + 1707 + { + title = "Super Paraloop"; + sprite = "NPRUA0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1708 + { + title = "Drill Refill"; + sprite = "NPRUB0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1709 + { + title = "Nightopian Helper"; + sprite = "NPRUC0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1711 + { + title = "Extra Time"; + sprite = "NPRUD0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1712 + { + title = "Link Freeze"; + sprite = "NPRUE0"; + flags4text = "[4] Bonus time only"; + flags8text = "[8] Spawn immediately"; + } + 1713 + { + arrow = 1; + title = "Hoop (Customizable)"; + flags1text = "[1] Radius +16"; + flags2text = "[2] Radius +32"; + flags4text = "[4] Radius +64"; + flags8text = "[8] Radius +128"; + sprite = "HOOPA0"; + width = 80; + height = 160; + unflippable = true; + centerHitbox = true; + } + 1714 + { + title = "Ideya Anchor Point"; + sprite = "internal:axis1"; + width = 8; + height = 16; + parametertext = "Ideya"; + } + } + + mario + { + color = 6; // Brown + title = "Mario"; + + 1800 + { + title = "Coin"; + sprite = "COINA0"; + width = 16; + height = 24; + flags8height = 24; + flags8text = "[8] Float"; + } + 1801 + { + arrow = 1; + title = "Goomba"; + sprite = "GOOMA0"; + width = 24; + height = 32; + } + 1802 + { + arrow = 1; + title = "Goomba (Blue)"; + sprite = "BGOMA0"; + width = 24; + height = 32; + } + 1803 + { + title = "Fire Flower"; + sprite = "FFWRB0"; + width = 16; + height = 32; + } + 1804 + { + title = "Koopa Shell"; + sprite = "SHLLA1"; + width = 16; + height = 20; + } + 1805 + { + title = "Puma (Jumping Fireball)"; + sprite = "PUMAA0"; + width = 8; + height = 16; + angletext = "Jump strength"; + } + 1806 + { + title = "King Bowser"; + sprite = "KOOPA0"; + width = 16; + height = 48; + } + 1807 + { + title = "Axe"; + sprite = "MAXEA0"; + width = 8; + height = 16; + } + 1808 + { + title = "Bush (Short)"; + sprite = "MUS1A0"; + width = 16; + height = 32; + } + 1809 + { + title = "Bush (Tall)"; + sprite = "MUS2A0"; + width = 16; + height = 32; + } + 1810 + { + title = "Toad"; + sprite = "TOADA0"; + width = 8; + height = 32; + } + } + + christmasdisco + { + color = 10; // Green + title = "Christmas & Disco"; + + 1850 + { + title = "Christmas Pole"; + sprite = "XMS1A0"; + width = 16; + height = 40; + } + 1851 + { + title = "Candy Cane"; + sprite = "XMS2A0"; + width = 8; + height = 32; + } + 1852 + { + blocking = 2; + title = "Snowman"; + sprite = "XMS3A0"; + width = 16; + height = 64; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1853 + { + blocking = 2; + title = "Snowman (With Hat)"; + sprite = "XMS3B0"; + width = 16; + height = 80; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + 1854 + { + title = "Lamp Post"; + sprite = "XMS4A0"; + width = 8; + height = 120; + } + 1855 + { + title = "Lamp Post (Snow)"; + sprite = "XMS4B0"; + width = 8; + height = 120; + } + 1856 + { + title = "Hanging Star"; + sprite = "XMS5A0"; + width = 4; + height = 80; + hangs = 1; + } + 1857 + { + title = "Berry Bush (Snow)"; + sprite = "BUS1B0"; + width = 16; + height = 32; + } + 1858 + { + title = "Bush (Snow)"; + sprite = "BUS2B0"; + width = 16; + height = 32; + } + 1859 + { + title = "Blueberry Bush (Snow)"; + sprite = "BUS3B0"; + width = 16; + height = 32; + } + 1875 + { + title = "Disco Ball"; + sprite = "DBALA0"; + width = 16; + height = 54; + hangs = 1; + } + 1876 + { + arrow = 1; + blocking = 2; + title = "Eggman Disco Statue"; + sprite = "ESTAB1"; + width = 20; + height = 96; + flags4text = "[4] Slides when pushed"; + flags8text = "[8] Not pushable"; + } + } + + stalagmites + { + color = 10; // Green + title = "Stalagmites"; + width = 16; + height = 40; + + 1900 + { + title = "Brown Stalagmite (Tall)"; + sprite = "STLGA0"; + width = 16; + height = 40; + } + 1901 + { + title = "Brown Stalagmite"; + sprite = "STLGB0"; + width = 16; + height = 40; + } + 1902 + { + title = "Orange Stalagmite (Tall)"; + sprite = "STLGC0"; + width = 16; + height = 40; + } + 1903 + { + title = "Orange Stalagmite"; + sprite = "STLGD0"; + width = 16; + height = 40; + } + 1904 + { + title = "Red Stalagmite (Tall)"; + sprite = "STLGE0"; + width = 16; + height = 40; + } + 1905 + { + title = "Red Stalagmite"; + sprite = "STLGF0"; + width = 16; + height = 40; + } + 1906 + { + title = "Gray Stalagmite (Tall)"; + sprite = "STLGG0"; + width = 24; + height = 96; + } + 1907 + { + title = "Gray Stalagmite"; + sprite = "STLGH0"; + width = 16; + height = 40; + } + 1908 + { + title = "Blue Stalagmite (Tall)"; + sprite = "STLGI0"; + width = 16; + height = 40; + } + 1909 + { + title = "Blue Stalagmite"; + sprite = "STLGJ0"; + width = 16; + height = 40; + } + } + + hauntedheights + { + color = 10; // Green + title = "Haunted Heights"; + + 2000 + { + title = "Smashing Spikeball"; + sprite = "FMCEA0"; + width = 18; + height = 28; + angletext = "Initial delay"; + } + 2001 + { + title = "HHZ Grass"; + sprite = "HHZMA0"; + width = 16; + height = 40; + } + 2002 + { + title = "HHZ Tentacle 1"; + sprite = "HHZMB0"; + width = 16; + height = 40; + } + 2003 + { + title = "HHZ Tentacle 2"; + sprite = "HHZMC0"; + width = 16; + height = 40; + } + 2004 + { + title = "HHZ Stalagmite (Tall)"; + sprite = "HHZME0"; + width = 16; + height = 40; + } + 2005 + { + title = "HHZ Stalagmite (Short)"; + sprite = "HHZMF0"; + width = 16; + height = 40; + } + 2006 + { + title = "Jack-o'-lantern 1"; + sprite = "PUMKA0"; + width = 16; + height = 40; + flags1text = "Don't flicker"; + } + 2007 + { + title = "Jack-o'-lantern 2"; + sprite = "PUMKB0"; + width = 16; + height = 40; + flags1text = "Don't flicker"; + } + 2008 + { + title = "Jack-o'-lantern 3"; + sprite = "PUMKC0"; + width = 16; + height = 40; + flags1text = "Don't flicker"; + } + 2009 + { + title = "Purple Mushroom"; + sprite = "SHRMD0"; + width = 16; + height = 48; + } + 2010 + { + title = "HHZ Tree"; + sprite = "HHPLC0"; + width = 12; + height = 40; + } + } + + frozenhillside + { + color = 10; // Green + title = "Frozen Hillside"; + + 2100 + { + title = "Ice Shard (Small)"; + sprite = "FHZIA0"; + width = 8; + height = 32; + } + 2101 + { + title = "Ice Shard (Large)"; + sprite = "FHZIB0"; + width = 8; + height = 32; + } + 2102 + { + title = "Crystal Tree (Aqua)"; + sprite = "TRE3A0"; + width = 20; + height = 200; + } + 2103 + { + title = "Crystal Tree (Pink)"; + sprite = "TRE3B0"; + width = 20; + height = 200; + } + 2104 + { + title = "Amy Cameo"; + sprite = "ROSYA1"; + width = 16; + height = 48; + flags1text = "[1] Grayscale mode"; + } + 2105 + { + title = "Mistletoe"; + sprite = "XMS6A0"; + width = 52; + height = 106; + } + } + + flickies + { + color = 10; // Green + title = "Flickies"; + width = 8; + height = 20; + flags1text = "[1] Move aimlessly"; + flags4text = "[4] No movement"; + flags8text = "[8] Hop"; + angletext = "Radius"; + + 2200 + { + title = "Bluebird"; + sprite = "FL01A1"; + } + 2201 + { + title = "Rabbit"; + sprite = "FL02A1"; + } + 2202 + { + title = "Chicken"; + sprite = "FL03A1"; + } + 2203 + { + title = "Seal"; + sprite = "FL04A1"; + } + 2204 + { + title = "Pig"; + sprite = "FL05A1"; + } + 2205 + { + title = "Chipmunk"; + sprite = "FL06A1"; + } + 2206 + { + title = "Penguin"; + sprite = "FL07A1"; + } + 2207 + { + title = "Fish"; + sprite = "FL08A1"; + parametertext = "Color"; + } + 2208 + { + title = "Ram"; + sprite = "FL09A1"; + } + 2209 + { + title = "Puffin"; + sprite = "FL10A1"; + } + 2210 + { + title = "Cow"; + sprite = "FL11A1"; + } + 2211 + { + title = "Rat"; + sprite = "FL12A1"; + } + 2212 + { + title = "Bear"; + sprite = "FL13A1"; + } + 2213 + { + title = "Dove"; + sprite = "FL14A1"; + } + 2214 + { + title = "Cat"; + sprite = "FL15A1"; + } + 2215 + { + title = "Canary"; + sprite = "FL16A1"; + } + 2216 + { + title = "Spider"; + sprite = "FS01A1"; + } + 2217 + { + title = "Bat"; + sprite = "FS02A0"; + } + } +} + +//Default things filters +thingsfilters +{ + + filter0 + { + name = "Player starts"; + category = "starts"; + type = -1; + } + + + filter1 + { + name = "Enemies"; + category = "enemies"; + type = -1; + + } + + + filter2 + { + name = "NiGHTS Track"; + category = "nightstrk"; + type = -1; + + } + + + filter3 + { + name = "Normal Gravity"; + category = ""; + type = -1; + + fields + { + 2 = false; + } + + } + + + filter4 + { + name = "Reverse Gravity"; + category = ""; + type = -1; + + fields + { + 2 = true; + } + + } +} diff --git a/extras/conf/SRB2_22Doom.cfg b/extras/conf/SRB2_22Doom.cfg new file mode 100644 index 000000000..65e49d387 --- /dev/null +++ b/extras/conf/SRB2_22Doom.cfg @@ -0,0 +1,38 @@ +/************************************************************************\ + Zone Builder Game Configuration for Sonic Robo Blast 2 Version 2.2 +\************************************************************************/ + +// This is required to prevent accidental use of a different configuration +type = "Doom Builder 2 Game Configuration"; + +// This is the title to show for this game +game = "Sonic Robo Blast 2 - 2.2 (Doom format)"; + +// This is the simplified game engine/sourceport name +engine = "zdoom"; + +// Settings common to all games and all map formats +include("Includes\\SRB222_common.cfg", "common"); + +// Settings common to Doom map format +include("Includes\\SRB222_common.cfg", "mapformat_doom"); + +include("Includes\\Game_SRB222.cfg"); + +// Script lumps detection +scriptlumpnames +{ + include("Includes\\SRB222_misc.cfg", "scriptlumpnames"); +} + +// THING TYPES +thingtypes +{ + include("Includes\\SRB222_things.cfg"); +} + +//Default things filters +thingsfilters +{ + include("Includes\\SRB222_misc.cfg", "thingsfilters"); +} \ No newline at end of file diff --git a/extras/conf/SRB2_22UDMF.cfg b/extras/conf/SRB2_22UDMF.cfg new file mode 100644 index 000000000..52104ed09 --- /dev/null +++ b/extras/conf/SRB2_22UDMF.cfg @@ -0,0 +1,47 @@ +/************************************************************************\ + Zone Builder Game Configuration for Sonic Robo Blast 2 Version 2.2 +\************************************************************************/ + +// This is required to prevent accidental use of a different configuration +type = "Doom Builder 2 Game Configuration"; + +// This is the title to show for this game +game = "Sonic Robo Blast 2 - 2.2 (UDMF)"; + +// This is the simplified game engine/sourceport name +engine = "zdoom"; + +// Settings common to all games and all map formats +include("Includes\\SRB222_common.cfg", "common"); + +// Settings common to Doom map format +include("Includes\\SRB222_common.cfg", "mapformat_udmf"); + +include("Includes\\Game_SRB222.cfg"); + +// Script lumps detection +scriptlumpnames +{ + include("Includes\\SRB222_misc.cfg", "scriptlumpnames"); +} + +// THING TYPES +thingtypes +{ + include("Includes\\SRB222_things.cfg"); +} + +//Default things filters +thingsfilters +{ + include("Includes\\SRB222_misc.cfg", "thingsfilters"); +} + +// ENUMERATIONS +// Each engine has its own additional thing types +// These are enumerated lists for linedef types and UDMF fields. +enums +{ + // Basic game enums + include("Includes\\SRB222_misc.cfg", "enums"); +} \ No newline at end of file diff --git a/libs/DLL-README.txt b/libs/DLL-README.txt index 058ec0685..7a288887e 100644 --- a/libs/DLL-README.txt +++ b/libs/DLL-README.txt @@ -1,12 +1,13 @@ # SRB2 - Which DLLs do I need to bundle? -Updated 12/4/2018 (v2.1.21) +Updated 12/6/2019 (v2.2) Here are the required DLLs, per build. For each architecture, copy all the binaries from these folders: * libs\dll-binaries\[i686/x86_64] * libs\SDL2\[i686/x86_64]...\bin -* libs\SDL2_mixer\[i686/x86_64]...\bin +* libs\SDL2mixerX\[i686/x86_64]...\bin +* libs\libopenmpt\[x86/x86_64]...\bin\mingw and don't forget to build r_opengl.dll for srb2dd. @@ -16,7 +17,8 @@ and don't forget to build r_opengl.dll for srb2dd. * libs\dll-binaries\i686\libgme.dll * libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll) * libs\SDL2\i686-w64-mingw32\bin\SDL2.dll -* libs\SDL2_mixer\i686-w64-mingw32\bin\*.dll (get everything) +* libs\SDL2mixerX\i686-w64-mingw32\bin\*.dll (get everything) +* libs\libopenmpt\x86\bin\mingw\libopenmpt.dll ## srb2win, 64-bit @@ -24,20 +26,5 @@ and don't forget to build r_opengl.dll for srb2dd. * libs\dll-binaries\x86_64\libgme.dll * libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll) * libs\SDL2\x86_64-w64-mingw32\bin\SDL2.dll -* libs\SDL2_mixer\x86_64-w64-mingw32\bin\*.dll (get everything) - -## srb2dd, 32-bit - -* libs\dll-binaries\i686\exchndl.dll -* libs\dll-binaries\i686\fmodex.dll -* libs\dll-binaries\i686\libgme.dll -* libs\dll-binaries\i686\mgwhelp.dll (depend for exchndl.dll) -* r_opengl.dll (build this from make) - -## srb2dd, 64-bit - -* libs\dll-binaries\x86_64\exchndl.dll -* libs\dll-binaries\x86_64\fmodex.dll -* libs\dll-binaries\x86_64\libgme.dll -* libs\dll-binaries\x86_64\mgwhelp.dll (depend for exchndl.dll) -* r_opengl.dll (build this from make) +* libs\SDL2mixerX\x86_64-w64-mingw32\bin\*.dll (get everything) +* libs\libopenmpt\x86_64\bin\mingw\libopenmpt.dll diff --git a/libs/SDL2/COPYING.txt b/libs/SDL2/COPYING.txt index 694e58a09..9cdb5f8bb 100644 --- a/libs/SDL2/COPYING.txt +++ b/libs/SDL2/COPYING.txt @@ -1,6 +1,6 @@ Simple DirectMedia Layer -Copyright (C) 1997-2018 Sam Lantinga +Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/WhatsNew.txt b/libs/SDL2/WhatsNew.txt index 9074b12ba..7f305012f 100644 --- a/libs/SDL2/WhatsNew.txt +++ b/libs/SDL2/WhatsNew.txt @@ -1,6 +1,38 @@ This is a list of major changes in SDL's version history. +--------------------------------------------------------------------------- +2.0.10: +--------------------------------------------------------------------------- + +General: +* The SDL_RW* macros have been turned into functions that are available only in 2.0.10 and onward +* Added SDL_SIMDGetAlignment(), SDL_SIMDAlloc(), and SDL_SIMDFree(), to allocate memory aligned for SIMD operations for the current CPU +* Added SDL_RenderDrawPointF(), SDL_RenderDrawPointsF(), SDL_RenderDrawLineF(), SDL_RenderDrawLinesF(), SDL_RenderDrawRectF(), SDL_RenderDrawRectsF(), SDL_RenderFillRectF(), SDL_RenderFillRectsF(), SDL_RenderCopyF(), SDL_RenderCopyExF(), to allow floating point precision in the SDL rendering API. +* Added SDL_GetTouchDeviceType() to get the type of a touch device, which can be a touch screen or a trackpad in relative or absolute coordinate mode. +* The SDL rendering API now uses batched rendering by default, for improved performance +* Added SDL_RenderFlush() to force batched render commands to execute, if you're going to mix SDL rendering with native rendering +* Added the hint SDL_HINT_RENDER_BATCHING to control whether batching should be used for the rendering API. This defaults to "1" if you don't specify what rendering driver to use when creating the renderer. +* Added the hint SDL_HINT_EVENT_LOGGING to enable logging of SDL events for debugging purposes +* Added the hint SDL_HINT_GAMECONTROLLERCONFIG_FILE to specify a file that will be loaded at joystick initialization with game controller bindings +* Added the hint SDL_HINT_MOUSE_TOUCH_EVENTS to control whether SDL will synthesize touch events from mouse events +* Improved handling of malformed WAVE and BMP files, fixing potential security exploits + +Linux: +* Removed the Mir video driver in favor of Wayland + +iOS / tvOS: +* Added support for Xbox and PS4 wireless controllers in iOS 13 and tvOS 13 +* Added support for text input using Bluetooth keyboards + +Android: +* Added low latency audio using OpenSL ES +* Removed SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH (replaced by SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS) + SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH=1, should be replaced by setting both previous hints to 0. + SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH=0, should be replaced by setting both previous hints to 1. +* Added the hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE to set whether the event loop will block itself when the app is paused. + + --------------------------------------------------------------------------- 2.0.9: --------------------------------------------------------------------------- diff --git a/libs/SDL2/docs/README-android.md b/libs/SDL2/docs/README-android.md index 7f3263dc3..9893dfeaf 100644 --- a/libs/SDL2/docs/README-android.md +++ b/libs/SDL2/docs/README-android.md @@ -20,7 +20,7 @@ https://developer.android.com/sdk/index.html Android NDK r15c or later https://developer.android.com/tools/sdk/ndk/index.html -Minimum API level supported by SDL: 14 (Android 4.0.1) +Minimum API level supported by SDL: 16 (Android 4.1) ================================================================================ @@ -174,7 +174,7 @@ http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-a Pause / Resume behaviour ================================================================================ -If SDL is compiled with SDL_ANDROID_BLOCK_ON_PAUSE defined (the default), +If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default), the event loop will block itself when the app is paused (ie, when the user returns to the main Android dashboard). Blocking is better in terms of battery use, and it allows your app to spring back to life instantaneously after resume @@ -380,13 +380,13 @@ https://developer.nvidia.com/tegra-graphics-debugger ================================================================================ - Why is API level 14 the minimum required? + Why is API level 16 the minimum required? ================================================================================ -The latest NDK toolchain doesn't support targeting earlier than API level 14. +The latest NDK toolchain doesn't support targeting earlier than API level 16. As of this writing, according to https://developer.android.com/about/dashboards/index.html -about 99% of the Android devices accessing Google Play support API level 14 or -higher (October 2017). +about 99% of the Android devices accessing Google Play support API level 16 or +higher (January 2018). ================================================================================ @@ -408,6 +408,24 @@ screen each frame. Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html +================================================================================ + Ending your application +================================================================================ + +Two legitimate ways: + +- return from your main() function. Java side will automatically terminate the +Activity by calling Activity.finish(). + +- Android OS can decide to terminate your application by calling onDestroy() +(see Activity life cycle). Your application will receive a SDL_QUIT event you +can handle to save things and quit. + +Don't call exit() as it stops the activity badly. + +NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode +SDLK_AC_BACK, for any purpose. + ================================================================================ Known issues ================================================================================ diff --git a/libs/SDL2/docs/README-linux.md b/libs/SDL2/docs/README-linux.md index 5274c60ef..bb3b1d9a4 100644 --- a/libs/SDL2/docs/README-linux.md +++ b/libs/SDL2/docs/README-linux.md @@ -25,9 +25,6 @@ fcitx-libs-dev libsamplerate0-dev libsndio-dev Ubuntu 16.04+ can also add "libwayland-dev libxkbcommon-dev wayland-protocols" to that command line for Wayland support. -Ubuntu 16.10 can also add "libmirclient-dev libxkbcommon-dev" to that command -line for Mir support. - NOTES: - This includes all the audio targets except arts, because Ubuntu pulled the artsc0-dev package, but in theory SDL still supports it. diff --git a/libs/SDL2/docs/README-macosx.md b/libs/SDL2/docs/README-macosx.md index 18d39518e..2cb80013f 100644 --- a/libs/SDL2/docs/README-macosx.md +++ b/libs/SDL2/docs/README-macosx.md @@ -100,7 +100,7 @@ You should replace EXE_NAME with the name of the executable. APP_NAME is what will be visible to the user in the Finder. Usually it will be the same as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME usually is "TestGame". You might also want to use `@PACKAGE@` to use the package -name as specified in your configure.in file. +name as specified in your configure.ac file. If your project builds more than one application, you will have to do a bit more. For each of your target applications, you need a separate rule. diff --git a/libs/SDL2/docs/README-porting.md b/libs/SDL2/docs/README-porting.md index cf8ef397a..82f35c628 100644 --- a/libs/SDL2/docs/README-porting.md +++ b/libs/SDL2/docs/README-porting.md @@ -13,7 +13,7 @@ There are two basic ways of building SDL at the moment: 1. The "UNIX" way: ./configure; make; make install - If you have a GNUish system, then you might try this. Edit configure.in, + If you have a GNUish system, then you might try this. Edit configure.ac, take a look at the large section labelled: "Set up the configuration based on the host platform!" diff --git a/libs/SDL2/docs/README-winrt.md b/libs/SDL2/docs/README-winrt.md index 35b7e6d87..fe539d83b 100644 --- a/libs/SDL2/docs/README-winrt.md +++ b/libs/SDL2/docs/README-winrt.md @@ -296,7 +296,7 @@ A few files should be included directly in your app's MSVC project, specifically included, mouse-position reporting may fail if and when the cursor is hidden, due to possible bugs/design-oddities in Windows itself.* -To include these files: +To include these files for C/C++ projects: 1. right-click on your project (again, in Visual C++'s Solution Explorer), navigate to "Add", then choose "Existing Item...". @@ -313,11 +313,14 @@ To include these files: 7. change the setting for "Consume Windows Runtime Extension" to "Yes (/ZW)". 8. click the OK button. This will close the dialog. - **NOTE: C++/CX compilation is currently required in at least one file of your app's project. This is to make sure that Visual C++'s linker builds a 'Windows Metadata' file (.winmd) for your app. Not doing so can lead to build errors.** +For non-C++ projects, you will need to call SDL_WinRTRunApp from your language's +main function, and generate SDL2-WinRTResources.res manually by using `rc` via +the Developer Command Prompt and including it as a within the +first block in your Visual Studio project file. ### 6. Add app code and assets ### diff --git a/libs/SDL2/i686-w64-mingw32/bin/SDL2.dll b/libs/SDL2/i686-w64-mingw32/bin/SDL2.dll index 701779044..3673be1ab 100755 Binary files a/libs/SDL2/i686-w64-mingw32/bin/SDL2.dll and b/libs/SDL2/i686-w64-mingw32/bin/SDL2.dll differ diff --git a/libs/SDL2/i686-w64-mingw32/bin/sdl2-config b/libs/SDL2/i686-w64-mingw32/bin/sdl2-config index e1060b3f2..18acfa7f7 100755 --- a/libs/SDL2/i686-w64-mingw32/bin/sdl2-config +++ b/libs/SDL2/i686-w64-mingw32/bin/sdl2-config @@ -39,7 +39,7 @@ while test $# -gt 0; do echo $exec_prefix ;; --version) - echo 2.0.9 + echo 2.0.10 ;; --cflags) echo -I${prefix}/include/SDL2 -Dmain=SDL_main @@ -49,7 +49,7 @@ while test $# -gt 0; do ;; --static-libs) # --libs|--static-libs) - echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc + echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc ;; *) echo "${usage}" 1>&2 diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL.h index fc35a419e..88dce0c03 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_assert.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_assert.h index b38f928ae..8baecb63e 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_assert.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_atomic.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_atomic.h index b2287748c..deee35f91 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_atomic.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_atomic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -162,12 +162,29 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__GNUC__) && defined(__arm__) -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) +#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ +/* Information from: + https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 + + The Linux kernel provides a helper function which provides the right code for a memory barrier, + hard-coded at address 0xffff0fa0 +*/ +typedef void (*SDL_KernelMemoryBarrierFunc)(); +#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#elif 0 /* defined(__QNXNTO__) */ +#include + +#define SDL_MemoryBarrierRelease() __cpu_membarrier() +#define SDL_MemoryBarrierAcquire() __cpu_membarrier() +#else +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) #ifdef __thumb__ /* The mcr instruction isn't available in thumb mode, use real functions */ +#define SDL_MEMORY_BARRIER_USES_FUNCTION #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() #else @@ -177,6 +194,7 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #else #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __LINUX__ || __ANDROID__ */ #endif /* __GNUC__ && __arm__ */ #else #if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_audio.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_audio.h index d3e1bface..305c01a9d 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_audio.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -420,23 +420,56 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, /* @} *//* Pause audio functions */ /** - * This function loads a WAVE from the data source, automatically freeing - * that source if \c freesrc is non-zero. For example, to load a WAVE file, - * you could do: + * \brief Load the audio data of a WAVE file into memory + * + * Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len + * to be valid pointers. The entire data portion of the file is then loaded + * into memory and decoded if necessary. + * + * If \c freesrc is non-zero, the data source gets automatically closed and + * freed before the function returns. + * + * Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), + * IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and + * µ-law (8 bits). Other formats are currently unsupported and cause an error. + * + * If this function succeeds, the pointer returned by it is equal to \c spec + * and the pointer to the audio data allocated by the function is written to + * \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec + * members \c freq, \c channels, and \c format are set to the values of the + * audio data in the buffer. The \c samples member is set to a sane default and + * all others are set to zero. + * + * It's necessary to use SDL_FreeWAV() to free the audio data returned in + * \c audio_buf when it is no longer used. + * + * Because of the underspecification of the Waveform format, there are many + * problematic files in the wild that cause issues with strict decoders. To + * provide compatibility with these files, this decoder is lenient in regards + * to the truncation of the file, the fact chunk, and the size of the RIFF + * chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, + * and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the + * loading process. + * + * Any file that is invalid (due to truncation, corruption, or wrong values in + * the headers), too big, or unsupported causes an error. Additionally, any + * critical I/O error from the data source will terminate the loading process + * with an error. The function returns NULL on error and in all cases (with the + * exception of \c src being NULL), an appropriate error message will be set. + * + * It is required that the data source supports seeking. + * + * Example: * \code * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); * \endcode * - * If this function succeeds, it returns the given SDL_AudioSpec, - * filled with the audio data format of the wave data, and sets - * \c *audio_buf to a malloc()'d buffer containing the audio data, - * and sets \c *audio_len to the length of that audio buffer, in bytes. - * You need to free the audio buffer with SDL_FreeWAV() when you are - * done with it. - * - * This function returns NULL and sets the SDL error message if the - * wave file cannot be opened, uses an unknown data format, or is - * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + * \param src The data source with the WAVE data + * \param freesrc A integer value that makes the function close the data source if non-zero + * \param spec A pointer filled with the audio format of the audio data + * \param audio_buf A pointer filled with the audio data allocated by the function + * \param audio_len A pointer filled with the length of the audio data buffer in bytes + * \return NULL on error, or non-NULL on success. */ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_bits.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_bits.h index eb8322f0d..b116cc8d0 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_bits.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -101,6 +101,15 @@ SDL_MostSignificantBitIndex32(Uint32 x) #endif } +SDL_FORCE_INLINE SDL_bool +SDL_HasExactlyOneBitSet32(Uint32 x) +{ + if (x && !(x & (x - 1))) { + return SDL_TRUE; + } + return SDL_FALSE; +} + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_blendmode.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_blendmode.h index 36a5ea76f..6f0a22b99 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_blendmode.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_blendmode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -90,12 +90,12 @@ typedef enum /** * \brief Create a custom blend mode, which may or may not be supported by a given renderer * - * \param srcColorFactor - * \param dstColorFactor - * \param colorOperation - * \param srcAlphaFactor - * \param dstAlphaFactor - * \param alphaOperation + * \param srcColorFactor source color factor + * \param dstColorFactor destination color factor + * \param colorOperation color operation + * \param srcAlphaFactor source alpha factor + * \param dstAlphaFactor destination alpha factor + * \param alphaOperation alpha operation * * The result of the blend mode operation will be: * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_clipboard.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_clipboard.h index f28751ebb..c4f8766ce 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_clipboard.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_config.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_config.h index c58be8e72..395ad7c26 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_config.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_config.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_cpuinfo.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_cpuinfo.h index ee3a47e84..296df01aa 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_cpuinfo.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_cpuinfo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -41,24 +41,43 @@ #else #include #ifndef _WIN64 +#ifndef __MMX__ #define __MMX__ +#endif +#ifndef __3dNOW__ #define __3dNOW__ #endif +#endif +#ifndef __SSE__ #define __SSE__ +#endif +#ifndef __SSE2__ #define __SSE2__ +#endif #endif /* __clang__ */ #elif defined(__MINGW64_VERSION_MAJOR) #include #else -#ifdef __ALTIVEC__ -#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H) +/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ +#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) #include -#undef pixel -#undef bool #endif -#endif -#if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H) -#include +#if !defined(SDL_DISABLE_ARM_NEON_H) +# if defined(__ARM_NEON) +# include +# elif defined(__WINDOWS__) || defined(__WINRT__) +/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ +# if defined(_M_ARM) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# if defined (_M_ARM64) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# endif #endif #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) #include @@ -177,6 +196,69 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); */ extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); +/** + * \brief Report the alignment this system needs for SIMD allocations. + * + * This will return the minimum number of bytes to which a pointer must be + * aligned to be compatible with SIMD instructions on the current machine. + * For example, if the machine supports SSE only, it will return 16, but if + * it supports AVX-512F, it'll return 64 (etc). This only reports values for + * instruction sets SDL knows about, so if your SDL build doesn't have + * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and + * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. + * Plan accordingly. + */ +extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); + +/** + * \brief Allocate memory in a SIMD-friendly way. + * + * This will allocate a block of memory that is suitable for use with SIMD + * instructions. Specifically, it will be properly aligned and padded for + * the system's supported vector instructions. + * + * The memory returned will be padded such that it is safe to read or write + * an incomplete vector at the end of the memory block. This can be useful + * so you don't have to drop back to a scalar fallback at the end of your + * SIMD processing loop to deal with the final elements without overflowing + * the allocated buffer. + * + * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() + * or delete[], etc. + * + * Note that SDL will only deal with SIMD instruction sets it is aware of; + * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors + * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't + * know that AVX-512 wants 64. To be clear: if you can't decide to use an + * instruction set with an SDL_Has*() function, don't use that instruction + * set with memory allocated through here. + * + * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't + * out of memory. + * + * \param len The length, in bytes, of the block to allocated. The actual + * allocated block might be larger due to padding, etc. + * \return Pointer to newly-allocated block, NULL if out of memory. + * + * \sa SDL_SIMDAlignment + * \sa SDL_SIMDFree + */ +extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); + +/** + * \brief Deallocate memory obtained from SDL_SIMDAlloc + * + * It is not valid to use this function on a pointer from anything but + * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, + * SDL_malloc, memalign, new[], etc. + * + * However, SDL_SIMDFree(NULL) is a legal no-op. + * + * \sa SDL_SIMDAlloc + */ +extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); + +/* vi: set ts=4 sw=4 expandtab: */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_egl.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_egl.h index d65ed437c..f50fa5c9b 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_egl.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_egl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_endian.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_endian.h index ed0bf5ba8..54d5d486d 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_endian.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_endian.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_error.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_error.h index c0e46298e..24416e693 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_error.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_error.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_events.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_events.h index af22eb646..282b9fb76 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_events.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -594,6 +594,9 @@ typedef union SDL_Event Uint8 padding[56]; } SDL_Event; +/* Make sure we haven't broken binary compatibility */ +SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); + /* Function prototypes */ diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_filesystem.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_filesystem.h index fa6a1fa6e..6d97e5896 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_filesystem.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_filesystem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gamecontroller.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gamecontroller.h index 6ae9c9542..ebde38715 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gamecontroller.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gamecontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gesture.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gesture.h index b223d80d4..9d25e9c1d 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gesture.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gesture.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_haptic.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_haptic.h index 2ea1bfc16..075627685 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_haptic.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_haptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hints.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hints.h index 4ee72e97d..8fa0dd660 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hints.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hints.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -315,6 +315,16 @@ extern "C" { */ #define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" +/** + * \brief A variable controlling whether mouse events should generate synthetic touch events + * + * This variable can be set to the following values: + * "0" - Mouse events will not generate touch events (default for desktop platforms) + * "1" - Mouse events will generate touch events (default for mobile platforms, such as Android and iOS) + */ + +#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" + /** * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. * @@ -436,6 +446,16 @@ extern "C" { */ #define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" +/** + * \brief A variable that lets you provide a file with extra gamecontroller db entries. + * + * The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" + /** * \brief A variable containing a list of devices to skip when scanning for game controllers. * @@ -836,19 +856,7 @@ extern "C" { */ #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" - /** - * \brief A variable to control whether mouse and touch events are to be treated together or separately - * - * The variable can be set to the following values: - * "0" - Mouse events will be handled as touch events, and touch will raise fake mouse - * events. This is the behaviour of SDL <= 2.0.3. (default) - * "1" - Mouse events will be handled separately from pure touch events. - * - * The value of this hint is used at runtime, so it can be changed at any time. - */ -#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH" - - /** +/** * \brief A variable to control whether we trap the Android back button to handle it manually. * This is necessary for the right mouse button to work on some Android devices, or * to be able to trap the back button for use in your code reliably. If set to true, @@ -865,6 +873,17 @@ extern "C" { */ #define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" +/** + * \brief A variable to control whether the event loop will block itself when the app is paused. + * + * The variable can be set to the following values: + * "0" - Non blocking. + * "1" - Blocking. (default) + * + * The value should be set before SDL is initialized. + */ +#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" + /** * \brief A variable to control whether the return key on the soft keyboard * should hide the soft keyboard on Android and iOS. @@ -1043,6 +1062,118 @@ extern "C" { */ #define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" +/** + * \brief A variable controlling whether the 2D render API is compatible or efficient. + * + * This variable can be set to the following values: + * + * "0" - Don't use batching to make rendering more efficient. + * "1" - Use batching, but might cause problems if app makes its own direct OpenGL calls. + * + * Up to SDL 2.0.9, the render API would draw immediately when requested. Now + * it batches up draw requests and sends them all to the GPU only when forced + * to (during SDL_RenderPresent, when changing render targets, by updating a + * texture that the batch needs, etc). This is significantly more efficient, + * but it can cause problems for apps that expect to render on top of the + * render API's output. As such, SDL will disable batching if a specific + * render backend is requested (since this might indicate that the app is + * planning to use the underlying graphics API directly). This hint can + * be used to explicitly request batching in this instance. It is a contract + * that you will either never use the underlying graphics API directly, or + * if you do, you will call SDL_RenderFlush() before you do so any current + * batch goes to the GPU before your work begins. Not following this contract + * will result in undefined behavior. + */ +#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING" + + +/** + * \brief A variable controlling whether SDL logs all events pushed onto its internal queue. + * + * This variable can be set to the following values: + * + * "0" - Don't log any events (default) + * "1" - Log all events except mouse and finger motion, which are pretty spammy. + * "2" - Log all events. + * + * This is generally meant to be used to debug SDL itself, but can be useful + * for application developers that need better visibility into what is going + * on in the event queue. Logged events are sent through SDL_Log(), which + * means by default they appear on stdout on most platforms or maybe + * OutputDebugString() on Windows, and can be funneled by the app with + * SDL_LogSetOutputFunction(), etc. + * + * This hint can be toggled on and off at runtime, if you only need to log + * events for a small subset of program execution. + */ +#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" + + + +/** + * \brief Controls how the size of the RIFF chunk affects the loading of a WAVE file. + * + * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE + * file) is not always reliable. In case the size is wrong, it's possible to + * just ignore it and step through the chunks until a fixed limit is reached. + * + * Note that files that have trailing data unrelated to the WAVE file or + * corrupt files may slow down the loading process without a reliable boundary. + * By default, SDL stops after 10000 chunks to prevent wasting time. Use the + * environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value. + * + * This variable can be set to the following values: + * + * "force" - Always use the RIFF chunk size as a boundary for the chunk search + * "ignorezero" - Like "force", but a zero size searches up to 4 GiB (default) + * "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB + * "maximum" - Search for chunks until the end of file (not recommended) + */ +#define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" + +/** + * \brief Controls how a truncated WAVE file is handled. + * + * A WAVE file is considered truncated if any of the chunks are incomplete or + * the data chunk size is not a multiple of the block size. By default, SDL + * decodes until the first incomplete block, as most applications seem to do. + * + * This variable can be set to the following values: + * + * "verystrict" - Raise an error if the file is truncated + * "strict" - Like "verystrict", but the size of the RIFF chunk is ignored + * "dropframe" - Decode until the first incomplete sample frame + * "dropblock" - Decode until the first incomplete block (default) + */ +#define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" + +/** + * \brief Controls how the fact chunk affects the loading of a WAVE file. + * + * The fact chunk stores information about the number of samples of a WAVE + * file. The Standards Update from Microsoft notes that this value can be used + * to 'determine the length of the data in seconds'. This is especially useful + * for compressed formats (for which this is a mandatory chunk) if they produce + * multiple sample frames per block and truncating the block is not allowed. + * The fact chunk can exactly specify how many sample frames there should be + * in this case. + * + * Unfortunately, most application seem to ignore the fact chunk and so SDL + * ignores it by default as well. + * + * This variable can be set to the following values: + * + * "truncate" - Use the number of samples to truncate the wave data if + * the fact chunk is present and valid + * "strict" - Like "truncate", but raise an error if the fact chunk + * is invalid, not present for non-PCM formats, or if the + * data chunk doesn't have that many samples + * "ignorezero" - Like "truncate", but ignore fact chunk if the number of + * samples is zero + * "ignore" - Ignore fact chunk entirely (default) + */ +#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" + /** * \brief An enumeration of hint priorities */ diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_joystick.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_joystick.h index 6e05a9c20..3a4c5d177 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_joystick.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_joystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keyboard.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keyboard.h index 874823171..4b2a055d8 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keyboard.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keycode.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keycode.h index d7d5b1dbc..3bceb418a 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keycode.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keycode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_loadso.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_loadso.h index da56fb452..793ba5358 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_loadso.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_loadso.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_log.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_log.h index e12b65886..40f768d57 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_log.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_main.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_main.h index 98558217f..623f2d005 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_main.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_main.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -55,6 +55,10 @@ /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. + If you link with SDL dynamically on iOS, the main function can't be in a + shared library, so you need to link with libSDLmain.a, which includes a + stub main function that calls into the shared library to start execution. + See src/video/uikit/SDL_uikitappdelegate.m for more details. */ #define SDL_MAIN_NEEDED @@ -82,12 +86,6 @@ #endif #endif /* SDL_MAIN_HANDLED */ -#ifdef __cplusplus -#define C_LINKAGE "C" -#else -#define C_LINKAGE -#endif /* __cplusplus */ - #ifndef SDLMAIN_DECLSPEC #define SDLMAIN_DECLSPEC #endif @@ -111,17 +109,18 @@ #define main SDL_main #endif -/** - * The prototype for the application's main() function - */ -extern C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); - - #include "begin_code.h" #ifdef __cplusplus extern "C" { #endif +/** + * The prototype for the application's main() function + */ +typedef int (*SDL_main_func)(int argc, char *argv[]); +extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); + + /** * This is called by the real SDL main function to let the rest of the * library know that initialization was done properly. @@ -136,8 +135,7 @@ extern DECLSPEC void SDLCALL SDL_SetMainReady(void); /** * This can be called to set the application class at startup */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, - void *hInst); +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #endif /* __WIN32__ */ @@ -153,10 +151,24 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more * information on the failure. */ -extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved); +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved); #endif /* __WINRT__ */ +#if defined(__IPHONEOS__) + +/** + * \brief Initializes and launches an SDL application. + * + * \param argc The argc parameter from the application's main() function + * \param argv The argv parameter from the application's main() function + * \param mainFunction The SDL app's C-style main(). + * \return the return value from mainFunction + */ +extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); + +#endif /* __IPHONEOS__ */ + #ifdef __cplusplus } diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_messagebox.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_messagebox.h index b7be59d88..e34b55477 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_messagebox.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mouse.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mouse.h index d3c9f6156..277559d23 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mouse.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mutex.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mutex.h index ba4247ced..970e78713 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mutex.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mutex.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_name.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_name.h index ecd863f4c..690a8199b 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_name.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_name.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengl.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengl.h index 253d9c93a..6685be73e 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengl.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles.h index 18dd984b3..1e0660c3d 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles2.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles2.h index 6ccecf216..df29d3840 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles2.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_pixels.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_pixels.h index 0b4364b18..dcb7a980d 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_pixels.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_pixels.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -168,7 +168,7 @@ enum ((format) && (SDL_PIXELFLAG(format) != 1)) /* Note: If you modify this list, update SDL_GetPixelFormatName() */ -enum +typedef enum { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB = @@ -290,7 +290,7 @@ enum SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */ SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') -}; +} SDL_PixelFormatEnum; typedef struct SDL_Color { diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_platform.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_platform.h index 7dea4ce94..c2cbc6b4e 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_platform.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_platform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_power.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_power.h index a4fe8a935..4831cb77e 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_power.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_power.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_quit.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_quit.h index fea56a8d8..c979983cb 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_quit.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_quit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rect.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rect.h index 543bb6186..71a411517 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rect.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -40,7 +40,7 @@ extern "C" { #endif /** - * \brief The structure that defines a point + * \brief The structure that defines a point (integer) * * \sa SDL_EnclosePoints * \sa SDL_PointInRect @@ -52,7 +52,20 @@ typedef struct SDL_Point } SDL_Point; /** - * \brief A rectangle, with the origin at the upper left. + * \brief The structure that defines a point (floating point) + * + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect + */ +typedef struct SDL_FPoint +{ + float x; + float y; +} SDL_FPoint; + + +/** + * \brief A rectangle, with the origin at the upper left (integer). * * \sa SDL_RectEmpty * \sa SDL_RectEquals @@ -67,6 +80,19 @@ typedef struct SDL_Rect int w, h; } SDL_Rect; + +/** + * \brief A rectangle, with the origin at the upper left (floating point). + */ +typedef struct SDL_FRect +{ + float x; + float y; + float w; + float h; +} SDL_FRect; + + /** * \brief Returns true if point resides inside a rectangle. */ diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_render.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_render.h index d33619297..096b4a577 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_render.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -835,6 +835,148 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, const SDL_Point *center, const SDL_RendererFlip flip); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, + float x, float y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, + float x1, float y1, float x2, float y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect, + const double angle, + const SDL_FPoint *center, + const SDL_RendererFlip flip); + /** * \brief Read pixels from the current rendering target. * @@ -876,6 +1018,31 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); */ extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); +/** + * \brief Force the rendering context to flush any pending commands to the + * underlying rendering API. + * + * You do not need to (and in fact, shouldn't) call this function unless + * you are planning to call into OpenGL/Direct3D/Metal/whatever directly + * in addition to using an SDL_Renderer. + * + * This is for a very-specific case: if you are using SDL's render API, + * you asked for a specific renderer backend (OpenGL, Direct3D, etc), + * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make + * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of + * this applies, you should call SDL_RenderFlush() between calls to SDL's + * render API and the low-level API you're using in cooperation. + * + * In all other cases, you can ignore this function. This is only here to + * get maximum performance out of a specific situation. In all other cases, + * SDL will do the right thing, perhaps at a performance loss. + * + * This function is first available in SDL 2.0.10, and is not needed in + * 2.0.9 and earlier, as earlier versions did not queue rendering commands + * at all, instead flushing them to the OS immediately. + */ +extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); + /** * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_revision.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_revision.h index 92fbe67b1..3b3fc85ea 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_revision.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_revision.h @@ -1,2 +1,2 @@ -#define SDL_REVISION "hg-12373:8feb5da6f2fb" -#define SDL_REVISION_NUMBER 12373 +#define SDL_REVISION "hg-12952:bc90ce38f1e2" +#define SDL_REVISION_NUMBER 12952 diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rwops.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rwops.h index 0960699d4..f66119fb0 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rwops.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rwops.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -176,19 +176,48 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); #define RW_SEEK_END 2 /**< Seek relative to the end of data */ /** - * \name Read/write macros - * - * Macros to easily read and write from an SDL_RWops structure. + * Return the size of the file in this rwops, or -1 if unknown */ -/* @{ */ -#define SDL_RWsize(ctx) (ctx)->size(ctx) -#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) -#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) -#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) -#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) -#define SDL_RWclose(ctx) (ctx)->close(ctx) -/* @} *//* Read/write macros */ +extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); +/** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, + Sint64 offset, int whence); + +/** + * Return the current offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context); + +/** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, + void *ptr, size_t size, size_t maxnum); + +/** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, + const void *ptr, size_t size, size_t num); + +/** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ +extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context); /** * Load all the data from an SDL data stream. @@ -209,9 +238,17 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, /** * Load an entire file. * - * Convenience macro. + * The data is allocated with a zero byte at the end (null terminated) + * + * If \c datasize is not NULL, it is filled with the size of the data read. + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The data should be freed with SDL_free(). + * + * \return the data, or NULL if there was an error. */ -#define SDL_LoadFile(file, datasize) SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1) +extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); /** * \name Read endian functions diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_scancode.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_scancode.h index 63871aa3b..a50305f55 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_scancode.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_scancode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,7 +38,7 @@ * SDL_Event structure. * * The values in this enumeration are based on the USB usage page standard: - * http://www.usb.org/developers/hidpage/Hut1_12v2.pdf + * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf */ typedef enum { diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_sensor.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_sensor.h index ac163a8cd..966adbf21 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_sensor.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_sensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,8 +26,8 @@ * */ -#ifndef _SDL_sensor_h -#define _SDL_sensor_h +#ifndef SDL_sensor_h_ +#define SDL_sensor_h_ #include "SDL_stdinc.h" #include "SDL_error.h" @@ -246,6 +246,6 @@ extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); #endif #include "close_code.h" -#endif /* _SDL_sensor_h */ +#endif /* SDL_sensor_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_shape.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_shape.h index 40a6baaae..2ab43fcdc 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_shape.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_stdinc.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_stdinc.h index e373bc380..28bb7b961 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_stdinc.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_stdinc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_surface.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_surface.h index 730d49fc8..51a128300 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_surface.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_surface.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -53,6 +53,7 @@ extern "C" { #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +#define SDL_SIMD_ALIGNED 0x00000008 /**< Surface uses aligned memory */ /* @} *//* Surface flags */ /** diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_system.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_system.h index 4dc372d6b..3b0840769 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_system.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_system.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_syswm.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_syswm.h index f1c4021cc..7aa8c6869 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_syswm.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_syswm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -34,16 +34,16 @@ #include "SDL_version.h" /** - * \file SDL_syswm.h + * \brief SDL_syswm.h * * Your application has access to a special type of event ::SDL_SYSWMEVENT, * which contains window-manager specific information and arrives whenever * an unhandled window event occurs. This event is ignored by default, but * you can enable it with SDL_EventState(). */ -#ifdef SDL_PROTOTYPES_ONLY struct SDL_SysWMinfo; -#else + +#if !defined(SDL_PROTOTYPES_ONLY) #if defined(SDL_VIDEO_DRIVER_WINDOWS) #ifndef WIN32_LEAN_AND_MEAN @@ -103,6 +103,8 @@ typedef void *EGLSurface; #if defined(SDL_VIDEO_DRIVER_VIVANTE) #include "SDL_egl.h" #endif +#endif /* SDL_PROTOTYPES_ONLY */ + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -110,6 +112,7 @@ typedef void *EGLSurface; extern "C" { #endif +#if !defined(SDL_PROTOTYPES_ONLY) /** * These are the various supported windowing subsystems */ @@ -122,7 +125,7 @@ typedef enum SDL_SYSWM_COCOA, SDL_SYSWM_UIKIT, SDL_SYSWM_WAYLAND, - SDL_SYSWM_MIR, + SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ SDL_SYSWM_WINRT, SDL_SYSWM_ANDROID, SDL_SYSWM_VIVANTE, @@ -257,11 +260,11 @@ struct SDL_SysWMinfo struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ } wl; #endif -#if defined(SDL_VIDEO_DRIVER_MIR) +#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ struct { - struct MirConnection *connection; /**< Mir display server connection */ - struct MirSurface *surface; /**< Mir surface */ + void *connection; /**< Mir display server connection */ + void *surface; /**< Mir surface */ } mir; #endif diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test.h index 6cc373bf8..17a33dc2c 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_assert.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_assert.h index 1788d7a20..b3ebb62fb 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_assert.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_common.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_common.h index be2e6b2aa..c34d0d103 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_common.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -140,14 +140,20 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); */ int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + /** - * \brief Returns common usage information + * \brief Logs command line usage info. * - * \param state The common state describing the test window to create. + * This logs the appropriate command line options for the subsystems in use + * plus other common options, and then any application-specific options. + * This uses the SDL_Log() function and splits up output to be friendly to + * 80-character-wide terminals. * - * \returns String with usage information + * \param state The common state describing the test window for the app. + * \param argv0 argv[0], as passed to main/SDL_main. + * \param options an array of strings for application specific options. The last element of the array should be NULL. */ -const char *SDLTest_CommonUsage(SDLTest_CommonState * state); +void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options); /** * \brief Open test window. @@ -158,6 +164,17 @@ const char *SDLTest_CommonUsage(SDLTest_CommonState * state); */ SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); +/** + * \brief Easy argument handling when test app doesn't need any custom args. + * + * \param state The common state describing the test window to create. + * \param argc argc, as supplied to SDL_main + * \param argv argv, as supplied to SDL_main + * + * \returns False if app should quit, true otherwise. + */ +SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv); + /** * \brief Common event handler for test windows. * diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_compare.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_compare.h index c22e447d8..1f751c8b9 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_compare.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_compare.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_crc32.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_crc32.h index 3d235d074..e615d8929 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_crc32.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_crc32.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_font.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_font.h index 59cbdcad6..8fa078440 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_font.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_font.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_fuzzer.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_fuzzer.h index 8fcb9ebbf..7259685a9 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_fuzzer.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_fuzzer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_harness.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_harness.h index 8641e0a7e..f5ae92ceb 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_harness.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_harness.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_images.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_images.h index 9c4dd5b82..b8934812f 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_images.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_images.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_log.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_log.h index ebd44fb50..01d0fedac 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_log.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_md5.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_md5.h index 0e4105768..2bfd7dff9 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_md5.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_md5.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_memory.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_memory.h index 4827ae6f2..5d4d39ea5 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_memory.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_memory.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -42,14 +42,14 @@ extern "C" { * * \note This should be called before any other SDL functions for complete tracking coverage */ -int SDLTest_TrackAllocations(); +int SDLTest_TrackAllocations(void); /** * \brief Print a log of any outstanding allocations * * \note This can be called after SDL_Quit() */ -void SDLTest_LogAllocations(); +void SDLTest_LogAllocations(void); /* Ends C function definitions when using C++ */ diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_random.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_random.h index 0eb414ff2..71e9c70b6 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_random.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_random.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_thread.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_thread.h index 554dd0b61..f78b1145d 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_thread.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_thread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_timer.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_timer.h index 5600618ff..2a47b043a 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_timer.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_timer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_touch.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_touch.h index f4075e79a..99dbcb8c3 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_touch.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -41,6 +41,14 @@ extern "C" { typedef Sint64 SDL_TouchID; typedef Sint64 SDL_FingerID; +typedef enum +{ + SDL_TOUCH_DEVICE_INVALID = -1, + SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */ +} SDL_TouchDeviceType; + typedef struct SDL_Finger { SDL_FingerID id; @@ -52,6 +60,9 @@ typedef struct SDL_Finger /* Used as the device ID for mouse events simulated with touch input */ #define SDL_TOUCH_MOUSEID ((Uint32)-1) +/* Used as the SDL_TouchID for touch events simulated with mouse input */ +#define SDL_MOUSE_TOUCHID ((Sint64)-1) + /* Function prototypes */ @@ -65,6 +76,11 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); */ extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); +/** + * \brief Get the type of the given touch device. + */ +extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); + /** * \brief Get the number of active fingers for a given touch device. */ diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_types.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_types.h index 4ac248c8c..9c3e9896f 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_types.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_version.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_version.h index 31443e149..6c7499d32 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_version.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_version.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 9 +#define SDL_PATCHLEVEL 10 /** * \brief Macro to determine SDL version program was compiled against. diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_video.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_video.h index 461f13805..352afd436 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_video.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_vulkan.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_vulkan.h index 972cca4d7..d69a436b3 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_vulkan.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_vulkan.h @@ -98,8 +98,8 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */ * applications to link with libvulkan (and historically MoltenVK was * provided as a static library). If it is not found then, on macOS, SDL * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib, - * \c MoltenVK.framework/MoltenVK and \c libMoltenVK.dylib in that order. - * On iOS SDL will attempt to load \c libMoltenVK.dylib. Applications + * followed by \c libvulkan.dylib, in that order. + * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications * using a dynamic framework or .dylib must ensure it is included in its * application bundle. * @@ -153,7 +153,7 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); * is smaller than the number of required extensions, \c SDL_FALSE will be * returned instead of \c SDL_TRUE, to indicate that not all the required * extensions were returned. - * + * * \note If \c window is not NULL, it will be checked against its creation * flags to ensure that the Vulkan flag is present. This parameter * will be removed in a future major release. diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/begin_code.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/begin_code.h index 6c2106246..22c997c41 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/begin_code.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/begin_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -105,6 +105,9 @@ #ifdef _MSC_VER #pragma warning(disable: 4103) #endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif #ifdef __BORLANDC__ #pragma nopackwarning #endif diff --git a/libs/SDL2/i686-w64-mingw32/include/SDL2/close_code.h b/libs/SDL2/i686-w64-mingw32/include/SDL2/close_code.h index b3b70a4c8..8e4cac3da 100644 --- a/libs/SDL2/i686-w64-mingw32/include/SDL2/close_code.h +++ b/libs/SDL2/i686-w64-mingw32/include/SDL2/close_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,6 +26,9 @@ * after you finish any function and structure declarations in your headers */ +#ifndef _begin_code_h +#error close_code.h included without matching begin_code.h +#endif #undef _begin_code_h /* Reset structure packing at previous byte alignment */ diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2.a b/libs/SDL2/i686-w64-mingw32/lib/libSDL2.a index 05489a95a..bee8366f9 100644 Binary files a/libs/SDL2/i686-w64-mingw32/lib/libSDL2.a and b/libs/SDL2/i686-w64-mingw32/lib/libSDL2.a differ diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2.dll.a b/libs/SDL2/i686-w64-mingw32/lib/libSDL2.dll.a index b20371a13..c74106707 100755 Binary files a/libs/SDL2/i686-w64-mingw32/lib/libSDL2.dll.a and b/libs/SDL2/i686-w64-mingw32/lib/libSDL2.dll.a differ diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2.la b/libs/SDL2/i686-w64-mingw32/lib/libSDL2.la index 3848c7db9..c4caaf3b0 100644 --- a/libs/SDL2/i686-w64-mingw32/lib/libSDL2.la +++ b/libs/SDL2/i686-w64-mingw32/lib/libSDL2.la @@ -23,8 +23,8 @@ dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 - weak_library_names='' # Version information for libSDL2. -current=9 -age=9 +current=10 +age=10 revision=0 # Is this an already installed library? @@ -38,4 +38,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/Users/valve/release/SDL/SDL2-2.0.9/i686-w64-mingw32/lib' +libdir='/Users/valve/release/SDL/SDL2-2.0.10/i686-w64-mingw32/lib' diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.a b/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.a index 190f9e072..997c1d4f5 100644 Binary files a/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.a and b/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.a differ diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.la b/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.la index 5f96235bd..169f37757 100644 --- a/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.la +++ b/libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.la @@ -38,4 +38,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/Users/valve/release/SDL/SDL2-2.0.9/i686-w64-mingw32/lib' +libdir='/Users/valve/release/SDL/SDL2-2.0.10/i686-w64-mingw32/lib' diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.a b/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.a index df7c95b95..aa33741d2 100644 Binary files a/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.a and b/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.a differ diff --git a/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.la b/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.la index d01b8a172..883237adb 100644 --- a/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.la +++ b/libs/SDL2/i686-w64-mingw32/lib/libSDL2main.la @@ -38,4 +38,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/Users/valve/release/SDL/SDL2-2.0.9/i686-w64-mingw32/lib' +libdir='/Users/valve/release/SDL/SDL2-2.0.10/i686-w64-mingw32/lib' diff --git a/libs/SDL2/i686-w64-mingw32/lib/pkgconfig/sdl2.pc b/libs/SDL2/i686-w64-mingw32/lib/pkgconfig/sdl2.pc index 25fc5928e..4e29497c8 100644 --- a/libs/SDL2/i686-w64-mingw32/lib/pkgconfig/sdl2.pc +++ b/libs/SDL2/i686-w64-mingw32/lib/pkgconfig/sdl2.pc @@ -7,9 +7,9 @@ includedir=${prefix}/include Name: sdl2 Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. -Version: 2.0.9 +Version: 2.0.10 Requires: Conflicts: Libs: -L${libdir} -lmingw32 -lSDL2main -lSDL2 -mwindows -Libs.private: -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc +Libs.private: -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc Cflags: -I${includedir}/SDL2 -Dmain=SDL_main diff --git a/libs/SDL2/i686-w64-mingw32/share/aclocal/sdl2.m4 b/libs/SDL2/i686-w64-mingw32/share/aclocal/sdl2.m4 index b915f99ed..0a73bc7d4 100644 --- a/libs/SDL2/i686-w64-mingw32/share/aclocal/sdl2.m4 +++ b/libs/SDL2/i686-w64-mingw32/share/aclocal/sdl2.m4 @@ -74,7 +74,7 @@ AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) done fi - if test -d $sdl_framework; then + if test x"$sdl_framework" != x && test -d "$sdl_framework"; then AC_MSG_RESULT($sdl_framework) sdl_framework_dir=`dirname $sdl_framework` SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" diff --git a/libs/SDL2/include/SDL.h b/libs/SDL2/include/SDL.h index fc35a419e..88dce0c03 100644 --- a/libs/SDL2/include/SDL.h +++ b/libs/SDL2/include/SDL.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_assert.h b/libs/SDL2/include/SDL_assert.h index b38f928ae..8baecb63e 100644 --- a/libs/SDL2/include/SDL_assert.h +++ b/libs/SDL2/include/SDL_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_atomic.h b/libs/SDL2/include/SDL_atomic.h index b2287748c..deee35f91 100644 --- a/libs/SDL2/include/SDL_atomic.h +++ b/libs/SDL2/include/SDL_atomic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -162,12 +162,29 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__GNUC__) && defined(__arm__) -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) +#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ +/* Information from: + https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 + + The Linux kernel provides a helper function which provides the right code for a memory barrier, + hard-coded at address 0xffff0fa0 +*/ +typedef void (*SDL_KernelMemoryBarrierFunc)(); +#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#elif 0 /* defined(__QNXNTO__) */ +#include + +#define SDL_MemoryBarrierRelease() __cpu_membarrier() +#define SDL_MemoryBarrierAcquire() __cpu_membarrier() +#else +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) #ifdef __thumb__ /* The mcr instruction isn't available in thumb mode, use real functions */ +#define SDL_MEMORY_BARRIER_USES_FUNCTION #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() #else @@ -177,6 +194,7 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #else #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __LINUX__ || __ANDROID__ */ #endif /* __GNUC__ && __arm__ */ #else #if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) diff --git a/libs/SDL2/include/SDL_audio.h b/libs/SDL2/include/SDL_audio.h index d3e1bface..305c01a9d 100644 --- a/libs/SDL2/include/SDL_audio.h +++ b/libs/SDL2/include/SDL_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -420,23 +420,56 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, /* @} *//* Pause audio functions */ /** - * This function loads a WAVE from the data source, automatically freeing - * that source if \c freesrc is non-zero. For example, to load a WAVE file, - * you could do: + * \brief Load the audio data of a WAVE file into memory + * + * Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len + * to be valid pointers. The entire data portion of the file is then loaded + * into memory and decoded if necessary. + * + * If \c freesrc is non-zero, the data source gets automatically closed and + * freed before the function returns. + * + * Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), + * IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and + * µ-law (8 bits). Other formats are currently unsupported and cause an error. + * + * If this function succeeds, the pointer returned by it is equal to \c spec + * and the pointer to the audio data allocated by the function is written to + * \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec + * members \c freq, \c channels, and \c format are set to the values of the + * audio data in the buffer. The \c samples member is set to a sane default and + * all others are set to zero. + * + * It's necessary to use SDL_FreeWAV() to free the audio data returned in + * \c audio_buf when it is no longer used. + * + * Because of the underspecification of the Waveform format, there are many + * problematic files in the wild that cause issues with strict decoders. To + * provide compatibility with these files, this decoder is lenient in regards + * to the truncation of the file, the fact chunk, and the size of the RIFF + * chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, + * and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the + * loading process. + * + * Any file that is invalid (due to truncation, corruption, or wrong values in + * the headers), too big, or unsupported causes an error. Additionally, any + * critical I/O error from the data source will terminate the loading process + * with an error. The function returns NULL on error and in all cases (with the + * exception of \c src being NULL), an appropriate error message will be set. + * + * It is required that the data source supports seeking. + * + * Example: * \code * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); * \endcode * - * If this function succeeds, it returns the given SDL_AudioSpec, - * filled with the audio data format of the wave data, and sets - * \c *audio_buf to a malloc()'d buffer containing the audio data, - * and sets \c *audio_len to the length of that audio buffer, in bytes. - * You need to free the audio buffer with SDL_FreeWAV() when you are - * done with it. - * - * This function returns NULL and sets the SDL error message if the - * wave file cannot be opened, uses an unknown data format, or is - * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + * \param src The data source with the WAVE data + * \param freesrc A integer value that makes the function close the data source if non-zero + * \param spec A pointer filled with the audio format of the audio data + * \param audio_buf A pointer filled with the audio data allocated by the function + * \param audio_len A pointer filled with the length of the audio data buffer in bytes + * \return NULL on error, or non-NULL on success. */ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, diff --git a/libs/SDL2/include/SDL_bits.h b/libs/SDL2/include/SDL_bits.h index eb8322f0d..b116cc8d0 100644 --- a/libs/SDL2/include/SDL_bits.h +++ b/libs/SDL2/include/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -101,6 +101,15 @@ SDL_MostSignificantBitIndex32(Uint32 x) #endif } +SDL_FORCE_INLINE SDL_bool +SDL_HasExactlyOneBitSet32(Uint32 x) +{ + if (x && !(x & (x - 1))) { + return SDL_TRUE; + } + return SDL_FALSE; +} + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/libs/SDL2/include/SDL_blendmode.h b/libs/SDL2/include/SDL_blendmode.h index 36a5ea76f..6f0a22b99 100644 --- a/libs/SDL2/include/SDL_blendmode.h +++ b/libs/SDL2/include/SDL_blendmode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -90,12 +90,12 @@ typedef enum /** * \brief Create a custom blend mode, which may or may not be supported by a given renderer * - * \param srcColorFactor - * \param dstColorFactor - * \param colorOperation - * \param srcAlphaFactor - * \param dstAlphaFactor - * \param alphaOperation + * \param srcColorFactor source color factor + * \param dstColorFactor destination color factor + * \param colorOperation color operation + * \param srcAlphaFactor source alpha factor + * \param dstAlphaFactor destination alpha factor + * \param alphaOperation alpha operation * * The result of the blend mode operation will be: * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor diff --git a/libs/SDL2/include/SDL_clipboard.h b/libs/SDL2/include/SDL_clipboard.h index f28751ebb..c4f8766ce 100644 --- a/libs/SDL2/include/SDL_clipboard.h +++ b/libs/SDL2/include/SDL_clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_config.h b/libs/SDL2/include/SDL_config.h index c58be8e72..395ad7c26 100644 --- a/libs/SDL2/include/SDL_config.h +++ b/libs/SDL2/include/SDL_config.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_cpuinfo.h b/libs/SDL2/include/SDL_cpuinfo.h index ee3a47e84..296df01aa 100644 --- a/libs/SDL2/include/SDL_cpuinfo.h +++ b/libs/SDL2/include/SDL_cpuinfo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -41,24 +41,43 @@ #else #include #ifndef _WIN64 +#ifndef __MMX__ #define __MMX__ +#endif +#ifndef __3dNOW__ #define __3dNOW__ #endif +#endif +#ifndef __SSE__ #define __SSE__ +#endif +#ifndef __SSE2__ #define __SSE2__ +#endif #endif /* __clang__ */ #elif defined(__MINGW64_VERSION_MAJOR) #include #else -#ifdef __ALTIVEC__ -#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H) +/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ +#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) #include -#undef pixel -#undef bool #endif -#endif -#if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H) -#include +#if !defined(SDL_DISABLE_ARM_NEON_H) +# if defined(__ARM_NEON) +# include +# elif defined(__WINDOWS__) || defined(__WINRT__) +/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ +# if defined(_M_ARM) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# if defined (_M_ARM64) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# endif #endif #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) #include @@ -177,6 +196,69 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); */ extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); +/** + * \brief Report the alignment this system needs for SIMD allocations. + * + * This will return the minimum number of bytes to which a pointer must be + * aligned to be compatible with SIMD instructions on the current machine. + * For example, if the machine supports SSE only, it will return 16, but if + * it supports AVX-512F, it'll return 64 (etc). This only reports values for + * instruction sets SDL knows about, so if your SDL build doesn't have + * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and + * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. + * Plan accordingly. + */ +extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); + +/** + * \brief Allocate memory in a SIMD-friendly way. + * + * This will allocate a block of memory that is suitable for use with SIMD + * instructions. Specifically, it will be properly aligned and padded for + * the system's supported vector instructions. + * + * The memory returned will be padded such that it is safe to read or write + * an incomplete vector at the end of the memory block. This can be useful + * so you don't have to drop back to a scalar fallback at the end of your + * SIMD processing loop to deal with the final elements without overflowing + * the allocated buffer. + * + * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() + * or delete[], etc. + * + * Note that SDL will only deal with SIMD instruction sets it is aware of; + * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors + * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't + * know that AVX-512 wants 64. To be clear: if you can't decide to use an + * instruction set with an SDL_Has*() function, don't use that instruction + * set with memory allocated through here. + * + * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't + * out of memory. + * + * \param len The length, in bytes, of the block to allocated. The actual + * allocated block might be larger due to padding, etc. + * \return Pointer to newly-allocated block, NULL if out of memory. + * + * \sa SDL_SIMDAlignment + * \sa SDL_SIMDFree + */ +extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); + +/** + * \brief Deallocate memory obtained from SDL_SIMDAlloc + * + * It is not valid to use this function on a pointer from anything but + * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, + * SDL_malloc, memalign, new[], etc. + * + * However, SDL_SIMDFree(NULL) is a legal no-op. + * + * \sa SDL_SIMDAlloc + */ +extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); + +/* vi: set ts=4 sw=4 expandtab: */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/libs/SDL2/include/SDL_egl.h b/libs/SDL2/include/SDL_egl.h index d65ed437c..f50fa5c9b 100644 --- a/libs/SDL2/include/SDL_egl.h +++ b/libs/SDL2/include/SDL_egl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_endian.h b/libs/SDL2/include/SDL_endian.h index ed0bf5ba8..54d5d486d 100644 --- a/libs/SDL2/include/SDL_endian.h +++ b/libs/SDL2/include/SDL_endian.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_error.h b/libs/SDL2/include/SDL_error.h index c0e46298e..24416e693 100644 --- a/libs/SDL2/include/SDL_error.h +++ b/libs/SDL2/include/SDL_error.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_events.h b/libs/SDL2/include/SDL_events.h index af22eb646..282b9fb76 100644 --- a/libs/SDL2/include/SDL_events.h +++ b/libs/SDL2/include/SDL_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -594,6 +594,9 @@ typedef union SDL_Event Uint8 padding[56]; } SDL_Event; +/* Make sure we haven't broken binary compatibility */ +SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); + /* Function prototypes */ diff --git a/libs/SDL2/include/SDL_filesystem.h b/libs/SDL2/include/SDL_filesystem.h index fa6a1fa6e..6d97e5896 100644 --- a/libs/SDL2/include/SDL_filesystem.h +++ b/libs/SDL2/include/SDL_filesystem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_gamecontroller.h b/libs/SDL2/include/SDL_gamecontroller.h index 6ae9c9542..ebde38715 100644 --- a/libs/SDL2/include/SDL_gamecontroller.h +++ b/libs/SDL2/include/SDL_gamecontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_gesture.h b/libs/SDL2/include/SDL_gesture.h index b223d80d4..9d25e9c1d 100644 --- a/libs/SDL2/include/SDL_gesture.h +++ b/libs/SDL2/include/SDL_gesture.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_haptic.h b/libs/SDL2/include/SDL_haptic.h index 2ea1bfc16..075627685 100644 --- a/libs/SDL2/include/SDL_haptic.h +++ b/libs/SDL2/include/SDL_haptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_hints.h b/libs/SDL2/include/SDL_hints.h index 4ee72e97d..8fa0dd660 100644 --- a/libs/SDL2/include/SDL_hints.h +++ b/libs/SDL2/include/SDL_hints.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -315,6 +315,16 @@ extern "C" { */ #define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" +/** + * \brief A variable controlling whether mouse events should generate synthetic touch events + * + * This variable can be set to the following values: + * "0" - Mouse events will not generate touch events (default for desktop platforms) + * "1" - Mouse events will generate touch events (default for mobile platforms, such as Android and iOS) + */ + +#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" + /** * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. * @@ -436,6 +446,16 @@ extern "C" { */ #define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" +/** + * \brief A variable that lets you provide a file with extra gamecontroller db entries. + * + * The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" + /** * \brief A variable containing a list of devices to skip when scanning for game controllers. * @@ -836,19 +856,7 @@ extern "C" { */ #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" - /** - * \brief A variable to control whether mouse and touch events are to be treated together or separately - * - * The variable can be set to the following values: - * "0" - Mouse events will be handled as touch events, and touch will raise fake mouse - * events. This is the behaviour of SDL <= 2.0.3. (default) - * "1" - Mouse events will be handled separately from pure touch events. - * - * The value of this hint is used at runtime, so it can be changed at any time. - */ -#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH" - - /** +/** * \brief A variable to control whether we trap the Android back button to handle it manually. * This is necessary for the right mouse button to work on some Android devices, or * to be able to trap the back button for use in your code reliably. If set to true, @@ -865,6 +873,17 @@ extern "C" { */ #define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" +/** + * \brief A variable to control whether the event loop will block itself when the app is paused. + * + * The variable can be set to the following values: + * "0" - Non blocking. + * "1" - Blocking. (default) + * + * The value should be set before SDL is initialized. + */ +#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" + /** * \brief A variable to control whether the return key on the soft keyboard * should hide the soft keyboard on Android and iOS. @@ -1043,6 +1062,118 @@ extern "C" { */ #define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" +/** + * \brief A variable controlling whether the 2D render API is compatible or efficient. + * + * This variable can be set to the following values: + * + * "0" - Don't use batching to make rendering more efficient. + * "1" - Use batching, but might cause problems if app makes its own direct OpenGL calls. + * + * Up to SDL 2.0.9, the render API would draw immediately when requested. Now + * it batches up draw requests and sends them all to the GPU only when forced + * to (during SDL_RenderPresent, when changing render targets, by updating a + * texture that the batch needs, etc). This is significantly more efficient, + * but it can cause problems for apps that expect to render on top of the + * render API's output. As such, SDL will disable batching if a specific + * render backend is requested (since this might indicate that the app is + * planning to use the underlying graphics API directly). This hint can + * be used to explicitly request batching in this instance. It is a contract + * that you will either never use the underlying graphics API directly, or + * if you do, you will call SDL_RenderFlush() before you do so any current + * batch goes to the GPU before your work begins. Not following this contract + * will result in undefined behavior. + */ +#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING" + + +/** + * \brief A variable controlling whether SDL logs all events pushed onto its internal queue. + * + * This variable can be set to the following values: + * + * "0" - Don't log any events (default) + * "1" - Log all events except mouse and finger motion, which are pretty spammy. + * "2" - Log all events. + * + * This is generally meant to be used to debug SDL itself, but can be useful + * for application developers that need better visibility into what is going + * on in the event queue. Logged events are sent through SDL_Log(), which + * means by default they appear on stdout on most platforms or maybe + * OutputDebugString() on Windows, and can be funneled by the app with + * SDL_LogSetOutputFunction(), etc. + * + * This hint can be toggled on and off at runtime, if you only need to log + * events for a small subset of program execution. + */ +#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" + + + +/** + * \brief Controls how the size of the RIFF chunk affects the loading of a WAVE file. + * + * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE + * file) is not always reliable. In case the size is wrong, it's possible to + * just ignore it and step through the chunks until a fixed limit is reached. + * + * Note that files that have trailing data unrelated to the WAVE file or + * corrupt files may slow down the loading process without a reliable boundary. + * By default, SDL stops after 10000 chunks to prevent wasting time. Use the + * environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value. + * + * This variable can be set to the following values: + * + * "force" - Always use the RIFF chunk size as a boundary for the chunk search + * "ignorezero" - Like "force", but a zero size searches up to 4 GiB (default) + * "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB + * "maximum" - Search for chunks until the end of file (not recommended) + */ +#define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" + +/** + * \brief Controls how a truncated WAVE file is handled. + * + * A WAVE file is considered truncated if any of the chunks are incomplete or + * the data chunk size is not a multiple of the block size. By default, SDL + * decodes until the first incomplete block, as most applications seem to do. + * + * This variable can be set to the following values: + * + * "verystrict" - Raise an error if the file is truncated + * "strict" - Like "verystrict", but the size of the RIFF chunk is ignored + * "dropframe" - Decode until the first incomplete sample frame + * "dropblock" - Decode until the first incomplete block (default) + */ +#define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" + +/** + * \brief Controls how the fact chunk affects the loading of a WAVE file. + * + * The fact chunk stores information about the number of samples of a WAVE + * file. The Standards Update from Microsoft notes that this value can be used + * to 'determine the length of the data in seconds'. This is especially useful + * for compressed formats (for which this is a mandatory chunk) if they produce + * multiple sample frames per block and truncating the block is not allowed. + * The fact chunk can exactly specify how many sample frames there should be + * in this case. + * + * Unfortunately, most application seem to ignore the fact chunk and so SDL + * ignores it by default as well. + * + * This variable can be set to the following values: + * + * "truncate" - Use the number of samples to truncate the wave data if + * the fact chunk is present and valid + * "strict" - Like "truncate", but raise an error if the fact chunk + * is invalid, not present for non-PCM formats, or if the + * data chunk doesn't have that many samples + * "ignorezero" - Like "truncate", but ignore fact chunk if the number of + * samples is zero + * "ignore" - Ignore fact chunk entirely (default) + */ +#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" + /** * \brief An enumeration of hint priorities */ diff --git a/libs/SDL2/include/SDL_joystick.h b/libs/SDL2/include/SDL_joystick.h index 6e05a9c20..3a4c5d177 100644 --- a/libs/SDL2/include/SDL_joystick.h +++ b/libs/SDL2/include/SDL_joystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_keyboard.h b/libs/SDL2/include/SDL_keyboard.h index 874823171..4b2a055d8 100644 --- a/libs/SDL2/include/SDL_keyboard.h +++ b/libs/SDL2/include/SDL_keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_keycode.h b/libs/SDL2/include/SDL_keycode.h index d7d5b1dbc..3bceb418a 100644 --- a/libs/SDL2/include/SDL_keycode.h +++ b/libs/SDL2/include/SDL_keycode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_loadso.h b/libs/SDL2/include/SDL_loadso.h index da56fb452..793ba5358 100644 --- a/libs/SDL2/include/SDL_loadso.h +++ b/libs/SDL2/include/SDL_loadso.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_log.h b/libs/SDL2/include/SDL_log.h index e12b65886..40f768d57 100644 --- a/libs/SDL2/include/SDL_log.h +++ b/libs/SDL2/include/SDL_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_main.h b/libs/SDL2/include/SDL_main.h index 98558217f..623f2d005 100644 --- a/libs/SDL2/include/SDL_main.h +++ b/libs/SDL2/include/SDL_main.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -55,6 +55,10 @@ /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. + If you link with SDL dynamically on iOS, the main function can't be in a + shared library, so you need to link with libSDLmain.a, which includes a + stub main function that calls into the shared library to start execution. + See src/video/uikit/SDL_uikitappdelegate.m for more details. */ #define SDL_MAIN_NEEDED @@ -82,12 +86,6 @@ #endif #endif /* SDL_MAIN_HANDLED */ -#ifdef __cplusplus -#define C_LINKAGE "C" -#else -#define C_LINKAGE -#endif /* __cplusplus */ - #ifndef SDLMAIN_DECLSPEC #define SDLMAIN_DECLSPEC #endif @@ -111,17 +109,18 @@ #define main SDL_main #endif -/** - * The prototype for the application's main() function - */ -extern C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); - - #include "begin_code.h" #ifdef __cplusplus extern "C" { #endif +/** + * The prototype for the application's main() function + */ +typedef int (*SDL_main_func)(int argc, char *argv[]); +extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); + + /** * This is called by the real SDL main function to let the rest of the * library know that initialization was done properly. @@ -136,8 +135,7 @@ extern DECLSPEC void SDLCALL SDL_SetMainReady(void); /** * This can be called to set the application class at startup */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, - void *hInst); +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #endif /* __WIN32__ */ @@ -153,10 +151,24 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more * information on the failure. */ -extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved); +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved); #endif /* __WINRT__ */ +#if defined(__IPHONEOS__) + +/** + * \brief Initializes and launches an SDL application. + * + * \param argc The argc parameter from the application's main() function + * \param argv The argv parameter from the application's main() function + * \param mainFunction The SDL app's C-style main(). + * \return the return value from mainFunction + */ +extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); + +#endif /* __IPHONEOS__ */ + #ifdef __cplusplus } diff --git a/libs/SDL2/include/SDL_messagebox.h b/libs/SDL2/include/SDL_messagebox.h index b7be59d88..e34b55477 100644 --- a/libs/SDL2/include/SDL_messagebox.h +++ b/libs/SDL2/include/SDL_messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_mouse.h b/libs/SDL2/include/SDL_mouse.h index d3c9f6156..277559d23 100644 --- a/libs/SDL2/include/SDL_mouse.h +++ b/libs/SDL2/include/SDL_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_mutex.h b/libs/SDL2/include/SDL_mutex.h index ba4247ced..970e78713 100644 --- a/libs/SDL2/include/SDL_mutex.h +++ b/libs/SDL2/include/SDL_mutex.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_name.h b/libs/SDL2/include/SDL_name.h index ecd863f4c..690a8199b 100644 --- a/libs/SDL2/include/SDL_name.h +++ b/libs/SDL2/include/SDL_name.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_opengl.h b/libs/SDL2/include/SDL_opengl.h index 253d9c93a..6685be73e 100644 --- a/libs/SDL2/include/SDL_opengl.h +++ b/libs/SDL2/include/SDL_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_opengles.h b/libs/SDL2/include/SDL_opengles.h index 18dd984b3..1e0660c3d 100644 --- a/libs/SDL2/include/SDL_opengles.h +++ b/libs/SDL2/include/SDL_opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_opengles2.h b/libs/SDL2/include/SDL_opengles2.h index 6ccecf216..df29d3840 100644 --- a/libs/SDL2/include/SDL_opengles2.h +++ b/libs/SDL2/include/SDL_opengles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_pixels.h b/libs/SDL2/include/SDL_pixels.h index 0b4364b18..dcb7a980d 100644 --- a/libs/SDL2/include/SDL_pixels.h +++ b/libs/SDL2/include/SDL_pixels.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -168,7 +168,7 @@ enum ((format) && (SDL_PIXELFLAG(format) != 1)) /* Note: If you modify this list, update SDL_GetPixelFormatName() */ -enum +typedef enum { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB = @@ -290,7 +290,7 @@ enum SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */ SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') -}; +} SDL_PixelFormatEnum; typedef struct SDL_Color { diff --git a/libs/SDL2/include/SDL_platform.h b/libs/SDL2/include/SDL_platform.h index 7dea4ce94..c2cbc6b4e 100644 --- a/libs/SDL2/include/SDL_platform.h +++ b/libs/SDL2/include/SDL_platform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_power.h b/libs/SDL2/include/SDL_power.h index a4fe8a935..4831cb77e 100644 --- a/libs/SDL2/include/SDL_power.h +++ b/libs/SDL2/include/SDL_power.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_quit.h b/libs/SDL2/include/SDL_quit.h index fea56a8d8..c979983cb 100644 --- a/libs/SDL2/include/SDL_quit.h +++ b/libs/SDL2/include/SDL_quit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_rect.h b/libs/SDL2/include/SDL_rect.h index 543bb6186..71a411517 100644 --- a/libs/SDL2/include/SDL_rect.h +++ b/libs/SDL2/include/SDL_rect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -40,7 +40,7 @@ extern "C" { #endif /** - * \brief The structure that defines a point + * \brief The structure that defines a point (integer) * * \sa SDL_EnclosePoints * \sa SDL_PointInRect @@ -52,7 +52,20 @@ typedef struct SDL_Point } SDL_Point; /** - * \brief A rectangle, with the origin at the upper left. + * \brief The structure that defines a point (floating point) + * + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect + */ +typedef struct SDL_FPoint +{ + float x; + float y; +} SDL_FPoint; + + +/** + * \brief A rectangle, with the origin at the upper left (integer). * * \sa SDL_RectEmpty * \sa SDL_RectEquals @@ -67,6 +80,19 @@ typedef struct SDL_Rect int w, h; } SDL_Rect; + +/** + * \brief A rectangle, with the origin at the upper left (floating point). + */ +typedef struct SDL_FRect +{ + float x; + float y; + float w; + float h; +} SDL_FRect; + + /** * \brief Returns true if point resides inside a rectangle. */ diff --git a/libs/SDL2/include/SDL_render.h b/libs/SDL2/include/SDL_render.h index d33619297..096b4a577 100644 --- a/libs/SDL2/include/SDL_render.h +++ b/libs/SDL2/include/SDL_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -835,6 +835,148 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, const SDL_Point *center, const SDL_RendererFlip flip); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, + float x, float y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, + float x1, float y1, float x2, float y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect, + const double angle, + const SDL_FPoint *center, + const SDL_RendererFlip flip); + /** * \brief Read pixels from the current rendering target. * @@ -876,6 +1018,31 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); */ extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); +/** + * \brief Force the rendering context to flush any pending commands to the + * underlying rendering API. + * + * You do not need to (and in fact, shouldn't) call this function unless + * you are planning to call into OpenGL/Direct3D/Metal/whatever directly + * in addition to using an SDL_Renderer. + * + * This is for a very-specific case: if you are using SDL's render API, + * you asked for a specific renderer backend (OpenGL, Direct3D, etc), + * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make + * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of + * this applies, you should call SDL_RenderFlush() between calls to SDL's + * render API and the low-level API you're using in cooperation. + * + * In all other cases, you can ignore this function. This is only here to + * get maximum performance out of a specific situation. In all other cases, + * SDL will do the right thing, perhaps at a performance loss. + * + * This function is first available in SDL 2.0.10, and is not needed in + * 2.0.9 and earlier, as earlier versions did not queue rendering commands + * at all, instead flushing them to the OS immediately. + */ +extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); + /** * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with diff --git a/libs/SDL2/include/SDL_revision.h b/libs/SDL2/include/SDL_revision.h index 92fbe67b1..3b3fc85ea 100644 --- a/libs/SDL2/include/SDL_revision.h +++ b/libs/SDL2/include/SDL_revision.h @@ -1,2 +1,2 @@ -#define SDL_REVISION "hg-12373:8feb5da6f2fb" -#define SDL_REVISION_NUMBER 12373 +#define SDL_REVISION "hg-12952:bc90ce38f1e2" +#define SDL_REVISION_NUMBER 12952 diff --git a/libs/SDL2/include/SDL_rwops.h b/libs/SDL2/include/SDL_rwops.h index 0960699d4..f66119fb0 100644 --- a/libs/SDL2/include/SDL_rwops.h +++ b/libs/SDL2/include/SDL_rwops.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -176,19 +176,48 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); #define RW_SEEK_END 2 /**< Seek relative to the end of data */ /** - * \name Read/write macros - * - * Macros to easily read and write from an SDL_RWops structure. + * Return the size of the file in this rwops, or -1 if unknown */ -/* @{ */ -#define SDL_RWsize(ctx) (ctx)->size(ctx) -#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) -#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) -#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) -#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) -#define SDL_RWclose(ctx) (ctx)->close(ctx) -/* @} *//* Read/write macros */ +extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); +/** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, + Sint64 offset, int whence); + +/** + * Return the current offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context); + +/** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, + void *ptr, size_t size, size_t maxnum); + +/** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, + const void *ptr, size_t size, size_t num); + +/** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ +extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context); /** * Load all the data from an SDL data stream. @@ -209,9 +238,17 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, /** * Load an entire file. * - * Convenience macro. + * The data is allocated with a zero byte at the end (null terminated) + * + * If \c datasize is not NULL, it is filled with the size of the data read. + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The data should be freed with SDL_free(). + * + * \return the data, or NULL if there was an error. */ -#define SDL_LoadFile(file, datasize) SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1) +extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); /** * \name Read endian functions diff --git a/libs/SDL2/include/SDL_scancode.h b/libs/SDL2/include/SDL_scancode.h index 63871aa3b..a50305f55 100644 --- a/libs/SDL2/include/SDL_scancode.h +++ b/libs/SDL2/include/SDL_scancode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,7 +38,7 @@ * SDL_Event structure. * * The values in this enumeration are based on the USB usage page standard: - * http://www.usb.org/developers/hidpage/Hut1_12v2.pdf + * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf */ typedef enum { diff --git a/libs/SDL2/include/SDL_sensor.h b/libs/SDL2/include/SDL_sensor.h index ac163a8cd..966adbf21 100644 --- a/libs/SDL2/include/SDL_sensor.h +++ b/libs/SDL2/include/SDL_sensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,8 +26,8 @@ * */ -#ifndef _SDL_sensor_h -#define _SDL_sensor_h +#ifndef SDL_sensor_h_ +#define SDL_sensor_h_ #include "SDL_stdinc.h" #include "SDL_error.h" @@ -246,6 +246,6 @@ extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); #endif #include "close_code.h" -#endif /* _SDL_sensor_h */ +#endif /* SDL_sensor_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/libs/SDL2/include/SDL_shape.h b/libs/SDL2/include/SDL_shape.h index 40a6baaae..2ab43fcdc 100644 --- a/libs/SDL2/include/SDL_shape.h +++ b/libs/SDL2/include/SDL_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_stdinc.h b/libs/SDL2/include/SDL_stdinc.h index e373bc380..28bb7b961 100644 --- a/libs/SDL2/include/SDL_stdinc.h +++ b/libs/SDL2/include/SDL_stdinc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_surface.h b/libs/SDL2/include/SDL_surface.h index 730d49fc8..51a128300 100644 --- a/libs/SDL2/include/SDL_surface.h +++ b/libs/SDL2/include/SDL_surface.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -53,6 +53,7 @@ extern "C" { #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +#define SDL_SIMD_ALIGNED 0x00000008 /**< Surface uses aligned memory */ /* @} *//* Surface flags */ /** diff --git a/libs/SDL2/include/SDL_system.h b/libs/SDL2/include/SDL_system.h index 4dc372d6b..3b0840769 100644 --- a/libs/SDL2/include/SDL_system.h +++ b/libs/SDL2/include/SDL_system.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_syswm.h b/libs/SDL2/include/SDL_syswm.h index f1c4021cc..7aa8c6869 100644 --- a/libs/SDL2/include/SDL_syswm.h +++ b/libs/SDL2/include/SDL_syswm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -34,16 +34,16 @@ #include "SDL_version.h" /** - * \file SDL_syswm.h + * \brief SDL_syswm.h * * Your application has access to a special type of event ::SDL_SYSWMEVENT, * which contains window-manager specific information and arrives whenever * an unhandled window event occurs. This event is ignored by default, but * you can enable it with SDL_EventState(). */ -#ifdef SDL_PROTOTYPES_ONLY struct SDL_SysWMinfo; -#else + +#if !defined(SDL_PROTOTYPES_ONLY) #if defined(SDL_VIDEO_DRIVER_WINDOWS) #ifndef WIN32_LEAN_AND_MEAN @@ -103,6 +103,8 @@ typedef void *EGLSurface; #if defined(SDL_VIDEO_DRIVER_VIVANTE) #include "SDL_egl.h" #endif +#endif /* SDL_PROTOTYPES_ONLY */ + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -110,6 +112,7 @@ typedef void *EGLSurface; extern "C" { #endif +#if !defined(SDL_PROTOTYPES_ONLY) /** * These are the various supported windowing subsystems */ @@ -122,7 +125,7 @@ typedef enum SDL_SYSWM_COCOA, SDL_SYSWM_UIKIT, SDL_SYSWM_WAYLAND, - SDL_SYSWM_MIR, + SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ SDL_SYSWM_WINRT, SDL_SYSWM_ANDROID, SDL_SYSWM_VIVANTE, @@ -257,11 +260,11 @@ struct SDL_SysWMinfo struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ } wl; #endif -#if defined(SDL_VIDEO_DRIVER_MIR) +#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ struct { - struct MirConnection *connection; /**< Mir display server connection */ - struct MirSurface *surface; /**< Mir surface */ + void *connection; /**< Mir display server connection */ + void *surface; /**< Mir surface */ } mir; #endif diff --git a/libs/SDL2/include/SDL_test.h b/libs/SDL2/include/SDL_test.h index 6cc373bf8..17a33dc2c 100644 --- a/libs/SDL2/include/SDL_test.h +++ b/libs/SDL2/include/SDL_test.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_assert.h b/libs/SDL2/include/SDL_test_assert.h index 1788d7a20..b3ebb62fb 100644 --- a/libs/SDL2/include/SDL_test_assert.h +++ b/libs/SDL2/include/SDL_test_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_common.h b/libs/SDL2/include/SDL_test_common.h index be2e6b2aa..c34d0d103 100644 --- a/libs/SDL2/include/SDL_test_common.h +++ b/libs/SDL2/include/SDL_test_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -140,14 +140,20 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); */ int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + /** - * \brief Returns common usage information + * \brief Logs command line usage info. * - * \param state The common state describing the test window to create. + * This logs the appropriate command line options for the subsystems in use + * plus other common options, and then any application-specific options. + * This uses the SDL_Log() function and splits up output to be friendly to + * 80-character-wide terminals. * - * \returns String with usage information + * \param state The common state describing the test window for the app. + * \param argv0 argv[0], as passed to main/SDL_main. + * \param options an array of strings for application specific options. The last element of the array should be NULL. */ -const char *SDLTest_CommonUsage(SDLTest_CommonState * state); +void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options); /** * \brief Open test window. @@ -158,6 +164,17 @@ const char *SDLTest_CommonUsage(SDLTest_CommonState * state); */ SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); +/** + * \brief Easy argument handling when test app doesn't need any custom args. + * + * \param state The common state describing the test window to create. + * \param argc argc, as supplied to SDL_main + * \param argv argv, as supplied to SDL_main + * + * \returns False if app should quit, true otherwise. + */ +SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv); + /** * \brief Common event handler for test windows. * diff --git a/libs/SDL2/include/SDL_test_compare.h b/libs/SDL2/include/SDL_test_compare.h index c22e447d8..1f751c8b9 100644 --- a/libs/SDL2/include/SDL_test_compare.h +++ b/libs/SDL2/include/SDL_test_compare.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_crc32.h b/libs/SDL2/include/SDL_test_crc32.h index 3d235d074..e615d8929 100644 --- a/libs/SDL2/include/SDL_test_crc32.h +++ b/libs/SDL2/include/SDL_test_crc32.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_font.h b/libs/SDL2/include/SDL_test_font.h index 59cbdcad6..8fa078440 100644 --- a/libs/SDL2/include/SDL_test_font.h +++ b/libs/SDL2/include/SDL_test_font.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_fuzzer.h b/libs/SDL2/include/SDL_test_fuzzer.h index 8fcb9ebbf..7259685a9 100644 --- a/libs/SDL2/include/SDL_test_fuzzer.h +++ b/libs/SDL2/include/SDL_test_fuzzer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_harness.h b/libs/SDL2/include/SDL_test_harness.h index 8641e0a7e..f5ae92ceb 100644 --- a/libs/SDL2/include/SDL_test_harness.h +++ b/libs/SDL2/include/SDL_test_harness.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_images.h b/libs/SDL2/include/SDL_test_images.h index 9c4dd5b82..b8934812f 100644 --- a/libs/SDL2/include/SDL_test_images.h +++ b/libs/SDL2/include/SDL_test_images.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_log.h b/libs/SDL2/include/SDL_test_log.h index ebd44fb50..01d0fedac 100644 --- a/libs/SDL2/include/SDL_test_log.h +++ b/libs/SDL2/include/SDL_test_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_md5.h b/libs/SDL2/include/SDL_test_md5.h index 0e4105768..2bfd7dff9 100644 --- a/libs/SDL2/include/SDL_test_md5.h +++ b/libs/SDL2/include/SDL_test_md5.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_test_memory.h b/libs/SDL2/include/SDL_test_memory.h index 4827ae6f2..5d4d39ea5 100644 --- a/libs/SDL2/include/SDL_test_memory.h +++ b/libs/SDL2/include/SDL_test_memory.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -42,14 +42,14 @@ extern "C" { * * \note This should be called before any other SDL functions for complete tracking coverage */ -int SDLTest_TrackAllocations(); +int SDLTest_TrackAllocations(void); /** * \brief Print a log of any outstanding allocations * * \note This can be called after SDL_Quit() */ -void SDLTest_LogAllocations(); +void SDLTest_LogAllocations(void); /* Ends C function definitions when using C++ */ diff --git a/libs/SDL2/include/SDL_test_random.h b/libs/SDL2/include/SDL_test_random.h index 0eb414ff2..71e9c70b6 100644 --- a/libs/SDL2/include/SDL_test_random.h +++ b/libs/SDL2/include/SDL_test_random.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_thread.h b/libs/SDL2/include/SDL_thread.h index 554dd0b61..f78b1145d 100644 --- a/libs/SDL2/include/SDL_thread.h +++ b/libs/SDL2/include/SDL_thread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_timer.h b/libs/SDL2/include/SDL_timer.h index 5600618ff..2a47b043a 100644 --- a/libs/SDL2/include/SDL_timer.h +++ b/libs/SDL2/include/SDL_timer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_touch.h b/libs/SDL2/include/SDL_touch.h index f4075e79a..99dbcb8c3 100644 --- a/libs/SDL2/include/SDL_touch.h +++ b/libs/SDL2/include/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -41,6 +41,14 @@ extern "C" { typedef Sint64 SDL_TouchID; typedef Sint64 SDL_FingerID; +typedef enum +{ + SDL_TOUCH_DEVICE_INVALID = -1, + SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */ +} SDL_TouchDeviceType; + typedef struct SDL_Finger { SDL_FingerID id; @@ -52,6 +60,9 @@ typedef struct SDL_Finger /* Used as the device ID for mouse events simulated with touch input */ #define SDL_TOUCH_MOUSEID ((Uint32)-1) +/* Used as the SDL_TouchID for touch events simulated with mouse input */ +#define SDL_MOUSE_TOUCHID ((Sint64)-1) + /* Function prototypes */ @@ -65,6 +76,11 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); */ extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); +/** + * \brief Get the type of the given touch device. + */ +extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); + /** * \brief Get the number of active fingers for a given touch device. */ diff --git a/libs/SDL2/include/SDL_types.h b/libs/SDL2/include/SDL_types.h index 4ac248c8c..9c3e9896f 100644 --- a/libs/SDL2/include/SDL_types.h +++ b/libs/SDL2/include/SDL_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_version.h b/libs/SDL2/include/SDL_version.h index 31443e149..6c7499d32 100644 --- a/libs/SDL2/include/SDL_version.h +++ b/libs/SDL2/include/SDL_version.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 9 +#define SDL_PATCHLEVEL 10 /** * \brief Macro to determine SDL version program was compiled against. diff --git a/libs/SDL2/include/SDL_video.h b/libs/SDL2/include/SDL_video.h index 461f13805..352afd436 100644 --- a/libs/SDL2/include/SDL_video.h +++ b/libs/SDL2/include/SDL_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/include/SDL_vulkan.h b/libs/SDL2/include/SDL_vulkan.h index 972cca4d7..d69a436b3 100644 --- a/libs/SDL2/include/SDL_vulkan.h +++ b/libs/SDL2/include/SDL_vulkan.h @@ -98,8 +98,8 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */ * applications to link with libvulkan (and historically MoltenVK was * provided as a static library). If it is not found then, on macOS, SDL * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib, - * \c MoltenVK.framework/MoltenVK and \c libMoltenVK.dylib in that order. - * On iOS SDL will attempt to load \c libMoltenVK.dylib. Applications + * followed by \c libvulkan.dylib, in that order. + * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications * using a dynamic framework or .dylib must ensure it is included in its * application bundle. * @@ -153,7 +153,7 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); * is smaller than the number of required extensions, \c SDL_FALSE will be * returned instead of \c SDL_TRUE, to indicate that not all the required * extensions were returned. - * + * * \note If \c window is not NULL, it will be checked against its creation * flags to ensure that the Vulkan flag is present. This parameter * will be removed in a future major release. diff --git a/libs/SDL2/include/begin_code.h b/libs/SDL2/include/begin_code.h index 6c2106246..22c997c41 100644 --- a/libs/SDL2/include/begin_code.h +++ b/libs/SDL2/include/begin_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -105,6 +105,9 @@ #ifdef _MSC_VER #pragma warning(disable: 4103) #endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif #ifdef __BORLANDC__ #pragma nopackwarning #endif diff --git a/libs/SDL2/include/close_code.h b/libs/SDL2/include/close_code.h index b3b70a4c8..8e4cac3da 100644 --- a/libs/SDL2/include/close_code.h +++ b/libs/SDL2/include/close_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,6 +26,9 @@ * after you finish any function and structure declarations in your headers */ +#ifndef _begin_code_h +#error close_code.h included without matching begin_code.h +#endif #undef _begin_code_h /* Reset structure packing at previous byte alignment */ diff --git a/libs/SDL2/lib/ARM/SDL2.dll b/libs/SDL2/lib/ARM/SDL2.dll new file mode 100644 index 000000000..3eec027ef Binary files /dev/null and b/libs/SDL2/lib/ARM/SDL2.dll differ diff --git a/libs/SDL2/lib/ARM/SDL2.lib b/libs/SDL2/lib/ARM/SDL2.lib index be9d86949..b027b8956 100644 Binary files a/libs/SDL2/lib/ARM/SDL2.lib and b/libs/SDL2/lib/ARM/SDL2.lib differ diff --git a/libs/SDL2/lib/ARM64/SDL2.dll b/libs/SDL2/lib/ARM64/SDL2.dll index f9eac1c0b..9e2d2c785 100644 Binary files a/libs/SDL2/lib/ARM64/SDL2.dll and b/libs/SDL2/lib/ARM64/SDL2.dll differ diff --git a/libs/SDL2/lib/ARM64/SDL2.lib b/libs/SDL2/lib/ARM64/SDL2.lib index 40904c308..3e8cf8d46 100644 Binary files a/libs/SDL2/lib/ARM64/SDL2.lib and b/libs/SDL2/lib/ARM64/SDL2.lib differ diff --git a/libs/SDL2/lib/x64/SDL2.dll b/libs/SDL2/lib/x64/SDL2.dll index 934f8091c..0edb386ee 100644 Binary files a/libs/SDL2/lib/x64/SDL2.dll and b/libs/SDL2/lib/x64/SDL2.dll differ diff --git a/libs/SDL2/lib/x64/SDL2.lib b/libs/SDL2/lib/x64/SDL2.lib index f4941ae0e..89f7d37fc 100644 Binary files a/libs/SDL2/lib/x64/SDL2.lib and b/libs/SDL2/lib/x64/SDL2.lib differ diff --git a/libs/SDL2/lib/x64/SDL2main.lib b/libs/SDL2/lib/x64/SDL2main.lib index 612994657..4d07170c4 100644 Binary files a/libs/SDL2/lib/x64/SDL2main.lib and b/libs/SDL2/lib/x64/SDL2main.lib differ diff --git a/libs/SDL2/lib/x64/SDL2test.lib b/libs/SDL2/lib/x64/SDL2test.lib index 5b0328280..f3ad021f7 100644 Binary files a/libs/SDL2/lib/x64/SDL2test.lib and b/libs/SDL2/lib/x64/SDL2test.lib differ diff --git a/libs/SDL2/lib/x86/SDL2.dll b/libs/SDL2/lib/x86/SDL2.dll index 701779044..3673be1ab 100644 Binary files a/libs/SDL2/lib/x86/SDL2.dll and b/libs/SDL2/lib/x86/SDL2.dll differ diff --git a/libs/SDL2/lib/x86/SDL2.lib b/libs/SDL2/lib/x86/SDL2.lib index cef79017c..da3b4432b 100644 Binary files a/libs/SDL2/lib/x86/SDL2.lib and b/libs/SDL2/lib/x86/SDL2.lib differ diff --git a/libs/SDL2/lib/x86/SDL2main.lib b/libs/SDL2/lib/x86/SDL2main.lib index 55c40c7a0..27b48de2a 100644 Binary files a/libs/SDL2/lib/x86/SDL2main.lib and b/libs/SDL2/lib/x86/SDL2main.lib differ diff --git a/libs/SDL2/lib/x86/SDL2test.lib b/libs/SDL2/lib/x86/SDL2test.lib index d7a395ff1..1f195015b 100644 Binary files a/libs/SDL2/lib/x86/SDL2test.lib and b/libs/SDL2/lib/x86/SDL2test.lib differ diff --git a/libs/SDL2/test/Makefile.in b/libs/SDL2/test/Makefile.in index 9ddd6ffe7..9a62156ec 100644 --- a/libs/SDL2/test/Makefile.in +++ b/libs/SDL2/test/Makefile.in @@ -28,9 +28,6 @@ TARGETS = \ testfilesystem$(EXE) \ testgamecontroller$(EXE) \ testgesture$(EXE) \ - testgl2$(EXE) \ - testgles$(EXE) \ - testgles2$(EXE) \ testhaptic$(EXE) \ testhittesting$(EXE) \ testhotplug$(EXE) \ @@ -56,7 +53,6 @@ TARGETS = \ testscale$(EXE) \ testsem$(EXE) \ testsensor$(EXE) \ - testshader$(EXE) \ testshape$(EXE) \ testsprite2$(EXE) \ testspriteminimal$(EXE) \ @@ -69,7 +65,13 @@ TARGETS = \ testwm2$(EXE) \ testyuv$(EXE) \ torturethread$(EXE) \ + +@OPENGL_TARGETS@ += testgl2$(EXE) testshader$(EXE) +@OPENGLES1_TARGETS@ += testgles$(EXE) +@OPENGLES2_TARGETS@ += testgles2$(EXE) + + all: Makefile $(TARGETS) copydatafiles Makefile: $(srcdir)/Makefile.in diff --git a/libs/SDL2/test/Makefile.os2 b/libs/SDL2/test/Makefile.os2 new file mode 100644 index 000000000..59866a056 --- /dev/null +++ b/libs/SDL2/test/Makefile.os2 @@ -0,0 +1,91 @@ +BINPATH = . + +TARGETS = testatomic.exe testdisplayinfo.exe testbounds.exe testdraw2.exe & + testdrawchessboard.exe testdropfile.exe testerror.exe testfile.exe & + testfilesystem.exe testgamecontroller.exe testgesture.exe & + testhittesting.exe testhotplug.exe testiconv.exe testime.exe & + testintersections.exe testjoystick.exe testkeys.exe testloadso.exe & + testlock.exe testmessage.exe testoverlay2.exe testplatform.exe & + testpower.exe testsensor.exe testrelative.exe testrendercopyex.exe & + testrendertarget.exe testrumble.exe testscale.exe testsem.exe & + testshader.exe testshape.exe testsprite2.exe testspriteminimal.exe & + teststreaming.exe testthread.exe testtimer.exe testver.exe & + testviewport.exe testwm2.exe torturethread.exe checkkeys.exe & + controllermap.exe testhaptic.exe testqsort.exe testresample.exe & + testaudioinfo.exe testaudiocapture.exe loopwave.exe loopwavequeue.exe & + testyuv.exe testgl2.exe testvulkan.exe testautomation.exe + +# SDL2test.lib sources (../src/test) + +CSRCS = SDL_test_assert.c SDL_test_common.c SDL_test_compare.c & + SDL_test_crc32.c SDL_test_font.c SDL_test_fuzzer.c SDL_test_harness.c & + SDL_test_imageBlit.c SDL_test_imageBlitBlend.c SDL_test_imageFace.c & + SDL_test_imagePrimitives.c SDL_test_imagePrimitivesBlend.c & + SDL_test_log.c SDL_test_md5.c SDL_test_random.c SDL_test_memory.c +TESTLIB = SDL2test.lib + +# testautomation sources + +TASRCS = testautomation.c testautomation_audio.c testautomation_clipboard.c & + testautomation_events.c testautomation_hints.c & + testautomation_keyboard.c testautomation_main.c & + testautomation_mouse.c testautomation_pixels.c & + testautomation_platform.c testautomation_rect.c & + testautomation_render.c testautomation_rwops.c & + testautomation_sdltest.c testautomation_stdlib.c & + testautomation_surface.c testautomation_syswm.c & + testautomation_timer.c testautomation_video.c + +OBJS = $(TARGETS:.exe=.obj) +COBJS = $(CSRCS:.c=.obj) +TAOBJS = $(TASRCS:.c=.obj) + +all: $(TARGETS) + +INCPATH = -I$(%WATCOM)/h/os2 -I$(%WATCOM)/h -I../include + +CFLAGS = $(INCPATH) -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei + +LIBPATH = .. +LIBS = SDL2.lib $(TESTLIB) + +#CFLAGS+= -DHAVE_SDL_TTF +#LIBS_TTF = SDL2ttf.lib + +.c: ../src/test + +$(TESTLIB): $(COBJS) + wlib -q -b -n $@ $(COBJS) + +.obj.exe: + @%make $(TESTLIB) + wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ + +.c.obj: + wcc386 $(CFLAGS) -wcd=107 -fo=$^@ $< + +# specials +testautomation.exe: $(TAOBJS) + @%make $(TESTLIB) + wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ + +testoverlay2.exe: testoverlay2.obj testyuv_cvt.obj + @%make $(TESTLIB) + wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ + +testyuv.exe: testyuv.obj testyuv_cvt.obj + @%make $(TESTLIB) + wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ + +testime.exe: testime.obj + @%make $(TESTLIB) + wlink SYS os2v2 libpath $(LIBPATH) lib {$(LIBS) $(LIBS_TTF)} op q op el file {$<} name $@ + +clean: .SYMBOLIC + @echo * Clean tests in $(BINPATH) + @if exist *.obj rm *.obj + @if exist *.err rm *.err + +distclean: .SYMBOLIC clean + @if exist *.exe rm *.exe + @if exist $(TESTLIB) rm $(TESTLIB) diff --git a/libs/SDL2/test/checkkeys.c b/libs/SDL2/test/checkkeys.c index 4452acaba..421f8f923 100644 --- a/libs/SDL2/test/checkkeys.c +++ b/libs/SDL2/test/checkkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/configure b/libs/SDL2/test/configure index 61c32fba1..909a485ac 100755 --- a/libs/SDL2/test/configure +++ b/libs/SDL2/test/configure @@ -589,6 +589,9 @@ XLIB GLES2LIB GLESLIB GLLIB +OPENGL_TARGETS +OPENGLES2_TARGETS +OPENGLES1_TARGETS CPP XMKMF SDL_CONFIG @@ -3901,17 +3904,23 @@ $as_echo "$have_opengles2" >&6; } GLLIB="" GLESLIB="" GLES2LIB="" +OPENGLES1_TARGETS="UNUSED" +OPENGLES2_TARGETS="UNUSED" +OPENGL_TARGETS="UNUSED" if test x$have_opengles = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGLES" GLESLIB="$XPATH -lGLESv1_CM" + OPENGLES1_TARGETS="TARGETS" fi if test x$have_opengles2 = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGLES2" #GLES2LIB="$XPATH -lGLESv2" + OPENGLES2_TARGETS="TARGETS" fi if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" GLLIB="$XPATH $SYS_GL_LIBS" + OPENGL_TARGETS="TARGETS" fi @@ -3919,6 +3928,9 @@ fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TTF_Init in -lSDL2_ttf" >&5 $as_echo_n "checking for TTF_Init in -lSDL2_ttf... " >&6; } if ${ac_cv_lib_SDL2_ttf_TTF_Init+:} false; then : diff --git a/libs/SDL2/test/configure.ac b/libs/SDL2/test/configure.ac new file mode 100644 index 000000000..2e237262e --- /dev/null +++ b/libs/SDL2/test/configure.ac @@ -0,0 +1,200 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(README) + +dnl Detect the canonical build and host environments +AC_CONFIG_AUX_DIRS($srcdir/../build-scripts) +AC_CANONICAL_HOST + +dnl Check for tools + +AC_PROG_CC + +dnl Check for compiler environment + +AC_C_CONST + +dnl We only care about this for building testnative at the moment, so these +dnl values shouldn't be considered absolute truth. +dnl (Haiku, for example, sets none of these.) +ISUNIX="false" +ISWINDOWS="false" +ISMACOSX="false" + +dnl Figure out which math library to use +case "$host" in + *-*-cygwin* | *-*-mingw32*) + ISWINDOWS="true" + EXE=".exe" + MATHLIB="" + SYS_GL_LIBS="-lopengl32" + ;; + *-*-haiku*) + EXE="" + MATHLIB="" + SYS_GL_LIBS="-lGL" + ;; + *-*-darwin* ) + ISMACOSX="true" + EXE="" + MATHLIB="" + SYS_GL_LIBS="-Wl,-framework,OpenGL" + ;; + *-*-aix*) + ISUNIX="true" + EXE="" + if test x$ac_cv_prog_gcc = xyes; then + CFLAGS="-mthreads" + fi + SYS_GL_LIBS="" + ;; + *-*-mint*) + EXE="" + MATHLIB="" + AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no) + if test "x$OSMESA_CONFIG" = "xyes"; then + OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags` + OSMESA_LIBS=`$OSMESA_CONFIG --libs` + CFLAGS="$CFLAGS $OSMESA_CFLAGS" + SYS_GL_LIBS="$OSMESA_LIBS" + else + SYS_GL_LIBS="-lOSMesa" + fi + ;; + *-*-qnx*) + EXE="" + MATHLIB="" + SYS_GL_LIBS="-lGLES_CM" + ;; + *-*-emscripten* ) + dnl This should really be .js, but we need to specify extra flags when compiling to js + EXE=".bc" + MATHLIB="" + SYS_GL_LIBS="" + ;; + *) + dnl Oh well, call it Unix... + ISUNIX="true" + EXE="" + MATHLIB="-lm" + SYS_GL_LIBS="-lGL" + ;; +esac +AC_SUBST(EXE) +AC_SUBST(MATHLIB) +AC_SUBST(ISMACOSX) +AC_SUBST(ISWINDOWS) +AC_SUBST(ISUNIX) + +dnl Check for SDL +SDL_VERSION=2.0.0 +AM_PATH_SDL2($SDL_VERSION, + :, + AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) +) +CFLAGS="$CFLAGS $SDL_CFLAGS" +LIBS="$LIBS -lSDL2_test $SDL_LIBS" + +dnl Check for X11 path, needed for OpenGL on some systems +AC_PATH_X +if test x$have_x = xyes; then + if test x$ac_x_includes = xno || test "x$ac_x_includes" = xNone || test "x$ac_x_includes" = x; then + : + else + CFLAGS="$CFLAGS -I$ac_x_includes" + fi + if test x$ac_x_libraries = xno || test "x$ac_x_libraries" = xNone; then + : + else + if test "x$ac_x_libraries" = x; then + XPATH="" + XLIB="-lX11" + else + XPATH="-L$ac_x_libraries" + XLIB="-L$ac_x_libraries -lX11" + fi + fi +fi + +dnl Check for OpenGL +AC_MSG_CHECKING(for OpenGL support) +have_opengl=no +AC_TRY_COMPILE([ + #include "SDL_opengl.h" +],[ +],[ +have_opengl=yes +]) +AC_MSG_RESULT($have_opengl) + +dnl Check for OpenGL ES +AC_MSG_CHECKING(for OpenGL ES support) +have_opengles=no +AC_TRY_COMPILE([ + #if defined (__IPHONEOS__) + #include + #else + #include + #endif /* __QNXNTO__ */ +],[ +],[ +have_opengles=yes +]) +AC_MSG_RESULT($have_opengles) + +dnl Check for OpenGL ES2 +AC_MSG_CHECKING(for OpenGL ES2 support) +have_opengles2=no +AC_TRY_COMPILE([ + #if defined (__IPHONEOS__) + #include + #include + #else + #include + #include + #endif +],[ +],[ +have_opengles2=yes +]) +AC_MSG_RESULT($have_opengles2) + +GLLIB="" +GLESLIB="" +GLES2LIB="" +OPENGLES1_TARGETS="UNUSED" +OPENGLES2_TARGETS="UNUSED" +OPENGL_TARGETS="UNUSED" +if test x$have_opengles = xyes; then + CFLAGS="$CFLAGS -DHAVE_OPENGLES" + GLESLIB="$XPATH -lGLESv1_CM" + OPENGLES1_TARGETS="TARGETS" +fi +if test x$have_opengles2 = xyes; then + CFLAGS="$CFLAGS -DHAVE_OPENGLES2" + #GLES2LIB="$XPATH -lGLESv2" + OPENGLES2_TARGETS="TARGETS" +fi +if test x$have_opengl = xyes; then + CFLAGS="$CFLAGS -DHAVE_OPENGL" + GLLIB="$XPATH $SYS_GL_LIBS" + OPENGL_TARGETS="TARGETS" +fi + +AC_SUBST(OPENGLES1_TARGETS) +AC_SUBST(OPENGLES2_TARGETS) +AC_SUBST(OPENGL_TARGETS) +AC_SUBST(GLLIB) +AC_SUBST(GLESLIB) +AC_SUBST(GLES2LIB) +AC_SUBST(XLIB) + +dnl Check for SDL_ttf +AC_CHECK_LIB(SDL2_ttf, TTF_Init, have_SDL_ttf=yes) +if test x$have_SDL_ttf = xyes; then + CFLAGS="$CFLAGS -DHAVE_SDL_TTF" + SDL_TTF_LIB="-lSDL2_ttf" +fi +AC_SUBST(SDL_TTF_LIB) + +dnl Finally create all the generated files +AC_OUTPUT([Makefile]) diff --git a/libs/SDL2/test/controllermap.c b/libs/SDL2/test/controllermap.c index 2ca53518a..b52baebfc 100644 --- a/libs/SDL2/test/controllermap.c +++ b/libs/SDL2/test/controllermap.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/loopwave.c b/libs/SDL2/test/loopwave.c index 88d8fc871..09fb2a385 100644 --- a/libs/SDL2/test/loopwave.c +++ b/libs/SDL2/test/loopwave.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/loopwavequeue.c b/libs/SDL2/test/loopwavequeue.c index 3f0a69e15..e1accb40a 100644 --- a/libs/SDL2/test/loopwavequeue.c +++ b/libs/SDL2/test/loopwavequeue.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testatomic.c b/libs/SDL2/test/testatomic.c index 6af9d4bf6..0a7d08424 100644 --- a/libs/SDL2/test/testatomic.c +++ b/libs/SDL2/test/testatomic.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testaudiocapture.c b/libs/SDL2/test/testaudiocapture.c index a418d123c..1a94b0af2 100644 --- a/libs/SDL2/test/testaudiocapture.c +++ b/libs/SDL2/test/testaudiocapture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testaudiohotplug.c b/libs/SDL2/test/testaudiohotplug.c index 374cbb27b..998d319f1 100644 --- a/libs/SDL2/test/testaudiohotplug.c +++ b/libs/SDL2/test/testaudiohotplug.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testaudioinfo.c b/libs/SDL2/test/testaudioinfo.c index adecce9b7..3ee1bfb65 100644 --- a/libs/SDL2/test/testaudioinfo.c +++ b/libs/SDL2/test/testaudioinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testautomation.c b/libs/SDL2/test/testautomation.c index bb799ea43..1a0ecbd12 100644 --- a/libs/SDL2/test/testautomation.c +++ b/libs/SDL2/test/testautomation.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -80,8 +80,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--iterations #] [--execKey #] [--seed string] [--filter suite_name|test_name]\n", - argv[0], SDLTest_CommonUsage(state)); + static const char *options[] = { "[--iterations #]", "[--execKey #]", "[--seed string]", "[--filter suite_name|test_name]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } diff --git a/libs/SDL2/test/testbounds.c b/libs/SDL2/test/testbounds.c index 764809446..7b8876c3c 100644 --- a/libs/SDL2/test/testbounds.c +++ b/libs/SDL2/test/testbounds.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testcustomcursor.c b/libs/SDL2/test/testcustomcursor.c index 469449818..b0b7fa79b 100644 --- a/libs/SDL2/test/testcustomcursor.c +++ b/libs/SDL2/test/testcustomcursor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -203,7 +203,7 @@ main(int argc, char *argv[]) break; } if (consumed < 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDLTest_CommonLogUsage(state, argv[0], NULL); quit(1); } i += consumed; diff --git a/libs/SDL2/test/testdisplayinfo.c b/libs/SDL2/test/testdisplayinfo.c index 0cc5fbdd7..90919baf7 100644 --- a/libs/SDL2/test/testdisplayinfo.c +++ b/libs/SDL2/test/testdisplayinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testdraw2.c b/libs/SDL2/test/testdraw2.c index 91ee7eea2..77a0f11eb 100644 --- a/libs/SDL2/test/testdraw2.c +++ b/libs/SDL2/test/testdraw2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -256,8 +256,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", - argv[0], SDLTest_CommonUsage(state)); + static const char *options[] = { "[--blend none|blend|add|mod]", "[--cyclecolor]", "[--cyclealpha]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); return 1; } i += consumed; diff --git a/libs/SDL2/test/testdrawchessboard.c b/libs/SDL2/test/testdrawchessboard.c index 3dd78e1ac..78e89d2a5 100644 --- a/libs/SDL2/test/testdrawchessboard.c +++ b/libs/SDL2/test/testdrawchessboard.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testdropfile.c b/libs/SDL2/test/testdropfile.c index 1c2a3f0e6..97ab872a2 100644 --- a/libs/SDL2/test/testdropfile.c +++ b/libs/SDL2/test/testdropfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -52,7 +52,7 @@ main(int argc, char *argv[]) consumed = -1; } if (consumed < 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); + SDLTest_CommonLogUsage(state, argv[0], NULL); quit(1); } i += consumed; @@ -75,8 +75,6 @@ main(int argc, char *argv[]) while (!done) { /* Check for events */ while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - if (event.type == SDL_DROPBEGIN) { SDL_Log("Drop beginning on window %u", (unsigned int) event.drop.windowID); } else if (event.type == SDL_DROPCOMPLETE) { @@ -85,8 +83,11 @@ main(int argc, char *argv[]) const char *typestr = (event.type == SDL_DROPFILE) ? "File" : "Text"; char *dropped_filedir = event.drop.file; SDL_Log("%s dropped on window %u: %s", typestr, (unsigned int) event.drop.windowID, dropped_filedir); - SDL_free(dropped_filedir); + /* Normally you'd have to do this, but this is freed in SDLTest_CommonEvent() */ + /*SDL_free(dropped_filedir);*/ } + + SDLTest_CommonEvent(state, &event, &done); } } diff --git a/libs/SDL2/test/testerror.c b/libs/SDL2/test/testerror.c index 87fcab21b..1f42a4fe2 100644 --- a/libs/SDL2/test/testerror.c +++ b/libs/SDL2/test/testerror.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testfile.c b/libs/SDL2/test/testfile.c index e563d77be..85ff8091c 100644 --- a/libs/SDL2/test/testfile.c +++ b/libs/SDL2/test/testfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testfilesystem.c b/libs/SDL2/test/testfilesystem.c index ada4e864c..cc26f34d1 100644 --- a/libs/SDL2/test/testfilesystem.c +++ b/libs/SDL2/test/testfilesystem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testgamecontroller.c b/libs/SDL2/test/testgamecontroller.c index c8616d7cd..4d3c93937 100644 --- a/libs/SDL2/test/testgamecontroller.c +++ b/libs/SDL2/test/testgamecontroller.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testgesture.c b/libs/SDL2/test/testgesture.c index f4b254a65..a41604a6f 100644 --- a/libs/SDL2/test/testgesture.c +++ b/libs/SDL2/test/testgesture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -9,6 +9,7 @@ including commercial applications, and to alter it and redistribute it freely. */ + /* Usage: * Spacebar to begin recording a gesture on all touches. * s to save all touches into "./gestureSave" @@ -22,6 +23,9 @@ #include #endif +#include "SDL_test.h" +#include "SDL_test_common.h" + #define WIDTH 640 #define HEIGHT 480 #define BPP 4 @@ -29,242 +33,231 @@ /* MUST BE A POWER OF 2! */ #define EVENT_BUF_SIZE 256 - #define VERBOSE 0 +static SDLTest_CommonState *state; static SDL_Event events[EVENT_BUF_SIZE]; static int eventWrite; - - static int colors[7] = {0xFF,0xFF00,0xFF0000,0xFFFF00,0x00FFFF,0xFF00FF,0xFFFFFF}; +static int quitting = 0; -SDL_Surface *screen; -SDL_Window *window; -SDL_bool quitting = SDL_FALSE; - -typedef struct { - float x,y; +typedef struct +{ + float x, y; } Point; -typedef struct { - float ang,r; - Point p; +typedef struct +{ + float ang, r; + Point p; } Knob; -static Knob knob; +static Knob knob = { 0.0f, 0.1f, { 0.0f, 0.0f } }; -void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) + +static void +setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) { - Uint32 *pixmem32; - Uint32 colour; - Uint8 r,g,b; - int x = (int)_x; - int y = (int)_y; - float a; + Uint32 *pixmem32; + Uint32 colour; + Uint8 r, g, b; + const int x = (int)_x; + const int y = (int)_y; + float a; - if(x < 0 || x >= screen->w) return; - if(y < 0 || y >= screen->h) return; - - pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x; - - SDL_memcpy(&colour,pixmem32,screen->format->BytesPerPixel); - - SDL_GetRGB(colour,screen->format,&r,&g,&b); - /* r = 0;g = 0; b = 0; */ - a = (float)((col>>24)&0xFF); - if(a == 0) a = 0xFF; /* Hack, to make things easier. */ - a /= 0xFF; - r = (Uint8)(r*(1-a) + ((col>>16)&0xFF)*(a)); - g = (Uint8)(g*(1-a) + ((col>> 8)&0xFF)*(a)); - b = (Uint8)(b*(1-a) + ((col>> 0)&0xFF)*(a)); - colour = SDL_MapRGB( screen->format,r, g, b); - - - *pixmem32 = colour; -} - -void drawLine(SDL_Surface *screen,float x0,float y0,float x1,float y1,unsigned int col) { - float t; - for(t=0;t<1;t+=(float)(1.f/SDL_max(SDL_fabs(x0-x1),SDL_fabs(y0-y1)))) - setpix(screen,x1+t*(x0-x1),y1+t*(y0-y1),col); -} - -void drawCircle(SDL_Surface* screen,float x,float y,float r,unsigned int c) -{ - float tx,ty; - float xr; - for(ty = (float)-SDL_fabs(r);ty <= (float)SDL_fabs((int)r);ty++) { - xr = (float)SDL_sqrt(r*r - ty*ty); - if(r > 0) { /* r > 0 ==> filled circle */ - for(tx=-xr+.5f;tx<=xr-.5;tx++) { - setpix(screen,x+tx,y+ty,c); - } + if ( (x < 0) || (x >= screen->w) || (y < 0) || (y >= screen->h) ) { + return; } - else { - setpix(screen,x-xr+.5f,y+ty,c); - setpix(screen,x+xr-.5f,y+ty,c); + + pixmem32 = (Uint32 *) screen->pixels + y * screen->pitch / BPP + x; + + SDL_memcpy(&colour, pixmem32, screen->format->BytesPerPixel); + + SDL_GetRGB(colour,screen->format,&r,&g,&b); + + /* r = 0;g = 0; b = 0; */ + a = (float) ((col >> 24) & 0xFF); + if (a == 0) { + a = 0xFF; /* Hack, to make things easier. */ } - } + + a = (a == 0.0f) ? 1 : (a / 255.0f); + r = (Uint8) (r * (1 - a) + ((col >> 16) & 0xFF) * a); + g = (Uint8) (g * (1 - a) + ((col >> 8) & 0xFF) * a); + b = (Uint8) (b * (1 - a) + ((col >> 0) & 0xFF) * a); + colour = SDL_MapRGB(screen->format, r, g, b); + + *pixmem32 = colour; } -void drawKnob(SDL_Surface* screen,Knob k) { - drawCircle(screen,k.p.x*screen->w,k.p.y*screen->h,k.r*screen->w,0xFFFFFF); - drawCircle(screen,(k.p.x+k.r/2*SDL_cosf(k.ang))*screen->w, - (k.p.y+k.r/2*SDL_sinf(k.ang))*screen->h,k.r/4*screen->w,0); -} - -void DrawScreen(SDL_Surface* screen, SDL_Window* window) +static void +drawLine(SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned int col) { - int i; -#if 1 - SDL_FillRect(screen, NULL, 0); -#else - int x, y; - for(y = 0;y < screen->h;y++) - for(x = 0;x < screen->w;x++) - setpix(screen,(float)x,(float)y,((x%255)<<16) + ((y%255)<<8) + (x+y)%255); -#endif - - /* draw Touch History */ - for(i = eventWrite; i < eventWrite+EVENT_BUF_SIZE; ++i) { - const SDL_Event *event = &events[i&(EVENT_BUF_SIZE-1)]; - float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; - float x, y; - unsigned int c, col; - - if(event->type == SDL_FINGERMOTION || - event->type == SDL_FINGERDOWN || - event->type == SDL_FINGERUP) { - x = event->tfinger.x; - y = event->tfinger.y; - - /* draw the touch: */ - c = colors[event->tfinger.fingerId%7]; - col = ((unsigned int)(c*(.1+.85))) | (unsigned int)(0xFF*age)<<24; - - if(event->type == SDL_FINGERMOTION) - drawCircle(screen,x*screen->w,y*screen->h,5,col); - else if(event->type == SDL_FINGERDOWN) - drawCircle(screen,x*screen->w,y*screen->h,-10,col); + float t; + for (t = 0; t < 1; t += (float) (1.0f / SDL_max(SDL_fabs(x0 - x1), SDL_fabs(y0 - y1)))) { + setpix(screen, x1 + t * (x0 - x1), y1 + t * (y0 - y1), col); } - } - - if(knob.p.x > 0) - drawKnob(screen,knob); - - SDL_UpdateWindowSurface(window); } -/* Returns a new SDL_Window if window is NULL or window if not. */ -SDL_Window* initWindow(SDL_Window *window, int width,int height) +static void +drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c) { - if (!window) { - window = SDL_CreateWindow("Gesture Test", - SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - width, height, SDL_WINDOW_RESIZABLE); - } - return window; + float tx,ty, xr; + for (ty = (float) -SDL_fabs(r); ty <= (float) SDL_fabs((int) r); ty++) { + xr = (float) SDL_sqrt(r * r - ty * ty); + if (r > 0) { /* r > 0 ==> filled circle */ + for(tx = -xr + 0.5f; tx <= xr - 0.5f; tx++) { + setpix(screen, x + tx, y + ty, c); + } + } else { + setpix(screen, x - xr + 0.5f, y + ty, c); + setpix(screen, x + xr - 0.5f, y + ty, c); + } + } } -void loop() +static void +drawKnob(SDL_Surface *screen, const Knob *k) +{ + drawCircle(screen, k->p.x * screen->w, k->p.y * screen->h, k->r * screen->w, 0xFFFFFF); + drawCircle(screen, (k->p.x + k->r / 2 * SDL_cosf(k->ang)) * screen->w, + (k->p.y + k->r / 2 * SDL_sinf(k->ang)) * screen->h, k->r / 4 * screen->w, 0); +} + +static void +DrawScreen(SDL_Window *window) +{ + SDL_Surface *screen = SDL_GetWindowSurface(window); + int i; + + if (!screen) { + return; + } + + SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 75, 75, 75)); + + /* draw Touch History */ + for (i = eventWrite; i < eventWrite + EVENT_BUF_SIZE; ++i) { + const SDL_Event *event = &events[i & (EVENT_BUF_SIZE - 1)]; + const float age = (float)(i - eventWrite) / EVENT_BUF_SIZE; + float x, y; + unsigned int c, col; + + if ( (event->type == SDL_FINGERMOTION) || + (event->type == SDL_FINGERDOWN) || + (event->type == SDL_FINGERUP) ) { + x = event->tfinger.x; + y = event->tfinger.y; + + /* draw the touch: */ + c = colors[event->tfinger.fingerId % 7]; + col = ((unsigned int) (c * (0.1f + 0.85f))) | (unsigned int) (0xFF * age) << 24; + + if (event->type == SDL_FINGERMOTION) { + drawCircle(screen, x * screen->w, y * screen->h, 5, col); + } else if (event->type == SDL_FINGERDOWN) { + drawCircle(screen, x * screen->w, y * screen->h, -10, col); + } + } + } + + if (knob.p.x > 0) { + drawKnob(screen, &knob); + } + + SDL_UpdateWindowSurface(window); +} + +static void +loop(void) { SDL_Event event; SDL_RWops *stream; + int i; - while(SDL_PollEvent(&event)) - { - /* Record _all_ events */ - events[eventWrite & (EVENT_BUF_SIZE-1)] = event; - eventWrite++; + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &quitting); - switch (event.type) - { - case SDL_QUIT: - quitting = SDL_TRUE; - break; - case SDL_KEYDOWN: - switch (event.key.keysym.sym) - { - case SDLK_i: - { - int i; - for (i = 0; i < SDL_GetNumTouchDevices(); ++i) { - SDL_TouchID id = SDL_GetTouchDevice(i); - SDL_Log("Fingers Down on device %"SDL_PRIs64": %d", id, SDL_GetNumTouchFingers(id)); - } - break; - } - case SDLK_SPACE: - SDL_RecordGesture(-1); - break; - case SDLK_s: - stream = SDL_RWFromFile("gestureSave", "w"); - SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream)); - SDL_RWclose(stream); - break; - case SDLK_l: - stream = SDL_RWFromFile("gestureSave", "r"); - SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream)); - SDL_RWclose(stream); - break; - case SDLK_ESCAPE: - quitting = SDL_TRUE; - break; + /* Record _all_ events */ + events[eventWrite & (EVENT_BUF_SIZE-1)] = event; + eventWrite++; + + switch (event.type) { + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_i: { + for (i = 0; i < SDL_GetNumTouchDevices(); ++i) { + const SDL_TouchID id = SDL_GetTouchDevice(i); + SDL_Log("Fingers Down on device %"SDL_PRIs64": %d", id, SDL_GetNumTouchFingers(id)); + } + break; + } + + case SDLK_SPACE: + SDL_RecordGesture(-1); + break; + + case SDLK_s: + stream = SDL_RWFromFile("gestureSave", "w"); + SDL_Log("Wrote %i templates", SDL_SaveAllDollarTemplates(stream)); + SDL_RWclose(stream); + break; + + case SDLK_l: + stream = SDL_RWFromFile("gestureSave", "r"); + SDL_Log("Loaded: %i", SDL_LoadDollarTemplates(-1, stream)); + SDL_RWclose(stream); + break; + } + break; + +#if VERBOSE + case SDL_FINGERMOTION: + SDL_Log("Finger: %"SDL_PRIs64",x: %f, y: %f",event.tfinger.fingerId, + event.tfinger.x,event.tfinger.y); + break; + + case SDL_FINGERDOWN: + SDL_Log("Finger: %"SDL_PRIs64" down - x: %f, y: %f", + event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); + break; + + case SDL_FINGERUP: + SDL_Log("Finger: %"SDL_PRIs64" up - x: %f, y: %f", + event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); + break; +#endif + + case SDL_MULTIGESTURE: +#if VERBOSE + SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", + event.mgesture.x, event.mgesture.y, + event.mgesture.dTheta, event.mgesture.dDist); + SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers); +#endif + + knob.p.x = event.mgesture.x; + knob.p.y = event.mgesture.y; + knob.ang += event.mgesture.dTheta; + knob.r += event.mgesture.dDist; + break; + + case SDL_DOLLARGESTURE: + SDL_Log("Gesture %"SDL_PRIs64" performed, error: %f", + event.dgesture.gestureId, event.dgesture.error); + break; + + case SDL_DOLLARRECORD: + SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId); + break; + } + } + + for (i = 0; i < state->num_windows; ++i) { + if (state->windows[i]) { + DrawScreen(state->windows[i]); } - break; - case SDL_WINDOWEVENT: - if (event.window.event == SDL_WINDOWEVENT_RESIZED) { - if (!(window = initWindow(window, event.window.data1, event.window.data2)) || - !(screen = SDL_GetWindowSurface(window))) - { - SDL_Quit(); - exit(1); - } - } - break; - case SDL_FINGERMOTION: -#if VERBOSE - SDL_Log("Finger: %"SDL_PRIs64",x: %f, y: %f",event.tfinger.fingerId, - event.tfinger.x,event.tfinger.y); -#endif - break; - case SDL_FINGERDOWN: -#if VERBOSE - SDL_Log("Finger: %"SDL_PRIs64" down - x: %f, y: %f", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); -#endif - break; - case SDL_FINGERUP: -#if VERBOSE - SDL_Log("Finger: %"SDL_PRIs64" up - x: %f, y: %f", - event.tfinger.fingerId,event.tfinger.x,event.tfinger.y); -#endif - break; - case SDL_MULTIGESTURE: -#if VERBOSE - SDL_Log("Multi Gesture: x = %f, y = %f, dAng = %f, dR = %f", - event.mgesture.x, - event.mgesture.y, - event.mgesture.dTheta, - event.mgesture.dDist); - SDL_Log("MG: numDownTouch = %i",event.mgesture.numFingers); -#endif - knob.p.x = event.mgesture.x; - knob.p.y = event.mgesture.y; - knob.ang += event.mgesture.dTheta; - knob.r += event.mgesture.dDist; - break; - case SDL_DOLLARGESTURE: - SDL_Log("Gesture %"SDL_PRIs64" performed, error: %f", - event.dgesture.gestureId, - event.dgesture.error); - break; - case SDL_DOLLARRECORD: - SDL_Log("Recorded gesture: %"SDL_PRIs64"",event.dgesture.gestureId); - break; - } } - DrawScreen(screen, window); #ifdef __EMSCRIPTEN__ if (quitting) { @@ -275,35 +268,30 @@ void loop() int main(int argc, char* argv[]) { - window = NULL; - screen = NULL; - quitting = SDL_FALSE; + state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); + if (!state) { + return 1; + } - /* Enable standard application logging */ - SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + state->window_title = "Gesture Test"; + state->window_w = WIDTH; + state->window_h = HEIGHT; + state->skip_renderer = SDL_TRUE; - /* gesture variables */ - knob.r = .1f; - knob.ang = 0; - - if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; - - if (!(window = initWindow(window, WIDTH, HEIGHT)) || - !(screen = SDL_GetWindowSurface(window))) - { - SDL_Quit(); - return 1; - } + if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { + SDLTest_CommonQuit(state); + return 1; + } #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(loop, 0, 1); #else - while(!quitting) { + while (!quitting) { loop(); } #endif - SDL_Quit(); - return 0; + SDLTest_CommonQuit(state); + return 0; } diff --git a/libs/SDL2/test/testgl2.c b/libs/SDL2/test/testgl2.c index dd01d0e29..a8bc181a3 100644 --- a/libs/SDL2/test/testgl2.c +++ b/libs/SDL2/test/testgl2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -218,6 +218,7 @@ main(int argc, char *argv[]) Uint32 then, now, frames; int status; int dw, dh; + int swap_interval = 0; /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); @@ -247,8 +248,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--fsaa n] [--accel n]\n", argv[0], - SDLTest_CommonUsage(state)); + static const char *options[] = { "[--fsaa n]", "[--accel n]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } i += consumed; @@ -289,11 +290,15 @@ main(int argc, char *argv[]) if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { /* try late-swap-tearing first. If not supported, try normal vsync. */ - if (SDL_GL_SetSwapInterval(-1) == -1) { + if (SDL_GL_SetSwapInterval(-1) == 0) { + swap_interval = -1; + } else { SDL_GL_SetSwapInterval(1); + swap_interval = 1; } } else { SDL_GL_SetSwapInterval(0); /* disable vsync. */ + swap_interval = 0; } SDL_GetCurrentDisplayMode(0, &mode); @@ -377,16 +382,35 @@ main(int argc, char *argv[]) then = SDL_GetTicks(); done = 0; while (!done) { + SDL_bool update_swap_interval = SDL_FALSE; + /* Check for events */ ++frames; while (SDL_PollEvent(&event)) { SDLTest_CommonEvent(state, &event, &done); + if (event.type == SDL_KEYDOWN) { + if (event.key.keysym.sym == SDLK_o) { + swap_interval--; + update_swap_interval = SDL_TRUE; + } else if (event.key.keysym.sym == SDLK_p) { + swap_interval++; + update_swap_interval = SDL_TRUE; + } + } } + + if (update_swap_interval) { + SDL_Log("Swap interval to be set to %d\n", swap_interval); + } + for (i = 0; i < state->num_windows; ++i) { int w, h; if (state->windows[i] == NULL) continue; SDL_GL_MakeCurrent(state->windows[i], context); + if (update_swap_interval) { + SDL_GL_SetSwapInterval(swap_interval); + } SDL_GL_GetDrawableSize(state->windows[i], &w, &h); ctx.glViewport(0, 0, w, h); Render(); diff --git a/libs/SDL2/test/testgles.c b/libs/SDL2/test/testgles.c index 96895da0f..c4ea45f54 100644 --- a/libs/SDL2/test/testgles.c +++ b/libs/SDL2/test/testgles.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -146,8 +146,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], - SDLTest_CommonUsage(state)); + static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } i += consumed; diff --git a/libs/SDL2/test/testgles2.c b/libs/SDL2/test/testgles2.c index c4578a5cc..641a8975c 100644 --- a/libs/SDL2/test/testgles2.c +++ b/libs/SDL2/test/testgles2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -518,8 +518,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log ("Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], - SDLTest_CommonUsage(state)); + static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } i += consumed; diff --git a/libs/SDL2/test/testhotplug.c b/libs/SDL2/test/testhotplug.c index 72c90e8d9..4a6a954f7 100644 --- a/libs/SDL2/test/testhotplug.c +++ b/libs/SDL2/test/testhotplug.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testiconv.c b/libs/SDL2/test/testiconv.c index 47e8c377a..4729b58fa 100644 --- a/libs/SDL2/test/testiconv.c +++ b/libs/SDL2/test/testiconv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testime.c b/libs/SDL2/test/testime.c index 77bb86962..45bcdb559 100644 --- a/libs/SDL2/test/testime.c +++ b/libs/SDL2/test/testime.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testintersections.c b/libs/SDL2/test/testintersections.c index 619df0640..0c824cb95 100644 --- a/libs/SDL2/test/testintersections.c +++ b/libs/SDL2/test/testintersections.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -315,8 +315,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha]\n", - argv[0], SDLTest_CommonUsage(state)); + static const char *options[] = { "[--blend none|blend|add|mod]", "[--cyclecolor]", "[--cyclealpha]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); return 1; } i += consumed; diff --git a/libs/SDL2/test/testjoystick.c b/libs/SDL2/test/testjoystick.c index bca749244..16877a152 100644 --- a/libs/SDL2/test/testjoystick.c +++ b/libs/SDL2/test/testjoystick.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testkeys.c b/libs/SDL2/test/testkeys.c index 73f880e13..fc770d3e2 100644 --- a/libs/SDL2/test/testkeys.c +++ b/libs/SDL2/test/testkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testloadso.c b/libs/SDL2/test/testloadso.c index c6fa33106..e5273815f 100644 --- a/libs/SDL2/test/testloadso.c +++ b/libs/SDL2/test/testloadso.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testlock.c b/libs/SDL2/test/testlock.c index 8299a9a67..b6e2935ac 100644 --- a/libs/SDL2/test/testlock.c +++ b/libs/SDL2/test/testlock.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testmessage.c b/libs/SDL2/test/testmessage.c index 8488d8eda..4ce8a13c8 100644 --- a/libs/SDL2/test/testmessage.c +++ b/libs/SDL2/test/testmessage.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testmultiaudio.c b/libs/SDL2/test/testmultiaudio.c index 52a4cac7d..e702b39e9 100644 --- a/libs/SDL2/test/testmultiaudio.c +++ b/libs/SDL2/test/testmultiaudio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testnative.c b/libs/SDL2/test/testnative.c index 674d9d3b4..c1facd398 100644 --- a/libs/SDL2/test/testnative.c +++ b/libs/SDL2/test/testnative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testnative.h b/libs/SDL2/test/testnative.h index 29d85fb32..1f9275311 100644 --- a/libs/SDL2/test/testnative.h +++ b/libs/SDL2/test/testnative.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testnativew32.c b/libs/SDL2/test/testnativew32.c index 7e96bc697..544c413cd 100644 --- a/libs/SDL2/test/testnativew32.c +++ b/libs/SDL2/test/testnativew32.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testnativex11.c b/libs/SDL2/test/testnativex11.c index 386c25e9e..a8303c714 100644 --- a/libs/SDL2/test/testnativex11.c +++ b/libs/SDL2/test/testnativex11.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testoverlay2.c b/libs/SDL2/test/testoverlay2.c index daf07d3e9..6da1f960c 100644 --- a/libs/SDL2/test/testoverlay2.c +++ b/libs/SDL2/test/testoverlay2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -252,7 +252,7 @@ main(int argc, char **argv) } while (argc > 1) { - if (strcmp(argv[1], "-fps") == 0) { + if (SDL_strcmp(argv[1], "-fps") == 0) { if (argv[2]) { fps = SDL_atoi(argv[2]); if (fps == 0) { @@ -272,11 +272,11 @@ main(int argc, char **argv) "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } - } else if (strcmp(argv[1], "-nodelay") == 0) { + } else if (SDL_strcmp(argv[1], "-nodelay") == 0) { nodelay = 1; argv += 1; argc -= 1; - } else if (strcmp(argv[1], "-scale") == 0) { + } else if (SDL_strcmp(argv[1], "-scale") == 0) { if (argv[2]) { scale = SDL_atoi(argv[2]); if (scale == 0) { @@ -296,8 +296,8 @@ main(int argc, char **argv) "The -fps option requires an argument [from 1 to 1000], default is 12.\n"); quit(10); } - } else if ((strcmp(argv[1], "-help") == 0) - || (strcmp(argv[1], "-h") == 0)) { + } else if ((SDL_strcmp(argv[1], "-help") == 0) + || (SDL_strcmp(argv[1], "-h") == 0)) { PrintUsage(argv[0]); quit(0); } else { @@ -307,7 +307,7 @@ main(int argc, char **argv) break; } - RawMooseData = (Uint8 *) malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); + RawMooseData = (Uint8 *) SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); if (RawMooseData == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n"); quit(1); @@ -317,7 +317,7 @@ main(int argc, char **argv) handle = SDL_RWFromFile("moose.dat", "rb"); if (handle == NULL) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); - free(RawMooseData); + SDL_free(RawMooseData); quit(2); } @@ -335,21 +335,21 @@ main(int argc, char **argv) SDL_WINDOW_RESIZABLE); if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); - free(RawMooseData); + SDL_free(RawMooseData); quit(4); } renderer = SDL_CreateRenderer(window, -1, 0); if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); - free(RawMooseData); + SDL_free(RawMooseData); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); if (!MooseTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); - free(RawMooseData); + SDL_free(RawMooseData); quit(5); } /* Uncomment this to check vertex color with a YUV texture */ @@ -373,7 +373,7 @@ main(int argc, char **argv) 0, 100); } - free(RawMooseData); + SDL_free(RawMooseData); /* set the start frame */ i = 0; diff --git a/libs/SDL2/test/testplatform.c b/libs/SDL2/test/testplatform.c index 1c1d2dcd8..44128111b 100644 --- a/libs/SDL2/test/testplatform.c +++ b/libs/SDL2/test/testplatform.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testpower.c b/libs/SDL2/test/testpower.c index adb58832a..985607788 100644 --- a/libs/SDL2/test/testpower.c +++ b/libs/SDL2/test/testpower.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testqsort.c b/libs/SDL2/test/testqsort.c index e83b0731e..8286832c3 100644 --- a/libs/SDL2/test/testqsort.c +++ b/libs/SDL2/test/testqsort.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testrelative.c b/libs/SDL2/test/testrelative.c index 816329ff5..3b61be4fa 100644 --- a/libs/SDL2/test/testrelative.c +++ b/libs/SDL2/test/testrelative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testrendercopyex.c b/libs/SDL2/test/testrendercopyex.c index 209a35157..fc01b654e 100644 --- a/libs/SDL2/test/testrendercopyex.c +++ b/libs/SDL2/test/testrendercopyex.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -174,18 +174,10 @@ main(int argc, char *argv[]) if (!state) { return 1; } - for (i = 1; i < argc;) { - int consumed; - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - return 1; - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); + if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { + SDLTest_CommonQuit(state); + return 1; } drawstates = SDL_stack_alloc(DrawState, state->num_windows); diff --git a/libs/SDL2/test/testrendertarget.c b/libs/SDL2/test/testrendertarget.c index 7d24d8aea..bc50007ff 100644 --- a/libs/SDL2/test/testrendertarget.c +++ b/libs/SDL2/test/testrendertarget.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -275,8 +275,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--composite]\n", - argv[0], SDLTest_CommonUsage(state)); + static const char *options[] = { "[--composite]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } i += consumed; diff --git a/libs/SDL2/test/testresample.c b/libs/SDL2/test/testresample.c index 4234d9e45..ded2ae3d3 100644 --- a/libs/SDL2/test/testresample.c +++ b/libs/SDL2/test/testresample.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testrumble.c b/libs/SDL2/test/testrumble.c index 908a6aafb..c8473f56a 100644 --- a/libs/SDL2/test/testrumble.c +++ b/libs/SDL2/test/testrumble.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testscale.c b/libs/SDL2/test/testscale.c index e1b46fcc8..363927721 100644 --- a/libs/SDL2/test/testscale.c +++ b/libs/SDL2/test/testscale.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -164,18 +164,10 @@ main(int argc, char *argv[]) if (!state) { return 1; } - for (i = 1; i < argc;) { - int consumed; - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - return 1; - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); + if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { + SDLTest_CommonQuit(state); + return 1; } drawstates = SDL_stack_alloc(DrawState, state->num_windows); diff --git a/libs/SDL2/test/testsem.c b/libs/SDL2/test/testsem.c index 884763e6a..804344020 100644 --- a/libs/SDL2/test/testsem.c +++ b/libs/SDL2/test/testsem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testsensor.c b/libs/SDL2/test/testsensor.c index 00bfd137d..0896c3067 100644 --- a/libs/SDL2/test/testsensor.c +++ b/libs/SDL2/test/testsensor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testshader.c b/libs/SDL2/test/testshader.c index ee0ccdad2..c791cd5b9 100644 --- a/libs/SDL2/test/testshader.c +++ b/libs/SDL2/test/testshader.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testshape.c b/libs/SDL2/test/testshape.c index 7e451e667..dab3a8747 100644 --- a/libs/SDL2/test/testshape.c +++ b/libs/SDL2/test/testshape.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testsprite2.c b/libs/SDL2/test/testsprite2.c index b0348f85d..76ac7ebd1 100644 --- a/libs/SDL2/test/testsprite2.c +++ b/libs/SDL2/test/testsprite2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,6 +37,8 @@ static SDL_Rect *positions; static SDL_Rect *velocities; static int sprite_w, sprite_h; static SDL_BlendMode blendMode = SDL_BLENDMODE_BLEND; +static Uint32 next_fps_check, frames; +static const Uint32 fps_check_delay = 5000; /* Number of iterations to move sprites - used for visual tests. */ /* -1: infinite random moves (default); >=0: enables N deterministic moves */ @@ -244,6 +246,7 @@ MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) void loop() { + Uint32 now; int i; SDL_Event event; @@ -261,13 +264,24 @@ loop() emscripten_cancel_main_loop(); } #endif + + frames++; + now = SDL_GetTicks(); + if (SDL_TICKS_PASSED(now, next_fps_check)) { + /* Print out some timing information */ + const Uint32 then = next_fps_check - fps_check_delay; + const double fps = ((double) frames * 1000) / (now - then); + SDL_Log("%2.2f frames per second\n", fps); + next_fps_check = now + fps_check_delay; + frames = 0; + } + } int main(int argc, char *argv[]) { int i; - Uint32 then, now, frames; Uint64 seed; const char *icon = "icon.bmp"; @@ -326,8 +340,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--blend none|blend|add|mod] [--cyclecolor] [--cyclealpha] [--iterations N] [num_sprites] [icon.bmp]\n", - argv[0], SDLTest_CommonUsage(state)); + static const char *options[] = { "[--blend none|blend|add|mod]", "[--cyclecolor]", "[--cyclealpha]", "[--iterations N]", "[num_sprites]", "[icon.bmp]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } i += consumed; @@ -384,24 +398,17 @@ main(int argc, char *argv[]) /* Main render loop */ frames = 0; - then = SDL_GetTicks(); + next_fps_check = SDL_GetTicks() + fps_check_delay; done = 0; #ifdef __EMSCRIPTEN__ emscripten_set_main_loop(loop, 0, 1); #else while (!done) { - ++frames; loop(); } #endif - /* Print out some timing information */ - now = SDL_GetTicks(); - if (now > then) { - double fps = ((double) frames * 1000) / (now - then); - SDL_Log("%2.2f frames per second\n", fps); - } quit(0); return 0; } diff --git a/libs/SDL2/test/testspriteminimal.c b/libs/SDL2/test/testspriteminimal.c index 92560002a..3eebdf8cf 100644 --- a/libs/SDL2/test/testspriteminimal.c +++ b/libs/SDL2/test/testspriteminimal.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/teststreaming.c b/libs/SDL2/test/teststreaming.c index 7ec689106..ade436bf2 100644 --- a/libs/SDL2/test/teststreaming.c +++ b/libs/SDL2/test/teststreaming.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testthread.c b/libs/SDL2/test/testthread.c index 4555a1e94..34c5d8821 100644 --- a/libs/SDL2/test/testthread.c +++ b/libs/SDL2/test/testthread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testtimer.c b/libs/SDL2/test/testtimer.c index 34764c1c9..e3fa93acf 100644 --- a/libs/SDL2/test/testtimer.c +++ b/libs/SDL2/test/testtimer.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testver.c b/libs/SDL2/test/testver.c index 1ae008345..2c39c637c 100644 --- a/libs/SDL2/test/testver.c +++ b/libs/SDL2/test/testver.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testviewport.c b/libs/SDL2/test/testviewport.c index 4b8d20e76..2706ab2ff 100644 --- a/libs/SDL2/test/testviewport.c +++ b/libs/SDL2/test/testviewport.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -161,8 +161,8 @@ main(int argc, char *argv[]) } } if (consumed < 0) { - SDL_Log("Usage: %s %s [--target]\n", - argv[0], SDLTest_CommonUsage(state)); + static const char *options[] = { "[--target]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); quit(1); } i += consumed; diff --git a/libs/SDL2/test/testvulkan.c b/libs/SDL2/test/testvulkan.c index cd682af1f..a0c1113a1 100644 --- a/libs/SDL2/test/testvulkan.c +++ b/libs/SDL2/test/testvulkan.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -1119,7 +1119,7 @@ static SDL_bool render(void) int main(int argc, char *argv[]) { int fsaa, accel; - int i, done; + int done; SDL_DisplayMode mode; SDL_Event event; Uint32 then, now, frames; @@ -1138,27 +1138,15 @@ int main(int argc, char *argv[]) { return 1; } - for(i = 1; i < argc;) - { - int consumed; - - consumed = SDLTest_CommonArg(state, i); - if(consumed < 0) - { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } /* Set Vulkan parameters */ state->window_flags |= SDL_WINDOW_VULKAN; state->num_windows = 1; state->skip_renderer = 1; - if(!SDLTest_CommonInit(state)) - { - quit(2); + if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { + SDLTest_CommonQuit(state); + return 1; } SDL_GetCurrentDisplayMode(0, &mode); diff --git a/libs/SDL2/test/testwm2.c b/libs/SDL2/test/testwm2.c index 5da387309..9ec867b04 100644 --- a/libs/SDL2/test/testwm2.c +++ b/libs/SDL2/test/testwm2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -129,21 +129,10 @@ main(int argc, char *argv[]) if (!state) { return 1; } - for (i = 1; i < argc;) { - int consumed; - consumed = SDLTest_CommonArg(state, i); - if (consumed == 0) { - consumed = -1; - } - if (consumed < 0) { - SDL_Log("Usage: %s %s\n", argv[0], SDLTest_CommonUsage(state)); - quit(1); - } - i += consumed; - } - if (!SDLTest_CommonInit(state)) { - quit(2); + if (!SDLTest_CommonDefaultArgs(state, argc, argv) || !SDLTest_CommonInit(state)) { + SDLTest_CommonQuit(state); + return 1; } SDL_EventState(SDL_DROPFILE, SDL_ENABLE); diff --git a/libs/SDL2/test/testyuv.c b/libs/SDL2/test/testyuv.c index f52ab9f72..1b05f0ab4 100644 --- a/libs/SDL2/test/testyuv.c +++ b/libs/SDL2/test/testyuv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testyuv_cvt.c b/libs/SDL2/test/testyuv_cvt.c index 553a3fa18..91e5071e5 100644 --- a/libs/SDL2/test/testyuv_cvt.c +++ b/libs/SDL2/test/testyuv_cvt.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/testyuv_cvt.h b/libs/SDL2/test/testyuv_cvt.h index bd845878f..15ac93260 100644 --- a/libs/SDL2/test/testyuv_cvt.h +++ b/libs/SDL2/test/testyuv_cvt.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/test/torturethread.c b/libs/SDL2/test/torturethread.c index 9b1a407ee..e41280d7a 100644 --- a/libs/SDL2/test/torturethread.c +++ b/libs/SDL2/test/torturethread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/bin/SDL2.dll b/libs/SDL2/x86_64-w64-mingw32/bin/SDL2.dll index 934f8091c..0edb386ee 100755 Binary files a/libs/SDL2/x86_64-w64-mingw32/bin/SDL2.dll and b/libs/SDL2/x86_64-w64-mingw32/bin/SDL2.dll differ diff --git a/libs/SDL2/x86_64-w64-mingw32/bin/sdl2-config b/libs/SDL2/x86_64-w64-mingw32/bin/sdl2-config index 9809f6002..0b03712c7 100755 --- a/libs/SDL2/x86_64-w64-mingw32/bin/sdl2-config +++ b/libs/SDL2/x86_64-w64-mingw32/bin/sdl2-config @@ -39,7 +39,7 @@ while test $# -gt 0; do echo $exec_prefix ;; --version) - echo 2.0.9 + echo 2.0.10 ;; --cflags) echo -I${prefix}/include/SDL2 -Dmain=SDL_main @@ -49,7 +49,7 @@ while test $# -gt 0; do ;; --static-libs) # --libs|--static-libs) - echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc + echo -L${exec_prefix}/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc ;; *) echo "${usage}" 1>&2 diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL.h index fc35a419e..88dce0c03 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_assert.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_assert.h index b38f928ae..8baecb63e 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_assert.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h index b2287748c..deee35f91 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -162,12 +162,29 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__GNUC__) && defined(__arm__) -#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) +#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ +/* Information from: + https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 + + The Linux kernel provides a helper function which provides the right code for a memory barrier, + hard-coded at address 0xffff0fa0 +*/ +typedef void (*SDL_KernelMemoryBarrierFunc)(); +#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() +#elif 0 /* defined(__QNXNTO__) */ +#include + +#define SDL_MemoryBarrierRelease() __cpu_membarrier() +#define SDL_MemoryBarrierAcquire() __cpu_membarrier() +#else +#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) #ifdef __thumb__ /* The mcr instruction isn't available in thumb mode, use real functions */ +#define SDL_MEMORY_BARRIER_USES_FUNCTION #define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() #define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() #else @@ -177,6 +194,7 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); #else #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") +#endif /* __LINUX__ || __ANDROID__ */ #endif /* __GNUC__ && __arm__ */ #else #if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_audio.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_audio.h index d3e1bface..305c01a9d 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_audio.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -420,23 +420,56 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, /* @} *//* Pause audio functions */ /** - * This function loads a WAVE from the data source, automatically freeing - * that source if \c freesrc is non-zero. For example, to load a WAVE file, - * you could do: + * \brief Load the audio data of a WAVE file into memory + * + * Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len + * to be valid pointers. The entire data portion of the file is then loaded + * into memory and decoded if necessary. + * + * If \c freesrc is non-zero, the data source gets automatically closed and + * freed before the function returns. + * + * Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), + * IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and + * µ-law (8 bits). Other formats are currently unsupported and cause an error. + * + * If this function succeeds, the pointer returned by it is equal to \c spec + * and the pointer to the audio data allocated by the function is written to + * \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec + * members \c freq, \c channels, and \c format are set to the values of the + * audio data in the buffer. The \c samples member is set to a sane default and + * all others are set to zero. + * + * It's necessary to use SDL_FreeWAV() to free the audio data returned in + * \c audio_buf when it is no longer used. + * + * Because of the underspecification of the Waveform format, there are many + * problematic files in the wild that cause issues with strict decoders. To + * provide compatibility with these files, this decoder is lenient in regards + * to the truncation of the file, the fact chunk, and the size of the RIFF + * chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, + * and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the + * loading process. + * + * Any file that is invalid (due to truncation, corruption, or wrong values in + * the headers), too big, or unsupported causes an error. Additionally, any + * critical I/O error from the data source will terminate the loading process + * with an error. The function returns NULL on error and in all cases (with the + * exception of \c src being NULL), an appropriate error message will be set. + * + * It is required that the data source supports seeking. + * + * Example: * \code * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); * \endcode * - * If this function succeeds, it returns the given SDL_AudioSpec, - * filled with the audio data format of the wave data, and sets - * \c *audio_buf to a malloc()'d buffer containing the audio data, - * and sets \c *audio_len to the length of that audio buffer, in bytes. - * You need to free the audio buffer with SDL_FreeWAV() when you are - * done with it. - * - * This function returns NULL and sets the SDL error message if the - * wave file cannot be opened, uses an unknown data format, or is - * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + * \param src The data source with the WAVE data + * \param freesrc A integer value that makes the function close the data source if non-zero + * \param spec A pointer filled with the audio format of the audio data + * \param audio_buf A pointer filled with the audio data allocated by the function + * \param audio_len A pointer filled with the length of the audio data buffer in bytes + * \return NULL on error, or non-NULL on success. */ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_bits.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_bits.h index eb8322f0d..b116cc8d0 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_bits.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -101,6 +101,15 @@ SDL_MostSignificantBitIndex32(Uint32 x) #endif } +SDL_FORCE_INLINE SDL_bool +SDL_HasExactlyOneBitSet32(Uint32 x) +{ + if (x && !(x & (x - 1))) { + return SDL_TRUE; + } + return SDL_FALSE; +} + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h index 36a5ea76f..6f0a22b99 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -90,12 +90,12 @@ typedef enum /** * \brief Create a custom blend mode, which may or may not be supported by a given renderer * - * \param srcColorFactor - * \param dstColorFactor - * \param colorOperation - * \param srcAlphaFactor - * \param dstAlphaFactor - * \param alphaOperation + * \param srcColorFactor source color factor + * \param dstColorFactor destination color factor + * \param colorOperation color operation + * \param srcAlphaFactor source alpha factor + * \param dstAlphaFactor destination alpha factor + * \param alphaOperation alpha operation * * The result of the blend mode operation will be: * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h index f28751ebb..c4f8766ce 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_config.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_config.h index c58be8e72..395ad7c26 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_config.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_config.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h index ee3a47e84..296df01aa 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -41,24 +41,43 @@ #else #include #ifndef _WIN64 +#ifndef __MMX__ #define __MMX__ +#endif +#ifndef __3dNOW__ #define __3dNOW__ #endif +#endif +#ifndef __SSE__ #define __SSE__ +#endif +#ifndef __SSE2__ #define __SSE2__ +#endif #endif /* __clang__ */ #elif defined(__MINGW64_VERSION_MAJOR) #include #else -#ifdef __ALTIVEC__ -#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H) +/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ +#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) #include -#undef pixel -#undef bool #endif -#endif -#if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H) -#include +#if !defined(SDL_DISABLE_ARM_NEON_H) +# if defined(__ARM_NEON) +# include +# elif defined(__WINDOWS__) || defined(__WINRT__) +/* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */ +# if defined(_M_ARM) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# if defined (_M_ARM64) +# include +# include +# define __ARM_NEON 1 /* Set __ARM_NEON so that it can be used elsewhere, at compile time */ +# endif +# endif #endif #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) #include @@ -177,6 +196,69 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); */ extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); +/** + * \brief Report the alignment this system needs for SIMD allocations. + * + * This will return the minimum number of bytes to which a pointer must be + * aligned to be compatible with SIMD instructions on the current machine. + * For example, if the machine supports SSE only, it will return 16, but if + * it supports AVX-512F, it'll return 64 (etc). This only reports values for + * instruction sets SDL knows about, so if your SDL build doesn't have + * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and + * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. + * Plan accordingly. + */ +extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); + +/** + * \brief Allocate memory in a SIMD-friendly way. + * + * This will allocate a block of memory that is suitable for use with SIMD + * instructions. Specifically, it will be properly aligned and padded for + * the system's supported vector instructions. + * + * The memory returned will be padded such that it is safe to read or write + * an incomplete vector at the end of the memory block. This can be useful + * so you don't have to drop back to a scalar fallback at the end of your + * SIMD processing loop to deal with the final elements without overflowing + * the allocated buffer. + * + * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() + * or delete[], etc. + * + * Note that SDL will only deal with SIMD instruction sets it is aware of; + * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors + * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't + * know that AVX-512 wants 64. To be clear: if you can't decide to use an + * instruction set with an SDL_Has*() function, don't use that instruction + * set with memory allocated through here. + * + * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't + * out of memory. + * + * \param len The length, in bytes, of the block to allocated. The actual + * allocated block might be larger due to padding, etc. + * \return Pointer to newly-allocated block, NULL if out of memory. + * + * \sa SDL_SIMDAlignment + * \sa SDL_SIMDFree + */ +extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); + +/** + * \brief Deallocate memory obtained from SDL_SIMDAlloc + * + * It is not valid to use this function on a pointer from anything but + * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, + * SDL_malloc, memalign, new[], etc. + * + * However, SDL_SIMDFree(NULL) is a legal no-op. + * + * \sa SDL_SIMDAlloc + */ +extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); + +/* vi: set ts=4 sw=4 expandtab: */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_egl.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_egl.h index d65ed437c..f50fa5c9b 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_egl.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_egl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_endian.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_endian.h index ed0bf5ba8..54d5d486d 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_endian.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_endian.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_error.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_error.h index c0e46298e..24416e693 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_error.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_error.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_events.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_events.h index af22eb646..282b9fb76 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_events.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -594,6 +594,9 @@ typedef union SDL_Event Uint8 padding[56]; } SDL_Event; +/* Make sure we haven't broken binary compatibility */ +SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); + /* Function prototypes */ diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h index fa6a1fa6e..6d97e5896 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h index 6ae9c9542..ebde38715 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h index b223d80d4..9d25e9c1d 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h index 2ea1bfc16..075627685 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_hints.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_hints.h index 4ee72e97d..8fa0dd660 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_hints.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_hints.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -315,6 +315,16 @@ extern "C" { */ #define SDL_HINT_TOUCH_MOUSE_EVENTS "SDL_TOUCH_MOUSE_EVENTS" +/** + * \brief A variable controlling whether mouse events should generate synthetic touch events + * + * This variable can be set to the following values: + * "0" - Mouse events will not generate touch events (default for desktop platforms) + * "1" - Mouse events will generate touch events (default for mobile platforms, such as Android and iOS) + */ + +#define SDL_HINT_MOUSE_TOUCH_EVENTS "SDL_MOUSE_TOUCH_EVENTS" + /** * \brief Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true. * @@ -436,6 +446,16 @@ extern "C" { */ #define SDL_HINT_GAMECONTROLLERCONFIG "SDL_GAMECONTROLLERCONFIG" +/** + * \brief A variable that lets you provide a file with extra gamecontroller db entries. + * + * The file should contain lines of gamecontroller config data, see SDL_gamecontroller.h + * + * This hint must be set before calling SDL_Init(SDL_INIT_GAMECONTROLLER) + * You can update mappings after the system is initialized with SDL_GameControllerMappingForGUID() and SDL_GameControllerAddMapping() + */ +#define SDL_HINT_GAMECONTROLLERCONFIG_FILE "SDL_GAMECONTROLLERCONFIG_FILE" + /** * \brief A variable containing a list of devices to skip when scanning for game controllers. * @@ -836,19 +856,7 @@ extern "C" { */ #define SDL_HINT_IME_INTERNAL_EDITING "SDL_IME_INTERNAL_EDITING" - /** - * \brief A variable to control whether mouse and touch events are to be treated together or separately - * - * The variable can be set to the following values: - * "0" - Mouse events will be handled as touch events, and touch will raise fake mouse - * events. This is the behaviour of SDL <= 2.0.3. (default) - * "1" - Mouse events will be handled separately from pure touch events. - * - * The value of this hint is used at runtime, so it can be changed at any time. - */ -#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH" - - /** +/** * \brief A variable to control whether we trap the Android back button to handle it manually. * This is necessary for the right mouse button to work on some Android devices, or * to be able to trap the back button for use in your code reliably. If set to true, @@ -865,6 +873,17 @@ extern "C" { */ #define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON" +/** + * \brief A variable to control whether the event loop will block itself when the app is paused. + * + * The variable can be set to the following values: + * "0" - Non blocking. + * "1" - Blocking. (default) + * + * The value should be set before SDL is initialized. + */ +#define SDL_HINT_ANDROID_BLOCK_ON_PAUSE "SDL_ANDROID_BLOCK_ON_PAUSE" + /** * \brief A variable to control whether the return key on the soft keyboard * should hide the soft keyboard on Android and iOS. @@ -1043,6 +1062,118 @@ extern "C" { */ #define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY" +/** + * \brief A variable controlling whether the 2D render API is compatible or efficient. + * + * This variable can be set to the following values: + * + * "0" - Don't use batching to make rendering more efficient. + * "1" - Use batching, but might cause problems if app makes its own direct OpenGL calls. + * + * Up to SDL 2.0.9, the render API would draw immediately when requested. Now + * it batches up draw requests and sends them all to the GPU only when forced + * to (during SDL_RenderPresent, when changing render targets, by updating a + * texture that the batch needs, etc). This is significantly more efficient, + * but it can cause problems for apps that expect to render on top of the + * render API's output. As such, SDL will disable batching if a specific + * render backend is requested (since this might indicate that the app is + * planning to use the underlying graphics API directly). This hint can + * be used to explicitly request batching in this instance. It is a contract + * that you will either never use the underlying graphics API directly, or + * if you do, you will call SDL_RenderFlush() before you do so any current + * batch goes to the GPU before your work begins. Not following this contract + * will result in undefined behavior. + */ +#define SDL_HINT_RENDER_BATCHING "SDL_RENDER_BATCHING" + + +/** + * \brief A variable controlling whether SDL logs all events pushed onto its internal queue. + * + * This variable can be set to the following values: + * + * "0" - Don't log any events (default) + * "1" - Log all events except mouse and finger motion, which are pretty spammy. + * "2" - Log all events. + * + * This is generally meant to be used to debug SDL itself, but can be useful + * for application developers that need better visibility into what is going + * on in the event queue. Logged events are sent through SDL_Log(), which + * means by default they appear on stdout on most platforms or maybe + * OutputDebugString() on Windows, and can be funneled by the app with + * SDL_LogSetOutputFunction(), etc. + * + * This hint can be toggled on and off at runtime, if you only need to log + * events for a small subset of program execution. + */ +#define SDL_HINT_EVENT_LOGGING "SDL_EVENT_LOGGING" + + + +/** + * \brief Controls how the size of the RIFF chunk affects the loading of a WAVE file. + * + * The size of the RIFF chunk (which includes all the sub-chunks of the WAVE + * file) is not always reliable. In case the size is wrong, it's possible to + * just ignore it and step through the chunks until a fixed limit is reached. + * + * Note that files that have trailing data unrelated to the WAVE file or + * corrupt files may slow down the loading process without a reliable boundary. + * By default, SDL stops after 10000 chunks to prevent wasting time. Use the + * environment variable SDL_WAVE_CHUNK_LIMIT to adjust this value. + * + * This variable can be set to the following values: + * + * "force" - Always use the RIFF chunk size as a boundary for the chunk search + * "ignorezero" - Like "force", but a zero size searches up to 4 GiB (default) + * "ignore" - Ignore the RIFF chunk size and always search up to 4 GiB + * "maximum" - Search for chunks until the end of file (not recommended) + */ +#define SDL_HINT_WAVE_RIFF_CHUNK_SIZE "SDL_WAVE_RIFF_CHUNK_SIZE" + +/** + * \brief Controls how a truncated WAVE file is handled. + * + * A WAVE file is considered truncated if any of the chunks are incomplete or + * the data chunk size is not a multiple of the block size. By default, SDL + * decodes until the first incomplete block, as most applications seem to do. + * + * This variable can be set to the following values: + * + * "verystrict" - Raise an error if the file is truncated + * "strict" - Like "verystrict", but the size of the RIFF chunk is ignored + * "dropframe" - Decode until the first incomplete sample frame + * "dropblock" - Decode until the first incomplete block (default) + */ +#define SDL_HINT_WAVE_TRUNCATION "SDL_WAVE_TRUNCATION" + +/** + * \brief Controls how the fact chunk affects the loading of a WAVE file. + * + * The fact chunk stores information about the number of samples of a WAVE + * file. The Standards Update from Microsoft notes that this value can be used + * to 'determine the length of the data in seconds'. This is especially useful + * for compressed formats (for which this is a mandatory chunk) if they produce + * multiple sample frames per block and truncating the block is not allowed. + * The fact chunk can exactly specify how many sample frames there should be + * in this case. + * + * Unfortunately, most application seem to ignore the fact chunk and so SDL + * ignores it by default as well. + * + * This variable can be set to the following values: + * + * "truncate" - Use the number of samples to truncate the wave data if + * the fact chunk is present and valid + * "strict" - Like "truncate", but raise an error if the fact chunk + * is invalid, not present for non-PCM formats, or if the + * data chunk doesn't have that many samples + * "ignorezero" - Like "truncate", but ignore fact chunk if the number of + * samples is zero + * "ignore" - Ignore fact chunk entirely (default) + */ +#define SDL_HINT_WAVE_FACT_CHUNK "SDL_WAVE_FACT_CHUNK" + /** * \brief An enumeration of hint priorities */ diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h index 6e05a9c20..3a4c5d177 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h index 874823171..4b2a055d8 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h index d7d5b1dbc..3bceb418a 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h index da56fb452..793ba5358 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_log.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_log.h index e12b65886..40f768d57 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_log.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_main.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_main.h index 98558217f..623f2d005 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_main.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_main.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -55,6 +55,10 @@ /* On iOS SDL provides a main function that creates an application delegate and starts the iOS application run loop. + If you link with SDL dynamically on iOS, the main function can't be in a + shared library, so you need to link with libSDLmain.a, which includes a + stub main function that calls into the shared library to start execution. + See src/video/uikit/SDL_uikitappdelegate.m for more details. */ #define SDL_MAIN_NEEDED @@ -82,12 +86,6 @@ #endif #endif /* SDL_MAIN_HANDLED */ -#ifdef __cplusplus -#define C_LINKAGE "C" -#else -#define C_LINKAGE -#endif /* __cplusplus */ - #ifndef SDLMAIN_DECLSPEC #define SDLMAIN_DECLSPEC #endif @@ -111,17 +109,18 @@ #define main SDL_main #endif -/** - * The prototype for the application's main() function - */ -extern C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); - - #include "begin_code.h" #ifdef __cplusplus extern "C" { #endif +/** + * The prototype for the application's main() function + */ +typedef int (*SDL_main_func)(int argc, char *argv[]); +extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); + + /** * This is called by the real SDL main function to let the rest of the * library know that initialization was done properly. @@ -136,8 +135,7 @@ extern DECLSPEC void SDLCALL SDL_SetMainReady(void); /** * This can be called to set the application class at startup */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, - void *hInst); +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #endif /* __WIN32__ */ @@ -153,10 +151,24 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more * information on the failure. */ -extern DECLSPEC int SDLCALL SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * reserved); +extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved); #endif /* __WINRT__ */ +#if defined(__IPHONEOS__) + +/** + * \brief Initializes and launches an SDL application. + * + * \param argc The argc parameter from the application's main() function + * \param argv The argv parameter from the application's main() function + * \param mainFunction The SDL app's C-style main(). + * \return the return value from mainFunction + */ +extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); + +#endif /* __IPHONEOS__ */ + #ifdef __cplusplus } diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h index b7be59d88..e34b55477 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h index d3c9f6156..277559d23 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h index ba4247ced..970e78713 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_name.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_name.h index ecd863f4c..690a8199b 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_name.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_name.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h index 253d9c93a..6685be73e 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h index 18dd984b3..1e0660c3d 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h index 6ccecf216..df29d3840 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h index 0b4364b18..dcb7a980d 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -168,7 +168,7 @@ enum ((format) && (SDL_PIXELFLAG(format) != 1)) /* Note: If you modify this list, update SDL_GetPixelFormatName() */ -enum +typedef enum { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB = @@ -290,7 +290,7 @@ enum SDL_DEFINE_PIXELFOURCC('N', 'V', '2', '1'), SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */ SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ') -}; +} SDL_PixelFormatEnum; typedef struct SDL_Color { diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_platform.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_platform.h index 7dea4ce94..c2cbc6b4e 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_platform.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_platform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_power.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_power.h index a4fe8a935..4831cb77e 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_power.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_power.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_quit.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_quit.h index fea56a8d8..c979983cb 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_quit.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_quit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rect.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rect.h index 543bb6186..71a411517 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rect.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -40,7 +40,7 @@ extern "C" { #endif /** - * \brief The structure that defines a point + * \brief The structure that defines a point (integer) * * \sa SDL_EnclosePoints * \sa SDL_PointInRect @@ -52,7 +52,20 @@ typedef struct SDL_Point } SDL_Point; /** - * \brief A rectangle, with the origin at the upper left. + * \brief The structure that defines a point (floating point) + * + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect + */ +typedef struct SDL_FPoint +{ + float x; + float y; +} SDL_FPoint; + + +/** + * \brief A rectangle, with the origin at the upper left (integer). * * \sa SDL_RectEmpty * \sa SDL_RectEquals @@ -67,6 +80,19 @@ typedef struct SDL_Rect int w, h; } SDL_Rect; + +/** + * \brief A rectangle, with the origin at the upper left (floating point). + */ +typedef struct SDL_FRect +{ + float x; + float y; + float w; + float h; +} SDL_FRect; + + /** * \brief Returns true if point resides inside a rectangle. */ diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_render.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_render.h index d33619297..096b4a577 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_render.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -835,6 +835,148 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, const SDL_Point *center, const SDL_RendererFlip flip); + +/** + * \brief Draw a point on the current rendering target. + * + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, + float x, float y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, + float x1, float y1, float x2, float y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, + const SDL_FPoint * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, + const SDL_FRect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, + const SDL_FRect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect); + +/** + * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_FRect * dstrect, + const double angle, + const SDL_FPoint *center, + const SDL_RendererFlip flip); + /** * \brief Read pixels from the current rendering target. * @@ -876,6 +1018,31 @@ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); */ extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); +/** + * \brief Force the rendering context to flush any pending commands to the + * underlying rendering API. + * + * You do not need to (and in fact, shouldn't) call this function unless + * you are planning to call into OpenGL/Direct3D/Metal/whatever directly + * in addition to using an SDL_Renderer. + * + * This is for a very-specific case: if you are using SDL's render API, + * you asked for a specific renderer backend (OpenGL, Direct3D, etc), + * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make + * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of + * this applies, you should call SDL_RenderFlush() between calls to SDL's + * render API and the low-level API you're using in cooperation. + * + * In all other cases, you can ignore this function. This is only here to + * get maximum performance out of a specific situation. In all other cases, + * SDL will do the right thing, perhaps at a performance loss. + * + * This function is first available in SDL 2.0.10, and is not needed in + * 2.0.9 and earlier, as earlier versions did not queue rendering commands + * at all, instead flushing them to the OS immediately. + */ +extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); + /** * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_revision.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_revision.h index 92fbe67b1..3b3fc85ea 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_revision.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_revision.h @@ -1,2 +1,2 @@ -#define SDL_REVISION "hg-12373:8feb5da6f2fb" -#define SDL_REVISION_NUMBER 12373 +#define SDL_REVISION "hg-12952:bc90ce38f1e2" +#define SDL_REVISION_NUMBER 12952 diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h index 0960699d4..f66119fb0 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -176,19 +176,48 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); #define RW_SEEK_END 2 /**< Seek relative to the end of data */ /** - * \name Read/write macros - * - * Macros to easily read and write from an SDL_RWops structure. + * Return the size of the file in this rwops, or -1 if unknown */ -/* @{ */ -#define SDL_RWsize(ctx) (ctx)->size(ctx) -#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) -#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) -#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) -#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) -#define SDL_RWclose(ctx) (ctx)->close(ctx) -/* @} *//* Read/write macros */ +extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); +/** + * Seek to \c offset relative to \c whence, one of stdio's whence values: + * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * + * \return the final offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, + Sint64 offset, int whence); + +/** + * Return the current offset in the data stream, or -1 on error. + */ +extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context); + +/** + * Read up to \c maxnum objects each of size \c size from the data + * stream to the area pointed at by \c ptr. + * + * \return the number of objects read, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, + void *ptr, size_t size, size_t maxnum); + +/** + * Write exactly \c num objects each of size \c size from the area + * pointed at by \c ptr to data stream. + * + * \return the number of objects written, or 0 at error or end of file. + */ +extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, + const void *ptr, size_t size, size_t num); + +/** + * Close and free an allocated SDL_RWops structure. + * + * \return 0 if successful or -1 on write error when flushing data. + */ +extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context); /** * Load all the data from an SDL data stream. @@ -209,9 +238,17 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, /** * Load an entire file. * - * Convenience macro. + * The data is allocated with a zero byte at the end (null terminated) + * + * If \c datasize is not NULL, it is filled with the size of the data read. + * + * If \c freesrc is non-zero, the stream will be closed after being read. + * + * The data should be freed with SDL_free(). + * + * \return the data, or NULL if there was an error. */ -#define SDL_LoadFile(file, datasize) SDL_LoadFile_RW(SDL_RWFromFile(file, "rb"), datasize, 1) +extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); /** * \name Read endian functions diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h index 63871aa3b..a50305f55 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -38,7 +38,7 @@ * SDL_Event structure. * * The values in this enumeration are based on the USB usage page standard: - * http://www.usb.org/developers/hidpage/Hut1_12v2.pdf + * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf */ typedef enum { diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h index ac163a8cd..966adbf21 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,8 +26,8 @@ * */ -#ifndef _SDL_sensor_h -#define _SDL_sensor_h +#ifndef SDL_sensor_h_ +#define SDL_sensor_h_ #include "SDL_stdinc.h" #include "SDL_error.h" @@ -246,6 +246,6 @@ extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); #endif #include "close_code.h" -#endif /* _SDL_sensor_h */ +#endif /* SDL_sensor_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_shape.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_shape.h index 40a6baaae..2ab43fcdc 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_shape.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h index e373bc380..28bb7b961 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_surface.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_surface.h index 730d49fc8..51a128300 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_surface.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_surface.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -53,6 +53,7 @@ extern "C" { #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ #define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ +#define SDL_SIMD_ALIGNED 0x00000008 /**< Surface uses aligned memory */ /* @} *//* Surface flags */ /** diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_system.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_system.h index 4dc372d6b..3b0840769 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_system.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_system.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h index f1c4021cc..7aa8c6869 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -34,16 +34,16 @@ #include "SDL_version.h" /** - * \file SDL_syswm.h + * \brief SDL_syswm.h * * Your application has access to a special type of event ::SDL_SYSWMEVENT, * which contains window-manager specific information and arrives whenever * an unhandled window event occurs. This event is ignored by default, but * you can enable it with SDL_EventState(). */ -#ifdef SDL_PROTOTYPES_ONLY struct SDL_SysWMinfo; -#else + +#if !defined(SDL_PROTOTYPES_ONLY) #if defined(SDL_VIDEO_DRIVER_WINDOWS) #ifndef WIN32_LEAN_AND_MEAN @@ -103,6 +103,8 @@ typedef void *EGLSurface; #if defined(SDL_VIDEO_DRIVER_VIVANTE) #include "SDL_egl.h" #endif +#endif /* SDL_PROTOTYPES_ONLY */ + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -110,6 +112,7 @@ typedef void *EGLSurface; extern "C" { #endif +#if !defined(SDL_PROTOTYPES_ONLY) /** * These are the various supported windowing subsystems */ @@ -122,7 +125,7 @@ typedef enum SDL_SYSWM_COCOA, SDL_SYSWM_UIKIT, SDL_SYSWM_WAYLAND, - SDL_SYSWM_MIR, + SDL_SYSWM_MIR, /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ SDL_SYSWM_WINRT, SDL_SYSWM_ANDROID, SDL_SYSWM_VIVANTE, @@ -257,11 +260,11 @@ struct SDL_SysWMinfo struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ } wl; #endif -#if defined(SDL_VIDEO_DRIVER_MIR) +#if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ struct { - struct MirConnection *connection; /**< Mir display server connection */ - struct MirSurface *surface; /**< Mir surface */ + void *connection; /**< Mir display server connection */ + void *surface; /**< Mir surface */ } mir; #endif diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test.h index 6cc373bf8..17a33dc2c 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h index 1788d7a20..b3ebb62fb 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h index be2e6b2aa..c34d0d103 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -140,14 +140,20 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags); */ int SDLTest_CommonArg(SDLTest_CommonState * state, int index); + /** - * \brief Returns common usage information + * \brief Logs command line usage info. * - * \param state The common state describing the test window to create. + * This logs the appropriate command line options for the subsystems in use + * plus other common options, and then any application-specific options. + * This uses the SDL_Log() function and splits up output to be friendly to + * 80-character-wide terminals. * - * \returns String with usage information + * \param state The common state describing the test window for the app. + * \param argv0 argv[0], as passed to main/SDL_main. + * \param options an array of strings for application specific options. The last element of the array should be NULL. */ -const char *SDLTest_CommonUsage(SDLTest_CommonState * state); +void SDLTest_CommonLogUsage(SDLTest_CommonState * state, const char *argv0, const char **options); /** * \brief Open test window. @@ -158,6 +164,17 @@ const char *SDLTest_CommonUsage(SDLTest_CommonState * state); */ SDL_bool SDLTest_CommonInit(SDLTest_CommonState * state); +/** + * \brief Easy argument handling when test app doesn't need any custom args. + * + * \param state The common state describing the test window to create. + * \param argc argc, as supplied to SDL_main + * \param argv argv, as supplied to SDL_main + * + * \returns False if app should quit, true otherwise. + */ +SDL_bool SDLTest_CommonDefaultArgs(SDLTest_CommonState * state, const int argc, char **argv); + /** * \brief Common event handler for test windows. * diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h index c22e447d8..1f751c8b9 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h index 3d235d074..e615d8929 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h index 59cbdcad6..8fa078440 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h index 8fcb9ebbf..7259685a9 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h index 8641e0a7e..f5ae92ceb 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h index 9c4dd5b82..b8934812f 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h index ebd44fb50..01d0fedac 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h index 0e4105768..2bfd7dff9 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h index 4827ae6f2..5d4d39ea5 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -42,14 +42,14 @@ extern "C" { * * \note This should be called before any other SDL functions for complete tracking coverage */ -int SDLTest_TrackAllocations(); +int SDLTest_TrackAllocations(void); /** * \brief Print a log of any outstanding allocations * * \note This can be called after SDL_Quit() */ -void SDLTest_LogAllocations(); +void SDLTest_LogAllocations(void); /* Ends C function definitions when using C++ */ diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h index 0eb414ff2..71e9c70b6 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_thread.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_thread.h index 554dd0b61..f78b1145d 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_thread.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_thread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_timer.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_timer.h index 5600618ff..2a47b043a 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_timer.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_timer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_touch.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_touch.h index f4075e79a..99dbcb8c3 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_touch.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -41,6 +41,14 @@ extern "C" { typedef Sint64 SDL_TouchID; typedef Sint64 SDL_FingerID; +typedef enum +{ + SDL_TOUCH_DEVICE_INVALID = -1, + SDL_TOUCH_DEVICE_DIRECT, /* touch screen with window-relative coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, /* trackpad with absolute device coordinates */ + SDL_TOUCH_DEVICE_INDIRECT_RELATIVE /* trackpad with screen cursor-relative coordinates */ +} SDL_TouchDeviceType; + typedef struct SDL_Finger { SDL_FingerID id; @@ -52,6 +60,9 @@ typedef struct SDL_Finger /* Used as the device ID for mouse events simulated with touch input */ #define SDL_TOUCH_MOUSEID ((Uint32)-1) +/* Used as the SDL_TouchID for touch events simulated with mouse input */ +#define SDL_MOUSE_TOUCHID ((Sint64)-1) + /* Function prototypes */ @@ -65,6 +76,11 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); */ extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); +/** + * \brief Get the type of the given touch device. + */ +extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); + /** * \brief Get the number of active fingers for a given touch device. */ diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_types.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_types.h index 4ac248c8c..9c3e9896f 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_types.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_version.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_version.h index 31443e149..6c7499d32 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_version.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_version.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -59,7 +59,7 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 9 +#define SDL_PATCHLEVEL 10 /** * \brief Macro to determine SDL version program was compiled against. diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_video.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_video.h index 461f13805..352afd436 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_video.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h index 972cca4d7..d69a436b3 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h @@ -98,8 +98,8 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */ * applications to link with libvulkan (and historically MoltenVK was * provided as a static library). If it is not found then, on macOS, SDL * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib, - * \c MoltenVK.framework/MoltenVK and \c libMoltenVK.dylib in that order. - * On iOS SDL will attempt to load \c libMoltenVK.dylib. Applications + * followed by \c libvulkan.dylib, in that order. + * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications * using a dynamic framework or .dylib must ensure it is included in its * application bundle. * @@ -153,7 +153,7 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); * is smaller than the number of required extensions, \c SDL_FALSE will be * returned instead of \c SDL_TRUE, to indicate that not all the required * extensions were returned. - * + * * \note If \c window is not NULL, it will be checked against its creation * flags to ensure that the Vulkan flag is present. This parameter * will be removed in a future major release. diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/begin_code.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/begin_code.h index 6c2106246..22c997c41 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/begin_code.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/begin_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -105,6 +105,9 @@ #ifdef _MSC_VER #pragma warning(disable: 4103) #endif +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpragma-pack" +#endif #ifdef __BORLANDC__ #pragma nopackwarning #endif diff --git a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/close_code.h b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/close_code.h index b3b70a4c8..8e4cac3da 100644 --- a/libs/SDL2/x86_64-w64-mingw32/include/SDL2/close_code.h +++ b/libs/SDL2/x86_64-w64-mingw32/include/SDL2/close_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,6 +26,9 @@ * after you finish any function and structure declarations in your headers */ +#ifndef _begin_code_h +#error close_code.h included without matching begin_code.h +#endif #undef _begin_code_h /* Reset structure packing at previous byte alignment */ diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.a b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.a index 827950682..1a0479ba2 100644 Binary files a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.a and b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.a differ diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.dll.a b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.dll.a index 669b6a637..f5d4d2bbb 100755 Binary files a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.dll.a and b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.dll.a differ diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.la b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.la index d5295eec8..f6f05ab4c 100644 --- a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.la +++ b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.la @@ -23,8 +23,8 @@ dependency_libs=' -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 - weak_library_names='' # Version information for libSDL2. -current=9 -age=9 +current=10 +age=10 revision=0 # Is this an already installed library? @@ -38,4 +38,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/Users/valve/release/SDL/SDL2-2.0.9/x86_64-w64-mingw32/lib' +libdir='/Users/valve/release/SDL/SDL2-2.0.10/x86_64-w64-mingw32/lib' diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.a b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.a index fcbdbbf76..7ac4da628 100644 Binary files a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.a and b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.a differ diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.la b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.la index 76ad43f0f..e7a7872ea 100644 --- a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.la +++ b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.la @@ -38,4 +38,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/Users/valve/release/SDL/SDL2-2.0.9/x86_64-w64-mingw32/lib' +libdir='/Users/valve/release/SDL/SDL2-2.0.10/x86_64-w64-mingw32/lib' diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a index 3a26e430d..ea1086e49 100644 Binary files a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a and b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a differ diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.la b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.la index 5aa469333..583786205 100644 --- a/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.la +++ b/libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.la @@ -38,4 +38,4 @@ dlopen='' dlpreopen='' # Directory that this library needs to be installed in: -libdir='/Users/valve/release/SDL/SDL2-2.0.9/x86_64-w64-mingw32/lib' +libdir='/Users/valve/release/SDL/SDL2-2.0.10/x86_64-w64-mingw32/lib' diff --git a/libs/SDL2/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc b/libs/SDL2/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc index ae83be160..ceb157f25 100644 --- a/libs/SDL2/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc +++ b/libs/SDL2/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc @@ -7,9 +7,9 @@ includedir=${prefix}/include Name: sdl2 Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. -Version: 2.0.9 +Version: 2.0.10 Requires: Conflicts: Libs: -L${libdir} -lmingw32 -lSDL2main -lSDL2 -mwindows -Libs.private: -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc +Libs.private: -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -luuid -static-libgcc Cflags: -I${includedir}/SDL2 -Dmain=SDL_main diff --git a/libs/SDL2/x86_64-w64-mingw32/share/aclocal/sdl2.m4 b/libs/SDL2/x86_64-w64-mingw32/share/aclocal/sdl2.m4 index b915f99ed..0a73bc7d4 100644 --- a/libs/SDL2/x86_64-w64-mingw32/share/aclocal/sdl2.m4 +++ b/libs/SDL2/x86_64-w64-mingw32/share/aclocal/sdl2.m4 @@ -74,7 +74,7 @@ AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) done fi - if test -d $sdl_framework; then + if test x"$sdl_framework" != x && test -d "$sdl_framework"; then AC_MSG_RESULT($sdl_framework) sdl_framework_dir=`dirname $sdl_framework` SDL_CFLAGS="-F$sdl_framework_dir -Wl,-framework,SDL2 -I$sdl_framework/include" diff --git a/libs/SDLMixerX/CHANGES.X.txt b/libs/SDLMixerX/CHANGES.X.txt new file mode 100644 index 000000000..17b43d9af --- /dev/null +++ b/libs/SDLMixerX/CHANGES.X.txt @@ -0,0 +1,48 @@ +2.1.0: +Vitaly Novichkov - Sat, Jan 20, 2018 18:06:00 + * SDL Mixer X has been re-created from original again as official SDL Mixer had a big and incompatible rework + * Custom resampler is no more needed as SDL2 now finally uses new better resampler + * Added CMake build + * Added an ability to toggle MIDI playing libraries (NativeMidi, Timidity or FluidSynth) + * Added a full seekability with "tell" and "length" commands + * Added a basic support for Meta-Tags to show Title, Artist, Album and Copyright captured from music files. + * Added an extra arguments in music path string to support song individual settings per some codecs (for example, play different MIDI files with different MIDI playing libraries) + * Timidity: Added ability to set a config search pach, for example, inside of application directory API. + * Added OPNMIDI MIDI sequencer based on YM2612 chip emulation. Includes a complete General-MIDI embedded bank. + * Added functions to use custom bank files for ADL/OPN-MIDI sequencers (WOPL for ADLMIDI and WOPN for OPNMIDI) + * WAVE: Added support for PCM24, PCM32, Float32, Float64m, ALAW, and MULAW sample formats, + * AIFF: Added support for AIFF-C, also support for PCM24, PCM32, Float32, Float64, ALAW, and MULAW formats + * WAVE & AIFF: Added full seekability support (seek, tell, length) + * MP3: More accurate MP3 file detection as some weird MP3 files are can't be detected by existing code; Added usage lf libID3tag library to fetch ID3 tags and also detect begin offset inside of MP3 files as some MP3 files are causing libMAD play ID3 data as actual encoded sound data that causes weird playback and later crash. To avoid this, ID3 parse is needed to detect actual begin of audio data. + * Fixed: SMPEG: Fix a broken build + * Fixed: OGG: Fixed support for pre-defined count of loops when loop tags are presented + * Warning fixes + * Some C90 compatibility fixes + * Internally: Added MIX_UNUSED() macro to mute warnings on various compilers + +1.0.3: +Vitaly Novichkov - 2016 + * Implemented own resampler to don't use buggy SDL Audio's resampler + * Added support of path arguments to allow dynamic configuring of GME and MIDI playing per every file + * ModPlug now is part of SDL Mixer X in same project + * Link all dependent libraries (libOGG, libVorbis, libFLAC, libMAD) statically + +1.0.2: +Vitaly Novichkov - 2015 + * Added ADLMIDI MIDI sequencer which is completely independent MIDI sequencer which requires no extra bank files to play MIDI. + * Added ability to dynamically switch MIDI device (ADLMIDI, Timidity, Native MIDI, FluidSynth) + * Added meta-tag getting functions: Mix_GetMusicTitle, Mix_GetMusicTitleTag, Mix_GetMusicArtistTag, Mix_GetMusicAlbumTag, Mix_GetMusicCopyrightTag. + * Added ability to build VB6-Compatible version to use it as standalone audio library + +1.0.1: +Vitaly Novichkov - 2015 + * Added GME library to support many game music formats + * Added support of loop tags for OGG Vorbis files (based on vorbis comments "LOOPSTART" and "LOOPEND" (also supported "LOOPLENGTH" for RPG-Maker compatibility)) + * Added MIX_Timidity_addToPathList(const char *path) to customize Timidity path + +1.0.0: +Vitaly Novichkov - 2015 + * Added support of SPC playback + * Attempt to fix resampling + * Using QMake instead of autotools to build library + diff --git a/libs/SDLMixerX/CHANGES.txt b/libs/SDLMixerX/CHANGES.txt new file mode 100644 index 000000000..50c0fee0b --- /dev/null +++ b/libs/SDLMixerX/CHANGES.txt @@ -0,0 +1,184 @@ +2.0.3: +Sam Lantinga - Thu, Mar 1, 2018 9:06:58 AM + * Fixed regression where Mix_Init() would return 0 for available music formats + +2.0.2: +Sam Lantinga - Fri Oct 20 22:04:50 PDT 2017 + * Implemented 24-bit and surround sound support for FLAC audio files +Sam Lantinga - Thu Oct 12 21:32:44 PDT 2017 + * Updated external libraries flac-1.3.2, libmodplug-0.8.9.0, libogg-1.3.2 and libvorbis-1.3.5 +Ryan Gordon - Thu Oct 12 21:29:59 PDT 2017 + * Updated for SDL 2.0.6 and newer +Franc[e]sco - Thu Jul 20 22:03:19 2017 +0200 + * Added support for MP3 playback using mpg123 +David Ludwig - Sun Apr 10 22:35:38 2016 + * Added support for UWP / Windows 10 apps +Juha Kuikka - Fri Jan 29 12:44:01 PST 2016 + * Added Mix_OpenAudioDevice() so you can specify the audio device to open + +2.0.1: +Sam Lantinga - Tue Jul 7 11:40:33 PDT 2015 + * Added support for 'smpl' format loop points in music WAV files +Sam Lantinga - Sat Aug 23 10:57:26 2014 + * Fixed floating point exception in Mix_Volume() +David Ludwig - Mon Apr 14 22:15:36 2014 + * Added support for building for Windows RT and Windows Phone +Isaac Burns - Sun Sep 15 21:50:27 PDT 2013 + * Added support for loading MP3 files as sound chunks + +2.0.0: +Sam Lantinga - Sun Jun 9 14:45:30 PDT 2013 + * Made libmodplug the default MOD player as it is now in the public domain +Sam Lantinga - Sat Jun 1 19:11:08 PDT 2013 + * Updated for SDL 2.0 release + * SDL_LoadMUS_RW() now takes an argument telling whether or not the data source should be freed when done. + +1.2.13: +Paul P Komkoff Jr - Sun Jul 22 16:12:28 PDT 2012 + * Fixed malloc/free mismatch in the MikMod driver + +1.2.12: +Sam Lantinga - Sat Jan 14 22:00:29 2012 -0500 + * Fixed seek offset with SMPEG (was relative, should be absolute) +Sam Lantinga - Fri Jan 13 03:04:27 EST 2012 + * Fixed memory crash loading Ogg Vorbis files on Windows +Sam Lantinga - Thu Jan 05 22:51:54 2012 -0500 + * Added an Xcode project for iOS +Nikos Chantziaras - 2012-01-02 17:37:36 PST + * Added Mix_LoadMUSType_RW() so you can tell SDL_mixer what type the music is +Sam Lantinga - Sun Jan 01 16:45:58 2012 -0500 + * Fixed looping native MIDI on Mac OS X and Windows +Sam Lantinga - Sun Jan 01 01:00:51 2012 -0500 + * Added /usr/local/share/timidity to the timidity data path +Sam Lantinga - Sat Dec 31 21:26:46 2011 -0500 + * Fixed timidity loading of some MIDI files +Sam Lantinga - Sat Dec 31 19:11:59 EST 2011 + * Fixed dropping audio in the FLAC audio decoding +Sam Lantinga - Sat Dec 31 18:32:05 EST 2011 + * Fixed memory leak in SDL_LoadMUS() +Sam Lantinga - Sat Dec 31 10:22:05 EST 2011 + * Removed GPL native MIDI code for new licensing +Sam Lantinga - Sat Dec 31 10:22:05 EST 2011 + * SDL_mixer is now under the zlib license +Manuel Montezelo - 2011-12-28 11:42:44 PST + * Fixed drums playing on MIDI channel 16 with timidity +Ryan C. Gordon - Wed Jun 15 03:41:31 2011 -0400 + * The music-finished hook can start a track immediately +James Le Cuirot - Mon Mar 21 16:54:11 PDT 2011 + * Added support for FluidSynth +Egor Suvorov - Tue Jan 18 11:06:47 PST 2011 + * Added support for native MIDI on Haiku +Sam Lantinga - Tue Jan 11 01:29:19 2011 -0800 + * Added Android.mk to build on the Android platform +Jon Atkins - Sat Nov 14 13:00:18 PST 2009 + * Added support for libmodplug (disabled by default) + +1.2.11: +Sam Lantinga - Sat Nov 14 12:38:01 PST 2009 + * Fixed initialization error and crashes if MikMod library isn't available +Sam Lantinga - Sat Nov 14 11:22:14 PST 2009 + * Fixed bug loading multiple music files + +1.2.10: +Sam Lantinga - Sun Nov 8 08:34:48 PST 2009 + * Added Mix_Init()/Mix_Quit() to prevent constantly loading and unloading DLLs +Mike Frysinger - 2009-11-05 09:11:43 PST + * Check for fork/vfork on any platform, don't just assume it on UNIX +Jon Atkins - Thu Nov 5 00:02:50 2009 UTC + * Fixed export of Mix_GetNumChunkDecoders() and Mix_GetNumMusicDecoders() +C.W. Betts - 2009-11-02 00:16:21 PST + * Use newer MIDI API on Mac OS X 10.5+ + +1.2.9: +Ryan Gordon - Sun Oct 18 11:42:31 PDT 2009 + * Updated native MIDI support on Mac OS X for 10.6 +Ryan Gordon - Sun Oct 11 05:29:55 2009 UTC + * Reset channel volumes after a fade out interrupts a fade in. +Ryan Gordon - Sun Oct 11 02:59:12 2009 UTC + * Fixed crash race condition with position audio functions +Ryan Gordon - Sat Oct 10 17:05:45 2009 UTC + * Fixed stereo panning in 8-bit mode +Sam Lantinga - Sat Oct 10 11:07:15 2009 UTC + * Added /usr/share/timidity to the default timidity.cfg locations +Sam Lantinga - Sat Oct 3 13:33:36 PDT 2009 + * MOD support uses libmikmod and is dynamically loaded by default + * A patched version of libmikmod is included in libmikmod-3.1.12.zip + * The libmikmod patches fix security issues CVE-2007-6720 and CVE-2009-0179. +Sam Lantinga - Sat Oct 3 02:49:41 PDT 2009 + * Added TIMIDITY_CFG environment variable to fully locate timidity.cfg +Sam Lantinga - Fri Oct 2 07:15:35 PDT 2009 + * Implemented seamless looping for music playback +Forrest Voight - 2009-06-13 20:31:38 PDT + * ID3 files are now recognized as MP3 format +Steven Noonan - 2008-05-13 13:31:36 PDT + * Fixed native MIDI crash on 64-bit Windows +Ryan Gordon - Fri Jun 5 16:07:08 2009 UTC + * Added decoder enumeration API: + Mix_GetNumChunkDecoders(), Mix_GetChunkDecoder(), + Mix_GetNumMusicDecoders(), Mix_GetMusicDecoder() +Austen Dicken - Tue Feb 26 23:28:27 PST 2008 + * Added support for FLAC audio both as chunks and streaming +Tilman Sauerbeck - Tue Feb 26 03:44:47 PST 2008 + * Added support for streaming WAV files with Mix_LoadMUS_RW() +Ryan Gordon - Mon Feb 4 17:10:08 UTC 2008 + * Fixed crash caused by not resetting position_channels + +1.2.8: +Sam Lantinga - Wed Jul 18 09:45:54 PDT 2007 + * Improved detection of Ogg Vorbis and Tremor libraries +Ryan Gordon - Sun Jul 15 12:03:54 EDT 2007 + * Fixed memory leaks in Effects API. +David Rose - Sat Jul 14 22:16:09 PDT 2007 + * Added support for MP3 playback with libmad (for GPL projects only!) +Sam Lantinga - Sat Jul 14 21:39:30 PDT 2007 + * Fixed the final loop of audio samples of a certain size +Sam Lantinga - Sat Jul 14 21:05:09 PDT 2007 + * Fixed opening Ogg Vorbis files using different C runtimes on Windows +Philippe Simons - Sat Jul 14 20:33:17 PDT 2007 + * Added support for Ogg Vorbis playback with Tremor (an integer decoder) +Sam Lantinga - Sat Jul 14 07:02:09 PDT 2007 + * Fixed memory corruption in timidity resampling code +Ryan Gordon - Tue Jul 3 10:44:29 2007 UTC + * Fixed building SDL_mixer with SDL 1.3 pre-release +Ryan Gordon - Tue Feb 13 08:11:54 2007 UTC + * Fixed compiling both timidity and native midi in the same build +Hans de Goede - Sun Aug 20 23:25:46 2006 UTC + * Added volume control to playmus +Jonathan Atkins - Thu Aug 10 15:06:40 2006 UTC + * Fixed linking with system libmikmod +David Ergo - Fri Jun 23 09:07:19 2006 UTC + * Corrected no-op conditions in SetDistance(), SetPanning() and SetPosition() + * Fixed copy/paste errors in channel amplitudes + +1.2.7: +Sam Lantinga - Fri May 12 00:04:32 PDT 2006 + * Added support for dynamically loading SMPEG library +Sam Lantinga - Thu May 11 22:22:43 PDT 2006 + * Added support for dynamically loading Ogg Vorbis library +Sam Lantinga - Sun Apr 30 09:01:44 PDT 2006 + * Removed automake dependency, to allow Universal binaries on Mac OS X + * Added gcc-fat.sh for generating Universal binaries on Mac OS X +Sam Lantinga - Sun Apr 30 01:48:40 PDT 2006 + * Updated libtool support to version 1.5.22 +Patrice Mandin - Sat Jul 16 16:43:24 UTC 2005 + * Use SDL_RWops also for native midi mac and win32 +Patrice Mandin - Sat Jul 9 14:40:09 UTC 2005 + * Use SDL_RWops also for native midi gpl (todo: mac and win32) +Ryan C. Gordon - Sat Jul 9 01:54:03 EDT 2005 + * Tweaked Mix_Chunk's definition to make predeclaration easier. +Patrice Mandin - Mon Jul 4 19:45:40 UTC 2005 + * Search timidity.cfg also in /etc + * Fix memory leaks in timidity player + * Use also SDL_RWops to read midifiles for timidity +Ryan C. Gordon - Mon Jun 13 18:18:12 EDT 2005 + * Patch from Eric Wing to fix native midi compiling on MacOS/x86. +Sam Lantinga - Wed Dec 22 17:14:32 PST 2004 + * Disabled support for the system version of libmikmod by default +Sam Lantinga - Tue Dec 21 09:51:29 PST 2004 + * Fixed building mikmod support on UNIX + * Always build SDL_RWops music support + * Added SDL_RWops support for reading MP3 files + +1.2.6: +Jonathan Atkins - Wed, 15 Sep 2004 23:26:42 -0500 + * Added support for using the system version of libmikmod diff --git a/libs/SDLMixerX/CMakeLists.txt b/libs/SDLMixerX/CMakeLists.txt new file mode 100644 index 000000000..af55b0265 --- /dev/null +++ b/libs/SDLMixerX/CMakeLists.txt @@ -0,0 +1,818 @@ +cmake_minimum_required (VERSION 2.8.11) +project(SDLMixerX C) + +include(FindPkgConfig) +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckLibraryExists) +#include(CheckCSourceRuns) +#include(CheckCCompilerFlag) + +if(NOT CMAKE_VERSION VERSION_LESS 2.8.12) + set(CMAKE_MACOSX_RPATH 0) +endif() + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) + message("== Using default build configuration which is a Release!") +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(MIX_DEBUG_SUFFIX "d") +else() + set(MIX_DEBUG_SUFFIX "") +endif() + +if(WIN32) + set(CMAKE_SHARED_LIBRARY_PREFIX "") +endif() + +if(POLICY CMP0058) + cmake_policy(SET CMP0058 NEW) +endif() + +option(SSEMATH "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH}) +option(MMX "Use MMX assembly routines" ${OPT_DEF_ASM}) +option(3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM}) +option(SSE "Use SSE assembly routines" ${OPT_DEF_ASM}) +option(SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH}) +option(SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH}) + +# Settings +option(SDL_MIXER_X_STATIC "Build static library of SDL Mixer X" ON) +option(SDL_MIXER_X_SHARED "Build shared library of SDL Mixer X" ON) + +option(DOWNLOAD_AUDIO_CODECS_DEPENDENCY "Downloads and compiles AudioCodecs dependencies pack directly" OFF) +set(AUDIO_CODECS_REPO_PATH "" CACHE PATH "Path to the AudioCodecs dependencies pack") +set(AUDIO_CODECS_INSTALL_PATH "" CACHE PATH "Path to installed AudioCodecs prefix") + +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + # Turn on warnings and legacy C/C++ standards to support more compilers + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c90") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++98") + # Deny undefined symbols + if(NOT APPLE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ) + endif() +endif() + +set(SDL_MIXER_INCLUDE_PATHS) + +if(NOT AUDIO_CODECS_REPO_PATH AND NOT AUDIO_CODECS_INSTALL_PATH) + # Try to resolve sqlite dependency + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + # Download and configure AudioCodecs dependency + set(SDL2_REPO_PATH ${CMAKE_INSTALL_PREFIX}) + set(SDL2_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include/SDL2) + set(SDL2_LIBS_PATH ${CMAKE_INSTALL_PREFIX}/lib) + include(cmake/DownloadAudioCodecs.cmake) + set(AUDIO_CODECS_REPO_PATH ${AUDIO_CODECS_REPOSITORY_PATH}) + set(AUDIO_CODECS_INSTALL_PATH ${AUDIO_CODECS_INSTALL_DIR}) + endif() +endif() + +set(FIND_PREFER_STATIC + "-static${MIX_DEBUG_SUFFIX}.a" + "-static${MIX_DEBUG_SUFFIX}.lib" + "${MIX_DEBUG_SUFFIX}.a" + "${MIX_DEBUG_SUFFIX}.lib" + "-static.a" + "-static.lib" + ".a" + ".lib" + "${MIX_DEBUG_SUFFIX}.dll.a" + "${MIX_DEBUG_SUFFIX}.dll.lib" + ".dll.a" + ".dll.lib" + "${MIX_DEBUG_SUFFIX}.so" + "${MIX_DEBUG_SUFFIX}.dylib" + ".so" + ".dylib" +) + +set(FIND_PREFER_SHARED + "${MIX_DEBUG_SUFFIX}.dll.a" + "${MIX_DEBUG_SUFFIX}.dll.lib" + ".dll.a" + ".dll.lib" + "${MIX_DEBUG_SUFFIX}.so" + "${MIX_DEBUG_SUFFIX}.dylib" + ".so" + ".dylib" + "-static${MIX_DEBUG_SUFFIX}.a" + "-static${MIX_DEBUG_SUFFIX}.lib" + "${MIX_DEBUG_SUFFIX}.a" + "${MIX_DEBUG_SUFFIX}.lib" + "-static.a" + "-static.lib" + ".a" + ".lib" +) + +if(AUDIO_CODECS_REPO_PATH OR AUDIO_CODECS_INSTALL_PATH) + set(AUDIO_CODECS_PATH ${AUDIO_CODECS_REPO_PATH}) + set(AUDIO_CODECS_INSTALL_DIR ${AUDIO_CODECS_INSTALL_PATH}) + set(SDL2_REPO_PATH ${AUDIO_CODECS_INSTALL_DIR}) + set(SDL2_INCLUDE_PATH ${AUDIO_CODECS_INSTALL_DIR}/include/SDL2) + link_directories(${AUDIO_CODECS_INSTALL_DIR}/lib) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_INSTALL_DIR}/include ${SDL2_INCLUDE_PATH}) + message("AudioCodecs will be used. No needed extra libraries installed in the system.") + set(USE_SYSTEM_AUDIO_LIBRARIES 0) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${FIND_PREFER_STATIC}) +else() + message("AudioCodecs will NOT be used. Libraries will be recognized in the system.") + set(USE_SYSTEM_AUDIO_LIBRARIES 1) +endif() + +add_definitions(-DHAVE_INTTYPES_H -DHAVE_SETENV -DHAVE_SINF) +add_definitions(-Dmain=SDL_main -DPIC -D_REENTRANT -D_USE_MATH_DEFINES) + +set(SDLMixerX_SOURCES) +set(SDLMixerX_LINK_LIBS) + +# Recognize SDL2 library from the system +if(USE_SYSTEM_AUDIO_LIBRARIES) + find_package(PkgConfig) + pkg_check_modules(SDL2 REQUIRED sdl2) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${SDL2_INCLUDE_DIRS}) + list(APPEND SDLMixerX_LINK_LIBS ${SDL2_LIBRARIES}) + message("== SDL2: ${SDL2_INCLUDE_DIRS} ${SDL2_LIBRARIES} ==") +endif() + +option(USE_WAV "Build with WAV codec" ON) +if(USE_WAV) + add_definitions(-DMUSIC_WAV) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/load_aiff.c + ${SDLMixerX_SOURCE_DIR}/src/codecs/load_voc.c + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_wav.c) +endif() + +option(USE_OGG_VORBIS "Build with OGG Vorbis codec" ON) +if(USE_OGG_VORBIS) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(vorbisfile ov_open "vorbis/vorbisfile.h" FOUND_VORBIS) + find_path(LIBVORBIS_INCLUDE_DIR vorbis/codec.h) + find_library(LIBVORBISFILE_LIB NAMES vorbisfile) + find_library(LIBVORBIS_LIB NAMES vorbis) + message("Vorbis: ${LIBVORBIS_INCLUDE_DIR} ${LIBVORBIS_LIB}") + else() + set(FOUND_VORBIS 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBVORBISFILE_LIB vorbisfile) + set(LIBVORBIS_LIB vorbis) + else() + find_library(LIBVORBISFILE_LIB NAMES vorbisfile + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + find_library(LIBVORBIS_LIB NAMES vorbis + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_VORBIS) + message("== using Vorbis ==") + add_definitions(-DMUSIC_OGG) + list(APPEND SDL_MIXER_INCLUDE_PATHS + ${AUDIO_CODECS_PATH}/libogg/include + ${AUDIO_CODECS_PATH}/libvorbis/include + ) + list(APPEND SDLMixerX_LINK_LIBS ${LIBVORBISFILE_LIB} ${LIBVORBIS_LIB}) + set(LIBOGG_NEEDED ON) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_ogg.c) + endif() +endif() + +option(USE_OPUS "Build with OPUS codec" ON) +if(USE_OPUS) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(opusfile op_open_file "opus/opusfile.h" FOUND_OPUS) + find_path(LIBOPUS_INCLUDE_DIR opus/opusfile.h) + find_library(LIBOPUSFILE_LIB NAMES opusfile) + find_library(LIBOPUS_LIB NAMES opusfile) + message("Opus: ${LIBOPUS_INCLUDE_DIR} ${LIBOPUSFILE_LIB} ${LIBOPUS_LIB}") + else() + set(FOUND_OPUS 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBOPUSFILE_LIB opusfile) + set(LIBOPUS_LIB opus) + else() + find_library(LIBOPUSFILE_LIB NAMES opusfile + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + find_library(LIBOPUS_LIB NAMES opus + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_OPUS) + message("== using Opus ==") + add_definitions(-DMUSIC_OPUS) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS + ${AUDIO_CODECS_PATH}/libogg/include + ${AUDIO_CODECS_PATH}/libopus/include + ${AUDIO_CODECS_PATH}/libopusfile/include + ) + endif() + if(AUDIO_CODECS_INSTALL_DIR) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_INSTALL_DIR}/include/opus) + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBOPUSFILE_LIB} ${LIBOPUS_LIB}) + set(LIBOGG_NEEDED ON) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_opus.c) + endif() +endif() + +option(USE_FLAC "Build with FLAC codec" ON) +if(USE_FLAC) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(FLAC FLAC__format_sample_rate_is_valid "FLAC/format.h" FOUND_FLAC) + find_path(LIBFLAC_INCLUDE_DIR "FLAC/all.h") + find_library(LIBFLAC_LIB NAMES FLAC) + message("FLAC: ${LIBFLAC_INCLUDE_DIR} ${LIBFLAC_LIB}") + else() + set(FOUND_FLAC 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBFLAC_LIB FLAC) + else() + find_library(LIBFLAC_LIB NAMES FLAC + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_FLAC) + message("== using FLAC ==") + add_definitions(-DMUSIC_FLAC -DFLAC__NO_DLL) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS + ${AUDIO_CODECS_PATH}/libogg/include + ${AUDIO_CODECS_PATH}/libFLAC/include + ) + endif() + set(LIBOGG_NEEDED ON) + list(APPEND SDLMixerX_LINK_LIBS ${LIBFLAC_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_flac.c) + endif() +endif() + +if(LIBOGG_NEEDED) + if(USE_SYSTEM_AUDIO_LIBRARIES) + find_library(LIBOGG_LIB NAMES ogg) + else() + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBOGG_LIB ogg) + else() + find_library(LIBOGG_LIB NAMES ogg + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBOGG_LIB}) +endif() + +option(USE_MP3_ID3TAG "Build with MP3 Meta tags support provided by libID3Tag library" ON) +if(USE_MP3_ID3TAG AND NOT USE_SYSTEM_AUDIO_LIBRARIES) + message("== using ID3Tag (custom) ==") + add_definitions(-DMUSIC_MP3_ID3TAG) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libid3tag/include) + endif() + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBID3TAG_LIB id3tag) + else() + find_library(LIBID3TAG_LIB NAMES id3tag + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBID3TAG_LIB}) +endif() + +option(USE_MP3_MAD "Build with MAD MP3 codec" ON) +option(USE_MP3_MAD_GPL_DITHERING "Enable GPL-Licensed dithering functions for MAD library" ON) +if(USE_MP3_MAD) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(mad mad_frame_init "mad.h" FOUND_MAD) + find_path(LIBMAD_INCLUDE_DIR "FLAC/all.h") + find_library(LIBMAD_LIB NAMES mad) + message("MAD: ${LIBMAD_INCLUDE_DIR} ${LIBMAD_LIB}") + else() + set(FOUND_MAD 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBMAD_LIB mad) + else() + find_library(LIBMAD_LIB NAMES mad + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_MAD) + message("== using MAD ==") + add_definitions(-DMUSIC_MP3_MAD) + if(USE_MP3_MAD_GPL_DITHERING) + add_definitions(-DMUSIC_MP3_MAD_GPL_DITHERING) + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBMAD_LIB}) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libmad/include) + endif() + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_mad.c) + endif() +endif() + +option(USE_MP3_SMPEG "Build with SMPEG MP3 codec" OFF) +if(USE_MP3_SMPEG) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(smpeg SMPEG_new "smpeg/smpeg.h" FOUND_SMPEG) + find_path(LIBSMPEG_INCLUDE_DIR "smpeg/smpeg.h") + find_library(LIBSMPEG_LIB NAMES smpeg) + message("SMPEG: ${LIBSMPEG_INCLUDE_DIR} ${LIBSMPEG_LIB}") + else() + set(FOUND_SMPEG 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBSMPEG_LIB smpeg) + else() + find_library(LIBSMPEG_LIB NAMES smpeg + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_SMPEG) + message("== using SMPEG ==") + add_definitions(-DMUSIC_MP3_SMPEG) + list(APPEND SDLMixerX_LINK_LIBS ${LIBSMPEG_LIB}) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/smpeg/include) + endif() + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_smpeg.c) + endif() +endif() + +option(USE_MP3_MPG123 "[WIP, DON'T USE IT] Build with MPG123 MP3 codec" OFF) +if(USE_MP3_MPG123) + add_definitions(-DMUSIC_MP3_MPG123) + + message(WARNING "MPG123 SUPPORT IS WIP, DON'T USE IT IN PRODUCTION!!!") + # ======= Until AudioCodecs will receive buildable mpg123, detect it externally ======= + include(cmake/FindMpg123.cmake) + + if(NOT MPG123_FOUND) + message(FATAL_ERROR "MPG123 is not found!") + else() + message("MPG123 found in ${MPG123_INCLUDE_DIR} folder") + endif() + + list(APPEND SDL_MIXER_INCLUDE_PATHS ${MPG123_INCLUDE_DIRS}) + set(LIBS ${LIBS} ${MPG123_LIBRARIES}) + list(APPEND SDLMixerX_LINK_LIBS mpg123) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_mpg123.c) +endif() + +if(USE_MP3_MAD OR USE_MP3_MPG123 OR USE_MP3_SMPEG) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_id3tag.c) +endif() + +option(USE_MODPLUG "Build with ModPlug library" ON) +if(USE_MODPLUG) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(modplug ModPlug_Load "libmodplug/modplug.h" FOUND_MODPLUG) + find_path(LIBMODPLUG_INCLUDE_DIR libmodplug/modplug.h) + find_library(LIBMODPLUG_LIB NAMES modplug) + message("ModPlug: ${LIBMODPLUG_INCLUDE_DIR} ${LIBMODPLUG_LIB}") + else() + set(FOUND_MODPLUG 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBMODPLUG_LIB modplug) + else() + find_library(LIBMODPLUG_LIB NAMES modplug + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_MODPLUG) + message("== using libModPlug ==") + add_definitions(-DMUSIC_MOD_MODPLUG -DMODPLUG_STATIC) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libmodplug/include) + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBMODPLUG_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_modplug.c) + endif() +endif() + +option(USE_MIKMOD "Build with MikMod library" OFF) +if(USE_MIKMOD) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(mikmod Player_Load "mikmod.h" FOUND_MIKMOD) + find_path(LIBMIKMOD_INCLUDE_DIR "mikmod.h") + find_library(LIBMIKMOD_LIB NAMES mikmod) + message("MikMod: ${LIBMIKMOD_INCLUDE_DIR} ${LIBMIKMOD_LIB}") + else() + set(FOUND_MIKMOD 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBMIKMOD_LIB mikmod) + else() + find_library(LIBMIKMOD_LIB NAMES mikmod + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_MIKMOD) + message("== using MikMod ==") + add_definitions(-DMUSIC_MOD_MIKMOD) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libmikmod/include) + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBMIKMOD_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_mikmod.c) + endif() +endif() + +option(USE_GME "Build with Game Music Emulators library" ON) +if(USE_GME) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(gme gme_load_file "gme.h" FOUND_GME) + find_path(LIBGME_INCLUDE_DIR "gme.h") + find_library(LIBGME_LIB NAMES gme) + find_library(LIBZLIB_LIB NAMES z zlib) + message("GME: ${LIBGME_INCLUDE_DIR} ${LIBGME_LIB}") + else() + set(FOUND_GME 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBGME_LIB gme) + set(LIBZLIB_LIB zlib) + else() + find_library(LIBGME_LIB NAMES gme + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + find_library(LIBZLIB_LIB NAMES zlib z + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_GME) + message("== using GME ==") + add_definitions(-DMUSIC_GME) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libgme/include) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/zlib/include) + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBGME_LIB} ${LIBZLIB_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_gme.c) + endif() +endif() + +if(NOT WIN32) # CMD Music is not supported on Windows + option(USE_CMD "Build with CMD music player support" ON) + if(USE_CMD) + message("== using CMD Music ==") + add_definitions(-DMUSIC_CMD -D_POSIX_C_SOURCE=1) + CHECK_FUNCTION_EXISTS(fork HAVE_FORK) + if(HAVE_FORK) + add_definitions(-DHAVE_FORK) + endif() + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_cmd.c) + endif() +endif() + +option(USE_MIDI "Build with MIDI support" ON) +if(USE_MIDI) + + option(USE_MIDI_ADLMIDI "Build with libADLMIDI OPL3 Emulator based MIDI sequencer support" ON) + if(USE_MIDI_ADLMIDI) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(ADLMIDI adl_init "adlmidi.h" FOUND_ADLMIDI) + find_path(LIBADLMIDI_INCLUDE_DIR "adlmidi.h") + find_library(LIBADLMIDI_LIB NAMES ADLMIDI) + message("ADLMIDI: ${LIBADLMIDI_INCLUDE_DIR} ${LIBADLMIDI_LIB}") + else() + set(FOUND_ADLMIDI 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBADLMIDI_LIB ADLMIDI) + else() + find_library(LIBADLMIDI_LIB NAMES ADLMIDI + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_ADLMIDI) + message("== using ADLMIDI ==") + add_definitions(-DMUSIC_MID_ADLMIDI) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libADLMIDI/include) + endif() + set(LIBMATH_NEEDED 1) + list(APPEND SDLMixerX_LINK_LIBS ${LIBADLMIDI_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_midi_adl.c) + endif() + endif() + + option(USE_MIDI_OPNMIDI "Build with libOPNMIDI OPN2 Emulator based MIDI sequencer support" ON) + if(USE_MIDI_OPNMIDI) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(OPNMIDI opn_init "opnmidi.h" FOUND_OPNMIDI) + find_path(LIBOPNMIDI_INCLUDE_DIR "opnmidi.h") + find_library(LIBOPNMIDI_LIB NAMES OPNMIDI) + message("OPNMIDI: ${LIBOPNMIDI_INCLUDE_DIR} ${LIBOPNMIDI_LIB}") + else() + set(FOUND_OPNMIDI 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBOPNMIDI_LIB OPNMIDI) + else() + find_library(LIBOPNMIDI_LIB NAMES OPNMIDI + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_OPNMIDI) + message("== using OPNMIDI ==") + add_definitions(-DMUSIC_MID_OPNMIDI) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libOPNMIDI/include) + endif() + set(LIBMATH_NEEDED 1) + list(APPEND SDLMixerX_LINK_LIBS ${LIBOPNMIDI_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_midi_opn.c) + endif() + endif() + + option(USE_MIDI_TIMIDITY "Build with Timidity wave table MIDI sequencer support" ON) + if(USE_MIDI_TIMIDITY AND NOT USE_SYSTEM_AUDIO_LIBRARIES) + message("== using Timidity (custom) ==") + add_definitions(-DMUSIC_MID_TIMIDITY) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/libtimidity/include) + endif() + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBTIMIDITY_LIB timidity) + else() + find_library(LIBTIMIDITY_LIB NAMES timidity + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBTIMIDITY_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_timidity.c) + endif() + + option(USE_MIDI_FLUIDSYNTH "Build with FluidSynth wave table MIDI sequencer support" OFF) + if(USE_MIDI_FLUIDSYNTH) + if(USE_SYSTEM_AUDIO_LIBRARIES) + check_library_exists(fluidsynth new_fluid_midi_router "fluidsynth.h" FOUND_FLUIDSYNTH) + find_path(LIBFLUIDSYNTH_INCLUDE_DIR "fluidsynth.h") + find_library(LIBFLUIDSYNTH_LIB NAMES fluidsynth) + message("FluidSynth: ${LIBFLUIDSYNTH_INCLUDE_DIR} ${LIBFLUIDSYNTH_LIB}") + else() + set(FOUND_FLUIDSYNTH 1) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBFLUIDSYNTH_LIB fluidsynth) + else() + find_library(LIBFLUIDSYNTH_LIB NAMES fluidsynth + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() + endif() + if(FOUND_FLUIDSYNTH) + message("== using FluidSynth ==") + add_definitions(-DMUSIC_MID_FLUIDSYNTH) + if(AUDIO_CODECS_REPO_PATH) + list(APPEND SDL_MIXER_INCLUDE_PATHS ${AUDIO_CODECS_PATH}/FluidLite/include) + endif() + list(APPEND SDLMixerX_LINK_LIBS ${LIBFLUIDSYNTH_LIB}) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_fluidsynth.c) + endif() + endif() + + # Native MIDI correctly works on Windows and macOS only. + if(WIN32 OR APPLE) + set(NATIVE_MIDI_SUPPORTED ON) + else() + set(NATIVE_MIDI_SUPPORTED OFF) + endif() + + option(USE_MIDI_NATIVE "Build with operating system native MIDI output support" ${NATIVE_MIDI_SUPPORTED}) + if(USE_MIDI_NATIVE) + add_definitions(-DMUSIC_MID_NATIVE) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/music_nativemidi.c + ${SDLMixerX_SOURCE_DIR}/src/codecs/native_midi/native_midi_common.c) + if(WIN32) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/native_midi/native_midi_win32.c) + list(APPEND SDLMixerX_LINK_LIBS winmm) + endif() + if(APPLE) + list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/codecs/native_midi/native_midi_macosx.c) + endif() + endif() + if(NOT USE_MIDI_ADLMIDI AND + NOT USE_MIDI_OPNMIDI AND + NOT USE_MIDI_TIMIDITY AND + NOT USE_MIDI_FLUIDSYNTH AND + NOT USE_MIDI_NATIVE) + message_error("To have MIDI support you must enable at least one MIDI sequencer library") + endif() + +endif() + +if(USE_SYSTEM_AUDIO_LIBRARIES) + find_library(LIBSDL2CUSTOM_LIB NAMES SDL2) +else() + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + set(LIBSDL2CUSTOM_LIB SDL2$<$:d>) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES ${FIND_PREFER_SHARED}) + find_library(LIBSDL2CUSTOM_LIB NAMES SDL2 + HINTS "${AUDIO_CODECS_INSTALL_PATH}/lib") + endif() +endif() +list(APPEND SDLMixerX_LINK_LIBS ${LIBSDL2CUSTOM_LIB}) + +if(LIBMATH_NEEDED AND NOT MSVC) + list(APPEND SDLMixerX_LINK_LIBS m) +endif() + +if(WIN32) + option(BUILD_AS_VB6_BINDING "Compile library into solid module compatible with VisualBasic 6" OFF) + if(BUILD_AS_VB6_BINDING) + message("== SDL Mixer X will be built as solid module that is ready for MS-VB6 binding! ==") + list(APPEND SDLMixerX_SOURCES ${SDLMixerX_SOURCE_DIR}/src/vb6_binding/vb6_sdl_binds.c) + list(REMOVE_ITEM SDLMixerX_LINK_LIBS SDL2) + list(REMOVE_ITEM SDLMixerX_LINK_LIBS SDL2$<$:d>) + list(APPEND SDLMixerX_LINK_LIBS + SDL2-static + uuid winmm ole32 imm32 version oleaut32 user32 gdi32) + if(NOT MSVC) + list(APPEND SDLMixerX_LINK_LIBS stdc++ gcc pthread) + endif() + endif() +endif() + +if(APPLE) + find_library(APPLE_CORE_AUDIO CoreAudio) + find_library(APPLE_IOKIT IOKit) + find_library(APPLE_COCOA Cocoa) + find_library(APPLE_AUDIOTOOLBOX AudioToolbox) + find_library(APPLE_CORE_VIDEO CoreVideo) + find_library(APPLE_CORE_FOUNDATION CoreFoundation) + find_library(APPLE_CARBON Carbon) + find_library(APPLE_FORCE_FEEDBACK ForceFeedback) + find_library(ICONV_LIB iconv) + list(APPEND SDLMixerX_LINK_LIBS + ${APPLE_CORE_AUDIO} + ${APPLE_COCOA} + ${APPLE_CORE_VIDEO} + ${APPLE_CORE_FOUNDATION} + ${APPLE_FORCE_FEEDBACK} + ${APPLE_IOKIT} + ${APPLE_CARBON} + ${APPLE_AUDIOTOOLBOX} + ${ICONV_LIB}) + list(APPEND SDLMixerX_LINK_LIBS objc) +endif() + +if(NOT MSVC) + list(APPEND SDLMixerX_LINK_LIBS stdc++) +endif() + +list(APPEND SDLMixerX_SOURCES + ${SDLMixerX_SOURCE_DIR}/src/effect_position.c + ${SDLMixerX_SOURCE_DIR}/src/effects_internal.c + ${SDLMixerX_SOURCE_DIR}/src/effect_stereoreverse.c + ${SDLMixerX_SOURCE_DIR}/src/mixer.c + ${SDLMixerX_SOURCE_DIR}/src/music.c + ${SDLMixerX_SOURCE_DIR}/src/mixer_x_deprecated.c + ) + +file(GLOB SDLMixerX_SOURCES ${SDLMixerX_SOURCES}) + +set(SDLMixerX_INSTALLS) + +if(SDL_MIXER_X_STATIC AND NOT BUILD_AS_VB6_BINDING) + add_library(SDL2_mixer_ext_Static STATIC ${SDLMixerX_SOURCES}) + if(WIN32) + set_target_properties(SDL2_mixer_ext_Static PROPERTIES OUTPUT_NAME SDL2_mixer_ext-static) + else() + set_target_properties(SDL2_mixer_ext_Static PROPERTIES OUTPUT_NAME SDL2_mixer_ext) + endif() + target_include_directories(SDL2_mixer_ext_Static PRIVATE + ${SDLMixerX_SOURCE_DIR}/include/SDL_mixer_ext + ${SDLMixerX_SOURCE_DIR}/src + ${SDLMixerX_SOURCE_DIR}/src/codecs + ${AUDIO_CODECS_INSTALL_DIR}/include/SDL2 + ) + target_include_directories(SDL2_mixer_ext_Static PUBLIC + ${SDLMixerX_SOURCE_DIR}/include + ${SDL_MIXER_INCLUDE_PATHS} + ) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY AND AUDIO_CODECS_INSTALL_PATH) + add_dependencies(SDL2_mixer_ext_Static AudioCodecs) + endif() + set_target_properties(SDL2_mixer_ext_Static + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + ) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + add_custom_command( + TARGET SDL2_mixer_ext_Static POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/include/SDL_mixer_ext/SDL_mixer_ext.h + ${AUDIO_CODECS_INSTALL_DIR}/include/SDL2) + endif() + list(APPEND SDLMixerX_INSTALLS SDL2_mixer_ext_Static) +endif() + +if(WIN32) + list(APPEND SDLMixerX_SOURCES ${SDLMixerX_SOURCE_DIR}/version.rc) +endif() + +if(SDL_MIXER_X_SHARED AND NOT BUILD_AS_VB6_BINDING) + add_library(SDL2_mixer_ext SHARED ${SDLMixerX_SOURCES}) + target_link_libraries(SDL2_mixer_ext ${SDLMixerX_LINK_LIBS}) + target_include_directories(SDL2_mixer_ext PRIVATE + ${SDLMixerX_SOURCE_DIR}/include/SDL_mixer_ext + ${SDLMixerX_SOURCE_DIR}/src + ${SDLMixerX_SOURCE_DIR}/src/codecs + ${AUDIO_CODECS_INSTALL_DIR}/include/SDL2 + ) + target_include_directories(SDL2_mixer_ext PUBLIC + ${SDLMixerX_SOURCE_DIR}/include + ${SDL_MIXER_INCLUDE_PATHS} + ) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY AND AUDIO_CODECS_INSTALL_PATH) + add_dependencies(SDL2_mixer_ext AudioCodecs) + endif() + set_target_properties(SDL2_mixer_ext + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + ) + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + add_custom_command( + TARGET SDL2_mixer_ext POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/include/SDL_mixer_ext/SDL_mixer_ext.h + ${AUDIO_CODECS_INSTALL_DIR}/include/SDL2) + endif() + list(APPEND SDLMixerX_INSTALLS SDL2_mixer_ext) +endif() + +if(BUILD_AS_VB6_BINDING) + add_library(SDL2_mixer_ext_VB6 MODULE ${SDLMixerX_SOURCES}) + set_target_properties(SDL2_mixer_ext_VB6 PROPERTIES OUTPUT_NAME SDL2MixerVB) + set_target_properties(SDL2_mixer_ext_VB6 PROPERTIES PREFIX "") + target_compile_definitions(SDL2_mixer_ext_VB6 PRIVATE -DFORCE_STDCALLS) + target_link_libraries(SDL2_mixer_ext_VB6 ${SDLMixerX_LINK_LIBS}) + target_include_directories(SDL2_mixer_ext_VB6 PUBLIC + ${SDLMixerX_SOURCE_DIR}/include/SDL_mixer_ext + ${SDLMixerX_SOURCE_DIR}/src + ${SDLMixerX_SOURCE_DIR}/src/codecs + ${AUDIO_CODECS_INSTALL_DIR}/include/SDL2 + ) + target_include_directories(SDL2_mixer_ext_VB6 PUBLIC + ${SDLMixerX_SOURCE_DIR}/include + ${SDL_MIXER_INCLUDE_PATHS} + ) + set_target_properties(SDL2_mixer_ext_VB6 PROPERTIES LINK_FLAGS + "-Wl,--add-stdcall-alias -static-libgcc -static-libstdc++ -static -lpthread") + if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY AND AUDIO_CODECS_INSTALL_PATH) + add_dependencies(SDL2_mixer_ext_VB6 AudioCodecs) + endif() + set_target_properties(SDL2_mixer_ext_VB6 + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdl-mixer-vb6" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdl-mixer-vb6" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/sdl-mixer-vb6" + ) + add_custom_command( + TARGET SDL2_mixer_ext_VB6 POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_SOURCE_DIR}/VB6_Wrapper/modSDL2_mixer_ext_vb6.bas + ${CMAKE_BINARY_DIR}/sdl-mixer-vb6) + list(APPEND SDLMixerX_INSTALLS SDL2_mixer_ext_VB6) +endif() + +install(TARGETS ${SDLMixerX_INSTALLS} + RUNTIME DESTINATION "bin" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + FRAMEWORK DESTINATION "lib" + INCLUDES DESTINATION "include") + +if(DOWNLOAD_AUDIO_CODECS_DEPENDENCY) + install(DIRECTORY ${AUDIO_CODECS_INSTALL_DIR}/bin + DESTINATION .) + install(DIRECTORY ${AUDIO_CODECS_INSTALL_DIR}/lib + DESTINATION .) + install(DIRECTORY ${AUDIO_CODECS_INSTALL_DIR}/include + DESTINATION .) +endif() + +install(FILES + include/SDL_mixer_ext/begin_code.h + include/SDL_mixer_ext/close_code.h + include/SDL_mixer_ext/SDL_mixer_ext.h + DESTINATION include/SDL2) + diff --git a/libs/SDLMixerX/COPYING.txt b/libs/SDLMixerX/COPYING.txt new file mode 100644 index 000000000..e8f8643f2 --- /dev/null +++ b/libs/SDLMixerX/COPYING.txt @@ -0,0 +1,24 @@ +/* + SDL Mixer X: An extended audio mixer library, forked from SDL_mixer + Copyright (C) 2014-2018 Vitaly Novichkov + + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +*/ diff --git a/libs/SDLMixerX/GPLv2.txt b/libs/SDLMixerX/GPLv2.txt new file mode 100644 index 000000000..1f963da0d --- /dev/null +++ b/libs/SDLMixerX/GPLv2.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. + diff --git a/libs/SDLMixerX/GPLv3.txt b/libs/SDLMixerX/GPLv3.txt new file mode 100644 index 000000000..10926e87f --- /dev/null +++ b/libs/SDLMixerX/GPLv3.txt @@ -0,0 +1,675 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + diff --git a/libs/SDLMixerX/README.txt b/libs/SDLMixerX/README.txt new file mode 100644 index 000000000..998e0d9d3 --- /dev/null +++ b/libs/SDLMixerX/README.txt @@ -0,0 +1,248 @@ +SDL Mixer X (aka SDL Mixer 2.0 Modded or SDL_mixer_ext), +by Vitaly Novichkov , +forked from SDL Mixer 2.0 by Sam Lantinga + +vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +WARNING: The licenses for libmad, ADLMIDI, OPNMIDI, and GME is GPL, + which means that in order to use it your application must + also be GPL! +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The latest original version of this library is available from: +http://www.libsdl.org/projects/SDL_mixer/ + +Sources of modified library version is available in the PGE Project's sources: +https://github.com/Wohlhabend-Networks/PGE-Project/ + in the folder: _Libs/SDL2_mixer_modified/ +or: +https://bitbucket.org/Wohlstand/pge-project + in the folder: _Libs/SDL2_mixer_modified/ + +============================================================================= +Difference between original and this library: +----------------------------------------------------------------------------- ++ Added new codecs: + - Game Music Emulators (LGPL v2.1) which adds support of chip tunes + like NSF, VGM, SPC, HES, etc. + - libADLMIDI (GPL v3, LGPL v3) (remake from ADLMIDI) to play MIDI with + emulated OPL3 synthesiser, also supports loop points + "loopStart" and "loopEnd" + - libOPNMIDI (GPL v3, LGPL v3) to play MIDI with + emulated OPN2 synthesiser, also supports loop points + "loopStart" and "loopEnd" ++ Added some new functions ++ Added support of loop points for OGG files (via "LOOPSTART" and "LOOPEND" + (or "LOOPLENGTH" to be compatible with RPG Maker) vorbis comments) ++ Reorganized music codecs processing system ++ Added support to get current position and track lenght for a seekable codecs + +vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +IMPORTANT: To choice a track number of NSF, GBM, HES, etc file, + you must append "|xxx" to end of file path for + Mix_LoadMUS function. + Where xxx - actual number of chip track, (from 0 to N-1) + Examples: "file.nsf|12", "file.hes|2" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +Arguments are passing like argument for a GME-based files (NSF, HES, etc.): +Syntax for MIDI is: + myfile.mid|xyy;xyy;xyy;...; + where x - parameter type + where y - value (every value must be ended with semicolon!) + +available parameters: + s - use a specific synthesiser + 0 - ADLMIDI + 1 - Native MIDI [Win32/OSX/Haiku only] + 2 - Timidity + 3 - Fluidsynth + b - value from 0 to 66 - number of ADLMIDI bank + t - (0 or 1) enable deep tremolo on ADLMIDI + v - (0 or 1) enable deep vibrato on ADLMIDI + m - (0 or 1) enable scalable modulation on ADLMIDI + a - (0 or 1) enable AdLib mode of percussion on ADLMIDI +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +============================================================================= +Added music codecs: +----------------------------------------------------------------------------- +General: +- MUS_GME - Game Music Emulatirs + +MIDI Playing: +- ADLMIDI - A software synthesizer is based on Yamaha OPL3 (YMF262) chip emulator +- OPNMIDI - A software synthesizer is based on Yamaha OPL3 (YM2612) chip emulator + +============================================================================= +Added functions: +----------------------------------------------------------------------------- +/* + Allows you to set up custom path for Timidify patches +*/ +void MIX_Timidity_addToPathList(const char *path); + +/* + Get music title from meta-tag if possible. If title tag is empty, filename will be returned +*/ +const char* Mix_GetMusicTitle(const Mix_Music *music); + +/* + Get music title from meta-tag if possible +*/ +const char* Mix_GetMusicTitleTag(const Mix_Music *music); + +/* + Get music artist from meta-tag if possible +*/ +const char* Mix_GetMusicArtistTag(const Mix_Music *music); + +/* + Get music album from meta-tag if possible +*/ +const char* Mix_GetMusicAlbumTag(const Mix_Music *music); + +/* + Get music copyright from meta-tag if possible +*/ +const char* Mix_GetMusicCopyrightTag(const Mix_Music *music); + +/* + Load music from memory with passing of extra arguments +*/ +Mix_Music * SDLCALLCC Mix_LoadMUS_RW_ARG(SDL_RWops *src, int freesrc, char *args) + +/* + Load music from memory with passing NSF/HES/etc. track number (accepts integer unlike SDLCALLCC Mix_LoadMUS_RW_ARG) +*/ +Mix_Music * SDLCALLCC Mix_LoadMUS_RW_GME(SDL_RWops *src, int freesrc, int trackID) + +typedef enum +{ + MIDI_ADLMIDI, + MIDI_Native, + MIDI_Timidity, + MIDI_OPNMIDI, + MIDI_Fluidsynth, + MIDI_KnuwnDevices /* Count of MIDI device types */ +} Mix_MIDI_Device; + +/* + Allows you to toggle MIDI Devices! + (change will be applied on re-opening of MIDI file) + Attempt to toggle unsupported MIDI device takes no effect + (for case when library built without linking of required library) +*/ +int Mix_SetMidiDevice(int device); + +/* + Returns current ADLMIDI bank number +*/ +int MIX_ADLMIDI_getBankID(); + +/* + Changes ADLMIDI bank number (changes applying on MIDI file reopen) +*/ +void MIX_ADLMIDI_setBankID(int bnk); + +/* + Returns current state of ADLMIDI deep tremolo flag +*/ +int MIX_ADLMIDI_getTremolo(); + +/* + Changes ADLMIDI deep tremolo flag (changes applying on MIDI file reopen) +*/ +void MIX_ADLMIDI_setTremolo(int tr); + +/* + Returns current state of ADLMIDI deep vibrato flag +*/ +int MIX_ADLMIDI_getVibrato(); + +/* + Changes ADLMIDI deep vibrato flag (changes applying on MIDI file reopen) +*/ +void MIX_ADLMIDI_setVibrato(int vib); + +/* + Returns current state of ADLMIDI deep scaling modulation flag +*/ +int MIX_ADLMIDI_getScaleMod(); + +/* + Changes ADLMIDI scaling modulation flag (changes applying on MIDI file reopen) +*/ +void MIX_ADLMIDI_setScaleMod(int sc); + +/* + Resets ADLMIDI flags and settings to default state +*/ +void MIX_ADLMIDI_setSetDefaults(); + +/* + Get the time current position of music stream + returns -1.0 if this feature is not supported for some codec +*/ +double Mix_GetMusicPosition(Mix_Music *music); +/* + Get the total time length of music stream + returns -1.0 if this feature is not supported for some codec + */ +double Mix_GetMusicTotalTime(Mix_Music *music); + +/* + Get the loop start time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec +*/ +double Mix_GetMusicLoopStartTime(Mix_Music *music); +/* + Get the loop end time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec +*/ +double Mix_GetMusicLoopEndTime(Mix_Music *music); +/* + Get the loop time length of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec +*/ +double Mix_GetMusicLoopLengthTime(Mix_Music *music); + +============================================================================= + +Due to popular demand, here is a simple multi-channel audio mixer. +It supports 8 channels of 16 bit stereo audio, plus a single channel +of music, mixed by the Modplug MOD, Timidity MIDI, ADLMIDI, GME +and LibMAD MP3 libraries. + +See the header file SDL_mixer_ext.h for documentation on this mixer library. + +The mixer can currently load Microsoft WAVE files and Creative Labs VOC +files as audio samples, and can load MIDI files via Timidity and the +following music formats via MikMod: .MOD .S3M .IT .XM. It can load +Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries, +and finally it can load MP3 music using the SMPEG or libmad libraries. + +Tremor decoding is disabled by default; you can enable it by passing + --enable-music-ogg-tremor +to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR. + +libmad decoding is disabled by default; you can enable it by passing + --enable-music-mp3-mad +to configure, or by defining MP3_MAD_MUSIC +vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv +WARNING: The license for libmad is GPL, which means that in order to + use it your application must also be GPL! +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The process of mixing MIDI files to wave output is very CPU intensive, +so if playing regular WAVE files sound great, but playing MIDI files +sound choppy on slow computers, try using 8-bit audio, mono audio, +or lower frequencies. + +To play MIDI files via Timidity, you'll need to get a complete set of GUS patches +from: +http://www.libsdl.org/projects/mixer/timidity/timidity.tar.gz +and unpack them in /usr/local/lib under UNIX, and C:\ under Win32. + +This library is under the zlib license, see the file "COPYING.txt" for details. + + + diff --git a/libs/SDLMixerX/SDL2_mixer_ext.License.txt b/libs/SDLMixerX/SDL2_mixer_ext.License.txt new file mode 100644 index 000000000..58806358d --- /dev/null +++ b/libs/SDLMixerX/SDL2_mixer_ext.License.txt @@ -0,0 +1,104 @@ +======================================================================== +SDL_mixer_ext {aka SDL Mixer X, SDL Mixer 2.0 Modded}, by Vitaly Novichkov +forked from SDL Mixer 2.0 by Sam Lantinga +======================================================================== + +SDL_mixer_ext: An extended audio mixer library, forked from SDL_mixer +Copyright (C) 2014-2018 Vitaly Novichkov + +SDL_mixer: An audio mixer library based on the SDL library +Copyright (C) 1997-2018 Sam Lantinga + +Sources of modified library version is available on GitHub: +https://github.com/WohlSoft/SDL-Mixer-X + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +======================================================================== +Statically linked libraries: +======================================================================== +------------------------------------------------------------------------ +libADLMIDI: is a free MIDI to WAV conversion library with OPL3 emulation + +Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma +ADLMIDI Library API: Copyright (c) 2015-2018 Vitaly Novichkov + +Library is based on the ADLMIDI, a MIDI player for Linux and Windows +with OPL3 emulation: +http://iki.fi/bisqwit/source/adlmidi.html + +Source code: https://github.com/Wohlstand/libADLMIDI + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +------------------------------------------------------------------------ + +Game Music Emulators: is a free chuptunes to WAV conversion library. + +Source code: https://bitbucket.org/mpyne/game-music-emu + +Copyright (C) 2003-2006 Shay Green. + +This module is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published +by the Free Software Foundation; either version 2.1 of the License, +or (at your option) any later version. + +This module is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this module; +If not, see . + +------------------------------------------------------------------------ + +libmad: MPEG audio decoder library + +Copyright (C) 2000-2004 Underbit Technologies, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +If you would like to negotiate alternate licensing terms, you may do +so by contacting: Underbit Technologies, Inc. + +------------------------------------------------------------------------ diff --git a/libs/SDLMixerX/SRB2Note.txt b/libs/SDLMixerX/SRB2Note.txt new file mode 100644 index 000000000..6036d394e --- /dev/null +++ b/libs/SDLMixerX/SRB2Note.txt @@ -0,0 +1,7 @@ +i686-w64-mingw32/bin/libfluidsynth-2.dll was grabbed from GZDoom v3.5.1, because this build does not have glib, gthread, or sndfile external dependencies. + +sdl_mixer_ext2.dll requires libgcc and libstdc++ external dependencies. While passing to the linker "-Bstatic -lgcc" works fine, adding "-lstdc++" to -Bstatic generates linker errors. + +Hence, libstdc++ needs to be bundled as DLL (and consequently, libgcc.) + +If you try to build yourself, make sure -lstdc++ does not follow -Bdynamic in the linker flags, because otherwise it will link to the DLL. diff --git a/libs/SDLMixerX/SRB2Note_cmakeflags.png b/libs/SDLMixerX/SRB2Note_cmakeflags.png new file mode 100644 index 000000000..ffcf269a4 Binary files /dev/null and b/libs/SDLMixerX/SRB2Note_cmakeflags.png differ diff --git a/libs/SDLMixerX/i686-w64-mingw32/bin/SDL2_mixer_ext.dll b/libs/SDLMixerX/i686-w64-mingw32/bin/SDL2_mixer_ext.dll new file mode 100644 index 000000000..158aad8c3 Binary files /dev/null and b/libs/SDLMixerX/i686-w64-mingw32/bin/SDL2_mixer_ext.dll differ diff --git a/libs/SDLMixerX/i686-w64-mingw32/bin/libfluidsynth-2.dll b/libs/SDLMixerX/i686-w64-mingw32/bin/libfluidsynth-2.dll new file mode 100644 index 000000000..1b768a6c1 Binary files /dev/null and b/libs/SDLMixerX/i686-w64-mingw32/bin/libfluidsynth-2.dll differ diff --git a/libs/SDLMixerX/i686-w64-mingw32/bin/libgcc_s_sjlj-1.dll b/libs/SDLMixerX/i686-w64-mingw32/bin/libgcc_s_sjlj-1.dll new file mode 100644 index 000000000..0a62946cb Binary files /dev/null and b/libs/SDLMixerX/i686-w64-mingw32/bin/libgcc_s_sjlj-1.dll differ diff --git a/libs/SDLMixerX/i686-w64-mingw32/bin/libstdc++-6.dll b/libs/SDLMixerX/i686-w64-mingw32/bin/libstdc++-6.dll new file mode 100644 index 000000000..e9feebaaa Binary files /dev/null and b/libs/SDLMixerX/i686-w64-mingw32/bin/libstdc++-6.dll differ diff --git a/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/SDL_mixer_ext.h b/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/SDL_mixer_ext.h new file mode 100644 index 000000000..3a6b91b50 --- /dev/null +++ b/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/SDL_mixer_ext.h @@ -0,0 +1,867 @@ +/* + SDL Mixer X: An extended audio mixer library, forked from SDL_mixer + Copyright (C) 2014-2018 Vitaly Novichkov + + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_MIXER_H_ +#define SDL_MIXER_H_ + +#include "SDL_stdinc.h" +#include "SDL_rwops.h" +#include "SDL_audio.h" +#include "SDL_endian.h" +#include "SDL_version.h" +#include "begin_code.h" + +/* Let applications recogonize which SDL Mixer edition is in use: Official or Extended fork by Wohlstand */ +#define SDL_MIXER_X 1 + +#define MIXSDLCALL + +#if defined(FORCE_STDCALLS) && defined(_WIN32) +#ifdef SDLCALL +#undef SDLCALL +#endif +#define SDLCALL __stdcall +#define SDLCALLCC __stdcall +#else +#define SDLCALLCC +#endif + +#ifndef DEPRECATED +#ifdef __GNUC__ +#define DEPRECATED(func) func __attribute__ ((deprecated)) +#elif defined(_MSC_VER) +#define DEPRECATED(func) __declspec(deprecated) func +#else +#pragma message("WARNING: You need to implement DEPRECATED for this compiler") +#define DEPRECATED(func) func +#endif +#endif + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MIXER_MAJOR_VERSION 2 +#define SDL_MIXER_MINOR_VERSION 2 +#define SDL_MIXER_PATCHLEVEL 0 + +/* This macro can be used to fill a version structure with the compile-time + * version of the SDL_mixer library. + */ +#define SDL_MIXER_VERSION(X) \ +{ \ + (X)->major = SDL_MIXER_MAJOR_VERSION; \ + (X)->minor = SDL_MIXER_MINOR_VERSION; \ + (X)->patch = SDL_MIXER_PATCHLEVEL; \ +} + +/* Backwards compatibility */ +#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION +#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION +#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL +#define MIX_VERSION(X) SDL_MIXER_VERSION(X) + +/** + * This is the version number macro for the current SDL_mixer version. + */ +#define SDL_MIXER_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z. + */ +#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ + (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/* This function gets the version of the dynamically linked SDL_mixer library. + it should NOT be used to fill a version structure, instead you should + use the SDL_MIXER_VERSION() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void); + +typedef enum +{ + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_MID = 0x00000020, + MIX_INIT_OPUS = 0x00000040 +} MIX_InitFlags; + +/* Loads dynamic libraries and prepares them for use. Flags should be + one or more flags from MIX_InitFlags OR'd together. + It returns the flags successfully initialized, or 0 on failure. + */ +extern DECLSPEC int SDLCALL Mix_Init(int flags); + +/* Unloads libraries loaded with Mix_Init */ +extern DECLSPEC void SDLCALL Mix_Quit(void); + + +/* The default mixer has 8 simultaneous mixing channels */ +#ifndef MIX_CHANNELS +#define MIX_CHANNELS 8 +#endif + +/* Good default values for a PC soundcard */ +#define MIX_DEFAULT_FREQUENCY 44100 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define MIX_DEFAULT_FORMAT AUDIO_S16LSB +#else +#define MIX_DEFAULT_FORMAT AUDIO_S16MSB +#endif +#define MIX_DEFAULT_CHANNELS 2 +#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */ + +/* The internal format for an audio chunk */ +typedef struct Mix_Chunk { + int allocated; + Uint8 *abuf; + Uint32 alen; + Uint8 volume; /* Per-sample volume, 0-128 */ +} Mix_Chunk; + +/* The different fading types supported */ +typedef enum { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN +} Mix_Fading; + +/* These are types of music files (not libraries used to load them) */ +typedef enum { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD_UNUSED, + MUS_FLAC, + MUS_MODPLUG_UNUSED, + MUS_OPUS, + MUS_GME, + MUS_ADLMIDI/*Use ADLMIDI coded for super-special formats like IMF, MUS or XMI are can't be played without ADLMIDI*/ +} Mix_MusicType; + +typedef enum { + MIDI_ADLMIDI, + MIDI_Native, + MIDI_Timidity, + MIDI_OPNMIDI, + MIDI_Fluidsynth, + MIDI_ANY, + MIDI_KnuwnDevices /* Count of MIDI device types */ +} Mix_MIDI_Device; + +/* Volume model type in the ADLMIDI */ +typedef enum { + ADLMIDI_VM_AUTO, + ADLMIDI_VM_GENERIC, + ADLMIDI_VM_CMF, + ADLMIDI_VM_DMX, + ADLMIDI_VM_APOGEE, + ADLMIDI_VM_9X +} Mix_ADLMIDI_VolumeModel; + +/* OPL3 chip emulators for ADLMIDI */ +typedef enum { + ADLMIDI_OPL3_EMU_DEFAULT = -1, + ADLMIDI_OPL3_EMU_NUKED = 0, + ADLMIDI_OPL3_EMU_NUKED_1_7_4, + ADLMIDI_OPL3_EMU_DOSBOX, +} Mix_ADLMIDI_Emulator; + +/* OPN2 chip emulators for OPNMIDI */ +typedef enum { + OPNMIDI_OPN2_EMU_DEFAULT = -1, + OPNMIDI_OPN2_EMU_MIME = 0, + OPNMIDI_OPN2_EMU_NUKED, + OPNMIDI_OPN2_EMU_GENS, +} Mix_OPNMIDI_Emulator; + +/* The internal format for a music chunk interpreted via mikmod */ +typedef struct _Mix_Music Mix_Music; + +/* Open the mixer with a certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize); + +/* Open the mixer with specific device and certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes); + +/* Dynamically change the number of channels managed by the mixer. + If decreasing the number of channels, the upper channels are + stopped. + This function returns the new number of allocated channels. + */ +extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans); + +/* Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + */ +extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels); + +/* Load a wave file or a music (.mod .s3m .it .xm) file + IMPORTANT: To choice a track number of NSF, GBM, HES, etc file, + you must append "|xxx" to end of file path for + Mix_LoadMUS function. + Where xxx - actual number of chip track, (from 0 to N-1) + Examples: "file.nsf|12", "file.hes|2" +*/ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); +#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file); + +/* Load a music file from an SDL_RWop object + * Matt Campbell (matt@campbellhome.dhs.org) April 2000 */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc); + +/* Load a music file from an SDL_RWop object with custom arguments (trackID for GME or settings for a MIDI playing) + * Arguments are taking no effect for file formats which are not supports extra arguments. + */ +extern DECLSPEC Mix_Music *SDLCALL Mix_LoadMUS_RW_ARG(SDL_RWops *src, int freesrc, const char *args); + +/* Load a music file from an SDL_RWop object with custom trackID for GME. + * trackID argument takes no effect for non-NSF,HES,GBM,etc. file formats. + * Default value should be 0 + */ +extern DECLSPEC Mix_Music *SDLCALL Mix_LoadMUS_RW_GME(SDL_RWops *src, int freesrc, int trackID); + +/* Load a music file from an SDL_RWop object assuming a specific format */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc); + +/* Load a music file from an SDL_RWop object assuming a specific format + with custom arguments (trackID for GME or settings for a MIDI playing) */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW_ARG(SDL_RWops *src, Mix_MusicType type, int freesrc, const char *args); + +/* Load a wave file of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem); + +/* Load raw audio data of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len); + +/* Free an audio chunk previously loaded */ +extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk); +extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music); + +/* Get a list of chunk/music decoders that this build of SDL_mixer provides. + This list can change between builds AND runs of the program, if external + libraries that add functionality become available. + You must successfully call Mix_OpenAudio() before calling these functions. + This API is only available in SDL_mixer 1.2.9 and later. + + // usage... + int i; + const int total = Mix_GetNumChunkDecoders(); + for (i = 0; i < total; i++) + printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i)); + + Appearing in this list doesn't promise your specific audio file will + decode...but it's handy to know if you have, say, a functioning Timidity + install. + + These return values are static, read-only data; do not modify or free it. + The pointers remain valid until you call Mix_CloseAudio(). +*/ +extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name); +extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name); + +/* Find out the music format of a mixer music, or the currently playing + music, if 'music' is NULL. +*/ +extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music); + +/* Get music title from meta-tag if possible. If title tag is empty, filename will be returned */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicTitle(const Mix_Music *music); +/* Get music title from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicTitleTag(const Mix_Music *music); +/* Get music artist from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicArtistTag(const Mix_Music *music); +/* Get music album from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicAlbumTag(const Mix_Music *music); +/* Get music copyright from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicCopyrightTag(const Mix_Music *music); + +/* Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +*/ +extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own callback for when the music has finished playing or when it is + * stopped from a call to Mix_HaltMusic. + */ +extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)); + +/* Get a pointer to the user data for the current music hook */ +extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void); + +/* + * Add your own callback when a channel has finished playing. NULL + * to disable callback. The callback may be called from the mixer's audio + * callback or it could be called as a result of Mix_HaltChannel(), etc. + * do not call SDL_LockAudio() from this callback; you will either be + * inside the audio callback, or SDL_mixer will explicitly lock the audio + * before calling your callback. + */ +extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)); + + +/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */ + +#define MIX_CHANNEL_POST -2 + +/* This is the format of a special effect callback: + * + * myeffect(int chan, void *stream, int len, void *udata); + * + * (chan) is the channel number that your effect is affecting. (stream) is + * the buffer of data to work upon. (len) is the size of (stream), and + * (udata) is a user-defined bit of data, which you pass as the last arg of + * Mix_RegisterEffect(), and is passed back unmolested to your callback. + * Your effect changes the contents of (stream) based on whatever parameters + * are significant, or just leaves it be, if you prefer. You can do whatever + * you like to the buffer, though, and it will continue in its changed state + * down the mixing pipeline, through any other effect functions, then finally + * to be mixed with the rest of the channels and music for the final output + * stream. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); + +/* + * This is a callback that signifies that a channel has finished all its + * loops and has completed playback. This gets called if the buffer + * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + * a channel via Mix_AllocateChannels(), or unregister a callback while + * it's still playing. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata); + + +/* Register a special effect function. At mixing time, the channel data is + * copied into a buffer and passed through each registered effect function. + * After it passes through all the functions, it is mixed into the final + * output stream. The copy to buffer is performed once, then each effect + * function performs on the output of the previous effect. Understand that + * this extra copy to a buffer is not performed if there are no effects + * registered for a given chunk, which saves CPU cycles, and any given + * effect will be extra cycles, too, so it is crucial that your code run + * fast. Also note that the data that your function is given is in the + * format of the sound device, and not the format you gave to Mix_OpenAudio(), + * although they may in reality be the same. This is an unfortunate but + * necessary speed concern. Use Mix_QuerySpec() to determine if you can + * handle the data before you register your effect, and take appropriate + * actions. + * You may also specify a callback (Mix_EffectDone_t) that is called when + * the channel finishes playing. This gives you a more fine-grained control + * than Mix_ChannelFinished(), in case you need to free effect-specific + * resources, etc. If you don't need this, you can specify NULL. + * You may set the callbacks before or after calling Mix_PlayChannel(). + * Things like Mix_SetPanning() are just internal special effect functions, + * so if you are using that, you've already incurred the overhead of a copy + * to a separate buffer, and that these effects will be in the queue with + * any functions you've registered. The list of registered effects for a + * channel is reset when a chunk finishes playing, so you need to explicitly + * set them with each call to Mix_PlayChannel*(). + * You may also register a special effect function that is to be run after + * final mixing occurs. The rules for these callbacks are identical to those + * in Mix_RegisterEffect, but they are run after all the channels and the + * music have been mixed into a single stream, whereas channel-specific + * effects run on a given channel before any other mixing occurs. These + * global effect callbacks are call "posteffects". Posteffects only have + * their Mix_EffectDone_t function called when they are unregistered (since + * the main output stream is never "done" in the same sense as a channel). + * You must unregister them manually when you've had enough. Your callback + * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + * processing is considered a posteffect. + * + * After all these effects have finished processing, the callback registered + * through Mix_SetPostMix() runs, and then the stream goes to the audio + * device. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + * + * returns zero if error (no such channel), nonzero if added. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg); + + +/* You may not need to call this explicitly, unless you need to stop an + * effect from processing in the middle of a chunk's playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel or effect), nonzero if removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f); + + +/* You may not need to call this explicitly, unless you need to stop all + * effects from processing in the middle of a chunk's playback. Note that + * this will also shut off some internal effect processing, since + * Mix_SetPanning() and others may use this API under the hood. This is + * called internally when a channel completes playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel), nonzero if all effects removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel); + + +#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED" + +/* + * These are the internally-defined mixing effects. They use the same API that + * effects defined in the application use, but are provided here as a + * convenience. Some effects can reduce their quality or use more memory in + * the name of speed; to enable this, make sure the environment variable + * MIX_EFFECTSMAXSPEED (see above) is defined before you call + * Mix_OpenAudio(). + */ + + +/* Set the panning of a channel. The left and right channels are specified + * as integers between 0 and 255, quietest to loudest, respectively. + * + * Technically, this is just individual volume control for a sample with + * two (stereo) channels, so it can be used for more than just panning. + * If you want real panning, call it like this: + * + * Mix_SetPanning(channel, left, 255 - left); + * + * ...which isn't so hard. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the panning will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally, and returns without + * registering the effect function if the audio device is not configured + * for stereo output. Setting both (left) and (right) to 255 causes this + * effect to be unregistered, since that is the data's normal state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if panning effect enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right); + + +/* Set the position of a channel. (angle) is an integer from 0 to 360, that + * specifies the location of the sound in relation to the listener. (angle) + * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260). + * Angle 0 is due north, and rotates clockwise as the value increases. + * For efficiency, the precision of this effect may be limited (angles 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. Using 255 does not guarantee that the channel will be + * culled from the mixing process or be completely silent. For efficiency, + * the precision of this effect may be limited (distance 0 through 5 might + * all produce the same effect, 6 through 10 are equal, etc). Setting (angle) + * and (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * If the audio device is configured for mono output, then you won't get + * any effectiveness from the angle; however, distance attenuation on the + * channel will still occur. While this effect will function with stereo + * voices, it makes more sense to use voices with only one channel of sound, + * so when they are mixed through this effect, the positioning will sound + * correct. You can convert them to mono through SDL before giving them to + * the mixer in the first place if you like. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the positioning will be done to the final mixed stream before passing it + * on to the audio device. + * + * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning(). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); + + +/* Set the "distance" of a channel. (distance) is an integer from 0 to 255 + * that specifies the location of the sound in relation to the listener. + * Distance 0 is overlapping the listener, and 255 is as far away as possible + * A distance of 255 does not guarantee silence; in such a case, you might + * want to try changing the chunk's volume, or just cull the sample from the + * mixing process with Mix_HaltChannel(). + * For efficiency, the precision of this effect may be limited (distances 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. + * Setting (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the distance attenuation will be done to the final mixed stream before + * passing it on to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance); + + +/* + * !!! FIXME : Haven't implemented, since the effect goes past the + * end of the sound buffer. Will have to think about this. + * --ryan. + */ +#if 0 +/* Causes an echo effect to be mixed into a sound. (echo) is the amount + * of echo to mix. 0 is no echo, 255 is infinite (and probably not + * what you want). + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the reverbing will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. If you specify an echo + * of zero, the effect is unregistered, as the data is already in that state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo); +#endif + +/* Causes a channel to reverse its stereo. This is handy if the user has his + * speakers hooked up backwards, or you would like to have a minor bit of + * psychedelia in your sound code. :) Calling this function with (flip) + * set to non-zero reverses the chunks's usual channels. If (flip) is zero, + * the effect is unregistered. + * + * This uses the Mix_RegisterEffect() API internally, and thus is probably + * more CPU intensive than having the user just plug in his speakers + * correctly. Mix_SetReverseStereo() returns without registering the effect + * function if the audio device is not configured for stereo output. + * + * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used + * on the final mixed stream before sending it on to the audio device (a + * posteffect). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip); + +/* end of effects API. --ryan. */ + + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num); + +/* Channel grouping functions */ + +/* Attach a tag to a channel. A tag can be assigned to several mixer + channels, to form groups of channels. + If 'tag' is -1, the tag is removed (actually -1 is the tag used to + represent the group of all the channels). + Returns true if everything was OK. + */ +extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag); +/* Assign several consecutive channels to a group */ +extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag); +/* Finds the first available channel in a group of channels, + returning -1 if none are available. + */ +extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag); +/* Returns the number of channels in a group. This is also a subtle + way to get the total number of channels when 'tag' is -1 + */ +extern DECLSPEC int SDLCALL Mix_GroupCount(int tag); +/* Finds the "oldest" sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag); +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag); + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +*/ +#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1) +/* The same as above, but the sound is played at most 'ticks' milliseconds */ +extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks); +extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops); +#define Mix_PlayChannelVol(channel,chunk,loops,vol) Mix_PlayChannelTimedVolume(channel,chunk,loops,-1,vol)/*MIXER-X*/ +extern DECLSPEC int SDLCALL Mix_PlayChannelTimedVolume(int which, Mix_Chunk *chunk, int loops, int ticks, int volume);/*MIXER-X*/ + +/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ +extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms); +extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position); +#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1) +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks); +#define Mix_FadeInChannelVolume(channel,chunk,loops,ms,vol) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1,vol)/*MIXER-X*/ +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimedVolume(int which, Mix_Chunk *chunk, int loops, int ms, int ticks, int volume);/*MIXER-X*/ + + +/* Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +*/ +extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume); + +/* Halt playing of a particular channel */ +extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel); +extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag); +extern DECLSPEC int SDLCALL Mix_HaltMusic(void); + +/* Change the expiration delay for a particular channel. + The sample will stop playing after the 'ticks' milliseconds have elapsed, + or remove the expiration if 'ticks' is -1 +*/ +extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks); + +/* Halt a channel, fading it out progressively till it's silent + The ms parameter indicates the number of milliseconds the fading + will take. + */ +extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms); + +/* Query the fading status of a channel */ +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void); +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which); + +/* Pause/Resume a particular channel */ +extern DECLSPEC void SDLCALL Mix_Pause(int channel); +extern DECLSPEC void SDLCALL Mix_Resume(int channel); +extern DECLSPEC int SDLCALL Mix_Paused(int channel); + +/* Pause/Resume the music stream */ +extern DECLSPEC void SDLCALL Mix_PauseMusic(void); +extern DECLSPEC void SDLCALL Mix_ResumeMusic(void); +extern DECLSPEC void SDLCALL Mix_RewindMusic(void); +extern DECLSPEC int SDLCALL Mix_PausedMusic(void); + +/* Set the current position in the music stream. + This returns 0 if successful, or -1 if it failed or isn't implemented. + This function is only implemented for MOD music formats (set pattern + order number) and for WAV, OGG, FLAC, MP3_MAD, MP3_MPG, and MODPLUG music + (set position in seconds), at the moment. +*/ +extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position); +/* + Get the time current position of music stream + returns -1.0 if this feature is not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicPosition(Mix_Music *music); +/* + Get the total time length of music stream + returns -1.0 if this feature is not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicTotalTime(Mix_Music *music); + +/* + Get the loop start time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopStartTime(Mix_Music *music); +/* + Get the loop end time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopEndTime(Mix_Music *music); +/* + Get the loop time length of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopLengthTime(Mix_Music *music); + + +/* Check the status of a specific channel. + If the specified channel is -1, check all channels. +*/ +extern DECLSPEC int SDLCALL Mix_Playing(int channel); +extern DECLSPEC int SDLCALL Mix_PlayingMusic(void); + +/* Stop music and set external music playback command */ +extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command); + +/* Synchro value is set by MikMod from modules while playing */ +extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value); +extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void); + +/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */ +extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths); +extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void); +extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data); + +/* Get the Mix_Chunk currently associated with a mixer channel + Returns NULL if it's an invalid channel, or there's no chunk associated. +*/ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel); + +/* Close the mixer, halting all playing audio */ +extern DECLSPEC void SDLCALL Mix_CloseAudio(void); + +/* Add additional Timidity bank path */ +extern DECLSPEC void SDLCALL Mix_Timidity_addToPathList(const char *path); + +/* ADLMIDI Setup functions */ +/* Get count of available hardcoded banks */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getTotalBanks(void); +/* Get array of the bank names */ +extern DECLSPEC const char *const *SDLCALL Mix_ADLMIDI_getBankNames(void); +/* Get bank ID */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getBankID(void); +/* Set bank ID (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setBankID(int bnk); +/* Get state of deep vibrato */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getTremolo(void); +/* Set deep tremolo mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setTremolo(int tr); +/* Get state of deep vibrato */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getVibrato(void); +/* Set deep vibrato mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setVibrato(int vib); +/* Get state of scalable modulation mode */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getScaleMod(void); +/* Set scalable modulation mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setScaleMod(int sc); +/* Get state of adlib drums mode */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getAdLibMode(void); +/* Set adlib drums mode mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setAdLibMode(int tr); +/* Get state of logarithmic mode */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getLogarithmicVolumes(void); +/* Set logarithmic volumes mode in the generic/CMF volume models (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setLogarithmicVolumes(int lv); +/* Get current volume model ID */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getVolumeModel(void); +/* Change current volumes model (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setVolumeModel(int vm); +/* Get full range mode for CC74-Brightness controller */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getFullRangeBrightness(void); +/* Set full range mode for CC74-Brightness controller */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setFullRangeBrightness(int frb); +/* Get the current OPL3 Emulator for ADLMIDI */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getEmulator(void); +/* Select the OPL3 Emulator for ADLMIDI */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setEmulator(int emu); +/* Reset all ADLMIDI properties to default state */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setSetDefaults(void); + +/* Sets WOPL bank file for ADLMIDI playing device, affects on MIDI file reopen */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setCustomBankFile(const char *bank_wonl_path); + +/* Reset all OPNMIDI properties to default state */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setSetDefaults(void); +/* Get full range mode for CC74-Brightness controller */ +extern DECLSPEC int SDLCALL Mix_OPNMIDI_getFullRangeBrightness(void); +/* Set full range mode for CC74-Brightness controller */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setFullRangeBrightness(int frb); +/* Get the OPN2 Emulator for OPNMIDI */ +extern DECLSPEC int SDLCALL Mix_OPNMIDI_getEmulator(void); +/* Select the OPN2 Emulator for OPNMIDI */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setEmulator(int emu); +/* Sets WOPN bank file for OPNMIDI playing device, affects on MIDI file reopen */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setCustomBankFile(const char *bank_wonp_path); + +/* Get type of MIDI player library currently in use */ +extern DECLSPEC int SDLCALL Mix_GetMidiPlayer(void); + +/* Get type of MIDI player library prepared for next opening of MIDI file */ +extern DECLSPEC int SDLCALL Mix_GetNextMidiPlayer(void); + +/* Set the MIDI playing library (ADLMIDI, Timidity, Native MIDI (if available) and FluidSynth) */ +extern DECLSPEC int SDLCALL Mix_SetMidiPlayer(int player); + +/* Disables support of MIDI file arguments */ +extern DECLSPEC void SDLCALL Mix_SetLockMIDIArgs(int lock_midiargs); + +/* DEPRECATED NAMES for new-added SDL Mixer X functions + Those names are made with mistake - beginning with "MIX_" than "Mix_" + which makes confusion when you looking for Mix_ function in your IDE + because some applications are still use them, to don't break ABI we will keep those + aliases until we will remove all usages of them from applications and libraries are used them +*/ +DEPRECATED(extern DECLSPEC int SDLCALL Mix_GetMidiDevice(void)); +DEPRECATED(extern DECLSPEC int SDLCALL Mix_GetNextMidiDevice(void)); +DEPRECATED(extern DECLSPEC int SDLCALL Mix_SetMidiDevice(int player)); + +/* We'll use SDL for reporting errors */ +#define Mix_SetError SDL_SetError +#define Mix_GetError SDL_GetError +#define Mix_ClearError SDL_ClearError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_MIXER_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/begin_code.h b/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/begin_code.h new file mode 100644 index 000000000..6c2106246 --- /dev/null +++ b/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/begin_code.h @@ -0,0 +1,167 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +#ifndef SDL_UNUSED +# ifdef __GNUC__ +# define SDL_UNUSED __attribute__((unused)) +# else +# define SDL_UNUSED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) || defined(__WINRT__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# elif defined(__OS2__) +# ifdef BUILD_SDL +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#define SDLCALL __cdecl +#elif defined(__OS2__) || defined(__EMX__) +#define SDLCALL _System +# if defined (__GNUC__) && !defined(_System) +# define _System /* for old EMX/GCC compat. */ +# endif +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) || defined(__CC_ARM) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +#ifndef SDL_NORETURN +#if defined(__GNUC__) +#define SDL_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define SDL_NORETURN __declspec(noreturn) +#else +#define SDL_NORETURN +#endif +#endif /* SDL_NORETURN not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/close_code.h b/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/close_code.h new file mode 100644 index 000000000..b3b70a4c8 --- /dev/null +++ b/libs/SDLMixerX/i686-w64-mingw32/include/SDL2/close_code.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file close_code.h + * + * This file reverses the effects of begin_code.h and should be included + * after you finish any function and structure declarations in your headers + */ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ diff --git a/libs/SDLMixerX/i686-w64-mingw32/lib/libSDL2_mixer_ext-static.a b/libs/SDLMixerX/i686-w64-mingw32/lib/libSDL2_mixer_ext-static.a new file mode 100644 index 000000000..8a59b5a61 Binary files /dev/null and b/libs/SDLMixerX/i686-w64-mingw32/lib/libSDL2_mixer_ext-static.a differ diff --git a/libs/SDLMixerX/i686-w64-mingw32/lib/libSDL2_mixer_ext.dll.a b/libs/SDLMixerX/i686-w64-mingw32/lib/libSDL2_mixer_ext.dll.a new file mode 100644 index 000000000..b5e43ef62 Binary files /dev/null and b/libs/SDLMixerX/i686-w64-mingw32/lib/libSDL2_mixer_ext.dll.a differ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/bin/SDL2_mixer_ext.dll b/libs/SDLMixerX/x86_64-w64-mingw32/bin/SDL2_mixer_ext.dll new file mode 100644 index 000000000..7762d5e8d Binary files /dev/null and b/libs/SDLMixerX/x86_64-w64-mingw32/bin/SDL2_mixer_ext.dll differ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/bin/libfluidsynth-2.dll b/libs/SDLMixerX/x86_64-w64-mingw32/bin/libfluidsynth-2.dll new file mode 100644 index 000000000..5dbcac34a Binary files /dev/null and b/libs/SDLMixerX/x86_64-w64-mingw32/bin/libfluidsynth-2.dll differ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/bin/libgcc_s_sjlj-1.dll b/libs/SDLMixerX/x86_64-w64-mingw32/bin/libgcc_s_sjlj-1.dll new file mode 100644 index 000000000..9684a2155 Binary files /dev/null and b/libs/SDLMixerX/x86_64-w64-mingw32/bin/libgcc_s_sjlj-1.dll differ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/bin/libstdc++-6.dll b/libs/SDLMixerX/x86_64-w64-mingw32/bin/libstdc++-6.dll new file mode 100644 index 000000000..220099c40 Binary files /dev/null and b/libs/SDLMixerX/x86_64-w64-mingw32/bin/libstdc++-6.dll differ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/SDL_mixer_ext.h b/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/SDL_mixer_ext.h new file mode 100644 index 000000000..3a6b91b50 --- /dev/null +++ b/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/SDL_mixer_ext.h @@ -0,0 +1,867 @@ +/* + SDL Mixer X: An extended audio mixer library, forked from SDL_mixer + Copyright (C) 2014-2018 Vitaly Novichkov + + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_MIXER_H_ +#define SDL_MIXER_H_ + +#include "SDL_stdinc.h" +#include "SDL_rwops.h" +#include "SDL_audio.h" +#include "SDL_endian.h" +#include "SDL_version.h" +#include "begin_code.h" + +/* Let applications recogonize which SDL Mixer edition is in use: Official or Extended fork by Wohlstand */ +#define SDL_MIXER_X 1 + +#define MIXSDLCALL + +#if defined(FORCE_STDCALLS) && defined(_WIN32) +#ifdef SDLCALL +#undef SDLCALL +#endif +#define SDLCALL __stdcall +#define SDLCALLCC __stdcall +#else +#define SDLCALLCC +#endif + +#ifndef DEPRECATED +#ifdef __GNUC__ +#define DEPRECATED(func) func __attribute__ ((deprecated)) +#elif defined(_MSC_VER) +#define DEPRECATED(func) __declspec(deprecated) func +#else +#pragma message("WARNING: You need to implement DEPRECATED for this compiler") +#define DEPRECATED(func) func +#endif +#endif + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL +*/ +#define SDL_MIXER_MAJOR_VERSION 2 +#define SDL_MIXER_MINOR_VERSION 2 +#define SDL_MIXER_PATCHLEVEL 0 + +/* This macro can be used to fill a version structure with the compile-time + * version of the SDL_mixer library. + */ +#define SDL_MIXER_VERSION(X) \ +{ \ + (X)->major = SDL_MIXER_MAJOR_VERSION; \ + (X)->minor = SDL_MIXER_MINOR_VERSION; \ + (X)->patch = SDL_MIXER_PATCHLEVEL; \ +} + +/* Backwards compatibility */ +#define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION +#define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION +#define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL +#define MIX_VERSION(X) SDL_MIXER_VERSION(X) + +/** + * This is the version number macro for the current SDL_mixer version. + */ +#define SDL_MIXER_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z. + */ +#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ + (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/* This function gets the version of the dynamically linked SDL_mixer library. + it should NOT be used to fill a version structure, instead you should + use the SDL_MIXER_VERSION() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void); + +typedef enum +{ + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_MID = 0x00000020, + MIX_INIT_OPUS = 0x00000040 +} MIX_InitFlags; + +/* Loads dynamic libraries and prepares them for use. Flags should be + one or more flags from MIX_InitFlags OR'd together. + It returns the flags successfully initialized, or 0 on failure. + */ +extern DECLSPEC int SDLCALL Mix_Init(int flags); + +/* Unloads libraries loaded with Mix_Init */ +extern DECLSPEC void SDLCALL Mix_Quit(void); + + +/* The default mixer has 8 simultaneous mixing channels */ +#ifndef MIX_CHANNELS +#define MIX_CHANNELS 8 +#endif + +/* Good default values for a PC soundcard */ +#define MIX_DEFAULT_FREQUENCY 44100 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define MIX_DEFAULT_FORMAT AUDIO_S16LSB +#else +#define MIX_DEFAULT_FORMAT AUDIO_S16MSB +#endif +#define MIX_DEFAULT_CHANNELS 2 +#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */ + +/* The internal format for an audio chunk */ +typedef struct Mix_Chunk { + int allocated; + Uint8 *abuf; + Uint32 alen; + Uint8 volume; /* Per-sample volume, 0-128 */ +} Mix_Chunk; + +/* The different fading types supported */ +typedef enum { + MIX_NO_FADING, + MIX_FADING_OUT, + MIX_FADING_IN +} Mix_Fading; + +/* These are types of music files (not libraries used to load them) */ +typedef enum { + MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD_UNUSED, + MUS_FLAC, + MUS_MODPLUG_UNUSED, + MUS_OPUS, + MUS_GME, + MUS_ADLMIDI/*Use ADLMIDI coded for super-special formats like IMF, MUS or XMI are can't be played without ADLMIDI*/ +} Mix_MusicType; + +typedef enum { + MIDI_ADLMIDI, + MIDI_Native, + MIDI_Timidity, + MIDI_OPNMIDI, + MIDI_Fluidsynth, + MIDI_ANY, + MIDI_KnuwnDevices /* Count of MIDI device types */ +} Mix_MIDI_Device; + +/* Volume model type in the ADLMIDI */ +typedef enum { + ADLMIDI_VM_AUTO, + ADLMIDI_VM_GENERIC, + ADLMIDI_VM_CMF, + ADLMIDI_VM_DMX, + ADLMIDI_VM_APOGEE, + ADLMIDI_VM_9X +} Mix_ADLMIDI_VolumeModel; + +/* OPL3 chip emulators for ADLMIDI */ +typedef enum { + ADLMIDI_OPL3_EMU_DEFAULT = -1, + ADLMIDI_OPL3_EMU_NUKED = 0, + ADLMIDI_OPL3_EMU_NUKED_1_7_4, + ADLMIDI_OPL3_EMU_DOSBOX, +} Mix_ADLMIDI_Emulator; + +/* OPN2 chip emulators for OPNMIDI */ +typedef enum { + OPNMIDI_OPN2_EMU_DEFAULT = -1, + OPNMIDI_OPN2_EMU_MIME = 0, + OPNMIDI_OPN2_EMU_NUKED, + OPNMIDI_OPN2_EMU_GENS, +} Mix_OPNMIDI_Emulator; + +/* The internal format for a music chunk interpreted via mikmod */ +typedef struct _Mix_Music Mix_Music; + +/* Open the mixer with a certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize); + +/* Open the mixer with specific device and certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes); + +/* Dynamically change the number of channels managed by the mixer. + If decreasing the number of channels, the upper channels are + stopped. + This function returns the new number of allocated channels. + */ +extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans); + +/* Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + */ +extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels); + +/* Load a wave file or a music (.mod .s3m .it .xm) file + IMPORTANT: To choice a track number of NSF, GBM, HES, etc file, + you must append "|xxx" to end of file path for + Mix_LoadMUS function. + Where xxx - actual number of chip track, (from 0 to N-1) + Examples: "file.nsf|12", "file.hes|2" +*/ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); +#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file); + +/* Load a music file from an SDL_RWop object + * Matt Campbell (matt@campbellhome.dhs.org) April 2000 */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc); + +/* Load a music file from an SDL_RWop object with custom arguments (trackID for GME or settings for a MIDI playing) + * Arguments are taking no effect for file formats which are not supports extra arguments. + */ +extern DECLSPEC Mix_Music *SDLCALL Mix_LoadMUS_RW_ARG(SDL_RWops *src, int freesrc, const char *args); + +/* Load a music file from an SDL_RWop object with custom trackID for GME. + * trackID argument takes no effect for non-NSF,HES,GBM,etc. file formats. + * Default value should be 0 + */ +extern DECLSPEC Mix_Music *SDLCALL Mix_LoadMUS_RW_GME(SDL_RWops *src, int freesrc, int trackID); + +/* Load a music file from an SDL_RWop object assuming a specific format */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc); + +/* Load a music file from an SDL_RWop object assuming a specific format + with custom arguments (trackID for GME or settings for a MIDI playing) */ +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW_ARG(SDL_RWops *src, Mix_MusicType type, int freesrc, const char *args); + +/* Load a wave file of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem); + +/* Load raw audio data of the mixer format from a memory buffer */ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len); + +/* Free an audio chunk previously loaded */ +extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk); +extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music); + +/* Get a list of chunk/music decoders that this build of SDL_mixer provides. + This list can change between builds AND runs of the program, if external + libraries that add functionality become available. + You must successfully call Mix_OpenAudio() before calling these functions. + This API is only available in SDL_mixer 1.2.9 and later. + + // usage... + int i; + const int total = Mix_GetNumChunkDecoders(); + for (i = 0; i < total; i++) + printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i)); + + Appearing in this list doesn't promise your specific audio file will + decode...but it's handy to know if you have, say, a functioning Timidity + install. + + These return values are static, read-only data; do not modify or free it. + The pointers remain valid until you call Mix_CloseAudio(). +*/ +extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name); +extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void); +extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name); + +/* Find out the music format of a mixer music, or the currently playing + music, if 'music' is NULL. +*/ +extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music); + +/* Get music title from meta-tag if possible. If title tag is empty, filename will be returned */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicTitle(const Mix_Music *music); +/* Get music title from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicTitleTag(const Mix_Music *music); +/* Get music artist from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicArtistTag(const Mix_Music *music); +/* Get music album from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicAlbumTag(const Mix_Music *music); +/* Get music copyright from meta-tag if possible */ +extern DECLSPEC const char *SDLCALL Mix_GetMusicCopyrightTag(const Mix_Music *music); + +/* Set a function that is called after all mixing is performed. + This can be used to provide real-time visual display of the audio stream + or add a custom mixer filter for the stream data. +*/ +extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); + +/* Add your own callback for when the music has finished playing or when it is + * stopped from a call to Mix_HaltMusic. + */ +extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)); + +/* Get a pointer to the user data for the current music hook */ +extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void); + +/* + * Add your own callback when a channel has finished playing. NULL + * to disable callback. The callback may be called from the mixer's audio + * callback or it could be called as a result of Mix_HaltChannel(), etc. + * do not call SDL_LockAudio() from this callback; you will either be + * inside the audio callback, or SDL_mixer will explicitly lock the audio + * before calling your callback. + */ +extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)); + + +/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */ + +#define MIX_CHANNEL_POST -2 + +/* This is the format of a special effect callback: + * + * myeffect(int chan, void *stream, int len, void *udata); + * + * (chan) is the channel number that your effect is affecting. (stream) is + * the buffer of data to work upon. (len) is the size of (stream), and + * (udata) is a user-defined bit of data, which you pass as the last arg of + * Mix_RegisterEffect(), and is passed back unmolested to your callback. + * Your effect changes the contents of (stream) based on whatever parameters + * are significant, or just leaves it be, if you prefer. You can do whatever + * you like to the buffer, though, and it will continue in its changed state + * down the mixing pipeline, through any other effect functions, then finally + * to be mixed with the rest of the channels and music for the final output + * stream. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); + +/* + * This is a callback that signifies that a channel has finished all its + * loops and has completed playback. This gets called if the buffer + * plays out normally, or if you call Mix_HaltChannel(), implicitly stop + * a channel via Mix_AllocateChannels(), or unregister a callback while + * it's still playing. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + */ +typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata); + + +/* Register a special effect function. At mixing time, the channel data is + * copied into a buffer and passed through each registered effect function. + * After it passes through all the functions, it is mixed into the final + * output stream. The copy to buffer is performed once, then each effect + * function performs on the output of the previous effect. Understand that + * this extra copy to a buffer is not performed if there are no effects + * registered for a given chunk, which saves CPU cycles, and any given + * effect will be extra cycles, too, so it is crucial that your code run + * fast. Also note that the data that your function is given is in the + * format of the sound device, and not the format you gave to Mix_OpenAudio(), + * although they may in reality be the same. This is an unfortunate but + * necessary speed concern. Use Mix_QuerySpec() to determine if you can + * handle the data before you register your effect, and take appropriate + * actions. + * You may also specify a callback (Mix_EffectDone_t) that is called when + * the channel finishes playing. This gives you a more fine-grained control + * than Mix_ChannelFinished(), in case you need to free effect-specific + * resources, etc. If you don't need this, you can specify NULL. + * You may set the callbacks before or after calling Mix_PlayChannel(). + * Things like Mix_SetPanning() are just internal special effect functions, + * so if you are using that, you've already incurred the overhead of a copy + * to a separate buffer, and that these effects will be in the queue with + * any functions you've registered. The list of registered effects for a + * channel is reset when a chunk finishes playing, so you need to explicitly + * set them with each call to Mix_PlayChannel*(). + * You may also register a special effect function that is to be run after + * final mixing occurs. The rules for these callbacks are identical to those + * in Mix_RegisterEffect, but they are run after all the channels and the + * music have been mixed into a single stream, whereas channel-specific + * effects run on a given channel before any other mixing occurs. These + * global effect callbacks are call "posteffects". Posteffects only have + * their Mix_EffectDone_t function called when they are unregistered (since + * the main output stream is never "done" in the same sense as a channel). + * You must unregister them manually when you've had enough. Your callback + * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the + * processing is considered a posteffect. + * + * After all these effects have finished processing, the callback registered + * through Mix_SetPostMix() runs, and then the stream goes to the audio + * device. + * + * DO NOT EVER call SDL_LockAudio() from your callback function! + * + * returns zero if error (no such channel), nonzero if added. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg); + + +/* You may not need to call this explicitly, unless you need to stop an + * effect from processing in the middle of a chunk's playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel or effect), nonzero if removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f); + + +/* You may not need to call this explicitly, unless you need to stop all + * effects from processing in the middle of a chunk's playback. Note that + * this will also shut off some internal effect processing, since + * Mix_SetPanning() and others may use this API under the hood. This is + * called internally when a channel completes playback. + * Posteffects are never implicitly unregistered as they are for channels, + * but they may be explicitly unregistered through this function by + * specifying MIX_CHANNEL_POST for a channel. + * returns zero if error (no such channel), nonzero if all effects removed. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel); + + +#define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED" + +/* + * These are the internally-defined mixing effects. They use the same API that + * effects defined in the application use, but are provided here as a + * convenience. Some effects can reduce their quality or use more memory in + * the name of speed; to enable this, make sure the environment variable + * MIX_EFFECTSMAXSPEED (see above) is defined before you call + * Mix_OpenAudio(). + */ + + +/* Set the panning of a channel. The left and right channels are specified + * as integers between 0 and 255, quietest to loudest, respectively. + * + * Technically, this is just individual volume control for a sample with + * two (stereo) channels, so it can be used for more than just panning. + * If you want real panning, call it like this: + * + * Mix_SetPanning(channel, left, 255 - left); + * + * ...which isn't so hard. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the panning will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally, and returns without + * registering the effect function if the audio device is not configured + * for stereo output. Setting both (left) and (right) to 255 causes this + * effect to be unregistered, since that is the data's normal state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if panning effect enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right); + + +/* Set the position of a channel. (angle) is an integer from 0 to 360, that + * specifies the location of the sound in relation to the listener. (angle) + * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260). + * Angle 0 is due north, and rotates clockwise as the value increases. + * For efficiency, the precision of this effect may be limited (angles 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. Using 255 does not guarantee that the channel will be + * culled from the mixing process or be completely silent. For efficiency, + * the precision of this effect may be limited (distance 0 through 5 might + * all produce the same effect, 6 through 10 are equal, etc). Setting (angle) + * and (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * If the audio device is configured for mono output, then you won't get + * any effectiveness from the angle; however, distance attenuation on the + * channel will still occur. While this effect will function with stereo + * voices, it makes more sense to use voices with only one channel of sound, + * so when they are mixed through this effect, the positioning will sound + * correct. You can convert them to mono through SDL before giving them to + * the mixer in the first place if you like. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the positioning will be done to the final mixed stream before passing it + * on to the audio device. + * + * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning(). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance); + + +/* Set the "distance" of a channel. (distance) is an integer from 0 to 255 + * that specifies the location of the sound in relation to the listener. + * Distance 0 is overlapping the listener, and 255 is as far away as possible + * A distance of 255 does not guarantee silence; in such a case, you might + * want to try changing the chunk's volume, or just cull the sample from the + * mixing process with Mix_HaltChannel(). + * For efficiency, the precision of this effect may be limited (distances 1 + * through 7 might all produce the same effect, 8 through 15 are equal, etc). + * (distance) is an integer between 0 and 255 that specifies the space + * between the sound and the listener. The larger the number, the further + * away the sound is. + * Setting (distance) to 0 unregisters this effect, since the data would be + * unchanged. + * If you need more precise positional audio, consider using OpenAL for + * spatialized effects instead of SDL_mixer. This is only meant to be a + * basic effect for simple "3D" games. + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the distance attenuation will be done to the final mixed stream before + * passing it on to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if position effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance); + + +/* + * !!! FIXME : Haven't implemented, since the effect goes past the + * end of the sound buffer. Will have to think about this. + * --ryan. + */ +#if 0 +/* Causes an echo effect to be mixed into a sound. (echo) is the amount + * of echo to mix. 0 is no echo, 255 is infinite (and probably not + * what you want). + * + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and + * the reverbing will be done to the final mixed stream before passing it on + * to the audio device. + * + * This uses the Mix_RegisterEffect() API internally. If you specify an echo + * of zero, the effect is unregistered, as the data is already in that state. + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. + * Error messages can be retrieved from Mix_GetError(). + */ +extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo); +#endif + +/* Causes a channel to reverse its stereo. This is handy if the user has his + * speakers hooked up backwards, or you would like to have a minor bit of + * psychedelia in your sound code. :) Calling this function with (flip) + * set to non-zero reverses the chunks's usual channels. If (flip) is zero, + * the effect is unregistered. + * + * This uses the Mix_RegisterEffect() API internally, and thus is probably + * more CPU intensive than having the user just plug in his speakers + * correctly. Mix_SetReverseStereo() returns without registering the effect + * function if the audio device is not configured for stereo output. + * + * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used + * on the final mixed stream before sending it on to the audio device (a + * posteffect). + * + * returns zero if error (no such channel or Mix_RegisterEffect() fails), + * nonzero if reversing effect is enabled. Note that an audio device in mono + * mode is a no-op, but this call will return successful in that case. + * Error messages can be retrieved from Mix_GetError(). + */ +extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip); + +/* end of effects API. --ryan. */ + + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num); + +/* Channel grouping functions */ + +/* Attach a tag to a channel. A tag can be assigned to several mixer + channels, to form groups of channels. + If 'tag' is -1, the tag is removed (actually -1 is the tag used to + represent the group of all the channels). + Returns true if everything was OK. + */ +extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag); +/* Assign several consecutive channels to a group */ +extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag); +/* Finds the first available channel in a group of channels, + returning -1 if none are available. + */ +extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag); +/* Returns the number of channels in a group. This is also a subtle + way to get the total number of channels when 'tag' is -1 + */ +extern DECLSPEC int SDLCALL Mix_GroupCount(int tag); +/* Finds the "oldest" sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag); +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */ +extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag); + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +*/ +#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1) +/* The same as above, but the sound is played at most 'ticks' milliseconds */ +extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks); +extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops); +#define Mix_PlayChannelVol(channel,chunk,loops,vol) Mix_PlayChannelTimedVolume(channel,chunk,loops,-1,vol)/*MIXER-X*/ +extern DECLSPEC int SDLCALL Mix_PlayChannelTimedVolume(int which, Mix_Chunk *chunk, int loops, int ticks, int volume);/*MIXER-X*/ + +/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */ +extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms); +extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position); +#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1) +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks); +#define Mix_FadeInChannelVolume(channel,chunk,loops,ms,vol) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1,vol)/*MIXER-X*/ +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimedVolume(int which, Mix_Chunk *chunk, int loops, int ms, int ticks, int volume);/*MIXER-X*/ + + +/* Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +*/ +extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume); +extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume); + +/* Halt playing of a particular channel */ +extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel); +extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag); +extern DECLSPEC int SDLCALL Mix_HaltMusic(void); + +/* Change the expiration delay for a particular channel. + The sample will stop playing after the 'ticks' milliseconds have elapsed, + or remove the expiration if 'ticks' is -1 +*/ +extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks); + +/* Halt a channel, fading it out progressively till it's silent + The ms parameter indicates the number of milliseconds the fading + will take. + */ +extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms); +extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms); + +/* Query the fading status of a channel */ +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void); +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which); + +/* Pause/Resume a particular channel */ +extern DECLSPEC void SDLCALL Mix_Pause(int channel); +extern DECLSPEC void SDLCALL Mix_Resume(int channel); +extern DECLSPEC int SDLCALL Mix_Paused(int channel); + +/* Pause/Resume the music stream */ +extern DECLSPEC void SDLCALL Mix_PauseMusic(void); +extern DECLSPEC void SDLCALL Mix_ResumeMusic(void); +extern DECLSPEC void SDLCALL Mix_RewindMusic(void); +extern DECLSPEC int SDLCALL Mix_PausedMusic(void); + +/* Set the current position in the music stream. + This returns 0 if successful, or -1 if it failed or isn't implemented. + This function is only implemented for MOD music formats (set pattern + order number) and for WAV, OGG, FLAC, MP3_MAD, MP3_MPG, and MODPLUG music + (set position in seconds), at the moment. +*/ +extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position); +/* + Get the time current position of music stream + returns -1.0 if this feature is not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicPosition(Mix_Music *music); +/* + Get the total time length of music stream + returns -1.0 if this feature is not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicTotalTime(Mix_Music *music); + +/* + Get the loop start time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopStartTime(Mix_Music *music); +/* + Get the loop end time position of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopEndTime(Mix_Music *music); +/* + Get the loop time length of music stream + returns -1.0 if this feature is not used for this music or not supported for some codec + */ +extern DECLSPEC double SDLCALL Mix_GetMusicLoopLengthTime(Mix_Music *music); + + +/* Check the status of a specific channel. + If the specified channel is -1, check all channels. +*/ +extern DECLSPEC int SDLCALL Mix_Playing(int channel); +extern DECLSPEC int SDLCALL Mix_PlayingMusic(void); + +/* Stop music and set external music playback command */ +extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command); + +/* Synchro value is set by MikMod from modules while playing */ +extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value); +extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void); + +/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */ +extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths); +extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void); +extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data); + +/* Get the Mix_Chunk currently associated with a mixer channel + Returns NULL if it's an invalid channel, or there's no chunk associated. +*/ +extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel); + +/* Close the mixer, halting all playing audio */ +extern DECLSPEC void SDLCALL Mix_CloseAudio(void); + +/* Add additional Timidity bank path */ +extern DECLSPEC void SDLCALL Mix_Timidity_addToPathList(const char *path); + +/* ADLMIDI Setup functions */ +/* Get count of available hardcoded banks */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getTotalBanks(void); +/* Get array of the bank names */ +extern DECLSPEC const char *const *SDLCALL Mix_ADLMIDI_getBankNames(void); +/* Get bank ID */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getBankID(void); +/* Set bank ID (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setBankID(int bnk); +/* Get state of deep vibrato */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getTremolo(void); +/* Set deep tremolo mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setTremolo(int tr); +/* Get state of deep vibrato */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getVibrato(void); +/* Set deep vibrato mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setVibrato(int vib); +/* Get state of scalable modulation mode */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getScaleMod(void); +/* Set scalable modulation mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setScaleMod(int sc); +/* Get state of adlib drums mode */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getAdLibMode(void); +/* Set adlib drums mode mode (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setAdLibMode(int tr); +/* Get state of logarithmic mode */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getLogarithmicVolumes(void); +/* Set logarithmic volumes mode in the generic/CMF volume models (0 off, 1 on) (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setLogarithmicVolumes(int lv); +/* Get current volume model ID */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getVolumeModel(void); +/* Change current volumes model (Applying on stop/play) */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setVolumeModel(int vm); +/* Get full range mode for CC74-Brightness controller */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getFullRangeBrightness(void); +/* Set full range mode for CC74-Brightness controller */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setFullRangeBrightness(int frb); +/* Get the current OPL3 Emulator for ADLMIDI */ +extern DECLSPEC int SDLCALL Mix_ADLMIDI_getEmulator(void); +/* Select the OPL3 Emulator for ADLMIDI */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setEmulator(int emu); +/* Reset all ADLMIDI properties to default state */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setSetDefaults(void); + +/* Sets WOPL bank file for ADLMIDI playing device, affects on MIDI file reopen */ +extern DECLSPEC void SDLCALL Mix_ADLMIDI_setCustomBankFile(const char *bank_wonl_path); + +/* Reset all OPNMIDI properties to default state */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setSetDefaults(void); +/* Get full range mode for CC74-Brightness controller */ +extern DECLSPEC int SDLCALL Mix_OPNMIDI_getFullRangeBrightness(void); +/* Set full range mode for CC74-Brightness controller */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setFullRangeBrightness(int frb); +/* Get the OPN2 Emulator for OPNMIDI */ +extern DECLSPEC int SDLCALL Mix_OPNMIDI_getEmulator(void); +/* Select the OPN2 Emulator for OPNMIDI */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setEmulator(int emu); +/* Sets WOPN bank file for OPNMIDI playing device, affects on MIDI file reopen */ +extern DECLSPEC void SDLCALL Mix_OPNMIDI_setCustomBankFile(const char *bank_wonp_path); + +/* Get type of MIDI player library currently in use */ +extern DECLSPEC int SDLCALL Mix_GetMidiPlayer(void); + +/* Get type of MIDI player library prepared for next opening of MIDI file */ +extern DECLSPEC int SDLCALL Mix_GetNextMidiPlayer(void); + +/* Set the MIDI playing library (ADLMIDI, Timidity, Native MIDI (if available) and FluidSynth) */ +extern DECLSPEC int SDLCALL Mix_SetMidiPlayer(int player); + +/* Disables support of MIDI file arguments */ +extern DECLSPEC void SDLCALL Mix_SetLockMIDIArgs(int lock_midiargs); + +/* DEPRECATED NAMES for new-added SDL Mixer X functions + Those names are made with mistake - beginning with "MIX_" than "Mix_" + which makes confusion when you looking for Mix_ function in your IDE + because some applications are still use them, to don't break ABI we will keep those + aliases until we will remove all usages of them from applications and libraries are used them +*/ +DEPRECATED(extern DECLSPEC int SDLCALL Mix_GetMidiDevice(void)); +DEPRECATED(extern DECLSPEC int SDLCALL Mix_GetNextMidiDevice(void)); +DEPRECATED(extern DECLSPEC int SDLCALL Mix_SetMidiDevice(int player)); + +/* We'll use SDL for reporting errors */ +#define Mix_SetError SDL_SetError +#define Mix_GetError SDL_GetError +#define Mix_ClearError SDL_ClearError + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_MIXER_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/begin_code.h b/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/begin_code.h new file mode 100644 index 000000000..6c2106246 --- /dev/null +++ b/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/begin_code.h @@ -0,0 +1,167 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file begin_code.h + * + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/* This shouldn't be nested -- included it around code only. */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +#ifndef SDL_DEPRECATED +# if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ +# define SDL_DEPRECATED __attribute__((deprecated)) +# else +# define SDL_DEPRECATED +# endif +#endif + +#ifndef SDL_UNUSED +# ifdef __GNUC__ +# define SDL_UNUSED __attribute__((unused)) +# else +# define SDL_UNUSED +# endif +#endif + +/* Some compilers use a special export keyword */ +#ifndef DECLSPEC +# if defined(__WIN32__) || defined(__WINRT__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# elif defined(__OS2__) +# ifdef BUILD_SDL +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# else +# if defined(__GNUC__) && __GNUC__ >= 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/* By default SDL uses the C calling convention */ +#ifndef SDLCALL +#if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) +#define SDLCALL __cdecl +#elif defined(__OS2__) || defined(__EMX__) +#define SDLCALL _System +# if defined (__GNUC__) && !defined(_System) +# define _System /* for old EMX/GCC compat. */ +# endif +#else +#define SDLCALL +#endif +#endif /* SDLCALL */ + +/* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ +#ifdef __SYMBIAN32__ +#undef DECLSPEC +#define DECLSPEC +#endif /* __SYMBIAN32__ */ + +/* Force structure packing at 4 byte alignment. + This is necessary if the header is included in code which has structure + packing set to an alternate value, say for loading structures from disk. + The packing is reset to the previous value in close_code.h + */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef _MSC_VER +#pragma warning(disable: 4103) +#endif +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#ifdef _M_X64 +/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ +#pragma pack(push,8) +#else +#pragma pack(push,4) +#endif +#endif /* Compiler needs structure packing set */ + +#ifndef SDL_INLINE +#if defined(__GNUC__) +#define SDL_INLINE __inline__ +#elif defined(_MSC_VER) || defined(__BORLANDC__) || \ + defined(__DMC__) || defined(__SC__) || \ + defined(__WATCOMC__) || defined(__LCC__) || \ + defined(__DECC) || defined(__CC_ARM) +#define SDL_INLINE __inline +#ifndef __inline__ +#define __inline__ __inline +#endif +#else +#define SDL_INLINE inline +#ifndef __inline__ +#define __inline__ inline +#endif +#endif +#endif /* SDL_INLINE not defined */ + +#ifndef SDL_FORCE_INLINE +#if defined(_MSC_VER) +#define SDL_FORCE_INLINE __forceinline +#elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) +#define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ +#else +#define SDL_FORCE_INLINE static SDL_INLINE +#endif +#endif /* SDL_FORCE_INLINE not defined */ + +#ifndef SDL_NORETURN +#if defined(__GNUC__) +#define SDL_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define SDL_NORETURN __declspec(noreturn) +#else +#define SDL_NORETURN +#endif +#endif /* SDL_NORETURN not defined */ + +/* Apparently this is needed by several Windows compilers */ +#if !defined(__MACH__) +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif /* NULL */ +#endif /* ! Mac OS X - breaks precompiled headers */ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/close_code.h b/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/close_code.h new file mode 100644 index 000000000..b3b70a4c8 --- /dev/null +++ b/libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2/close_code.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file close_code.h + * + * This file reverses the effects of begin_code.h and should be included + * after you finish any function and structure declarations in your headers + */ + +#undef _begin_code_h + +/* Reset structure packing at previous byte alignment */ +#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) +#ifdef __BORLANDC__ +#pragma nopackwarning +#endif +#pragma pack(pop) +#endif /* Compiler needs structure packing set */ diff --git a/libs/SDLMixerX/x86_64-w64-mingw32/lib/libSDL2_mixer_ext.dll.a b/libs/SDLMixerX/x86_64-w64-mingw32/lib/libSDL2_mixer_ext.dll.a new file mode 100644 index 000000000..c1cede98d Binary files /dev/null and b/libs/SDLMixerX/x86_64-w64-mingw32/lib/libSDL2_mixer_ext.dll.a differ diff --git a/libs/libgme.props b/libs/libgme.props new file mode 100644 index 000000000..209f6b9a8 --- /dev/null +++ b/libs/libgme.props @@ -0,0 +1,16 @@ + + + + + + $(SolutionDir)libs\gme\include;$(IncludePath) + $(SolutionDir)libs\gme\win32;$(LibraryPath) + $(SolutionDir)libs\gme\win64;$(LibraryPath) + + + + libgme.dll.a;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/libs/libopenmpt.props b/libs/libopenmpt.props new file mode 100644 index 000000000..8825907b6 --- /dev/null +++ b/libs/libopenmpt.props @@ -0,0 +1,16 @@ + + + + + + $(SolutionDir)libs\libopenmpt\inc;$(IncludePath) + $(SolutionDir)libs\libopenmpt\lib\x86;$(LibraryPath) + $(SolutionDir)libs\libopenmpt\lib\x86_64;$(LibraryPath) + + + + libopenmpt.lib;%(AdditionalDependencies) + + + + \ No newline at end of file diff --git a/libs/libopenmpt/LICENSE.txt b/libs/libopenmpt/LICENSE.txt new file mode 100644 index 000000000..e0f012166 --- /dev/null +++ b/libs/libopenmpt/LICENSE.txt @@ -0,0 +1,26 @@ +Copyright (c) 2004-2019, OpenMPT contributors +Copyright (c) 1997-2003, Olivier Lapicque +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the OpenMPT project nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/libs/libopenmpt/Licenses/License.Vorbis.txt b/libs/libopenmpt/Licenses/License.Vorbis.txt new file mode 100644 index 000000000..153b926a1 --- /dev/null +++ b/libs/libopenmpt/Licenses/License.Vorbis.txt @@ -0,0 +1,28 @@ +Copyright (c) 2002-2018 Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libs/libopenmpt/Licenses/License.mpg123.Authors.txt b/libs/libopenmpt/Licenses/License.mpg123.Authors.txt new file mode 100644 index 000000000..c1eac976d --- /dev/null +++ b/libs/libopenmpt/Licenses/License.mpg123.Authors.txt @@ -0,0 +1,175 @@ +This is an attempt to give credit to the people who contributed in some way to the mpg123 project. +There are names and email addresses listed. Please use these addresses only to contact contributors with some question about their mpg123 contribution. +You are explicitly not allowed to send them unwanted business offers or to question the quality of their sex life. +-------------------- + +Being on the list of contributing authors not necessarily means that there +is significant copyright in parts of the source code. There are obviously +contributions of differing complexity. I try to mention people who motivated +changes at least by suggesting some definite code changes, even if their +code did not enter the mpg123 source verbatim. Trivial changes like pointing +out ovbious syntax errors that make compilers cry do not land here. + +-------------------- + +Current maintainers with various sorts of contributions: + Thomas Orgis + Patrick Dehne + Jonathan Yong <10walls@gmail.com> + Taihei Momma + +Co-initiator of the revived mpg123 project, but not that involved anymore: + Nicholas J Humfrey + +Special thanks go to Taihei, the person who keeps the assembly optimisations alive +and takes care of portability to OSX/iOS platforms. + +Generic address pointing to the current maintainer (hopefully still works in future in case maintainership will change again): + +The creator: Michael Hipp (email: hippm@informatik.uni-tuebingen.de - please bother maintainers first) + +Contributions/ideas Thomas Orgis era (includes backports from mhipp trunk): + +Won-Kyu Park : patch to get rid of asm textrels (x86 PIC) +Michael Weiser : update of coreaudio output to AudioComponents API +Bent Bisballe Nyeng : patch for MPG123_NO_PEEK_END and MPG123_FORCE_SEEKABLE +Eric S. Raymond : man page fixes +Tobias Weber : patch for --disable-equalizer +Hans de Goede : patch to skip APE tags +Stephan Vedder : MSVC++ 2013 port update +Rajeev V. Pillai : pointing out/patching issues in HTTP code and behaviour of mpg123 remote/terminal control +Jarno Lehtinen : tinyalsa output +Anthony Wells : initial version of ID3v2 APIC patch +David Wohlferd : Win32 WaveOut buffer destructor fix. +Mike Gorchak : QNX native audio output (QSA) +Dan McGee : various patches (also for test suite) +Jonathan Yong (jon_y) <10walls@gmail.com>: win32 hacking, win32 wasapi audio. +Malcolm Boczek : Common language runtime wrapper +Elbert Pol (TeLLie) : OS/2 port fixup +Jeroen Valkonet : motivate pitch control, suggestive patch for pitch command in generic control interface +Andy Hefner : patch for that second UTF16 issue +Taihei Monma : A whole lot of new/improved assembler code, including Altivec! +Christian Weisgerber , Brad Smith: sndio output +Patrick Dehne (P4tr3ck) : more MSVC++ porting, patch to handle missing bit reservoirs +Thorsten Glaser : icy2utf8, suggest utf8 locale stuff +Dan Smith : ABI fixes for ensuring stack alignment (esp. for MinGW-built DLL with MSVC) +Michael Ryzhykh : mpg123.spec.in +Stefan Lenselink : initial aRts output +Sergej Kvachonok : win32 audio rewrite +Winston: SunOS-4.1.4/gcc-2.7.0 testing and suggestions for fixes (legacy Makefile, integer type headers) +Mika Tiainen: pointing out the fix for the UTF to ASCII filtering of tags to actually work +Nick Kurshev : extended 3dnow (from mplayer) +Zuxy Meng : SSE (from mplayer) +Honza : idea and prototype patch for ICY meta data support +Petr Baudis : patches: term sigcont, id3 display unicode fallback and condensed output +Petr Salinger : i486 enhancement +mpdavig@users.sourceforge.net: linux-ppc-nas Makefile.legacy entry +Adrian Bacon : patched decode_i586_dither (noise shaped float/int rounding) +Cool Feet Audio project : realtime equalizer control +Steve Grundell : clean stdout in control mode with stdout decoding +Romain Dolbeau : Altivec support (taken from mplayer) +higway : MMX Patch +Clemens Ladisch : ALSA 0.9/1.0 support + +Debian Daniel Kobras era: + +Steve Kemp +Dan Olson +Syuuhei Kashiyama +Rupert Levene +Andreas Dilger +Erik B. Andersen +Chris Butler +Martin Sjogren +Chet Hosey +Roland Rosenfeld + + +Debian Colin Watson era: + +Helge Deller +Chet Hosey +Christopher C. Chimelis +Roland Rosenfeld +Marcelo E. Magallon + + +Initial Debianers: + +Tommi Virtanen +Paul Haggart + + +Contributions/ideas Michael Hipp era: + +Mikko Tommila: DCT9 +Oliver Fromme +MPEG Software Simulation Group: reference decoder package +Tobias Bading: idea for DCT64 in subband synthesis from maplay package +Jeff Tsay and Mikko Tommila: MDCT36 from maplay package +Philipp Knirsch : DCT36/manual unroll idea +Thomas Woerner: SGI Audio +Damien Clermonte: HP-UX audio fixes +Niclas Lindstrom : OS2 port +Stefan Bieschewski : Pentium optimizations, decode_i586.s +Martin Denn : NAS port +Niklas Beisert : MPEG 2.5 tables + and : NetBSD Patch(es) +Kevin Brintnall : BSD patch +Tony Million: win32 port +Steven Tiger Lang: advanced shuffle +Eric B. Mitchell: esd port +Ryan R. Prosser : esd port for Solaris +Andreas Neuhaus: initial generic control interface + +(additionally fetched from changelog:) + +Ralf Hildebrandt : audio_alib changes +: BSDOS 4.0 with gcc added to Makefile +Bertrand Petit : frontend changes +Erik Mouw : SGI audio fix for non RAD machines +Daniel O'Connor : freebsd-esd make-entry +D. Skarda <0rfelyus@atrey.karlin.mff.cuni.cz>: enhanced head_check +Wilson, Jeff D : xterm-title +Robert Bihlmeyer : esd changes +Hannu Napari's : SGI audio patches +: native AIX support +: playlist patch +Gilles Zunino : SGI audio patches +Matthew Parslow : esdserver patch +: equalizer patch (equalfile setting) +Ducroquet Erwan : HPUX/ALib support +Shane Wegner : genrepatch +Samuel Audet : wav-File patch +"J. Dean Brederson" : SGI-RAD support +Chou Ye-chi : sajberplay/FreeBSD patch +Fabrice Bellard : 486 optimizations +A. Hermansen and J. Kysela : ALSA output +KIMURA Takuhiro : K6-3DNow +Petr Stehlik : MINT +Andy : float2int speed up proposal +Brian Foutz : TK3Play +Thomas Niederreiter : RIFF header fix +Stefan Gybas : m68k patch +Grant Erickson : Linux PPC patch +Peter Berger : BSDi patch +Henrik P Johnson : HTTP auth +Steven Tiger Lang : advanced shuffle +"Brian J. Swetland" : front-end (remote) patch + +Tillmann Steinbrecher : shuffle patch +M.Stekelenburg : i386-getbits +Antti Andreimann : outburst patch +Hur TaeSung : 'http accept' patch + +(from post-0.59 changes that yet have to go into new trunk:) + +Hans Schwengeler : audio_dec additions +Wojciech Barañski's Mp3Play (check the tools folder): Mp3Play frontend +Daniel Koukola: audio_oss.c patch +Munechika SUMIKAWA : IPv6 +TEMNOTA : HTTP,FTP patch/playlist fix +Peter Surda : VBR patch +Ben : ARM startup time improvements +Dave MacKenzie : init_output() patch +pasky's : close-on-stop patch diff --git a/libs/libopenmpt/Licenses/License.mpg123.txt b/libs/libopenmpt/Licenses/License.mpg123.txt new file mode 100644 index 000000000..d7bb85fc3 --- /dev/null +++ b/libs/libopenmpt/Licenses/License.mpg123.txt @@ -0,0 +1,772 @@ +This is the file that contains the terms of use, copying, etc. for the mpg123 distribution package. + +Main message, to include in "About ..." boxes, etc: + + Copyright (c) 1995-2013 by Michael Hipp and others, + free software under the terms of the LGPL v2.1 + +There is an attempt to cover the actual list of authors in the AUTHORS file. +Project maintainer since 2006 is Thomas Orgis and many people have contributed +since the Michael Hipp era, but he stays the initial source and it would +be impractical to count them all individually, so it's "and others". +Source files contain the phrase "the mpg123 project" to the same effect +in their license boilerplate; especially those that were added after +maintainership changed. The person mainly responsible for the first version +is usually named in the phrase "initially written by ...". + +All files in the distribution that don't carry a license note on their own are +licensed under the terms of the LGPL 2.1; exceptions may apply, especially to +files not in the official distribution but in the revision control repository. + +The formal license text follows. + +======================= +1. The LGPL version 2.1 +======================= + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + +==================== +2. The GPL version 2 +==================== + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/libs/libopenmpt/Licenses/License.ogg.txt b/libs/libopenmpt/Licenses/License.ogg.txt new file mode 100644 index 000000000..6111c6c5a --- /dev/null +++ b/libs/libopenmpt/Licenses/License.ogg.txt @@ -0,0 +1,28 @@ +Copyright (c) 2002, Xiph.org Foundation + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +- Neither the name of the Xiph.org Foundation nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION +OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/libs/libopenmpt/Licenses/License.zlib.txt b/libs/libopenmpt/Licenses/License.zlib.txt new file mode 100644 index 000000000..51106de47 --- /dev/null +++ b/libs/libopenmpt/Licenses/License.zlib.txt @@ -0,0 +1,115 @@ +ZLIB DATA COMPRESSION LIBRARY + +zlib 1.2.11 is a general purpose data compression library. All the code is +thread safe. The data format used by the zlib library is described by RFCs +(Request for Comments) 1950 to 1952 in the files +http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and +rfc1952 (gzip format). + +All functions of the compression library are documented in the file zlib.h +(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example +of the library is given in the file test/example.c which also tests that +the library is working correctly. Another example is given in the file +test/minigzip.c. The compression library itself is composed of all source +files in the root directory. + +To compile all files and run the test program, follow the instructions given at +the top of Makefile.in. In short "./configure; make test", and if that goes +well, "make install" should work for most flavors of Unix. For Windows, use +one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use +make_vms.com. + +Questions about zlib should be sent to , or to Gilles Vollant + for the Windows DLL version. The zlib home page is +http://zlib.net/ . Before reporting a problem, please check this site to +verify that you have the latest version of zlib; otherwise get the latest +version and check whether the problem still exists or not. + +PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. + +Mark Nelson wrote an article about zlib for the Jan. 1997 +issue of Dr. Dobb's Journal; a copy of the article is available at +http://marknelson.us/1997/01/01/zlib-engine/ . + +The changes made in version 1.2.11 are documented in the file ChangeLog. + +Unsupported third party contributions are provided in directory contrib/ . + +zlib is available in Java using the java.util.zip package, documented at +http://java.sun.com/developer/technicalArticles/Programming/compression/ . + +A Perl interface to zlib written by Paul Marquess is available +at CPAN (Comprehensive Perl Archive Network) sites, including +http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . + +A Python interface to zlib written by A.M. Kuchling is +available in Python 1.5 and later versions, see +http://docs.python.org/library/zlib.html . + +zlib is built into tcl: http://wiki.tcl.tk/4610 . + +An experimental package to read and write files in .zip format, written on top +of zlib by Gilles Vollant , is available in the +contrib/minizip directory of zlib. + + +Notes for some targets: + +- For Windows DLL versions, please see win32/DLL_FAQ.txt + +- For 64-bit Irix, deflate.c must be compiled without any optimization. With + -O, one libpng test fails. The test works in 32 bit mode (with the -n32 + compiler flag). The compiler bug has been reported to SGI. + +- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works + when compiled with cc. + +- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is + necessary to get gzprintf working correctly. This is done by configure. + +- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with + other compilers. Use "make test" to check your compiler. + +- gzdopen is not supported on RISCOS or BEOS. + +- For PalmOs, see http://palmzlib.sourceforge.net/ + + +Acknowledgments: + + The deflate format used by zlib was defined by Phil Katz. The deflate and + zlib specifications were written by L. Peter Deutsch. Thanks to all the + people who reported problems and suggested various improvements in zlib; they + are too numerous to cite here. + +Copyright notice: + + (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +If you use the zlib library in a product, we would appreciate *not* receiving +lengthy legal documents to sign. The sources are provided for free but without +warranty of any kind. The library has been entirely written by Jean-loup +Gailly and Mark Adler; it does not include third-party code. + +If you redistribute modified sources, we would appreciate that you include in +the file ChangeLog history information documenting your changes. Please read +the FAQ for more information on the distribution of modified source versions. diff --git a/libs/libopenmpt/SRB2NOTE-DEBIAN.md b/libs/libopenmpt/SRB2NOTE-DEBIAN.md new file mode 100644 index 000000000..7e050d29a --- /dev/null +++ b/libs/libopenmpt/SRB2NOTE-DEBIAN.md @@ -0,0 +1,90 @@ +# libopenmpt Debian backport info + +Backported libopenmpt 0.4.0 packages are available at ppa:stjr/srb2 +for Ubuntu Disco, Cosmic, Bionic, Xenial, and Trusty as of 2019/01/04. + +Debian Jessie users should use the Trusty package. Later Debian versions +may use Disco or another working version. + +* libopenmpt 0.4.0 source package: http://archive.ubuntu.com/ubuntu/pool/universe/libo/libopenmpt/libopenmpt_0.4.0-1.dsc + +# Backporting from Disco to Cosmic and Bionic + +Cosmic and Bionic require no changes to the source package. They have +the prerequisite `debhelper` and `dpkg-dev` versions, a matching +`automake` version (1.15), as well as G++ > 5. + +Use the `backportpackage` script to automatically tag the package to +Cosmic and Bionic, then upload to PPA: + +``` +sudo apt install ubuntu-dev-tools +export UBUMAIL="John Doe " # Name and email associated with your PGP sign key +backportpackage -d [cosmic/bionic] -u [path-to-ppa] --key=[key-fingerprint] http://archive.ubuntu.com/ubuntu/pool/universe/libo/libopenmpt/libopenmpt_0.4.0-1.dsc +``` + +# Backporting from Disco to Xenial + +Download the package: + +``` +dget http://archive.ubuntu.com/ubuntu/pool/universe/libo/libopenmpt/libopenmpt_0.4.0-1.dsc +``` + +Xenial has an earlier `debhelper` version, but the rest of the prerequisites +are available. + +The required changes (see patch `debian/libopenmpt-0.4.0-xenial-backport.diff` in this directory): + +* `debian/control` + * Add `automake` to Build-Depends + * Change `debhelper` version to `(>= 9.0~)` +* `debian/compat` + * Change to `10` + +Then run these commands: + +``` +dch -i # Edit the changelog; make sure the Name and email match the PGP sign key and that the changelog targets xenial +debuild -s -d -k0x[key-fingerprint] # Build the updated package +dput [path-to-ppa] [path-to-changes-file] # Upload to PPA +``` + +# Backporting from Disco to Trusty + +Download the package: + +``` +dget http://archive.ubuntu.com/ubuntu/pool/universe/libo/libopenmpt/libopenmpt_0.4.0-1.dsc +``` + +Trusty requires more changes because it uses G++ 4.8 whereas the source +package expects G++ >= 5. Automake is an earlier version as well -- +1.14 vs 1.15 -- so `autoreconf` needs to be run at build time. + +The required changes (see patch `debian/libopenmpt-0.4.0-trusty-backport.diff` in this directory): + +* `debian/control` + * Add `automake` and `libtool` to Build-Depends + * Change `debhelper` version to `(>= 9.0~)` + * Change `dpkg-dev` version to `(>= 1.17.0)` +* `debian/compat` + * Change to `10` +* `debian/rules` + * Under `override_dh_auto_configure`, input this line as the first command: + `autoreconf --force --install` + * This re-configures the package for Automake 1.14 +* `debian/libopenmpt-modplug1.symbols` and `debian/libopenmpt0.symbols` + * Delete these files + * The C++ ABI for G++ 4.8 is incompatible with G++ >= 5, so the + generated symbols will be different than the expected symbols + in the `*.symbols` files. Deleting these files will skip the + symbol check. + +Then run these commands: + +``` +dch -i # Edit the changelog; make sure the Name and email match the PGP sign key and that the changelog targets trusty +debuild -s -d -k0x[key-fingerprint] # Build the updated package +dput [path-to-ppa] [path-to-changes-file] # Upload to PPA +``` diff --git a/libs/libopenmpt/SRB2NOTE.md b/libs/libopenmpt/SRB2NOTE.md new file mode 100644 index 000000000..7eac9183b --- /dev/null +++ b/libs/libopenmpt/SRB2NOTE.md @@ -0,0 +1,54 @@ +# libopenmpt mingw-w64 binary info + +Current built version as of 2019/09/27 is 0.4.7+r12088.pkg + +* mingw binaries (.dll): `bin/[x86 or x86_64]/mingw` +* mingw import libraries (.dll.a): `lib/[x86 or x86_64]/mingw` + +# Building libopenmpt with mingw-w64 + +libopenmpt must be built from the Makefile / Android dev package in the +[Downloads page](https://lib.openmpt.org/libopenmpt/download/#all-downloads) + +Use the mingw-w64 distributions from +[SourceForge](https://sourceforge.net/projects/mingw-w64/files/#readme). + +You can download the appropriate 7-zip archive, extract to a folder of +your choice, remove any existing mingw directories from your PATH, +then call `mingw32-make.exe` from its direct location. + +FOR LIBOPENMPT, YOU MUST USE A MINGW PACKAGE THAT SUPPORTS THE POSIX +THREADING MODEL! DO NOT COMPILE WITH A WIN32 THREADING MODEL! + +I use GCC 7.3.0: + +* [x86_64-posix-seh](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z) +* [i686-posix-dwarf](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/7.3.0/threads-posix/dwarf/i686-7.3.0-release-posix-dwarf-rt_v5-rev0.7z) + +## x86 build instructions + +``` +set CFLAGS=-march=pentium -static-libgcc +set CXXFLAGS=-march=pentium -static-libgcc -static-libstdc++ +set LDFLAGS=-Wl,--out-implib,bin/libopenmpt.dll.a -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive + +cd [libopenmpt-make-src] +[x86-mingw-w64-bin]/mingw32-make.exe CONFIG=mingw64-win32 +``` + +`libopenmpt.dll` and `libopenmpt.dll.a` will be built in the +`bin/` folder. + +## x86_64 build instructions + +``` +set CFLAGS=-march=nocona -static-libgcc +set CXXFLAGS=-march=nocona -static-libgcc -static-libstdc++ +set LDFLAGS=-Wl,--out-implib,bin/libopenmpt.dll.a -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive + +cd [libopenmpt-make-src] +[x86_64-mingw-w64-bin]/mingw32-make.exe CONFIG=mingw64-win64 +``` + +`libopenmpt.dll` and `libopenmpt.dll.a` will be built in the +`bin/` folder. \ No newline at end of file diff --git a/libs/libopenmpt/bin/x86/libopenmpt.dll b/libs/libopenmpt/bin/x86/libopenmpt.dll new file mode 100644 index 000000000..8ad64fdfd Binary files /dev/null and b/libs/libopenmpt/bin/x86/libopenmpt.dll differ diff --git a/libs/libopenmpt/bin/x86/mingw/libopenmpt.dll b/libs/libopenmpt/bin/x86/mingw/libopenmpt.dll new file mode 100644 index 000000000..945b475e6 Binary files /dev/null and b/libs/libopenmpt/bin/x86/mingw/libopenmpt.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-mpg123.dll b/libs/libopenmpt/bin/x86/openmpt-mpg123.dll new file mode 100644 index 000000000..b068ddd0c Binary files /dev/null and b/libs/libopenmpt/bin/x86/openmpt-mpg123.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-ogg.dll b/libs/libopenmpt/bin/x86/openmpt-ogg.dll new file mode 100644 index 000000000..a5b460063 Binary files /dev/null and b/libs/libopenmpt/bin/x86/openmpt-ogg.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-vorbis.dll b/libs/libopenmpt/bin/x86/openmpt-vorbis.dll new file mode 100644 index 000000000..1ebed9b0e Binary files /dev/null and b/libs/libopenmpt/bin/x86/openmpt-vorbis.dll differ diff --git a/libs/libopenmpt/bin/x86/openmpt-zlib.dll b/libs/libopenmpt/bin/x86/openmpt-zlib.dll new file mode 100644 index 000000000..41bc22d2f Binary files /dev/null and b/libs/libopenmpt/bin/x86/openmpt-zlib.dll differ diff --git a/libs/libopenmpt/bin/x86_64/libopenmpt.dll b/libs/libopenmpt/bin/x86_64/libopenmpt.dll new file mode 100644 index 000000000..ffbb4b19a Binary files /dev/null and b/libs/libopenmpt/bin/x86_64/libopenmpt.dll differ diff --git a/libs/libopenmpt/bin/x86_64/mingw/libopenmpt.dll b/libs/libopenmpt/bin/x86_64/mingw/libopenmpt.dll new file mode 100644 index 000000000..018ae8276 Binary files /dev/null and b/libs/libopenmpt/bin/x86_64/mingw/libopenmpt.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll b/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll new file mode 100644 index 000000000..9a0fca874 Binary files /dev/null and b/libs/libopenmpt/bin/x86_64/openmpt-mpg123.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll b/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll new file mode 100644 index 000000000..4bc1a336b Binary files /dev/null and b/libs/libopenmpt/bin/x86_64/openmpt-ogg.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll b/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll new file mode 100644 index 000000000..ebe8ef9b3 Binary files /dev/null and b/libs/libopenmpt/bin/x86_64/openmpt-vorbis.dll differ diff --git a/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll b/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll new file mode 100644 index 000000000..319b646ff Binary files /dev/null and b/libs/libopenmpt/bin/x86_64/openmpt-zlib.dll differ diff --git a/libs/libopenmpt/changelog.md b/libs/libopenmpt/changelog.md new file mode 100644 index 000000000..0b7279558 --- /dev/null +++ b/libs/libopenmpt/changelog.md @@ -0,0 +1,829 @@ + +Changelog {#changelog} +========= + +For fully detailed change log, please see the source repository directly. This +is just a high-level summary. + +### libopenmpt 0.4.7 (2019-09-23) + + * [**Bug**] Compilation fix for various platforms that do not provide + `std::aligned_alloc` in C++17 mode. The problematic dependency has been + removed. This should fix build problems on MinGW, OpenBSD, Haiku, and others + for good. + + * J2B: Ignore notes with non-existing instrument (fixes Ending.j2b). + + * mpg123: Update to v1.25.13 (2019-08-24). + * ogg: Update to v1.3.4. (2019-08-31). + * flac: Update to v1.3.3. (2019-08-04). + +### libopenmpt 0.4.6 (2019-08-10) + + * [**Bug**] Compilation fix for OpenBSD. + * [**Bug**] Compilation fix for NO_PLUGINS being defined. + + * in_openmpt: Correct documentation. `openmpt-mpg123.dll` must be placed into + the Winamp directory. + + * Detect IT files unpacked with early UNMO3 versions. + + * mpg123: Update to v1.25.11 (2019-07-18). + * minimp3: Update to commit 977514a6dfc4960d819a103f43b358e58ac6c28f + (2019-07-24). + * miniz: Update to v2.1.0 (2019-05-05). + * stb_vorbis: Update to v1.17 (2019-08-09). + +### libopenmpt 0.4.5 (2019-05-27) + + * [**Sec**] Possible crash during playback due out-of-bounds read in XM and + MT2 files (r11608). + + * Breaking out of a sustain loop through Note-Off sometimes didn't continue in + the regular sample loop. + * Seeking did not stop notes playing with XM Key Off (Kxx) effect. + +### libopenmpt 0.4.4 (2019-04-07) + + * [**Bug**] Channel VU meters were swapped. + + * Startrekker: Clamp speed to 31 ticks per row. + * MTM: Ignore unused Exy commands on import. Command E5x (Set Finetune) is now + applied correctly. + * MOD: Sample swapping was always enabled since it has been separated from the + ProTracker 1/2 compatibility flag. Now it is always enabled for Amiga-style + modules and otherwise the old heuristic is used again. + + * stb_vorbis: Update to v1.16 (2019-03-05). + +### libopenmpt 0.4.3 (2019-02-11) + + * [**Sec**] Possible crash due to null-pointer access when doing a portamento + from an OPL instrument to an empty instrument note map slot (r11348). + + * [**Bug**] libopenmpt did not compile on Apple platforms in C++17 mode. + + * IT: Various fixes for note-off + instrument number in Old Effects mode. + * MO3: Import IT row highlights as written by MO3 2.4.1.2 or newer. Required + for modules using modern tempo mode. + + * miniz: Update to v2.0.8 (2018-09-19). + * stb_vorbis: Update to v1.15 (2019-02-07). + +### libopenmpt 0.4.2 (2019-01-22) + + * [**Sec**] DSM: Assertion failure during file parsing with debug STLs + (r11209). + * [**Sec**] J2B: Assertion failure during file parsing with debug STLs + (r11216). + + * S3M: Allow volume change of OPL instruments after Note Cut. + +### libopenmpt 0.4.1 (2019-01-06) + + * [**Bug**] Binaries compiled for winold (Windows XP, Vista, 7, for CPUs + without SSE2 support) did not actually work on CPUs without SSE2 support. + * [**Bug**] libmodplug: Public symbols of the C++ API had `visibility=hidden` + set on non-MSVC systems, which made them not publicly accessible. + * [**Bug**] Project files for Windows 10 desktop builds on ARM and ARM64 + (`build/vs2017win10`) were missing from Windows source package. + * [**Bug**] MSVC project files in Windows source package lacked additional + files required to build DLLs. + + * MO3: Apply playback changes based on "ModPlug-made" header flag. + + * minimp3: Update to commit e9df0760e94044caded36a55d70ab4152134adc5 + (2018-12-23). + +### libopenmpt 0.4.0 (2018-12-23) + + * [**New**] libopenmpt now includes emulation of the OPL chip and thus plays + OPL instruments in S3M, C67 and MPTM files. OPL chip emulation volume can be + changed with the new ctl `render.opl.volume_factor`. + * [**New**] libopenmpt now supports CDFM / Composer 670 module files. + * [**New**] Autotools `configure` and plain `Makefile` now honor the variable + `CXXSTDLIB_PCLIBSPRIVATE` which serves the sole purpose of listing the + standard library (or libraries) required for static linking. The contents of + this variable will be put in `libopenmpt.pc` `Libs.private` and used for + nothing else. See \ref libopenmpt_c_staticlinking . + * [**New**] foo_openmpt: foo_openmpt now also works on Windows XP. + * [**New**] libopenmpt Emscripten builds now ship with MP3 support by + default, based on minimp3 by Lion (github.com/lieff). + * [**New**] libopenmpt: New ctl `play.at_end` can be used to change what + happens when the song end is reached: + * "fadeout": Fades the module out for a short while. Subsequent reads + after the fadeout will return 0 rendered frames. This is the default and + identical to the behaviour in previous libopenmpt versions. + * "continue": Returns 0 rendered frames when the song end is reached. + Subsequent reads will continue playing from the song start or loop + start. This can be used for custom loop logic, such as loop + auto-detection and longer fadeouts. + * "stop": Returns 0 rendered frames when the song end is reached. + Subsequent reads will return 0 rendered frames. + * [**New**] Add new metadata fields `"originaltype"` and `"originaltype_long"` + which allow more clearly reflecting what is going on with converted formats + like MO3 and GDM. + * [**New**] `Makefile` `CONFIG=emscripten` now can generate WebAssembly via + the additional option `EMSCRIPTEN_TARGET=wasm`. + * [**New**] Compiling for DOS is now experimentally supported via DJGPP GCC + 7.2 or later. + + * [**Change**] minimp3: Instead of the LGPL-2.1-licensed minimp3 by KeyJ, + libopenmpt now uses the CC0-1.0-licensed minimp3 by Lion (github.com/lieff) + as a fallback if libmpg123 is unavailable. The `USE_MINIMP3` `Makefile` + option is gone and minimp3 will be used automatically in the `Makefile` + build system if libmpg123 is not available. + * [**Change**] openmpt123: openmpt123 now rejects `--output-type` in `--ui` + and `--batch` modes and also rejects `--output` in `--render` mode. These + combinations of options really made no sense and were rather confusing. + * [**Change**] Android NDK build system now uses libc++ (`c++_shared`) instead + of GNU libstdc++ (`gnustl_shared`), as recommended by Android NDK r16b. + * [**Change**] xmp-openmpt: `openmpt-mpg123.dll` is no longer optional and + must be placed into the same directory as `xmp-openmpt.dll`. + * [**Change**] in_openmpt: `openmpt-mpg123.dll` is no longer optional and must + be placed either into the directory of the player itself or into the same + directory as `in_openmpt.dll`. This is dependent on how the player loads its + plugins. For WinAMP 5, `openmpt-mpg123.dll` needs to be in the directory + which contains `winamp.exe`. `in_openmpt.dll` needs to be in the `Plugins` + directory. + * [**Change**] foo_openmpt: foo_openmpt is now packaged as a fb2k-component + package for easier installation. + * [**Change**] When building libopenmpt with MinGW-w64, it is now recommended + to use the posix thread model (as opposed to the win32 threading model), + because the former does support std::mutex while the latter does not. When + building with win32 threading model with the Autotools build system, it is + recommended to provide the `mingw-std-threads` package. Building libopenmpt + with MinGW-w64 without any `std::thread`/`std::mutex` support is deprecated + and support for such configurations will be removed in libopenmpt 0.5. + * [**Change**] `Makefile` `CONFIG=emscripten` now has 4 `EMSCRIPTEN_TARGET=` + settings: `wasm` generates WebAssembly, `asmjs128m` generates asm.js with a + fixed size 128MB heap, `asmjs` generates asm.js with a fixed default size + heap (as of Emscripten 1.38.11, this amounts to 16MB), `js` generates + JavaScript with dynamic heap growth and with compatibility for older VMs. + * [**Change**] libmodplug: Update public headers to libmodplug 0.8.8.5. This + adds support for kind-of automatic MODPLUG_EXPORT decoration on Windows. + + * [**Regression**] Support for Clang 3.4, 3.5 has been removed. + * [**Regression**] Building with Android NDK older than NDK r16b is not + supported any more. + * [**Regression**] Support for Emscripten versions older than 1.38.5 has been + removed. + * [**Regression**] Support for libmpg123 older than 1.14.0 has been removed. + * [**Regression**] Using MediaFoundation to decode MP3 samples is no longer + supported. Use libmpg123 or minimp3 instead. + * [**Regression**] libmodplug: Support for emulating libmodplug 0.8.7 API/ABI + has been removed. + + * [**Bug**] xmp-openmpt: Sample rate and number of output channels were not + applied correctly when using per-file settings. + * [**Bug**] Internal mixer state was not initialized properly when initially + rendering in 44100kHz stereo format. + * [**Bug**] openmpt123: Prevent libsdl2 and libsdl from being enabled at the + same time because they conflict with each other. + * [**Bug**] libmodplug: Setting `SNDMIX_NORESAMPLING` in the C++ API always + resulted in linear interpolation instead of nearest neighbour + + * IT: In Compatible Gxx mode, allow sample changes next to a tone portamento + effect if a previous sample has already stopped playing. + * IT: Fix broken volume envelopes with negative values as found in breakdwn.it + by Elysis. + * MOD: Slides and delayed notes are executed on every repetition of a row with + row delay (fixes "ode to protracker"). + * XM: If the sustain point of the panning envelope is reached before key-off, + it is never released. + * XM: Do not default recall volume / panning for delayed instrument-less notes + * XM :E60 loop bug was not considered in song length calucation. + * S3M: Notes without instrument number use previous note's sample offset. + * Tighten M15 and MOD file rejection heuristics. + * J2B: Ignore frequency limits from file header. Fixes Medivo.j2b, broken + since libopenmpt-0.2.6401-beta17. + * STM: More accurate tempo calculation. + * STM: Better support for early format revisions (no such files have been + found in the wild, though). + * STM: Last character of sample name was missing. + * SFX: Work around bad conversions of the "Operation Stealth" soundtrack by + turning pattern breaks into note stops. + * IMF: Filter cutoff was upside down and the cutoff range was too small. + * ParamEq plugin center frequency was not limited correctly. + * Keep track of active SFx macro during seeking. + * The "note cut" duplicate note action did not volume-ramp the previously + playing sample. + * A song starting with non-existing patterns could not be played. + * DSM: Support restart position and 16-bit samples. + * DTM: Import global volume. + * MOD: Support notes in octave 2, like in FastTracker 2 (fixes DOPE.MOD). + * Do not apply Amiga playback heuristics to MOD files that have clearly been + written with a PC tracker. + * MPTM: More logical release node behaviour. + * Subsong search is now less thorough. It could previously find many subsongs + that are technically correct (unplayed rows at the beginning of patterns + that have been jumped over due to pattern breaks), but so far no real-world + module that would require such a thorough subsong detection was found. The + old mechanism caused way more false positives than intended with real-world + modules, though. + * Restrict the unpacked size of compressed DMF, IT, MDL and MO3 samples to + avoid huge allocations with malformed small files. + +### libopenmpt 0.3 (2017-09-27) + + * [**New**] New error handling functionality in the C API, which in particular + allows distinguishing potentially transient out-of-memory errors from parse + errors during module loading. + * [**New**] New API `openmpt::module::get_selected_subsong()` (C++) and + `openmpt_module_get_selected_subsong()` (C). + * [**New**] Faster file header probing API `openmpt::probe_file_header()` and + `openmpt::probe_file_header_get_recommended_size` (C++), and + `openmpt_probe_file_header()`, + `openmpt_probe_file_header_without_filesize()`, + `openmpt_probe_file_header_from_stream()` and + `openmpt_probe_file_header_get_recommended_size()` (C). + * [**New**] New API `openmpt::could_open_probability()` (C++) and + `openmpt_could_open_probability()` (C). This fixes a spelling error in the + old 0.2 API. + * [**New**] openmpt123: openmpt123 can now open M3U, M3U8, M3UEXT, M3U8EXT and + PLSv2 playlists via the `--playlist` option. + * [**New**] openmpt123: openmpt123 now supports very fast file header probing + via the `--probe` option. + * [**New**] Libopenmpt now supports building for Windows 10 Universal (Windows + Store 8.2) APIs with MSVC, and also for the older Windows Runtime APIs with + MinGW-w64. + * [**New**] New API header `libopenmpt_ext.h` which implements the libopenmpt + extension APIs also for the C interface. + * [**New**] The Reverb effect (S99 in S3M/IT/MPTM, and X99 in XM) is now + implemented in libopenmpt. + * [**New**] For Amiga modules, a new resampler based on the Amiga's sound + characteristics has been added. It can be activated by passing the + `render.resampler.emulate_amiga` ctl with a value of `1`. Non-Amiga modules + are not affected by this, and setting the ctl overrides the resampler choice + specified by `OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH` or + `openmpt::module::RENDER_INTERPOLATIONFILTER_LENGTH`. Support for the MOD + command E0x (Set LED Filter) is also available when the Amiga resampler is + enabled. + + * [**Change**] libopenmpt versioning changed and follows the more conventional + major.minor.patch as well as the recommendations of the + [SemVer](http://semver.org/) scheme now. In addition to the SemVer + requirements, pre-1.0.0 versions will also honor API and ABI stability in + libopenmpt (i.e. libopenmpt ignores SemVer Clause 4). + * [**Change**] The output directories of the MSVC build system were changed to + `bin/vs2015-shared/x86-64-win7/` (and similar) layout which allows building + in the same tree with different compiler versions without overwriting other + outputs. + * [**Change**] The emscripten build now exports libopenmpt as 'libopenmpt' + instead of the default 'Module'. + * [**Change**] Android: The build system changed. The various Android.mk files + have been merged into a single one which can be controlled using command + line options. + * [**Change**] The `Makefile` build system now passes `std=c++11` to the + compiler by default. Older compilers may still work if you pass + `STDCXX=c++0x` to the `make` invocation. + * [**Change**] The `Makefile` option `ANCIENT=1` is gone. + * [**Change**] The optional dependencies on `libltdl` or `libdl` are gone. + They are no longer needed for any functionality. + + * [**Regression**] Compiling client code using the C++ API now requires a + compiler running in C++11 mode. + * [**Regression**] Support for GCC 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7 has been + removed. + * [**Regression**] Support for Clang 3.0, 3.1, 3.2, 3.3 has been removed. + * [**Regression**] Support for Emscripten versions older than 1.31.0 has been + removed. + * [**Regression**] Support for Android NDK versions older than 11 has been + removed. + * [**Regression**] Visual Studio 2008, 2010, 2012, 2013 support has been + removed. + * [**Regression**] Dynamic run-time loading of libmpg123 is no longer + supported. Libmpg123 must be linked at link-time now. + * [**Regression**] xmp-openmpt: xmp-openmpt now requires XMPlay 3.8 or later + and compiling xmp-openmpt requires an appropriate XMPlay SDK with + `XMPIN_FACE` >= `4`. + * [**Regression**] Support for libmpg123 older than 1.13.0 has been removed. + * [**Regression**] Un4seen unmo3 support has been removed. + + * [**Bug**] C++ API: `openmpt::exception` did not define copy and move + constructors or copy and move assignment operators in libopenmpt 0.2. The + compiler-generated ones were not adequate though. libopenmpt 0.3 adds the + appropriate special member functions. This adds the respective symbol names + to the exported ABI, which, depending on the compiler, might or might not + have been there in libopenmpt 0.2. The possibly resulting possible ODR + violation only affects cases that did crash in the libopenmpt 0.2 API anyway + due to memory double-free, and does not cause any further problems in + practice for all known platforms and compilers. + * [**Bug**] The C API could crash instead of failing gracefully in + out-of-memory situations. + * [**Bug**] The test suite could fail on MacOSX or FreeBSD in non-fatal ways + when no locale was active. + * [**Bug**] `libopenmpt_stream_callbacks_fd.h` and + `libopenmpt_stream_callbacks_file.h` were missing in Windows development + packages. + * [**Bug**] libopenmpt on Windows did not properly guard against current + working directory DLL injection attacks. + * [**Bug**] localtime() was used to determine the version of Schism Tracker + used to save IT and S3M files. This function is not guaranteed to be + thread-safe by the standard and is now no longer used. + * [**Bug**] Possible crashes with malformed IT, ITP, AMS, MDL, MED, MPTM, PSM + and Startrekker files. + * [**Bug**] Possible hangs with malformed DBM, MPTM and PSM files. + * [**Bug**] Possible hangs with malformed files containing cyclic plugin + routings. + * [**Bug**] Excessive loading times with malformed ITP / truncated AMS files. + * [**Bug**] Plugins did not work correctly when changing the sample rate + between two render calls. + * [**Bug**] Possible NULL-pointer dereference read during obscure + out-of-memory situations while handling exceptions in the C API. + * [**Bug**] libmodplug: `libmodplug.pc` was wrong. + * [**Bug**] Cross-compiling libopenmpt with autotools for Windows now properly + sets `-municode` and `-mconsole` as well as all required Windows system + libraries. + * [**Bug**] foo_openmpt: Interpolation filter and volume ramping settings were + confused in previous versions. This version resets both to the defaults. + * [**Bug**] libmodplug: The CSoundFile::Read function in the emulated + libmodplug C++ API returned the wrong value, causing qmmp (and possibly + other software) to crash. + + * Support for SoundTracker Pro II (STP) and Digital Tracker (DTM) modules. + * Increased accuracy of the sample position and sample rate to drift less when + playing very long samples. + * Various playback improvements for IT and XM files. + * Channel frequency could wrap around after some excessive portamento / down + in some formats since libopenmpt 0.2-beta17. + * Playback improvements for S3M files made with Impulse Tracker and + Schism Tracker. + * ParamEq plugin emulation didn't do anything at full gain (+15dB). + * All standard DMO effects are now also emulated on non-Windows and non-MSVC + systems. + * Added `libopenmpt_stream_callbacks_buffer.h` which adds + `openmpt_stream_callbacks` support for in-memory buffers, possibly even only + using a truncated prefix view into a bigger file which is useful for + probing. + * Avoid enabling some ProTracker-specific quirks for MOD files most likely + created with ScreamTracker 3. + * Tremolo effect only had half the intended strength in MOD files. + * Pattern loops ending on the last row a pattern were not executed correctly + in S3M files. + * Work-around for reading MIDI macros and plugin settings in some malformed IT + files written by old UNMO3 versions. + * Improve tracker detection in IT format. + * Playback fixes for 8-channel MED files + * Do not set note volume to 0 on out-of-range offset in XM files. + * Better import of some slide commands in SFX files. + * Sample 15 in "Crew Generation" by Necros requires short loops at the + beginning of the sample to not be ignored. Since we need to ignore them in + some (non-ProTracker) modules, we heuristically disable the old loop + sanitization behaviour based on the module channel count. + * Both normal and percentage offset in PLM files were handled as percentage + offset. + * MT2 files with instruments that had both sample and plugin assignments were + not read correctly. + * Some valid FAR files were rejected erroneously. + * Support for VBlank timing flag and comment field in PT36 files. + * Improved accuracy of vibrato command in DIGI / DBM files. + * STM: Add support for "WUZAMOD!" magic bytes and allow some slightly + malformed STM files to load which were previously rejected. + * Detect whether "hidden" patterns in the order list of SoundTracker modules + should be taken into account or not. + * Tighten heuristics for rejecting invalid 669, M15, MOD and ICE files and + loosen them in other places to allow some valid MOD files to load. + * Improvements to seeking: Channel panning was not always updated from + instruments / samples when seeking, and out-of-range global volume was not + applied correctly in some formats. + * seek.sync_samples=1 did not apply PTM reverse offset effect and the volume + slide part of combined volume slide + vibrato commands. + * If the order list was longer than 256 items and there was a pattern break + effect without a position jump on the last pattern of the sequence, it did + not jump to the correct restart order. + * `Makefile` has now explicit support for FreeBSD with no special option or + configuration required. + * openmpt123: Improved section layout in man page. + * libmodplug: Added all missing C++ API symbols that are accessible via the + public libmodplug header file. + * Autotools build system now has options `--disable-openmpt123`, + `--disable-tests` and `--disable-examples` which may be desireable when + cross-compiling. + * Windows binary packages now ship with libmpg123 included. + +### libopenmpt 0.2-beta20 (2016-08-07) + + * [**Bug**] PSM loader was broken on big-endian platforms since forever. + * [**Bug**] `load.skip_samples` ctl did not work for PSM16 modules. + + * There is a new `subsong` ctl, which can return the currently selected + subsong. + * More accurate ProTracker arpeggio wrap-around emulation. + * More accurate sample tuning in PSM16 files. + * Samples in DSM files were sometimes detuned and some pattern commands were + not imported correctly. + * More accurate import of MDL 7-bit panning command. + * Only import pattern commands supported by the UltraTracker version that was + used to save ULT files. Add support for command 5-C (end loop). + * DMF sample loop lengths were off by one. + * Unis 669 pan slide effect was too deep. + * Several valid (but slightly corrupted possibly due to disk failures or data + transfer errors) SoundTracker files were no longer loading since libopenmpt + 0.2-beta18. + +### libopenmpt 0.2-beta19 (2016-07-23) + + * [**Change**] libopenmpt now uses C++14 `[[deprecated]]` attribute instead + of compiler-specific solutions when appropriate. + * [**Change**] libopenmpt C++ header now uses C++11 `noexcept` instead of + C++98 `throw()` exception specification when supported. `throw()` is + deprecated since C++11. This does not change API or ABI as they are + equivalent. Use `LIBOPENMPT_ASSUME_CPLUSPLUS_NOEXCEPT` to override the + default. + * [**Change**] The preprocessor macro `LIBOPENMPT_ANCIENT_COMPILER_STDINT` is + gone. Please use `LIBOPENMPT_ASSUME_CPLUSPLUS_CSTDINT instead`. + Additionally, the typedefs moved from illegal namespace ::std into somewhat + less dangerous namespace ::openmpt::std. You can test + `#ifdef LIBOPENMPT_QUIRK_NO_CSTDINT` client-side to check whether + `libopenmpt.hpp` used the non-standard types. (Note: Of all supported + compilers, this change only affects the 3 compilers with only limited + support: MSVC 2008, GCC 4.1, GCC 4.2.) + + * [**Bug**] xmp-openmpt: Crash when viewing sample texts. + + * The public libopenmpt C++ header has auto-detection logic for the used C++ + standard now. In case your client code compiler misreports the standard + version or you want to override it for other reasons, + `#define LIBOPENMPT_ASSUME_CPLUSPLUS` to the value of the standard version + you desire to be used. There is also a macro for each individual aspect, + like `LIBOPENMPT_ASSUME_CPLUSPLUS_CSTDINT`, + `LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED`, + `LIBOPENMPT_ASSUME_CPLUSPLUS_NOEXCEPT` which take precedence over the + general macro. + * Portamento with sample swap behaviour was wrong for ProTracker MODs. + * Rewritten loader and various playback fixes for MDL files. + * libopenmpt 0.2-beta18 broke import of many pattern commands in DBM, DMF and + ULT files. + * ADPCM samples in MOD files were broken since libopenmpt 0.2-beta17. + +### libopenmpt 0.2-beta18 (2016-07-11) + + * [**Change**] openmpt123: Add PulseAudio output support. Autotools and + `Makefile` build systems now depend on `libpulse` and `libpulse-simple` by + default. Disable with `--without-pulseaudio` or `NO_PULSEAUDIO=1` + respectively. When enabled, PulseAudio will be the default output driver, + * [**Change**] xmp-openmpt: Settings are now stored in xmplay.ini like with + every other plugin. + + * [**Regression**] openmpt123: Support for FLAC < 1.3.0 has been removed. FLAC + before 1.3.0 is broken beyond repair as it provides `assert.h` in the + include path. + + * [**Bug**] Generated pkg-config file libopenmpt.pc by both `Makefile` and + Autotools build systems was totally broken. + * [**Bug**] libopenmpt no longer uses the non-thread-safe global std::rand() + function. + * [**Bug**] Sample loops in GDM modules did not work when using Emscripten. + * [**Bug**] XM and MO3 loaders could crash due to unaligned memory accesses. + * [**Bug**] Fixed incorrect handling of custom MPTM tunings on big endian + platforms. + * [**Bug**] Fixed various problems found with clang 3.8 static analyzer, + address sanitizer and undefined behaviour sanitizer. + * [**Bug**] File header probing functionality was broken for most formats. + * [**Bug**] With non-seekable streams, the entire file was almost always + cached even if it was not of any supported module type. + + * Seeking in allsubsongs-mode now works correctly. + * openmpt123: Added subsong support. + * Various playback fixes for 669, IT, MT2 and MTM files. + * Some MOD files with more than 128 patterns (e.g. NIETNU.MOD) were not loaded + correctly. + * A new example `libopenmpt_example_c_probe` has been added which demonstrates + the usage and flexibility of openmpt_could_open_propability() in the C API + under various constraints. + +### libopenmpt 0.2-beta17 (2016-05-21) + + * [**Change**] The Makefile and Autotools build systems now require to + explicitly specify `NO_LTDL=1` or `--without-ltdl` respectively if no + support for dynamic loading of third party libraries via libtool libltdl is + desired. + * [**Change**] In the Makefile build system option `USE_MO3` and the Autotools + build system option `--enable-mo3` are gone. Dynamic loading of un4seen + unmo3 is now always enabled when dynamic loading is possible and built-in + MO3 support is not possible because either a MP3 or a Vorbis decoder is + missing. + * [**Change**] The MSVC build system changed. The `libopenmptDLL` project is + gone. Use the new `ReleaseShared` configuration of the `libopenmpt` project + instead. libopenmpt now links against zlib by default. A separate project + with smaller footprint linking against miniz is still available as + `libopenmpt-small`. + * [**Change**] The constants used to query library information from + `openmpt_get_string()` and `openmpt::string::get()` (i.e. OPENMPT_STRING_FOO + and openmpt::string::FOO) have been deprecated because having syntactic + constants for theses keys makes extending the API in a backwards and + forwards compatible way harder than it should be. Please just use the string + literals directly. + * [**Change**] Deprecated API identifiers will now cause deprecation warnings + with MSVC, GCC and clang. `#define LIBOPENMPT_NO_DEPRECATE` to disable the + warnings. + * [**Change**] openmpt123: `--[no-]shuffle` option has been renamed to + `--[no-]randomize`. A new `--[no-]shuffle` option has been added which + shuffles randomly through the playlist as opposed to randomizing the + playlist upfront. + * [**Change**] Support for Un4seen unmo3 has generally been deprecated in + favour of the new internal mo3 decoder. Un4seen unmo3 support will be + removed on 2018-01-01. + + * [**Bug**] Memory consumption during loading has been reduced by about 1/3 in + case a seekable input stream is provided (either via C API callback open + functions or via C++ API iostream constructors). + * [**Bug**] Some samples in AMS modules were detuned when using Emscripten. + * [**Bug**] Possible crash with excessive portamento down in some formats. + * [**Bug**] Possible crashes with malformed AMF, AMS, DBM, IT, MDL, MED, MPTM, + MT2, PSM and MMCMP-, XPK- and PP20-compressed files. + * [**Bug**] `openmpt::module::format_pattern_row_channel` with `width == 0` + was returning an empty string instead of an string with unconstrained + length. + + * Support for ProTracker 3.6 IFF-style modules and SoundFX / MultiMedia Sound + (SFX / MMS) modules. + * libopenmpt now has support for DMO plugins on Windows when built with MSVC. + Additionally, the DMO Compression, Distortion, Echo, Gargle, ParamEQ and + WavesReverb DSPs are emulated on on all other platforms. + * libopenmpt now supports the DigiBooster Echo DSP. + * To avoid any of the aforementioned plugins to be used, the load.skip_plugins + ctl can be passed when loading a module. + * libopenmpt got native MO3 support with MP3 decoding either via libmpg123 or + MediaFoundation (on Windows 7 and up) and Vorbis decoding via libogg, + libvorbis, libvorbisfile or stb_vorbis. + * libopenmpt MSVC builds with Visual Studio 2010 or later on Windows 7 or + later now use an internal MO3 decoder with libogg, libvorbis, libvorbisfile, + and libmpg123 or minimp3 or MediaFoundation suppport by default. Visual + Studio 2008 builds still use unmo3.dll by default but also support the + built-in decoder in which case libmpg123 is required. + * libopenmpt with Makefile or Autotools build system can now also use + glibc/libdl instead of libtool/libltdl for dynamic loading of third-party + libraries. Options `NO_DL=1` and `--without-dl` have been added + respectively. + * The `Makefile` build system got 4 new options NO_MPG123, NO_OGG, NO_VORBIS, + NO_VORBISFILE. The default is to use the new dependencies automatically. + * The `Autotools` build system got 4 new options --without-mpg123, + --without-ogg, --without-vorbis, --without-vorbisfile. The default is to use + the new dependencies automatically. + * Makefile and Android builds got support for using minimp3 instead of + libmpg123. For Android, use `Android-minimp3-stbvorbis.mk`, for Makefile use + `USE_MINIMP3=1`. You have to download + [minimp3](http://keyj.emphy.de/minimp3/) yourself and put its contents into + `include/minimp3/`. + * `"source_url"`, `"source_date"` and `"build_compiler"` keys have been added + to `openmpt_string_get()` and `openmpt::string::get()`. + * openmpt123: Add new `--[no-]restart]` option which restarts the playlist + when finished. + * Improved Ultimate SoundTracker version detection heuristics. + * Playing a sample at a sample rate close to the mix rate could lead to small + clicks when using vibrato. + * More fine-grained internal legacy module compatibility settings to correctly + play back modules made with older versions of OpenMPT and a few other + trackers. + * The tail of compressed MDL samples was slightly off. + * Some probably hex-edited XM files (e.g. cybernostra weekend.xm) were not + loaded correctly. + * Countless other playback fixes for MOD, XM, S3M, IT and MT2 files. + +### libopenmpt 0.2-beta16 (2015-11-22) + + * [**Change**] The Autotools build system does strict checking of all + dependencies now. Instead of best effort auto-magic detection of all + potentially optional dependencies, the default set of dependencies is now + enforced unless each individual dependency gets explicitely disabled via + `--without-foo` or `--disable-foo` `./configure` switches. Run + `./configure --help` for the full list of options. + + * [**Bug**] Some MOD files were erroneously detected as 669 files. + * [**Bug**] Some malformed AMF files could result in very long loading times. + * [**Bug**] Fixed crashes in IMF and MT2 loaders. + * [**Bug**] MTM files generated by UNMO3 were not loaded properly. + + * Improved MTM playback. + * `make CONFIG=haiku` for Haiku has been added. + * Language bindings for FreeBASIC have been added (see + `libopenmpt/bindings/`). + +### libopenmpt 0.2-beta15 (2015-10-31) + + * [**Change**] openmpt123: SDL2 is now supported and preferred to SDL1 if + available with the `Makefile` build system. + + * [**Bug**] Emscripten support for older emscripten versions broke in -beta14. + These are now supported again when using `make CONFIG=emscripten-old`. + * [**Bug**] Fixed crashes in MED loader. + + * Playback improvements and loader fixes for MOD, MT2 and MED. + +### libopenmpt 0.2-beta14 (2015-09-13) + + * [**Change**] The C++ API example now uses the PortAudio C++ bindings + instead of the C API. + * [**Change**] Default compiler options for Emscripten have been changed to + more closely match the Emscripten recommendations. + + * [**Bug**] Client code compilation with C89 compilers was broken in beta13. + * [**Bug**] Test suite failed on certain Emscripten/node.js combinations. + * [**Bug**] Fixed various crashes or hangs in DMF, OKT, PLM, IT and MPTM + loaders. + + * Implemented error handling in the libopenmpt API examples. + * Various playback improvements and fixes for OKT, IT and MOD. + +### libopenmpt 0.2-beta13 (2015-08-16) + + * [**Change**] The MSVC build system has been redone. Solutions are now + located in `build/vsVERSION/`. + + * [**Bug**] get_current_channel_vu_left and get_current_channel_vu_right only + return the volume of the front left and right channels now. + get_current_channel_vu_rear_left and get_current_channel_vu_rear_right + do now actually work and return non-zero values. + * [**Bug**] Fix crashes and hangs in MED and MDL loaders and with some + truncated compressed IT samples. + * [**Bug**] Fix crash when playing extremely high-pitched samples. + + * Completed C and C++ documentation + * Added new key for openmpt::module::get_metadata, "message_raw", which + returns an empty string if there is no song message rather than a list of + instrument names. + * in_openmpt: Support for compiling with VS2008. + * xmp-openmpt: Support for compiling with VS2008. + * in_openmpt: Add a more readable file information window. + +### libopenmpt 0.2-beta12 (2015-04-19) + + * Playback fix when row delay effect is used together with offset command. + * A couple of fixes for the seek.sync_samples=1 case. + * IT compatibility fix for IT note delay. + * ProTracker MOD playback compatibility improvement. + +### libopenmpt 0.2-beta11 (2015-04-18) + + * [**Change**] openmpt_stream_seek_func() now gets called with + OPENMPT_STREAM_SEEK_SET, OPENMPT_STREAM_SEEK_CUR and + OPENMPT_STREAM_SEEK_END whence parameter instead of SEEK_SET, SEEK_CUR and + SEEK_END. These are defined to 0, 1 and 2 respectively which corresponds to + the definition in all common C libraries. If your C library uses different + constants, this theoretically breaks binary compatibility. The old + libopenmpt code, however, never actually called the seek function, thus, + there will be no problem in practice. + * [**Change**] openmpt123: When both SDL1.2 and PortAudio are available, + SDL is now the preferred backend because SDL is more widespread and better + tested on all kinds of different platforms, and in general, SDL is just + more reliable. + + * [**Bug**] libopenmpt now also compiles with GCC 4.3. + + * libopenmpt now supports PLM (Disorder Tracker 2) files. + * Various playback improvements and fixes for IT, S3M, XM, MOD, PTM and 669 + files. + +### libopenmpt 0.2-beta10 (2015-02-17) + + * [**Change**] Makefile configuration filenames changed from + `build/make/Makefile.config.*` to `build/make/config-*.mk`. + * [**Change**] libopenmpt for Android now supports unmo3 from un4seen. See + `build/android_ndk/README.AndroidNDK.txt` for details. + + * [**Bug**] Fix out-of-bounds read in mixer code for ProTracker-compatible + MOD files which was introduced back in r4223 / beta6. + + * Vibrato effect was too weak in beta8 and beta9 in IT linear slide mode. + * Very small fine portamento was wrong in beta8 and beta9 in IT linear slide + mode. + * Tiny IT playback compatibility improvements. + * STM playback improvements. + +### libopenmpt 0.2-beta9 (2014-12-21) + + * [**Bug**] libopenmpt_ext.hpp was missing from the Windows binary zip files. + +### libopenmpt 0.2-beta8 (2014-12-21) + + * [**Change**] foo_openmpt: Settings are now accessible via foobar2000 + advanced settings. + * [**Change**] Autotools based build now supports libunmo3. Specify + --enable-unmo3. + * [**Change**] Support for dynamic loading of libunmo3 on MacOS X. + * [**Change**] libopenmpt now uses libltld (from libtool) for dynamic loading + of libunmo3 on all non-Windows platforms. + * [**Change**] Support for older compilers: + * GCC 4.1.x to 4.3.x (use `make ANCIENT=1`) + * Microsoft Visual Studio 2008 (with latest Service Pack) + (see `build/vs2008`) + * [**Change**] libopenmpt_ext.hpp is now distributed by default. The API is + still considered experimental and not guaranteed to stay API or ABI + compatible. + * [**Change**] xmp-openmpt / in_openmpt: No more libopenmpt_settings.dll. + The settings dialog now uses a statically linked copy of MFC. + + * [**Bug**] The -autotools tarballs were not working at all. + + * Vastly improved MT2 loader. + * Improved S3M playback compatibility. + * Added openmpt::ext::interactive, an extension which adds a whole bunch of + new functionality to change playback in some way or another. + * Added possibility to sync sample playback when using + openmpt::module::set_position_* by setting the ctl value + seek.sync_samples=1 + * Support for "hidden" subsongs has been added. + They are accessible through the same interface as ordinary subsongs, i.e. + use openmpt::module::select_subsong to switch between any kind of subsongs. + * All subsongs can now be played consecutively by passing -1 as the subsong + index in openmpt::module::select_subsong. + * Added documentation for a couple of more functions. + +### libopenmpt 0.2-beta7 (2014-09-07) + + * [**Change**] libopenmpt now has an GNU Autotools based build system (in + addition to all previously supported ways of building libopenmpt). + Autotools support is packaged separately as tarballs ending in + `-autotools.tar.gz`. + + * [**Bug**] The distributed windows .zip file did not include pugixml. + + * [**Regression**] openmpt123: Support for writing WavPack (.wv) files has + been removed. + + Reasoning: + 1. WavPack support was incomplete and did not include support for writing + WavPack metadata at all. + 2. openmpt123 already supports libSndFile which can be used to write + uncompressed lossless WAV files which can then be encoded to whatever + format the user desires with other tools. + +### libopenmpt 0.2-beta6 (2014-09-06) + + * [**Change**] openmpt123: SDL is now also used by default if availble, in + addition to PortAudio. + * [**Change**] Support for emscripten is no longer experimental. + * [**Change**] libopenmpt itself can now also be compiled with VS2008. + + * [**Bug**] Fix all known crashes on platforms that do not support unaligned + memory access. + * [**Bug**] openmpt123: Effect column was always missing in pattern display. + +### libopenmpt 0.2-beta5 (2014-06-15) + + * [**Change**] Add unmo3 support for non-Windows builds. + * [**Change**] Namespace all internal functions in order to allow statically + linking against libopenmpt without risking duplicate symbols. + * [**Change**] Iconv is now completely optional and only used on Linux + systems by default. + * [**Change**] Added libopenmpt_example_c_stdout.c, an example without + requiring PortAudio. + * [**Change**] Add experimental support for building libopenmpt with + emscripten. + + * [**Bug**] Fix ping-pong loop behaviour which broke in 0.2-beta3. + * [**Bug**] Fix crashes when accessing invalid patterns through libopenmpt + API. + * [**Bug**] Makefile: Support building with missing optional dependencies + without them being stated explicitely. + * [**Bug**] openmpt123: Crash when quitting while playback is stopped. + * [**Bug**] openmpt123: Crash when writing output to a file in interactive UI + mode. + * [**Bug**] openmpt123: Wrong FLAC output filename in --render mode. + + * Various smaller playback accuracy improvements. + +### libopenmpt 0.2-beta4 (2014-02-25) + + * [**Bug**] Makefile: Dependency tracking for the test suite did not work. + +### libopenmpt 0.2-beta3 (2014-02-21) + + * [**Change**] The test suite is now built by default with Makefile based + builds. Use `TEST=0` to skip building the tests. `make check` runs the test + suite. + + * [**Bug**] Crash in MOD and XM loaders on architectures not supporting + unaligned memory access. + * [**Bug**] MMCMP, PP20 and XPK unpackers should now work on non-x86 hardware + and implement proper bounds checking. + * [**Bug**] openmpt_module_get_num_samples() returned the wrong value. + * [**Bug**] in_openmpt: DSP plugins did not work properly. + * [**Bug**] in_openmpt/xmp-openmpt: Setting name for stereo separation was + misspelled. This version will revert your stereo separation settings to + default. + * [**Bug**] Crash when loading some corrupted modules with stereo samples. + + * Support building on Android NDK. + * Avoid clicks in sample loops when using interpolation. + * IT filters are now done in integer instead of floating point. This improves + performance, especially on architectures with no or a slow FPU. + * MOD pattern break handling fixes. + * Various XM playback improvements. + * Improved and switchable dithering when using 16bit integer API. + +### libopenmpt 0.2-beta2 (2014-01-12) + + * [**Bug**] MT2 loader crash. + * [**Bug**] Saving settings in in_openmpt and xmp-openmpt did not work. + * [**Bug**] Load libopenmpt_settings.dll also from below Plugins directory in + Winamp. + + * DBM playback improvements. + +### libopenmpt 0.2-beta1 (2013-12-31) + + * First release. + diff --git a/libs/libopenmpt/debian/libopenmpt-0.4.0-trusty-backport.diff b/libs/libopenmpt/debian/libopenmpt-0.4.0-trusty-backport.diff new file mode 100644 index 000000000..1c9b56ba5 --- /dev/null +++ b/libs/libopenmpt/debian/libopenmpt-0.4.0-trusty-backport.diff @@ -0,0 +1,550 @@ +diff -uraN ../../orig/libopenmpt-0.4.0/debian/changelog ./debian/changelog +--- ../../orig/libopenmpt-0.4.0/debian/changelog 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/changelog 2019-01-04 17:56:35.024725537 -0500 +@@ -1,3 +1,38 @@ ++libopenmpt (0.4.0-ubuntu14.04.1~ppa14) trusty; urgency=medium ++ ++ * Remove debian symbols files due to gcc 4.8 - 5 C++ abi incompatibility ++ ++ -- Sonic Team Junior Fri, 04 Jan 2019 17:56:01 -0500 ++ ++libopenmpt (0.4.0-ubuntu14.04.1~ppa13) trusty; urgency=medium ++ ++ * autoreconf libtool ++ ++ -- Sonic Team Junior Fri, 04 Jan 2019 17:10:45 -0500 ++ ++libopenmpt (0.4.0-ubuntu14.04.1~ppa12) trusty; urgency=medium ++ ++ * debian/rules autoreconf ++ ++ -- Sonic Team Junior Fri, 04 Jan 2019 17:03:19 -0500 ++ ++libopenmpt (0.4.0-ubuntu14.04.1~ppa11) trusty; urgency=medium ++ ++ * debian/rules autoreconf ++ ++ -- Sonic Team Junior Fri, 04 Jan 2019 16:59:08 -0500 ++ ++libopenmpt (0.4.0-ubuntu14.04.1~ppa10) trusty; urgency=medium ++ ++ * Backport to trusty ++ * Added automake build depend ++ * Adjusted debhelper depend to >= 9.0~ ++ * Adjusted dpkg-dev depend to >= 1.17.0 ++ * Adjusted debian/compat to 10 ++ * autoreconf --force --install ++ ++ -- Sonic Team Junior Fri, 04 Jan 2019 16:54:04 -0500 ++ + libopenmpt (0.4.0-1) unstable; urgency=medium + + * New upstream release. +diff -uraN ../../orig/libopenmpt-0.4.0/debian/compat ./debian/compat +--- ../../orig/libopenmpt-0.4.0/debian/compat 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/compat 2019-01-04 16:39:17.613976357 -0500 +@@ -1 +1 @@ +-11 ++10 +diff -uraN ../../orig/libopenmpt-0.4.0/debian/control ./debian/control +--- ../../orig/libopenmpt-0.4.0/debian/control 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/control 2019-01-04 17:10:42.008523333 -0500 +@@ -4,10 +4,12 @@ + Maintainer: Debian Multimedia Maintainers + Uploaders: James Cowgill + Build-Depends: +- debhelper (>= 11.1~), ++ automake, ++ libtool, ++ debhelper (>= 9.0~), + dh-exec, + doxygen, +- dpkg-dev (>= 1.18.0), ++ dpkg-dev (>= 1.17.0), + libflac-dev, + libmpg123-dev, + libogg-dev, +diff -uraN ../../orig/libopenmpt-0.4.0/debian/files ./debian/files +--- ../../orig/libopenmpt-0.4.0/debian/files 1969-12-31 19:00:00.000000000 -0500 ++++ ./debian/files 2019-01-04 17:56:47.813250880 -0500 +@@ -0,0 +1 @@ ++libopenmpt_0.4.0-ubuntu14.04.1~ppa14_source.buildinfo libs optional +diff -uraN ../../orig/libopenmpt-0.4.0/debian/libopenmpt0.symbols ./debian/libopenmpt0.symbols +--- ../../orig/libopenmpt-0.4.0/debian/libopenmpt0.symbols 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/libopenmpt0.symbols 1969-12-31 19:00:00.000000000 -0500 +@@ -1,256 +0,0 @@ +-libopenmpt.so.0 libopenmpt0 #MINVER# +-* Build-Depends-Package: libopenmpt-dev +-# Ignore std:: template instantiations +- (regex|optional)"^_ZN?K?S" 0.2.7025~beta20.1 +- _ZN7openmpt10module_ext13get_interfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt10module_extC1EPKcjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt10module_extC1EPKcmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt10module_extC1EPKvjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt10module_extC1EPKvmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extC1ERKS0_@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extC1ERKSt6vectorIcSaIcEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcES2_EESC_St4lessISC_ESaISt4pairIKSC_SC_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extC1ERSiRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_St4lessIS9_ESaISt4pairIKS9_S9_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt10module_extC2EPKcjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt10module_extC2EPKcmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt10module_extC2EPKvjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt10module_extC2EPKvmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extC2ERKS0_@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extC2ERKSt6vectorIcSaIcEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcES2_EESC_St4lessISC_ESaISt4pairIKSC_SC_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extC2ERSiRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_St4lessIS9_ESaISt4pairIKS9_S9_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extD0Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extD1Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extD2Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt10module_extaSERKS0_@Base 0.2.7025~beta20.1 +- _ZN7openmpt16get_core_versionEv@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt17probe_file_headerEyPKhj@Base 0.3.0 +- (arch-bits=64)_ZN7openmpt17probe_file_headerEmPKhm@Base 0.3.0 +- (arch-bits=32)_ZN7openmpt17probe_file_headerEyPKhjy@Base 0.3.0 +- (arch-bits=64)_ZN7openmpt17probe_file_headerEmPKhmm@Base 0.3.0 +- (arch-bits=32)_ZN7openmpt17probe_file_headerEyRSi@Base 0.3.0 +- (arch-bits=64)_ZN7openmpt17probe_file_headerEmRSi@Base 0.3.0 +- _ZN7openmpt19get_library_versionEv@Base 0.2.7025~beta20.1 +- _ZN7openmpt22could_open_probabilityERSidRSo@Base 0.3.0 +- _ZN7openmpt22could_open_propabilityERSidRSo@Base 0.2.7025~beta20.1 +- _ZN7openmpt22is_extension_supportedERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt24get_supported_extensionsB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt38probe_file_header_get_recommended_sizeEv@Base 0.3.0 +- _ZN7openmpt6module14select_subsongEi@Base 0.2.7025~beta20.1 +- _ZN7openmpt6module16set_render_paramEii@Base 0.2.7025~beta20.1 +- _ZN7openmpt6module16set_repeat_countEi@Base 0.2.7025~beta20.1 +- _ZN7openmpt6module20set_position_secondsEd@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module21read_interleaved_quadEijPf@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module21read_interleaved_quadEimPf@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module21read_interleaved_quadEijPs@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module21read_interleaved_quadEimPs@Base 0.2.7025~beta20.1 +- _ZN7openmpt6module22set_position_order_rowEii@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module23read_interleaved_stereoEijPf@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module23read_interleaved_stereoEimPf@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module23read_interleaved_stereoEijPs@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module23read_interleaved_stereoEimPs@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module4readEijPf@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module4readEimPf@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module4readEijPfS1_@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module4readEimPfS1_@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module4readEijPfS1_S1_S1_@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module4readEimPfS1_S1_S1_@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module4readEijPs@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module4readEimPs@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module4readEijPsS1_@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module4readEimPsS1_@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6module4readEijPsS1_S1_S1_@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6module4readEimPsS1_S1_S1_@Base 0.2.7025~beta20.1 +- _ZN7openmpt6module7ctl_setERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_@Base 0.2.7025~beta20.1 +- _ZN7openmpt6module8set_implEPNS_11module_implE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1EPKcS2_RSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6moduleC1EPKcjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6moduleC1EPKcmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1EPKhS2_RSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6moduleC1EPKhjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6moduleC1EPKhmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6moduleC1EPKvjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6moduleC1EPKvmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1ERKS0_@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1ERKSt6vectorIcSaIcEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcES2_EESC_St4lessISC_ESaISt4pairIKSC_SC_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1ERKSt6vectorIhSaIhEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_St4lessISD_ESaISt4pairIKSD_SD_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1ERSiRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_St4lessIS9_ESaISt4pairIKS9_S9_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC1Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2EPKcS2_RSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6moduleC2EPKcjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6moduleC2EPKcmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2EPKhS2_RSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6moduleC2EPKhjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6moduleC2EPKhmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZN7openmpt6moduleC2EPKvjRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZN7openmpt6moduleC2EPKvmRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_St4lessISA_ESaISt4pairIKSA_SA_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2ERKS0_@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2ERKSt6vectorIcSaIcEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcES2_EESC_St4lessISC_ESaISt4pairIKSC_SC_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2ERKSt6vectorIhSaIhEERSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESD_St4lessISD_ESaISt4pairIKSD_SD_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2ERSiRSoRKSt3mapINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_St4lessIS9_ESaISt4pairIKS9_S9_EEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleC2Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleD0Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleD1Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleD2Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt6moduleaSERKS0_@Base 0.2.7025~beta20.1 +- _ZN7openmpt6string3getERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt9exceptionC1EOS0_@Base 0.3.0 +- _ZN7openmpt9exceptionC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt9exceptionC1ERKS0_@Base 0.3.0 +- _ZN7openmpt9exceptionC2EOS0_@Base 0.3.0 +- _ZN7openmpt9exceptionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- _ZN7openmpt9exceptionC2ERKS0_@Base 0.3.0 +- _ZN7openmpt9exceptionD0Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt9exceptionD1Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt9exceptionD2Ev@Base 0.2.7025~beta20.1 +- _ZN7openmpt9exceptionaSEOS0_@Base 0.3.0 +- _ZN7openmpt9exceptionaSERKS0_@Base 0.3.0 +- _ZNK7openmpt6module12get_metadataERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module14get_num_ordersEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module15get_current_rowEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module15get_num_samplesEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module15get_order_namesB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module16get_num_channelsEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module16get_num_patternsEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module16get_num_subsongsEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module16get_render_paramEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module16get_repeat_countEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module16get_sample_namesB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_channel_namesB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_current_orderEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_current_speedEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_current_tempoEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_metadata_keysB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_order_patternEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_pattern_namesB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module17get_subsong_namesB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module19get_current_patternEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module19get_num_instrumentsEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module20get_duration_secondsEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module20get_instrument_namesB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module20get_pattern_num_rowsEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module20get_position_secondsEv@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module20get_selected_subsongEv@Base 0.3.0 +- (arch-bits=32)_ZNK7openmpt6module26format_pattern_row_channelB5cxx11Eiiijb@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZNK7openmpt6module26format_pattern_row_channelB5cxx11Eiiimb@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module27get_current_channel_vu_leftEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module27get_current_channel_vu_monoEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module28get_current_channel_vu_rightEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module28get_current_playing_channelsEv@Base 0.2.7025~beta20.1 +- (arch-bits=32)_ZNK7openmpt6module29highlight_pattern_row_channelB5cxx11Eiiijb@Base 0.2.7025~beta20.1 +- (arch-bits=64)_ZNK7openmpt6module29highlight_pattern_row_channelB5cxx11Eiiimb@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module31get_pattern_row_channel_commandEiiii@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module32get_current_channel_vu_rear_leftEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module33get_current_channel_vu_rear_rightEi@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module34format_pattern_row_channel_commandB5cxx11Eiiii@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module37highlight_pattern_row_channel_commandB5cxx11Eiiii@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module7ctl_getERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@Base 0.2.7025~beta20.1 +- _ZNK7openmpt6module8get_ctlsB5cxx11Ev@Base 0.2.7025~beta20.1 +- _ZNK7openmpt9exception4whatEv@Base 0.2.7025~beta20.1 +- _ZTIN7openmpt10module_extE@Base 0.2.7025~beta20.1 +- _ZTIN7openmpt6moduleE@Base 0.2.7025~beta20.1 +- _ZTIN7openmpt9exceptionE@Base 0.2.7025~beta20.1 +- (optional=weak)_ZTISt11_Mutex_baseILN9__gnu_cxx12_Lock_policyE2EE@Base 0.2.7025~beta20.1 +- (optional=weak)_ZTISt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE@Base 0.2.7025~beta20.1 +- _ZTSN7openmpt10module_extE@Base 0.2.7025~beta20.1 +- _ZTSN7openmpt6moduleE@Base 0.2.7025~beta20.1 +- _ZTSN7openmpt9exceptionE@Base 0.2.7025~beta20.1 +- (optional=weak)_ZTSSt11_Mutex_baseILN9__gnu_cxx12_Lock_policyE2EE@Base 0.2.7025~beta20.1 +- (optional=weak)_ZTSSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE@Base 0.2.7025~beta20.1 +- (optional=weak)_ZTSSt19_Sp_make_shared_tag@Base 0.2.7025~beta20.1 +- _ZTVN7openmpt10module_extE@Base 0.2.7025~beta20.1 +- _ZTVN7openmpt6moduleE@Base 0.2.7025~beta20.1 +- _ZTVN7openmpt9exceptionE@Base 0.2.7025~beta20.1 +- (optional=weak)_ZZNSt19_Sp_make_shared_tag5_S_tiEvE5__tag@Base 0.4.0 +- openmpt_could_open_probability2@Base 0.3.0 +- openmpt_could_open_probability@Base 0.3.0 +- openmpt_could_open_propability@Base 0.2.7025~beta20.1 +- openmpt_error_func_default@Base 0.3.0 +- openmpt_error_func_errno@Base 0.3.0 +- openmpt_error_func_errno_userdata@Base 0.3.0 +- openmpt_error_func_ignore@Base 0.3.0 +- openmpt_error_func_log@Base 0.3.0 +- openmpt_error_func_store@Base 0.3.0 +- openmpt_error_is_transient@Base 0.3.0 +- openmpt_error_string@Base 0.3.0 +- openmpt_free_string@Base 0.2.7025~beta20.1 +- openmpt_get_core_version@Base 0.2.7025~beta20.1 +- openmpt_get_library_version@Base 0.2.7025~beta20.1 +- openmpt_get_string@Base 0.2.7025~beta20.1 +- openmpt_get_supported_extensions@Base 0.2.7025~beta20.1 +- openmpt_is_extension_supported@Base 0.2.7025~beta20.1 +- openmpt_log_func_default@Base 0.2.7025~beta20.1 +- openmpt_log_func_silent@Base 0.2.7025~beta20.1 +- openmpt_module_create2@Base 0.3.0 +- openmpt_module_create@Base 0.2.7025~beta20.1 +- openmpt_module_create_from_memory2@Base 0.3.0 +- openmpt_module_create_from_memory@Base 0.2.7025~beta20.1 +- openmpt_module_ctl_get@Base 0.2.7025~beta20.1 +- openmpt_module_ctl_set@Base 0.2.7025~beta20.1 +- openmpt_module_destroy@Base 0.2.7025~beta20.1 +- openmpt_module_error_clear@Base 0.3.0 +- openmpt_module_error_get_last@Base 0.3.0 +- openmpt_module_error_get_last_message@Base 0.3.0 +- openmpt_module_error_set_last@Base 0.3.0 +- openmpt_module_ext_create@Base 0.3.0 +- openmpt_module_ext_create_from_memory@Base 0.3.0 +- openmpt_module_ext_destroy@Base 0.3.0 +- openmpt_module_ext_get_interface@Base 0.3.0 +- openmpt_module_ext_get_module@Base 0.3.0 +- openmpt_module_format_pattern_row_channel@Base 0.2.7025~beta20.1 +- openmpt_module_format_pattern_row_channel_command@Base 0.2.7025~beta20.1 +- openmpt_module_get_channel_name@Base 0.2.7025~beta20.1 +- openmpt_module_get_ctls@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_channel_vu_left@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_channel_vu_mono@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_channel_vu_rear_left@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_channel_vu_rear_right@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_channel_vu_right@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_order@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_pattern@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_playing_channels@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_row@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_speed@Base 0.2.7025~beta20.1 +- openmpt_module_get_current_tempo@Base 0.2.7025~beta20.1 +- openmpt_module_get_duration_seconds@Base 0.2.7025~beta20.1 +- openmpt_module_get_instrument_name@Base 0.2.7025~beta20.1 +- openmpt_module_get_metadata@Base 0.2.7025~beta20.1 +- openmpt_module_get_metadata_keys@Base 0.2.7025~beta20.1 +- openmpt_module_get_num_channels@Base 0.2.7025~beta20.1 +- openmpt_module_get_num_instruments@Base 0.2.7025~beta20.1 +- openmpt_module_get_num_orders@Base 0.2.7025~beta20.1 +- openmpt_module_get_num_patterns@Base 0.2.7025~beta20.1 +- openmpt_module_get_num_samples@Base 0.2.7025~beta20.1 +- openmpt_module_get_num_subsongs@Base 0.2.7025~beta20.1 +- openmpt_module_get_order_name@Base 0.2.7025~beta20.1 +- openmpt_module_get_order_pattern@Base 0.2.7025~beta20.1 +- openmpt_module_get_pattern_name@Base 0.2.7025~beta20.1 +- openmpt_module_get_pattern_num_rows@Base 0.2.7025~beta20.1 +- openmpt_module_get_pattern_row_channel_command@Base 0.2.7025~beta20.1 +- openmpt_module_get_position_seconds@Base 0.2.7025~beta20.1 +- openmpt_module_get_render_param@Base 0.2.7025~beta20.1 +- openmpt_module_get_repeat_count@Base 0.2.7025~beta20.1 +- openmpt_module_get_sample_name@Base 0.2.7025~beta20.1 +- openmpt_module_get_selected_subsong@Base 0.3.0 +- openmpt_module_get_subsong_name@Base 0.2.7025~beta20.1 +- openmpt_module_highlight_pattern_row_channel@Base 0.2.7025~beta20.1 +- openmpt_module_highlight_pattern_row_channel_command@Base 0.2.7025~beta20.1 +- openmpt_module_read_float_mono@Base 0.2.7025~beta20.1 +- openmpt_module_read_float_quad@Base 0.2.7025~beta20.1 +- openmpt_module_read_float_stereo@Base 0.2.7025~beta20.1 +- openmpt_module_read_interleaved_float_quad@Base 0.2.7025~beta20.1 +- openmpt_module_read_interleaved_float_stereo@Base 0.2.7025~beta20.1 +- openmpt_module_read_interleaved_quad@Base 0.2.7025~beta20.1 +- openmpt_module_read_interleaved_stereo@Base 0.2.7025~beta20.1 +- openmpt_module_read_mono@Base 0.2.7025~beta20.1 +- openmpt_module_read_quad@Base 0.2.7025~beta20.1 +- openmpt_module_read_stereo@Base 0.2.7025~beta20.1 +- openmpt_module_select_subsong@Base 0.2.7025~beta20.1 +- openmpt_module_set_error_func@Base 0.3.0 +- openmpt_module_set_log_func@Base 0.3.0 +- openmpt_module_set_position_order_row@Base 0.2.7025~beta20.1 +- openmpt_module_set_position_seconds@Base 0.2.7025~beta20.1 +- openmpt_module_set_render_param@Base 0.2.7025~beta20.1 +- openmpt_module_set_repeat_count@Base 0.2.7025~beta20.1 +- openmpt_probe_file_header@Base 0.3.0 +- openmpt_probe_file_header_from_stream@Base 0.3.0 +- openmpt_probe_file_header_get_recommended_size@Base 0.3.0 +- openmpt_probe_file_header_without_filesize@Base 0.3.0 +diff -uraN ../../orig/libopenmpt-0.4.0/debian/libopenmpt-modplug1.symbols ./debian/libopenmpt-modplug1.symbols +--- ../../orig/libopenmpt-0.4.0/debian/libopenmpt-modplug1.symbols 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/libopenmpt-modplug1.symbols 1969-12-31 19:00:00.000000000 -0500 +@@ -1,200 +0,0 @@ +-libopenmpt_modplug.so.1 libopenmpt-modplug1 #MINVER# +-* Build-Depends-Package: libopenmpt-modplug-dev +- LIBOPENMPT_MODPLUG1@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_ExportIT@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_ExportMOD@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_ExportS3M@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_ExportXM@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetCurrentOrder@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetCurrentPattern@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetCurrentRow@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetCurrentSpeed@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetCurrentTempo@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetLength@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetMasterVolume@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetMessage@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetModuleType@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetName@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetPattern@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetPlayingChannels@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_GetSettings@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_InitMixerCallback@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_InstrumentName@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_Load@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_NumChannels@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_NumInstruments@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_NumPatterns@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_NumSamples@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_Read@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_SampleName@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_Seek@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_SeekOrder@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_SetMasterVolume@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_SetSettings@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_Unload@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- ModPlug_UnloadMixerCallback@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile10FreeSampleEPv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10InitPlayerEb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10NoteChangeEjibb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10PackSampleERii@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10ProcessAGCEi@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10ProcessRowEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10ReadSampleEP14_MODINSTRUMENTjPKcj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10RetrigNoteEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile10gdwSysInfoE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile10gnCPUUsageE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile10gnChannelsE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile11DoFreqSlideEP11_MODCHANNELi@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile11FineVibratoEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile11FreePatternEPv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile11InitSysInfoEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile11LoopPatternEii@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile11PatternLoopEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile11VolumeSlideEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12FineVolumeUpEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12ITInstrToMPTEPKvP17_INSTRUMENTHEADERj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12IsSampleUsedEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12PanningSlideEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12PortamentoUpEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12ResetMidiCfgEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12SetMixConfigEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile12gnReverbTypeE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile12gpSndMixHookE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile13CanPackSampleEPcjjPh@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile13CheckCPUUsageEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile13DestroySampleEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile13ResetChannelsEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile13SetCurrentPosEj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile13SetWaveConfigEjjjb@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile13gdwMixingFreqE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile13gdwSoundSetupE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile13m_nXBassDepthE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile13m_nXBassRangeE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile14AllocateSampleEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14FineVolumeDownEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14GlobalFadeSongEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14GlobalVolSlideEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14LoadMixPluginsEPKvj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14PortamentoDownEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14ProcessEffectsEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14SaveMixPluginsEP8_IO_FILEb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14SetPatternNameEjPKc@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14TonePortamentoEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile14m_nReverbDelayE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile14m_nReverbDepthE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile15AllocatePatternEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile15ChannelVolSlideEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile15CreateStereoMixEi@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile15GetSongCommentsEPcjj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile15SetCurrentOrderEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile15SetMasterVolumeEjb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile15SetWaveConfigExEbbbbbbb@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile15gnBitsPerSampleE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile15m_nStreamVolumeE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile16AdjustSampleLoopEP14_MODINSTRUMENT@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile16FinePortamentoUpEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile16InstrumentChangeEP11_MODCHANNELjbbb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile16IsInstrumentUsedEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile16ProcessMidiMacroEjPKcj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile16m_nProLogicDelayE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile16m_nProLogicDepthE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile17DestroyInstrumentEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile17MapMidiInstrumentEjjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile17SetResamplingModeEj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile17m_nMaxMixChannelsE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile18FinePortamentoDownEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile18GetRawSongCommentsEPcjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile18ReadSampleFromSongEjPS_j@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile18SetXBassParametersEjj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile19DetectUnusedSamplesEPb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile19ExtendedMODCommandsEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile19ExtendedS3MCommandsEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile19SetReverbParametersEjj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile19gnVolumeRampSamplesE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile19m_nStereoSeparationE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile20FrequencyToTransposeEP14_MODINSTRUMENT@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile20FrequencyToTransposeEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile20Normalize24BitBufferEPhjjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile20TransposeToFrequencyEii@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile21ExtendedChannelEffectEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile21ExtraFinePortamentoUpEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile21RemoveSelectedSamplesEPb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile21SetSurroundParametersEjj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile21gpMixPluginCreateProcE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile22ReadInstrumentFromSongEjPS_j@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile23ExtraFinePortamentoDownEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile23RemoveInstrumentSamplesEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile4ReadEPvj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile5gnAGCE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile6CreateEPKhj@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile6KeyOffEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile6ReadITEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile6ReadXMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile6SetAGCEb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7DestroyEv@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile7NoteCutEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7Read669EPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadABCEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadAMFEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadAMSEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadDBMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadDMFEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadDSMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadFAREPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadJ2BEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadMDLEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadMIDEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadMT2EPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadMTMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadMedEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadModEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadOKTEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadPATEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadPSMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadPTMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadS3MEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadSTMEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadUMXEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadUltEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7ReadWavEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7TestABCEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7TestMIDEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7TestPATEPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7TremoloEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile7VibratoEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8CheckNNAEjjib@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8FadeSongEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8ReadAMS2EPKhj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8ReadNoteEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8ResetAGCEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8SetSpeedEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile8SetTempoEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile9GetLengthEbb@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFile9PanbrelloEP11_MODCHANNELj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZN10CSoundFile9gnVUMeterE@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFileC1Ev@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFileC2Ev@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFileD1Ev@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZN10CSoundFileD2Ev@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZNK10CSoundFile10S3MConvertEP11_MODCOMMANDb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile13GetCurrentPosEv@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZNK10CSoundFile13GetNNAChannelEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile13GetSampleNameEjPc@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14GetMaxPositionEv@LIBOPENMPT_MODPLUG1 0.2.7386~beta20.3 +- _ZNK10CSoundFile14GetNumChannelsEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14GetNumPatternsEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14GetPatternNameEjPcj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14GetSaveFormatsEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14IsSongFinishedEjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14ModSaveCommandEPK11_MODCOMMANDb@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile14S3MSaveConvertEPjS0_b@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17ConvertModCommandEP11_MODCOMMAND@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17CutOffToFrequencyEji@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17GetBestSaveFormatEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17GetFreqFromPeriodEjji@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17GetInstrumentNameEjPc@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17GetNoteFromPeriodEj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17GetNumInstrumentsEv@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile17GetPeriodFromNoteEjij@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile18SetupChannelFilterEP11_MODCHANNELbi@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +- _ZNK10CSoundFile19IsValidBackwardJumpEjjjj@LIBOPENMPT_MODPLUG1 0.2.7561~beta20.5 +diff -uraN ../../orig/libopenmpt-0.4.0/debian/rules ./debian/rules +--- ../../orig/libopenmpt-0.4.0/debian/rules 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/rules 2019-01-04 17:03:16.206691071 -0500 +@@ -11,9 +11,10 @@ + dh $@ + + override_dh_autoreconf: +- dh_autoreconf --as-needed ++ autoreconf --force --install + + override_dh_auto_configure: ++ debian/rules override_dh_autoreconf + dh_auto_configure -- --disable-static --enable-libopenmpt_modplug + + override_dh_auto_build: diff --git a/libs/libopenmpt/debian/libopenmpt-0.4.0-xenial-backport.diff b/libs/libopenmpt/debian/libopenmpt-0.4.0-xenial-backport.diff new file mode 100644 index 000000000..9cb88b748 --- /dev/null +++ b/libs/libopenmpt/debian/libopenmpt-0.4.0-xenial-backport.diff @@ -0,0 +1,40 @@ +diff -uraN ../../orig/libopenmpt-0.4.0/debian/changelog ./debian/changelog +--- ../../orig/libopenmpt-0.4.0/debian/changelog 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/changelog 2019-01-04 16:37:08.788775423 -0500 +@@ -1,3 +1,12 @@ ++libopenmpt (0.4.0-ubuntu16.04.1~ppa10) xenial; urgency=medium ++ ++ * Backport to Xenial ++ * automake build depend added ++ * debhelper depend adjusted to >= 9.0~ ++ * deb compat level adjusted to 10 ++ ++ -- Sonic Team Junior Fri, 04 Jan 2019 16:35:08 -0500 ++ + libopenmpt (0.4.0-1) unstable; urgency=medium + + * New upstream release. +diff -uraN ../../orig/libopenmpt-0.4.0/debian/compat ./debian/compat +--- ../../orig/libopenmpt-0.4.0/debian/compat 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/compat 2019-01-04 16:34:31.830370437 -0500 +@@ -1 +1 @@ +-11 ++10 +diff -uraN ../../orig/libopenmpt-0.4.0/debian/control ./debian/control +--- ../../orig/libopenmpt-0.4.0/debian/control 2018-12-24 16:43:58.000000000 -0500 ++++ ./debian/control 2019-01-04 16:34:59.339499384 -0500 +@@ -4,7 +4,8 @@ + Maintainer: Debian Multimedia Maintainers + Uploaders: James Cowgill + Build-Depends: +- debhelper (>= 11.1~), ++ automake, ++ debhelper (>= 9.0~), + dh-exec, + doxygen, + dpkg-dev (>= 1.18.0), +diff -uraN ../../orig/libopenmpt-0.4.0/debian/files ./debian/files +--- ../../orig/libopenmpt-0.4.0/debian/files 1969-12-31 19:00:00.000000000 -0500 ++++ ./debian/files 2019-01-04 16:37:20.001229883 -0500 +@@ -0,0 +1 @@ ++libopenmpt_0.4.0-ubuntu16.04.1~ppa10_source.buildinfo libs optional diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt.h new file mode 100644 index 000000000..d41324885 --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt.h @@ -0,0 +1,1449 @@ +/* + * libopenmpt.h + * ------------ + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_H +#define LIBOPENMPT_H + +#include "libopenmpt_config.h" +#include +#include + +/*! + * \page libopenmpt_c_overview C API + * + * \section libopenmpt_c_error Error Handling + * + * - Functions with no return value in the corresponding C++ API return 0 on + * failure and 1 on success. + * - Functions that return a string in the corresponding C++ API return a + * dynamically allocated const char *. In case of failure or memory allocation + * failure, a NULL pointer is returned. + * - Functions that return integer values signal error condition by returning + * an invalid value (-1 in most cases, 0 in some cases). + * - All functions that work on an \ref openmpt_module object will call an + * \ref openmpt_error_func and depending on the value returned by this function + * log the error code and/xor/or store it inside the openmpt_module object. + * Stored error codes can be accessed with the openmpt_module_error_get_last() + * and openmpt_module_error_get_last_message(). Stored errors will not get + * cleared automatically and should be reset with openmpt_module_error_clear(). + * - Some functions not directly related to an \ref openmpt_module object take + * an explicit \ref openmpt_error_func error function callback and a pointer to + * an int and behave analog to the functions working on an \ref openmpt_module + * object. + * + * \section libopenmpt_c_strings Strings + * + * - All strings returned from libopenmpt are encoded in UTF-8. + * - All strings passed to libopenmpt should also be encoded in UTF-8. + * Behaviour in case of invalid UTF-8 is unspecified. + * - libopenmpt does not enforce or expect any particular Unicode + * normalization form. + * - All strings returned from libopenmpt are dynamically allocated and must + * be freed with openmpt_free_string(). Do NOT use the C standard library + * free() for libopenmpt strings as that would make your code invalid on + * windows when dynamically linking against libopenmpt which itself statically + * links to the C runtime. + * - All strings passed to libopenmpt are copied. No ownership is assumed or + * transferred. + * + * \section libopenmpt_c_fileio File I/O + * + * libopenmpt can use 3 different strategies for file I/O. + * + * - openmpt_module_create_from_memory2() will load the module from the provided + * memory buffer, which will require loading all data upfront by the library + * caller. + * - openmpt_module_create2() with a seekable stream will load the module via + * callbacks to the stream interface. libopenmpt will not implement an + * additional buffering layer in this case which means the callbacks are assumed + * to be performant even with small i/o sizes. + * - openmpt_module_create2() with an unseekable stream will load the module via + * callbacks to the stream interface. libopempt will make an internal copy as + * it goes along, and sometimes have to pre-cache the whole file in case it + * needs to know the complete file size. This strategy is intended to be used + * if the file is located on a high latency network. + * + * | create function | speed | memory consumption | + * | ----------------------------------------------: | :----: | :----------------: | + * | openmpt_module_create_from_memory2() |

fast

|

medium

| + * | openmpt_module_create2() with seekable stream |

slow

|

low

| + * | openmpt_module_create2() with unseekable stream |

medium

|

high

| + * + * In all cases, the data or stream passed to the create function is no longer + * needed after the openmpt_module has been created and can be freed by the + * caller. + * + * \section libopenmpt_c_outputformat Output Format + * + * libopenmpt supports a wide range of PCM output formats: + * [8000..192000]/[mono|stereo|quad]/[f32|i16]. + * + * Unless you have some very specific requirements demanding a particular aspect + * of the output format, you should always prefer 48000/stereo/f32 as the + * libopenmpt PCM format. + * + * - Please prefer 48000Hz unless the user explicitly demands something else. + * Practically all audio equipment and file formats use 48000Hz nowadays. + * - Practically all module formats are made for stereo output. Mono will not + * give you any measurable speed improvements and can trivially be obtained from + * the stereo output anyway. Quad is not expected by almost all modules and even + * if they do use surround effects, they expect the effects to be mixed to + * stereo. + * - Floating point output provides headroom instead of hard clipping if the + * module is louder than 0dBFs, will give you a better signal-to-noise ratio + * than int16 output, and avoid the need to apply an additional dithering to the + * output by libopenmpt. Unless your platform has no floating point unit at all, + * floating point will thus also be slightly faster. + * + * \section libopenmpt_c_threads libopenmpt in multi-threaded environments + * + * - libopenmpt is thread-aware. + * - Individual libopenmpt objects are not thread-safe. + * - libopenmpt itself does not spawn any user-visible threads but may spawn + * threads for internal use. + * - You must ensure to only ever access a particular libopenmpt object from a + * single thread at a time. + * - Consecutive accesses can happen from different threads. + * - Different objects can be accessed concurrently from different threads. + * + * \section libopenmpt_c_staticlinking Statically linking to libopenmpt + * + * libopenmpt is implemented in C++. This implies that linking to libopenmpt + * statically requires linking to the C++ runtime and standard library. The + * **highly preferred and recommended** way to do this is by using the C++ + * compiler instead of the platform linker to do the linking. This will do all + * necessary things that are C++ specific (in particular, it will pull in the + * appropriate runtime and/or library). If for whatever reason it is not + * possible to use the C++ compiler for statically linking against libopenmpt, + * the libopenmpt build system can list the required libraries in the pkg-config + * file `libopenmpt.pc`. However, there is no reliable way to determine the name + * of the required library or libraries from within the build system. The + * libopenmpt autotools `configure` and plain `Makefile` honor the custom + * variable `CXXSTDLIB_PCLIBSPRIVATE` which serves the sole purpose of listing + * the standard library (or libraries) required for static linking. The contents + * of this variable will be put in `libopenmpt.pc` `Libs.private` and used for + * nothing else. + * + * This problem is inherent to libraries implemented in C++ that can also be used + * without a C++ compiler. Other libraries try to solve that by listing + * `-lstdc++` unconditionally in `Libs.private`. However, that will break + * platforms that use a different C++ standard library (in particular FreeBSD). + * + * See https://lists.freedesktop.org/archives/pkg-config/2016-August/001055.html . + * + * Dymically linking to libopenmpt does not require anything special and will + * work as usual (and exactly as done for libraries implemented in C). + * + * Note: This section does not apply when using Microsoft Visual Studio or + * Andriod NDK ndk-build build systems. + * + * \section libopenmpt_c_detailed Detailed documentation + * + * \ref libopenmpt_c + * + * In case a function is not documented here, you might want to look at the + * \ref libopenmpt_cpp documentation. The C and C++ APIs are kept semantically + * as close as possible. + * + * \section libopenmpt_c_examples Examples + * + * \subsection libopenmpt_c_example_unsafe Unsafe, simplified example without any error checking to get a first idea of the API + * \include libopenmpt_example_c_unsafe.c + * \subsection libopenmpt_c_example_file FILE* + * \include libopenmpt_example_c.c + * \subsection libopenmpt_c_example_inmemory in memory + * \include libopenmpt_example_c_mem.c + * \subsection libopenmpt_c_example_stdout reading FILE* and writing PCM data to STDOUT (usable without PortAudio) + * \include libopenmpt_example_c_stdout.c + * + */ + +/*! \defgroup libopenmpt_c libopenmpt C */ + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*! \brief Get the libopenmpt version number + * + * Returns the libopenmpt version number. + * \return The value represents (major << 24 + minor << 16 + patch << 0). + * \remarks libopenmpt < 0.3.0-pre used the following scheme: (major << 24 + minor << 16 + revision). + */ +LIBOPENMPT_API uint32_t openmpt_get_library_version(void); + +/*! \brief Get the core version number + * + * Return the OpenMPT core version number. + * \return The value represents (majormajor << 24 + major << 16 + minor << 8 + minorminor). + */ +LIBOPENMPT_API uint32_t openmpt_get_core_version(void); + +/*! Return a verbose library version string from openmpt_get_string(). \deprecated Please use `"library_version"` directly. */ +#define OPENMPT_STRING_LIBRARY_VERSION LIBOPENMPT_DEPRECATED_STRING( "library_version" ) +/*! Return a verbose library features string from openmpt_get_string(). \deprecated Please use `"library_features"` directly. */ +#define OPENMPT_STRING_LIBRARY_FEATURES LIBOPENMPT_DEPRECATED_STRING( "library_features" ) +/*! Return a verbose OpenMPT core version string from openmpt_get_string(). \deprecated Please use `"core_version"` directly. */ +#define OPENMPT_STRING_CORE_VERSION LIBOPENMPT_DEPRECATED_STRING( "core_version" ) +/*! Return information about the current build (e.g. the build date or compiler used) from openmpt_get_string(). \deprecated Please use `"build"` directly. */ +#define OPENMPT_STRING_BUILD LIBOPENMPT_DEPRECATED_STRING( "build" ) +/*! Return all contributors from openmpt_get_string(). \deprecated Please use `"credits"` directly. */ +#define OPENMPT_STRING_CREDITS LIBOPENMPT_DEPRECATED_STRING( "credits" ) +/*! Return contact information about libopenmpt from openmpt_get_string(). \deprecated Please use `"contact"` directly. */ +#define OPENMPT_STRING_CONTACT LIBOPENMPT_DEPRECATED_STRING( "contact" ) +/*! Return the libopenmpt license from openmpt_get_string(). \deprecated Please use `"license"` directly. */ +#define OPENMPT_STRING_LICENSE LIBOPENMPT_DEPRECATED_STRING( "license" ) + +/*! \brief Free a string returned by libopenmpt + * + * Frees any string that got returned by libopenmpt. + */ +LIBOPENMPT_API void openmpt_free_string( const char * str ); + +/*! \brief Get library related metadata. + * + * \param key Key to query. + * Possible keys are: + * - "library_version": verbose library version string + * - "library_version_is_release": "1" if the version is an officially released version + * - "library_features": verbose library features string + * - "core_version": verbose OpenMPT core version string + * - "source_url": original source code URL + * - "source_date": original source code date + * - "source_revision": original source code revision + * - "source_is_modified": "1" if the original source has been modified + * - "source_has_mixed_revisions": "1" if the original source has been compiled from different various revision + * - "source_is_package": "1" if the original source has been obtained from a source pacakge instead of source code version control + * - "build": information about the current build (e.g. the build date or compiler used) + * - "build_compiler": information about the compiler used to build libopenmpt + * - "credits": all contributors + * - "contact": contact information about libopenmpt + * - "license": the libopenmpt license + * - "url": libopenmpt website URL + * - "support_forum_url": libopenmpt support and discussions forum URL + * - "bugtracker_url": libopenmpt bug and issue tracker URL + * \return A (possibly multi-line) string containing the queried information. If no information is available, the string is empty. + */ +LIBOPENMPT_API const char * openmpt_get_string( const char * key ); + +/*! \brief Get a list of supported file extensions + * + * \return The semicolon-separated list of extensions supported by this libopenmpt build. The extensions are returned lower-case without a leading dot. + */ +LIBOPENMPT_API const char * openmpt_get_supported_extensions(void); + +/*! \brief Query whether a file extension is supported + * + * \param extension file extension to query without a leading dot. The case is ignored. + * \return 1 if the extension is supported by libopenmpt, 0 otherwise. + */ +LIBOPENMPT_API int openmpt_is_extension_supported( const char * extension ); + +/*! Seek to the given offset relative to the beginning of the file. */ +#define OPENMPT_STREAM_SEEK_SET 0 +/*! Seek to the given offset relative to the current position in the file. */ +#define OPENMPT_STREAM_SEEK_CUR 1 +/*! Seek to the given offset relative to the end of the file. */ +#define OPENMPT_STREAM_SEEK_END 2 + +/*! \brief Read bytes from stream + * + * Read bytes data from stream to dst. + * \param stream Stream to read data from + * \param dst Target where to copy data. + * \param bytes Number of bytes to read. + * \return Number of bytes actually read and written to dst. + * \retval 0 End of stream or error. + * \remarks Short reads are allowed as long as they return at least 1 byte if EOF is not reached. + */ +typedef size_t (*openmpt_stream_read_func)( void * stream, void * dst, size_t bytes ); + +/*! \brief Seek stream position + * + * Seek to stream position offset at whence. + * \param stream Stream to operate on. + * \param offset Offset to seek to. + * \param whence OPENMPT_STREAM_SEEK_SET, OPENMPT_STREAM_SEEK_CUR, OPENMPT_STREAM_SEEK_END. See C89 documentation. + * \return Returns 0 on success. + * \retval 0 Success. + * \retval -1 Failure. Position does not get updated. + * \remarks libopenmpt will not try to seek beyond the file size, thus it is not important whether you allow for virtual positioning after the file end, or return an error in that case. The position equal to the file size needs to be seekable to. + */ +typedef int (*openmpt_stream_seek_func)( void * stream, int64_t offset, int whence ); + +/*! \brief Tell stream position + * + * Tell position of stream. + * \param stream Stream to operate on. + * \return Current position in stream. + * \retval -1 Failure. + */ +typedef int64_t (*openmpt_stream_tell_func)( void * stream ); + +/*! \brief Stream callbacks + * + * Stream callbacks used by libopenmpt for stream operations. + * \sa openmpt_stream_get_file_callbacks + * \sa openmpt_stream_get_fd_callbacks + * \sa openmpt_stream_get_buffer_callbacks + */ +typedef struct openmpt_stream_callbacks { + + /*! \brief Read callback. + * + * \sa openmpt_stream_read_func + */ + openmpt_stream_read_func read; + + /*! \brief Seek callback. + * + * Seek callback can be NULL if seeking is not supported. + * \sa openmpt_stream_seek_func + */ + openmpt_stream_seek_func seek; + + /*! \brief Tell callback. + * + * Tell callback can be NULL if seeking is not supported. + * \sa openmpt_stream_tell_func + */ + openmpt_stream_tell_func tell; + +} openmpt_stream_callbacks; + +/*! \brief Logging function + * + * \param message UTF-8 encoded log message. + * \param user User context that was passed to openmpt_module_create2(), openmpt_module_create_from_memory2() or openmpt_could_open_probability2(). + */ +typedef void (*openmpt_log_func)( const char * message, void * user ); + +/*! \brief Default logging function + * + * Default logging function that logs anything to stderr. + */ +LIBOPENMPT_API void openmpt_log_func_default( const char * message, void * user ); + +/*! \brief Silent logging function + * + * Silent logging function that throws any log message away. + */ +LIBOPENMPT_API void openmpt_log_func_silent( const char * message, void * user ); + +/*! No error. \since 0.3.0 */ +#define OPENMPT_ERROR_OK 0 + +/*! Lowest value libopenmpt will use for any of its own error codes. \since 0.3.0 */ +#define OPENMPT_ERROR_BASE 256 + +/*! Unknown internal error. \since 0.3.0 */ +#define OPENMPT_ERROR_UNKNOWN ( OPENMPT_ERROR_BASE + 1 ) + +/*! Unknown internal C++ exception. \since 0.3.0 */ +#define OPENMPT_ERROR_EXCEPTION ( OPENMPT_ERROR_BASE + 11 ) + +/*! Out of memory. \since 0.3.0 */ +#define OPENMPT_ERROR_OUT_OF_MEMORY ( OPENMPT_ERROR_BASE + 21 ) + +/*! Runtime error. \since 0.3.0 */ +#define OPENMPT_ERROR_RUNTIME ( OPENMPT_ERROR_BASE + 30 ) +/*! Range error. \since 0.3.0 */ +#define OPENMPT_ERROR_RANGE ( OPENMPT_ERROR_BASE + 31 ) +/*! Arithmetic overflow. \since 0.3.0 */ +#define OPENMPT_ERROR_OVERFLOW ( OPENMPT_ERROR_BASE + 32 ) +/*! Arithmetic underflow. \since 0.3.0 */ +#define OPENMPT_ERROR_UNDERFLOW ( OPENMPT_ERROR_BASE + 33 ) + +/*! Logic error. \since 0.3.0 */ +#define OPENMPT_ERROR_LOGIC ( OPENMPT_ERROR_BASE + 40 ) +/*! Value domain error. \since 0.3.0 */ +#define OPENMPT_ERROR_DOMAIN ( OPENMPT_ERROR_BASE + 41 ) +/*! Maximum supported size exceeded. \since 0.3.0 */ +#define OPENMPT_ERROR_LENGTH ( OPENMPT_ERROR_BASE + 42 ) +/*! Argument out of range. \since 0.3.0 */ +#define OPENMPT_ERROR_OUT_OF_RANGE ( OPENMPT_ERROR_BASE + 43 ) +/*! Invalid argument. \since 0.3.0 */ +#define OPENMPT_ERROR_INVALID_ARGUMENT ( OPENMPT_ERROR_BASE + 44 ) + +/*! General libopenmpt error. \since 0.3.0 */ +#define OPENMPT_ERROR_GENERAL ( OPENMPT_ERROR_BASE + 101 ) +/*! openmpt_module * is invalid. \since 0.3.0 */ +#define OPENMPT_ERROR_INVALID_MODULE_POINTER ( OPENMPT_ERROR_BASE + 102 ) +/*! NULL pointer argument. \since 0.3.0 */ +#define OPENMPT_ERROR_ARGUMENT_NULL_POINTER ( OPENMPT_ERROR_BASE + 103 ) + +/*! \brief Check whether the error is transient + * + * Checks whether an error code represents a transient error which may not occur again in a later try if for example memory has been freed up after an out-of-memory error. + * \param error Error code. + * \retval 0 Error is not transient. + * \retval 1 Error is transient. + * \sa OPENMPT_ERROR_OUT_OF_MEMORY + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_error_is_transient( int error ); + +/*! \brief Convert error code to text + * + * Converts an error code into a text string describing the error. + * \param error Error code. + * \return Allocated string describing the error. + * \retval NULL Not enough memory to allocate the string. + * \since 0.3.0 + */ +LIBOPENMPT_API const char * openmpt_error_string( int error ); + +/*! Do not log or store the error. \since 0.3.0 */ +#define OPENMPT_ERROR_FUNC_RESULT_NONE 0 +/*! Log the error. \since 0.3.0 */ +#define OPENMPT_ERROR_FUNC_RESULT_LOG ( 1 << 0 ) +/*! Store the error. \since 0.3.0 */ +#define OPENMPT_ERROR_FUNC_RESULT_STORE ( 1 << 1 ) +/*! Log and store the error. \since 0.3.0 */ +#define OPENMPT_ERROR_FUNC_RESULT_DEFAULT ( OPENMPT_ERROR_FUNC_RESULT_LOG | OPENMPT_ERROR_FUNC_RESULT_STORE ) + +/*! \brief Error function + * + * \param error Error code. + * \param user User context that was passed to openmpt_module_create2(), openmpt_module_create_from_memory2() or openmpt_could_open_probability2(). + * \return Mask of OPENMPT_ERROR_FUNC_RESULT_LOG and OPENMPT_ERROR_FUNC_RESULT_STORE. + * \retval OPENMPT_ERROR_FUNC_RESULT_NONE Do not log or store the error. + * \retval OPENMPT_ERROR_FUNC_RESULT_LOG Log the error. + * \retval OPENMPT_ERROR_FUNC_RESULT_STORE Store the error. + * \retval OPENMPT_ERROR_FUNC_RESULT_DEFAULT Log and store the error. + * \sa OPENMPT_ERROR_FUNC_RESULT_NONE + * \sa OPENMPT_ERROR_FUNC_RESULT_LOG + * \sa OPENMPT_ERROR_FUNC_RESULT_STORE + * \sa OPENMPT_ERROR_FUNC_RESULT_DEFAULT + * \sa openmpt_error_func_default + * \sa openmpt_error_func_log + * \sa openmpt_error_func_store + * \sa openmpt_error_func_ignore + * \sa openmpt_error_func_errno + * \since 0.3.0 + */ +typedef int (*openmpt_error_func)( int error, void * user ); + +/*! \brief Default error function + * + * Causes all errors to be logged and stored. + * \param error Error code. + * \param user Ignored. + * \retval OPENMPT_ERROR_FUNC_RESULT_DEFAULT Always. + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_error_func_default( int error, void * user ); + +/*! \brief Log error function + * + * Causes all errors to be logged. + * \param error Error code. + * \param user Ignored. + * \retval OPENMPT_ERROR_FUNC_RESULT_LOG Always. + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_error_func_log( int error, void * user ); + +/*! \brief Store error function + * + * Causes all errors to be stored. + * \param error Error code. + * \param user Ignored. + * \retval OPENMPT_ERROR_FUNC_RESULT_STORE Always. + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_error_func_store( int error, void * user ); + +/*! \brief Ignore error function + * + * Causes all errors to be neither logged nor stored. + * \param error Error code. + * \param user Ignored. + * \retval OPENMPT_ERROR_FUNC_RESULT_NONE Always. + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_error_func_ignore( int error, void * user ); + +/*! \brief Errno error function + * + * Causes all errors to be stored in the pointer passed in as user. + * \param error Error code. + * \param user Pointer to an int as generated by openmpt_error_func_errno_userdata. + * \retval OPENMPT_ERROR_FUNC_RESULT_NONE user is not NULL. + * \retval OPENMPT_ERROR_FUNC_RESULT_DEFAULT user is NULL. + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_error_func_errno( int error, void * user ); + +/*! \brief User pointer for openmpt_error_func_errno + * + * Provides a suitable user pointer argument for openmpt_error_func_errno. + * \param error Pointer to an integer value to be used as output by openmpt_error_func_errno. + * \retval (void*)error. + * \since 0.3.0 + */ +LIBOPENMPT_API void * openmpt_error_func_errno_userdata( int * error ); + +/*! \brief Roughly scan the input stream to find out whether libopenmpt might be able to open it + * + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to scan. + * \param effort Effort to make when validating stream. Effort 0.0 does not even look at stream at all and effort 1.0 completely loads the file from stream. A lower effort requires less data to be loaded but only gives a rough estimate answer. Use an effort of 0.25 to only verify the header data of the module file. + * \param logfunc Logging function where warning and errors are written. May be NULL. + * \param user Logging function user context. Used to pass any user-defined data associated with this module to the logging function. + * \return Probability between 0.0 and 1.0. + * \remarks openmpt_could_open_probability() can return any value between 0.0 and 1.0. Only 0.0 and 1.0 are definitive answers, all values in between are just estimates. In general, any return value >0.0 means that you should try loading the file, and any value below 1.0 means that loading may fail. If you want a threshold above which you can be reasonably sure that libopenmpt will be able to load the file, use >=0.5. If you see the need for a threshold below which you could reasonably outright reject a file, use <0.25 (Note: Such a threshold for rejecting on the lower end is not recommended, but may be required for better integration into some other framework's probe scoring.). + * \remarks openmpt_could_open_probability() expects the complete file data to be eventually available to it, even if it is asked to just parse the header. Verification will be unreliable (both false positives and false negatives), if you pretend that the file is just some few bytes of initial data threshold in size. In order to really just access the first bytes of a file, check in your callback functions whether data or seeking is requested beyond your initial data threshold, and in that case, return an error. openmpt_could_open_probability() will treat this as any other I/O error and return 0.0. You must not expect the correct result in this case. You instead must remember that it asked for more data than you currently want to provide to it and treat this situation as if openmpt_could_open_probability() returned 0.5. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \deprecated Please use openmpt_could_open_probability2(). + * \since 0.3.0 + */ +LIBOPENMPT_API LIBOPENMPT_DEPRECATED double openmpt_could_open_probability( openmpt_stream_callbacks stream_callbacks, void * stream, double effort, openmpt_log_func logfunc, void * user ); + +/*! \brief Roughly scan the input stream to find out whether libopenmpt might be able to open it + * + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to scan. + * \param effort Effort to make when validating stream. Effort 0.0 does not even look at stream at all and effort 1.0 completely loads the file from stream. A lower effort requires less data to be loaded but only gives a rough estimate answer. Use an effort of 0.25 to only verify the header data of the module file. + * \param logfunc Logging function where warning and errors are written. May be NULL. + * \param user Logging function user context. Used to pass any user-defined data associated with this module to the logging function. + * \return Probability between 0.0 and 1.0. + * \remarks openmpt_could_open_probability() can return any value between 0.0 and 1.0. Only 0.0 and 1.0 are definitive answers, all values in between are just estimates. In general, any return value >0.0 means that you should try loading the file, and any value below 1.0 means that loading may fail. If you want a threshold above which you can be reasonably sure that libopenmpt will be able to load the file, use >=0.5. If you see the need for a threshold below which you could reasonably outright reject a file, use <0.25 (Note: Such a threshold for rejecting on the lower end is not recommended, but may be required for better integration into some other framework's probe scoring.). + * \remarks openmpt_could_open_probability() expects the complete file data to be eventually available to it, even if it is asked to just parse the header. Verification will be unreliable (both false positives and false negatives), if you pretend that the file is just some few bytes of initial data threshold in size. In order to really just access the first bytes of a file, check in your callback functions whether data or seeking is requested beyond your initial data threshold, and in that case, return an error. openmpt_could_open_probability() will treat this as any other I/O error and return 0.0. You must not expect the correct result in this case. You instead must remember that it asked for more data than you currently want to provide to it and treat this situation as if openmpt_could_open_probability() returned 0.5. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \deprecated Please use openmpt_could_open_probability2(). + */ +LIBOPENMPT_API LIBOPENMPT_DEPRECATED double openmpt_could_open_propability( openmpt_stream_callbacks stream_callbacks, void * stream, double effort, openmpt_log_func logfunc, void * user ); + +/*! \brief Roughly scan the input stream to find out whether libopenmpt might be able to open it + * + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to scan. + * \param effort Effort to make when validating stream. Effort 0.0 does not even look at stream at all and effort 1.0 completely loads the file from stream. A lower effort requires less data to be loaded but only gives a rough estimate answer. Use an effort of 0.25 to only verify the header data of the module file. + * \param logfunc Logging function where warning and errors are written. May be NULL. + * \param loguser Logging function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \return Probability between 0.0 and 1.0. + * \remarks openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize() provide a simpler and faster interface that fits almost all use cases better. It is recommended to use openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize() instead of openmpt_could_open_probability(). + * \remarks openmpt_could_open_probability2() can return any value between 0.0 and 1.0. Only 0.0 and 1.0 are definitive answers, all values in between are just estimates. In general, any return value >0.0 means that you should try loading the file, and any value below 1.0 means that loading may fail. If you want a threshold above which you can be reasonably sure that libopenmpt will be able to load the file, use >=0.5. If you see the need for a threshold below which you could reasonably outright reject a file, use <0.25 (Note: Such a threshold for rejecting on the lower end is not recommended, but may be required for better integration into some other framework's probe scoring.). + * \remarks openmpt_could_open_probability2() expects the complete file data to be eventually available to it, even if it is asked to just parse the header. Verification will be unreliable (both false positives and false negatives), if you pretend that the file is just some few bytes of initial data threshold in size. In order to really just access the first bytes of a file, check in your callback functions whether data or seeking is requested beyond your initial data threshold, and in that case, return an error. openmpt_could_open_probability2() will treat this as any other I/O error and return 0.0. You must not expect the correct result in this case. You instead must remember that it asked for more data than you currently want to provide to it and treat this situation as if openmpt_could_open_probability2() returned 0.5. \include libopenmpt_example_c_probe.c + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_probe_file_header + * \sa openmpt_probe_file_header_without_filesize + * \since 0.3.0 + */ +LIBOPENMPT_API double openmpt_could_open_probability2( openmpt_stream_callbacks stream_callbacks, void * stream, double effort, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message ); + +/*! \brief Get recommended header size for successfull format probing + * + * \sa openmpt_probe_file_header() + * \sa openmpt_probe_file_header_without_filesize() + * \since 0.3.0 + */ +LIBOPENMPT_API size_t openmpt_probe_file_header_get_recommended_size(void); + +/*! Probe for module formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES 0x1ul +/*! Probe for module-specific container formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS 0x2ul + +/*! Probe for the default set of formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT ( OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES | OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS ) +/*! Probe for no formats in openmpt_probe_file_header() or openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_FLAGS_NONE 0x0ul + +/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS 1 +/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE 0 +/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA (-1) +/*! Possible return values fo openmpt_probe_file_header() and openmpt_probe_file_header_without_filesize(). \since 0.3.0 */ +#define OPENMPT_PROBE_FILE_HEADER_RESULT_ERROR (-255) + +/*! \brief Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it + * + * \param flags Ored mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. + * \param data Beginning of the file data. + * \param size Size of the beginning of the file data. + * \param filesize Full size of the file data on disk. + * \param logfunc Logging function where warning and errors are written. May be NULL. + * \param loguser Logging function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \remarks It is recommended to provide openmpt_probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size and filesize to the file's size. + * \remarks openmpt_could_open_probability2() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt_probe_file_header() though, if possible. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS The file will most likely be supported by libopenmpt. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE The file is not supported by libopenmpt. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA An answer could not be determined with the amount of data provided. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_ERROR An internal error occurred. + * \sa openmpt_probe_file_header_get_recommended_size() + * \sa openmpt_probe_file_header_without_filesize() + * \sa openmpt_probe_file_header_from_stream() + * \sa openmpt_could_open_probability2() + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_probe_file_header( uint64_t flags, const void * data, size_t size, uint64_t filesize, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message ); +/*! \brief Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it + * + * \param flags Ored mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. + * \param data Beginning of the file data. + * \param size Size of the beginning of the file data. + * \param logfunc Logging function where warning and errors are written. May be NULL. + * \param loguser Logging function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \remarks It is recommended to use openmpt_probe_file_header() and provide the acutal file's size as a parameter if at all possible. libopenmpt can provide more accurate answers if the filesize is known. + * \remarks It is recommended to provide openmpt_probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size to the file's size. + * \remarks openmpt_could_open_probability2() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt_probe_file_header() though, if possible. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS The file will most likely be supported by libopenmpt. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE The file is not supported by libopenmpt. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA An answer could not be determined with the amount of data provided. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_ERROR An internal error occurred. + * \sa openmpt_probe_file_header_get_recommended_size() + * \sa openmpt_probe_file_header() + * \sa openmpt_probe_file_header_from_stream() + * \sa openmpt_could_open_probability2() + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_probe_file_header_without_filesize( uint64_t flags, const void * data, size_t size, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message ); + +/*! \brief Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it + * + * \param flags Ored mask of OPENMPT_PROBE_FILE_HEADER_FLAGS_MODULES and OPENMPT_PROBE_FILE_HEADER_FLAGS_CONTAINERS, or OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT. + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to scan. + * \param logfunc Logging function where warning and errors are written. May be NULL. + * \param loguser Logging function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \remarks The stream is left in an unspecified state when this function returns. + * \remarks It is recommended to provide openmpt_probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size and filesize to the file's size. + * \remarks openmpt_could_open_probability2() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt_probe_file_header() though, if possible. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS The file will most likely be supported by libopenmpt. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_FAILURE The file is not supported by libopenmpt. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_WANTMOREDATA An answer could not be determined with the amount of data provided. + * \retval OPENMPT_PROBE_FILE_HEADER_RESULT_ERROR An internal error occurred. + * \sa openmpt_probe_file_header_get_recommended_size() + * \sa openmpt_probe_file_header() + * \sa openmpt_probe_file_header_without_filesize() + * \sa openmpt_could_open_probability2() + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_probe_file_header_from_stream( uint64_t flags, openmpt_stream_callbacks stream_callbacks, void * stream, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message ); + + +/*! \brief Opaque type representing a libopenmpt module + */ +typedef struct openmpt_module openmpt_module; + +typedef struct openmpt_module_initial_ctl { + const char * ctl; + const char * value; +} openmpt_module_initial_ctl; + +/*! \brief Construct an openmpt_module + * + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to load the module from. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. May be NULL. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \return A pointer to the constructed openmpt_module, or NULL on failure. + * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. + * \sa openmpt_stream_callbacks + * \sa \ref libopenmpt_c_fileio + * \deprecated Please use openmpt_module_create2(). + */ +LIBOPENMPT_API LIBOPENMPT_DEPRECATED openmpt_module * openmpt_module_create( openmpt_stream_callbacks stream_callbacks, void * stream, openmpt_log_func logfunc, void * loguser, const openmpt_module_initial_ctl * ctls ); + +/*! \brief Construct an openmpt_module + * + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to load the module from. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. May be NULL. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \return A pointer to the constructed openmpt_module, or NULL on failure. + * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. + * \sa openmpt_stream_callbacks + * \sa \ref libopenmpt_c_fileio + * \since 0.3.0 + */ +LIBOPENMPT_API openmpt_module * openmpt_module_create2( openmpt_stream_callbacks stream_callbacks, void * stream, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message, const openmpt_module_initial_ctl * ctls ); + +/*! \brief Construct an openmpt_module + * + * \param filedata Data to load the module from. + * \param filesize Amount of data available. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \return A pointer to the constructed openmpt_module, or NULL on failure. + * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. + * \sa \ref libopenmpt_c_fileio + * \deprecated Please use openmpt_module_create_from_memory2(). + */ +LIBOPENMPT_API LIBOPENMPT_DEPRECATED openmpt_module * openmpt_module_create_from_memory( const void * filedata, size_t filesize, openmpt_log_func logfunc, void * loguser, const openmpt_module_initial_ctl * ctls ); + +/*! \brief Construct an openmpt_module + * + * \param filedata Data to load the module from. + * \param filesize Amount of data available. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \param ctls A map of initial ctl values. See openmpt_module_get_ctls() + * \return A pointer to the constructed openmpt_module, or NULL on failure. + * \remarks The input data can be discarded after an openmpt_module has been constructed successfully. + * \sa \ref libopenmpt_c_fileio + * \since 0.3.0 + */ +LIBOPENMPT_API openmpt_module * openmpt_module_create_from_memory2( const void * filedata, size_t filesize, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message, const openmpt_module_initial_ctl * ctls ); + +/*! \brief Unload a previously created openmpt_module from memory. + * + * \param mod The module to unload. + */ +LIBOPENMPT_API void openmpt_module_destroy( openmpt_module * mod ); + +/*! \brief Set logging function. + * + * Set the logging function of an already constructed openmpt_module. + * \param mod The module handle to work on. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \since 0.3.0 + */ +LIBOPENMPT_API void openmpt_module_set_log_func( openmpt_module * mod, openmpt_log_func logfunc, void * loguser ); + +/*! \brief Set error function. + * + * Set the error function of an already constructed openmpt_module. + * \param mod The module handle to work on. + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. + * \since 0.3.0 + */ +LIBOPENMPT_API void openmpt_module_set_error_func( openmpt_module * mod, openmpt_error_func errfunc, void * erruser ); + +/*! \brief Get last error. + * + * Return the error currently stored in an openmpt_module. The stored error is not cleared. + * \param mod The module handle to work on. + * \return The error currently stored. + * \sa openmpt_module_error_get_last_message + * \sa openmpt_module_error_set_last + * \sa openmpt_module_error_clear + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_module_error_get_last( openmpt_module * mod ); + +/*! \brief Get last error message. + * + * Return the error message currently stored in an openmpt_module. The stored error is not cleared. + * \param mod The module handle to work on. + * \return The error message currently stored. + * \sa openmpt_module_error_set_last + * \sa openmpt_module_error_clear + * \since 0.3.0 + */ +LIBOPENMPT_API const char * openmpt_module_error_get_last_message( openmpt_module * mod ); + +/*! \brief Set last error. + * + * Set the error currently stored in an openmpt_module. + * \param mod The module handle to work on. + * \param error Error to be stored. + * \sa openmpt_module_error_get_last + * \sa openmpt_module_error_clear + * \since 0.3.0 + */ +LIBOPENMPT_API void openmpt_module_error_set_last( openmpt_module * mod, int error ); + +/*! \brief Clear last error. + * + * Set the error currently stored in an openmpt_module to OPPENMPT_ERROR_OK. + * \param mod The module handle to work on. + * \sa openmpt_module_error_get_last + * \sa openmpt_module_error_set_last + * \since 0.3.0 + */ +LIBOPENMPT_API void openmpt_module_error_clear( openmpt_module * mod ); + +/** + * \defgroup openmpt_module_render_param Render param indices + * + * \brief Parameter index to use with openmpt_module_get_render_param() and openmpt_module_set_render_param() + * @{ + */ +/*! \brief Master Gain + * + * The related value represents a relative gain in milliBel.\n + * The default value is 0.\n + * The supported value range is unlimited.\n + */ +#define OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL 1 +/*! \brief Stereo Separation + * + * The related value represents the stereo separation generated by the libopenmpt mixer in percent.\n + * The default value is 100.\n + * The supported value range is [0,200].\n + */ +#define OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT 2 +/*! \brief Interpolation Filter + * + * The related value represents the interpolation filter length used by the libopenmpt mixer.\n + * The default value is 0, which indicates a recommended default value.\n + * The supported value range is [0,inf). Values greater than the implementation limit are clamped to the maximum supported value.\n + * Currently supported values: + * - 0: internal default + * - 1: no interpolation (zero order hold) + * - 2: linear interpolation + * - 4: cubic interpolation + * - 8: windowed sinc with 8 taps + */ +#define OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH 3 +/*! \brief Volume Ramping Strength + * + * The related value represents the amount of volume ramping done by the libopenmpt mixer.\n + * The default value is -1, which indicates a recommended default value.\n + * The meaningful value range is [-1..10].\n + * A value of 0 completely disables volume ramping. This might cause clicks in sound output.\n + * Higher values imply slower/softer volume ramps. + */ +#define OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH 4 +/** @}*/ + +/** + * \defgroup openmpt_module_command_index Pattern cell indices + * + * \brief Parameter index to use with openmpt_module_get_pattern_row_channel_command(), openmpt_module_format_pattern_row_channel_command() and openmpt_module_highlight_pattern_row_channel_command() + * @{ + */ +#define OPENMPT_MODULE_COMMAND_NOTE 0 +#define OPENMPT_MODULE_COMMAND_INSTRUMENT 1 +#define OPENMPT_MODULE_COMMAND_VOLUMEEFFECT 2 +#define OPENMPT_MODULE_COMMAND_EFFECT 3 +#define OPENMPT_MODULE_COMMAND_VOLUME 4 +#define OPENMPT_MODULE_COMMAND_PARAMETER 5 +/** @}*/ + +/*! \brief Select a sub-song from a multi-song module + * + * \param mod The module handle to work on. + * \param subsong Index of the sub-song. -1 plays all sub-songs consecutively. + * \return 1 on success, 0 on failure. + * \sa openmpt_module_get_num_subsongs, openmpt_module_get_selected_subsong, openmpt_module_get_subsong_name + * \remarks Whether subsong -1 (all subsongs consecutively), subsong 0 or some other subsong is selected by default, is an implementation detail and subject to change. If you do not want to care about subsongs, it is recommended to just not call openmpt_module_select_subsong() at all. + */ +LIBOPENMPT_API int openmpt_module_select_subsong( openmpt_module * mod, int32_t subsong ); +/*! \brief Get currently selected sub-song from a multi-song module + * + * \param mod The module handle to work on. + * \return Currently selected sub-song. -1 for all subsongs consecutively, 0 or greater for the current sub-song index. + * \sa openmpt_module_get_num_subsongs, openmpt_module_select_subsong, openmpt_module_get_subsong_name + * \since 0.3.0 + */ +LIBOPENMPT_API int32_t openmpt_module_get_selected_subsong( openmpt_module * mod ); +/*! \brief Set Repeat Count + * + * \param mod The module handle to work on. + * \param repeat_count Repeat Count + * - -1: repeat forever + * - 0: play once, repeat zero times (the default) + * - n>0: play once and repeat n times after that + * \return 1 on success, 0 on failure. + * \sa openmpt_module_get_repeat_count + */ +LIBOPENMPT_API int openmpt_module_set_repeat_count( openmpt_module * mod, int32_t repeat_count ); +/*! \brief Get Repeat Count + * + * \param mod The module handle to work on. + * \return Repeat Count + * - -1: repeat forever + * - 0: play once, repeat zero times (the default) + * - n>0: play once and repeat n times after that + * \sa openmpt_module_set_repeat_count + */ +LIBOPENMPT_API int32_t openmpt_module_get_repeat_count( openmpt_module * mod ); + +/*! \brief approximate song duration + * + * \param mod The module handle to work on. + * \return Approximate duration of current sub-song in seconds. + */ +LIBOPENMPT_API double openmpt_module_get_duration_seconds( openmpt_module * mod ); + +/*! \brief Set approximate current song position + * + * \param mod The module handle to work on. + * \param seconds Seconds to seek to. If seconds is out of range, the position gets set to song start or end respectively. + * \return Approximate new song position in seconds. + * \sa openmpt_module_get_position_seconds + */ +LIBOPENMPT_API double openmpt_module_set_position_seconds( openmpt_module * mod, double seconds ); +/*! \brief Get current song position + * + * \param mod The module handle to work on. + * \return Current song position in seconds. + * \sa openmpt_module_set_position_seconds + */ +LIBOPENMPT_API double openmpt_module_get_position_seconds( openmpt_module * mod ); + +/*! \brief Set approximate current song position + * + * If order or row are out of range, to position is not modified and the current position is returned. + * \param mod The module handle to work on. + * \param order Pattern order number to seek to. + * \param row Pattern row number to seek to. + * \return Approximate new song position in seconds. + * \sa openmpt_module_set_position_seconds + * \sa openmpt_module_get_position_seconds + */ +LIBOPENMPT_API double openmpt_module_set_position_order_row( openmpt_module * mod, int32_t order, int32_t row ); + +/*! \brief Get render parameter + * + * \param mod The module handle to work on. + * \param param Parameter to query. See \ref openmpt_module_render_param + * \param value Pointer to the variable that receives the current value of the parameter. + * \return 1 on success, 0 on failure (invalid param or value is NULL). + * \sa OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL + * \sa OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT + * \sa OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH + * \sa OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH + * \sa openmpt_module_set_render_param + */ +LIBOPENMPT_API int openmpt_module_get_render_param( openmpt_module * mod, int param, int32_t * value ); +/*! \brief Set render parameter + * + * \param mod The module handle to work on. + * \param param Parameter to set. See \ref openmpt_module_render_param + * \param value The value to set param to. + * \return 1 on success, 0 on failure (invalid param). + * \sa OPENMPT_MODULE_RENDER_MASTERGAIN_MILLIBEL + * \sa OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT + * \sa OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH + * \sa OPENMPT_MODULE_RENDER_VOLUMERAMPING_STRENGTH + * \sa openmpt_module_get_render_param + */ +LIBOPENMPT_API int openmpt_module_set_render_param( openmpt_module * mod, int param, int32_t value ); + +/*@{*/ +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param mono Pointer to a buffer of at least count elements that receives the mono/center output. + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_mono( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * mono ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param left Pointer to a buffer of at least count elements that receives the left output. + * \param right Pointer to a buffer of at least count elements that receives the right output. + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_stereo( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param left Pointer to a buffer of at least count elements that receives the left output. + * \param right Pointer to a buffer of at least count elements that receives the right output. + * \param rear_left Pointer to a buffer of at least count elements that receives the rear left output. + * \param rear_right Pointer to a buffer of at least count elements that receives the rear right output. + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * left, int16_t * right, int16_t * rear_left, int16_t * rear_right ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param mono Pointer to a buffer of at least count elements that receives the mono/center output. + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_float_mono( openmpt_module * mod, int32_t samplerate, size_t count, float * mono ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param left Pointer to a buffer of at least count elements that receives the left output. + * \param right Pointer to a buffer of at least count elements that receives the right output. + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_float_stereo( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param left Pointer to a buffer of at least count elements that receives the left output. + * \param right Pointer to a buffer of at least count elements that receives the right output. + * \param rear_left Pointer to a buffer of at least count elements that receives the rear left output. + * \param rear_right Pointer to a buffer of at least count elements that receives the rear right output. + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * left, float * right, float * rear_left, float * rear_right ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param interleaved_stereo Pointer to a buffer of at least count*2 elements that receives the interleaved stereo output in the order (L,R). + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_interleaved_stereo( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * interleaved_stereo ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_interleaved_quad( openmpt_module * mod, int32_t samplerate, size_t count, int16_t * interleaved_quad ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param interleaved_stereo Pointer to a buffer of at least count*2 elements that receives the interleaved stereo output in the order (L,R). + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + * \sa \ref libopenmpt_c_outputformat + */ +LIBOPENMPT_API size_t openmpt_module_read_interleaved_float_stereo( openmpt_module * mod, int32_t samplerate, size_t count, float * interleaved_stereo ); +/*! \brief Render audio data + * + * \param mod The module handle to work on. + * \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + * \param count Number of audio frames to render per channel. + * \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + * \return The number of frames actually rendered. + * \retval 0 The end of song has been reached. + * \remarks The output buffers are only written to up to the returned number of elements. + * \remarks You can freely switch between any of the "openmpt_module_read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + * \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + * \sa \ref libopenmpt_c_outputformat +*/ +LIBOPENMPT_API size_t openmpt_module_read_interleaved_float_quad( openmpt_module * mod, int32_t samplerate, size_t count, float * interleaved_quad ); +/*@}*/ + +/*! \brief Get the list of supported metadata item keys + * + * \param mod The module handle to work on. + * \return Metadata item keys supported by openmpt_module_get_metadata, as a semicolon-separated list. + * \sa openmpt_module_get_metadata + */ +LIBOPENMPT_API const char * openmpt_module_get_metadata_keys( openmpt_module * mod ); +/*! \brief Get a metadata item value + * + * \param mod The module handle to work on. + * \param key Metadata item key to query. Use openmpt_module_get_metadata_keys to check for available keys. + * Possible keys are: + * - type: Module format extension (e.g. it) + * - type_long: Format name associated with the module format (e.g. Impulse Tracker) + * - originaltype: Module format extension (e.g. it) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) + * - originaltype_long: Format name associated with the module format (e.g. Impulse Tracker) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) + * - container: Container format the module file is embedded in, if any (e.g. umx) + * - container_long: Full container name if the module is embedded in a container (e.g. Unreal Music) + * - tracker: Tracker that was (most likely) used to save the module file, if known + * - artist: Author of the module + * - title: Module title + * - date: Date the module was last saved, in ISO-8601 format. + * - message: Song message. If the song message is empty or the module format does not support song messages, a list of instrument and sample names is returned instead. + * - message_raw: Song message. If the song message is empty or the module format does not support song messages, an empty string is returned. + * - warnings: A list of warnings that were generated while loading the module. + * \return The associated value for key. + * \sa openmpt_module_get_metadata_keys + */ +LIBOPENMPT_API const char * openmpt_module_get_metadata( openmpt_module * mod, const char * key ); + +/*! \brief Get the current speed + * + * \param mod The module handle to work on. + * \return The current speed in ticks per row. + */ +LIBOPENMPT_API int32_t openmpt_module_get_current_speed( openmpt_module * mod ); +/*! \brief Get the current tempo + * + * \param mod The module handle to work on. + * \return The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used. + */ +LIBOPENMPT_API int32_t openmpt_module_get_current_tempo( openmpt_module * mod ); +/*! \brief Get the current order + * + * \param mod The module handle to work on. + * \return The current order at which the module is being played back. + */ +LIBOPENMPT_API int32_t openmpt_module_get_current_order( openmpt_module * mod ); +/*! \brief Get the current pattern + * + * \param mod The module handle to work on. + * \return The current pattern that is being played. + */ +LIBOPENMPT_API int32_t openmpt_module_get_current_pattern( openmpt_module * mod ); +/*! \brief Get the current row + * + * \param mod The module handle to work on. + * \return The current row at which the current pattern is being played. + */ +LIBOPENMPT_API int32_t openmpt_module_get_current_row( openmpt_module * mod ); +/*! \brief Get the current amount of playing channels. + * + * \param mod The module handle to work on. + * \return The amount of sample channels that are currently being rendered. + */ +LIBOPENMPT_API int32_t openmpt_module_get_current_playing_channels( openmpt_module * mod ); + +/*! \brief Get an approximate indication of the channel volume. + * + * \param mod The module handle to work on. + * \param channel The channel whose volume should be retrieved. + * \return The approximate channel volume. + * \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_mono( openmpt_module * mod, int32_t channel ); +/*! \brief Get an approximate indication of the channel volume on the front-left speaker. + * + * \param mod The module handle to work on. + * \param channel The channel whose volume should be retrieved. + * \return The approximate channel volume. + * \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_left( openmpt_module * mod, int32_t channel ); +/*! \brief Get an approximate indication of the channel volume on the front-right speaker. + * + * \param mod The module handle to work on. + * \param channel The channel whose volume should be retrieved. + * \return The approximate channel volume. + * \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_right( openmpt_module * mod, int32_t channel ); +/*! \brief Get an approximate indication of the channel volume on the rear-left speaker. + * + * \param mod The module handle to work on. + * \param channel The channel whose volume should be retrieved. + * \return The approximate channel volume. + * \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_rear_left( openmpt_module * mod, int32_t channel ); +/*! \brief Get an approximate indication of the channel volume on the rear-right speaker. + * + * \param mod The module handle to work on. + * \param channel The channel whose volume should be retrieved. + * \return The approximate channel volume. + * \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ +LIBOPENMPT_API float openmpt_module_get_current_channel_vu_rear_right( openmpt_module * mod, int32_t channel ); + +/*! \brief Get the number of sub-songs + * + * \param mod The module handle to work on. + * \return The number of sub-songs in the module. This includes any "hidden" songs (songs that share the same sequence, but start at different order indices) and "normal" sub-songs or "sequences" (if the format supports them). + * \sa openmpt_module_get_subsong_name, openmpt_module_select_subsong, openmpt_module_get_selected_subsong + */ +LIBOPENMPT_API int32_t openmpt_module_get_num_subsongs( openmpt_module * mod ); +/*! \brief Get the number of pattern channels + * + * \param mod The module handle to work on. + * \return The number of pattern channels in the module. Not all channels do necessarily contain data. + * \remarks The number of pattern channels is completely independent of the number of output channels. libopenmpt can render modules in mono, stereo or quad surround, but the choice of which of the three modes to use must not be made based on the return value of this function, which may be any positive integer amount. Only use this function for informational purposes. + */ +LIBOPENMPT_API int32_t openmpt_module_get_num_channels( openmpt_module * mod ); +/*! \brief Get the number of orders + * + * \param mod The module handle to work on. + * \return The number of orders in the current sequence of the module. + */ +LIBOPENMPT_API int32_t openmpt_module_get_num_orders( openmpt_module * mod ); +/*! \brief Get the number of patterns + * + * \param mod The module handle to work on. + * \return The number of distinct patterns in the module. + */ +LIBOPENMPT_API int32_t openmpt_module_get_num_patterns( openmpt_module * mod ); +/*! \brief Get the number of instruments + * + * \param mod The module handle to work on. + * \return The number of instrument slots in the module. Instruments are a layer on top of samples, and are not supported by all module formats. + */ +LIBOPENMPT_API int32_t openmpt_module_get_num_instruments( openmpt_module * mod ); +/*! \brief Get the number of samples + * + * \param mod The module handle to work on. + * \return The number of sample slots in the module. + */ +LIBOPENMPT_API int32_t openmpt_module_get_num_samples( openmpt_module * mod ); + +/*! \brief Get a sub-song name + * + * \param mod The module handle to work on. + * \param index The sub-song whose name should be retrieved + * \return The sub-song name. + * \sa openmpt_module_get_num_subsongs, openmpt_module_select_subsong, openmpt_module_get_selected_subsong + */ +LIBOPENMPT_API const char * openmpt_module_get_subsong_name( openmpt_module * mod, int32_t index ); +/*! \brief Get a channel name + * + * \param mod The module handle to work on. + * \param index The channel whose name should be retrieved + * \return The channel name. + * \sa openmpt_module_get_num_channels + */ +LIBOPENMPT_API const char * openmpt_module_get_channel_name( openmpt_module * mod, int32_t index ); +/*! \brief Get an order name + * + * \param mod The module handle to work on. + * \param index The order whose name should be retrieved + * \return The order name. + * \sa openmpt_module_get_num_orders + */ +LIBOPENMPT_API const char * openmpt_module_get_order_name( openmpt_module * mod, int32_t index ); +/*! \brief Get a pattern name + * + * \param mod The module handle to work on. + * \param index The pattern whose name should be retrieved + * \return The pattern name. + * \sa openmpt_module_get_num_patterns + */ +LIBOPENMPT_API const char * openmpt_module_get_pattern_name( openmpt_module * mod, int32_t index ); +/*! \brief Get an instrument name + * + * \param mod The module handle to work on. + * \param index The instrument whose name should be retrieved + * \return The instrument name. + * \sa openmpt_module_get_num_instruments + */ +LIBOPENMPT_API const char * openmpt_module_get_instrument_name( openmpt_module * mod, int32_t index ); +/*! \brief Get a sample name + * + * \param mod The module handle to work on. + * \param index The sample whose name should be retrieved + * \return The sample name. + * \sa openmpt_module_get_num_samples + */ +LIBOPENMPT_API const char * openmpt_module_get_sample_name( openmpt_module * mod, int32_t index ); + +/*! \brief Get pattern at order position + * + * \param mod The module handle to work on. + * \param order The order item whose pattern index should be retrieved. + * \return The pattern index found at the given order position of the current sequence. + */ +LIBOPENMPT_API int32_t openmpt_module_get_order_pattern( openmpt_module * mod, int32_t order ); +/*! \brief Get the number of rows in a pattern + * + * \param mod The module handle to work on. + * \param pattern The pattern whose row count should be retrieved. + * \return The number of rows in the given pattern. If the pattern does not exist, 0 is returned. + */ +LIBOPENMPT_API int32_t openmpt_module_get_pattern_num_rows( openmpt_module * mod, int32_t pattern ); + +/*! \brief Get raw pattern content + * + * \param mod The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \param command The cell index at which the data should be retrieved. See \ref openmpt_module_command_index + * \return The internal, raw pattern data at the given pattern position. + */ +LIBOPENMPT_API uint8_t openmpt_module_get_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command ); + +/*! \brief Get formatted (human-readable) pattern content + * + * \param mod The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \param command The cell index at which the data should be retrieved. + * \return The formatted pattern data at the given pattern position. See \ref openmpt_module_command_index + * \sa openmpt_module_highlight_pattern_row_channel_command + */ +LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command ); +/*! \brief Get highlighting information for formatted pattern content + * + * \param mod The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \param command The cell index at which the data should be retrieved. See \ref openmpt_module_command_index + * \return The highlighting string for the formatted pattern data as retrieved by openmpt_module_get_pattern_row_channel_command at the given pattern position. + * \remarks The returned string will map each character position of the string returned by openmpt_module_get_pattern_row_channel_command to a highlighting instruction. + * Possible highlighting characters are: + * - " " : empty/space + * - "." : empty/dot + * - "n" : generic note + * - "m" : special note + * - "i" : generic instrument + * - "u" : generic volume column effect + * - "v" : generic volume column parameter + * - "e" : generic effect column effect + * - "f" : generic effect column parameter + * \sa openmpt_module_get_pattern_row_channel_command + */ +LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command ); + +/*! \brief Get formatted (human-readable) pattern content + * + * \param mod The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \param width The maximum number of characters the string should contain. 0 means no limit. + * \param pad If true, the string will be resized to the exact length provided in the width parameter. + * \return The formatted pattern data at the given pattern position. + * \sa openmpt_module_highlight_pattern_row_channel + */ +LIBOPENMPT_API const char * openmpt_module_format_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ); +/*! \brief Get highlighting information for formatted pattern content + * + * \param mod The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \param width The maximum number of characters the string should contain. 0 means no limit. + * \param pad If true, the string will be resized to the exact length provided in the width parameter. + * \return The highlighting string for the formatted pattern data as retrieved by openmpt_module_format_pattern_row_channel at the given pattern position. + * \sa openmpt_module_format_pattern_row_channel + */ +LIBOPENMPT_API const char * openmpt_module_highlight_pattern_row_channel( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, size_t width, int pad ); + +/*! \brief Retrieve supported ctl keys + * + * \param mod The module handle to work on. + * \return A semicolon-separated list containing all supported ctl keys. + * \remarks Currently supported ctl values are: + * - load.skip_samples: Set to "1" to avoid loading samples into memory + * - load.skip_patterns: Set to "1" to avoid loading patterns into memory + * - load.skip_plugins: Set to "1" to avoid loading plugins + * - load.skip_subsongs_init: Set to "1" to avoid pre-initializing sub-songs. Skipping results in faster module loading but slower seeking. + * - seek.sync_samples: Set to "1" to sync sample playback when using openmpt_module_set_position_seconds or openmpt_module_set_position_order_row. + * - subsong: The current subsong. Setting it has identical semantics as openmpt_module_select_subsong(), getting it returns the currently selected subsong. + * - play.at_end: Chooses the behaviour when the end of song is reached: + * - "fadeout": Fades the module out for a short while. Subsequent reads after the fadeout will return 0 rendered frames. + * - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the song start or loop start. + * - "stop": Returns 0 rendered frames when the song end is reached. Subsequent reads will return 0 rendered frames. + * - play.tempo_factor: Set a floating point tempo factor. "1.0" is the default tempo. + * - play.pitch_factor: Set a floating point pitch factor. "1.0" is the default pitch. + * - render.resampler.emulate_amiga: Set to "1" to enable the Amiga resampler for Amiga modules. This emulates the sound characteristics of the Paula chip and overrides the selected interpolation filter. Non-Amiga module formats are not affected by this setting. + * - render.opl.volume_factor: Set volume factor applied to synthesized OPL sounds, relative to the default OPL volume. + * - dither: Set the dither algorithm that is used for the 16 bit versions of openmpt_module_read. Supported values are: + * - 0: No dithering. + * - 1: Default mode. Chosen by OpenMPT code, might change. + * - 2: Rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker). + * - 3: Rectangular, 1 bit depth, simple 1st order noise shaping + */ +LIBOPENMPT_API const char * openmpt_module_get_ctls( openmpt_module * mod ); +/*! \brief Get current ctl value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be retrieved. + * \return The associated ctl value, or NULL on failure. + * \sa openmpt_module_get_ctls + */ +LIBOPENMPT_API const char * openmpt_module_ctl_get( openmpt_module * mod, const char * ctl ); +/*! \brief Set ctl value + * + * \param mod The module handle to work on. + * \param ctl The ctl key whose value should be set. + * \param value The value that should be set. + * \return 1 if successful, 0 in case the value is not sensible (e.g. negative tempo factor) or the ctl is not recognized. + * \sa openmpt_module_get_ctls + */ +LIBOPENMPT_API int openmpt_module_ctl_set( openmpt_module * mod, const char * ctl, const char * value ); + +/* remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR */ + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_H */ + diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp b/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp new file mode 100644 index 000000000..55097f830 --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt.hpp @@ -0,0 +1,1015 @@ +/* + * libopenmpt.hpp + * -------------- + * Purpose: libopenmpt public c++ interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_HPP +#define LIBOPENMPT_HPP + +#include "libopenmpt_config.h" + +#include +#include +#include +#include +#include +#include + +#include + +/*! + * \page libopenmpt_cpp_overview C++ API + * + * \section libopenmpt_cpp_error Error Handling + * + * libopenmpt C++ uses C++ exception handling for errror reporting. + * + * Unless otherwise noted, any libopenmpt function may throw exceptions and + * all exceptions thrown by libopenmpt itself are derived from + * openmpt::exception. + * In addition, any libopenmpt function may also throw any exception specified + * by the C++ language and C++ standard library. These are all derived from + * std::exception. + * + * \section libopenmpt_cpp_strings Strings + * + * - All strings returned from libopenmpt are encoded in UTF-8. + * - All strings passed to libopenmpt should also be encoded in UTF-8. + * Behaviour in case of invalid UTF-8 is unspecified. + * - libopenmpt does not enforce or expect any particular Unicode + * normalization form. + * + * \section libopenmpt_cpp_fileio File I/O + * + * libopenmpt can use 3 different strategies for file I/O. + * + * - openmpt::module::module() with any kind of memory buffer as parameter will + * load the module from the provided memory buffer, which will require loading + * all data upfront by the library + * caller. + * - openmpt::module::module() with a seekable std::istream as parameter will + * load the module via the stream interface. libopenmpt will not implement an + * additional buffering layer in this case whih means the callbacks are assumed + * to be performant even with small i/o sizes. + * - openmpt::module::module() with an unseekable std::istream as parameter + * will load the module via the stream interface. libopempt will make an + * internal copy as it goes along, and sometimes have to pre-cache the whole + * file in case it needs to know the complete file size. This strategy is + * intended to be used if the file is located on a high latency network. + * + * | constructor | speed | memory consumption | + * | ----------------: | :----: | :----------------: | + * | memory buffer |

fast

|

medium

| + * | seekable stream |

slow

|

low

| + * | unseekable stream |

medium

|

high

| + * + * In all cases, the data or stream passed to the constructor is no longer + * needed after the openmpt::module has been constructed and can be destroyed + * by the caller. + * + * \section libopenmpt_cpp_outputformat Output Format + * + * libopenmpt supports a wide range of PCM output formats: + * [8000..192000]/[mono|stereo|quad]/[f32|i16]. + * + * Unless you have some very specific requirements demanding a particular aspect + * of the output format, you should always prefer 48000/stereo/f32 as the + * libopenmpt PCM format. + * + * - Please prefer 48000Hz unless the user explicitly demands something else. + * Practically all audio equipment and file formats use 48000Hz nowadays. + * - Practically all module formats are made for stereo output. Mono will not + * give you any measurable speed improvements and can trivially be obtained from + * the stereo output anyway. Quad is not expected by almost all modules and even + * if they do use surround effects, they expect the effects to be mixed to + * stereo. + * - Floating point output provides headroom instead of hard clipping if the + * module is louder than 0dBFs, will give you a better signal-to-noise ratio + * than int16 output, and avoid the need to apply an additional dithering to the + * output by libopenmpt. Unless your platform has no floating point unit at all, + * floating point will thus also be slightly faster. + * + * \section libopenmpt_cpp_threads libopenmpt in multi-threaded environments + * + * - libopenmpt is thread-aware. + * - Individual libopenmpt objects are not thread-safe. + * - libopenmpt itself does not spawn any user-visible threads but may spawn + * threads for internal use. + * - You must ensure to only ever access a particular libopenmpt object via + * non-const member functions from a single thread at a time. + * - You may access a particular libopenmpt objects concurrently from different + * threads when using only const member functions from all threads. + * - Consecutive accesses can happen from different threads. + * - Different objects can be accessed concurrently from different threads. + * + * \section libopenmpt-cpp-windows Windows support + * + * Using the libopenmpt C++ API when libopenmpt is compiled as a DLL on Windows + * requires `#define LIBOPENMPT_USE_DLL` (or some equivalent build system + * configuration) before `#include ` in order to + * correctly import the symbols from the DLL. + * + * \section libopenmpt-cpp-detailed Detailed documentation + * + * \ref libopenmpt_cpp + * + * \section libopenmpt_cpp_examples Example + * + * \include libopenmpt_example_cxx.cpp + * + */ + +/*! \defgroup libopenmpt_cpp libopenmpt C++ */ + +/*! \addtogroup libopenmpt_cpp + @{ +*/ + +namespace openmpt { + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4275) +#endif +//! libopenmpt exception base class +/*! + Base class used for all exceptions that are thrown by libopenmpt itself. Libopenmpt may additionally throw any exception thrown by the standard library which are all derived from std::exception. + \sa \ref libopenmpt_cpp_error +*/ +class LIBOPENMPT_CXX_API exception : public std::exception { +private: + char * text; +public: + exception( const std::string & text ) noexcept; + exception( const exception & other ) noexcept; + exception( exception && other ) noexcept; + exception & operator = ( const exception & other ) noexcept; + exception & operator = ( exception && other ) noexcept; + virtual ~exception() noexcept; + const char * what() const noexcept override; +}; // class exception +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +//! Get the libopenmpt version number +/*! + Returns the libopenmpt version number. + \return The value represents (major << 24 + minor << 16 + patch << 0). + \remarks libopenmpt < 0.3.0-pre used the following scheme: (major << 24 + minor << 16 + revision). +*/ +LIBOPENMPT_CXX_API std::uint32_t get_library_version(); + +//! Get the core version number +/*! + Return the OpenMPT core version number. + \return The value represents (majormajor << 24 + major << 16 + minor << 8 + minorminor). +*/ +LIBOPENMPT_CXX_API std::uint32_t get_core_version(); + +namespace string { + +//! Return a verbose library version string from openmpt::string::get(). \deprecated Please use `"library_version"` directly. +LIBOPENMPT_DEPRECATED static const char library_version LIBOPENMPT_ATTR_DEPRECATED [] = "library_version"; +//! Return a verbose library features string from openmpt::string::get(). \deprecated Please use `"library_features"` directly. +LIBOPENMPT_DEPRECATED static const char library_features LIBOPENMPT_ATTR_DEPRECATED [] = "library_features"; +//! Return a verbose OpenMPT core version string from openmpt::string::get(). \deprecated Please use `"core_version"` directly. +LIBOPENMPT_DEPRECATED static const char core_version LIBOPENMPT_ATTR_DEPRECATED [] = "core_version"; +//! Return information about the current build (e.g. the build date or compiler used) from openmpt::string::get(). \deprecated Please use `"build"` directly. +LIBOPENMPT_DEPRECATED static const char build LIBOPENMPT_ATTR_DEPRECATED [] = "build"; +//! Return all contributors from openmpt::string::get(). \deprecated Please use `"credits"` directly. +LIBOPENMPT_DEPRECATED static const char credits LIBOPENMPT_ATTR_DEPRECATED [] = "credits"; +//! Return contact information about libopenmpt from openmpt::string::get(). \deprecated Please use `"contact"` directly. +LIBOPENMPT_DEPRECATED static const char contact LIBOPENMPT_ATTR_DEPRECATED [] = "contact"; +//! Return the libopenmpt license from openmpt::string::get(). \deprecated Please use `"license"` directly. +LIBOPENMPT_DEPRECATED static const char license LIBOPENMPT_ATTR_DEPRECATED [] = "license"; + +//! Get library related metadata. +/*! + \param key Key to query. + Possible keys are: + - "library_version": verbose library version string + - "library_version_major": libopenmpt major version number + - "library_version_minor": libopenmpt minor version number + - "library_version_patch": libopenmpt patch version number + - "library_version_prerel": libopenmpt pre-release version string + - "library_version_is_release": "1" if the version is an officially released version + - "library_features": verbose library features string + - "core_version": verbose OpenMPT core version string + - "source_url": original source code URL + - "source_date": original source code date + - "source_revision": original source code revision + - "source_is_modified": "1" if the original source has been modified + - "source_has_mixed_revisions": "1" if the original source has been compiled from different various revision + - "source_is_package": "1" if the original source has been obtained from a source pacakge instead of source code version control + - "build": information about the current build (e.g. the build date or compiler used) + - "build_compiler": information about the compiler used to build libopenmpt + - "credits": all contributors + - "contact": contact information about libopenmpt + - "license": the libopenmpt license + - "url": libopenmpt website URL + - "support_forum_url": libopenmpt support and discussions forum URL + - "bugtracker_url": libopenmpt bug and issue tracker URL + + \return A (possibly multi-line) string containing the queried information. If no information is available, the string is empty. +*/ +LIBOPENMPT_CXX_API std::string get( const std::string & key ); + +} // namespace string + +//! Get a list of supported file extensions +/*! + \return The list of extensions supported by this libopenmpt build. The extensions are returned lower-case without a leading dot. +*/ +LIBOPENMPT_CXX_API std::vector get_supported_extensions(); + +//! Query whether a file extension is supported +/*! + \param extension file extension to query without a leading dot. The case is ignored. + \return true if the extension is supported by libopenmpt, false otherwise. +*/ +LIBOPENMPT_CXX_API bool is_extension_supported( const std::string & extension ); + +//! Roughly scan the input stream to find out whether libopenmpt might be able to open it +/*! + \param stream Input stream to scan. + \param effort Effort to make when validating stream. Effort 0.0 does not even look at stream at all and effort 1.0 completely loads the file from stream. A lower effort requires less data to be loaded but only gives a rough estimate answer. Use an effort of 0.25 to only verify the header data of the module file. + \param log Log where warning and errors are written. + \return Probability between 0.0 and 1.0. + \remarks openmpt::probe_file_header() provides a simpler and faster interface that fits almost all use cases better. It is recommended to use openmpt::probe_file_header() instead of openmpt::could_open_probability(). + \remarks openmpt::could_open_probability() can return any value between 0.0 and 1.0. Only 0.0 and 1.0 are definitive answers, all values in between are just estimates. In general, any return value >0.0 means that you should try loading the file, and any value below 1.0 means that loading may fail. If you want a threshold above which you can be reasonably sure that libopenmpt will be able to load the file, use >=0.5. If you see the need for a threshold below which you could reasonably outright reject a file, use <0.25 (Note: Such a threshold for rejecting on the lower end is not recommended, but may be required for better integration into some other framework's probe scoring.). + \remarks openmpt::could_open_probability() expects the complete file data to be eventually available to it, even if it is asked to just parse the header. Verification will be unreliable (both false positives and false negatives), if you pretend that the file is just some few bytes of initial data threshold in size. In order to really just access the first bytes of a file, check in your std::istream implementation whether data or seeking is requested beyond your initial data threshold, and in that case, return an error. openmpt::could_open_probability() will treat this as any other I/O error and return 0.0. You must not expect the correct result in this case. You instead must remember that it asked for more data than you currently want to provide to it and treat this situation as if openmpt::could_open_probability() returned 0.5. + \sa \ref libopenmpt_c_fileio + \sa openmpt::probe_file_header() + \since 0.3.0 +*/ +LIBOPENMPT_CXX_API double could_open_probability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog ); + +//! Roughly scan the input stream to find out whether libopenmpt might be able to open it +/*! + \deprecated Please use openmpt::module::could_open_probability(). +*/ +LIBOPENMPT_ATTR_DEPRECATED LIBOPENMPT_CXX_API LIBOPENMPT_DEPRECATED double could_open_propability( std::istream & stream, double effort = 1.0, std::ostream & log = std::clog ); + +//! Get recommended header size for successfull format probing +/*! + \sa openmpt::probe_file_header() + \since 0.3.0 +*/ +LIBOPENMPT_CXX_API std::size_t probe_file_header_get_recommended_size(); + +//! Probe for module formats in openmpt::probe_file_header(). \since 0.3.0 +static const std::uint64_t probe_file_header_flags_modules = 0x1ul; + +//! Probe for module-specific container formats in openmpt::probe_file_header(). \since 0.3.0 +static const std::uint64_t probe_file_header_flags_containers = 0x2ul; + +//! Probe for the default set of formats in openmpt::probe_file_header(). \since 0.3.0 +static const std::uint64_t probe_file_header_flags_default = probe_file_header_flags_modules | probe_file_header_flags_containers; + +//! Probe for no formats in openmpt::probe_file_header(). \since 0.3.0 +static const std::uint64_t probe_file_header_flags_none = 0x0ul; + +//! Possible return values for openmpt::probe_file_header(). \since 0.3.0 +enum probe_file_header_result { + probe_file_header_result_success = 1, + probe_file_header_result_failure = 0, + probe_file_header_result_wantmoredata = -1 +}; + +//! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it +/*! + \param flags Ored mask of openmpt::probe_file_header_flags_modules and openmpt::probe_file_header_flags_containers, or openmpt::probe_file_header_flags_default. + \param data Beginning of the file data. + \param size Size of the beginning of the file data. + \param filesize Full size of the file data on disk. + \remarks It is recommended to provide openmpt::probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size and filesize to the file's size. + \remarks openmpt::could_open_probability() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt::probe_file_header() though, if possible. + \retval probe_file_header_result_success The file will most likely be supported by libopenmpt. + \retval probe_file_header_result_failure The file is not supported by libopenmpt. + \retval probe_file_header_result_wantmoredata An answer could not be determined with the amount of data provided. + \sa openmpt::probe_file_header_get_recommended_size() + \sa openmpt::could_open_probability() + \since 0.3.0 +*/ +LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, const std::uint8_t * data, std::size_t size, std::uint64_t filesize ); + +//! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it +/*! + \param flags Ored mask of openmpt::probe_file_header_flags_modules and openmpt::probe_file_header_flags_containers, or openmpt::probe_file_header_flags_default. + \param data Beginning of the file data. + \param size Size of the beginning of the file data. + \remarks It is recommended to use the overload of this function that also takes the filesize as parameter if at all possile. libopenmpt can provide more accurate answers if the filesize is known. + \remarks It is recommended to provide openmpt::probe_file_header_get_recommended_size() bytes of data for data and size. If the file is smaller, only provide the filesize amount and set size to the file's size. + \remarks openmpt::could_open_probability() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt::probe_file_header() though, if possible. + \retval probe_file_header_result_success The file will most likely be supported by libopenmpt. + \retval probe_file_header_result_failure The file is not supported by libopenmpt. + \retval probe_file_header_result_wantmoredata An answer could not be determined with the amount of data provided. + \sa openmpt::probe_file_header_get_recommended_size() + \sa openmpt::could_open_probability() + \since 0.3.0 +*/ +LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, const std::uint8_t * data, std::size_t size ); + +//! Probe the provided bytes from the beginning of a file for supported file format headers to find out whether libopenmpt might be able to open it +/*! + \param flags Ored mask of openmpt::probe_file_header_flags_modules and openmpt::probe_file_header_flags_containers, or openmpt::probe_file_header_flags_default. + \param stream Input stream to scan. + \remarks stream is left in an unspecified state when this function returns. + \remarks openmpt::could_open_probability() provides a more elaborate interface that might be required for special use cases. It is recommended to use openmpt::probe_file_header() though, if possible. + \retval probe_file_header_result_success The file will most likely be supported by libopenmpt. + \retval probe_file_header_result_failure The file is not supported by libopenmpt. + \retval probe_file_header_result_wantmoredata An answer could not be determined with the amount of data provided. + \sa openmpt::probe_file_header_get_recommended_size() + \sa openmpt::could_open_probability() + \since 0.3.0 +*/ +LIBOPENMPT_CXX_API int probe_file_header( std::uint64_t flags, std::istream & stream ); + +class module_impl; + +class module_ext; + +namespace detail { + +typedef std::map< std::string, std::string > initial_ctls_map; + +} // namespace detail + +class LIBOPENMPT_CXX_API module { + + friend class module_ext; + +public: + + //! Parameter index to use with openmpt::module::get_render_param and openmpt::module::set_render_param + enum render_param { + //! Master Gain + /*! + The related value represents a relative gain in milliBel.\n + The default value is 0.\n + The supported value range is unlimited.\n + */ + RENDER_MASTERGAIN_MILLIBEL = 1, + //! Stereo Separation + /*! + The related value represents the stereo separation generated by the libopenmpt mixer in percent.\n + The default value is 100.\n + The supported value range is [0,200].\n + */ + RENDER_STEREOSEPARATION_PERCENT = 2, + //! Interpolation Filter + /*! + The related value represents the interpolation filter length used by the libopenmpt mixer.\n + The default value is 0, which indicates a recommended default value.\n + The supported value range is [0,inf). Values greater than the implementation limit are clamped to the maximum supported value.\n + Currently supported values: + - 0: internal default + - 1: no interpolation (zero order hold) + - 2: linear interpolation + - 4: cubic interpolation + - 8: windowed sinc with 8 taps + */ + RENDER_INTERPOLATIONFILTER_LENGTH = 3, + //! Volume Ramping Strength + /*! + The related value represents the amount of volume ramping done by the libopenmpt mixer.\n + The default value is -1, which indicates a recommended default value.\n + The meaningful value range is [-1..10].\n + A value of 0 completely disables volume ramping. This might cause clicks in sound output.\n + Higher values imply slower/softer volume ramps. + */ + RENDER_VOLUMERAMPING_STRENGTH = 4 + }; + + //! Parameter index to use with openmpt::module::get_pattern_row_channel_command, openmpt::module::format_pattern_row_channel_command and openmpt::module::highlight_pattern_row_channel_command + enum command_index { + command_note = 0, + command_instrument = 1, + command_volumeffect = 2, + command_effect = 3, + command_volume = 4, + command_parameter = 5 + }; + +private: + module_impl * impl; +private: + // non-copyable + module( const module & ); + void operator = ( const module & ); +private: + // for module_ext + module(); + void set_impl( module_impl * i ); +public: + //! Construct an openmpt::module + /*! + \param stream Input stream from which the module is loaded. After the constructor has finished successfully, the input position of stream is set to the byte after the last byte that has been read. If the constructor fails, the state of the input position of stream is undefined. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param beg Begin of data to load the module from. + \param end End of data to load the module from. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param size Amount of data available. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param beg Begin of data to load the module from. + \param end End of data to load the module from. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param size Amount of data available. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + /*! + \param data Data to load the module from. + \param size Amount of data available. + \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. + \param ctls A map of initial ctl values, see openmpt::module::get_ctls. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. + \remarks The input data can be discarded after an openmpt::module has been constructed successfully. + \sa \ref libopenmpt_cpp_fileio + */ + module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + virtual ~module(); +public: + + //! Select a sub-song from a multi-song module + /*! + \param subsong Index of the sub-song. -1 plays all sub-songs consecutively. + \throws openmpt::exception Throws an exception derived from openmpt::exception if sub-song is not in range [-1,openmpt::module::get_num_subsongs()[ + \sa openmpt::module::get_num_subsongs, openmpt::module::get_selected_subsong, openmpt::module::get_subsong_names + \remarks Whether subsong -1 (all subsongs consecutively), subsong 0 or some other subsong is selected by default, is an implementation detail and subject to change. If you do not want to care about subsongs, it is recommended to just not call openmpt::module::select_subsong() at all. + */ + void select_subsong( std::int32_t subsong ); + //! Get currently selected sub-song from a multi-song module + /*! + \return Currently selected sub-song. -1 for all subsongs consecutively, 0 or greater for the current sub-song index. + \sa openmpt::module::get_num_subsongs, openmpt::module::select_subsong, openmpt::module::get_subsong_names + \since 0.3.0 + */ + std::int32_t get_selected_subsong() const; + //! Set Repeat Count + /*! + \param repeat_count Repeat Count + - -1: repeat forever + - 0: play once, repeat zero times (the default) + - n>0: play once and repeat n times after that + \sa openmpt::module::get_repeat_count + */ + void set_repeat_count( std::int32_t repeat_count ); + //! Get Repeat Count + /*! + \return Repeat Count + - -1: repeat forever + - 0: play once, repeat zero times (the default) + - n>0: play once and repeat n times after that + \sa openmpt::module::set_repeat_count + */ + std::int32_t get_repeat_count() const; + + //! Get approximate song duration + /*! + \return Approximate duration of current sub-song in seconds. + */ + double get_duration_seconds() const; + + //! Set approximate current song position + /*! + \param seconds Seconds to seek to. If seconds is out of range, the position gets set to song start or end respectively. + \return Approximate new song position in seconds. + \sa openmpt::module::get_position_seconds + */ + double set_position_seconds( double seconds ); + //! Get current song position + /*! + \return Current song position in seconds. + \sa openmpt::module::set_position_seconds + */ + double get_position_seconds() const; + + //! Set approximate current song position + /*! + If order or row are out of range, to position is not modified and the current position is returned. + \param order Pattern order number to seek to. + \param row Pattern row number to seek to. + \return Approximate new song position in seconds. + \sa openmpt::module::set_position_seconds + \sa openmpt::module::get_position_seconds + */ + double set_position_order_row( std::int32_t order, std::int32_t row ); + + //! Get render parameter + /*! + \param param Parameter to query. See openmpt::module::render_param. + \return The current value of the parameter. + \throws openmpt::exception Throws an exception derived from openmpt::exception if param is invalid. + \sa openmpt::module::render_param + \sa openmpt::module::set_render_param + */ + std::int32_t get_render_param( int param ) const; + //! Set render parameter + /*! + \param param Parameter to set. See openmpt::module::render_param. + \param value The value to set param to. + \throws openmpt::exception Throws an exception derived from openmpt::exception if param is invalid or value is out of range. + \sa openmpt::module::render_param + \sa openmpt::module::get_render_param + */ + void set_render_param( int param, std::int32_t value ); + + /*@{*/ + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param mono Pointer to a buffer of at least count elements that receives the mono/center output. + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param left Pointer to a buffer of at least count elements that receives the left output. + \param right Pointer to a buffer of at least count elements that receives the right output. + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param left Pointer to a buffer of at least count elements that receives the left output. + \param right Pointer to a buffer of at least count elements that receives the right output. + \param rear_left Pointer to a buffer of at least count elements that receives the rear left output. + \param rear_right Pointer to a buffer of at least count elements that receives the rear right output. + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param mono Pointer to a buffer of at least count elements that receives the mono/center output. + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read( std::int32_t samplerate, std::size_t count, float * mono ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param left Pointer to a buffer of at least count elements that receives the left output. + \param right Pointer to a buffer of at least count elements that receives the right output. + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param left Pointer to a buffer of at least count elements that receives the left output. + \param right Pointer to a buffer of at least count elements that receives the right output. + \param rear_left Pointer to a buffer of at least count elements that receives the rear left output. + \param rear_right Pointer to a buffer of at least count elements that receives the rear right output. + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read( std::int32_t samplerate, std::size_t count, float * left, float * right, float * rear_left, float * rear_right ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param interleaved_stereo Pointer to a buffer of at least count*2 elements that receives the interleaved stereo output in the order (L,R). + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_stereo ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks It is recommended to use the floating point API because of the greater dynamic range and no implied clipping. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, std::int16_t * interleaved_quad ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param interleaved_stereo Pointer to a buffer of at least count*2 elements that receives the interleaved stereo output in the order (L,R). + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read_interleaved_stereo( std::int32_t samplerate, std::size_t count, float * interleaved_stereo ); + //! Render audio data + /*! + \param samplerate Sample rate to render output. Should be in [8000,192000], but this is not enforced. + \param count Number of audio frames to render per channel. + \param interleaved_quad Pointer to a buffer of at least count*4 elements that receives the interleaved suad surround output in the order (L,R,RL,RR). + \return The number of frames actually rendered. + \retval 0 The end of song has been reached. + \remarks The output buffers are only written to up to the returned number of elements. + \remarks You can freely switch between any of the "read*" variants if you see a need to do so. libopenmpt tries to introduce as little switching annoyances as possible. Normally, you would only use a single one of these functions for rendering a particular module. + \remarks Floating point samples are in the [-1.0..1.0] nominal range. They are not clipped to that range though and thus might overshoot. + \sa \ref libopenmpt_cpp_outputformat + */ + std::size_t read_interleaved_quad( std::int32_t samplerate, std::size_t count, float * interleaved_quad ); + /*@}*/ + + //! Get the list of supported metadata item keys + /*! + \return Metadata item keys supported by openmpt::module::get_metadata + \sa openmpt::module::get_metadata + */ + std::vector get_metadata_keys() const; + //! Get a metadata item value + /*! + \param key Metadata item key to query. Use openmpt::module::get_metadata_keys to check for available keys. + Possible keys are: + - type: Module format extension (e.g. it) + - type_long: Format name associated with the module format (e.g. Impulse Tracker) + - originaltype: Module format extension (e.g. it) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) + - originaltype_long: Format name associated with the module format (e.g. Impulse Tracker) of the original module in case the actual type is a converted format (e.g. mo3 or gdm) + - container: Container format the module file is embedded in, if any (e.g. umx) + - container_long: Full container name if the module is embedded in a container (e.g. Unreal Music) + - tracker: Tracker that was (most likely) used to save the module file, if known + - artist: Author of the module + - title: Module title + - date: Date the module was last saved, in ISO-8601 format. + - message: Song message. If the song message is empty or the module format does not support song messages, a list of instrument and sample names is returned instead. + - message_raw: Song message. If the song message is empty or the module format does not support song messages, an empty string is returned. + - warnings: A list of warnings that were generated while loading the module. + \return The associated value for key. + \sa openmpt::module::get_metadata_keys + */ + std::string get_metadata( const std::string & key ) const; + + //! Get the current speed + /*! + \return The current speed in ticks per row. + */ + std::int32_t get_current_speed() const; + //! Get the current tempo + /*! + \return The current tempo in tracker units. The exact meaning of this value depends on the tempo mode being used. + */ + std::int32_t get_current_tempo() const; + //! Get the current order + /*! + \return The current order at which the module is being played back. + */ + std::int32_t get_current_order() const; + //! Get the current pattern + /*! + \return The current pattern that is being played. + */ + std::int32_t get_current_pattern() const; + //! Get the current row + /*! + \return The current row at which the current pattern is being played. + */ + std::int32_t get_current_row() const; + //! Get the current amount of playing channels. + /*! + \return The amount of sample channels that are currently being rendered. + */ + std::int32_t get_current_playing_channels() const; + + //! Get an approximate indication of the channel volume. + /*! + \param channel The channel whose volume should be retrieved. + \return The approximate channel volume. + \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ + float get_current_channel_vu_mono( std::int32_t channel ) const; + //! Get an approximate indication of the channel volume on the front-left speaker. + /*! + \param channel The channel whose volume should be retrieved. + \return The approximate channel volume. + \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ + float get_current_channel_vu_left( std::int32_t channel ) const; + //! Get an approximate indication of the channel volume on the front-right speaker. + /*! + \param channel The channel whose volume should be retrieved. + \return The approximate channel volume. + \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ + float get_current_channel_vu_right( std::int32_t channel ) const; + //! Get an approximate indication of the channel volume on the rear-left speaker. + /*! + \param channel The channel whose volume should be retrieved. + \return The approximate channel volume. + \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ + float get_current_channel_vu_rear_left( std::int32_t channel ) const; + //! Get an approximate indication of the channel volume on the rear-right speaker. + /*! + \param channel The channel whose volume should be retrieved. + \return The approximate channel volume. + \remarks The returned value is solely based on the note velocity and does not take the actual waveform of the playing sample into account. + */ + float get_current_channel_vu_rear_right( std::int32_t channel ) const; + + //! Get the number of sub-songs + /*! + \return The number of sub-songs in the module. This includes any "hidden" songs (songs that share the same sequence, but start at different order indices) and "normal" sub-songs or "sequences" (if the format supports them). + \sa openmpt::module::get_subsong_names, openmpt::module::select_subsong, openmpt::module::get_selected_subsong + */ + std::int32_t get_num_subsongs() const; + //! Get the number of pattern channels + /*! + \return The number of pattern channels in the module. Not all channels do necessarily contain data. + \remarks The number of pattern channels is completely independent of the number of output channels. libopenmpt can render modules in mono, stereo or quad surround, but the choice of which of the three modes to use must not be made based on the return value of this function, which may be any positive integer amount. Only use this function for informational purposes. + */ + std::int32_t get_num_channels() const; + //! Get the number of orders + /*! + \return The number of orders in the current sequence of the module. + */ + std::int32_t get_num_orders() const; + //! Get the number of patterns + /*! + \return The number of distinct patterns in the module. + */ + std::int32_t get_num_patterns() const; + //! Get the number of instruments + /*! + \return The number of instrument slots in the module. Instruments are a layer on top of samples, and are not supported by all module formats. + */ + std::int32_t get_num_instruments() const; + //! Get the number of samples + /*! + \return The number of sample slots in the module. + */ + std::int32_t get_num_samples() const; + + //! Get a list of sub-song names + /*! + \return All sub-song names. + \sa openmpt::module::get_num_subsongs, openmpt::module::select_subsong, openmpt::module::get_selected_subsong + */ + std::vector get_subsong_names() const; + //! Get a list of channel names + /*! + \return All channel names. + \sa openmpt::module::get_num_channels + */ + std::vector get_channel_names() const; + //! Get a list of order names + /*! + \return All order names. + \sa openmpt::module::get_num_orders + */ + std::vector get_order_names() const; + //! Get a list of pattern names + /*! + \return All pattern names. + \sa openmpt::module::get_num_patterns + */ + std::vector get_pattern_names() const; + //! Get a list of instrument names + /*! + \return All instrument names. + \sa openmpt::module::get_num_instruments + */ + std::vector get_instrument_names() const; + //! Get a list of sample names + /*! + \return All sample names. + \sa openmpt::module::get_num_samples + */ + std::vector get_sample_names() const; + + //! Get pattern at order position + /*! + \param order The order item whose pattern index should be retrieved. + \return The pattern index found at the given order position of the current sequence. + */ + std::int32_t get_order_pattern( std::int32_t order ) const; + + //! Get the number of rows in a pattern + /*! + \param pattern The pattern whose row count should be retrieved. + \return The number of rows in the given pattern. If the pattern does not exist, 0 is returned. + */ + std::int32_t get_pattern_num_rows( std::int32_t pattern ) const; + + //! Get raw pattern content + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \param command The cell index at which the data should be retrieved. See openmpt::module::command_index + \return The internal, raw pattern data at the given pattern position. + */ + std::uint8_t get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + + //! Get formatted (human-readable) pattern content + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \param command The cell index at which the data should be retrieved. + \return The formatted pattern data at the given pattern position. See openmpt::module::command_index + \sa openmpt::module::highlight_pattern_row_channel_command + */ + std::string format_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + + //! Get highlighting information for formatted pattern content + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \param command The cell index at which the data should be retrieved. See openmpt::module::command_index + \return The highlighting string for the formatted pattern data as retrieved by openmpt::module::get_pattern_row_channel_command at the given pattern position. + \remarks The returned string will map each character position of the string returned by openmpt::module::get_pattern_row_channel_command to a highlighting instruction. + Possible highlighting characters are: + - " " : empty/space + - "." : empty/dot + - "n" : generic note + - "m" : special note + - "i" : generic instrument + - "u" : generic volume column effect + - "v" : generic volume column parameter + - "e" : generic effect column effect + - "f" : generic effect column parameter + \sa openmpt::module::get_pattern_row_channel_command + */ + std::string highlight_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const; + + //! Get formatted (human-readable) pattern content + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \param width The maximum number of characters the string should contain. 0 means no limit. + \param pad If true, the string will be resized to the exact length provided in the width parameter. + \return The formatted pattern data at the given pattern position. + \sa openmpt::module::highlight_pattern_row_channel + */ + std::string format_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + //! Get highlighting information for formatted pattern content + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \param width The maximum number of characters the string should contain. 0 means no limit. + \param pad If true, the string will be resized to the exact length provided in the width parameter. + \return The highlighting string for the formatted pattern data as retrieved by openmpt::module::format_pattern_row_channel at the given pattern position. + \sa openmpt::module::format_pattern_row_channel + */ + std::string highlight_pattern_row_channel( std::int32_t pattern, std::int32_t row, std::int32_t channel, std::size_t width = 0, bool pad = true ) const; + + //! Retrieve supported ctl keys + /*! + \return A vector containing all supported ctl keys. + \remarks Currently supported ctl values are: + - load.skip_samples: Set to "1" to avoid loading samples into memory + - load.skip_patterns: Set to "1" to avoid loading patterns into memory + - load.skip_plugins: Set to "1" to avoid loading plugins + - load.skip_subsongs_init: Set to "1" to avoid pre-initializing sub-songs. Skipping results in faster module loading but slower seeking. + - seek.sync_samples: Set to "1" to sync sample playback when using openmpt::module::set_position_seconds or openmpt::module::set_position_order_row. + - subsong: The current subsong. Setting it has identical semantics as openmpt::module::select_subsong(), getting it returns the currently selected subsong. + - play.at_end: Chooses the behaviour when the end of song is reached: + - "fadeout": Fades the module out for a short while. Subsequent reads after the fadeout will return 0 rendered frames. + - "continue": Returns 0 rendered frames when the song end is reached. Subsequent reads will continue playing from the song start or loop start. + - "stop": Returns 0 rendered frames when the song end is reached. Subsequent reads will return 0 rendered frames. + - play.tempo_factor: Set a floating point tempo factor. "1.0" is the default tempo. + - play.pitch_factor: Set a floating point pitch factor. "1.0" is the default pitch. + - render.resampler.emulate_amiga: Set to "1" to enable the Amiga resampler for Amiga modules. This emulates the sound characteristics of the Paula chip and overrides the selected interpolation filter. Non-Amiga module formats are not affected by this setting. + - render.opl.volume_factor: Set volume factor applied to synthesized OPL sounds, relative to the default OPL volume. + - dither: Set the dither algorithm that is used for the 16 bit versions of openmpt::module::read. Supported values are: + - 0: No dithering. + - 1: Default mode. Chosen by OpenMPT code, might change. + - 2: Rectangular, 0.5 bit depth, no noise shaping (original ModPlug Tracker). + - 3: Rectangular, 1 bit depth, simple 1st order noise shaping + + An exclamation mark ("!") or a question mark ("?") can be appended to any ctl key in order to influence the behaviour in case of an unknown ctl key. "!" causes an exception to be thrown; "?" causes the ctl to be silently ignored. In case neither is appended to the key name, unknown init_ctls are ignored by default and other ctls throw an exception by default. + */ + std::vector get_ctls() const; + + //! Get current ctl value + /*! + \param ctl The ctl key whose value should be retrieved. + \return The associated ctl value. + \sa openmpt::module::get_ctls + */ + std::string ctl_get( const std::string & ctl ) const; + //! Set ctl value + /*! + \param ctl The ctl key whose value should be set. + \param value The value that should be set. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the value is not sensible (e.g. negative tempo factor) or under the circumstances outlined in openmpt::module::get_ctls. + \sa openmpt::module::get_ctls + */ + void ctl_set( const std::string & ctl, const std::string & value ); + + // remember to add new functions to both C and C++ interfaces and to increase OPENMPT_API_VERSION_MINOR + +}; // class module + +} // namespace openmpt + +/*! + @} +*/ + +#endif // LIBOPENMPT_HPP diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h new file mode 100644 index 000000000..0323ab1e0 --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_config.h @@ -0,0 +1,204 @@ +/* + * libopenmpt_config.h + * ------------------- + * Purpose: libopenmpt public interface configuration + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_CONFIG_H +#define LIBOPENMPT_CONFIG_H + +/*! \defgroup libopenmpt libopenmpt */ + +/*! \addtogroup libopenmpt + @{ +*/ + +/* provoke warnings if already defined */ +#define LIBOPENMPT_API +#undef LIBOPENMPT_API +#define LIBOPENMPT_CXX_API +#undef LIBOPENMPT_CXX_API + +/*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_buffer.h exists. */ +#define LIBOPENMPT_STREAM_CALLBACKS_BUFFER + +/*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_fd.h exists. + * \since 0.3 + * \remarks + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_FD) || ((OPENMPT_API_VERSION_MAJOR == 0) && ((OPENMPT_API_VERSION_MINOR == 2) || (OPENMPT_API_VERSION_MINOR == 1))) + * #include + * #endif + * \endcode + */ +#define LIBOPENMPT_STREAM_CALLBACKS_FD + +/*! \brief Defined if libopenmpt/libopenmpt_stream_callbacks_file.h exists. + * \since 0.3 + * \remarks + * Use the following to check for availability: + * \code + * #include + * #if defined(LIBOPENMPT_STREAM_CALLBACKS_FILE) || ((OPENMPT_API_VERSION_MAJOR == 0) && ((OPENMPT_API_VERSION_MINOR == 2) || (OPENMPT_API_VERSION_MINOR == 1))) + * #include + * #endif + * \endcode + */ +#define LIBOPENMPT_STREAM_CALLBACKS_FILE + +#if defined(__DOXYGEN__) + +#define LIBOPENMPT_API_HELPER_EXPORT +#define LIBOPENMPT_API_HELPER_IMPORT +#define LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API_HELPER_LOCAL + +#elif defined(_MSC_VER) + +#define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport) +#define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport) +#define LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API_HELPER_LOCAL + +#elif defined(__EMSCRIPTEN__) + +#define LIBOPENMPT_API_HELPER_EXPORT __attribute__((visibility("default"))) __attribute__((used)) +#define LIBOPENMPT_API_HELPER_IMPORT __attribute__((visibility("default"))) __attribute__((used)) +#define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) __attribute__((used)) +#define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden"))) + +#elif (defined(__GNUC__) || defined(__clang__)) && defined(_WIN32) + +#define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport) +#define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport) +#define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden"))) + +#elif defined(__GNUC__) || defined(__clang__) + +#define LIBOPENMPT_API_HELPER_EXPORT __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_IMPORT __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_PUBLIC __attribute__((visibility("default"))) +#define LIBOPENMPT_API_HELPER_LOCAL __attribute__((visibility("hidden"))) + +#elif defined(_WIN32) + +#define LIBOPENMPT_API_HELPER_EXPORT __declspec(dllexport) +#define LIBOPENMPT_API_HELPER_IMPORT __declspec(dllimport) +#define LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API_HELPER_LOCAL + +#else + +#define LIBOPENMPT_API_HELPER_EXPORT +#define LIBOPENMPT_API_HELPER_IMPORT +#define LIBOPENMPT_API_HELPER_PUBLIC +#define LIBOPENMPT_API_HELPER_LOCAL + +#endif + +#if defined(LIBOPENMPT_BUILD_DLL) +#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_EXPORT +#elif defined(LIBOPENMPT_USE_DLL) +#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_IMPORT +#else +#define LIBOPENMPT_API LIBOPENMPT_API_HELPER_PUBLIC +#endif + +#ifdef __cplusplus + +#define LIBOPENMPT_CXX_API LIBOPENMPT_API + +#if defined(LIBOPENMPT_USE_DLL) +#if defined(_MSC_VER) && !defined(_DLL) +#error "C++ interface is disabled if libopenmpt is built as a DLL and the runtime is statically linked. This is not supported by microsoft and cannot possibly work. Ever." +#undef LIBOPENMPT_CXX_API +#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL +#endif +#endif + +#if defined(__EMSCRIPTEN__) + +/* Only the C API is supported for emscripten. Disable the C++ API. */ +#undef LIBOPENMPT_CXX_API +#define LIBOPENMPT_CXX_API LIBOPENMPT_API_HELPER_LOCAL +#endif + +#endif + +/*! + @} +*/ + + +/* C */ + +#if !defined(LIBOPENMPT_NO_DEPRECATE) +#if defined(__clang__) +#define LIBOPENMPT_DEPRECATED __attribute__((deprecated)) +#elif defined(__GNUC__) +#define LIBOPENMPT_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +#define LIBOPENMPT_DEPRECATED __declspec(deprecated) +#else +#define LIBOPENMPT_DEPRECATED +#endif +#endif + +#ifndef __cplusplus +#if !defined(LIBOPENMPT_NO_DEPRECATE) +LIBOPENMPT_DEPRECATED static const int LIBOPENMPT_DEPRECATED_STRING_CONSTANT = 0; +#define LIBOPENMPT_DEPRECATED_STRING( str ) ( LIBOPENMPT_DEPRECATED_STRING_CONSTANT ? ( str ) : ( str ) ) +#else +#define LIBOPENMPT_DEPRECATED_STRING( str ) str +#endif +#endif + + +/* C++ */ + +#ifdef __cplusplus + +#ifndef LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED +/* handle known broken compilers here by defining LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED appropriately */ +#endif + +#if defined(LIBOPENMPT_ASSUME_CPLUSPLUS) +#ifndef LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED +#define LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED LIBOPENMPT_ASSUME_CPLUSPLUS +#endif +#endif + +#if !defined(LIBOPENMPT_NO_DEPRECATE) +#if defined(LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED) +#if (LIBOPENMPT_ASSUME_CPLUSPLUS_DEPRECATED >= 201402L) +#define LIBOPENMPT_ATTR_DEPRECATED [[deprecated]] +#undef LIBOPENMPT_DEPRECATED +#define LIBOPENMPT_DEPRECATED +#else +#define LIBOPENMPT_ATTR_DEPRECATED +#endif +#elif (__cplusplus >= 201402L) +#define LIBOPENMPT_ATTR_DEPRECATED [[deprecated]] +#undef LIBOPENMPT_DEPRECATED +#define LIBOPENMPT_DEPRECATED +#else +#define LIBOPENMPT_ATTR_DEPRECATED +#endif +#else +#undef LIBOPENMPT_DEPRECATED +#define LIBOPENMPT_DEPRECATED +#define LIBOPENMPT_ATTR_DEPRECATED +#endif + +#endif + + +#include "libopenmpt_version.h" + +#endif /* LIBOPENMPT_CONFIG_H */ diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h new file mode 100644 index 000000000..e76f758de --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.h @@ -0,0 +1,318 @@ +/* + * libopenmpt_ext.h + * ---------------- + * Purpose: libopenmpt public c interface for libopenmpt extensions + * Notes : + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_EXT_H +#define LIBOPENMPT_EXT_H + +#include "libopenmpt_config.h" +#include "libopenmpt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * \page libopenmpt_ext_c_overview libopenmpt_ext C API + * + * libopenmpt_ext is included in all builds by default. + * + * \section libopenmpt-ext-c-detailed Detailed documentation + * + * \ref libopenmpt_ext_c + * + */ + +/*! \defgroup libopenmpt_ext_c libopenmpt_ext C */ + +/*! \addtogroup libopenmpt_ext_c + * @{ + */ + +/*! \brief Opaque type representing a libopenmpt extension module + */ +typedef struct openmpt_module_ext openmpt_module_ext; + +/*! \brief Construct an openmpt_module_ext + * + * \param stream_callbacks Input stream callback operations. + * \param stream Input stream to load the module from. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module_ext. May be NULL. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \param ctls A map of initial ctl values, see openmpt_module_get_ctls. + * \return A pointer to the constructed openmpt_module_ext, or NULL on failure. + * \remarks The input data can be discarded after an openmpt_module_ext has been constructed successfully. + * \sa openmpt_stream_callbacks + * \sa \ref libopenmpt_c_fileio + * \since 0.3.0 + */ +LIBOPENMPT_API openmpt_module_ext * openmpt_module_ext_create( openmpt_stream_callbacks stream_callbacks, void * stream, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message, const openmpt_module_initial_ctl * ctls ); + +/*! \brief Construct an openmpt_module_ext + * + * \param filedata Data to load the module from. + * \param filesize Amount of data available. + * \param logfunc Logging function where warning and errors are written. The logging function may be called throughout the lifetime of openmpt_module_ext. + * \param loguser User-defined data associated with this module. This value will be passed to the logging callback function (logfunc) + * \param errfunc Error function to define error behaviour. May be NULL. + * \param erruser Error function user context. Used to pass any user-defined data associated with this module to the logging function. + * \param error Pointer to an integer where an error may get stored. May be NULL. + * \param error_message Pointer to a string pointer where an error message may get stored. May be NULL. + * \param ctls A map of initial ctl values, see openmpt_module_get_ctls. + * \return A pointer to the constructed openmpt_module_ext, or NULL on failure. + * \remarks The input data can be discarded after an openmpt_module_ext has been constructed successfully. + * \sa \ref libopenmpt_c_fileio + * \since 0.3.0 + */ +LIBOPENMPT_API openmpt_module_ext * openmpt_module_ext_create_from_memory( const void * filedata, size_t filesize, openmpt_log_func logfunc, void * loguser, openmpt_error_func errfunc, void * erruser, int * error, const char * * error_message, const openmpt_module_initial_ctl * ctls ); + +/*! \brief Unload a previously created openmpt_module_ext from memory. + * + * \param mod_ext The module to unload. + */ +LIBOPENMPT_API void openmpt_module_ext_destroy( openmpt_module_ext * mod_ext ); + +/*! \brief Retrieve the openmpt_module handle from an openmpt_module_ext handle. + * + * \param mod_ext The extension module handle to convert + * \return An equivalent openmpt_module handle to pass to standard libopenmpt functions + * \since 0.3.0 + */ +LIBOPENMPT_API openmpt_module * openmpt_module_ext_get_module( openmpt_module_ext * mod_ext ); + +/*! Retrieve a libopenmpt extension. + * + * \param mod_ext The module handle to work on. + * \param interface_id The name of the extension interface to retrieve (e.g. LIBOPENMPT_EXT_C_INTERFACE_PATTERN_VIS). + * \param interface Appropriate structure of interface function pointers which is to be filled by this function (e.g. a pointer to a openmpt_module_ext_interface_pattern_vis structure). + * \param interface_size Size of the interface's structure of function pointers (e.g. sizeof(openmpt_module_ext_interface_pattern_vis)). + * \return 1 on success, 0 if the interface was not found. + * \since 0.3.0 + */ +LIBOPENMPT_API int openmpt_module_ext_get_interface( openmpt_module_ext * mod_ext, const char * interface_id, void * interface, size_t interface_size ); + + + +#ifndef LIBOPENMPT_EXT_C_INTERFACE_PATTERN_VIS +#define LIBOPENMPT_EXT_C_INTERFACE_PATTERN_VIS "pattern_vis" +#endif + +/*! Pattern command type */ +#define OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_UNKNOWN 0 +#define OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_GENERAL 1 +#define OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_GLOBAL 2 +#define OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_VOLUME 3 +#define OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_PANNING 4 +#define OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_PITCH 5 + +typedef struct openmpt_module_ext_interface_pattern_vis { + /*! Get pattern command type for pattern highlighting + * + * \param mod_ext The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \return The command type in the effect column at the given pattern position (see OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_*) + * \sa openmpt_module_ext_interface_pattern_vis::get_pattern_row_channel_volume_effect_type + */ + int ( * get_pattern_row_channel_volume_effect_type ) ( openmpt_module_ext * mod_ext, int32_t pattern, int32_t row, int32_t channel ); + + /*! Get pattern command type for pattern highlighting + * + * \param mod_ext The module handle to work on. + * \param pattern The pattern whose data should be retrieved. + * \param row The row from which the data should be retrieved. + * \param channel The channel from which the data should be retrieved. + * \return The command type in the effect column at the given pattern position (see OPENMPT_MODULE_EXT_INTERFACE_PATTERN_VIS_EFFECT_TYPE_*) + * \sa openmpt_module_ext_interface_pattern_vis::get_pattern_row_channel_volume_effect_type + */ + int ( * get_pattern_row_channel_effect_type ) ( openmpt_module_ext * mod_ext, int32_t pattern, int32_t row, int32_t channel ); +} openmpt_module_ext_interface_pattern_vis; + + + +#ifndef LIBOPENMPT_EXT_C_INTERFACE_INTERACTIVE +#define LIBOPENMPT_EXT_C_INTERFACE_INTERACTIVE "interactive" +#endif + +typedef struct openmpt_module_ext_interface_interactive { + /*! Set the current ticks per row (speed) + * + * \param mod_ext The module handle to work on. + * \param speed The new tick count in range [1, 65535]. + * \return 1 on success, 0 on failure. + * \remarks The tick count may be reset by pattern commands at any time. + * \sa openmpt_module_get_current_speed + */ + int ( * set_current_speed ) ( openmpt_module_ext * mod_ext, int32_t speed ); + + /*! Set the current module tempo + * + * \param mod_ext The module handle to work on. + * \param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module. + * \return 1 on success, 0 on failure. + * \remarks The tempo may be reset by pattern commands at any time. Use openmpt_module_ext_interface_interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. + * \sa openmpt_module_get_current_tempo + */ + int ( * set_current_tempo ) ( openmpt_module_ext * mod_ext, int32_t tempo ); + + /*! Set the current module tempo factor without affecting playback pitch + * + * \param mod_ext The module handle to work on. + * \param factor The new tempo factor in range ]0.0, 4.0] - 1.0 means unmodified tempo. + * \return 1 on success, 0 on failure. + * \remarks Modifying the tempo without applying the same pitch factor using openmpt_module_ext_interface_interactive::set_pitch_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + * \sa openmpt_module_ext_interface_interactive::get_tempo_factor + */ + int ( * set_tempo_factor ) ( openmpt_module_ext * mod_ext, double factor ); + + /*! Gets the current module tempo factor + * + * \param mod_ext The module handle to work on. + * \return The current tempo factor. + * \sa openmpt_module_ext_interface_interactive::set_tempo_factor + */ + double ( * get_tempo_factor ) ( openmpt_module_ext * mod_ext ); + + /*! Set the current module pitch factor without affecting playback speed + * + * \param mod_ext The module handle to work on. + * \param factor The new pitch factor in range ]0.0, 4.0] - 1.0 means unmodified pitch. + * \return 1 on success, 0 on failure. + * \remarks Modifying the pitch without applying the the same tempo factor using openmpt_module_ext_interface_interactive::set_tempo_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + * \remarks To shift the pich by `n` semitones, the parameter can be calculated as follows: `pow( 2.0, n / 12.0 )` + * \sa openmpt_module_ext_interface_interactive::get_pitch_factor + */ + int ( * set_pitch_factor ) ( openmpt_module_ext * mod_ext, double factor ); + + /*! Gets the current module pitch factor + * + * \param mod_ext The module handle to work on. + * \return The current pitch factor. + * \sa openmpt_module_ext_interface_interactive::set_pitch_factor + */ + double ( * get_pitch_factor ) ( openmpt_module_ext * mod_ext ); + + /*! Set the current global volume + * + * \param mod_ext The module handle to work on. + * \param volume The new global volume in range [0.0, 1.0] + * \return 1 on success, 0 on failure. + * \remarks The global volume may be reset by pattern commands at any time. Use openmpt_module_set_render_param to apply a global overall volume factor that is independent of pattern commands. + * \sa openmpt_module_ext_interface_interactive::get_global_volume + */ + int ( * set_global_volume ) ( openmpt_module_ext * mod_ext, double volume ); + + /*! Get the current global volume + * + * \param mod_ext The module handle to work on. + * \return The current global volume in range [0.0, 1.0] + * \sa openmpt_module_ext_interface_interactive::set_global_volume + */ + double ( * get_global_volume ) ( openmpt_module_ext * mod_ext ); + + /*! Set the current channel volume for a channel + * + * \param mod_ext The module handle to work on. + * \param channel The channel whose volume should be set, in range [0, openmpt_module_get_num_channels()[ + * \param volume The new channel volume in range [0.0, 1.0] + * \return 1 on success, 0 on failure (channel out of range). + * \remarks The channel volume may be reset by pattern commands at any time. + * \sa openmpt_module_ext_interface_interactive::get_channel_volume + */ + int ( * set_channel_volume ) ( openmpt_module_ext * mod_ext, int32_t channel, double volume ); + + /*! Get the current channel volume for a channel + * + * \param mod_ext The module handle to work on. + * \param channel The channel whose volume should be retrieved, in range [0, openmpt_module_get_num_channels()[ + * \return The current channel volume in range [0.0, 1.0] + * \sa openmpt_module_ext_interface_interactive::set_channel_volume + */ + double ( * get_channel_volume ) ( openmpt_module_ext * mod_ext, int32_t channel ); + + /*! Set the current mute status for a channel + * + * \param mod_ext The module handle to work on. + * \param channel The channel whose mute status should be set, in range [0, openmpt_module_get_num_channels()[ + * \param mute The new mute status. true is muted, false is unmuted. + * \return 1 on success, 0 on failure (channel out of range). + * \sa openmpt_module_ext_interface_interactive::get_channel_mute_status + */ + int ( * set_channel_mute_status ) ( openmpt_module_ext * mod_ext, int32_t channel, int mute ); + + /*! Get the current mute status for a channel + * + * \param mod_ext The module handle to work on. + * \param channel The channel whose mute status should be retrieved, in range [0, openmpt_module_get_num_channels()[ + * \return The current channel mute status. 1 is muted, 0 is unmuted, -1 means the instrument was out of range + * \sa openmpt_module_ext_interface_interactive::set_channel_mute_status + */ + int ( * get_channel_mute_status ) ( openmpt_module_ext * mod_ext, int32_t channel ); + + /*! Set the current mute status for an instrument + * + * \param mod_ext The module handle to work on. + * \param instrument The instrument whose mute status should be set, in range [0, openmpt_module_get_num_instruments()[ if openmpt_module_get_num_instruments is not 0, otherwise in [0, openmpt_module_get_num_samples()[ + * \param mute The new mute status. true is muted, false is unmuted. + * \return 1 on success, 0 on failure (instrument out of range). + * \sa openmpt_module_ext_interface_interactive::get_instrument_mute_status + */ + int ( * set_instrument_mute_status ) ( openmpt_module_ext * mod_ext, int32_t instrument, int mute ); + + /*! Get the current mute status for an instrument + * + * \param mod_ext The module handle to work on. + * \param instrument The instrument whose mute status should be retrieved, in range [0, openmpt_module_get_num_instruments()[ if openmpt_module_get_num_instruments is not 0, otherwise in [0, openmpt_module_get_num_samples()[ + * \return The current instrument mute status. 1 is muted, 0 is unmuted, -1 means the instrument was out of range + * \sa openmpt_module_ext_interface_interactive::set_instrument_mute_status + */ + int ( * get_instrument_mute_status ) ( openmpt_module_ext * mod_ext, int32_t instrument ); + + /*! Play a note using the specified instrument + * + * \param mod_ext The module handle to work on. + * \param instrument The instrument that should be played, in range [0, openmpt_module_get_num_instruments()[ if openmpt_module_get_num_instruments is not 0, otherwise in [0, openmpt_module_get_num_samples()[ + * \param note The note to play, in rage [0, 119]. 60 is the middle C. + * \param volume The volume at which the note should be triggered, in range [0.0, 1.0] + * \param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center. + * \return The channel on which the note is played. This can pe be passed to openmpt_module_ext_interface_interactive::stop_note to stop the note. -1 means that no channel could be allocated and the note is not played. + * \sa openmpt_module_ext_interface_interactive::stop_note + */ + int32_t ( * play_note ) ( openmpt_module_ext * mod_ext, int32_t instrument, int32_t note, double volume, double panning ); + + /*! Stop the note playing on the specified channel + * + * \param mod_ext The module handle to work on. + * \param channel The channel on which the note should be stopped. + * \return 1 on success, 0 on failure (channel out of range). + * \sa openmpt_module_ext_interface_interactive::play_note + */ + int ( * stop_note ) ( openmpt_module_ext * mod_ext, int32_t channel ); +} openmpt_module_ext_interface_interactive; + + + +/* add stuff here */ + + + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_EXT_H */ + diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp new file mode 100644 index 000000000..686eaeeed --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_ext.hpp @@ -0,0 +1,306 @@ +/* + * libopenmpt_ext.hpp + * ------------------ + * Purpose: libopenmpt public c++ interface for libopenmpt extensions + * Notes : + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_EXT_HPP +#define LIBOPENMPT_EXT_HPP + +#include "libopenmpt_config.h" +#include "libopenmpt.hpp" + +/*! + * \page libopenmpt_ext_cpp_overview libopenmpt_ext C++ API + * + * libopenmpt_ext is now included in all builds by default. + * + * \section libopenmpt-ext-cpp-detailed Detailed documentation + * + * \ref libopenmpt_ext_cpp + * + */ + +/*! \defgroup libopenmpt_ext_cpp libopenmpt_ext C++ */ + +/*! \addtogroup libopenmpt_ext_cpp + @{ +*/ + +namespace openmpt { + +class module_ext_impl; + +class LIBOPENMPT_CXX_API module_ext : public module { + +private: + module_ext_impl * ext_impl; +private: + // non-copyable + module_ext( const module_ext & ); + void operator = ( const module_ext & ); +public: + module_ext( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + module_ext( const std::vector & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + module_ext( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + module_ext( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); + virtual ~module_ext(); + +public: + + //! Retrieve a libopenmpt extension. + /*! Example: Retrieving the interactive extension to change the tempo of a module: + \code{.cpp} + openmpt::module_ext *mod = new openmpt::module_ext( stream ); + #ifdef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE + openmpt::ext::interactive *interactive = static_cast( self->mod->get_interface( openmpt::ext::interactive_id ) ); + if ( interactive ) { + interactive->set_tempo_factor( 2.0 ); // play module at double speed + } else { + // interface not available + } + #else + // interfae not available + #endif + \endcode + \param interface_id The name of the extension interface to retrieve. + \return The interface object. This may be a nullptr if the extension was not found. + */ + void * get_interface( const std::string & interface_id ); + +}; // class module_ext + +namespace ext { + +#define LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(name) \ + static const char name ## _id [] = # name ; \ + class name; \ +/**/ + +#define LIBOPENMPT_EXT_CXX_INTERFACE(name) \ + protected: \ + name () {} \ + virtual ~ name () {} \ + public: \ +/**/ + + +#ifndef LIBOPENMPT_EXT_INTERFACE_PATTERN_VIS +#define LIBOPENMPT_EXT_INTERFACE_PATTERN_VIS +#endif + +LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(pattern_vis) + +class pattern_vis { + + LIBOPENMPT_EXT_CXX_INTERFACE(pattern_vis) + + //! Pattern command type + enum effect_type { + + effect_unknown = 0, + effect_general = 1, + effect_global = 2, + effect_volume = 3, + effect_panning = 4, + effect_pitch = 5 + + }; // enum effect_type + + //! Get pattern command type for pattern highlighting + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \return The command type in the effect column at the given pattern position (see openmpt::ext::pattern_vis::effect_type) + \sa openmpt::ext::pattern_vis::get_pattern_row_channel_effect_type + */ + virtual effect_type get_pattern_row_channel_volume_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0; + + //! Get pattern command type for pattern highlighting + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \return The command type in the volume column at the given pattern position (see openmpt::ext::pattern_vis::effect_type) + \sa openmpt::ext::pattern_vis::get_pattern_row_channel_volume_effect_type + */ + virtual effect_type get_pattern_row_channel_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0; + +}; // class pattern_vis + + +#ifndef LIBOPENMPT_EXT_INTERFACE_INTERACTIVE +#define LIBOPENMPT_EXT_INTERFACE_INTERACTIVE +#endif + +LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE(interactive) + +class interactive { + + LIBOPENMPT_EXT_CXX_INTERFACE(interactive) + + //! Set the current ticks per row (speed) + /*! + \param speed The new tick count in range [1, 65535]. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the speed is outside the specified range. + \remarks The tick count may be reset by pattern commands at any time. + \sa openmpt::module::get_current_speed + */ + virtual void set_current_speed( std::int32_t speed ) = 0; + + //! Set the current module tempo + /*! + \param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range. + \remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. + \sa openmpt::module::get_current_tempo + */ + virtual void set_current_tempo( std::int32_t tempo ) = 0; + + //! Set the current module tempo factor without affecting playback pitch + /*! + \param factor The new tempo factor in range ]0.0, 4.0] - 1.0 means unmodified tempo. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range. + \remarks Modifying the tempo without applying the same pitch factor using openmpt::ext::interactive::set_pitch_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + \sa openmpt::ext::interactive::get_tempo_factor + */ + virtual void set_tempo_factor( double factor ) = 0; + + //! Gets the current module tempo factor + /*! + \return The current tempo factor. + \sa openmpt::ext::interactive::set_tempo_factor + */ + virtual double get_tempo_factor( ) const = 0; + + //! Set the current module pitch factor without affecting playback speed + /*! + \param factor The new pitch factor in range ]0.0, 4.0] - 1.0 means unmodified pitch. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range. + \remarks Modifying the pitch without applying the the same tempo factor using openmpt::ext::interactive::set_tempo_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + \remarks To shift the pich by `n` semitones, the parameter can be calculated as follows: `pow( 2.0, n / 12.0 )` + \sa openmpt::ext::interactive::get_pitch_factor + */ + virtual void set_pitch_factor( double factor ) = 0; + + //! Gets the current module pitch factor + /*! + \return The current pitch factor. + \sa openmpt::ext::interactive::set_pitch_factor + */ + virtual double get_pitch_factor( ) const = 0; + + //! Set the current global volume + /*! + \param volume The new global volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the volume is outside the specified range. + \remarks The global volume may be reset by pattern commands at any time. Use openmpt::module::set_render_param to apply a global overall volume factor that is independent of pattern commands. + \sa openmpt::ext::interactive::get_global_volume + */ + virtual void set_global_volume( double volume ) = 0; + + //! Get the current global volume + /*! + \return The current global volume in range [0.0, 1.0] + \sa openmpt::ext::interactive::set_global_volume + */ + virtual double get_global_volume( ) const = 0; + + //! Set the current channel volume for a channel + /*! + \param channel The channel whose volume should be set, in range [0, openmpt::module::get_num_channels()[ + \param volume The new channel volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel or volume is outside the specified range. + \remarks The channel volume may be reset by pattern commands at any time. + \sa openmpt::ext::interactive::get_channel_volume + */ + virtual void set_channel_volume( std::int32_t channel, double volume ) = 0; + + //! Get the current channel volume for a channel + /*! + \param channel The channel whose volume should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::set_channel_volume + */ + virtual double get_channel_volume( std::int32_t channel ) const = 0; + + //! Set the current mute status for a channel + /*! + \param channel The channel whose mute status should be set, in range [0, openmpt::module::get_num_channels()[ + \param mute The new mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::get_channel_mute_status + */ + virtual void set_channel_mute_status( std::int32_t channel, bool mute ) = 0; + + //! Get the current mute status for a channel + /*! + \param channel The channel whose mute status should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::set_channel_mute_status + */ + virtual bool get_channel_mute_status( std::int32_t channel ) const = 0; + + //! Set the current mute status for an instrument + /*! + \param instrument The instrument whose mute status should be set, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \param mute The new mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range. + \sa openmpt::ext::interactive::get_instrument_mute_status + */ + virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) = 0; + + //! Get the current mute status for an instrument + /*! + \param instrument The instrument whose mute status should be retrieved, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \return The current instrument mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range. + \sa openmpt::ext::interactive::set_instrument_mute_status + */ + virtual bool get_instrument_mute_status( std::int32_t instrument ) const = 0; + + //! Play a note using the specified instrument + /*! + \param instrument The instrument that should be played, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \param note The note to play, in rage [0, 119]. 60 is the middle C. + \param volume The volume at which the note should be triggered, in range [0.0, 1.0] + \param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center. + \return The channel on which the note is played. This can pe be passed to openmpt::ext::interactive::stop_note to stop the note. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument or note is outside the specified range. + \sa openmpt::ext::interactive::stop_note + */ + virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) = 0; + + //! Stop the note playing on the specified channel + /*! + \param channel The channel on which the note should be stopped. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \sa openmpt::ext::interactive::play_note + */ + virtual void stop_note( std::int32_t channel ) = 0; + +}; // class interactive + + +/* add stuff here */ + + + +#undef LIBOPENMPT_DECLARE_EXT_CXX_INTERFACE +#undef LIBOPENMPT_EXT_CXX_INTERFACE + +} // namespace ext + +} // namespace openmpt + +/*! + @} +*/ + +#endif // LIBOPENMPT_EXT_HPP diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h new file mode 100644 index 000000000..575049e4d --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_buffer.h @@ -0,0 +1,198 @@ +/* + * libopenmpt_stream_callbacks_buffer.h + * ------------------------------------ + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_BUFFER_H +#define LIBOPENMPT_STREAM_CALLBACKS_BUFFER_H + +#include "libopenmpt.h" + +/* The use of this header requires: + +#include +#if defined( LIBOPENMPT_STREAM_CALLBACKS_BUFFER ) +#include +#else +#error "libopenmpt too old." +#endif + +*/ + +#include +#include +#include + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct openmpt_stream_buffer { + const void * file_data; /* or prefix data IFF prefix_size < file_size */ + int64_t file_size; + int64_t file_pos; + int64_t prefix_size; + int overflow; +} openmpt_stream_buffer; + +static size_t openmpt_stream_buffer_read_func( void * stream, void * dst, size_t bytes ) { + openmpt_stream_buffer * s = (openmpt_stream_buffer*)stream; + int64_t offset = 0; + int64_t begpos = 0; + int64_t endpos = 0; + size_t valid_bytes = 0; + if ( !s ) { + return 0; + } + offset = bytes; + begpos = s->file_pos; + endpos = s->file_pos; + valid_bytes = 0; + endpos = (uint64_t)endpos + (uint64_t)offset; + if ( ( offset > 0 ) && !( (uint64_t)endpos > (uint64_t)begpos ) ) { + /* integer wrapped */ + return 0; + } + if ( bytes == 0 ) { + return 0; + } + if ( begpos >= s->file_size ) { + return 0; + } + if ( endpos > s->file_size ) { + /* clip to eof */ + bytes = bytes - (size_t)( endpos - s->file_size ); + endpos = endpos - ( endpos - s->file_size ); + } + memset( dst, 0, bytes ); + if ( begpos >= s->prefix_size ) { + s->overflow = 1; + valid_bytes = 0; + } else if ( endpos > s->prefix_size ) { + s->overflow = 1; + valid_bytes = bytes - (size_t)( endpos - s->prefix_size ); + } else { + valid_bytes = bytes; + } + memcpy( dst, (const char*)s->file_data + s->file_pos, valid_bytes ); + s->file_pos = s->file_pos + bytes; + return bytes; +} + +static int openmpt_stream_buffer_seek_func( void * stream, int64_t offset, int whence ) { + openmpt_stream_buffer * s = (openmpt_stream_buffer*)stream; + int result = -1; + if ( !s ) { + return -1; + } + switch ( whence ) { + case OPENMPT_STREAM_SEEK_SET: + if ( offset < 0 ) { + return -1; + } + if ( offset > s->file_size ) { + return -1; + } + s->file_pos = offset; + result = 0; + break; + case OPENMPT_STREAM_SEEK_CUR: + do { + int64_t oldpos = s->file_pos; + int64_t pos = s->file_pos; + pos = (uint64_t)pos + (uint64_t)offset; + if ( ( offset > 0 ) && !( (uint64_t)pos > (uint64_t)oldpos ) ) { + /* integer wrapped */ + return -1; + } + if ( ( offset < 0 ) && !( (uint64_t)pos < (uint64_t)oldpos ) ) { + /* integer wrapped */ + return -1; + } + s->file_pos = pos; + } while(0); + result = 0; + break; + case OPENMPT_STREAM_SEEK_END: + if ( offset > 0 ) { + return -1; + } + do { + int64_t oldpos = s->file_pos; + int64_t pos = s->file_pos; + pos = s->file_size; + pos = (uint64_t)pos + (uint64_t)offset; + if ( ( offset < 0 ) && !( (uint64_t)pos < (uint64_t)oldpos ) ) { + /* integer wrapped */ + return -1; + } + s->file_pos = pos; + } while(0); + result = 0; + break; + } + return result; +} + +static int64_t openmpt_stream_buffer_tell_func( void * stream ) { + openmpt_stream_buffer * s = (openmpt_stream_buffer*)stream; + if ( !s ) { + return -1; + } + return s->file_pos; +} + +static void openmpt_stream_buffer_init( openmpt_stream_buffer * buffer, const void * file_data, int64_t file_size ) { + memset( buffer, 0, sizeof( openmpt_stream_buffer ) ); + buffer->file_data = file_data; + buffer->file_size = file_size; + buffer->file_pos = 0; + buffer->prefix_size = file_size; + buffer->overflow = 0; +} + +#define openmpt_stream_buffer_init_prefix_only( buffer_, prefix_data_, prefix_size_, file_size_ ) do { \ + openmpt_stream_buffer_init( (buffer_), (prefix_data_), (file_size_) ); \ + (buffer_)->prefix_size = (prefix_size_); \ +} while(0) + +#define openmpt_stream_buffer_overflowed( buffer_ ) ( (buffer_)->overflow ) + +/*! \brief Provide openmpt_stream_callbacks for in-memoy buffers + * + * Fills openmpt_stream_callbacks suitable for passing an in-memory buffer as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(openmpt_stream_buffer*)stream_buffer`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_buffer_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_buffer_read_func; + retval.seek = openmpt_stream_buffer_seek_func; + retval.tell = openmpt_stream_buffer_tell_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_BUFFER_H */ + diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h new file mode 100644 index 000000000..46b39f129 --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_fd.h @@ -0,0 +1,101 @@ +/* + * libopenmpt_stream_callbacks_fd.h + * -------------------------------- + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_FD_H +#define LIBOPENMPT_STREAM_CALLBACKS_FD_H + +#include "libopenmpt.h" + +#ifdef _MSC_VER +#include +#endif +#include +#include +#include +#include +#ifndef _MSC_VER +#include +#endif + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* This stuff has to be in a header file because of possibly different MSVC CRTs which cause problems for fd crossing CRT boundaries. */ + +static size_t openmpt_stream_fd_read_func( void * stream, void * dst, size_t bytes ) { + int fd = 0; + #if defined(_MSC_VER) + size_t retval = 0; + int to_read = 0; + int ret_read = 0; + #else + ssize_t retval = 0; + #endif + fd = (int)(uintptr_t)stream; + if ( fd < 0 ) { + return 0; + } + #if defined(_MSC_VER) + retval = 0; + while ( bytes > 0 ) { + to_read = 0; + if ( bytes < (size_t)INT_MAX ) { + to_read = (int)bytes; + } else { + to_read = INT_MAX; + } + ret_read = _read( fd, dst, to_read ); + if ( ret_read <= 0 ) { + return retval; + } + bytes -= ret_read; + retval += ret_read; + } + #else + retval = read( fd, dst, bytes ); + #endif + if ( retval <= 0 ) { + return 0; + } + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard POSIX file descriptors + * + * Fills openmpt_stream_callbacks suitable for passing a POSIX filer descriptor as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(uintptr_t)(int)fd`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_fd_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_fd_read_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_FD_H */ + diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h new file mode 100644 index 000000000..643049153 --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_stream_callbacks_file.h @@ -0,0 +1,132 @@ +/* + * libopenmpt_stream_callbacks_file.h + * ---------------------------------- + * Purpose: libopenmpt public c interface + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_STREAM_CALLBACKS_FILE_H +#define LIBOPENMPT_STREAM_CALLBACKS_FILE_H + +#include "libopenmpt.h" + +#include +#include +#include +#include +#ifdef _MSC_VER +#include /* off_t */ +#endif + +/*! \addtogroup libopenmpt_c + * @{ + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* This stuff has to be in a header file because of possibly different MSVC CRTs which cause problems for FILE * crossing CRT boundaries. */ + +static size_t openmpt_stream_file_read_func( void * stream, void * dst, size_t bytes ) { + FILE * f = 0; + size_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return 0; + } + retval = fread( dst, 1, bytes, f ); + if ( retval <= 0 ) { + return 0; + } + return retval; +} + +static int openmpt_stream_file_seek_func( void * stream, int64_t offset, int whence ) { + FILE * f = 0; + int fwhence = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + switch ( whence ) { +#if defined(SEEK_SET) + case OPENMPT_STREAM_SEEK_SET: + fwhence = SEEK_SET; + break; +#endif +#if defined(SEEK_CUR) + case OPENMPT_STREAM_SEEK_CUR: + fwhence = SEEK_CUR; + break; +#endif +#if defined(SEEK_END) + case OPENMPT_STREAM_SEEK_END: + fwhence = SEEK_END; + break; +#endif + default: + return -1; + break; + } + #if defined(_MSC_VER) + return _fseeki64( f, offset, fwhence ) ? -1 : 0; + #elif defined(_POSIX_SOURCE) && (_POSIX_SOURCE == 1) + return fseeko( f, offset, fwhence ) ? -1 : 0; + #else + return fseek( f, offset, fwhence ) ? -1 : 0; + #endif +} + +static int64_t openmpt_stream_file_tell_func( void * stream ) { + FILE * f = 0; + int64_t retval = 0; + f = (FILE*)stream; + if ( !f ) { + return -1; + } + #if defined(_MSC_VER) + retval = _ftelli64( f ); + #elif defined(_POSIX_SOURCE) && (_POSIX_SOURCE == 1) + retval = ftello( f ); + #else + retval = ftell( f ); + #endif + if ( retval < 0 ) { + return -1; + } + return retval; +} + +/*! \brief Provide openmpt_stream_callbacks for standard C FILE objects + * + * Fills openmpt_stream_callbacks suitable for passing a standard C FILE object as a stream parameter to functions doing file input/output. + * + * \remarks The stream argument must be passed as `(void*)(FILE*)file`. + * \sa \ref libopenmpt_c_fileio + * \sa openmpt_stream_callbacks + * \sa openmpt_could_open_probability2 + * \sa openmpt_probe_file_header_from_stream + * \sa openmpt_module_create2 + */ +static openmpt_stream_callbacks openmpt_stream_get_file_callbacks(void) { + openmpt_stream_callbacks retval; + memset( &retval, 0, sizeof( openmpt_stream_callbacks ) ); + retval.read = openmpt_stream_file_read_func; + retval.seek = openmpt_stream_file_seek_func; + retval.tell = openmpt_stream_file_tell_func; + return retval; +} + +#ifdef __cplusplus +} +#endif + +/*! + * @} + */ + +#endif /* LIBOPENMPT_STREAM_CALLBACKS_FILE_H */ + diff --git a/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h b/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h new file mode 100644 index 000000000..4bb90278c --- /dev/null +++ b/libs/libopenmpt/inc/libopenmpt/libopenmpt_version.h @@ -0,0 +1,75 @@ +/* + * libopenmpt_version.h + * -------------------- + * Purpose: libopenmpt public interface version + * Notes : (currently none) + * Authors: OpenMPT Devs + * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. + */ + +#ifndef LIBOPENMPT_VERSION_H +#define LIBOPENMPT_VERSION_H + +/*! \addtogroup libopenmpt + @{ +*/ + +/*! \brief libopenmpt major version number */ +#define OPENMPT_API_VERSION_MAJOR 0 +/*! \brief libopenmpt minor version number */ +#define OPENMPT_API_VERSION_MINOR 4 +/*! \brief libopenmpt patch version number */ +#define OPENMPT_API_VERSION_PATCH 7 +/*! \brief libopenmpt pre-release tag */ +#define OPENMPT_API_VERSION_PREREL "" +/*! \brief libopenmpt pre-release flag */ +#define OPENMPT_API_VERSION_IS_PREREL 0 + +/*! \brief libopenmpt version number as a single integer value + * \since 0.3 + * \remarks Use the following shim if you need to support earlier libopenmpt versions: + * \code + * #include + * #if !defined(OPENMPT_API_VERSION_MAKE) + * #define OPENMPT_API_VERSION_MAKE(major, minor, patch) (((major)<<24)|((minor)<<16)|((patch)<<0)) + * #endif + * \endcode + */ +#define OPENMPT_API_VERSION_MAKE(major, minor, patch) (((major)<<24)|((minor)<<16)|((patch)<<0)) + +/*! \brief libopenmpt API version number */ +#define OPENMPT_API_VERSION OPENMPT_API_VERSION_MAKE(OPENMPT_API_VERSION_MAJOR, OPENMPT_API_VERSION_MINOR, OPENMPT_API_VERSION_PATCH) + +/*! \brief Check whether the libopenmpt API is at least the provided version + * \since 0.3 + * \remarks Use the following shim if you need to support earlier libopenmpt versions: + * \code + * #include + * #if !defined(OPENMPT_API_VERSION_AT_LEAST) + * #define OPENMPT_API_VERSION_AT_LEAST(major, minor, patch) (OPENMPT_API_VERSION >= OPENMPT_API_VERSION_MAKE((major), (minor), (patch))) + * #endif + * \endcode + */ +#define OPENMPT_API_VERSION_AT_LEAST(major, minor, patch) (OPENMPT_API_VERSION >= OPENMPT_API_VERSION_MAKE((major), (minor), (patch))) + +/*! \brief Check whether the libopenmpt API is before the provided version + * \since 0.3 + * \remarks Use the following shim if you need to support earlier libopenmpt versions: + * \code + * #include + * #if !defined(OPENMPT_API_VERSION_BEFORE) + * #define OPENMPT_API_VERSION_BEFORE(major, minor, patch) (OPENMPT_API_VERSION < OPENMPT_API_VERSION_MAKE((major), (minor), (patch))) + * #endif + * \endcode + */ +#define OPENMPT_API_VERSION_BEFORE(major, minor, patch) (OPENMPT_API_VERSION < OPENMPT_API_VERSION_MAKE((major), (minor), (patch))) + +#define OPENMPT_API_VERSION_HELPER_STRINGIZE(x) #x +#define OPENMPT_API_VERSION_STRINGIZE(x) OPENMPT_API_VERSION_HELPER_STRINGIZE(x) +#define OPENMPT_API_VERSION_STRING OPENMPT_API_VERSION_STRINGIZE(OPENMPT_API_VERSION_MAJOR) "." OPENMPT_API_VERSION_STRINGIZE(OPENMPT_API_VERSION_MINOR) "." OPENMPT_API_VERSION_STRINGIZE(OPENMPT_API_VERSION_PATCH) OPENMPT_API_VERSION_PREREL + +/*! + @} +*/ + +#endif /* LIBOPENMPT_VERSION_H */ diff --git a/libs/libopenmpt/lib/x86/libopenmpt.lib b/libs/libopenmpt/lib/x86/libopenmpt.lib new file mode 100644 index 000000000..c81c4c4ed Binary files /dev/null and b/libs/libopenmpt/lib/x86/libopenmpt.lib differ diff --git a/libs/libopenmpt/lib/x86/mingw/libopenmpt.dll.a b/libs/libopenmpt/lib/x86/mingw/libopenmpt.dll.a new file mode 100644 index 000000000..1d7637253 Binary files /dev/null and b/libs/libopenmpt/lib/x86/mingw/libopenmpt.dll.a differ diff --git a/libs/libopenmpt/lib/x86_64/libopenmpt.lib b/libs/libopenmpt/lib/x86_64/libopenmpt.lib new file mode 100644 index 000000000..216d93b45 Binary files /dev/null and b/libs/libopenmpt/lib/x86_64/libopenmpt.lib differ diff --git a/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a b/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a new file mode 100644 index 000000000..c6eda119f Binary files /dev/null and b/libs/libopenmpt/lib/x86_64/mingw/libopenmpt.dll.a differ diff --git a/libs/libpng-src/ANNOUNCE b/libs/libpng-src/ANNOUNCE index 02a24bd6b..ecf9c7043 100644 --- a/libs/libpng-src/ANNOUNCE +++ b/libs/libpng-src/ANNOUNCE @@ -1,65 +1,47 @@ +libpng 1.6.37 - April 14, 2019 +============================== -Libpng 1.2.46 - July 9, 2011 +This is a public release of libpng, intended for use in production code. -This is a public release of libpng, intended for use in production codes. -Files available for download: +Files available for download +---------------------------- -Source files with LF line endings (for Unix/Linux) and with a -"configure" script +Source files with LF line endings (for Unix/Linux): - libpng-1.2.46.tar.xz (LZMA-compressed, recommended) - libpng-1.2.46.tar.gz - libpng-1.2.46.tar.bz2 + * libpng-1.6.37.tar.xz (LZMA-compressed, recommended) + * libpng-1.6.37.tar.gz -Source files with LF line endings (for Unix/Linux) without the -"configure" script +Source files with CRLF line endings (for Windows): - libpng-1.2.46-no-config.tar.xz (LZMA-compressed, recommended) - libpng-1.2.46-no-config.tar.gz - libpng-1.2.46-no-config.tar.bz2 - -Source files with CRLF line endings (for Windows), without the -"configure" script - - lpng1246.zip - lpng1246.7z - lpng1246.tar.bz2 - -Project files - - libpng-1.2.46-project-netware.zip - libpng-1.2.46-project-wince.zip + * lp1637.7z (LZMA-compressed, recommended) + * lp1637.zip Other information: - libpng-1.2.46-README.txt - libpng-1.2.46-KNOWNBUGS.txt - libpng-1.2.46-LICENSE.txt - libpng-1.2.46-Y2K-compliance.txt - libpng-1.2.46-[previous version]-diff.txt + * README.md + * LICENSE.md + * AUTHORS.md + * TRADEMARK.md -Changes since the last public release (1.2.43): -version 1.2.45 [July 9, 2011] +Changes since the previous public release (version 1.6.36) +---------------------------------------------------------- - Fixed uninitialized memory read in png_format_buffer() (Bug - report by Frank Busse, related to CVE-2004-0421). - Pass "" instead of '\0' to png_default_error() in png_err(). This mistake - was introduced in libpng-1.2.20beta01. - Check for up->location !PNG_AFTER_IDAT when writing unknown chunks - before IDAT. - Ported bugfix in pngrtran.c from 1.5.3: when expanding a paletted image, - always expand to RGBA if transparency is present. - Check for integer overflow in png_set_rgb_to_gray(). - Check for sCAL chunk too short. - Added CMakeLists.txt, projects/xcode, and pnggccrd.c to EXTRA_DIST in - Makefile.am and Makefile.in - Udated copyright year to 2011. + * Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. + * Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. + * Fixed a memory leak in pngtest.c. + * Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in + contrib/pngminus; refactor. + * Changed the license of contrib/pngminus to MIT; refresh makefile and docs. + (Contributed by Willem van Schaik) + * Fixed a typo in the libpng license v2. + (Contributed by Miguel Ojeda) + * Added makefiles for AddressSanitizer-enabled builds. + * Cleaned up various makefiles. -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net. +Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net - -Glenn R-P +to subscribe. diff --git a/libs/libpng-src/AUTHORS b/libs/libpng-src/AUTHORS new file mode 100644 index 000000000..79a3d1036 --- /dev/null +++ b/libs/libpng-src/AUTHORS @@ -0,0 +1,45 @@ +PNG REFERENCE LIBRARY AUTHORS +============================= + +This is the list of PNG Reference Library ("libpng") Contributing +Authors, for copyright and licensing purposes. + + * Andreas Dilger + * Cosmin Truta + * Dave Martindale + * Eric S. Raymond + * Gilles Vollant + * Glenn Randers-Pehrson + * Greg Roelofs + * Guy Eric Schalnat + * James Yu + * John Bowler + * Kevin Bracey + * Magnus Holmgren + * Mandar Sahastrabuddhe + * Mans Rullgard + * Matt Sarett + * Mike Klein + * Paul Schmidt + * Sam Bushell + * Samuel Williams + * Simon-Pierre Cadieux + * Tim Wegner + * Tom Lane + * Tom Tanner + * Vadim Barkov + * Willem van Schaik + * Zhijie Liang + * Arm Holdings + - Richard Townsend + * Google Inc. + - Matt Sarett + - Mike Klein + +The build projects, the build scripts, the test scripts, and other +files in the "projects", "scripts" and "tests" directories, have other +copyright owners, but are released under the libpng license. + +Some files in the "contrib" directory, and some tools-generated files +that are distributed with libpng, have other copyright owners, and are +released under other open source licenses. diff --git a/libs/libpng-src/CHANGES b/libs/libpng-src/CHANGES index 1b7a30ee4..f0b0a9342 100644 --- a/libs/libpng-src/CHANGES +++ b/libs/libpng-src/CHANGES @@ -1,11 +1,13 @@ -/* CHANGES - changes for libpng -version 0.2 +version 0.1 [March 29, 1995] + initial work-in-progress release + +version 0.2 [April 1, 1995] added reader into png.h fixed small problems in stub file -version 0.3 +version 0.3 [April 8, 1995] added pull reader split up pngwrite.c to several files added pnglib.txt @@ -16,7 +18,7 @@ version 0.3 added K&R support added check for 64 KB blocks for 16 bit machines -version 0.4 +version 0.4 [April 26, 1995] cleaned up code and commented code simplified time handling into png_time created png_color_16 and png_color_8 to handle color needs @@ -27,28 +29,29 @@ version 0.4 cleaned up zTXt reader and writer (using zlib's Reset functions) split transformations into pngrtran.c and pngwtran.c -version 0.5 +version 0.5 [April 30, 1995] interfaced with zlib 0.8 fixed many reading and writing bugs saved using 3 spaces instead of tabs -version 0.6 +version 0.6 [May 1, 1995] + first beta release added png_large_malloc() and png_large_free() added png_size_t cleaned up some compiler warnings added png_start_read_image() -version 0.7 +version 0.7 [June 24, 1995] cleaned up lots of bugs finished dithering and other stuff added test program changed name from pnglib to libpng -version 0.71 [June, 1995] +version 0.71 [June 26, 1995] changed pngtest.png for zlib 0.93 fixed error in libpng.txt and example.c -version 0.8 +version 0.8 [August 20, 1995] cleaned up some bugs added png_set_filler() split up pngstub.c into pngmem.c, pngio.c, and pngerror.c @@ -62,191 +65,199 @@ version 0.8 changed external functions passing floats to doubles (k&r problems?) put all the configurable stuff in pngconf.h enabled png_set_shift to work with paletted images on read - added png_read_update_info() - updates info structure with - transformations + added png_read_update_info() - updates info structure with transformations -version 0.81 [August, 1995] +Version 0.81 [August, 1995] incorporated Tim Wegner's medium model code (thanks, Tim) -version 0.82 [September, 1995] +Version 0.82 [September, 1995] [unspecified changes] -version 0.85 [December, 1995] +Version 0.85 [December, 1995] added more medium model code (almost everything's a far) added i/o, error, and memory callback functions - fixed some bugs (16 bit, 4 bit interlaced, etc.) + fixed some bugs (16-bit, 4-bit interlaced, etc.) added first run progressive reader (barely tested) -version 0.86 [January, 1996] +Version 0.86 [January, 1996] fixed bugs improved documentation -version 0.87 [January, 1996] +Version 0.87 [January, 1996] fixed medium model bugs fixed other bugs introduced in 0.85 and 0.86 added some minor documentation -version 0.88 [January, 1996] +Version 0.88 [January, 1996] fixed progressive bugs replaced tabs with spaces cleaned up documentation added callbacks for read/write and warning/error functions -version 0.89 [July, 1996] - added new initialization API to make libpng work better with shared libs - we now have png_create_read_struct(), png_create_write_struct(), - png_create_info_struct(), png_destroy_read_struct(), and - png_destroy_write_struct() instead of the separate calls to - malloc and png_read_init(), png_info_init(), and png_write_init() - changed warning/error callback functions to fix bug - this means you - should use the new initialization API if you were using the old - png_set_message_fn() calls, and that the old API no longer exists - so that people are aware that they need to change their code - changed filter selection API to allow selection of multiple filters - since it didn't work in previous versions of libpng anyways - optimized filter selection code - fixed png_set_background() to allow using an arbitrary RGB color for - paletted images - fixed gamma and background correction for paletted images, so - png_correct_palette is not needed unless you are correcting an - external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED - in pngconf.h) - if nobody uses this, it may disappear in the future. - fixed bug with Borland 64K memory allocation (Alexander Lehmann) - fixed bug in interlace handling (Smarasderagd, I think) - added more error checking for writing and image to reduce invalid files - separated read and write functions so that they won't both be linked - into a binary when only reading or writing functionality is used - new pngtest image also has interlacing and zTXt - updated documentation to reflect new API +Version 0.89 [June 5, 1996] + Added new initialization API to make libpng work better with shared libs + we now have png_create_read_struct(), png_create_write_struct(), + png_create_info_struct(), png_destroy_read_struct(), and + png_destroy_write_struct() instead of the separate calls to + malloc and png_read_init(), png_info_init(), and png_write_init() + Changed warning/error callback functions to fix bug - this means you + should use the new initialization API if you were using the old + png_set_message_fn() calls, and that the old API no longer exists + so that people are aware that they need to change their code + Changed filter selection API to allow selection of multiple filters + since it didn't work in previous versions of libpng anyways + Optimized filter selection code + Fixed png_set_background() to allow using an arbitrary RGB color for + paletted images + Fixed gamma and background correction for paletted images, so + png_correct_palette is not needed unless you are correcting an + external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED + in pngconf.h) - if nobody uses this, it may disappear in the future. + Fixed bug with Borland 64K memory allocation (Alexander Lehmann) + Fixed bug in interlace handling (Smarasderagd, I think) + Added more error checking for writing and image to reduce invalid files + Separated read and write functions so that they won't both be linked + into a binary when only reading or writing functionality is used + New pngtest image also has interlacing and zTXt + Updated documentation to reflect new API -version 0.90 [January, 1997] - made CRC errors/warnings on critical and ancillary chunks configurable +Version 0.89c [June 17, 1996] + Bug fixes. + +Version 0.90 [January, 1997] + Made CRC errors/warnings on critical and ancillary chunks configurable libpng will use the zlib CRC routines by (compile-time) default - changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) - added external C++ wrapper statements to png.h (Gilles Dauphin) - allow PNG file to be read when some or all of file signature has already - been read from the beginning of the stream. ****This affects the size - of info_struct and invalidates all programs that use a shared libpng**** - fixed png_filler() declarations - fixed? background color conversions - fixed order of error function pointers to match documentation - current chunk name is now available in png_struct to reduce the number - of nearly identical error messages (will simplify multi-lingual - support when available) - try to get ready for unknown-chunk callback functions: - - previously read critical chunks are flagged, so the chunk handling - routines can determine if the chunk is in the right place - - all chunk handling routines have the same prototypes, so we will - be able to handle all chunks via a callback mechanism - try to fix Linux "setjmp" buffer size problems - removed png_large_malloc, png_large_free, and png_realloc functions. + Changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) + Added external C++ wrapper statements to png.h (Gilles Dauphin) + Allow PNG file to be read when some or all of file signature has already + been read from the beginning of the stream. ****This affects the size + of info_struct and invalidates all programs that use a shared libpng**** + Fixed png_filler() declarations + Fixed? background color conversions + Fixed order of error function pointers to match documentation + Current chunk name is now available in png_struct to reduce the number + of nearly identical error messages (will simplify multi-lingual + support when available) + Try to get ready for unknown-chunk callback functions: + - previously read critical chunks are flagged, so the chunk handling + routines can determine if the chunk is in the right place + - all chunk handling routines have the same prototypes, so we will + be able to handle all chunks via a callback mechanism + Try to fix Linux "setjmp" buffer size problems + Removed png_large_malloc, png_large_free, and png_realloc functions. -version 0.95 [March, 1997] - fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never - fixed bug in PNG file signature compares when start != 0 - changed parameter type of png_set_filler(...filler...) from png_byte - to png_uint_32 - added test for MACOS to ensure that both math.h and fp.h are not #included - added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) - added "packswap" transformation, which changes the endianness of - packed-pixel bytes (Kevin Bracey) - added "strip_alpha" transformation, which removes the alpha channel of - input images without using it (not necessarily a good idea) - added "swap_alpha" transformation, which puts the alpha channel in front - of the color bytes instead of after - removed all implicit variable tests which assume NULL == 0 (I think) - changed several variables to "png_size_t" to show 16/32-bit limitations - added new pCAL chunk read/write support - added experimental filter selection weighting (Greg Roelofs) - removed old png_set_rgbx() and png_set_xrgb() functions that have been - obsolete for about 2 years now (use png_set_filler() instead) - added macros to read 16- and 32-bit ints directly from buffer, to be - used only on those systems that support it (namely PowerPC and 680x0) - With some testing, this may become the default for MACOS/PPC systems. - only calculate CRC on data if we are going to use it - added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? - added macros for simple libpng debugging output selectable at compile time - removed PNG_READ_END_MODE in progressive reader (Smarasderagd) - more description of info_struct in libpng.txt and png.h - more instructions in example.c - more chunk types tested in pngtest.c - renamed pngrcb.c to pngset.c, and all png_read_ functions to be - png_set_. We now have corresponding png_get_ - functions in pngget.c to get information in info_ptr. This isolates - the application from the internal organization of png_info_struct - (good for shared library implementations). +Version 0.95 [March, 1997] + Fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never + Fixed bug in PNG file signature compares when start != 0 + Changed parameter type of png_set_filler(...filler...) from png_byte + to png_uint_32 + Added test for MACOS to ensure that both math.h and fp.h are not #included + Added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) + Added "packswap" transformation, which changes the endianness of + packed-pixel bytes (Kevin Bracey) + Added "strip_alpha" transformation, which removes the alpha channel of + input images without using it (not necessarily a good idea) + Added "swap_alpha" transformation, which puts the alpha channel in front + of the color bytes instead of after + Removed all implicit variable tests which assume NULL == 0 (I think) + Changed several variables to "png_size_t" to show 16/32-bit limitations + Added new pCAL chunk read/write support + Added experimental filter selection weighting (Greg Roelofs) + Removed old png_set_rgbx() and png_set_xrgb() functions that have been + obsolete for about 2 years now (use png_set_filler() instead) + Added macros to read 16- and 32-bit ints directly from buffer, to be + used only on those systems that support it (namely PowerPC and 680x0) + With some testing, this may become the default for MACOS/PPC systems. + Only calculate CRC on data if we are going to use it + Added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? + Added macros for simple libpng debugging output selectable at compile time + Removed PNG_READ_END_MODE in progressive reader (Smarasderagd) + More description of info_struct in libpng.txt and png.h + More instructions in example.c + More chunk types tested in pngtest.c + Renamed pngrcb.c to pngset.c, and all png_read_ functions to be + png_set_. We now have corresponding png_get_ + functions in pngget.c to get information in info_ptr. This isolates + the application from the internal organization of png_info_struct + (good for shared library implementations). -version 0.96 [May, 1997] - fixed serious bug with < 8bpp images introduced in 0.95 - fixed 256-color transparency bug (Greg Roelofs) - fixed up documentation (Greg Roelofs, Laszlo Nyul) - fixed "error" in pngconf.h for Linux setjmp() behaviour - fixed DOS medium model support (Tim Wegner) - fixed png_check_keyword() for case with error in static string text - added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) - added typecasts to quiet compiler errors - added more debugging info +Version 0.96 [May, 1997] + Fixed serious bug with < 8bpp images introduced in 0.95 + Fixed 256-color transparency bug (Greg Roelofs) + Fixed up documentation (Greg Roelofs, Laszlo Nyul) + Fixed "error" in pngconf.h for Linux setjmp() behavior + Fixed DOS medium model support (Tim Wegner) + Fixed png_check_keyword() for case with error in static string text + Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) + Added typecasts to quiet compiler errors + Added more debugging info -version 0.97 [January, 1998] - removed PNG_USE_OWN_CRC capability - relocated png_set_crc_action from pngrutil.c to pngrtran.c - fixed typecasts of "new_key", etc. (Andreas Dilger) - added RFC 1152 [sic] date support - fixed bug in gamma handling of 4-bit grayscale - added 2-bit grayscale gamma handling (Glenn R-P) - added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) - minor corrections in libpng.txt - added simple sRGB support (Glenn R-P) - easier conditional compiling, e.g. define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead - of having to edit pngconf.h (Glenn R-P) - fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) - added more conditions for png_do_background, to avoid changing - black pixels to background when a background is supplied and - no pixels are transparent - repaired PNG_NO_STDIO behaviour - tested NODIV support and made it default behaviour (Greg Roelofs) - added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) - regularized version numbering scheme and bumped shared-library major - version number to 2 to avoid problems with libpng 0.89 apps (Greg Roelofs) +Version 0.97 [January, 1998] + Removed PNG_USE_OWN_CRC capability + Relocated png_set_crc_action from pngrutil.c to pngrtran.c + Fixed typecasts of "new_key", etc. (Andreas Dilger) + Added RFC 1152 [sic] date support + Fixed bug in gamma handling of 4-bit grayscale + Added 2-bit grayscale gamma handling (Glenn R-P) + Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) + Minor corrections in libpng.txt + Added simple sRGB support (Glenn R-P) + Easier conditional compiling, e.g., + define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; + all configurable options can be selected from command-line instead + of having to edit pngconf.h (Glenn R-P) + Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) + Added more conditions for png_do_background, to avoid changing + black pixels to background when a background is supplied and + no pixels are transparent + Repaired PNG_NO_STDIO behavior + Tested NODIV support and made it default behavior (Greg Roelofs) + Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) + Regularized version numbering scheme and bumped shared-library major + version number to 2 to avoid problems with libpng 0.89 apps + (Greg Roelofs) -version 0.98 [January, 1998] - cleaned up some typos in libpng.txt and in code documentation - fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) - cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c - changed recommendation about file_gamma for PC images to .51 from .45, - in example.c and libpng.txt, added comments to distinguish between - screen_gamma, viewing_gamma, and display_gamma. - changed all references to RFC1152 to read RFC1123 and changed the - PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED - added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) - changed srgb_intent from png_byte to int to avoid compiler bugs +Version 0.98 [January, 1998] + Cleaned up some typos in libpng.txt and in code documentation + Fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) + Cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c + Changed recommendation about file_gamma for PC images to .51 from .45, + in example.c and libpng.txt, added comments to distinguish between + screen_gamma, viewing_gamma, and display_gamma. + Changed all references to RFC1152 to read RFC1123 and changed the + PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED + Added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) + Changed srgb_intent from png_byte to int to avoid compiler bugs -version 0.99 [January 30, 1998] - free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) - fixed a longstanding "packswap" bug in pngtrans.c - fixed some inconsistencies in pngconf.h that prevented compiling with - PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined - fixed some typos and made other minor rearrangement of libpng.txt (Andreas) - changed recommendation about file_gamma for PC images to .50 from .51 in - example.c and libpng.txt, and changed file_gamma for sRGB images to .45 - added a number of functions to access information from the png structure - png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) - added TARGET_MACOS similar to zlib-1.0.8 - define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined - added type casting to all png_malloc() function calls -version 0.99a [January 31, 1998] +Version 0.99 [January 30, 1998] + Free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) + Fixed a longstanding "packswap" bug in pngtrans.c + Fixed some inconsistencies in pngconf.h that prevented compiling with + PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined + Fixed some typos and made other minor rearrangement of libpng.txt (Andreas) + Changed recommendation about file_gamma for PC images to .50 from .51 in + example.c and libpng.txt, and changed file_gamma for sRGB images to .45 + Added a number of functions to access information from the png structure + png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) + Added TARGET_MACOS similar to zlib-1.0.8 + Define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined + Added type casting to all png_malloc() function calls + +Version 0.99a [January 31, 1998] Added type casts and parentheses to all returns that return a value.(Tim W.) -version 0.99b [February 4, 1998] + +Version 0.99b [February 4, 1998] Added type cast png_uint_32 on malloc function calls where needed. Changed type of num_hist from png_uint_32 to int (same as num_palette). Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. Renamed makefile.elf to makefile.lnx. -version 0.99c [February 7, 1998] + +Version 0.99c [February 7, 1998] More type casting. Removed erroneous overflow test in pngmem.c. Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. -version 0.99d [February 11, 1998] + +Version 0.99d [February 11, 1998] Renamed "far_to_near()" "png_far_to_near()" Revised libpng.3 Version 99c "buffered" operations didn't work as intended. Replaced them @@ -256,7 +267,8 @@ version 0.99d [February 11, 1998] Check for overlength tRNS chunk present when indexed-color PLTE is read. Cleaned up spelling errors in libpng.3/libpng.txt Corrected a problem with png_get_tRNS() which returned undefined trans array -version 0.99e [February 28, 1998] + +Version 0.99e [February 28, 1998] Corrected png_get_tRNS() again. Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". Touched up example.c to make more of it compileable, although the entire @@ -266,53 +278,59 @@ version 0.99e [February 28, 1998] Replaced pngtest.png with one created with zlib 1.1.1 Changed pngtest to report PASS even when file size is different (Jean-loup G.) Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) -version 0.99f [March 5, 1998] + +Version 0.99f [March 5, 1998] Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) Moved makefiles into a "scripts" directory, and added INSTALL instruction file Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) Added pointers to "note on libpng versions" in makefile.lnx and README Added row callback feature when reading and writing nonprogressive rows - and added a test of this feature in pngtest.c + and added a test of this feature in pngtest.c Added user transform callbacks, with test of the feature in pngtest.c -version 0.99g [March 6, 1998, morning] + +Version 0.99g [March 6, 1998, morning] Minor changes to pngtest.c to suppress compiler warnings. Removed "beta" language from documentation. -version 0.99h [March 6, 1998, evening] + +Version 0.99h [March 6, 1998, evening] Minor changes to previous minor changes to pngtest.c Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED - and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro + and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro Added user transform capability -version 1.00 [March 7, 1998] +Version 1.00 [March 7, 1998] Changed several typedefs in pngrutil.c Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) - replaced "while(1)" with "for(;;)" - added PNGARG() to prototypes in pngtest.c and removed some prototypes - updated some of the makefiles (Tom Lane) - changed some typedefs (s_start, etc.) in pngrutil.c - fixed dimensions of "short_months" array in pngwrite.c + Replaced "while(1)" with "for(;;)" + Added PNGARG() to prototypes in pngtest.c and removed some prototypes + Updated some of the makefiles (Tom Lane) + Changed some typedefs (s_start, etc.) in pngrutil.c + Fixed dimensions of "short_months" array in pngwrite.c Replaced ansi2knr.c with the one from jpeg-v6 -version 1.0.0 [March 8, 1998] +Version 1.0.0 [March 8, 1998] Changed name from 1.00 to 1.0.0 (Adam Costello) Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) -version 1.0.0a [March 9, 1998] + +Version 1.0.0a [March 9, 1998] Fixed three bugs in pngrtran.c to make gamma+background handling consistent - (Greg Roelofs) + (Greg Roelofs) Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz - for major, minor, and bugfix releases. This is 10001. (Adam Costello, - Tom Lane) + for major, minor, and bugfix releases. This is 10001. (Adam Costello, + Tom Lane) Make months range from 1-12 in png_convert_to_rfc1123 -version 1.0.0b [March 13, 1998] + +Version 1.0.0b [March 13, 1998] Quieted compiler complaints about two empty "for" loops in pngrutil.c Minor changes to makefile.s2x Removed #ifdef/#endif around a png_free() in pngread.c -version 1.0.1 [March 14, 1998] +Version 1.0.1 [March 14, 1998] Changed makefile.s2x to reduce security risk of using a relative pathname Fixed some typos in the documentation (Greg). Fixed a problem with value of "channels" returned by png_read_update_info() -version 1.0.1a [April 21, 1998] + +Version 1.0.1a [April 21, 1998] Optimized Paeth calculations by replacing abs() function calls with intrinsics plus other loop optimizations. Improves avg decoding speed by about 20%. Commented out i386istic "align" compiler flags in makefile.lnx. @@ -326,19 +344,24 @@ version 1.0.1a [April 21, 1998] Moved a misplaced pngrutil code block that truncates tRNS if it has more than num_palette entries -- test was done before num_palette was defined. Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). - Changed compiler flags in makefile.wat for better optimization (Pawel Mrochen). -version 1.0.1b [May 2, 1998] + Changed compiler flags in makefile.wat for better optimization + (Pawel Mrochen). + +Version 1.0.1b [May 2, 1998] Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). Relocated the png_composite macros from pngrtran.c to png.h (Greg). Added makefile.sco (contributed by Mike Hopkirk). Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. - More work on the Paeth-filtering, achieving imperceptible speedup (A Kleinert). - More work on loop optimization which may help when compiled with C++ compilers. + More work on the Paeth-filtering, achieving imperceptible speedup + (A Kleinert). + More work on loop optimization which may help when compiled with C++ + compilers. Added warnings when people try to use transforms they've defined out. Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) -version 1.0.1c [May 11, 1998] + +Version 1.0.1c [May 11, 1998] Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for filler bytes should have been 0xff instead of 0xf. Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. @@ -350,7 +373,8 @@ version 1.0.1c [May 11, 1998] to remove unwanted capabilities via the compile line Made some corrections to grammar (which, it's) in documentation (Greg). Corrected example.c, use of row_pointers in png_write_image(). -version 1.0.1d [May 24, 1998] + +Version 1.0.1d [May 24, 1998] Corrected several statements that used side effects illegally in pngrutil.c and pngtrans.c, that were introduced in version 1.0.1b Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) @@ -360,7 +384,8 @@ version 1.0.1d [May 24, 1998] Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) Changed several loops from count-down to count-up, for consistency. -version 1.0.1e [June 6, 1998] + +Version 1.0.1e [June 6, 1998] Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and added warnings when people try to set png_read_fn and png_write_fn in the same structure. @@ -377,9 +402,10 @@ version 1.0.1e [June 6, 1998] PNGTEST_DEBUG_MEM feature. Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). -version 1.0.2 [June 14, 1998] +Version 1.0.2 [June 14, 1998] Fixed two bugs in makefile.bor . -version 1.0.2a [December 30, 1998] + +Version 1.0.2a [December 30, 1998] Replaced and extended code that was removed from png_set_filler() in 1.0.1a. Fixed a bug in png_do_filler() that made it fail to write filler bytes in the left-most pixel of each row (Kevin Bracey). @@ -401,23 +427,26 @@ version 1.0.2a [December 30, 1998] Added png_get_copyright() and png_get_header_version() functions. Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c Added information about debugging in libpng.txt and libpng.3 . - Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and makefile.sco. + Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and + makefile.sco. Removed lines after Dynamic Dependencies" in makefile.aco . Revised makefile.dec to make a shared library (Jeremie Petit). Removed trailing blanks from all files. -version 1.0.2a [January 6, 1999] + +Version 1.0.2a [January 6, 1999] Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h Added "if" tests to silence complaints about unused png_ptr in png.h and png.c Changed "check_if_png" function in example.c to return true (nonzero) if PNG. Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() which is obsolete. -version 1.0.3 [January 14, 1999] +Version 1.0.3 [January 14, 1999] Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. -version 1.0.3a [August 12, 1999] + +Version 1.0.3a [August 12, 1999] Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning - if an attempt is made to read an interlaced image when it's not supported. + if an attempt is made to read an interlaced image when it's not supported. Added check if png_ptr->trans is defined before freeing it in pngread.c Modified the Y2K statement to include versions back to version 0.71 Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c @@ -425,7 +454,7 @@ version 1.0.3a [August 12, 1999] Replaced leading blanks with tab characters in makefile.hux Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. Changed (float)red and (float)green to (double)red, (double)green - in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. + in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). Updated documentation to refer to the PNG-1.2 specification. @@ -442,13 +471,15 @@ version 1.0.3a [August 12, 1999] Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be consistent with PNG-1.2, and allow variance of 500 before complaining. Added assembler code contributed by Intel in file pngvcrd.c and modified - makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, Gilles Vollant) + makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, + Gilles Vollant) Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. Added some aliases for png_set_expand() in pngrtran.c, namely png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() (Greg Roelofs, in "PNG: The Definitive Guide"). Added makefile.beo for BEOS on X86, contributed by Sander Stok. -version 1.0.3b [August 26, 1999] + +Version 1.0.3b [August 26, 1999] Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h Changed leading blanks to tabs in all makefiles. Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. @@ -460,12 +491,13 @@ version 1.0.3b [August 26, 1999] negative shift distance, whose results are undefined in the C language. Added a check in pngset.c to prevent writing multiple tIME chunks. Added a check in pngwrite.c to detect invalid small window_bits sizes. -version 1.0.3d [September 4, 1999] + +Version 1.0.3d [September 4, 1999] Fixed type casting of igamma in pngrutil.c Added new png_expand functions to scripts/pngdef.pas and pngos2.def Added a demo read_user_transform_fn that examines the row filters in pngtest.c -version 1.0.4 [September 24, 1999] +Version 1.0.4 [September 24, 1999, not distributed publicly] Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h Made several minor corrections to pngtest.c @@ -479,24 +511,31 @@ version 1.0.4 [September 24, 1999] assembler code) and makefile.vcwin32 (doesn't). Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) Added a copy of pngnow.png to the distribution. -version 1.0.4a [September 25, 1999] + +Version 1.0.4a [September 25, 1999] Increase max_pixel_depth in pngrutil.c if a user transform needs it. Changed several division operations to right-shifts in pngvcrd.c -version 1.0.4b [September 30, 1999] + +Version 1.0.4b [September 30, 1999] Added parentheses in line 3732 of pngvcrd.c Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 -version 1.0.4c [October 1, 1999] + +Version 1.0.4c [October 1, 1999] Added a "png_check_version" function in png.c and pngtest.c that will generate a helpful compiler error if an old png.h is found in the search path. Changed type of png_user_transform_depth|channels from int to png_byte. -version 1.0.4d [October 6, 1999] + Added "Libpng is OSI Certified Open Source Software" statement to png.h + +Version 1.0.4d [October 6, 1999] Changed 0.45 to 0.45455 in png_set_sRGB() Removed unused PLTE entries from pngnow.png Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. -version 1.0.4e [October 10, 1999] + +Version 1.0.4e [October 10, 1999] Fixed sign error in pngvcrd.c (Greg Roelofs) Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) -version 1.0.4f [October 15, 1999] + +Version 1.0.4f [October 15, 1999] Surrounded example.c code with #if 0 .. #endif to prevent people from inadvertently trying to compile it. Changed png_get_header_version() from a function to a macro in png.h @@ -504,9 +543,10 @@ version 1.0.4f [October 15, 1999] Removed some pointless "ptr = NULL" in pngmem.c Added a "contrib" directory containing the source code from Greg's book. -version 1.0.5 [October 15, 1999] +Version 1.0.5 [October 15, 1999] Minor editing of the INSTALL and README files. -version 1.0.5a [October 23, 1999] + +Version 1.0.5a [October 23, 1999] Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) Further optimization and bugfix of pngvcrd.c @@ -514,14 +554,16 @@ version 1.0.5a [October 23, 1999] text_ptr structure. Instead, it makes its own copy. Created separate write_end_info_struct in pngtest.c for a more severe test. Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. -version 1.0.5b [November 23, 1999] + +Version 1.0.5b [November 23, 1999] Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and PNG_FLAG_WROTE_tIME from flags to mode. Added png_write_info_before_PLTE() function. Fixed some typecasting in contrib/gregbook/*.c Updated scripts/makevms.com and added makevms.com to contrib/gregbook and contrib/pngminus (Martin Zinser) -version 1.0.5c [November 26, 1999] + +Version 1.0.5c [November 26, 1999] Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr. Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to accommodate making DLL's: Moved usr_png_ver from global variable to function @@ -534,21 +576,23 @@ version 1.0.5c [November 26, 1999] Removed some extraneous "-I" from contrib/pngminus/makefile.std Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 -version 1.0.5d [November 29, 1999] + +Version 1.0.5d [November 29, 1999] Add type cast (png_const_charp) two places in png.c Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available to applications a macro "PNG_USE_LOCAL_ARRAYS". - Remove all the new declarations with #ifdef/#endif when + comment out (with #ifdef) all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. Added PNG_EXPORT_VAR macro to accommodate making DLL's. -version 1.0.5e [November 30, 1999] + +Version 1.0.5e [November 30, 1999] Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text structure; refactored the inflate/deflate support to make adding new chunks with trailing compressed parts easier in the future, and added new functions png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang + NOTE: Applications that write text chunks MUST define png_text->lang before calling png_set_text(). It must be set to NULL if you want to write tEXt or zTXt chunks. If you want your application to be able to run with older versions of libpng, use @@ -563,18 +607,21 @@ version 1.0.5e [November 30, 1999] PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED macros, leaving the separate macros also available. Removed comments on #endifs at the end of many short, non-nested #if-blocks. -version 1.0.5f [December 6, 1999] + +Version 1.0.5f [December 6, 1999] Changed makefile.solaris to issue a warning about potential problems when the ucb "ld" is in the path ahead of the ccs "ld". Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. Added sCAL chunk support (Eric S. Raymond). -version 1.0.5g [December 7, 1999] + +Version 1.0.5g [December 7, 1999] Fixed "png_free_spallettes" typo in png.h Added code to handle new chunks in pngpread.c Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block Added "translated_key" to png_text structure and png_write_iTXt(). Added code in pngwrite.c to work around a newly discovered zlib bug. -version 1.0.5h [December 10, 1999] + +Version 1.0.5h [December 10, 1999] NOTE: regarding the note for version 1.0.5e, the following must also be included in your code: png_text[i].translated_key = NULL; @@ -582,7 +629,8 @@ version 1.0.5h [December 10, 1999] Option to eliminate all floating point support was added. Some new fixed-point functions such as png_set_gAMA_fixed() were added. Expanded tabs and removed trailing blanks in source files. -version 1.0.5i [December 13, 1999] + +Version 1.0.5i [December 13, 1999] Added some type casts to silence compiler warnings. Renamed "png_free_spalette" to "png_free_spalettes" for consistency. Removed leading blanks from a #define in pngvcrd.c @@ -594,7 +642,8 @@ version 1.0.5i [December 13, 1999] Added png_free_hIST() function. Various patches to fix bugs in the sCAL and integer cHRM processing, and to add some convenience macros for use with sCAL. -version 1.0.5j [December 21, 1999] + +Version 1.0.5j [December 21, 1999] Changed "unit" parameter of png_write_sCAL from png_byte to int, to work around buggy compilers. Added new type "png_fixed_point" for integers that hold float*100000 values @@ -610,7 +659,8 @@ version 1.0.5j [December 21, 1999] and to write the iTXt chunk after IDAT if it appears in the end_ptr. Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) Reversed the order of trying to write floating-point and fixed-point gAMA. -version 1.0.5k [December 27, 1999] + +Version 1.0.5k [December 27, 1999] Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" Added png_handle_as_unknown() function (Glenn) Added png_free_chunk_list() function and chunk_list and num_chunk_list members @@ -621,33 +671,41 @@ version 1.0.5k [December 27, 1999] Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). -version 1.0.5l [January 1, 2000] + +Version 1.0.5l [January 1, 2000] Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() for setting a callback function to handle unknown chunks and for retrieving the associated user pointer (Glenn). -version 1.0.5m [January 7, 2000] + +Version 1.0.5m [January 7, 2000] Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). -version 1.0.5n [January 9, 2000] + +Version 1.0.5n [January 9, 2000] Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its own memory for info_ptr->palette. This makes it safe for the calling application to free its copy of the palette any time after it calls png_set_PLTE(). -version 1.0.5o [January 20, 2000] + +Version 1.0.5o [January 20, 2000] Cosmetic changes only (removed some trailing blanks and TABs) -version 1.0.5p [January 31, 2000] + +Version 1.0.5p [January 31, 2000] Renamed pngdll.mak to makefile.bd32 Cosmetic changes in pngtest.c -version 1.0.5q [February 5, 2000] + +Version 1.0.5q [February 5, 2000] Relocated the makefile.solaris warning about PATH problems. Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) Revised makefile.gcmmx Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros -version 1.0.5r [February 7, 2000] + +Version 1.0.5r [February 7, 2000] Removed superfluous prototype for png_get_itxt from png.h Fixed a bug in pngrtran.c that improperly expanded the background color. Return *num_text=0 from png_get_text() when appropriate, and fix documentation of png_get_text() in libpng.txt/libpng.3. -version 1.0.5s [February 18, 2000] + +Version 1.0.5s [February 18, 2000] Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the new error handler that's planned for the next libpng release, and changed example.c, pngtest.c, and contrib programs to use this macro. @@ -666,7 +724,8 @@ version 1.0.5s [February 18, 2000] Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). Modified png_read_png() to allocate info_ptr->row_pointers only if it hasn't already been allocated. -version 1.0.5t [March 4, 2000] + +Version 1.0.5t [March 4, 2000] Changed png_jmp_env() migration aiding macro to png_jmpbuf(). Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when @@ -675,13 +734,15 @@ version 1.0.5t [March 4, 2000] a 24-bit visual if one is available, and to allow abbreviated options. Files in contrib/pngminus were revised to use the png_jmpbuf() macro. Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s -version 1.0.5u [March 5, 2000] + +Version 1.0.5u [March 5, 2000] Simplified the code that detects old png.h in png.c and pngtest.c Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) Increased precision of rgb_to_gray calculations from 8 to 15 bits and added png_set_rgb_to_gray_fixed() function. Added makefile.bc32 (32-bit Borland C++, C mode) -version 1.0.5v [March 11, 2000] + +Version 1.0.5v [March 11, 2000] Added some parentheses to the png_jmpbuf macro definition. Updated references to the zlib home page, which has moved to freesoftware.com. Corrected bugs in documentation regarding png_read_row() and png_write_row(). @@ -689,10 +750,11 @@ version 1.0.5v [March 11, 2000] Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) -version 1.0.6 [March 20, 2000] +Version 1.0.6 [March 20, 2000] Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c Added makefile.sggcc (SGI IRIX with gcc) -version 1.0.6d [April 7, 2000] + +Version 1.0.6d [April 7, 2000] Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO Added data_length parameter to png_decompress_chunk() function Revised documentation to remove reference to abandoned png_free_chnk functions @@ -701,7 +763,8 @@ version 1.0.6d [April 7, 2000] Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). -version 1.0.6e [April 9, 2000] + +Version 1.0.6e [April 9, 2000] Added png_data_freer() function. In the code that checks for over-length tRNS chunks, added check of info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) @@ -712,25 +775,29 @@ version 1.0.6e [April 9, 2000] is defined. Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c and mentioned the purposes of the two macros in libpng.txt/libpng.3. -version 1.0.6f [April 14, 2000] + +Version 1.0.6f [April 14, 2000] Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. Add checks in png_set_text() for NULL members of the input text structure. Revised libpng.txt/libpng.3. - Removed superfluous prototype for png_set_itxt from png.h + Removed superfluous prototype for png_set_iTXt from png.h Removed "else" from pngread.c, after png_error(), and changed "0" to "length". Changed several png_errors about malformed ancillary chunks to png_warnings. -version 1.0.6g [April 24, 2000] + +Version 1.0.6g [April 24, 2000] Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. Relocated paragraph about png_set_background() in libpng.3/libpng.txt and other revisions (Matthias Benckmann) Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and png_ptr members to restore binary compatibility with libpng-1.0.5 (breaks compatibility with libpng-1.0.6). -version 1.0.6h [April 24, 2000] + +Version 1.0.6h [April 24, 2000] Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) This is a temporary change for test purposes. -version 1.0.6i [May 2, 2000] + +Version 1.0.6i [May 2, 2000] Rearranged some members at the end of png_info and png_struct, to put unknown_chunks_num and free_me within the original size of the png_structs and free_me, png_read_user_fn, and png_free_fn within the original png_info, @@ -755,22 +822,25 @@ version 1.0.6i [May 2, 2000] generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED was not defined. Added makefile.intel and updated makefile.watcom (Pawel Mrochen) -version 1.0.6j [May 3, 2000] + +Version 1.0.6j [May 3, 2000] Overloaded png_read_init() and png_write_init() with macros that convert calls to png_read_init_2() or png_write_init_2() that check the version and structure sizes. -version 1.0.7beta11 [May 7, 2000] + +Version 1.0.7beta11 [May 7, 2000] Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes which are no longer used. Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is - defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED + defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED is defined. Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory overrun when old applications fill the info_ptr->text structure directly. Added PNGAPI macro, and added it to the definitions of all exported functions. Relocated version macro definitions ahead of the includes of zlib.h and pngconf.h in png.h. -version 1.0.7beta12 [May 12, 2000] + +Version 1.0.7beta12 [May 12, 2000] Revised pngset.c to avoid a problem with expanding the png_debug macro. Deleted some extraneous defines from pngconf.h Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. @@ -778,7 +848,8 @@ version 1.0.7beta12 [May 12, 2000] Added png_access_version_number() function. Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). Expanded libpng.3/libpng.txt information about png_data_freer(). -version 1.0.7beta14 [May 17, 2000] (beta13 was not published) + +Version 1.0.7beta14 [May 17, 2000] (beta13 was not published) Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as warnings instead of errors, as pngrutil.c does. Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() @@ -790,7 +861,8 @@ version 1.0.7beta14 [May 17, 2000] (beta13 was not published) Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. Added png_set_invalid() function. Fixed incorrect illustrations of png_destroy_write_struct() in example.c. -version 1.0.7beta15 [May 30, 2000] + +Version 1.0.7beta15 [May 30, 2000] Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce fewer error messages. Rearranged checks for Z_OK to check the most likely path first in pngpread.c @@ -802,9 +874,11 @@ version 1.0.7beta15 [May 30, 2000] Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c Set each pointer to NULL after freeing it in png_free_data(). Worked around a problem in pngconf.h; AIX's strings.h defines an "index" - macro that conflicts with libpng's png_color_16.index. (Dimitri Papadapoulos) + macro that conflicts with libpng's png_color_16.index. (Dimitri + Papadapoulos) Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). -version 1.0.7beta16 [June 4, 2000] + +Version 1.0.7beta16 [June 4, 2000] Revised the workaround of AIX string.h "index" bug. Added a check for overlength PLTE chunk in pngrutil.c. Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer @@ -814,49 +888,58 @@ version 1.0.7beta16 [June 4, 2000] Added PNG_USE_DLL macro. Revised the copyright/disclaimer/license notice. Added contrib/msvctest directory -version 1.0.7rc1 [June 9, 2000] + +Version 1.0.7rc1 [June 9, 2000] Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) Added contrib/visupng directory (Willem van Schaik) -version 1.0.7beta18 [June 23, 2000] + +Version 1.0.7beta18 [June 23, 2000] Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ and do not redefine PNGAPI if it is passed in via a compiler directive. Revised visupng/PngFile.c to remove returns from within the Try block. Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. Updated contrib/visupng/cexcept.h to version 1.0.0. Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. -version 1.0.7rc2 [June 28, 2000] + +Version 1.0.7rc2 [June 28, 2000] Updated license to include disclaimers required by UCITA. Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. -version 1.0.7 [July 1, 2000] +Version 1.0.7 [July 1, 2000] Revised the definition of "trans_values" in libpng.3/libpng.txt -version 1.0.8beta1 [July 8, 2000] + +Version 1.0.8beta1 [July 8, 2000] Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and - pngwutil.c. + pngwutil.c. Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. Removed unused "#include " from png.c Added WindowsCE support. Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. -version 1.0.8beta2 [July 10, 2000] + +Version 1.0.8beta2 [July 10, 2000] Added project files to the wince directory and made further revisions - of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. -version 1.0.8beta3 [July 11, 2000] + of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. + +Version 1.0.8beta3 [July 11, 2000] Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() - for indexed-color input files to avoid potential double-freeing trans array - under some unusual conditions; problem was introduced in version 1.0.6f. + for indexed-color input files to avoid potential double-freeing trans array + under some unusual conditions; problem was introduced in version 1.0.6f. Further revisions to pngtest.c and files in the wince subdirectory. -version 1.0.8beta4 [July 14, 2000] + +Version 1.0.8beta4 [July 14, 2000] Added the files pngbar.png and pngbar.jpg to the distribution. Added makefile.cygwin, and cygwin support in pngconf.h Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) -version 1.0.8rc1 [July 16, 2000] + +Version 1.0.8rc1 [July 16, 2000] Revised png_debug() macros and statements to eliminate compiler warnings. -version 1.0.8 [July 24, 2000] +Version 1.0.8 [July 24, 2000] Added png_flush() in pngwrite.c, after png_write_IEND(). Updated makefile.hpux to build a shared library. -version 1.0.9beta1 [November 10, 2000] + +Version 1.0.9beta1 [November 10, 2000] Fixed typo in scripts/makefile.hpux Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) @@ -875,59 +958,72 @@ version 1.0.9beta1 [November 10, 2000] Revised makefile.cygwin Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). -version 1.0.9beta2 [November 19, 2000] + +Version 1.0.9beta2 [November 19, 2000] Renamed the "dll" subdirectory "projects". Added borland project files to "projects" subdirectory. Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. Add error message in png_set_compression_buffer_size() when malloc fails. -version 1.0.9beta3 [November 23, 2000] + +Version 1.0.9beta3 [November 23, 2000] Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. Removed the png_flush() in pngwrite.c that crashes some applications that don't set png_output_flush_fn. Added makefile.macosx and makefile.aix to scripts directory. -version 1.0.9beta4 [December 1, 2000] + +Version 1.0.9beta4 [December 1, 2000] Change png_chunk_warning to png_warning in png_check_keyword(). Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). -version 1.0.9beta5 [December 15, 2000] + +Version 1.0.9beta5 [December 15, 2000] Added support for filter method 64 (for PNG datastreams embedded in MNG). -version 1.0.9beta6 [December 18, 2000] + +Version 1.0.9beta6 [December 18, 2000] Revised png_set_filter() to accept filter method 64 when appropriate. Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to help prevent applications from using MNG features in PNG datastreams. Added png_permit_mng_features() function. Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". -version 1.0.9rc1 [December 23, 2000] + +Version 1.0.9rc1 [December 23, 2000] Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c Fixed error handling of unknown compression type in png_decompress_chunk(). In pngconf.h, define __cdecl when _MSC_VER is defined. -version 1.0.9beta7 [December 28, 2000] + +Version 1.0.9beta7 [December 28, 2000] Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. Revised memory management in png_set_hIST and png_handle_hIST in a backward compatible manner. PLTE and tRNS were revised similarly. Revised the iCCP chunk reader to ignore trailing garbage. -version 1.0.9beta8 [January 12, 2001] + +Version 1.0.9beta8 [January 12, 2001] Moved pngasmrd.h into pngconf.h. Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. -version 1.0.9beta9 [January 15, 2001] + +Version 1.0.9beta9 [January 15, 2001] Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to wince and msvc project module definition files. Minor revision of makefile.cygwin. Fixed bug with progressive reading of narrow interlaced images in pngpread.c -version 1.0.9beta10 [January 16, 2001] + +Version 1.0.9beta10 [January 16, 2001] Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. Fixed "png_mmx_supported" typo in project definition files. -version 1.0.9beta11 [January 19, 2001] + +Version 1.0.9beta11 [January 19, 2001] Updated makefile.sgi to make shared library. Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED by default, for the benefit of DLL forward compatibility. These will be re-enabled in version 1.2.0. -version 1.0.9rc2 [January 22, 2001] + +Version 1.0.9rc2 [January 22, 2001] Revised cygwin support. -version 1.0.9 [January 31, 2001] +Version 1.0.9 [January 31, 2001] Added check of cygwin's ALL_STATIC in pngconf.h Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. -version 1.0.10beta1 [March 14, 2001] + +Version 1.0.10beta1 [March 14, 2001] Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. Reformatted libpng.3 to eliminate bad line breaks. Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c @@ -940,33 +1036,39 @@ version 1.0.10beta1 [March 14, 2001] Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) Added warnings when retrieving or setting gamma=0. Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). -version 1.0.10rc1 [March 23, 2001] + +Version 1.0.10rc1 [March 23, 2001] Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, and png_strlen. Revised png_mmx_supported() function in pnggccrd.c to return proper value. Fixed bug in progressive reading (pngpread.c) with small images (height < 8). -version 1.0.10 [March 30, 2001] +Version 1.0.10 [March 30, 2001] Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin Added beos project files (Chris Herborth) -version 1.0.11beta1 [April 3, 2001] + +Version 1.0.11beta1 [April 3, 2001] Added type casts on several png_malloc() calls (Dimitri Papadapoulos). Removed a no-longer needed AIX work-around from pngconf.h Changed several "//" single-line comments to C-style in pnggccrd.c -version 1.0.11beta2 [April 11, 2001] + +Version 1.0.11beta2 [April 11, 2001] Removed PNGAPI from several functions whose prototypes did not have PNGAPI. Updated scripts/pngos2.def -version 1.0.11beta3 [April 14, 2001] + +Version 1.0.11beta3 [April 14, 2001] Added checking the results of many instances of png_malloc() for NULL -version 1.0.11beta4 [April 20, 2001] + +Version 1.0.11beta4 [April 20, 2001] Undid the changes from version 1.0.11beta3. Added a check for NULL return from user's malloc_fn(). Removed some useless type casts of the NULL pointer. Added makefile.netbsd -version 1.0.11 [April 27, 2001] +Version 1.0.11 [April 27, 2001] Revised makefile.netbsd -version 1.0.12beta1 [May 14, 2001] + +Version 1.0.12beta1 [May 14, 2001] Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. @@ -974,66 +1076,76 @@ version 1.0.12beta1 [May 14, 2001] libpng will reallocate the png_struct and info_struct if they are too small. This retains future binary compatibility for old applications written for libpng-0.88 and earlier. -version 1.2.0beta1 [May 6, 2001] + +Version 1.2.0beta1 [May 6, 2001] Bumped DLLNUM to 2. Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED by default. Added runtime selection of MMX features. Added png_set_strip_error_numbers function and related macros. -version 1.2.0beta2 [May 7, 2001] + +Version 1.2.0beta2 [May 7, 2001] Finished merging 1.2.0beta1 with version 1.0.11 Added a check for attempts to read or write PLTE in grayscale PNG datastreams. -version 1.2.0beta3 [May 17, 2001] + +Version 1.2.0beta3 [May 17, 2001] Enabled user memory function by default. Modified png_create_struct so it passes user mem_ptr to user memory allocator. Increased png_mng_features flag from png_byte to png_uint_32. Bumped shared-library (so-number) and dll-number to 3. -version 1.2.0beta4 [June 23, 2001] + +Version 1.2.0beta4 [June 23, 2001] Check for missing profile length field in iCCP chunk and free chunk_data - in case of truncated iCCP chunk. + in case of truncated iCCP chunk. Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc Bumped dll-number from 2 to 3 in makefile.cygwin Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly - if user attempts to run it on an 8-bit display. + if user attempts to run it on an 8-bit display. Updated contrib/gregbook Use png_malloc instead of png_zalloc to allocate palette in pngset.c Updated makefile.ibmc Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes - of png_write_oFFS width and height from png_uint_32 to png_int_32. + of png_write_oFFS width and height from png_uint_32 to png_int_32. Updated example.c Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c -version 1.2.0beta5 [August 8, 2001] + +Version 1.2.0beta5 [August 8, 2001] Revised contrib/gregbook Revised makefile.gcmmx Revised pnggccrd.c to conditionally compile some thread-unsafe code only - when PNG_THREAD_UNSAFE_OK is defined. + when PNG_THREAD_UNSAFE_OK is defined. Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with - value exceeding 2^bit_depth-1 + value exceeding 2^bit_depth-1 Revised makefile.sgi and makefile.sggcc Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c Removed restriction that do_invert_mono only operate on 1-bit opaque files -version 1.2.0 [September 1, 2001] +Version 1.2.0 [September 1, 2001] Changed a png_warning() to png_debug() in pnggccrd.c Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). -version 1.2.1beta1 [October 19, 2001] + +Version 1.2.1beta1 [October 19, 2001] Revised makefile.std in contrib/pngminus Include background_1 in png_struct regardless of gamma support. Revised makefile.netbsd and makefile.macosx, added makefile.darwin. Revised example.c to provide more details about using row_callback(). -version 1.2.1beta2 [October 25, 2001] + +Version 1.2.1beta2 [October 25, 2001] Added type cast to each NULL appearing in a function call, except for WINCE functions. Added makefile.so9. -version 1.2.1beta3 [October 27, 2001] + +Version 1.2.1beta3 [October 27, 2001] Removed type casts from all NULLs. Simplified png_create_struct_2(). -version 1.2.1beta4 [November 7, 2001] + +Version 1.2.1beta4 [November 7, 2001] Revised png_create_info_struct() and png_creat_struct_2(). Added error message if png_write_info() was omitted. Type cast NULLs appearing in function calls when _NO_PROTO or PNG_TYPECAST_NULL is defined. -version 1.2.1rc1 [November 24, 2001] + +Version 1.2.1rc1 [November 24, 2001] Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL is defined. Changed typecast of "size" argument to png_size_t in pngmem.c calls to @@ -1042,14 +1154,16 @@ version 1.2.1rc1 [November 24, 2001] Updated makefile.sgi to recognize LIBPATH and INCPATH. Updated various makefiles so "make clean" does not remove previous major version of the shared library. -version 1.2.1rc2 [December 4, 2001] + +Version 1.2.1rc2 [December 4, 2001] Always allocate 256-entry internal palette, hist, and trans arrays, to avoid out-of-bounds memory reference caused by invalid PNG datastreams. Added a check for prefix_length > data_length in iCCP chunk handler. -version 1.2.1 [December 7, 2001] +Version 1.2.1 [December 7, 2001] None. -version 1.2.2beta1 [February 22, 2002] + +Version 1.2.2beta1 [February 22, 2002] Fixed a bug with reading the length of iCCP profiles (Larry Reeves). Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h @@ -1059,13 +1173,15 @@ version 1.2.2beta1 [February 22, 2002] Revised calls to png_create_read_struct() and png_create_write_struct() for simpler debugging. Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) -version 1.2.2beta2 [February 23, 2002] + +Version 1.2.2beta2 [February 23, 2002] Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. Check for invalid image dimensions in png_get_IHDR. Added missing "fi;" in the install target of the SGI makefiles. Added install-static to all makefiles that make shared libraries. Always do gamma compensation when image is partially transparent. -version 1.2.2beta3 [March 7, 2002] + +Version 1.2.2beta3 [March 7, 2002] Compute background.gray and background_1.gray even when color_type is RGB in case image gets reduced to gray later. Modified shared-library makefiles to install pkgconfig/libpngNN.pc. @@ -1075,12 +1191,14 @@ version 1.2.2beta3 [March 7, 2002] Added install-shared target to all makefiles that make shared libraries. Stopped a double free of palette, hist, and trans when not using free_me. Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. -version 1.2.2beta4 [March 8, 2002] + +Version 1.2.2beta4 [March 8, 2002] Compute background.gray and background_1.gray even when color_type is RGB in case image gets reduced to gray later (Jason Summers). Relocated a misplaced /bin/rm in the "install-shared" makefile targets Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. -version 1.2.2beta5 [March 26, 2002] + +Version 1.2.2beta5 [March 26, 2002] Added missing PNGAPI to several function definitions. Check for invalid bit_depth or color_type in png_get_IHDR(), and check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). @@ -1089,33 +1207,45 @@ version 1.2.2beta5 [March 26, 2002] Changed "()" to "{}" in scripts/libpng.pc.in. Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so -version 1.2.2beta6 [March 31, 2002] -version 1.0.13beta1 [March 31, 2002] + +Version 1.2.2beta6 [March 31, 2002] + +Version 1.0.13beta1 [March 31, 2002] Prevent png_zalloc() from trying to memset memory that it failed to acquire. Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). Ensure that the right function (user or default) is used to free the png_struct after an error in png_create_read_struct_2(). -version 1.2.2rc1 [April 7, 2002] -version 1.0.13rc1 [April 7, 2002] + +Version 1.2.2rc1 [April 7, 2002] + +Version 1.0.13rc1 [April 7, 2002] Save the ebx register in pnggccrd.c (Sami Farin) Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). Updated makefiles to put headers in include/libpng and remove old include/*.h. -version 1.2.2 [April 15, 2002] -version 1.0.13 [April 15, 2002] +Version 1.2.2 [April 15, 2002] + +Version 1.0.13 [April 15, 2002] Revised description of png_set_filter() in libpng.3/libpng.txt. Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd -version 1.0.13patch01 [April 17, 2002] -version 1.2.2patch01 [April 17, 2002] - Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc - Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install + +Version 1.0.13patch01 [April 17, 2002] + +Version 1.2.2patch01 [April 17, 2002] + Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and + makefile.sggcc + Fixed VER -> PNGVER typo in makefile.macosx and added install-static to + install Added install: target to makefile.32sunu and makefile.64sunu -version 1.0.13patch03 [April 18, 2002] -version 1.2.2patch03 [April 18, 2002] + +Version 1.0.13patch03 [April 18, 2002] + +Version 1.2.2patch03 [April 18, 2002] Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng subdirectory to libpngNN subdirectory without the full pathname. Moved generation of libpng.pc from "install" to "all" in 15 makefiles. -version 1.2.3rc1 [April 28, 2002] + +Version 1.2.3rc1 [April 28, 2002] Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) Fixed bug with $prefix, should be $(prefix) in makefile.hpux. @@ -1127,70 +1257,83 @@ version 1.2.3rc1 [April 28, 2002] to put one in their application. Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and removed them from module definition files. -version 1.2.3rc2 [May 1, 2002] + +Version 1.2.3rc2 [May 1, 2002] Fixed bug in reporting number of channels in pngget.c and pngset.c, that was introduced in version 1.2.2beta5. Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), png_default_flush(), and png_push_fill_buffer() and included them in module definition files. Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. -version 1.2.3rc3 [May 1, 2002] + +Version 1.2.3rc3 [May 1, 2002] Revised prototype for png_default_flush() Remove old libpng.pc and libpngNN.pc before installing new ones. -version 1.2.3rc4 [May 2, 2002] + +Version 1.2.3rc4 [May 2, 2002] Typos in *.def files (png_default_read|write -> png_default_read|write_data) In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc - Added libpng-config and libpngNN-config and modified makefiles to install them. + Added libpng-config and libpngNN-config and modified makefiles to install + them. Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp -version 1.2.3rc5 [May 11, 2002] + +Version 1.2.3rc5 [May 11, 2002] Changed "error" and "message" in prototypes to "error_message" and "warning_message" to avoid namespace conflict. Revised 15 makefiles to build libpng-config from libpng-config-*.in Once more restored png_zalloc and png_zfree to regular nonexported form. Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer - to nonexported form, but with PNGAPI, and removed them from module def files. -version 1.2.3rc6 [May 14, 2002] + to nonexported form, but with PNGAPI, and removed them from module def + files. + +Version 1.2.3rc6 [May 14, 2002] Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. Removed leftover libpng-config "sed" script from four makefiles. Revised libpng-config creating script in 16 makefiles. -version 1.2.3 [May 22, 2002] +Version 1.2.3 [May 22, 2002] Revised libpng-config target in makefile.cygwin. Removed description of png_set_mem_fn() from documentation. Revised makefile.freebsd. Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). Revised projects/msvc/README.txt Changed -lpng to -lpngNN in LDFLAGS in several makefiles. -version 1.2.4beta1 [May 24, 2002] + +Version 1.2.4beta1 [May 24, 2002] Added libpng.pc and libpng-config to "all:" target in 16 makefiles. Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) Added missing "\" before closing double quote in makefile.gcmmx. Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() functions. -version 1.2.4beta2 [June 25, 2002] + +Version 1.2.4beta2 [June 25, 2002] Plugged memory leak of png_ptr->current_text (Matt Holgate). Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) Added -soname to the loader flags in makefile.dec, makefile.sgi, and makefile.sggcc. Added "test-installed" target to makefile.linux, makefile.gcmmx, makefile.sgi, and makefile.sggcc. -version 1.2.4beta3 [June 28, 2002] + +Version 1.2.4beta3 [June 28, 2002] Plugged memory leak of row_buf in pngtest.c when there is a png_error(). Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. Added "test-installed" target to makefile.32sunu, makefile.64sunu, makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. -version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] + +Version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] Added "test-installed" target to makefile.cygwin and makefile.sco. Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. -version 1.2.4 and 1.0.14 [July 8, 2002] +Version 1.2.4 and 1.0.14 [July 8, 2002] Changed png_warning() to png_error() when width is too large to process. -version 1.2.4patch01 [July 20, 2002] + +Version 1.2.4patch01 [July 20, 2002] Revised makefile.cygwin to use DLL number 12 instead of 13. -version 1.2.5beta1 [August 6, 2002] + +Version 1.2.5beta1 [August 6, 2002] Added code to contrib/gregbook/readpng2.c to ignore unused chunks. Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) Removed some stray *.o files from contrib/gregbook. @@ -1199,36 +1342,43 @@ version 1.2.5beta1 [August 6, 2002] Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). Updated makefile.hpgcc Updated png.c and pnggccrd.c handling of return from png_mmx_support() -version 1.2.5beta2 [August 15, 2002] + +Version 1.2.5beta2 [August 15, 2002] Only issue png_warning() about "Too much data" in pngpread.c when avail_in is nonzero. Updated makefiles to install a separate libpng.so.3 with its own rpath. -version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] + +Version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] Revised makefiles to not remove previous minor versions of shared libraries. -version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] + +Version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared library loader directive. Added missing "$OBJSDLL" line to makefile.gcmmx. Added missing "; fi" to makefile.32sunu. -version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] + +Version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] Revised libpng-config script. -version 1.2.5 and 1.0.15 [October 3, 2002] +Version 1.2.5 and 1.0.15 [October 3, 2002] Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, and makefile.aix. Relocated two misplaced PNGAPI lines in pngtest.c -version 1.2.6beta1 [October 22, 2002] + +Version 1.2.6beta1 [October 22, 2002] Commented out warning about uninitialized mmx_support in pnggccrd.c. Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h. Relocated two more misplaced PNGAPI lines in pngtest.c Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams, introduced in version 1.0.2. Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu. -version 1.2.6beta2 [November 1, 2002] + +Version 1.2.6beta2 [November 1, 2002] Added libpng-config "--ldopts" output. Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)" in makefiles. -version 1.2.6beta3 [July 18, 2004] + +Version 1.2.6beta3 [July 18, 2004] Reverted makefile changes from version 1.2.6beta2 and some of the changes from version 1.2.6beta1; these will be postponed until version 1.2.7. Version 1.2.6 is going to be a simple bugfix release. @@ -1281,7 +1431,8 @@ version 1.2.6beta3 [July 18, 2004] Updated contrib/visupng/VisualPng.dsp (Cosmin). Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin). Added a separate distribution with "configure" and supporting files (Junichi). -version 1.2.6beta4 [July 28, 2004] + +Version 1.2.6beta4 [July 28, 2004] Added user ability to change png_size_t via a PNG_SIZE_T macro. Added png_sizeof() and png_convert_size() functions. Added PNG_SIZE_MAX (maximum value of a png_size_t variable. @@ -1301,11 +1452,13 @@ version 1.2.6beta4 [July 28, 2004] Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove sequential read support. Added some "#if PNG_WRITE_SUPPORTED" blocks. - Removed some redundancy with #ifdef/#endif in png_malloc_default(). - Use png_malloc instead of png_zalloc to allocate the pallete. -version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] - Fixed buffer overflow vulnerability in png_handle_tRNS() - Fixed integer arithmetic overflow vulnerability in png_read_png(). + Added #ifdef to remove some redundancy in png_malloc_default(). + Use png_malloc instead of png_zalloc to allocate the palette. + +Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] + Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS(). + Fixed NULL dereference vulnerability (CVE-2004-0598) in png_handle_iCCP(). + Fixed integer overflow vulnerability (CVE-2004-0599) in png_read_png(). Fixed some harmless bugs in png_handle_sBIT, etc, that would cause duplicate chunk types to go undetected. Fixed some timestamps in the -config version @@ -1318,7 +1471,8 @@ version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] Fixed wrong cast of returns from png_get_user_width|height_max(). Changed some "keep the compiler happy" from empty statements to returns, Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution -version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] + +Version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] Revised makefile.darwin and makefile.solaris. Removed makefile.macosx. Revised pngtest's png_debug_malloc() to use png_malloc() instead of png_malloc_default() which is not supposed to be exported. @@ -1332,91 +1486,106 @@ version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin) Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles. Added code to update the row_info->colortype in png_do_read_filler() (MSB). -version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] + +Version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro. Revised documentation of png_set_keep_unknown_chunks(). Check handle_as_unknown status in pngpread.c, as in pngread.c previously. Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c -version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] + +Version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of "pinfo" was out of place). -version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED - section of png.h where they were inadvertently placed in version rc3. -version 1.2.6 and 1.0.16 [August 15, 2004] +Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] + Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED + section of png.h where they were inadvertently placed in version rc3. + +Version 1.2.6 and 1.0.16 [August 15, 2004] Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1. -version 1.2.7beta1 [August 26, 2004] + +Version 1.2.7beta1 [August 26, 2004] Removed unused pngasmrd.h file. Removed references to uu.net for archived files. Added references to PNG Spec (second edition) and the PNG ISO/IEC Standard. Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR. Fixed bug with "optimized window size" in the IDAT datastream, that causes libpng to write PNG files with incorrect zlib header bytes. -version 1.2.7beta2 [August 28, 2004] + +Version 1.2.7beta2 [August 28, 2004] Fixed bug with sCAL chunk and big-endian machines (David Munro). Undid new code added in 1.2.6rc2 to update the color_type in png_set_filler(). Added png_set_add_alpha() that updates color type. -version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] + +Version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] Revised png_set_strip_filler() to not remove alpha if color_type has alpha. -version 1.2.7 and 1.0.17 [September 12, 2004] +Version 1.2.7 and 1.0.17 [September 12, 2004] Added makefile.hp64 Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin -version 1.2.8beta1 [November 1, 2004] + +Version 1.2.8beta1 [November 1, 2004] Fixed bug in png_text_compress() that would fail to complete a large block. Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during strip alpha operation in png_do_strip_filler(). Added PNG_1_2_X definition in pngconf.h - Comment out with #ifdef/#endif png_info_init in png.c and png_read_init - in pngread.c (as of 1.3.0) -version 1.2.8beta2 [November 2, 2004] + Use #ifdef to comment out png_info_init in png.c and png_read_init in + pngread.c (as of 1.3.0) + +Version 1.2.8beta2 [November 2, 2004] Reduce color_type to a nonalpha type after strip alpha operation in png_do_strip_filler(). -version 1.2.8beta3 [November 3, 2004] + +Version 1.2.8beta3 [November 3, 2004] Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM -version 1.2.8beta4 [November 12, 2004] + +Version 1.2.8beta4 [November 12, 2004] Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin). Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin). Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection of data type in deflate (Cosmin). Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. -version 1.2.8beta5 [November 20, 2004] + +Version 1.2.8beta5 [November 20, 2004] Use png_ptr->flags instead of png_ptr->transformations to pass PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI compatibility. Revised handling of SPECIALBUILD, PRIVATEBUILD, PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. -version 1.2.8rc1 [November 24, 2004] + +Version 1.2.8rc1 [November 24, 2004] Moved handling of BUILD macros from pngconf.h to png.h Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently omitted from beta5. Revised scripts/pngw32.rc Despammed mailing addresses by masking "@" with "at". Inadvertently installed a supposedly faster test version of pngrutil.c -version 1.2.8rc2 [November 26, 2004] + +Version 1.2.8rc2 [November 26, 2004] Added two missing "\" in png.h Change tests in pngread.c and pngpread.c to if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) png_do_read_transformations(png_ptr); -version 1.2.8rc3 [November 28, 2004] + +Version 1.2.8rc3 [November 28, 2004] Reverted pngrutil.c to version libpng-1.2.8beta5. Added scripts/makefile.elf with supporting code in pngconf.h for symbol versioning (John Bowler). -version 1.2.8rc4 [November 29, 2004] + +Version 1.2.8rc4 [November 29, 2004] Added projects/visualc7 (Simon-pierre). -version 1.2.8rc5 [November 29, 2004] + +Version 1.2.8rc5 [November 29, 2004] Fixed new typo in scripts/pngw32.rc -version 1.2.8 [December 3, 2004] +Version 1.2.8 [December 3, 2004] Removed projects/visualc7, added projects/visualc71. -version 1.2.9beta1 [February 21, 2006] - +Version 1.2.9beta1 [February 21, 2006] Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints Revised man page and libpng.txt to make it clear that one should not call png_read_end or png_write_end after png_read_png or png_write_png. @@ -1438,8 +1607,7 @@ version 1.2.9beta1 [February 21, 2006] Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin). Default iTXt support was inadvertently enabled. -version 1.2.9beta2 [February 21, 2006] - +Version 1.2.9beta2 [February 21, 2006] Check for png_rgb_to_gray and png_gray_to_rgb read transformations before checking for png_read_dither in pngrtran.c Revised checking of chromaticity limits to accommodate extended RGB @@ -1452,8 +1620,7 @@ version 1.2.9beta2 [February 21, 2006] Eliminated distributions without the "configure" script. Updated INSTALL instructions. -version 1.2.9beta3 [February 24, 2006] - +Version 1.2.9beta3 [February 24, 2006] Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler) Removed reference to pngasmrd.h from Makefile.am @@ -1462,8 +1629,7 @@ version 1.2.9beta3 [February 24, 2006] Renamed ANNOUNCE to NEWS. Created AUTHORS file. -version 1.2.9beta4 [March 3, 2006] - +Version 1.2.9beta4 [March 3, 2006] Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING. Removed newline from the end of some error and warning messages. @@ -1474,17 +1640,17 @@ version 1.2.9beta4 [March 3, 2006] Added "OS2" to list of systems that don't need underscores, in pnggccrd.c Removed libpng version and date from *.c files. -version 1.2.9beta5 [March 4, 2006] +Version 1.2.9beta5 [March 4, 2006] Removed trailing blanks from source files. Put version and date of latest change in each source file, and changed copyright year accordingly. More cleanup of configure.ac, Makefile.am, and associated scripts. Restored scripts/makefile.elf which was inadvertently deleted. -version 1.2.9beta6 [March 6, 2006] +Version 1.2.9beta6 [March 6, 2006] Fixed typo (RELEASE) in configuration files. -version 1.2.9beta7 [March 7, 2006] +Version 1.2.9beta7 [March 7, 2006] Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s() in png.h. @@ -1492,7 +1658,7 @@ version 1.2.9beta7 [March 7, 2006] Made cosmetic changes to some makefiles, adding LN_SF and other macros. Made some makefiles accept "exec_prefix". -version 1.2.9beta8 [March 9, 2006] +Version 1.2.9beta8 [March 9, 2006] Fixed some "#if defined (..." which should be "#if defined(..." Bug introduced in libpng-1.2.8. Fixed inconsistency in definition of png_default_read_data() @@ -1503,82 +1669,82 @@ version 1.2.9beta8 [March 9, 2006] Added png_set_expand_gray_1_2_4_to_8() and deprecated png_set_gray_1_2_4_to_8() which also expands tRNS to alpha. -version 1.2.9beta9 [March 10, 2006] +Version 1.2.9beta9 [March 10, 2006] Include "config.h" in pngconf.h when available. Added some checks for NULL png_ptr or NULL info_ptr (timeless) -version 1.2.9beta10 [March 20, 2006] +Version 1.2.9beta10 [March 20, 2006] Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin) Made pnggccrd.c PIC-compliant (Christian Aichinger). Added makefile.mingw (Wolfgang Glas). Revised pngconf.h MMX checking. -version 1.2.9beta11 [March 22, 2006] +Version 1.2.9beta11 [March 22, 2006] Fixed out-of-order declaration in pngwrite.c that was introduced in beta9 Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros. -version 1.2.9rc1 [March 31, 2006] +Version 1.2.9rc1 [March 31, 2006] Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin). Removed nonsensical assertion check from pngtest.c (Cosmin). -version 1.2.9 [April 14, 2006] +Version 1.2.9 [April 14, 2006] Revised makefile.beos and added "none" selector in ltmain.sh -version 1.2.10beta1 [April 15, 2006] +Version 1.2.10beta1 [April 15, 2006] Renamed "config.h" to "png_conf.h" and revised Makefile.am to add -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h to include png_conf.h only when PNG_BUILDING_LIBPNG is defined. -version 1.2.10beta2 [April 15, 2006] +Version 1.2.10beta2 [April 15, 2006] Manually updated Makefile.in and configure. Changed png_conf.h.in back to config.h. -version 1.2.10beta3 [April 15, 2006] +Version 1.2.10beta3 [April 15, 2006] Change png_conf.h back to config.h in pngconf.h. -version 1.2.10beta4 [April 16, 2006] +Version 1.2.10beta4 [April 16, 2006] Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*. -version 1.2.10beta5 [April 16, 2006] +Version 1.2.10beta5 [April 16, 2006] Added a configure check for compiling assembler code in pnggccrd.c -version 1.2.10beta6 [April 17, 2006] +Version 1.2.10beta6 [April 17, 2006] Revised the configure check for pnggccrd.c Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@ Added @LIBPNG_DEFINES@ to arguments when building libpng.sym -version 1.2.10beta7 [April 18, 2006] +Version 1.2.10beta7 [April 18, 2006] Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles. -version 1.2.10rc1 [April 19, 2006] +Version 1.2.10rc1 [April 19, 2006] Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD Fixed "LN_FS" typo in makefile.sco and makefile.solaris. -version 1.2.10rc2 [April 20, 2006] +Version 1.2.10rc2 [April 20, 2006] Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE in configure.ac and configure Made the configure warning about versioned symbols less arrogant. -version 1.2.10rc3 [April 21, 2006] +Version 1.2.10rc3 [April 21, 2006] Added a note in libpng.txt that png_set_sig_bytes(8) can be used when writing an embedded PNG without the 8-byte signature. Revised makefiles and configure to avoid making links to libpng.so.* -version 1.2.10 [April 23, 2006] +Version 1.2.10 [April 23, 2006] Reverted configure to "rc2" state. -version 1.2.11beta1 [May 31, 2006] +Version 1.2.11beta1 [May 31, 2006] scripts/libpng.pc.in contained "configure" style version info and would not work with makefiles. The shared-library makefiles were linking to libpng.so.0 instead of libpng.so.3 compatibility as the library. -version 1.2.11beta2 [June 2, 2006] +Version 1.2.11beta2 [June 2, 2006] Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid buffer overflow. Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb) -version 1.2.11beta3 [June 5, 2006] +Version 1.2.11beta3 [June 5, 2006] Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin). Removed the accidental leftover Makefile.in~ (Cosmin). Avoided potential buffer overflow and optimized buffer in @@ -1586,116 +1752,116 @@ version 1.2.11beta3 [June 5, 2006] Removed the include directories and libraries from CFLAGS and LDFLAGS in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin). -version 1.2.11beta4 [June 6, 2006] +Version 1.2.11beta4 [June 6, 2006] Allow zero-length IDAT chunks after the entire zlib datastream, but not after another intervening chunk type. -version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] +Version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] Deleted extraneous square brackets from [config.h] in configure.ac -version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] +Version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] Added prototypes for PNG_INCH_CONVERSIONS functions to png.h Revised INSTALL and autogen.sh Fixed typo in several makefiles (-W1 should be -Wl) Added typedef for png_int_32 and png_uint_32 on 64-bit systems. -version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] +Version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] Removed the new typedefs for 64-bit systems (delay until version 1.4.0) Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid reading out of bounds. -version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] +Version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] Really removed the new typedefs for 64-bit systems. -version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] +Version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] Removed png_sig_bytes entry from scripts/pngw32.def -version 1.0.19, 1.2.11 [June 26, 2006] +Version 1.0.19, 1.2.11 [June 26, 2006] None. -version 1.0.20, 1.2.12 [June 27, 2006] +Version 1.0.20, 1.2.12 [June 27, 2006] Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid buffer overflow. -version 1.2.13beta1 [October 2, 2006] +Version 1.2.13beta1 [October 2, 2006] Removed AC_FUNC_MALLOC from configure.ac Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h Change "logical" to "bitwise" throughout documentation. - Detect and fix attempt to write wrong iCCP profile length. + Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244) -version 1.0.21, 1.2.13 [November 14, 2006] +Version 1.0.21, 1.2.13 [November 14, 2006] Fix potential buffer overflow in sPLT chunk handler. Fix Makefile.am to not try to link to noexistent files. Check all exported functions for NULL png_ptr. -version 1.2.14beta1 [November 17, 2006] +Version 1.2.14beta1 [November 17, 2006] Relocated three misplaced tests for NULL png_ptr. Built Makefile.in with automake-1.9.6 instead of 1.9.2. Build configure with autoconf-2.60 instead of 2.59 -version 1.2.14beta2 [November 17, 2006] +Version 1.2.14beta2 [November 17, 2006] Added some typecasts in png_zalloc(). -version 1.2.14rc1 [November 20, 2006] +Version 1.2.14rc1 [November 20, 2006] Changed "strtod" to "png_strtod" in pngrutil.c -version 1.0.22, 1.2.14 [November 27, 2006] +Version 1.0.22, 1.2.14 [November 27, 2006] Added missing "$(srcdir)" in Makefile.am and Makefile.in -version 1.2.15beta1 [December 3, 2006] +Version 1.2.15beta1 [December 3, 2006] Generated configure with autoconf-2.61 instead of 2.60 Revised configure.ac to update libpng.pc and libpng-config. -version 1.2.15beta2 [December 3, 2006] +Version 1.2.15beta2 [December 3, 2006] Always export MMX asm functions, just stubs if not building pnggccrd.c -version 1.2.15beta3 [December 4, 2006] +Version 1.2.15beta3 [December 4, 2006] Add "png_bytep" typecast to profile while calculating length in pngwutil.c -version 1.2.15beta4 [December 7, 2006] +Version 1.2.15beta4 [December 7, 2006] Added scripts/CMakeLists.txt Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta -version 1.2.15beta5 [December 7, 2006] +Version 1.2.15beta5 [December 7, 2006] Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c Revised scripts/CMakeLists.txt -version 1.2.15beta6 [December 13, 2006] +Version 1.2.15beta6 [December 13, 2006] Revised scripts/CMakeLists.txt and configure.ac -version 1.2.15rc1 [December 18, 2006] +Version 1.2.15rc1 [December 18, 2006] Revised scripts/CMakeLists.txt -version 1.2.15rc2 [December 21, 2006] +Version 1.2.15rc2 [December 21, 2006] Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. Added scripts/makefile.nommx -version 1.2.15rc3 [December 25, 2006] +Version 1.2.15rc3 [December 25, 2006] Fixed shared library numbering error that was introduced in 1.2.15beta6. -version 1.2.15rc4 [December 27, 2006] +Version 1.2.15rc4 [December 27, 2006] Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set. -version 1.2.15rc5 [December 31, 2006] +Version 1.2.15rc5 [December 31, 2006] Revised handling of rgb_to_gray. -version 1.0.23, 1.2.15 [January 5, 2007] +Version 1.2.15 [January 5, 2007] Added some (unsigned long) typecasts in pngtest.c to avoid printing errors. -version 1.2.16beta1 [January 6, 2007] +Version 1.2.16beta1 [January 6, 2007] Fix bugs in makefile.nommx -version 1.2.16beta2 [January 16, 2007] +Version 1.2.16beta2 [January 16, 2007] Revised scripts/CMakeLists.txt -version 1.0.24, 1.2.16 [January 31, 2007] +Version 1.2.16 [January 31, 2007] No changes. -version 1.2.17beta1 [March 6, 2007] +Version 1.2.17beta1 [March 6, 2007] Revised scripts/CMakeLists.txt to install both shared and static libraries. Deleted a redundant line from pngset.c. -version 1.2.17beta2 [April 26, 2007] +Version 1.2.17beta2 [April 26, 2007] Relocated misplaced test for png_ptr == NULL in pngpread.c Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN flags. @@ -1704,10 +1870,10 @@ version 1.2.17beta2 [April 26, 2007] Added "const" to some array declarations. Mention examples of libpng usage in the libpng*.txt and libpng.3 documents. -version 1.2.17rc1 [May 4, 2007] +Version 1.2.17rc1 [May 4, 2007] No changes. -version 1.2.17rc2 [May 8, 2007] +Version 1.2.17rc2 [May 8, 2007] Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications calling set_unknown_chunk_location() need them. Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in @@ -1716,693 +1882,445 @@ version 1.2.17rc2 [May 8, 2007] can be free'ed in case of error. Revised unknown chunk handling in pngrutil.c and pngpread.c to use this structure. -version 1.2.17rc3 [May 8, 2007] +Version 1.2.17rc3 [May 8, 2007] Revised symbol-handling in configure script. -version 1.2.17rc4 [May 10, 2007] +Version 1.2.17rc4 [May 10, 2007] Revised unknown chunk handling to avoid storing unknown critical chunks. -version 1.0.25 [May 15, 2007] -version 1.2.17 [May 15, 2007] +Version 1.0.25 [May 15, 2007] +Version 1.2.17 [May 15, 2007] Added "png_ptr->num_trans=0" before error return in png_handle_tRNS, to eliminate a vulnerability (CVE-2007-2445, CERT VU#684664) -version 1.0.26 [May 15, 2007] -version 1.2.18 [May 15, 2007] +Version 1.0.26 [May 15, 2007] +Version 1.2.18 [May 15, 2007] Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script -version 1.2.19beta1 [May 18, 2007] +Version 1.2.19beta1 [May 18, 2007] Changed "const static" to "static PNG_CONST" everywhere, mostly undoing change of libpng-1.2.17beta2. Changed other "const" to "PNG_CONST" Changed some handling of unused parameters, to avoid compiler warnings. "if (unused == NULL) return;" becomes "unused = unused". -version 1.2.19beta2 [May 18, 2007] +Version 1.2.19beta2 [May 18, 2007] Only use the valid bits of tRNS value in png_do_expand() (Brian Cartier) -version 1.2.19beta3 [May 19, 2007] +Version 1.2.19beta3 [May 19, 2007] Add some "png_byte" typecasts in png_check_keyword() and write new_key instead of key in zTXt chunk (Kevin Ryde). -version 1.2.19beta4 [May 21, 2007] +Version 1.2.19beta4 [May 21, 2007] Add png_snprintf() function and use it in place of sprint() for improved defense against buffer overflows. -version 1.2.19beta5 [May 21, 2007] +Version 1.2.19beta5 [May 21, 2007] Fixed png_handle_tRNS() to only use the valid bits of tRNS value. Changed handling of more unused parameters, to avoid compiler warnings. Removed some PNG_CONST in pngwutil.c to avoid compiler warnings. -version 1.2.19beta6 [May 22, 2007] +Version 1.2.19beta6 [May 22, 2007] Added some #ifdef PNG_MMX_CODE_SUPPORTED where needed in pngvcrd.c Added a special "_MSC_VER" case that defines png_snprintf to _snprintf -version 1.2.19beta7 [May 22, 2007] +Version 1.2.19beta7 [May 22, 2007] Squelched png_squelch_warnings() in pnggccrd.c and added - an #ifdef PNG_MMX_CODE_SUPPORTED/#endif block around the declarations - that caused the warnings that png_squelch_warnings was squelching. + an #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused + the warnings that png_squelch_warnings was squelching. -version 1.2.19beta8 [May 22, 2007] +Version 1.2.19beta8 [May 22, 2007] Removed __MMX__ from test in pngconf.h. -version 1.2.19beta9 [May 23, 2007] +Version 1.2.19beta9 [May 23, 2007] Made png_squelch_warnings() available via PNG_SQUELCH_WARNINGS macro. Revised png_squelch_warnings() so it might work. Updated makefile.sgcc and makefile.solaris; added makefile.solaris-x86. -version 1.2.19beta10 [May 24, 2007] +Version 1.2.19beta10 [May 24, 2007] Resquelched png_squelch_warnings(), use "__attribute__((used))" instead. -version 1.2.19beta11 [May 28, 2007] - Return 0 from png_get_sPLT() and png_get_unknown_chunks() if png_ptr is NULL; - changed three remaining instances of png_strcpy() to png_strncpy() (David - Hill). - Make test for NULL row_buf at the beginning of png_do_read_transformations - unconditional. +Version 1.4.0beta1 [April 20, 2006] + Enabled iTXt support (changes png_struct, thus requires so-number change). + Cleaned up PNG_ASSEMBLER_CODE_SUPPORTED vs PNG_MMX_CODE_SUPPORTED + Eliminated PNG_1_0_X and PNG_1_2_X macros. + Removed deprecated functions png_read_init, png_write_init, png_info_init, + png_permit_empty_plte, png_set_gray_1_2_4_to_8, png_check_sig, and + removed the deprecated macro PNG_MAX_UINT. + Moved "PNG_INTERNAL" parts of png.h and pngconf.h into pngintrn.h + Removed many WIN32_WCE #ifdefs (Cosmin). + Reduced dependency on C-runtime library when on Windows (Simon-Pierre) + Replaced sprintf() with png_sprintf() (Simon-Pierre) -version 1.2.19beta12 [May 28, 2007] - Revised pnggccrd.c. +Version 1.4.0beta2 [April 20, 2006] + Revised makefiles and configure to avoid making links to libpng.so.* + Moved some leftover MMX-related defines from pngconf.h to pngintrn.h + Updated scripts/pngos2.def, pngw32.def, and projects/wince/png32ce.def -version 1.2.19beta13 [June 14, 2007] - Prefer PNG_USE_PNGVCRD when _MSC_VER is defined in pngconf.h +Version 1.4.0beta3 [May 10, 2006] + Updated scripts/pngw32.def to comment out MMX functions. + Added PNG_NO_GET_INT_32 and PNG_NO_SAVE_INT_32 macros. + Scripts/libpng.pc.in contained "configure" style version info and would + not work with makefiles. + Revised pngconf.h and added pngconf.h.in, so makefiles and configure can + pass defines to libpng and applications. -version 1.2.19beta14 [June 16, 2007] - Fix bug with handling of 16-bit transparency, introduced in 1.2.19beta2 +Version 1.4.0beta4 [May 11, 2006] + Revised configure.ac, Makefile.am, and many of the makefiles to write + their defines in pngconf.h. -version 1.2.19beta15 [June 17, 2007] - Revised pnggccrd.c. +Version 1.4.0beta5 [May 15, 2006] + Added a missing semicolon in Makefile.am and Makefile.in + Deleted extraneous square brackets from configure.ac -version 1.2.19beta16 [June 18, 2007] - Revised pnggccrd.c again. - Updated contrib/gregbook. - Changed '#include "pnggccrd.c"' to 'include "$srcdir/pnggccrd.c"' - in configure.ac +Version 1.4.0beta6 [June 2, 2006] + Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid + buffer overflow. + Changed sonum from 0 to 1. + Removed unused prototype for png_check_sig() from png.h -version 1.2.19beta17 [June 19, 2007] - Revised many of the makefiles, to set -DPNG_NO_MMX_CODE where needed - and to not use -O3 unless -DPNG_NO_MMX_CODE is also set. +Version 1.4.0beta7 [June 16, 2006] + Exported png_write_sig (Cosmin). + Optimized buffer in png_handle_cHRM() (Cosmin). + Set pHYs = 2835 x 2835 pixels per meter, and added + sCAL = 0.352778e-3 x 0.352778e-3 meters, in pngtest.png (Cosmin). + Added png_set_benign_errors(), png_benign_error(), png_chunk_benign_error(). + Added typedef for png_int_32 and png_uint_32 on 64-bit systems. + Added "(unsigned long)" typecast on png_uint_32 variables in printf lists. -version 1.2.19beta18 [June 23, 2007] - Replaced some C++ style comments with C style comments in pnggccrd.c. - Copied optimized C code from pnggccrd.c to pngrutil.c, removed dependency - on pnggccrd.o from many makefiles. - Added sl and dylib to list of extensions be installed by Makefile.am +Version 1.4.0beta8 [June 22, 2006] + Added demonstration of user chunk support in pngtest.c, to support the + public sTER chunk and a private vpAg chunk. -version 1.2.19beta19 [June 28, 2007] - Fixed testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN in pngrtran.c - More cleanup of pnggccrd.c and pngvcrd.c +Version 1.4.0beta9 [July 3, 2006] + Removed ordinals from scripts/pngw32.def and removed png_info_int and + png_set_gray_1_2_4_to_8 entries. + Inline call of png_get_uint_32() in png_get_uint_31(). + Use png_get_uint_31() to get vpAg width and height in pngtest.c + Removed WINCE and Netware projects. + Removed standalone Y2KINFO file. -version 1.2.19beta20 [June 29, 2007] - Rebuilt Makefile.in and configure using libtool-1.5.24. - Fixed typo in pnggccrd.c +Version 1.4.0beta10 [July 12, 2006] + Eliminated automatic copy of pngconf.h to pngconf.h.in from configure and + some makefiles, because it was not working reliably. Instead, distribute + pngconf.h.in along with pngconf.h and cause configure and some of the + makefiles to update pngconf.h from pngconf.h.in. + Added pngconf.h to DEPENDENCIES in Makefile.am -version 1.2.19beta21 [June 30, 2007] - More revision of pnggccrd.c - Added "test" target to Makefile.in and Makefile.am +Version 1.4.0beta11 [August 19, 2006] + Removed AC_FUNC_MALLOC from configure.ac. + Added a warning when writing iCCP profile with mismatched profile length. + Patched pnggccrd.c to assemble on x86_64 platforms. + Moved chunk header reading into a separate function png_read_chunk_header() + in pngrutil.c. The chunk header (len+sig) is now serialized in a single + operation (Cosmin). + Implemented support for I/O states. Added png_ptr member io_state, and + functions png_get_io_chunk_name() and png_get_io_state() in pngget.c + (Cosmin). + Added png_get_io_chunk_name and png_get_io_state to scripts/*.def (Cosmin). + Renamed scripts/pngw32.* to scripts/pngwin.* (Cosmin). + Removed the include directories and libraries from CFLAGS and LDFLAGS + in scripts/makefile.gcc (Cosmin). + Used png_save_uint_32() to set vpAg width and height in pngtest.c (Cosmin). + Cast to proper type when getting/setting vpAg units in pngtest.c (Cosmin). + Added pngintrn.h to the Visual C++ projects (Cosmin). + Removed scripts/list (Cosmin). + Updated copyright year in scripts/pngwin.def (Cosmin). + Removed PNG_TYPECAST_NULL and used standard NULL consistently (Cosmin). + Disallowed the user to redefine png_size_t, and enforced a consistent use + of png_size_t across libpng (Cosmin). + Changed the type of png_ptr->rowbytes, PNG_ROWBYTES() and friends + to png_size_t (Cosmin). + Removed png_convert_size() and replaced png_sizeof with sizeof (Cosmin). + Removed some unnecessary type casts (Cosmin). + Changed prototype of png_get_compression_buffer_size() and + png_set_compression_buffer_size() to work with png_size_t instead of + png_uint_32 (Cosmin). + Removed png_memcpy_check() and png_memset_check() (Cosmin). + Fixed a typo (png_byte --> png_bytep) in libpng.3 and libpng.txt (Cosmin). + Clarified that png_zalloc() does not clear the allocated memory, + and png_zalloc() and png_zfree() cannot be PNGAPI (Cosmin). + Renamed png_mem_size_t to png_alloc_size_t, fixed its definition in + pngconf.h, and used it in all memory allocation functions (Cosmin). + Renamed pngintrn.h to pngpriv.h, added a comment at the top of the file + mentioning that the symbols declared in that file are private, and + updated the scripts and the Visual C++ projects accordingly (Cosmin). + Removed circular references between pngconf.h and pngconf.h.in in + scripts/makefile.vc*win32 (Cosmin). + Removing trailing '.' from the warning and error messages (Cosmin). + Added pngdefs.h that is built by makefile or configure, instead of + pngconf.h.in (Glenn). + Detect and fix attempt to write wrong iCCP profile length. -version 1.2.19beta22 [July 3, 2007] - Added info about pngrutil/pnggccrd/pngvcrd to png_get_header_version() - Fix type definition of dummy_value_a, b in pnggccrd.c +Version 1.4.0beta12 [October 19, 2006] + Changed "logical" to "bitwise" in the documentation. + Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h + Add a typecast to stifle compiler warning in pngrutil.c -version 1.2.19beta23 [July 10, 2007] - Revert change to type definition of dummy_value_a, b in pnggccrd.c - Make sure __PIC__ is defined in pnggccrd.c when PIC is defined. - Require gcc-4.1 or better to use PNG_HAVE_MMX_FILTER_ROW on x86_64 platforms +Version 1.4.0beta13 [November 10, 2006] + Fix potential buffer overflow in sPLT chunk handler. + Fix Makefile.am to not try to link to noexistent files. -version 1.2.19beta24 [July 14, 2007] - Added PNG_NO_READ_FILTER, PNG_NO_WRITE_FILTER, PNG_NO_WARNING macros. - Added contrib/pngminim to demonstrate building minimal encoder and decoder +Version 1.4.0beta14 [November 15, 2006] + Check all exported functions for NULL png_ptr. -version 1.2.19beta25 [July 15, 2007] - Removed the new PNG_NO_READ_FILTER macro since it would make the library - unable to read valid PNG files, and filtering is at the heart of the - PNG format. +Version 1.4.0beta15 [November 17, 2006] + Relocated two misplaced tests for NULL png_ptr. + Built Makefile.in with automake-1.9.6 instead of 1.9.2. + Build configure with autoconf-2.60 instead of 2.59 + Add "install: all" in Makefile.am so "configure; make install" will work. -version 1.2.19beta26 [July 16, 2007] - Changed "png_free(str)" to "png_free(png_ptr,str)" in pngrutil.c WinCE - code (Yves Piguet). This bug was introduced in libpng-1.2.14. - Updated scripts/CMakeLists.txt - Relocated a misplaced #endif in pnggccrd.c +Version 1.4.0beta16 [November 17, 2006] + Added a typecast in png_zalloc(). -version 1.2.19beta27 [July 17, 2007] - Fixed incorrect stride and number of bytes copied (was 4 instead of - 6 bytes) in the cleanup loop of pnggccrd.c and pngvcrd.c for handling - the end of 48-bit interlaced rows (Glenn R-P). +Version 1.4.0beta17 [December 4, 2006] + Changed "new_key[79] = '\0';" to "(*new_key)[79] = '\0';" in pngwutil.c + Add "png_bytep" typecast to profile while calculating length in pngwutil.c -version 1.2.19beta28 [July 19, 2007] - Removed requirement for gcc-4.1 or better to use PNG_HAVE_MMX_FILTER_ROW - on x86_64 platforms - Added png_warning() in pngrutil.c for short iCCP, iTXt, sPLT, or zTXT chunks. - Revised pngtest.c so warnings are displayed regardless of PNG_NO_STDIO. +Version 1.4.0beta18 [December 7, 2006] + Added scripts/CMakeLists.txt -version 1.2.19beta29 [July 20, 2007] - Fix typo in pnggccrd.c (%%eax should be %%ax in secondloop48) - -version 1.2.19beta30 [July 26, 2007] - Revised pnggccrd.c - -version 1.2.19beta31 [July 27, 2007] - Fix typos in pnggccrd.c - -version 1.0.27rc1 and 1.2.19rc1 [July 31, 2007] - Disable PNG_MMX_CODE_SUPPORTED when PNG_ASSEMBLER_CODE_SUPPORTED is off. - Enable PNG_MMX_READ_FILTER_* by default, except when gcc-3.x is being - used (they were inadvertently disabled in libpng-1.2.19beta23). - Fix some debugging statements in pnggccrd.c and pngrutil.c - Added information about disabling the MMX code in libpng documentation. - -version 1.0.27rc2 and 1.2.19rc2 [August 4, 2007] - Removed some "#if 0" blocks. - Made a global struct local in pngvcrd.c to make it thread safe. - Issue a png_error() if application attempts to transform a row tht - has not been initialized. - -version 1.0.27rc3 and 1.2.19rc3 [August 9, 2007] - Slightly revised pngvcrd.c - -version 1.0.27rc4 and 1.2.19rc4 [August 9, 2007] - Revised pnggccrd.c debugging change of rc1, which was broken. +Version 1.4.0beta19 [May 16, 2007] Revised scripts/CMakeLists.txt - Change default to PNG_NO_GLOBAL_ARRAYS for MSVC. - Turn off PNG_FLAG_ROW_INIT flag when setting transforms that expand pixels. - -version 1.0.27rc5 and 1.2.19rc5 [August 10, 2007] - Fix typo (missing '"') in pnggccrd.c - Revise handling of png_strtod in recent versions of WINCE - -version 1.0.27rc6 and 1.2.19rc6 [August 15, 2007] - Fix typo (missing ',') in contrib/gregbook/readpng2.c - Undid row initialization error exit added to rc2 and rc4. - -version 1.0.27 and 1.2.19 [August 18, 2007] - Conditionally restored row initialization error exit. - -version 1.2.20beta01 [August 19, 2007] - Fixed problem with compiling pnggccrd.c on Intel-Apple platforms. - Changed png_malloc() to png_malloc_warn() in png_set_sPLT(). - Added PNG_NO_ERROR_TEXT feature, with demo in contrib/pngminim - Removed define PNG_WARN_UNINITIALIZED_ROW 1 /* 0: warning; 1: error */ - because it caused some trouble. - -version 1.2.20beta02 [August 20, 2007] - Avoid compiling pnggccrd.c on Intel-Apple platforms. - -version 1.2.20beta03 [August 20, 2007] - Added "/D PNG_NO_MMX_CODE" to the non-mmx builds of projects/visualc6 - and visualc71. - -version 1.2.20beta04 [August 21, 2007] - Revised pngvcrd.c for improved efficiency (Steve Snyder). - -version 1.2.20rc1 [August 23, 2007] - Revised pngconf.h to set PNG_NO_MMX_CODE for gcc-3.x compilers. - -version 1.2.20rc2 [August 27, 2007] - Revised scripts/CMakeLists.txt - Revised #ifdefs to ensure one and only one of pnggccrd.c, pngvcrd.c, - or part of pngrutil.c is selected. - -version 1.2.20rc3 [August 30, 2007] - Remove a little more code in pngwutil.c when PNG_NO_WRITE_FILTER is selected. - Added /D _CRT_SECURE_NO_WARNINGS to visual6c and visualc71 projects. - Compile png_mmx_support() in png.c even when PNG_NO_MMX_CODE is defined. - Restored a "superfluous" #ifdef that was removed from 1.2.20rc2 pnggccrd.c, - breaking the png_mmx_support() function. - -version 1.2.20rc4 [September 1, 2007] - Removed Intel contributions (MMX, Optimized C). - -version 1.2.20rc5 [September 2, 2007] - Restored configure and Makefile.in to rc3 and put a snippet of code in - pnggccrd.c, to ensure configure makes the same PNG_NO_MMX_CODE selection - -version 1.2.20rc6 [September 2, 2007] - Fixed bugs in scripts/CMakeLists.txt - Removed pngvcrd.c references from msvc projects. - -version 1.0.28 and 1.2.20 [September 8, 2007] - Removed "(NO READ SUPPORT)" from png_get_header_version() string. - -version 1.2.21beta1 [September 14, 2007] - Fixed various mistakes reported by George Cook and Jeff Phillips: - logical vs bitwise NOT in pngrtran.c, bug introduced in 1.2.19rc2 - 16-bit cheap transparency expansion, bug introduced in 1.2.19beta2 - errors with sizeof(unknown_chunk.name), bugs introduced in 1.2.19beta11 - <= compare with unsigned var in pngset.c, should be ==. - -version 1.2.21beta2 [September 18, 2007] - Removed some extraneous typecasts. - -version 1.2.21rc1 [September 25, 2007] - Fixed potential out-of-bounds reads in png_handle_pCAL() and - png_handle_ztXt() ("flayer" results reported by Tavis Ormandy). - -version 1.2.21rc2 [September 26, 2007] - Fixed potential out-of-bounds reads in png_handle_sCAL(), - png_handle_iTXt(), and png_push_read_tEXt(). - Remove some PNG_CONST declarations from pngwutil.c to avoid compiler warnings - Revised makefiles to update paths in libpng.pc properly. - -version 1.2.21rc3 [September 27, 2007] - Revised makefiles to update "Libs" in libpng.pc properly. - -version 1.0.29 and 1.2.21rc3 [October 4, 2007] - No changes. - -version 1.2.22beta1 [October 4, 2007] - Again, fixed logical vs bitwise NOT in pngrtran.c, bug introduced - in 1.2.19rc2 - -version 1.2.22beta2 [October 5, 2007] - Fixed string length error in pngset.c (caused crashes while decoding iCCP) - Add terminating NULL after each instance of png_strncpy(). - -version 1.2.22beta3 [October 6, 2007] - Fix two off-by-one terminating NULL after png_strncpy(). - -version 1.2.22beta4 [October 7, 2007] - Changed some 0 to '\0'. - -version 1.0.30rc1 and 1.2.22rc1 [October 8, 2007] - No changes. - -version 1.0.30 and 1.2.22 [October 13, 2007] - No changes. - -version 1.2.23beta01 [October 15, 2007] - Reduced number of invocations of png_strlen() in pngset.c. - Changed [azAZ09_] to [_abcde...89] in Makefile.am for better localization. - -version 1.2.23beta02 [October 16, 2007] - Eliminated png_strncpy() and png_strcpy() (Pierre Poissinger) - Changed $AN to $(AN) in Makefile.am. - -version 1.2.23beta03 [October 16, 2007] - Fixed off-by-one error in pngset.c - Restore statement to set last character of buffer to \0 in pngerror.c - -version 1.2.23beta04 [October 23, 2007] - Reject attempt to set all-zero cHRM values. - -version 1.2.23beta05 [October 26, 2007] - Add missing quotes in projects/visualc6, lost in version 1.2.20rc3 - -version 1.2.23rc01 [November 2, 2007] - No changes. - -version 1.2.23 [November 6, 2007] - No changes. - -version 1.2.24beta01 [November 19, 2007] - Moved misplaced test for malloc failure in png_set_sPLT(). This bug was - introduced in libpng-1.2.20beta01. - Ifdef out avg_row etc from png.h and pngwrite.c when PNG_NO_WRITE_FILTER - Do not use png_ptr->free_fn and png_ptr->mem_fn in png_destroy_read_struct() - when png_ptr is NULL (Marshall Clow). - Updated handling of symbol prefixes in Makefile.am and configure.ac (Mike - Frysinger). - -version 1.2.24beta02 [November 30, 2007] - Removed a useless test and fixed incorrect test in png_set_cHRM_fixed() - (David Hill). - -version 1.2.24rc01 [December 7, 2007] - No changes. - -version 1.2.24 [December 14, 2007] - Make sure not to redefine _BSD_SOURCE in pngconf.h - Revised gather.sh and makefile.std in contrib/pngminim to avoid compiling - unused files. - -version 1.2.25beta01 [January 7, 2008] - Fixed bug with unknown chunk handling, introduced in version 1.2.17rc2 - -version 1.2.25beta02 [January 10, 2008] - Prevent gamma from being applied twice. - -version 1.2.25rc01 [January 17, 2008] - No changes. - -version 1.2.25beta03 [January 22, 2008] - Fixed some continue-after-malloc-failure errors in pngset.c (David Hill) - Check for info_ptr == NULL in png_read_info() and png_process_data(). - Check for possible use of NULL user_png_ver[] in png_create_read_struct(). - Change "if (swidth == NULL)" to "if (sheight == NULL)" in png_handle_sCAL - (bug introduced in libpng-1.2.4/1.0.13). - Return from png_destroy_read_struct() if png_ptr_ptr is NULL. - Fix overflow of "msg" in png_decompress_chunk(). - -version 1.2.25beta04 [January 26, 2008] - Work around Coverity bug report by slightly refactoring - png_read_push_finish_row() - -version 1.2.25beta05 [January 31, 2008] - Added libpng-1.2.25beta05.tar.lzma to distribution. Get the lzma codec - from . - Added lp1225b05.7z to distribution. Get the 7-zip decoder from - from . - Fixed some broken links in the README file. - -version 1.2.25beta06 [February 6, 2008] - Refactored png_read_push_finish_row() again, trying to satisfy Coverity. - Fixed potential NULL dereference of png_ptr in png_destroy_write_struct(); - clarified potential NULL dereference of png_ptr in png_destroy_read_struct(); - fixed potential NULL dereference of info_ptr in png_handle_bKGD(); - fixed potential NULL dereference of user_png_ver[] in - png_create_write_struct_2(). (Coverity) - -version 1.2.25rc02 [February 10, 2008] - Reset png_ptr->pass in png_read_push_finish_row() before break. - Changed "pass" from png_byte to int. - -version 1.2.25 and 1.0.31 [February 18, 2008] - No changes. - -version 1.2.26beta01 [February 21, 2008] - Added missing "(" in pngmem.c. Bug introduced in libpng-1.2.2/1.0.13 - -version 1.2.26beta02 [March 12, 2008] - Refined error message returned from deflateInit2 in pngwutil.c - Check IHDR length in png_push_read_chunk() before saving it. - -version 1.2.26beta03 [March 16, 2008] - Revised contrib/gregbook to handle premature end-of-file and file - read errors correctly. - -version 1.2.26beta04 [March 18, 2008] - Free png_ptr->big_row_buf and png_ptr->prev_row before allocating - new copies in png_read_start_row(). Bug introduced in libpng-1.2.22. - -version 1.2.26beta05 [March 19, 2008] - Removed extra png_free() added in libpng-1.2.26beta04. - -version 1.2.26beta06 [March 19, 2008] - Avoid reallocating big_row_buf and prev_row when the size does not increase. - -version 1.2.26rc01 [March 26, 2008] - Ifdef out some code that is unused when interlacing is not supported. - -versions 1.0.32 and 1.2.26 [April 2, 2008] - No changes. - -version 1.2.27beta01 [April 12, 2008] - Fixed bug (introduced in libpng-1.0.5h) with handling zero-length - unknown chunks. - Added more information about png_set_keep_unknown_chunks() to the - documentation. - Reject tRNS chunk with out-of-range samples instead of masking off - the invalid high bits as done in since libpng-1.2.19beta5. - -version 1.2.27beta02 [April 13, 2008] - Revised documentation about unknown chunk and user chunk handling. - Keep tRNS chunk with out-of-range samples and issue a png_warning(). - -version 1.2.27beta03 [April 14, 2008] - Added check for NULL ptr in TURBOC version of png_free_default(). - Removed several unnecessary checks for NULL before calling png_free(). - Revised png_set_tRNS() so that calling it twice removes and invalidates - the previous call. - Revised pngtest to check for out-of-range tRNS samples. - -version 1.2.27beta04 [April 18, 2008] - Added AC_LIBTOOL_WIN32_DLL to configure.ac - Rebuilt Makefile.in, aclocal.m4, and configure with autoconf-2.62 - -version 1.2.27beta05 [April 19, 2008] - Added MAINTAINERCLEANFILES variable to Makefile.am - -version 1.2.27beta06 [April 21, 2008] - Avoid changing color_type from GRAY to RGB by - png_set_expand_gray_1_2_4_to_8(). - -version 1.2.27rc01 [April 23, 2008] - Fix broken URL for rfc2083 in png.5 and libpng-*.txt - -version 1.0.33 and 1.2.27 [April 30, 2008] - No changes. - -version 1.0.34 and 1.2.28 [April 30, 2008] - Rebuilt Makefile.in, aclocal.m4, and configure with autoconf-2.61 - due to backward incompatibilities. - Removed a stray object file from contrib/gregbook - -version 1.2.29beta01 [May 1, 2008] - Removed some stray *.diff and *.orig files - -version 1.2.29beta02 [May 1, 2008] - Reverted Makefile.in, aclocal.m4, and configure to the libpng-1.2.26 - versions. - -version 1.2.29beta03 [May 2, 2008] - Added --force to autogen libtoolize options and --force-missing to - automake options. - Changed $(ECHO) to echo in Makefile.am and Makefile.in - Updated all configure files to autoconf-2.62 - Comment out pnggcrd.c code with #ifdef/#endif if using MSC_VER - -version 1.2.29rc01 [May 4, 2008] - No changes. - -version 1.0.35 and 1.2.29 [May 8, 2008] - No changes. - -version 1.0.37 [May 9, 2008] - Updated Makefile.in and configure (omitted version 1.0.36). - -version 1.2.30beta01 [May 29, 2008] - Updated libpng.pc-configure.in and libpng-config.in per debian bug reports. - -version 1.2.30beta02 [June 25, 2008] - Restored png_flush(png_ptr) at the end of png_write_end(), that was - removed from libpng-1.0.9beta03. - -version 1.2.30beta03 [July 6, 2008] - Merged some cosmetic whitespace changes from libpng-1.4.0beta19. - Inline call of png_get_uint_32() in png_get_uint_31(), as in 1.4.0beta19. - Added demo of decoding vpAg and sTER chunks to pngtest.c, from 1.4.0beta19. - Changed PNGMAJ from 0 to 12 in makefile.darwin, which does not like 0. - Added new private function png_read_chunk_header() from 1.4.0beta19. - Merge reading of chunk length and chunk type into a single 8-byte read. - Merge writing of chunk length and chunk type into a single 8-byte write. - -version 1.2.30beta04 [July 10, 2008] - Merged more cosmetic whitespace changes from libpng-1.4.0beta19. - -version 1.0.38rc01, 1.2.30rc01 [July 18, 2008] - No changes. - -version 1.0.38rc02, 1.2.30rc02 [July 21, 2008] + Rebuilt configure and Makefile.in with newer tools. + Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. + Added scripts/makefile.nommx + +Version 1.4.0beta20 [July 9, 2008] + Moved several PNG_HAVE_* macros from pngpriv.h to png.h because applications + calling set_unknown_chunk_location() need them. + Moved several macro definitions from pngpriv.h to pngconf.h + Merge with changes to the 1.2.X branch, as of 1.2.30beta04. + Deleted all use of the MMX assembler code and Intel-licensed optimizations. + Revised makefile.mingw + +Version 1.4.0beta21 [July 21, 2008] Moved local array "chunkdata" from pngrutil.c to the png_struct, so it will be freed by png_read_destroy() in case of a read error (Kurt Christensen). -version 1.0.38rc03, 1.2.30rc03 [July 21, 2008] - Changed "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. +Version 1.4.0beta22 [July 21, 2008] + Change "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. -version 1.0.38rc04, 1.2.30rc04 [July 22, 2008] - Changed "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in +Version 1.4.0beta23 [July 22, 2008] + Change "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in png_decompress_chunk(). -version 1.0.38rc05, 1.2.30rc05 [July 25, 2008] - Changed all remaining "chunkdata" to "png_ptr->chunkdata" in - png_decompress_chunk() and remove chunkdata from parameter list. +Version 1.4.0beta24 [July 25, 2008] + Change all remaining "chunkdata" to "png_ptr->chunkdata" in + png_decompress_chunk(), and remove "chunkdata" from parameter list. Put a call to png_check_chunk_name() in png_read_chunk_header(). Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte. - Removed two calls to png_check_chunk_name() occuring later in the process. + Removed two calls to png_check_chunk_name() occurring later in the process. + Define PNG_NO_ERROR_NUMBERS by default in pngconf.h -version 1.0.38rc06, 1.2.30rc06 [July 29, 2008] +Version 1.4.0beta25 [July 30, 2008] Added a call to png_check_chunk_name() in pngpread.c Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte. - -version 1.0.38r07, 1.2.30r07 [August 2, 2008] - Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta) - Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings. - Added code in pngset.c to quiet compiler warnings. - Updated contrib/visupng/cexcept.h to version 2.0.1 + Added png_push_have_buffer() function to pngpread.c + Eliminated PNG_BIG_ENDIAN_SUPPORTED and associated png_get_* macros. + Made inline expansion of png_get_*() optional with PNG_USE_READ_MACROS. + Eliminated all PNG_USELESS_TESTS and PNG_CORRECT_PALETTE_SUPPORTED code. + Synced contrib directory and configure files with libpng-1.2.30beta06. + Eliminated no-longer-used pngdefs.h (but it's still built in the makefiles) Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c -version 1.0.38r08, 1.2.30r08 [August 2, 2008] - Enclose "volatile" declarations in #ifdef PNG_SETJMP_SUPPORTED (Cosmin). +Version 1.4.0beta26 [August 4, 2008] + Removed png_push_have_buffer() function in pngpread.c. It increased the + compiled library size slightly. + Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta) + Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings. + Updated contrib/visupng/cexcept.h to version 2.0.1 + Added PNG_LITERAL_CHARACTER macros for #, [, and ]. -version 1.0.38, 1.2.30 [August 14, 2008] - No changes. +Version 1.4.0beta27 [August 5, 2008] + Revised usage of PNG_LITERAL_SHARP in pngerror.c. + Moved newline character from individual png_debug messages into the + png_debug macros. + Allow user to #define their own png_debug, png_debug1, and png_debug2. -version 1.2.31rc01 [August 19, 2008] +Version 1.4.0beta28 [August 5, 2008] + Revised usage of PNG_LITERAL_SHARP in pngerror.c. + Added PNG_STRING_NEWLINE macro + +Version 1.4.0beta29 [August 9, 2008] + Revised usage of PNG_STRING_NEWLINE to work on non-ISO compilers. + Added PNG_STRING_COPYRIGHT macro. + Added non-ISO versions of png_debug macros. + +Version 1.4.0beta30 [August 14, 2008] + Added premultiplied alpha feature (Volker Wiendl). + +Version 1.4.0beta31 [August 18, 2008] + Moved png_set_premultiply_alpha from pngtrans.c to pngrtran.c Removed extra crc check at the end of png_handle_cHRM(). Bug introduced - in libpng-1.2.30beta03 (Heiko Nitzsche). + in libpng-1.4.0beta20. -version 1.2.31rc02 [August 19, 2008] +Version 1.4.0beta32 [August 19, 2008] Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call. + Revised PNG_NO_STDIO version of png_write_flush() -version 1.2.31rc03 [August 19, 2008] - Added PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED block, off by default, around - new png_flush(). +Version 1.4.0beta33 [August 20, 2008] + Added png_get|set_chunk_cache_max() to limit the total number of sPLT, + text, and unknown chunks that can be stored. -version 1.0.39, 1.2.31 [August 21, 2008] - No changes. - -version 1.2.32beta01 [September 6, 2008] - Shortened tIME_string to 29 bytes in pngtest.c (bug introduced in - libpng-1.2.22). +Version 1.4.0beta34 [September 6, 2008] + Shortened tIME_string to 29 bytes in pngtest.c Fixed off-by-one error introduced in png_push_read_zTXt() function in libpng-1.2.30beta04/pngpread.c (Harald van Dijk) - These bugs have been given the vulnerability id CVE-2008-3964. -version 1.0.40, 1.2.32 [September 18, 2008] - No changes. - -version 1.2.33beta01 [October 6, 2008] +Version 1.4.0beta35 [October 6, 2008] + Changed "trans_values" to "trans_color". + Changed so-number from 0 to 14. Some OS do not like 0. Revised makefile.darwin to fix shared library numbering. Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8() in example.c (debian bug report) -version 1.2.33rc01 [October 15, 2008] - No changes. +Version 1.4.0beta36 [October 25, 2008] + Sync with tEXt vulnerability fix in libpng-1.2.33rc02. -version 1.0.41rc01, version 1.2.33rc02 [October 23, 2008] - Changed remaining "key" to "png_ptr->chunkdata" in png_handle_tEXt() - to avoid memory leak after memory failure while reading tEXt chunk.` +Version 1.4.0beta37 [November 13, 2008] + Added png_check_cHRM in png.c and moved checking from pngget.c, pngrutil.c, + and pngwrite.c -version 1.2.33 [October 31, 2008] - No changes. +Version 1.4.0beta38 [November 22, 2008] + Added check for zero-area RGB cHRM triangle in png_check_cHRM() and + png_check_cHRM_fixed(). -version 1.2.34beta01 [November 27, 2008] - Revised png_warning() to write its message on standard output by default - when warning_fn is NULL. This was the behavior prior to libpng-1.2.9beta9. - Fixed string vs pointer-to-string error in png_check_keyword(). - Added png_check_cHRM_fixed() in png.c and moved checking from pngget.c, - pngrutil.c, and pngwrite.c, and eliminated floating point cHRM checking. - Added check for zero-area RGB cHRM triangle in png_check_cHRM_fixed(). - In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant - check for all-zero coordinates that is detected by the triangle check. +Version 1.4.0beta39 [November 23, 2008] Revised png_warning() to write its message on standard output by default when warning_fn is NULL. -version 1.2.34beta02 [November 28, 2008] - Corrected off-by-one error in bKGD validity check in png_write_bKGD() - and in png_handle_bKGD(). +Version 1.4.0beta40 [November 24, 2008] + Eliminated png_check_cHRM(). Instead, always use png_check_cHRM_fixed(). + In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant + check for all-zero coordinates that is detected by the triangle check. -version 1.2.34beta03 [December 1, 2008] - Revised bKGD validity check to use >= x instead of > x + 1 - Merged with png_debug from libpng-1.4.0 to remove newlines. +Version 1.4.0beta41 [November 26, 2008] + Fixed string vs pointer-to-string error in png_check_keyword(). + Rearranged test expressions in png_check_cHRM_fixed() to avoid internal + overflows. + Added PNG_NO_CHECK_cHRM conditional. -version 1.2.34beta04 [December 2, 2008] - More merging with png_debug from libpng-1.4.0 to remove newlines. +Version 1.4.0beta42, 43 [December 1, 2008] + Merge png_debug with version 1.2.34beta04. -version 1.2.34beta05 [December 5, 2008] +Version 1.4.0beta44 [December 6, 2008] Removed redundant check for key==NULL before calling png_check_keyword() to ensure that new_key gets initialized and removed extra warning - (Arvan Pritchard). + (Merge with version 1.2.34beta05 -- Arvan Pritchard). -version 1.2.34beta06 [December 9, 2008] +Version 1.4.0beta45 [December 9, 2008] In png_write_png(), respect the placement of the filler bytes in an earlier call to png_set_filler() (Jim Barry). -version 1.2.34beta07 [December 9, 2008] +Version 1.4.0beta46 [December 10, 2008] Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated PNG_TRANSFORM_STRIP_FILLER (Jim Barry). -version 1.0.42rc01, 1.2.34rc01 [December 11, 2008] - No changes. +Version 1.4.0beta47 [December 15, 2008] + Support for dithering was disabled by default, because it has never + been well tested and doesn't work very well. The code has not + been removed, however, and can be enabled by building libpng with + PNG_READ_DITHER_SUPPORTED defined. -version 1.0.42, 1.2.34 [December 18, 2008] - No changes. +Version 1.4.0beta48 [February 14, 2009] + Added new exported function png_calloc(). + Combined several instances of png_malloc(); png_memset() into png_calloc(). + Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 + but was never defined. -version 1.2.35beta01 [February 4, 2009] - Zero out some arrays of pointers after png_malloc(). (Tavis Ormandy) - -version 1.2.35beta02 [February 4, 2009] - Zero out more arrays of pointers after png_malloc(). - -version 1.2.35beta03 [February 5, 2009] - Use png_memset() instead of a loop to intialize pointers. We realize - this will not work on platforms where the NULL pointer is not all zeroes. - -version 1.2.35rc01 [February 11, 2009] - No changes. - -version 1.2.35rc02 [February 12, 2009] - Fix typo in new png_memset call in pngset.c (png_color should be png_charp) - -version 1.0.43 and 1.2.35 [February 14, 2009] - No changes. - -version 1.2.36beta01 [February 28, 2009] +Version 1.4.0beta49 [February 28, 2009] + Added png_fileno() macro to pngconf.h, used in pngwio.c + Corrected order of #ifdef's in png_debug definition in png.h + Fixed bug introduced in libpng-1.4.0beta48 with the memset arguments + for pcal_params. + Fixed order of #ifdef directives in the png_debug defines in png.h + (bug introduced in libpng-1.2.34/1.4.0beta29). Revised comments in png_set_read_fn() and png_set_write_fn(). - Revised order of #ifdef's and indentation in png_debug definitions of png.h - bug introduced in libpng-1.2.34. -version 1.2.36beta02 [March 21, 2009] - Use png_memset() after png_malloc() of big_row_buf when reading an - interlaced file, to avoid a possible UMR. - Undid recent revision of PNG_NO_STDIO version of png_write_flush(). Users - having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined. - Revised libpng*.txt documentation about use of png_write_flush(). +Version 1.4.0beta50 [March 18, 2009] + Use png_calloc() instead of png_malloc() to allocate big_row_buf when + reading an interlaced file, to avoid a possible UMR. + Undid revision of PNG_NO_STDIO version of png_write_flush(). Users + having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined + or supply their own flush_fn() replacement. + Revised libpng*.txt and png.h documentation about use of png_write_flush() + and png_set_write_fn(). Removed fflush() from pngtest.c. Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h -version 1.2.36beta03 [March 27, 2009] - Relocated misplaced PNG_1_0_X define in png.h that caused the prototype - for png_set_strip_error_numbers() to be omitted from PNG_NO_ASSEMBLER_CODE - builds. This bug was introduced in libpng-1.2.15beta4. +Version 1.4.0beta51 [March 21, 2009] + Removed new png_fileno() macro from pngconf.h . + +Version 1.4.0beta52 [March 27, 2009] + Relocated png_do_chop() ahead of building gamma tables in pngrtran.c + This avoids building 16-bit gamma tables unnecessarily. + Removed fflush() from pngtest.c. + Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt -version 1.2.36beta04 [April 5, 2009] +Version 1.4.0beta53 [April 1, 2009] + Removed some remaining MMX macros from pngpriv.h Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles) -version 1.2.36beta05 [April 24, 2009] +Version 1.4.0beta54 [April 13, 2009] Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow application code writers to bypass the check for multiple inclusion of setjmp.h when they know that it is safe to ignore the situation. - Made some cosmetic changes to whitespace in pngtest output. + Eliminated internal use of setjmp() in pngread.c and pngwrite.c + Reordered ancillary chunks in pngtest.png to be the same as what + pngtest now produces, and made some cosmetic changes to pngtest output. + Eliminated deprecated png_read_init_3() and png_write_init_3() functions. + +Version 1.4.0beta55 [April 15, 2009] + Simplified error handling in pngread.c and pngwrite.c by putting + the new png_read_cleanup() and png_write_cleanup() functions inline. + +Version 1.4.0beta56 [April 25, 2009] Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress "shadowed declaration" warning from gcc-4.3.3. Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration" warning about a global "gamma" variable in math.h on some platforms. -version 1.2.36rc01 [April 30, 2009] - No changes. +Version 1.4.0beta57 [May 2, 2009] + Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 + but was never defined (again). + Rebuilt configure scripts with autoconf-2.63 instead of 2.62 + Removed pngprefs.h and MMX from makefiles -version 1.0.44 and 1.2.36 [May 7, 2009] - No changes. - -version 1.2.37beta01 [May 14, 2009] - Fixed inconsistency in pngrutil.c, introduced in libpng-1.2.36. The - memset() was using "png_ptr->rowbytes" instead of "row_bytes", which - the corresponding png_malloc() uses (Joe Drew). +Version 1.4.0beta58 [May 14, 2009] + Changed pngw32.def to pngwin.def in makefile.mingw (typo was introduced + in beta57). Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) - Updated some of the makefiles in the scripts directory (merged with - those in libpng-1.4.0beta57). -version 1.2.37beta02 [May 19, 2009] - Fixed typo in libpng documentation (FILTER_AVE should be FILTER_AVG) +Version 1.4.0beta59 [May 15, 2009] + Reformated sources in libpng style (3-space intentation, comment format) + Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) + Added sections about the git repository and our coding style to the + documentation Relocated misplaced #endif in pngwrite.c, sCAL chunk handler. + +Version 1.4.0beta60 [May 19, 2009] Conditionally compile png_read_finish_row() which is not used by progressive readers. Added contrib/pngminim/preader to demonstrate building minimal progressive decoder, based on contrib/gregbook with embedded libpng and zlib. -version 1.2.37beta03 [May 20, 2009] +Version 1.4.0beta61 [May 20, 2009] In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there is only one makefile in those directories, and revised the README files accordingly. - Reformated sources in libpng style (3-space indentation, comment format) + More reformatting of comments, mostly to capitalize sentences. -version 1.2.37rc01 [May 27, 2009] - No changes. - -versions 1.2.37 and 1.0.45 [June 4, 2009] - Reformatted several remaining "else statement;" and "if () statement;" into - two lines. +Version 1.4.0beta62 [June 2, 2009] Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h - Added sections about the git repository and our coding style to the - documentation (merged from libpng-1.4.0beta62) + Reformatted several remaining "else statement" into two lines. Added a section to the libpng documentation about using png_get_io_ptr() in configure scripts to detect the presence of libpng. -version 1.2.38beta01 [June 17, 2009] +Version 1.4.0beta63 [June 15, 2009] Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR() multiple times and to specify the sample order in the tRNS chunk, because the ISO PNG specification has a typo in the tRNS table. @@ -2411,154 +2329,143 @@ version 1.2.38beta01 [June 17, 2009] available for ignoring known chunks even when not saving unknown chunks. Adopted preference for consistent use of "#ifdef" and "#ifndef" versus "#if defined()" and "if !defined()" where possible. - Added PNG_NO_HANDLE_AS_UNKNOWN in the PNG_LEGACY_SUPPORTED block of - pngconf.h, and moved the various unknown chunk macro definitions - outside of the PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. -version 1.0.46 [June 18, 2009] - Removed some editing cruft from scripts/libpng.pc.in and some makefiles. +Version 1.4.0beta64 [June 24, 2009] + Eliminated PNG_LEGACY_SUPPORTED code. + Moved the various unknown chunk macro definitions outside of the + PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. -version 1.2.38rc01 [June 24, 2009] - No changes. +Version 1.4.0beta65 [June 26, 2009] + Added a reference to the libpng license in each file. -version 1.2.38rc02 [June 29, 2009] - Added a reference to the libpng license in each source file. +Version 1.4.0beta66 [June 27, 2009] + Refer to the libpng license instead of the libpng license in each file. -version 1.2.38rc03 [July 11, 2009] - Revised references to the libpng license in pngconf.h and contrib/visupng - source files. - Rebuilt configure scripts with autoconf-2.63. +Version 1.4.0beta67 [July 6, 2009] + Relocated INVERT_ALPHA within png_read_png() and png_write_png(). + Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB. + Added an "xcode" project to the projects directory (Alam Arias). -version 1.0.47 and 1.2.38 [July 16, 2009] - No changes. +Version 1.4.0beta68 [July 19, 2009] + Avoid some tests in filter selection in pngwutil.c -version 1.2.39beta01 [July 25, 2009] +Version 1.4.0beta69 [July 25, 2009] + Simplified the new filter-selection test. This runs faster in the + common "PNG_ALL_FILTERS" and PNG_FILTER_NONE cases. + Removed extraneous declaration from the new call to png_read_gray_to_rgb() + (bug introduced in libpng-1.4.0beta67). + Fixed up xcode project (Alam Arias) Added a prototype for png_64bit_product() in png.c -version 1.2.39beta02 [July 27, 2009] +Version 1.4.0beta70 [July 27, 2009] Avoid a possible NULL dereference in debug build, in png_set_text_2(). (bug introduced in libpng-0.95, discovered by Evan Rouault) -version 1.2.39beta03 [July 29, 2009] - Relocated new png_64_bit_product() prototype into png.h - Expanded the information about prototypes in the libpng style section of - the documentation. +Version 1.4.0beta71 [July 29, 2009] Rebuilt configure scripts with autoconf-2.64. -version 1.2.39beta04 [August 1, 2009] - Replaced *.tar.lzma with *.txz in distribution. Get the xz codec +Version 1.4.0beta72 [August 1, 2009] + Replaced *.tar.lzma with *.tar.xz in distribution. Get the xz codec from . -version 1.2.39beta05 [August 1, 2009] +Version 1.4.0beta73 [August 1, 2009] Reject attempt to write iCCP chunk with negative embedded profile length - (JD Chen) + (JD Chen) (CVE-2009-5063). -version 1.2.39c01 [August 6, 2009] - No changes. +Version 1.4.0beta74 [August 8, 2009] + Changed png_ptr and info_ptr member "trans" to "trans_alpha". -version 1.2.39 and 1.0.48 [August 13, 2009] - No changes. - -version 1.2.40beta01 [August 20, 2009] +Version 1.4.0beta75 [August 21, 2009] Removed an extra png_debug() recently added to png_write_find_filter(). Fixed incorrect #ifdef in pngset.c regarding unknown chunk support. -version 1.2.40rc01 [September 2, 2009] +Version 1.4.0beta76 [August 22, 2009] + Moved an incorrectly located test in png_read_row() in pngread.c + +Version 1.4.0beta77 [August 27, 2009] + Removed lpXYZ.tar.bz2 (with CRLF), KNOWNBUG, libpng-x.y.z-KNOWNBUG.txt, + and the "noconfig" files from the distribution. + Moved CMakeLists.txt from scripts into the main libpng directory. Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) -version 1.2.40 and 1.0.49 [September 2, 2009] - No changes. +Version 1.4.0beta78 [August 31, 2009] + Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h + Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros. + Use png_malloc plus a loop instead of png_calloc() to initialize + row_pointers in png_read_png(). -version 1.0.50 [September 10, 2009] - Removed some editing cruft from pngset.c and pngwutil.c. +Version 1.4.0beta79 [September 1, 2009] + Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays. + Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc(). -version 1.2.41beta01 [September 25, 2009] +Version 1.4.0beta80 [September 17, 2009] + Removed scripts/libpng.icc + Changed typecast of filler from png_byte to png_uint_16 in png_set_filler(). + (Dennis Gustafsson) + Fixed typo introduced in beta78 in pngtest.c ("#if def " should be "#ifdef ") + +Version 1.4.0beta81 [September 23, 2009] + Eliminated unused PNG_FLAG_FREE_* defines from pngpriv.h + Expanded TAB characters in pngrtran.c + Removed PNG_CONST from all "PNG_CONST PNG_CHNK" declarations to avoid + compiler complaints about doubly declaring things "const". + Changed all "#if [!]defined(X)" to "if[n]def X" where possible. + Eliminated unused png_ptr->row_buf_size + +Version 1.4.0beta82 [September 25, 2009] Moved redundant IHDR checking into new png_check_IHDR() in png.c and report all errors found in the IHDR data. Eliminated useless call to png_check_cHRM() from pngset.c - Expanded TAB characters in pngrtran.c -version 1.2.41beta02 [September 30, 2009] - Revised png_check_IHDR(). +Version 1.4.0beta83 [September 25, 2009] + Revised png_check_IHDR() to eliminate bogus complaint about filter_type. -version 1.2.41beta03 [October 1, 2009] +Version 1.4.0beta84 [September 30, 2009] + Fixed some inconsistent indentation in pngconf.h + Revised png_check_IHDR() to add a test for width variable less than 32-bit. + +Version 1.4.0beta85 [October 1, 2009] Revised png_check_IHDR() again, to check info_ptr members instead of the contents of the returned parameters. -version 1.2.41beta04 [October 7, 2009] - Added "xcode" project similar one already in libpng-1.4.0beta (Alam Arias). - Ported some cosmetic changes from libpng-1.4.0beta86. +Version 1.4.0beta86 [October 9, 2009] + Updated the "xcode" project (Alam Arias). Eliminated a shadowed declaration of "pp" in png_handle_sPLT(). -version 1.2.41beta05 [October 17, 2009] - Revised pngconf.h to make it easier to enable iTXt support. From libpng - version 1.2.9 through 1.2.40, defining PNG_iTXt_SUPPORTED did not work - as expected. - Ported some cosmetic changes from libpng-1.4.0beta87, changing - many "#if defined(x)" to "#ifdef x". +Version 1.4.0rc01 [October 19, 2009] + Trivial cosmetic changes. -version 1.2.41beta06 [October 18, 2009] - Restored PNG_USE_LOCAL_ARRAYS code in pngread.c that was inadvertently - deleted in libpng-1.2.41beta05. - Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h - as in libpng-1.4.0beta78 and later. +Version 1.4.0beta87 [October 30, 2009] + Moved version 1.4.0 back into beta. -version 1.2.41beta07 [October 21, 2009] - Ported some cosmetic changes from libpng-1.4.0rc01, changing - many "#if defined(x)" to "#ifdef x" in png.h and pngconf.h. +Version 1.4.0beta88 [October 30, 2009] + Revised libpng*.txt section about differences between 1.2.x and 1.4.0 + because most of the new features have now been ported back to 1.2.41 -version 1.2.41beta08 [October 30, 2009] - Ported from libpng-1.4.0rc01: png_calloc(), png_get_io_chunk_name(), - png_get_io_state(), png_set_user_cache_max(), png_get_user_cache_max(), - png_set_premultiply_alpha, and png_do_read_premultiply_alpha(). - Relocated png_do_chop() ahead of building gamma tables in pngrtran.c - This avoids building 16-bit gamma tables unnecessarily. - -version 1.2.41beta09 [November 1, 2009] - Removed a harmless extra png_set_invert_alpha() from pngwrite.c +Version 1.4.0beta89 [November 1, 2009] More bugfixes and improvements to CMakeLists.txt (Philip Lowman) - Moved CMakeLists.txt from scripts into the main libpng directory. + Removed a harmless extra png_set_invert_alpha() from pngwrite.c Apply png_user_chunk_cache_max within png_decompress_chunk(). Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate. -version 1.2.41beta10 [November 1, 2009] - Enabled iTXt support by default. To ensure binary compatibility with - previous versions, the "lang" and "lang_key" members will be assumed - to be omitted from previous versions unless the current libpng - version was built with PNG_iTXt_SUPPORTED (which is otherwise no - longer necessary to gain iTXt support), as a signal that the user has - been building previous versions with PNG_iTXt_SUPPORTED as well. +Version 1.4.0beta90 [November 2, 2009] + Removed all remaining WIN32_WCE #ifdefs except those involving the + time.h "tm" structure -version 1.2.41beta11 [November 2, 2009] - Store user's user_png_ver in new png_ptr->user_png_ver element. - Revised iTXt support. To ensure binary compatibility with - previous versions, the "lang" and "lang_key" members will be assumed - to be omitted from versions prior to 1.2.41beta11 whenever there is a - library mismatch. - -version 1.2.41beta12 [November 2, 2009] - Free png_ptr->user_png_ver when destroying png_ptr. - -version 1.2.41beta13 [November 3, 2009] +Version 1.4.0beta91 [November 3, 2009] Updated scripts/pngw32.def and projects/wince/png32ce.def Copied projects/wince/png32ce.def to the scripts directory. Added scripts/makefile.wce Patched ltmain.sh for wince support. Added PNG_CONVERT_tIME_SUPPORTED macro. -version 1.2.41beta14 [November 8, 2009] - versions 1.2.41beta05 through 1.2.41beta13 were abandoned. - The 1.0.x/1.2.x series will only receive security updates from now on. +Version 1.4.0beta92 [November 4, 2009] Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED - Reverted iTXt compatibility stuff from 1.2.41beta05, 1.2.41beta11, and - 1.2.41beta12. - Reverted IOSTATE feature, user_cache_max, and premultiply_alpha features - from 1.2.41beta08. - Retained png_calloc() from 1.2.41beta08 but as a non-exported function, - and removed reference to png_calloc from scripts/*.def + Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead + of differences from 1.2.41 to 1.4.0) -version 1.2.41beta15 [November 8, 2009] +Version 1.4.0beta93 [November 7, 2009] Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and PNG_ALLOCATED macros to detect deprecated direct access to the png_struct or info_struct members and other deprecated usage in @@ -2568,179 +2475,3635 @@ version 1.2.41beta15 [November 8, 2009] functions while building libpng. They need to be tested, especially those using compilers other than gcc. Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG". - -version 1.2.41beta16 [November 9, 2009] + They should work but still need to be updated to remove + references to pnggccrd.c or pngvcrd.c and ASM building. + Added README.txt to the beos, cbuilder5, netware, and xcode projects warning + that they need to be updated, to remove references to pnggccrd.c and + pngvcrd.c and to depend on pngpriv.h Removed three direct references to read_info_ptr members in pngtest.c that were detected by the new PNG_DEPSTRUCT macro. + Moved the png_debug macro definitions and the png_read_destroy(), + png_write_destroy() and png_far_to_near() prototypes from png.h + to pngpriv.h (John Bowler) + Moved the synopsis lines for png_read_destroy(), png_write_destroy() + png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3. + +Version 1.4.0beta94 [November 9, 2009] + Removed the obsolete, unused pnggccrd.c and pngvcrd.c files. + Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions. + Removed dependency of pngtest.o on pngpriv.h in the makefiles. Only #define PNG_DEPSTRUCT, etc. in pngconf.h if not already defined. -version 1.2.41beta17 [November 10, 2009] - Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions. - Marked deprecated function prototypes with PNG_DEPRECATED. - Marked memory allocation function prototypes with PNG_ALLOCATED. +Version 1.4.0beta95 [November 10, 2009] + Changed png_check_sig() to !png_sig_cmp() in contrib programs. + Added -DPNG_CONFIGURE_LIBPNG to contrib/pngminm/*/makefile Changed png_check_sig() to !png_sig_cmp() in contrib programs. Corrected the png_get_IHDR() call in contrib/gregbook/readpng2.c - Added "-DPNG_CONFIGURE_LIBPNG" to the contrib/pngminum makefiles. + Changed pngminim/*/gather.sh to stop trying to remove pnggccrd.c and pngvcrd.c + Added dependency on pngpriv.h in contrib/pngminim/*/makefile -version 1.2.41beta18 [November 11, 2009] +Version 1.4.0beta96 [November 12, 2009] Renamed scripts/makefile.wce to scripts/makefile.cegcc - Marked nonexported functions with PNG_PRIVATE macro. + Revised Makefile.am to use libpng.sys while building libpng.so + so that only PNG_EXPORT functions are exported. + Removed the deprecated png_check_sig() function/macro. + Removed recently removed function names from scripts/*.def + Revised pngtest.png to put chunks in the same order written by pngtest + (evidently the same change made in libpng-1.0beta54 was lost). + Added PNG_PRIVATE macro definition in pngconf.h for possible future use. -version 1.2.41rc01 and 1.0.51rc01 [November 18, 2009] - Revised scripts/*.def to reflect functions actually exported by libpng. - Updated the copyright year in scripts/pngw32.rc from 2004 to 2009. +Version 1.4.0beta97 [November 13, 2009] + Restored pngtest.png to the libpng-1.4.0beta7 version. + Removed projects/beos and netware.txt; no one seems to be supporting them. + Revised Makefile.in + +Version 1.4.0beta98 [November 13, 2009] + Added the "xcode" project to zip distributions, + Fixed a typo in scripts/pngwin.def introduced in beta97. + +Version 1.4.0beta99 [November 14, 2009] + Moved libpng-config.in and libpng.pc-configure.in out of the scripts + directory, to libpng-config.in and libpng-pc.in, respectively, and + modified Makefile.am and configure.ac accordingly. Now "configure" + needs nothing from the "scripts" directory. + Avoid redefining PNG_CONST in pngconf.h + +Version 1.4.0beta100 [November 14, 2009] + Removed ASM builds from projects/visualc6 and projects/visualc71 + Removed scripts/makefile.nommx and makefile.vcawin32 + Revised CMakeLists.txt to account for new location of libpng-config.in + and libpng-pc.in + Updated INSTALL to reflect removal and relocation of files. + +Version 1.4.0beta101 [November 14, 2009] + Restored the binary files (*.jpg, *.png, some project files) that were + accidentally deleted from the zip and 7z distributions when the xcode + project was added. + +Version 1.4.0beta102 [November 18, 2009] + Added libpng-config.in and libpng-pc.in to the zip and 7z distributions. + Fixed a typo in projects/visualc6/pngtest.dsp, introduced in beta100. Moved descriptions of makefiles and other scripts out of INSTALL into scripts/README.txt + Updated the copyright year in scripts/pngwin.rc from 2006 to 2009. -version 1.2.41rc02 [November 22, 2009] - Rebuilt the configure scripts with autoconf-2.65 +Version 1.4.0beta103 [November 21, 2009] + Removed obsolete comments about ASM from projects/visualc71/README_zlib.txt + Align row_buf on 16-byte boundary in memory. + Restored the PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED guard around the call + to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 + changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone + needs this feature. + Make the 'png_jmpbuf' macro expand to a call that records the correct + longjmp function as well as returning a pointer to the setjmp + jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'. + (John Bowler) -version 1.2.41rc03 [November 25, 2009] - Disabled the new pedantic warnings about deprecated function use - and deprecated structure access unless the user defines - PNG_PEDANTIC_WARNINGS. +Version 1.4.0beta104 [November 22, 2009] + Removed png_longjmp_ptr from scripts/*.def and libpng.3 + Rebuilt configure scripts with autoconf-2.65 + +Version 1.4.0beta105 [November 25, 2009] + Use fast integer PNG_DIVIDE_BY_255() or PNG_DIVIDE_BY_65535() + to accomplish alpha premultiplication when + PNG_READ_COMPOSITE_NODIV_SUPPORTED is defined. + Changed "/255" to "/255.0" in background calculations to make it clear + that the 255 is used as a double. + +Version 1.4.0beta106 [November 27, 2009] + Removed premultiplied alpha feature. + +Version 1.4.0beta107 [December 4, 2009] + Updated README Added "#define PNG_NO_PEDANTIC_WARNINGS" in the libpng source files. Removed "-DPNG_CONFIGURE_LIBPNG" from the makefiles and projects. - -version 1.2.41 and 1.0.51 [December 3, 2009] - Updated the list of files and made some cosmetic changes in README. - -version 1.2.42beta01 [December 4, 2009] - Removed "#define PNG_NO_ERROR_NUMBERS" that was inadvertently added - to pngconf.h in version 1.2.41. Revised scripts/makefile.netbsd, makefile.openbsd, and makefile.sco to put png.h and pngconf.h in $prefix/include, like the other scripts, instead of in $prefix/include/libpng. Also revised makefile.sco - to put them in $prefix/include/libpng12 instead of in - $prefix/include/libpng/libpng12. - Removed leftover "-DPNG_CONFIGURE_LIBPNG" from scripts/makefile.darwin + to put them in $prefix/include/libpng15 instead of in + $prefix/include/libpng/libpng15. -version 1.2.42beta02 [December 11, 2009] +Version 1.4.0beta108 [December 11, 2009] Removed leftover "-DPNG_CONFIGURE_LIBPNG" from contrib/pngminim/*/makefile - Relocated png_do_chop() to its original position in pngrtran.c. The + Relocated png_do_chop() to its original position in pngrtran.c; the change in version 1.2.41beta08 caused transparency to be handled wrong in some 16-bit datastreams (Yusaku Sugai). -version 1.2.42rc01 [December 17, 2009] - No changes. +Version 1.4.0beta109 [December 13, 2009] + Added "bit_depth" parameter to the private png_build_gamma_table() function. + Pass bit_depth=8 to png_build_gamma_table() when bit_depth is 16 but the + PNG_16_TO_8 transform has been set, to avoid unnecessary build of 16-bit + tables. -version 1.2.42rc02 [December 22, 2009] +Version 1.4.0rc02 [December 20, 2009] + Declared png_cleanup_needed "volatile" in pngread.c and pngwrite.c + +Version 1.4.0rc03 [December 22, 2009] Renamed libpng-pc.in back to libpng.pc.in and revised CMakeLists.txt - (revising changes made in 1.2.41beta17 and 1.2.41rc01) + (revising the change in 1.4.0beta99) -version 1.2.42rc03 [December 25, 2009] +Version 1.4.0rc04 [December 25, 2009] Swapped PNG_UNKNOWN_CHUNKS_SUPPORTED and PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngset.c to be consistent with other changes in version 1.2.38. -version 1.2.42rc04 [January 1, 2010] - Marked png_memcpy_check() and png_memset_check() PNG_DEPRECATED. - Updated copyright year. +Version 1.4.0rc05 [December 25, 2009] + Changed "libpng-pc.in" to "libpng.pc.in" in configure.ac, configure, and + Makefile.in to be consistent with changes in libpng-1.4.0rc03 -version 1.2.42rc05 [January 2, 2010] +Version 1.4.0rc06 [December 29, 2009] + Reverted the gamma_table changes from libpng-1.4.0beta109. + Fixed some indentation errors. + +Version 1.4.0rc07 [January 1, 2010] + Revised libpng*.txt and libpng.3 about 1.2.x->1.4.x differences. + Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c + Update copyright year to 2010. + +Version 1.4.0rc08 [January 2, 2010] Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr in pngtest.c -version 1.2.42 and 1.0.52 [January 3, 2010] +Version 1.4.0 [January 3, 2010] No changes. -version 1.2.43beta01 [January 27, 2010] +Version 1.4.1beta01 [January 8, 2010] Updated CMakeLists.txt for consistent indentation and to avoid an unclosed if-statement warning (Philip Lowman). - Removed "#ifdef PNG_1_0_X / #endif" surrounding - PNG_READ_16_TO_8_SUPPORTED and PNG_READ_GRAY_TO_RGB_SUPPORTED - in pngconf.h. These were added in libpng-1.2.41beta08 and libpng-1.0.51, - which introduced a binary incompatibility with libpng-1.0.50. - Backported new png_decompress_chunk() algorithm from libpng-1.4.1. + Revised Makefile.am and Makefile.in to remove references to Y2KINFO, + KNOWNBUG, and libpng.la (Robert Schwebel). + Revised the makefiles to install the same files and symbolic + links as configure, except for libpng.la and libpng14.la. + Make png_set|get_compression_buffer_size() available even when + PNG_WRITE_SUPPORTED is not enabled. + Revised Makefile.am and Makefile.in to simplify their maintenance. + Revised scripts/makefile.linux to install a link to libpng14.so.14.1 -version 1.2.43beta02 [February 1, 2010] - Backported two-pass png_decompress_chunk() algorithm from libpng-1.4.1. +Version 1.4.1beta02 [January 9, 2010] + Revised the rest of the makefiles to install a link to libpng14.so.14.1 -version 1.2.43beta03 [February 6, 2010] - Backported fast png_push_save_buffer() algorithm from libpng-1.4.1. - Backported some cosmetic changes from libpng-1.4.1. +Version 1.4.1beta03 [January 10, 2010] + Removed png_set_premultiply_alpha() from scripts/*.def -version 1.2.43beta04 [February 8, 2010] - Reverted recent changes to png_push_save-buffer(). - Removed PNGAPI declaration of png_calloc() and png_write_sig() in - 1ibpng-1.2.X, introduced by mistake in libpng-1.2.41. - Return allocated "old_buffer" in png_push_save_buffer() before png_error() - to avoid a potential memory leak. - -version 1.2.43beta05 [February 8, 2010] - Ported rewritten png_decompress_chunk() by John Bowler from libpng-1.4.1. - -version 1.0.53rc01 and 1.2.43rc01 [February 18, 2010] +Version 1.4.1rc01 [January 16, 2010] No changes. -version 1.0.53rc02 and 1.2.43rc02 [February 19, 2010] - Define _ALL_SOURCE in configure.ac, makefile.aix, and CMakeLists.txt - when using AIX compiler. +Version 1.4.1beta04 [January 23, 2010] + Revised png_decompress_chunk() to improve speed and memory usage when + decoding large chunks. + Added png_set|get_chunk_malloc_max() functions. -version 1.0.53 and 1.2.43 [February 25, 2010] +Version 1.4.1beta05 [January 26, 2010] + Relocated "int k" declaration in pngtest.c to minimize its scope. + +Version 1.4.1beta06 [January 28, 2010] + Revised png_decompress_chunk() to use a two-pass method suggested by + John Bowler. + +Version 1.4.1beta07 [February 6, 2010] + Folded some long lines in the source files. + Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, + and a PNG_USER_LIMITS_SUPPORTED flag. + Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as + png_ptr->png_user_chunk_malloc_max. + Revised png_push_save_buffer() to do fewer but larger png_malloc() calls. + +Version 1.4.1beta08 [February 6, 2010] + Minor cleanup and updating of dates and copyright year. + +Version 1.5.0beta01 [February 7, 2010] + Moved declaration of png_struct into private pngstruct.h and png_info + into pnginfo.h + +Version 1.4.1beta09 and 1.5.0beta02 [February 7, 2010] + Reverted to original png_push_save_buffer() code. + +Version 1.4.1beta10 and 1.5.0beta03 [February 8, 2010] + Return allocated "old_buffer" in png_push_save_buffer() before + calling png_error(), to avoid a potential memory leak. + Updated configure script to use SO number 15. + +Version 1.5.0beta04 [February 9, 2010] + Removed malformed "incomplete struct declaration" of png_info from png.h + +Version 1.5.0beta05 [February 12, 2010] + Removed PNG_DEPSTRUCT markup in pngstruct.h and pnginfo.h, and undid the + linewrapping that it entailed. + Revised comments in pngstruct.h and pnginfo.h and added pointers to + the libpng license. + Changed PNG_INTERNAL to PNG_EXPOSE_INTERNAL_STRUCTURES + Removed the cbuilder5 project, which has not been updated to 1.4.0. + +Version 1.4.1beta12 and 1.5.0beta06 [February 14, 2010] + Fixed type declaration of png_get_chunk_malloc_max() in pngget.c (Daisuke + Nishikawa) + +Version 1.5.0beta07 [omitted] + +Version 1.5.0beta08 [February 19, 2010] + Changed #ifdef PNG_NO_STDIO_SUPPORTED to #ifdef PNG_NO_CONSOLE_IO_SUPPORTED + wherever png_snprintf() is used to construct error and warning messages. + Noted in scripts/makefile.mingw that it expects to be run under MSYS. + Removed obsolete unused MMX-querying support from contrib/gregbook + Added exported png_longjmp() function. + Removed the AIX redefinition of jmpbuf in png.h + Added -D_ALLSOURCE in configure.ac, makefile.aix, and CMakeLists.txt + when building on AIX. + +Version 1.5.0beta09 [February 19, 2010] + Removed -D_ALLSOURCE from configure.ac, makefile.aix, and CMakeLists.txt. + Changed the name of png_ptr->jmpbuf to png_ptr->png_jmpbuf in pngstruct.h + +Version 1.5.0beta10 [February 25, 2010] Removed unused gzio.c from contrib/pngminim gather and makefile scripts + Removed replacement error handlers from contrib/gregbook. Because of + the new png_longjmp() function they are no longer needed. -version 1.2.44beta01 [June 18, 2010] +Version 1.5.0beta11 [March 6, 2010] + Removed checking for already-included setjmp.h from pngconf.h + Fixed inconsistent indentations and made numerous cosmetic changes. + Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5 + +Version 1.5.0beta12 [March 9, 2010] + Moved "#include png.h" inside pngpriv.h and removed "#include png.h" from + the source files, along with "#define PNG_EXPOSE_INTERNAL_STRUCTURES" + and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler). + Created new pngdebug.h and moved debug definitions there. + +Version 1.5.0beta13 [March 10, 2010] + Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice. + Revise the "#ifdef" blocks in png_inflate() so it will compile when neither + PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED + is defined. + Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3 + Moved the 'config.h' support from pngconf.h to pngpriv.h + Removed PNGAPI from the png_longjmp_ptr typedef. + Eliminated dependence of pngtest.c on the private pngdebug.h file. + Make all png_debug macros into *unterminated* statements or + expressions (i.e. a trailing ';' must always be added) and correct + the format statements in various png_debug messages. + +Version 1.5.0beta14 [March 14, 2010] + Removed direct access to png_ptr->io_ptr from the Windows code in pngtest.c + Revised Makefile.am to account for recent additions and replacements. + Corrected CE and OS/2 DEF files (scripts/png*def) for symbols removed and + added ordinal numbers to the Windows DEF file and corrected the duplicated + ordinal numbers on CE symbols that are commented out. + Added back in export symbols that can be present in the Windows build but + are disabled by default. + PNG_EXPORT changed to include an 'ordinal' field for DEF file generation. + PNG_CALLBACK added to make callback definitions uniform. PNGAPI split + into PNGCAPI (base C form), PNGAPI (exports) and PNGCBAPI (callbacks), + and appropriate changes made to all files. Cygwin builds re-hinged to + allow procedure call standard changes and to remove the need for the DEF + file (fixes build on Cygwin). + Enabled 'attribute' warnings that are relevant to library APIs and callbacks. + Changed rules for generation of the various symbol files and added a new + rule for a DEF file (which is also added to the distribution). + Updated the symbol file generation to stop it adding spurious spaces + to EOL (coming from preprocessor macro expansion). Added a facility + to join tokens in the output and rewrite *.dfn to use this. + Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71 + and removed scripts/makefile.cygwin. + Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. + Removed the include of sys/types.h - apparently unnecessary now on the + platforms on which it happened (all but Mac OS and RISC OS). + Moved the Mac OS test into pngpriv.h (the only place it is used.) + +Version 1.5.0beta15 [March 17, 2010] + Added symbols.chk target to Makefile.am to validate the symbols in png.h + against the new DEF file scripts/symbols.def. + Changed the default DEF file back to pngwin.def. + Removed makefile.mingw. + Eliminated PNG_NO_EXTERN and PNG_ALL_EXTERN + +Version 1.5.0beta16 [April 1, 2010] + Make png_text_struct independent of PNG_iTXt_SUPPORTED, so that + fields are initialized in all configurations. The READ/WRITE + macros (PNG_(READ|WRITE)_iTXt_SUPPORTED) still function as + before to disable code to actually read or write iTXt chunks + and iTXt_SUPPORTED can be used to detect presence of either + read or write support (but it is probably better to check for + the one actually required - read or write.) + Combined multiple png_warning() calls for a single error. + Restored the macro definition of png_check_sig(). + +Version 1.5.0beta17 [April 17, 2010] + Added some "(long)" typecasts to printf calls in png_handle_cHRM(). + Documented the fact that png_set_dither() was disabled since libpng-1.4.0. + Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect + more accurately what it actually does. At the same time, renamed + the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to + PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. + Added some "(long)" typecasts to printf calls in png_handle_cHRM(). + Freeze build-time only configuration in the build. + In all prior versions of libpng most configuration options + controlled by compiler #defines had to be repeated by the + application code that used libpng. This patch changes this + so that compilation options that can only be changed at build + time are frozen in the build. Options that are compiler + dependent (and those that are system dependent) are evaluated + each time - pngconf.h holds these. Options that can be changed + per-file in the application are in png.h. Frozen options are + in the new installed header file pnglibconf.h (John Bowler) + Removed the xcode project because it has not been updated to work + with libpng-1.5.0. + Removed the ability to include optional pngusr.h + +Version 1.5.0beta18 [April 17, 2010] + Restored the ability to include optional pngusr.h + Moved replacements for png_error() and png_warning() from the + contrib/pngminim project to pngerror.c, for use when warnings or + errors are disabled via PNG_NO_WARN or PNG_NO_ERROR_TEXT, to avoid + storing unneeded error/warning text. + Updated contrib/pngminim project to work with the new pnglibconf.h + Added some PNG_NO_* defines to contrib/pngminim/*/pngusr.h to save space. + +Version 1.5.0beta19 [April 24, 2010] + Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the functions + to read and write ints to be disabled independently of PNG_USE_READ_MACROS, + which allows libpng to be built with the functions even though the default + is to use the macros - this allows applications to choose at app build + time whether or not to use macros (previously impossible because the + functions weren't in the default build.) + Changed Windows calling convention back to __cdecl for API functions. + For Windows/x86 platforms only: + __stdcall is no longer needed for Visual Basic, so libpng-1.5.0 uses + __cdecl throughout (both API functions and callbacks) on Windows/x86 + platforms. + Replaced visualc6 and visualc71 projects with new vstudio project + Relaxed the overly-restrictive permissions of some files. + +Version 1.5.0beta20 [April 24, 2010] + Relaxed more overly-restrictive permissions of some files. + +Version 1.5.0beta21 [April 27, 2010] + Removed some unwanted binary bytes and changed CRLF to NEWLINE in the new + vstudio project files, and some trivial editing of some files in the + scripts directory. + Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in + contrib/pngminim/decoder/pngusr.h to make a smaller decoder application. + +Version 1.5.0beta22 [April 28, 2010] + Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS + because it has a macro equivalent. + Improved the options.awk script; added an "everything off" option. + Revised contrib/pngminim to use the "everything off" option in pngusr.dfa. + +Version 1.5.0beta23 [April 29, 2010] + Corrected PNG_REMOVED macro to take five arguments. + The macro was documented with two arguments (name,ordinal), however + the symbol checking .dfn files assumed five arguments. The five + argument form seems more useful so it is changed to that. + Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED + in gregbook/readpng2.c + Corrected protection of png_get_user_transform_ptr. The API declaration in + png.h is removed if both READ and WRITE USER_TRANSFORM are turned off + but was left defined in pngtrans.c + Added logunsupported=1 to cause pnglibconf.h to document disabled options. + This makes the installed pnglibconf.h more readable but causes no + other change. The intention is that users of libpng will find it + easier to understand if an API they need is missing. + Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined. + Removed dummy_inflate.c from contrib/pngminim/encoder + Removed contrib/pngminim/*/gather.sh; gathering is now done in the makefile. + +Version 1.5.0beta24 [May 7, 2010] + Use bitwise "&" instead of arithmetic mod in pngrutil.c calculation of the + offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf. + Added more blank lines for readability. + +Version 1.5.0beta25 [June 18, 2010] In pngpread.c: png_push_have_row() add check for new_row > height Removed the now-redundant check for out-of-bounds new_row from example.c -version 1.2.44beta02 [June 19, 2010] +Version 1.5.0beta26 [June 18, 2010] In pngpread.c: png_push_process_row() add check for too many rows. - Removed the now-redundant check for new_row > height in png_push_have_row(). -version 1.2.44beta03 [June 20, 2010] - Rewrote png_process_IDAT_data() to consistently treat extra data as warnings +Version 1.5.0beta27 [June 18, 2010] + Removed the check added in beta25 as it is now redundant. + +Version 1.5.0beta28 [June 20, 2010] + Rewrote png_process_IDAT_data to consistently treat extra data as warnings and handle end conditions more cleanly. - Removed the new (beta02) check in png_push_process_row(). + Removed the new (beta26) check in png_push_process_row(). -version 1.2.44rc01 [June 21, 2010] - Revised some comments in png_process_IDAT_data(). +Version 1.5.0beta29 [June 21, 2010] + Revised scripts/options.awk to work on Sunos (but still doesn't work) + Added comment to options.awk and contrib/pngminim/*/makefile to try nawk. -version 1.2.44rc02 [June 22, 2010] +Version 1.5.0beta30 [June 22, 2010] Stop memory leak when reading a malformed sCAL chunk. -version 1.2.44rc03 [June 23, 2010] - Revised pngpread.c patch of beta05 to avoid an endless loop. +Version 1.5.0beta31 [June 26, 2010] + Revised pngpread.c patch of beta28 to avoid an endless loop. + Removed some trailing blanks. -version 1.2.44 [June 26, 2010] - Updated some of the "last changed" dates. +Version 1.5.0beta32 [June 26, 2010] + Removed leftover scripts/options.patch and scripts/options.rej -version 1.2.45beta01 [June 7, 2011] - Fixed uninitialized memory read in png_format_buffer() (Bug - report by Frank Busse, related to CVE-2004-0421). - Pass "" instead of '\0' to png_default_error() in png_err(). This mistake - was introduced in libpng-1.2.20beta01. - Check for up->location !PNG_AFTER_IDAT when writing unknown chunks - before IDAT. - Ported bugfix in pngrtran.c from 1.5.3: when expanding a paletted image, - always expand to RGBA if transparency is present. +Version 1.5.0beta33 [July 6, 3010] + Made FIXED and FLOATING options consistent in the APIs they enable and + disable. Corrected scripts/options.awk to handle both command line + options and options specified in the .dfa files. + Changed char *msg to PNG_CONST char *msg in pngrutil.c + Make png_set_sRGB_gAMA_and_cHRM set values using either the fixed or + floating point APIs, but not both. + Reversed patch to remove error handler when the jmp_buf is stored in the + main program structure, not the png_struct. + The error handler is needed because the default handler in libpng will + always use the jmp_buf in the library control structure; this is never + set. The gregbook code is a useful example because, even though it + uses setjmp/longjmp, it shows how error handling can be implemented + using control mechanisms not directly supported by libpng. The + technique will work correctly with mechanisms such as Microsoft + Structure Exceptions or C++ exceptions (compiler willing - note that gcc + does not by default support interworking of C and C++ error handling.) + Reverted changes to call png_longjmp in contrib/gregbook where it is not + appropriate. If mainprog->jmpbuf is used by setjmp, then png_longjmp + cannot be used. + Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans) + Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {') -version 1.2.45beta02 [June 8, 2011] - Check for integer overflow in png_set_rgb_to_gray(). +Version 1.5.0beta34 [July 12, 2010] + Put #ifndef PNG_EXTERN, #endif around the define PNG_EXTERN in pngpriv.h -version 1.2.45beta03 [June 19, 2011] - Check for sCAL chunk too short. +Version 1.5.0beta35 [July 24, 2010] + Removed some newly-added TAB characters. + Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2 + Moved the definition of png_snprintf() outside of the enclosing + #ifdef blocks in pngconf.h -version 1.2.45rc01 and 1.0.55rc01 [June 30, 2011] - Updated "last changed" dates and copyright year. +Version 1.5.0beta36 [July 29, 2010] + Patches by John Bowler: + Fixed point APIs are now supported throughout (no missing APIs). + Internal fixed point arithmetic support exists for all internal floating + point operations. + sCAL validates the floating point strings it is passed. + Safe, albeit rudimentary, Watcom support is provided by PNG_API_RULE==2 + Two new APIs exist to get the number of passes without turning on the + PNG_INTERLACE transform and to get the number of rows in the current + pass. + A new test program, pngvalid.c, validates the gamma code. + Errors in the 16-bit gamma correction (overflows) have been corrected. + cHRM chunk testing is done consistently (previously the floating point + API bypassed it, because the test really didn't work on FP, now the test + is performed on the actual values to be stored in the PNG file so it + works in the FP case too.) + Most floating point APIs now simply call the fixed point APIs after + converting the values to the fixed point form used in the PNG file. + The standard headers no longer include zlib.h, which is currently only + required for pngstruct.h and can therefore be internal. + Revised png_get_int_32 to undo the PNG two's complement representation of + negative numbers. -version 1.2.45 and 1.0.55 [July 7, 2011] +Version 1.5.0beta37 [July 30, 2010] + Added a typecast in png_get_int_32() in png.h and pngrutil.h to avoid + a compiler warning. + Replaced oFFs 0,0 with oFFs -10,20 in pngtest.png + +Version 1.5.0beta38 [July 31, 2010] + Implemented remaining "_fixed" functions. + Corrected a number of recently introduced warnings mostly resulting from + safe but uncast assignments to shorter integers. Also added a zlib + VStudio release library project because the latest zlib Official Windows + build does not include such a thing. + Revised png_get_int_16() to be similar to png_get_int_32(). + Restored projects/visualc71. + +Version 1.5.0beta39 [August 2, 2010] + VisualC/GCC warning fixes, VisualC build fixes + The changes include support for function attributes in VC in addition to + those already present in GCC - necessary because without these some + warnings are unavoidable. Fixes include signed/unsigned fixes in + pngvalid and checks with gcc -Wall -Wextra -Wunused. + VC requires function attributes on function definitions as well as + declarations, PNG_FUNCTION has been added to enable this and the + relevant function definitions changed. + +Version 1.5.0beta40 [August 6, 2010] + Correct use of _WINDOWS_ in pngconf.h + Removed png_mem_ #defines; they are no longer used. + Added the sRGB chunk to pngtest.png + +Version 1.5.0beta41 [August 11, 2010] + Added the cHRM chunk to pngtest.png + Don't try to use version-script with cygwin/mingw. + Revised contrib/gregbook to work under cygwin/mingw. + +Version 1.5.0beta42 [August 18, 2010] + Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov) + Made all API functions that have const arguments and constant string + literal pointers declare them (John Bowler). + +Version 1.5.0beta43 [August 20, 2010] + Removed spurious tabs, shorten long lines (no source change) + Also added scripts/chkfmt to validate the format of all the files that can + reasonably be validated (it is suggested to run "make distclean" before + checking, because some machine generated files have long lines.) + Reformatted the CHANGES file to be more consistent throughout. + Made changes to address various issues identified by GCC, mostly + signed/unsigned and shortening problems on assignment but also a few + difficult to optimize (for GCC) loops. + Fixed non-GCC fixed point builds. In png.c a declaration was misplaced + in an earlier update. Fixed to declare the auto variables at the head. + Use cexcept.h in pngvalid.c. + +Version 1.5.0beta44 [August 24, 2010] + Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for + installing libpng in /usr/lib64 (Funda Wang). + Revised CMakeLists.txt to put the man pages in share/man/man* not man/man* + Revised CMakeLists.txt to make symlinks instead of copies when installing. + Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman) + Implemented memory checks within pngvalid + Reformatted/rearranged pngvalid.c to assist use of progressive reader. + Check interlaced images in pngvalid + Clarified pngusr.h comments in pnglibconf.dfa + Simplified the pngvalid error-handling code now that cexcept.h is in place. + Implemented progressive reader in pngvalid.c for standard tests + Implemented progressive read in pngvalid.c gamma tests + Turn on progressive reader in pngvalid.c by default and tidy code. + +Version 1.5.0beta45 [August 26, 2010] + Added an explicit make step to projects/vstudio for pnglibconf.h + Also corrected zlib.vcxproj into which Visual Studio had introduced + what it calls an "authoring error". The change to make pnglibconf.h + simply copies the file; in the future it may actually generate the + file from scripts/pnglibconf.dfa as the other build systems do. + Changed pngvalid to work when floating point APIs are disabled + Renamed the prebuilt scripts/pnglibconf.h to scripts/pnglibconf.h.prebuilt + Supply default values for PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX + in pngpriv.h in case the user neglected to define them in their pngusr.h + +Version 1.5.0beta46 [August 28, 2010] + Added new private header files to libpng_sources in CMakeLists.txt + Added PNG_READ_16BIT, PNG_WRITE_16BIT, and PNG_16BIT options. + Added reference to scripts/pnglibconf.h.prebuilt in the visualc71 project. + +Version 1.5.0beta47 [September 11, 2010] + Fixed a number of problems with 64-bit compilation reported by Visual + Studio 2010 (John Bowler). + +Version 1.5.0beta48 [October 4, 2010] + Updated CMakeLists.txt (Philip Lowman). + Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER, + $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE + Fixed problem with symbols creation in Makefile.am which was assuming that + all versions of ccp write to standard output by default (Martin Banky). The + bug was introduced in libpng-1.2.9beta5. + Removed unused mkinstalldirs. + +Version 1.5.0beta49 [October 8, 2010] + Undid Makefile.am revision of 1.5.0beta48. + +Version 1.5.0beta50 [October 14, 2010] + Revised Makefile.in to account for mkinstalldirs being removed. + Added some "(unsigned long)" typecasts in printf statements in pngvalid.c. + Suppressed a compiler warning in png_handle_sPLT(). + Check for out-of-range text compression mode in png_set_text(). + +Version 1.5.0beta51 [October 15, 2010] + Changed embedded dates to "(PENDING RELEASE) in beta releases (and future + rc releases) to minimize the difference between releases. + +Version 1.5.0beta52 [October 16, 2010] + Restored some of the embedded dates (in png.h, png.c, documentation, etc.) + +Version 1.5.0beta53 [October 18, 2010] + Updated INSTALL to mention using "make maintainer-clean" and to remove + obsolete statement about a custom ltmain.sh + Disabled "color-tests" by default in Makefile.am so it will work with + automake versions earlier than 1.11.1 + Use document name "libpng-manual.txt" instead of "libpng-.txt" + to simplify version differences. + Removed obsolete remarks about setjmp handling from INSTALL. + Revised and renamed the typedef in png.h and png.c that was designed + to catch library and header mismatch. + +Version 1.5.0beta54 [November 10, 2010] + Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks. + Used a consistent structure for the pngget.c functions. + +Version 1.5.0beta55 [November 21, 2010] + Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin) + Moved reading of file signature into png_read_sig (Cosmin) + Fixed atomicity of chunk header serialization (Cosmin) + Added test for io_state in pngtest.c (Cosmin) + Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts. + Changes to remove gcc warnings (John Bowler) + Certain optional gcc warning flags resulted in warnings in libpng code. + With these changes only -Wconversion and -Wcast-qual cannot be turned on. + Changes are trivial rearrangements of code. -Wconversion is not possible + for pngrutil.c (because of the widespread use of += et al on variables + smaller than (int) or (unsigned int)) and -Wcast-qual is not possible + with pngwio.c and pngwutil.c because the 'write' callback and zlib + compression both fail to declare their input buffers with 'const'. + +Version 1.5.0beta56 [December 7, 2010] + Added the private PNG_UNUSED() macro definition in pngpriv.h. + Added some commentary about PNG_EXPORT in png.h and pngconf.h + Revised PNG_EXPORT() macro and added PNG_EXPORTA() macro, with the + objective of simplifying and improving the cosmetic appearance of png.h. + Fixed some incorrect "=" macro names in pnglibconf.dfa + Included documentation of changes in 1.5.0 from 1.4.x in libpng-manual.txt + +Version 1.5.0beta57 [December 9, 2010] + Documented the pngvalid gamma error summary with additional comments and + print statements. + Improved missing symbol handling in checksym.awk; symbols missing in both + the old and new files can now be optionally ignored, treated as errors + or warnings. + Removed references to pngvcrd.c and pnggccrd.c from the vstudio project. + Updated "libpng14" to "libpng15" in the visualc71 project. + Enabled the strip16 tests in pngvalid.` + Don't display test results (except PASS/FAIL) when running "make test". + Instead put them in pngtest-log.txt + Added "--with-zprefix=" to configure.ac + Updated the prebuilt configuration files to autoconf version 2.68 + +Version 1.5.0beta58 [December 19, 2010] + Fixed interlace image handling and add test cases (John Bowler) + Fixed the clean rule in Makefile.am to remove pngtest-log.txt + Made minor changes to work around warnings in gcc 3.4 + +Version 1.5.0rc01 [December 27, 2010] No changes. -version 1.2.46rc01 and 1.0.56rc01 [July 8, 2011] - Reverted changes to Makefile.am and Makefile.in to libpng-1.2.44 versions. +Version 1.5.0rc02 [December 27, 2010] + Eliminated references to the scripts/*.def files in project/visualc71. -version 1.2.46rc02 and 1.0.56rc02 [July 8, 2011] - Added CMakeLists.txt, projects/xcode, and pnggccrd.c to EXTRA_DIST in - Makefile.am and Makefile.in +Version 1.5.0rc03 [December 28, 2010] + Eliminated scripts/*.def and revised Makefile.am accordingly -version 1.2.46 and 1.0.56 [July 9, 2011] - Udated copyright year to 2011. +Version 1.5.0rc04 [December 29, 2010] + Fixed bug in background transformation handling in pngrtran.c (it was + looking for the flag in png_ptr->transformations instead of in + png_ptr->flags) (David Raymond). -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit +Version 1.5.0rc05 [December 31, 2010] + Fixed typo in a comment in CMakeLists.txt (libpng14 => libpng15) (Cosmin) + +Version 1.5.0rc06 [January 4, 2011] + Changed the new configure option "zprefix=string" to "zlib-prefix=string" + +Version 1.5.0rc07 [January 4, 2011] + Updated copyright year. + +Version 1.5.0 [January 6, 2011] + No changes. + +version 1.5.1beta01 [January 8, 2011] + Added description of png_set_crc_action() to the manual. + Added a note in the manual that the type of the iCCP profile was changed + from png_charpp to png_bytepp in png_get_iCCP(). This change happened + in version 1.5.0beta36 but is not noted in the CHANGES. Similarly, + it was changed from png_charpp to png_const_bytepp in png_set_iCCP(). + Ensure that png_rgb_to_gray ignores palette mapped images, if libpng + internally happens to call it with one, and fixed a failure to handle + palette mapped images correctly. This fixes CVE-2690. + +Version 1.5.1beta02 [January 14, 2011] + Fixed a bug in handling of interlaced images (bero at arklinux.org). + Updated CMakeLists.txt (Clifford Yapp) + +Version 1.5.1beta03 [January 14, 2011] + Fixed typecasting of some png_debug() statements (Cosmin) + +Version 1.5.1beta04 [January 16, 2011] + Updated documentation of png_set|get_tRNS() (Thomas Klausner). + Mentioned in the documentation that applications must #include "zlib.h" + if they need access to anything in zlib.h, and that a number of + macros such as png_memset() are no longer accessible by applications. + Corrected pngvalid gamma test "sample" function to access all of the color + samples of each pixel, instead of sampling the red channel three times. + Prefixed variable names index, div, exp, gamma with "png_" to avoid "shadow" + warnings, and (mistakenly) changed png_exp() to exp(). + +Version 1.5.1beta05 [January 16, 2011] + Changed variable names png_index, png_div, png_exp, and png_gamma to + char_index, divisor, exp_b10, and gamma_val, respectively, and + changed exp() back to png_exp(). + +Version 1.5.1beta06 [January 20, 2011] + Prevent png_push_crc_skip() from hanging while reading an unknown chunk + or an over-large compressed zTXt chunk with the progressive reader. + Eliminated more GCC "shadow" warnings. + Revised png_fixed() in png.c to avoid compiler warning about reaching the + end without returning anything. + +Version 1.5.1beta07 [January 22, 2011] + In the manual, describe the png_get_IHDR() arguments in the correct order. + Added const_png_structp and const_png_infop types, and used them in + prototypes for most png_get_*() functions. + +Version 1.5.1beta08 [January 23, 2011] + Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name() + Added synopses for the IO_STATE functions and other missing synopses + to the manual. Removed the synopses from libpngpf.3 because they + were out of date and no longer useful. Better information can be + obtained by reading the prototypes and comments in pngpriv.h + Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build + Added a make macro DFNCPP that is a CPP that will accept the tokens in + a .dfn file and adds configure stuff to test for such a CPP. ./configure + should fail if one is not available. + Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace. + Added png_get_current_row_number and png_get_current_pass_number for the + benefit of the user transform callback. + Added png_process_data_pause and png_process_data_skip for the benefit of + progressive readers that need to stop data processing or want to optimize + skipping of unread data (e.g., if the reader marks a chunk to be skipped.) + +Version 1.5.1beta09 [January 24, 2011] + Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error. + pngvalid contains tests of transforms, which tests are currently disabled + because they are incompletely tested. gray_to_rgb was failing to expand + the bit depth for smaller bit depth images; this seems to be a long + standing error and resulted, apparently, in invalid output + (CVE-2011-0408, CERT VU#643140). The documentation did not accurately + describe what libpng really does when converting RGB to gray. + +Version 1.5.1beta10 [January 27, 2010] + Fixed incorrect examples of callback prototypes in the manual, that were + introduced in libpng-1.0.0. + In addition the order of the png_get_uint macros with respect to the + relevant function definitions has been reversed. This helps the + preprocessing of the symbol files be more robust. Furthermore, the + symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when + the library may actually be built with PNG_USE_READ_MACROS; this stops + the read macros interfering with the symbol file format. + Made the manual, synopses, and function prototypes use the function + argument names file_gamma, int_file_gamma, and srgb_intent consistently. + +Version 1.5.1beta11 [January 28, 2011] + Changed PNG_UNUSED from "param=param;" to "{if(param){}}". + Corrected local variable type in new API png_process_data_skip() + The type was self-evidently incorrect but only causes problems on 64-bit + architectures. + Added transform tests to pngvalid and simplified the arguments. + +Version 1.5.1rc01 [January 29, 2011] + No changes. + +Version 1.5.1rc02 [January 31, 2011] + Added a request in the manual that applications do not use "png_" or + "PNG_" to begin any of their own symbols. + Changed PNG_UNUSED to "(void)param;" and updated the commentary in pngpriv.h + +Version 1.5.1 [February 3, 2011] + No changes. + +Version 1.5.2beta01 [February 13, 2011] + More -Wshadow fixes for older gcc compilers. Older gcc versions apparently + check formal parameters names in function declarations (as well as + definitions) to see if they match a name in the global namespace. + Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the + old VisualC++ preprocessor. + Turned on interlace handling in png_read_png(). + Fixed gcc pedantic warnings. + Handle longjmp in Cygwin. + Fixed png_get_current_row_number() in the interlaced case. + Cleaned up ALPHA flags and transformations. + Implemented expansion to 16 bits. + +Version 1.5.2beta02 [February 19, 2011] + Fixed mistake in the descriptions of user read_transform and write_transform + function prototypes in the manual. The row_info struct is png_row_infop. + Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior. + Corrected png_get_current_row_number documentation + Fixed the read/write row callback documentation. + This documents the current behavior, where the callback is called after + every row with information pertaining to the next row. + +Version 1.5.2beta03 [March 3, 2011] + Fixed scripts/makefile.vcwin32 + Updated contrib/pngsuite/README to add the word "modify". + Define PNG_ALLOCATED to blank when _MSC_VER<1300. + +Version 1.5.2rc01 [March 19, 2011] + Define remaining attributes to blank when MSC_VER<1300. + ifdef out mask arrays in pngread.c when interlacing is not supported. + +Version 1.5.2rc02 [March 22, 2011] + Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak + and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip" + from the makefiles. + Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail + to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill) + +Version 1.5.2rc03 [March 24, 2011] + Don't include standard header files in png.h while building the symbol table, + to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro). + +Version 1.5.2 [March 31, 2011] + No changes. + +Version 1.5.3beta01 [April 1, 2011] + Re-initialize the zlib compressor before compressing non-IDAT chunks. + Added API functions (png_set_text_compression_level() and four others) to + set parameters for zlib compression of non-IDAT chunks. + +Version 1.5.3beta02 [April 3, 2011] + Updated scripts/symbols.def with new API functions. + Only compile the new zlib re-initializing code when text or iCCP is + supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro. + Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03). + Optimize the zlib CMF byte in non-IDAT compressed chunks + +Version 1.5.3beta03 [April 16, 2011] + Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have + snprintf, and the "__STRICT_ANSI__" detects that condition more reliably + than __STDC__ (John Bowler). + Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells + the compiler that a user supplied callback (the error handler) does not + return, yet there is no guarantee in practice that the application code + will correctly implement the error handler because the compiler only + issues a warning if there is a mistake (John Bowler). + Removed the no-longer-used PNG_DEPSTRUCT macro. + Updated the zlib version to 1.2.5 in the VStudio project. + Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in + pngwutil.c (John Bowler). + Fixed bug with stripping the filler or alpha channel when writing, that + was introduced in libpng-1.5.2beta01 (bug report by Andrew Church). + +Version 1.5.3beta04 [April 27, 2011] + Updated pngtest.png with the new zlib CMF optimization. + Cleaned up conditional compilation code and of background/gamma handling + Internal changes only except a new option to avoid compiling the + png_build_grayscale_palette API (which is not used at all internally.) + The main change is to move the transform tests (READ_TRANSFORMS, + WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids + calls to spurious functions if all transforms are disabled and slightly + simplifies those functions. Pngvalid modified to handle this. + A minor change is to stop the strip_16 and expand_16 interfaces from + disabling each other; this allows the future alpha premultiplication + code to use 16-bit intermediate values while still producing 8-bit output. + png_do_background and png_do_gamma have been simplified to take a single + pointer to the png_struct rather than pointers to every item required + from the png_struct. This makes no practical difference to the internal + code. + A serious bug in the pngvalid internal routine 'standard_display_init' has + been fixed - this failed to initialize the red channel and accidentally + initialized the alpha channel twice. + Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to + avoid a possible clash with the png_jmpbuf macro on some platforms. + +Version 1.5.3beta05 [May 6, 2011] + Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the + correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and + pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs. + Removed png_snprintf and added formatted warning messages. This change adds + internal APIs to allow png_warning messages to have parameters without + requiring the host OS to implement snprintf. As a side effect the + dependency of the tIME-supporting RFC1132 code on stdio is removed and + PNG_NO_WARNINGS does actually work now. + Pass "" instead of '\0' to png_default_error() in png_err(). This mistake + was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691. + Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte + optimization configurable. + IDAT compression failed if preceded by a compressed text chunk (bug + introduced in libpng-1.5.3beta01-02). This was because the attempt to + reset the zlib stream in png_write_IDAT happened after the first IDAT + chunk had been deflated - much too late. In this change internal + functions were added to claim/release the z_stream and, hopefully, make + the code more robust. Also deflateEnd checking is added - previously + libpng would ignore an error at the end of the stream. + +Version 1.5.3beta06 [May 8, 2011] + Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt + Implemented premultiplied alpha support: png_set_alpha_mode API + +Version 1.5.3beta07 [May 11, 2011] + Added expand_16 support to the high level interface. + Added named value and 'flag' gamma support to png_set_gamma. Made a minor + change from the previous (unreleased) ABI/API to hide the exact value used + for Macs - it's not a good idea to embed this in the ABI! + Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT + from pngpriv.h to png.h because they must be visible to applications + that call png_set_unknown_chunks(). + Check for up->location !PNG_AFTER_IDAT when writing unknown chunks + before IDAT. + +Version 1.5.3beta08 [May 16, 2011] + Improved "pngvalid --speed" to exclude more of pngvalid from the time. + Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt + The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative + parameters are supplied by the caller), while in the absence of cHRM + sRGB/Rec 709 values are still used. This introduced a divide-by-zero + bug in png_handle_cHRM(). + The bKGD chunk no longer overwrites the background value set by + png_set_background(), allowing the latter to be used before the file + header is read. It never performed any useful function to override + the default anyway. + Added memory overwrite and palette image checks to pngvalid.c + Previously palette image code was poorly checked. Since the transformation + code has a special palette path in most cases this was a severe weakness. + Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When + expanding an indexed image, always expand to RGBA if transparency is + present. + +Version 1.5.3beta09 [May 17, 2011] + Reversed earlier 1.5.3 change of transformation order; move png_expand_16 + back where it was. The change doesn't work because it requires 16-bit + gamma tables when the code only generates 8-bit ones. This fails + silently; the libpng code just doesn't do any gamma correction. Moving + the tests back leaves the old, inaccurate, 8-bit gamma calculations, but + these are clearly better than none! + +Version 1.5.3beta10 [May 20, 2011] + + png_set_background() and png_expand_16() did not work together correctly. + This problem is present in 1.5.2; if png_set_background is called with + need_expand false and the matching 16 bit color libpng erroneously just + treats it as an 8-bit color because of where png_do_expand_16 is in the + transform list. This simple fix reduces the supplied colour to 8-bits, + so it gets smashed, but this is better than the current behavior. + Added tests for expand16, more fixes for palette image tests to pngvalid. + Corrects the code for palette image tests and disables attempts to + validate palette colors. + +Version 1.5.3rc01 [June 3, 2011] + No changes. + +Version 1.5.3rc02 [June 8, 2011] + Fixed uninitialized memory read in png_format_buffer() (Bug report by + Frank Busse, CVE-2011-2501, related to CVE-2004-0421). + +Version 1.5.3beta11 [June 11, 2011] + Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692. + Added sCAL to pngtest.png + Revised documentation about png_set_user_limits() to say that it also affects + png writing. + Revised handling of png_set_user_limits() so that it can increase the + limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only + reduce it. + Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is + wrong (high by one) 25% of the time. Dividing by 257 with rounding is + wrong in 128 out of 65536 cases. Getting the right answer all the time + without division is easy. + Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro. + Added projects/owatcom, an IDE project for OpenWatcom to replace + scripts/makefile.watcom. This project works with OpenWatcom 1.9. The + IDE autogenerates appropriate makefiles (libpng.mk) for batch processing. + The project is configurable, unlike the Visual Studio project, so long + as the developer has an awk. + Changed png_set_gAMA to limit the gamma value range so that the inverse + of the stored value cannot overflow the fixed point representation, + and changed other things OpenWatcom warns about. + Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows + pngvalid to build when ALPHA_MODE is not supported, which is required if + it is to build on libpng 1.4. + Removed string/memory macros that are no longer used and are not + necessarily fully supportable, particularly png_strncpy and png_snprintf. + Added log option to pngvalid.c and attempted to improve gamma messages. + +Version 1.5.3 [omitted] + People found the presence of a beta release following an rc release + to be confusing; therefore we bump the version to libpng-1.5.4beta01 + and there will be no libpng-1.5.3 release. + +Version 1.5.4beta01 [June 14, 2011] + Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED + to get the same (inaccurate) output as libpng-1.5.2 and earlier. + Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE + outside of an unknown-chunk block in png.h because they are also + needed for other uses. + +Version 1.5.4beta02 [June 14, 2011] + Fixed and clarified LEGACY 16-to-8 scaling code. + Added png_set_chop_16() API, to match inaccurate results from previous + libpng versions. + Removed the ACCURATE and LEGACY options (they are no longer useable) + Use the old scaling method for background if png_set_chop_16() was + called. + Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED + +Version 1.5.4beta03 [June 15, 2011] + Fixed a problem in png_do_expand_palette() exposed by optimization in + 1.5.3beta06 + Also removed a spurious and confusing "trans" member ("trans") from png_info. + The palette expand optimization prevented expansion to an intermediate RGBA + form if tRNS was present but alpha was marked to be stripped; this exposed + a check for tRNS in png_do_expand_palette() which is inconsistent with the + code elsewhere in libpng. + Correction to the expand_16 code; removed extra instance of + png_set_scale_16_to_8 from pngpriv.h + +Version 1.5.4beta04 [June 16, 2011] + Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c + Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms. + Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is + not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built. + Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8 + +Version 1.5.4beta05 [June 16, 2011] + Renamed png_set_strip_16() to png_set_scale_16() and renamed + png_set_chop_16() to png_set_strip(16) in an attempt to minimize the + behavior changes between libpng14 and libpng15. + +Version 1.5.4beta06 [June 18, 2011] + Fixed new bug that was causing both strip_16 and scale_16 to be applied. + +Version 1.5.4beta07 [June 19, 2011] + Fixed pngvalid, simplified macros, added checking for 0 in sCAL. + The ACCURATE scale macro is no longer defined in 1.5 - call the + png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined + if the png_strip_16_to_8 API is present. png_check_fp_number now + maintains some state so that positive, negative and zero values are + identified. sCAL uses these to be strictly spec conformant. + +Version 1.5.4beta08 [June 23, 2011] + Fixed pngvalid if ACCURATE_SCALE is defined. + Updated scripts/pnglibconf.h.prebuilt. + +Version 1.5.4rc01 [June 30, 2011] + Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400. + +Version 1.5.4 [July 7, 2011] + No changes. + +Version 1.5.5beta01 [July 13, 2011] + Fixed some typos and made other minor changes in the manual. + Updated contrib/pngminus/makefile.std (Samuli Souminen) + +Version 1.5.5beta02 [July 14, 2011] + Revised Makefile.am and Makefile.in to look in the right directory for + pnglibconf.h.prebuilt + +Version 1.5.5beta03 [July 27, 2011] + Enabled compilation with g++ compiler. This compiler does not recognize + the file extension, so it always compiles with C++ rules. Made minor + changes to pngrutil.c to cast results where C++ expects it but C does not. + Minor editing of libpng.3 and libpng-manual.txt. + +Version 1.5.5beta04 [July 29, 2011] + Revised CMakeLists.txt (Clifford Yapp) + Updated commentary about the png_rgb_to_gray() default coefficients + in the manual and in pngrtran.c + +Version 1.5.5beta05 [August 17, 2011] + Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL" + is removed from the test of whether a DLL is being built (this erroneously + caused the libpng APIs to be marked as DLL exports in static builds under + Microsoft Visual Studio). Almost all of the libpng building configuration + is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in + pngconf.h, though, so that it is colocated with the import definition (it + is no longer used anywhere in the installed headers). The VStudio project + definitions have been cleaned up: "_USRDLL" has been removed from the + static library builds (this was incorrect), and PNG_USE_DLL has been added + to pngvalid to test the functionality (pngtest does not supply it, + deliberately). The spurious "_EXPORTS" has been removed from the + libpng build (all these errors were a result of copy/paste between project + configurations.) + Added new types and internal functions for CIE RGB end point handling to + pngpriv.h (functions yet to be implemented). + +Version 1.5.5beta06 [August 26, 2011] + Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt + (Clifford Yap) + Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler): + The rgb_to_gray code had errors when combined with gamma correction. + Some pixels were treated as true grey when they weren't and such pixels + and true grey ones were not gamma corrected (the original value of the + red component was used instead). APIs to get and set cHRM using color + space end points have been added and the rgb_to_gray code that defaults + based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT + VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected. + A considerable number of tests has been added to pngvalid for the + rgb_to_gray transform. + Arithmetic errors in rgb_to_gray whereby the calculated gray value was + truncated to the bit depth rather than rounded have been fixed except in + the 8-bit non-gamma-corrected case (where consistency seems more important + than correctness.) The code still has considerable inaccuracies in the + 8-bit case because 8-bit linear arithmetic is used. + +Version 1.5.5beta07 [September 7, 2011] + Added "$(ARCH)" option to makefile.darwin + Added SunOS support to configure.ac and Makefile.am + Changed png_chunk_benign_error() to png_warning() in png.c, in + png_XYZ_from_xy_checked(). + +Version 1.5.5beta08 [September 10, 2011] + Fixed 64-bit compilation errors (gcc). The errors fixed relate + to conditions where types that are 32 bits in the GCC 32-bit + world (uLong and png_size_t) become 64 bits in the 64-bit + world. This produces potential truncation errors which the + compiler correctly flags. + Relocated new HAVE_SOLARIS_LD definition in configure.ac + Constant changes for 64-bit compatibility (removal of L suffixes). The + 16-bit cases still use "L" as we don't have a 16-bit test system. + +Version 1.5.5rc01 [September 15, 2011] + Removed "L" suffixes in pngpriv.h + +Version 1.5.5 [September 22, 2011] + No changes. + +Version 1.5.6beta01 [September 22, 2011] + Fixed some 64-bit type conversion warnings in pngrtran.c + Moved row_info from png_struct to a local variable. + The various interlace mask arrays have been made into arrays of + bytes and made PNG_CONST and static (previously some arrays were + marked PNG_CONST and some weren't). + Additional checks have been added to the transform code to validate the + pixel depths after the transforms on both read and write. + Removed some redundant code from pngwrite.c, in png_destroy_write_struct(). + Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4]. + This removes the need to allocate temporary strings for chunk names on + the stack in the read/write code. Unknown chunk handling still uses the + string form because this is exposed in the API. + +Version 1.5.6beta02 [September 26, 2011] + Added a note in the manual the png_read_update_info() must be called only + once with a particular info_ptr. + Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro. + +Version 1.5.6beta03 [September 28, 2011] + Revised test-pngtest.sh to report FAIL when pngtest fails. + Added "--strict" option to pngtest, to report FAIL when the failure is + only because the resulting valid files are different. + Revised CMakeLists.txt to work with mingw and removed some material from + CMakeLists.txt that is no longer useful in libpng-1.5. + +Version 1.5.6beta04 [October 5, 2011] + Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")." + +Version 1.5.6beta05 [October 12, 2011] + Speed up png_combine_row() for interlaced images. This reduces the generality + of the code, allowing it to be optimized for Adam7 interlace. The masks + passed to png_combine_row() are now generated internally, avoiding + some code duplication and localizing the interlace handling somewhat. + Align png_struct::row_buf - previously it was always unaligned, caused by + a bug in the code that attempted to align it; the code needs to subtract + one from the pointer to take account of the filter byte prepended to + each row. + Optimized png_combine_row() when rows are aligned. This gains a small + percentage for 16-bit and 32-bit pixels in the typical case where the + output row buffers are appropriately aligned. The optimization was not + previously possible because the png_struct buffer was always misaligned. + Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01. + +Version 1.5.6beta06 [October 17, 2011] + Removed two redundant tests for uninitialized row. + Fixed a relatively harmless memory overwrite in compressed text writing + with a 1 byte zlib buffer. + Add ability to call png_read_update_info multiple times to pngvalid.c. + Fixes for multiple calls to png_read_update_info. These fixes attend to + most of the errors revealed in pngvalid, however doing the gamma work + twice results in inaccuracies that can't be easily fixed. There is now + a warning in the code if this is going to happen. + Turned on multiple png_read_update_info in pngvalid transform tests. + Prevent libpng from overwriting unused bits at the end of the image when + it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would + overwrite the partial byte at the end of each row if the row width was not + an exact multiple of 8 bits and the image is not interlaced. + +Version 1.5.6beta07 [October 21, 2011] + Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row + (Mans Rullgard). + +Version 1.5.6rc01 [October 26, 2011] + Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM" + +Version 1.5.6rc02 [October 27, 2011] + Added LSR() macro to defend against buggy compilers that evaluate non-taken + code branches and complain about out-of-range shifts. + +Version 1.5.6rc03 [October 28, 2011] + Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro. + Fixed compiler warnings with Intel and MSYS compilers. The logical shift + fix for Microsoft Visual C is required by other compilers, so this + enables that fix for all compilers when using compile-time constants. + Under MSYS 'byte' is a name declared in a system header file, so we + changed the name of a local variable to avoid the warnings that result. + Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h + +Version 1.5.6 [November 3, 2011] + No changes. + +Version 1.5.7beta01 [November 4, 2011] + Added support for ARM processor, when decoding all PNG up-filtered rows + and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard). + Fixed bug in pngvalid on early allocation failure; fixed type cast in + pngmem.c; pngvalid would attempt to call png_error() if the allocation + of a png_struct or png_info failed. This would probably have led to a + crash. The pngmem.c implementation of png_malloc() included a cast + to png_size_t which would fail on large allocations on 16-bit systems. + Fix for the preprocessor of the Intel C compiler. The preprocessor + splits adjacent @ signs with a space; this changes the concatenation + token from @-@-@ to PNG_JOIN; that should work with all compiler + preprocessors. + Paeth filter speed improvements from work by Siarhei Siamashka. This + changes the 'Paeth' reconstruction function to improve the GCC code + generation on x86. The changes are only part of the suggested ones; + just the changes that definitely improve speed and remain simple. + The changes also slightly increase the clarity of the code. + +Version 1.5.7beta02 [November 11, 2011] + Check compression_type parameter in png_get_iCCP and remove spurious + casts. The compression_type parameter is always assigned to, so must + be non-NULL. The cast of the profile length potentially truncated the + value unnecessarily on a 16-bit int system, so the cast of the (byte) + compression type to (int) is specified by ANSI-C anyway. + Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left + the sBIT fields in the test pixel as 0, which resulted in a floating + point division by zero which was irrelevant but causes systems where + FP exceptions cause a crash. Added code to pngvalid to turn on FP + exceptions if the appropriate glibc support is there to ensure this is + tested in the future. + Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the + new PNG_JOIN macro. + Added versioning to pnglibconf.h comments. + Simplified read/write API initial version; basic read/write tested on + a variety of images, limited documentation (in the header file.) + Installed more accurate linear to sRGB conversion tables. The slightly + modified tables reduce the number of 16-bit values that + convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used + to generate the tables is now in a contrib/sRGBtables sub-directory. + +Version 1.5.7beta03 [November 17, 2011] + Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c + Added run-time detection of NEON support. + Added contrib/libtests; includes simplified API test and timing test and + a color conversion utility for rapid checking of failed 'pngstest' results. + Multiple transform bug fixes plus a work-round for double gamma correction. + libpng does not support more than one transform that requires linear data + at once - if this is tried typically the results is double gamma + correction. Since the simplified APIs can need rgb to gray combined with + a compose operation it is necessary to do one of these outside the main + libpng transform code. This check-in also contains fixes to various bugs + in the simplified APIs themselves and to some bugs in compose and rgb to + gray (on palette) itself. + Fixes for C++ compilation using g++ When libpng source is compiled + using g++. The compiler imposes C++ rules on the C source; thus it + is desirable to make the source work with either C or C++ rules + without throwing away useful error information. This change adds + png_voidcast to allow C semantic (void*) cases or the corresponding + C++ static_cast operation, as appropriate. + Added --noexecstack to assembler file compilation. GCC does not set + this on assembler compilation, even though it does on C compilation. + This creates security issues if assembler code is enabled; the + work-around is to set it by default in the flags for $(CCAS) + Work around compilers that don't support declaration of const data. Some + compilers fault 'extern const' data declarations (because the data is + not initialized); this turns on const-ness only for compilers where + this is known to work. + +Version 1.5.7beta04 [November 17, 2011] + Since the gcc driver does not recognize the --noexecstack flag, we must + use the -Wa prefix to have it passed through to the assembler. + Also removed a duplicate setting of this flag. + Added files that were omitted from the libpng-1.5.7beta03 zip distribution. + +Version 1.5.7beta05 [November 25, 2011] + Removed "zTXt" from warning in generic chunk decompression function. + Validate time settings passed to png_set_tIME() and png_convert_to_rfc1123() + (Frank Busse). Note: This prevented CVE-2015-7981 from affecting + libpng-1.5.7 and later. + Added MINGW support to CMakeLists.txt + Reject invalid compression flag or method when reading the iTXt chunk. + Backed out 'simplified' API changes. The API seems too complex and there + is a lack of consensus or enthusiasm for the proposals. The API also + reveals significant bugs inside libpng (double gamma correction and the + known bug of being unable to retrieve a corrected palette). It seems + better to wait until the bugs, at least, are corrected. + Moved pngvalid.c into contrib/libtests + Rebuilt Makefile.in, configure, etc., with autoconf-2.68 + +Version 1.5.7rc01 [December 1, 2011] + Replaced an "#if" with "#ifdef" in pngrtran.c + Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else) + +Version 1.5.7rc02 [December 5, 2011] + Revised project files and contrib/pngvalid/pngvalid.c to account for + the relocation of pngvalid into contrib/libtests. + Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400, + as in libpng-1.5.4. + Put CRLF line endings in the owatcom project files. + +Version 1.5.7rc03 [December 7, 2011] + Updated CMakeLists.txt to account for the relocation of pngvalid.c + +Version 1.5.7 [December 15, 2011] + Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings + reported by earlier versions. + Fixed minor memset/sizeof errors in pngvalid.c. + +Version 1.6.0beta01 [December 15, 2011] + Removed machine-generated configure files from the GIT repository (they will + continue to appear in the tarball distributions and in the libpng15 and + earlier GIT branches). + Restored the new 'simplified' API, which was started in libpng-1.5.7beta02 + but later deleted from libpng-1.5.7beta05. + Added example programs for the new 'simplified' API. + Added ANSI-C (C90) headers and require them, and take advantage of the + change. Also fixed some of the projects/* and contrib/* files that needed + updates for libpng16 and the move of pngvalid.c. + With this change the required ANSI-C header files are assumed to exist: the + implementation must provide float.h, limits.h, stdarg.h and stddef.h and + libpng relies on limits.h and stddef.h existing and behaving as defined + (the other two required headers aren't used). Non-ANSI systems that don't + have stddef.h or limits.h will have to provide an appropriate fake + containing the relevant types and #defines. + Dropped support for 16-bit platforms. The use of FAR/far has been eliminated + and the definition of png_alloc_size_t is now controlled by a flag so + that 'small size_t' systems can select it if necessary. Libpng 1.6 may + not currently work on such systems -- it seems likely that it will + ask 'malloc' for more than 65535 bytes with any image that has a + sufficiently large row size (rather than simply failing to read such + images). + New tools directory containing tools used to generate libpng code. + Fixed race conditions in parallel make builds. With higher degrees of + parallelism during 'make' the use of the same temporary file names such + as 'dfn*' can result in a race where a temporary file from one arm of the + build is deleted or overwritten in another arm. This changes the + temporary files for suffix rules to always use $* and ensures that the + non-suffix rules use unique file names. + +Version 1.6.0beta02 [December 21, 2011] + Correct configure builds where build and source directories are separate. + The include path of 'config.h' was erroneously made relative in pngvalid.c + in libpng 1.5.7. + +Version 1.6.0beta03 [December 22, 2011] + Start-up code size improvements, error handler flexibility. These changes + alter how the tricky allocation of the initial png_struct and png_info + structures are handled. png_info is now handled in pretty much the same + way as everything else, except that the allocations handle NULL return + silently. png_struct is changed in a similar way on allocation and on + deallocation a 'safety' error handler is put in place (which should never + be required). The error handler itself is changed to permit mismatches + in the application and libpng error buffer size; however, this means a + silent change to the API to return the jmp_buf if the size doesn't match + the size from the libpng compilation; libpng now allocates the memory and + this may fail. Overall these changes result in slight code size + reductions; however, this is a reduction in code that is always executed + so is particularly valuable. Overall on a 64-bit system the libpng DLL + decreases in code size by 1733 bytes. pngerror.o increases in size by + about 465 bytes because of the new functionality. + Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123() + to avoid including a spurious buffer in the png_struct. + +Version 1.6.0beta04 [December 30, 2011] + Regenerated configure scripts with automake-1.11.2 + Eliminated png_info_destroy(). It is now used only in png.c and only calls + one other internal function and memset(). + Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously + it was disabled whenever internal fixed point arithmetic was selected, + which meant it didn't exist even on systems where FP was available but not + preferred. + Added pngvalid.c compile time checks for const APIs. + Implemented 'restrict' for png_info and png_struct. Because of the way + libpng works both png_info and png_struct are always accessed via a + single pointer. This means adding C99 'restrict' to the pointer gives + the compiler some opportunity to optimize the code. This change allows + that. + Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper + location in configure.ac (Gilles Espinasse). + Changed png_memcpy to C assignment where appropriate. Changed all those + uses of png_memcpy that were doing a simple assignment to assignments + (all those cases where the thing being copied is a non-array C L-value). + Added some error checking to png_set_*() routines. + Removed the reference to the non-exported function png_memcpy() from + example.c. + Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but + it had become misaligned. + Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32 + and unsigned long are of different sizes. + +Version 1.6.0beta05 [January 15, 2012] + Updated manual with description of the simplified API (copied from png.h) + Fix bug in pngerror.c: some long warnings were being improperly truncated + (CVE-2011-3464, bug introduced in libpng-1.5.3beta05). + +Version 1.6.0beta06 [January 24, 2012] + Added palette support to the simplified APIs. This commit + changes some of the macro definitions in png.h, app code + may need corresponding changes. + Increased the formatted warning buffer to 192 bytes. + Added color-map support to simplified API. This is an initial version for + review; the documentation has not yet been updated. + Fixed Min/GW uninstall to remove libpng.dll.a + +Version 1.6.0beta07 [January 28, 2012] + Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) + compiler issues slightly different warnings from those issued by the + current vesions of GCC. This eliminates those warnings by + adding/removing casts and small code rewrites. + Updated configure.ac from autoupdate: added --enable-werror option. + Also some layout regularization and removal of introduced tab characters + (replaced with 3-character indentation). Obsolete macros identified by + autoupdate have been removed; the replacements are all in 2.59 so + the pre-req hasn't been changed. --enable-werror checks for support + for -Werror (or the given argument) in the compiler. This mimics the + gcc configure option by allowing -Werror to be turned on safely; without + the option the tests written in configure itself fail compilation because + they cause compiler warnings. + Rewrote autogen.sh to run autoreconf instead of running tools one-by-one. + Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and + set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp). + Freeze libtool files in the 'scripts' directory. This version of autogen.sh + attempts to dissuade people from running it when it is not, or should not, + be necessary. In fact, autogen.sh does not work when run in a libpng + directory extracted from a tar distribution anymore. You must run it in + a GIT clone instead. + Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale), + and renamed three whose names were inconsistent with those in + pngsuite/README.txt. + +Version 1.6.0beta08 [February 1, 2012] + Fixed Image::colormap misalignment in pngstest.c + Check libtool/libtoolize version number (2.4.2) in configure.ac + Divide test-pngstest.sh into separate pngstest runs for basic and + transparent images. + Moved automake options to AM_INIT_AUTOMAKE in configure.ac + Added color-tests, silent-rules (Not yet implemented in Makefile.am) and + version checking to configure.ac + Improved pngstest speed by not doing redundant tests and add const to + the background parameter of png_image_finish_read. The --background + option is now done automagically only when required, so that commandline + option no longer exists. + Cleaned up pngpriv.h to consistently declare all functions and data. + Also eliminated PNG_CONST_DATA, which is apparently not needed but we + can't be sure until it is gone. + Added symbol prefixing that allows all the libpng external symbols + to be prefixed (suggested by Reuben Hawkins). + Updated "ftbb*.png" list in the owatcom and vstudio projects. + Fixed 'prefix' builds on clean systems. The generation of pngprefix.h + should not require itself. + Updated INSTALL to explain that autogen.sh must be run in a GIT clone, + not in a libpng directory extracted from a tar distribution. + +Version 1.6.0beta09 [February 1, 2012] + Reverted the prebuilt configure files to libpng-1.6.0beta05 condition. + +Version 1.6.0beta10 [February 3, 2012] + Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests + Updated list of test images in CMakeLists.txt + Updated the prebuilt configure files to current condition. + Revised INSTALL information about autogen.sh; it works in tar distributions. + +Version 1.6.0beta11 [February 16, 2012] + Fix character count in pngstest command in projects/owatcom/pngstest.tgt + Revised test-pngstest.sh to report PASS/FAIL for each image. + Updated documentation about the simplified API. + Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is + extremely inaccurate for sRGB conversions because it uses an 8-bit + intermediate linear value and it does not use the sRGB transform, so it + suffers from the known instability in gamma transforms for values close + to 0 (see Poynton). The net result is that the calculation has a maximum + error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the + permitted 8-bit error. This may still not be enough because of arithmetic + error. + Removed some unused arrays (with #ifdef) from png_read_push_finish_row(). + Fixed a memory overwrite bug in simplified read of RGB PNG with + non-linear gamma Also bugs in the error checking in pngread.c and changed + quite a lot of the checks in pngstest.c to be correct; either correctly + written or not over-optimistic. The pngstest changes are insufficient to + allow all possible RGB transforms to be passed; pngstest cmppixel needs + to be rewritten to make it clearer which errors it allows and then changed + to permit known inaccuracies. + Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h + Fixed fixed/float API export conditionals. 1) If FIXED_POINT or + FLOATING_POINT options were switched off, png.h ended up with lone ';' + characters. This is not valid ANSI-C outside a function. The ';' + characters have been moved inside the definition of PNG_FP_EXPORT and + PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration + of the corresponding functions were completely omitted, even though some + of them are still used internally. The result is still valid, but + produces warnings from gcc with some warning options (including -Wall). The + fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION + when png.h is included from pngpriv.h. + Check for invalid palette index while reading paletted PNG. When one is + found, issue a warning and increase png_ptr->num_palette accordingly. + Apps are responsible for checking to see if that happened. + +Version 1.6.0beta12 [February 18, 2012] + Do not increase num_palette on invalid_index. + Relocated check for invalid palette index to pngrtran.c, after unpacking + the sub-8-bit pixels. + Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when + iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the + test on iCCP chunk length. Also removed spurious casts that may hide + problems on 16-bit systems. + +Version 1.6.0beta13 [February 24, 2012] + Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from + pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c; + now that png_ptr->buffer is inaccessible to applications, the special + handling is no longer useful. + Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new + pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is + defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the + configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in + pnglibconf.h.prebuilt and pnglibconf.h. + +Version 1.6.0beta14 [February 27, 2012] + Added information about the new limits in the manual. + Updated Makefile.in + +Version 1.6.0beta15 [March 2, 2012] + Removed unused "current_text" members of png_struct and the png_free() + of png_ptr->current_text from pngread.c + Rewrote pngstest.c for substantial speed improvement. + Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a + spurious check in pngwrite.c + Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store + intermediate files, or intermediate in-memory data, while processing + image data with the simplified API. The option makes the files larger + but faster to write and read. pngstest now uses this by default; this + can be disabled with the --slow option. + Improved pngstest fine tuning of error numbers, new test file generator. + The generator generates images that test the full range of sample values, + allow the error numbers in pngstest to be tuned and checked. makepng + also allows generation of images with extra chunks, although this is + still work-in-progress. + Added check for invalid palette index while reading. + Fixed some bugs in ICC profile writing. The code should now accept + all potentially valid ICC profiles and reject obviously invalid ones. + It now uses png_error() to do so rather than casually writing a PNG + without the necessary color data. + Removed whitespace from the end of lines in all source files and scripts. + +Version 1.6.0beta16 [March 6, 2012] + Relocated palette-index checking function from pngrutil.c to pngtrans.c + Added palette-index checking while writing. + Changed png_inflate() and calling routines to avoid overflow problems. + This is an intermediate check-in that solves the immediate problems and + introduces one performance improvement (avoiding a copy via png_ptr->zbuf.) + Further changes will be made to make ICC profile handling more secure. + Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options + declares 'index' as a global, causing a warning if it is used as a local + variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit) + to an (int) (signed 32-bit). MSVC, however, warns about using the + unary '-' operator on an unsigned value (even though it is well defined + by ANSI-C to be ~x+1). The padding calculation was changed to use a + different method. Removed the tests on png_ptr->pass. + Added contrib/libtests/tarith.c to test internal arithmetic functions from + png.c. This is a libpng maintainer program used to validate changes to the + internal arithmetic functions. + Made read 'inflate' handling like write 'deflate' handling. The read + code now claims and releases png_ptr->zstream, like the write code. + The bug whereby the progressive reader failed to release the zstream + is now fixed, all initialization is delayed, and the code checks for + changed parameters on deflate rather than always calling + deflatedEnd/deflateInit. + Validate the zTXt strings in pngvalid. + Added code to validate the windowBits value passed to deflateInit2(). + If the call to deflateInit2() is wrong a png_warning will be issued + (in fact this is harmless, but the PNG data produced may be sub-optimal). + +Version 1.6.0beta17 [March 10, 2012] + Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition. + Reject all iCCP chunks after the first, even if the first one is invalid. + Deflate/inflate was reworked to move common zlib calls into single + functions [rw]util.c. A new shared keyword check routine was also added + and the 'zbuf' is no longer allocated on progressive read. It is now + possible to call png_inflate() incrementally. A warning is no longer + issued if the language tag or translated keyword in the iTXt chunk + has zero length. + If benign errors are disabled use maximum window on ancillary inflate. + This works round a bug introduced in 1.5.4 where compressed ancillary + chunks could end up with a too-small windowBits value in the deflate + header. + +Version 1.6.0beta18 [March 16, 2012] + Issue a png_benign_error() instead of png_warning() about bad palette index. + In pngtest, treat benign errors as errors if "-strict" is present. + Fixed an off-by-one error in the palette index checking function. + Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) + Revised example.c to put text strings in a temporary character array + instead of directly assigning string constants to png_textp members. + This avoids compiler warnings when -Wwrite-strings is enabled. + Added output flushing to aid debugging under Visual Studio. Unfortunately + this is necessary because the VS2010 output window otherwise simply loses + the error messages on error (they weren't flushed to the window before + the process exited, apparently!) + Added configuration support for benign errors and changed the read + default. Also changed some warnings in the iCCP and sRGB handling + from to benign errors. Configuration now makes read benign + errors warnings and write benign errors to errors by default (thus + changing the behavior on read). The simplified API always forces + read benign errors to warnings (regardless of the system default, unless + this is disabled in which case the simplified API can't be built.) + +Version 1.6.0beta19 [March 18, 2012] + Work around for duplicate row start calls; added warning messages. + This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that + fails to call one of the 'start' routines (not enabled in libpng-1.5 + because it is technically an API change, since it did normally work + before.) It also makes duplicate calls to png_read_start_row (an + internal function called at the start of the image read) benign, as + they were before changes to use png_inflate_claim. Somehow webkit is + causing this to happen; this is probably a mis-feature in the zlib + changes so this commit is only a work-round. + Removed erroneous setting of DETECT_UNINITIALIZED and added more + checks. The code now does a png_error if an attempt is made to do the + row initialization twice; this is an application error and it has + serious consequences because the transform data in png_struct is + changed by each call. + Added application error reporting and added chunk names to read + benign errors; also added --strict to pngstest - not enabled + yet because a warning is produced. + Avoid the double gamma correction warning in the simplified API. + This allows the --strict option to pass in the pngstest checks + +Version 1.6.0beta20 [March 29, 2012] + Changed chunk handler warnings into benign errors, incrementally load iCCP + Added checksum-icc.c to contrib/tools + Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice. + Recognize known sRGB ICC profiles while reading; prefer writing the + iCCP profile over writing the sRGB chunk, controlled by the + PNG_sRGB_PROFILE_CHECKS option. + Revised png_set_text_2() to avoid potential memory corruption (fixes + CVE-2011-3048, also known as CVE-2012-3425). + +Version 1.6.0beta21 [April 27, 2012] + Revised scripts/makefile.darwin: use system zlib; remove quotes around + architecture list; add missing ppc architecture; add architecture options + to shared library link; don't try to create a shared lib based on missing + RELEASE variable. + Enable png_set_check_for_invalid_index() for both read and write. + Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around + declaration of png_handle_unknown(). + Added -lssp_nonshared in a comment in scripts/makefile.freebsd + and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE. + +Version 1.6.0beta22 [May 23, 2012] + Removed need for -Wno-cast-align with clang. clang correctly warns on + alignment increasing pointer casts when -Wcast-align is passed. This + fixes the cases that clang warns about either by eliminating the + casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c + where the cast is previously verified or pngstest.c where it is OK, by + introducing new png_aligncast macros to do the cast in a way that clang + accepts. + +Version 1.6.0beta23 [June 6, 2012] + Revised CMakeLists.txt to not attempt to make a symlink under mingw. + Made fixes for new optimization warnings from gcc 4.7.0. The compiler + performs an optimization which is safe; however it then warns about it. + Changing the type of 'palette_number' in pngvalid.c removes the warning. + Do not depend upon a GCC feature macro being available for use in generating + the linker mapfile symbol prefix. + Improved performance of new do_check_palette_indexes() function (only + update the value when it actually increases, move test for whether + the check is wanted out of the function. + +Version 1.6.0beta24 [June 7, 2012] + Don't check palette indexes if num_palette is 0 (as it can be in MNG files). + +Version 1.6.0beta25 [June 16, 2012] + Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all + unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT, + and IEND. Previously it only meant ignore all unknown chunks, the + same as num_chunks == 0. Revised png_image_skip_unused_chunks() to + provide a list of chunks to be processed instead of a list of chunks to + ignore. Revised contrib/gregbook/readpng2.c accordingly. + +Version 1.6.0beta26 [July 10, 2012] + Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it + depends on configure, which is not included in those archives. + Moved scripts/chkfmt to contrib/tools. + Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386. + +Version 1.6.0beta27 [August 11, 2012] + Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. + Do not use __restrict when GNUC is <= 3.1 + Removed references to png_zalloc() and png_zfree() from the manual. + Fixed configurations where floating point is completely disabled. Because + of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares + floating point APIs during libpng builds even if they are completely + disabled. This requires the png floating point types (png_double*) to be + declared even though the functions are never actually defined. This + change provides a dummy definition so that the declarations work, yet any + implementation will fail to compile because of an incomplete type. + Re-eliminated the use of strcpy() in pngtest.c. An unnecessary use of + strcpy() was accidentally re-introduced in libpng16; this change replaces + it with strncpy(). + Eliminated use of png_sizeof(); use sizeof() instead. + Use a consistent style for (sizeof type) and (sizeof (array)) + Cleanup of png_set_filler(). This function does very different things on + read and write. In libpng 1.6 the two cases can be distinguished and + considerable code cleanup, and extra error checking, is possible. This + makes calls on the write side that have no effect be ignored with a + png_app_error(), which can be disabled in the app using + png_set_benign_errors(), and removes the spurious use of usr_channels + on the read side. + Insist on autotools 1.12.1 for git builds because there are security issues + with 1.12 and insisting on anything less would allow 1.12 to be used. + Removed info_ptr->signature[8] from WRITE-only builds. + Add some conditions for compiling png_fixed(). This is a small function + but it requires "-lm" on some platforms. + Cause pngtest --strict to fail on any warning from libpng (not just errors) + and cause it not to fail at the comparison step if libpng lacks support + for writing chunks that it reads from the input (currently only implemented + for compressed text chunks). + Make all three "make check" test programs work without READ or WRITE support. + Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ + or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading + and writing of a PNG file is always tested by one or more of the tests. + Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the + png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros. + Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and + png_memcmp() macros. + Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object + to the split initialization of num_chunks. + +Version 1.6.0beta28 [August 29, 2012] + Unknown handling fixes and clean up. This adds more correct option + control of the unknown handling, corrects the pre-existing bug where + the per-chunk 'keep' setting is ignored and makes it possible to skip + IDAT chunks in the sequential reader (broken in earlier 1.6 versions). + There is a new test program, test-unknown.c, which is a work in progress + (not currently part of the test suite). Comments in the header files now + explain how the unknown handling works. + Allow fine grain control of unknown chunk APIs. This change allows + png_set_keep_unknown_chunks() to be turned off if not required and causes + both read and write to behave appropriately (on read this is only possible + if the user callback is used to handle unknown chunks). The change + also removes the support for storing unknown chunks in the info_struct + if the only unknown handling enabled is via the callback, allowing libpng + to be configured with callback reading and none of the unnecessary code. + Corrected fix for unknown handling in pngtest. This reinstates the + libpng handling of unknown chunks other than vpAg and sTER (including + unsafe-to-copy chunks which were dropped before) and eliminates the + repositioning of vpAg and sTER in pngtest.png by changing pngtest.png + (so the chunks are where libpng would put them). + Added "tunknown" test and corrected a logic error in png_handle_unknown() + when SAVE support is absent. Moved the shell test scripts for + contrib/libtests from the libpng top directory to contrib/libtests. + png_handle_unknown() must always read or skip the chunk, if + SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set + a user callback an unknown chunk will not be read, leading to a read + error, which was revealed by the "tunknown" test. + Cleaned up and corrected ICC profile handling. + contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error + messages could be truncated; made a correct buffer size calculation and + adjusted pngerror.c appropriately. png_icc_check_* checking improved; + changed the functions to receive the correct color type of the PNG on read + or write and check that it matches the color space of the profile (despite + what the comments said before, there is danger in assuming the app will + cope correctly with an RGB profile on a grayscale image and, since it + violates the PNG spec, allowing it is certain to produce inconsistent + app behavior and might even cause app crashes.) Check that profiles + contain the tags needed to process the PNG (tags all required by the ICC + spec). Removed unused PNG_STATIC from pngpriv.h. + +Version 1.6.0beta29 [September 4, 2012] + Fixed the simplified API example programs to add the *colormap parameter + to several of he API and improved the error message if the version field + is not set. + Added contrib/examples/* to the *.zip and *.7z distributions. + Updated simplified API synopses and description of the png_image structure + in the manual. + Made makepng and pngtest produce identical PNGs, add "--relaxed" option + to pngtest. The "--relaxed" option turns off the benign errors that are + enabled by default in pre-RC builds. makepng can now write ICC profiles + where the length has not been extended to a multiple of 4, and pngtest + now intercepts all libpng errors, allowing the previously-introduced + "--strict test" on no warnings to actually work. + Improved ICC profile handling including cHRM chunk generation and fixed + Cygwin+MSVC build errors. The ICC profile handling now includes more + checking. Several errors that caused rejection of the profile are now + handled with a warning in such a way that the invalid profiles will be + read by default in release (but not pre-RC) builds but will not be + written by default. The easy part of handling the cHRM chunk is written, + where the ICC profile contains the required data. The more difficult + part plus guessing a gAMA value requires code to pass selected RGB values + through the profile. + +Version 1.6.0beta30 [October 24, 2012] + Changed ICC profile matrix/vector types to not depend on array type rules. + By the ANSI-C standard the new types should be identical to the previous + versions, and all known versions of gcc tested with the previous versions + except for GCC-4.2.1 work with this version. The change makes the ANSI-C + rule that const applied to an array of elements applies instead to the + elements in the array moot by explicitly applying const to the base + elements of the png_icc_matrix and png_icc_vector types. The accidental + (harmless) 'const' previously applied to the parameters of two of the + functions have also been removed. + Added a work around for GCC 4.2 optimization bug. + Marked the broken (bad white point) original HP sRGB profiles correctly and + correct comments. + Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7 + Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio + builds, fixed build errors and corrected a minor exit code error in + pngvalid if the 'touch' file name is invalid. + Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio + Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in + pngrtran.c (Domani Hannes). + +Version 1.6.0beta31 [November 1, 2012] + Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30. + Made pngvalid so that it will build outside the libpng source tree. + Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail). + Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA. + Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the + interfaces that use it (specifically, png_do_background in 1.4 would + simply display composite for grayscale images but do composition + with the incorrect arithmetic for color ones). In 1.6 the semantic + of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that + depends on it; this obliges people who set it to consider whether they + really want it off if they happen to use any of the interfaces in + question (typically most users who disable it won't). + Fixed GUIDs in projects/vstudio. Some were duplicated or missing, + resulting in VS2010 having to update the files. + Removed non-working ICC profile support code that was mostly added to + libpng-1.6.0beta29 and beta30. There was too much code for too little + gain; implementing full ICC color correction may be desirable but is left + up to applications. + +Version 1.6.0beta32 [November 25, 2012] + Fixed an intermittent SEGV in pngstest due to an uninitialized array element. + Added the ability for contrib/libtests/makepng.c to make a PNG with just one + color. This is useful for debugging pngstest color inaccuracy reports. + Fixed error checking in the simplified write API (Olaf van der Spek) + Made png_user_version_check() ok to use with libpng version 1.10.x and later. + +Version 1.6.0beta33 [December 15, 2012] + Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX) + that causes the MALLOC_MAX limit not to work (John Bowler) + Change png_warning() to png_app_error() in pngwrite.c and comment the + fall-through condition. + Change png_warning() to png_app_warning() in png_write_tRNS(). + Rearranged the ARM-NEON optimizations: Isolated the machine specific code + to the hardware subdirectory and added comments to pngrutil.c so that + implementors of other optimizations know what to do. + Fixed cases of unquoted DESTDIR in Makefile.am + Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5. + +Version 1.6.0beta34 [December 19, 2012] + Cleaned up whitespace in the synopsis portion of the manpage "libpng.3" + Disassembled the version number in scripts/options.awk (necessary for + building on SunOs). + +Version 1.6.0beta35 [December 23, 2012] + Made default Zlib compression settings be configurable. This adds #defines to + pnglibconf.h to control the defaults. + Fixed Windows build issues, enabled ARM compilation. Various warnings issued + by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old + GCCs.) ARM support is enabled by default in zlib.props (unsupported by + Microsoft) and ARM compilation is made possible by deleting the check for + x86. The test programs cannot be run because they are not signed. + +Version 1.6.0beta36 [January 2, 2013] + Discontinued distributing libpng-1.x.x.tar.bz2. + Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar. + Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33) + Fixed 'make distcheck' on SUN OS - libpng.so was not being removed + +Version 1.6.0beta37 [January 10, 2013] + Fixed conceivable but difficult to repro overflow. Also added two test + programs to generate and test a PNG which should have the problem. + +Version 1.6.0beta39 [January 19, 2013] + Again corrected attempt at overflow detection in png_set_unknown_chunks() + (CVE-2013-7353). Added overflow detection in png_set_sPLT() and + png_set_text_2() (CVE-2013-7354). + +Version 1.6.0beta40 [January 20, 2013] + Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs + +Version 1.6.0rc01 [January 26, 2013] + No changes. + +Version 1.6.0rc02 [February 4, 2013] + Added png_get_palette_max() function. + +Version 1.6.0rc03 [February 5, 2013] + Fixed the png_get_palette_max API. + +Version 1.6.0rc04 [February 7, 2013] + Turn serial tests back on (recently turned off by autotools upgrade). + +Version 1.6.0rc05 [February 8, 2013] + Update manual about png_get_palette_max(). + +Version 1.6.0rc06 [February 9, 2013] + Fixed missing dependency in --prefix builds The intermediate + internal 'prefix.h' file can only be generated correctly after + pnglibconf.h, however the dependency was not in Makefile.am. The + symptoms are unpredictable depending on the order make chooses to + build pngprefix.h and pnglibconf.h, often the error goes unnoticed + because there is a system pnglibconf.h to use instead. + +Version 1.6.0rc07 [February 10, 2013] + Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED + block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly. + +Version 1.6.0rc08 [February 10, 2013] + Fix typo in png.h #ifdef + +Version 1.6.0 [February 14, 2013] + No changes. + +Version 1.6.1beta01 [February 16, 2013] + Made symbol prefixing work with the ARM neon optimizations. Also allow + pngpriv.h to be included for preprocessor definitions only, so it can + be used in non-C/C++ files. Back ported from libpng 1.7. + Made sRGB check numbers consistent. + Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. + Removed cc -E workround, corrected png_get_palette_max API Tested on + SUN OS cc 5.9, which demonstrates the tokenization problem previously + avoided by using /lib/cpp. Since all .dfn output is now protected in + double quotes unless it is to be macro substituted the fix should + work everywhere. + Enabled parallel tests - back ported from libpng-1.7. + scripts/pnglibconf.dfa formatting improvements back ported from libpng17. + Fixed a race condition in the creation of the build 'scripts' directory + while building with a parallel make. + Use approved/supported Android method to check for NEON, use Linux/POSIX + 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other + library calls (ported from libpng15). + +Version 1.6.1beta02 [February 19, 2013] + Use parentheses more consistently in "#if defined(MACRO)" tests. + Folded long lines. + Reenabled code to allow zero length PLTE chunks for MNG. + +Version 1.6.1beta03 [February 22, 2013] + Fixed ALIGNED_MEMORY support. + Added a new configure option: + --enable-arm-neon=always will stop the run-time checks. New checks + within arm/arm_init.c will cause the code not to be compiled unless + __ARM_NEON__ is set. This should make it fail safe (if someone asks + for it on then the build will fail if it can't be done.) + Updated the INSTALL document. + +Version 1.6.1beta04 [February 27, 2013] + Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES. + Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC. + Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble + with CRLF line endings. + +Version 1.6.1beta05 [March 1, 2013] + Avoid a possible memory leak in contrib/gregbook/readpng.c + +Version 1.6.1beta06 [March 4, 2013] + Better documentation of unknown handling API interactions. + Corrected Android builds and corrected libpng.vers with symbol + prefixing. It also makes those tests compile and link on Android. + Added an API png_set_option() to set optimization options externally, + providing an alternative and general solution for the non-portable + run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option. + The order of settings vs options in pnglibconf.h is reversed to allow + settings to depend on options and options can now set (or override) the + defaults for settings. + +Version 1.6.1beta07 [March 7, 2013] + Corrected simplified API default gamma for color-mapped output, added + a flag to change default. In 1.6.0 when the simplified API was used + to produce color-mapped output from an input image with no gamma + information the gamma assumed for the input could be different from + that assumed for non-color-mapped output. In particular 16-bit depth + input files were assumed to be sRGB encoded, whereas in the 'direct' + case they were assumed to have linear data. This was an error. The + fix makes the simplified API treat all input files the same way and + adds a new flag to the png_image::flags member to allow the + application/user to specify that 16-bit files contain sRGB data + rather than the default linear. + Fixed bugs in the pngpixel and makepng test programs. + +Version 1.6.1beta08 [March 7, 2013] + Fixed CMakelists.txt to allow building a single variant of the library + (Claudio Bley): + Introduced a PNG_LIB_TARGETS variable that lists all activated library + targets. It is an error if this variable ends up empty, ie. you have + to build at least one library variant. + Made the *_COPY targets only depend on library targets actually being build. + Use PNG_LIB_TARGETS to unify a code path. + Changed the CREATE_SYMLINK macro to expect the full path to a file as the + first argument. When symlinking the filename component of that path is + determined and used as the link target. + Use copy_if_different in the CREATE_SYMLINK macro. + +Version 1.6.1beta09 [March 13, 2013] + Eliminated two warnings from the Intel C compiler. The warnings are + technically valid, although a reasonable treatment of division would + show it to be incorrect. + +Version 1.6.1rc01 [March 21, 2013] + No changes. + +Version 1.6.1 [March 28, 2013] + No changes. + +Version 1.6.2beta01 [April 14, 2013] + Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling. + Fixed incorrect warning of excess deflate data. End condition - the + warning would be produced if the end of the deflate stream wasn't read + in the last row. The warning is harmless. + Corrected the test on user transform changes on read. It was in the + png_set of the transform function, but that doesn't matter unless the + transform function changes the rowbuf size, and that is only valid if + transform_info is called. + Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c + (Flavio Medeiros). + Corrected length written to uncompressed iTXt chunks (Samuli Suominen). + Bug was introduced in libpng-1.6.0. + +Version 1.6.2rc01 [April 18, 2013] + Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length + written by libpng-1.6.0 and 1.6.1. + Disallow storing sRGB information when the sRGB is not supported. + +Version 1.6.2rc02 [April 18, 2013] + Merge pngtest.c with libpng-1.7.0 + +Version 1.6.2rc03 [April 22, 2013] + Trivial spelling cleanup. + +Version 1.6.2rc04 and 1.6.2rc05 [omitted] + +Version 1.6.2rc06 [April 24, 2013] + Reverted to version 1.6.2rc03. Recent changes to arm/neon support + have been ported to libpng-1.7.0beta09 and will reappear in version + 1.6.3beta01. + +Version 1.6.2 [April 25, 2013] + No changes. + +Version 1.6.3beta01 [April 25, 2013] + Revised stack marking in arm/filter_neon.S and configure.ac. + Ensure that NEON filter stuff is completely disabled when switched 'off'. + Previously the ARM NEON specific files were still built if the option + was switched 'off' as opposed to being explicitly disabled. + +Version 1.6.3beta02 [April 26, 2013] + Test for 'arm*' not just 'arm' in the host_cpu configure variable. + Rebuilt the configure scripts. + +Version 1.6.3beta03 [April 30, 2013] + Expanded manual paragraph about writing private chunks, particularly + the need to call png_set_keep_unknown_chunks() when writing them. + Avoid dereferencing NULL pointer possibly returned from + png_create_write_struct() (Andrew Church). + +Version 1.6.3beta05 [May 9, 2013] + Calculate our own zlib windowBits when decoding rather than trusting the + CMF bytes in the PNG datastream. + Added an option to force maximum window size for inflating, which was + the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW + option for png_set_options(). + Added png-fix-itxt and png-fix-too-far-back to the built programs and + removed warnings from the source code and timepng that are revealed as + a result. + Detect wrong libpng versions linked to png-fix-too-far-back, which currently + only works with libpng versions that can be made to reliably fail when + the deflate data contains an out-of-window reference. This means only + 1.6 and later. + Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning + message which it is easier to work round than ignore. + Updated contrib/pngminus/pnm2png.c (Paul Stewart): + Check for EOF + Ignore "#" delimited comments in input file to pnm2png.c. + Fixed whitespace handling + Added a call to png_set_packing() + Initialize dimension values so if sscanf fails at least we have known + invalid values. + Attempt to detect configuration issues with png-fix-too-far-back, which + requires both the correct libpng and the correct zlib to function + correctly. + Check ZLIB_VERNUM for mismatches, enclose #error in quotes + Added information in the documentation about problems with and fixes for + the bad CRC and bad iTXt chunk situations. + +Version 1.6.3beta06 [May 12, 2013] + Allow contrib/pngminus/pnm2png.c to compile without WRITE_INVERT and + WRITE_PACK supported (writes error message that it can't read P1 or + P4 PBM files). + Improved png-fix-too-far-back usage message, added --suffix option. + Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the + right zlib header files. + Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile + +Version 1.6.3beta07 [June 8, 2013] + Removed a redundant test in png_set_IHDR(). + Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt) + Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt + Enclose the prototypes for the simplified write API in + #ifdef PNG_STDIO_SUPPORTED/#endif + Make ARM NEON support work at compile time (not just configure time). + This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when + using a compiler that compiles for multiple architectures at one time. + Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from + pnglibconf.h, allowing more of the decisions to be made internally + (pngpriv.h) during the compile. Without this, symbol prefixing is broken + under certain circumstances on ARM platforms. Now only the API parts of + the optimizations ('check' vs 'api') are exposed in the public header files + except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the + decision about whether or not to use the optimizations. + Protect symbol prefixing against CC/CPPFLAGS/CFLAGS usage. + Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test + on __ARM_NEON__ from configure time to compile time. This breaks symbol + prefixing because the definition of the special png_init_filter_functions + call was hidden at configure time if the relevant compiler arguments are + passed in CFLAGS as opposed to CC. This change attempts to avoid all + the confusion that would result by declaring the init function even when + it is not used, so that it will always get prefixed. + +Version 1.6.3beta08 [June 18, 2013] + Revised libpng.3 so that "doclifter" can process it. + +Version 1.6.3beta09 [June 27, 2013] + Revised example.c to illustrate use of PNG_DEFAULT_sRGB and PNG_GAMMA_MAC_18 + as parameters for png_set_gamma(). These have been available since + libpng-1.5.4. + Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised it + to check all compressed chunks known to libpng. + +Version 1.6.3beta10 [July 5, 2013] + Updated documentation to show default behavior of benign errors correctly. + Only compile ARM code when PNG_READ_SUPPORTED is defined. + Fixed undefined behavior in contrib/tools/pngfix.c and added new strip + option. pngfix relied on undefined behavior and even a simple change from + gcc to g++ caused it to fail. The new strip option 'unsafe' has been + implemented and is the default if --max is given. Option names have + been clarified, with --strip=transform now stripping the bKGD chunk, + which was stripped previously with --strip=unused. + Added all documented chunk types to pngpriv.h + Unified pngfix.c source with libpng17. + +Version 1.6.3rc01 [July 11, 2013] + No changes. + +Version 1.6.3 [July 18, 2013] + Revised manual about changes in iTXt chunk handling made in libpng-1.6.0. + Added "/* SAFE */" comments in pngrutil.c and pngrtran.c where warnings + may be erroneously issued by code-checking applications. + +Version 1.6.4beta01 [August 21, 2013] + Added information about png_set_options() to the manual. + Delay calling png_init_filter_functions() until a row with nonzero filter + is found. + +Version 1.6.4beta02 [August 30, 2013] + Fixed inconsistent conditional compilation of png_chunk_unknown_handling() + prototype, definition, and usage. Made it depend on + PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere. + +Version 1.6.4rc01 [September 5, 2013] + No changes. + +Version 1.6.4 [September 12, 2013] + No changes. + +Version 1.6.5 [September 14, 2013] + Removed two stray lines of code from arm/arm_init.c. + +Version 1.6.6 [September 16, 2013] + Removed two stray lines of code from arm/arm_init.c, again. + +Version 1.6.7beta01 [September 30, 2013] + Revised unknown chunk code to correct several bugs in the NO_SAVE_/NO_WRITE + combination + Allow HANDLE_AS_UNKNOWN to work when other options are configured off. Also + fixed the pngminim makefiles to work when $(MAKEFLAGS) contains stuff + which terminates the make options (as by default in recent versions of + Gentoo). + Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of + png_modifier are greater than that of png_store and as a consequence + compilation of pngvalid.c results in a warning about increased alignment + requirements because of the bare cast to (png_modifier*). The code is safe, + because the pointer is known to point to a stack allocated png_modifier, + but this change avoids the warning. + Fixed default behavior of ARM_NEON_API. If the ARM NEON API option was + compiled without the CHECK option it defaulted to on, not off. + Check user callback behavior in pngunknown.c. Previous versions compiled + if SAVE_UNKNOWN was not available but did nothing since the callback + was never implemented. + Merged pngunknown.c with 1.7 version and back ported 1.7 improvements/fixes + +Version 1.6.7beta02 [October 12, 2013] + Made changes for compatibility with automake 1.14: + 1) Added the 'compile' program to the list of programs that must be cleaned + in autogen.sh + 2) Added 'subdir-objects' which causes .c files in sub-directories to be + compiled such that the corresponding .o files are also in the + sub-directory. This is because automake 1.14 warns that the + current behavior of compiling to the top level directory may be removed + in the future. + 3) Updated dependencies on pnglibconf.h to match the new .o locations and + added all the files in contrib/libtests and contrib/tools that depend + on pnglibconf.h + 4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended + way of handling the dependencies of sources that are machine generated; + unfortunately it only works if the user does 'make all' or 'make check', + so the dependencies (3) are still required. + Cleaned up (char*) casts of zlib messages. The latest version of the Intel C + compiler complains about casting a string literal as (char*), so copied the + treatment of z_const from the library code into pngfix.c + Simplified error message code in pngunknown. The simplification has the + useful side effect of avoiding a bogus warning generated by the latest + version of the Intel C compiler (it objects to + condition ? string-literal : string-literal). + Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always + removing the 1.14 'compile' script but never checking for it. + +Version 1.6.7beta03 [October 19, 2013] + Added ARMv8 support (James Yu ). Added file + arm/filter_neon_intrinsics.c; enable with -mfpu=neon. + Revised pngvalid to generate size images with as many filters as it can + manage, limited by the number of rows. + Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h + and detect the broken GCC compilers. + +Version 1.6.7beta04 [October 26, 2013] + Allow clang derived from older GCC versions to use ARM intrinsics. This + causes all clang builds that use -mfpu=neon to use the intrinsics code, + not the assembler code. This has only been tested on iOS 7. It may be + necessary to exclude some earlier clang versions but this seems unlikely. + Changed NEON implementation selection mechanism. This allows assembler + or intrinsics to be turned on at compile time during the build by defining + PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro + is undefined by default and the build type is selected in pngpriv.h. + +Version 1.6.7rc01 [November 2, 2013] + No changes. + +Version 1.6.7rc02 [November 7, 2013] + Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char + checking macros take an unsigned char argument, not a signed char. + +Version 1.6.7 [November 14, 2013] + No changes. + +Version 1.6.8beta01 [November 24, 2013] + Moved prototype for png_handle_unknown() in pngpriv.h outside of + the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block. + Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile + Conditionally compile some unused functions reported by -Wall in + pngminim. + Fixed 'minimal' builds. Various obviously useful minimal configurations + don't build because of missing contrib/libtests test programs and + overly complex dependencies in scripts/pnglibconf.dfa. This change + adds contrib/conftest/*.dfa files that can be used in automatic build + scripts to ensure that these configurations continue to build. + Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder. + Fixed pngvalid 'fail' function declaration on the Intel C Compiler. + This reverts to the previous 'static' implementation and works round + the 'unused static function' warning by using PNG_UNUSED(). + +Version 1.6.8beta02 [November 30, 2013] + Removed or marked PNG_UNUSED some harmless "dead assignments" reported + by clang scan-build. + Changed tabs to 3 spaces in png_debug macros and changed '"%s"m' + to '"%s" m' to improve portability among compilers. + Changed png_free_default() to free() in pngtest.c + +Version 1.6.8rc01 [December 12, 2013] + Tidied up pngfix inits and fixed pngtest no-write builds. + +Version 1.6.8rc02 [December 14, 2013] + Handle zero-length PLTE chunk or NULL palette with png_error() + instead of png_chunk_report(), which by default issues a warning + rather than an error, leading to later reading from a NULL pointer + (png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954 + and VU#650142. Libpng-1.6.1 through 1.6.7 are vulnerable. + Libpng-1.6.0 and earlier do not have this bug. + +Version 1.6.8 [December 19, 2013] + No changes. + +Version 1.6.9beta01 [December 26, 2013] + Bookkeeping: Moved functions around (no changes). Moved transform + function definitions before the place where they are called so that + they can be made static. Move the intrapixel functions and the + grayscale palette builder out of the png?tran.c files. The latter + isn't a transform function and is no longer used internally, and the + former MNG specific functions are better placed in pngread/pngwrite.c + Made transform implementation functions static. This makes the internal + functions called by png_do_{read|write}_transformations static. On an + x86-64 DLL build (Gentoo Linux) this reduces the size of the text + segment of the DLL by 1208 bytes, about 0.6%. It also simplifies + maintenance by removing the declarations from pngpriv.h and allowing + easier changes to the internal interfaces. + Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69 + in the tar distributions. + +Version 1.6.9beta02 [January 1, 2014] + Added checks for libpng 1.5 to pngvalid.c. This supports the use of + this version of pngvalid in libpng 1.5 + Merged with pngvalid.c from libpng-1.7 changes to create a single + pngvalid.c + Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner). + Merged pngrio.c, pngtrans.c, pngwio.c, and pngerror.c with libpng-1.7.0 + Merged libpng-1.7.0 changes to make no-interlace configurations work + with test programs. + Revised pngvalid.c to support libpng 1.5, which does not support the + PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when appropriate in + pngvalid.c + Allow unversioned links created on install to be disabled in configure. + In configure builds 'make install' changes/adds links like png.h + and libpng.a to point to the newly installed, versioned, files (e.g. + libpng17/png.h and libpng17.a). Three new configure options and some + rearrangement of Makefile.am allow creation of these links to be disabled. + +Version 1.6.9beta03 [January 10, 2014] + Removed potentially misleading warning from png_check_IHDR(). + +Version 1.6.9beta04 [January 20, 2014] + Updated scripts/makefile.* to use CPPFLAGS (Cosmin). + Added clang attribute support (Cosmin). + +Version 1.6.9rc01 [January 28, 2014] + No changes. + +Version 1.6.9rc02 [January 30, 2014] + Quiet an uninitialized memory warning from VC2013 in png_get_png(). + +Version 1.6.9 [February 6, 2014] + +Version 1.6.10beta01 [February 9, 2014] + Backported changes from libpng-1.7.0beta30 and beta31: + Fixed a large number of instances where PNGCBAPI was omitted from + function definitions. + Added pngimage test program for png_read_png() and png_write_png() + with two new test scripts. + Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling + png_set_packing() in png_read_png(). + Fixed combination of ~alpha with shift. On read invert alpha, processing + occurred after shift processing, which causes the final values to be + outside the range that should be produced by the shift. Reversing the + order on read makes the two transforms work together correctly and mirrors + the order used on write. + Do not read invalid sBIT chunks. Previously libpng only checked sBIT + values on write, so a malicious PNG writer could therefore cause + the read code to return an invalid sBIT chunk, which might lead to + application errors or crashes. Such chunks are now skipped (with + chunk_benign_error). + Make png_read_png() and png_write_png() prototypes in png.h depend + upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED. + Support builds with unsupported PNG_TRANSFORM_* values. All of the + PNG_TRANSFORM_* values are always defined in png.h and, because they + are used for both read and write in some cases, it is not reliable + to #if out ones that are totally unsupported. This change adds error + detection in png_read_image() and png_write_image() to do a + png_app_error() if the app requests something that cannot be done + and it adds corresponding code to pngimage.c to handle such options + by not attempting to test them. + +Version 1.6.10beta02 [February 23, 2014] + Moved redefines of png_error(), png_warning(), png_chunk_error(), + and png_chunk_warning() from pngpriv.h to png.h to make them visible + to libpng-calling applications. + Moved OS dependent code from arm/arm_init.c, to allow the included + implementation of the ARM NEON discovery function to be set at + build-time and provide sample implementations from the current code in the + contrib/arm-neon subdirectory. The __linux__ code has also been changed to + compile and link on Android by using /proc/cpuinfo, and the old linux code + is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux + dependencies apart from opening /proc/cpuinfo and is C90 compliant. + Check for info_ptr == NULL early in png_read_end() so we don't need to + run all the png_handle_*() and depend on them to return if info_ptr == NULL. + This improves the performance of png_read_end(png_ptr, NULL) and makes + it more robust against future programming errors. + Check for __has_extension before using it in pngconf.h, to + support older Clang versions (Jeremy Sequoia). + Treat CRC error handling with png_set_crc_action(), instead of with + png_set_benign_errors(), which has been the case since libpng-1.6.0beta18. + Use a user warning handler in contrib/gregbook/readpng2.c instead of default, + so warnings will be put on stderr even if libpng has CONSOLE_IO disabled. + Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk + after recognizing the IDAT chunk, which avoids an infinite loop while + reading a datastream whose first IDAT chunk is of zero-length. + This fixes CERT VU#684412 and CVE-2014-0333. + Don't recognize known sRGB profiles as sRGB if they have been hacked, + but don't reject them and don't issue a copyright violation warning. + +Version 1.6.10beta03 [February 25, 2014] + Moved some documentation from png.h to libpng.3 and libpng-manual.txt + Minor editing of contrib/arm-neon/README and contrib/examples/*.c + +Version 1.6.10rc01 [February 27, 2014] + Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS + and PNG_USR_CONFIG -> PNG_USER_CONFIG). + +Version 1.6.10rc02 [February 28, 2014] + Removed unreachable return statement after png_chunk_error() + in pngrutil.c + +Version 1.6.10rc03 [March 4, 2014] + Un-deprecated png_data_freer(). + +Version 1.6.10 [March 6, 2014] + No changes. + +Version 1.6.11beta01 [March 17, 2014] + Use "if (value != 0)" instead of "if (value)" consistently. + Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio. + Moved configuration information from the manual to the INSTALL file. + +Version 1.6.11beta02 [April 6, 2014] + Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because + they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3 + when using its "__builtin_pow()" function. + Silence 'unused parameter' build warnings (Cosmin Truta). + $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp' + where applicable, and applied other minor makefile changes (Cosmin). + Don't warn about invalid dimensions exceeding user limits (Cosmin). + Allow an easy replacement of the default pre-built configuration + header with a custom header, via the make PNGLIBCONF_H_PREBUILT + macro (Cosmin). + +Version 1.6.11beta03 [April 6, 2014] + Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes + with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss). + Optionally use __builtin_bswap16() in png_do_swap(). + +Version 1.6.11beta04 [April 19, 2014] + Made progressive reading of interlaced images consistent with the + behavior of the sequential reader and consistent with the manual, by + moving some code out of the PNG_READ_INTERLACING_SUPPORTED blocks. The + row_callback now receives the proper pass number and unexpanded rows, when + png_combine_row() isn't built or used, and png_set_interlace_handling() + is not called. + Allow PNG_sRGB_PROFILE_CHECKING = (-1) to mean no sRGB profile checking. + +Version 1.6.11beta05 [April 26, 2014] + Do not reject ICC V2 profiles that lack padding (Kai-Uwe Behrmann). + Relocated closing bracket of the sRGB profile test loop to avoid getting + "Not recognizing known sRGB profile that has been edited" warning for + ICC V2 profiles that lack the MD5 signature in the profile header. + +Version 1.6.11beta06 [May 19, 2014] + Added PNG_SKIP_sRGB_CHECK_PROFILE choice for png_set_option(). + +Version 1.6.11rc01 [May 27, 2014] + No changes. + +Version 1.6.11rc02 [June 3, 2014] + Test ZLIB_VERNUM instead of PNG_ZLIB_VERNUM in contrib/tools/pngfix.c + +Version 1.6.11 [June 5, 2014] + No changes. + +Version 1.6.12rc01 [June 6, 2014] + Relocated new code from 1.6.11beta06 in png.c to a point after the + declarations (Max Stepin). + +Version 1.6.12rc02 [June 7, 2014] + Changed file permissions of contrib/tools/intgamma.sh, + test-driver, and compile from 0644 to 0755 (Cosmin). + +Version 1.6.12rc03 [June 8, 2014] + Ensure "__has_attribute()" macro exists before trying to use it with + old clang compilers (MacPorts Ticket #43939). + +Version 1.6.12 [June 12, 2014] + No changes. + +Version 1.6.13beta01 [July 4, 2014] + Quieted -Wsign-compare and -Wclobber compiler warnings in + contrib/pngminus/*.c + Added "(void) png_ptr;" where needed in contrib/gregbook to quiet + compiler complaints about unused pointers. + Split a long output string in contrib/gregbook/rpng2-x.c. + Added "PNG_SET_OPTION" requirement for sRGB chunk support to pnglibconf.dfa, + Needed for write-only support (John Bowler). + Changed "if defined(__ARM_NEON__)" to + "if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu). + Fixed clang no-warning builds: png_digit was defined but never used. + +Version 1.6.13beta02 [July 21, 2014] + Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32 + (bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11. + Also fixed makefile.bc32, makefile.bor, makefile.msc, makefile.intel, and + makefile.tc3 similarly. + +Version 1.6.13beta03 [August 3, 2014] + Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14 + due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT + definitions from pngconf.h. + Ensure that CMakeLists.txt makes the target "lib" directory before making + symbolic link into it (SourceForge bug report #226 by Rolf Timmermans). + +Version 1.6.13beta04 [August 8, 2014] + Added opinion that the ECCN (Export Control Classification Number) for + libpng is EAR99 to the README file. + Eliminated use of "$<" in makefile explicit rules, when copying + $PNGLIBCONF_H_PREBUILT. This does not work on some versions of make; + bug introduced in libpng version 1.6.11. + +Version 1.6.13rc01 [August 14, 2014] + Made "ccopts" agree with "CFLAGS" in scripts/makefile.hp* and makefile.*sunu + +Version 1.6.13 [August 21, 2014] + No changes. + +Version 1.6.14beta01 [September 14, 2014] + Guard usage of png_ptr->options with #ifdef PNG_SET_OPTION_SUPPORTED. + Do not build contrib/tools/pngfix.c when PNG_SETJMP_NOT_SUPPORTED, + to allow "make" to complete without setjmp support (bug report by + Claudio Fontana) + Add "#include " to contrib/tools/pngfix.c (John Bowler) + +Version 1.6.14beta02 [September 18, 2014] + Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c + because usleep() is deprecated. + Define usleep() in contrib/gregbook/rpng2-x.c if not already defined + in unistd.h and nanosleep() is not available; fixes error introduced + in libpng-1.6.13. + Disable floating point exception handling in pngvalid.c when + PNG_FLOATING_ARITHMETIC is not supported (bug report by "zootus + at users.sourceforge.net"). + +Version 1.6.14beta03 [September 19, 2014] + Define FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in pngvalid.c if not + already defined. Revert floating point exception handling in pngvalid.c + to version 1.6.14beta01 behavior. + +Version 1.6.14beta04 [September 27, 2014] + Fixed incorrect handling of the iTXt compression flag in pngrutil.c + (bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0. + +Version 1.6.14beta05 [October 1, 2014] + Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa + +Version 1.6.14beta06 [October 5, 2014] + Removed unused "text_len" parameter from private function png_write_zTXt(). + Conditionally compile some code in png_deflate_claim(), when + PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled. + Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL. + Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT" + to pnglibconf.dfa. + Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa, + to make it possible to configure a libpng that supports iCCP but not TEXT. + +Version 1.6.14beta07 [October 7, 2014] + Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa + Only mark text chunks as written after successfully writing them. + +Version 1.6.14rc01 [October 15, 2014] + Fixed some typos in comments. + +Version 1.6.14rc02 [October 17, 2014] + Changed png_convert_to_rfc_1123() to png_convert_to_rfc_1123_buffer() + in the manual, to reflect the change made in libpng-1.6.0. + Updated README file to explain that direct access to the png_struct + and info_struct members has not been permitted since libpng-1.5.0. + +Version 1.6.14 [October 23, 2014] + No changes. + +Version 1.6.15beta01 [October 29, 2014] + Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)" + Simplified png_free_data(). + Added missing "ptr = NULL" after some instances of png_free(). + +Version 1.6.15beta02 [November 1, 2014] + Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)" + +Version 1.6.15beta03 [November 3, 2014] + Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz). + +Version 1.6.15beta04 [November 4, 2014] + Removed new PNG_USE_ARM_NEON configuration flag and made a one-line + revision to configure.ac to support ARM on aarch64 instead (John Bowler). + +Version 1.6.15beta05 [November 5, 2014] + Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in + example.c, pngtest.c, and applications in the contrib directory. + Fixed an out-of-range read in png_user_version_check() (Bug report from + Qixue Xiao, CVE-2015-8540). + Simplified and future-proofed png_user_version_check(). + Fixed GCC unsigned int->float warnings. Various versions of GCC + seem to generate warnings when an unsigned value is implicitly + converted to double. This is probably a GCC bug but this change + avoids the issue by explicitly converting to (int) where safe. + Free all allocated memory in pngimage. The file buffer cache was left + allocated at the end of the program, harmless but it causes memory + leak reports from clang. + Fixed array size calculations to avoid warnings. At various points + in the code the number of elements in an array is calculated using + sizeof. This generates a compile time constant of type (size_t) which + is then typically assigned to an (unsigned int) or (int). Some versions + of GCC on 64-bit systems warn about the apparent narrowing, even though + the same compiler does apparently generate the correct, in-range, + numeric constant. This adds appropriate, safe, casts to make the + warnings go away. + +Version 1.6.15beta06 [November 6, 2014] + Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING + in the manual, example.c, pngtest.c, and applications in the contrib + directory. It was incorrect advice. + +Version 1.6.15beta07 [November 7, 2014] + Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is + needed by png_reciprocal2(). + Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and + png_do_swap(). + Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */" + +Version 1.6.15beta08 [November 8, 2014] + More housecleaning in *.h + +Version 1.6.15rc01 [November 13, 2014] + +Version 1.6.15rc02 [November 14, 2014] + The macros passed in the command line to Borland make were ignored if + similarly-named macros were already defined in makefiles. This behavior + is different from POSIX make and other make programs. Surround the + macro definitions with ifndef guards (Cosmin). + +Version 1.6.15rc03 [November 16, 2014] + Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32. + Removed the obsolete $ARCH variable from scripts/makefile.darwin. + +Version 1.6.15 [November 20, 2014] + No changes. + +Version 1.6.16beta01 [December 14, 2014] + Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that + don't do alignment correctly. + Revised Makefile.am and scripts/symbols.dfn to work with MinGW/MSYS + (Bob Friesenhahn). + +Version 1.6.16beta02 [December 15, 2014] + Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS; + renamed scripts/*.dfn to scripts/*.c (John Bowler). + +Version 1.6.16beta03 [December 21, 2014] + Quiet a "comparison always true" warning in pngstest.c (John Bowler). + +Version 1.6.16rc01 [December 21, 2014] + Restored a test on width that was removed from png.c at libpng-1.6.9 + (Bug report by Alex Eubanks, CVE-2015-0973). + +Version 1.6.16rc02 [December 21, 2014] + Undid the update to pngrutil.c in 1.6.16rc01. + +Version 1.6.16rc03 [December 21, 2014] + Fixed an overflow in png_combine_row() with very wide interlaced images + (Bug report and fix by John Bowler, CVE-2014-9495). + +Version 1.6.16 [December 22, 2014] + No changes. + +Version 1.6.17beta01 [January 29, 2015] + Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h + Corrected the width limit calculation in png_check_IHDR(). + Removed user limits from pngfix. Also pass NULL pointers to + png_read_row to skip the unnecessary row de-interlace stuff. + Added testing of png_set_packing() to pngvalid.c + Regenerated configure scripts in the *.tar distributions with libtool-2.4.4 + Implement previously untested cases of libpng transforms in pngvalid.c + Fixed byte order in png_do_read_filler() with 16-bit input. Previously + the high and low bytes of the filler, from png_set_filler() or from + png_set_add_alpha(), were read in the wrong order. + Made the check for out-of-range values in png_set_tRNS() detect + values that are exactly 2^bit_depth, and work on 16-bit platforms. + Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47. + Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and + pngset.c to avoid warnings about dead code. + Added "& 0xff" to many instances of expressions that are typecast + to (png_byte), to avoid Coverity warnings. + +Version 1.6.17beta02 [February 7, 2015] + Work around one more Coverity-scan dead-code warning. + Do not build png_product2() when it is unused. + +Version 1.6.17beta03 [February 17, 2015] + Display user limits in the output from pngtest. + Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column + and 1-million-row default limits in pnglibconf.dfa, that can be reset + by the user at build time or run time. This provides a more robust + defense against DOS and as-yet undiscovered overflows. + +Version 1.6.17beta04 [February 21, 2015] + Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. + Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins). + Rebuilt configure scripts with automake-1.15 and libtool-2.4.6 + +Version 1.6.17beta05 [February 25, 2015] + Restored compiling of png_reciprocal2 with PNG_NO_16BIT. + +Version 1.6.17beta06 [February 27, 2015] + Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block + of png.h. + Avoid runtime checks when converting integer to png_byte with + Visual Studio (Sergey Kosarevsky) + +Version 1.6.17rc01 [March 4, 2015] + No changes. + +Version 1.6.17rc02 [March 9, 2015] + Removed some comments that the configure script did not handle + properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt. + Free the unknown_chunks structure even when it contains no data. + +Version 1.6.17rc03 [March 12, 2015] + Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF + for consistency, and remove some useless tests (Alexey Petruchik). + +Version 1.6.17rc04 [March 16, 2015] + Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of + pnglibconf.* in "make clean" (Cosmin). + Fix bug in calculation of maxbits, in png_write_sBIT, introduced + in libpng-1.6.17beta01 (John Bowler). + +Version 1.6.17rc05 [March 21, 2015] + Define PNG_FILTER_* and PNG_FILTER_VALUE_* in png.h even when WRITE + is not supported (John Bowler). This fixes an error introduced in + libpng-1.6.17beta06. + Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes + the Coverity scan without them. + +Version 1.6.17rc06 [March 23, 2015] + Remove pnglibconf.dfn and pnglibconf.pre with "make clean". + Reformatted some "&0xff" instances to "& 0xff". + Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha + value was wrong. It's not clear if this affected the final stored + value; in the obvious code path the upper and lower 8-bits of the + alpha value were identical and the alpha was truncated to 8-bits + rather than dividing by 257 (John Bowler). + +Version 1.6.17 [March 26, 2015] + No changes. + +Version 1.6.18beta01 [April 1, 2015] + Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They + have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves + bug report by Andrew Church). + Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This + fixes some arithmetic errors that caused some tests to fail on + some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] + and Petr Gajdos [i586]). + +Version 1.6.18beta02 [April 26, 2015] + Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler + (Bug report by Viktor Szakats). + +Version 1.6.18beta03 [May 6, 2015] + Replaced "unexpected" with an integer (0xabadca11) in pngset.c + where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1. + Added contrib/examples/simpleover.c, to demonstrate how to handle + alpha compositing of multiple images, using the "simplified API" + and an example PNG generation tool, contrib/examples/genpng.c + (John Bowler). + +Version 1.6.18beta04 [May 20, 2015] + PNG_RELEASE_BUILD replaces tests where the code depended on the build base + type and can be defined on the command line, allowing testing in beta + builds (John Bowler). + Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds. + Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug + report from Christopher Ferris). + +Version 1.6.18beta05 [May 31, 2015] + Backport filter selection code from libpng-1.7.0beta51, to combine + sub_row, up_row, avg_row, and paeth_row into try_row and tst_row. + Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c + to avoid confusion with the libpng private macros. + Fixed old cut&paste bug in the weighted filter selection code in + pngwutil.c, introduced in libpng-0.95, March 1997. + +Version 1.6.18beta06 [June 1, 2015] + Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the + compiled library size. It never worked properly and as far as we can + tell, no one uses it. The png_set_filter_heuristics() and + png_set_filter_heuristics_fixed() APIs are retained but deprecated + and do nothing. + +Version 1.6.18beta07 [June 6, 2015] + Removed non-working progressive reader 'skip' function. This + function has apparently never been used. It was implemented + to support back-door modification of png_struct in libpng-1.4.x + but (because it does nothing and cannot do anything) was apparently + never tested (John Bowler). + Fixed cexcept.h in which GCC 5 now reports that one of the auto + variables in the Try macro needs to be volatile to prevent value + being lost over the setjmp (John Bowler). + Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler). + Fix g++ build breaks (John Bowler). + Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, + pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt + would only work with iTXt chunks with length 255 or less. + Added #ifdef's to contrib/examples programs so people don't try + to compile them without the minimum required support enabled + (suggested by Flavio Medeiros). + +Version 1.6.18beta08 [June 30, 2015] + Eliminated the final two Coverity defects (insecure temporary file + handling in contrib/libtests/pngstest.c; possible overflow of + unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure" + file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will + be used. + Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h + +Version 1.6.18beta09 [July 5, 2015] + Removed some useless typecasts from contrib/tools/png-fix-itxt.c + Fixed a new signed-unsigned comparison in pngrtran.c (Max Stepin). + Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To + preserve API compatibility, the new defines all default to "extern" + (requested by Jan Nijtmans). + +Version 1.6.18rc01 [July 9, 2015] + Belatedly added Mans Rullgard and James Yu to the list of Contributing + Authors. + +Version 1.6.18rc02 [July 12, 2015] + Restored unused FILTER_HEURISTIC macros removed at libpng-1.6.18beta08 + to png.h to avoid compatibility warnings. + +Version 1.6.18rc03 [July 15, 2015] + Minor changes to the man page + +Version 1.6.18 [July 23, 2015] + No changes. + +Version 1.6.19beta01 [July 30, 2015] + Updated obsolete information about the simplified API macros in the + manual pages (Bug report by Arc Riley). + Avoid potentially dereferencing NULL info_ptr in png_info_init_3(). + Rearranged png.h to put the major sections in the same order as + in libpng17. + Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and + PNG_WEIGHT_FACTOR macros. + Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler + (Bug report by Viktor Szakats). Several warnings remain and are + unavoidable, where we test for overflow. + Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c + Fixed uninitialized variable in contrib/gregbook/rpng2-x.c + +Version 1.6.19beta02 [August 19, 2015] + Moved config.h.in~ from the "libpng_autotools_files" list to the + "libpng_autotools_extra" list in autogen.sh because it was causing a + false positive for missing files (bug report by Robert C. Seacord). + Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c + to suppress clang warnings (Bug report by Viktor Szakats). + Fixed some bad links in the man page. + Changed "n bit" to "n-bit" in comments. + Added signed/unsigned 16-bit safety net. This removes the dubious + 0x8000 flag definitions on 16-bit systems. They aren't supported + yet the defs *probably* work, however it seems much safer to do this + and be advised if anyone, contrary to advice, is building libpng 1.6 + on a 16-bit system. It also adds back various switch default clauses + for GCC; GCC errors out if they are not present (with an appropriately + high level of warnings). + Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert + Seacord). + Fixed the recently reported 1's complement security issue by replacing + the value that is illegal in the PNG spec, in both signed and unsigned + values, with 0. Illegal unsigned values (anything greater than or equal + to 0x80000000) can still pass through, but since these are not illegal + in ANSI-C (unlike 0x80000000 in the signed case) the checking that + occurs later can catch them (John Bowler). + +Version 1.6.19beta03 [September 26, 2015] + Fixed png_save_int_32 when int is not 2's complement (John Bowler). + Updated libpng16 with all the recent test changes from libpng17, + including changes to pngvalid.c to ensure that the original, + distributed, version of contrib/visupng/cexcept.h can be used + (John Bowler). + pngvalid contains the correction to the use of SAVE/STORE_ + UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More + tests contain the --strict option to detect warnings and the + pngvalid-standard test has been corrected so that it does not + turn on progressive-read. There is a separate test which does + that. (John Bowler) + Also made some signed/unsigned fixes. + Make pngstest error limits version specific. Splitting the machine + generated error structs out to a file allows the values to be updated + without changing pngstest.c itself. Since libpng 1.6 and 1.7 have + slightly different error limits this simplifies maintenance. The + makepngs.sh script has also been updated to more accurately reflect + current problems in libpng 1.7 (John Bowler). + Incorporated new test PNG files into make check. tests/pngstest-* + are changed so that the new test files are divided into 8 groups by + gamma and alpha channel. These tests have considerably better code + and pixel-value coverage than contrib/pngsuite; however,coverage is + still incomplete (John Bowler). + Removed the '--strict' in 1.6 because of the double-gamma-correction + warning, updated pngstest-errors.h for the errors detected with the + new contrib/testspngs PNG test files (John Bowler). + +Version 1.6.19beta04 [October 15, 2015] + Worked around rgb-to-gray issues in libpng 1.6. The previous + attempts to ignore the errors in the code aren't quite enough to + deal with the 'channel selection' encoding added to libpng 1.7; abort. + pngvalid.c is changed to drop this encoding in prior versions. + Fixed 'pow' macros in pngvalid.c. It is legal for 'pow' to be a + macro, therefore the argument list cannot contain preprocessing + directives. Make sure pow is a function where this happens. This is + a minimal safe fix, the issue only arises in non-performance-critical + code (bug report by Curtis Leach, fix by John Bowler). + Added sPLT support to pngtest.c + +Version 1.6.19rc01 [October 23, 2015] + No changes. + +Version 1.6.19rc02 [October 31, 2015] + Prevent setting or writing over-length PLTE chunk (Cosmin Truta). + Silently truncate over-length PLTE chunk while reading. + Libpng incorrectly calculated the output rowbytes when the application + decreased either the number of channels or the bit depth (or both) in + a user transform. This was safe; libpng overallocated buffer space + (potentially by quite a lot; up to 4 times the amount required) but, + from 1.5.4 on, resulted in a png_error (John Bowler). + +Version 1.6.19rc03 [November 3, 2015] + Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed(). + Clarified COPYRIGHT information to state explicitly that versions + are derived from previous versions. + Removed much of the long list of previous versions from png.h and + libpng.3. + +Version 1.6.19rc04 [November 5, 2015] + Fixed new bug with CRC error after reading an over-length palette + (bug report by Cosmin Truta) (CVE-2015-8126). + +Version 1.6.19 [November 12, 2015] + Cleaned up coding style in png_handle_PLTE(). + +Version 1.6.20beta01 [November 20, 2015] + Avoid potential pointer overflow/underflow in png_handle_sPLT() and + png_handle_pCAL() (Bug report by John Regehr). + +Version 1.6.20beta02 [November 23, 2015] + Fixed incorrect implementation of png_set_PLTE() that uses png_ptr + not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126 + vulnerability. Fixes CVE-2015-8472. + +Version 1.6.20beta03 [November 24, 2015] + Backported tests from libpng-1.7.0beta69. + +Version 1.6.20rc01 [November 26, 2015] + Fixed an error in handling of bad zlib CMINFO field in pngfix, found by + American Fuzzy Lop, reported by Brian Carpenter. inflate() doesn't + immediately fault a bad CMINFO field; instead a 'too far back' error + happens later (at least some times). pngfix failed to limit CMINFO to + the allowed values but then assumed that window_bits was in range, + triggering an assert. The bug is mostly harmless; the PNG file cannot + be fixed. + +Version 1.6.20rc02 [November 29, 2015] + In libpng 1.6 zlib initialization was changed to use the window size + in the zlib stream, not a fixed value. This causes some invalid images, + where CINFO is too large, to display 'correctly' if the rest of the + data is valid. This provides a workaround for zlib versions where the + error arises (ones that support the API change to use the window size + in the stream). + +Version 1.6.20 [December 3, 2015] + No changes. + +Version 1.6.21beta01 [December 11, 2015] + Fixed syntax "$(command)" in tests/pngstest that some shells other than + bash could not parse (Bug report by Nelson Beebe). Use `command` instead. + +Version 1.6.21beta02 [December 14, 2015] + Moved png_check_keyword() from pngwutil.c to pngset.c + Removed LE/BE dependencies in pngvalid, to 'fix' the current problem + in the BigEndian tests by not testing it, making the BE code the same + as the LE version. + Fixes to pngvalid for various reduced build configurations (eliminate unused + statics) and a fix for the case in rgb_to_gray when the digitize option + reduces graylo to 0, producing a large error. + +Version 1.6.21beta03 [December 18, 2015] + Widened the 'limit' check on the internally calculated error limits in + the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error + checks) and changed the check to only operate in non-release builds + (base build type not RC or RELEASE.) + Fixed undefined behavior in pngvalid.c, undefined because + (png_byte) << shift is undefined if it changes the signed bit + (because png_byte is promoted to int). The libpng exported functions + png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by + David Drysdale as a result of reports from UBSAN in clang 3.8). + This changes pngvalid to use BE random numbers; this used to produce + errors but these should not be fixed as a result of the previous changes. + +Version 1.6.21rc01 [January 4, 2016] + In projects/vstudio, combined readme.txt and WARNING into README.txt + +Version 1.6.21rc02 [January 7, 2016] + Relocated assert() in contrib/tools/pngfix.c, bug found by American + Fuzzy Lop, reported by Brian Carpenter. + Marked 'limit' UNUSED in transform_range_check(). This only affects + release builds. + +Version 1.6.21 [January 15, 2016] + Worked around a false-positive Coverity issue in pngvalid.c. + +Version 1.6.22beta01 [January 23, 2016] + Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate + "tmpfile()" implementation in contrib/libtests/pngstest.c + Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io() + if there is no stdio.h support. + Added a png_image_write_to_memory() API and a number of assist macros + to allow an application that uses the simplified API write to bypass + stdio and write directly to memory. + Added some warnings (png.h) and some check code to detect *possible* + overflow in the ROW_STRIDE and simplified image SIZE macros. This + disallows image width/height/format that *might* overflow. This is + a quiet API change that limits in-memory image size (uncompressed) to + less than 4GByte and image row size (stride) to less than 2GByte. + Revised workaround for false-positive Coverity issue in pngvalid.c. + +Version 1.6.22beta02 [February 8, 2016] + Only use exit(77) in configure builds. + Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported + the palette size because it failed to take into account that the memory + palette has to be expanded to full RGB when it is written to PNG. + Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in + and test.cmake.in (Roger Leigh). + Relaxed limit checks on gamma values in pngrtran.c. As suggested in + the comments gamma values outside the range currently permitted + by png_set_alpha_mode are useful for HDR data encoding. These values + are already permitted by png_set_gamma so it is reasonable caution to + extend the png_set_alpha_mode range as HDR imaging systems are starting + to emerge. + +Version 1.6.22beta03 [March 9, 2016] + Added a common-law trademark notice and export control information + to the LICENSE file, png.h, and the man page. + Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that + were accidentally removed from libpng-1.6.17. + Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h + (Robert C. Seacord). + Removed dubious "#if INT_MAX" test from png.h that was added to + libpng-1.6.19beta02 (John Bowler). + Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok). + Updated LICENSE to say files in the contrib directory are not + necessarily under the libpng license, and that some makefiles have + other copyright owners. + Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.). + Made contrib/libtests/timepng more robust. The code no longer gives + up/fails on invalid PNG data, it just skips it (with error messages). + The code no longer fails on PNG files with data beyond IEND. Options + exist to use png_read_png (reading the whole image, not by row) and, in + that case, to apply any of the supported transforms. This makes for + more realistic testing; the decoded data actually gets used in a + meaningful fashion (John Bowler). + Fixed some misleading indentation (Krishnaraj Bhat). + +Version 1.6.22beta04 [April 5, 2016] + Force GCC compilation to C89 if needed (Dagobert Michelsen). + SSE filter speed improvements for bpp=3: + memcpy-free implementations of load3() / store3(). + call load3() only when needed at the end of a scanline. + +Version 1.6.22beta05 [April 27, 2016] + Added PNG_FAST_FILTERS macro (defined as + PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP). + Various fixes for contrib/libtests/timepng.c + Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch. + Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED + (Bug report by Y.Ohashik). + +Version 1.6.22beta06 [May 5, 2016] + Rebased contrib/intel_sse.patch. + Quieted two Coverity issues in contrib/libtests/timepng.c. + Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok): + Added support to use multiple directories in ZLIBINCDIR variable, + Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC, + Fixed pnglibconf.c compilation on OS X including the sysroot path. + +Version 1.6.22rc01 [May 14, 2016] + No changes. + +Version 1.6.22rc02 [May 16, 2016] + Removed contrib/timepng from default build; it does not build on platforms + that don't supply clock_gettime(). + +Version 1.6.22rc03 [May 17, 2016] + Restored contrib/timepng to default build but check for the presence + of clock_gettime() in configure.ac and Makefile.am. + +Version 1.6.22 [May 26, 2016] + No changes. + +Version 1.6.23beta01 [May 29, 2016] + Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying). + Fixed the progressive reader to handle empty first IDAT chunk properly + (patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and + only affected the libpng16 branch. + Added tests in pngvalid.c to check zero-length IDAT chunks in various + positions. Fixed the sequential reader to handle these more robustly + (John Bowler). + +Version 1.6.23rc01 [June 2, 2016] + Corrected progressive read input buffer in pngvalid.c. The previous version + the code invariably passed just one byte at a time to libpng. The intent + was to pass a random number of bytes in the range 0..511. + Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch. + Added missing ")" in pngerror.c (Matt Sarrett). + +Version 1.6.23rc02 [June 4, 2016] + Fixed undefined behavior in png_push_save_buffer(). Do not call + memcpy() with a null source, even if count is zero (Leon Scroggins III). + +Version 1.6.23 [June 9, 2016] + Fixed bad link to RFC2083 in png.5 (Nikola Forro). + +Version 1.6.24beta01 [June 11, 2016] + Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro + is not used within libpng, but is used in some of the examples. + +Version 1.6.24beta02 [June 23, 2016] + Correct filter heuristic overflow handling. This was broken when the + write filter code was moved out-of-line; if there is a single filter and + the heuristic sum overflows the calculation of the filtered line is not + completed. In versions prior to 1.6 the code was duplicated in-line + and the check not performed, so the filter operation completed; however, + in the multi-filter case where the sum is performed the 'none' filter would + be selected if all the sums overflowed, even if it wasn't in the filter + list. The fix to the first problem is simply to provide PNG_SIZE_MAX as + the current lmins sum value; this means the sum can never exceed it and + overflows silently. A reasonable compiler that does choose to inline + the code will simply eliminate the sum check. + The fix to the second problem is to use high precision arithmetic (this is + implemented in 1.7), however a simple safe fix here is to chose the lowest + numbered filter in the list from png_set_filter (this only works if the + first problem is also fixed) (John Bowler). + Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois). + Fixed the case where PNG_IMAGE_BUFFER_SIZE can overflow in the application + as a result of the application using an increased 'row_stride'; previously + png_image_finish_read only checked for overflow on the base calculation of + components. (I.e. it checked for overflow of a 32-bit number on the total + number of pixel components in the output format, not the possibly padded row + length and not the number of bytes, which for linear formats is twice the + number of components.) + MSVC does not like '-(unsigned)', so replaced it with 0U-(unsigned) + MSVC does not like (uInt) = -(unsigned) (i.e. as an initializer), unless + the conversion is explicitly invoked by a cast. + Put the SKIP definition in the correct place. It needs to come after the + png.h include (see all the other .c files in contrib/libtests) because it + depends on PNG_LIBPNG_VER. + Removed the three compile warning options from the individual project + files into the zlib.props globals. It increases the warning level from 4 + to All and adds a list of the warnings that need to be turned off. This is + semi-documentary; the intent is to tell libpng users which warnings have + been examined and judged non-fixable at present. The warning about + structure padding is fixable, but it would be a significant change (moving + structure members around). + +Version 1.6.24beta03 [July 4, 2016] + Optimized absolute value calculation in filter selection, similar to + code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to + use this. + Added pngcp to the build together with a pngcp.dfa configuration test. + Added high resolution timing to pngcp. + Added "Common linking failures" section to INSTALL. + Relocated misplaced #endif in png.c sRGB profile checking. + Fixed two Coverity issues in pngcp.c. + +Version 1.6.24beta04 [July 8, 2016] + Avoid filter-selection heuristic sum calculations in cases where only one + filter is a candidate for selection. This trades off code size (added + private png_setup_*_row_only() functions) for speed. + +Version 1.6.24beta05 [July 13, 2016] + Fixed some indentation to comply with our coding style. + Added contrib/tools/reindent. + +Version 1.6.24beta06 [July 18, 2016] + Fixed more indentation to comply with our coding style. + Eliminated unnecessary tests of boolean png_isaligned() vs 0. + +Version 1.6.24rc01 [July 25, 2016] + No changes. + +Version 1.6.24rc02 [August 1, 2016] + Conditionally compile SSE2 headers in contrib/intel/intel_sse.patch + Conditionally compile png_decompress_chunk(). + +Version 1.6.24rc03 [August 2, 2016] + Conditionally compile ARM_NEON headers in pngpriv.h + Updated contrib/intel/intel_sse.patch + +Version 1.6.24[August 4, 2016] + No changes. + +Version 1.6.25beta01 [August 12, 2016] + Reject oversized iCCP profile immediately. + Cleaned up PNG_DEBUG compile of pngtest.c. + Conditionally compile png_inflate(). + +Version 1.6.25beta02 [August 18, 2016] + Don't install pngcp; it conflicts with pngcp in the pngtools package. + Minor editing of INSTALL, (whitespace, added copyright line) + +Version 1.6.25rc01 [August 24, 2016] + No changes. + +Version 1.6.25rc02 [August 29, 2016] + Added MIPS support (Mandar Sahastrabuddhe ). + Only the UP filter is currently implemented. + +Version 1.6.25rc03 [August 29, 2016] + Rebased contrib/intel/intel_sse.patch after the MIPS implementation. + +Version 1.6.25rc04 [August 30, 2016] + Added MIPS support for SUB, AVG, and PAETH filters (Mandar Sahastrabuddhe). + +Version 1.6.25rc05 [August 30, 2016] + Rebased contrib/intel/intel_sse.patch after the MIPS implementation update.. + +Version 1.6.25 [September 1, 2016] + No changes. + +Version 1.6.26beta01 [September 26, 2016] + Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo, + bugfix by John Bowler). + Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL + has allocated memory that libpng needs to free. + Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c + Issue a png_benign_error instead of a png_error on ADLER32 mismatch + while decoding compressed data chunks. + Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngpriv.h, pngstruct.h, and + pngrutil.c. + If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE, + ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs. + Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error(). + Add tests/badcrc.png and tests/badadler.png to tests/pngtest. + Merged pngtest.c with libpng-1.7.0beta84/pngtest.c + +Version 1.6.26beta02 [October 1, 2016] + Updated the documentation about CRC and ADLER32 handling. + Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c, + pngwrite.c, pngunknown.c, and pngvalid.c. + Quieted 58 (out of 144) -Wconversion compiler warnings by changing + flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes + in png.c, pngread.c, and pngwutil.c. + +Version 1.6.26beta03 [October 2, 2016] + Removed contrib/libtests/*.orig and *.rej that slipped into the tarballs. + Quieted the 86 remaining -Wconversion compiler warnings by + revising the png_isaligned() macro and trivial changes in png.c, + pngerror.c, pngget.c, pngmem.c, pngset.c, pngrtran.c, pngrutil.c, + pngwtran.c, pngwrite.c, and pngwutil.c. + +Version 1.6.26beta04 [October 3, 2016] + Quieted (bogus?) clang warnings about "absolute value has no effect" + when PNG_USE_ABS is defined. + Fixed offsets in contrib/intel/intel_sse.patch + +Version 1.6.26beta05 [October 6, 2016] + Changed integer constant 4294967294 to unsigned 4294967294U in pngconf.h + to avoid a signed/unsigned compare in the preprocessor. + +Version 1.6.26beta06 [October 7, 2016] + Use zlib-1.2.8.1 inflateValidate() instead of inflateReset2() to + optionally avoid ADLER32 evaluation. + +Version 1.6.26rc01 [October 12, 2016] + No changes. + +Version 1.6.26 [October 20, 2016] + Cosmetic change, "ptr != 0" to "ptr != NULL" in png.c and pngrutil.c + Despammed email addresses (replaced "@" with " at "). + +Version 1.6.27beta01 [November 2, 2016] + Restrict the new ADLER32-skipping to IDAT chunks. It broke iCCP chunk + handling: an erroneous iCCP chunk would throw a png_error and reject the + entire PNG image instead of rejecting just the iCCP chunk with a warning, + if built with zlib-1.2.8.1. + +Version 1.6.27rc01 [December 27, 2016] + Control ADLER32 checking with new PNG_IGNORE_ADLER32 option. Fixes + an endless loop when handling erroneous ADLER32 checksums; bug + introduced in libpng-1.6.26. + Removed the use of a macro containing the pre-processor 'defined' + operator. It is unclear whether this is valid; a macro that + "generates" 'defined' is not permitted, but the use of the word + "generates" within the C90 standard seems to imply more than simple + substitution of an expression itself containing a well-formed defined + operation. + Added ARM support to CMakeLists.txt (Andreas Franek). + +Version 1.6.27 [December 29, 2016] + Fixed a potential null pointer dereference in png_set_text_2() (bug report + and patch by Patrick Keshishian, CVE-2016-10087). + +Version 1.6.28rc01 [January 3, 2017] + Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna). + Added option to Cmake build allowing a custom location of zlib to be + specified in a scenario where libpng is being built as a subproject + alongside zlib by another project (Sam Serrels). + Changed png_ptr->options from a png_byte to png_uint_32, to accommodate + up to 16 options. + +Version 1.6.28rc02 [January 4, 2017] + Added "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna). + Moved SSE2 optimization code into the main libpng source directory. + Configure libpng with "configure --enable-intel-sse" or compile + libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it. + +Version 1.6.28rc03 [January 4, 2017] + Backed out the SSE optimization and last CMakeLists.txt to allow time for QA. + +Version 1.6.28 [January 5, 2017] + No changes. + +Version 1.6.29beta01 [January 12, 2017] + Readded "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna). + Moved SSE2 optimization code into the main libpng source directory. + Configure libpng with "configure --enable-intel-sse" or compile + libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it. + Simplified conditional compilation in pngvalid.c, for AIX (Michael Felt). + +Version 1.6.29beta02 [February 22, 2017] + Avoid conditional directives that break statements in pngrutil.c (Romero + Malaquias) + The contrib/examples/pngtopng.c recovery code was in the wrong "if" + branches; the comments were correct. + Added code for PowerPC VSX optimisation (Vadim Barkov). + +Version 1.6.29beta03 [March 1, 2017] + Avoid potential overflow of shift operations in png_do_expand() (Aaron Boxer). + Change test ZLIB_VERNUM >= 0x1281 to ZLIB_VERNUM >= 0x1290 in pngrutil.c + because Solaris 11 distributes zlib-1.2.8.f that is older than 1.2.8.1, + as suggested in zlib FAQ, item 24. + Suppress clang warnings about implicit sign changes in png.c + +Version 1.6.29 [March 16, 2017] + No changes. + +Version 1.6.30beta01 [April 1, 2017] + Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in + makefile.linux and makefile.solaris-x86 (Cosmin). + Revised documentation of png_get_error_ptr() in the libpng manual. + Silence clang -Wcomma and const drop warnings (Viktor Szakats). + Update Sourceforge URLs in documentation (https instead of http). + +Version 1.6.30beta02 [April 22, 2017] + Document need to check for integer overflow when allocating a pixel + buffer for multiple rows in contrib/gregbook, contrib/pngminus, + example.c, and in the manual (suggested by Jaeseung Choi). This + is similar to the bug reported against pngquant in CVE-2016-5735. + Removed reference to the obsolete PNG_SAFE_LIMITS macro in the documentation. + +Version 1.6.30beta03 [May 22, 2017] + Check for integer overflow in contrib/visupng and contrib/tools/genpng. + Do not double evaluate CMAKE_SYSTEM_PROCESSOR in CMakeLists.txt. + Test CMAKE_HOST_WIN32 instead of WIN32 in CMakeLists.txt. + Fix some URL in documentation. + +Version 1.6.30beta04 [June 7, 2017] + Avoid writing an empty IDAT when the last IDAT exactly fills the + compression buffer (bug report by Brian Baird). This bug was + introduced in libpng-1.6.0. + +Version 1.6.30rc01 [June 14, 2017] + No changes. + +Version 1.6.30rc02 [June 25, 2017] + Update copyright year in pnglibconf.h, make ltmain.sh executable. + Add a reference to the libpng.download site in README. + +Version 1.6.30 [June 28, 2017] + No changes. + +Version 1.6.31beta01 [July 5, 2017] + Guard the definition of _POSIX_SOURCE in pngpriv.h (AIX already defines it; + bug report by Michael Felt). + Revised pngpriv.h to work around failure to compile arm/filter_neon.S + ("typedef" directive is unrecognized by the assembler). The problem + was introduced in libpng-1.6.30beta01. + Added "Requires: zlib" to libpng.pc.in (Pieter Neerincx). + Added special case for FreeBSD in arm/filter_neon.S (Maya Rashish). + +Version 1.6.31beta02 [July 8, 2017] + Added instructions for disabling hardware optimizations in INSTALL. + Added "--enable-hardware-optimizations" configuration flag to enable + or disable all hardware optimizations with one flag. + +Version 1.6.31beta03 [July 9, 2017] + Updated CMakeLists.txt to add INTEL_SSE and MIPS_MSA platforms. + Changed "int" to "png_size_t" in intel/filter_sse2.c to prevent + possible integer overflow (Bug report by John Bowler). + Quieted "declaration after statement" warnings in intel/filter_sse2.c. + Added scripts/makefile-linux-opt, which has hardware optimizations enabled. + +Version 1.6.31beta04 [July 11, 2017] + Removed one of the GCC-7.1.0 'strict-overflow' warnings that result when + integers appear on both sides of a compare. Worked around the others by + forcing the strict-overflow setting in the relevant functions to a level + where they are not reported (John Bowler). + Changed "FALL THROUGH" comments to "FALLTHROUGH" because GCC doesn't like + the space. + Worked around some C-style casts from (void*) because g++ 5.4.0 objects + to them. + Increased the buffer size for 'sprint' to pass the gcc 7.1.0 'sprint + overflow' check that is on by default with -Wall -Wextra. + +Version 1.6.31beta05 [July 13, 2017] + Added eXIf chunk support. + +Version 1.6.31beta06 [July 17, 2017] + Added a minimal eXIf chunk (with Orientation and FocalLengthIn35mmFilm + tags) to pngtest.png. + +Version 1.6.31beta07 [July 18, 2017] + Revised the eXIf chunk in pngtest.png to fix "Bad IFD1 Directory" warning. + +Version 1.6.31rc01 [July 19, 2017] + No changes. + +Version 1.6.31rc02 [July 25, 2017] + Fixed typo in example.c (png_free_image should be png_image_free) (Bug + report by John Smith) + +Version 1.6.31 [July 27, 2017] + No changes. + +Version 1.6.32beta01 [July 31, 2017] + Avoid possible NULL dereference in png_handle_eXIf when benign_errors + are allowed. Avoid leaking the input buffer "eXIf_buf". + Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif + to arguments for png_get_eXIf() and png_set_eXIf(). + Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf() in + pngwrite.c, and made various other fixes to png_write_eXIf(). + Changed name of png_get_eXIF and png_set_eXIf() to png_get_eXIf_1() and + png_set_eXIf_1(), respectively, to avoid breaking API compatibility + with libpng-1.6.31. + +Version 1.6.32beta02 [August 1, 2017] + Updated contrib/libtests/pngunknown.c with eXIf chunk. + +Version 1.6.32beta03 [August 2, 2017] + Initialized btoa[] in pngstest.c + Stop memory leak when returning from png_handle_eXIf() with an error + (Bug report from the OSS-fuzz project). + +Version 1.6.32beta04 [August 2, 2017] + Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf(). + Update libpng.3 and libpng-manual.txt about eXIf functions. + +Version 1.6.32beta05 [August 2, 2017] + Restored png_get_eXIf() and png_set_eXIf() to maintain API compatibility. + +Version 1.6.32beta06 [August 2, 2017] + Removed png_get_eXIf_1() and png_set_eXIf_1(). + +Version 1.6.32beta07 [August 3, 2017] + Check length of all chunks except IDAT against user limit to fix an + OSS-fuzz issue (Fixes CVE-2017-12652). + +Version 1.6.32beta08 [August 3, 2017] + Check length of IDAT against maximum possible IDAT size, accounting + for height, rowbytes, interlacing and zlib/deflate overhead. + Restored png_get_eXIf_1() and png_set_eXIf_1(), because strlen(eXIf_buf) + does not work (the eXIf chunk data can contain zeroes). + +Version 1.6.32beta09 [August 3, 2017] + Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation, + no longer using deprecated cmake LOCATION feature (Clifford Yapp). + Fixed five-byte error in the calculation of IDAT maximum possible size. + +Version 1.6.32beta10 [August 5, 2017] + Moved chunk-length check into a png_check_chunk_length() private + function (Suggested by Max Stepin). + Moved bad pngs from tests to contrib/libtests/crashers + Moved testing of bad pngs into a separate tests/pngtest-badpngs script + Added the --xfail (expected FAIL) option to pngtest.c. It writes XFAIL + in the output but PASS for the libpng test. + Require cmake-3.0.2 in CMakeLists.txt (Clifford Yapp). + Fix "const" declaration info_ptr argument to png_get_eXIf_1() and the + num_exif argument to png_get_eXIf_1() (Github Issue 171). + +Version 1.6.32beta11 [August 7, 2017] + Added "eXIf" to "chunks_to_ignore[]" in png_set_keep_unknown_chunks(). + Added huge_IDAT.png and empty_ancillary_chunks.png to testpngs/crashers. + Make pngtest --strict, --relax, --xfail options imply -m (multiple). + Removed unused chunk_name parameter from png_check_chunk_length(). + Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak. + Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz issue. + Initialize png_ptr->row_buf[0] to 255 in png_read_row() to fix OSS-fuzz UMR. + Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue. + Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(), to account + for the minimum 'deflate' stream, and relocate the test to a point + after the keyword has been read. + Check that the eXIf chunk has at least 2 bytes and begins with "II" or "MM". + +Version 1.6.32rc01 [August 18, 2017] + Added a set of "huge_xxxx_chunk.png" files to contrib/testpngs/crashers, + one for each known chunk type, with length = 2GB-1. + Check for 0 return from png_get_rowbytes() and added some (size_t) typecasts + in contrib/pngminus/*.c to stop some Coverity issues (162705, 162706, + and 162707). + Renamed chunks in contrib/testpngs/crashers to avoid having files whose + names differ only in case; this causes problems with some platforms + (github issue #172). + +Version 1.6.32rc02 [August 22, 2017] + Added contrib/oss-fuzz directory which contains files used by the oss-fuzz + project (https://github.com/google/oss-fuzz/tree/master/projects/libpng). + +Version 1.6.32 [August 24, 2017] + No changes. + +Version 1.6.33beta01 [August 28, 2017] + Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing + parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse). + Fixed off-by-one error in png_do_check_palette_indexes() (Bug report + by Mick P., Source Forge Issue #269). + +Version 1.6.33beta02 [September 3, 2017] + Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc + to fix shortlived oss-fuzz issue 3234. + Compute a larger limit on IDAT because some applications write a deflate + buffer for each row (Bug report by Andrew Church). + Use current date (DATE) instead of release-date (RDATE) in last + changed date of contrib/oss-fuzz files. + Enabled ARM support in CMakeLists.txt (Bernd Kuhls). + +Version 1.6.33beta03 [September 14, 2017] + Fixed incorrect typecast of some arguments to png_malloc() and + png_calloc() that were png_uint_32 instead of png_alloc_size_t + (Bug report by "irwir" in Github libpng issue #175). + Use pnglibconf.h.prebuilt when building for ANDROID with cmake (Github + issue 162, by rcdailey). + +Version 1.6.33rc01 [September 20, 2017] + Initialize memory allocated by png_inflate to zero, using memset, to + stop an oss-fuzz "use of uninitialized value" detection in png_set_text_2() + due to truncated iTXt or zTXt chunk. + Initialize memory allocated by png_read_buffer to zero, using memset, to + stop an oss-fuzz "use of uninitialized value" detection in + png_icc_check_tag_table() due to truncated iCCP chunk. + Removed a redundant test (suggested by "irwir" in Github issue #180). + +Version 1.6.33rc02 [September 23, 2017] + Added an interlaced version of each file in contrib/pngsuite. + Relocate new memset() call in pngrutil.c. + Removed more redundant tests (suggested by "irwir" in Github issue #180). + Add support for loading images with associated alpha in the Simplified + API (Samuel Williams). + +Version 1.6.33 [September 28, 2017] + Revert contrib/oss-fuzz/libpng_read_fuzzer.cc to libpng-1.6.32 state. + Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc + Add end_info structure and png_read_end() to the libpng fuzzer. + +Version 1.6.34 [September 29, 2017] + Removed contrib/pngsuite/i*.png; some of them caused test failures. + +Version 1.6.35beta01 [March 6, 2018] + Restored 21 of the contrib/pngsuite/i*.png, which do not cause test + failures. Placed the remainder in contrib/pngsuite/interlaced/i*.png. + Added calls to png_set_*() transforms commonly used by browsers to + the fuzzer. + Removed some unnecessary brackets in pngrtran.c + Fixed miscellaneous typos (Patch by github user "luzpaz"). + Change "ASM C" to "C ASM" in CMakeLists.txt + Fixed incorrect handling of bKGD chunk in sub-8-bit files (Cosmin) + Added hardware optimization directories to zip and 7z distributions. + Fixed incorrect bitmask for options. + Fixed many spelling typos. + +Version 1.6.35beta02 [March 28, 2018] + Make png_get_iCCP consistent with man page (allow compression-type argument + to be NULL, bug report by Lenard Szolnoki). + +Version 1.6.35 [July 15, 2018] + Replaced the remaining uses of png_size_t with size_t (Cosmin) + Fixed the calculation of row_factor in png_check_chunk_length + (reported by Thuan Pham in SourceForge issue #278) + Added missing parentheses to a macro definition + (suggested by "irwir" in GitHub issue #216) + +Version 1.6.36 [December 1, 2018] + Optimized png_do_expand_palette for ARM processors. + Improved performance by around 10-22% on a recent ARM Chromebook. + (Contributed by Richard Townsend, ARM Holdings) + Fixed manipulation of machine-specific optimization options. + (Contributed by Vicki Pfau) + Used memcpy instead of manual pointer arithmetic on Intel SSE2. + (Contributed by Samuel Williams) + Fixed build errors with MSVC on ARM64. + (Contributed by Zhijie Liang) + Fixed detection of libm in CMakeLists. + (Contributed by Cameron Cawley) + Fixed incorrect creation of pkg-config file in CMakeLists. + (Contributed by Kyle Bentley) + Fixed the CMake build on Windows MSYS by avoiding symlinks. + Fixed a build warning on OpenBSD. + (Contributed by Theo Buehler) + Fixed various typos in comments. + (Contributed by "luz.paz") + Raised the minimum required CMake version from 3.0.2 to 3.1. + Removed yet more of the vestigial support for pre-ANSI C compilers. + Removed ancient makefiles for ancient systems that have been broken + across all previous libpng-1.6.x versions. + Removed the Y2K compliance statement and the export control + information. + Applied various code style and documentation fixes. + +Version 1.6.37 [April 14, 2019] + Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free. + Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette. + Fixed a memory leak in pngtest.c. + Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in + contrib/pngminus; refactor. + Changed the license of contrib/pngminus to MIT; refresh makefile and docs. + (Contributed by Willem van Schaik) + Fixed a typo in the libpng license v2. + (Contributed by Miguel Ojeda) + Added makefiles for AddressSanitizer-enabled builds. + Cleaned up various makefiles. + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net. +Subscription is required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) -or to glennrp at users.sourceforge.net - -Glenn R-P -*/ +to subscribe. diff --git a/libs/libpng-src/CMakeLists.txt b/libs/libpng-src/CMakeLists.txt index a3ab4649b..6451fcf1b 100644 --- a/libs/libpng-src/CMakeLists.txt +++ b/libs/libpng-src/CMakeLists.txt @@ -1,106 +1,476 @@ -cmake_minimum_required(VERSION 2.4.3) -set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) +# CMakeLists.txt -if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING - "Choose the type of build, options are: - None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) - Debug - Release - RelWithDebInfo - MinSizeRel.") -endif() - -project(libpng C) -enable_testing() - -# Copyright (C) 2007-2010 Glenn Randers-Pehrson +# Copyright (C) 2018 Cosmin Truta +# Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson +# Written by Christian Ehrlicher, 2007 +# Revised by Roger Lowman, 2009-2010 +# Revised by Clifford Yapp, 2011-2012,2017 +# Revised by Roger Leigh, 2016 +# Revised by Andreas Franek, 2016 +# Revised by Sam Serrels, 2017 +# Revised by Vadim Barkov, 2017 +# Revised by Vicky Pfau, 2018 +# Revised by Cameron Cawley, 2018 +# Revised by Cosmin Truta, 2018 +# Revised by Kyle Bentley, 2018 # This code is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h +cmake_minimum_required(VERSION 3.1) +cmake_policy(VERSION 3.1) + +project(libpng C ASM) +enable_testing() + set(PNGLIB_MAJOR 1) -set(PNGLIB_MINOR 2) -set(PNGLIB_RELEASE 46) +set(PNGLIB_MINOR 6) +set(PNGLIB_RELEASE 37) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) -# needed packages -find_package(ZLIB REQUIRED) -include_directories(${ZLIB_INCLUDE_DIR}) +include(GNUInstallDirs) -if(NOT WIN32) - find_library(M_LIBRARY - NAMES m - PATHS /usr/lib /usr/local/lib - ) - if(NOT M_LIBRARY) - message(STATUS - "math library 'libm' not found - floating point support disabled") - endif() +# needed packages + +# Allow users to specify location of Zlib. +# Useful if zlib is being built alongside this as a sub-project. +option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF) + +if(NOT PNG_BUILD_ZLIB) + find_package(ZLIB REQUIRED) + include_directories(${ZLIB_INCLUDE_DIR}) +endif() + +if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU) + find_library(M_LIBRARY m) else() - # not needed on windows + # libm is not needed and/or not available set(M_LIBRARY "") endif() # COMMAND LINE OPTIONS -if(DEFINED PNG_SHARED) - option(PNG_SHARED "Build shared lib" ${PNG_SHARED}) -else() - option(PNG_SHARED "Build shared lib" ON) -endif() -if(DEFINED PNG_STATIC) - option(PNG_STATIC "Build static lib" ${PNG_STATIC}) -else() - option(PNG_STATIC "Build static lib" ON) +option(PNG_SHARED "Build shared lib" ON) +option(PNG_STATIC "Build static lib" ON) +option(PNG_TESTS "Build libpng tests" ON) + +# Many more configuration options could be added here +option(PNG_FRAMEWORK "Build OS X framework" OFF) +option(PNG_DEBUG "Build with debug output" OFF) +option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON) + +set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names") +set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings") + +if(PNG_HARDWARE_OPTIMIZATIONS) + +# set definitions and sources for arm +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + set(PNG_ARM_NEON_POSSIBLE_VALUES check on off) + set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations: + check: (default) use internal checking code; + off: disable the optimizations; + on: turn on unconditionally.") + set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS + ${PNG_ARM_NEON_POSSIBLE_VALUES}) + list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_ARM_NEON} STREQUAL "off") + set(libpng_arm_sources + arm/arm_init.c + arm/filter_neon.S + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c) + + if(${PNG_ARM_NEON} STREQUAL "on") + add_definitions(-DPNG_ARM_NEON_OPT=2) + elseif(${PNG_ARM_NEON} STREQUAL "check") + add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED) + endif() + else() + add_definitions(-DPNG_ARM_NEON_OPT=0) + endif() endif() -if(MINGW) - option(PNG_TESTS "Build pngtest" NO) -else() - option(PNG_TESTS "Build pngtest" YES) +# set definitions and sources for powerpc +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") + set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off) + set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations: + off: disable the optimizations.") + set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS + ${PNG_POWERPC_VSX_POSSIBLE_VALUES}) + list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off") + set(libpng_powerpc_sources + powerpc/powerpc_init.c + powerpc/filter_vsx_intrinsics.c) + if(${PNG_POWERPC_VSX} STREQUAL "on") + add_definitions(-DPNG_POWERPC_VSX_OPT=2) + endif() + else() + add_definitions(-DPNG_POWERPC_VSX_OPT=0) + endif() endif() -option(PNG_NO_CONSOLE_IO "FIXME" YES) -option(PNG_NO_STDIO "FIXME" YES) -option(PNG_DEBUG "Build with debug output" NO) -option(PNGARG "FIXME" YES) -#TODO: -# PNG_CONSOLE_IO_SUPPORTED - -# maybe needs improving, but currently I don't know when we can enable what :) -set(png_asm_tmp "OFF") -if(NOT WIN32) - find_program(uname_executable NAMES uname PATHS /bin /usr/bin /usr/local/bin) - if(uname_executable) - exec_program(${uname_executable} - ARGS --machine OUTPUT_VARIABLE uname_output) - if("uname_output" MATCHES "^.*i[1-9]86.*$") - set(png_asm_tmp "ON") - else("uname_output" MATCHES "^.*i[1-9]86.*$") - set(png_asm_tmp "OFF") - endif("uname_output" MATCHES "^.*i[1-9]86.*$") - endif(uname_executable) -else() - # this env var is normally only set on win64 - set(TEXT "ProgramFiles(x86)") - if("$ENV{${TEXT}}" STREQUAL "") - set(png_asm_tmp "ON") - endif("$ENV{${TEXT}}" STREQUAL "") +# set definitions and sources for intel +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") + set(PNG_INTEL_SSE_POSSIBLE_VALUES on off) + set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations: + off: disable the optimizations") + set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS + ${PNG_INTEL_SSE_POSSIBLE_VALUES}) + list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off") + set(libpng_intel_sources + intel/intel_init.c + intel/filter_sse2_intrinsics.c) + if(${PNG_INTEL_SSE} STREQUAL "on") + add_definitions(-DPNG_INTEL_SSE_OPT=1) + endif() + else() + add_definitions(-DPNG_INTEL_SSE_OPT=0) + endif() endif() +# set definitions and sources for MIPS +if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") + set(PNG_MIPS_MSA_POSSIBLE_VALUES on off) + set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations: + off: disable the optimizations") + set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS + ${PNG_MIPS_MSA_POSSIBLE_VALUES}) + list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index) + if(index EQUAL -1) + message(FATAL_ERROR + "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]") + elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off") + set(libpng_mips_sources + mips/mips_init.c + mips/filter_msa_intrinsics.c) + if(${PNG_MIPS_MSA} STREQUAL "on") + add_definitions(-DPNG_MIPS_MSA_OPT=2) + endif() + else() + add_definitions(-DPNG_MIPS_MSA_OPT=0) + endif() +endif() + +else(PNG_HARDWARE_OPTIMIZATIONS) + +# set definitions and sources for arm +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64") + add_definitions(-DPNG_ARM_NEON_OPT=0) +endif() + +# set definitions and sources for powerpc +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*") + add_definitions(-DPNG_POWERPC_VSX_OPT=0) +endif() + +# set definitions and sources for intel +if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*") + add_definitions(-DPNG_INTEL_SSE_OPT=0) +endif() + +# set definitions and sources for MIPS +if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR + CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*") + add_definitions(-DPNG_MIPS_MSA_OPT=0) +endif() + +endif(PNG_HARDWARE_OPTIMIZATIONS) + # SET LIBNAME set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) # to distinguish between debug and release lib set(CMAKE_DEBUG_POSTFIX "d") +include(CheckCSourceCompiles) +option(ld-version-script "Enable linker version script" ON) +if(ld-version-script AND NOT APPLE) + # Check if LD supports linker scripts. + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { + global: sym; + local: *; +}; + +VERS_2 { + global: sym2; + main; +} VERS_1; +") + set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'") + check_c_source_compiles("void sym(void) {} +void sym2(void) {} +int main(void) {return 0;} +" HAVE_LD_VERSION_SCRIPT) + if(NOT HAVE_LD_VERSION_SCRIPT) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + check_c_source_compiles("void sym(void) {} +void sym2(void) {} +int main(void) {return 0;} +" HAVE_SOLARIS_LD_VERSION_SCRIPT) + endif() + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +endif() + +# Find symbol prefix. Likely obsolete and unnecessary with recent +# toolchains (it's not done in many other projects). +function(symbol_prefix) + set(SYMBOL_PREFIX) + + execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-" + INPUT_FILE /dev/null + OUTPUT_VARIABLE OUT + RESULT_VARIABLE STATUS) + + if(CPP_FAIL) + message(WARNING "Failed to run the C preprocessor") + endif() + + string(REPLACE "\n" ";" OUT "${OUT}") + foreach(line ${OUT}) + string(REGEX MATCH "^PREFIX=" found_match "${line}") + if(found_match) + string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}") + string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}") + if(found_match) + string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}") + endif() + set(SYMBOL_PREFIX "${prefix}") + endif() + endforeach() + + message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}") + set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE) +endfunction() + +if(UNIX) + symbol_prefix() +endif() + +find_program(AWK NAMES gawk awk) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +if(NOT AWK OR ANDROID) + # No awk available to generate sources; use pre-built pnglibconf.h + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt + ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h) + add_custom_target(genfiles) # Dummy +else() + include(CMakeParseArguments) + # Generate .chk from .out with awk + # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_chk) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GC_INPUT) + message(FATAL_ERROR "generate_chk: Missing INPUT argument") + endif() + if(NOT _GC_OUTPUT) + message(FATAL_ERROR "generate_chk: Missing OUTPUT argument") + endif() + + add_custom_command(OUTPUT "${_GC_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GC_INPUT}" + "-DOUTPUT=${_GC_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake" + DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Generate .out from .c with awk + # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_out) + set(options) + set(oneValueArgs INPUT OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GO_INPUT) + message(FATAL_ERROR "generate_out: Missing INPUT argument") + endif() + if(NOT _GO_OUTPUT) + message(FATAL_ERROR "generate_out: Missing OUTPUT argument") + endif() + + add_custom_command(OUTPUT "${_GO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DINPUT=${_GO_INPUT}" + "-DOUTPUT=${_GO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake" + DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Generate specific source file with awk + # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]]) + function(generate_source) + set(options) + set(oneValueArgs OUTPUT) + set(multiValueArgs DEPENDS) + cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(NOT _GSO_OUTPUT) + message(FATAL_ERROR "generate_source: Missing OUTPUT argument") + endif() + + add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=${_GSO_OUTPUT}" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" + DEPENDS ${_GSO_DEPENDS} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endfunction() + + # Copy file + function(generate_copy source destination) + add_custom_command(OUTPUT "${destination}" + COMMAND "${CMAKE_COMMAND}" -E remove "${destination}" + COMMAND "${CMAKE_COMMAND}" -E copy "${source}" + "${destination}" + DEPENDS "${source}") + endfunction() + + # Generate scripts/pnglibconf.h + generate_source(OUTPUT "scripts/pnglibconf.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") + + # Generate pnglibconf.c + generate_source(OUTPUT "pnglibconf.c" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h") + + if(PNG_PREFIX) + set(PNGLIBCONF_H_EXTRA_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst") + set(PNGPREFIX_H_EXTRA_DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out") + endif() + + generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + + # Generate pnglibconf.h + generate_source(OUTPUT "pnglibconf.h" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + ${PNGLIBCONF_H_EXTRA_DEPENDS}) + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out") + + # Generate pngprefix.h + generate_source(OUTPUT "pngprefix.h" + DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS}) + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt") + + generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h" + "${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h") + + generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk" + "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def") + + add_custom_target(symbol-check DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk") + + generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") + generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") + + add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers") + add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym") + + add_custom_target("genprebuilt" + COMMAND "${CMAKE_COMMAND}" + "-DOUTPUT=scripts/pnglibconf.h.prebuilt" + -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + + # A single target handles generation of all generated files. If + # they are depended upon separately by multiple targets, this + # confuses parallel make (it would require a separate top-level + # target for each file to track the dependencies properly). + add_custom_target(genfiles DEPENDS + "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym" + "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out" + "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" + "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out") +endif(NOT AWK OR ANDROID) # OUR SOURCES -set(libpng_sources +set(libpng_public_hdrs png.h pngconf.h + "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h" +) +set(libpng_private_hdrs + pngpriv.h + pngdebug.h + pnginfo.h + pngstruct.h +) +if(AWK AND NOT ANDROID) + list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h") +endif() +set(libpng_sources + ${libpng_public_hdrs} + ${libpng_private_hdrs} png.c pngerror.c pngget.c @@ -116,169 +486,446 @@ set(libpng_sources pngwrite.c pngwtran.c pngwutil.c + ${libpng_arm_sources} + ${libpng_intel_sources} + ${libpng_mips_sources} + ${libpng_powerpc_sources} ) set(pngtest_sources pngtest.c ) -# SOME NEEDED DEFINITIONS - -add_definitions(-DPNG_CONFIGURE_LIBPNG) - -if(_AIX) - add_definitions(-D_ALL_SOURCE) -endif(_AIX) +set(pngvalid_sources + contrib/libtests/pngvalid.c +) +set(pngstest_sources + contrib/libtests/pngstest.c +) +set(pngunknown_sources + contrib/libtests/pngunknown.c +) +set(pngimage_sources + contrib/libtests/pngimage.c +) +set(pngfix_sources + contrib/tools/pngfix.c +) +set(png_fix_itxt_sources + contrib/tools/png-fix-itxt.c +) if(MSVC) - add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE) -endif(MSVC) - -if(PNG_SHARED OR NOT MSVC) - #if building msvc static this has NOT to be defined - add_definitions(-DZLIB_DLL) -endif() - -add_definitions(-DLIBPNG_NO_MMX) -add_definitions(-DPNG_NO_MMX_CODE) - - -if(PNG_CONSOLE_IO_SUPPORTED) - add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) -endif() - -if(PNG_NO_CONSOLE_IO) - add_definitions(-DPNG_NO_CONSOLE_IO) -endif() - -if(PNG_NO_STDIO) - add_definitions(-DPNG_NO_STDIO) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) endif() if(PNG_DEBUG) add_definitions(-DPNG_DEBUG) endif() -if(NOT M_LIBRARY AND NOT WIN32) - add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) -endif() - # NOW BUILD OUR TARGET include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) +unset(PNG_LIB_TARGETS) + if(PNG_SHARED) - add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) + add_library(png SHARED ${libpng_sources}) + set(PNG_LIB_TARGETS png) + set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME}) + add_dependencies(png genfiles) if(MSVC) # msvc does not append 'lib' - do it here to have consistent name - set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib") + set_target_properties(png PROPERTIES PREFIX "lib") + set_target_properties(png PROPERTIES IMPORT_PREFIX "lib") + endif() + target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY}) + + if(UNIX AND AWK) + if(HAVE_LD_VERSION_SCRIPT) + set_target_properties(png PROPERTIES LINK_FLAGS + "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT) + set_target_properties(png PROPERTIES LINK_FLAGS + "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'") + endif() endif() - target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) endif() if(PNG_STATIC) -# does not work without changing name - set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) - add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources}) + # does not work without changing name + set(PNG_LIB_NAME_STATIC png_static) + add_library(png_static STATIC ${libpng_sources}) + add_dependencies(png_static genfiles) + # MSVC doesn't use a different file extension for shared vs. static + # libs. We are able to change OUTPUT_NAME to remove the _static + # for all other platforms. + if(NOT MSVC) + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}" + CLEAN_DIRECT_OUTPUT 1) + else() + set_target_properties(png_static PROPERTIES + OUTPUT_NAME "${PNG_LIB_NAME}_static" + CLEAN_DIRECT_OUTPUT 1) + endif() + list(APPEND PNG_LIB_TARGETS png_static) if(MSVC) # msvc does not append 'lib' - do it here to have consistent name - set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib") + set_target_properties(png_static PROPERTIES PREFIX "lib") endif() + target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY}) endif() +if(PNG_FRAMEWORK) + set(PNG_LIB_NAME_FRAMEWORK png_framework) + add_library(png_framework SHARED ${libpng_sources}) + add_dependencies(png_framework genfiles) + list(APPEND PNG_LIB_TARGETS png_framework) + set_target_properties(png_framework PROPERTIES + FRAMEWORK TRUE + FRAMEWORK_VERSION ${PNGLIB_VERSION} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION} + MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + PUBLIC_HEADER "${libpng_public_hdrs}" + OUTPUT_NAME png) + target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY}) +endif() + +if(NOT PNG_LIB_TARGETS) + message(SEND_ERROR + "No library variant selected to build. " + "Please enable at least one of the following options: " + "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK") +endif() if(PNG_SHARED AND WIN32) - set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) + set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) endif() +function(png_add_test) + set(options) + set(oneValueArgs NAME COMMAND) + set(multiValueArgs OPTIONS FILES) + cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT _PAT_NAME) + message(FATAL_ERROR "png_add_test: Missing NAME argument") + endif() + if(NOT _PAT_COMMAND) + message(FATAL_ERROR "png_add_test: Missing COMMAND argument") + endif() + + set(TEST_OPTIONS "${_PAT_OPTIONS}") + set(TEST_FILES "${_PAT_FILES}") + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY) + add_test(NAME "${_PAT_NAME}" + COMMAND "${CMAKE_COMMAND}" + "-DLIBPNG=$" + "-DTEST_COMMAND=$" + -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake") +endfunction() + if(PNG_TESTS AND PNG_SHARED) - # does not work with msvc due to png_lib_ver issue + # Find test PNG files by globbing, but sort lists to ensure + # consistency between different filesystems. + file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png") + list(SORT PNGSUITE_PNGS) + file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png") + list(SORT TEST_PNGS) + + set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png") + add_executable(pngtest ${pngtest_sources}) - target_link_libraries(pngtest ${PNG_LIB_NAME}) - add_test(pngtest pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png) + target_link_libraries(pngtest png) + + png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}") + + add_executable(pngvalid ${pngvalid_sources}) + target_link_libraries(pngvalid png) + + png_add_test(NAME pngvalid-gamma-16-to-8 + COMMAND pngvalid OPTIONS --gamma-16-to-8) + png_add_test(NAME pngvalid-gamma-alpha-mode + COMMAND pngvalid OPTIONS --gamma-alpha-mode) + png_add_test(NAME pngvalid-gamma-background + COMMAND pngvalid OPTIONS --gamma-background) + png_add_test(NAME pngvalid-gamma-expand16-alpha-mode + COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16) + png_add_test(NAME pngvalid-gamma-expand16-background + COMMAND pngvalid OPTIONS --gamma-background --expand16) + png_add_test(NAME pngvalid-gamma-expand16-transform + COMMAND pngvalid OPTIONS --gamma-transform --expand16) + png_add_test(NAME pngvalid-gamma-sbit + COMMAND pngvalid OPTIONS --gamma-sbit) + png_add_test(NAME pngvalid-gamma-threshold + COMMAND pngvalid OPTIONS --gamma-threshold) + png_add_test(NAME pngvalid-gamma-transform + COMMAND pngvalid OPTIONS --gamma-transform) + png_add_test(NAME pngvalid-progressive-interlace-standard + COMMAND pngvalid OPTIONS --standard --progressive-read --interlace) + png_add_test(NAME pngvalid-progressive-size + COMMAND pngvalid OPTIONS --size --progressive-read) + png_add_test(NAME pngvalid-progressive-standard + COMMAND pngvalid OPTIONS --standard --progressive-read) + png_add_test(NAME pngvalid-standard + COMMAND pngvalid OPTIONS --standard) + png_add_test(NAME pngvalid-transform + COMMAND pngvalid OPTIONS --transform) + + add_executable(pngstest ${pngstest_sources}) + target_link_libraries(pngstest png) + + foreach(gamma_type 1.8 linear none sRGB) + foreach(alpha_type none alpha) + set(PNGSTEST_FILES) + foreach(test_png ${TEST_PNGS}) + string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}") + string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}") + string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}") + string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}") + + set(TEST_PNG_VALID TRUE) + + if(TEST_PNG_ALPHA) + if(NOT "${alpha_type}" STREQUAL "alpha") + set(TEST_PNG_VALID FALSE) + endif() + else() + if("${alpha_type}" STREQUAL "alpha") + set(TEST_PNG_VALID FALSE) + endif() + endif() + + if(TEST_PNG_LINEAR) + if(NOT "${gamma_type}" STREQUAL "linear") + set(TEST_PNG_VALID FALSE) + endif() + elseif(TEST_PNG_SRGB) + if(NOT "${gamma_type}" STREQUAL "sRGB") + set(TEST_PNG_VALID FALSE) + endif() + elseif(TEST_PNG_G18) + if(NOT "${gamma_type}" STREQUAL "1.8") + set(TEST_PNG_VALID FALSE) + endif() + else() + if(NOT "${gamma_type}" STREQUAL "none") + set(TEST_PNG_VALID FALSE) + endif() + endif() + + if(TEST_PNG_VALID) + list(APPEND PNGSTEST_FILES "${test_png}") + endif() + endforeach() + # Should already be sorted, but sort anyway to be certain. + list(SORT PNGSTEST_FILES) + png_add_test(NAME pngstest-${gamma_type}-${alpha_type} + COMMAND pngstest + OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log + FILES ${PNGSTEST_FILES}) + endforeach() + endforeach() + + add_executable(pngunknown ${pngunknown_sources}) + target_link_libraries(pngunknown png) + + png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}") + png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}") + + add_executable(pngimage ${pngimage_sources}) + target_link_libraries(pngimage png) + + png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS}) + png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS}) endif() +if(PNG_SHARED) + add_executable(pngfix ${pngfix_sources}) + target_link_libraries(pngfix png) + set(PNG_BIN_TARGETS pngfix) + + add_executable(png-fix-itxt ${png_fix_itxt_sources}) + target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY}) + list(APPEND PNG_BIN_TARGETS png-fix-itxt) +endif() + +# Set a variable with CMake code which: +# Creates a symlink from src to dest (if possible) or alternatively +# copies if different. +include(CMakeParseArguments) + +function(create_symlink DEST_FILE) + + cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN}) + + if(NOT S_TARGET AND NOT S_FILE) + message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument") + endif() + + if(S_TARGET AND S_FILE) + message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.") + endif() + + if(S_FILE) + # If we don't need to symlink something that's coming from a build target, + # we can go ahead and symlink/copy at configure time. + if(CMAKE_HOST_WIN32 AND NOT CYGWIN) + execute_process( + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + else() + execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif() + endif() + + if(S_TARGET) + # We need to use generator expressions, which can be a bit tricky, so for + # simplicity make the symlink a POST_BUILD step and use the TARGET + # signature of add_custom_command. + if(CMAKE_HOST_WIN32 AND NOT CYGWIN) + add_custom_command(TARGET ${S_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE}) + else() + add_custom_command(TARGET ${S_TARGET} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E create_symlink $ $/${DEST_FILE}) + endif() + endif() + +endfunction() + +# Create source generation scripts. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY) + +# libpng is a library so default to 'lib' +if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(CMAKE_INSTALL_LIBDIR lib) +endif() # CREATE PKGCONFIG FILES -# we use the same files like ./configure, so we have to set its vars -set(prefix ${CMAKE_INSTALL_PREFIX}) -set(exec_prefix ${CMAKE_INSTALL_PREFIX}) -set(libdir ${CMAKE_INSTALL_PREFIX}/lib) -set(includedir ${CMAKE_INSTALL_PREFIX}/include) +# We use the same files like ./configure, so we have to set its vars. +# Only do this on Windows for Cygwin - the files don't make much sense outside +# of a UNIX look-alike. +if(NOT WIN32 OR CYGWIN OR MINGW) + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix ${CMAKE_INSTALL_PREFIX}) + set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) + set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + set(LIBS "-lz -lm") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY) + create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng-config.in - ${CMAKE_CURRENT_BINARY_DIR}/libpng-config) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/libpng-config.in - ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in + ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY) + create_symlink(libpng-config FILE ${PNGLIB_NAME}-config) +endif() # SET UP LINKS if(PNG_SHARED) - set_target_properties(${PNG_LIB_NAME} PROPERTIES -# VERSION 0.${PNGLIB_RELEASE}.1.2.46 - VERSION 0.${PNGLIB_RELEASE}.0 - SOVERSION 0 + set_target_properties(png PROPERTIES +# VERSION 16.${PNGLIB_RELEASE}.1.6.37 + VERSION 16.${PNGLIB_RELEASE}.0 + SOVERSION 16 CLEAN_DIRECT_OUTPUT 1) endif() -if(PNG_STATIC) - if(NOT WIN32) - # that's uncool on win32 - it overwrites our static import lib... - set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES - OUTPUT_NAME ${PNG_LIB_NAME} - CLEAN_DIRECT_OUTPUT 1) - endif() -endif() # INSTALL -if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) + install(TARGETS ${PNG_LIB_TARGETS} + EXPORT libpng + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) + if(PNG_SHARED) - install(TARGETS ${PNG_LIB_NAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + # Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin + if(CYGWIN OR MINGW) + create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png) + install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() + + if(NOT WIN32) + create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png) + install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() endif() + if(PNG_STATIC) - install(TARGETS ${PNG_LIB_NAME_STATIC} - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + if(NOT WIN32 OR CYGWIN OR MINGW) + create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static) + install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + endif() endif() endif() -if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) - install(FILES png.h pngconf.h DESTINATION include) - install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME}) +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) + install(FILES ${libpng_public_hdrs} DESTINATION include) + install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME}) endif() -if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL ) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) - install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config - DESTINATION bin) +if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL) + if(NOT WIN32 OR CYGWIN OR MINGW) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) + endif() endif() -if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + +if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL) + install(TARGETS ${PNG_BIN_TARGETS} + RUNTIME DESTINATION bin) +endif() + +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL) # Install man pages - install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) - install(FILES png.5 DESTINATION man/man5) + if(NOT PNG_MAN_DIR) + set(PNG_MAN_DIR "share/man") + endif() + install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3) + install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5) # Install pkg-config files - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc - DESTINATION lib/pkgconfig) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng-config - DESTINATION bin) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc - DESTINATION lib/pkgconfig) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config - DESTINATION bin) + if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config + DESTINATION bin) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config + DESTINATION bin) + endif() endif() -# what's with libpng.txt and all the extra files? +# Create an export file that CMake users can include() to import our targets. +if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL) + install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake) +endif() +# what's with libpng-manual.txt and all the extra files? # UNINSTALL # do we need this? - # DIST # do we need this? # to create msvc import lib for mingw compiled shared lib # pexports libpng.dll > libpng.def # lib /def:libpng.def /machine:x86 - diff --git a/libs/libpng-src/INSTALL b/libs/libpng-src/INSTALL index 99e5ccc2a..4c1702251 100644 --- a/libs/libpng-src/INSTALL +++ b/libs/libpng-src/INSTALL @@ -1,5 +1,28 @@ -Installing libpng version 1.2.46 - July 9, 2011 + Installing libpng + +Contents + + I. Simple installation + II. Rebuilding the configure scripts + III. Using scripts/makefile* + IV. Using cmake + V. Directory structure + VI. Building with project files + VII. Building with makefiles + VIII. Configuring libpng for 16-bit platforms + IX. Configuring for DOS + X. Configuring for Medium Model + XI. Prepending a prefix to exported symbols + XII. Configuring for compiler xxx: + XIII. Removing unwanted object code + XIV. Enabling or disabling hardware optimizations + XV. Changes to the build and configuration of libpng in libpng-1.5.x + XVI. Setjmp/longjmp issues + XVII. Common linking failures + XVIII. Other sources of information about libpng + +I. Simple installation On Unix/Linux and similar systems, you can simply type @@ -7,20 +30,44 @@ On Unix/Linux and similar systems, you can simply type make check make install -and ignore the rest of this document. +and ignore the rest of this document. "/path" is the path to the directory +where you want to install the libpng "lib", "include", and "bin" +subdirectories. -If configure does not work on your system and you have a reasonably -up-to-date set of tools, running ./autogen.sh before running ./configure -may fix the problem. You can also run the individual commands in -autogen.sh with the --force option, if supported by your version of -the tools. If you run 'libtoolize --force', though, this will replace -the distributed, patched, version of ltmain.sh with an unpatched version -and your shared library builds may fail to produce libraries with the -correct version numbers. +If you downloaded a GIT clone, you will need to run ./autogen.sh before +running ./configure, to create "configure" and "Makefile.in" which are +not included in the GIT repository. + +Note that "configure" is only included in the "*.tar" distributions and not +in the "*.zip" or "*.7z" distributions. If you downloaded one of those +distributions, see "Building with project files" or "Building with makefiles", +below. + +II. Rebuilding the configure scripts + +If configure does not work on your system, or if you have a need to +change configure.ac or Makefile.am, and you have a reasonably +up-to-date set of tools, running ./autogen.sh in a git clone before +running ./configure may fix the problem. To be really sure that you +aren't using any of the included pre-built scripts, especially if you +are building from a tar distribution instead of a git distribution, +do this: + + ./configure --enable-maintainer-mode + make maintainer-clean + ./autogen.sh --maintainer --clean + ./autogen.sh --maintainer + ./configure [--prefix=/path] [other options] + make + make install + make check + +III. Using scripts/makefile* Instead, you can use one of the custom-built makefiles in the "scripts" directory + cp scripts/pnglibconf.h.prebuilt pnglibconf.h cp scripts/makefile.system makefile make test make install @@ -32,82 +79,107 @@ Or you can use one of the "projects" in the "projects" directory. Before installing libpng, you must first install zlib, if it is not already on your system. zlib can usually be found -wherever you got libpng. zlib can be placed in another directory, -at the same level as libpng. - -If you want to use "cmake" (see www.cmake.org), type - - cmake . -DCMAKE_INSTALL_PREFIX=/path - make - make install +wherever you got libpng; otherwise go to https://zlib.net/. You can +place zlib in the same directory as libpng or in another directory. If your system already has a preinstalled zlib you will still need to have access to the zlib.h and zconf.h include files that correspond to the version of zlib that's installed. +If you wish to test with a particular zlib that is not first in the +standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS, +and LD_LIBRARY_PATH in your environment before running "make test" +or "make distcheck": + + ZLIBLIB=/path/to/lib export ZLIBLIB + ZLIBINC=/path/to/include export ZLIBINC + CPPFLAGS="-I$ZLIBINC" export CPPFLAGS + LDFLAGS="-L$ZLIBLIB" export LDFLAGS + LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH + +If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC +in your environment and type + + make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test + +IV. Using cmake + +If you want to use "cmake" (see www.cmake.org), type + + cmake . -DCMAKE_INSTALL_PREFIX=/path + make + make install + +As when using the simple configure method described above, "/path" points to +the installation directory where you want to put the libpng "lib", "include", +and "bin" subdirectories. + +V. Directory structure + You can rename the directories that you downloaded (they -might be called "libpng-1.2.46" or "libpng12" and "zlib-1.2.3" -or "zlib123") so that you have directories called "zlib" and "libpng". +might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8" +or "zlib128") so that you have directories called "zlib" and "libpng". Your directory structure should look like this: - .. (the parent directory) - libpng (this directory) + .. (the parent directory) + libpng (this directory) INSTALL (this file) README - *.h - *.c + *.h, *.c => libpng source files CMakeLists.txt => "cmake" script configuration files: configure.ac, configure, Makefile.am, Makefile.in, - autogen.sh, config.guess, ltmain.sh, missing, - aclocal.m4, config.h.in, config.sub, + autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in, + libpng-config.in, aclocal.m4, config.h.in, config.sub, depcomp, install-sh, mkinstalldirs, test-pngtest.sh contrib - gregbook - pngminim - pngminus - pngsuite - visupng + arm-neon, conftest, examples, gregbook, libtests, pngminim, + pngminus, pngsuite, tools, visupng projects - cbuilder5 (Borland) - visualc6 (msvc) - visualc71 - xcode + cbuilder5, owatcom, visualc71, vstudio, xcode scripts makefile.* *.def (module definition files) + etc. pngtest.png etc. zlib - README - *.h - *.c - contrib - etc. + README, *.h, *.c contrib, etc. If the line endings in the files look funny, you may wish to get the other distribution of libpng. It is available in both tar.gz (UNIX style line endings) and zip (DOS style line endings) formats. +VI. Building with project files + If you are building libpng with MSVC, you can enter the -libpng projects\visualc6 or visualc71 directory and follow the instructions +libpng projects\visualc71 or vstudio directory and follow the instructions in README.txt. Otherwise enter the zlib directory and follow the instructions in zlib/README, then come back here and run "configure" or choose the appropriate makefile.sys in the scripts directory. +VII. Building with makefiles + Copy the file (or files) that you need from the scripts directory into this directory, for example - MSDOS example: copy scripts\makefile.msc makefile - UNIX example: cp scripts/makefile.std makefile +MSDOS example: + + copy scripts\makefile.msc makefile + copy scripts\pnglibconf.h.prebuilt pnglibconf.h + +UNIX example: + + cp scripts/makefile.std makefile + cp scripts/pnglibconf.h.prebuilt pnglibconf.h Read the makefile to see if you need to change any source or target directories to match your preferences. -Then read pngconf.h to see if you want to make any configuration +Then read pnglibconf.dfa to see if you want to make any configuration changes. Then just run "make" which will create the libpng library in @@ -125,39 +197,269 @@ do that, run "make install" in the zlib directory first if necessary). Some also allow you to run "make test-installed" after you have run "make install". -If you encounter a compiler error message complaining about the -lines +VIII. Configuring libpng for 16-bit platforms - __png.h__ already includes setjmp.h; - __dont__ include it again.; +You will want to look into zconf.h to tell zlib (and thus libpng) that +it cannot allocate more than 64K at a time. Even if you can, the memory +won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. -this means you have compiled another module that includes setjmp.h, -which is hazardous because the two modules might not include exactly -the same setjmp.h. If you are sure that you know what you are doing -and that they are exactly the same, then you can comment out or -delete the two lines. Better yet, use the cexcept interface -instead, as demonstrated in contrib/visupng of the libpng distribution. +IX. Configuring for DOS -Further information can be found in the README and libpng.txt +For DOS users who only have access to the lower 640K, you will +have to limit zlib's memory usage via a png_set_compression_mem_level() +call. See zlib.h or zconf.h in the zlib library for more information. + +X. Configuring for Medium Model + +Libpng's support for medium model has been tested on most of the popular +compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets +defined, and FAR gets defined to far in pngconf.h, and you should be +all set. Everything in the library (except for zlib's structure) is +expecting far data. You must use the typedefs with the p or pp on +the end for pointers (or at least look at them and be careful). Make +note that the rows of data are defined as png_bytepp, which is +an "unsigned char far * far *". + +XI. Prepending a prefix to exported symbols + +Starting with libpng-1.6.0, you can configure libpng (when using the +"configure" script) to prefix all exported symbols by means of the +configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any +string beginning with a letter and containing only uppercase +and lowercase letters, digits, and the underscore (i.e., a C language +identifier). This creates a set of macros in pnglibconf.h, so this is +transparent to applications; their function calls get transformed by +the macros to use the modified names. + +XII. Configuring for compiler xxx: + +All includes for libpng are in pngconf.h. If you need to add, change +or delete an include, this is the place to do it. +The includes that are not needed outside libpng are placed in pngpriv.h, +which is only used by the routines inside libpng itself. +The files in libpng proper only include pngpriv.h and png.h, which +in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h. +As of libpng-1.5.0, pngpriv.h also includes three other private header +files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material +that previously appeared in the public headers. + +XIII. Removing unwanted object code + +There are a bunch of #define's in pngconf.h that control what parts of +libpng are compiled. All the defines end in _SUPPORTED. If you are +never going to use a capability, you can change the #define to #undef +before recompiling libpng and save yourself code and data space, or +you can turn off individual capabilities with defines that begin with +"PNG_NO_". + +In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead. + +You can also turn all of the transforms and ancillary chunk capabilities +off en masse with compiler directives that define +PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, +or all four, along with directives to turn on any of the capabilities that +you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the +extra transformations but still leave the library fully capable of reading +and writing PNG files with all known public chunks. Use of the +PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library +that is incapable of reading or writing ancillary chunks. If you are +not using the progressive reading capability, you can turn that off +with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING +capability, which you'll still have). + +All the reading and writing specific code are in separate files, so the +linker should only grab the files it needs. However, if you want to +make sure, or if you are building a stand alone library, all the +reading files start with "pngr" and all the writing files start with "pngw". +The files that don't match either (like png.c, pngtrans.c, etc.) +are used for both reading and writing, and always need to be included. +The progressive reader is in pngpread.c + +If you are creating or distributing a dynamically linked library (a .so +or DLL file), you should not remove or disable any parts of the library, +as this will cause applications linked with different versions of the +library to fail if they call functions not available in your library. +The size of the library itself should not be an issue, because only +those sections that are actually used will be loaded into memory. + +XIV. Enabling or disabling hardware optimizations + +Certain hardware capabilities, such as the Intel SSE instructions, +are normally detected at run time. Enable them with configure options +such as one of + + --enable-arm-neon=yes + --enable-mips-msa=yes + --enable-intel-sse=yes + --enable-powerpc-vsx=yes + +or enable them all at once with + + --enable-hardware-optimizations=yes + +or, if you are not using "configure", you can use one +or more of + + CPPFLAGS += "-DPNG_ARM_NEON" + CPPFLAGS += "-DPNG_MIPS_MSA" + CPPFLAGS += "-DPNG_INTEL_SSE" + CPPFLAGS += "-DPNG_POWERPC_VSX" + +See for example scripts/makefile.linux-opt + +If you wish to avoid using them, +you can disable them via the configure option + + --disable-hardware-optimizations + +to disable them all, or + + --enable-intel-sse=no + +to disable a particular one, +or via compiler-command options such as + + CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0, + -DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0" + +If you are using cmake, hardware optimizations are "on" +by default. To disable them, use + + cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \ + -DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no + +or disable them all at once with + + cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no + +XV. Changes to the build and configuration of libpng in libpng-1.5.x + +Details of internal changes to the library code can be found in the CHANGES +file and in the GIT repository logs. These will be of no concern to the vast +majority of library users or builders; however, the few who configure libpng +to a non-default feature set may need to change how this is done. + +There should be no need for library builders to alter build scripts if +these use the distributed build support - configure or the makefiles - +however, users of the makefiles may care to update their build scripts +to build pnglibconf.h where the corresponding makefile does not do so. + +Building libpng with a non-default configuration has changed completely. +The old method using pngusr.h should still work correctly even though the +way pngusr.h is used in the build has been changed; however, library +builders will probably want to examine the changes to take advantage of +new capabilities and to simplify their build system. + +A. Specific changes to library configuration capabilities + +The exact mechanism used to control attributes of API functions has +changed. A single set of operating system independent macro definitions +is used and operating system specific directives are defined in +pnglibconf.h + +As part of this the mechanism used to choose procedure call standards on +those systems that allow a choice has been changed. At present this only +affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems +running on Intel processors. As before, PNGAPI is defined where required +to control the exported API functions; however, two new macros, PNGCBAPI +and PNGCAPI, are used instead for callback functions (PNGCBAPI) and +(PNGCAPI) for functions that must match a C library prototype (currently +only png_longjmp_ptr, which must match the C longjmp function.) The new +approach is documented in pngconf.h + +Despite these changes, libpng 1.5.0 only supports the native C function +calling standard on those platforms tested so far ("__cdecl" on Microsoft +Windows). This is because the support requirements for alternative +calling conventions seem to no longer exist. Developers who find it +necessary to set PNG_API_RULE to 1 should advise the mailing list +(png-mng-implement) of this and library builders who use Openwatcom and +therefore set PNG_API_RULE to 2 should also contact the mailing list. + +B. Changes to the configuration mechanism + +Prior to libpng-1.5.0 library builders who needed to configure libpng +had either to modify the exported pngconf.h header file to add system +specific configuration or had to write feature selection macros into +pngusr.h and cause this to be included into pngconf.h by defining +PNG_USER_CONFIG. The latter mechanism had the disadvantage that an +application built without PNG_USER_CONFIG defined would see the +unmodified, default, libpng API and thus would probably fail to link. + +These mechanisms still work in the configure build and in any makefile +build that builds pnglibconf.h, although the feature selection macros +have changed somewhat as described above. In 1.5.0, however, pngusr.h is +processed only once, at the time the exported header file pnglibconf.h is +built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored +after the build of pnglibconf.h and it is never included in an application +build. + +The formerly used alternative of adding a list of feature macros to the +CPPFLAGS setting in the build also still works; however, the macros will be +copied to pnglibconf.h and this may produce macro redefinition warnings +when the individual C files are compiled. + +All configuration now only works if pnglibconf.h is built from +scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan +(the original author of awk) maintains C source code of that awk and this +and all known later implementations (often called by subtly different +names - nawk and gawk for example) are adequate to build pnglibconf.h. +The Sun Microsystems (now Oracle) program 'awk' is an earlier version +and does not work; this may also apply to other systems that have a +functioning awk called 'nawk'. + +Configuration options are now documented in scripts/pnglibconf.dfa. This +file also includes dependency information that ensures a configuration is +consistent; that is, if a feature is switched off, dependent features are +also switched off. As a recommended alternative to using feature macros in +pngusr.h a system builder may also define equivalent options in pngusr.dfa +(or, indeed, any file) and add that to the configuration by setting +DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate +how to do this, and also illustrate a case where pngusr.h is still required. + +After you have built libpng, the definitions that were recorded in +pnglibconf.h are available to your application (pnglibconf.h is included +in png.h and gets installed alongside png.h and pngconf.h in your +$PREFIX/include directory). Do not edit pnglibconf.h after you have built +libpng, because than the settings would not accurately reflect the settings +that were used to build libpng. + +XVI. Setjmp/longjmp issues + +Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp() +is known to be not thread-safe on some platforms and we don't know of +any platform where it is guaranteed to be thread-safe. Therefore, if +your application is going to be using multiple threads, you should +configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with +-DPNG_NO_SETJMP on your compile line, or with + + #undef PNG_SETJMP_SUPPORTED + +in your pnglibconf.h or pngusr.h. + +Starting with libpng-1.6.0, the library included a "simplified API". +This requires setjmp/longjmp, so you must either build the library +with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED +and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined. + +XVII. Common linking failures + +If your application fails to find libpng or zlib entries while linking: + + Be sure "-lz" appears after "-lpng" on your linking command. + + Be sure you have built libpng, zlib, and your application for the + same platform (e.g., 32-bit or 64-bit). + + If you are using the vstudio project, observe the WARNING in + project/vstudio/README.txt. + +XVIII. Other sources of information about libpng: + +Further information can be found in the README and libpng-manual.txt files, in the individual makefiles, in png.h, and the manual pages libpng.3 and png.5. - -Using the ./configure script -- 16 December 2002. -================================================= - - -The ./configure script should work compatibly with what scripts/makefile.* -did, however there are some options you need to add to configure explicitly, -which previously was done semi-automatically (if you didn't edit -scripts/makefile.* yourself, that is) - - -CFLAGS="-Wall -O -funroll-loops \ --malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \ ---with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include - -You can alternatively specify --includedir=/usr/include, /usr/local/include, -/usr/include/png12, or whatever. - - +Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson +This document is released under the libpng license. +For conditions of distribution and use, see the disclaimer +and license in png.h. diff --git a/libs/libpng-src/LICENSE b/libs/libpng-src/LICENSE index 0fa9cb703..e0c5b531c 100644 --- a/libs/libpng-src/LICENSE +++ b/libs/libpng-src/LICENSE @@ -1,111 +1,134 @@ +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE +========================================= -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. +PNG Reference Library License version 2 +--------------------------------------- -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: + * Copyright (c) 1995-2019 The PNG Reference Library Authors. + * Copyright (c) 2018-2019 Cosmin Truta. + * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. + * Copyright (c) 1996-1997 Andreas Dilger. + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. -If you modify libpng you may insert additional notices immediately following -this sentence. +The software is supplied "as is", without warranty of any kind, +express or implied, including, without limitation, the warranties +of merchantability, fitness for a particular purpose, title, and +non-infringement. In no event shall the Copyright owners, or +anyone distributing the software, be liable for any damages or +other liability, whether in contract, tort or otherwise, arising +from, out of, or in connection with the software, or the use or +other dealings in the software, even if advised of the possibility +of such damage. -This code is released under the libpng license. +Permission is hereby granted to use, copy, modify, and distribute +this software, or portions hereof, for any purpose, without fee, +subject to the following restrictions: -libpng versions 1.2.6, August 15, 2004, through 1.2.46, July 9, 2011, are -Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.2.5 -with the following individual added to the list of Contributing Authors + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you + use this software in a product, an acknowledgment in the product + documentation would be appreciated, but is not required. - Cosmin Truta + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. -libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are -Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-1.0.6 -with the following individuals added to the list of Contributing Authors + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. - Simon-Pierre Cadieux - Eric S. Raymond - Gilles Vollant + +PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) +----------------------------------------------------------------------- + +libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are +Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are +derived from libpng-1.0.6, and are distributed according to the same +disclaimer and license as libpng-1.0.6 with the following individuals +added to the list of Contributing Authors: + + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + Mandar Sahastrabuddhe + Google Inc. + Vadim Barkov and with the following additions to the disclaimer: - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. + There is no warranty against interference with your enjoyment of + the library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is + with the user. + +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners, and +are released under other open source licenses. libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are -distributed according to the same disclaimer and license as libpng-0.96, -with the following individuals added to the list of Contributing Authors: +Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from +libpng-0.96, and are distributed according to the same disclaimer and +license as libpng-0.96, with the following individuals added to the +list of Contributing Authors: - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996, 1997 Andreas Dilger -Distributed according to the same disclaimer and license as libpng-0.88, -with the following individuals added to the list of Contributing Authors: +Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, +and are distributed according to the same disclaimer and license as +libpng-0.88, with the following individuals added to the list of +Contributing Authors: - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +Some files in the "scripts" directory have other copyright owners, +but are released under this license. libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc. +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. For the purposes of this copyright and license, "Contributing Authors" is defined as the following set of individuals: - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. +The PNG Reference Library is supplied "AS IS". The Contributing +Authors and Group 42, Inc. disclaim all warranties, expressed or +implied, including, without limitation, the warranties of +merchantability and of fitness for any purpose. The Contributing +Authors and Group 42, Inc. assume no liability for direct, indirect, +incidental, special, exemplary, or consequential damages, which may +result from the use of the PNG Reference Library, even if advised of +the possibility of such damage. Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions: -1. The origin of this source code must not be misrepresented. + 1. The origin of this source code must not be misrepresented. -2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. -3. This Copyright notice may not be removed or altered from any - source or altered source distribution. + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s",png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a -certification mark of the Open Source Initiative. - -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -July 9, 2011 +The Contributing Authors and Group 42, Inc. specifically permit, +without fee, and encourage the use of this source code as a component +to supporting the PNG file format in commercial products. If you use +this source code in a product, acknowledgment is not required but would +be appreciated. diff --git a/libs/libpng-src/Makefile.am b/libs/libpng-src/Makefile.am index d3289ca95..4f621aa4d 100644 --- a/libs/libpng-src/Makefile.am +++ b/libs/libpng-src/Makefile.am @@ -1,155 +1,393 @@ -# Makefile.am: -# Source file for Makefile.in (and hence Makefile) +# Makefile.am, the source file for Makefile.in (and hence Makefile), is # -# Makefile.am need only be changed on a major version number -# change (e.g. libpng12 --> libpng14). In that case seach -# this file for every instance of the old base name (libpng12) -# and change to the new one (libpng14), then change the -# -version-number settings below so that the new values have -# the correct major part (first field). +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -# libpng does not follow GNU file name conventions -AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I scripts # test programs - run on make check, make distcheck -check_PROGRAMS= pngtest +check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp +if HAVE_CLOCK_GETTIME +check_PROGRAMS += timepng +endif + +# Utilities - installed +bin_PROGRAMS= pngfix png-fix-itxt + +# This ensures that pnglibconf.h gets built at the start of 'make all' or +# 'make check', but it does not add dependencies to the individual programs, +# this is done below. +# +# IMPORTANT: always add the object modules of new programs to the list below +# because otherwise the sequence 'configure; make new-program' will *sometimes* +# result in the installed (system) pnglibconf.h being used and the result is +# always wrong and always very confusing. +BUILT_SOURCES = pnglibconf.h + pngtest_SOURCES = pngtest.c -pngtest_LDADD = libpng12.la -TESTS = test-pngtest.sh -TESTS_ENVIRONMENT= srcdir=$(srcdir) +pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngvalid_SOURCES = contrib/libtests/pngvalid.c +pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngstest_SOURCES = contrib/libtests/pngstest.c +pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngunknown_SOURCES = contrib/libtests/pngunknown.c +pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngimage_SOURCES = contrib/libtests/pngimage.c +pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +timepng_SOURCES = contrib/libtests/timepng.c +timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +pngfix_SOURCES = contrib/tools/pngfix.c +pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c + +pngcp_SOURCES = contrib/tools/pngcp.c +pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +# Generally these are single line shell scripts to run a test with a particular +# set of parameters: +TESTS =\ + tests/pngtest\ + tests/pngtest-badpngs\ + tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ + tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ + tests/pngvalid-gamma-expand16-background\ + tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ + tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ + tests/pngvalid-progressive-size\ + tests/pngvalid-progressive-interlace-standard\ + tests/pngvalid-transform\ + tests/pngvalid-progressive-standard tests/pngvalid-standard\ + tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\ + tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\ + tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\ + tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ + tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\ + tests/pngimage-quick tests/pngimage-full # man pages dist_man_MANS= libpng.3 libpngpf.3 png.5 # generate the -config scripts if required -binconfigs= libpng12-config -EXTRA_SCRIPTS= libpng-config libpng12-config +binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config +EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config bin_SCRIPTS= @binconfigs@ # rules to build libpng, only build the old library on request -lib_LTLIBRARIES=libpng12.la @compatlib@ -EXTRA_LTLIBRARIES= libpng.la -libpng12_la_SOURCES = png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c \ - png.h pngconf.h -libpng_la_SOURCES = $(libpng12_la_SOURCES) +lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +# EXTRA_LTLIBRARIES= libpng.la +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\ + pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\ + pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\ + png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa -libpng_la_CPPFLAGS = @LIBPNG_DEFINES@ -libpng12_la_CPPFLAGS = @LIBPNG_DEFINES@ +if PNG_ARM_NEON +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\ + arm/filter_neon.S arm/filter_neon_intrinsics.c \ + arm/palette_neon_intrinsics.c +endif -# MAJOR UPGRADE: the version-number settings below must be changed. -libpng12_la_LDFLAGS = -no-undefined -export-dynamic \ - -version-number 0:@PNGLIB_RELEASE@:0 -# -rpath is needed as automake doesn't know the directory -libpng_la_LDFLAGS = -rpath '$(libdir)' -no-undefined -export-dynamic \ - -version-number 3:@PNGLIB_RELEASE@:0 +if PNG_MIPS_MSA +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\ + mips/filter_msa_intrinsics.c +endif + +if PNG_INTEL_SSE +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\ + intel/filter_sse2_intrinsics.c +endif + +if PNG_POWERPC_VSX +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\ + powerpc/filter_vsx_intrinsics.c +endif + +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h + +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \ + -version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 if HAVE_LD_VERSION_SCRIPT - # Versioned symbols and restricted exports - libpng12_la_LDFLAGS += -Wl,--version-script=libpng.vers - libpng12_la_DEPENDENCIES = libpng.vers +# Versioned symbols and restricted exports +if HAVE_SOLARIS_LD + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers else - # Only restricted exports when possible - libpng12_la_LDFLAGS += -export-symbols libpng.sym - libpng12_la_DEPENDENCIES = libpng.sym + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers endif -libpng_la_DEPENDENCIES = $(libpng12_la_DEPENDENCIES) -# Avoid depending upon Character Ranges. -AN = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers +else +# Only restricted exports when possible + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym +endif #distribute headers in /usr/include/libpng/* pkgincludedir= $(includedir)/$(PNGLIB_BASENAME) pkginclude_HEADERS= png.h pngconf.h +nodist_pkginclude_HEADERS= pnglibconf.h # pkg-config stuff, note that libpng.pc is always required in order # to get the correct library pkgconfigdir = @pkgconfigdir@ -pkgconfig_DATA = libpng12.pc +pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc -#extra source distribution files. +# Extra source distribution files, '${srcdir}' is used below to stop build files +# from those directories being included. This only works if the configure is +# not done in the source directory! EXTRA_DIST= \ - ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO \ + ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \ pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ - CMakeLists.txt \ - ${srcdir}/projects/cbuilder5/* \ - ${srcdir}/projects/beos/* \ - ${srcdir}/projects/visualc6/* \ - ${srcdir}/projects/visualc71/* \ - ${srcdir}/projects/wince.txt \ - ${srcdir}/projects/netware.txt \ - ${srcdir}/projects/xcode/* \ - ${srcdir}/scripts/* \ - ${srcdir}/contrib/gregbook/* \ - ${srcdir}/contrib/pngminim/* \ - ${srcdir}/contrib/pngminus/* \ - ${srcdir}/contrib/pngsuite/* \ - ${srcdir}/contrib/visupng/* \ - $(TESTS) \ - example.c libpng-1.2.46.txt pnggccrd.c pngvcrd.c + ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ + $(TESTS) $(XFAIL_TESTS) tests/pngstest \ + CMakeLists.txt example.c libpng-manual.txt -CLEANFILES= pngout.png libpng12.pc libpng12-config libpng.vers \ -libpng.sym +SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk + +CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ + check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ + pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ + $(SCRIPT_CLEANFILES) MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ config.sub configure depcomp install-sh ltmain.sh missing +# PNG_COPTS give extra options for the C compiler to be used on all compilation +# steps (unless targe_CFLAGS is specified; that will take precedence over +# AM_CFLAGS) +PNG_COPTS = @PNG_COPTS@ +AM_CFLAGS = ${PNG_COPTS} + +# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe +# other operating systems (NeXT?) the C preprocessor selected by configure +# checks input tokens for validity - effectively it performs part of the ANSI-C +# parsing - and therefore fails with the .df files. configure.ac has special +# checks for this and sets DFNCPP appropriately. +DFNCPP = @DFNCPP@ + +SUFFIXES = .chk .out + $(PNGLIB_BASENAME).pc: libpng.pc cp libpng.pc $@ $(PNGLIB_BASENAME)-config: libpng-config cp libpng-config $@ -libpng.sym: png.h pngconf.h - rm -f $@ $@.new - $(CPP) @LIBPNG_DEFINES@ $(CPPFLAGS) -DPNG_BUILDSYMS $(srcdir)/png.h | \ - $(SED) -n -e \ - 's|^.*PNG_FUNCTION_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \ - -e 's|^.*PNG_DATA_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \ - >$@.new - mv $@.new $@ +scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h +scripts/prefix.out: png.h pngconf.h pnglibconf.out +scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt +scripts/intprefix.out: pnglibconf.h -libpng.vers: libpng.sym - rm -f $@ $@.new - echo PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0 '{global:' > $@.new - $(SED) s/$$/\;/ libpng.sym >> $@.new - echo 'local: *; };' >> $@.new - mv $@.new $@ +libpng.sym: scripts/sym.out + rm -f $@ + cp $? $@ +libpng.vers: scripts/vers.out + rm -f $@ + cp $? $@ -test: check +if DO_PNG_PREFIX +# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix. +# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual +# implementation of the macro). +pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst + rm -f $@ + $(AWK) 's==0 && NR>1{print prev}\ + s==0{prev=$$0}\ + s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\ + s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\ + END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\ + s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8 + mv pnglibconf.tf8 $@ -# install the .../include headers as links to the new ones -install-data-hook: - cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h - cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h - cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h pngconf.h - cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc - cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc +pngprefix.h: scripts/intprefix.out + rm -f pngprefix.tf1 + $(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1 + mv pngprefix.tf1 $@ +else +pnglibconf.h: pnglibconf.out + rm -f $@ + cp $? $@ -# do evil things to libpng to cause libpng12 to be used -install-exec-hook: - cd $(DESTDIR)$(bindir); rm -f libpng-config - cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config - @set -x;\ - cd $(DESTDIR)$(libdir);\ - for ext in a la so sl dylib; do\ - rm -f libpng.$$ext;\ - if test -f $(PNGLIB_BASENAME).$$ext; then\ - $(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\ - fi;\ +pngprefix.h: # is empty + :>$@ +endif + +$(srcdir)/scripts/pnglibconf.h.prebuilt: + @echo "Attempting to build $@" >&2 + @echo "This is a machine generated file, but if you want to make" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 + @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 + @exit 1 + +# The following is necessary to ensure that the local pnglibconf.h is used, not +# an installed one (this can happen immediately after on a clean system if +# 'make test' is the first thing the user does.) Only files which include +# one of the png source files (typically png.h or pngpriv.h) need to be listed +# here: +pngtest.o: pnglibconf.h + +contrib/libtests/makepng.o: pnglibconf.h +contrib/libtests/pngstest.o: pnglibconf.h +contrib/libtests/pngunknown.o: pnglibconf.h +contrib/libtests/pngimage.o: pnglibconf.h +contrib/libtests/pngvalid.o: pnglibconf.h +contrib/libtests/readpng.o: pnglibconf.h +contrib/libtests/tarith.o: pnglibconf.h +contrib/libtests/timepng.o: pnglibconf.h + +contrib/tools/makesRGB.o: pnglibconf.h +contrib/tools/pngfix.o: pnglibconf.h +contrib/tools/pngcp.o: pnglibconf.h + +# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually +# be built with PNG_USE_READ_MACROS; this prevents the read macros from +# interfering with the symbol file format. +SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\ + -DPNGLIB_VERSION='@PNGLIB_VERSION@'\ + -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\ + -DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE + +if DO_PNG_PREFIX +SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@' +endif + +.c.out: + rm -f $@ $*.tf[12] + test -d scripts || mkdir scripts || test -d scripts + $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ + $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1 + $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 + rm -f $*.tf1 + mv $*.tf2 $@ + +# The .c file for pnglibconf.h is machine generated +pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) + rm -f $@ $*.tf[45] + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2 + rm $*.tf4 + mv $*.tf5 $@ + +# Symbol checks (.def and .out files should match) +scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out + +.out.chk: + rm -f $@ $*.new + $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ + of="$*.new" $< >&2 + mv $*.new $@ + +# used on demand to regenerate the standard header, CPPFLAGS should +# be empty - no non-standard defines +scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h + rm -f $@ pnglibconf.tf[67] + test -z "$(CPPFLAGS)" + echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\ + logunsupported=1 version=search ${srcdir}/pngconf.h -\ + ${srcdir}/scripts/pnglibconf.dfa 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\ + pnglibconf.tf6 1>&2 + rm pnglibconf.tf6 + mv pnglibconf.tf7 $@ + +$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \ + pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h + +test: check-am + +# Extra checks +check: scripts/symbols.chk + +# Don't distribute the generated script files +dist-hook: + cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) + +# Make links between installed files with release-specific names and the generic +# file names. If this install rule is run the generic names will be deleted and +# recreated - this has obvious issues for systems with multiple installations. + +install-header-links: + @set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \ + rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done + +uninstall-header-links: + cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS) + +install-libpng-pc: + @set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \ + $(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc + +uninstall-libpng-pc: + rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc' + +# EXT_LIST is a list of the possibly library directory extensions, this exists +# because we can't find a good way of discovering the file extensions that are +# actually installed on a given system, so instead we check for every extension +# we have seen. + +EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib + +install-library-links: + @set -x; cd '$(DESTDIR)$(libdir)';\ + for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext";\ + if test -f "$(PNGLIB_BASENAME).$$ext"; then\ + $(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\ + fi;\ done -uninstall-hook: - cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h - rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc - rm -f $(DESTDIR)$(bindir)/libpng-config - @if test -n "@compatlib@"; then\ - set -x;\ - cd $(DESTDIR)$(libdir);\ - for ext in a la so sl dylib; do\ - rm -f libpng.$$ext;\ - done;\ - fi +uninstall-library-links: + @set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext"; done + +install-libpng-config: + @set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \ + $(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config + +uninstall-libpng-config: + rm -f '$(DESTDIR)$(bindir)/libpng-config' + +if DO_INSTALL_LINKS +# If --enable-unversioned-links is specified the header and lib file links +# will be automatically made on a 'make install': + +install-data-hook: install-header-links +uninstall-hook: uninstall-header-links +install-exec-hook: install-library-links +uninstall-hook: uninstall-library-links +endif + +if DO_INSTALL_LIBPNG_PC +# Likewise, --install-pc causes libpng.pc to be constructed: + +install-data-hook: install-libpng-pc +uninstall-hook: uninstall-libpng-pc +endif + +if DO_INSTALL_LIBPNG_CONFIG +# And --install-config: + +install-exec-hook: install-libpng-config +uninstall-hook: uninstall-libpng-config +endif + +# The following addition ensures that 'make all' always builds the test programs +# too. It used to, but some change either in libpng or configure stopped this +# working. +all-am: $(check_PROGRAMS) diff --git a/libs/libpng-src/Makefile.in b/libs/libpng-src/Makefile.in index d07cb3d7b..81ac1c855 100644 --- a/libs/libpng-src/Makefile.in +++ b/libs/libpng-src/Makefile.in @@ -1,9 +1,8 @@ -# Makefile.in generated by automake 1.11 from Makefile.am. +# Makefile.in generated by automake 1.16.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1994-2018 Free Software Foundation, Inc. + # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -15,20 +14,75 @@ @SET_MAKE@ -# Makefile.am: -# Source file for Makefile.in (and hence Makefile) +# Makefile.am, the source file for Makefile.in (and hence Makefile), is # -# Makefile.am need only be changed on a major version number -# change (e.g. libpng12 --> libpng14). In that case seach -# this file for every instance of the old base name (libpng12) -# and change to the new one (libpng14), then change the -# -version-number settings below so that the new values have -# the correct major part (first field). +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ @@ -46,27 +100,55 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -check_PROGRAMS = pngtest$(EXEEXT) -@HAVE_LD_VERSION_SCRIPT_TRUE@am__append_1 = -Wl,--version-script=libpng.vers -@HAVE_LD_VERSION_SCRIPT_FALSE@am__append_2 = -export-symbols libpng.sym +check_PROGRAMS = pngtest$(EXEEXT) pngunknown$(EXEEXT) \ + pngstest$(EXEEXT) pngvalid$(EXEEXT) pngimage$(EXEEXT) \ + pngcp$(EXEEXT) $(am__EXEEXT_1) +@HAVE_CLOCK_GETTIME_TRUE@am__append_1 = timepng +bin_PROGRAMS = pngfix$(EXEEXT) png-fix-itxt$(EXEEXT) +@PNG_ARM_NEON_TRUE@am__append_2 = arm/arm_init.c\ +@PNG_ARM_NEON_TRUE@ arm/filter_neon.S arm/filter_neon_intrinsics.c \ +@PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.c + +@PNG_MIPS_MSA_TRUE@am__append_3 = mips/mips_init.c\ +@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.c + +@PNG_INTEL_SSE_TRUE@am__append_4 = intel/intel_init.c\ +@PNG_INTEL_SSE_TRUE@ intel/filter_sse2_intrinsics.c + +@PNG_POWERPC_VSX_TRUE@am__append_5 = powerpc/powerpc_init.c\ +@PNG_POWERPC_VSX_TRUE@ powerpc/filter_vsx_intrinsics.c + + +# Versioned symbols and restricted exports +@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_TRUE@am__append_6 = -Wl,-M -Wl,libpng.vers +@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_FALSE@am__append_7 = -Wl,--version-script=libpng.vers +# Only restricted exports when possible +@HAVE_LD_VERSION_SCRIPT_FALSE@am__append_8 = -export-symbols libpng.sym +@DO_PNG_PREFIX_TRUE@am__append_9 = -DPNG_PREFIX='@PNG_PREFIX@' subdir = . -DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \ - $(pkginclude_HEADERS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/config.h.in \ - $(top_srcdir)/configure $(top_srcdir)/scripts/libpng-config.in \ - $(top_srcdir)/scripts/libpng.pc-configure.in INSTALL TODO \ - config.guess config.sub depcomp install-sh ltmain.sh missing \ - mkinstalldirs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/scripts/libtool.m4 \ + $(top_srcdir)/scripts/ltoptions.m4 \ + $(top_srcdir)/scripts/ltsugar.m4 \ + $(top_srcdir)/scripts/ltversion.m4 \ + $(top_srcdir)/scripts/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ + $(am__configure_deps) $(pkginclude_HEADERS) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = libpng.pc libpng-config CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" \ + "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" \ + "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)" +@HAVE_CLOCK_GETTIME_TRUE@am__EXEEXT_1 = timepng$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -88,83 +170,396 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \ - "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" \ - "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(pkgincludedir)" +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } LTLIBRARIES = $(lib_LTLIBRARIES) -libpng_la_LIBADD = -am__objects_1 = libpng_la-png.lo libpng_la-pngset.lo \ - libpng_la-pngget.lo libpng_la-pngrutil.lo \ - libpng_la-pngtrans.lo libpng_la-pngwutil.lo \ - libpng_la-pngread.lo libpng_la-pngrio.lo libpng_la-pngwio.lo \ - libpng_la-pngwrite.lo libpng_la-pngrtran.lo \ - libpng_la-pngwtran.lo libpng_la-pngmem.lo \ - libpng_la-pngerror.lo libpng_la-pngpread.lo -am_libpng_la_OBJECTS = $(am__objects_1) -libpng_la_OBJECTS = $(am_libpng_la_OBJECTS) -libpng_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libpng_la_LDFLAGS) $(LDFLAGS) -o $@ -libpng12_la_LIBADD = -am_libpng12_la_OBJECTS = libpng12_la-png.lo libpng12_la-pngset.lo \ - libpng12_la-pngget.lo libpng12_la-pngrutil.lo \ - libpng12_la-pngtrans.lo libpng12_la-pngwutil.lo \ - libpng12_la-pngread.lo libpng12_la-pngrio.lo \ - libpng12_la-pngwio.lo libpng12_la-pngwrite.lo \ - libpng12_la-pngrtran.lo libpng12_la-pngwtran.lo \ - libpng12_la-pngmem.lo libpng12_la-pngerror.lo \ - libpng12_la-pngpread.lo -libpng12_la_OBJECTS = $(am_libpng12_la_OBJECTS) -libpng12_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libpng12_la_LDFLAGS) $(LDFLAGS) -o $@ +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = +am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST = png.c \ + pngerror.c pngget.c pngmem.c pngpread.c pngread.c pngrio.c \ + pngrtran.c pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c \ + pngwtran.c pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h \ + pngpriv.h pngstruct.h pngusr.dfa arm/arm_init.c \ + arm/filter_neon.S arm/filter_neon_intrinsics.c \ + arm/palette_neon_intrinsics.c mips/mips_init.c \ + mips/filter_msa_intrinsics.c intel/intel_init.c \ + intel/filter_sse2_intrinsics.c powerpc/powerpc_init.c \ + powerpc/filter_vsx_intrinsics.c +am__dirstamp = $(am__leading_dot)dirstamp +@PNG_ARM_NEON_TRUE@am__objects_1 = arm/arm_init.lo arm/filter_neon.lo \ +@PNG_ARM_NEON_TRUE@ arm/filter_neon_intrinsics.lo \ +@PNG_ARM_NEON_TRUE@ arm/palette_neon_intrinsics.lo +@PNG_MIPS_MSA_TRUE@am__objects_2 = mips/mips_init.lo \ +@PNG_MIPS_MSA_TRUE@ mips/filter_msa_intrinsics.lo +@PNG_INTEL_SSE_TRUE@am__objects_3 = intel/intel_init.lo \ +@PNG_INTEL_SSE_TRUE@ intel/filter_sse2_intrinsics.lo +@PNG_POWERPC_VSX_TRUE@am__objects_4 = powerpc/powerpc_init.lo \ +@PNG_POWERPC_VSX_TRUE@ powerpc/filter_vsx_intrinsics.lo +am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = png.lo pngerror.lo \ + pngget.lo pngmem.lo pngpread.lo pngread.lo pngrio.lo \ + pngrtran.lo pngrutil.lo pngset.lo pngtrans.lo pngwio.lo \ + pngwrite.lo pngwtran.lo pngwutil.lo $(am__objects_1) \ + $(am__objects_2) $(am__objects_3) $(am__objects_4) +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS = \ + $(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) \ + $(nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK = $(LIBTOOL) $(AM_V_lt) \ + --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \ + $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS) $(LDFLAGS) -o \ + $@ +am_png_fix_itxt_OBJECTS = contrib/tools/png-fix-itxt.$(OBJEXT) +png_fix_itxt_OBJECTS = $(am_png_fix_itxt_OBJECTS) +png_fix_itxt_LDADD = $(LDADD) +am_pngcp_OBJECTS = contrib/tools/pngcp.$(OBJEXT) +pngcp_OBJECTS = $(am_pngcp_OBJECTS) +pngcp_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngfix_OBJECTS = contrib/tools/pngfix.$(OBJEXT) +pngfix_OBJECTS = $(am_pngfix_OBJECTS) +pngfix_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngimage_OBJECTS = contrib/libtests/pngimage.$(OBJEXT) +pngimage_OBJECTS = $(am_pngimage_OBJECTS) +pngimage_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngstest_OBJECTS = contrib/libtests/pngstest.$(OBJEXT) +pngstest_OBJECTS = $(am_pngstest_OBJECTS) +pngstest_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la am_pngtest_OBJECTS = pngtest.$(OBJEXT) pngtest_OBJECTS = $(am_pngtest_OBJECTS) -pngtest_DEPENDENCIES = libpng12.la +pngtest_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngunknown_OBJECTS = contrib/libtests/pngunknown.$(OBJEXT) +pngunknown_OBJECTS = $(am_pngunknown_OBJECTS) +pngunknown_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_pngvalid_OBJECTS = contrib/libtests/pngvalid.$(OBJEXT) +pngvalid_OBJECTS = $(am_pngvalid_OBJECTS) +pngvalid_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +am_timepng_OBJECTS = contrib/libtests/timepng.$(OBJEXT) +timepng_OBJECTS = $(am_timepng_OBJECTS) +timepng_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la SCRIPTS = $(bin_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles +am__maybe_remake_depfiles = depfiles +am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \ + ./$(DEPDIR)/pngget.Plo ./$(DEPDIR)/pngmem.Plo \ + ./$(DEPDIR)/pngpread.Plo ./$(DEPDIR)/pngread.Plo \ + ./$(DEPDIR)/pngrio.Plo ./$(DEPDIR)/pngrtran.Plo \ + ./$(DEPDIR)/pngrutil.Plo ./$(DEPDIR)/pngset.Plo \ + ./$(DEPDIR)/pngtest.Po ./$(DEPDIR)/pngtrans.Plo \ + ./$(DEPDIR)/pngwio.Plo ./$(DEPDIR)/pngwrite.Plo \ + ./$(DEPDIR)/pngwtran.Plo ./$(DEPDIR)/pngwutil.Plo \ + arm/$(DEPDIR)/arm_init.Plo arm/$(DEPDIR)/filter_neon.Plo \ + arm/$(DEPDIR)/filter_neon_intrinsics.Plo \ + arm/$(DEPDIR)/palette_neon_intrinsics.Plo \ + contrib/libtests/$(DEPDIR)/pngimage.Po \ + contrib/libtests/$(DEPDIR)/pngstest.Po \ + contrib/libtests/$(DEPDIR)/pngunknown.Po \ + contrib/libtests/$(DEPDIR)/pngvalid.Po \ + contrib/libtests/$(DEPDIR)/timepng.Po \ + contrib/tools/$(DEPDIR)/png-fix-itxt.Po \ + contrib/tools/$(DEPDIR)/pngcp.Po \ + contrib/tools/$(DEPDIR)/pngfix.Po \ + intel/$(DEPDIR)/filter_sse2_intrinsics.Plo \ + intel/$(DEPDIR)/intel_init.Plo \ + mips/$(DEPDIR)/filter_msa_intrinsics.Plo \ + mips/$(DEPDIR)/mips_init.Plo \ + powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo \ + powerpc/$(DEPDIR)/powerpc_init.Plo am__mv = mv -f +CPPASCOMPILE = $(CCAS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CCASFLAGS) $(CCASFLAGS) +LTCPPASCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CCAS) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CCASFLAGS) $(CCASFLAGS) +AM_V_CPPAS = $(am__v_CPPAS_@AM_V@) +am__v_CPPAS_ = $(am__v_CPPAS_@AM_DEFAULT_V@) +am__v_CPPAS_0 = @echo " CPPAS " $@; +am__v_CPPAS_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ -SOURCES = $(libpng_la_SOURCES) $(libpng12_la_SOURCES) \ - $(pngtest_SOURCES) -DIST_SOURCES = $(libpng_la_SOURCES) $(libpng12_la_SOURCES) \ - $(pngtest_SOURCES) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \ + $(nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \ + $(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \ + $(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \ + $(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES) +DIST_SOURCES = \ + $(am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST) \ + $(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \ + $(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \ + $(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac man3dir = $(mandir)/man3 man5dir = $(mandir)/man5 NROFF = nroff MANS = $(dist_man_MANS) DATA = $(pkgconfig_DATA) -HEADERS = $(pkginclude_HEADERS) +HEADERS = $(nodist_pkginclude_HEADERS) $(pkginclude_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ + $(LISP)config.h.in +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags -am__tty_colors = \ -red=; grn=; lgn=; blu=; std= +CSCOPE = cscope +AM_RECURSIVE_TARGETS = cscope check recheck +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = { \ + $(am__tty_colors_dummy); \ + if test "X$(AM_COLOR_TESTS)" = Xno; then \ + am__color_tests=no; \ + elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ + am__color_tests=yes; \ + elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ + am__color_tests=yes; \ + fi; \ + if test $$am__color_tests = yes; then \ + red=''; \ + grn=''; \ + lgn=''; \ + blu=''; \ + mgn=''; \ + brg=''; \ + std=''; \ + fi; \ +} +am__recheck_rx = ^[ ]*:recheck:[ ]* +am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* +am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* +# A command that, given a newline-separated list of test names on the +# standard input, print the name of the tests that are to be re-run +# upon "make recheck". +am__list_recheck_tests = $(AWK) '{ \ + recheck = 1; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + { \ + if ((getline line2 < ($$0 ".log")) < 0) \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ + { \ + recheck = 0; \ + break; \ + } \ + else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ + { \ + break; \ + } \ + }; \ + if (recheck) \ + print $$0; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# A command that, given a newline-separated list of test names on the +# standard input, create the global log from their .trs and .log files. +am__create_global_log = $(AWK) ' \ +function fatal(msg) \ +{ \ + print "fatal: making $@: " msg | "cat >&2"; \ + exit 1; \ +} \ +function rst_section(header) \ +{ \ + print header; \ + len = length(header); \ + for (i = 1; i <= len; i = i + 1) \ + printf "="; \ + printf "\n\n"; \ +} \ +{ \ + copy_in_global_log = 1; \ + global_test_result = "RUN"; \ + while ((rc = (getline line < ($$0 ".trs"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".trs"); \ + if (line ~ /$(am__global_test_result_rx)/) \ + { \ + sub("$(am__global_test_result_rx)", "", line); \ + sub("[ ]*$$", "", line); \ + global_test_result = line; \ + } \ + else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ + copy_in_global_log = 0; \ + }; \ + if (copy_in_global_log) \ + { \ + rst_section(global_test_result ": " $$0); \ + while ((rc = (getline line < ($$0 ".log"))) != 0) \ + { \ + if (rc < 0) \ + fatal("failed to read from " $$0 ".log"); \ + print line; \ + }; \ + printf "\n"; \ + }; \ + close ($$0 ".trs"); \ + close ($$0 ".log"); \ +}' +# Restructured Text title. +am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } +# Solaris 10 'make', and several other traditional 'make' implementations, +# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it +# by disabling -e (using the XSI extension "set +e") if it's set. +am__sh_e_setup = case $$- in *e*) set +e;; esac +# Default flags passed to test drivers. +am__common_driver_flags = \ + --color-tests "$$am__color_tests" \ + --enable-hard-errors "$$am__enable_hard_errors" \ + --expect-failure "$$am__expect_failure" +# To be inserted before the command running the test. Creates the +# directory for the log if needed. Stores in $dir the directory +# containing $f, in $tst the test, in $log the log. Executes the +# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and +# passes TESTS_ENVIRONMENT. Set up options for the wrapper that +# will run the test scripts (or their associated LOG_COMPILER, if +# thy have one). +am__check_pre = \ +$(am__sh_e_setup); \ +$(am__vpath_adj_setup) $(am__vpath_adj) \ +$(am__tty_colors); \ +srcdir=$(srcdir); export srcdir; \ +case "$@" in \ + */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ + *) am__odir=.;; \ +esac; \ +test "x$$am__odir" = x"." || test -d "$$am__odir" \ + || $(MKDIR_P) "$$am__odir" || exit $$?; \ +if test -f "./$$f"; then dir=./; \ +elif test -f "$$f"; then dir=; \ +else dir="$(srcdir)/"; fi; \ +tst=$$dir$$f; log='$@'; \ +if test -n '$(DISABLE_HARD_ERRORS)'; then \ + am__enable_hard_errors=no; \ +else \ + am__enable_hard_errors=yes; \ +fi; \ +case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ + am__expect_failure=yes;; \ + *) \ + am__expect_failure=no;; \ +esac; \ +$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) +# A shell command to get the names of the tests scripts with any registered +# extension removed (i.e., equivalently, the names of the test logs, with +# the '.log' extension removed). The result is saved in the shell variable +# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, +# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", +# since that might cause problem with VPATH rewrites for suffix-less tests. +# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. +am__set_TESTS_bases = \ + bases='$(TEST_LOGS)'; \ + bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ + bases=`echo $$bases` +RECHECK_LOGS = $(TEST_LOGS) +TEST_SUITE_LOG = test-suite.log +TEST_EXTENSIONS = @EXEEXT@ .test +LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) +am__set_b = \ + case '$@' in \ + */*) \ + case '$*' in \ + */*) b='$*';; \ + *) b=`echo '$@' | sed 's/\.log$$//'`; \ + esac;; \ + *) \ + b='$*';; \ + esac +am__test_logs1 = $(TESTS:=.log) +am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) +TEST_LOGS = $(am__test_logs2:.test.log=.log) +TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver +TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ + $(TEST_LOG_FLAGS) +am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in $(srcdir)/libpng-config.in \ + $(srcdir)/libpng.pc.in AUTHORS INSTALL README TODO compile \ + config.guess config.sub depcomp install-sh ltmain.sh missing \ + test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } -DIST_ARCHIVES = $(distdir).tar.gz + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi +am__post_remove_distdir = $(am__remove_distdir) +DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz GZIP_ENV = --best +DIST_TARGETS = dist-xz dist-gzip distuninstallcheck_listfiles = find . -type f -print +am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ + | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print #distribute headers in /usr/include/libpng/* pkgincludedir = $(includedir)/$(PNGLIB_BASENAME) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ @@ -172,6 +567,9 @@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ +CCAS = @CCAS@ +CCASDEPMODE = @CCASDEPMODE@ +CCASFLAGS = @CCASFLAGS@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ @@ -179,6 +577,13 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ + +# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe +# other operating systems (NeXT?) the C preprocessor selected by configure +# checks input tokens for validity - effectively it performs part of the ANSI-C +# parsing - and therefore fails with the .df files. configure.ac has special +# checks for this and sets DFNCPP appropriately. +DFNCPP = @DFNCPP@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ @@ -197,15 +602,15 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ -LIBPNG_DEFINES = @LIBPNG_DEFINES@ -LIBPNG_NO_MMX = @LIBPNG_NO_MMX@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -225,6 +630,12 @@ PNGLIB_MAJOR = @PNGLIB_MAJOR@ PNGLIB_MINOR = @PNGLIB_MINOR@ PNGLIB_RELEASE = @PNGLIB_RELEASE@ PNGLIB_VERSION = @PNGLIB_VERSION@ + +# PNG_COPTS give extra options for the C compiler to be used on all compilation +# steps (unless targe_CFLAGS is specified; that will take precedence over +# AM_CFLAGS) +PNG_COPTS = @PNG_COPTS@ +PNG_PREFIX = @PNG_PREFIX@ POW_LIB = @POW_LIB@ RANLIB = @RANLIB@ SED = @SED@ @@ -237,6 +648,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -246,7 +658,7 @@ am__tar = @am__tar@ am__untar = @am__untar@ # generate the -config scripts if required -binconfigs = libpng12-config +binconfigs = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config bindir = @bindir@ build = @build@ build_alias = @build_alias@ @@ -254,7 +666,6 @@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ -compatlib = @compatlib@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ @@ -273,7 +684,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -294,80 +704,124 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ PNGLIB_BASENAME = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ +ACLOCAL_AMFLAGS = -I scripts -# libpng does not follow GNU file name conventions -AUTOMAKE_OPTIONS = foreign +# This ensures that pnglibconf.h gets built at the start of 'make all' or +# 'make check', but it does not add dependencies to the individual programs, +# this is done below. +# +# IMPORTANT: always add the object modules of new programs to the list below +# because otherwise the sequence 'configure; make new-program' will *sometimes* +# result in the installed (system) pnglibconf.h being used and the result is +# always wrong and always very confusing. +BUILT_SOURCES = pnglibconf.h pngtest_SOURCES = pngtest.c -pngtest_LDADD = libpng12.la -TESTS = test-pngtest.sh -TESTS_ENVIRONMENT = srcdir=$(srcdir) +pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngvalid_SOURCES = contrib/libtests/pngvalid.c +pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngstest_SOURCES = contrib/libtests/pngstest.c +pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngunknown_SOURCES = contrib/libtests/pngunknown.c +pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngimage_SOURCES = contrib/libtests/pngimage.c +pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +timepng_SOURCES = contrib/libtests/timepng.c +timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +pngfix_SOURCES = contrib/tools/pngfix.c +pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c +pngcp_SOURCES = contrib/tools/pngcp.c +pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la + +# Generally these are single line shell scripts to run a test with a particular +# set of parameters: +TESTS = \ + tests/pngtest\ + tests/pngtest-badpngs\ + tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\ + tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\ + tests/pngvalid-gamma-expand16-background\ + tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\ + tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\ + tests/pngvalid-progressive-size\ + tests/pngvalid-progressive-interlace-standard\ + tests/pngvalid-transform\ + tests/pngvalid-progressive-standard tests/pngvalid-standard\ + tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\ + tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\ + tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\ + tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\ + tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\ + tests/pngimage-quick tests/pngimage-full + # man pages dist_man_MANS = libpng.3 libpngpf.3 png.5 -EXTRA_SCRIPTS = libpng-config libpng12-config +EXTRA_SCRIPTS = libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config bin_SCRIPTS = @binconfigs@ # rules to build libpng, only build the old library on request -lib_LTLIBRARIES = libpng12.la @compatlib@ -EXTRA_LTLIBRARIES = libpng.la -libpng12_la_SOURCES = png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ - pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ - pngwtran.c pngmem.c pngerror.c pngpread.c \ - png.h pngconf.h - -libpng_la_SOURCES = $(libpng12_la_SOURCES) -libpng_la_CPPFLAGS = @LIBPNG_DEFINES@ -libpng12_la_CPPFLAGS = @LIBPNG_DEFINES@ - -# MAJOR UPGRADE: the version-number settings below must be changed. -libpng12_la_LDFLAGS = -no-undefined -export-dynamic -version-number \ - 0:@PNGLIB_RELEASE@:0 $(am__append_1) $(am__append_2) -# -rpath is needed as automake doesn't know the directory -libpng_la_LDFLAGS = -rpath '$(libdir)' -no-undefined -export-dynamic \ - -version-number 3:@PNGLIB_RELEASE@:0 - -@HAVE_LD_VERSION_SCRIPT_FALSE@libpng12_la_DEPENDENCIES = libpng.sym -@HAVE_LD_VERSION_SCRIPT_TRUE@libpng12_la_DEPENDENCIES = libpng.vers -libpng_la_DEPENDENCIES = $(libpng12_la_DEPENDENCIES) - -# Avoid depending upon Character Ranges. -AN = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' +lib_LTLIBRARIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la +# EXTRA_LTLIBRARIES= libpng.la +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c \ + pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c \ + pngrutil.c pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c \ + pngwutil.c png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h \ + pngstruct.h pngusr.dfa $(am__append_2) $(am__append_3) \ + $(am__append_4) $(am__append_5) +nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined \ + -export-dynamic -version-number \ + @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 \ + $(am__append_6) $(am__append_7) $(am__append_8) +@HAVE_LD_VERSION_SCRIPT_FALSE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym +@HAVE_LD_VERSION_SCRIPT_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers pkginclude_HEADERS = png.h pngconf.h -pkgconfig_DATA = libpng12.pc +nodist_pkginclude_HEADERS = pnglibconf.h +pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc -#extra source distribution files. +# Extra source distribution files, '${srcdir}' is used below to stop build files +# from those directories being included. This only works if the configure is +# not done in the source directory! EXTRA_DIST = \ - ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO \ - CMakeLists.txt \ + ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \ pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \ - ${srcdir}/projects/cbuilder5/* \ - ${srcdir}/projects/beos/* \ - ${srcdir}/projects/visualc6/* \ - ${srcdir}/projects/visualc71/* \ - ${srcdir}/projects/wince.txt \ - ${srcdir}/projects/xcode/* \ - ${srcdir}/projects/netware.txt \ - ${srcdir}/scripts/* \ - ${srcdir}/contrib/gregbook/* \ - ${srcdir}/contrib/pngminim/* \ - ${srcdir}/contrib/pngminus/* \ - ${srcdir}/contrib/pngsuite/* \ - ${srcdir}/contrib/visupng/* \ - $(TESTS) \ - example.c libpng-1.2.46.txt pnggccrd.c pngvcrd.c + ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \ + $(TESTS) $(XFAIL_TESTS) tests/pngstest \ + CMakeLists.txt example.c libpng-manual.txt -CLEANFILES = pngout.png libpng12.pc libpng12-config libpng.vers \ -libpng.sym +SCRIPT_CLEANFILES = scripts/*.out scripts/*.chk +CLEANFILES = *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \ + libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \ + check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \ + pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \ + $(SCRIPT_CLEANFILES) MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \ config.sub configure depcomp install-sh ltmain.sh missing -all: config.h +AM_CFLAGS = ${PNG_COPTS} +SUFFIXES = .chk .out + +# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually +# be built with PNG_USE_READ_MACROS; this prevents the read macros from +# interfering with the symbol file format. +SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0' \ + -DPNGLIB_VERSION='@PNGLIB_VERSION@' \ + -DSYMBOL_PREFIX='$(SYMBOL_PREFIX)' -DPNG_NO_USE_READ_MACROS \ + -DPNG_BUILDING_SYMBOL_TABLE $(am__append_9) + +# EXT_LIST is a list of the possibly library directory extensions, this exists +# because we can't find a good way of discovering the file extensions that are +# actually installed on a given system, so instead we check for every extension +# we have seen. +EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib +all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj -am--refresh: +.SUFFIXES: .chk .out .S .c .lo .log .o .obj .test .test$(EXEEXT) .trs +am--refresh: Makefile @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ @@ -382,15 +836,14 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile -.PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -403,28 +856,84 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): config.h: stamp-h1 - @if test ! -f $@; then \ - rm -f stamp-h1; \ - $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ - else :; fi + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h -$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 -libpng.pc: $(top_builddir)/config.status $(top_srcdir)/scripts/libpng.pc-configure.in +libpng.pc: $(top_builddir)/config.status $(srcdir)/libpng.pc.in cd $(top_builddir) && $(SHELL) ./config.status $@ -libpng-config: $(top_builddir)/config.status $(top_srcdir)/scripts/libpng-config.in +libpng-config: $(top_builddir)/config.status $(srcdir)/libpng-config.in cd $(top_builddir) && $(SHELL) ./config.status $@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p \ + || test -f $$p1 \ + ; then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' \ + -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' \ + `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list + install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) - test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ @@ -432,6 +941,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) else :; fi; \ done; \ test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } @@ -447,32 +958,130 @@ uninstall-libLTLIBRARIES: clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) - @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ - dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ - test "$$dir" != "$$p" || dir=.; \ - echo "rm -f \"$${dir}/so_locations\""; \ - rm -f "$${dir}/so_locations"; \ - done -libpng.la: $(libpng_la_OBJECTS) $(libpng_la_DEPENDENCIES) - $(libpng_la_LINK) $(libpng_la_OBJECTS) $(libpng_la_LIBADD) $(LIBS) -libpng12.la: $(libpng12_la_OBJECTS) $(libpng12_la_DEPENDENCIES) - $(libpng12_la_LINK) -rpath $(libdir) $(libpng12_la_OBJECTS) $(libpng12_la_LIBADD) $(LIBS) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } +arm/$(am__dirstamp): + @$(MKDIR_P) arm + @: > arm/$(am__dirstamp) +arm/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) arm/$(DEPDIR) + @: > arm/$(DEPDIR)/$(am__dirstamp) +arm/arm_init.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) +arm/filter_neon.lo: arm/$(am__dirstamp) arm/$(DEPDIR)/$(am__dirstamp) +arm/filter_neon_intrinsics.lo: arm/$(am__dirstamp) \ + arm/$(DEPDIR)/$(am__dirstamp) +arm/palette_neon_intrinsics.lo: arm/$(am__dirstamp) \ + arm/$(DEPDIR)/$(am__dirstamp) +mips/$(am__dirstamp): + @$(MKDIR_P) mips + @: > mips/$(am__dirstamp) +mips/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) mips/$(DEPDIR) + @: > mips/$(DEPDIR)/$(am__dirstamp) +mips/mips_init.lo: mips/$(am__dirstamp) mips/$(DEPDIR)/$(am__dirstamp) +mips/filter_msa_intrinsics.lo: mips/$(am__dirstamp) \ + mips/$(DEPDIR)/$(am__dirstamp) +intel/$(am__dirstamp): + @$(MKDIR_P) intel + @: > intel/$(am__dirstamp) +intel/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) intel/$(DEPDIR) + @: > intel/$(DEPDIR)/$(am__dirstamp) +intel/intel_init.lo: intel/$(am__dirstamp) \ + intel/$(DEPDIR)/$(am__dirstamp) +intel/filter_sse2_intrinsics.lo: intel/$(am__dirstamp) \ + intel/$(DEPDIR)/$(am__dirstamp) +powerpc/$(am__dirstamp): + @$(MKDIR_P) powerpc + @: > powerpc/$(am__dirstamp) +powerpc/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) powerpc/$(DEPDIR) + @: > powerpc/$(DEPDIR)/$(am__dirstamp) +powerpc/powerpc_init.lo: powerpc/$(am__dirstamp) \ + powerpc/$(DEPDIR)/$(am__dirstamp) +powerpc/filter_vsx_intrinsics.lo: powerpc/$(am__dirstamp) \ + powerpc/$(DEPDIR)/$(am__dirstamp) -clean-checkPROGRAMS: - @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ - echo " rm -f" $$list; \ - rm -f $$list || exit $$?; \ - test -n "$(EXEEXT)" || exit 0; \ - list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f" $$list; \ - rm -f $$list -pngtest$(EXEEXT): $(pngtest_OBJECTS) $(pngtest_DEPENDENCIES) +libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES) $(EXTRA_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES) + $(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LINK) -rpath $(libdir) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD) $(LIBS) +contrib/tools/$(am__dirstamp): + @$(MKDIR_P) contrib/tools + @: > contrib/tools/$(am__dirstamp) +contrib/tools/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) contrib/tools/$(DEPDIR) + @: > contrib/tools/$(DEPDIR)/$(am__dirstamp) +contrib/tools/png-fix-itxt.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +png-fix-itxt$(EXEEXT): $(png_fix_itxt_OBJECTS) $(png_fix_itxt_DEPENDENCIES) $(EXTRA_png_fix_itxt_DEPENDENCIES) + @rm -f png-fix-itxt$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(png_fix_itxt_OBJECTS) $(png_fix_itxt_LDADD) $(LIBS) +contrib/tools/pngcp.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +pngcp$(EXEEXT): $(pngcp_OBJECTS) $(pngcp_DEPENDENCIES) $(EXTRA_pngcp_DEPENDENCIES) + @rm -f pngcp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngcp_OBJECTS) $(pngcp_LDADD) $(LIBS) +contrib/tools/pngfix.$(OBJEXT): contrib/tools/$(am__dirstamp) \ + contrib/tools/$(DEPDIR)/$(am__dirstamp) + +pngfix$(EXEEXT): $(pngfix_OBJECTS) $(pngfix_DEPENDENCIES) $(EXTRA_pngfix_DEPENDENCIES) + @rm -f pngfix$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngfix_OBJECTS) $(pngfix_LDADD) $(LIBS) +contrib/libtests/$(am__dirstamp): + @$(MKDIR_P) contrib/libtests + @: > contrib/libtests/$(am__dirstamp) +contrib/libtests/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) contrib/libtests/$(DEPDIR) + @: > contrib/libtests/$(DEPDIR)/$(am__dirstamp) +contrib/libtests/pngimage.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngimage$(EXEEXT): $(pngimage_OBJECTS) $(pngimage_DEPENDENCIES) $(EXTRA_pngimage_DEPENDENCIES) + @rm -f pngimage$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngimage_OBJECTS) $(pngimage_LDADD) $(LIBS) +contrib/libtests/pngstest.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngstest$(EXEEXT): $(pngstest_OBJECTS) $(pngstest_DEPENDENCIES) $(EXTRA_pngstest_DEPENDENCIES) + @rm -f pngstest$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngstest_OBJECTS) $(pngstest_LDADD) $(LIBS) + +pngtest$(EXEEXT): $(pngtest_OBJECTS) $(pngtest_DEPENDENCIES) $(EXTRA_pngtest_DEPENDENCIES) @rm -f pngtest$(EXEEXT) - $(LINK) $(pngtest_OBJECTS) $(pngtest_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(pngtest_OBJECTS) $(pngtest_LDADD) $(LIBS) +contrib/libtests/pngunknown.$(OBJEXT): \ + contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngunknown$(EXEEXT): $(pngunknown_OBJECTS) $(pngunknown_DEPENDENCIES) $(EXTRA_pngunknown_DEPENDENCIES) + @rm -f pngunknown$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngunknown_OBJECTS) $(pngunknown_LDADD) $(LIBS) +contrib/libtests/pngvalid.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +pngvalid$(EXEEXT): $(pngvalid_OBJECTS) $(pngvalid_DEPENDENCIES) $(EXTRA_pngvalid_DEPENDENCIES) + @rm -f pngvalid$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(pngvalid_OBJECTS) $(pngvalid_LDADD) $(LIBS) +contrib/libtests/timepng.$(OBJEXT): contrib/libtests/$(am__dirstamp) \ + contrib/libtests/$(DEPDIR)/$(am__dirstamp) + +timepng$(EXEEXT): $(timepng_OBJECTS) $(timepng_DEPENDENCIES) $(EXTRA_timepng_DEPENDENCIES) + @rm -f timepng$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(timepng_OBJECTS) $(timepng_LDADD) $(LIBS) install-binSCRIPTS: $(bin_SCRIPTS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ @@ -500,294 +1109,139 @@ uninstall-binSCRIPTS: @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(bindir)" && rm -f $$files + dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) mostlyclean-compile: -rm -f *.$(OBJEXT) + -rm -f arm/*.$(OBJEXT) + -rm -f arm/*.lo + -rm -f contrib/libtests/*.$(OBJEXT) + -rm -f contrib/tools/*.$(OBJEXT) + -rm -f intel/*.$(OBJEXT) + -rm -f intel/*.lo + -rm -f mips/*.$(OBJEXT) + -rm -f mips/*.lo + -rm -f powerpc/*.$(OBJEXT) + -rm -f powerpc/*.lo distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-png.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngerror.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngget.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngmem.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngpread.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngread.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngrio.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngrtran.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngrutil.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngset.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngtrans.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngwio.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngwrite.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngwtran.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng12_la-pngwutil.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-png.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngerror.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngget.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngmem.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngpread.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngread.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngrio.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngrtran.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngrutil.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngset.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngtrans.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngwio.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngwrite.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngwtran.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpng_la-pngwutil.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngtest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/png.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngerror.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngget.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngmem.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngpread.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngread.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngrio.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngrtran.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngrutil.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngset.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngtest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngtrans.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwio.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwrite.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwtran.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pngwutil.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/arm_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/filter_neon_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@arm/$(DEPDIR)/palette_neon_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngimage.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngstest.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngunknown.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/pngvalid.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/libtests/$(DEPDIR)/timepng.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/png-fix-itxt.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/pngcp.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@contrib/tools/$(DEPDIR)/pngfix.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@intel/$(DEPDIR)/filter_sse2_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@intel/$(DEPDIR)/intel_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/filter_msa_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/mips_init.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/powerpc_init.Plo@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.S.o: +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ $< + +.S.obj: +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCCAS_TRUE@ $(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.S.lo: +@am__fastdepCCAS_TRUE@ $(AM_V_CPPAS)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCCAS_TRUE@ $(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCCAS_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCCAS_FALSE@ DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCCAS_FALSE@ $(AM_V_CPPAS@am__nodep@)$(LTCPPASCOMPILE) -c -o $@ $< .c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -libpng_la-png.lo: png.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-png.lo -MD -MP -MF $(DEPDIR)/libpng_la-png.Tpo -c -o libpng_la-png.lo `test -f 'png.c' || echo '$(srcdir)/'`png.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-png.Tpo $(DEPDIR)/libpng_la-png.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='png.c' object='libpng_la-png.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-png.lo `test -f 'png.c' || echo '$(srcdir)/'`png.c - -libpng_la-pngset.lo: pngset.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngset.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngset.Tpo -c -o libpng_la-pngset.lo `test -f 'pngset.c' || echo '$(srcdir)/'`pngset.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngset.Tpo $(DEPDIR)/libpng_la-pngset.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngset.c' object='libpng_la-pngset.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngset.lo `test -f 'pngset.c' || echo '$(srcdir)/'`pngset.c - -libpng_la-pngget.lo: pngget.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngget.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngget.Tpo -c -o libpng_la-pngget.lo `test -f 'pngget.c' || echo '$(srcdir)/'`pngget.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngget.Tpo $(DEPDIR)/libpng_la-pngget.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngget.c' object='libpng_la-pngget.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngget.lo `test -f 'pngget.c' || echo '$(srcdir)/'`pngget.c - -libpng_la-pngrutil.lo: pngrutil.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngrutil.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngrutil.Tpo -c -o libpng_la-pngrutil.lo `test -f 'pngrutil.c' || echo '$(srcdir)/'`pngrutil.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngrutil.Tpo $(DEPDIR)/libpng_la-pngrutil.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngrutil.c' object='libpng_la-pngrutil.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngrutil.lo `test -f 'pngrutil.c' || echo '$(srcdir)/'`pngrutil.c - -libpng_la-pngtrans.lo: pngtrans.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngtrans.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngtrans.Tpo -c -o libpng_la-pngtrans.lo `test -f 'pngtrans.c' || echo '$(srcdir)/'`pngtrans.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngtrans.Tpo $(DEPDIR)/libpng_la-pngtrans.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngtrans.c' object='libpng_la-pngtrans.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngtrans.lo `test -f 'pngtrans.c' || echo '$(srcdir)/'`pngtrans.c - -libpng_la-pngwutil.lo: pngwutil.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngwutil.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngwutil.Tpo -c -o libpng_la-pngwutil.lo `test -f 'pngwutil.c' || echo '$(srcdir)/'`pngwutil.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngwutil.Tpo $(DEPDIR)/libpng_la-pngwutil.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwutil.c' object='libpng_la-pngwutil.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngwutil.lo `test -f 'pngwutil.c' || echo '$(srcdir)/'`pngwutil.c - -libpng_la-pngread.lo: pngread.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngread.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngread.Tpo -c -o libpng_la-pngread.lo `test -f 'pngread.c' || echo '$(srcdir)/'`pngread.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngread.Tpo $(DEPDIR)/libpng_la-pngread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngread.c' object='libpng_la-pngread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngread.lo `test -f 'pngread.c' || echo '$(srcdir)/'`pngread.c - -libpng_la-pngrio.lo: pngrio.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngrio.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngrio.Tpo -c -o libpng_la-pngrio.lo `test -f 'pngrio.c' || echo '$(srcdir)/'`pngrio.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngrio.Tpo $(DEPDIR)/libpng_la-pngrio.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngrio.c' object='libpng_la-pngrio.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngrio.lo `test -f 'pngrio.c' || echo '$(srcdir)/'`pngrio.c - -libpng_la-pngwio.lo: pngwio.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngwio.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngwio.Tpo -c -o libpng_la-pngwio.lo `test -f 'pngwio.c' || echo '$(srcdir)/'`pngwio.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngwio.Tpo $(DEPDIR)/libpng_la-pngwio.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwio.c' object='libpng_la-pngwio.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngwio.lo `test -f 'pngwio.c' || echo '$(srcdir)/'`pngwio.c - -libpng_la-pngwrite.lo: pngwrite.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngwrite.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngwrite.Tpo -c -o libpng_la-pngwrite.lo `test -f 'pngwrite.c' || echo '$(srcdir)/'`pngwrite.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngwrite.Tpo $(DEPDIR)/libpng_la-pngwrite.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwrite.c' object='libpng_la-pngwrite.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngwrite.lo `test -f 'pngwrite.c' || echo '$(srcdir)/'`pngwrite.c - -libpng_la-pngrtran.lo: pngrtran.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngrtran.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngrtran.Tpo -c -o libpng_la-pngrtran.lo `test -f 'pngrtran.c' || echo '$(srcdir)/'`pngrtran.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngrtran.Tpo $(DEPDIR)/libpng_la-pngrtran.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngrtran.c' object='libpng_la-pngrtran.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngrtran.lo `test -f 'pngrtran.c' || echo '$(srcdir)/'`pngrtran.c - -libpng_la-pngwtran.lo: pngwtran.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngwtran.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngwtran.Tpo -c -o libpng_la-pngwtran.lo `test -f 'pngwtran.c' || echo '$(srcdir)/'`pngwtran.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngwtran.Tpo $(DEPDIR)/libpng_la-pngwtran.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwtran.c' object='libpng_la-pngwtran.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngwtran.lo `test -f 'pngwtran.c' || echo '$(srcdir)/'`pngwtran.c - -libpng_la-pngmem.lo: pngmem.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngmem.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngmem.Tpo -c -o libpng_la-pngmem.lo `test -f 'pngmem.c' || echo '$(srcdir)/'`pngmem.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngmem.Tpo $(DEPDIR)/libpng_la-pngmem.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngmem.c' object='libpng_la-pngmem.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngmem.lo `test -f 'pngmem.c' || echo '$(srcdir)/'`pngmem.c - -libpng_la-pngerror.lo: pngerror.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngerror.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngerror.Tpo -c -o libpng_la-pngerror.lo `test -f 'pngerror.c' || echo '$(srcdir)/'`pngerror.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngerror.Tpo $(DEPDIR)/libpng_la-pngerror.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngerror.c' object='libpng_la-pngerror.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngerror.lo `test -f 'pngerror.c' || echo '$(srcdir)/'`pngerror.c - -libpng_la-pngpread.lo: pngpread.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng_la-pngpread.lo -MD -MP -MF $(DEPDIR)/libpng_la-pngpread.Tpo -c -o libpng_la-pngpread.lo `test -f 'pngpread.c' || echo '$(srcdir)/'`pngpread.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng_la-pngpread.Tpo $(DEPDIR)/libpng_la-pngpread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngpread.c' object='libpng_la-pngpread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng_la-pngpread.lo `test -f 'pngpread.c' || echo '$(srcdir)/'`pngpread.c - -libpng12_la-png.lo: png.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-png.lo -MD -MP -MF $(DEPDIR)/libpng12_la-png.Tpo -c -o libpng12_la-png.lo `test -f 'png.c' || echo '$(srcdir)/'`png.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-png.Tpo $(DEPDIR)/libpng12_la-png.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='png.c' object='libpng12_la-png.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-png.lo `test -f 'png.c' || echo '$(srcdir)/'`png.c - -libpng12_la-pngset.lo: pngset.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngset.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngset.Tpo -c -o libpng12_la-pngset.lo `test -f 'pngset.c' || echo '$(srcdir)/'`pngset.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngset.Tpo $(DEPDIR)/libpng12_la-pngset.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngset.c' object='libpng12_la-pngset.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngset.lo `test -f 'pngset.c' || echo '$(srcdir)/'`pngset.c - -libpng12_la-pngget.lo: pngget.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngget.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngget.Tpo -c -o libpng12_la-pngget.lo `test -f 'pngget.c' || echo '$(srcdir)/'`pngget.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngget.Tpo $(DEPDIR)/libpng12_la-pngget.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngget.c' object='libpng12_la-pngget.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngget.lo `test -f 'pngget.c' || echo '$(srcdir)/'`pngget.c - -libpng12_la-pngrutil.lo: pngrutil.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngrutil.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngrutil.Tpo -c -o libpng12_la-pngrutil.lo `test -f 'pngrutil.c' || echo '$(srcdir)/'`pngrutil.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngrutil.Tpo $(DEPDIR)/libpng12_la-pngrutil.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngrutil.c' object='libpng12_la-pngrutil.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngrutil.lo `test -f 'pngrutil.c' || echo '$(srcdir)/'`pngrutil.c - -libpng12_la-pngtrans.lo: pngtrans.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngtrans.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngtrans.Tpo -c -o libpng12_la-pngtrans.lo `test -f 'pngtrans.c' || echo '$(srcdir)/'`pngtrans.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngtrans.Tpo $(DEPDIR)/libpng12_la-pngtrans.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngtrans.c' object='libpng12_la-pngtrans.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngtrans.lo `test -f 'pngtrans.c' || echo '$(srcdir)/'`pngtrans.c - -libpng12_la-pngwutil.lo: pngwutil.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngwutil.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngwutil.Tpo -c -o libpng12_la-pngwutil.lo `test -f 'pngwutil.c' || echo '$(srcdir)/'`pngwutil.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngwutil.Tpo $(DEPDIR)/libpng12_la-pngwutil.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwutil.c' object='libpng12_la-pngwutil.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngwutil.lo `test -f 'pngwutil.c' || echo '$(srcdir)/'`pngwutil.c - -libpng12_la-pngread.lo: pngread.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngread.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngread.Tpo -c -o libpng12_la-pngread.lo `test -f 'pngread.c' || echo '$(srcdir)/'`pngread.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngread.Tpo $(DEPDIR)/libpng12_la-pngread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngread.c' object='libpng12_la-pngread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngread.lo `test -f 'pngread.c' || echo '$(srcdir)/'`pngread.c - -libpng12_la-pngrio.lo: pngrio.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngrio.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngrio.Tpo -c -o libpng12_la-pngrio.lo `test -f 'pngrio.c' || echo '$(srcdir)/'`pngrio.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngrio.Tpo $(DEPDIR)/libpng12_la-pngrio.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngrio.c' object='libpng12_la-pngrio.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngrio.lo `test -f 'pngrio.c' || echo '$(srcdir)/'`pngrio.c - -libpng12_la-pngwio.lo: pngwio.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngwio.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngwio.Tpo -c -o libpng12_la-pngwio.lo `test -f 'pngwio.c' || echo '$(srcdir)/'`pngwio.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngwio.Tpo $(DEPDIR)/libpng12_la-pngwio.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwio.c' object='libpng12_la-pngwio.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngwio.lo `test -f 'pngwio.c' || echo '$(srcdir)/'`pngwio.c - -libpng12_la-pngwrite.lo: pngwrite.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngwrite.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngwrite.Tpo -c -o libpng12_la-pngwrite.lo `test -f 'pngwrite.c' || echo '$(srcdir)/'`pngwrite.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngwrite.Tpo $(DEPDIR)/libpng12_la-pngwrite.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwrite.c' object='libpng12_la-pngwrite.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngwrite.lo `test -f 'pngwrite.c' || echo '$(srcdir)/'`pngwrite.c - -libpng12_la-pngrtran.lo: pngrtran.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngrtran.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngrtran.Tpo -c -o libpng12_la-pngrtran.lo `test -f 'pngrtran.c' || echo '$(srcdir)/'`pngrtran.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngrtran.Tpo $(DEPDIR)/libpng12_la-pngrtran.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngrtran.c' object='libpng12_la-pngrtran.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngrtran.lo `test -f 'pngrtran.c' || echo '$(srcdir)/'`pngrtran.c - -libpng12_la-pngwtran.lo: pngwtran.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngwtran.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngwtran.Tpo -c -o libpng12_la-pngwtran.lo `test -f 'pngwtran.c' || echo '$(srcdir)/'`pngwtran.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngwtran.Tpo $(DEPDIR)/libpng12_la-pngwtran.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngwtran.c' object='libpng12_la-pngwtran.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngwtran.lo `test -f 'pngwtran.c' || echo '$(srcdir)/'`pngwtran.c - -libpng12_la-pngmem.lo: pngmem.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngmem.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngmem.Tpo -c -o libpng12_la-pngmem.lo `test -f 'pngmem.c' || echo '$(srcdir)/'`pngmem.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngmem.Tpo $(DEPDIR)/libpng12_la-pngmem.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngmem.c' object='libpng12_la-pngmem.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngmem.lo `test -f 'pngmem.c' || echo '$(srcdir)/'`pngmem.c - -libpng12_la-pngerror.lo: pngerror.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngerror.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngerror.Tpo -c -o libpng12_la-pngerror.lo `test -f 'pngerror.c' || echo '$(srcdir)/'`pngerror.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngerror.Tpo $(DEPDIR)/libpng12_la-pngerror.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngerror.c' object='libpng12_la-pngerror.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngerror.lo `test -f 'pngerror.c' || echo '$(srcdir)/'`pngerror.c - -libpng12_la-pngpread.lo: pngpread.c -@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libpng12_la-pngpread.lo -MD -MP -MF $(DEPDIR)/libpng12_la-pngpread.Tpo -c -o libpng12_la-pngpread.lo `test -f 'pngpread.c' || echo '$(srcdir)/'`pngpread.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpng12_la-pngpread.Tpo $(DEPDIR)/libpng12_la-pngpread.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pngpread.c' object='libpng12_la-pngpread.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libpng12_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libpng12_la-pngpread.lo `test -f 'pngpread.c' || echo '$(srcdir)/'`pngpread.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs + -rm -rf arm/.libs arm/_libs + -rm -rf intel/.libs intel/_libs + -rm -rf mips/.libs mips/_libs + -rm -rf powerpc/.libs powerpc/_libs distclean-libtool: -rm -f libtool config.lt install-man3: $(dist_man_MANS) @$(NORMAL_INSTALL) - test -z "$(man3dir)" || $(MKDIR_P) "$(DESTDIR)$(man3dir)" - @list=''; test -n "$(man3dir)" || exit 0; \ - { for i in $$list; do echo "$$i"; done; \ - l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.3[a-z]*$$/p'; \ + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man3dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man3dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man3dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.3[a-z]*$$/p'; \ + fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -816,16 +1270,21 @@ uninstall-man3: sed -n '/\.3[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - test -z "$$files" || { \ - echo " ( cd '$(DESTDIR)$(man3dir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(man3dir)" && rm -f $$files; } + dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir) install-man5: $(dist_man_MANS) @$(NORMAL_INSTALL) - test -z "$(man5dir)" || $(MKDIR_P) "$(DESTDIR)$(man5dir)" - @list=''; test -n "$(man5dir)" || exit 0; \ - { for i in $$list; do echo "$$i"; done; \ - l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.5[a-z]*$$/p'; \ + @list1=''; \ + list2='$(dist_man_MANS)'; \ + test -n "$(man5dir)" \ + && test -n "`echo $$list1$$list2`" \ + || exit 0; \ + echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ + { for i in $$list1; do echo "$$i"; done; \ + if test -n "$$list2"; then \ + for i in $$list2; do echo "$$i"; done \ + | sed -n '/\.5[a-z]*$$/p'; \ + fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ @@ -854,13 +1313,14 @@ uninstall-man5: sed -n '/\.5[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - test -z "$$files" || { \ - echo " ( cd '$(DESTDIR)$(man5dir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(man5dir)" && rm -f $$files; } + dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) install-pkgconfigDATA: $(pkgconfig_DATA) @$(NORMAL_INSTALL) - test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -874,13 +1334,35 @@ uninstall-pkgconfigDATA: @$(NORMAL_UNINSTALL) @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files + dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir) +install-nodist_pkgincludeHEADERS: $(nodist_pkginclude_HEADERS) + @$(NORMAL_INSTALL) + @list='$(nodist_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(pkgincludedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(pkgincludedir)" || exit $$?; \ + done + +uninstall-nodist_pkgincludeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(nodist_pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) install-pkgincludeHEADERS: $(pkginclude_HEADERS) @$(NORMAL_INSTALL) - test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(pkgincludedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)" || exit 1; \ + fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ @@ -894,30 +1376,17 @@ uninstall-pkgincludeHEADERS: @$(NORMAL_UNINSTALL) @list='$(pkginclude_HEADERS)'; test -n "$(pkgincludedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(pkgincludedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(pkgincludedir)" && rm -f $$files + dir='$(DESTDIR)$(pkgincludedir)'; $(am__uninstall_files_from_dir) -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags -TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ - list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ + $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ @@ -929,15 +1398,11 @@ TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $$unique; \ fi; \ fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique @@ -946,116 +1411,423 @@ GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" +cscope: cscope.files + test ! -s cscope.files \ + || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) +clean-cscope: + -rm -f cscope.files +cscope.files: clean-cscope cscopelist +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + -rm -f cscope.out cscope.in.out cscope.po.out cscope.files -check-TESTS: $(TESTS) - @failed=0; all=0; xfail=0; xpass=0; skip=0; \ - srcdir=$(srcdir); export srcdir; \ - list=' $(TESTS) '; \ - $(am__tty_colors); \ - if test -n "$$list"; then \ - for tst in $$list; do \ - if test -f ./$$tst; then dir=./; \ - elif test -f $$tst; then dir=; \ - else dir="$(srcdir)/"; fi; \ - if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xpass=`expr $$xpass + 1`; \ - failed=`expr $$failed + 1`; \ - col=$$red; res=XPASS; \ - ;; \ - *) \ - col=$$grn; res=PASS; \ - ;; \ - esac; \ - elif test $$? -ne 77; then \ - all=`expr $$all + 1`; \ - case " $(XFAIL_TESTS) " in \ - *[\ \ ]$$tst[\ \ ]*) \ - xfail=`expr $$xfail + 1`; \ - col=$$lgn; res=XFAIL; \ - ;; \ - *) \ - failed=`expr $$failed + 1`; \ - col=$$red; res=FAIL; \ - ;; \ - esac; \ - else \ - skip=`expr $$skip + 1`; \ - col=$$blu; res=SKIP; \ - fi; \ - echo "$${col}$$res$${std}: $$tst"; \ +# Recover from deleted '.trs' file; this should ensure that +# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create +# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells +# to avoid problems with "make -n". +.log.trs: + rm -f $< $@ + $(MAKE) $(AM_MAKEFLAGS) $< + +# Leading 'am--fnord' is there to ensure the list of targets does not +# expand to empty, as could happen e.g. with make check TESTS=''. +am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) +am--force-recheck: + @: + +$(TEST_SUITE_LOG): $(TEST_LOGS) + @$(am__set_TESTS_bases); \ + am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ + redo_bases=`for i in $$bases; do \ + am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ + done`; \ + if test -n "$$redo_bases"; then \ + redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ + redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ + if $(am__make_dryrun); then :; else \ + rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ + fi; \ + fi; \ + if test -n "$$am__remaking_logs"; then \ + echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ + "recursion detected" >&2; \ + elif test -n "$$redo_logs"; then \ + am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ + fi; \ + if $(am__make_dryrun); then :; else \ + st=0; \ + errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ + for i in $$redo_bases; do \ + test -f $$i.trs && test -r $$i.trs \ + || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ + test -f $$i.log && test -r $$i.log \ + || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ - if test "$$all" -eq 1; then \ - tests="test"; \ - All=""; \ - else \ - tests="tests"; \ - All="All "; \ - fi; \ - if test "$$failed" -eq 0; then \ - if test "$$xfail" -eq 0; then \ - banner="$$All$$all $$tests passed"; \ + test $$st -eq 0 || exit 1; \ + fi + @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ + ws='[ ]'; \ + results=`for b in $$bases; do echo $$b.trs; done`; \ + test -n "$$results" || results=/dev/null; \ + all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ + pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ + fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ + skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ + xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ + xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ + error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ + if test `expr $$fail + $$xpass + $$error` -eq 0; then \ + success=true; \ + else \ + success=false; \ + fi; \ + br='==================='; br=$$br$$br$$br$$br; \ + result_count () \ + { \ + if test x"$$1" = x"--maybe-color"; then \ + maybe_colorize=yes; \ + elif test x"$$1" = x"--no-color"; then \ + maybe_colorize=no; \ else \ - if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ - banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ - else \ - if test "$$xpass" -eq 0; then \ - banner="$$failed of $$all $$tests failed"; \ + shift; \ + desc=$$1 count=$$2; \ + if test $$maybe_colorize = yes && test $$count -gt 0; then \ + color_start=$$3 color_end=$$std; \ else \ - if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ - banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + color_start= color_end=; \ fi; \ - fi; \ - dashes="$$banner"; \ - skipped=""; \ - if test "$$skip" -ne 0; then \ - if test "$$skip" -eq 1; then \ - skipped="($$skip test was not run)"; \ - else \ - skipped="($$skip tests were not run)"; \ - fi; \ - test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$skipped"; \ - fi; \ - report=""; \ - if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ - report="Please report to $(PACKAGE_BUGREPORT)"; \ - test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ - dashes="$$report"; \ - fi; \ - dashes=`echo "$$dashes" | sed s/./=/g`; \ - if test "$$failed" -eq 0; then \ - echo "$$grn$$dashes"; \ - else \ - echo "$$red$$dashes"; \ - fi; \ - echo "$$banner"; \ - test -z "$$skipped" || echo "$$skipped"; \ - test -z "$$report" || echo "$$report"; \ - echo "$$dashes$$std"; \ - test "$$failed" -eq 0; \ - else :; fi + echo "$${color_start}# $$desc $$count$${color_end}"; \ + }; \ + create_testsuite_report () \ + { \ + result_count $$1 "TOTAL:" $$all "$$brg"; \ + result_count $$1 "PASS: " $$pass "$$grn"; \ + result_count $$1 "SKIP: " $$skip "$$blu"; \ + result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ + result_count $$1 "FAIL: " $$fail "$$red"; \ + result_count $$1 "XPASS:" $$xpass "$$red"; \ + result_count $$1 "ERROR:" $$error "$$mgn"; \ + }; \ + { \ + echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ + $(am__rst_title); \ + create_testsuite_report --no-color; \ + echo; \ + echo ".. contents:: :depth: 2"; \ + echo; \ + for b in $$bases; do echo $$b; done \ + | $(am__create_global_log); \ + } >$(TEST_SUITE_LOG).tmp || exit 1; \ + mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ + if $$success; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ + fi; \ + echo "$${col}$$br$${std}"; \ + echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ + echo "$${col}$$br$${std}"; \ + create_testsuite_report --maybe-color; \ + echo "$$col$$br$$std"; \ + if $$success; then :; else \ + echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ + if test -n "$(PACKAGE_BUGREPORT)"; then \ + echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ + fi; \ + echo "$$col$$br$$std"; \ + fi; \ + $$success || exit 1 -distdir: $(DISTFILES) - @list='$(MANS)'; if test -n "$$list"; then \ - list=`for p in $$list; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ - if test -n "$$list" && \ - grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ - echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ - grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ - echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ - echo " typically \`make maintainer-clean' will remove them" >&2; \ - exit 1; \ - else :; fi; \ - else :; fi +check-TESTS: $(check_PROGRAMS) + @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list + @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + trs_list=`for i in $$bases; do echo $$i.trs; done`; \ + log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ + exit $$?; +recheck: all $(check_PROGRAMS) + @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) + @set +e; $(am__set_TESTS_bases); \ + bases=`for i in $$bases; do echo $$i; done \ + | $(am__list_recheck_tests)` || exit 1; \ + log_list=`for i in $$bases; do echo $$i.log; done`; \ + log_list=`echo $$log_list`; \ + $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ + am__force_recheck=am--force-recheck \ + TEST_LOGS="$$log_list"; \ + exit $$? +tests/pngtest.log: tests/pngtest + @p='tests/pngtest'; \ + b='tests/pngtest'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngtest-badpngs.log: tests/pngtest-badpngs + @p='tests/pngtest-badpngs'; \ + b='tests/pngtest-badpngs'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-16-to-8.log: tests/pngvalid-gamma-16-to-8 + @p='tests/pngvalid-gamma-16-to-8'; \ + b='tests/pngvalid-gamma-16-to-8'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-alpha-mode.log: tests/pngvalid-gamma-alpha-mode + @p='tests/pngvalid-gamma-alpha-mode'; \ + b='tests/pngvalid-gamma-alpha-mode'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-background.log: tests/pngvalid-gamma-background + @p='tests/pngvalid-gamma-background'; \ + b='tests/pngvalid-gamma-background'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-alpha-mode.log: tests/pngvalid-gamma-expand16-alpha-mode + @p='tests/pngvalid-gamma-expand16-alpha-mode'; \ + b='tests/pngvalid-gamma-expand16-alpha-mode'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-background.log: tests/pngvalid-gamma-expand16-background + @p='tests/pngvalid-gamma-expand16-background'; \ + b='tests/pngvalid-gamma-expand16-background'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-expand16-transform.log: tests/pngvalid-gamma-expand16-transform + @p='tests/pngvalid-gamma-expand16-transform'; \ + b='tests/pngvalid-gamma-expand16-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-sbit.log: tests/pngvalid-gamma-sbit + @p='tests/pngvalid-gamma-sbit'; \ + b='tests/pngvalid-gamma-sbit'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-threshold.log: tests/pngvalid-gamma-threshold + @p='tests/pngvalid-gamma-threshold'; \ + b='tests/pngvalid-gamma-threshold'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-gamma-transform.log: tests/pngvalid-gamma-transform + @p='tests/pngvalid-gamma-transform'; \ + b='tests/pngvalid-gamma-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-size.log: tests/pngvalid-progressive-size + @p='tests/pngvalid-progressive-size'; \ + b='tests/pngvalid-progressive-size'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-interlace-standard.log: tests/pngvalid-progressive-interlace-standard + @p='tests/pngvalid-progressive-interlace-standard'; \ + b='tests/pngvalid-progressive-interlace-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-transform.log: tests/pngvalid-transform + @p='tests/pngvalid-transform'; \ + b='tests/pngvalid-transform'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-progressive-standard.log: tests/pngvalid-progressive-standard + @p='tests/pngvalid-progressive-standard'; \ + b='tests/pngvalid-progressive-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngvalid-standard.log: tests/pngvalid-standard + @p='tests/pngvalid-standard'; \ + b='tests/pngvalid-standard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-1.8.log: tests/pngstest-1.8 + @p='tests/pngstest-1.8'; \ + b='tests/pngstest-1.8'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-1.8-alpha.log: tests/pngstest-1.8-alpha + @p='tests/pngstest-1.8-alpha'; \ + b='tests/pngstest-1.8-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-linear.log: tests/pngstest-linear + @p='tests/pngstest-linear'; \ + b='tests/pngstest-linear'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-linear-alpha.log: tests/pngstest-linear-alpha + @p='tests/pngstest-linear-alpha'; \ + b='tests/pngstest-linear-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-none.log: tests/pngstest-none + @p='tests/pngstest-none'; \ + b='tests/pngstest-none'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-none-alpha.log: tests/pngstest-none-alpha + @p='tests/pngstest-none-alpha'; \ + b='tests/pngstest-none-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-sRGB.log: tests/pngstest-sRGB + @p='tests/pngstest-sRGB'; \ + b='tests/pngstest-sRGB'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngstest-sRGB-alpha.log: tests/pngstest-sRGB-alpha + @p='tests/pngstest-sRGB-alpha'; \ + b='tests/pngstest-sRGB-alpha'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-IDAT.log: tests/pngunknown-IDAT + @p='tests/pngunknown-IDAT'; \ + b='tests/pngunknown-IDAT'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-discard.log: tests/pngunknown-discard + @p='tests/pngunknown-discard'; \ + b='tests/pngunknown-discard'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-if-safe.log: tests/pngunknown-if-safe + @p='tests/pngunknown-if-safe'; \ + b='tests/pngunknown-if-safe'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-sAPI.log: tests/pngunknown-sAPI + @p='tests/pngunknown-sAPI'; \ + b='tests/pngunknown-sAPI'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-sTER.log: tests/pngunknown-sTER + @p='tests/pngunknown-sTER'; \ + b='tests/pngunknown-sTER'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-save.log: tests/pngunknown-save + @p='tests/pngunknown-save'; \ + b='tests/pngunknown-save'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngunknown-vpAg.log: tests/pngunknown-vpAg + @p='tests/pngunknown-vpAg'; \ + b='tests/pngunknown-vpAg'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngimage-quick.log: tests/pngimage-quick + @p='tests/pngimage-quick'; \ + b='tests/pngimage-quick'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +tests/pngimage-full.log: tests/pngimage-full + @p='tests/pngimage-full'; \ + b='tests/pngimage-full'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +.test.log: + @p='$<'; \ + $(am__set_b); \ + $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) +@am__EXEEXT_TRUE@.test$(EXEEXT).log: +@am__EXEEXT_TRUE@ @p='$<'; \ +@am__EXEEXT_TRUE@ $(am__set_b); \ +@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ +@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ +@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ +@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ @@ -1087,44 +1859,53 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook -test -n "$(am__skip_mode_fix)" \ - || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) + tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz + $(am__post_remove_distdir) dist-bzip2: distdir - tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 - $(am__remove_distdir) - -dist-lzma: distdir - tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma - $(am__remove_distdir) + tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 + $(am__post_remove_distdir) +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__post_remove_distdir) dist-xz: distdir - tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz - $(am__remove_distdir) + tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz + $(am__post_remove_distdir) dist-tarZ: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z - $(am__remove_distdir) + $(am__post_remove_distdir) dist-shar: distdir - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz - $(am__remove_distdir) + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 + shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz + $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) - $(am__remove_distdir) + $(am__post_remove_distdir) -dist dist-all: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz - $(am__remove_distdir) +dist dist-all: + $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' + $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another @@ -1132,31 +1913,33 @@ dist dist-all: distdir distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ - bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ - *.tar.lzma*) \ - unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir); chmod a+w $(distdir) - mkdir $(distdir)/_build - mkdir $(distdir)/_inst + chmod -R a-w $(distdir) + chmod u+w $(distdir) + mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ - && $(am__cd) $(distdir)/_build \ - && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + && $(am__cd) $(distdir)/_build/sub \ + && ../../configure \ + $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ + --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ @@ -1179,13 +1962,21 @@ distcheck: dist && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 - $(am__remove_distdir) + $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: - @$(am__cd) '$(distuninstallcheck_dir)' \ - && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + @test -n '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: trying to run $@ with an empty' \ + '$$(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + $(am__cd) '$(distuninstallcheck_dir)' || { \ + echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ + exit 1; \ + }; \ + test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ @@ -1204,14 +1995,18 @@ distcleancheck: distclean check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS -check: check-am -all-am: Makefile $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) $(HEADERS) \ - config.h +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) \ + $(HEADERS) config.h +install-binPROGRAMS: install-libLTLIBRARIES + installdirs: - for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(pkgincludedir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done -install: install-am +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am @@ -1221,11 +2016,19 @@ install-am: all-am installcheck: installcheck-am install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi mostlyclean-generic: + -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) + -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) + -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) @@ -1233,19 +2036,68 @@ clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -rm -f arm/$(DEPDIR)/$(am__dirstamp) + -rm -f arm/$(am__dirstamp) + -rm -f contrib/libtests/$(DEPDIR)/$(am__dirstamp) + -rm -f contrib/libtests/$(am__dirstamp) + -rm -f contrib/tools/$(DEPDIR)/$(am__dirstamp) + -rm -f contrib/tools/$(am__dirstamp) + -rm -f intel/$(DEPDIR)/$(am__dirstamp) + -rm -f intel/$(am__dirstamp) + -rm -f mips/$(DEPDIR)/$(am__dirstamp) + -rm -f mips/$(am__dirstamp) + -rm -f powerpc/$(DEPDIR)/$(am__dirstamp) + -rm -f powerpc/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +@DO_INSTALL_LIBPNG_CONFIG_FALSE@@DO_INSTALL_LINKS_FALSE@install-exec-hook: +@DO_INSTALL_LIBPNG_PC_FALSE@@DO_INSTALL_LINKS_FALSE@install-data-hook: +@DO_INSTALL_LIBPNG_CONFIG_FALSE@@DO_INSTALL_LIBPNG_PC_FALSE@@DO_INSTALL_LINKS_FALSE@uninstall-hook: clean: clean-am -clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ - clean-libtool mostlyclean-am +clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \ + clean-libLTLIBRARIES clean-libtool mostlyclean-am distclean: distclean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/pngerror.Plo + -rm -f ./$(DEPDIR)/pngget.Plo + -rm -f ./$(DEPDIR)/pngmem.Plo + -rm -f ./$(DEPDIR)/pngpread.Plo + -rm -f ./$(DEPDIR)/pngread.Plo + -rm -f ./$(DEPDIR)/pngrio.Plo + -rm -f ./$(DEPDIR)/pngrtran.Plo + -rm -f ./$(DEPDIR)/pngrutil.Plo + -rm -f ./$(DEPDIR)/pngset.Plo + -rm -f ./$(DEPDIR)/pngtest.Po + -rm -f ./$(DEPDIR)/pngtrans.Plo + -rm -f ./$(DEPDIR)/pngwio.Plo + -rm -f ./$(DEPDIR)/pngwrite.Plo + -rm -f ./$(DEPDIR)/pngwtran.Plo + -rm -f ./$(DEPDIR)/pngwutil.Plo + -rm -f arm/$(DEPDIR)/arm_init.Plo + -rm -f arm/$(DEPDIR)/filter_neon.Plo + -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo + -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo + -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po + -rm -f contrib/libtests/$(DEPDIR)/pngstest.Po + -rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po + -rm -f contrib/libtests/$(DEPDIR)/pngvalid.Po + -rm -f contrib/libtests/$(DEPDIR)/timepng.Po + -rm -f contrib/tools/$(DEPDIR)/png-fix-itxt.Po + -rm -f contrib/tools/$(DEPDIR)/pngcp.Po + -rm -f contrib/tools/$(DEPDIR)/pngfix.Po + -rm -f intel/$(DEPDIR)/filter_sse2_intrinsics.Plo + -rm -f intel/$(DEPDIR)/intel_init.Plo + -rm -f mips/$(DEPDIR)/filter_msa_intrinsics.Plo + -rm -f mips/$(DEPDIR)/mips_init.Plo + -rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo + -rm -f powerpc/$(DEPDIR)/powerpc_init.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -1262,15 +2114,16 @@ info: info-am info-am: -install-data-am: install-man install-pkgconfigDATA \ - install-pkgincludeHEADERS +install-data-am: install-man install-nodist_pkgincludeHEADERS \ + install-pkgconfigDATA install-pkgincludeHEADERS @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-am install-dvi-am: -install-exec-am: install-binSCRIPTS install-libLTLIBRARIES +install-exec-am: install-binPROGRAMS install-binSCRIPTS \ + install-libLTLIBRARIES @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-html: install-html-am @@ -1296,7 +2149,40 @@ installcheck-am: maintainer-clean: maintainer-clean-am -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache - -rm -rf ./$(DEPDIR) + -rm -f ./$(DEPDIR)/png.Plo + -rm -f ./$(DEPDIR)/pngerror.Plo + -rm -f ./$(DEPDIR)/pngget.Plo + -rm -f ./$(DEPDIR)/pngmem.Plo + -rm -f ./$(DEPDIR)/pngpread.Plo + -rm -f ./$(DEPDIR)/pngread.Plo + -rm -f ./$(DEPDIR)/pngrio.Plo + -rm -f ./$(DEPDIR)/pngrtran.Plo + -rm -f ./$(DEPDIR)/pngrutil.Plo + -rm -f ./$(DEPDIR)/pngset.Plo + -rm -f ./$(DEPDIR)/pngtest.Po + -rm -f ./$(DEPDIR)/pngtrans.Plo + -rm -f ./$(DEPDIR)/pngwio.Plo + -rm -f ./$(DEPDIR)/pngwrite.Plo + -rm -f ./$(DEPDIR)/pngwtran.Plo + -rm -f ./$(DEPDIR)/pngwutil.Plo + -rm -f arm/$(DEPDIR)/arm_init.Plo + -rm -f arm/$(DEPDIR)/filter_neon.Plo + -rm -f arm/$(DEPDIR)/filter_neon_intrinsics.Plo + -rm -f arm/$(DEPDIR)/palette_neon_intrinsics.Plo + -rm -f contrib/libtests/$(DEPDIR)/pngimage.Po + -rm -f contrib/libtests/$(DEPDIR)/pngstest.Po + -rm -f contrib/libtests/$(DEPDIR)/pngunknown.Po + -rm -f contrib/libtests/$(DEPDIR)/pngvalid.Po + -rm -f contrib/libtests/$(DEPDIR)/timepng.Po + -rm -f contrib/tools/$(DEPDIR)/png-fix-itxt.Po + -rm -f contrib/tools/$(DEPDIR)/pngcp.Po + -rm -f contrib/tools/$(DEPDIR)/pngfix.Po + -rm -f intel/$(DEPDIR)/filter_sse2_intrinsics.Plo + -rm -f intel/$(DEPDIR)/intel_init.Plo + -rm -f mips/$(DEPDIR)/filter_msa_intrinsics.Plo + -rm -f mips/$(DEPDIR)/mips_init.Plo + -rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo + -rm -f powerpc/$(DEPDIR)/powerpc_init.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1313,41 +2199,45 @@ ps: ps-am ps-am: -uninstall-am: uninstall-binSCRIPTS uninstall-libLTLIBRARIES \ - uninstall-man uninstall-pkgconfigDATA \ +uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \ + uninstall-libLTLIBRARIES uninstall-man \ + uninstall-nodist_pkgincludeHEADERS uninstall-pkgconfigDATA \ uninstall-pkgincludeHEADERS @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook uninstall-man: uninstall-man3 uninstall-man5 -.MAKE: all check-am install-am install-data-am install-exec-am \ - install-strip uninstall-am +.MAKE: all check check-am install install-am install-data-am \ + install-exec-am install-strip uninstall-am -.PHONY: CTAGS GTAGS all all-am am--refresh check check-TESTS check-am \ - clean clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ - clean-libtool ctags dist dist-all dist-bzip2 dist-gzip \ - dist-lzma dist-shar dist-tarZ dist-xz dist-zip distcheck \ +.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles am--refresh check \ + check-TESTS check-am clean clean-binPROGRAMS \ + clean-checkPROGRAMS clean-cscope clean-generic \ + clean-libLTLIBRARIES clean-libtool cscope cscopelist-am ctags \ + ctags-am dist dist-all dist-bzip2 dist-gzip dist-hook \ + dist-lzip dist-shar dist-tarZ dist-xz dist-zip distcheck \ distclean distclean-compile distclean-generic distclean-hdr \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ - install install-am install-binSCRIPTS install-data \ - install-data-am install-data-hook install-dvi install-dvi-am \ - install-exec install-exec-am install-exec-hook install-html \ - install-html-am install-info install-info-am \ + install install-am install-binPROGRAMS install-binSCRIPTS \ + install-data install-data-am install-data-hook install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-hook \ + install-html install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-man3 install-man5 \ - install-pdf install-pdf-am install-pkgconfigDATA \ - install-pkgincludeHEADERS install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ + install-nodist_pkgincludeHEADERS install-pdf install-pdf-am \ + install-pkgconfigDATA install-pkgincludeHEADERS install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \ + uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-binSCRIPTS uninstall-hook uninstall-libLTLIBRARIES \ uninstall-man uninstall-man3 uninstall-man5 \ - uninstall-pkgconfigDATA uninstall-pkgincludeHEADERS + uninstall-nodist_pkgincludeHEADERS uninstall-pkgconfigDATA \ + uninstall-pkgincludeHEADERS +.PRECIOUS: Makefile -@HAVE_LD_VERSION_SCRIPT_TRUE@ # Versioned symbols and restricted exports -@HAVE_LD_VERSION_SCRIPT_FALSE@ # Only restricted exports when possible $(PNGLIB_BASENAME).pc: libpng.pc cp libpng.pc $@ @@ -1355,56 +2245,183 @@ $(PNGLIB_BASENAME).pc: libpng.pc $(PNGLIB_BASENAME)-config: libpng-config cp libpng-config $@ -libpng.sym: png.h pngconf.h - rm -f $@ $@.new - $(CPP) @LIBPNG_DEFINES@ $(CPPFLAGS) -DPNG_BUILDSYMS $(srcdir)/png.h | \ - $(SED) -n -e \ - 's|^.*PNG_FUNCTION_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \ - -e 's|^.*PNG_DATA_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \ - >$@.new - mv $@.new $@ +scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h +scripts/prefix.out: png.h pngconf.h pnglibconf.out +scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt +scripts/intprefix.out: pnglibconf.h -libpng.vers: libpng.sym - rm -f $@ $@.new - echo PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0 '{global:' > $@.new - $(SED) s/$$/\;/ libpng.sym >> $@.new - echo 'local: *; };' >> $@.new - mv $@.new $@ +libpng.sym: scripts/sym.out + rm -f $@ + cp $? $@ +libpng.vers: scripts/vers.out + rm -f $@ + cp $? $@ -test: check +# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix. +# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual +# implementation of the macro). +@DO_PNG_PREFIX_TRUE@pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst +@DO_PNG_PREFIX_TRUE@ rm -f $@ +@DO_PNG_PREFIX_TRUE@ $(AWK) 's==0 && NR>1{print prev}\ +@DO_PNG_PREFIX_TRUE@ s==0{prev=$$0}\ +@DO_PNG_PREFIX_TRUE@ s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\ +@DO_PNG_PREFIX_TRUE@ s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\ +@DO_PNG_PREFIX_TRUE@ END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\ +@DO_PNG_PREFIX_TRUE@ s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8 +@DO_PNG_PREFIX_TRUE@ mv pnglibconf.tf8 $@ -# install the .../include headers as links to the new ones -install-data-hook: - cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h - cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h - cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h pngconf.h - cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc - cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc +@DO_PNG_PREFIX_TRUE@pngprefix.h: scripts/intprefix.out +@DO_PNG_PREFIX_TRUE@ rm -f pngprefix.tf1 +@DO_PNG_PREFIX_TRUE@ $(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1 +@DO_PNG_PREFIX_TRUE@ mv pngprefix.tf1 $@ +@DO_PNG_PREFIX_FALSE@pnglibconf.h: pnglibconf.out +@DO_PNG_PREFIX_FALSE@ rm -f $@ +@DO_PNG_PREFIX_FALSE@ cp $? $@ -# do evil things to libpng to cause libpng12 to be used -install-exec-hook: - cd $(DESTDIR)$(bindir); rm -f libpng-config - cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config - @set -x;\ - cd $(DESTDIR)$(libdir);\ - for ext in a la so sl dylib; do\ - rm -f libpng.$$ext;\ - if test -f $(PNGLIB_BASENAME).$$ext; then\ - $(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\ - fi;\ +@DO_PNG_PREFIX_FALSE@pngprefix.h: # is empty +@DO_PNG_PREFIX_FALSE@ :>$@ + +$(srcdir)/scripts/pnglibconf.h.prebuilt: + @echo "Attempting to build $@" >&2 + @echo "This is a machine generated file, but if you want to make" >&2 + @echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2 + @echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2 + @exit 1 + +# The following is necessary to ensure that the local pnglibconf.h is used, not +# an installed one (this can happen immediately after on a clean system if +# 'make test' is the first thing the user does.) Only files which include +# one of the png source files (typically png.h or pngpriv.h) need to be listed +# here: +pngtest.o: pnglibconf.h + +contrib/libtests/makepng.o: pnglibconf.h +contrib/libtests/pngstest.o: pnglibconf.h +contrib/libtests/pngunknown.o: pnglibconf.h +contrib/libtests/pngimage.o: pnglibconf.h +contrib/libtests/pngvalid.o: pnglibconf.h +contrib/libtests/readpng.o: pnglibconf.h +contrib/libtests/tarith.o: pnglibconf.h +contrib/libtests/timepng.o: pnglibconf.h + +contrib/tools/makesRGB.o: pnglibconf.h +contrib/tools/pngfix.o: pnglibconf.h +contrib/tools/pngcp.o: pnglibconf.h + +.c.out: + rm -f $@ $*.tf[12] + test -d scripts || mkdir scripts || test -d scripts + $(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\ + $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1 + $(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2 + rm -f $*.tf1 + mv $*.tf2 $@ + +# The .c file for pnglibconf.h is machine generated +pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA) + rm -f $@ $*.tf[45] + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2 + rm $*.tf4 + mv $*.tf5 $@ + +# Symbol checks (.def and .out files should match) +scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out + +.out.chk: + rm -f $@ $*.new + $(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\ + of="$*.new" $< >&2 + mv $*.new $@ + +# used on demand to regenerate the standard header, CPPFLAGS should +# be empty - no non-standard defines +scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h + rm -f $@ pnglibconf.tf[67] + test -z "$(CPPFLAGS)" + echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\ + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\ + logunsupported=1 version=search ${srcdir}/pngconf.h -\ + ${srcdir}/scripts/pnglibconf.dfa 1>&2 + $(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\ + pnglibconf.tf6 1>&2 + rm pnglibconf.tf6 + mv pnglibconf.tf7 $@ + +$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \ + pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h + +test: check-am + +# Extra checks +check: scripts/symbols.chk + +# Don't distribute the generated script files +dist-hook: + cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES) + +# Make links between installed files with release-specific names and the generic +# file names. If this install rule is run the generic names will be deleted and +# recreated - this has obvious issues for systems with multiple installations. + +install-header-links: + @set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \ + rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done + +uninstall-header-links: + cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS) + +install-libpng-pc: + @set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \ + $(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc + +uninstall-libpng-pc: + rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc' + +install-library-links: + @set -x; cd '$(DESTDIR)$(libdir)';\ + for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext";\ + if test -f "$(PNGLIB_BASENAME).$$ext"; then\ + $(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\ + fi;\ done -uninstall-hook: - cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h - rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc - rm -f $(DESTDIR)$(bindir)/libpng-config - @if test -n "@compatlib@"; then\ - set -x;\ - cd $(DESTDIR)$(libdir);\ - for ext in a la so sl dylib; do\ - rm -f libpng.$$ext;\ - done;\ - fi +uninstall-library-links: + @set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\ + rm -f "libpng.$$ext"; done + +install-libpng-config: + @set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \ + $(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config + +uninstall-libpng-config: + rm -f '$(DESTDIR)$(bindir)/libpng-config' + +# If --enable-unversioned-links is specified the header and lib file links +# will be automatically made on a 'make install': + +@DO_INSTALL_LINKS_TRUE@install-data-hook: install-header-links +@DO_INSTALL_LINKS_TRUE@uninstall-hook: uninstall-header-links +@DO_INSTALL_LINKS_TRUE@install-exec-hook: install-library-links +@DO_INSTALL_LINKS_TRUE@uninstall-hook: uninstall-library-links + +# Likewise, --install-pc causes libpng.pc to be constructed: + +@DO_INSTALL_LIBPNG_PC_TRUE@install-data-hook: install-libpng-pc +@DO_INSTALL_LIBPNG_PC_TRUE@uninstall-hook: uninstall-libpng-pc + +# And --install-config: + +@DO_INSTALL_LIBPNG_CONFIG_TRUE@install-exec-hook: install-libpng-config +@DO_INSTALL_LIBPNG_CONFIG_TRUE@uninstall-hook: uninstall-libpng-config + +# The following addition ensures that 'make all' always builds the test programs +# too. It used to, but some change either in libpng or configure stopped this +# working. +all-am: $(check_PROGRAMS) # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/libs/libpng-src/README b/libs/libpng-src/README index cbff54441..cfc1f0e3d 100644 --- a/libs/libpng-src/README +++ b/libs/libpng-src/README @@ -1,19 +1,16 @@ -README for libpng version 1.2.46 - July 9, 2011 (shared library 12.0) -See the note about version numbers near the top of png.h +README for libpng version 1.6.37 - April 14, 2019 +================================================= +See the note about version numbers near the top of png.h. See INSTALL for instructions on how to install libpng. -Libpng comes in several distribution formats. Get libpng-*.tar.gz, -libpng-*.tar.xz, or libpng-*.tar.bz2 if you want UNIX-style line -endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style -line endings. You can get UNIX-style line endings from the *.zip file -by using "unzip -a" but there seems to be no simple way to recover -UNIX-style line endings from the *.7z file. The *.tar.xz file is -recommended for *NIX users instead. +Libpng comes in several distribution formats. Get libpng-*.tar.gz or +libpng-*.tar.xz or if you want UNIX-style line endings in the text +files, or lpng*.7z or lpng*.zip if you want DOS-style line endings. Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had +fact that it's the first release fool you. The libpng library has been +in extensive use and testing since mid-1995. By late 1997 it had finally gotten to the stage where there hadn't been significant changes to the API in some time, and people have a bad feeling about libraries with versions < 1.0. Version 1.0.0 was released in @@ -27,18 +24,25 @@ earlier versions if you are using a shared library. The type of the png_uint_32, which will affect shared-library applications that use this function. -To avoid problems with changes to the internals of png_info_struct, +To avoid problems with changes to the internals of the png info_struct, new APIs have been made available in 0.95 to avoid direct application access to info_ptr. These functions are the png_set_ and png_get_ functions. These functions should be used when accessing/storing the info_struct data, rather than manipulating it directly, to avoid such problems in the future. -It is important to note that the APIs do not make current programs +It is important to note that the APIs did not make current programs that access the info struct directly incompatible with the new -library. However, it is strongly suggested that new programs use -the new APIs (as shown in example.c and pngtest.c), and older programs -be converted to the new format, to facilitate upgrades in the future. +library, through libpng-1.2.x. In libpng-1.4.x, which was meant to +be a transitional release, members of the png_struct and the +info_struct can still be accessed, but the compiler will issue a +warning about deprecated usage. Since libpng-1.5.0, direct access +to these structs is not allowed, and the definitions of the structs +reside in private pngstruct.h and pnginfo.h header files that are not +accessible to applications. It is strongly suggested that new +programs use the new APIs (as shown in example.c and pngtest.c), and +older programs be converted to the new format, to facilitate upgrades +in the future. **** Additions since 0.90 include the ability to compile libpng as a @@ -57,101 +61,71 @@ the library action on the detection of chunk CRC errors. It is possible to set different actions based on whether the CRC error occurred in a critical or an ancillary chunk. -The changes made to the library, and bugs fixed are based on discussions -on the png-mng-implement mailing list and not on material submitted -privately to Guy, Andreas, or Glenn. They will forward any good -suggestions to the list. - -For a detailed description on using libpng, read libpng.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h +For a detailed description on using libpng, read libpng-manual.txt. +For examples of libpng in a program, see example.c and pngtest.c. For +usage information and restrictions (what little they are) on libpng, +see png.h. For a description on using zlib (the compression library +used by libpng) and zlib's restrictions, see zlib.h I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. +compiler specific ones, but you may have to modify one for your own +needs. You should use zlib 1.0.4 or later to run this, but it MAY work with versions as old as zlib 0.95. Even so, there are bugs in older zlib versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. +some images. + +You should also note that zlib is a compression library that is useful +for more things than just PNG files. You can use zlib as a drop-in +replacement for fread() and fwrite(), if you are so inclined. zlib should be available at the same place that libpng is, or at -ftp://ftp.simplesystems.org/pub/png/src/ +https://zlib.net. You may also want a copy of the PNG specification. It is available as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find -these at http://www.libpng.org/pub/png/pngdocs.html +these at http://www.libpng.org/pub/png/pngdocs.html . -This code is currently being archived at libpng.sf.net in the -[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT) -at GO GRAPHSUP. If you can't find it in any of those places, -e-mail me, and I'll help you find it. +This code is currently being archived at libpng.sourceforge.io in the +[DOWNLOAD] area, and at http://libpng.download/src . -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG +This release, based in a large way on Glenn's, Guy's and Andreas' +earlier work, was created and will be supported by myself and the PNG development group. -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit +Send comments/corrections/commendations to png-mng-implement at +lists.sourceforge.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net +to subscribe). -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will -read mail addressed to the png-mng-implement list, however. - -Please do not send general questions about PNG. Send them to -the (png-mng-misc at lists.sourceforge.net, subscription required, visit +Send general questions about the PNG specification to png-mng-misc +at lists.sourceforge.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-misc to -subscribe). On the other hand, please do not send libpng questions to -that address, send them to me or to the png-mng-implement list. I'll -get them in the end anyway. If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for twelve years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used immediately, -it may be used later. +subscribe). Files in this distribution: ANNOUNCE => Announcement of this version, with recent changes + AUTHORS => List of contributing authors CHANGES => Description of changes between libpng versions KNOWNBUG => List of known bugs and deficiencies LICENSE => License to use and redistribute libpng README => This file TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance + TRADEMARK => Trademark information example.c => Example code for using libpng functions - libpng-*-*-diff.txt => Diff from previous release - libpng.3 => manual page for libpng (includes libpng.txt) - libpng.txt => Description of libpng and its functions + libpng.3 => manual page for libpng (includes libpng-manual.txt) + libpng-manual.txt => Description of libpng and its functions libpngpf.3 => manual page for libpng's private functions png.5 => manual page for the PNG format png.c => Basic interface functions common to library - png.h => Library function and interface declarations - pngconf.h => System specific library configuration + png.h => Library function and interface declarations (public) + pngpriv.h => Library function and interface declarations (private) + pngconf.h => System specific library configuration (public) + pngstruct.h => png_struct declaration (private) + pnginfo.h => png_info struct declaration (private) + pngdebug.h => debugging macros (private) pngerror.c => Error/warning message I/O functions pngget.c => Functions for retrieving info from struct pngmem.c => Memory handling functions @@ -170,106 +144,40 @@ Files in this distribution: pngwrite.c => High-level write functions pngwtran.c => Write data transformations pngwutil.c => Write utility functions + arm => Contains optimized code for the ARM platform + powerpc => Contains optimized code for the PowerPC platform contrib => Contributions + arm-neon => Optimized code for ARM-NEON platform + powerpc-vsx => Optimized code for POWERPC-VSX platform + examples => Example programs gregbook => source code for PNG reading and writing, from Greg Roelofs' "PNG: The Definitive Guide", O'Reilly, 1999 - msvctest => Builds and runs pngtest using a MSVC workspace - pngminim => Simple pnm2pngm and png2pnmm programs - pngminus => Simple pnm2png and png2pnm programs - pngsuite => Test images - visupng => Contains a MSVC workspace for VisualPng + libtests => Test programs + mips-msa => Optimized code for MIPS-MSA platform + pngminim => Minimal decoder, encoder, and progressive decoder + programs demonstrating use of pngusr.dfa + pngminus => Simple pnm2png and png2pnm programs + pngsuite => Test images + testpngs + tools => Various tools + visupng => Contains a MSVC workspace for VisualPng + intel => Optimized code for INTEL-SSE2 platform + mips => Optimized code for MIPS platform projects => Contains project files and workspaces for building a DLL - beos => Contains a Beos workspace for building libpng - c5builder => Contains a Borland workspace for building - libpng and zlib - netware.txt => Contains instructions for downloading a set - of project files for building libpng and - zlib on Netware. - visualc6 => Contains a Microsoft Visual C++ (MSVC) + owatcom => Contains a WATCOM project for building libpng + visualc71 => Contains a Microsoft Visual C++ (MSVC) + workspace for building libpng and zlib + vstudio => Contains a Microsoft Visual C++ (MSVC) workspace for building libpng and zlib - wince.txt => Contains instructions for downloading a - Microsoft Visual C++ (Windows CD Toolkit) - workspace for building libpng and zlib on - WindowsCE - xcode => Contains xcode project files scripts => Directory containing scripts for building libpng: - descrip.mms => VMS makefile for MMS or MMK - makefile.std => Generic UNIX makefile (cc, creates static - libpng.a) - makefile.elf => Linux/ELF gcc makefile symbol versioning, - creates libpng12.so.0.1.2.46) - makefile.linux => Linux/ELF makefile (gcc, creates - libpng12.so.0.1.2.46) - makefile.gcmmx => Linux/ELF makefile (gcc, creates - libpng12.so.0.1.2.46, previously - used assembler code tuned for Intel MMX - platform) - makefile.gcc => Generic makefile (gcc, creates static - libpng.a) - makefile.knr => Archaic UNIX Makefile that converts files - with ansi2knr (Requires ansi2knr.c from - ftp://ftp.cs.wisc.edu/ghost) - makefile.aix => AIX makefile - makefile.cygwin => Cygwin/gcc makefile - makefile.darwin => Darwin makefile - makefile.dec => DEC Alpha UNIX makefile - makefile.freebsd => FreeBSD makefile - makefile.hpgcc => HPUX makefile using gcc - makefile.hpux => HPUX (10.20 and 11.00) makefile - makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit - makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 - (static) - makefile.intel => Intel C/C++ version 4.0 and later - libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later - makefile.netbsd => NetBSD/cc makefile, makes libpng.so. - makefile.ne12bsd => NetBSD/cc makefile, makes libpng12.so - makefile.openbsd => OpenBSD makefile - makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) - makefile.sggcc => Silicon Graphics - (gcc, creates libpng12.so.0.1.2.46) - makefile.sunos => Sun makefile - makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng12.so.0.1.2.46) - makefile.so9 => Solaris 9 makefile - (gcc, creates libpng12.so.0.1.2.46) - makefile.32sunu => Sun Ultra 32-bit makefile - makefile.64sunu => Sun Ultra 64-bit makefile - makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc - makefile.mips => MIPS makefile - makefile.acorn => Acorn makefile - makefile.amiga => Amiga makefile - smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC - compiler (Requires SCOPTIONS, copied from - scripts/SCOPTIONS.ppc) - makefile.atari => Atari makefile - makefile.beos => BEOS makefile for X86 - makefile.bor => Borland makefile (uses bcc) - makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode) - makefile.tc3 => Turbo C 3.0 makefile - makefile.dj2 => DJGPP 2 makefile - makefile.msc => Microsoft C makefile - makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and - later (previously used assembler code tuned - for Intel MMX platform) - makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and - later (does not use assembler code) - makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def) - pngos2.def => OS/2 module definition file used by makefile.os2 - makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model - makevms.com => VMS build script - SCOPTIONS.ppc => Used with smakefile.ppc + (see scripts/README.txt for the list of scripts) -Good luck, and happy coding. +Good luck, and happy coding! --Glenn Randers-Pehrson (current maintainer, since 1998) - Internet: glennrp at users.sourceforge.net - --Andreas Eric Dilger (former maintainer, 1996-1997) - Internet: adilger at enel.ucalgary.ca - Web: http://members.shaw.ca/adilger/ - --Guy Eric Schalnat (original author and former maintainer, 1995-1996) - (formerly of Group 42, Inc) - Internet: gschal at infinet.com + * Cosmin Truta (current maintainer, since 2018) + * Glenn Randers-Pehrson (former maintainer, 1998-2018) + * Andreas Eric Dilger (former maintainer, 1996-1997) + * Guy Eric Schalnat (original author and former maintainer, 1995-1996) + (formerly of Group 42, Inc.) diff --git a/libs/libpng-src/TODO b/libs/libpng-src/TODO index face7658c..562dab069 100644 --- a/libs/libpng-src/TODO +++ b/libs/libpng-src/TODO @@ -1,25 +1,23 @@ TODO - list of things to do for libpng: -Final bug fixes. -Improve API by hiding the png_struct and png_info structs. -Finish work on the no-floating-point version (including gamma compensation) -Better C++ wrapper/full C++ implementation? -Fix problem with C++ and EXTERN "C". -cHRM transformation. -Improve setjmp/longjmp usage or remove it in favor of returning error codes. -Add "grayscale->palette" transformation and "palette->grayscale" detection. -Improved dithering. -Multi-lingual error and warning message support. -Complete sRGB transformation (presently it simply uses gamma=0.45455). -Man pages for function calls. -Better documentation. -Better filter selection - (counting huffman bits/precompression? filter inertia? filter costs?). -Histogram creation. -Text conversion between different code pages (Latin-1 -> Mac and DOS). -Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety? -Build gamma tables using fixed point (and do away with floating point entirely). -Use greater precision when changing to linear gamma for compositing against - background and doing rgb-to-gray transformation. -Investigate pre-incremented loop counters and other loop constructions. -Add interpolated method of handling interlacing. +* Fix all defects (duh!) +* Better C++ wrapper / full C++ implementation (?) +* Fix the problems with C++ and 'extern "C"'. +* cHRM transformation. +* Palette creation. +* "grayscale->palette" transformation and "palette->grayscale" detection. +* Improved dithering. +* Multi-lingual error and warning message support. +* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.) +* Man pages for function calls. +* Better documentation. +* Better filter selection + (e.g., counting huffman bits/precompression; filter inertia; filter costs). +* Histogram creation. +* Text conversion between different code pages (e.g., Latin-1 -> Mac). +* Avoid building gamma tables whenever possible. +* Greater precision in changing to linear gamma for compositing against + background, and in doing rgb-to-gray transformations. +* Investigate pre-incremented loop counters and other loop constructions. +* Interpolated method of handling interlacing. +* More validations for libpng transformations. diff --git a/libs/libpng-src/TRADEMARK b/libs/libpng-src/TRADEMARK new file mode 100644 index 000000000..ac667187d --- /dev/null +++ b/libs/libpng-src/TRADEMARK @@ -0,0 +1,8 @@ +TRADEMARK +========= + +The name "libpng" has not been registered by the Copyright owners +as a trademark in any jurisdiction. However, because libpng has +been distributed and maintained world-wide, continually since 1995, +the Copyright owners claim "common-law trademark protection" in any +jurisdiction where common-law trademark is recognized. diff --git a/libs/libpng-src/aclocal.m4 b/libs/libpng-src/aclocal.m4 index 27bc57cf4..bc18c34f0 100644 --- a/libs/libpng-src/aclocal.m4 +++ b/libs/libpng-src/aclocal.m4 @@ -1,7 +1,7 @@ -# generated automatically by aclocal 1.11 -*- Autoconf -*- +# generated automatically by aclocal 1.16.1 -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -11,7961 +11,16 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, -[m4_warning([this file was generated for autoconf 2.65. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. -To do so, use the procedure documented by the package, typically `autoreconf'.])]) +To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- -# -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -m4_define([_LT_COPYING], [dnl -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 -# -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -]) - -# serial 56 LT_INIT - - -# LT_PREREQ(VERSION) -# ------------------ -# Complain and exit if this libtool version is less that VERSION. -m4_defun([LT_PREREQ], -[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, - [m4_default([$3], - [m4_fatal([Libtool version $1 or higher is required], - 63)])], - [$2])]) - - -# _LT_CHECK_BUILDDIR -# ------------------ -# Complain if the absolute build directory name contains unusual characters -m4_defun([_LT_CHECK_BUILDDIR], -[case `pwd` in - *\ * | *\ *) - AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; -esac -]) - - -# LT_INIT([OPTIONS]) -# ------------------ -AC_DEFUN([LT_INIT], -[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT -AC_BEFORE([$0], [LT_LANG])dnl -AC_BEFORE([$0], [LT_OUTPUT])dnl -AC_BEFORE([$0], [LTDL_INIT])dnl -m4_require([_LT_CHECK_BUILDDIR])dnl - -dnl Autoconf doesn't catch unexpanded LT_ macros by default: -m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl -m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl -dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 -dnl unless we require an AC_DEFUNed macro: -AC_REQUIRE([LTOPTIONS_VERSION])dnl -AC_REQUIRE([LTSUGAR_VERSION])dnl -AC_REQUIRE([LTVERSION_VERSION])dnl -AC_REQUIRE([LTOBSOLETE_VERSION])dnl -m4_require([_LT_PROG_LTMAIN])dnl - -dnl Parse OPTIONS -_LT_SET_OPTIONS([$0], [$1]) - -# This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" - -# Always use our own libtool. -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -AC_SUBST(LIBTOOL)dnl - -_LT_SETUP - -# Only expand once: -m4_define([LT_INIT]) -])# LT_INIT - -# Old names: -AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) -AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PROG_LIBTOOL], []) -dnl AC_DEFUN([AM_PROG_LIBTOOL], []) - - -# _LT_CC_BASENAME(CC) -# ------------------- -# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. -m4_defun([_LT_CC_BASENAME], -[for cc_temp in $1""; do - case $cc_temp in - compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; - distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` -]) - - -# _LT_FILEUTILS_DEFAULTS -# ---------------------- -# It is okay to use these file commands and assume they have been set -# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. -m4_defun([_LT_FILEUTILS_DEFAULTS], -[: ${CP="cp -f"} -: ${MV="mv -f"} -: ${RM="rm -f"} -])# _LT_FILEUTILS_DEFAULTS - - -# _LT_SETUP -# --------- -m4_defun([_LT_SETUP], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -_LT_DECL([], [host_alias], [0], [The host system])dnl -_LT_DECL([], [host], [0])dnl -_LT_DECL([], [host_os], [0])dnl -dnl -_LT_DECL([], [build_alias], [0], [The build system])dnl -_LT_DECL([], [build], [0])dnl -_LT_DECL([], [build_os], [0])dnl -dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -dnl -AC_REQUIRE([AC_PROG_LN_S])dnl -test -z "$LN_S" && LN_S="ln -s" -_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl -dnl -AC_REQUIRE([LT_CMD_MAX_LEN])dnl -_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl -_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl -dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_CHECK_SHELL_FEATURES])dnl -m4_require([_LT_CMD_RELOAD])dnl -m4_require([_LT_CHECK_MAGIC_METHOD])dnl -m4_require([_LT_CMD_OLD_ARCHIVE])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl - -_LT_CONFIG_LIBTOOL_INIT([ -# See if we are running on zsh, and set the options which allow our -# commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi -]) -if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST -fi - -_LT_CHECK_OBJDIR - -m4_require([_LT_TAG_COMPILER])dnl -_LT_PROG_ECHO_BACKSLASH - -case $host_os in -aix3*) - # AIX sometimes has problems with the GCC collect2 program. For some - # reason, if we set the COLLECT_NAMES environment variable, the problems - # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES - fi - ;; -esac - -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\([["`\\]]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - -# Global variables: -ofile=libtool -can_build_shared=yes - -# All known linkers require a `.a' archive for static linking (except MSVC, -# which needs '.lib'). -libext=a - -with_gnu_ld="$lt_cv_prog_gnu_ld" - -old_CC="$CC" -old_CFLAGS="$CFLAGS" - -# Set sane defaults for various variables -test -z "$CC" && CC=cc -test -z "$LTCC" && LTCC=$CC -test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS -test -z "$LD" && LD=ld -test -z "$ac_objext" && ac_objext=o - -_LT_CC_BASENAME([$compiler]) - -# Only perform the check for file, if the check method requires it -test -z "$MAGIC_CMD" && MAGIC_CMD=file -case $deplibs_check_method in -file_magic*) - if test "$file_magic_cmd" = '$MAGIC_CMD'; then - _LT_PATH_MAGIC - fi - ;; -esac - -# Use C for the default configuration in the libtool script -LT_SUPPORTED_TAG([CC]) -_LT_LANG_C_CONFIG -_LT_LANG_DEFAULT_CONFIG -_LT_CONFIG_COMMANDS -])# _LT_SETUP - - -# _LT_PROG_LTMAIN -# --------------- -# Note that this code is called both from `configure', and `config.status' -# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, -# `config.status' has no value for ac_aux_dir unless we are using Automake, -# so we pass a copy along to make sure it has a sensible value anyway. -m4_defun([_LT_PROG_LTMAIN], -[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl -_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) -ltmain="$ac_aux_dir/ltmain.sh" -])# _LT_PROG_LTMAIN - - - -# So that we can recreate a full libtool script including additional -# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS -# in macros and then make a single call at the end using the `libtool' -# label. - - -# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) -# ---------------------------------------- -# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL_INIT], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_INIT], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_INIT]) - - -# _LT_CONFIG_LIBTOOL([COMMANDS]) -# ------------------------------ -# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. -m4_define([_LT_CONFIG_LIBTOOL], -[m4_ifval([$1], - [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], - [$1 -])])]) - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) - - -# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) -# ----------------------------------------------------- -m4_defun([_LT_CONFIG_SAVE_COMMANDS], -[_LT_CONFIG_LIBTOOL([$1]) -_LT_CONFIG_LIBTOOL_INIT([$2]) -]) - - -# _LT_FORMAT_COMMENT([COMMENT]) -# ----------------------------- -# Add leading comment marks to the start of each line, and a trailing -# full-stop to the whole comment if one is not present already. -m4_define([_LT_FORMAT_COMMENT], -[m4_ifval([$1], [ -m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], - [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) -)]) - - - - - -# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) -# ------------------------------------------------------------------- -# CONFIGNAME is the name given to the value in the libtool script. -# VARNAME is the (base) name used in the configure script. -# VALUE may be 0, 1 or 2 for a computed quote escaped value based on -# VARNAME. Any other value will be used directly. -m4_define([_LT_DECL], -[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], - [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], - [m4_ifval([$1], [$1], [$2])]) - lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) - m4_ifval([$4], - [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) - lt_dict_add_subkey([lt_decl_dict], [$2], - [tagged?], [m4_ifval([$5], [yes], [no])])]) -]) - - -# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) -# -------------------------------------------------------- -m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) - - -# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_tag_varnames], -[_lt_decl_filter([tagged?], [yes], $@)]) - - -# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) -# --------------------------------------------------------- -m4_define([_lt_decl_filter], -[m4_case([$#], - [0], [m4_fatal([$0: too few arguments: $#])], - [1], [m4_fatal([$0: too few arguments: $#: $1])], - [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], - [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], - [lt_dict_filter([lt_decl_dict], $@)])[]dnl -]) - - -# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) -# -------------------------------------------------- -m4_define([lt_decl_quote_varnames], -[_lt_decl_filter([value], [1], $@)]) - - -# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_dquote_varnames], -[_lt_decl_filter([value], [2], $@)]) - - -# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) -# --------------------------------------------------- -m4_define([lt_decl_varnames_tagged], -[m4_assert([$# <= 2])dnl -_$0(m4_quote(m4_default([$1], [[, ]])), - m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), - m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) -m4_define([_lt_decl_varnames_tagged], -[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) - - -# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) -# ------------------------------------------------ -m4_define([lt_decl_all_varnames], -[_$0(m4_quote(m4_default([$1], [[, ]])), - m4_if([$2], [], - m4_quote(lt_decl_varnames), - m4_quote(m4_shift($@))))[]dnl -]) -m4_define([_lt_decl_all_varnames], -[lt_join($@, lt_decl_varnames_tagged([$1], - lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl -]) - - -# _LT_CONFIG_STATUS_DECLARE([VARNAME]) -# ------------------------------------ -# Quote a variable value, and forward it to `config.status' so that its -# declaration there will have the same value as in `configure'. VARNAME -# must have a single quote delimited value for this to work. -m4_define([_LT_CONFIG_STATUS_DECLARE], -[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) - - -# _LT_CONFIG_STATUS_DECLARATIONS -# ------------------------------ -# We delimit libtool config variables with single quotes, so when -# we write them to config.status, we have to be sure to quote all -# embedded single quotes properly. In configure, this macro expands -# each variable declared with _LT_DECL (and _LT_TAGDECL) into: -# -# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' -m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], -[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), - [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAGS -# ---------------- -# Output comment and list of tags supported by the script -m4_defun([_LT_LIBTOOL_TAGS], -[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl -available_tags="_LT_TAGS"dnl -]) - - -# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) -# ----------------------------------- -# Extract the dictionary values for VARNAME (optionally with TAG) and -# expand to a commented shell variable setting: -# -# # Some comment about what VAR is for. -# visible_name=$lt_internal_name -m4_define([_LT_LIBTOOL_DECLARE], -[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], - [description])))[]dnl -m4_pushdef([_libtool_name], - m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl -m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), - [0], [_libtool_name=[$]$1], - [1], [_libtool_name=$lt_[]$1], - [2], [_libtool_name=$lt_[]$1], - [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl -m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl -]) - - -# _LT_LIBTOOL_CONFIG_VARS -# ----------------------- -# Produce commented declarations of non-tagged libtool config variables -# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' -# script. Tagged libtool config variables (even for the LIBTOOL CONFIG -# section) are produced by _LT_LIBTOOL_TAG_VARS. -m4_defun([_LT_LIBTOOL_CONFIG_VARS], -[m4_foreach([_lt_var], - m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) - - -# _LT_LIBTOOL_TAG_VARS(TAG) -# ------------------------- -m4_define([_LT_LIBTOOL_TAG_VARS], -[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), - [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) - - -# _LT_TAGVAR(VARNAME, [TAGNAME]) -# ------------------------------ -m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) - - -# _LT_CONFIG_COMMANDS -# ------------------- -# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of -# variables for single and double quote escaping we saved from calls -# to _LT_DECL, we can put quote escaped variables declarations -# into `config.status', and then the shell code to quote escape them in -# for loops in `config.status'. Finally, any additional code accumulated -# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. -m4_defun([_LT_CONFIG_COMMANDS], -[AC_PROVIDE_IFELSE([LT_OUTPUT], - dnl If the libtool generation code has been placed in $CONFIG_LT, - dnl instead of duplicating it all over again into config.status, - dnl then we will have config.status run $CONFIG_LT later, so it - dnl needs to know what name is stored there: - [AC_CONFIG_COMMANDS([libtool], - [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], - dnl If the libtool generation code is destined for config.status, - dnl expand the accumulated commands and init code now: - [AC_CONFIG_COMMANDS([libtool], - [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) -])#_LT_CONFIG_COMMANDS - - -# Initialize. -m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], -[ - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -sed_quote_subst='$sed_quote_subst' -double_quote_subst='$double_quote_subst' -delay_variable_subst='$delay_variable_subst' -_LT_CONFIG_STATUS_DECLARATIONS -LTCC='$LTCC' -LTCFLAGS='$LTCFLAGS' -compiler='$compiler_DEFAULT' - -# Quote evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_quote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Double-quote double-evaled strings. -for var in lt_decl_all_varnames([[ \ -]], lt_decl_dquote_varnames); do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in - *[[\\\\\\\`\\"\\\$]]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" - ;; - *) - eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" - ;; - esac -done - -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\[$]0 --fallback-echo"')dnl " - lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` - ;; -esac - -_LT_OUTPUT_LIBTOOL_INIT -]) - - -# LT_OUTPUT -# --------- -# This macro allows early generation of the libtool script (before -# AC_OUTPUT is called), incase it is used in configure for compilation -# tests. -AC_DEFUN([LT_OUTPUT], -[: ${CONFIG_LT=./config.lt} -AC_MSG_NOTICE([creating $CONFIG_LT]) -cat >"$CONFIG_LT" <<_LTEOF -#! $SHELL -# Generated by $as_me. -# Run this file to recreate a libtool stub with the current configuration. - -lt_cl_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AS_SHELL_SANITIZE -_AS_PREPARE - -exec AS_MESSAGE_FD>&1 -exec AS_MESSAGE_LOG_FD>>config.log -{ - echo - AS_BOX([Running $as_me.]) -} >&AS_MESSAGE_LOG_FD - -lt_cl_help="\ -\`$as_me' creates a local libtool stub from the current configuration, -for use in further configure time tests before the real libtool is -generated. - -Usage: $[0] [[OPTIONS]] - - -h, --help print this help, then exit - -V, --version print version number, then exit - -q, --quiet do not print progress messages - -d, --debug don't remove temporary files - -Report bugs to ." - -lt_cl_version="\ -m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl -m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) -configured by $[0], generated by m4_PACKAGE_STRING. - -Copyright (C) 2008 Free Software Foundation, Inc. -This config.lt script is free software; the Free Software Foundation -gives unlimited permision to copy, distribute and modify it." - -while test $[#] != 0 -do - case $[1] in - --version | --v* | -V ) - echo "$lt_cl_version"; exit 0 ;; - --help | --h* | -h ) - echo "$lt_cl_help"; exit 0 ;; - --debug | --d* | -d ) - debug=: ;; - --quiet | --q* | --silent | --s* | -q ) - lt_cl_silent=: ;; - - -*) AC_MSG_ERROR([unrecognized option: $[1] -Try \`$[0] --help' for more information.]) ;; - - *) AC_MSG_ERROR([unrecognized argument: $[1] -Try \`$[0] --help' for more information.]) ;; - esac - shift -done - -if $lt_cl_silent; then - exec AS_MESSAGE_FD>/dev/null -fi -_LTEOF - -cat >>"$CONFIG_LT" <<_LTEOF -_LT_OUTPUT_LIBTOOL_COMMANDS_INIT -_LTEOF - -cat >>"$CONFIG_LT" <<\_LTEOF -AC_MSG_NOTICE([creating $ofile]) -_LT_OUTPUT_LIBTOOL_COMMANDS -AS_EXIT(0) -_LTEOF -chmod +x "$CONFIG_LT" - -# configure is writing to config.log, but config.lt does its own redirection, -# appending to config.log, which fails on DOS, as config.log is still kept -# open by configure. Here we exec the FD to /dev/null, effectively closing -# config.log, so it can be properly (re)opened and appended to by config.lt. -if test "$no_create" != yes; then - lt_cl_success=: - test "$silent" = yes && - lt_config_lt_args="$lt_config_lt_args --quiet" - exec AS_MESSAGE_LOG_FD>/dev/null - $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false - exec AS_MESSAGE_LOG_FD>>config.log - $lt_cl_success || AS_EXIT(1) -fi -])# LT_OUTPUT - - -# _LT_CONFIG(TAG) -# --------------- -# If TAG is the built-in tag, create an initial libtool script with a -# default configuration from the untagged config vars. Otherwise add code -# to config.status for appending the configuration named by TAG from the -# matching tagged config vars. -m4_defun([_LT_CONFIG], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_CONFIG_SAVE_COMMANDS([ - m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl - m4_if(_LT_TAG, [C], [ - # See if we are running on zsh, and set the options which allow our - # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then - setopt NO_GLOB_SUBST - fi - - cfgfile="${ofile}T" - trap "$RM \"$cfgfile\"; exit 1" 1 2 15 - $RM "$cfgfile" - - cat <<_LT_EOF >> "$cfgfile" -#! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION -# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: -# NOTE: Changes made to this file will be lost: look at ltmain.sh. -# -_LT_COPYING -_LT_LIBTOOL_TAGS - -# ### BEGIN LIBTOOL CONFIG -_LT_LIBTOOL_CONFIG_VARS -_LT_LIBTOOL_TAG_VARS -# ### END LIBTOOL CONFIG - -_LT_EOF - - case $host_os in - aix3*) - cat <<\_LT_EOF >> "$cfgfile" -# AIX sometimes has problems with the GCC collect2 program. For some -# reason, if we set the COLLECT_NAMES environment variable, the problems -# vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then - COLLECT_NAMES= - export COLLECT_NAMES -fi -_LT_EOF - ;; - esac - - _LT_PROG_LTMAIN - - # We use sed instead of cat because bash on DJGPP gets confused if - # if finds mixed CR/LF and LF-only lines. Since sed operates in - # text mode, it properly converts lines to CR/LF. This bash problem - # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - _LT_PROG_XSI_SHELLFNS - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || - (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") - chmod +x "$ofile" -], -[cat <<_LT_EOF >> "$ofile" - -dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded -dnl in a comment (ie after a #). -# ### BEGIN LIBTOOL TAG CONFIG: $1 -_LT_LIBTOOL_TAG_VARS(_LT_TAG) -# ### END LIBTOOL TAG CONFIG: $1 -_LT_EOF -])dnl /m4_if -], -[m4_if([$1], [], [ - PACKAGE='$PACKAGE' - VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' - RM='$RM' - ofile='$ofile'], []) -])dnl /_LT_CONFIG_SAVE_COMMANDS -])# _LT_CONFIG - - -# LT_SUPPORTED_TAG(TAG) -# --------------------- -# Trace this macro to discover what tags are supported by the libtool -# --tag option, using: -# autoconf --trace 'LT_SUPPORTED_TAG:$1' -AC_DEFUN([LT_SUPPORTED_TAG], []) - - -# C support is built-in for now -m4_define([_LT_LANG_C_enabled], []) -m4_define([_LT_TAGS], []) - - -# LT_LANG(LANG) -# ------------- -# Enable libtool support for the given language if not already enabled. -AC_DEFUN([LT_LANG], -[AC_BEFORE([$0], [LT_OUTPUT])dnl -m4_case([$1], - [C], [_LT_LANG(C)], - [C++], [_LT_LANG(CXX)], - [Java], [_LT_LANG(GCJ)], - [Fortran 77], [_LT_LANG(F77)], - [Fortran], [_LT_LANG(FC)], - [Windows Resource], [_LT_LANG(RC)], - [m4_ifdef([_LT_LANG_]$1[_CONFIG], - [_LT_LANG($1)], - [m4_fatal([$0: unsupported language: "$1"])])])dnl -])# LT_LANG - - -# _LT_LANG(LANGNAME) -# ------------------ -m4_defun([_LT_LANG], -[m4_ifdef([_LT_LANG_]$1[_enabled], [], - [LT_SUPPORTED_TAG([$1])dnl - m4_append([_LT_TAGS], [$1 ])dnl - m4_define([_LT_LANG_]$1[_enabled], [])dnl - _LT_LANG_$1_CONFIG($1)])dnl -])# _LT_LANG - - -# _LT_LANG_DEFAULT_CONFIG -# ----------------------- -m4_defun([_LT_LANG_DEFAULT_CONFIG], -[AC_PROVIDE_IFELSE([AC_PROG_CXX], - [LT_LANG(CXX)], - [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) - -AC_PROVIDE_IFELSE([AC_PROG_F77], - [LT_LANG(F77)], - [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) - -AC_PROVIDE_IFELSE([AC_PROG_FC], - [LT_LANG(FC)], - [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) - -dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal -dnl pulling things in needlessly. -AC_PROVIDE_IFELSE([AC_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], - [LT_LANG(GCJ)], - [AC_PROVIDE_IFELSE([LT_PROG_GCJ], - [LT_LANG(GCJ)], - [m4_ifdef([AC_PROG_GCJ], - [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([A][M_PROG_GCJ], - [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) - m4_ifdef([LT_PROG_GCJ], - [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) - -AC_PROVIDE_IFELSE([LT_PROG_RC], - [LT_LANG(RC)], - [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) -])# _LT_LANG_DEFAULT_CONFIG - -# Obsolete macros: -AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) -AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) -AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) -AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_CXX], []) -dnl AC_DEFUN([AC_LIBTOOL_F77], []) -dnl AC_DEFUN([AC_LIBTOOL_FC], []) -dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) - - -# _LT_TAG_COMPILER -# ---------------- -m4_defun([_LT_TAG_COMPILER], -[AC_REQUIRE([AC_PROG_CC])dnl - -_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl -_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl -_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl -_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl - -# If no C compiler was specified, use CC. -LTCC=${LTCC-"$CC"} - -# If no C compiler flags were specified, use CFLAGS. -LTCFLAGS=${LTCFLAGS-"$CFLAGS"} - -# Allow CC to be a program name with arguments. -compiler=$CC -])# _LT_TAG_COMPILER - - -# _LT_COMPILER_BOILERPLATE -# ------------------------ -# Check for compiler boilerplate output or warnings with -# the simple compiler test code. -m4_defun([_LT_COMPILER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_compile_test_code" >conftest.$ac_ext -eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_compiler_boilerplate=`cat conftest.err` -$RM conftest* -])# _LT_COMPILER_BOILERPLATE - - -# _LT_LINKER_BOILERPLATE -# ---------------------- -# Check for linker boilerplate output or warnings with -# the simple link test code. -m4_defun([_LT_LINKER_BOILERPLATE], -[m4_require([_LT_DECL_SED])dnl -ac_outfile=conftest.$ac_objext -echo "$lt_simple_link_test_code" >conftest.$ac_ext -eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err -_lt_linker_boilerplate=`cat conftest.err` -$RM -r conftest* -])# _LT_LINKER_BOILERPLATE - -# _LT_REQUIRED_DARWIN_CHECKS -# ------------------------- -m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ - case $host_os in - rhapsody* | darwin*) - AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) - AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) - AC_CHECK_TOOL([LIPO], [lipo], [:]) - AC_CHECK_TOOL([OTOOL], [otool], [:]) - AC_CHECK_TOOL([OTOOL64], [otool64], [:]) - _LT_DECL([], [DSYMUTIL], [1], - [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) - _LT_DECL([], [NMEDIT], [1], - [Tool to change global to local symbols on Mac OS X]) - _LT_DECL([], [LIPO], [1], - [Tool to manipulate fat objects and archives on Mac OS X]) - _LT_DECL([], [OTOOL], [1], - [ldd/readelf like tool for Mach-O binaries on Mac OS X]) - _LT_DECL([], [OTOOL64], [1], - [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) - - AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], - [lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then - # By default we will add the -single_module flag. You can override - # by either setting the environment variable LT_MULTI_MODULE - # non-empty at configure time, or by adding -multi_module to the - # link flags. - rm -rf libconftest.dylib* - echo "int foo(void){return 1;}" > conftest.c - echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ --dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD - $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ - -dynamiclib -Wl,-single_module conftest.c 2>conftest.err - _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then - lt_cv_apple_cc_single_mod=yes - else - cat conftest.err >&AS_MESSAGE_LOG_FD - fi - rm -rf libconftest.dylib* - rm -f conftest.* - fi]) - AC_CACHE_CHECK([for -exported_symbols_list linker flag], - [lt_cv_ld_exported_symbols_list], - [lt_cv_ld_exported_symbols_list=no - save_LDFLAGS=$LDFLAGS - echo "_main" > conftest.sym - LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [lt_cv_ld_exported_symbols_list=yes], - [lt_cv_ld_exported_symbols_list=no]) - LDFLAGS="$save_LDFLAGS" - ]) - case $host_os in - rhapsody* | darwin1.[[012]]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; - darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - esac - ;; - esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then - _lt_dar_single_mod='$single_module' - fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' - else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' - fi - if test "$DSYMUTIL" != ":"; then - _lt_dsymutil='~$DSYMUTIL $lib || :' - else - _lt_dsymutil= - fi - ;; - esac -]) - - -# _LT_DARWIN_LINKER_FEATURES -# -------------------------- -# Checks for linker and compiler features on darwin -m4_defun([_LT_DARWIN_LINKER_FEATURES], -[ - m4_require([_LT_REQUIRED_DARWIN_CHECKS]) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_automatic, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(whole_archive_flag_spec, $1)='' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" - case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; - *) _lt_dar_can_shared=$GCC ;; - esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" - m4_if([$1], [CXX], -[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then - _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" - _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" - fi -],[]) - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi -]) - -# _LT_SYS_MODULE_PATH_AIX -# ----------------------- -# Links a minimal program and checks the executable -# for the system default hardcoded library path. In most cases, -# this is /usr/lib:/lib, but when the MPI compilers are used -# the location of the communication and MPI libs are included too. -# If we don't find anything, use the default library path according -# to the aix ld manual. -m4_defun([_LT_SYS_MODULE_PATH_AIX], -[m4_require([_LT_DECL_SED])dnl -AC_LINK_IFELSE(AC_LANG_PROGRAM,[ -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi],[]) -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi -])# _LT_SYS_MODULE_PATH_AIX - - -# _LT_SHELL_INIT(ARG) -# ------------------- -m4_define([_LT_SHELL_INIT], -[ifdef([AC_DIVERSION_NOTICE], - [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) -$1 -AC_DIVERT_POP -])# _LT_SHELL_INIT - - -# _LT_PROG_ECHO_BACKSLASH -# ----------------------- -# Add some code to the start of the generated configure script which -# will find an echo command which doesn't interpret backslashes. -m4_defun([_LT_PROG_ECHO_BACKSLASH], -[_LT_SHELL_INIT([ -# Check that we are running under the correct shell. -SHELL=${CONFIG_SHELL-/bin/sh} - -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X[$]1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X[$]1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} -fi - -if test "X[$]1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -[$]* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL [$]0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "[$]0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" -fi - -AC_SUBST(lt_ECHO) -]) -_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) -_LT_DECL([], [ECHO], [1], - [An echo program that does not interpret backslashes]) -])# _LT_PROG_ECHO_BACKSLASH - - -# _LT_ENABLE_LOCK -# --------------- -m4_defun([_LT_ENABLE_LOCK], -[AC_ARG_ENABLE([libtool-lock], - [AS_HELP_STRING([--disable-libtool-lock], - [avoid locking (might break parallel builds)])]) -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes - -# Some flags need to be propagated to the compiler or linker for good -# libtool support. -case $host in -ia64-*-hpux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.$ac_objext` in - *ELF-32*) - HPUX_IA64_MODE="32" - ;; - *ELF-64*) - HPUX_IA64_MODE="64" - ;; - esac - fi - rm -rf conftest* - ;; -*-*-irix6*) - # Find out which ABI we are using. - echo '[#]line __oline__ "configure"' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - if test "$lt_cv_prog_gnu_ld" = yes; then - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -melf32bsmip" - ;; - *N32*) - LD="${LD-ld} -melf32bmipn32" - ;; - *64-bit*) - LD="${LD-ld} -melf64bmip" - ;; - esac - else - case `/usr/bin/file conftest.$ac_objext` in - *32-bit*) - LD="${LD-ld} -32" - ;; - *N32*) - LD="${LD-ld} -n32" - ;; - *64-bit*) - LD="${LD-ld} -64" - ;; - esac - fi - fi - rm -rf conftest* - ;; - -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *32-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_i386_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_i386" - ;; - ppc64-*linux*|powerpc64-*linux*) - LD="${LD-ld} -m elf32ppclinux" - ;; - s390x-*linux*) - LD="${LD-ld} -m elf_s390" - ;; - sparc64-*linux*) - LD="${LD-ld} -m elf32_sparc" - ;; - esac - ;; - *64-bit*) - case $host in - x86_64-*kfreebsd*-gnu) - LD="${LD-ld} -m elf_x86_64_fbsd" - ;; - x86_64-*linux*) - LD="${LD-ld} -m elf_x86_64" - ;; - ppc*-*linux*|powerpc*-*linux*) - LD="${LD-ld} -m elf64ppc" - ;; - s390*-*linux*|s390*-*tpf*) - LD="${LD-ld} -m elf64_s390" - ;; - sparc*-*linux*) - LD="${LD-ld} -m elf64_sparc" - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; - -*-*-sco3.2v5*) - # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -belf" - AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_LANG_PUSH(C) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) - AC_LANG_POP]) - if test x"$lt_cv_cc_needs_belf" != x"yes"; then - # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" - fi - ;; -sparc*-*solaris*) - # Find out which ABI we are using. - echo 'int i;' > conftest.$ac_ext - if AC_TRY_EVAL(ac_compile); then - case `/usr/bin/file conftest.o` in - *64-bit*) - case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; - *) - if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then - LD="${LD-ld} -64" - fi - ;; - esac - ;; - esac - fi - rm -rf conftest* - ;; -esac - -need_locks="$enable_libtool_lock" -])# _LT_ENABLE_LOCK - - -# _LT_CMD_OLD_ARCHIVE -# ------------------- -m4_defun([_LT_CMD_OLD_ARCHIVE], -[AC_CHECK_TOOL(AR, ar, false) -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru -_LT_DECL([], [AR], [1], [The archiver]) -_LT_DECL([], [AR_FLAGS], [1]) - -AC_CHECK_TOOL(STRIP, strip, :) -test -z "$STRIP" && STRIP=: -_LT_DECL([], [STRIP], [1], [A symbol stripping program]) - -AC_CHECK_TOOL(RANLIB, ranlib, :) -test -z "$RANLIB" && RANLIB=: -_LT_DECL([], [RANLIB], [1], - [Commands used to install an old-style archive]) - -# Determine commands to create old-style static archives. -old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' -old_postinstall_cmds='chmod 644 $oldlib' -old_postuninstall_cmds= - -if test -n "$RANLIB"; then - case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" - ;; - esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" -fi -_LT_DECL([], [old_postinstall_cmds], [2]) -_LT_DECL([], [old_postuninstall_cmds], [2]) -_LT_TAGDECL([], [old_archive_cmds], [2], - [Commands used to build an old-style archive]) -])# _LT_CMD_OLD_ARCHIVE - - -# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------------------- -# Check whether the given compiler option works -AC_DEFUN([_LT_COMPILER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$3" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - # The option is referenced via a variable to avoid confusing sed. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>conftest.err) - ac_status=$? - cat conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s "$ac_outfile"; then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - fi - $RM conftest* -]) - -if test x"[$]$2" = xyes; then - m4_if([$5], , :, [$5]) -else - m4_if([$6], , :, [$6]) -fi -])# _LT_COMPILER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) - - -# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, -# [ACTION-SUCCESS], [ACTION-FAILURE]) -# ---------------------------------------------------- -# Check whether the given linker option works -AC_DEFUN([_LT_LINKER_OPTION], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_SED])dnl -AC_CACHE_CHECK([$1], [$2], - [$2=no - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS $3" - echo "$lt_simple_link_test_code" > conftest.$ac_ext - if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then - # The linker can only warn and ignore the option if not recognized - # So say no if there are warnings - if test -s conftest.err; then - # Append any errors to the config.log. - cat conftest.err 1>&AS_MESSAGE_LOG_FD - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp - $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 - if diff conftest.exp conftest.er2 >/dev/null; then - $2=yes - fi - else - $2=yes - fi - fi - $RM -r conftest* - LDFLAGS="$save_LDFLAGS" -]) - -if test x"[$]$2" = xyes; then - m4_if([$4], , :, [$4]) -else - m4_if([$5], , :, [$5]) -fi -])# _LT_LINKER_OPTION - -# Old name: -AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) - - -# LT_CMD_MAX_LEN -#--------------- -AC_DEFUN([LT_CMD_MAX_LEN], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -# find the maximum length of command line arguments -AC_MSG_CHECKING([the maximum length of command line arguments]) -AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl - i=0 - teststring="ABCD" - - case $build_os in - msdosdjgpp*) - # On DJGPP, this test can blow up pretty badly due to problems in libc - # (any single argument exceeding 2000 bytes causes a buffer overrun - # during glob expansion). Even if it were fixed, the result of this - # check would be larger than it should be. - lt_cv_sys_max_cmd_len=12288; # 12K is about right - ;; - - gnu*) - # Under GNU Hurd, this test is not required because there is - # no limit to the length of command line arguments. - # Libtool will interpret -1 as no limit whatsoever - lt_cv_sys_max_cmd_len=-1; - ;; - - cygwin* | mingw* | cegcc*) - # On Win9x/ME, this test blows up -- it succeeds, but takes - # about 5 minutes as the teststring grows exponentially. - # Worse, since 9x/ME are not pre-emptively multitasking, - # you end up with a "frozen" computer, even though with patience - # the test eventually succeeds (with a max line length of 256k). - # Instead, let's just punt: use the minimum linelength reported by - # all of the supported platforms: 8192 (on NT/2K/XP). - lt_cv_sys_max_cmd_len=8192; - ;; - - amigaos*) - # On AmigaOS with pdksh, this test takes hours, literally. - # So we just punt and use a minimum line length of 8192. - lt_cv_sys_max_cmd_len=8192; - ;; - - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) - # This has been around since 386BSD, at least. Likely further. - if test -x /sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` - elif test -x /usr/sbin/sysctl; then - lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` - else - lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs - fi - # And add a safety zone - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - ;; - - interix*) - # We know the value 262144 and hardcode it with a safety zone (like BSD) - lt_cv_sys_max_cmd_len=196608 - ;; - - osf*) - # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure - # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not - # nice to cause kernel panics so lets avoid the loop below. - # First set a reasonable default. - lt_cv_sys_max_cmd_len=16384 - # - if test -x /sbin/sysconfig; then - case `/sbin/sysconfig -q proc exec_disable_arg_limit` in - *1*) lt_cv_sys_max_cmd_len=-1 ;; - esac - fi - ;; - sco3.2v5*) - lt_cv_sys_max_cmd_len=102400 - ;; - sysv5* | sco5v6* | sysv4.2uw2*) - kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` - if test -n "$kargmax"; then - lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` - else - lt_cv_sys_max_cmd_len=32768 - fi - ;; - *) - lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` - else - # Make teststring a little bigger before we do anything with it. - # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do - teststring=$teststring$teststring - done - SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} - # If test is not a shell built-in, we'll probably end up computing a - # maximum length that is only half of the actual maximum length, but - # we can't tell. - while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough - do - i=`expr $i + 1` - teststring=$teststring$teststring - done - # Only check the string length outside the loop. - lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` - teststring= - # Add a significant safety factor because C++ compilers can tack on - # massive amounts of additional arguments before passing them to the - # linker. It appears as though 1/2 is a usable value. - lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` - fi - ;; - esac -]) -if test -n $lt_cv_sys_max_cmd_len ; then - AC_MSG_RESULT($lt_cv_sys_max_cmd_len) -else - AC_MSG_RESULT(none) -fi -max_cmd_len=$lt_cv_sys_max_cmd_len -_LT_DECL([], [max_cmd_len], [0], - [What is the maximum length of a command?]) -])# LT_CMD_MAX_LEN - -# Old name: -AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) - - -# _LT_HEADER_DLFCN -# ---------------- -m4_defun([_LT_HEADER_DLFCN], -[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl -])# _LT_HEADER_DLFCN - - -# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, -# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) -# ---------------------------------------------------------------- -m4_defun([_LT_TRY_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "$cross_compiling" = yes; then : - [$4] -else - lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 - lt_status=$lt_dlunknown - cat > conftest.$ac_ext <<_LT_EOF -[#line __oline__ "configure" -#include "confdefs.h" - -#if HAVE_DLFCN_H -#include -#endif - -#include - -#ifdef RTLD_GLOBAL -# define LT_DLGLOBAL RTLD_GLOBAL -#else -# ifdef DL_GLOBAL -# define LT_DLGLOBAL DL_GLOBAL -# else -# define LT_DLGLOBAL 0 -# endif -#endif - -/* We may have to define LT_DLLAZY_OR_NOW in the command line if we - find out it does not work in some platform. */ -#ifndef LT_DLLAZY_OR_NOW -# ifdef RTLD_LAZY -# define LT_DLLAZY_OR_NOW RTLD_LAZY -# else -# ifdef DL_LAZY -# define LT_DLLAZY_OR_NOW DL_LAZY -# else -# ifdef RTLD_NOW -# define LT_DLLAZY_OR_NOW RTLD_NOW -# else -# ifdef DL_NOW -# define LT_DLLAZY_OR_NOW DL_NOW -# else -# define LT_DLLAZY_OR_NOW 0 -# endif -# endif -# endif -# endif -#endif - -void fnord() { int i=42;} -int main () -{ - void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); - int status = $lt_dlunknown; - - if (self) - { - if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; - /* dlclose (self); */ - } - else - puts (dlerror ()); - - return status; -}] -_LT_EOF - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then - (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null - lt_status=$? - case x$lt_status in - x$lt_dlno_uscore) $1 ;; - x$lt_dlneed_uscore) $2 ;; - x$lt_dlunknown|x*) $3 ;; - esac - else : - # compilation failed - $3 - fi -fi -rm -fr conftest* -])# _LT_TRY_DLOPEN_SELF - - -# LT_SYS_DLOPEN_SELF -# ------------------ -AC_DEFUN([LT_SYS_DLOPEN_SELF], -[m4_require([_LT_HEADER_DLFCN])dnl -if test "x$enable_dlopen" != xyes; then - enable_dlopen=unknown - enable_dlopen_self=unknown - enable_dlopen_self_static=unknown -else - lt_cv_dlopen=no - lt_cv_dlopen_libs= - - case $host_os in - beos*) - lt_cv_dlopen="load_add_on" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ;; - - mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" - lt_cv_dlopen_libs= - ;; - - cygwin*) - lt_cv_dlopen="dlopen" - lt_cv_dlopen_libs= - ;; - - darwin*) - # if libdl is installed we need to link against it - AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ - lt_cv_dlopen="dyld" - lt_cv_dlopen_libs= - lt_cv_dlopen_self=yes - ]) - ;; - - *) - AC_CHECK_FUNC([shl_load], - [lt_cv_dlopen="shl_load"], - [AC_CHECK_LIB([dld], [shl_load], - [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], - [AC_CHECK_FUNC([dlopen], - [lt_cv_dlopen="dlopen"], - [AC_CHECK_LIB([dl], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_LIB([svld], [dlopen], - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB([dld], [dld_link], - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) - ]) - ]) - ]) - ]) - ]) - ;; - esac - - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else - enable_dlopen=no - fi - - case $lt_cv_dlopen in - dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - - save_LDFLAGS="$LDFLAGS" - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - - save_LIBS="$LIBS" - LIBS="$lt_cv_dlopen_libs $LIBS" - - AC_CACHE_CHECK([whether a program can dlopen itself], - lt_cv_dlopen_self, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, - lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) - ]) - - if test "x$lt_cv_dlopen_self" = xyes; then - wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" - AC_CACHE_CHECK([whether a statically linked program can dlopen itself], - lt_cv_dlopen_self_static, [dnl - _LT_TRY_DLOPEN_SELF( - lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, - lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) - ]) - fi - - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" - ;; - esac - - case $lt_cv_dlopen_self in - yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; - *) enable_dlopen_self=unknown ;; - esac - - case $lt_cv_dlopen_self_static in - yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; - *) enable_dlopen_self_static=unknown ;; - esac -fi -_LT_DECL([dlopen_support], [enable_dlopen], [0], - [Whether dlopen is supported]) -_LT_DECL([dlopen_self], [enable_dlopen_self], [0], - [Whether dlopen of programs is supported]) -_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], - [Whether dlopen of statically linked programs is supported]) -])# LT_SYS_DLOPEN_SELF - -# Old name: -AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) - - -# _LT_COMPILER_C_O([TAGNAME]) -# --------------------------- -# Check to see if options -c and -o are simultaneously supported by compiler. -# This macro does not hard code the compiler like AC_PROG_CC_C_O. -m4_defun([_LT_COMPILER_C_O], -[m4_require([_LT_DECL_SED])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], - [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no - $RM -r conftest 2>/dev/null - mkdir conftest - cd conftest - mkdir out - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - lt_compiler_flag="-o out/conftest2.$ac_objext" - # Insert the option either (1) after the last *FLAGS variable, or - # (2) before a word containing "conftest.", or (3) at the end. - # Note that $ac_compile itself does not contain backslashes and begins - # with a dollar sign (not a hyphen), so the echo should work correctly. - lt_compile=`echo "$ac_compile" | $SED \ - -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ - -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ - -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$lt_compile" 2>out/conftest.err) - ac_status=$? - cat out/conftest.err >&AS_MESSAGE_LOG_FD - echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD - if (exit $ac_status) && test -s out/conftest2.$ac_objext - then - # The compiler can only warn and ignore the option if not recognized - # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp - $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 - if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then - _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - fi - fi - chmod u+w . 2>&AS_MESSAGE_LOG_FD - $RM conftest* - # SGI C++ compiler will create directory out/ii_files/ for - # template instantiation - test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files - $RM out/* && rmdir out - cd .. - $RM -r conftest - $RM conftest* -]) -_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], - [Does compiler simultaneously support -c and -o options?]) -])# _LT_COMPILER_C_O - - -# _LT_COMPILER_FILE_LOCKS([TAGNAME]) -# ---------------------------------- -# Check to see if we can do hard links to lock some files if needed -m4_defun([_LT_COMPILER_FILE_LOCKS], -[m4_require([_LT_ENABLE_LOCK])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -_LT_COMPILER_C_O([$1]) - -hard_links="nottested" -if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then - # do not overwrite the value of need_locks provided by the user - AC_MSG_CHECKING([if we can lock with hard links]) - hard_links=yes - $RM conftest* - ln conftest.a conftest.b 2>/dev/null && hard_links=no - touch conftest.a - ln conftest.a conftest.b 2>&5 || hard_links=no - ln conftest.a conftest.b 2>/dev/null && hard_links=no - AC_MSG_RESULT([$hard_links]) - if test "$hard_links" = no; then - AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) - need_locks=warn - fi -else - need_locks=no -fi -_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) -])# _LT_COMPILER_FILE_LOCKS - - -# _LT_CHECK_OBJDIR -# ---------------- -m4_defun([_LT_CHECK_OBJDIR], -[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], -[rm -f .libs 2>/dev/null -mkdir .libs 2>/dev/null -if test -d .libs; then - lt_cv_objdir=.libs -else - # MS-DOS does not allow filenames that begin with a dot. - lt_cv_objdir=_libs -fi -rmdir .libs 2>/dev/null]) -objdir=$lt_cv_objdir -_LT_DECL([], [objdir], [0], - [The name of the directory that contains temporary libtool files])dnl -m4_pattern_allow([LT_OBJDIR])dnl -AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", - [Define to the sub-directory in which libtool stores uninstalled libraries.]) -])# _LT_CHECK_OBJDIR - - -# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) -# -------------------------------------- -# Check hardcoding attributes. -m4_defun([_LT_LINKER_HARDCODE_LIBPATH], -[AC_MSG_CHECKING([how to hardcode library paths into programs]) -_LT_TAGVAR(hardcode_action, $1)= -if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || - test -n "$_LT_TAGVAR(runpath_var, $1)" || - test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then - - # We can hardcode non-existent directories. - if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && - # If the only mechanism to avoid hardcoding is shlibpath_var, we - # have to relink, otherwise we might link with an installed library - # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && - test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then - # Linking always hardcodes the temporary library directory. - _LT_TAGVAR(hardcode_action, $1)=relink - else - # We can link without hardcoding, and we can hardcode nonexisting dirs. - _LT_TAGVAR(hardcode_action, $1)=immediate - fi -else - # We cannot hardcode anything, or else we can only hardcode existing - # directories. - _LT_TAGVAR(hardcode_action, $1)=unsupported -fi -AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) - -if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || - test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then - # Fast installation is not supported - enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then - # Fast installation is not necessary - enable_fast_install=needless -fi -_LT_TAGDECL([], [hardcode_action], [0], - [How to hardcode a shared library path into an executable]) -])# _LT_LINKER_HARDCODE_LIBPATH - - -# _LT_CMD_STRIPLIB -# ---------------- -m4_defun([_LT_CMD_STRIPLIB], -[m4_require([_LT_DECL_EGREP]) -striplib= -old_striplib= -AC_MSG_CHECKING([whether stripping libraries is possible]) -if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then - test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" - test -z "$striplib" && striplib="$STRIP --strip-unneeded" - AC_MSG_RESULT([yes]) -else -# FIXME - insert some real tests, host_os isn't really good enough - case $host_os in - darwin*) - if test -n "$STRIP" ; then - striplib="$STRIP -x" - old_striplib="$STRIP -S" - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac -fi -_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) -_LT_DECL([], [striplib], [1]) -])# _LT_CMD_STRIPLIB - - -# _LT_SYS_DYNAMIC_LINKER([TAG]) -# ----------------------------- -# PORTME Fill in your ld.so characteristics -m4_defun([_LT_SYS_DYNAMIC_LINKER], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_OBJDUMP])dnl -m4_require([_LT_DECL_SED])dnl -AC_MSG_CHECKING([dynamic linker characteristics]) -m4_if([$1], - [], [ -if test "$GCC" = yes; then - case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; - esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then - # if the path contains ";" then we assume it to be the separator - # otherwise default to the standard path separator (i.e. ":") - it is - # assumed that no part of a normal pathname contains ";" but that should - # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. - lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` - for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else - test -d "$lt_sys_path" && \ - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" - fi - done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; - for (lt_i = NF; lt_i > 0; lt_i--) { - if ($lt_i != "" && $lt_i != ".") { - if ($lt_i == "..") { - lt_count++; - } else { - if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; - } else { - lt_count--; - } - } - } - } - if (lt_foo != "") { lt_freq[[lt_foo]]++; } - if (lt_freq[[lt_foo]] == 1) { print lt_foo; } -}'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` -else - sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" -fi]) -library_names_spec= -libname_spec='lib$name' -soname_spec= -shrext_cmds=".so" -postinstall_cmds= -postuninstall_cmds= -finish_cmds= -finish_eval= -shlibpath_var= -shlibpath_overrides_runpath=unknown -version_type=none -dynamic_linker="$host_os ld.so" -sys_lib_dlsearch_path_spec="/lib /usr/lib" -need_lib_prefix=unknown -hardcode_into_libs=no - -# when you set need_version to no, make sure it does not cause -set_version -# flags to be left without arguments -need_version=unknown - -case $host_os in -aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' - shlibpath_var=LIBPATH - - # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' - ;; - -aix[[4-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - hardcode_into_libs=yes - if test "$host_cpu" = ia64; then - # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - else - # With GCC up to 2.95.x, collect2 would create an import file - # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in - # development snapshots of GCC prior to 3.0. - case $host_os in - aix4 | aix4.[[01]] | aix4.[[01]].*) - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; - esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib.so - # instead of lib.a to let people know that these are not - # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else - # We preserve .a as extension for shared libraries through AIX4.2 - # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi - shlibpath_var=LIBPATH - fi - ;; - -amigaos*) - case $host_cpu in - powerpc) - # Since July 2007 AmigaOS4 officially supports .so libraries. - # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - ;; - m68k) - library_names_spec='$libname.ixlibrary $libname.a' - # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' - ;; - esac - ;; - -beos*) - library_names_spec='${libname}${shared_ext}' - dynamic_linker="$host_os ld.so" - shlibpath_var=LIBRARY_PATH - ;; - -bsdi[[45]]*) - version_type=linux - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" - sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" - # the default ld.so.conf also contains /usr/contrib/lib and - # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow - # libtool to hard-code these into programs - ;; - -cygwin* | mingw* | pw32* | cegcc*) - version_type=windows - shrext_cmds=".dll" - need_version=no - need_lib_prefix=no - - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) - library_names_spec='$libname.dll.a' - # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ - dldir=$destdir/`dirname \$dlpath`~ - test -d \$dldir || mkdir -p \$dldir~ - $install_prog $dir/$dlname \$dldir/$dlname~ - chmod a+x \$dldir/$dlname~ - if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then - eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; - fi' - postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ - dlpath=$dir/\$dldll~ - $RM \$dlpath' - shlibpath_overrides_runpath=yes - - case $host_os in - cygwin*) - # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" - ;; - mingw* | cegcc*) - # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi - ;; - pw32*) - # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' - ;; - esac - ;; - - *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' - ;; - esac - dynamic_linker='Win32 ld.exe' - # FIXME: first we should search . and the directory the executable is in - shlibpath_var=PATH - ;; - -darwin* | rhapsody*) - dynamic_linker="$host_os dyld" - version_type=darwin - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' - shlibpath_overrides_runpath=yes - shlibpath_var=DYLD_LIBRARY_PATH - shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' -m4_if([$1], [],[ - sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) - sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' - ;; - -dgux*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -freebsd1*) - dynamic_linker=no - ;; - -freebsd* | dragonfly*) - # DragonFly does not have aout. When/if they implement a new - # versioning mechanism, adjust this. - if test -x /usr/bin/objformat; then - objformat=`/usr/bin/objformat` - else - case $host_os in - freebsd[[123]]*) objformat=aout ;; - *) objformat=elf ;; - esac - fi - version_type=freebsd-$objformat - case $version_type in - freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - need_version=no - need_lib_prefix=no - ;; - freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' - need_version=yes - ;; - esac - shlibpath_var=LD_LIBRARY_PATH - case $host_os in - freebsd2*) - shlibpath_overrides_runpath=yes - ;; - freebsd3.[[01]]* | freebsdelf3.[[01]]*) - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ - freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - *) # from 4.6 on, and DragonFly - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - esac - ;; - -gnu*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - hardcode_into_libs=yes - ;; - -hpux9* | hpux10* | hpux11*) - # Give a soname corresponding to the major version so that dld.sl refuses to - # link against other versions. - version_type=sunos - need_lib_prefix=no - need_version=no - case $host_cpu in - ia64*) - shrext_cmds='.so' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.so" - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then - sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" - else - sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" - fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - hppa*64*) - shrext_cmds='.sl' - hardcode_into_libs=yes - dynamic_linker="$host_os dld.sl" - shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH - shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec - ;; - *) - shrext_cmds='.sl' - dynamic_linker="$host_os dld.sl" - shlibpath_var=SHLIB_PATH - shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - ;; - esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. - postinstall_cmds='chmod 555 $lib' - ;; - -interix[[3-9]]*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -irix5* | irix6* | nonstopux*) - case $host_os in - nonstopux*) version_type=nonstopux ;; - *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux - else - version_type=irix - fi ;; - esac - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' - case $host_os in - irix5* | nonstopux*) - libsuff= shlibsuff= - ;; - *) - case $LD in # libtool.m4 will add one of these switches to LD - *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") - libsuff= shlibsuff= libmagic=32-bit;; - *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") - libsuff=32 shlibsuff=N32 libmagic=N32;; - *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") - libsuff=64 shlibsuff=64 libmagic=64-bit;; - *) libsuff= shlibsuff= libmagic=never-match;; - esac - ;; - esac - shlibpath_var=LD_LIBRARY${shlibsuff}_PATH - shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" - hardcode_into_libs=yes - ;; - -# No shared lib support for Linux oldld, aout, or coff. -linux*oldld* | linux*aout* | linux*coff*) - dynamic_linker=no - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ - LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" - AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], - [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], - [shlibpath_overrides_runpath=yes])]) - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir - - # This implies no fast_install, which is unacceptable. - # Some rework will be needed to allow for fast_install - # before this can be enabled. - hardcode_into_libs=yes - - # Append ld.so.conf contents to the search path - if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` - sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" - fi - - # We used to test for /lib/ld.so.1 and disable shared libraries on - # powerpc, because MkLinux only supported shared libraries with the - # GNU dynamic linker. Since this was broken with cross compilers, - # most powerpc-linux boxes support dynamic linking these days and - # people can always --disable-shared, the test was removed, and we - # assume the GNU/Linux dynamic linker is in use. - dynamic_linker='GNU/Linux ld.so' - ;; - -netbsd*) - version_type=sunos - need_lib_prefix=no - need_version=no - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - dynamic_linker='NetBSD (a.out) ld.so' - else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - dynamic_linker='NetBSD ld.elf_so' - fi - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - ;; - -newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - -*nto* | *qnx*) - version_type=qnx - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - dynamic_linker='ldqnx.so' - ;; - -openbsd*) - version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" - need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' - shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[[89]] | openbsd2.[[89]].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi - ;; - -os2*) - libname_spec='$name' - shrext_cmds=".dll" - need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' - dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH - ;; - -osf3* | osf4* | osf5*) - version_type=osf - need_lib_prefix=no - need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" - ;; - -rdos*) - dynamic_linker=no - ;; - -solaris*) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - # ldd complains unless libraries are executable - postinstall_cmds='chmod +x $lib' - ;; - -sunos4*) - version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' - finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - fi - need_version=yes - ;; - -sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - case $host_vendor in - sni) - shlibpath_overrides_runpath=no - need_lib_prefix=no - runpath_var=LD_RUN_PATH - ;; - siemens) - need_lib_prefix=no - ;; - motorola) - need_lib_prefix=no - need_version=no - shlibpath_overrides_runpath=no - sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' - ;; - esac - ;; - -sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' - shlibpath_var=LD_LIBRARY_PATH - fi - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then - sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' - else - sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' - case $host_os in - sco3.2v5*) - sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" - ;; - esac - fi - sys_lib_dlsearch_path_spec='/usr/lib' - ;; - -tpf*) - # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=no - hardcode_into_libs=yes - ;; - -uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH - ;; - -*) - dynamic_linker=no - ;; -esac -AC_MSG_RESULT([$dynamic_linker]) -test "$dynamic_linker" = no && can_build_shared=no - -variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then - variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" -fi - -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" -fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" -fi - -_LT_DECL([], [variables_saved_for_relink], [1], - [Variables whose values should be saved in libtool wrapper scripts and - restored at link time]) -_LT_DECL([], [need_lib_prefix], [0], - [Do we need the "lib" prefix for modules?]) -_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) -_LT_DECL([], [version_type], [0], [Library versioning type]) -_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) -_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) -_LT_DECL([], [shlibpath_overrides_runpath], [0], - [Is shlibpath searched before the hard-coded library search path?]) -_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) -_LT_DECL([], [library_names_spec], [1], - [[List of archive names. First name is the real one, the rest are links. - The last name is the one that the linker finds with -lNAME]]) -_LT_DECL([], [soname_spec], [1], - [[The coded name of the library, if different from the real name]]) -_LT_DECL([], [postinstall_cmds], [2], - [Command to use after installation of a shared archive]) -_LT_DECL([], [postuninstall_cmds], [2], - [Command to use after uninstallation of a shared archive]) -_LT_DECL([], [finish_cmds], [2], - [Commands used to finish a libtool library installation in a directory]) -_LT_DECL([], [finish_eval], [1], - [[As "finish_cmds", except a single script fragment to be evaled but - not shown]]) -_LT_DECL([], [hardcode_into_libs], [0], - [Whether we should hardcode library paths into libraries]) -_LT_DECL([], [sys_lib_search_path_spec], [2], - [Compile-time system search path for libraries]) -_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], - [Run-time system search path for libraries]) -])# _LT_SYS_DYNAMIC_LINKER - - -# _LT_PATH_TOOL_PREFIX(TOOL) -# -------------------------- -# find a file program which can recognize shared library -AC_DEFUN([_LT_PATH_TOOL_PREFIX], -[m4_require([_LT_DECL_EGREP])dnl -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, -[case $MAGIC_CMD in -[[\\/*] | ?:[\\/]*]) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. - ;; -*) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR -dnl $ac_dummy forces splitting on constant user-supplied paths. -dnl POSIX.2 word splitting is done only on the output of word expansions, -dnl not every word. This closes a longstanding sh security hole. - ac_dummy="m4_if([$2], , $PATH, [$2])" - for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/$1; then - lt_cv_path_MAGIC_CMD="$ac_dir/$1" - if test -n "$file_magic_test_file"; then - case $deplibs_check_method in - "file_magic "*) - file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" - if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | - $EGREP "$file_magic_regex" > /dev/null; then - : - else - cat <<_LT_EOF 1>&2 - -*** Warning: the command libtool uses to detect shared libraries, -*** $file_magic_cmd, produces output that libtool cannot recognize. -*** The result is that libtool may fail to recognize shared libraries -*** as such. This will affect the creation of libtool libraries that -*** depend on shared libraries, but programs linked with such libtool -*** libraries will work regardless of this problem. Nevertheless, you -*** may want to report the problem to your system manager and/or to -*** bug-libtool@gnu.org - -_LT_EOF - fi ;; - esac - fi - break - fi - done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" - ;; -esac]) -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" -if test -n "$MAGIC_CMD"; then - AC_MSG_RESULT($MAGIC_CMD) -else - AC_MSG_RESULT(no) -fi -_LT_DECL([], [MAGIC_CMD], [0], - [Used to examine libraries when file_magic_cmd begins with "file"])dnl -])# _LT_PATH_TOOL_PREFIX - -# Old name: -AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) - - -# _LT_PATH_MAGIC -# -------------- -# find a file program which can recognize a shared library -m4_defun([_LT_PATH_MAGIC], -[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) -if test -z "$lt_cv_path_MAGIC_CMD"; then - if test -n "$ac_tool_prefix"; then - _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) - else - MAGIC_CMD=: - fi -fi -])# _LT_PATH_MAGIC - - -# LT_PATH_LD -# ---------- -# find the pathname to the GNU or non-GNU linker -AC_DEFUN([LT_PATH_LD], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_CANONICAL_BUILD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_ARG_WITH([gnu-ld], - [AS_HELP_STRING([--with-gnu-ld], - [assume the C compiler uses GNU ld @<:@default=no@:>@])], - [test "$withval" = no || with_gnu_ld=yes], - [with_gnu_ld=no])dnl - -ac_prog=ld -if test "$GCC" = yes; then - # Check if gcc -print-prog-name=ld gives a path. - AC_MSG_CHECKING([for ld used by $CC]) - case $host in - *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw - ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; - *) - ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; - esac - case $ac_prog in - # Accept absolute paths. - [[\\/]]* | ?:[[\\/]]*) - re_direlt='/[[^/]][[^/]]*/\.\./' - # Canonicalize the pathname of ld - ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` - while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do - ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` - done - test -z "$LD" && LD="$ac_prog" - ;; - "") - # If it fails, then pretend we aren't using GCC. - ac_prog=ld - ;; - *) - # If it is relative, then search for the first ld in PATH. - with_gnu_ld=unknown - ;; - esac -elif test "$with_gnu_ld" = yes; then - AC_MSG_CHECKING([for GNU ld]) -else - AC_MSG_CHECKING([for non-GNU ld]) -fi -AC_CACHE_VAL(lt_cv_path_LD, -[if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" - # Check to see if the program is GNU ld. I'd rather use --version, - # but apparently some variants of GNU ld only accept -v. - # Break only if it was the GNU/non-GNU ld that we prefer. - case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then - lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' - lt_cv_file_magic_cmd='func_win32_libid' - else - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - fi - ;; - -cegcc) - # use the weaker test based on 'objdump'. See mingw*. - lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' - lt_cv_file_magic_cmd='$OBJDUMP -f' - ;; - -darwin* | rhapsody*) - lt_cv_deplibs_check_method=pass_all - ;; - -freebsd* | dragonfly*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - case $host_cpu in - i*86 ) - # Not sure whether the presence of OpenBSD here was a mistake. - # Let's accept both of them until this is cleared up. - lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` - ;; - esac - else - lt_cv_deplibs_check_method=pass_all - fi - ;; - -gnu*) - lt_cv_deplibs_check_method=pass_all - ;; - -hpux10.20* | hpux11*) - lt_cv_file_magic_cmd=/usr/bin/file - case $host_cpu in - ia64*) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' - lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so - ;; - hppa*64*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] - lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl - ;; - *) - lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' - lt_cv_file_magic_test_file=/usr/lib/libc.sl - ;; - esac - ;; - -interix[[3-9]]*) - # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' - ;; - -irix5* | irix6* | nonstopux*) - case $LD in - *-32|*"-32 ") libmagic=32-bit;; - *-n32|*"-n32 ") libmagic=N32;; - *-64|*"-64 ") libmagic=64-bit;; - *) libmagic=never-match;; - esac - lt_cv_deplibs_check_method=pass_all - ;; - -# This must be Linux ELF. -linux* | k*bsd*-gnu) - lt_cv_deplibs_check_method=pass_all - ;; - -netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' - fi - ;; - -newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file - lt_cv_file_magic_test_file=/usr/lib/libnls.so - ;; - -*nto* | *qnx*) - lt_cv_deplibs_check_method=pass_all - ;; - -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' - else - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' - fi - ;; - -osf3* | osf4* | osf5*) - lt_cv_deplibs_check_method=pass_all - ;; - -rdos*) - lt_cv_deplibs_check_method=pass_all - ;; - -solaris*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - lt_cv_deplibs_check_method=pass_all - ;; - -sysv4 | sysv4.3*) - case $host_vendor in - motorola) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' - lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` - ;; - ncr) - lt_cv_deplibs_check_method=pass_all - ;; - sequent) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' - ;; - sni) - lt_cv_file_magic_cmd='/bin/file' - lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" - lt_cv_file_magic_test_file=/lib/libc.so - ;; - siemens) - lt_cv_deplibs_check_method=pass_all - ;; - pc) - lt_cv_deplibs_check_method=pass_all - ;; - esac - ;; - -tpf*) - lt_cv_deplibs_check_method=pass_all - ;; -esac -]) -file_magic_cmd=$lt_cv_file_magic_cmd -deplibs_check_method=$lt_cv_deplibs_check_method -test -z "$deplibs_check_method" && deplibs_check_method=unknown - -_LT_DECL([], [deplibs_check_method], [1], - [Method to check whether dependent libraries are shared objects]) -_LT_DECL([], [file_magic_cmd], [1], - [Command to use when deplibs_check_method == "file_magic"]) -])# _LT_CHECK_MAGIC_METHOD - - -# LT_PATH_NM -# ---------- -# find the pathname to a BSD- or MS-compatible name lister -AC_DEFUN([LT_PATH_NM], -[AC_REQUIRE([AC_PROG_CC])dnl -AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, -[if test -n "$NM"; then - # Let the user override the test. - lt_cv_path_NM="$NM" -else - lt_nm_to_check="${ac_tool_prefix}nm" - if test -n "$ac_tool_prefix" && test "$build" = "$host"; then - lt_nm_to_check="$lt_nm_to_check nm" - fi - for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" - test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then - # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: - # nm: unknown option "B" ignored - # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) - lt_cv_path_NM="$tmp_nm -B" - break - ;; - *) - case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in - */dev/null*) - lt_cv_path_NM="$tmp_nm -p" - break - ;; - *) - lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but - continue # so that we can try to find one that supports BSD flags - ;; - esac - ;; - esac - fi - done - IFS="$lt_save_ifs" - done - : ${lt_cv_path_NM=no} -fi]) -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" -else - # Didn't find any BSD compatible name lister, look for dumpbin. - AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) - AC_SUBST([DUMPBIN]) - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" - fi -fi -test -z "$NM" && NM=nm -AC_SUBST([NM]) -_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl - -AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], - [lt_cv_nm_interface="BSD nm" - echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) - (eval "$ac_compile" 2>conftest.err) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) - (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) - cat conftest.err >&AS_MESSAGE_LOG_FD - (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) - cat conftest.out >&AS_MESSAGE_LOG_FD - if $GREP 'External.*some_variable' conftest.out > /dev/null; then - lt_cv_nm_interface="MS dumpbin" - fi - rm -f conftest*]) -])# LT_PATH_NM - -# Old names: -AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) -AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_PROG_NM], []) -dnl AC_DEFUN([AC_PROG_NM], []) - - -# LT_LIB_M -# -------- -# check for math library -AC_DEFUN([LT_LIB_M], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -LIBM= -case $host in -*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) - # These system don't have libm, or don't need it - ;; -*-ncr-sysv4.3*) - AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") - AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") - ;; -*) - AC_CHECK_LIB(m, cos, LIBM="-lm") - ;; -esac -AC_SUBST([LIBM]) -])# LT_LIB_M - -# Old name: -AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_CHECK_LIBM], []) - - -# _LT_COMPILER_NO_RTTI([TAGNAME]) -# ------------------------------- -m4_defun([_LT_COMPILER_NO_RTTI], -[m4_require([_LT_TAG_COMPILER])dnl - -_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - -if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - - _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], - lt_cv_prog_compiler_rtti_exceptions, - [-fno-rtti -fno-exceptions], [], - [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) -fi -_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], - [Compiler flag to turn off builtin functions]) -])# _LT_COMPILER_NO_RTTI - - -# _LT_CMD_GLOBAL_SYMBOLS -# ---------------------- -m4_defun([_LT_CMD_GLOBAL_SYMBOLS], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -AC_REQUIRE([AC_PROG_CC])dnl -AC_REQUIRE([LT_PATH_NM])dnl -AC_REQUIRE([LT_PATH_LD])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_TAG_COMPILER])dnl - -# Check for command to grab the raw symbol name followed by C symbol from nm. -AC_MSG_CHECKING([command to parse $NM output from $compiler object]) -AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], -[ -# These are sane defaults that work on at least a few old systems. -# [They come from Ultrix. What could be older than Ultrix?!! ;)] - -# Character class describing NM global symbol codes. -symcode='[[BCDEGRST]]' - -# Regexp to match symbols that can be accessed directly from C. -sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' - -# Define system-specific variables. -case $host_os in -aix*) - symcode='[[BCDT]]' - ;; -cygwin* | mingw* | pw32* | cegcc*) - symcode='[[ABCDGISTW]]' - ;; -hpux*) - if test "$host_cpu" = ia64; then - symcode='[[ABCDEGRST]]' - fi - ;; -irix* | nonstopux*) - symcode='[[BCDEGRST]]' - ;; -osf*) - symcode='[[BCDEGQRST]]' - ;; -solaris*) - symcode='[[BDRT]]' - ;; -sco3.2v5*) - symcode='[[DT]]' - ;; -sysv4.2uw2*) - symcode='[[DT]]' - ;; -sysv5* | sco5v6* | unixware* | OpenUNIX*) - symcode='[[ABDT]]' - ;; -sysv4) - symcode='[[DFNSTU]]' - ;; -esac - -# If we're using GNU nm, then use its standard symbol codes. -case `$NM -V 2>&1` in -*GNU* | *'with BFD'*) - symcode='[[ABCDGIRSTW]]' ;; -esac - -# Transform an extracted symbol line into a proper C declaration. -# Some systems (esp. on ia64) link data and code symbols differently, -# so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" - -# Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" - -# Handle CRLF in mingw tool chain -opt_cr= -case $build_os in -mingw*) - opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp - ;; -esac - -# Try without a prefix underscore, then with it. -for ac_symprfx in "" "_"; do - - # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. - symxfrm="\\1 $ac_symprfx\\2 \\2" - - # Write the raw and C identifiers. - if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. - # Also find C++ and __fastcall symbols from MSVC++, - # which start with @ or ?. - lt_cv_sys_global_symbol_pipe="$AWK ['"\ -" {last_section=section; section=\$ 3};"\ -" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ -" \$ 0!~/External *\|/{next};"\ -" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ -" {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ -" ' prfx=^$ac_symprfx]" - else - lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" - fi - - # Check to see that the pipe works correctly. - pipe_works=no - - rm -f conftest* - cat > conftest.$ac_ext <<_LT_EOF -#ifdef __cplusplus -extern "C" { -#endif -char nm_test_var; -void nm_test_func(void); -void nm_test_func(void){} -#ifdef __cplusplus -} -#endif -int main(){nm_test_var='a';nm_test_func();return(0);} -_LT_EOF - - if AC_TRY_EVAL(ac_compile); then - # Now try to grab the symbols. - nlist=conftest.nm - if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then - # Try sorting and uniquifying the output. - if sort "$nlist" | uniq > "$nlist"T; then - mv -f "$nlist"T "$nlist" - else - rm -f "$nlist"T - fi - - # Make sure that we snagged all the symbols we need. - if $GREP ' nm_test_var$' "$nlist" >/dev/null; then - if $GREP ' nm_test_func$' "$nlist" >/dev/null; then - cat <<_LT_EOF > conftest.$ac_ext -#ifdef __cplusplus -extern "C" { -#endif - -_LT_EOF - # Now generate the symbol file. - eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' - - cat <<_LT_EOF >> conftest.$ac_ext - -/* The mapping between symbol names and symbols. */ -const struct { - const char *name; - void *address; -} -lt__PROGRAM__LTX_preloaded_symbols[[]] = -{ - { "@PROGRAM@", (void *) 0 }, -_LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext - cat <<\_LT_EOF >> conftest.$ac_ext - {0, (void *) 0} -}; - -/* This works around a problem in FreeBSD linker */ -#ifdef FREEBSD_WORKAROUND -static const void *lt_preloaded_setup() { - return lt__PROGRAM__LTX_preloaded_symbols; -} -#endif - -#ifdef __cplusplus -} -#endif -_LT_EOF - # Now try linking the two files. - mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" - CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" - if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then - pipe_works=yes - fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" - else - echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD - fi - else - echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD - fi - else - echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD - cat conftest.$ac_ext >&5 - fi - rm -rf conftest* conftst* - - # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then - break - else - lt_cv_sys_global_symbol_pipe= - fi -done -]) -if test -z "$lt_cv_sys_global_symbol_pipe"; then - lt_cv_sys_global_symbol_to_cdecl= -fi -if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - AC_MSG_RESULT(failed) -else - AC_MSG_RESULT(ok) -fi - -_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], - [Take the output of nm and produce a listing of raw symbols and C names]) -_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], - [Transform the output of nm in a proper C declaration]) -_LT_DECL([global_symbol_to_c_name_address], - [lt_cv_sys_global_symbol_to_c_name_address], [1], - [Transform the output of nm in a C name address pair]) -_LT_DECL([global_symbol_to_c_name_address_lib_prefix], - [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], - [Transform the output of nm in a C name address pair when lib prefix is needed]) -]) # _LT_CMD_GLOBAL_SYMBOLS - - -# _LT_COMPILER_PIC([TAGNAME]) -# --------------------------- -m4_defun([_LT_COMPILER_PIC], -[m4_require([_LT_TAG_COMPILER])dnl -_LT_TAGVAR(lt_prog_compiler_wl, $1)= -_LT_TAGVAR(lt_prog_compiler_pic, $1)= -_LT_TAGVAR(lt_prog_compiler_static, $1)= - -AC_MSG_CHECKING([for $compiler option to produce PIC]) -m4_if([$1], [CXX], [ - # C++ specific cases for pic, static, wl, etc. - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - *djgpp*) - # DJGPP does not support shared libraries at all - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - case $host_os in - aix[[4-9]]*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - chorus*) - case $cc_basename in - cxch68*) - # Green Hills C++ Compiler - # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" - ;; - esac - ;; - dgux*) - case $cc_basename in - ec++*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - ghcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - freebsd* | dragonfly*) - # FreeBSD uses GNU C++ - ;; - hpux9* | hpux10* | hpux11*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - if test "$host_cpu" != ia64; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - fi - ;; - aCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - ;; - *) - ;; - esac - ;; - interix*) - # This is c89, which is MS Visual C++ (no shared libs) - # Anyone wants to do a port? - ;; - irix5* | irix6* | nonstopux*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - # CC pic flag -KPIC is the default. - ;; - *) - ;; - esac - ;; - linux* | k*bsd*-gnu) - case $cc_basename in - KCC*) - # KAI C++ Compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - ecpc* ) - # old Intel C++ for x86_64 which still supported -KPIC. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - icpc* ) - # Intel C++, used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - cxx*) - # Compaq C++ - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xlc* | xlC*) - # IBM XL 8.0 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - esac - ;; - esac - ;; - lynxos*) - ;; - m88k*) - ;; - mvs*) - case $cc_basename in - cxx*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' - ;; - *) - ;; - esac - ;; - netbsd*) - ;; - *qnx* | *nto*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' - ;; - RCC*) - # Rational C++ 2.4.1 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - cxx*) - # Digital/Compaq C++ - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # Make sure the PIC flag is empty. It appears that all Alpha - # Linux and Compaq Tru64 Unix objects are PIC. - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - *) - ;; - esac - ;; - psos*) - ;; - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - ;; - *) - ;; - esac - ;; - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - lcc*) - # Lucid - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - ;; - *) - ;; - esac - ;; - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - case $cc_basename in - CC*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - esac - ;; - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - ;; - *) - ;; - esac - ;; - vxworks*) - ;; - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -], -[ - if test "$GCC" = yes; then - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - - case $host_os in - aix*) - # All AIX code is PIC. - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - m68k) - # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' - ;; - esac - ;; - - beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) - # PIC is the default for these OSes. - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - # Although the cygwin gcc ignores -fPIC, still need this for old-style - # (--disable-auto-import) libraries - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - darwin* | rhapsody*) - # PIC is the default on this platform - # Common symbols not allowed in MH_DYLIB files - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' - ;; - - hpux*) - # PIC is the default for 64-bit PA HP-UX, but not for 32-bit - # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag - # sets the default TLS model and affects inlining. - case $host_cpu in - hppa*64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - ;; - - interix[[3-9]]*) - # Interix 3.x gcc -fpic/-fPIC options generate broken code. - # Instead, we relocate shared libraries at runtime. - ;; - - msdosdjgpp*) - # Just because we use GCC doesn't mean we suddenly get shared libraries - # on systems that don't support them. - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - enable_shared=no - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic - fi - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - ;; - esac - else - # PORTME Check for flag to pass linker flags through the system compiler. - case $host_os in - aix*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - else - _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' - fi - ;; - - mingw* | cygwin* | pw32* | os2* | cegcc*) - # This hack is so that the source file can tell whether it is being - # built for inclusion in a dll (and should export symbols for example). - m4_if([$1], [GCJ], [], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) - ;; - - hpux9* | hpux10* | hpux11*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but - # not for PA HP-UX. - case $host_cpu in - hppa*64*|ia64*) - # +Z the default - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' - ;; - esac - # Is there a better lt_prog_compiler_static that works with the bundled CC? - _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' - ;; - - irix5* | irix6* | nonstopux*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # PIC (with -KPIC) is the default. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. - ecc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # icc used to be incompatible with GCC. - # ICC 10 doesn't accept -KPIC any more. - icc* | ifort*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' - ;; - # Lahey Fortran 8.1. - lf95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' - _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' - ;; - pgcc* | pgf77* | pgf90* | pgf95*) - # Portland Group compilers (*not* the Pentium gcc compiler, - # which looks to be a dead project) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - ccc*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All Alpha code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C 5.9 - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - _LT_TAGVAR(lt_prog_compiler_wl, $1)='' - ;; - esac - ;; - esac - ;; - - newsos6) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *nto* | *qnx*) - # QNX uses GNU C++, but need to define -shared option too, otherwise - # it will coredump. - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' - ;; - - osf3* | osf4* | osf5*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - # All OSF/1 code is PIC. - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - rdos*) - _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' - ;; - - solaris*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - case $cc_basename in - f77* | f90* | f95*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; - *) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; - esac - ;; - - sunos4*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4 | sysv4.2uw2* | sysv4.3*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - sysv4*MP*) - if test -d /usr/nec ;then - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - fi - ;; - - sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - unicos*) - _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - - uts4*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' - _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' - ;; - - *) - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no - ;; - esac - fi -]) -case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: - *djgpp*) - _LT_TAGVAR(lt_prog_compiler_pic, $1)= - ;; - *) - _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" - ;; -esac -AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) -_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], - [How to pass a linker flag through the compiler]) - -# -# Check to make sure the PIC flag actually works. -# -if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then - _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], - [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], - [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], - [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in - "" | " "*) ;; - *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; - esac], - [_LT_TAGVAR(lt_prog_compiler_pic, $1)= - _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) -fi -_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], - [Additional compiler flags for building library objects]) - -# -# Check to make sure the static flag actually works. -# -wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" -_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], - _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), - $lt_tmp_static_flag, - [], - [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) -_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], - [Compiler flag to prevent dynamic linking]) -])# _LT_COMPILER_PIC - - -# _LT_LINKER_SHLIBS([TAGNAME]) -# ---------------------------- -# See if the linker supports building shared libraries. -m4_defun([_LT_LINKER_SHLIBS], -[AC_REQUIRE([LT_PATH_LD])dnl -AC_REQUIRE([LT_PATH_NM])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl -m4_require([_LT_DECL_SED])dnl -m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl -m4_require([_LT_TAG_COMPILER])dnl -AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) -m4_if([$1], [CXX], [ - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - case $host_os in - aix[[4-9]]*) - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - ;; - pw32*) - _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" - ;; - cygwin* | mingw* | cegcc*) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' - ;; - *) - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - ;; - esac - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] -], [ - runpath_var= - _LT_TAGVAR(allow_undefined_flag, $1)= - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(archive_cmds, $1)= - _LT_TAGVAR(archive_expsym_cmds, $1)= - _LT_TAGVAR(compiler_needs_object, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' - _LT_TAGVAR(hardcode_automatic, $1)=no - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= - _LT_TAGVAR(hardcode_libdir_separator, $1)= - _LT_TAGVAR(hardcode_minus_L, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported - _LT_TAGVAR(inherit_rpath, $1)=no - _LT_TAGVAR(link_all_deplibs, $1)=unknown - _LT_TAGVAR(module_cmds, $1)= - _LT_TAGVAR(module_expsym_cmds, $1)= - _LT_TAGVAR(old_archive_from_new_cmds, $1)= - _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= - _LT_TAGVAR(thread_safe_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - # include_expsyms should be a list of space-separated symbols to be *always* - # included in the symbol list - _LT_TAGVAR(include_expsyms, $1)= - # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. - _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] - # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out - # platforms (ab)use it in PIC code, but their linkers get confused if - # the symbol is explicitly referenced. Since portable code cannot - # rely on this symbol name, it's probably fine to never include it in - # preloaded symbol tables. - # Exclude shared library initialization/finalization symbols. -dnl Note also adjust exclude_expsyms for C++ above. - extract_expsyms_cmds= - - case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - if test "$GCC" != yes; then - with_gnu_ld=no - fi - ;; - interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) - with_gnu_ld=yes - ;; - openbsd*) - with_gnu_ld=no - ;; - esac - - _LT_TAGVAR(ld_shlibs, $1)=yes - if test "$with_gnu_ld" = yes; then - # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' - - # Set some defaults for GNU ld with shared library support. These - # are reset later if shared libraries are not supported. Putting them - # here allows them to be overridden if necessary. - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - # ancient GNU ld didn't support --whole-archive et. al. - if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - supports_anon_versioning=no - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 - *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... - *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... - *\ 2.11.*) ;; # other 2.11 versions - *) supports_anon_versioning=yes ;; - esac - - # See if GNU ld supports shared libraries. - case $host_os in - aix[[3-9]]*) - # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: the GNU linker, at least up to release 2.9.1, is reported -*** to be unable to reliably create shared libraries on AIX. -*** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. - -_LT_EOF - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - - gnu* | linux* | tpf* | k*bsd*-gnu) - tmp_diet=no - if test "$host_os" = linux-dietlibc; then - case $cc_basename in - diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) - esac - fi - if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no - then - tmp_addflag= - tmp_sharedflag='-shared' - case $cc_basename,$host_cpu in - pgcc*) # Portland Group C compiler - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag' - ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - tmp_addflag=' $pic_flag -Mnomain' ;; - ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 - tmp_addflag=' -i_dynamic' ;; - efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 - tmp_addflag=' -i_dynamic -nofor_main' ;; - ifc* | ifort*) # Intel Fortran compiler - tmp_addflag=' -nofor_main' ;; - lf95*) # Lahey Fortran 8.1 - _LT_TAGVAR(whole_archive_flag_spec, $1)= - tmp_sharedflag='--shared' ;; - xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) - tmp_sharedflag='-qmkshrobj' - tmp_addflag= ;; - esac - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) # Sun C 5.9 - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - tmp_sharedflag='-G' ;; - *Sun\ F*) # Sun Fortran 8.3 - tmp_sharedflag='-G' ;; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - - case $cc_basename in - xlf*) - # IBM XL Fortran 10.1 on PPC cannot create shared libs itself - _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' - _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' - fi - ;; - esac - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' - wlarc= - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - fi - ;; - - solaris*) - if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: The releases 2.8.* of the GNU linker cannot reliably -*** create shared libraries on Solaris systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.9.1 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) - case `$LD -v 2>&1` in - *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) - _LT_TAGVAR(ld_shlibs, $1)=no - cat <<_LT_EOF 1>&2 - -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not -*** reliably create shared libraries on SCO systems. Therefore, libtool -*** is disabling shared libraries support. We urge you to upgrade GNU -*** binutils to release 2.16.91.0.3 or newer. Another option is to modify -*** your PATH or compiler configuration so that the native linker is -*** used, and then restart. - -_LT_EOF - ;; - *) - # For security reasons, it is highly recommended that you always - # use absolute paths for naming shared libraries, and exclude the - # DT_RUNPATH tag from executables and libraries. But doing so - # requires that you compile everything twice, which is a pain. - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - sunos4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - - if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then - runpath_var= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= - _LT_TAGVAR(export_dynamic_flag_spec, $1)= - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - # PORTME fill in a description of your system's linker (not GNU ld) - case $host_os in - aix3*) - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=yes - _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' - # Note: this linker hardcodes the directories in LIBPATH if there - # are no directories specified by -L. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then - # Neither direct hardcoding nor static linking is supported with a - # broken collect2. - _LT_TAGVAR(hardcode_direct, $1)=unsupported - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm - if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - else - _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' - fi - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then - aix_use_runtimelinking=yes - break - fi - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GCC" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - ;; - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - amigaos*) - case $host_cpu in - powerpc) - # see comment about AmigaOS4 .so support - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='' - ;; - m68k) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - ;; - - bsdi[[45]]*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. - # hardcode_libdir_flag_spec is actually meaningless, as there is - # no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' - # FIXME: Should let the user specify the lib program. - _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' - _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - ;; - - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - freebsd1*) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor - # support. Future versions do this automatically, but an explicit c++rt0.o - # does not break anything, and helps significantly (at the cost of a little - # extra space). - freebsd2.2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - # FreeBSD 3 and greater uses gcc -shared to do shared libraries. - freebsd* | dragonfly*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - hpux9*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - - hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - fi - ;; - - hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - else - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - fi - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - - # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. - _LT_TAGVAR(hardcode_minus_L, $1)=yes - ;; - esac - fi - ;; - - irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - # Try to use the -exported_symbol ld option, if it does not - # work, assume that -exports_file does not work either and - # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - AC_LINK_IFELSE(int foo(void) {}, - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - ) - LDFLAGS="$save_LDFLAGS" - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out - else - _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - newsos6) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *nto* | *qnx*) - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - else - case $host_os in - openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - ;; - esac - fi - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - os2*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' - ;; - - osf3*) - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - else - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' - - # Both c and cxx compiler support -rpath directly - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - fi - _LT_TAGVAR(archive_cmds_need_lc, $1)='no' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - ;; - - solaris*) - _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - else - case `$CC -V 2>&1` in - *"Compilers 5.0"*) - wlarc='' - _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' - ;; - *) - wlarc='${wl}' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' - ;; - esac - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', - # but is careful enough not to reorder. - # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - fi - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - - sunos4*) - if test "x$host_vendor" = xsequent; then - # Use $CC to link under sequent, because it throws in some extra .o - # files that make .init and .fini sections work. - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' - fi - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4) - case $host_vendor in - sni) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? - ;; - siemens) - ## LD is ld it makes a PLAMLIB - ## CC just makes a GrossModule. - _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' - _LT_TAGVAR(hardcode_direct, $1)=no - ;; - motorola) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie - ;; - esac - runpath_var='LD_RUN_PATH' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - sysv4.3*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' - ;; - - sysv4*MP*) - if test -d /usr/nec; then - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var=LD_RUN_PATH - hardcode_runpath_var=yes - _LT_TAGVAR(ld_shlibs, $1)=yes - fi - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - if test "$GCC" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - fi - ;; - - uts4*) - _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - - *) - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - if test x$host_vendor = xsni; then - case $host in - sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' - ;; - esac - fi - fi -]) -AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) -test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - -_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld - -_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl -_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl -_LT_DECL([], [extract_expsyms_cmds], [2], - [The commands to extract the exported symbol list from a shared archive]) - -# -# Do we need to explicitly link libc? -# -case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in -x|xyes) - # Assume -lc should be added - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - - if test "$enable_shared" = yes && test "$GCC" = yes; then - case $_LT_TAGVAR(archive_cmds, $1) in - *'~'*) - # FIXME: we may have to deal with multi-command sequences. - ;; - '$CC '*) - # Test whether the compiler implicitly links with -lc since on some - # systems, -lgcc has to come before -lc. If gcc already passes -lc - # to ld, don't add -lc before -lgcc. - AC_MSG_CHECKING([whether -lc should be explicitly linked in]) - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext - - if AC_TRY_EVAL(ac_compile) 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) - pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) - _LT_TAGVAR(allow_undefined_flag, $1)= - if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) - then - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - else - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - fi - _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) - ;; - esac - fi - ;; -esac - -_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], - [Whether or not to add -lc for building shared libraries]) -_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], - [enable_shared_with_static_runtimes], [0], - [Whether or not to disallow shared libs when runtime libs are static]) -_LT_TAGDECL([], [export_dynamic_flag_spec], [1], - [Compiler flag to allow reflexive dlopens]) -_LT_TAGDECL([], [whole_archive_flag_spec], [1], - [Compiler flag to generate shared objects directly from archives]) -_LT_TAGDECL([], [compiler_needs_object], [1], - [Whether the compiler copes with passing no objects directly]) -_LT_TAGDECL([], [old_archive_from_new_cmds], [2], - [Create an old-style archive from a shared archive]) -_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], - [Create a temporary old-style archive to link instead of a shared archive]) -_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) -_LT_TAGDECL([], [archive_expsym_cmds], [2]) -_LT_TAGDECL([], [module_cmds], [2], - [Commands used to build a loadable module if different from building - a shared archive.]) -_LT_TAGDECL([], [module_expsym_cmds], [2]) -_LT_TAGDECL([], [with_gnu_ld], [1], - [Whether we are building with GNU ld or not]) -_LT_TAGDECL([], [allow_undefined_flag], [1], - [Flag that allows shared libraries with undefined symbols to be built]) -_LT_TAGDECL([], [no_undefined_flag], [1], - [Flag that enforces no undefined symbols]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], - [Flag to hardcode $libdir into a binary during linking. - This must work even if $libdir does not exist]) -_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], - [[If ld is used when linking, flag to hardcode $libdir into a binary - during linking. This must work even if $libdir does not exist]]) -_LT_TAGDECL([], [hardcode_libdir_separator], [1], - [Whether we need a single "-rpath" flag with a separated argument]) -_LT_TAGDECL([], [hardcode_direct], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary]) -_LT_TAGDECL([], [hardcode_direct_absolute], [0], - [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes - DIR into the resulting binary and the resulting library dependency is - "absolute", i.e impossible to change by setting ${shlibpath_var} if the - library is relocated]) -_LT_TAGDECL([], [hardcode_minus_L], [0], - [Set to "yes" if using the -LDIR flag during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_shlibpath_var], [0], - [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR - into the resulting binary]) -_LT_TAGDECL([], [hardcode_automatic], [0], - [Set to "yes" if building a shared library automatically hardcodes DIR - into the library and all subsequent libraries and executables linked - against it]) -_LT_TAGDECL([], [inherit_rpath], [0], - [Set to yes if linker adds runtime paths of dependent libraries - to runtime path list]) -_LT_TAGDECL([], [link_all_deplibs], [0], - [Whether libtool must link a program against all its dependency libraries]) -_LT_TAGDECL([], [fix_srcfile_path], [1], - [Fix the shell variable $srcfile for the compiler]) -_LT_TAGDECL([], [always_export_symbols], [0], - [Set to "yes" if exported symbols are required]) -_LT_TAGDECL([], [export_symbols_cmds], [2], - [The commands to list exported symbols]) -_LT_TAGDECL([], [exclude_expsyms], [1], - [Symbols that should not be listed in the preloaded symbols]) -_LT_TAGDECL([], [include_expsyms], [1], - [Symbols that must always be exported]) -_LT_TAGDECL([], [prelink_cmds], [2], - [Commands necessary for linking programs (against libraries) with templates]) -_LT_TAGDECL([], [file_list_spec], [1], - [Specify filename containing input files]) -dnl FIXME: Not yet implemented -dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], -dnl [Compiler flag to generate thread safe objects]) -])# _LT_LINKER_SHLIBS - - -# _LT_LANG_C_CONFIG([TAG]) -# ------------------------ -# Ensure that the configuration variables for a C compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_C_CONFIG], -[m4_require([_LT_DECL_EGREP])dnl -lt_save_CC="$CC" -AC_LANG_PUSH(C) - -# Source file extension for C test sources. -ac_ext=c - -# Object file extension for compiled C test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="int some_variable = 0;" - -# Code to be used in simple link tests -lt_simple_link_test_code='int main(){return(0);}' - -_LT_TAG_COMPILER -# Save the default compiler, since it gets overwritten when the other -# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. -compiler_DEFAULT=$CC - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - LT_SYS_DLOPEN_SELF - _LT_CMD_STRIPLIB - - # Report which library types will actually be built - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_CONFIG($1) -fi -AC_LANG_POP -CC="$lt_save_CC" -])# _LT_LANG_C_CONFIG - - -# _LT_PROG_CXX -# ------------ -# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ -# compiler, we have our own version here. -m4_defun([_LT_PROG_CXX], -[ -pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) -AC_PROG_CXX -if test -n "$CXX" && ( test "X$CXX" != "Xno" && - ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || - (test "X$CXX" != "Xg++"))) ; then - AC_PROG_CXXCPP -else - _lt_caught_CXX_error=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_CXX - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_CXX], []) - - -# _LT_LANG_CXX_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a C++ compiler are suitably -# defined. These variables are subsequently used by _LT_CONFIG to write -# the compiler configuration to `libtool'. -m4_defun([_LT_LANG_CXX_CONFIG], -[AC_REQUIRE([_LT_PROG_CXX])dnl -m4_require([_LT_FILEUTILS_DEFAULTS])dnl -m4_require([_LT_DECL_EGREP])dnl - -AC_LANG_PUSH(C++) -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(compiler_needs_object, $1)=no -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for C++ test sources. -ac_ext=cpp - -# Object file extension for compiled C++ test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the CXX compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_caught_CXX_error" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="int some_variable = 0;" - - # Code to be used in simple link tests - lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC=$CC - lt_save_LD=$LD - lt_save_GCC=$GCC - GCC=$GXX - lt_save_with_gnu_ld=$with_gnu_ld - lt_save_path_LD=$lt_cv_path_LD - if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then - lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx - else - $as_unset lt_cv_prog_gnu_ld - fi - if test -n "${lt_cv_path_LDCXX+set}"; then - lt_cv_path_LD=$lt_cv_path_LDCXX - else - $as_unset lt_cv_path_LD - fi - test -z "${LDCXX+set}" || LD=$LDCXX - CC=${CXX-"c++"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - # We don't want -fno-exception when compiling C++ code, so set the - # no_builtin_flag separately - if test "$GXX" = yes; then - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' - else - _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= - fi - - if test "$GXX" = yes; then - # Set up default GNU C++ configuration - - LT_PATH_LD - - # Check if GNU C++ uses GNU ld as the underlying linker, since the - # archiving commands below assume that GNU ld is being used. - if test "$with_gnu_ld" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # If archive_cmds runs LD, not CC, wlarc should be empty - # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to - # investigate it a little bit more. (MM) - wlarc='${wl}' - - # ancient GNU ld didn't support --whole-archive et. al. - if eval "`$CC -print-prog-name=ld` --help 2>&1" | - $GREP 'no-whole-archive' > /dev/null; then - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - else - _LT_TAGVAR(whole_archive_flag_spec, $1)= - fi - else - with_gnu_ld=no - wlarc= - - # A generic and very simple default shared library creation - # command for GNU C++ for the case where it uses the native - # linker, instead of GNU ld. If possible, this setting should - # overridden to take advantage of the native linker features on - # the platform it is being used on. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - fi - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - GXX=no - with_gnu_ld=no - wlarc= - fi - - # PORTME: fill in a description of your system's C++ link characteristics - AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) - _LT_TAGVAR(ld_shlibs, $1)=yes - case $host_os in - aix3*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aix[[4-9]]*) - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - aix_use_runtimelinking=no - - # Test if we are trying to use run time linking or normal - # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. - case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) - for ld_flag in $LDFLAGS; do - case $ld_flag in - *-brtl*) - aix_use_runtimelinking=yes - break - ;; - esac - done - ;; - esac - - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi - - # When large executables or shared objects are built, AIX ld can - # have problems creating the table of contents. If linking a library - # or program results in "error TOC overflow" add -mminimal-toc to - # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not - # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. - - _LT_TAGVAR(archive_cmds, $1)='' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' - - if test "$GXX" = yes; then - case $host_os in aix4.[[012]]|aix4.[[012]].*) - # We only want to do this on AIX 4.2 and lower, the check - # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && - strings "$collect2name" | $GREP resolve_lib_name >/dev/null - then - # We have reworked collect2 - : - else - # We have old collect2 - _LT_TAGVAR(hardcode_direct, $1)=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - _LT_TAGVAR(hardcode_minus_L, $1)=yes - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)= - fi - esac - shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' - fi - else - # not using gcc - if test "$host_cpu" = ia64; then - # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release - # chokes on -Wl,-G. The following line is correct: - shared_flag='-G' - else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' - else - shared_flag='${wl}-bM:SRE' - fi - fi - fi - - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' - # It seems that -bexpall does not export symbols beginning with - # underscore (_), so it is better to generate a list of symbols to - # export. - _LT_TAGVAR(always_export_symbols, $1)=yes - if test "$aix_use_runtimelinking" = yes; then - # Warning - without using the other runtime loading flags (-brtl), - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(allow_undefined_flag, $1)='-berok' - # Determine the default libpath from the value encoded in an empty - # executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" - else - if test "$host_cpu" = ia64; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' - _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" - else - # Determine the default libpath from the value encoded in an - # empty executable. - _LT_SYS_MODULE_PATH_AIX - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" - # Warning - without using the other run time loading flags, - # -berok will link without error, but may produce a broken library. - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' - _LT_TAGVAR(archive_cmds_need_lc, $1)=yes - # This is similar to how AIX traditionally builds its shared - # libraries. - _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' - fi - fi - ;; - - beos*) - if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - # Joseph Beckenbach says some releases of gcc - # support --undefined. This deserves some investigation. FIXME - _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - chorus*) - case $cc_basename in - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - cygwin* | mingw* | pw32* | cegcc*) - # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, - # as there is no search path for DLLs. - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' - _LT_TAGVAR(allow_undefined_flag, $1)=unsupported - _LT_TAGVAR(always_export_symbols, $1)=no - _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes - - if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - darwin* | rhapsody*) - _LT_DARWIN_LINKER_FEATURES($1) - ;; - - dgux*) - case $cc_basename in - ec++*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - ghcx*) - # Green Hills C++ Compiler - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - freebsd[[12]]*) - # C++ shared libraries reported to be fairly broken before - # switch to ELF - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - freebsd-elf*) - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - ;; - - freebsd* | dragonfly*) - # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF - # conventions - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - gnu*) - ;; - - hpux9*) - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - hpux10*|hpux11*) - if test $with_gnu_ld = no; then - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - case $host_cpu in - hppa*64*|ia64*) - ;; - *) - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - ;; - esac - fi - case $host_cpu in - hppa*64*|ia64*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - ;; - *) - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. - ;; - esac - - case $cc_basename in - CC*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - aCC*) - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes; then - if test $with_gnu_ld = no; then - case $host_cpu in - hppa*64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - ia64*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - ;; - esac - fi - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - interix[[3-9]]*) - _LT_TAGVAR(hardcode_direct, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. - # Instead, shared libraries are loaded at an image base (0x10000000 by - # default) and relocated if they conflict, which is a slow very memory - # consuming and fragmenting process. To avoid this, we pick a random, - # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link - # time. Moving up from 0x10000000 also allows more sbrk(2) space. - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - ;; - irix5* | irix6*) - case $cc_basename in - CC*) - # SGI C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - - # Archives containing C++ object files must be created using - # "CC -ar", where "CC" is the IRIX C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' - ;; - *) - if test "$GXX" = yes; then - if test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - else - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' - fi - fi - _LT_TAGVAR(link_all_deplibs, $1)=yes - ;; - esac - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - _LT_TAGVAR(inherit_rpath, $1)=yes - ;; - - linux* | k*bsd*-gnu) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - - # Archives containing C++ object files must be created using - # "CC -Bstatic", where "CC" is the KAI C++ compiler. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' - ;; - icpc* | ecpc* ) - # Intel C++ - with_gnu_ld=yes - # version 8.0 and above of icpc choke on multiply defined symbols - # if we add $predep_objects and $postdep_objects, however 7.1 and - # earlier do not add the objects themselves. - case `$CC -V 2>&1` in - *"Version 7."*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - *) # Version 8.0 or newer - tmp_idyn= - case $host_cpu in - ia64*) tmp_idyn=' -i_dynamic';; - esac - _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' - ;; - esac - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' - ;; - pgCC* | pgcpp*) - # Portland Group C++ compiler - case `$CC -V` in - *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) - _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ - compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' - _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ - $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ - $RANLIB $oldlib' - _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ - rm -rf $tpldir~ - $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ - $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - *) # Version 6 will use weak symbols - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - ;; - cxx*) - # Compaq C++ - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' - - runpath_var=LD_RUN_PATH - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - xl*) - # IBM XL 8.0 on PPC, with GNU ld - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' - _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' - fi - ;; - *) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' - _LT_TAGVAR(compiler_needs_object, $1)=yes - - # Not sure whether something based on - # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 - # would be better. - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - esac - ;; - esac - ;; - - lynxos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - m88k*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - mvs*) - case $cc_basename in - cxx*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' - wlarc= - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - fi - # Workaround some broken pre-1.5 toolchains - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' - ;; - - *nto* | *qnx*) - _LT_TAGVAR(ld_shlibs, $1)=yes - ;; - - openbsd2*) - # C++ shared libraries are fairly broken - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - openbsd*) - if test -f /usr/libexec/ld.so; then - _LT_TAGVAR(hardcode_direct, $1)=yes - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' - _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' - fi - output_verbose_link_cmd=echo - else - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - - osf3* | osf4* | osf5*) - case $cc_basename in - KCC*) - # Kuck and Associates, Inc. (KAI) C++ Compiler - - # KCC will only create a shared library if the output file - # ends with ".so" (or ".sl" for HP-UX), so rename the library - # to its proper name (with version) after linking. - _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Archives containing C++ object files must be created using - # the KAI C++ compiler. - case $host in - osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; - *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; - esac - ;; - RCC*) - # Rational C++ 2.4.1 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - cxx*) - case $host in - osf3*) - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - ;; - *) - _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' - _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ - echo "-hidden">> $lib.exp~ - $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ - $RM $lib.exp' - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - # - # There doesn't appear to be a way to prevent this compiler from - # explicitly linking system object files so we need to strip them - # from the output so that they don't get included in the library - # dependencies. - output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' - ;; - *) - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' - case $host in - osf3*) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - ;; - esac - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=: - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - - else - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - fi - ;; - esac - ;; - - psos*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - sunos4*) - case $cc_basename in - CC*) - # Sun C++ 4.x - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - lcc*) - # Lucid - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - solaris*) - case $cc_basename in - CC*) - # Sun C++ 4.2, 5.x and Centerline C++ - _LT_TAGVAR(archive_cmds_need_lc,$1)=yes - _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' - _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. - # Supported since Solaris 2.6 (maybe 2.5.1?) - _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' - ;; - esac - _LT_TAGVAR(link_all_deplibs, $1)=yes - - output_verbose_link_cmd='echo' - - # Archives containing C++ object files must be created using - # "CC -xar", where "CC" is the Sun C++ compiler. This is - # necessary to make sure instantiated templates are included - # in the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' - ;; - gcx*) - # Green Hills C++ Compiler - _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - - # The C++ compiler must be used to create the archive. - _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' - ;; - *) - # GNU C++ compiler with Solaris linker - if test "$GXX" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' - if $CC --version | $GREP -v '^2\.7' > /dev/null; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - else - # g++ 2.7 appears to require `-G' NOT `-shared' on this - # platform. - _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' - _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' - fi - - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' - case $host_os in - solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; - *) - _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' - ;; - esac - fi - ;; - esac - ;; - - sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not - # link with -lc, and that would cause any symbols used from libc to - # always be unresolved, which means just about no library would - # ever link correctly. If we're not using GNU ld we use -z text - # though, which does catch some bad symbols but isn't as heavy-handed - # as -z defs. - _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' - _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' - _LT_TAGVAR(archive_cmds_need_lc, $1)=no - _LT_TAGVAR(hardcode_shlibpath_var, $1)=no - _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' - _LT_TAGVAR(hardcode_libdir_separator, $1)=':' - _LT_TAGVAR(link_all_deplibs, $1)=yes - _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' - runpath_var='LD_RUN_PATH' - - case $cc_basename in - CC*) - _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - ;; - esac - ;; - - tandem*) - case $cc_basename in - NCC*) - # NonStop-UX NCC 3.20 - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - ;; - - vxworks*) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - - *) - # FIXME: insert proper C++ library support - _LT_TAGVAR(ld_shlibs, $1)=no - ;; - esac - - AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) - test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no - - _LT_TAGVAR(GCC, $1)="$GXX" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - CC=$lt_save_CC - LDCXX=$LD - LD=$lt_save_LD - GCC=$lt_save_GCC - with_gnu_ld=$lt_save_with_gnu_ld - lt_cv_path_LDCXX=$lt_cv_path_LD - lt_cv_path_LD=$lt_save_path_LD - lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld - lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld -fi # test "$_lt_caught_CXX_error" != yes - -AC_LANG_POP -])# _LT_LANG_CXX_CONFIG - - -# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) -# --------------------------------- -# Figure out "hidden" library dependencies from verbose -# compiler output when linking a shared library. -# Parse the compiler output and extract the necessary -# objects, libraries and library flags. -m4_defun([_LT_SYS_HIDDEN_LIBDEPS], -[m4_require([_LT_FILEUTILS_DEFAULTS])dnl -# Dependencies to place before and after the object being linked: -_LT_TAGVAR(predep_objects, $1)= -_LT_TAGVAR(postdep_objects, $1)= -_LT_TAGVAR(predeps, $1)= -_LT_TAGVAR(postdeps, $1)= -_LT_TAGVAR(compiler_lib_search_path, $1)= - -dnl we can't use the lt_simple_compile_test_code here, -dnl because it contains code intended for an executable, -dnl not a library. It's possible we should let each -dnl tag define a new lt_????_link_test_code variable, -dnl but it's only used here... -m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF -int a; -void foo (void) { a = 0; } -_LT_EOF -], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF -class Foo -{ -public: - Foo (void) { a = 0; } -private: - int a; -}; -_LT_EOF -], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer*4 a - a=0 - return - end -_LT_EOF -], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF - subroutine foo - implicit none - integer a - a=0 - return - end -_LT_EOF -], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF -public class foo { - private int a; - public void bar (void) { - a = 0; - } -}; -_LT_EOF -]) -dnl Parse the compiler output and extract the necessary -dnl objects, libraries and library flags. -if AC_TRY_EVAL(ac_compile); then - # Parse the compiler output and extract the necessary - # objects, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_test_object_deps_done=no - - for p in `eval "$output_verbose_link_cmd"`; do - case $p in - - -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" || - test $p = "-R"; then - prev=$p - continue - else - prev= - fi - - if test "$pre_test_object_deps_done" = no; then - case $p in - -L* | -R*) - # Internal compiler library paths should come after those - # provided the user. The postdeps already come after the - # user supplied libs so there is no need to process them. - if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then - _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" - else - _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" - fi - ;; - # The "-l" case would never come before the object being - # linked, so don't bother handling this case. - esac - else - if test -z "$_LT_TAGVAR(postdeps, $1)"; then - _LT_TAGVAR(postdeps, $1)="${prev}${p}" - else - _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" - fi - fi - ;; - - *.$objext) - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" = "conftest.$objext"; then - pre_test_object_deps_done=yes - continue - fi - - if test "$pre_test_object_deps_done" = no; then - if test -z "$_LT_TAGVAR(predep_objects, $1)"; then - _LT_TAGVAR(predep_objects, $1)="$p" - else - _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" - fi - else - if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then - _LT_TAGVAR(postdep_objects, $1)="$p" - else - _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" - fi - fi - ;; - - *) ;; # Ignore the rest. - - esac - done - - # Clean up. - rm -f a.out a.exe -else - echo "libtool.m4: error: problem compiling $1 test program" -fi - -$RM -f confest.$objext - -# PORTME: override above test on systems where it is broken -m4_if([$1], [CXX], -[case $host_os in -interix[[3-9]]*) - # Interix 3.5 installs completely hosed .la files for C++, so rather than - # hack all around it, let's just trust "g++" to DTRT. - _LT_TAGVAR(predep_objects,$1)= - _LT_TAGVAR(postdep_objects,$1)= - _LT_TAGVAR(postdeps,$1)= - ;; - -linux*) - case `$CC -V 2>&1 | sed 5q` in - *Sun\ C*) - # Sun C++ 5.9 - - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; - -solaris*) - case $cc_basename in - CC*) - # The more standards-conforming stlport4 library is - # incompatible with the Cstd library. Avoid specifying - # it if it's in CXXFLAGS. Ignore libCrun as - # -library=stlport4 depends on it. - case " $CXX $CXXFLAGS " in - *" -library=stlport4 "*) - solaris_use_stlport4=yes - ;; - esac - - # Adding this requires a known-good setup of shared libraries for - # Sun compiler versions before 5.6, else PIC objects from an old - # archive will be linked into the output, leading to subtle bugs. - if test "$solaris_use_stlport4" != yes; then - _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' - fi - ;; - esac - ;; -esac -]) - -case " $_LT_TAGVAR(postdeps, $1) " in -*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; -esac - _LT_TAGVAR(compiler_lib_search_dirs, $1)= -if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then - _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` -fi -_LT_TAGDECL([], [compiler_lib_search_dirs], [1], - [The directories searched by this compiler when creating a shared library]) -_LT_TAGDECL([], [predep_objects], [1], - [Dependencies to place before and after the objects being linked to - create a shared library]) -_LT_TAGDECL([], [postdep_objects], [1]) -_LT_TAGDECL([], [predeps], [1]) -_LT_TAGDECL([], [postdeps], [1]) -_LT_TAGDECL([], [compiler_lib_search_path], [1], - [The library search path used internally by the compiler when linking - a shared library]) -])# _LT_SYS_HIDDEN_LIBDEPS - - -# _LT_PROG_F77 -# ------------ -# Since AC_PROG_F77 is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_F77], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) -AC_PROG_F77 -if test -z "$F77" || test "X$F77" = "Xno"; then - _lt_disable_F77=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_F77 - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_F77], []) - - -# _LT_LANG_F77_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for a Fortran 77 compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_F77_CONFIG], -[AC_REQUIRE([_LT_PROG_F77])dnl -AC_LANG_PUSH(Fortran 77) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for f77 test sources. -ac_ext=f - -# Object file extension for compiled f77 test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the F77 compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_F77" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${F77-"f77"} - compiler=$CC - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - GCC=$G77 - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$G77" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_F77" != yes - -AC_LANG_POP -])# _LT_LANG_F77_CONFIG - - -# _LT_PROG_FC -# ----------- -# Since AC_PROG_FC is broken, in that it returns the empty string -# if there is no fortran compiler, we have our own version here. -m4_defun([_LT_PROG_FC], -[ -pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) -AC_PROG_FC -if test -z "$FC" || test "X$FC" = "Xno"; then - _lt_disable_FC=yes -fi -popdef([AC_MSG_ERROR]) -])# _LT_PROG_FC - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([_LT_PROG_FC], []) - - -# _LT_LANG_FC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for a Fortran compiler are -# suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_FC_CONFIG], -[AC_REQUIRE([_LT_PROG_FC])dnl -AC_LANG_PUSH(Fortran) - -_LT_TAGVAR(archive_cmds_need_lc, $1)=no -_LT_TAGVAR(allow_undefined_flag, $1)= -_LT_TAGVAR(always_export_symbols, $1)=no -_LT_TAGVAR(archive_expsym_cmds, $1)= -_LT_TAGVAR(export_dynamic_flag_spec, $1)= -_LT_TAGVAR(hardcode_direct, $1)=no -_LT_TAGVAR(hardcode_direct_absolute, $1)=no -_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= -_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= -_LT_TAGVAR(hardcode_libdir_separator, $1)= -_LT_TAGVAR(hardcode_minus_L, $1)=no -_LT_TAGVAR(hardcode_automatic, $1)=no -_LT_TAGVAR(inherit_rpath, $1)=no -_LT_TAGVAR(module_cmds, $1)= -_LT_TAGVAR(module_expsym_cmds, $1)= -_LT_TAGVAR(link_all_deplibs, $1)=unknown -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds -_LT_TAGVAR(no_undefined_flag, $1)= -_LT_TAGVAR(whole_archive_flag_spec, $1)= -_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no - -# Source file extension for fc test sources. -ac_ext=${ac_fc_srcext-f} - -# Object file extension for compiled fc test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# No sense in running all these tests if we already determined that -# the FC compiler isn't working. Some variables (like enable_shared) -# are currently assumed to apply to all compilers on this platform, -# and will be corrupted by setting them based on a non-working compiler. -if test "$_lt_disable_FC" != yes; then - # Code to be used in simple compile tests - lt_simple_compile_test_code="\ - subroutine t - return - end -" - - # Code to be used in simple link tests - lt_simple_link_test_code="\ - program t - end -" - - # ltmain only uses $CC for tagged configurations so make sure $CC is set. - _LT_TAG_COMPILER - - # save warnings/boilerplate of simple test code - _LT_COMPILER_BOILERPLATE - _LT_LINKER_BOILERPLATE - - # Allow CC to be a program name with arguments. - lt_save_CC="$CC" - lt_save_GCC=$GCC - CC=${FC-"f95"} - compiler=$CC - GCC=$ac_cv_fc_compiler_gnu - - _LT_TAGVAR(compiler, $1)=$CC - _LT_CC_BASENAME([$compiler]) - - if test -n "$compiler"; then - AC_MSG_CHECKING([if libtool supports shared libraries]) - AC_MSG_RESULT([$can_build_shared]) - - AC_MSG_CHECKING([whether to build shared libraries]) - test "$can_build_shared" = "no" && enable_shared=no - - # On AIX, shared libraries and static libraries use the same namespace, and - # are all built from PIC. - case $host_os in - aix3*) - test "$enable_shared" = yes && enable_static=no - if test -n "$RANLIB"; then - archive_cmds="$archive_cmds~\$RANLIB \$lib" - postinstall_cmds='$RANLIB $lib' - fi - ;; - aix[[4-9]]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no - fi - ;; - esac - AC_MSG_RESULT([$enable_shared]) - - AC_MSG_CHECKING([whether to build static libraries]) - # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes - AC_MSG_RESULT([$enable_static]) - - _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" - _LT_TAGVAR(LD, $1)="$LD" - - ## CAVEAT EMPTOR: - ## There is no encapsulation within the following macros, do not change - ## the running order or otherwise move them around unless you know exactly - ## what you are doing... - _LT_SYS_HIDDEN_LIBDEPS($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_SYS_DYNAMIC_LINKER($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) - fi # test -n "$compiler" - - GCC=$lt_save_GCC - CC="$lt_save_CC" -fi # test "$_lt_disable_FC" != yes - -AC_LANG_POP -])# _LT_LANG_FC_CONFIG - - -# _LT_LANG_GCJ_CONFIG([TAG]) -# -------------------------- -# Ensure that the configuration variables for the GNU Java Compiler compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_GCJ_CONFIG], -[AC_REQUIRE([LT_PROG_GCJ])dnl -AC_LANG_SAVE - -# Source file extension for Java test sources. -ac_ext=java - -# Object file extension for compiled Java test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code="class foo {}" - -# Code to be used in simple link tests -lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC=yes -CC=${GCJ-"gcj"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_TAGVAR(LD, $1)="$LD" -_LT_CC_BASENAME([$compiler]) - -# GCJ did not exist at the time GCC didn't implicitly link libc in. -_LT_TAGVAR(archive_cmds_need_lc, $1)=no - -_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds - -if test -n "$compiler"; then - _LT_COMPILER_NO_RTTI($1) - _LT_COMPILER_PIC($1) - _LT_COMPILER_C_O($1) - _LT_COMPILER_FILE_LOCKS($1) - _LT_LINKER_SHLIBS($1) - _LT_LINKER_HARDCODE_LIBPATH($1) - - _LT_CONFIG($1) -fi - -AC_LANG_RESTORE - -GCC=$lt_save_GCC -CC="$lt_save_CC" -])# _LT_LANG_GCJ_CONFIG - - -# _LT_LANG_RC_CONFIG([TAG]) -# ------------------------- -# Ensure that the configuration variables for the Windows resource compiler -# are suitably defined. These variables are subsequently used by _LT_CONFIG -# to write the compiler configuration to `libtool'. -m4_defun([_LT_LANG_RC_CONFIG], -[AC_REQUIRE([LT_PROG_RC])dnl -AC_LANG_SAVE - -# Source file extension for RC test sources. -ac_ext=rc - -# Object file extension for compiled RC test sources. -objext=o -_LT_TAGVAR(objext, $1)=$objext - -# Code to be used in simple compile tests -lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' - -# Code to be used in simple link tests -lt_simple_link_test_code="$lt_simple_compile_test_code" - -# ltmain only uses $CC for tagged configurations so make sure $CC is set. -_LT_TAG_COMPILER - -# save warnings/boilerplate of simple test code -_LT_COMPILER_BOILERPLATE -_LT_LINKER_BOILERPLATE - -# Allow CC to be a program name with arguments. -lt_save_CC="$CC" -lt_save_GCC=$GCC -GCC= -CC=${RC-"windres"} -compiler=$CC -_LT_TAGVAR(compiler, $1)=$CC -_LT_CC_BASENAME([$compiler]) -_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes - -if test -n "$compiler"; then - : - _LT_CONFIG($1) -fi - -GCC=$lt_save_GCC -AC_LANG_RESTORE -CC="$lt_save_CC" -])# _LT_LANG_RC_CONFIG - - -# LT_PROG_GCJ -# ----------- -AC_DEFUN([LT_PROG_GCJ], -[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], - [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], - [AC_CHECK_TOOL(GCJ, gcj,) - test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" - AC_SUBST(GCJFLAGS)])])[]dnl -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_GCJ], []) - - -# LT_PROG_RC -# ---------- -AC_DEFUN([LT_PROG_RC], -[AC_CHECK_TOOL(RC, windres,) -]) - -# Old name: -AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_RC], []) - - -# _LT_DECL_EGREP -# -------------- -# If we don't have a new enough Autoconf to choose the best grep -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_EGREP], -[AC_REQUIRE([AC_PROG_EGREP])dnl -AC_REQUIRE([AC_PROG_FGREP])dnl -test -z "$GREP" && GREP=grep -_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) -_LT_DECL([], [EGREP], [1], [An ERE matcher]) -_LT_DECL([], [FGREP], [1], [A literal string matcher]) -dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too -AC_SUBST([GREP]) -]) - - -# _LT_DECL_OBJDUMP -# -------------- -# If we don't have a new enough Autoconf to choose the best objdump -# available, choose the one first in the user's PATH. -m4_defun([_LT_DECL_OBJDUMP], -[AC_CHECK_TOOL(OBJDUMP, objdump, false) -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) -AC_SUBST([OBJDUMP]) -]) - - -# _LT_DECL_SED -# ------------ -# Check for a fully-functional sed program, that truncates -# as few characters as possible. Prefer GNU sed if found. -m4_defun([_LT_DECL_SED], -[AC_PROG_SED -test -z "$SED" && SED=sed -Xsed="$SED -e 1s/^X//" -_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) -_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], - [Sed that helps us avoid accidentally triggering echo(1) options like -n]) -])# _LT_DECL_SED - -m4_ifndef([AC_PROG_SED], [ -# NOTE: This macro has been submitted for inclusion into # -# GNU Autoconf as AC_PROG_SED. When it is available in # -# a released version of Autoconf we should remove this # -# macro and use it instead. # - -m4_defun([AC_PROG_SED], -[AC_MSG_CHECKING([for a sed that does not truncate output]) -AC_CACHE_VAL(lt_cv_path_SED, -[# Loop through the user's path and test for sed and gsed. -# Then use that list of sed's as ones to test for truncation. -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for lt_ac_prog in sed gsed; do - for ac_exec_ext in '' $ac_executable_extensions; do - if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then - lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" - fi - done - done -done -IFS=$as_save_IFS -lt_ac_max=0 -lt_ac_count=0 -# Add /usr/xpg4/bin/sed as it is typically found on Solaris -# along with /bin/sed that truncates output. -for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do - test ! -f $lt_ac_sed && continue - cat /dev/null > conftest.in - lt_ac_count=0 - echo $ECHO_N "0123456789$ECHO_C" >conftest.in - # Check for GNU sed and select it if it is found. - if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then - lt_cv_path_SED=$lt_ac_sed - break - fi - while true; do - cat conftest.in conftest.in >conftest.tmp - mv conftest.tmp conftest.in - cp conftest.in conftest.nl - echo >>conftest.nl - $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break - cmp -s conftest.out conftest.nl || break - # 10000 chars as input seems more than enough - test $lt_ac_count -gt 10 && break - lt_ac_count=`expr $lt_ac_count + 1` - if test $lt_ac_count -gt $lt_ac_max; then - lt_ac_max=$lt_ac_count - lt_cv_path_SED=$lt_ac_sed - fi - done -done -]) -SED=$lt_cv_path_SED -AC_SUBST([SED]) -AC_MSG_RESULT([$SED]) -])#AC_PROG_SED -])#m4_ifndef - -# Old name: -AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([LT_AC_PROG_SED], []) - - -# _LT_CHECK_SHELL_FEATURES -# ------------------------ -# Find out whether the shell is Bourne or XSI compatible, -# or has some other useful features. -m4_defun([_LT_CHECK_SHELL_FEATURES], -[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -AC_MSG_RESULT([$xsi_shell]) -_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) - -AC_MSG_CHECKING([whether the shell understands "+="]) -lt_shell_append=no -( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -AC_MSG_RESULT([$lt_shell_append]) -_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) - -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - lt_unset=unset -else - lt_unset=false -fi -_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl - -# test EBCDIC or ASCII -case `echo X|tr X '\101'` in - A) # ASCII based system - # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr - lt_SP2NL='tr \040 \012' - lt_NL2SP='tr \015\012 \040\040' - ;; - *) # EBCDIC based system - lt_SP2NL='tr \100 \n' - lt_NL2SP='tr \r\n \100\100' - ;; -esac -_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl -_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl -])# _LT_CHECK_SHELL_FEATURES - - -# _LT_PROG_XSI_SHELLFNS -# --------------------- -# Bourne and XSI compatible variants of some useful shell functions. -m4_defun([_LT_PROG_XSI_SHELLFNS], -[case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $[*] )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - -dnl func_dirname_and_basename -dnl A portable version of this function is already defined in general.m4sh -dnl so there is no need for it here. - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[[^=]]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$[@]"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]+=\$[2]" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$[1]=\$$[1]\$[2]" -} - -_LT_EOF - ;; - esac -]) - -# Helper functions for option handling. -*- Autoconf -*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltoptions.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) - - -# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) -# ------------------------------------------ -m4_define([_LT_MANGLE_OPTION], -[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) - - -# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) -# --------------------------------------- -# Set option OPTION-NAME for macro MACRO-NAME, and if there is a -# matching handler defined, dispatch to it. Other OPTION-NAMEs are -# saved as a flag. -m4_define([_LT_SET_OPTION], -[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl -m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), - _LT_MANGLE_DEFUN([$1], [$2]), - [m4_warning([Unknown $1 option `$2'])])[]dnl -]) - - -# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) -# ------------------------------------------------------------ -# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. -m4_define([_LT_IF_OPTION], -[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) - - -# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) -# ------------------------------------------------------- -# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME -# are set. -m4_define([_LT_UNLESS_OPTIONS], -[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), - [m4_define([$0_found])])])[]dnl -m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 -])[]dnl -]) - - -# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) -# ---------------------------------------- -# OPTION-LIST is a space-separated list of Libtool options associated -# with MACRO-NAME. If any OPTION has a matching handler declared with -# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about -# the unknown option and exit. -m4_defun([_LT_SET_OPTIONS], -[# Set options -m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), - [_LT_SET_OPTION([$1], _LT_Option)]) - -m4_if([$1],[LT_INIT],[ - dnl - dnl Simply set some default values (i.e off) if boolean options were not - dnl specified: - _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no - ]) - _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no - ]) - dnl - dnl If no reference was made to various pairs of opposing options, then - dnl we run the default mode handler for the pair. For example, if neither - dnl `shared' nor `disable-shared' was passed, we enable building of shared - dnl archives by default: - _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) - _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) - _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], - [_LT_ENABLE_FAST_INSTALL]) - ]) -])# _LT_SET_OPTIONS - - - -# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) -# ----------------------------------------- -m4_define([_LT_MANGLE_DEFUN], -[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) - - -# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) -# ----------------------------------------------- -m4_define([LT_OPTION_DEFINE], -[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl -])# LT_OPTION_DEFINE - - -# dlopen -# ------ -LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes -]) - -AU_DEFUN([AC_LIBTOOL_DLOPEN], -[_LT_SET_OPTION([LT_INIT], [dlopen]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `dlopen' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) - - -# win32-dll -# --------- -# Declare package support for building win32 dll's. -LT_OPTION_DEFINE([LT_INIT], [win32-dll], -[enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) - AC_CHECK_TOOL(AS, as, false) - AC_CHECK_TOOL(DLLTOOL, dlltool, false) - AC_CHECK_TOOL(OBJDUMP, objdump, false) - ;; -esac - -test -z "$AS" && AS=as -_LT_DECL([], [AS], [0], [Assembler program])dnl - -test -z "$DLLTOOL" && DLLTOOL=dlltool -_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl - -test -z "$OBJDUMP" && OBJDUMP=objdump -_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl -])# win32-dll - -AU_DEFUN([AC_LIBTOOL_WIN32_DLL], -[AC_REQUIRE([AC_CANONICAL_HOST])dnl -_LT_SET_OPTION([LT_INIT], [win32-dll]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `win32-dll' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) - - -# _LT_ENABLE_SHARED([DEFAULT]) -# ---------------------------- -# implement the --enable-shared flag, and supports the `shared' and -# `disable-shared' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_SHARED], -[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([shared], - [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], - [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_shared=yes ;; - no) enable_shared=no ;; - *) - enable_shared=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_shared=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) - - _LT_DECL([build_libtool_libs], [enable_shared], [0], - [Whether or not to build shared libraries]) -])# _LT_ENABLE_SHARED - -LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) -]) - -AC_DEFUN([AC_DISABLE_SHARED], -[_LT_SET_OPTION([LT_INIT], [disable-shared]) -]) - -AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) -AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_SHARED], []) -dnl AC_DEFUN([AM_DISABLE_SHARED], []) - - - -# _LT_ENABLE_STATIC([DEFAULT]) -# ---------------------------- -# implement the --enable-static flag, and support the `static' and -# `disable-static' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_STATIC], -[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([static], - [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], - [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_static=yes ;; - no) enable_static=no ;; - *) - enable_static=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_static=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_static=]_LT_ENABLE_STATIC_DEFAULT) - - _LT_DECL([build_old_libs], [enable_static], [0], - [Whether or not to build static libraries]) -])# _LT_ENABLE_STATIC - -LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) - -# Old names: -AC_DEFUN([AC_ENABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) -]) - -AC_DEFUN([AC_DISABLE_STATIC], -[_LT_SET_OPTION([LT_INIT], [disable-static]) -]) - -AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) -AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AM_ENABLE_STATIC], []) -dnl AC_DEFUN([AM_DISABLE_STATIC], []) - - - -# _LT_ENABLE_FAST_INSTALL([DEFAULT]) -# ---------------------------------- -# implement the --enable-fast-install flag, and support the `fast-install' -# and `disable-fast-install' LT_INIT options. -# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. -m4_define([_LT_ENABLE_FAST_INSTALL], -[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl -AC_ARG_ENABLE([fast-install], - [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], - [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], - [p=${PACKAGE-default} - case $enableval in - yes) enable_fast_install=yes ;; - no) enable_fast_install=no ;; - *) - enable_fast_install=no - # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," - for pkg in $enableval; do - IFS="$lt_save_ifs" - if test "X$pkg" = "X$p"; then - enable_fast_install=yes - fi - done - IFS="$lt_save_ifs" - ;; - esac], - [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) - -_LT_DECL([fast_install], [enable_fast_install], [0], - [Whether or not to optimize for fast installation])dnl -])# _LT_ENABLE_FAST_INSTALL - -LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) -LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) - -# Old names: -AU_DEFUN([AC_ENABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `fast-install' option into LT_INIT's first parameter.]) -]) - -AU_DEFUN([AC_DISABLE_FAST_INSTALL], -[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you put -the `disable-fast-install' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) -dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) - - -# _LT_WITH_PIC([MODE]) -# -------------------- -# implement the --with-pic flag, and support the `pic-only' and `no-pic' -# LT_INIT options. -# MODE is either `yes' or `no'. If omitted, it defaults to `both'. -m4_define([_LT_WITH_PIC], -[AC_ARG_WITH([pic], - [AS_HELP_STRING([--with-pic], - [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], - [pic_mode="$withval"], - [pic_mode=default]) - -test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) - -_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl -])# _LT_WITH_PIC - -LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) -LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) - -# Old name: -AU_DEFUN([AC_LIBTOOL_PICMODE], -[_LT_SET_OPTION([LT_INIT], [pic-only]) -AC_DIAGNOSE([obsolete], -[$0: Remove this warning and the call to _LT_SET_OPTION when you -put the `pic-only' option into LT_INIT's first parameter.]) -]) - -dnl aclocal-1.4 backwards compatibility: -dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) - - -m4_define([_LTDL_MODE], []) -LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], - [m4_define([_LTDL_MODE], [nonrecursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [recursive], - [m4_define([_LTDL_MODE], [recursive])]) -LT_OPTION_DEFINE([LTDL_INIT], [subproject], - [m4_define([_LTDL_MODE], [subproject])]) - -m4_define([_LTDL_TYPE], []) -LT_OPTION_DEFINE([LTDL_INIT], [installable], - [m4_define([_LTDL_TYPE], [installable])]) -LT_OPTION_DEFINE([LTDL_INIT], [convenience], - [m4_define([_LTDL_TYPE], [convenience])]) - -# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. -# Written by Gary V. Vaughan, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 6 ltsugar.m4 - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) - - -# lt_join(SEP, ARG1, [ARG2...]) -# ----------------------------- -# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their -# associated separator. -# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier -# versions in m4sugar had bugs. -m4_define([lt_join], -[m4_if([$#], [1], [], - [$#], [2], [[$2]], - [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) -m4_define([_lt_join], -[m4_if([$#$2], [2], [], - [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) - - -# lt_car(LIST) -# lt_cdr(LIST) -# ------------ -# Manipulate m4 lists. -# These macros are necessary as long as will still need to support -# Autoconf-2.59 which quotes differently. -m4_define([lt_car], [[$1]]) -m4_define([lt_cdr], -[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], - [$#], 1, [], - [m4_dquote(m4_shift($@))])]) -m4_define([lt_unquote], $1) - - -# lt_append(MACRO-NAME, STRING, [SEPARATOR]) -# ------------------------------------------ -# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. -# Note that neither SEPARATOR nor STRING are expanded; they are appended -# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). -# No SEPARATOR is output if MACRO-NAME was previously undefined (different -# than defined and empty). -# -# This macro is needed until we can rely on Autoconf 2.62, since earlier -# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. -m4_define([lt_append], -[m4_define([$1], - m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) - - - -# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) -# ---------------------------------------------------------- -# Produce a SEP delimited list of all paired combinations of elements of -# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list -# has the form PREFIXmINFIXSUFFIXn. -# Needed until we can rely on m4_combine added in Autoconf 2.62. -m4_define([lt_combine], -[m4_if(m4_eval([$# > 3]), [1], - [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl -[[m4_foreach([_Lt_prefix], [$2], - [m4_foreach([_Lt_suffix], - ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, - [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) - - -# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) -# ----------------------------------------------------------------------- -# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited -# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. -m4_define([lt_if_append_uniq], -[m4_ifdef([$1], - [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], - [lt_append([$1], [$2], [$3])$4], - [$5])], - [lt_append([$1], [$2], [$3])$4])]) - - -# lt_dict_add(DICT, KEY, VALUE) -# ----------------------------- -m4_define([lt_dict_add], -[m4_define([$1($2)], [$3])]) - - -# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) -# -------------------------------------------- -m4_define([lt_dict_add_subkey], -[m4_define([$1($2:$3)], [$4])]) - - -# lt_dict_fetch(DICT, KEY, [SUBKEY]) -# ---------------------------------- -m4_define([lt_dict_fetch], -[m4_ifval([$3], - m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), - m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) - - -# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) -# ----------------------------------------------------------------- -m4_define([lt_if_dict_fetch], -[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], - [$5], - [$6])]) - - -# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) -# -------------------------------------------------------------- -m4_define([lt_dict_filter], -[m4_if([$5], [], [], - [lt_join(m4_quote(m4_default([$4], [[, ]])), - lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), - [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl -]) - -# ltversion.m4 -- version numbers -*- Autoconf -*- -# -# Copyright (C) 2004 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004 -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# Generated from ltversion.in. - -# serial 3017 ltversion.m4 -# This file is part of GNU Libtool - -m4_define([LT_PACKAGE_VERSION], [2.2.6b]) -m4_define([LT_PACKAGE_REVISION], [1.3017]) - -AC_DEFUN([LTVERSION_VERSION], -[macro_version='2.2.6b' -macro_revision='1.3017' -_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) -_LT_DECL(, macro_revision, 0) -]) - -# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- -# -# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. -# Written by Scott James Remnant, 2004. -# -# This file is free software; the Free Software Foundation gives -# unlimited permission to copy and/or distribute it, with or without -# modifications, as long as this notice is preserved. - -# serial 4 lt~obsolete.m4 - -# These exist entirely to fool aclocal when bootstrapping libtool. -# -# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) -# which have later been changed to m4_define as they aren't part of the -# exported API, or moved to Autoconf or Automake where they belong. -# -# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN -# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us -# using a macro with the same name in our local m4/libtool.m4 it'll -# pull the old libtool.m4 in (it doesn't see our shiny new m4_define -# and doesn't know about Autoconf macros at all.) -# -# So we provide this file, which has a silly filename so it's always -# included after everything else. This provides aclocal with the -# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything -# because those macros already exist, or will be overwritten later. -# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. -# -# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. -# Yes, that means every name once taken will need to remain here until -# we give up compatibility with versions before 1.7, at which point -# we need to keep only those names which we still refer to. - -# This is to help aclocal find these macros, as it can't see m4_define. -AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) - -m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) -m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) -m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) -m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) -m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) -m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) -m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) -m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) -m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) -m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) -m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) -m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) -m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) -m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) -m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) -m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) -m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) -m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) -m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) -m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) -m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) -m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) -m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) -m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) -m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) -m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) -m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) -m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) -m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) -m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) -m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) -m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) -m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) -m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) -m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) -m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) -m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) -m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) -m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) -m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) -m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) -m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) -m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) -m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) -m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) -m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) -m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) -m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) -m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) -m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) - -# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# Copyright (C) 2002-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -7977,10 +32,10 @@ m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.11' +[am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11], [], +m4_if([$1], [1.16.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -7996,22 +51,42 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11])dnl +[AM_AUTOMAKE_VERSION([1.16.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) +# Figure out how to run the assembler. -*- Autoconf -*- + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_AS +# ---------- +AC_DEFUN([AM_PROG_AS], +[# By default we simply use the C compiler to build assembly code. +AC_REQUIRE([AC_PROG_CC]) +test "${CCAS+set}" = set || CCAS=$CC +test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS +AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)]) +AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)]) +_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl +]) + # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets -# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to -# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to +# '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and @@ -8030,7 +105,7 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually -# harmless because $srcdir is `.', but things will broke when you +# harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, @@ -8048,30 +123,26 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], -[dnl Rely on autoconf to set up CDPATH properly. -AC_PREREQ([2.50])dnl -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 9 - # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], -[AC_PREREQ(2.52)dnl - ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], - [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +[AC_PREREQ([2.52])dnl + m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl @@ -8090,16 +161,14 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 -# Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 10 -# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing @@ -8109,7 +178,7 @@ fi])]) # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. -# NAME is "CC", "CXX", "GCJ", or "OBJC". +# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was @@ -8122,12 +191,13 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl -ifelse([$1], CC, [depcc="$CC" am_compiler_list=], - [$1], CXX, [depcc="$CXX" am_compiler_list=], - [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], - [$1], UPC, [depcc="$UPC" am_compiler_list=], - [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], - [depcc="$$1" am_compiler_list=]) +m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], + [$1], [CXX], [depcc="$CXX" am_compiler_list=], + [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], + [$1], [UPC], [depcc="$UPC" am_compiler_list=], + [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], @@ -8135,8 +205,9 @@ AC_CACHE_CHECK([dependency style of $depcc], # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -8175,16 +246,16 @@ AC_CACHE_CHECK([dependency style of $depcc], : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with `-c' and `-o' for the sake of the "dashmstdout" + # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -8193,16 +264,16 @@ AC_CACHE_CHECK([dependency style of $depcc], test "$am__universal" = false || continue ;; nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -8250,7 +321,7 @@ AM_CONDITIONAL([am__fastdep$1], [ # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. -# This macro is AC_REQUIREd in _AM_DEPENDENCIES +# This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl @@ -8260,81 +331,75 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], -[AC_ARG_ENABLE(dependency-tracking, -[ --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors]) +[AC_ARG_ENABLE([dependency-tracking], [dnl +AS_HELP_STRING( + [--enable-dependency-tracking], + [do not reject slow dependency extractors]) +AS_HELP_STRING( + [--disable-dependency-tracking], + [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' + am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +AC_SUBST([am__nodep])dnl +_AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -#serial 5 - # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ - # Autoconf 2.62 quotes --file arguments for eval, but not when files + # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + AS_CASE([$CONFIG_FILES], + [*\'*], [eval set x "$CONFIG_FILES"], + [*], [set x $CONFIG_FILES]) shift - for mf + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf do # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line + am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`AS_DIRNAME("$mf")` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`AS_DIRNAME(["$file"])` - AS_MKDIR_P([$dirpart/$fdir]) - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`AS_DIRNAME(["$am_mf"])` + am_filepart=`AS_BASENAME(["$am_mf"])` + AM_RUN_LOG([cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles]) || am_rc=$? done + if test $am_rc -ne 0; then + AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. Try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking).]) + fi + AS_UNSET([am_dirpart]) + AS_UNSET([am_filepart]) + AS_UNSET([am_mf]) + AS_UNSET([am_rc]) + rm -f conftest-deps.mk } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS @@ -8343,41 +408,31 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # -# This code is only required when automatic dependency tracking -# is enabled. FIXME. This creates each `.P' file that we will -# need in order to bootstrap the dependency handling code. +# This code is only required when automatic dependency tracking is enabled. +# This creates each '.Po' and '.Plo' makefile fragment that we'll need in +# order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], - [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) -]) - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 -# Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# serial 8 - -# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. -AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])]) # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 16 - # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- @@ -8390,7 +445,7 @@ AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], -[AC_PREREQ([2.62])dnl +[AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl @@ -8419,33 +474,42 @@ AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], -[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl +[AC_DIAGNOSE([obsolete], + [$0: two- and three-arguments forms are deprecated.]) +m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. -m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, +m4_if( + m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), + [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, -[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) - AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl +[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) + AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl -AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) -AM_MISSING_PROG(AUTOCONF, autoconf) -AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) -AM_MISSING_PROG(AUTOHEADER, autoheader) -AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) +AM_MISSING_PROG([AUTOCONF], [autoconf]) +AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) +AM_MISSING_PROG([AUTOHEADER], [autoheader]) +AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl -AC_REQUIRE([AM_PROG_MKDIR_P])dnl -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +AC_SUBST([mkdir_p], ['$(MKDIR_P)']) +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl @@ -8454,34 +518,82 @@ _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], - [_AM_DEPENDENCIES(CC)], - [define([AC_PROG_CC], - defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl + [_AM_DEPENDENCIES([CC])], + [m4_define([AC_PROG_CC], + m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], - [_AM_DEPENDENCIES(CXX)], - [define([AC_PROG_CXX], - defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl + [_AM_DEPENDENCIES([CXX])], + [m4_define([AC_PROG_CXX], + m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], - [_AM_DEPENDENCIES(OBJC)], - [define([AC_PROG_OBJC], - defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl + [_AM_DEPENDENCIES([OBJC])], + [m4_define([AC_PROG_OBJC], + m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], + [_AM_DEPENDENCIES([OBJCXX])], + [m4_define([AC_PROG_OBJCXX], + m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) -_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl -dnl The `parallel-tests' driver may need to know about EXEEXT, so add the -dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro -dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_REQUIRE([AM_SILENT_RULES])dnl +dnl The testsuite driver may need to know about EXEEXT, so add the +dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This +dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi +dnl The trailing newline in this macro's definition is deliberate, for +dnl backward compatibility and to allow trailing 'dnl'-style comments +dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) -dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. @@ -8503,7 +615,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8514,7 +626,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -8522,16 +634,14 @@ if test x"${install_sh}" != xset; then install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi -AC_SUBST(install_sh)]) +AC_SUBST([install_sh])]) -# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2003-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], @@ -8548,20 +658,17 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 - # AM_MAINTAINER_MODE([DEFAULT-MODE]) # ---------------------------------- # Control maintainer-specific portions of Makefiles. -# Default is to disable them, unless `enable' is passed literally. -# For symmetry, `disable' may be passed as well. Anyway, the user +# Default is to disable them, unless 'enable' is passed literally. +# For symmetry, 'disable' may be passed as well. Anyway, the user # can override the default with the --enable/--disable switch. AC_DEFUN([AM_MAINTAINER_MODE], [m4_case(m4_default([$1], [disable]), @@ -8569,13 +676,14 @@ AC_DEFUN([AM_MAINTAINER_MODE], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) +AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], -[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful - (and sometimes confusing) to the casual installer], - [USE_MAINTAINER_MODE=$enableval], - [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode], + am_maintainer_other[ make rules and dependencies not useful + (and sometimes confusing) to the casual installer])], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) AC_MSG_RESULT([$USE_MAINTAINER_MODE]) AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) MAINT=$MAINTAINER_MODE_TRUE @@ -8583,71 +691,57 @@ AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of ] ) -AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) - # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 - # AM_MAKE_INCLUDE() # ----------------- -# Check to see how make treats includes. +# Check whether make has an 'include' directive that can support all +# the idioms we need for our automatic dependency tracking code. AC_DEFUN([AM_MAKE_INCLUDE], -[am_make=${MAKE-make} -cat > confinc << 'END' +[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive]) +cat > confinc.mk << 'END' am__doit: - @echo this is the am__doit target + @echo this is the am__doit target >confinc.out .PHONY: am__doit END -# If we don't find an include directive, just comment out the code. -AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD - ;; - esac -fi -AC_SUBST([am__include]) -AC_SUBST([am__quote]) -AC_MSG_RESULT([$_am_result]) -rm -f confinc confmf -]) +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out]) + AS_CASE([$?:`cat confinc.out 2>/dev/null`], + ['0:this is the am__doit target'], + [AS_CASE([$s], + [BSD], [am__include='.include' am__quote='"'], + [am__include='include' am__quote=''])]) + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +AC_MSG_RESULT([${_am_result}]) +AC_SUBST([am__include])]) +AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1997-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 6 - # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], @@ -8655,11 +749,10 @@ AC_DEFUN([AM_MISSING_PROG], $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) - # AM_MISSING_HAS_RUN # ------------------ -# Define MISSING if not defined so far and test if it supports --run. -# If it does, set am_missing_run to use it, otherwise, to nothing. +# Define MISSING if not defined so far and test if it is modern enough. +# If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl @@ -8672,63 +765,35 @@ if test x"${MISSING+set}" != xset; then esac fi # Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " else am_missing_run= - AC_MSG_WARN([`missing' script is too old or missing]) + AC_MSG_WARN(['missing' script is too old or missing]) fi ]) -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_MKDIR_P -# --------------- -# Check for `mkdir -p'. -AC_DEFUN([AM_PROG_MKDIR_P], -[AC_PREREQ([2.60])dnl -AC_REQUIRE([AC_PROG_MKDIR_P])dnl -dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, -dnl while keeping a definition of mkdir_p for backward compatibility. -dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. -dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of -dnl Makefile.ins that do not define MKDIR_P, so we do our own -dnl adjustment using top_builddir (which is defined more often than -dnl MKDIR_P). -AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl -case $mkdir_p in - [[\\/$]]* | ?:[[\\/]]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac -]) - # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 4 - # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) -# ------------------------------ +# -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], -[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) +[m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) -# ---------------------------------- +# ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) @@ -8739,24 +804,82 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Check to make sure that the build environment is sane. -*- Autoconf -*- - -# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 -# Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 5 +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_RUN_LOG(COMMAND) +# ------------------- +# Run COMMAND, save the exit status in ac_status, and log it. +# (This has been adapted from Autoconf's _AC_RUN_LOG macro.) +AC_DEFUN([AM_RUN_LOG], +[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD + ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + (exit $ac_status); }]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' @@ -8767,32 +890,40 @@ case `pwd` in esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) - AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; + AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac -# Do `set' in a subshell so we don't clobber the current shell's +# Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$[*]" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$[*]" != "X $srcdir/configure conftest.file" \ - && test "$[*]" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken -alias in your environment]) - fi + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken + alias in your environment]) + fi + if test "$[2]" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done test "$[2]" = conftest.file ) then @@ -8802,9 +933,85 @@ else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi -AC_MSG_RESULT(yes)]) +AC_MSG_RESULT([yes]) +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi +AC_CONFIG_COMMANDS_PRE( + [AC_MSG_CHECKING([that generated files are newer than configure]) + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + AC_MSG_RESULT([done])]) +rm -f conftest.file +]) -# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2009-2018 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_SILENT_RULES([DEFAULT]) +# -------------------------- +# Enable less verbose build rules; with the default set to DEFAULT +# ("yes" being less verbose, "no" or empty being verbose). +AC_DEFUN([AM_SILENT_RULES], +[AC_ARG_ENABLE([silent-rules], [dnl +AS_HELP_STRING( + [--enable-silent-rules], + [less verbose build output (undo: "make V=1")]) +AS_HELP_STRING( + [--disable-silent-rules], + [verbose build output (undo: "make V=0")])dnl +]) +case $enable_silent_rules in @%:@ ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; +esac +dnl +dnl A few 'make' implementations (e.g., NonStop OS and NextStep) +dnl do not support nested variable expansions. +dnl See automake bug#9928 and bug#10237. +am_make=${MAKE-make} +AC_CACHE_CHECK([whether $am_make supports nested variables], + [am_cv_make_support_nested_variables], + [if AS_ECHO([['TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi]) +if test $am_cv_make_support_nested_variables = yes; then + dnl Using '$V' instead of '$(V)' breaks IRIX make. + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AC_SUBST([AM_V])dnl +AM_SUBST_NOTMAKE([AM_V])dnl +AC_SUBST([AM_DEFAULT_V])dnl +AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl +AC_SUBST([AM_DEFAULT_VERBOSITY])dnl +AM_BACKSLASH='\' +AC_SUBST([AM_BACKSLASH])dnl +_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl +]) + +# Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -8812,34 +1019,32 @@ AC_MSG_RESULT(yes)]) # AM_PROG_INSTALL_STRIP # --------------------- -# One issue with vendor `install' (even GNU) is that you can't +# One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we -# always use install-sh in `make install-strip', and initialize +# always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. -dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +# will honor the 'STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. @@ -8847,24 +1052,22 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# --------------------------- +# -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004-2018 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 2 - # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. -# FORMAT should be one of `v7', `ustar', or `pax'. +# FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory @@ -8874,76 +1077,120 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar +# AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) -m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], - [m4_case([$1], [ustar],, [pax],, - [m4_fatal([Unknown tar format])]) -AC_MSG_CHECKING([how to create a $1 tar archive]) -# Loop over all known methods to create a tar archive until one works. +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) + +# We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' -_am_tools=${am_cv_prog_tar_$1-$_am_tools} -# Do not fold the above two line into one, because Tru64 sh and -# Solaris sh will not grok spaces in the rhs of `-'. -for _am_tool in $_am_tools -do - case $_am_tool in - gnutar) - for _am_tar in tar gnutar gtar; - do - AM_RUN_LOG([$_am_tar --version]) && break - done - am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' - am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' - am__untar="$_am_tar -xf -" - ;; - plaintar) - # Must skip GNU tar: if it does not support --format= it doesn't create - # ustar tarball either. - (tar --version) >/dev/null 2>&1 && continue - am__tar='tar chf - "$$tardir"' - am__tar_='tar chf - "$tardir"' - am__untar='tar xf -' - ;; - pax) - am__tar='pax -L -x $1 -w "$$tardir"' - am__tar_='pax -L -x $1 -w "$tardir"' - am__untar='pax -r' - ;; - cpio) - am__tar='find "$$tardir" -print | cpio -o -H $1 -L' - am__tar_='find "$tardir" -print | cpio -o -H $1 -L' - am__untar='cpio -i -H $1 -d' - ;; - none) - am__tar=false - am__tar_=false - am__untar=false - ;; - esac - # If the value was cached, stop now. We just wanted to have am__tar - # and am__untar set. - test -n "${am_cv_prog_tar_$1}" && break +m4_if([$1], [v7], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], - # tar/untar a dummy directory, and stop if the command works + [m4_case([$1], + [ustar], + [# The POSIX 1988 'ustar' format is defined with fixed-size fields. + # There is notably a 21 bits limit for the UID and the GID. In fact, + # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 + # and bug#13588). + am_max_uid=2097151 # 2^21 - 1 + am_max_gid=$am_max_uid + # The $UID and $GID variables are not portable, so we need to resort + # to the POSIX-mandated id(1) utility. Errors in the 'id' calls + # below are definitely unexpected, so allow the users to see them + # (that is, avoid stderr redirection). + am_uid=`id -u || echo unknown` + am_gid=`id -g || echo unknown` + AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) + if test $am_uid -le $am_max_uid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi + AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) + if test $am_gid -le $am_max_gid; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + _am_tools=none + fi], + + [pax], + [], + + [m4_fatal([Unknown tar format])]) + + AC_MSG_CHECKING([how to create a $1 tar archive]) + + # Go ahead even if we have the value already cached. We do so because we + # need to set the values for the 'am__tar' and 'am__untar' variables. + _am_tools=${am_cv_prog_tar_$1-$_am_tools} + + for _am_tool in $_am_tools; do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works. + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi + done rm -rf conftest.dir - mkdir conftest.dir - echo GrepMe > conftest.dir/file - AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) - rm -rf conftest.dir - if test -s conftest.tar; then - AM_RUN_LOG([$am__untar /dev/null 2>&1 && break - fi -done -rm -rf conftest.dir -AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) -AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) + AC_MSG_RESULT([$am_cv_prog_tar_$1])]) + AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +m4_include([scripts/libtool.m4]) +m4_include([scripts/ltoptions.m4]) +m4_include([scripts/ltsugar.m4]) +m4_include([scripts/ltversion.m4]) +m4_include([scripts/lt~obsolete.m4]) diff --git a/libs/libpng-src/arm/arm_init.c b/libs/libpng-src/arm/arm_init.c new file mode 100644 index 000000000..a34ecdbef --- /dev/null +++ b/libs/libpng-src/arm/arm_init.c @@ -0,0 +1,136 @@ + +/* arm_init.c - NEON optimised filter functions + * + * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2014,2016 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are + * called. + */ +#define _POSIX_SOURCE 1 + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +#if PNG_ARM_NEON_OPT > 0 +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */ +/* WARNING: it is strongly recommended that you do not build libpng with + * run-time checks for CPU features if at all possible. In the case of the ARM + * NEON instructions there is no processor-specific way of detecting the + * presence of the required support, therefore run-time detection is extremely + * OS specific. + * + * You may set the macro PNG_ARM_NEON_FILE to the file name of file containing + * a fragment of C source code which defines the png_have_neon function. There + * are a number of implementations in contrib/arm-neon, but the only one that + * has partial support is contrib/arm-neon/linux.c - a generic Linux + * implementation which reads /proc/cpufino. + */ +#ifndef PNG_ARM_NEON_FILE +# ifdef __linux__ +# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c" +# endif +#endif + +#ifdef PNG_ARM_NEON_FILE + +#include /* for sig_atomic_t */ +static int png_have_neon(png_structp png_ptr); +#include PNG_ARM_NEON_FILE + +#else /* PNG_ARM_NEON_FILE */ +# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks" +#endif /* PNG_ARM_NEON_FILE */ +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifndef PNG_ALIGNED_MEMORY_SUPPORTED +# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +#endif + +void +png_init_filter_functions_neon(png_structp pp, unsigned int bpp) +{ + /* The switch statement is compiled in for ARM_NEON_API, the call to + * png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined + * the check is only performed if the API has not set the NEON option on + * or off explicitly. In this case the check controls what happens. + * + * If the CHECK is not compiled in and the option is UNSET the behavior prior + * to 1.6.7 was to use the NEON code - this was a bug caused by having the + * wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF, + * as documented in png.h + */ + png_debug(1, "in png_init_filter_functions_neon"); +#ifdef PNG_ARM_NEON_API_SUPPORTED + switch ((pp->options >> PNG_ARM_NEON) & 3) + { + case PNG_OPTION_UNSET: + /* Allow the run-time check to execute if it has been enabled - + * thus both API and CHECK can be turned on. If it isn't supported + * this case will fall through to the 'default' below, which just + * returns. + */ +#endif /* PNG_ARM_NEON_API_SUPPORTED */ +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED + { + static volatile sig_atomic_t no_neon = -1; /* not checked */ + + if (no_neon < 0) + no_neon = !png_have_neon(pp); + + if (no_neon) + return; + } +#ifdef PNG_ARM_NEON_API_SUPPORTED + break; +#endif +#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ + +#ifdef PNG_ARM_NEON_API_SUPPORTED + default: /* OFF or INVALID */ + return; + + case PNG_OPTION_ON: + /* Option turned on */ + break; + } +#endif + + /* IMPORTANT: any new external functions used here must be declared using + * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the + * 'prefix' option to configure works: + * + * ./configure --with-libpng-prefix=foobar_ + * + * Verify you have got this right by running the above command, doing a build + * and examining pngprefix.h; it must contain a #define for every external + * function you add. (Notice that this happens automatically for the + * initialization function.) + */ + pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon; + + if (bpp == 3) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth3_neon; + } + + else if (bpp == 4) + { + pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon; + pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon; + pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = + png_read_filter_row_paeth4_neon; + } +} +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* READ */ diff --git a/libs/libpng-src/arm/filter_neon.S b/libs/libpng-src/arm/filter_neon.S new file mode 100644 index 000000000..2308aad13 --- /dev/null +++ b/libs/libpng-src/arm/filter_neon.S @@ -0,0 +1,253 @@ + +/* filter_neon.S - NEON optimised filter functions + * + * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2014,2017 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +/* This is required to get the symbol renames, which are #defines, and the + * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION. + */ +#define PNG_VERSION_INFO_ONLY +#include "../pngpriv.h" + +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ +#endif + +#ifdef PNG_READ_SUPPORTED + +/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for + * ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it + * only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h + * for the logic which sets PNG_USE_ARM_NEON_ASM: + */ +#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */ + +#if PNG_ARM_NEON_OPT > 0 + +#ifdef __ELF__ +# define ELF +#else +# define ELF @ +#endif + + .arch armv7-a + .fpu neon + +.macro func name, export=0 + .macro endfunc +ELF .size \name, . - \name + .endfunc + .purgem endfunc + .endm + .text + + /* Explicitly specifying alignment here because some versions of + * GAS don't align code correctly. This is harmless in correctly + * written versions of GAS. + */ + .align 2 + + .if \export + .global \name + .endif +ELF .type \name, STT_FUNC + .func \name +\name: +.endm + +func png_read_filter_row_sub4_neon, export=1 + ldr r3, [r0, #4] @ rowbytes + vmov.i8 d3, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vadd.u8 d0, d3, d4 + vadd.u8 d1, d0, d5 + vadd.u8 d2, d1, d6 + vadd.u8 d3, d2, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r3, r3, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_sub3_neon, export=1 + ldr r3, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + mov r0, r1 + mov r2, #3 + mov r12, #12 + vld1.8 {q11}, [r0], r12 +1: + vext.8 d5, d22, d23, #3 + vadd.u8 d0, d3, d22 + vext.8 d6, d22, d23, #6 + vadd.u8 d1, d0, d5 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], r12 + vst1.32 {d0[0]}, [r1,:32], r2 + vadd.u8 d2, d1, d6 + vst1.32 {d1[0]}, [r1], r2 + vadd.u8 d3, d2, d7 + vst1.32 {d2[0]}, [r1], r2 + vst1.32 {d3[0]}, [r1], r2 + subs r3, r3, #12 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_up_neon, export=1 + ldr r3, [r0, #4] @ rowbytes +1: + vld1.8 {q0}, [r1,:128] + vld1.8 {q1}, [r2,:128]! + vadd.u8 q0, q0, q1 + vst1.8 {q0}, [r1,:128]! + subs r3, r3, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_avg4_neon, export=1 + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! + vhadd.u8 d0, d3, d16 + vadd.u8 d0, d0, d4 + vhadd.u8 d1, d0, d17 + vadd.u8 d1, d1, d5 + vhadd.u8 d2, d1, d18 + vadd.u8 d2, d2, d6 + vhadd.u8 d3, d2, d19 + vadd.u8 d3, d3, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r12, r12, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_avg3_neon, export=1 + push {r4,lr} + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + mov r0, r1 + mov r4, #3 + mov lr, #12 + vld1.8 {q11}, [r0], lr +1: + vld1.8 {q10}, [r2], lr + vext.8 d5, d22, d23, #3 + vhadd.u8 d0, d3, d20 + vext.8 d17, d20, d21, #3 + vadd.u8 d0, d0, d22 + vext.8 d6, d22, d23, #6 + vhadd.u8 d1, d0, d17 + vext.8 d18, d20, d21, #6 + vadd.u8 d1, d1, d5 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], lr + vst1.32 {d0[0]}, [r1,:32], r4 + vhadd.u8 d2, d1, d18 + vst1.32 {d1[0]}, [r1], r4 + vext.8 d19, d21, d21, #1 + vadd.u8 d2, d2, d6 + vhadd.u8 d3, d2, d19 + vst1.32 {d2[0]}, [r1], r4 + vadd.u8 d3, d3, d7 + vst1.32 {d3[0]}, [r1], r4 + subs r12, r12, #12 + bgt 1b + + pop {r4,pc} +endfunc + +.macro paeth rx, ra, rb, rc + vaddl.u8 q12, \ra, \rb @ a + b + vaddl.u8 q15, \rc, \rc @ 2*c + vabdl.u8 q13, \rb, \rc @ pa + vabdl.u8 q14, \ra, \rc @ pb + vabd.u16 q15, q12, q15 @ pc + vcle.u16 q12, q13, q14 @ pa <= pb + vcle.u16 q13, q13, q15 @ pa <= pc + vcle.u16 q14, q14, q15 @ pb <= pc + vand q12, q12, q13 @ pa <= pb && pa <= pc + vmovn.u16 d28, q14 + vmovn.u16 \rx, q12 + vbsl d28, \rb, \rc + vbsl \rx, \ra, d28 +.endm + +func png_read_filter_row_paeth4_neon, export=1 + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + vmov.i8 d20, #0 +1: + vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128] + vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]! + paeth d0, d3, d16, d20 + vadd.u8 d0, d0, d4 + paeth d1, d0, d17, d16 + vadd.u8 d1, d1, d5 + paeth d2, d1, d18, d17 + vadd.u8 d2, d2, d6 + paeth d3, d2, d19, d18 + vmov d20, d19 + vadd.u8 d3, d3, d7 + vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]! + subs r12, r12, #16 + bgt 1b + + bx lr +endfunc + +func png_read_filter_row_paeth3_neon, export=1 + push {r4,lr} + ldr r12, [r0, #4] @ rowbytes + vmov.i8 d3, #0 + vmov.i8 d4, #0 + mov r0, r1 + mov r4, #3 + mov lr, #12 + vld1.8 {q11}, [r0], lr +1: + vld1.8 {q10}, [r2], lr + paeth d0, d3, d20, d4 + vext.8 d5, d22, d23, #3 + vadd.u8 d0, d0, d22 + vext.8 d17, d20, d21, #3 + paeth d1, d0, d17, d20 + vst1.32 {d0[0]}, [r1,:32], r4 + vext.8 d6, d22, d23, #6 + vadd.u8 d1, d1, d5 + vext.8 d18, d20, d21, #6 + paeth d2, d1, d18, d17 + vext.8 d7, d23, d23, #1 + vld1.8 {q11}, [r0], lr + vst1.32 {d1[0]}, [r1], r4 + vadd.u8 d2, d2, d6 + vext.8 d19, d21, d21, #1 + paeth d3, d2, d19, d18 + vst1.32 {d2[0]}, [r1], r4 + vmov d4, d19 + vadd.u8 d3, d3, d7 + vst1.32 {d3[0]}, [r1], r4 + subs r12, r12, #12 + bgt 1b + + pop {r4,pc} +endfunc +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */ +#endif /* READ */ diff --git a/libs/libpng-src/arm/filter_neon_intrinsics.c b/libs/libpng-src/arm/filter_neon_intrinsics.c new file mode 100644 index 000000000..553c0be21 --- /dev/null +++ b/libs/libpng-src/arm/filter_neon_intrinsics.c @@ -0,0 +1,402 @@ + +/* filter_neon_intrinsics.c - NEON optimised filter functions + * + * Copyright (c) 2018 Cosmin Truta + * Copyright (c) 2014,2016 Glenn Randers-Pehrson + * Written by James Yu , October 2013. + * Based on filter_neon.S, written by Mans Rullgard, 2011. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#ifdef PNG_READ_SUPPORTED + +/* This code requires -mfpu=neon on the command line: */ +#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */ + +#if defined(_MSC_VER) && defined(_M_ARM64) +# include +#else +# include +#endif + +/* libpng row pointers are not necessarily aligned to any particular boundary, + * however this code will only work with appropriate alignment. arm/arm_init.c + * checks for this (and will not compile unless it is done). This code uses + * variants of png_aligncast to avoid compiler warnings. + */ +#define png_ptr(type,pointer) png_aligncast(type *,pointer) +#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer) + +/* The following relies on a variable 'temp_pointer' being declared with type + * 'type'. This is written this way just to hide the GCC strict aliasing + * warning; note that the code is safe because there never is an alias between + * the input and output pointers. + * + * When compiling with MSVC ARM64, the png_ldr macro can't be passed directly + * to vst4_lane_u32, because of an internal compiler error inside MSVC. + * To avoid this compiler bug, we use a temporary variable (vdest_val) to store + * the result of png_ldr. + */ +#define png_ldr(type,pointer)\ + (temp_pointer = png_ptr(type,pointer), *temp_pointer) + +#if PNG_ARM_NEON_OPT > 0 + +void +png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + png_debug(1, "in png_read_filter_row_up_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint8x16_t qrp, qpp; + + qrp = vld1q_u8(rp); + qpp = vld1q_u8(pp); + qrp = vaddq_u8(qrp, qpp); + vst1q_u8(rp, qrp); + } +} + +void +png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp = vld1q_u8(rp); + uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp); + uint8x8x2_t vrp = *vrpt; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_sub3_neon"); + + for (; rp < rp_stop;) + { + uint8x8_t vtmp1, vtmp2; + uint32x2_t *temp_pointer; + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]); + vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6); + vdest.val[1] = vadd_u8(vdest.val[0], vtmp1); + + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + vdest.val[2] = vadd_u8(vdest.val[1], vtmp2); + vdest.val[3] = vadd_u8(vdest.val[2], vtmp1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t, &vtmp); + vrp = *vrpt; + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } + + PNG_UNUSED(prev_row) +} + +void +png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_sub4_neon"); + + for (; rp < rp_stop; rp += 16) + { + uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp)); + uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp); + uint8x8x4_t vrp = *vrpt; + uint32x2x4_t *temp_pointer; + uint32x2x4_t vdest_val; + + vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]); + vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]); + vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]); + + vdest_val = png_ldr(uint32x2x4_t, &vdest); + vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0); + } + + PNG_UNUSED(prev_row) +} + +void +png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_const_bytep pp = prev_row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp; + uint8x8x2_t *vrpt; + uint8x8x2_t vrp; + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + vtmp = vld1q_u8(rp); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + png_debug(1, "in png_read_filter_row_avg3_neon"); + + for (; rp < rp_stop; pp += 12) + { + uint8x8_t vtmp1, vtmp2, vtmp3; + + uint8x8x2_t *vppt; + uint8x8x2_t vpp; + + uint32x2_t *temp_pointer; + + vtmp = vld1q_u8(pp); + vppt = png_ptr(uint8x8x2_t,&vtmp); + vpp = *vppt; + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3); + vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6); + vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2); + vdest.val[1] = vadd_u8(vdest.val[1], vtmp1); + + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6); + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2); + vdest.val[2] = vadd_u8(vdest.val[2], vtmp3); + + vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1); + + vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2); + vdest.val[3] = vadd_u8(vdest.val[3], vtmp1); + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } +} + +void +png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_avg4_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint32x2x4_t vtmp; + uint8x8x4_t *vrpt, *vppt; + uint8x8x4_t vrp, vpp; + uint32x2x4_t *temp_pointer; + uint32x2x4_t vdest_val; + + vtmp = vld4_u32(png_ptr(uint32_t,rp)); + vrpt = png_ptr(uint8x8x4_t,&vtmp); + vrp = *vrpt; + vtmp = vld4_u32(png_ptrc(uint32_t,pp)); + vppt = png_ptr(uint8x8x4_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]); + vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]); + vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]); + vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]); + vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]); + vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]); + + vdest_val = png_ldr(uint32x2x4_t, &vdest); + vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0); + } +} + +static uint8x8_t +paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c) +{ + uint8x8_t d, e; + uint16x8_t p1, pa, pb, pc; + + p1 = vaddl_u8(a, b); /* a + b */ + pc = vaddl_u8(c, c); /* c * 2 */ + pa = vabdl_u8(b, c); /* pa */ + pb = vabdl_u8(a, c); /* pb */ + pc = vabdq_u16(p1, pc); /* pc */ + + p1 = vcleq_u16(pa, pb); /* pa <= pb */ + pa = vcleq_u16(pa, pc); /* pa <= pc */ + pb = vcleq_u16(pb, pc); /* pb <= pc */ + + p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */ + + d = vmovn_u16(pb); + e = vmovn_u16(p1); + + d = vbsl_u8(d, b, c); + e = vbsl_u8(e, a, d); + + return e; +} + +void +png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_const_bytep pp = prev_row; + png_bytep rp_stop = row + row_info->rowbytes; + + uint8x16_t vtmp; + uint8x8x2_t *vrpt; + uint8x8x2_t vrp; + uint8x8_t vlast = vdup_n_u8(0); + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + vtmp = vld1q_u8(rp); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + png_debug(1, "in png_read_filter_row_paeth3_neon"); + + for (; rp < rp_stop; pp += 12) + { + uint8x8x2_t *vppt; + uint8x8x2_t vpp; + uint8x8_t vtmp1, vtmp2, vtmp3; + uint32x2_t *temp_pointer; + + vtmp = vld1q_u8(pp); + vppt = png_ptr(uint8x8x2_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3); + vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3); + vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[1], vtmp1); + + vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6); + vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6); + vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2); + vdest.val[2] = vadd_u8(vdest.val[2], vtmp1); + + vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1); + vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1); + + vtmp = vld1q_u8(rp + 12); + vrpt = png_ptr(uint8x8x2_t,&vtmp); + vrp = *vrpt; + + vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3); + vdest.val[3] = vadd_u8(vdest.val[3], vtmp1); + + vlast = vtmp2; + + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0); + rp += 3; + vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0); + rp += 3; + } +} + +void +png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row, + png_const_bytep prev_row) +{ + png_bytep rp = row; + png_bytep rp_stop = row + row_info->rowbytes; + png_const_bytep pp = prev_row; + + uint8x8_t vlast = vdup_n_u8(0); + uint8x8x4_t vdest; + vdest.val[3] = vdup_n_u8(0); + + png_debug(1, "in png_read_filter_row_paeth4_neon"); + + for (; rp < rp_stop; rp += 16, pp += 16) + { + uint32x2x4_t vtmp; + uint8x8x4_t *vrpt, *vppt; + uint8x8x4_t vrp, vpp; + uint32x2x4_t *temp_pointer; + uint32x2x4_t vdest_val; + + vtmp = vld4_u32(png_ptr(uint32_t,rp)); + vrpt = png_ptr(uint8x8x4_t,&vtmp); + vrp = *vrpt; + vtmp = vld4_u32(png_ptrc(uint32_t,pp)); + vppt = png_ptr(uint8x8x4_t,&vtmp); + vpp = *vppt; + + vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast); + vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]); + vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]); + vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]); + vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]); + vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]); + vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]); + vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]); + + vlast = vpp.val[3]; + + vdest_val = png_ldr(uint32x2x4_t, &vdest); + vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0); + } +} + +#endif /* PNG_ARM_NEON_OPT > 0 */ +#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */ +#endif /* READ */ diff --git a/libs/libpng-src/arm/palette_neon_intrinsics.c b/libs/libpng-src/arm/palette_neon_intrinsics.c new file mode 100644 index 000000000..b4d1fd2ab --- /dev/null +++ b/libs/libpng-src/arm/palette_neon_intrinsics.c @@ -0,0 +1,149 @@ + +/* palette_neon_intrinsics.c - NEON optimised palette expansion functions + * + * Copyright (c) 2018-2019 Cosmin Truta + * Copyright (c) 2017-2018 Arm Holdings. All rights reserved. + * Written by Richard Townsend , February 2017. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + */ + +#include "../pngpriv.h" + +#if PNG_ARM_NEON_IMPLEMENTATION == 1 + +#if defined(_MSC_VER) && defined(_M_ARM64) +# include +#else +# include +#endif + +/* Build an RGBA8 palette from the separate RGB and alpha palettes. */ +void +png_riffle_palette_neon(png_structrp png_ptr) +{ + png_const_colorp palette = png_ptr->palette; + png_bytep riffled_palette = png_ptr->riffled_palette; + png_const_bytep trans_alpha = png_ptr->trans_alpha; + int num_trans = png_ptr->num_trans; + int i; + + png_debug(1, "in png_riffle_palette_neon"); + + /* Initially black, opaque. */ + uint8x16x4_t w = {{ + vdupq_n_u8(0x00), + vdupq_n_u8(0x00), + vdupq_n_u8(0x00), + vdupq_n_u8(0xff), + }}; + + /* First, riffle the RGB colours into an RGBA8 palette. + * The alpha component is set to opaque for now. + */ + for (i = 0; i < 256; i += 16) + { + uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i)); + w.val[0] = v.val[0]; + w.val[1] = v.val[1]; + w.val[2] = v.val[2]; + vst4q_u8(riffled_palette + (i << 2), w); + } + + /* Fix up the missing transparency values. */ + for (i = 0; i < num_trans; i++) + riffled_palette[(i << 2) + 3] = trans_alpha[i]; +} + +/* Expands a palettized row into RGBA8. */ +int +png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info, + png_const_bytep row, png_bytepp ssp, png_bytepp ddp) +{ + png_uint_32 row_width = row_info->width; + const png_uint_32 *riffled_palette = + (const png_uint_32 *)png_ptr->riffled_palette; + const png_int_32 pixels_per_chunk = 4; + int i; + + png_debug(1, "in png_do_expand_palette_rgba8_neon"); + + if (row_width < pixels_per_chunk) + return 0; + + /* This function originally gets the last byte of the output row. + * The NEON part writes forward from a given position, so we have + * to seek this back by 4 pixels x 4 bytes. + */ + *ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1); + + for (i = 0; i < row_width; i += pixels_per_chunk) + { + uint32x4_t cur; + png_bytep sp = *ssp - i, dp = *ddp - (i << 2); + cur = vld1q_dup_u32 (riffled_palette + *(sp - 3)); + cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1); + cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2); + cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3); + vst1q_u32((void *)dp, cur); + } + if (i != row_width) + { + /* Remove the amount that wasn't processed. */ + i -= pixels_per_chunk; + } + + /* Decrement output pointers. */ + *ssp = *ssp - i; + *ddp = *ddp - (i << 2); + return i; +} + +/* Expands a palettized row into RGB8. */ +int +png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info, + png_const_bytep row, png_bytepp ssp, png_bytepp ddp) +{ + png_uint_32 row_width = row_info->width; + png_const_bytep palette = (png_const_bytep)png_ptr->palette; + const png_uint_32 pixels_per_chunk = 8; + int i; + + png_debug(1, "in png_do_expand_palette_rgb8_neon"); + + if (row_width <= pixels_per_chunk) + return 0; + + /* Seeking this back by 8 pixels x 3 bytes. */ + *ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1); + + for (i = 0; i < row_width; i += pixels_per_chunk) + { + uint8x8x3_t cur; + png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i); + cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7))); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6); + cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7); + vst3_u8((void *)dp, cur); + } + + if (i != row_width) + { + /* Remove the amount that wasn't processed. */ + i -= pixels_per_chunk; + } + + /* Decrement output pointers. */ + *ssp = *ssp - i; + *ddp = *ddp - ((i << 1) + i); + return i; +} + +#endif /* PNG_ARM_NEON_IMPLEMENTATION */ diff --git a/libs/libpng-src/autogen.sh b/libs/libpng-src/autogen.sh index 77b63087c..a46daf65a 100755 --- a/libs/libpng-src/autogen.sh +++ b/libs/libpng-src/autogen.sh @@ -1,25 +1,225 @@ #! /bin/sh -# a quick hack script to generate necessary files from -# auto* tools. # -# WARNING: if you run this you will change the versions -# of the tools which are used and, maybe, required! - touch Makefile.am configure.ac -{ - echo "running libtoolize" >&2 - libtoolize --force --copy --automake -} && { - echo "running aclocal" >&2 - aclocal -} && { - echo "running autoheader [ignore the warnings]" >&2 - autoheader -} && { - echo "running automake" >&2 - automake --force-missing --foreign -a -c -} && { - echo "running autoconf" >&2 - autoconf -} && - echo "autogen complete" >&2 || - echo "ERROR: autogen.sh failed, autogen is incomplete" >&2 +# Run 'autoreconf' to build 'configure', 'Makefile.in' and other configure +# control files. +# +# The first time this is run on a GIT checkout the only files that exist are +# configure.ac and Makefile.am; all of the autotools support scripts are +# missing. They are instantiated with autoreconf --force --install. +# +# For regular ("tarball") distributions all the files should exist. We do not +# want them to be updated *under any circumstances*. It should never be +# necessary to run autogen.sh because ./configure --enable-maintainer-mode says +# what to do if Makefile.am or configure.ac are changed. +# +# It is *probably* OK to update the files on a GIT checkout, because they have +# come from the local tools, but leave that to the user who is assumed to know +# whether it is ok or required. +# +# This script is intended to work without arguments, there are, however, hidden +# arguments (a) for use while testing the script and (b) to fix up systems that +# have been broken. If (b) is required the script prompts for the correct +# options. For this reason the options are *NOT* documented in the help; this +# is deliberate; UTSL. +# +clean= +maintainer= +while test $# -gt 0 +do + case "$1" in + --maintainer) + maintainer=1;; + + --clean) + clean=1;; + + *) + exec >&2 + echo "$0: usage: ./autogen.sh" + if test -d .git + then + echo " ./autogen.sh generates the configure script and" + echo " Makefile.in, or refreshes them after changes to Makefile.am" + echo " or configure.ac. You may prefer to just run autoreconf." + elif test -z "$maintainer" + then + echo " DO NOT RUN THIS SCRIPT." + echo " If you need to change Makefile.am or configure.ac then you" + echo " also need to run ./configure --enable-maintainer-mode and" + echo " use the appropriate autotools, *NOT* this script, to update" + echo " everything, please check the documentation of autoreconf." + echo " WARNING: libpng is intentionally generated with a known," + echo " fixed, set of autotools. It is known *NOT* to work with" + echo " the collection of autotools distributed on highly reputable" + echo " operating systems." + echo " Remember: autotools is GNU software, you are expected to" + echo " pay for support." + else + echo " You have run autogen.sh with --maintainer enabled and you" + echo " are not using a GIT distribution, then you have given an" + echo " unrecognized argument. This is not good. --maintainer" + echo " switches off any assumptions that you might not know what" + echo " you are doing." + fi + exit 1;; + esac + + shift +done +# +# First check for a set of the autotools files; if absent then this is assumed +# to be a GIT version and the local autotools must be used. If present this +# is a tarball distribution and the script should not be used. If partially +# present bad things are happening. +# +# The autotools generated files: +libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in + config.sub configure depcomp install-sh ltmain.sh missing\ + test-driver" +# +# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later +# versions than those required by configure.ac): +libpng_autotools_extra="compile config.h.in~" +# +# These are separate because 'maintainer-clean' does not remove them. +libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\ + scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4" + +libpng_autotools_dirs="autom4te.cache" # not required +# +# The configure generated files: +libpng_configure_files="Makefile config.h config.log config.status\ + libpng-config libpng.pc libtool stamp-h1" + +libpng_configure_dirs=".deps" +# +# We must remove the configure generated files as well as the autotools +# generated files if autotools are regenerated because otherwise if configure +# has been run without "--enable-maintainer-mode" make can do a partial update +# of Makefile. These functions do the two bits of cleaning. +clean_autotools(){ + rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs + rm -rf $libpng_autotools_extra +} + +clean_configure(){ + rm -rf $libpng_configure_files $libpng_configure_dirs +} +# +# Clean: remove everything (this is to help with testing) +if test -n "$clean" +then + clean_configure + if test -n "$maintainer" + then + clean_autotools + fi + + exit 0 +fi +# +# Validate the distribution. +libpng_autotools_file_found= +libpng_autotools_file_missing= +for file in $libpng_autotools_files +do + if test -f "$file" + then + libpng_autotools_file_found=1 + else + libpng_autotools_file_missing=1 + fi +done +# +# Presence of one of these does not *invalidate* missing, but absence +# invalidates found. +for file in $libpng_libtool_files +do + if test ! -f "$file" + then + libpng_autotools_file_missing=1 + fi +done +# +# The cache directory doesn't matter - it will be regenerated and does not exist +# anyway in a tarball. +# +# Either everything is missing or everything is there, the --maintainer option +# just changes this so that the mode is set to generate all the files. +mode= +if test -z "$libpng_autotools_file_found" -o -n "$maintainer" +then + mode="autoreconf" +else + if test -n "$libpng_autotools_file_missing" + then + mode="broken" + else + mode="configure" + fi +fi +# +# So: +case "$mode" in + autoreconf) + # Clean in case configure files exist + clean_configure + clean_autotools + # Everything must be initialized, so use --force + if autoreconf --warnings=all --force --install + then + missing= + for file in $libpng_autotools_files + do + test -f "$file" || missing=1 + done + # ignore the cache directory + test -z "$missing" || { + exec >&2 + echo "autoreconf was run, but did not produce all the expected" + echo "files. It is likely that your autotools installation is" + echo "not compatible with that expected by libpng." + exit 1 + } + else + exec >&2 + echo "autoreconf failed: your version of autotools is incompatible" + echo "with this libpng version. Please use a distributed archive" + echo "(which includes the autotools generated files) and run configure" + echo "instead." + exit 1 + fi;; + + configure) + if test -d .git + then + exec >&2 + echo "ERROR: running autoreconf on an initialized system" + echo " This is not necessary; it is only necessary to remake the" + echo " autotools generated files if Makefile.am or configure.ac" + echo " change and make does the right thing with:" + echo + echo " ./configure --enable-maintainer-mode." + echo + echo " You can run autoreconf yourself if you don't like maintainer" + echo " mode and you can also just run autoreconf -f -i to initialize" + echo " everything in the first place; this script is only for" + echo " compatibility with prior releases." + exit 1 + else + exec >&2 + echo "autogen.sh is intended only to generate 'configure' on systems" + echo "that do not have it. You have a complete 'configure', if you" + echo "need to change Makefile.am or configure.ac you also need to" + echo "run configure with the --enable-maintainer-mode option." + exit 1 + fi;; + + broken) + exec >&2 + echo "Your system has a partial set of autotools generated files." + echo "autogen.sh is unable to proceed. The full set of files is" + echo "contained in the libpng 'tar' distribution archive and you do" + echo "not need to run autogen.sh if you use it." + exit 1;; +esac diff --git a/libs/libpng-src/compile b/libs/libpng-src/compile new file mode 100644 index 000000000..99e50524b --- /dev/null +++ b/libs/libpng-src/compile @@ -0,0 +1,348 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2018-03-07.03; # UTC + +# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'before-save-hook 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/libs/libpng-src/config.guess b/libs/libpng-src/config.guess index da8331460..256083a70 100755 --- a/libs/libpng-src/config.guess +++ b/libs/libpng-src/config.guess @@ -1,14 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2009-04-27' +timestamp='2018-03-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -17,26 +15,22 @@ timestamp='2009-04-27' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner . -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + me=`echo "$0" | sed -e 's,.*/,,'` @@ -45,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -56,8 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -114,9 +107,9 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -139,12 +132,40 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "$UNAME_SYSTEM" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # If ldd exists, use it to detect musl libc. + if command -v ldd >/dev/null && \ + ldd --version 2>&1 | grep -q ^musl + then + LIBC=musl + fi + ;; +esac + # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -154,23 +175,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + earmv*) + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown + ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -180,7 +211,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd + ;; + esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -188,42 +226,62 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" + echo "$machine-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -233,60 +291,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -295,12 +347,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -325,35 +377,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + eval "$set_cc_for_build" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -362,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -391,44 +446,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint"$UNAME_RELEASE" + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint"$UNAME_RELEASE" + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint"$UNAME_RELEASE" + exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -437,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -477,21 +532,21 @@ EOF echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -506,7 +561,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -518,14 +573,14 @@ EOF if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -536,7 +591,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -548,28 +603,29 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -584,67 +640,67 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` - sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "$sc_cpu_version" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "$sc_kernel_bits" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" - #define _HPUX_SOURCE - #include - #include + #define _HPUX_SOURCE + #include + #include - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -655,23 +711,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -696,11 +752,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -709,7 +765,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -717,9 +773,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -727,215 +783,126 @@ EOF exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin + exit ;; + *:MINGW64*:*) + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; - *:Interix*:[3456]*) - case ${UNAME_MACHINE} in + *:Interix*:*) + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; - EM64T | authenticamd | genuineintel) - echo x86_64-unknown-interix${UNAME_RELEASE} + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + echo "$UNAME_MACHINE"-pc-minix exit ;; - arm*:Linux:*:*) - eval $set_cc_for_build - if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep -q __ARM_EABI__ - then - echo ${UNAME_MACHINE}-unknown-linux-gnu - else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi - fi + aarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; - avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - cris:Linux:*:*) - echo cris-axis-linux-gnu - exit ;; - crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu - exit ;; - frv:Linux:*:*) - echo frv-unknown-linux-gnu - exit ;; - ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips64 - #undef mips64el - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu - exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -946,106 +913,144 @@ EOF EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + arm*:Linux:*:*) + eval "$set_cc_for_build" + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + else + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + cris:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + crisv32:Linux:*:*) + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + frv:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + hexagon:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + i*86:Linux:*:*) + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + exit ;; + ia64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m32r*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + m68*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } + ;; + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-"$LIBC" + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-gnu + echo sparc-unknown-linux-"$LIBC" + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-"$LIBC" + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-"$LIBC" + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-"$LIBC" + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + tile*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both @@ -1053,54 +1058,54 @@ EOF echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + # Use sysv4.2uw... so that sysv4* matches it. + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1110,20 +1115,20 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1132,9 +1137,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1154,39 +1159,39 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1197,15 +1202,15 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1217,25 +1222,25 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1248,53 +1253,97 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + eval "$set_cc_for_build" + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1303,18 +1352,18 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1335,14 +1384,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1351,182 +1400,48 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 +echo "$0: unable to guess system type" >&2 -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 </dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} +NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize +the system type. Please install a C compiler and try again. EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi + ;; +esac cat >&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp @@ -1545,16 +1460,16 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/libs/libpng-src/config.h.in b/libs/libpng-src/config.h.in index fb2349568..2931048bf 100644 --- a/libs/libpng-src/config.h.in +++ b/libs/libpng-src/config.h.in @@ -3,6 +3,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H +/* Define to 1 if you have the `feenableexcept' function. */ +#undef HAVE_FEENABLEEXCEPT + /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H @@ -12,15 +15,9 @@ /* Define to 1 if you have the `z' library (-lz). */ #undef HAVE_LIBZ -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW @@ -45,8 +42,7 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ +/* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ @@ -70,6 +66,36 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Turn on ARM Neon optimizations at run-time */ +#undef PNG_ARM_NEON_API_SUPPORTED + +/* Check for ARM Neon support at run-time */ +#undef PNG_ARM_NEON_CHECK_SUPPORTED + +/* Enable ARM Neon optimizations */ +#undef PNG_ARM_NEON_OPT + +/* Enable Intel SSE optimizations */ +#undef PNG_INTEL_SSE_OPT + +/* Turn on MIPS MSA optimizations at run-time */ +#undef PNG_MIPS_MSA_API_SUPPORTED + +/* Check for MIPS MSA support at run-time */ +#undef PNG_MIPS_MSA_CHECK_SUPPORTED + +/* Enable MIPS MSA optimizations */ +#undef PNG_MIPS_MSA_OPT + +/* Turn on POWERPC VSX optimizations at run-time */ +#undef PNG_POWERPC_VSX_API_SUPPORTED + +/* Check for POWERPC VSX support at run-time */ +#undef PNG_POWERPC_VSX_CHECK_SUPPORTED + +/* Enable POWERPC VSX optimizations */ +#undef PNG_POWERPC_VSX_OPT + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS @@ -82,5 +108,19 @@ /* Define to empty if `const' does not conform to ANSI C. */ #undef const +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + /* Define to `unsigned int' if does not define. */ #undef size_t diff --git a/libs/libpng-src/config.sub b/libs/libpng-src/config.sub index a39437d01..9ccf09a7a 100755 --- a/libs/libpng-src/config.sub +++ b/libs/libpng-src/config.sub @@ -1,44 +1,40 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 -# Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2009-04-17' +timestamp='2018-03-08' -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to . Submit a context -# diff and a properly formatted ChangeLog entry. +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -57,12 +53,11 @@ timestamp='2009-04-17' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -72,8 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright 1992-2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -100,7 +94,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -118,19 +112,24 @@ esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` + basic_machine=`echo "$1" | sed 's/-[^-]*$//'` + if [ "$basic_machine" != "$1" ] + then os=`echo "$1" | sed 's/.*-/-/'` else os=; fi ;; esac @@ -149,10 +148,13 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -167,62 +169,65 @@ case $os in os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'` ;; -psos*) os=-psos @@ -239,20 +244,29 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ - | fido | fr30 | frv \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -266,45 +280,80 @@ case $basic_machine in | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ - | nios | nios2 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ - | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) ;; ms1) basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. @@ -313,31 +362,38 @@ case $basic_machine in ;; # Object if more than one company name word. *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -351,32 +407,45 @@ case $basic_machine in | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ - | nios-* | nios2-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ - | romp-* | rs6000-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ - | v850-* | v850e-* | vax-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -388,7 +457,7 @@ case $basic_machine in # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) - basic_machine=i386-unknown + basic_machine=i386-pc os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) @@ -401,7 +470,7 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -422,7 +491,7 @@ case $basic_machine in basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl @@ -451,6 +520,9 @@ case $basic_machine in basic_machine=i386-pc os=-aros ;; + asmjs) + basic_machine=asmjs-unknown + ;; aux) basic_machine=m68k-apple os=-aux @@ -464,14 +536,27 @@ case $basic_machine in os=-linux ;; blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -503,7 +588,7 @@ case $basic_machine in basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -554,10 +639,18 @@ case $basic_machine in basic_machine=rs6000-bull os=-bosx ;; - dpx2* | dpx2*-bull) + dpx2*) basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -647,9 +740,6 @@ case $basic_machine in hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; hppaosf) basic_machine=hppa1.1-hp os=-osf @@ -661,28 +751,27 @@ case $basic_machine in i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; - i386-vsta | vsta) + vsta) basic_machine=i386-unknown os=-vsta ;; @@ -700,17 +789,17 @@ case $basic_machine in basic_machine=m68k-isi os=-sysv ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` + ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; - m88k-omron*) - basic_machine=m88k-omron - ;; magnum | m3230) basic_machine=mips-mips os=-sysv @@ -719,8 +808,15 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; mingw32ce) @@ -735,10 +831,10 @@ case $basic_machine in os=-mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k @@ -748,17 +844,29 @@ case $basic_machine in basic_machine=powerpc-unknown os=-morphos ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; ncr3000) basic_machine=i486-ncr os=-sysv4 @@ -787,7 +895,7 @@ case $basic_machine in basic_machine=v70-nec os=-sysv ;; - next | m*-next ) + next | m*-next) basic_machine=m68k-next case $os in -nextstep* ) @@ -823,9 +931,21 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -858,7 +978,7 @@ case $basic_machine in os=-linux ;; parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` os=-linux ;; pbd) @@ -874,7 +994,7 @@ case $basic_machine in basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc @@ -889,41 +1009,42 @@ case $basic_machine in basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm @@ -932,7 +1053,11 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; - rdos) + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) basic_machine=i386-pc os=-rdos ;; @@ -973,17 +1098,10 @@ case $basic_machine in sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; sh5el) basic_machine=sh5le-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -1001,6 +1119,9 @@ case $basic_machine in basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1057,20 +1178,8 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1133,6 +1242,9 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; + x64) + basic_machine=x86_64-pc + ;; xbox) basic_machine=i686-pc os=-mingw32 @@ -1140,18 +1252,13 @@ case $basic_machine in xps | xps100) basic_machine=xps100-honeywell ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + ;; ymp) basic_machine=ymp-cray os=-unicos ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; none) basic_machine=none-none os=-none @@ -1180,10 +1287,6 @@ case $basic_machine in vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; @@ -1193,9 +1296,6 @@ case $basic_machine in sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; @@ -1215,7 +1315,7 @@ case $basic_machine in # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac @@ -1223,10 +1323,10 @@ esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1237,53 +1337,60 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases that might get confused + # with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; - -svr4*) - os=-sysv4 - ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + -es1800*) + os=-ose + ;; + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. + # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -kopensolaris* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ + | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* | -hcos* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -morphos* | -superux* | -rtmk* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ + | -midnightbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1300,12 +1407,12 @@ case $os in -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + -sim | -xray | -os68k* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + os=`echo "$os" | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc @@ -1314,26 +1421,20 @@ case $os in os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) os=-wince ;; - -osfrose*) - os=-osfrose - ;; - -osf*) - os=-osf - ;; -utek*) os=-bsd ;; @@ -1358,7 +1459,7 @@ case $os in -nova*) os=-rtmk-nova ;; - -ns2 ) + -ns2) os=-nextstep2 ;; -nsk*) @@ -1371,7 +1472,7 @@ case $os in -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1380,7 +1481,7 @@ case $os in -oss*) os=-sysv3 ;; - -svr4) + -svr4*) os=-sysv4 ;; -svr3) @@ -1395,33 +1496,38 @@ case $os in -ose*) os=-ose ;; - -es1800*) - os=-ose - ;; - -xenix) - os=-xenix - ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; - -aros*) - os=-aros - ;; - -kaos*) - os=-kaos - ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; + -pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=-eabi + ;; + *) + os=-elf + ;; + esac + ;; + -nacl*) + ;; + -ios) + ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1438,10 +1544,10 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1453,8 +1559,23 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1474,14 +1595,11 @@ case $basic_machine in ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1499,16 +1617,16 @@ case $basic_machine in sparc-* | *-sun) os=-sunos4.1.1 ;; + pru-*) + os=-elf + ;; *-be) os=-beos ;; - *-haiku) - os=-haiku - ;; *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) @@ -1544,7 +1662,7 @@ case $basic_machine in m88k-omron*) os=-luna ;; - *-next ) + *-next) os=-nextstep ;; *-sequent) @@ -1559,9 +1677,6 @@ case $basic_machine in i370-*) os=-mvs ;; - *-next) - os=-nextstep3 - ;; *-gould) os=-sysv ;; @@ -1613,7 +1728,7 @@ case $basic_machine in -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) @@ -1671,15 +1786,15 @@ case $basic_machine in vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$basic_machine$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/libs/libpng-src/configure b/libs/libpng-src/configure index 89657aae0..1b2c46366 100755 --- a/libs/libpng-src/configure +++ b/libs/libpng-src/configure @@ -1,13 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for libpng 1.2.46. +# Generated by GNU Autoconf 2.69 for libpng 1.6.37. # # Report bugs to . # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -91,6 +89,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -135,6 +134,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -168,12 +192,21 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 -test \$(( 1 + 1 )) = 2 || exit 1" +test \$(( 1 + 1 )) = 2 || exit 1 + + test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ + || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else @@ -213,14 +246,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -319,10 +363,18 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -359,19 +411,19 @@ else fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -444,6 +496,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -478,16 +534,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -499,28 +555,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -528,161 +564,14 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - -# Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} -case X$lt_ECHO in -X*--fallback-echo) - # Remove one level of quotation (which was required for Make). - ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` - ;; -esac - -ECHO=${lt_ECHO-echo} -if test "X$1" = X--no-reexec; then - # Discard the --no-reexec flag, and continue. - shift -elif test "X$1" = X--fallback-echo; then - # Avoid inline document here, it may be left over - : -elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then - # Yippee, $ECHO works! - : -else - # Restart under the correct shell. - exec $SHELL "$0" --no-reexec ${1+"$@"} -fi - -if test "X$1" = X--fallback-echo; then - # used as fallback echo - shift - cat <<_LT_EOF -$* -_LT_EOF - exit 0 -fi - -# The HP-UX ksh and POSIX shell print the target directory to stdout -# if CDPATH is set. -(unset CDPATH) >/dev/null 2>&1 && unset CDPATH - -if test -z "$lt_ECHO"; then - if test "X${echo_test_string+set}" != Xset; then - # find a string as large as possible, as long as the shell can cope with it - for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do - # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... - if { echo_test_string=`eval $cmd`; } 2>/dev/null && - { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null - then - break - fi - done - fi - - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - : - else - # The Solaris, AIX, and Digital Unix default echo programs unquote - # backslashes. This makes it impossible to quote backslashes using - # echo "$something" | sed 's/\\/\\\\/g' - # - # So, first we look for a working echo in the user's PATH. - - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR - for dir in $PATH /usr/ucb; do - IFS="$lt_save_ifs" - if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && - test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && - echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$dir/echo" - break - fi - done - IFS="$lt_save_ifs" - - if test "X$ECHO" = Xecho; then - # We didn't find a better echo, so look for alternatives. - if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # This shell has a builtin print -r that does the trick. - ECHO='print -r' - elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && - test "X$CONFIG_SHELL" != X/bin/ksh; then - # If we have ksh, try running configure again with it. - ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} - export ORIGINAL_CONFIG_SHELL - CONFIG_SHELL=/bin/ksh - export CONFIG_SHELL - exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} - else - # Try using printf. - ECHO='printf %s\n' - if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && - echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - # Cool, printf works - : - elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL - export CONFIG_SHELL - SHELL="$CONFIG_SHELL" - export SHELL - ECHO="$CONFIG_SHELL $0 --fallback-echo" - elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && - test "X$echo_testing_string" = 'X\t' && - echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && - test "X$echo_testing_string" = "X$echo_test_string"; then - ECHO="$CONFIG_SHELL $0 --fallback-echo" - else - # maybe with a smaller string... - prev=: - - for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do - if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null - then - break - fi - prev="$cmd" - done - - if test "$prev" != 'sed 50q "$0"'; then - echo_test_string=`eval $prev` - export echo_test_string - exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} - else - # Oops. We lost completely, so just stick with echo. - ECHO=echo - fi - fi - fi - fi - fi -fi - -# Copy echo and quote the copy suitably for passing to libtool from -# the Makefile, instead of quoting the original, which is used later. -lt_ECHO=$ECHO -if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then - lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" -fi - - - test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -701,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libpng' PACKAGE_TARNAME='libpng' -PACKAGE_VERSION='1.2.46' -PACKAGE_STRING='libpng 1.2.46' +PACKAGE_VERSION='1.6.37' +PACKAGE_STRING='libpng 1.6.37' PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net' PACKAGE_URL='' @@ -746,7 +635,23 @@ ac_includes_default="\ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS -compatlib +PNG_POWERPC_VSX_FALSE +PNG_POWERPC_VSX_TRUE +PNG_INTEL_SSE_FALSE +PNG_INTEL_SSE_TRUE +PNG_MIPS_MSA_FALSE +PNG_MIPS_MSA_TRUE +PNG_ARM_NEON_FALSE +PNG_ARM_NEON_TRUE +DO_INSTALL_LIBPNG_CONFIG_FALSE +DO_INSTALL_LIBPNG_CONFIG_TRUE +DO_INSTALL_LIBPNG_PC_FALSE +DO_INSTALL_LIBPNG_PC_TRUE +DO_INSTALL_LINKS_FALSE +DO_INSTALL_LINKS_TRUE +DO_PNG_PREFIX_FALSE +DO_PNG_PREFIX_TRUE +PNG_PREFIX binconfigs pkgconfigdir PNGLIB_RELEASE @@ -756,26 +661,32 @@ PNGLIB_VERSION SYMBOL_PREFIX HAVE_LD_VERSION_SCRIPT_FALSE HAVE_LD_VERSION_SCRIPT_TRUE -LIBPNG_NO_MMX -LIBPNG_DEFINES +HAVE_SOLARIS_LD_FALSE +HAVE_SOLARIS_LD_TRUE +HAVE_CLOCK_GETTIME_FALSE +HAVE_CLOCK_GETTIME_TRUE LIBOBJS POW_LIB +PNG_COPTS +DFNCPP +LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL -lt_ECHO +MANIFEST_TOOL RANLIB +ac_ct_AR AR NM ac_ct_DUMPBIN DUMPBIN LIBTOOL -LN_S OBJDUMP DLLTOOL AS +LN_S CPP LD FGREP @@ -790,13 +701,18 @@ build_os build_vendor build_cpu build +am__fastdepCCAS_FALSE +am__fastdepCCAS_TRUE +CCASDEPMODE +CCASFLAGS +CCAS am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE +am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE -am__quote am__include DEPDIR OBJEXT @@ -809,6 +725,10 @@ CC MAINT MAINTAINER_MODE_FALSE MAINTAINER_MODE_TRUE +AM_BACKSLASH +AM_DEFAULT_VERBOSITY +AM_DEFAULT_V +AM_V am__untar am__tar AMTAR @@ -869,10 +789,12 @@ PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR -SHELL' +SHELL +am__quote' ac_subst_files='' ac_user_opts=' enable_option_checking +enable_silent_rules enable_maintainer_mode enable_dependency_tracking with_gnu_ld @@ -880,10 +802,22 @@ enable_shared enable_static with_pic enable_fast_install +with_aix_soname +with_sysroot enable_libtool_lock +enable_werror +with_zlib_prefix with_pkgconfigdir with_binconfigs -with_libpng_compat +with_libpng_prefix +enable_unversioned_links +enable_unversioned_libpng_pc +enable_unversioned_libpng_config +enable_hardware_optimizations +enable_arm_neon +enable_mips_msa +enable_intel_sse +enable_powerpc_vsx ' ac_precious_vars='build_alias host_alias @@ -893,7 +827,11 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -CPP' +CCAS +CCASFLAGS +CPP +LT_SYS_LIBRARY_PATH +PNG_COPTS' # Initialize some variables set by options. @@ -956,8 +894,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -1002,7 +941,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1028,7 +967,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1232,7 +1171,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1248,7 +1187,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1278,8 +1217,8 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1287,7 +1226,7 @@ Try \`$0 --help' for more information." # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1297,7 +1236,7 @@ Try \`$0 --help' for more information." $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1305,13 +1244,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1334,7 +1273,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1348,8 +1287,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1364,9 +1301,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1405,11 +1342,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1435,7 +1372,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libpng 1.2.46 to adapt to many kinds of systems. +\`configure' configures libpng 1.6.37 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1449,7 +1386,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1505,7 +1442,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libpng 1.2.46:";; + short | recursive ) echo "Configuration of libpng 1.6.37:";; esac cat <<\_ACEOF @@ -1513,28 +1450,95 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --enable-maintainer-mode enable make rules and dependencies not useful - (and sometimes confusing) to the casual installer - --disable-dependency-tracking speeds up one-time build - --enable-dependency-tracking do not reject slow dependency extractors + --enable-silent-rules less verbose build output (undo: "make V=1") + --disable-silent-rules verbose build output (undo: "make V=0") + --enable-maintainer-mode + enable make rules and dependencies not useful (and + sometimes confusing) to the casual installer + --enable-dependency-tracking + do not reject slow dependency extractors + --disable-dependency-tracking + speeds up one-time build --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-werror[=OPT] Pass -Werror or the given argument to the compiler + if it is supported + --enable-unversioned-links + Installed libpng header files are placed in a + versioned subdirectory and installed libpng library + (including DLL) files are versioned. If this option + is enabled unversioned links will be created + pointing to the corresponding installed files. If + you use libpng.pc or libpng-config for all builds + you do not need these links, but if you compile + programs directly they will typically #include + and link with -lpng; in that case you need + the links. The links can be installed manually using + 'make install-header-links' and 'make + install-library-links' and can be removed using the + corresponding uninstall- targets. If you do enable + this option every libpng 'make install' will + recreate the links to point to the just installed + version of libpng. The default is to create the + links; use --disable-unversioned-links to change + this + --enable-unversioned-libpng-pc + Install the configuration file 'libpng.pc' as a link + to the versioned version. This is done by default - + use --disable-unversioned-libpng-pc to change this. + --enable-unversioned-libpng-config + Install the configuration file 'libpng-config' as a + link to the versioned version. This is done by + default - use --disable-unversioned-libpng-config to + change this. + --enable-hardware-optimizations + Enable hardware optimizations: =no/off, yes/on: + --enable-arm-neon Enable ARM NEON optimizations: =no/off, check, api, + yes/on: no/off: disable the optimizations; check: + use internal checking code (deprecated and poorly + supported); api: disable by default, enable by a + call to png_set_option; yes/on: turn on + unconditionally. If not specified: determined by the + compiler. + --enable-mips-msa Enable MIPS MSA optimizations: =no/off, check, api, + yes/on: no/off: disable the optimizations; check: + use internal checking code (deprecated and poorly + supported); api: disable by default, enable by a + call to png_set_option; yes/on: turn on + unconditionally. If not specified: determined by the + compiler. + --enable-intel-sse Enable Intel SSE optimizations: =no/off, yes/on: + no/off: disable the optimizations; yes/on: enable + the optimizations. If not specified: determined by + the compiler. + --enable-powerpc-vsx Enable POWERPC VSX optimizations: =no/off, check, + api, yes/on: no/off: disable the optimizations; + check: use internal checking code api: disable by + default, enable by a call to png_set_option yes/on: + turn on unconditionally. If not specified: + determined by the compiler. Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-gnu-ld assume the C compiler uses GNU ld [default=no] - --with-pic try to use only PIC/non-PIC objects [default=use + --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] - --with-pkgconfigdir Use the specified pkgconfig dir (default is + --with-aix-soname=aix|svr4|both + shared library versioning (aka "SONAME") variant to + provide on AIX, [default=aix]. + --with-sysroot[=DIR] Search for dependent libraries within DIR (or the + compiler's sysroot if not specified). + --with-zlib-prefix prefix that may have been used in installed zlib + --with-pkgconfigdir Use the specified pkgconfig dir (default is libdir/pkgconfig) - --with-binconfigs Generate shell libpng-config scripts as well as + --with-binconfigs Generate shell libpng-config scripts as well as pkg-config data [default=yes] - --with-libpng-compat Generate the obsolete libpng.so library - [default=yes] + --with-libpng-prefix prefix libpng exported function (API) names with the + given value Some influential environment variables: CC C compiler command @@ -1544,7 +1548,13 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + CCAS assembler compiler command (defaults to CC) + CCASFLAGS assembler compiler flags (defaults to CFLAGS) CPP C preprocessor + LT_SYS_LIBRARY_PATH + User-defined run-time library search path. + PNG_COPTS additional flags for the C compiler, use this for options that + would cause configure itself to fail Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1612,10 +1622,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libpng configure 1.2.46 -generated by GNU Autoconf 2.65 +libpng configure 1.6.37 +generated by GNU Autoconf 2.69 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1659,7 +1669,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1685,7 +1695,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1696,7 +1706,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1728,7 +1738,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1742,7 +1752,7 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -1756,7 +1766,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1774,7 +1784,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile @@ -1815,7 +1825,7 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1828,7 +1838,7 @@ ac_fn_c_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1883,103 +1893,10 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func -# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists, giving a warning if it cannot be compiled using -# the include files in INCLUDES and setting the cache variable VAR -# accordingly. -ac_fn_c_check_header_mongrel () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 -$as_echo_n "checking $2 usability... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_header_compiler=yes -else - ac_header_compiler=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 -$as_echo_n "checking $2 presence... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <$2> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - ac_header_preproc=yes -else - ac_header_preproc=no -fi -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( - yes:no: ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} - ;; - no:yes:* ) - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( cat <<\_ASBOX -## ------------------------------------------------------ ## -## Report this to png-mng-implement@lists.sourceforge.net ## -## ------------------------------------------------------ ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - eval "$3=\$ac_header_compiler" -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_c_check_header_mongrel - # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache @@ -1989,7 +1906,7 @@ ac_fn_c_check_type () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -2030,15 +1947,15 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libpng $as_me 1.2.46, which was -generated by GNU Autoconf 2.65. Invocation command line was +It was created by libpng $as_me 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2148,11 +2065,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -2186,11 +2101,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -2203,11 +2116,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2221,11 +2132,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2280,7 +2189,12 @@ _ACEOF ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2295,7 +2209,11 @@ do { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done @@ -2371,7 +2289,7 @@ if $ac_cache_corrupted; then $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2384,20 +2302,34 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -am__api_version='1.11' + + +# libpng does not follow GNU file name conventions (hence 'foreign') +# color-tests requires automake 1.11 or later +# silent-rules requires automake 1.11 or later +# dist-xz requires automake 1.11 or later +# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1 +# 1.13 is required for parallel tests +am__api_version='1.16' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2426,7 +2358,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2446,7 +2378,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2504,56 +2436,71 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } -# Just in case -sleep 1 -echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; + as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac -# Do `set' in a subshell so we don't clobber the current shell's +# Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( - set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` - if test "$*" = "X"; then - # -L didn't work. - set X `ls -t "$srcdir/configure" conftest.file` - fi - rm -f conftest.file - if test "$*" != "X $srcdir/configure conftest.file" \ - && test "$*" != "X conftest.file $srcdir/configure"; then - - # If neither matched, then we have a broken ls. This can happen - # if, for instance, CONFIG_SHELL is bash and it inherits a - # broken ls alias from the environment. This has actually - # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken -alias in your environment" "$LINENO" 5 - fi + am_has_slept=no + for am_try in 1 2; do + echo "timestamp, slept: $am_has_slept" > conftest.file + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken + alias in your environment" "$LINENO" 5 + fi + if test "$2" = conftest.file || test $am_try -eq 2; then + break + fi + # Just in case. + sleep 1 + am_has_slept=yes + done test "$2" = conftest.file ) then # Ok. : else - as_fn_error "newly created file is older than distributed files! + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +# If we didn't sleep, we still need to ensure time stamps of config.status and +# generated files are strictly newer. +am_sleep_pid= +if grep 'slept: no' conftest.file >/dev/null 2>&1; then + ( sleep 1 ) & + am_sleep_pid=$! +fi + +rm -f conftest.file + test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. @@ -2564,8 +2511,8 @@ test "$program_suffix" != NONE && ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` -# expand $ac_aux_dir to an absolute path -am_aux_dir=`cd $ac_aux_dir && pwd` +# Expand $ac_aux_dir to an absolute path. +am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in @@ -2576,15 +2523,15 @@ if test x"${MISSING+set}" != xset; then esac fi # Use eval to expand $SHELL -if eval "$MISSING --run true"; then - am_missing_run="$MISSING --run " +if eval "$MISSING --is-lightweight"; then + am_missing_run="$MISSING " else am_missing_run= - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 -$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi -if test x"${install_sh}" != xset; then +if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; @@ -2593,17 +2540,17 @@ if test x"${install_sh}" != xset; then esac fi -# Installed binaries are usually stripped using `strip' when the user -# run `make install-strip'. However `strip' might not be the right +# Installed binaries are usually stripped using 'strip' when the user +# run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake -# will honor the `STRIP' environment variable to overrule this program. +# will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -2615,7 +2562,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2643,7 +2590,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -2655,7 +2602,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2696,7 +2643,7 @@ INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then - if test "${ac_cv_path_mkdir+set}" = set; then : + if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -2706,7 +2653,7 @@ do test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -2735,19 +2682,13 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } -mkdir_p="$MKDIR_P" -case $mkdir_p in - [\\/$]* | ?:[\\/]*) ;; - */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; -esac - for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -2759,7 +2700,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2787,7 +2728,7 @@ done $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2795,7 +2736,7 @@ SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -2823,13 +2764,52 @@ else fi rmdir .tst 2>/dev/null +# Check whether --enable-silent-rules was given. +if test "${enable_silent_rules+set}" = set; then : + enableval=$enable_silent_rules; +fi + +case $enable_silent_rules in # ((( + yes) AM_DEFAULT_VERBOSITY=0;; + no) AM_DEFAULT_VERBOSITY=1;; + *) AM_DEFAULT_VERBOSITY=1;; +esac +am_make=${MAKE-make} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 +$as_echo_n "checking whether $am_make supports nested variables... " >&6; } +if ${am_cv_make_support_nested_variables+:} false; then : + $as_echo_n "(cached) " >&6 +else + if $as_echo 'TRUE=$(BAR$(V)) +BAR0=false +BAR1=true +V=1 +am__doit: + @$(TRUE) +.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then + am_cv_make_support_nested_variables=yes +else + am_cv_make_support_nested_variables=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 +$as_echo "$am_cv_make_support_nested_variables" >&6; } +if test $am_cv_make_support_nested_variables = yes; then + AM_V='$(V)' + AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' +else + AM_V=$AM_DEFAULT_VERBOSITY + AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY +fi +AM_BACKSLASH='\' + if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi @@ -2845,7 +2825,7 @@ fi # Define the identity of the package. PACKAGE='libpng' - VERSION='1.2.46' + VERSION='1.6.37' cat >>confdefs.h <<_ACEOF @@ -2873,19 +2853,75 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} -# We need awk for the "check" target. The system "awk" is bad on -# some platforms. -# Always define AMTAR for backward compatibility. +# For better backward compatibility. To be removed once Automake 1.9.x +# dies out for good. For more background, see: +# +# +mkdir_p='$(MKDIR_P)' -AMTAR=${AMTAR-"${am_missing_run}tar"} +# We need awk for the "check" target (and possibly the TAP driver). The +# system "awk" is bad on some platforms. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + +# We'll loop over all known methods to create a tar archive until one works. +_am_tools='gnutar pax cpio none' + +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: . + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi + +# The following line causes --disable-maintainer-mode to be the default to +# configure. This is necessary because libpng distributions cannot rely on the +# time stamps of the autotools generated files being correct + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } # Check whether --enable-maintainer-mode was given. @@ -2909,10 +2945,11 @@ fi -PNGLIB_VERSION=1.2.46 + +PNGLIB_VERSION=1.6.37 PNGLIB_MAJOR=1 -PNGLIB_MINOR=2 -PNGLIB_RELEASE=46 +PNGLIB_MINOR=6 +PNGLIB_RELEASE=37 @@ -2920,6 +2957,12 @@ ac_config_headers="$ac_config_headers config.h" # Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -2930,7 +2973,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2942,7 +2985,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2970,7 +3013,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2982,7 +3025,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3023,7 +3066,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3035,7 +3078,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3063,7 +3106,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3076,7 +3119,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3122,7 +3165,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3134,7 +3177,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3166,7 +3209,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3178,7 +3221,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3220,8 +3263,8 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3335,9 +3378,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3379,8 +3421,8 @@ done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3437,9 +3479,9 @@ $as_echo "$ac_try_echo"; } >&5 else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5; } fi fi fi @@ -3450,7 +3492,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3490,8 +3532,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3501,7 +3543,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3538,7 +3580,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -3616,7 +3658,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -3625,8 +3667,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3710,49 +3751,108 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" - -am_make=${MAKE-make} -cat > confinc << 'END' +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5 +$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; } +cat > confinc.mk << 'END' am__doit: - @echo this is the am__doit target + @echo this is the am__doit target >confinc.out .PHONY: am__doit END -# If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 -$as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# Ignore all kinds of additional output from `make'. -case `$am_make -s -f confmf 2> /dev/null` in #( -*the\ am__doit\ target*) - am__include=include - am__quote= - _am_result=GNU - ;; -esac -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - case `$am_make -s -f confmf 2> /dev/null` in #( - *the\ am__doit\ target*) - am__include=.include - am__quote="\"" - _am_result=BSD +# BSD make does it like this. +echo '.include "confinc.mk" # ignored' > confmf.BSD +# Other make implementations (GNU, Solaris 10, AIX) do it like this. +echo 'include confinc.mk # ignored' > confmf.GNU +_am_result=no +for s in GNU BSD; do + { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5 + (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + case $?:`cat confinc.out 2>/dev/null` in #( + '0:this is the am__doit target') : + case $s in #( + BSD) : + am__include='.include' am__quote='"' ;; #( + *) : + am__include='include' am__quote='' ;; +esac ;; #( + *) : ;; - esac -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 -$as_echo "$_am_result" >&6; } -rm -f confinc confmf +esac + if test "$am__include" != "#"; then + _am_result="yes ($s style)" + break + fi +done +rm -f confinc.* confmf.* +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5 +$as_echo "${_am_result}" >&6; } # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : @@ -3762,6 +3862,7 @@ fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' + am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= @@ -3777,15 +3878,16 @@ depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then : +if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up - # making a dummy file named `D' -- because `-MD' means `put the output - # in D'. + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. @@ -3819,16 +3921,16 @@ else : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c - # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with - # Solaris 8's {/usr,}/bin/sh. - touch sub/conftst$i.h + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf - # We check with `-c' and `-o' for the sake of the "dashmstdout" + # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly - # handle `-M -o', and we need to detect this. Also, some Intel - # versions had trouble with output in subdirs + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in @@ -3837,16 +3939,16 @@ else test "$am__universal" = false || continue ;; nosideeffect) - # after this tag, mechanisms are not by side-effect, so they'll - # only be used when explicitly requested + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; - msvisualcpp | msvcmsys) - # This compiler won't grok `-c -o', but also, the minuso test has + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} @@ -3900,29 +4002,162 @@ else fi +# By default we simply use the C compiler to build assembly code. + +test "${CCAS+set}" = set || CCAS=$CC +test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS + + + +depcc="$CCAS" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CCAS_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named 'D' -- because '-MD' means "put the output + # in D". + rm -rf conftest.dir + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CCAS_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with + # Solaris 10 /bin/sh. + echo '/* dummy */' > sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with '-c' and '-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle '-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs. + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # After this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested. + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvc7 | msvc7msys | msvisualcpp | msvcmsys) + # This compiler won't grok '-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CCAS_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CCAS_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CCAS_dependencies_compiler_type" >&6; } +CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then + am__fastdepCCAS_TRUE= + am__fastdepCCAS_FALSE='#' +else + am__fastdepCCAS_TRUE='#' + am__fastdepCCAS_FALSE= +fi + + # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then : +if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -3940,14 +4175,14 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then : +if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi @@ -3955,7 +4190,7 @@ fi $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -3973,7 +4208,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } -if test "${ac_cv_path_SED+set}" = set; then : +if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ @@ -3993,7 +4228,7 @@ do for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue + as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in @@ -4028,7 +4263,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then - as_fn_error "no acceptable sed could be found in \$PATH" "$LINENO" 5 + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED @@ -4055,7 +4290,7 @@ Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -4069,7 +4304,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4104,7 +4339,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -4118,7 +4353,7 @@ $as_echo "$ac_cv_path_GREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -4135,7 +4370,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4170,7 +4405,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -4185,7 +4420,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } -if test "${ac_cv_path_FGREP+set}" = set; then : +if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 @@ -4202,7 +4437,7 @@ do for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue + as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in @@ -4237,7 +4472,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then - as_fn_error "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP @@ -4268,23 +4503,75 @@ test -z "$GREP" && GREP=grep +ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 +$as_echo_n "checking how to print strings... " >&6; } +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "" +} + +case $ECHO in + printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 +$as_echo "printf" >&6; } ;; + print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 +$as_echo "print -r" >&6; } ;; + *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 +$as_echo "cat" >&6; } ;; +esac + + + + + + + + + + + + + + # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : - withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes + withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld -if test "$GCC" = yes; then +if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) - # gcc leaves a trailing carriage return which upsets mingw + # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; @@ -4298,7 +4585,7 @@ $as_echo_n "checking for ld used by $CC... " >&6; } while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done - test -z "$LD" && LD="$ac_prog" + test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. @@ -4309,43 +4596,43 @@ $as_echo_n "checking for ld used by $CC... " >&6; } with_gnu_ld=unknown ;; esac -elif test "$with_gnu_ld" = yes; then +elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi -if test "${lt_cv_path_LD+set}" = set; then : +if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then - lt_cv_path_LD="$ac_dir/$ac_prog" + lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } @@ -4353,10 +4640,10 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5 +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } -if test "${lt_cv_prog_gnu_ld+set}" = set; then : +if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. @@ -4393,7 +4680,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -4423,7 +4710,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4439,11 +4726,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -4482,7 +4769,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -4498,18 +4785,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -4518,16 +4805,17 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}sed", so it can be a program name with args. -set dummy ${ac_tool_prefix}sed; ac_word=$2 +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_SED+set}" = set; then : +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else - if test -n "$SED"; then - ac_cv_prog_SED="$SED" # Let the user override the test. + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -4535,8 +4823,8 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_SED="${ac_tool_prefix}sed" + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -4546,372 +4834,18 @@ IFS=$as_save_IFS fi fi -SED=$ac_cv_prog_SED -if test -n "$SED"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5 -$as_echo "$SED" >&6; } +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi -fi -if test -z "$ac_cv_prog_SED"; then - ac_ct_SED=$SED - # Extract the first word of "sed", so it can be a program name with args. -set dummy sed; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_SED+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_SED"; then - ac_cv_prog_ac_ct_SED="$ac_ct_SED" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_SED="sed" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi + test -n "$AWK" && break done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_SED=$ac_cv_prog_ac_ct_SED -if test -n "$ac_ct_SED"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_SED" >&5 -$as_echo "$ac_ct_SED" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_SED" = x; then - SED=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - SED=$ac_ct_SED - fi -else - SED="$ac_cv_prog_SED" -fi - -enable_win32_dll=yes - -case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. -set dummy ${ac_tool_prefix}as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AS+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$AS"; then - ac_cv_prog_AS="$AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AS="${ac_tool_prefix}as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -AS=$ac_cv_prog_AS -if test -n "$AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 -$as_echo "$AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_AS"; then - ac_ct_AS=$AS - # Extract the first word of "as", so it can be a program name with args. -set dummy as; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AS+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_AS"; then - ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AS="as" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_AS=$ac_cv_prog_ac_ct_AS -if test -n "$ac_ct_AS"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 -$as_echo "$ac_ct_AS" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_AS" = x; then - AS="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - AS=$ac_ct_AS - fi -else - AS="$ac_cv_prog_AS" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. -set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DLLTOOL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$DLLTOOL"; then - ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -DLLTOOL=$ac_cv_prog_DLLTOOL -if test -n "$DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 -$as_echo "$DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_DLLTOOL"; then - ac_ct_DLLTOOL=$DLLTOOL - # Extract the first word of "dlltool", so it can be a program name with args. -set dummy dlltool; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_DLLTOOL"; then - ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_DLLTOOL="dlltool" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL -if test -n "$ac_ct_DLLTOOL"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 -$as_echo "$ac_ct_DLLTOOL" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_DLLTOOL" = x; then - DLLTOOL="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - DLLTOOL=$ac_ct_DLLTOOL - fi -else - DLLTOOL="$ac_cv_prog_DLLTOOL" -fi - - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. -set dummy ${ac_tool_prefix}objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$OBJDUMP"; then - ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -OBJDUMP=$ac_cv_prog_OBJDUMP -if test -n "$OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 -$as_echo "$OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_OBJDUMP"; then - ac_ct_OBJDUMP=$OBJDUMP - # Extract the first word of "objdump", so it can be a program name with args. -set dummy objdump; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_OBJDUMP"; then - ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_OBJDUMP="objdump" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP -if test -n "$ac_ct_OBJDUMP"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 -$as_echo "$ac_ct_OBJDUMP" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_OBJDUMP" = x; then - OBJDUMP="false" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - OBJDUMP=$ac_ct_OBJDUMP - fi -else - OBJDUMP="$ac_cv_prog_OBJDUMP" -fi - - ;; -esac - -test -z "$AS" && AS=as - - - - - -test -z "$DLLTOOL" && DLLTOOL=dlltool - - - - - -test -z "$OBJDUMP" && OBJDUMP=objdump - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 @@ -4929,7 +4863,7 @@ fi $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -4937,7 +4871,7 @@ SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -4956,6 +4890,7 @@ $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi + case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 @@ -4964,8 +4899,8 @@ esac -macro_version='2.2.6b' -macro_revision='1.3017' +macro_version='2.4.6' +macro_revision='2.4.6' @@ -4979,42 +4914,64 @@ macro_revision='1.3017' -ltmain="$ac_aux_dir/ltmain.sh" +ltmain=$ac_aux_dir/ltmain.sh + +# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } -if test "${lt_cv_path_NM+set}" = set; then : +if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. - lt_cv_path_NM="$NM" + lt_cv_path_NM=$NM else - lt_nm_to_check="${ac_tool_prefix}nm" + lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - tmp_nm="$ac_dir/$lt_tmp_nm" - if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. - # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file - case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in - */dev/null* | *'Invalid file or object type'*) + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" - break + break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" - break + break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but @@ -5025,25 +4982,28 @@ else esac fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } -if test "$lt_cv_path_NM" != "no"; then - NM="$lt_cv_path_NM" +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. - if test -n "$ac_tool_prefix"; then - for ac_prog in "dumpbin -symbols" "link -dump -symbols" + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + if test -n "$ac_tool_prefix"; then + for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DUMPBIN+set}" = set; then : +if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then @@ -5055,7 +5015,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5081,13 +5041,13 @@ fi fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN - for ac_prog in "dumpbin -symbols" "link -dump -symbols" + for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then : +if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then @@ -5099,7 +5059,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5136,9 +5096,18 @@ esac fi fi + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi - if test "$DUMPBIN" != ":"; then - NM="$DUMPBIN" + if test : != "$DUMPBIN"; then + NM=$DUMPBIN fi fi test -z "$NM" && NM=nm @@ -5150,18 +5119,18 @@ test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } -if test "${lt_cv_nm_interface+set}" = set; then : +if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:5158: $ac_compile\"" >&5) + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:5161: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:5164: output\"" >&5) + (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5174,11 +5143,11 @@ $as_echo "$lt_cv_nm_interface" >&6; } # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } -if test "${lt_cv_sys_max_cmd_len+set}" = set; then : +if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 - teststring="ABCD" + teststring=ABCD case $build_os in msdosdjgpp*) @@ -5207,13 +5176,18 @@ else lt_cv_sys_max_cmd_len=8192; ;; + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; - netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` @@ -5232,6 +5206,11 @@ else lt_cv_sys_max_cmd_len=196608 ;; + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not @@ -5258,22 +5237,23 @@ else ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` - if test -n "$lt_cv_sys_max_cmd_len"; then + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. - for i in 1 2 3 4 5 6 7 8 ; do + for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. - while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ - = "XX$teststring$teststring"; } >/dev/null 2>&1 && - test $i != 17 # 1/2 MB should be enough + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring @@ -5291,7 +5271,7 @@ else fi -if test -n $lt_cv_sys_max_cmd_len ; then +if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else @@ -5309,30 +5289,6 @@ max_cmd_len=$lt_cv_sys_max_cmd_len : ${MV="mv -f"} : ${RM="rm -f"} -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 -$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } -# Try some XSI features -xsi_shell=no -( _lt_dummy="a/b/c" - test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ - = c,a/b,, \ - && eval 'test $(( 1 + 1 )) -eq 2 \ - && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ - && xsi_shell=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 -$as_echo "$xsi_shell" >&6; } - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 -$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } -lt_shell_append=no -( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ - >/dev/null 2>&1 \ - && lt_shell_append=yes -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 -$as_echo "$lt_shell_append" >&6; } - - if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else @@ -5364,9 +5320,83 @@ esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 +$as_echo_n "checking how to convert $build file names to $host format... " >&6; } +if ${lt_cv_to_host_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac + +fi + +to_host_file_cmd=$lt_cv_to_host_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 +$as_echo "$lt_cv_to_host_file_cmd" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 +$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } +if ${lt_cv_to_tool_file_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + #assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac + +fi + +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 +$as_echo "$lt_cv_to_tool_file_cmd" >&6; } + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } -if test "${lt_cv_ld_reload_flag+set}" = set; then : +if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' @@ -5380,9 +5410,14 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + if test yes != "$GCC"; then + reload_cmds=false + fi + ;; darwin*) - if test "$GCC" = yes; then - reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + if test yes = "$GCC"; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi @@ -5402,7 +5437,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then @@ -5414,7 +5449,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5442,7 +5477,7 @@ if test -z "$ac_cv_prog_OBJDUMP"; then set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then : +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then @@ -5454,7 +5489,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5498,7 +5533,7 @@ test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } -if test "${lt_cv_deplibs_check_method+set}" = set; then : +if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' @@ -5507,13 +5542,13 @@ lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. -# `unknown' -- same as none, but documents that we really don't know. +# 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path -# which responds to the $file_magic_cmd with a given extended regex. -# If you have `file' or equivalent on your system and you're not sure -# whether `pass_all' will *always* work, you probably want this one. +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) @@ -5544,12 +5579,13 @@ mingw* | pw32*) lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else - lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; -cegcc) +cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' @@ -5575,7 +5611,7 @@ freebsd* | dragonfly*) fi ;; -gnu*) +haiku*) lt_cv_deplibs_check_method=pass_all ;; @@ -5587,11 +5623,11 @@ hpux10.20* | hpux11*) lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) - lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac @@ -5612,8 +5648,8 @@ irix5* | irix6* | nonstopux*) lt_cv_deplibs_check_method=pass_all ;; -# This must be Linux ELF. -linux* | k*bsd*-gnu) +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; @@ -5635,8 +5671,8 @@ newos6*) lt_cv_deplibs_check_method=pass_all ;; -openbsd*) - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' @@ -5689,11 +5725,29 @@ sysv4 | sysv4.3*) tpf*) lt_cv_deplibs_check_method=pass_all ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` + fi + ;; + esac +fi + file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown @@ -5707,14 +5761,165 @@ test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. -set dummy ${ac_tool_prefix}ar; ac_word=$2 + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AR+set}" = set; then : +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 +$as_echo_n "checking how to associate runtime and link libraries... " >&6; } +if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 +$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + + + + + + + + +if test -n "$ac_tool_prefix"; then + for ac_prog in ar + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then @@ -5726,8 +5931,8 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_AR="${ac_tool_prefix}ar" + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5747,14 +5952,18 @@ $as_echo "no" >&6; } fi + test -n "$AR" && break + done fi -if test -z "$ac_cv_prog_AR"; then +if test -z "$AR"; then ac_ct_AR=$AR - # Extract the first word of "ar", so it can be a program name with args. -set dummy ar; ac_word=$2 + for ac_prog in ar +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_AR+set}" = set; then : +if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then @@ -5766,8 +5975,8 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_AR="ar" + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -5786,6 +5995,10 @@ else $as_echo "no" >&6; } fi + + test -n "$ac_ct_AR" && break +done + if test "x$ac_ct_AR" = x; then AR="false" else @@ -5797,12 +6010,10 @@ ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi -else - AR="$ac_cv_prog_AR" fi -test -z "$AR" && AR=ar -test -z "$AR_FLAGS" && AR_FLAGS=cru +: ${AR=ar} +: ${AR_FLAGS=cru} @@ -5814,12 +6025,70 @@ test -z "$AR_FLAGS" && AR_FLAGS=cru +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 +$as_echo_n "checking for archiver @FILE support... " >&6; } +if ${lt_cv_ar_at_file+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ar_at_file=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 + (eval $lt_ar_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 +$as_echo "$lt_cv_ar_at_file" >&6; } + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi + + + + + + + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then : +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -5831,7 +6100,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5859,7 +6128,7 @@ if test -z "$ac_cv_prog_STRIP"; then set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then : +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -5871,7 +6140,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5918,7 +6187,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_RANLIB+set}" = set; then : +if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then @@ -5930,7 +6199,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5958,7 +6227,7 @@ if test -z "$ac_cv_prog_RANLIB"; then set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then @@ -5970,7 +6239,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6019,16 +6288,28 @@ old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in - openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac - old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac + + + + + + @@ -6075,7 +6356,7 @@ compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } -if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then : +if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else @@ -6097,7 +6378,7 @@ cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; @@ -6130,14 +6411,44 @@ case `$NM -V 2>&1` in symcode='[ABCDGIRSTW]' ;; esac +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. -lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address -lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= @@ -6155,24 +6466,29 @@ for ac_symprfx in "" "_"; do # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then - # Fake it for dumpbin and say T for any non-static function - # and D for any global variable. + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ -" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ -" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ -" s[1]~/^[@?]/{print s[1], s[1]; next};"\ -" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no @@ -6198,8 +6514,8 @@ _LT_EOF test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 - (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then @@ -6214,6 +6530,18 @@ _LT_EOF if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + #ifdef __cplusplus extern "C" { #endif @@ -6225,7 +6553,7 @@ _LT_EOF cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -const struct { +LT_DLSYM_CONST struct { const char *name; void *address; } @@ -6233,7 +6561,7 @@ lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF - $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; @@ -6251,19 +6579,19 @@ static const void *lt_preloaded_setup() { _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext - lt_save_LIBS="$LIBS" - lt_save_CFLAGS="$CFLAGS" - LIBS="conftstm.$ac_objext" + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext}; then + test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi - LIBS="$lt_save_LIBS" - CFLAGS="$lt_save_CFLAGS" + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi @@ -6280,7 +6608,7 @@ _LT_EOF rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. - if test "$pipe_works" = yes; then + if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= @@ -6300,6 +6628,12 @@ else $as_echo "ok" >&6; } fi +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then + nm_file_list_spec='@' +fi @@ -6321,19 +6655,152 @@ fi + + + + + + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 +$as_echo_n "checking for sysroot... " >&6; } + +# Check whether --with-sysroot was given. +if test "${with_sysroot+set}" = set; then : + withval=$with_sysroot; +else + with_sysroot=no +fi + + +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 +$as_echo "$with_sysroot" >&6; } + as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 + ;; +esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 +$as_echo "${lt_sysroot:-no}" >&6; } + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 +$as_echo_n "checking for a working dd... " >&6; } +if ${ac_cv_path_lt_DD+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +if test -z "$lt_DD"; then + ac_path_lt_DD_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in dd; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_lt_DD" || continue +if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi + $ac_path_lt_DD_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_lt_DD"; then + : + fi +else + ac_cv_path_lt_DD=$lt_DD +fi + +rm -f conftest.i conftest2.i conftest.out +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 +$as_echo "$ac_cv_path_lt_DD" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 +$as_echo_n "checking how to truncate binary pipes... " >&6; } +if ${lt_cv_truncate_bin+:} false; then : + $as_echo_n "(cached) " >&6 +else + printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 +$as_echo "$lt_cv_truncate_bin" >&6; } + + + + + + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi -test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes +test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 @@ -6342,24 +6809,25 @@ ia64-*-hpux*) test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) - HPUX_IA64_MODE="32" + HPUX_IA64_MODE=32 ;; *ELF-64*) - HPUX_IA64_MODE="64" + HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) - # Find out which ABI we are using. - echo '#line 6356 "configure"' > conftest.$ac_ext + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - if test "$lt_cv_prog_gnu_ld" = yes; then + if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" @@ -6388,9 +6856,50 @@ ia64-*-hpux*) rm -rf conftest* ;; -x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '#line '$LINENO' "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) - # Find out which ABI we are using. + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 @@ -6404,9 +6913,19 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) - LD="${LD-ld} -m elf_i386" + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac ;; - ppc64-*linux*|powerpc64-*linux*) + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) @@ -6425,7 +6944,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - ppc*-*linux*|powerpc*-*linux*) + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -6443,11 +6965,11 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. - SAVE_CFLAGS="$CFLAGS" + SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } -if test "${lt_cv_cc_needs_belf+set}" = set; then : +if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c @@ -6483,13 +7005,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } - if test x"$lt_cv_cc_needs_belf" != x"yes"; then + if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf - CFLAGS="$SAVE_CFLAGS" + CFLAGS=$SAVE_CFLAGS fi ;; -sparc*-*solaris*) - # Find out which ABI we are using. +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 @@ -6499,7 +7022,20 @@ sparc*-*solaris*) case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in - yes*) LD="${LD-ld} -m elf64_sparc" ;; + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" @@ -6513,7 +7049,124 @@ sparc*-*solaris*) ;; esac -need_locks="$enable_libtool_lock" +need_locks=$enable_libtool_lock + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. +set dummy ${ac_tool_prefix}mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$MANIFEST_TOOL"; then + ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL +if test -n "$MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 +$as_echo "$MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_MANIFEST_TOOL"; then + ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL + # Extract the first word of "mt", so it can be a program name with args. +set dummy mt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_MANIFEST_TOOL"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL +if test -n "$ac_ct_MANIFEST_TOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 +$as_echo "$ac_ct_MANIFEST_TOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_MANIFEST_TOOL" = x; then + MANIFEST_TOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL + fi +else + MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" +fi + +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 +$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } +if ${lt_cv_path_mainfest_tool+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&5 + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 +$as_echo "$lt_cv_path_mainfest_tool" >&6; } +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi + + + + case $host_os in @@ -6523,7 +7176,7 @@ need_locks="$enable_libtool_lock" set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_DSYMUTIL+set}" = set; then : +if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then @@ -6535,7 +7188,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6563,7 +7216,7 @@ if test -z "$ac_cv_prog_DSYMUTIL"; then set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then : +if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then @@ -6575,7 +7228,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6615,7 +7268,7 @@ fi set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_NMEDIT+set}" = set; then : +if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then @@ -6627,7 +7280,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6655,7 +7308,7 @@ if test -z "$ac_cv_prog_NMEDIT"; then set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then : +if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then @@ -6667,7 +7320,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6707,7 +7360,7 @@ fi set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_LIPO+set}" = set; then : +if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then @@ -6719,7 +7372,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6747,7 +7400,7 @@ if test -z "$ac_cv_prog_LIPO"; then set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then : +if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then @@ -6759,7 +7412,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6799,7 +7452,7 @@ fi set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OTOOL+set}" = set; then : +if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then @@ -6811,7 +7464,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6839,7 +7492,7 @@ if test -z "$ac_cv_prog_OTOOL"; then set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then : +if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then @@ -6851,7 +7504,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6891,7 +7544,7 @@ fi set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_OTOOL64+set}" = set; then : +if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then @@ -6903,7 +7556,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6931,7 +7584,7 @@ if test -z "$ac_cv_prog_OTOOL64"; then set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then : +if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then @@ -6943,7 +7596,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7006,11 +7659,11 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } -if test "${lt_cv_apple_cc_single_mod+set}" = set; then : +if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no - if test -z "${LT_MULTI_MODULE}"; then + if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the @@ -7022,7 +7675,13 @@ else $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? - if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&5 + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 @@ -7033,9 +7692,10 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } -if test "${lt_cv_ld_exported_symbols_list+set}" = set; then : +if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no @@ -7060,39 +7720,74 @@ else fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 +$as_echo_n "checking for -force_load linker flag... " >&6; } +if ${lt_cv_ld_force_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 + echo "$AR cru libconftest.a conftest.o" >&5 + $AR cru libconftest.a conftest.o 2>&5 + echo "$RANLIB libconftest.a" >&5 + $RANLIB libconftest.a 2>&5 + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&5 + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&5 + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 +$as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) - _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) - _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[012][,.]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac - if test "$lt_cv_apple_cc_single_mod" = "yes"; then + if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi - if test "$lt_cv_ld_exported_symbols_list" = "yes"; then - _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else - _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi - if test "$DSYMUTIL" != ":"; then + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= @@ -7100,10 +7795,45 @@ $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } ;; esac +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7220,8 +7950,7 @@ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7235,7 +7964,7 @@ for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " -if test "x$ac_cv_header_dlfcn_h" = x""yes; then : +if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF @@ -7246,7 +7975,309 @@ done + + # Set options +enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AS="${ac_tool_prefix}as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AS=$ac_cv_prog_AS +if test -n "$AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 +$as_echo "$AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AS"; then + ac_ct_AS=$AS + # Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AS+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AS"; then + ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AS="as" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AS=$ac_cv_prog_ac_ct_AS +if test -n "$ac_ct_AS"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 +$as_echo "$ac_ct_AS" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AS" = x; then + AS="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AS=$ac_ct_AS + fi +else + AS="$ac_cv_prog_AS" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 +$as_echo "$DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 +$as_echo "$ac_ct_DLLTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + + ;; +esac + +test -z "$AS" && AS=as + + + + + +test -z "$DLLTOOL" && DLLTOOL=dlltool + + + + + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + @@ -7263,14 +8294,14 @@ if test "${enable_shared+set}" = set; then : *) enable_shared=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -7294,14 +8325,14 @@ if test "${enable_static+set}" = set; then : *) enable_static=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -7319,14 +8350,27 @@ fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : - withval=$with_pic; pic_mode="$withval" + withval=$with_pic; lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac else pic_mode=default fi -test -z "$pic_mode" && pic_mode=default - @@ -7342,14 +8386,14 @@ if test "${enable_fast_install+set}" = set; then : *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. - lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done - IFS="$lt_save_ifs" + IFS=$lt_save_ifs ;; esac else @@ -7363,11 +8407,63 @@ fi + shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[5-9]*,yes) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 +$as_echo_n "checking which variant of shared library versioning to provide... " >&6; } + +# Check whether --with-aix-soname was given. +if test "${with_aix_soname+set}" = set; then : + withval=$with_aix_soname; case $withval in + aix|svr4|both) + ;; + *) + as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname +else + if ${lt_cv_with_aix_soname+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_with_aix_soname=aix +fi + + with_aix_soname=$lt_cv_with_aix_soname +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 +$as_echo "$with_aix_soname" >&6; } + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + + + + + + + # This can be used to rebuild libtool when needed -LIBTOOL_DEPS="$ltmain" +LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' @@ -7390,6 +8486,11 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + @@ -7411,13 +8512,13 @@ test -z "$LN_S" && LN_S="ln -s" -if test -n "${ZSH_VERSION+set}" ; then +if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } -if test "${lt_cv_objdir+set}" = set; then : +if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null @@ -7445,60 +8546,30 @@ _ACEOF - - - - - - - - - - - - - case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. - if test "X${COLLECT_NAMES+set}" != Xset; then + if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac -# Sed substitution that helps us do robust quoting. It backslashifies -# metacharacters that are still active within double-quoted strings. -sed_quote_subst='s/\(["`$\\]\)/\\\1/g' - -# Same as above, but do not quote variable references. -double_quote_subst='s/\(["`\\]\)/\\\1/g' - -# Sed substitution to delay expansion of an escaped shell variable in a -# double_quote_subst'ed string. -delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' - -# Sed substitution to delay expansion of an escaped single quote. -delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' - -# Sed substitution to avoid accidental globbing in evaled expressions -no_glob_subst='s/\*/\\\*/g' - # Global variables: ofile=libtool can_build_shared=yes -# All known linkers require a `.a' archive for static linking (except MSVC, +# All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a -with_gnu_ld="$lt_cv_prog_gnu_ld" +with_gnu_ld=$lt_cv_prog_gnu_ld -old_CC="$CC" -old_CFLAGS="$CFLAGS" +old_CC=$CC +old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc @@ -7507,15 +8578,8 @@ test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o -for cc_temp in $compiler""; do - case $cc_temp in - compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; - distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; - \-*) ;; - *) break;; - esac -done -cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +func_cc_basename $compiler +cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it @@ -7525,27 +8589,27 @@ file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : +if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/${ac_tool_prefix}file; then - lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -f "$ac_dir/${ac_tool_prefix}file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : @@ -7568,13 +8632,13 @@ _LT_EOF break fi done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } @@ -7591,27 +8655,27 @@ if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } -if test "${lt_cv_path_MAGIC_CMD+set}" = set; then : +if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) - lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) - lt_save_MAGIC_CMD="$MAGIC_CMD" - lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do - IFS="$lt_save_ifs" + IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. - if test -f $ac_dir/file; then - lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -f "$ac_dir/file"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` - MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : @@ -7634,13 +8698,13 @@ _LT_EOF break fi done - IFS="$lt_save_ifs" - MAGIC_CMD="$lt_save_MAGIC_CMD" + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi -MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } @@ -7661,7 +8725,7 @@ esac # Use C for the default configuration in the libtool script -lt_save_CC="$CC" +lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -7715,22 +8779,31 @@ _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= -if test "$GCC" = yes; then - lt_prog_compiler_no_builtin_flag=' -fno-builtin' +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; + *) + lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; + esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } -if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then : +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="-fno-rtti -fno-exceptions" + lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins @@ -7740,15 +8813,15 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7743: $lt_compile\"" >&5) + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7747: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes @@ -7760,7 +8833,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } -if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then +if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : @@ -7777,20 +8850,19 @@ fi lt_prog_compiler_pic= lt_prog_compiler_static= -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 -$as_echo_n "checking for $compiler option to produce PIC... " >&6; } - if test "$GCC" = yes; then + if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi + lt_prog_compiler_pic='-fPIC' ;; amigaos*) @@ -7801,8 +8873,8 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but - # adding the `-m68020' flag to GCC prevents building anything better, - # like `-m68040'. + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac @@ -7818,6 +8890,11 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac ;; darwin* | rhapsody*) @@ -7826,6 +8903,12 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } lt_prog_compiler_pic='-fno-common' ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + lt_prog_compiler_static= + ;; + hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag @@ -7868,12 +8951,21 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } lt_prog_compiler_pic='-fPIC' ;; esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + lt_prog_compiler_wl='-Xlinker ' + if test -n "$lt_prog_compiler_pic"; then + lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" + fi + ;; + esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else @@ -7881,10 +8973,29 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } fi ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' + case $host_os in + os2*) + lt_prog_compiler_static='$wl-static' + ;; + esac ;; hpux9* | hpux10* | hpux11*) @@ -7900,7 +9011,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? - lt_prog_compiler_static='${wl}-a ${wl}archive' + lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) @@ -7909,9 +9020,9 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } lt_prog_compiler_static='-non_shared' ;; - linux* | k*bsd*-gnu) + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in - # old Intel for x86_64 which still supported -KPIC. + # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' @@ -7930,7 +9041,19 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; - pgcc* | pgf77* | pgf90* | pgf95*) + nagfor*) + # NAG Fortran compiler + lt_prog_compiler_wl='-Wl,-Wl,,' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' @@ -7942,25 +9065,40 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; - xl*) - # IBM XL C 8.0/Fortran 10.1 on PPC + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + *Sun\ F* | *Sun*Fortran*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Qoption ld ' + ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; - *Sun\ F*) - # Sun Fortran 8.3 passes all unrecognized flags to the linker - lt_prog_compiler_pic='-KPIC' + *Intel*\ [CF]*Compiler*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + *Portland\ Group*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' - lt_prog_compiler_wl='' ;; esac ;; @@ -7992,7 +9130,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in - f77* | f90* | f95*) + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; @@ -8012,7 +9150,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } ;; sysv4*MP*) - if test -d /usr/nec ;then + if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi @@ -8041,7 +9179,7 @@ $as_echo_n "checking for $compiler option to produce PIC... " >&6; } fi case $host_os in - # For platforms which do not support PIC, -DPIC is meaningless: + # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; @@ -8049,13 +9187,17 @@ case $host_os in lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 -$as_echo "$lt_prog_compiler_pic" >&6; } - - - - +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } +if ${lt_cv_prog_compiler_pic+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic=$lt_prog_compiler_pic +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 +$as_echo "$lt_cv_prog_compiler_pic" >&6; } +lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. @@ -8063,13 +9205,13 @@ $as_echo "$lt_prog_compiler_pic" >&6; } if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } -if test "${lt_cv_prog_compiler_pic_works+set}" = set; then : +if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext - lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins @@ -8079,15 +9221,15 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8082: $lt_compile\"" >&5) + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8086: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes @@ -8099,7 +9241,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } -if test x"$lt_cv_prog_compiler_pic_works" = xyes; then +if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; @@ -8116,17 +9258,22 @@ fi + + + + + # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } -if test "${lt_cv_prog_compiler_static_works+set}" = set; then : +if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then @@ -8135,7 +9282,7 @@ else if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 - $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes @@ -8145,13 +9292,13 @@ else fi fi $RM -r conftest* - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } -if test x"$lt_cv_prog_compiler_static_works" = xyes; then +if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= @@ -8165,7 +9312,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test "${lt_cv_prog_compiler_c_o+set}" = set; then : +if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no @@ -8184,16 +9331,16 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8187: $lt_compile\"" >&5) + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8191: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes @@ -8220,7 +9367,7 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } -if test "${lt_cv_prog_compiler_c_o+set}" = set; then : +if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no @@ -8239,16 +9386,16 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8242: $lt_compile\"" >&5) + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8246: \$? = $ac_status" >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings - $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes @@ -8271,8 +9418,8 @@ $as_echo "$lt_cv_prog_compiler_c_o" >&6; } -hard_links="nottested" -if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then +hard_links=nottested +if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } @@ -8284,9 +9431,9 @@ $as_echo_n "checking if we can lock with hard links... " >&6; } ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } - if test "$hard_links" = no; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 -$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + if test no = "$hard_links"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else @@ -8314,7 +9461,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported @@ -8330,9 +9476,9 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude - # it will be wrapped by ` (' and `)$', so one must not match beginning or - # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', - # as well as any symbol that contains `d'. + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if @@ -8347,7 +9493,7 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. - if test "$GCC" != yes; then + if test yes != "$GCC"; then with_gnu_ld=no fi ;; @@ -8355,30 +9501,57 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; - openbsd*) + openbsd* | bitrig*) with_gnu_ld=no ;; esac ld_shlibs=yes - if test "$with_gnu_ld" = yes; then + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; + *\ \(GNU\ Binutils\)\ [3-9]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty - wlarc='${wl}' + wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - export_dynamic_flag_spec='${wl}--export-dynamic' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then - whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no - case `$LD -v 2>&1` in + case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... @@ -8390,15 +9563,16 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken - if test "$host_cpu" != ia64; then + if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 -*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you -*** really care for shared libraries, you may want to modify your PATH -*** so that a non-GNU linker is found, and then restart. +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. _LT_EOF fi @@ -8408,7 +9582,7 @@ _LT_EOF case $host_cpu in powerpc) # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) @@ -8424,7 +9598,7 @@ _LT_EOF allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME - archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi @@ -8434,61 +9608,97 @@ _LT_EOF # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' + export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes - export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' - # If the export-symbols file already is a .def file (1st line - # is EXPORTS), use it as is; otherwise, prepend... - archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname.def; - else - echo EXPORTS > $output_objdir/$soname.def; - cat $export_symbols >> $output_objdir/$soname.def; - fi~ - $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; + haiku*) + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + link_all_deplibs=yes + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes + ;; + interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. - archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' - archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; - gnu* | linux* | tpf* | k*bsd*-gnu) + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no - if test "$host_os" = linux-dietlibc; then + if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ - && test "$tmp_diet" = no + && test no = "$tmp_diet" then - tmp_addflag= + tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; - pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers - whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; @@ -8499,39 +9709,47 @@ _LT_EOF lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; - xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + compiler_needs_object=yes + ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 - whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac - archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in - xlf*) + tcc*) + export_dynamic_flag_spec='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' - hardcode_libdir_flag_spec= - hardcode_libdir_flag_spec_ld='-rpath $libdir' - archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' - if test "x$supports_anon_versioning" = xyes; then + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ - cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ - echo "local: *; };" >> $output_objdir/$libname.ver~ - $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac @@ -8545,8 +9763,8 @@ _LT_EOF archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; @@ -8564,8 +9782,8 @@ _LT_EOF _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -8577,7 +9795,7 @@ _LT_EOF ld_shlibs=no cat <<_LT_EOF 1>&2 -*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify @@ -8592,9 +9810,9 @@ _LT_EOF # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi @@ -8611,15 +9829,15 @@ _LT_EOF *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac - if test "$ld_shlibs" = no; then + if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= @@ -8635,7 +9853,7 @@ _LT_EOF # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes - if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported @@ -8643,32 +9861,57 @@ _LT_EOF ;; aix[4-9]*) - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' - no_entry_flag="" + no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. - # -C means demangle to AIX nm, but means don't demangle with GNU nm + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then - export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else - export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we - # need to do runtime linking. + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi ;; esac @@ -8687,13 +9930,21 @@ _LT_EOF hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes - file_list_spec='${wl}-f,' + file_list_spec='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + hardcode_direct=no + hardcode_direct_absolute=no + ;; + esac - if test "$GCC" = yes; then + if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ - collect2name=`${CC} -print-prog-name=collect2` + collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then @@ -8712,35 +9963,48 @@ _LT_EOF ;; esac shared_flag='-shared' - if test "$aix_use_runtimelinking" = yes; then - shared_flag="$shared_flag "'${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' else # not using gcc - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else - if test "$aix_use_runtimelinking" = yes; then - shared_flag='${wl}-G' + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' else - shared_flag='${wl}-bM:SRE' + shared_flag='$wl-bM:SRE' fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' fi fi - export_dynamic_flag_spec='${wl}-bexpall' + export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes - if test "$aix_use_runtimelinking" = yes; then + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -8753,34 +10017,47 @@ main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" - archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else - if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + if test ia64 = "$host_cpu"; then + hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + if ${lt_cv_aix_libpath_+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -8793,33 +10070,57 @@ main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : -lt_aix_libpath_sed=' - /Import File Strings/,/^$/ { - /^0/ { - s/^0 *\(.*\)$/\1/ - p - } - }' -aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -# Check for a 64-bit object if we didn't find anything. -if test -z "$aix_libpath"; then - aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` -fi + lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }' + lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext -if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + if test -z "$lt_cv_aix_libpath_"; then + lt_cv_aix_libpath_=/usr/lib:/lib + fi - hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" +fi + + aix_libpath=$lt_cv_aix_libpath_ +fi + + hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. - no_undefined_flag=' ${wl}-bernotok' - allow_undefined_flag=' ${wl}-berok' - # Exported symbols can be pulled into shared objects from archives - whole_archive_flag_spec='$convenience' + no_undefined_flag=' $wl-bernotok' + allow_undefined_flag=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + fi archive_cmds_need_lc=yes - # This is similar to how AIX traditionally builds its shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; @@ -8828,7 +10129,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi case $host_cpu in powerpc) # see comment about AmigaOS4 .so support - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) @@ -8848,20 +10149,65 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. - hardcode_libdir_flag_spec=' ' - allow_undefined_flag=unsupported - # Tell ltmain to make .lib files, not .a files. - libext=lib - # Tell ltmain to make .dll files, not .so files. - shrext_cmds=".dll" - # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' - # The linker will automatically build a .lib file if we build a DLL. - old_archive_from_new_cmds='true' - # FIXME: Should let the user specify the lib program. - old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' - fix_srcfile_path='`cygpath -w "$srcfile"`' - enable_shared_with_static_runtimes=yes + case $cc_basename in + cl*) + # Native MSVC + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + always_export_symbols=yes + file_list_spec='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, )='true' + enable_shared_with_static_runtimes=yes + exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + old_postinstall_cmds='chmod 644 $oldlib' + postlink_cmds='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + enable_shared_with_static_runtimes=yes + ;; + esac ;; darwin* | rhapsody*) @@ -8871,19 +10217,24 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported - whole_archive_flag_spec='' + if test yes = "$lt_cv_ld_force_load"; then + whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + + else + whole_archive_flag_spec='' + fi link_all_deplibs=yes - allow_undefined_flag="$_lt_dar_allow_undefined" + allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in - ifort*) _lt_dar_can_shared=yes ;; + ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac - if test "$_lt_dar_can_shared" = "yes"; then - output_verbose_link_cmd=echo - archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" - module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" - archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" - module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no @@ -8897,10 +10248,6 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi hardcode_shlibpath_var=no ;; - freebsd1*) - ld_shlibs=no - ;; - # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little @@ -8913,7 +10260,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. - freebsd2*) + freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes @@ -8922,41 +10269,40 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) - archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) - if test "$GCC" = yes; then - archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + if test yes = "$GCC"; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else - archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes - export_dynamic_flag_spec='${wl}-E' + export_dynamic_flag_spec='$wl-E' ;; hpux10*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + if test yes,no = "$GCC,$with_gnu_ld"; then + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' - hardcode_libdir_flag_spec_ld='+b $libdir' + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' + export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes @@ -8964,33 +10310,72 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ;; hpux11*) - if test "$GCC" = yes -a "$with_gnu_ld" = no; then + if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) - archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 +$as_echo_n "checking if $CC understands -b... " >&6; } +if ${lt_cv_prog_compiler__b+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler__b=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -b" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler__b=yes + fi + else + lt_cv_prog_compiler__b=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 +$as_echo "$lt_cv_prog_compiler__b" >&6; } + +if test yes = "$lt_cv_prog_compiler__b"; then + archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' +else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' +fi + ;; esac fi - if test "$with_gnu_ld" = no; then - hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + if test no = "$with_gnu_ld"; then + hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in @@ -9001,7 +10386,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi *) hardcode_direct=yes hardcode_direct_absolute=yes - export_dynamic_flag_spec='${wl}-E' + export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. @@ -9012,35 +10397,58 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ;; irix5* | irix6* | nonstopux*) - if test "$GCC" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GCC"; then + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + # This should be the same for all languages, so no per-tag cache variable. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 +$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } +if ${lt_cv_irix_exported_symbol+:} false; then : + $as_echo_n "(cached) " >&6 +else + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -int foo(void) {} +int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' - + lt_cv_irix_exported_symbol=yes +else + lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS="$save_LDFLAGS" + LDFLAGS=$save_LDFLAGS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 +$as_echo "$lt_cv_irix_exported_symbol" >&6; } + if test yes = "$lt_cv_irix_exported_symbol"; then + archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi else - archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + ld_shlibs=yes + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out @@ -9055,7 +10463,7 @@ rm -f core conftest.err conftest.$ac_objext \ newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; @@ -9063,27 +10471,19 @@ rm -f core conftest.err conftest.$ac_objext \ *nto* | *qnx*) ;; - openbsd*) + openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - export_dynamic_flag_spec='${wl}-E' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' + export_dynamic_flag_spec='$wl-E' else - case $host_os in - openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' - ;; - *) - archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' - hardcode_libdir_flag_spec='${wl}-rpath,$libdir' - ;; - esac + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no @@ -9094,33 +10494,53 @@ rm -f core conftest.err conftest.$ac_objext \ hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported - archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' - old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + shrext_cmds=.dll + archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + enable_shared_with_static_runtimes=yes ;; osf3*) - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag - if test "$GCC" = yes; then - allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' - hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + if test yes = "$GCC"; then + allow_undefined_flag=' $wl-expect_unresolved $wl\*' + archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' - archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ - $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' @@ -9131,24 +10551,24 @@ rm -f core conftest.err conftest.$ac_objext \ solaris*) no_undefined_flag=' -z defs' - if test "$GCC" = yes; then - wlarc='${wl}' - archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + wlarc='$wl' + archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' - archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) - wlarc='${wl}' - archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + wlarc='$wl' + archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi @@ -9158,11 +10578,11 @@ rm -f core conftest.err conftest.$ac_objext \ solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, - # but understands `-z linker_flag'. GCC discards it without `$wl', + # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) - if test "$GCC" = yes; then - whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + if test yes = "$GCC"; then + whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi @@ -9172,10 +10592,10 @@ rm -f core conftest.err conftest.$ac_objext \ ;; sunos4*) - if test "x$host_vendor" = xsequent; then + if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. - archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi @@ -9224,43 +10644,43 @@ rm -f core conftest.err conftest.$ac_objext \ ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) - no_undefined_flag='${wl}-z,text' + no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) - # Note: We can NOT use -z defs as we might desire, because we do not + # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. - no_undefined_flag='${wl}-z,text' - allow_undefined_flag='${wl}-z,nodefs' + no_undefined_flag='$wl-z,text' + allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no - hardcode_libdir_flag_spec='${wl}-R,$libdir' + hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes - export_dynamic_flag_spec='${wl}-Bexport' + export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' - if test "$GCC" = yes; then - archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + if test yes = "$GCC"; then + archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else - archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' - archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; @@ -9275,10 +10695,10 @@ rm -f core conftest.err conftest.$ac_objext \ ;; esac - if test x$host_vendor = xsni; then + if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) - export_dynamic_flag_spec='${wl}-Blargedynsym' + export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi @@ -9286,7 +10706,7 @@ rm -f core conftest.err conftest.$ac_objext \ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } -test "$ld_shlibs" = no && can_build_shared=no +test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld @@ -9312,7 +10732,7 @@ x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes - if test "$enable_shared" = yes && test "$GCC" = yes; then + if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. @@ -9323,44 +10743,50 @@ x|xyes) # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } - $RM conftest* - echo "$lt_simple_compile_test_code" > conftest.$ac_ext +if ${lt_cv_archive_cmds_need_lc+:} false; then : + $as_echo_n "(cached) " >&6 +else + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then - soname=conftest - lib=conftest - libobjs=conftest.$ac_objext - deplibs= - wl=$lt_prog_compiler_wl - pic_flag=$lt_prog_compiler_pic - compiler_flags=-v - linker_flags=-v - verstring= - output_objdir=. - libname=conftest - lt_save_allow_undefined_flag=$allow_undefined_flag - allow_undefined_flag= - if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } - then - archive_cmds_need_lc=no - else - archive_cmds_need_lc=yes - fi - allow_undefined_flag=$lt_save_allow_undefined_flag - else - cat conftest.err 1>&5 - fi - $RM conftest* - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 -$as_echo "$archive_cmds_need_lc" >&6; } + then + lt_cv_archive_cmds_need_lc=no + else + lt_cv_archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 +$as_echo "$lt_cv_archive_cmds_need_lc" >&6; } + archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi @@ -9512,11 +10938,6 @@ esac - - - - - @@ -9526,44 +10947,58 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } -if test "$GCC" = yes; then +if test yes = "$GCC"; then case $host_os in - darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; - *) lt_awk_arg="/^libraries:/" ;; + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; esac - lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` - else - lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac # Ok, now we have the path, separated by spaces, we can step through it - # and add multilib dir if necessary. + # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= - lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac for lt_sys_path in $lt_search_path_spec; do - if test -d "$lt_sys_path/$lt_multi_os_dir"; then - lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" - else + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done - lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' -BEGIN {RS=" "; FS="/|\n";} { - lt_foo=""; - lt_count=0; + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { - lt_foo="/" $lt_i lt_foo; + lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } @@ -9573,14 +11008,20 @@ BEGIN {RS=" "; FS="/|\n";} { if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` - sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([A-Za-z]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= -shrext_cmds=".so" +shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= @@ -9597,56 +11038,108 @@ hardcode_into_libs=no # flags to be left without arguments need_version=unknown + + case $host_os in aix3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. - soname_spec='${libname}${release}${shared_ext}$major' + soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes - if test "$host_cpu" = ia64; then + if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 - library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with - # the line `#! .'. This would cause the generated library to - # depend on `.', always an invalid library. This was fixed in + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' - echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. - if test "$aix_use_runtimelinking" = yes; then + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. - library_names_spec='${libname}${release}.a $libname.a' - soname_spec='${libname}${release}${shared_ext}$major' - fi + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac shlibpath_var=LIBPATH fi ;; @@ -9656,27 +11149,27 @@ amigaos*) powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) - library_names_spec='${libname}${shared_ext}' + library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" @@ -9688,16 +11181,17 @@ bsdi[45]*) cygwin* | mingw* | pw32* | cegcc*) version_type=windows - shrext_cmds=".dll" + shrext_cmds=.dll need_version=no need_lib_prefix=no - case $GCC,$host_os in - yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + case $GCC,$cc_basename in + yes,*) + # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds - postinstall_cmds='base_file=`basename \${file}`~ - dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ @@ -9713,37 +11207,84 @@ cygwin* | mingw* | pw32* | cegcc*) case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix - soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' - sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` - if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then - # It is most probably a Windows format PATH printed by - # mingw gcc, but we are running on Cygwin. Gcc prints its search - # path with ; separators, and with drive letters. We can handle the - # drive letters (cygwin fileutils understands them), so leave them, - # especially as we might pass files found there to a mingw objdump, - # which wouldn't understand a cygwinified path. Ahh. - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` - else - sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` - fi + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' - library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' ;; *) - library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' ;; esac - dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; @@ -9753,8 +11294,8 @@ darwin* | rhapsody*) version_type=darwin need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' - soname_spec='${libname}${release}${major}$shared_ext' + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' @@ -9764,18 +11305,14 @@ darwin* | rhapsody*) ;; dgux*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; -freebsd1*) - dynamic_linker=no - ;; - freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. @@ -9783,25 +11320,26 @@ freebsd* | dragonfly*) objformat=`/usr/bin/objformat` else case $host_os in - freebsd[123]*) objformat=aout ;; + freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) - library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in - freebsd2*) + freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) @@ -9820,13 +11358,16 @@ freebsd* | dragonfly*) esac ;; -gnu*) - version_type=linux +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - shlibpath_var=LD_LIBRARY_PATH + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; @@ -9843,14 +11384,15 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' - if test "X$HPUX_IA64_MODE" = X32; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi - sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' @@ -9858,8 +11400,8 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; @@ -9868,20 +11410,22 @@ hpux9* | hpux10* | hpux11*) dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' ;; esac - # HP-UX runs *really* slowly unless shared libraries are mode 555. + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 ;; interix[3-9]*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no @@ -9892,16 +11436,16 @@ irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) - if test "$lt_cv_prog_gnu_ld" = yes; then - version_type=linux + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= @@ -9920,8 +11464,8 @@ irix5* | irix6* | nonstopux*) esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no - sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" - sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; @@ -9930,22 +11474,47 @@ linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; -# This must be Linux ELF. -linux* | k*bsd*-gnu) - version_type=linux +linux*android*) + version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + hardcode_libdir_flag_spec='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH - save_LDFLAGS=$LDFLAGS - save_libdir=$libdir - eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ - LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + if ${lt_cv_shlibpath_overrides_runpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -9958,22 +11527,31 @@ main () _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : - shlibpath_overrides_runpath=yes + lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext - LDFLAGS=$save_LDFLAGS - libdir=$save_libdir + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + +fi + + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes - # Append ld.so.conf contents to the search path + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then - lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi @@ -9991,12 +11569,12 @@ netbsd*) need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH @@ -10005,8 +11583,8 @@ netbsd*) ;; newsos6) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; @@ -10015,58 +11593,68 @@ newsos6) version_type=qnx need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; -openbsd*) +openbsd* | bitrig*) version_type=sunos - sys_lib_dlsearch_path_spec="/usr/lib" + sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no - # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. - case $host_os in - openbsd3.3 | openbsd3.3.*) need_version=yes ;; - *) need_version=no ;; - esac - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH - if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then - case $host_os in - openbsd2.[89] | openbsd2.[89].*) - shlibpath_overrides_runpath=no - ;; - *) - shlibpath_overrides_runpath=yes - ;; - esac - else - shlibpath_overrides_runpath=yes - fi + shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' - shrext_cmds=".dll" + version_type=windows + shrext_cmds=.dll + need_version=no need_lib_prefix=no - library_names_spec='$libname${shared_ext} $libname.a' + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' - shlibpath_var=LIBPATH + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no - soname_spec='${libname}${release}${shared_ext}$major' - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" - sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) @@ -10074,11 +11662,11 @@ rdos*) ;; solaris*) - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes @@ -10088,20 +11676,20 @@ solaris*) sunos4*) version_type=sunos - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) @@ -10122,24 +11710,24 @@ sysv4 | sysv4.3*) ;; sysv4*MP*) - if test -d /usr/nec ;then - version_type=linux - library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' - soname_spec='$libname${shared_ext}.$major' + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) - version_type=freebsd-elf + version_type=sco need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes - if test "$with_gnu_ld" = yes; then + if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' @@ -10154,19 +11742,19 @@ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. - version_type=linux + version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) - version_type=linux - library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' - soname_spec='${libname}${release}${shared_ext}$major' + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; @@ -10176,20 +11764,40 @@ uts4*) esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } -test "$dynamic_linker" = no && can_build_shared=no +test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" -if test "$GCC" = yes; then +if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi -if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then - sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi -if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then - sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + + + + + + + + + + + @@ -10281,15 +11889,15 @@ $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || - test "X$hardcode_automatic" = "Xyes" ; then + test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. - if test "$hardcode_direct" != no && + if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one - ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && - test "$hardcode_minus_L" != no; then + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && + test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else @@ -10304,12 +11912,12 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } -if test "$hardcode_action" = relink || - test "$inherit_rpath" = yes; then +if test relink = "$hardcode_action" || + test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no -elif test "$shlibpath_overrides_runpath" = yes || - test "$enable_shared" = no; then +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi @@ -10319,7 +11927,7 @@ fi - if test "x$enable_dlopen" != xyes; then + if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown @@ -10329,26 +11937,26 @@ else case $host_os in beos*) - lt_cv_dlopen="load_add_on" + lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) - lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) - lt_cv_dlopen="dlopen" + lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) - # if libdl is installed we need to link against it + # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10382,11 +11990,11 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else - lt_cv_dlopen="dyld" + lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes @@ -10394,14 +12002,22 @@ fi ;; + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" -if test "x$ac_cv_func_shl_load" = x""yes; then : - lt_cv_dlopen="shl_load" +if test "x$ac_cv_func_shl_load" = xyes; then : + lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } -if test "${ac_cv_lib_dld_shl_load+set}" = set; then : +if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10435,16 +12051,16 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } -if test "x$ac_cv_lib_dld_shl_load" = x""yes; then : - lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : + lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" -if test "x$ac_cv_func_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" +if test "x$ac_cv_func_dlopen" = xyes; then : + lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } -if test "${ac_cv_lib_dl_dlopen+set}" = set; then : +if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10478,12 +12094,12 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } -if test "x$ac_cv_lib_dl_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } -if test "${ac_cv_lib_svld_dlopen+set}" = set; then : +if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10517,12 +12133,12 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } -if test "x$ac_cv_lib_svld_dlopen" = x""yes; then : - lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : + lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } -if test "${ac_cv_lib_dld_dld_link+set}" = set; then : +if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -10556,8 +12172,8 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } -if test "x$ac_cv_lib_dld_dld_link" = x""yes; then : - lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : + lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi @@ -10578,35 +12194,35 @@ fi ;; esac - if test "x$lt_cv_dlopen" != xno; then - enable_dlopen=yes - else + if test no = "$lt_cv_dlopen"; then enable_dlopen=no + else + enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) - save_CPPFLAGS="$CPPFLAGS" - test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" - save_LDFLAGS="$LDFLAGS" + save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" - save_LIBS="$LIBS" + save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } -if test "${lt_cv_dlopen_self+set}" = set; then : +if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : + if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10609 "configure" +#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10647,7 +12263,13 @@ else # endif #endif -void fnord() { int i=42;} +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -10656,7 +12278,11 @@ int main () if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } /* dlclose (self); */ } else @@ -10669,7 +12295,7 @@ _LT_EOF (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in @@ -10689,20 +12315,20 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } - if test "x$lt_cv_dlopen_self" = xyes; then + if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } -if test "${lt_cv_dlopen_self_static+set}" = set; then : +if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then : + if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10705 "configure" +#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10743,7 +12369,13 @@ else # endif #endif -void fnord() { int i=42;} +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); @@ -10752,7 +12384,11 @@ int main () if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; - else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } /* dlclose (self); */ } else @@ -10765,7 +12401,7 @@ _LT_EOF (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in @@ -10786,9 +12422,9 @@ fi $as_echo "$lt_cv_dlopen_self_static" >&6; } fi - CPPFLAGS="$save_CPPFLAGS" - LDFLAGS="$save_LDFLAGS" - LIBS="$save_LIBS" + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS ;; esac @@ -10832,7 +12468,7 @@ else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) - if test -n "$STRIP" ; then + if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -10860,7 +12496,7 @@ fi - # Report which library types will actually be built + # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 @@ -10868,13 +12504,13 @@ $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } - test "$can_build_shared" = "no" && enable_shared=no + test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) - test "$enable_shared" = yes && enable_static=no + test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' @@ -10882,8 +12518,12 @@ $as_echo_n "checking whether to build shared libraries... " >&6; } ;; aix[4-9]*) - if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then - test "$enable_shared" = yes && enable_static=no + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac fi ;; esac @@ -10893,7 +12533,7 @@ $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. - test "$enable_shared" = yes || enable_static=yes + test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } @@ -10907,7 +12547,9 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -CC="$lt_save_CC" +CC=$lt_save_CC + + @@ -10930,10 +12572,101 @@ CC="$lt_save_CC" + +# Some awks crash when confronted with pnglibconf.dfa, do a test run now +# to make sure this doesn't happen +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that AWK works" >&5 +$as_echo_n "checking that AWK works... " >&6; } +if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa 1>&2 +then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 1 "failed +See \`config.log' for more details" "$LINENO" 5; } +fi + +# This is a remnant of the old cc -E validation, where it may have been +# necessary to use a different preprocessor for .dfn files +DFNCPP="$CPP" + + +# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it +# checks the compiler with a program that generates a warning), add the +# following option to deal with this + +# Check whether --enable-werror was given. +if test "${enable_werror+set}" = set; then : + enableval=$enable_werror; test "$enable_werror" = "yes" && enable_werror="-Werror" + if test "$enable_werror" != "no"; then + sav_CFLAGS="$CFLAGS" + CFLAGS="$enable_werror $CFLAGS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler allows $enable_werror" >&5 +$as_echo_n "checking if the compiler allows $enable_werror... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + int main(int argc, char **argv){ + return argv[argc-1][0]; + } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + PNG_COPTS="$PNG_COPTS $enable_werror" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$sav_CFLAGS" + fi +fi + + +# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89 +# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1 +# This is incompatible with the new default mode, so we test for that and force the +# "-std=c89" compiler option: +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to force back C standard to C89" >&5 +$as_echo_n "checking if we need to force back C standard to C89... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #define _POSIX_SOURCE 1 + #include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +else + + if test "x$GCC" != "xyes"; then + as_fn_error $? "Forcing back to C89 is required but the flags are only known for GCC" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + CFLAGS="$CFLAGS -std=c89" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11043,25 +12776,11 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi -for ac_header in malloc.h stdlib.h string.h strings.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : +if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11070,11 +12789,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -11091,8 +12810,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -11108,10 +12828,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -11140,7 +12860,7 @@ $as_echo "#define const /**/" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : +if test "x$ac_cv_type_size_t" = xyes; then : else @@ -11152,7 +12872,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if test "${ac_cv_struct_tm+set}" = set; then : +if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -11185,11 +12905,57 @@ $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 +$as_echo_n "checking for C/C++ restrict keyword... " >&6; } +if ${ac_cv_c_restrict+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +typedef int * int_ptr; + int foo (int_ptr $ac_kw ip) { + return ip[0]; + } +int +main () +{ +int s[1]; + int * $ac_kw t = s; + t[0] = 0; + return foo(t) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_restrict=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_restrict" != no && break + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 +$as_echo "$ac_cv_c_restrict" >&6; } + + case $ac_cv_c_restrict in + restrict) ;; + no) $as_echo "#define restrict /**/" >>confdefs.h + ;; + *) cat >>confdefs.h <<_ACEOF +#define restrict $ac_cv_c_restrict +_ACEOF + ;; + esac + # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 $as_echo_n "checking for working strtod... " >&6; } -if test "${ac_cv_func_strtod+set}" = set; then : +if ${ac_cv_func_strtod+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -11248,14 +13014,14 @@ if test $ac_cv_func_strtod = no; then esac ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = x""yes; then : +if test "x$ac_cv_func_pow" = xyes; then : fi if test $ac_cv_func_pow = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 $as_echo_n "checking for pow in -lm... " >&6; } -if test "${ac_cv_lib_m_pow+set}" = set; then : +if ${ac_cv_lib_m_pow+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11289,7 +13055,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 $as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = x""yes; then : +if test "x$ac_cv_lib_m_pow" = xyes; then : POW_LIB=-lm else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 @@ -11300,23 +13066,10 @@ fi fi -for ac_func in memset -do : - ac_fn_c_check_func "$LINENO" "memset" "ac_cv_func_memset" -if test "x$ac_cv_func_memset" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_MEMSET 1 -_ACEOF - -else - as_fn_error "memset not found in libc" "$LINENO" 5 -fi -done - for ac_func in pow do : ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" -if test "x$ac_cv_func_pow" = x""yes; then : +if test "x$ac_cv_func_pow" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_POW 1 _ACEOF @@ -11324,7 +13077,7 @@ _ACEOF else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 $as_echo_n "checking for pow in -lm... " >&6; } -if test "${ac_cv_lib_m_pow+set}" = set; then : +if ${ac_cv_lib_m_pow+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11358,7 +13111,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 $as_echo "$ac_cv_lib_m_pow" >&6; } -if test "x$ac_cv_lib_m_pow" = x""yes; then : +if test "x$ac_cv_lib_m_pow" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -11366,15 +13119,43 @@ _ACEOF LIBS="-lm $LIBS" else - as_fn_error "cannot find pow" "$LINENO" 5 + as_fn_error $? "cannot find pow" "$LINENO" 5 fi fi done + +# Some later POSIX 1003.1 functions are required for test programs, failure here +# is soft (the corresponding test program is not built). +ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime" +if test "x$ac_cv_func_clock_gettime" = xyes; then : + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: not building timepng" >&5 +$as_echo "$as_me: WARNING: not building timepng" >&2;} +fi + + if test "$ac_cv_func_clock_gettime" = "yes"; then + HAVE_CLOCK_GETTIME_TRUE= + HAVE_CLOCK_GETTIME_FALSE='#' +else + HAVE_CLOCK_GETTIME_TRUE='#' + HAVE_CLOCK_GETTIME_FALSE= +fi + + + +# Check whether --with-zlib-prefix was given. +if test "${with_zlib_prefix+set}" = set; then : + withval=$with_zlib_prefix; ZPREFIX=${withval} +else + ZPREFIX='z_' +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for zlibVersion in -lz" >&5 $as_echo_n "checking for zlibVersion in -lz... " >&6; } -if test "${ac_cv_lib_z_zlibVersion+set}" = set; then : +if ${ac_cv_lib_z_zlibVersion+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11408,7 +13189,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_zlibVersion" >&5 $as_echo "$ac_cv_lib_z_zlibVersion" >&6; } -if test "x$ac_cv_lib_z_zlibVersion" = x""yes; then : +if test "x$ac_cv_lib_z_zlibVersion" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBZ 1 _ACEOF @@ -11416,46 +13197,158 @@ _ACEOF LIBS="-lz $LIBS" else - as_fn_error "zlib not installed" "$LINENO" 5 -fi - - -case $host_os in - aix*) - LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG -D_ALL_SOURCE;; - *) - LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG;; -esac -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE" >&5 -$as_echo_n "checking if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE... " >&6; } + as_ac_Lib=`$as_echo "ac_cv_lib_z_${ZPREFIX}zlibVersion" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ZPREFIX}zlibVersion in -lz" >&5 +$as_echo_n "checking for ${ZPREFIX}zlibVersion in -lz... " >&6; } +if eval \${$as_ac_Lib+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include "$srcdir/pnggccrd.c" + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ${ZPREFIX}zlibVersion (); int main () { -return 0; +return ${ZPREFIX}zlibVersion (); ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - LIBPNG_NO_MMX="" +if ac_fn_c_try_link "$LINENO"; then : + eval "$as_ac_Lib=yes" else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - LIBPNG_NO_MMX=-DPNG_NO_MMX_CODE + eval "$as_ac_Lib=no" fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -LIBPNG_DEFINES=$LIBPNG_DEFINES\ $LIBPNG_NO_MMX +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +eval ac_res=\$$as_ac_Lib + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBZ 1 +_ACEOF + LIBS="-lz $LIBS" + +else + as_fn_error $? "zlib not installed" "$LINENO" 5 +fi + +fi + + +# The following is for pngvalid, to ensure it catches FP errors even on +# platforms that don't enable FP exceptions, the function appears in the math +# library (typically), it's not an error if it is not found. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for feenableexcept in -lm" >&5 +$as_echo_n "checking for feenableexcept in -lm... " >&6; } +if ${ac_cv_lib_m_feenableexcept+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char feenableexcept (); +int +main () +{ +return feenableexcept (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_feenableexcept=yes +else + ac_cv_lib_m_feenableexcept=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_feenableexcept" >&5 +$as_echo "$ac_cv_lib_m_feenableexcept" >&6; } +if test "x$ac_cv_lib_m_feenableexcept" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + +for ac_func in feenableexcept +do : + ac_fn_c_check_func "$LINENO" "feenableexcept" "ac_cv_func_feenableexcept" +if test "x$ac_cv_func_feenableexcept" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_FEENABLEEXCEPT 1 +_ACEOF + +fi +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if using Solaris linker" >&5 +$as_echo_n "checking if using Solaris linker... " >&6; } +SLD=`$LD --version 2>&1 | grep Solaris` +if test "$SLD"; then + have_solaris_ld=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + have_solaris_ld=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + if test "$have_solaris_ld" = "yes"; then + HAVE_SOLARIS_LD_TRUE= + HAVE_SOLARIS_LD_FALSE='#' +else + HAVE_SOLARIS_LD_TRUE='#' + HAVE_SOLARIS_LD_FALSE= +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libraries can be versioned" >&5 $as_echo_n "checking if libraries can be versioned... " >&6; } -GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` +# Special case for PE/COFF platforms: ld reports +# support for version-script, but doesn't actually +# DO anything with it. +case $host in +*cygwin* | *mingw32* | *interix* ) + have_ld_version_script=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +;; +* ) + +if test "$have_solaris_ld" = "yes"; then + GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'` +else + GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` +fi + if test "$GLD"; then have_ld_version_script=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -11467,6 +13360,9 @@ $as_echo "no" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** You have not enabled versioned symbols." >&5 $as_echo "$as_me: WARNING: *** You have not enabled versioned symbols." >&2;} fi +;; +esac + if test "$have_ld_version_script" = "yes"; then HAVE_LD_VERSION_SCRIPT_TRUE= HAVE_LD_VERSION_SCRIPT_FALSE='#' @@ -11480,9 +13376,9 @@ if test "$have_ld_version_script" = "yes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for symbol prefix" >&5 $as_echo_n "checking for symbol prefix... " >&6; } SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ - | ${CPP-${CC-gcc} -E} - 2>&1 \ - | ${EGREP-grep} "^PREFIX=" \ - | ${SED-sed} "s:^PREFIX=::"` + | ${CPP-${CC-gcc} -E} - 2>&1 \ + | ${EGREP-grep} "^PREFIX=" \ + | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SYMBOL_PREFIX" >&5 $as_echo "$SYMBOL_PREFIX" >&6; } @@ -11514,40 +13410,366 @@ $as_echo "$as_me: pkgconfig directory is ${pkgconfigdir}" >&6;} # Check whether --with-binconfigs was given. if test "${with_binconfigs+set}" = set; then : withval=$with_binconfigs; if test "${withval}" = no; then - binconfigs= - { $as_echo "$as_me:${as_lineno-$LINENO}: libpng-config scripts will not be built" >&5 + binconfigs= + { $as_echo "$as_me:${as_lineno-$LINENO}: libpng-config scripts will not be built" >&5 $as_echo "$as_me: libpng-config scripts will not be built" >&6;} - else - binconfigs='${binconfigs}' - fi + else + binconfigs='${binconfigs}' + fi else binconfigs='${binconfigs}' fi -# Allow the old version number library, libpng.so, to be removed from -# the build +# Support for prefixes to the API function names; this will generate defines +# at the start of the build to rename exported library functions -# Check whether --with-libpng-compat was given. -if test "${with_libpng_compat+set}" = set; then : - withval=$with_libpng_compat; if test "${withval}" = no; then - compatlib= - { $as_echo "$as_me:${as_lineno-$LINENO}: libpng.so will not be built" >&5 -$as_echo "$as_me: libpng.so will not be built" >&6;} - else - compatlib=libpng.la - fi +# Check whether --with-libpng-prefix was given. +if test "${with_libpng_prefix+set}" = set; then : + withval=$with_libpng_prefix; if test "${withval:-no}" != "no"; then + PNG_PREFIX=${withval} + + fi +fi + + if test "${with_libpng_prefix:-no}" != "no"; then + DO_PNG_PREFIX_TRUE= + DO_PNG_PREFIX_FALSE='#' else - compatlib=libpng.la + DO_PNG_PREFIX_TRUE='#' + DO_PNG_PREFIX_FALSE= +fi + + +# Control over what links are made for installed files. Versioned files are +# always installed, when the following options are turned on corresponding +# unversioned links are also created (normally as symbolic links): +# Check whether --enable-unversioned-links was given. +if test "${enable_unversioned_links+set}" = set; then : + enableval=$enable_unversioned_links; +fi + + +# The AM_CONDITIONAL test is written so that the default is enabled; +# --disable-unversioned-links must be given to turn the option off. + if test "$enable_unversioned_links" != "no"; then + DO_INSTALL_LINKS_TRUE= + DO_INSTALL_LINKS_FALSE='#' +else + DO_INSTALL_LINKS_TRUE='#' + DO_INSTALL_LINKS_FALSE= +fi + + +# Check whether --enable-unversioned-libpng-pc was given. +if test "${enable_unversioned_libpng_pc+set}" = set; then : + enableval=$enable_unversioned_libpng_pc; +fi + + if test "$enable_unversioned_libpng_pc" != "no"; then + DO_INSTALL_LIBPNG_PC_TRUE= + DO_INSTALL_LIBPNG_PC_FALSE='#' +else + DO_INSTALL_LIBPNG_PC_TRUE='#' + DO_INSTALL_LIBPNG_PC_FALSE= +fi + + +# Check whether --enable-unversioned-libpng-config was given. +if test "${enable_unversioned_libpng_config+set}" = set; then : + enableval=$enable_unversioned_libpng_config; +fi + + if test "$enable_unversioned_libpng_config" != "no"; then + DO_INSTALL_LIBPNG_CONFIG_TRUE= + DO_INSTALL_LIBPNG_CONFIG_FALSE='#' +else + DO_INSTALL_LIBPNG_CONFIG_TRUE='#' + DO_INSTALL_LIBPNG_CONFIG_FALSE= +fi + + +# HOST SPECIFIC OPTIONS +# ===================== +# +# DEFAULT +# ======= +# +# Check whether --enable-hardware-optimizations was given. +if test "${enable_hardware_optimizations+set}" = set; then : + enableval=$enable_hardware_optimizations; case "$enableval" in + no|off) + # disable hardware optimization on all systems: + enable_arm_neon=no + +$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h + + enable_mips_msa=no + +$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h + + enable_powerpc_vsx=no + +$as_echo "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h + + enable_intel_sse=no + +$as_echo "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h + + ;; + *) + # allow enabling hardware optimization on any system: + case "$host_cpu" in + arm*|aarch64*) + enable_arm_neon=yes + +$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h + + ;; + mipsel*|mips64el*) + enable_mips_msa=yes + +$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h + + ;; + i?86|x86_64) + enable_intel_sse=yes + +$as_echo "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h + + ;; + powerpc*|ppc64*) + enable_powerpc_vsx=yes + +$as_echo "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h + + ;; + esac + ;; + esac +fi + + +# ARM +# === +# +# ARM NEON (SIMD) support. + +# Check whether --enable-arm-neon was given. +if test "${enable_arm_neon+set}" = set; then : + enableval=$enable_arm_neon; case "$enableval" in + no|off) + # disable the default enabling on __ARM_NEON__ systems: + +$as_echo "#define PNG_ARM_NEON_OPT 0" >>confdefs.h + + # Prevent inclusion of the assembler files below: + enable_arm_neon=no;; + check) + +$as_echo "#define PNG_ARM_NEON_CHECK_SUPPORTED /**/" >>confdefs.h +;; + api) + +$as_echo "#define PNG_ARM_NEON_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) + +$as_echo "#define PNG_ARM_NEON_OPT 2" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-arm-neon: please specify 'check' or 'api', if + you want the optimizations unconditionally pass -mfpu=neon + to the compiler." >&5 +$as_echo "$as_me: WARNING: --enable-arm-neon: please specify 'check' or 'api', if + you want the optimizations unconditionally pass -mfpu=neon + to the compiler." >&2;};; + *) + as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: invalid value" "$LINENO" 5 + esac +fi + + +# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or +# where ARM optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'arm*') + + if test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm*|aarch64*) :;; + *) test "$enable_arm_neon" != '';; + esac; then + PNG_ARM_NEON_TRUE= + PNG_ARM_NEON_FALSE='#' +else + PNG_ARM_NEON_TRUE='#' + PNG_ARM_NEON_FALSE= +fi + + +# MIPS +# === +# +# MIPS MSA (SIMD) support. + +# Check whether --enable-mips-msa was given. +if test "${enable_mips_msa+set}" = set; then : + enableval=$enable_mips_msa; case "$enableval" in + no|off) + # disable the default enabling on __mips_msa systems: + +$as_echo "#define PNG_MIPS_MSA_OPT 0" >>confdefs.h + + # Prevent inclusion of the assembler files below: + enable_mips_msa=no;; + check) + +$as_echo "#define PNG_MIPS_MSA_CHECK_SUPPORTED /**/" >>confdefs.h +;; + api) + +$as_echo "#define PNG_MIPS_MSA_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) + +$as_echo "#define PNG_MIPS_MSA_OPT 2" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-mips-msa: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-mmsa -mfp64' + to the compiler." >&5 +$as_echo "$as_me: WARNING: --enable-mips-msa: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-mmsa -mfp64' + to the compiler." >&2;};; + *) + as_fn_error $? "--enable-mips-msa=${enable_mips_msa}: invalid value" "$LINENO" 5 + esac +fi + + +# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or +# where MIPS optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'mips*') + + if test "$enable_mips_msa" != 'no' && + case "$host_cpu" in + mipsel*|mips64el*) :;; + esac; then + PNG_MIPS_MSA_TRUE= + PNG_MIPS_MSA_FALSE='#' +else + PNG_MIPS_MSA_TRUE='#' + PNG_MIPS_MSA_FALSE= +fi + + +# INTEL +# ===== +# +# INTEL SSE (SIMD) support. + +# Check whether --enable-intel-sse was given. +if test "${enable_intel_sse+set}" = set; then : + enableval=$enable_intel_sse; case "$enableval" in + no|off) + # disable the default enabling: + +$as_echo "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h + + # Prevent inclusion of the assembler files below: + enable_intel_sse=no;; + yes|on) + +$as_echo "#define PNG_INTEL_SSE_OPT 1" >>confdefs.h +;; + *) + as_fn_error $? "--enable-intel-sse=${enable_intel_sse}: invalid value" "$LINENO" 5 + esac +fi + + +# Add Intel specific files to all builds where the host_cpu is Intel ('x86*') +# or where Intel optimizations were explicitly requested (this allows a +# fallback if a future host CPU does not match 'x86*') + if test "$enable_intel_sse" != 'no' && + case "$host_cpu" in + i?86|x86_64) :;; + *) test "$enable_intel_sse" != '';; + esac; then + PNG_INTEL_SSE_TRUE= + PNG_INTEL_SSE_FALSE='#' +else + PNG_INTEL_SSE_TRUE='#' + PNG_INTEL_SSE_FALSE= +fi + + +# PowerPC +# === +# +# PowerPC VSX (SIMD) support. + +# Check whether --enable-powerpc-vsx was given. +if test "${enable_powerpc_vsx+set}" = set; then : + enableval=$enable_powerpc_vsx; case "$enableval" in + no|off) + # disable the default enabling on __ppc64__ systems: + +$as_echo "#define PNG_POWERPC_VSX_OPT 0" >>confdefs.h + + # Prevent inclusion of the platform specific files below: + enable_powerpc_vsx=no;; + check) + +$as_echo "#define PNG_POWERPC_VSX_CHECK_SUPPORTED /**/" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file + for the list of supported OSes." >&5 +$as_echo "$as_me: WARNING: --enable-powerpc-vsx Please check contrib/powerpc/README file + for the list of supported OSes." >&2;};; + api) + +$as_echo "#define PNG_POWERPC_VSX_API_SUPPORTED /**/" >>confdefs.h +;; + yes|on) + +$as_echo "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-maltivec -mvsx' + or '-mcpu=power8'to the compiler." >&5 +$as_echo "$as_me: WARNING: --enable-powerpc-vsx: please specify 'check' or 'api', if + you want the optimizations unconditionally pass '-maltivec -mvsx' + or '-mcpu=power8'to the compiler." >&2;};; + *) + as_fn_error $? "--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value" "$LINENO" 5 + esac +fi + + +# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or +# where POWERPC optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'powerpc*') + + if test "$enable_powerpc_vsx" != 'no' && + case "$host_cpu" in + powerpc*|ppc64*) :;; + esac; then + PNG_POWERPC_VSX_TRUE= + PNG_POWERPC_VSX_FALSE='#' +else + PNG_POWERPC_VSX_TRUE='#' + PNG_POWERPC_VSX_FALSE= fi -# Config files, substituting as above -ac_config_files="$ac_config_files Makefile libpng.pc:scripts/libpng.pc-configure.in" +{ $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5 +$as_echo "$as_me: Extra options for compiler: $PNG_COPTS" >&6;} -ac_config_files="$ac_config_files libpng-config:scripts/libpng-config.in" +# Config files, substituting as above +ac_config_files="$ac_config_files Makefile libpng.pc:libpng.pc.in" + +ac_config_files="$ac_config_files libpng-config:libpng-config.in" cat >confcache <<\_ACEOF @@ -11614,10 +13836,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -11633,6 +13866,7 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -11647,6 +13881,14 @@ LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 +$as_echo_n "checking that generated files are newer than configure... " >&6; } + if test -n "$am_sleep_pid"; then + # Hide warnings about reused PIDs. + wait $am_sleep_pid 2>/dev/null + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 +$as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' @@ -11656,23 +13898,67 @@ else fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then - as_fn_error "conditional \"MAINTAINER_MODE\" was never defined. + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. + as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_CLOCK_GETTIME_TRUE}" && test -z "${HAVE_CLOCK_GETTIME_FALSE}"; then + as_fn_error $? "conditional \"HAVE_CLOCK_GETTIME\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${HAVE_SOLARIS_LD_TRUE}" && test -z "${HAVE_SOLARIS_LD_FALSE}"; then + as_fn_error $? "conditional \"HAVE_SOLARIS_LD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_LD_VERSION_SCRIPT_TRUE}" && test -z "${HAVE_LD_VERSION_SCRIPT_FALSE}"; then - as_fn_error "conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined. + as_fn_error $? "conditional \"HAVE_LD_VERSION_SCRIPT\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_PNG_PREFIX_TRUE}" && test -z "${DO_PNG_PREFIX_FALSE}"; then + as_fn_error $? "conditional \"DO_PNG_PREFIX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_INSTALL_LINKS_TRUE}" && test -z "${DO_INSTALL_LINKS_FALSE}"; then + as_fn_error $? "conditional \"DO_INSTALL_LINKS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_INSTALL_LIBPNG_PC_TRUE}" && test -z "${DO_INSTALL_LIBPNG_PC_FALSE}"; then + as_fn_error $? "conditional \"DO_INSTALL_LIBPNG_PC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${DO_INSTALL_LIBPNG_CONFIG_TRUE}" && test -z "${DO_INSTALL_LIBPNG_CONFIG_FALSE}"; then + as_fn_error $? "conditional \"DO_INSTALL_LIBPNG_CONFIG\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_ARM_NEON_TRUE}" && test -z "${PNG_ARM_NEON_FALSE}"; then + as_fn_error $? "conditional \"PNG_ARM_NEON\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_MIPS_MSA_TRUE}" && test -z "${PNG_MIPS_MSA_FALSE}"; then + as_fn_error $? "conditional \"PNG_MIPS_MSA\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_INTEL_SSE_TRUE}" && test -z "${PNG_INTEL_SSE_FALSE}"; then + as_fn_error $? "conditional \"PNG_INTEL_SSE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${PNG_POWERPC_VSX_TRUE}" && test -z "${PNG_POWERPC_VSX_FALSE}"; then + as_fn_error $? "conditional \"PNG_POWERPC_VSX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -11773,6 +14059,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -11818,19 +14105,19 @@ export LANGUAGE (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -11968,16 +14255,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -12026,7 +14313,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -12037,28 +14324,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -12079,8 +14354,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libpng $as_me 1.2.46, which was -generated by GNU Autoconf 2.65. Invocation command line was +This file was extended by libpng $as_me 1.6.37, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -12145,11 +14420,11 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libpng config.status 1.2.46 -configured by $0, generated by GNU Autoconf 2.65, +libpng config.status 1.6.37 +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -12167,11 +14442,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -12193,6 +14473,7 @@ do $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -12205,7 +14486,7 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -12214,7 +14495,7 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -12234,7 +14515,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -12258,7 +14539,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # -AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" +AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}" # The HP-UX ksh and POSIX shell print the target directory to stdout @@ -12268,137 +14549,167 @@ AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' -SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' -Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' -GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' -EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' -FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' -LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' -AS='`$ECHO "X$AS" | $Xsed -e "$delay_single_quote_subst"`' -DLLTOOL='`$ECHO "X$DLLTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' -macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' -macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' -enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' -pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' -enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' -host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' -host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' -host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' -build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' -build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' -build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' -NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' -LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' -max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' -ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' -exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' -lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' -lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' -lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' -reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' -reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' -deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' -file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' -AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' -AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' -STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' -RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' -old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' -CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' -compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' -GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' -SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' -ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' -MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' -lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' -lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' -need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' -DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' -NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' -LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' -OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' -libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' -shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' -extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' -enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' -export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' -old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' -archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' -module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' -with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' -allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' -inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' -link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' -fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' -always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' -export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' -exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' -prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' -file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' -variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' -need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' -need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' -version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' -runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' -shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' -libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' -library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' -soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' -postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' -finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' -hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' -enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' -old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' -striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' +SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' +Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' +GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' +EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' +FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' +SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' +ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' +LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' +macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' +macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' +AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' +DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' +enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' +enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' +pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' +shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' +PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' +host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' +host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' +host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' +build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' +build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' +build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' +NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' +LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' +ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' +exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' +lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' +lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' +lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' +reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' +file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' +want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' +sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' +AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' +archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' +STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' +RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' +lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' +CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' +compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' +GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' +lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' +nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' +lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' +lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' +objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' +need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' +MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' +LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' +OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' +libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' +module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' +postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' +need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' +version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' +runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' +libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' +soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' +install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' +finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' +configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' +configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' +old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' +striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$1 +_LTECHO_EOF' +} + # Quote evaled strings. for var in SED \ GREP \ EGREP \ FGREP \ +SHELL \ +ECHO \ LD \ +AS \ +DLLTOOL \ +OBJDUMP \ +PATH_SEPARATOR \ NM \ LN_S \ lt_SP2NL \ @@ -12406,8 +14717,12 @@ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ +file_magic_glob \ +want_nocaseglob \ +sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ +archiver_list_spec \ STRIP \ RANLIB \ CC \ @@ -12415,16 +14730,19 @@ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ -SHELL \ -ECHO \ +lt_cv_nm_interface \ +nm_file_list_spec \ +lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ -lt_prog_compiler_wl \ lt_prog_compiler_pic \ +lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ +MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ @@ -12438,9 +14756,7 @@ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ -hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ -fix_srcfile_path \ exclude_expsyms \ include_expsyms \ file_list_spec \ @@ -12448,12 +14764,13 @@ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ +install_override_mode \ finish_eval \ old_striplib \ striplib; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -12475,14 +14792,16 @@ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ +postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ -sys_lib_dlsearch_path_spec; do - case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in +configure_time_dlsearch_path \ +configure_time_lt_sys_library_path; do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) - eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" @@ -12490,26 +14809,17 @@ sys_lib_dlsearch_path_spec; do esac done -# Fix-up fallback echo if it was mangled by the above quoting rules. -case \$lt_ECHO in -*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` - ;; -esac - ac_aux_dir='$ac_aux_dir' -xsi_shell='$xsi_shell' -lt_shell_append='$lt_shell_append' -# See if we are running on zsh, and set the options which allow our +# See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. -if test -n "\${ZSH_VERSION+set}" ; then +if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' - TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' @@ -12528,10 +14838,10 @@ do "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - "libpng.pc") CONFIG_FILES="$CONFIG_FILES libpng.pc:scripts/libpng.pc-configure.in" ;; - "libpng-config") CONFIG_FILES="$CONFIG_FILES libpng-config:scripts/libpng-config.in" ;; + "libpng.pc") CONFIG_FILES="$CONFIG_FILES libpng.pc:libpng.pc.in" ;; + "libpng-config") CONFIG_FILES="$CONFIG_FILES libpng-config:libpng-config.in" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -12554,9 +14864,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -12564,12 +14875,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -12586,12 +14898,12 @@ if test "x$ac_cr" = x; then fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -12600,18 +14912,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -12619,7 +14931,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -12667,7 +14979,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -12699,21 +15011,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -12725,7 +15045,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -12737,11 +15057,11 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -12826,7 +15146,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -12839,7 +15159,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -12858,7 +15178,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -12867,7 +15187,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -12893,8 +15213,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -13030,23 +15350,24 @@ s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -13055,21 +15376,21 @@ which seems to be undefined. Please make sure it is defined." >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" @@ -13115,32 +15436,38 @@ $as_echo "$as_me: executing $ac_file commands" >&6;} case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { - # Autoconf 2.62 quotes --file arguments for eval, but not when files + # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. - case $CONFIG_FILES in - *\'*) eval set x "$CONFIG_FILES" ;; - *) set x $CONFIG_FILES ;; - esac + # TODO: see whether this extra hack can be removed once we start + # requiring Autoconf 2.70 or later. + case $CONFIG_FILES in #( + *\'*) : + eval set x "$CONFIG_FILES" ;; #( + *) : + set x $CONFIG_FILES ;; #( + *) : + ;; +esac shift - for mf + # Used to flag and report bootstrapping failures. + am_rc=0 + for am_mf do # Strip MF so we end up with the name of the file. - mf=`echo "$mf" | sed -e 's/:.*$//'` - # Check whether this is an Automake generated Makefile or not. - # We used to match only the files named `Makefile.in', but - # some people rename them; so instead we look at the file content. - # Grep'ing the first line is not enough: some people post-process - # each Makefile.in and add a new line on top of each file to say so. - # Grep'ing the whole file is not good either: AIX grep has a line + am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile which includes + # dependency-tracking related rules and includes. + # Grep'ing the whole file directly is not great: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. - if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then - dirpart=`$as_dirname -- "$mf" || -$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$mf" : 'X\(//\)[^/]' \| \ - X"$mf" : 'X\(//\)$' \| \ - X"$mf" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$mf" | + sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \ + || continue + am_dirpart=`$as_dirname -- "$am_mf" || +$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$am_mf" : 'X\(//\)[^/]' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$am_mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q @@ -13158,107 +15485,99 @@ $as_echo X"$mf" | q } s/.*/./; q'` - else - continue - fi - # Extract the definition of DEPDIR, am__include, and am__quote - # from the Makefile without running `make'. - DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` - test -z "$DEPDIR" && continue - am__include=`sed -n 's/^am__include = //p' < "$mf"` - test -z "am__include" && continue - am__quote=`sed -n 's/^am__quote = //p' < "$mf"` - # When using ansi2knr, U may be empty or an underscore; expand it - U=`sed -n 's/^U = //p' < "$mf"` - # Find all dependency output files, they are included files with - # $(DEPDIR) in their names. We invoke sed twice because it is the - # simplest approach to changing $(DEPDIR) to its actual value in the - # expansion. - for file in `sed -n " - s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ - sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do - # Make sure the directory exists. - test -f "$dirpart/$file" && continue - fdir=`$as_dirname -- "$file" || -$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$file" : 'X\(//\)[^/]' \| \ - X"$file" : 'X\(//\)$' \| \ - X"$file" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$file" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + am_filepart=`$as_basename -- "$am_mf" || +$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \ + X"$am_mf" : 'X\(//\)$' \| \ + X"$am_mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$am_mf" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } - /^X\(\/\/\)[^/].*/{ + /^X\/\(\/\/\)$/{ s//\1/ q } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ + /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` - as_dir=$dirpart/$fdir; as_fn_mkdir_p - # echo "creating $dirpart/$file" - echo '# dummy' > "$dirpart/$file" - done + { echo "$as_me:$LINENO: cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles" >&5 + (cd "$am_dirpart" \ + && sed -e '/# am--include-marker/d' "$am_filepart" \ + | $MAKE -f - am--depfiles) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } || am_rc=$? done + if test $am_rc -ne 0; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "Something went wrong bootstrapping makefile fragments + for automatic dependency tracking. Try re-running configure with the + '--disable-dependency-tracking' option to at least be able to build + the package (albeit without support for automatic dependency tracking). +See \`config.log' for more details" "$LINENO" 5; } + fi + { am_dirpart=; unset am_dirpart;} + { am_filepart=; unset am_filepart;} + { am_mf=; unset am_mf;} + { am_rc=; unset am_rc;} + rm -f conftest-deps.mk } ;; "libtool":C) - # See if we are running on zsh, and set the options which allow our + # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. - if test -n "${ZSH_VERSION+set}" ; then + if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi - cfgfile="${ofile}T" + cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL - -# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. -# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Generated automatically by $as_me ($PACKAGE) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, -# 2006, 2007, 2008 Free Software Foundation, Inc. -# Written by Gordon Matzigkeit, 1996 +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. # -# This file is part of GNU Libtool. -# -# GNU Libtool is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# As a special exception to the GNU General Public License, -# if you distribute this file as part of a program or library that -# is built using GNU Libtool, you may include this file under the -# same distribution terms that you use for the rest of that program. -# -# GNU Libtool is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with GNU Libtool; see the file COPYING. If not, a copy -# can be downloaded from http://www.gnu.org/licenses/gpl.html, or -# obtained by writing to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program. If not, see . # The names of the tagged configurations supported by this script. -available_tags="" +available_tags='' + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG @@ -13277,19 +15596,25 @@ EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP -# Assembler program. -AS=$AS +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL -# DLL creation program. -DLLTOOL=$DLLTOOL - -# Object dumper program. -OBJDUMP=$OBJDUMP +# An echo program that protects backslashes. +ECHO=$lt_ECHO # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision +# Assembler program. +AS=$lt_AS + +# DLL creation program. +DLLTOOL=$lt_DLLTOOL + +# Object dumper program. +OBJDUMP=$lt_OBJDUMP + # Whether or not to build shared libraries. build_libtool_libs=$enable_shared @@ -13302,6 +15627,12 @@ pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install +# Shared archive member basename,for filename based shared library versioning on AIX. +shared_archive_member_spec=$shared_archive_member_spec + +# The PATH separator for the build system. +PATH_SEPARATOR=$lt_PATH_SEPARATOR + # The host system. host_alias=$host_alias host=$host @@ -13336,20 +15667,36 @@ SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP -# How to create reloadable object files. -reload_flag=$lt_reload_flag -reload_cmds=$lt_reload_cmds +# convert \$build file names to \$host format. +to_host_file_cmd=$lt_cv_to_host_file_cmd + +# convert \$build files to toolchain format. +to_tool_file_cmd=$lt_cv_to_tool_file_cmd # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method -# Command to use when deplibs_check_method == "file_magic". +# Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd +# How to find potential files when deplibs_check_method = "file_magic". +file_magic_glob=$lt_file_magic_glob + +# Find potential files using nocaseglob when deplibs_check_method = "file_magic". +want_nocaseglob=$lt_want_nocaseglob + +# Command to associate shared and link libraries. +sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd + # The archiver. AR=$lt_AR + +# Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS +# How to feed a file listing to the archiver. +archiver_list_spec=$lt_archiver_list_spec + # A symbol stripping program. STRIP=$lt_STRIP @@ -13358,6 +15705,9 @@ RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds +# Whether to use a lock for old archive extraction. +lock_old_archive_extraction=$lock_old_archive_extraction + # A C compiler. LTCC=$lt_CC @@ -13370,27 +15720,39 @@ global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl +# Transform the output of nm into a list of symbols to manually relocate. +global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import + # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix +# The name lister interface. +nm_interface=$lt_lt_cv_nm_interface + +# Specify filename containing input files for \$NM. +nm_file_list_spec=$lt_nm_file_list_spec + +# The root where to search for dependent libraries,and where our libraries should be installed. +lt_sysroot=$lt_sysroot + +# Command to truncate a binary pipe. +lt_truncate_bin=$lt_lt_cv_truncate_bin + # The name of the directory that contains temporary libtool files. objdir=$objdir -# Shell to use when invoking shell scripts. -SHELL=$lt_SHELL - -# An echo program that does not interpret backslashes. -ECHO=$lt_ECHO - # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks +# Manifest tool. +MANIFEST_TOOL=$lt_MANIFEST_TOOL + # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL @@ -13447,6 +15809,9 @@ library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec +# Permission mode override for installation of shared libraries. +install_override_mode=$lt_install_override_mode + # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds @@ -13466,8 +15831,11 @@ hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec -# Run-time system search path for libraries. -sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec +# Detected run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path + +# Explicit LT_SYS_LIBRARY_PATH set during ./configure time. +configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen @@ -13486,6 +15854,10 @@ striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds @@ -13498,12 +15870,12 @@ with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag -# How to pass a linker flag through the compiler. -wl=$lt_lt_prog_compiler_wl - # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static @@ -13553,20 +15925,16 @@ no_undefined_flag=$lt_no_undefined_flag # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec -# If ld is used when linking, flag to hardcode \$libdir into a binary -# during linking. This must work even if \$libdir does not exist. -hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld - # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct -# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is -# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute @@ -13590,9 +15958,6 @@ inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs -# Fix the shell variable \$srcfile for the compiler. -fix_srcfile_path=$lt_fix_srcfile_path - # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols @@ -13608,6 +15973,9 @@ include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds +# Commands necessary for finishing linking programs. +postlink_cmds=$lt_postlink_cmds + # Specify filename containing input files. file_list_spec=$lt_file_list_spec @@ -13616,6 +15984,65 @@ hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x$2 in + x) + ;; + *:) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" + ;; + x:*) + eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" + ;; + *) + eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" + ;; + esac +} + + +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in $*""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} + + +# ### END FUNCTIONS SHARED WITH CONFIGURE + _LT_EOF case $host_os in @@ -13624,7 +16051,7 @@ _LT_EOF # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. -if test "X${COLLECT_NAMES+set}" != Xset; then +if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi @@ -13633,219 +16060,17 @@ _LT_EOF esac -ltmain="$ac_aux_dir/ltmain.sh" +ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? - sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) - case $xsi_shell in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac -} - -# func_basename file -func_basename () -{ - func_basename_result="${1##*/}" -} - -# func_dirname_and_basename file append nondir_replacement -# perform func_basename and func_dirname in a single function -# call: -# dirname: Compute the dirname of FILE. If nonempty, -# add APPEND to the result, otherwise set result -# to NONDIR_REPLACEMENT. -# value returned in "$func_dirname_result" -# basename: Compute filename of FILE. -# value retuned in "$func_basename_result" -# Implementation must be kept synchronized with func_dirname -# and func_basename. For efficiency, we do not delegate to -# those functions but instead duplicate the functionality here. -func_dirname_and_basename () -{ - case ${1} in - */*) func_dirname_result="${1%/*}${2}" ;; - * ) func_dirname_result="${3}" ;; - esac - func_basename_result="${1##*/}" -} - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -func_stripname () -{ - # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are - # positional parameters, so assign one to ordinary parameter first. - func_stripname_result=${3} - func_stripname_result=${func_stripname_result#"${1}"} - func_stripname_result=${func_stripname_result%"${2}"} -} - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=${1%%=*} - func_opt_split_arg=${1#*=} -} - -# func_lo2o object -func_lo2o () -{ - case ${1} in - *.lo) func_lo2o_result=${1%.lo}.${objext} ;; - *) func_lo2o_result=${1} ;; - esac -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=${1%.*}.lo -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=$(( $* )) -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=${#1} -} - -_LT_EOF - ;; - *) # Bourne compatible functions. - cat << \_LT_EOF >> "$cfgfile" - -# func_dirname file append nondir_replacement -# Compute the dirname of FILE. If nonempty, add APPEND to the result, -# otherwise set result to NONDIR_REPLACEMENT. -func_dirname () -{ - # Extract subdirectory from the argument. - func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` - if test "X$func_dirname_result" = "X${1}"; then - func_dirname_result="${3}" - else - func_dirname_result="$func_dirname_result${2}" - fi -} - -# func_basename file -func_basename () -{ - func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` -} - - -# func_stripname prefix suffix name -# strip PREFIX and SUFFIX off of NAME. -# PREFIX and SUFFIX must not contain globbing or regex special -# characters, hashes, percent signs, but SUFFIX may contain a leading -# dot (in which case that matches only a dot). -# func_strip_suffix prefix name -func_stripname () -{ - case ${2} in - .*) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; - *) func_stripname_result=`$ECHO "X${3}" \ - | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; - esac -} - -# sed scripts: -my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' -my_sed_long_arg='1s/^-[^=]*=//' - -# func_opt_split -func_opt_split () -{ - func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` - func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` -} - -# func_lo2o object -func_lo2o () -{ - func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` -} - -# func_xform libobj-or-source -func_xform () -{ - func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` -} - -# func_arith arithmetic-term... -func_arith () -{ - func_arith_result=`expr "$@"` -} - -# func_len string -# STRING may not start with a hyphen. -func_len () -{ - func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` -} - -_LT_EOF -esac - -case $lt_shell_append in - yes) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1+=\$2" -} -_LT_EOF - ;; - *) - cat << \_LT_EOF >> "$cfgfile" - -# func_append var value -# Append VALUE to the end of shell variable VAR. -func_append () -{ - eval "$1=\$$1\$2" -} - -_LT_EOF - ;; - esac - - - sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ - || (rm -f "$cfgfile"; exit 1) - - mv -f "$cfgfile" "$ofile" || + mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" @@ -13861,7 +16086,7 @@ _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -13882,7 +16107,7 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 diff --git a/libs/libpng-src/configure.ac b/libs/libpng-src/configure.ac index bfdbf7a0c..52dba94b4 100644 --- a/libs/libpng-src/configure.ac +++ b/libs/libpng-src/configure.ac @@ -1,5 +1,12 @@ # configure.ac +# Copyright (c) 2018 Cosmin Truta +# Copyright (c) 2004-2016 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + dnl Process this file with autoconf to produce a configure script. dnl dnl Minor upgrades (compatible ABI): increment the package version @@ -14,72 +21,178 @@ dnl Makefile.am to upgrade the package name. dnl This is here to prevent earlier autoconf from being used, it dnl should not be necessary to regenerate configure if the time dnl stamps are correct -AC_PREREQ(2.59) +AC_PREREQ([2.68]) dnl Version number stuff here: -AC_INIT([libpng], [1.2.46], [png-mng-implement@lists.sourceforge.net]) -AM_INIT_AUTOMAKE -dnl stop configure from automagically running automake +AC_INIT([libpng],[1.6.37],[png-mng-implement@lists.sourceforge.net]) +AC_CONFIG_MACRO_DIR([scripts]) + +# libpng does not follow GNU file name conventions (hence 'foreign') +# color-tests requires automake 1.11 or later +# silent-rules requires automake 1.11 or later +# dist-xz requires automake 1.11 or later +# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1 +# 1.13 is required for parallel tests +AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects]) +# The following line causes --disable-maintainer-mode to be the default to +# configure. This is necessary because libpng distributions cannot rely on the +# time stamps of the autotools generated files being correct AM_MAINTAINER_MODE -PNGLIB_VERSION=1.2.46 +dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later +dnl version; aclocal.m4 will generate a failure if you use a prior version of +dnl automake, so the following is not necessary (and is not defined anyway): +dnl AM_PREREQ([1.11.2]) +dnl stop configure from automagically running automake + +PNGLIB_VERSION=1.6.37 PNGLIB_MAJOR=1 -PNGLIB_MINOR=2 -PNGLIB_RELEASE=46 +PNGLIB_MINOR=6 +PNGLIB_RELEASE=37 dnl End of version number stuff AC_CONFIG_SRCDIR([pngget.c]) -AM_CONFIG_HEADER(config.h) +AC_CONFIG_HEADERS([config.h]) # Checks for programs. +AC_LANG([C]) AC_PROG_CC -AC_PROG_LD +AM_PROG_AS +LT_PATH_LD AC_PROG_CPP -AC_CHECK_TOOL(SED, sed, :) -AC_LIBTOOL_WIN32_DLL +AC_PROG_AWK AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET -AC_PROG_LIBTOOL + +dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any +dnl compatible later version may be used +LT_INIT([win32-dll]) +LT_PREREQ([2.4.2]) + +# Some awks crash when confronted with pnglibconf.dfa, do a test run now +# to make sure this doesn't happen +AC_MSG_CHECKING([that AWK works]) +if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\ + ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\ + ${srcdir}/pngusr.dfa 1>&2 +then + AC_MSG_RESULT([ok]) +else + AC_MSG_FAILURE([failed], 1) +fi + +# This is a remnant of the old cc -E validation, where it may have been +# necessary to use a different preprocessor for .dfn files +DFNCPP="$CPP" +AC_SUBST(DFNCPP) + +# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it +# checks the compiler with a program that generates a warning), add the +# following option to deal with this +AC_ARG_VAR(PNG_COPTS, + [additional flags for the C compiler, use this for options that would] + [cause configure itself to fail]) +AC_ARG_ENABLE(werror, + AS_HELP_STRING([[[--enable-werror[=OPT]]]], + [Pass -Werror or the given argument to the compiler if it is supported]), + [test "$enable_werror" = "yes" && enable_werror="-Werror" + if test "$enable_werror" != "no"; then + sav_CFLAGS="$CFLAGS" + CFLAGS="$enable_werror $CFLAGS" + AC_MSG_CHECKING([if the compiler allows $enable_werror]) + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([ + [int main(int argc, char **argv){] + [return argv[argc-1][0];] + [}]])], + AC_MSG_RESULT(yes) + PNG_COPTS="$PNG_COPTS $enable_werror", + AC_MSG_RESULT(no)) + CFLAGS="$sav_CFLAGS" + fi],) + +# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89 +# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1 +# This is incompatible with the new default mode, so we test for that and force the +# "-std=c89" compiler option: +AC_MSG_CHECKING([if we need to force back C standard to C89]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ + [#define _POSIX_SOURCE 1] + [#include ] + ])], + AC_MSG_RESULT(no),[ + if test "x$GCC" != "xyes"; then + AC_MSG_ERROR( + [Forcing back to C89 is required but the flags are only known for GCC]) + fi + AC_MSG_RESULT(yes) + CFLAGS="$CFLAGS -std=c89" +]) # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T AC_STRUCT_TM +AC_C_RESTRICT # Checks for library functions. AC_FUNC_STRTOD -AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc])) -AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) ) -AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed])) +AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) ) -case $host_os in - aix*) - LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG -D_ALL_SOURCE;; - *) - LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG;; -esac -AC_MSG_CHECKING( - [if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE]) -AC_TRY_COMPILE( - [#include "$srcdir/pnggccrd.c"], - [return 0;], - AC_MSG_RESULT(yes) - LIBPNG_NO_MMX="", - AC_MSG_RESULT(no) - LIBPNG_NO_MMX=-DPNG_NO_MMX_CODE) -LIBPNG_DEFINES=$LIBPNG_DEFINES\ $LIBPNG_NO_MMX -AC_SUBST(LIBPNG_DEFINES) -AC_SUBST(LIBPNG_NO_MMX) +# Some later POSIX 1003.1 functions are required for test programs, failure here +# is soft (the corresponding test program is not built). +AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])]) +AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"]) + +AC_ARG_WITH(zlib-prefix, + AS_HELP_STRING([[[--with-zlib-prefix]]], + [prefix that may have been used in installed zlib]), + [ZPREFIX=${withval}], + [ZPREFIX='z_']) +AC_CHECK_LIB(z, zlibVersion, , + AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed))) + +# The following is for pngvalid, to ensure it catches FP errors even on +# platforms that don't enable FP exceptions, the function appears in the math +# library (typically), it's not an error if it is not found. +AC_CHECK_LIB([m], [feenableexcept]) +AC_CHECK_FUNCS([feenableexcept]) + +AC_MSG_CHECKING([if using Solaris linker]) +SLD=`$LD --version 2>&1 | grep Solaris` +if test "$SLD"; then + have_solaris_ld=yes + AC_MSG_RESULT(yes) +else + have_solaris_ld=no + AC_MSG_RESULT(no) +fi +AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes") AC_MSG_CHECKING([if libraries can be versioned]) -GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` +# Special case for PE/COFF platforms: ld reports +# support for version-script, but doesn't actually +# DO anything with it. +case $host in +*cygwin* | *mingw32* | *interix* ) + have_ld_version_script=no + AC_MSG_RESULT(no) +;; +* ) + +if test "$have_solaris_ld" = "yes"; then + GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'` +else + GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script` +fi + if test "$GLD"; then have_ld_version_script=yes AC_MSG_RESULT(yes) @@ -88,14 +201,17 @@ else AC_MSG_RESULT(no) AC_MSG_WARN(*** You have not enabled versioned symbols.) fi +;; +esac + AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") if test "$have_ld_version_script" = "yes"; then AC_MSG_CHECKING([for symbol prefix]) SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \ - | ${CPP-${CC-gcc} -E} - 2>&1 \ - | ${EGREP-grep} "^PREFIX=" \ - | ${SED-sed} "s:^PREFIX=::"` + | ${CPP-${CC-gcc} -E} - 2>&1 \ + | ${EGREP-grep} "^PREFIX=" \ + | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"` AC_SUBST(SYMBOL_PREFIX) AC_MSG_RESULT($SYMBOL_PREFIX) fi @@ -109,45 +225,308 @@ AC_SUBST(PNGLIB_RELEASE) # Additional arguments (and substitutions) # Allow the pkg-config directory to be set AC_ARG_WITH(pkgconfigdir, - AC_HELP_STRING([--with-pkgconfigdir], - [Use the specified pkgconfig dir (default is libdir/pkgconfig)]), - [pkgconfigdir=${withval}], - [pkgconfigdir='${libdir}/pkgconfig']) + AS_HELP_STRING([[[--with-pkgconfigdir]]], + [Use the specified pkgconfig dir (default is libdir/pkgconfig)]), + [pkgconfigdir=${withval}], + [pkgconfigdir='${libdir}/pkgconfig']) AC_SUBST([pkgconfigdir]) -AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}]) +AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]]) # Make the *-config binary config scripts optional AC_ARG_WITH(binconfigs, - AC_HELP_STRING([--with-binconfigs], - [Generate shell libpng-config scripts as well as pkg-config data] - [@<:@default=yes@:>@]), - [if test "${withval}" = no; then - binconfigs= - AC_MSG_NOTICE([libpng-config scripts will not be built]) - else - binconfigs='${binconfigs}' - fi], - [binconfigs='${binconfigs}']) + AS_HELP_STRING([[[--with-binconfigs]]], + [Generate shell libpng-config scripts as well as pkg-config data] + [@<:@default=yes@:>@]), + [if test "${withval}" = no; then + binconfigs= + AC_MSG_NOTICE([[libpng-config scripts will not be built]]) + else + binconfigs='${binconfigs}' + fi], + [binconfigs='${binconfigs}']) AC_SUBST([binconfigs]) -# Allow the old version number library, libpng.so, to be removed from -# the build -AC_ARG_WITH(libpng-compat, - AC_HELP_STRING([--with-libpng-compat], - [Generate the obsolete libpng.so library @<:@default=yes@:>@]), - [if test "${withval}" = no; then - compatlib= - AC_MSG_NOTICE([libpng.so will not be built]) - else - compatlib=libpng.la - fi], - [compatlib=libpng.la]) -AC_SUBST([compatlib]) +# Support for prefixes to the API function names; this will generate defines +# at the start of the build to rename exported library functions +AC_ARG_WITH(libpng-prefix, + AS_HELP_STRING([[[--with-libpng-prefix]]], + [prefix libpng exported function (API) names with the given value]), + [if test "${withval:-no}" != "no"; then + AC_SUBST([PNG_PREFIX], [${withval}]) + fi]) +AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"]) + +# Control over what links are made for installed files. Versioned files are +# always installed, when the following options are turned on corresponding +# unversioned links are also created (normally as symbolic links): +AC_ARG_ENABLE([unversioned-links], + AS_HELP_STRING([[[--enable-unversioned-links]]], + [Installed libpng header files are placed in a versioned subdirectory] + [and installed libpng library (including DLL) files are versioned.] + [If this option is enabled unversioned links will be created pointing to] + [the corresponding installed files. If you use libpng.pc or] + [libpng-config for all builds you do not need these links, but if you] + [compile programs directly they will typically #include and] + [link with -lpng; in that case you need the links.] + [The links can be installed manually using 'make install-header-links'] + [and 'make install-library-links' and can be removed using the] + [corresponding uninstall- targets. If you do enable this option every] + [libpng 'make install' will recreate the links to point to the just] + [installed version of libpng. The default is to create the links;] + [use --disable-unversioned-links to change this])) + +# The AM_CONDITIONAL test is written so that the default is enabled; +# --disable-unversioned-links must be given to turn the option off. +AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"]) + +AC_ARG_ENABLE([unversioned-libpng-pc], + AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]], + [Install the configuration file 'libpng.pc' as a link to the versioned] + [version. This is done by default - use --disable-unversioned-libpng-pc] + [to change this.])) +AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC], + [test "$enable_unversioned_libpng_pc" != "no"]) + +AC_ARG_ENABLE([unversioned-libpng-config], + AS_HELP_STRING([[[--enable-unversioned-libpng-config]]], + [Install the configuration file 'libpng-config' as a link to the] + [versioned version. This is done by default - use] + [--disable-unversioned-libpng-config to change this.])) +AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG], + [test "$enable_unversioned_libpng_config" != "no"]) + +# HOST SPECIFIC OPTIONS +# ===================== +# +# DEFAULT +# ======= +# +AC_ARG_ENABLE([hardware-optimizations], + AS_HELP_STRING([[[--enable-hardware-optimizations]]], + [Enable hardware optimizations: =no/off, yes/on:]), + [case "$enableval" in + no|off) + # disable hardware optimization on all systems: + enable_arm_neon=no + AC_DEFINE([PNG_ARM_NEON_OPT], [0], + [Disable ARM_NEON optimizations]) + enable_mips_msa=no + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], + [Disable MIPS_MSA optimizations]) + enable_powerpc_vsx=no + AC_DEFINE([PNG_POWERPC_VSX_OPT], [0], + [Disable POWERPC VSX optimizations]) + enable_intel_sse=no + AC_DEFINE([PNG_INTEL_SSE_OPT], [0], + [Disable INTEL_SSE optimizations]) + ;; + *) + # allow enabling hardware optimization on any system: + case "$host_cpu" in + arm*|aarch64*) + enable_arm_neon=yes + AC_DEFINE([PNG_ARM_NEON_OPT], [0], + [Enable ARM_NEON optimizations]) + ;; + mipsel*|mips64el*) + enable_mips_msa=yes + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], + [Enable MIPS_MSA optimizations]) + ;; + i?86|x86_64) + enable_intel_sse=yes + AC_DEFINE([PNG_INTEL_SSE_OPT], [1], + [Enable Intel SSE optimizations]) + ;; + powerpc*|ppc64*) + enable_powerpc_vsx=yes + AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], + [Enable POWERPC VSX optimizations]) + ;; + esac + ;; + esac]) + +# ARM +# === +# +# ARM NEON (SIMD) support. + +AC_ARG_ENABLE([arm-neon], + AS_HELP_STRING([[[--enable-arm-neon]]], + [Enable ARM NEON optimizations: =no/off, check, api, yes/on:] + [no/off: disable the optimizations; check: use internal checking code] + [(deprecated and poorly supported); api: disable by default, enable by] + [a call to png_set_option; yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __ARM_NEON__ systems: + AC_DEFINE([PNG_ARM_NEON_OPT], [0], + [Disable ARM Neon optimizations]) + # Prevent inclusion of the assembler files below: + enable_arm_neon=no;; + check) + AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [], + [Check for ARM Neon support at run-time]);; + api) + AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [], + [Turn on ARM Neon optimizations at run-time]);; + yes|on) + AC_DEFINE([PNG_ARM_NEON_OPT], [2], + [Enable ARM Neon optimizations]) + AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass -mfpu=neon] + [to the compiler.]);; + *) + AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value]) + esac]) + +# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or +# where ARM optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'arm*') + +AM_CONDITIONAL([PNG_ARM_NEON], + [test "$enable_arm_neon" != 'no' && + case "$host_cpu" in + arm*|aarch64*) :;; + *) test "$enable_arm_neon" != '';; + esac]) + +# MIPS +# === +# +# MIPS MSA (SIMD) support. + +AC_ARG_ENABLE([mips-msa], + AS_HELP_STRING([[[--enable-mips-msa]]], + [Enable MIPS MSA optimizations: =no/off, check, api, yes/on:] + [no/off: disable the optimizations; check: use internal checking code] + [(deprecated and poorly supported); api: disable by default, enable by] + [a call to png_set_option; yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __mips_msa systems: + AC_DEFINE([PNG_MIPS_MSA_OPT], [0], + [Disable MIPS MSA optimizations]) + # Prevent inclusion of the assembler files below: + enable_mips_msa=no;; + check) + AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [], + [Check for MIPS MSA support at run-time]);; + api) + AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [], + [Turn on MIPS MSA optimizations at run-time]);; + yes|on) + AC_DEFINE([PNG_MIPS_MSA_OPT], [2], + [Enable MIPS MSA optimizations]) + AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass '-mmsa -mfp64'] + [to the compiler.]);; + *) + AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value]) + esac]) + +# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or +# where MIPS optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'mips*') + +AM_CONDITIONAL([PNG_MIPS_MSA], + [test "$enable_mips_msa" != 'no' && + case "$host_cpu" in + mipsel*|mips64el*) :;; + esac]) + +# INTEL +# ===== +# +# INTEL SSE (SIMD) support. + +AC_ARG_ENABLE([intel-sse], + AS_HELP_STRING([[[--enable-intel-sse]]], + [Enable Intel SSE optimizations: =no/off, yes/on:] + [no/off: disable the optimizations;] + [yes/on: enable the optimizations.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling: + AC_DEFINE([PNG_INTEL_SSE_OPT], [0], + [Disable Intel SSE optimizations]) + # Prevent inclusion of the assembler files below: + enable_intel_sse=no;; + yes|on) + AC_DEFINE([PNG_INTEL_SSE_OPT], [1], + [Enable Intel SSE optimizations]);; + *) + AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value]) + esac]) + +# Add Intel specific files to all builds where the host_cpu is Intel ('x86*') +# or where Intel optimizations were explicitly requested (this allows a +# fallback if a future host CPU does not match 'x86*') +AM_CONDITIONAL([PNG_INTEL_SSE], + [test "$enable_intel_sse" != 'no' && + case "$host_cpu" in + i?86|x86_64) :;; + *) test "$enable_intel_sse" != '';; + esac]) + +# PowerPC +# === +# +# PowerPC VSX (SIMD) support. + +AC_ARG_ENABLE([powerpc-vsx], +AS_HELP_STRING([[[--enable-powerpc-vsx]]], + [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:] + [no/off: disable the optimizations; check: use internal checking code] + [api: disable by default, enable by a call to png_set_option] + [yes/on: turn on unconditionally.] + [If not specified: determined by the compiler.]), + [case "$enableval" in + no|off) + # disable the default enabling on __ppc64__ systems: + AC_DEFINE([PNG_POWERPC_VSX_OPT], [0], + [Disable POWERPC VSX optimizations]) + # Prevent inclusion of the platform specific files below: + enable_powerpc_vsx=no;; + check) + AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [], + [Check for POWERPC VSX support at run-time]) + AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file] + [for the list of supported OSes.]);; + api) + AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [], + [Turn on POWERPC VSX optimizations at run-time]);; + yes|on) + AC_DEFINE([PNG_POWERPC_VSX_OPT], [2], + [Enable POWERPC VSX optimizations]) + AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if] + [you want the optimizations unconditionally pass '-maltivec -mvsx'] + [or '-mcpu=power8'to the compiler.]);; + *) + AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value]) + esac]) + +# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or +# where POWERPC optimizations were explicitly requested (this allows a fallback if a +# future host CPU does not match 'powerpc*') + +AM_CONDITIONAL([PNG_POWERPC_VSX], + [test "$enable_powerpc_vsx" != 'no' && + case "$host_cpu" in + powerpc*|ppc64*) :;; + esac]) + + +AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) # Config files, substituting as above -AC_CONFIG_FILES([Makefile libpng.pc:scripts/libpng.pc-configure.in]) -AC_CONFIG_FILES([libpng-config:scripts/libpng-config.in], - [chmod +x libpng-config]) +AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) +AC_CONFIG_FILES([libpng-config:libpng-config.in], + [chmod +x libpng-config]) AC_OUTPUT diff --git a/libs/libpng-src/contrib/README.txt b/libs/libpng-src/contrib/README.txt new file mode 100644 index 000000000..97963c6d5 --- /dev/null +++ b/libs/libpng-src/contrib/README.txt @@ -0,0 +1,5 @@ + +This "contrib" directory contains contributions which are not necessarily under +the libpng license, although all are open source. They are not part of +libpng proper and are not used for building the library, although some are used +for testing the library via "make check". diff --git a/libs/libpng-src/contrib/arm-neon/README b/libs/libpng-src/contrib/arm-neon/README new file mode 100644 index 000000000..b4248cf28 --- /dev/null +++ b/libs/libpng-src/contrib/arm-neon/README @@ -0,0 +1,83 @@ +OPERATING SYSTEM SPECIFIC ARM NEON DETECTION +-------------------------------------------- + +Detection of the ability to execute ARM NEON on an ARM processor requires +operating system support. (The information is not available in user mode.) + +HOW TO USE THIS +--------------- + +This directory contains C code fragments that can be included in arm/arm_init.c +by setting the macro PNG_ARM_NEON_FILE to the file name in "" or <> at build +time. This setting is not recorded in pnglibconf.h and can be changed simply by +rebuilding arm/arm_init.o with the required macro definition. + +For any of this code to be used the ARM NEON code must be enabled and run time +checks must be supported. I.e.: + +#if PNG_ARM_NEON_OPT > 0 +#ifdef PNG_ARM_NEON_CHECK_SUPPORTED + +This is done in a 'configure' build by passing configure the argument: + + --enable-arm-neon=check + +Apart from the basic Linux implementation in contrib/arm-neon/linux.c this code +is unsupported. That means that it is not even compiled on a regular basis and +may be broken in any given minor release. + +FILE FORMAT +----------- + +Each file documents its testing status as of the last time it was tested (which +may have been a long time ago): + +STATUS: one of: + SUPPORTED: This indicates that the file is included in the regularly + performed test builds and bugs are fixed when discovered. + COMPILED: This indicates that the code did compile at least once. See the + more detailed description for the extent to which the result was + successful. + TESTED: This means the code was fully compiled into the libpng test programs + and these were run at least once. + +BUG REPORTS: an email address to which to send reports of problems + +The file is a fragment of C code. It should not define any 'extern' symbols; +everything should be static. It must define the function: + +static int png_have_neon(png_structp png_ptr); + +That function must return 1 if ARM NEON instructions are supported, 0 if not. +It must not execute png_error unless it detects a bug. A png_error will prevent +the reading of the PNG and in the future, writing too. + +BUG REPORTS +----------- + +If you mail a bug report for any file that is not SUPPORTED there may only be +limited response. Consider fixing it and sending a patch to fix the problem - +this is more likely to result in action. + +CONTRIBUTIONS +------------- + +You may send contributions of new implementations to +png-mng-implement@sourceforge.net. Please write code in strict C90 C where +possible. Obviously OS dependencies are to be expected. If you submit code you +must have the authors permission and it must have a license that is acceptable +to the current maintainer; in particular that license must permit modification +and redistribution. + +Please try to make the contribution a single file and give the file a clear and +unambiguous name that identifies the target OS. If multiple files really are +required put them all in a sub-directory. + +You must also be prepared to handle bug reports from users of the code, either +by joining the png-mng-implement mailing list or by providing an email for the +"BUG REPORTS" entry or both. Please make sure that the header of the file +contains the STATUS and BUG REPORTS fields as above. + +Please list the OS requirements as precisely as possible. Ideally you should +also list the environment in which the code has been tested and certainly list +any environments where you suspect it might not work. diff --git a/libs/libpng-src/contrib/arm-neon/android-ndk.c b/libs/libpng-src/contrib/arm-neon/android-ndk.c new file mode 100644 index 000000000..fb3a4898d --- /dev/null +++ b/libs/libpng-src/contrib/arm-neon/android-ndk.c @@ -0,0 +1,39 @@ +/* contrib/arm-neon/android-ndk.c + * + * Copyright (c) 2014 Glenn Randers-Pehrson + * Written by John Bowler, 2014. + * Last changed in libpng 1.6.10 [March 6, 2014] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * SEE contrib/arm-neon/README before reporting bugs + * + * STATUS: COMPILED, UNTESTED + * BUG REPORTS: png-mng-implement@sourceforge.net + * + * png_have_neon implemented for the Android NDK, see: + * + * Documentation: + * http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html + * https://code.google.com/p/android/issues/detail?id=49065 + * + * NOTE: this requires that libpng is built against the Android NDK and linked + * with an implementation of the Android ARM 'cpu-features' library. The code + * has been compiled only, not linked: no version of the library has been found, + * only the header files exist in the NDK. + */ +#include + +static int +png_have_neon(png_structp png_ptr) +{ + /* This is a whole lot easier than the linux code, however it is probably + * implemented as below, therefore it is better to cache the result (these + * function calls may be slow!) + */ + PNG_UNUSED(png_ptr) + return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM && + (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; +} diff --git a/libs/libpng-src/contrib/arm-neon/linux-auxv.c b/libs/libpng-src/contrib/arm-neon/linux-auxv.c new file mode 100644 index 000000000..4d26bd3b3 --- /dev/null +++ b/libs/libpng-src/contrib/arm-neon/linux-auxv.c @@ -0,0 +1,120 @@ +/* contrib/arm-neon/linux-auxv.c + * + * Copyright (c) 2014 Glenn Randers-Pehrson + * Written by Mans Rullgard, 2011. + * Last changed in libpng 1.6.10 [March 6, 2014] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * SEE contrib/arm-neon/README before reporting bugs + * + * STATUS: COMPILED, TESTED + * BUG REPORTS: png-mng-implement@sourceforge.net + * + * png_have_neon implemented for Linux versions which allow access to + * /proc/self/auxv. This is probably faster, cleaner and safer than the code to + * read /proc/cpuinfo in contrib/arm-neon/linux, however it is yet another piece + * of potentially untested code and has more complex dependencies than the code + * to read cpuinfo. + * + * This generic __linux__ implementation requires reading /proc/self/auxv and + * looking at each element for one that records NEON capabilities. + */ +#include /* for POSIX 1003.1 */ +#include /* for EINTR */ + +#include +#include +#include +#include +#include + +/* A read call may be interrupted, in which case it returns -1 and sets errno to + * EINTR if nothing was done, otherwise (if something was done) a partial read + * may result. + */ +static size_t +safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes) +{ + size_t ntotal = 0; + char *buffer = png_voidcast(char*, buffer_in); + + while (nbytes > 0) + { + unsigned int nread; + int iread; + + /* Passing nread > INT_MAX to read is implementation defined in POSIX + * 1003.1, therefore despite the unsigned argument portable code must + * limit the value to INT_MAX! + */ + if (nbytes > INT_MAX) + nread = INT_MAX; + + else + nread = (unsigned int)/*SAFE*/nbytes; + + iread = read(fd, buffer, nread); + + if (iread == -1) + { + /* This is the devil in the details, a read can terminate early with 0 + * bytes read because of EINTR, yet it still returns -1 otherwise end + * of file cannot be distinguished. + */ + if (errno != EINTR) + { + png_warning(png_ptr, "/proc read failed"); + return 0; /* I.e., a permanent failure */ + } + } + + else if (iread < 0) + { + /* Not a valid 'read' result: */ + png_warning(png_ptr, "OS /proc read bug"); + return 0; + } + + else if (iread > 0) + { + /* Continue reading until a permanent failure, or EOF */ + buffer += iread; + nbytes -= (unsigned int)/*SAFE*/iread; + ntotal += (unsigned int)/*SAFE*/iread; + } + + else + return ntotal; + } + + return ntotal; /* nbytes == 0 */ +} + +static int +png_have_neon(png_structp png_ptr) +{ + int fd = open("/proc/self/auxv", O_RDONLY); + Elf32_auxv_t aux; + + /* Failsafe: failure to open means no NEON */ + if (fd == -1) + { + png_warning(png_ptr, "/proc/self/auxv open failed"); + return 0; + } + + while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux) + { + if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0) + { + close(fd); + return 1; + } + } + + close(fd); + return 0; +} diff --git a/libs/libpng-src/contrib/arm-neon/linux.c b/libs/libpng-src/contrib/arm-neon/linux.c new file mode 100644 index 000000000..a9bc360dd --- /dev/null +++ b/libs/libpng-src/contrib/arm-neon/linux.c @@ -0,0 +1,161 @@ +/* contrib/arm-neon/linux.c + * + * Last changed in libpng 1.6.31 [July 27, 2017] + * Copyright (c) 2014, 2017 Glenn Randers-Pehrson + * Written by John Bowler, 2014, 2017. + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * SEE contrib/arm-neon/README before reporting bugs + * + * STATUS: SUPPORTED + * BUG REPORTS: png-mng-implement@sourceforge.net + * + * png_have_neon implemented for Linux by reading the widely available + * pseudo-file /proc/cpuinfo. + * + * This code is strict ANSI-C and is probably moderately portable; it does + * however use and it assumes that /proc/cpuinfo is never localized. + */ +#include + +static int +png_have_neon(png_structp png_ptr) +{ + FILE *f = fopen("/proc/cpuinfo", "rb"); + + if (f != NULL) + { + /* This is a simple state machine which reads the input byte-by-byte until + * it gets a match on the 'neon' feature or reaches the end of the stream. + */ + static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 }; + static const char ch_neon[] = { 78, 69, 79, 78 }; + + enum + { + StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine + } state; + int counter; + + for (state=StartLine, counter=0;;) + { + int ch = fgetc(f); + + if (ch == EOF) + { + /* EOF means error or end-of-file, return false; neon at EOF is + * assumed to be a mistake. + */ + fclose(f); + return 0; + } + + switch (state) + { + case StartLine: + /* Match spaces at the start of line */ + if (ch <= 32) /* skip control characters and space */ + break; + + counter=0; + state = Feature; + /* FALLTHROUGH */ + + case Feature: + /* Match 'FEATURE', ASCII case insensitive. */ + if ((ch & ~0x20) == ch_feature[counter]) + { + if (++counter == (sizeof ch_feature)) + state = Colon; + break; + } + + /* did not match 'feature' */ + state = SkipLine; + /* FALLTHROUGH */ + + case SkipLine: + skipLine: + /* Skip everything until we see linefeed or carriage return */ + if (ch != 10 && ch != 13) + break; + + state = StartLine; + break; + + case Colon: + /* Match any number of space or tab followed by ':' */ + if (ch == 32 || ch == 9) + break; + + if (ch == 58) /* i.e. ':' */ + { + state = StartTag; + break; + } + + /* Either a bad line format or a 'feature' prefix followed by + * other characters. + */ + state = SkipLine; + goto skipLine; + + case StartTag: + /* Skip space characters before a tag */ + if (ch == 32 || ch == 9) + break; + + state = Neon; + counter = 0; + /* FALLTHROUGH */ + + case Neon: + /* Look for 'neon' tag */ + if ((ch & ~0x20) == ch_neon[counter]) + { + if (++counter == (sizeof ch_neon)) + state = HaveNeon; + break; + } + + state = SkipTag; + /* FALLTHROUGH */ + + case SkipTag: + /* Skip non-space characters */ + if (ch == 10 || ch == 13) + state = StartLine; + + else if (ch == 32 || ch == 9) + state = StartTag; + break; + + case HaveNeon: + /* Have seen a 'neon' prefix, but there must be a space or new + * line character to terminate it. + */ + if (ch == 10 || ch == 13 || ch == 32 || ch == 9) + { + fclose(f); + return 1; + } + + state = SkipTag; + break; + + default: + png_error(png_ptr, "png_have_neon: internal error (bug)"); + } + } + } + +#ifdef PNG_WARNINGS_SUPPORTED + else + png_warning(png_ptr, "/proc/cpuinfo open failed"); +#endif + + return 0; +} diff --git a/libs/libpng-src/contrib/conftest/README b/libs/libpng-src/contrib/conftest/README new file mode 100644 index 000000000..0f472791f --- /dev/null +++ b/libs/libpng-src/contrib/conftest/README @@ -0,0 +1,49 @@ +This directory contains test configuration files, currently always '.dfa' files +intended to be used in the build by setting the make macro DFA_XTRA to the name +of the file. + +These files are used in release validation of the 'configure' builds of libpng +by building 'make check', or 'make all-am' for cross-builds, with each .dfa +file. + +The files in this directory may change between minor releases, however +contributions describing specific builds of libpng are welcomed. There is no +guarantee that libpng will continue to build with such configurations; support +for given configurations can be, and has been, dropped between successive minor +releases. However if a .dfa file describing a configuration is not in this +directory it is very unlikely that it will be tested before a minor release! + +You can use these .dfa files as the basis of new configurations. Files in this +directory should not have any use restrictions or restrictive licenses. + +This directory is not included in the .zip and .7z distributions, which do +not contain 'configure' scripts. + +DOCUMENTATION +============= + +Examples: + ${srcdir}/pngusr.dfa + ${srcdir}/contrib/pngminim/*/pngusr.dfa + +Documentation of the options: + ${srcdir}/scripts/pnglibconf.dfa + +Documentation of the file format: + ${srcdir}/scripts/options.awk + +FILE NAMING +=========== + +File names in this directory may NOT contain any of the five characters: + + - , + * ? + +Neither may they contain any space character. + +While other characters may be used it is strongly suggested that file names be +limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if +necessary the underscore (_) character. File names should be about 8 characters +long (excluding the .dfa extension). Submitted .dfa files should have names +between 7 and 16 characters long, shorter names (6 characters or less) are +reserved for standard tests. diff --git a/libs/libpng-src/contrib/conftest/pngcp.dfa b/libs/libpng-src/contrib/conftest/pngcp.dfa new file mode 100644 index 000000000..31c411d5f --- /dev/null +++ b/libs/libpng-src/contrib/conftest/pngcp.dfa @@ -0,0 +1,57 @@ +# pngcp.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2016 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with support for pngcp. This means just png_read_png, +# png_write_png and small number of configuration settings. +# +everything = off + +# This option is specific to this configuration; it adds a #define to the +# generated pnglibconf.h which turns on the (not portable) timing option for +# pngcp. Note that any option is automatically preceded by PNG_; there is no +# way round this and this is deliberate. +option PNGCP_TIMING + +# Because of the everything off above the option must also be turned on. This +# may not be done in one step because it is safer and avoids mis-spelled options +# in user .dfa files to error out if an unrecognized option is turned on. +option PNGCP_TIMING on + +# Options to turn on png_read_png and png_write_png: +option INFO_IMAGE on +option SEQUENTIAL_READ on +option EASY_ACCESS on +option WRITE on +option WRITE_16BIT on +option WRITE_FILTER on + +# pngcp needs this to preserve unknown chunks, switching all these on means that +# pngcp can work without explicit known chunk reading support +option UNKNOWN_CHUNKS on +option SET_UNKNOWN_CHUNKS on +option HANDLE_AS_UNKNOWN on +option SAVE_UNKNOWN_CHUNKS on +option WRITE_UNKNOWN_CHUNKS on + +# pngcp needs this to handle palette files with invalid indices: +option CHECK_FOR_INVALID_INDEX on +option GET_PALETTE_MAX on + +# Pre-libpng 1.7 pngcp has to stash text chunks manually, post 1.7 without this +# text chunks should be handled as unknown ok. +option TEXT on + +# this is used to turn off limits: +option USER_LIMITS on +option SET_USER_LIMITS on + +# these are just required for specific customizations +option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on +option WRITE_CUSTOMIZE_COMPRESSION on diff --git a/libs/libpng-src/contrib/conftest/read.dfa b/libs/libpng-src/contrib/conftest/read.dfa new file mode 100644 index 000000000..21e88d01a --- /dev/null +++ b/libs/libpng-src/contrib/conftest/read.dfa @@ -0,0 +1,58 @@ +# read.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with basic read support. This enables the lowest level libpng +# read API - the one where the calling code has to use a loop to read each row. +# At present this is the API used by most programs. +# +# Support is enabled only for those chunks and transformations that are +# typically required - others can be added easily. +# + +everything = off + +# The sequential read code is enabled here; the progressive code can be used +# instead but there is no point enabling both. + +option SEQUENTIAL_READ on + +# Likewise it is pointless enabling both fixed and floating point APIs. Choose +# one or the other for both the API and the internal math. + +#Fixed point: +#option FIXED_POINT on +#option FLOATING_ARITHMETIC off + +#Floating point: +option FLOATING_POINT on +option FLOATING_ARITHMETIC on + +# Basic error handling, IO and user memory support. The latter allows the +# application program to provide its own implementations of 'malloc' and 'free'. +option SETJMP on +option STDIO on +option USER_MEM on + +# To read the full set of PNG images correctly interlace, transparency and +# 16-bit support is required. The application can implement interlace itself, +# but very few do and it's no longer possible to disable it when READ is +# enabled. +option READ_tRNS on +option READ_16BIT on + +# Everything else is application dependent. This file assumes the app handles +# all the native PNG bit layouts, so it doesn't need any of layout change +# transforms, but needs libpng to perform gamma correction. It doesn't do any +# colorspace stuff and ignores the 'significant bit' information. +# +# If your app always expands the image to a limited set of bit layouts you +# probably want to consider using the simplified API instead of the low level +# one - see png.h and s_read.dfa. +option READ_GAMMA on diff --git a/libs/libpng-src/contrib/conftest/s_read.dfa b/libs/libpng-src/contrib/conftest/s_read.dfa new file mode 100644 index 000000000..cb1ce0ba6 --- /dev/null +++ b/libs/libpng-src/contrib/conftest/s_read.dfa @@ -0,0 +1,35 @@ +# s_read.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with simplified read support (only). This builds a minimal +# libpng able to read all PNG formats and convert them into a small number of +# well understood memory formats. +# + +everything = off + +option SIMPLIFIED_READ on + +# It isn't necessary to chose fixed or floating point for the APIs because the +# simplified API doesn't need fixed or floating point numbers. It is necessary +# to chose an internal math implementation. The default (because of 'everything +# = off') is fixed point - turn the floating point implementation on if you have +# hardware floating point or prefer your software floating point implementation. +option FLOATING_ARITHMETIC on + +# This is not strictly necessary, but without it the message strings in the API +# will not be filled in +option ERROR_TEXT on + +# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't +# need this if you don't use them, they just allow the in-memory layout to be +# changed to match common hardware formats. +option SIMPLIFIED_READ_AFIRST on +option SIMPLIFIED_READ_BGR on diff --git a/libs/libpng-src/contrib/conftest/s_write.dfa b/libs/libpng-src/contrib/conftest/s_write.dfa new file mode 100644 index 000000000..e540a46dc --- /dev/null +++ b/libs/libpng-src/contrib/conftest/s_write.dfa @@ -0,0 +1,33 @@ +# s_write.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with (just) simplified write support +# + +everything = off + +option SIMPLIFIED_WRITE on + +# It isn't necessary to chose fixed or floating point for the APIs because the +# simplified API doesn't need fixed or floating point numbers. It is necessary +# to chose an internal math implementation. The default (because of 'everything +# = off') is fixed point - turn the floating point implementation on if you have +# hardware floating point or prefer your software floating point implementation. +option FLOATING_ARITHMETIC on + +# This is not strictly necessary, but without it the message strings in the API +# will not be filled in +option ERROR_TEXT on + +# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't +# need this if you don't use them, they just allow the in-memory layout to be +# changed to match common hardware formats. +option SIMPLIFIED_WRITE_AFIRST on +option SIMPLIFIED_WRITE_BGR on diff --git a/libs/libpng-src/contrib/conftest/simple.dfa b/libs/libpng-src/contrib/conftest/simple.dfa new file mode 100644 index 000000000..041933344 --- /dev/null +++ b/libs/libpng-src/contrib/conftest/simple.dfa @@ -0,0 +1,36 @@ +# simple.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with just the simplified APIs (read and write). +# + +everything = off + +option SIMPLIFIED_WRITE on +option SIMPLIFIED_READ on + +# It isn't necessary to chose fixed or floating point for the APIs because the +# simplified API doesn't need fixed or floating point numbers. It is necessary +# to chose an internal math implementation. The default (because of 'everything +# = off') is fixed point - turn the floating point implementation on if you have +# hardware floating point or prefer your software floating point implementation. +option FLOATING_ARITHMETIC on + +# This is not strictly necessary, but without it the message strings in the API +# will not be filled in +option ERROR_TEXT on + +# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't +# need this if you don't use them, they just allow the in-memory layout to be +# changed to match common hardware formats. +option SIMPLIFIED_READ_AFIRST on +option SIMPLIFIED_READ_BGR on +option SIMPLIFIED_WRITE_AFIRST on +option SIMPLIFIED_WRITE_BGR on diff --git a/libs/libpng-src/contrib/conftest/write.dfa b/libs/libpng-src/contrib/conftest/write.dfa new file mode 100644 index 000000000..3319aabee --- /dev/null +++ b/libs/libpng-src/contrib/conftest/write.dfa @@ -0,0 +1,45 @@ +# write.dfa +# Build time configuration of libpng +# +# Author: John Bowler +# Copyright: (c) John Bowler, 2013 +# Usage rights: +# To the extent possible under law, the author has waived all copyright and +# related or neighboring rights to this work. This work is published from: +# United States. +# +# Build libpng with no read support and minimal write support. +# + +everything = off + +# Switch on the write code - this makes a minimalist encoder + +option WRITE on + +# Choose fixed or floating point APIs and arithmetic. The choices are +# independent but normally they will match. It is typically better to use the +# floating point if you have floating point hardware. If you don't know, or +# (perhaps) to make libpng smaller used fixed point throughout. + +#Fixed point: +#option FIXED_POINT on +#option FLOATING_ARITHMETIC off + +#Floating point: +option FLOATING_POINT on +option FLOATING_ARITHMETIC on + +# Basic error handling, IO and user memory support. The latter allows the +# application program to provide its own implementations of 'malloc' and 'free'. +option SETJMP on +option STDIO on +option USER_MEM on + +# Everything else is optional. Unlike the read code in libpng the write code +# does not need to deal with arbitrary formats, so only add support for things +# you really do write! For example you might only write sRGB images, sometimes +# with transparency and never write 16 bit images, so: +option WRITE_sRGB on +option WRITE_tRNS on +#option WRITE_16BIT off (this is the default with 'everything = off') diff --git a/libs/libpng-src/contrib/examples/README.txt b/libs/libpng-src/contrib/examples/README.txt new file mode 100644 index 000000000..48dab4f0f --- /dev/null +++ b/libs/libpng-src/contrib/examples/README.txt @@ -0,0 +1,24 @@ + +This directory (contrib/examples) contains examples of libpng usage. + +NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY. + +To the extent possible under law, the authors have waived all copyright and +related or neighboring rights to this work. This work is published from: +United States. + +The files may be used freely in any way. The intention is that appropriate +parts of the files be used in other libpng-using programs without any need for +the authors of the using code to seek copyright or license from the original +authors. + +The source code and comments in this directory are the original work of the +people named below. No other person or organization has made contributions to +the work in this directory. + +ORIGINAL AUTHORS + The following people have contributed to the code in this directory. None + of the people below claim any rights with regard to the contents of this + directory. + + John Bowler diff --git a/libs/libpng-src/contrib/examples/iccfrompng.c b/libs/libpng-src/contrib/examples/iccfrompng.c new file mode 100644 index 000000000..00056abfd --- /dev/null +++ b/libs/libpng-src/contrib/examples/iccfrompng.c @@ -0,0 +1,185 @@ +/*- iccfrompng + * + * COPYRIGHT: Written by John Cunningham Bowler, 2011. + * To the extent possible under law, the author has waived all copyright and + * related or neighboring rights to this work. This work is published from: + * United States. + * + * Extract any icc profiles found in the given PNG files. This is a simple + * example of a program that extracts information from the header of a PNG file + * without processing the image. Notice that some header information may occur + * after the image data. Textual data and comments are an example; the approach + * in this file won't work reliably for such data because it only looks for the + * information in the section of the file that precedes the image data. + * + * Compile and link against libpng and zlib, plus anything else required on the + * system you use. + * + * To use supply a list of PNG files containing iCCP chunks, the chunks will be + * extracted to a similarly named file with the extension replaced by 'icc', + * which will be overwritten without warning. + */ +#include +#include +#include +#include + +#include + +#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \ + defined (PNG_iCCP_SUPPORTED) + + +static int verbose = 1; +static png_byte no_profile[] = "no profile"; + +static png_bytep +extract(FILE *fp, png_uint_32 *proflen) +{ + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_infop info_ptr = NULL; + png_bytep result = NULL; + + /* Initialize for error or no profile: */ + *proflen = 0; + + if (png_ptr == NULL) + { + fprintf(stderr, "iccfrompng: version library mismatch?\n"); + return 0; + } + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return 0; + } + + png_init_io(png_ptr, fp); + + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) + png_error(png_ptr, "OOM allocating info structure"); + + png_read_info(png_ptr, info_ptr); + + { + png_charp name; + int compression_type; + png_bytep profile; + + if (png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile, + proflen) & PNG_INFO_iCCP) + { + result = malloc(*proflen); + if (result != NULL) + memcpy(result, profile, *proflen); + + else + png_error(png_ptr, "OOM allocating profile buffer"); + } + + else + result = no_profile; + } + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + return result; +} + +static int +extract_one_file(const char *filename) +{ + int result = 0; + FILE *fp = fopen(filename, "rb"); + + if (fp != NULL) + { + png_uint_32 proflen = 0; + png_bytep profile = extract(fp, &proflen); + + if (profile != NULL && profile != no_profile) + { + size_t len; + char *output; + + { + const char *ep = strrchr(filename, '.'); + + if (ep != NULL) + len = ep-filename; + + else + len = strlen(filename); + } + + output = malloc(len + 5); + if (output != NULL) + { + FILE *of; + + memcpy(output, filename, len); + strcpy(output+len, ".icc"); + + of = fopen(output, "wb"); + if (of != NULL) + { + if (fwrite(profile, proflen, 1, of) == 1 && + fflush(of) == 0 && + fclose(of) == 0) + { + if (verbose) + printf("%s -> %s\n", filename, output); + /* Success return */ + result = 1; + } + + else + { + fprintf(stderr, "%s: error writing profile\n", output); + if (remove(output)) + fprintf(stderr, "%s: could not remove file\n", output); + } + } + + else + fprintf(stderr, "%s: failed to open output file\n", output); + + free(output); + } + + else + fprintf(stderr, "%s: OOM allocating string!\n", filename); + + free(profile); + } + + else if (verbose && profile == no_profile) + printf("%s has no profile\n", filename); + } + + else + fprintf(stderr, "%s: could not open file\n", filename); + + return result; +} + +int +main(int argc, char **argv) +{ + int i; + int extracted = 0; + + for (i=1; i +#include +#include /* required for error handling */ + +/* Normally use here to get the installed libpng, but this is done to + * ensure the code picks up the local libpng implementation: + */ +#include "../../png.h" + +#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED) + +/* Return component 'c' of pixel 'x' from the given row. */ +static unsigned int +component(png_const_bytep row, png_uint_32 x, unsigned int c, + unsigned int bit_depth, unsigned int channels) +{ + /* PNG images can be up to 2^31 pixels wide, but this means they can be up to + * 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence 2^34 + * bytes wide. Since the row fitted into memory, however, the following must + * work: + */ + png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels); + png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c); + + row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi); + row += bit_offset_lo >> 3; + bit_offset_lo &= 0x07; + + /* PNG pixels are packed into bytes to put the first pixel in the highest + * bits of the byte and into two bytes for 16-bit values with the high 8 bits + * first, so: + */ + switch (bit_depth) + { + case 1: return (row[0] >> (7-bit_offset_lo)) & 0x01; + case 2: return (row[0] >> (6-bit_offset_lo)) & 0x03; + case 4: return (row[0] >> (4-bit_offset_lo)) & 0x0f; + case 8: return row[0]; + case 16: return (row[0] << 8) + row[1]; + default: + /* This should never happen; it indicates a bug in this program or in + * libpng itself: + */ + fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth); + exit(1); + } +} + +/* Print a pixel from a row returned by libpng; determine the row format, find + * the pixel, and print the relevant information to stdout. + */ +static void +print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row, + png_uint_32 x) +{ + unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr); + + switch (png_get_color_type(png_ptr, info_ptr)) + { + case PNG_COLOR_TYPE_GRAY: + printf("GRAY %u\n", component(row, x, 0, bit_depth, 1)); + return; + + /* The palette case is slightly more difficult - the palette and, if + * present, the tRNS ('transparency', though the values are really + * opacity) data must be read to give the full picture: + */ + case PNG_COLOR_TYPE_PALETTE: + { + int index = component(row, x, 0, bit_depth, 1); + png_colorp palette = NULL; + int num_palette = 0; + + if ((png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) & + PNG_INFO_PLTE) && num_palette > 0 && palette != NULL) + { + png_bytep trans_alpha = NULL; + int num_trans = 0; + if ((png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, + NULL) & PNG_INFO_tRNS) && num_trans > 0 && + trans_alpha != NULL) + printf("INDEXED %u = %d %d %d %d\n", index, + palette[index].red, palette[index].green, + palette[index].blue, + index < num_trans ? trans_alpha[index] : 255); + + else /* no transparency */ + printf("INDEXED %u = %d %d %d\n", index, + palette[index].red, palette[index].green, + palette[index].blue); + } + + else + printf("INDEXED %u = invalid index\n", index); + } + return; + + case PNG_COLOR_TYPE_RGB: + printf("RGB %u %u %u\n", component(row, x, 0, bit_depth, 3), + component(row, x, 1, bit_depth, 3), + component(row, x, 2, bit_depth, 3)); + return; + + case PNG_COLOR_TYPE_GRAY_ALPHA: + printf("GRAY+ALPHA %u %u\n", component(row, x, 0, bit_depth, 2), + component(row, x, 1, bit_depth, 2)); + return; + + case PNG_COLOR_TYPE_RGB_ALPHA: + printf("RGBA %u %u %u %u\n", component(row, x, 0, bit_depth, 4), + component(row, x, 1, bit_depth, 4), + component(row, x, 2, bit_depth, 4), + component(row, x, 3, bit_depth, 4)); + return; + + default: + png_error(png_ptr, "pngpixel: invalid color type"); + } +} + +int main(int argc, const char **argv) +{ + /* This program uses the default, based, libpng error handling + * mechanism, therefore any local variable that exists before the call to + * setjmp and is changed after the call to setjmp returns successfully must + * be declared with 'volatile' to ensure that their values don't get + * destroyed by longjmp: + */ + volatile int result = 1/*fail*/; + + if (argc == 4) + { + long x = atol(argv[1]); + long y = atol(argv[2]); + FILE *f = fopen(argv[3], "rb"); + volatile png_bytep row = NULL; + + if (f != NULL) + { + /* libpng requires a callback function for handling errors; this + * callback must not return. The default callback function uses a + * stored style jmp_buf which is held in a png_struct and + * writes error messages to stderr. Creating the png_struct is a + * little tricky; just copy the following code. + */ + png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, + NULL, NULL, NULL); + + if (png_ptr != NULL) + { + png_infop info_ptr = png_create_info_struct(png_ptr); + + if (info_ptr != NULL) + { + /* Declare stack variables to hold pointers to locally allocated + * data. + */ + + /* Initialize the error control buffer: */ + if (setjmp(png_jmpbuf(png_ptr)) == 0) + { + png_uint_32 width, height; + int bit_depth, color_type, interlace_method, + compression_method, filter_method; + png_bytep row_tmp; + + /* Now associate the recently opened (FILE*) with the default + * libpng initialization functions. Sometimes libpng is + * compiled without stdio support (it can be difficult to do + * in some environments); in that case you will have to write + * your own read callback to read data from the (FILE*). + */ + png_init_io(png_ptr, f); + + /* And read the first part of the PNG file - the header and + * all the information up to the first pixel. + */ + png_read_info(png_ptr, info_ptr); + + /* This fills in enough information to tell us the width of + * each row in bytes, allocate the appropriate amount of + * space. In this case png_malloc is used - it will not + * return if memory isn't available. + */ + row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, + info_ptr)); + + /* To avoid the overhead of using a volatile auto copy row_tmp + * to a local here - just use row for the png_free below. + */ + row_tmp = row; + + /* All the information we need is in the header is returned by + * png_get_IHDR, if this fails we can now use 'png_error' to + * signal the error and return control to the setjmp above. + */ + if (png_get_IHDR(png_ptr, info_ptr, &width, &height, + &bit_depth, &color_type, &interlace_method, + &compression_method, &filter_method)) + { + int passes, pass; + + /* png_set_interlace_handling returns the number of + * passes required as well as turning on libpng's + * handling, but since we do it ourselves this is + * necessary: + */ + switch (interlace_method) + { + case PNG_INTERLACE_NONE: + passes = 1; + break; + + case PNG_INTERLACE_ADAM7: + passes = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + png_error(png_ptr, "pngpixel: unknown interlace"); + } + + /* Now read the pixels, pass-by-pass, row-by-row: */ + png_start_read_image(png_ptr); + + for (pass=0; pass +#include +#include +#include + +/* Normally use here to get the installed libpng, but this is done to + * ensure the code picks up the local libpng implementation: + */ +#include "../../png.h" +#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \ + defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) + +int main(int argc, const char **argv) +{ + int result = 1; + + if (argc == 3) + { + png_image image; + + /* Only the image structure version number needs to be set. */ + memset(&image, 0, sizeof image); + image.version = PNG_IMAGE_VERSION; + + if (png_image_begin_read_from_file(&image, argv[1])) + { + png_bytep buffer; + + /* Change this to try different formats! If you set a colormap format + * then you must also supply a colormap below. + */ + image.format = PNG_FORMAT_RGBA; + + buffer = malloc(PNG_IMAGE_SIZE(image)); + + if (buffer != NULL) + { + if (png_image_finish_read(&image, NULL/*background*/, buffer, + 0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */)) + { + if (png_image_write_to_file(&image, argv[2], + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/)) + result = 0; + + else + fprintf(stderr, "pngtopng: write %s: %s\n", argv[2], + image.message); + } + + else + fprintf(stderr, "pngtopng: read %s: %s\n", argv[1], + image.message); + + free(buffer); + } + + else + { + fprintf(stderr, "pngtopng: out of memory: %lu bytes\n", + (unsigned long)PNG_IMAGE_SIZE(image)); + + /* This is the only place where a 'free' is required; libpng does + * the cleanup on error and success, but in this case we couldn't + * complete the read because of running out of memory and so libpng + * has not got to the point where it can do cleanup. + */ + png_image_free(&image); + } + } + + else + /* Failed to read the first argument: */ + fprintf(stderr, "pngtopng: %s: %s\n", argv[1], image.message); + } + + else + /* Wrong number of arguments */ + fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n"); + + return result; +} +#endif /* READ && WRITE */ diff --git a/libs/libpng-src/contrib/examples/simpleover.c b/libs/libpng-src/contrib/examples/simpleover.c new file mode 100644 index 000000000..59dd31368 --- /dev/null +++ b/libs/libpng-src/contrib/examples/simpleover.c @@ -0,0 +1,648 @@ +/*- simpleover + * + * COPYRIGHT: Written by John Cunningham Bowler, 2015. + * To the extent possible under law, the author has waived all copyright and + * related or neighboring rights to this work. This work is published from: + * United States. + * + * Read several PNG files, which should have an alpha channel or transparency + * information, and composite them together to produce one or more 16-bit linear + * RGBA intermediates. This involves doing the correct 'over' composition to + * combine the alpha channels and corresponding data. + * + * Finally read an output (background) PNG using the 24-bit RGB format (the + * PNG will be composited on green (#00ff00) by default if it has an alpha + * channel), and apply the intermediate image generated above to specified + * locations in the image. + * + * The command line has the general format: + * + * simpleover [output.png] + * {--sprite=width,height,name {[--at=x,y] {sprite.png}}} + * {--add=name {x,y}} + * + * The --sprite and --add options may occur multiple times. They are executed + * in order. --add may refer to any sprite already read. + * + * This code is intended to show how to composite multiple images together + * correctly. Apart from the libpng Simplified API the only work done in here + * is to combine multiple input PNG images into a single sprite; this involves + * a Porter-Duff 'over' operation and the input PNG images may, as a result, + * be regarded as being layered one on top of the other with the first (leftmost + * on the command line) being at the bottom and the last on the top. + */ +#include +#include +#include +#include +#include + +/* Normally use here to get the installed libpng, but this is done to + * ensure the code picks up the local libpng implementation, so long as this + * file is linked against a sufficiently recent libpng (1.6+) it is ok to + * change this to : + */ +#include "../../png.h" + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED + +#define sprite_name_chars 15 +struct sprite { + FILE *file; + png_uint_16p buffer; + unsigned int width; + unsigned int height; + char name[sprite_name_chars+1]; +}; + +#if 0 /* div by 65535 test program */ +#include +#include + +int main(void) { + double err = 0; + unsigned int xerr = 0; + unsigned int r = 32769; + { + unsigned int x = 0; + + do { + unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r; + double v = x, errtest; + + if (t < x) { + fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t); + return 1; + } + + v /= 65535; + errtest = v; + t >>= 16; + errtest -= t; + + if (errtest > err) { + err = errtest; + xerr = x; + + if (errtest >= .5) { + fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n", + x, v, t, errtest); + return 0; + } + } + } while (++x <= 65535U*65535U); + } + + printf("error %f @ %u\n", err, xerr); + + return 0; +} +#endif /* div by 65535 test program */ + +static void +sprite_op(const struct sprite *sprite, int x_offset, int y_offset, + png_imagep image, const png_uint_16 *buffer) +{ + /* This is where the Porter-Duff 'Over' operator is evaluated; change this + * code to change the operator (this could be parameterized). Any other + * image processing operation could be used here. + */ + + + /* Check for an x or y offset that pushes any part of the image beyond the + * right or bottom of the sprite: + */ + if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) && + (x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width)) + { + unsigned int y = 0; + + if (y_offset < 0) + y = -y_offset; /* Skip to first visible row */ + + do + { + unsigned int x = 0; + + if (x_offset < 0) + x = -x_offset; + + do + { + /* In and out are RGBA values, so: */ + const png_uint_16 *in_pixel = buffer + (y * image->width + x)*4; + png_uint_32 in_alpha = in_pixel[3]; + + /* This is the optimized Porter-Duff 'Over' operation, when the + * input alpha is 0 the output is not changed. + */ + if (in_alpha > 0) + { + png_uint_16 *out_pixel = sprite->buffer + + ((y+y_offset) * sprite->width + (x+x_offset))*4; + + /* This is the weight to apply to the output: */ + in_alpha = 65535-in_alpha; + + if (in_alpha > 0) + { + /* The input must be composed onto the output. This means + * multiplying the current output pixel value by the inverse + * of the input alpha (1-alpha). A division is required but + * it is by the constant 65535. Approximate this as: + * + * (x + (x >> 16) + 32769) >> 16; + * + * This is exact (and does not overflow) for all values of + * x in the range 0..65535*65535. (Note that the calculation + * produces the closest integer; the maximum error is <0.5). + */ + png_uint_32 tmp; + +# define compose(c)\ + tmp = out_pixel[c] * in_alpha;\ + tmp = (tmp + (tmp >> 16) + 32769) >> 16;\ + out_pixel[c] = tmp + in_pixel[c] + + /* The following is very vectorizable... */ + compose(0); + compose(1); + compose(2); + compose(3); + } + + else + out_pixel[0] = in_pixel[0], + out_pixel[1] = in_pixel[1], + out_pixel[2] = in_pixel[2], + out_pixel[3] = in_pixel[3]; + } + } + while (++x < image->width); + } + while (++y < image->height); + } +} + +static int +create_sprite(struct sprite *sprite, int *argc, const char ***argv) +{ + /* Read the arguments and create this sprite. The sprite buffer has already + * been allocated. This reads the input PNGs one by one in linear format, + * composes them onto the sprite buffer (the code in the function above) + * then saves the result, converting it on the fly to PNG RGBA 8-bit format. + */ + while (*argc > 0) + { + char tombstone; + int x = 0, y = 0; + + if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-') + { + /* The only supported option is --at. */ + if (sscanf((*argv)[0], "--at=%d,%d%c", &x, &y, &tombstone) != 2) + break; /* success; caller will parse this option */ + + ++*argv, --*argc; + } + + else + { + /* The argument has to be a file name */ + png_image image; + + image.version = PNG_IMAGE_VERSION; + image.opaque = NULL; + + if (png_image_begin_read_from_file(&image, (*argv)[0])) + { + png_uint_16p buffer; + + image.format = PNG_FORMAT_LINEAR_RGB_ALPHA; + + buffer = malloc(PNG_IMAGE_SIZE(image)); + + if (buffer != NULL) + { + if (png_image_finish_read(&image, NULL/*background*/, buffer, + 0/*row_stride*/, + NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/)) + { + /* This is the place where the Porter-Duff 'Over' operator + * needs to be done by this code. In fact, any image + * processing required can be done here; the data is in + * the correct format (linear, 16-bit) and source and + * destination are in memory. + */ + sprite_op(sprite, x, y, &image, buffer); + free(buffer); + ++*argv, --*argc; + /* And continue to the next argument */ + continue; + } + + else + { + free(buffer); + fprintf(stderr, "simpleover: read %s: %s\n", (*argv)[0], + image.message); + } + } + + else + { + fprintf(stderr, "simpleover: out of memory: %lu bytes\n", + (unsigned long)PNG_IMAGE_SIZE(image)); + + /* png_image_free must be called if we abort the Simplified API + * read because of a problem detected in this code. If problems + * are detected in the Simplified API it cleans up itself. + */ + png_image_free(&image); + } + } + + else + { + /* Failed to read the first argument: */ + fprintf(stderr, "simpleover: %s: %s\n", (*argv)[0], image.message); + } + + return 0; /* failure */ + } + } + + /* All the sprite operations have completed successfully. Save the RGBA + * buffer as a PNG using the simplified write API. + */ + sprite->file = tmpfile(); + + if (sprite->file != NULL) + { + png_image save; + + memset(&save, 0, sizeof save); + save.version = PNG_IMAGE_VERSION; + save.opaque = NULL; + save.width = sprite->width; + save.height = sprite->height; + save.format = PNG_FORMAT_LINEAR_RGB_ALPHA; + save.flags = PNG_IMAGE_FLAG_FAST; + save.colormap_entries = 0; + + if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/, + sprite->buffer, 0/*row_stride*/, NULL/*colormap*/)) + { + /* Success; the buffer is no longer needed: */ + free(sprite->buffer); + sprite->buffer = NULL; + return 1; /* ok */ + } + + else + fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name, + save.message); + } + + else + fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n", + sprite->name, strerror(errno)); + + return 0; /* fail */ +} + +static int +add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite, + int *argc, const char ***argv) +{ + /* Given a --add argument naming this sprite, perform the operations listed + * in the following arguments. The arguments are expected to have the form + * (x,y), which is just an offset at which to add the sprite to the + * output. + */ + while (*argc > 0) + { + char tombstone; + int x, y; + + if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-') + return 1; /* success */ + + if (sscanf((*argv)[0], "%d,%d%c", &x, &y, &tombstone) == 2) + { + /* Now add the new image into the sprite data, but only if it + * will fit. + */ + if (x < 0 || y < 0 || + (unsigned)/*SAFE*/x >= output->width || + (unsigned)/*SAFE*/y >= output->height || + sprite->width > output->width-x || + sprite->height > output->height-y) + { + fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n", + sprite->name, x, y); + /* Could just skip this, but for the moment it is an error */ + return 0; /* error */ + } + + else + { + /* Since we know the sprite fits we can just read it into the + * output using the simplified API. + */ + png_image in; + + in.version = PNG_IMAGE_VERSION; + rewind(sprite->file); + + if (png_image_begin_read_from_stdio(&in, sprite->file)) + { + in.format = PNG_FORMAT_RGB; /* force compose */ + + if (png_image_finish_read(&in, NULL/*background*/, + out_buf + (y*output->width + x)*3/*RGB*/, + output->width*3/*row_stride*/, + NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/)) + { + ++*argv, --*argc; + continue; + } + } + + /* The read failed: */ + fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name, + in.message); + return 0; /* error */ + } + } + + else + { + fprintf(stderr, "simpleover: --add='%s': invalid position %s\n", + sprite->name, (*argv)[0]); + return 0; /* error */ + } + } + + return 1; /* ok */ +} + +static int +simpleover_process(png_imagep output, png_bytep out_buf, int argc, + const char **argv) +{ + int result = 1; /* success */ +# define csprites 10/*limit*/ +# define str(a) #a + int nsprites = 0; + struct sprite sprites[csprites]; + + while (argc > 0) + { + result = 0; /* fail */ + + if (strncmp(argv[0], "--sprite=", 9) == 0) + { + char tombstone; + + if (nsprites < csprites) + { + int n; + + sprites[nsprites].width = sprites[nsprites].height = 0; + sprites[nsprites].name[0] = 0; + + n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c", + &sprites[nsprites].width, &sprites[nsprites].height, + sprites[nsprites].name, &tombstone); + + if ((n == 2 || n == 3) && + sprites[nsprites].width > 0 && sprites[nsprites].height > 0) + { + size_t buf_size, tmp; + + /* Default a name if not given. */ + if (sprites[nsprites].name[0] == 0) + sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1); + + /* Allocate a buffer for the sprite and calculate the buffer + * size: + */ + buf_size = sizeof (png_uint_16 [4]); + buf_size *= sprites[nsprites].width; + buf_size *= sprites[nsprites].height; + + /* This can overflow a (size_t); check for this: */ + tmp = buf_size; + tmp /= sprites[nsprites].width; + tmp /= sprites[nsprites].height; + + if (tmp == sizeof (png_uint_16 [4])) + { + sprites[nsprites].buffer = malloc(buf_size); + /* This buffer must be initialized to transparent: */ + memset(sprites[nsprites].buffer, 0, buf_size); + + if (sprites[nsprites].buffer != NULL) + { + sprites[nsprites].file = NULL; + ++argv, --argc; + + if (create_sprite(sprites+nsprites++, &argc, &argv)) + { + result = 1; /* still ok */ + continue; + } + + break; /* error */ + } + } + + /* Overflow, or OOM */ + fprintf(stderr, "simpleover: %s: sprite too large\n", argv[0]); + break; + } + + else + { + fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n", + argv[0], sprites[nsprites].width, sprites[nsprites].height); + break; + } + } + + else + { + fprintf(stderr, "simpleover: %s: too many sprites\n", argv[0]); + break; + } + } + + else if (strncmp(argv[0], "--add=", 6) == 0) + { + const char *name = argv[0]+6; + int isprite = nsprites; + + ++argv, --argc; + + while (--isprite >= 0) + { + if (strcmp(sprites[isprite].name, name) == 0) + { + if (!add_sprite(output, out_buf, sprites+isprite, &argc, &argv)) + goto out; /* error in add_sprite */ + + break; + } + } + + if (isprite < 0) /* sprite not found */ + { + fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name); + break; + } + } + + else + { + fprintf(stderr, "simpleover: %s: unrecognized operation\n", argv[0]); + break; + } + + result = 1; /* ok */ + } + + /* Clean up the cache of sprites: */ +out: + while (--nsprites >= 0) + { + if (sprites[nsprites].buffer != NULL) + free(sprites[nsprites].buffer); + + if (sprites[nsprites].file != NULL) + (void)fclose(sprites[nsprites].file); + } + + return result; +} + +int main(int argc, const char **argv) +{ + int result = 1; /* default to fail */ + + if (argc >= 2) + { + int argi = 2; + const char *output = NULL; + png_image image; + + if (argc > 2 && argv[2][0] != '-'/*an operation*/) + { + output = argv[2]; + argi = 3; + } + + image.version = PNG_IMAGE_VERSION; + image.opaque = NULL; + + if (png_image_begin_read_from_file(&image, argv[1])) + { + png_bytep buffer; + + image.format = PNG_FORMAT_RGB; /* 24-bit RGB */ + + buffer = malloc(PNG_IMAGE_SIZE(image)); + + if (buffer != NULL) + { + png_color background = {0, 0xff, 0}; /* fully saturated green */ + + if (png_image_finish_read(&image, &background, buffer, + 0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */)) + { + /* At this point png_image_finish_read has cleaned up the + * allocated data in png_image, and only the buffer needs to be + * freed. + * + * Perform the remaining operations: + */ + if (simpleover_process(&image, buffer, argc-argi, argv+argi)) + { + /* Write the output: */ + if ((output != NULL && + png_image_write_to_file(&image, output, + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/)) || + (output == NULL && + png_image_write_to_stdio(&image, stdout, + 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, + NULL/*colormap*/))) + result = 0; + + else + fprintf(stderr, "simpleover: write %s: %s\n", + output == NULL ? "stdout" : output, image.message); + } + + /* else simpleover_process writes an error message */ + } + + else + fprintf(stderr, "simpleover: read %s: %s\n", argv[1], + image.message); + + free(buffer); + } + + else + { + fprintf(stderr, "simpleover: out of memory: %lu bytes\n", + (unsigned long)PNG_IMAGE_SIZE(image)); + + /* This is the only place where a 'free' is required; libpng does + * the cleanup on error and success, but in this case we couldn't + * complete the read because of running out of memory. + */ + png_image_free(&image); + } + } + + else + { + /* Failed to read the first argument: */ + fprintf(stderr, "simpleover: %s: %s\n", argv[1], image.message); + } + } + + else + { + /* Usage message */ + fprintf(stderr, + "simpleover: usage: simpleover background.png [output.png]\n" + " Output 'background.png' as a 24-bit RGB PNG file in 'output.png'\n" + " or, if not given, stdout. 'background.png' will be composited\n" + " on fully saturated green.\n" + "\n" + " Optionally, before output, process additional PNG files:\n" + "\n" + " --sprite=width,height,name {[--at=x,y] {sprite.png}}\n" + " Produce a transparent sprite of size (width,height) and with\n" + " name 'name'.\n" + " For each sprite.png composite it using a Porter-Duff 'Over'\n" + " operation at offset (x,y) in the sprite (defaulting to (0,0)).\n" + " Input PNGs will be truncated to the area of the sprite.\n" + "\n" + " --add='name' {x,y}\n" + " Optionally, before output, composite a sprite, 'name', which\n" + " must have been previously produced using --sprite, at each\n" + " offset (x,y) in the output image. Each sprite must fit\n" + " completely within the output image.\n" + "\n" + " PNG files are processed in the order they occur on the command\n" + " line and thus the first PNG processed appears as the bottommost\n" + " in the output image.\n"); + } + + return result; +} +#endif /* SIMPLIFIED_READ */ diff --git a/libs/libpng-src/contrib/gregbook/COPYING b/libs/libpng-src/contrib/gregbook/COPYING index d60c31a97..a3e977479 100644 --- a/libs/libpng-src/contrib/gregbook/COPYING +++ b/libs/libpng-src/contrib/gregbook/COPYING @@ -1,12 +1,12 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - GNU GENERAL PUBLIC LICENSE + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains @@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN @@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS + END OF TERMS AND CONDITIONS - How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it diff --git a/libs/libpng-src/contrib/gregbook/Makefile.mingw32 b/libs/libpng-src/contrib/gregbook/Makefile.mingw32 index e70a59aef..3a3ff607e 100644 --- a/libs/libpng-src/contrib/gregbook/Makefile.mingw32 +++ b/libs/libpng-src/contrib/gregbook/Makefile.mingw32 @@ -47,7 +47,8 @@ CC = gcc #CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation LD = $(CC) RM = rm -f -CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS) +CPPFLAGS = $(INCS) +CFLAGS = -O -Wall $(MINGW_CCFLAGS) # [note that -Wall is a gcc-specific compilation flag ("most warnings on")] # [-ansi, -pedantic and -W can also be used] LDFLAGS = $(MINGW_LDFLAGS) @@ -85,10 +86,10 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES) # implicit make rules ------------------------------------------------------- .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< %.pic$(O): %.c - $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< # dependencies -------------------------------------------------------------- diff --git a/libs/libpng-src/contrib/gregbook/Makefile.sgi b/libs/libpng-src/contrib/gregbook/Makefile.sgi index e3ca6ce4c..94d61b465 100644 --- a/libs/libpng-src/contrib/gregbook/Makefile.sgi +++ b/libs/libpng-src/contrib/gregbook/Makefile.sgi @@ -23,9 +23,9 @@ # macros -------------------------------------------------------------------- -PNGINC = -I/usr/local/include/libpng12 -PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng -#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng +PNGINC = -I/usr/local/include/libpng16 +PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng +#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng # or: #PNGINC = -I../.. #PNGLIB = -L../.. -lpng @@ -53,7 +53,8 @@ CC = cc LD = cc RM = rm -f # ABI must be the same as that used to build libpng. -ABI= +ABI = +CPPFLAGS = CFLAGS = $(ABI) -O -fullwarn $(INCS) LDFLAGS = $(ABI) O = .o @@ -73,7 +74,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) # implicit make rules ------------------------------------------------------- .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< # dependencies -------------------------------------------------------------- diff --git a/libs/libpng-src/contrib/gregbook/Makefile.unx b/libs/libpng-src/contrib/gregbook/Makefile.unx index 7ff65bfb7..1a73e03bf 100644 --- a/libs/libpng-src/contrib/gregbook/Makefile.unx +++ b/libs/libpng-src/contrib/gregbook/Makefile.unx @@ -26,14 +26,14 @@ # macros -------------------------------------------------------------------- #PNGDIR = /usr/local/lib -#PNGINC = -I/usr/local/include/libpng12 -#PNGLIBd = -L$(PNGDIR) -lpng12 # dynamically linked, installed libpng -#PNGLIBs = $(PNGDIR)/libpng12.a # statically linked, installed libpng +#PNGINC = -I/usr/local/include/libpng16 +#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng +#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng # or: PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds #PNGDIR = ../libpng PNGINC = -I$(PNGDIR) -PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng12 # dynamically linked +PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng ZDIR = /usr/local/lib @@ -59,14 +59,16 @@ INCS = $(PNGINC) $(ZINC) $(XINC) RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm WLIBSd = $(PNGLIBd) $(ZLIBd) -lm -WLIBSs = $(PNGLIBs) $(ZLIBs) +WLIBSs = $(PNGLIBs) $(ZLIBs) -lm CC = gcc LD = gcc RM = rm -f -CFLAGS = -O -Wall $(INCS) -DFEATURE_LOOP +CPPFLAGS = $(INCS) -DFEATURE_LOOP +CFLAGS = -O -Wall +#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi # [note that -Wall is a gcc-specific compilation flag ("most warnings on")] -# [-ansi, -pedantic and -W can also be used] +# [-ansi, -pedantic, -Wextra, and -W can also be used] LDFLAGS = O = .o E = @@ -92,7 +94,7 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES) # implicit make rules ------------------------------------------------------- .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< # dependencies -------------------------------------------------------------- diff --git a/libs/libpng-src/contrib/gregbook/Makefile.w32 b/libs/libpng-src/contrib/gregbook/Makefile.w32 index 3c0808593..ab7dcf7ca 100644 --- a/libs/libpng-src/contrib/gregbook/Makefile.w32 +++ b/libs/libpng-src/contrib/gregbook/Makefile.w32 @@ -18,7 +18,7 @@ # "c:\windows\command.com /e:4096" as the program command line and set the # working directory to this directory. Then double-click to open the new # DOS-prompt window with a bigger environment and retry the commands above. -# +# # This makefile assumes libpng and zlib have already been built or downloaded # and are in subdirectories at the same level as the current subdirectory # (as indicated by the PNGPATH and ZPATH macros below). Edit as appropriate. @@ -53,7 +53,8 @@ WLIBS = $(PNGLIB) $(ZLIB) CC = cl LD = link RM = del -CFLAGS = -nologo -O -W3 $(INCS) $(cvars) +CPPFLAGS = $(INCS) +CFLAGS = -nologo -O -W3 $(cvars) # [note that -W3 is an MSVC-specific compilation flag ("all warnings on")] # [see %devstudio%\vc\include\win32.mak for cvars macro definition] O = .obj @@ -76,7 +77,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E) # implicit make rules ------------------------------------------------------- .c$(O): - $(CC) -c $(CFLAGS) $< + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< # dependencies -------------------------------------------------------------- diff --git a/libs/libpng-src/contrib/gregbook/README b/libs/libpng-src/contrib/gregbook/README index cb6e5257e..90e28f7ce 100644 --- a/libs/libpng-src/contrib/gregbook/README +++ b/libs/libpng-src/contrib/gregbook/README @@ -15,7 +15,7 @@ of PBMPLUS/NetPBM) and converts them to PNG. The source code for all three demo programs currently compiles under Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser, -zinser@decus.de, for making the necessary changes for OpenVMS and for +zinser at decus.de, for making the necessary changes for OpenVMS and for providing an appropriate build script.) Build instructions can be found below. @@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters 13-15 of the book for detailed discussion of the three programs. Greg Roelofs -http://pobox.com/~newt/greg_contact.html +https://pobox.com/~newt/greg_contact.html 16 March 2008 @@ -63,9 +63,9 @@ BUILD INSTRUCTIONS - Prerequisites (in order of compilation): - - zlib http://zlib.net/ - - libpng http://www.libpng.org/pub/png/libpng.html - - pngbook http://www.libpng.org/pub/png/book/sources.html + - zlib https://zlib.net/ + - libpng http://www.libpng.org/pub/png/libpng.html + - pngbook http://www.libpng.org/pub/png/book/sources.html The pngbook demo programs are explicitly designed to demonstrate proper coding techniques for using the libpng reference library. As a result, @@ -104,7 +104,7 @@ BUILD INSTRUCTIONS unpacked the source code. For MSVC, set up the necessary environment variables by invoking - + %devstudio%\vc\bin\vcvars32.bat where where %devstudio% is the installation directory for MSVC / @@ -165,19 +165,19 @@ RUNNING THE PROGRAMS: (VERY) BRIEF INTRO rpng is a simple PNG viewer that can display transparent PNGs with a specified background color; for example, - rpng -bgcolor #ff0000 toucan.png + rpng -bgcolor \#ff0000 toucan.png would display the image with a red background. rpng2 is a progressive viewer that simulates a web browser in some respects; it can display images against either a background color or a dynamically generated background image. For example: - rpng2 -bgpat 16 toucan.png + rpng2 -bgpat 16 toucan.png wpng is a purely command-line image converter from binary PBMPLUS/NetPBM format (.pgm or .ppm) to PNG; for example, - wpng -time < toucan-notrans.ppm > toucan-notrans.png + wpng -time < toucan-notrans.ppm > toucan-notrans.png would convert the specified PPM file (using redirection) to PNG, auto- matically setting the PNG modification-time chunk. diff --git a/libs/libpng-src/contrib/gregbook/makevms.com b/libs/libpng-src/contrib/gregbook/makevms.com index bd37dc0d7..f32bcaba7 100644 --- a/libs/libpng-src/contrib/gregbook/makevms.com +++ b/libs/libpng-src/contrib/gregbook/makevms.com @@ -20,13 +20,13 @@ $ if zpath .eqs. "" $ then $ write sys$output "zlib include not found. Exiting..." $ exit 2 -$ endif +$ endif $! $ if pngpath .eqs. "" $ then $ write sys$output "libpng include not found. Exiting..." $ exit 2 -$ endif +$ endif $! $! Look for the compiler used. $! diff --git a/libs/libpng-src/contrib/gregbook/readpng.c b/libs/libpng-src/contrib/gregbook/readpng.c index abfc1fb4c..fad9b536a 100644 --- a/libs/libpng-src/contrib/gregbook/readpng.c +++ b/libs/libpng-src/contrib/gregbook/readpng.c @@ -4,7 +4,7 @@ --------------------------------------------------------------------------- - Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -55,8 +55,9 @@ #include #include +#include -#include "png.h" /* libpng header; includes zlib.h */ +#include "png.h" /* libpng header */ #include "readpng.h" /* typedefs, common macros, public prototypes */ /* future versions of libpng will provide this macro: */ @@ -99,7 +100,8 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight) /* could pass pointers to user-defined error handlers instead of NULLs: */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL, + NULL); if (!png_ptr) return 4; /* out of memory */ @@ -214,6 +216,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) * libpng function */ if (setjmp(png_jmpbuf(png_ptr))) { + free(image_data); + image_data = NULL; + free(row_pointers); + row_pointers = NULL; png_destroy_read_struct(&png_ptr, &info_ptr, NULL); return NULL; } @@ -229,8 +235,14 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) png_set_expand(png_ptr); if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_expand(png_ptr); +#ifdef PNG_READ_16_TO_8_SUPPORTED if (bit_depth == 16) +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(png_ptr); +# else png_set_strip_16(png_ptr); +# endif +#endif if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr); @@ -252,6 +264,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) *pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr); *pChannels = (int)png_get_channels(png_ptr, info_ptr); + /* Guard against integer overflow */ + if (height > ((size_t)(-1))/rowbytes) { + fprintf(stderr, "readpng: image_data buffer would be too large\n", + return NULL; + } + if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); return NULL; @@ -263,7 +281,8 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) return NULL; } - Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height)); + Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", + *pChannels, rowbytes, height)); /* set the individual row_pointers to point at the correct offsets */ diff --git a/libs/libpng-src/contrib/gregbook/readpng2.c b/libs/libpng-src/contrib/gregbook/readpng2.c index 2ee6b681f..610b3cd87 100644 --- a/libs/libpng-src/contrib/gregbook/readpng2.c +++ b/libs/libpng-src/contrib/gregbook/readpng2.c @@ -4,7 +4,7 @@ --------------------------------------------------------------------------- - Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2015 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -51,12 +51,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + --------------------------------------------------------------------------- + + Changelog: + 2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P) + 2017-04-22 - Guard against integer overflow (Glenn R-P) + ---------------------------------------------------------------------------*/ #include /* for exit() prototype */ +#include -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ +#include +#include "png.h" /* libpng header from the local directory */ #include "readpng2.h" /* typedefs, common macros, public prototypes */ @@ -67,90 +75,17 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass); static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr); static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg); +static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg); void readpng2_version_info(void) { -#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \ - (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \ - defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - /* - * WARNING: This preprocessor approach means that the following code - * cannot be used with a libpng DLL older than 1.2.0--the - * compiled-in symbols for the new functions will not exist. - * (Could use dlopen() and dlsym() on Unix and corresponding - * calls for Windows, but not portable...) - */ - { - int mmxsupport = png_mmx_support(); - if (mmxsupport < 0) - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); - else { - int compilerID; - png_uint_32 mmx_mask = png_get_mmx_flagmask( - PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); + fprintf(stderr, " Compiled with libpng %s; using libpng %s\n", + PNG_LIBPNG_VER_STRING, png_libpng_ver); - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING, - png_libpng_ver, compilerID == 1? "MSVC++" : - (compilerID == 2? "GNU C" : "unknown")); - fprintf(stderr, " Processor (x86%s) %s MMX instructions.\n", -#if defined(__x86_64__) - "_64", -#else - "", -#endif - mmxsupport? "supports" : "does not support"); - if (mmxsupport > 0) { - int num_optims = 0; - - fprintf(stderr, - " Potential MMX optimizations supported by libpng:\n"); - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) - ++num_optims; - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) - ++num_optims; - if (num_optims) - fprintf(stderr, - " decoding %s row filters (reading)\n", - (num_optims == 4)? "all non-trivial" : "some"); - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) { - fprintf(stderr, " combining rows (reading)\n"); - ++num_optims; - } - if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) { - fprintf(stderr, - " expanding interlacing (reading)\n"); - ++num_optims; - } - mmx_mask &= ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - if (mmx_mask) { - fprintf(stderr, " other (unknown)\n"); - ++num_optims; - } - if (num_optims == 0) - fprintf(stderr, " (none)\n"); - } - } - } -#else - fprintf(stderr, " Compiled with libpng %s; using libpng %s " - "without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); -#endif - - fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n", + fprintf(stderr, " and with zlib %s; using zlib %s.\n", ZLIB_VERSION, zlib_version); } @@ -175,8 +110,8 @@ int readpng2_init(mainprog_info *mainprog_ptr) /* could also replace libpng warning-handler (final NULL), but no need: */ - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, - readpng2_error_handler, NULL); + png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr, + readpng2_error_handler, readpng2_warning_handler); if (!png_ptr) return 4; /* out of memory */ @@ -203,36 +138,30 @@ int readpng2_init(mainprog_info *mainprog_ptr) } -#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED /* prepare the reader to ignore all recognized chunks whose data won't be * used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT, * IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */ { - /* These byte strings were copied from png.h. If a future libpng - * version recognizes more chunks, add them to this list. If a - * future version of readpng2.c recognizes more chunks, delete them - * from this list. */ - static const png_byte chunks_to_ignore[] = { - 99, 72, 82, 77, '\0', /* cHRM */ - 104, 73, 83, 84, '\0', /* hIST */ - 105, 67, 67, 80, '\0', /* iCCP */ - 105, 84, 88, 116, '\0', /* iTXt */ - 111, 70, 70, 115, '\0', /* oFFs */ - 112, 67, 65, 76, '\0', /* pCAL */ - 112, 72, 89, 115, '\0', /* pHYs */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 67, 65, 76, '\0', /* sCAL */ - 115, 80, 76, 84, '\0', /* sPLT */ - 115, 84, 69, 82, '\0', /* sTER */ - 116, 69, 88, 116, '\0', /* tEXt */ - 116, 73, 77, 69, '\0', /* tIME */ - 122, 84, 88, 116, '\0' /* zTXt */ - }; + /* These byte strings were copied from png.h. If a future version + * of readpng2.c recognizes more chunks, add them to this list. + */ + static const png_byte chunks_to_process[] = { + 98, 75, 71, 68, '\0', /* bKGD */ + 103, 65, 77, 65, '\0', /* gAMA */ + 115, 82, 71, 66, '\0', /* sRGB */ + }; - png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */, - chunks_to_ignore, sizeof(chunks_to_ignore)/5); + /* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */ + png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */, + NULL, -1); + + /* But do not ignore chunks in the "chunks_to_process" list */ + png_set_keep_unknown_chunks(png_ptr, + 0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process, + sizeof(chunks_to_process)/5); } -#endif /* PNG_UNKNOWN_CHUNKS_SUPPORTED */ +#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */ /* instead of doing png_init_io() here, now we set up our callback @@ -242,96 +171,6 @@ int readpng2_init(mainprog_info *mainprog_ptr) readpng2_info_callback, readpng2_row_callback, readpng2_end_callback); - /* - * may as well enable or disable MMX routines here, if supported; - * - * to enable all: mask = png_get_mmx_flagmask ( - * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - * flags = png_get_asm_flags (png_ptr); - * flags |= mask; - * png_set_asm_flags (png_ptr, flags); - * - * to disable all: mask = png_get_mmx_flagmask ( - * PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID); - * flags = png_get_asm_flags (png_ptr); - * flags &= ~mask; - * png_set_asm_flags (png_ptr, flags); - */ - -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \ - defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200) - /* - * WARNING: This preprocessor approach means that the following code - * cannot be used with a libpng DLL older than 1.2.0--the - * compiled-in symbols for the new functions will not exist. - * (Could use dlopen() and dlsym() on Unix and corresponding - * calls for Windows, but not portable...) - */ - { -#ifdef PNG_ASSEMBLER_CODE_SUPPORTED - png_uint_32 mmx_disable_mask = 0; - png_uint_32 asm_flags, mmx_mask; - int compilerID; - - if (mainprog_ptr->nommxfilters) - mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ); - if (mainprog_ptr->nommxcombine) - mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW; - if (mainprog_ptr->nommxinterlace) - mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE; - asm_flags = png_get_asm_flags(png_ptr); - png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask); - - - /* Now query libpng's asm settings, just for yuks. Note that this - * differs from the querying of its *potential* MMX capabilities - * in readpng2_version_info(); this is true runtime verification. */ - - asm_flags = png_get_asm_flags(png_ptr); - mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE, - &compilerID); - if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED) - fprintf(stderr, - " MMX support (%s version) is compiled into libpng\n", - compilerID == 1? "MSVC++" : - (compilerID == 2? "GNU C" : "unknown")); - else - fprintf(stderr, " MMX support is not compiled into libpng\n"); - fprintf(stderr, " MMX instructions are %ssupported by CPU\n", - (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not "); - fprintf(stderr, " MMX read support for combining rows is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis"); - fprintf(stderr, - " MMX read support for expanding interlacing is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis"); - fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n", - (asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis"); - asm_flags &= (mmx_mask & ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \ - | PNG_ASM_FLAG_MMX_READ_INTERLACE \ - | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \ - | PNG_ASM_FLAG_MMX_READ_FILTER_UP \ - | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \ - | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )); - if (asm_flags) - fprintf(stderr, - " additional MMX support is also enabled (0x%02lx)\n", - asm_flags); -#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */ - fprintf(stderr, " MMX querying is disabled in libpng.\n"); -#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ - } -#endif - - /* make sure we save our pointers for use in readpng2_decode_data() */ mainprog_ptr->png_ptr = png_ptr; @@ -380,7 +219,11 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) mainprog_info *mainprog_ptr; int color_type, bit_depth; png_uint_32 width, height; +#ifdef PNG_FLOATING_POINT_SUPPORTED double gamma; +#else + png_fixed_point gamma; +#endif /* setjmp() doesn't make sense here, because we'd either have to exit(), @@ -424,36 +267,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) /* since we know we've read all of the PNG file's "header" (i.e., up * to IDAT), we can check for a background color here */ - if (mainprog_ptr->need_bgcolor && - png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD)) + if (mainprog_ptr->need_bgcolor) { png_color_16p pBackground; /* it is not obvious from the libpng documentation, but this function * takes a pointer to a pointer, and it always returns valid red, * green and blue values, regardless of color_type: */ - png_get_bKGD(png_ptr, info_ptr, &pBackground); + if (png_get_bKGD(png_ptr, info_ptr, &pBackground)) + { - /* however, it always returns the raw bKGD data, regardless of any - * bit-depth transformations, so check depth and adjust if necessary */ - if (bit_depth == 16) { - mainprog_ptr->bg_red = pBackground->red >> 8; - mainprog_ptr->bg_green = pBackground->green >> 8; - mainprog_ptr->bg_blue = pBackground->blue >> 8; - } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { - if (bit_depth == 1) - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = pBackground->gray? 255 : 0; - else if (bit_depth == 2) - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = (255/3) * pBackground->gray; - else /* bit_depth == 4 */ - mainprog_ptr->bg_red = mainprog_ptr->bg_green = - mainprog_ptr->bg_blue = (255/15) * pBackground->gray; - } else { - mainprog_ptr->bg_red = (uch)pBackground->red; - mainprog_ptr->bg_green = (uch)pBackground->green; - mainprog_ptr->bg_blue = (uch)pBackground->blue; + /* however, it always returns the raw bKGD data, regardless of any + * bit-depth transformations, so check depth and adjust if necessary + */ + if (bit_depth == 16) { + mainprog_ptr->bg_red = pBackground->red >> 8; + mainprog_ptr->bg_green = pBackground->green >> 8; + mainprog_ptr->bg_blue = pBackground->blue >> 8; + } else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) { + if (bit_depth == 1) + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = pBackground->gray? 255 : 0; + else if (bit_depth == 2) + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = (255/3) * pBackground->gray; + else /* bit_depth == 4 */ + mainprog_ptr->bg_red = mainprog_ptr->bg_green = + mainprog_ptr->bg_blue = (255/15) * pBackground->gray; + } else { + mainprog_ptr->bg_red = (uch)pBackground->red; + mainprog_ptr->bg_green = (uch)pBackground->green; + mainprog_ptr->bg_blue = (uch)pBackground->blue; + } } } @@ -469,8 +314,14 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) png_set_expand(png_ptr); if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) png_set_expand(png_ptr); +#ifdef PNG_READ_16_TO_8_SUPPORTED if (bit_depth == 16) +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(png_ptr); +# else png_set_strip_16(png_ptr); +# endif +#endif if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png_ptr); @@ -491,11 +342,19 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr) * "gamma" value for the entire display system, i.e., the product of * LUT_exponent and CRT_exponent. */ +#ifdef PNG_FLOATING_POINT_SUPPORTED if (png_get_gAMA(png_ptr, info_ptr, &gamma)) png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma); else png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455); - +#else + if (png_get_gAMA_fixed(png_ptr, info_ptr, &gamma)) + png_set_gamma_fixed(png_ptr, + (png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), gamma); + else + png_set_gamma_fixed(png_ptr, + (png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), 45455); +#endif /* we'll let libpng expand interlaced images, too */ @@ -597,6 +456,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr) /* all done */ + (void)info_ptr; /* Unused */ + return; } @@ -617,7 +478,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr) } - +static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg) +{ + fprintf(stderr, "readpng2 libpng warning: %s\n", msg); + fflush(stderr); + (void)png_ptr; /* Unused */ +} static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg) @@ -644,5 +510,12 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg) exit(99); } + /* Now we have our data structure we can use the information in it + * to return control to our own higher level code (all the points + * where 'setjmp' is called in this file.) This will work with other + * error handling mechanisms as well - libpng always calls png_error + * when it can proceed no further, thus, so long as the error handler + * is intercepted, application code can do its own error recovery. + */ longjmp(mainprog_ptr->jmpbuf, 1); } diff --git a/libs/libpng-src/contrib/gregbook/readpng2.h b/libs/libpng-src/contrib/gregbook/readpng2.h index fbfffb4ba..6b3660d7c 100644 --- a/libs/libpng-src/contrib/gregbook/readpng2.h +++ b/libs/libpng-src/contrib/gregbook/readpng2.h @@ -96,11 +96,6 @@ typedef struct _mainprog_info { int rowbytes; int channels; int need_bgcolor; -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - int nommxfilters; - int nommxcombine; - int nommxinterlace; -#endif int state; uch bg_red; uch bg_green; diff --git a/libs/libpng-src/contrib/gregbook/readppm.c b/libs/libpng-src/contrib/gregbook/readppm.c index be9a56d95..52e702777 100644 --- a/libs/libpng-src/contrib/gregbook/readppm.c +++ b/libs/libpng-src/contrib/gregbook/readppm.c @@ -9,7 +9,7 @@ --------------------------------------------------------------------------- - Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -154,17 +154,26 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes) *pRowbytes = rowbytes = channels*width; *pChannels = channels; + Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height)); + + /* Guard against integer overflow */ + if (height > ((size_t)(-1))/rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n", + return NULL; + } + if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) { return NULL; } - Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height)); - - /* now we can go ahead and just read the whole image */ - fread(image_data, 1L, rowbytes*height, saved_infile); - + if (fread(image_data, 1L, rowbytes*height, saved_infile) < + rowbytes*height) { + free (image_data); + image_data = NULL; + return NULL; + } return image_data; } diff --git a/libs/libpng-src/contrib/gregbook/rpng-win.c b/libs/libpng-src/contrib/gregbook/rpng-win.c index 20209611e..1a6f87615 100644 --- a/libs/libpng-src/contrib/gregbook/rpng-win.c +++ b/libs/libpng-src/contrib/gregbook/rpng-win.c @@ -24,10 +24,11 @@ - 1.10: enabled "message window"/console (thanks to David Geldreich) - 2.00: dual-licensed (added GNU GPL) - 2.01: fixed improper display of usage screen on PNG error(s) + - 2.02: check for integer overflow (Glenn R-P) --------------------------------------------------------------------------- - Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -85,7 +86,33 @@ #include #include #include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else #include /* only for _getch() */ +#endif /* #define DEBUG : this enables the Trace() macros */ @@ -153,15 +180,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) filename = (char *)NULL; - +#ifndef __CYGWIN__ /* First reenable console output, which normally goes to the bit bucket * for windowed apps. Closing the console window will terminate the - * app. Thanks to David.Geldreich@realviz.com for supplying the magical + * app. Thanks to David.Geldreich at realviz.com for supplying the magical * incantation. */ AllocConsole(); freopen("CONOUT$", "a", stderr); freopen("CONOUT$", "a", stdout); +#endif /* Next set the default value for our display-system exponent, i.e., @@ -279,7 +307,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) /* print usage screen if any errors up to this point */ if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng_version_info(); @@ -293,11 +323,15 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" "\t\t used with transparent images\n" "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ "Press Q or Esc to quit this usage screen.\n" +#endif "\n", PROGNAME, default_display_exponent); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(1); } @@ -333,18 +367,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(2); } else { fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ fprintf(stderr, "\n [console window: closing this window will terminate %s]\n\n", PROGNAME); +#endif } @@ -417,7 +457,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) /* wait for the user to tell us when to quit */ printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); fflush(stdout); while (GetMessage(&msg, NULL, 0, 0)) { @@ -452,6 +497,12 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode) wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2; + /* Guard against integer overflow */ + if (image_height > ((size_t)(-1))/wimage_rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n"); + return 4; /* fail */ + } + if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) + wimage_rowbytes*image_height))) { diff --git a/libs/libpng-src/contrib/gregbook/rpng-x.c b/libs/libpng-src/contrib/gregbook/rpng-x.c index 0a9817029..92effaa6d 100644 --- a/libs/libpng-src/contrib/gregbook/rpng-x.c +++ b/libs/libpng-src/contrib/gregbook/rpng-x.c @@ -26,10 +26,13 @@ - 1.14: added support for X resources (thanks to Gerhard Niklasch) - 2.00: dual-licensed (added GNU GPL) - 2.01: fixed improper display of usage screen on PNG error(s) + - 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings + about unused variable (GR-P) + - 2.03: check for integer overflow (Glenn R-P) --------------------------------------------------------------------------- - Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -80,9 +83,9 @@ #define PROGNAME "rpng-x" #define LONGNAME "Simple PNG Viewer for X" -#define VERSION "2.01 of 16 March 2008" -#define RESNAME "rpng" /* our X resource application name */ -#define RESCLASS "Rpng" /* our X resource class name */ +#define VERSION "2.02 of 15 June 2014" +#define RESNAME "rpng" /* our X resource application name */ +#define RESCLASS "Rpng" /* our X resource class name */ #include #include @@ -252,8 +255,8 @@ int main(int argc, char **argv) else { bgstr = *argv; if (strlen(bgstr) != 7 || bgstr[0] != '#') - ++error; - else + ++error; + else have_bg = TRUE; } } else { @@ -279,15 +282,17 @@ int main(int argc, char **argv) "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n" " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" " exp \ttransfer-function exponent (``gamma'') of the display\n" - "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" + "\t\t system in floating-point format (e.g., ``%.1f''); equal\n", + PROGNAME, default_display_exponent); + + fprintf(stderr, "\n" "\t\t to the product of the lookup-table exponent (varies)\n" "\t\t and the CRT exponent (usually 2.2); must be positive\n" " bg \tdesired background color in 7-character hex RGB format\n" "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" "\t\t used with transparent images\n" "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, default_display_exponent); + "is displayed) to quit.\n"); exit(1); } @@ -419,6 +424,8 @@ int main(int argc, char **argv) rpng_x_cleanup(); + (void)argc; /* Unused */ + return 0; } diff --git a/libs/libpng-src/contrib/gregbook/rpng2-win.c b/libs/libpng-src/contrib/gregbook/rpng2-win.c index 9f7ad78dd..ed6b526ec 100644 --- a/libs/libpng-src/contrib/gregbook/rpng2-win.c +++ b/libs/libpng-src/contrib/gregbook/rpng2-win.c @@ -32,10 +32,12 @@ - 2.01: fixed 64-bit typo in readpng2.c - 2.02: fixed improper display of usage screen on PNG error(s); fixed unexpected-EOF and file-read-error cases + - 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options + - 2.04: check for integer overflow (Glenn R-P) --------------------------------------------------------------------------- - Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -95,7 +97,33 @@ #include #include /* only for PvdM background code */ #include +#ifdef __CYGWIN__ +/* getch replacement. Turns out, we don't really need this, + * but leave it here if we ever enable any of the uses of + * _getch in the main code + */ +#include +#include +#include +int repl_getch( void ) +{ + char ch; + int fd = fileno(stdin); + struct termio old_tty, new_tty; + + ioctl(fd, TCGETA, &old_tty); + new_tty = old_tty; + new_tty.c_lflag &= ~(ICANON | ECHO | ISIG); + ioctl(fd, TCSETA, &new_tty); + fread(&ch, 1, sizeof(ch), stdin); + ioctl(fd, TCSETA, &old_tty); + + return ch; +} +#define _getch repl_getch +#else #include /* only for _getch() */ +#endif /* all for PvdM background code: */ #ifndef PI @@ -269,16 +297,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) filename = (char *)NULL; memset(&rpng2_info, 0, sizeof(mainprog_info)); - +#ifndef __CYGWIN__ /* Next reenable console output, which normally goes to the bit bucket * for windowed apps. Closing the console window will terminate the - * app. Thanks to David.Geldreich@realviz.com for supplying the magical + * app. Thanks to David.Geldreich at realviz.com for supplying the magical * incantation. */ AllocConsole(); freopen("CONOUT$", "a", stderr); freopen("CONOUT$", "a", stdout); - +#endif /* Set the default value for our display-system exponent, i.e., the * product of the CRT exponent and the exponent corresponding to @@ -395,18 +423,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) } } else if (!strncmp(*argv, "-timing", 2)) { timing = TRUE; -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; -#endif } else { if (**argv != '-') { filename = *argv; @@ -424,15 +440,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) /* print usage screen if any errors up to this point */ if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng2_version_info(); fprintf(stderr, "\n" "Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n" -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif " %*s file.png\n\n" " exp \ttransfer-function exponent (``gamma'') of the display\n" "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" @@ -445,21 +460,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) "\t\t transparent images; overrides -bgcolor option\n" " -timing\tenables delay for every block read, to simulate modem\n" "\t\t download of image (~36 Kbps)\n" -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" -#endif "\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n" +#ifndef __CYGWIN__ "Press Q or Esc to quit this usage screen. ", +#else + , +#endif PROGNAME, -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) +#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \ + !(defined(__CYGWIN__) || defined(__MINGW32__)) (int)strlen(PROGNAME), " ", #endif (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat); fflush(stderr); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(1); } @@ -496,18 +514,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) if (error) { +#ifndef __CYGWIN__ int ch; +#endif fprintf(stderr, PROGNAME ": aborting.\n"); +#ifndef __CYGWIN__ do ch = _getch(); while (ch != 'q' && ch != 'Q' && ch != 0x1B); +#endif exit(2); } else { fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname); +#ifndef __CYGWIN__ fprintf(stderr, "\n [console window: closing this window will terminate %s]\n\n", PROGNAME); +#endif fflush(stderr); } @@ -567,7 +591,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode) "(unexpectedly) while reading PNG image file\n"); exit(3); } else /* if (error) */ { - // will print error message below + /* will print error message below */ } break; } @@ -625,6 +649,13 @@ static void rpng2_win_init() Trace((stderr, " width = %ld\n", rpng2_info.width)) Trace((stderr, " height = %ld\n", rpng2_info.height)) + /* Guard against integer overflow */ + if (rpng2_info.height > ((size_t)(-1))/rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n", + readpng2_cleanup(&rpng2_info); + return; + } + rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); if (!rpng2_info.image_data) { readpng2_cleanup(&rpng2_info); @@ -1150,7 +1181,12 @@ static void rpng2_win_finish_display() rpng2_info.state = kDone; printf( - "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"); +#ifndef __CYGWIN__ + "Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n" +#else + "Done. Press mouse button 1 (within image window) to quit.\n" +#endif + ); fflush(stdout); } diff --git a/libs/libpng-src/contrib/gregbook/rpng2-x.c b/libs/libpng-src/contrib/gregbook/rpng2-x.c index 873af2335..af944c0f2 100644 --- a/libs/libpng-src/contrib/gregbook/rpng2-x.c +++ b/libs/libpng-src/contrib/gregbook/rpng2-x.c @@ -40,10 +40,15 @@ - 2.02: fixed improper display of usage screen on PNG error(s); fixed unexpected-EOF and file-read-error cases; fixed Trace() cut-and- paste bugs - + - 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options + - 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings + about unused variables (GR-P) + - 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P). + - 2.06: check for integer overflow (Glenn R-P) --------------------------------------------------------------------------- - Copyright (c) 1998-2008 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2010, 2014-2015, 2017 Greg Roelofs. All rights + reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -94,9 +99,9 @@ #define PROGNAME "rpng2-x" #define LONGNAME "Progressive PNG Viewer for X" -#define VERSION "2.02 of 16 March 2008" -#define RESNAME "rpng2" /* our X resource application name */ -#define RESCLASS "Rpng" /* our X resource class name */ +#define VERSION "2.04 of 15 June 2014" +#define RESNAME "rpng2" /* our X resource application name */ +#define RESCLASS "Rpng" /* our X resource class name */ #include #include @@ -110,6 +115,19 @@ #include #include /* defines XK_* macros */ +#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */ +# undef usleep +# define usleep(usec) { \ + struct timespec ts; \ + ts.tv_sec = 0; \ + ts.tv_nsec = (usec) * 1000; \ + nanosleep(&ts, NULL); } +# endif + +#ifndef usleep /* have neither nanosleep() nor usleep() */ +# define usleep(x) sleep(((x)+499999)/1000000) +#endif + #ifdef VMS # include #endif @@ -131,7 +149,7 @@ (e.type == KeyPress && /* v--- or 1 for shifted keys */ \ ((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape))) -#define NO_24BIT_MASKS /* undef case not fully written--only for redisplay() */ +#define NO_24BIT_MASKS /* undef case not fully written--only for redisplay() */ #define rgb1_max bg_freq #define rgb1_min bg_gray @@ -301,7 +319,7 @@ int main(int argc, char **argv) int have_bg = FALSE; #ifdef FEATURE_LOOP int loop = FALSE; - long loop_interval = -1; /* seconds (100,000 max) */ + long loop_interval = -1; /* seconds (100,000 max) */ #endif double LUT_exponent; /* just the lookup table */ double CRT_exponent = 2.2; /* just the monitor */ @@ -434,18 +452,6 @@ int main(int argc, char **argv) else if (loop_interval > 100000) /* bit more than one day */ loop_interval = 100000; } -#endif -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - } else if (!strncmp(*argv, "-nommxfilters", 7)) { - rpng2_info.nommxfilters = TRUE; - } else if (!strncmp(*argv, "-nommxcombine", 7)) { - rpng2_info.nommxcombine = TRUE; - } else if (!strncmp(*argv, "-nommxinterlace", 7)) { - rpng2_info.nommxinterlace = TRUE; - } else if (!strcmp(*argv, "-nommx")) { - rpng2_info.nommxfilters = TRUE; - rpng2_info.nommxcombine = TRUE; - rpng2_info.nommxinterlace = TRUE; #endif } else { if (**argv != '-') { @@ -467,50 +473,47 @@ int main(int argc, char **argv) fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname); readpng2_version_info(); fprintf(stderr, "\n" - "Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n" -#endif + "Usage: "); + fprintf(stderr, + "%s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n" + " %*s [-usleep dur | -timing] [-pause]\n", + PROGNAME, (int)strlen(PROGNAME), " "); + fprintf(stderr, #ifdef FEATURE_LOOP - " %*s [-usleep dur | -timing] [-pause] [-loop [sec]] file.png\n\n" -#else - " %*s [-usleep dur | -timing] [-pause] file.png\n\n" + " [-loop [sec]]" #endif + " file.png\n\n"); + fprintf(stderr, " xdpy\tname of the target X display (e.g., ``hostname:0'')\n" " exp \ttransfer-function exponent (``gamma'') of the display\n" "\t\t system in floating-point format (e.g., ``%.1f''); equal\n" - "\t\t to the product of the lookup-table exponent (varies)\n" + "\t\t to the product of the lookup-table exponent (varies)\n", + default_display_exponent); + fprintf(stderr, "\t\t and the CRT exponent (usually 2.2); must be positive\n" " bg \tdesired background color in 7-character hex RGB format\n" "\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n" "\t\t used with transparent images; overrides -bgpat\n" " pat \tdesired background pattern number (0-%d); used with\n" - "\t\t transparent images; overrides -bgcolor\n" + "\t\t transparent images; overrides -bgcolor\n", + num_bgpat-1); #ifdef FEATURE_LOOP + fprintf(stderr, " -loop\tloops through background images after initial display\n" "\t\t is complete (depends on -bgpat)\n" - " sec \tseconds to display each background image (default = 2)\n" -#endif -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - " -nommx*\tdisable optimized MMX routines for decoding row filters,\n" - "\t\t combining rows, and expanding interlacing, respectively\n" + " sec \tseconds to display each background image (default = 2)\n"); #endif + fprintf(stderr, " dur \tduration in microseconds to wait after displaying each\n" "\t\t row (for demo purposes)\n" " -timing\tenables delay for every block read, to simulate modem\n" "\t\t download of image (~36 Kbps)\n" " -pause\tpauses after displaying each pass until mouse clicked\n" "\nPress Q, Esc or mouse button 1 (within image window, after image\n" - "is displayed) to quit.\n" - "\n", PROGNAME, -#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) - (int)strlen(PROGNAME), " ", -#endif - (int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1); + "is displayed) to quit.\n"); exit(1); } - if (!(infile = fopen(filename, "rb"))) { fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename); ++error; @@ -612,7 +615,7 @@ int main(int argc, char **argv) "(unexpectedly) while reading PNG image file\n"); exit(3); } else /* if (error) */ { - // will print error message below + /* will print error message below */ } break; } @@ -756,6 +759,8 @@ int main(int argc, char **argv) Trace((stderr, "about to call rpng2_x_cleanup()\n")) rpng2_x_cleanup(); + (void)argc; /* Unused */ + return 0; } @@ -777,6 +782,13 @@ static void rpng2_x_init(void) Trace((stderr, " width = %ld\n", rpng2_info.width)) Trace((stderr, " height = %ld\n", rpng2_info.height)) + /* Guard against integer overflow */ + if (rpng2_info.height > ((size_t)(-1))/rpng2_info.rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer would be too large\n"); + readpng2_cleanup(&rpng2_info); + return; + } + rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height); if (!rpng2_info.image_data) { readpng2_cleanup(&rpng2_info); @@ -802,8 +814,9 @@ static void rpng2_x_init(void) if (rpng2_x_create_window()) { /* GRR TEMPORARY HACK: this is fundamentally no different from cases - * above; libpng should longjmp() back to us when png_ptr goes away. - * If we/it segfault instead, seems like a libpng bug... */ + * above; libpng should call our error handler to longjmp() back to us + * when png_ptr goes away. If we/it segfault instead, seems like a + * libpng bug... */ /* we're here via libpng callback, so if window fails, clean and bail */ readpng2_cleanup(&rpng2_info); @@ -1297,7 +1310,7 @@ static int rpng2_x_load_bg_image(void) for (row = 0; row < rpng2_info.height; ++row) { src = bg_data + row*bg_rowbytes; dest = ximage->data + row*ximage_rowbytes; - if (bpp == 32) { /* slightly optimized version */ + if (bpp == 32) { /* slightly optimized version */ for (i = rpng2_info.width; i > 0; --i) { red = *src++; green = *src++; @@ -1846,6 +1859,9 @@ static void rpng2_x_redisplay_image(ulg startcol, ulg startrow, XFlush(display); } + (void)startcol; + (void)width; + } /* end function rpng2_x_redisplay_image() */ diff --git a/libs/libpng-src/contrib/gregbook/wpng.c b/libs/libpng-src/contrib/gregbook/wpng.c index a06e3529e..a8f367fb8 100644 --- a/libs/libpng-src/contrib/gregbook/wpng.c +++ b/libs/libpng-src/contrib/gregbook/wpng.c @@ -29,6 +29,7 @@ - 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix (see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff) - 2.00: dual-licensed (added GNU GPL) + - 2.01: check for integer overflow (Glenn R-P) [REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line dose not work! In order to do something useful I needed to redirect @@ -38,7 +39,7 @@ --------------------------------------------------------------------------- - Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -702,7 +703,18 @@ int main(int argc, char **argv) if (wpng_info.interlaced) { long i; ulg bytes; - ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */ + ulg image_bytes; + + /* Guard against integer overflow */ + if (wpng_info_height > ((size_t)(-1)/rowbytes || + wpng_info_height > ((ulg)(-1)/rowbytes) { + fprintf(stderr, PROGNAME ": image_data buffer too large\n"); + writepng_cleanup(&wpng_info); + wpng_cleanup(); + exit(5); + } + + image_bytes = rowbytes * wpng_info.height; wpng_info.image_data = (uch *)malloc(image_bytes); wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *)); diff --git a/libs/libpng-src/contrib/gregbook/writepng.c b/libs/libpng-src/contrib/gregbook/writepng.c index e6d81ea40..055c74374 100644 --- a/libs/libpng-src/contrib/gregbook/writepng.c +++ b/libs/libpng-src/contrib/gregbook/writepng.c @@ -4,7 +4,7 @@ --------------------------------------------------------------------------- - Copyright (c) 1998-2007 Greg Roelofs. All rights reserved. + Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved. This software is provided "as is," without warranty of any kind, express or implied. In no event shall the author or contributors @@ -55,8 +55,9 @@ #include /* for exit() prototype */ +#include -#include "png.h" /* libpng header; includes zlib.h and setjmp.h */ +#include "png.h" /* libpng header, includes setjmp.h */ #include "writepng.h" /* typedefs, common macros, public prototypes */ @@ -89,7 +90,7 @@ int writepng_init(mainprog_info *mainprog_ptr) /* could also replace libpng warning-handler (final NULL), but no need: */ - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr, + png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr, writepng_error_handler, NULL); if (!png_ptr) return 4; /* out of memory */ @@ -104,7 +105,8 @@ int writepng_init(mainprog_info *mainprog_ptr) /* setjmp() must be called in every function that calls a PNG-writing * libpng function, unless an alternate error handler was installed-- * but compatible error handlers must either use longjmp() themselves - * (as in this program) or exit immediately, so here we go: */ + * (as in this program) or some other method to return control to + * application code, so here we go: */ if (setjmp(mainprog_ptr->jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); @@ -388,5 +390,12 @@ static void writepng_error_handler(png_structp png_ptr, png_const_charp msg) exit(99); } + /* Now we have our data structure we can use the information in it + * to return control to our own higher level code (all the points + * where 'setjmp' is called in this file.) This will work with other + * error handling mechanisms as well - libpng always calls png_error + * when it can proceed no further, thus, so long as the error handler + * is intercepted, application code can do its own error recovery. + */ longjmp(mainprog_ptr->jmpbuf, 1); } diff --git a/libs/libpng-src/contrib/libtests/fakepng.c b/libs/libpng-src/contrib/libtests/fakepng.c new file mode 100644 index 000000000..6512c1401 --- /dev/null +++ b/libs/libpng-src/contrib/libtests/fakepng.c @@ -0,0 +1,65 @@ +/* Fake a PNG - just write it out directly. + * + * COPYRIGHT: Written by John Cunningham Bowler, 2014. + * To the extent possible under law, the author has waived all copyright and + * related or neighboring rights to this work. This work is published from: + * United States. + * + */ + +#include +#include /* for crc32 */ + +void +put_uLong(uLong val) +{ + putchar(val >> 24); + putchar(val >> 16); + putchar(val >> 8); + putchar(val >> 0); +} + +void +put_chunk(const unsigned char *chunk, uInt length) +{ + uLong crc; + + put_uLong(length-4); /* Exclude the tag */ + + fwrite(chunk, length, 1, stdout); + + crc = crc32(0, Z_NULL, 0); + put_uLong(crc32(crc, chunk, length)); +} + +const unsigned char signature[] = +{ + 137, 80, 78, 71, 13, 10, 26, 10 +}; + +const unsigned char IHDR[] = +{ + 73, 72, 68, 82, /* IHDR */ + 0, 0, 0, 1, /* width */ + 0, 0, 0, 1, /* height */ + 1, /* bit depth */ + 0, /* color type: greyscale */ + 0, /* compression method */ + 0, /* filter method */ + 0 /* interlace method: none */ +}; + +const unsigned char unknown[] = +{ + 'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */ +}; + +int +main(void) +{ + fwrite(signature, sizeof signature, 1, stdout); + put_chunk(IHDR, sizeof IHDR); + + for (;;) + put_chunk(unknown, sizeof unknown); +} diff --git a/libs/libpng-src/contrib/libtests/gentests.sh b/libs/libpng-src/contrib/libtests/gentests.sh new file mode 100644 index 000000000..f0f8d2395 --- /dev/null +++ b/libs/libpng-src/contrib/libtests/gentests.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# +# Copyright (c) 2013 John Cunningham Bowler +# +# Last changed in libpng 1.6.0 [February 14, 2013] +# +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h +# +# Generate a set of PNG test images. The images are generated in a +# sub-directory called 'tests' by default, however a command line argument will +# change that name. The generation requires a built version of makepng in the +# current directory. +# +usage(){ + exec >&2 + echo "$0 []" + echo ' Generate a set of PNG test files in "directory" ("tests" by default)' + exit 1 +} + +mp="$PWD/makepng" +test -x "$mp" || { + exec >&2 + echo "$0: the 'makepng' program must exist" + echo " in the directory within which this program:" + echo " $mp" + echo " is executed" + usage +} + +# Just one argument: the directory +testdir="tests" +test $# -gt 1 && { + testdir="$1" + shift +} +test $# -eq 0 || usage + +# Take care not to clobber something +if test -e "$testdir" +then + test -d "$testdir" || usage +else + # mkdir -p isn't portable, so do the following + mkdir "$testdir" 2>/dev/null || mkdir -p "$testdir" || usage +fi + +# This fails in a very satisfactory way if it's not accessible +cd "$testdir" +:>"test$$.png" || { + exec >&2 + echo "$testdir: directory not writable" + usage +} +rm "test$$.png" || { + exec >&2 + echo "$testdir: you have create but not write privileges here." + echo " This is unexpected. You have a spurion; "'"'"test$$.png"'"'"." + echo " You need to remove this yourself. Try a different directory." + exit 1 +} + +# Now call makepng ($mp) to create every file we can think of with a +# reasonable name +doit(){ + for gamma in "" --sRGB --linear --1.8 + do + case "$gamma" in + "") + gname=;; + --sRGB) + gname="-srgb";; + --linear) + gname="-lin";; + --1.8) + gname="-18";; + *) + gname="-$gamma";; + esac + "$mp" $gamma "$1" "$2" "test-$1-$2$gname.png" + done +} +# +for ct in gray palette +do + for bd in 1 2 4 8 + do + doit "$ct" "$bd" + done +done +# +doit "gray" "16" +# +for ct in gray-alpha rgb rgb-alpha +do + for bd in 8 16 + do + doit "$ct" "$bd" + done +done diff --git a/libs/libpng-src/contrib/libtests/makepng.c b/libs/libpng-src/contrib/libtests/makepng.c new file mode 100644 index 000000000..312062bda --- /dev/null +++ b/libs/libpng-src/contrib/libtests/makepng.c @@ -0,0 +1,1941 @@ +/* makepng.c */ +#define _ISOC99_SOURCE +/* Copyright: */ +#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler" +/* + * Last changed in libpng 1.6.20 [November 24, 2015] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * Make a test PNG image. The arguments are as follows: + * + * makepng [--sRGB|--linear|--1.8] [--tRNS] [--nofilters] \ + * color-type bit-depth [file-name] + * + * The color-type may be numeric (and must match the numbers used by the PNG + * specification) or one of the format names listed below. The bit-depth is the + * component bit depth, or the pixel bit-depth for a color-mapped image. + * + * Without any options no color-space information is written, with the options + * an sRGB or the appropriate gAMA chunk is written. "1.8" refers to the + * display system used on older Apple computers to correct for high ambient + * light levels in the viewing environment; it applies a transform of + * approximately value^(1/1.45) to the color values and so a gAMA chunk of 65909 + * is written (1.45/2.2). + * + * The image data is generated internally. Unless --color is given the images + * used are as follows: + * + * 1 channel: a square image with a diamond, the least luminous colors are on + * the edge of the image, the most luminous in the center. + * + * 2 channels: the color channel increases in luminosity from top to bottom, the + * alpha channel increases in opacity from left to right. + * + * 3 channels: linear combinations of, from the top-left corner clockwise, + * black, green, white, red. + * + * 4 channels: linear combinations of, from the top-left corner clockwise, + * transparent, red, green, blue. + * + * For color-mapped images a four channel color-map is used and if --tRNS is + * given the PNG file has a tRNS chunk, as follows: + * + * 1-bit: entry 0 is transparent-red, entry 1 is opaque-white + * 2-bit: entry 0: transparent-green + * entry 1: 40%-red + * entry 2: 80%-blue + * entry 3: opaque-white + * 4-bit: the 16 combinations of the 2-bit case + * 8-bit: the 256 combinations of the 4-bit case + * + * The palette always has 2^bit-depth entries and the tRNS chunk one fewer. The + * image is the 1-channel diamond, but using palette index, not luminosity. + * + * For formats other than color-mapped ones if --tRNS is specified a tRNS chunk + * is generated with all channels equal to the low bits of 0x0101. + * + * Image size is determined by the final pixel depth in bits, i.e. channels x + * bit-depth, as follows: + * + * 8 bits or less: 64x64 + * 16 bits: 256x256 + * More than 16 bits: 1024x1024 + * + * Row filtering is the libpng default but may be turned off (the 'none' filter + * is used on every row) with the --nofilters option. + * + * The images are not interlaced. + * + * If file-name is given then the PNG is written to that file, else it is + * written to stdout. Notice that stdout is not supported on systems where, by + * default, it assumes text output; this program makes no attempt to change the + * text mode of stdout! + * + * makepng --color= ... + * + * If --color is given then the whole image has that color, color-mapped images + * will have exactly one palette entry and all image files with be 16x16 in + * size. The color value is 1 to 4 decimal numbers as appropriate for the color + * type. + * + * makepng --small ... + * + * If --small is given the images are no larger than required to include every + * possible pixel value for the format. + * + * For formats with pixels 8 bits or fewer in size the images consist of a + * single row with 2^pixel-depth pixels, one of every possible value. + * + * For formats with 16-bit pixels a 256x256 image is generated containing every + * possible pixel value. + * + * For larger pixel sizes a 256x256 image is generated where the first row + * consists of each pixel that has identical byte values throughout the pixel + * followed by rows where the byte values differ within the pixel. + * + * In all cases the pixel values are arranged in such a way that the SUB and UP + * filters give byte sequences for maximal zlib compression. By default (if + * --nofilters is not given) the SUB filter is used on the first row and the UP + * filter on all following rows. + * + * The --small option is meant to provide good test-case coverage, however the + * images are not easy to examine visually. Without the --small option the + * images contain identical color values; the pixel values are adjusted + * according to the gamma encoding with no gamma encoding being interpreted as + * sRGB. + * + * LICENSING + * ========= + * + * This code is copyright of the authors, see the COPYRIGHT define above. The + * code is licensed as above, using the libpng license. The code generates + * images which are solely the product of the code; the options choose which of + * the many possibilities to generate. The images that result (but not the code + * which generates them) are licensed as defined here: + * + * IMPORTANT: the COPYRIGHT #define must contain ISO-Latin-1 characters, the + * IMAGE_LICENSING #define must contain UTF-8 characters. The 'copyright' + * symbol 0xA9U (\251) in ISO-Latin-1 encoding and 0xC20xA9 (\302\251) in UTF-8. + */ +#define IMAGE_LICENSING "Dedicated to the public domain per Creative Commons "\ + "license \"CC0 1.0\"; https://creativecommons.org/publicdomain/zero/1.0/" + +#include /* for offsetof */ +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#include + +/* Work round for GCC complaints about casting a (double) function result to + * an unsigned: + */ +static unsigned int +flooru(double d) +{ + d = floor(d); + return (unsigned int)d; +} + +static png_byte +floorb(double d) +{ + d = floor(d); + return (png_byte)d; +} + +/* This structure is used for inserting extra chunks (the --insert argument, not + * documented above.) + */ +typedef struct chunk_insert +{ + struct chunk_insert *next; + void (*insert)(png_structp, png_infop, int, png_charpp); + int nparams; + png_charp parameters[1]; +} chunk_insert; + +static unsigned int +channels_of_type(int color_type) +{ + if (color_type & PNG_COLOR_MASK_PALETTE) + return 1; + + else + { + int channels = 1; + + if (color_type & PNG_COLOR_MASK_COLOR) + channels = 3; + + if (color_type & PNG_COLOR_MASK_ALPHA) + return channels + 1; + + else + return channels; + } +} + +static unsigned int +pixel_depth_of_type(int color_type, int bit_depth) +{ + return channels_of_type(color_type) * bit_depth; +} + +static unsigned int +image_size_of_type(int color_type, int bit_depth, unsigned int *colors, + int small) +{ + if (*colors) + return 16; + + else + { + int pixel_depth = pixel_depth_of_type(color_type, bit_depth); + + if (small) + { + if (pixel_depth <= 8) /* there will be one row */ + return 1 << pixel_depth; + + else + return 256; + } + + else if (pixel_depth < 8) + return 64; + + else if (pixel_depth > 16) + return 1024; + + else + return 256; + } +} + +static void +set_color(png_colorp color, png_bytep trans, unsigned int red, + unsigned int green, unsigned int blue, unsigned int alpha, + png_const_bytep gamma_table) +{ + color->red = gamma_table[red]; + color->green = gamma_table[green]; + color->blue = gamma_table[blue]; + *trans = (png_byte)alpha; +} + +static int +generate_palette(png_colorp palette, png_bytep trans, int bit_depth, + png_const_bytep gamma_table, unsigned int *colors) +{ + /* + * 1-bit: entry 0 is transparent-red, entry 1 is opaque-white + * 2-bit: entry 0: transparent-green + * entry 1: 40%-red + * entry 2: 80%-blue + * entry 3: opaque-white + * 4-bit: the 16 combinations of the 2-bit case + * 8-bit: the 256 combinations of the 4-bit case + */ + switch (colors[0]) + { + default: + fprintf(stderr, "makepng: --colors=...: invalid count %u\n", + colors[0]); + exit(1); + + case 1: + set_color(palette+0, trans+0, colors[1], colors[1], colors[1], 255, + gamma_table); + return 1; + + case 2: + set_color(palette+0, trans+0, colors[1], colors[1], colors[1], + colors[2], gamma_table); + return 1; + + case 3: + set_color(palette+0, trans+0, colors[1], colors[2], colors[3], 255, + gamma_table); + return 1; + + case 4: + set_color(palette+0, trans+0, colors[1], colors[2], colors[3], + colors[4], gamma_table); + return 1; + + case 0: + if (bit_depth == 1) + { + set_color(palette+0, trans+0, 255, 0, 0, 0, gamma_table); + set_color(palette+1, trans+1, 255, 255, 255, 255, gamma_table); + return 2; + } + + else + { + unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */ + unsigned int x, y; + volatile unsigned int ip = 0; + + for (x=0; x> 3; + + if (offset < rowbytes && (bit_depth < 16 || offset+1 < rowbytes)) + { + row += offset; + + switch (bit_depth) + { + case 1: + case 2: + case 4: + /* Don't gamma correct - values get smashed */ + { + unsigned int shift = (8 - bit_depth) - (x & 0x7U); + + mask <<= shift; + value = (value << shift) & mask; + *row = (png_byte)((*row & ~mask) | value); + } + return; + + default: + fprintf(stderr, "makepng: bad bit depth (internal error)\n"); + exit(1); + + case 16: + value = flooru(65535*pow(value/65535.,conv)+.5); + *row++ = (png_byte)(value >> 8); + *row = (png_byte)value; + return; + + case 8: + *row = gamma_table[value]; + return; + } + } + + else + { + fprintf(stderr, "makepng: row buffer overflow (internal error)\n"); + exit(1); + } + } + + else + { + fprintf(stderr, "makepng: component overflow (internal error)\n"); + exit(1); + } +} + +static int /* filter mask for row */ +generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type, + int bit_depth, png_const_bytep gamma_table, double conv, + unsigned int *colors, int small) +{ + int filters = 0; /* file *MASK*, 0 means the default, not NONE */ + png_uint_32 size_max = + image_size_of_type(color_type, bit_depth, colors, small)-1; + png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */ + + if (colors[0] == 0) if (small) + { + unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth); + + /* For pixel depths less than 16 generate a single row containing all the + * possible pixel values. For 16 generate all 65536 byte pair + * combinations in a 256x256 pixel array. + */ + switch (pixel_depth) + { + case 1: + assert(y == 0 && rowbytes == 1 && size_max == 1); + row[0] = 0x6CU; /* binary: 01101100, only top 2 bits used */ + filters = PNG_FILTER_NONE; + break; + + case 2: + assert(y == 0 && rowbytes == 1 && size_max == 3); + row[0] = 0x1BU; /* binary 00011011, all bits used */ + filters = PNG_FILTER_NONE; + break; + + case 4: + assert(y == 0 && rowbytes == 8 && size_max == 15); + row[0] = 0x01U; + row[1] = 0x23U; /* SUB gives 0x22U for all following bytes */ + row[2] = 0x45U; + row[3] = 0x67U; + row[4] = 0x89U; + row[5] = 0xABU; + row[6] = 0xCDU; + row[7] = 0xEFU; + filters = PNG_FILTER_SUB; + break; + + case 8: + /* The row will have all the pixel values in order starting with + * '1', the SUB filter will change every byte into '1' (including + * the last, which generates pixel value '0'). Since the SUB filter + * has value 1 this should result in maximum compression. + */ + assert(y == 0 && rowbytes == 256 && size_max == 255); + for (;;) + { + row[size_max] = 0xFFU & (size_max+1); + if (size_max == 0) + break; + --size_max; + } + filters = PNG_FILTER_SUB; + break; + + case 16: + /* Rows are generated such that each row has a constant difference + * between the first and second byte of each pixel and so that the + * difference increases by 1 at each row. The rows start with the + * first byte value of 0 and the value increases to 255 across the + * row. + * + * The difference starts at 1, so the first row is: + * + * 0 1 1 2 2 3 3 4 ... 254 255 255 0 + * + * This means that running the SUB filter on the first row produces: + * + * [SUB==1] 0 1 0 1 0 1... + * + * Then the difference is 2 on the next row, giving: + * + * 0 2 1 3 2 4 3 5 ... 254 0 255 1 + * + * When the UP filter is run on this libpng produces: + * + * [UP ==2] 0 1 0 1 0 1... + * + * And so on for all the remain rows to the final two * rows: + * + * row 254: 0 255 1 0 2 1 3 2 4 3 ... 254 253 255 254 + * row 255: 0 0 1 1 2 2 3 3 4 4 ... 254 254 255 255 + */ + assert(rowbytes == 512 && size_max == 255); + for (;;) + { + row[2*size_max ] = 0xFFU & size_max; + row[2*size_max+1] = 0xFFU & (size_max+y+1); + if (size_max == 0) + break; + --size_max; + } + /* The first row must include PNG_FILTER_UP so that libpng knows we + * need to keep it for the following row: + */ + filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP); + break; + + case 24: + case 32: + case 48: + case 64: + /* The rows are filled by an alogorithm similar to the above, in the + * first row pixel bytes are all equal, increasing from 0 by 1 for + * each pixel. In the second row the bytes within a pixel are + * incremented 1,3,5,7,... from the previous row byte. Using an odd + * number ensures all the possible byte values are used. + */ + assert(size_max == 255 && rowbytes == 256*(pixel_depth>>3)); + pixel_depth >>= 3; /* now in bytes */ + while (rowbytes > 0) + { + const size_t pixel_index = --rowbytes/pixel_depth; + + if (y == 0) + row[rowbytes] = 0xFFU & pixel_index; + + else + { + const size_t byte_offset = + rowbytes - pixel_index * pixel_depth; + + row[rowbytes] = + 0xFFU & (pixel_index + (byte_offset * 2*y) + 1); + } + } + filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP); + break; + + default: + assert(0/*NOT REACHED*/); + } + } + + else switch (channels_of_type(color_type)) + { + /* 1 channel: a square image with a diamond, the least luminous colors are on + * the edge of the image, the most luminous in the center. + */ + case 1: + { + png_uint_32 x; + png_uint_32 base = 2*size_max - abs(2*y-size_max); + + for (x=0; x<=size_max; ++x) + { + png_uint_32 luma = base - abs(2*x-size_max); + + /* 'luma' is now in the range 0..2*size_max, we need + * 0..depth_max + */ + luma = (luma*depth_max + size_max) / (2*size_max); + set_value(row, rowbytes, x, bit_depth, luma, gamma_table, conv); + } + } + break; + + /* 2 channels: the color channel increases in luminosity from top to bottom, + * the alpha channel increases in opacity from left to right. + */ + case 2: + { + png_uint_32 alpha = (depth_max * y * 2 + size_max) / (2 * size_max); + png_uint_32 x; + + for (x=0; x<=size_max; ++x) + { + set_value(row, rowbytes, 2*x, bit_depth, + (depth_max * x * 2 + size_max) / (2 * size_max), gamma_table, + conv); + set_value(row, rowbytes, 2*x+1, bit_depth, alpha, gamma_table, + conv); + } + } + break; + + /* 3 channels: linear combinations of, from the top-left corner clockwise, + * black, green, white, red. + */ + case 3: + { + /* x0: the black->red scale (the value of the red component) at the + * start of the row (blue and green are 0). + * x1: the green->white scale (the value of the red and blue + * components at the end of the row; green is depth_max). + */ + png_uint_32 Y = (depth_max * y * 2 + size_max) / (2 * size_max); + png_uint_32 x; + + /* Interpolate x/depth_max from start to end: + * + * start end difference + * red: Y Y 0 + * green: 0 depth_max depth_max + * blue: 0 Y Y + */ + for (x=0; x<=size_max; ++x) + { + set_value(row, rowbytes, 3*x+0, bit_depth, /* red */ Y, + gamma_table, conv); + set_value(row, rowbytes, 3*x+1, bit_depth, /* green */ + (depth_max * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 3*x+2, bit_depth, /* blue */ + (Y * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + } + } + break; + + /* 4 channels: linear combinations of, from the top-left corner clockwise, + * transparent, red, green, blue. + */ + case 4: + { + /* x0: the transparent->blue scale (the value of the blue and alpha + * components) at the start of the row (red and green are 0). + * x1: the red->green scale (the value of the red and green + * components at the end of the row; blue is 0 and alpha is + * depth_max). + */ + png_uint_32 Y = (depth_max * y * 2 + size_max) / (2 * size_max); + png_uint_32 x; + + /* Interpolate x/depth_max from start to end: + * + * start end difference + * red: 0 depth_max-Y depth_max-Y + * green: 0 Y Y + * blue: Y 0 -Y + * alpha: Y depth_max depth_max-Y + */ + for (x=0; x<=size_max; ++x) + { + set_value(row, rowbytes, 4*x+0, bit_depth, /* red */ + ((depth_max-Y) * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 4*x+1, bit_depth, /* green */ + (Y * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 4*x+2, bit_depth, /* blue */ + Y - (Y * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + set_value(row, rowbytes, 4*x+3, bit_depth, /* alpha */ + Y + ((depth_max-Y) * x * 2 + size_max) / (2 * size_max), + gamma_table, conv); + } + } + break; + + default: + fprintf(stderr, "makepng: internal bad channel count\n"); + exit(2); + } + + else if (color_type & PNG_COLOR_MASK_PALETTE) + { + /* Palette with fixed color: the image rows are all 0 and the image width + * is 16. + */ + memset(row, 0, rowbytes); + } + + else if (colors[0] == channels_of_type(color_type)) + switch (channels_of_type(color_type)) + { + case 1: + { + png_uint_32 luma = colors[1]; + png_uint_32 x; + + for (x=0; x<=size_max; ++x) + set_value(row, rowbytes, x, bit_depth, luma, gamma_table, + conv); + } + break; + + case 2: + { + png_uint_32 luma = colors[1]; + png_uint_32 alpha = colors[2]; + png_uint_32 x; + + for (x=0; x 0 && gamma < 1000) + gamma = PNG_FP_1; + + if (gamma > 0) + real_gamma = gamma; + + { + unsigned int i; + + if (real_gamma == 45455) for (i=0; i<256; ++i) + { + gamma_table[i] = (png_byte)i; + conv = 1.; + } + + else + { + /* Convert 'i' from sRGB (45455) to real_gamma, this makes + * the images look the same regardless of the gAMA chunk. + */ + conv = real_gamma; + conv /= 45455; + + gamma_table[0] = 0; + + for (i=1; i<255; ++i) + gamma_table[i] = floorb(pow(i/255.,conv) * 255 + .5); + + gamma_table[255] = 255; + } + } + + png_set_IHDR(png_ptr, info_ptr, size, ysize, bit_depth, color_type, + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + if (color_type & PNG_COLOR_MASK_PALETTE) + { + int npalette; + png_color palette[256]; + png_byte trans[256]; + + npalette = generate_palette(palette, trans, bit_depth, gamma_table, + colors); + png_set_PLTE(png_ptr, info_ptr, palette, npalette); + + if (tRNS) + png_set_tRNS(png_ptr, info_ptr, trans, npalette-1, + NULL/*transparent color*/); + + /* Reset gamma_table to prevent the image rows being changed */ + for (npalette=0; npalette<256; ++npalette) + gamma_table[npalette] = (png_byte)npalette; + } + + else if (tRNS) + { + png_color_16 col; + + col.red = col.green = col.blue = col.gray = + 0x0101U & ((1U< 0) /* Else don't set color space information */ + { + png_set_gAMA_fixed(png_ptr, info_ptr, real_gamma); + + /* Just use the sRGB values here. */ + png_set_cHRM_fixed(png_ptr, info_ptr, + /* color x y */ + /* white */ 31270, 32900, + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000 + ); + } + + /* Insert extra information. */ + while (insert != NULL) + { + insert->insert(png_ptr, info_ptr, insert->nparams, insert->parameters); + insert = insert->next; + } + + /* Write the file header. */ + png_write_info(png_ptr, info_ptr); + + /* Restrict the filters */ + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters); + + { +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + int passes = png_set_interlace_handling(png_ptr); +# else /* !WRITE_INTERLACING */ + int passes = 1; +# endif /* !WRITE_INTERLACING */ + int pass; + size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr); + + row = malloc(rowbytes); + + if (row == NULL) + png_error(png_ptr, "OOM allocating row buffer"); + + for (pass = 0; pass < passes; ++pass) + { + unsigned int y; + + for (y=0; y 0) + { + /* Round up to a multiple of 4 here to allow an iCCP profile + * to be padded to a 4x boundary. + */ + png_bytep data = malloc((total+3)&~3); + + if (data != NULL) + { + size_t new_size = 0; + + for (;;) + { + ch = getc(fp); + if (ch == EOF) break; + data[new_size++] = (png_byte)ch; + } + + if (ferror(fp) || new_size != total) + { + perror("temporary file"); + fprintf(stderr, "temporary file read error\n"); + free(data); + } + + else + { + (void)fclose(fp); + *result = data; + return total; + } + } + + else + fprintf(stderr, "%s: out of memory loading file\n", name); + } + + else + fprintf(stderr, "%s: empty file\n", name); + } + } + } + + else + { + perror(name); + fprintf(stderr, "%s: open failed\n", name); + } + + fclose(fp); + } + + else + fprintf(stderr, "makepng: %s: could not open temporary file\n", name); + + exit(1); + return 0; +} + +static size_t +load_fake(png_charp param, png_bytepp profile) +{ + char *endptr = NULL; + uint64_t size = strtoull(param, &endptr, 0/*base*/); + + /* The 'fake' format is *[string] */ + if (endptr != NULL && *endptr == '*') + { + size_t len = strlen(++endptr); + size_t result = (size_t)size; + + if (len == 0) len = 1; /* capture the terminating '\0' */ + + /* Now repeat that string to fill 'size' bytes. */ + if (result == size && (*profile = malloc(result)) != NULL) + { + png_bytep out = *profile; + + if (len == 1) + memset(out, *endptr, result); + + else + { + while (size >= len) + { + memcpy(out, endptr, len); + out += len; + size -= len; + } + memcpy(out, endptr, size); + } + + return result; + } + + else + { + fprintf(stderr, "%s: size exceeds system limits\n", param); + exit(1); + } + } + + return 0; +} + +static void +check_param_count(int nparams, int expect) +{ + if (nparams != expect) + { + fprintf(stderr, "bad parameter count (internal error)\n"); + exit(1); + } +} + +static void +insert_iCCP(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_bytep profile = NULL; + png_uint_32 proflen = 0; + int result; + + check_param_count(nparams, 2); + + switch (params[1][0]) + { + case '<': + { + size_t filelen = load_file(params[1]+1, &profile); + if (filelen > 0xfffffffc) /* Maximum profile length */ + { + fprintf(stderr, "%s: file too long (%lu) for an ICC profile\n", + params[1]+1, (unsigned long)filelen); + exit(1); + } + + proflen = (png_uint_32)filelen; + } + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + size_t fake_len = load_fake(params[1], &profile); + + if (fake_len > 0) /* else a simple parameter */ + { + if (fake_len > 0xffffffff) /* Maximum profile length */ + { + fprintf(stderr, + "%s: fake data too long (%lu) for an ICC profile\n", + params[1], (unsigned long)fake_len); + exit(1); + } + proflen = (png_uint_32)(fake_len & ~3U); + /* Always fix up the profile length. */ + png_save_uint_32(profile, proflen); + break; + } + } + + default: + fprintf(stderr, "--insert iCCP \"%s\": unrecognized\n", params[1]); + fprintf(stderr, " use '<' to read a file: \" 3) + { + png_uint_32 prof_header = png_get_uint_32(profile); + + if (prof_header != proflen) + { + fprintf(stderr, "--insert iCCP %s: profile length field wrong:\n", + params[1]); + fprintf(stderr, " actual %lu, recorded value %lu (corrected)\n", + (unsigned long)proflen, (unsigned long)prof_header); + png_save_uint_32(profile, proflen); + } + } + + if (result && profile != NULL && proflen >=4) + png_set_iCCP(png_ptr, info_ptr, params[0], PNG_COMPRESSION_TYPE_BASE, + profile, proflen); + + if (profile) + free(profile); + + if (!result) + exit(1); +} + +static void +clear_text(png_text *text, png_charp keyword) +{ + text->compression = -1; /* none */ + text->key = keyword; + text->text = NULL; + text->text_length = 0; /* libpng calculates this */ + text->itxt_length = 0; /* libpng calculates this */ + text->lang = NULL; + text->lang_key = NULL; +} + +static void +set_text(png_structp png_ptr, png_infop info_ptr, png_textp text, + png_charp param) +{ + switch (param[0]) + { + case '<': + { + png_bytep file = NULL; + + text->text_length = load_file(param+1, &file); + text->text = (png_charp)file; + } + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + { + png_bytep data = NULL; + size_t fake_len = load_fake(param, &data); + + if (fake_len > 0) /* else a simple parameter */ + { + text->text_length = fake_len; + text->text = (png_charp)data; + break; + } + } + + default: + text->text = param; + break; + } + + png_set_text(png_ptr, info_ptr, text, 1); + + if (text->text != param) + free(text->text); +} + +static void +insert_tEXt(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_text text; + + check_param_count(nparams, 2); + clear_text(&text, params[0]); + set_text(png_ptr, info_ptr, &text, params[1]); +} + +static void +insert_zTXt(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_text text; + + check_param_count(nparams, 2); + clear_text(&text, params[0]); + text.compression = 0; /* deflate */ + set_text(png_ptr, info_ptr, &text, params[1]); +} + +static void +insert_iTXt(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + png_text text; + + check_param_count(nparams, 4); + clear_text(&text, params[0]); + text.compression = 2; /* iTXt + deflate */ + text.lang = params[1];/* language tag */ + text.lang_key = params[2]; /* translated keyword */ + set_text(png_ptr, info_ptr, &text, params[3]); +} + +static void +insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, + png_charpp params) +{ + int i; + png_uint_16 freq[256]; + + /* libpng takes the count from the PLTE count; we don't check it here but we + * do set the array to 0 for unspecified entries. + */ + memset(freq, 0, sizeof freq); + for (i=0; inext = NULL; + cip->insert = insert; + cip->nparams = nparams; + for (i=0; iparameters[i] = list[i]; + + return cip; +} + +static chunk_insert * +find_insert(png_const_charp what, png_charp param) +{ + png_uint_32 chunk = 0; + png_charp parameter_list[1024]; + int i, nparams; + + /* Assemble the chunk name */ + for (i=0; i<4; ++i) + { + char ch = what[i]; + + if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122)) + chunk = (chunk << 8) + what[i]; + + else + break; + } + + if (i < 4 || what[4] != 0) + { + fprintf(stderr, "makepng --insert \"%s\": invalid chunk name\n", what); + exit(1); + } + + /* Assemble the parameter list. */ + nparams = find_parameters(what, param, parameter_list, 1024); + +# define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d)) + + switch (chunk) + { + case CHUNK(105,67,67,80): /* iCCP */ + if (nparams == 2) + return make_insert(what, insert_iCCP, nparams, parameter_list); + break; + + case CHUNK(116,69,88,116): /* tEXt */ + if (nparams == 2) + return make_insert(what, insert_tEXt, nparams, parameter_list); + break; + + case CHUNK(122,84,88,116): /* zTXt */ + if (nparams == 2) + return make_insert(what, insert_zTXt, nparams, parameter_list); + break; + + case CHUNK(105,84,88,116): /* iTXt */ + if (nparams == 4) + return make_insert(what, insert_iTXt, nparams, parameter_list); + break; + + case CHUNK(104,73,83,84): /* hIST */ + if (nparams <= 256) + return make_insert(what, insert_hIST, nparams, parameter_list); + break; + + case CHUNK(115,66,73,84): /* sBIT */ + if (nparams <= 4) + return make_insert(what, insert_sBIT, nparams, parameter_list); + break; + +#if 0 + case CHUNK(115,80,76,84): /* sPLT */ + return make_insert(what, insert_sPLT, nparams, parameter_list); +#endif + + default: + fprintf(stderr, "makepng --insert \"%s\": unrecognized chunk name\n", + what); + exit(1); + } + + bad_parameter_count(what, nparams); + return NULL; +} + +/* This is necessary because libpng expects writeable strings for things like + * text chunks (maybe this should be fixed...) + */ +static png_charp +strstash(png_const_charp foo) +{ + /* The program indicates a memory allocation error by crashing, this is by + * design. + */ + if (foo != NULL) + { + png_charp bar = malloc(strlen(foo)+1); + return strcpy(bar, foo); + } + + return NULL; +} + +static png_charp +strstash_list(const png_const_charp *text) +{ + size_t foo = 0; + png_charp result, bar; + const png_const_charp *line = text; + + while (*line != NULL) + foo += strlen(*line++); + + result = bar = malloc(foo+1); + + line = text; + while (*line != NULL) + { + foo = strlen(*line); + memcpy(bar, *line++, foo); + bar += foo; + } + + *bar = 0; + return result; +} + +/* These are used to insert Copyright and Licence fields, they allow the text to + * have \n unlike the --insert option. + */ +static chunk_insert * +add_tEXt(const char *key, const png_const_charp *text) +{ + static char what[5] = { 116, 69, 88, 116, 0 }; + png_charp parameter_list[3]; + + parameter_list[0] = strstash(key); + parameter_list[1] = strstash_list(text); + parameter_list[2] = NULL; + + return make_insert(what, insert_tEXt, 2, parameter_list); +} + +static chunk_insert * +add_iTXt(const char *key, const char *language, const char *language_key, + const png_const_charp *text) +{ + static char what[5] = { 105, 84, 88, 116, 0 }; + png_charp parameter_list[5]; + + parameter_list[0] = strstash(key); + parameter_list[1] = strstash(language); + parameter_list[2] = strstash(language_key); + parameter_list[3] = strstash_list(text); + parameter_list[4] = NULL; + + return make_insert(what, insert_iTXt, 4, parameter_list); +} + +/* This is a not-very-good parser for a sequence of numbers (including 0). It + * doesn't accept some apparently valid things, but it accepts all the sensible + * combinations. + */ +static void +parse_color(char *arg, unsigned int *colors) +{ + unsigned int ncolors = 0; + + while (*arg && ncolors < 4) + { + char *ep = arg; + + unsigned long ul = strtoul(arg, &ep, 0); + + if (ul > 65535) + { + fprintf(stderr, "makepng --color=...'%s': too big\n", arg); + exit(1); + } + + if (ep == arg) + { + fprintf(stderr, "makepng --color=...'%s': not a valid color\n", arg); + exit(1); + } + + if (*ep) ++ep; /* skip a separator */ + arg = ep; + + colors[++ncolors] = (unsigned int)ul; /* checked above */ + } + + if (*arg) + { + fprintf(stderr, "makepng --color=...'%s': too many values\n", arg); + exit(1); + } + + *colors = ncolors; +} + +int +main(int argc, char **argv) +{ + FILE *fp = stdout; + const char *file_name = NULL; + int color_type = 8; /* invalid */ + int bit_depth = 32; /* invalid */ + int small = 0; /* make full size images */ + int tRNS = 0; /* don't output a tRNS chunk */ + unsigned int colors[5]; + unsigned int filters = PNG_ALL_FILTERS; + png_fixed_point gamma = 0; /* not set */ + chunk_insert *head_insert = NULL; + chunk_insert **insert_ptr = &head_insert; + + memset(colors, 0, sizeof colors); + + while (--argc > 0) + { + char *arg = *++argv; + + if (strcmp(arg, "--small") == 0) + { + small = 1; + continue; + } + + if (strcmp(arg, "--tRNS") == 0) + { + tRNS = 1; + continue; + } + + if (strcmp(arg, "--sRGB") == 0) + { + gamma = PNG_DEFAULT_sRGB; + continue; + } + + if (strcmp(arg, "--linear") == 0) + { + gamma = PNG_FP_1; + continue; + } + + if (strcmp(arg, "--1.8") == 0) + { + gamma = PNG_GAMMA_MAC_18; + continue; + } + + if (strcmp(arg, "--nofilters") == 0) + { + filters = PNG_FILTER_NONE; + continue; + } + + if (strncmp(arg, "--color=", 8) == 0) + { + parse_color(arg+8, colors); + continue; + } + + if (argc >= 3 && strcmp(arg, "--insert") == 0) + { + png_const_charp what = *++argv; + png_charp param = *++argv; + chunk_insert *new_insert; + + argc -= 2; + + new_insert = find_insert(what, param); + + if (new_insert != NULL) + { + *insert_ptr = new_insert; + insert_ptr = &new_insert->next; + } + + continue; + } + + if (arg[0] == '-') + { + fprintf(stderr, "makepng: %s: invalid option\n", arg); + exit(1); + } + + if (strcmp(arg, "palette") == 0) + { + color_type = PNG_COLOR_TYPE_PALETTE; + continue; + } + + if (strncmp(arg, "gray", 4) == 0) + { + if (arg[4] == 0) + { + color_type = PNG_COLOR_TYPE_GRAY; + continue; + } + + else if (strcmp(arg+4, "a") == 0 || + strcmp(arg+4, "alpha") == 0 || + strcmp(arg+4, "-alpha") == 0) + { + color_type = PNG_COLOR_TYPE_GRAY_ALPHA; + continue; + } + } + + if (strncmp(arg, "rgb", 3) == 0) + { + if (arg[3] == 0) + { + color_type = PNG_COLOR_TYPE_RGB; + continue; + } + + else if (strcmp(arg+3, "a") == 0 || + strcmp(arg+3, "alpha") == 0 || + strcmp(arg+3, "-alpha") == 0) + { + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + continue; + } + } + + if (color_type == 8 && isdigit(arg[0])) + { + color_type = atoi(arg); + if (color_type < 0 || color_type > 6 || color_type == 1 || + color_type == 5) + { + fprintf(stderr, "makepng: %s: not a valid color type\n", arg); + exit(1); + } + + continue; + } + + if (bit_depth == 32 && isdigit(arg[0])) + { + bit_depth = atoi(arg); + if (bit_depth <= 0 || bit_depth > 16 || + (bit_depth & -bit_depth) != bit_depth) + { + fprintf(stderr, "makepng: %s: not a valid bit depth\n", arg); + exit(1); + } + + continue; + } + + if (argc == 1) /* It's the file name */ + { + fp = fopen(arg, "wb"); + if (fp == NULL) + { + fprintf(stderr, "%s: %s: could not open\n", arg, strerror(errno)); + exit(1); + } + + file_name = arg; + continue; + } + + fprintf(stderr, "makepng: %s: unknown argument\n", arg); + exit(1); + } /* argument while loop */ + + if (color_type == 8 || bit_depth == 32) + { + fprintf(stderr, "usage: makepng [--small] [--sRGB|--linear|--1.8] " + "[--color=...] color-type bit-depth [file-name]\n" + " Make a test PNG file, by default writes to stdout.\n" + " Other options are available, UTSL.\n"); + exit(1); + } + + /* Check the colors */ + { + unsigned int lim = (color_type == PNG_COLOR_TYPE_PALETTE ? 255U : + (1U< lim) + { + fprintf(stderr, "makepng: --color=...: %u out of range [0..%u]\n", + colors[i], lim); + exit(1); + } + } + + /* small and colors are incomparible (will probably crash if both are used at + * the same time!) + */ + if (small && colors[0] != 0) + { + fprintf(stderr, "makepng: --color --small: only one at a time!\n"); + exit(1); + } + + /* Restrict the filters for more speed to those we know are used for the + * generated images. + */ + if (filters == PNG_ALL_FILTERS && !small/*small provides defaults*/) + { + if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8) + filters = PNG_FILTER_NONE; + + else if (color_type & PNG_COLOR_MASK_COLOR) /* rgb */ + { + if (bit_depth == 8) + filters &= ~(PNG_FILTER_NONE | PNG_FILTER_AVG); + + else + filters = PNG_FILTER_SUB | PNG_FILTER_PAETH; + } + + else /* gray 8 or 16-bit */ + filters &= ~PNG_FILTER_NONE; + } + + /* Insert standard copyright and licence text. */ + { + static png_const_charp copyright[] = + { + COPYRIGHT, /* ISO-Latin-1 */ + NULL + }; + static png_const_charp licensing[] = + { + IMAGE_LICENSING, /* UTF-8 */ + NULL + }; + + chunk_insert *new_insert; + + new_insert = add_tEXt("Copyright", copyright); + if (new_insert != NULL) + { + *insert_ptr = new_insert; + insert_ptr = &new_insert->next; + } + + new_insert = add_iTXt("Licensing", "en", NULL, licensing); + if (new_insert != NULL) + { + *insert_ptr = new_insert; + insert_ptr = &new_insert->next; + } + } + + { + int ret = write_png(&file_name, fp, color_type, bit_depth, gamma, + head_insert, filters, colors, small, tRNS); + + if (ret != 0 && file_name != NULL) + remove(file_name); + + return ret; + } +} diff --git a/libs/libpng-src/contrib/libtests/pngimage.c b/libs/libpng-src/contrib/libtests/pngimage.c new file mode 100644 index 000000000..f130c043d --- /dev/null +++ b/libs/libpng-src/contrib/libtests/pngimage.c @@ -0,0 +1,1712 @@ +/* pngimage.c + * + * Copyright (c) 2015,2016 John Cunningham Bowler + * + * Last changed in libpng 1.6.24 [August 4, 2016] + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * Test the png_read_png and png_write_png interfaces. Given a PNG file load it + * using png_read_png and then write with png_write_png. Test all possible + * transforms. + */ +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#ifndef PNG_SETJMP_SUPPORTED +# include /* because png.h did *not* include this */ +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + +#if PNG_LIBPNG_VER < 10700 + /* READ_PNG and WRITE_PNG were not defined, so: */ +# ifdef PNG_INFO_IMAGE_SUPPORTED +# ifdef PNG_SEQUENTIAL_READ_SUPPORTED +# define PNG_READ_PNG_SUPPORTED +# endif /* SEQUENTIAL_READ */ +# ifdef PNG_WRITE_SUPPORTED +# define PNG_WRITE_PNG_SUPPORTED +# endif /* WRITE */ +# endif /* INFO_IMAGE */ +#endif /* pre 1.7.0 */ + +#ifdef PNG_READ_PNG_SUPPORTED +/* If a transform is valid on both read and write this implies that if the + * transform is applied to read it must also be applied on write to produce + * meaningful data. This is because these transforms when performed on read + * produce data with a memory format that does not correspond to a PNG format. + * + * Most of these transforms are invertible; after applying the transform on + * write the result is the original PNG data that would have would have been + * read if no transform were applied. + * + * The exception is _SHIFT, which destroys the low order bits marked as not + * significant in a PNG with the sBIT chunk. + * + * The following table lists, for each transform, the conditions under which it + * is expected to do anything. Conditions are defined as follows: + * + * 1) Color mask bits required - simply a mask to AND with color_type; one of + * these must be present for the transform to fire, except that 0 means + * 'always'. + * 2) Color mask bits which must be absent - another mask - none of these must + * be present. + * 3) Bit depths - a mask of component bit depths for the transform to fire. + * 4) 'read' - the transform works in png_read_png. + * 5) 'write' - the transform works in png_write_png. + * 6) PNG_INFO_chunk; a mask of the chunks that must be present for the + * transform to fire. All must be present - the requirement is that + * png_get_valid() & mask == mask, so if mask is 0 there is no requirement. + * + * The condition refers to the original image state - if multiple transforms are + * used together it is possible to cause a transform that wouldn't fire on the + * original image to fire. + */ +static struct transform_info +{ + const char *name; + int transform; + png_uint_32 valid_chunks; +# define CHUNK_NONE 0 +# define CHUNK_sBIT PNG_INFO_sBIT +# define CHUNK_tRNS PNG_INFO_tRNS + png_byte color_mask_required; + png_byte color_mask_absent; +# define COLOR_MASK_X 0 +# define COLOR_MASK_P PNG_COLOR_MASK_PALETTE +# define COLOR_MASK_C PNG_COLOR_MASK_COLOR +# define COLOR_MASK_A PNG_COLOR_MASK_ALPHA +# define COLOR_MASK_ALL (PALETTE+COLOR+ALPHA) /* absent = gray, no alpha */ + png_byte bit_depths; +# define BD_ALL (1 + 2 + 4 + 8 + 16) +# define BD_PAL (1 + 2 + 4 + 8) +# define BD_LOW (1 + 2 + 4) +# define BD_16 16 +# define BD_TRUE (8+16) /* i.e. true-color depths */ + png_byte when; +# define TRANSFORM_R 1 +# define TRANSFORM_W 2 +# define TRANSFORM_RW 3 + png_byte tested; /* the transform was tested somewhere */ +} transform_info[] = +{ + /* List ALL the PNG_TRANSFORM_ macros here. Check for support using the READ + * macros; even if the transform is supported on write it cannot be tested + * without the read support. + */ +# define T(name,chunk,cm_required,cm_absent,bd,when)\ + { #name, PNG_TRANSFORM_ ## name, CHUNK_ ## chunk,\ + COLOR_MASK_ ## cm_required, COLOR_MASK_ ## cm_absent, BD_ ## bd,\ + TRANSFORM_ ## when, 0/*!tested*/ } + +#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED + T(STRIP_16, NONE, X, X, 16, R), + /* drops the bottom 8 bits when bit depth is 16 */ +#endif +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED + T(STRIP_ALPHA, NONE, A, X, ALL, R), + /* removes the alpha channel if present */ +#endif +#ifdef PNG_WRITE_PACK_SUPPORTED +# define TRANSFORM_RW_PACK TRANSFORM_RW +#else +# define TRANSFORM_RW_PACK TRANSFORM_R +#endif +#ifdef PNG_READ_PACK_SUPPORTED + T(PACKING, NONE, X, X, LOW, RW_PACK), + /* unpacks low-bit-depth components into 1 byte per component on read, + * reverses this on write. + */ +#endif +#ifdef PNG_WRITE_PACKSWAP_SUPPORTED +# define TRANSFORM_RW_PACKSWAP TRANSFORM_RW +#else +# define TRANSFORM_RW_PACKSWAP TRANSFORM_R +#endif +#ifdef PNG_READ_PACKSWAP_SUPPORTED + T(PACKSWAP, NONE, X, X, LOW, RW_PACKSWAP), + /* reverses the order of low-bit-depth components packed into a byte */ +#endif +#ifdef PNG_READ_EXPAND_SUPPORTED + T(EXPAND, NONE, P, X, ALL, R), + /* expands PLTE PNG files to RGB (no tRNS) or RGBA (tRNS) * + * Note that the 'EXPAND' transform does lots of different things: */ + T(EXPAND, NONE, X, C, ALL, R), + /* expands grayscale PNG files to RGB, or RGBA */ + T(EXPAND, tRNS, X, A, ALL, R), + /* expands the tRNS chunk in files without alpha */ +#endif +#ifdef PNG_WRITE_INVERT_SUPPORTED +# define TRANSFORM_RW_INVERT TRANSFORM_RW +#else +# define TRANSFORM_RW_INVERT TRANSFORM_R +#endif +#ifdef PNG_READ_INVERT_SUPPORTED + T(INVERT_MONO, NONE, X, C, ALL, RW_INVERT), + /* converts gray-scale components to 1..0 from 0..1 */ +#endif +#ifdef PNG_WRITE_SHIFT_SUPPORTED +# define TRANSFORM_RW_SHIFT TRANSFORM_RW +#else +# define TRANSFORM_RW_SHIFT TRANSFORM_R +#endif +#ifdef PNG_READ_SHIFT_SUPPORTED + T(SHIFT, sBIT, X, X, ALL, RW_SHIFT), + /* reduces component values to the original range based on the sBIT chunk, + * this is only partially reversible - the low bits are lost and cannot be + * recovered on write. In fact write code replicates the bits to generate + * new low-order bits. + */ +#endif +#ifdef PNG_WRITE_BGR_SUPPORTED +# define TRANSFORM_RW_BGR TRANSFORM_RW +#else +# define TRANSFORM_RW_BGR TRANSFORM_R +#endif +#ifdef PNG_READ_BGR_SUPPORTED + T(BGR, NONE, C, P, TRUE, RW_BGR), + /* reverses the rgb component values of true-color pixels */ +#endif +#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED +# define TRANSFORM_RW_SWAP_ALPHA TRANSFORM_RW +#else +# define TRANSFORM_RW_SWAP_ALPHA TRANSFORM_R +#endif +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED + T(SWAP_ALPHA, NONE, A, X, TRUE, RW_SWAP_ALPHA), + /* swaps the alpha channel of RGBA or GA pixels to the front - ARGB or + * AG, on write reverses the process. + */ +#endif +#ifdef PNG_WRITE_SWAP_SUPPORTED +# define TRANSFORM_RW_SWAP TRANSFORM_RW +#else +# define TRANSFORM_RW_SWAP TRANSFORM_R +#endif +#ifdef PNG_READ_SWAP_SUPPORTED + T(SWAP_ENDIAN, NONE, X, P, 16, RW_SWAP), + /* byte-swaps 16-bit component values */ +#endif +#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED +# define TRANSFORM_RW_INVERT_ALPHA TRANSFORM_RW +#else +# define TRANSFORM_RW_INVERT_ALPHA TRANSFORM_R +#endif +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED + T(INVERT_ALPHA, NONE, A, X, TRUE, RW_INVERT_ALPHA), + /* converts an alpha channel from 0..1 to 1..0 */ +#endif +#ifdef PNG_WRITE_FILLER_SUPPORTED + T(STRIP_FILLER_BEFORE, NONE, A, P, TRUE, W), /* 'A' for a filler! */ + /* on write skips a leading filler channel; testing requires data with a + * filler channel so this is produced from RGBA or GA images by removing + * the 'alpha' flag from the color type in place. + */ + T(STRIP_FILLER_AFTER, NONE, A, P, TRUE, W), + /* on write strips a trailing filler channel */ +#endif +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED + T(GRAY_TO_RGB, NONE, X, C, ALL, R), + /* expands grayscale images to RGB, also causes the palette part of + * 'EXPAND' to happen. Low bit depth grayscale images are expanded to + * 8-bits per component and no attempt is made to convert the image to a + * palette image. While this transform is partially reversible + * png_write_png does not currently support this. + */ + T(GRAY_TO_RGB, NONE, P, X, ALL, R), + /* The 'palette' side effect mentioned above; a bit bogus but this is the + * way the libpng code works. + */ +#endif +#ifdef PNG_READ_EXPAND_16_SUPPORTED + T(EXPAND_16, NONE, X, X, PAL, R), + /* expands images to 16-bits per component, as a side effect expands + * palette images to RGB and expands the tRNS chunk if present, so it can + * modify 16-bit per component images as well: + */ + T(EXPAND_16, tRNS, X, A, 16, R), + /* side effect of EXPAND_16 - expands the tRNS chunk in an RGB or G 16-bit + * image. + */ +#endif +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + T(SCALE_16, NONE, X, X, 16, R), + /* scales 16-bit components to 8-bits. */ +#endif + + { NULL /*name*/, 0, 0, 0, 0, 0, 0, 0/*!tested*/ } + +#undef T +}; + +#define ARRAY_SIZE(a) ((sizeof a)/(sizeof a[0])) +#define TTABLE_SIZE ARRAY_SIZE(transform_info) + +/* Some combinations of options that should be reversible are not; these cases + * are bugs. + */ +static int known_bad_combos[][2] = +{ + /* problem, antidote */ + { PNG_TRANSFORM_SHIFT | PNG_TRANSFORM_INVERT_ALPHA, 0/*antidote*/ } +}; + +static int +is_combo(int transforms) +{ + return transforms & (transforms-1); /* non-zero if more than one set bit */ +} + +static int +first_transform(int transforms) +{ + return transforms & -transforms; /* lowest set bit */ +} + +static int +is_bad_combo(int transforms) +{ + unsigned int i; + + for (i=0; ifirst.next = NULL; + buffer->last = NULL; + buffer->current = NULL; +} + +static void +buffer_destroy_list(struct buffer_list *list) +{ + if (list != NULL) + { + struct buffer_list *next = list->next; + DELETE(list); + buffer_destroy_list(next); + } +} + +static void +buffer_destroy(struct buffer *buffer) +{ + struct buffer_list *list = buffer->first.next; + buffer_init(buffer); + buffer_destroy_list(list); +} + +#ifdef PNG_WRITE_PNG_SUPPORTED +static void +buffer_start_write(struct buffer *buffer) +{ + buffer->last = &buffer->first; + buffer->end_count = 0; + buffer->current = NULL; +} +#endif + +static void +buffer_start_read(struct buffer *buffer) +{ + buffer->current = &buffer->first; + buffer->read_count = 0; +} + +#ifdef ENOMEM /* required by POSIX 1003.1 */ +# define MEMORY ENOMEM +#else +# define MEMORY ERANGE /* required by ANSI-C */ +#endif +static struct buffer * +get_buffer(png_structp pp) + /* Used from libpng callbacks to get the current buffer */ +{ + return (struct buffer*)png_get_io_ptr(pp); +} + +static struct buffer_list * +buffer_extend(struct buffer_list *current) +{ + struct buffer_list *add; + + assert(current->next == NULL); + + add = NEW(struct buffer_list); + if (add == NULL) + return NULL; + + add->next = NULL; + current->next = add; + + return add; +} + +/* Load a buffer from a file; does the equivalent of buffer_start_write. On a + * read error returns an errno value, else returns 0. + */ +static int +buffer_from_file(struct buffer *buffer, FILE *fp) +{ + struct buffer_list *last = &buffer->first; + size_t count = 0; + + for (;;) + { + size_t r = fread(last->buffer+count, 1/*size*/, + (sizeof last->buffer)-count, fp); + + if (r > 0) + { + count += r; + + if (count >= sizeof last->buffer) + { + assert(count == sizeof last->buffer); + count = 0; + + if (last->next == NULL) + { + last = buffer_extend(last); + if (last == NULL) + return MEMORY; + } + + else + last = last->next; + } + } + + else /* fread failed - probably end of file */ + { + if (feof(fp)) + { + buffer->last = last; + buffer->end_count = count; + return 0; /* no error */ + } + + /* Some kind of funky error; errno should be non-zero */ + return errno == 0 ? ERANGE : errno; + } + } +} + +/* This structure is used to control the test of a single file. */ +typedef enum +{ + VERBOSE, /* switches on all messages */ + INFORMATION, + WARNINGS, /* switches on warnings */ + LIBPNG_WARNING, + APP_WARNING, + ERRORS, /* just errors */ + APP_FAIL, /* continuable error - no need to longjmp */ + LIBPNG_ERROR, /* this and higher cause a longjmp */ + LIBPNG_BUG, /* erroneous behavior in libpng */ + APP_ERROR, /* such as out-of-memory in a callback */ + QUIET, /* no normal messages */ + USER_ERROR, /* such as file-not-found */ + INTERNAL_ERROR +} error_level; +#define LEVEL_MASK 0xf /* where the level is in 'options' */ + +#define EXHAUSTIVE 0x010 /* Test all combinations of active options */ +#define STRICT 0x020 /* Fail on warnings as well as errors */ +#define LOG 0x040 /* Log pass/fail to stdout */ +#define CONTINUE 0x080 /* Continue on APP_FAIL errors */ +#define SKIP_BUGS 0x100 /* Skip over known bugs */ +#define LOG_SKIPPED 0x200 /* Log skipped bugs */ +#define FIND_BAD_COMBOS 0x400 /* Attempt to deduce bad combos */ +#define LIST_COMBOS 0x800 /* List combos by name */ + +/* Result masks apply to the result bits in the 'results' field below; these + * bits are simple 1U<options = WARNINGS; /* default to !verbose, !quiet */ + dp->filename = NULL; + dp->operation = NULL; + dp->original_pp = NULL; + dp->original_ip = NULL; + dp->original_rows = NULL; + dp->read_pp = NULL; + dp->read_ip = NULL; + buffer_init(&dp->original_file); + +# ifdef PNG_WRITE_PNG_SUPPORTED + dp->write_pp = NULL; + buffer_init(&dp->written_file); +# endif +} + +static void +display_clean_read(struct display *dp) +{ + if (dp->read_pp != NULL) + png_destroy_read_struct(&dp->read_pp, &dp->read_ip, NULL); +} + +#ifdef PNG_WRITE_PNG_SUPPORTED +static void +display_clean_write(struct display *dp) +{ + if (dp->write_pp != NULL) + png_destroy_write_struct(&dp->write_pp, NULL); +} +#endif + +static void +display_clean(struct display *dp) +{ +# ifdef PNG_WRITE_PNG_SUPPORTED + display_clean_write(dp); +# endif + display_clean_read(dp); + + dp->original_rowbytes = 0; + dp->original_rows = NULL; + dp->chunks = 0; + + png_destroy_read_struct(&dp->original_pp, &dp->original_ip, NULL); + /* leave the filename for error detection */ + dp->results = 0; /* reset for next time */ +} + +static void +display_destroy(struct display *dp) +{ + /* Release any memory held in the display. */ +# ifdef PNG_WRITE_PNG_SUPPORTED + buffer_destroy(&dp->written_file); +# endif + + buffer_destroy(&dp->original_file); +} + +static struct display * +get_dp(png_structp pp) + /* The display pointer is always stored in the png_struct error pointer */ +{ + struct display *dp = (struct display*)png_get_error_ptr(pp); + + if (dp == NULL) + { + fprintf(stderr, "pngimage: internal error (no display)\n"); + exit(99); /* prevents a crash */ + } + + return dp; +} + +/* error handling */ +#ifdef __GNUC__ +# define VGATTR __attribute__((__format__ (__printf__,3,4))) + /* Required to quiet GNUC warnings when the compiler sees a stdarg function + * that calls one of the stdio v APIs. + */ +#else +# define VGATTR +#endif +static void VGATTR +display_log(struct display *dp, error_level level, const char *fmt, ...) + /* 'level' is as above, fmt is a stdio style format string. This routine + * does not return if level is above LIBPNG_WARNING + */ +{ + dp->results |= 1U << level; + + if (level > (error_level)(dp->options & LEVEL_MASK)) + { + const char *lp; + va_list ap; + + switch (level) + { + case INFORMATION: lp = "information"; break; + case LIBPNG_WARNING: lp = "warning(libpng)"; break; + case APP_WARNING: lp = "warning(pngimage)"; break; + case APP_FAIL: lp = "error(continuable)"; break; + case LIBPNG_ERROR: lp = "error(libpng)"; break; + case LIBPNG_BUG: lp = "bug(libpng)"; break; + case APP_ERROR: lp = "error(pngimage)"; break; + case USER_ERROR: lp = "error(user)"; break; + + case INTERNAL_ERROR: /* anything unexpected is an internal error: */ + case VERBOSE: case WARNINGS: case ERRORS: case QUIET: + default: lp = "bug(pngimage)"; break; + } + + fprintf(stderr, "%s: %s: %s", + dp->filename != NULL ? dp->filename : "", lp, dp->operation); + + if (dp->transforms != 0) + { + int tr = dp->transforms; + + if (is_combo(tr)) + { + if (dp->options & LIST_COMBOS) + { + int trx = tr; + + fprintf(stderr, "("); + if (trx) + { + int start = 0; + + while (trx) + { + int trz = trx & -trx; + + if (start) fprintf(stderr, "+"); + fprintf(stderr, "%s", transform_name(trz)); + start = 1; + trx &= ~trz; + } + } + + else + fprintf(stderr, "-"); + fprintf(stderr, ")"); + } + + else + fprintf(stderr, "(0x%x)", tr); + } + + else + fprintf(stderr, "(%s)", transform_name(tr)); + } + + fprintf(stderr, ": "); + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + fputc('\n', stderr); + } + /* else do not output any message */ + + /* Errors cause this routine to exit to the fail code */ + if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE))) + longjmp(dp->error_return, level); +} + +/* error handler callbacks for libpng */ +static void PNGCBAPI +display_warning(png_structp pp, png_const_charp warning) +{ + display_log(get_dp(pp), LIBPNG_WARNING, "%s", warning); +} + +static void PNGCBAPI +display_error(png_structp pp, png_const_charp error) +{ + struct display *dp = get_dp(pp); + + display_log(dp, LIBPNG_ERROR, "%s", error); +} + +static void +display_cache_file(struct display *dp, const char *filename) + /* Does the initial cache of the file. */ +{ + FILE *fp; + int ret; + + dp->filename = filename; + + if (filename != NULL) + { + fp = fopen(filename, "rb"); + if (fp == NULL) + display_log(dp, USER_ERROR, "open failed: %s", strerror(errno)); + } + + else + fp = stdin; + + ret = buffer_from_file(&dp->original_file, fp); + + fclose(fp); + + if (ret != 0) + display_log(dp, APP_ERROR, "read failed: %s", strerror(ret)); +} + +static void +buffer_read(struct display *dp, struct buffer *bp, png_bytep data, + size_t size) +{ + struct buffer_list *last = bp->current; + size_t read_count = bp->read_count; + + while (size > 0) + { + size_t avail; + + if (last == NULL || + (last == bp->last && read_count >= bp->end_count)) + { + display_log(dp, USER_ERROR, "file truncated (%lu bytes)", + (unsigned long)size); + /*NOTREACHED*/ + break; + } + + else if (read_count >= sizeof last->buffer) + { + /* Move to the next buffer: */ + last = last->next; + read_count = 0; + bp->current = last; /* Avoid update outside the loop */ + + /* And do a sanity check (the EOF case is caught above) */ + if (last == NULL) + { + display_log(dp, INTERNAL_ERROR, "damaged buffer list"); + /*NOTREACHED*/ + break; + } + } + + avail = (sizeof last->buffer) - read_count; + if (avail > size) + avail = size; + + memcpy(data, last->buffer + read_count, avail); + read_count += avail; + size -= avail; + data += avail; + } + + bp->read_count = read_count; +} + +static void PNGCBAPI +read_function(png_structp pp, png_bytep data, size_t size) +{ + buffer_read(get_dp(pp), get_buffer(pp), data, size); +} + +static void +read_png(struct display *dp, struct buffer *bp, const char *operation, + int transforms) +{ + png_structp pp; + png_infop ip; + + /* This cleans out any previous read and sets operation and transforms to + * empty. + */ + display_clean_read(dp); + + if (operation != NULL) /* else this is a verify and do not overwrite info */ + { + dp->operation = operation; + dp->transforms = transforms; + } + + dp->read_pp = pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, dp, + display_error, display_warning); + if (pp == NULL) + display_log(dp, LIBPNG_ERROR, "failed to create read struct"); + + /* The png_read_png API requires us to make the info struct, but it does the + * call to png_read_info. + */ + dp->read_ip = ip = png_create_info_struct(pp); + if (ip == NULL) + display_log(dp, LIBPNG_ERROR, "failed to create info struct"); + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + /* Remove the user limits, if any */ + png_set_user_limits(pp, 0x7fffffff, 0x7fffffff); +# endif + + /* Set the IO handling */ + buffer_start_read(bp); + png_set_read_fn(pp, bp, read_function); + + png_read_png(pp, ip, transforms, NULL/*params*/); + +#if 0 /* crazy debugging */ + { + png_bytep pr = png_get_rows(pp, ip)[0]; + size_t rb = png_get_rowbytes(pp, ip); + size_t cb; + char c = ' '; + + fprintf(stderr, "%.4x %2d (%3lu bytes):", transforms, png_get_bit_depth(pp,ip), (unsigned long)rb); + + for (cb=0; cboriginal_file, "original read", 0/*no transform*/); + + /* Move the result to the 'original' fields */ + dp->original_pp = pp = dp->read_pp, dp->read_pp = NULL; + dp->original_ip = ip = dp->read_ip, dp->read_ip = NULL; + + dp->original_rowbytes = png_get_rowbytes(pp, ip); + if (dp->original_rowbytes == 0) + display_log(dp, LIBPNG_BUG, "png_get_rowbytes returned 0"); + + dp->chunks = png_get_valid(pp, ip, 0xffffffff); + if ((dp->chunks & PNG_INFO_IDAT) == 0) /* set by png_read_png */ + display_log(dp, LIBPNG_BUG, "png_read_png did not set IDAT flag"); + + dp->original_rows = png_get_rows(pp, ip); + if (dp->original_rows == NULL) + display_log(dp, LIBPNG_BUG, "png_read_png did not create row buffers"); + + if (!png_get_IHDR(pp, ip, + &dp->width, &dp->height, &dp->bit_depth, &dp->color_type, + &dp->interlace_method, &dp->compression_method, &dp->filter_method)) + display_log(dp, LIBPNG_BUG, "png_get_IHDR failed"); + + /* 'active' transforms are discovered based on the original image format; + * running one active transform can activate others. At present the code + * does not attempt to determine the closure. + */ + { + png_uint_32 chunks = dp->chunks; + int active = 0, inactive = 0; + int ct = dp->color_type; + int bd = dp->bit_depth; + unsigned int i; + + for (i=0; iactive_transforms = active; + dp->ignored_transforms = inactive; /* excluding write-only transforms */ + } +} + +static int +compare_read(struct display *dp, int applied_transforms) +{ + /* Compare the png_info from read_ip with original_info */ + size_t rowbytes; + png_uint_32 width, height; + int bit_depth, color_type; + int interlace_method, compression_method, filter_method; + const char *e = NULL; + + png_get_IHDR(dp->read_pp, dp->read_ip, &width, &height, &bit_depth, + &color_type, &interlace_method, &compression_method, &filter_method); + +# define C(item) if (item != dp->item) \ + display_log(dp, APP_WARNING, "IHDR " #item "(%lu) changed to %lu",\ + (unsigned long)dp->item, (unsigned long)item), e = #item + + /* The IHDR should be identical: */ + C(width); + C(height); + C(bit_depth); + C(color_type); + C(interlace_method); + C(compression_method); + C(filter_method); + + /* 'e' remains set to the name of the last thing changed: */ + if (e) + display_log(dp, APP_ERROR, "IHDR changed (%s)", e); + + /* All the chunks from the original PNG should be preserved in the output PNG + * because the PNG format has not been changed. + */ + { + unsigned long chunks = + png_get_valid(dp->read_pp, dp->read_ip, 0xffffffff); + + if (chunks != dp->chunks) + display_log(dp, APP_FAIL, "PNG chunks changed from 0x%lx to 0x%lx", + (unsigned long)dp->chunks, chunks); + } + + /* rowbytes should be the same */ + rowbytes = png_get_rowbytes(dp->read_pp, dp->read_ip); + + /* NOTE: on 64-bit systems this may trash the top bits of rowbytes, + * which could lead to weird error messages. + */ + if (rowbytes != dp->original_rowbytes) + display_log(dp, APP_ERROR, "PNG rowbytes changed from %lu to %lu", + (unsigned long)dp->original_rowbytes, (unsigned long)rowbytes); + + /* The rows should be the same too, unless the applied transforms includes + * the shift transform, in which case low bits may have been lost. + */ + { + png_bytepp rows = png_get_rows(dp->read_pp, dp->read_ip); + unsigned int mask; /* mask (if not zero) for the final byte */ + + if (bit_depth < 8) + { + /* Need the stray bits at the end, this depends only on the low bits + * of the image width; overflow does not matter. If the width is an + * exact multiple of 8 bits this gives a mask of 0, not 0xff. + */ + mask = 0xff & (0xff00 >> ((bit_depth * width) & 7)); + } + + else + mask = 0; + + if (rows == NULL) + display_log(dp, LIBPNG_BUG, "png_get_rows returned NULL"); + + if ((applied_transforms & PNG_TRANSFORM_SHIFT) == 0 || + (dp->active_transforms & PNG_TRANSFORM_SHIFT) == 0 || + color_type == PNG_COLOR_TYPE_PALETTE) + { + unsigned long y; + + for (y=0; yoriginal_rows[y]; + + if (memcmp(row, orig, rowbytes-(mask != 0)) != 0 || (mask != 0 && + ((row[rowbytes-1] & mask) != (orig[rowbytes-1] & mask)))) + { + size_t x; + + /* Find the first error */ + for (x=0; x 0x%.2x", + (unsigned long)x, (unsigned long)y, orig[x], row[x]); + return 0; /* don't keep reporting failed rows on 'continue' */ + } + } + } + + else +# ifdef PNG_sBIT_SUPPORTED + { + unsigned long y; + int bpp; /* bits-per-pixel then bytes-per-pixel */ + /* components are up to 8 bytes in size */ + png_byte sig_bits[8]; + png_color_8p sBIT; + + if (png_get_sBIT(dp->read_pp, dp->read_ip, &sBIT) != PNG_INFO_sBIT) + display_log(dp, INTERNAL_ERROR, + "active shift transform but no sBIT in file"); + + switch (color_type) + { + case PNG_COLOR_TYPE_GRAY: + sig_bits[0] = sBIT->gray; + bpp = bit_depth; + break; + + case PNG_COLOR_TYPE_GA: + sig_bits[0] = sBIT->gray; + sig_bits[1] = sBIT->alpha; + bpp = 2 * bit_depth; + break; + + case PNG_COLOR_TYPE_RGB: + sig_bits[0] = sBIT->red; + sig_bits[1] = sBIT->green; + sig_bits[2] = sBIT->blue; + bpp = 3 * bit_depth; + break; + + case PNG_COLOR_TYPE_RGBA: + sig_bits[0] = sBIT->red; + sig_bits[1] = sBIT->green; + sig_bits[2] = sBIT->blue; + sig_bits[3] = sBIT->alpha; + bpp = 4 * bit_depth; + break; + + default: + display_log(dp, LIBPNG_ERROR, "invalid colour type %d", + color_type); + /*NOTREACHED*/ + bpp = 0; + break; + } + + { + int b; + + for (b=0; 8*b bit_depth/*!palette*/) + display_log(dp, LIBPNG_BUG, + "invalid sBIT[%u] value %d returned for PNG bit depth %d", + b, sig_bits[b], bit_depth); + } + } + + if (bpp < 8 && bpp != bit_depth) + { + /* sanity check; this is a grayscale PNG; something is wrong in the + * code above. + */ + display_log(dp, INTERNAL_ERROR, "invalid bpp %u for bit_depth %u", + bpp, bit_depth); + } + + switch (bit_depth) + { + int b; + + case 16: /* Two bytes per component, big-endian */ + for (b = (bpp >> 4); b > 0; --b) + { + unsigned int sig = (unsigned int)(0xffff0000 >> sig_bits[b]); + + sig_bits[2*b+1] = (png_byte)sig; + sig_bits[2*b+0] = (png_byte)(sig >> 8); /* big-endian */ + } + break; + + case 8: /* One byte per component */ + for (b=0; b*8 < bpp; ++b) + sig_bits[b] = (png_byte)(0xff00 >> sig_bits[b]); + break; + + case 1: /* allowed, but dumb */ + /* Value is 1 */ + sig_bits[0] = 0xff; + break; + + case 2: /* Replicate 4 times */ + /* Value is 1 or 2 */ + b = 0x3 & ((0x3<<2) >> sig_bits[0]); + b |= b << 2; + b |= b << 4; + sig_bits[0] = (png_byte)b; + break; + + case 4: /* Relicate twice */ + /* Value is 1, 2, 3 or 4 */ + b = 0xf & ((0xf << 4) >> sig_bits[0]); + b |= b << 4; + sig_bits[0] = (png_byte)b; + break; + + default: + display_log(dp, LIBPNG_BUG, "invalid bit depth %d", bit_depth); + break; + } + + /* Convert bpp to bytes; this gives '1' for low-bit depth grayscale, + * where there are multiple pixels per byte. + */ + bpp = (bpp+7) >> 3; + + /* The mask can be combined with sig_bits[0] */ + if (mask != 0) + { + mask &= sig_bits[0]; + + if (bpp != 1 || mask == 0) + display_log(dp, INTERNAL_ERROR, "mask calculation error %u, %u", + bpp, mask); + } + + for (y=0; yoriginal_rows[y]; + unsigned long x; + + for (x=0; x<(width-(mask!=0)); ++x) + { + int b; + + for (b=0; b%.2x", + x, b, y, orig[-1], row[-1]); + return 0; + } + } + } + + if (mask != 0 && (*row & mask) != (*orig & mask)) + { + display_log(dp, APP_FAIL, + "significant bits at (%lu[end],%lu) changed", x, y); + return 0; + } + } /* for y */ + } +# else /* !sBIT */ + display_log(dp, INTERNAL_ERROR, + "active shift transform but no sBIT support"); +# endif /* !sBIT */ + } + + return 1; /* compare succeeded */ +} + +#ifdef PNG_WRITE_PNG_SUPPORTED +static void +buffer_write(struct display *dp, struct buffer *buffer, png_bytep data, + size_t size) + /* Generic write function used both from the write callback provided to + * libpng and from the generic read code. + */ +{ + /* Write the data into the buffer, adding buffers as required */ + struct buffer_list *last = buffer->last; + size_t end_count = buffer->end_count; + + while (size > 0) + { + size_t avail; + + if (end_count >= sizeof last->buffer) + { + if (last->next == NULL) + { + last = buffer_extend(last); + + if (last == NULL) + display_log(dp, APP_ERROR, "out of memory saving file"); + } + + else + last = last->next; + + buffer->last = last; /* avoid the need to rewrite every time */ + end_count = 0; + } + + avail = (sizeof last->buffer) - end_count; + if (avail > size) + avail = size; + + memcpy(last->buffer + end_count, data, avail); + end_count += avail; + size -= avail; + data += avail; + } + + buffer->end_count = end_count; +} + +static void PNGCBAPI +write_function(png_structp pp, png_bytep data, size_t size) +{ + buffer_write(get_dp(pp), get_buffer(pp), data, size); +} + +static void +write_png(struct display *dp, png_infop ip, int transforms) +{ + display_clean_write(dp); /* safety */ + + buffer_start_write(&dp->written_file); + dp->operation = "write"; + dp->transforms = transforms; + + dp->write_pp = png_create_write_struct(PNG_LIBPNG_VER_STRING, dp, + display_error, display_warning); + + if (dp->write_pp == NULL) + display_log(dp, APP_ERROR, "failed to create write png_struct"); + + png_set_write_fn(dp->write_pp, &dp->written_file, write_function, + NULL/*flush*/); + +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + /* Remove the user limits, if any */ + png_set_user_limits(dp->write_pp, 0x7fffffff, 0x7fffffff); +# endif + + /* Certain transforms require the png_info to be zapped to allow the + * transform to work correctly. + */ + if (transforms & (PNG_TRANSFORM_PACKING| + PNG_TRANSFORM_STRIP_FILLER| + PNG_TRANSFORM_STRIP_FILLER_BEFORE)) + { + int ct = dp->color_type; + + if (transforms & (PNG_TRANSFORM_STRIP_FILLER| + PNG_TRANSFORM_STRIP_FILLER_BEFORE)) + ct &= ~PNG_COLOR_MASK_ALPHA; + + png_set_IHDR(dp->write_pp, ip, dp->width, dp->height, dp->bit_depth, ct, + dp->interlace_method, dp->compression_method, dp->filter_method); + } + + png_write_png(dp->write_pp, ip, transforms, NULL/*params*/); + + /* Clean it on the way out - if control returns to the caller then the + * written_file contains the required data. + */ + display_clean_write(dp); +} +#endif /* WRITE_PNG */ + +static int +skip_transform(struct display *dp, int tr) + /* Helper to test for a bad combo and log it if it is skipped */ +{ + if ((dp->options & SKIP_BUGS) != 0 && is_bad_combo(tr)) + { + /* Log this to stdout if logging is on, otherwise just do an information + * display_log. + */ + if ((dp->options & LOG_SKIPPED) != 0) + { + printf("SKIP: %s transforms ", dp->filename); + + while (tr != 0) + { + int next = first_transform(tr); + tr &= ~next; + + printf("%s", transform_name(next)); + if (tr != 0) + putchar('+'); + } + + putchar('\n'); + } + + else + display_log(dp, INFORMATION, "%s: skipped known bad combo 0x%x", + dp->filename, tr); + + return 1; /* skip */ + } + + return 0; /* don't skip */ +} + +static void +test_one_file(struct display *dp, const char *filename) +{ + /* First cache the file and update the display original file + * information for the new file. + */ + dp->operation = "cache file"; + dp->transforms = 0; + display_cache_file(dp, filename); + update_display(dp); + + /* First test: if there are options that should be ignored for this file + * verify that they really are ignored. + */ + if (dp->ignored_transforms != 0) + { + read_png(dp, &dp->original_file, "ignored transforms", + dp->ignored_transforms); + + /* The result should be identical to the original_rows */ + if (!compare_read(dp, 0/*transforms applied*/)) + return; /* no point testing more */ + } + +#ifdef PNG_WRITE_PNG_SUPPORTED + /* Second test: write the original PNG data out to a new file (to test the + * write side) then read the result back in and make sure that it hasn't + * changed. + */ + dp->operation = "write"; + write_png(dp, dp->original_ip, 0/*transforms*/); + read_png(dp, &dp->written_file, NULL, 0/*transforms*/); + if (!compare_read(dp, 0/*transforms applied*/)) + return; +#endif + + /* Third test: the active options. Test each in turn, or, with the + * EXHAUSTIVE option, test all possible combinations. + */ + { + /* Use unsigned int here because the code below to increment through all + * the possibilities exhaustively has to use a compare and that must be + * unsigned, because some transforms are negative on a 16-bit system. + */ + unsigned int active = dp->active_transforms; + int exhaustive = (dp->options & EXHAUSTIVE) != 0; + unsigned int current = first_transform(active); + unsigned int bad_transforms = 0; + unsigned int bad_combo = ~0U; /* bitwise AND of failing transforms */ + unsigned int bad_combo_list = 0; /* bitwise OR of failures */ + + for (;;) + { + read_png(dp, &dp->original_file, "active transforms", current); + + /* If this involved any irreversible transformations then if we write + * it out with just the reversible transformations and read it in again + * with the same transforms we should get the same thing. At present + * this isn't done - it just seems like a waste of time and it would + * require two sets of read png_struct/png_info. + * + * If there were no irreversible transformations then if we write it + * out and read it back in again (without the reversible transforms) + * we should get back to the place where we started. + */ +#ifdef PNG_WRITE_PNG_SUPPORTED + if ((current & write_transforms) == current) + { + /* All transforms reversible: write the PNG with the transformations + * reversed, then read it back in with no transformations. The + * result should be the same as the original apart from the loss of + * low order bits because of the SHIFT/sBIT transform. + */ + dp->operation = "reversible transforms"; + write_png(dp, dp->read_ip, current); + + /* And if this is read back in, because all the transformations were + * reversible, the result should be the same. + */ + read_png(dp, &dp->written_file, NULL, 0); + if (!compare_read(dp, current/*for the SHIFT/sBIT transform*/)) + { + /* This set of transforms failed. If a single bit is set - if + * there is just one transform - don't include this in further + * 'exhaustive' tests. Notice that each transform is tested on + * its own before testing combos in the exhaustive case. + */ + if (is_combo(current)) + { + bad_combo &= current; + bad_combo_list |= current; + } + + else + bad_transforms |= current; + } + } +#endif + + /* Now move to the next transform */ + if (exhaustive) /* all combinations */ + { + unsigned int next = current; + + do + { + if (next == read_transforms) /* Everything tested */ + goto combo; + + ++next; + } /* skip known bad combos if the relevant option is set; skip + * combos involving known bad single transforms in all cases. + */ + while ( (next & read_transforms) <= current + || (next & active) == 0 /* skip cases that do nothing */ + || (next & bad_transforms) != 0 + || skip_transform(dp, next)); + + assert((next & read_transforms) == next); + current = next; + } + + else /* one at a time */ + { + active &= ~current; + + if (active == 0) + goto combo; + + current = first_transform(active); + } + } + +combo: + if (dp->options & FIND_BAD_COMBOS) + { + /* bad_combos identifies the combos that occur in all failing cases; + * bad_combo_list identifies transforms that do not prevent the + * failure. + */ + if (bad_combo != ~0U) + printf("%s[0x%x]: PROBLEM: 0x%x[0x%x] ANTIDOTE: 0x%x\n", + dp->filename, active, bad_combo, bad_combo_list, + rw_transforms & ~bad_combo_list); + + else + printf("%s: no %sbad combos found\n", dp->filename, + (dp->options & SKIP_BUGS) ? "additional " : ""); + } + } +} + +static int +do_test(struct display *dp, const char *file) + /* Exists solely to isolate the setjmp clobbers */ +{ + int ret = setjmp(dp->error_return); + + if (ret == 0) + { + test_one_file(dp, file); + return 0; + } + + else if (ret < ERRORS) /* shouldn't longjmp on warnings */ + display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret); + + return ret; +} + +int +main(int argc, char **argv) +{ + /* For each file on the command line test it with a range of transforms */ + int option_end, ilog = 0; + struct display d; + + validate_T(); + display_init(&d); + + for (option_end=1; option_end QUIET) /* abort on user or internal error */ + return 99; + } + + /* Here on any return, including failures, except user/internal issues + */ + { + int pass = (d.options & STRICT) ? + RESULT_STRICT(d.results) : RESULT_RELAXED(d.results); + + if (!pass) + ++errors; + + if (d.options & LOG) + { + int j; + + printf("%s: pngimage ", pass ? "PASS" : "FAIL"); + + for (j=1; j +#include +#include +#include +#include +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + +#ifdef PNG_SIMPLIFIED_READ_SUPPORTED /* Else nothing can be done */ +#include "../tools/sRGB.h" + +/* KNOWN ISSUES + * + * These defines switch on alternate algorithms for format conversions to match + * the current libpng implementation; they are set to allow pngstest to pass + * even though libpng is producing answers that are not as correct as they + * should be. + */ +#define ALLOW_UNUSED_GPC 0 + /* If true include unused static GPC functions and declare an external array + * of them to hide the fact that they are unused. This is for development + * use while testing the correct function to use to take into account libpng + * misbehavior, such as using a simple power law to correct sRGB to linear. + */ + +/* The following is to support direct compilation of this file as C++ */ +#ifdef __cplusplus +# define voidcast(type, value) static_cast(value) +# define aligncastconst(type, value) \ + static_cast(static_cast(value)) +#else +# define voidcast(type, value) (value) +# define aligncastconst(type, value) ((const void*)(value)) +#endif /* __cplusplus */ + +/* During parallel runs of pngstest each temporary file needs a unique name, + * this is used to permit uniqueness using a command line argument which can be + * up to 22 characters long. + */ +static char tmpf[23] = "TMP"; + +/* Generate random bytes. This uses a boring repeatable algorithm and it + * is implemented here so that it gives the same set of numbers on every + * architecture. It's a linear congruential generator (Knuth or Sedgewick + * "Algorithms") but it comes from the 'feedback taps' table in Horowitz and + * Hill, "The Art of Electronics". + */ +static void +make_random_bytes(png_uint_32* seed, void* pv, size_t size) +{ + png_uint_32 u0 = seed[0], u1 = seed[1]; + png_bytep bytes = voidcast(png_bytep, pv); + + /* There are thirty three bits, the next bit in the sequence is bit-33 XOR + * bit-20. The top 1 bit is in u1, the bottom 32 are in u0. + */ + size_t i; + for (i=0; i> (20-8)) ^ ((u1 << 7) | (u0 >> (32-7)))) & 0xff; + u1 <<= 8; + u1 |= u0 >> 24; + u0 <<= 8; + u0 |= u; + *bytes++ = (png_byte)u; + } + + seed[0] = u0; + seed[1] = u1; +} + +static png_uint_32 color_seed[2]; + +static void +reseed(void) +{ + color_seed[0] = 0x12345678U; + color_seed[1] = 0x9abcdefU; +} + +static void +random_color(png_colorp color) +{ + make_random_bytes(color_seed, color, sizeof *color); +} + +/* Math support - neither Cygwin nor Visual Studio have C99 support and we need + * a predictable rounding function, so make one here: + */ +static double +closestinteger(double x) +{ + return floor(x + .5); +} + +/* Cast support: remove GCC whines. */ +static png_byte +u8d(double d) +{ + d = closestinteger(d); + return (png_byte)d; +} + +static png_uint_16 +u16d(double d) +{ + d = closestinteger(d); + return (png_uint_16)d; +} + +/* sRGB support: use exact calculations rounded to the nearest int, see the + * fesetround() call in main(). sRGB_to_d optimizes the 8 to 16-bit conversion. + */ +static double sRGB_to_d[256]; +static double g22_to_d[256]; + +static void +init_sRGB_to_d(void) +{ + int i; + + sRGB_to_d[0] = 0; + for (i=1; i<255; ++i) + sRGB_to_d[i] = linear_from_sRGB(i/255.); + sRGB_to_d[255] = 1; + + g22_to_d[0] = 0; + for (i=1; i<255; ++i) + g22_to_d[i] = pow(i/255., 1/.45455); + g22_to_d[255] = 1; +} + +static png_byte +sRGB(double linear /*range 0.0 .. 1.0*/) +{ + return u8d(255 * sRGB_from_linear(linear)); +} + +static png_byte +isRGB(int fixed_linear) +{ + return sRGB(fixed_linear / 65535.); +} + +#if 0 /* not used */ +static png_byte +unpremultiply(int component, int alpha) +{ + if (alpha <= component) + return 255; /* Arbitrary, but consistent with the libpng code */ + + else if (alpha >= 65535) + return isRGB(component); + + else + return sRGB((double)component / alpha); +} +#endif + +static png_uint_16 +ilinear(int fixed_srgb) +{ + return u16d(65535 * sRGB_to_d[fixed_srgb]); +} + +static png_uint_16 +ilineara(int fixed_srgb, int alpha) +{ + return u16d((257 * alpha) * sRGB_to_d[fixed_srgb]); +} + +static png_uint_16 +ilinear_g22(int fixed_srgb) +{ + return u16d(65535 * g22_to_d[fixed_srgb]); +} + +#if ALLOW_UNUSED_GPC +static png_uint_16 +ilineara_g22(int fixed_srgb, int alpha) +{ + return u16d((257 * alpha) * g22_to_d[fixed_srgb]); +} +#endif + +static double +YfromRGBint(int ir, int ig, int ib) +{ + double r = ir; + double g = ig; + double b = ib; + return YfromRGB(r, g, b); +} + +#if 0 /* unused */ +/* The error that results from using a 2.2 power law in place of the correct + * sRGB transform, given an 8-bit value which might be either sRGB or power-law. + */ +static int +power_law_error8(int value) +{ + if (value > 0 && value < 255) + { + double vd = value / 255.; + double e = fabs( + pow(sRGB_to_d[value], 1/2.2) - sRGB_from_linear(pow(vd, 2.2))); + + /* Always allow an extra 1 here for rounding errors */ + e = 1+floor(255 * e); + return (int)e; + } + + return 0; +} + +static int error_in_sRGB_roundtrip = 56; /* by experiment */ +static int +power_law_error16(int value) +{ + if (value > 0 && value < 65535) + { + /* Round trip the value through an 8-bit representation but using + * non-matching to/from conversions. + */ + double vd = value / 65535.; + double e = fabs( + pow(sRGB_from_linear(vd), 2.2) - linear_from_sRGB(pow(vd, 1/2.2))); + + /* Always allow an extra 1 here for rounding errors */ + e = error_in_sRGB_roundtrip+floor(65535 * e); + return (int)e; + } + + return 0; +} + +static int +compare_8bit(int v1, int v2, int error_limit, int multiple_algorithms) +{ + int e = abs(v1-v2); + int ev1, ev2; + + if (e <= error_limit) + return 1; + + if (!multiple_algorithms) + return 0; + + ev1 = power_law_error8(v1); + if (e <= ev1) + return 1; + + ev2 = power_law_error8(v2); + if (e <= ev2) + return 1; + + return 0; +} + +static int +compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms) +{ + int e = abs(v1-v2); + int ev1, ev2; + + if (e <= error_limit) + return 1; + + /* "multiple_algorithms" in this case means that a color-map has been + * involved somewhere, so we can deduce that the values were forced to 8-bit + * (like the via_linear case for 8-bit.) + */ + if (!multiple_algorithms) + return 0; + + ev1 = power_law_error16(v1); + if (e <= ev1) + return 1; + + ev2 = power_law_error16(v2); + if (e <= ev2) + return 1; + + return 0; +} +#endif /* unused */ + +#define USE_FILE 1 /* else memory */ +#define USE_STDIO 2 /* else use file name */ +#define STRICT 4 /* fail on warnings too */ +#define VERBOSE 8 +#define KEEP_TMPFILES 16 /* else delete temporary files */ +#define KEEP_GOING 32 +#define ACCUMULATE 64 +#define FAST_WRITE 128 +#define sRGB_16BIT 256 +#define NO_RESEED 512 /* do not reseed on each new file */ +#define GBG_ERROR 1024 /* do not ignore the gamma+background_rgb_to_gray + * libpng warning. */ + +static void +print_opts(png_uint_32 opts) +{ + if (opts & USE_FILE) + printf(" --file"); + if (opts & USE_STDIO) + printf(" --stdio"); + if (!(opts & STRICT)) + printf(" --nostrict"); + if (opts & VERBOSE) + printf(" --verbose"); + if (opts & KEEP_TMPFILES) + printf(" --preserve"); + if (opts & KEEP_GOING) + printf(" --keep-going"); + if (opts & ACCUMULATE) + printf(" --accumulate"); + if (!(opts & FAST_WRITE)) /* --fast is currently the default */ + printf(" --slow"); + if (opts & sRGB_16BIT) + printf(" --sRGB-16bit"); + if (opts & NO_RESEED) + printf(" --noreseed"); +#if PNG_LIBPNG_VER < 10700 /* else on by default */ + if (opts & GBG_ERROR) + printf(" --fault-gbg-warning"); +#endif +} + +#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */ + +/* A name table for all the formats - defines the format of the '+' arguments to + * pngstest. + */ +#define FORMAT_COUNT 64 +#define FORMAT_MASK 0x3f +static const char * const format_names[FORMAT_COUNT] = +{ + "sRGB-gray", + "sRGB-gray+alpha", + "sRGB-rgb", + "sRGB-rgb+alpha", + "linear-gray", + "linear-gray+alpha", + "linear-rgb", + "linear-rgb+alpha", + + "color-mapped-sRGB-gray", + "color-mapped-sRGB-gray+alpha", + "color-mapped-sRGB-rgb", + "color-mapped-sRGB-rgb+alpha", + "color-mapped-linear-gray", + "color-mapped-linear-gray+alpha", + "color-mapped-linear-rgb", + "color-mapped-linear-rgb+alpha", + + "sRGB-gray", + "sRGB-gray+alpha", + "sRGB-bgr", + "sRGB-bgr+alpha", + "linear-gray", + "linear-gray+alpha", + "linear-bgr", + "linear-bgr+alpha", + + "color-mapped-sRGB-gray", + "color-mapped-sRGB-gray+alpha", + "color-mapped-sRGB-bgr", + "color-mapped-sRGB-bgr+alpha", + "color-mapped-linear-gray", + "color-mapped-linear-gray+alpha", + "color-mapped-linear-bgr", + "color-mapped-linear-bgr+alpha", + + "sRGB-gray", + "alpha+sRGB-gray", + "sRGB-rgb", + "alpha+sRGB-rgb", + "linear-gray", + "alpha+linear-gray", + "linear-rgb", + "alpha+linear-rgb", + + "color-mapped-sRGB-gray", + "color-mapped-alpha+sRGB-gray", + "color-mapped-sRGB-rgb", + "color-mapped-alpha+sRGB-rgb", + "color-mapped-linear-gray", + "color-mapped-alpha+linear-gray", + "color-mapped-linear-rgb", + "color-mapped-alpha+linear-rgb", + + "sRGB-gray", + "alpha+sRGB-gray", + "sRGB-bgr", + "alpha+sRGB-bgr", + "linear-gray", + "alpha+linear-gray", + "linear-bgr", + "alpha+linear-bgr", + + "color-mapped-sRGB-gray", + "color-mapped-alpha+sRGB-gray", + "color-mapped-sRGB-bgr", + "color-mapped-alpha+sRGB-bgr", + "color-mapped-linear-gray", + "color-mapped-alpha+linear-gray", + "color-mapped-linear-bgr", + "color-mapped-alpha+linear-bgr", +}; + +/* Decode an argument to a format number. */ +static png_uint_32 +formatof(const char *arg) +{ + char *ep; + unsigned long format = strtoul(arg, &ep, 0); + + if (ep > arg && *ep == 0 && format < FORMAT_COUNT) + return (png_uint_32)format; + + else for (format=0; format < FORMAT_COUNT; ++format) + { + if (strcmp(format_names[format], arg) == 0) + return (png_uint_32)format; + } + + fprintf(stderr, "pngstest: format name '%s' invalid\n", arg); + return FORMAT_COUNT; +} + +/* Bitset/test functions for formats */ +#define FORMAT_SET_COUNT (FORMAT_COUNT / 32) +typedef struct +{ + png_uint_32 bits[FORMAT_SET_COUNT]; +} +format_list; + +static void format_init(format_list *pf) +{ + int i; + for (i=0; ibits[i] = 0; /* All off */ +} + +#if 0 /* currently unused */ +static void format_clear(format_list *pf) +{ + int i; + for (i=0; ibits[i] = 0; +} +#endif + +static int format_is_initial(format_list *pf) +{ + int i; + for (i=0; ibits[i] != 0) + return 0; + + return 1; +} + +static int format_set(format_list *pf, png_uint_32 format) +{ + if (format < FORMAT_COUNT) + return pf->bits[format >> 5] |= ((png_uint_32)1) << (format & 31); + + return 0; +} + +#if 0 /* currently unused */ +static int format_unset(format_list *pf, png_uint_32 format) +{ + if (format < FORMAT_COUNT) + return pf->bits[format >> 5] &= ~((png_uint_32)1) << (format & 31); + + return 0; +} +#endif + +static int format_isset(format_list *pf, png_uint_32 format) +{ + return format < FORMAT_COUNT && + (pf->bits[format >> 5] & (((png_uint_32)1) << (format & 31))) != 0; +} + +static void format_default(format_list *pf, int redundant) +{ + if (redundant) + { + int i; + + /* set everything, including flags that are pointless */ + for (i=0; ibits[i] = ~(png_uint_32)0; + } + + else + { + png_uint_32 f; + + for (f=0; finput_file != NULL) + rewind(image->input_file); +} + +/* Free the image buffer; the buffer is re-used on a re-read, this is just for + * cleanup. + */ +static void +freebuffer(Image *image) +{ + if (image->buffer) free(image->buffer); + image->buffer = NULL; + image->bufsize = 0; + image->allocsize = 0; +} + +/* Delete function; cleans out all the allocated data and the temporary file in + * the image. + */ +static void +freeimage(Image *image) +{ + freebuffer(image); + png_image_free(&image->image); + + if (image->input_file != NULL) + { + fclose(image->input_file); + image->input_file = NULL; + } + + if (image->input_memory != NULL) + { + free(image->input_memory); + image->input_memory = NULL; + image->input_memory_size = 0; + } + + if (image->tmpfile_name[0] != 0 && (image->opts & KEEP_TMPFILES) == 0) + { + (void)remove(image->tmpfile_name); + image->tmpfile_name[0] = 0; + } +} + +/* This is actually a re-initializer; allows an image structure to be re-used by + * freeing everything that relates to an old image. + */ +static void initimage(Image *image, png_uint_32 opts, const char *file_name, + int stride_extra) +{ + freeimage(image); + memset(&image->image, 0, sizeof image->image); + image->opts = opts; + image->file_name = file_name; + image->stride_extra = stride_extra; +} + +/* Make sure the image buffer is big enough; allows re-use of the buffer if the + * image is re-read. + */ +#define BUFFER_INIT8 73 +static void +allocbuffer(Image *image) +{ + size_t size = PNG_IMAGE_BUFFER_SIZE(image->image, image->stride); + + if (size+32 > image->bufsize) + { + freebuffer(image); + image->buffer = voidcast(png_bytep, malloc(size+32)); + if (image->buffer == NULL) + { + fflush(stdout); + fprintf(stderr, + "simpletest: out of memory allocating %lu(+32) byte buffer\n", + (unsigned long)size); + exit(1); + } + image->bufsize = size+32; + } + + memset(image->buffer, 95, image->bufsize); + memset(image->buffer+16, BUFFER_INIT8, size); + image->allocsize = size; +} + +/* Make sure 16 bytes match the given byte. */ +static int +check16(png_const_bytep bp, int b) +{ + int i = 16; + + do + if (*bp != b) return 1; + while (--i); + + return 0; +} + +/* Check for overwrite in the image buffer. */ +static void +checkbuffer(Image *image, const char *arg) +{ + if (check16(image->buffer, 95)) + { + fflush(stdout); + fprintf(stderr, "%s: overwrite at start of image buffer\n", arg); + exit(1); + } + + if (check16(image->buffer+16+image->allocsize, 95)) + { + fflush(stdout); + fprintf(stderr, "%s: overwrite at end of image buffer\n", arg); + exit(1); + } +} + +/* ERROR HANDLING */ +/* Log a terminal error, also frees the libpng part of the image if necessary. + */ +static int +logerror(Image *image, const char *a1, const char *a2, const char *a3) +{ + fflush(stdout); + if (image->image.warning_or_error) + fprintf(stderr, "%s%s%s: %s\n", a1, a2, a3, image->image.message); + + else + fprintf(stderr, "%s%s%s\n", a1, a2, a3); + + if (image->image.opaque != NULL) + { + fprintf(stderr, "%s: image opaque pointer non-NULL on error\n", + image->file_name); + png_image_free(&image->image); + } + + return 0; +} + +/* Log an error and close a file (just a utility to do both things in one + * function call.) + */ +static int +logclose(Image *image, FILE *f, const char *name, const char *operation) +{ + int e = errno; + + fclose(f); + return logerror(image, name, operation, strerror(e)); +} + +/* Make sure the png_image has been freed - validates that libpng is doing what + * the spec says and freeing the image. + */ +static int +checkopaque(Image *image) +{ + if (image->image.opaque != NULL) + { + png_image_free(&image->image); + return logerror(image, image->file_name, ": opaque not NULL", ""); + } + + /* Separate out the gamma+background_rgb_to_gray warning because it may + * produce opaque component errors: + */ + else if (image->image.warning_or_error != 0 && + (strcmp(image->image.message, + "libpng does not support gamma+background+rgb_to_gray") == 0 ? + (image->opts & GBG_ERROR) != 0 : (image->opts & STRICT) != 0)) + return logerror(image, image->file_name, (image->opts & GBG_ERROR) != 0 ? + " --fault-gbg-warning" : " --strict", ""); + + else + return 1; +} + +/* IMAGE COMPARISON/CHECKING */ +/* Compare the pixels of two images, which should be the same but aren't. The + * images must have been checked for a size match. + */ +typedef struct +{ + /* The components, for grayscale images the gray value is in 'g' and if alpha + * is not present 'a' is set to 255 or 65535 according to format. + */ + int r, g, b, a; +} Pixel; + +typedef struct +{ + /* The background as the original sRGB 8-bit value converted to the final + * integer format and as a double precision linear value in the range 0..1 + * for with partially transparent pixels. + */ + int ir, ig, ib; + double dr, dg, db; /* linear r,g,b scaled to 0..1 */ +} Background; + +/* Basic image formats; control the data but not the layout thereof. */ +#define BASE_FORMATS\ + (PNG_FORMAT_FLAG_ALPHA|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_LINEAR) + +/* Read a Pixel from a buffer. The code below stores the correct routine for + * the format in a function pointer, these are the routines: + */ +static void +gp_g8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = p->g = p->b = pp[0]; + p->a = 255; +} + +static void +gp_ga8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = p->g = p->b = pp[0]; + p->a = pp[1]; +} + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_ag8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = p->g = p->b = pp[1]; + p->a = pp[0]; +} +#endif + +static void +gp_rgb8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = 255; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgr8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = 255; +} +#endif + +static void +gp_rgba8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = pp[3]; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgra8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = pp[3]; +} +#endif + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_argb8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[1]; + p->g = pp[2]; + p->b = pp[3]; + p->a = pp[0]; +} +#endif + +#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED) +static void +gp_abgr8(Pixel *p, png_const_voidp pb) +{ + png_const_bytep pp = voidcast(png_const_bytep, pb); + + p->r = pp[3]; + p->g = pp[2]; + p->b = pp[1]; + p->a = pp[0]; +} +#endif + +static void +gp_g16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = p->g = p->b = pp[0]; + p->a = 65535; +} + +static void +gp_ga16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = p->g = p->b = pp[0]; + p->a = pp[1]; +} + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_ag16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = p->g = p->b = pp[1]; + p->a = pp[0]; +} +#endif + +static void +gp_rgb16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = 65535; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgr16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = 65535; +} +#endif + +static void +gp_rgba16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[0]; + p->g = pp[1]; + p->b = pp[2]; + p->a = pp[3]; +} + +#ifdef PNG_FORMAT_BGR_SUPPORTED +static void +gp_bgra16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[2]; + p->g = pp[1]; + p->b = pp[0]; + p->a = pp[3]; +} +#endif + +#ifdef PNG_FORMAT_AFIRST_SUPPORTED +static void +gp_argb16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[1]; + p->g = pp[2]; + p->b = pp[3]; + p->a = pp[0]; +} +#endif + +#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED) +static void +gp_abgr16(Pixel *p, png_const_voidp pb) +{ + png_const_uint_16p pp = voidcast(png_const_uint_16p, pb); + + p->r = pp[3]; + p->g = pp[2]; + p->b = pp[1]; + p->a = pp[0]; +} +#endif + +/* Given a format, return the correct one of the above functions. */ +static void (* +get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb) +{ + /* The color-map flag is irrelevant here - the caller of the function + * returned must either pass the buffer or, for a color-mapped image, the + * correct entry in the color-map. + */ + if (format & PNG_FORMAT_FLAG_LINEAR) + { + if (format & PNG_FORMAT_FLAG_COLOR) + { +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_abgr16; + + else +# endif + return gp_bgra16; + } + + else + return gp_bgr16; + } + + else +# endif + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_argb16; + + else +# endif + return gp_rgba16; + } + + else + return gp_rgb16; + } + } + + else + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_ag16; + + else +# endif + return gp_ga16; + } + + else + return gp_g16; + } + } + + else + { + if (format & PNG_FORMAT_FLAG_COLOR) + { +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_abgr8; + + else +# endif + return gp_bgra8; + } + + else + return gp_bgr8; + } + + else +# endif + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_argb8; + + else +# endif + return gp_rgba8; + } + + else + return gp_rgb8; + } + } + + else + { + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + return gp_ag8; + + else +# endif + return gp_ga8; + } + + else + return gp_g8; + } + } +} + +/* Conversion between pixel formats. The code above effectively eliminates the + * component ordering changes leaving three basic changes: + * + * 1) Remove an alpha channel by pre-multiplication or compositing on a + * background color. (Adding an alpha channel is a no-op.) + * + * 2) Remove color by mapping to grayscale. (Grayscale to color is a no-op.) + * + * 3) Convert between 8-bit and 16-bit components. (Both directtions are + * relevant.) + * + * This gives the following base format conversion matrix: + * + * OUT: ----- 8-bit ----- ----- 16-bit ----- + * IN G GA RGB RGBA G GA RGB RGBA + * 8 G . . . . lin lin lin lin + * 8 GA bckg . bckc . pre' pre pre' pre + * 8 RGB g8 g8 . . glin glin lin lin + * 8 RGBA g8b g8 bckc . gpr' gpre pre' pre + * 16 G sRGB sRGB sRGB sRGB . . . . + * 16 GA b16g unpg b16c unpc A . A . + * 16 RGB sG sG sRGB sRGB g16 g16 . . + * 16 RGBA gb16 sGp cb16 sCp g16 g16' A . + * + * 8-bit to 8-bit: + * bckg: composite on gray background + * bckc: composite on color background + * g8: convert sRGB components to sRGB grayscale + * g8b: convert sRGB components to grayscale and composite on gray background + * + * 8-bit to 16-bit: + * lin: make sRGB components linear, alpha := 65535 + * pre: make sRGB components linear and premultiply by alpha (scale alpha) + * pre': as 'pre' but alpha := 65535 + * glin: make sRGB components linear, convert to grayscale, alpha := 65535 + * gpre: make sRGB components grayscale and linear and premultiply by alpha + * gpr': as 'gpre' but alpha := 65535 + * + * 16-bit to 8-bit: + * sRGB: convert linear components to sRGB, alpha := 255 + * unpg: unpremultiply gray component and convert to sRGB (scale alpha) + * unpc: unpremultiply color components and convert to sRGB (scale alpha) + * b16g: composite linear onto gray background and convert the result to sRGB + * b16c: composite linear onto color background and convert the result to sRGB + * sG: convert linear RGB to sRGB grayscale + * sGp: unpremultiply RGB then convert to sRGB grayscale + * sCp: unpremultiply RGB then convert to sRGB + * gb16: composite linear onto background and convert to sRGB grayscale + * (order doesn't matter, the composite and grayscale operations permute) + * cb16: composite linear onto background and convert to sRGB + * + * 16-bit to 16-bit: + * A: set alpha to 65535 + * g16: convert linear RGB to linear grayscale (alpha := 65535) + * g16': as 'g16' but alpha is unchanged + */ +/* Simple copy: */ +static void +gpc_noop(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = in->r; + out->g = in->g; + out->b = in->b; + out->a = in->a; +} + +#if ALLOW_UNUSED_GPC +static void +gpc_nop8(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + if (in->a == 0) + out->r = out->g = out->b = 255; + + else + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + + out->a = in->a; +} +#endif + +#if ALLOW_UNUSED_GPC +static void +gpc_nop6(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + if (in->a == 0) + out->r = out->g = out->b = 65535; + + else + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + + out->a = in->a; +} +#endif + +/* 8-bit to 8-bit conversions */ +/* bckg: composite on gray background */ +static void +gpc_bckg(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else if (in->a >= 255) + out->r = out->g = out->b = in->g; + + else + { + double a = in->a / 255.; + + out->r = out->g = out->b = sRGB(sRGB_to_d[in->g] * a + back->dg * (1-a)); + } + + out->a = 255; +} + +/* bckc: composite on color background */ +static void +gpc_bckc(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + { + out->r = back->ir; + out->g = back->ig; + out->b = back->ib; + } + + else if (in->a >= 255) + { + out->r = in->r; + out->g = in->g; + out->b = in->b; + } + + else + { + double a = in->a / 255.; + + out->r = sRGB(sRGB_to_d[in->r] * a + back->dr * (1-a)); + out->g = sRGB(sRGB_to_d[in->g] * a + back->dg * (1-a)); + out->b = sRGB(sRGB_to_d[in->b] * a + back->db * (1-a)); + } + + out->a = 255; +} + +/* g8: convert sRGB components to sRGB grayscale */ +static void +gpc_g8(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = in->g; + + else + out->r = out->g = out->b = + sRGB(YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = in->a; +} + +/* g8b: convert sRGB components to grayscale and composite on gray background */ +static void +gpc_g8b(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else if (in->a >= 255) + { + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = in->g; + + else + out->r = out->g = out->b = sRGB(YfromRGB( + sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + } + + else + { + double a = in->a/255.; + + out->r = out->g = out->b = sRGB(a * YfromRGB(sRGB_to_d[in->r], + sRGB_to_d[in->g], sRGB_to_d[in->b]) + back->dg * (1-a)); + } + + out->a = 255; +} + +/* 8-bit to 16-bit conversions */ +/* lin: make sRGB components linear, alpha := 65535 */ +static void +gpc_lin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilinear(in->r); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilinear(in->b); + } + + else + { + out->g = ilinear(in->g); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilinear(in->b); + } + + out->a = 65535; +} + +/* pre: make sRGB components linear and premultiply by alpha (scale alpha) */ +static void +gpc_pre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara(in->b, in->a); + } + + else + { + out->g = ilineara(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara(in->b, in->a); + } + + out->a = in->a * 257; +} + +/* pre': as 'pre' but alpha := 65535 */ +static void +gpc_preq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara(in->b, in->a); + } + + else + { + out->g = ilineara(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara(in->b, in->a); + } + + out->a = 65535; +} + +/* glin: make sRGB components linear, convert to grayscale, alpha := 65535 */ +static void +gpc_glin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilinear(in->g); + + else + out->r = out->g = out->b = u16d(65535 * + YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = 65535; +} + +/* gpre: make sRGB components grayscale and linear and premultiply by alpha */ +static void +gpc_gpre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = 257 * in->a; +} + +/* gpr': as 'gpre' but alpha := 65535 */ +static void +gpc_gprq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(sRGB_to_d[in->r], sRGB_to_d[in->g], sRGB_to_d[in->b])); + + out->a = 65535; +} + +/* 8-bit to 16-bit conversions for gAMA 45455 encoded values */ +/* Lin: make gAMA 45455 components linear, alpha := 65535 */ +static void +gpc_Lin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilinear_g22(in->r); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilinear_g22(in->b); + } + + else + { + out->g = ilinear_g22(in->g); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilinear_g22(in->b); + } + + out->a = 65535; +} + +#if ALLOW_UNUSED_GPC +/* Pre: make gAMA 45455 components linear and premultiply by alpha (scale alpha) + */ +static void +gpc_Pre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara_g22(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara_g22(in->b, in->a); + } + + else + { + out->g = ilineara_g22(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara_g22(in->b, in->a); + } + + out->a = in->a * 257; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Pre': as 'Pre' but alpha := 65535 */ +static void +gpc_Preq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = ilineara_g22(in->r, in->a); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = ilineara_g22(in->b, in->a); + } + + else + { + out->g = ilineara_g22(in->g, in->a); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = ilineara_g22(in->b, in->a); + } + + out->a = 65535; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Glin: make gAMA 45455 components linear, convert to grayscale, alpha := 65535 + */ +static void +gpc_Glin(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilinear_g22(in->g); + + else + out->r = out->g = out->b = u16d(65535 * + YfromRGB(g22_to_d[in->r], g22_to_d[in->g], g22_to_d[in->b])); + + out->a = 65535; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Gpre: make gAMA 45455 components grayscale and linear and premultiply by + * alpha. + */ +static void +gpc_Gpre(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara_g22(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(g22_to_d[in->r], g22_to_d[in->g], g22_to_d[in->b])); + + out->a = 257 * in->a; +} +#endif + +#if ALLOW_UNUSED_GPC +/* Gpr': as 'Gpre' but alpha := 65535 */ +static void +gpc_Gprq(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->r == in->g && in->g == in->b) + out->r = out->g = out->b = ilineara_g22(in->g, in->a); + + else + out->r = out->g = out->b = u16d(in->a * 257 * + YfromRGB(g22_to_d[in->r], g22_to_d[in->g], g22_to_d[in->b])); + + out->a = 65535; +} +#endif + +/* 16-bit to 8-bit conversions */ +/* sRGB: convert linear components to sRGB, alpha := 255 */ +static void +gpc_sRGB(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = isRGB(in->r); + + if (in->g == in->r) + { + out->g = out->r; + + if (in->b == in->r) + out->b = out->r; + + else + out->b = isRGB(in->b); + } + + else + { + out->g = isRGB(in->g); + + if (in->b == in->r) + out->b = out->r; + + else if (in->b == in->g) + out->b = out->g; + + else + out->b = isRGB(in->b); + } + + out->a = 255; +} + +/* unpg: unpremultiply gray component and convert to sRGB (scale alpha) */ +static void +gpc_unpg(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = out->g = out->b = sRGB((double)in->g / in->a); + out->a = u8d(in->a / 257.); + } +} + +/* unpc: unpremultiply color components and convert to sRGB (scale alpha) */ +static void +gpc_unpc(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = sRGB((double)in->r / in->a); + out->g = sRGB((double)in->g / in->a); + out->b = sRGB((double)in->b / in->a); + out->a = u8d(in->a / 257.); + } +} + +/* b16g: composite linear onto gray background and convert the result to sRGB */ +static void +gpc_b16g(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else + { + double a = in->a/65535.; + double a1 = 1-a; + + a /= 65535; + out->r = out->g = out->b = sRGB(in->g * a + back->dg * a1); + } + + out->a = 255; +} + +/* b16c: composite linear onto color background and convert the result to sRGB*/ +static void +gpc_b16c(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + { + out->r = back->ir; + out->g = back->ig; + out->b = back->ib; + } + + else + { + double a = in->a/65535.; + double a1 = 1-a; + + a /= 65535; + out->r = sRGB(in->r * a + back->dr * a1); + out->g = sRGB(in->g * a + back->dg * a1); + out->b = sRGB(in->b * a + back->db * a1); + } + + out->a = 255; +} + +/* sG: convert linear RGB to sRGB grayscale */ +static void +gpc_sG(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + out->r = out->g = out->b = sRGB(YfromRGBint(in->r, in->g, in->b)/65535); + out->a = 255; +} + +/* sGp: unpremultiply RGB then convert to sRGB grayscale */ +static void +gpc_sGp(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = out->g = out->b = sRGB(YfromRGBint(in->r, in->g, in->b)/in->a); + out->a = u8d(in->a / 257.); + } +} + +/* sCp: unpremultiply RGB then convert to sRGB */ +static void +gpc_sCp(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + + if (in->a <= 128) + { + out->r = out->g = out->b = 255; + out->a = 0; + } + + else + { + out->r = sRGB((double)in->r / in->a); + out->g = sRGB((double)in->g / in->a); + out->b = sRGB((double)in->b / in->a); + out->a = u8d(in->a / 257.); + } +} + +/* gb16: composite linear onto background and convert to sRGB grayscale */ +/* (order doesn't matter, the composite and grayscale operations permute) */ +static void +gpc_gb16(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + out->r = out->g = out->b = back->ig; + + else if (in->a >= 65535) + out->r = out->g = out->b = isRGB(in->g); + + else + { + double a = in->a / 65535.; + double a1 = 1-a; + + a /= 65535; + out->r = out->g = out->b = sRGB(in->g * a + back->dg * a1); + } + + out->a = 255; +} + +/* cb16: composite linear onto background and convert to sRGB */ +static void +gpc_cb16(Pixel *out, const Pixel *in, const Background *back) +{ + if (in->a <= 0) + { + out->r = back->ir; + out->g = back->ig; + out->b = back->ib; + } + + else if (in->a >= 65535) + { + out->r = isRGB(in->r); + out->g = isRGB(in->g); + out->b = isRGB(in->b); + } + + else + { + double a = in->a / 65535.; + double a1 = 1-a; + + a /= 65535; + out->r = sRGB(in->r * a + back->dr * a1); + out->g = sRGB(in->g * a + back->dg * a1); + out->b = sRGB(in->b * a + back->db * a1); + } + + out->a = 255; +} + +/* 16-bit to 16-bit conversions */ +/* A: set alpha to 65535 */ +static void +gpc_A(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = in->r; + out->g = in->g; + out->b = in->b; + out->a = 65535; +} + +/* g16: convert linear RGB to linear grayscale (alpha := 65535) */ +static void +gpc_g16(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = out->g = out->b = u16d(YfromRGBint(in->r, in->g, in->b)); + out->a = 65535; +} + +/* g16': as 'g16' but alpha is unchanged */ +static void +gpc_g16q(Pixel *out, const Pixel *in, const Background *back) +{ + (void)back; + out->r = out->g = out->b = u16d(YfromRGBint(in->r, in->g, in->b)); + out->a = in->a; +} + +#if ALLOW_UNUSED_GPC +/* Unused functions (to hide them from GCC unused function warnings) */ +void (* const gpc_unused[]) + (Pixel *out, const Pixel *in, const Background *back) = +{ + gpc_Pre, gpc_Preq, gpc_Glin, gpc_Gpre, gpc_Gprq, gpc_nop8, gpc_nop6 +}; +#endif + +/* OUT: ----- 8-bit ----- ----- 16-bit ----- + * IN G GA RGB RGBA G GA RGB RGBA + * 8 G . . . . lin lin lin lin + * 8 GA bckg . bckc . pre' pre pre' pre + * 8 RGB g8 g8 . . glin glin lin lin + * 8 RGBA g8b g8 bckc . gpr' gpre pre' pre + * 16 G sRGB sRGB sRGB sRGB . . . . + * 16 GA b16g unpg b16c unpc A . A . + * 16 RGB sG sG sRGB sRGB g16 g16 . . + * 16 RGBA gb16 sGp cb16 sCp g16 g16' A . + * + * The matrix is held in an array indexed thus: + * + * gpc_fn[out_format & BASE_FORMATS][in_format & BASE_FORMATS]; + */ +/* This will produce a compile time error if the FORMAT_FLAG values don't + * match the above matrix! + */ +#if PNG_FORMAT_FLAG_ALPHA == 1 && PNG_FORMAT_FLAG_COLOR == 2 &&\ + PNG_FORMAT_FLAG_LINEAR == 4 +static void (* const gpc_fn[8/*in*/][8/*out*/]) + (Pixel *out, const Pixel *in, const Background *back) = +{ +/*out: G-8 GA-8 RGB-8 RGBA-8 G-16 GA-16 RGB-16 RGBA-16 */ + {gpc_noop,gpc_noop,gpc_noop,gpc_noop, gpc_Lin, gpc_Lin, gpc_Lin, gpc_Lin }, + {gpc_bckg,gpc_noop,gpc_bckc,gpc_noop, gpc_preq,gpc_pre, gpc_preq,gpc_pre }, + {gpc_g8, gpc_g8, gpc_noop,gpc_noop, gpc_glin,gpc_glin,gpc_lin, gpc_lin }, + {gpc_g8b, gpc_g8, gpc_bckc,gpc_noop, gpc_gprq,gpc_gpre,gpc_preq,gpc_pre }, + {gpc_sRGB,gpc_sRGB,gpc_sRGB,gpc_sRGB, gpc_noop,gpc_noop,gpc_noop,gpc_noop}, + {gpc_b16g,gpc_unpg,gpc_b16c,gpc_unpc, gpc_A, gpc_noop,gpc_A, gpc_noop}, + {gpc_sG, gpc_sG, gpc_sRGB,gpc_sRGB, gpc_g16, gpc_g16, gpc_noop,gpc_noop}, + {gpc_gb16,gpc_sGp, gpc_cb16,gpc_sCp, gpc_g16, gpc_g16q,gpc_A, gpc_noop} +}; + +/* The array is repeated for the cases where both the input and output are color + * mapped because then different algorithms are used. + */ +static void (* const gpc_fn_colormapped[8/*in*/][8/*out*/]) + (Pixel *out, const Pixel *in, const Background *back) = +{ +/*out: G-8 GA-8 RGB-8 RGBA-8 G-16 GA-16 RGB-16 RGBA-16 */ + {gpc_noop,gpc_noop,gpc_noop,gpc_noop, gpc_lin, gpc_lin, gpc_lin, gpc_lin }, + {gpc_bckg,gpc_noop,gpc_bckc,gpc_noop, gpc_preq,gpc_pre, gpc_preq,gpc_pre }, + {gpc_g8, gpc_g8, gpc_noop,gpc_noop, gpc_glin,gpc_glin,gpc_lin, gpc_lin }, + {gpc_g8b, gpc_g8, gpc_bckc,gpc_noop, gpc_gprq,gpc_gpre,gpc_preq,gpc_pre }, + {gpc_sRGB,gpc_sRGB,gpc_sRGB,gpc_sRGB, gpc_noop,gpc_noop,gpc_noop,gpc_noop}, + {gpc_b16g,gpc_unpg,gpc_b16c,gpc_unpc, gpc_A, gpc_noop,gpc_A, gpc_noop}, + {gpc_sG, gpc_sG, gpc_sRGB,gpc_sRGB, gpc_g16, gpc_g16, gpc_noop,gpc_noop}, + {gpc_gb16,gpc_sGp, gpc_cb16,gpc_sCp, gpc_g16, gpc_g16q,gpc_A, gpc_noop} +}; + +/* The error arrays record the error in the same matrix; 64 entries, however + * the different algorithms used in libpng for colormap and direct conversions + * mean that four separate matrices are used (for each combination of + * colormapped and direct.) + * + * In some cases the conversion between sRGB formats goes via a linear + * intermediate; an sRGB to linear conversion (as above) is followed by a simple + * linear to sRGB step with no other conversions. This is done by a separate + * error array from an arbitrary 'in' format to one of the four basic outputs + * (since final output is always sRGB not colormapped). + * + * These arrays may be modified if the --accumulate flag is set during the run; + * then instead of logging errors they are simply added in. + * + * The three entries are currently for transparent, partially transparent and + * opaque input pixel values. Notice that alpha should be exact in each case. + * + * Errors in alpha should only occur when converting from a direct format + * to a colormapped format, when alpha is effectively smashed (so large + * errors can occur.) There should be no error in the '0' and 'opaque' + * values. The fourth entry in the array is used for the alpha error (and it + * should always be zero for the 'via linear' case since this is never color + * mapped.) + * + * Mapping to a colormap smashes the colors, it is necessary to have separate + * values for these cases because they are much larger; it is very much + * impossible to obtain a reasonable result, these are held in + * gpc_error_to_colormap. + */ +#if PNG_FORMAT_FLAG_COLORMAP == 8 /* extra check also required */ +# include "pngstest-errors.h" /* machine generated */ +#endif /* COLORMAP flag check */ +#endif /* flag checks */ + +typedef struct +{ + /* Basic pixel information: */ + Image* in_image; /* Input image */ + const Image* out_image; /* Output image */ + + /* 'background' is the value passed to the gpc_ routines, it may be NULL if + * it should not be used (*this* program has an error if it crashes as a + * result!) + */ + Background background_color; + const Background* background; + + /* Precalculated values: */ + int in_opaque; /* Value of input alpha that is opaque */ + int is_palette; /* Sample values come from the palette */ + int accumulate; /* Accumulate component errors (don't log) */ + int output_8bit; /* Output is 8-bit (else 16-bit) */ + + void (*in_gp)(Pixel*, png_const_voidp); + void (*out_gp)(Pixel*, png_const_voidp); + + void (*transform)(Pixel *out, const Pixel *in, const Background *back); + /* A function to perform the required transform */ + + void (*from_linear)(Pixel *out, const Pixel *in, const Background *back); + /* For 'via_linear' transforms the final, from linear, step, else NULL */ + + png_uint_16 error[4]; + /* Three error values for transparent, partially transparent and opaque + * input pixels (in turn). + */ + + png_uint_16 *error_ptr; + /* Where these are stored in the static array (for 'accumulate') */ +} +Transform; + +/* Return a 'transform' as above for the given format conversion. */ +static void +transform_from_formats(Transform *result, Image *in_image, + const Image *out_image, png_const_colorp background, int via_linear) +{ + png_uint_32 in_format, out_format; + png_uint_32 in_base, out_base; + + memset(result, 0, sizeof *result); + + /* Store the original images for error messages */ + result->in_image = in_image; + result->out_image = out_image; + + in_format = in_image->image.format; + out_format = out_image->image.format; + + if (in_format & PNG_FORMAT_FLAG_LINEAR) + result->in_opaque = 65535; + else + result->in_opaque = 255; + + result->output_8bit = (out_format & PNG_FORMAT_FLAG_LINEAR) == 0; + + result->is_palette = 0; /* set by caller if required */ + result->accumulate = (in_image->opts & ACCUMULATE) != 0; + + /* The loaders (which need the ordering information) */ + result->in_gp = get_pixel(in_format); + result->out_gp = get_pixel(out_format); + + /* Remove the ordering information: */ + in_format &= BASE_FORMATS | PNG_FORMAT_FLAG_COLORMAP; + in_base = in_format & BASE_FORMATS; + out_format &= BASE_FORMATS | PNG_FORMAT_FLAG_COLORMAP; + out_base = out_format & BASE_FORMATS; + + if (via_linear) + { + /* Check for an error in this program: */ + if (out_format & (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLORMAP)) + { + fprintf(stderr, "internal transform via linear error 0x%x->0x%x\n", + in_format, out_format); + exit(1); + } + + result->transform = gpc_fn[in_base][out_base | PNG_FORMAT_FLAG_LINEAR]; + result->from_linear = gpc_fn[out_base | PNG_FORMAT_FLAG_LINEAR][out_base]; + result->error_ptr = gpc_error_via_linear[in_format][out_format]; + } + + else if (~in_format & out_format & PNG_FORMAT_FLAG_COLORMAP) + { + /* The input is not colormapped but the output is, the errors will + * typically be large (only the grayscale-no-alpha case permits preserving + * even 8-bit values.) + */ + result->transform = gpc_fn[in_base][out_base]; + result->from_linear = NULL; + result->error_ptr = gpc_error_to_colormap[in_base][out_base]; + } + + else + { + /* The caller handles the colormap->pixel value conversion, so the + * transform function just gets a pixel value, however because libpng + * currently contains a different implementation for mapping a colormap if + * both input and output are colormapped we need different conversion + * functions to deal with errors in the libpng implementation. + */ + if (in_format & out_format & PNG_FORMAT_FLAG_COLORMAP) + result->transform = gpc_fn_colormapped[in_base][out_base]; + else + result->transform = gpc_fn[in_base][out_base]; + result->from_linear = NULL; + result->error_ptr = gpc_error[in_format][out_format]; + } + + /* Follow the libpng simplified API rules to work out what to pass to the gpc + * routines as a background value, if one is not required pass NULL so that + * this program crashes in the even of a programming error. + */ + result->background = NULL; /* default: not required */ + + /* Rule 1: background only need be supplied if alpha is to be removed */ + if (in_format & ~out_format & PNG_FORMAT_FLAG_ALPHA) + { + /* The input value is 'NULL' to use the background and (otherwise) an sRGB + * background color (to use a solid color). The code above uses a fixed + * byte value, BUFFER_INIT8, for buffer even for 16-bit output. For + * linear (16-bit) output the sRGB background color is ignored; the + * composition is always on the background (so BUFFER_INIT8 * 257), except + * that for the colormap (i.e. linear colormapped output) black is used. + */ + result->background = &result->background_color; + + if (out_format & PNG_FORMAT_FLAG_LINEAR || via_linear) + { + if (out_format & PNG_FORMAT_FLAG_COLORMAP) + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = 0; + result->background_color.dr = + result->background_color.dg = + result->background_color.db = 0; + } + + else + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = BUFFER_INIT8 * 257; + result->background_color.dr = + result->background_color.dg = + result->background_color.db = 0; + } + } + + else /* sRGB output */ + { + if (background != NULL) + { + if (out_format & PNG_FORMAT_FLAG_COLOR) + { + result->background_color.ir = background->red; + result->background_color.ig = background->green; + result->background_color.ib = background->blue; + /* TODO: sometimes libpng uses the power law conversion here, how + * to handle this? + */ + result->background_color.dr = sRGB_to_d[background->red]; + result->background_color.dg = sRGB_to_d[background->green]; + result->background_color.db = sRGB_to_d[background->blue]; + } + + else /* grayscale: libpng only looks at 'g' */ + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = background->green; + /* TODO: sometimes libpng uses the power law conversion here, how + * to handle this? + */ + result->background_color.dr = + result->background_color.dg = + result->background_color.db = sRGB_to_d[background->green]; + } + } + + else if ((out_format & PNG_FORMAT_FLAG_COLORMAP) == 0) + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = BUFFER_INIT8; + /* TODO: sometimes libpng uses the power law conversion here, how + * to handle this? + */ + result->background_color.dr = + result->background_color.dg = + result->background_color.db = sRGB_to_d[BUFFER_INIT8]; + } + + /* Else the output is colormapped and a background color must be + * provided; if pngstest crashes then that is a bug in this program + * (though libpng should png_error as well.) + */ + else + result->background = NULL; + } + } + + if (result->background == NULL) + { + result->background_color.ir = + result->background_color.ig = + result->background_color.ib = -1; /* not used */ + result->background_color.dr = + result->background_color.dg = + result->background_color.db = 1E30; /* not used */ + } + + + /* Copy the error values into the Transform: */ + result->error[0] = result->error_ptr[0]; + result->error[1] = result->error_ptr[1]; + result->error[2] = result->error_ptr[2]; + result->error[3] = result->error_ptr[3]; +} + + +/* Compare two pixels. + * + * OLD error values: +static int error_to_linear = 811; * by experiment * +static int error_to_linear_grayscale = 424; * by experiment * +static int error_to_sRGB = 6; * by experiment * +static int error_to_sRGB_grayscale = 17; * libpng error by calculation + + 2 by experiment * +static int error_in_compose = 2; * by experiment * +static int error_in_premultiply = 1; + * + * The following is *just* the result of a round trip from 8-bit sRGB to linear + * then back to 8-bit sRGB when it is done by libpng. There are two problems: + * + * 1) libpng currently uses a 2.2 power law with no linear segment, this results + * in instability in the low values and even with 16-bit precision sRGB(1) ends + * up mapping to sRGB(0) as a result of rounding in the 16-bit representation. + * This gives an error of 1 in the handling of value 1 only. + * + * 2) libpng currently uses an intermediate 8-bit linear value in gamma + * correction of 8-bit values. This results in many more errors, the worse of + * which is mapping sRGB(14) to sRGB(0). + * + * The general 'error_via_linear' is more complex because of pre-multiplication, + * this compounds the 8-bit errors according to the alpha value of the pixel. + * As a result 256 values are pre-calculated for error_via_linear. + */ +#if 0 +static int error_in_libpng_gamma; +static int error_via_linear[256]; /* Indexed by 8-bit alpha */ + +static void +init_error_via_linear(void) +{ + int alpha; + + error_via_linear[0] = 255; /* transparent pixel */ + + for (alpha=1; alpha<=255; ++alpha) + { + /* 16-bit values less than 128.5 get rounded to 8-bit 0 and so the worst + * case error arises with 16-bit 128.5, work out what sRGB + * (non-associated) value generates 128.5; any value less than this is + * going to map to 0, so the worst error is floor(value). + * + * Note that errors are considerably higher (more than a factor of 2) + * because libpng uses a simple power law for sRGB data at present. + * + * Add .1 for arithmetic errors inside libpng. + */ + double v = floor(255*pow(.5/*(128.5 * 255 / 65535)*/ / alpha, 1/2.2)+.1); + + error_via_linear[alpha] = (int)v; + } + + /* This is actually 14.99, but, despite the closeness to 15, 14 seems to work + * ok in this case. + */ + error_in_libpng_gamma = 14; +} +#endif + +static void +print_pixel(char string[64], const Pixel *pixel, png_uint_32 format) +{ + switch (format & (PNG_FORMAT_FLAG_ALPHA|PNG_FORMAT_FLAG_COLOR)) + { + case 0: + sprintf(string, "%s(%d)", format_names[format], pixel->g); + break; + + case PNG_FORMAT_FLAG_ALPHA: + sprintf(string, "%s(%d,%d)", format_names[format], pixel->g, + pixel->a); + break; + + case PNG_FORMAT_FLAG_COLOR: + sprintf(string, "%s(%d,%d,%d)", format_names[format], + pixel->r, pixel->g, pixel->b); + break; + + case PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA: + sprintf(string, "%s(%d,%d,%d,%d)", format_names[format], + pixel->r, pixel->g, pixel->b, pixel->a); + break; + + default: + sprintf(string, "invalid-format"); + break; + } +} + +static int +logpixel(const Transform *transform, png_uint_32 x, png_uint_32 y, + const Pixel *in, const Pixel *calc, const Pixel *out, const char *reason) +{ + png_uint_32 in_format = transform->in_image->image.format; + png_uint_32 out_format = transform->out_image->image.format; + + png_uint_32 back_format = out_format & ~PNG_FORMAT_FLAG_ALPHA; + const char *via_linear = ""; + + char pixel_in[64], pixel_calc[64], pixel_out[64], pixel_loc[64]; + char background_info[100]; + + print_pixel(pixel_in, in, in_format); + print_pixel(pixel_calc, calc, out_format); + print_pixel(pixel_out, out, out_format); + + if (transform->is_palette) + sprintf(pixel_loc, "palette: %lu", (unsigned long)y); + else + sprintf(pixel_loc, "%lu,%lu", (unsigned long)x, (unsigned long)y); + + if (transform->from_linear != NULL) + { + via_linear = " (via linear)"; + /* And as a result the *read* format which did any background processing + * was itself linear, so the background color information is also + * linear. + */ + back_format |= PNG_FORMAT_FLAG_LINEAR; + } + + if (transform->background != NULL) + { + Pixel back; + char pixel_back[64]; + + back.r = transform->background->ir; + back.g = transform->background->ig; + back.b = transform->background->ib; + back.a = -1; /* not used */ + + print_pixel(pixel_back, &back, back_format); + sprintf(background_info, " on background %s", pixel_back); + } + + else + background_info[0] = 0; + + if (transform->in_image->file_name != transform->out_image->file_name) + { + char error_buffer[512]; + sprintf(error_buffer, + "(%s) %s error%s:\n %s%s ->\n %s\n not: %s.\n" + "Use --preserve and examine: ", pixel_loc, reason, via_linear, + pixel_in, background_info, pixel_out, pixel_calc); + return logerror(transform->in_image, transform->in_image->file_name, + error_buffer, transform->out_image->file_name); + } + + else + { + char error_buffer[512]; + sprintf(error_buffer, + "(%s) %s error%s:\n %s%s ->\n %s\n not: %s.\n" + " The error happened when reading the original file with this format.", + pixel_loc, reason, via_linear, pixel_in, background_info, pixel_out, + pixel_calc); + return logerror(transform->in_image, transform->in_image->file_name, + error_buffer, ""); + } +} + +static int +cmppixel(Transform *transform, png_const_voidp in, png_const_voidp out, + png_uint_32 x, png_uint_32 y/*or palette index*/) +{ + int maxerr; + png_const_charp errmsg; + Pixel pixel_in, pixel_calc, pixel_out; + + transform->in_gp(&pixel_in, in); + + if (transform->from_linear == NULL) + transform->transform(&pixel_calc, &pixel_in, transform->background); + + else + { + transform->transform(&pixel_out, &pixel_in, transform->background); + transform->from_linear(&pixel_calc, &pixel_out, NULL); + } + + transform->out_gp(&pixel_out, out); + + /* Eliminate the case where the input and output values match exactly. */ + if (pixel_calc.a == pixel_out.a && pixel_calc.r == pixel_out.r && + pixel_calc.g == pixel_out.g && pixel_calc.b == pixel_out.b) + return 1; + + /* Eliminate the case where the output pixel is transparent and the output + * is 8-bit - any component values are valid. Don't check the input alpha + * here to also skip the 16-bit small alpha cases. + */ + if (transform->output_8bit && pixel_calc.a == 0 && pixel_out.a == 0) + return 1; + + /* Check for alpha errors first; an alpha error can damage the components too + * so avoid spurious checks on components if one is found. + */ + errmsg = NULL; + { + int err_a = abs(pixel_calc.a-pixel_out.a); + + if (err_a > transform->error[3]) + { + /* If accumulating check the components too */ + if (transform->accumulate) + transform->error[3] = (png_uint_16)err_a; + + else + errmsg = "alpha"; + } + } + + /* Now if *either* of the output alphas are 0 but alpha is within tolerance + * eliminate the 8-bit component comparison. + */ + if (errmsg == NULL && transform->output_8bit && + (pixel_calc.a == 0 || pixel_out.a == 0)) + return 1; + + if (errmsg == NULL) /* else just signal an alpha error */ + { + int err_r = abs(pixel_calc.r - pixel_out.r); + int err_g = abs(pixel_calc.g - pixel_out.g); + int err_b = abs(pixel_calc.b - pixel_out.b); + int limit; + + if ((err_r | err_g | err_b) == 0) + return 1; /* exact match */ + + /* Mismatch on a component, check the input alpha */ + if (pixel_in.a >= transform->in_opaque) + { + errmsg = "opaque component"; + limit = 2; /* opaque */ + } + + else if (pixel_in.a > 0) + { + errmsg = "alpha component"; + limit = 1; /* partially transparent */ + } + + else + { + errmsg = "transparent component (background)"; + limit = 0; /* transparent */ + } + + maxerr = err_r; + if (maxerr < err_g) maxerr = err_g; + if (maxerr < err_b) maxerr = err_b; + + if (maxerr <= transform->error[limit]) + return 1; /* within the error limits */ + + /* Handle a component mis-match; log it, just return an error code, or + * accumulate it. + */ + if (transform->accumulate) + { + transform->error[limit] = (png_uint_16)maxerr; + return 1; /* to cause the caller to keep going */ + } + } + + /* Failure to match and not accumulating, so the error must be logged. */ + return logpixel(transform, x, y, &pixel_in, &pixel_calc, &pixel_out, errmsg); +} + +static png_byte +component_loc(png_byte loc[4], png_uint_32 format) +{ + /* Given a format return the number of channels and the location of + * each channel. + * + * The mask 'loc' contains the component offset of the channels in the + * following order. Note that if 'format' is grayscale the entries 1-3 must + * all contain the location of the gray channel. + * + * 0: alpha + * 1: red or gray + * 2: green or gray + * 3: blue or gray + */ + png_byte channels; + + if (format & PNG_FORMAT_FLAG_COLOR) + { + channels = 3; + + loc[2] = 1; + +# ifdef PNG_FORMAT_BGR_SUPPORTED + if (format & PNG_FORMAT_FLAG_BGR) + { + loc[1] = 2; + loc[3] = 0; + } + + else +# endif + { + loc[1] = 0; + loc[3] = 2; + } + } + + else + { + channels = 1; + loc[1] = loc[2] = loc[3] = 0; + } + + if (format & PNG_FORMAT_FLAG_ALPHA) + { +# ifdef PNG_FORMAT_AFIRST_SUPPORTED + if (format & PNG_FORMAT_FLAG_AFIRST) + { + loc[0] = 0; + ++loc[1]; + ++loc[2]; + ++loc[3]; + } + + else +# endif + loc[0] = channels; + + ++channels; + } + + else + loc[0] = 4; /* not present */ + + return channels; +} + +/* Compare two images, the original 'a', which was written out then read back in + * to * give image 'b'. The formats may have been changed. + */ +static int +compare_two_images(Image *a, Image *b, int via_linear, + png_const_colorp background) +{ + ptrdiff_t stridea = a->stride; + ptrdiff_t strideb = b->stride; + png_const_bytep rowa = a->buffer+16; + png_const_bytep rowb = b->buffer+16; + png_uint_32 width = a->image.width; + png_uint_32 height = a->image.height; + png_uint_32 formata = a->image.format; + png_uint_32 formatb = b->image.format; + unsigned int a_sample = PNG_IMAGE_SAMPLE_SIZE(formata); + unsigned int b_sample = PNG_IMAGE_SAMPLE_SIZE(formatb); + int alpha_added, alpha_removed; + int bchannels; + png_uint_32 y; + Transform tr; + int btoa[4]={0,0,0,0}; + + /* This should never happen: */ + if (width != b->image.width || height != b->image.height) + return logerror(a, a->file_name, ": width x height changed: ", + b->file_name); + + /* Set up the background and the transform */ + transform_from_formats(&tr, a, b, background, via_linear); + + /* Find the first row and inter-row space. */ + if (!(formata & PNG_FORMAT_FLAG_COLORMAP) && + (formata & PNG_FORMAT_FLAG_LINEAR)) + stridea *= 2; + + if (!(formatb & PNG_FORMAT_FLAG_COLORMAP) && + (formatb & PNG_FORMAT_FLAG_LINEAR)) + strideb *= 2; + + if (stridea < 0) rowa += (height-1) * (-stridea); + if (strideb < 0) rowb += (height-1) * (-strideb); + + /* First shortcut the two colormap case by comparing the image data; if it + * matches then we expect the colormaps to match, although this is not + * absolutely necessary for an image match. If the colormaps fail to match + * then there is a problem in libpng. + */ + if (formata & formatb & PNG_FORMAT_FLAG_COLORMAP) + { + /* Only check colormap entries that actually exist; */ + png_const_bytep ppa, ppb; + int match; + png_byte in_use[256], amax = 0, bmax = 0; + + memset(in_use, 0, sizeof in_use); + + ppa = rowa; + ppb = rowb; + + /* Do this the slow way to accumulate the 'in_use' flags, don't break out + * of the loop until the end; this validates the color-mapped data to + * ensure all pixels are valid color-map indexes. + */ + for (y=0, match=1; y bmax) + bmax = bval; + + if (bval != aval) + match = 0; + + in_use[aval] = 1; + if (aval > amax) + amax = aval; + } + } + + /* If the buffers match then the colormaps must too. */ + if (match) + { + /* Do the color-maps match, entry by entry? Only check the 'in_use' + * entries. An error here should be logged as a color-map error. + */ + png_const_bytep a_cmap = (png_const_bytep)a->colormap; + png_const_bytep b_cmap = (png_const_bytep)b->colormap; + int result = 1; /* match by default */ + + /* This is used in logpixel to get the error message correct. */ + tr.is_palette = 1; + + for (y=0; y<256; ++y, a_cmap += a_sample, b_cmap += b_sample) + if (in_use[y]) + { + /* The colormap entries should be valid, but because libpng doesn't + * do any checking at present the original image may contain invalid + * pixel values. These cause an error here (at present) unless + * accumulating errors in which case the program just ignores them. + */ + if (y >= a->image.colormap_entries) + { + if ((a->opts & ACCUMULATE) == 0) + { + char pindex[9]; + sprintf(pindex, "%lu[%lu]", (unsigned long)y, + (unsigned long)a->image.colormap_entries); + logerror(a, a->file_name, ": bad pixel index: ", pindex); + } + result = 0; + } + + else if (y >= b->image.colormap_entries) + { + if ((b->opts & ACCUMULATE) == 0) + { + char pindex[9]; + sprintf(pindex, "%lu[%lu]", (unsigned long)y, + (unsigned long)b->image.colormap_entries); + logerror(b, b->file_name, ": bad pixel index: ", pindex); + } + result = 0; + } + + /* All the mismatches are logged here; there can only be 256! */ + else if (!cmppixel(&tr, a_cmap, b_cmap, 0, y)) + result = 0; + } + + /* If requested, copy the error values back from the Transform. */ + if (a->opts & ACCUMULATE) + { + tr.error_ptr[0] = tr.error[0]; + tr.error_ptr[1] = tr.error[1]; + tr.error_ptr[2] = tr.error[2]; + tr.error_ptr[3] = tr.error[3]; + result = 1; /* force a continue */ + } + + return result; + } + + /* else the image buffers don't match pixel-wise so compare sample values + * instead, but first validate that the pixel indexes are in range (but + * only if not accumulating, when the error is ignored.) + */ + else if ((a->opts & ACCUMULATE) == 0) + { +# ifdef __GNUC__ +# define BYTE_CHARS 20 /* 2^32: GCC sprintf warning */ +# else +# define BYTE_CHARS 3 /* 2^8: real maximum value */ +# endif + /* Check the original image first, + * TODO: deal with input images with bad pixel values? + */ + if (amax >= a->image.colormap_entries) + { + char pindex[3+2*BYTE_CHARS]; + sprintf(pindex, "%d[%u]", amax, + (png_byte)/*SAFE*/a->image.colormap_entries); + return logerror(a, a->file_name, ": bad pixel index: ", pindex); + } + + else if (bmax >= b->image.colormap_entries) + { + char pindex[3+2*BYTE_CHARS]; + sprintf(pindex, "%d[%u]", bmax, + (png_byte)/*SAFE*/b->image.colormap_entries); + return logerror(b, b->file_name, ": bad pixel index: ", pindex); + } + } + } + + /* We can directly compare pixel values without the need to use the read + * or transform support (i.e. a memory compare) if: + * + * 1) The bit depth has not changed. + * 2) RGB to grayscale has not been done (the reverse is ok; we just compare + * the three RGB values to the original grayscale.) + * 3) An alpha channel has not been removed from an 8-bit format, or the + * 8-bit alpha value of the pixel was 255 (opaque). + * + * If an alpha channel has been *added* then it must have the relevant opaque + * value (255 or 65535). + * + * The fist two the tests (in the order given above) (using the boolean + * equivalence !a && !b == !(a || b)) + */ + if (!(((formata ^ formatb) & PNG_FORMAT_FLAG_LINEAR) | + (formata & (formatb ^ PNG_FORMAT_FLAG_COLOR) & PNG_FORMAT_FLAG_COLOR))) + { + /* Was an alpha channel changed? */ + png_uint_32 alpha_changed = (formata ^ formatb) & PNG_FORMAT_FLAG_ALPHA; + + /* Was an alpha channel removed? (The third test.) If so the direct + * comparison is only possible if the input alpha is opaque. + */ + alpha_removed = (formata & alpha_changed) != 0; + + /* Was an alpha channel added? */ + alpha_added = (formatb & alpha_changed) != 0; + + /* The channels may have been moved between input and output, this finds + * out how, recording the result in the btoa array, which says where in + * 'a' to find each channel of 'b'. If alpha was added then btoa[alpha] + * ends up as 4 (and is not used.) + */ + { + int i; + png_byte aloc[4]; + png_byte bloc[4]; + + /* The following are used only if the formats match, except that + * 'bchannels' is a flag for matching formats. btoa[x] says, for each + * channel in b, where to find the corresponding value in a, for the + * bchannels. achannels may be different for a gray to rgb transform + * (a will be 1 or 2, b will be 3 or 4 channels.) + */ + (void)component_loc(aloc, formata); + bchannels = component_loc(bloc, formatb); + + /* Hence the btoa array. */ + for (i=0; i<4; ++i) if (bloc[i] < 4) + btoa[bloc[i]] = aloc[i]; /* may be '4' for alpha */ + + if (alpha_added) + alpha_added = bloc[0]; /* location of alpha channel in image b */ + + else + alpha_added = 4; /* Won't match an image b channel */ + + if (alpha_removed) + alpha_removed = aloc[0]; /* location of alpha channel in image a */ + + else + alpha_removed = 4; + } + } + + else + { + /* Direct compare is not possible, cancel out all the corresponding local + * variables. + */ + bchannels = 0; + alpha_removed = alpha_added = 4; + btoa[3] = btoa[2] = btoa[1] = btoa[0] = 4; /* 4 == not present */ + } + + for (y=0; ycolormap + a_sample * *ppa++; + else + psa = ppa, ppa += a_sample; + + if (formatb & PNG_FORMAT_FLAG_COLORMAP) + psb = (png_const_bytep)b->colormap + b_sample * *ppb++; + else + psb = ppb, ppb += b_sample; + + /* Do the fast test if possible. */ + if (bchannels) + { + /* Check each 'b' channel against either the corresponding 'a' + * channel or the opaque alpha value, as appropriate. If + * alpha_removed value is set (not 4) then also do this only if the + * 'a' alpha channel (alpha_removed) is opaque; only relevant for + * the 8-bit case. + */ + if (formatb & PNG_FORMAT_FLAG_LINEAR) /* 16-bit checks */ + { + png_const_uint_16p pua = aligncastconst(png_const_uint_16p, psa); + png_const_uint_16p pub = aligncastconst(png_const_uint_16p, psb); + + switch (bchannels) + { + case 4: + if (pua[btoa[3]] != pub[3]) break; + /* FALLTHROUGH */ + case 3: + if (pua[btoa[2]] != pub[2]) break; + /* FALLTHROUGH */ + case 2: + if (pua[btoa[1]] != pub[1]) break; + /* FALLTHROUGH */ + case 1: + if (pua[btoa[0]] != pub[0]) break; + if (alpha_added != 4 && pub[alpha_added] != 65535) break; + continue; /* x loop */ + default: + break; /* impossible */ + } + } + + else if (alpha_removed == 4 || psa[alpha_removed] == 255) + { + switch (bchannels) + { + case 4: + if (psa[btoa[3]] != psb[3]) break; + /* FALLTHROUGH */ + case 3: + if (psa[btoa[2]] != psb[2]) break; + /* FALLTHROUGH */ + case 2: + if (psa[btoa[1]] != psb[1]) break; + /* FALLTHROUGH */ + case 1: + if (psa[btoa[0]] != psb[0]) break; + if (alpha_added != 4 && psb[alpha_added] != 255) break; + continue; /* x loop */ + default: + break; /* impossible */ + } + } + } + + /* If we get to here the fast match failed; do the slow match for this + * pixel. + */ + if (!cmppixel(&tr, psa, psb, x, y) && (a->opts & KEEP_GOING) == 0) + return 0; /* error case */ + } + } + + /* If requested, copy the error values back from the Transform. */ + if (a->opts & ACCUMULATE) + { + tr.error_ptr[0] = tr.error[0]; + tr.error_ptr[1] = tr.error[1]; + tr.error_ptr[2] = tr.error[2]; + tr.error_ptr[3] = tr.error[3]; + } + + return 1; +} + +/* Read the file; how the read gets done depends on which of input_file and + * input_memory have been set. + */ +static int +read_file(Image *image, png_uint_32 format, png_const_colorp background) +{ + memset(&image->image, 0, sizeof image->image); + image->image.version = PNG_IMAGE_VERSION; + + if (image->input_memory != NULL) + { + if (!png_image_begin_read_from_memory(&image->image, image->input_memory, + image->input_memory_size)) + return logerror(image, "memory init: ", image->file_name, ""); + } + +# ifdef PNG_STDIO_SUPPORTED + else if (image->input_file != NULL) + { + if (!png_image_begin_read_from_stdio(&image->image, image->input_file)) + return logerror(image, "stdio init: ", image->file_name, ""); + } + + else + { + if (!png_image_begin_read_from_file(&image->image, image->file_name)) + return logerror(image, "file init: ", image->file_name, ""); + } +# else + else + { + return logerror(image, "unsupported file/stdio init: ", + image->file_name, ""); + } +# endif + + /* This must be set after the begin_read call: */ + if (image->opts & sRGB_16BIT) + image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB; + + /* Have an initialized image with all the data we need plus, maybe, an + * allocated file (myfile) or buffer (mybuffer) that need to be freed. + */ + { + int result; + png_uint_32 image_format; + + /* Print both original and output formats. */ + image_format = image->image.format; + + if (image->opts & VERBOSE) + { + printf("%s %lu x %lu %s -> %s", image->file_name, + (unsigned long)image->image.width, + (unsigned long)image->image.height, + format_names[image_format & FORMAT_MASK], + (format & FORMAT_NO_CHANGE) != 0 || image->image.format == format + ? "no change" : format_names[format & FORMAT_MASK]); + + if (background != NULL) + printf(" background(%d,%d,%d)\n", background->red, + background->green, background->blue); + else + printf("\n"); + + fflush(stdout); + } + + /* 'NO_CHANGE' combined with the color-map flag forces the base format + * flags to be set on read to ensure that the original representation is + * not lost in the pass through a colormap format. + */ + if ((format & FORMAT_NO_CHANGE) != 0) + { + if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0 && + (image_format & PNG_FORMAT_FLAG_COLORMAP) != 0) + format = (image_format & ~BASE_FORMATS) | (format & BASE_FORMATS); + + else + format = image_format; + } + + image->image.format = format; + + image->stride = PNG_IMAGE_ROW_STRIDE(image->image) + image->stride_extra; + allocbuffer(image); + + result = png_image_finish_read(&image->image, background, + image->buffer+16, (png_int_32)image->stride, image->colormap); + + checkbuffer(image, image->file_name); + + if (result) + return checkopaque(image); + + else + return logerror(image, image->file_name, ": image read failed", ""); + } +} + +/* Reads from a filename, which must be in image->file_name, but uses + * image->opts to choose the method. The file is always read in its native + * format (the one the simplified API suggests). + */ +static int +read_one_file(Image *image) +{ + if (!(image->opts & USE_FILE) || (image->opts & USE_STDIO)) + { + /* memory or stdio. */ + FILE *f = fopen(image->file_name, "rb"); + + if (f != NULL) + { + if (image->opts & USE_FILE) + image->input_file = f; + + else /* memory */ + { + if (fseek(f, 0, SEEK_END) == 0) + { + long int cb = ftell(f); + + if (cb > 0) + { +#ifndef __COVERITY__ + if ((unsigned long int)cb <= (size_t)~(size_t)0) +#endif + { + png_bytep b = voidcast(png_bytep, malloc((size_t)cb)); + + if (b != NULL) + { + rewind(f); + + if (fread(b, (size_t)cb, 1, f) == 1) + { + fclose(f); + image->input_memory_size = cb; + image->input_memory = b; + } + + else + { + free(b); + return logclose(image, f, image->file_name, + ": read failed: "); + } + } + + else + return logclose(image, f, image->file_name, + ": out of memory: "); + } + + else + return logclose(image, f, image->file_name, + ": file too big for this architecture: "); + /* cb is the length of the file as a (long) and + * this is greater than the maximum amount of + * memory that can be requested from malloc. + */ + } + + else if (cb == 0) + return logclose(image, f, image->file_name, + ": zero length: "); + + else + return logclose(image, f, image->file_name, + ": tell failed: "); + } + + else + return logclose(image, f, image->file_name, ": seek failed: "); + } + } + + else + return logerror(image, image->file_name, ": open failed: ", + strerror(errno)); + } + + return read_file(image, FORMAT_NO_CHANGE, NULL); +} + +#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED +static int +write_one_file(Image *output, Image *image, int convert_to_8bit) +{ + if (image->opts & FAST_WRITE) + image->image.flags |= PNG_IMAGE_FLAG_FAST; + + if (image->opts & USE_STDIO) + { +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED +#ifndef __COVERITY__ + FILE *f = tmpfile(); +#else + /* Experimental. Coverity says tmpfile() is insecure because it + * generates predictable names. + * + * It is possible to satisfy Coverity by using mkstemp(); however, + * any platform supporting mkstemp() undoubtedly has a secure tmpfile() + * implementation as well, and doesn't need the fix. Note that + * the fix won't work on platforms that don't support mkstemp(). + * + * https://www.securecoding.cert.org/confluence/display/c/ + * FIO21-C.+Do+not+create+temporary+files+in+shared+directories + * says that most historic implementations of tmpfile() provide + * only a limited number of possible temporary file names + * (usually 26) before file names are recycled. That article also + * provides a secure solution that unfortunately depends upon mkstemp(). + */ + char tmpfile[] = "pngstest-XXXXXX"; + int filedes; + FILE *f; + umask(0177); + filedes = mkstemp(tmpfile); + if (filedes < 0) + f = NULL; + else + { + f = fdopen(filedes,"w+"); + /* Hide the filename immediately and ensure that the file does + * not exist after the program ends + */ + (void) unlink(tmpfile); + } +#endif + + if (f != NULL) + { + if (png_image_write_to_stdio(&image->image, f, convert_to_8bit, + image->buffer+16, (png_int_32)image->stride, image->colormap)) + { + if (fflush(f) == 0) + { + rewind(f); + initimage(output, image->opts, "tmpfile", image->stride_extra); + output->input_file = f; + if (!checkopaque(image)) + return 0; + } + + else + return logclose(image, f, "tmpfile", ": flush: "); + } + + else + { + fclose(f); + return logerror(image, "tmpfile", ": write failed", ""); + } + } + + else + return logerror(image, "tmpfile", ": open: ", strerror(errno)); +#else /* SIMPLIFIED_WRITE_STDIO */ + return logerror(image, "tmpfile", ": open: unsupported", ""); +#endif /* SIMPLIFIED_WRITE_STDIO */ + } + + else if (image->opts & USE_FILE) + { +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED + static int counter = 0; + char name[32]; + + sprintf(name, "%s%d.png", tmpf, ++counter); + + if (png_image_write_to_file(&image->image, name, convert_to_8bit, + image->buffer+16, (png_int_32)image->stride, image->colormap)) + { + initimage(output, image->opts, output->tmpfile_name, + image->stride_extra); + /* Afterwards, or freeimage will delete it! */ + strcpy(output->tmpfile_name, name); + + if (!checkopaque(image)) + return 0; + } + + else + return logerror(image, name, ": write failed", ""); +#else /* SIMPLIFIED_WRITE_STDIO */ + return logerror(image, "stdio", ": open: unsupported", ""); +#endif /* SIMPLIFIED_WRITE_STDIO */ + } + + else /* use memory */ + { + png_alloc_size_t size; + + if (png_image_write_get_memory_size(image->image, size, convert_to_8bit, + image->buffer+16, (png_int_32)image->stride, image->colormap)) + { + /* This is non-fatal but ignoring it was causing serious problems in + * the macro to be ignored: + */ + if (size > PNG_IMAGE_PNG_SIZE_MAX(image->image)) + return logerror(image, "memory", ": PNG_IMAGE_SIZE_MAX wrong", ""); + + initimage(output, image->opts, "memory", image->stride_extra); + output->input_memory = malloc(size); + + if (output->input_memory != NULL) + { + output->input_memory_size = size; + + if (png_image_write_to_memory(&image->image, output->input_memory, + &output->input_memory_size, convert_to_8bit, image->buffer+16, + (png_int_32)image->stride, image->colormap)) + { + /* This is also non-fatal but it safes safer to error out anyway: + */ + if (size != output->input_memory_size) + return logerror(image, "memory", ": memory size wrong", ""); + } + + else + return logerror(image, "memory", ": write failed", ""); + } + + else + return logerror(image, "memory", ": out of memory", ""); + } + + else + return logerror(image, "memory", ": get size:", ""); + } + + /* 'output' has an initialized temporary image, read this back in and compare + * this against the original: there should be no change since the original + * format was written unmodified unless 'convert_to_8bit' was specified. + * However, if the original image was color-mapped, a simple read will zap + * the linear, color and maybe alpha flags, this will cause spurious failures + * under some circumstances. + */ + if (read_file(output, image->image.format | FORMAT_NO_CHANGE, NULL)) + { + png_uint_32 original_format = image->image.format; + + if (convert_to_8bit) + original_format &= ~PNG_FORMAT_FLAG_LINEAR; + + if ((output->image.format & BASE_FORMATS) != + (original_format & BASE_FORMATS)) + return logerror(image, image->file_name, ": format changed on read: ", + output->file_name); + + return compare_two_images(image, output, 0/*via linear*/, NULL); + } + + else + return logerror(output, output->tmpfile_name, + ": read of new file failed", ""); +} +#endif + +static int +testimage(Image *image, png_uint_32 opts, format_list *pf) +{ + int result; + Image copy; + + /* Copy the original data, stealing it from 'image' */ + checkopaque(image); + copy = *image; + + copy.opts = opts; + copy.buffer = NULL; + copy.bufsize = 0; + copy.allocsize = 0; + + image->input_file = NULL; + image->input_memory = NULL; + image->input_memory_size = 0; + image->tmpfile_name[0] = 0; + + { + png_uint_32 counter; + Image output; + + newimage(&output); + + result = 1; + + /* Use the low bit of 'counter' to indicate whether or not to do alpha + * removal with a background color or by composting onto the image; this + * step gets skipped if it isn't relevant + */ + for (counter=0; counter<2*FORMAT_COUNT; ++counter) + if (format_isset(pf, counter >> 1)) + { + png_uint_32 format = counter >> 1; + + png_color background_color; + png_colorp background = NULL; + + /* If there is a format change that removes the alpha channel then + * the background is relevant. If the output is 8-bit color-mapped + * then a background color *must* be provided, otherwise there are + * two tests to do - one with a color, the other with NULL. The + * NULL test happens second. + */ + if ((counter & 1) == 0) + { + if ((format & PNG_FORMAT_FLAG_ALPHA) == 0 && + (image->image.format & PNG_FORMAT_FLAG_ALPHA) != 0) + { + /* Alpha/transparency will be removed, the background is + * relevant: make it a color the first time + */ + random_color(&background_color); + background = &background_color; + + /* BUT if the output is to a color-mapped 8-bit format then + * the background must always be a color, so increment 'counter' + * to skip the NULL test. + */ + if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0 && + (format & PNG_FORMAT_FLAG_LINEAR) == 0) + ++counter; + } + + /* Otherwise an alpha channel is not being eliminated, just leave + * background NULL and skip the (counter & 1) NULL test. + */ + else + ++counter; + } + /* else just use NULL for background */ + + resetimage(©); + copy.opts = opts; /* in case read_file needs to change it */ + + result = read_file(©, format, background); + if (!result) + break; + + /* Make sure the file just read matches the original file. */ + result = compare_two_images(image, ©, 0/*via linear*/, background); + if (!result) + break; + +# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED + /* Write the *copy* just made to a new file to make sure the write + * side works ok. Check the conversion to sRGB if the copy is + * linear. + */ + output.opts = opts; + result = write_one_file(&output, ©, 0/*convert to 8bit*/); + if (!result) + break; + + /* Validate against the original too; the background is needed here + * as well so that compare_two_images knows what color was used. + */ + result = compare_two_images(image, &output, 0, background); + if (!result) + break; + + if ((format & PNG_FORMAT_FLAG_LINEAR) != 0 && + (format & PNG_FORMAT_FLAG_COLORMAP) == 0) + { + /* 'output' is linear, convert to the corresponding sRGB format. + */ + output.opts = opts; + result = write_one_file(&output, ©, 1/*convert to 8bit*/); + if (!result) + break; + + /* This may involve a conversion via linear; in the ideal world + * this would round-trip correctly, but libpng 1.5.7 is not the + * ideal world so allow a drift (error_via_linear). + * + * 'image' has an alpha channel but 'output' does not then there + * will a strip-alpha-channel operation (because 'output' is + * linear), handle this by composing on black when doing the + * comparison. + */ + result = compare_two_images(image, &output, 1/*via_linear*/, + background); + if (!result) + break; + } +# endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */ + } + + freeimage(&output); + } + + freeimage(©); + + return result; +} + +static int +test_one_file(const char *file_name, format_list *formats, png_uint_32 opts, + int stride_extra, int log_pass) +{ + int result; + Image image; + + if (!(opts & NO_RESEED)) + reseed(); /* ensure that the random numbers don't depend on file order */ + newimage(&image); + initimage(&image, opts, file_name, stride_extra); + result = read_one_file(&image); + if (result) + result = testimage(&image, opts, formats); + freeimage(&image); + + /* Ensure that stderr is flushed into any log file */ + fflush(stderr); + + if (log_pass) + { + if (result) + printf("PASS:"); + + else + printf("FAIL:"); + +# ifndef PNG_SIMPLIFIED_WRITE_SUPPORTED + printf(" (no write)"); +# endif + + print_opts(opts); + printf(" %s\n", file_name); + /* stdout may not be line-buffered if it is piped to a file, so: */ + fflush(stdout); + } + + else if (!result) + exit(1); + + return result; +} + +int +main(int argc, char **argv) +{ + png_uint_32 opts = FAST_WRITE | STRICT; + format_list formats; + const char *touch = NULL; + int log_pass = 0; + int redundant = 0; + int stride_extra = 0; + int retval = 0; + int c; + +#if PNG_LIBPNG_VER >= 10700 + /* This error should not exist in 1.7 or later: */ + opts |= GBG_ERROR; +#endif + + init_sRGB_to_d(); +#if 0 + init_error_via_linear(); +#endif + format_init(&formats); + reseed(); /* initialize random number seeds */ + + for (c=1; c= sizeof tmpf) + { + fflush(stdout); + fprintf(stderr, "%s: %s is too long for a temp file prefix\n", + argv[0], argv[c]); + exit(99); + } + + /* Safe: checked above */ + strncpy(tmpf, argv[c], sizeof (tmpf)-1); + } + + else + { + fflush(stdout); + fprintf(stderr, "%s: %s requires a temporary file prefix\n", + argv[0], arg); + exit(99); + } + } + else if (strcmp(arg, "--touch") == 0) + { + if (c+1 < argc) + touch = argv[++c]; + + else + { + fflush(stdout); + fprintf(stderr, "%s: %s requires a file name argument\n", + argv[0], arg); + exit(99); + } + } + else if (arg[0] == '+') + { + png_uint_32 format = formatof(arg+1); + + if (format > FORMAT_COUNT) + exit(99); + + format_set(&formats, format); + } + else if (arg[0] == '-' && arg[1] != 0 && (arg[1] != '0' || arg[2] != 0)) + { + fflush(stdout); + fprintf(stderr, "%s: unknown option: %s\n", argv[0], arg); + exit(99); + } + else + { + if (format_is_initial(&formats)) + format_default(&formats, redundant); + + if (arg[0] == '-') + { + int term = (arg[1] == '0' ? 0 : '\n'); + unsigned int ich = 0; + + /* Loop reading files, use a static buffer to simplify this and just + * stop if the name gets to long. + */ + static char buffer[4096]; + + do + { + int ch = getchar(); + + /* Don't allow '\0' in file names, and terminate with '\n' or, + * for -0, just '\0' (use -print0 to find to make this work!) + */ + if (ch == EOF || ch == term || ch == 0) + { + buffer[ich] = 0; + + if (ich > 0 && !test_one_file(buffer, &formats, opts, + stride_extra, log_pass)) + retval = 1; + + if (ch == EOF) + break; + + ich = 0; + --ich; /* so that the increment below sets it to 0 again */ + } + + else + buffer[ich] = (char)ch; + } while (++ich < sizeof buffer); + + if (ich) + { + buffer[32] = 0; + buffer[4095] = 0; + fprintf(stderr, "%s...%s: file name too long\n", buffer, + buffer+(4096-32)); + exit(99); + } + } + + else if (!test_one_file(arg, &formats, opts, stride_extra, log_pass)) + retval = 1; + } + } + + if (opts & ACCUMULATE) + { + unsigned int in; + + printf("/* contrib/libtests/pngstest-errors.h\n"); + printf(" *\n"); + printf(" * BUILT USING:" PNG_HEADER_VERSION_STRING); + printf(" *\n"); + printf(" * This code is released under the libpng license.\n"); + printf(" * For conditions of distribution and use, see the disclaimer\n"); + printf(" * and license in png.h\n"); + printf(" *\n"); + printf(" * THIS IS A MACHINE GENERATED FILE: do not edit it directly!\n"); + printf(" * Instead run:\n"); + printf(" *\n"); + printf(" * pngstest --accumulate\n"); + printf(" *\n"); + printf(" * on as many PNG files as possible; at least PNGSuite and\n"); + printf(" * contrib/libtests/testpngs.\n"); + printf(" */\n"); + + printf("static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =\n"); + printf("{\n"); + for (in=0; in<16; ++in) + { + unsigned int out; + printf(" { /* input: %s */\n ", format_names[in]); + for (out=0; out<16; ++out) + { + unsigned int alpha; + printf(" {"); + for (alpha=0; alpha<4; ++alpha) + { + printf(" %d", gpc_error[in][out][alpha]); + if (alpha < 3) putchar(','); + } + printf(" }"); + if (out < 15) + { + putchar(','); + if (out % 4 == 3) printf("\n "); + } + } + printf("\n }"); + + if (in < 15) + putchar(','); + else + putchar('\n'); + } + printf("};\n"); + + printf("static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =\n"); + printf("{\n"); + for (in=0; in<16; ++in) + { + unsigned int out; + printf(" { /* input: %s */\n ", format_names[in]); + for (out=0; out<4; ++out) + { + unsigned int alpha; + printf(" {"); + for (alpha=0; alpha<4; ++alpha) + { + printf(" %d", gpc_error_via_linear[in][out][alpha]); + if (alpha < 3) putchar(','); + } + printf(" }"); + if (out < 3) + putchar(','); + } + printf("\n }"); + + if (in < 15) + putchar(','); + else + putchar('\n'); + } + printf("};\n"); + + printf("static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =\n"); + printf("{\n"); + for (in=0; in<8; ++in) + { + unsigned int out; + printf(" { /* input: %s */\n ", format_names[in]); + for (out=0; out<8; ++out) + { + unsigned int alpha; + printf(" {"); + for (alpha=0; alpha<4; ++alpha) + { + printf(" %d", gpc_error_to_colormap[in][out][alpha]); + if (alpha < 3) putchar(','); + } + printf(" }"); + if (out < 7) + { + putchar(','); + if (out % 4 == 3) printf("\n "); + } + } + printf("\n }"); + + if (in < 7) + putchar(','); + else + putchar('\n'); + } + printf("};\n"); + printf("/* END MACHINE GENERATED */\n"); + } + + if (retval == 0 && touch != NULL) + { + FILE *fsuccess = fopen(touch, "wt"); + + if (fsuccess != NULL) + { + int error = 0; + fprintf(fsuccess, "PNG simple API tests succeeded\n"); + fflush(fsuccess); + error = ferror(fsuccess); + + if (fclose(fsuccess) || error) + { + fflush(stdout); + fprintf(stderr, "%s: write failed\n", touch); + exit(99); + } + } + + else + { + fflush(stdout); + fprintf(stderr, "%s: open failed\n", touch); + exit(99); + } + } + + return retval; +} + +#else /* !PNG_SIMPLIFIED_READ_SUPPORTED */ +int main(void) +{ + fprintf(stderr, "pngstest: no read support in libpng, test skipped\n"); + /* So the test is skipped: */ + return SKIP; +} +#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */ diff --git a/libs/libpng-src/contrib/libtests/pngunknown.c b/libs/libpng-src/contrib/libtests/pngunknown.c new file mode 100644 index 000000000..05bdd833d --- /dev/null +++ b/libs/libpng-src/contrib/libtests/pngunknown.c @@ -0,0 +1,1294 @@ + +/* pngunknown.c - test the read side unknown chunk handling + * + * Last changed in libpng 1.6.32 [August 24, 2017] + * Copyright (c) 2015,2017 Glenn Randers-Pehrson + * Written by John Cunningham Bowler + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * NOTES: + * This is a C program that is intended to be linked against libpng. It + * allows the libpng unknown handling code to be tested by interpreting + * arguments to save or discard combinations of chunks. The program is + * currently just a minimal validation for the built-in libpng facilities. + */ + +#include +#include +#include +#include + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + + +/* Since this program tests the ability to change the unknown chunk handling + * these must be defined: + */ +#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\ + defined(PNG_STDIO_SUPPORTED) &&\ + defined(PNG_READ_SUPPORTED) + +/* One of these must be defined to allow us to find out what happened. It is + * still useful to set unknown chunk handling without either of these in order + * to cause *known* chunks to be discarded. This can be a significant + * efficiency gain, but it can't really be tested here. + */ +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) ||\ + defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + +#if PNG_LIBPNG_VER < 10500 +/* This deliberately lacks the const. */ +typedef png_byte *png_const_bytep; + +/* This is copied from 1.5.1 png.h: */ +#define PNG_INTERLACE_ADAM7_PASSES 7 +#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7) +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) +#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \ + (((yIn)<>(((7-(off))-(pass))<<2)) & 0xFU) | \ + ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U)) +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) + +/* These are needed too for the default build: */ +#define PNG_WRITE_16BIT_SUPPORTED +#define PNG_READ_16BIT_SUPPORTED + +/* This comes from pnglibconf.h after 1.5: */ +#define PNG_FP_1 100000 +#define PNG_GAMMA_THRESHOLD_FIXED\ + ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1)) +#endif + +#if PNG_LIBPNG_VER < 10600 + /* 1.6.0 constifies many APIs. The following exists to allow pngvalid to be + * compiled against earlier versions. + */ +# define png_const_structp png_structp +#endif + +#if PNG_LIBPNG_VER < 10700 + /* Copied from libpng 1.7.0 png.h */ +#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2)) + +#define PNG_U16(b1, b2) ((png_uint_16)PNG_u2(b1, b2)) +#define PNG_U32(b1, b2, b3, b4)\ + (((png_uint_32)PNG_u2(b1, b2) << 16) + PNG_u2(b3, b4)) + +/* Constants for known chunk types. + */ +#define png_IDAT PNG_U32( 73, 68, 65, 84) +#define png_IEND PNG_U32( 73, 69, 78, 68) +#define png_IHDR PNG_U32( 73, 72, 68, 82) +#define png_PLTE PNG_U32( 80, 76, 84, 69) +#define png_bKGD PNG_U32( 98, 75, 71, 68) +#define png_cHRM PNG_U32( 99, 72, 82, 77) +#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */ +#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */ +#define png_gAMA PNG_U32(103, 65, 77, 65) +#define png_gIFg PNG_U32(103, 73, 70, 103) +#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */ +#define png_gIFx PNG_U32(103, 73, 70, 120) +#define png_hIST PNG_U32(104, 73, 83, 84) +#define png_iCCP PNG_U32(105, 67, 67, 80) +#define png_iTXt PNG_U32(105, 84, 88, 116) +#define png_oFFs PNG_U32(111, 70, 70, 115) +#define png_pCAL PNG_U32(112, 67, 65, 76) +#define png_pHYs PNG_U32(112, 72, 89, 115) +#define png_sBIT PNG_U32(115, 66, 73, 84) +#define png_sCAL PNG_U32(115, 67, 65, 76) +#define png_sPLT PNG_U32(115, 80, 76, 84) +#define png_sRGB PNG_U32(115, 82, 71, 66) +#define png_sTER PNG_U32(115, 84, 69, 82) +#define png_tEXt PNG_U32(116, 69, 88, 116) +#define png_tIME PNG_U32(116, 73, 77, 69) +#define png_tRNS PNG_U32(116, 82, 78, 83) +#define png_zTXt PNG_U32(122, 84, 88, 116) + +/* Test on flag values as defined in the spec (section 5.4): */ +#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29)) +#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c)) +#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21)) +#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13)) +#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5)) + +#endif /* PNG_LIBPNG_VER < 10700 */ + +#ifdef __cplusplus +# define this not_the_cpp_this +# define new not_the_cpp_new +# define voidcast(type, value) static_cast(value) +#else +# define voidcast(type, value) (value) +#endif /* __cplusplus */ + +/* Unused formal parameter errors are removed using the following macro which is + * expected to have no bad effects on performance. + */ +#ifndef UNUSED +# if defined(__GNUC__) || defined(_MSC_VER) +# define UNUSED(param) (void)param; +# else +# define UNUSED(param) +# endif +#endif + +/* Types of chunks not known to libpng */ +#define png_vpAg PNG_U32(118, 112, 65, 103) + +/* Chunk information */ +#define PNG_INFO_tEXt 0x10000000U +#define PNG_INFO_iTXt 0x20000000U +#define PNG_INFO_zTXt 0x40000000U + +#define PNG_INFO_sTER 0x01000000U +#define PNG_INFO_vpAg 0x02000000U + +#define ABSENT 0 +#define START 1 +#define END 2 + +static struct +{ + char name[5]; + png_uint_32 flag; + png_uint_32 tag; + int unknown; /* Chunk not known to libpng */ + int all; /* Chunk set by the '-1' option */ + int position; /* position in pngtest.png */ + int keep; /* unknown handling setting */ +} chunk_info[] = { + /* Critical chunks */ + { "IDAT", PNG_INFO_IDAT, png_IDAT, 0, 0, START, 0 }, /* must be [0] */ + { "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 }, + + /* Non-critical chunks that libpng handles */ + /* This is a mess but it seems to be the only way to do it - there is no way + * to check for a definition outside a #if. + */ + { "bKGD", PNG_INFO_bKGD, png_bKGD, +# ifdef PNG_READ_bKGD_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "cHRM", PNG_INFO_cHRM, png_cHRM, +# ifdef PNG_READ_cHRM_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "eXIf", PNG_INFO_eXIf, png_eXIf, +# ifdef PNG_READ_eXIf_SUPPORTED + 0, +# else + 1, +# endif + 1, END, 0 }, + { "gAMA", PNG_INFO_gAMA, png_gAMA, +# ifdef PNG_READ_gAMA_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "hIST", PNG_INFO_hIST, png_hIST, +# ifdef PNG_READ_hIST_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "iCCP", PNG_INFO_iCCP, png_iCCP, +# ifdef PNG_READ_iCCP_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "iTXt", PNG_INFO_iTXt, png_iTXt, +# ifdef PNG_READ_iTXt_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "oFFs", PNG_INFO_oFFs, png_oFFs, +# ifdef PNG_READ_oFFs_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "pCAL", PNG_INFO_pCAL, png_pCAL, +# ifdef PNG_READ_pCAL_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "pHYs", PNG_INFO_pHYs, png_pHYs, +# ifdef PNG_READ_pHYs_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sBIT", PNG_INFO_sBIT, png_sBIT, +# ifdef PNG_READ_sBIT_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sCAL", PNG_INFO_sCAL, png_sCAL, +# ifdef PNG_READ_sCAL_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "sPLT", PNG_INFO_sPLT, png_sPLT, +# ifdef PNG_READ_sPLT_SUPPORTED + 0, +# else + 1, +# endif + 1, ABSENT, 0 }, + { "sRGB", PNG_INFO_sRGB, png_sRGB, +# ifdef PNG_READ_sRGB_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tEXt", PNG_INFO_tEXt, png_tEXt, +# ifdef PNG_READ_tEXt_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tIME", PNG_INFO_tIME, png_tIME, +# ifdef PNG_READ_tIME_SUPPORTED + 0, +# else + 1, +# endif + 1, START, 0 }, + { "tRNS", PNG_INFO_tRNS, png_tRNS, +# ifdef PNG_READ_tRNS_SUPPORTED + 0, +# else + 1, +# endif + 0, ABSENT, 0 }, + { "zTXt", PNG_INFO_zTXt, png_zTXt, +# ifdef PNG_READ_zTXt_SUPPORTED + 0, +# else + 1, +# endif + 1, END, 0 }, + + /* No libpng handling */ + { "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 }, + { "vpAg", PNG_INFO_vpAg, png_vpAg, 1, 0, START, 0 }, +}; + +#define NINFO ((int)((sizeof chunk_info)/(sizeof chunk_info[0]))) + +static void +clear_keep(void) +{ + int i = NINFO; + while (--i >= 0) + chunk_info[i].keep = 0; +} + +static int +find(const char *name) +{ + int i = NINFO; + while (--i >= 0) + { + if (memcmp(chunk_info[i].name, name, 4) == 0) + break; + } + + return i; +} + +static int +findb(const png_byte *name) +{ + int i = NINFO; + while (--i >= 0) + { + if (memcmp(chunk_info[i].name, name, 4) == 0) + break; + } + + return i; +} + +static int +find_by_flag(png_uint_32 flag) +{ + int i = NINFO; + + while (--i >= 0) if (chunk_info[i].flag == flag) return i; + + fprintf(stderr, "pngunknown: internal error\n"); + exit(4); +} + +static int +ancillary(const char *name) +{ + return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3])); +} + +#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED +static int +ancillaryb(const png_byte *name) +{ + return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3])); +} +#endif + +/* Type of an error_ptr */ +typedef struct +{ + jmp_buf error_return; + png_structp png_ptr; + png_infop info_ptr, end_ptr; + png_uint_32 before_IDAT; + png_uint_32 after_IDAT; + int error_count; + int warning_count; + int keep; /* the default value */ + const char *program; + const char *file; + const char *test; +} display; + +static const char init[] = "initialization"; +static const char cmd[] = "command line"; + +static void +init_display(display *d, const char *program) +{ + memset(d, 0, sizeof *d); + d->png_ptr = NULL; + d->info_ptr = d->end_ptr = NULL; + d->error_count = d->warning_count = 0; + d->program = program; + d->file = program; + d->test = init; +} + +static void +clean_display(display *d) +{ + png_destroy_read_struct(&d->png_ptr, &d->info_ptr, &d->end_ptr); + + /* This must not happen - it might cause an app crash */ + if (d->png_ptr != NULL || d->info_ptr != NULL || d->end_ptr != NULL) + { + fprintf(stderr, "%s(%s): png_destroy_read_struct error\n", d->file, + d->test); + exit(1); + } +} + +PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN) +{ + ++(d->error_count); + + if (d->png_ptr != NULL) + clean_display(d); + + /* During initialization and if this is a single command line argument set + * exit now - there is only one test, otherwise longjmp to do the next test. + */ + if (d->test == init || d->test == cmd) + exit(1); + + longjmp(d->error_return, 1); +} + +static int +display_rc(const display *d, int strict) +{ + return d->error_count + (strict ? d->warning_count : 0); +} + +/* libpng error and warning callbacks */ +PNG_FUNCTION(void, (PNGCBAPI error), (png_structp png_ptr, const char *message), + static PNG_NORETURN) +{ + display *d = (display*)png_get_error_ptr(png_ptr); + + fprintf(stderr, "%s(%s): libpng error: %s\n", d->file, d->test, message); + display_exit(d); +} + +static void PNGCBAPI +warning(png_structp png_ptr, const char *message) +{ + display *d = (display*)png_get_error_ptr(png_ptr); + + fprintf(stderr, "%s(%s): libpng warning: %s\n", d->file, d->test, message); + ++(d->warning_count); +} + +static png_uint_32 +get_valid(display *d, png_infop info_ptr) +{ + png_uint_32 flags = png_get_valid(d->png_ptr, info_ptr, (png_uint_32)~0); + + /* Map the text chunks back into the flags */ + { + png_textp text; + png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL); + + while (ntext > 0) switch (text[--ntext].compression) + { + case -1: + flags |= PNG_INFO_tEXt; + break; + case 0: + flags |= PNG_INFO_zTXt; + break; + case 1: + case 2: + flags |= PNG_INFO_iTXt; + break; + default: + fprintf(stderr, "%s(%s): unknown text compression %d\n", d->file, + d->test, text[ntext].compression); + display_exit(d); + } + } + + return flags; +} + +#ifdef PNG_READ_USER_CHUNKS_SUPPORTED +static int PNGCBAPI +read_callback(png_structp pp, png_unknown_chunkp pc) +{ + /* This function mimics the behavior of png_set_keep_unknown_chunks by + * returning '0' to keep the chunk and '1' to discard it. + */ + display *d = voidcast(display*, png_get_user_chunk_ptr(pp)); + int chunk = findb(pc->name); + int keep, discard; + + if (chunk < 0) /* not one in our list, so not a known chunk */ + keep = d->keep; + + else + { + keep = chunk_info[chunk].keep; + if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + { + /* See the comments in png.h - use the default for unknown chunks, + * do not keep known chunks. + */ + if (chunk_info[chunk].unknown) + keep = d->keep; + + else + keep = PNG_HANDLE_CHUNK_NEVER; + } + } + + switch (keep) + { + default: + fprintf(stderr, "%s(%s): %d: unrecognized chunk option\n", d->file, + d->test, chunk_info[chunk].keep); + display_exit(d); + + case PNG_HANDLE_CHUNK_AS_DEFAULT: + case PNG_HANDLE_CHUNK_NEVER: + discard = 1/*handled; discard*/; + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + case PNG_HANDLE_CHUNK_ALWAYS: + discard = 0/*not handled; keep*/; + break; + } + + /* Also store information about this chunk in the display, the relevant flag + * is set if the chunk is to be kept ('not handled'.) + */ + if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */ + { + png_uint_32 flag = chunk_info[chunk].flag; + + if (pc->location & PNG_AFTER_IDAT) + d->after_IDAT |= flag; + + else + d->before_IDAT |= flag; + } + + /* However if there is no support to store unknown chunks don't ask libpng to + * do it; there will be an png_error. + */ +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + return discard; +# else + return 1; /*handled; discard*/ +# endif +} +#endif /* READ_USER_CHUNKS_SUPPORTED */ + +#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED +static png_uint_32 +get_unknown(display *d, png_infop info_ptr, int after_IDAT) +{ + /* Create corresponding 'unknown' flags */ + png_uint_32 flags = 0; + + UNUSED(after_IDAT) + + { + png_unknown_chunkp unknown; + int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown); + + while (--num_unknown >= 0) + { + int chunk = findb(unknown[num_unknown].name); + + /* Chunks not known to pngunknown must be validated here; since they + * must also be unknown to libpng the 'display->keep' behavior should + * have been used. + */ + if (chunk < 0) switch (d->keep) + { + default: /* impossible */ + case PNG_HANDLE_CHUNK_AS_DEFAULT: + case PNG_HANDLE_CHUNK_NEVER: + fprintf(stderr, "%s(%s): %s: %s: unknown chunk saved\n", + d->file, d->test, d->keep ? "discard" : "default", + unknown[num_unknown].name); + ++(d->error_count); + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + if (!ancillaryb(unknown[num_unknown].name)) + { + fprintf(stderr, + "%s(%s): if-safe: %s: unknown critical chunk saved\n", + d->file, d->test, unknown[num_unknown].name); + ++(d->error_count); + break; + } + /* FALLTHROUGH */ /* (safe) */ + case PNG_HANDLE_CHUNK_ALWAYS: + break; + } + + else + flags |= chunk_info[chunk].flag; + } + } + + return flags; +} +#else /* SAVE_UNKNOWN_CHUNKS */ +static png_uint_32 +get_unknown(display *d, png_infop info_ptr, int after_IDAT) + /* Otherwise this will return the cached values set by any user callback */ +{ + UNUSED(info_ptr); + + if (after_IDAT) + return d->after_IDAT; + + else + return d->before_IDAT; +} + +# ifndef PNG_READ_USER_CHUNKS_SUPPORTED + /* The #defines above should mean this is never reached, it's just here as + * a check to ensure the logic is correct. + */ +# error No store support and no user chunk support, this will not work +# endif /* READ_USER_CHUNKS */ +#endif /* SAVE_UNKNOWN_CHUNKS */ + +static int +check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/, + display *d, int set_callback) +{ + int i, npasses, ipass; + png_uint_32 height; + + d->keep = PNG_HANDLE_CHUNK_AS_DEFAULT; + d->before_IDAT = 0; + d->after_IDAT = 0; + + /* Some of these errors are permanently fatal and cause an exit here, others + * are per-test and cause an error return. + */ + d->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, d, error, + warning); + if (d->png_ptr == NULL) + { + fprintf(stderr, "%s(%s): could not allocate png struct\n", d->file, + d->test); + /* Terminate here, this error is not test specific. */ + exit(1); + } + + d->info_ptr = png_create_info_struct(d->png_ptr); + d->end_ptr = png_create_info_struct(d->png_ptr); + if (d->info_ptr == NULL || d->end_ptr == NULL) + { + fprintf(stderr, "%s(%s): could not allocate png info\n", d->file, + d->test); + clean_display(d); + exit(1); + } + + png_init_io(d->png_ptr, fp); + +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + /* This is only done if requested by the caller; it interferes with the + * standard store/save mechanism. + */ + if (set_callback) + png_set_read_user_chunk_fn(d->png_ptr, d, read_callback); +# else + UNUSED(set_callback) +# endif + + /* Handle each argument in turn; multiple settings are possible for the same + * chunk and multiple calls will occur (the last one should override all + * preceding ones). + */ + for (i=0; i= 10700 &&\ + !defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + if (option < PNG_HANDLE_CHUNK_IF_SAFE) +# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */ + { + png_byte name[5]; + + memcpy(name, chunk_info[chunk].name, 5); + png_set_keep_unknown_chunks(d->png_ptr, option, name, 1); + chunk_info[chunk].keep = option; + } + continue; + } + + break; + + case 7: /* default */ + if (memcmp(argv[i], "default", 7) == 0) + { +# if PNG_LIBPNG_VER >= 10700 &&\ + !defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + if (option < PNG_HANDLE_CHUNK_IF_SAFE) +# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */ + png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0); + + d->keep = option; + continue; + } + + break; + + case 3: /* all */ + if (memcmp(argv[i], "all", 3) == 0) + { +# if PNG_LIBPNG_VER >= 10700 &&\ + !defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED) + if (option < PNG_HANDLE_CHUNK_IF_SAFE) +# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */ + png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1); + + d->keep = option; + + for (chunk = 0; chunk < NINFO; ++chunk) + if (chunk_info[chunk].all) + chunk_info[chunk].keep = option; + continue; + } + + break; + + default: /* some misplaced = */ + + break; + } + } + + fprintf(stderr, "%s(%s): %s: unrecognized chunk argument\n", d->file, + d->test, argv[i]); + display_exit(d); + } + + png_read_info(d->png_ptr, d->info_ptr); + + switch (png_get_interlace_type(d->png_ptr, d->info_ptr)) + { + case PNG_INTERLACE_NONE: + npasses = 1; + break; + + case PNG_INTERLACE_ADAM7: + npasses = PNG_INTERLACE_ADAM7_PASSES; + break; + + default: + /* Hard error because it is not test specific */ + fprintf(stderr, "%s(%s): invalid interlace type\n", d->file, d->test); + clean_display(d); + exit(1); + } + + /* Skip the image data, if IDAT is not being handled then don't do this + * because it will cause a CRC error. + */ + if (chunk_info[0/*IDAT*/].keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + { + png_start_read_image(d->png_ptr); + height = png_get_image_height(d->png_ptr, d->info_ptr); + + if (npasses > 1) + { + png_uint_32 width = png_get_image_width(d->png_ptr, d->info_ptr); + + for (ipass=0; ipass 0) + { + png_uint_32 y; + + for (y=0; ypng_ptr, NULL, NULL); + } + } + } /* interlaced */ + + else /* not interlaced */ + { + png_uint_32 y; + + for (y=0; ypng_ptr, NULL, NULL); + } + } + + png_read_end(d->png_ptr, d->end_ptr); + + flags[0] = get_valid(d, d->info_ptr); + flags[1] = get_unknown(d, d->info_ptr, 0/*before IDAT*/); + + /* Only png_read_png sets PNG_INFO_IDAT! */ + flags[chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT] |= + PNG_INFO_IDAT; + + flags[2] = get_valid(d, d->end_ptr); + flags[3] = get_unknown(d, d->end_ptr, 1/*after IDAT*/); + + clean_display(d); + + return d->keep; +} + +static void +check_error(display *d, png_uint_32 flags, const char *message) +{ + while (flags) + { + png_uint_32 flag = flags & -(png_int_32)flags; + int i = find_by_flag(flag); + + fprintf(stderr, "%s(%s): chunk %s: %s\n", d->file, d->test, + chunk_info[i].name, message); + ++(d->error_count); + + flags &= ~flag; + } +} + +static void +check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known, + png_uint_32 unknown, const char *position, int set_callback) +{ + while (chunks) + { + png_uint_32 flag = chunks & -(png_int_32)chunks; + int i = find_by_flag(flag); + int keep = chunk_info[i].keep; + const char *type; + const char *errorx = NULL; + + if (chunk_info[i].unknown) + { + if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) + { + type = "UNKNOWN (default)"; + keep = def; + } + + else + type = "UNKNOWN (specified)"; + + if (flag & known) + errorx = "chunk processed"; + + else switch (keep) + { + case PNG_HANDLE_CHUNK_AS_DEFAULT: + if (flag & unknown) + errorx = "DEFAULT: unknown chunk saved"; + break; + + case PNG_HANDLE_CHUNK_NEVER: + if (flag & unknown) + errorx = "DISCARD: unknown chunk saved"; + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + if (ancillary(chunk_info[i].name)) + { + if (!(flag & unknown)) + errorx = "IF-SAFE: unknown ancillary chunk lost"; + } + + else if (flag & unknown) + errorx = "IF-SAFE: unknown critical chunk saved"; + break; + + case PNG_HANDLE_CHUNK_ALWAYS: + if (!(flag & unknown)) + errorx = "SAVE: unknown chunk lost"; + break; + + default: + errorx = "internal error: bad keep"; + break; + } + } /* unknown chunk */ + + else /* known chunk */ + { + type = "KNOWN"; + + if (flag & known) + { + /* chunk was processed, it won't have been saved because that is + * caught below when checking for inconsistent processing. + */ + if (keep != PNG_HANDLE_CHUNK_AS_DEFAULT) + errorx = "!DEFAULT: known chunk processed"; + } + + else /* not processed */ switch (keep) + { + case PNG_HANDLE_CHUNK_AS_DEFAULT: + errorx = "DEFAULT: known chunk not processed"; + break; + + case PNG_HANDLE_CHUNK_NEVER: + if (flag & unknown) + errorx = "DISCARD: known chunk saved"; + break; + + case PNG_HANDLE_CHUNK_IF_SAFE: + if (ancillary(chunk_info[i].name)) + { + if (!(flag & unknown)) + errorx = "IF-SAFE: known ancillary chunk lost"; + } + + else if (flag & unknown) + errorx = "IF-SAFE: known critical chunk saved"; + break; + + case PNG_HANDLE_CHUNK_ALWAYS: + if (!(flag & unknown)) + errorx = "SAVE: known chunk lost"; + break; + + default: + errorx = "internal error: bad keep (2)"; + break; + } + } + + if (errorx != NULL) + { + ++(d->error_count); + fprintf(stderr, "%s(%s%s): %s %s %s: %s\n", d->file, d->test, + set_callback ? ",callback" : "", + type, chunk_info[i].name, position, errorx); + } + + chunks &= ~flag; + } +} + +static void +perform_one_test(FILE *fp, int argc, const char **argv, + png_uint_32 *default_flags, display *d, int set_callback) +{ + int def; + png_uint_32 flags[2][4]; + + rewind(fp); + clear_keep(); + memcpy(flags[0], default_flags, sizeof flags[0]); + + def = check(fp, argc, argv, flags[1], d, set_callback); + + /* If IDAT is being handled as unknown the image read is skipped and all the + * IDATs after the first end up in the end info struct, so in this case add + * IDAT to the list of unknowns. (Do this after 'check' above sets the + * chunk_info 'keep' fields.) + * + * Note that the flag setting has to be in the 'known' field to avoid + * triggering the consistency check below and the flag must only be set if + * there are multiple IDATs, so if the check above did find an unknown IDAT + * after IDAT. + */ + if (chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT && + (flags[1][3] & PNG_INFO_IDAT) != 0) + flags[0][2] |= PNG_INFO_IDAT; + + /* Chunks should either be known or unknown, never both and this should apply + * whether the chunk is before or after the IDAT (actually, the app can + * probably change this by swapping the handling after the image, but this + * test does not do that.) + */ + check_error(d, (flags[0][0]|flags[0][2]) & (flags[0][1]|flags[0][3]), + "chunk handled inconsistently in count tests"); + check_error(d, (flags[1][0]|flags[1][2]) & (flags[1][1]|flags[1][3]), + "chunk handled inconsistently in option tests"); + + /* Now find out what happened to each chunk before and after the IDAT and + * determine if the behavior was correct. First some basic sanity checks, + * any known chunk should be known in the original count, any unknown chunk + * should be either known or unknown in the original. + */ + { + png_uint_32 test; + + test = flags[1][0] & ~flags[0][0]; + check_error(d, test, "new known chunk before IDAT"); + test = flags[1][1] & ~(flags[0][0] | flags[0][1]); + check_error(d, test, "new unknown chunk before IDAT"); + test = flags[1][2] & ~flags[0][2]; + check_error(d, test, "new known chunk after IDAT"); + test = flags[1][3] & ~(flags[0][2] | flags[0][3]); + check_error(d, test, "new unknown chunk after IDAT"); + } + + /* Now each chunk in the original list should have been handled according to + * the options set for that chunk, regardless of whether libpng knows about + * it or not. + */ + check_handling(d, def, flags[0][0] | flags[0][1], flags[1][0], flags[1][1], + "before IDAT", set_callback); + check_handling(d, def, flags[0][2] | flags[0][3], flags[1][2], flags[1][3], + "after IDAT", set_callback); +} + +static void +perform_one_test_safe(FILE *fp, int argc, const char **argv, + png_uint_32 *default_flags, display *d, const char *test) +{ + if (setjmp(d->error_return) == 0) + { + d->test = test; /* allow use of d->error_return */ +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, d, 0); +# endif +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, d, 1); +# endif + d->test = init; /* prevent use of d->error_return */ + } +} + +static const char *standard_tests[] = +{ + "discard", "default=discard", 0, + "save", "default=save", 0, + "if-safe", "default=if-safe", 0, + "vpAg", "vpAg=if-safe", 0, + "sTER", "sTER=if-safe", 0, + "IDAT", "default=discard", "IDAT=save", 0, + "sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save", + "sBIT=save", "sRGB=save", "eXIf=save", 0, + 0/*end*/ +}; + +static PNG_NORETURN void +usage(const char *program, const char *reason) +{ + fprintf(stderr, "pngunknown: %s: usage:\n %s [--strict] " + "--default|{(CHNK|default|all)=(default|discard|if-safe|save)} " + "testfile.png\n", reason, program); + exit(99); +} + +int +main(int argc, const char **argv) +{ + FILE *fp; + png_uint_32 default_flags[4/*valid,unknown{before,after}*/]; + int strict = 0, default_tests = 0; + const char *count_argv = "default=save"; + const char *touch_file = NULL; + display d; + + init_display(&d, argv[0]); + + while (++argv, --argc > 0) + { + if (strcmp(*argv, "--strict") == 0) + strict = 1; + + else if (strcmp(*argv, "--default") == 0) + default_tests = 1; + + else if (strcmp(*argv, "--touch") == 0) + { + if (argc > 1) + touch_file = *++argv, --argc; + + else + usage(d.program, "--touch: missing file name"); + } + + else + break; + } + + /* A file name is required, but there should be no other arguments if + * --default was specified. + */ + if (argc <= 0) + usage(d.program, "missing test file"); + + /* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc + * optimization which causes warnings with -Wstrict-overflow! + */ + else if (default_tests) if (argc != 1) + usage(d.program, "extra arguments"); + + /* The name of the test file is the last argument; remove it. */ + d.file = argv[--argc]; + + fp = fopen(d.file, "rb"); + if (fp == NULL) + { + perror(d.file); + exit(99); + } + + /* First find all the chunks, known and unknown, in the test file, a failure + * here aborts the whole test. + * + * If 'save' is supported then the normal saving method should happen, + * otherwise if 'read' is supported then the read callback will do the + * same thing. If both are supported the 'read' callback won't be + * instantiated by default. If 'save' is *not* supported then a user + * callback is required even though we can call png_get_unknown_chunks. + */ + if (check(fp, 1, &count_argv, default_flags, &d, +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + 0 +# else + 1 +# endif + ) != PNG_HANDLE_CHUNK_ALWAYS) + { + fprintf(stderr, "%s: %s: internal error\n", d.program, d.file); + exit(99); + } + + /* Now find what the various supplied options cause to change: */ + if (!default_tests) + { + d.test = cmd; /* acts as a flag to say exit, do not longjmp */ +# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, &d, 0); +# endif +# ifdef PNG_READ_USER_CHUNKS_SUPPORTED + perform_one_test(fp, argc, argv, default_flags, &d, 1); +# endif + d.test = init; + } + + else + { + const char **test = standard_tests; + + /* Set the exit_test pointer here so we can continue after a libpng error. + * NOTE: this leaks memory because the png_struct data from the failing + * test is never freed. + */ + while (*test) + { + const char *this_test = *test++; + const char **next = test; + int count = display_rc(&d, strict), new_count; + const char *result; + int arg_count = 0; + + while (*next) ++next, ++arg_count; + + perform_one_test_safe(fp, arg_count, test, default_flags, &d, + this_test); + + new_count = display_rc(&d, strict); + + if (new_count == count) + result = "PASS"; + + else + result = "FAIL"; + + printf("%s: %s %s\n", result, d.program, this_test); + + test = next+1; + } + } + + fclose(fp); + + if (display_rc(&d, strict) == 0) + { + /* Success, touch the success file if appropriate */ + if (touch_file != NULL) + { + FILE *fsuccess = fopen(touch_file, "wt"); + + if (fsuccess != NULL) + { + int err = 0; + fprintf(fsuccess, "PNG unknown tests succeeded\n"); + fflush(fsuccess); + err = ferror(fsuccess); + + if (fclose(fsuccess) || err) + { + fprintf(stderr, "%s: write failed\n", touch_file); + exit(99); + } + } + + else + { + fprintf(stderr, "%s: open failed\n", touch_file); + exit(99); + } + } + + return 0; + } + + return 1; +} + +#else /* !(READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS) */ +int +main(void) +{ + fprintf(stderr, + " test ignored: no support to find out about unknown chunks\n"); + /* So the test is skipped: */ + return SKIP; +} +#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */ + +#else /* !(SET_UNKNOWN_CHUNKS && READ) */ +int +main(void) +{ + fprintf(stderr, + " test ignored: no support to modify unknown chunk handling\n"); + /* So the test is skipped: */ + return SKIP; +} +#endif /* SET_UNKNOWN_CHUNKS && READ*/ diff --git a/libs/libpng-src/contrib/libtests/pngvalid.c b/libs/libpng-src/contrib/libtests/pngvalid.c new file mode 100644 index 000000000..d800110c7 --- /dev/null +++ b/libs/libpng-src/contrib/libtests/pngvalid.c @@ -0,0 +1,12230 @@ + +/* pngvalid.c - validate libpng by constructing then reading png files. + * + * Last changed in libpng 1.6.31 [July 27, 2017] + * Copyright (c) 2014-2017 John Cunningham Bowler + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * + * NOTES: + * This is a C program that is intended to be linked against libpng. It + * generates bitmaps internally, stores them as PNG files (using the + * sequential write code) then reads them back (using the sequential + * read code) and validates that the result has the correct data. + * + * The program can be modified and extended to test the correctness of + * transformations performed by libpng. + */ + +#define _POSIX_SOURCE 1 +#define _ISOC99_SOURCE 1 /* For floating point */ +#define _GNU_SOURCE 1 /* For the floating point exception extension */ +#define _BSD_SOURCE 1 /* For the floating point exception extension */ + +#include +#include + +#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) +# include +#endif + +#ifdef HAVE_FEENABLEEXCEPT /* from config.h, if included */ +# include +#endif + +#ifndef FE_DIVBYZERO +# define FE_DIVBYZERO 0 +#endif +#ifndef FE_INVALID +# define FE_INVALID 0 +#endif +#ifndef FE_OVERFLOW +# define FE_OVERFLOW 0 +#endif + +/* Define the following to use this test against your installed libpng, rather + * than the one being built here: + */ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../../png.h" +#endif + +#ifdef PNG_ZLIB_HEADER +# include PNG_ZLIB_HEADER +#else +# include /* For crc32 */ +#endif + +/* 1.6.1 added support for the configure test harness, which uses 77 to indicate + * a skipped test, in earlier versions we need to succeed on a skipped test, so: + */ +#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H) +# define SKIP 77 +#else +# define SKIP 0 +#endif + +/* pngvalid requires write support and one of the fixed or floating point APIs. + */ +#if defined(PNG_WRITE_SUPPORTED) &&\ + (defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED)) + +#if PNG_LIBPNG_VER < 10500 +/* This deliberately lacks the const. */ +typedef png_byte *png_const_bytep; + +/* This is copied from 1.5.1 png.h: */ +#define PNG_INTERLACE_ADAM7_PASSES 7 +#define PNG_PASS_START_ROW(pass) (((1U&~(pass))<<(3-((pass)>>1)))&7) +#define PNG_PASS_START_COL(pass) (((1U& (pass))<<(3-(((pass)+1)>>1)))&7) +#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) +#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) +#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) +#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) +#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \ + (((yIn)<>(((7-(off))-(pass))<<2)) & 0xFU) | \ + ((0x01145AF0U>>(((7-(off))-(pass))<<2)) & 0xF0U)) +#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ + ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) +#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ + ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) + +/* These are needed too for the default build: */ +#define PNG_WRITE_16BIT_SUPPORTED +#define PNG_READ_16BIT_SUPPORTED + +/* This comes from pnglibconf.h after 1.5: */ +#define PNG_FP_1 100000 +#define PNG_GAMMA_THRESHOLD_FIXED\ + ((png_fixed_point)(PNG_GAMMA_THRESHOLD * PNG_FP_1)) +#endif + +#if PNG_LIBPNG_VER < 10600 + /* 1.6.0 constifies many APIs, the following exists to allow pngvalid to be + * compiled against earlier versions. + */ +# define png_const_structp png_structp +#endif + +#ifndef RELEASE_BUILD + /* RELEASE_BUILD is true for releases and release candidates: */ +# define RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC) +#endif +#if RELEASE_BUILD +# define debugonly(something) +#else /* !RELEASE_BUILD */ +# define debugonly(something) something +#endif /* !RELEASE_BUILD */ + +#include /* For floating point constants */ +#include /* For malloc */ +#include /* For memcpy, memset */ +#include /* For floor */ + +/* Convenience macros. */ +#define CHUNK(a,b,c,d) (((a)<<24)+((b)<<16)+((c)<<8)+(d)) +#define CHUNK_IHDR CHUNK(73,72,68,82) +#define CHUNK_PLTE CHUNK(80,76,84,69) +#define CHUNK_IDAT CHUNK(73,68,65,84) +#define CHUNK_IEND CHUNK(73,69,78,68) +#define CHUNK_cHRM CHUNK(99,72,82,77) +#define CHUNK_gAMA CHUNK(103,65,77,65) +#define CHUNK_sBIT CHUNK(115,66,73,84) +#define CHUNK_sRGB CHUNK(115,82,71,66) + +/* Unused formal parameter errors are removed using the following macro which is + * expected to have no bad effects on performance. + */ +#ifndef UNUSED +# if defined(__GNUC__) || defined(_MSC_VER) +# define UNUSED(param) (void)param; +# else +# define UNUSED(param) +# endif +#endif + +/***************************** EXCEPTION HANDLING *****************************/ +#ifdef PNG_FREESTANDING_TESTS +# include +#else +# include "../visupng/cexcept.h" +#endif + +#ifdef __cplusplus +# define this not_the_cpp_this +# define new not_the_cpp_new +# define voidcast(type, value) static_cast(value) +#else +# define voidcast(type, value) (value) +#endif /* __cplusplus */ + +struct png_store; +define_exception_type(struct png_store*); + +/* The following are macros to reduce typing everywhere where the well known + * name 'the_exception_context' must be defined. + */ +#define anon_context(ps) struct exception_context *the_exception_context = \ + &(ps)->exception_context +#define context(ps,fault) anon_context(ps); png_store *fault + +/* This macro returns the number of elements in an array as an (unsigned int), + * it is necessary to avoid the inability of certain versions of GCC to use + * the value of a compile-time constant when performing range checks. It must + * be passed an array name. + */ +#define ARRAY_SIZE(a) ((unsigned int)((sizeof (a))/(sizeof (a)[0]))) + +/* GCC BUG 66447 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66447) requires + * some broken GCC versions to be fixed up to avoid invalid whining about auto + * variables that are *not* changed within the scope of a setjmp being changed. + * + * Feel free to extend the list of broken versions. + */ +#define is_gnu(major,minor)\ + (defined __GNUC__) && __GNUC__ == (major) && __GNUC_MINOR__ == (minor) +#define is_gnu_patch(major,minor,patch)\ + is_gnu(major,minor) && __GNUC_PATCHLEVEL__ == 0 +/* For the moment just do it always; all versions of GCC seem to be broken: */ +#ifdef __GNUC__ + const void * volatile make_volatile_for_gnu; +# define gnu_volatile(x) make_volatile_for_gnu = &x; +#else /* !GNUC broken versions */ +# define gnu_volatile(x) +#endif /* !GNUC broken versions */ + +/******************************* UTILITIES ************************************/ +/* Error handling is particularly problematic in production code - error + * handlers often themselves have bugs which lead to programs that detect + * minor errors crashing. The following functions deal with one very + * common class of errors in error handlers - attempting to format error or + * warning messages into buffers that are too small. + */ +static size_t safecat(char *buffer, size_t bufsize, size_t pos, + const char *cat) +{ + while (pos < bufsize && cat != NULL && *cat != 0) + buffer[pos++] = *cat++; + + if (pos >= bufsize) + pos = bufsize-1; + + buffer[pos] = 0; + return pos; +} + +static size_t safecatn(char *buffer, size_t bufsize, size_t pos, int n) +{ + char number[64]; + sprintf(number, "%d", n); + return safecat(buffer, bufsize, pos, number); +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static size_t safecatd(char *buffer, size_t bufsize, size_t pos, double d, + int precision) +{ + char number[64]; + sprintf(number, "%.*f", precision, d); + return safecat(buffer, bufsize, pos, number); +} +#endif + +static const char invalid[] = "invalid"; +static const char sep[] = ": "; + +static const char *colour_types[8] = +{ + "grayscale", invalid, "truecolour", "indexed-colour", + "grayscale with alpha", invalid, "truecolour with alpha", invalid +}; + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Convert a double precision value to fixed point. */ +static png_fixed_point +fix(double d) +{ + d = floor(d * PNG_FP_1 + .5); + return (png_fixed_point)d; +} +#endif /* PNG_READ_SUPPORTED */ + +/* Generate random bytes. This uses a boring repeatable algorithm and it + * is implemented here so that it gives the same set of numbers on every + * architecture. It's a linear congruential generator (Knuth or Sedgewick + * "Algorithms") but it comes from the 'feedback taps' table in Horowitz and + * Hill, "The Art of Electronics" (Pseudo-Random Bit Sequences and Noise + * Generation.) + */ +static void +make_random_bytes(png_uint_32* seed, void* pv, size_t size) +{ + png_uint_32 u0 = seed[0], u1 = seed[1]; + png_bytep bytes = voidcast(png_bytep, pv); + + /* There are thirty three bits, the next bit in the sequence is bit-33 XOR + * bit-20. The top 1 bit is in u1, the bottom 32 are in u0. + */ + size_t i; + for (i=0; i> (20-8)) ^ ((u1 << 7) | (u0 >> (32-7)))) & 0xff; + u1 <<= 8; + u1 |= u0 >> 24; + u0 <<= 8; + u0 |= u; + *bytes++ = (png_byte)u; + } + + seed[0] = u0; + seed[1] = u1; +} + +static void +make_four_random_bytes(png_uint_32* seed, png_bytep bytes) +{ + make_random_bytes(seed, bytes, 4); +} + +#if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED ||\ + defined PNG_WRITE_FILTER_SUPPORTED +static void +randomize(void *pv, size_t size) +{ + static png_uint_32 random_seed[2] = {0x56789abc, 0xd}; + make_random_bytes(random_seed, pv, size); +} + +#define R8(this) randomize(&(this), sizeof (this)) + +#ifdef PNG_READ_SUPPORTED +static png_byte +random_byte(void) +{ + unsigned char b1[1]; + randomize(b1, sizeof b1); + return b1[0]; +} +#endif /* READ */ + +static png_uint_16 +random_u16(void) +{ + unsigned char b2[2]; + randomize(b2, sizeof b2); + return png_get_uint_16(b2); +} + +#if defined PNG_READ_RGB_TO_GRAY_SUPPORTED ||\ + defined PNG_READ_FILLER_SUPPORTED +static png_uint_32 +random_u32(void) +{ + unsigned char b4[4]; + randomize(b4, sizeof b4); + return png_get_uint_32(b4); +} +#endif /* READ_FILLER || READ_RGB_TO_GRAY */ + +#endif /* READ || WRITE_tRNS || WRITE_FILTER */ + +#if defined PNG_READ_TRANSFORMS_SUPPORTED ||\ + defined PNG_WRITE_FILTER_SUPPORTED +static unsigned int +random_mod(unsigned int max) +{ + return random_u16() % max; /* 0 .. max-1 */ +} +#endif /* READ_TRANSFORMS || WRITE_FILTER */ + +#if (defined PNG_READ_RGB_TO_GRAY_SUPPORTED) ||\ + (defined PNG_READ_FILLER_SUPPORTED) +static int +random_choice(void) +{ + return random_byte() & 1; +} +#endif /* READ_RGB_TO_GRAY || READ_FILLER */ + +/* A numeric ID based on PNG file characteristics. The 'do_interlace' field + * simply records whether pngvalid did the interlace itself or whether it + * was done by libpng. Width and height must be less than 256. 'palette' is an + * index of the palette to use for formats with a palette otherwise a boolean + * indicating if a tRNS chunk was generated. + */ +#define FILEID(col, depth, palette, interlace, width, height, do_interlace) \ + ((png_uint_32)((col) + ((depth)<<3) + ((palette)<<8) + ((interlace)<<13) + \ + (((do_interlace)!=0)<<15) + ((width)<<16) + ((height)<<24))) + +#define COL_FROM_ID(id) ((png_byte)((id)& 0x7U)) +#define DEPTH_FROM_ID(id) ((png_byte)(((id) >> 3) & 0x1fU)) +#define PALETTE_FROM_ID(id) (((id) >> 8) & 0x1f) +#define INTERLACE_FROM_ID(id) ((png_byte)(((id) >> 13) & 0x3)) +#define DO_INTERLACE_FROM_ID(id) ((int)(((id)>>15) & 1)) +#define WIDTH_FROM_ID(id) (((id)>>16) & 0xff) +#define HEIGHT_FROM_ID(id) (((id)>>24) & 0xff) + +/* Utility to construct a standard name for a standard image. */ +static size_t +standard_name(char *buffer, size_t bufsize, size_t pos, png_byte colour_type, + int bit_depth, unsigned int npalette, int interlace_type, + png_uint_32 w, png_uint_32 h, int do_interlace) +{ + pos = safecat(buffer, bufsize, pos, colour_types[colour_type]); + if (colour_type == 3) /* must have a palette */ + { + pos = safecat(buffer, bufsize, pos, "["); + pos = safecatn(buffer, bufsize, pos, npalette); + pos = safecat(buffer, bufsize, pos, "]"); + } + + else if (npalette != 0) + pos = safecat(buffer, bufsize, pos, "+tRNS"); + + pos = safecat(buffer, bufsize, pos, " "); + pos = safecatn(buffer, bufsize, pos, bit_depth); + pos = safecat(buffer, bufsize, pos, " bit"); + + if (interlace_type != PNG_INTERLACE_NONE) + { + pos = safecat(buffer, bufsize, pos, " interlaced"); + if (do_interlace) + pos = safecat(buffer, bufsize, pos, "(pngvalid)"); + else + pos = safecat(buffer, bufsize, pos, "(libpng)"); + } + + if (w > 0 || h > 0) + { + pos = safecat(buffer, bufsize, pos, " "); + pos = safecatn(buffer, bufsize, pos, w); + pos = safecat(buffer, bufsize, pos, "x"); + pos = safecatn(buffer, bufsize, pos, h); + } + + return pos; +} + +static size_t +standard_name_from_id(char *buffer, size_t bufsize, size_t pos, png_uint_32 id) +{ + return standard_name(buffer, bufsize, pos, COL_FROM_ID(id), + DEPTH_FROM_ID(id), PALETTE_FROM_ID(id), INTERLACE_FROM_ID(id), + WIDTH_FROM_ID(id), HEIGHT_FROM_ID(id), DO_INTERLACE_FROM_ID(id)); +} + +/* Convenience API and defines to list valid formats. Note that 16 bit read and + * write support is required to do 16 bit read tests (we must be able to make a + * 16 bit image to test!) + */ +#ifdef PNG_WRITE_16BIT_SUPPORTED +# define WRITE_BDHI 4 +# ifdef PNG_READ_16BIT_SUPPORTED +# define READ_BDHI 4 +# define DO_16BIT +# endif +#else +# define WRITE_BDHI 3 +#endif +#ifndef DO_16BIT +# define READ_BDHI 3 +#endif + +/* The following defines the number of different palettes to generate for + * each log bit depth of a colour type 3 standard image. + */ +#define PALETTE_COUNT(bit_depth) ((bit_depth) > 4 ? 1U : 16U) + +static int +next_format(png_bytep colour_type, png_bytep bit_depth, + unsigned int* palette_number, int low_depth_gray, int tRNS) +{ + if (*bit_depth == 0) + { + *colour_type = 0; + if (low_depth_gray) + *bit_depth = 1; + else + *bit_depth = 8; + *palette_number = 0; + return 1; + } + + if (*colour_type < 4/*no alpha channel*/) + { + /* Add multiple palettes for colour type 3, one image with tRNS + * and one without for other non-alpha formats: + */ + unsigned int pn = ++*palette_number; + png_byte ct = *colour_type; + + if (((ct == 0/*GRAY*/ || ct/*RGB*/ == 2) && tRNS && pn < 2) || + (ct == 3/*PALETTE*/ && pn < PALETTE_COUNT(*bit_depth))) + return 1; + + /* No: next bit depth */ + *palette_number = 0; + } + + *bit_depth = (png_byte)(*bit_depth << 1); + + /* Palette images are restricted to 8 bit depth */ + if (*bit_depth <= 8 +#ifdef DO_16BIT + || (*colour_type != 3 && *bit_depth <= 16) +#endif + ) + return 1; + + /* Move to the next color type, or return 0 at the end. */ + switch (*colour_type) + { + case 0: + *colour_type = 2; + *bit_depth = 8; + return 1; + + case 2: + *colour_type = 3; + *bit_depth = 1; + return 1; + + case 3: + *colour_type = 4; + *bit_depth = 8; + return 1; + + case 4: + *colour_type = 6; + *bit_depth = 8; + return 1; + + default: + return 0; + } +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static unsigned int +sample(png_const_bytep row, png_byte colour_type, png_byte bit_depth, + png_uint_32 x, unsigned int sample_index, int swap16, int littleendian) +{ + png_uint_32 bit_index, result; + + /* Find a sample index for the desired sample: */ + x *= bit_depth; + bit_index = x; + + if ((colour_type & 1) == 0) /* !palette */ + { + if (colour_type & 2) + bit_index *= 3; + + if (colour_type & 4) + bit_index += x; /* Alpha channel */ + + /* Multiple channels; select one: */ + if (colour_type & (2+4)) + bit_index += sample_index * bit_depth; + } + + /* Return the sample from the row as an integer. */ + row += bit_index >> 3; + result = *row; + + if (bit_depth == 8) + return result; + + else if (bit_depth > 8) + { + if (swap16) + return (*++row << 8) + result; + else + return (result << 8) + *++row; + } + + /* Less than 8 bits per sample. By default PNG has the big end of + * the egg on the left of the screen, but if littleendian is set + * then the big end is on the right. + */ + bit_index &= 7; + + if (!littleendian) + bit_index = 8-bit_index-bit_depth; + + return (result >> bit_index) & ((1U<> 3] & ~destMask; + unsigned int sourceByte = fromBuffer[fromIndex >> 3]; + + /* Don't rely on << or >> supporting '0' here, just in case: */ + fromIndex &= 7; + if (littleendian) + { + if (fromIndex > 0) sourceByte >>= fromIndex; + if ((toIndex & 7) > 0) sourceByte <<= toIndex & 7; + } + + else + { + if (fromIndex > 0) sourceByte <<= fromIndex; + if ((toIndex & 7) > 0) sourceByte >>= toIndex & 7; + } + + toBuffer[toIndex >> 3] = (png_byte)(destByte | (sourceByte & destMask)); + } + else /* One or more bytes */ + memmove(toBuffer+(toIndex>>3), fromBuffer+(fromIndex>>3), pixelSize>>3); +} + +#ifdef PNG_READ_SUPPORTED +/* Copy a complete row of pixels, taking into account potential partial + * bytes at the end. + */ +static void +row_copy(png_bytep toBuffer, png_const_bytep fromBuffer, unsigned int bitWidth, + int littleendian) +{ + memcpy(toBuffer, fromBuffer, bitWidth >> 3); + + if ((bitWidth & 7) != 0) + { + unsigned int mask; + + toBuffer += bitWidth >> 3; + fromBuffer += bitWidth >> 3; + if (littleendian) + mask = 0xff << (bitWidth & 7); + else + mask = 0xff >> (bitWidth & 7); + *toBuffer = (png_byte)((*toBuffer & mask) | (*fromBuffer & ~mask)); + } +} + +/* Compare pixels - they are assumed to start at the first byte in the + * given buffers. + */ +static int +pixel_cmp(png_const_bytep pa, png_const_bytep pb, png_uint_32 bit_width) +{ +#if PNG_LIBPNG_VER < 10506 + if (memcmp(pa, pb, bit_width>>3) == 0) + { + png_uint_32 p; + + if ((bit_width & 7) == 0) return 0; + + /* Ok, any differences? */ + p = pa[bit_width >> 3]; + p ^= pb[bit_width >> 3]; + + if (p == 0) return 0; + + /* There are, but they may not be significant, remove the bits + * after the end (the low order bits in PNG.) + */ + bit_width &= 7; + p >>= 8-bit_width; + + if (p == 0) return 0; + } +#else + /* From libpng-1.5.6 the overwrite should be fixed, so compare the trailing + * bits too: + */ + if (memcmp(pa, pb, (bit_width+7)>>3) == 0) + return 0; +#endif + + /* Return the index of the changed byte. */ + { + png_uint_32 where = 0; + + while (pa[where] == pb[where]) ++where; + return 1+where; + } +} +#endif /* PNG_READ_SUPPORTED */ + +/*************************** BASIC PNG FILE WRITING ***************************/ +/* A png_store takes data from the sequential writer or provides data + * to the sequential reader. It can also store the result of a PNG + * write for later retrieval. + */ +#define STORE_BUFFER_SIZE 500 /* arbitrary */ +typedef struct png_store_buffer +{ + struct png_store_buffer* prev; /* NOTE: stored in reverse order */ + png_byte buffer[STORE_BUFFER_SIZE]; +} png_store_buffer; + +#define FILE_NAME_SIZE 64 + +typedef struct store_palette_entry /* record of a single palette entry */ +{ + png_byte red; + png_byte green; + png_byte blue; + png_byte alpha; +} store_palette_entry, store_palette[256]; + +typedef struct png_store_file +{ + struct png_store_file* next; /* as many as you like... */ + char name[FILE_NAME_SIZE]; + unsigned int IDAT_bits; /* Number of bits in IDAT size */ + png_uint_32 IDAT_size; /* Total size of IDAT data */ + png_uint_32 id; /* must be correct (see FILEID) */ + size_t datacount; /* In this (the last) buffer */ + png_store_buffer data; /* Last buffer in file */ + int npalette; /* Number of entries in palette */ + store_palette_entry* palette; /* May be NULL */ +} png_store_file; + +/* The following is a pool of memory allocated by a single libpng read or write + * operation. + */ +typedef struct store_pool +{ + struct png_store *store; /* Back pointer */ + struct store_memory *list; /* List of allocated memory */ + png_byte mark[4]; /* Before and after data */ + + /* Statistics for this run. */ + png_alloc_size_t max; /* Maximum single allocation */ + png_alloc_size_t current; /* Current allocation */ + png_alloc_size_t limit; /* Highest current allocation */ + png_alloc_size_t total; /* Total allocation */ + + /* Overall statistics (retained across successive runs). */ + png_alloc_size_t max_max; + png_alloc_size_t max_limit; + png_alloc_size_t max_total; +} store_pool; + +typedef struct png_store +{ + /* For cexcept.h exception handling - simply store one of these; + * the context is a self pointer but it may point to a different + * png_store (in fact it never does in this program.) + */ + struct exception_context + exception_context; + + unsigned int verbose :1; + unsigned int treat_warnings_as_errors :1; + unsigned int expect_error :1; + unsigned int expect_warning :1; + unsigned int saw_warning :1; + unsigned int speed :1; + unsigned int progressive :1; /* use progressive read */ + unsigned int validated :1; /* used as a temporary flag */ + int nerrors; + int nwarnings; + int noptions; /* number of options below: */ + struct { + unsigned char option; /* option number, 0..30 */ + unsigned char setting; /* setting (unset,invalid,on,off) */ + } options[16]; + char test[128]; /* Name of test */ + char error[256]; + + /* Share fields */ + png_uint_32 chunklen; /* Length of chunk+overhead (chunkpos >= 8) */ + png_uint_32 chunktype;/* Type of chunk (valid if chunkpos >= 4) */ + png_uint_32 chunkpos; /* Position in chunk */ + png_uint_32 IDAT_size;/* Accumulated IDAT size in .new */ + unsigned int IDAT_bits;/* Cache of the file store value */ + + /* Read fields */ + png_structp pread; /* Used to read a saved file */ + png_infop piread; + png_store_file* current; /* Set when reading */ + png_store_buffer* next; /* Set when reading */ + size_t readpos; /* Position in *next */ + png_byte* image; /* Buffer for reading interlaced images */ + size_t cb_image; /* Size of this buffer */ + size_t cb_row; /* Row size of the image(s) */ + uLong IDAT_crc; + png_uint_32 IDAT_len; /* Used when re-chunking IDAT chunks */ + png_uint_32 IDAT_pos; /* Used when re-chunking IDAT chunks */ + png_uint_32 image_h; /* Number of rows in a single image */ + store_pool read_memory_pool; + + /* Write fields */ + png_store_file* saved; + png_structp pwrite; /* Used when writing a new file */ + png_infop piwrite; + size_t writepos; /* Position in .new */ + char wname[FILE_NAME_SIZE]; + png_store_buffer new; /* The end of the new PNG file being written. */ + store_pool write_memory_pool; + store_palette_entry* palette; + int npalette; +} png_store; + +/* Initialization and cleanup */ +static void +store_pool_mark(png_bytep mark) +{ + static png_uint_32 store_seed[2] = { 0x12345678, 1}; + + make_four_random_bytes(store_seed, mark); +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* Use this for random 32 bit values; this function makes sure the result is + * non-zero. + */ +static png_uint_32 +random_32(void) +{ + + for (;;) + { + png_byte mark[4]; + png_uint_32 result; + + store_pool_mark(mark); + result = png_get_uint_32(mark); + + if (result != 0) + return result; + } +} +#endif /* PNG_READ_SUPPORTED */ + +static void +store_pool_init(png_store *ps, store_pool *pool) +{ + memset(pool, 0, sizeof *pool); + + pool->store = ps; + pool->list = NULL; + pool->max = pool->current = pool->limit = pool->total = 0; + pool->max_max = pool->max_limit = pool->max_total = 0; + store_pool_mark(pool->mark); +} + +static void +store_init(png_store* ps) +{ + memset(ps, 0, sizeof *ps); + init_exception_context(&ps->exception_context); + store_pool_init(ps, &ps->read_memory_pool); + store_pool_init(ps, &ps->write_memory_pool); + ps->verbose = 0; + ps->treat_warnings_as_errors = 0; + ps->expect_error = 0; + ps->expect_warning = 0; + ps->saw_warning = 0; + ps->speed = 0; + ps->progressive = 0; + ps->validated = 0; + ps->nerrors = ps->nwarnings = 0; + ps->pread = NULL; + ps->piread = NULL; + ps->saved = ps->current = NULL; + ps->next = NULL; + ps->readpos = 0; + ps->image = NULL; + ps->cb_image = 0; + ps->cb_row = 0; + ps->image_h = 0; + ps->pwrite = NULL; + ps->piwrite = NULL; + ps->writepos = 0; + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; + ps->IDAT_bits = 0; + ps->new.prev = NULL; + ps->palette = NULL; + ps->npalette = 0; + ps->noptions = 0; +} + +static void +store_freebuffer(png_store_buffer* psb) +{ + if (psb->prev) + { + store_freebuffer(psb->prev); + free(psb->prev); + psb->prev = NULL; + } +} + +static void +store_freenew(png_store *ps) +{ + store_freebuffer(&ps->new); + ps->writepos = 0; + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; + ps->IDAT_bits = 0; + if (ps->palette != NULL) + { + free(ps->palette); + ps->palette = NULL; + ps->npalette = 0; + } +} + +static void +store_storenew(png_store *ps) +{ + png_store_buffer *pb; + + pb = voidcast(png_store_buffer*, malloc(sizeof *pb)); + + if (pb == NULL) + png_error(ps->pwrite, "store new: OOM"); + + *pb = ps->new; + ps->new.prev = pb; + ps->writepos = 0; +} + +static void +store_freefile(png_store_file **ppf) +{ + if (*ppf != NULL) + { + store_freefile(&(*ppf)->next); + + store_freebuffer(&(*ppf)->data); + (*ppf)->datacount = 0; + if ((*ppf)->palette != NULL) + { + free((*ppf)->palette); + (*ppf)->palette = NULL; + (*ppf)->npalette = 0; + } + free(*ppf); + *ppf = NULL; + } +} + +static unsigned int +bits_of(png_uint_32 num) +{ + /* Return the number of bits in 'num' */ + unsigned int b = 0; + + if (num & 0xffff0000U) b += 16U, num >>= 16; + if (num & 0xff00U) b += 8U, num >>= 8; + if (num & 0xf0U) b += 4U, num >>= 4; + if (num & 0xcU) b += 2U, num >>= 2; + if (num & 0x2U) ++b, num >>= 1; + if (num) ++b; + + return b; /* 0..32 */ +} + +/* Main interface to file storage, after writing a new PNG file (see the API + * below) call store_storefile to store the result with the given name and id. + */ +static void +store_storefile(png_store *ps, png_uint_32 id) +{ + png_store_file *pf; + + if (ps->chunkpos != 0U || ps->chunktype != 0U || ps->chunklen != 0U || + ps->IDAT_size == 0) + png_error(ps->pwrite, "storefile: incomplete write"); + + pf = voidcast(png_store_file*, malloc(sizeof *pf)); + if (pf == NULL) + png_error(ps->pwrite, "storefile: OOM"); + safecat(pf->name, sizeof pf->name, 0, ps->wname); + pf->id = id; + pf->data = ps->new; + pf->datacount = ps->writepos; + pf->IDAT_size = ps->IDAT_size; + pf->IDAT_bits = bits_of(ps->IDAT_size); + /* Because the IDAT always has zlib header stuff this must be true: */ + if (pf->IDAT_bits == 0U) + png_error(ps->pwrite, "storefile: 0 sized IDAT"); + ps->new.prev = NULL; + ps->writepos = 0; + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; + pf->palette = ps->palette; + pf->npalette = ps->npalette; + ps->palette = 0; + ps->npalette = 0; + + /* And save it. */ + pf->next = ps->saved; + ps->saved = pf; +} + +/* Generate an error message (in the given buffer) */ +static size_t +store_message(png_store *ps, png_const_structp pp, char *buffer, size_t bufsize, + size_t pos, const char *msg) +{ + if (pp != NULL && pp == ps->pread) + { + /* Reading a file */ + pos = safecat(buffer, bufsize, pos, "read: "); + + if (ps->current != NULL) + { + pos = safecat(buffer, bufsize, pos, ps->current->name); + pos = safecat(buffer, bufsize, pos, sep); + } + } + + else if (pp != NULL && pp == ps->pwrite) + { + /* Writing a file */ + pos = safecat(buffer, bufsize, pos, "write: "); + pos = safecat(buffer, bufsize, pos, ps->wname); + pos = safecat(buffer, bufsize, pos, sep); + } + + else + { + /* Neither reading nor writing (or a memory error in struct delete) */ + pos = safecat(buffer, bufsize, pos, "pngvalid: "); + } + + if (ps->test[0] != 0) + { + pos = safecat(buffer, bufsize, pos, ps->test); + pos = safecat(buffer, bufsize, pos, sep); + } + pos = safecat(buffer, bufsize, pos, msg); + return pos; +} + +/* Verbose output to the error stream: */ +static void +store_verbose(png_store *ps, png_const_structp pp, png_const_charp prefix, + png_const_charp message) +{ + char buffer[512]; + + if (prefix) + fputs(prefix, stderr); + + (void)store_message(ps, pp, buffer, sizeof buffer, 0, message); + fputs(buffer, stderr); + fputc('\n', stderr); +} + +/* Log an error or warning - the relevant count is always incremented. */ +static void +store_log(png_store* ps, png_const_structp pp, png_const_charp message, + int is_error) +{ + /* The warning is copied to the error buffer if there are no errors and it is + * the first warning. The error is copied to the error buffer if it is the + * first error (overwriting any prior warnings). + */ + if (is_error ? (ps->nerrors)++ == 0 : + (ps->nwarnings)++ == 0 && ps->nerrors == 0) + store_message(ps, pp, ps->error, sizeof ps->error, 0, message); + + if (ps->verbose) + store_verbose(ps, pp, is_error ? "error: " : "warning: ", message); +} + +#ifdef PNG_READ_SUPPORTED +/* Internal error function, called with a png_store but no libpng stuff. */ +static void +internal_error(png_store *ps, png_const_charp message) +{ + store_log(ps, NULL, message, 1 /* error */); + + /* And finally throw an exception. */ + { + struct exception_context *the_exception_context = &ps->exception_context; + Throw ps; + } +} +#endif /* PNG_READ_SUPPORTED */ + +/* Functions to use as PNG callbacks. */ +static void PNGCBAPI +store_error(png_structp ppIn, png_const_charp message) /* PNG_NORETURN */ +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_error_ptr(pp)); + + if (!ps->expect_error) + store_log(ps, pp, message, 1 /* error */); + + /* And finally throw an exception. */ + { + struct exception_context *the_exception_context = &ps->exception_context; + Throw ps; + } +} + +static void PNGCBAPI +store_warning(png_structp ppIn, png_const_charp message) +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_error_ptr(pp)); + + if (!ps->expect_warning) + store_log(ps, pp, message, 0 /* warning */); + else + ps->saw_warning = 1; +} + +/* These somewhat odd functions are used when reading an image to ensure that + * the buffer is big enough, the png_structp is for errors. + */ +/* Return a single row from the correct image. */ +static png_bytep +store_image_row(const png_store* ps, png_const_structp pp, int nImage, + png_uint_32 y) +{ + size_t coffset = (nImage * ps->image_h + y) * (ps->cb_row + 5) + 2; + + if (ps->image == NULL) + png_error(pp, "no allocated image"); + + if (coffset + ps->cb_row + 3 > ps->cb_image) + png_error(pp, "image too small"); + + return ps->image + coffset; +} + +static void +store_image_free(png_store *ps, png_const_structp pp) +{ + if (ps->image != NULL) + { + png_bytep image = ps->image; + + if (image[-1] != 0xed || image[ps->cb_image] != 0xfe) + { + if (pp != NULL) + png_error(pp, "png_store image overwrite (1)"); + else + store_log(ps, NULL, "png_store image overwrite (2)", 1); + } + + ps->image = NULL; + ps->cb_image = 0; + --image; + free(image); + } +} + +static void +store_ensure_image(png_store *ps, png_const_structp pp, int nImages, + size_t cbRow, png_uint_32 cRows) +{ + size_t cb = nImages * cRows * (cbRow + 5); + + if (ps->cb_image < cb) + { + png_bytep image; + + store_image_free(ps, pp); + + /* The buffer is deliberately mis-aligned. */ + image = voidcast(png_bytep, malloc(cb+2)); + if (image == NULL) + { + /* Called from the startup - ignore the error for the moment. */ + if (pp == NULL) + return; + + png_error(pp, "OOM allocating image buffer"); + } + + /* These magic tags are used to detect overwrites above. */ + ++image; + image[-1] = 0xed; + image[cb] = 0xfe; + + ps->image = image; + ps->cb_image = cb; + } + + /* We have an adequate sized image; lay out the rows. There are 2 bytes at + * the start and three at the end of each (this ensures that the row + * alignment starts out odd - 2+1 and changes for larger images on each row.) + */ + ps->cb_row = cbRow; + ps->image_h = cRows; + + /* For error checking, the whole buffer is set to 10110010 (0xb2 - 178). + * This deliberately doesn't match the bits in the size test image which are + * outside the image; these are set to 0xff (all 1). To make the row + * comparison work in the 'size' test case the size rows are pre-initialized + * to the same value prior to calling 'standard_row'. + */ + memset(ps->image, 178, cb); + + /* Then put in the marks. */ + while (--nImages >= 0) + { + png_uint_32 y; + + for (y=0; yimage; + + if (image[-1] != 0xed || image[ps->cb_image] != 0xfe) + png_error(pp, "image overwrite"); + else + { + size_t cbRow = ps->cb_row; + png_uint_32 rows = ps->image_h; + + image += iImage * (cbRow+5) * ps->image_h; + + image += 2; /* skip image first row markers */ + + for (; rows > 0; --rows) + { + if (image[-2] != 190 || image[-1] != 239) + png_error(pp, "row start overwritten"); + + if (image[cbRow] != 222 || image[cbRow+1] != 173 || + image[cbRow+2] != 17) + png_error(pp, "row end overwritten"); + + image += cbRow+5; + } + } +} +#endif /* PNG_READ_SUPPORTED */ + +static int +valid_chunktype(png_uint_32 chunktype) +{ + /* Each byte in the chunk type must be in one of the ranges 65..90, 97..122 + * (both inclusive), so: + */ + unsigned int i; + + for (i=0; i<4; ++i) + { + unsigned int c = chunktype & 0xffU; + + if (!((c >= 65U && c <= 90U) || (c >= 97U && c <= 122U))) + return 0; + + chunktype >>= 8; + } + + return 1; /* It's valid */ +} + +static void PNGCBAPI +store_write(png_structp ppIn, png_bytep pb, size_t st) +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_io_ptr(pp)); + size_t writepos = ps->writepos; + png_uint_32 chunkpos = ps->chunkpos; + png_uint_32 chunktype = ps->chunktype; + png_uint_32 chunklen = ps->chunklen; + + if (ps->pwrite != pp) + png_error(pp, "store state damaged"); + + /* Technically this is legal, but in practice libpng never writes more than + * the maximum chunk size at once so if it happens something weird has + * changed inside libpng (probably). + */ + if (st > 0x7fffffffU) + png_error(pp, "unexpected write size"); + + /* Now process the bytes to be written. Do this in units of the space in the + * output (write) buffer or, at the start 4 bytes for the chunk type and + * length limited in any case by the amount of data. + */ + while (st > 0) + { + if (writepos >= STORE_BUFFER_SIZE) + store_storenew(ps), writepos = 0; + + if (chunkpos < 4) + { + png_byte b = *pb++; + --st; + chunklen = (chunklen << 8) + b; + ps->new.buffer[writepos++] = b; + ++chunkpos; + } + + else if (chunkpos < 8) + { + png_byte b = *pb++; + --st; + chunktype = (chunktype << 8) + b; + ps->new.buffer[writepos++] = b; + + if (++chunkpos == 8) + { + chunklen &= 0xffffffffU; + if (chunklen > 0x7fffffffU) + png_error(pp, "chunk length too great"); + + chunktype &= 0xffffffffU; + if (chunktype == CHUNK_IDAT) + { + if (chunklen > ~ps->IDAT_size) + png_error(pp, "pngvalid internal image too large"); + + ps->IDAT_size += chunklen; + } + + else if (!valid_chunktype(chunktype)) + png_error(pp, "invalid chunk type"); + + chunklen += 12; /* for header and CRC */ + } + } + + else /* chunkpos >= 8 */ + { + size_t cb = st; + + if (cb > STORE_BUFFER_SIZE - writepos) + cb = STORE_BUFFER_SIZE - writepos; + + if (cb > chunklen - chunkpos/* bytes left in chunk*/) + cb = (size_t)/*SAFE*/(chunklen - chunkpos); + + memcpy(ps->new.buffer + writepos, pb, cb); + chunkpos += (png_uint_32)/*SAFE*/cb; + pb += cb; + writepos += cb; + st -= cb; + + if (chunkpos >= chunklen) /* must be equal */ + chunkpos = chunktype = chunklen = 0; + } + } /* while (st > 0) */ + + ps->writepos = writepos; + ps->chunkpos = chunkpos; + ps->chunktype = chunktype; + ps->chunklen = chunklen; +} + +static void PNGCBAPI +store_flush(png_structp ppIn) +{ + UNUSED(ppIn) /*DOES NOTHING*/ +} + +#ifdef PNG_READ_SUPPORTED +static size_t +store_read_buffer_size(png_store *ps) +{ + /* Return the bytes available for read in the current buffer. */ + if (ps->next != &ps->current->data) + return STORE_BUFFER_SIZE; + + return ps->current->datacount; +} + +/* Return total bytes available for read. */ +static size_t +store_read_buffer_avail(png_store *ps) +{ + if (ps->current != NULL && ps->next != NULL) + { + png_store_buffer *next = &ps->current->data; + size_t cbAvail = ps->current->datacount; + + while (next != ps->next && next != NULL) + { + next = next->prev; + cbAvail += STORE_BUFFER_SIZE; + } + + if (next != ps->next) + png_error(ps->pread, "buffer read error"); + + if (cbAvail > ps->readpos) + return cbAvail - ps->readpos; + } + + return 0; +} + +static int +store_read_buffer_next(png_store *ps) +{ + png_store_buffer *pbOld = ps->next; + png_store_buffer *pbNew = &ps->current->data; + if (pbOld != pbNew) + { + while (pbNew != NULL && pbNew->prev != pbOld) + pbNew = pbNew->prev; + + if (pbNew != NULL) + { + ps->next = pbNew; + ps->readpos = 0; + return 1; + } + + png_error(ps->pread, "buffer lost"); + } + + return 0; /* EOF or error */ +} + +/* Need separate implementation and callback to allow use of the same code + * during progressive read, where the io_ptr is set internally by libpng. + */ +static void +store_read_imp(png_store *ps, png_bytep pb, size_t st) +{ + if (ps->current == NULL || ps->next == NULL) + png_error(ps->pread, "store state damaged"); + + while (st > 0) + { + size_t cbAvail = store_read_buffer_size(ps) - ps->readpos; + + if (cbAvail > 0) + { + if (cbAvail > st) cbAvail = st; + memcpy(pb, ps->next->buffer + ps->readpos, cbAvail); + st -= cbAvail; + pb += cbAvail; + ps->readpos += cbAvail; + } + + else if (!store_read_buffer_next(ps)) + png_error(ps->pread, "read beyond end of file"); + } +} + +static size_t +store_read_chunk(png_store *ps, png_bytep pb, size_t max, size_t min) +{ + png_uint_32 chunklen = ps->chunklen; + png_uint_32 chunktype = ps->chunktype; + png_uint_32 chunkpos = ps->chunkpos; + size_t st = max; + + if (st > 0) do + { + if (chunkpos >= chunklen) /* end of last chunk */ + { + png_byte buffer[8]; + + /* Read the header of the next chunk: */ + store_read_imp(ps, buffer, 8U); + chunklen = png_get_uint_32(buffer) + 12U; + chunktype = png_get_uint_32(buffer+4U); + chunkpos = 0U; /* Position read so far */ + } + + if (chunktype == CHUNK_IDAT) + { + png_uint_32 IDAT_pos = ps->IDAT_pos; + png_uint_32 IDAT_len = ps->IDAT_len; + png_uint_32 IDAT_size = ps->IDAT_size; + + /* The IDAT headers are constructed here; skip the input header. */ + if (chunkpos < 8U) + chunkpos = 8U; + + if (IDAT_pos == IDAT_len) + { + png_byte random = random_byte(); + + /* Make a new IDAT chunk, if IDAT_len is 0 this is the first IDAT, + * if IDAT_size is 0 this is the end. At present this is set up + * using a random number so that there is a 25% chance before + * the start of the first IDAT chunk being 0 length. + */ + if (IDAT_len == 0U) /* First IDAT */ + { + switch (random & 3U) + { + case 0U: IDAT_len = 12U; break; /* 0 bytes */ + case 1U: IDAT_len = 13U; break; /* 1 byte */ + default: IDAT_len = random_u32(); + IDAT_len %= IDAT_size; + IDAT_len += 13U; /* 1..IDAT_size bytes */ + break; + } + } + + else if (IDAT_size == 0U) /* all IDAT data read */ + { + /* The last (IDAT) chunk should be positioned at the CRC now: */ + if (chunkpos != chunklen-4U) + png_error(ps->pread, "internal: IDAT size mismatch"); + + /* The only option here is to add a zero length IDAT, this + * happens 25% of the time. Because of the check above + * chunklen-4U-chunkpos must be zero, we just need to skip the + * CRC now. + */ + if ((random & 3U) == 0U) + IDAT_len = 12U; /* Output another 0 length IDAT */ + + else + { + /* End of IDATs, skip the CRC to make the code above load the + * next chunk header next time round. + */ + png_byte buffer[4]; + + store_read_imp(ps, buffer, 4U); + chunkpos += 4U; + ps->IDAT_pos = IDAT_pos; + ps->IDAT_len = IDAT_len; + ps->IDAT_size = 0U; + continue; /* Read the next chunk */ + } + } + + else + { + /* Middle of IDATs, use 'random' to determine the number of bits + * to use in the IDAT length. + */ + IDAT_len = random_u32(); + IDAT_len &= (1U << (1U + random % ps->IDAT_bits)) - 1U; + if (IDAT_len > IDAT_size) + IDAT_len = IDAT_size; + IDAT_len += 12U; /* zero bytes may occur */ + } + + IDAT_pos = 0U; + ps->IDAT_crc = 0x35af061e; /* Ie: crc32(0UL, "IDAT", 4) */ + } /* IDAT_pos == IDAT_len */ + + if (IDAT_pos < 8U) /* Return the header */ do + { + png_uint_32 b; + unsigned int shift; + + if (IDAT_pos < 4U) + b = IDAT_len - 12U; + + else + b = CHUNK_IDAT; + + shift = 3U & IDAT_pos; + ++IDAT_pos; + + if (shift < 3U) + b >>= 8U*(3U-shift); + + *pb++ = 0xffU & b; + } + while (--st > 0 && IDAT_pos < 8); + + else if (IDAT_pos < IDAT_len - 4U) /* I.e not the CRC */ + { + if (chunkpos < chunklen-4U) + { + uInt avail = (uInt)-1; + + if (avail > (IDAT_len-4U) - IDAT_pos) + avail = (uInt)/*SAFE*/((IDAT_len-4U) - IDAT_pos); + + if (avail > st) + avail = (uInt)/*SAFE*/st; + + if (avail > (chunklen-4U) - chunkpos) + avail = (uInt)/*SAFE*/((chunklen-4U) - chunkpos); + + store_read_imp(ps, pb, avail); + ps->IDAT_crc = crc32(ps->IDAT_crc, pb, avail); + pb += (size_t)/*SAFE*/avail; + st -= (size_t)/*SAFE*/avail; + chunkpos += (png_uint_32)/*SAFE*/avail; + IDAT_size -= (png_uint_32)/*SAFE*/avail; + IDAT_pos += (png_uint_32)/*SAFE*/avail; + } + + else /* skip the input CRC */ + { + png_byte buffer[4]; + + store_read_imp(ps, buffer, 4U); + chunkpos += 4U; + } + } + + else /* IDAT crc */ do + { + uLong b = ps->IDAT_crc; + unsigned int shift = (IDAT_len - IDAT_pos); /* 4..1 */ + ++IDAT_pos; + + if (shift > 1U) + b >>= 8U*(shift-1U); + + *pb++ = 0xffU & b; + } + while (--st > 0 && IDAT_pos < IDAT_len); + + ps->IDAT_pos = IDAT_pos; + ps->IDAT_len = IDAT_len; + ps->IDAT_size = IDAT_size; + } + + else /* !IDAT */ + { + /* If there is still some pending IDAT data after the IDAT chunks have + * been processed there is a problem: + */ + if (ps->IDAT_len > 0 && ps->IDAT_size > 0) + png_error(ps->pread, "internal: missing IDAT data"); + + if (chunktype == CHUNK_IEND && ps->IDAT_len == 0U) + png_error(ps->pread, "internal: missing IDAT"); + + if (chunkpos < 8U) /* Return the header */ do + { + png_uint_32 b; + unsigned int shift; + + if (chunkpos < 4U) + b = chunklen - 12U; + + else + b = chunktype; + + shift = 3U & chunkpos; + ++chunkpos; + + if (shift < 3U) + b >>= 8U*(3U-shift); + + *pb++ = 0xffU & b; + } + while (--st > 0 && chunkpos < 8); + + else /* Return chunk bytes, including the CRC */ + { + size_t avail = st; + + if (avail > chunklen - chunkpos) + avail = (size_t)/*SAFE*/(chunklen - chunkpos); + + store_read_imp(ps, pb, avail); + pb += avail; + st -= avail; + chunkpos += (png_uint_32)/*SAFE*/avail; + + /* Check for end of chunk and end-of-file; don't try to read a new + * chunk header at this point unless instructed to do so by 'min'. + */ + if (chunkpos >= chunklen && max-st >= min && + store_read_buffer_avail(ps) == 0) + break; + } + } /* !IDAT */ + } + while (st > 0); + + ps->chunklen = chunklen; + ps->chunktype = chunktype; + ps->chunkpos = chunkpos; + + return st; /* space left */ +} + +static void PNGCBAPI +store_read(png_structp ppIn, png_bytep pb, size_t st) +{ + png_const_structp pp = ppIn; + png_store *ps = voidcast(png_store*, png_get_io_ptr(pp)); + + if (ps == NULL || ps->pread != pp) + png_error(pp, "bad store read call"); + + store_read_chunk(ps, pb, st, st); +} + +static void +store_progressive_read(png_store *ps, png_structp pp, png_infop pi) +{ + if (ps->pread != pp || ps->current == NULL || ps->next == NULL) + png_error(pp, "store state damaged (progressive)"); + + /* This is another Horowitz and Hill random noise generator. In this case + * the aim is to stress the progressive reader with truly horrible variable + * buffer sizes in the range 1..500, so a sequence of 9 bit random numbers + * is generated. We could probably just count from 1 to 32767 and get as + * good a result. + */ + while (store_read_buffer_avail(ps) > 0) + { + static png_uint_32 noise = 2; + size_t cb; + png_byte buffer[512]; + + /* Generate 15 more bits of stuff: */ + noise = (noise << 9) | ((noise ^ (noise >> (9-5))) & 0x1ff); + cb = noise & 0x1ff; + cb -= store_read_chunk(ps, buffer, cb, 1); + png_process_data(pp, pi, buffer, cb); + } +} +#endif /* PNG_READ_SUPPORTED */ + +/* The caller must fill this in: */ +static store_palette_entry * +store_write_palette(png_store *ps, int npalette) +{ + if (ps->pwrite == NULL) + store_log(ps, NULL, "attempt to write palette without write stream", 1); + + if (ps->palette != NULL) + png_error(ps->pwrite, "multiple store_write_palette calls"); + + /* This function can only return NULL if called with '0'! */ + if (npalette > 0) + { + ps->palette = voidcast(store_palette_entry*, malloc(npalette * + sizeof *ps->palette)); + + if (ps->palette == NULL) + png_error(ps->pwrite, "store new palette: OOM"); + + ps->npalette = npalette; + } + + return ps->palette; +} + +#ifdef PNG_READ_SUPPORTED +static store_palette_entry * +store_current_palette(png_store *ps, int *npalette) +{ + /* This is an internal error (the call has been made outside a read + * operation.) + */ + if (ps->current == NULL) + { + store_log(ps, ps->pread, "no current stream for palette", 1); + return NULL; + } + + /* The result may be null if there is no palette. */ + *npalette = ps->current->npalette; + return ps->current->palette; +} +#endif /* PNG_READ_SUPPORTED */ + +/***************************** MEMORY MANAGEMENT*** ***************************/ +#ifdef PNG_USER_MEM_SUPPORTED +/* A store_memory is simply the header for an allocated block of memory. The + * pointer returned to libpng is just after the end of the header block, the + * allocated memory is followed by a second copy of the 'mark'. + */ +typedef struct store_memory +{ + store_pool *pool; /* Originating pool */ + struct store_memory *next; /* Singly linked list */ + png_alloc_size_t size; /* Size of memory allocated */ + png_byte mark[4]; /* ID marker */ +} store_memory; + +/* Handle a fatal error in memory allocation. This calls png_error if the + * libpng struct is non-NULL, else it outputs a message and returns. This means + * that a memory problem while libpng is running will abort (png_error) the + * handling of particular file while one in cleanup (after the destroy of the + * struct has returned) will simply keep going and free (or attempt to free) + * all the memory. + */ +static void +store_pool_error(png_store *ps, png_const_structp pp, const char *msg) +{ + if (pp != NULL) + png_error(pp, msg); + + /* Else we have to do it ourselves. png_error eventually calls store_log, + * above. store_log accepts a NULL png_structp - it just changes what gets + * output by store_message. + */ + store_log(ps, pp, msg, 1 /* error */); +} + +static void +store_memory_free(png_const_structp pp, store_pool *pool, store_memory *memory) +{ + /* Note that pp may be NULL (see store_pool_delete below), the caller has + * found 'memory' in pool->list *and* unlinked this entry, so this is a valid + * pointer (for sure), but the contents may have been trashed. + */ + if (memory->pool != pool) + store_pool_error(pool->store, pp, "memory corrupted (pool)"); + + else if (memcmp(memory->mark, pool->mark, sizeof memory->mark) != 0) + store_pool_error(pool->store, pp, "memory corrupted (start)"); + + /* It should be safe to read the size field now. */ + else + { + png_alloc_size_t cb = memory->size; + + if (cb > pool->max) + store_pool_error(pool->store, pp, "memory corrupted (size)"); + + else if (memcmp((png_bytep)(memory+1)+cb, pool->mark, sizeof pool->mark) + != 0) + store_pool_error(pool->store, pp, "memory corrupted (end)"); + + /* Finally give the library a chance to find problems too: */ + else + { + pool->current -= cb; + free(memory); + } + } +} + +static void +store_pool_delete(png_store *ps, store_pool *pool) +{ + if (pool->list != NULL) + { + fprintf(stderr, "%s: %s %s: memory lost (list follows):\n", ps->test, + pool == &ps->read_memory_pool ? "read" : "write", + pool == &ps->read_memory_pool ? (ps->current != NULL ? + ps->current->name : "unknown file") : ps->wname); + ++ps->nerrors; + + do + { + store_memory *next = pool->list; + pool->list = next->next; + next->next = NULL; + + fprintf(stderr, "\t%lu bytes @ %p\n", + (unsigned long)next->size, (const void*)(next+1)); + /* The NULL means this will always return, even if the memory is + * corrupted. + */ + store_memory_free(NULL, pool, next); + } + while (pool->list != NULL); + } + + /* And reset the other fields too for the next time. */ + if (pool->max > pool->max_max) pool->max_max = pool->max; + pool->max = 0; + if (pool->current != 0) /* unexpected internal error */ + fprintf(stderr, "%s: %s %s: memory counter mismatch (internal error)\n", + ps->test, pool == &ps->read_memory_pool ? "read" : "write", + pool == &ps->read_memory_pool ? (ps->current != NULL ? + ps->current->name : "unknown file") : ps->wname); + pool->current = 0; + + if (pool->limit > pool->max_limit) + pool->max_limit = pool->limit; + + pool->limit = 0; + + if (pool->total > pool->max_total) + pool->max_total = pool->total; + + pool->total = 0; + + /* Get a new mark too. */ + store_pool_mark(pool->mark); +} + +/* The memory callbacks: */ +static png_voidp PNGCBAPI +store_malloc(png_structp ppIn, png_alloc_size_t cb) +{ + png_const_structp pp = ppIn; + store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp)); + store_memory *new = voidcast(store_memory*, malloc(cb + (sizeof *new) + + (sizeof pool->mark))); + + if (new != NULL) + { + if (cb > pool->max) + pool->max = cb; + + pool->current += cb; + + if (pool->current > pool->limit) + pool->limit = pool->current; + + pool->total += cb; + + new->size = cb; + memcpy(new->mark, pool->mark, sizeof new->mark); + memcpy((png_byte*)(new+1) + cb, pool->mark, sizeof pool->mark); + new->pool = pool; + new->next = pool->list; + pool->list = new; + ++new; + } + + else + { + /* NOTE: the PNG user malloc function cannot use the png_ptr it is passed + * other than to retrieve the allocation pointer! libpng calls the + * store_malloc callback in two basic cases: + * + * 1) From png_malloc; png_malloc will do a png_error itself if NULL is + * returned. + * 2) From png_struct or png_info structure creation; png_malloc is + * to return so cleanup can be performed. + * + * To handle this store_malloc can log a message, but can't do anything + * else. + */ + store_log(pool->store, pp, "out of memory", 1 /* is_error */); + } + + return new; +} + +static void PNGCBAPI +store_free(png_structp ppIn, png_voidp memory) +{ + png_const_structp pp = ppIn; + store_pool *pool = voidcast(store_pool*, png_get_mem_ptr(pp)); + store_memory *this = voidcast(store_memory*, memory), **test; + + /* Because libpng calls store_free with a dummy png_struct when deleting + * png_struct or png_info via png_destroy_struct_2 it is necessary to check + * the passed in png_structp to ensure it is valid, and not pass it to + * png_error if it is not. + */ + if (pp != pool->store->pread && pp != pool->store->pwrite) + pp = NULL; + + /* First check that this 'memory' really is valid memory - it must be in the + * pool list. If it is, use the shared memory_free function to free it. + */ + --this; + for (test = &pool->list; *test != this; test = &(*test)->next) + { + if (*test == NULL) + { + store_pool_error(pool->store, pp, "bad pointer to free"); + return; + } + } + + /* Unlink this entry, *test == this. */ + *test = this->next; + this->next = NULL; + store_memory_free(pp, pool, this); +} +#endif /* PNG_USER_MEM_SUPPORTED */ + +/* Setup functions. */ +/* Cleanup when aborting a write or after storing the new file. */ +static void +store_write_reset(png_store *ps) +{ + if (ps->pwrite != NULL) + { + anon_context(ps); + + Try + png_destroy_write_struct(&ps->pwrite, &ps->piwrite); + + Catch_anonymous + { + /* memory corruption: continue. */ + } + + ps->pwrite = NULL; + ps->piwrite = NULL; + } + + /* And make sure that all the memory has been freed - this will output + * spurious errors in the case of memory corruption above, but this is safe. + */ +# ifdef PNG_USER_MEM_SUPPORTED + store_pool_delete(ps, &ps->write_memory_pool); +# endif + + store_freenew(ps); +} + +/* The following is the main write function, it returns a png_struct and, + * optionally, a png_info suitable for writiing a new PNG file. Use + * store_storefile above to record this file after it has been written. The + * returned libpng structures as destroyed by store_write_reset above. + */ +static png_structp +set_store_for_write(png_store *ps, png_infopp ppi, const char *name) +{ + anon_context(ps); + + Try + { + if (ps->pwrite != NULL) + png_error(ps->pwrite, "write store already in use"); + + store_write_reset(ps); + safecat(ps->wname, sizeof ps->wname, 0, name); + + /* Don't do the slow memory checks if doing a speed test, also if user + * memory is not supported we can't do it anyway. + */ +# ifdef PNG_USER_MEM_SUPPORTED + if (!ps->speed) + ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, + ps, store_error, store_warning, &ps->write_memory_pool, + store_malloc, store_free); + + else +# endif + ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING, + ps, store_error, store_warning); + + png_set_write_fn(ps->pwrite, ps, store_write, store_flush); + +# ifdef PNG_SET_OPTION_SUPPORTED + { + int opt; + for (opt=0; optnoptions; ++opt) + if (png_set_option(ps->pwrite, ps->options[opt].option, + ps->options[opt].setting) == PNG_OPTION_INVALID) + png_error(ps->pwrite, "png option invalid"); + } +# endif + + if (ppi != NULL) + *ppi = ps->piwrite = png_create_info_struct(ps->pwrite); + } + + Catch_anonymous + return NULL; + + return ps->pwrite; +} + +/* Cleanup when finished reading (either due to error or in the success case). + * This routine exists even when there is no read support to make the code + * tidier (avoid a mass of ifdefs) and so easier to maintain. + */ +static void +store_read_reset(png_store *ps) +{ +# ifdef PNG_READ_SUPPORTED + if (ps->pread != NULL) + { + anon_context(ps); + + Try + png_destroy_read_struct(&ps->pread, &ps->piread, NULL); + + Catch_anonymous + { + /* error already output: continue */ + } + + ps->pread = NULL; + ps->piread = NULL; + } +# endif + +# ifdef PNG_USER_MEM_SUPPORTED + /* Always do this to be safe. */ + store_pool_delete(ps, &ps->read_memory_pool); +# endif + + ps->current = NULL; + ps->next = NULL; + ps->readpos = 0; + ps->validated = 0; + + ps->chunkpos = 8; + ps->chunktype = 0; + ps->chunklen = 16; + ps->IDAT_size = 0; +} + +#ifdef PNG_READ_SUPPORTED +static void +store_read_set(png_store *ps, png_uint_32 id) +{ + png_store_file *pf = ps->saved; + + while (pf != NULL) + { + if (pf->id == id) + { + ps->current = pf; + ps->next = NULL; + ps->IDAT_size = pf->IDAT_size; + ps->IDAT_bits = pf->IDAT_bits; /* just a cache */ + ps->IDAT_len = 0; + ps->IDAT_pos = 0; + ps->IDAT_crc = 0UL; + store_read_buffer_next(ps); + return; + } + + pf = pf->next; + } + + { + size_t pos; + char msg[FILE_NAME_SIZE+64]; + + pos = standard_name_from_id(msg, sizeof msg, 0, id); + pos = safecat(msg, sizeof msg, pos, ": file not found"); + png_error(ps->pread, msg); + } +} + +/* The main interface for reading a saved file - pass the id number of the file + * to retrieve. Ids must be unique or the earlier file will be hidden. The API + * returns a png_struct and, optionally, a png_info. Both of these will be + * destroyed by store_read_reset above. + */ +static png_structp +set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id, + const char *name) +{ + /* Set the name for png_error */ + safecat(ps->test, sizeof ps->test, 0, name); + + if (ps->pread != NULL) + png_error(ps->pread, "read store already in use"); + + store_read_reset(ps); + + /* Both the create APIs can return NULL if used in their default mode + * (because there is no other way of handling an error because the jmp_buf + * by default is stored in png_struct and that has not been allocated!) + * However, given that store_error works correctly in these circumstances + * we don't ever expect NULL in this program. + */ +# ifdef PNG_USER_MEM_SUPPORTED + if (!ps->speed) + ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps, + store_error, store_warning, &ps->read_memory_pool, store_malloc, + store_free); + + else +# endif + ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, store_error, + store_warning); + + if (ps->pread == NULL) + { + struct exception_context *the_exception_context = &ps->exception_context; + + store_log(ps, NULL, "png_create_read_struct returned NULL (unexpected)", + 1 /*error*/); + + Throw ps; + } + +# ifdef PNG_SET_OPTION_SUPPORTED + { + int opt; + for (opt=0; optnoptions; ++opt) + if (png_set_option(ps->pread, ps->options[opt].option, + ps->options[opt].setting) == PNG_OPTION_INVALID) + png_error(ps->pread, "png option invalid"); + } +# endif + + store_read_set(ps, id); + + if (ppi != NULL) + *ppi = ps->piread = png_create_info_struct(ps->pread); + + return ps->pread; +} +#endif /* PNG_READ_SUPPORTED */ + +/* The overall cleanup of a store simply calls the above then removes all the + * saved files. This does not delete the store itself. + */ +static void +store_delete(png_store *ps) +{ + store_write_reset(ps); + store_read_reset(ps); + store_freefile(&ps->saved); + store_image_free(ps, NULL); +} + +/*********************** PNG FILE MODIFICATION ON READ ************************/ +/* Files may be modified on read. The following structure contains a complete + * png_store together with extra members to handle modification and a special + * read callback for libpng. To use this the 'modifications' field must be set + * to a list of png_modification structures that actually perform the + * modification, otherwise a png_modifier is functionally equivalent to a + * png_store. There is a special read function, set_modifier_for_read, which + * replaces set_store_for_read. + */ +typedef enum modifier_state +{ + modifier_start, /* Initial value */ + modifier_signature, /* Have a signature */ + modifier_IHDR /* Have an IHDR */ +} modifier_state; + +typedef struct CIE_color +{ + /* A single CIE tristimulus value, representing the unique response of a + * standard observer to a variety of light spectra. The observer recognizes + * all spectra that produce this response as the same color, therefore this + * is effectively a description of a color. + */ + double X, Y, Z; +} CIE_color; + +typedef struct color_encoding +{ + /* A description of an (R,G,B) encoding of color (as defined above); this + * includes the actual colors of the (R,G,B) triples (1,0,0), (0,1,0) and + * (0,0,1) plus an encoding value that is used to encode the linear + * components R, G and B to give the actual values R^gamma, G^gamma and + * B^gamma that are stored. + */ + double gamma; /* Encoding (file) gamma of space */ + CIE_color red, green, blue; /* End points */ +} color_encoding; + +#ifdef PNG_READ_SUPPORTED +#if defined PNG_READ_TRANSFORMS_SUPPORTED && defined PNG_READ_cHRM_SUPPORTED +static double +chromaticity_x(CIE_color c) +{ + return c.X / (c.X + c.Y + c.Z); +} + +static double +chromaticity_y(CIE_color c) +{ + return c.Y / (c.X + c.Y + c.Z); +} + +static CIE_color +white_point(const color_encoding *encoding) +{ + CIE_color white; + + white.X = encoding->red.X + encoding->green.X + encoding->blue.X; + white.Y = encoding->red.Y + encoding->green.Y + encoding->blue.Y; + white.Z = encoding->red.Z + encoding->green.Z + encoding->blue.Z; + + return white; +} +#endif /* READ_TRANSFORMS && READ_cHRM */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +static void +normalize_color_encoding(color_encoding *encoding) +{ + const double whiteY = encoding->red.Y + encoding->green.Y + + encoding->blue.Y; + + if (whiteY != 1) + { + encoding->red.X /= whiteY; + encoding->red.Y /= whiteY; + encoding->red.Z /= whiteY; + encoding->green.X /= whiteY; + encoding->green.Y /= whiteY; + encoding->green.Z /= whiteY; + encoding->blue.X /= whiteY; + encoding->blue.Y /= whiteY; + encoding->blue.Z /= whiteY; + } +} +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static size_t +safecat_color_encoding(char *buffer, size_t bufsize, size_t pos, + const color_encoding *e, double encoding_gamma) +{ + if (e != 0) + { + if (encoding_gamma != 0) + pos = safecat(buffer, bufsize, pos, "("); + pos = safecat(buffer, bufsize, pos, "R("); + pos = safecatd(buffer, bufsize, pos, e->red.X, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->red.Y, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->red.Z, 4); + pos = safecat(buffer, bufsize, pos, "),G("); + pos = safecatd(buffer, bufsize, pos, e->green.X, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->green.Y, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->green.Z, 4); + pos = safecat(buffer, bufsize, pos, "),B("); + pos = safecatd(buffer, bufsize, pos, e->blue.X, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->blue.Y, 4); + pos = safecat(buffer, bufsize, pos, ","); + pos = safecatd(buffer, bufsize, pos, e->blue.Z, 4); + pos = safecat(buffer, bufsize, pos, ")"); + if (encoding_gamma != 0) + pos = safecat(buffer, bufsize, pos, ")"); + } + + if (encoding_gamma != 0) + { + pos = safecat(buffer, bufsize, pos, "^"); + pos = safecatd(buffer, bufsize, pos, encoding_gamma, 5); + } + + return pos; +} +#endif /* READ_TRANSFORMS */ +#endif /* PNG_READ_SUPPORTED */ + +typedef struct png_modifier +{ + png_store this; /* I am a png_store */ + struct png_modification *modifications; /* Changes to make */ + + modifier_state state; /* My state */ + + /* Information from IHDR: */ + png_byte bit_depth; /* From IHDR */ + png_byte colour_type; /* From IHDR */ + + /* While handling PLTE, IDAT and IEND these chunks may be pended to allow + * other chunks to be inserted. + */ + png_uint_32 pending_len; + png_uint_32 pending_chunk; + + /* Test values */ + double *gammas; + unsigned int ngammas; + unsigned int ngamma_tests; /* Number of gamma tests to run*/ + double current_gamma; /* 0 if not set */ + const color_encoding *encodings; + unsigned int nencodings; + const color_encoding *current_encoding; /* If an encoding has been set */ + unsigned int encoding_counter; /* For iteration */ + int encoding_ignored; /* Something overwrote it */ + + /* Control variables used to iterate through possible encodings, the + * following must be set to 0 and tested by the function that uses the + * png_modifier because the modifier only sets it to 1 (true.) + */ + unsigned int repeat :1; /* Repeat this transform test. */ + unsigned int test_uses_encoding :1; + + /* Lowest sbit to test (pre-1.7 libpng fails for sbit < 8) */ + png_byte sbitlow; + + /* Error control - these are the limits on errors accepted by the gamma tests + * below. + */ + double maxout8; /* Maximum output value error */ + double maxabs8; /* Absolute sample error 0..1 */ + double maxcalc8; /* Absolute sample error 0..1 */ + double maxpc8; /* Percentage sample error 0..100% */ + double maxout16; /* Maximum output value error */ + double maxabs16; /* Absolute sample error 0..1 */ + double maxcalc16;/* Absolute sample error 0..1 */ + double maxcalcG; /* Absolute sample error 0..1 */ + double maxpc16; /* Percentage sample error 0..100% */ + + /* This is set by transforms that need to allow a higher limit, it is an + * internal check on pngvalid to ensure that the calculated error limits are + * not ridiculous; without this it is too easy to make a mistake in pngvalid + * that allows any value through. + * + * NOTE: this is not checked in release builds. + */ + double limit; /* limit on error values, normally 4E-3 */ + + /* Log limits - values above this are logged, but not necessarily + * warned. + */ + double log8; /* Absolute error in 8 bits to log */ + double log16; /* Absolute error in 16 bits to log */ + + /* Logged 8 and 16 bit errors ('output' values): */ + double error_gray_2; + double error_gray_4; + double error_gray_8; + double error_gray_16; + double error_color_8; + double error_color_16; + double error_indexed; + + /* Flags: */ + /* Whether to call png_read_update_info, not png_read_start_image, and how + * many times to call it. + */ + int use_update_info; + + /* Whether or not to interlace. */ + int interlace_type :9; /* int, but must store '1' */ + + /* Run the standard tests? */ + unsigned int test_standard :1; + + /* Run the odd-sized image and interlace read/write tests? */ + unsigned int test_size :1; + + /* Run tests on reading with a combination of transforms, */ + unsigned int test_transform :1; + unsigned int test_tRNS :1; /* Includes tRNS images */ + + /* When to use the use_input_precision option, this controls the gamma + * validation code checks. If set any value that is within the transformed + * range input-.5 to input+.5 will be accepted, otherwise the value must be + * within the normal limits. It should not be necessary to set this; the + * result should always be exact within the permitted error limits. + */ + unsigned int use_input_precision :1; + unsigned int use_input_precision_sbit :1; + unsigned int use_input_precision_16to8 :1; + + /* If set assume that the calculation bit depth is set by the input + * precision, not the output precision. + */ + unsigned int calculations_use_input_precision :1; + + /* If set assume that the calculations are done in 16 bits even if the sample + * depth is 8 bits. + */ + unsigned int assume_16_bit_calculations :1; + + /* Which gamma tests to run: */ + unsigned int test_gamma_threshold :1; + unsigned int test_gamma_transform :1; /* main tests */ + unsigned int test_gamma_sbit :1; + unsigned int test_gamma_scale16 :1; + unsigned int test_gamma_background :1; + unsigned int test_gamma_alpha_mode :1; + unsigned int test_gamma_expand16 :1; + unsigned int test_exhaustive :1; + + /* Whether or not to run the low-bit-depth grayscale tests. This fails on + * gamma images in some cases because of gross inaccuracies in the grayscale + * gamma handling for low bit depth. + */ + unsigned int test_lbg :1; + unsigned int test_lbg_gamma_threshold :1; + unsigned int test_lbg_gamma_transform :1; + unsigned int test_lbg_gamma_sbit :1; + unsigned int test_lbg_gamma_composition :1; + + unsigned int log :1; /* Log max error */ + + /* Buffer information, the buffer size limits the size of the chunks that can + * be modified - they must fit (including header and CRC) into the buffer! + */ + size_t flush; /* Count of bytes to flush */ + size_t buffer_count; /* Bytes in buffer */ + size_t buffer_position; /* Position in buffer */ + png_byte buffer[1024]; +} png_modifier; + +/* This returns true if the test should be stopped now because it has already + * failed and it is running silently. + */ +static int fail(png_modifier *pm) +{ + return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 || + (pm->this.treat_warnings_as_errors && pm->this.nwarnings > 0)); +} + +static void +modifier_init(png_modifier *pm) +{ + memset(pm, 0, sizeof *pm); + store_init(&pm->this); + pm->modifications = NULL; + pm->state = modifier_start; + pm->sbitlow = 1U; + pm->ngammas = 0; + pm->ngamma_tests = 0; + pm->gammas = 0; + pm->current_gamma = 0; + pm->encodings = 0; + pm->nencodings = 0; + pm->current_encoding = 0; + pm->encoding_counter = 0; + pm->encoding_ignored = 0; + pm->repeat = 0; + pm->test_uses_encoding = 0; + pm->maxout8 = pm->maxpc8 = pm->maxabs8 = pm->maxcalc8 = 0; + pm->maxout16 = pm->maxpc16 = pm->maxabs16 = pm->maxcalc16 = 0; + pm->maxcalcG = 0; + pm->limit = 4E-3; + pm->log8 = pm->log16 = 0; /* Means 'off' */ + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0; + pm->error_gray_16 = pm->error_color_8 = pm->error_color_16 = 0; + pm->error_indexed = 0; + pm->use_update_info = 0; + pm->interlace_type = PNG_INTERLACE_NONE; + pm->test_standard = 0; + pm->test_size = 0; + pm->test_transform = 0; +# ifdef PNG_WRITE_tRNS_SUPPORTED + pm->test_tRNS = 1; +# else + pm->test_tRNS = 0; +# endif + pm->use_input_precision = 0; + pm->use_input_precision_sbit = 0; + pm->use_input_precision_16to8 = 0; + pm->calculations_use_input_precision = 0; + pm->assume_16_bit_calculations = 0; + pm->test_gamma_threshold = 0; + pm->test_gamma_transform = 0; + pm->test_gamma_sbit = 0; + pm->test_gamma_scale16 = 0; + pm->test_gamma_background = 0; + pm->test_gamma_alpha_mode = 0; + pm->test_gamma_expand16 = 0; + pm->test_lbg = 1; + pm->test_lbg_gamma_threshold = 1; + pm->test_lbg_gamma_transform = 1; + pm->test_lbg_gamma_sbit = 1; + pm->test_lbg_gamma_composition = 1; + pm->test_exhaustive = 0; + pm->log = 0; + + /* Rely on the memset for all the other fields - there are no pointers */ +} + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + +/* This controls use of checks that explicitly know how libpng digitizes the + * samples in calculations; setting this circumvents simple error limit checking + * in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5 + * algorithm. + */ +#define DIGITIZE PNG_LIBPNG_VER < 10700 + +/* If pm->calculations_use_input_precision is set then operations will happen + * with the precision of the input, not the precision of the output depth. + * + * If pm->assume_16_bit_calculations is set then even 8 bit calculations use 16 + * bit precision. This only affects those of the following limits that pertain + * to a calculation - not a digitization operation - unless the following API is + * called directly. + */ +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +#if DIGITIZE +static double digitize(double value, int depth, int do_round) +{ + /* 'value' is in the range 0 to 1, the result is the same value rounded to a + * multiple of the digitization factor - 8 or 16 bits depending on both the + * sample depth and the 'assume' setting. Digitization is normally by + * rounding and 'do_round' should be 1, if it is 0 the digitized value will + * be truncated. + */ + unsigned int digitization_factor = (1U << depth) - 1; + + /* Limiting the range is done as a convenience to the caller - it's easier to + * do it once here than every time at the call site. + */ + if (value <= 0) + value = 0; + + else if (value >= 1) + value = 1; + + value *= digitization_factor; + if (do_round) value += .5; + return floor(value)/digitization_factor; +} +#endif +#endif /* RGB_TO_GRAY */ + +#ifdef PNG_READ_GAMMA_SUPPORTED +static double abserr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* Absolute error permitted in linear values - affected by the bit depth of + * the calculations. + */ + if (pm->assume_16_bit_calculations || + (pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxabs16; + else + return pm->maxabs8; +} + +static double calcerr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* Error in the linear composition arithmetic - only relevant when + * composition actually happens (0 < alpha < 1). + */ + if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxcalc16; + else if (pm->assume_16_bit_calculations) + return pm->maxcalcG; + else + return pm->maxcalc8; +} + +static double pcerr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* Percentage error permitted in the linear values. Note that the specified + * value is a percentage but this routine returns a simple number. + */ + if (pm->assume_16_bit_calculations || + (pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxpc16 * .01; + else + return pm->maxpc8 * .01; +} + +/* Output error - the error in the encoded value. This is determined by the + * digitization of the output so can be +/-0.5 in the actual output value. In + * the expand_16 case with the current code in libpng the expand happens after + * all the calculations are done in 8 bit arithmetic, so even though the output + * depth is 16 the output error is determined by the 8 bit calculation. + * + * This limit is not determined by the bit depth of internal calculations. + * + * The specified parameter does *not* include the base .5 digitization error but + * it is added here. + */ +static double outerr(const png_modifier *pm, int in_depth, int out_depth) +{ + /* There is a serious error in the 2 and 4 bit grayscale transform because + * the gamma table value (8 bits) is simply shifted, not rounded, so the + * error in 4 bit grayscale gamma is up to the value below. This is a hack + * to allow pngvalid to succeed: + * + * TODO: fix this in libpng + */ + if (out_depth == 2) + return .73182-.5; + + if (out_depth == 4) + return .90644-.5; + + if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + return pm->maxout16; + + /* This is the case where the value was calculated at 8-bit precision then + * scaled to 16 bits. + */ + else if (out_depth == 16) + return pm->maxout8 * 257; + + else + return pm->maxout8; +} + +/* This does the same thing as the above however it returns the value to log, + * rather than raising a warning. This is useful for debugging to track down + * exactly what set of parameters cause high error values. + */ +static double outlog(const png_modifier *pm, int in_depth, int out_depth) +{ + /* The command line parameters are either 8 bit (0..255) or 16 bit (0..65535) + * and so must be adjusted for low bit depth grayscale: + */ + if (out_depth <= 8) + { + if (pm->log8 == 0) /* switched off */ + return 256; + + if (out_depth < 8) + return pm->log8 / 255 * ((1<log8; + } + + if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16) + { + if (pm->log16 == 0) + return 65536; + + return pm->log16; + } + + /* This is the case where the value was calculated at 8-bit precision then + * scaled to 16 bits. + */ + if (pm->log8 == 0) + return 65536; + + return pm->log8 * 257; +} + +/* This complements the above by providing the appropriate quantization for the + * final value. Normally this would just be quantization to an integral value, + * but in the 8 bit calculation case it's actually quantization to a multiple of + * 257! + */ +static int output_quantization_factor(const png_modifier *pm, int in_depth, + int out_depth) +{ + if (out_depth == 16 && in_depth != 16 && + pm->calculations_use_input_precision) + return 257; + else + return 1; +} +#endif /* PNG_READ_GAMMA_SUPPORTED */ + +/* One modification structure must be provided for each chunk to be modified (in + * fact more than one can be provided if multiple separate changes are desired + * for a single chunk.) Modifications include adding a new chunk when a + * suitable chunk does not exist. + * + * The caller of modify_fn will reset the CRC of the chunk and record 'modified' + * or 'added' as appropriate if the modify_fn returns 1 (true). If the + * modify_fn is NULL the chunk is simply removed. + */ +typedef struct png_modification +{ + struct png_modification *next; + png_uint_32 chunk; + + /* If the following is NULL all matching chunks will be removed: */ + int (*modify_fn)(struct png_modifier *pm, + struct png_modification *me, int add); + + /* If the following is set to PLTE, IDAT or IEND and the chunk has not been + * found and modified (and there is a modify_fn) the modify_fn will be called + * to add the chunk before the relevant chunk. + */ + png_uint_32 add; + unsigned int modified :1; /* Chunk was modified */ + unsigned int added :1; /* Chunk was added */ + unsigned int removed :1; /* Chunk was removed */ +} png_modification; + +static void +modification_reset(png_modification *pmm) +{ + if (pmm != NULL) + { + pmm->modified = 0; + pmm->added = 0; + pmm->removed = 0; + modification_reset(pmm->next); + } +} + +static void +modification_init(png_modification *pmm) +{ + memset(pmm, 0, sizeof *pmm); + pmm->next = NULL; + pmm->chunk = 0; + pmm->modify_fn = NULL; + pmm->add = 0; + modification_reset(pmm); +} + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +static void +modifier_current_encoding(const png_modifier *pm, color_encoding *ce) +{ + if (pm->current_encoding != 0) + *ce = *pm->current_encoding; + + else + memset(ce, 0, sizeof *ce); + + ce->gamma = pm->current_gamma; +} +#endif + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +static size_t +safecat_current_encoding(char *buffer, size_t bufsize, size_t pos, + const png_modifier *pm) +{ + pos = safecat_color_encoding(buffer, bufsize, pos, pm->current_encoding, + pm->current_gamma); + + if (pm->encoding_ignored) + pos = safecat(buffer, bufsize, pos, "[overridden]"); + + return pos; +} +#endif + +/* Iterate through the usefully testable color encodings. An encoding is one + * of: + * + * 1) Nothing (no color space, no gamma). + * 2) Just a gamma value from the gamma array (including 1.0) + * 3) A color space from the encodings array with the corresponding gamma. + * 4) The same, but with gamma 1.0 (only really useful with 16 bit calculations) + * + * The iterator selects these in turn, the randomizer selects one at random, + * which is used depends on the setting of the 'test_exhaustive' flag. Notice + * that this function changes the colour space encoding so it must only be + * called on completion of the previous test. This is what 'modifier_reset' + * does, below. + * + * After the function has been called the 'repeat' flag will still be set; the + * caller of modifier_reset must reset it at the start of each run of the test! + */ +static unsigned int +modifier_total_encodings(const png_modifier *pm) +{ + return 1 + /* (1) nothing */ + pm->ngammas + /* (2) gamma values to test */ + pm->nencodings + /* (3) total number of encodings */ + /* The following test only works after the first time through the + * png_modifier code because 'bit_depth' is set when the IHDR is read. + * modifier_reset, below, preserves the setting until after it has called + * the iterate function (also below.) + * + * For this reason do not rely on this function outside a call to + * modifier_reset. + */ + ((pm->bit_depth == 16 || pm->assume_16_bit_calculations) ? + pm->nencodings : 0); /* (4) encodings with gamma == 1.0 */ +} + +static void +modifier_encoding_iterate(png_modifier *pm) +{ + if (!pm->repeat && /* Else something needs the current encoding again. */ + pm->test_uses_encoding) /* Some transform is encoding dependent */ + { + if (pm->test_exhaustive) + { + if (++pm->encoding_counter >= modifier_total_encodings(pm)) + pm->encoding_counter = 0; /* This will stop the repeat */ + } + + else + { + /* Not exhaustive - choose an encoding at random; generate a number in + * the range 1..(max-1), so the result is always non-zero: + */ + if (pm->encoding_counter == 0) + pm->encoding_counter = random_mod(modifier_total_encodings(pm)-1)+1; + else + pm->encoding_counter = 0; + } + + if (pm->encoding_counter > 0) + pm->repeat = 1; + } + + else if (!pm->repeat) + pm->encoding_counter = 0; +} + +static void +modifier_reset(png_modifier *pm) +{ + store_read_reset(&pm->this); + pm->limit = 4E-3; + pm->pending_len = pm->pending_chunk = 0; + pm->flush = pm->buffer_count = pm->buffer_position = 0; + pm->modifications = NULL; + pm->state = modifier_start; + modifier_encoding_iterate(pm); + /* The following must be set in the next run. In particular + * test_uses_encodings must be set in the _ini function of each transform + * that looks at the encodings. (Not the 'add' function!) + */ + pm->test_uses_encoding = 0; + pm->current_gamma = 0; + pm->current_encoding = 0; + pm->encoding_ignored = 0; + /* These only become value after IHDR is read: */ + pm->bit_depth = pm->colour_type = 0; +} + +/* The following must be called before anything else to get the encoding set up + * on the modifier. In particular it must be called before the transform init + * functions are called. + */ +static void +modifier_set_encoding(png_modifier *pm) +{ + /* Set the encoding to the one specified by the current encoding counter, + * first clear out all the settings - this corresponds to an encoding_counter + * of 0. + */ + pm->current_gamma = 0; + pm->current_encoding = 0; + pm->encoding_ignored = 0; /* not ignored yet - happens in _ini functions. */ + + /* Now, if required, set the gamma and encoding fields. */ + if (pm->encoding_counter > 0) + { + /* The gammas[] array is an array of screen gammas, not encoding gammas, + * so we need the inverse: + */ + if (pm->encoding_counter <= pm->ngammas) + pm->current_gamma = 1/pm->gammas[pm->encoding_counter-1]; + + else + { + unsigned int i = pm->encoding_counter - pm->ngammas; + + if (i >= pm->nencodings) + { + i %= pm->nencodings; + pm->current_gamma = 1; /* Linear, only in the 16 bit case */ + } + + else + pm->current_gamma = pm->encodings[i].gamma; + + pm->current_encoding = pm->encodings + i; + } + } +} + +/* Enquiry functions to find out what is set. Notice that there is an implicit + * assumption below that the first encoding in the list is the one for sRGB. + */ +static int +modifier_color_encoding_is_sRGB(const png_modifier *pm) +{ + return pm->current_encoding != 0 && pm->current_encoding == pm->encodings && + pm->current_encoding->gamma == pm->current_gamma; +} + +static int +modifier_color_encoding_is_set(const png_modifier *pm) +{ + return pm->current_gamma != 0; +} + +/* The guts of modification are performed during a read. */ +static void +modifier_crc(png_bytep buffer) +{ + /* Recalculate the chunk CRC - a complete chunk must be in + * the buffer, at the start. + */ + uInt datalen = png_get_uint_32(buffer); + uLong crc = crc32(0, buffer+4, datalen+4); + /* The cast to png_uint_32 is safe because a crc32 is always a 32 bit value. + */ + png_save_uint_32(buffer+datalen+8, (png_uint_32)crc); +} + +static void +modifier_setbuffer(png_modifier *pm) +{ + modifier_crc(pm->buffer); + pm->buffer_count = png_get_uint_32(pm->buffer)+12; + pm->buffer_position = 0; +} + +/* Separate the callback into the actual implementation (which is passed the + * png_modifier explicitly) and the callback, which gets the modifier from the + * png_struct. + */ +static void +modifier_read_imp(png_modifier *pm, png_bytep pb, size_t st) +{ + while (st > 0) + { + size_t cb; + png_uint_32 len, chunk; + png_modification *mod; + + if (pm->buffer_position >= pm->buffer_count) switch (pm->state) + { + static png_byte sign[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; + case modifier_start: + store_read_chunk(&pm->this, pm->buffer, 8, 8); /* signature. */ + pm->buffer_count = 8; + pm->buffer_position = 0; + + if (memcmp(pm->buffer, sign, 8) != 0) + png_error(pm->this.pread, "invalid PNG file signature"); + pm->state = modifier_signature; + break; + + case modifier_signature: + store_read_chunk(&pm->this, pm->buffer, 13+12, 13+12); /* IHDR */ + pm->buffer_count = 13+12; + pm->buffer_position = 0; + + if (png_get_uint_32(pm->buffer) != 13 || + png_get_uint_32(pm->buffer+4) != CHUNK_IHDR) + png_error(pm->this.pread, "invalid IHDR"); + + /* Check the list of modifiers for modifications to the IHDR. */ + mod = pm->modifications; + while (mod != NULL) + { + if (mod->chunk == CHUNK_IHDR && mod->modify_fn && + (*mod->modify_fn)(pm, mod, 0)) + { + mod->modified = 1; + modifier_setbuffer(pm); + } + + /* Ignore removal or add if IHDR! */ + mod = mod->next; + } + + /* Cache information from the IHDR (the modified one.) */ + pm->bit_depth = pm->buffer[8+8]; + pm->colour_type = pm->buffer[8+8+1]; + + pm->state = modifier_IHDR; + pm->flush = 0; + break; + + case modifier_IHDR: + default: + /* Read a new chunk and process it until we see PLTE, IDAT or + * IEND. 'flush' indicates that there is still some data to + * output from the preceding chunk. + */ + if ((cb = pm->flush) > 0) + { + if (cb > st) cb = st; + pm->flush -= cb; + store_read_chunk(&pm->this, pb, cb, cb); + pb += cb; + st -= cb; + if (st == 0) return; + } + + /* No more bytes to flush, read a header, or handle a pending + * chunk. + */ + if (pm->pending_chunk != 0) + { + png_save_uint_32(pm->buffer, pm->pending_len); + png_save_uint_32(pm->buffer+4, pm->pending_chunk); + pm->pending_len = 0; + pm->pending_chunk = 0; + } + else + store_read_chunk(&pm->this, pm->buffer, 8, 8); + + pm->buffer_count = 8; + pm->buffer_position = 0; + + /* Check for something to modify or a terminator chunk. */ + len = png_get_uint_32(pm->buffer); + chunk = png_get_uint_32(pm->buffer+4); + + /* Terminators first, they may have to be delayed for added + * chunks + */ + if (chunk == CHUNK_PLTE || chunk == CHUNK_IDAT || + chunk == CHUNK_IEND) + { + mod = pm->modifications; + + while (mod != NULL) + { + if ((mod->add == chunk || + (mod->add == CHUNK_PLTE && chunk == CHUNK_IDAT)) && + mod->modify_fn != NULL && !mod->modified && !mod->added) + { + /* Regardless of what the modify function does do not run + * this again. + */ + mod->added = 1; + + if ((*mod->modify_fn)(pm, mod, 1 /*add*/)) + { + /* Reset the CRC on a new chunk */ + if (pm->buffer_count > 0) + modifier_setbuffer(pm); + + else + { + pm->buffer_position = 0; + mod->removed = 1; + } + + /* The buffer has been filled with something (we assume) + * so output this. Pend the current chunk. + */ + pm->pending_len = len; + pm->pending_chunk = chunk; + break; /* out of while */ + } + } + + mod = mod->next; + } + + /* Don't do any further processing if the buffer was modified - + * otherwise the code will end up modifying a chunk that was + * just added. + */ + if (mod != NULL) + break; /* out of switch */ + } + + /* If we get to here then this chunk may need to be modified. To + * do this it must be less than 1024 bytes in total size, otherwise + * it just gets flushed. + */ + if (len+12 <= sizeof pm->buffer) + { + size_t s = len+12-pm->buffer_count; + store_read_chunk(&pm->this, pm->buffer+pm->buffer_count, s, s); + pm->buffer_count = len+12; + + /* Check for a modification, else leave it be. */ + mod = pm->modifications; + while (mod != NULL) + { + if (mod->chunk == chunk) + { + if (mod->modify_fn == NULL) + { + /* Remove this chunk */ + pm->buffer_count = pm->buffer_position = 0; + mod->removed = 1; + break; /* Terminate the while loop */ + } + + else if ((*mod->modify_fn)(pm, mod, 0)) + { + mod->modified = 1; + /* The chunk may have been removed: */ + if (pm->buffer_count == 0) + { + pm->buffer_position = 0; + break; + } + modifier_setbuffer(pm); + } + } + + mod = mod->next; + } + } + + else + pm->flush = len+12 - pm->buffer_count; /* data + crc */ + + /* Take the data from the buffer (if there is any). */ + break; + } + + /* Here to read from the modifier buffer (not directly from + * the store, as in the flush case above.) + */ + cb = pm->buffer_count - pm->buffer_position; + + if (cb > st) + cb = st; + + memcpy(pb, pm->buffer + pm->buffer_position, cb); + st -= cb; + pb += cb; + pm->buffer_position += cb; + } +} + +/* The callback: */ +static void PNGCBAPI +modifier_read(png_structp ppIn, png_bytep pb, size_t st) +{ + png_const_structp pp = ppIn; + png_modifier *pm = voidcast(png_modifier*, png_get_io_ptr(pp)); + + if (pm == NULL || pm->this.pread != pp) + png_error(pp, "bad modifier_read call"); + + modifier_read_imp(pm, pb, st); +} + +/* Like store_progressive_read but the data is getting changed as we go so we + * need a local buffer. + */ +static void +modifier_progressive_read(png_modifier *pm, png_structp pp, png_infop pi) +{ + if (pm->this.pread != pp || pm->this.current == NULL || + pm->this.next == NULL) + png_error(pp, "store state damaged (progressive)"); + + /* This is another Horowitz and Hill random noise generator. In this case + * the aim is to stress the progressive reader with truly horrible variable + * buffer sizes in the range 1..500, so a sequence of 9 bit random numbers + * is generated. We could probably just count from 1 to 32767 and get as + * good a result. + */ + for (;;) + { + static png_uint_32 noise = 1; + size_t cb, cbAvail; + png_byte buffer[512]; + + /* Generate 15 more bits of stuff: */ + noise = (noise << 9) | ((noise ^ (noise >> (9-5))) & 0x1ff); + cb = noise & 0x1ff; + + /* Check that this number of bytes are available (in the current buffer.) + * (This doesn't quite work - the modifier might delete a chunk; unlikely + * but possible, it doesn't happen at present because the modifier only + * adds chunks to standard images.) + */ + cbAvail = store_read_buffer_avail(&pm->this); + if (pm->buffer_count > pm->buffer_position) + cbAvail += pm->buffer_count - pm->buffer_position; + + if (cb > cbAvail) + { + /* Check for EOF: */ + if (cbAvail == 0) + break; + + cb = cbAvail; + } + + modifier_read_imp(pm, buffer, cb); + png_process_data(pp, pi, buffer, cb); + } + + /* Check the invariants at the end (if this fails it's a problem in this + * file!) + */ + if (pm->buffer_count > pm->buffer_position || + pm->this.next != &pm->this.current->data || + pm->this.readpos < pm->this.current->datacount) + png_error(pp, "progressive read implementation error"); +} + +/* Set up a modifier. */ +static png_structp +set_modifier_for_read(png_modifier *pm, png_infopp ppi, png_uint_32 id, + const char *name) +{ + /* Do this first so that the modifier fields are cleared even if an error + * happens allocating the png_struct. No allocation is done here so no + * cleanup is required. + */ + pm->state = modifier_start; + pm->bit_depth = 0; + pm->colour_type = 255; + + pm->pending_len = 0; + pm->pending_chunk = 0; + pm->flush = 0; + pm->buffer_count = 0; + pm->buffer_position = 0; + + return set_store_for_read(&pm->this, ppi, id, name); +} + + +/******************************** MODIFICATIONS *******************************/ +/* Standard modifications to add chunks. These do not require the _SUPPORTED + * macros because the chunks can be there regardless of whether this specific + * libpng supports them. + */ +typedef struct gama_modification +{ + png_modification this; + png_fixed_point gamma; +} gama_modification; + +static int +gama_modify(png_modifier *pm, png_modification *me, int add) +{ + UNUSED(add) + /* This simply dumps the given gamma value into the buffer. */ + png_save_uint_32(pm->buffer, 4); + png_save_uint_32(pm->buffer+4, CHUNK_gAMA); + png_save_uint_32(pm->buffer+8, ((gama_modification*)me)->gamma); + return 1; +} + +static void +gama_modification_init(gama_modification *me, png_modifier *pm, double gammad) +{ + double g; + + modification_init(&me->this); + me->this.chunk = CHUNK_gAMA; + me->this.modify_fn = gama_modify; + me->this.add = CHUNK_PLTE; + g = fix(gammad); + me->gamma = (png_fixed_point)g; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +typedef struct chrm_modification +{ + png_modification this; + const color_encoding *encoding; + png_fixed_point wx, wy, rx, ry, gx, gy, bx, by; +} chrm_modification; + +static int +chrm_modify(png_modifier *pm, png_modification *me, int add) +{ + UNUSED(add) + /* As with gAMA this just adds the required cHRM chunk to the buffer. */ + png_save_uint_32(pm->buffer , 32); + png_save_uint_32(pm->buffer+ 4, CHUNK_cHRM); + png_save_uint_32(pm->buffer+ 8, ((chrm_modification*)me)->wx); + png_save_uint_32(pm->buffer+12, ((chrm_modification*)me)->wy); + png_save_uint_32(pm->buffer+16, ((chrm_modification*)me)->rx); + png_save_uint_32(pm->buffer+20, ((chrm_modification*)me)->ry); + png_save_uint_32(pm->buffer+24, ((chrm_modification*)me)->gx); + png_save_uint_32(pm->buffer+28, ((chrm_modification*)me)->gy); + png_save_uint_32(pm->buffer+32, ((chrm_modification*)me)->bx); + png_save_uint_32(pm->buffer+36, ((chrm_modification*)me)->by); + return 1; +} + +static void +chrm_modification_init(chrm_modification *me, png_modifier *pm, + const color_encoding *encoding) +{ + CIE_color white = white_point(encoding); + + /* Original end points: */ + me->encoding = encoding; + + /* Chromaticities (in fixed point): */ + me->wx = fix(chromaticity_x(white)); + me->wy = fix(chromaticity_y(white)); + + me->rx = fix(chromaticity_x(encoding->red)); + me->ry = fix(chromaticity_y(encoding->red)); + me->gx = fix(chromaticity_x(encoding->green)); + me->gy = fix(chromaticity_y(encoding->green)); + me->bx = fix(chromaticity_x(encoding->blue)); + me->by = fix(chromaticity_y(encoding->blue)); + + modification_init(&me->this); + me->this.chunk = CHUNK_cHRM; + me->this.modify_fn = chrm_modify; + me->this.add = CHUNK_PLTE; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +typedef struct srgb_modification +{ + png_modification this; + png_byte intent; +} srgb_modification; + +static int +srgb_modify(png_modifier *pm, png_modification *me, int add) +{ + UNUSED(add) + /* As above, ignore add and just make a new chunk */ + png_save_uint_32(pm->buffer, 1); + png_save_uint_32(pm->buffer+4, CHUNK_sRGB); + pm->buffer[8] = ((srgb_modification*)me)->intent; + return 1; +} + +static void +srgb_modification_init(srgb_modification *me, png_modifier *pm, png_byte intent) +{ + modification_init(&me->this); + me->this.chunk = CHUNK_sBIT; + + if (intent <= 3) /* if valid, else *delete* sRGB chunks */ + { + me->this.modify_fn = srgb_modify; + me->this.add = CHUNK_PLTE; + me->intent = intent; + } + + else + { + me->this.modify_fn = 0; + me->this.add = 0; + me->intent = 0; + } + + me->this.next = pm->modifications; + pm->modifications = &me->this; +} + +#ifdef PNG_READ_GAMMA_SUPPORTED +typedef struct sbit_modification +{ + png_modification this; + png_byte sbit; +} sbit_modification; + +static int +sbit_modify(png_modifier *pm, png_modification *me, int add) +{ + png_byte sbit = ((sbit_modification*)me)->sbit; + if (pm->bit_depth > sbit) + { + int cb = 0; + switch (pm->colour_type) + { + case 0: + cb = 1; + break; + + case 2: + case 3: + cb = 3; + break; + + case 4: + cb = 2; + break; + + case 6: + cb = 4; + break; + + default: + png_error(pm->this.pread, + "unexpected colour type in sBIT modification"); + } + + png_save_uint_32(pm->buffer, cb); + png_save_uint_32(pm->buffer+4, CHUNK_sBIT); + + while (cb > 0) + (pm->buffer+8)[--cb] = sbit; + + return 1; + } + else if (!add) + { + /* Remove the sBIT chunk */ + pm->buffer_count = pm->buffer_position = 0; + return 1; + } + else + return 0; /* do nothing */ +} + +static void +sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit) +{ + modification_init(&me->this); + me->this.chunk = CHUNK_sBIT; + me->this.modify_fn = sbit_modify; + me->this.add = CHUNK_PLTE; + me->sbit = sbit; + me->this.next = pm->modifications; + pm->modifications = &me->this; +} +#endif /* PNG_READ_GAMMA_SUPPORTED */ +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +/***************************** STANDARD PNG FILES *****************************/ +/* Standard files - write and save standard files. */ +/* There are two basic forms of standard images. Those which attempt to have + * all the possible pixel values (not possible for 16bpp images, but a range of + * values are produced) and those which have a range of image sizes. The former + * are used for testing transforms, in particular gamma correction and bit + * reduction and increase. The latter are reserved for testing the behavior of + * libpng with respect to 'odd' image sizes - particularly small images where + * rows become 1 byte and interlace passes disappear. + * + * The first, most useful, set are the 'transform' images, the second set of + * small images are the 'size' images. + * + * The transform files are constructed with rows which fit into a 1024 byte row + * buffer. This makes allocation easier below. Further regardless of the file + * format every row has 128 pixels (giving 1024 bytes for 64bpp formats). + * + * Files are stored with no gAMA or sBIT chunks, with a PLTE only when needed + * and with an ID derived from the colour type, bit depth and interlace type + * as above (FILEID). The width (128) and height (variable) are not stored in + * the FILEID - instead the fields are set to 0, indicating a transform file. + * + * The size files ar constructed with rows a maximum of 128 bytes wide, allowing + * a maximum width of 16 pixels (for the 64bpp case.) They also have a maximum + * height of 16 rows. The width and height are stored in the FILEID and, being + * non-zero, indicate a size file. + * + * Because the PNG filter code is typically the largest CPU consumer within + * libpng itself there is a tendency to attempt to optimize it. This results in + * special case code which needs to be validated. To cause this to happen the + * 'size' images are made to use each possible filter, in so far as this is + * possible for smaller images. + * + * For palette image (colour type 3) multiple transform images are stored with + * the same bit depth to allow testing of more colour combinations - + * particularly important for testing the gamma code because libpng uses a + * different code path for palette images. For size images a single palette is + * used. + */ + +/* Make a 'standard' palette. Because there are only 256 entries in a palette + * (maximum) this actually makes a random palette in the hope that enough tests + * will catch enough errors. (Note that the same palette isn't produced every + * time for the same test - it depends on what previous tests have been run - + * but a given set of arguments to pngvalid will always produce the same palette + * at the same test! This is why pseudo-random number generators are useful for + * testing.) + * + * The store must be open for write when this is called, otherwise an internal + * error will occur. This routine contains its own magic number seed, so the + * palettes generated don't change if there are intervening errors (changing the + * calls to the store_mark seed.) + */ +static store_palette_entry * +make_standard_palette(png_store* ps, int npalette, int do_tRNS) +{ + static png_uint_32 palette_seed[2] = { 0x87654321, 9 }; + + int i = 0; + png_byte values[256][4]; + + /* Always put in black and white plus the six primary and secondary colors. + */ + for (; i<8; ++i) + { + values[i][1] = (png_byte)((i&1) ? 255U : 0U); + values[i][2] = (png_byte)((i&2) ? 255U : 0U); + values[i][3] = (png_byte)((i&4) ? 255U : 0U); + } + + /* Then add 62 grays (one quarter of the remaining 256 slots). */ + { + int j = 0; + png_byte random_bytes[4]; + png_byte need[256]; + + need[0] = 0; /*got black*/ + memset(need+1, 1, (sizeof need)-2); /*need these*/ + need[255] = 0; /*but not white*/ + + while (i<70) + { + png_byte b; + + if (j==0) + { + make_four_random_bytes(palette_seed, random_bytes); + j = 4; + } + + b = random_bytes[--j]; + if (need[b]) + { + values[i][1] = b; + values[i][2] = b; + values[i++][3] = b; + } + } + } + + /* Finally add 192 colors at random - don't worry about matches to things we + * already have, chance is less than 1/65536. Don't worry about grays, + * chance is the same, so we get a duplicate or extra gray less than 1 time + * in 170. + */ + for (; i<256; ++i) + make_four_random_bytes(palette_seed, values[i]); + + /* Fill in the alpha values in the first byte. Just use all possible values + * (0..255) in an apparently random order: + */ + { + store_palette_entry *palette; + png_byte selector[4]; + + make_four_random_bytes(palette_seed, selector); + + if (do_tRNS) + for (i=0; i<256; ++i) + values[i][0] = (png_byte)(i ^ selector[0]); + + else + for (i=0; i<256; ++i) + values[i][0] = 255; /* no transparency/tRNS chunk */ + + /* 'values' contains 256 ARGB values, but we only need 'npalette'. + * 'npalette' will always be a power of 2: 2, 4, 16 or 256. In the low + * bit depth cases select colors at random, else it is difficult to have + * a set of low bit depth palette test with any chance of a reasonable + * range of colors. Do this by randomly permuting values into the low + * 'npalette' entries using an XOR mask generated here. This also + * permutes the npalette == 256 case in a potentially useful way (there is + * no relationship between palette index and the color value therein!) + */ + palette = store_write_palette(ps, npalette); + + for (i=0; i 0) + png_set_tRNS(pp, pi, tRNS, j, 0/*color*/); +#endif + } +} + +#ifdef PNG_WRITE_tRNS_SUPPORTED +static void +set_random_tRNS(png_structp pp, png_infop pi, png_byte colour_type, + int bit_depth) +{ + /* To make this useful the tRNS color needs to match at least one pixel. + * Random values are fine for gray, including the 16-bit case where we know + * that the test image contains all the gray values. For RGB we need more + * method as only 65536 different RGB values are generated. + */ + png_color_16 tRNS; + png_uint_16 mask = (png_uint_16)((1U << bit_depth)-1); + + R8(tRNS); /* makes unset fields random */ + + if (colour_type & 2/*RGB*/) + { + if (bit_depth == 8) + { + tRNS.red = random_u16(); + tRNS.green = random_u16(); + tRNS.blue = tRNS.red ^ tRNS.green; + tRNS.red &= mask; + tRNS.green &= mask; + tRNS.blue &= mask; + } + + else /* bit_depth == 16 */ + { + tRNS.red = random_u16(); + tRNS.green = (png_uint_16)(tRNS.red * 257); + tRNS.blue = (png_uint_16)(tRNS.green * 17); + } + } + + else + { + tRNS.gray = random_u16(); + tRNS.gray &= mask; + } + + png_set_tRNS(pp, pi, NULL, 0, &tRNS); +} +#endif + +/* The number of passes is related to the interlace type. There was no libpng + * API to determine this prior to 1.5, so we need an inquiry function: + */ +static int +npasses_from_interlace_type(png_const_structp pp, int interlace_type) +{ + switch (interlace_type) + { + default: + png_error(pp, "invalid interlace type"); + + case PNG_INTERLACE_NONE: + return 1; + + case PNG_INTERLACE_ADAM7: + return PNG_INTERLACE_ADAM7_PASSES; + } +} + +static unsigned int +bit_size(png_const_structp pp, png_byte colour_type, png_byte bit_depth) +{ + switch (colour_type) + { + default: png_error(pp, "invalid color type"); + + case 0: return bit_depth; + + case 2: return 3*bit_depth; + + case 3: return bit_depth; + + case 4: return 2*bit_depth; + + case 6: return 4*bit_depth; + } +} + +#define TRANSFORM_WIDTH 128U +#define TRANSFORM_ROWMAX (TRANSFORM_WIDTH*8U) +#define SIZE_ROWMAX (16*8U) /* 16 pixels, max 8 bytes each - 128 bytes */ +#define STANDARD_ROWMAX TRANSFORM_ROWMAX /* The larger of the two */ +#define SIZE_HEIGHTMAX 16 /* Maximum range of size images */ + +static size_t +transform_rowsize(png_const_structp pp, png_byte colour_type, + png_byte bit_depth) +{ + return (TRANSFORM_WIDTH * bit_size(pp, colour_type, bit_depth)) / 8; +} + +/* transform_width(pp, colour_type, bit_depth) current returns the same number + * every time, so just use a macro: + */ +#define transform_width(pp, colour_type, bit_depth) TRANSFORM_WIDTH + +static png_uint_32 +transform_height(png_const_structp pp, png_byte colour_type, png_byte bit_depth) +{ + switch (bit_size(pp, colour_type, bit_depth)) + { + case 1: + case 2: + case 4: + return 1; /* Total of 128 pixels */ + + case 8: + return 2; /* Total of 256 pixels/bytes */ + + case 16: + return 512; /* Total of 65536 pixels */ + + case 24: + case 32: + return 512; /* 65536 pixels */ + + case 48: + case 64: + return 2048;/* 4 x 65536 pixels. */ +# define TRANSFORM_HEIGHTMAX 2048 + + default: + return 0; /* Error, will be caught later */ + } +} + +#ifdef PNG_READ_SUPPORTED +/* The following can only be defined here, now we have the definitions + * of the transform image sizes. + */ +static png_uint_32 +standard_width(png_const_structp pp, png_uint_32 id) +{ + png_uint_32 width = WIDTH_FROM_ID(id); + UNUSED(pp) + + if (width == 0) + width = transform_width(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id)); + + return width; +} + +static png_uint_32 +standard_height(png_const_structp pp, png_uint_32 id) +{ + png_uint_32 height = HEIGHT_FROM_ID(id); + + if (height == 0) + height = transform_height(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id)); + + return height; +} + +static png_uint_32 +standard_rowsize(png_const_structp pp, png_uint_32 id) +{ + png_uint_32 width = standard_width(pp, id); + + /* This won't overflow: */ + width *= bit_size(pp, COL_FROM_ID(id), DEPTH_FROM_ID(id)); + return (width + 7) / 8; +} +#endif /* PNG_READ_SUPPORTED */ + +static void +transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX], + png_byte colour_type, png_byte bit_depth, png_uint_32 y) +{ + png_uint_32 v = y << 7; + png_uint_32 i = 0; + + switch (bit_size(pp, colour_type, bit_depth)) + { + case 1: + while (i<128/8) buffer[i] = (png_byte)(v & 0xff), v += 17, ++i; + return; + + case 2: + while (i<128/4) buffer[i] = (png_byte)(v & 0xff), v += 33, ++i; + return; + + case 4: + while (i<128/2) buffer[i] = (png_byte)(v & 0xff), v += 65, ++i; + return; + + case 8: + /* 256 bytes total, 128 bytes in each row set as follows: */ + while (i<128) buffer[i] = (png_byte)(v & 0xff), ++v, ++i; + return; + + case 16: + /* Generate all 65536 pixel values in order, which includes the 8 bit + * GA case as well as the 16 bit G case. + */ + while (i<128) + { + buffer[2*i] = (png_byte)((v>>8) & 0xff); + buffer[2*i+1] = (png_byte)(v & 0xff); + ++v; + ++i; + } + + return; + + case 24: + /* 65535 pixels, but rotate the values. */ + while (i<128) + { + /* Three bytes per pixel, r, g, b, make b by r^g */ + buffer[3*i+0] = (png_byte)((v >> 8) & 0xff); + buffer[3*i+1] = (png_byte)(v & 0xff); + buffer[3*i+2] = (png_byte)(((v >> 8) ^ v) & 0xff); + ++v; + ++i; + } + + return; + + case 32: + /* 65535 pixels, r, g, b, a; just replicate */ + while (i<128) + { + buffer[4*i+0] = (png_byte)((v >> 8) & 0xff); + buffer[4*i+1] = (png_byte)(v & 0xff); + buffer[4*i+2] = (png_byte)((v >> 8) & 0xff); + buffer[4*i+3] = (png_byte)(v & 0xff); + ++v; + ++i; + } + + return; + + case 48: + /* y is maximum 2047, giving 4x65536 pixels, make 'r' increase by 1 at + * each pixel, g increase by 257 (0x101) and 'b' by 0x1111: + */ + while (i<128) + { + png_uint_32 t = v++; + buffer[6*i+0] = (png_byte)((t >> 8) & 0xff); + buffer[6*i+1] = (png_byte)(t & 0xff); + t *= 257; + buffer[6*i+2] = (png_byte)((t >> 8) & 0xff); + buffer[6*i+3] = (png_byte)(t & 0xff); + t *= 17; + buffer[6*i+4] = (png_byte)((t >> 8) & 0xff); + buffer[6*i+5] = (png_byte)(t & 0xff); + ++i; + } + + return; + + case 64: + /* As above in the 32 bit case. */ + while (i<128) + { + png_uint_32 t = v++; + buffer[8*i+0] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+1] = (png_byte)(t & 0xff); + buffer[8*i+4] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+5] = (png_byte)(t & 0xff); + t *= 257; + buffer[8*i+2] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+3] = (png_byte)(t & 0xff); + buffer[8*i+6] = (png_byte)((t >> 8) & 0xff); + buffer[8*i+7] = (png_byte)(t & 0xff); + ++i; + } + return; + + default: + break; + } + + png_error(pp, "internal error"); +} + +/* This is just to do the right cast - could be changed to a function to check + * 'bd' but there isn't much point. + */ +#define DEPTH(bd) ((png_byte)(1U << (bd))) + +/* This is just a helper for compiling on minimal systems with no write + * interlacing support. If there is no write interlacing we can't generate test + * cases with interlace: + */ +#ifdef PNG_WRITE_INTERLACING_SUPPORTED +# define INTERLACE_LAST PNG_INTERLACE_LAST +# define check_interlace_type(type) ((void)(type)) +# define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp) +# define do_own_interlace 0 +#elif PNG_LIBPNG_VER < 10700 +# define set_write_interlace_handling(pp,type) (1) +static void +check_interlace_type(int const interlace_type) +{ + /* Prior to 1.7.0 libpng does not support the write of an interlaced image + * unless PNG_WRITE_INTERLACING_SUPPORTED, even with do_interlace so the + * code here does the pixel interlace itself, so: + */ + if (interlace_type != PNG_INTERLACE_NONE) + { + /* This is an internal error - --interlace tests should be skipped, not + * attempted. + */ + fprintf(stderr, "pngvalid: no interlace support\n"); + exit(99); + } +} +# define INTERLACE_LAST (PNG_INTERLACE_NONE+1) +# define do_own_interlace 0 +#else /* libpng 1.7+ */ +# define set_write_interlace_handling(pp,type)\ + npasses_from_interlace_type(pp,type) +# define check_interlace_type(type) ((void)(type)) +# define INTERLACE_LAST PNG_INTERLACE_LAST +# define do_own_interlace 1 +#endif /* WRITE_INTERLACING tests */ + +#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED +# define CAN_WRITE_INTERLACE 1 +#else +# define CAN_WRITE_INTERLACE 0 +#endif + +/* Do the same thing for read interlacing; this controls whether read tests do + * their own de-interlace or use libpng. + */ +#ifdef PNG_READ_INTERLACING_SUPPORTED +# define do_read_interlace 0 +#else /* no libpng read interlace support */ +# define do_read_interlace 1 +#endif +/* The following two routines use the PNG interlace support macros from + * png.h to interlace or deinterlace rows. + */ +static void +interlace_row(png_bytep buffer, png_const_bytep imageRow, + unsigned int pixel_size, png_uint_32 w, int pass, int littleendian) +{ + png_uint_32 xin, xout, xstep; + + /* Note that this can, trivially, be optimized to a memcpy on pass 7, the + * code is presented this way to make it easier to understand. In practice + * consult the code in the libpng source to see other ways of doing this. + * + * It is OK for buffer and imageRow to be identical, because 'xin' moves + * faster than 'xout' and we copy up. + */ + xin = PNG_PASS_START_COL(pass); + xstep = 1U<wname); + text.text = copy; + text.text_length = pos; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + if (colour_type == 3) /* palette */ + init_standard_palette(ps, pp, pi, 1U << bit_depth, 1/*do tRNS*/); + +# ifdef PNG_WRITE_tRNS_SUPPORTED + else if (palette_number) + set_random_tRNS(pp, pi, colour_type, bit_depth); +# endif + + png_write_info(pp, pi); + + if (png_get_rowbytes(pp, pi) != + transform_rowsize(pp, colour_type, bit_depth)) + png_error(pp, "transform row size incorrect"); + + else + { + /* Somewhat confusingly this must be called *after* png_write_info + * because if it is called before, the information in *pp has not been + * updated to reflect the interlaced image. + */ + int npasses = set_write_interlace_handling(pp, interlace_type); + int pass; + + if (npasses != npasses_from_interlace_type(pp, interlace_type)) + png_error(pp, "write: png_set_interlace_handling failed"); + + for (pass=0; pass 0) + interlace_row(buffer, buffer, + bit_size(pp, colour_type, bit_depth), w, pass, + 0/*data always bigendian*/); + else + continue; + } +# endif /* do_own_interlace */ + + choose_random_filter(pp, pass == 0 && y == 0); + png_write_row(pp, buffer); + } + } + } + +#ifdef PNG_TEXT_SUPPORTED + { + static char key[] = "end marker"; + static char comment[] = "end"; + png_text text; + + /* Use a compressed text string to test the correct interaction of text + * compression and IDAT compression. + */ + text.compression = TEXT_COMPRESSION; + text.key = key; + text.text = comment; + text.text_length = (sizeof comment)-1; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + png_write_end(pp, pi); + + /* And store this under the appropriate id, then clean up. */ + store_storefile(ps, FILEID(colour_type, bit_depth, palette_number, + interlace_type, 0, 0, 0)); + + store_write_reset(ps); + } + + Catch(fault) + { + /* Use the png_store returned by the exception. This may help the compiler + * because 'ps' is not used in this branch of the setjmp. Note that fault + * and ps will always be the same value. + */ + store_write_reset(fault); + } +} + +static void +make_transform_images(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* This is in case of errors. */ + safecat(pm->this.test, sizeof pm->this.test, 0, "make standard images"); + + /* Use next_format to enumerate all the combinations we test, including + * generating multiple low bit depth palette images. Non-A images (palette + * and direct) are created with and without tRNS chunks. + */ + while (next_format(&colour_type, &bit_depth, &palette_number, 1, 1)) + { + int interlace_type; + + for (interlace_type = PNG_INTERLACE_NONE; + interlace_type < INTERLACE_LAST; ++interlace_type) + { + char name[FILE_NAME_SIZE]; + + standard_name(name, sizeof name, 0, colour_type, bit_depth, + palette_number, interlace_type, 0, 0, do_own_interlace); + make_transform_image(&pm->this, colour_type, bit_depth, palette_number, + interlace_type, name); + } + } +} + +/* Build a single row for the 'size' test images; this fills in only the + * first bit_width bits of the sample row. + */ +static void +size_row(png_byte buffer[SIZE_ROWMAX], png_uint_32 bit_width, png_uint_32 y) +{ + /* height is in the range 1 to 16, so: */ + y = ((y & 1) << 7) + ((y & 2) << 6) + ((y & 4) << 5) + ((y & 8) << 4); + /* the following ensures bits are set in small images: */ + y ^= 0xA5; + + while (bit_width >= 8) + *buffer++ = (png_byte)y++, bit_width -= 8; + + /* There may be up to 7 remaining bits, these go in the most significant + * bits of the byte. + */ + if (bit_width > 0) + { + png_uint_32 mask = (1U<<(8-bit_width))-1; + *buffer = (png_byte)((*buffer & mask) | (y & ~mask)); + } +} + +static void +make_size_image(png_store* const ps, png_byte const colour_type, + png_byte const bit_depth, int const interlace_type, + png_uint_32 const w, png_uint_32 const h, + int const do_interlace) +{ + context(ps, fault); + + check_interlace_type(interlace_type); + + Try + { + png_infop pi; + png_structp pp; + unsigned int pixel_size; + + /* Make a name and get an appropriate id for the store: */ + char name[FILE_NAME_SIZE]; + png_uint_32 id = FILEID(colour_type, bit_depth, 0/*palette*/, + interlace_type, w, h, do_interlace); + + standard_name_from_id(name, sizeof name, 0, id); + pp = set_store_for_write(ps, &pi, name); + + /* In the event of a problem return control to the Catch statement below + * to do the clean up - it is not possible to 'return' directly from a Try + * block. + */ + if (pp == NULL) + Throw ps; + + png_set_IHDR(pp, pi, w, h, bit_depth, colour_type, interlace_type, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + +#ifdef PNG_TEXT_SUPPORTED + { + static char key[] = "image name"; /* must be writeable */ + size_t pos; + png_text text; + char copy[FILE_NAME_SIZE]; + + /* Use a compressed text string to test the correct interaction of text + * compression and IDAT compression. + */ + text.compression = TEXT_COMPRESSION; + text.key = key; + /* Yuck: the text must be writable! */ + pos = safecat(copy, sizeof copy, 0, ps->wname); + text.text = copy; + text.text_length = pos; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + if (colour_type == 3) /* palette */ + init_standard_palette(ps, pp, pi, 1U << bit_depth, 0/*do tRNS*/); + + png_write_info(pp, pi); + + /* Calculate the bit size, divide by 8 to get the byte size - this won't + * overflow because we know the w values are all small enough even for + * a system where 'unsigned int' is only 16 bits. + */ + pixel_size = bit_size(pp, colour_type, bit_depth); + if (png_get_rowbytes(pp, pi) != ((w * pixel_size) + 7) / 8) + png_error(pp, "size row size incorrect"); + + else + { + int npasses = npasses_from_interlace_type(pp, interlace_type); + png_uint_32 y; + int pass; + png_byte image[16][SIZE_ROWMAX]; + + /* To help consistent error detection make the parts of this buffer + * that aren't set below all '1': + */ + memset(image, 0xff, sizeof image); + + if (!do_interlace && + npasses != set_write_interlace_handling(pp, interlace_type)) + png_error(pp, "write: png_set_interlace_handling failed"); + + /* Prepare the whole image first to avoid making it 7 times: */ + for (y=0; y 0) + { + /* Set to all 1's for error detection (libpng tends to + * set unset things to 0). + */ + memset(tempRow, 0xff, sizeof tempRow); + interlace_row(tempRow, row, pixel_size, w, pass, + 0/*data always bigendian*/); + row = tempRow; + } + else + continue; + } + +# ifdef PNG_WRITE_FILTER_SUPPORTED + /* Only get to here if the row has some pixels in it, set the + * filters to 'all' for the very first row and thereafter to a + * single filter. It isn't well documented, but png_set_filter + * does accept a filter number (per the spec) as well as a bit + * mask. + * + * The code now uses filters at random, except that on the first + * row of an image it ensures that a previous row filter is in + * the set so that libpng allocates the row buffer. + */ + { + int filters = 8 << random_mod(PNG_FILTER_VALUE_LAST); + + if (pass == 0 && y == 0 && + (filters < PNG_FILTER_UP || w == 1U)) + filters |= PNG_FILTER_UP; + + png_set_filter(pp, 0/*method*/, filters); + } +# endif + + png_write_row(pp, row); + } + } + } + +#ifdef PNG_TEXT_SUPPORTED + { + static char key[] = "end marker"; + static char comment[] = "end"; + png_text text; + + /* Use a compressed text string to test the correct interaction of text + * compression and IDAT compression. + */ + text.compression = TEXT_COMPRESSION; + text.key = key; + text.text = comment; + text.text_length = (sizeof comment)-1; + text.itxt_length = 0; + text.lang = 0; + text.lang_key = 0; + + png_set_text(pp, pi, &text, 1); + } +#endif + + png_write_end(pp, pi); + + /* And store this under the appropriate id, then clean up. */ + store_storefile(ps, id); + + store_write_reset(ps); + } + + Catch(fault) + { + /* Use the png_store returned by the exception. This may help the compiler + * because 'ps' is not used in this branch of the setjmp. Note that fault + * and ps will always be the same value. + */ + store_write_reset(fault); + } +} + +static void +make_size(png_store* const ps, png_byte const colour_type, int bdlo, + int const bdhi) +{ + for (; bdlo <= bdhi; ++bdlo) + { + png_uint_32 width; + + for (width = 1; width <= 16; ++width) + { + png_uint_32 height; + + for (height = 1; height <= 16; ++height) + { + /* The four combinations of DIY interlace and interlace or not - + * no interlace + DIY should be identical to no interlace with + * libpng doing it. + */ + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE, + width, height, 0); + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE, + width, height, 1); +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, + width, height, 0); +# endif +# if CAN_WRITE_INTERLACE + /* 1.7.0 removes the hack that prevented app write of an interlaced + * image if WRITE_INTERLACE was not supported + */ + make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, + width, height, 1); +# endif + } + } + } +} + +static void +make_size_images(png_store *ps) +{ + /* This is in case of errors. */ + safecat(ps->test, sizeof ps->test, 0, "make size images"); + + /* Arguments are colour_type, low bit depth, high bit depth + */ + make_size(ps, 0, 0, WRITE_BDHI); + make_size(ps, 2, 3, WRITE_BDHI); + make_size(ps, 3, 0, 3 /*palette: max 8 bits*/); + make_size(ps, 4, 3, WRITE_BDHI); + make_size(ps, 6, 3, WRITE_BDHI); +} + +#ifdef PNG_READ_SUPPORTED +/* Return a row based on image id and 'y' for checking: */ +static void +standard_row(png_const_structp pp, png_byte std[STANDARD_ROWMAX], + png_uint_32 id, png_uint_32 y) +{ + if (WIDTH_FROM_ID(id) == 0) + transform_row(pp, std, COL_FROM_ID(id), DEPTH_FROM_ID(id), y); + else + size_row(std, WIDTH_FROM_ID(id) * bit_size(pp, COL_FROM_ID(id), + DEPTH_FROM_ID(id)), y); +} +#endif /* PNG_READ_SUPPORTED */ + +/* Tests - individual test cases */ +/* Like 'make_standard' but errors are deliberately introduced into the calls + * to ensure that they get detected - it should not be possible to write an + * invalid image with libpng! + */ +/* TODO: the 'set' functions can probably all be made to take a + * png_const_structp rather than a modifiable one. + */ +#ifdef PNG_WARNINGS_SUPPORTED +static void +sBIT0_error_fn(png_structp pp, png_infop pi) +{ + /* 0 is invalid... */ + png_color_8 bad; + bad.red = bad.green = bad.blue = bad.gray = bad.alpha = 0; + png_set_sBIT(pp, pi, &bad); +} + +static void +sBIT_error_fn(png_structp pp, png_infop pi) +{ + png_byte bit_depth; + png_color_8 bad; + + if (png_get_color_type(pp, pi) == PNG_COLOR_TYPE_PALETTE) + bit_depth = 8; + + else + bit_depth = png_get_bit_depth(pp, pi); + + /* Now we know the bit depth we can easily generate an invalid sBIT entry */ + bad.red = bad.green = bad.blue = bad.gray = bad.alpha = + (png_byte)(bit_depth+1); + png_set_sBIT(pp, pi, &bad); +} + +static const struct +{ + void (*fn)(png_structp, png_infop); + const char *msg; + unsigned int warning :1; /* the error is a warning... */ +} error_test[] = + { + /* no warnings makes these errors undetectable prior to 1.7.0 */ + { sBIT0_error_fn, "sBIT(0): failed to detect error", + PNG_LIBPNG_VER < 10700 }, + + { sBIT_error_fn, "sBIT(too big): failed to detect error", + PNG_LIBPNG_VER < 10700 }, + }; + +static void +make_error(png_store* const ps, png_byte const colour_type, + png_byte bit_depth, int interlace_type, int test, png_const_charp name) +{ + context(ps, fault); + + check_interlace_type(interlace_type); + + Try + { + png_infop pi; + png_structp pp = set_store_for_write(ps, &pi, name); + png_uint_32 w, h; + gnu_volatile(pp) + + if (pp == NULL) + Throw ps; + + w = transform_width(pp, colour_type, bit_depth); + gnu_volatile(w) + h = transform_height(pp, colour_type, bit_depth); + gnu_volatile(h) + png_set_IHDR(pp, pi, w, h, bit_depth, colour_type, interlace_type, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + if (colour_type == 3) /* palette */ + init_standard_palette(ps, pp, pi, 1U << bit_depth, 0/*do tRNS*/); + + /* Time for a few errors; these are in various optional chunks, the + * standard tests test the standard chunks pretty well. + */ +# define exception__prev exception_prev_1 +# define exception__env exception_env_1 + Try + { + gnu_volatile(exception__prev) + + /* Expect this to throw: */ + ps->expect_error = !error_test[test].warning; + ps->expect_warning = error_test[test].warning; + ps->saw_warning = 0; + error_test[test].fn(pp, pi); + + /* Normally the error is only detected here: */ + png_write_info(pp, pi); + + /* And handle the case where it was only a warning: */ + if (ps->expect_warning && ps->saw_warning) + Throw ps; + + /* If we get here there is a problem, we have success - no error or + * no warning - when we shouldn't have success. Log an error. + */ + store_log(ps, pp, error_test[test].msg, 1 /*error*/); + } + + Catch (fault) + { /* expected exit */ + } +#undef exception__prev +#undef exception__env + + /* And clear these flags */ + ps->expect_warning = 0; + + if (ps->expect_error) + ps->expect_error = 0; + + else + { + /* Now write the whole image, just to make sure that the detected, or + * undetected, error has not created problems inside libpng. This + * doesn't work if there was a png_error in png_write_info because that + * can abort before PLTE was written. + */ + if (png_get_rowbytes(pp, pi) != + transform_rowsize(pp, colour_type, bit_depth)) + png_error(pp, "row size incorrect"); + + else + { + int npasses = set_write_interlace_handling(pp, interlace_type); + int pass; + + if (npasses != npasses_from_interlace_type(pp, interlace_type)) + png_error(pp, "write: png_set_interlace_handling failed"); + + for (pass=0; pass 0) + interlace_row(buffer, buffer, + bit_size(pp, colour_type, bit_depth), w, pass, + 0/*data always bigendian*/); + else + continue; + } +# endif /* do_own_interlace */ + + png_write_row(pp, buffer); + } + } + } /* image writing */ + + png_write_end(pp, pi); + } + + /* The following deletes the file that was just written. */ + store_write_reset(ps); + } + + Catch(fault) + { + store_write_reset(fault); + } +} + +static int +make_errors(png_modifier* const pm, png_byte const colour_type, + int bdlo, int const bdhi) +{ + for (; bdlo <= bdhi; ++bdlo) + { + int interlace_type; + + for (interlace_type = PNG_INTERLACE_NONE; + interlace_type < INTERLACE_LAST; ++interlace_type) + { + unsigned int test; + char name[FILE_NAME_SIZE]; + + standard_name(name, sizeof name, 0, colour_type, 1<this, colour_type, DEPTH(bdlo), interlace_type, + test, name); + + if (fail(pm)) + return 0; + } + } + } + + return 1; /* keep going */ +} +#endif /* PNG_WARNINGS_SUPPORTED */ + +static void +perform_error_test(png_modifier *pm) +{ +#ifdef PNG_WARNINGS_SUPPORTED /* else there are no cases that work! */ + /* Need to do this here because we just write in this test. */ + safecat(pm->this.test, sizeof pm->this.test, 0, "error test"); + + if (!make_errors(pm, 0, 0, WRITE_BDHI)) + return; + + if (!make_errors(pm, 2, 3, WRITE_BDHI)) + return; + + if (!make_errors(pm, 3, 0, 3)) + return; + + if (!make_errors(pm, 4, 3, WRITE_BDHI)) + return; + + if (!make_errors(pm, 6, 3, WRITE_BDHI)) + return; +#else + UNUSED(pm) +#endif +} + +/* This is just to validate the internal PNG formatting code - if this fails + * then the warning messages the library outputs will probably be garbage. + */ +static void +perform_formatting_test(png_store *ps) +{ +#ifdef PNG_TIME_RFC1123_SUPPORTED + /* The handle into the formatting code is the RFC1123 support; this test does + * nothing if that is compiled out. + */ + context(ps, fault); + + Try + { + png_const_charp correct = "29 Aug 2079 13:53:60 +0000"; + png_const_charp result; +# if PNG_LIBPNG_VER >= 10600 + char timestring[29]; +# endif + png_structp pp; + png_time pt; + + pp = set_store_for_write(ps, NULL, "libpng formatting test"); + + if (pp == NULL) + Throw ps; + + + /* Arbitrary settings: */ + pt.year = 2079; + pt.month = 8; + pt.day = 29; + pt.hour = 13; + pt.minute = 53; + pt.second = 60; /* a leap second */ + +# if PNG_LIBPNG_VER < 10600 + result = png_convert_to_rfc1123(pp, &pt); +# else + if (png_convert_to_rfc1123_buffer(timestring, &pt)) + result = timestring; + + else + result = NULL; +# endif + + if (result == NULL) + png_error(pp, "png_convert_to_rfc1123 failed"); + + if (strcmp(result, correct) != 0) + { + size_t pos = 0; + char msg[128]; + + pos = safecat(msg, sizeof msg, pos, "png_convert_to_rfc1123("); + pos = safecat(msg, sizeof msg, pos, correct); + pos = safecat(msg, sizeof msg, pos, ") returned: '"); + pos = safecat(msg, sizeof msg, pos, result); + pos = safecat(msg, sizeof msg, pos, "'"); + + png_error(pp, msg); + } + + store_write_reset(ps); + } + + Catch(fault) + { + store_write_reset(fault); + } +#else + UNUSED(ps) +#endif +} + +#ifdef PNG_READ_SUPPORTED +/* Because we want to use the same code in both the progressive reader and the + * sequential reader it is necessary to deal with the fact that the progressive + * reader callbacks only have one parameter (png_get_progressive_ptr()), so this + * must contain all the test parameters and all the local variables directly + * accessible to the sequential reader implementation. + * + * The technique adopted is to reinvent part of what Dijkstra termed a + * 'display'; an array of pointers to the stack frames of enclosing functions so + * that a nested function definition can access the local (C auto) variables of + * the functions that contain its definition. In fact C provides the first + * pointer (the local variables - the stack frame pointer) and the last (the + * global variables - the BCPL global vector typically implemented as global + * addresses), this code requires one more pointer to make the display - the + * local variables (and function call parameters) of the function that actually + * invokes either the progressive or sequential reader. + * + * Perhaps confusingly this technique is confounded with classes - the + * 'standard_display' defined here is sub-classed as the 'gamma_display' below. + * A gamma_display is a standard_display, taking advantage of the ANSI-C + * requirement that the pointer to the first member of a structure must be the + * same as the pointer to the structure. This allows us to reuse standard_ + * functions in the gamma test code; something that could not be done with + * nested functions! + */ +typedef struct standard_display +{ + png_store* ps; /* Test parameters (passed to the function) */ + png_byte colour_type; + png_byte bit_depth; + png_byte red_sBIT; /* Input data sBIT values. */ + png_byte green_sBIT; + png_byte blue_sBIT; + png_byte alpha_sBIT; + png_byte interlace_type; + png_byte filler; /* Output has a filler */ + png_uint_32 id; /* Calculated file ID */ + png_uint_32 w; /* Width of image */ + png_uint_32 h; /* Height of image */ + int npasses; /* Number of interlaced passes */ + png_uint_32 pixel_size; /* Width of one pixel in bits */ + png_uint_32 bit_width; /* Width of output row in bits */ + size_t cbRow; /* Bytes in a row of the output image */ + int do_interlace; /* Do interlacing internally */ + int littleendian; /* App (row) data is little endian */ + int is_transparent; /* Transparency information was present. */ + int has_tRNS; /* color type GRAY or RGB with a tRNS chunk. */ + int speed; /* Doing a speed test */ + int use_update_info;/* Call update_info, not start_image */ + struct + { + png_uint_16 red; + png_uint_16 green; + png_uint_16 blue; + } transparent; /* The transparent color, if set. */ + int npalette; /* Number of entries in the palette. */ + store_palette + palette; +} standard_display; + +static void +standard_display_init(standard_display *dp, png_store* ps, png_uint_32 id, + int do_interlace, int use_update_info) +{ + memset(dp, 0, sizeof *dp); + + dp->ps = ps; + dp->colour_type = COL_FROM_ID(id); + dp->bit_depth = DEPTH_FROM_ID(id); + if (dp->bit_depth < 1 || dp->bit_depth > 16) + internal_error(ps, "internal: bad bit depth"); + if (dp->colour_type == 3) + dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT = 8; + else + dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT = + dp->bit_depth; + dp->interlace_type = INTERLACE_FROM_ID(id); + check_interlace_type(dp->interlace_type); + dp->id = id; + /* All the rest are filled in after the read_info: */ + dp->w = 0; + dp->h = 0; + dp->npasses = 0; + dp->pixel_size = 0; + dp->bit_width = 0; + dp->cbRow = 0; + dp->do_interlace = do_interlace; + dp->littleendian = 0; + dp->is_transparent = 0; + dp->speed = ps->speed; + dp->use_update_info = use_update_info; + dp->npalette = 0; + /* Preset the transparent color to black: */ + memset(&dp->transparent, 0, sizeof dp->transparent); + /* Preset the palette to full intensity/opaque throughout: */ + memset(dp->palette, 0xff, sizeof dp->palette); +} + +/* Initialize the palette fields - this must be done later because the palette + * comes from the particular png_store_file that is selected. + */ +static void +standard_palette_init(standard_display *dp) +{ + store_palette_entry *palette = store_current_palette(dp->ps, &dp->npalette); + + /* The remaining entries remain white/opaque. */ + if (dp->npalette > 0) + { + int i = dp->npalette; + memcpy(dp->palette, palette, i * sizeof *palette); + + /* Check for a non-opaque palette entry: */ + while (--i >= 0) + if (palette[i].alpha < 255) + break; + +# ifdef __GNUC__ + /* GCC can't handle the more obviously optimizable version. */ + if (i >= 0) + dp->is_transparent = 1; + else + dp->is_transparent = 0; +# else + dp->is_transparent = (i >= 0); +# endif + } +} + +/* Utility to read the palette from the PNG file and convert it into + * store_palette format. This returns 1 if there is any transparency in the + * palette (it does not check for a transparent colour in the non-palette case.) + */ +static int +read_palette(store_palette palette, int *npalette, png_const_structp pp, + png_infop pi) +{ + png_colorp pal; + png_bytep trans_alpha; + int num; + + pal = 0; + *npalette = -1; + + if (png_get_PLTE(pp, pi, &pal, npalette) & PNG_INFO_PLTE) + { + int i = *npalette; + + if (i <= 0 || i > 256) + png_error(pp, "validate: invalid PLTE count"); + + while (--i >= 0) + { + palette[i].red = pal[i].red; + palette[i].green = pal[i].green; + palette[i].blue = pal[i].blue; + } + + /* Mark the remainder of the entries with a flag value (other than + * white/opaque which is the flag value stored above.) + */ + memset(palette + *npalette, 126, (256-*npalette) * sizeof *palette); + } + + else /* !png_get_PLTE */ + { + if (*npalette != (-1)) + png_error(pp, "validate: invalid PLTE result"); + /* But there is no palette, so record this: */ + *npalette = 0; + memset(palette, 113, sizeof (store_palette)); + } + + trans_alpha = 0; + num = 2; /* force error below */ + if ((png_get_tRNS(pp, pi, &trans_alpha, &num, 0) & PNG_INFO_tRNS) != 0 && + (trans_alpha != NULL || num != 1/*returns 1 for a transparent color*/) && + /* Oops, if a palette tRNS gets expanded png_read_update_info (at least so + * far as 1.5.4) does not remove the trans_alpha pointer, only num_trans, + * so in the above call we get a success, we get a pointer (who knows what + * to) and we get num_trans == 0: + */ + !(trans_alpha != NULL && num == 0)) /* TODO: fix this in libpng. */ + { + int i; + + /* Any of these are crash-worthy - given the implementation of + * png_get_tRNS up to 1.5 an app won't crash if it just checks the + * result above and fails to check that the variables it passed have + * actually been filled in! Note that if the app were to pass the + * last, png_color_16p, variable too it couldn't rely on this. + */ + if (trans_alpha == NULL || num <= 0 || num > 256 || num > *npalette) + png_error(pp, "validate: unexpected png_get_tRNS (palette) result"); + + for (i=0; iis_transparent) + png_error(pp, "validate: palette transparency changed"); + + if (npalette != dp->npalette) + { + size_t pos = 0; + char msg[64]; + + pos = safecat(msg, sizeof msg, pos, "validate: palette size changed: "); + pos = safecatn(msg, sizeof msg, pos, dp->npalette); + pos = safecat(msg, sizeof msg, pos, " -> "); + pos = safecatn(msg, sizeof msg, pos, npalette); + png_error(pp, msg); + } + + { + int i = npalette; /* npalette is aliased */ + + while (--i >= 0) + if (palette[i].red != dp->palette[i].red || + palette[i].green != dp->palette[i].green || + palette[i].blue != dp->palette[i].blue || + palette[i].alpha != dp->palette[i].alpha) + png_error(pp, "validate: PLTE or tRNS chunk changed"); + } +} + +/* By passing a 'standard_display' the progressive callbacks can be used + * directly by the sequential code, the functions suffixed "_imp" are the + * implementations, the functions without the suffix are the callbacks. + * + * The code for the info callback is split into two because this callback calls + * png_read_update_info or png_start_read_image and what gets called depends on + * whether the info needs updating (we want to test both calls in pngvalid.) + */ +static void +standard_info_part1(standard_display *dp, png_structp pp, png_infop pi) +{ + if (png_get_bit_depth(pp, pi) != dp->bit_depth) + png_error(pp, "validate: bit depth changed"); + + if (png_get_color_type(pp, pi) != dp->colour_type) + png_error(pp, "validate: color type changed"); + + if (png_get_filter_type(pp, pi) != PNG_FILTER_TYPE_BASE) + png_error(pp, "validate: filter type changed"); + + if (png_get_interlace_type(pp, pi) != dp->interlace_type) + png_error(pp, "validate: interlacing changed"); + + if (png_get_compression_type(pp, pi) != PNG_COMPRESSION_TYPE_BASE) + png_error(pp, "validate: compression type changed"); + + dp->w = png_get_image_width(pp, pi); + + if (dp->w != standard_width(pp, dp->id)) + png_error(pp, "validate: image width changed"); + + dp->h = png_get_image_height(pp, pi); + + if (dp->h != standard_height(pp, dp->id)) + png_error(pp, "validate: image height changed"); + + /* Record (but don't check at present) the input sBIT according to the colour + * type information. + */ + { + png_color_8p sBIT = 0; + + if (png_get_sBIT(pp, pi, &sBIT) & PNG_INFO_sBIT) + { + int sBIT_invalid = 0; + + if (sBIT == 0) + png_error(pp, "validate: unexpected png_get_sBIT result"); + + if (dp->colour_type & PNG_COLOR_MASK_COLOR) + { + if (sBIT->red == 0 || sBIT->red > dp->bit_depth) + sBIT_invalid = 1; + else + dp->red_sBIT = sBIT->red; + + if (sBIT->green == 0 || sBIT->green > dp->bit_depth) + sBIT_invalid = 1; + else + dp->green_sBIT = sBIT->green; + + if (sBIT->blue == 0 || sBIT->blue > dp->bit_depth) + sBIT_invalid = 1; + else + dp->blue_sBIT = sBIT->blue; + } + + else /* !COLOR */ + { + if (sBIT->gray == 0 || sBIT->gray > dp->bit_depth) + sBIT_invalid = 1; + else + dp->blue_sBIT = dp->green_sBIT = dp->red_sBIT = sBIT->gray; + } + + /* All 8 bits in tRNS for a palette image are significant - see the + * spec. + */ + if (dp->colour_type & PNG_COLOR_MASK_ALPHA) + { + if (sBIT->alpha == 0 || sBIT->alpha > dp->bit_depth) + sBIT_invalid = 1; + else + dp->alpha_sBIT = sBIT->alpha; + } + + if (sBIT_invalid) + png_error(pp, "validate: sBIT value out of range"); + } + } + + /* Important: this is validating the value *before* any transforms have been + * put in place. It doesn't matter for the standard tests, where there are + * no transforms, but it does for other tests where rowbytes may change after + * png_read_update_info. + */ + if (png_get_rowbytes(pp, pi) != standard_rowsize(pp, dp->id)) + png_error(pp, "validate: row size changed"); + + /* Validate the colour type 3 palette (this can be present on other color + * types.) + */ + standard_palette_validate(dp, pp, pi); + + /* In any case always check for a transparent color (notice that the + * colour type 3 case must not give a successful return on the get_tRNS call + * with these arguments!) + */ + { + png_color_16p trans_color = 0; + + if (png_get_tRNS(pp, pi, 0, 0, &trans_color) & PNG_INFO_tRNS) + { + if (trans_color == 0) + png_error(pp, "validate: unexpected png_get_tRNS (color) result"); + + switch (dp->colour_type) + { + case 0: + dp->transparent.red = dp->transparent.green = dp->transparent.blue = + trans_color->gray; + dp->has_tRNS = 1; + break; + + case 2: + dp->transparent.red = trans_color->red; + dp->transparent.green = trans_color->green; + dp->transparent.blue = trans_color->blue; + dp->has_tRNS = 1; + break; + + case 3: + /* Not expected because it should result in the array case + * above. + */ + png_error(pp, "validate: unexpected png_get_tRNS result"); + break; + + default: + png_error(pp, "validate: invalid tRNS chunk with alpha image"); + } + } + } + + /* Read the number of passes - expected to match the value used when + * creating the image (interlaced or not). This has the side effect of + * turning on interlace handling (if do_interlace is not set.) + */ + dp->npasses = npasses_from_interlace_type(pp, dp->interlace_type); + if (!dp->do_interlace) + { +# ifdef PNG_READ_INTERLACING_SUPPORTED + if (dp->npasses != png_set_interlace_handling(pp)) + png_error(pp, "validate: file changed interlace type"); +# else /* !READ_INTERLACING */ + /* This should never happen: the relevant tests (!do_interlace) should + * not be run. + */ + if (dp->npasses > 1) + png_error(pp, "validate: no libpng interlace support"); +# endif /* !READ_INTERLACING */ + } + + /* Caller calls png_read_update_info or png_start_read_image now, then calls + * part2. + */ +} + +/* This must be called *after* the png_read_update_info call to get the correct + * 'rowbytes' value, otherwise png_get_rowbytes will refer to the untransformed + * image. + */ +static void +standard_info_part2(standard_display *dp, png_const_structp pp, + png_const_infop pi, int nImages) +{ + /* Record cbRow now that it can be found. */ + { + png_byte ct = png_get_color_type(pp, pi); + png_byte bd = png_get_bit_depth(pp, pi); + + if (bd >= 8 && (ct == PNG_COLOR_TYPE_RGB || ct == PNG_COLOR_TYPE_GRAY) && + dp->filler) + ct |= 4; /* handle filler as faked alpha channel */ + + dp->pixel_size = bit_size(pp, ct, bd); + } + dp->bit_width = png_get_image_width(pp, pi) * dp->pixel_size; + dp->cbRow = png_get_rowbytes(pp, pi); + + /* Validate the rowbytes here again. */ + if (dp->cbRow != (dp->bit_width+7)/8) + png_error(pp, "bad png_get_rowbytes calculation"); + + /* Then ensure there is enough space for the output image(s). */ + store_ensure_image(dp->ps, pp, nImages, dp->cbRow, dp->h); +} + +static void +standard_info_imp(standard_display *dp, png_structp pp, png_infop pi, + int nImages) +{ + /* Note that the validation routine has the side effect of turning on + * interlace handling in the subsequent code. + */ + standard_info_part1(dp, pp, pi); + + /* And the info callback has to call this (or png_read_update_info - see + * below in the png_modifier code for that variant. + */ + if (dp->use_update_info) + { + /* For debugging the effect of multiple calls: */ + int i = dp->use_update_info; + while (i-- > 0) + png_read_update_info(pp, pi); + } + + else + png_start_read_image(pp); + + /* Validate the height, width and rowbytes plus ensure that sufficient buffer + * exists for decoding the image. + */ + standard_info_part2(dp, pp, pi, nImages); +} + +static void PNGCBAPI +standard_info(png_structp pp, png_infop pi) +{ + standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + /* Call with nImages==1 because the progressive reader can only produce one + * image. + */ + standard_info_imp(dp, pp, pi, 1 /*only one image*/); +} + +static void PNGCBAPI +progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass) +{ + png_const_structp pp = ppIn; + const standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + /* When handling interlacing some rows will be absent in each pass, the + * callback still gets called, but with a NULL pointer. This is checked + * in the 'else' clause below. We need our own 'cbRow', but we can't call + * png_get_rowbytes because we got no info structure. + */ + if (new_row != NULL) + { + png_bytep row; + + /* In the case where the reader doesn't do the interlace it gives + * us the y in the sub-image: + */ + if (dp->do_interlace && dp->interlace_type == PNG_INTERLACE_ADAM7) + { +#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED + /* Use this opportunity to validate the png 'current' APIs: */ + if (y != png_get_current_row_number(pp)) + png_error(pp, "png_get_current_row_number is broken"); + + if (pass != png_get_current_pass_number(pp)) + png_error(pp, "png_get_current_pass_number is broken"); +#endif /* USER_TRANSFORM_INFO */ + + y = PNG_ROW_FROM_PASS_ROW(y, pass); + } + + /* Validate this just in case. */ + if (y >= dp->h) + png_error(pp, "invalid y to progressive row callback"); + + row = store_image_row(dp->ps, pp, 0, y); + + /* Combine the new row into the old: */ +#ifdef PNG_READ_INTERLACING_SUPPORTED + if (dp->do_interlace) +#endif /* READ_INTERLACING */ + { + if (dp->interlace_type == PNG_INTERLACE_ADAM7) + deinterlace_row(row, new_row, dp->pixel_size, dp->w, pass, + dp->littleendian); + else + row_copy(row, new_row, dp->pixel_size * dp->w, dp->littleendian); + } +#ifdef PNG_READ_INTERLACING_SUPPORTED + else + png_progressive_combine_row(pp, row, new_row); +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + } + + else if (dp->interlace_type == PNG_INTERLACE_ADAM7 && + PNG_ROW_IN_INTERLACE_PASS(y, pass) && + PNG_PASS_COLS(dp->w, pass) > 0) + png_error(pp, "missing row in progressive de-interlacing"); +} + +static void +sequential_row(standard_display *dp, png_structp pp, png_infop pi, + int iImage, int iDisplay) +{ + int npasses = dp->npasses; + int do_interlace = dp->do_interlace && + dp->interlace_type == PNG_INTERLACE_ADAM7; + png_uint_32 height = standard_height(pp, dp->id); + png_uint_32 width = standard_width(pp, dp->id); + const png_store* ps = dp->ps; + int pass; + + for (pass=0; pass 0 && PNG_ROW_IN_INTERLACE_PASS(y, pass)) + { + /* Read the row into a pair of temporary buffers, then do the + * merge here into the output rows. + */ + png_byte row[STANDARD_ROWMAX], display[STANDARD_ROWMAX]; + + /* The following aids (to some extent) error detection - we can + * see where png_read_row wrote. Use opposite values in row and + * display to make this easier. Don't use 0xff (which is used in + * the image write code to fill unused bits) or 0 (which is a + * likely value to overwrite unused bits with). + */ + memset(row, 0xc5, sizeof row); + memset(display, 0x5c, sizeof display); + + png_read_row(pp, row, display); + + if (iImage >= 0) + deinterlace_row(store_image_row(ps, pp, iImage, y), row, + dp->pixel_size, dp->w, pass, dp->littleendian); + + if (iDisplay >= 0) + deinterlace_row(store_image_row(ps, pp, iDisplay, y), display, + dp->pixel_size, dp->w, pass, dp->littleendian); + } + } + else + png_read_row(pp, + iImage >= 0 ? store_image_row(ps, pp, iImage, y) : NULL, + iDisplay >= 0 ? store_image_row(ps, pp, iDisplay, y) : NULL); + } + } + + /* And finish the read operation (only really necessary if the caller wants + * to find additional data in png_info from chunks after the last IDAT.) + */ + png_read_end(pp, pi); +} + +#ifdef PNG_TEXT_SUPPORTED +static void +standard_check_text(png_const_structp pp, png_const_textp tp, + png_const_charp keyword, png_const_charp text) +{ + char msg[1024]; + size_t pos = safecat(msg, sizeof msg, 0, "text: "); + size_t ok; + + pos = safecat(msg, sizeof msg, pos, keyword); + pos = safecat(msg, sizeof msg, pos, ": "); + ok = pos; + + if (tp->compression != TEXT_COMPRESSION) + { + char buf[64]; + + sprintf(buf, "compression [%d->%d], ", TEXT_COMPRESSION, + tp->compression); + pos = safecat(msg, sizeof msg, pos, buf); + } + + if (tp->key == NULL || strcmp(tp->key, keyword) != 0) + { + pos = safecat(msg, sizeof msg, pos, "keyword \""); + if (tp->key != NULL) + { + pos = safecat(msg, sizeof msg, pos, tp->key); + pos = safecat(msg, sizeof msg, pos, "\", "); + } + + else + pos = safecat(msg, sizeof msg, pos, "null, "); + } + + if (tp->text == NULL) + pos = safecat(msg, sizeof msg, pos, "text lost, "); + + else + { + if (tp->text_length != strlen(text)) + { + char buf[64]; + sprintf(buf, "text length changed[%lu->%lu], ", + (unsigned long)strlen(text), (unsigned long)tp->text_length); + pos = safecat(msg, sizeof msg, pos, buf); + } + + if (strcmp(tp->text, text) != 0) + { + pos = safecat(msg, sizeof msg, pos, "text becomes \""); + pos = safecat(msg, sizeof msg, pos, tp->text); + pos = safecat(msg, sizeof msg, pos, "\" (was \""); + pos = safecat(msg, sizeof msg, pos, text); + pos = safecat(msg, sizeof msg, pos, "\"), "); + } + } + + if (tp->itxt_length != 0) + pos = safecat(msg, sizeof msg, pos, "iTXt length set, "); + + if (tp->lang != NULL) + { + pos = safecat(msg, sizeof msg, pos, "iTXt language \""); + pos = safecat(msg, sizeof msg, pos, tp->lang); + pos = safecat(msg, sizeof msg, pos, "\", "); + } + + if (tp->lang_key != NULL) + { + pos = safecat(msg, sizeof msg, pos, "iTXt keyword \""); + pos = safecat(msg, sizeof msg, pos, tp->lang_key); + pos = safecat(msg, sizeof msg, pos, "\", "); + } + + if (pos > ok) + { + msg[pos-2] = '\0'; /* Remove the ", " at the end */ + png_error(pp, msg); + } +} + +static void +standard_text_validate(standard_display *dp, png_const_structp pp, + png_infop pi, int check_end) +{ + png_textp tp = NULL; + png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL); + + if (num_text == 2 && tp != NULL) + { + standard_check_text(pp, tp, "image name", dp->ps->current->name); + + /* This exists because prior to 1.5.18 the progressive reader left the + * png_struct z_stream unreset at the end of the image, so subsequent + * attempts to use it simply returns Z_STREAM_END. + */ + if (check_end) + standard_check_text(pp, tp+1, "end marker", "end"); + } + + else + { + char msg[64]; + + sprintf(msg, "expected two text items, got %lu", + (unsigned long)num_text); + png_error(pp, msg); + } +} +#else +# define standard_text_validate(dp,pp,pi,check_end) ((void)0) +#endif + +static void +standard_row_validate(standard_display *dp, png_const_structp pp, + int iImage, int iDisplay, png_uint_32 y) +{ + int where; + png_byte std[STANDARD_ROWMAX]; + + /* The row must be pre-initialized to the magic number here for the size + * tests to pass: + */ + memset(std, 178, sizeof std); + standard_row(pp, std, dp->id, y); + + /* At the end both the 'row' and 'display' arrays should end up identical. + * In earlier passes 'row' will be partially filled in, with only the pixels + * that have been read so far, but 'display' will have those pixels + * replicated to fill the unread pixels while reading an interlaced image. + */ + if (iImage >= 0 && + (where = pixel_cmp(std, store_image_row(dp->ps, pp, iImage, y), + dp->bit_width)) != 0) + { + char msg[64]; + sprintf(msg, "PNG image row[%lu][%d] changed from %.2x to %.2x", + (unsigned long)y, where-1, std[where-1], + store_image_row(dp->ps, pp, iImage, y)[where-1]); + png_error(pp, msg); + } + + if (iDisplay >= 0 && + (where = pixel_cmp(std, store_image_row(dp->ps, pp, iDisplay, y), + dp->bit_width)) != 0) + { + char msg[64]; + sprintf(msg, "display row[%lu][%d] changed from %.2x to %.2x", + (unsigned long)y, where-1, std[where-1], + store_image_row(dp->ps, pp, iDisplay, y)[where-1]); + png_error(pp, msg); + } +} + +static void +standard_image_validate(standard_display *dp, png_const_structp pp, int iImage, + int iDisplay) +{ + png_uint_32 y; + + if (iImage >= 0) + store_image_check(dp->ps, pp, iImage); + + if (iDisplay >= 0) + store_image_check(dp->ps, pp, iDisplay); + + for (y=0; yh; ++y) + standard_row_validate(dp, pp, iImage, iDisplay, y); + + /* This avoids false positives if the validation code is never called! */ + dp->ps->validated = 1; +} + +static void PNGCBAPI +standard_end(png_structp ppIn, png_infop pi) +{ + png_const_structp pp = ppIn; + standard_display *dp = voidcast(standard_display*, + png_get_progressive_ptr(pp)); + + UNUSED(pi) + + /* Validate the image - progressive reading only produces one variant for + * interlaced images. + */ + standard_text_validate(dp, pp, pi, + PNG_LIBPNG_VER >= 10518/*check_end: see comments above*/); + standard_image_validate(dp, pp, 0, -1); +} + +/* A single test run checking the standard image to ensure it is not damaged. */ +static void +standard_test(png_store* const psIn, png_uint_32 const id, + int do_interlace, int use_update_info) +{ + standard_display d; + context(psIn, fault); + + /* Set up the display (stack frame) variables from the arguments to the + * function and initialize the locals that are filled in later. + */ + standard_display_init(&d, psIn, id, do_interlace, use_update_info); + + /* Everything is protected by a Try/Catch. The functions called also + * typically have local Try/Catch blocks. + */ + Try + { + png_structp pp; + png_infop pi; + + /* Get a png_struct for reading the image. This will throw an error if it + * fails, so we don't need to check the result. + */ + pp = set_store_for_read(d.ps, &pi, d.id, + d.do_interlace ? (d.ps->progressive ? + "pngvalid progressive deinterlacer" : + "pngvalid sequential deinterlacer") : (d.ps->progressive ? + "progressive reader" : "sequential reader")); + + /* Initialize the palette correctly from the png_store_file. */ + standard_palette_init(&d); + + /* Introduce the correct read function. */ + if (d.ps->progressive) + { + png_set_progressive_read_fn(pp, &d, standard_info, progressive_row, + standard_end); + + /* Now feed data into the reader until we reach the end: */ + store_progressive_read(d.ps, pp, pi); + } + else + { + /* Note that this takes the store, not the display. */ + png_set_read_fn(pp, d.ps, store_read); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* The code tests both versions of the images that the sequential + * reader can produce. + */ + standard_info_imp(&d, pp, pi, 2 /*images*/); + + /* Need the total bytes in the image below; we can't get to this point + * unless the PNG file values have been checked against the expected + * values. + */ + { + sequential_row(&d, pp, pi, 0, 1); + + /* After the last pass loop over the rows again to check that the + * image is correct. + */ + if (!d.speed) + { + standard_text_validate(&d, pp, pi, 1/*check_end*/); + standard_image_validate(&d, pp, 0, 1); + } + else + d.ps->validated = 1; + } + } + + /* Check for validation. */ + if (!d.ps->validated) + png_error(pp, "image read failed silently"); + + /* Successful completion. */ + } + + Catch(fault) + d.ps = fault; /* make sure this hasn't been clobbered. */ + + /* In either case clean up the store. */ + store_read_reset(d.ps); +} + +static int +test_standard(png_modifier* const pm, png_byte const colour_type, + int bdlo, int const bdhi) +{ + for (; bdlo <= bdhi; ++bdlo) + { + int interlace_type; + + for (interlace_type = PNG_INTERLACE_NONE; + interlace_type < INTERLACE_LAST; ++interlace_type) + { + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + interlace_type, 0, 0, 0), do_read_interlace, pm->use_update_info); + + if (fail(pm)) + return 0; + } + } + + return 1; /* keep going */ +} + +static void +perform_standard_test(png_modifier *pm) +{ + /* Test each colour type over the valid range of bit depths (expressed as + * log2(bit_depth) in turn, stop as soon as any error is detected. + */ + if (!test_standard(pm, 0, 0, READ_BDHI)) + return; + + if (!test_standard(pm, 2, 3, READ_BDHI)) + return; + + if (!test_standard(pm, 3, 0, 3)) + return; + + if (!test_standard(pm, 4, 3, READ_BDHI)) + return; + + if (!test_standard(pm, 6, 3, READ_BDHI)) + return; +} + + +/********************************** SIZE TESTS ********************************/ +static int +test_size(png_modifier* const pm, png_byte const colour_type, + int bdlo, int const bdhi) +{ + /* Run the tests on each combination. + * + * NOTE: on my 32 bit x86 each of the following blocks takes + * a total of 3.5 seconds if done across every combo of bit depth + * width and height. This is a waste of time in practice, hence the + * hinc and winc stuff: + */ + static const png_byte hinc[] = {1, 3, 11, 1, 5}; + static const png_byte winc[] = {1, 9, 5, 7, 1}; + int save_bdlo = bdlo; + + for (; bdlo <= bdhi; ++bdlo) + { + png_uint_32 h, w; + + for (h=1; h<=16; h+=hinc[bdlo]) for (w=1; w<=16; w+=winc[bdlo]) + { + /* First test all the 'size' images against the sequential + * reader using libpng to deinterlace (where required.) This + * validates the write side of libpng. There are four possibilities + * to validate. + */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_NONE, w, h, 0), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; + + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_NONE, w, h, 1), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; + + /* Now validate the interlaced read side - do_interlace true, + * in the progressive case this does actually make a difference + * to the code used in the non-interlaced case too. + */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_NONE, w, h, 0), 1/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; + +# if CAN_WRITE_INTERLACE + /* Validate the pngvalid code itself: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 1), 1/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif + } + } + + /* Now do the tests of libpng interlace handling, after we have made sure + * that the pngvalid version works: + */ + for (bdlo = save_bdlo; bdlo <= bdhi; ++bdlo) + { + png_uint_32 h, w; + + for (h=1; h<=16; h+=hinc[bdlo]) for (w=1; w<=16; w+=winc[bdlo]) + { +# ifdef PNG_READ_INTERLACING_SUPPORTED + /* Test with pngvalid generated interlaced images first; we have + * already verify these are ok (unless pngvalid has self-consistent + * read/write errors, which is unlikely), so this detects errors in the + * read side first: + */ +# if CAN_WRITE_INTERLACE + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 1), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif +# endif /* READ_INTERLACING */ + +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Test the libpng write side against the pngvalid read side: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 0), 1/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif + +# ifdef PNG_READ_INTERLACING_SUPPORTED +# ifdef PNG_WRITE_INTERLACING_SUPPORTED + /* Test both together: */ + standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/, + PNG_INTERLACE_ADAM7, w, h, 0), 0/*do_interlace*/, + pm->use_update_info); + + if (fail(pm)) + return 0; +# endif +# endif /* READ_INTERLACING */ + } + } + + return 1; /* keep going */ +} + +static void +perform_size_test(png_modifier *pm) +{ + /* Test each colour type over the valid range of bit depths (expressed as + * log2(bit_depth) in turn, stop as soon as any error is detected. + */ + if (!test_size(pm, 0, 0, READ_BDHI)) + return; + + if (!test_size(pm, 2, 3, READ_BDHI)) + return; + + /* For the moment don't do the palette test - it's a waste of time when + * compared to the grayscale test. + */ +#if 0 + if (!test_size(pm, 3, 0, 3)) + return; +#endif + + if (!test_size(pm, 4, 3, READ_BDHI)) + return; + + if (!test_size(pm, 6, 3, READ_BDHI)) + return; +} + + +/******************************* TRANSFORM TESTS ******************************/ +#ifdef PNG_READ_TRANSFORMS_SUPPORTED +/* A set of tests to validate libpng image transforms. The possibilities here + * are legion because the transforms can be combined in a combinatorial + * fashion. To deal with this some measure of restraint is required, otherwise + * the tests would take forever. + */ +typedef struct image_pixel +{ + /* A local (pngvalid) representation of a PNG pixel, in all its + * various forms. + */ + unsigned int red, green, blue, alpha; /* For non-palette images. */ + unsigned int palette_index; /* For a palette image. */ + png_byte colour_type; /* As in the spec. */ + png_byte bit_depth; /* Defines bit size in row */ + png_byte sample_depth; /* Scale of samples */ + unsigned int have_tRNS :1; /* tRNS chunk may need processing */ + unsigned int swap_rgb :1; /* RGB swapped to BGR */ + unsigned int alpha_first :1; /* Alpha at start, not end */ + unsigned int alpha_inverted :1; /* Alpha channel inverted */ + unsigned int mono_inverted :1; /* Gray channel inverted */ + unsigned int swap16 :1; /* Byte swap 16-bit components */ + unsigned int littleendian :1; /* High bits on right */ + unsigned int sig_bits :1; /* Pixel shifted (sig bits only) */ + + /* For checking the code calculates double precision floating point values + * along with an error value, accumulated from the transforms. Because an + * sBIT setting allows larger error bounds (indeed, by the spec, apparently + * up to just less than +/-1 in the scaled value) the *lowest* sBIT for each + * channel is stored. This sBIT value is folded in to the stored error value + * at the end of the application of the transforms to the pixel. + * + * If sig_bits is set above the red, green, blue and alpha values have been + * scaled so they only contain the significant bits of the component values. + */ + double redf, greenf, bluef, alphaf; + double rede, greene, bluee, alphae; + png_byte red_sBIT, green_sBIT, blue_sBIT, alpha_sBIT; +} image_pixel; + +/* Shared utility function, see below. */ +static void +image_pixel_setf(image_pixel *this, unsigned int rMax, unsigned int gMax, + unsigned int bMax, unsigned int aMax) +{ + this->redf = this->red / (double)rMax; + this->greenf = this->green / (double)gMax; + this->bluef = this->blue / (double)bMax; + this->alphaf = this->alpha / (double)aMax; + + if (this->red < rMax) + this->rede = this->redf * DBL_EPSILON; + else + this->rede = 0; + if (this->green < gMax) + this->greene = this->greenf * DBL_EPSILON; + else + this->greene = 0; + if (this->blue < bMax) + this->bluee = this->bluef * DBL_EPSILON; + else + this->bluee = 0; + if (this->alpha < aMax) + this->alphae = this->alphaf * DBL_EPSILON; + else + this->alphae = 0; +} + +/* Initialize the structure for the next pixel - call this before doing any + * transforms and call it for each pixel since all the fields may need to be + * reset. + */ +static void +image_pixel_init(image_pixel *this, png_const_bytep row, png_byte colour_type, + png_byte bit_depth, png_uint_32 x, store_palette palette, + const image_pixel *format /*from pngvalid transform of input*/) +{ + png_byte sample_depth = + (png_byte)(colour_type == PNG_COLOR_TYPE_PALETTE ? 8 : bit_depth); + unsigned int max = (1U<swap16); + int littleendian = (format != 0 && format->littleendian); + int sig_bits = (format != 0 && format->sig_bits); + + /* Initially just set everything to the same number and the alpha to opaque. + * Note that this currently assumes a simple palette where entry x has colour + * rgb(x,x,x)! + */ + this->palette_index = this->red = this->green = this->blue = + sample(row, colour_type, bit_depth, x, 0, swap16, littleendian); + this->alpha = max; + this->red_sBIT = this->green_sBIT = this->blue_sBIT = this->alpha_sBIT = + sample_depth; + + /* Then override as appropriate: */ + if (colour_type == 3) /* palette */ + { + /* This permits the caller to default to the sample value. */ + if (palette != 0) + { + unsigned int i = this->palette_index; + + this->red = palette[i].red; + this->green = palette[i].green; + this->blue = palette[i].blue; + this->alpha = palette[i].alpha; + } + } + + else /* not palette */ + { + unsigned int i = 0; + + if ((colour_type & 4) != 0 && format != 0 && format->alpha_first) + { + this->alpha = this->red; + /* This handles the gray case for 'AG' pixels */ + this->palette_index = this->red = this->green = this->blue = + sample(row, colour_type, bit_depth, x, 1, swap16, littleendian); + i = 1; + } + + if (colour_type & 2) + { + /* Green is second for both BGR and RGB: */ + this->green = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + + if (format != 0 && format->swap_rgb) /* BGR */ + this->red = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + else + this->blue = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + } + + else /* grayscale */ if (format != 0 && format->mono_inverted) + this->red = this->green = this->blue = this->red ^ max; + + if ((colour_type & 4) != 0) /* alpha */ + { + if (format == 0 || !format->alpha_first) + this->alpha = sample(row, colour_type, bit_depth, x, ++i, swap16, + littleendian); + + if (format != 0 && format->alpha_inverted) + this->alpha ^= max; + } + } + + /* Calculate the scaled values, these are simply the values divided by + * 'max' and the error is initialized to the double precision epsilon value + * from the header file. + */ + image_pixel_setf(this, + sig_bits ? (1U << format->red_sBIT)-1 : max, + sig_bits ? (1U << format->green_sBIT)-1 : max, + sig_bits ? (1U << format->blue_sBIT)-1 : max, + sig_bits ? (1U << format->alpha_sBIT)-1 : max); + + /* Store the input information for use in the transforms - these will + * modify the information. + */ + this->colour_type = colour_type; + this->bit_depth = bit_depth; + this->sample_depth = sample_depth; + this->have_tRNS = 0; + this->swap_rgb = 0; + this->alpha_first = 0; + this->alpha_inverted = 0; + this->mono_inverted = 0; + this->swap16 = 0; + this->littleendian = 0; + this->sig_bits = 0; +} + +#if defined PNG_READ_EXPAND_SUPPORTED || defined PNG_READ_GRAY_TO_RGB_SUPPORTED\ + || defined PNG_READ_EXPAND_SUPPORTED || defined PNG_READ_EXPAND_16_SUPPORTED\ + || defined PNG_READ_BACKGROUND_SUPPORTED +/* Convert a palette image to an rgb image. This necessarily converts the tRNS + * chunk at the same time, because the tRNS will be in palette form. The way + * palette validation works means that the original palette is never updated, + * instead the image_pixel value from the row contains the RGB of the + * corresponding palette entry and *this* is updated. Consequently this routine + * only needs to change the colour type information. + */ +static void +image_pixel_convert_PLTE(image_pixel *this) +{ + if (this->colour_type == PNG_COLOR_TYPE_PALETTE) + { + if (this->have_tRNS) + { + this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + this->have_tRNS = 0; + } + else + this->colour_type = PNG_COLOR_TYPE_RGB; + + /* The bit depth of the row changes at this point too (notice that this is + * the row format, not the sample depth, which is separate.) + */ + this->bit_depth = 8; + } +} + +/* Add an alpha channel; this will import the tRNS information because tRNS is + * not valid in an alpha image. The bit depth will invariably be set to at + * least 8 prior to 1.7.0. Palette images will be converted to alpha (using + * the above API). With png_set_background the alpha channel is never expanded + * but this routine is used by pngvalid to simplify code; 'for_background' + * records this. + */ +static void +image_pixel_add_alpha(image_pixel *this, const standard_display *display, + int for_background) +{ + if (this->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(this); + + if ((this->colour_type & PNG_COLOR_MASK_ALPHA) == 0) + { + if (this->colour_type == PNG_COLOR_TYPE_GRAY) + { +# if PNG_LIBPNG_VER < 10700 + if (!for_background && this->bit_depth < 8) + this->bit_depth = this->sample_depth = 8; +# endif + + if (this->have_tRNS) + { + /* After 1.7 the expansion of bit depth only happens if there is a + * tRNS chunk to expand at this point. + */ +# if PNG_LIBPNG_VER >= 10700 + if (!for_background && this->bit_depth < 8) + this->bit_depth = this->sample_depth = 8; +# endif + + this->have_tRNS = 0; + + /* Check the input, original, channel value here against the + * original tRNS gray chunk valie. + */ + if (this->red == display->transparent.red) + this->alphaf = 0; + else + this->alphaf = 1; + } + else + this->alphaf = 1; + + this->colour_type = PNG_COLOR_TYPE_GRAY_ALPHA; + } + + else if (this->colour_type == PNG_COLOR_TYPE_RGB) + { + if (this->have_tRNS) + { + this->have_tRNS = 0; + + /* Again, check the exact input values, not the current transformed + * value! + */ + if (this->red == display->transparent.red && + this->green == display->transparent.green && + this->blue == display->transparent.blue) + this->alphaf = 0; + else + this->alphaf = 1; + } + else + this->alphaf = 1; + + this->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + } + + /* The error in the alpha is zero and the sBIT value comes from the + * original sBIT data (actually it will always be the original bit depth). + */ + this->alphae = 0; + this->alpha_sBIT = display->alpha_sBIT; + } +} +#endif /* transforms that need image_pixel_add_alpha */ + +struct transform_display; +typedef struct image_transform +{ + /* The name of this transform: a string. */ + const char *name; + + /* Each transform can be disabled from the command line: */ + int enable; + + /* The global list of transforms; read only. */ + struct image_transform *const list; + + /* The global count of the number of times this transform has been set on an + * image. + */ + unsigned int global_use; + + /* The local count of the number of times this transform has been set. */ + unsigned int local_use; + + /* The next transform in the list, each transform must call its own next + * transform after it has processed the pixel successfully. + */ + const struct image_transform *next; + + /* A single transform for the image, expressed as a series of function + * callbacks and some space for values. + * + * First a callback to add any required modifications to the png_modifier; + * this gets called just before the modifier is set up for read. + */ + void (*ini)(const struct image_transform *this, + struct transform_display *that); + + /* And a callback to set the transform on the current png_read_struct: + */ + void (*set)(const struct image_transform *this, + struct transform_display *that, png_structp pp, png_infop pi); + + /* Then a transform that takes an input pixel in one PNG format or another + * and modifies it by a pngvalid implementation of the transform (thus + * duplicating the libpng intent without, we hope, duplicating the bugs + * in the libpng implementation!) The png_structp is solely to allow error + * reporting via png_error and png_warning. + */ + void (*mod)(const struct image_transform *this, image_pixel *that, + png_const_structp pp, const struct transform_display *display); + + /* Add this transform to the list and return true if the transform is + * meaningful for this colour type and bit depth - if false then the + * transform should have no effect on the image so there's not a lot of + * point running it. + */ + int (*add)(struct image_transform *this, + const struct image_transform **that, png_byte colour_type, + png_byte bit_depth); +} image_transform; + +typedef struct transform_display +{ + standard_display this; + + /* Parameters */ + png_modifier* pm; + const image_transform* transform_list; + unsigned int max_gamma_8; + + /* Local variables */ + png_byte output_colour_type; + png_byte output_bit_depth; + png_byte unpacked; + + /* Modifications (not necessarily used.) */ + gama_modification gama_mod; + chrm_modification chrm_mod; + srgb_modification srgb_mod; +} transform_display; + +/* Set sRGB, cHRM and gAMA transforms as required by the current encoding. */ +static void +transform_set_encoding(transform_display *this) +{ + /* Set up the png_modifier '_current' fields then use these to determine how + * to add appropriate chunks. + */ + png_modifier *pm = this->pm; + + modifier_set_encoding(pm); + + if (modifier_color_encoding_is_set(pm)) + { + if (modifier_color_encoding_is_sRGB(pm)) + srgb_modification_init(&this->srgb_mod, pm, PNG_sRGB_INTENT_ABSOLUTE); + + else + { + /* Set gAMA and cHRM separately. */ + gama_modification_init(&this->gama_mod, pm, pm->current_gamma); + + if (pm->current_encoding != 0) + chrm_modification_init(&this->chrm_mod, pm, pm->current_encoding); + } + } +} + +/* Three functions to end the list: */ +static void +image_transform_ini_end(const image_transform *this, + transform_display *that) +{ + UNUSED(this) + UNUSED(that) +} + +static void +image_transform_set_end(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + UNUSED(this) + UNUSED(that) + UNUSED(pp) + UNUSED(pi) +} + +/* At the end of the list recalculate the output image pixel value from the + * double precision values set up by the preceding 'mod' calls: + */ +static unsigned int +sample_scale(double sample_value, unsigned int scale) +{ + sample_value = floor(sample_value * scale + .5); + + /* Return NaN as 0: */ + if (!(sample_value > 0)) + sample_value = 0; + else if (sample_value > scale) + sample_value = scale; + + return (unsigned int)sample_value; +} + +static void +image_transform_mod_end(const image_transform *this, image_pixel *that, + png_const_structp pp, const transform_display *display) +{ + unsigned int scale = (1U<sample_depth)-1; + int sig_bits = that->sig_bits; + + UNUSED(this) + UNUSED(pp) + UNUSED(display) + + /* At the end recalculate the digitized red green and blue values according + * to the current sample_depth of the pixel. + * + * The sample value is simply scaled to the maximum, checking for over + * and underflow (which can both happen for some image transforms, + * including simple size scaling, though libpng doesn't do that at present. + */ + that->red = sample_scale(that->redf, scale); + + /* This is a bit bogus; really the above calculation should use the red_sBIT + * value, not sample_depth, but because libpng does png_set_shift by just + * shifting the bits we get errors if we don't do it the same way. + */ + if (sig_bits && that->red_sBIT < that->sample_depth) + that->red >>= that->sample_depth - that->red_sBIT; + + /* The error value is increased, at the end, according to the lowest sBIT + * value seen. Common sense tells us that the intermediate integer + * representations are no more accurate than +/- 0.5 in the integral values, + * the sBIT allows the implementation to be worse than this. In addition the + * PNG specification actually permits any error within the range (-1..+1), + * but that is ignored here. Instead the final digitized value is compared, + * below to the digitized value of the error limits - this has the net effect + * of allowing (almost) +/-1 in the output value. It's difficult to see how + * any algorithm that digitizes intermediate results can be more accurate. + */ + that->rede += 1./(2*((1U<red_sBIT)-1)); + + if (that->colour_type & PNG_COLOR_MASK_COLOR) + { + that->green = sample_scale(that->greenf, scale); + if (sig_bits && that->green_sBIT < that->sample_depth) + that->green >>= that->sample_depth - that->green_sBIT; + + that->blue = sample_scale(that->bluef, scale); + if (sig_bits && that->blue_sBIT < that->sample_depth) + that->blue >>= that->sample_depth - that->blue_sBIT; + + that->greene += 1./(2*((1U<green_sBIT)-1)); + that->bluee += 1./(2*((1U<blue_sBIT)-1)); + } + else + { + that->blue = that->green = that->red; + that->bluef = that->greenf = that->redf; + that->bluee = that->greene = that->rede; + } + + if ((that->colour_type & PNG_COLOR_MASK_ALPHA) || + that->colour_type == PNG_COLOR_TYPE_PALETTE) + { + that->alpha = sample_scale(that->alphaf, scale); + that->alphae += 1./(2*((1U<alpha_sBIT)-1)); + } + else + { + that->alpha = scale; /* opaque */ + that->alphaf = 1; /* Override this. */ + that->alphae = 0; /* It's exact ;-) */ + } + + if (sig_bits && that->alpha_sBIT < that->sample_depth) + that->alpha >>= that->sample_depth - that->alpha_sBIT; +} + +/* Static 'end' structure: */ +static image_transform image_transform_end = +{ + "(end)", /* name */ + 1, /* enable */ + 0, /* list */ + 0, /* global_use */ + 0, /* local_use */ + 0, /* next */ + image_transform_ini_end, + image_transform_set_end, + image_transform_mod_end, + 0 /* never called, I want it to crash if it is! */ +}; + +/* Reader callbacks and implementations, where they differ from the standard + * ones. + */ +static void +transform_display_init(transform_display *dp, png_modifier *pm, png_uint_32 id, + const image_transform *transform_list) +{ + memset(dp, 0, sizeof *dp); + + /* Standard fields */ + standard_display_init(&dp->this, &pm->this, id, do_read_interlace, + pm->use_update_info); + + /* Parameter fields */ + dp->pm = pm; + dp->transform_list = transform_list; + dp->max_gamma_8 = 16; + + /* Local variable fields */ + dp->output_colour_type = 255; /* invalid */ + dp->output_bit_depth = 255; /* invalid */ + dp->unpacked = 0; /* not unpacked */ +} + +static void +transform_info_imp(transform_display *dp, png_structp pp, png_infop pi) +{ + /* Reuse the standard stuff as appropriate. */ + standard_info_part1(&dp->this, pp, pi); + + /* Now set the list of transforms. */ + dp->transform_list->set(dp->transform_list, dp, pp, pi); + + /* Update the info structure for these transforms: */ + { + int i = dp->this.use_update_info; + /* Always do one call, even if use_update_info is 0. */ + do + png_read_update_info(pp, pi); + while (--i > 0); + } + + /* And get the output information into the standard_display */ + standard_info_part2(&dp->this, pp, pi, 1/*images*/); + + /* Plus the extra stuff we need for the transform tests: */ + dp->output_colour_type = png_get_color_type(pp, pi); + dp->output_bit_depth = png_get_bit_depth(pp, pi); + + /* If png_set_filler is in action then fake the output color type to include + * an alpha channel where appropriate. + */ + if (dp->output_bit_depth >= 8 && + (dp->output_colour_type == PNG_COLOR_TYPE_RGB || + dp->output_colour_type == PNG_COLOR_TYPE_GRAY) && dp->this.filler) + dp->output_colour_type |= 4; + + /* Validate the combination of colour type and bit depth that we are getting + * out of libpng; the semantics of something not in the PNG spec are, at + * best, unclear. + */ + switch (dp->output_colour_type) + { + case PNG_COLOR_TYPE_PALETTE: + if (dp->output_bit_depth > 8) goto error; + /* FALLTHROUGH */ + case PNG_COLOR_TYPE_GRAY: + if (dp->output_bit_depth == 1 || dp->output_bit_depth == 2 || + dp->output_bit_depth == 4) + break; + /* FALLTHROUGH */ + default: + if (dp->output_bit_depth == 8 || dp->output_bit_depth == 16) + break; + /* FALLTHROUGH */ + error: + { + char message[128]; + size_t pos; + + pos = safecat(message, sizeof message, 0, + "invalid final bit depth: colour type("); + pos = safecatn(message, sizeof message, pos, dp->output_colour_type); + pos = safecat(message, sizeof message, pos, ") with bit depth: "); + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + + png_error(pp, message); + } + } + + /* Use a test pixel to check that the output agrees with what we expect - + * this avoids running the whole test if the output is unexpected. This also + * checks for internal errors. + */ + { + image_pixel test_pixel; + + memset(&test_pixel, 0, sizeof test_pixel); + test_pixel.colour_type = dp->this.colour_type; /* input */ + test_pixel.bit_depth = dp->this.bit_depth; + if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE) + test_pixel.sample_depth = 8; + else + test_pixel.sample_depth = test_pixel.bit_depth; + /* Don't need sBIT here, but it must be set to non-zero to avoid + * arithmetic overflows. + */ + test_pixel.have_tRNS = dp->this.is_transparent != 0; + test_pixel.red_sBIT = test_pixel.green_sBIT = test_pixel.blue_sBIT = + test_pixel.alpha_sBIT = test_pixel.sample_depth; + + dp->transform_list->mod(dp->transform_list, &test_pixel, pp, dp); + + if (test_pixel.colour_type != dp->output_colour_type) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, "colour type "); + + pos = safecatn(message, sizeof message, pos, dp->output_colour_type); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.colour_type); + + png_error(pp, message); + } + + if (test_pixel.bit_depth != dp->output_bit_depth) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, "bit depth "); + + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } + + /* If both bit depth and colour type are correct check the sample depth. + */ + if (test_pixel.colour_type == PNG_COLOR_TYPE_PALETTE && + test_pixel.sample_depth != 8) /* oops - internal error! */ + png_error(pp, "pngvalid: internal: palette sample depth not 8"); + else if (dp->unpacked && test_pixel.bit_depth != 8) + png_error(pp, "pngvalid: internal: bad unpacked pixel depth"); + else if (!dp->unpacked && test_pixel.colour_type != PNG_COLOR_TYPE_PALETTE + && test_pixel.bit_depth != test_pixel.sample_depth) + { + char message[128]; + size_t pos = safecat(message, sizeof message, 0, + "internal: sample depth "); + + /* Because unless something has set 'unpacked' or the image is palette + * mapped we expect the transform to keep sample depth and bit depth + * the same. + */ + pos = safecatn(message, sizeof message, pos, test_pixel.sample_depth); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } + else if (test_pixel.bit_depth != dp->output_bit_depth) + { + /* This could be a libpng error too; libpng has not produced what we + * expect for the output bit depth. + */ + char message[128]; + size_t pos = safecat(message, sizeof message, 0, + "internal: bit depth "); + + pos = safecatn(message, sizeof message, pos, dp->output_bit_depth); + pos = safecat(message, sizeof message, pos, " expected "); + pos = safecatn(message, sizeof message, pos, test_pixel.bit_depth); + + png_error(pp, message); + } + } +} + +static void PNGCBAPI +transform_info(png_structp pp, png_infop pi) +{ + transform_info_imp(voidcast(transform_display*, png_get_progressive_ptr(pp)), + pp, pi); +} + +static void +transform_range_check(png_const_structp pp, unsigned int r, unsigned int g, + unsigned int b, unsigned int a, unsigned int in_digitized, double in, + unsigned int out, png_byte sample_depth, double err, double limit, + const char *name, double digitization_error) +{ + /* Compare the scaled, digitzed, values of our local calculation (in+-err) + * with the digitized values libpng produced; 'sample_depth' is the actual + * digitization depth of the libpng output colors (the bit depth except for + * palette images where it is always 8.) The check on 'err' is to detect + * internal errors in pngvalid itself. + */ + unsigned int max = (1U< limit ||) !(out >= in_min && out <= in_max)) + { + char message[256]; + size_t pos; + + pos = safecat(message, sizeof message, 0, name); + pos = safecat(message, sizeof message, pos, " output value error: rgba("); + pos = safecatn(message, sizeof message, pos, r); + pos = safecat(message, sizeof message, pos, ","); + pos = safecatn(message, sizeof message, pos, g); + pos = safecat(message, sizeof message, pos, ","); + pos = safecatn(message, sizeof message, pos, b); + pos = safecat(message, sizeof message, pos, ","); + pos = safecatn(message, sizeof message, pos, a); + pos = safecat(message, sizeof message, pos, "): "); + pos = safecatn(message, sizeof message, pos, out); + pos = safecat(message, sizeof message, pos, " expected: "); + pos = safecatn(message, sizeof message, pos, in_digitized); + pos = safecat(message, sizeof message, pos, " ("); + pos = safecatd(message, sizeof message, pos, (in-err)*max, 3); + pos = safecat(message, sizeof message, pos, ".."); + pos = safecatd(message, sizeof message, pos, (in+err)*max, 3); + pos = safecat(message, sizeof message, pos, ")"); + + png_error(pp, message); + } + + UNUSED(limit) +} + +static void +transform_image_validate(transform_display *dp, png_const_structp pp, + png_infop pi) +{ + /* Constants for the loop below: */ + const png_store* const ps = dp->this.ps; + png_byte in_ct = dp->this.colour_type; + png_byte in_bd = dp->this.bit_depth; + png_uint_32 w = dp->this.w; + png_uint_32 h = dp->this.h; + png_byte out_ct = dp->output_colour_type; + png_byte out_bd = dp->output_bit_depth; + png_byte sample_depth = + (png_byte)(out_ct == PNG_COLOR_TYPE_PALETTE ? 8 : out_bd); + png_byte red_sBIT = dp->this.red_sBIT; + png_byte green_sBIT = dp->this.green_sBIT; + png_byte blue_sBIT = dp->this.blue_sBIT; + png_byte alpha_sBIT = dp->this.alpha_sBIT; + int have_tRNS = dp->this.is_transparent; + double digitization_error; + + store_palette out_palette; + png_uint_32 y; + + UNUSED(pi) + + /* Check for row overwrite errors */ + store_image_check(dp->this.ps, pp, 0); + + /* Read the palette corresponding to the output if the output colour type + * indicates a palette, otherwise set out_palette to garbage. + */ + if (out_ct == PNG_COLOR_TYPE_PALETTE) + { + /* Validate that the palette count itself has not changed - this is not + * expected. + */ + int npalette = (-1); + + (void)read_palette(out_palette, &npalette, pp, pi); + if (npalette != dp->this.npalette) + png_error(pp, "unexpected change in palette size"); + + digitization_error = .5; + } + else + { + png_byte in_sample_depth; + + memset(out_palette, 0x5e, sizeof out_palette); + + /* use-input-precision means assume that if the input has 8 bit (or less) + * samples and the output has 16 bit samples the calculations will be done + * with 8 bit precision, not 16. + */ + if (in_ct == PNG_COLOR_TYPE_PALETTE || in_bd < 16) + in_sample_depth = 8; + else + in_sample_depth = in_bd; + + if (sample_depth != 16 || in_sample_depth > 8 || + !dp->pm->calculations_use_input_precision) + digitization_error = .5; + + /* Else calculations are at 8 bit precision, and the output actually + * consists of scaled 8-bit values, so scale .5 in 8 bits to the 16 bits: + */ + else + digitization_error = .5 * 257; + } + + for (y=0; ythis.palette, + NULL); + + in_pixel.red_sBIT = red_sBIT; + in_pixel.green_sBIT = green_sBIT; + in_pixel.blue_sBIT = blue_sBIT; + in_pixel.alpha_sBIT = alpha_sBIT; + in_pixel.have_tRNS = have_tRNS != 0; + + /* For error detection, below. */ + r = in_pixel.red; + g = in_pixel.green; + b = in_pixel.blue; + a = in_pixel.alpha; + + /* This applies the transforms to the input data, including output + * format operations which must be used when reading the output + * pixel that libpng produces. + */ + dp->transform_list->mod(dp->transform_list, &in_pixel, pp, dp); + + /* Read the output pixel and compare it to what we got, we don't + * use the error field here, so no need to update sBIT. in_pixel + * says whether we expect libpng to change the output format. + */ + image_pixel_init(&out_pixel, pRow, out_ct, out_bd, x, out_palette, + &in_pixel); + + /* We don't expect changes to the index here even if the bit depth is + * changed. + */ + if (in_ct == PNG_COLOR_TYPE_PALETTE && + out_ct == PNG_COLOR_TYPE_PALETTE) + { + if (in_pixel.palette_index != out_pixel.palette_index) + png_error(pp, "unexpected transformed palette index"); + } + + /* Check the colours for palette images too - in fact the palette could + * be separately verified itself in most cases. + */ + if (in_pixel.red != out_pixel.red) + transform_range_check(pp, r, g, b, a, in_pixel.red, in_pixel.redf, + out_pixel.red, sample_depth, in_pixel.rede, + dp->pm->limit + 1./(2*((1U<pm->limit + 1./(2*((1U<pm->limit + 1./(2*((1U<pm->limit + 1./(2*((1U<this.ps->validated = 1; +} + +static void PNGCBAPI +transform_end(png_structp ppIn, png_infop pi) +{ + png_const_structp pp = ppIn; + transform_display *dp = voidcast(transform_display*, + png_get_progressive_ptr(pp)); + + if (!dp->this.speed) + transform_image_validate(dp, pp, pi); + else + dp->this.ps->validated = 1; +} + +/* A single test run. */ +static void +transform_test(png_modifier *pmIn, png_uint_32 idIn, + const image_transform* transform_listIn, const char * const name) +{ + transform_display d; + context(&pmIn->this, fault); + + transform_display_init(&d, pmIn, idIn, transform_listIn); + + Try + { + size_t pos = 0; + png_structp pp; + png_infop pi; + char full_name[256]; + + /* Make sure the encoding fields are correct and enter the required + * modifications. + */ + transform_set_encoding(&d); + + /* Add any modifications required by the transform list. */ + d.transform_list->ini(d.transform_list, &d); + + /* Add the color space information, if any, to the name. */ + pos = safecat(full_name, sizeof full_name, pos, name); + pos = safecat_current_encoding(full_name, sizeof full_name, pos, d.pm); + + /* Get a png_struct for reading the image. */ + pp = set_modifier_for_read(d.pm, &pi, d.this.id, full_name); + standard_palette_init(&d.this); + +# if 0 + /* Logging (debugging only) */ + { + char buffer[256]; + + (void)store_message(&d.pm->this, pp, buffer, sizeof buffer, 0, + "running test"); + + fprintf(stderr, "%s\n", buffer); + } +# endif + + /* Introduce the correct read function. */ + if (d.pm->this.progressive) + { + /* Share the row function with the standard implementation. */ + png_set_progressive_read_fn(pp, &d, transform_info, progressive_row, + transform_end); + + /* Now feed data into the reader until we reach the end: */ + modifier_progressive_read(d.pm, pp, pi); + } + else + { + /* modifier_read expects a png_modifier* */ + png_set_read_fn(pp, d.pm, modifier_read); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* Process the 'info' requirements. Only one image is generated */ + transform_info_imp(&d, pp, pi); + + sequential_row(&d.this, pp, pi, -1, 0); + + if (!d.this.speed) + transform_image_validate(&d, pp, pi); + else + d.this.ps->validated = 1; + } + + modifier_reset(d.pm); + } + + Catch(fault) + { + modifier_reset(voidcast(png_modifier*,(void*)fault)); + } +} + +/* The transforms: */ +#define ITSTRUCT(name) image_transform_##name +#define ITDATA(name) image_transform_data_##name +#define image_transform_ini image_transform_default_ini +#define IT(name)\ +static image_transform ITSTRUCT(name) =\ +{\ + #name,\ + 1, /*enable*/\ + &PT, /*list*/\ + 0, /*global_use*/\ + 0, /*local_use*/\ + 0, /*next*/\ + image_transform_ini,\ + image_transform_png_set_##name##_set,\ + image_transform_png_set_##name##_mod,\ + image_transform_png_set_##name##_add\ +} +#define PT ITSTRUCT(end) /* stores the previous transform */ + +/* To save code: */ +extern void image_transform_default_ini(const image_transform *this, + transform_display *that); /* silence GCC warnings */ + +void /* private, but almost always needed */ +image_transform_default_ini(const image_transform *this, + transform_display *that) +{ + this->next->ini(this->next, that); +} + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +static int +image_transform_default_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return 1; +} +#endif + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_palette_to_rgb */ +static void +image_transform_png_set_palette_to_rgb_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_palette_to_rgb(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_palette_to_rgb_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_palette_to_rgb_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type == PNG_COLOR_TYPE_PALETTE; +} + +IT(palette_to_rgb); +#undef PT +#define PT ITSTRUCT(palette_to_rgb) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_tRNS_to_alpha */ +static void +image_transform_png_set_tRNS_to_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_tRNS_to_alpha(pp); + + /* If there was a tRNS chunk that would get expanded and add an alpha + * channel is_transparent must be updated: + */ + if (that->this.has_tRNS) + that->this.is_transparent = 1; + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ +#if PNG_LIBPNG_VER < 10700 + /* LIBPNG BUG: this always forces palette images to RGB. */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); +#endif + + /* This effectively does an 'expand' only if there is some transparency to + * convert to an alpha channel. + */ + if (that->have_tRNS) +# if PNG_LIBPNG_VER >= 10700 + if (that->colour_type != PNG_COLOR_TYPE_PALETTE && + (that->colour_type & PNG_COLOR_MASK_ALPHA) == 0) +# endif + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + +#if PNG_LIBPNG_VER < 10700 + /* LIBPNG BUG: otherwise libpng still expands to 8 bits! */ + else + { + if (that->bit_depth < 8) + that->bit_depth =8; + if (that->sample_depth < 8) + that->sample_depth = 8; + } +#endif + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_tRNS_to_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* We don't know yet whether there will be a tRNS chunk, but we know that + * this transformation should do nothing if there already is an alpha + * channel. In addition, after the bug fix in 1.7.0, there is no longer + * any action on a palette image. + */ + return +# if PNG_LIBPNG_VER >= 10700 + colour_type != PNG_COLOR_TYPE_PALETTE && +# endif + (colour_type & PNG_COLOR_MASK_ALPHA) == 0; +} + +IT(tRNS_to_alpha); +#undef PT +#define PT ITSTRUCT(tRNS_to_alpha) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED +/* png_set_gray_to_rgb */ +static void +image_transform_png_set_gray_to_rgb_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_gray_to_rgb(pp); + /* NOTE: this doesn't result in tRNS expansion. */ + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_gray_to_rgb_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* NOTE: we can actually pend the tRNS processing at this point because we + * can correctly recognize the original pixel value even though we have + * mapped the one gray channel to the three RGB ones, but in fact libpng + * doesn't do this, so we don't either. + */ + if ((that->colour_type & PNG_COLOR_MASK_COLOR) == 0 && that->have_tRNS) + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + /* Simply expand the bit depth and alter the colour type as required. */ + if (that->colour_type == PNG_COLOR_TYPE_GRAY) + { + /* RGB images have a bit depth at least equal to '8' */ + if (that->bit_depth < 8) + that->sample_depth = that->bit_depth = 8; + + /* And just changing the colour type works here because the green and blue + * channels are being maintained in lock-step with the red/gray: + */ + that->colour_type = PNG_COLOR_TYPE_RGB; + } + + else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_RGB_ALPHA; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_gray_to_rgb_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return (colour_type & PNG_COLOR_MASK_COLOR) == 0; +} + +IT(gray_to_rgb); +#undef PT +#define PT ITSTRUCT(gray_to_rgb) +#endif /* PNG_READ_GRAY_TO_RGB_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_expand */ +static void +image_transform_png_set_expand_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_expand(pp); + + if (that->this.has_tRNS) + that->this.is_transparent = 1; + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_expand_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* The general expand case depends on what the colour type is: */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); + else if (that->bit_depth < 8) /* grayscale */ + that->sample_depth = that->bit_depth = 8; + + if (that->have_tRNS) + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_expand_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* 'expand' should do nothing for RGBA or GA input - no tRNS and the bit + * depth is at least 8 already. + */ + return (colour_type & PNG_COLOR_MASK_ALPHA) == 0; +} + +IT(expand); +#undef PT +#define PT ITSTRUCT(expand) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_SUPPORTED +/* png_set_expand_gray_1_2_4_to_8 + * Pre 1.7.0 LIBPNG BUG: this just does an 'expand' + */ +static void +image_transform_png_set_expand_gray_1_2_4_to_8_set( + const image_transform *this, transform_display *that, png_structp pp, + png_infop pi) +{ + png_set_expand_gray_1_2_4_to_8(pp); + /* NOTE: don't expect this to expand tRNS */ + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_expand_gray_1_2_4_to_8_mod( + const image_transform *this, image_pixel *that, png_const_structp pp, + const transform_display *display) +{ +#if PNG_LIBPNG_VER < 10700 + image_transform_png_set_expand_mod(this, that, pp, display); +#else + /* Only expand grayscale of bit depth less than 8: */ + if (that->colour_type == PNG_COLOR_TYPE_GRAY && + that->bit_depth < 8) + that->sample_depth = that->bit_depth = 8; + + this->next->mod(this->next, that, pp, display); +#endif /* 1.7 or later */ +} + +static int +image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ +#if PNG_LIBPNG_VER < 10700 + return image_transform_png_set_expand_add(this, that, colour_type, + bit_depth); +#else + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* This should do nothing unless the color type is gray and the bit depth is + * less than 8: + */ + return colour_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8; +#endif /* 1.7 or later */ +} + +IT(expand_gray_1_2_4_to_8); +#undef PT +#define PT ITSTRUCT(expand_gray_1_2_4_to_8) +#endif /* PNG_READ_EXPAND_SUPPORTED */ + +#ifdef PNG_READ_EXPAND_16_SUPPORTED +/* png_set_expand_16 */ +static void +image_transform_png_set_expand_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_expand_16(pp); + + /* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */ +# if PNG_LIBPNG_VER < 10700 + if (that->this.has_tRNS) + that->this.is_transparent = 1; +# endif + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_expand_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* Expect expand_16 to expand everything to 16 bits as a result of also + * causing 'expand' to happen. + */ + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); + + if (that->have_tRNS) + image_pixel_add_alpha(that, &display->this, 0/*!for background*/); + + if (that->bit_depth < 16) + that->sample_depth = that->bit_depth = 16; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_expand_16_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + /* expand_16 does something unless the bit depth is already 16. */ + return bit_depth < 16; +} + +IT(expand_16); +#undef PT +#define PT ITSTRUCT(expand_16) +#endif /* PNG_READ_EXPAND_16_SUPPORTED */ + +#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED /* API added in 1.5.4 */ +/* png_set_scale_16 */ +static void +image_transform_png_set_scale_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_scale_16(pp); +# if PNG_LIBPNG_VER < 10700 + /* libpng will limit the gamma table size: */ + that->max_gamma_8 = PNG_MAX_GAMMA_8; +# endif + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_scale_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth == 16) + { + that->sample_depth = that->bit_depth = 8; + if (that->red_sBIT > 8) that->red_sBIT = 8; + if (that->green_sBIT > 8) that->green_sBIT = 8; + if (that->blue_sBIT > 8) that->blue_sBIT = 8; + if (that->alpha_sBIT > 8) that->alpha_sBIT = 8; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_scale_16_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth > 8; +} + +IT(scale_16); +#undef PT +#define PT ITSTRUCT(scale_16) +#endif /* PNG_READ_SCALE_16_TO_8_SUPPORTED (1.5.4 on) */ + +#ifdef PNG_READ_16_TO_8_SUPPORTED /* the default before 1.5.4 */ +/* png_set_strip_16 */ +static void +image_transform_png_set_strip_16_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_strip_16(pp); +# if PNG_LIBPNG_VER < 10700 + /* libpng will limit the gamma table size: */ + that->max_gamma_8 = PNG_MAX_GAMMA_8; +# endif + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_strip_16_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth == 16) + { + that->sample_depth = that->bit_depth = 8; + if (that->red_sBIT > 8) that->red_sBIT = 8; + if (that->green_sBIT > 8) that->green_sBIT = 8; + if (that->blue_sBIT > 8) that->blue_sBIT = 8; + if (that->alpha_sBIT > 8) that->alpha_sBIT = 8; + + /* Prior to 1.5.4 png_set_strip_16 would use an 'accurate' method if this + * configuration option is set. From 1.5.4 the flag is never set and the + * 'scale' API (above) must be used. + */ +# ifdef PNG_READ_ACCURATE_SCALE_SUPPORTED +# if PNG_LIBPNG_VER >= 10504 +# error PNG_READ_ACCURATE_SCALE should not be set +# endif + + /* The strip 16 algorithm drops the low 8 bits rather than calculating + * 1/257, so we need to adjust the permitted errors appropriately: + * Notice that this is only relevant prior to the addition of the + * png_set_scale_16 API in 1.5.4 (but 1.5.4+ always defines the above!) + */ + { + const double d = (255-128.5)/65535; + that->rede += d; + that->greene += d; + that->bluee += d; + that->alphae += d; + } +# endif + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_strip_16_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth > 8; +} + +IT(strip_16); +#undef PT +#define PT ITSTRUCT(strip_16) +#endif /* PNG_READ_16_TO_8_SUPPORTED */ + +#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED +/* png_set_strip_alpha */ +static void +image_transform_png_set_strip_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_strip_alpha(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_strip_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY; + else if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) + that->colour_type = PNG_COLOR_TYPE_RGB; + + that->have_tRNS = 0; + that->alphaf = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_strip_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return (colour_type & PNG_COLOR_MASK_ALPHA) != 0; +} + +IT(strip_alpha); +#undef PT +#define PT ITSTRUCT(strip_alpha) +#endif /* PNG_READ_STRIP_ALPHA_SUPPORTED */ + +#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED +/* png_set_rgb_to_gray(png_structp, int err_action, double red, double green) + * png_set_rgb_to_gray_fixed(png_structp, int err_action, png_fixed_point red, + * png_fixed_point green) + * png_get_rgb_to_gray_status + * + * The 'default' test here uses values known to be used inside libpng prior to + * 1.7.0: + * + * red: 6968 + * green: 23434 + * blue: 2366 + * + * These values are being retained for compatibility, along with the somewhat + * broken truncation calculation in the fast-and-inaccurate code path. Older + * versions of libpng will fail the accuracy tests below because they use the + * truncation algorithm everywhere. + */ +#define data ITDATA(rgb_to_gray) +static struct +{ + double gamma; /* File gamma to use in processing */ + + /* The following are the parameters for png_set_rgb_to_gray: */ +# ifdef PNG_FLOATING_POINT_SUPPORTED + double red_to_set; + double green_to_set; +# else + png_fixed_point red_to_set; + png_fixed_point green_to_set; +# endif + + /* The actual coefficients: */ + double red_coefficient; + double green_coefficient; + double blue_coefficient; + + /* Set if the coeefficients have been overridden. */ + int coefficients_overridden; +} data; + +#undef image_transform_ini +#define image_transform_ini image_transform_png_set_rgb_to_gray_ini +static void +image_transform_png_set_rgb_to_gray_ini(const image_transform *this, + transform_display *that) +{ + png_modifier *pm = that->pm; + const color_encoding *e = pm->current_encoding; + + UNUSED(this) + + /* Since we check the encoding this flag must be set: */ + pm->test_uses_encoding = 1; + + /* If 'e' is not NULL chromaticity information is present and either a cHRM + * or an sRGB chunk will be inserted. + */ + if (e != 0) + { + /* Coefficients come from the encoding, but may need to be normalized to a + * white point Y of 1.0 + */ + const double whiteY = e->red.Y + e->green.Y + e->blue.Y; + + data.red_coefficient = e->red.Y; + data.green_coefficient = e->green.Y; + data.blue_coefficient = e->blue.Y; + + if (whiteY != 1) + { + data.red_coefficient /= whiteY; + data.green_coefficient /= whiteY; + data.blue_coefficient /= whiteY; + } + } + + else + { + /* The default (built in) coeffcients, as above: */ +# if PNG_LIBPNG_VER < 10700 + data.red_coefficient = 6968 / 32768.; + data.green_coefficient = 23434 / 32768.; + data.blue_coefficient = 2366 / 32768.; +# else + data.red_coefficient = .2126; + data.green_coefficient = .7152; + data.blue_coefficient = .0722; +# endif + } + + data.gamma = pm->current_gamma; + + /* If not set then the calculations assume linear encoding (implicitly): */ + if (data.gamma == 0) + data.gamma = 1; + + /* The arguments to png_set_rgb_to_gray can override the coefficients implied + * by the color space encoding. If doing exhaustive checks do the override + * in each case, otherwise do it randomly. + */ + if (pm->test_exhaustive) + { + /* First time in coefficients_overridden is 0, the following sets it to 1, + * so repeat if it is set. If a test fails this may mean we subsequently + * skip a non-override test, ignore that. + */ + data.coefficients_overridden = !data.coefficients_overridden; + pm->repeat = data.coefficients_overridden != 0; + } + + else + data.coefficients_overridden = random_choice(); + + if (data.coefficients_overridden) + { + /* These values override the color encoding defaults, simply use random + * numbers. + */ + png_uint_32 ru; + double total; + + ru = random_u32(); + data.green_coefficient = total = (ru & 0xffff) / 65535.; + ru >>= 16; + data.red_coefficient = (1 - total) * (ru & 0xffff) / 65535.; + total += data.red_coefficient; + data.blue_coefficient = 1 - total; + +# ifdef PNG_FLOATING_POINT_SUPPORTED + data.red_to_set = data.red_coefficient; + data.green_to_set = data.green_coefficient; +# else + data.red_to_set = fix(data.red_coefficient); + data.green_to_set = fix(data.green_coefficient); +# endif + + /* The following just changes the error messages: */ + pm->encoding_ignored = 1; + } + + else + { + data.red_to_set = -1; + data.green_to_set = -1; + } + + /* Adjust the error limit in the png_modifier because of the larger errors + * produced in the digitization during the gamma handling. + */ + if (data.gamma != 1) /* Use gamma tables */ + { + if (that->this.bit_depth == 16 || pm->assume_16_bit_calculations) + { + /* The computations have the form: + * + * r * rc + g * gc + b * bc + * + * Each component of which is +/-1/65535 from the gamma_to_1 table + * lookup, resulting in a base error of +/-6. The gamma_from_1 + * conversion adds another +/-2 in the 16-bit case and + * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. + */ +# if PNG_LIBPNG_VER < 10700 + if (that->this.bit_depth < 16) + that->max_gamma_8 = PNG_MAX_GAMMA_8; +# endif + that->pm->limit += pow( + (that->this.bit_depth == 16 || that->max_gamma_8 > 14 ? + 8. : + 6. + (1<<(15-that->max_gamma_8)) + )/65535, data.gamma); + } + + else + { + /* Rounding to 8 bits in the linear space causes massive errors which + * will trigger the error check in transform_range_check. Fix that + * here by taking the gamma encoding into account. + * + * When DIGITIZE is set because a pre-1.7 version of libpng is being + * tested allow a bigger slack. + * + * NOTE: this number only affects the internal limit check in pngvalid, + * it has no effect on the limits applied to the libpng values. + */ +#if DIGITIZE + that->pm->limit += pow( 2.0/255, data.gamma); +#else + that->pm->limit += pow( 1.0/255, data.gamma); +#endif + } + } + + else + { + /* With no gamma correction a large error comes from the truncation of the + * calculation in the 8 bit case, allow for that here. + */ + if (that->this.bit_depth != 16 && !pm->assume_16_bit_calculations) + that->pm->limit += 4E-3; + } +} + +static void +image_transform_png_set_rgb_to_gray_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + int error_action = 1; /* no error, no defines in png.h */ + +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_rgb_to_gray(pp, error_action, data.red_to_set, data.green_to_set); +# else + png_set_rgb_to_gray_fixed(pp, error_action, data.red_to_set, + data.green_to_set); +# endif + +# ifdef PNG_READ_cHRM_SUPPORTED + if (that->pm->current_encoding != 0) + { + /* We have an encoding so a cHRM chunk may have been set; if so then + * check that the libpng APIs give the correct (X,Y,Z) values within + * some margin of error for the round trip through the chromaticity + * form. + */ +# ifdef PNG_FLOATING_POINT_SUPPORTED +# define API_function png_get_cHRM_XYZ +# define API_form "FP" +# define API_type double +# define API_cvt(x) (x) +# else +# define API_function png_get_cHRM_XYZ_fixed +# define API_form "fixed" +# define API_type png_fixed_point +# define API_cvt(x) ((double)(x)/PNG_FP_1) +# endif + + API_type rX, gX, bX; + API_type rY, gY, bY; + API_type rZ, gZ, bZ; + + if ((API_function(pp, pi, &rX, &rY, &rZ, &gX, &gY, &gZ, &bX, &bY, &bZ) + & PNG_INFO_cHRM) != 0) + { + double maxe; + const char *el; + color_encoding e, o; + + /* Expect libpng to return a normalized result, but the original + * color space encoding may not be normalized. + */ + modifier_current_encoding(that->pm, &o); + normalize_color_encoding(&o); + + /* Sanity check the pngvalid code - the coefficients should match + * the normalized Y values of the encoding unless they were + * overridden. + */ + if (data.red_to_set == -1 && data.green_to_set == -1 && + (fabs(o.red.Y - data.red_coefficient) > DBL_EPSILON || + fabs(o.green.Y - data.green_coefficient) > DBL_EPSILON || + fabs(o.blue.Y - data.blue_coefficient) > DBL_EPSILON)) + png_error(pp, "internal pngvalid cHRM coefficient error"); + + /* Generate a colour space encoding. */ + e.gamma = o.gamma; /* not used */ + e.red.X = API_cvt(rX); + e.red.Y = API_cvt(rY); + e.red.Z = API_cvt(rZ); + e.green.X = API_cvt(gX); + e.green.Y = API_cvt(gY); + e.green.Z = API_cvt(gZ); + e.blue.X = API_cvt(bX); + e.blue.Y = API_cvt(bY); + e.blue.Z = API_cvt(bZ); + + /* This should match the original one from the png_modifier, within + * the range permitted by the libpng fixed point representation. + */ + maxe = 0; + el = "-"; /* Set to element name with error */ + +# define CHECK(col,x)\ + {\ + double err = fabs(o.col.x - e.col.x);\ + if (err > maxe)\ + {\ + maxe = err;\ + el = #col "(" #x ")";\ + }\ + } + + CHECK(red,X) + CHECK(red,Y) + CHECK(red,Z) + CHECK(green,X) + CHECK(green,Y) + CHECK(green,Z) + CHECK(blue,X) + CHECK(blue,Y) + CHECK(blue,Z) + + /* Here in both fixed and floating cases to check the values read + * from the cHRm chunk. PNG uses fixed point in the cHRM chunk, so + * we can't expect better than +/-.5E-5 on the result, allow 1E-5. + */ + if (maxe >= 1E-5) + { + size_t pos = 0; + char buffer[256]; + + pos = safecat(buffer, sizeof buffer, pos, API_form); + pos = safecat(buffer, sizeof buffer, pos, " cHRM "); + pos = safecat(buffer, sizeof buffer, pos, el); + pos = safecat(buffer, sizeof buffer, pos, " error: "); + pos = safecatd(buffer, sizeof buffer, pos, maxe, 7); + pos = safecat(buffer, sizeof buffer, pos, " "); + /* Print the color space without the gamma value: */ + pos = safecat_color_encoding(buffer, sizeof buffer, pos, &o, 0); + pos = safecat(buffer, sizeof buffer, pos, " -> "); + pos = safecat_color_encoding(buffer, sizeof buffer, pos, &e, 0); + + png_error(pp, buffer); + } + } + } +# endif /* READ_cHRM */ + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_rgb_to_gray_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if ((that->colour_type & PNG_COLOR_MASK_COLOR) != 0) + { + double gray, err; + +# if PNG_LIBPNG_VER < 10700 + if (that->colour_type == PNG_COLOR_TYPE_PALETTE) + image_pixel_convert_PLTE(that); +# endif + + /* Image now has RGB channels... */ +# if DIGITIZE + { + png_modifier *pm = display->pm; + unsigned int sample_depth = that->sample_depth; + unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 : + sample_depth); + unsigned int gamma_depth = + (sample_depth == 16 ? + display->max_gamma_8 : + (pm->assume_16_bit_calculations ? + display->max_gamma_8 : + sample_depth)); + int isgray; + double r, g, b; + double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi; + + /* Do this using interval arithmetic, otherwise it is too difficult to + * handle the errors correctly. + * + * To handle the gamma correction work out the upper and lower bounds + * of the digitized value. Assume rounding here - normally the values + * will be identical after this operation if there is only one + * transform, feel free to delete the png_error checks on this below in + * the future (this is just me trying to ensure it works!) + * + * Interval arithmetic is exact, but to implement it it must be + * possible to control the floating point implementation rounding mode. + * This cannot be done in ANSI-C, so instead I reduce the 'lo' values + * by DBL_EPSILON and increase the 'hi' values by the same. + */ +# define DD(v,d,r) (digitize(v*(1-DBL_EPSILON), d, r) * (1-DBL_EPSILON)) +# define DU(v,d,r) (digitize(v*(1+DBL_EPSILON), d, r) * (1+DBL_EPSILON)) + + r = rlo = rhi = that->redf; + rlo -= that->rede; + rlo = DD(rlo, calc_depth, 1/*round*/); + rhi += that->rede; + rhi = DU(rhi, calc_depth, 1/*round*/); + + g = glo = ghi = that->greenf; + glo -= that->greene; + glo = DD(glo, calc_depth, 1/*round*/); + ghi += that->greene; + ghi = DU(ghi, calc_depth, 1/*round*/); + + b = blo = bhi = that->bluef; + blo -= that->bluee; + blo = DD(blo, calc_depth, 1/*round*/); + bhi += that->bluee; + bhi = DU(bhi, calc_depth, 1/*round*/); + + isgray = r==g && g==b; + + if (data.gamma != 1) + { + const double power = 1/data.gamma; + const double abse = .5/(sample_depth == 16 ? 65535 : 255); + + /* If a gamma calculation is done it is done using lookup tables of + * precision gamma_depth, so the already digitized value above may + * need to be further digitized here. + */ + if (gamma_depth != calc_depth) + { + rlo = DD(rlo, gamma_depth, 0/*truncate*/); + rhi = DU(rhi, gamma_depth, 0/*truncate*/); + glo = DD(glo, gamma_depth, 0/*truncate*/); + ghi = DU(ghi, gamma_depth, 0/*truncate*/); + blo = DD(blo, gamma_depth, 0/*truncate*/); + bhi = DU(bhi, gamma_depth, 0/*truncate*/); + } + + /* 'abse' is the error in the gamma table calculation itself. */ + r = pow(r, power); + rlo = DD(pow(rlo, power)-abse, calc_depth, 1); + rhi = DU(pow(rhi, power)+abse, calc_depth, 1); + + g = pow(g, power); + glo = DD(pow(glo, power)-abse, calc_depth, 1); + ghi = DU(pow(ghi, power)+abse, calc_depth, 1); + + b = pow(b, power); + blo = DD(pow(blo, power)-abse, calc_depth, 1); + bhi = DU(pow(bhi, power)+abse, calc_depth, 1); + } + + /* Now calculate the actual gray values. Although the error in the + * coefficients depends on whether they were specified on the command + * line (in which case truncation to 15 bits happened) or not (rounding + * was used) the maximum error in an individual coefficient is always + * 2/32768, because even in the rounding case the requirement that + * coefficients add up to 32768 can cause a larger rounding error. + * + * The only time when rounding doesn't occur in 1.5.5 and later is when + * the non-gamma code path is used for less than 16 bit data. + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient; + + { + int do_round = data.gamma != 1 || calc_depth == 16; + const double ce = 2. / 32768; + + graylo = DD(rlo * (data.red_coefficient-ce) + + glo * (data.green_coefficient-ce) + + blo * (data.blue_coefficient-ce), calc_depth, do_round); + if (graylo > gray) /* always accept the right answer */ + graylo = gray; + + grayhi = DU(rhi * (data.red_coefficient+ce) + + ghi * (data.green_coefficient+ce) + + bhi * (data.blue_coefficient+ce), calc_depth, do_round); + if (grayhi < gray) + grayhi = gray; + } + + /* And invert the gamma. */ + if (data.gamma != 1) + { + const double power = data.gamma; + + /* And this happens yet again, shifting the values once more. */ + if (gamma_depth != sample_depth) + { + rlo = DD(rlo, gamma_depth, 0/*truncate*/); + rhi = DU(rhi, gamma_depth, 0/*truncate*/); + glo = DD(glo, gamma_depth, 0/*truncate*/); + ghi = DU(ghi, gamma_depth, 0/*truncate*/); + blo = DD(blo, gamma_depth, 0/*truncate*/); + bhi = DU(bhi, gamma_depth, 0/*truncate*/); + } + + gray = pow(gray, power); + graylo = DD(pow(graylo, power), sample_depth, 1); + grayhi = DU(pow(grayhi, power), sample_depth, 1); + } + +# undef DD +# undef DU + + /* Now the error can be calculated. + * + * If r==g==b because there is no overall gamma correction libpng + * currently preserves the original value. + */ + if (isgray) + err = (that->rede + that->greene + that->bluee)/3; + + else + { + err = fabs(grayhi-gray); + + if (fabs(gray - graylo) > err) + err = fabs(graylo-gray); + +#if !RELEASE_BUILD + /* Check that this worked: */ + if (err > pm->limit) + { + size_t pos = 0; + char buffer[128]; + + pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error "); + pos = safecatd(buffer, sizeof buffer, pos, err, 6); + pos = safecat(buffer, sizeof buffer, pos, " exceeds limit "); + pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6); + png_warning(pp, buffer); + pm->limit = err; + } +#endif /* !RELEASE_BUILD */ + } + } +# else /* !DIGITIZE */ + { + double r = that->redf; + double re = that->rede; + double g = that->greenf; + double ge = that->greene; + double b = that->bluef; + double be = that->bluee; + +# if PNG_LIBPNG_VER < 10700 + /* The true gray case involves no math in earlier versions (not + * true, there was some if gamma correction was happening too.) + */ + if (r == g && r == b) + { + gray = r; + err = re; + if (err < ge) err = ge; + if (err < be) err = be; + } + + else +# endif /* before 1.7 */ + if (data.gamma == 1) + { + /* There is no need to do the conversions to and from linear space, + * so the calculation should be a lot more accurate. There is a + * built in error in the coefficients because they only have 15 bits + * and are adjusted to make sure they add up to 32768. This + * involves a integer calculation with truncation of the form: + * + * ((int)(coefficient * 100000) * 32768)/100000 + * + * This is done to the red and green coefficients (the ones + * provided to the API) then blue is calculated from them so the + * result adds up to 32768. In the worst case this can result in + * a -1 error in red and green and a +2 error in blue. Consequently + * the worst case in the calculation below is 2/32768 error. + * + * TODO: consider fixing this in libpng by rounding the calculation + * limiting the error to 1/32768. + * + * Handling this by adding 2/32768 here avoids needing to increase + * the global error limits to take this into account.) + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient; + err = re * data.red_coefficient + ge * data.green_coefficient + + be * data.blue_coefficient + 2./32768 + gray * 5 * DBL_EPSILON; + } + + else + { + /* The calculation happens in linear space, and this produces much + * wider errors in the encoded space. These are handled here by + * factoring the errors in to the calculation. There are two table + * lookups in the calculation and each introduces a quantization + * error defined by the table size. + */ + png_modifier *pm = display->pm; + double in_qe = (that->sample_depth > 8 ? .5/65535 : .5/255); + double out_qe = (that->sample_depth > 8 ? .5/65535 : + (pm->assume_16_bit_calculations ? .5/(1<max_gamma_8) : + .5/255)); + double rhi, ghi, bhi, grayhi; + double g1 = 1/data.gamma; + + rhi = r + re + in_qe; if (rhi > 1) rhi = 1; + r -= re + in_qe; if (r < 0) r = 0; + ghi = g + ge + in_qe; if (ghi > 1) ghi = 1; + g -= ge + in_qe; if (g < 0) g = 0; + bhi = b + be + in_qe; if (bhi > 1) bhi = 1; + b -= be + in_qe; if (b < 0) b = 0; + + r = pow(r, g1)*(1-DBL_EPSILON); rhi = pow(rhi, g1)*(1+DBL_EPSILON); + g = pow(g, g1)*(1-DBL_EPSILON); ghi = pow(ghi, g1)*(1+DBL_EPSILON); + b = pow(b, g1)*(1-DBL_EPSILON); bhi = pow(bhi, g1)*(1+DBL_EPSILON); + + /* Work out the lower and upper bounds for the gray value in the + * encoded space, then work out an average and error. Remove the + * previously added input quantization error at this point. + */ + gray = r * data.red_coefficient + g * data.green_coefficient + + b * data.blue_coefficient - 2./32768 - out_qe; + if (gray <= 0) + gray = 0; + else + { + gray *= (1 - 6 * DBL_EPSILON); + gray = pow(gray, data.gamma) * (1-DBL_EPSILON); + } + + grayhi = rhi * data.red_coefficient + ghi * data.green_coefficient + + bhi * data.blue_coefficient + 2./32768 + out_qe; + grayhi *= (1 + 6 * DBL_EPSILON); + if (grayhi >= 1) + grayhi = 1; + else + grayhi = pow(grayhi, data.gamma) * (1+DBL_EPSILON); + + err = (grayhi - gray) / 2; + gray = (grayhi + gray) / 2; + + if (err <= in_qe) + err = gray * DBL_EPSILON; + + else + err -= in_qe; + +#if !RELEASE_BUILD + /* Validate that the error is within limits (this has caused + * problems before, it's much easier to detect them here.) + */ + if (err > pm->limit) + { + size_t pos = 0; + char buffer[128]; + + pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error "); + pos = safecatd(buffer, sizeof buffer, pos, err, 6); + pos = safecat(buffer, sizeof buffer, pos, " exceeds limit "); + pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6); + png_warning(pp, buffer); + pm->limit = err; + } +#endif /* !RELEASE_BUILD */ + } + } +# endif /* !DIGITIZE */ + + that->bluef = that->greenf = that->redf = gray; + that->bluee = that->greene = that->rede = err; + + /* The sBIT is the minimum of the three colour channel sBITs. */ + if (that->red_sBIT > that->green_sBIT) + that->red_sBIT = that->green_sBIT; + if (that->red_sBIT > that->blue_sBIT) + that->red_sBIT = that->blue_sBIT; + that->blue_sBIT = that->green_sBIT = that->red_sBIT; + + /* And remove the colour bit in the type: */ + if (that->colour_type == PNG_COLOR_TYPE_RGB) + that->colour_type = PNG_COLOR_TYPE_GRAY; + else if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY_ALPHA; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_rgb_to_gray_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return (colour_type & PNG_COLOR_MASK_COLOR) != 0; +} + +#undef data +IT(rgb_to_gray); +#undef PT +#define PT ITSTRUCT(rgb_to_gray) +#undef image_transform_ini +#define image_transform_ini image_transform_default_ini +#endif /* PNG_READ_RGB_TO_GRAY_SUPPORTED */ + +#ifdef PNG_READ_BACKGROUND_SUPPORTED +/* png_set_background(png_structp, png_const_color_16p background_color, + * int background_gamma_code, int need_expand, double background_gamma) + * png_set_background_fixed(png_structp, png_const_color_16p background_color, + * int background_gamma_code, int need_expand, + * png_fixed_point background_gamma) + * + * This ignores the gamma (at present.) +*/ +#define data ITDATA(background) +static image_pixel data; + +static void +image_transform_png_set_background_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_byte colour_type, bit_depth; + png_byte random_bytes[8]; /* 8 bytes - 64 bits - the biggest pixel */ + int expand; + png_color_16 back; + + /* We need a background colour, because we don't know exactly what transforms + * have been set we have to supply the colour in the original file format and + * so we need to know what that is! The background colour is stored in the + * transform_display. + */ + R8(random_bytes); + + /* Read the random value, for colour type 3 the background colour is actually + * expressed as a 24bit rgb, not an index. + */ + colour_type = that->this.colour_type; + if (colour_type == 3) + { + colour_type = PNG_COLOR_TYPE_RGB; + bit_depth = 8; + expand = 0; /* passing in an RGB not a pixel index */ + } + + else + { + if (that->this.has_tRNS) + that->this.is_transparent = 1; + + bit_depth = that->this.bit_depth; + expand = 1; + } + + image_pixel_init(&data, random_bytes, colour_type, + bit_depth, 0/*x*/, 0/*unused: palette*/, NULL/*format*/); + + /* Extract the background colour from this image_pixel, but make sure the + * unused fields of 'back' are garbage. + */ + R8(back); + + if (colour_type & PNG_COLOR_MASK_COLOR) + { + back.red = (png_uint_16)data.red; + back.green = (png_uint_16)data.green; + back.blue = (png_uint_16)data.blue; + } + + else + back.gray = (png_uint_16)data.red; + +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0); +#else + png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0); +#endif + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_background_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* Check for tRNS first: */ + if (that->have_tRNS && that->colour_type != PNG_COLOR_TYPE_PALETTE) + image_pixel_add_alpha(that, &display->this, 1/*for background*/); + + /* This is only necessary if the alpha value is less than 1. */ + if (that->alphaf < 1) + { + /* Now we do the background calculation without any gamma correction. */ + if (that->alphaf <= 0) + { + that->redf = data.redf; + that->greenf = data.greenf; + that->bluef = data.bluef; + + that->rede = data.rede; + that->greene = data.greene; + that->bluee = data.bluee; + + that->red_sBIT= data.red_sBIT; + that->green_sBIT= data.green_sBIT; + that->blue_sBIT= data.blue_sBIT; + } + + else /* 0 < alpha < 1 */ + { + double alf = 1 - that->alphaf; + + that->redf = that->redf * that->alphaf + data.redf * alf; + that->rede = that->rede * that->alphaf + data.rede * alf + + DBL_EPSILON; + that->greenf = that->greenf * that->alphaf + data.greenf * alf; + that->greene = that->greene * that->alphaf + data.greene * alf + + DBL_EPSILON; + that->bluef = that->bluef * that->alphaf + data.bluef * alf; + that->bluee = that->bluee * that->alphaf + data.bluee * alf + + DBL_EPSILON; + } + + /* Remove the alpha type and set the alpha (not in that order.) */ + that->alphaf = 1; + that->alphae = 0; + } + + if (that->colour_type == PNG_COLOR_TYPE_RGB_ALPHA) + that->colour_type = PNG_COLOR_TYPE_RGB; + else if (that->colour_type == PNG_COLOR_TYPE_GRAY_ALPHA) + that->colour_type = PNG_COLOR_TYPE_GRAY; + /* PNG_COLOR_TYPE_PALETTE is not changed */ + + this->next->mod(this->next, that, pp, display); +} + +#define image_transform_png_set_background_add image_transform_default_add + +#undef data +IT(background); +#undef PT +#define PT ITSTRUCT(background) +#endif /* PNG_READ_BACKGROUND_SUPPORTED */ + +/* png_set_quantize(png_structp, png_colorp palette, int num_palette, + * int maximum_colors, png_const_uint_16p histogram, int full_quantize) + * + * Very difficult to validate this! + */ +/*NOTE: TBD NYI */ + +/* The data layout transforms are handled by swapping our own channel data, + * necessarily these need to happen at the end of the transform list because the + * semantic of the channels changes after these are executed. Some of these, + * like set_shift and set_packing, can't be done at present because they change + * the layout of the data at the sub-sample level so sample() won't get the + * right answer. + */ +/* png_set_invert_alpha */ +#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED +/* Invert the alpha channel + * + * png_set_invert_alpha(png_structrp png_ptr) + */ +static void +image_transform_png_set_invert_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_invert_alpha(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_invert_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type & 4) + that->alpha_inverted = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_invert_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* Only has an effect on pixels with alpha: */ + return (colour_type & 4) != 0; +} + +IT(invert_alpha); +#undef PT +#define PT ITSTRUCT(invert_alpha) + +#endif /* PNG_READ_INVERT_ALPHA_SUPPORTED */ + +/* png_set_bgr */ +#ifdef PNG_READ_BGR_SUPPORTED +/* Swap R,G,B channels to order B,G,R. + * + * png_set_bgr(png_structrp png_ptr) + * + * This only has an effect on RGB and RGBA pixels. + */ +static void +image_transform_png_set_bgr_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_bgr(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_bgr_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_RGB || + that->colour_type == PNG_COLOR_TYPE_RGBA) + that->swap_rgb = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_bgr_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type == PNG_COLOR_TYPE_RGB || + colour_type == PNG_COLOR_TYPE_RGBA; +} + +IT(bgr); +#undef PT +#define PT ITSTRUCT(bgr) + +#endif /* PNG_READ_BGR_SUPPORTED */ + +/* png_set_swap_alpha */ +#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED +/* Put the alpha channel first. + * + * png_set_swap_alpha(png_structrp png_ptr) + * + * This only has an effect on GA and RGBA pixels. + */ +static void +image_transform_png_set_swap_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_swap_alpha(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_swap_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type == PNG_COLOR_TYPE_GA || + that->colour_type == PNG_COLOR_TYPE_RGBA) + that->alpha_first = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_swap_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type == PNG_COLOR_TYPE_GA || + colour_type == PNG_COLOR_TYPE_RGBA; +} + +IT(swap_alpha); +#undef PT +#define PT ITSTRUCT(swap_alpha) + +#endif /* PNG_READ_SWAP_ALPHA_SUPPORTED */ + +/* png_set_swap */ +#ifdef PNG_READ_SWAP_SUPPORTED +/* Byte swap 16-bit components. + * + * png_set_swap(png_structrp png_ptr) + */ +static void +image_transform_png_set_swap_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_swap(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_swap_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth == 16) + that->swap16 = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_swap_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth == 16; +} + +IT(swap); +#undef PT +#define PT ITSTRUCT(swap) + +#endif /* PNG_READ_SWAP_SUPPORTED */ + +#ifdef PNG_READ_FILLER_SUPPORTED +/* Add a filler byte to 8-bit Gray or 24-bit RGB images. + * + * png_set_filler, (png_structp png_ptr, png_uint_32 filler, int flags)); + * + * Flags: + * + * PNG_FILLER_BEFORE + * PNG_FILLER_AFTER + */ +#define data ITDATA(filler) +static struct +{ + png_uint_32 filler; + int flags; +} data; + +static void +image_transform_png_set_filler_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + /* Need a random choice for 'before' and 'after' as well as for the + * filler. The 'filler' value has all 32 bits set, but only bit_depth + * will be used. At this point we don't know bit_depth. + */ + data.filler = random_u32(); + data.flags = random_choice(); + + png_set_filler(pp, data.filler, data.flags); + + /* The standard display handling stuff also needs to know that + * there is a filler, so set that here. + */ + that->this.filler = 1; + + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_filler_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth >= 8 && + (that->colour_type == PNG_COLOR_TYPE_RGB || + that->colour_type == PNG_COLOR_TYPE_GRAY)) + { + unsigned int max = (1U << that->bit_depth)-1; + that->alpha = data.filler & max; + that->alphaf = ((double)that->alpha) / max; + that->alphae = 0; + + /* The filler has been stored in the alpha channel, we must record + * that this has been done for the checking later on, the color + * type is faked to have an alpha channel, but libpng won't report + * this; the app has to know the extra channel is there and this + * was recording in standard_display::filler above. + */ + that->colour_type |= 4; /* alpha added */ + that->alpha_first = data.flags == PNG_FILLER_BEFORE; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_filler_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + this->next = *that; + *that = this; + + return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || + colour_type == PNG_COLOR_TYPE_GRAY); +} + +#undef data +IT(filler); +#undef PT +#define PT ITSTRUCT(filler) + +/* png_set_add_alpha, (png_structp png_ptr, png_uint_32 filler, int flags)); */ +/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ +#define data ITDATA(add_alpha) +static struct +{ + png_uint_32 filler; + int flags; +} data; + +static void +image_transform_png_set_add_alpha_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + /* Need a random choice for 'before' and 'after' as well as for the + * filler. The 'filler' value has all 32 bits set, but only bit_depth + * will be used. At this point we don't know bit_depth. + */ + data.filler = random_u32(); + data.flags = random_choice(); + + png_set_add_alpha(pp, data.filler, data.flags); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_add_alpha_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth >= 8 && + (that->colour_type == PNG_COLOR_TYPE_RGB || + that->colour_type == PNG_COLOR_TYPE_GRAY)) + { + unsigned int max = (1U << that->bit_depth)-1; + that->alpha = data.filler & max; + that->alphaf = ((double)that->alpha) / max; + that->alphae = 0; + + that->colour_type |= 4; /* alpha added */ + that->alpha_first = data.flags == PNG_FILLER_BEFORE; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_add_alpha_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + this->next = *that; + *that = this; + + return bit_depth >= 8 && (colour_type == PNG_COLOR_TYPE_RGB || + colour_type == PNG_COLOR_TYPE_GRAY); +} + +#undef data +IT(add_alpha); +#undef PT +#define PT ITSTRUCT(add_alpha) + +#endif /* PNG_READ_FILLER_SUPPORTED */ + +/* png_set_packing */ +#ifdef PNG_READ_PACK_SUPPORTED +/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. + * + * png_set_packing(png_structrp png_ptr) + * + * This should only affect grayscale and palette images with less than 8 bits + * per pixel. + */ +static void +image_transform_png_set_packing_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_packing(pp); + that->unpacked = 1; + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_packing_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* The general expand case depends on what the colour type is, + * low bit-depth pixel values are unpacked into bytes without + * scaling, so sample_depth is not changed. + */ + if (that->bit_depth < 8) /* grayscale or palette */ + that->bit_depth = 8; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_packing_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + /* Nothing should happen unless the bit depth is less than 8: */ + return bit_depth < 8; +} + +IT(packing); +#undef PT +#define PT ITSTRUCT(packing) + +#endif /* PNG_READ_PACK_SUPPORTED */ + +/* png_set_packswap */ +#ifdef PNG_READ_PACKSWAP_SUPPORTED +/* Swap pixels packed into bytes; reverses the order on screen so that + * the high order bits correspond to the rightmost pixels. + * + * png_set_packswap(png_structrp png_ptr) + */ +static void +image_transform_png_set_packswap_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_packswap(pp); + that->this.littleendian = 1; + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_packswap_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->bit_depth < 8) + that->littleendian = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_packswap_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(colour_type) + + this->next = *that; + *that = this; + + return bit_depth < 8; +} + +IT(packswap); +#undef PT +#define PT ITSTRUCT(packswap) + +#endif /* PNG_READ_PACKSWAP_SUPPORTED */ + + +/* png_set_invert_mono */ +#ifdef PNG_READ_INVERT_MONO_SUPPORTED +/* Invert the gray channel + * + * png_set_invert_mono(png_structrp png_ptr) + */ +static void +image_transform_png_set_invert_mono_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_invert_mono(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_invert_mono_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + if (that->colour_type & 4) + that->mono_inverted = 1; + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_invert_mono_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + /* Only has an effect on pixels with no colour: */ + return (colour_type & 2) == 0; +} + +IT(invert_mono); +#undef PT +#define PT ITSTRUCT(invert_mono) + +#endif /* PNG_READ_INVERT_MONO_SUPPORTED */ + +#ifdef PNG_READ_SHIFT_SUPPORTED +/* png_set_shift(png_structp, png_const_color_8p true_bits) + * + * The output pixels will be shifted by the given true_bits + * values. + */ +#define data ITDATA(shift) +static png_color_8 data; + +static void +image_transform_png_set_shift_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + /* Get a random set of shifts. The shifts need to do something + * to test the transform, so they are limited to the bit depth + * of the input image. Notice that in the following the 'gray' + * field is randomized independently. This acts as a check that + * libpng does use the correct field. + */ + unsigned int depth = that->this.bit_depth; + + data.red = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.green = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.blue = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.gray = (png_byte)/*SAFE*/(random_mod(depth)+1); + data.alpha = (png_byte)/*SAFE*/(random_mod(depth)+1); + + png_set_shift(pp, &data); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_shift_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + /* Copy the correct values into the sBIT fields, libpng does not do + * anything to palette data: + */ + if (that->colour_type != PNG_COLOR_TYPE_PALETTE) + { + that->sig_bits = 1; + + /* The sBIT fields are reset to the values previously sent to + * png_set_shift according to the colour type. + * does. + */ + if (that->colour_type & 2) /* RGB channels */ + { + that->red_sBIT = data.red; + that->green_sBIT = data.green; + that->blue_sBIT = data.blue; + } + + else /* One grey channel */ + that->red_sBIT = that->green_sBIT = that->blue_sBIT = data.gray; + + that->alpha_sBIT = data.alpha; + } + + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_shift_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + UNUSED(bit_depth) + + this->next = *that; + *that = this; + + return colour_type != PNG_COLOR_TYPE_PALETTE; +} + +IT(shift); +#undef PT +#define PT ITSTRUCT(shift) + +#endif /* PNG_READ_SHIFT_SUPPORTED */ + +#ifdef THIS_IS_THE_PROFORMA +static void +image_transform_png_set_@_set(const image_transform *this, + transform_display *that, png_structp pp, png_infop pi) +{ + png_set_@(pp); + this->next->set(this->next, that, pp, pi); +} + +static void +image_transform_png_set_@_mod(const image_transform *this, + image_pixel *that, png_const_structp pp, + const transform_display *display) +{ + this->next->mod(this->next, that, pp, display); +} + +static int +image_transform_png_set_@_add(image_transform *this, + const image_transform **that, png_byte colour_type, png_byte bit_depth) +{ + this->next = *that; + *that = this; + + return 1; +} + +IT(@); +#endif + + +/* This may just be 'end' if all the transforms are disabled! */ +static image_transform *const image_transform_first = &PT; + +static void +transform_enable(const char *name) +{ + /* Everything starts out enabled, so if we see an 'enable' disabled + * everything else the first time round. + */ + static int all_disabled = 0; + int found_it = 0; + image_transform *list = image_transform_first; + + while (list != &image_transform_end) + { + if (strcmp(list->name, name) == 0) + { + list->enable = 1; + found_it = 1; + } + else if (!all_disabled) + list->enable = 0; + + list = list->list; + } + + all_disabled = 1; + + if (!found_it) + { + fprintf(stderr, "pngvalid: --transform-enable=%s: unknown transform\n", + name); + exit(99); + } +} + +static void +transform_disable(const char *name) +{ + image_transform *list = image_transform_first; + + while (list != &image_transform_end) + { + if (strcmp(list->name, name) == 0) + { + list->enable = 0; + return; + } + + list = list->list; + } + + fprintf(stderr, "pngvalid: --transform-disable=%s: unknown transform\n", + name); + exit(99); +} + +static void +image_transform_reset_count(void) +{ + image_transform *next = image_transform_first; + int count = 0; + + while (next != &image_transform_end) + { + next->local_use = 0; + next->next = 0; + next = next->list; + ++count; + } + + /* This can only happen if we every have more than 32 transforms (excluding + * the end) in the list. + */ + if (count > 32) abort(); +} + +static int +image_transform_test_counter(png_uint_32 counter, unsigned int max) +{ + /* Test the list to see if there is any point contining, given a current + * counter and a 'max' value. + */ + image_transform *next = image_transform_first; + + while (next != &image_transform_end) + { + /* For max 0 or 1 continue until the counter overflows: */ + counter >>= 1; + + /* Continue if any entry hasn't reacked the max. */ + if (max > 1 && next->local_use < max) + return 1; + next = next->list; + } + + return max <= 1 && counter == 0; +} + +static png_uint_32 +image_transform_add(const image_transform **this, unsigned int max, + png_uint_32 counter, char *name, size_t sizeof_name, size_t *pos, + png_byte colour_type, png_byte bit_depth) +{ + for (;;) /* until we manage to add something */ + { + png_uint_32 mask; + image_transform *list; + + /* Find the next counter value, if the counter is zero this is the start + * of the list. This routine always returns the current counter (not the + * next) so it returns 0 at the end and expects 0 at the beginning. + */ + if (counter == 0) /* first time */ + { + image_transform_reset_count(); + if (max <= 1) + counter = 1; + else + counter = random_32(); + } + else /* advance the counter */ + { + switch (max) + { + case 0: ++counter; break; + case 1: counter <<= 1; break; + default: counter = random_32(); break; + } + } + + /* Now add all these items, if possible */ + *this = &image_transform_end; + list = image_transform_first; + mask = 1; + + /* Go through the whole list adding anything that the counter selects: */ + while (list != &image_transform_end) + { + if ((counter & mask) != 0 && list->enable && + (max == 0 || list->local_use < max)) + { + /* Candidate to add: */ + if (list->add(list, this, colour_type, bit_depth) || max == 0) + { + /* Added, so add to the name too. */ + *pos = safecat(name, sizeof_name, *pos, " +"); + *pos = safecat(name, sizeof_name, *pos, list->name); + } + + else + { + /* Not useful and max>0, so remove it from *this: */ + *this = list->next; + list->next = 0; + + /* And, since we know it isn't useful, stop it being added again + * in this run: + */ + list->local_use = max; + } + } + + mask <<= 1; + list = list->list; + } + + /* Now if anything was added we have something to do. */ + if (*this != &image_transform_end) + return counter; + + /* Nothing added, but was there anything in there to add? */ + if (!image_transform_test_counter(counter, max)) + return 0; + } +} + +static void +perform_transform_test(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + while (next_format(&colour_type, &bit_depth, &palette_number, pm->test_lbg, + pm->test_tRNS)) + { + png_uint_32 counter = 0; + size_t base_pos; + char name[64]; + + base_pos = safecat(name, sizeof name, 0, "transform:"); + + for (;;) + { + size_t pos = base_pos; + const image_transform *list = 0; + + /* 'max' is currently hardwired to '1'; this should be settable on the + * command line. + */ + counter = image_transform_add(&list, 1/*max*/, counter, + name, sizeof name, &pos, colour_type, bit_depth); + + if (counter == 0) + break; + + /* The command line can change this to checking interlaced images. */ + do + { + pm->repeat = 0; + transform_test(pm, FILEID(colour_type, bit_depth, palette_number, + pm->interlace_type, 0, 0, 0), list, name); + + if (fail(pm)) + return; + } + while (pm->repeat); + } + } +} +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + +/********************************* GAMMA TESTS ********************************/ +#ifdef PNG_READ_GAMMA_SUPPORTED +/* Reader callbacks and implementations, where they differ from the standard + * ones. + */ +typedef struct gamma_display +{ + standard_display this; + + /* Parameters */ + png_modifier* pm; + double file_gamma; + double screen_gamma; + double background_gamma; + png_byte sbit; + int threshold_test; + int use_input_precision; + int scale16; + int expand16; + int do_background; + png_color_16 background_color; + + /* Local variables */ + double maxerrout; + double maxerrpc; + double maxerrabs; +} gamma_display; + +#define ALPHA_MODE_OFFSET 4 + +static void +gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id, + double file_gamma, double screen_gamma, png_byte sbit, int threshold_test, + int use_input_precision, int scale16, int expand16, + int do_background, const png_color_16 *pointer_to_the_background_color, + double background_gamma) +{ + /* Standard fields */ + standard_display_init(&dp->this, &pm->this, id, do_read_interlace, + pm->use_update_info); + + /* Parameter fields */ + dp->pm = pm; + dp->file_gamma = file_gamma; + dp->screen_gamma = screen_gamma; + dp->background_gamma = background_gamma; + dp->sbit = sbit; + dp->threshold_test = threshold_test; + dp->use_input_precision = use_input_precision; + dp->scale16 = scale16; + dp->expand16 = expand16; + dp->do_background = do_background; + if (do_background && pointer_to_the_background_color != 0) + dp->background_color = *pointer_to_the_background_color; + else + memset(&dp->background_color, 0, sizeof dp->background_color); + + /* Local variable fields */ + dp->maxerrout = dp->maxerrpc = dp->maxerrabs = 0; +} + +static void +gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi) +{ + /* Reuse the standard stuff as appropriate. */ + standard_info_part1(&dp->this, pp, pi); + + /* If requested strip 16 to 8 bits - this is handled automagically below + * because the output bit depth is read from the library. Note that there + * are interactions with sBIT but, internally, libpng makes sbit at most + * PNG_MAX_GAMMA_8 prior to 1.7 when doing the following. + */ + if (dp->scale16) +# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED + png_set_scale_16(pp); +# else + /* The following works both in 1.5.4 and earlier versions: */ +# ifdef PNG_READ_16_TO_8_SUPPORTED + png_set_strip_16(pp); +# else + png_error(pp, "scale16 (16 to 8 bit conversion) not supported"); +# endif +# endif + + if (dp->expand16) +# ifdef PNG_READ_EXPAND_16_SUPPORTED + png_set_expand_16(pp); +# else + png_error(pp, "expand16 (8 to 16 bit conversion) not supported"); +# endif + + if (dp->do_background >= ALPHA_MODE_OFFSET) + { +# ifdef PNG_READ_ALPHA_MODE_SUPPORTED + { + /* This tests the alpha mode handling, if supported. */ + int mode = dp->do_background - ALPHA_MODE_OFFSET; + + /* The gamma value is the output gamma, and is in the standard, + * non-inverted, representation. It provides a default for the PNG file + * gamma, but since the file has a gAMA chunk this does not matter. + */ + const double sg = dp->screen_gamma; +# ifndef PNG_FLOATING_POINT_SUPPORTED + png_fixed_point g = fix(sg); +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_alpha_mode(pp, mode, sg); +# else + png_set_alpha_mode_fixed(pp, mode, g); +# endif + + /* However, for the standard Porter-Duff algorithm the output defaults + * to be linear, so if the test requires non-linear output it must be + * corrected here. + */ + if (mode == PNG_ALPHA_STANDARD && sg != 1) + { +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_gamma(pp, sg, dp->file_gamma); +# else + png_fixed_point f = fix(dp->file_gamma); + png_set_gamma_fixed(pp, g, f); +# endif + } + } +# else + png_error(pp, "alpha mode handling not supported"); +# endif + } + + else + { + /* Set up gamma processing. */ +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_gamma(pp, dp->screen_gamma, dp->file_gamma); +# else + { + png_fixed_point s = fix(dp->screen_gamma); + png_fixed_point f = fix(dp->file_gamma); + png_set_gamma_fixed(pp, s, f); + } +# endif + + if (dp->do_background) + { +# ifdef PNG_READ_BACKGROUND_SUPPORTED + /* NOTE: this assumes the caller provided the correct background gamma! + */ + const double bg = dp->background_gamma; +# ifndef PNG_FLOATING_POINT_SUPPORTED + png_fixed_point g = fix(bg); +# endif + +# ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_background(pp, &dp->background_color, dp->do_background, + 0/*need_expand*/, bg); +# else + png_set_background_fixed(pp, &dp->background_color, + dp->do_background, 0/*need_expand*/, g); +# endif +# else + png_error(pp, "png_set_background not supported"); +# endif + } + } + + { + int i = dp->this.use_update_info; + /* Always do one call, even if use_update_info is 0. */ + do + png_read_update_info(pp, pi); + while (--i > 0); + } + + /* Now we may get a different cbRow: */ + standard_info_part2(&dp->this, pp, pi, 1 /*images*/); +} + +static void PNGCBAPI +gamma_info(png_structp pp, png_infop pi) +{ + gamma_info_imp(voidcast(gamma_display*, png_get_progressive_ptr(pp)), pp, + pi); +} + +/* Validate a single component value - the routine gets the input and output + * sample values as unscaled PNG component values along with a cache of all the + * information required to validate the values. + */ +typedef struct validate_info +{ + png_const_structp pp; + gamma_display *dp; + png_byte sbit; + int use_input_precision; + int do_background; + int scale16; + unsigned int sbit_max; + unsigned int isbit_shift; + unsigned int outmax; + + double gamma_correction; /* Overall correction required. */ + double file_inverse; /* Inverse of file gamma. */ + double screen_gamma; + double screen_inverse; /* Inverse of screen gamma. */ + + double background_red; /* Linear background value, red or gray. */ + double background_green; + double background_blue; + + double maxabs; + double maxpc; + double maxcalc; + double maxout; + double maxout_total; /* Total including quantization error */ + double outlog; + int outquant; +} +validate_info; + +static void +init_validate_info(validate_info *vi, gamma_display *dp, png_const_structp pp, + int in_depth, int out_depth) +{ + unsigned int outmax = (1U<pp = pp; + vi->dp = dp; + + if (dp->sbit > 0 && dp->sbit < in_depth) + { + vi->sbit = dp->sbit; + vi->isbit_shift = in_depth - dp->sbit; + } + + else + { + vi->sbit = (png_byte)in_depth; + vi->isbit_shift = 0; + } + + vi->sbit_max = (1U << vi->sbit)-1; + + /* This mimics the libpng threshold test, '0' is used to prevent gamma + * correction in the validation test. + */ + vi->screen_gamma = dp->screen_gamma; + if (fabs(vi->screen_gamma-1) < PNG_GAMMA_THRESHOLD) + vi->screen_gamma = vi->screen_inverse = 0; + else + vi->screen_inverse = 1/vi->screen_gamma; + + vi->use_input_precision = dp->use_input_precision; + vi->outmax = outmax; + vi->maxabs = abserr(dp->pm, in_depth, out_depth); + vi->maxpc = pcerr(dp->pm, in_depth, out_depth); + vi->maxcalc = calcerr(dp->pm, in_depth, out_depth); + vi->maxout = outerr(dp->pm, in_depth, out_depth); + vi->outquant = output_quantization_factor(dp->pm, in_depth, out_depth); + vi->maxout_total = vi->maxout + vi->outquant * .5; + vi->outlog = outlog(dp->pm, in_depth, out_depth); + + if ((dp->this.colour_type & PNG_COLOR_MASK_ALPHA) != 0 || + (dp->this.colour_type == 3 && dp->this.is_transparent) || + ((dp->this.colour_type == 0 || dp->this.colour_type == 2) && + dp->this.has_tRNS)) + { + vi->do_background = dp->do_background; + + if (vi->do_background != 0) + { + const double bg_inverse = 1/dp->background_gamma; + double r, g, b; + + /* Caller must at least put the gray value into the red channel */ + r = dp->background_color.red; r /= outmax; + g = dp->background_color.green; g /= outmax; + b = dp->background_color.blue; b /= outmax; + +# if 0 + /* libpng doesn't do this optimization, if we do pngvalid will fail. + */ + if (fabs(bg_inverse-1) >= PNG_GAMMA_THRESHOLD) +# endif + { + r = pow(r, bg_inverse); + g = pow(g, bg_inverse); + b = pow(b, bg_inverse); + } + + vi->background_red = r; + vi->background_green = g; + vi->background_blue = b; + } + } + else /* Do not expect any background processing */ + vi->do_background = 0; + + if (vi->do_background == 0) + vi->background_red = vi->background_green = vi->background_blue = 0; + + vi->gamma_correction = 1/(dp->file_gamma*dp->screen_gamma); + if (fabs(vi->gamma_correction-1) < PNG_GAMMA_THRESHOLD) + vi->gamma_correction = 0; + + vi->file_inverse = 1/dp->file_gamma; + if (fabs(vi->file_inverse-1) < PNG_GAMMA_THRESHOLD) + vi->file_inverse = 0; + + vi->scale16 = dp->scale16; +} + +/* This function handles composition of a single non-alpha component. The + * argument is the input sample value, in the range 0..1, and the alpha value. + * The result is the composed, linear, input sample. If alpha is less than zero + * this is the alpha component and the function should not be called! + */ +static double +gamma_component_compose(int do_background, double input_sample, double alpha, + double background, int *compose) +{ + switch (do_background) + { +#ifdef PNG_READ_BACKGROUND_SUPPORTED + case PNG_BACKGROUND_GAMMA_SCREEN: + case PNG_BACKGROUND_GAMMA_FILE: + case PNG_BACKGROUND_GAMMA_UNIQUE: + /* Standard PNG background processing. */ + if (alpha < 1) + { + if (alpha > 0) + { + input_sample = input_sample * alpha + background * (1-alpha); + if (compose != NULL) + *compose = 1; + } + + else + input_sample = background; + } + break; +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD: + case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN: + /* The components are premultiplied in either case and the output is + * gamma encoded (to get standard Porter-Duff we expect the output + * gamma to be set to 1.0!) + */ + case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED: + /* The optimization is that the partial-alpha entries are linear + * while the opaque pixels are gamma encoded, but this only affects the + * output encoding. + */ + if (alpha < 1) + { + if (alpha > 0) + { + input_sample *= alpha; + if (compose != NULL) + *compose = 1; + } + + else + input_sample = 0; + } + break; +#endif + + default: + /* Standard cases where no compositing is done (so the component + * value is already correct.) + */ + UNUSED(alpha) + UNUSED(background) + UNUSED(compose) + break; + } + + return input_sample; +} + +/* This API returns the encoded *input* component, in the range 0..1 */ +static double +gamma_component_validate(const char *name, const validate_info *vi, + unsigned int id, unsigned int od, + const double alpha /* <0 for the alpha channel itself */, + const double background /* component background value */) +{ + unsigned int isbit = id >> vi->isbit_shift; + unsigned int sbit_max = vi->sbit_max; + unsigned int outmax = vi->outmax; + int do_background = vi->do_background; + + double i; + + /* First check on the 'perfect' result obtained from the digitized input + * value, id, and compare this against the actual digitized result, 'od'. + * 'i' is the input result in the range 0..1: + */ + i = isbit; i /= sbit_max; + + /* Check for the fast route: if we don't do any background composition or if + * this is the alpha channel ('alpha' < 0) or if the pixel is opaque then + * just use the gamma_correction field to correct to the final output gamma. + */ + if (alpha == 1 /* opaque pixel component */ || !do_background +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + || do_background == ALPHA_MODE_OFFSET + PNG_ALPHA_PNG +#endif + || (alpha < 0 /* alpha channel */ +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + && do_background != ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN +#endif + )) + { + /* Then get the gamma corrected version of 'i' and compare to 'od', any + * error less than .5 is insignificant - just quantization of the output + * value to the nearest digital value (nevertheless the error is still + * recorded - it's interesting ;-) + */ + double encoded_sample = i; + double encoded_error; + + /* alpha less than 0 indicates the alpha channel, which is always linear + */ + if (alpha >= 0 && vi->gamma_correction > 0) + encoded_sample = pow(encoded_sample, vi->gamma_correction); + encoded_sample *= outmax; + + encoded_error = fabs(od-encoded_sample); + + if (encoded_error > vi->dp->maxerrout) + vi->dp->maxerrout = encoded_error; + + if (encoded_error < vi->maxout_total && encoded_error < vi->outlog) + return i; + } + + /* The slow route - attempt to do linear calculations. */ + /* There may be an error, or background processing is required, so calculate + * the actual sample values - unencoded light intensity values. Note that in + * practice these are not completely unencoded because they include a + * 'viewing correction' to decrease or (normally) increase the perceptual + * contrast of the image. There's nothing we can do about this - we don't + * know what it is - so assume the unencoded value is perceptually linear. + */ + { + double input_sample = i; /* In range 0..1 */ + double output, error, encoded_sample, encoded_error; + double es_lo, es_hi; + int compose = 0; /* Set to one if composition done */ + int output_is_encoded; /* Set if encoded to screen gamma */ + int log_max_error = 1; /* Check maximum error values */ + png_const_charp pass = 0; /* Reason test passes (or 0 for fail) */ + + /* Convert to linear light (with the above caveat.) The alpha channel is + * already linear. + */ + if (alpha >= 0) + { + int tcompose; + + if (vi->file_inverse > 0) + input_sample = pow(input_sample, vi->file_inverse); + + /* Handle the compose processing: */ + tcompose = 0; + input_sample = gamma_component_compose(do_background, input_sample, + alpha, background, &tcompose); + + if (tcompose) + compose = 1; + } + + /* And similarly for the output value, but we need to check the background + * handling to linearize it correctly. + */ + output = od; + output /= outmax; + + output_is_encoded = vi->screen_gamma > 0; + + if (alpha < 0) /* The alpha channel */ + { +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if (do_background != ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN) +#endif + { + /* In all other cases the output alpha channel is linear already, + * don't log errors here, they are much larger in linear data. + */ + output_is_encoded = 0; + log_max_error = 0; + } + } + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + else /* A component */ + { + if (do_background == ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED && + alpha < 1) /* the optimized case - linear output */ + { + if (alpha > 0) log_max_error = 0; + output_is_encoded = 0; + } + } +#endif + + if (output_is_encoded) + output = pow(output, vi->screen_gamma); + + /* Calculate (or recalculate) the encoded_sample value and repeat the + * check above (unnecessary if we took the fast route, but harmless.) + */ + encoded_sample = input_sample; + if (output_is_encoded) + encoded_sample = pow(encoded_sample, vi->screen_inverse); + encoded_sample *= outmax; + + encoded_error = fabs(od-encoded_sample); + + /* Don't log errors in the alpha channel, or the 'optimized' case, + * neither are significant to the overall perception. + */ + if (log_max_error && encoded_error > vi->dp->maxerrout) + vi->dp->maxerrout = encoded_error; + + if (encoded_error < vi->maxout_total) + { + if (encoded_error < vi->outlog) + return i; + + /* Test passed but error is bigger than the log limit, record why the + * test passed: + */ + pass = "less than maxout:\n"; + } + + /* i: the original input value in the range 0..1 + * + * pngvalid calculations: + * input_sample: linear result; i linearized and composed, range 0..1 + * encoded_sample: encoded result; input_sample scaled to output bit depth + * + * libpng calculations: + * output: linear result; od scaled to 0..1 and linearized + * od: encoded result from libpng + */ + + /* Now we have the numbers for real errors, both absolute values as as a + * percentage of the correct value (output): + */ + error = fabs(input_sample-output); + + if (log_max_error && error > vi->dp->maxerrabs) + vi->dp->maxerrabs = error; + + /* The following is an attempt to ignore the tendency of quantization to + * dominate the percentage errors for lower result values: + */ + if (log_max_error && input_sample > .5) + { + double percentage_error = error/input_sample; + if (percentage_error > vi->dp->maxerrpc) + vi->dp->maxerrpc = percentage_error; + } + + /* Now calculate the digitization limits for 'encoded_sample' using the + * 'max' values. Note that maxout is in the encoded space but maxpc and + * maxabs are in linear light space. + * + * First find the maximum error in linear light space, range 0..1: + */ + { + double tmp = input_sample * vi->maxpc; + if (tmp < vi->maxabs) tmp = vi->maxabs; + /* If 'compose' is true the composition was done in linear space using + * integer arithmetic. This introduces an extra error of +/- 0.5 (at + * least) in the integer space used. 'maxcalc' records this, taking + * into account the possibility that even for 16 bit output 8 bit space + * may have been used. + */ + if (compose && tmp < vi->maxcalc) tmp = vi->maxcalc; + + /* The 'maxout' value refers to the encoded result, to compare with + * this encode input_sample adjusted by the maximum error (tmp) above. + */ + es_lo = encoded_sample - vi->maxout; + + if (es_lo > 0 && input_sample-tmp > 0) + { + double low_value = input_sample-tmp; + if (output_is_encoded) + low_value = pow(low_value, vi->screen_inverse); + low_value *= outmax; + if (low_value < es_lo) es_lo = low_value; + + /* Quantize this appropriately: */ + es_lo = ceil(es_lo / vi->outquant - .5) * vi->outquant; + } + + else + es_lo = 0; + + es_hi = encoded_sample + vi->maxout; + + if (es_hi < outmax && input_sample+tmp < 1) + { + double high_value = input_sample+tmp; + if (output_is_encoded) + high_value = pow(high_value, vi->screen_inverse); + high_value *= outmax; + if (high_value > es_hi) es_hi = high_value; + + es_hi = floor(es_hi / vi->outquant + .5) * vi->outquant; + } + + else + es_hi = outmax; + } + + /* The primary test is that the final encoded value returned by the + * library should be between the two limits (inclusive) that were + * calculated above. + */ + if (od >= es_lo && od <= es_hi) + { + /* The value passes, but we may need to log the information anyway. */ + if (encoded_error < vi->outlog) + return i; + + if (pass == 0) + pass = "within digitization limits:\n"; + } + + { + /* There has been an error in processing, or we need to log this + * value. + */ + double is_lo, is_hi; + + /* pass is set at this point if either of the tests above would have + * passed. Don't do these additional tests here - just log the + * original [es_lo..es_hi] values. + */ + if (pass == 0 && vi->use_input_precision && vi->dp->sbit) + { + /* Ok, something is wrong - this actually happens in current libpng + * 16-to-8 processing. Assume that the input value (id, adjusted + * for sbit) can be anywhere between value-.5 and value+.5 - quite a + * large range if sbit is low. + * + * NOTE: at present because the libpng gamma table stuff has been + * changed to use a rounding algorithm to correct errors in 8-bit + * calculations the precise sbit calculation (a shift) has been + * lost. This can result in up to a +/-1 error in the presence of + * an sbit less than the bit depth. + */ +# if PNG_LIBPNG_VER < 10700 +# define SBIT_ERROR .5 +# else +# define SBIT_ERROR 1. +# endif + double tmp = (isbit - SBIT_ERROR)/sbit_max; + + if (tmp <= 0) + tmp = 0; + + else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1) + tmp = pow(tmp, vi->file_inverse); + + tmp = gamma_component_compose(do_background, tmp, alpha, background, + NULL); + + if (output_is_encoded && tmp > 0 && tmp < 1) + tmp = pow(tmp, vi->screen_inverse); + + is_lo = ceil(outmax * tmp - vi->maxout_total); + + if (is_lo < 0) + is_lo = 0; + + tmp = (isbit + SBIT_ERROR)/sbit_max; + + if (tmp >= 1) + tmp = 1; + + else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1) + tmp = pow(tmp, vi->file_inverse); + + tmp = gamma_component_compose(do_background, tmp, alpha, background, + NULL); + + if (output_is_encoded && tmp > 0 && tmp < 1) + tmp = pow(tmp, vi->screen_inverse); + + is_hi = floor(outmax * tmp + vi->maxout_total); + + if (is_hi > outmax) + is_hi = outmax; + + if (!(od < is_lo || od > is_hi)) + { + if (encoded_error < vi->outlog) + return i; + + pass = "within input precision limits:\n"; + } + + /* One last chance. If this is an alpha channel and the 16to8 + * option has been used and 'inaccurate' scaling is used then the + * bit reduction is obtained by simply using the top 8 bits of the + * value. + * + * This is only done for older libpng versions when the 'inaccurate' + * (chop) method of scaling was used. + */ +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# if PNG_LIBPNG_VER < 10504 + /* This may be required for other components in the future, + * but at present the presence of gamma correction effectively + * prevents the errors in the component scaling (I don't quite + * understand why, but since it's better this way I care not + * to ask, JB 20110419.) + */ + if (pass == 0 && alpha < 0 && vi->scale16 && vi->sbit > 8 && + vi->sbit + vi->isbit_shift == 16) + { + tmp = ((id >> 8) - .5)/255; + + if (tmp > 0) + { + is_lo = ceil(outmax * tmp - vi->maxout_total); + if (is_lo < 0) is_lo = 0; + } + + else + is_lo = 0; + + tmp = ((id >> 8) + .5)/255; + + if (tmp < 1) + { + is_hi = floor(outmax * tmp + vi->maxout_total); + if (is_hi > outmax) is_hi = outmax; + } + + else + is_hi = outmax; + + if (!(od < is_lo || od > is_hi)) + { + if (encoded_error < vi->outlog) + return i; + + pass = "within 8 bit limits:\n"; + } + } +# endif +# endif + } + else /* !use_input_precision */ + is_lo = es_lo, is_hi = es_hi; + + /* Attempt to output a meaningful error/warning message: the message + * output depends on the background/composite operation being performed + * because this changes what parameters were actually used above. + */ + { + size_t pos = 0; + /* Need either 1/255 or 1/65535 precision here; 3 or 6 decimal + * places. Just use outmax to work out which. + */ + int precision = (outmax >= 1000 ? 6 : 3); + int use_input=1, use_background=0, do_compose=0; + char msg[256]; + + if (pass != 0) + pos = safecat(msg, sizeof msg, pos, "\n\t"); + + /* Set up the various flags, the output_is_encoded flag above + * is also used below. do_compose is just a double check. + */ + switch (do_background) + { +# ifdef PNG_READ_BACKGROUND_SUPPORTED + case PNG_BACKGROUND_GAMMA_SCREEN: + case PNG_BACKGROUND_GAMMA_FILE: + case PNG_BACKGROUND_GAMMA_UNIQUE: + use_background = (alpha >= 0 && alpha < 1); +# endif +# ifdef PNG_READ_ALPHA_MODE_SUPPORTED + /* FALLTHROUGH */ + case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD: + case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN: + case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED: +# endif /* ALPHA_MODE_SUPPORTED */ + do_compose = (alpha > 0 && alpha < 1); + use_input = (alpha != 0); + break; + + default: + break; + } + + /* Check the 'compose' flag */ + if (compose != do_compose) + png_error(vi->pp, "internal error (compose)"); + + /* 'name' is the component name */ + pos = safecat(msg, sizeof msg, pos, name); + pos = safecat(msg, sizeof msg, pos, "("); + pos = safecatn(msg, sizeof msg, pos, id); + if (use_input || pass != 0/*logging*/) + { + if (isbit != id) + { + /* sBIT has reduced the precision of the input: */ + pos = safecat(msg, sizeof msg, pos, ", sbit("); + pos = safecatn(msg, sizeof msg, pos, vi->sbit); + pos = safecat(msg, sizeof msg, pos, "): "); + pos = safecatn(msg, sizeof msg, pos, isbit); + } + pos = safecat(msg, sizeof msg, pos, "/"); + /* The output is either "id/max" or "id sbit(sbit): isbit/max" */ + pos = safecatn(msg, sizeof msg, pos, vi->sbit_max); + } + pos = safecat(msg, sizeof msg, pos, ")"); + + /* A component may have been multiplied (in linear space) by the + * alpha value, 'compose' says whether this is relevant. + */ + if (compose || pass != 0) + { + /* If any form of composition is being done report our + * calculated linear value here (the code above doesn't record + * the input value before composition is performed, so what + * gets reported is the value after composition.) + */ + if (use_input || pass != 0) + { + if (vi->file_inverse > 0) + { + pos = safecat(msg, sizeof msg, pos, "^"); + pos = safecatd(msg, sizeof msg, pos, vi->file_inverse, 2); + } + + else + pos = safecat(msg, sizeof msg, pos, "[linear]"); + + pos = safecat(msg, sizeof msg, pos, "*(alpha)"); + pos = safecatd(msg, sizeof msg, pos, alpha, precision); + } + + /* Now record the *linear* background value if it was used + * (this function is not passed the original, non-linear, + * value but it is contained in the test name.) + */ + if (use_background) + { + pos = safecat(msg, sizeof msg, pos, use_input ? "+" : " "); + pos = safecat(msg, sizeof msg, pos, "(background)"); + pos = safecatd(msg, sizeof msg, pos, background, precision); + pos = safecat(msg, sizeof msg, pos, "*"); + pos = safecatd(msg, sizeof msg, pos, 1-alpha, precision); + } + } + + /* Report the calculated value (input_sample) and the linearized + * libpng value (output) unless this is just a component gamma + * correction. + */ + if (compose || alpha < 0 || pass != 0) + { + pos = safecat(msg, sizeof msg, pos, + pass != 0 ? " =\n\t" : " = "); + pos = safecatd(msg, sizeof msg, pos, input_sample, precision); + pos = safecat(msg, sizeof msg, pos, " (libpng: "); + pos = safecatd(msg, sizeof msg, pos, output, precision); + pos = safecat(msg, sizeof msg, pos, ")"); + + /* Finally report the output gamma encoding, if any. */ + if (output_is_encoded) + { + pos = safecat(msg, sizeof msg, pos, " ^"); + pos = safecatd(msg, sizeof msg, pos, vi->screen_inverse, 2); + pos = safecat(msg, sizeof msg, pos, "(to screen) ="); + } + + else + pos = safecat(msg, sizeof msg, pos, " [screen is linear] ="); + } + + if ((!compose && alpha >= 0) || pass != 0) + { + if (pass != 0) /* logging */ + pos = safecat(msg, sizeof msg, pos, "\n\t[overall:"); + + /* This is the non-composition case, the internal linear + * values are irrelevant (though the log below will reveal + * them.) Output a much shorter warning/error message and report + * the overall gamma correction. + */ + if (vi->gamma_correction > 0) + { + pos = safecat(msg, sizeof msg, pos, " ^"); + pos = safecatd(msg, sizeof msg, pos, vi->gamma_correction, 2); + pos = safecat(msg, sizeof msg, pos, "(gamma correction) ="); + } + + else + pos = safecat(msg, sizeof msg, pos, + " [no gamma correction] ="); + + if (pass != 0) + pos = safecat(msg, sizeof msg, pos, "]"); + } + + /* This is our calculated encoded_sample which should (but does + * not) match od: + */ + pos = safecat(msg, sizeof msg, pos, pass != 0 ? "\n\t" : " "); + pos = safecatd(msg, sizeof msg, pos, is_lo, 1); + pos = safecat(msg, sizeof msg, pos, " < "); + pos = safecatd(msg, sizeof msg, pos, encoded_sample, 1); + pos = safecat(msg, sizeof msg, pos, " (libpng: "); + pos = safecatn(msg, sizeof msg, pos, od); + pos = safecat(msg, sizeof msg, pos, ")"); + pos = safecat(msg, sizeof msg, pos, "/"); + pos = safecatn(msg, sizeof msg, pos, outmax); + pos = safecat(msg, sizeof msg, pos, " < "); + pos = safecatd(msg, sizeof msg, pos, is_hi, 1); + + if (pass == 0) /* The error condition */ + { +# ifdef PNG_WARNINGS_SUPPORTED + png_warning(vi->pp, msg); +# else + store_warning(vi->pp, msg); +# endif + } + + else /* logging this value */ + store_verbose(&vi->dp->pm->this, vi->pp, pass, msg); + } + } + } + + return i; +} + +static void +gamma_image_validate(gamma_display *dp, png_const_structp pp, + png_infop pi) +{ + /* Get some constants derived from the input and output file formats: */ + const png_store* const ps = dp->this.ps; + png_byte in_ct = dp->this.colour_type; + png_byte in_bd = dp->this.bit_depth; + png_uint_32 w = dp->this.w; + png_uint_32 h = dp->this.h; + const size_t cbRow = dp->this.cbRow; + png_byte out_ct = png_get_color_type(pp, pi); + png_byte out_bd = png_get_bit_depth(pp, pi); + + /* There are three sources of error, firstly the quantization in the + * file encoding, determined by sbit and/or the file depth, secondly + * the output (screen) gamma and thirdly the output file encoding. + * + * Since this API receives the screen and file gamma in double + * precision it is possible to calculate an exact answer given an input + * pixel value. Therefore we assume that the *input* value is exact - + * sample/maxsample - calculate the corresponding gamma corrected + * output to the limits of double precision arithmetic and compare with + * what libpng returns. + * + * Since the library must quantize the output to 8 or 16 bits there is + * a fundamental limit on the accuracy of the output of +/-.5 - this + * quantization limit is included in addition to the other limits + * specified by the parameters to the API. (Effectively, add .5 + * everywhere.) + * + * The behavior of the 'sbit' parameter is defined by section 12.5 + * (sample depth scaling) of the PNG spec. That section forces the + * decoder to assume that the PNG values have been scaled if sBIT is + * present: + * + * png-sample = floor( input-sample * (max-out/max-in) + .5); + * + * This means that only a subset of the possible PNG values should + * appear in the input. However, the spec allows the encoder to use a + * variety of approximations to the above and doesn't require any + * restriction of the values produced. + * + * Nevertheless the spec requires that the upper 'sBIT' bits of the + * value stored in a PNG file be the original sample bits. + * Consequently the code below simply scales the top sbit bits by + * (1<this.palette; + int in_is_transparent = dp->this.is_transparent; + int process_tRNS; + int out_npalette = -1; + int out_is_transparent = 0; /* Just refers to the palette case */ + store_palette out_palette; + validate_info vi; + + /* Check for row overwrite errors */ + store_image_check(dp->this.ps, pp, 0); + + /* Supply the input and output sample depths here - 8 for an indexed image, + * otherwise the bit depth. + */ + init_validate_info(&vi, dp, pp, in_ct==3?8:in_bd, out_ct==3?8:out_bd); + + processing = (vi.gamma_correction > 0 && !dp->threshold_test) + || in_bd != out_bd || in_ct != out_ct || vi.do_background; + process_tRNS = dp->this.has_tRNS && vi.do_background; + + /* TODO: FIX THIS: MAJOR BUG! If the transformations all happen inside + * the palette there is no way of finding out, because libpng fails to + * update the palette on png_read_update_info. Indeed, libpng doesn't + * even do the required work until much later, when it doesn't have any + * info pointer. Oops. For the moment 'processing' is turned off if + * out_ct is palette. + */ + if (in_ct == 3 && out_ct == 3) + processing = 0; + + if (processing && out_ct == 3) + out_is_transparent = read_palette(out_palette, &out_npalette, pp, pi); + + for (y=0; ythis.palette[in_index].alpha : + sample(std, in_ct, in_bd, x, samples_per_pixel, 0, 0); + + unsigned int output_alpha = 65536 /* as a flag value */; + + if (out_ct == 3) + { + if (out_is_transparent) + output_alpha = out_palette[out_index].alpha; + } + + else if ((out_ct & PNG_COLOR_MASK_ALPHA) != 0) + output_alpha = sample(pRow, out_ct, out_bd, x, + samples_per_pixel, 0, 0); + + if (output_alpha != 65536) + alpha = gamma_component_validate("alpha", &vi, input_alpha, + output_alpha, -1/*alpha*/, 0/*background*/); + + else /* no alpha in output */ + { + /* This is a copy of the calculation of 'i' above in order to + * have the alpha value to use in the background calculation. + */ + alpha = input_alpha >> vi.isbit_shift; + alpha /= vi.sbit_max; + } + } + + else if (process_tRNS) + { + /* alpha needs to be set appropriately for this pixel, it is + * currently 1 and needs to be 0 for an input pixel which matches + * the values in tRNS. + */ + switch (in_ct) + { + case 0: /* gray */ + if (sample(std, in_ct, in_bd, x, 0, 0, 0) == + dp->this.transparent.red) + alpha = 0; + break; + + case 2: /* RGB */ + if (sample(std, in_ct, in_bd, x, 0, 0, 0) == + dp->this.transparent.red && + sample(std, in_ct, in_bd, x, 1, 0, 0) == + dp->this.transparent.green && + sample(std, in_ct, in_bd, x, 2, 0, 0) == + dp->this.transparent.blue) + alpha = 0; + break; + + default: + break; + } + } + + /* Handle grayscale or RGB components. */ + if ((in_ct & PNG_COLOR_MASK_COLOR) == 0) /* grayscale */ + (void)gamma_component_validate("gray", &vi, + sample(std, in_ct, in_bd, x, 0, 0, 0), + sample(pRow, out_ct, out_bd, x, 0, 0, 0), + alpha/*component*/, vi.background_red); + else /* RGB or palette */ + { + (void)gamma_component_validate("red", &vi, + in_ct == 3 ? in_palette[in_index].red : + sample(std, in_ct, in_bd, x, 0, 0, 0), + out_ct == 3 ? out_palette[out_index].red : + sample(pRow, out_ct, out_bd, x, 0, 0, 0), + alpha/*component*/, vi.background_red); + + (void)gamma_component_validate("green", &vi, + in_ct == 3 ? in_palette[in_index].green : + sample(std, in_ct, in_bd, x, 1, 0, 0), + out_ct == 3 ? out_palette[out_index].green : + sample(pRow, out_ct, out_bd, x, 1, 0, 0), + alpha/*component*/, vi.background_green); + + (void)gamma_component_validate("blue", &vi, + in_ct == 3 ? in_palette[in_index].blue : + sample(std, in_ct, in_bd, x, 2, 0, 0), + out_ct == 3 ? out_palette[out_index].blue : + sample(pRow, out_ct, out_bd, x, 2, 0, 0), + alpha/*component*/, vi.background_blue); + } + } + } + + else if (memcmp(std, pRow, cbRow) != 0) + { + char msg[64]; + + /* No transform is expected on the threshold tests. */ + sprintf(msg, "gamma: below threshold row %lu changed", + (unsigned long)y); + + png_error(pp, msg); + } + } /* row (y) loop */ + + dp->this.ps->validated = 1; +} + +static void PNGCBAPI +gamma_end(png_structp ppIn, png_infop pi) +{ + png_const_structp pp = ppIn; + gamma_display *dp = voidcast(gamma_display*, png_get_progressive_ptr(pp)); + + if (!dp->this.speed) + gamma_image_validate(dp, pp, pi); + else + dp->this.ps->validated = 1; +} + +/* A single test run checking a gamma transformation. + * + * maxabs: maximum absolute error as a fraction + * maxout: maximum output error in the output units + * maxpc: maximum percentage error (as a percentage) + */ +static void +gamma_test(png_modifier *pmIn, png_byte colour_typeIn, + png_byte bit_depthIn, int palette_numberIn, + int interlace_typeIn, + const double file_gammaIn, const double screen_gammaIn, + png_byte sbitIn, int threshold_testIn, + const char *name, + int use_input_precisionIn, int scale16In, + int expand16In, int do_backgroundIn, + const png_color_16 *bkgd_colorIn, double bkgd_gammaIn) +{ + gamma_display d; + context(&pmIn->this, fault); + + gamma_display_init(&d, pmIn, FILEID(colour_typeIn, bit_depthIn, + palette_numberIn, interlace_typeIn, 0, 0, 0), + file_gammaIn, screen_gammaIn, sbitIn, + threshold_testIn, use_input_precisionIn, scale16In, + expand16In, do_backgroundIn, bkgd_colorIn, bkgd_gammaIn); + + Try + { + png_structp pp; + png_infop pi; + gama_modification gama_mod; + srgb_modification srgb_mod; + sbit_modification sbit_mod; + + /* For the moment don't use the png_modifier support here. */ + d.pm->encoding_counter = 0; + modifier_set_encoding(d.pm); /* Just resets everything */ + d.pm->current_gamma = d.file_gamma; + + /* Make an appropriate modifier to set the PNG file gamma to the + * given gamma value and the sBIT chunk to the given precision. + */ + d.pm->modifications = NULL; + gama_modification_init(&gama_mod, d.pm, d.file_gamma); + srgb_modification_init(&srgb_mod, d.pm, 127 /*delete*/); + if (d.sbit > 0) + sbit_modification_init(&sbit_mod, d.pm, d.sbit); + + modification_reset(d.pm->modifications); + + /* Get a png_struct for reading the image. */ + pp = set_modifier_for_read(d.pm, &pi, d.this.id, name); + standard_palette_init(&d.this); + + /* Introduce the correct read function. */ + if (d.pm->this.progressive) + { + /* Share the row function with the standard implementation. */ + png_set_progressive_read_fn(pp, &d, gamma_info, progressive_row, + gamma_end); + + /* Now feed data into the reader until we reach the end: */ + modifier_progressive_read(d.pm, pp, pi); + } + else + { + /* modifier_read expects a png_modifier* */ + png_set_read_fn(pp, d.pm, modifier_read); + + /* Check the header values: */ + png_read_info(pp, pi); + + /* Process the 'info' requirements. Only one image is generated */ + gamma_info_imp(&d, pp, pi); + + sequential_row(&d.this, pp, pi, -1, 0); + + if (!d.this.speed) + gamma_image_validate(&d, pp, pi); + else + d.this.ps->validated = 1; + } + + modifier_reset(d.pm); + + if (d.pm->log && !d.threshold_test && !d.this.speed) + fprintf(stderr, "%d bit %s %s: max error %f (%.2g, %2g%%)\n", + d.this.bit_depth, colour_types[d.this.colour_type], name, + d.maxerrout, d.maxerrabs, 100*d.maxerrpc); + + /* Log the summary values too. */ + if (d.this.colour_type == 0 || d.this.colour_type == 4) + { + switch (d.this.bit_depth) + { + case 1: + break; + + case 2: + if (d.maxerrout > d.pm->error_gray_2) + d.pm->error_gray_2 = d.maxerrout; + + break; + + case 4: + if (d.maxerrout > d.pm->error_gray_4) + d.pm->error_gray_4 = d.maxerrout; + + break; + + case 8: + if (d.maxerrout > d.pm->error_gray_8) + d.pm->error_gray_8 = d.maxerrout; + + break; + + case 16: + if (d.maxerrout > d.pm->error_gray_16) + d.pm->error_gray_16 = d.maxerrout; + + break; + + default: + png_error(pp, "bad bit depth (internal: 1)"); + } + } + + else if (d.this.colour_type == 2 || d.this.colour_type == 6) + { + switch (d.this.bit_depth) + { + case 8: + + if (d.maxerrout > d.pm->error_color_8) + d.pm->error_color_8 = d.maxerrout; + + break; + + case 16: + + if (d.maxerrout > d.pm->error_color_16) + d.pm->error_color_16 = d.maxerrout; + + break; + + default: + png_error(pp, "bad bit depth (internal: 2)"); + } + } + + else if (d.this.colour_type == 3) + { + if (d.maxerrout > d.pm->error_indexed) + d.pm->error_indexed = d.maxerrout; + } + } + + Catch(fault) + modifier_reset(voidcast(png_modifier*,(void*)fault)); +} + +static void gamma_threshold_test(png_modifier *pm, png_byte colour_type, + png_byte bit_depth, int interlace_type, double file_gamma, + double screen_gamma) +{ + size_t pos = 0; + char name[64]; + pos = safecat(name, sizeof name, pos, "threshold "); + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "/"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + (void)gamma_test(pm, colour_type, bit_depth, 0/*palette*/, interlace_type, + file_gamma, screen_gamma, 0/*sBIT*/, 1/*threshold test*/, name, + 0 /*no input precision*/, + 0 /*no scale16*/, 0 /*no expand16*/, 0 /*no background*/, 0 /*hence*/, + 0 /*no background gamma*/); +} + +static void +perform_gamma_threshold_tests(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* Don't test more than one instance of each palette - it's pointless, in + * fact this test is somewhat excessive since libpng doesn't make this + * decision based on colour type or bit depth! + * + * CHANGED: now test two palettes and, as a side effect, images with and + * without tRNS. + */ + while (next_format(&colour_type, &bit_depth, &palette_number, + pm->test_lbg_gamma_threshold, pm->test_tRNS)) + if (palette_number < 2) + { + double test_gamma = 1.0; + while (test_gamma >= .4) + { + /* There's little point testing the interlacing vs non-interlacing, + * but this can be set from the command line. + */ + gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, + test_gamma, 1/test_gamma); + test_gamma *= .95; + } + + /* And a special test for sRGB */ + gamma_threshold_test(pm, colour_type, bit_depth, pm->interlace_type, + .45455, 2.2); + + if (fail(pm)) + return; + } +} + +static void gamma_transform_test(png_modifier *pm, + png_byte colour_type, png_byte bit_depth, + int palette_number, + int interlace_type, const double file_gamma, + const double screen_gamma, png_byte sbit, + int use_input_precision, int scale16) +{ + size_t pos = 0; + char name[64]; + + if (sbit != bit_depth && sbit != 0) + { + pos = safecat(name, sizeof name, pos, "sbit("); + pos = safecatn(name, sizeof name, pos, sbit); + pos = safecat(name, sizeof name, pos, ") "); + } + + else + pos = safecat(name, sizeof name, pos, "gamma "); + + if (scale16) + pos = safecat(name, sizeof name, pos, "16to8 "); + + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "->"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + gamma_test(pm, colour_type, bit_depth, palette_number, interlace_type, + file_gamma, screen_gamma, sbit, 0, name, use_input_precision, + scale16, pm->test_gamma_expand16, 0 , 0, 0); +} + +static void perform_gamma_transform_tests(png_modifier *pm) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + while (next_format(&colour_type, &bit_depth, &palette_number, + pm->test_lbg_gamma_transform, pm->test_tRNS)) + { + unsigned int i, j; + + for (i=0; ingamma_tests; ++i) for (j=0; jngamma_tests; ++j) + if (i != j) + { + gamma_transform_test(pm, colour_type, bit_depth, palette_number, + pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], 0/*sBIT*/, + pm->use_input_precision, 0 /*do not scale16*/); + + if (fail(pm)) + return; + } + } +} + +static void perform_gamma_sbit_tests(png_modifier *pm) +{ + png_byte sbit; + + /* The only interesting cases are colour and grayscale, alpha is ignored here + * for overall speed. Only bit depths where sbit is less than the bit depth + * are tested. + */ + for (sbit=pm->sbitlow; sbit<(1<test_lbg_gamma_sbit, pm->test_tRNS)) + if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 && + ((colour_type == 3 && sbit < 8) || + (colour_type != 3 && sbit < bit_depth))) + { + unsigned int i; + + for (i=0; ingamma_tests; ++i) + { + unsigned int j; + + for (j=0; jngamma_tests; ++j) if (i != j) + { + gamma_transform_test(pm, colour_type, bit_depth, npalette, + pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], + sbit, pm->use_input_precision_sbit, 0 /*scale16*/); + + if (fail(pm)) + return; + } + } + } + } +} + +/* Note that this requires a 16 bit source image but produces 8 bit output, so + * we only need the 16bit write support, but the 16 bit images are only + * generated if DO_16BIT is defined. + */ +#ifdef DO_16BIT +static void perform_gamma_scale16_tests(png_modifier *pm) +{ +# ifndef PNG_MAX_GAMMA_8 +# define PNG_MAX_GAMMA_8 11 +# endif +# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700 +# define SBIT_16_TO_8 PNG_MAX_GAMMA_8 +# else +# define SBIT_16_TO_8 16 +# endif + /* Include the alpha cases here. Note that sbit matches the internal value + * used by the library - otherwise we will get spurious errors from the + * internal sbit style approximation. + * + * The threshold test is here because otherwise the 16 to 8 conversion will + * proceed *without* gamma correction, and the tests above will fail (but not + * by much) - this could be fixed, it only appears with the -g option. + */ + unsigned int i, j; + for (i=0; ingamma_tests; ++i) + { + for (j=0; jngamma_tests; ++j) + { + if (i != j && + fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD) + { + gamma_transform_test(pm, 0, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + + gamma_transform_test(pm, 2, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + + gamma_transform_test(pm, 4, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + + gamma_transform_test(pm, 6, 16, 0, pm->interlace_type, + 1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8, + pm->use_input_precision_16to8, 1 /*scale16*/); + + if (fail(pm)) + return; + } + } + } +} +#endif /* 16 to 8 bit conversion */ + +#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ + defined(PNG_READ_ALPHA_MODE_SUPPORTED) +static void gamma_composition_test(png_modifier *pm, + png_byte colour_type, png_byte bit_depth, + int palette_number, + int interlace_type, const double file_gamma, + const double screen_gamma, + int use_input_precision, int do_background, + int expand_16) +{ + size_t pos = 0; + png_const_charp base; + double bg; + char name[128]; + png_color_16 background; + + /* Make up a name and get an appropriate background gamma value. */ + switch (do_background) + { + default: + base = ""; + bg = 4; /* should not be used */ + break; + case PNG_BACKGROUND_GAMMA_SCREEN: + base = " bckg(Screen):"; + bg = 1/screen_gamma; + break; + case PNG_BACKGROUND_GAMMA_FILE: + base = " bckg(File):"; + bg = file_gamma; + break; + case PNG_BACKGROUND_GAMMA_UNIQUE: + base = " bckg(Unique):"; + /* This tests the handling of a unique value, the math is such that the + * value tends to be <1, but is neither screen nor file (even if they + * match!) + */ + bg = (file_gamma + screen_gamma) / 3; + break; +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + case ALPHA_MODE_OFFSET + PNG_ALPHA_PNG: + base = " alpha(PNG)"; + bg = 4; /* should not be used */ + break; + case ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD: + base = " alpha(Porter-Duff)"; + bg = 4; /* should not be used */ + break; + case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED: + base = " alpha(Optimized)"; + bg = 4; /* should not be used */ + break; + case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN: + base = " alpha(Broken)"; + bg = 4; /* should not be used */ + break; +#endif + } + + /* Use random background values - the background is always presented in the + * output space (8 or 16 bit components). + */ + if (expand_16 || bit_depth == 16) + { + png_uint_32 r = random_32(); + + background.red = (png_uint_16)r; + background.green = (png_uint_16)(r >> 16); + r = random_32(); + background.blue = (png_uint_16)r; + background.gray = (png_uint_16)(r >> 16); + + /* In earlier libpng versions, those where DIGITIZE is set, any background + * gamma correction in the expand16 case was done using 8-bit gamma + * correction tables, resulting in larger errors. To cope with those + * cases use a 16-bit background value which will handle this gamma + * correction. + */ +# if DIGITIZE + if (expand_16 && (do_background == PNG_BACKGROUND_GAMMA_UNIQUE || + do_background == PNG_BACKGROUND_GAMMA_FILE) && + fabs(bg*screen_gamma-1) > PNG_GAMMA_THRESHOLD) + { + /* The background values will be looked up in an 8-bit table to do + * the gamma correction, so only select values which are an exact + * match for the 8-bit table entries: + */ + background.red = (png_uint_16)((background.red >> 8) * 257); + background.green = (png_uint_16)((background.green >> 8) * 257); + background.blue = (png_uint_16)((background.blue >> 8) * 257); + background.gray = (png_uint_16)((background.gray >> 8) * 257); + } +# endif + } + + else /* 8 bit colors */ + { + png_uint_32 r = random_32(); + + background.red = (png_byte)r; + background.green = (png_byte)(r >> 8); + background.blue = (png_byte)(r >> 16); + background.gray = (png_byte)(r >> 24); + } + + background.index = 193; /* rgb(193,193,193) to detect errors */ + + if (!(colour_type & PNG_COLOR_MASK_COLOR)) + { + /* Because, currently, png_set_background is always called with + * 'need_expand' false in this case and because the gamma test itself + * doesn't cause an expand to 8-bit for lower bit depths the colour must + * be reduced to the correct range. + */ + if (bit_depth < 8) + background.gray &= (png_uint_16)((1U << bit_depth)-1); + + /* Grayscale input, we do not convert to RGB (TBD), so we must set the + * background to gray - else libpng seems to fail. + */ + background.red = background.green = background.blue = background.gray; + } + + pos = safecat(name, sizeof name, pos, "gamma "); + pos = safecatd(name, sizeof name, pos, file_gamma, 3); + pos = safecat(name, sizeof name, pos, "->"); + pos = safecatd(name, sizeof name, pos, screen_gamma, 3); + + pos = safecat(name, sizeof name, pos, base); + if (do_background < ALPHA_MODE_OFFSET) + { + /* Include the background color and gamma in the name: */ + pos = safecat(name, sizeof name, pos, "("); + /* This assumes no expand gray->rgb - the current code won't handle that! + */ + if (colour_type & PNG_COLOR_MASK_COLOR) + { + pos = safecatn(name, sizeof name, pos, background.red); + pos = safecat(name, sizeof name, pos, ","); + pos = safecatn(name, sizeof name, pos, background.green); + pos = safecat(name, sizeof name, pos, ","); + pos = safecatn(name, sizeof name, pos, background.blue); + } + else + pos = safecatn(name, sizeof name, pos, background.gray); + pos = safecat(name, sizeof name, pos, ")^"); + pos = safecatd(name, sizeof name, pos, bg, 3); + } + + gamma_test(pm, colour_type, bit_depth, palette_number, interlace_type, + file_gamma, screen_gamma, 0/*sBIT*/, 0, name, use_input_precision, + 0/*strip 16*/, expand_16, do_background, &background, bg); +} + + +static void +perform_gamma_composition_tests(png_modifier *pm, int do_background, + int expand_16) +{ + png_byte colour_type = 0; + png_byte bit_depth = 0; + unsigned int palette_number = 0; + + /* Skip the non-alpha cases - there is no setting of a transparency colour at + * present. + * + * TODO: incorrect; the palette case sets tRNS and, now RGB and gray do, + * however the palette case fails miserably so is commented out below. + */ + while (next_format(&colour_type, &bit_depth, &palette_number, + pm->test_lbg_gamma_composition, pm->test_tRNS)) + if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0 +#if 0 /* TODO: FIXME */ + /*TODO: FIXME: this should work */ + || colour_type == 3 +#endif + || (colour_type != 3 && palette_number != 0)) + { + unsigned int i, j; + + /* Don't skip the i==j case here - it's relevant. */ + for (i=0; ingamma_tests; ++i) for (j=0; jngamma_tests; ++j) + { + gamma_composition_test(pm, colour_type, bit_depth, palette_number, + pm->interlace_type, 1/pm->gammas[i], pm->gammas[j], + pm->use_input_precision, do_background, expand_16); + + if (fail(pm)) + return; + } + } +} +#endif /* READ_BACKGROUND || READ_ALPHA_MODE */ + +static void +init_gamma_errors(png_modifier *pm) +{ + /* Use -1 to catch tests that were not actually run */ + pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = -1.; + pm->error_color_8 = -1.; + pm->error_indexed = -1.; + pm->error_gray_16 = pm->error_color_16 = -1.; +} + +static void +print_one(const char *leader, double err) +{ + if (err != -1.) + printf(" %s %.5f\n", leader, err); +} + +static void +summarize_gamma_errors(png_modifier *pm, png_const_charp who, int low_bit_depth, + int indexed) +{ + fflush(stderr); + + if (who) + printf("\nGamma correction with %s:\n", who); + + else + printf("\nBasic gamma correction:\n"); + + if (low_bit_depth) + { + print_one(" 2 bit gray: ", pm->error_gray_2); + print_one(" 4 bit gray: ", pm->error_gray_4); + print_one(" 8 bit gray: ", pm->error_gray_8); + print_one(" 8 bit color:", pm->error_color_8); + if (indexed) + print_one(" indexed: ", pm->error_indexed); + } + + print_one("16 bit gray: ", pm->error_gray_16); + print_one("16 bit color:", pm->error_color_16); + + fflush(stdout); +} + +static void +perform_gamma_test(png_modifier *pm, int summary) +{ + /*TODO: remove this*/ + /* Save certain values for the temporary overrides below. */ + unsigned int calculations_use_input_precision = + pm->calculations_use_input_precision; +# ifdef PNG_READ_BACKGROUND_SUPPORTED + double maxout8 = pm->maxout8; +# endif + + /* First some arbitrary no-transform tests: */ + if (!pm->this.speed && pm->test_gamma_threshold) + { + perform_gamma_threshold_tests(pm); + + if (fail(pm)) + return; + } + + /* Now some real transforms. */ + if (pm->test_gamma_transform) + { + if (summary) + { + fflush(stderr); + printf("Gamma correction error summary\n\n"); + printf("The printed value is the maximum error in the pixel values\n"); + printf("calculated by the libpng gamma correction code. The error\n"); + printf("is calculated as the difference between the output pixel\n"); + printf("value (always an integer) and the ideal value from the\n"); + printf("libpng specification (typically not an integer).\n\n"); + + printf("Expect this value to be less than .5 for 8 bit formats,\n"); + printf("less than 1 for formats with fewer than 8 bits and a small\n"); + printf("number (typically less than 5) for the 16 bit formats.\n"); + printf("For performance reasons the value for 16 bit formats\n"); + printf("increases when the image file includes an sBIT chunk.\n"); + fflush(stdout); + } + + init_gamma_errors(pm); + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + perform_gamma_transform_tests(pm); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, 0/*who*/, 1/*low bit depth*/, 1/*indexed*/); + + if (fail(pm)) + return; + } + + /* The sbit tests produce much larger errors: */ + if (pm->test_gamma_sbit) + { + init_gamma_errors(pm); + perform_gamma_sbit_tests(pm); + + if (summary) + summarize_gamma_errors(pm, "sBIT", pm->sbitlow < 8U, 1/*indexed*/); + + if (fail(pm)) + return; + } + +#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */ + if (pm->test_gamma_scale16) + { + /* The 16 to 8 bit strip operations: */ + init_gamma_errors(pm); + perform_gamma_scale16_tests(pm); + + if (summary) + { + fflush(stderr); + printf("\nGamma correction with 16 to 8 bit reduction:\n"); + printf(" 16 bit gray: %.5f\n", pm->error_gray_16); + printf(" 16 bit color: %.5f\n", pm->error_color_16); + fflush(stdout); + } + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_BACKGROUND_SUPPORTED + if (pm->test_gamma_background) + { + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + { + pm->calculations_use_input_precision = 1; + pm->maxout8 = .499; /* because the 16 bit background is smashed */ + } + perform_gamma_composition_tests(pm, PNG_BACKGROUND_GAMMA_UNIQUE, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + pm->maxout8 = maxout8; + + if (summary) + summarize_gamma_errors(pm, "background", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif + +#ifdef PNG_READ_ALPHA_MODE_SUPPORTED + if (pm->test_gamma_alpha_mode) + { + int do_background; + + init_gamma_errors(pm); + + /*TODO: remove this. Necessary because the current libpng + * implementation works in 8 bits: + */ + if (pm->test_gamma_expand16) + pm->calculations_use_input_precision = 1; + for (do_background = ALPHA_MODE_OFFSET + PNG_ALPHA_STANDARD; + do_background <= ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN && !fail(pm); + ++do_background) + perform_gamma_composition_tests(pm, do_background, + pm->test_gamma_expand16); + if (!calculations_use_input_precision) + pm->calculations_use_input_precision = 0; + + if (summary) + summarize_gamma_errors(pm, "alpha mode", 1, 0/*indexed*/); + + if (fail(pm)) + return; + } +#endif +} +#endif /* PNG_READ_GAMMA_SUPPORTED */ +#endif /* PNG_READ_SUPPORTED */ + +/* INTERLACE MACRO VALIDATION */ +/* This is copied verbatim from the specification, it is simply the pass + * number in which each pixel in each 8x8 tile appears. The array must + * be indexed adam7[y][x] and notice that the pass numbers are based at + * 1, not 0 - the base libpng uses. + */ +static const +png_byte adam7[8][8] = +{ + { 1,6,4,6,2,6,4,6 }, + { 7,7,7,7,7,7,7,7 }, + { 5,6,5,6,5,6,5,6 }, + { 7,7,7,7,7,7,7,7 }, + { 3,6,4,6,3,6,4,6 }, + { 7,7,7,7,7,7,7,7 }, + { 5,6,5,6,5,6,5,6 }, + { 7,7,7,7,7,7,7,7 } +}; + +/* This routine validates all the interlace support macros in png.h for + * a variety of valid PNG widths and heights. It uses a number of similarly + * named internal routines that feed off the above array. + */ +static png_uint_32 +png_pass_start_row(int pass) +{ + int x, y; + ++pass; + for (y=0; y<8; ++y) for (x=0; x<8; ++x) if (adam7[y][x] == pass) + return y; + return 0xf; +} + +static png_uint_32 +png_pass_start_col(int pass) +{ + int x, y; + ++pass; + for (x=0; x<8; ++x) for (y=0; y<8; ++y) if (adam7[y][x] == pass) + return x; + return 0xf; +} + +static int +png_pass_row_shift(int pass) +{ + int x, y, base=(-1), inc=8; + ++pass; + for (y=0; y<8; ++y) for (x=0; x<8; ++x) if (adam7[y][x] == pass) + { + if (base == (-1)) + base = y; + else if (base == y) + {} + else if (inc == y-base) + base=y; + else if (inc == 8) + inc = y-base, base=y; + else if (inc != y-base) + return 0xff; /* error - more than one 'inc' value! */ + } + + if (base == (-1)) return 0xfe; /* error - no row in pass! */ + + /* The shift is always 1, 2 or 3 - no pass has all the rows! */ + switch (inc) + { +case 2: return 1; +case 4: return 2; +case 8: return 3; +default: break; + } + + /* error - unrecognized 'inc' */ + return (inc << 8) + 0xfd; +} + +static int +png_pass_col_shift(int pass) +{ + int x, y, base=(-1), inc=8; + ++pass; + for (x=0; x<8; ++x) for (y=0; y<8; ++y) if (adam7[y][x] == pass) + { + if (base == (-1)) + base = x; + else if (base == x) + {} + else if (inc == x-base) + base=x; + else if (inc == 8) + inc = x-base, base=x; + else if (inc != x-base) + return 0xff; /* error - more than one 'inc' value! */ + } + + if (base == (-1)) return 0xfe; /* error - no row in pass! */ + + /* The shift is always 1, 2 or 3 - no pass has all the rows! */ + switch (inc) + { +case 1: return 0; /* pass 7 has all the columns */ +case 2: return 1; +case 4: return 2; +case 8: return 3; +default: break; + } + + /* error - unrecognized 'inc' */ + return (inc << 8) + 0xfd; +} + +static png_uint_32 +png_row_from_pass_row(png_uint_32 yIn, int pass) +{ + /* By examination of the array: */ + switch (pass) + { +case 0: return yIn * 8; +case 1: return yIn * 8; +case 2: return yIn * 8 + 4; +case 3: return yIn * 4; +case 4: return yIn * 4 + 2; +case 5: return yIn * 2; +case 6: return yIn * 2 + 1; +default: break; + } + + return 0xff; /* bad pass number */ +} + +static png_uint_32 +png_col_from_pass_col(png_uint_32 xIn, int pass) +{ + /* By examination of the array: */ + switch (pass) + { +case 0: return xIn * 8; +case 1: return xIn * 8 + 4; +case 2: return xIn * 4; +case 3: return xIn * 4 + 2; +case 4: return xIn * 2; +case 5: return xIn * 2 + 1; +case 6: return xIn; +default: break; + } + + return 0xff; /* bad pass number */ +} + +static int +png_row_in_interlace_pass(png_uint_32 y, int pass) +{ + /* Is row 'y' in pass 'pass'? */ + int x; + y &= 7; + ++pass; + for (x=0; x<8; ++x) if (adam7[y][x] == pass) + return 1; + + return 0; +} + +static int +png_col_in_interlace_pass(png_uint_32 x, int pass) +{ + /* Is column 'x' in pass 'pass'? */ + int y; + x &= 7; + ++pass; + for (y=0; y<8; ++y) if (adam7[y][x] == pass) + return 1; + + return 0; +} + +static png_uint_32 +png_pass_rows(png_uint_32 height, int pass) +{ + png_uint_32 tiles = height>>3; + png_uint_32 rows = 0; + unsigned int x, y; + + height &= 7; + ++pass; + for (y=0; y<8; ++y) for (x=0; x<8; ++x) if (adam7[y][x] == pass) + { + rows += tiles; + if (y < height) ++rows; + break; /* i.e. break the 'x', column, loop. */ + } + + return rows; +} + +static png_uint_32 +png_pass_cols(png_uint_32 width, int pass) +{ + png_uint_32 tiles = width>>3; + png_uint_32 cols = 0; + unsigned int x, y; + + width &= 7; + ++pass; + for (x=0; x<8; ++x) for (y=0; y<8; ++y) if (adam7[y][x] == pass) + { + cols += tiles; + if (x < width) ++cols; + break; /* i.e. break the 'y', row, loop. */ + } + + return cols; +} + +static void +perform_interlace_macro_validation(void) +{ + /* The macros to validate, first those that depend only on pass: + * + * PNG_PASS_START_ROW(pass) + * PNG_PASS_START_COL(pass) + * PNG_PASS_ROW_SHIFT(pass) + * PNG_PASS_COL_SHIFT(pass) + */ + int pass; + + for (pass=0; pass<7; ++pass) + { + png_uint_32 m, f, v; + + m = PNG_PASS_START_ROW(pass); + f = png_pass_start_row(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_START_ROW(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + m = PNG_PASS_START_COL(pass); + f = png_pass_start_col(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_START_COL(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + m = PNG_PASS_ROW_SHIFT(pass); + f = png_pass_row_shift(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_ROW_SHIFT(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + m = PNG_PASS_COL_SHIFT(pass); + f = png_pass_col_shift(pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_COL_SHIFT(%d) = %u != %x\n", pass, m, f); + exit(99); + } + + /* Macros that depend on the image or sub-image height too: + * + * PNG_PASS_ROWS(height, pass) + * PNG_PASS_COLS(width, pass) + * PNG_ROW_FROM_PASS_ROW(yIn, pass) + * PNG_COL_FROM_PASS_COL(xIn, pass) + * PNG_ROW_IN_INTERLACE_PASS(y, pass) + * PNG_COL_IN_INTERLACE_PASS(x, pass) + */ + for (v=0;;) + { + /* The first two tests overflow if the pass row or column is outside + * the possible range for a 32-bit result. In fact the values should + * never be outside the range for a 31-bit result, but checking for 32 + * bits here ensures that if an app uses a bogus pass row or column + * (just so long as it fits in a 32 bit integer) it won't get a + * possibly dangerous overflow. + */ + /* First the base 0 stuff: */ + if (v < png_pass_rows(0xFFFFFFFFU, pass)) + { + m = PNG_ROW_FROM_PASS_ROW(v, pass); + f = png_row_from_pass_row(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_ROW_FROM_PASS_ROW(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + } + + if (v < png_pass_cols(0xFFFFFFFFU, pass)) + { + m = PNG_COL_FROM_PASS_COL(v, pass); + f = png_col_from_pass_col(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_COL_FROM_PASS_COL(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + } + + m = PNG_ROW_IN_INTERLACE_PASS(v, pass); + f = png_row_in_interlace_pass(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_ROW_IN_INTERLACE_PASS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + m = PNG_COL_IN_INTERLACE_PASS(v, pass); + f = png_col_in_interlace_pass(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_COL_IN_INTERLACE_PASS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + /* Then the base 1 stuff: */ + ++v; + m = PNG_PASS_ROWS(v, pass); + f = png_pass_rows(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_ROWS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + m = PNG_PASS_COLS(v, pass); + f = png_pass_cols(v, pass); + if (m != f) + { + fprintf(stderr, "PNG_PASS_COLS(%u, %d) = %u != %x\n", + v, pass, m, f); + exit(99); + } + + /* Move to the next v - the stepping algorithm starts skipping + * values above 1024. + */ + if (v > 1024) + { + if (v == PNG_UINT_31_MAX) + break; + + v = (v << 1) ^ v; + if (v >= PNG_UINT_31_MAX) + v = PNG_UINT_31_MAX-1; + } + } + } +} + +/* Test color encodings. These values are back-calculated from the published + * chromaticities. The values are accurate to about 14 decimal places; 15 are + * given. These values are much more accurate than the ones given in the spec, + * which typically don't exceed 4 decimal places. This allows testing of the + * libpng code to its theoretical accuracy of 4 decimal places. (If pngvalid + * used the published errors the 'slack' permitted would have to be +/-.5E-4 or + * more.) + * + * The png_modifier code assumes that encodings[0] is sRGB and treats it + * specially: do not change the first entry in this list! + */ +static const color_encoding test_encodings[] = +{ +/* sRGB: must be first in this list! */ +/*gamma:*/ { 1/2.2, +/*red: */ { 0.412390799265959, 0.212639005871510, 0.019330818715592 }, +/*green:*/ { 0.357584339383878, 0.715168678767756, 0.119194779794626 }, +/*blue: */ { 0.180480788401834, 0.072192315360734, 0.950532152249660} }, +/* Kodak ProPhoto (wide gamut) */ +/*gamma:*/ { 1/1.6 /*approximate: uses 1.8 power law compared to sRGB 2.4*/, +/*red: */ { 0.797760489672303, 0.288071128229293, 0.000000000000000 }, +/*green:*/ { 0.135185837175740, 0.711843217810102, 0.000000000000000 }, +/*blue: */ { 0.031349349581525, 0.000085653960605, 0.825104602510460} }, +/* Adobe RGB (1998) */ +/*gamma:*/ { 1/(2+51./256), +/*red: */ { 0.576669042910131, 0.297344975250536, 0.027031361386412 }, +/*green:*/ { 0.185558237906546, 0.627363566255466, 0.070688852535827 }, +/*blue: */ { 0.188228646234995, 0.075291458493998, 0.991337536837639} }, +/* Adobe Wide Gamut RGB */ +/*gamma:*/ { 1/(2+51./256), +/*red: */ { 0.716500716779386, 0.258728243040113, 0.000000000000000 }, +/*green:*/ { 0.101020574397477, 0.724682314948566, 0.051211818965388 }, +/*blue: */ { 0.146774385252705, 0.016589442011321, 0.773892783545073} }, +/* Fake encoding which selects just the green channel */ +/*gamma:*/ { 1.45/2.2, /* the 'Mac' gamma */ +/*red: */ { 0.716500716779386, 0.000000000000000, 0.000000000000000 }, +/*green:*/ { 0.101020574397477, 1.000000000000000, 0.051211818965388 }, +/*blue: */ { 0.146774385252705, 0.000000000000000, 0.773892783545073} }, +}; + +/* signal handler + * + * This attempts to trap signals and escape without crashing. It needs a + * context pointer so that it can throw an exception (call longjmp) to recover + * from the condition; this is handled by making the png_modifier used by 'main' + * into a global variable. + */ +static png_modifier pm; + +static void signal_handler(int signum) +{ + + size_t pos = 0; + char msg[64]; + + pos = safecat(msg, sizeof msg, pos, "caught signal: "); + + switch (signum) + { + case SIGABRT: + pos = safecat(msg, sizeof msg, pos, "abort"); + break; + + case SIGFPE: + pos = safecat(msg, sizeof msg, pos, "floating point exception"); + break; + + case SIGILL: + pos = safecat(msg, sizeof msg, pos, "illegal instruction"); + break; + + case SIGINT: + pos = safecat(msg, sizeof msg, pos, "interrupt"); + break; + + case SIGSEGV: + pos = safecat(msg, sizeof msg, pos, "invalid memory access"); + break; + + case SIGTERM: + pos = safecat(msg, sizeof msg, pos, "termination request"); + break; + + default: + pos = safecat(msg, sizeof msg, pos, "unknown "); + pos = safecatn(msg, sizeof msg, pos, signum); + break; + } + + store_log(&pm.this, NULL/*png_structp*/, msg, 1/*error*/); + + /* And finally throw an exception so we can keep going, unless this is + * SIGTERM in which case stop now. + */ + if (signum != SIGTERM) + { + struct exception_context *the_exception_context = + &pm.this.exception_context; + + Throw &pm.this; + } + + else + exit(1); +} + +/* main program */ +int main(int argc, char **argv) +{ + int summary = 1; /* Print the error summary at the end */ + int memstats = 0; /* Print memory statistics at the end */ + + /* Create the given output file on success: */ + const char *touch = NULL; + + /* This is an array of standard gamma values (believe it or not I've seen + * every one of these mentioned somewhere.) + * + * In the following list the most useful values are first! + */ + static double + gammas[]={2.2, 1.0, 2.2/1.45, 1.8, 1.5, 2.4, 2.5, 2.62, 2.9}; + + /* This records the command and arguments: */ + size_t cp = 0; + char command[1024]; + + anon_context(&pm.this); + + gnu_volatile(summary) + gnu_volatile(memstats) + gnu_volatile(touch) + + /* Add appropriate signal handlers, just the ANSI specified ones: */ + signal(SIGABRT, signal_handler); + signal(SIGFPE, signal_handler); + signal(SIGILL, signal_handler); + signal(SIGINT, signal_handler); + signal(SIGSEGV, signal_handler); + signal(SIGTERM, signal_handler); + +#ifdef HAVE_FEENABLEEXCEPT + /* Only required to enable FP exceptions on platforms where they start off + * disabled; this is not necessary but if it is not done pngvalid will likely + * end up ignoring FP conditions that other platforms fault. + */ + feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif + + modifier_init(&pm); + + /* Preallocate the image buffer, because we know how big it needs to be, + * note that, for testing purposes, it is deliberately mis-aligned by tag + * bytes either side. All rows have an additional five bytes of padding for + * overwrite checking. + */ + store_ensure_image(&pm.this, NULL, 2, TRANSFORM_ROWMAX, TRANSFORM_HEIGHTMAX); + + /* Don't give argv[0], it's normally some horrible libtool string: */ + cp = safecat(command, sizeof command, cp, "pngvalid"); + + /* Default to error on warning: */ + pm.this.treat_warnings_as_errors = 1; + + /* Default assume_16_bit_calculations appropriately; this tells the checking + * code that 16-bit arithmetic is used for 8-bit samples when it would make a + * difference. + */ + pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700; + + /* Currently 16 bit expansion happens at the end of the pipeline, so the + * calculations are done in the input bit depth not the output. + * + * TODO: fix this + */ + pm.calculations_use_input_precision = 1U; + + /* Store the test gammas */ + pm.gammas = gammas; + pm.ngammas = ARRAY_SIZE(gammas); + pm.ngamma_tests = 0; /* default to off */ + + /* Low bit depth gray images don't do well in the gamma tests, until + * this is fixed turn them off for some gamma cases: + */ +# ifdef PNG_WRITE_tRNS_SUPPORTED + pm.test_tRNS = 1; +# endif + pm.test_lbg = PNG_LIBPNG_VER >= 10600; + pm.test_lbg_gamma_threshold = 1; + pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600; + pm.test_lbg_gamma_sbit = 1; + pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700; + + /* And the test encodings */ + pm.encodings = test_encodings; + pm.nencodings = ARRAY_SIZE(test_encodings); + +# if PNG_LIBPNG_VER < 10700 + pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ +# else + pm.sbitlow = 1U; +# endif + + /* The following allows results to pass if they correspond to anything in the + * transformed range [input-.5,input+.5]; this is is required because of the + * way libpng treates the 16_TO_8 flag when building the gamma tables in + * releases up to 1.6.0. + * + * TODO: review this + */ + pm.use_input_precision_16to8 = 1U; + pm.use_input_precision_sbit = 1U; /* because libpng now rounds sBIT */ + + /* Some default values (set the behavior for 'make check' here). + * These values simply control the maximum error permitted in the gamma + * transformations. The practical limits for human perception are described + * below (the setting for maxpc16), however for 8 bit encodings it isn't + * possible to meet the accepted capabilities of human vision - i.e. 8 bit + * images can never be good enough, regardless of encoding. + */ + pm.maxout8 = .1; /* Arithmetic error in *encoded* value */ + pm.maxabs8 = .00005; /* 1/20000 */ + pm.maxcalc8 = 1./255; /* +/-1 in 8 bits for compose errors */ + pm.maxpc8 = .499; /* I.e., .499% fractional error */ + pm.maxout16 = .499; /* Error in *encoded* value */ + pm.maxabs16 = .00005;/* 1/20000 */ + pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */ +# if PNG_LIBPNG_VER < 10700 + pm.maxcalcG = 1./((1<38149 by the following: + */ + pm.maxpc16 = .005; /* I.e., 1/200% - 1/20000 */ + + /* Now parse the command line options. */ + while (--argc >= 1) + { + int catmore = 0; /* Set if the argument has an argument. */ + + /* Record each argument for posterity: */ + cp = safecat(command, sizeof command, cp, " "); + cp = safecat(command, sizeof command, cp, *++argv); + + if (strcmp(*argv, "-v") == 0) + pm.this.verbose = 1; + + else if (strcmp(*argv, "-l") == 0) + pm.log = 1; + + else if (strcmp(*argv, "-q") == 0) + summary = pm.this.verbose = pm.log = 0; + + else if (strcmp(*argv, "-w") == 0 || + strcmp(*argv, "--strict") == 0) + pm.this.treat_warnings_as_errors = 1; /* NOTE: this is the default! */ + + else if (strcmp(*argv, "--nostrict") == 0) + pm.this.treat_warnings_as_errors = 0; + + else if (strcmp(*argv, "--speed") == 0) + pm.this.speed = 1, pm.ngamma_tests = pm.ngammas, pm.test_standard = 0, + summary = 0; + + else if (strcmp(*argv, "--memory") == 0) + memstats = 1; + + else if (strcmp(*argv, "--size") == 0) + pm.test_size = 1; + + else if (strcmp(*argv, "--nosize") == 0) + pm.test_size = 0; + + else if (strcmp(*argv, "--standard") == 0) + pm.test_standard = 1; + + else if (strcmp(*argv, "--nostandard") == 0) + pm.test_standard = 0; + + else if (strcmp(*argv, "--transform") == 0) + pm.test_transform = 1; + + else if (strcmp(*argv, "--notransform") == 0) + pm.test_transform = 0; + +#ifdef PNG_READ_TRANSFORMS_SUPPORTED + else if (strncmp(*argv, "--transform-disable=", + sizeof "--transform-disable") == 0) + { + pm.test_transform = 1; + transform_disable(*argv + sizeof "--transform-disable"); + } + + else if (strncmp(*argv, "--transform-enable=", + sizeof "--transform-enable") == 0) + { + pm.test_transform = 1; + transform_enable(*argv + sizeof "--transform-enable"); + } +#endif /* PNG_READ_TRANSFORMS_SUPPORTED */ + + else if (strcmp(*argv, "--gamma") == 0) + { + /* Just do two gamma tests here (2.2 and linear) for speed: */ + pm.ngamma_tests = 2U; + pm.test_gamma_threshold = 1; + pm.test_gamma_transform = 1; + pm.test_gamma_sbit = 1; + pm.test_gamma_scale16 = 1; + pm.test_gamma_background = 1; /* composition */ + pm.test_gamma_alpha_mode = 1; + } + + else if (strcmp(*argv, "--nogamma") == 0) + pm.ngamma_tests = 0; + + else if (strcmp(*argv, "--gamma-threshold") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_threshold = 1; + + else if (strcmp(*argv, "--nogamma-threshold") == 0) + pm.test_gamma_threshold = 0; + + else if (strcmp(*argv, "--gamma-transform") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_transform = 1; + + else if (strcmp(*argv, "--nogamma-transform") == 0) + pm.test_gamma_transform = 0; + + else if (strcmp(*argv, "--gamma-sbit") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_sbit = 1; + + else if (strcmp(*argv, "--nogamma-sbit") == 0) + pm.test_gamma_sbit = 0; + + else if (strcmp(*argv, "--gamma-16-to-8") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_scale16 = 1; + + else if (strcmp(*argv, "--nogamma-16-to-8") == 0) + pm.test_gamma_scale16 = 0; + + else if (strcmp(*argv, "--gamma-background") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_background = 1; + + else if (strcmp(*argv, "--nogamma-background") == 0) + pm.test_gamma_background = 0; + + else if (strcmp(*argv, "--gamma-alpha-mode") == 0) + pm.ngamma_tests = 2U, pm.test_gamma_alpha_mode = 1; + + else if (strcmp(*argv, "--nogamma-alpha-mode") == 0) + pm.test_gamma_alpha_mode = 0; + + else if (strcmp(*argv, "--expand16") == 0) + pm.test_gamma_expand16 = 1; + + else if (strcmp(*argv, "--noexpand16") == 0) + pm.test_gamma_expand16 = 0; + + else if (strcmp(*argv, "--low-depth-gray") == 0) + pm.test_lbg = pm.test_lbg_gamma_threshold = + pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit = + pm.test_lbg_gamma_composition = 1; + + else if (strcmp(*argv, "--nolow-depth-gray") == 0) + pm.test_lbg = pm.test_lbg_gamma_threshold = + pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit = + pm.test_lbg_gamma_composition = 0; + +# ifdef PNG_WRITE_tRNS_SUPPORTED + else if (strcmp(*argv, "--tRNS") == 0) + pm.test_tRNS = 1; +# endif + + else if (strcmp(*argv, "--notRNS") == 0) + pm.test_tRNS = 0; + + else if (strcmp(*argv, "--more-gammas") == 0) + pm.ngamma_tests = 3U; + + else if (strcmp(*argv, "--all-gammas") == 0) + pm.ngamma_tests = pm.ngammas; + + else if (strcmp(*argv, "--progressive-read") == 0) + pm.this.progressive = 1; + + else if (strcmp(*argv, "--use-update-info") == 0) + ++pm.use_update_info; /* Can call multiple times */ + + else if (strcmp(*argv, "--interlace") == 0) + { +# if CAN_WRITE_INTERLACE + pm.interlace_type = PNG_INTERLACE_ADAM7; +# else /* !CAN_WRITE_INTERLACE */ + fprintf(stderr, "pngvalid: no write interlace support\n"); + return SKIP; +# endif /* !CAN_WRITE_INTERLACE */ + } + + else if (strcmp(*argv, "--use-input-precision") == 0) + pm.use_input_precision = 1U; + + else if (strcmp(*argv, "--use-calculation-precision") == 0) + pm.use_input_precision = 0; + + else if (strcmp(*argv, "--calculations-use-input-precision") == 0) + pm.calculations_use_input_precision = 1U; + + else if (strcmp(*argv, "--assume-16-bit-calculations") == 0) + pm.assume_16_bit_calculations = 1U; + + else if (strcmp(*argv, "--calculations-follow-bit-depth") == 0) + pm.calculations_use_input_precision = + pm.assume_16_bit_calculations = 0; + + else if (strcmp(*argv, "--exhaustive") == 0) + pm.test_exhaustive = 1; + + else if (argc > 1 && strcmp(*argv, "--sbitlow") == 0) + --argc, pm.sbitlow = (png_byte)atoi(*++argv), catmore = 1; + + else if (argc > 1 && strcmp(*argv, "--touch") == 0) + --argc, touch = *++argv, catmore = 1; + + else if (argc > 1 && strncmp(*argv, "--max", 5) == 0) + { + --argc; + + if (strcmp(5+*argv, "abs8") == 0) + pm.maxabs8 = atof(*++argv); + + else if (strcmp(5+*argv, "abs16") == 0) + pm.maxabs16 = atof(*++argv); + + else if (strcmp(5+*argv, "calc8") == 0) + pm.maxcalc8 = atof(*++argv); + + else if (strcmp(5+*argv, "calc16") == 0) + pm.maxcalc16 = atof(*++argv); + + else if (strcmp(5+*argv, "out8") == 0) + pm.maxout8 = atof(*++argv); + + else if (strcmp(5+*argv, "out16") == 0) + pm.maxout16 = atof(*++argv); + + else if (strcmp(5+*argv, "pc8") == 0) + pm.maxpc8 = atof(*++argv); + + else if (strcmp(5+*argv, "pc16") == 0) + pm.maxpc16 = atof(*++argv); + + else + { + fprintf(stderr, "pngvalid: %s: unknown 'max' option\n", *argv); + exit(99); + } + + catmore = 1; + } + + else if (strcmp(*argv, "--log8") == 0) + --argc, pm.log8 = atof(*++argv), catmore = 1; + + else if (strcmp(*argv, "--log16") == 0) + --argc, pm.log16 = atof(*++argv), catmore = 1; + +#ifdef PNG_SET_OPTION_SUPPORTED + else if (strncmp(*argv, "--option=", 9) == 0) + { + /* Syntax of the argument is
@@ -214,19 +220,19 @@ /MACHINE:I386 %(AdditionalOptions) ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll true .\zlibvc.def true - $(OutDir)zlibwapi.pdb true - $(OutDir)zlibwapi.map Windows false - $(OutDir)zlibwapi.lib + + cd ..\..\masmx86 +bld_ml32.bat + @@ -262,18 +268,14 @@ /MACHINE:I386 %(AdditionalOptions) - $(OutDir)zlibwapi.dll true false .\zlibvc.def - $(OutDir)zlibwapi.pdb true - $(OutDir)zlibwapi.map Windows false - $(OutDir)zlibwapi.lib @@ -311,19 +313,19 @@ /MACHINE:I386 %(AdditionalOptions) ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll true false .\zlibvc.def - $(OutDir)zlibwapi.pdb true - $(OutDir)zlibwapi.map Windows false - $(OutDir)zlibwapi.lib + + cd ..\..\masmx86 +bld_ml32.bat + @@ -357,17 +359,17 @@ ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll true .\zlibvc.def true - $(OutDir)zlibwapi.pdb true - $(OutDir)zlibwapi.map Windows - $(OutDir)zlibwapi.lib MachineX64 + + cd ..\..\masmx64 +bld_ml64.bat + @@ -445,15 +447,11 @@ 0x040c - $(OutDir)zlibwapi.dll true false .\zlibvc.def - $(OutDir)zlibwapi.pdb true - $(OutDir)zlibwapi.map Windows - $(OutDir)zlibwapi.lib MachineX64 @@ -536,17 +534,17 @@ ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) - $(OutDir)zlibwapi.dll true false .\zlibvc.def - $(OutDir)zlibwapi.pdb true - $(OutDir)zlibwapi.map Windows - $(OutDir)zlibwapi.lib MachineX64 + + cd ..\..\masmx64 +bld_ml64.bat + diff --git a/libs/zlib/contrib/vstudio/vc11/miniunz.vcxproj b/libs/zlib/contrib/vstudio/vc11/miniunz.vcxproj new file mode 100644 index 000000000..8f9f20bd3 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/miniunz.vcxproj @@ -0,0 +1,314 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc11/minizip.vcxproj b/libs/zlib/contrib/vstudio/vc11/minizip.vcxproj new file mode 100644 index 000000000..c93d9e6ff --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/minizip.vcxproj @@ -0,0 +1,311 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc11/testzlib.vcxproj b/libs/zlib/contrib/vstudio/vc11/testzlib.vcxproj new file mode 100644 index 000000000..6d5595401 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/testzlib.vcxproj @@ -0,0 +1,426 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + v110 + + + Application + MultiByte + true + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + true + + + Application + MultiByte + true + + + Application + MultiByte + + + Application + true + v110 + + + Application + true + v110 + + + Application + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj b/libs/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj new file mode 100644 index 000000000..9f20c78f6 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj @@ -0,0 +1,314 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + v110 + + + Application + Unicode + v110 + + + Application + MultiByte + + + Application + MultiByte + + + Application + MultiByte + v110 + + + Application + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc11/zlib.rc b/libs/zlib/contrib/vstudio/vc11/zlib.rc new file mode 100644 index 000000000..c4e4b016e --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/libs/zlib/contrib/vstudio/vc11/zlibstat.vcxproj b/libs/zlib/contrib/vstudio/vc11/zlibstat.vcxproj new file mode 100644 index 000000000..806b76a88 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/zlibstat.vcxproj @@ -0,0 +1,464 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + Unicode + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + + + StaticLibrary + false + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc11/zlibvc.def b/libs/zlib/contrib/vstudio/vc11/zlibvc.def new file mode 100644 index 000000000..f876c3bca --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/libs/zlib/contrib/vstudio/vc11/zlibvc.sln b/libs/zlib/contrib/vstudio/vc11/zlibvc.sln new file mode 100644 index 000000000..9fcbafdd0 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/zlibvc.sln @@ -0,0 +1,117 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/zlib/contrib/vstudio/vc11/zlibvc.vcxproj b/libs/zlib/contrib/vstudio/vc11/zlibvc.vcxproj new file mode 100644 index 000000000..c65b95fdb --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc11/zlibvc.vcxproj @@ -0,0 +1,688 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + v110 + Unicode + + + DynamicLibrary + false + true + + + DynamicLibrary + false + true + + + DynamicLibrary + false + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + v110 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\contrib\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc12/miniunz.vcxproj b/libs/zlib/contrib/vstudio/vc12/miniunz.vcxproj new file mode 100644 index 000000000..d88ac7fc7 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/miniunz.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc12/minizip.vcxproj b/libs/zlib/contrib/vstudio/vc12/minizip.vcxproj new file mode 100644 index 000000000..f1f239c9e --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/minizip.vcxproj @@ -0,0 +1,313 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc12/testzlib.vcxproj b/libs/zlib/contrib/vstudio/vc12/testzlib.vcxproj new file mode 100644 index 000000000..64b2cbe34 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/testzlib.vcxproj @@ -0,0 +1,430 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + v120 + + + Application + MultiByte + true + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + true + v120 + + + Application + MultiByte + true + v120 + + + Application + MultiByte + v120 + + + Application + true + v120 + + + Application + true + v120 + + + Application + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + false + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj b/libs/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj new file mode 100644 index 000000000..c66573a8b --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + v120 + + + Application + Unicode + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + Application + MultiByte + v120 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc12/zlib.rc b/libs/zlib/contrib/vstudio/vc12/zlib.rc new file mode 100644 index 000000000..c4e4b016e --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/libs/zlib/contrib/vstudio/vc12/zlibstat.vcxproj b/libs/zlib/contrib/vstudio/vc12/zlibstat.vcxproj new file mode 100644 index 000000000..3fdee7c50 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/zlibstat.vcxproj @@ -0,0 +1,467 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + Unicode + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + StaticLibrary + false + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc12/zlibvc.def b/libs/zlib/contrib/vstudio/vc12/zlibvc.def new file mode 100644 index 000000000..f876c3bca --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/libs/zlib/contrib/vstudio/vc12/zlibvc.sln b/libs/zlib/contrib/vstudio/vc12/zlibvc.sln new file mode 100644 index 000000000..dcda22984 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/zlibvc.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/zlib/contrib/vstudio/vc12/zlibvc.vcxproj b/libs/zlib/contrib/vstudio/vc12/zlibvc.vcxproj new file mode 100644 index 000000000..ab2b6c360 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc12/zlibvc.vcxproj @@ -0,0 +1,692 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + v120 + Unicode + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + false + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\contrib\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc14/miniunz.vcxproj b/libs/zlib/contrib/vstudio/vc14/miniunz.vcxproj new file mode 100644 index 000000000..9b5c07587 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/miniunz.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694382A} + Win32Proj + + + + Application + MultiByte + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + true + false + x86\MiniUnzip$(Configuration)\ + x86\MiniUnzip$(Configuration)\Tmp\ + false + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + true + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + true + false + x64\MiniUnzip$(Configuration)\ + x64\MiniUnzip$(Configuration)\Tmp\ + false + false + ia64\MiniUnzip$(Configuration)\ + ia64\MiniUnzip$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + $(OutDir)miniunz.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)miniunz.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc14/minizip.vcxproj b/libs/zlib/contrib/vstudio/vc14/minizip.vcxproj new file mode 100644 index 000000000..968a410a1 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/minizip.vcxproj @@ -0,0 +1,313 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B} + Win32Proj + + + + Application + MultiByte + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + true + false + x86\MiniZip$(Configuration)\ + x86\MiniZip$(Configuration)\Tmp\ + false + x64\$(Configuration)\ + x64\$(Configuration)\ + true + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + true + false + x64\$(Configuration)\ + x64\$(Configuration)\ + false + ia64\$(Configuration)\ + ia64\$(Configuration)\ + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + $(OutDir)minizip.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)minizip.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc14/testzlib.vcxproj b/libs/zlib/contrib/vstudio/vc14/testzlib.vcxproj new file mode 100644 index 000000000..2c371252a --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/testzlib.vcxproj @@ -0,0 +1,430 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B} + testzlib + Win32Proj + + + + Application + MultiByte + true + v140 + + + Application + MultiByte + true + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + true + v140 + + + Application + MultiByte + true + v140 + + + Application + MultiByte + v140 + + + Application + true + v140 + + + Application + true + v140 + + + Application + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + true + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x86\TestZlib$(Configuration)\ + x86\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + true + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + x64\TestZlib$(Configuration)\ + x64\TestZlib$(Configuration)\Tmp\ + false + ia64\TestZlib$(Configuration)\ + ia64\TestZlib$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)testzlib.exe + true + Console + true + true + false + + + MachineX86 + false + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDebugDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + Disabled + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_DEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + AssemblyAndSourceCode + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + %(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + ..\..\..;%(AdditionalIncludeDirectories) + ASMV;ASMINF;WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + Default + MultiThreadedDLL + false + $(IntDir) + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;NDEBUG;_CONSOLE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + $(OutDir)testzlib.exe + true + Console + true + true + MachineIA64 + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj b/libs/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj new file mode 100644 index 000000000..d87474dec --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj @@ -0,0 +1,316 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {C52F9E7B-498A-42BE-8DB4-85A15694366A} + Win32Proj + + + + Application + MultiByte + v140 + + + Application + Unicode + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + Application + MultiByte + v140 + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + true + false + x86\TestZlibDll$(Configuration)\ + x86\TestZlibDll$(Configuration)\Tmp\ + false + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + true + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + true + false + x64\TestZlibDll$(Configuration)\ + x64\TestZlibDll$(Configuration)\Tmp\ + false + false + ia64\TestZlibDll$(Configuration)\ + ia64\TestZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + false + + + MachineX86 + + + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + Default + MultiThreaded + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x86\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + false + + + MachineX86 + + + + + X64 + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineX64 + + + + + Itanium + + + Disabled + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;_DEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDebugDLL + false + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllDebug\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + $(OutDir)testzlib.pdb + Console + MachineIA64 + + + + + X64 + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + x64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineX64 + + + + + Itanium + + + MaxSpeed + OnlyExplicitInline + true + ..\..\..;..\..\minizip;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ZLIB_WINAPI;NDEBUG;_CONSOLE;WIN64;%(PreprocessorDefinitions) + true + Default + MultiThreadedDLL + false + true + + + $(IntDir) + Level3 + ProgramDatabase + + + ia64\ZlibDllRelease\zlibwapi.lib;%(AdditionalDependencies) + $(OutDir)testzlibdll.exe + true + Console + true + true + MachineIA64 + + + + + + + + {8fd826f8-3739-44e6-8cc8-997122e53b8d} + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc14/zlib.rc b/libs/zlib/contrib/vstudio/vc14/zlib.rc new file mode 100644 index 000000000..c4e4b016e --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/zlib.rc @@ -0,0 +1,32 @@ +#include + +#define IDR_VERSION1 1 +IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS 0 + FILEOS VOS_DOS_WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + + BEGIN + VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" + VALUE "FileVersion", "1.2.11\0" + VALUE "InternalName", "zlib\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" + VALUE "ProductName", "ZLib.DLL\0" + VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/libs/zlib/contrib/vstudio/vc14/zlibstat.vcxproj b/libs/zlib/contrib/vstudio/vc14/zlibstat.vcxproj new file mode 100644 index 000000000..3e4b98639 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/zlibstat.vcxproj @@ -0,0 +1,467 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8} + + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + Unicode + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + StaticLibrary + false + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x86\ZlibStat$(Configuration)\ + x86\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + x64\ZlibStat$(Configuration)\ + x64\ZlibStat$(Configuration)\Tmp\ + ia64\ZlibStat$(Configuration)\ + ia64\ZlibStat$(Configuration)\Tmp\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:X86 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + OldStyle + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + X64 + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:AMD64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + Itanium + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + ZLIB_WINAPI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibstat.pch + $(IntDir) + $(IntDir) + $(OutDir) + Level3 + true + + + 0x040c + + + /MACHINE:IA64 /NODEFAULTLIB %(AdditionalOptions) + $(OutDir)zlibstat.lib + true + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc14/zlibvc.def b/libs/zlib/contrib/vstudio/vc14/zlibvc.def new file mode 100644 index 000000000..f876c3bca --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/zlibvc.def @@ -0,0 +1,153 @@ +LIBRARY +; zlib data compression and ZIP file I/O library + +VERSION 1.2 + +EXPORTS + adler32 @1 + compress @2 + crc32 @3 + deflate @4 + deflateCopy @5 + deflateEnd @6 + deflateInit2_ @7 + deflateInit_ @8 + deflateParams @9 + deflateReset @10 + deflateSetDictionary @11 + gzclose @12 + gzdopen @13 + gzerror @14 + gzflush @15 + gzopen @16 + gzread @17 + gzwrite @18 + inflate @19 + inflateEnd @20 + inflateInit2_ @21 + inflateInit_ @22 + inflateReset @23 + inflateSetDictionary @24 + inflateSync @25 + uncompress @26 + zlibVersion @27 + gzprintf @28 + gzputc @29 + gzgetc @30 + gzseek @31 + gzrewind @32 + gztell @33 + gzeof @34 + gzsetparams @35 + zError @36 + inflateSyncPoint @37 + get_crc_table @38 + compress2 @39 + gzputs @40 + gzgets @41 + inflateCopy @42 + inflateBackInit_ @43 + inflateBack @44 + inflateBackEnd @45 + compressBound @46 + deflateBound @47 + gzclearerr @48 + gzungetc @49 + zlibCompileFlags @50 + deflatePrime @51 + deflatePending @52 + + unzOpen @61 + unzClose @62 + unzGetGlobalInfo @63 + unzGetCurrentFileInfo @64 + unzGoToFirstFile @65 + unzGoToNextFile @66 + unzOpenCurrentFile @67 + unzReadCurrentFile @68 + unzOpenCurrentFile3 @69 + unztell @70 + unzeof @71 + unzCloseCurrentFile @72 + unzGetGlobalComment @73 + unzStringFileNameCompare @74 + unzLocateFile @75 + unzGetLocalExtrafield @76 + unzOpen2 @77 + unzOpenCurrentFile2 @78 + unzOpenCurrentFilePassword @79 + + zipOpen @80 + zipOpenNewFileInZip @81 + zipWriteInFileInZip @82 + zipCloseFileInZip @83 + zipClose @84 + zipOpenNewFileInZip2 @86 + zipCloseFileInZipRaw @87 + zipOpen2 @88 + zipOpenNewFileInZip3 @89 + + unzGetFilePos @100 + unzGoToFilePos @101 + + fill_win32_filefunc @110 + +; zlibwapi v1.2.4 added: + fill_win32_filefunc64 @111 + fill_win32_filefunc64A @112 + fill_win32_filefunc64W @113 + + unzOpen64 @120 + unzOpen2_64 @121 + unzGetGlobalInfo64 @122 + unzGetCurrentFileInfo64 @124 + unzGetCurrentFileZStreamPos64 @125 + unztell64 @126 + unzGetFilePos64 @127 + unzGoToFilePos64 @128 + + zipOpen64 @130 + zipOpen2_64 @131 + zipOpenNewFileInZip64 @132 + zipOpenNewFileInZip2_64 @133 + zipOpenNewFileInZip3_64 @134 + zipOpenNewFileInZip4_64 @135 + zipCloseFileInZipRaw64 @136 + +; zlib1 v1.2.4 added: + adler32_combine @140 + crc32_combine @142 + deflateSetHeader @144 + deflateTune @145 + gzbuffer @146 + gzclose_r @147 + gzclose_w @148 + gzdirect @149 + gzoffset @150 + inflateGetHeader @156 + inflateMark @157 + inflatePrime @158 + inflateReset2 @159 + inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/libs/zlib/contrib/vstudio/vc14/zlibvc.sln b/libs/zlib/contrib/vstudio/vc14/zlibvc.sln new file mode 100644 index 000000000..6f4a1076a --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/zlibvc.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibvc", "zlibvc.vcxproj", "{8FD826F8-3739-44E6-8CC8-997122E53B8D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlibstat", "zlibstat.vcxproj", "{745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlib", "testzlib.vcxproj", "{AA6666AA-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testzlibdll", "testzlibdll.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694366A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minizip", "minizip.vcxproj", "{48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "miniunz", "miniunz.vcxproj", "{C52F9E7B-498A-42BE-8DB4-85A15694382A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Itanium = Debug|Itanium + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Itanium = Release|Itanium + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + ReleaseWithoutAsm|Itanium = ReleaseWithoutAsm|Itanium + ReleaseWithoutAsm|Win32 = ReleaseWithoutAsm|Win32 + ReleaseWithoutAsm|x64 = ReleaseWithoutAsm|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Itanium.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.ActiveCfg = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|Win32.Build.0 = Debug|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.ActiveCfg = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Debug|x64.Build.0 = Debug|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Itanium.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.ActiveCfg = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|Win32.Build.0 = Release|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.ActiveCfg = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.Release|x64.Build.0 = Release|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {8FD826F8-3739-44E6-8CC8-997122E53B8D}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Itanium.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.ActiveCfg = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|Win32.Build.0 = Debug|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.ActiveCfg = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Debug|x64.Build.0 = Debug|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Itanium.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.ActiveCfg = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|Win32.Build.0 = Release|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.ActiveCfg = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.Release|x64.Build.0 = Release|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {745DEC58-EBB3-47A9-A9B8-4C6627C01BF8}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.Build.0 = ReleaseWithoutAsm|Win32 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = ReleaseWithoutAsm|x64 + {AA6666AA-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.Build.0 = ReleaseWithoutAsm|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694366A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Itanium.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.ActiveCfg = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|Win32.Build.0 = Debug|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.ActiveCfg = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Debug|x64.Build.0 = Debug|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|Win32.Build.0 = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.ActiveCfg = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.Release|x64.Build.0 = Release|x64 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {48CDD9DC-E09F-4135-9C0C-4FE50C3C654B}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Itanium.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.ActiveCfg = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|Win32.Build.0 = Debug|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.ActiveCfg = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Debug|x64.Build.0 = Debug|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|Win32.Build.0 = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.ActiveCfg = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.Release|x64.Build.0 = Release|x64 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Itanium.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|Win32.ActiveCfg = Release|Win32 + {C52F9E7B-498A-42BE-8DB4-85A15694382A}.ReleaseWithoutAsm|x64.ActiveCfg = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libs/zlib/contrib/vstudio/vc14/zlibvc.vcxproj b/libs/zlib/contrib/vstudio/vc14/zlibvc.vcxproj new file mode 100644 index 000000000..f8f673cb0 --- /dev/null +++ b/libs/zlib/contrib/vstudio/vc14/zlibvc.vcxproj @@ -0,0 +1,692 @@ + + + + + Debug + Itanium + + + Debug + Win32 + + + Debug + x64 + + + ReleaseWithoutAsm + Itanium + + + ReleaseWithoutAsm + Win32 + + + ReleaseWithoutAsm + x64 + + + Release + Itanium + + + Release + Win32 + + + Release + x64 + + + + {8FD826F8-3739-44E6-8CC8-997122E53B8D} + + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + v140 + Unicode + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + v140 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30128.1 + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + true + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x86\ZlibDll$(Configuration)\ + x86\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + true + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + true + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + x64\ZlibDll$(Configuration)\ + x64\ZlibDll$(Configuration)\Tmp\ + false + false + ia64\ZlibDll$(Configuration)\ + ia64\ZlibDll$(Configuration)\Tmp\ + false + false + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + zlibwapi + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;%(PreprocessorDefinitions) + true + + + MultiThreaded + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + /MACHINE:I386 %(AdditionalOptions) + ..\..\masmx86\match686.obj;..\..\masmx86\inffas32.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + false + + + $(OutDir)zlibwapi.lib + false + + + cd ..\..\masmx86 +bld_ml32.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\contrib\masmx64 +bld_ml64.bat + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + Disabled + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + + + MultiThreadedDebugDLL + false + $(IntDir)zlibvc.pch + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + .\zlibvc.def + true + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + WIN32;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;ASMV;ASMINF;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + ..\..\masmx64\gvmat64.obj;..\..\masmx64\inffasx64.obj;%(AdditionalDependencies) + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineX64 + + + cd ..\..\masmx64 +bld_ml64.bat + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Itanium + $(OutDir)zlibvc.tlb + + + OnlyExplicitInline + ..\..\..;..\..\masmx86;%(AdditionalIncludeDirectories) + _CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_WARNINGS;ZLIB_WINAPI;WIN64;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + true + $(IntDir)zlibvc.pch + All + $(IntDir) + $(IntDir) + $(OutDir) + + + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x040c + + + $(OutDir)zlibwapi.dll + true + false + .\zlibvc.def + $(OutDir)zlibwapi.pdb + true + $(OutDir)zlibwapi.map + Windows + $(OutDir)zlibwapi.lib + MachineIA64 + + + + + + + + + + + + + + true + true + true + true + true + true + + + + + + + + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + %(AdditionalIncludeDirectories) + ZLIB_INTERNAL;%(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libs/zlib/contrib/vstudio/vc9/zlib.rc b/libs/zlib/contrib/vstudio/vc9/zlib.rc index 863b59c78..c4e4b016e 100644 --- a/libs/zlib/contrib/vstudio/vc9/zlib.rc +++ b/libs/zlib/contrib/vstudio/vc9/zlib.rc @@ -2,8 +2,8 @@ #define IDR_VERSION1 1 IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE - FILEVERSION 1,2,5,0 - PRODUCTVERSION 1,2,5,0 + FILEVERSION 1, 2, 11, 0 + PRODUCTVERSION 1, 2, 11, 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_DOS_WINDOWS32 @@ -17,12 +17,12 @@ BEGIN BEGIN VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" - VALUE "FileVersion", "1.2.5.0\0" + VALUE "FileVersion", "1.2.11\0" VALUE "InternalName", "zlib\0" - VALUE "OriginalFilename", "zlib.dll\0" + VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "ProductName", "ZLib.DLL\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" - VALUE "LegalCopyright", "(C) 1995-2010 Jean-loup Gailly & Mark Adler\0" + VALUE "LegalCopyright", "(C) 1995-2017 Jean-loup Gailly & Mark Adler\0" END END BLOCK "VarFileInfo" diff --git a/libs/zlib/contrib/vstudio/vc9/zlibvc.def b/libs/zlib/contrib/vstudio/vc9/zlibvc.def index fa171ae92..f876c3bca 100644 --- a/libs/zlib/contrib/vstudio/vc9/zlibvc.def +++ b/libs/zlib/contrib/vstudio/vc9/zlibvc.def @@ -1,7 +1,7 @@ LIBRARY ; zlib data compression and ZIP file I/O library -VERSION 1.24 +VERSION 1.2 EXPORTS adler32 @1 @@ -55,6 +55,7 @@ EXPORTS gzungetc @49 zlibCompileFlags @50 deflatePrime @51 + deflatePending @52 unzOpen @61 unzClose @62 @@ -128,3 +129,25 @@ EXPORTS inflatePrime @158 inflateReset2 @159 inflateUndermine @160 + +; zlib1 v1.2.6 added: + gzgetc_ @161 + inflateResetKeep @163 + deflateResetKeep @164 + +; zlib1 v1.2.7 added: + gzopen_w @165 + +; zlib1 v1.2.8 added: + inflateGetDictionary @166 + gzvprintf @167 + +; zlib1 v1.2.9 added: + inflateCodesUsed @168 + inflateValidate @169 + uncompress2 @170 + gzfread @171 + gzfwrite @172 + deflateGetDictionary @173 + adler32_z @174 + crc32_z @175 diff --git a/libs/zlib/crc32.c b/libs/zlib/crc32.c index c12471e61..9580440c0 100644 --- a/libs/zlib/crc32.c +++ b/libs/zlib/crc32.c @@ -1,5 +1,5 @@ /* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2006, 2010, 2011 Mark Adler + * Copyright (C) 1995-2006, 2010, 2011, 2012, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h * * Thanks to Rodney Brown for his contribution of faster @@ -30,41 +30,17 @@ #include "zutil.h" /* for STDC and FAR definitions */ -#define local static - -/* Find a four-byte integer type for crc32_little() and crc32_big(). */ -#ifndef NOBYFOUR -# ifdef STDC /* need ANSI C limits.h to determine sizes */ -# include -# define BYFOUR -# if (UINT_MAX == 0xffffffffUL) - typedef unsigned int u4; -# else -# if (ULONG_MAX == 0xffffffffUL) - typedef unsigned long u4; -# else -# if (USHRT_MAX == 0xffffffffUL) - typedef unsigned short u4; -# else -# undef BYFOUR /* can't find a four-byte integer type! */ -# endif -# endif -# endif -# endif /* STDC */ -#endif /* !NOBYFOUR */ - /* Definitions for doing the crc four data bytes at a time. */ +#if !defined(NOBYFOUR) && defined(Z_U4) +# define BYFOUR +#endif #ifdef BYFOUR - typedef u4 crc_table_t; -# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \ - (((w)&0xff00)<<8)+(((w)&0xff)<<24)) local unsigned long crc32_little OF((unsigned long, - const unsigned char FAR *, unsigned)); + const unsigned char FAR *, z_size_t)); local unsigned long crc32_big OF((unsigned long, - const unsigned char FAR *, unsigned)); + const unsigned char FAR *, z_size_t)); # define TBLS 8 #else - typedef unsigned long crc_table_t; # define TBLS 1 #endif /* BYFOUR */ @@ -78,10 +54,10 @@ local uLong crc32_combine_ OF((uLong crc1, uLong crc2, z_off64_t len2)); #ifdef DYNAMIC_CRC_TABLE local volatile int crc_table_empty = 1; -local crc_table_t FAR crc_table[TBLS][256]; +local z_crc_t FAR crc_table[TBLS][256]; local void make_crc_table OF((void)); #ifdef MAKECRCH - local void write_table OF((FILE *, const crc_table_t FAR *)); + local void write_table OF((FILE *, const z_crc_t FAR *)); #endif /* MAKECRCH */ /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: @@ -111,9 +87,9 @@ local void make_crc_table OF((void)); */ local void make_crc_table() { - crc_table_t c; + z_crc_t c; int n, k; - crc_table_t poly; /* polynomial exclusive-or pattern */ + z_crc_t poly; /* polynomial exclusive-or pattern */ /* terms of polynomial defining this crc (except x^32): */ static volatile int first = 1; /* flag to limit concurrent making */ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; @@ -127,11 +103,11 @@ local void make_crc_table() /* make exclusive-or pattern from polynomial (0xedb88320UL) */ poly = 0; for (n = 0; n < (int)(sizeof(p)/sizeof(unsigned char)); n++) - poly |= (crc_table_t)1 << (31 - p[n]); + poly |= (z_crc_t)1 << (31 - p[n]); /* generate a crc for every 8-bit value */ for (n = 0; n < 256; n++) { - c = (crc_table_t)n; + c = (z_crc_t)n; for (k = 0; k < 8; k++) c = c & 1 ? poly ^ (c >> 1) : c >> 1; crc_table[0][n] = c; @@ -142,11 +118,11 @@ local void make_crc_table() and then the byte reversal of those as well as the first table */ for (n = 0; n < 256; n++) { c = crc_table[0][n]; - crc_table[4][n] = REV(c); + crc_table[4][n] = ZSWAP32(c); for (k = 1; k < 4; k++) { c = crc_table[0][c & 0xff] ^ (c >> 8); crc_table[k][n] = c; - crc_table[k + 4][n] = REV(c); + crc_table[k + 4][n] = ZSWAP32(c); } } #endif /* BYFOUR */ @@ -168,7 +144,7 @@ local void make_crc_table() if (out == NULL) return; fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); - fprintf(out, "local const crc_table_t FAR "); + fprintf(out, "local const z_crc_t FAR "); fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); write_table(out, crc_table[0]); # ifdef BYFOUR @@ -188,7 +164,7 @@ local void make_crc_table() #ifdef MAKECRCH local void write_table(out, table) FILE *out; - const crc_table_t FAR *table; + const z_crc_t FAR *table; { int n; @@ -209,13 +185,13 @@ local void write_table(out, table) /* ========================================================================= * This function can be used by asm versions of crc32() */ -const unsigned long FAR * ZEXPORT get_crc_table() +const z_crc_t FAR * ZEXPORT get_crc_table() { #ifdef DYNAMIC_CRC_TABLE if (crc_table_empty) make_crc_table(); #endif /* DYNAMIC_CRC_TABLE */ - return (const unsigned long FAR *)crc_table; + return (const z_crc_t FAR *)crc_table; } /* ========================================================================= */ @@ -223,10 +199,10 @@ const unsigned long FAR * ZEXPORT get_crc_table() #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 /* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) +unsigned long ZEXPORT crc32_z(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; - uInt len; + z_size_t len; { if (buf == Z_NULL) return 0UL; @@ -237,7 +213,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) #ifdef BYFOUR if (sizeof(void *) == sizeof(ptrdiff_t)) { - u4 endian; + z_crc_t endian; endian = 1; if (*((unsigned char *)(&endian))) @@ -257,8 +233,29 @@ unsigned long ZEXPORT crc32(crc, buf, len) return crc ^ 0xffffffffUL; } +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + uInt len; +{ + return crc32_z(crc, buf, len); +} + #ifdef BYFOUR +/* + This BYFOUR code accesses the passed unsigned char * buffer with a 32-bit + integer pointer type. This violates the strict aliasing rule, where a + compiler can assume, for optimization purposes, that two pointers to + fundamentally different types won't ever point to the same memory. This can + manifest as a problem only if one of the pointers is written to. This code + only reads from those pointers. So long as this code remains isolated in + this compilation unit, there won't be a problem. For this reason, this code + should not be copied and pasted into a compilation unit in which other code + writes to the buffer that is passed to these routines. + */ + /* ========================================================================= */ #define DOLIT4 c ^= *buf4++; \ c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ @@ -269,19 +266,19 @@ unsigned long ZEXPORT crc32(crc, buf, len) local unsigned long crc32_little(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; - unsigned len; + z_size_t len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = (u4)crc; + c = (z_crc_t)crc; c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; while (len >= 32) { DOLIT32; len -= 32; @@ -300,7 +297,7 @@ local unsigned long crc32_little(crc, buf, len) } /* ========================================================================= */ -#define DOBIG4 c ^= *++buf4; \ +#define DOBIG4 c ^= *buf4++; \ c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] #define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 @@ -309,20 +306,19 @@ local unsigned long crc32_little(crc, buf, len) local unsigned long crc32_big(crc, buf, len) unsigned long crc; const unsigned char FAR *buf; - unsigned len; + z_size_t len; { - register u4 c; - register const u4 FAR *buf4; + register z_crc_t c; + register const z_crc_t FAR *buf4; - c = REV((u4)crc); + c = ZSWAP32((z_crc_t)crc); c = ~c; while (len && ((ptrdiff_t)buf & 3)) { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); len--; } - buf4 = (const u4 FAR *)(const void FAR *)buf; - buf4--; + buf4 = (const z_crc_t FAR *)(const void FAR *)buf; while (len >= 32) { DOBIG32; len -= 32; @@ -331,14 +327,13 @@ local unsigned long crc32_big(crc, buf, len) DOBIG4; len -= 4; } - buf4++; buf = (const unsigned char FAR *)buf4; if (len) do { c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); } while (--len); c = ~c; - return (unsigned long)(REV(c)); + return (unsigned long)(ZSWAP32(c)); } #endif /* BYFOUR */ diff --git a/libs/zlib/crc32.h b/libs/zlib/crc32.h index c3e7171c5..9e0c77810 100644 --- a/libs/zlib/crc32.h +++ b/libs/zlib/crc32.h @@ -2,7 +2,7 @@ * Generated automatically by crc32.c */ -local const crc_table_t FAR crc_table[TBLS][256] = +local const z_crc_t FAR crc_table[TBLS][256] = { { 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL, diff --git a/libs/zlib/deflate.c b/libs/zlib/deflate.c index 8bd480eb6..1ec761448 100644 --- a/libs/zlib/deflate.c +++ b/libs/zlib/deflate.c @@ -1,5 +1,5 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -52,7 +52,7 @@ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.6 Copyright 1995-2012 Jean-loup Gailly and Mark Adler "; + " deflate 1.2.11 Copyright 1995-2017 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -73,6 +73,8 @@ typedef enum { typedef block_state (*compress_func) OF((deflate_state *s, int flush)); /* Compression function. Returns the block state after the call. */ +local int deflateStateCheck OF((z_streamp strm)); +local void slide_hash OF((deflate_state *s)); local void fill_window OF((deflate_state *s)); local block_state deflate_stored OF((deflate_state *s, int flush)); local block_state deflate_fast OF((deflate_state *s, int flush)); @@ -84,15 +86,16 @@ local block_state deflate_huff OF((deflate_state *s, int flush)); local void lm_init OF((deflate_state *s)); local void putShortMSB OF((deflate_state *s, uInt b)); local void flush_pending OF((z_streamp strm)); -local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); +local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); #ifdef ASMV +# pragma message("Assembler code may have bugs -- use at your own risk") void match_init OF((void)); /* asm code initialization */ uInt longest_match OF((deflate_state *s, IPos cur_match)); #else local uInt longest_match OF((deflate_state *s, IPos cur_match)); #endif -#ifdef DEBUG +#ifdef ZLIB_DEBUG local void check_match OF((deflate_state *s, IPos start, IPos match, int length)); #endif @@ -148,21 +151,14 @@ local const config configuration_table[10] = { * meaning. */ -#define EQUAL 0 -/* result of memcmp for equal strings */ - -#ifndef NO_DUMMY_DECL -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ -#endif - /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) +#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) /* =========================================================================== * Update a hash value with the given input byte - * IN assertion: all calls to to UPDATE_HASH are made with consecutive - * input characters, so that a running hash key can be computed from the - * previous key instead of complete recalculation each time. + * IN assertion: all calls to UPDATE_HASH are made with consecutive input + * characters, so that a running hash key can be computed from the previous + * key instead of complete recalculation each time. */ #define UPDATE_HASH(s,h,c) (h = (((h)<hash_shift) ^ (c)) & s->hash_mask) @@ -173,9 +169,9 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ * the previous length of the hash chain. * If this file is compiled with -DFASTEST, the compression level is forced * to 1, and no hash chains are maintained. - * IN assertion: all calls to to INSERT_STRING are made with consecutive - * input characters and the first MIN_MATCH bytes of str are valid - * (except for the last MIN_MATCH-1 bytes of the input file). + * IN assertion: all calls to INSERT_STRING are made with consecutive input + * characters and the first MIN_MATCH bytes of str are valid (except for + * the last MIN_MATCH-1 bytes of the input file). */ #ifdef FASTEST #define INSERT_STRING(s, str, match_head) \ @@ -197,6 +193,37 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ s->head[s->hash_size-1] = NIL; \ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head)); +/* =========================================================================== + * Slide the hash table when sliding the window down (could be avoided with 32 + * bit values at the expense of memory usage). We slide even when level == 0 to + * keep the hash table consistent if we switch back to level > 0 later. + */ +local void slide_hash(s) + deflate_state *s; +{ + unsigned n, m; + Posf *p; + uInt wsize = s->w_size; + + n = s->hash_size; + p = &s->head[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m - wsize : NIL); + } while (--n); + n = wsize; +#ifndef FASTEST + p = &s->prev[n]; + do { + m = *--p; + *p = (Pos)(m >= wsize ? m - wsize : NIL); + /* If n is not on any hash chain, prev[n] is garbage but + * its value will never be used. + */ + } while (--n); +#endif +} + /* ========================================================================= */ int ZEXPORT deflateInit_(strm, level, version, stream_size) z_streamp strm; @@ -270,7 +297,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, #endif if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_FIXED) { + strategy < 0 || strategy > Z_FIXED || (windowBits == 8 && wrap != 1)) { return Z_STREAM_ERROR; } if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */ @@ -278,14 +305,15 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (s == Z_NULL) return Z_MEM_ERROR; strm->state = (struct internal_state FAR *)s; s->strm = strm; + s->status = INIT_STATE; /* to pass state test in deflateReset() */ s->wrap = wrap; s->gzhead = Z_NULL; - s->w_bits = windowBits; + s->w_bits = (uInt)windowBits; s->w_size = 1 << s->w_bits; s->w_mask = s->w_size - 1; - s->hash_bits = memLevel + 7; + s->hash_bits = (uInt)memLevel + 7; s->hash_size = 1 << s->hash_bits; s->hash_mask = s->hash_size - 1; s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH); @@ -305,7 +333,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { s->status = FINISH_STATE; - strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); + strm->msg = ERR_MSG(Z_MEM_ERROR); deflateEnd (strm); return Z_MEM_ERROR; } @@ -319,6 +347,31 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, return deflateReset(strm); } +/* ========================================================================= + * Check for a valid deflate stream state. Return 0 if ok, 1 if not. + */ +local int deflateStateCheck (strm) + z_streamp strm; +{ + deflate_state *s; + if (strm == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + return 1; + s = strm->state; + if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE && +#ifdef GZIP + s->status != GZIP_STATE && +#endif + s->status != EXTRA_STATE && + s->status != NAME_STATE && + s->status != COMMENT_STATE && + s->status != HCRC_STATE && + s->status != BUSY_STATE && + s->status != FINISH_STATE)) + return 1; + return 0; +} + /* ========================================================================= */ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) z_streamp strm; @@ -329,9 +382,9 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) uInt str, n; int wrap; unsigned avail; - unsigned char *next; + z_const unsigned char *next; - if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL) + if (deflateStateCheck(strm) || dictionary == Z_NULL) return Z_STREAM_ERROR; s = strm->state; wrap = s->wrap; @@ -359,7 +412,7 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) avail = strm->avail_in; next = strm->next_in; strm->avail_in = dictLength; - strm->next_in = (Bytef *)dictionary; + strm->next_in = (z_const Bytef *)dictionary; fill_window(s); while (s->lookahead >= MIN_MATCH) { str = s->strstart; @@ -388,14 +441,35 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength) return Z_OK; } +/* ========================================================================= */ +int ZEXPORT deflateGetDictionary (strm, dictionary, dictLength) + z_streamp strm; + Bytef *dictionary; + uInt *dictLength; +{ + deflate_state *s; + uInt len; + + if (deflateStateCheck(strm)) + return Z_STREAM_ERROR; + s = strm->state; + len = s->strstart + s->lookahead; + if (len > s->w_size) + len = s->w_size; + if (dictionary != Z_NULL && len) + zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len); + if (dictLength != Z_NULL) + *dictLength = len; + return Z_OK; +} + /* ========================================================================= */ int ZEXPORT deflateResetKeep (strm) z_streamp strm; { deflate_state *s; - if (strm == Z_NULL || strm->state == Z_NULL || - strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { + if (deflateStateCheck(strm)) { return Z_STREAM_ERROR; } @@ -410,7 +484,11 @@ int ZEXPORT deflateResetKeep (strm) if (s->wrap < 0) { s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ } - s->status = s->wrap ? INIT_STATE : BUSY_STATE; + s->status = +#ifdef GZIP + s->wrap == 2 ? GZIP_STATE : +#endif + s->wrap ? INIT_STATE : BUSY_STATE; strm->adler = #ifdef GZIP s->wrap == 2 ? crc32(0L, Z_NULL, 0) : @@ -440,8 +518,8 @@ int ZEXPORT deflateSetHeader (strm, head) z_streamp strm; gz_headerp head; { - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; - if (strm->state->wrap != 2) return Z_STREAM_ERROR; + if (deflateStateCheck(strm) || strm->state->wrap != 2) + return Z_STREAM_ERROR; strm->state->gzhead = head; return Z_OK; } @@ -452,7 +530,7 @@ int ZEXPORT deflatePending (strm, pending, bits) int *bits; z_streamp strm; { - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != Z_NULL) *pending = strm->state->pending; if (bits != Z_NULL) @@ -469,7 +547,7 @@ int ZEXPORT deflatePrime (strm, bits, value) deflate_state *s; int put; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; if ((Bytef *)(s->d_buf) < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; @@ -494,9 +572,8 @@ int ZEXPORT deflateParams(strm, level, strategy) { deflate_state *s; compress_func func; - int err = Z_OK; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; #ifdef FASTEST @@ -510,11 +587,22 @@ int ZEXPORT deflateParams(strm, level, strategy) func = configuration_table[s->level].func; if ((strategy != s->strategy || func != configuration_table[level].func) && - strm->total_in != 0) { + s->high_water) { /* Flush the last buffer: */ - err = deflate(strm, Z_BLOCK); + int err = deflate(strm, Z_BLOCK); + if (err == Z_STREAM_ERROR) + return err; + if (strm->avail_out == 0) + return Z_BUF_ERROR; } if (s->level != level) { + if (s->level == 0 && s->matches != 0) { + if (s->matches == 1) + slide_hash(s); + else + CLEAR_HASH(s); + s->matches = 0; + } s->level = level; s->max_lazy_match = configuration_table[level].max_lazy; s->good_match = configuration_table[level].good_length; @@ -522,7 +610,7 @@ int ZEXPORT deflateParams(strm, level, strategy) s->max_chain_length = configuration_table[level].max_chain; } s->strategy = strategy; - return err; + return Z_OK; } /* ========================================================================= */ @@ -535,12 +623,12 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) { deflate_state *s; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; - s->good_match = good_length; - s->max_lazy_match = max_lazy; + s->good_match = (uInt)good_length; + s->max_lazy_match = (uInt)max_lazy; s->nice_match = nice_length; - s->max_chain_length = max_chain; + s->max_chain_length = (uInt)max_chain; return Z_OK; } @@ -567,14 +655,13 @@ uLong ZEXPORT deflateBound(strm, sourceLen) { deflate_state *s; uLong complen, wraplen; - Bytef *str; /* conservative upper bound for compressed data */ complen = sourceLen + ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5; /* if can't get parameters, return conservative bound plus zlib wrapper */ - if (strm == Z_NULL || strm->state == Z_NULL) + if (deflateStateCheck(strm)) return complen + 6; /* compute wrapper length */ @@ -586,9 +673,11 @@ uLong ZEXPORT deflateBound(strm, sourceLen) case 1: /* zlib wrapper */ wraplen = 6 + (s->strstart ? 4 : 0); break; +#ifdef GZIP case 2: /* gzip wrapper */ wraplen = 18; if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ + Bytef *str; if (s->gzhead->extra != Z_NULL) wraplen += 2 + s->gzhead->extra_len; str = s->gzhead->name; @@ -605,6 +694,7 @@ uLong ZEXPORT deflateBound(strm, sourceLen) wraplen += 2; } break; +#endif default: /* for compiler happiness */ wraplen = 6; } @@ -632,10 +722,10 @@ local void putShortMSB (s, b) } /* ========================================================================= - * Flush as much pending output as possible. All deflate() output goes - * through this function so some applications may wish to modify it - * to avoid allocating a large strm->next_out buffer and copying into it. - * (See also read_buf()). + * Flush as much pending output as possible. All deflate() output, except for + * some deflate_stored() output, goes through this function so some + * applications may wish to modify it to avoid allocating a large + * strm->next_out buffer and copying into it. (See also read_buf()). */ local void flush_pending(strm) z_streamp strm; @@ -652,13 +742,23 @@ local void flush_pending(strm) strm->next_out += len; s->pending_out += len; strm->total_out += len; - strm->avail_out -= len; - s->pending -= len; + strm->avail_out -= len; + s->pending -= len; if (s->pending == 0) { s->pending_out = s->pending_buf; } } +/* =========================================================================== + * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1]. + */ +#define HCRC_UPDATE(beg) \ + do { \ + if (s->gzhead->hcrc && s->pending > (beg)) \ + strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ + s->pending - (beg)); \ + } while (0) + /* ========================================================================= */ int ZEXPORT deflate (strm, flush) z_streamp strm; @@ -667,203 +767,21 @@ int ZEXPORT deflate (strm, flush) int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; - if (strm == Z_NULL || strm->state == Z_NULL || - flush > Z_BLOCK || flush < 0) { + if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || - (strm->next_in == Z_NULL && strm->avail_in != 0) || + (strm->avail_in != 0 && strm->next_in == Z_NULL) || (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); - s->strm = strm; /* just in case */ old_flush = s->last_flush; s->last_flush = flush; - /* Write the header */ - if (s->status == INIT_STATE) { -#ifdef GZIP - if (s->wrap == 2) { - strm->adler = crc32(0L, Z_NULL, 0); - put_byte(s, 31); - put_byte(s, 139); - put_byte(s, 8); - if (s->gzhead == Z_NULL) { - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, 0); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, OS_CODE); - s->status = BUSY_STATE; - } - else { - put_byte(s, (s->gzhead->text ? 1 : 0) + - (s->gzhead->hcrc ? 2 : 0) + - (s->gzhead->extra == Z_NULL ? 0 : 4) + - (s->gzhead->name == Z_NULL ? 0 : 8) + - (s->gzhead->comment == Z_NULL ? 0 : 16) - ); - put_byte(s, (Byte)(s->gzhead->time & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); - put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); - put_byte(s, s->level == 9 ? 2 : - (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? - 4 : 0)); - put_byte(s, s->gzhead->os & 0xff); - if (s->gzhead->extra != Z_NULL) { - put_byte(s, s->gzhead->extra_len & 0xff); - put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); - } - if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, - s->pending); - s->gzindex = 0; - s->status = EXTRA_STATE; - } - } - else -#endif - { - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags; - - if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) - level_flags = 0; - else if (s->level < 6) - level_flags = 1; - else if (s->level == 6) - level_flags = 2; - else - level_flags = 3; - header |= (level_flags << 6); - if (s->strstart != 0) header |= PRESET_DICT; - header += 31 - (header % 31); - - s->status = BUSY_STATE; - putShortMSB(s, header); - - /* Save the adler32 of the preset dictionary: */ - if (s->strstart != 0) { - putShortMSB(s, (uInt)(strm->adler >> 16)); - putShortMSB(s, (uInt)(strm->adler & 0xffff)); - } - strm->adler = adler32(0L, Z_NULL, 0); - } - } -#ifdef GZIP - if (s->status == EXTRA_STATE) { - if (s->gzhead->extra != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - - while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) - break; - } - put_byte(s, s->gzhead->extra[s->gzindex]); - s->gzindex++; - } - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (s->gzindex == s->gzhead->extra_len) { - s->gzindex = 0; - s->status = NAME_STATE; - } - } - else - s->status = NAME_STATE; - } - if (s->status == NAME_STATE) { - if (s->gzhead->name != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->name[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) { - s->gzindex = 0; - s->status = COMMENT_STATE; - } - } - else - s->status = COMMENT_STATE; - } - if (s->status == COMMENT_STATE) { - if (s->gzhead->comment != Z_NULL) { - uInt beg = s->pending; /* start of bytes to update crc */ - int val; - - do { - if (s->pending == s->pending_buf_size) { - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - flush_pending(strm); - beg = s->pending; - if (s->pending == s->pending_buf_size) { - val = 1; - break; - } - } - val = s->gzhead->comment[s->gzindex++]; - put_byte(s, val); - } while (val != 0); - if (s->gzhead->hcrc && s->pending > beg) - strm->adler = crc32(strm->adler, s->pending_buf + beg, - s->pending - beg); - if (val == 0) - s->status = HCRC_STATE; - } - else - s->status = HCRC_STATE; - } - if (s->status == HCRC_STATE) { - if (s->gzhead->hcrc) { - if (s->pending + 2 > s->pending_buf_size) - flush_pending(strm); - if (s->pending + 2 <= s->pending_buf_size) { - put_byte(s, (Byte)(strm->adler & 0xff)); - put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); - strm->adler = crc32(0L, Z_NULL, 0); - s->status = BUSY_STATE; - } - } - else - s->status = BUSY_STATE; - } -#endif - /* Flush as much pending output as possible */ if (s->pending != 0) { flush_pending(strm); @@ -892,15 +810,197 @@ int ZEXPORT deflate (strm, flush) ERR_RETURN(strm, Z_BUF_ERROR); } + /* Write the header */ + if (s->status == INIT_STATE) { + /* zlib header */ + uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; + uInt level_flags; + + if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) + level_flags = 0; + else if (s->level < 6) + level_flags = 1; + else if (s->level == 6) + level_flags = 2; + else + level_flags = 3; + header |= (level_flags << 6); + if (s->strstart != 0) header |= PRESET_DICT; + header += 31 - (header % 31); + + putShortMSB(s, header); + + /* Save the adler32 of the preset dictionary: */ + if (s->strstart != 0) { + putShortMSB(s, (uInt)(strm->adler >> 16)); + putShortMSB(s, (uInt)(strm->adler & 0xffff)); + } + strm->adler = adler32(0L, Z_NULL, 0); + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } +#ifdef GZIP + if (s->status == GZIP_STATE) { + /* gzip header */ + strm->adler = crc32(0L, Z_NULL, 0); + put_byte(s, 31); + put_byte(s, 139); + put_byte(s, 8); + if (s->gzhead == Z_NULL) { + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, 0); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, OS_CODE); + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } + else { + put_byte(s, (s->gzhead->text ? 1 : 0) + + (s->gzhead->hcrc ? 2 : 0) + + (s->gzhead->extra == Z_NULL ? 0 : 4) + + (s->gzhead->name == Z_NULL ? 0 : 8) + + (s->gzhead->comment == Z_NULL ? 0 : 16) + ); + put_byte(s, (Byte)(s->gzhead->time & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); + put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); + put_byte(s, s->level == 9 ? 2 : + (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? + 4 : 0)); + put_byte(s, s->gzhead->os & 0xff); + if (s->gzhead->extra != Z_NULL) { + put_byte(s, s->gzhead->extra_len & 0xff); + put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); + } + if (s->gzhead->hcrc) + strm->adler = crc32(strm->adler, s->pending_buf, + s->pending); + s->gzindex = 0; + s->status = EXTRA_STATE; + } + } + if (s->status == EXTRA_STATE) { + if (s->gzhead->extra != Z_NULL) { + ulg beg = s->pending; /* start of bytes to update crc */ + uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex; + while (s->pending + left > s->pending_buf_size) { + uInt copy = s->pending_buf_size - s->pending; + zmemcpy(s->pending_buf + s->pending, + s->gzhead->extra + s->gzindex, copy); + s->pending = s->pending_buf_size; + HCRC_UPDATE(beg); + s->gzindex += copy; + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + beg = 0; + left -= copy; + } + zmemcpy(s->pending_buf + s->pending, + s->gzhead->extra + s->gzindex, left); + s->pending += left; + HCRC_UPDATE(beg); + s->gzindex = 0; + } + s->status = NAME_STATE; + } + if (s->status == NAME_STATE) { + if (s->gzhead->name != Z_NULL) { + ulg beg = s->pending; /* start of bytes to update crc */ + int val; + do { + if (s->pending == s->pending_buf_size) { + HCRC_UPDATE(beg); + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + beg = 0; + } + val = s->gzhead->name[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + HCRC_UPDATE(beg); + s->gzindex = 0; + } + s->status = COMMENT_STATE; + } + if (s->status == COMMENT_STATE) { + if (s->gzhead->comment != Z_NULL) { + ulg beg = s->pending; /* start of bytes to update crc */ + int val; + do { + if (s->pending == s->pending_buf_size) { + HCRC_UPDATE(beg); + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + beg = 0; + } + val = s->gzhead->comment[s->gzindex++]; + put_byte(s, val); + } while (val != 0); + HCRC_UPDATE(beg); + } + s->status = HCRC_STATE; + } + if (s->status == HCRC_STATE) { + if (s->gzhead->hcrc) { + if (s->pending + 2 > s->pending_buf_size) { + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } + put_byte(s, (Byte)(strm->adler & 0xff)); + put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); + strm->adler = crc32(0L, Z_NULL, 0); + } + s->status = BUSY_STATE; + + /* Compression must start with an empty pending buffer */ + flush_pending(strm); + if (s->pending != 0) { + s->last_flush = -1; + return Z_OK; + } + } +#endif + /* Start a new block or continue the current one. */ if (strm->avail_in != 0 || s->lookahead != 0 || (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { block_state bstate; - bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : - (s->strategy == Z_RLE ? deflate_rle(s, flush) : - (*(configuration_table[s->level].func))(s, flush)); + bstate = s->level == 0 ? deflate_stored(s, flush) : + s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) : + s->strategy == Z_RLE ? deflate_rle(s, flush) : + (*(configuration_table[s->level].func))(s, flush); if (bstate == finish_started || bstate == finish_done) { s->status = FINISH_STATE; @@ -942,7 +1042,6 @@ int ZEXPORT deflate (strm, flush) } } } - Assert(strm->avail_out > 0, "bug2"); if (flush != Z_FINISH) return Z_OK; if (s->wrap <= 0) return Z_STREAM_END; @@ -979,18 +1078,9 @@ int ZEXPORT deflateEnd (strm) { int status; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (deflateStateCheck(strm)) return Z_STREAM_ERROR; status = strm->state->status; - if (status != INIT_STATE && - status != EXTRA_STATE && - status != NAME_STATE && - status != COMMENT_STATE && - status != HCRC_STATE && - status != BUSY_STATE && - status != FINISH_STATE) { - return Z_STREAM_ERROR; - } /* Deallocate in reverse order of allocations: */ TRY_FREE(strm, strm->state->pending_buf); @@ -1021,7 +1111,7 @@ int ZEXPORT deflateCopy (dest, source) ushf *overlay; - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { + if (deflateStateCheck(source) || dest == Z_NULL) { return Z_STREAM_ERROR; } @@ -1071,7 +1161,7 @@ int ZEXPORT deflateCopy (dest, source) * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -local int read_buf(strm, buf, size) +local unsigned read_buf(strm, buf, size) z_streamp strm; Bytef *buf; unsigned size; @@ -1095,7 +1185,7 @@ local int read_buf(strm, buf, size) strm->next_in += len; strm->total_in += len; - return (int)len; + return len; } /* =========================================================================== @@ -1149,9 +1239,9 @@ local uInt longest_match(s, cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ - register Bytef *match; /* matched string */ + register Bytef *match; /* matched string */ register int len; /* length of current match */ - int best_len = s->prev_length; /* best match length so far */ + int best_len = (int)s->prev_length; /* best match length so far */ int nice_match = s->nice_match; /* stop if match long enough */ IPos limit = s->strstart > (IPos)MAX_DIST(s) ? s->strstart - (IPos)MAX_DIST(s) : NIL; @@ -1186,7 +1276,7 @@ local uInt longest_match(s, cur_match) /* Do not look for matches beyond the end of the input. This is necessary * to make deflate deterministic. */ - if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; + if ((uInt)nice_match > s->lookahead) nice_match = (int)s->lookahead; Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); @@ -1347,7 +1437,11 @@ local uInt longest_match(s, cur_match) #endif /* FASTEST */ -#ifdef DEBUG +#ifdef ZLIB_DEBUG + +#define EQUAL 0 +/* result of memcmp for equal strings */ + /* =========================================================================== * Check that the match at match_start is indeed a match. */ @@ -1373,7 +1467,7 @@ local void check_match(s, start, match, length) } #else # define check_match(s, start, match, length) -#endif /* DEBUG */ +#endif /* ZLIB_DEBUG */ /* =========================================================================== * Fill the window when the lookahead becomes insufficient. @@ -1388,8 +1482,7 @@ local void check_match(s, start, match, length) local void fill_window(s) deflate_state *s; { - register unsigned n, m; - register Posf *p; + unsigned n; unsigned more; /* Amount of free space at the end of the window. */ uInt wsize = s->w_size; @@ -1416,35 +1509,11 @@ local void fill_window(s) */ if (s->strstart >= wsize+MAX_DIST(s)) { - zmemcpy(s->window, s->window+wsize, (unsigned)wsize); + zmemcpy(s->window, s->window+wsize, (unsigned)wsize - more); s->match_start -= wsize; s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ s->block_start -= (long) wsize; - - /* Slide the hash table (could be avoided with 32 bit values - at the expense of memory usage). We slide even when level == 0 - to keep the hash table consistent if we switch back to level > 0 - later. (Using level 0 permanently is not an optimal usage of - zlib, so we don't care about this pathological case.) - */ - n = s->hash_size; - p = &s->head[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - } while (--n); - - n = wsize; -#ifndef FASTEST - p = &s->prev[n]; - do { - m = *--p; - *p = (Pos)(m >= wsize ? m-wsize : NIL); - /* If n is not on any hash chain, prev[n] is garbage but - * its value will never be used. - */ - } while (--n); -#endif + slide_hash(s); more += wsize; } if (s->strm->avail_in == 0) break; @@ -1550,70 +1619,199 @@ local void fill_window(s) if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ } +/* Maximum stored block length in deflate format (not including header). */ +#define MAX_STORED 65535 + +/* Minimum of a and b. */ +#define MIN(a, b) ((a) > (b) ? (b) : (a)) + /* =========================================================================== * Copy without compression as much as possible from the input stream, return * the current block state. - * This function does not insert new strings in the dictionary since - * uncompressible data is probably not useful. This function is used - * only for the level=0 compression option. - * NOTE: this function should be optimized to avoid extra copying from - * window to pending_buf. + * + * In case deflateParams() is used to later switch to a non-zero compression + * level, s->matches (otherwise unused when storing) keeps track of the number + * of hash table slides to perform. If s->matches is 1, then one hash table + * slide will be done when switching. If s->matches is 2, the maximum value + * allowed here, then the hash table will be cleared, since two or more slides + * is the same as a clear. + * + * deflate_stored() is written to minimize the number of times an input byte is + * copied. It is most efficient with large input and output buffers, which + * maximizes the opportunites to have a single copy from next_in to next_out. */ local block_state deflate_stored(s, flush) deflate_state *s; int flush; { - /* Stored blocks are limited to 0xffff bytes, pending_buf is limited - * to pending_buf_size, and each stored block has a 5 byte header: + /* Smallest worthy block size when not flushing or finishing. By default + * this is 32K. This can be as small as 507 bytes for memLevel == 1. For + * large input and output buffers, the stored block size will be larger. */ - ulg max_block_size = 0xffff; - ulg max_start; + unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); - if (max_block_size > s->pending_buf_size - 5) { - max_block_size = s->pending_buf_size - 5; - } - - /* Copy as much as possible from input to output: */ - for (;;) { - /* Fill the window as much as possible: */ - if (s->lookahead <= 1) { - - Assert(s->strstart < s->w_size+MAX_DIST(s) || - s->block_start >= (long)s->w_size, "slide too late"); - - fill_window(s); - if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; - - if (s->lookahead == 0) break; /* flush the current block */ - } - Assert(s->block_start >= 0L, "block gone"); - - s->strstart += s->lookahead; - s->lookahead = 0; - - /* Emit a stored block if pending_buf will be full: */ - max_start = s->block_start + max_block_size; - if (s->strstart == 0 || (ulg)s->strstart >= max_start) { - /* strstart == 0 is possible when wraparound on 16-bit machine */ - s->lookahead = (uInt)(s->strstart - max_start); - s->strstart = (uInt)max_start; - FLUSH_BLOCK(s, 0); - } - /* Flush if we may have to slide, otherwise block_start may become - * negative and the data will be gone: + /* Copy as many min_block or larger stored blocks directly to next_out as + * possible. If flushing, copy the remaining available input to next_out as + * stored blocks, if there is enough space. + */ + unsigned len, left, have, last = 0; + unsigned used = s->strm->avail_in; + do { + /* Set len to the maximum size block that we can copy directly with the + * available input data and output space. Set left to how much of that + * would be copied from what's left in the window. */ - if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) { - FLUSH_BLOCK(s, 0); + len = MAX_STORED; /* maximum deflate stored block length */ + have = (s->bi_valid + 42) >> 3; /* number of header bytes */ + if (s->strm->avail_out < have) /* need room for header */ + break; + /* maximum stored block length that will fit in avail_out: */ + have = s->strm->avail_out - have; + left = s->strstart - s->block_start; /* bytes left in window */ + if (len > (ulg)left + s->strm->avail_in) + len = left + s->strm->avail_in; /* limit len to the input */ + if (len > have) + len = have; /* limit len to the output */ + + /* If the stored block would be less than min_block in length, or if + * unable to copy all of the available input when flushing, then try + * copying to the window and the pending buffer instead. Also don't + * write an empty block when flushing -- deflate() does that. + */ + if (len < min_block && ((len == 0 && flush != Z_FINISH) || + flush == Z_NO_FLUSH || + len != left + s->strm->avail_in)) + break; + + /* Make a dummy stored block in pending to get the header bytes, + * including any pending bits. This also updates the debugging counts. + */ + last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0; + _tr_stored_block(s, (char *)0, 0L, last); + + /* Replace the lengths in the dummy stored block with len. */ + s->pending_buf[s->pending - 4] = len; + s->pending_buf[s->pending - 3] = len >> 8; + s->pending_buf[s->pending - 2] = ~len; + s->pending_buf[s->pending - 1] = ~len >> 8; + + /* Write the stored block header bytes. */ + flush_pending(s->strm); + +#ifdef ZLIB_DEBUG + /* Update debugging counts for the data about to be copied. */ + s->compressed_len += len << 3; + s->bits_sent += len << 3; +#endif + + /* Copy uncompressed bytes from the window to next_out. */ + if (left) { + if (left > len) + left = len; + zmemcpy(s->strm->next_out, s->window + s->block_start, left); + s->strm->next_out += left; + s->strm->avail_out -= left; + s->strm->total_out += left; + s->block_start += left; + len -= left; } + + /* Copy uncompressed bytes directly from next_in to next_out, updating + * the check value. + */ + if (len) { + read_buf(s->strm, s->strm->next_out, len); + s->strm->next_out += len; + s->strm->avail_out -= len; + s->strm->total_out += len; + } + } while (last == 0); + + /* Update the sliding window with the last s->w_size bytes of the copied + * data, or append all of the copied data to the existing window if less + * than s->w_size bytes were copied. Also update the number of bytes to + * insert in the hash tables, in the event that deflateParams() switches to + * a non-zero compression level. + */ + used -= s->strm->avail_in; /* number of input bytes directly copied */ + if (used) { + /* If any input was used, then no unused input remains in the window, + * therefore s->block_start == s->strstart. + */ + if (used >= s->w_size) { /* supplant the previous history */ + s->matches = 2; /* clear hash */ + zmemcpy(s->window, s->strm->next_in - s->w_size, s->w_size); + s->strstart = s->w_size; + } + else { + if (s->window_size - s->strstart <= used) { + /* Slide the window down. */ + s->strstart -= s->w_size; + zmemcpy(s->window, s->window + s->w_size, s->strstart); + if (s->matches < 2) + s->matches++; /* add a pending slide_hash() */ + } + zmemcpy(s->window + s->strstart, s->strm->next_in - used, used); + s->strstart += used; + } + s->block_start = s->strstart; + s->insert += MIN(used, s->w_size - s->insert); } - s->insert = 0; - if (flush == Z_FINISH) { - FLUSH_BLOCK(s, 1); + if (s->high_water < s->strstart) + s->high_water = s->strstart; + + /* If the last block was written to next_out, then done. */ + if (last) return finish_done; + + /* If flushing and all input has been consumed, then done. */ + if (flush != Z_NO_FLUSH && flush != Z_FINISH && + s->strm->avail_in == 0 && (long)s->strstart == s->block_start) + return block_done; + + /* Fill the window with any remaining input. */ + have = s->window_size - s->strstart - 1; + if (s->strm->avail_in > have && s->block_start >= (long)s->w_size) { + /* Slide the window down. */ + s->block_start -= s->w_size; + s->strstart -= s->w_size; + zmemcpy(s->window, s->window + s->w_size, s->strstart); + if (s->matches < 2) + s->matches++; /* add a pending slide_hash() */ + have += s->w_size; /* more space now */ } - if ((long)s->strstart > s->block_start) - FLUSH_BLOCK(s, 0); - return block_done; + if (have > s->strm->avail_in) + have = s->strm->avail_in; + if (have) { + read_buf(s->strm, s->window + s->strstart, have); + s->strstart += have; + } + if (s->high_water < s->strstart) + s->high_water = s->strstart; + + /* There was not enough avail_out to write a complete worthy or flushed + * stored block to next_out. Write a stored block to pending instead, if we + * have enough input for a worthy block, or if flushing and there is enough + * room for the remaining input as a stored block in the pending buffer. + */ + have = (s->bi_valid + 42) >> 3; /* number of header bytes */ + /* maximum stored block length that will fit in pending: */ + have = MIN(s->pending_buf_size - have, MAX_STORED); + min_block = MIN(have, s->w_size); + left = s->strstart - s->block_start; + if (left >= min_block || + ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && + s->strm->avail_in == 0 && left <= have)) { + len = MIN(left, have); + last = flush == Z_FINISH && s->strm->avail_in == 0 && + len == left ? 1 : 0; + _tr_stored_block(s, (charf *)s->window + s->block_start, len, last); + s->block_start += len; + flush_pending(s->strm); + } + + /* We've done all we can with the available input and output. */ + return last ? finish_started : need_more; } /* =========================================================================== @@ -1890,7 +2088,7 @@ local block_state deflate_rle(s, flush) prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && scan < strend); - s->match_length = MAX_MATCH - (int)(strend - scan); + s->match_length = MAX_MATCH - (uInt)(strend - scan); if (s->match_length > s->lookahead) s->match_length = s->lookahead; } diff --git a/libs/zlib/deflate.h b/libs/zlib/deflate.h index fbac44d90..23ecdd312 100644 --- a/libs/zlib/deflate.h +++ b/libs/zlib/deflate.h @@ -1,5 +1,5 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2012 Jean-loup Gailly + * Copyright (C) 1995-2016 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -51,13 +51,16 @@ #define Buf_size 16 /* size of bit buffer in bi_buf */ -#define INIT_STATE 42 -#define EXTRA_STATE 69 -#define NAME_STATE 73 -#define COMMENT_STATE 91 -#define HCRC_STATE 103 -#define BUSY_STATE 113 -#define FINISH_STATE 666 +#define INIT_STATE 42 /* zlib header -> BUSY_STATE */ +#ifdef GZIP +# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */ +#endif +#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */ +#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */ +#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */ +#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */ +#define BUSY_STATE 113 /* deflate -> FINISH_STATE */ +#define FINISH_STATE 666 /* stream complete */ /* Stream status */ @@ -83,7 +86,7 @@ typedef struct static_tree_desc_s static_tree_desc; typedef struct tree_desc_s { ct_data *dyn_tree; /* the dynamic tree */ int max_code; /* largest code with non zero frequency */ - static_tree_desc *stat_desc; /* the corresponding static tree */ + const static_tree_desc *stat_desc; /* the corresponding static tree */ } FAR tree_desc; typedef ush Pos; @@ -100,11 +103,11 @@ typedef struct internal_state { Bytef *pending_buf; /* output still pending */ ulg pending_buf_size; /* size of pending_buf */ Bytef *pending_out; /* next pending byte to output to the stream */ - uInt pending; /* nb of bytes in the pending buffer */ + ulg pending; /* nb of bytes in the pending buffer */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ gz_headerp gzhead; /* gzip header information to write */ - uInt gzindex; /* where in extra, name, or comment */ - Byte method; /* STORED (for zip only) or DEFLATED */ + ulg gzindex; /* where in extra, name, or comment */ + Byte method; /* can only be DEFLATED */ int last_flush; /* value of flush param for previous deflate call */ /* used by deflate.c: */ @@ -249,7 +252,7 @@ typedef struct internal_state { uInt matches; /* number of string matches in current block */ uInt insert; /* bytes at end of window left to insert */ -#ifdef DEBUG +#ifdef ZLIB_DEBUG ulg compressed_len; /* total bit length of compressed file mod 2^32 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif @@ -275,7 +278,7 @@ typedef struct internal_state { /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} +#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) @@ -309,7 +312,7 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, * used. */ -#ifndef DEBUG +#ifndef ZLIB_DEBUG /* Inline versions of _tr_tally for speed: */ #if defined(GEN_TREES_H) || !defined(STDC) @@ -328,8 +331,8 @@ void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, flush = (s->last_lit == s->lit_bufsize-1); \ } # define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ s->d_buf[s->last_lit] = dist; \ s->l_buf[s->last_lit++] = len; \ dist--; \ diff --git a/libs/zlib/doc/algorithm.txt b/libs/zlib/doc/algorithm.txt index 34960bdda..c97f49502 100644 --- a/libs/zlib/doc/algorithm.txt +++ b/libs/zlib/doc/algorithm.txt @@ -206,4 +206,4 @@ Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, pp. 337-343. ``DEFLATE Compressed Data Format Specification'' available in -http://www.ietf.org/rfc/rfc1951.txt +http://tools.ietf.org/html/rfc1951 diff --git a/libs/zlib/examples/enough.c b/libs/zlib/examples/enough.c index c40410bad..b99114430 100644 --- a/libs/zlib/examples/enough.c +++ b/libs/zlib/examples/enough.c @@ -1,7 +1,7 @@ /* enough.c -- determine the maximum size of inflate's Huffman code tables over * all possible valid and complete Huffman codes, subject to a length limit. - * Copyright (C) 2007, 2008 Mark Adler - * Version 1.3 17 February 2008 Mark Adler + * Copyright (C) 2007, 2008, 2012 Mark Adler + * Version 1.4 18 August 2012 Mark Adler */ /* Version history: @@ -14,6 +14,9 @@ 1.3 17 Feb 2008 Add argument for initial root table size Fix bug for initial root table size == max - 1 Use a macro to compute the history index + 1.4 18 Aug 2012 Avoid shifts more than bits in type (caused endless loop!) + Clean up comparisons of different types + Clean up code indentation */ /* @@ -236,8 +239,8 @@ local big_t count(int syms, int len, int left) for (use = least; use <= most; use++) { got = count(syms - use, len + 1, (left - use) << 1); sum += got; - if (got == -1 || sum < got) /* overflow */ - return -1; + if (got == (big_t)0 - 1 || sum < got) /* overflow */ + return (big_t)0 - 1; } /* verify that all recursive calls are productive */ @@ -458,6 +461,7 @@ int main(int argc, char **argv) int n; /* number of symbols to code for this run */ big_t got; /* return value of count() */ big_t sum; /* accumulated number of codes over n */ + code_t word; /* for counting bits in code_t */ /* set up globals for cleanup() */ code = NULL; @@ -466,19 +470,19 @@ int main(int argc, char **argv) /* get arguments -- default to the deflate literal/length code */ syms = 286; - root = 9; + root = 9; max = 15; if (argc > 1) { syms = atoi(argv[1]); if (argc > 2) { root = atoi(argv[2]); - if (argc > 3) - max = atoi(argv[3]); - } + if (argc > 3) + max = atoi(argv[3]); + } } if (argc > 4 || syms < 2 || root < 1 || max < 1) { fputs("invalid arguments, need: [sym >= 2 [root >= 1 [max >= 1]]]\n", - stderr); + stderr); return 1; } @@ -487,18 +491,17 @@ int main(int argc, char **argv) max = syms - 1; /* determine the number of bits in a code_t */ - n = 0; - while (((code_t)1 << n) != 0) - n++; + for (n = 0, word = 1; word; n++, word <<= 1) + ; /* make sure that the calculation of most will not overflow */ - if (max > n || syms - 2 >= (((code_t)0 - 1) >> (max - 1))) { + if (max > n || (code_t)(syms - 2) >= (((code_t)0 - 1) >> (max - 1))) { fputs("abort: code length too long for internal types\n", stderr); return 1; } /* reject impossible code requests */ - if (syms - 1 > ((code_t)1 << max) - 1) { + if ((code_t)(syms - 1) > ((code_t)1 << max) - 1) { fprintf(stderr, "%d symbols cannot be coded in %d bits\n", syms, max); return 1; @@ -532,7 +535,7 @@ int main(int argc, char **argv) for (n = 2; n <= syms; n++) { got = count(n, 1, 2); sum += got; - if (got == -1 || sum < got) { /* overflow */ + if (got == (big_t)0 - 1 || sum < got) { /* overflow */ fputs("abort: can't count that high!\n", stderr); cleanup(); return 1; @@ -556,9 +559,9 @@ int main(int argc, char **argv) } /* find and show maximum inflate table usage */ - if (root > max) /* reduce root to max length */ - root = max; - if (syms < ((code_t)1 << (root + 1))) + if (root > max) /* reduce root to max length */ + root = max; + if ((code_t)syms < ((code_t)1 << (root + 1))) enough(syms); else puts("cannot handle minimum code lengths > root"); diff --git a/libs/zlib/examples/gun.c b/libs/zlib/examples/gun.c index 72b0882ab..be44fa51f 100644 --- a/libs/zlib/examples/gun.c +++ b/libs/zlib/examples/gun.c @@ -1,7 +1,7 @@ /* gun.c -- simple gunzip to give an example of the use of inflateBack() - * Copyright (C) 2003, 2005, 2008, 2010 Mark Adler + * Copyright (C) 2003, 2005, 2008, 2010, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h - Version 1.6 17 January 2010 Mark Adler */ + Version 1.7 12 August 2012 Mark Adler */ /* Version history: 1.0 16 Feb 2003 First version for testing of inflateBack() @@ -18,6 +18,7 @@ 1.4 8 Dec 2006 LZW decompression speed improvements 1.5 9 Feb 2008 Avoid warning in latest version of gcc 1.6 17 Jan 2010 Avoid signed/unsigned comparison warnings + 1.7 12 Aug 2012 Update for z_const usage in zlib 1.2.8 */ /* @@ -45,7 +46,7 @@ end-of-file, they cannot be concantenated. If a Unix compress stream is encountered in an input file, it is the last stream in that file. - Like gunzip and uncompress, the file attributes of the orignal compressed + Like gunzip and uncompress, the file attributes of the original compressed file are maintained in the final uncompressed file, to the extent that the user permissions allow it. @@ -85,7 +86,7 @@ struct ind { /* Load input buffer, assumed to be empty, and return bytes loaded and a pointer to them. read() is called until the buffer is full, or until it returns end-of-file or error. Return 0 on error. */ -local unsigned in(void *in_desc, unsigned char **buf) +local unsigned in(void *in_desc, z_const unsigned char **buf) { int ret; unsigned len; @@ -196,7 +197,7 @@ unsigned char match[65280 + 2]; /* buffer for reversed match or gzip file, read error, or write error (a write error indicated by strm->next_in not equal to Z_NULL), or Z_DATA_ERROR for invalid input. */ -local int lunpipe(unsigned have, unsigned char *next, struct ind *indp, +local int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp, int outfile, z_stream *strm) { int last; /* last byte read by NEXT(), or -1 if EOF */ @@ -383,7 +384,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile) { int ret, first, last; unsigned have, flags, len; - unsigned char *next = NULL; + z_const unsigned char *next = NULL; struct ind ind, *indp; struct outd outd; diff --git a/libs/zlib/examples/gzappend.c b/libs/zlib/examples/gzappend.c index e9e878e11..662dec379 100644 --- a/libs/zlib/examples/gzappend.c +++ b/libs/zlib/examples/gzappend.c @@ -1,7 +1,7 @@ /* gzappend -- command to append to a gzip file - Copyright (C) 2003 Mark Adler, all rights reserved - version 1.1, 4 Nov 2003 + Copyright (C) 2003, 2012 Mark Adler, all rights reserved + version 1.2, 11 Oct 2012 This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages @@ -39,6 +39,8 @@ * - Keep gzip file clean on appended file read errors * - Use in-place rotate instead of auxiliary buffer * (Why you ask? Because it was fun to write!) + * 1.2 11 Oct 2012 - Fix for proper z_const usage + * - Check for input buffer malloc failure */ /* @@ -170,7 +172,7 @@ typedef struct { int size; /* 1 << size is bytes in buf */ unsigned left; /* bytes available at next */ unsigned char *buf; /* buffer */ - unsigned char *next; /* next byte in buffer */ + z_const unsigned char *next; /* next byte in buffer */ char *name; /* file name for error messages */ } file; @@ -399,14 +401,14 @@ local void gztack(char *name, int gd, z_stream *strm, int last) } /* allocate buffers */ - in = fd == -1 ? NULL : malloc(CHUNK); + in = malloc(CHUNK); out = malloc(CHUNK); - if (out == NULL) bye("out of memory", ""); + if (in == NULL || out == NULL) bye("out of memory", ""); /* compress input file and append to gzip file */ do { /* get more input */ - len = fd == -1 ? 0 : read(fd, in, CHUNK); + len = read(fd, in, CHUNK); if (len == -1) { fprintf(stderr, "gzappend warning: error reading %s, skipping rest ...\n", @@ -453,7 +455,7 @@ local void gztack(char *name, int gd, z_stream *strm, int last) /* clean up and return */ free(out); - if (in != NULL) free(in); + free(in); if (fd > 0) close(fd); } @@ -467,11 +469,13 @@ int main(int argc, char **argv) z_stream strm; /* ignore command name */ - argv++; + argc--; argv++; /* provide usage if no arguments */ if (*argv == NULL) { - printf("gzappend 1.1 (4 Nov 2003) Copyright (C) 2003 Mark Adler\n"); + printf( + "gzappend 1.2 (11 Oct 2012) Copyright (C) 2003, 2012 Mark Adler\n" + ); printf( "usage: gzappend [-level] file.gz [ addthis [ andthis ... ]]\n"); return 0; diff --git a/libs/zlib/examples/gzjoin.c b/libs/zlib/examples/gzjoin.c index 129347ce3..89e809844 100644 --- a/libs/zlib/examples/gzjoin.c +++ b/libs/zlib/examples/gzjoin.c @@ -1,7 +1,7 @@ /* gzjoin -- command to join gzip files into one gzip file - Copyright (C) 2004 Mark Adler, all rights reserved - version 1.0, 11 Dec 2004 + Copyright (C) 2004, 2005, 2012 Mark Adler, all rights reserved + version 1.2, 14 Aug 2012 This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages @@ -27,6 +27,7 @@ * * 1.0 11 Dec 2004 - First version * 1.1 12 Jun 2005 - Changed ssize_t to long for portability + * 1.2 14 Aug 2012 - Clean up for z_const usage */ /* @@ -308,7 +309,7 @@ local void gzcopy(char *name, int clr, unsigned long *crc, unsigned long *tot, /* inflate and copy compressed data, clear last-block bit if requested */ len = 0; zpull(&strm, in); - start = strm.next_in; + start = in->next; last = start[0] & 1; if (last && clr) start[0] &= ~1; @@ -351,7 +352,7 @@ local void gzcopy(char *name, int clr, unsigned long *crc, unsigned long *tot, pos = 0x100 >> pos; last = strm.next_in[-1] & pos; if (last && clr) - strm.next_in[-1] &= ~pos; + in->buf[strm.next_in - in->buf - 1] &= ~pos; } else { /* next last-block bit is in next unused byte */ @@ -364,14 +365,14 @@ local void gzcopy(char *name, int clr, unsigned long *crc, unsigned long *tot, } last = strm.next_in[0] & 1; if (last && clr) - strm.next_in[0] &= ~1; + in->buf[strm.next_in - in->buf] &= ~1; } } } /* update buffer with unused input */ in->left = strm.avail_in; - in->next = strm.next_in; + in->next = in->buf + (strm.next_in - in->buf); /* copy used input, write empty blocks to get to byte boundary */ pos = strm.data_type & 7; diff --git a/libs/zlib/examples/gzlog.c b/libs/zlib/examples/gzlog.c index d70aacaba..b8c29274e 100644 --- a/libs/zlib/examples/gzlog.c +++ b/libs/zlib/examples/gzlog.c @@ -1,8 +1,8 @@ /* * gzlog.c - * Copyright (C) 2004, 2008 Mark Adler, all rights reserved + * Copyright (C) 2004, 2008, 2012, 2016 Mark Adler, all rights reserved * For conditions of distribution and use, see copyright notice in gzlog.h - * version 2.0, 25 Apr 2008 + * version 2.2, 14 Aug 2012 */ /* @@ -243,7 +243,7 @@ typedef unsigned int uint; typedef unsigned long ulong; /* Macro for debugging to deterministically force recovery operations */ -#ifdef DEBUG +#ifdef GZLOG_DEBUG #include /* longjmp */ jmp_buf gzlog_jump; /* where to go back to */ int gzlog_bail = 0; /* which point to bail at (1..8) */ @@ -750,7 +750,8 @@ local int log_recover(struct log *log, int op) strcpy(log->end, ".add"); if (stat(log->path, &st) == 0 && st.st_size) { len = (size_t)(st.st_size); - if (len != st.st_size || (data = malloc(st.st_size)) == NULL) { + if ((off_t)len != st.st_size || + (data = malloc(st.st_size)) == NULL) { log_log(log, op, "allocation failure"); return -2; } @@ -758,7 +759,7 @@ local int log_recover(struct log *log, int op) log_log(log, op, ".add file read failure"); return -1; } - ret = read(fd, data, len) != len; + ret = (size_t)read(fd, data, len) != len; close(fd); if (ret) { log_log(log, op, ".add file read failure"); @@ -913,7 +914,7 @@ int gzlog_compress(gzlog *logd) struct log *log = logd; /* check arguments */ - if (log == NULL || strcmp(log->id, LOGID) || len < 0) + if (log == NULL || strcmp(log->id, LOGID)) return -3; /* see if we lost the lock -- if so get it again and reload the extra @@ -952,7 +953,7 @@ int gzlog_compress(gzlog *logd) fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) break; - ret = write(fd, data, len) != len; + ret = (size_t)write(fd, data, len) != len; if (ret | close(fd)) break; log_touch(log); @@ -963,7 +964,7 @@ int gzlog_compress(gzlog *logd) if (fd < 0) break; next = DICT > len ? len : DICT; - ret = write(fd, (char *)data + len - next, next) != next; + ret = (size_t)write(fd, (char *)data + len - next, next) != next; if (ret | close(fd)) break; log_touch(log); @@ -997,9 +998,9 @@ int gzlog_write(gzlog *logd, void *data, size_t len) struct log *log = logd; /* check arguments */ - if (log == NULL || strcmp(log->id, LOGID) || len < 0) + if (log == NULL || strcmp(log->id, LOGID)) return -3; - if (data == NULL || len == 0) + if (data == NULL || len <= 0) return 0; /* see if we lost the lock -- if so get it again and reload the extra @@ -1013,7 +1014,7 @@ int gzlog_write(gzlog *logd, void *data, size_t len) fd = open(log->path, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) return -1; - ret = write(fd, data, len) != len; + ret = (size_t)write(fd, data, len) != len; if (ret | close(fd)) return -1; log_touch(log); diff --git a/libs/zlib/examples/gzlog.h b/libs/zlib/examples/gzlog.h index c46142673..86f0cecba 100644 --- a/libs/zlib/examples/gzlog.h +++ b/libs/zlib/examples/gzlog.h @@ -1,6 +1,6 @@ /* gzlog.h - Copyright (C) 2004, 2008 Mark Adler, all rights reserved - version 2.0, 25 Apr 2008 + Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved + version 2.2, 14 Aug 2012 This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages @@ -27,6 +27,8 @@ Interface changed slightly in that now path is a prefix Compression now occurs as needed during gzlog_write() gzlog_write() now always leaves the log file as valid gzip + 2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write() + 2.2 14 Aug 2012 Clean up signed comparisons */ /* diff --git a/libs/zlib/examples/zran.c b/libs/zlib/examples/zran.c index 617a13086..4fec6594a 100644 --- a/libs/zlib/examples/zran.c +++ b/libs/zlib/examples/zran.c @@ -1,7 +1,12 @@ /* zran.c -- example of zlib/gzip stream indexing and random access - * Copyright (C) 2005 Mark Adler + * Copyright (C) 2005, 2012 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h - Version 1.0 29 May 2005 Mark Adler */ + Version 1.1 29 Sep 2012 Mark Adler */ + +/* Version History: + 1.0 29 May 2005 First version + 1.1 29 Sep 2012 Fix memory reallocation error + */ /* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() for random access of a compressed file. A file containing a zlib or gzip @@ -22,7 +27,7 @@ grows as needed to accommodate the points. To use the index, an offset in the uncompressed data is provided, for which - the latest accees point at or preceding that offset is located in the index. + the latest access point at or preceding that offset is located in the index. The input file is positioned to the specified location in the index, and if necessary the first few bits of the compressed data is read from the file. inflate is initialized with those bits and the 32K of uncompressed data, and @@ -221,7 +226,7 @@ local int build_index(FILE *in, off_t span, struct access **built) /* clean up and return index (release unused entries in list) */ (void)inflateEnd(&strm); - index = realloc(index, sizeof(struct point) * index->have); + index->list = realloc(index->list, sizeof(struct point) * index->have); index->size = index->have; *built = index; return index->size; diff --git a/libs/zlib/gzguts.h b/libs/zlib/gzguts.h index 6154b062c..990a4d251 100644 --- a/libs/zlib/gzguts.h +++ b/libs/zlib/gzguts.h @@ -1,5 +1,5 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -12,7 +12,7 @@ # endif #endif -#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) +#ifdef HAVE_HIDDEN # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL @@ -25,15 +25,31 @@ # include # include #endif -#ifdef _MSC_VER -#include + +#ifndef _POSIX_SOURCE +# define _POSIX_SOURCE #endif #include -#ifdef __TURBOC__ +#ifdef _WIN32 +# include +#endif + +#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) # include #endif +#if defined(_WIN32) || defined(__CYGWIN__) +# define WIDECHAR +#endif + +#ifdef WINAPI_FAMILY +# define open _open +# define read _read +# define write _write +# define close _close +#endif + #ifdef NO_DEFLATE /* for compatibility with old definition */ # define NO_GZCOMPRESS #endif @@ -59,7 +75,7 @@ #ifndef HAVE_VSNPRINTF # ifdef MSDOS /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), - but for now we just assume it doesn't. */ + but for now we just assume it doesn't. */ # define NO_vsnprintf # endif # ifdef __TURBOC__ @@ -87,10 +103,19 @@ # endif #endif +/* unlike snprintf (which is required in C99), _snprintf does not guarantee + null termination of the result -- however this is only used in gzlib.c where + the result is assured to fit in the space provided */ +#if defined(_MSC_VER) && _MSC_VER < 1900 +# define snprintf _snprintf +#endif + #ifndef local # define local static #endif -/* compile with -Dlocal if your debugger can't find static symbols */ +/* since "static" is used to mean two completely different things in C, we + define "local" for the non-static meaning of "static", for readability + (compile with -Dlocal if your debugger can't find static symbols) */ /* gz* functions always use library allocation functions */ #ifndef STDC @@ -103,7 +128,7 @@ # include # define zstrerror() gz_strwinerror((DWORD)GetLastError()) #else -# ifdef STDC +# ifndef NO_STRERROR # include # define zstrerror() strerror(errno) # else @@ -126,7 +151,8 @@ # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif -/* default i/o buffer size -- double this for output when reading */ +/* default i/o buffer size -- double this for output when reading (this and + twice this must be able to fit in an unsigned type) */ #define GZBUFSIZE 8192 /* gzip modes, also provide a little integrity check on the passed structure */ @@ -153,7 +179,7 @@ typedef struct { char *path; /* path or fd for error messages */ unsigned size; /* buffer size, zero if not allocated yet */ unsigned want; /* requested buffer size, default is GZBUFSIZE */ - unsigned char *in; /* input buffer */ + unsigned char *in; /* input buffer (double-sized when writing) */ unsigned char *out; /* output buffer (double-sized when reading) */ int direct; /* 0 if processing gzip, 1 if transparent */ /* just for reading */ diff --git a/libs/zlib/gzlib.c b/libs/zlib/gzlib.c index 7aedab8e2..4105e6aff 100644 --- a/libs/zlib/gzlib.c +++ b/libs/zlib/gzlib.c @@ -1,11 +1,11 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004, 2010, 2011 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" -#if defined(_WIN32) && !defined(__BORLANDC__) +#if defined(_WIN32) && !defined(__BORLANDC__) && !defined(__MINGW32__) # define LSEEK _lseeki64 #else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 @@ -17,7 +17,7 @@ /* Local functions */ local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const char *, int, const char *)); +local gzFile gz_open OF((const void *, int, const char *)); #if defined UNDER_CE @@ -89,18 +89,26 @@ local void gz_reset(state) /* Open a gzip file either by name or file descriptor. */ local gzFile gz_open(path, fd, mode) - const char *path; + const void *path; int fd; const char *mode; { gz_statep state; + z_size_t len; + int oflag; +#ifdef O_CLOEXEC + int cloexec = 0; +#endif +#ifdef O_EXCL + int exclusive = 0; +#endif /* check input */ if (path == NULL) return NULL; /* allocate gzFile structure to return */ - state = malloc(sizeof(gz_state)); + state = (gz_statep)malloc(sizeof(gz_state)); if (state == NULL) return NULL; state->size = 0; /* no buffers allocated yet */ @@ -133,6 +141,16 @@ local gzFile gz_open(path, fd, mode) return NULL; case 'b': /* ignore -- will request binary anyway */ break; +#ifdef O_CLOEXEC + case 'e': + cloexec = 1; + break; +#endif +#ifdef O_EXCL + case 'x': + exclusive = 1; + break; +#endif case 'f': state->strategy = Z_FILTERED; break; @@ -144,8 +162,10 @@ local gzFile gz_open(path, fd, mode) break; case 'F': state->strategy = Z_FIXED; + break; case 'T': state->direct = 1; + break; default: /* could consider as an error, but just ignore */ ; } @@ -168,36 +188,70 @@ local gzFile gz_open(path, fd, mode) } /* save the path name for error messages */ - state->path = malloc(strlen(path) + 1); +#ifdef WIDECHAR + if (fd == -2) { + len = wcstombs(NULL, path, 0); + if (len == (z_size_t)-1) + len = 0; + } + else +#endif + len = strlen((const char *)path); + state->path = (char *)malloc(len + 1); if (state->path == NULL) { free(state); return NULL; } - strcpy(state->path, path); +#ifdef WIDECHAR + if (fd == -2) + if (len) + wcstombs(state->path, path, len + 1); + else + *(state->path) = 0; + else +#endif +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + (void)snprintf(state->path, len + 1, "%s", (const char *)path); +#else + strcpy(state->path, path); +#endif - /* open the file with the appropriate mode (or just use fd) */ - state->fd = fd != -1 ? fd : - open(path, + /* compute the flags for open() */ + oflag = #ifdef O_LARGEFILE - O_LARGEFILE | + O_LARGEFILE | #endif #ifdef O_BINARY - O_BINARY | + O_BINARY | #endif - (state->mode == GZ_READ ? - O_RDONLY : - (O_WRONLY | O_CREAT | ( - state->mode == GZ_WRITE ? - O_TRUNC : - O_APPEND))), - 0666); +#ifdef O_CLOEXEC + (cloexec ? O_CLOEXEC : 0) | +#endif + (state->mode == GZ_READ ? + O_RDONLY : + (O_WRONLY | O_CREAT | +#ifdef O_EXCL + (exclusive ? O_EXCL : 0) | +#endif + (state->mode == GZ_WRITE ? + O_TRUNC : + O_APPEND))); + + /* open the file with the appropriate flags (or just use fd) */ + state->fd = fd > -1 ? fd : ( +#ifdef WIDECHAR + fd == -2 ? _wopen(path, oflag, 0666) : +#endif + open((const char *)path, oflag, 0666)); if (state->fd == -1) { free(state->path); free(state); return NULL; } - if (state->mode == GZ_APPEND) + if (state->mode == GZ_APPEND) { + LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ state->mode = GZ_WRITE; /* simplify later checks */ + } /* save the current position for rewinding (only if reading) */ if (state->mode == GZ_READ) { @@ -236,14 +290,28 @@ gzFile ZEXPORT gzdopen(fd, mode) char *path; /* identifier for error messages */ gzFile gz; - if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL) + if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) return NULL; +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + (void)snprintf(path, 7 + 3 * sizeof(int), "", fd); +#else sprintf(path, "", fd); /* for debugging */ +#endif gz = gz_open(path, fd, mode); free(path); return gz; } +/* -- see zlib.h -- */ +#ifdef WIDECHAR +gzFile ZEXPORT gzopen_w(path, mode) + const wchar_t *path; + const char *mode; +{ + return gz_open(path, -2, mode); +} +#endif + /* -- see zlib.h -- */ int ZEXPORT gzbuffer(file, size) gzFile file; @@ -263,6 +331,8 @@ int ZEXPORT gzbuffer(file, size) return -1; /* check and set requested size */ + if ((size << 1) < size) + return -1; /* need to be able to double it */ if (size < 2) size = 2; /* need two bytes to check magic header */ state->want = size; @@ -475,7 +545,8 @@ const char * ZEXPORT gzerror(file, errnum) /* return error information */ if (errnum != NULL) *errnum = state->err; - return state->msg == NULL ? "" : state->msg; + return state->err == Z_MEM_ERROR ? "out of memory" : + (state->msg == NULL ? "" : state->msg); } /* -- see zlib.h -- */ @@ -526,22 +597,24 @@ void ZLIB_INTERNAL gz_error(state, err, msg) if (msg == NULL) return; - /* for an out of memory error, save as static string */ - if (err == Z_MEM_ERROR) { - state->msg = (char *)msg; + /* for an out of memory error, return literal string when requested */ + if (err == Z_MEM_ERROR) return; - } /* construct error message with path */ - if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) { + if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == + NULL) { state->err = Z_MEM_ERROR; - state->msg = (char *)"out of memory"; return; } +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, + "%s%s%s", state->path, ": ", msg); +#else strcpy(state->msg, state->path); strcat(state->msg, ": "); strcat(state->msg, msg); - return; +#endif } #ifndef INT_MAX diff --git a/libs/zlib/gzread.c b/libs/zlib/gzread.c index 46d40e0bb..956b91ea7 100644 --- a/libs/zlib/gzread.c +++ b/libs/zlib/gzread.c @@ -1,5 +1,5 @@ /* gzread.c -- zlib functions for reading gzip files - * Copyright (C) 2004, 2005, 2010, 2011 Mark Adler + * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -12,6 +12,7 @@ local int gz_look OF((gz_statep)); local int gz_decomp OF((gz_statep)); local int gz_fetch OF((gz_statep)); local int gz_skip OF((gz_statep, z_off64_t)); +local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. @@ -24,13 +25,17 @@ local int gz_load(state, buf, len, have) unsigned *have; { int ret; + unsigned get, max = ((unsigned)-1 >> 2) + 1; *have = 0; do { - ret = read(state->fd, buf + *have, len - *have); + get = len - *have; + if (get > max) + get = max; + ret = read(state->fd, buf + *have, get); if (ret <= 0) break; - *have += ret; + *have += (unsigned)ret; } while (*have < len); if (ret < 0) { gz_error(state, Z_ERRNO, zstrerror()); @@ -57,8 +62,14 @@ local int gz_avail(state) if (state->err != Z_OK && state->err != Z_BUF_ERROR) return -1; if (state->eof == 0) { - if (strm->avail_in) - memmove(state->in, strm->next_in, strm->avail_in); + if (strm->avail_in) { /* copy what's there to the start */ + unsigned char *p = state->in; + unsigned const char *q = strm->next_in; + unsigned n = strm->avail_in; + do { + *p++ = *q++; + } while (--n); + } if (gz_load(state, state->in + strm->avail_in, state->size - strm->avail_in, &got) == -1) return -1; @@ -85,13 +96,11 @@ local int gz_look(state) /* allocate read buffers and inflate memory */ if (state->size == 0) { /* allocate buffers */ - state->in = malloc(state->want); - state->out = malloc(state->want << 1); + state->in = (unsigned char *)malloc(state->want); + state->out = (unsigned char *)malloc(state->want << 1); if (state->in == NULL || state->out == NULL) { - if (state->out != NULL) - free(state->out); - if (state->in != NULL) - free(state->in); + free(state->out); + free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } @@ -278,33 +287,17 @@ local int gz_skip(state, len) return 0; } -/* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ - unsigned got, n; +/* Read len bytes into buf from file, or less than len up to the end of the + input. Return the number of bytes read. If zero is returned, either the + end of file was reached, or there was an error. state->err must be + consulted in that case to determine which. */ +local z_size_t gz_read(state, buf, len) gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return -1; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're reading and that there's no (serious) error */ - if (state->mode != GZ_READ || - (state->err != Z_OK && state->err != Z_BUF_ERROR)) - return -1; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids the flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return -1; - } + voidp buf; + z_size_t len; +{ + z_size_t got; + unsigned n; /* if len is zero, avoid unnecessary operations */ if (len == 0) @@ -314,49 +307,55 @@ int ZEXPORT gzread(file, buf, len) if (state->seek) { state->seek = 0; if (gz_skip(state, state->skip) == -1) - return -1; + return 0; } /* get len bytes to buf, or less than len if at the end */ got = 0; do { + /* set n to the maximum amount of len that fits in an unsigned int */ + n = -1; + if (n > len) + n = len; + /* first just try copying data from the output buffer */ if (state->x.have) { - n = state->x.have > len ? len : state->x.have; + if (state->x.have < n) + n = state->x.have; memcpy(buf, state->x.next, n); state->x.next += n; state->x.have -= n; } /* output buffer empty -- return if we're at the end of the input */ - else if (state->eof && strm->avail_in == 0) { + else if (state->eof && state->strm.avail_in == 0) { state->past = 1; /* tried to read past end */ break; } /* need output data -- for small len or new stream load up our output buffer */ - else if (state->how == LOOK || len < (state->size << 1)) { + else if (state->how == LOOK || n < (state->size << 1)) { /* get more output, looking for header if required */ if (gz_fetch(state) == -1) - return -1; - continue; /* no progress yet -- go back to memcpy() above */ + return 0; + continue; /* no progress yet -- go back to copy above */ /* the copy above assures that we will leave with space in the output buffer, allowing at least one gzungetc() to succeed */ } /* large len -- read directly into user buffer */ else if (state->how == COPY) { /* read directly */ - if (gz_load(state, buf, len, &n) == -1) - return -1; + if (gz_load(state, (unsigned char *)buf, n, &n) == -1) + return 0; } /* large len -- decompress directly into user buffer */ else { /* state->how == GZIP */ - strm->avail_out = len; - strm->next_out = buf; + state->strm.avail_out = n; + state->strm.next_out = (unsigned char *)buf; if (gz_decomp(state) == -1) - return -1; + return 0; n = state->x.have; state->x.have = 0; } @@ -368,12 +367,84 @@ int ZEXPORT gzread(file, buf, len) state->x.pos += n; } while (len); - /* return number of bytes read into user buffer (will fit in int) */ - return (int)got; + /* return number of bytes read into user buffer */ + return got; } /* -- see zlib.h -- */ -int ZEXPORT gzgetc_(file) +int ZEXPORT gzread(file, buf, len) + gzFile file; + voidp buf; + unsigned len; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return -1; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids a flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); + return -1; + } + + /* read len or fewer bytes to buf */ + len = gz_read(state, buf, len); + + /* check for an error */ + if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) + return -1; + + /* return the number of bytes read (this is assured to fit in an int) */ + return (int)len; +} + +/* -- see zlib.h -- */ +z_size_t ZEXPORT gzfread(buf, size, nitems, file) + voidp buf; + z_size_t size; + z_size_t nitems; + gzFile file; +{ + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're reading and that there's no (serious) error */ + if (state->mode != GZ_READ || + (state->err != Z_OK && state->err != Z_BUF_ERROR)) + return 0; + + /* compute bytes to read -- error on overflow */ + len = nitems * size; + if (size && len / size != nitems) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); + return 0; + } + + /* read len or fewer bytes to buf, return the number of full items read */ + return len ? gz_read(state, buf, len) / size : 0; +} + +/* -- see zlib.h -- */ +#ifdef Z_PREFIX_SET +# undef z_gzgetc +#else +# undef gzgetc +#endif +int ZEXPORT gzgetc(file) gzFile file; { int ret; @@ -397,17 +468,16 @@ int ZEXPORT gzgetc_(file) return *(state->x.next)++; } - /* nothing there -- try gzread() */ - ret = gzread(file, buf, 1); + /* nothing there -- try gz_read() */ + ret = gz_read(state, buf, 1); return ret < 1 ? -1 : buf[0]; } -#undef gzgetc -int ZEXPORT gzgetc(file) +int ZEXPORT gzgetc_(file) gzFile file; { - return gzgetc_(file); -} + return gzgetc(file); +} /* -- see zlib.h -- */ int ZEXPORT gzungetc(c, file) @@ -441,7 +511,7 @@ int ZEXPORT gzungetc(c, file) if (state->x.have == 0) { state->x.have = 1; state->x.next = state->out + (state->size << 1) - 1; - state->x.next[0] = c; + state->x.next[0] = (unsigned char)c; state->x.pos--; state->past = 0; return c; @@ -463,7 +533,7 @@ int ZEXPORT gzungetc(c, file) } state->x.have++; state->x.next--; - state->x.next[0] = c; + state->x.next[0] = (unsigned char)c; state->x.pos--; state->past = 0; return c; @@ -513,7 +583,7 @@ char * ZEXPORT gzgets(file, buf, len) /* look for end-of-line in current output buffer */ n = state->x.have > left ? left : state->x.have; - eol = memchr(state->x.next, '\n', n); + eol = (unsigned char *)memchr(state->x.next, '\n', n); if (eol != NULL) n = (unsigned)(eol - state->x.next) + 1; diff --git a/libs/zlib/gzwrite.c b/libs/zlib/gzwrite.c index caa35b61a..c7b5651d7 100644 --- a/libs/zlib/gzwrite.c +++ b/libs/zlib/gzwrite.c @@ -1,5 +1,5 @@ /* gzwrite.c -- zlib functions for writing gzip files - * Copyright (C) 2004, 2005, 2010, 2011, 2012 Mark Adler + * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,17 +9,19 @@ local int gz_init OF((gz_statep)); local int gz_comp OF((gz_statep, int)); local int gz_zero OF((gz_statep, z_off64_t)); +local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); /* Initialize state for writing a gzip file. Mark initialization by setting - state->size to non-zero. Return -1 on failure or 0 on success. */ + state->size to non-zero. Return -1 on a memory allocation failure, or 0 on + success. */ local int gz_init(state) gz_statep state; { int ret; z_streamp strm = &(state->strm); - /* allocate input buffer */ - state->in = malloc(state->want); + /* allocate input buffer (double size for gzprintf) */ + state->in = (unsigned char *)malloc(state->want << 1); if (state->in == NULL) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; @@ -28,7 +30,7 @@ local int gz_init(state) /* only need output buffer and deflate state if compressing */ if (!state->direct) { /* allocate output buffer */ - state->out = malloc(state->want); + state->out = (unsigned char *)malloc(state->want); if (state->out == NULL) { free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); @@ -47,6 +49,7 @@ local int gz_init(state) gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } + strm->next_in = NULL; } /* mark state as initialized */ @@ -62,17 +65,17 @@ local int gz_init(state) } /* Compress whatever is at avail_in and next_in and write to the output file. - Return -1 if there is an error writing to the output file, otherwise 0. - flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH, - then the deflate() state is reset to start a new gzip stream. If gz->direct - is true, then simply write to the output file without compressing, and - ignore flush. */ + Return -1 if there is an error writing to the output file or if gz_init() + fails to allocate memory, otherwise 0. flush is assumed to be a valid + deflate() flush value. If flush is Z_FINISH, then the deflate() state is + reset to start a new gzip stream. If gz->direct is true, then simply write + to the output file without compressing, and ignore flush. */ local int gz_comp(state, flush) gz_statep state; int flush; { - int ret, got; - unsigned have; + int ret, writ; + unsigned have, put, max = ((unsigned)-1 >> 2) + 1; z_streamp strm = &(state->strm); /* allocate memory if this is the first time through */ @@ -81,12 +84,16 @@ local int gz_comp(state, flush) /* write directly if requested */ if (state->direct) { - got = write(state->fd, strm->next_in, strm->avail_in); - if (got < 0 || (unsigned)got != strm->avail_in) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; + while (strm->avail_in) { + put = strm->avail_in > max ? max : strm->avail_in; + writ = write(state->fd, strm->next_in, put); + if (writ < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + strm->avail_in -= (unsigned)writ; + strm->next_in += writ; } - strm->avail_in = 0; return 0; } @@ -97,17 +104,21 @@ local int gz_comp(state, flush) doing Z_FINISH then don't write until we get to Z_STREAM_END */ if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && (flush != Z_FINISH || ret == Z_STREAM_END))) { - have = (unsigned)(strm->next_out - state->x.next); - if (have && ((got = write(state->fd, state->x.next, have)) < 0 || - (unsigned)got != have)) { - gz_error(state, Z_ERRNO, zstrerror()); - return -1; + while (strm->next_out > state->x.next) { + put = strm->next_out - state->x.next > (int)max ? max : + (unsigned)(strm->next_out - state->x.next); + writ = write(state->fd, state->x.next, put); + if (writ < 0) { + gz_error(state, Z_ERRNO, zstrerror()); + return -1; + } + state->x.next += writ; } if (strm->avail_out == 0) { strm->avail_out = state->size; strm->next_out = state->out; + state->x.next = state->out; } - state->x.next = strm->next_out; } /* compress */ @@ -129,7 +140,8 @@ local int gz_comp(state, flush) return 0; } -/* Compress len zeros to output. Return -1 on error, 0 on success. */ +/* Compress len zeros to output. Return -1 on a write error or memory + allocation failure by gz_comp(), or 0 on success. */ local int gz_zero(state, len) gz_statep state; z_off64_t len; @@ -161,33 +173,14 @@ local int gz_zero(state, len) return 0; } -/* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ - unsigned put = len; - unsigned n; +/* Write len bytes from buf to file. Return the number of bytes written. If + the returned value is less than len, then there was an error. */ +local z_size_t gz_write(state, buf, len) gz_statep state; - z_streamp strm; - - /* get internal structure */ - if (file == NULL) - return 0; - state = (gz_statep)file; - strm = &(state->strm); - - /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; - - /* since an int is returned, make sure len fits in one, otherwise return - with an error (this avoids the flaw in the interface) */ - if ((int)len < 0) { - gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); - return 0; - } + voidpc buf; + z_size_t len; +{ + z_size_t put = len; /* if len is zero, avoid unnecessary operations */ if (len == 0) @@ -208,35 +201,103 @@ int ZEXPORT gzwrite(file, buf, len) if (len < state->size) { /* copy to input buffer, compress when full */ do { - if (strm->avail_in == 0) - strm->next_in = state->in; - n = state->size - strm->avail_in; - if (n > len) - n = len; - memcpy(strm->next_in + strm->avail_in, buf, n); - strm->avail_in += n; - state->x.pos += n; - buf = (char *)buf + n; - len -= n; + unsigned have, copy; + + if (state->strm.avail_in == 0) + state->strm.next_in = state->in; + have = (unsigned)((state->strm.next_in + state->strm.avail_in) - + state->in); + copy = state->size - have; + if (copy > len) + copy = len; + memcpy(state->in + have, buf, copy); + state->strm.avail_in += copy; + state->x.pos += copy; + buf = (const char *)buf + copy; + len -= copy; if (len && gz_comp(state, Z_NO_FLUSH) == -1) return 0; } while (len); } else { /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) + if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1) return 0; /* directly compress user buffer to file */ - strm->avail_in = len; - strm->next_in = (voidp)buf; - state->x.pos += len; - if (gz_comp(state, Z_NO_FLUSH) == -1) - return 0; + state->strm.next_in = (z_const Bytef *)buf; + do { + unsigned n = (unsigned)-1; + if (n > len) + n = len; + state->strm.avail_in = n; + state->x.pos += n; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return 0; + len -= n; + } while (len); } - /* input was all buffered or compressed (put will fit in int) */ - return (int)put; + /* input was all buffered or compressed */ + return put; +} + +/* -- see zlib.h -- */ +int ZEXPORT gzwrite(file, buf, len) + gzFile file; + voidpc buf; + unsigned len; +{ + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* since an int is returned, make sure len fits in one, otherwise return + with an error (this avoids a flaw in the interface) */ + if ((int)len < 0) { + gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); + return 0; + } + + /* write len bytes from buf (the return value will fit in an int) */ + return (int)gz_write(state, buf, len); +} + +/* -- see zlib.h -- */ +z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) + voidpc buf; + z_size_t size; + z_size_t nitems; + gzFile file; +{ + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return 0; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return 0; + + /* compute bytes to read -- error on overflow */ + len = nitems * size; + if (size && len / size != nitems) { + gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); + return 0; + } + + /* write len bytes to buf, return the number of full items written */ + return len ? gz_write(state, buf, len) / size : 0; } /* -- see zlib.h -- */ @@ -244,6 +305,7 @@ int ZEXPORT gzputc(file, c) gzFile file; int c; { + unsigned have; unsigned char buf[1]; gz_statep state; z_streamp strm; @@ -267,17 +329,21 @@ int ZEXPORT gzputc(file, c) /* try writing to input buffer for speed (state->size == 0 if buffer not initialized) */ - if (strm->avail_in < state->size) { + if (state->size) { if (strm->avail_in == 0) strm->next_in = state->in; - strm->next_in[strm->avail_in++] = c; - state->x.pos++; - return c & 0xff; + have = (unsigned)((strm->next_in + strm->avail_in) - state->in); + if (have < state->size) { + state->in[have] = (unsigned char)c; + strm->avail_in++; + state->x.pos++; + return c & 0xff; + } } /* no room in buffer or not initialized, use gz_write() */ - buf[0] = c; - if (gzwrite(file, buf, 1) != 1) + buf[0] = (unsigned char)c; + if (gz_write(state, buf, 1) != 1) return -1; return c & 0xff; } @@ -288,11 +354,21 @@ int ZEXPORT gzputs(file, str) const char *str; { int ret; - unsigned len; + z_size_t len; + gz_statep state; + + /* get internal structure */ + if (file == NULL) + return -1; + state = (gz_statep)file; + + /* check that we're writing and that there's no error */ + if (state->mode != GZ_WRITE || state->err != Z_OK) + return -1; /* write string */ - len = (unsigned)strlen(str); - ret = gzwrite(file, str, len); + len = strlen(str); + ret = gz_write(state, str, len); return ret == 0 && len != 0 ? -1 : ret; } @@ -300,74 +376,89 @@ int ZEXPORT gzputs(file, str) #include /* -- see zlib.h -- */ -int ZEXPORTVA gzprintf (gzFile file, const char *format, ...) +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { - int size, len; + int len; + unsigned left; + char *next; gz_statep state; z_streamp strm; - va_list va; /* get internal structure */ if (file == NULL) - return -1; + return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; + return Z_STREAM_ERROR; /* make sure we have some buffer space */ if (state->size == 0 && gz_init(state) == -1) - return 0; + return state->err; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return 0; + return state->err; } - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* do the printf() into the input buffer, put length in len */ - size = (int)(state->size); - state->in[size - 1] = 0; - va_start(va, format); + /* do the printf() into the input buffer, put length in len -- the input + buffer is double-sized just for this function, so there is guaranteed to + be state->size bytes available after the current contents */ + if (strm->avail_in == 0) + strm->next_in = state->in; + next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in); + next[state->size - 1] = 0; #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void - (void)vsprintf(state->in, format, va); - va_end(va); - for (len = 0; len < size; len++) - if (state->in[len] == 0) break; + (void)vsprintf(next, format, va); + for (len = 0; len < state->size; len++) + if (next[len] == 0) break; # else - len = vsprintf(state->in, format, va); - va_end(va); + len = vsprintf(next, format, va); # endif #else # ifdef HAS_vsnprintf_void - (void)vsnprintf(state->in, size, format, va); - va_end(va); - len = strlen(state->in); + (void)vsnprintf(next, state->size, format, va); + len = strlen(next); # else - len = vsnprintf((char *)(state->in), size, format, va); - va_end(va); + len = vsnprintf(next, state->size, format, va); # endif #endif /* check that printf() results fit in buffer */ - if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) + if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) return 0; - /* update buffer and position, defer compression until needed */ - strm->avail_in = (unsigned)len; - strm->next_in = state->in; + /* update buffer and position, compress first half if past that */ + strm->avail_in += (unsigned)len; state->x.pos += len; + if (strm->avail_in >= state->size) { + left = strm->avail_in - state->size; + strm->avail_in = state->size; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return state->err; + memcpy(state->in, state->in + state->size, left); + strm->next_in = state->in; + strm->avail_in = left; + } return len; } +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) +{ + va_list va; + int ret; + + va_start(va, format); + ret = gzvprintf(file, format, va); + va_end(va); + return ret; +} + #else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ @@ -378,72 +469,82 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; { - int size, len; + unsigned len, left; + char *next; gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) - return -1; + return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that can really pass pointer in ints */ if (sizeof(int) != sizeof(void *)) - return 0; + return Z_STREAM_ERROR; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) - return 0; + return Z_STREAM_ERROR; /* make sure we have some buffer space */ if (state->size == 0 && gz_init(state) == -1) - return 0; + return state->error; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return 0; + return state->error; } - /* consume whatever's left in the input buffer */ - if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) - return 0; - - /* do the printf() into the input buffer, put length in len */ - size = (int)(state->size); - state->in[size - 1] = 0; + /* do the printf() into the input buffer, put length in len -- the input + buffer is double-sized just for this function, so there is guaranteed to + be state->size bytes available after the current contents */ + if (strm->avail_in == 0) + strm->next_in = state->in; + next = (char *)(strm->next_in + strm->avail_in); + next[state->size - 1] = 0; #ifdef NO_snprintf # ifdef HAS_sprintf_void - sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, + a13, a14, a15, a16, a17, a18, a19, a20); for (len = 0; len < size; len++) - if (state->in[len] == 0) break; + if (next[len] == 0) + break; # else - len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, + a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #else # ifdef HAS_snprintf_void - snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); - len = strlen(state->in); + snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = strlen(next); # else - len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); + len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, + a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #endif /* check that printf() results fit in buffer */ - if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) + if (len == 0 || len >= state->size || next[state->size - 1] != 0) return 0; - /* update buffer and position, defer compression until needed */ - strm->avail_in = (unsigned)len; - strm->next_in = state->in; + /* update buffer and position, compress first half if past that */ + strm->avail_in += len; state->x.pos += len; - return len; + if (strm->avail_in >= state->size) { + left = strm->avail_in - state->size; + strm->avail_in = state->size; + if (gz_comp(state, Z_NO_FLUSH) == -1) + return state->err; + memcpy(state->in, state->in + state->size, left); + strm->next_in = state->in; + strm->avail_in = left; + } + return (int)len; } #endif @@ -457,7 +558,7 @@ int ZEXPORT gzflush(file, flush) /* get internal structure */ if (file == NULL) - return -1; + return Z_STREAM_ERROR; state = (gz_statep)file; /* check that we're writing and that there's no error */ @@ -472,11 +573,11 @@ int ZEXPORT gzflush(file, flush) if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return -1; + return state->err; } /* compress remaining data with requested flush */ - gz_comp(state, flush); + (void)gz_comp(state, flush); return state->err; } @@ -507,13 +608,13 @@ int ZEXPORT gzsetparams(file, level, strategy) if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) - return -1; + return state->err; } /* change compression parameters for subsequent input */ if (state->size) { /* flush previous input with previous parameters before changing */ - if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1) + if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) return state->err; deflateParams(strm, level, strategy); } @@ -548,11 +649,13 @@ int ZEXPORT gzclose_w(file) /* flush, free memory, and close file */ if (gz_comp(state, Z_FINISH) == -1) ret = state->err; - if (!state->direct) { - (void)deflateEnd(&(state->strm)); - free(state->out); + if (state->size) { + if (!state->direct) { + (void)deflateEnd(&(state->strm)); + free(state->out); + } + free(state->in); } - free(state->in); gz_error(state, Z_OK, NULL); free(state->path); if (close(state->fd) == -1) @@ -560,34 +663,3 @@ int ZEXPORT gzclose_w(file) free(state); return ret; } - -/* used by zlibVersion() to get the vsnprintf story from the horse's mouth */ -unsigned long ZEXPORT gzflags() -{ - unsigned long flags = 0; -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifdef NO_vsnprintf - flags += 1L << 25; -# ifdef HAS_vsprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_vsnprintf_void - flags += 1L << 26; -# endif -# endif -#else - flags += 1L << 24; -# ifdef NO_snprintf - flags += 1L << 25; -# ifdef HAS_sprintf_void - flags += 1L << 26; -# endif -# else -# ifdef HAS_snprintf_void - flags += 1L << 26; -# endif -# endif -#endif - return flags; -} diff --git a/libs/zlib/infback.c b/libs/zlib/infback.c index 981aff17c..59679ecbf 100644 --- a/libs/zlib/infback.c +++ b/libs/zlib/infback.c @@ -1,5 +1,5 @@ /* infback.c -- inflate using a call-back interface - * Copyright (C) 1995-2011 Mark Adler + * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -61,7 +61,7 @@ int stream_size; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; state->dmax = 32768U; - state->wbits = windowBits; + state->wbits = (uInt)windowBits; state->wsize = 1U << windowBits; state->window = window; state->wnext = 0; @@ -255,7 +255,7 @@ out_func out; void FAR *out_desc; { struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ + z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ diff --git a/libs/zlib/inffast.c b/libs/zlib/inffast.c index 2f1d60b43..0dbd1dbc0 100644 --- a/libs/zlib/inffast.c +++ b/libs/zlib/inffast.c @@ -1,5 +1,5 @@ /* inffast.c -- fast decoding - * Copyright (C) 1995-2008, 2010 Mark Adler + * Copyright (C) 1995-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -8,26 +8,9 @@ #include "inflate.h" #include "inffast.h" -#ifndef ASMINF - -/* Allow machine dependent optimization for post-increment or pre-increment. - Based on testing to date, - Pre-increment preferred for: - - PowerPC G3 (Adler) - - MIPS R5000 (Randers-Pehrson) - Post-increment preferred for: - - none - No measurable difference: - - Pentium III (Anderson) - - M68060 (Nikl) - */ -#ifdef POSTINC -# define OFF 0 -# define PUP(a) *(a)++ +#ifdef ASMINF +# pragma message("Assembler code may have bugs -- use at your own risk") #else -# define OFF 1 -# define PUP(a) *++(a) -#endif /* Decode literal, length, and distance codes and write out the resulting @@ -69,8 +52,8 @@ z_streamp strm; unsigned start; /* inflate()'s starting value for strm->avail_out */ { struct inflate_state FAR *state; - unsigned char FAR *in; /* local strm->next_in */ - unsigned char FAR *last; /* while in < last, enough input available */ + z_const unsigned char FAR *in; /* local strm->next_in */ + z_const unsigned char FAR *last; /* have enough input while in < last */ unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR *end; /* while out < end, enough space available */ @@ -96,9 +79,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; - in = strm->next_in - OFF; + in = strm->next_in; last = in + (strm->avail_in - 5); - out = strm->next_out - OFF; + out = strm->next_out; beg = out - (start - strm->avail_out); end = out + (strm->avail_out - 257); #ifdef INFLATE_STRICT @@ -119,9 +102,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ input data or output space */ do { if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } here = lcode[hold & lmask]; @@ -134,14 +117,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? "inflate: literal '%c'\n" : "inflate: literal 0x%02x\n", here.val)); - PUP(out) = (unsigned char)(here.val); + *out++ = (unsigned char)(here.val); } else if (op & 16) { /* length base */ len = (unsigned)(here.val); op &= 15; /* number of extra bits */ if (op) { if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } len += (unsigned)hold & ((1U << op) - 1); @@ -150,9 +133,9 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ } Tracevv((stderr, "inflate: length %u\n", len)); if (bits < 15) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } here = dcode[hold & dmask]; @@ -165,10 +148,10 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ dist = (unsigned)(here.val); op &= 15; /* number of extra bits */ if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; if (bits < op) { - hold += (unsigned long)(PUP(in)) << bits; + hold += (unsigned long)(*in++) << bits; bits += 8; } } @@ -196,30 +179,30 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR if (len <= op - whave) { do { - PUP(out) = 0; + *out++ = 0; } while (--len); continue; } len -= op - whave; do { - PUP(out) = 0; + *out++ = 0; } while (--op > whave); if (op == 0) { from = out - dist; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--len); continue; } #endif } - from = window - OFF; + from = window; if (wnext == 0) { /* very common case */ from += wsize - op; if (op < len) { /* some from window */ len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); from = out - dist; /* rest from output */ } @@ -230,14 +213,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ if (op < len) { /* some from end of window */ len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); - from = window - OFF; + from = window; if (wnext < len) { /* some from start of window */ op = wnext; len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); from = out - dist; /* rest from output */ } @@ -248,35 +231,35 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ if (op < len) { /* some from window */ len -= op; do { - PUP(out) = PUP(from); + *out++ = *from++; } while (--op); from = out - dist; /* rest from output */ } } while (len > 2) { - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; len -= 3; } if (len) { - PUP(out) = PUP(from); + *out++ = *from++; if (len > 1) - PUP(out) = PUP(from); + *out++ = *from++; } } else { from = out - dist; /* copy direct from output */ do { /* minimum length is three */ - PUP(out) = PUP(from); - PUP(out) = PUP(from); - PUP(out) = PUP(from); + *out++ = *from++; + *out++ = *from++; + *out++ = *from++; len -= 3; } while (len > 2); if (len) { - PUP(out) = PUP(from); + *out++ = *from++; if (len > 1) - PUP(out) = PUP(from); + *out++ = *from++; } } } @@ -313,8 +296,8 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ hold &= (1U << bits) - 1; /* update state and return */ - strm->next_in = in + OFF; - strm->next_out = out + OFF; + strm->next_in = in; + strm->next_out = out; strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last)); strm->avail_out = (unsigned)(out < end ? 257 + (end - out) : 257 - (out - end)); diff --git a/libs/zlib/inflate.c b/libs/zlib/inflate.c index cc89517bc..ac333e8c2 100644 --- a/libs/zlib/inflate.c +++ b/libs/zlib/inflate.c @@ -1,5 +1,5 @@ /* inflate.c -- zlib decompression - * Copyright (C) 1995-2011 Mark Adler + * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -92,20 +92,36 @@ #endif /* function prototypes */ +local int inflateStateCheck OF((z_streamp strm)); local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, unsigned out)); +local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, + unsigned copy)); #ifdef BUILDFIXED void makefixed OF((void)); #endif -local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, +local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, unsigned len)); +local int inflateStateCheck(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (strm == Z_NULL || + strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) + return 1; + state = (struct inflate_state FAR *)strm->state; + if (state == Z_NULL || state->strm != strm || + state->mode < HEAD || state->mode > SYNC) + return 1; + return 0; +} + int ZEXPORT inflateResetKeep(strm) z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; @@ -130,7 +146,7 @@ z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; state->wsize = 0; state->whave = 0; @@ -146,7 +162,7 @@ int windowBits; struct inflate_state FAR *state; /* get the state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* extract wrap request from windowBits parameter */ @@ -155,7 +171,7 @@ int windowBits; windowBits = -windowBits; } else { - wrap = (windowBits >> 4) + 1; + wrap = (windowBits >> 4) + 5; #ifdef GUNZIP if (windowBits < 48) windowBits &= 15; @@ -209,7 +225,9 @@ int stream_size; if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; + state->strm = strm; state->window = Z_NULL; + state->mode = HEAD; /* to pass state test in inflateReset2() */ ret = inflateReset2(strm, windowBits); if (ret != Z_OK) { ZFREE(strm, state); @@ -233,17 +251,17 @@ int value; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (bits < 0) { state->hold = 0; state->bits = 0; return Z_OK; } - if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; + if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; value &= (1L << bits) - 1; - state->hold += value << state->bits; - state->bits += bits; + state->hold += (unsigned)value << state->bits; + state->bits += (uInt)bits; return Z_OK; } @@ -375,12 +393,13 @@ void makefixed() output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(strm, out) +local int updatewindow(strm, end, copy) z_streamp strm; -unsigned out; +const Bytef *end; +unsigned copy; { struct inflate_state FAR *state; - unsigned copy, dist; + unsigned dist; state = (struct inflate_state FAR *)strm->state; @@ -400,19 +419,18 @@ unsigned out; } /* copy state->wsize or less output bytes into the circular window */ - copy = out - strm->avail_out; if (copy >= state->wsize) { - zmemcpy(state->window, strm->next_out - state->wsize, state->wsize); + zmemcpy(state->window, end - state->wsize, state->wsize); state->wnext = 0; state->whave = state->wsize; } else { dist = state->wsize - state->wnext; if (dist > copy) dist = copy; - zmemcpy(state->window + state->wnext, strm->next_out - copy, dist); + zmemcpy(state->window + state->wnext, end - copy, dist); copy -= dist; if (copy) { - zmemcpy(state->window, strm->next_out - copy, copy); + zmemcpy(state->window, end - copy, copy); state->wnext = copy; state->whave = state->wsize; } @@ -519,11 +537,6 @@ unsigned out; bits -= bits & 7; \ } while (0) -/* Reverse the bytes in a 32-bit value */ -#define REVERSE(q) \ - ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ - (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) - /* inflate() uses a state machine to process as much input data and generate as much output data as possible before returning. The state machine is @@ -611,7 +624,7 @@ z_streamp strm; int flush; { struct inflate_state FAR *state; - unsigned char FAR *next; /* next input */ + z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ @@ -629,7 +642,7 @@ int flush; static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL || + if (inflateStateCheck(strm) || strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0)) return Z_STREAM_ERROR; @@ -649,6 +662,8 @@ int flush; NEEDBITS(16); #ifdef GUNZIP if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + if (state->wbits == 0) + state->wbits = 15; state->check = crc32(0L, Z_NULL, 0); CRC2(state->check, hold); INITBITS(); @@ -676,7 +691,7 @@ int flush; len = BITS(4) + 8; if (state->wbits == 0) state->wbits = len; - else if (len > state->wbits) { + if (len > 15 || len > state->wbits) { strm->msg = (char *)"invalid window size"; state->mode = BAD; break; @@ -703,14 +718,16 @@ int flush; } if (state->head != Z_NULL) state->head->text = (int)((hold >> 8) & 1); - if (state->flags & 0x0200) CRC2(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); INITBITS(); state->mode = TIME; case TIME: NEEDBITS(32); if (state->head != Z_NULL) state->head->time = hold; - if (state->flags & 0x0200) CRC4(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC4(state->check, hold); INITBITS(); state->mode = OS; case OS: @@ -719,7 +736,8 @@ int flush; state->head->xflags = (int)(hold & 0xff); state->head->os = (int)(hold >> 8); } - if (state->flags & 0x0200) CRC2(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; case EXLEN: @@ -728,7 +746,8 @@ int flush; state->length = (unsigned)(hold); if (state->head != Z_NULL) state->head->extra_len = (unsigned)hold; - if (state->flags & 0x0200) CRC2(state->check, hold); + if ((state->flags & 0x0200) && (state->wrap & 4)) + CRC2(state->check, hold); INITBITS(); } else if (state->head != Z_NULL) @@ -746,7 +765,7 @@ int flush; len + copy > state->head->extra_max ? state->head->extra_max - len : copy); } - if (state->flags & 0x0200) + if ((state->flags & 0x0200) && (state->wrap & 4)) state->check = crc32(state->check, next, copy); have -= copy; next += copy; @@ -765,9 +784,9 @@ int flush; if (state->head != Z_NULL && state->head->name != Z_NULL && state->length < state->head->name_max) - state->head->name[state->length++] = len; + state->head->name[state->length++] = (Bytef)len; } while (len && copy < have); - if (state->flags & 0x0200) + if ((state->flags & 0x0200) && (state->wrap & 4)) state->check = crc32(state->check, next, copy); have -= copy; next += copy; @@ -786,9 +805,9 @@ int flush; if (state->head != Z_NULL && state->head->comment != Z_NULL && state->length < state->head->comm_max) - state->head->comment[state->length++] = len; + state->head->comment[state->length++] = (Bytef)len; } while (len && copy < have); - if (state->flags & 0x0200) + if ((state->flags & 0x0200) && (state->wrap & 4)) state->check = crc32(state->check, next, copy); have -= copy; next += copy; @@ -800,7 +819,7 @@ int flush; case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); - if (hold != (state->check & 0xffff)) { + if ((state->wrap & 4) && hold != (state->check & 0xffff)) { strm->msg = (char *)"header crc mismatch"; state->mode = BAD; break; @@ -817,7 +836,7 @@ int flush; #endif case DICTID: NEEDBITS(32); - strm->adler = state->check = REVERSE(hold); + strm->adler = state->check = ZSWAP32(hold); INITBITS(); state->mode = DICT; case DICT: @@ -925,7 +944,7 @@ int flush; while (state->have < 19) state->lens[order[state->have++]] = 0; state->next = state->codes; - state->lencode = (code const FAR *)(state->next); + state->lencode = (const code FAR *)(state->next); state->lenbits = 7; ret = inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work); @@ -999,7 +1018,7 @@ int flush; values here (9 and 6) without reading the comments in inftrees.h concerning the ENOUGH constants, which depend on those values */ state->next = state->codes; - state->lencode = (code const FAR *)(state->next); + state->lencode = (const code FAR *)(state->next); state->lenbits = 9; ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work); @@ -1008,7 +1027,7 @@ int flush; state->mode = BAD; break; } - state->distcode = (code const FAR *)(state->next); + state->distcode = (const code FAR *)(state->next); state->distbits = 6; ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, &(state->next), &(state->distbits), state->work); @@ -1181,15 +1200,15 @@ int flush; out -= left; strm->total_out += out; state->total += out; - if (out) + if ((state->wrap & 4) && out) strm->adler = state->check = UPDATE(state->check, put - out, out); out = left; - if (( + if ((state->wrap & 4) && ( #ifdef GUNZIP state->flags ? hold : #endif - REVERSE(hold)) != state->check) { + ZSWAP32(hold)) != state->check) { strm->msg = (char *)"incorrect data check"; state->mode = BAD; break; @@ -1235,7 +1254,7 @@ int flush; RESTORE(); if (state->wsize || (out != strm->avail_out && state->mode < BAD && (state->mode < CHECK || flush != Z_FINISH))) - if (updatewindow(strm, out)) { + if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { state->mode = MEM; return Z_MEM_ERROR; } @@ -1244,10 +1263,10 @@ int flush; strm->total_in += in; strm->total_out += out; state->total += out; - if (state->wrap && out) + if ((state->wrap & 4) && out) strm->adler = state->check = UPDATE(state->check, strm->next_out - out, out); - strm->data_type = state->bits + (state->last ? 64 : 0) + + strm->data_type = (int)state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) @@ -1259,7 +1278,7 @@ int ZEXPORT inflateEnd(strm) z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->window != Z_NULL) ZFREE(strm, state->window); @@ -1269,40 +1288,55 @@ z_streamp strm; return Z_OK; } +int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) +z_streamp strm; +Bytef *dictionary; +uInt *dictLength; +{ + struct inflate_state FAR *state; + + /* check state */ + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + + /* copy dictionary */ + if (state->whave && dictionary != Z_NULL) { + zmemcpy(dictionary, state->window + state->wnext, + state->whave - state->wnext); + zmemcpy(dictionary + state->whave - state->wnext, + state->window, state->wnext); + } + if (dictLength != Z_NULL) + *dictLength = state->whave; + return Z_OK; +} + int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) z_streamp strm; const Bytef *dictionary; uInt dictLength; { struct inflate_state FAR *state; - unsigned long id; - unsigned char *next; - unsigned avail; + unsigned long dictid; int ret; /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->wrap != 0 && state->mode != DICT) return Z_STREAM_ERROR; - /* check for correct dictionary id */ + /* check for correct dictionary identifier */ if (state->mode == DICT) { - id = adler32(0L, Z_NULL, 0); - id = adler32(id, dictionary, dictLength); - if (id != state->check) + dictid = adler32(0L, Z_NULL, 0); + dictid = adler32(dictid, dictionary, dictLength); + if (dictid != state->check) return Z_DATA_ERROR; } /* copy dictionary to window using updatewindow(), which will amend the existing dictionary if appropriate */ - next = strm->next_out; - avail = strm->avail_out; - strm->next_out = (Bytef *)dictionary + dictLength; - strm->avail_out = 0; - ret = updatewindow(strm, dictLength); - strm->avail_out = avail; - strm->next_out = next; + ret = updatewindow(strm, dictionary + dictLength, dictLength); if (ret) { state->mode = MEM; return Z_MEM_ERROR; @@ -1319,7 +1353,7 @@ gz_headerp head; struct inflate_state FAR *state; /* check state */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; @@ -1342,7 +1376,7 @@ gz_headerp head; */ local unsigned syncsearch(have, buf, len) unsigned FAR *have; -unsigned char FAR *buf; +const unsigned char FAR *buf; unsigned len; { unsigned got; @@ -1372,7 +1406,7 @@ z_streamp strm; struct inflate_state FAR *state; /* check parameters */ - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; @@ -1419,7 +1453,7 @@ z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; return state->mode == STORED && state->bits == 0; } @@ -1434,8 +1468,7 @@ z_streamp source; unsigned wsize; /* check input */ - if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || - source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) + if (inflateStateCheck(source) || dest == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)source->state; @@ -1456,6 +1489,7 @@ z_streamp source; /* copy state */ zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); + copy->strm = dest; if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); @@ -1477,25 +1511,51 @@ int subvert; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; - state->sane = !subvert; #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR + state->sane = !subvert; return Z_OK; #else + (void)subvert; state->sane = 1; return Z_DATA_ERROR; #endif } +int ZEXPORT inflateValidate(strm, check) +z_streamp strm; +int check; +{ + struct inflate_state FAR *state; + + if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + state = (struct inflate_state FAR *)strm->state; + if (check) + state->wrap |= 4; + else + state->wrap &= ~4; + return Z_OK; +} + long ZEXPORT inflateMark(strm) z_streamp strm; { struct inflate_state FAR *state; - if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16; + if (inflateStateCheck(strm)) + return -(1L << 16); state = (struct inflate_state FAR *)strm->state; - return ((long)(state->back) << 16) + + return (long)(((unsigned long)((long)state->back)) << 16) + (state->mode == COPY ? state->length : (state->mode == MATCH ? state->was - state->length : 0)); } + +unsigned long ZEXPORT inflateCodesUsed(strm) +z_streamp strm; +{ + struct inflate_state FAR *state; + if (inflateStateCheck(strm)) return (unsigned long)-1; + state = (struct inflate_state FAR *)strm->state; + return (unsigned long)(state->next - state->codes); +} diff --git a/libs/zlib/inflate.h b/libs/zlib/inflate.h index 95f4986d4..a46cce6b6 100644 --- a/libs/zlib/inflate.h +++ b/libs/zlib/inflate.h @@ -1,5 +1,5 @@ /* inflate.h -- internal inflate state definition - * Copyright (C) 1995-2009 Mark Adler + * Copyright (C) 1995-2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -18,7 +18,7 @@ /* Possible inflate modes between inflate() calls */ typedef enum { - HEAD, /* i: waiting for magic header */ + HEAD = 16180, /* i: waiting for magic header */ FLAGS, /* i: waiting for method and flags (gzip) */ TIME, /* i: waiting for modification time (gzip) */ OS, /* i: waiting for extra flags and operating system (gzip) */ @@ -77,11 +77,14 @@ typedef enum { CHECK -> LENGTH -> DONE */ -/* state maintained between inflate() calls. Approximately 10K bytes. */ +/* State maintained between inflate() calls -- approximately 7K bytes, not + including the allocated sliding window, which is up to 32K bytes. */ struct inflate_state { + z_streamp strm; /* pointer back to this zlib stream */ inflate_mode mode; /* current inflate mode */ int last; /* true if processing last block */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip, + bit 2 true to validate check value */ int havedict; /* true if dictionary provided */ int flags; /* gzip header method and flags (0 if zlib) */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ diff --git a/libs/zlib/inftrees.c b/libs/zlib/inftrees.c index 60bbd58bf..2ea08fc13 100644 --- a/libs/zlib/inftrees.c +++ b/libs/zlib/inftrees.c @@ -1,5 +1,5 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2012 Mark Adler + * Copyright (C) 1995-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ @@ -9,7 +9,7 @@ #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.6 Copyright 1995-2012 Mark Adler "; + " inflate 1.2.11 Copyright 1995-2017 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot @@ -54,7 +54,7 @@ unsigned short FAR *work; code FAR *next; /* next available space in table */ const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR *extra; /* extra bits table to use */ - int end; /* use base and extra for symbol > end */ + unsigned match; /* use base and extra for symbol >= match */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ @@ -62,7 +62,7 @@ unsigned short FAR *work; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 69}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 202}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, @@ -181,19 +181,17 @@ unsigned short FAR *work; switch (type) { case CODES: base = extra = work; /* dummy value--not used */ - end = 19; + match = 20; break; case LENS: base = lbase; - base -= 257; extra = lext; - extra -= 257; - end = 256; + match = 257; break; - default: /* DISTS */ + default: /* DISTS */ base = dbase; extra = dext; - end = -1; + match = 0; } /* initialize state for loop */ @@ -208,21 +206,21 @@ unsigned short FAR *work; mask = used - 1; /* mask for comparing low */ /* check available table space */ - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) + if ((type == LENS && used > ENOUGH_LENS) || + (type == DISTS && used > ENOUGH_DISTS)) return 1; /* process all codes and make table entries */ for (;;) { /* create table entry */ here.bits = (unsigned char)(len - drop); - if ((int)(work[sym]) < end) { + if (work[sym] + 1U < match) { here.op = (unsigned char)0; here.val = work[sym]; } - else if ((int)(work[sym]) > end) { - here.op = (unsigned char)(extra[work[sym]]); - here.val = base[work[sym]]; + else if (work[sym] >= match) { + here.op = (unsigned char)(extra[work[sym] - match]); + here.val = base[work[sym] - match]; } else { here.op = (unsigned char)(32 + 64); /* end of block */ @@ -277,8 +275,8 @@ unsigned short FAR *work; /* check for enough space */ used += 1U << curr; - if ((type == LENS && used >= ENOUGH_LENS) || - (type == DISTS && used >= ENOUGH_DISTS)) + if ((type == LENS && used > ENOUGH_LENS) || + (type == DISTS && used > ENOUGH_DISTS)) return 1; /* point entry in root table to sub-table */ diff --git a/libs/zlib/make_vms.com b/libs/zlib/make_vms.com index 11be527f0..65e9d0cbc 100644 --- a/libs/zlib/make_vms.com +++ b/libs/zlib/make_vms.com @@ -3,7 +3,7 @@ $! Martin P.J. Zinser $! $! In case of problems with the install you might contact me at $! zinser@zinser.no-ip.info(preferred) or -$! zinser@sysdev.deutsche-boerse.com (work) +$! martin.zinser@eurexchange.com (work) $! $! Make procedure history for Zlib $! @@ -14,9 +14,16 @@ $! 0.02 20061008 Adapt to new Makefile.in $! 0.03 20091224 Add support for large file check $! 0.04 20100110 Add new gzclose, gzlib, gzread, gzwrite $! 0.05 20100221 Exchange zlibdefs.h by zconf.h.in +$! 0.06 20120111 Fix missing amiss_err, update zconf_h.in, fix new exmples +$! subdir path, update module search in makefile.in +$! 0.07 20120115 Triggered by work done by Alexey Chupahin completly redesigned +$! shared image creation +$! 0.08 20120219 Make it work on VAX again, pre-load missing symbols to shared +$! image +$! 0.09 20120305 SMS. P1 sets builder ("MMK", "MMS", " " (built-in)). +$! "" -> automatic, preference: MMK, MMS, built-in. $! $ on error then goto err_exit -$ set proc/parse=ext $! $ true = 1 $ false = 0 @@ -32,31 +39,43 @@ $ s_case = False $! $! Setup variables holding "config" information $! -$ Make = "" +$ Make = "''p1'" $ name = "Zlib" $ version = "?.?.?" $ v_string = "ZLIB_VERSION" $ v_file = "zlib.h" -$ ccopt = "" +$ ccopt = "/include = []" $ lopts = "" $ dnsrl = "" -$ aconf_in_file = "zconf.h.in#zconf.h_in" +$ aconf_in_file = "zconf.h.in#zconf.h_in#zconf_h.in" $ conf_check_string = "" $ linkonly = false $ optfile = name + ".opt" +$ mapfile = name + ".map" $ libdefs = "" +$ vax = f$getsyi("HW_MODEL").lt.1024 $ axp = f$getsyi("HW_MODEL").ge.1024 .and. f$getsyi("HW_MODEL").lt.4096 +$ ia64 = f$getsyi("HW_MODEL").ge.4096 $! -$ whoami = f$parse(f$enviornment("Procedure"),,,,"NO_CONCEAL") +$! 2012-03-05 SMS. +$! Why is this needed? And if it is needed, why not simply ".not. vax"? +$! +$!!! if axp .or. ia64 then set proc/parse=extended +$! +$ whoami = f$parse(f$environment("Procedure"),,,,"NO_CONCEAL") $ mydef = F$parse(whoami,,,"DEVICE") $ mydir = f$parse(whoami,,,"DIRECTORY") - "][" $ myproc = f$parse(whoami,,,"Name") + f$parse(whoami,,,"type") $! $! Check for MMK/MMS $! -$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" -$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" -$! +$ if (Make .eqs. "") +$ then +$ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" +$ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" +$ else +$ Make = f$edit( Make, "trim") +$ endif $! $ gosub find_version $! @@ -69,6 +88,7 @@ $! Look for the compiler used $! $ gosub check_compiler $ close topt +$ close optf $! $ if its_decc $ then @@ -83,6 +103,15 @@ $ ccopt = "/decc" + ccopt $ define sys decc$library_include: $ endif $ endif +$! +$! 2012-03-05 SMS. +$! Why /NAMES = AS_IS? Why not simply ".not. vax"? And why not on VAX? +$! +$ if axp .or. ia64 +$ then +$ ccopt = ccopt + "/name=as_is/opt=(inline=speed)" +$ s_case = true +$ endif $ endif $ if its_vaxc .or. its_gnuc $ then @@ -122,15 +151,20 @@ $ gosub check_config $ endif $ goto aconf_loop $ACONF_EXIT: +$ write aconf "" +$ write aconf "/* VMS specifics added by make_vms.com: */" $ write aconf "#define VMS 1" $ write aconf "#include " $ write aconf "#include " $ write aconf "#ifdef _LARGEFILE" -$ write aconf "#define off64_t __off64_t" -$ write aconf "#define fopen64 fopen" -$ write aconf "#define fseeko64 fseeko" -$ write aconf "#define lseek64 lseek" -$ write aconf "#define ftello64 ftell" +$ write aconf "# define off64_t __off64_t" +$ write aconf "# define fopen64 fopen" +$ write aconf "# define fseeko64 fseeko" +$ write aconf "# define lseek64 lseek" +$ write aconf "# define ftello64 ftell" +$ write aconf "#endif" +$ write aconf "#if !defined( __VAX) && (__CRTL_VER >= 70312000)" +$ write aconf "# define HAVE_VSNPRINTF" $ write aconf "#endif" $ close aconf_in $ close aconf @@ -139,8 +173,9 @@ $! Build the thing plain or with mms $! $ write sys$output "Compiling Zlib sources ..." $ if make.eqs."" -$ then -$ dele example.obj;*,minigzip.obj;* +$ then +$ if (f$search( "example.obj;*") .nes. "") then delete example.obj;* +$ if (f$search( "minigzip.obj;*") .nes. "") then delete minigzip.obj;* $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - adler32.c zlib.h zconf.h $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - @@ -174,41 +209,34 @@ $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - $ write sys$output "Building Zlib ..." $ CALL MAKE libz.OLB "lib/crea libz.olb *.obj" *.OBJ $ write sys$output "Building example..." -$ CALL MAKE example.OBJ "CC ''CCOPT' example" - - test/example.c zlib.h zconf.h +$ CALL MAKE example.OBJ "CC ''CCOPT' [.test]example" - + [.test]example.c zlib.h zconf.h $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb -$ if f$search("x11vms:xvmsutils.olb") .nes. "" -$ then -$ write sys$output "Building minigzip..." -$ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - - test/minigzip.c zlib.h zconf.h -$ call make minigzip.exe - - "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - - minigzip.obj libz.olb -$ endif -$ else +$ write sys$output "Building minigzip..." +$ CALL MAKE minigzip.OBJ "CC ''CCOPT' [.test]minigzip" - + [.test]minigzip.c zlib.h zconf.h +$ call make minigzip.exe - + "LINK minigzip,libz.olb/lib" - + minigzip.obj libz.olb +$ else $ gosub crea_mms $ write sys$output "Make ''name' ''version' with ''Make' " $ 'make' -$ endif -$! -$! Alpha gets a shareable image -$! -$ If axp -$ Then -$ gosub crea_olist -$ write sys$output "Creating libzshr.exe" -$ call anal_obj_axp modules.opt _link.opt -$ if s_case -$ then -$ open/append optf modules.opt -$ write optf "case_sensitive=YES" -$ close optf -$ endif -$ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,_link.opt/opt $ endif +$! +$! Create shareable image +$! +$ gosub crea_olist +$ write sys$output "Creating libzshr.exe" +$ call map_2_shopt 'mapfile' 'optfile' +$ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,'optfile'/opt $ write sys$output "Zlib build completed" +$ delete/nolog tmp.opt;* $ exit +$AMISS_ERR: +$ write sys$output "No source for config.hin found." +$ write sys$output "Tried any of ''aconf_in_file'" +$ goto err_exit $CC_ERR: $ write sys$output "C compiler required to build ''name'" $ goto err_exit @@ -216,7 +244,6 @@ $ERR_EXIT: $ set message/facil/ident/sever/text $ close/nolog optf $ close/nolog topt -$ close/nolog conf_hin $ close/nolog aconf_in $ close/nolog aconf $ close/nolog out @@ -397,7 +424,7 @@ $ copy sys$input: out $ deck # descrip.mms: MMS description file for building zlib on VMS # written by Martin P.J. Zinser -# +# OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzlib.obj\ gzread.obj, gzwrite.obj, uncompr.obj, infback.obj\ @@ -407,10 +434,9 @@ OBJS = adler32.obj, compress.obj, crc32.obj, gzclose.obj, gzlib.obj\ $ eod $ write out "CFLAGS=", ccopt $ write out "LOPTS=", lopts +$ write out "all : example.exe minigzip.exe libz.olb" $ copy sys$input: out $ deck - -all : example.exe minigzip.exe libz.olb @ write sys$output " Example applications available" libz.olb : libz.olb($(OBJS)) @@ -420,7 +446,7 @@ example.exe : example.obj libz.olb link $(LOPTS) example,libz.olb/lib minigzip.exe : minigzip.obj libz.olb - link $(LOPTS) minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib + link $(LOPTS) minigzip,libz.olb/lib clean : delete *.obj;*,libz.olb;*,*.opt;*,*.exe;* @@ -431,7 +457,7 @@ adler32.obj : adler32.c zutil.h zlib.h zconf.h compress.obj : compress.c zlib.h zconf.h crc32.obj : crc32.c zutil.h zlib.h zconf.h deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h -example.obj : test/example.c zlib.h zconf.h +example.obj : [.test]example.c zlib.h zconf.h gzclose.obj : gzclose.c zutil.h zlib.h zconf.h gzlib.obj : gzlib.c zutil.h zlib.h zconf.h gzread.obj : gzread.c zutil.h zlib.h zconf.h @@ -439,7 +465,7 @@ gzwrite.obj : gzwrite.c zutil.h zlib.h zconf.h inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h inflate.obj : inflate.c zutil.h zlib.h zconf.h inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h -minigzip.obj : test/minigzip.c zlib.h zconf.h +minigzip.obj : [.test]minigzip.c zlib.h zconf.h trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h uncompr.obj : uncompr.c zlib.h zconf.h zutil.obj : zutil.c zutil.h zlib.h zconf.h @@ -455,13 +481,18 @@ $! $CREA_OLIST: $ open/read min makefile.in $ open/write mod modules.opt -$ src_check = "OBJC =" +$ src_check_list = "OBJZ =#OBJG =" $MRLOOP: $ read/end=mrdone min rec -$ if (f$extract(0,6,rec) .nes. src_check) then goto mrloop +$ i = 0 +$SRC_CHECK_LOOP: +$ src_check = f$element(i, "#", src_check_list) +$ i = i+1 +$ if src_check .eqs. "#" then goto mrloop +$ if (f$extract(0,6,rec) .nes. src_check) then goto src_check_loop $ rec = rec - src_check $ gosub extra_filnam -$ if (f$element(1,"\",rec) .eqs. "\") then goto mrdone +$ if (f$element(1,"\",rec) .eqs. "\") then goto mrloop $MRSLOOP: $ read/end=mrdone min rec $ gosub extra_filnam @@ -672,124 +703,6 @@ $ endif $ return $!------------------------------------------------------------------------------ $! -$! Analyze Object files for OpenVMS AXP to extract Procedure and Data -$! information to build a symbol vector for a shareable image -$! All the "brains" of this logic was suggested by Hartmut Becker -$! (Hartmut.Becker@compaq.com). All the bugs were introduced by me -$! (zinser@zinser.no-ip.info), so if you do have problem reports please do not -$! bother Hartmut/HP, but get in touch with me -$! -$! Version history -$! 0.01 20040406 Skip over shareable images in option file -$! 0.02 20041109 Fix option file for shareable images with case_sensitive=YES -$! 0.03 20050107 Skip over Identification labels in option file -$! 0.04 20060117 Add uppercase alias to code compiled with /name=as_is -$! -$ ANAL_OBJ_AXP: Subroutine -$ V = 'F$Verify(0) -$ SAY := "WRITE_ SYS$OUTPUT" -$ -$ IF F$SEARCH("''P1'") .EQS. "" -$ THEN -$ SAY "ANAL_OBJ_AXP-E-NOSUCHFILE: Error, inputfile ''p1' not available" -$ goto exit_aa -$ ENDIF -$ IF "''P2'" .EQS. "" -$ THEN -$ SAY "ANAL_OBJ_AXP: Error, no output file provided" -$ goto exit_aa -$ ENDIF -$ -$ open/read in 'p1 -$ create a.tmp -$ open/append atmp a.tmp -$ loop: -$ read/end=end_loop in line -$ if f$locate("/SHARE",f$edit(line,"upcase")) .lt. f$length(line) -$ then -$ write sys$output "ANAL_SKP_SHR-i-skipshare, ''line'" -$ goto loop -$ endif -$ if f$locate("IDENTIFICATION=",f$edit(line,"upcase")) .lt. f$length(line) -$ then -$ write sys$output "ANAL_OBJ_AXP-i-ident: Identification ", - - f$element(1,"=",line) -$ goto loop -$ endif -$ f= f$search(line) -$ if f .eqs. "" -$ then -$ write sys$output "ANAL_OBJ_AXP-w-nosuchfile, ''line'" -$ goto loop -$ endif -$ define/user sys$output nl: -$ define/user sys$error nl: -$ anal/obj/gsd 'f /out=x.tmp -$ open/read xtmp x.tmp -$ XLOOP: -$ read/end=end_xloop xtmp xline -$ xline = f$edit(xline,"compress") -$ write atmp xline -$ goto xloop -$ END_XLOOP: -$ close xtmp -$ goto loop -$ end_loop: -$ close in -$ close atmp -$ if f$search("a.tmp") .eqs. "" - - then $ exit -$ ! all global definitions -$ search a.tmp "symbol:","EGSY$V_DEF 1","EGSY$V_NORM 1"/out=b.tmp -$ ! all procedures -$ search b.tmp "EGSY$V_NORM 1"/wind=(0,1) /out=c.tmp -$ search c.tmp "symbol:"/out=d.tmp -$ define/user sys$output nl: -$ edito/edt/command=sys$input d.tmp -sub/symbol: "/symbol_vector=(/whole -sub/"/=PROCEDURE)/whole -exit -$ ! all data -$ search b.tmp "EGSY$V_DEF 1"/wind=(0,1) /out=e.tmp -$ search e.tmp "symbol:"/out=f.tmp -$ define/user sys$output nl: -$ edito/edt/command=sys$input f.tmp -sub/symbol: "/symbol_vector=(/whole -sub/"/=DATA)/whole -exit -$ sort/nodupl d.tmp,f.tmp g.tmp -$ open/read raw_vector g.tmp -$ open/write case_vector 'p2' -$ RAWLOOP: -$ read/end=end_rawloop raw_vector raw_element -$ write case_vector raw_element -$ if f$locate("=PROCEDURE)",raw_element) .lt. f$length(raw_element) -$ then -$ name = f$element(1,"=",raw_element) - "(" -$ if f$edit(name,"UPCASE") .nes. name then - - write case_vector f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)", - - f$edit(name,"UPCASE"), name) -$ endif -$ if f$locate("=DATA)",raw_element) .lt. f$length(raw_element) -$ then -$ name = f$element(1,"=",raw_element) - "(" -$ if f$edit(name,"UPCASE") .nes. name then - - write case_vector f$fao(" symbol_vector=(!AS/!AS=DATA)", - - f$edit(name,"UPCASE"), name) -$ endif -$ goto rawloop -$ END_RAWLOOP: -$ close raw_vector -$ close case_vector -$ delete a.tmp;*,b.tmp;*,c.tmp;*,d.tmp;*,e.tmp;*,f.tmp;*,g.tmp;* -$ if f$search("x.tmp") .nes. "" - - then $ delete x.tmp;* -$! -$ EXIT_AA: -$ if V then set verify -$ endsubroutine -$!------------------------------------------------------------------------------ -$! $! Write configuration to both permanent and temporary config file $! $! Version history @@ -802,3 +715,153 @@ $ write confh 'p1' $ close confh $ENDSUBROUTINE $!------------------------------------------------------------------------------ +$! +$! Analyze the project map file and create the symbol vector for a shareable +$! image from it +$! +$! Version history +$! 0.01 20120128 First version +$! 0.02 20120226 Add pre-load logic +$! +$ MAP_2_SHOPT: Subroutine +$! +$ SAY := "WRITE_ SYS$OUTPUT" +$! +$ IF F$SEARCH("''P1'") .EQS. "" +$ THEN +$ SAY "MAP_2_SHOPT-E-NOSUCHFILE: Error, inputfile ''p1' not available" +$ goto exit_m2s +$ ENDIF +$ IF "''P2'" .EQS. "" +$ THEN +$ SAY "MAP_2_SHOPT: Error, no output file provided" +$ goto exit_m2s +$ ENDIF +$! +$ module1 = "deflate#deflateEnd#deflateInit_#deflateParams#deflateSetDictionary" +$ module2 = "gzclose#gzerror#gzgetc#gzgets#gzopen#gzprintf#gzputc#gzputs#gzread" +$ module3 = "gzseek#gztell#inflate#inflateEnd#inflateInit_#inflateSetDictionary" +$ module4 = "inflateSync#uncompress#zlibVersion#compress" +$ open/read map 'p1 +$ if axp .or. ia64 +$ then +$ open/write aopt a.opt +$ open/write bopt b.opt +$ write aopt " CASE_SENSITIVE=YES" +$ write bopt "SYMBOL_VECTOR= (-" +$ mod_sym_num = 1 +$ MOD_SYM_LOOP: +$ if f$type(module'mod_sym_num') .nes. "" +$ then +$ mod_in = 0 +$ MOD_SYM_IN: +$ shared_proc = f$element(mod_in, "#", module'mod_sym_num') +$ if shared_proc .nes. "#" +$ then +$ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",- + f$edit(shared_proc,"upcase"),shared_proc) +$ write bopt f$fao("!AS=PROCEDURE,-",shared_proc) +$ mod_in = mod_in + 1 +$ goto mod_sym_in +$ endif +$ mod_sym_num = mod_sym_num + 1 +$ goto mod_sym_loop +$ endif +$MAP_LOOP: +$ read/end=map_end map line +$ if (f$locate("{",line).lt. f$length(line)) .or. - + (f$locate("global:", line) .lt. f$length(line)) +$ then +$ proc = true +$ goto map_loop +$ endif +$ if f$locate("}",line).lt. f$length(line) then proc = false +$ if f$locate("local:", line) .lt. f$length(line) then proc = false +$ if proc +$ then +$ shared_proc = f$edit(line,"collapse") +$ chop_semi = f$locate(";", shared_proc) +$ if chop_semi .lt. f$length(shared_proc) then - + shared_proc = f$extract(0, chop_semi, shared_proc) +$ write aopt f$fao(" symbol_vector=(!AS/!AS=PROCEDURE)",- + f$edit(shared_proc,"upcase"),shared_proc) +$ write bopt f$fao("!AS=PROCEDURE,-",shared_proc) +$ endif +$ goto map_loop +$MAP_END: +$ close/nolog aopt +$ close/nolog bopt +$ open/append libopt 'p2' +$ open/read aopt a.opt +$ open/read bopt b.opt +$ALOOP: +$ read/end=aloop_end aopt line +$ write libopt line +$ goto aloop +$ALOOP_END: +$ close/nolog aopt +$ sv = "" +$BLOOP: +$ read/end=bloop_end bopt svn +$ if (svn.nes."") +$ then +$ if (sv.nes."") then write libopt sv +$ sv = svn +$ endif +$ goto bloop +$BLOOP_END: +$ write libopt f$extract(0,f$length(sv)-2,sv), "-" +$ write libopt ")" +$ close/nolog bopt +$ delete/nolog/noconf a.opt;*,b.opt;* +$ else +$ if vax +$ then +$ open/append libopt 'p2' +$ mod_sym_num = 1 +$ VMOD_SYM_LOOP: +$ if f$type(module'mod_sym_num') .nes. "" +$ then +$ mod_in = 0 +$ VMOD_SYM_IN: +$ shared_proc = f$element(mod_in, "#", module'mod_sym_num') +$ if shared_proc .nes. "#" +$ then +$ write libopt f$fao("UNIVERSAL=!AS",- + f$edit(shared_proc,"upcase")) +$ mod_in = mod_in + 1 +$ goto vmod_sym_in +$ endif +$ mod_sym_num = mod_sym_num + 1 +$ goto vmod_sym_loop +$ endif +$VMAP_LOOP: +$ read/end=vmap_end map line +$ if (f$locate("{",line).lt. f$length(line)) .or. - + (f$locate("global:", line) .lt. f$length(line)) +$ then +$ proc = true +$ goto vmap_loop +$ endif +$ if f$locate("}",line).lt. f$length(line) then proc = false +$ if f$locate("local:", line) .lt. f$length(line) then proc = false +$ if proc +$ then +$ shared_proc = f$edit(line,"collapse") +$ chop_semi = f$locate(";", shared_proc) +$ if chop_semi .lt. f$length(shared_proc) then - + shared_proc = f$extract(0, chop_semi, shared_proc) +$ write libopt f$fao("UNIVERSAL=!AS",- + f$edit(shared_proc,"upcase")) +$ endif +$ goto vmap_loop +$VMAP_END: +$ else +$ write sys$output "Unknown Architecture (Not VAX, AXP, or IA64)" +$ write sys$output "No options file created" +$ endif +$ endif +$ EXIT_M2S: +$ close/nolog map +$ close/nolog libopt +$ endsubroutine diff --git a/libs/zlib/msdos/Makefile.bor b/libs/zlib/msdos/Makefile.bor index 0c1b99c9b..3d12a2c25 100644 --- a/libs/zlib/msdos/Makefile.bor +++ b/libs/zlib/msdos/Makefile.bor @@ -86,9 +86,9 @@ uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h -example.obj: example.c zlib.h zconf.h +example.obj: test/example.c zlib.h zconf.h -minigzip.obj: minigzip.c zlib.h zconf.h +minigzip.obj: test/minigzip.c zlib.h zconf.h # the command line is cut to fit in the MS-DOS 128 byte limit: diff --git a/libs/zlib/msdos/Makefile.dj2 b/libs/zlib/msdos/Makefile.dj2 index 29b03954d..59d2037d6 100644 --- a/libs/zlib/msdos/Makefile.dj2 +++ b/libs/zlib/msdos/Makefile.dj2 @@ -29,7 +29,7 @@ CC=gcc #CFLAGS=-MMD -O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG +#CFLAGS=-MMD -g -DZLIB_DEBUG CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -Wstrict-prototypes -Wmissing-prototypes diff --git a/libs/zlib/msdos/Makefile.emx b/libs/zlib/msdos/Makefile.emx index 9c1b57a58..e30f67bed 100644 --- a/libs/zlib/msdos/Makefile.emx +++ b/libs/zlib/msdos/Makefile.emx @@ -11,7 +11,7 @@ CC=gcc #CFLAGS=-MMD -O #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-MMD -g -DDEBUG +#CFLAGS=-MMD -g -DZLIB_DEBUG CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ -Wstrict-prototypes -Wmissing-prototypes diff --git a/libs/zlib/msdos/Makefile.msc b/libs/zlib/msdos/Makefile.msc index cd2816fbf..ae8378615 100644 --- a/libs/zlib/msdos/Makefile.msc +++ b/libs/zlib/msdos/Makefile.msc @@ -80,10 +80,10 @@ uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h -example.obj: example.c zlib.h zconf.h +example.obj: test/example.c zlib.h zconf.h $(CC) -c $(CFLAGS) $*.c -minigzip.obj: minigzip.c zlib.h zconf.h +minigzip.obj: test/minigzip.c zlib.h zconf.h $(CC) -c $(CFLAGS) $*.c diff --git a/libs/zlib/msdos/Makefile.tc b/libs/zlib/msdos/Makefile.tc index bcd0d1889..5aec82a9d 100644 --- a/libs/zlib/msdos/Makefile.tc +++ b/libs/zlib/msdos/Makefile.tc @@ -71,9 +71,9 @@ uncompr.obj: uncompr.c zlib.h zconf.h zutil.obj: zutil.c zutil.h zlib.h zconf.h -example.obj: example.c zlib.h zconf.h +example.obj: test/example.c zlib.h zconf.h -minigzip.obj: minigzip.c zlib.h zconf.h +minigzip.obj: test/minigzip.c zlib.h zconf.h # the command line is cut to fit in the MS-DOS 128 byte limit: diff --git a/libs/zlib/old/Makefile.emx b/libs/zlib/old/Makefile.emx new file mode 100644 index 000000000..612b03791 --- /dev/null +++ b/libs/zlib/old/Makefile.emx @@ -0,0 +1,69 @@ +# Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. +# Copyright (C) 1995-1998 Jean-loup Gailly. +# For conditions of distribution and use, see copyright notice in zlib.h + +# To compile, or to compile and test, type: +# +# make -fmakefile.emx; make test -fmakefile.emx +# + +CC=gcc -Zwin32 + +#CFLAGS=-MMD -O +#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 +#CFLAGS=-MMD -g -DZLIB_DEBUG +CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ + -Wstrict-prototypes -Wmissing-prototypes + +# If cp.exe is available, replace "copy /Y" with "cp -fp" . +CP=copy /Y +# If gnu install.exe is available, replace $(CP) with ginstall. +INSTALL=$(CP) +# The default value of RM is "rm -f." If "rm.exe" is found, comment out: +RM=del +LDLIBS=-L. -lzlib +LD=$(CC) -s -o +LDSHARED=$(CC) + +INCL=zlib.h zconf.h +LIBS=zlib.a + +AR=ar rcs + +prefix=/usr/local +exec_prefix = $(prefix) + +OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ + gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o + +TEST_OBJS = example.o minigzip.o + +all: example.exe minigzip.exe + +test: all + ./example + echo hello world | .\minigzip | .\minigzip -d + +%.o : %.c + $(CC) $(CFLAGS) -c $< -o $@ + +zlib.a: $(OBJS) + $(AR) $@ $(OBJS) + +%.exe : %.o $(LIBS) + $(LD) $@ $< $(LDLIBS) + + +.PHONY : clean + +clean: + $(RM) *.d + $(RM) *.o + $(RM) *.exe + $(RM) zlib.a + $(RM) foo.gz + +DEPS := $(wildcard *.d) +ifneq ($(DEPS),) +include $(DEPS) +endif diff --git a/libs/zlib/old/os2/Makefile.os2 b/libs/zlib/old/os2/Makefile.os2 index a105aaa5b..bb426c0d8 100644 --- a/libs/zlib/old/os2/Makefile.os2 +++ b/libs/zlib/old/os2/Makefile.os2 @@ -14,7 +14,7 @@ CC=gcc -Zomf -s CFLAGS=-O6 -Wall #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 -#CFLAGS=-g -DDEBUG +#CFLAGS=-g -DZLIB_DEBUG #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ # -Wstrict-prototypes -Wmissing-prototypes diff --git a/libs/zlib/os400/README400 b/libs/zlib/os400/README400 new file mode 100644 index 000000000..4f98334f5 --- /dev/null +++ b/libs/zlib/os400/README400 @@ -0,0 +1,48 @@ + ZLIB version 1.2.11 for OS/400 installation instructions + +1) Download and unpack the zlib tarball to some IFS directory. + (i.e.: /path/to/the/zlib/ifs/source/directory) + + If the installed IFS command suppors gzip format, this is straightforward, +else you have to unpack first to some directory on a system supporting it, +then move the whole directory to the IFS via the network (via SMB or FTP). + +2) Edit the configuration parameters in the compilation script. + + EDTF STMF('/path/to/the/zlib/ifs/source/directory/os400/make.sh') + +Tune the parameters according to your needs if not matching the defaults. +Save the file and exit after edition. + +3) Enter qshell, then work in the zlib OS/400 specific directory. + + QSH + cd /path/to/the/zlib/ifs/source/directory/os400 + +4) Compile and install + + sh make.sh + +The script will: +- create the libraries, objects and IFS directories for the zlib environment, +- compile all modules, +- create a service program, +- create a static and a dynamic binding directory, +- install header files for C/C++ and for ILE/RPG, both for compilation in + DB2 and IFS environments. + +That's all. + + +Notes: For OS/400 ILE RPG programmers, a /copy member defining the ZLIB + API prototypes for ILE RPG can be found in ZLIB/H(ZLIB.INC). + In the ILE environment, the same definitions are available from + file zlib.inc located in the same IFS include directory as the + C/C++ header files. + Please read comments in this member for more information. + + Remember that most foreign textual data are ASCII coded: this + implementation does not handle conversion from/to ASCII, so + text data code conversions must be done explicitely. + + Mainly for the reason above, always open zipped files in binary mode. diff --git a/libs/zlib/os400/bndsrc b/libs/zlib/os400/bndsrc new file mode 100644 index 000000000..5e6e0a2f0 --- /dev/null +++ b/libs/zlib/os400/bndsrc @@ -0,0 +1,119 @@ +STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB') + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.1.3 entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("adler32") + EXPORT SYMBOL("compress") + EXPORT SYMBOL("compress2") + EXPORT SYMBOL("crc32") + EXPORT SYMBOL("get_crc_table") + EXPORT SYMBOL("deflate") + EXPORT SYMBOL("deflateEnd") + EXPORT SYMBOL("deflateSetDictionary") + EXPORT SYMBOL("deflateCopy") + EXPORT SYMBOL("deflateReset") + EXPORT SYMBOL("deflateParams") + EXPORT SYMBOL("deflatePrime") + EXPORT SYMBOL("deflateInit_") + EXPORT SYMBOL("deflateInit2_") + EXPORT SYMBOL("gzopen") + EXPORT SYMBOL("gzdopen") + EXPORT SYMBOL("gzsetparams") + EXPORT SYMBOL("gzread") + EXPORT SYMBOL("gzwrite") + EXPORT SYMBOL("gzprintf") + EXPORT SYMBOL("gzputs") + EXPORT SYMBOL("gzgets") + EXPORT SYMBOL("gzputc") + EXPORT SYMBOL("gzgetc") + EXPORT SYMBOL("gzflush") + EXPORT SYMBOL("gzseek") + EXPORT SYMBOL("gzrewind") + EXPORT SYMBOL("gztell") + EXPORT SYMBOL("gzeof") + EXPORT SYMBOL("gzclose") + EXPORT SYMBOL("gzerror") + EXPORT SYMBOL("inflate") + EXPORT SYMBOL("inflateEnd") + EXPORT SYMBOL("inflateSetDictionary") + EXPORT SYMBOL("inflateSync") + EXPORT SYMBOL("inflateReset") + EXPORT SYMBOL("inflateInit_") + EXPORT SYMBOL("inflateInit2_") + EXPORT SYMBOL("inflateSyncPoint") + EXPORT SYMBOL("uncompress") + EXPORT SYMBOL("zlibVersion") + EXPORT SYMBOL("zError") + EXPORT SYMBOL("z_errmsg") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.1 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("compressBound") + EXPORT SYMBOL("deflateBound") + EXPORT SYMBOL("deflatePending") + EXPORT SYMBOL("gzungetc") + EXPORT SYMBOL("gzclearerr") + EXPORT SYMBOL("inflateBack") + EXPORT SYMBOL("inflateBackEnd") + EXPORT SYMBOL("inflateBackInit_") + EXPORT SYMBOL("inflateCopy") + EXPORT SYMBOL("zlibCompileFlags") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.4 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("adler32_combine") + EXPORT SYMBOL("adler32_combine64") + EXPORT SYMBOL("crc32_combine") + EXPORT SYMBOL("crc32_combine64") + EXPORT SYMBOL("deflateSetHeader") + EXPORT SYMBOL("deflateTune") + EXPORT SYMBOL("gzbuffer") + EXPORT SYMBOL("gzclose_r") + EXPORT SYMBOL("gzclose_w") + EXPORT SYMBOL("gzdirect") + EXPORT SYMBOL("gzoffset") + EXPORT SYMBOL("gzoffset64") + EXPORT SYMBOL("gzopen64") + EXPORT SYMBOL("gzseek64") + EXPORT SYMBOL("gztell64") + EXPORT SYMBOL("inflateGetHeader") + EXPORT SYMBOL("inflateMark") + EXPORT SYMBOL("inflatePrime") + EXPORT SYMBOL("inflateReset2") + EXPORT SYMBOL("inflateUndermine") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.6 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("deflateResetKeep") + EXPORT SYMBOL("gzgetc_") + EXPORT SYMBOL("inflateResetKeep") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.8 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("gzvprintf") + EXPORT SYMBOL("inflateGetDictionary") + +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ +/* Version 1.2.9 additional entry points. */ +/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ + + EXPORT SYMBOL("adler32_z") + EXPORT SYMBOL("crc32_z") + EXPORT SYMBOL("deflateGetDictionary") + EXPORT SYMBOL("gzfread") + EXPORT SYMBOL("gzfwrite") + EXPORT SYMBOL("inflateCodesUsed") + EXPORT SYMBOL("inflateValidate") + EXPORT SYMBOL("uncompress2") + +ENDPGMEXP diff --git a/libs/zlib/os400/make.sh b/libs/zlib/os400/make.sh new file mode 100644 index 000000000..19eec117a --- /dev/null +++ b/libs/zlib/os400/make.sh @@ -0,0 +1,366 @@ +#!/bin/sh +# +# ZLIB compilation script for the OS/400. +# +# +# This is a shell script since make is not a standard component of OS/400. + + +################################################################################ +# +# Tunable configuration parameters. +# +################################################################################ + +TARGETLIB='ZLIB' # Target OS/400 program library +STATBNDDIR='ZLIB_A' # Static binding directory. +DYNBNDDIR='ZLIB' # Dynamic binding directory. +SRVPGM="ZLIB" # Service program. +IFSDIR='/zlib' # IFS support base directory. +TGTCCSID='500' # Target CCSID of objects +DEBUG='*NONE' # Debug level +OPTIMIZE='40' # Optimisation level +OUTPUT='*NONE' # Compilation output option. +TGTRLS='V6R1M0' # Target OS release + +export TARGETLIB STATBNDDIR DYNBNDDIR SRVPGM IFSDIR +export TGTCCSID DEBUG OPTIMIZE OUTPUT TGTRLS + + +################################################################################ +# +# OS/400 specific definitions. +# +################################################################################ + +LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB" + + +################################################################################ +# +# Procedures. +# +################################################################################ + +# action_needed dest [src] +# +# dest is an object to build +# if specified, src is an object on which dest depends. +# +# exit 0 (succeeds) if some action has to be taken, else 1. + +action_needed() + +{ + [ ! -e "${1}" ] && return 0 + [ "${2}" ] || return 1 + [ "${1}" -ot "${2}" ] && return 0 + return 1 +} + + +# make_module module_name source_name [additional_definitions] +# +# Compile source name into module if needed. +# As side effect, append the module name to variable MODULES. +# Set LINK to "YES" if the module has been compiled. + +make_module() + +{ + MODULES="${MODULES} ${1}" + MODIFSNAME="${LIBIFSNAME}/${1}.MODULE" + CSRC="`basename \"${2}\"`" + + if action_needed "${MODIFSNAME}" "${2}" + then : + elif [ ! "`sed -e \"//,/<\\\\/source>/!d\" \ + -e '/ tmphdrfile + + # Need to translate to target CCSID. + + CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DEST}')" + CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" + system "${CMD}" + # touch -r "${HFILE}" "${DEST}" + rm -f tmphdrfile + fi + + IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" + + if action_needed "${IFSFILE}" "${DEST}" + then rm -f "${IFSFILE}" + ln -s "${DEST}" "${IFSFILE}" + fi +done + + +# Install the ILE/RPG header file. + + +HFILE="${SCRIPTDIR}/zlib.inc" +DEST="${SRCPF}/ZLIB.INC.MBR" + +if action_needed "${DEST}" "${HFILE}" +then CMD="CPY OBJ('${HFILE}') TOOBJ('${DEST}')" + CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)" + system "${CMD}" + # touch -r "${HFILE}" "${DEST}" +fi + +IFSFILE="${IFSDIR}/include/`basename \"${HFILE}\"`" + +if action_needed "${IFSFILE}" "${DEST}" +then rm -f "${IFSFILE}" + ln -s "${DEST}" "${IFSFILE}" +fi + + +# Create and compile the identification source file. + +echo '#pragma comment(user, "ZLIB version '"${VERSION}"'")' > os400.c +echo '#pragma comment(user, __DATE__)' >> os400.c +echo '#pragma comment(user, __TIME__)' >> os400.c +echo '#pragma comment(copyright, "Copyright (C) 1995-2017 Jean-Loup Gailly, Mark Adler. OS/400 version by P. Monnerat.")' >> os400.c +make_module OS400 os400.c +LINK= # No need to rebuild service program yet. +MODULES= + + +# Get source list. + +CSOURCES=`sed -e '/ Disabled - WIN32;_DEBUG;ASMV;ASMINF;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) true Default MultiThreadedDebugDLL @@ -267,7 +267,7 @@ MaxSpeed OnlyExplicitInline - WIN32;NDEBUG;ASMV;ASMINF;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;%(PreprocessorDefinitions) true MultiThreadedDLL true @@ -570,6 +570,8 @@ true true true + true + true true @@ -578,6 +580,8 @@ true true true + true + true true diff --git a/libs/zlib/qnx/package.qpg b/libs/zlib/qnx/package.qpg index 2bc63b21a..31e8e90db 100644 --- a/libs/zlib/qnx/package.qpg +++ b/libs/zlib/qnx/package.qpg @@ -25,10 +25,10 @@ - - - - + + + + @@ -63,7 +63,7 @@ - 1.2.5 + 1.2.11 Medium Stable diff --git a/libs/zlib/test/example.c b/libs/zlib/test/example.c new file mode 100644 index 000000000..eee17ce7c --- /dev/null +++ b/libs/zlib/test/example.c @@ -0,0 +1,602 @@ +/* example.c -- usage example of the zlib compression library + * Copyright (C) 1995-2006, 2011, 2016 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#include "zlib.h" +#include + +#ifdef STDC +# include +# include +#endif + +#if defined(VMS) || defined(RISCOS) +# define TESTFILE "foo-gz" +#else +# define TESTFILE "foo.gz" +#endif + +#define CHECK_ERR(err, msg) { \ + if (err != Z_OK) { \ + fprintf(stderr, "%s error: %d\n", msg, err); \ + exit(1); \ + } \ +} + +static z_const char hello[] = "hello, hello!"; +/* "hello world" would be more standard, but the repeated "hello" + * stresses the compression code better, sorry... + */ + +static const char dictionary[] = "hello"; +static uLong dictId; /* Adler32 value of the dictionary */ + +void test_deflate OF((Byte *compr, uLong comprLen)); +void test_inflate OF((Byte *compr, uLong comprLen, + Byte *uncompr, uLong uncomprLen)); +void test_large_deflate OF((Byte *compr, uLong comprLen, + Byte *uncompr, uLong uncomprLen)); +void test_large_inflate OF((Byte *compr, uLong comprLen, + Byte *uncompr, uLong uncomprLen)); +void test_flush OF((Byte *compr, uLong *comprLen)); +void test_sync OF((Byte *compr, uLong comprLen, + Byte *uncompr, uLong uncomprLen)); +void test_dict_deflate OF((Byte *compr, uLong comprLen)); +void test_dict_inflate OF((Byte *compr, uLong comprLen, + Byte *uncompr, uLong uncomprLen)); +int main OF((int argc, char *argv[])); + + +#ifdef Z_SOLO + +void *myalloc OF((void *, unsigned, unsigned)); +void myfree OF((void *, void *)); + +void *myalloc(q, n, m) + void *q; + unsigned n, m; +{ + (void)q; + return calloc(n, m); +} + +void myfree(void *q, void *p) +{ + (void)q; + free(p); +} + +static alloc_func zalloc = myalloc; +static free_func zfree = myfree; + +#else /* !Z_SOLO */ + +static alloc_func zalloc = (alloc_func)0; +static free_func zfree = (free_func)0; + +void test_compress OF((Byte *compr, uLong comprLen, + Byte *uncompr, uLong uncomprLen)); +void test_gzio OF((const char *fname, + Byte *uncompr, uLong uncomprLen)); + +/* =========================================================================== + * Test compress() and uncompress() + */ +void test_compress(compr, comprLen, uncompr, uncomprLen) + Byte *compr, *uncompr; + uLong comprLen, uncomprLen; +{ + int err; + uLong len = (uLong)strlen(hello)+1; + + err = compress(compr, &comprLen, (const Bytef*)hello, len); + CHECK_ERR(err, "compress"); + + strcpy((char*)uncompr, "garbage"); + + err = uncompress(uncompr, &uncomprLen, compr, comprLen); + CHECK_ERR(err, "uncompress"); + + if (strcmp((char*)uncompr, hello)) { + fprintf(stderr, "bad uncompress\n"); + exit(1); + } else { + printf("uncompress(): %s\n", (char *)uncompr); + } +} + +/* =========================================================================== + * Test read/write of .gz files + */ +void test_gzio(fname, uncompr, uncomprLen) + const char *fname; /* compressed file name */ + Byte *uncompr; + uLong uncomprLen; +{ +#ifdef NO_GZCOMPRESS + fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); +#else + int err; + int len = (int)strlen(hello)+1; + gzFile file; + z_off_t pos; + + file = gzopen(fname, "wb"); + if (file == NULL) { + fprintf(stderr, "gzopen error\n"); + exit(1); + } + gzputc(file, 'h'); + if (gzputs(file, "ello") != 4) { + fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); + exit(1); + } + if (gzprintf(file, ", %s!", "hello") != 8) { + fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); + exit(1); + } + gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ + gzclose(file); + + file = gzopen(fname, "rb"); + if (file == NULL) { + fprintf(stderr, "gzopen error\n"); + exit(1); + } + strcpy((char*)uncompr, "garbage"); + + if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { + fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); + exit(1); + } + if (strcmp((char*)uncompr, hello)) { + fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); + exit(1); + } else { + printf("gzread(): %s\n", (char*)uncompr); + } + + pos = gzseek(file, -8L, SEEK_CUR); + if (pos != 6 || gztell(file) != pos) { + fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", + (long)pos, (long)gztell(file)); + exit(1); + } + + if (gzgetc(file) != ' ') { + fprintf(stderr, "gzgetc error\n"); + exit(1); + } + + if (gzungetc(' ', file) != ' ') { + fprintf(stderr, "gzungetc error\n"); + exit(1); + } + + gzgets(file, (char*)uncompr, (int)uncomprLen); + if (strlen((char*)uncompr) != 7) { /* " hello!" */ + fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); + exit(1); + } + if (strcmp((char*)uncompr, hello + 6)) { + fprintf(stderr, "bad gzgets after gzseek\n"); + exit(1); + } else { + printf("gzgets() after gzseek: %s\n", (char*)uncompr); + } + + gzclose(file); +#endif +} + +#endif /* Z_SOLO */ + +/* =========================================================================== + * Test deflate() with small buffers + */ +void test_deflate(compr, comprLen) + Byte *compr; + uLong comprLen; +{ + z_stream c_stream; /* compression stream */ + int err; + uLong len = (uLong)strlen(hello)+1; + + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (voidpf)0; + + err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, "deflateInit"); + + c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_out = compr; + + while (c_stream.total_in != len && c_stream.total_out < comprLen) { + c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ + err = deflate(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate"); + } + /* Finish the stream, still forcing small buffers: */ + for (;;) { + c_stream.avail_out = 1; + err = deflate(&c_stream, Z_FINISH); + if (err == Z_STREAM_END) break; + CHECK_ERR(err, "deflate"); + } + + err = deflateEnd(&c_stream); + CHECK_ERR(err, "deflateEnd"); +} + +/* =========================================================================== + * Test inflate() with small buffers + */ +void test_inflate(compr, comprLen, uncompr, uncomprLen) + Byte *compr, *uncompr; + uLong comprLen, uncomprLen; +{ + int err; + z_stream d_stream; /* decompression stream */ + + strcpy((char*)uncompr, "garbage"); + + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (voidpf)0; + + d_stream.next_in = compr; + d_stream.avail_in = 0; + d_stream.next_out = uncompr; + + err = inflateInit(&d_stream); + CHECK_ERR(err, "inflateInit"); + + while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { + d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ + err = inflate(&d_stream, Z_NO_FLUSH); + if (err == Z_STREAM_END) break; + CHECK_ERR(err, "inflate"); + } + + err = inflateEnd(&d_stream); + CHECK_ERR(err, "inflateEnd"); + + if (strcmp((char*)uncompr, hello)) { + fprintf(stderr, "bad inflate\n"); + exit(1); + } else { + printf("inflate(): %s\n", (char *)uncompr); + } +} + +/* =========================================================================== + * Test deflate() with large buffers and dynamic change of compression level + */ +void test_large_deflate(compr, comprLen, uncompr, uncomprLen) + Byte *compr, *uncompr; + uLong comprLen, uncomprLen; +{ + z_stream c_stream; /* compression stream */ + int err; + + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (voidpf)0; + + err = deflateInit(&c_stream, Z_BEST_SPEED); + CHECK_ERR(err, "deflateInit"); + + c_stream.next_out = compr; + c_stream.avail_out = (uInt)comprLen; + + /* At this point, uncompr is still mostly zeroes, so it should compress + * very well: + */ + c_stream.next_in = uncompr; + c_stream.avail_in = (uInt)uncomprLen; + err = deflate(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate"); + if (c_stream.avail_in != 0) { + fprintf(stderr, "deflate not greedy\n"); + exit(1); + } + + /* Feed in already compressed data and switch to no compression: */ + deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); + c_stream.next_in = compr; + c_stream.avail_in = (uInt)comprLen/2; + err = deflate(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate"); + + /* Switch back to compressing mode: */ + deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); + c_stream.next_in = uncompr; + c_stream.avail_in = (uInt)uncomprLen; + err = deflate(&c_stream, Z_NO_FLUSH); + CHECK_ERR(err, "deflate"); + + err = deflate(&c_stream, Z_FINISH); + if (err != Z_STREAM_END) { + fprintf(stderr, "deflate should report Z_STREAM_END\n"); + exit(1); + } + err = deflateEnd(&c_stream); + CHECK_ERR(err, "deflateEnd"); +} + +/* =========================================================================== + * Test inflate() with large buffers + */ +void test_large_inflate(compr, comprLen, uncompr, uncomprLen) + Byte *compr, *uncompr; + uLong comprLen, uncomprLen; +{ + int err; + z_stream d_stream; /* decompression stream */ + + strcpy((char*)uncompr, "garbage"); + + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (voidpf)0; + + d_stream.next_in = compr; + d_stream.avail_in = (uInt)comprLen; + + err = inflateInit(&d_stream); + CHECK_ERR(err, "inflateInit"); + + for (;;) { + d_stream.next_out = uncompr; /* discard the output */ + d_stream.avail_out = (uInt)uncomprLen; + err = inflate(&d_stream, Z_NO_FLUSH); + if (err == Z_STREAM_END) break; + CHECK_ERR(err, "large inflate"); + } + + err = inflateEnd(&d_stream); + CHECK_ERR(err, "inflateEnd"); + + if (d_stream.total_out != 2*uncomprLen + comprLen/2) { + fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); + exit(1); + } else { + printf("large_inflate(): OK\n"); + } +} + +/* =========================================================================== + * Test deflate() with full flush + */ +void test_flush(compr, comprLen) + Byte *compr; + uLong *comprLen; +{ + z_stream c_stream; /* compression stream */ + int err; + uInt len = (uInt)strlen(hello)+1; + + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (voidpf)0; + + err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); + CHECK_ERR(err, "deflateInit"); + + c_stream.next_in = (z_const unsigned char *)hello; + c_stream.next_out = compr; + c_stream.avail_in = 3; + c_stream.avail_out = (uInt)*comprLen; + err = deflate(&c_stream, Z_FULL_FLUSH); + CHECK_ERR(err, "deflate"); + + compr[3]++; /* force an error in first compressed block */ + c_stream.avail_in = len - 3; + + err = deflate(&c_stream, Z_FINISH); + if (err != Z_STREAM_END) { + CHECK_ERR(err, "deflate"); + } + err = deflateEnd(&c_stream); + CHECK_ERR(err, "deflateEnd"); + + *comprLen = c_stream.total_out; +} + +/* =========================================================================== + * Test inflateSync() + */ +void test_sync(compr, comprLen, uncompr, uncomprLen) + Byte *compr, *uncompr; + uLong comprLen, uncomprLen; +{ + int err; + z_stream d_stream; /* decompression stream */ + + strcpy((char*)uncompr, "garbage"); + + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (voidpf)0; + + d_stream.next_in = compr; + d_stream.avail_in = 2; /* just read the zlib header */ + + err = inflateInit(&d_stream); + CHECK_ERR(err, "inflateInit"); + + d_stream.next_out = uncompr; + d_stream.avail_out = (uInt)uncomprLen; + + err = inflate(&d_stream, Z_NO_FLUSH); + CHECK_ERR(err, "inflate"); + + d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ + err = inflateSync(&d_stream); /* but skip the damaged part */ + CHECK_ERR(err, "inflateSync"); + + err = inflate(&d_stream, Z_FINISH); + if (err != Z_DATA_ERROR) { + fprintf(stderr, "inflate should report DATA_ERROR\n"); + /* Because of incorrect adler32 */ + exit(1); + } + err = inflateEnd(&d_stream); + CHECK_ERR(err, "inflateEnd"); + + printf("after inflateSync(): hel%s\n", (char *)uncompr); +} + +/* =========================================================================== + * Test deflate() with preset dictionary + */ +void test_dict_deflate(compr, comprLen) + Byte *compr; + uLong comprLen; +{ + z_stream c_stream; /* compression stream */ + int err; + + c_stream.zalloc = zalloc; + c_stream.zfree = zfree; + c_stream.opaque = (voidpf)0; + + err = deflateInit(&c_stream, Z_BEST_COMPRESSION); + CHECK_ERR(err, "deflateInit"); + + err = deflateSetDictionary(&c_stream, + (const Bytef*)dictionary, (int)sizeof(dictionary)); + CHECK_ERR(err, "deflateSetDictionary"); + + dictId = c_stream.adler; + c_stream.next_out = compr; + c_stream.avail_out = (uInt)comprLen; + + c_stream.next_in = (z_const unsigned char *)hello; + c_stream.avail_in = (uInt)strlen(hello)+1; + + err = deflate(&c_stream, Z_FINISH); + if (err != Z_STREAM_END) { + fprintf(stderr, "deflate should report Z_STREAM_END\n"); + exit(1); + } + err = deflateEnd(&c_stream); + CHECK_ERR(err, "deflateEnd"); +} + +/* =========================================================================== + * Test inflate() with a preset dictionary + */ +void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) + Byte *compr, *uncompr; + uLong comprLen, uncomprLen; +{ + int err; + z_stream d_stream; /* decompression stream */ + + strcpy((char*)uncompr, "garbage"); + + d_stream.zalloc = zalloc; + d_stream.zfree = zfree; + d_stream.opaque = (voidpf)0; + + d_stream.next_in = compr; + d_stream.avail_in = (uInt)comprLen; + + err = inflateInit(&d_stream); + CHECK_ERR(err, "inflateInit"); + + d_stream.next_out = uncompr; + d_stream.avail_out = (uInt)uncomprLen; + + for (;;) { + err = inflate(&d_stream, Z_NO_FLUSH); + if (err == Z_STREAM_END) break; + if (err == Z_NEED_DICT) { + if (d_stream.adler != dictId) { + fprintf(stderr, "unexpected dictionary"); + exit(1); + } + err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, + (int)sizeof(dictionary)); + } + CHECK_ERR(err, "inflate with dict"); + } + + err = inflateEnd(&d_stream); + CHECK_ERR(err, "inflateEnd"); + + if (strcmp((char*)uncompr, hello)) { + fprintf(stderr, "bad inflate with dict\n"); + exit(1); + } else { + printf("inflate with dictionary: %s\n", (char *)uncompr); + } +} + +/* =========================================================================== + * Usage: example [output.gz [input.gz]] + */ + +int main(argc, argv) + int argc; + char *argv[]; +{ + Byte *compr, *uncompr; + uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ + uLong uncomprLen = comprLen; + static const char* myVersion = ZLIB_VERSION; + + if (zlibVersion()[0] != myVersion[0]) { + fprintf(stderr, "incompatible zlib version\n"); + exit(1); + + } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { + fprintf(stderr, "warning: different zlib version\n"); + } + + printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", + ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); + + compr = (Byte*)calloc((uInt)comprLen, 1); + uncompr = (Byte*)calloc((uInt)uncomprLen, 1); + /* compr and uncompr are cleared to avoid reading uninitialized + * data and to ensure that uncompr compresses well. + */ + if (compr == Z_NULL || uncompr == Z_NULL) { + printf("out of memory\n"); + exit(1); + } + +#ifdef Z_SOLO + (void)argc; + (void)argv; +#else + test_compress(compr, comprLen, uncompr, uncomprLen); + + test_gzio((argc > 1 ? argv[1] : TESTFILE), + uncompr, uncomprLen); +#endif + + test_deflate(compr, comprLen); + test_inflate(compr, comprLen, uncompr, uncomprLen); + + test_large_deflate(compr, comprLen, uncompr, uncomprLen); + test_large_inflate(compr, comprLen, uncompr, uncomprLen); + + test_flush(compr, &comprLen); + test_sync(compr, comprLen, uncompr, uncomprLen); + comprLen = uncomprLen; + + test_dict_deflate(compr, comprLen); + test_dict_inflate(compr, comprLen, uncompr, uncomprLen); + + free(compr); + free(uncompr); + + return 0; +} diff --git a/libs/zlib/test/infcover.c b/libs/zlib/test/infcover.c new file mode 100644 index 000000000..2be01646c --- /dev/null +++ b/libs/zlib/test/infcover.c @@ -0,0 +1,671 @@ +/* infcover.c -- test zlib's inflate routines with full code coverage + * Copyright (C) 2011, 2016 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* to use, do: ./configure --cover && make cover */ + +#include +#include +#include +#include +#include "zlib.h" + +/* get definition of internal structure so we can mess with it (see pull()), + and so we can call inflate_trees() (see cover5()) */ +#define ZLIB_INTERNAL +#include "inftrees.h" +#include "inflate.h" + +#define local static + +/* -- memory tracking routines -- */ + +/* + These memory tracking routines are provided to zlib and track all of zlib's + allocations and deallocations, check for LIFO operations, keep a current + and high water mark of total bytes requested, optionally set a limit on the + total memory that can be allocated, and when done check for memory leaks. + + They are used as follows: + + z_stream strm; + mem_setup(&strm) initializes the memory tracking and sets the + zalloc, zfree, and opaque members of strm to use + memory tracking for all zlib operations on strm + mem_limit(&strm, limit) sets a limit on the total bytes requested -- a + request that exceeds this limit will result in an + allocation failure (returns NULL) -- setting the + limit to zero means no limit, which is the default + after mem_setup() + mem_used(&strm, "msg") prints to stderr "msg" and the total bytes used + mem_high(&strm, "msg") prints to stderr "msg" and the high water mark + mem_done(&strm, "msg") ends memory tracking, releases all allocations + for the tracking as well as leaked zlib blocks, if + any. If there was anything unusual, such as leaked + blocks, non-FIFO frees, or frees of addresses not + allocated, then "msg" and information about the + problem is printed to stderr. If everything is + normal, nothing is printed. mem_done resets the + strm members to Z_NULL to use the default memory + allocation routines on the next zlib initialization + using strm. + */ + +/* these items are strung together in a linked list, one for each allocation */ +struct mem_item { + void *ptr; /* pointer to allocated memory */ + size_t size; /* requested size of allocation */ + struct mem_item *next; /* pointer to next item in list, or NULL */ +}; + +/* this structure is at the root of the linked list, and tracks statistics */ +struct mem_zone { + struct mem_item *first; /* pointer to first item in list, or NULL */ + size_t total, highwater; /* total allocations, and largest total */ + size_t limit; /* memory allocation limit, or 0 if no limit */ + int notlifo, rogue; /* counts of non-LIFO frees and rogue frees */ +}; + +/* memory allocation routine to pass to zlib */ +local void *mem_alloc(void *mem, unsigned count, unsigned size) +{ + void *ptr; + struct mem_item *item; + struct mem_zone *zone = mem; + size_t len = count * (size_t)size; + + /* induced allocation failure */ + if (zone == NULL || (zone->limit && zone->total + len > zone->limit)) + return NULL; + + /* perform allocation using the standard library, fill memory with a + non-zero value to make sure that the code isn't depending on zeros */ + ptr = malloc(len); + if (ptr == NULL) + return NULL; + memset(ptr, 0xa5, len); + + /* create a new item for the list */ + item = malloc(sizeof(struct mem_item)); + if (item == NULL) { + free(ptr); + return NULL; + } + item->ptr = ptr; + item->size = len; + + /* insert item at the beginning of the list */ + item->next = zone->first; + zone->first = item; + + /* update the statistics */ + zone->total += item->size; + if (zone->total > zone->highwater) + zone->highwater = zone->total; + + /* return the allocated memory */ + return ptr; +} + +/* memory free routine to pass to zlib */ +local void mem_free(void *mem, void *ptr) +{ + struct mem_item *item, *next; + struct mem_zone *zone = mem; + + /* if no zone, just do a free */ + if (zone == NULL) { + free(ptr); + return; + } + + /* point next to the item that matches ptr, or NULL if not found -- remove + the item from the linked list if found */ + next = zone->first; + if (next) { + if (next->ptr == ptr) + zone->first = next->next; /* first one is it, remove from list */ + else { + do { /* search the linked list */ + item = next; + next = item->next; + } while (next != NULL && next->ptr != ptr); + if (next) { /* if found, remove from linked list */ + item->next = next->next; + zone->notlifo++; /* not a LIFO free */ + } + + } + } + + /* if found, update the statistics and free the item */ + if (next) { + zone->total -= next->size; + free(next); + } + + /* if not found, update the rogue count */ + else + zone->rogue++; + + /* in any case, do the requested free with the standard library function */ + free(ptr); +} + +/* set up a controlled memory allocation space for monitoring, set the stream + parameters to the controlled routines, with opaque pointing to the space */ +local void mem_setup(z_stream *strm) +{ + struct mem_zone *zone; + + zone = malloc(sizeof(struct mem_zone)); + assert(zone != NULL); + zone->first = NULL; + zone->total = 0; + zone->highwater = 0; + zone->limit = 0; + zone->notlifo = 0; + zone->rogue = 0; + strm->opaque = zone; + strm->zalloc = mem_alloc; + strm->zfree = mem_free; +} + +/* set a limit on the total memory allocation, or 0 to remove the limit */ +local void mem_limit(z_stream *strm, size_t limit) +{ + struct mem_zone *zone = strm->opaque; + + zone->limit = limit; +} + +/* show the current total requested allocations in bytes */ +local void mem_used(z_stream *strm, char *prefix) +{ + struct mem_zone *zone = strm->opaque; + + fprintf(stderr, "%s: %lu allocated\n", prefix, zone->total); +} + +/* show the high water allocation in bytes */ +local void mem_high(z_stream *strm, char *prefix) +{ + struct mem_zone *zone = strm->opaque; + + fprintf(stderr, "%s: %lu high water mark\n", prefix, zone->highwater); +} + +/* release the memory allocation zone -- if there are any surprises, notify */ +local void mem_done(z_stream *strm, char *prefix) +{ + int count = 0; + struct mem_item *item, *next; + struct mem_zone *zone = strm->opaque; + + /* show high water mark */ + mem_high(strm, prefix); + + /* free leftover allocations and item structures, if any */ + item = zone->first; + while (item != NULL) { + free(item->ptr); + next = item->next; + free(item); + item = next; + count++; + } + + /* issue alerts about anything unexpected */ + if (count || zone->total) + fprintf(stderr, "** %s: %lu bytes in %d blocks not freed\n", + prefix, zone->total, count); + if (zone->notlifo) + fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo); + if (zone->rogue) + fprintf(stderr, "** %s: %d frees not recognized\n", + prefix, zone->rogue); + + /* free the zone and delete from the stream */ + free(zone); + strm->opaque = Z_NULL; + strm->zalloc = Z_NULL; + strm->zfree = Z_NULL; +} + +/* -- inflate test routines -- */ + +/* Decode a hexadecimal string, set *len to length, in[] to the bytes. This + decodes liberally, in that hex digits can be adjacent, in which case two in + a row writes a byte. Or they can be delimited by any non-hex character, + where the delimiters are ignored except when a single hex digit is followed + by a delimiter, where that single digit writes a byte. The returned data is + allocated and must eventually be freed. NULL is returned if out of memory. + If the length is not needed, then len can be NULL. */ +local unsigned char *h2b(const char *hex, unsigned *len) +{ + unsigned char *in, *re; + unsigned next, val; + + in = malloc((strlen(hex) + 1) >> 1); + if (in == NULL) + return NULL; + next = 0; + val = 1; + do { + if (*hex >= '0' && *hex <= '9') + val = (val << 4) + *hex - '0'; + else if (*hex >= 'A' && *hex <= 'F') + val = (val << 4) + *hex - 'A' + 10; + else if (*hex >= 'a' && *hex <= 'f') + val = (val << 4) + *hex - 'a' + 10; + else if (val != 1 && val < 32) /* one digit followed by delimiter */ + val += 240; /* make it look like two digits */ + if (val > 255) { /* have two digits */ + in[next++] = val & 0xff; /* save the decoded byte */ + val = 1; /* start over */ + } + } while (*hex++); /* go through the loop with the terminating null */ + if (len != NULL) + *len = next; + re = realloc(in, next); + return re == NULL ? in : re; +} + +/* generic inflate() run, where hex is the hexadecimal input data, what is the + text to include in an error message, step is how much input data to feed + inflate() on each call, or zero to feed it all, win is the window bits + parameter to inflateInit2(), len is the size of the output buffer, and err + is the error code expected from the first inflate() call (the second + inflate() call is expected to return Z_STREAM_END). If win is 47, then + header information is collected with inflateGetHeader(). If a zlib stream + is looking for a dictionary, then an empty dictionary is provided. + inflate() is run until all of the input data is consumed. */ +local void inf(char *hex, char *what, unsigned step, int win, unsigned len, + int err) +{ + int ret; + unsigned have; + unsigned char *in, *out; + z_stream strm, copy; + gz_header head; + + mem_setup(&strm); + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit2(&strm, win); + if (ret != Z_OK) { + mem_done(&strm, what); + return; + } + out = malloc(len); assert(out != NULL); + if (win == 47) { + head.extra = out; + head.extra_max = len; + head.name = out; + head.name_max = len; + head.comment = out; + head.comm_max = len; + ret = inflateGetHeader(&strm, &head); assert(ret == Z_OK); + } + in = h2b(hex, &have); assert(in != NULL); + if (step == 0 || step > have) + step = have; + strm.avail_in = step; + have -= step; + strm.next_in = in; + do { + strm.avail_out = len; + strm.next_out = out; + ret = inflate(&strm, Z_NO_FLUSH); assert(err == 9 || ret == err); + if (ret != Z_OK && ret != Z_BUF_ERROR && ret != Z_NEED_DICT) + break; + if (ret == Z_NEED_DICT) { + ret = inflateSetDictionary(&strm, in, 1); + assert(ret == Z_DATA_ERROR); + mem_limit(&strm, 1); + ret = inflateSetDictionary(&strm, out, 0); + assert(ret == Z_MEM_ERROR); + mem_limit(&strm, 0); + ((struct inflate_state *)strm.state)->mode = DICT; + ret = inflateSetDictionary(&strm, out, 0); + assert(ret == Z_OK); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_BUF_ERROR); + } + ret = inflateCopy(©, &strm); assert(ret == Z_OK); + ret = inflateEnd(©); assert(ret == Z_OK); + err = 9; /* don't care next time around */ + have += strm.avail_in; + strm.avail_in = step > have ? have : step; + have -= strm.avail_in; + } while (strm.avail_in); + free(in); + free(out); + ret = inflateReset2(&strm, -8); assert(ret == Z_OK); + ret = inflateEnd(&strm); assert(ret == Z_OK); + mem_done(&strm, what); +} + +/* cover all of the lines in inflate.c up to inflate() */ +local void cover_support(void) +{ + int ret; + z_stream strm; + + mem_setup(&strm); + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit(&strm); assert(ret == Z_OK); + mem_used(&strm, "inflate init"); + ret = inflatePrime(&strm, 5, 31); assert(ret == Z_OK); + ret = inflatePrime(&strm, -1, 0); assert(ret == Z_OK); + ret = inflateSetDictionary(&strm, Z_NULL, 0); + assert(ret == Z_STREAM_ERROR); + ret = inflateEnd(&strm); assert(ret == Z_OK); + mem_done(&strm, "prime"); + + inf("63 0", "force window allocation", 0, -15, 1, Z_OK); + inf("63 18 5", "force window replacement", 0, -8, 259, Z_OK); + inf("63 18 68 30 d0 0 0", "force split window update", 4, -8, 259, Z_OK); + inf("3 0", "use fixed blocks", 0, -15, 1, Z_STREAM_END); + inf("", "bad window size", 0, 1, 0, Z_STREAM_ERROR); + + mem_setup(&strm); + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); + assert(ret == Z_VERSION_ERROR); + mem_done(&strm, "wrong version"); + + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit(&strm); assert(ret == Z_OK); + ret = inflateEnd(&strm); assert(ret == Z_OK); + fputs("inflate built-in memory routines\n", stderr); +} + +/* cover all inflate() header and trailer cases and code after inflate() */ +local void cover_wrap(void) +{ + int ret; + z_stream strm, copy; + unsigned char dict[257]; + + ret = inflate(Z_NULL, 0); assert(ret == Z_STREAM_ERROR); + ret = inflateEnd(Z_NULL); assert(ret == Z_STREAM_ERROR); + ret = inflateCopy(Z_NULL, Z_NULL); assert(ret == Z_STREAM_ERROR); + fputs("inflate bad parameters\n", stderr); + + inf("1f 8b 0 0", "bad gzip method", 0, 31, 0, Z_DATA_ERROR); + inf("1f 8b 8 80", "bad gzip flags", 0, 31, 0, Z_DATA_ERROR); + inf("77 85", "bad zlib method", 0, 15, 0, Z_DATA_ERROR); + inf("8 99", "set window size from header", 0, 0, 0, Z_OK); + inf("78 9c", "bad zlib window size", 0, 8, 0, Z_DATA_ERROR); + inf("78 9c 63 0 0 0 1 0 1", "check adler32", 0, 15, 1, Z_STREAM_END); + inf("1f 8b 8 1e 0 0 0 0 0 0 1 0 0 0 0 0 0", "bad header crc", 0, 47, 1, + Z_DATA_ERROR); + inf("1f 8b 8 2 0 0 0 0 0 0 1d 26 3 0 0 0 0 0 0 0 0 0", "check gzip length", + 0, 47, 0, Z_STREAM_END); + inf("78 90", "bad zlib header check", 0, 47, 0, Z_DATA_ERROR); + inf("8 b8 0 0 0 1", "need dictionary", 0, 8, 0, Z_NEED_DICT); + inf("78 9c 63 0", "compute adler32", 0, 15, 1, Z_OK); + + mem_setup(&strm); + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit2(&strm, -8); + strm.avail_in = 2; + strm.next_in = (void *)"\x63"; + strm.avail_out = 1; + strm.next_out = (void *)&ret; + mem_limit(&strm, 1); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_MEM_ERROR); + mem_limit(&strm, 0); + memset(dict, 0, 257); + ret = inflateSetDictionary(&strm, dict, 257); + assert(ret == Z_OK); + mem_limit(&strm, (sizeof(struct inflate_state) << 1) + 256); + ret = inflatePrime(&strm, 16, 0); assert(ret == Z_OK); + strm.avail_in = 2; + strm.next_in = (void *)"\x80"; + ret = inflateSync(&strm); assert(ret == Z_DATA_ERROR); + ret = inflate(&strm, Z_NO_FLUSH); assert(ret == Z_STREAM_ERROR); + strm.avail_in = 4; + strm.next_in = (void *)"\0\0\xff\xff"; + ret = inflateSync(&strm); assert(ret == Z_OK); + (void)inflateSyncPoint(&strm); + ret = inflateCopy(©, &strm); assert(ret == Z_MEM_ERROR); + mem_limit(&strm, 0); + ret = inflateUndermine(&strm, 1); assert(ret == Z_DATA_ERROR); + (void)inflateMark(&strm); + ret = inflateEnd(&strm); assert(ret == Z_OK); + mem_done(&strm, "miscellaneous, force memory errors"); +} + +/* input and output functions for inflateBack() */ +local unsigned pull(void *desc, unsigned char **buf) +{ + static unsigned int next = 0; + static unsigned char dat[] = {0x63, 0, 2, 0}; + struct inflate_state *state; + + if (desc == Z_NULL) { + next = 0; + return 0; /* no input (already provided at next_in) */ + } + state = (void *)((z_stream *)desc)->state; + if (state != Z_NULL) + state->mode = SYNC; /* force an otherwise impossible situation */ + return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; +} + +local int push(void *desc, unsigned char *buf, unsigned len) +{ + buf += len; + return desc != Z_NULL; /* force error if desc not null */ +} + +/* cover inflateBack() up to common deflate data cases and after those */ +local void cover_back(void) +{ + int ret; + z_stream strm; + unsigned char win[32768]; + + ret = inflateBackInit_(Z_NULL, 0, win, 0, 0); + assert(ret == Z_VERSION_ERROR); + ret = inflateBackInit(Z_NULL, 0, win); assert(ret == Z_STREAM_ERROR); + ret = inflateBack(Z_NULL, Z_NULL, Z_NULL, Z_NULL, Z_NULL); + assert(ret == Z_STREAM_ERROR); + ret = inflateBackEnd(Z_NULL); assert(ret == Z_STREAM_ERROR); + fputs("inflateBack bad parameters\n", stderr); + + mem_setup(&strm); + ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); + strm.avail_in = 2; + strm.next_in = (void *)"\x03"; + ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL); + assert(ret == Z_STREAM_END); + /* force output error */ + strm.avail_in = 3; + strm.next_in = (void *)"\x63\x00"; + ret = inflateBack(&strm, pull, Z_NULL, push, &strm); + assert(ret == Z_BUF_ERROR); + /* force mode error by mucking with state */ + ret = inflateBack(&strm, pull, &strm, push, Z_NULL); + assert(ret == Z_STREAM_ERROR); + ret = inflateBackEnd(&strm); assert(ret == Z_OK); + mem_done(&strm, "inflateBack bad state"); + + ret = inflateBackInit(&strm, 15, win); assert(ret == Z_OK); + ret = inflateBackEnd(&strm); assert(ret == Z_OK); + fputs("inflateBack built-in memory routines\n", stderr); +} + +/* do a raw inflate of data in hexadecimal with both inflate and inflateBack */ +local int try(char *hex, char *id, int err) +{ + int ret; + unsigned len, size; + unsigned char *in, *out, *win; + char *prefix; + z_stream strm; + + /* convert to hex */ + in = h2b(hex, &len); + assert(in != NULL); + + /* allocate work areas */ + size = len << 3; + out = malloc(size); + assert(out != NULL); + win = malloc(32768); + assert(win != NULL); + prefix = malloc(strlen(id) + 6); + assert(prefix != NULL); + + /* first with inflate */ + strcpy(prefix, id); + strcat(prefix, "-late"); + mem_setup(&strm); + strm.avail_in = 0; + strm.next_in = Z_NULL; + ret = inflateInit2(&strm, err < 0 ? 47 : -15); + assert(ret == Z_OK); + strm.avail_in = len; + strm.next_in = in; + do { + strm.avail_out = size; + strm.next_out = out; + ret = inflate(&strm, Z_TREES); + assert(ret != Z_STREAM_ERROR && ret != Z_MEM_ERROR); + if (ret == Z_DATA_ERROR || ret == Z_NEED_DICT) + break; + } while (strm.avail_in || strm.avail_out == 0); + if (err) { + assert(ret == Z_DATA_ERROR); + assert(strcmp(id, strm.msg) == 0); + } + inflateEnd(&strm); + mem_done(&strm, prefix); + + /* then with inflateBack */ + if (err >= 0) { + strcpy(prefix, id); + strcat(prefix, "-back"); + mem_setup(&strm); + ret = inflateBackInit(&strm, 15, win); + assert(ret == Z_OK); + strm.avail_in = len; + strm.next_in = in; + ret = inflateBack(&strm, pull, Z_NULL, push, Z_NULL); + assert(ret != Z_STREAM_ERROR); + if (err) { + assert(ret == Z_DATA_ERROR); + assert(strcmp(id, strm.msg) == 0); + } + inflateBackEnd(&strm); + mem_done(&strm, prefix); + } + + /* clean up */ + free(prefix); + free(win); + free(out); + free(in); + return ret; +} + +/* cover deflate data cases in both inflate() and inflateBack() */ +local void cover_inflate(void) +{ + try("0 0 0 0 0", "invalid stored block lengths", 1); + try("3 0", "fixed", 0); + try("6", "invalid block type", 1); + try("1 1 0 fe ff 0", "stored", 0); + try("fc 0 0", "too many length or distance symbols", 1); + try("4 0 fe ff", "invalid code lengths set", 1); + try("4 0 24 49 0", "invalid bit length repeat", 1); + try("4 0 24 e9 ff ff", "invalid bit length repeat", 1); + try("4 0 24 e9 ff 6d", "invalid code -- missing end-of-block", 1); + try("4 80 49 92 24 49 92 24 71 ff ff 93 11 0", + "invalid literal/lengths set", 1); + try("4 80 49 92 24 49 92 24 f b4 ff ff c3 84", "invalid distances set", 1); + try("4 c0 81 8 0 0 0 0 20 7f eb b 0 0", "invalid literal/length code", 1); + try("2 7e ff ff", "invalid distance code", 1); + try("c c0 81 0 0 0 0 0 90 ff 6b 4 0", "invalid distance too far back", 1); + + /* also trailer mismatch just in inflate() */ + try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 1", "incorrect data check", -1); + try("1f 8b 8 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 1", + "incorrect length check", -1); + try("5 c0 21 d 0 0 0 80 b0 fe 6d 2f 91 6c", "pull 17", 0); + try("5 e0 81 91 24 cb b2 2c 49 e2 f 2e 8b 9a 47 56 9f fb fe ec d2 ff 1f", + "long code", 0); + try("ed c0 1 1 0 0 0 40 20 ff 57 1b 42 2c 4f", "length extra", 0); + try("ed cf c1 b1 2c 47 10 c4 30 fa 6f 35 1d 1 82 59 3d fb be 2e 2a fc f c", + "long distance and extra", 0); + try("ed c0 81 0 0 0 0 80 a0 fd a9 17 a9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 " + "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6", "window end", 0); + inf("2 8 20 80 0 3 0", "inflate_fast TYPE return", 0, -15, 258, + Z_STREAM_END); + inf("63 18 5 40 c 0", "window wrap", 3, -8, 300, Z_OK); +} + +/* cover remaining lines in inftrees.c */ +local void cover_trees(void) +{ + int ret; + unsigned bits; + unsigned short lens[16], work[16]; + code *next, table[ENOUGH_DISTS]; + + /* we need to call inflate_table() directly in order to manifest not- + enough errors, since zlib insures that enough is always enough */ + for (bits = 0; bits < 15; bits++) + lens[bits] = (unsigned short)(bits + 1); + lens[15] = 15; + next = table; + bits = 15; + ret = inflate_table(DISTS, lens, 16, &next, &bits, work); + assert(ret == 1); + next = table; + bits = 1; + ret = inflate_table(DISTS, lens, 16, &next, &bits, work); + assert(ret == 1); + fputs("inflate_table not enough errors\n", stderr); +} + +/* cover remaining inffast.c decoding and window copying */ +local void cover_fast(void) +{ + inf("e5 e0 81 ad 6d cb b2 2c c9 01 1e 59 63 ae 7d ee fb 4d fd b5 35 41 68" + " ff 7f 0f 0 0 0", "fast length extra bits", 0, -8, 258, Z_DATA_ERROR); + inf("25 fd 81 b5 6d 59 b6 6a 49 ea af 35 6 34 eb 8c b9 f6 b9 1e ef 67 49" + " 50 fe ff ff 3f 0 0", "fast distance extra bits", 0, -8, 258, + Z_DATA_ERROR); + inf("3 7e 0 0 0 0 0", "fast invalid distance code", 0, -8, 258, + Z_DATA_ERROR); + inf("1b 7 0 0 0 0 0", "fast invalid literal/length code", 0, -8, 258, + Z_DATA_ERROR); + inf("d c7 1 ae eb 38 c 4 41 a0 87 72 de df fb 1f b8 36 b1 38 5d ff ff 0", + "fast 2nd level codes and too far back", 0, -8, 258, Z_DATA_ERROR); + inf("63 18 5 8c 10 8 0 0 0 0", "very common case", 0, -8, 259, Z_OK); + inf("63 60 60 18 c9 0 8 18 18 18 26 c0 28 0 29 0 0 0", + "contiguous and wrap around window", 6, -8, 259, Z_OK); + inf("63 0 3 0 0 0 0 0", "copy direct from output", 0, -8, 259, + Z_STREAM_END); +} + +int main(void) +{ + fprintf(stderr, "%s\n", zlibVersion()); + cover_support(); + cover_wrap(); + cover_back(); + cover_inflate(); + cover_trees(); + cover_fast(); + return 0; +} diff --git a/libs/zlib/test/minigzip.c b/libs/zlib/test/minigzip.c new file mode 100644 index 000000000..e22fb08c0 --- /dev/null +++ b/libs/zlib/test/minigzip.c @@ -0,0 +1,651 @@ +/* minigzip.c -- simulate gzip using the zlib compression library + * Copyright (C) 1995-2006, 2010, 2011, 2016 Jean-loup Gailly + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* + * minigzip is a minimal implementation of the gzip utility. This is + * only an example of using zlib and isn't meant to replace the + * full-featured gzip. No attempt is made to deal with file systems + * limiting names to 14 or 8+3 characters, etc... Error checking is + * very limited. So use minigzip only for testing; use gzip for the + * real thing. On MSDOS, use only on file names without extension + * or in pipe mode. + */ + +/* @(#) $Id$ */ + +#include "zlib.h" +#include + +#ifdef STDC +# include +# include +#endif + +#ifdef USE_MMAP +# include +# include +# include +#endif + +#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) +# include +# include +# ifdef UNDER_CE +# include +# endif +# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) +#else +# define SET_BINARY_MODE(file) +#endif + +#if defined(_MSC_VER) && _MSC_VER < 1900 +# define snprintf _snprintf +#endif + +#ifdef VMS +# define unlink delete +# define GZ_SUFFIX "-gz" +#endif +#ifdef RISCOS +# define unlink remove +# define GZ_SUFFIX "-gz" +# define fileno(file) file->__file +#endif +#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os +# include /* for fileno */ +#endif + +#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) +#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ + extern int unlink OF((const char *)); +#endif +#endif + +#if defined(UNDER_CE) +# include +# define perror(s) pwinerror(s) + +/* Map the Windows error number in ERROR to a locale-dependent error + message string and return a pointer to it. Typically, the values + for ERROR come from GetLastError. + + The string pointed to shall not be modified by the application, + but may be overwritten by a subsequent call to strwinerror + + The strwinerror function does not change the current setting + of GetLastError. */ + +static char *strwinerror (error) + DWORD error; +{ + static char buf[1024]; + + wchar_t *msgbuf; + DWORD lasterr = GetLastError(); + DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_ALLOCATE_BUFFER, + NULL, + error, + 0, /* Default language */ + (LPVOID)&msgbuf, + 0, + NULL); + if (chars != 0) { + /* If there is an \r\n appended, zap it. */ + if (chars >= 2 + && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { + chars -= 2; + msgbuf[chars] = 0; + } + + if (chars > sizeof (buf) - 1) { + chars = sizeof (buf) - 1; + msgbuf[chars] = 0; + } + + wcstombs(buf, msgbuf, chars + 1); + LocalFree(msgbuf); + } + else { + sprintf(buf, "unknown win32 error (%ld)", error); + } + + SetLastError(lasterr); + return buf; +} + +static void pwinerror (s) + const char *s; +{ + if (s && *s) + fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ())); + else + fprintf(stderr, "%s\n", strwinerror(GetLastError ())); +} + +#endif /* UNDER_CE */ + +#ifndef GZ_SUFFIX +# define GZ_SUFFIX ".gz" +#endif +#define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) + +#define BUFLEN 16384 +#define MAX_NAME_LEN 1024 + +#ifdef MAXSEG_64K +# define local static + /* Needed for systems with limitation on stack size. */ +#else +# define local +#endif + +#ifdef Z_SOLO +/* for Z_SOLO, create simplified gz* functions using deflate and inflate */ + +#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) +# include /* for unlink() */ +#endif + +void *myalloc OF((void *, unsigned, unsigned)); +void myfree OF((void *, void *)); + +void *myalloc(q, n, m) + void *q; + unsigned n, m; +{ + (void)q; + return calloc(n, m); +} + +void myfree(q, p) + void *q, *p; +{ + (void)q; + free(p); +} + +typedef struct gzFile_s { + FILE *file; + int write; + int err; + char *msg; + z_stream strm; +} *gzFile; + +gzFile gzopen OF((const char *, const char *)); +gzFile gzdopen OF((int, const char *)); +gzFile gz_open OF((const char *, int, const char *)); + +gzFile gzopen(path, mode) +const char *path; +const char *mode; +{ + return gz_open(path, -1, mode); +} + +gzFile gzdopen(fd, mode) +int fd; +const char *mode; +{ + return gz_open(NULL, fd, mode); +} + +gzFile gz_open(path, fd, mode) + const char *path; + int fd; + const char *mode; +{ + gzFile gz; + int ret; + + gz = malloc(sizeof(struct gzFile_s)); + if (gz == NULL) + return NULL; + gz->write = strchr(mode, 'w') != NULL; + gz->strm.zalloc = myalloc; + gz->strm.zfree = myfree; + gz->strm.opaque = Z_NULL; + if (gz->write) + ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0); + else { + gz->strm.next_in = 0; + gz->strm.avail_in = Z_NULL; + ret = inflateInit2(&(gz->strm), 15 + 16); + } + if (ret != Z_OK) { + free(gz); + return NULL; + } + gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") : + fopen(path, gz->write ? "wb" : "rb"); + if (gz->file == NULL) { + gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm)); + free(gz); + return NULL; + } + gz->err = 0; + gz->msg = ""; + return gz; +} + +int gzwrite OF((gzFile, const void *, unsigned)); + +int gzwrite(gz, buf, len) + gzFile gz; + const void *buf; + unsigned len; +{ + z_stream *strm; + unsigned char out[BUFLEN]; + + if (gz == NULL || !gz->write) + return 0; + strm = &(gz->strm); + strm->next_in = (void *)buf; + strm->avail_in = len; + do { + strm->next_out = out; + strm->avail_out = BUFLEN; + (void)deflate(strm, Z_NO_FLUSH); + fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); + } while (strm->avail_out == 0); + return len; +} + +int gzread OF((gzFile, void *, unsigned)); + +int gzread(gz, buf, len) + gzFile gz; + void *buf; + unsigned len; +{ + int ret; + unsigned got; + unsigned char in[1]; + z_stream *strm; + + if (gz == NULL || gz->write) + return 0; + if (gz->err) + return 0; + strm = &(gz->strm); + strm->next_out = (void *)buf; + strm->avail_out = len; + do { + got = fread(in, 1, 1, gz->file); + if (got == 0) + break; + strm->next_in = in; + strm->avail_in = 1; + ret = inflate(strm, Z_NO_FLUSH); + if (ret == Z_DATA_ERROR) { + gz->err = Z_DATA_ERROR; + gz->msg = strm->msg; + return 0; + } + if (ret == Z_STREAM_END) + inflateReset(strm); + } while (strm->avail_out); + return len - strm->avail_out; +} + +int gzclose OF((gzFile)); + +int gzclose(gz) + gzFile gz; +{ + z_stream *strm; + unsigned char out[BUFLEN]; + + if (gz == NULL) + return Z_STREAM_ERROR; + strm = &(gz->strm); + if (gz->write) { + strm->next_in = Z_NULL; + strm->avail_in = 0; + do { + strm->next_out = out; + strm->avail_out = BUFLEN; + (void)deflate(strm, Z_FINISH); + fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); + } while (strm->avail_out == 0); + deflateEnd(strm); + } + else + inflateEnd(strm); + fclose(gz->file); + free(gz); + return Z_OK; +} + +const char *gzerror OF((gzFile, int *)); + +const char *gzerror(gz, err) + gzFile gz; + int *err; +{ + *err = gz->err; + return gz->msg; +} + +#endif + +static char *prog; + +void error OF((const char *msg)); +void gz_compress OF((FILE *in, gzFile out)); +#ifdef USE_MMAP +int gz_compress_mmap OF((FILE *in, gzFile out)); +#endif +void gz_uncompress OF((gzFile in, FILE *out)); +void file_compress OF((char *file, char *mode)); +void file_uncompress OF((char *file)); +int main OF((int argc, char *argv[])); + +/* =========================================================================== + * Display error message and exit + */ +void error(msg) + const char *msg; +{ + fprintf(stderr, "%s: %s\n", prog, msg); + exit(1); +} + +/* =========================================================================== + * Compress input to output then close both files. + */ + +void gz_compress(in, out) + FILE *in; + gzFile out; +{ + local char buf[BUFLEN]; + int len; + int err; + +#ifdef USE_MMAP + /* Try first compressing with mmap. If mmap fails (minigzip used in a + * pipe), use the normal fread loop. + */ + if (gz_compress_mmap(in, out) == Z_OK) return; +#endif + for (;;) { + len = (int)fread(buf, 1, sizeof(buf), in); + if (ferror(in)) { + perror("fread"); + exit(1); + } + if (len == 0) break; + + if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); + } + fclose(in); + if (gzclose(out) != Z_OK) error("failed gzclose"); +} + +#ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ + +/* Try compressing the input file at once using mmap. Return Z_OK if + * if success, Z_ERRNO otherwise. + */ +int gz_compress_mmap(in, out) + FILE *in; + gzFile out; +{ + int len; + int err; + int ifd = fileno(in); + caddr_t buf; /* mmap'ed buffer for the entire input file */ + off_t buf_len; /* length of the input file */ + struct stat sb; + + /* Determine the size of the file, needed for mmap: */ + if (fstat(ifd, &sb) < 0) return Z_ERRNO; + buf_len = sb.st_size; + if (buf_len <= 0) return Z_ERRNO; + + /* Now do the actual mmap: */ + buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); + if (buf == (caddr_t)(-1)) return Z_ERRNO; + + /* Compress the whole file at once: */ + len = gzwrite(out, (char *)buf, (unsigned)buf_len); + + if (len != (int)buf_len) error(gzerror(out, &err)); + + munmap(buf, buf_len); + fclose(in); + if (gzclose(out) != Z_OK) error("failed gzclose"); + return Z_OK; +} +#endif /* USE_MMAP */ + +/* =========================================================================== + * Uncompress input to output then close both files. + */ +void gz_uncompress(in, out) + gzFile in; + FILE *out; +{ + local char buf[BUFLEN]; + int len; + int err; + + for (;;) { + len = gzread(in, buf, sizeof(buf)); + if (len < 0) error (gzerror(in, &err)); + if (len == 0) break; + + if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { + error("failed fwrite"); + } + } + if (fclose(out)) error("failed fclose"); + + if (gzclose(in) != Z_OK) error("failed gzclose"); +} + + +/* =========================================================================== + * Compress the given file: create a corresponding .gz file and remove the + * original. + */ +void file_compress(file, mode) + char *file; + char *mode; +{ + local char outfile[MAX_NAME_LEN]; + FILE *in; + gzFile out; + + if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { + fprintf(stderr, "%s: filename too long\n", prog); + exit(1); + } + +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(outfile, sizeof(outfile), "%s%s", file, GZ_SUFFIX); +#else + strcpy(outfile, file); + strcat(outfile, GZ_SUFFIX); +#endif + + in = fopen(file, "rb"); + if (in == NULL) { + perror(file); + exit(1); + } + out = gzopen(outfile, mode); + if (out == NULL) { + fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); + exit(1); + } + gz_compress(in, out); + + unlink(file); +} + + +/* =========================================================================== + * Uncompress the given file and remove the original. + */ +void file_uncompress(file) + char *file; +{ + local char buf[MAX_NAME_LEN]; + char *infile, *outfile; + FILE *out; + gzFile in; + unsigned len = strlen(file); + + if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { + fprintf(stderr, "%s: filename too long\n", prog); + exit(1); + } + +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(buf, sizeof(buf), "%s", file); +#else + strcpy(buf, file); +#endif + + if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { + infile = file; + outfile = buf; + outfile[len-3] = '\0'; + } else { + outfile = file; + infile = buf; +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX); +#else + strcat(infile, GZ_SUFFIX); +#endif + } + in = gzopen(infile, "rb"); + if (in == NULL) { + fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); + exit(1); + } + out = fopen(outfile, "wb"); + if (out == NULL) { + perror(file); + exit(1); + } + + gz_uncompress(in, out); + + unlink(infile); +} + + +/* =========================================================================== + * Usage: minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...] + * -c : write to standard output + * -d : decompress + * -f : compress with Z_FILTERED + * -h : compress with Z_HUFFMAN_ONLY + * -r : compress with Z_RLE + * -1 to -9 : compression level + */ + +int main(argc, argv) + int argc; + char *argv[]; +{ + int copyout = 0; + int uncompr = 0; + gzFile file; + char *bname, outmode[20]; + +#if !defined(NO_snprintf) && !defined(NO_vsnprintf) + snprintf(outmode, sizeof(outmode), "%s", "wb6 "); +#else + strcpy(outmode, "wb6 "); +#endif + + prog = argv[0]; + bname = strrchr(argv[0], '/'); + if (bname) + bname++; + else + bname = argv[0]; + argc--, argv++; + + if (!strcmp(bname, "gunzip")) + uncompr = 1; + else if (!strcmp(bname, "zcat")) + copyout = uncompr = 1; + + while (argc > 0) { + if (strcmp(*argv, "-c") == 0) + copyout = 1; + else if (strcmp(*argv, "-d") == 0) + uncompr = 1; + else if (strcmp(*argv, "-f") == 0) + outmode[3] = 'f'; + else if (strcmp(*argv, "-h") == 0) + outmode[3] = 'h'; + else if (strcmp(*argv, "-r") == 0) + outmode[3] = 'R'; + else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && + (*argv)[2] == 0) + outmode[2] = (*argv)[1]; + else + break; + argc--, argv++; + } + if (outmode[3] == ' ') + outmode[3] = 0; + if (argc == 0) { + SET_BINARY_MODE(stdin); + SET_BINARY_MODE(stdout); + if (uncompr) { + file = gzdopen(fileno(stdin), "rb"); + if (file == NULL) error("can't gzdopen stdin"); + gz_uncompress(file, stdout); + } else { + file = gzdopen(fileno(stdout), outmode); + if (file == NULL) error("can't gzdopen stdout"); + gz_compress(stdin, file); + } + } else { + if (copyout) { + SET_BINARY_MODE(stdout); + } + do { + if (uncompr) { + if (copyout) { + file = gzopen(*argv, "rb"); + if (file == NULL) + fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); + else + gz_uncompress(file, stdout); + } else { + file_uncompress(*argv); + } + } else { + if (copyout) { + FILE * in = fopen(*argv, "rb"); + + if (in == NULL) { + perror(*argv); + } else { + file = gzdopen(fileno(stdout), outmode); + if (file == NULL) error("can't gzdopen stdout"); + + gz_compress(in, file); + } + + } else { + file_compress(*argv, outmode); + } + } + } while (argv++, --argc); + } + return 0; +} diff --git a/libs/zlib/treebuild.xml b/libs/zlib/treebuild.xml index 89963a0ce..fd75525f9 100644 --- a/libs/zlib/treebuild.xml +++ b/libs/zlib/treebuild.xml @@ -1,6 +1,6 @@ - - + + zip compression library @@ -101,7 +101,7 @@ \t"\1", // \2 static const char *const MOBJFLAG2_LIST[] = { - "AXIS", // It's a NiGHTS axis! (For faster checking) - "TWOD", // Moves like it's in a 2D level - "DONTRESPAWN", // Don't respawn this object! - "DONTDRAW", // Don't generate a vissprite - "AUTOMATIC", // Thrown ring has automatic properties - "RAILRING", // Thrown ring has rail properties - "BOUNCERING", // Thrown ring has bounce properties - "EXPLOSION", // Thrown ring has explosive properties - "SCATTER", // Thrown ring has scatter properties - "BEYONDTHEGRAVE",// Source of this missile has died and has since respawned. - "PUSHED", // Mobj was already pushed this tic - "SLIDEPUSH", // MF_PUSHABLE that pushes continuously. - "CLASSICPUSH", // Drops straight down when object has negative Z. - "STANDONME", // While not pushable, stand on me anyway. - "INFLOAT", // Floating to a height for a move, don't auto float to target's height. - "DEBRIS", // Splash ring from explosion ring - "NIGHTSPULL", // Attracted from a paraloop - "JUSTATTACKED", // can be pushed by other moving mobjs - "FIRING", // turret fire - "SUPERFIRE", // Firing something with Super Sonic-stopping properties. Or, if mobj has MF_MISSILE, this is the actual fire from it. - "SHADOW", // Fuzzy draw, makes targeting harder. - "STRONGBOX", // Flag used for "strong" random monitors. - "OBJECTFLIP", // Flag for objects that always have flipped gravity. - "SKULLFLY", // Special handling: skull in flight. - "FRET", // Flashing from a previous hit - "BOSSNOTRAP", // No Egg Trap after boss - "BOSSFLEE", // Boss is fleeing! - "BOSSDEAD", // Boss is dead! (Not necessarily fleeing, if a fleeing point doesn't exist.) + "AXIS", // It's a NiGHTS axis! (For faster checking) + "TWOD", // Moves like it's in a 2D level + "DONTRESPAWN", // Don't respawn this object! + "DONTDRAW", // Don't generate a vissprite + "AUTOMATIC", // Thrown ring has automatic properties + "RAILRING", // Thrown ring has rail properties + "BOUNCERING", // Thrown ring has bounce properties + "EXPLOSION", // Thrown ring has explosive properties + "SCATTER", // Thrown ring has scatter properties + "BEYONDTHEGRAVE", // Source of this missile has died and has since respawned. + "SLIDEPUSH", // MF_PUSHABLE that pushes continuously. + "CLASSICPUSH", // Drops straight down when object has negative momz. + "INVERTAIMABLE", // Flips whether it's targetable by A_LookForEnemies (enemies no, decoys yes) + "INFLOAT", // Floating to a height for a move, don't auto float to target's height. + "DEBRIS", // Splash ring from explosion ring + "NIGHTSPULL", // Attracted from a paraloop + "JUSTATTACKED", // can be pushed by other moving mobjs + "FIRING", // turret fire + "SUPERFIRE", // Firing something with Super Sonic-stopping properties. Or, if mobj has MF_MISSILE, this is the actual fire from it. + "SHADOW", // Fuzzy draw, makes targeting harder. + "STRONGBOX", // Flag used for "strong" random monitors. + "OBJECTFLIP", // Flag for objects that always have flipped gravity. + "SKULLFLY", // Special handling: skull in flight. + "FRET", // Flashing from a previous hit + "BOSSNOTRAP", // No Egg Trap after boss + "BOSSFLEE", // Boss is fleeing! + "BOSSDEAD", // Boss is dead! (Not necessarily fleeing, if a fleeing point doesn't exist.) + "AMBUSH", // Alternate behaviour typically set by MTF_AMBUSH + "LINKDRAW", // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) + "SHIELD", // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) NULL }; @@ -6740,24 +8831,28 @@ static const char *const MOBJEFLAG_LIST[] = { "JUSTSTEPPEDDOWN", // used for ramp sectors "VERTICALFLIP", // Vertically flip sprite/allow upside-down physics "GOOWATER", // Goo water - "\x01", // free: 1<<7 (name un-matchable) + "TOUCHLAVA", // The mobj is touching a lava block + "PUSHED", // Mobj was already pushed this tic "SPRUNG", // Mobj was already sprung this tic "APPLYPMOMZ", // Platform movement + "TRACERANGLE", // Compute and trigger on mobj angle relative to tracer NULL }; -#ifdef HAVE_BLUA static const char *const MAPTHINGFLAG_LIST[4] = { - NULL, + "EXTRA", // Extra flag for objects. "OBJECTFLIP", // Reverse gravity flag for objects. "OBJECTSPECIAL", // Special flag used with certain objects. "AMBUSH" // Deaf monsters/do not react to sound. }; -#endif static const char *const PLAYERFLAG_LIST[] = { - // Flip camera angle with gravity flip prefrence. - "FLIPCAM", + + // Cvars + "FLIPCAM", // Flip camera angle with gravity flip prefrence. + "ANALOGMODE", // Analog mode? + "DIRECTIONCHAR", // Directional character sprites? + "AUTOBRAKE", // Autobrake? // Cheats "GODMODE", @@ -6775,58 +8870,77 @@ static const char *const PLAYERFLAG_LIST[] = { "JUMPSTASIS", // and that includes jumping. // (we don't include FULLSTASIS here I guess because it's just those two together...?) - // Did you get a time-over? - "TIMEOVER", - - // Ready for Super? - "SUPERREADY", + // Applying autobrake? + "APPLYAUTOBRAKE", // Character action status + "STARTJUMP", "JUMPED", + "NOJUMPDAMAGE", + "SPINNING", "STARTDASH", + "THOKKED", - - // Are you gliding? + "SHIELDABILITY", "GLIDING", - - // Tails pickup! - "CARRIED", + "BOUNCING", // Sliding (usually in water) like Labyrinth/Oil Ocean "SLIDING", - // Hanging on a rope - "ROPEHANG", - - // Hanging on an item of some kind - zipline, chain, etc. (->tracer) - "ITEMHANG", - - // On the mace chain spinning around (->tracer) - "MACESPIN", - - /*** NIGHTS STUFF ***/ - // Is the player in NiGHTS mode? - "NIGHTSMODE", + // NiGHTS stuff "TRANSFERTOCLOSEST", - - // Spill rings after falling - "NIGHTSFALL", "DRILLING", - "SKIDDOWN", - /*** TAG STUFF ***/ - "TAGGED", // Player has been tagged and awaits the next round in hide and seek. + // Gametype-specific stuff + "GAMETYPEOVER", // Race time over, or H&S out-of-game "TAGIT", // The player is it! For Tag Mode /*** misc ***/ "FORCESTRAFE", // Translate turn inputs into strafe inputs - "ANALOGMODE", // Analog mode? + "CANCARRY", // Can carry? + "FINISHED", NULL // stop loop here. }; -#ifdef HAVE_BLUA +static const char *const GAMETYPERULE_LIST[] = { + "CAMPAIGN", + "RINGSLINGER", + "SPECTATORS", + "LIVES", + "TEAMS", + "FIRSTPERSON", + "POWERSTONES", + "TEAMFLAGS", + "FRIENDLY", + "SPECIALSTAGES", + "EMERALDTOKENS", + "EMERALDHUNT", + "RACE", + "TAG", + "POINTLIMIT", + "TIMELIMIT", + "OVERTIME", + "HURTMESSAGES", + "FRIENDLYFIRE", + "STARTCOUNTDOWN", + "HIDEFROZEN", + "BLINDFOLDED", + "RESPAWNDELAY", + "PITYSHIELD", + "DEATHPENALTY", + "NOSPECTATORSPAWN", + "DEATHMATCHSTARTS", + "SPAWNINVUL", + "SPAWNENEMIES", + "ALLOWEXIT", + "NOTITLECARD", + "CUTSCENES", + NULL +}; + // Linedef flags static const char *const ML_LIST[16] = { "IMPASSIBLE", @@ -6846,55 +8960,140 @@ static const char *const ML_LIST[16] = { "BOUNCY", "TFERLINE" }; -#endif // This DOES differ from r_draw's Color_Names, unfortunately. // Also includes Super colors static const char *COLOR_ENUMS[] = { - "NONE", // SKINCOLOR_NONE - "WHITE", // SKINCOLOR_WHITE - "SILVER", // SKINCOLOR_SILVER - "GREY", // SKINCOLOR_GREY - "BLACK", // SKINCOLOR_BLACK - "CYAN", // SKINCOLOR_CYAN - "TEAL", // SKINCOLOR_TEAL - "STEELBLUE", // SKINCOLOR_STEELBLUE - "BLUE", // SKINCOLOR_BLUE - "PEACH", // SKINCOLOR_PEACH - "TAN", // SKINCOLOR_TAN - "PINK", // SKINCOLOR_PINK - "LAVENDER", // SKINCOLOR_LAVENDER - "PURPLE", // SKINCOLOR_PURPLE - "ORANGE", // SKINCOLOR_ORANGE - "ROSEWOOD", // SKINCOLOR_ROSEWOOD - "BEIGE", // SKINCOLOR_BEIGE - "BROWN", // SKINCOLOR_BROWN - "RED", // SKINCOLOR_RED - "DARKRED", // SKINCOLOR_DARKRED - "NEONGREEN", // SKINCOLOR_NEONGREEN - "GREEN", // SKINCOLOR_GREEN - "ZIM", // SKINCOLOR_ZIM - "OLIVE", // SKINCOLOR_OLIVE - "YELLOW", // SKINCOLOR_YELLOW - "GOLD", // SKINCOLOR_GOLD + "NONE", // SKINCOLOR_NONE, + + // Greyscale ranges + "WHITE", // SKINCOLOR_WHITE, + "BONE", // SKINCOLOR_BONE, + "CLOUDY", // SKINCOLOR_CLOUDY, + "GREY", // SKINCOLOR_GREY, + "SILVER", // SKINCOLOR_SILVER, + "CARBON", // SKINCOLOR_CARBON, + "JET", // SKINCOLOR_JET, + "BLACK", // SKINCOLOR_BLACK, + + // Desaturated + "AETHER", // SKINCOLOR_AETHER, + "SLATE", // SKINCOLOR_SLATE, + "BLUEBELL", // SKINCOLOR_BLUEBELL, + "PINK", // SKINCOLOR_PINK, + "YOGURT", // SKINCOLOR_YOGURT, + "BROWN", // SKINCOLOR_BROWN, + "BRONZE", // SKINCOLOR_BRONZE, + "TAN", // SKINCOLOR_TAN, + "BEIGE", // SKINCOLOR_BEIGE, + "MOSS", // SKINCOLOR_MOSS, + "AZURE", // SKINCOLOR_AZURE, + "LAVENDER", // SKINCOLOR_LAVENDER, + + // Viv's vivid colours (toast 21/07/17) + "RUBY", // SKINCOLOR_RUBY, + "SALMON", // SKINCOLOR_SALMON, + "RED", // SKINCOLOR_RED, + "CRIMSON", // SKINCOLOR_CRIMSON, + "FLAME", // SKINCOLOR_FLAME, + "KETCHUP", // SKINCOLOR_KETCHUP, + "PEACHY", // SKINCOLOR_PEACHY, + "QUAIL", // SKINCOLOR_QUAIL, + "SUNSET", // SKINCOLOR_SUNSET, + "COPPER", // SKINCOLOR_COPPER, + "APRICOT", // SKINCOLOR_APRICOT, + "ORANGE", // SKINCOLOR_ORANGE, + "RUST", // SKINCOLOR_RUST, + "GOLD", // SKINCOLOR_GOLD, + "SANDY", // SKINCOLOR_SANDY, + "YELLOW", // SKINCOLOR_YELLOW, + "OLIVE", // SKINCOLOR_OLIVE, + "LIME", // SKINCOLOR_LIME, + "PERIDOT", // SKINCOLOR_PERIDOT, + "APPLE", // SKINCOLOR_APPLE, + "GREEN", // SKINCOLOR_GREEN, + "FOREST", // SKINCOLOR_FOREST, + "EMERALD", // SKINCOLOR_EMERALD, + "MINT", // SKINCOLOR_MINT, + "SEAFOAM", // SKINCOLOR_SEAFOAM, + "AQUA", // SKINCOLOR_AQUA, + "TEAL", // SKINCOLOR_TEAL, + "WAVE", // SKINCOLOR_WAVE, + "CYAN", // SKINCOLOR_CYAN, + "SKY", // SKINCOLOR_SKY, + "CERULEAN", // SKINCOLOR_CERULEAN, + "ICY", // SKINCOLOR_ICY, + "SAPPHIRE", // SKINCOLOR_SAPPHIRE, + "CORNFLOWER", // SKINCOLOR_CORNFLOWER, + "BLUE", // SKINCOLOR_BLUE, + "COBALT", // SKINCOLOR_COBALT, + "VAPOR", // SKINCOLOR_VAPOR, + "DUSK", // SKINCOLOR_DUSK, + "PASTEL", // SKINCOLOR_PASTEL, + "PURPLE", // SKINCOLOR_PURPLE, + "BUBBLEGUM", // SKINCOLOR_BUBBLEGUM, + "MAGENTA", // SKINCOLOR_MAGENTA, + "NEON", // SKINCOLOR_NEON, + "VIOLET", // SKINCOLOR_VIOLET, + "LILAC", // SKINCOLOR_LILAC, + "PLUM", // SKINCOLOR_PLUM, + "RASPBERRY", // SKINCOLOR_RASPBERRY, + "ROSY", // SKINCOLOR_ROSY, + // Super special awesome Super flashing colors! - "SUPER1", // SKINCOLOR_SUPER1 - "SUPER2", // SKINCOLOR_SUPER2, - "SUPER3", // SKINCOLOR_SUPER3, - "SUPER4", // SKINCOLOR_SUPER4, - "SUPER5", // SKINCOLOR_SUPER5, - // Super Tails - "TSUPER1", // SKINCOLOR_TSUPER1, - "TSUPER2", // SKINCOLOR_TSUPER2, - "TSUPER3", // SKINCOLOR_TSUPER3, - "TSUPER4", // SKINCOLOR_TSUPER4, - "TSUPER5", // SKINCOLOR_TSUPER5, - // Super Knuckles - "KSUPER1", // SKINCOLOR_KSUPER1, - "KSUPER2", // SKINCOLOR_KSUPER2, - "KSUPER3", // SKINCOLOR_KSUPER3, - "KSUPER4", // SKINCOLOR_KSUPER4, - "KSUPER5" // SKINCOLOR_KSUPER5, + "SUPERSILVER1", // SKINCOLOR_SUPERSILVER1 + "SUPERSILVER2", // SKINCOLOR_SUPERSILVER2, + "SUPERSILVER3", // SKINCOLOR_SUPERSILVER3, + "SUPERSILVER4", // SKINCOLOR_SUPERSILVER4, + "SUPERSILVER5", // SKINCOLOR_SUPERSILVER5, + + "SUPERRED1", // SKINCOLOR_SUPERRED1 + "SUPERRED2", // SKINCOLOR_SUPERRED2, + "SUPERRED3", // SKINCOLOR_SUPERRED3, + "SUPERRED4", // SKINCOLOR_SUPERRED4, + "SUPERRED5", // SKINCOLOR_SUPERRED5, + + "SUPERORANGE1", // SKINCOLOR_SUPERORANGE1 + "SUPERORANGE2", // SKINCOLOR_SUPERORANGE2, + "SUPERORANGE3", // SKINCOLOR_SUPERORANGE3, + "SUPERORANGE4", // SKINCOLOR_SUPERORANGE4, + "SUPERORANGE5", // SKINCOLOR_SUPERORANGE5, + + "SUPERGOLD1", // SKINCOLOR_SUPERGOLD1 + "SUPERGOLD2", // SKINCOLOR_SUPERGOLD2, + "SUPERGOLD3", // SKINCOLOR_SUPERGOLD3, + "SUPERGOLD4", // SKINCOLOR_SUPERGOLD4, + "SUPERGOLD5", // SKINCOLOR_SUPERGOLD5, + + "SUPERPERIDOT1", // SKINCOLOR_SUPERPERIDOT1 + "SUPERPERIDOT2", // SKINCOLOR_SUPERPERIDOT2, + "SUPERPERIDOT3", // SKINCOLOR_SUPERPERIDOT3, + "SUPERPERIDOT4", // SKINCOLOR_SUPERPERIDOT4, + "SUPERPERIDOT5", // SKINCOLOR_SUPERPERIDOT5, + + "SUPERSKY1", // SKINCOLOR_SUPERSKY1 + "SUPERSKY2", // SKINCOLOR_SUPERSKY2, + "SUPERSKY3", // SKINCOLOR_SUPERSKY3, + "SUPERSKY4", // SKINCOLOR_SUPERSKY4, + "SUPERSKY5", // SKINCOLOR_SUPERSKY5, + + "SUPERPURPLE1", // SKINCOLOR_SUPERPURPLE1, + "SUPERPURPLE2", // SKINCOLOR_SUPERPURPLE2, + "SUPERPURPLE3", // SKINCOLOR_SUPERPURPLE3, + "SUPERPURPLE4", // SKINCOLOR_SUPERPURPLE4, + "SUPERPURPLE5", // SKINCOLOR_SUPERPURPLE5, + + "SUPERRUST1", // SKINCOLOR_SUPERRUST1 + "SUPERRUST2", // SKINCOLOR_SUPERRUST2, + "SUPERRUST3", // SKINCOLOR_SUPERRUST3, + "SUPERRUST4", // SKINCOLOR_SUPERRUST4, + "SUPERRUST5", // SKINCOLOR_SUPERRUST5, + + "SUPERTAN1", // SKINCOLOR_SUPERTAN1 + "SUPERTAN2", // SKINCOLOR_SUPERTAN2, + "SUPERTAN3", // SKINCOLOR_SUPERTAN3, + "SUPERTAN4", // SKINCOLOR_SUPERTAN4, + "SUPERTAN5" // SKINCOLOR_SUPERTAN5, }; static const char *const POWERS_LIST[] = { @@ -6902,10 +9101,14 @@ static const char *const POWERS_LIST[] = { "SNEAKERS", "FLASHING", "SHIELD", + "CARRY", "TAILSFLY", // tails flying "UNDERWATER", // underwater timer "SPACETIME", // In space, no one can hear you spin! "EXTRALIFE", // Extra Life timer + "PUSHING", + "JUSTSPRUNG", + "NOAUTOBRAKE", "SUPER", // Are you super? "GRAVITYBOOTS", // gravity boots @@ -6929,36 +9132,27 @@ static const char *const POWERS_LIST[] = { //for linedef exec 427 "NOCONTROL", - "INGOOP" // In goop + "JUSTLAUNCHED", }; static const char *const HUDITEMS_LIST[] = { - "LIVESNAME", - "LIVESPIC", - "LIVESNUM", - "LIVESX", + "LIVES", "RINGS", - "RINGSSPLIT", "RINGSNUM", - "RINGSNUMSPLIT", + "RINGSNUMTICS", "SCORE", "SCORENUM", "TIME", - "TIMESPLIT", "MINUTES", - "MINUTESSPLIT", "TIMECOLON", - "TIMECOLONSPLIT", "SECONDS", - "SECONDSSPLIT", "TIMETICCOLON", "TICS", "SS_TOTALRINGS", - "SS_TOTALRINGS_SPLIT", "GETRINGS", "GETRINGSNUM", @@ -6966,18 +9160,105 @@ static const char *const HUDITEMS_LIST[] = { "TIMELEFTNUM", "TIMEUP", "HUNTPICS", - "GRAVBOOTSICO", - "LAP" + "POWERUPS" +}; + +static const char *const MENUTYPES_LIST[] = { + "NONE", + + "MAIN", + + // Single Player + "SP_MAIN", + + "SP_LOAD", + "SP_PLAYER", + + "SP_LEVELSELECT", + "SP_LEVELSTATS", + + "SP_TIMEATTACK", + "SP_TIMEATTACK_LEVELSELECT", + "SP_GUESTREPLAY", + "SP_REPLAY", + "SP_GHOST", + + "SP_NIGHTSATTACK", + "SP_NIGHTS_LEVELSELECT", + "SP_NIGHTS_GUESTREPLAY", + "SP_NIGHTS_REPLAY", + "SP_NIGHTS_GHOST", + + // Multiplayer + "MP_MAIN", + "MP_SPLITSCREEN", // SplitServer + "MP_SERVER", + "MP_CONNECT", + "MP_ROOM", + "MP_PLAYERSETUP", // MP_PlayerSetupDef shared with SPLITSCREEN if #defined NONET + + // Options + "OP_MAIN", + + "OP_P1CONTROLS", + "OP_CHANGECONTROLS", // OP_ChangeControlsDef shared with P2 + "OP_P1MOUSE", + "OP_P1JOYSTICK", + "OP_JOYSTICKSET", // OP_JoystickSetDef shared with P2 + + "OP_P2CONTROLS", + "OP_P2MOUSE", + "OP_P2JOYSTICK", + + "OP_VIDEO", + "OP_VIDEOMODE", + "OP_COLOR", + "OP_OPENGL", + "OP_OPENGL_LIGHTING", + "OP_OPENGL_FOG", + "OP_OPENGL_COLOR", + + "OP_SOUND", + + "OP_SERVER", + "OP_MONITORTOGGLE", + + "OP_DATA", + "OP_ADDONS", + "OP_SCREENSHOTS", + "OP_ERASEDATA", + + // Extras + "SR_MAIN", + "SR_PANDORA", + "SR_LEVELSELECT", + "SR_UNLOCKCHECKLIST", + "SR_EMBLEMHINT", + "SR_PLAYER", + "SR_SOUNDTEST", + + // Addons (Part of MISC, but let's make it our own) + "AD_MAIN", + + // MISC + // "MESSAGE", + // "SPAUSE", + + // "MPAUSE", + // "SCRAMBLETEAM", + // "CHANGETEAM", + // "CHANGELEVEL", + + // "MAPAUSE", + // "HELP", + + "SPECIAL" }; struct { const char *n; // has to be able to hold both fixed_t and angle_t, so drastic measure!! -#ifdef HAVE_BLUA lua_Integer v; -#else - INT64 v; -#endif } const INT_CONST[] = { // If a mod removes some variables here, // please leave the names in-tact and just set @@ -7003,12 +9284,15 @@ struct { // doomdef.h constants {"TICRATE",TICRATE}, + {"MUSICRATE",MUSICRATE}, {"RING_DIST",RING_DIST}, {"PUSHACCEL",PUSHACCEL}, {"MODID",MODID}, // I don't know, I just thought it would be cool for a wad to potentially know what mod it was loaded into. {"CODEBASE",CODEBASE}, // or what release of SRB2 this is. {"VERSION",VERSION}, // Grab the game's version! {"SUBVERSION",SUBVERSION}, // more precise version number + {"NEWTICRATE",NEWTICRATE}, // TICRATE*NEWTICRATERATIO + {"NEWTICRATERATIO",NEWTICRATERATIO}, // Special linedef executor tag numbers! {"LE_PINCHPHASE",LE_PINCHPHASE}, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!) @@ -7016,13 +9300,28 @@ struct { {"LE_BOSSDEAD",LE_BOSSDEAD}, // A boss in the map died (Chaos mode boss tally) {"LE_BOSS4DROP",LE_BOSS4DROP}, // CEZ boss dropped its cage {"LE_BRAKVILEATACK",LE_BRAKVILEATACK}, // Brak's doing his LOS attack, oh noes + {"LE_TURRET",LE_TURRET}, // THZ turret + {"LE_BRAKPLATFORM",LE_BRAKPLATFORM}, // v2.0 Black Eggman destroys platform + {"LE_CAPSULE2",LE_CAPSULE2}, // Egg Capsule + {"LE_CAPSULE1",LE_CAPSULE1}, // Egg Capsule + {"LE_CAPSULE0",LE_CAPSULE0}, // Egg Capsule + {"LE_KOOPA",LE_KOOPA}, // Distant cousin to Gay Bowser + {"LE_AXE",LE_AXE}, // MKB Axe object + {"LE_PARAMWIDTH",LE_PARAMWIDTH}, // If an object that calls LinedefExecute has a nonzero parameter value, this times the parameter will be subtracted. (Mostly for the purpose of coexisting bosses...) /// \todo Get all this stuff into its own sections, maybe. Maybe. // Frame settings {"FF_FRAMEMASK",FF_FRAMEMASK}, + {"FF_SPR2SUPER",FF_SPR2SUPER}, + {"FF_SPR2ENDSTATE",FF_SPR2ENDSTATE}, + {"FF_SPR2MIDSTART",FF_SPR2MIDSTART}, {"FF_ANIMATE",FF_ANIMATE}, + {"FF_RANDOMANIM",FF_RANDOMANIM}, + {"FF_GLOBALANIM",FF_GLOBALANIM}, {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_VERTICALFLIP",FF_VERTICALFLIP}, + {"FF_PAPERSPRITE",FF_PAPERSPRITE}, {"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSSHIFT",FF_TRANSSHIFT}, // new preshifted translucency (used in source) @@ -7058,47 +9357,26 @@ struct { {"tr_trans90",tr_trans90}, {"NUMTRANSMAPS",NUMTRANSMAPS}, - // Type of levels - {"TOL_SP",TOL_SP}, - {"TOL_COOP",TOL_COOP}, - {"TOL_COMPETITION",TOL_COMPETITION}, - {"TOL_RACE",TOL_RACE}, - {"TOL_MATCH",TOL_MATCH}, - {"TOL_TAG",TOL_TAG}, - {"TOL_CTF",TOL_CTF}, - {"TOL_CUSTOM",TOL_CUSTOM}, - {"TOL_2D",TOL_2D}, - {"TOL_MARIO",TOL_MARIO}, - {"TOL_NIGHTS",TOL_NIGHTS}, - {"TOL_ERZ3",TOL_ERZ3}, - {"TOL_XMAS",TOL_XMAS}, - // Level flags {"LF_SCRIPTISFILE",LF_SCRIPTISFILE}, {"LF_SPEEDMUSIC",LF_SPEEDMUSIC}, {"LF_NOSSMUSIC",LF_NOSSMUSIC}, {"LF_NORELOAD",LF_NORELOAD}, {"LF_NOZONE",LF_NOZONE}, + {"LF_SAVEGAME",LF_SAVEGAME}, + {"LF_MIXNIGHTSCOUNTDOWN",LF_MIXNIGHTSCOUNTDOWN}, + {"LF_NOTITLECARDFIRST",LF_NOTITLECARDFIRST}, + {"LF_NOTITLECARDRESPAWN",LF_NOTITLECARDRESPAWN}, + {"LF_NOTITLECARDRECORDATTACK",LF_NOTITLECARDRECORDATTACK}, + {"LF_NOTITLECARD",LF_NOTITLECARD}, + {"LF_WARNINGTITLE",LF_WARNINGTITLE}, // And map flags {"LF2_HIDEINMENU",LF2_HIDEINMENU}, {"LF2_HIDEINSTATS",LF2_HIDEINSTATS}, {"LF2_RECORDATTACK",LF2_RECORDATTACK}, {"LF2_NIGHTSATTACK",LF2_NIGHTSATTACK}, {"LF2_NOVISITNEEDED",LF2_NOVISITNEEDED}, - - // Save override - {"SAVE_NEVER",SAVE_NEVER}, - {"SAVE_DEFAULT",SAVE_DEFAULT}, - {"SAVE_ALWAYS",SAVE_ALWAYS}, - - // NiGHTS grades - {"GRADE_F",GRADE_F}, - {"GRADE_E",GRADE_E}, - {"GRADE_D",GRADE_D}, - {"GRADE_C",GRADE_C}, - {"GRADE_B",GRADE_B}, - {"GRADE_A",GRADE_A}, - {"GRADE_S",GRADE_S}, + {"LF2_WIDEICON",LF2_WIDEICON}, // Emeralds {"EMERALD1",EMERALD1}, @@ -7123,23 +9401,46 @@ struct { {"PRECIP_STORM_NOSTRIKES",PRECIP_STORM_NOSTRIKES}, // Shields - // These ones use the lower 8 bits {"SH_NONE",SH_NONE}, - {"SH_JUMP",SH_JUMP}, + // Shield flags + {"SH_PROTECTFIRE",SH_PROTECTFIRE}, + {"SH_PROTECTWATER",SH_PROTECTWATER}, + {"SH_PROTECTELECTRIC",SH_PROTECTELECTRIC}, + {"SH_PROTECTSPIKE",SH_PROTECTSPIKE}, + // Indivisible shields + {"SH_PITY",SH_PITY}, + {"SH_WHIRLWIND",SH_WHIRLWIND}, + {"SH_ARMAGEDDON",SH_ARMAGEDDON}, + {"SH_PINK",SH_PINK}, + // normal shields that use flags {"SH_ATTRACT",SH_ATTRACT}, {"SH_ELEMENTAL",SH_ELEMENTAL}, - {"SH_BOMB",SH_BOMB}, + // Sonic 3 shields + {"SH_FLAMEAURA",SH_FLAMEAURA}, {"SH_BUBBLEWRAP",SH_BUBBLEWRAP}, {"SH_THUNDERCOIN",SH_THUNDERCOIN}, - {"SH_FLAMEAURA",SH_FLAMEAURA}, - {"SH_PITY",SH_PITY}, - // These ones are special and use the upper bits - {"SH_FIREFLOWER",SH_FIREFLOWER}, // Lower bits are a normal shield stacked on top of the fire flower - {"SH_FORCE",SH_FORCE}, // Lower bits are how many hits left, 0 is the last hit - // Stack masks + // The force shield uses the lower 8 bits to count how many extra hits are left. + {"SH_FORCE",SH_FORCE}, + {"SH_FORCEHP",SH_FORCEHP}, // to be used as a bitmask only + // Mostly for use with Mario mode. + {"SH_FIREFLOWER",SH_FIREFLOWER}, {"SH_STACK",SH_STACK}, {"SH_NOSTACK",SH_NOSTACK}, + // Carrying + {"CR_NONE",CR_NONE}, + {"CR_GENERIC",CR_GENERIC}, + {"CR_PLAYER",CR_PLAYER}, + {"CR_NIGHTSMODE",CR_NIGHTSMODE}, + {"CR_NIGHTSFALL",CR_NIGHTSFALL}, + {"CR_BRAKGOOP",CR_BRAKGOOP}, + {"CR_ZOOMTUBE",CR_ZOOMTUBE}, + {"CR_ROPEHANG",CR_ROPEHANG}, + {"CR_MACESPIN",CR_MACESPIN}, + {"CR_MINECART",CR_MINECART}, + {"CR_ROLLOUT",CR_ROLLOUT}, + {"CR_PTERABYTE",CR_PTERABYTE}, + // Ring weapons (ringweapons_t) // Useful for A_GiveWeapon {"RW_AUTO",RW_AUTO}, @@ -7151,12 +9452,25 @@ struct { // Character flags (skinflags_t) {"SF_SUPER",SF_SUPER}, - {"SF_SUPERANIMS",SF_SUPERANIMS}, - {"SF_SUPERSPIN",SF_SUPERSPIN}, + {"SF_NOSUPERSPIN",SF_NOSUPERSPIN}, + {"SF_NOSPINDASHDUST",SF_NOSPINDASHDUST}, {"SF_HIRES",SF_HIRES}, {"SF_NOSKID",SF_NOSKID}, {"SF_NOSPEEDADJUST",SF_NOSPEEDADJUST}, {"SF_RUNONWATER",SF_RUNONWATER}, + {"SF_NOJUMPSPIN",SF_NOJUMPSPIN}, + {"SF_NOJUMPDAMAGE",SF_NOJUMPDAMAGE}, + {"SF_STOMPDAMAGE",SF_STOMPDAMAGE}, + {"SF_MARIODAMAGE",SF_MARIODAMAGE}, + {"SF_MACHINE",SF_MACHINE}, + {"SF_DASHMODE",SF_DASHMODE}, + {"SF_FASTEDGE",SF_FASTEDGE}, + {"SF_MULTIABILITY",SF_MULTIABILITY}, + {"SF_NONIGHTSROTATION",SF_NONIGHTSROTATION}, + + // Dashmode constants + {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, + {"DASHMODE_MAX",DASHMODE_MAX}, // Character abilities! // Primary @@ -7174,10 +9488,13 @@ struct { {"CA_JUMPBOOST",CA_JUMPBOOST}, {"CA_AIRDRILL",CA_AIRDRILL}, {"CA_JUMPTHOK",CA_JUMPTHOK}, + {"CA_BOUNCE",CA_BOUNCE}, + {"CA_TWINSPIN",CA_TWINSPIN}, // Secondary {"CA2_NONE",CA2_NONE}, // now slot 0! {"CA2_SPINDASH",CA2_SPINDASH}, - {"CA2_MULTIABILITY",CA2_MULTIABILITY}, + {"CA2_GUNSLINGER",CA2_GUNSLINGER}, + {"CA2_MELEE",CA2_MELEE}, // Sound flags {"SF_TOTALLYSINGLE",SF_TOTALLYSINGLE}, @@ -7188,7 +9505,15 @@ struct { {"SF_NOINTERRUPT",SF_NOINTERRUPT}, {"SF_X2AWAYSOUND",SF_X2AWAYSOUND}, -#ifdef HAVE_BLUA + // Global emblem var flags + {"GE_NIGHTSPULL",GE_NIGHTSPULL}, + {"GE_NIGHTSITEM",GE_NIGHTSITEM}, + + // Map emblem var flags + {"ME_ALLEMERALDS",ME_ALLEMERALDS}, + {"ME_ULTIMATE",ME_ULTIMATE}, + {"ME_PERFECT",ME_PERFECT}, + // p_local.h constants {"FLOATSPEED",FLOATSPEED}, {"MAXSTEPMOVE",MAXSTEPMOVE}, @@ -7202,16 +9527,51 @@ struct { {"PAL_MIXUP",PAL_MIXUP}, {"PAL_RECYCLE",PAL_RECYCLE}, {"PAL_NUKE",PAL_NUKE}, + // for P_DamageMobj + //// Damage types + {"DMG_WATER",DMG_WATER}, + {"DMG_FIRE",DMG_FIRE}, + {"DMG_ELECTRIC",DMG_ELECTRIC}, + {"DMG_SPIKE",DMG_SPIKE}, + {"DMG_NUKE",DMG_NUKE}, + //// Death types + {"DMG_INSTAKILL",DMG_INSTAKILL}, + {"DMG_DROWNED",DMG_DROWNED}, + {"DMG_SPACEDROWN",DMG_SPACEDROWN}, + {"DMG_DEATHPIT",DMG_DEATHPIT}, + {"DMG_CRUSHED",DMG_CRUSHED}, + {"DMG_SPECTATOR",DMG_SPECTATOR}, + //// Masks + {"DMG_CANHURTSELF",DMG_CANHURTSELF}, + {"DMG_DEATHMASK",DMG_DEATHMASK}, - // Gametypes, for use with global var "gametype" - {"GT_COOP",GT_COOP}, - {"GT_COMPETITION",GT_COMPETITION}, - {"GT_RACE",GT_RACE}, - {"GT_MATCH",GT_MATCH}, - {"GT_TEAMMATCH",GT_TEAMMATCH}, - {"GT_TAG",GT_TAG}, - {"GT_HIDEANDSEEK",GT_HIDEANDSEEK}, - {"GT_CTF",GT_CTF}, + // Intermission types + {"int_none",int_none}, + {"int_coop",int_coop}, + {"int_match",int_match}, + {"int_teammatch",int_teammatch}, + //{"int_tag",int_tag}, + {"int_ctf",int_ctf}, + {"int_spec",int_spec}, + {"int_race",int_race}, + {"int_comp",int_comp}, + + // Jingles (jingletype_t) + {"JT_NONE",JT_NONE}, + {"JT_OTHER",JT_OTHER}, + {"JT_MASTER",JT_MASTER}, + {"JT_1UP",JT_1UP}, + {"JT_SHOES",JT_SHOES}, + {"JT_INV",JT_INV}, + {"JT_MINV",JT_MINV}, + {"JT_DROWN",JT_DROWN}, + {"JT_SUPER",JT_SUPER}, + {"JT_GOVER",JT_GOVER}, + {"JT_NIGHTSTIMEOUT",JT_NIGHTSTIMEOUT}, + {"JT_SSTIMEOUT",JT_SSTIMEOUT}, + // {"JT_LCLEAR",JT_LCLEAR}, + // {"JT_RACENT",JT_RACENT}, + // {"JT_CONTSC",JT_CONTSC}, // Player state (playerstate_t) {"PST_LIVE",PST_LIVE}, // Playing or camping. @@ -7221,11 +9581,18 @@ struct { // Player animation (panim_t) {"PA_ETC",PA_ETC}, {"PA_IDLE",PA_IDLE}, + {"PA_EDGE",PA_EDGE}, {"PA_WALK",PA_WALK}, {"PA_RUN",PA_RUN}, + {"PA_DASH",PA_DASH}, + {"PA_PAIN",PA_PAIN}, {"PA_ROLL",PA_ROLL}, + {"PA_JUMP",PA_JUMP}, + {"PA_SPRING",PA_SPRING}, {"PA_FALL",PA_FALL}, {"PA_ABILITY",PA_ABILITY}, + {"PA_ABILITY2",PA_ABILITY2}, + {"PA_RIDE",PA_RIDE}, // Current weapon {"WEP_AUTO",WEP_AUTO}, @@ -7236,6 +9603,9 @@ struct { {"WEP_RAIL",WEP_RAIL}, {"NUM_WEAPONS",NUM_WEAPONS}, + // Value for infinite lives + {"INFLIVES",INFLIVES}, + // Got Flags, for player->gotflag! // Used to be MF_ for some stupid reason, now they're GF_ to stop them looking like mobjflags {"GF_REDFLAG",GF_REDFLAG}, @@ -7295,20 +9665,23 @@ struct { {"FF_QUICKSAND",FF_QUICKSAND}, ///< Quicksand! {"FF_PLATFORM",FF_PLATFORM}, ///< You can jump up through this to the top. {"FF_REVERSEPLATFORM",FF_REVERSEPLATFORM}, ///< A fall-through floor in normal gravity, a platform in reverse gravity. - {"FF_INTANGABLEFLATS",FF_INTANGABLEFLATS}, ///< Both flats are intangable, but the sides are still solid. - {"FF_SHATTER",FF_SHATTER}, ///< Used with ::FF_BUSTUP. Thinks everyone's Knuckles. - {"FF_SPINBUST",FF_SPINBUST}, ///< Used with ::FF_BUSTUP. Jump or fall onto it while curled in a ball. - {"FF_ONLYKNUX",FF_ONLYKNUX}, ///< Used with ::FF_BUSTUP. Only Knuckles can break this rock. + {"FF_INTANGIBLEFLATS",FF_INTANGIBLEFLATS}, ///< Both flats are intangible, but the sides are still solid. + {"FF_INTANGABLEFLATS",FF_INTANGIBLEFLATS}, ///< Both flats are intangable, but the sides are still solid. + {"FF_SHATTER",FF_SHATTER}, ///< Used with ::FF_BUSTUP. Bustable on mere touch. + {"FF_SPINBUST",FF_SPINBUST}, ///< Used with ::FF_BUSTUP. Also bustable if you're in your spinning frames. + {"FF_STRONGBUST",FF_STRONGBUST}, ///< Used with ::FF_BUSTUP. Only bustable by "strong" characters (Knuckles) and abilities (bouncing, twinspin, melee). {"FF_RIPPLE",FF_RIPPLE}, ///< Ripple the flats {"FF_COLORMAPONLY",FF_COLORMAPONLY}, ///< Only copy the colormap, not the lightlevel {"FF_GOOWATER",FF_GOOWATER}, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. +#ifdef HAVE_LUA_SEGS + // Node flags + {"NF_SUBSECTOR",NF_SUBSECTOR}, // Indicate a leaf. +#endif #ifdef ESLOPE // Slope flags - {"SL_NOPHYSICS",SL_NOPHYSICS}, // Don't do momentum adjustment with this slope - {"SL_NODYNAMIC",SL_NODYNAMIC}, // Slope will never need to move during the level, so don't fuss with recalculating it - {"SL_ANCHORVERTEX",SL_ANCHORVERTEX},// Slope is using a Slope Vertex Thing to anchor its position - {"SL_VERTEXSLOPE",SL_VERTEXSLOPE}, // Slope is built from three Slope Vertex Things + {"SL_NOPHYSICS",SL_NOPHYSICS}, + {"SL_DYNAMIC",SL_DYNAMIC}, #endif // Angles @@ -7355,6 +9728,11 @@ struct { {"DI_SOUTHEAST",DI_SOUTHEAST}, {"NUMDIRS",NUMDIRS}, + // Sprite rotation axis (rotaxis_t) + {"ROTAXIS_X",ROTAXIS_X}, + {"ROTAXIS_Y",ROTAXIS_Y}, + {"ROTAXIS_Z",ROTAXIS_Z}, + // Buttons (ticcmd_t) {"BT_WEAPONMASK",BT_WEAPONMASK}, //our first four bits. {"BT_WEAPONNEXT",BT_WEAPONNEXT}, @@ -7370,6 +9748,11 @@ struct { {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable + // Lua command registration flags + {"COM_ADMIN",COM_ADMIN}, + {"COM_SPLITSCREEN",COM_SPLITSCREEN}, + {"COM_LOCAL",COM_LOCAL}, + // cvflags_t {"CV_SAVE",CV_SAVE}, {"CV_CALL",CV_CALL}, @@ -7384,6 +9767,7 @@ struct { {"CV_HIDEN",CV_HIDEN}, {"CV_HIDDEN",CV_HIDEN}, {"CV_CHEAT",CV_CHEAT}, + {"CV_NOLUA",CV_NOLUA}, // v_video flags {"V_NOSCALEPATCH",V_NOSCALEPATCH}, @@ -7392,13 +9776,23 @@ struct { {"V_6WIDTHSPACE",V_6WIDTHSPACE}, {"V_OLDSPACING",V_OLDSPACING}, {"V_MONOSPACE",V_MONOSPACE}, - {"V_PURPLEMAP",V_PURPLEMAP}, + + {"V_MAGENTAMAP",V_MAGENTAMAP}, {"V_YELLOWMAP",V_YELLOWMAP}, {"V_GREENMAP",V_GREENMAP}, {"V_BLUEMAP",V_BLUEMAP}, {"V_REDMAP",V_REDMAP}, {"V_GRAYMAP",V_GRAYMAP}, {"V_ORANGEMAP",V_ORANGEMAP}, + {"V_SKYMAP",V_SKYMAP}, + {"V_PURPLEMAP",V_PURPLEMAP}, + {"V_AQUAMAP",V_AQUAMAP}, + {"V_PERIDOTMAP",V_PERIDOTMAP}, + {"V_AZUREMAP",V_AZUREMAP}, + {"V_BROWNMAP",V_BROWNMAP}, + {"V_ROSYMAP",V_ROSYMAP}, + {"V_INVERTMAP",V_INVERTMAP}, + {"V_TRANSLUCENT",V_TRANSLUCENT}, {"V_10TRANS",V_10TRANS}, {"V_20TRANS",V_20TRANS}, @@ -7417,6 +9811,7 @@ struct { {"V_OFFSET",V_OFFSET}, {"V_ALLOWLOWERCASE",V_ALLOWLOWERCASE}, {"V_FLIP",V_FLIP}, + {"V_CENTERNAMETAG",V_CENTERNAMETAG}, {"V_SNAPTOTOP",V_SNAPTOTOP}, {"V_SNAPTOBOTTOM",V_SNAPTOBOTTOM}, {"V_SNAPTOLEFT",V_SNAPTOLEFT}, @@ -7424,7 +9819,7 @@ struct { {"V_WRAPX",V_WRAPX}, {"V_WRAPY",V_WRAPY}, {"V_NOSCALESTART",V_NOSCALESTART}, - {"V_SPLITSCREEN",V_SPLITSCREEN}, + {"V_PERPLAYER",V_PERPLAYER}, {"V_PARAMMASK",V_PARAMMASK}, {"V_SCALEPATCHMASK",V_SCALEPATCHMASK}, @@ -7442,13 +9837,21 @@ struct { {"KR_TIMEOUT",KR_TIMEOUT}, {"KR_BAN",KR_BAN}, {"KR_LEAVE",KR_LEAVE}, -#endif + + // translation colormaps + {"TC_DEFAULT",TC_DEFAULT}, + {"TC_BOSS",TC_BOSS}, + {"TC_METALSONIC",TC_METALSONIC}, + {"TC_ALLWHITE",TC_ALLWHITE}, + {"TC_RAINBOW",TC_RAINBOW}, + {"TC_BLINK",TC_BLINK}, + {"TC_DASHMODE",TC_DASHMODE}, {NULL,0} }; static mobjtype_t get_mobjtype(const char *word) -{ // Returns the vlaue of MT_ enumerations +{ // Returns the value of MT_ enumerations mobjtype_t i; if (*word >= '0' && *word <= '9') return atoi(word); @@ -7464,7 +9867,7 @@ static mobjtype_t get_mobjtype(const char *word) if (fastcmp(word, MOBJTYPE_LIST[i]+3)) return i; deh_warning("Couldn't find mobjtype named 'MT_%s'",word); - return MT_BLUECRAWLA; + return MT_NULL; } static statenum_t get_state(const char *word) @@ -7501,6 +9904,20 @@ static spritenum_t get_sprite(const char *word) return SPR_NULL; } +static playersprite_t get_sprite2(const char *word) +{ // Returns the value of SPR2_ enumerations + playersprite_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("SPR2_",word,5)) + word += 5; // take off the SPR2_ + for (i = 0; i < NUMPLAYERSPRITES; i++) + if (!spr2names[i][4] && memcmp(word,spr2names[i],4)==0) + return i; + deh_warning("Couldn't find sprite named 'SPR2_%s'",word); + return SPR2_STND; +} + static sfxenum_t get_sfx(const char *word) { // Returns the value of SFX_ enumerations sfxenum_t i; @@ -7568,12 +9985,39 @@ static hudnum_t get_huditem(const char *word) if (fastcmp(word, HUDITEMS_LIST[i])) return i; deh_warning("Couldn't find huditem named 'HUD_%s'",word); - return HUD_LIVESNAME; + return HUD_LIVES; +} + +static menutype_t get_menutype(const char *word) +{ // Returns the value of MN_ enumerations + menutype_t i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("MN_",word,3)) + word += 3; // take off the MN_ + for (i = 0; i < NUMMENUTYPES; i++) + if (fastcmp(word, MENUTYPES_LIST[i])) + return i; + deh_warning("Couldn't find menutype named 'MN_%s'",word); + return MN_NONE; +} + +/*static INT16 get_gametype(const char *word) +{ // Returns the value of GT_ enumerations + INT16 i; + if (*word >= '0' && *word <= '9') + return atoi(word); + if (fastncmp("GT_",word,3)) + word += 3; // take off the GT_ + for (i = 0; i < NUMGAMETYPES; i++) + if (fastcmp(word, Gametype_ConstantNames[i]+3)) + return i; + deh_warning("Couldn't find gametype named 'GT_%s'",word); + return GT_COOP; } -#ifndef HAVE_BLUA static powertype_t get_power(const char *word) -{ // Returns the vlaue of pw_ enumerations +{ // Returns the value of pw_ enumerations powertype_t i; if (*word >= '0' && *word <= '9') return atoi(word); @@ -7584,7 +10028,7 @@ static powertype_t get_power(const char *word) return i; deh_warning("Couldn't find power named 'pw_%s'",word); return pw_invulnerability; -} +}*/ /// \todo Make ANY of this completely over-the-top math craziness obey the order of operations. static fixed_t op_mul(fixed_t a, fixed_t b) { return a*b; } @@ -7612,7 +10056,7 @@ struct { }; // Returns the full word, cut at the first symbol or whitespace -static char *read_word(const char *line) +/*static char *read_word(const char *line) { // Part 1: You got the start of the word, now find the end. const char *p; @@ -7767,6 +10211,42 @@ static fixed_t find_const(const char **rword) free(word); return r; } + else if (fastncmp("MN_",word,3)) { + r = get_menutype(word); + free(word); + return r; + } + else if (fastncmp("GT_",word,3)) { + r = get_gametype(word); + free(word); + return r; + } + else if (fastncmp("GTR_", word, 4)) { + char *p = word+4; + for (i = 0; GAMETYPERULE_LIST[i]; i++) + if (fastcmp(p, GAMETYPERULE_LIST[i])) { + free(word); + return (1< 0) - { + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); + + while (n-- > 0) + { s = Z_StrDup(luaL_checkstring(L,1)); type = strtok(s, "_"); if (type) @@ -7881,7 +10373,7 @@ static inline int lib_freeslot(lua_State *L) lua_pushinteger(L, sfx); r++; } else - return r; + CONS_Alert(CONS_WARNING, "Ran out of free SFX slots!\n"); } else if (fastcmp(type, "SPR")) { @@ -7908,7 +10400,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (j > SPR_LASTFREESLOT) - return r; + CONS_Alert(CONS_WARNING, "Ran out of free sprite slots!\n"); } else if (fastcmp(type, "S")) { @@ -7923,7 +10415,7 @@ static inline int lib_freeslot(lua_State *L) break; } if (i == NUMSTATEFREESLOTS) - return r; + CONS_Alert(CONS_WARNING, "Ran out of free State slots!\n"); } else if (fastcmp(type, "MT")) { @@ -7938,7 +10430,48 @@ static inline int lib_freeslot(lua_State *L) break; } if (i == NUMMOBJFREESLOTS) - return r; + CONS_Alert(CONS_WARNING, "Ran out of free MobjType slots!\n"); + } + else if (fastcmp(type, "SPR2")) + { + // Search if we already have an SPR2 by that name... + playersprite_t i; + for (i = SPR2_FIRSTFREESLOT; i < free_spr2; i++) + if (memcmp(spr2names[i],word,4) == 0) + break; + // We don't, so allocate a new one. + if (i >= free_spr2) { + if (free_spr2 < NUMPLAYERSPRITES) + { + CONS_Printf("Sprite SPR2_%s allocated.\n",word); + strncpy(spr2names[free_spr2],word,4); + spr2defaults[free_spr2] = 0; + spr2names[free_spr2++][4] = 0; + } else + CONS_Alert(CONS_WARNING, "Ran out of free SPR2 slots!\n"); + } + r++; + } + else if (fastcmp(type, "TOL")) + { + // Search if we already have a typeoflevel by that name... + int i; + for (i = 0; TYPEOFLEVEL[i].name; i++) + if (fastcmp(word, TYPEOFLEVEL[i].name)) + break; + + // We don't, so allocate a new one. + if (TYPEOFLEVEL[i].name == NULL) { + if (lastcustomtol == (UINT32)MAXTOL) // Unless you have way too many, since they're flags. + CONS_Alert(CONS_WARNING, "Ran out of free typeoflevel slots!\n"); + else { + CONS_Printf("TypeOfLevel TOL_%s allocated.\n",word); + G_AddTOL(lastcustomtol, word); + lua_pushinteger(L, lastcustomtol); + lastcustomtol <<= 1; + r++; + } + } } Z_Free(s); lua_remove(L, 1); @@ -7948,14 +10481,14 @@ static inline int lib_freeslot(lua_State *L) } // Wrapper for ALL A_Action functions. -// Upvalue: actionf_t to represent // Arguments: mobj_t actor, int var1, int var2 -static inline int lib_action(lua_State *L) +static int action_call(lua_State *L) { - actionf_t *action = lua_touserdata(L,lua_upvalueindex(1)); - mobj_t *actor = *((mobj_t **)luaL_checkudata(L,1,META_MOBJ)); - var1 = (INT32)luaL_optinteger(L,2,0); - var2 = (INT32)luaL_optinteger(L,3,0); + //actionf_t *action = lua_touserdata(L,lua_upvalueindex(1)); + actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION)); + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + var1 = (INT32)luaL_optinteger(L, 3, 0); + var2 = (INT32)luaL_optinteger(L, 4, 0); if (!actor) return LUA_ErrInvalid(L, "mobj_t"); action->acp1(actor); @@ -8044,6 +10577,36 @@ static inline int lib_getenum(lua_State *L) if (mathlib) return luaL_error(L, "playerflag '%s' could not be found.\n", word); return 0; } + else if (fastncmp("GT_", word, 3)) { + p = word; + for (i = 0; Gametype_ConstantNames[i]; i++) + if (fastcmp(p, Gametype_ConstantNames[i])) { + lua_pushinteger(L, i); + return 1; + } + if (mathlib) return luaL_error(L, "gametype '%s' could not be found.\n", word); + return 0; + } + else if (fastncmp("GTR_", word, 4)) { + p = word+4; + for (i = 0; GAMETYPERULE_LIST[i]; i++) + if (fastcmp(p, GAMETYPERULE_LIST[i])) { + lua_pushinteger(L, ((lua_Integer)1< return action's string name +static int lib_getActionName(lua_State *L) +{ + if (lua_isuserdata(L, 1)) // arg 1 is built-in action, expect action userdata + { + actionf_t *action = *((actionf_t **)luaL_checkudata(L, 1, META_ACTION)); + const char *name = NULL; + if (!action) + return luaL_error(L, "not a valid action?"); + name = LUA_GetActionName(action); + if (!name) // that can't be right? + return luaL_error(L, "no name string could be found for this action"); + lua_pushstring(L, name); + return 1; + } + else if (lua_isfunction(L, 1)) // arg 1 is a function (either C or Lua) + { + lua_settop(L, 1); // set top of stack to 1 (removing any extra args, which there shouldn't be) + // get the name for this action, if possible. + lua_getfield(L, LUA_REGISTRYINDEX, LREG_ACTIONS); + lua_pushnil(L); + // Lua stack at this point: + // 1 ... -2 -1 + // arg ... LREG_ACTIONS nil + while (lua_next(L, -2)) + { + // Lua stack at this point: + // 1 ... -3 -2 -1 + // arg ... LREG_ACTIONS "A_ACTION" function + if (lua_rawequal(L, -1, 1)) // is this the same as the arg? + { + // make sure the key (i.e. "A_ACTION") is a string first + // (note: we don't use lua_isstring because it also returns true for numbers) + if (lua_type(L, -2) == LUA_TSTRING) + { + lua_pushvalue(L, -2); // push "A_ACTION" string to top of stack + return 1; + } + lua_pop(L, 2); // pop the name and function + break; // probably should have succeeded but we didn't, so end the loop + } + lua_pop(L, 1); + } + lua_pop(L, 1); // pop LREG_ACTIONS + return 0; // return nothing (don't error) + } + + return luaL_typerror(L, 1, "action userdata or Lua function"); +} + + + int LUA_SOCLib(lua_State *L) { lua_register(L,"freeslot",lib_freeslot); + lua_register(L,"getActionName",lib_getActionName); + + luaL_newmetatable(L, META_ACTION); + lua_pushcfunction(L, action_call); + lua_setfield(L, -2, "__call"); + lua_pop(L, 1); + return 0; } @@ -8388,5 +10953,3 @@ void LUA_SetActionByName(void *state, const char *actiontocompare) } } } - -#endif // HAVE_BLUA diff --git a/src/dehacked.h b/src/dehacked.h index 411cb6c1b..54225f36e 100644 --- a/src/dehacked.h +++ b/src/dehacked.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,25 +27,16 @@ typedef enum UNDO_DONE = 0, } undotype_f; -#ifdef DELFILE -void DEH_WriteUndoline(const char *value, const char *data, undotype_f flags); -void DEH_UnloadDehackedWad(UINT16 wad); -#else // null the undo lines -#define DEH_WriteUndoline(a,b,c) -#endif - void DEH_LoadDehackedLump(lumpnum_t lumpnum); -void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump); +void DEH_LoadDehackedLumpPwad(UINT16 wad, UINT16 lump, boolean mainfile); void DEH_Check(void); fixed_t get_number(const char *word); -#ifdef HAVE_BLUA boolean LUA_SetLuaAction(void *state, const char *actiontocompare); const char *LUA_GetActionName(void *action); void LUA_SetActionByName(void *state, const char *actiontocompare); -#endif extern boolean deh_loaded; @@ -54,7 +45,7 @@ extern const char *superactions[MAXRECURSION]; extern UINT8 superstack; // If the dehacked patch does not match this version, we throw a warning -#define PATCHVERSION 210 +#define PATCHVERSION 220 #define MAXLINELEN 1024 diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 52c90aac2..847853a89 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -438,6 +438,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -519,6 +550,7 @@ void I_ResumeSong (INT32 handle) songpaused = false; } + void I_SetMusicVolume(INT32 volume) { if (midi_disabled) @@ -545,3 +577,44 @@ int I_QrySongPlaying(int handle) return (midi_pos==-1); } #endif + +/// ------------------------ +// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} diff --git a/src/djgppdos/i_video.c b/src/djgppdos/i_video.c index 612c72215..02c7a842b 100644 --- a/src/djgppdos/i_video.c +++ b/src/djgppdos/i_video.c @@ -90,10 +90,17 @@ static unsigned long nombre = NEWTICRATE*10; static void I_BlitScreenVesa1(void); //see later void I_FinishUpdate (void) { + // draw captions if enabled + if (cv_closedcaptioning.value) + SCR_ClosedCaptions(); + // draw FPS if enabled if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + //blast it to the screen // this code sucks //memcpy(dascreen,screens[0],screenwidth*screenheight); @@ -331,3 +338,8 @@ void I_StartupGraphics(void) graphics_started = true; } + +void I_StartupHardwareGraphics(void) +{ + // oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo y +} diff --git a/src/djgppdos/rdb-s.h b/src/djgppdos/rdb-s.h index 7a6d8be3c..2d460c935 100644 --- a/src/djgppdos/rdb-s.h +++ b/src/djgppdos/rdb-s.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// Copyright (C) 2005-2018 by Sonic Team Jr. +// Copyright (C) 2005-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/src/djgppdos/vid_vesa.c b/src/djgppdos/vid_vesa.c index ec7b8b886..c8ce7dae5 100644 --- a/src/djgppdos/vid_vesa.c +++ b/src/djgppdos/vid_vesa.c @@ -378,6 +378,11 @@ INT32 VID_SetMode (INT32 modenum) //, UINT8 *palette) return 1; } +void VID_CheckRenderer(void) +{ + // .............. +} + // converts a segm:offs 32bit pair to a 32bit flat ptr diff --git a/src/doomdata.h b/src/doomdata.h index ff025e99c..c2ee50c2e 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -46,6 +46,9 @@ enum ML_BLOCKMAP, // LUT, motion clipping, walls/grid element }; +// Extra flag for objects. +#define MTF_EXTRA 1 + // Reverse gravity flag for objects. #define MTF_OBJECTFLIP 2 @@ -127,11 +130,9 @@ typedef struct #define ML_EFFECT4 512 #define ML_EFFECT5 1024 -// New ones to disable lines for characters -#define ML_NOSONIC 2048 -#define ML_NOTAILS 4096 -#define ML_NOKNUX 8192 -#define ML_NETONLY 14336 // all of the above +#define ML_NETONLY 2048 // Apply effect only in netgames +#define ML_NONET 4096 // Apply effect only in single player games +#define ML_EFFECT6 8192 // Bounce off walls! #define ML_BOUNCY 16384 @@ -207,8 +208,9 @@ typedef struct #define ZSHIFT 4 -extern const char *Color_Names[MAXSKINCOLORS]; -extern const UINT8 Color_Opposite[MAXSKINCOLORS*2]; +extern const UINT8 Color_Index[MAXTRANSLATIONS-1][16]; +extern const char *Color_Names[MAXSKINCOLORS + NUMSUPERCOLORS]; +extern const UINT8 Color_Opposite[MAXSKINCOLORS - 1][2]; #define NUMMAPS 1035 diff --git a/src/doomdef.h b/src/doomdef.h index 527cdf05f..71c885019 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,13 +28,11 @@ // Use Mixer interface? #ifdef HAVE_MIXER - //#if !defined(DC) && !defined(_WIN32_WCE) && !defined(_XBOX) && !defined(GP2X) #define SOUND SOUND_MIXER #define NOHS // No HW3SOUND #ifdef HW3SOUND #undef HW3SOUND #endif - //#endif #endif // Use generic SDL interface. @@ -70,7 +68,7 @@ #endif #endif -#if defined (_WIN32) || defined (_WIN32_WCE) +#ifdef _WIN32 #define ASMCALL __cdecl #else #define ASMCALL @@ -87,13 +85,6 @@ // warning C4152: nonstandard extension, function/data pointer conversion in expression // warning C4213: nonstandard extension used : cast on l-value -#if defined (_WIN32_WCE) && defined (DEBUG) && defined (ARM) -#if defined (ARMV4) || defined (ARMV4I) -//#pragma warning(disable : 1166) -// warning LNK1166: cannot adjust code at offset= -#endif -#endif - #include "doomtype.h" @@ -107,16 +98,14 @@ #ifdef GETTEXT #include -#include #endif +#include // locale should not be dependent on GETTEXT -- 11/01/20 Monster Iestyn -#if !defined (_WIN32_WCE) #include #include -#endif #include -#if ((defined (_WIN32) && !defined (_WIN32_WCE)) || defined (__DJGPP__)) && !defined (_XBOX) +#if defined (_WIN32) || defined (__DJGPP__) #include #endif @@ -138,8 +127,12 @@ #ifdef LOGMESSAGES extern FILE *logstream; +extern char logfilename[1024]; #endif +/* A mod name to further distinguish versions. */ +#define SRB2APPLICATION "SRB2" + //#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3 #ifdef DEVELOP #define VERSION 0 // Game version @@ -149,10 +142,10 @@ extern FILE *logstream; // most interface strings are ignored in development mode. // we use comprevision and compbranch instead. #else -#define VERSION 201 // Game version -#define SUBVERSION 23 // more precise version number -#define VERSIONSTRING "v2.1.23" -#define VERSIONSTRINGW L"v2.1.23" +#define VERSION 202 // Game version +#define SUBVERSION 2 // more precise version number +#define VERSIONSTRING "v2.2.2" +#define VERSIONSTRINGW L"v2.2.2" // Hey! If you change this, add 1 to the MODVERSION below! // Otherwise we can't force updates! #endif @@ -206,18 +199,18 @@ extern FILE *logstream; // and should not be changed unless you have merged changes between versions of SRB2 // (such as 2.0.4 to 2.0.5, etc) into your working copy. // Will always resemble the versionstring, 205 = 2.0.5, 210 = 2.1, etc. -#define CODEBASE 210 +#define CODEBASE 220 // The Modification ID; must be obtained from Rob ( https://mb.srb2.org/private.php?do=newpm&u=546 ). // DO NOT try to set this otherwise, or your modification will be unplayable through the Master Server. -// "12" is the default mod ID for version 2.1 -#define MODID 12 +// "18" is the default mod ID for version 2.2 +#define MODID 18 // The Modification Version, starting from 1. Do not follow your version string for this, // it's only for detection of the version the player is using so the MS can alert them of an update. // Only set it higher, not lower, obviously. -// Note that we use this to help keep internal testing in check; this is why v2.1.0 is not version "1". -#define MODVERSION 28 +// Note that we use this to help keep internal testing in check; this is why v2.2.0 is not version "1". +#define MODVERSION 42 // To version config.cfg, MAJOREXECVERSION is set equal to MODVERSION automatically. // Increment MINOREXECVERSION whenever a config change is needed that does not correspond @@ -239,64 +232,149 @@ extern FILE *logstream; // NOTE: it needs more than this to increase the number of players... #define MAXPLAYERS 32 -#define MAXSKINS MAXPLAYERS +#define MAXSKINS 32 #define PLAYERSMASK (MAXPLAYERS-1) #define MAXPLAYERNAME 21 typedef enum { SKINCOLOR_NONE = 0, - SKINCOLOR_WHITE, - SKINCOLOR_SILVER, - SKINCOLOR_GREY, - SKINCOLOR_BLACK, - SKINCOLOR_CYAN, - SKINCOLOR_TEAL, - SKINCOLOR_STEELBLUE, - SKINCOLOR_BLUE, - SKINCOLOR_PEACH, - SKINCOLOR_TAN, - SKINCOLOR_PINK, - SKINCOLOR_LAVENDER, - SKINCOLOR_PURPLE, - SKINCOLOR_ORANGE, - SKINCOLOR_ROSEWOOD, - SKINCOLOR_BEIGE, - SKINCOLOR_BROWN, - SKINCOLOR_RED, - SKINCOLOR_DARKRED, - SKINCOLOR_NEONGREEN, - SKINCOLOR_GREEN, - SKINCOLOR_ZIM, - SKINCOLOR_OLIVE, - SKINCOLOR_YELLOW, - SKINCOLOR_GOLD, - // Careful! MAXSKINCOLORS cannot be greater than 0x20! + // Greyscale ranges + SKINCOLOR_WHITE, + SKINCOLOR_BONE, + SKINCOLOR_CLOUDY, + SKINCOLOR_GREY, + SKINCOLOR_SILVER, + SKINCOLOR_CARBON, + SKINCOLOR_JET, + SKINCOLOR_BLACK, + + // Desaturated + SKINCOLOR_AETHER, + SKINCOLOR_SLATE, + SKINCOLOR_BLUEBELL, + SKINCOLOR_PINK, + SKINCOLOR_YOGURT, + SKINCOLOR_BROWN, + SKINCOLOR_BRONZE, + SKINCOLOR_TAN, + SKINCOLOR_BEIGE, + SKINCOLOR_MOSS, + SKINCOLOR_AZURE, + SKINCOLOR_LAVENDER, + + // Viv's vivid colours (toast 21/07/17) + SKINCOLOR_RUBY, + SKINCOLOR_SALMON, + SKINCOLOR_RED, + SKINCOLOR_CRIMSON, + SKINCOLOR_FLAME, + SKINCOLOR_KETCHUP, + SKINCOLOR_PEACHY, + SKINCOLOR_QUAIL, + SKINCOLOR_SUNSET, + SKINCOLOR_COPPER, + SKINCOLOR_APRICOT, + SKINCOLOR_ORANGE, + SKINCOLOR_RUST, + SKINCOLOR_GOLD, + SKINCOLOR_SANDY, + SKINCOLOR_YELLOW, + SKINCOLOR_OLIVE, + SKINCOLOR_LIME, + SKINCOLOR_PERIDOT, + SKINCOLOR_APPLE, + SKINCOLOR_GREEN, + SKINCOLOR_FOREST, + SKINCOLOR_EMERALD, + SKINCOLOR_MINT, + SKINCOLOR_SEAFOAM, + SKINCOLOR_AQUA, + SKINCOLOR_TEAL, + SKINCOLOR_WAVE, + SKINCOLOR_CYAN, + SKINCOLOR_SKY, + SKINCOLOR_CERULEAN, + SKINCOLOR_ICY, + SKINCOLOR_SAPPHIRE, // sweet mother, i cannot weave – slender aphrodite has overcome me with longing for a girl + SKINCOLOR_CORNFLOWER, + SKINCOLOR_BLUE, + SKINCOLOR_COBALT, + SKINCOLOR_VAPOR, + SKINCOLOR_DUSK, + SKINCOLOR_PASTEL, + SKINCOLOR_PURPLE, + SKINCOLOR_BUBBLEGUM, + SKINCOLOR_MAGENTA, + SKINCOLOR_NEON, + SKINCOLOR_VIOLET, + SKINCOLOR_LILAC, + SKINCOLOR_PLUM, + SKINCOLOR_RASPBERRY, + SKINCOLOR_ROSY, + + // SKINCOLOR_? - one left before we bump up against 0x39, which isn't a HARD limit anymore but would be excessive + MAXSKINCOLORS, // Super special awesome Super flashing colors! - SKINCOLOR_SUPER1 = MAXSKINCOLORS, - SKINCOLOR_SUPER2, - SKINCOLOR_SUPER3, - SKINCOLOR_SUPER4, - SKINCOLOR_SUPER5, + SKINCOLOR_SUPERSILVER1 = MAXSKINCOLORS, + SKINCOLOR_SUPERSILVER2, + SKINCOLOR_SUPERSILVER3, + SKINCOLOR_SUPERSILVER4, + SKINCOLOR_SUPERSILVER5, - // Super Tails - SKINCOLOR_TSUPER1, - SKINCOLOR_TSUPER2, - SKINCOLOR_TSUPER3, - SKINCOLOR_TSUPER4, - SKINCOLOR_TSUPER5, + SKINCOLOR_SUPERRED1, + SKINCOLOR_SUPERRED2, + SKINCOLOR_SUPERRED3, + SKINCOLOR_SUPERRED4, + SKINCOLOR_SUPERRED5, - // Super Knuckles - SKINCOLOR_KSUPER1, - SKINCOLOR_KSUPER2, - SKINCOLOR_KSUPER3, - SKINCOLOR_KSUPER4, - SKINCOLOR_KSUPER5, + SKINCOLOR_SUPERORANGE1, + SKINCOLOR_SUPERORANGE2, + SKINCOLOR_SUPERORANGE3, + SKINCOLOR_SUPERORANGE4, + SKINCOLOR_SUPERORANGE5, - MAXTRANSLATIONS + SKINCOLOR_SUPERGOLD1, + SKINCOLOR_SUPERGOLD2, + SKINCOLOR_SUPERGOLD3, + SKINCOLOR_SUPERGOLD4, + SKINCOLOR_SUPERGOLD5, + + SKINCOLOR_SUPERPERIDOT1, + SKINCOLOR_SUPERPERIDOT2, + SKINCOLOR_SUPERPERIDOT3, + SKINCOLOR_SUPERPERIDOT4, + SKINCOLOR_SUPERPERIDOT5, + + SKINCOLOR_SUPERSKY1, + SKINCOLOR_SUPERSKY2, + SKINCOLOR_SUPERSKY3, + SKINCOLOR_SUPERSKY4, + SKINCOLOR_SUPERSKY5, + + SKINCOLOR_SUPERPURPLE1, + SKINCOLOR_SUPERPURPLE2, + SKINCOLOR_SUPERPURPLE3, + SKINCOLOR_SUPERPURPLE4, + SKINCOLOR_SUPERPURPLE5, + + SKINCOLOR_SUPERRUST1, + SKINCOLOR_SUPERRUST2, + SKINCOLOR_SUPERRUST3, + SKINCOLOR_SUPERRUST4, + SKINCOLOR_SUPERRUST5, + + SKINCOLOR_SUPERTAN1, + SKINCOLOR_SUPERTAN2, + SKINCOLOR_SUPERTAN3, + SKINCOLOR_SUPERTAN4, + SKINCOLOR_SUPERTAN5, + + MAXTRANSLATIONS, + NUMSUPERCOLORS = ((MAXTRANSLATIONS - MAXSKINCOLORS)/5) } skincolors_t; // State updates, number of tics / second. @@ -305,27 +383,35 @@ typedef enum #define NEWTICRATERATIO 1 // try 4 for 140 fps :) #define NEWTICRATE (TICRATE*NEWTICRATERATIO) +#define MUSICRATE 1000 // sound timing is calculated by milliseconds + #define RING_DIST 512*FRACUNIT // how close you need to be to a ring to attract it #define PUSHACCEL (2*FRACUNIT) // Acceleration for MF2_SLIDEPUSH items. // Special linedef executor tag numbers! enum { - LE_PINCHPHASE = -2, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!) - LE_ALLBOSSESDEAD = -3, // All bosses in the map are dead (Egg capsule raise) - LE_BOSSDEAD = -4, // A boss in the map died (Chaos mode boss tally) - LE_BOSS4DROP = -5, // CEZ boss dropped its cage - LE_BRAKVILEATACK = -6 // Brak's doing his LOS attack, oh noes + LE_PINCHPHASE = -2, // A boss entered pinch phase (and, in most cases, is preparing their pinch phase attack!) + LE_ALLBOSSESDEAD = -3, // All bosses in the map are dead (Egg capsule raise) + LE_BOSSDEAD = -4, // A boss in the map died (Chaos mode boss tally) + LE_BOSS4DROP = -5, // CEZ boss dropped its cage (also subtract the number of hitpoints it's lost) + LE_BRAKVILEATACK = -6, // Brak's doing his LOS attack, oh noes + LE_TURRET = 32000, // THZ turret + LE_BRAKPLATFORM = 4200, // v2.0 Black Eggman destroys platform + LE_CAPSULE2 = 682, // Egg Capsule + LE_CAPSULE1 = 681, // Egg Capsule + LE_CAPSULE0 = 680, // Egg Capsule + LE_KOOPA = 650, // Distant cousin to Gay Bowser + LE_AXE = 649, // MKB Axe object + LE_PARAMWIDTH = -100 // If an object that calls LinedefExecute has a nonzero parameter value, this times the parameter will be subtracted. (Mostly for the purpose of coexisting bosses...) }; // Name of local directory for config files and savegames -#if !defined(_arch_dreamcast) && !defined(_WIN32_WCE) && !defined(GP2X) && !defined(_WII) && !defined(_PS3) #if (((defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON)) && !defined (__CYGWIN__)) && !defined (__APPLE__) #define DEFAULTDIR ".srb2" #else #define DEFAULTDIR "srb2" #endif -#endif #include "g_state.h" @@ -374,15 +460,18 @@ char savegamename[256]; // m_misc.h #ifdef GETTEXT #define M_GetText(String) gettext(String) -void M_StartupLocale(void); #else // If no translations are to be used, make a stub // M_GetText function that just returns the string. #define M_GetText(x) (x) #endif +void M_StartupLocale(void); extern void *(*M_Memcpy)(void* dest, const void* src, size_t n) FUNCNONNULL; char *va(const char *format, ...) FUNCPRINTF; char *M_GetToken(const char *inputString); +void M_UnGetToken(void); +UINT32 M_GetTokenPos(void); +void M_SetTokenPos(UINT32 newPos); char *sizeu1(size_t num); char *sizeu2(size_t num); char *sizeu3(size_t num); @@ -396,7 +485,7 @@ extern INT32 cv_debug; #define DBG_BASIC 0x0001 #define DBG_DETAILED 0x0002 -#define DBG_RANDOMIZER 0x0004 +#define DBG_PLAYER 0x0004 #define DBG_RENDER 0x0008 #define DBG_NIGHTSBASIC 0x0010 #define DBG_NIGHTS 0x0020 @@ -406,17 +495,22 @@ extern INT32 cv_debug; #define DBG_MEMORY 0x0200 #define DBG_SETUP 0x0400 #define DBG_LUA 0x0800 +#define DBG_RANDOMIZER 0x1000 +#define DBG_VIEWMORPH 0x2000 // ======================= // Misc stuff for later... // ======================= +#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180) + // Modifier key variables, accessible anywhere extern UINT8 shiftdown, ctrldown, altdown; extern boolean capslock; // if we ever make our alloc stuff... #define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL) +#define ZZ_Calloc(x) Z_Calloc(x, PU_STATIC, NULL) // i_system.c, replace getchar() once the keyboard has been appropriated INT32 I_GetKey(void); @@ -428,13 +522,20 @@ INT32 I_GetKey(void); #define max(x, y) (((x) > (y)) ? (x) : (y)) #endif +// Max gamepad/joysticks that can be detected/used. +#define MAX_JOYSTICKS 4 + +#ifndef M_PIl +#define M_PIl 3.1415926535897932384626433832795029L +#endif + // Floating point comparison epsilons from float.h #ifndef FLT_EPSILON #define FLT_EPSILON 1.1920928955078125e-7f #endif #ifndef DBL_EPSILON -#define DBL_EPSILON 2.2204460492503131e-16 +#define DBL_EPSILON 2.2204460492503131e-16l #endif // An assert-type mechanism. @@ -452,6 +553,8 @@ INT32 I_GetKey(void); #define PATHSEP "/" #endif +#define PUNCTUATION "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" + // Compile date and time and revision. extern const char *compdate, *comptime, *comprevision, *compbranch; @@ -468,10 +571,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #define ESLOPE_TYPESHIM #endif -/// Delete file while the game is running. -/// \note EXTREMELY buggy, tends to crash game. -//#define DELFILE - /// Allows the use of devmode in multiplayer. AKA "fishcake" //#define NETGAME_DEVMODE @@ -484,9 +583,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Polyobject fake flat code #define POLYOBJECTS_PLANES -/// Improved way of dealing with ping values and a ping limit. -#define NEWPING - /// See name of player in your crosshair #define SEENAMES @@ -499,19 +595,15 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Most modifications should probably enable this. //#define SAVEGAME_OTHERVERSIONS -#if !defined (_NDS) && !defined (_PSP) /// Shuffle's incomplete OpenGL sorting code. #define SHUFFLE // This has nothing to do with sorting, why was it disabled? -#endif -#if !defined (_NDS) && !defined (_PSP) /// Allow the use of the SOC RESETINFO command. /// \note Builds that are tight on memory should disable this. /// This stops the game from storing backups of the states, sprites, and mobjinfo tables. /// Though this info is compressed under normal circumstances, it's still a lot of extra /// memory that never gets touched. #define ALLOW_RESETDATA -#endif #ifndef NONET /// Display a connection screen on join attempts. @@ -525,9 +617,8 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// \note You should leave this enabled unless you're working with a future SRB2 version. #define MUSICSLOT_COMPATIBILITY -/// Handle touching sector specials in P_PlayerAfterThink instead of P_PlayerThink. -/// \note Required for proper collision with moving sloped surfaces that have sector specials on them. -//#define SECTORSPECIALSAFTERTHINK +/// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls. +//#define PAPER_COLLISIONCORRECTION /// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up /// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down) @@ -536,4 +627,31 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// SRB2CB itself ported this from PrBoom+ #define NEWCLIP +/// Handle touching sector specials in P_PlayerAfterThink instead of P_PlayerThink. +/// \note Required for proper collision with moving sloped surfaces that have sector specials on them. +#define SECTORSPECIALSAFTERTHINK + +/// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up +/// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down) +/// on the bright side it fixes some weird issues with translucent walls +/// \note SRB2CB port. +/// SRB2CB itself ported this from PrBoom+ +#define NEWCLIP + +/// Cache patches in Lua in a way that renderer switching will work flawlessly. +//#define LUA_PATCH_SAFETY + +/// Sprite rotation +#define ROTSPRITE +#define ROTANGLES 72 // Needs to be a divisor of 360 (45, 60, 90, 120...) +#define ROTANGDIFF (360 / ROTANGLES) + +/// PNG support +#ifndef HAVE_PNG +#define NO_PNG_LUMPS +#endif + +/// Render flats on walls +#define WALLFLATS + #endif // __DOOMDEF__ diff --git a/src/doomstat.h b/src/doomstat.h index d37ae440a..893514b32 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -33,17 +33,24 @@ extern INT16 gamemap; extern char mapmusname[7]; extern UINT16 mapmusflags; +extern UINT32 mapmusposition; #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- +#define MUSIC_FORCERESET 0x4000 // -*-------------- // Use other bits if necessary. -extern INT16 maptol; +extern UINT32 maptol; extern UINT8 globalweather; extern INT32 curWeather; extern INT32 cursaveslot; -extern INT16 lastmapsaved; +//extern INT16 lastmapsaved; +extern INT16 lastmaploaded; extern boolean gamecomplete; +#define maxgameovers 13 +extern UINT8 numgameovers; +extern SINT8 startinglivesbalance[maxgameovers+1]; + #define PRECIP_NONE 0 #define PRECIP_STORM 1 #define PRECIP_SNOW 2 @@ -77,6 +84,9 @@ extern boolean addedtogame; // true after the server has added you extern boolean multiplayer; extern INT16 gametype; +extern UINT32 gametyperules; +extern INT16 gametypecount; + extern boolean splitscreen; extern boolean circuitmap; // Does this level have 'circuit mode'? extern boolean fromlevelselect; @@ -118,17 +128,28 @@ extern INT32 secondarydisplayplayer; // for splitscreen // Maps of special importance extern INT16 spstage_start; -extern INT16 sstage_start; -extern INT16 sstage_end; +extern INT16 sstage_start, sstage_end, smpstage_start, smpstage_end; + +extern INT16 titlemap; +extern boolean hidetitlepics; +extern INT16 bootmap; //bootmap for loading a map on startup + +extern INT16 tutorialmap; // map to load for tutorial +extern boolean tutorialmode; // are we in a tutorial right now? +extern INT32 tutorialgcs; // which control scheme is loaded? +extern INT32 tutorialusemouse; // store cv_usemouse user value +extern INT32 tutorialfreelook; // store cv_alwaysfreelook user value +extern INT32 tutorialmousemove; // store cv_mousemove user value +extern INT32 tutorialanalog; // store cv_analog[0] user value extern boolean looptitle; -extern boolean useNightsSS; // CTF colors. extern UINT8 skincolor_redteam, skincolor_blueteam, skincolor_redring, skincolor_bluering; extern tic_t countdowntimer; extern boolean countdowntimeup; +extern boolean exitfadestarted; typedef struct { @@ -145,6 +166,7 @@ typedef struct char musswitch[7]; UINT16 musswitchflags; + UINT32 musswitchposition; UINT8 fadecolor; // Color number for fade, 0 means don't do the first fade UINT8 fadeinid; // ID of the first fade, to a color -- ignored if fadecolor is 0 @@ -159,11 +181,65 @@ typedef struct extern cutscene_t *cutscenes[128]; +// Reserve prompt space for tutorials +#define TUTORIAL_PROMPT 201 // one-based +#define TUTORIAL_AREAS 6 +#define TUTORIAL_AREA_PROMPTS 5 +#define MAX_PROMPTS (TUTORIAL_PROMPT+TUTORIAL_AREAS*TUTORIAL_AREA_PROMPTS*3) // 3 control modes +#define MAX_PAGES 128 + +#define PROMPT_PIC_PERSIST 0 +#define PROMPT_PIC_LOOP 1 +#define PROMPT_PIC_DESTROY 2 +#define MAX_PROMPT_PICS 8 +typedef struct +{ + UINT8 numpics; + UINT8 picmode; // sequence mode after displaying last pic, 0 = persist, 1 = loop, 2 = destroy + UINT8 pictoloop; // if picmode == loop, which pic to loop to? + UINT8 pictostart; // initial pic number to show + char picname[MAX_PROMPT_PICS][8]; + UINT8 pichires[MAX_PROMPT_PICS]; + UINT16 xcoord[MAX_PROMPT_PICS]; // gfx + UINT16 ycoord[MAX_PROMPT_PICS]; // gfx + UINT16 picduration[MAX_PROMPT_PICS]; + + char musswitch[7]; + UINT16 musswitchflags; + UINT8 musicloop; + + char tag[33]; // page tag + char name[34]; // narrator name, extra char for color + char iconname[8]; // narrator icon lump + boolean rightside; // narrator side, false = left, true = right + boolean iconflip; // narrator flip icon horizontally + UINT8 hidehud; // hide hud, 0 = show all, 1 = hide depending on prompt position (top/bottom), 2 = hide all + UINT8 lines; // # of lines to show. If name is specified, name takes one of the lines. If 0, defaults to 4. + INT32 backcolor; // see CON_SetupBackColormap: 0-11, INT32_MAX for user-defined (CONS_BACKCOLOR) + UINT8 align; // text alignment, 0 = left, 1 = right, 2 = center + UINT8 verticalalign; // vertical text alignment, 0 = top, 1 = bottom, 2 = middle + UINT8 textspeed; // text speed, delay in tics between characters. + sfxenum_t textsfx; // sfx_ id for printing text + UINT8 nextprompt; // next prompt to jump to, one-based. 0 = current prompt + UINT8 nextpage; // next page to jump to, one-based. 0 = next page within prompt->numpages + char nexttag[33]; // next tag to jump to. If set, this overrides nextprompt and nextpage. + INT32 timetonext; // time in tics to jump to next page automatically. 0 = don't jump automatically + char *text; +} textpage_t; + +typedef struct +{ + textpage_t page[MAX_PAGES]; + INT32 numpages; // Number of pages in this prompt +} textprompt_t; + +extern textprompt_t *textprompts[MAX_PROMPTS]; + // For the Custom Exit linedef. extern INT16 nextmapoverride; -extern boolean skipstats; +extern UINT8 skipstats; -extern UINT32 totalrings; // Total # of rings in a level +extern UINT32 ssspheres; // Total # of spheres in a level // Fun extra stuff extern INT16 lastmap; // Last level you were at (returning from special stages). @@ -211,10 +287,12 @@ typedef struct char lvlttl[22]; ///< Level name without "Zone". (21 character limit instead of 32, 21 characters can display on screen max anyway) char subttl[33]; ///< Subtitle for level UINT8 actnum; ///< Act number or 0 for none. - UINT16 typeoflevel; ///< Combination of typeoflevel flags. + UINT32 typeoflevel; ///< Combination of typeoflevel flags. INT16 nextlevel; ///< Map number of next level, or 1100-1102 to end. + char keywords[33]; ///< Keywords separated by space to search for. 32 characters. char musname[7]; ///< Music track to play. "" for no music. UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. + UINT32 muspos; ///< Music position to jump to. char forcecharacter[17]; ///< (SKINNAMESIZE+1) Skin to switch to or "" to disable. UINT8 weather; ///< 0 = sunny day, 1 = storm, 2 = snow, 3 = rain, 4 = blank, 5 = thunder w/o rain, 6 = rain w/o lightning, 7 = heat wave. INT16 skynum; ///< Sky number to use. @@ -234,15 +312,38 @@ typedef struct SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no. UINT8 levelselect; ///< Is this map available in the level select? If so, which map list is it available in? SINT8 bonustype; ///< What type of bonus does this level have? (-1 for null.) - SINT8 saveoverride; ///< Set how the game is allowed to save (1 for always, -1 for never, 0 is 2.1 default) + SINT8 maxbonuslives; ///< How many bonus lives to award at Intermission? (-1 for unlimited.) - UINT8 levelflags; ///< LF_flags: merged eight booleans into one UINT8 for space, see below + UINT16 levelflags; ///< LF_flags: merged booleans into one UINT16 for space, see below UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus + char selectheading[22]; ///< Level select heading. Allows for controllable grouping. + UINT16 startrings; ///< Number of rings players start with. + + // Title card. + char ltzzpatch[8]; ///< Zig zag patch. + char ltzztext[8]; ///< Zig zag text. + char ltactdiamond[8]; ///< Act diamond. + + // Freed animals stuff. + UINT8 numFlickies; ///< Internal. For freed flicky support. + mobjtype_t *flickies; ///< List of freeable flickies in this level. Allocated dynamically for space reasons. Be careful. + // NiGHTS stuff. UINT8 numGradedMares; ///< Internal. For grade support. nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful. + // Music stuff. + UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds + char musintername[7]; ///< Intermission screen music. + + char muspostbossname[7]; ///< Post-bossdeath music. + UINT16 muspostbosstrack; ///< Post-bossdeath track. + UINT32 muspostbosspos; ///< Post-bossdeath position + UINT32 muspostbossfadein; ///< Post-bossdeath fade-in milliseconds. + + SINT8 musforcereset; ///< Force resetmusic (-1 for default; 0 for force off; 1 for force on) + // Lua stuff. // (This is not ifdeffed so the map header structure can stay identical, just in case.) UINT8 numCustomOptions; ///< Internal. For Lua custom value support. @@ -250,25 +351,97 @@ typedef struct } mapheader_t; // level flags -#define LF_SCRIPTISFILE 1 ///< True if the script is a file, not a lump. -#define LF_SPEEDMUSIC 2 ///< Speed up act music for super sneakers -#define LF_NOSSMUSIC 4 ///< Disable Super Sonic music -#define LF_NORELOAD 8 ///< Don't reload level on death -#define LF_NOZONE 16 ///< Don't include "ZONE" on level title +#define LF_SCRIPTISFILE (1<<0) ///< True if the script is a file, not a lump. +#define LF_SPEEDMUSIC (1<<1) ///< Speed up act music for super sneakers +#define LF_NOSSMUSIC (1<<2) ///< Disable Super Sonic music +#define LF_NORELOAD (1<<3) ///< Don't reload level on death +#define LF_NOZONE (1<<4) ///< Don't include "ZONE" on level title +#define LF_SAVEGAME (1<<5) ///< Save the game upon loading this level +#define LF_MIXNIGHTSCOUNTDOWN (1<<6) ///< Play sfx_timeup instead of music change for NiGHTS countdown +#define LF_WARNINGTITLE (1<<7) ///< WARNING! WARNING! WARNING! WARNING! + +#define LF_NOTITLECARDFIRST (1<<8) +#define LF_NOTITLECARDRESPAWN (1<<9) +#define LF_NOTITLECARDRECORDATTACK (1<<10) +#define LF_NOTITLECARD (LF_NOTITLECARDFIRST|LF_NOTITLECARDRESPAWN|LF_NOTITLECARDRECORDATTACK) ///< Don't start the title card at all #define LF2_HIDEINMENU 1 ///< Hide in the multiplayer menu #define LF2_HIDEINSTATS 2 ///< Hide in the statistics screen #define LF2_RECORDATTACK 4 ///< Show this map in Time Attack #define LF2_NIGHTSATTACK 8 ///< Show this map in NiGHTS mode menu #define LF2_NOVISITNEEDED 16 ///< Available in time attack/nights mode without visiting the level - -// Save override -#define SAVE_NEVER -1 -#define SAVE_DEFAULT 0 -#define SAVE_ALWAYS 1 +#define LF2_WIDEICON 32 ///< If you're in a circumstance where it fits, use a wide map icon extern mapheader_t* mapheaderinfo[NUMMAPS]; +// Gametypes +#define NUMGAMETYPEFREESLOTS 128 +enum GameType +{ + GT_COOP = 0, // also used in single player + GT_COMPETITION, // Classic "Race" + GT_RACE, + + GT_MATCH, + GT_TEAMMATCH, + + GT_TAG, + GT_HIDEANDSEEK, + + GT_CTF, // capture the flag + + GT_FIRSTFREESLOT, + GT_LASTFREESLOT = GT_FIRSTFREESLOT + NUMGAMETYPEFREESLOTS - 1, + NUMGAMETYPES +}; +// If you alter this list, update dehacked.c, MISC_ChangeGameTypeMenu in m_menu.c, and Gametype_Names in g_game.c + +// Gametype rules +enum GameTypeRules +{ + GTR_CAMPAIGN = 1, // Linear Co-op map progression, don't allow random maps + GTR_RINGSLINGER = 1<<1, // Outside of Co-op, Competition, and Race (overriden by cv_ringslinger) + GTR_SPECTATORS = 1<<2, // Outside of Co-op, Competition, and Race + GTR_LIVES = 1<<3, // Co-op and Competition + GTR_TEAMS = 1<<4, // Team Match, CTF + GTR_FIRSTPERSON = 1<<5, // First person camera + GTR_POWERSTONES = 1<<6, // Power stones (Match and CTF) + GTR_TEAMFLAGS = 1<<7, // Gametype has team flags (CTF) + GTR_FRIENDLY = 1<<8, // Co-op + GTR_SPECIALSTAGES = 1<<9, // Allow special stages + GTR_EMERALDTOKENS = 1<<10, // Spawn emerald tokens + GTR_EMERALDHUNT = 1<<11, // Emerald Hunt + GTR_RACE = 1<<12, // Race and Competition + GTR_TAG = 1<<13, // Tag and Hide and Seek + GTR_POINTLIMIT = 1<<14, // Ringslinger point limit + GTR_TIMELIMIT = 1<<15, // Ringslinger time limit + GTR_OVERTIME = 1<<16, // Allow overtime + GTR_HURTMESSAGES = 1<<17, // Hit and death messages + GTR_FRIENDLYFIRE = 1<<18, // Always allow friendly fire + GTR_STARTCOUNTDOWN = 1<<19, // Hide time countdown (Tag and Hide and Seek) + GTR_HIDEFROZEN = 1<<20, // Frozen after hide time (Hide and Seek, but not Tag) + GTR_BLINDFOLDED = 1<<21, // Blindfolded view (Tag and Hide and Seek) + GTR_RESPAWNDELAY = 1<<22, // Respawn delay + GTR_PITYSHIELD = 1<<23, // Award pity shield + GTR_DEATHPENALTY = 1<<24, // Death score penalty + GTR_NOSPECTATORSPAWN = 1<<25, // Use with GTR_SPECTATORS, spawn in the map instead of with the spectators + GTR_DEATHMATCHSTARTS = 1<<26, // Use deathmatch starts + GTR_SPAWNINVUL = 1<<27, // Babysitting deterrent + GTR_SPAWNENEMIES = 1<<28, // Spawn enemies + GTR_ALLOWEXIT = 1<<29, // Allow exit sectors + GTR_NOTITLECARD = 1<<30, // Don't show the title card + GTR_CUTSCENES = 1<<31, // Play cutscenes, ending, credits, and evaluation +}; + +// String names for gametypes +extern const char *Gametype_Names[NUMGAMETYPES]; +extern const char *Gametype_ConstantNames[NUMGAMETYPES]; + +// Point and time limits for every gametype +extern INT32 pointlimits[NUMGAMETYPES]; +extern INT32 timelimits[NUMGAMETYPES]; + +// TypeOfLevel things enum TypeOfLevel { TOL_SP = 0x01, ///< Single Player @@ -284,33 +457,26 @@ enum TypeOfLevel TOL_CTF = 0x40, ///< Capture the Flag // CTF default = 64 - TOL_CUSTOM = 0x80, ///< Custom (Lua-scripted, etc.) + // 0x80 was here TOL_2D = 0x0100, ///< 2D TOL_MARIO = 0x0200, ///< Mario TOL_NIGHTS = 0x0400, ///< NiGHTS TOL_ERZ3 = 0x0800, ///< ERZ3 - TOL_XMAS = 0x1000 ///< Christmas NiGHTS + TOL_XMAS = 0x1000, ///< Christmas NiGHTS }; -// Gametypes -enum GameType +#define MAXTOL (1<<31) +#define NUMBASETOLNAMES (19) +#define NUMTOLNAMES (NUMBASETOLNAMES + NUMGAMETYPEFREESLOTS) + +typedef struct { - GT_COOP = 0, // also used in single player - GT_COMPETITION, // Classic "Race" - GT_RACE, - - GT_MATCH, - GT_TEAMMATCH, - - GT_TAG, - GT_HIDEANDSEEK, - - GT_CTF, // capture the flag - - NUMGAMETYPES -}; -// If you alter this list, update gametype_cons_t in m_menu.c + const char *name; + UINT32 flag; +} tolinfo_t; +extern tolinfo_t TYPEOFLEVEL[NUMTOLNAMES]; +extern UINT32 lastcustomtol; extern tic_t totalplaytime; @@ -327,6 +493,9 @@ extern UINT16 emeralds; #define EMERALD7 64 #define ALL7EMERALDS(v) ((v & (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7)) == (EMERALD1|EMERALD2|EMERALD3|EMERALD4|EMERALD5|EMERALD6|EMERALD7)) +#define NUM_LUABANKS 16 // please only make this number go up between versions, never down. you'll break saves otherwise. also, must fit in UINT8 +extern INT32 luabanks[NUM_LUABANKS]; + extern INT32 nummaprings; //keep track of spawned rings/coins /** Time attack information, currently a very small structure. @@ -367,7 +536,9 @@ extern recorddata_t *mainrecords[NUMMAPS]; #define MV_ALLEMERALDS 4 #define MV_ULTIMATE 8 #define MV_PERFECT 16 -#define MV_MAX 31 // used in gamedata check +#define MV_PERFECTRA 32 +#define MV_MAX 63 // used in gamedata check, update whenever MV's are added +#define MV_MP 128 extern UINT8 mapvisited[NUMMAPS]; // Temporary holding place for nights data for the current map @@ -375,6 +546,7 @@ nightsdata_t ntemprecords; extern UINT32 token; ///< Number of tokens collected in a level extern UINT32 tokenlist; ///< List of tokens collected +extern boolean gottoken; ///< Did you get a token? Used for end of act extern INT32 tokenbits; ///< Used for setting token bits extern INT32 sstimer; ///< Time allotted in the special stage extern UINT32 bluescore; ///< Blue Team Scores @@ -396,6 +568,7 @@ extern UINT16 tailsflytics; extern UINT16 underwatertics; extern UINT16 spacetimetics; extern UINT16 extralifetics; +extern UINT16 nightslinktics; extern UINT8 introtoplay; extern UINT8 creditscutscene; @@ -468,6 +641,8 @@ extern boolean precache; // wipegamestate can be set to -1 // to force a wipe on the next draw extern gamestate_t wipegamestate; +extern INT16 wipetypepre; +extern INT16 wipetypepost; // debug flag to cancel adaptiveness extern boolean singletics; @@ -479,6 +654,8 @@ extern boolean singletics; #include "d_clisrv.h" extern consvar_t cv_timetic; // display high resolution timer +extern consvar_t cv_powerupdisplay; // display powerups +extern consvar_t cv_showinputjoy; // display joystick in time attack extern consvar_t cv_forceskin; // force clients to use the server's skin extern consvar_t cv_downloading; // allow clients to downloading WADs. extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; diff --git a/src/doomtype.h b/src/doomtype.h index b44e32e46..571e930e0 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -17,18 +17,20 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ -#if (defined (_WIN32) && !defined (_XBOX)) || (defined (_WIN32_WCE) && !defined (__GNUC__)) +#ifdef _WIN32 //#define WIN32_LEAN_AND_MEAN #define RPC_NO_WINDOWS_H #include #endif -#ifdef _NDS -#include -#endif - /* 7.18.1.1 Exact-width integer types */ #ifdef _MSC_VER +// libopenmpt.h will include stdint.h later; +// include it now so that INT8_MAX etc. don't get redefined +#ifdef HAVE_OPENMPT +#include +#endif + #define UINT8 unsigned __int8 #define SINT8 signed __int8 @@ -52,19 +54,6 @@ typedef long ssize_t; #define PDWORD_PTR PDWORD #endif #endif -#elif defined (_arch_dreamcast) // KOS Dreamcast -#include - -#define UINT8 unsigned char -#define SINT8 signed char - -#define UINT16 uint16 -#define INT16 int16 - -#define INT32 int -#define UINT32 unsigned int -#define INT64 int64 -#define UINT64 uint64 #elif defined (__DJGPP__) #define UINT8 unsigned char #define SINT8 signed char @@ -100,15 +89,13 @@ typedef long ssize_t; /* Strings and some misc platform specific stuff */ -#if defined (_MSC_VER) || defined (__OS2__) - // Microsoft VisualC++ #ifdef _MSC_VER + // Microsoft VisualC++ #if (_MSC_VER <= 1800) // MSVC 2013 and back #define snprintf _snprintf #if (_MSC_VER <= 1200) // MSVC 6.0 and back #define vsnprintf _vsnprintf #endif -#endif #endif #define strncasecmp strnicmp #define strcasecmp stricmp @@ -121,23 +108,15 @@ typedef long ssize_t; #define strncasecmp strnicmp #define strcasecmp strcmpi #endif -#ifdef _PSP - #include -#elif (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) +#if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) #undef stricmp #define stricmp(x,y) strcasecmp(x,y) #undef strnicmp #define strnicmp(x,y,n) strncasecmp(x,y,n) #endif -#ifdef _WIN32_WCE -#ifndef __GNUC__ - #define stricmp(x,y) _stricmp(x,y) - #define strnicmp _strnicmp -#endif - #define strdup _strdup - #define strupr _strupr - #define strlwr _strlwr -#endif + +char *strcasestr(const char *in, const char *what); +#define stristr strcasestr #if defined (macintosh) //|| defined (__APPLE__) //skip all boolean/Boolean crap #define true 1 @@ -157,7 +136,7 @@ typedef long ssize_t; #endif #endif //macintosh -#if defined (PC_DOS) || defined (_WIN32) || defined (_WII) || defined (_PSP) || defined (_arch_dreamcast) || defined (__HAIKU__) || defined(_NDS) || defined(_PS3) +#if defined (PC_DOS) || defined (_WIN32) || defined (__HAIKU__) #define HAVE_DOSSTR_FUNCS #endif @@ -191,21 +170,17 @@ size_t strlcpy(char *dst, const char *src, size_t siz); //faB: clean that up !! #if defined( _MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013 and forward #include "stdbool.h" - #elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) + #elif defined (_WIN32) #define false FALSE // use windows types #define true TRUE #define boolean BOOL - #elif defined(_NDS) - #define boolean bool - #elif defined(_PS3) // defined(__GNUC__)? - #include //_bool_true_false_are_defined? - #define boolean bool #else typedef enum {false, true} boolean; #endif #endif // __BYTEBOOL__ /* 7.18.2.1 Limits of exact-width integer types */ + #ifndef INT8_MIN #define INT8_MIN (-128) #endif @@ -298,12 +273,6 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #endif #define ATTRUNUSED __attribute__((unused)) - - // Xbox-only macros - #ifdef _XBOX - #define FILESTAMP I_OutputMsg("%s:%d\n",__FILE__,__LINE__); - #define XBOXSTATIC static - #endif #elif defined (_MSC_VER) #define ATTRNORETURN __declspec(noreturn) #define ATTRINLINE __forceinline @@ -357,25 +326,21 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #ifndef ATTRNOINLINE #define ATTRNOINLINE #endif -#ifndef XBOXSTATIC -#define XBOXSTATIC -#endif -#ifndef FILESTAMP -#define FILESTAMP -#endif /* Miscellaneous types that don't fit anywhere else (Can this be changed?) */ +typedef struct +{ + UINT8 red; + UINT8 green; + UINT8 blue; + UINT8 alpha; +} byteColor_t; + union FColorRGBA { UINT32 rgba; - struct - { - UINT8 red; - UINT8 green; - UINT8 blue; - UINT8 alpha; - } s; + byteColor_t s; } ATTRPACK; typedef union FColorRGBA RGBA_t; diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 7275bb1ae..f09158e01 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -95,6 +95,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -142,4 +173,45 @@ boolean I_SetSongTrack(int track) { (void)track; return false; -} \ No newline at end of file +} + +/// ------------------------ +// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)source_volume; + (void)ms; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +{ + (void)target_volume; + (void)ms; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index a3fe3077c..5c0f7eb99 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -150,6 +150,8 @@ void I_GetJoystick2Events(void){} void I_GetMouseEvents(void){} +void I_UpdateMouseGrab(void){} + char *I_GetEnv(const char *name) { (void)name; diff --git a/src/dummy/i_video.c b/src/dummy/i_video.c index e167e833f..fafeee000 100644 --- a/src/dummy/i_video.c +++ b/src/dummy/i_video.c @@ -11,6 +11,7 @@ boolean allow_fullscreen = false; consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; void I_StartupGraphics(void){} +void I_StartupHardwareGraphics(void){} void I_ShutdownGraphics(void){} @@ -39,6 +40,11 @@ INT32 VID_SetMode(INT32 modenum) return 0; } +void VID_CheckRenderer(void) +{ + // .............. +} + const char *VID_GetModeName(INT32 modenum) { (void)modenum; diff --git a/src/endian.h b/src/endian.h index d3c1cb18b..24d8e35cd 100644 --- a/src/endian.h +++ b/src/endian.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/f_finale.c b/src/f_finale.c index d4a468c57..95535a7ea 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -14,6 +14,7 @@ #include "doomdef.h" #include "doomstat.h" #include "d_main.h" +#include "d_netcmd.h" #include "f_finale.h" #include "g_game.h" #include "hu_stuff.h" @@ -29,19 +30,29 @@ #include "g_input.h" #include "console.h" #include "m_random.h" +#include "m_misc.h" // moviemode functionality #include "y_inter.h" #include "m_cond.h" +#include "p_local.h" +#include "p_setup.h" +#include "st_stuff.h" // hud hiding +#include "fastcmp.h" +#include "console.h" + +#include "lua_hud.h" // Stage of animation: // 0 = text, 1 = art screen -static INT32 finalecount; -INT32 titlescrollspeed = 80; +INT32 finalecount; +INT32 titlescrollxspeed = 20; +INT32 titlescrollyspeed = 0; +UINT8 titlemapinaction = TITLEMAP_OFF; static INT32 timetonext; // Delay between screen changes static INT32 continuetime; // Short delay when continuing static tic_t animtimer; // Used for some animation timings -static INT32 roidtics; // Asteroid spinning +static INT16 skullAnimCounter; // Prompts: Chevron animation static INT32 deplete; static tic_t stoptimer; @@ -49,10 +60,46 @@ static tic_t stoptimer; static boolean keypressed = false; // (no longer) De-Demo'd Title Screen +static tic_t xscrolltimer; +static tic_t yscrolltimer; +static INT32 menuanimtimer; // Title screen: background animation timing +mobj_t *titlemapcameraref = NULL; + +// menu presentation state +char curbgname[9]; +SINT8 curfadevalue; +INT32 curbgcolor; +INT32 curbgxspeed; +INT32 curbgyspeed; +boolean curbghide; +boolean hidetitlemap; // WARNING: set to false by M_SetupNextMenu and M_ClearMenus + static UINT8 curDemo = 0; static UINT32 demoDelayLeft; static UINT32 demoIdleLeft; +// customizable title screen graphics + +ttmode_enum ttmode = TTMODE_OLD; +UINT8 ttscale = 1; // FRACUNIT / ttscale +// ttmode user vars +char ttname[9]; +INT16 ttx = 0; +INT16 tty = 0; +INT16 ttloop = -1; +UINT16 tttics = 1; + +boolean curhidepics; +ttmode_enum curttmode; +UINT8 curttscale; +// ttmode user vars +char curttname[9]; +INT16 curttx; +INT16 curtty; +INT16 curttloop; +UINT16 curtttics; + +// ttmode old static patch_t *ttbanner; // white banner with "robo blast" and "2" static patch_t *ttwing; // wing background static patch_t *ttsonic; // "SONIC" @@ -69,7 +116,101 @@ static patch_t *ttspop5; static patch_t *ttspop6; static patch_t *ttspop7; -static void F_SkyScroll(INT32 scrollspeed); +// ttmode alacroix +static SINT8 testttscale = 0; +static SINT8 activettscale = 0; +boolean ttavailable[6]; +boolean ttloaded[6]; + +static patch_t *ttribb[6][TTMAX_ALACROIX]; +static patch_t *ttsont[6][TTMAX_ALACROIX]; +static patch_t *ttrobo[6][TTMAX_ALACROIX]; +static patch_t *tttwot[6][TTMAX_ALACROIX]; +static patch_t *ttembl[6][TTMAX_ALACROIX]; +static patch_t *ttrbtx[6][TTMAX_ALACROIX]; +static patch_t *ttsoib[6][TTMAX_ALACROIX]; +static patch_t *ttsoif[6][TTMAX_ALACROIX]; +static patch_t *ttsoba[6][TTMAX_ALACROIX]; +static patch_t *ttsobk[6][TTMAX_ALACROIX]; +static patch_t *ttsodh[6][TTMAX_ALACROIX]; +static patch_t *tttaib[6][TTMAX_ALACROIX]; +static patch_t *tttaif[6][TTMAX_ALACROIX]; +static patch_t *tttaba[6][TTMAX_ALACROIX]; +static patch_t *tttabk[6][TTMAX_ALACROIX]; +static patch_t *tttabt[6][TTMAX_ALACROIX]; +static patch_t *tttaft[6][TTMAX_ALACROIX]; +static patch_t *ttknib[6][TTMAX_ALACROIX]; +static patch_t *ttknif[6][TTMAX_ALACROIX]; +static patch_t *ttknba[6][TTMAX_ALACROIX]; +static patch_t *ttknbk[6][TTMAX_ALACROIX]; +static patch_t *ttkndh[6][TTMAX_ALACROIX]; + +#define TTEMBL (ttembl[activettscale-1]) +#define TTRIBB (ttribb[activettscale-1]) +#define TTSONT (ttsont[activettscale-1]) +#define TTROBO (ttrobo[activettscale-1]) +#define TTTWOT (tttwot[activettscale-1]) +#define TTRBTX (ttrbtx[activettscale-1]) +#define TTSOIB (ttsoib[activettscale-1]) +#define TTSOIF (ttsoif[activettscale-1]) +#define TTSOBA (ttsoba[activettscale-1]) +#define TTSOBK (ttsobk[activettscale-1]) +#define TTSODH (ttsodh[activettscale-1]) +#define TTTAIB (tttaib[activettscale-1]) +#define TTTAIF (tttaif[activettscale-1]) +#define TTTABA (tttaba[activettscale-1]) +#define TTTABK (tttabk[activettscale-1]) +#define TTTABT (tttabt[activettscale-1]) +#define TTTAFT (tttaft[activettscale-1]) +#define TTKNIB (ttknib[activettscale-1]) +#define TTKNIF (ttknif[activettscale-1]) +#define TTKNBA (ttknba[activettscale-1]) +#define TTKNBK (ttknbk[activettscale-1]) +#define TTKNDH (ttkndh[activettscale-1]) + +static boolean sonic_blink = false; +static boolean sonic_blink_twice = false; +static boolean sonic_blinked_already = false; +static INT32 sonic_idle_start = 0; +static INT32 sonic_idle_end = 0; +static boolean tails_blink = false; +static boolean tails_blink_twice = false; +static boolean tails_blinked_already = false; +static INT32 tails_idle_start = 0; +static INT32 tails_idle_end = 0; +static boolean knux_blink = false; +static boolean knux_blink_twice = false; +static boolean knux_blinked_already = false; +static INT32 knux_idle_start = 0; +static INT32 knux_idle_end = 0; + +// ttmode user +static patch_t *ttuser[TTMAX_USER]; +static INT32 ttuser_count = 0; + +static boolean goodending; +static patch_t *endbrdr[2]; // border - blue, white, pink - where have i seen those colours before? +static patch_t *endbgsp[3]; // nebula, sun, planet +static patch_t *endegrk[2]; // eggrock - replaced midway through good ending +static patch_t *endfwrk[3]; // firework - replaced with skin when good ending +static patch_t *endspkl[3]; // sparkle +static patch_t *endglow[2]; // glow aura - replaced with black rock's midway through good ending +static patch_t *endxpld[4]; // mini explosion +static patch_t *endescp[5]; // escape pod + flame +static INT32 sparkloffs[3][2]; // eggrock explosions/blackrock sparkles +static INT32 sparklloop; + +// +// PROMPT STATE +// +boolean promptactive = false; +static mobj_t *promptmo; +static INT16 promptpostexectag; +static boolean promptblockcontrols; +static char *promptpagetext = NULL; +static INT32 callpromptnum = INT32_MAX; +static INT32 callpagenum = INT32_MAX; +static INT32 callplayer = INT32_MAX; // // CUTSCENE TEXT WRITING @@ -159,103 +300,10 @@ static void F_NewCutscene(const char *basetext) cutscene_textcount = TICRATE/2; } -// -// F_DrawPatchCol -// -static void F_DrawPatchCol(INT32 x, patch_t *patch, INT32 col) -{ - const column_t *column; - const UINT8 *source; - UINT8 *desttop, *dest = NULL; - const UINT8 *deststop, *destbottom; - size_t count; - - desttop = screens[0] + x*vid.dupx; - deststop = screens[0] + vid.rowbytes * vid.height; - destbottom = desttop + vid.height*vid.width; - - do { - INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[col])); - - // step through the posts in a column - while (column->topdelta != 0xff) - { - topdelta = column->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - source = (const UINT8 *)column + 3; - dest = desttop + topdelta*vid.width; - count = column->length; - - while (count--) - { - INT32 dupycount = vid.dupy; - - while (dupycount-- && dest < destbottom) - { - INT32 dupxcount = vid.dupx; - while (dupxcount-- && dest <= deststop) - *dest++ = *source; - - dest += (vid.width - vid.dupx); - } - source++; - } - column = (const column_t *)((const UINT8 *)column + column->length + 4); - } - - desttop += SHORT(patch->height)*vid.dupy*vid.width; - } while(dest < destbottom); -} - -// -// F_SkyScroll -// -static void F_SkyScroll(INT32 scrollspeed) -{ - INT32 scrolled, x, mx, fakedwidth; - patch_t *pat; - - pat = W_CachePatchName("TITLESKY", PU_CACHE); - - animtimer = ((finalecount*scrollspeed)/16) % SHORT(pat->width); - - fakedwidth = vid.width / vid.dupx; - - if (rendermode == render_soft) - { // if only hardware rendering could be this elegant and complete - scrolled = (SHORT(pat->width) - animtimer) - 1; - for (x = 0, mx = scrolled; x < fakedwidth; x++, mx = (mx+1)%SHORT(pat->width)) - F_DrawPatchCol(x, pat, mx); - } -#ifdef HWRENDER - else if (rendermode != render_none) - { // if only software rendering could be this simple and retarded - INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); - INT32 y, pw = SHORT(pat->width) * dupz, ph = SHORT(pat->height) * dupz; - scrolled = animtimer * dupz; - for (x = 0; x < vid.width; x += pw) - { - for (y = 0; y < vid.height; y += ph) - { - if (scrolled > 0) - V_DrawScaledPatch(scrolled - pw, y, V_NOSCALESTART, pat); - - V_DrawScaledPatch(x + scrolled, y, V_NOSCALESTART, pat); - } - } - } -#endif - - W_UnlockCachedPatch(pat); -} - // ============= // INTRO SCENE // ============= -#define NUMINTROSCENES 16 +#define NUMINTROSCENES 17 INT32 intro_scenenum = 0; INT32 intro_curtime = 0; @@ -275,7 +323,8 @@ static tic_t introscenetime[NUMINTROSCENES] = 16*TICRATE, // Meanwhile, Sonic was tearing across the zones... 16*TICRATE + (TICRATE/2), // Sonic knew he was getting closer to the city... 17*TICRATE, // Greenflower City was gone... - 16*TICRATE + (TICRATE/2), // You're not quite as dead as we thought, huh?... + 7*TICRATE, // You're not quite as dead as we thought, huh?... + 8*TICRATE, // We'll see... let's give you a quick warm up... 18*TICRATE + (TICRATE/2), // Eggman took this as his cue and blasted off... 16*TICRATE, // Easy! We go find Eggman and stop his... 25*TICRATE, // I'm just finding what mission obje... @@ -286,6 +335,9 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset void F_StartIntro(void) { + S_StopMusic(); + S_StopSounds(); + if (introtoplay) { if (!cutscenes[introtoplay - 1]) @@ -305,7 +357,7 @@ void F_StartIntro(void) introtext[2] = M_GetText( "As it was about to drain the rings\n" "away from the planet, Sonic burst into\n" - "the Satellite and for what he thought\n" + "the control room and for what he thought\n" "would be the last time,\xB4 defeated\n" "Dr. Eggman.\n#"); @@ -315,11 +367,11 @@ void F_StartIntro(void) "return,\xB8 bringing an all new threat.\n#"); introtext[4] = M_GetText( - "\xA8""About once every year, a strange asteroid\n" + "\xA8""About every five years, a strange asteroid\n" "hovers around the planet.\xBF It suddenly\n" "appears from nowhere, circles around, and\n" "\xB6- just as mysteriously as it arrives -\xB6\n" - "vanishes after about two months.\xBF\n" + "vanishes after only one week.\xBF\n" "No one knows why it appears, or how.\n#"); introtext[5] = M_GetText( @@ -331,11 +383,11 @@ void F_StartIntro(void) "the screen, and just shrugged it off.\n#"); introtext[6] = M_GetText( - "It was only later\n" + "It was hours later\n" "that he had an\n" "idea. \xBF\xA7\"The Black\n" - "Rock usually has a\n" - "lot of energy\n" + "Rock has a large\n" + "amount of energy\n" "within it\xAC...\xA7\xBF\n" "If I can somehow\n" "harness this,\xB8 I\n" @@ -353,58 +405,66 @@ void F_StartIntro(void) "a reunion party...\n#"); introtext[8] = M_GetText( - "\xA5\"We're\xB6 ready\xB6 to\xB4 fire\xB6 in\xB6 15\xB6 seconds!\"\xA8\xB8\n" - "The robot said, his voice crackling a\n" - "little down the com-link. \xBF\xA7\"Good!\"\xA8\xB8\n" - "Eggman sat back in his Egg-Mobile and\n" + "\xA5\"PRE-""\xB6""PARING-""\xB6""TO-""\xB4""FIRE-\xB6IN-""\xB6""15-""\xB6""SECONDS!\"\xA8\xB8\n" + "his targeting system crackled\n" + "robotically down the com-link. \xBF\xA7\"Good!\"\xA8\xB8\n" + "Eggman sat back in his eggmobile and\n" "began to count down as he saw the\n" - "GreenFlower city on the main monitor.\n#"); + "Greenflower mountain on the monitor.\n#"); introtext[9] = M_GetText( "\xA5\"10...\xD2""9...\xD2""8...\"\xA8\xD2\n" "Meanwhile, Sonic was tearing across the\n" "zones. Everything became a blur as he\n" - "ran around loops, skimmed over water,\n" + "ran up slopes, skimmed over water,\n" "and catapulted himself off rocks with\n" "his phenomenal speed.\n#"); introtext[10] = M_GetText( "\xA5\"6...\xD2""5...\xD2""4...\"\xA8\xD2\n" "Sonic knew he was getting closer to the\n" - "City, and pushed himself harder.\xB4 Finally,\n" - "the city appeared in the horizon.\xD2\xD2\n" + "zone, and pushed himself harder.\xB4 Finally,\n" + "the mountain appeared on the horizon.\xD2\xD2\n" "\xA5\"3...\xD2""2...\xD2""1...\xD2""Zero.\"\n#"); introtext[11] = M_GetText( - "GreenFlower City was gone.\xC4\n" + "Greenflower Mountain was no more.\xC4\n" "Sonic arrived just in time to see what\n" "little of the 'ruins' were left.\n" - "Everyone and everything in the city\n" + "The natural beauty of the zone\n" "had been obliterated.\n#"); introtext[12] = M_GetText( - "\xA7\"You're not quite as dead as we thought,\n" - "huh?\xBF Are you going to tell us your plan as\n" - "usual or will I \xA8\xB4'have to work it out'\xA7 or\n" - "something?\"\xD2\xD2\n" + "\xA7\"You're not\n" + "quite as gone\n" + "as we thought,\n" + "huh?\xBF Are you\n" + "going to tell\n" + "us your plan as\n" + "usual or will I\n" + "\xA8\xB4'have to work\n" + "it out'\xA7 or\n" + "something?\"\xD2\xD2\n#"); + + introtext[13] = M_GetText( "\"We'll see\xAA...\xA7\xBF let's give you a quick warm\n" "up, Sonic!\xA6\xC4 JETTYSYNS!\xA7\xBD Open fire!\"\n#"); - introtext[13] = M_GetText( + introtext[14] = M_GetText( "Eggman took this\n" "as his cue and\n" "blasted off,\n" "leaving Sonic\n" "and Tails behind.\xB6\n" "Tails looked at\n" - "the ruins of the\n" - "Greenflower City\n" + "the once-perfect\n" + "mountainside\n" "with a grim face\n" "and sighed.\xC6\n" "\xA7\"Now\xB6 what do we\n" "do?\",\xA9 he asked.\n#"); - introtext[14] = M_GetText( + introtext[15] = M_GetText( "\xA7\"Easy!\xBF We go\n" "find Eggman\n" "and stop his\n" @@ -418,7 +478,7 @@ void F_StartIntro(void) "\xAA*ARE*\xA9 you\n" "doing?\"\n#"); - introtext[15] = M_GetText( + introtext[16] = M_GetText( "\xA8\"I'm just finding what mission obje\xAC\xB1...\xBF\n" "\xA6""a-\xB8""ha!\xBF Here it is!\xA8\xBF This will only give us\n" "the robot's primary objective.\xBF It says\xAC\xB1...\"\n" @@ -447,8 +507,7 @@ void F_StartIntro(void) F_NewCutscene(introtext[0]); intro_scenenum = 0; - finalecount = animtimer = stoptimer = 0; - roidtics = BASEVIDWIDTH - 64; + finalecount = animtimer = skullAnimCounter = stoptimer = 0; timetonext = introscenetime[intro_scenenum]; } @@ -457,91 +516,93 @@ void F_StartIntro(void) // static void F_IntroDrawScene(void) { - boolean highres = false; + boolean highres = true; INT32 cx = 8, cy = 128; patch_t *background = NULL; INT32 bgxoffs = 0; void *patch; // DRAW A FULL PIC INSTEAD OF FLAT! - if (intro_scenenum == 0); - else if (intro_scenenum == 1) - background = W_CachePatchName("INTRO1", PU_CACHE); - else if (intro_scenenum == 2) + switch (intro_scenenum) { - background = W_CachePatchName("INTRO2", PU_CACHE); - highres = true; - } - else if (intro_scenenum == 3) - background = W_CachePatchName("INTRO3", PU_CACHE); - else if (intro_scenenum == 4) - background = W_CachePatchName("INTRO4", PU_CACHE); - else if (intro_scenenum == 5) - { - if (intro_curtime >= 5*TICRATE) - background = W_CachePatchName("RADAR", PU_CACHE); - else + case 0: + break; + case 1: + background = W_CachePatchName("INTRO1", PU_PATCH); + break; + case 2: + background = W_CachePatchName("INTRO2", PU_PATCH); + break; + case 3: + background = W_CachePatchName("INTRO3", PU_PATCH); + break; + case 4: + background = W_CachePatchName("INTRO4", PU_PATCH); + break; + case 5: + if (intro_curtime >= 5*TICRATE) + background = W_CachePatchName("RADAR", PU_PATCH); + else + background = W_CachePatchName("DRAT", PU_PATCH); + break; + case 6: + background = W_CachePatchName("INTRO6", PU_PATCH); + cx = 180; + cy = 8; + break; + case 7: { - background = W_CachePatchName("DRAT", PU_CACHE); - highres = true; + if (intro_curtime >= 7*TICRATE + ((TICRATE/7)*2)) + background = W_CachePatchName("SGRASS5", PU_PATCH); + else if (intro_curtime >= 7*TICRATE + (TICRATE/7)) + background = W_CachePatchName("SGRASS4", PU_PATCH); + else if (intro_curtime >= 7*TICRATE) + background = W_CachePatchName("SGRASS3", PU_PATCH); + else if (intro_curtime >= 6*TICRATE) + background = W_CachePatchName("SGRASS2", PU_PATCH); + else + background = W_CachePatchName("SGRASS1", PU_PATCH); + break; } - } - else if (intro_scenenum == 6) - { - background = W_CachePatchName("INTRO6", PU_CACHE); - cx = 180; - cy = 8; - } - else if (intro_scenenum == 7) - { - if (intro_curtime >= 6*TICRATE) - background = W_CachePatchName("SGRASS5", PU_CACHE); - else - background = W_CachePatchName("SGRASS1", PU_CACHE); - } - else if (intro_scenenum == 8) - { - background = W_CachePatchName("WATCHING", PU_CACHE); - highres = true; - } - else if (intro_scenenum == 9) - { - background = W_CachePatchName("ZOOMING", PU_CACHE); - highres = true; - } - else if (intro_scenenum == 10); - else if (intro_scenenum == 11) - background = W_CachePatchName("INTRO5", PU_CACHE); - else if (intro_scenenum == 12) - { - if (intro_curtime >= 7*TICRATE) - background = W_CachePatchName("CONFRONT", PU_CACHE); - else - background = W_CachePatchName("REVENGE", PU_CACHE); - highres = true; - } - else if (intro_scenenum == 13) - { - background = W_CachePatchName("TAILSSAD", PU_CACHE); - highres = true; - bgxoffs = 144; - cx = 8; - cy = 8; - } - else if (intro_scenenum == 14) - { - if (intro_curtime >= 7*TICRATE) - background = W_CachePatchName("SONICDO2", PU_CACHE); - else - background = W_CachePatchName("SONICDO1", PU_CACHE); - highres = true; - cx = 224; - cy = 8; - } - else if (intro_scenenum == 15) - { - background = W_CachePatchName("INTRO7", PU_CACHE); - highres = true; + case 8: + background = W_CachePatchName("WATCHING", PU_PATCH); + break; + case 9: + background = W_CachePatchName("ZOOMING", PU_PATCH); + break; + case 10: + break; + case 11: + background = W_CachePatchName("INTRO5", PU_PATCH); + break; + case 12: + background = W_CachePatchName("REVENGE", PU_PATCH); + cx = 208; + cy = 8; + break; + case 13: + background = W_CachePatchName("CONFRONT", PU_PATCH); + cy += 48; + break; + case 14: + background = W_CachePatchName("TAILSSAD", PU_PATCH); + bgxoffs = 144; + cx = 8; + cy = 8; + break; + case 15: + if (intro_curtime >= 7*TICRATE) + background = W_CachePatchName("SONICDO2", PU_PATCH); + else + background = W_CachePatchName("SONICDO1", PU_PATCH); + cx = 224; + cy = 8; + break; + case 16: + background = W_CachePatchName("INTRO7", PU_PATCH); + break; + default: + break; } V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); @@ -565,33 +626,33 @@ static void F_IntroDrawScene(void) if (finalecount < 4) S_StopMusic(); if (finalecount == 4) - S_ChangeMusicInternal("stjr", false); + S_ChangeMusicInternal("_stjr", false); x = (BASEVIDWIDTH< 6) { - V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH2", PU_CACHE)), aspect); + V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH2", PU_PATCH)), aspect); W_UnlockCachedPatch(patch); } if (finalecount > 10) { - V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH3", PU_CACHE)), aspect); + V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH3", PU_PATCH)), aspect); W_UnlockCachedPatch(patch); } if (finalecount > 14) { - V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH4", PU_CACHE)), aspect); + V_DrawSciencePatch(x, y, 0, (patch = W_CachePatchName("WAHH4", PU_PATCH)), aspect); W_UnlockCachedPatch(patch); } } else if (finalecount-30 < 20) { // Big eggy - background = W_CachePatchName("FEEDIN", PU_CACHE); + background = W_CachePatchName("FEEDIN", PU_PATCH); x = (BASEVIDWIDTH< 4*TICRATE) { // Door is being raised! int ftime = (finalecount-TICRATE/2-4*TICRATE); y -= FixedDiv((ftime*ftime)< 5*TICRATE && timetonext < 6*TICRATE) { if (!(finalecount & 3)) - background = W_CachePatchName("BRITEGG1", PU_CACHE); + background = W_CachePatchName("BRITEGG1", PU_PATCH); else - background = W_CachePatchName("DARKEGG1", PU_CACHE); + background = W_CachePatchName("DARKEGG1", PU_PATCH); - V_DrawScaledPatch(0, 0, 0, background); + V_DrawSmallScaledPatch(0, 0, 0, background); } else if (timetonext > 3*TICRATE && timetonext < 4*TICRATE) { if (!(finalecount & 3)) - background = W_CachePatchName("BRITEGG2", PU_CACHE); + background = W_CachePatchName("BRITEGG2", PU_PATCH); else - background = W_CachePatchName("DARKEGG2", PU_CACHE); + background = W_CachePatchName("DARKEGG2", PU_PATCH); - V_DrawScaledPatch(0, 0, 0, background); + V_DrawSmallScaledPatch(0, 0, 0, background); } else if (timetonext > 1*TICRATE && timetonext < 2*TICRATE) { if (!(finalecount & 3)) - background = W_CachePatchName("BRITEGG3", PU_CACHE); + background = W_CachePatchName("BRITEGG3", PU_PATCH); else - background = W_CachePatchName("DARKEGG3", PU_CACHE); + background = W_CachePatchName("DARKEGG3", PU_PATCH); - V_DrawScaledPatch(0, 0, 0, background); + V_DrawSmallScaledPatch(0, 0, 0, background); } else { - F_SkyScroll(80*4); - if (timetonext == 6) + tic_t sonicdelay = max(0, timetonext - 16*TICRATE); + tic_t tailsdelay = max(0, timetonext - (9*TICRATE >> 1)); + tic_t knucklesdelay = max(0, timetonext - (5*TICRATE >> 1)); + INT32 sonicx = (timetonext >> 2) + min(sonicdelay, TICRATE >> 1) * sonicdelay; + INT32 tailsx = 32 + min(tailsdelay, TICRATE >> 1) * tailsdelay; + INT32 knucklesx = 96 + min(knucklesdelay, TICRATE >> 1) * knucklesdelay; + INT32 tailsy = 12 + P_ReturnThrustX(NULL, finalecount * ANGLE_22h, 2); + INT32 knucklesy = 48 - (timetonext >> 3); + INT32 skyx, grassx; + + if (timetonext >= 0 && timetonext < 18) { - stoptimer = finalecount; - animtimer = finalecount % 16; - } - else if (timetonext >= 0 && timetonext < 6) - { - animtimer = stoptimer; - deplete -= 32; + deplete -= 16; } else { - animtimer = finalecount % 16; - deplete = 160; + stoptimer = finalecount; + deplete = 96; } + skyx = 2 * stoptimer % 320; + grassx = 16 * stoptimer % 320; + sonicx += deplete; + tailsx += sonicx; + knucklesx += sonicx; + sonicx += P_ReturnThrustX(NULL, finalecount * ANG10, 3); + + V_DrawSmallScaledPatch(skyx, 0, 0, (patch = W_CachePatchName("INTROSKY", PU_PATCH))); + V_DrawSmallScaledPatch(skyx - 320, 0, 0, patch); + W_UnlockCachedPatch(patch); + V_DrawSmallScaledPatch(grassx, 0, 0, (patch = W_CachePatchName("INTROGRS", PU_PATCH))); + V_DrawSmallScaledPatch(grassx - 320, 0, 0, patch); + W_UnlockCachedPatch(patch); if (finalecount & 1) { - V_DrawScaledPatch(deplete, 8, 0, (patch = W_CachePatchName("RUN2", PU_CACHE))); + // Sonic + V_DrawSmallScaledPatch(sonicx, 54, 0, (patch = W_CachePatchName("RUN2", PU_PATCH))); W_UnlockCachedPatch(patch); - V_DrawScaledPatch(deplete, 72, 0, (patch = W_CachePatchName("PEELOUT2", PU_CACHE))); + + // Appendages + if (finalecount & 2) + { + // Sonic's feet + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT4", PU_PATCH))); + W_UnlockCachedPatch(patch); + // Tails' tails + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP2", PU_PATCH))); + W_UnlockCachedPatch(patch); + } + else + { + // Sonic's feet + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT2", PU_PATCH))); + W_UnlockCachedPatch(patch); + // Tails' tails + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP1", PU_PATCH))); + W_UnlockCachedPatch(patch); + } + + // Tails + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("FLY2", PU_PATCH))); + W_UnlockCachedPatch(patch); + + // Knuckles + V_DrawSmallScaledPatch(knucklesx, knucklesy, 0, (patch = W_CachePatchName("GLIDE2", PU_PATCH))); W_UnlockCachedPatch(patch); } else { - V_DrawScaledPatch(deplete, 8, 0, (patch = W_CachePatchName("RUN1", PU_CACHE))); + // Sonic + V_DrawSmallScaledPatch(sonicx, 54, 0, (patch = W_CachePatchName("RUN1", PU_PATCH))); W_UnlockCachedPatch(patch); - V_DrawScaledPatch(deplete, 72, 0, (patch = W_CachePatchName("PEELOUT1", PU_CACHE))); + + // Appendages + if (finalecount & 2) + { + // Sonic's feet + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT3", PU_PATCH))); + W_UnlockCachedPatch(patch); + // Tails' tails + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP2", PU_PATCH))); + W_UnlockCachedPatch(patch); + } + else + { + // Sonic's feet + V_DrawSmallScaledPatch(sonicx - 8, 92, 0, (patch = W_CachePatchName("PEELOUT1", PU_PATCH))); + W_UnlockCachedPatch(patch); + // Tails' tails + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("HELICOP1", PU_PATCH))); + W_UnlockCachedPatch(patch); + } + + // Tails + V_DrawSmallScaledPatch(tailsx, tailsy, 0, (patch = W_CachePatchName("FLY1", PU_PATCH))); + W_UnlockCachedPatch(patch); + + // Knuckles + V_DrawSmallScaledPatch(knucklesx, knucklesy, 0, (patch = W_CachePatchName("GLIDE1", PU_PATCH))); W_UnlockCachedPatch(patch); } - { // Fixing up the black box rendering to look right in resolutions <16:10 -Red - INT32 y = 112; - INT32 h = BASEVIDHEIGHT - 112; - if (vid.height != BASEVIDHEIGHT * vid.dupy) - { - INT32 adjust = (vid.height/vid.dupy)-200; - adjust /= 2; - y += adjust; - h += adjust; - V_DrawFill(0, 0, BASEVIDWIDTH, adjust, 31); // Render a black bar on top so it keeps the "cinematic" windowboxing... I just prefer it this way. -Red - } - V_DrawFill(0, y, BASEVIDWIDTH, h, 31); - } + // Black bars to hide the sky on widescreen + V_DrawFill(-80, 0, 80, 256, 31); + V_DrawFill(BASEVIDWIDTH, 0, 80, 256, 31); } } @@ -731,33 +852,56 @@ static void F_IntroDrawScene(void) if (intro_scenenum == 4) // The asteroid SPINS! { - if (roidtics >= 0) + if (intro_curtime > 1) { - V_DrawScaledPatch(roidtics, 24, 0, - (patch = W_CachePatchName(va("ROID00%.2d", intro_curtime%35), PU_CACHE))); - W_UnlockCachedPatch(patch); + INT32 worktics = intro_curtime - 1; + INT32 scale = FRACUNIT; + patch_t *rockpat; + UINT8 *colormap = NULL; + patch_t *glow; + INT32 trans = 0; + + INT32 x = ((BASEVIDWIDTH - 64)<= 5) + trans = (worktics-5)>>1; + if (trans < 10) + V_DrawFixedPatch(x, y, scale, trans< 7*TICRATE) - { - patch_t *sgrass; - - if (intro_curtime >= 7*TICRATE + ((TICRATE/7)*2)) - sgrass = W_CachePatchName("SGRASS4", PU_CACHE); - else if (intro_curtime >= 7*TICRATE + (TICRATE/7)) - sgrass = W_CachePatchName("SGRASS3", PU_CACHE); - else - sgrass = W_CachePatchName("SGRASS2", PU_CACHE); - V_DrawScaledPatch(123, 4, 0, sgrass); - - W_UnlockCachedPatch(sgrass); - } - - V_DrawString(cx, cy, 0, cutscene_disptext); + V_DrawString(cx, cy, V_ALLOWLOWERCASE, cutscene_disptext); } // @@ -771,51 +915,60 @@ void F_IntroDrawer(void) { if (rendermode != render_none) { + wipestyleflags = WSF_FADEOUT; F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + F_TryColormapFade(31); F_WipeEndScreen(); F_RunWipe(99,true); } - S_ChangeMusicInternal("read_m", false); + S_ChangeMusicInternal("_intro", false); } - else if (intro_scenenum == 3) - roidtics = BASEVIDWIDTH - 64; else if (intro_scenenum == 10) { - // The only fade to white in the entire damn game. if (rendermode != render_none) { + wipestyleflags = (WSF_FADEOUT|WSF_TOWHITE); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); + F_TryColormapFade(0); F_WipeEndScreen(); F_RunWipe(99,true); } } - else if (intro_scenenum == 15) + else if (intro_scenenum == 16) { if (rendermode != render_none) { + wipestyleflags = WSF_FADEOUT; F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + F_TryColormapFade(31); F_WipeEndScreen(); F_RunWipe(99,true); } // Stay on black for a bit. =) { - tic_t quittime; - quittime = I_GetTime() + NEWTICRATE*2; // Shortened the quit time, used to be 2 seconds - while (quittime > I_GetTime()) + tic_t nowtime, quittime, lasttime; + nowtime = lasttime = I_GetTime(); + quittime = nowtime + NEWTICRATE*2; // Shortened the quit time, used to be 2 seconds + while (quittime > nowtime) { + while (!((nowtime = I_GetTime()) - lasttime)) + I_Sleep(); + lasttime = nowtime; + I_OsPolling(); I_UpdateNoBlit(); M_Drawer(); // menu is drawn even on top of wipes I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001 + + if (moviemode) // make sure we save frames for the white hold too + M_SaveFrame(); } } D_StartTitle(); + wipegamestate = GS_INTRO; return; } F_NewCutscene(introtext[++intro_scenenum]); @@ -823,6 +976,7 @@ void F_IntroDrawer(void) F_WipeStartScreen(); wipegamestate = -1; + wipestyleflags = WSF_CROSSFADE; animtimer = stoptimer = 0; } @@ -832,52 +986,52 @@ void F_IntroDrawer(void) { if (intro_scenenum == 5 && intro_curtime == 5*TICRATE) { - patch_t *radar = W_CachePatchName("RADAR", PU_CACHE); + patch_t *radar = W_CachePatchName("RADAR", PU_PATCH); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - V_DrawScaledPatch(0, 0, 0, radar); + F_WipeColorFill(31); + V_DrawSmallScaledPatch(0, 0, 0, radar); W_UnlockCachedPatch(radar); - V_DrawString(8, 128, 0, cutscene_disptext); + V_DrawString(8, 128, V_ALLOWLOWERCASE, cutscene_disptext); F_WipeEndScreen(); F_RunWipe(99,true); } else if (intro_scenenum == 7 && intro_curtime == 6*TICRATE) // Force a wipe here { - patch_t *grass = W_CachePatchName("SGRASS5", PU_CACHE); + patch_t *grass = W_CachePatchName("SGRASS2", PU_PATCH); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - V_DrawScaledPatch(0, 0, 0, grass); + F_WipeColorFill(31); + V_DrawSmallScaledPatch(0, 0, 0, grass); W_UnlockCachedPatch(grass); - V_DrawString(8, 128, 0, cutscene_disptext); + V_DrawString(8, 128, V_ALLOWLOWERCASE, cutscene_disptext); F_WipeEndScreen(); F_RunWipe(99,true); } - else if (intro_scenenum == 12 && intro_curtime == 7*TICRATE) + /*else if (intro_scenenum == 12 && intro_curtime == 7*TICRATE) { - patch_t *confront = W_CachePatchName("CONFRONT", PU_CACHE); + patch_t *confront = W_CachePatchName("CONFRONT", PU_PATCH); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + F_WipeColorFill(31); V_DrawSmallScaledPatch(0, 0, 0, confront); W_UnlockCachedPatch(confront); - V_DrawString(8, 128, 0, cutscene_disptext); + V_DrawString(8, 128, V_ALLOWLOWERCASE, cutscene_disptext); F_WipeEndScreen(); F_RunWipe(99,true); - } - if (intro_scenenum == 14 && intro_curtime == 7*TICRATE) + }*/ + if (intro_scenenum == 15 && intro_curtime == 7*TICRATE) { - patch_t *sdo = W_CachePatchName("SONICDO2", PU_CACHE); + patch_t *sdo = W_CachePatchName("SONICDO2", PU_PATCH); F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + F_WipeColorFill(31); V_DrawSmallScaledPatch(0, 0, 0, sdo); W_UnlockCachedPatch(sdo); - V_DrawString(224, 8, 0, cutscene_disptext); + V_DrawString(224, 8, V_ALLOWLOWERCASE, cutscene_disptext); F_WipeEndScreen(); F_RunWipe(99,true); @@ -895,9 +1049,6 @@ void F_IntroTicker(void) // advance animation finalecount++; - if (finalecount % 3 == 0) - roidtics--; - timetonext--; F_WriteText(); @@ -967,6 +1118,9 @@ static const char *credits[] = { "\1Sonic Robo Blast II", "\1Credits", "", + "\1Producer", + "Rob Tisdell", + "", "\1Game Design", "Ben \"Mystic\" Geyer", "\"SSNTails\"", @@ -977,26 +1131,31 @@ static const char *credits[] = { "Logan \"GBA\" Arias", "Callum Dickinson", "Scott \"Graue\" Feeney", + "Victor \"SteelT\" Fuentes", "Nathan \"Jazz\" Giroux", "Vivian \"toaster\" Grannell", "Kepa \"Nev3r\" Iceta", "Thomas \"Shadow Hog\" Igoe", + "\"james\"", "Iestyn \"Monster Iestyn\" Jealous", + "\"Jimita\"", "Ronald \"Furyhunter\" Kinard", // The SDL2 port + "Louis-Antoine \"LJ Sonic\" de Moulins", // de Rochefort doesn't quite fit on the screen sorry lol "John \"JTE\" Muniz", "Ehab \"Wolfy\" Saeed", + "Jonas \"MascaraSnake\" Sauer", "\"Kaito Sinclaire\"", "\"SSNTails\"", + "Lachlan \"Lach\" Wright", "Marco \"mazmazz\" Zafra", "", "\1Programming", "\1Assistance", "\"chi.miru\"", // helped port slope drawing code from ZDoom "Andrew \"orospakr\" Clunis", + "Sally \"TehRealSalt\" Cochenour", "Gregor \"Oogaland\" Dick", - "Louis-Antoine \"LJSonic\" de Moulins", // for fixing 2.1's netcode (de Rochefort doesn't quite fit on the screen sorry lol) "Julio \"Chaos Zero 64\" Guir", - "\"Jimita\"", "\"Kalaron\"", // Coded some of Sryder13's collection of OpenGL fixes, especially fog "\"Lat'\"", // SRB2-CHAT, the chat window from Kart "Matthew \"Shuffle\" Marsalko", @@ -1005,38 +1164,54 @@ static const char *credits[] = { "Colin \"Sonict\" Pfaff", "Sean \"Sryder13\" Ryder", "Tasos \"tatokis\" Sahanidis", // Corrected C FixedMul, making 64-bit builds netplay compatible - "\"Steel Titanium\"", + "Wessel \"sphere\" Smit", "Ben \"Cue\" Woodford", + "Ikaro \"Tatsuru\" Vinhas", // Git contributors with 5+ approved merges of substantive quality, // or contributors with at least one groundbreaking merge, may be named. // Everyone else is acknowledged under "Special Thanks > SRB2 Community Contributors". "", - "\1Sprite Artists", - "Odi \"Iceman404\" Atunzu", + "\1Art", "Victor \"VAdaPEGA\" Ara\x1Fjo", // Araújo -- sorry for our limited font! D: - "Jim \"MotorRoach\" DeMello", + "Ryan \"Blaze Hedgehog\" Bloom", + "Paul \"Boinciel\" Clempson", + "Sally \"TehRealSalt\" Cochenour", + "\"Dave Lite\"", "Desmond \"Blade\" DesJardins", "Sherman \"CoatRack\" DesJardins", - "Andrew \"Senku Niola\" Moran", - "David \"Instant Sonic\" Spencer Jr.", - "\"SSNTails\"", - "", - "\1Texture Artists", - "Ryan \"Blaze Hedgehog\" Bloom", + "\"DirkTheHusky\"", "Buddy \"KinkaJoy\" Fischer", "Vivian \"toaster\" Grannell", + "James \"SwitchKaze\" Hale", + "James \"SeventhSentinel\" Hall", "Kepa \"Nev3r\" Iceta", + "Iestyn \"Monster Iestyn\" Jealous", + "William \"GuyWithThePie\" Kloppenberg", + "Alice \"Alacroix\" de Lemos", + "Alexander \"DrTapeworm\" Moench-Ford", + "Andrew \"Senku Niola\" Moran", + "\"MotorRoach\"", + "Phillip \"TelosTurntable\" Robinson", + "Wessel \"sphere\" Smit", + "David \"Instant Sonic\" Spencer Jr.", + "\"SSNTails\"", + "Daniel \"Inazuma\" Trinh", + "\"VelocitOni\"", "Jarrett \"JEV3\" Voight", "", "\1Music and Sound", "\1Production", + "Victor \"VAdaPEGA\" Ara\x1Fjo", // Araújo "Malcolm \"RedXVI\" Brown", "Dave \"DemonTomatoDave\" Bulmer", "Paul \"Boinciel\" Clempson", + "Shane \"CobaltBW\" Ellis", + "James \"SeventhSentinel\" Hall", "Cyan Helkaraxe", "Kepa \"Nev3r\" Iceta", "Iestyn \"Monster Iestyn\" Jealous", "Jarel \"Arrow\" Jones", + "Alexander \"DrTapeworm\" Moench-Ford", "Stefan \"Stuf\" Rimalia", "Shane Mychal Sexton", "\"Spazzo\"", @@ -1045,27 +1220,34 @@ static const char *credits[] = { "\"SSNTails\"", "", "\1Level Design", + "Hank \"FuriousFox\" Brannock", "Matthew \"Fawfulfan\" Chapman", "Paul \"Boinciel\" Clempson", + "Sally \"TehRealSalt\" Cochenour", "Desmond \"Blade\" DesJardins", "Sherman \"CoatRack\" DesJardins", "Ben \"Mystic\" Geyer", "Nathan \"Jazz\" Giroux", + "Vivian \"toaster\" Grannell", "Dan \"Blitzzo\" Hagerstrand", + "James \"SeventhSentinel\" Hall", "Kepa \"Nev3r\" Iceta", "Thomas \"Shadow Hog\" Igoe", - "Erik \"Torgo\" Nielsen", + "Alexander \"DrTapeworm\" Moench-Ford", "\"Kaito Sinclaire\"", + "Anna \"QueenDelta\" Sandlin", "Wessel \"sphere\" Smit", "\"Spazzo\"", "\"SSNTails\"", "Rob Tisdell", + "\"Torgo\"", "Jarrett \"JEV3\" Voight", "Johnny \"Sonikku\" Wallbank", "Marco \"mazmazz\" Zafra", "", "\1Boss Design", "Ben \"Mystic\" Geyer", + "Vivian \"toaster\" Grannell", "Thomas \"Shadow Hog\" Igoe", "John \"JTE\" Muniz", "Samuel \"Prime 2.0\" Peters", @@ -1077,7 +1259,7 @@ static const char *credits[] = { "Cody \"SRB2 Playah\" Koester", "Skye \"OmegaVelocity\" Meredith", "Stephen \"HEDGESMFG\" Moellering", - "Nick \"ST218\" Molina", + "Rosalie \"ST218\" Molina", "Samuel \"Prime 2.0\" Peters", "Colin \"Sonict\" Pfaff", "Bill \"Tets\" Reed", @@ -1086,13 +1268,18 @@ static const char *credits[] = { "iD Software", "Doom Legacy Project", "FreeDoom Project", // Used some of the mancubus and rocket launcher sprites for Brak + "Kart Krew", "Alex \"MistaED\" Fuller", "Pascal \"CodeImp\" vd Heiden", // Doom Builder developer "Randi Heit ()", // For their MSPaint sprite that we nicked "Simon \"sirjuddington\" Judd", // SLADE developer // Acknowledged here are the following: // Minor merge request authors, see guideline above - // Golden - Expanded thin font + // - Golden - Expanded thin font + // Creators of small quantities of sprite/texture assets + // - Arietty - New Green Hill-styled textures + // - Scizor300 - the only other contributor to the 2.0 SRB2 Asset Pack + // - Revan/Icefox - the new Nimbus Ruins skybox "SRB2 Community Contributors", "", "\1Produced By", @@ -1101,30 +1288,41 @@ static const char *credits[] = { "\1Published By", "A 28K dialup modem", "", - "\1Thank you", - "\1for playing!", + "\1Thank you ", + "\1for playing! ", NULL }; +#define CREDITS_LEFT 8 +#define CREDITS_RIGHT ((BASEVIDWIDTH) - 8) + static struct { - UINT32 x, y; + UINT32 x; const char *patch; } credits_pics[] = { - { 8, 80+200* 1, "CREDIT01"}, - { 4, 80+200* 2, "CREDIT13"}, - {250, 80+200* 3, "CREDIT12"}, - { 8, 80+200* 4, "CREDIT03"}, - {248, 80+200* 5, "CREDIT11"}, - { 8, 80+200* 6, "CREDIT04"}, - {112, 80+200* 7, "CREDIT10"}, - {240, 80+200* 8, "CREDIT05"}, - {120, 80+200* 9, "CREDIT06"}, - { 8, 80+200*10, "CREDIT07"}, - { 8, 80+200*11, "CREDIT08"}, - {112, 80+200*12, "CREDIT09"}, - {0, 0, NULL} + {CREDITS_LEFT, "CREDIT01"}, + {CREDITS_RIGHT - (271 >> 1), "CREDIT02"}, + {CREDITS_LEFT, "CREDIT03"}, + {CREDITS_RIGHT - (316 >> 1), "CREDIT04"}, + {CREDITS_LEFT, "CREDIT05"}, + {CREDITS_RIGHT - (399 >> 1), "CREDIT06"}, + {CREDITS_LEFT, "CREDIT07"}, + {CREDITS_RIGHT - (302 >> 1), "CREDIT08"}, + {CREDITS_LEFT, "CREDIT09"}, + {CREDITS_RIGHT - (250 >> 1), "CREDIT10"}, + {CREDITS_LEFT, "CREDIT11"}, + {CREDITS_RIGHT - (279 >> 1), "CREDIT12"}, + //{(BASEVIDWIDTH - (279 >> 1)) >> 1, "CREDIT12"}, + // CREDIT13 is extra art and is not shown by default + {0, NULL} }; +#undef CREDITS_LEFT +#undef CREDITS_RIGHT + +static UINT32 credits_height = 0; +static const UINT8 credits_numpics = sizeof(credits_pics)/sizeof(credits_pics[0]) - 1; + void F_StartCredits(void) { G_SetGamestate(GS_CREDITS); @@ -1133,7 +1331,7 @@ void F_StartCredits(void) M_ClearMenus(true); // Save the second we enter the credits - if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && cursaveslot >= 0) + if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && cursaveslot > 0) G_SaveGame((UINT32)cursaveslot); if (creditscutscene) @@ -1146,8 +1344,9 @@ void F_StartCredits(void) paused = false; CON_ToggleOff(); S_StopMusic(); + S_StopSounds(); - S_ChangeMusicInternal("credit", false); + S_ChangeMusicInternal("_creds", true); finalecount = 0; animtimer = 0; @@ -1157,16 +1356,23 @@ void F_StartCredits(void) void F_CreditDrawer(void) { UINT16 i; - fixed_t y = (80<>1); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + // Zig Zagz + V_DrawScaledPatch(-16, zagpos, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_PATCH)); + V_DrawScaledPatch(-16, zagpos - 320, V_SNAPTOLEFT, W_CachePatchName("LTZIGZAG", PU_PATCH)); + V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_PATCH)); + V_DrawScaledPatch(BASEVIDWIDTH + 16, zagpos - 320, V_SNAPTORIGHT|V_FLIP, W_CachePatchName("LTZIGZAG", PU_PATCH)); + // Draw background pictures first for (i = 0; credits_pics[i].patch; i++) - V_DrawSciencePatch(credits_pics[i].x<>1); + V_DrawSciencePatch(credits_pics[i].x<>1); // Dim the background - V_DrawFadeScreen(); + V_DrawFadeScreen(0xFF00, 16); // Draw credits text on top for (i = 0; credits[i]; i++) @@ -1181,6 +1387,11 @@ void F_CreditDrawer(void) V_DrawCreditString((160 - (V_CreditStringWidth(&credits[i][1])>>1))<>FRACBITS > -10) + V_DrawStringAtFixed((BASEVIDWIDTH-V_StringWidth(&credits[i][1], V_ALLOWLOWERCASE|V_YELLOWMAP))<>1, y, V_ALLOWLOWERCASE|V_YELLOWMAP, &credits[i][1]); + y += 12<>FRACBITS > -10) V_DrawStringAtFixed(32<>1); + + // Calculate credits height to display art properly + if (credits_height == 0) + { + for (i = 0; credits[i]; i++) + { + switch(credits[i][0]) + { + case 0: credits_height += 80; break; + case 1: credits_height += 30; break; + default: credits_height += 12; break; + } + } + credits_height = 131*credits_height/80; // account for scroll speeds. This is a guess now, so you may need to update this if you change the credits length. + } // Draw credits text on top for (i = 0; credits[i]; i++) @@ -1264,7 +1490,7 @@ boolean F_CreditResponder(event_t *event) break; } - if (!(timesBeaten) && !(netgame || multiplayer)) + if (!(timesBeaten) && !(netgame || multiplayer) && !cv_debug) return false; if (event->type != ev_keydown) @@ -1283,20 +1509,21 @@ boolean F_CreditResponder(event_t *event) // ============ // EVALUATION // ============ -#define INTERVAL 50 -#define TRANSLEVEL V_80TRANS -static INT32 eemeralds_start; -static boolean drawemblem = false, drawchaosemblem = false; + +#define SPARKLLOOPTIME 7 // must be odd void F_StartGameEvaluation(void) { - // Credits option in secrets menu - if (cursaveslot == -2) + // Credits option in extras menu + if (cursaveslot == -1) { + S_FadeOutStopMusic(2*MUSICRATE); F_StartGameEnd(); return; } + S_FadeOutStopMusic(5*MUSICRATE); + G_SetGamestate(GS_EVALUATION); // Just in case they're open ... somehow @@ -1305,79 +1532,125 @@ void F_StartGameEvaluation(void) // Save the second we enter the evaluation // We need to do this again! Remember, it's possible a mod designed skipped // the credits sequence! - if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && cursaveslot >= 0) + if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && cursaveslot > 0) G_SaveGame((UINT32)cursaveslot); + goodending = (ALL7EMERALDS(emeralds)); + gameaction = ga_nothing; paused = false; CON_ToggleOff(); - finalecount = 0; + finalecount = -1; + sparklloop = 0; } void F_GameEvaluationDrawer(void) { INT32 x, y, i; - const fixed_t radius = 48*FRACUNIT; angle_t fa; INT32 eemeralds_cur; char patchname[7] = "CEMGx0"; + const char* endingtext = (goodending ? "CONGRATULATIONS!" : "TRY AGAIN..."); V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Draw all the good crap here. - if (ALL7EMERALDS(emeralds)) - V_DrawString(114, 16, 0, "GOT THEM ALL!"); - else - V_DrawString(124, 16, 0, "TRY AGAIN!"); - eemeralds_start++; - eemeralds_cur = eemeralds_start; - - for (i = 0; i < 7; ++i) + if (finalecount > 0) { - fa = (FixedAngle(eemeralds_cur*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - x = 160 + FixedInt(FixedMul(FINECOSINE(fa),radius)); - y = 100 + FixedInt(FixedMul(FINESINE(fa),radius)); + INT32 scale = FRACUNIT; + patch_t *rockpat; + UINT8 *colormap[2] = {NULL, NULL}; + patch_t *glow; + INT32 trans = 0; - patchname[4] = 'A'+(char)i; - if (emeralds & (1<= 360) - eemeralds_start -= 360; - - if (finalecount == 5*TICRATE) - { - if ((!modifiedgame || savemoddata) && !(netgame || multiplayer)) + if (finalecount < 5) { - ++timesBeaten; + scale = (finalecount<<(FRACBITS-2)); + x += (30*(FRACUNIT-scale)); + y += (30*(FRACUNIT-scale)); + } - if (ALL7EMERALDS(emeralds)) - ++timesBeatenWithEmeralds; + if (goodending) + { + rockpat = W_CachePatchName(va("ROID00%.2d", 34 - (finalecount % 35)), PU_PATCH); + glow = W_CachePatchName(va("ENDGLOW%.1d", 2+(finalecount & 1)), PU_PATCH); + x -= FRACUNIT; + } + else + { + rockpat = W_CachePatchName("ROID0000", PU_LEVEL); + glow = W_CachePatchName(va("ENDGLOW%.1d", (finalecount & 1)), PU_PATCH); + } - if (ultimatemode) - ++timesBeatenUltimate; + if (finalecount >= 5) + trans = (finalecount-5)>>1; + if (trans < 10) + V_DrawFixedPatch(x, y, scale, trans< (finalecount/SPARKLLOOPTIME)) + j = (finalecount/SPARKLLOOPTIME); + while (j) + { + if (j > 1 || sparklloop >= 2) + { + // if j == 0 - alternate between 0 and 1 + // 1 - 1 and 2 + // 2 - 2 and not rendered + V_DrawFixedPatch(x+sparkloffs[j-1][0], y+sparkloffs[j-1][1], FRACUNIT, 0, W_CachePatchName(va("ENDSPKL%.1d", (j - ((sparklloop & 1) ? 0 : 1))), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_AQUA, GTC_CACHE)); + } + j--; + } + } + else + { + patch_t *eggrock = W_CachePatchName("ENDEGRK5", PU_PATCH); + V_DrawFixedPatch(x, y, scale, 0, eggrock, colormap[0]); + if (trans < 10) + V_DrawFixedPatch(x, y, scale, trans<>ANGLETOFINESHIFT) & FINEMASK; + x = (BASEVIDWIDTH<<(FRACBITS-1)) + (60*FINECOSINE(fa)); + y = ((BASEVIDHEIGHT+16)<<(FRACBITS-1)) + (60*FINESINE(fa)); + eemeralds_cur += (360<= 5*TICRATE) { - if (drawemblem) - V_DrawScaledPatch(120, 192, 0, W_CachePatchName("NWNGA0", PU_CACHE)); - - if (drawchaosemblem) - V_DrawScaledPatch(200, 192, 0, W_CachePatchName("NWNGA0", PU_CACHE)); - V_DrawString(8, 16, V_YELLOWMAP, "Unlocked:"); if (!(netgame) && (!modifiedgame || savemoddata)) @@ -1396,20 +1669,626 @@ void F_GameEvaluationDrawer(void) } } else if (netgame) - V_DrawString(8, 96, V_YELLOWMAP, "Prizes only\nawarded in\nsingle player!"); + V_DrawString(8, 96, V_YELLOWMAP, "Multiplayer games\ncan't unlock\nextras!"); else - V_DrawString(8, 96, V_YELLOWMAP, "Prizes not\nawarded in\nmodified games!"); + V_DrawString(8, 96, V_YELLOWMAP, "Modified games\ncan't unlock\nextras!"); } +#endif } void F_GameEvaluationTicker(void) { - finalecount++; - - if (finalecount > 10*TICRATE) + if (++finalecount > 10*TICRATE) + { F_StartGameEnd(); + return; + } + + if (!goodending) + { + if (sparklloop) + sparklloop--; + + if (finalecount == (5*TICRATE)/2 + || finalecount == (7*TICRATE)/2 + || finalecount == ((7*TICRATE)/2)+5) + { + S_StartSound(NULL, sfx_s3k5c); + sparklloop = 10; + } + } + else if (++sparklloop == SPARKLLOOPTIME) // time to roll the randomisation again + { + angle_t workingangle = FixedAngle((M_RandomKey(360))<>ANGLETOFINESHIFT; + fixed_t workingradius = M_RandomKey(26); + + sparkloffs[2][0] = sparkloffs[1][0]; + sparkloffs[2][1] = sparkloffs[1][1]; + sparkloffs[1][0] = sparkloffs[0][0]; + sparkloffs[1][1] = sparkloffs[0][1]; + + sparkloffs[0][0] = (30< (XTRA_ENDING+2)) + { + sprdef = &skins[skinnum].sprites[SPR2_XTRA]; + // character head, skin specific + sprframe = &sprdef->spriteframes[XTRA_ENDING]; + endfwrk[0] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + sprframe = &sprdef->spriteframes[XTRA_ENDING+1]; + endfwrk[1] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + sprframe = &sprdef->spriteframes[XTRA_ENDING+2]; + endfwrk[2] = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + } + else // Show a star if your character doesn't have an ending firework display. (Basically the MISSINGs for this) + { + endfwrk[0] = W_CachePatchName("ENDFWRK3", PU_PATCH); + endfwrk[1] = W_CachePatchName("ENDFWRK4", PU_PATCH); + endfwrk[2] = W_CachePatchName("ENDFWRK5", PU_PATCH); + } + + endbrdr[0] = W_CachePatchName("ENDBRDR2", PU_PATCH); + } + else + { + // eggman, skin nonspecific + endfwrk[0] = W_CachePatchName("ENDFWRK0", PU_PATCH); + endfwrk[1] = W_CachePatchName("ENDFWRK1", PU_PATCH); + endfwrk[2] = W_CachePatchName("ENDFWRK2", PU_PATCH); + + endbrdr[0] = W_CachePatchName("ENDBRDR0", PU_LEVEL); + } +} + +static void F_CacheGoodEnding(void) +{ + endegrk[0] = W_CachePatchName("ENDEGRK2", PU_PATCH); + endegrk[1] = W_CachePatchName("ENDEGRK3", PU_PATCH); + + endglow[0] = W_CachePatchName("ENDGLOW2", PU_PATCH); + endglow[1] = W_CachePatchName("ENDGLOW3", PU_PATCH); + + endxpld[0] = W_CachePatchName("ENDEGRK4", PU_PATCH); +} + +void F_StartEnding(void) +{ + G_SetGamestate(GS_ENDING); + wipetypepost = INT16_MAX; + + // Just in case they're open ... somehow + M_ClearMenus(true); + + // Save before the credits sequence. + if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && cursaveslot > 0) + G_SaveGame((UINT32)cursaveslot); + + gameaction = ga_nothing; + paused = false; + CON_ToggleOff(); + S_StopMusic(); // todo: placeholder + S_StopSounds(); + + finalecount = -10; // what? this totally isn't a hack. why are you asking? + + memset(sparkloffs, 0, sizeof(INT32)*3*2); + sparklloop = 0; + + F_CacheEnding(); +} + +void F_EndingTicker(void) +{ + if (++finalecount > STOPPINGPOINT) + { + F_StartCredits(); + wipetypepre = INT16_MAX; + return; + } + + if (finalecount == -8) + S_ChangeMusicInternal((goodending ? "_endg" : "_endb"), false); + + if (goodending && finalecount == INFLECTIONPOINT) // time to swap some assets + F_CacheGoodEnding(); + + if (++sparklloop == SPARKLLOOPTIME) // time to roll the randomisation again + { + angle_t workingangle = FixedAngle((M_RandomRange(-170, 80))<>ANGLETOFINESHIFT; + fixed_t workingradius = M_RandomKey(26); + + sparkloffs[0][0] = (30<= INFLECTIONPOINT) // time to swap some assets + F_CacheGoodEnding(); + } + + if (!goodending || finalecount < INFLECTIONPOINT) + rockpat = W_CachePatchName("ROID0000", PU_PATCH); + else + rockpat = W_CachePatchName(va("ROID00%.2d", 34 - ((finalecount - INFLECTIONPOINT) % 35)), PU_PATCH); + + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + + parallaxticker = finalecount - INFLECTIONPOINT; + x = -((parallaxticker*20)< -19) + { + INT32 trans = (-parallaxticker)>>1; + if (trans < 0) + trans = 0; + V_DrawFixedPatch((200< 0) // gunchedrock + { + INT32 scale = FRACUNIT + ((parallaxticker-10)<<7); + INT32 trans = parallaxticker>>2; + UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_JET, GTC_CACHE); + + if (parallaxticker < 10) + { + tweakx = parallaxticker< 0) + { + i -= (3+(tweakx<<1)); + j += tweaky<<2; + } + + if (parallaxticker <= 70) // eggrock/blackrock + { + INT32 trans; + fixed_t scale = FRACUNIT; + UINT8 *colormap[2] = {NULL, NULL}; + + x += i; + y += j; + + if (parallaxticker > 66) + { + scale = ((70 - parallaxticker)<<(FRACBITS-2)); + x += (30*(FRACUNIT-scale)); + y += (30*(FRACUNIT-scale)); + } + else if ((parallaxticker > 60) || (goodending && parallaxticker > 0)) + ; + else + { + doexplosions = true; + if (!sparklloop) + { + x += ((sparkloffs[0][0] < 30< INFLECTIONPOINT) + parallaxticker -= 40; + + if ((-parallaxticker/4) < 5) + { + trans = (-parallaxticker/4) + 5; + if (trans < 0) + trans = 0; + V_DrawFixedPatch(x, y, scale, trans< INFLECTIONPOINT) + { + if (finalecount < INFLECTIONPOINT+10) + V_DrawFadeFill(24, 24, BASEVIDWIDTH-48, BASEVIDHEIGHT-48, 0, 0, INFLECTIONPOINT+10-finalecount); + parallaxticker -= 30; + } + + if ((parallaxticker/2) > -15) + colormap[0] = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); + V_DrawFixedPatch(x, y, scale, 0, rockpat, colormap[0]); + if ((parallaxticker/2) > -25) + { + trans = (parallaxticker/2) + 15; + if (trans < 0) + trans = -trans; + if (trans < 10) + V_DrawFixedPatch(x, y, scale, trans< INFLECTIONPOINT) + { + if (finalecount < INFLECTIONPOINT+10) + V_DrawFixedPatch(x, y, scale, (finalecount-INFLECTIONPOINT)<= 3 && doexplosions) + { + INT32 boomtime = parallaxticker - sparklloop; + + x = ((((BASEVIDWIDTH-82)/2)+11)< INFLECTIONPOINT && finalecount < INFLECTIONPOINT+10) + V_DrawScaledPatch(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, (finalecount-INFLECTIONPOINT)<= TICRATE && finalecount < INFLECTIONPOINT) + { + INT32 workingtime = finalecount - TICRATE; + fixed_t radius = ((vid.width/vid.dupx)*(INFLECTIONPOINT - TICRATE - workingtime))/(INFLECTIONPOINT - TICRATE); + angle_t fa; + INT32 eemeralds_cur[4]; + char patchname[7] = "CEMGx0"; + + radius <<= FRACBITS; + + for (i = 0; i < 4; ++i) + { + if (i == 1) + workingtime -= sparklloop; + else if (i) + workingtime -= SPARKLLOOPTIME; + eemeralds_cur[i] = (workingtime % 360)<>ANGLETOFINESHIFT) & FINEMASK; + x = (BASEVIDWIDTH<<(FRACBITS-1)) + FixedMul(FINECOSINE(fa),radius); + y = (BASEVIDHEIGHT<<(FRACBITS-1)) + FixedMul(FINESINE(fa),radius); + eemeralds_cur[j] += (360<>ANGLETOFINESHIFT) & FINEMASK; + x = (BASEVIDWIDTH<<(FRACBITS-1)) + FixedMul(FINECOSINE(fa),radius); + y = ((BASEVIDHEIGHT+16)<<(FRACBITS-1)) + FixedMul(FINESINE(fa),radius); + eemeralds_cur[0] += (360< 20) + + // look, i make an ending for you last-minute, the least you could do is let me have this + if (cv_soundtest.value == 413) + { + INT32 trans = 0; + boolean donttouch = false; + const char *str; + if (goodending) + str = va("[S] %s: Engage.", skins[players[consoleplayer].skin].realname); + else + str = "[S] Eggman: Abscond."; + + if (finalecount < 10) + trans = (10-finalecount)/2; + else if (finalecount > STOPPINGPOINT - 20) + { + trans = 10 + (finalecount - STOPPINGPOINT)/2; + donttouch = true; + } + + if (trans < 10) + { + //colset(linkmap, 164, 165, 169); -- the ideal purple colour to represent a clicked in-game link, but not worth it just for a soundtest-controlled secret + V_DrawCenteredString(BASEVIDWIDTH/2, 8, V_ALLOWLOWERCASE|(trans<'|(trans<= STOPPINGPOINT-TICRATE) ? V_PURPLEMAP : V_BLUEMAP)|(trans<"); + } + + if (finalecount > STOPPINGPOINT-(20+(2*TICRATE))) + { + INT32 trans2 = abs((5*FINECOSINE((FixedAngle((finalecount*5)<>ANGLETOFINESHIFT & FINEMASK)))>>FRACBITS)+2; + if (!donttouch) + { + trans = 10 + (STOPPINGPOINT-(20+(2*TICRATE))) - finalecount; + if (trans > trans2) + trans2 = trans; + } + else + trans2 += 2*trans; + if (trans2 < 10) + V_DrawCharacter(26, BASEVIDHEIGHT-33, '\x1C'|(trans2< 0) - (scrollxspeed < 0), tilex; + INT32 yscrolled, y, yneg = (scrollyspeed > 0) - (scrollyspeed < 0), tiley; + boolean xispos = (scrollxspeed >= 0), yispos = (scrollyspeed >= 0); + INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + INT16 patwidth, patheight; + INT32 pw, ph; // scaled by dupz + patch_t *pat; + INT32 i, j; + + if (rendermode == render_none) + return; + + if (!patchname || !patchname[0]) + { + V_DrawFill(0, 0, vid.width, vid.height, 31); + return; + } + + if (!scrollxspeed && !scrollyspeed) + { + V_DrawPatchFill(W_CachePatchName(patchname, PU_PATCH)); + return; + } + + pat = W_CachePatchName(patchname, PU_PATCH); + + patwidth = SHORT(pat->width); + patheight = SHORT(pat->height); + pw = patwidth * dupz; + ph = patheight * dupz; + + tilex = max(FixedCeil(FixedDiv(vid.width, pw)) >> FRACBITS, 1)+2; // one tile on both sides of center + tiley = max(FixedCeil(FixedDiv(vid.height, ph)) >> FRACBITS, 1)+2; + + xscrolltimer = ((menuanimtimer*scrollxspeed)/16 + patwidth*xneg) % (patwidth); + yscrolltimer = ((menuanimtimer*scrollyspeed)/16 + patheight*yneg) % (patheight); + + // coordinate offsets + xscrolled = xscrolltimer * dupz; + yscrolled = yscrolltimer * dupz; + + for (x = (xispos) ? -pw*(tilex-1)+pw : 0, i = 0; + i < tilex; + x += pw, i++) + { + for (y = (yispos) ? -ph*(tiley-1)+ph : 0, j = 0; + j < tiley; + y += ph, j++) + { + V_DrawScaledPatch( + (xispos) ? xscrolled - x : x + xscrolled, + (yispos) ? yscrolled - y : y + yscrolled, + V_NOSCALESTART, pat); + } + } + + W_UnlockCachedPatch(pat); +} + +#define LOADTTGFX(arr, name, maxf) \ +lumpnum = W_CheckNumForName(name); \ +if (lumpnum != LUMPERROR) \ +{ \ + arr[0] = W_CachePatchName(name, PU_LEVEL); \ + arr[min(1, maxf-1)] = 0; \ +} \ +else if (strlen(name) <= 6) \ +{ \ + fixed_t cnt = strlen(name); \ + strncpy(lumpname, name, 7); \ + for (i = 0; i < maxf-1; i++) \ + { \ + sprintf(&lumpname[cnt], "%.2hu", (UINT16)(i+1)); \ + lumpname[8] = 0; \ + lumpnum = W_CheckNumForName(lumpname); \ + if (lumpnum != LUMPERROR) \ + arr[i] = W_CachePatchName(lumpname, PU_LEVEL); \ + else \ + break; \ + } \ + arr[min(i, maxf-1)] = 0; \ +} \ +else \ + arr[0] = 0; + +static void F_CacheTitleScreen(void) +{ + switch(curttmode) + { + case TTMODE_OLD: + case TTMODE_NONE: + ttbanner = W_CachePatchName("TTBANNER", PU_LEVEL); + ttwing = W_CachePatchName("TTWING", PU_LEVEL); + ttsonic = W_CachePatchName("TTSONIC", PU_LEVEL); + ttswave1 = W_CachePatchName("TTSWAVE1", PU_LEVEL); + ttswave2 = W_CachePatchName("TTSWAVE2", PU_LEVEL); + ttswip1 = W_CachePatchName("TTSWIP1", PU_LEVEL); + ttsprep1 = W_CachePatchName("TTSPREP1", PU_LEVEL); + ttsprep2 = W_CachePatchName("TTSPREP2", PU_LEVEL); + ttspop1 = W_CachePatchName("TTSPOP1", PU_LEVEL); + ttspop2 = W_CachePatchName("TTSPOP2", PU_LEVEL); + ttspop3 = W_CachePatchName("TTSPOP3", PU_LEVEL); + ttspop4 = W_CachePatchName("TTSPOP4", PU_LEVEL); + ttspop5 = W_CachePatchName("TTSPOP5", PU_LEVEL); + ttspop6 = W_CachePatchName("TTSPOP6", PU_LEVEL); + ttspop7 = W_CachePatchName("TTSPOP7", PU_LEVEL); + break; + + // don't load alacroix gfx yet; we do that upon first draw. + case TTMODE_ALACROIX: + break; + + case TTMODE_USER: + { + UINT16 i; + lumpnum_t lumpnum; + char lumpname[9]; + + LOADTTGFX(ttuser, curttname, TTMAX_USER) + break; + } + } +} + void F_StartTitleScreen(void) { + if (menupres[MN_MAIN].musname[0]) + S_ChangeMusic(menupres[MN_MAIN].musname, menupres[MN_MAIN].mustrack, menupres[MN_MAIN].muslooping); + else + S_ChangeMusicInternal("_title", looptitle); + if (gamestate != GS_TITLESCREEN && gamestate != GS_WAITINGPLAYERS) - finalecount = 0; + { + ttuser_count =\ + ttloaded[0] = ttloaded[1] = ttloaded[2] = ttloaded[3] = ttloaded[4] = ttloaded[5] =\ + testttscale = activettscale =\ + sonic_blink = sonic_blink_twice = sonic_idle_start = sonic_idle_end =\ + tails_blink = tails_blink_twice = tails_idle_start = tails_idle_end =\ + knux_blink = knux_blink_twice = knux_idle_start = knux_idle_end = 0; + + sonic_blinked_already = tails_blinked_already = knux_blinked_already = 1; // don't blink on the first idle cycle + + if (curttmode == TTMODE_ALACROIX) + finalecount = -3; // hack so that frames don't advance during the entry wipe + else + finalecount = 0; + wipetypepost = menupres[MN_MAIN].enterwipe; + } else wipegamestate = GS_TITLESCREEN; + + if (titlemap) + { + mapthing_t *startpos; + + gamestate_t prevwipegamestate = wipegamestate; + titlemapinaction = TITLEMAP_LOADING; + titlemapcameraref = NULL; + gamemap = titlemap; + + if (!mapheaderinfo[gamemap-1]) + P_AllocMapHeader(gamemap-1); + + maptol = mapheaderinfo[gamemap-1]->typeoflevel; + globalweather = mapheaderinfo[gamemap-1]->weather; + + G_DoLoadLevel(true); + if (!titlemap) + return; + + players[displayplayer].playerstate = PST_DEAD; // Don't spawn the player in dummy (I'm still a filthy cheater) + + // Set Default Position + if (playerstarts[0]) + startpos = playerstarts[0]; + else if (deathmatchstarts[0]) + startpos = deathmatchstarts[0]; + else + startpos = NULL; + + if (startpos) + { + camera.x = startpos->x << FRACBITS; + camera.y = startpos->y << FRACBITS; + camera.subsector = R_PointInSubsector(camera.x, camera.y); + camera.z = camera.subsector->sector->floorheight + (startpos->z << FRACBITS); + camera.angle = (startpos->angle % 360)*ANG1; + camera.aiming = 0; + } + else + { + camera.x = camera.y = camera.z = camera.angle = camera.aiming = 0; + camera.subsector = NULL; // toast is filthy too + } + + camera.chase = true; + camera.height = 0; + + // Run enter linedef exec for MN_MAIN, since this is where we start + if (menupres[MN_MAIN].entertag) + P_LinedefExecute(menupres[MN_MAIN].entertag, players[displayplayer].mo, NULL); + + wipegamestate = prevwipegamestate; + } + else + { + titlemapinaction = TITLEMAP_OFF; + gamemap = 1; // g_game.c + CON_ClearHUD(); + } + G_SetGamestate(GS_TITLESCREEN); - CON_ClearHUD(); // IWAD dependent stuff. - S_ChangeMusicInternal("titles", looptitle); - - animtimer = 0; + animtimer = skullAnimCounter = 0; demoDelayLeft = demoDelayTime; demoIdleLeft = demoIdleTime; - ttbanner = W_CachePatchName("TTBANNER", PU_LEVEL); - ttwing = W_CachePatchName("TTWING", PU_LEVEL); - ttsonic = W_CachePatchName("TTSONIC", PU_LEVEL); - ttswave1 = W_CachePatchName("TTSWAVE1", PU_LEVEL); - ttswave2 = W_CachePatchName("TTSWAVE2", PU_LEVEL); - ttswip1 = W_CachePatchName("TTSWIP1", PU_LEVEL); - ttsprep1 = W_CachePatchName("TTSPREP1", PU_LEVEL); - ttsprep2 = W_CachePatchName("TTSPREP2", PU_LEVEL); - ttspop1 = W_CachePatchName("TTSPOP1", PU_LEVEL); - ttspop2 = W_CachePatchName("TTSPOP2", PU_LEVEL); - ttspop3 = W_CachePatchName("TTSPOP3", PU_LEVEL); - ttspop4 = W_CachePatchName("TTSPOP4", PU_LEVEL); - ttspop5 = W_CachePatchName("TTSPOP5", PU_LEVEL); - ttspop6 = W_CachePatchName("TTSPOP6", PU_LEVEL); - ttspop7 = W_CachePatchName("TTSPOP7", PU_LEVEL); + F_CacheTitleScreen(); +} + +static void F_UnloadAlacroixGraphics(SINT8 oldttscale) +{ + // This all gets freed by PU_LEVEL when exiting the menus. + // When re-visiting the menus (e.g., from exiting in-game), the gfx are force-reloaded. + // So leftover addresses here should not be a problem. + + UINT16 i; + oldttscale--; // zero-based index + for (i = 0; i < TTMAX_ALACROIX; i++) + { + if(ttembl[oldttscale][i]) { Z_Free(ttembl[oldttscale][i]); ttembl[oldttscale][i] = 0; } + if(ttribb[oldttscale][i]) { Z_Free(ttribb[oldttscale][i]); ttribb[oldttscale][i] = 0; } + if(ttsont[oldttscale][i]) { Z_Free(ttsont[oldttscale][i]); ttsont[oldttscale][i] = 0; } + if(ttrobo[oldttscale][i]) { Z_Free(ttrobo[oldttscale][i]); ttrobo[oldttscale][i] = 0; } + if(tttwot[oldttscale][i]) { Z_Free(tttwot[oldttscale][i]); tttwot[oldttscale][i] = 0; } + if(ttrbtx[oldttscale][i]) { Z_Free(ttrbtx[oldttscale][i]); ttrbtx[oldttscale][i] = 0; } + if(ttsoib[oldttscale][i]) { Z_Free(ttsoib[oldttscale][i]); ttsoib[oldttscale][i] = 0; } + if(ttsoif[oldttscale][i]) { Z_Free(ttsoif[oldttscale][i]); ttsoif[oldttscale][i] = 0; } + if(ttsoba[oldttscale][i]) { Z_Free(ttsoba[oldttscale][i]); ttsoba[oldttscale][i] = 0; } + if(ttsobk[oldttscale][i]) { Z_Free(ttsobk[oldttscale][i]); ttsobk[oldttscale][i] = 0; } + if(ttsodh[oldttscale][i]) { Z_Free(ttsodh[oldttscale][i]); ttsodh[oldttscale][i] = 0; } + if(tttaib[oldttscale][i]) { Z_Free(tttaib[oldttscale][i]); tttaib[oldttscale][i] = 0; } + if(tttaif[oldttscale][i]) { Z_Free(tttaif[oldttscale][i]); tttaif[oldttscale][i] = 0; } + if(tttaba[oldttscale][i]) { Z_Free(tttaba[oldttscale][i]); tttaba[oldttscale][i] = 0; } + if(tttabk[oldttscale][i]) { Z_Free(tttabk[oldttscale][i]); tttabk[oldttscale][i] = 0; } + if(tttabt[oldttscale][i]) { Z_Free(tttabt[oldttscale][i]); tttabt[oldttscale][i] = 0; } + if(tttaft[oldttscale][i]) { Z_Free(tttaft[oldttscale][i]); tttaft[oldttscale][i] = 0; } + if(ttknib[oldttscale][i]) { Z_Free(ttknib[oldttscale][i]); ttknib[oldttscale][i] = 0; } + if(ttknif[oldttscale][i]) { Z_Free(ttknif[oldttscale][i]); ttknif[oldttscale][i] = 0; } + if(ttknba[oldttscale][i]) { Z_Free(ttknba[oldttscale][i]); ttknba[oldttscale][i] = 0; } + if(ttknbk[oldttscale][i]) { Z_Free(ttknbk[oldttscale][i]); ttknbk[oldttscale][i] = 0; } + if(ttkndh[oldttscale][i]) { Z_Free(ttkndh[oldttscale][i]); ttkndh[oldttscale][i] = 0; } + } + ttloaded[oldttscale] = false; +} + +static void F_LoadAlacroixGraphics(SINT8 newttscale) +{ + UINT16 i, j; + lumpnum_t lumpnum; + char lumpname[9]; + char names[22][5] = { + "EMBL", + "RIBB", + "SONT", + "ROBO", + "TWOT", + "RBTX", + "SOIB", + "SOIF", + "SOBA", + "SOBK", + "SODH", + "TAIB", + "TAIF", + "TABA", + "TABK", + "TABT", + "TAFT", + "KNIB", + "KNIF", + "KNBA", + "KNBK", + "KNDH" + }; + char lumpnames[22][7]; + + newttscale--; // 0-based index + + if (!ttloaded[newttscale]) + { + for (j = 0; j < 22; j++) + sprintf(&lumpnames[j][0], "T%.1hu%s", (UINT16)( (UINT8)newttscale+1 ), names[j]); + + LOADTTGFX(ttembl[newttscale], lumpnames[0], TTMAX_ALACROIX) + LOADTTGFX(ttribb[newttscale], lumpnames[1], TTMAX_ALACROIX) + LOADTTGFX(ttsont[newttscale], lumpnames[2], TTMAX_ALACROIX) + LOADTTGFX(ttrobo[newttscale], lumpnames[3], TTMAX_ALACROIX) + LOADTTGFX(tttwot[newttscale], lumpnames[4], TTMAX_ALACROIX) + LOADTTGFX(ttrbtx[newttscale], lumpnames[5], TTMAX_ALACROIX) + LOADTTGFX(ttsoib[newttscale], lumpnames[6], TTMAX_ALACROIX) + LOADTTGFX(ttsoif[newttscale], lumpnames[7], TTMAX_ALACROIX) + LOADTTGFX(ttsoba[newttscale], lumpnames[8], TTMAX_ALACROIX) + LOADTTGFX(ttsobk[newttscale], lumpnames[9], TTMAX_ALACROIX) + LOADTTGFX(ttsodh[newttscale], lumpnames[10], TTMAX_ALACROIX) + LOADTTGFX(tttaib[newttscale], lumpnames[11], TTMAX_ALACROIX) + LOADTTGFX(tttaif[newttscale], lumpnames[12], TTMAX_ALACROIX) + LOADTTGFX(tttaba[newttscale], lumpnames[13], TTMAX_ALACROIX) + LOADTTGFX(tttabk[newttscale], lumpnames[14], TTMAX_ALACROIX) + LOADTTGFX(tttabt[newttscale], lumpnames[15], TTMAX_ALACROIX) + LOADTTGFX(tttaft[newttscale], lumpnames[16], TTMAX_ALACROIX) + LOADTTGFX(ttknib[newttscale], lumpnames[17], TTMAX_ALACROIX) + LOADTTGFX(ttknif[newttscale], lumpnames[18], TTMAX_ALACROIX) + LOADTTGFX(ttknba[newttscale], lumpnames[19], TTMAX_ALACROIX) + LOADTTGFX(ttknbk[newttscale], lumpnames[20], TTMAX_ALACROIX) + LOADTTGFX(ttkndh[newttscale], lumpnames[21], TTMAX_ALACROIX) + + ttloaded[newttscale] = true; + } +} + +#undef LOADTTGFX + +static void F_FigureActiveTtScale(void) +{ + SINT8 newttscale = max(1, min(6, vid.dupx)); + SINT8 oldttscale = activettscale; + + if (needpatchrecache) + ttloaded[0] = ttloaded[1] = ttloaded[2] = ttloaded[3] = ttloaded[4] = ttloaded[5] = 0; + else + { + if (newttscale == testttscale) + return; + + // We have a new ttscale, so load gfx + if(oldttscale > 0) + F_UnloadAlacroixGraphics(oldttscale); + } + + testttscale = newttscale; + + // If ttscale is unavailable: look for lower scales, then higher scales. + for (; newttscale >= 1; newttscale--) + { + if (ttavailable[newttscale-1]) + break; + } + + for (; newttscale <= 6; newttscale++) + { + if (ttavailable[newttscale-1]) + break; + } + + activettscale = (newttscale >= 1 && newttscale <= 6) ? newttscale : 0; + + if(activettscale > 0) + F_LoadAlacroixGraphics(activettscale); } // (no longer) De-Demo'd Title Screen void F_TitleScreenDrawer(void) { + boolean hidepics; + fixed_t sc = FRACUNIT / max(1, curttscale); + INT32 whitefade = 0; + UINT8 *whitecol[2] = {NULL, NULL}; + if (modeattacking) return; // We likely came here from retrying. Don't do a damn thing. - // Draw that sky! - F_SkyScroll(titlescrollspeed); + if (needpatchrecache && (curttmode != TTMODE_ALACROIX)) + F_CacheTitleScreen(); - // Don't draw outside of the title screewn, or if the patch isn't there. - if (!ttwing || (gamestate != GS_TITLESCREEN && gamestate != GS_WAITINGPLAYERS)) + // Draw that sky! + if (curbgcolor >= 0) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor); + else if (!curbghide || !titlemapinaction || gamestate == GS_WAITINGPLAYERS) + F_SkyScroll(curbgxspeed, curbgyspeed, curbgname); + + // Don't draw outside of the title screen, or if the patch isn't there. + if (gamestate != GS_TITLESCREEN && gamestate != GS_WAITINGPLAYERS) return; - V_DrawScaledPatch(30, 14, 0, ttwing); + // Don't draw if title mode is set to Old/None and the patch isn't there + if (!ttwing && (curttmode == TTMODE_OLD || curttmode == TTMODE_NONE)) + return; - if (finalecount < 57) + // rei|miru: use title pics? + hidepics = curhidepics; + if (hidepics) + goto luahook; + + switch(curttmode) { - if (finalecount == 35) - V_DrawScaledPatch(115, 15, 0, ttspop1); - else if (finalecount == 36) - V_DrawScaledPatch(114, 15, 0,ttspop2); - else if (finalecount == 37) - V_DrawScaledPatch(113, 15, 0,ttspop3); - else if (finalecount == 38) - V_DrawScaledPatch(112, 15, 0,ttspop4); - else if (finalecount == 39) - V_DrawScaledPatch(111, 15, 0,ttspop5); - else if (finalecount == 40) - V_DrawScaledPatch(110, 15, 0, ttspop6); - else if (finalecount >= 41 && finalecount <= 44) - V_DrawScaledPatch(109, 15, 0, ttspop7); - else if (finalecount >= 45 && finalecount <= 48) - V_DrawScaledPatch(108, 12, 0, ttsprep1); - else if (finalecount >= 49 && finalecount <= 52) - V_DrawScaledPatch(107, 9, 0, ttsprep2); - else if (finalecount >= 53 && finalecount <= 56) - V_DrawScaledPatch(106, 6, 0, ttswip1); - V_DrawScaledPatch(93, 106, 0, ttsonic); - } - else - { - V_DrawScaledPatch(93, 106, 0,ttsonic); - if (finalecount/5 & 1) - V_DrawScaledPatch(100, 3, 0,ttswave1); - else - V_DrawScaledPatch(100,3, 0,ttswave2); + case TTMODE_OLD: + case TTMODE_NONE: + V_DrawSciencePatch(30<= 41 && finalecount <= 44) + V_DrawSciencePatch(109<= 45 && finalecount <= 48) + V_DrawSciencePatch(108<= 49 && finalecount <= 52) + V_DrawSciencePatch(107<= 53 && finalecount <= 56) + V_DrawSciencePatch(106< 29 && finalecount < 35) + V_DrawFadeScreen(0, (whitefade = 9)); + else if (finalecount > 34 && 44-finalecount > 0 && 44-finalecount < 10) + V_DrawFadeScreen(0, 44-finalecount); + if (39-finalecount > 0) + { + whitefade = (9 - (39-finalecount))<= 0) + V_DrawSciencePatch(89< 9) + { + INT32 fadeval = 0; + + // Fade between tic 10 and tic 29. + if (finalecount < 30) + { + UINT8 fadecounter = 30-finalecount; + switch(fadecounter) + { + case 20: case 19: fadeval = V_90TRANS; break; + case 18: case 17: fadeval = V_80TRANS; break; + case 16: case 15: fadeval = V_70TRANS; break; + case 14: case 13: fadeval = V_60TRANS; break; + case 12: case 11: fadeval = V_TRANSLUCENT; break; + case 10: case 9: fadeval = V_40TRANS; break; + case 8: case 7: fadeval = V_30TRANS; break; + case 6: case 5: fadeval = V_20TRANS; break; + case 4: case 3: fadeval = V_10TRANS; break; + default: break; + } + } + V_DrawSciencePatch(79< 15) + V_DrawSciencePatch(106<= KNUXIDLE) + { + if (!knux_idle_start || finalecount - knux_idle_start >= knux_idle_end) + { + if (knux_blink) + { + knux_blink = false; // don't run the cycle twice in a row + knux_blinked_already = true; + } + else if (knux_blinked_already) // or after the first non-blink cycle, either. + knux_blinked_already = false; + else + { + // make this chance higher than Sonic/Tails because Knux's idle cycle is longer + knux_blink = !(M_RandomKey(100) % 2); + knux_blink_twice = knux_blink ? !(M_RandomKey(100) % 5) : false; + } + knux_idle_start = finalecount; + } + + knux_idle_end = knux_blink ? (knux_blink_twice ? 17 : 7) : 46; + } + + if (finalecount >= TAILSIDLE) + { + if (!tails_idle_start || finalecount - tails_idle_start >= tails_idle_end) + { + if (tails_blink) + { + tails_blink = false; // don't run the cycle twice in a row + tails_blinked_already = true; + } + else if (tails_blinked_already) // or after the first non-blink cycle, either. + tails_blinked_already = false; + else + { + tails_blink = !(M_RandomKey(100) % 3); + tails_blink_twice = tails_blink ? !(M_RandomKey(100) % 5) : false; + } + tails_idle_start = finalecount; + } + + // Tails does not actually have a non-blink idle cycle, but make up a number + // so he can still blink. + tails_idle_end = tails_blink ? (tails_blink_twice ? 17 : 7) : 30; + } + + if (finalecount >= SONICIDLE) + { + if (!sonic_idle_start || finalecount - sonic_idle_start >= sonic_idle_end) + { + if (sonic_blink) + { + sonic_blink = false; // don't run the cycle twice in a row + sonic_blinked_already = true; + } + else if (sonic_blinked_already) // or after the first non-blink cycle, either. + sonic_blinked_already = false; + else + { + sonic_blink = !(M_RandomKey(100) % 3); + sonic_blink_twice = sonic_blink ? !(M_RandomKey(100) % 5) : false; + } + sonic_idle_start = finalecount; + } + + sonic_idle_end = sonic_blink ? (sonic_blink_twice ? 17 : 7) : 25; + } + + + // + // BACK TAIL LAYER + // + + if (finalecount >= TAILSSTART) + { + if (finalecount >= TAILSIDLE) + { + // + // Tails Back Tail Layer Idle + // + SINT8 taftcount = (finalecount - (TAILSIDLE)) % 41; + if (taftcount >= 0 && taftcount < 5 ) + V_DrawSciencePatch(TAILSX<= 5 && taftcount < 9 ) + V_DrawSciencePatch(TAILSX<= 9 && taftcount < 12 ) + V_DrawSciencePatch(TAILSX<= 12 && taftcount < 14 ) + V_DrawSciencePatch(TAILSX<= 14 && taftcount < 17 ) + V_DrawSciencePatch(TAILSX<= 17 && taftcount < 21 ) + V_DrawSciencePatch(TAILSX<= 21 && taftcount < 24 ) + V_DrawSciencePatch(TAILSX<= 24 && taftcount < 25 ) + V_DrawSciencePatch(TAILSX<= 25 && taftcount < 28 ) + V_DrawSciencePatch(TAILSX<= 28 && taftcount < 31 ) + V_DrawSciencePatch(TAILSX<= 31 && taftcount < 35 ) + V_DrawSciencePatch(TAILSX<= 35 && taftcount < 41 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART) + { + if (finalecount >= TAILSIDLE) + { + // + // Tails Front Tail Layer Idle + // + SINT8 tabtcount = (finalecount - (TAILSIDLE)) % 41; + if (tabtcount >= 0 && tabtcount < 6 ) + V_DrawSciencePatch(TAILSX<= 6 && tabtcount < 11 ) + V_DrawSciencePatch(TAILSX<= 11 && tabtcount < 15 ) + V_DrawSciencePatch(TAILSX<= 15 && tabtcount < 18 ) + V_DrawSciencePatch(TAILSX<= 18 && tabtcount < 19 ) + V_DrawSciencePatch(TAILSX<= 19 && tabtcount < 22 ) + V_DrawSciencePatch(TAILSX<= 22 && tabtcount < 27 ) + V_DrawSciencePatch(TAILSX<= 27 && tabtcount < 30 ) + V_DrawSciencePatch(TAILSX<= 30 && tabtcount < 31 ) + V_DrawSciencePatch(TAILSX<= 31 && tabtcount < 34 ) + V_DrawSciencePatch(TAILSX<= 34 && tabtcount < 37 ) + V_DrawSciencePatch(TAILSX<= 37 && tabtcount < 41 ) + V_DrawSciencePatch(TAILSX<= KNUXSTART) + { + if (finalecount < KNUXIDLE) + { + // + // Knux Back Layer Intro + // + if (finalecount >= KNUXSTART+0 && finalecount < KNUXSTART+6 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+6 && finalecount < KNUXSTART+10 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+10 && finalecount < KNUXSTART+13 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+13 && finalecount < KNUXSTART+15 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+15 && finalecount < KNUXSTART+18 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+18 && finalecount < KNUXSTART+22 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+22 && finalecount < KNUXSTART+28 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+28 && finalecount < KNUXSTART+32 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+32 && finalecount < KNUXSTART+35 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+35 && finalecount < KNUXSTART+40 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+40 && finalecount < KNUXSTART+41 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+41 && finalecount < KNUXSTART+44 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+44 && finalecount < KNUXSTART+50 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+50 && finalecount < KNUXSTART+56 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+56 && finalecount < KNUXSTART+57 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+57 && finalecount < KNUXSTART+60 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+60 && finalecount < KNUXSTART+63 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+63 && finalecount < KNUXSTART+67 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+67 && finalecount < KNUXSTART+70 ) + V_DrawSciencePatch(KNUXX<= 0 && idlecount < 2 ) + V_DrawSciencePatch(KNUXX<= 2 && idlecount < 6 ) + V_DrawSciencePatch(KNUXX<= 6 && idlecount < 7 ) + V_DrawSciencePatch(KNUXX<= 7 && idlecount < 10) + V_DrawSciencePatch(KNUXX<= 10 && idlecount < 12) + V_DrawSciencePatch(KNUXX<= 12 && idlecount < 16) + V_DrawSciencePatch(KNUXX<= 16 && idlecount < 17) + V_DrawSciencePatch(KNUXX<= TAILSSTART) + { + if (finalecount < TAILSIDLE) + { + // + // Tails Back Layer Intro + // + if (finalecount >= TAILSSTART+0 && finalecount < TAILSSTART+6 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+6 && finalecount < TAILSSTART+10 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+10 && finalecount < TAILSSTART+12 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+12 && finalecount < TAILSSTART+16 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+16 && finalecount < TAILSSTART+22 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+22 && finalecount < TAILSSTART+23 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+23 && finalecount < TAILSSTART+26 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+26 && finalecount < TAILSSTART+30 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+30 && finalecount < TAILSSTART+35 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+35 && finalecount < TAILSSTART+41 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+41 && finalecount < TAILSSTART+43 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+43 && finalecount < TAILSSTART+47 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+47 && finalecount < TAILSSTART+51 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+51 && finalecount < TAILSSTART+53 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+53 && finalecount < TAILSSTART+56 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+56 && finalecount < TAILSSTART+60 ) + V_DrawSciencePatch(TAILSX<= +0 && idlecount < +2 ) + V_DrawSciencePatch(TAILSX<= +2 && idlecount < +6 ) + V_DrawSciencePatch(TAILSX<= +6 && idlecount < +7 ) + V_DrawSciencePatch(TAILSX<= +7 && idlecount < +10) + V_DrawSciencePatch(TAILSX<= +10 && idlecount < +12) + V_DrawSciencePatch(TAILSX<= +12 && idlecount < +16) + V_DrawSciencePatch(TAILSX<= +16 && idlecount < +17) + V_DrawSciencePatch(TAILSX<= SONICSTART) + { + if (finalecount < SONICIDLE) + { + // + // Sonic Back Layer Intro + // + if (finalecount >= SONICSTART+0 && finalecount < SONICSTART+6 ) + V_DrawSciencePatch(SONICX<= SONICSTART+6 && finalecount < SONICSTART+11 ) + V_DrawSciencePatch(SONICX<= SONICSTART+11 && finalecount < SONICSTART+14 ) + V_DrawSciencePatch(SONICX<= SONICSTART+14 && finalecount < SONICSTART+18 ) + V_DrawSciencePatch(SONICX<= SONICSTART+18 && finalecount < SONICSTART+19 ) + V_DrawSciencePatch(SONICX<= SONICSTART+19 && finalecount < SONICSTART+27 ) + V_DrawSciencePatch(SONICX<= SONICSTART+27 && finalecount < SONICSTART+31 ) + V_DrawSciencePatch(SONICX<= SONICSTART+31 && finalecount < SONICSTART+33 ) + // Frame is blank + // V_DrawSciencePatch(SONICX<= SONICSTART+33 && finalecount < SONICSTART+36 ) + V_DrawSciencePatch(SONICX<= SONICSTART+36 && finalecount < SONICSTART+40 ) + V_DrawSciencePatch(SONICX<= SONICSTART+40 && finalecount < SONICSTART+44 ) + V_DrawSciencePatch(SONICX<= SONICSTART+44 && finalecount < SONICSTART+47 ) + V_DrawSciencePatch(SONICX<= SONICSTART+47 && finalecount < SONICSTART+49 ) + V_DrawSciencePatch(SONICX<= SONICSTART+49 && finalecount < SONICSTART+50 ) + V_DrawSciencePatch(SONICX<= SONICSTART+50 && finalecount < SONICSTART+53 ) + V_DrawSciencePatch(SONICX<= SONICSTART+53 && finalecount < SONICSTART+57 ) + V_DrawSciencePatch(SONICX<= 0 && idlecount < 2 ) + V_DrawSciencePatch(SONICX<= 2 && idlecount < 6 ) + V_DrawSciencePatch(SONICX<= 6 && idlecount < 7 ) + V_DrawSciencePatch(SONICX<= 7 && idlecount < 10) + V_DrawSciencePatch(SONICX<= 10 && idlecount < 12) + V_DrawSciencePatch(SONICX<= 12 && idlecount < 16) + V_DrawSciencePatch(SONICX<= 16 && idlecount < 17) + V_DrawSciencePatch(SONICX< 29) + V_DrawSciencePatch(39<= KNUXSTART) + { + if (finalecount < KNUXIDLE) + { + // + // Knux Front Layer Intro + // + if (finalecount >= KNUXSTART+22 && finalecount < KNUXSTART+28 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+28 && finalecount < KNUXSTART+32 ) + V_DrawSciencePatch(KNUXX<= KNUXSTART+32 && finalecount < KNUXSTART+35 ) + V_DrawSciencePatch(KNUXX<= 0 && idlecount < 5 ) + V_DrawSciencePatch(KNUXX<= 5 && idlecount < 10) + V_DrawSciencePatch(KNUXX<= 10 && idlecount < 13) + V_DrawSciencePatch(KNUXX<= 13 && idlecount < 14) + V_DrawSciencePatch(KNUXX<= 14 && idlecount < 17) + V_DrawSciencePatch(KNUXX<= 17 && idlecount < 21) + V_DrawSciencePatch(KNUXX<= 21 && idlecount < 27) + V_DrawSciencePatch(KNUXX<= 27 && idlecount < 32) + V_DrawSciencePatch(KNUXX<= 32 && idlecount < 34) + V_DrawSciencePatch(KNUXX<= 34 && idlecount < 37) + V_DrawSciencePatch(KNUXX<= 37 && idlecount < 39) + V_DrawSciencePatch(KNUXX<= 39 && idlecount < 42) + V_DrawSciencePatch(KNUXX<= 42 && idlecount < 46) + V_DrawSciencePatch(KNUXX<= TAILSSTART) + { + if (finalecount < TAILSIDLE) + { + // + // Tails Front Layer Intro + // + if (finalecount >= TAILSSTART+26 && finalecount < TAILSSTART+30 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+30 && finalecount < TAILSSTART+35 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+35 && finalecount < TAILSSTART+41 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+41 && finalecount < TAILSSTART+43 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+43 && finalecount < TAILSSTART+47 ) + V_DrawSciencePatch(TAILSX<= TAILSSTART+47 && finalecount < TAILSSTART+51 ) + V_DrawSciencePatch(TAILSX<= SONICSTART) + { + if (finalecount < SONICIDLE) + { + // + // Sonic Front Layer Intro + // + if (finalecount >= SONICSTART+19 && finalecount < SONICSTART+27 ) + V_DrawSciencePatch(SONICX<= SONICSTART+27 && finalecount < SONICSTART+31 ) + V_DrawSciencePatch(SONICX<= SONICSTART+31 && finalecount < SONICSTART+33 ) + V_DrawSciencePatch(SONICX<= SONICSTART+33 && finalecount < SONICSTART+36 ) + V_DrawSciencePatch(SONICX<= SONICSTART+36 && finalecount < SONICSTART+40 ) + V_DrawSciencePatch(SONICX<= SONICSTART+40 && finalecount < SONICSTART+44 ) + V_DrawSciencePatch(SONICX<= SONICSTART+44 && finalecount < SONICSTART+47 ) + V_DrawSciencePatch(SONICX<= SONICSTART+53 && finalecount < SONICSTART+57 ) + V_DrawSciencePatch(SONICX<= 0 && idlecount < 5 ) + V_DrawSciencePatch(SONICX<= 5 && idlecount < 8 ) + V_DrawSciencePatch(SONICX<= 8 && idlecount < 9 ) + V_DrawSciencePatch(SONICX<= 9 && idlecount < 12) + V_DrawSciencePatch(SONICX<= 12 && idlecount < 17) + V_DrawSciencePatch(SONICX<= 17 && idlecount < 19) + V_DrawSciencePatch(SONICX<= 19 && idlecount < 21) + V_DrawSciencePatch(SONICX<= 21 && idlecount < 22) + V_DrawSciencePatch(SONICX<= 22 && idlecount < 25) + V_DrawSciencePatch(SONICX< -1 && ttuser[curttloop]) + ttuser_count = curttloop; + else if (ttuser[max(0, ttuser_count-1)]) + ttuser_count = max(0, ttuser_count-1); + else + break; // draw nothing + } + + V_DrawSciencePatch(curttx<type != MT_ALTVIEWMAN) + { + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (!mo2) + continue; + + if (mo2->type != MT_ALTVIEWMAN) + continue; + + cameraref = titlemapcameraref = mo2; + break; + } + } + else + cameraref = titlemapcameraref; + + if (cameraref) + { + camera.x = cameraref->x; + camera.y = cameraref->y; + camera.z = cameraref->z; + camera.angle = cameraref->angle; + camera.aiming = cameraref->cusval; + camera.subsector = cameraref->subsector; + } + else + { + // Default behavior: Do a lil' camera spin if a title map is loaded; + camera.angle += titlescrollxspeed*ANG1/64; + } + } + // no demos to play? or, are they disabled? if (!cv_rollingdemos.value || !numDemos) return; @@ -1606,6 +3609,11 @@ void F_TitleDemoTicker(void) // ========== // CONTINUE // ========== + +static skin_t *contskins[2]; +static UINT8 cont_spr2[2][6]; +static UINT8 *contcolormaps[2]; + void F_StartContinue(void) { I_Assert(!netgame && !multiplayer); @@ -1616,6 +3624,7 @@ void F_StartContinue(void) return; } + wipestyleflags = WSF_FADEOUT; G_SetGamestate(GS_CONTINUING); gameaction = ga_nothing; @@ -1626,10 +3635,47 @@ void F_StartContinue(void) // In case menus are still up?!! M_ClearMenus(true); - S_ChangeMusicInternal("contsc", false); + S_ChangeMusicInternal("_conti", false); S_StopSounds(); - timetonext = TICRATE*11; + contskins[0] = &skins[players[consoleplayer].skin]; + cont_spr2[0][0] = P_GetSkinSprite2(contskins[0], SPR2_CNT1, NULL); + cont_spr2[0][2] = contskins[0]->contangle & 7; + contcolormaps[0] = R_GetTranslationColormap(players[consoleplayer].skin, players[consoleplayer].skincolor, GTC_CACHE); + cont_spr2[0][4] = contskins[0]->sprites[cont_spr2[0][0]].numframes; + cont_spr2[0][5] = max(1, contskins[0]->contspeed); + + if (botskin) + { + INT32 secondplaya; + + if (secondarydisplayplayer != consoleplayer) + secondplaya = secondarydisplayplayer; + else // HACK + secondplaya = 1; + + contskins[1] = &skins[players[secondplaya].skin]; + cont_spr2[1][0] = P_GetSkinSprite2(contskins[1], SPR2_CNT4, NULL); + cont_spr2[1][2] = (contskins[1]->contangle >> 3) & 7; + contcolormaps[1] = R_GetTranslationColormap(players[secondplaya].skin, players[secondplaya].skincolor, GTC_CACHE); + cont_spr2[1][4] = contskins[1]->sprites[cont_spr2[1][0]].numframes; + if (cont_spr2[1][0] == SPR2_CNT4) + cont_spr2[1][5] = 4; // sorry, this one is hardcoded + else + cont_spr2[1][5] = max(1, contskins[1]->contspeed); + } + else + { + contskins[1] = NULL; + contcolormaps[1] = NULL; + cont_spr2[1][0] = cont_spr2[1][2] = cont_spr2[1][4] = cont_spr2[1][5] = 0; + } + + cont_spr2[0][1] = cont_spr2[0][3] =\ + cont_spr2[1][1] = cont_spr2[1][3] = 0; + + timetonext = (11*TICRATE)+11; + continuetime = 0; } // @@ -1638,47 +3684,198 @@ void F_StartContinue(void) // void F_ContinueDrawer(void) { - patch_t *contsonic; - INT32 i, x = (BASEVIDWIDTH/2) + 4, ncontinues = players[consoleplayer].continues; - if (ncontinues > 20) - ncontinues = 20; + spritedef_t *sprdef; + spriteframe_t *sprframe; + patch_t *patch; + INT32 i, x = (BASEVIDWIDTH>>1), ncontinues = players[consoleplayer].continues; + char numbuf[9] = "CONTNUM*"; + tic_t timeleft = (timetonext/TICRATE); + INT32 offsx = 0, offsy = 0, lift[2] = {0, 0}; - if (imcontinuing) - contsonic = W_CachePatchName("CONT2", PU_CACHE); - else - contsonic = W_CachePatchName("CONT1", PU_CACHE); + if (continuetime >= 3*TICRATE) + { + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); + return; + } V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - V_DrawCenteredString(BASEVIDWIDTH/2, 100, 0, "CONTINUE?"); - // Draw a Sonic! - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(contsonic->width))/2, 32, 0, contsonic); + if (timetonext >= (11*TICRATE)+10) + return; - // Draw the continue markers! Show continues minus one. - x -= ncontinues * 6; - for (i = 0; i < ncontinues; ++i) - V_DrawContinueIcon(x + (i*12), 140, 0, players[consoleplayer].skin, players[consoleplayer].skincolor); + V_DrawLevelTitle(x - (V_LevelNameWidth("Continue?")>>1), 16, 0, "Continue?"); - V_DrawCenteredString(BASEVIDWIDTH/2, 168, 0, va("\x82*\x80" " %02d " "\x82*\x80", timetonext/TICRATE)); + // Two stars... + patch = W_CachePatchName("CONTSTAR", PU_PATCH); + V_DrawScaledPatch(x-32, 160, 0, patch); + V_DrawScaledPatch(x+32, 160, 0, patch); + + // Time left! + if (timeleft > 9) + { + numbuf[7] = '1'; + V_DrawScaledPatch(x - 10, 160, 0, W_CachePatchName(numbuf, PU_PATCH)); + numbuf[7] = '0'; + V_DrawScaledPatch(x + 10, 160, 0, W_CachePatchName(numbuf, PU_PATCH)); + } + else + { + numbuf[7] = '0'+timeleft; + V_DrawScaledPatch(x, 160, 0, W_CachePatchName(numbuf, PU_PATCH)); + } + + // Draw the continue markers! Show continues. + if (ncontinues > 10) + { + if (!(continuetime & 1) || continuetime > 17) + V_DrawContinueIcon(x, 68, 0, players[consoleplayer].skin, players[consoleplayer].skincolor); + V_DrawScaledPatch(x+12, 66, 0, stlivex); + V_DrawRightAlignedString(x+38, 64, 0, + va("%d",(imcontinuing ? ncontinues-1 : ncontinues))); + } + else + { + x += (ncontinues/2) * 30; + if (!(ncontinues & 1)) + x -= 15; + for (i = 0; i < ncontinues; ++i) + { + if (i == (ncontinues/2) && ((continuetime & 1) || continuetime > 17)) + continue; + V_DrawContinueIcon(x - (i*30), 68, 0, players[consoleplayer].skin, players[consoleplayer].skincolor); + } + x = BASEVIDWIDTH>>1; + } + + // Spotlight + V_DrawScaledPatch(x, 140, 0, W_CachePatchName("CONTSPOT", PU_PATCH)); + + // warping laser + if (continuetime) + { + INT32 w = min(continuetime, 28), brightness = (continuetime>>1) & 7; + if (brightness > 3) + brightness = 8-brightness; + V_DrawFadeFill(x-w, 0, w<<1, 140, 0, 0, (3+brightness)); + } + + if (contskins[1]) + { + if (continuetime > 15) + { + angle_t work = FixedAngle((10*(continuetime-15))<>ANGLETOFINESHIFT; + offsy = FINESINE(work)<<1; + offsx = (27*FINECOSINE(work))>>1; + } + else + offsx = 27<<(FRACBITS-1); + lift[1] = continuetime-10; + if (lift[1] < 0) + lift[1] = 0; + else if (lift[1] > TICRATE+5) + lift[1] = TICRATE+5; + } + + lift[0] = continuetime-5; + if (lift[0] < 0) + lift[0] = 0; + else if (lift[0] > TICRATE+5) + lift[0] = TICRATE+5; + +#define drawchar(dx, dy, n) {\ + sprdef = &contskins[n]->sprites[cont_spr2[n][0]];\ + sprframe = &sprdef->spriteframes[cont_spr2[n][1]];\ + patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH);\ + V_DrawFixedPatch((dx), (dy), contskins[n]->highresscale, (sprframe->flip & (1<= 0) + drawchar((BASEVIDWIDTH<<(FRACBITS-1))-offsx, ((140-lift[0])< (11*TICRATE)) + V_DrawFadeScreen(31, timetonext-(11*TICRATE)); + if (continuetime > ((3*TICRATE) - 10)) + V_DrawFadeScreen(0, (continuetime - ((3*TICRATE) - 10))); } void F_ContinueTicker(void) { if (!imcontinuing) { - // note the setup to prevent 2x reloading - if (timetonext >= 0) - timetonext--; - if (timetonext == 0) - Command_ExitGame_f(); + if (timetonext > 0) + { + if (!(--timetonext)) + { + Command_ExitGame_f(); + return; + } + } } else { - // note the setup to prevent 2x reloading - if (continuetime >= 0) - continuetime--; - if (continuetime == 0) + if (++continuetime == 3*TICRATE) + { G_Continue(); + return; + } + + if (continuetime > 5 && ((continuetime & 1) || continuetime > TICRATE) && (++cont_spr2[0][2]) >= 8) + cont_spr2[0][2] = 0; + + if (continuetime > 10 && (!(continuetime & 1) || continuetime > TICRATE+5) && (++cont_spr2[1][2]) >= 8) + cont_spr2[1][2] = 0; + + if (continuetime == (3*TICRATE)-10) + S_StartSound(NULL, sfx_cdfm56); // or 31 + else if (continuetime == 5) + { + cont_spr2[0][0] = P_GetSkinSprite2(contskins[0], SPR2_CNT2, NULL); + cont_spr2[0][4] = contskins[0]->sprites[cont_spr2[0][0]].numframes; + cont_spr2[0][1] = cont_spr2[0][3] = 0; + cont_spr2[0][5] = 2; + } + else if (continuetime == TICRATE) + { + cont_spr2[0][0] = P_GetSkinSprite2(contskins[0], SPR2_CNT3, NULL); + cont_spr2[0][4] = contskins[0]->sprites[cont_spr2[0][0]].numframes; + cont_spr2[0][1] = cont_spr2[0][3] = 0; + } + else if (contskins[1]) + { + if (continuetime == 10) + { + cont_spr2[1][0] = P_GetSkinSprite2(contskins[1], SPR2_CNT2, NULL); + cont_spr2[1][4] = contskins[1]->sprites[cont_spr2[1][0]].numframes; + cont_spr2[1][1] = cont_spr2[1][3] = 0; + cont_spr2[1][5] = 2; + } + else if (continuetime == TICRATE+5) + { + cont_spr2[1][0] = P_GetSkinSprite2(contskins[1], SPR2_CNT3, NULL); + cont_spr2[1][4] = contskins[1]->sprites[cont_spr2[1][0]].numframes; + cont_spr2[1][1] = cont_spr2[1][3] = 0; + } + } + } + + if ((++cont_spr2[0][3]) >= cont_spr2[0][5]) + { + cont_spr2[0][3] = 0; + if (++cont_spr2[0][1] >= cont_spr2[0][4]) + cont_spr2[0][1] = 0; + } + + if (contskins[1] && (++cont_spr2[1][3]) >= cont_spr2[1][5]) + { + cont_spr2[1][3] = 0; + if (++cont_spr2[1][1] >= cont_spr2[1][4]) + cont_spr2[1][1] = 0; } } @@ -1709,8 +3906,9 @@ boolean F_ContinueResponder(event_t *event) keypressed = true; imcontinuing = true; - continuetime = TICRATE; - S_StartSound(0, sfx_itemup); + S_StartSound(NULL, sfx_kc6b); + I_FadeSong(0, MUSICRATE, &S_StopMusic); + return true; } @@ -1718,7 +3916,7 @@ boolean F_ContinueResponder(event_t *event) // CUSTOM CUTSCENES // ================== static INT32 scenenum, cutnum; -static INT32 picxpos, picypos, picnum, pictime; +static INT32 picxpos, picypos, picnum, pictime, picmode, numpics, pictoloop; static INT32 textxpos, textypos; static boolean dofadenow = false, cutsceneover = false; static boolean runningprecutscene = false, precutresetplayer = false; @@ -1741,9 +3939,10 @@ static void F_AdvanceToNextScene(void) picypos = cutscenes[cutnum]->scene[scenenum].ycoord[picnum]; if (cutscenes[cutnum]->scene[scenenum].musswitch[0]) - S_ChangeMusic(cutscenes[cutnum]->scene[scenenum].musswitch, + S_ChangeMusicEx(cutscenes[cutnum]->scene[scenenum].musswitch, cutscenes[cutnum]->scene[scenenum].musswitchflags, - cutscenes[cutnum]->scene[scenenum].musicloop); + cutscenes[cutnum]->scene[scenenum].musicloop, + cutscenes[cutnum]->scene[scenenum].musswitchposition, 0, 0); // Fade to the next dofadenow = true; @@ -1786,6 +3985,9 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset G_SetGamestate(GS_CUTSCENE); + if (wipegamestate == GS_CUTSCENE) + wipegamestate = -1; + gameaction = ga_nothing; paused = false; CON_ToggleOff(); @@ -1812,11 +4014,13 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset stoptimer = 0; if (cutscenes[cutnum]->scene[0].musswitch[0]) - S_ChangeMusic(cutscenes[cutnum]->scene[0].musswitch, + S_ChangeMusicEx(cutscenes[cutnum]->scene[0].musswitch, cutscenes[cutnum]->scene[0].musswitchflags, - cutscenes[cutnum]->scene[0].musicloop); + cutscenes[cutnum]->scene[0].musicloop, + cutscenes[cutnum]->scene[scenenum].musswitchposition, 0, 0); else S_StopMusic(); + S_StopSounds(); } // @@ -1845,10 +4049,10 @@ void F_CutsceneDrawer(void) { if (cutscenes[cutnum]->scene[scenenum].pichires[picnum]) V_DrawSmallScaledPatch(picxpos, picypos, 0, - W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_CACHE)); + W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH)); else V_DrawScaledPatch(picxpos,picypos, 0, - W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_CACHE)); + W_CachePatchName(cutscenes[cutnum]->scene[scenenum].picname[picnum], PU_PATCH)); } if (dofadenow && rendermode != render_none) @@ -1857,7 +4061,7 @@ void F_CutsceneDrawer(void) F_RunWipe(cutscenes[cutnum]->scene[scenenum].fadeoutid, true); } - V_DrawString(textxpos, textypos, 0, cutscene_disptext); + V_DrawString(textxpos, textypos, V_ALLOWLOWERCASE, cutscene_disptext); } void F_CutsceneTicker(void) @@ -1923,3 +4127,628 @@ boolean F_CutsceneResponder(event_t *event) return false; } + +// ================== +// TEXT PROMPTS +// ================== + +static void F_GetPageTextGeometry(UINT8 *pagelines, boolean *rightside, INT32 *boxh, INT32 *texth, INT32 *texty, INT32 *namey, INT32 *chevrony, INT32 *textx, INT32 *textr) +{ + // reuse: + // cutnum -> promptnum + // scenenum -> pagenum + lumpnum_t iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); + + *pagelines = textprompts[cutnum]->page[scenenum].lines ? textprompts[cutnum]->page[scenenum].lines : 4; + *rightside = (iconlump != LUMPERROR && textprompts[cutnum]->page[scenenum].rightside); + + // Vertical calculations + *boxh = *pagelines*2; + *texth = textprompts[cutnum]->page[scenenum].name[0] ? (*pagelines-1)*2 : *pagelines*2; // name takes up first line if it exists + *texty = BASEVIDHEIGHT - ((*texth * 4) + (*texth/2)*4); + *namey = BASEVIDHEIGHT - ((*boxh * 4) + (*boxh/2)*4); + *chevrony = BASEVIDHEIGHT - (((1*2) * 4) + ((1*2)/2)*4); // force on last line + + // Horizontal calculations + // Shift text to the right if we have a character icon on the left side + // Add 4 margin against icon + *textx = (iconlump != LUMPERROR && !*rightside) ? ((*boxh * 4) + (*boxh/2)*4) + 4 : 4; + *textr = *rightside ? BASEVIDWIDTH - (((*boxh * 4) + (*boxh/2)*4) + 4) : BASEVIDWIDTH-4; +} + +static fixed_t F_GetPromptHideHudBound(void) +{ + UINT8 pagelines; + boolean rightside; + INT32 boxh, texth, texty, namey, chevrony; + INT32 textx, textr; + + if (cutnum == INT32_MAX || scenenum == INT32_MAX || !textprompts[cutnum] || scenenum >= textprompts[cutnum]->numpages || + !textprompts[cutnum]->page[scenenum].hidehud || + (splitscreen && textprompts[cutnum]->page[scenenum].hidehud != 2)) // don't hide on splitscreen, unless hide all is forced + return 0; + else if (textprompts[cutnum]->page[scenenum].hidehud == 2) // hide all + return BASEVIDHEIGHT; + + F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); + + // calc boxheight (see V_DrawPromptBack) + boxh *= vid.dupy; + boxh = (boxh * 4) + (boxh/2)*5; // 4 lines of space plus gaps between and some leeway + + // return a coordinate to check + // if negative: don't show hud elements below this coordinate (visually) + // if positive: don't show hud elements above this coordinate (visually) + return 0 - boxh; // \todo: if prompt at top of screen (someday), make this return positive +} + +boolean F_GetPromptHideHudAll(void) +{ + if (cutnum == INT32_MAX || scenenum == INT32_MAX || !textprompts[cutnum] || scenenum >= textprompts[cutnum]->numpages || + !textprompts[cutnum]->page[scenenum].hidehud || + (splitscreen && textprompts[cutnum]->page[scenenum].hidehud != 2)) // don't hide on splitscreen, unless hide all is forced + return false; + else if (textprompts[cutnum]->page[scenenum].hidehud == 2) // hide all + return true; + else + return false; +} + +boolean F_GetPromptHideHud(fixed_t y) +{ + INT32 ybound; + boolean fromtop; + fixed_t ytest; + + if (!promptactive) + return false; + + ybound = F_GetPromptHideHudBound(); + fromtop = (ybound >= 0); + ytest = (fromtop ? ybound : BASEVIDHEIGHT + ybound); + + return (fromtop ? y < ytest : y >= ytest); // true means hide +} + +static void F_PreparePageText(char *pagetext) +{ + UINT8 pagelines; + boolean rightside; + INT32 boxh, texth, texty, namey, chevrony; + INT32 textx, textr; + + F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); + + if (promptpagetext) + Z_Free(promptpagetext); + promptpagetext = (pagetext && pagetext[0]) ? V_WordWrap(textx, textr, 0, pagetext) : Z_StrDup(""); + + F_NewCutscene(promptpagetext); + cutscene_textspeed = textprompts[cutnum]->page[scenenum].textspeed ? textprompts[cutnum]->page[scenenum].textspeed : TICRATE/5; + cutscene_textcount = 0; // no delay in beginning + cutscene_boostspeed = 0; // don't print 8 characters to start + + // \todo update control hot strings on re-config + // and somehow don't reset cutscene text counters +} + +static void F_AdvanceToNextPage(void) +{ + INT32 nextprompt = textprompts[cutnum]->page[scenenum].nextprompt ? textprompts[cutnum]->page[scenenum].nextprompt - 1 : INT32_MAX, + nextpage = textprompts[cutnum]->page[scenenum].nextpage ? textprompts[cutnum]->page[scenenum].nextpage - 1 : INT32_MAX, + oldcutnum = cutnum; + + if (textprompts[cutnum]->page[scenenum].nexttag[0]) + F_GetPromptPageByNamedTag(textprompts[cutnum]->page[scenenum].nexttag, &nextprompt, &nextpage); + + // determine next prompt + if (nextprompt != INT32_MAX) + { + if (nextprompt <= MAX_PROMPTS && textprompts[nextprompt]) + cutnum = nextprompt; + else + cutnum = INT32_MAX; + } + + // determine next page + if (nextpage != INT32_MAX) + { + if (cutnum != INT32_MAX) + { + scenenum = nextpage; + if (scenenum >= MAX_PAGES || scenenum > textprompts[cutnum]->numpages-1) + scenenum = INT32_MAX; + } + } + else + { + if (cutnum != oldcutnum) + scenenum = 0; + else if (scenenum + 1 < MAX_PAGES && scenenum < textprompts[cutnum]->numpages-1) + scenenum++; + else + scenenum = INT32_MAX; + } + + // close the prompt if either num is invalid + if (cutnum == INT32_MAX || scenenum == INT32_MAX) + F_EndTextPrompt(false, false); + else + { + // on page mode, number of tics before allowing boost + // on timer mode, number of tics until page advances + timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10; + F_PreparePageText(textprompts[cutnum]->page[scenenum].text); + + // gfx + picnum = textprompts[cutnum]->page[scenenum].pictostart; + numpics = textprompts[cutnum]->page[scenenum].numpics; + picmode = textprompts[cutnum]->page[scenenum].picmode; + pictoloop = textprompts[cutnum]->page[scenenum].pictoloop > 0 ? textprompts[cutnum]->page[scenenum].pictoloop - 1 : 0; + picxpos = textprompts[cutnum]->page[scenenum].xcoord[picnum]; + picypos = textprompts[cutnum]->page[scenenum].ycoord[picnum]; + animtimer = pictime = textprompts[cutnum]->page[scenenum].picduration[picnum]; + + // music change + if (textprompts[cutnum]->page[scenenum].musswitch[0]) + S_ChangeMusic(textprompts[cutnum]->page[scenenum].musswitch, + textprompts[cutnum]->page[scenenum].musswitchflags, + textprompts[cutnum]->page[scenenum].musicloop); + } +} + +void F_EndTextPrompt(boolean forceexec, boolean noexec) +{ + boolean promptwasactive = promptactive; + promptactive = false; + callpromptnum = callpagenum = callplayer = INT32_MAX; + + if (promptwasactive) + { + if (promptmo && promptmo->player && promptblockcontrols) + promptmo->reactiontime = TICRATE/4; // prevent jumping right away // \todo account freeze realtime for this) + // \todo reset frozen realtime? + } + + // \todo net safety, maybe loop all player thinkers? + if ((promptwasactive || forceexec) && !noexec && promptpostexectag) + { + if (tmthing) // edge case where starting an invalid prompt immediately on level load will make P_MapStart fail + P_LinedefExecute(promptpostexectag, promptmo, NULL); + else + { + P_MapStart(); + P_LinedefExecute(promptpostexectag, promptmo, NULL); + P_MapEnd(); + } + } +} + +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime) +{ + INT32 i; + + // if splitscreen and we already have a prompt active, ignore. + // \todo Proper per-player splitscreen support (individual prompts) + if (promptactive && splitscreen && promptnum == callpromptnum && pagenum == callpagenum) + return; + + // \todo proper netgame support + if (netgame) + { + F_EndTextPrompt(true, false); // run the post-effects immediately + return; + } + + // We share vars, so no starting text prompts over cutscenes or title screens! + keypressed = false; + finalecount = 0; + timetonext = 0; + animtimer = 0; + stoptimer = 0; + skullAnimCounter = 0; + + // Set up state + promptmo = mo; + promptpostexectag = postexectag; + promptblockcontrols = blockcontrols; + (void)freezerealtime; // \todo freeze player->realtime, maybe this needs to cycle through player thinkers + + // Initialize current prompt and scene + callpromptnum = promptnum; + callpagenum = pagenum; + cutnum = (promptnum < MAX_PROMPTS && textprompts[promptnum]) ? promptnum : INT32_MAX; + scenenum = (cutnum != INT32_MAX && pagenum < MAX_PAGES && pagenum <= textprompts[cutnum]->numpages-1) ? pagenum : INT32_MAX; + promptactive = (cutnum != INT32_MAX && scenenum != INT32_MAX); + + if (promptactive) + { + // on page mode, number of tics before allowing boost + // on timer mode, number of tics until page advances + timetonext = textprompts[cutnum]->page[scenenum].timetonext ? textprompts[cutnum]->page[scenenum].timetonext : TICRATE/10; + F_PreparePageText(textprompts[cutnum]->page[scenenum].text); + + // gfx + picnum = textprompts[cutnum]->page[scenenum].pictostart; + numpics = textprompts[cutnum]->page[scenenum].numpics; + picmode = textprompts[cutnum]->page[scenenum].picmode; + pictoloop = textprompts[cutnum]->page[scenenum].pictoloop > 0 ? textprompts[cutnum]->page[scenenum].pictoloop - 1 : 0; + picxpos = textprompts[cutnum]->page[scenenum].xcoord[picnum]; + picypos = textprompts[cutnum]->page[scenenum].ycoord[picnum]; + animtimer = pictime = textprompts[cutnum]->page[scenenum].picduration[picnum]; + + // music change + if (textprompts[cutnum]->page[scenenum].musswitch[0]) + S_ChangeMusic(textprompts[cutnum]->page[scenenum].musswitch, + textprompts[cutnum]->page[scenenum].musswitchflags, + textprompts[cutnum]->page[scenenum].musicloop); + + // get the calling player + if (promptblockcontrols && mo && mo->player) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (players[i].mo == mo) + { + callplayer = i; + break; + } + } + } + } + else + F_EndTextPrompt(true, false); // run the post-effects immediately +} + +static boolean F_GetTextPromptTutorialTag(char *tag, INT32 length) +{ + INT32 gcs = gcs_custom; + boolean suffixed = true; + + if (!tag || !tag[0] || !tutorialmode) + return false; + + if (!strncmp(tag, "TAM", 3)) // Movement + gcs = G_GetControlScheme(gamecontrol, gcl_movement, num_gcl_movement); + else if (!strncmp(tag, "TAC", 3)) // Camera + { + // Check for gcl_movement so we can differentiate between FPS and Platform schemes. + gcs = G_GetControlScheme(gamecontrol, gcl_movement, num_gcl_movement); + if (gcs == gcs_custom) // try again, maybe we'll get a match + gcs = G_GetControlScheme(gamecontrol, gcl_camera, num_gcl_camera); + if (gcs == gcs_fps && !cv_usemouse.value) + gcs = gcs_platform; // Platform (arrow) scheme is stand-in for no mouse + } + else if (!strncmp(tag, "TAD", 3)) // Movement and Camera + gcs = G_GetControlScheme(gamecontrol, gcl_movement_camera, num_gcl_movement_camera); + else if (!strncmp(tag, "TAJ", 3)) // Jump + gcs = G_GetControlScheme(gamecontrol, gcl_jump, num_gcl_jump); + else if (!strncmp(tag, "TAS", 3)) // Spin + gcs = G_GetControlScheme(gamecontrol, gcl_use, num_gcl_use); + else if (!strncmp(tag, "TAA", 3)) // Char ability + gcs = G_GetControlScheme(gamecontrol, gcl_jump, num_gcl_jump); + else if (!strncmp(tag, "TAW", 3)) // Shield ability + gcs = G_GetControlScheme(gamecontrol, gcl_jump_use, num_gcl_jump_use); + else + gcs = G_GetControlScheme(gamecontrol, gcl_tutorial_used, num_gcl_tutorial_used); + + switch (gcs) + { + case gcs_fps: + // strncat(tag, "FPS", length); + suffixed = false; + break; + + case gcs_platform: + strncat(tag, "PLATFORM", length); + break; + + default: + strncat(tag, "CUSTOM", length); + break; + } + + return suffixed; +} + +void F_GetPromptPageByNamedTag(const char *tag, INT32 *promptnum, INT32 *pagenum) +{ + INT32 nosuffixpromptnum = INT32_MAX, nosuffixpagenum = INT32_MAX; + INT32 tutorialpromptnum = (tutorialmode) ? TUTORIAL_PROMPT-1 : 0; + boolean suffixed = false, found = false; + char suffixedtag[33]; + + *promptnum = *pagenum = INT32_MAX; + + if (!tag || !tag[0]) + return; + + strncpy(suffixedtag, tag, 33); + suffixedtag[32] = 0; + + if (tutorialmode) + suffixed = F_GetTextPromptTutorialTag(suffixedtag, 33); + + for (*promptnum = 0 + tutorialpromptnum; *promptnum < MAX_PROMPTS; (*promptnum)++) + { + if (!textprompts[*promptnum]) + continue; + + for (*pagenum = 0; *pagenum < textprompts[*promptnum]->numpages && *pagenum < MAX_PAGES; (*pagenum)++) + { + if (suffixed && fastcmp(suffixedtag, textprompts[*promptnum]->page[*pagenum].tag)) + { + // this goes first because fastcmp ends early if first string is shorter + found = true; + break; + } + else if (nosuffixpromptnum == INT32_MAX && nosuffixpagenum == INT32_MAX && fastcmp(tag, textprompts[*promptnum]->page[*pagenum].tag)) + { + if (suffixed) + { + nosuffixpromptnum = *promptnum; + nosuffixpagenum = *pagenum; + // continue searching for the suffixed tag + } + else + { + found = true; + break; + } + } + } + + if (found) + break; + } + + if (suffixed && !found && nosuffixpromptnum != INT32_MAX && nosuffixpagenum != INT32_MAX) + { + found = true; + *promptnum = nosuffixpromptnum; + *pagenum = nosuffixpagenum; + } + + if (!found) + CONS_Debug(DBG_GAMELOGIC, "Text prompt: Can't find a page with named tag %s or suffixed tag %s\n", tag, suffixedtag); +} + +void F_TextPromptDrawer(void) +{ + // reuse: + // cutnum -> promptnum + // scenenum -> pagenum + lumpnum_t iconlump; + UINT8 pagelines; + boolean rightside; + INT32 boxh, texth, texty, namey, chevrony; + INT32 textx, textr; + + // Data + patch_t *patch; + + if (!promptactive) + return; + + iconlump = W_CheckNumForName(textprompts[cutnum]->page[scenenum].iconname); + F_GetPageTextGeometry(&pagelines, &rightside, &boxh, &texth, &texty, &namey, &chevrony, &textx, &textr); + + // Draw gfx first + if (picnum >= 0 && picnum < numpics && textprompts[cutnum]->page[scenenum].picname[picnum][0] != '\0') + { + if (textprompts[cutnum]->page[scenenum].pichires[picnum]) + V_DrawSmallScaledPatch(picxpos, picypos, 0, + W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH)); + else + V_DrawScaledPatch(picxpos,picypos, 0, + W_CachePatchName(textprompts[cutnum]->page[scenenum].picname[picnum], PU_PATCH)); + } + + // Draw background + V_DrawPromptBack(boxh, textprompts[cutnum]->page[scenenum].backcolor); + + // Draw narrator icon + if (iconlump != LUMPERROR) + { + INT32 iconx, icony, scale, scaledsize; + patch = W_CachePatchName(textprompts[cutnum]->page[scenenum].iconname, PU_PATCH); + + // scale and center + if (patch->width > patch->height) + { + scale = FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->width); + scaledsize = FixedMul(patch->height, scale); + iconx = (rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4) << FRACBITS; + icony = ((namey-4) << FRACBITS) + FixedDiv(BASEVIDHEIGHT - namey + 4 - scaledsize, 2); // account for 4 margin + } + else if (patch->height > patch->width) + { + scale = FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->height); + scaledsize = FixedMul(patch->width, scale); + iconx = (rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4) << FRACBITS; + icony = namey << FRACBITS; + iconx += FixedDiv(FixedMul(patch->height, scale) - scaledsize, 2); + } + else + { + scale = FixedDiv(((boxh * 4) + (boxh/2)*4) - 4, patch->width); + iconx = (rightside ? BASEVIDWIDTH - (((boxh * 4) + (boxh/2)*4)) : 4) << FRACBITS; + icony = namey << FRACBITS; + } + + if (textprompts[cutnum]->page[scenenum].iconflip) + iconx += FixedMul(patch->width, scale) << FRACBITS; + + V_DrawFixedPatch(iconx, icony, scale, (V_SNAPTOBOTTOM|(textprompts[cutnum]->page[scenenum].iconflip ? V_FLIP : 0)), patch, NULL); + W_UnlockCachedPatch(patch); + } + + // Draw text + V_DrawString(textx, texty, (V_SNAPTOBOTTOM|V_ALLOWLOWERCASE), cutscene_disptext); + + // Draw name + // Don't use V_YELLOWMAP here so that the name color can be changed with control codes + if (textprompts[cutnum]->page[scenenum].name[0]) + V_DrawString(textx, namey, (V_SNAPTOBOTTOM|V_ALLOWLOWERCASE), textprompts[cutnum]->page[scenenum].name); + + // Draw chevron + if (promptblockcontrols && !timetonext) + V_DrawString(textr-8, chevrony + (skullAnimCounter/5), (V_SNAPTOBOTTOM|V_YELLOWMAP), "\x1B"); // down arrow +} + +#define nocontrolallowed(j) {\ + players[j].powers[pw_nocontrol] = 1;\ + if (players[j].mo)\ + {\ + if (players[j].mo->state == states+S_PLAY_STND && players[j].mo->tics != -1)\ + players[j].mo->tics++;\ + else if (players[j].mo->state == states+S_PLAY_WAIT)\ + P_SetPlayerMobjState(players[j].mo, S_PLAY_STND);\ + }\ + } + +void F_TextPromptTicker(void) +{ + INT32 i; + + if (!promptactive || paused || P_AutoPause()) + return; + + // advance animation + finalecount++; + cutscene_boostspeed = 0; + + // for the chevron + if (--skullAnimCounter <= 0) + skullAnimCounter = 8; + + // button handling + if (textprompts[cutnum]->page[scenenum].timetonext) + { + if (promptblockcontrols) // same procedure as below, just without the button handling + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (netgame && i != serverplayer && !IsPlayerAdmin(i)) + continue; + else if (splitscreen) { + // Both players' controls are locked, + // But only consoleplayer can advance the prompt. + // \todo Proper per-player splitscreen support (individual prompts) + if (i == consoleplayer || i == secondarydisplayplayer) + nocontrolallowed(i) + } + else if (i == consoleplayer) + nocontrolallowed(i) + + if (!splitscreen) + break; + } + } + + if (timetonext >= 1) + timetonext--; + + if (!timetonext) + F_AdvanceToNextPage(); + + F_WriteText(); + } + else + { + if (promptblockcontrols) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (netgame && i != serverplayer && !IsPlayerAdmin(i)) + continue; + else if (splitscreen) { + // Both players' controls are locked, + // But only the triggering player can advance the prompt. + if (i == consoleplayer || i == secondarydisplayplayer) + { + players[i].powers[pw_nocontrol] = 1; + + if (callplayer == consoleplayer || callplayer == secondarydisplayplayer) + { + if (i != callplayer) + continue; + } + else if (i != consoleplayer) + continue; + } + else + continue; + } + else if (i == consoleplayer) + nocontrolallowed(i) + else + continue; + + if ((players[i].cmd.buttons & BT_USE) || (players[i].cmd.buttons & BT_JUMP)) + { + if (timetonext > 1) + timetonext--; + else if (cutscene_baseptr) // don't set boost if we just reset the string + cutscene_boostspeed = 1; // only after a slight delay + + if (keypressed) + { + if (!splitscreen) + break; + else + continue; + } + + if (!timetonext) // is 0 when finished generating text + { + F_AdvanceToNextPage(); + if (promptactive) + S_StartSound(NULL, sfx_menu1); + } + keypressed = true; // prevent repeat events + } + else if (!(players[i].cmd.buttons & BT_USE) && !(players[i].cmd.buttons & BT_JUMP)) + keypressed = false; + + if (!splitscreen) + break; + } + } + + // generate letter-by-letter text + if (scenenum >= MAX_PAGES || + !textprompts[cutnum]->page[scenenum].text || + !textprompts[cutnum]->page[scenenum].text[0] || + !F_WriteText()) + timetonext = !promptblockcontrols; // never show the chevron if we can't toggle pages + } + + // gfx + if (picnum >= 0 && picnum < numpics) + { + if (animtimer <= 0) + { + boolean persistanimtimer = false; + + if (picnum < numpics-1 && textprompts[cutnum]->page[scenenum].picname[picnum+1][0] != '\0') + picnum++; + else if (picmode == PROMPT_PIC_LOOP) + picnum = pictoloop; + else if (picmode == PROMPT_PIC_DESTROY) + picnum = -1; + else // if (picmode == PROMPT_PIC_PERSIST) + persistanimtimer = true; + + if (!persistanimtimer && picnum >= 0) + { + picxpos = textprompts[cutnum]->page[scenenum].xcoord[picnum]; + picypos = textprompts[cutnum]->page[scenenum].ycoord[picnum]; + pictime = textprompts[cutnum]->page[scenenum].picduration[picnum]; + animtimer = pictime; + } + } + else + animtimer--; + } +} diff --git a/src/f_finale.h b/src/f_finale.h index efab71698..63319d7d6 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -17,6 +17,7 @@ #include "doomtype.h" #include "d_event.h" +#include "p_mobj.h" // // FINALE @@ -33,16 +34,21 @@ void F_IntroTicker(void); void F_TitleScreenTicker(boolean run); void F_CutsceneTicker(void); void F_TitleDemoTicker(void); +void F_TextPromptTicker(void); // Called by main loop. void F_GameEndDrawer(void); void F_IntroDrawer(void); void F_TitleScreenDrawer(void); +void F_SkyScroll(INT32 scrollxspeed, INT32 scrollyspeed, const char *patchname); void F_GameEvaluationDrawer(void); void F_StartGameEvaluation(void); void F_GameEvaluationTicker(void); +void F_EndingTicker(void); +void F_EndingDrawer(void); + void F_CreditTicker(void); void F_CreditDrawer(void); @@ -50,9 +56,17 @@ void F_StartCustomCutscene(INT32 cutscenenum, boolean precutscene, boolean reset void F_CutsceneDrawer(void); void F_EndCutScene(void); +void F_StartTextPrompt(INT32 promptnum, INT32 pagenum, mobj_t *mo, UINT16 postexectag, boolean blockcontrols, boolean freezerealtime); +void F_GetPromptPageByNamedTag(const char *tag, INT32 *promptnum, INT32 *pagenum); +void F_TextPromptDrawer(void); +void F_EndTextPrompt(boolean forceexec, boolean noexec); +boolean F_GetPromptHideHudAll(void); +boolean F_GetPromptHideHud(fixed_t y); + void F_StartGameEnd(void); void F_StartIntro(void); void F_StartTitleScreen(void); +void F_StartEnding(void); void F_StartCredits(void); boolean F_ContinueResponder(event_t *event); @@ -60,17 +74,116 @@ void F_StartContinue(void); void F_ContinueTicker(void); void F_ContinueDrawer(void); -extern INT32 titlescrollspeed; +extern INT32 finalecount; +extern INT32 titlescrollxspeed; +extern INT32 titlescrollyspeed; + +typedef enum +{ + TTMODE_NONE = 0, + TTMODE_OLD, + TTMODE_ALACROIX, + TTMODE_USER +} ttmode_enum; + +#define TTMAX_ALACROIX 30 // max frames for SONIC typeface, plus one for NULL terminating entry +#define TTMAX_USER 100 + +extern ttmode_enum ttmode; +extern UINT8 ttscale; +// ttmode user vars +extern char ttname[9]; +extern INT16 ttx; +extern INT16 tty; +extern INT16 ttloop; +extern UINT16 tttics; +extern boolean ttavailable[6]; + + +typedef enum +{ + TITLEMAP_OFF = 0, + TITLEMAP_LOADING, + TITLEMAP_RUNNING +} titlemap_enum; + +// Current menu parameters + +extern mobj_t *titlemapcameraref; +extern char curbgname[9]; +extern SINT8 curfadevalue; +extern INT32 curbgcolor; +extern INT32 curbgxspeed; +extern INT32 curbgyspeed; +extern boolean curbghide; +extern boolean hidetitlemap; + +extern boolean curhidepics; +extern ttmode_enum curttmode; +extern UINT8 curttscale; +// ttmode user vars +extern char curttname[9]; +extern INT16 curttx; +extern INT16 curtty; +extern INT16 curttloop; +extern UINT16 curtttics; + +#define TITLEBACKGROUNDACTIVE (curfadevalue >= 0 || curbgname[0]) + +void F_InitMenuPresValues(void); +void F_MenuPresTicker(boolean run); // // WIPE // +// HACK for menu fading while titlemapinaction; skips the level check +#define FORCEWIPE -3 +#define FORCEWIPEOFF -2 + extern boolean WipeInAction; +extern boolean WipeStageTitle; + +typedef enum +{ + WIPESTYLE_NORMAL, + WIPESTYLE_COLORMAP +} wipestyle_t; +extern wipestyle_t wipestyle; + +typedef enum +{ + WSF_FADEOUT = 1, + WSF_FADEIN = 1<<1, + WSF_TOWHITE = 1<<2, + WSF_CROSSFADE = 1<<3, +} wipestyleflags_t; +extern wipestyleflags_t wipestyleflags; + +// Even my function names are borderline +boolean F_ShouldColormapFade(void); +boolean F_TryColormapFade(UINT8 wipecolor); +void F_DecideWipeStyle(void); + +#define FADECOLORMAPDIV 8 +#define FADECOLORMAPROWS (256/FADECOLORMAPDIV) + +#define FADEREDFACTOR 15 +#define FADEGREENFACTOR 15 +#define FADEBLUEFACTOR 10 + extern INT32 lastwipetic; +// Don't know where else to place this constant +// But this file seems appropriate +#define PRELEVELTIME 24 // frames in tics + void F_WipeStartScreen(void); void F_WipeEndScreen(void); void F_RunWipe(UINT8 wipetype, boolean drawMenu); +void F_WipeStageTitle(void); +#define F_WipeColorFill(c) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, c) +tic_t F_GetWipeLength(UINT8 wipetype); +boolean F_WipeExists(UINT8 wipetype); enum { @@ -85,6 +198,7 @@ enum wipe_evaluation_toblack, wipe_gameend_toblack, wipe_intro_toblack, + wipe_ending_toblack, wipe_cutscene_toblack, // custom intermissions @@ -101,15 +215,16 @@ enum wipe_evaluation_final, wipe_gameend_final, wipe_intro_final, + wipe_ending_final, wipe_cutscene_final, // custom intermissions wipe_specinter_final, wipe_multinter_final, - NUMWIPEDEFS + NUMWIPEDEFS, + WIPEFINALSHIFT = (wipe_level_final-wipe_level_toblack) }; -#define WIPEFINALSHIFT 13 extern UINT8 wipedefs[NUMWIPEDEFS]; #endif diff --git a/src/f_wipe.c b/src/f_wipe.c index 95dd5bbde..08d7ed991 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -16,8 +16,11 @@ #include "i_video.h" #include "v_video.h" +#include "r_state.h" // fadecolormap #include "r_draw.h" // transtable #include "p_pspr.h" // tr_transxxx +#include "p_local.h" +#include "st_stuff.h" #include "w_wad.h" #include "z_zone.h" @@ -25,8 +28,13 @@ #include "m_menu.h" #include "console.h" #include "d_main.h" +#include "g_game.h" #include "m_misc.h" // movie mode +#include "doomstat.h" + +#include "lua_hud.h" // level title + #ifdef HWRENDER #include "hardware/hw_main.h" #endif @@ -47,13 +55,14 @@ UINT8 wipedefs[NUMWIPEDEFS] = { 0, // wipe_level_toblack UINT8_MAX, // wipe_intermission_toblack - UINT8_MAX, // wipe_continuing_toblack + 0, // wipe_continuing_toblack 0, // wipe_titlescreen_toblack 0, // wipe_timeattack_toblack 99, // wipe_credits_toblack 0, // wipe_evaluation_toblack 0, // wipe_gameend_toblack 99, // wipe_intro_toblack (hardcoded) + 0, // wipe_ending_toblack 99, // wipe_cutscene_toblack (hardcoded) 0, // wipe_specinter_toblack @@ -69,6 +78,7 @@ UINT8 wipedefs[NUMWIPEDEFS] = { 0, // wipe_evaluation_final 0, // wipe_gameend_final 99, // wipe_intro_final (hardcoded) + 0, // wipe_ending_final 99, // wipe_cutscene_final (hardcoded) 0, // wipe_specinter_final @@ -80,13 +90,17 @@ UINT8 wipedefs[NUMWIPEDEFS] = { //-------------------------------------------------------------------------- boolean WipeInAction = false; +boolean WipeStageTitle = false; INT32 lastwipetic = 0; +wipestyle_t wipestyle = WIPESTYLE_NORMAL; +wipestyleflags_t wipestyleflags = WSF_CROSSFADE; + #ifndef NOWIPE static UINT8 *wipe_scr_start; //screen 3 static UINT8 *wipe_scr_end; //screen 4 static UINT8 *wipe_scr; //screen 0 (main drawing) -static fixed_t paldiv; +static fixed_t paldiv = 0; /** Create fademask_t from lump * @@ -145,8 +159,11 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) { while (lsize--) { // Determine pixel to use from fademask - pcolor = &pLocalPalette[*lump++]; - *mask++ = FixedDiv((pcolor->s.red+1)<>FRACBITS; + pcolor = &pMasterPalette[*lump++]; + if (wipestyle == WIPESTYLE_COLORMAP) + *mask++ = pcolor->s.red / FADECOLORMAPDIV; + else + *mask++ = FixedDiv((pcolor->s.red+1)<>FRACBITS; } fm.xscale = FixedDiv(vid.width<= 10) { // shortcut - memcpy target to work while (draw_linestogo--) @@ -287,6 +318,111 @@ static void F_DoWipe(fademask_t *fademask) free(scrypos); } } + +static void F_DoColormapWipe(fademask_t *fademask, UINT8 *colormap) +{ + // Lactozilla: F_DoWipe for WIPESTYLE_COLORMAP + { + // wipe screen, start, end + UINT8 *w = wipe_scr; + const UINT8 *s = wipe_scr_start; + const UINT8 *e = wipe_scr_end; + + // first pixel for each screen + UINT8 *w_base = w; + const UINT8 *s_base = s; + const UINT8 *e_base = e; + + // mask data, end + UINT8 *transtbl; + const UINT8 *mask = fademask->mask; + const UINT8 *maskend = mask + fademask->size; + + // rectangle draw hints + UINT32 draw_linestart, draw_rowstart; + UINT32 draw_lineend, draw_rowend; + UINT32 draw_linestogo, draw_rowstogo; + + // rectangle coordinates, etc. + UINT16* scrxpos = (UINT16*)malloc((fademask->width + 1) * sizeof(UINT16)); + UINT16* scrypos = (UINT16*)malloc((fademask->height + 1) * sizeof(UINT16)); + UINT16 maskx, masky; + UINT32 relativepos; + + // --- + // Screw it, we do the fixed point math ourselves up front. + scrxpos[0] = 0; + for (relativepos = 0, maskx = 1; maskx < fademask->width; ++maskx) + scrxpos[maskx] = (relativepos += fademask->xscale)>>FRACBITS; + scrxpos[fademask->width] = vid.width; + + scrypos[0] = 0; + for (relativepos = 0, masky = 1; masky < fademask->height; ++masky) + scrypos[masky] = (relativepos += fademask->yscale)>>FRACBITS; + scrypos[fademask->height] = vid.height; + // --- + + maskx = masky = 0; + do + { + draw_rowstart = scrxpos[maskx]; + draw_rowend = scrxpos[maskx + 1]; + draw_linestart = scrypos[masky]; + draw_lineend = scrypos[masky + 1]; + + relativepos = (draw_linestart * vid.width) + draw_rowstart; + draw_linestogo = draw_lineend - draw_linestart; + + if (*mask == 0) + { + // shortcut - memcpy source to work + while (draw_linestogo--) + { + M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart); + relativepos += vid.width; + } + } + else if (*mask >= FADECOLORMAPROWS) + { + // shortcut - memcpy target to work + while (draw_linestogo--) + { + M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart); + relativepos += vid.width; + } + } + else + { + int nmask = *mask; + if (wipestyleflags & WSF_FADEIN) + nmask = (FADECOLORMAPROWS-1) - nmask; + + transtbl = colormap + (nmask * 256); + + // DRAWING LOOP + while (draw_linestogo--) + { + w = w_base + relativepos; + s = s_base + relativepos; + e = e_base + relativepos; + draw_rowstogo = draw_rowend - draw_rowstart; + + while (draw_rowstogo--) + *w++ = transtbl[*e++]; + + relativepos += vid.width; + } + // END DRAWING LOOP + } + + if (++maskx >= fademask->width) + ++masky, maskx = 0; + } while (++mask < maskend); + + free(scrxpos); + free(scrypos); + } +} #endif /** Save the "before" screen of a wipe. @@ -324,6 +460,62 @@ void F_WipeEndScreen(void) #endif } +/** Verifies every condition for a colormapped fade. + */ +boolean F_ShouldColormapFade(void) +{ + if ((wipestyleflags & (WSF_FADEIN|WSF_FADEOUT)) // only if one of those wipestyleflags are actually set + && !(wipestyleflags & WSF_CROSSFADE)) // and if not crossfading + { + // World + return (gamestate == GS_LEVEL + || gamestate == GS_TITLESCREEN + // Finales + || gamestate == GS_CONTINUING + || gamestate == GS_CREDITS + || gamestate == GS_EVALUATION + || gamestate == GS_INTRO + || gamestate == GS_ENDING + // Menus + || gamestate == GS_TIMEATTACK); + } + return false; +} + +/** Decides what wipe style to use. + */ +void F_DecideWipeStyle(void) +{ + // Set default wipe style + wipestyle = WIPESTYLE_NORMAL; + + // Check for colormap wipe style + if (F_ShouldColormapFade()) + wipestyle = WIPESTYLE_COLORMAP; +} + +/** Attempt to run a colormap fade, + provided all the conditionals were properly met. + Returns true if so. + I demand you call F_RunWipe after this function. + */ +boolean F_TryColormapFade(UINT8 wipecolor) +{ + if (F_ShouldColormapFade()) + { +#ifdef HWRENDER + if (rendermode == render_opengl) + F_WipeColorFill(wipecolor); +#endif + return true; + } + else + { + F_WipeColorFill(wipecolor); + return false; + } +} + /** After setting up the screens you want to wipe, * calling this will do a 'typical' wipe. */ @@ -337,9 +529,11 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu) UINT8 wipeframe = 0; fademask_t *fmask; - paldiv = FixedDiv(257< 99) + return 0; + + for (wipeframe = 0; wipeframe < 100; wipeframe++) + { + sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipetype, (UINT16)wipeframe); + + lumpnum = W_CheckNumForName(lumpname); + if (lumpnum == LUMPERROR) + return --wipeframe; + } + return --wipeframe; +#endif +} + +/** Does the specified wipe exist? + */ +boolean F_WipeExists(UINT8 wipetype) +{ +#ifdef NOWIPE + return false; +#else + static char lumpname[10] = "FADEmm00"; + lumpnum_t lumpnum; + + if (wipetype > 99) + return false; + + sprintf(&lumpname[4], "%.2hu00", (UINT16)wipetype); + + lumpnum = W_CheckNumForName(lumpname); + return !(lumpnum == LUMPERROR); #endif } diff --git a/src/filesrch.c b/src/filesrch.c index 0276e1c90..13d73b6f4 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -16,16 +16,12 @@ #ifdef __GNUC__ #include #endif -#if defined (_WIN32) && !defined (_XBOX) +#ifdef _WIN32 //#define WIN32_LEAN_AND_MEAN #define RPC_NO_WINDOWS_H #include #endif -#ifdef _WIN32_WCE -#include "sdl12/SRB2CE/cehelp.h" -#else #include -#endif #include #include "filesrch.h" @@ -34,7 +30,7 @@ #include "z_zone.h" #include "m_menu.h" // Addons_option_Onchange -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && defined (_MSC_VER) && !defined (_XBOX) +#if defined (_WIN32) && defined (_MSC_VER) #include #include @@ -344,107 +340,6 @@ char *refreshdirname = NULL; size_t packetsizetally = 0; size_t mainwadstally = 0; -#if defined (_XBOX) && defined (_MSC_VER) -filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, - boolean completepath, int maxsearchdepth) -{ -//NONE? - startpath = filename = NULL; - wantedmd5sum = NULL; - maxsearchdepth = 0; - completepath = false; - return FS_NOTFOUND; -} - -void closefilemenu(boolean validsize) -{ - (void)validsize; - return; -} - -void searchfilemenu(char *tempname) -{ - (void)tempname; - return; -} - -boolean preparefilemenu(boolean samedepth) -{ - (void)samedepth; - return false; -} - -#elif defined (_WIN32_WCE) -filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, - boolean completepath, int maxsearchdepth) -{ -#ifdef __GNUC__ -//NONE? - startpath = filename = NULL; - wantedmd5sum = NULL; - maxsearchdepth = 0; - completepath = false; -#else - WIN32_FIND_DATA dta; - HANDLE searchhandle = INVALID_HANDLE_VALUE; - const wchar_t wm[4] = L"*.*"; - - //if (startpath) SetCurrentDirectory(startpath); - if (FIL_ReadFileOK(filename)) - { - // checkfilemd5 returns an FS_* value, either FS_FOUND or FS_MD5SUMBAD - return checkfilemd5(filename, wantedmd5sum); - } - ZeroMemory(&dta,sizeof (dta)); - if (maxsearchdepth) - searchhandle = FindFirstFile(wm,&dta); - if (searchhandle != INVALID_HANDLE_VALUE) - { - do - { - if ((dta.cFileName[0]!='.') && (dta.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - //if (SetCurrentDirectory(dta.cFileName)) - { // can fail if we haven't the right - filestatus_t found; - found = filesearch(filename,NULL,wantedmd5sum,completepath,maxsearchdepth-1); - //SetCurrentDirectory(".."); - if (found == FS_FOUND || found == FS_MD5SUMBAD) - { - if (completepath) - strcatbf(filename,(char *)dta.cFileName,"\\"); - FindClose(searchhandle); - return found; - } - } - } - } while (FindNextFile(searchhandle,&dta)==0); - FindClose(searchhandle); - } -#endif - return FS_NOTFOUND; -} - -void closefilemenu(boolean validsize) -{ - (void)validsize; - return; -} - -void searchfilemenu(char *tempname) -{ - (void)tempname; - return; -} - -boolean preparefilemenu(boolean samedepth) -{ - (void)samedepth; - return false; -} - -#else - filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *wantedmd5sum, boolean completepath, int maxsearchdepth) { filestatus_t retval = FS_NOTFOUND; @@ -473,9 +368,9 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want return FS_NOTFOUND; } - if (searchpath[searchpathindex[depthleft]-2] != '/') + if (searchpath[searchpathindex[depthleft]-2] != PATHSEP[0]) { - searchpath[searchpathindex[depthleft]-1] = '/'; + searchpath[searchpathindex[depthleft]-1] = PATHSEP[0]; searchpath[searchpathindex[depthleft]] = 0; } else @@ -517,7 +412,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want depthleft++; } - searchpath[searchpathindex[depthleft]-1]='/'; + searchpath[searchpathindex[depthleft]-1]=PATHSEP[0]; searchpath[searchpathindex[depthleft]]=0; } else if (!strcasecmp(searchname, dent->d_name)) @@ -856,7 +751,7 @@ boolean preparefilemenu(boolean samedepth) } else if (ext == EXT_TXT) { - if (!strcmp(dent->d_name, "log.txt") || !strcmp(dent->d_name, "errorlog.txt")) + if (!strncmp(dent->d_name, "log-", 4) || !strcmp(dent->d_name, "errorlog.txt")) ext |= EXT_LOADED; } @@ -906,5 +801,3 @@ boolean preparefilemenu(boolean samedepth) return true; } - -#endif diff --git a/src/filesrch.h b/src/filesrch.h index 4186271b0..dfea8979e 100644 --- a/src/filesrch.h +++ b/src/filesrch.h @@ -60,7 +60,7 @@ typedef enum #endif EXT_PK3, EXT_SOC, - EXT_LUA, // allowed even if not HAVE_BLUA so that we can yell on load attempt + EXT_LUA, NUM_EXT, NUM_EXT_TABLE = NUM_EXT-EXT_START, EXT_LOADED = 0x80 diff --git a/src/g_game.c b/src/g_game.c index 213c3b83e..bf73f6ce2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,6 +15,7 @@ #include "console.h" #include "d_main.h" #include "d_player.h" +#include "d_clisrv.h" #include "f_finale.h" #include "p_setup.h" #include "p_saveg.h" @@ -37,7 +38,7 @@ #include "byteptr.h" #include "i_joy.h" #include "r_local.h" -#include "r_things.h" +#include "r_skins.h" #include "y_inter.h" #include "v_video.h" #include "dehacked.h" // get_number (for ghost thok) @@ -46,6 +47,8 @@ #include "m_cond.h" // condition sets #include "md5.h" // demo checksums +#include "lua_hud.h" + gameaction_t gameaction; gamestate_t gamestate = GS_NULL; UINT8 ultimatemode = false; @@ -71,15 +74,20 @@ static void G_DoWorldDone(void); char mapmusname[7]; // Music name UINT16 mapmusflags; // Track and reset bit +UINT32 mapmusposition; // Position to jump to INT16 gamemap = 1; -INT16 maptol; +UINT32 maptol; UINT8 globalweather = 0; INT32 curWeather = PRECIP_NONE; -INT32 cursaveslot = -1; // Auto-save 1p savegame slot -INT16 lastmapsaved = 0; // Last map we auto-saved at +INT32 cursaveslot = 0; // Auto-save 1p savegame slot +//INT16 lastmapsaved = 0; // Last map we auto-saved at +INT16 lastmaploaded = 0; // Last map the game loaded boolean gamecomplete = false; +UINT8 numgameovers = 0; // for startinglives balance +SINT8 startinglivesbalance[maxgameovers+1] = {3, 5, 7, 9, 12, 15, 20, 25, 30, 40, 50, 75, 99, 0x7F}; + UINT16 mainwads = 0; boolean modifiedgame; // Set if homebrew PWAD stuff has been added. boolean savemoddata = false; @@ -88,16 +96,17 @@ UINT8 modeattacking = ATTACKING_NONE; boolean disableSpeedAdjust = false; boolean imcontinuing = false; boolean runemeraldmanager = false; +UINT16 emeraldspawndelay = 60*TICRATE; // menu demo things -UINT8 numDemos = 3; +UINT8 numDemos = 0; UINT32 demoDelayTime = 15*TICRATE; UINT32 demoIdleTime = 3*TICRATE; boolean timingdemo; // if true, exit with report on completion boolean nodrawers; // for comparative timing purposes boolean noblit; // for comparative timing purposes -static tic_t demostarttime; // for comparative timing purposes +tic_t demostarttime; // for comparative timing purposes boolean netgame; // only true if packets are broadcast boolean multiplayer; @@ -111,29 +120,41 @@ INT32 secondarydisplayplayer; // for splitscreen tic_t gametic; tic_t levelstarttic; // gametic at level start -UINT32 totalrings; // for intermission +UINT32 ssspheres; // old special stage INT16 lastmap; // last level you were at (returning from special stages) tic_t timeinmap; // Ticker for time spent in level (used for levelcard display) INT16 spstage_start; -INT16 sstage_start; -INT16 sstage_end; +INT16 sstage_start, sstage_end, smpstage_start, smpstage_end; + +INT16 titlemap = 0; +boolean hidetitlepics = false; +INT16 bootmap; //bootmap for loading a map on startup + +INT16 tutorialmap = 0; // map to load for tutorial +boolean tutorialmode = false; // are we in a tutorial right now? +INT32 tutorialgcs = gcs_custom; // which control scheme is loaded? +INT32 tutorialusemouse = 0; // store cv_usemouse user value +INT32 tutorialfreelook = 0; // store cv_alwaysfreelook user value +INT32 tutorialmousemove = 0; // store cv_mousemove user value +INT32 tutorialanalog = 0; // store cv_analog[0] user value boolean looptitle = false; -boolean useNightsSS = false; UINT8 skincolor_redteam = SKINCOLOR_RED; UINT8 skincolor_blueteam = SKINCOLOR_BLUE; -UINT8 skincolor_redring = SKINCOLOR_RED; -UINT8 skincolor_bluering = SKINCOLOR_STEELBLUE; +UINT8 skincolor_redring = SKINCOLOR_SALMON; +UINT8 skincolor_bluering = SKINCOLOR_CORNFLOWER; tic_t countdowntimer = 0; boolean countdowntimeup = false; +boolean exitfadestarted = false; cutscene_t *cutscenes[128]; +textprompt_t *textprompts[MAX_PROMPTS]; INT16 nextmapoverride; -boolean skipstats; +UINT8 skipstats; // Pointers to each CTF flag mobj_t *redflag; @@ -149,12 +170,15 @@ mapheader_t* mapheaderinfo[NUMMAPS] = {NULL}; static boolean exitgame = false; static boolean retrying = false; +static boolean retryingmodeattack = false; UINT8 stagefailed; // Used for GEMS BONUS? Also to see if you beat the stage. UINT16 emeralds; +INT32 luabanks[NUM_LUABANKS]; UINT32 token; // Number of tokens collected in a level UINT32 tokenlist; // List of tokens collected +boolean gottoken; // Did you get a token? Used for end of act INT32 tokenbits; // Used for setting token bits // Old Special Stage @@ -193,8 +217,11 @@ UINT16 tailsflytics = 8*TICRATE; UINT16 underwatertics = 30*TICRATE; UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; +UINT16 nightslinktics = 2*TICRATE; -INT32 gameovertics = 15*TICRATE; +INT32 gameovertics = 11*TICRATE; + +UINT8 ammoremovaltics = 2*TICRATE; UINT8 use1upSound = 0; UINT8 maxXtraLife = 2; // Max extra lives from rings @@ -238,7 +265,7 @@ static UINT8 demoflags; static UINT16 demoversion; boolean singledemo; // quit after playing a demo from cmdline boolean demo_start; // don't start playing demo right away -static boolean demosynced = true; // console warning message +boolean demosynced = true; // console warning message boolean metalrecording; // recording as metal sonic mobj_t *metalplayback; @@ -246,6 +273,12 @@ static UINT8 *metalbuffer = NULL; static UINT8 *metal_p; static UINT16 metalversion; +typedef struct joystickvector2_s +{ + INT32 xaxis; + INT32 yaxis; +} joystickvector2_t; + // extra data stuff (events registered this frame while recording) static struct { UINT8 flags; // EZT flags @@ -265,7 +298,7 @@ static struct { // There is no conflict here. typedef struct demoghost { UINT8 checksum[16]; - UINT8 *buffer, *p, color; + UINT8 *buffer, *p, color, fadein; UINT16 version; mobj_t oldmo, *mo; struct demoghost *next; @@ -283,48 +316,16 @@ static void UserAnalog_OnChange(void); static void UserAnalog2_OnChange(void); static void Analog_OnChange(void); static void Analog2_OnChange(void); +static void DirectionChar_OnChange(void); +static void DirectionChar2_OnChange(void); +static void AutoBrake_OnChange(void); +static void AutoBrake2_OnChange(void); void SendWeaponPref(void); void SendWeaponPref2(void); static CV_PossibleValue_t crosshair_cons_t[] = {{0, "Off"}, {1, "Cross"}, {2, "Angle"}, {3, "Point"}, {0, NULL}}; static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, -#ifdef _WII -{1, "LStick.X"}, {2, "LStick.Y"}, {-1, "LStick.X-"}, {-2, "LStick.Y-"}, -#if JOYAXISSET > 1 -{3, "RStick.X"}, {4, "RStick.Y"}, {-3, "RStick.X-"}, {-4, "RStick.Y-"}, -#endif -#if JOYAXISSET > 2 -{5, "RTrigger"}, {6, "LTrigger"}, {-5, "RTrigger-"}, {-6, "LTrigger-"}, -#endif -#if JOYAXISSET > 3 -{7, "Pitch"}, {8, "Roll"}, {-7, "Pitch-"}, {-8, "Roll-"}, -#endif -#if JOYAXISSET > 4 -{7, "Yaw"}, {8, "Dummy"}, {-7, "Yaw-"}, {-8, "Dummy-"}, -#endif -#if JOYAXISSET > 4 -{9, "LAnalog"}, {10, "RAnalog"}, {-9, "LAnalog-"}, {-10, "RAnalog-"}, -#endif -#elif defined (WMINPUT) -{1, "LStick.X"}, {2, "LStick.Y"}, {-1, "LStick.X-"}, {-2, "LStick.Y-"}, -#if JOYAXISSET > 1 -{3, "RStick.X"}, {4, "RStick.Y"}, {-3, "RStick.X-"}, {-4, "RStick.Y-"}, -#endif -#if JOYAXISSET > 2 -{5, "NStick.X"}, {6, "NStick.Y"}, {-5, "NStick.X-"}, {-6, "NStick.Y-"}, -#endif -#if JOYAXISSET > 3 -{7, "LAnalog"}, {8, "RAnalog"}, {-7, "LAnalog-"}, {-8, "RAnalog-"}, -#endif -#else {1, "X-Axis"}, {2, "Y-Axis"}, {-1, "X-Axis-"}, {-2, "Y-Axis-"}, -#ifdef _arch_dreamcast -{3, "R-Trig"}, {4, "L-Trig"}, {-3, "R-Trig-"}, {-4, "L-Trig-"}, -{5, "Alt X-Axis"}, {6, "Alt Y-Axis"}, {-5, "Alt X-Axis-"}, {-6, "Alt Y-Axis-"}, -{7, "Triggers"}, {-7,"Triggers-"}, -#elif defined (_XBOX) -{3, "Alt X-Axis"}, {4, "Alt Y-Axis"}, {-3, "Alt X-Axis-"}, {-4, "Alt Y-Axis-"}, -#else #if JOYAXISSET > 1 {3, "Z-Axis"}, {4, "X-Rudder"}, {-3, "Z-Axis-"}, {-4, "X-Rudder-"}, #endif @@ -333,19 +334,11 @@ static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, #endif #if JOYAXISSET > 3 {7, "U-Axis"}, {8, "V-Axis"}, {-7, "U-Axis-"}, {-8, "V-Axis-"}, -#endif -#endif #endif {0, NULL}}; -#ifdef _WII -#if JOYAXISSET > 5 -"More Axis Sets" -#endif -#else #if JOYAXISSET > 4 "More Axis Sets" #endif -#endif // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. @@ -357,8 +350,8 @@ static CV_PossibleValue_t chattime_cons_t[] = {{5, "MIN"}, {999, "MAX"}, {0, NUL consvar_t cv_chattime = {"chattime", "8", CV_SAVE, chattime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // chatwidth -static CV_PossibleValue_t chatwidth_cons_t[] = {{64, "MIN"}, {150, "MAX"}, {0, NULL}}; -consvar_t cv_chatwidth = {"chatwidth", "128", CV_SAVE, chatwidth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t chatwidth_cons_t[] = {{64, "MIN"}, {300, "MAX"}, {0, NULL}}; +consvar_t cv_chatwidth = {"chatwidth", "150", CV_SAVE, chatwidth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // chatheight static CV_PossibleValue_t chatheight_cons_t[] = {{6, "MIN"}, {22, "MAX"}, {0, NULL}}; @@ -377,26 +370,87 @@ consvar_t cv_chatbacktint = {"chatbacktint", "On", CV_SAVE, CV_OnOff, NULL, 0, N static CV_PossibleValue_t consolechat_cons_t[] = {{0, "Window"}, {1, "Console"}, {2, "Window (Hidden)"}, {0, NULL}}; consvar_t cv_consolechat = {"chatmode", "Window", CV_SAVE, consolechat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +// Pause game upon window losing focus +consvar_t cv_pauseifunfocused = {"pauseifunfocused", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_crosshair = {"crosshair", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_crosshair2 = {"crosshair2", "Cross", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_invertmouse = {"invertmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_alwaysfreelook = {"alwaysmlook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_alwaysfreelook2 = {"alwaysmlook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasefreelook = {"chasemlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_analog = {"analog", "Off", CV_CALL, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_analog2 = {"analog2", "Off", CV_CALL, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#ifdef DC -consvar_t cv_useranalog = {"useranalog", "On", CV_SAVE|CV_CALL, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog2 = {"useranalog2", "On", CV_SAVE|CV_CALL, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#else -consvar_t cv_useranalog = {"useranalog", "Off", CV_SAVE|CV_CALL, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog2 = {"useranalog2", "Off", CV_SAVE|CV_CALL, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#endif + +// previously "analog", "analog2", "useranalog", and "useranalog2", invalidating 2.1-era copies of config.cfg +// changed because it'd be nice to see people try out our actually good controls with gamepads now autobrake exists +consvar_t cv_analog[2] = { + {"sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; +consvar_t cv_useranalog[2] = { + {"configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; + +// deez New User eXperiences +static CV_PossibleValue_t directionchar_cons_t[] = {{0, "Camera"}, {1, "Movement"}, {2, "Simple Locked"}, {0, NULL}}; +consvar_t cv_directionchar[2] = { + {"directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; +consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +// hi here's some new controls +static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_cam_shiftfacing[2] = { + {"cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +consvar_t cv_cam_turnfacing[2] = { + {"cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +consvar_t cv_cam_turnfacingability[2] = { + {"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +consvar_t cv_cam_turnfacingspindash[2] = { + {"cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +consvar_t cv_cam_turnfacinginput[2] = { + {"cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + +static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {2, "Sticky Hold"}, {0, NULL}}; +consvar_t cv_cam_centertoggle[2] = { + {"cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + +static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}}; +consvar_t cv_cam_lockedinput[2] = { + {"cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + +static CV_PossibleValue_t lockedassist_cons_t[] = { + {0, "Off"}, + {LOCK_BOSS, "Bosses"}, + {LOCK_BOSS|LOCK_ENEMY, "Enemies"}, + {LOCK_BOSS|LOCK_INTERESTS, "Interests"}, + {LOCK_BOSS|LOCK_ENEMY|LOCK_INTERESTS, "Full"}, + {0, NULL} +}; +consvar_t cv_cam_lockonboss[2] = { + {"cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; typedef enum { @@ -405,127 +459,44 @@ typedef enum AXISMOVE, AXISLOOK, AXISSTRAFE, - AXISDEAD, //Axises that don't want deadzones + + AXISDIGITAL, // axes below this use digital deadzone + AXISJUMP, AXISSPIN, AXISFIRE, AXISFIRENORMAL, } axis_input_e; -#if defined (_WII) || defined (WMINPUT) -consvar_t cv_turnaxis = {"joyaxis_turn", "LStick.X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_moveaxis = {"joyaxis_move", "LStick.Y", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sideaxis = {"joyaxis_side", "RStick.X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lookaxis = {"joyaxis_look", "RStick.Y", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fireaxis = {"joyaxis_fire", "LAnalog", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_firenaxis = {"joyaxis_firenormal", "RAnalog", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_turnaxis = {"joyaxis_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#ifdef PSP -consvar_t cv_moveaxis = {"joyaxis_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_moveaxis = {"joyaxis_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif -#ifdef _arch_dreamcast -consvar_t cv_sideaxis = {"joyaxis_side", "Triggers", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#elif defined (_XBOX) -consvar_t cv_sideaxis = {"joyaxis_side", "Alt X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lookaxis = {"joyaxis_look", "Alt Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#elif defined (PSP) -consvar_t cv_sideaxis = {"joyaxis_side", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_sideaxis = {"joyaxis_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif -#ifndef _XBOX -#ifdef PSP -consvar_t cv_lookaxis = {"joyaxis_look", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_lookaxis = {"joyaxis_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif -#endif consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif +consvar_t cv_deadzone = {"joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_digitaldeadzone = {"joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#if defined (_WII) || defined (WMINPUT) -consvar_t cv_turnaxis2 = {"joyaxis2_turn", "LStick.X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_moveaxis2 = {"joyaxis2_move", "LStick.Y", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sideaxis2 = {"joyaxis2_side", "RStick.X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lookaxis2 = {"joyaxis2_look", "RStick.Y", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_fireaxis2 = {"joyaxis2_fire", "LAnalog", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "RAnalog", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#ifdef _arch_dreamcast -consvar_t cv_sideaxis2 = {"joyaxis2_side", "Triggers", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#elif defined (_XBOX) -consvar_t cv_sideaxis2 = {"joyaxis2_side", "Alt X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lookaxis2 = {"joyaxis2_look", "Alt Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#elif defined (_PSP) -consvar_t cv_sideaxis2 = {"joyaxis2_side", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_sideaxis2 = {"joyaxis2_side", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif -#ifndef _XBOX consvar_t cv_lookaxis2 = {"joyaxis2_look", "Y-Rudder-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif - - -#if MAXPLAYERS > 32 -#error "please update player_name table using the new value for MAXPLAYERS" -#endif +consvar_t cv_deadzone2 = {"joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_digitaldeadzone2 = {"joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef SEENAMES player_t *seenplayer; // player we're aiming at right now #endif -char player_names[MAXPLAYERS][MAXPLAYERNAME+1] = -{ - "Player 1", - "Player 2", - "Player 3", - "Player 4", - "Player 5", - "Player 6", - "Player 7", - "Player 8", - "Player 9", - "Player 10", - "Player 11", - "Player 12", - "Player 13", - "Player 14", - "Player 15", - "Player 16", - "Player 17", - "Player 18", - "Player 19", - "Player 20", - "Player 21", - "Player 22", - "Player 23", - "Player 24", - "Player 25", - "Player 26", - "Player 27", - "Player 28", - "Player 29", - "Player 30", - "Player 31", - "Player 32" -}; +// now automatically allocated in D_RegisterClientCommands +// so that it doesn't have to be updated depending on the value of MAXPLAYERS +char player_names[MAXPLAYERS][MAXPLAYERNAME+1]; INT16 rw_maximums[NUM_WEAPONS] = { @@ -634,11 +605,99 @@ void G_AddTempNightsRecords(UINT32 pscore, tic_t ptime, UINT8 mare) ntemprecords.nummares = mare; } +// +// G_UpdateRecordReplays +// +// Update replay files/data, etc. for Record Attack +// See G_SetNightsRecords for NiGHTS Attack. +// +static void G_UpdateRecordReplays(void) +{ + const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; + char *gpath; + char lastdemo[256], bestdemo[256]; + UINT8 earnedEmblems; + + // Record new best time + if (!mainrecords[gamemap-1]) + G_AllocMainRecordData(gamemap-1); + + if (players[consoleplayer].score > mainrecords[gamemap-1]->score) + mainrecords[gamemap-1]->score = players[consoleplayer].score; + + if ((mainrecords[gamemap-1]->time == 0) || (players[consoleplayer].realtime < mainrecords[gamemap-1]->time)) + mainrecords[gamemap-1]->time = players[consoleplayer].realtime; + + if ((UINT16)(players[consoleplayer].rings) > mainrecords[gamemap-1]->rings) + mainrecords[gamemap-1]->rings = (UINT16)(players[consoleplayer].rings); + + // Save demo! + bestdemo[255] = '\0'; + lastdemo[255] = '\0'; + G_SetDemoTime(players[consoleplayer].realtime, players[consoleplayer].score, (UINT16)(players[consoleplayer].rings)); + G_CheckDemoStatus(); + + I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); + I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); + + if ((gpath = malloc(glen)) == NULL) + I_Error("Out of memory for replay filepath\n"); + + sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); + snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, skins[cv_chooseskin.value-1].name); + + if (FIL_FileExists(lastdemo)) + { + UINT8 *buf; + size_t len = FIL_ReadFile(lastdemo, &buf); + + snprintf(bestdemo, 255, "%s-%s-time-best.lmp", gpath, skins[cv_chooseskin.value-1].name); + if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) + { // Better time, save this demo. + if (FIL_FileExists(bestdemo)) + remove(bestdemo); + FIL_WriteFile(bestdemo, buf, len); + CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW RECORD TIME!"), M_GetText("Saved replay as"), bestdemo); + } + + snprintf(bestdemo, 255, "%s-%s-score-best.lmp", gpath, skins[cv_chooseskin.value-1].name); + if (!FIL_FileExists(bestdemo) || (G_CmpDemoTime(bestdemo, lastdemo) & (1<<1))) + { // Better score, save this demo. + if (FIL_FileExists(bestdemo)) + remove(bestdemo); + FIL_WriteFile(bestdemo, buf, len); + CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW HIGH SCORE!"), M_GetText("Saved replay as"), bestdemo); + } + + snprintf(bestdemo, 255, "%s-%s-rings-best.lmp", gpath, skins[cv_chooseskin.value-1].name); + if (!FIL_FileExists(bestdemo) || (G_CmpDemoTime(bestdemo, lastdemo) & (1<<2))) + { // Better rings, save this demo. + if (FIL_FileExists(bestdemo)) + remove(bestdemo); + FIL_WriteFile(bestdemo, buf, len); + CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW MOST RINGS!"), M_GetText("Saved replay as"), bestdemo); + } + + //CONS_Printf("%s '%s'\n", M_GetText("Saved replay as"), lastdemo); + + Z_Free(buf); + } + free(gpath); + + // Check emblems when level data is updated + if ((earnedEmblems = M_CheckLevelEmblems())) + CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for Record Attack records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); + + // Update timeattack menu's replay availability. + Nextmap_OnChange(); +} + void G_SetNightsRecords(void) { INT32 i; UINT32 totalscore = 0; tic_t totaltime = 0; + UINT8 earnedEmblems; const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char *gpath; @@ -738,9 +797,11 @@ void G_SetNightsRecords(void) } free(gpath); + if ((earnedEmblems = M_CheckLevelEmblems())) + CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for NiGHTS records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); + // If the mare count changed, this will update the score display - CV_AddValue(&cv_nextmap, 1); - CV_AddValue(&cv_nextmap, -1); + Nextmap_OnChange(); } // for consistency among messages: this modifies the game and removes savemoddata. @@ -866,14 +927,6 @@ static INT32 JoyAxis(axis_input_e axissel) axisval = -axisval; flp = true; } -#ifdef _arch_dreamcast - if (axisval == 7) // special case - { - retaxis = joyxmove[1] - joyymove[1]; - goto skipDC; - } - else -#endif if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None return 0; @@ -889,20 +942,18 @@ static INT32 JoyAxis(axis_input_e axissel) retaxis = joyymove[axisval]; } -#ifdef _arch_dreamcast - skipDC: -#endif - if (retaxis < (-JOYAXISRANGE)) retaxis = -JOYAXISRANGE; if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick.bGamepadStyle && axissel < AXISDEAD) + + if (!Joystick.bGamepadStyle && axissel > AXISDIGITAL) { - const INT32 jdeadzone = JOYAXISRANGE/4; + const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) return 0; } + if (flp) retaxis = -retaxis; //flip it around return retaxis; } @@ -950,14 +1001,7 @@ static INT32 Joy2Axis(axis_input_e axissel) axisval = -axisval; flp = true; } -#ifdef _arch_dreamcast - if (axisval == 7) // special case - { - retaxis = joy2xmove[1] - joy2ymove[1]; - goto skipDC; - } - else -#endif + if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None return 0; @@ -973,25 +1017,91 @@ static INT32 Joy2Axis(axis_input_e axissel) retaxis = joy2ymove[axisval]; } -#ifdef _arch_dreamcast - skipDC: -#endif - if (retaxis < (-JOYAXISRANGE)) retaxis = -JOYAXISRANGE; if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick2.bGamepadStyle && axissel < AXISDEAD) + + if (!Joystick2.bGamepadStyle && axissel > AXISDIGITAL) { - const INT32 jdeadzone = JOYAXISRANGE/4; + const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_digitaldeadzone2.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) return 0; } + if (flp) retaxis = -retaxis; //flip it around return retaxis; } +#define PlayerJoyAxis(p, ax) ((p) == 1 ? JoyAxis(ax) : Joy2Axis(ax)) + +// Take a magnitude of two axes, and adjust it to take out the deadzone +// Will return a value between 0 and JOYAXISRANGE +static INT32 G_BasicDeadZoneCalculation(INT32 magnitude, fixed_t deadZone) +{ + const INT32 jdeadzone = (JOYAXISRANGE * deadZone) / FRACUNIT; + INT32 deadzoneAppliedValue = 0; + INT32 adjustedMagnitude = abs(magnitude); + + if (jdeadzone >= JOYAXISRANGE && adjustedMagnitude >= JOYAXISRANGE) // If the deadzone and magnitude are both 100%... + return JOYAXISRANGE; // ...return 100% input directly, to avoid dividing by 0 + else if (adjustedMagnitude > jdeadzone) // Otherwise, calculate how much the magnitude exceeds the deadzone + { + adjustedMagnitude = min(adjustedMagnitude, JOYAXISRANGE); + + adjustedMagnitude -= jdeadzone; + + deadzoneAppliedValue = (adjustedMagnitude * JOYAXISRANGE) / (JOYAXISRANGE - jdeadzone); + } + + return deadzoneAppliedValue; +} + +// Get the actual sensible radial value for a joystick axis when accounting for a deadzone +static void G_HandleAxisDeadZone(UINT8 splitnum, joystickvector2_t *joystickvector) +{ + INT32 gamepadStyle = Joystick.bGamepadStyle; + fixed_t deadZone = cv_deadzone.value; + + if (splitnum == 1) + { + gamepadStyle = Joystick2.bGamepadStyle; + deadZone = cv_deadzone2.value; + } + + // When gamepadstyle is "true" the values are just -1, 0, or 1. This is done in the interface code. + if (!gamepadStyle) + { + // Get the total magnitude of the 2 axes + INT32 magnitude = (joystickvector->xaxis * joystickvector->xaxis) + (joystickvector->yaxis * joystickvector->yaxis); + INT32 normalisedXAxis; + INT32 normalisedYAxis; + INT32 normalisedMagnitude; + double dMagnitude = sqrt((double)magnitude); + magnitude = (INT32)dMagnitude; + + // Get the normalised xy values from the magnitude + normalisedXAxis = (joystickvector->xaxis * magnitude) / JOYAXISRANGE; + normalisedYAxis = (joystickvector->yaxis * magnitude) / JOYAXISRANGE; + + // Apply the deadzone to the magnitude to give a correct value between 0 and JOYAXISRANGE + normalisedMagnitude = G_BasicDeadZoneCalculation(magnitude, deadZone); + + // Apply the deadzone to the xy axes + joystickvector->xaxis = (normalisedXAxis * normalisedMagnitude) / JOYAXISRANGE; + joystickvector->yaxis = (normalisedYAxis * normalisedMagnitude) / JOYAXISRANGE; + + // Cap the values so they don't go above the correct maximum + joystickvector->xaxis = min(joystickvector->xaxis, JOYAXISRANGE); + joystickvector->xaxis = max(joystickvector->xaxis, -JOYAXISRANGE); + joystickvector->yaxis = min(joystickvector->yaxis, JOYAXISRANGE); + joystickvector->yaxis = max(joystickvector->yaxis, -JOYAXISRANGE); + } +} + + + // // G_BuildTiccmd // Builds a ticcmd from all of the available inputs @@ -1007,147 +1117,237 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn -void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) +boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player +mobj_t *ticcmd_ztargetfocus[2]; // Locking onto an object? +void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { boolean forcestrafe = false; - INT32 tspeed, forward, side, axis, altaxis, i; + boolean forcefullinput = false; + INT32 tspeed, forward, side, axis, strafeaxis, moveaxis, turnaxis, lookaxis, i; + + joystickvector2_t movejoystickvector, lookjoystickvector; + const INT32 speed = 1; // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; - player_t *player = &players[consoleplayer]; - camera_t *thiscam = &camera; + boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; + boolean strafeisturn; // Simple controls only + player_t *player = &players[ssplayer == 2 ? secondarydisplayplayer : consoleplayer]; + camera_t *thiscam = ((ssplayer == 1 || player->bot == 2) ? &camera : &camera2); + angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); + INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); - static INT32 turnheld; // for accelerative turning - static boolean keyboard_look; // true if lookup/down using keyboard - static boolean resetdown; // don't cam reset every frame - static boolean joyaiming; // check the last frame's value if we need to reset the camera + angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; + INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, invertmouse, turnmultiplier, mousemove; + controlstyle_e controlstyle = G_ControlStyle(ssplayer); + INT32 *mx; INT32 *my; INT32 *mly; - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + static INT32 turnheld[2]; // for accelerative turning + static boolean keyboard_look[2]; // true if lookup/down using keyboard + static boolean resetdown[2]; // don't cam reset every frame + static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera + + // simple mode vars + static boolean zchange[2]; // only switch z targets once per press + static fixed_t tta_factor[2] = {FRACUNIT, FRACUNIT}; // disables turn-to-angle when manually turning camera until movement happens + boolean centerviewdown = false; + + UINT8 forplayer = ssplayer-1; + + if (ssplayer == 1) + { + chasecam = cv_chasecam.value; + chasefreelook = cv_chasefreelook.value; + alwaysfreelook = cv_alwaysfreelook.value; + usejoystick = cv_usejoystick.value; + invertmouse = cv_invertmouse.value; + turnmultiplier = cv_cam_turnmultiplier.value; + mousemove = cv_mousemove.value; + mx = &mousex; + my = &mousey; + mly = &mlooky; + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + } + else + { + chasecam = cv_chasecam2.value; + chasefreelook = cv_chasefreelook2.value; + alwaysfreelook = cv_alwaysfreelook2.value; + usejoystick = cv_usejoystick2.value; + invertmouse = cv_invertmouse2.value; + turnmultiplier = cv_cam2_turnmultiplier.value; + mousemove = cv_mousemove2.value; + mx = &mouse2x; + my = &mouse2y; + mly = &mlook2y; + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver + } + + strafeisturn = controlstyle == CS_SIMPLE && ticcmd_centerviewdown[forplayer] && + ((cv_cam_lockedinput[forplayer].value && !ticcmd_ztargetfocus[forplayer]) || (player->pflags & PF_STARTDASH)) && + !player->climbing && player->powers[pw_carry] != CR_MINECART; // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. - if (paused || P_AutoPause() || (gamestate == GS_LEVEL && player->playerstate == PST_REBORN)) - { - cmd->angleturn = (INT16)(localangle >> 16); - cmd->aiming = G_ClipAimingPitch(&localaiming); + // ...OR if we're blindfolded. No looking into the floor. + if (paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG) + && (leveltime < hidetime * TICRATE) && (player->pflags & PF_TAGIT))))) + {//@TODO splitscreen player + cmd->angleturn = (INT16)(*myangle >> 16); + cmd->aiming = G_ClipAimingPitch(myaiming); return; } - turnright = PLAYER1INPUTDOWN(gc_turnright); - turnleft = PLAYER1INPUTDOWN(gc_turnleft); - mouseaiming = (PLAYER1INPUTDOWN(gc_mouseaiming)) ^ - (cv_chasecam.value ? cv_chasefreelook.value : cv_alwaysfreelook.value); - analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; + turnright = PLAYERINPUTDOWN(ssplayer, gc_turnright); + turnleft = PLAYERINPUTDOWN(ssplayer, gc_turnleft); - thisjoyaiming = (cv_chasecam.value) ? cv_chasefreelook.value : cv_alwaysfreelook.value; + straferkey = PLAYERINPUTDOWN(ssplayer, gc_straferight); + strafelkey = PLAYERINPUTDOWN(ssplayer, gc_strafeleft); + movefkey = PLAYERINPUTDOWN(ssplayer, gc_forward); + movebkey = PLAYERINPUTDOWN(ssplayer, gc_backward); + + if (strafeisturn) + { + turnright |= straferkey; + turnleft |= strafelkey; + straferkey = strafelkey = false; + } + + mouseaiming = (PLAYERINPUTDOWN(ssplayer, gc_mouseaiming)) ^ + ((chasecam && !player->spectator) ? chasefreelook : alwaysfreelook); + analogjoystickmove = usejoystick && !Joystick.bGamepadStyle; + gamepadjoystickmove = usejoystick && Joystick.bGamepadStyle; + + thisjoyaiming = (chasecam && !player->spectator) ? chasefreelook : alwaysfreelook; // Reset the vertical look if we're no longer joyaiming - if (!thisjoyaiming && joyaiming) - localaiming = 0; - joyaiming = thisjoyaiming; + if (!thisjoyaiming && joyaiming[forplayer]) + *myaiming = 0; + joyaiming[forplayer] = thisjoyaiming; - axis = JoyAxis(AXISTURN); - if (gamepadjoystickmove && axis != 0) + turnaxis = PlayerJoyAxis(ssplayer, AXISTURN); + if (strafeisturn) + turnaxis += PlayerJoyAxis(ssplayer, AXISSTRAFE); + lookaxis = PlayerJoyAxis(ssplayer, AXISLOOK); + lookjoystickvector.xaxis = turnaxis; + lookjoystickvector.yaxis = lookaxis; + G_HandleAxisDeadZone(forplayer, &lookjoystickvector); + + if (gamepadjoystickmove && lookjoystickvector.xaxis != 0) { - turnright = turnright || (axis > 0); - turnleft = turnleft || (axis < 0); + turnright = turnright || (lookjoystickvector.xaxis > 0); + turnleft = turnleft || (lookjoystickvector.xaxis < 0); } forward = side = 0; // use two stage accelerative turning // on the keyboard and joystick if (turnleft || turnright) - turnheld += realtics; + turnheld[forplayer] += realtics; else - turnheld = 0; + turnheld[forplayer] = 0; - if (turnheld < SLOWTURNTICS) + if (turnheld[forplayer] < SLOWTURNTICS) tspeed = 2; // slow turn else tspeed = speed; // let movement keys cancel each other out - if (cv_analog.value) // Analog + if (controlstyle == CS_LMAOGALOG) // Analog { if (turnright) cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); if (turnleft) cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); } - if (cv_analog.value || twodlevel + if (twodlevel || (player->mo && (player->mo->flags2 & MF2_TWOD)) - || (!demoplayback && (player->climbing - || (player->pflags & PF_NIGHTSMODE) - || (player->pflags & PF_SLIDING) - || (player->pflags & PF_FORCESTRAFE)))) // Analog + || (!demoplayback && (player->pflags & PF_SLIDING))) + forcefullinput = true; + if (twodlevel + || (player->mo && (player->mo->flags2 & MF2_TWOD)) + || (!demoplayback && ((player->powers[pw_carry] == CR_NIGHTSMODE) + || (player->pflags & (PF_SLIDING|PF_FORCESTRAFE))))) // Analog forcestrafe = true; - if (forcestrafe) // Analog + if (forcestrafe) { if (turnright) side += sidemove[speed]; if (turnleft) side -= sidemove[speed]; - if (analogjoystickmove && axis != 0) + if (analogjoystickmove && lookjoystickvector.xaxis != 0) { // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); + side += ((lookjoystickvector.xaxis * sidemove[1]) >> 10); } } + else if (controlstyle == CS_LMAOGALOG) // Analog + { + if (turnright) + cmd->buttons |= BT_CAMRIGHT; + if (turnleft) + cmd->buttons |= BT_CAMLEFT; + } else { - if (turnright) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); + if (turnright && turnleft); + else if (turnright) + cmd->angleturn = (INT16)(cmd->angleturn - ((angleturn[tspeed] * turnmultiplier)>>FRACBITS)); else if (turnleft) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); + cmd->angleturn = (INT16)(cmd->angleturn + ((angleturn[tspeed] * turnmultiplier)>>FRACBITS)); - if (analogjoystickmove && axis != 0) + if (analogjoystickmove && lookjoystickvector.xaxis != 0) { // JOYAXISRANGE should be 1023 (divide by 1024) - cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! + cmd->angleturn = (INT16)(cmd->angleturn - ((((lookjoystickvector.xaxis * angleturn[1]) >> 10) * turnmultiplier)>>FRACBITS)); // ANALOG! } + + if (turnright || turnleft || abs(cmd->angleturn) > angleturn[2]) + tta_factor[forplayer] = 0; // suspend turn to angle } - axis = JoyAxis(AXISSTRAFE); - if (gamepadjoystickmove && axis != 0) + strafeaxis = strafeisturn ? 0 : PlayerJoyAxis(ssplayer, AXISSTRAFE); + moveaxis = PlayerJoyAxis(ssplayer, AXISMOVE); + movejoystickvector.xaxis = strafeaxis; + movejoystickvector.yaxis = moveaxis; + G_HandleAxisDeadZone(forplayer, &movejoystickvector); + + if (gamepadjoystickmove && movejoystickvector.xaxis != 0) { - if (axis < 0) + if (movejoystickvector.xaxis > 0) side += sidemove[speed]; - else if (axis > 0) + else if (movejoystickvector.xaxis < 0) side -= sidemove[speed]; } - else if (analogjoystickmove && axis != 0) + else if (analogjoystickmove && movejoystickvector.xaxis != 0) { // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); + side += ((movejoystickvector.xaxis * sidemove[1]) >> 10); } // forward with key or button - axis = JoyAxis(AXISMOVE); - altaxis = JoyAxis(AXISLOOK); - if (PLAYER1INPUTDOWN(gc_forward) || (gamepadjoystickmove && axis < 0) - || ((player->pflags & PF_NIGHTSMODE) - && (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && altaxis < 0)))) + if (movefkey || (gamepadjoystickmove && movejoystickvector.yaxis < 0) + || ((player->powers[pw_carry] == CR_NIGHTSMODE) + && (PLAYERINPUTDOWN(ssplayer, gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0)))) forward = forwardmove[speed]; - if (PLAYER1INPUTDOWN(gc_backward) || (gamepadjoystickmove && axis > 0) - || ((player->pflags & PF_NIGHTSMODE) - && (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && altaxis > 0)))) + if (movebkey || (gamepadjoystickmove && movejoystickvector.yaxis > 0) + || ((player->powers[pw_carry] == CR_NIGHTSMODE) + && (PLAYERINPUTDOWN(ssplayer, gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0)))) forward -= forwardmove[speed]; - if (analogjoystickmove && axis != 0) - forward -= ((axis * forwardmove[1]) >> 10); // ANALOG! + if (analogjoystickmove && movejoystickvector.yaxis != 0) + forward -= ((movejoystickvector.yaxis * forwardmove[1]) >> 10); // ANALOG! // some people strafe left & right with mouse buttons // those people are weird - if (PLAYER1INPUTDOWN(gc_straferight)) + if (straferkey) side += sidemove[speed]; - if (PLAYER1INPUTDOWN(gc_strafeleft)) + if (strafelkey) side -= sidemove[speed]; - if (PLAYER1INPUTDOWN(gc_weaponnext)) + if (PLAYERINPUTDOWN(ssplayer, gc_weaponnext)) cmd->buttons |= BT_WEAPONNEXT; // Next Weapon - if (PLAYER1INPUTDOWN(gc_weaponprev)) + if (PLAYERINPUTDOWN(ssplayer, gc_weaponprev)) cmd->buttons |= BT_WEAPONPREV; // Previous Weapon #if NUM_WEAPONS > 10 @@ -1156,120 +1356,223 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) //use the four avaliable bits to determine the weapon. cmd->buttons &= ~BT_WEAPONMASK; for (i = 0; i < NUM_WEAPONS; ++i) - if (PLAYER1INPUTDOWN(gc_wepslot1 + i)) + if (PLAYERINPUTDOWN(ssplayer, gc_wepslot1 + i)) { cmd->buttons |= (UINT16)(i + 1); break; } // fire with any button/key - axis = JoyAxis(AXISFIRE); - if (PLAYER1INPUTDOWN(gc_fire) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISFIRE); + if (PLAYERINPUTDOWN(ssplayer, gc_fire) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; // fire normal with any button/key - axis = JoyAxis(AXISFIRENORMAL); - if (PLAYER1INPUTDOWN(gc_firenormal) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISFIRENORMAL); + if (PLAYERINPUTDOWN(ssplayer, gc_firenormal) || (usejoystick && axis > 0)) cmd->buttons |= BT_FIRENORMAL; - if (PLAYER1INPUTDOWN(gc_tossflag)) + if (PLAYERINPUTDOWN(ssplayer, gc_tossflag)) cmd->buttons |= BT_TOSSFLAG; // Lua scriptable buttons - if (PLAYER1INPUTDOWN(gc_custom1)) + if (PLAYERINPUTDOWN(ssplayer, gc_custom1)) cmd->buttons |= BT_CUSTOM1; - if (PLAYER1INPUTDOWN(gc_custom2)) + if (PLAYERINPUTDOWN(ssplayer, gc_custom2)) cmd->buttons |= BT_CUSTOM2; - if (PLAYER1INPUTDOWN(gc_custom3)) + if (PLAYERINPUTDOWN(ssplayer, gc_custom3)) cmd->buttons |= BT_CUSTOM3; // use with any button/key - axis = JoyAxis(AXISSPIN); - if (PLAYER1INPUTDOWN(gc_use) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISSPIN); + if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0)) cmd->buttons |= BT_USE; - // Camera Controls - if (cv_debug || cv_analog.value || demoplayback || objectplacing || player->pflags & PF_NIGHTSMODE) + // Centerview can be a toggle in simple mode! { - if (PLAYER1INPUTDOWN(gc_camleft)) - cmd->buttons |= BT_CAMLEFT; - if (PLAYER1INPUTDOWN(gc_camright)) - cmd->buttons |= BT_CAMRIGHT; + static boolean last_centerviewdown[2], centerviewhold[2]; // detect taps for toggle behavior + boolean down = PLAYERINPUTDOWN(ssplayer, gc_centerview); + + if (!(controlstyle == CS_SIMPLE && cv_cam_centertoggle[forplayer].value)) + centerviewdown = down; + else + { + if (down && !last_centerviewdown[forplayer]) + centerviewhold[forplayer] = !centerviewhold[forplayer]; + last_centerviewdown[forplayer] = down; + + if (cv_cam_centertoggle[forplayer].value == 2 && !down && !ticcmd_ztargetfocus[forplayer]) + centerviewhold[forplayer] = false; + + centerviewdown = centerviewhold[forplayer]; + } } - if (PLAYER1INPUTDOWN(gc_camreset)) + if (centerviewdown) { - if (camera.chase && !resetdown) - P_ResetCamera(&players[displayplayer], &camera); - resetdown = true; + if (controlstyle == CS_SIMPLE && !ticcmd_centerviewdown[forplayer] && !G_RingSlingerGametype()) + { + CV_SetValue(&cv_directionchar[forplayer], 2); + *myangle = player->mo->angle; + *myaiming = 0; + + if (cv_cam_lockonboss[forplayer].value) + P_SetTarget(&ticcmd_ztargetfocus[forplayer], P_LookForFocusTarget(player, NULL, 0, cv_cam_lockonboss[forplayer].value)); + } + + ticcmd_centerviewdown[forplayer] = true; + } + else if (ticcmd_centerviewdown[forplayer]) + { + if (controlstyle == CS_SIMPLE) + { + P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); + CV_SetValue(&cv_directionchar[forplayer], 1); + } + + ticcmd_centerviewdown[forplayer] = false; + } + + if (ticcmd_ztargetfocus[forplayer]) + { + if ( + P_MobjWasRemoved(ticcmd_ztargetfocus[forplayer]) || + !ticcmd_ztargetfocus[forplayer]->health || + (ticcmd_ztargetfocus[forplayer]->flags2 & MF2_FRET) || + (ticcmd_ztargetfocus[forplayer]->type == MT_EGGMOBILE3 && !ticcmd_ztargetfocus[forplayer]->movecount) // Sea Egg is moving around underground and shouldn't be tracked + ) + P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); + else + { + mobj_t *newtarget = NULL; + if (zchange[forplayer]) + { + if (!turnleft && !turnright && abs(cmd->angleturn) < angleturn[0]) + zchange[forplayer] = false; + } + else if (turnleft || cmd->angleturn > angleturn[0]) + { + zchange[forplayer] = true; + newtarget = P_LookForFocusTarget(player, ticcmd_ztargetfocus[forplayer], 1, cv_cam_lockonboss[forplayer].value); + } + else if (turnright || cmd->angleturn < -angleturn[0]) + { + zchange[forplayer] = true; + newtarget = P_LookForFocusTarget(player, ticcmd_ztargetfocus[forplayer], -1, cv_cam_lockonboss[forplayer].value); + } + + if (newtarget) + P_SetTarget(&ticcmd_ztargetfocus[forplayer], newtarget); + + // I assume this is netgame-safe because gunslinger spawns this for only the local player...... *sweats intensely* + newtarget = P_SpawnMobj(ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y, ticcmd_ztargetfocus[forplayer]->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&newtarget->target, ticcmd_ztargetfocus[forplayer]); + + if (P_AproxDistance( + player->mo->x - ticcmd_ztargetfocus[forplayer]->x, + player->mo->y - ticcmd_ztargetfocus[forplayer]->y + ) > 50*player->mo->scale) + { + INT32 anglediff = R_PointToAngle2(player->mo->x, player->mo->y, ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y) - *myangle; + const INT32 maxturn = ANG10/2; + anglediff /= 4; + + if (anglediff > maxturn) + anglediff = maxturn; + else if (anglediff < -maxturn) + anglediff = -maxturn; + + *myangle += anglediff; + } + } + } + + if (ticcmd_centerviewdown[forplayer] && controlstyle == CS_SIMPLE) + controlstyle = CS_LEGACY; + + if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) + { + if (thiscam->chase && !resetdown[forplayer]) + P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], thiscam); + + resetdown[forplayer] = true; } else - resetdown = false; + resetdown[forplayer] = false; + // jump button - axis = JoyAxis(AXISJUMP); - if (PLAYER1INPUTDOWN(gc_jump) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISJUMP); + if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0)) cmd->buttons |= BT_JUMP; // player aiming shit, ahhhh... { - INT32 player_invert = cv_invertmouse.value ? -1 : 1; + INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!camera.chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted + && (!thiscam->chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted ? -1 : 1; // set to -1 or 1 to multiply + INT32 configlookaxis = ssplayer == 1 ? cv_lookaxis.value : cv_lookaxis2.value; // mouse look stuff (mouse look is not the same as mouse aim) if (mouseaiming) { - keyboard_look = false; + keyboard_look[forplayer] = false; // looking up/down - localaiming += (mlooky<<19)*player_invert*screen_invert; + *myaiming += (*mly<<19)*player_invert*screen_invert; } - axis = JoyAxis(AXISLOOK); - if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis.value != 0) - localaiming += (axis<<16) * screen_invert; + if (analogjoystickmove && joyaiming[forplayer] && lookjoystickvector.yaxis != 0 && configlookaxis != 0) + *myaiming += (lookjoystickvector.yaxis<<16) * screen_invert; // spring back if not using keyboard neither mouselookin' - if (!keyboard_look && cv_lookaxis.value == 0 && !joyaiming && !mouseaiming) - localaiming = 0; + if (!keyboard_look[forplayer] && configlookaxis == 0 && !joyaiming[forplayer] && !mouseaiming) + *myaiming = 0; - if (!(player->pflags & PF_NIGHTSMODE)) + if (!(player->powers[pw_carry] == CR_NIGHTSMODE)) { - if (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0)) + if (PLAYERINPUTDOWN(ssplayer, gc_lookup) || (gamepadjoystickmove && lookjoystickvector.yaxis < 0)) { - localaiming += KB_LOOKSPEED * screen_invert; - keyboard_look = true; + *myaiming += KB_LOOKSPEED * screen_invert; + keyboard_look[forplayer] = true; } - else if (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && axis > 0)) + else if (PLAYERINPUTDOWN(ssplayer, gc_lookdown) || (gamepadjoystickmove && lookjoystickvector.yaxis > 0)) { - localaiming -= KB_LOOKSPEED * screen_invert; - keyboard_look = true; + *myaiming -= KB_LOOKSPEED * screen_invert; + keyboard_look[forplayer] = true; } - else if (PLAYER1INPUTDOWN(gc_centerview)) - localaiming = 0; + else if (ticcmd_centerviewdown[forplayer]) + *myaiming = 0; } // accept no mlook for network games if (!cv_allowmlook.value) - localaiming = 0; + *myaiming = 0; - cmd->aiming = G_ClipAimingPitch(&localaiming); + cmd->aiming = G_ClipAimingPitch(myaiming); } - if (!mouseaiming && cv_mousemove.value) - forward += mousey; + if (!mouseaiming && mousemove) + forward += *my; - if (cv_analog.value || - (!demoplayback && (player->climbing - || (player->pflags & PF_SLIDING)))) // Analog for mouse - side += mousex*2; + if ((!demoplayback && (player->pflags & PF_SLIDING))) // Analog for mouse + side += *mx*2; + else if (controlstyle == CS_LMAOGALOG) + { + if (*mx) + { + if (*mx > 0) + cmd->buttons |= BT_CAMRIGHT; + else + cmd->buttons |= BT_CAMLEFT; + } + } else - cmd->angleturn = (INT16)(cmd->angleturn - (mousex*8)); + cmd->angleturn = (INT16)(cmd->angleturn - (*mx*8)); - mousex = mousey = mlooky = 0; + *mx = *my = *mly = 0; if (forward > MAXPLMOVE) forward = MAXPLMOVE; @@ -1282,14 +1585,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) // No additional acceleration when moving forward/backward and strafing simultaneously. // do this AFTER we cap to MAXPLMOVE so people can't find ways to cheese around this. - if (!forcestrafe && forward && side) + if (!forcefullinput && forward && side) { - forward = FixedMul(forward, 3*FRACUNIT/4); - side = FixedMul(side, 3*FRACUNIT/4); + angle_t angle = R_PointToAngle2(0, 0, side << FRACBITS, forward << FRACBITS); + INT32 maxforward = abs(P_ReturnThrustY(NULL, angle, MAXPLMOVE)); + INT32 maxside = abs(P_ReturnThrustX(NULL, angle, MAXPLMOVE)); + forward = max(min(forward, maxforward), -maxforward); + side = max(min(side, maxside), -maxside); } //Silly hack to make 2d mode *somewhat* playable with no chasecam. - if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !camera.chase) + if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !thiscam->chase) { INT32 temp = forward; forward = side; @@ -1299,334 +1605,117 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); cmd->sidemove = (SINT8)(cmd->sidemove + side); - if (cv_analog.value) { - cmd->angleturn = (INT16)(thiscam->angle >> 16); - if (player->awayviewtics) - cmd->angleturn = (INT16)(player->awayviewmobj->angle >> 16); - } - else - { - localangle += (cmd->angleturn<<16); - cmd->angleturn = (INT16)(localangle >> 16); - } - - //Reset away view if a command is given. - if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayer != consoleplayer) - displayplayer = consoleplayer; -} - -// like the g_buildticcmd 1 but using mouse2, gamcontrolbis, ... -void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) -{ - boolean forcestrafe = false; - INT32 tspeed, forward, side, axis, altaxis, i; - const INT32 speed = 1; - // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; - player_t *player = &players[secondarydisplayplayer]; - camera_t *thiscam = (player->bot == 2 ? &camera : &camera2); - - static INT32 turnheld; // for accelerative turning - static boolean keyboard_look; // true if lookup/down using keyboard - static boolean resetdown; // don't cam reset every frame - static boolean joyaiming; // check the last frame's value if we need to reset the camera - - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver - - //why build a ticcmd if we're paused? - // Or, for that matter, if we're being reborn. - if (paused || P_AutoPause() || player->playerstate == PST_REBORN) - { - cmd->angleturn = (INT16)(localangle2 >> 16); - cmd->aiming = G_ClipAimingPitch(&localaiming2); - return; - } - - turnright = PLAYER2INPUTDOWN(gc_turnright); - turnleft = PLAYER2INPUTDOWN(gc_turnleft); - mouseaiming = (PLAYER2INPUTDOWN(gc_mouseaiming)) ^ - (cv_chasecam2.value ? cv_chasefreelook2.value : cv_alwaysfreelook2.value); - analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle; - - thisjoyaiming = (cv_chasecam2.value) ? cv_chasefreelook2.value : cv_alwaysfreelook2.value; - - // Reset the vertical look if we're no longer joyaiming - if (!thisjoyaiming && joyaiming) - localaiming2 = 0; - joyaiming = thisjoyaiming; - - axis = Joy2Axis(AXISTURN); - if (gamepadjoystickmove && axis != 0) - { - turnright = turnright || (axis > 0); - turnleft = turnleft || (axis < 0); - } - forward = side = 0; - - // use two stage accelerative turning - // on the keyboard and joystick - if (turnleft || turnright) - turnheld += realtics; - else - turnheld = 0; - - if (turnheld < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = speed; - - // let movement keys cancel each other out - if (cv_analog2.value) // Analog - { - if (turnright) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - if (turnleft) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); - } - if (cv_analog2.value || twodlevel - || (player->mo && (player->mo->flags2 & MF2_TWOD)) - || player->climbing - || (player->pflags & PF_NIGHTSMODE) - || (player->pflags & PF_SLIDING) - || (player->pflags & PF_FORCESTRAFE)) // Analog - forcestrafe = true; - if (forcestrafe) // Analog - { - if (turnright) - side += sidemove[speed]; - if (turnleft) - side -= sidemove[speed]; - - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); - } - } - else - { - if (turnright) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - else if (turnleft) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); - - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE should be 1023 (divide by 1024) - cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! - } - } - - axis = Joy2Axis(AXISSTRAFE); - if (gamepadjoystickmove && axis != 0) - { - if (axis < 0) - side += sidemove[speed]; - else if (axis > 0) - side -= sidemove[speed]; - } - else if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); - } - - // forward with key or button - axis = Joy2Axis(AXISMOVE); - altaxis = Joy2Axis(AXISLOOK); - if (PLAYER2INPUTDOWN(gc_forward) || (gamepadjoystickmove && axis < 0) - || ((player->pflags & PF_NIGHTSMODE) - && (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && altaxis < 0)))) - forward = forwardmove[speed]; - if (PLAYER2INPUTDOWN(gc_backward) || (gamepadjoystickmove && axis > 0) - || ((player->pflags & PF_NIGHTSMODE) - && (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && altaxis > 0)))) - forward -= forwardmove[speed]; - - if (analogjoystickmove && axis != 0) - forward -= ((axis * forwardmove[1]) >> 10); // ANALOG! - - // some people strafe left & right with mouse buttons - // those people are (still) weird - if (PLAYER2INPUTDOWN(gc_straferight)) - side += sidemove[speed]; - if (PLAYER2INPUTDOWN(gc_strafeleft)) - side -= sidemove[speed]; - - if (PLAYER2INPUTDOWN(gc_weaponnext)) - cmd->buttons |= BT_WEAPONNEXT; // Next Weapon - if (PLAYER2INPUTDOWN(gc_weaponprev)) - cmd->buttons |= BT_WEAPONPREV; // Previous Weapon - - //use the four avaliable bits to determine the weapon. - cmd->buttons &= ~BT_WEAPONMASK; - for (i = 0; i < NUM_WEAPONS; ++i) - if (PLAYER2INPUTDOWN(gc_wepslot1 + i)) - { - cmd->buttons |= (UINT16)(i + 1); - break; - } - - // fire with any button/key - axis = Joy2Axis(AXISFIRE); - if (PLAYER2INPUTDOWN(gc_fire) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_ATTACK; - - // fire normal with any button/key - axis = Joy2Axis(AXISFIRENORMAL); - if (PLAYER2INPUTDOWN(gc_firenormal) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_FIRENORMAL; - - if (PLAYER2INPUTDOWN(gc_tossflag)) - cmd->buttons |= BT_TOSSFLAG; - - // Lua scriptable buttons - if (PLAYER2INPUTDOWN(gc_custom1)) - cmd->buttons |= BT_CUSTOM1; - if (PLAYER2INPUTDOWN(gc_custom2)) - cmd->buttons |= BT_CUSTOM2; - if (PLAYER2INPUTDOWN(gc_custom3)) - cmd->buttons |= BT_CUSTOM3; - - // use with any button/key - axis = Joy2Axis(AXISSPIN); - if (PLAYER2INPUTDOWN(gc_use) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_USE; - - // Camera Controls - if (cv_debug || cv_analog2.value || player->pflags & PF_NIGHTSMODE) - { - if (PLAYER2INPUTDOWN(gc_camleft)) - cmd->buttons |= BT_CAMLEFT; - if (PLAYER2INPUTDOWN(gc_camright)) - cmd->buttons |= BT_CAMRIGHT; - } - - if (PLAYER2INPUTDOWN(gc_camreset)) - { - if (camera2.chase && !resetdown) - P_ResetCamera(&players[secondarydisplayplayer], &camera2); - resetdown = true; - } - else - resetdown = false; - - // jump button - axis = Joy2Axis(AXISJUMP); - if (PLAYER2INPUTDOWN(gc_jump) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_JUMP; - - // player aiming shit, ahhhh... - { - INT32 player_invert = cv_invertmouse2.value ? -1 : 1; - INT32 screen_invert = - (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!camera2.chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted - ? -1 : 1; // set to -1 or 1 to multiply - - // mouse look stuff (mouse look is not the same as mouse aim) - if (mouseaiming) - { - keyboard_look = false; - - // looking up/down - localaiming2 += (mlook2y<<19)*player_invert*screen_invert; - } - - axis = Joy2Axis(AXISLOOK); - if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis2.value != 0) - localaiming2 += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!keyboard_look && cv_lookaxis2.value == 0 && !joyaiming && !mouseaiming) - localaiming2 = 0; - - if (!(player->pflags & PF_NIGHTSMODE)) - { - if (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0)) - { - localaiming2 += KB_LOOKSPEED * screen_invert; - keyboard_look = true; - } - else if (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && axis > 0)) - { - localaiming2 -= KB_LOOKSPEED * screen_invert; - keyboard_look = true; - } - else if (PLAYER2INPUTDOWN(gc_centerview)) - localaiming2 = 0; - } - - // accept no mlook for network games - if (!cv_allowmlook.value) - localaiming2 = 0; - - cmd->aiming = G_ClipAimingPitch(&localaiming2); - } - - if (!mouseaiming && cv_mousemove2.value) - forward += mouse2y; - - if (cv_analog2.value || player->climbing - || (player->pflags & PF_SLIDING)) // Analog for mouse - side += mouse2x*2; - else - cmd->angleturn = (INT16)(cmd->angleturn - (mouse2x*8)); - - mouse2x = mouse2y = mlook2y = 0; - - if (forward > MAXPLMOVE) - forward = MAXPLMOVE; - else if (forward < -MAXPLMOVE) - forward = -MAXPLMOVE; - if (side > MAXPLMOVE) - side = MAXPLMOVE; - else if (side < -MAXPLMOVE) - side = -MAXPLMOVE; - - // No additional acceleration when moving forward/backward and strafing simultaneously. - // do this AFTER we cap to MAXPLMOVE so people can't find ways to cheese around this. - if (!forcestrafe && forward && side) - { - forward = FixedMul(forward, 3*FRACUNIT/4); - side = FixedMul(side, 3*FRACUNIT/4); - } - - //Silly hack to make 2d mode *somewhat* playable with no chasecam. - if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !camera2.chase) - { - INT32 temp = forward; - forward = side; - side = temp; - } - - cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); - cmd->sidemove = (SINT8)(cmd->sidemove + side); - - if (player->bot == 1) { + if (player->bot == 1) { // Tailsbot for P2 if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } else { G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver B_BuildTiccmd(player, cmd); } + B_HandleFlightIndicator(player); } + else if (player->bot == 2) + *myangle = localangle; // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Legacy - if (cv_analog2.value) { - cmd->angleturn = (INT16)(thiscam->angle >> 16); + if (controlstyle == CS_LMAOGALOG) { if (player->awayviewtics) cmd->angleturn = (INT16)(player->awayviewmobj->angle >> 16); + else + cmd->angleturn = (INT16)(thiscam->angle >> 16); } else { - localangle2 += (cmd->angleturn<<16); - cmd->angleturn = (INT16)(localangle2 >> 16); + *myangle += (cmd->angleturn<<16); + cmd->angleturn = (INT16)(*myangle >> 16); + + // Adjust camera angle by player input + if (controlstyle == CS_SIMPLE && !forcestrafe && thiscam->chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + { + fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; + + if (camadjustfactor) + { + fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); + fixed_t factor; + + if ((sine > 0) == (cmd->sidemove > 0)) + sine = 0; // Prevent jerking right when braking from going left, or vice versa + + factor = min(40, FixedMul(player->speed, abs(sine))*2 / FRACUNIT); + + *myangle -= cmd->sidemove * factor * camadjustfactor; + } + + if (ticcmd_centerviewdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) + cmd->sidemove = 0; + } + + // Adjust camera angle to face player direction, depending on circumstances + // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction + if (controlstyle == CS_SIMPLE && !forcestrafe && thiscam->chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) + { + fixed_t camadjustfactor; + boolean alt = false; // Reduce intensity on diagonals and prevent backwards movement from turning the camera + + if (player->pflags & PF_GLIDING) + camadjustfactor = cv_cam_turnfacingability[forplayer].value/4; + else if (player->pflags & PF_STARTDASH) + camadjustfactor = cv_cam_turnfacingspindash[forplayer].value/4; + else + { + alt = true; + camadjustfactor = cv_cam_turnfacing[forplayer].value/8; + } + + camadjustfactor = FixedMul(camadjustfactor, max(FRACUNIT - player->speed, min(player->speed/18, FRACUNIT))); + + camadjustfactor = FixedMul(camadjustfactor, tta_factor[forplayer]); + + if (tta_factor[forplayer] < FRACUNIT && (cmd->forwardmove || cmd->sidemove || tta_factor[forplayer] >= FRACUNIT/3)) + tta_factor[forplayer] += FRACUNIT>>5; + else if (tta_factor[forplayer] && tta_factor[forplayer] < FRACUNIT/3) + tta_factor[forplayer] -= FRACUNIT>>5; + + if (camadjustfactor) + { + angle_t controlangle; + INT32 anglediff; + + if ((cmd->forwardmove || cmd->sidemove) && !(player->pflags & PF_SPINNING)) + controlangle = (cmd->angleturn<<16) + R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); + else + controlangle = player->drawangle + drawangleoffset; + + anglediff = controlangle - *myangle; + + if (alt) + { + fixed_t sine = FINESINE((angle_t) (anglediff)>>ANGLETOFINESHIFT); + sine = abs(sine); + + if (abs(anglediff) > ANGLE_90) + sine = max(0, sine*3 - 2*FRACUNIT); // At about 135 degrees, this will stop turning + + anglediff = FixedMul(anglediff, sine); + } + + *myangle += FixedMul(anglediff, camadjustfactor); + } + } + } + + //Reset away view if a command is given. + if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons) + && displayplayer != consoleplayer) + { + // Call ViewpointSwitch hooks here. + // The viewpoint was forcibly changed. + LUAh_ViewpointSwitch(player, &players[consoleplayer], true); + displayplayer = consoleplayer; } } @@ -1635,20 +1724,20 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) // fudging with it. static void UserAnalog_OnChange(void) { - if (cv_useranalog.value) - CV_SetValue(&cv_analog, 1); + if (cv_useranalog[0].value) + CV_SetValue(&cv_analog[0], 1); else - CV_SetValue(&cv_analog, 0); + CV_SetValue(&cv_analog[0], 0); } static void UserAnalog2_OnChange(void) { if (botingame) return; - if (cv_useranalog2.value) - CV_SetValue(&cv_analog2, 1); + if (cv_useranalog[1].value) + CV_SetValue(&cv_analog[1], 1); else - CV_SetValue(&cv_analog2, 0); + CV_SetValue(&cv_analog[1], 0); } static void Analog_OnChange(void) @@ -1658,8 +1747,8 @@ static void Analog_OnChange(void) // cameras are not initialized at this point - if (!cv_chasecam.value && cv_analog.value) { - CV_SetValue(&cv_analog, 0); + if (!cv_chasecam.value && cv_analog[0].value) { + CV_SetValue(&cv_analog[0], 0); return; } @@ -1673,14 +1762,34 @@ static void Analog2_OnChange(void) // cameras are not initialized at this point - if (!cv_chasecam2.value && cv_analog2.value) { - CV_SetValue(&cv_analog2, 0); + if (!cv_chasecam2.value && cv_analog[1].value) { + CV_SetValue(&cv_analog[1], 0); return; } SendWeaponPref2(); } +static void DirectionChar_OnChange(void) +{ + SendWeaponPref(); +} + +static void DirectionChar2_OnChange(void) +{ + SendWeaponPref2(); +} + +static void AutoBrake_OnChange(void) +{ + SendWeaponPref(); +} + +static void AutoBrake2_OnChange(void) +{ + SendWeaponPref2(); +} + // // G_DoLoadLevel // @@ -1690,6 +1799,7 @@ void G_DoLoadLevel(boolean resetplayer) // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); + demosynced = true; levelstarttic = gametic; // for time calculation @@ -1699,7 +1809,23 @@ void G_DoLoadLevel(boolean resetplayer) if (gamestate == GS_INTERMISSION) Y_EndIntermission(); + // cleanup + if (titlemapinaction == TITLEMAP_LOADING) + { + if (W_CheckNumForName(G_BuildMapName(gamemap)) == LUMPERROR) + { + titlemap = 0; // let's not infinite recursion ok + Command_ExitGame_f(); + return; + } + + titlemapinaction = TITLEMAP_RUNNING; + } + else + titlemapinaction = TITLEMAP_OFF; + G_SetGamestate(GS_LEVEL); + I_UpdateMouseGrab(); for (i = 0; i < MAXPLAYERS; i++) { @@ -1708,15 +1834,14 @@ void G_DoLoadLevel(boolean resetplayer) } // Setup the level. - if (!P_SetupLevel(false)) + if (!P_LoadLevel(false)) // this never returns false? { // fail so reset game stuff Command_ExitGame_f(); return; } - if (!resetplayer) - P_FindEmerald(); + P_FindEmerald(); displayplayer = consoleplayer; // view the guy you are playing if (!splitscreen && !botingame) @@ -1746,7 +1871,90 @@ void G_DoLoadLevel(boolean resetplayer) CON_ClearHUD(); } -static INT32 pausedelay = 0; +// +// Start the title card. +// +void G_StartTitleCard(void) +{ + // The title card has been disabled for this map. + // Oh well. + if (!G_IsTitleCardAvailable()) + { + WipeStageTitle = false; + return; + } + + // clear the hud + CON_ClearHUD(); + + // prepare status bar + ST_startTitleCard(); + + // start the title card + WipeStageTitle = (!titlemapinaction); +} + +// +// Run the title card before fading in to the level. +// +void G_PreLevelTitleCard(void) +{ + tic_t starttime = I_GetTime(); + tic_t endtime = starttime + (PRELEVELTIME*NEWTICRATERATIO); + tic_t nowtime = starttime; + tic_t lasttime = starttime; + while (nowtime < endtime) + { + // draw loop + while (!((nowtime = I_GetTime()) - lasttime)) + I_Sleep(); + lasttime = nowtime; + + ST_runTitleCard(); + ST_preLevelTitleCardDrawer(); + I_FinishUpdate(); // page flip or blit buffer + + if (moviemode) + M_SaveFrame(); + if (takescreenshot) // Only take screenshots after drawing. + M_DoScreenShot(); + } + if (!cv_showhud.value) + wipestyleflags = WSF_CROSSFADE; +} + +static boolean titlecardforreload = false; + +// +// Returns true if the current level has a title card. +// +boolean G_IsTitleCardAvailable(void) +{ + // The current level header explicitly disabled the title card. + UINT16 titleflag = LF_NOTITLECARDFIRST; + + if (modeattacking != ATTACKING_NONE) + titleflag = LF_NOTITLECARDRECORDATTACK; + else if (titlecardforreload) + titleflag = LF_NOTITLECARDRESPAWN; + + if (mapheaderinfo[gamemap-1]->levelflags & titleflag) + return false; + + // The current gametype doesn't have a title card. + if (gametyperules & GTR_NOTITLECARD) + return false; + + // The current level has no name. + if (!mapheaderinfo[gamemap-1]->lvlttl[0]) + return false; + + // The title card is available. + return true; +} + +INT32 pausedelay = 0; +boolean pausebreakkey = false; static INT32 camtoggledelay, camtoggledelay2 = 0; // @@ -1755,70 +1963,11 @@ static INT32 camtoggledelay, camtoggledelay2 = 0; // boolean G_Responder(event_t *ev) { - // allow spy mode changes even during the demo - if (gamestate == GS_LEVEL && ev->type == ev_keydown - && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) - { - if (splitscreen || !netgame) - displayplayer = consoleplayer; - else - { - // spy mode - do - { - displayplayer++; - if (displayplayer == MAXPLAYERS) - displayplayer = 0; - - if (!playeringame[displayplayer]) - continue; - - if (players[displayplayer].spectator) - continue; - - if (G_GametypeHasTeams()) - { - if (players[consoleplayer].ctfteam - && players[displayplayer].ctfteam != players[consoleplayer].ctfteam) - continue; - } - else if (gametype == GT_HIDEANDSEEK) - { - if (players[consoleplayer].pflags & PF_TAGIT) - continue; - } - // Other Tag-based gametypes? - else if (G_TagGametype()) - { - if (!players[consoleplayer].spectator - && (players[consoleplayer].pflags & PF_TAGIT) != (players[displayplayer].pflags & PF_TAGIT)) - continue; - } - else if (G_GametypeHasSpectators() && G_RingSlingerGametype()) - { - if (!players[consoleplayer].spectator) - continue; - } - - break; - } while (displayplayer != consoleplayer); - - // change statusbar also if playing back demo - if (singledemo) - ST_changeDemoView(); - - // tell who's the view - CONS_Printf(M_GetText("Viewpoint: %s\n"), player_names[displayplayer]); - - return true; - } - } - // any other key pops up menu if in demos if (gameaction == ga_nothing && !singledemo && ((demoplayback && !modeattacking && !titledemo) || gamestate == GS_TITLESCREEN)) { - if (ev->type == ev_keydown && ev->data1 != 301) + if (ev->type == ev_keydown && ev->data1 != 301 && !(gamestate == GS_TITLESCREEN && finalecount < TICRATE)) { M_StartControlPanel(); return true; @@ -1865,32 +2014,100 @@ boolean G_Responder(event_t *ev) return true; } } - - else if (gamestate == GS_CREDITS) + else if (gamestate == GS_CREDITS || gamestate == GS_ENDING) // todo: keep ending here? { if (HU_Responder(ev)) return true; // chat ate the event if (F_CreditResponder(ev)) { - F_StartGameEvaluation(); + // Skip credits for everyone + if (!netgame || server || IsPlayerAdmin(consoleplayer)) + SendNetXCmd(XD_EXITLEVEL, NULL, 0); return true; } } - else if (gamestate == GS_CONTINUING) { if (F_ContinueResponder(ev)) return true; } // Demo End - else if (gamestate == GS_GAMEEND || gamestate == GS_EVALUATION || gamestate == GS_CREDITS) + else if (gamestate == GS_GAMEEND) return true; - - else if (gamestate == GS_INTERMISSION) + else if (gamestate == GS_INTERMISSION || gamestate == GS_EVALUATION) if (HU_Responder(ev)) return true; // chat ate the event + // allow spy mode changes even during the demo + if (gamestate == GS_LEVEL && ev->type == ev_keydown + && (ev->data1 == KEY_F12 || ev->data1 == gamecontrol[gc_viewpoint][0] || ev->data1 == gamecontrol[gc_viewpoint][1])) + { + // ViewpointSwitch Lua hook. + UINT8 canSwitchView = 0; + + if (splitscreen || !netgame) + displayplayer = consoleplayer; + else + { + // spy mode + do + { + displayplayer++; + if (displayplayer == MAXPLAYERS) + displayplayer = 0; + + if (!playeringame[displayplayer]) + continue; + + // Call ViewpointSwitch hooks here. + canSwitchView = LUAh_ViewpointSwitch(&players[consoleplayer], &players[displayplayer], false); + if (canSwitchView == 1) // Set viewpoint to this player + break; + else if (canSwitchView == 2) // Skip this player + continue; + + if (players[displayplayer].spectator) + continue; + + if (G_GametypeHasTeams()) + { + if (players[consoleplayer].ctfteam + && players[displayplayer].ctfteam != players[consoleplayer].ctfteam) + continue; + } + else if (gametype == GT_HIDEANDSEEK) + { + if (players[consoleplayer].pflags & PF_TAGIT) + continue; + } + // Other Tag-based gametypes? + else if (G_TagGametype()) + { + if (!players[consoleplayer].spectator + && (players[consoleplayer].pflags & PF_TAGIT) != (players[displayplayer].pflags & PF_TAGIT)) + continue; + } + else if (G_GametypeHasSpectators() && G_RingSlingerGametype()) + { + if (!players[consoleplayer].spectator) + continue; + } + + break; + } while (displayplayer != consoleplayer); + + // change statusbar also if playing back demo + if (singledemo) + ST_changeDemoView(); + + // tell who's the view + CONS_Printf(M_GetText("Viewpoint: %s\n"), player_names[displayplayer]); + + return true; + } + } + // update keys current state G_MapEventsToControls(ev); @@ -1901,17 +2118,32 @@ boolean G_Responder(event_t *ev) || ev->data1 == gamecontrol[gc_pause][1] || ev->data1 == KEY_PAUSE) { - if (!pausedelay) + if (modeattacking && !demoplayback && (gamestate == GS_LEVEL)) { - // don't let busy scripts prevent pausing - pausedelay = NEWTICRATE/7; + pausebreakkey = (ev->data1 == KEY_PAUSE); + if (menuactive || pausedelay < 0 || leveltime < 2) + return true; - // command will handle all the checks for us - COM_ImmedExecute("pause"); - return true; + if (pausedelay < 1+(NEWTICRATE/2)) + pausedelay = 1+(NEWTICRATE/2); + else if (++pausedelay > 1+(NEWTICRATE/2)+(NEWTICRATE/3)) + { + G_SetModeAttackRetryFlag(); + return true; + } + pausedelay++; // counteract subsequent subtraction this frame } else - pausedelay = NEWTICRATE/7; + { + INT32 oldpausedelay = pausedelay; + pausedelay = (NEWTICRATE/7); + if (!oldpausedelay) + { + // command will handle all the checks for us + COM_ImmedExecute("pause"); + return true; + } + } } if (ev->data1 == gamecontrol[gc_camtoggle][0] || ev->data1 == gamecontrol[gc_camtoggle][1]) @@ -1971,11 +2203,19 @@ void G_Ticker(boolean run) { G_ClearRetryFlag(); - // Costs a life to retry ... unless the player in question is dead already. - if (G_GametypeUsesLives() && players[consoleplayer].playerstate == PST_LIVE) - players[consoleplayer].lives -= 1; + if (modeattacking) + { + pausedelay = INT32_MIN; + M_ModeAttackRetry(0); + } + else + { + // Costs a life to retry ... unless the player in question is dead already. + if (G_GametypeUsesLives() && players[consoleplayer].playerstate == PST_LIVE && players[consoleplayer].lives != INFLIVES) + players[consoleplayer].lives -= 1; - G_DoReborn(consoleplayer); + G_DoReborn(consoleplayer); + } } for (i = 0; i < MAXPLAYERS; i++) @@ -2012,7 +2252,8 @@ void G_Ticker(boolean run) if (titledemo) F_TitleDemoTicker(); P_Ticker(run); // tic the game - ST_Ticker(); + ST_Ticker(run); + F_TextPromptTicker(); AM_Ticker(); HU_Ticker(); break; @@ -2024,6 +2265,7 @@ void G_Ticker(boolean run) break; case GS_TIMEATTACK: + F_MenuPresTicker(run); break; case GS_INTRO: @@ -2031,6 +2273,12 @@ void G_Ticker(boolean run) F_IntroTicker(); break; + case GS_ENDING: + if (run) + F_EndingTicker(); + HU_Ticker(); + break; + case GS_CUTSCENE: if (run) F_CutsceneTicker(); @@ -2045,6 +2293,7 @@ void G_Ticker(boolean run) case GS_EVALUATION: if (run) F_GameEvaluationTicker(); + HU_Ticker(); break; case GS_CONTINUING: @@ -2059,7 +2308,10 @@ void G_Ticker(boolean run) break; case GS_TITLESCREEN: + if (titlemapinaction) P_Ticker(run); // then intentionally fall through + /* FALLTHRU */ case GS_WAITINGPLAYERS: + F_MenuPresTicker(run); F_TitleScreenTicker(run); break; @@ -2070,8 +2322,13 @@ void G_Ticker(boolean run) if (run) { - if (pausedelay) - pausedelay--; + if (pausedelay && pausedelay != INT32_MIN) + { + if (pausedelay > 0) + pausedelay--; + else + pausedelay++; + } if (camtoggledelay) camtoggledelay--; @@ -2101,6 +2358,7 @@ static inline void G_PlayerFinishLevel(INT32 player) p->mo->flags2 &= ~MF2_SHADOW; // cancel invisibility P_FlashPal(p, 0, 0); // Resets + p->starpostscale = 0; p->starpostangle = 0; p->starposttime = 0; p->starpostx = 0; @@ -2116,12 +2374,14 @@ static inline void G_PlayerFinishLevel(INT32 player) // G_PlayerReborn // Called after a player dies. Almost everything is cleared and initialized. // -void G_PlayerReborn(INT32 player) +void G_PlayerReborn(INT32 player, boolean betweenmaps) { player_t *p; INT32 score; INT32 lives; INT32 continues; + fixed_t camerascale; + fixed_t shieldscale; UINT8 charability; UINT8 charability2; fixed_t normalspeed; @@ -2134,6 +2394,7 @@ void G_PlayerReborn(INT32 player) UINT32 thokitem; UINT32 spinitem; UINT32 revitem; + UINT32 followitem; fixed_t actionspd; fixed_t mindash; fixed_t maxdash; @@ -2144,7 +2405,10 @@ void G_PlayerReborn(INT32 player) INT16 starpostz; INT32 starpostnum; INT32 starpostangle; + fixed_t starpostscale; fixed_t jumpfactor; + fixed_t height; + fixed_t spinheight; INT32 exiting; INT16 numboxes; INT16 totalring; @@ -2152,10 +2416,15 @@ void G_PlayerReborn(INT32 player) UINT8 mare; UINT8 skincolor; INT32 skin; + UINT32 availabilities; tic_t jointime; + tic_t quittime; boolean spectator; + boolean outofcoop; INT16 bot; SINT8 pity; + INT16 rings; + INT16 spheres; score = players[player].score; lives = players[player].lives; @@ -2163,8 +2432,13 @@ void G_PlayerReborn(INT32 player) ctfteam = players[player].ctfteam; exiting = players[player].exiting; jointime = players[player].jointime; + quittime = players[player].quittime; spectator = players[player].spectator; - pflags = (players[player].pflags & (PF_TIMEOVER|PF_FLIPCAM|PF_TAGIT|PF_TAGGED|PF_ANALOGMODE)); + outofcoop = players[player].outofcoop; + pflags = (players[player].pflags & (PF_FLIPCAM|PF_ANALOGMODE|PF_DIRECTIONCHAR|PF_AUTOBRAKE|PF_TAGIT|PF_GAMETYPEOVER)); + + if (!betweenmaps) + pflags |= (players[player].pflags & PF_FINISHED); // As long as we're not in multiplayer, carry over cheatcodes from map to map if (!(netgame || multiplayer)) @@ -2176,6 +2450,9 @@ void G_PlayerReborn(INT32 player) skincolor = players[player].skincolor; skin = players[player].skin; + availabilities = players[player].availabilities; + camerascale = players[player].camerascale; + shieldscale = players[player].shieldscale; charability = players[player].charability; charability2 = players[player].charability2; normalspeed = players[player].normalspeed; @@ -2191,10 +2468,14 @@ void G_PlayerReborn(INT32 player) starpostz = players[player].starpostz; starpostnum = players[player].starpostnum; starpostangle = players[player].starpostangle; + starpostscale = players[player].starpostscale; jumpfactor = players[player].jumpfactor; + height = players[player].height; + spinheight = players[player].spinheight; thokitem = players[player].thokitem; spinitem = players[player].spinitem; revitem = players[player].revitem; + followitem = players[player].followitem; actionspd = players[player].actionspd; mindash = players[player].mindash; maxdash = players[player].maxdash; @@ -2203,6 +2484,17 @@ void G_PlayerReborn(INT32 player) bot = players[player].bot; pity = players[player].pity; + if (betweenmaps || !G_IsSpecialStage(gamemap)) + { + rings = (ultimatemode ? 0 : mapheaderinfo[gamemap-1]->startrings); + spheres = 0; + } + else + { + rings = players[player].rings; + spheres = players[player].spheres; + } + p = &players[player]; memset(p, 0, sizeof (*p)); @@ -2212,11 +2504,16 @@ void G_PlayerReborn(INT32 player) p->pflags = pflags; p->ctfteam = ctfteam; p->jointime = jointime; + p->quittime = quittime; p->spectator = spectator; + p->outofcoop = outofcoop; // save player config truth reborn p->skincolor = skincolor; p->skin = skin; + p->availabilities = availabilities; + p->camerascale = camerascale; + p->shieldscale = shieldscale; p->charability = charability; p->charability2 = charability2; p->normalspeed = normalspeed; @@ -2228,6 +2525,7 @@ void G_PlayerReborn(INT32 player) p->thokitem = thokitem; p->spinitem = spinitem; p->revitem = revitem; + p->followitem = followitem; p->actionspd = actionspd; p->mindash = mindash; p->maxdash = maxdash; @@ -2238,7 +2536,10 @@ void G_PlayerReborn(INT32 player) p->starpostz = starpostz; p->starpostnum = starpostnum; p->starpostangle = starpostangle; + p->starpostscale = starpostscale; p->jumpfactor = jumpfactor; + p->height = height; + p->spinheight = spinheight; p->exiting = exiting; p->numboxes = numboxes; @@ -2249,6 +2550,8 @@ void G_PlayerReborn(INT32 player) if (bot) p->bot = 1; // reset to AI-controlled p->pity = pity; + p->rings = rings; + p->spheres = spheres; // Don't do anything immediately p->pflags |= PF_USEDOWN; @@ -2256,36 +2559,10 @@ void G_PlayerReborn(INT32 player) p->pflags |= PF_JUMPDOWN; p->playerstate = PST_LIVE; - p->health = 1; // 0 rings p->panim = PA_IDLE; // standing animation - if ((netgame || multiplayer) && !p->spectator) - p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent - - if (p-players == consoleplayer) - { - if (mapmusflags & MUSIC_RELOADRESET) - { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK; - } - S_ChangeMusic(mapmusname, mapmusflags, true); - } - - if (gametype == GT_COOP) - P_FindEmerald(); // scan for emeralds to hunt for - - // Reset Nights score and max link to 0 on death - p->marescore = p->maxlink = 0; - - // If NiGHTS, find lowest mare to start with. - p->mare = P_FindLowestMare(); - - CONS_Debug(DBG_NIGHTS, M_GetText("Current mare is %d\n"), p->mare); - - if (p->mare == 255) - p->mare = 0; + //if ((netgame || multiplayer) && !p->spectator) -- moved into P_SpawnPlayer to account for forced changes there + //p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent // Check to make sure their color didn't change somehow... if (G_GametypeHasTeams()) @@ -2305,6 +2582,36 @@ void G_PlayerReborn(INT32 player) CV_SetValue(&cv_playercolor2, skincolor_blueteam); } } + + if (betweenmaps) + return; + + if (p-players == consoleplayer) + { + if (mapmusflags & MUSIC_RELOADRESET) + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; + } + + // This is in S_Start, but this was not here previously. + // if (RESETMUSIC) + // S_StopMusic(); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + } + + if (gametype == GT_COOP) + P_FindEmerald(); // scan for emeralds to hunt for + + // If NiGHTS, find lowest mare to start with. + p->mare = P_FindLowestMare(); + + CONS_Debug(DBG_NIGHTS, M_GetText("Current mare is %d\n"), p->mare); + + if (p->mare == 255) + p->mare = 0; } // @@ -2351,74 +2658,22 @@ static boolean G_CheckSpot(INT32 playernum, mapthing_t *mthing) // or a not-so-appropriate spot, if it initially fails // due to a lack of starts open or something. // -void G_SpawnPlayer(INT32 playernum, boolean starpost) +void G_SpawnPlayer(INT32 playernum) { - mapthing_t *spawnpoint; - if (!playeringame[playernum]) return; P_SpawnPlayer(playernum); - - if (starpost) //Don't even bother with looking for a place to spawn. - { - P_MovePlayerToStarpost(playernum); -#ifdef HAVE_BLUA - LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) -#endif - return; - } - - // -- CTF -- - // Order: CTF->DM->Coop - if (gametype == GT_CTF && players[playernum].ctfteam) - { - if (!(spawnpoint = G_FindCTFStart(playernum)) // find a CTF start - && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start - spawnpoint = G_FindCoopStart(playernum); // fallback - } - - // -- DM/Tag/CTF-spectator/etc -- - // Order: DM->CTF->Coop - else if (gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF - || ((gametype == GT_TAG || gametype == GT_HIDEANDSEEK) && !(players[playernum].pflags & PF_TAGIT))) - { - if (!(spawnpoint = G_FindMatchStart(playernum)) // find a DM start - && !(spawnpoint = G_FindCTFStart(playernum))) // find a CTF start - spawnpoint = G_FindCoopStart(playernum); // fallback - } - - // -- Other game modes -- - // Order: Coop->DM->CTF - else - { - if (!(spawnpoint = G_FindCoopStart(playernum)) // find a Co-op start - && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start - spawnpoint = G_FindCTFStart(playernum); // fallback - } - - //No spawns found. ANYWHERE. - if (!spawnpoint) - { - if (nummapthings) - { - if (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer)) - CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); - spawnpoint = &mapthings[0]; - } - else - { - if (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer)) - CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); - //P_MovePlayerToSpawn handles this fine if the spawnpoint is NULL. - } - } - P_MovePlayerToSpawn(playernum, spawnpoint); - -#ifdef HAVE_BLUA + G_MovePlayerToSpawnOrStarpost(playernum); LUAh_PlayerSpawn(&players[playernum]); // Lua hook for player spawning :) -#endif +} +void G_MovePlayerToSpawnOrStarpost(INT32 playernum) +{ + if (players[playernum].starposttime) + P_MovePlayerToStarpost(playernum); + else + P_MovePlayerToSpawn(playernum, G_FindMapStart(playernum)); } mapthing_t *G_FindCTFStart(INT32 playernum) @@ -2427,7 +2682,7 @@ mapthing_t *G_FindCTFStart(INT32 playernum) if (!numredctfstarts && !numbluectfstarts) //why even bother, eh? { - if (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer)) + if ((gametyperules & GTR_TEAMFLAGS) && (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer))) CONS_Alert(CONS_WARNING, M_GetText("No CTF starts in this map!\n")); return NULL; } @@ -2515,6 +2770,59 @@ mapthing_t *G_FindCoopStart(INT32 playernum) return NULL; } +mapthing_t *G_FindMapStart(INT32 playernum) +{ + mapthing_t *spawnpoint; + + if (!playeringame[playernum]) + return NULL; + + // -- CTF -- + // Order: CTF->DM->Coop + if ((gametyperules & (GTR_TEAMFLAGS|GTR_TEAMS)) && players[playernum].ctfteam) + { + if (!(spawnpoint = G_FindCTFStart(playernum)) // find a CTF start + && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start + spawnpoint = G_FindCoopStart(playernum); // fallback + } + + // -- DM/Tag/CTF-spectator/etc -- + // Order: DM->CTF->Coop + else if ((gametyperules & GTR_DEATHMATCHSTARTS) && !(players[playernum].pflags & PF_TAGIT)) + { + if (!(spawnpoint = G_FindMatchStart(playernum)) // find a DM start + && !(spawnpoint = G_FindCTFStart(playernum))) // find a CTF start + spawnpoint = G_FindCoopStart(playernum); // fallback + } + + // -- Other game modes -- + // Order: Coop->DM->CTF + else + { + if (!(spawnpoint = G_FindCoopStart(playernum)) // find a Co-op start + && !(spawnpoint = G_FindMatchStart(playernum))) // find a DM start + spawnpoint = G_FindCTFStart(playernum); // fallback + } + + //No spawns found. ANYWHERE. + if (!spawnpoint) + { + if (nummapthings) + { + if (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer)) + CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the first mapthing!\n")); + spawnpoint = &mapthings[0]; + } + else + { + if (playernum == consoleplayer || (splitscreen && playernum == secondarydisplayplayer)) + CONS_Alert(CONS_ERROR, M_GetText("No player spawns found, spawning at the origin!\n")); + } + } + + return spawnpoint; +} + // Go back through all the projectiles and remove all references to the old // player mobj, replacing them with the new one. void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo) @@ -2525,9 +2833,9 @@ void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo) I_Assert((oldmo != NULL) && (newmo != NULL)); // scan all thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -2549,7 +2857,8 @@ void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo) void G_DoReborn(INT32 playernum) { player_t *player = &players[playernum]; - boolean starpost = false; + boolean resetlevel = false; + INT32 i; if (modeattacking) { @@ -2575,34 +2884,99 @@ void G_DoReborn(INT32 playernum) B_RespawnBot(playernum); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); + + return; } - else if (countdowntimeup || (!multiplayer && gametype == GT_COOP)) + + if (countdowntimeup || (!(netgame || multiplayer) && gametype == GT_COOP)) + resetlevel = true; + else if ((G_GametypeUsesCoopLives() || G_GametypeUsesCoopStarposts()) && (netgame || multiplayer) && !G_IsSpecialStage(gamemap)) + { + boolean notgameover = true; + + if (G_GametypeUsesCoopLives() && (cv_cooplives.value != 0 && player->lives <= 0)) // consider game over first + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + if (players[i].exiting || players[i].lives > 0) + break; + } + + if (i == MAXPLAYERS) + { + notgameover = false; + if (!countdown2) + { + // They're dead, Jim. + //nextmapoverride = spstage_start; + nextmapoverride = gamemap; + countdown2 = TICRATE; + skipstats = 2; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i]) + players[i].score = 0; + } + + //emeralds = 0; + tokenbits = 0; + tokenlist = 0; + token = 0; + } + } + } + + if (G_GametypeUsesCoopStarposts() && (notgameover && cv_coopstarposts.value == 2)) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].playerstate != PST_DEAD && !players[i].spectator && players[i].mo && players[i].mo->health) + break; + } + if (i == MAXPLAYERS) + resetlevel = true; + } + } + + if (resetlevel) { // reload the level from scratch if (countdowntimeup) { - player->starpostangle = 0; - player->starposttime = 0; - player->starpostx = 0; - player->starposty = 0; - player->starpostz = 0; - player->starpostnum = 0; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + players[i].starpostscale = 0; + players[i].starpostangle = 0; + players[i].starposttime = 0; + players[i].starpostx = 0; + players[i].starposty = 0; + players[i].starpostz = 0; + players[i].starpostnum = 0; + } } if (!countdowntimeup && (mapheaderinfo[gamemap-1]->levelflags & LF_NORELOAD)) { - INT32 i; + P_RespawnThings(); - player->playerstate = PST_REBORN; - - P_LoadThingsOnly(); - - P_ClearStarPost(player->starpostnum); + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + players[i].playerstate = PST_REBORN; + P_ClearStarPost(players[i].starpostnum); + } // Do a wipe wipegamestate = -1; - - if (player->starposttime) - starpost = true; + wipestyleflags = WSF_CROSSFADE; if (camera.chase) P_ResetCamera(&players[displayplayer], &camera); @@ -2611,7 +2985,7 @@ void G_DoReborn(INT32 playernum) // clear cmd building stuff memset(gamekeydown, 0, sizeof (gamekeydown)); - for (i = 0;i < JOYAXISSET; i++) + for (i = 0; i < JOYAXISSET; i++) { joyxmove[i] = joyymove[i] = 0; joy2xmove[i] = joy2ymove[i] = 0; @@ -2623,20 +2997,35 @@ void G_DoReborn(INT32 playernum) CON_ClearHUD(); // Starpost support - G_SpawnPlayer(playernum, starpost); + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + G_SpawnPlayer(i); + } - if (botingame) - { // Bots respawn next to their master. - players[secondarydisplayplayer].playerstate = PST_REBORN; - G_SpawnPlayer(secondarydisplayplayer, false); + // restore time in netgame (see also p_setup.c) + if ((netgame || multiplayer) && G_GametypeUsesCoopStarposts() && cv_coopstarposts.value == 2) + { + // is this a hack? maybe + tic_t maxstarposttime = 0; + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && players[i].starposttime > maxstarposttime) + maxstarposttime = players[i].starposttime; + } + leveltime = maxstarposttime; } } else { -#ifdef HAVE_BLUA LUAh_MapChange(gamemap); -#endif + titlecardforreload = true; G_DoLoadLevel(true); + titlecardforreload = false; + if (metalrecording) + G_BeginMetal(); + return; } } else @@ -2644,8 +3033,11 @@ void G_DoReborn(INT32 playernum) // respawn at the start mobj_t *oldmo = NULL; - if (player->starposttime) - starpost = true; + // Not resetting map, so return to level music + if (!countdown2 + && player->lives <= 0 + && cv_cooplives.value == 1) // not allowed for life steal because no way to come back from zero group lives without addons, which should call this anyways + P_RestoreMultiMusic(player); // first dissasociate the corpse if (player->mo) @@ -2655,7 +3047,7 @@ void G_DoReborn(INT32 playernum) P_RemoveMobj(player->mo); } - G_SpawnPlayer(playernum, starpost); + G_SpawnPlayer(playernum); if (oldmo) G_ChangePlayerReferences(oldmo, players[playernum].mo); } @@ -2663,10 +3055,76 @@ void G_DoReborn(INT32 playernum) void G_AddPlayer(INT32 playernum) { + INT32 countplayers = 0, notexiting = 0; + player_t *p = &players[playernum]; - p->jointime = 0; + // Go through the current players and make sure you have the latest starpost set + if (G_PlatformGametype() && (netgame || multiplayer)) + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].bot) // ignore dumb, stupid tails + continue; + + countplayers++; + + if (!players[i].exiting) + notexiting++; + + if (!(cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (p->starpostnum < players[i].starpostnum))) + continue; + + p->starpostscale = players[i].starpostscale; + p->starposttime = players[i].starposttime; + p->starpostx = players[i].starpostx; + p->starposty = players[i].starposty; + p->starpostz = players[i].starpostz; + p->starpostangle = players[i].starpostangle; + p->starpostnum = players[i].starpostnum; + } + } + p->playerstate = PST_REBORN; + + p->height = mobjinfo[MT_PLAYER].height; + + if (G_GametypeUsesLives() || ((netgame || multiplayer) && gametype == GT_COOP)) + p->lives = cv_startinglives.value; + + if ((countplayers && !notexiting) || G_IsSpecialStage(gamemap)) + P_DoPlayerExit(p); +} + +boolean G_EnoughPlayersFinished(void) +{ + UINT8 numneeded = (G_IsSpecialStage(gamemap) ? 4 : cv_playersforexit.value); + INT32 total = 0; + INT32 exiting = 0; + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator || players[i].bot) + continue; + if (players[i].quittime > 30 * TICRATE) + continue; + if (players[i].lives <= 0) + continue; + + total++; + if ((players[i].pflags & PF_FINISHED) || players[i].exiting) + exiting++; + } + + if (exiting) + return exiting * 4 / total >= numneeded; + else + return false; } void G_ExitLevel(void) @@ -2684,12 +3142,315 @@ void G_ExitLevel(void) CV_SetValue(&cv_teamscramble, cv_scrambleonchange.value); } - if (gametype != GT_COOP) + if (!(gametyperules & GTR_CAMPAIGN)) CONS_Printf(M_GetText("The round has ended.\n")); // Remove CEcho text on round end. HU_ClearCEcho(); } + else if (gamestate == GS_ENDING) + { + F_StartCredits(); + } + else if (gamestate == GS_CREDITS) + { + F_StartGameEvaluation(); + } +} + +// See also the enum GameType in doomstat.h +const char *Gametype_Names[NUMGAMETYPES] = +{ + "Co-op", // GT_COOP + "Competition", // GT_COMPETITION + "Race", // GT_RACE + + "Match", // GT_MATCH + "Team Match", // GT_TEAMMATCH + + "Tag", // GT_TAG + "Hide & Seek", // GT_HIDEANDSEEK + + "CTF" // GT_CTF +}; + +// For dehacked +const char *Gametype_ConstantNames[NUMGAMETYPES] = +{ + "GT_COOP", // GT_COOP + "GT_COMPETITION", // GT_COMPETITION + "GT_RACE", // GT_RACE + + "GT_MATCH", // GT_MATCH + "GT_TEAMMATCH", // GT_TEAMMATCH + + "GT_TAG", // GT_TAG + "GT_HIDEANDSEEK", // GT_HIDEANDSEEK + + "GT_CTF" // GT_CTF +}; + +// Gametype rules +UINT32 gametypedefaultrules[NUMGAMETYPES] = +{ + // Co-op + GTR_CAMPAIGN|GTR_LIVES|GTR_FRIENDLY|GTR_SPAWNENEMIES|GTR_ALLOWEXIT|GTR_EMERALDHUNT|GTR_EMERALDTOKENS|GTR_SPECIALSTAGES|GTR_CUTSCENES, + // Competition + GTR_RACE|GTR_LIVES|GTR_SPAWNENEMIES|GTR_EMERALDTOKENS|GTR_SPAWNINVUL|GTR_ALLOWEXIT, + // Race + GTR_RACE|GTR_SPAWNENEMIES|GTR_SPAWNINVUL|GTR_ALLOWEXIT, + + // Match + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_POWERSTONES|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD|GTR_DEATHPENALTY, + // Team Match + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_TEAMS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD, + + // Tag + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_TAG|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_STARTCOUNTDOWN|GTR_BLINDFOLDED|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY, + // Hide and Seek + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_TAG|GTR_SPECTATORS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_STARTCOUNTDOWN|GTR_BLINDFOLDED|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY, + + // CTF + GTR_RINGSLINGER|GTR_FIRSTPERSON|GTR_SPECTATORS|GTR_TEAMS|GTR_TEAMFLAGS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME|GTR_POWERSTONES|GTR_DEATHMATCHSTARTS|GTR_SPAWNINVUL|GTR_RESPAWNDELAY|GTR_PITYSHIELD, +}; + +// +// G_SetGametype +// +// Set a new gametype, also setting gametype rules accordingly. Yay! +// +void G_SetGametype(INT16 gtype) +{ + gametype = gtype; + gametyperules = gametypedefaultrules[gametype]; +} + +// +// G_AddGametype +// +// Add a gametype. Returns the new gametype number. +// +INT16 G_AddGametype(UINT32 rules) +{ + INT16 newgtype = gametypecount; + gametypecount++; + + // Set gametype rules. + gametypedefaultrules[newgtype] = rules; + Gametype_Names[newgtype] = "???"; + + // Update gametype_cons_t accordingly. + G_UpdateGametypeSelections(); + + return newgtype; +} + +// +// G_AddGametypeConstant +// +// Self-explanatory. Filters out "bad" characters. +// +void G_AddGametypeConstant(INT16 gtype, const char *newgtconst) +{ + size_t r = 0; // read + size_t w = 0; // write + char *gtconst = Z_Calloc(strlen(newgtconst) + 4, PU_STATIC, NULL); + char *tmpconst = Z_Calloc(strlen(newgtconst) + 1, PU_STATIC, NULL); + + // Copy the gametype name. + strcpy(tmpconst, newgtconst); + + // Make uppercase. + strupr(tmpconst); + + // Prepare to write the new constant string now. + strcpy(gtconst, "GT_"); + + // Remove characters that will not be allowed in the constant string. + for (; r < strlen(tmpconst); r++) + { + boolean writechar = true; + char rc = tmpconst[r]; + switch (rc) + { + // Space, at sign and question mark + case ' ': + case '@': + case '?': + // Used for operations + case '+': + case '-': + case '*': + case '/': + case '%': + case '^': + case '&': + case '!': + // Part of Lua's syntax + case '#': + case '=': + case '~': + case '<': + case '>': + case '(': + case ')': + case '{': + case '}': + case '[': + case ']': + case ':': + case ';': + case ',': + case '.': + writechar = false; + break; + } + if (writechar) + { + gtconst[3 + w] = rc; + w++; + } + } + + // Free the temporary string. + Z_Free(tmpconst); + + // Finally, set the constant string. + Gametype_ConstantNames[gtype] = gtconst; +} + +// +// G_UpdateGametypeSelections +// +// Updates gametype_cons_t. +// +void G_UpdateGametypeSelections(void) +{ + INT32 i; + for (i = 0; i < gametypecount; i++) + { + gametype_cons_t[i].value = i; + gametype_cons_t[i].strvalue = Gametype_Names[i]; + } + gametype_cons_t[NUMGAMETYPES].value = 0; + gametype_cons_t[NUMGAMETYPES].strvalue = NULL; +} + +// +// G_SetGametypeDescription +// +// Set a description for the specified gametype. +// (Level platter) +// +void G_SetGametypeDescription(INT16 gtype, char *descriptiontext, UINT8 leftcolor, UINT8 rightcolor) +{ + if (descriptiontext != NULL) + strncpy(gametypedesc[gtype].notes, descriptiontext, 441); + gametypedesc[gtype].col[0] = leftcolor; + gametypedesc[gtype].col[1] = rightcolor; +} + +// Gametype rankings +INT16 gametyperankings[NUMGAMETYPES] = +{ + GT_COOP, + GT_COMPETITION, + GT_RACE, + + GT_MATCH, + GT_TEAMMATCH, + + GT_TAG, + GT_HIDEANDSEEK, + + GT_CTF, +}; + +// Gametype to TOL (Type Of Level) +UINT32 gametypetol[NUMGAMETYPES] = +{ + TOL_COOP, // Co-op + TOL_COMPETITION, // Competition + TOL_RACE, // Race + + TOL_MATCH, // Match + TOL_MATCH, // Team Match + + TOL_TAG, // Tag + TOL_TAG, // Hide and Seek + + TOL_CTF, // CTF +}; + +tolinfo_t TYPEOFLEVEL[NUMTOLNAMES] = { + {"SOLO",TOL_SP}, + {"SP",TOL_SP}, + {"SINGLEPLAYER",TOL_SP}, + {"SINGLE",TOL_SP}, + + {"COOP",TOL_COOP}, + {"CO-OP",TOL_COOP}, + + {"COMPETITION",TOL_COMPETITION}, + {"RACE",TOL_RACE}, + + {"MATCH",TOL_MATCH}, + {"TAG",TOL_TAG}, + {"CTF",TOL_CTF}, + + {"2D",TOL_2D}, + {"MARIO",TOL_MARIO}, + {"NIGHTS",TOL_NIGHTS}, + {"OLDBRAK",TOL_ERZ3}, + + {"XMAS",TOL_XMAS}, + {"CHRISTMAS",TOL_XMAS}, + {"WINTER",TOL_XMAS}, + + {NULL, 0} +}; + +UINT32 lastcustomtol = (TOL_XMAS<<1); + +// +// G_AddTOL +// +// Adds a type of level. +// +void G_AddTOL(UINT32 newtol, const char *tolname) +{ + INT32 i; + for (i = 0; TYPEOFLEVEL[i].name; i++) + ; + + TYPEOFLEVEL[i].name = Z_StrDup(tolname); + TYPEOFLEVEL[i].flag = newtol; +} + +// +// G_AddGametypeTOL +// +// Assigns a type of level to a gametype. +// +void G_AddGametypeTOL(INT16 gtype, UINT32 newtol) +{ + gametypetol[gtype] = newtol; +} + +// +// G_GetGametypeByName +// +// Returns the number for the given gametype name string, or -1 if not valid. +// +INT32 G_GetGametypeByName(const char *gametypestr) +{ + INT32 i; + + for (i = 0; i < gametypecount; i++) + if (!stricmp(gametypestr, Gametype_Names[i])) + return i; + + return -1; // unknown gametype } // @@ -2700,7 +3461,11 @@ void G_ExitLevel(void) // boolean G_IsSpecialStage(INT32 mapnum) { - if (gametype == GT_COOP && modeattacking != ATTACKING_RECORD && mapnum >= sstage_start && mapnum <= sstage_end) + if (gametype != GT_COOP || modeattacking == ATTACKING_RECORD) + return false; + if (mapnum >= sstage_start && mapnum <= sstage_end) + return true; + if (mapnum >= smpstage_start && mapnum <= smpstage_end) return true; return false; @@ -2714,15 +3479,37 @@ boolean G_IsSpecialStage(INT32 mapnum) // boolean G_GametypeUsesLives(void) { - // Coop, Competitive - if ((gametype == GT_COOP || gametype == GT_COMPETITION) - && !modeattacking // No lives in Time Attack - //&& !G_IsSpecialStage(gamemap) + // Coop, Competitive + if ((gametyperules & GTR_LIVES) + && !(modeattacking || metalrecording) // No lives in Time Attack + && !G_IsSpecialStage(gamemap) && !(maptol & TOL_NIGHTS)) // No lives in NiGHTS return true; return false; } +// +// G_GametypeUsesCoopLives +// +// Returns true if the current gametype uses +// the cooplives CVAR. False otherwise. +// +boolean G_GametypeUsesCoopLives(void) +{ + return (gametyperules & (GTR_LIVES|GTR_FRIENDLY)) == (GTR_LIVES|GTR_FRIENDLY); +} + +// +// G_GametypeUsesCoopStarposts +// +// Returns true if the current gametype uses +// the coopstarposts CVAR. False otherwise. +// +boolean G_GametypeUsesCoopStarposts(void) +{ + return (gametyperules & GTR_FRIENDLY); +} + // // G_GametypeHasTeams // @@ -2731,7 +3518,7 @@ boolean G_GametypeUsesLives(void) // boolean G_GametypeHasTeams(void) { - return (gametype == GT_TEAMMATCH || gametype == GT_CTF); + return (gametyperules & GTR_TEAMS); } // @@ -2742,7 +3529,7 @@ boolean G_GametypeHasTeams(void) // boolean G_GametypeHasSpectators(void) { - return (gametype != GT_COOP && gametype != GT_COMPETITION && gametype != GT_RACE); + return (gametyperules & GTR_SPECTATORS); } // @@ -2753,7 +3540,7 @@ boolean G_GametypeHasSpectators(void) // boolean G_RingSlingerGametype(void) { - return ((gametype != GT_COOP && gametype != GT_COMPETITION && gametype != GT_RACE) || (cv_ringslinger.value)); + return ((gametyperules & GTR_RINGSLINGER) || (cv_ringslinger.value)); } // @@ -2763,7 +3550,7 @@ boolean G_RingSlingerGametype(void) // boolean G_PlatformGametype(void) { - return (gametype == GT_COOP || gametype == GT_RACE || gametype == GT_COMPETITION); + return (!(gametyperules & GTR_RINGSLINGER)); } // @@ -2773,7 +3560,17 @@ boolean G_PlatformGametype(void) // boolean G_TagGametype(void) { - return (gametype == GT_TAG || gametype == GT_HIDEANDSEEK); + return (gametyperules & GTR_TAG); +} + +// +// G_CompetitionGametype +// +// For gametypes that are race gametypes, and have lives. +// +boolean G_CompetitionGametype(void) +{ + return ((gametyperules & GTR_RACE) && (gametyperules & GTR_LIVES)); } /** Get the typeoflevel flag needed to indicate support of a gametype. @@ -2782,20 +3579,11 @@ boolean G_TagGametype(void) * \return The typeoflevel flag to check for that gametype. * \author Graue */ -INT16 G_TOLFlag(INT32 pgametype) +UINT32 G_TOLFlag(INT32 pgametype) { - if (!multiplayer) return TOL_SP; - if (pgametype == GT_COOP) return TOL_COOP; - if (pgametype == GT_COMPETITION) return TOL_COMPETITION; - if (pgametype == GT_RACE) return TOL_RACE; - if (pgametype == GT_MATCH) return TOL_MATCH; - if (pgametype == GT_TEAMMATCH) return TOL_MATCH; - if (pgametype == GT_TAG) return TOL_TAG; - if (pgametype == GT_HIDEANDSEEK) return TOL_TAG; - if (pgametype == GT_CTF) return TOL_CTF; - - CONS_Alert(CONS_ERROR, M_GetText("Unknown gametype! %d\n"), pgametype); - return INT16_MAX; + if (!multiplayer) + return TOL_SP; + return gametypetol[pgametype]; } /** Select a random map with the given typeoflevel flags. @@ -2806,7 +3594,7 @@ INT16 G_TOLFlag(INT32 pgametype) * has those flags. * \author Graue */ -static INT16 RandMap(INT16 tolflags, INT16 pprevmap) +static INT16 RandMap(UINT32 tolflags, INT16 pprevmap) { INT16 *okmaps = Z_Malloc(NUMMAPS * sizeof(INT16), PU_STATIC, NULL); INT32 numokmaps = 0; @@ -2830,22 +3618,67 @@ static INT16 RandMap(INT16 tolflags, INT16 pprevmap) return ix; } +// +// G_UpdateVisited +// +static void G_UpdateVisited(void) +{ + boolean spec = G_IsSpecialStage(gamemap); + // Update visitation flags? + if ((!modifiedgame || savemoddata) // Not modified + && !multiplayer && !demoplayback && (gametype == GT_COOP) // SP/RA/NiGHTS mode + && !(spec && stagefailed)) // Not failed the special stage + { + UINT8 earnedEmblems; + + // Update visitation flags + mapvisited[gamemap-1] |= MV_BEATEN; + // eh, what the hell + if (ultimatemode) + mapvisited[gamemap-1] |= MV_ULTIMATE; + // may seem incorrect but IS possible in what the main game uses as mp special stages, and nummaprings will be -1 in NiGHTS + if (nummaprings > 0 && players[consoleplayer].rings >= nummaprings) + { + mapvisited[gamemap-1] |= MV_PERFECT; + if (modeattacking) + mapvisited[gamemap-1] |= MV_PERFECTRA; + } + if (!spec) + { + // not available to special stages because they can only really be done in one order in an unmodified game, so impossible for first six and trivial for seventh + if (ALL7EMERALDS(emeralds)) + mapvisited[gamemap-1] |= MV_ALLEMERALDS; + } + + if (modeattacking == ATTACKING_RECORD) + G_UpdateRecordReplays(); + else if (modeattacking == ATTACKING_NIGHTS) + G_SetNightsRecords(); + + if ((earnedEmblems = M_CompletionEmblems())) + CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); + } +} + // // G_DoCompleted // static void G_DoCompleted(void) { INT32 i; - boolean gottoken = false; + boolean spec = G_IsSpecialStage(gamemap); tokenlist = 0; // Reset the list + if (modeattacking && pausedelay) + pausedelay = 0; + gameaction = ga_nothing; if (metalplayback) G_StopMetalDemo(); if (metalrecording) - G_StopMetalRecording(); + G_StopMetalRecording(false); for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) @@ -2866,18 +3699,18 @@ static void G_DoCompleted(void) nextmap = (INT16)(mapheaderinfo[gamemap-1]->nextlevel-1); // Remember last map for when you come out of the special stage. - if (!G_IsSpecialStage(gamemap)) + if (!spec) lastmap = nextmap; // If nextmap is actually going to get used, make sure it points to // a map of the proper gametype -- skip levels that don't support // the current gametype. (Helps avoid playing boss levels in Race, // for instance). - if (!token && !G_IsSpecialStage(gamemap) + if (!token && !spec && (nextmap >= 0 && nextmap < NUMMAPS)) { register INT16 cm = nextmap; - INT16 tolflag = G_TOLFlag(gametype); + UINT32 tolflag = G_TOLFlag(gametype); UINT8 visitedmap[(NUMMAPS+7)/8]; memset(visitedmap, 0, sizeof (visitedmap)); @@ -2915,42 +3748,37 @@ static void G_DoCompleted(void) nextmap = cm; } - if (nextmap < 0 || (nextmap >= NUMMAPS && nextmap < 1100-1) || nextmap > 1102-1) + if (nextmap < 0 || (nextmap >= NUMMAPS && nextmap < 1100-1) || nextmap > 1103-1) I_Error("Followed map %d to invalid map %d\n", prevmap + 1, nextmap + 1); // wrap around in race - if (nextmap >= 1100-1 && nextmap <= 1102-1 && (gametype == GT_RACE || gametype == GT_COMPETITION)) + if (nextmap >= 1100-1 && nextmap <= 1102-1 && !(gametyperules & GTR_CAMPAIGN)) nextmap = (INT16)(spstage_start-1); - if (gametype == GT_COOP && token) + if ((gottoken = ((gametyperules & GTR_SPECIALSTAGES) && token))) { token--; - gottoken = true; - if (!(emeralds & EMERALD1)) - nextmap = (INT16)(sstage_start - 1); // Special Stage 1 - else if (!(emeralds & EMERALD2)) - nextmap = (INT16)(sstage_start); // Special Stage 2 - else if (!(emeralds & EMERALD3)) - nextmap = (INT16)(sstage_start + 1); // Special Stage 3 - else if (!(emeralds & EMERALD4)) - nextmap = (INT16)(sstage_start + 2); // Special Stage 4 - else if (!(emeralds & EMERALD5)) - nextmap = (INT16)(sstage_start + 3); // Special Stage 5 - else if (!(emeralds & EMERALD6)) - nextmap = (INT16)(sstage_start + 4); // Special Stage 6 - else if (!(emeralds & EMERALD7)) - nextmap = (INT16)(sstage_start + 5); // Special Stage 7 - else + for (i = 0; i < 7; i++) + if (!(emeralds & (1<cutscenenum && !modeattacking) // Start a custom cutscene. + if ((gametyperules & GTR_CUTSCENES) && mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking && skipstats <= 1) // Start a custom cutscene. F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false); else { @@ -3062,8 +3902,11 @@ static void G_DoContinued(void) tokenlist = 0; token = 0; + if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking) && (!modifiedgame || savemoddata) && cursaveslot > 0) + G_SaveGameOver((UINT32)cursaveslot, true); + // Reset # of lives - pl->lives = (ultimatemode) ? 1 : 3; + pl->lives = (ultimatemode) ? 1 : startinglivesbalance[numgameovers]; D_MapChange(gamemap, gametype, ultimatemode, false, 0, false, false); @@ -3084,8 +3927,13 @@ static void G_DoContinued(void) void G_EndGame(void) { // Only do evaluation and credits in coop games. - if (gametype == GT_COOP) + if (gametyperules & GTR_CUTSCENES) { + if (nextmap == 1103-1) // end game with ending + { + F_StartEnding(); + return; + } if (nextmap == 1102-1) // end game with credits { F_StartCredits(); @@ -3111,8 +3959,10 @@ void G_LoadGameSettings(void) // defaults spstage_start = 1; sstage_start = 50; - sstage_end = 57; // 8 special stages in vanilla SRB2 - useNightsSS = false; //true; + sstage_end = 56; // 7 special stages in vanilla SRB2 + sstage_end++; // plus one weirdo + smpstage_start = 60; + smpstage_end = 66; // 7 multiplayer special stages too // initialize free sfx slots for skin sounds S_InitRuntimeSounds(); @@ -3147,6 +3997,11 @@ void G_LoadGameData(void) // Allow saving of gamedata beyond this point gamedataloaded = true; + if (M_CheckParm("-gamedata") && M_IsNextParm()) + { + strlcpy(gamedatafilename, M_GetNextParm(), sizeof gamedatafilename); + } + if (M_CheckParm("-resetdata")) return; // Don't load (essentially, reset). @@ -3223,6 +4078,7 @@ void G_LoadGameData(void) recscore = READUINT32(save_p); rectime = (tic_t)READUINT32(save_p); recrings = READUINT16(save_p); + save_p++; // compat if (recrings > 10000 || recscore > MAXSCORE) goto datacorrupt; @@ -3317,7 +4173,7 @@ void G_SaveGameData(void) // TODO put another cipher on these things? meh, I don't care... for (i = 0; i < NUMMAPS; i++) - WRITEUINT8(save_p, mapvisited[i]); + WRITEUINT8(save_p, (mapvisited[i] & MV_MAX)); // To save space, use one bit per collected/achieved/unlocked flag for (i = 0; i < MAXEMBLEMS;) @@ -3372,6 +4228,7 @@ void G_SaveGameData(void) WRITEUINT32(save_p, 0); WRITEUINT16(save_p, 0); } + WRITEUINT8(save_p, 0); // compat } // NiGHTS records @@ -3402,59 +4259,6 @@ void G_SaveGameData(void) #define VERSIONSIZE 16 -#ifdef SAVEGAMES_OTHERVERSIONS -static INT16 startonmapnum = 0; - -// -// User wants to load a savegame from a different version? -// -static void M_ForceLoadGameResponse(INT32 ch) -{ - if (ch != 'y' && ch != KEY_ENTER) - { - //refused - Z_Free(savebuffer); - save_p = savebuffer = NULL; - startonmapnum = 0; - M_SetupNextMenu(&SP_LoadDef); - return; - } - - // pick up where we left off. - save_p += VERSIONSIZE; - if (!P_LoadGame(startonmapnum)) - { - M_ClearMenus(true); // so ESC backs out to title - M_StartMessage(M_GetText("Savegame file corrupted\n\nPress ESC\n"), NULL, MM_NOTHING); - Command_ExitGame_f(); - Z_Free(savebuffer); - save_p = savebuffer = NULL; - startonmapnum = 0; - - // no cheating! - memset(&savedata, 0, sizeof(savedata)); - return; - } - - // done - Z_Free(savebuffer); - save_p = savebuffer = NULL; - startonmapnum = 0; - - //set cursaveslot to -1 so nothing gets saved. - cursaveslot = -1; - - displayplayer = consoleplayer; - multiplayer = splitscreen = false; - - if (setsizeneeded) - R_ExecuteSetViewSize(); - - M_ClearMenus(true); - CON_ToggleOff(); -} -#endif - // // G_InitFromSavegame // Can be called by the startup code or the menu task. @@ -3547,17 +4351,17 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride) // G_SaveGame // Saves your game. // -void G_SaveGame(UINT32 savegameslot) +void G_SaveGame(UINT32 slot) { boolean saved; char savename[256] = ""; const char *backup; - sprintf(savename, savegamename, savegameslot); + sprintf(savename, savegamename, slot); backup = va("%s",savename); // save during evaluation or credits? game's over, folks! - if (gamestate == GS_CREDITS || gamestate == GS_EVALUATION) + if (gamestate == GS_ENDING || gamestate == GS_CREDITS || gamestate == GS_EVALUATION) gamecomplete = true; gameaction = ga_nothing; @@ -3589,9 +4393,113 @@ void G_SaveGame(UINT32 savegameslot) if (cv_debug && saved) CONS_Printf(M_GetText("Game saved.\n")); else if (!saved) - CONS_Alert(CONS_ERROR, M_GetText("Error while writing to %s for save slot %u, base: %s\n"), backup, savegameslot, savegamename); + CONS_Alert(CONS_ERROR, M_GetText("Error while writing to %s for save slot %u, base: %s\n"), backup, slot, savegamename); } +#define BADSAVE goto cleanup; +#define CHECKPOS if (save_p >= end_p) BADSAVE +void G_SaveGameOver(UINT32 slot, boolean modifylives) +{ + boolean saved = false; + size_t length; + char vcheck[VERSIONSIZE]; + char savename[255]; + const char *backup; + + sprintf(savename, savegamename, slot); + backup = va("%s",savename); + + length = FIL_ReadFile(savename, &savebuffer); + if (!length) + { + CONS_Printf(M_GetText("Couldn't read file %s\n"), savename); + return; + } + + { + char temp[sizeof(timeattackfolder)]; + UINT8 *end_p = savebuffer + length; + UINT8 *lives_p; + SINT8 pllives; + + save_p = savebuffer; + // Version check + memset(vcheck, 0, sizeof (vcheck)); + sprintf(vcheck, "version %d", VERSION); + if (strcmp((const char *)save_p, (const char *)vcheck)) BADSAVE + save_p += VERSIONSIZE; + + // P_UnArchiveMisc() + (void)READINT16(save_p); + CHECKPOS + (void)READUINT16(save_p); // emeralds + CHECKPOS + READSTRINGN(save_p, temp, sizeof(temp)); // mod it belongs to + if (strcmp(temp, timeattackfolder)) BADSAVE + + // P_UnArchivePlayer() + CHECKPOS + (void)READUINT16(save_p); + CHECKPOS + + WRITEUINT8(save_p, numgameovers); + CHECKPOS + + lives_p = save_p; + pllives = READSINT8(save_p); // lives + CHECKPOS + if (modifylives && pllives < startinglivesbalance[numgameovers]) + { + pllives = startinglivesbalance[numgameovers]; + WRITESINT8(lives_p, pllives); + } + + (void)READINT32(save_p); // Score + CHECKPOS + (void)READINT32(save_p); // continues + + // File end marker check + CHECKPOS + switch (READUINT8(save_p)) + { + case 0xb7: + { + UINT8 i, banksinuse; + CHECKPOS + banksinuse = READUINT8(save_p); + CHECKPOS + if (banksinuse > NUM_LUABANKS) + BADSAVE + for (i = 0; i < banksinuse; i++) + { + (void)READINT32(save_p); + CHECKPOS + } + if (READUINT8(save_p) != 0x1d) + BADSAVE + } + case 0x1d: + break; + default: + BADSAVE + } + + // done + saved = FIL_WriteFile(backup, savebuffer, length); + } + +cleanup: + if (cv_debug && saved) + CONS_Printf(M_GetText("Game saved.\n")); + else if (!saved) + CONS_Alert(CONS_ERROR, M_GetText("Error while writing to %s for save slot %u, base: %s\n"), backup, slot, savegamename); + Z_Free(savebuffer); + save_p = savebuffer = NULL; + +} +#undef CHECKPOS +#undef BADSAVE + // // G_DeferedInitNew // Can be called by the startup code or the menu task, @@ -3599,7 +4507,7 @@ void G_SaveGame(UINT32 savegameslot) // void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, boolean SSSG, boolean FLS) { - UINT8 color = 0; + UINT8 color = skins[pickedchar].prefcolor; paused = false; if (demoplayback) @@ -3611,10 +4519,8 @@ void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, b if (savedata.lives > 0) { - color = savedata.skincolor; - botskin = savedata.botskin; - botcolor = savedata.botcolor; - botingame = (botskin != 0); + if ((botingame = ((botskin = savedata.botskin) != 0))) + botcolor = skins[botskin-1].prefcolor; } else if (splitscreen != SSSG) { @@ -3622,8 +4528,7 @@ void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, b SplitScreen_OnChange(); } - if (!color) - color = skins[pickedchar].prefcolor; + color = skins[pickedchar].prefcolor; SetPlayerSkinByNum(consoleplayer, pickedchar); CV_StealthSet(&cv_skin, skins[pickedchar].name); CV_StealthSetValue(&cv_playercolor, color); @@ -3636,10 +4541,12 @@ void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, b // This is the map command interpretation something like Command_Map_f // // called at: map cmd execution, doloadgame, doplaydemo -void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean skipprecutscene) +void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean skipprecutscene, boolean FLS) { INT32 i; + Y_CleanupScreenBuffer(); + if (paused) { paused = false; @@ -3647,7 +4554,7 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean } if (netgame || multiplayer) // Nice try, haxor. - ultimatemode = false; + pultmode = false; if (!demoplayback && !netgame) // Netgame sets random seed elsewhere, demo playback sets seed just before us! P_SetRandSeed(M_RandomizedSeed()); // Use a more "Random" random seed @@ -3655,38 +4562,37 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean if (resetplayer) { // Clear a bunch of variables - tokenlist = token = sstimer = redscore = bluescore = lastmap = 0; - countdown = countdown2 = 0; + numgameovers = tokenlist = token = sstimer = redscore = bluescore = lastmap = 0; + countdown = countdown2 = exitfadestarted = 0; for (i = 0; i < MAXPLAYERS; i++) { players[i].playerstate = PST_REBORN; - players[i].starpostangle = players[i].starpostnum = players[i].starposttime = 0; + players[i].starpostscale = players[i].starpostangle = players[i].starpostnum = players[i].starposttime = 0; players[i].starpostx = players[i].starposty = players[i].starpostz = 0; if (netgame || multiplayer) { - players[i].lives = cv_startinglives.value; - players[i].continues = 0; - } - else if (pultmode) - { - players[i].lives = 1; + if (!FLS || (players[i].lives < 1)) + players[i].lives = cv_startinglives.value; players[i].continues = 0; } else { - players[i].lives = 3; - players[i].continues = 1; + players[i].lives = (pultmode) ? 1 : startinglivesbalance[0]; + players[i].continues = (pultmode) ? 0 : 1; } + if (!((netgame || multiplayer) && (FLS))) + players[i].score = 0; + // The latter two should clear by themselves, but just in case - players[i].pflags &= ~(PF_TAGIT|PF_TAGGED|PF_FULLSTASIS); + players[i].pflags &= ~(PF_TAGIT|PF_GAMETYPEOVER|PF_FULLSTASIS); // Clear cheatcodes too, just in case. players[i].pflags &= ~(PF_GODMODE|PF_NOCLIP|PF_INVIS); - players[i].score = players[i].xtralife = 0; + players[i].xtralife = 0; } // Reset unlockable triggers @@ -3724,7 +4630,7 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean automapactive = false; imcontinuing = false; - if (!skipprecutscene && mapheaderinfo[gamemap-1]->precutscenenum && !modeattacking) // Start a custom cutscene. + if ((gametyperules & GTR_CUTSCENES) && !skipprecutscene && mapheaderinfo[gamemap-1]->precutscenenum && !modeattacking) // Start a custom cutscene. F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer); else G_DoLoadLevel(resetplayer); @@ -3748,6 +4654,9 @@ char *G_BuildMapTitle(INT32 mapnum) { char *title = NULL; + if (!mapheaderinfo[mapnum-1]) + P_AllocMapHeader(mapnum-1); + if (strcmp(mapheaderinfo[mapnum-1]->lvlttl, "")) { size_t len = 1; @@ -3757,7 +4666,7 @@ char *G_BuildMapTitle(INT32 mapnum) len += strlen(mapheaderinfo[mapnum-1]->lvlttl); if (!(mapheaderinfo[mapnum-1]->levelflags & LF_NOZONE)) { - zonetext = M_GetText("ZONE"); + zonetext = M_GetText("Zone"); len += strlen(zonetext) + 1; // ' ' + zonetext } if (actnum > 0) @@ -3773,11 +4682,250 @@ char *G_BuildMapTitle(INT32 mapnum) return title; } +static void measurekeywords(mapsearchfreq_t *fr, + struct searchdim **dimp, UINT8 *cuntp, + const char *s, const char *q, boolean wanttable) +{ + char *qp; + char *sp; + if (wanttable) + (*dimp) = Z_Realloc((*dimp), 255 * sizeof (struct searchdim), + PU_STATIC, NULL); + for (qp = strtok(va("%s", q), " "); + qp && fr->total < 255; + qp = strtok(0, " ")) + { + if (( sp = strcasestr(s, qp) )) + { + if (wanttable) + { + (*dimp)[(*cuntp)].pos = sp - s; + (*dimp)[(*cuntp)].siz = strlen(qp); + } + (*cuntp)++; + fr->total++; + } + } + if (wanttable) + (*dimp) = Z_Realloc((*dimp), (*cuntp) * sizeof (struct searchdim), + PU_STATIC, NULL); +} + +static void writesimplefreq(mapsearchfreq_t *fr, INT32 *frc, + INT32 mapnum, UINT8 pos, UINT8 siz) +{ + fr[(*frc)].mapnum = mapnum; + fr[(*frc)].matchd = ZZ_Alloc(sizeof (struct searchdim)); + fr[(*frc)].matchd[0].pos = pos; + fr[(*frc)].matchd[0].siz = siz; + fr[(*frc)].matchc = 1; + fr[(*frc)].total = 1; + (*frc)++; +} + +INT32 G_FindMap(const char *mapname, char **foundmapnamep, + mapsearchfreq_t **freqp, INT32 *freqcp) +{ + INT32 newmapnum = 0; + INT32 mapnum; + INT32 apromapnum = 0; + + size_t mapnamelen; + char *realmapname = NULL; + char *newmapname = NULL; + char *apromapname = NULL; + char *aprop = NULL; + + mapsearchfreq_t *freq; + boolean wanttable; + INT32 freqc; + UINT8 frequ; + + INT32 i; + + mapnamelen = strlen(mapname); + + /* Count available maps; how ugly. */ + for (i = 0, freqc = 0; i < NUMMAPS; ++i) + { + if (mapheaderinfo[i]) + freqc++; + } + + freq = ZZ_Calloc(freqc * sizeof (mapsearchfreq_t)); + + wanttable = !!( freqp ); + + freqc = 0; + for (i = 0, mapnum = 1; i < NUMMAPS; ++i, ++mapnum) + if (mapheaderinfo[i]) + { + if (!( realmapname = G_BuildMapTitle(mapnum) )) + continue; + + aprop = realmapname; + + /* Now that we found a perfect match no need to fucking guess. */ + if (strnicmp(realmapname, mapname, mapnamelen) == 0) + { + if (wanttable) + { + writesimplefreq(freq, &freqc, mapnum, 0, mapnamelen); + } + if (newmapnum == 0) + { + newmapnum = mapnum; + newmapname = realmapname; + realmapname = 0; + Z_Free(apromapname); + if (!wanttable) + break; + } + } + else + if (apromapnum == 0 || wanttable) + { + /* LEVEL 1--match keywords verbatim */ + if (( aprop = strcasestr(realmapname, mapname) )) + { + if (wanttable) + { + writesimplefreq(freq, &freqc, + mapnum, aprop - realmapname, mapnamelen); + } + if (apromapnum == 0) + { + apromapnum = mapnum; + apromapname = realmapname; + realmapname = 0; + } + } + else/* ...match individual keywords */ + { + freq[freqc].mapnum = mapnum; + measurekeywords(&freq[freqc], + &freq[freqc].matchd, &freq[freqc].matchc, + realmapname, mapname, wanttable); + measurekeywords(&freq[freqc], + &freq[freqc].keywhd, &freq[freqc].keywhc, + mapheaderinfo[i]->keywords, mapname, wanttable); + if (freq[freqc].total) + freqc++; + } + } + + Z_Free(realmapname);/* leftover old name */ + } + + if (newmapnum == 0)/* no perfect match--try a substring */ + { + newmapnum = apromapnum; + newmapname = apromapname; + } + + if (newmapnum == 0)/* calculate most queries met! */ + { + frequ = 0; + for (i = 0; i < freqc; ++i) + { + if (freq[i].total > frequ) + { + frequ = freq[i].total; + newmapnum = freq[i].mapnum; + } + } + if (newmapnum) + { + newmapname = G_BuildMapTitle(newmapnum); + } + } + + if (freqp) + (*freqp) = freq; + else + Z_Free(freq); + + if (freqcp) + (*freqcp) = freqc; + + if (foundmapnamep) + (*foundmapnamep) = newmapname; + else + Z_Free(newmapname); + + return newmapnum; +} + +void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc) +{ + INT32 i; + for (i = 0; i < freqc; ++i) + { + Z_Free(freq[i].matchd); + } + Z_Free(freq); +} + +INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep) +{ + boolean usemapcode = false; + + INT32 newmapnum; + + size_t mapnamelen; + + char *p; + + mapnamelen = strlen(mapname); + + if (mapnamelen == 2)/* maybe two digit code */ + { + if (( newmapnum = M_MapNumber(mapname[0], mapname[1]) )) + usemapcode = true; + } + else if (mapnamelen == 5 && strnicmp(mapname, "MAP", 3) == 0) + { + if (( newmapnum = M_MapNumber(mapname[3], mapname[4]) )) + usemapcode = true; + } + + if (!usemapcode) + { + /* Now detect map number in base 10, which no one asked for. */ + newmapnum = strtol(mapname, &p, 10); + if (*p == '\0')/* we got it */ + { + if (newmapnum < 1 || newmapnum > NUMMAPS) + { + CONS_Alert(CONS_ERROR, M_GetText("Invalid map number %d.\n"), newmapnum); + return 0; + } + usemapcode = true; + } + else + { + newmapnum = G_FindMap(mapname, realmapnamep, NULL, NULL); + } + } + + if (usemapcode) + { + /* we can't check mapheaderinfo for this hahahaha */ + if (W_CheckNumForName(G_BuildMapName(newmapnum)) == LUMPERROR) + return 0; + + if (realmapnamep) + (*realmapnamep) = G_BuildMapTitle(newmapnum); + } + + return newmapnum; +} + // // DEMO RECORDING // -#define DEMOVERSION 0x0009 +#define DEMOVERSION 0x000c #define DEMOHEADER "\xF0" "SRB2Replay" "\x0F" #define DF_GHOST 0x01 // This demo contains ghost data too! @@ -3793,6 +4941,8 @@ char *G_BuildMapTitle(INT32 mapnum) #define ZT_BUTTONS 0x08 #define ZT_AIMING 0x10 #define DEMOMARKER 0x80 // demoend +#define METALDEATH 0x44 +#define METALSNICE 0x69 static ticcmd_t oldcmd; @@ -3801,10 +4951,10 @@ static ticcmd_t oldcmd; #define GZT_MOMXY 0x02 #define GZT_MOMZ 0x04 #define GZT_ANGLE 0x08 -// Not used for Metal Sonic -#define GZT_SPRITE 0x10 // Animation frame -#define GZT_EXTRA 0x20 -#define GZT_NIGHTS 0x40 // NiGHTS Mode stuff! +#define GZT_FRAME 0x10 // Animation frame +#define GZT_SPR2 0x20 // Player animations +#define GZT_EXTRA 0x40 +#define GZT_FOLLOW 0x80 // Followmobj // GZT_EXTRA flags #define EZT_THOK 0x01 // Spawned a thok object @@ -3816,6 +4966,15 @@ static ticcmd_t oldcmd; #define EZT_SCALE 0x10 // Changed size #define EZT_HIT 0x20 // Damaged a mobj #define EZT_SPRITE 0x40 // Changed sprite set completely out of PLAY (NiGHTS, SOCs, whatever) +#define EZT_HEIGHT 0x80 // Changed height + +// GZT_FOLLOW flags +#define FZT_SPAWNED 0x01 // just been spawned +#define FZT_SKIN 0x02 // has skin +#define FZT_LINKDRAW 0x04 // has linkdraw (combine with spawned only) +#define FZT_COLORIZED 0x08 // colorized (ditto) +#define FZT_SCALE 0x10 // different scale to object +// spare FZT slots 0x20 to 0x80 static mobj_t oldmetal, oldghost; @@ -3941,28 +5100,28 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) void G_GhostAddThok(void) { - if (!demorecording || !(demoflags & DF_GHOST)) + if (!metalrecording && (!demorecording || !(demoflags & DF_GHOST))) return; ghostext.flags = (ghostext.flags & ~EZT_THOKMASK) | EZT_THOK; } void G_GhostAddSpin(void) { - if (!demorecording || !(demoflags & DF_GHOST)) + if (!metalrecording && (!demorecording || !(demoflags & DF_GHOST))) return; ghostext.flags = (ghostext.flags & ~EZT_THOKMASK) | EZT_SPIN; } void G_GhostAddRev(void) { - if (!demorecording || !(demoflags & DF_GHOST)) + if (!metalrecording && (!demorecording || !(demoflags & DF_GHOST))) return; ghostext.flags = (ghostext.flags & ~EZT_THOKMASK) | EZT_REV; } void G_GhostAddFlip(void) { - if (!demorecording || !(demoflags & DF_GHOST)) + if (!metalrecording && (!demorecording || !(demoflags & DF_GHOST))) return; ghostext.flags |= EZT_FLIP; } @@ -3982,7 +5141,7 @@ void G_GhostAddColor(ghostcolor_t color) void G_GhostAddScale(fixed_t scale) { - if (!demorecording || !(demoflags & DF_GHOST)) + if (!metalrecording && (!demorecording || !(demoflags & DF_GHOST))) return; if (ghostext.lastscale == scale) { @@ -4008,21 +5167,13 @@ void G_WriteGhostTic(mobj_t *ghost) char ziptic = 0; UINT8 *ziptic_p; UINT32 i; - UINT8 sprite; - UINT8 frame; + fixed_t height; if (!demo_p) return; if (!(demoflags & DF_GHOST)) return; // No ghost data to write. - if (ghost->player && ghost->player->pflags & PF_NIGHTSMODE && ghost->tracer) - { - // We're talking about the NiGHTS thing, not the normal platforming thing! - ziptic |= GZT_NIGHTS; - ghost = ghost->tracer; - } - ziptic_p = demo_p++; // the ziptic, written at the end of this function #define MAXMOM (0xFFFF<<8) @@ -4076,30 +5227,42 @@ void G_WriteGhostTic(mobj_t *ghost) // Only store the 8 most relevant bits of angle // because exact values aren't too easy to discern to begin with when only 8 angles have different sprites // and it does not affect this mode of movement at all anyway. - if (ghost->angle>>24 != oldghost.angle) + if (ghost->player && ghost->player->drawangle>>24 != oldghost.angle) { - oldghost.angle = ghost->angle>>24; + oldghost.angle = ghost->player->drawangle>>24; ziptic |= GZT_ANGLE; WRITEUINT8(demo_p,oldghost.angle); } // Store the sprite frame. - frame = ghost->frame & 0xFF; - if (frame != oldghost.frame) + if ((ghost->frame & FF_FRAMEMASK) != oldghost.frame) { - oldghost.frame = frame; - ziptic |= GZT_SPRITE; + oldghost.frame = (ghost->frame & FF_FRAMEMASK); + ziptic |= GZT_FRAME; WRITEUINT8(demo_p,oldghost.frame); } - // Check for sprite set changes - sprite = ghost->sprite; - if (sprite != oldghost.sprite) + if (ghost->sprite == SPR_PLAY + && ghost->sprite2 != oldghost.sprite2) { - oldghost.sprite = sprite; + oldghost.sprite2 = ghost->sprite2; + ziptic |= GZT_SPR2; + WRITEUINT8(demo_p,oldghost.sprite2); + } + + // Check for sprite set changes + if (ghost->sprite != oldghost.sprite) + { + oldghost.sprite = ghost->sprite; ghostext.flags |= EZT_SPRITE; } + if ((height = FixedDiv(ghost->height, ghost->scale)) != oldghost.height) + { + oldghost.height = height; + ghostext.flags |= EZT_HEIGHT; + } + if (ghostext.flags) { ziptic |= GZT_EXTRA; @@ -4126,7 +5289,7 @@ void G_WriteGhostTic(mobj_t *ghost) for (i = 0; i < ghostext.hits; i++) { mobj_t *mo = ghostext.hitlist[i]; - WRITEUINT32(demo_p,UINT32_MAX); // reserved for some method of determining exactly which mobj this is. (mobjnum doesn't work here.) + //WRITEUINT32(demo_p,UINT32_MAX); // reserved for some method of determining exactly which mobj this is. (mobjnum doesn't work here.) WRITEUINT32(demo_p,mo->type); WRITEUINT16(demo_p,(UINT16)mo->health); WRITEFIXED(demo_p,mo->x); @@ -4139,15 +5302,67 @@ void G_WriteGhostTic(mobj_t *ghost) ghostext.hitlist = NULL; } if (ghostext.flags & EZT_SPRITE) - WRITEUINT8(demo_p,sprite); + WRITEUINT16(demo_p,oldghost.sprite); + if (ghostext.flags & EZT_HEIGHT) + { + height >>= FRACBITS; + WRITEINT16(demo_p, height); + } ghostext.flags = 0; } + if (ghost->player && ghost->player->followmobj && !(ghost->player->followmobj->sprite == SPR_NULL || (ghost->player->followmobj->flags2 & MF2_DONTDRAW))) // bloats tails runs but what can ya do + { + INT16 temp; + UINT8 *followtic_p = demo_p++; + UINT8 followtic = 0; + + ziptic |= GZT_FOLLOW; + + if (ghost->player->followmobj->skin) + followtic |= FZT_SKIN; + + if (!(oldghost.flags2 & MF2_AMBUSH)) + { + followtic |= FZT_SPAWNED; + WRITEINT16(demo_p,ghost->player->followmobj->info->height>>FRACBITS); + if (ghost->player->followmobj->flags2 & MF2_LINKDRAW) + followtic |= FZT_LINKDRAW; + if (ghost->player->followmobj->colorized) + followtic |= FZT_COLORIZED; + if (followtic & FZT_SKIN) + WRITEUINT8(demo_p,(UINT8)(((skin_t *)(ghost->player->followmobj->skin))-skins)); + oldghost.flags2 |= MF2_AMBUSH; + } + + if (ghost->player->followmobj->scale != ghost->scale) + { + followtic |= FZT_SCALE; + WRITEFIXED(demo_p,ghost->player->followmobj->scale); + } + + temp = (INT16)((ghost->player->followmobj->x-ghost->x)>>8); + WRITEINT16(demo_p,temp); + temp = (INT16)((ghost->player->followmobj->y-ghost->y)>>8); + WRITEINT16(demo_p,temp); + temp = (INT16)((ghost->player->followmobj->z-ghost->z)>>8); + WRITEINT16(demo_p,temp); + if (followtic & FZT_SKIN) + WRITEUINT8(demo_p,ghost->player->followmobj->sprite2); + WRITEUINT16(demo_p,ghost->player->followmobj->sprite); + WRITEUINT8(demo_p,(ghost->player->followmobj->frame & FF_FRAMEMASK)); + WRITEUINT8(demo_p,ghost->player->followmobj->color); + + *followtic_p = followtic; + } + else + oldghost.flags2 &= ~MF2_AMBUSH; + *ziptic_p = ziptic; // attention here for the ticcmd size! // latest demos with mouse aiming byte in ticcmd - if (demo_p >= demoend - (13 + 9)) + if (demo_p >= demoend - (13 + 9 + 9)) { G_CheckDemoStatus(); // no more space return; @@ -4161,7 +5376,6 @@ void G_ConsGhostTic(void) UINT8 ziptic; UINT16 px,py,pz,gx,gy,gz; mobj_t *testmo; - boolean nightsfail = false; if (!demo_p || !demo_start) return; @@ -4193,23 +5407,19 @@ void G_ConsGhostTic(void) } if (ziptic & GZT_ANGLE) demo_p++; - if (ziptic & GZT_SPRITE) + if (ziptic & GZT_FRAME) + demo_p++; + if (ziptic & GZT_SPR2) demo_p++; - if(ziptic & GZT_NIGHTS) { - if (!testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) - nightsfail = true; - else - testmo = testmo->tracer; - } if (ziptic & GZT_EXTRA) { // But wait, there's more! - ziptic = READUINT8(demo_p); - if (ziptic & EZT_COLOR) + UINT8 xziptic = READUINT8(demo_p); + if (xziptic & EZT_COLOR) demo_p++; - if (ziptic & EZT_SCALE) + if (xziptic & EZT_SCALE) demo_p += sizeof(fixed_t); - if (ziptic & EZT_HIT) + if (xziptic & EZT_HIT) { // Resync mob damage. UINT16 i, count = READUINT16(demo_p); thinker_t *th; @@ -4223,7 +5433,7 @@ void G_ConsGhostTic(void) for (i = 0; i < count; i++) { - demo_p += 4; // reserved. + //demo_p += 4; // reserved. type = READUINT32(demo_p); health = READUINT16(demo_p); x = READFIXED(demo_p); @@ -4232,26 +5442,48 @@ void G_ConsGhostTic(void) demo_p += sizeof(angle_t); // angle, unnecessary for cons. mobj = NULL; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mobj = (mobj_t *)th; if (mobj->type == (mobjtype_t)type && mobj->x == x && mobj->y == y && mobj->z == z) break; - mobj = NULL; // wasn't this one, keep searching. } - if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! + if (th != &thlist[THINK_MOBJ] && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); demosynced = false; - P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); + P_DamageMobj(mobj, players[0].mo, players[0].mo, 1, 0); } } } - if (ziptic & EZT_SPRITE) + if (xziptic & EZT_SPRITE) + demo_p += sizeof(UINT16); + if (xziptic & EZT_HEIGHT) + demo_p += sizeof(INT16); + } + + if (ziptic & GZT_FOLLOW) + { // Even more... + UINT8 followtic = READUINT8(demo_p); + if (followtic & FZT_SPAWNED) + { + demo_p += sizeof(INT16); + if (followtic & FZT_SKIN) + demo_p++; + } + if (followtic & FZT_SCALE) + demo_p += sizeof(fixed_t); + demo_p += sizeof(INT16); + demo_p += sizeof(INT16); + demo_p += sizeof(INT16); + if (followtic & FZT_SKIN) demo_p++; + demo_p += sizeof(UINT16); + demo_p++; + demo_p++; } // Re-synchronise @@ -4262,7 +5494,7 @@ void G_ConsGhostTic(void) gy = oldghost.y>>FRACBITS; gz = oldghost.z>>FRACBITS; - if (nightsfail || px != gx || py != gy || pz != gz) + if (px != gx || py != gy || pz != gz) { if (demosynced) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); @@ -4290,6 +5522,7 @@ void G_GhostTicker(void) { // Skip normal demo data. UINT8 ziptic = READUINT8(g->p); + UINT8 xziptic = 0; if (ziptic & ZT_FWD) g->p++; if (ziptic & ZT_SIDE) @@ -4323,9 +5556,11 @@ void G_GhostTicker(void) g->oldmo.z += g->oldmo.momz; } if (ziptic & GZT_ANGLE) - g->oldmo.angle = READUINT8(g->p)<<24; - if (ziptic & GZT_SPRITE) + g->mo->angle = READUINT8(g->p)<<24; + if (ziptic & GZT_FRAME) g->oldmo.frame = READUINT8(g->p); + if (ziptic & GZT_SPR2) + g->oldmo.sprite2 = READUINT8(g->p); // Update ghost P_UnsetThingPosition(g->mo); @@ -4333,18 +5568,26 @@ void G_GhostTicker(void) g->mo->y = g->oldmo.y; g->mo->z = g->oldmo.z; P_SetThingPosition(g->mo); - g->mo->angle = g->oldmo.angle; g->mo->frame = g->oldmo.frame | tr_trans30<fadein) + { + g->mo->frame += (((--g->fadein)/6)<fadein is bad, and it's only set once, so... + g->mo->flags2 &= ~MF2_DONTDRAW; + } + g->mo->sprite2 = g->oldmo.sprite2; if (ziptic & GZT_EXTRA) { // But wait, there's more! - ziptic = READUINT8(g->p); - if (ziptic & EZT_COLOR) + xziptic = READUINT8(g->p); + if (xziptic & EZT_COLOR) { g->color = READUINT8(g->p); switch(g->color) { default: + case GHC_RETURNSKIN: + g->mo->skin = g->oldmo.skin; + /* FALLTHRU */ case GHC_NORMAL: // Go back to skin color g->mo->color = g->oldmo.color; break; @@ -4355,24 +5598,27 @@ void G_GhostTicker(void) case GHC_FIREFLOWER: // Fireflower g->mo->color = SKINCOLOR_WHITE; break; + case GHC_NIGHTSSKIN: // not actually a colour + g->mo->skin = &skins[DEFAULTNIGHTSSKIN]; + break; } } - if (ziptic & EZT_FLIP) + if (xziptic & EZT_FLIP) g->mo->eflags ^= MFE_VERTICALFLIP; - if (ziptic & EZT_SCALE) + if (xziptic & EZT_SCALE) { g->mo->destscale = READFIXED(g->p); if (g->mo->destscale != g->mo->scale) P_SetScale(g->mo, g->mo->destscale); } - if (ziptic & EZT_THOKMASK) + if (xziptic & EZT_THOKMASK) { // Let's only spawn ONE of these per frame, thanks. mobj_t *mobj; INT32 type = -1; if (g->mo->skin) { skin_t *skin = (skin_t *)g->mo->skin; - switch (ziptic & EZT_THOKMASK) + switch (xziptic & EZT_THOKMASK) { case EZT_THOK: type = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; @@ -4385,35 +5631,40 @@ void G_GhostTicker(void) break; } } - if (type == MT_GHOST) + if (type != MT_NULL) { - mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us - mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo->x, g->mo->y, g->mo->z - FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); - mobj->sprite = states[mobjinfo[type].spawnstate].sprite; - mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<tics = -1; // nope. - mobj->color = g->mo->color; - if (g->mo->eflags & MFE_VERTICALFLIP) + if (type == MT_GHOST) { - mobj->flags2 |= MF2_OBJECTFLIP; - mobj->eflags |= MFE_VERTICALFLIP; + mobj = P_SpawnGhostMobj(g->mo); // does a large portion of the work for us + mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|tr_trans60<mo->scale); - mobj->destscale = g->mo->scale; + else + { + mobj = P_SpawnMobjFromMobj(g->mo, 0, 0, -FixedDiv(FixedMul(g->mo->info->height, g->mo->scale) - g->mo->height,3*FRACUNIT), MT_THOK); + mobj->sprite = states[mobjinfo[type].spawnstate].sprite; + mobj->frame = (states[mobjinfo[type].spawnstate].frame & FF_FRAMEMASK) | tr_trans60<color = g->mo->color; + mobj->skin = g->mo->skin; + P_SetScale(mobj, (mobj->destscale = g->mo->scale)); + + if (type == MT_THOK) // spintrail-specific modification for MT_THOK + { + mobj->frame = FF_TRANS80; + mobj->fuse = mobj->tics; + } + mobj->tics = -1; // nope. + } + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z+mobj->height; + P_UnsetThingPosition(mobj); + mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... + P_SetThingPosition(mobj); + if (!mobj->fuse) + mobj->fuse = 8; + P_SetTarget(&mobj->target, g->mo); } - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_UnsetThingPosition(mobj); - mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... - P_SetThingPosition(mobj); - mobj->fuse = 8; - P_SetTarget(&mobj->target, g->mo); } - if (ziptic & EZT_HIT) + if (xziptic & EZT_HIT) { // Spawn hit poofs for killing things! UINT16 i, count = READUINT16(g->p), health; UINT32 type; @@ -4422,7 +5673,7 @@ void G_GhostTicker(void) mobj_t *poof; for (i = 0; i < count; i++) { - g->p += 4; // reserved + //g->p += 4; // reserved type = READUINT32(g->p); health = READUINT16(g->p); x = READFIXED(g->p); @@ -4440,28 +5691,113 @@ void G_GhostTicker(void) P_SetMobjStateNF(poof, S_XPLD1); } } - if (ziptic & EZT_SPRITE) - g->mo->sprite = READUINT8(g->p); + if (xziptic & EZT_SPRITE) + g->mo->sprite = READUINT16(g->p); + if (xziptic & EZT_HEIGHT) + { + fixed_t temp = READINT16(g->p)<mo->height = FixedMul(temp, g->mo->scale); + } } // Tick ghost colors (Super and Mario Invincibility flashing) switch(g->color) { - case GHC_SUPER: // Super Sonic (P_DoSuperStuff) - g->mo->color = SKINCOLOR_SUPER1; + case GHC_SUPER: // Super (P_DoSuperStuff) + if (g->mo->skin) + { + skin_t *skin = (skin_t *)g->mo->skin; + g->mo->color = skin->supercolor; + } + else + g->mo->color = SKINCOLOR_SUPERGOLD1; g->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); break; case GHC_INVINCIBLE: // Mario invincibility (P_CheckInvincibilityTimer) - g->mo->color = (UINT8)(leveltime % MAXSKINCOLORS); + g->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (MAXSKINCOLORS - SKINCOLOR_RUBY))); // Passes through all saturated colours break; default: break; } +#define follow g->mo->tracer + if (ziptic & GZT_FOLLOW) + { // Even more... + UINT8 followtic = READUINT8(g->p); + fixed_t temp; + if (followtic & FZT_SPAWNED) + { + if (follow) + P_RemoveMobj(follow); + P_SetTarget(&follow, P_SpawnMobjFromMobj(g->mo, 0, 0, 0, MT_GHOST)); + P_SetTarget(&follow->tracer, g->mo); + follow->tics = -1; + temp = READINT16(g->p)<height = FixedMul(follow->scale, temp); + + if (followtic & FZT_LINKDRAW) + follow->flags2 |= MF2_LINKDRAW; + + if (followtic & FZT_COLORIZED) + follow->colorized = true; + + if (followtic & FZT_SKIN) + follow->skin = &skins[READUINT8(g->p)]; + } + if (follow) + { + if (followtic & FZT_SCALE) + follow->destscale = READFIXED(g->p); + else + follow->destscale = g->mo->destscale; + if (follow->destscale != follow->scale) + P_SetScale(follow, follow->destscale); + + P_UnsetThingPosition(follow); + temp = READINT16(g->p)<<8; + follow->x = g->mo->x + temp; + temp = READINT16(g->p)<<8; + follow->y = g->mo->y + temp; + temp = READINT16(g->p)<<8; + follow->z = g->mo->z + temp; + P_SetThingPosition(follow); + if (followtic & FZT_SKIN) + follow->sprite2 = READUINT8(g->p); + else + follow->sprite2 = 0; + follow->sprite = READUINT16(g->p); + follow->frame = (READUINT8(g->p)) | (g->mo->frame & FF_TRANSMASK); + follow->angle = g->mo->angle; + follow->color = READUINT8(g->p); + + if (!(followtic & FZT_SPAWNED)) + { + if (xziptic & EZT_FLIP) + { + follow->flags2 ^= MF2_OBJECTFLIP; + follow->eflags ^= MFE_VERTICALFLIP; + } + } + } + } + else if (follow) + { + P_RemoveMobj(follow); + P_SetTarget(&follow, NULL); + } // Demo ends after ghost data. if (*g->p == DEMOMARKER) { g->mo->momx = g->mo->momy = g->mo->momz = 0; +#if 1 // freeze frame (maybe more useful for time attackers) + g->mo->colorized = true; + if (follow) + follow->colorized = true; +#else // dissapearing act + g->mo->fuse = TICRATE; + if (follow) + follow->fuse = TICRATE; +#endif if (p) p->next = g->next; else @@ -4470,17 +5806,41 @@ void G_GhostTicker(void) continue; } p = g; +#undef follow } } void G_ReadMetalTic(mobj_t *metal) { UINT8 ziptic; - UINT16 speed; - UINT8 statetype; + UINT8 xziptic = 0; if (!metal_p) return; + + if (!metal->health) + { + G_StopMetalDemo(); + return; + } + + switch (*metal_p) + { + case METALSNICE: + break; + case METALDEATH: + if (metal->tracer) + P_RemoveMobj(metal->tracer); + P_KillMobj(metal, NULL, NULL, 0); + /* FALLTHRU */ + case DEMOMARKER: + default: + // end of demo data stream + G_StopMetalDemo(); + return; + } + metal_p++; + ziptic = READUINT8(metal_p); // Read changes from the tic @@ -4505,9 +5865,11 @@ void G_ReadMetalTic(mobj_t *metal) oldmetal.z += oldmetal.momz; } if (ziptic & GZT_ANGLE) - oldmetal.angle = READUINT8(metal_p)<<24; - if (ziptic & GZT_SPRITE) - metal_p++; // Currently unused. (Metal Sonic figures out what he's doing his own damn self.) + metal->angle = READUINT8(metal_p)<<24; + if (ziptic & GZT_FRAME) + oldmetal.frame = READUINT32(metal_p); + if (ziptic & GZT_SPR2) + oldmetal.sprite2 = READUINT8(metal_p); // Set movement, position, and angle // oldmetal contains where you're supposed to be. @@ -4519,68 +5881,163 @@ void G_ReadMetalTic(mobj_t *metal) metal->y = oldmetal.y; metal->z = oldmetal.z; P_SetThingPosition(metal); - metal->angle = oldmetal.angle; + metal->frame = oldmetal.frame; + metal->sprite2 = oldmetal.sprite2; if (ziptic & GZT_EXTRA) { // But wait, there's more! - ziptic = READUINT8(metal_p); - if (ziptic & EZT_FLIP) + xziptic = READUINT8(metal_p); + if (xziptic & EZT_FLIP) + { metal->eflags ^= MFE_VERTICALFLIP; - if (ziptic & EZT_SCALE) + metal->flags2 ^= MF2_OBJECTFLIP; + } + if (xziptic & EZT_SCALE) { metal->destscale = READFIXED(metal_p); if (metal->destscale != metal->scale) P_SetScale(metal, metal->destscale); } - } + if (xziptic & EZT_THOKMASK) + { // Let's only spawn ONE of these per frame, thanks. + mobj_t *mobj; + INT32 type = -1; + if (metal->skin) + { + skin_t *skin = (skin_t *)metal->skin; + switch (xziptic & EZT_THOKMASK) + { + case EZT_THOK: + type = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; + break; + case EZT_SPIN: + type = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; + break; + case EZT_REV: + type = skin->revitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; + break; + } + } + if (type != MT_NULL) + { + if (type == MT_GHOST) + { + mobj = P_SpawnGhostMobj(metal); // does a large portion of the work for us + } + else + { + mobj = P_SpawnMobjFromMobj(metal, 0, 0, -FixedDiv(FixedMul(metal->info->height, metal->scale) - metal->height,3*FRACUNIT), MT_THOK); + mobj->sprite = states[mobjinfo[type].spawnstate].sprite; + mobj->frame = states[mobjinfo[type].spawnstate].frame; + mobj->angle = metal->angle; + mobj->color = metal->color; + mobj->skin = metal->skin; + P_SetScale(mobj, (mobj->destscale = metal->scale)); - // Calculates player's speed based on distance-of-a-line formula - speed = FixedDiv(P_AproxDistance(oldmetal.momx, oldmetal.momy), metal->scale)>>FRACBITS; - - // Use speed to decide an appropriate state - if (speed > 28) // default skin runspeed - statetype = 2; - else if (speed > 1) // stopspeed - statetype = 1; - else - statetype = 0; - - // Set state - if (statetype != metal->threshold) - { - switch (statetype) - { - case 2: // run - P_SetMobjState(metal,metal->info->meleestate); - break; - case 1: // walk - P_SetMobjState(metal,metal->info->seestate); - break; - default: // stand - P_SetMobjState(metal,metal->info->spawnstate); - break; + if (type == MT_THOK) // spintrail-specific modification for MT_THOK + { + mobj->frame = FF_TRANS70; + mobj->fuse = mobj->tics; + } + mobj->tics = -1; // nope. + } + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z+mobj->height; + P_UnsetThingPosition(mobj); + mobj->flags = MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; // make an ATTEMPT to curb crazy SOCs fucking stuff up... + P_SetThingPosition(mobj); + if (!mobj->fuse) + mobj->fuse = 8; + P_SetTarget(&mobj->target, metal); + } + } + if (xziptic & EZT_SPRITE) + metal->sprite = READUINT16(metal_p); + if (xziptic & EZT_HEIGHT) + { + fixed_t temp = READINT16(metal_p)<height = FixedMul(temp, metal->scale); } - metal->threshold = statetype; } - // TODO: Modify state durations based on movement speed, similar to players? +#define follow metal->tracer + if (ziptic & GZT_FOLLOW) + { // Even more... + UINT8 followtic = READUINT8(metal_p); + fixed_t temp; + if (followtic & FZT_SPAWNED) + { + if (follow) + P_RemoveMobj(follow); + P_SetTarget(&follow, P_SpawnMobjFromMobj(metal, 0, 0, 0, MT_GHOST)); + P_SetTarget(&follow->tracer, metal); + follow->tics = -1; + temp = READINT16(metal_p)<height = FixedMul(follow->scale, temp); - if (*metal_p == DEMOMARKER) - { - // end of demo data stream - G_StopMetalDemo(); - return; - } + if (followtic & FZT_LINKDRAW) + follow->flags2 |= MF2_LINKDRAW; + + if (followtic & FZT_COLORIZED) + follow->colorized = true; + + if (followtic & FZT_SKIN) + follow->skin = &skins[READUINT8(metal_p)]; + } + if (follow) + { + if (followtic & FZT_SCALE) + follow->destscale = READFIXED(metal_p); + else + follow->destscale = metal->destscale; + if (follow->destscale != follow->scale) + P_SetScale(follow, follow->destscale); + + P_UnsetThingPosition(follow); + temp = READINT16(metal_p)<<8; + follow->x = metal->x + temp; + temp = READINT16(metal_p)<<8; + follow->y = metal->y + temp; + temp = READINT16(metal_p)<<8; + follow->z = metal->z + temp; + P_SetThingPosition(follow); + if (followtic & FZT_SKIN) + follow->sprite2 = READUINT8(metal_p); + else + follow->sprite2 = 0; + follow->sprite = READUINT16(metal_p); + follow->frame = READUINT32(metal_p); // NOT & FF_FRAMEMASK here, so 32 bits + follow->angle = metal->angle; + follow->color = READUINT8(metal_p); + + if (!(followtic & FZT_SPAWNED)) + { + if (xziptic & EZT_FLIP) + { + follow->flags2 ^= MF2_OBJECTFLIP; + follow->eflags ^= MFE_VERTICALFLIP; + } + } + } + } + else if (follow) + { + P_RemoveMobj(follow); + P_SetTarget(&follow, NULL); + } +#undef follow } void G_WriteMetalTic(mobj_t *metal) { UINT8 ziptic = 0; UINT8 *ziptic_p; + fixed_t height; - if (!demo_p) // demo_p will be NULL until the race start linedef executor is triggered! + if (!demo_p) // demo_p will be NULL until the race start linedef executor is activated! return; + WRITEUINT8(demo_p, METALSNICE); ziptic_p = demo_p++; // the ziptic, written at the end of this function #define MAXMOM (0xFFFF<<8) @@ -4593,10 +6050,10 @@ void G_WriteMetalTic(mobj_t *metal) oldmetal.x = metal->x; oldmetal.y = metal->y; oldmetal.z = metal->z; + ziptic |= GZT_XYZ; WRITEFIXED(demo_p,oldmetal.x); WRITEFIXED(demo_p,oldmetal.y); WRITEFIXED(demo_p,oldmetal.z); - ziptic |= GZT_XYZ; } else { @@ -4609,16 +6066,16 @@ void G_WriteMetalTic(mobj_t *metal) { oldmetal.momx = momx; oldmetal.momy = momy; + ziptic |= GZT_MOMXY; WRITEINT16(demo_p,momx); WRITEINT16(demo_p,momy); - ziptic |= GZT_MOMXY; } momx = (INT16)((metal->z-oldmetal.z)>>8); if (momx != oldmetal.momz) { oldmetal.momz = momx; - WRITEINT16(demo_p,momx); ziptic |= GZT_MOMZ; + WRITEINT16(demo_p,momx); } // This SHOULD set oldmetal.x/y/z to match metal->x/y/z @@ -4634,48 +6091,119 @@ void G_WriteMetalTic(mobj_t *metal) // Only store the 8 most relevant bits of angle // because exact values aren't too easy to discern to begin with when only 8 angles have different sprites // and it does not affect movement at all anyway. - if (metal->angle>>24 != oldmetal.angle) + if (metal->player && metal->player->drawangle>>24 != oldmetal.angle) { - oldmetal.angle = metal->angle>>24; - WRITEUINT8(demo_p,oldmetal.angle); + oldmetal.angle = metal->player->drawangle>>24; ziptic |= GZT_ANGLE; + WRITEUINT8(demo_p,oldmetal.angle); } - // Metal Sonic does not need our state changes. - // ... currently. - + // Store the sprite frame. + if ((metal->frame & FF_FRAMEMASK) != oldmetal.frame) { - UINT8 *exttic_p = NULL; - UINT8 exttic = 0; - if ((metal->eflags & MFE_VERTICALFLIP) != (oldmetal.eflags & MFE_VERTICALFLIP)) - { - if (!exttic_p) - exttic_p = demo_p++; - exttic |= EZT_FLIP; - oldmetal.eflags ^= MFE_VERTICALFLIP; - } - if (metal->scale != oldmetal.scale) - { - if (!exttic_p) - exttic_p = demo_p++; - exttic |= EZT_SCALE; - WRITEFIXED(demo_p,metal->scale); - oldmetal.scale = metal->scale; - } - if (exttic_p) - { - *exttic_p = exttic; - ziptic |= GZT_EXTRA; - } + oldmetal.frame = metal->frame; // NOT & FF_FRAMEMASK here, so 32 bits + ziptic |= GZT_FRAME; + WRITEUINT32(demo_p,oldmetal.frame); } + if (metal->sprite == SPR_PLAY + && metal->sprite2 != oldmetal.sprite2) + { + oldmetal.sprite2 = metal->sprite2; + ziptic |= GZT_SPR2; + WRITEUINT8(demo_p,oldmetal.sprite2); + } + + // Check for sprite set changes + if (metal->sprite != oldmetal.sprite) + { + oldmetal.sprite = metal->sprite; + ghostext.flags |= EZT_SPRITE; + } + + if ((height = FixedDiv(metal->height, metal->scale)) != oldmetal.height) + { + oldmetal.height = height; + ghostext.flags |= EZT_HEIGHT; + } + + if (ghostext.flags & ~(EZT_COLOR|EZT_HIT)) // these two aren't handled by metal ever + { + ziptic |= GZT_EXTRA; + + if (ghostext.scale == ghostext.lastscale) + ghostext.flags &= ~EZT_SCALE; + + WRITEUINT8(demo_p,ghostext.flags); + if (ghostext.flags & EZT_SCALE) + { + WRITEFIXED(demo_p,ghostext.scale); + ghostext.lastscale = ghostext.scale; + } + if (ghostext.flags & EZT_SPRITE) + WRITEUINT16(demo_p,oldmetal.sprite); + if (ghostext.flags & EZT_HEIGHT) + { + height >>= FRACBITS; + WRITEINT16(demo_p, height); + } + ghostext.flags = 0; + } + + if (metal->player && metal->player->followmobj && !(metal->player->followmobj->sprite == SPR_NULL || (metal->player->followmobj->flags2 & MF2_DONTDRAW))) + { + INT16 temp; + UINT8 *followtic_p = demo_p++; + UINT8 followtic = 0; + + ziptic |= GZT_FOLLOW; + + if (metal->player->followmobj->skin) + followtic |= FZT_SKIN; + + if (!(oldmetal.flags2 & MF2_AMBUSH)) + { + followtic |= FZT_SPAWNED; + WRITEINT16(demo_p,metal->player->followmobj->info->height>>FRACBITS); + if (metal->player->followmobj->flags2 & MF2_LINKDRAW) + followtic |= FZT_LINKDRAW; + if (metal->player->followmobj->colorized) + followtic |= FZT_COLORIZED; + if (followtic & FZT_SKIN) + WRITEUINT8(demo_p,(UINT8)(((skin_t *)(metal->player->followmobj->skin))-skins)); + oldmetal.flags2 |= MF2_AMBUSH; + } + + if (metal->player->followmobj->scale != metal->scale) + { + followtic |= FZT_SCALE; + WRITEFIXED(demo_p,metal->player->followmobj->scale); + } + + temp = (INT16)((metal->player->followmobj->x-metal->x)>>8); + WRITEINT16(demo_p,temp); + temp = (INT16)((metal->player->followmobj->y-metal->y)>>8); + WRITEINT16(demo_p,temp); + temp = (INT16)((metal->player->followmobj->z-metal->z)>>8); + WRITEINT16(demo_p,temp); + if (followtic & FZT_SKIN) + WRITEUINT8(demo_p,metal->player->followmobj->sprite2); + WRITEUINT16(demo_p,metal->player->followmobj->sprite); + WRITEUINT32(demo_p,metal->player->followmobj->frame); // NOT & FF_FRAMEMASK here, so 32 bits + WRITEUINT8(demo_p,metal->player->followmobj->color); + + *followtic_p = followtic; + } + else + oldmetal.flags2 &= ~MF2_AMBUSH; + *ziptic_p = ziptic; // attention here for the ticcmd size! // latest demos with mouse aiming byte in ticcmd if (demo_p >= demoend - 32) { - G_StopMetalRecording(); // no more space + G_StopMetalRecording(false); // no more space return; } } @@ -4797,12 +6325,51 @@ void G_BeginRecording(void) WRITEUINT8(demo_p,player->thrustfactor); WRITEUINT8(demo_p,player->accelstart); WRITEUINT8(demo_p,player->acceleration); + WRITEUINT8(demo_p,player->height>>FRACBITS); + WRITEUINT8(demo_p,player->spinheight>>FRACBITS); + WRITEUINT8(demo_p,player->camerascale>>FRACBITS); + WRITEUINT8(demo_p,player->shieldscale>>FRACBITS); // Trying to convert it back to % causes demo desync due to precision loss. // Don't do it. WRITEFIXED(demo_p, player->jumpfactor); - // Save netvar data (SONICCD, etc) + // And mobjtype_t is best with UINT32 too... + WRITEUINT32(demo_p, player->followitem); + + // Save pflag data - see SendWeaponPref() + { + UINT8 buf = 0; + pflags_t pflags = 0; + if (cv_flipcam.value) + { + buf |= 0x01; + pflags |= PF_FLIPCAM; + } + if (cv_analog[0].value) + { + buf |= 0x02; + pflags |= PF_ANALOGMODE; + } + if (cv_directionchar[0].value) + { + buf |= 0x04; + pflags |= PF_DIRECTIONCHAR; + } + if (cv_autobrake.value) + { + buf |= 0x08; + pflags |= PF_AUTOBRAKE; + } + if (cv_usejoystick.value) + buf |= 0x10; + CV_SetValue(&cv_showinputjoy, !!(cv_usejoystick.value)); + + WRITEUINT8(demo_p,buf); + player->pflags = pflags; + } + + // Save netvar data CV_SaveNetVars(&demo_p); memset(&oldcmd,0,sizeof(oldcmd)); @@ -4816,7 +6383,7 @@ void G_BeginRecording(void) oldghost.x = player->mo->x; oldghost.y = player->mo->y; oldghost.z = player->mo->z; - oldghost.angle = player->mo->angle; + oldghost.angle = player->mo->angle>>24; // preticker started us gravity flipped if (player->mo->eflags & MFE_VERTICALFLIP) @@ -4828,8 +6395,10 @@ void G_BeginMetal(void) { mobj_t *mo = players[consoleplayer].mo; +#if 0 if (demo_p) return; +#endif demo_p = demobuffer; @@ -4844,12 +6413,15 @@ void G_BeginMetal(void) M_Memcpy(demo_p, "METL", 4); demo_p += 4; + memset(&ghostext,0,sizeof(ghostext)); + ghostext.lastscale = ghostext.scale = FRACUNIT; + // Set up our memory. memset(&oldmetal,0,sizeof(oldmetal)); oldmetal.x = mo->x; oldmetal.y = mo->y; oldmetal.z = mo->z; - oldmetal.angle = mo->angle; + oldmetal.angle = mo->angle>>24; } void G_SetDemoTime(UINT32 ptime, UINT32 pscore, UINT16 prings) @@ -4949,8 +6521,6 @@ UINT8 G_CmpDemoTime(char *oldname, char *newname) switch(oldversion) // demoversion { case DEMOVERSION: // latest always supported - // compatibility available? - case 0x0008: break; // too old, cannot support. default: @@ -5026,8 +6596,9 @@ void G_DoPlayDemo(char *defdemoname) lumpnum_t l; char skin[17],color[17],*n,*pdemoname; UINT8 version,subversion,charability,charability2,thrustfactor,accelstart,acceleration; - UINT32 randseed; - fixed_t actionspd,mindash,maxdash,normalspeed,runspeed,jumpfactor; + pflags_t pflags; + UINT32 randseed, followitem; + fixed_t camerascale,shieldscale,actionspd,mindash,maxdash,normalspeed,runspeed,jumpfactor,height,spinheight; char msg[1024]; skin[16] = '\0'; @@ -5089,8 +6660,6 @@ void G_DoPlayDemo(char *defdemoname) switch(demoversion) { case DEMOVERSION: // latest always supported - // compatibility available? - case 0x0008: break; // too old, cannot support. default: @@ -5116,10 +6685,7 @@ void G_DoPlayDemo(char *defdemoname) return; } demo_p += 4; // "PLAY" - if (demoversion <= 0x0008) - gamemap = READUINT8(demo_p); - else - gamemap = READINT16(demo_p); + gamemap = READINT16(demo_p); demo_p += 16; // mapmd5 demoflags = READUINT8(demo_p); @@ -5173,7 +6739,27 @@ void G_DoPlayDemo(char *defdemoname) thrustfactor = READUINT8(demo_p); accelstart = READUINT8(demo_p); acceleration = READUINT8(demo_p); + height = (fixed_t)READUINT8(demo_p)<z << FRACBITS; gh->mo = P_SpawnMobj(mthing->x << FRACBITS, mthing->y << FRACBITS, 0, MT_GHOST); - gh->mo->angle = FixedAngle(mthing->angle*FRACUNIT); + gh->mo->angle = FixedAngle(mthing->angle << FRACBITS); f = gh->mo->floorz; c = gh->mo->ceilingz - mobjinfo[MT_PLAYER].height; if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP)) { - z = c; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); + z = c - offset; if (z < f) z = f; } else { - z = f; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); + z = f + offset; if (z > c) z = c; } gh->mo->z = z; } - gh->mo->state = states+S_PLAY_STND; - gh->mo->sprite = gh->mo->state->sprite; - gh->mo->frame = (gh->mo->state->frame & FF_FRAMEMASK) | tr_trans20<mo->tics = -1; gh->oldmo.x = gh->mo->x; gh->oldmo.y = gh->mo->y; @@ -5471,6 +7056,14 @@ void G_AddGhost(char *defdemoname) } gh->oldmo.color = gh->mo->color; + gh->mo->state = states+S_PLAY_STND; + gh->mo->sprite = gh->mo->state->sprite; + gh->mo->sprite2 = (gh->mo->state->frame & FF_FRAMEMASK); + //gh->mo->frame = tr_trans30<mo->flags2 |= MF2_DONTDRAW; + gh->fadein = (9-3)*6; // fade from invisible to trans30 over as close to 35 tics as possible + gh->mo->tics = -1; + CONS_Printf(M_GetText("Added ghost %s from %s\n"), name, pdemoname); Z_Free(pdemoname); } @@ -5511,16 +7104,18 @@ void G_DoPlayMetal(void) metalbuffer = metal_p = W_CacheLumpNum(l, PU_STATIC); // find metal sonic - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo = (mobj_t *)th; - if (mo->type == MT_METALSONIC_RACE) - break; + if (mo->type != MT_METALSONIC_RACE) + continue; + + break; } - if (!mo) + if (th == &thlist[THINK_MOBJ]) { CONS_Alert(CONS_ERROR, M_GetText("Failed to find bot entity.\n")); Z_Free(metalbuffer); @@ -5535,8 +7130,6 @@ void G_DoPlayMetal(void) switch(metalversion) { case DEMOVERSION: // latest always supported - // compatibility available? - case 0x0008: break; // too old, cannot support. default: @@ -5557,7 +7150,6 @@ void G_DoPlayMetal(void) oldmetal.x = mo->x; oldmetal.y = mo->y; oldmetal.z = mo->z; - oldmetal.angle = mo->angle; metalplayback = mo; } @@ -5590,19 +7182,23 @@ void G_StopMetalDemo(void) } // Stops metal sonic recording. -ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void) +ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(boolean kill) { boolean saved = false; if (demo_p) { UINT8 *p = demobuffer+16; // checksum position + if (kill) + WRITEUINT8(demo_p, METALDEATH); // add the metal death marker + else + WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker #ifdef NOMD5 - UINT8 i; - WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker - for (i = 0; i < 16; i++, p++) - *p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. + { + UINT8 i; + for (i = 0; i < 16; i++, p++) + *p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct. + } #else - WRITEUINT8(demo_p, DEMOMARKER); // add the demo end marker md5_buffer((char *)p+16, demo_p - (p+16), (void *)p); // make a checksum of everything after the checksum in the file. #endif saved = FIL_WriteFile(va("%sMS.LMP", G_BuildMapName(gamemap)), demobuffer, demo_p - demobuffer); // finally output the file. @@ -5660,7 +7256,46 @@ boolean G_CheckDemoStatus(void) timingdemo = false; f1 = (double)demotime; f2 = (double)framecount*TICRATE; - CONS_Printf(M_GetText("timed %u gametics in %d realtics\n%f seconds, %f avg fps\n"), leveltime,demotime,f1/TICRATE,f2/f1); + + CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"), + leveltime,demotime,(UINT32)framecount,f1/TICRATE,f2/f1); + + // CSV-readable timedemo results, for external parsing + if (timedemo_csv) + { + FILE *f; + const char *csvpath = va("%s"PATHSEP"%s", srb2home, "timedemo.csv"); + const char *header = "id,demoname,seconds,avgfps,leveltime,demotime,framecount,ticrate,rendermode,vidmode,vidwidth,vidheight,procbits\n"; + const char *rowformat = "\"%s\",\"%s\",%f,%f,%u,%d,%u,%u,%u,%u,%u,%u,%u\n"; + boolean headerrow = !FIL_FileExists(csvpath); + UINT8 procbits = 0; + + // Bitness + if (sizeof(void*) == 4) + procbits = 32; + else if (sizeof(void*) == 8) + procbits = 64; + + f = fopen(csvpath, "a+"); + + if (f) + { + if (headerrow) + fputs(header, f); + fprintf(f, rowformat, + timedemo_csv_id,timedemo_name,f1/TICRATE,f2/f1,leveltime,demotime,(UINT32)framecount,TICRATE,rendermode,vid.modenum,vid.width,vid.height,procbits); + fclose(f); + CONS_Printf("Timedemo results saved to '%s'\n", csvpath); + } + else + { + // Just print the CSV output to console + CON_LogMessage(header); + CONS_Printf(rowformat, + timedemo_csv_id,timedemo_name,f1/TICRATE,f2/f1,leveltime,demotime,(UINT32)framecount,TICRATE,rendermode,vid.modenum,vid.width,vid.height,procbits); + } + } + if (restorecv_vidwait != cv_vidwait.value) CV_SetValue(&cv_vidwait, restorecv_vidwait); D_AdvanceDemo(); @@ -5759,6 +7394,22 @@ boolean G_GetRetryFlag(void) return retrying; } +void G_SetModeAttackRetryFlag(void) +{ + retryingmodeattack = true; + G_SetRetryFlag(); +} + +void G_ClearModeAttackRetryFlag(void) +{ + retryingmodeattack = false; +} + +boolean G_GetModeAttackRetryFlag(void) +{ + return retryingmodeattack; +} + // Time utility functions INT32 G_TicsToHours(tic_t tics) { diff --git a/src/g_game.h b/src/g_game.h index 5259eacbb..8a2c5b0ae 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -37,10 +37,12 @@ extern boolean playeringame[MAXPLAYERS]; // demoplaying back and demo recording extern boolean demoplayback, titledemo, demorecording, timingdemo; +extern tic_t demostarttime; // Quit after playing a demo from cmdline. extern boolean singledemo; extern boolean demo_start; +extern boolean demosynced; extern mobj_t *metalplayback; @@ -50,20 +52,53 @@ extern tic_t levelstarttic; // for modding? extern INT16 prevmap, nextmap; extern INT32 gameovertics; +extern UINT8 ammoremovaltics; extern tic_t timeinmap; // Ticker for time spent in level (used for levelcard display) extern INT16 rw_maximums[NUM_WEAPONS]; +extern INT32 pausedelay; +extern boolean pausebreakkey; + +extern boolean promptactive; + +extern consvar_t cv_pauseifunfocused; // used in game menu +extern consvar_t cv_tutorialprompt; extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, cv_consolechat, cv_chatbacktint, cv_chatspamprotection, cv_compactscoreboard; extern consvar_t cv_crosshair, cv_crosshair2; extern consvar_t cv_invertmouse, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove; extern consvar_t cv_invertmouse2, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2; -extern consvar_t cv_useranalog, cv_useranalog2; -extern consvar_t cv_analog, cv_analog2; -extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis; -extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2; + +extern consvar_t cv_useranalog[2], cv_analog[2]; +extern consvar_t cv_directionchar[2]; + +typedef enum { + CS_LEGACY, + CS_LMAOGALOG, + CS_STANDARD, + CS_SIMPLE = CS_LMAOGALOG|CS_STANDARD, +} controlstyle_e; +#define G_ControlStyle(ssplayer) (cv_directionchar[(ssplayer)-1].value == 3 ? CS_LMAOGALOG : ((cv_analog[(ssplayer)-1].value ? CS_LMAOGALOG : 0) | (cv_directionchar[(ssplayer)-1].value ? CS_STANDARD : 0))) +#define P_ControlStyle(player) ((((player)->pflags & PF_ANALOGMODE) ? CS_LMAOGALOG : 0) | (((player)->pflags & PF_DIRECTIONCHAR) ? CS_STANDARD : 0)) + +extern consvar_t cv_autobrake, cv_autobrake2; +extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone,cv_digitaldeadzone; +extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2,cv_digitaldeadzone2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; +// hi here's some new controls +extern consvar_t cv_cam_shiftfacing[2], cv_cam_turnfacing[2], + cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2], + cv_cam_centertoggle[2], cv_cam_lockedinput[2], cv_cam_lockonboss[2]; + +typedef enum +{ + LOCK_BOSS = 1<<0, + LOCK_ENEMY = 1<<1, + LOCK_INTERESTS = 1<<2, +} lockassist_e; + + // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) #define MAXPLMOVE (50) @@ -71,8 +106,10 @@ extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_g // build an internal map name MAPxx from map number const char *G_BuildMapName(INT32 map); -void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics); -void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics); + +extern boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player +extern mobj_t *ticcmd_ztargetfocus[2]; // Locking onto an object? +void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); // copy ticcmd_t to and fro the normal way ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n); @@ -91,23 +128,51 @@ extern INT32 localaiming, localaiming2; // should be an angle_t but signed // void G_ChangePlayerReferences(mobj_t *oldmo, mobj_t *newmo); void G_DoReborn(INT32 playernum); -void G_PlayerReborn(INT32 player); +void G_PlayerReborn(INT32 player, boolean betweenmaps); void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, - boolean skipprecutscene); + boolean skipprecutscene, boolean FLS); char *G_BuildMapTitle(INT32 mapnum); +struct searchdim +{ + UINT8 pos; + UINT8 siz; +}; + +typedef struct +{ + INT16 mapnum; + UINT8 matchc; + struct searchdim *matchd;/* offset that a pattern was matched */ + UINT8 keywhc; + struct searchdim *keywhd;/* ...in KEYWORD */ + UINT8 total;/* total hits */ +} +mapsearchfreq_t; + +INT32 G_FindMap(const char *query, char **foundmapnamep, + mapsearchfreq_t **freqp, INT32 *freqc); +void G_FreeMapSearch(mapsearchfreq_t *freq, INT32 freqc); + +/* Match map name by search + 2 digit map code or map number. */ +INT32 G_FindMapByNameOrCode(const char *query, char **foundmapnamep); + // XMOD spawning mapthing_t *G_FindCTFStart(INT32 playernum); mapthing_t *G_FindMatchStart(INT32 playernum); mapthing_t *G_FindCoopStart(INT32 playernum); -void G_SpawnPlayer(INT32 playernum, boolean starpost); +mapthing_t *G_FindMapStart(INT32 playernum); +void G_MovePlayerToSpawnOrStarpost(INT32 playernum); +void G_SpawnPlayer(INT32 playernum); // Can be called by the startup code or M_Responder. // A normal game starts at map 1, but a warp test can start elsewhere void G_DeferedInitNew(boolean pultmode, const char *mapname, INT32 pickedchar, boolean SSSG, boolean FLS); void G_DoLoadLevel(boolean resetplayer); - +void G_StartTitleCard(void); +void G_PreLevelTitleCard(void); +boolean G_IsTitleCardAvailable(void); void G_DeferedPlayDemo(const char *demo); // Can be called by the startup code or M_Responder, calls P_SetupLevel. @@ -117,6 +182,8 @@ void G_SaveGameData(void); void G_SaveGame(UINT32 slot); +void G_SaveGameOver(UINT32 slot, boolean modifylives); + // Only called by startup code. void G_RecordDemo(const char *name); void G_RecordMetal(void); @@ -132,7 +199,9 @@ typedef enum GHC_NORMAL = 0, GHC_SUPER, GHC_FIREFLOWER, - GHC_INVINCIBLE + GHC_INVINCIBLE, + GHC_NIGHTSSKIN, // not actually a colour + GHC_RETURNSKIN // ditto } ghostcolor_t; // Record/playback tics @@ -159,17 +228,34 @@ void G_AddGhost(char *defdemoname); void G_DoPlayMetal(void); void G_DoneLevelLoad(void); void G_StopMetalDemo(void); -ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(void); +ATTRNORETURN void FUNCNORETURN G_StopMetalRecording(boolean kill); void G_StopDemo(void); boolean G_CheckDemoStatus(void); +extern UINT32 gametypedefaultrules[NUMGAMETYPES]; +extern UINT32 gametypetol[NUMGAMETYPES]; +extern INT16 gametyperankings[NUMGAMETYPES]; + +void G_SetGametype(INT16 gametype); +INT16 G_AddGametype(UINT32 rules); +void G_AddGametypeConstant(INT16 gtype, const char *newgtconst); +void G_UpdateGametypeSelections(void); +void G_AddTOL(UINT32 newtol, const char *tolname); +void G_AddGametypeTOL(INT16 gtype, UINT32 newtol); +void G_SetGametypeDescription(INT16 gtype, char *descriptiontext, UINT8 leftcolor, UINT8 rightcolor); + +INT32 G_GetGametypeByName(const char *gametypestr); boolean G_IsSpecialStage(INT32 mapnum); boolean G_GametypeUsesLives(void); +boolean G_GametypeUsesCoopLives(void); +boolean G_GametypeUsesCoopStarposts(void); boolean G_GametypeHasTeams(void); boolean G_GametypeHasSpectators(void); boolean G_RingSlingerGametype(void); boolean G_PlatformGametype(void); boolean G_TagGametype(void); +boolean G_CompetitionGametype(void); +boolean G_EnoughPlayersFinished(void); void G_ExitLevel(void); void G_NextLevel(void); void G_Continue(void); @@ -185,10 +271,14 @@ void G_AddPlayer(INT32 playernum); void G_SetExitGameFlag(void); void G_ClearExitGameFlag(void); boolean G_GetExitGameFlag(void); + void G_SetRetryFlag(void); void G_ClearRetryFlag(void); boolean G_GetRetryFlag(void); +void G_SetModeAttackRetryFlag(void); +void G_ClearModeAttackRetryFlag(void); +boolean G_GetModeAttackRetryFlag(void); void G_LoadGameData(void); void G_LoadGameSettings(void); @@ -219,6 +309,6 @@ FUNCMATH INT32 G_TicsToCentiseconds(tic_t tics); FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); // Don't split up TOL handling -INT16 G_TOLFlag(INT32 pgametype); +UINT32 G_TOLFlag(INT32 pgametype); #endif diff --git a/src/g_input.c b/src/g_input.c index 796235559..ecce4d83c 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -45,6 +45,48 @@ UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control INT32 gamecontrol[num_gamecontrols][2]; INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player +INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention +INT32 gamecontrolbisdefault[num_gamecontrolschemes][num_gamecontrols][2]; + +// lists of GC codes for selective operation +const INT32 gcl_tutorial_check[num_gcl_tutorial_check] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight, + gc_turnleft, gc_turnright +}; + +const INT32 gcl_tutorial_used[num_gcl_tutorial_used] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight, + gc_turnleft, gc_turnright, + gc_jump, gc_use +}; + +const INT32 gcl_tutorial_full[num_gcl_tutorial_full] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight, + gc_lookup, gc_lookdown, gc_turnleft, gc_turnright, gc_centerview, + gc_jump, gc_use, + gc_fire, gc_firenormal +}; + +const INT32 gcl_movement[num_gcl_movement] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight +}; + +const INT32 gcl_camera[num_gcl_camera] = { + gc_turnleft, gc_turnright +}; + +const INT32 gcl_movement_camera[num_gcl_movement_camera] = { + gc_forward, gc_backward, gc_strafeleft, gc_straferight, + gc_turnleft, gc_turnright +}; + +const INT32 gcl_jump[num_gcl_jump] = { gc_jump }; + +const INT32 gcl_use[num_gcl_use] = { gc_use }; + +const INT32 gcl_jump_use[num_gcl_jump_use] = { + gc_jump, gc_use +}; typedef struct { @@ -208,11 +250,9 @@ static keyname_t keynames[] = {KEY_SCROLLLOCK, "SCROLLLOCK"}, // bill gates keys -#ifndef _arch_dreamcast {KEY_LEFTWIN, "LEFTWIN"}, {KEY_RIGHTWIN, "RIGHTWIN"}, {KEY_MENU, "MENU"}, -#endif {KEY_LSHIFT, "LSHIFT"}, {KEY_RSHIFT, "RSHIFT"}, @@ -274,140 +314,24 @@ static keyname_t keynames[] = {KEY_MOUSE1+0,"MOUSE1"}, {KEY_MOUSE1+1,"MOUSE2"}, {KEY_MOUSE1+2,"MOUSE3"}, -#if !defined (_arch_dreamcast) && !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_MOUSE1+3,"MOUSE4"}, {KEY_MOUSE1+4,"MOUSE5"}, {KEY_MOUSE1+5,"MOUSE6"}, {KEY_MOUSE1+6,"MOUSE7"}, {KEY_MOUSE1+7,"MOUSE8"}, -#endif {KEY_2MOUSE1+0,"SEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 {KEY_2MOUSE1+1,"SEC_MOUSE1"}, {KEY_2MOUSE1+2,"SEC_MOUSE3"}, -#if !defined (_arch_dreamcast) && !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_2MOUSE1+3,"SEC_MOUSE4"}, {KEY_2MOUSE1+4,"SEC_MOUSE5"}, {KEY_2MOUSE1+5,"SEC_MOUSE6"}, {KEY_2MOUSE1+6,"SEC_MOUSE7"}, {KEY_2MOUSE1+7,"SEC_MOUSE8"}, -#endif {KEY_MOUSEWHEELUP, "Wheel 1 UP"}, {KEY_MOUSEWHEELDOWN, "Wheel 1 Down"}, {KEY_2MOUSEWHEELUP, "Wheel 2 UP"}, {KEY_2MOUSEWHEELDOWN, "Wheel 2 Down"}, -#ifdef DC - {KEY_JOY1+0, "JOYC"}, - {KEY_JOY1+1, "JOYB"}, - {KEY_JOY1+2, "JOYA"}, - {KEY_JOY1+3, "JOYS"}, - {KEY_JOY1+4, "JOYZ"}, - {KEY_JOY1+5, "JOYY"}, - {KEY_JOY1+6, "JOYX"}, - {KEY_JOY1+7, "JOYD"}, -#elif defined (_XBOX) - {KEY_JOY1+0, "JOYA"}, - {KEY_JOY1+1, "JOYB"}, - {KEY_JOY1+2, "JOYX"}, - {KEY_JOY1+3, "JOYY"}, - {KEY_JOY1+4, "JOYG"}, - {KEY_JOY1+5, "JOYW"}, - {KEY_JOY1+6, "JOYL"}, - {KEY_JOY1+7, "JOYR"}, - {KEY_JOY1+8, "JOYS"}, - {KEY_JOY1+9, "JOYN"}, - {KEY_JOY1+10,"JOYW"}, - {KEY_JOY1+11,"JOYE"}, -#define NOMOREJOYBTN_1S -#elif defined (_PSP) - {KEY_JOY1+0, "TRIANGLE"}, - {KEY_JOY1+1, "CIRCLE" }, - {KEY_JOY1+2, "CROSS" }, - {KEY_JOY1+3, "SQUARE" }, - {KEY_JOY1+4, "LTRIGGER"}, - {KEY_JOY1+5, "RTRIGGER"}, - {KEY_JOY1+6, "SELECT" }, - {KEY_JOY1+7, "START" }, - {KEY_JOY1+8, "HOME" }, - {KEY_JOY1+9, "HOLD" }, -#define NOMOREJOYBTN_1S -#elif defined (GP2X) - {KEY_JOY1+0, "JOYA"}, - {KEY_JOY1+1, "JOYY"}, - {KEY_JOY1+2, "JOYB"}, - {KEY_JOY1+3, "JOYX"}, - {KEY_JOY1+4, "JOYL"}, - {KEY_JOY1+5, "JOYR"}, - {KEY_JOY1+6, "JOYVOLUP"}, - {KEY_JOY1+7, "JOYVOLDOWN"}, - {KEY_JOY1+8, "JOYSELECT"}, -#elif defined (_NDS) - {KEY_JOY1+0, "JOYA"}, - {KEY_JOY1+1, "JOYB"}, - {KEY_JOY1+2, "JOYX"}, - {KEY_JOY1+3, "JOYY"}, - {KEY_JOY1+4, "JOYL"}, - {KEY_JOY1+5, "JOYR"}, - {KEY_JOY1+6, "JOYSTART"}, - {KEY_JOY1+7, "JOYSELECT"}, -#define NOMOREJOYBTN_1S -#elif defined (WMINPUT) - {KEY_JOY1+0, "JOYB"}, - {KEY_JOY1+1, "JOYA"}, - {KEY_JOY1+2, "JOYUP"}, - {KEY_JOY1+3, "JOYDOWN"}, - {KEY_JOY1+4, "JOYLEFT"}, - {KEY_JOY1+5, "JOYRIGHT"}, - {KEY_JOY1+6, "JOYAA"}, - {KEY_JOY1+7, "JOYBB"}, - {KEY_JOY1+8, "JOYCC"}, - {KEY_JOY1+9, "JOYXX"}, - {KEY_JOY1+10, "JOYYY"}, - {KEY_JOY1+11, "JOYZZ"}, - {KEY_JOY1+12, "JOYL"}, - {KEY_JOY1+13, "JOYR"}, - {KEY_JOY1+14, "JOYZL"}, - {KEY_JOY1+15, "JOYZR"}, - {KEY_JOY1+16, "JOYSELECT"}, - {KEY_JOY1+17, "JOYSTART"}, - {KEY_JOY1+18, "JOYHOME"}, - {KEY_JOY1+19, "JOYMINUS"}, - {KEY_JOY1+20, "JOYPLUS"}, - {KEY_JOY1+21, "JOY_1"}, - {KEY_JOY1+22, "JOY_2"}, - {KEY_JOY1+23, "JOY24"}, - {KEY_JOY1+24, "JOY25"}, - {KEY_JOY1+25, "JOY26"}, - {KEY_JOY1+26, "JOY27"}, - {KEY_JOY1+27, "JOY28"}, - {KEY_JOY1+28, "JOY29"}, - {KEY_JOY1+29, "JOY30"}, - {KEY_JOY1+30, "JOY31"}, - {KEY_JOY1+31, "JOY32"}, -#define NOMOREJOYBTN_1S -#elif defined (_WII) - {KEY_JOY1+0, "JOYA"}, - {KEY_JOY1+1, "JOYB"}, - {KEY_JOY1+2, "JOY1"}, - {KEY_JOY1+3, "JOY2"}, - {KEY_JOY1+4, "JOYMINUS"}, - {KEY_JOY1+5, "JOYPLUS"}, - {KEY_JOY1+6, "JOYHOME"}, - {KEY_JOY1+7, "JOYZ"}, - {KEY_JOY1+8, "JOYC"}, - {KEY_JOY1+9, "JOYA_CC"}, - {KEY_JOY1+10, "JOYB_CC"}, - {KEY_JOY1+11, "JOYX"}, - {KEY_JOY1+12, "JOYY"}, - {KEY_JOY1+13, "JOYL"}, - {KEY_JOY1+14, "JOYR"}, - {KEY_JOY1+15, "JOYZL"}, - {KEY_JOY1+16, "JOYZR"}, - {KEY_JOY1+17, "JOYMINUS_CC"}, - {KEY_JOY1+18, "JOYHPLUS_CC"}, - {KEY_JOY1+19, "JOYMHOME_CC"}, -#define NOMOREJOYBTN_1S -#else {KEY_JOY1+0, "JOY1"}, {KEY_JOY1+1, "JOY2"}, {KEY_JOY1+2, "JOY3"}, @@ -417,8 +341,7 @@ static keyname_t keynames[] = {KEY_JOY1+6, "JOY7"}, {KEY_JOY1+7, "JOY8"}, {KEY_JOY1+8, "JOY9"}, -#endif -#if !defined (_arch_dreamcast) && !defined (NOMOREJOYBTN_1S) +#if !defined (NOMOREJOYBTN_1S) // we use up to 32 buttons in DirectInput {KEY_JOY1+9, "JOY10"}, {KEY_JOY1+10, "JOY11"}, @@ -449,12 +372,10 @@ static keyname_t keynames[] = {KEY_HAT1+1, "HATDOWN"}, {KEY_HAT1+2, "HATLEFT"}, {KEY_HAT1+3, "HATRIGHT"}, -#if !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_HAT1+4, "HATUP2"}, {KEY_HAT1+5, "HATDOWN2"}, {KEY_HAT1+6, "HATLEFT2"}, {KEY_HAT1+7, "HATRIGHT2"}, -#ifndef _arch_dreamcast {KEY_HAT1+8, "HATUP3"}, {KEY_HAT1+9, "HATDOWN3"}, {KEY_HAT1+10, "HATLEFT3"}, @@ -463,142 +384,24 @@ static keyname_t keynames[] = {KEY_HAT1+13, "HATDOWN4"}, {KEY_HAT1+14, "HATLEFT4"}, {KEY_HAT1+15, "HATRIGHT4"}, -#endif -#endif {KEY_DBLMOUSE1+0, "DBLMOUSE1"}, {KEY_DBLMOUSE1+1, "DBLMOUSE2"}, {KEY_DBLMOUSE1+2, "DBLMOUSE3"}, -#if !defined (_arch_dreamcast) && !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_DBLMOUSE1+3, "DBLMOUSE4"}, {KEY_DBLMOUSE1+4, "DBLMOUSE5"}, {KEY_DBLMOUSE1+5, "DBLMOUSE6"}, {KEY_DBLMOUSE1+6, "DBLMOUSE7"}, {KEY_DBLMOUSE1+7, "DBLMOUSE8"}, -#endif {KEY_DBL2MOUSE1+0, "DBLSEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 {KEY_DBL2MOUSE1+1, "DBLSEC_MOUSE1"}, {KEY_DBL2MOUSE1+2, "DBLSEC_MOUSE3"}, -#if !defined (_arch_dreamcast) && !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_DBL2MOUSE1+3, "DBLSEC_MOUSE4"}, {KEY_DBL2MOUSE1+4, "DBLSEC_MOUSE5"}, {KEY_DBL2MOUSE1+5, "DBLSEC_MOUSE6"}, {KEY_DBL2MOUSE1+6, "DBLSEC_MOUSE7"}, {KEY_DBL2MOUSE1+7, "DBLSEC_MOUSE8"}, -#endif -#ifdef DC - {KEY_DBLJOY1+0, "DBLJOYC"}, - {KEY_DBLJOY1+1, "DBLJOYB"}, - {KEY_DBLJOY1+2, "DBLJOYA"}, - {KEY_DBLJOY1+3, "DBLJOYS"}, - {KEY_DBLJOY1+4, "DBLJOYZ"}, - {KEY_DBLJOY1+5, "DBLJOYY"}, - {KEY_DBLJOY1+6, "DBLJOYX"}, - {KEY_DBLJOY1+7, "DBLJOYD"}, -#elif defined (_XBOX) - {KEY_DBLJOY1+0, "DBLJOYA"}, - {KEY_DBLJOY1+1, "DBLJOYB"}, - {KEY_DBLJOY1+2, "DBLJOYX"}, - {KEY_DBLJOY1+3, "DBLJOYY"}, - {KEY_DBLJOY1+4, "DBLJOYG"}, - {KEY_DBLJOY1+5, "DBLJOYW"}, - {KEY_DBLJOY1+6, "DBLJOYL"}, - {KEY_DBLJOY1+7, "DBLJOYR"}, - {KEY_DBLJOY1+8, "DBLJOYS"}, - {KEY_DBLJOY1+9, "DBLJOYN"}, - {KEY_DBLJOY1+10,"DBLJOYW"}, - {KEY_DBLJOY1+11,"DBLJOYE"}, -#define NOMOREJOYBTN_1DBL -#elif defined (_PSP) - {KEY_DBLJOY1+0, "DBLTRIANGLE"}, - {KEY_DBLJOY1+1, "DBLCIRCLE" }, - {KEY_DBLJOY1+2, "DBLCROSS" }, - {KEY_DBLJOY1+3, "DBLSQUARE" }, - {KEY_DBLJOY1+4, "DBLLTRIGGER"}, - {KEY_DBLJOY1+5, "DBLRTRIGGER"}, - {KEY_DBLJOY1+6, "DBLSELECT" }, - {KEY_DBLJOY1+7, "DBLSTART" }, - {KEY_DBLJOY1+8, "DBLHOME" }, - {KEY_DBLJOY1+9, "DBLHOLD" }, -#elif defined (GP2X) - {KEY_DBLJOY1+0, "DBLJOYA"}, - {KEY_DBLJOY1+1, "DBLJOYY"}, - {KEY_DBLJOY1+2, "DBLJOYB"}, - {KEY_DBLJOY1+3, "DBLJOYX"}, - {KEY_DBLJOY1+4, "DBLJOYL"}, - {KEY_DBLJOY1+5, "DBLJOYR"}, - {KEY_DBLJOY1+6, "DBLJOYVOLUP"}, - {KEY_DBLJOY1+7, "DBLJOYVOLDOWN"}, - {KEY_DBLJOY1+8, "DBLJOYSELECT"}, -#define NOMOREJOYBTN_1DBL -#elif defined (_NDS) - {KEY_DBLJOY1+0, "DBLJOYA"}, - {KEY_DBLJOY1+1, "DBLJOYB"}, - {KEY_DBLJOY1+2, "DBLJOYX"}, - {KEY_DBLJOY1+3, "DBLJOYY"}, - {KEY_DBLJOY1+4, "DBLJOYL"}, - {KEY_DBLJOY1+5, "DBLJOYR"}, - {KEY_DBLJOY1+6, "DBLJOYSTART"}, - {KEY_DBLJOY1+7, "DBLJOYSELECT"}, -#define NOMOREJOYBTN_1DBL -#elif defined (WMINPUT) - {KEY_DBLJOY1+0, "DBLJOYB"}, - {KEY_DBLJOY1+1, "DBLJOYA"}, - {KEY_DBLJOY1+2, "DBLJOYUP"}, - {KEY_DBLJOY1+3, "DBLJOYDOWN"}, - {KEY_DBLJOY1+4, "DBLJOYLEFT"}, - {KEY_DBLJOY1+5, "DBLJOYRIGHT"}, - {KEY_DBLJOY1+6, "DBLJOYAA"}, - {KEY_DBLJOY1+7, "DBLJOYBB"}, - {KEY_DBLJOY1+8, "DBLJOYCC"}, - {KEY_DBLJOY1+9, "DBLJOYXX"}, - {KEY_DBLJOY1+10, "DBLJOYYY"}, - {KEY_DBLJOY1+11, "DBLJOYZZ"}, - {KEY_DBLJOY1+12, "DBLJOYL"}, - {KEY_DBLJOY1+13, "DBLJOYR"}, - {KEY_DBLJOY1+14, "DBLJOYZL"}, - {KEY_DBLJOY1+15, "DBLJOYZR"}, - {KEY_DBLJOY1+16, "DBLJOYSELECT"}, - {KEY_DBLJOY1+17, "DBLJOYSTART"}, - {KEY_DBLJOY1+18, "DBLJOYHOME"}, - {KEY_DBLJOY1+19, "DBLJOYMINUS"}, - {KEY_DBLJOY1+20, "DBLJOYPLUS"}, - {KEY_DBLJOY1+21, "DBLJOY_1"}, - {KEY_DBLJOY1+22, "DBLJOY_2"}, - {KEY_DBLJOY1+23, "DBLJOY24"}, - {KEY_DBLJOY1+24, "DBLJOY25"}, - {KEY_DBLJOY1+25, "DBLJOY26"}, - {KEY_DBLJOY1+26, "DBLJOY27"}, - {KEY_DBLJOY1+27, "DBLJOY28"}, - {KEY_DBLJOY1+28, "DBLJOY29"}, - {KEY_DBLJOY1+29, "DBLJOY30"}, - {KEY_DBLJOY1+30, "DBLJOY31"}, - {KEY_DBLJOY1+31, "DBLJOY32"}, -#define NOMOREJOYBTN_1DBL -#elif defined (_WII) - {KEY_DBLJOY1+0, "DBLJOYA"}, - {KEY_DBLJOY1+1, "DBLJOYB"}, - {KEY_DBLJOY1+2, "DBLJOY1"}, - {KEY_DBLJOY1+3, "DBLJOY2"}, - {KEY_DBLJOY1+4, "DBLJOYMINUS"}, - {KEY_DBLJOY1+5, "DBLJOYPLUS"}, - {KEY_DBLJOY1+6, "DBLJOYHOME"}, - {KEY_DBLJOY1+7, "DBLJOYZ"}, - {KEY_DBLJOY1+8, "DBLJOYC"}, - {KEY_DBLJOY1+9, "DBLJOYA_CC"}, - {KEY_DBLJOY1+10, "DBLJOYB_CC"}, - {KEY_DBLJOY1+11, "DBLJOYX"}, - {KEY_DBLJOY1+12, "DBLJOYY"}, - {KEY_DBLJOY1+13, "DBLJOYL"}, - {KEY_DBLJOY1+14, "DBLJOYR"}, - {KEY_DBLJOY1+15, "DBLJOYZL"}, - {KEY_DBLJOY1+16, "DBLJOYZR"}, - {KEY_DBLJOY1+17, "DBLJOYMINUS_CC"}, - {KEY_DBLJOY1+18, "DBLJOYHPLUS_CC"}, - {KEY_DBLJOY1+19, "DBLJOYMHOME_CC"}, -#define NOMOREJOYBTN_1DBL -#else {KEY_DBLJOY1+0, "DBLJOY1"}, {KEY_DBLJOY1+1, "DBLJOY2"}, {KEY_DBLJOY1+2, "DBLJOY3"}, @@ -607,8 +410,7 @@ static keyname_t keynames[] = {KEY_DBLJOY1+5, "DBLJOY6"}, {KEY_DBLJOY1+6, "DBLJOY7"}, {KEY_DBLJOY1+7, "DBLJOY8"}, -#endif -#if !defined (_arch_dreamcast) && !defined (NOMOREJOYBTN_1DBL) +#if !defined (NOMOREJOYBTN_1DBL) {KEY_DBLJOY1+8, "DBLJOY9"}, {KEY_DBLJOY1+9, "DBLJOY10"}, {KEY_DBLJOY1+10, "DBLJOY11"}, @@ -638,12 +440,10 @@ static keyname_t keynames[] = {KEY_DBLHAT1+1, "DBLHATDOWN"}, {KEY_DBLHAT1+2, "DBLHATLEFT"}, {KEY_DBLHAT1+3, "DBLHATRIGHT"}, -#if !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_DBLHAT1+4, "DBLHATUP2"}, {KEY_DBLHAT1+5, "DBLHATDOWN2"}, {KEY_DBLHAT1+6, "DBLHATLEFT2"}, {KEY_DBLHAT1+7, "DBLHATRIGHT2"}, -#ifndef _arch_dreamcast {KEY_DBLHAT1+8, "DBLHATUP3"}, {KEY_DBLHAT1+9, "DBLHATDOWN3"}, {KEY_DBLHAT1+10, "DBLHATLEFT3"}, @@ -652,101 +452,7 @@ static keyname_t keynames[] = {KEY_DBLHAT1+13, "DBLHATDOWN4"}, {KEY_DBLHAT1+14, "DBLHATLEFT4"}, {KEY_DBLHAT1+15, "DBLHATRIGHT4"}, -#endif -#endif -#ifdef DC - {KEY_2JOY1+0, "SEC_JOYC"}, - {KEY_2JOY1+1, "SEC_JOYB"}, - {KEY_2JOY1+2, "SEC_JOYA"}, - {KEY_2JOY1+3, "SEC_JOYS"}, - {KEY_2JOY1+4, "SEC_JOYZ"}, - {KEY_2JOY1+5, "SEC_JOYY"}, - {KEY_2JOY1+6, "SEC_JOYX"}, - {KEY_2JOY1+7, "SEC_JOYD"}, -#elif defined (_XBOX) - {KEY_2JOY1+0, "SEC_JOYA"}, - {KEY_2JOY1+1, "SEC_JOYB"}, - {KEY_2JOY1+2, "SEC_JOYX"}, - {KEY_2JOY1+3, "SEC_JOYY"}, - {KEY_2JOY1+4, "SEC_JOYG"}, - {KEY_2JOY1+5, "SEC_JOYW"}, - {KEY_2JOY1+6, "SEC_JOYL"}, - {KEY_2JOY1+7, "SEC_JOYR"}, - {KEY_2JOY1+8, "SEC_JOYS"}, - {KEY_2JOY1+9, "SEC_JOYN"}, - {KEY_2JOY1+10,"SEC_JOYW"}, - {KEY_2JOY1+11,"SEC_JOYE"}, -#define NOMOREJOYBTN_2S -#elif defined (_PSP) - {KEY_2JOY1+0, "SEC_TRIANGLE"}, - {KEY_2JOY1+1, "SEC_CIRCLE" }, - {KEY_2JOY1+2, "SEC_CROSS" }, - {KEY_2JOY1+3, "SEC_SQUARE" }, - {KEY_2JOY1+4, "SEC_LTRIGGER"}, - {KEY_2JOY1+5, "SEC_RTRIGGER"}, - {KEY_2JOY1+6, "SEC_SELECT" }, - {KEY_2JOY1+7, "SEC_START" }, - {KEY_2JOY1+8, "SEC_HOME" }, - {KEY_2JOY1+9, "SEC_HOLD" }, -#define NOMOREJOYBTN_2S -#elif defined (WMINPUT) - {KEY_2JOY1+0, "SEC_JOYB"}, - {KEY_2JOY1+1, "SEC_JOYA"}, - {KEY_2JOY1+2, "SEC_JOYUP"}, - {KEY_2JOY1+3, "SEC_JOYDOWN"}, - {KEY_2JOY1+4, "SEC_JOYLEFT"}, - {KEY_2JOY1+5, "SEC_JOYRIGHT"}, - {KEY_2JOY1+6, "SEC_JOYAA"}, - {KEY_2JOY1+7, "SEC_JOYBB"}, - {KEY_2JOY1+8, "SEC_JOYCC"}, - {KEY_2JOY1+9, "SEC_JOYXX"}, - {KEY_2JOY1+10, "SEC_JOYYY"}, - {KEY_2JOY1+11, "SEC_JOYZZ"}, - {KEY_2JOY1+12, "SEC_JOYL"}, - {KEY_2JOY1+13, "SEC_JOYR"}, - {KEY_2JOY1+14, "SEC_JOYZL"}, - {KEY_2JOY1+15, "SEC_JOYZR"}, - {KEY_2JOY1+16, "SEC_JOYSELECT"}, - {KEY_2JOY1+17, "SEC_JOYSTART"}, - {KEY_2JOY1+18, "SEC_JOYHOME"}, - {KEY_2JOY1+19, "SEC_JOYMINUS"}, - {KEY_2JOY1+20, "SEC_JOYPLUS"}, - {KEY_2JOY1+21, "SEC_JOY_1"}, - {KEY_2JOY1+22, "SEC_JOY_2"}, - {KEY_2JOY1+23, "SEC_JOY24"}, - {KEY_2JOY1+24, "SEC_JOY25"}, - {KEY_2JOY1+25, "SEC_JOY26"}, - {KEY_2JOY1+26, "SEC_JOY27"}, - {KEY_2JOY1+27, "SEC_JOY28"}, - {KEY_2JOY1+28, "SEC_JOY29"}, - {KEY_2JOY1+29, "SEC_JOY30"}, - {KEY_2JOY1+30, "SEC_JOY31"}, - {KEY_2JOY1+31, "SEC_JOY32"}, -#define NOMOREJOYBTN_2S -#elif defined (_WII) - {KEY_2JOY1+0, "SEC_JOYA"}, - {KEY_2JOY1+1, "SEC_JOYB"}, - {KEY_2JOY1+2, "SEC_JOY1"}, - {KEY_2JOY1+3, "SEC_JOY2"}, - {KEY_2JOY1+4, "SEC_JOYMINUS"}, - {KEY_2JOY1+5, "SEC_JOYPLUS"}, - {KEY_2JOY1+6, "SEC_JOYHOME"}, - {KEY_2JOY1+7, "SEC_JOYZ"}, - {KEY_2JOY1+8, "SEC_JOYC"}, - {KEY_2JOY1+9, "SEC_JOYA_CC"}, - {KEY_2JOY1+10, "SEC_JOYB_CC"}, - {KEY_2JOY1+11, "SEC_JOYX"}, - {KEY_2JOY1+12, "SEC_JOYY"}, - {KEY_2JOY1+13, "SEC_JOYL"}, - {KEY_2JOY1+14, "SEC_JOYR"}, - {KEY_2JOY1+15, "SEC_JOYZL"}, - {KEY_2JOY1+16, "SEC_JOYZR"}, - {KEY_2JOY1+17, "SEC_JOYMINUS_CC"}, - {KEY_2JOY1+18, "SEC_JOYHPLUS_CC"}, - {KEY_2JOY1+19, "SEC_JOYMHOME_CC"}, -#define NOMOREJOYBTN_2S -#else {KEY_2JOY1+0, "SEC_JOY1"}, {KEY_2JOY1+1, "SEC_JOY2"}, {KEY_2JOY1+2, "SEC_JOY3"}, @@ -755,8 +461,7 @@ static keyname_t keynames[] = {KEY_2JOY1+5, "SEC_JOY6"}, {KEY_2JOY1+6, "SEC_JOY7"}, {KEY_2JOY1+7, "SEC_JOY8"}, -#endif -#if !defined (_arch_dreamcast) && !defined (NOMOREJOYBTN_2S) +#if !defined (NOMOREJOYBTN_2S) // we use up to 32 buttons in DirectInput {KEY_2JOY1+8, "SEC_JOY9"}, {KEY_2JOY1+9, "SEC_JOY10"}, @@ -788,12 +493,10 @@ static keyname_t keynames[] = {KEY_2HAT1+1, "SEC_HATDOWN"}, {KEY_2HAT1+2, "SEC_HATLEFT"}, {KEY_2HAT1+3, "SEC_HATRIGHT"}, -#if !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_2HAT1+4, "SEC_HATUP2"}, {KEY_2HAT1+5, "SEC_HATDOWN2"}, {KEY_2HAT1+6, "SEC_HATLEFT2"}, {KEY_2HAT1+7, "SEC_HATRIGHT2"}, -#ifndef _arch_dreamcast {KEY_2HAT1+8, "SEC_HATUP3"}, {KEY_2HAT1+9, "SEC_HATDOWN3"}, {KEY_2HAT1+10, "SEC_HATLEFT3"}, @@ -802,101 +505,7 @@ static keyname_t keynames[] = {KEY_2HAT1+13, "SEC_HATDOWN4"}, {KEY_2HAT1+14, "SEC_HATLEFT4"}, {KEY_2HAT1+15, "SEC_HATRIGHT4"}, -#endif -#endif -#ifdef DC - {KEY_DBL2JOY1+0, "DBLSEC_JOYC"}, - {KEY_DBL2JOY1+1, "DBLSEC_JOYB"}, - {KEY_DBL2JOY1+2, "DBLSEC_JOYA"}, - {KEY_DBL2JOY1+3, "DBLSEC_JOYS"}, - {KEY_DBL2JOY1+4, "DBLSEC_JOYZ"}, - {KEY_DBL2JOY1+5, "DBLSEC_JOYY"}, - {KEY_DBL2JOY1+6, "DBLSEC_JOYX"}, - {KEY_DBL2JOY1+7, "DBLSEC_JOYD"}, -#elif defined (_XBOX) - {KEY_DBL2JOY1+0, "DBLSEC_JOYA"}, - {KEY_DBL2JOY1+1, "DBLSEC_JOYB"}, - {KEY_DBL2JOY1+2, "DBLSEC_JOYX"}, - {KEY_DBL2JOY1+3, "DBLSEC_JOYY"}, - {KEY_DBL2JOY1+4, "DBLSEC_JOYG"}, - {KEY_DBL2JOY1+5, "DBLSEC_JOYW"}, - {KEY_DBL2JOY1+6, "DBLSEC_JOYL"}, - {KEY_DBL2JOY1+7, "DBLSEC_JOYR"}, - {KEY_DBL2JOY1+8, "DBLSEC_JOYS"}, - {KEY_DBL2JOY1+9, "DBLSEC_JOYN"}, - {KEY_DBL2JOY1+10,"DBLSEC_JOYW"}, - {KEY_DBL2JOY1+11,"DBLSEC_JOYE"}, -#define NOMOREJOYBTN_2DBL -#elif defined (_PSP) - {KEY_DBL2JOY1+0, "DBLSEC_TRIANGLE"}, - {KEY_DBL2JOY1+1, "DBLSEC_CIRCLE" }, - {KEY_DBL2JOY1+2, "DBLSEC_CROSS" }, - {KEY_DBL2JOY1+3, "DBLSEC_SQUARE" }, - {KEY_DBL2JOY1+4, "DBLSEC_LTRIGGER"}, - {KEY_DBL2JOY1+5, "DBLSEC_RTRIGGER"}, - {KEY_DBL2JOY1+6, "DBLSEC_SELECT" }, - {KEY_DBL2JOY1+7, "DBLSEC_START" }, - {KEY_DBL2JOY1+8, "DBLSEC_HOME" }, - {KEY_DBL2JOY1+9, "DBLSEC_HOLD" }, -#define NOMOREJOYBTN_2DBL -#elif defined (WMINPUT) - {KEY_DBL2JOY1+0, "DBLSEC_JOYB"}, - {KEY_DBL2JOY1+1, "DBLSEC_JOYA"}, - {KEY_DBL2JOY1+2, "DBLSEC_JOYUP"}, - {KEY_DBL2JOY1+3, "DBLSEC_JOYDOWN"}, - {KEY_DBL2JOY1+4, "DBLSEC_JOYLEFT"}, - {KEY_DBL2JOY1+5, "DBLSEC_JOYRIGHT"}, - {KEY_DBL2JOY1+6, "DBLSEC_JOYAA"}, - {KEY_DBL2JOY1+7, "DBLSEC_JOYBB"}, - {KEY_DBL2JOY1+8, "DBLSEC_JOYCC"}, - {KEY_DBL2JOY1+9, "DBLSEC_JOYXX"}, - {KEY_DBL2JOY1+10, "DBLSEC_JOYYY"}, - {KEY_DBL2JOY1+11, "DBLSEC_JOYZZ"}, - {KEY_DBL2JOY1+12, "DBLSEC_JOYL"}, - {KEY_DBL2JOY1+13, "DBLSEC_JOYR"}, - {KEY_DBL2JOY1+14, "DBLSEC_JOYZL"}, - {KEY_DBL2JOY1+15, "DBLSEC_JOYZR"}, - {KEY_DBL2JOY1+16, "DBLSEC_JOYSELECT"}, - {KEY_DBL2JOY1+17, "DBLSEC_JOYSTART"}, - {KEY_DBL2JOY1+18, "DBLSEC_JOYHOME"}, - {KEY_DBL2JOY1+19, "DBLSEC_JOYMINUS"}, - {KEY_DBL2JOY1+20, "DBLSEC_JOYPLUS"}, - {KEY_DBL2JOY1+21, "DBLSEC_JOY_1"}, - {KEY_DBL2JOY1+22, "DBLSEC_JOY_2"}, - {KEY_DBL2JOY1+23, "DBLSEC_JOY24"}, - {KEY_DBL2JOY1+24, "DBLSEC_JOY25"}, - {KEY_DBL2JOY1+25, "DBLSEC_JOY26"}, - {KEY_DBL2JOY1+26, "DBLSEC_JOY27"}, - {KEY_DBL2JOY1+27, "DBLSEC_JOY28"}, - {KEY_DBL2JOY1+28, "DBLSEC_JOY29"}, - {KEY_DBL2JOY1+29, "DBLSEC_JOY30"}, - {KEY_DBL2JOY1+30, "DBLSEC_JOY31"}, - {KEY_DBL2JOY1+31, "DBLSEC_JOY32"}, -#define NOMOREJOYBTN_2SDBL -#elif defined (_WII) - {KEY_DBL2JOY1+0, "DBLSEC_JOYA"}, - {KEY_DBL2JOY1+1, "DBLSEC_JOYB"}, - {KEY_DBL2JOY1+2, "DBLSEC_JOY1"}, - {KEY_DBL2JOY1+3, "DBLSEC_JOY2"}, - {KEY_DBL2JOY1+4, "DBLSEC_JOYMINUS"}, - {KEY_DBL2JOY1+5, "DBLSEC_JOYPLUS"}, - {KEY_DBL2JOY1+6, "DBLSEC_JOYHOME"}, - {KEY_DBL2JOY1+7, "DBLSEC_JOYZ"}, - {KEY_DBL2JOY1+8, "DBLSEC_JOYC"}, - {KEY_DBL2JOY1+9, "DBLSEC_JOYA_CC"}, - {KEY_DBL2JOY1+10, "DBLSEC_JOYB_CC"}, - {KEY_DBL2JOY1+11, "DBLSEC_JOYX"}, - {KEY_DBL2JOY1+12, "DBLSEC_JOYY"}, - {KEY_DBL2JOY1+13, "DBLSEC_JOYL"}, - {KEY_DBL2JOY1+14, "DBLSEC_JOYR"}, - {KEY_DBL2JOY1+15, "DBLSEC_JOYZL"}, - {KEY_DBL2JOY1+16, "DBLSEC_JOYZR"}, - {KEY_DBL2JOY1+17, "DBLSEC_JOYMINUS_CC"}, - {KEY_DBL2JOY1+18, "DBLSEC_JOYHPLUS_CC"}, - {KEY_DBL2JOY1+19, "DBLSEC_JOYMHOME_CC"}, -#define NOMOREJOYBTN_2DBL -#else {KEY_DBL2JOY1+0, "DBLSEC_JOY1"}, {KEY_DBL2JOY1+1, "DBLSEC_JOY2"}, {KEY_DBL2JOY1+2, "DBLSEC_JOY3"}, @@ -905,8 +514,7 @@ static keyname_t keynames[] = {KEY_DBL2JOY1+5, "DBLSEC_JOY6"}, {KEY_DBL2JOY1+6, "DBLSEC_JOY7"}, {KEY_DBL2JOY1+7, "DBLSEC_JOY8"}, -#endif -#if !defined (_arch_dreamcast) && !defined (NOMOREJOYBTN_2DBL) +#if !defined (NOMOREJOYBTN_2DBL) {KEY_DBL2JOY1+8, "DBLSEC_JOY9"}, {KEY_DBL2JOY1+9, "DBLSEC_JOY10"}, {KEY_DBL2JOY1+10, "DBLSEC_JOY11"}, @@ -936,12 +544,10 @@ static keyname_t keynames[] = {KEY_DBL2HAT1+1, "DBLSEC_HATDOWN"}, {KEY_DBL2HAT1+2, "DBLSEC_HATLEFT"}, {KEY_DBL2HAT1+3, "DBLSEC_HATRIGHT"}, -#if !defined (_XBOX) && !defined (_PSP) && !defined (_WII) {KEY_DBL2HAT1+4, "DBLSEC_HATUP2"}, {KEY_DBL2HAT1+5, "DBLSEC_HATDOWN2"}, {KEY_DBL2HAT1+6, "DBLSEC_HATLEFT2"}, {KEY_DBL2HAT1+7, "DBLSEC_HATRIGHT2"}, -#ifndef _arch_dreamcast {KEY_DBL2HAT1+8, "DBLSEC_HATUP3"}, {KEY_DBL2HAT1+9, "DBLSEC_HATDOWN3"}, {KEY_DBL2HAT1+10, "DBLSEC_HATLEFT3"}, @@ -950,8 +556,6 @@ static keyname_t keynames[] = {KEY_DBL2HAT1+13, "DBLSEC_HATDOWN4"}, {KEY_DBL2HAT1+14, "DBLSEC_HATLEFT4"}, {KEY_DBL2HAT1+15, "DBLSEC_HATRIGHT4"}, -#endif -#endif }; @@ -981,8 +585,6 @@ static const char *gamecontrolname[num_gamecontrols] = "tossflag", "use", "camtoggle", - "camleft", - "camright", "camreset", "lookup", "lookdown", @@ -1060,7 +662,13 @@ INT32 G_KeyStringtoNum(const char *keystr) return keystr[0]; if (!strncmp(keystr, "KEY", 3) && keystr[3] >= '0' && keystr[3] <= '9') - return atoi(&keystr[3]); + { + /* what if we out of range bruh? */ + j = atoi(&keystr[3]); + if (j < NUMINPUTS) + return j; + return 0; + } for (j = 0; j < NUMKEYNAMES; j++) if (!stricmp(keynames[j].name, keystr)) @@ -1069,260 +677,150 @@ INT32 G_KeyStringtoNum(const char *keystr) return 0; } -#ifdef DC -void G_Controldefault(void) +void G_DefineDefaultControls(void) { - gamecontrol[gc_forward ][0] = KEY_HAT1+0; //Up - gamecontrol[gc_forward ][1] = KEY_UPARROW; - gamecontrol[gc_backward ][0] = KEY_HAT1+1; //Down - gamecontrol[gc_backward ][1] = KEY_DOWNARROW; - //gamecontrol[gc_straferight][0] = '['; - //gamecontrol[gc_strafeleft ][0] = ']'; - gamecontrol[gc_turnleft ][0] = KEY_HAT1+2; //Left - gamecontrol[gc_turnleft ][1] = KEY_LEFTARROW; - gamecontrol[gc_turnright ][0] = KEY_HAT1+3; //Right - gamecontrol[gc_turnright ][1] = KEY_RIGHTARROW; - gamecontrol[gc_weaponnext ][0] = ']'; - gamecontrol[gc_weaponprev ][0] = '['; - gamecontrol[gc_fire ][0] = KEY_JOY1+6; //X - gamecontrol[gc_fire ][1] = KEY_RCTRL; - gamecontrol[gc_firenormal ][0] = KEY_JOY1+5; //Y - gamecontrol[gc_firenormal ][1] = ';'; - gamecontrol[gc_tossflag ][0] = '\''; - gamecontrol[gc_use ][0] = KEY_JOY1+1; //B - gamecontrol[gc_use ][1] = '.'; - gamecontrol[gc_camtoggle ][1] = ','; - gamecontrol[gc_camleft ][0] = 'o'; - gamecontrol[gc_camright ][0] = 'p'; - gamecontrol[gc_camreset ][0] = 'c'; - gamecontrol[gc_lookup ][0] = KEY_PGUP; - gamecontrol[gc_lookdown ][0] = KEY_PGDN; - gamecontrol[gc_centerview ][0] = KEY_END; - gamecontrol[gc_mouseaiming][0] = 's'; - gamecontrol[gc_talkkey ][0] = 't'; - gamecontrol[gc_teamkey ][0] = 'y'; - gamecontrol[gc_scores ][0] = KEY_TAB; - gamecontrol[gc_jump ][0] = KEY_JOY1+2; //A - gamecontrol[gc_jump ][1] = '/'; - gamecontrol[gc_console ][0] = KEY_CONSOLE; - gamecontrol[gc_console ][1] = KEY_F5; - //gamecontrolbis - gamecontrolbis[gc_forward ][0] = KEY_2HAT1+0; - gamecontrolbis[gc_forward ][1] = 'w'; - gamecontrolbis[gc_backward ][0] = KEY_2HAT1+1; - gamecontrolbis[gc_backward ][1] = 's'; - gamecontrolbis[gc_turnleft ][0] = KEY_2HAT1+2; - gamecontrolbis[gc_turnleft ][1] = 'a'; - gamecontrolbis[gc_turnright ][0] = KEY_2HAT1+3; - gamecontrolbis[gc_turnright ][1] = 'd'; - gamecontrolbis[gc_weaponnext][0] = 't'; - gamecontrolbis[gc_weaponprev][0] = 'r'; - gamecontrolbis[gc_fire ][0] = KEY_2JOY1+6; //X - gamecontrolbis[gc_firenormal][0] = KEY_2JOY1+5; //Y - gamecontrolbis[gc_use ][0] = KEY_2JOY1+1; //B - gamecontrolbis[gc_jump ][0] = KEY_2JOY1+2; //A - //gamecontrolbis[gc_straferight][0] = 'x'; - //gamecontrolbis[gc_strafeleft ][0] = 'z'; -} -#elif defined (_PSP) -void G_Controldefault(void) -{ - gamecontrol[gc_forward ][0] = KEY_HAT1+0; // Up - gamecontrol[gc_backward ][0] = KEY_HAT1+1; // Down - gamecontrol[gc_turnleft ][0] = KEY_HAT1+2; // Left - gamecontrol[gc_turnright ][0] = KEY_HAT1+3; // Right - gamecontrol[gc_strafeleft ][0] = KEY_JOY1+4; // L - gamecontrol[gc_straferight][0] = KEY_JOY1+5; // R - gamecontrol[gc_tossflag ][0] = KEY_JOY1+0; // Triangle - gamecontrol[gc_use ][0] = KEY_JOY1+1; // Circle - gamecontrol[gc_camtoggle ][0] = KEY_JOY1+6; // Select - gamecontrol[gc_camreset ][0] = KEY_JOY1+3; // Square - gamecontrol[gc_centerview ][0] = KEY_JOY1+9; // Hold - gamecontrol[gc_pause ][0] = KEY_JOY1+8; // Start - gamecontrol[gc_jump ][0] = KEY_JOY1+2; // Cross -} -#elif defined (GP2X) -void G_Controldefault(void) -{ - gamecontrol[gc_fire ][0] = KEY_JOY1+0; //A - gamecontrol[gc_forward ][0] = KEY_JOY1+1; //Y - gamecontrol[gc_jump ][0] = KEY_JOY1+2; //B - gamecontrol[gc_use ][0] = KEY_JOY1+3; //X - gamecontrol[gc_strafeleft ][0] = KEY_JOY1+4; //L - gamecontrol[gc_straferight][0] = KEY_JOY1+5; //R - gamecontrol[gc_lookup ][0] = KEY_JOY1+6; //U - gamecontrol[gc_lookdown ][0] = KEY_JOY1+7; //D - gamecontrol[gc_pause ][0] = KEY_JOY1+8; //S -} -#elif defined (_NDS) -void G_Controldefault(void) -{ - gamecontrol[gc_fire ][0] = KEY_JOY1+2; //X - gamecontrol[gc_forward ][0] = KEY_UPARROW; - gamecontrol[gc_backward ][0] = KEY_DOWNARROW; - gamecontrol[gc_jump ][0] = KEY_JOY1+0; //A - gamecontrol[gc_use ][0] = KEY_JOY1+3; //Y - gamecontrol[gc_strafeleft ][0] = KEY_JOY1+4; //L - gamecontrol[gc_straferight][0] = KEY_JOY1+5; //R - gamecontrol[gc_turnleft ][0] = KEY_LEFTARROW; - gamecontrol[gc_turnright ][0] = KEY_RIGHTARROW; - gamecontrol[gc_pause ][0] = KEY_JOY1+6; //Start - gamecontrol[gc_weaponnext ][0] = KEY_JOY1+7; //Select -} -#else -void G_Controldefault(void) -{ - gamecontrol[gc_forward ][0] = 'w'; - gamecontrol[gc_backward ][0] = 's'; - gamecontrol[gc_strafeleft ][0] = 'a'; - gamecontrol[gc_straferight][0] = 'd'; - gamecontrol[gc_turnleft ][0] = KEY_LEFTARROW; - gamecontrol[gc_turnright ][0] = KEY_RIGHTARROW; - gamecontrol[gc_weaponnext ][0] = 'e'; - gamecontrol[gc_weaponnext ][1] = KEY_JOY1+1; // B - gamecontrol[gc_weaponprev ][0] = 'q'; - gamecontrol[gc_weaponprev ][1] = KEY_JOY1+2; // X - gamecontrol[gc_wepslot1 ][0] = '1'; - gamecontrol[gc_wepslot2 ][0] = '2'; - gamecontrol[gc_wepslot3 ][0] = '3'; - gamecontrol[gc_wepslot4 ][0] = '4'; - gamecontrol[gc_wepslot5 ][0] = '5'; - gamecontrol[gc_wepslot6 ][0] = '6'; - gamecontrol[gc_wepslot7 ][0] = '7'; - gamecontrol[gc_wepslot8 ][0] = '8'; - gamecontrol[gc_wepslot9 ][0] = '9'; - gamecontrol[gc_wepslot10 ][0] = '0'; - gamecontrol[gc_fire ][0] = KEY_RCTRL; - gamecontrol[gc_fire ][1] = KEY_MOUSE1+0; - gamecontrol[gc_firenormal ][0] = 'c'; - gamecontrol[gc_tossflag ][0] = '\''; - gamecontrol[gc_tossflag ][1] = KEY_JOY1+0; // A - gamecontrol[gc_use ][0] = KEY_LSHIFT; - gamecontrol[gc_use ][1] = KEY_JOY1+4; // LB - gamecontrol[gc_camtoggle ][0] = 'v'; - gamecontrol[gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up - gamecontrol[gc_camleft ][0] = '['; - gamecontrol[gc_camright ][0] = ']'; - gamecontrol[gc_camreset ][0] = 'r'; - gamecontrol[gc_camreset ][1] = KEY_JOY1+3; // Y - gamecontrol[gc_lookup ][0] = KEY_UPARROW; - gamecontrol[gc_lookdown ][0] = KEY_DOWNARROW; - gamecontrol[gc_centerview ][0] = KEY_END; - gamecontrol[gc_centerview ][1] = KEY_JOY1+9; // Right Stick - gamecontrol[gc_talkkey ][0] = 't'; - gamecontrol[gc_talkkey ][1] = KEY_HAT1+2; // D-Pad Left - gamecontrol[gc_teamkey ][0] = 'y'; - gamecontrol[gc_scores ][0] = KEY_TAB; - gamecontrol[gc_scores ][1] = KEY_HAT1+3; // D-Pad Right - gamecontrol[gc_jump ][0] = KEY_SPACE; - gamecontrol[gc_jump ][1] = KEY_JOY1+5; // RB - gamecontrol[gc_console ][0] = KEY_CONSOLE; - gamecontrol[gc_pause ][0] = 'p'; - gamecontrol[gc_pause ][1] = KEY_JOY1+6; // Back - gamecontrol[gc_screenshot ][0] = KEY_F8; - gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down - gamecontrol[gc_recordgif ][0] = KEY_F9; - gamecontrol[gc_viewpoint ][0] = KEY_F12; - gamecontrol[gc_systemmenu ][0] = KEY_JOY1+7; // Start - gamecontrolbis[gc_weaponnext][0] = KEY_2JOY1+1; // B - gamecontrolbis[gc_weaponprev][0] = KEY_2JOY1+2; // X - gamecontrolbis[gc_tossflag ][0] = KEY_2JOY1+0; // A - gamecontrolbis[gc_use ][0] = KEY_2JOY1+4; // LB - gamecontrolbis[gc_camreset ][0] = KEY_2JOY1+3; // Y - gamecontrolbis[gc_centerview][0] = KEY_2JOY1+9; // Right Stick - gamecontrolbis[gc_jump ][0] = KEY_2JOY1+5; // RB - //gamecontrolbis[gc_pause ][0] = KEY_2JOY1+6; // Back - //gamecontrolbis[gc_systemmenu][0] = KEY_2JOY1+7; // Start - gamecontrolbis[gc_camtoggle ][0] = KEY_2HAT1+0; // D-Pad Up - gamecontrolbis[gc_screenshot][0] = KEY_2HAT1+1; // D-Pad Down - //gamecontrolbis[gc_talkkey ][0] = KEY_2HAT1+2; // D-Pad Left - //gamecontrolbis[gc_scores ][0] = KEY_2HAT1+3; // D-Pad Right -#ifdef WMINPUT - gamecontrol[gc_forward ][0] = KEY_JOY1+02; //UP - gamecontrol[gc_backward ][0] = KEY_JOY1+03; //DOWN - gamecontrol[gc_turnleft ][0] = KEY_JOY1+04; //LEFT - gamecontrol[gc_turnright ][0] = KEY_JOY1+05; //RIGHT - gamecontrol[gc_weaponnext ][0] = KEY_JOY1+10; //y - gamecontrol[gc_weaponprev ][0] = KEY_JOY1+9; //x - gamecontrol[gc_fire ][0] = KEY_JOY1+12; //L - gamecontrol[gc_firenormal ][0] = KEY_JOY1+13; //R - gamecontrol[gc_use ][0] = KEY_JOY1+00; //B - gamecontrol[gc_use ][1] = KEY_JOY1+07; //b - gamecontrol[gc_jump ][0] = KEY_JOY1+01; //A - gamecontrol[gc_jump ][1] = KEY_JOY1+06; //a - gamecontrol[gc_pause ][0] = KEY_JOY1+18; //Home - gamecontrolbis[gc_forward ][0] = KEY_2JOY1+02; //UP - gamecontrolbis[gc_backward ][0] = KEY_2JOY1+03; //DOWN - gamecontrolbis[gc_turnleft ][0] = KEY_2JOY1+04; //LEFT - gamecontrolbis[gc_turnright ][0] = KEY_2JOY1+05; //RIGHT - gamecontrolbis[gc_weaponnext ][0] = KEY_2JOY1+10; //y - gamecontrolbis[gc_weaponprev ][0] = KEY_2JOY1+9; //x - gamecontrolbis[gc_fire ][0] = KEY_2JOY1+12; //L - gamecontrolbis[gc_firenormal ][0] = KEY_2JOY1+13; //R - gamecontrolbis[gc_use ][0] = KEY_2JOY1+00; //B - gamecontrolbis[gc_use ][1] = KEY_2JOY1+07; //b - gamecontrolbis[gc_jump ][0] = KEY_2JOY1+01; //A - gamecontrolbis[gc_jump ][1] = KEY_2JOY1+06; //a - gamecontrolbis[gc_pause ][0] = KEY_2JOY1+18; //Home -#endif -#ifdef _WII - gamecontrol[gc_forward ][1] = KEY_HAT1+00; //UP - gamecontrol[gc_backward ][1] = KEY_HAT1+01; //DOWN - gamecontrol[gc_straferight][1] = KEY_JOY1+16; //ZR - gamecontrol[gc_strafeleft ][1] = KEY_JOY1+15; //ZL - gamecontrol[gc_turnleft ][1] = KEY_HAT1+02; //LEFT - gamecontrol[gc_turnright ][1] = KEY_HAT1+03; //RIGHT - gamecontrol[gc_weaponnext ][1] = KEY_JOY1+11; //x - gamecontrol[gc_fire ][0] = KEY_JOY1+12; //y - gamecontrol[gc_fire ][1] = KEY_JOY1+01; //B - gamecontrol[gc_firenormal ][0] = KEY_JOY1+13; //L - gamecontrol[gc_firenormal ][1] = KEY_JOY1+00; //A - gamecontrol[gc_tossflag ][1] = KEY_JOY1+17; //Plus CC - gamecontrol[gc_use ][0] = KEY_JOY1+9; //a - gamecontrol[gc_use ][1] = KEY_JOY1+02; //1 - gamecontrol[gc_centerview ][1] = KEY_JOY1+14; //R - gamecontrol[gc_scores ][0] = KEY_JOY1+04; //Minus - gamecontrol[gc_scores ][1] = KEY_JOY1+18; //Minus - gamecontrol[gc_jump ][0] = KEY_JOY1+10; //b - gamecontrol[gc_jump ][1] = KEY_JOY1+3; //2 - gamecontrol[gc_pause ][0] = KEY_JOY1+06; //Home - gamecontrol[gc_pause ][1] = KEY_JOY1+19; //Home - gamecontrolbis[gc_forward ][1] = KEY_2HAT1+00; //UP - gamecontrolbis[gc_backward ][1] = KEY_2HAT1+01; //DOWN - gamecontrolbis[gc_straferight][1] = KEY_2JOY1+16; //ZR - gamecontrolbis[gc_strafeleft ][1] = KEY_2JOY1+15; //ZL - gamecontrolbis[gc_turnleft ][1] = KEY_2HAT1+02; //LEFT - gamecontrolbis[gc_turnright ][1] = KEY_2HAT1+03; //RIGHT - gamecontrolbis[gc_weaponnext ][1] = KEY_2JOY1+11; //x - gamecontrolbis[gc_fire ][0] = KEY_2JOY1+12; //y - gamecontrolbis[gc_fire ][1] = KEY_2JOY1+01; //B - gamecontrolbis[gc_firenormal ][0] = KEY_2JOY1+13; //L - gamecontrolbis[gc_firenormal ][1] = KEY_2JOY1+00; //A - gamecontrolbis[gc_tossflag ][1] = KEY_2JOY1+17; //Plus CC - gamecontrolbis[gc_use ][0] = KEY_2JOY1+9; //a - gamecontrolbis[gc_use ][1] = KEY_2JOY1+02; //1 - gamecontrolbis[gc_centerview ][1] = KEY_2JOY1+14; //R - gamecontrolbis[gc_scores ][0] = KEY_2JOY1+04; //Minus - gamecontrolbis[gc_scores ][1] = KEY_2JOY1+18; //Minus - gamecontrolbis[gc_jump ][0] = KEY_2JOY1+10; //b - gamecontrolbis[gc_jump ][1] = KEY_2JOY1+3; //2 - gamecontrolbis[gc_pause ][0] = KEY_2JOY1+06; //Home - gamecontrolbis[gc_pause ][1] = KEY_2JOY1+19; //Home -#endif -} -#endif + INT32 i; -void G_SaveKeySetting(FILE *f) + // FPS game controls (WASD) + gamecontroldefault[gcs_fps][gc_forward ][0] = 'w'; + gamecontroldefault[gcs_fps][gc_backward ][0] = 's'; + gamecontroldefault[gcs_fps][gc_strafeleft ][0] = 'a'; + gamecontroldefault[gcs_fps][gc_straferight][0] = 'd'; + gamecontroldefault[gcs_fps][gc_lookup ][0] = KEY_UPARROW; + gamecontroldefault[gcs_fps][gc_lookdown ][0] = KEY_DOWNARROW; + gamecontroldefault[gcs_fps][gc_turnleft ][0] = KEY_LEFTARROW; + gamecontroldefault[gcs_fps][gc_turnright ][0] = KEY_RIGHTARROW; + gamecontroldefault[gcs_fps][gc_centerview ][0] = KEY_END; + gamecontroldefault[gcs_fps][gc_jump ][0] = KEY_SPACE; + gamecontroldefault[gcs_fps][gc_use ][0] = KEY_LSHIFT; + gamecontroldefault[gcs_fps][gc_fire ][0] = KEY_RCTRL; + gamecontroldefault[gcs_fps][gc_fire ][1] = KEY_MOUSE1+0; + gamecontroldefault[gcs_fps][gc_firenormal ][0] = 'c'; + + // Platform game controls (arrow keys) + gamecontroldefault[gcs_platform][gc_forward ][0] = KEY_UPARROW; + gamecontroldefault[gcs_platform][gc_backward ][0] = KEY_DOWNARROW; + gamecontroldefault[gcs_platform][gc_strafeleft ][0] = 'a'; + gamecontroldefault[gcs_platform][gc_straferight][0] = 'd'; + gamecontroldefault[gcs_platform][gc_lookup ][0] = KEY_PGUP; + gamecontroldefault[gcs_platform][gc_lookdown ][0] = KEY_PGDN; + gamecontroldefault[gcs_platform][gc_turnleft ][0] = KEY_LEFTARROW; + gamecontroldefault[gcs_platform][gc_turnright ][0] = KEY_RIGHTARROW; + gamecontroldefault[gcs_platform][gc_centerview ][0] = KEY_END; + gamecontroldefault[gcs_platform][gc_jump ][0] = KEY_SPACE; + gamecontroldefault[gcs_platform][gc_use ][0] = KEY_LSHIFT; + gamecontroldefault[gcs_platform][gc_fire ][0] = 's'; + gamecontroldefault[gcs_platform][gc_fire ][1] = KEY_MOUSE1+0; + gamecontroldefault[gcs_platform][gc_firenormal ][0] = 'w'; + + for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0) + { + gamecontroldefault[i][gc_weaponnext ][0] = KEY_MOUSEWHEELUP+0; + gamecontroldefault[i][gc_weaponprev ][0] = KEY_MOUSEWHEELDOWN+0; + gamecontroldefault[i][gc_wepslot1 ][0] = '1'; + gamecontroldefault[i][gc_wepslot2 ][0] = '2'; + gamecontroldefault[i][gc_wepslot3 ][0] = '3'; + gamecontroldefault[i][gc_wepslot4 ][0] = '4'; + gamecontroldefault[i][gc_wepslot5 ][0] = '5'; + gamecontroldefault[i][gc_wepslot6 ][0] = '6'; + gamecontroldefault[i][gc_wepslot7 ][0] = '7'; + gamecontroldefault[i][gc_wepslot8 ][0] = '8'; + gamecontroldefault[i][gc_wepslot9 ][0] = '9'; + gamecontroldefault[i][gc_wepslot10 ][0] = '0'; + gamecontroldefault[i][gc_tossflag ][0] = '\''; + gamecontroldefault[i][gc_camtoggle ][0] = 'v'; + gamecontroldefault[i][gc_camreset ][0] = 'r'; + gamecontroldefault[i][gc_talkkey ][0] = 't'; + gamecontroldefault[i][gc_teamkey ][0] = 'y'; + gamecontroldefault[i][gc_scores ][0] = KEY_TAB; + gamecontroldefault[i][gc_console ][0] = KEY_CONSOLE; + gamecontroldefault[i][gc_pause ][0] = 'p'; + gamecontroldefault[i][gc_screenshot ][0] = KEY_F8; + gamecontroldefault[i][gc_recordgif ][0] = KEY_F9; + gamecontroldefault[i][gc_viewpoint ][0] = KEY_F12; + + // Gamepad controls -- same for both schemes + gamecontroldefault[i][gc_weaponnext ][1] = KEY_JOY1+1; // B + gamecontroldefault[i][gc_weaponprev ][1] = KEY_JOY1+2; // X + gamecontroldefault[i][gc_tossflag ][1] = KEY_JOY1+0; // A + gamecontroldefault[i][gc_use ][1] = KEY_JOY1+4; // LB + gamecontroldefault[i][gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up + gamecontroldefault[i][gc_camreset ][1] = KEY_JOY1+3; // Y + gamecontroldefault[i][gc_centerview ][1] = KEY_JOY1+9; // Right Stick + gamecontroldefault[i][gc_talkkey ][1] = KEY_HAT1+2; // D-Pad Left + gamecontroldefault[i][gc_scores ][1] = KEY_HAT1+3; // D-Pad Right + gamecontroldefault[i][gc_jump ][1] = KEY_JOY1+5; // RB + gamecontroldefault[i][gc_pause ][1] = KEY_JOY1+6; // Back + gamecontroldefault[i][gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down + gamecontroldefault[i][gc_systemmenu ][0] = KEY_JOY1+7; // Start + + // Second player controls only have joypad defaults + gamecontrolbisdefault[i][gc_weaponnext][0] = KEY_2JOY1+1; // B + gamecontrolbisdefault[i][gc_weaponprev][0] = KEY_2JOY1+2; // X + gamecontrolbisdefault[i][gc_tossflag ][0] = KEY_2JOY1+0; // A + gamecontrolbisdefault[i][gc_use ][0] = KEY_2JOY1+4; // LB + gamecontrolbisdefault[i][gc_camreset ][0] = KEY_2JOY1+3; // Y + gamecontrolbisdefault[i][gc_centerview][0] = KEY_2JOY1+9; // Right Stick + gamecontrolbisdefault[i][gc_jump ][0] = KEY_2JOY1+5; // RB + //gamecontrolbisdefault[i][gc_pause ][0] = KEY_2JOY1+6; // Back + //gamecontrolbisdefault[i][gc_systemmenu][0] = KEY_2JOY1+7; // Start + gamecontrolbisdefault[i][gc_camtoggle ][0] = KEY_2HAT1+0; // D-Pad Up + gamecontrolbisdefault[i][gc_screenshot][0] = KEY_2HAT1+1; // D-Pad Down + //gamecontrolbisdefault[i][gc_talkkey ][0] = KEY_2HAT1+2; // D-Pad Left + //gamecontrolbisdefault[i][gc_scores ][0] = KEY_2HAT1+3; // D-Pad Right + } +} + +INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen) +{ + INT32 i, j, gc; + boolean skipscheme; + + for (i = 1; i < num_gamecontrolschemes; i++) // skip gcs_custom (0) + { + skipscheme = false; + for (j = 0; j < (gclist && gclen ? gclen : num_gamecontrols); j++) + { + gc = (gclist && gclen) ? gclist[j] : j; + if (((fromcontrols[gc][0] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][0] : true) && + ((fromcontrols[gc][0] && gamecontroldefault[i][gc][1]) ? fromcontrols[gc][0] != gamecontroldefault[i][gc][1] : true) && + ((fromcontrols[gc][1] && gamecontroldefault[i][gc][0]) ? fromcontrols[gc][1] != gamecontroldefault[i][gc][0] : true) && + ((fromcontrols[gc][1] && gamecontroldefault[i][gc][1]) ? fromcontrols[gc][1] != gamecontroldefault[i][gc][1] : true)) + { + skipscheme = true; + break; + } + } + if (!skipscheme) + return i; + } + + return gcs_custom; +} + +void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen) +{ + INT32 i, gc; + + for (i = 0; i < (gclist && gclen ? gclen : num_gamecontrols); i++) + { + gc = (gclist && gclen) ? gclist[i] : i; + setupcontrols[gc][0] = fromcontrols[gc][0]; + setupcontrols[gc][1] = fromcontrols[gc][1]; + } +} + +void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]) { INT32 i; for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrol[i][0])); + G_KeynumToString(fromcontrols[i][0])); - if (gamecontrol[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrol[i][1])); + if (fromcontrols[i][1]) + fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrols[i][1])); else fprintf(f, "\n"); } @@ -1330,10 +828,10 @@ void G_SaveKeySetting(FILE *f) for (i = 1; i < num_gamecontrols; i++) { fprintf(f, "setcontrol2 \"%s\" \"%s\"", gamecontrolname[i], - G_KeynumToString(gamecontrolbis[i][0])); + G_KeynumToString(fromcontrolsbis[i][0])); - if (gamecontrolbis[i][1]) - fprintf(f, " \"%s\"\n", G_KeynumToString(gamecontrolbis[i][1])); + if (fromcontrolsbis[i][1]) + fprintf(f, " \"%s\"\n", G_KeynumToString(fromcontrolsbis[i][1])); else fprintf(f, "\n"); } @@ -1390,7 +888,6 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT else if (keyidx == 1 && *keynum2 == KEY_PAUSE) return -1; // skip setting control -#if !defined (DC) && !defined (_PSP) && !defined (GP2X) && !defined (_NDS) && !defined(WMINPUT) && !defined(_WII) if (GETMAJOREXECVERSION(cv_execversion.value) < 27 && ( // v2.1.22 numctrl == gc_weaponnext || numctrl == gc_weaponprev || numctrl == gc_tossflag || numctrl == gc_use || numctrl == gc_camreset || numctrl == gc_jump || @@ -1483,7 +980,6 @@ static INT32 G_FilterKeyByVersion(INT32 numctrl, INT32 keyidx, INT32 player, INT else return 0; } -#endif // All's good, so pass the keynum as-is if (keyidx == 1) diff --git a/src/g_input.h b/src/g_input.h index 8f4e9cb09..a7484c7ad 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -22,33 +22,10 @@ // keys (mousebuttons and joybuttons becomes keys) #define NUMKEYS 256 - -#ifdef _arch_dreamcast -#define MOUSEBUTTONS 5 -#define JOYBUTTONS 8 // 8 buttons -#define JOYHATS 2 // 2 hats -#define JOYAXISSET 3 // 3 Sets of 2 axises -#elif defined (_XBOX) -#define MOUSEBUTTONS 5 -#define JOYBUTTONS 12 // 12 buttons -#define JOYHATS 1 // 1 hat -#define JOYAXISSET 2 // 2 Sets of 2 axises -#elif defined (_PSP) -#define MOUSEBUTTONS 3 -#define JOYBUTTONS 14 // 10 buttons -#define JOYHATS 1 // 1 hat -#define JOYAXISSET 1 // 1 Set of 2 axises -#elif defined (_WII) -#define MOUSEBUTTONS 3 -#define JOYBUTTONS 20 // 20 buttons -#define JOYHATS 1 // 1 hat -#define JOYAXISSET 5 // 5 Sets of 2 axises -#else #define MOUSEBUTTONS 8 #define JOYBUTTONS 32 // 32 buttons #define JOYHATS 4 // 4 hats #define JOYAXISSET 4 // 4 Sets of 2 axises -#endif // // mouse and joystick buttons are handled as 'virtual' keys @@ -105,8 +82,6 @@ typedef enum gc_tossflag, gc_use, gc_camtoggle, - gc_camleft, - gc_camright, gc_camreset, gc_lookup, gc_lookdown, @@ -128,6 +103,14 @@ typedef enum num_gamecontrols } gamecontrols_e; +typedef enum +{ + gcs_custom, + gcs_fps, + gcs_platform, + num_gamecontrolschemes +} gamecontrolschemes_e; + // mouse values are used once extern consvar_t cv_mousesens, cv_mouseysens; extern consvar_t cv_mousesens2, cv_mouseysens2; @@ -145,8 +128,31 @@ extern UINT8 gamekeydown[NUMINPUTS]; // two key codes (or virtual key) per game control extern INT32 gamecontrol[num_gamecontrols][2]; extern INT32 gamecontrolbis[num_gamecontrols][2]; // secondary splitscreen player +extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // default control storage, use 0 (gcs_custom) for memory retention +extern INT32 gamecontrolbisdefault[num_gamecontrolschemes][num_gamecontrols][2]; #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) +#define PLAYERINPUTDOWN(p, gc) ((p) == 2 ? PLAYER2INPUTDOWN(gc) : PLAYER1INPUTDOWN(gc)) + +#define num_gcl_tutorial_check 6 +#define num_gcl_tutorial_used 8 +#define num_gcl_tutorial_full 13 +#define num_gcl_movement 4 +#define num_gcl_camera 2 +#define num_gcl_movement_camera 6 +#define num_gcl_jump 1 +#define num_gcl_use 1 +#define num_gcl_jump_use 2 + +extern const INT32 gcl_tutorial_check[num_gcl_tutorial_check]; +extern const INT32 gcl_tutorial_used[num_gcl_tutorial_used]; +extern const INT32 gcl_tutorial_full[num_gcl_tutorial_full]; +extern const INT32 gcl_movement[num_gcl_movement]; +extern const INT32 gcl_camera[num_gcl_camera]; +extern const INT32 gcl_movement_camera[num_gcl_movement_camera]; +extern const INT32 gcl_jump[num_gcl_jump]; +extern const INT32 gcl_use[num_gcl_use]; +extern const INT32 gcl_jump_use[num_gcl_jump_use]; // peace to my little coder fingers! // check a gamecontrol being active or not @@ -163,8 +169,10 @@ void G_ClearControlKeys(INT32 (*setupcontrols)[2], INT32 control); void G_ClearAllControlKeys(void); void Command_Setcontrol_f(void); void Command_Setcontrol2_f(void); -void G_Controldefault(void); -void G_SaveKeySetting(FILE *f); +void G_DefineDefaultControls(void); +INT32 G_GetControlScheme(INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen); +void G_CopyControls(INT32 (*setupcontrols)[2], INT32 (*fromcontrols)[2], const INT32 *gclist, INT32 gclen); +void G_SaveKeySetting(FILE *f, INT32 (*fromcontrols)[2], INT32 (*fromcontrolsbis)[2]); INT32 G_CheckDoubleUsage(INT32 keynum, boolean modify); #endif diff --git a/src/g_state.h b/src/g_state.h index 76c9bd16f..3320ebc47 100644 --- a/src/g_state.h +++ b/src/g_state.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,12 +27,14 @@ typedef enum GS_TITLESCREEN, // title screen GS_TIMEATTACK, // time attack menu + GS_CREDITS, // credit sequence GS_EVALUATION, // Evaluation at the end of a game. - GS_GAMEEND, // game end sequence + GS_GAMEEND, // game end sequence - "did you get all those chaos emeralds?" // Hardcoded fades or other fading methods GS_INTRO, // introduction + GS_ENDING, // currently shared between bad and good endings GS_CUTSCENE, // custom cutscene // Not fadable @@ -50,6 +52,7 @@ typedef enum } gameaction_t; extern gamestate_t gamestate; +extern UINT8 titlemapinaction; extern UINT8 ultimatemode; // was sk_insane extern gameaction_t gameaction; diff --git a/src/hardware/hw3sound.c b/src/hardware/hw3sound.c index f7c6e1da0..7858640c0 100644 --- a/src/hardware/hw3sound.c +++ b/src/hardware/hw3sound.c @@ -28,7 +28,7 @@ #include "../tables.h" #include "../sounds.h" #include "../r_main.h" -#include "../r_things.h" +#include "../r_skins.h" #include "../m_random.h" #include "../p_local.h" #include "hw3dsdrv.h" diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 21fd85a33..6f3dd9fbd 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -29,6 +29,7 @@ #include "../m_argv.h" #include "../i_video.h" #include "../w_wad.h" +#include "../p_setup.h" // levelfadecol // -------------------------------------------------------------------------- // This is global data for planes rendering @@ -200,7 +201,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, // (do not accept hit with the extensions) num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; frac = num / den; - if (frac < 0.0 || frac > 1.0) + if (frac < 0.0l || frac > 1.0l) return NULL; // now get the frac along the BSP line @@ -448,8 +449,12 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) // for each seg of the subsector for (; count--; lseg++) { - //x,y,dx,dy (like a divline) line_t *line = lseg->linedef; + + if (lseg->glseg) + continue; + + //x,y,dx,dy (like a divline) p1.x = FIXED_TO_FLOAT(lseg->side ? line->v2->x : line->v1->x); p1.y = FIXED_TO_FLOAT(lseg->side ? line->v2->y : line->v1->y); p2.x = FIXED_TO_FLOAT(lseg->side ? line->v1->x : line->v2->x); @@ -835,8 +840,10 @@ static INT32 SolveTProblem(void) return 0; CONS_Debug(DBG_RENDER, "Solving T-joins. This may take a while. Please wait...\n"); +#ifdef HWR_LOADING_SCREEN CON_Drawer(); //let the user know what we are doing I_FinishUpdate(); // page flip or blit buffer +#endif numsplitpoly = 0; @@ -963,9 +970,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum) CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n"); #ifdef HWR_LOADING_SCREEN ls_count = ls_percent = 0; // reset the loading status -#endif CON_Drawer(); //let the user know what we are doing I_FinishUpdate(); // page flip or blit buffer +#endif HWR_ClearPolys(); diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 78fc31afc..059556f15 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -30,10 +30,8 @@ #include "../z_zone.h" #include "../v_video.h" #include "../r_draw.h" - -//Hurdler: 25/04/2000: used for new colormap code in hardware mode -//static UINT8 *gr_colormap = NULL; // by default it must be NULL ! (because colormap tables are not initialized) -boolean firetranslucent = false; +#include "../r_patch.h" +#include "../p_setup.h" // Values set after a call to HWR_ResizeBlock() static INT32 blocksize, blockwidth, blockheight; @@ -41,50 +39,364 @@ static INT32 blocksize, blockwidth, blockheight; INT32 patchformat = GR_TEXFMT_AP_88; // use alpha for holes INT32 textureformat = GR_TEXFMT_P_8; // use chromakey for hole -// sprite, use alpha and chroma key for hole +static const INT32 format2bpp[16] = +{ + 0, //0 + 0, //1 + 1, //2 GR_TEXFMT_ALPHA_8 + 1, //3 GR_TEXFMT_INTENSITY_8 + 1, //4 GR_TEXFMT_ALPHA_INTENSITY_44 + 1, //5 GR_TEXFMT_P_8 + 4, //6 GR_RGBA + 0, //7 + 0, //8 + 0, //9 + 2, //10 GR_TEXFMT_RGB_565 + 2, //11 GR_TEXFMT_ARGB_1555 + 2, //12 GR_TEXFMT_ARGB_4444 + 2, //13 GR_TEXFMT_ALPHA_INTENSITY_88 + 2, //14 GR_TEXFMT_AP_88 +}; + +// This code was originally placed directly in HWR_DrawPatchInCache. +// It is now split from it for my sanity! (and the sanity of others) +// -- Monster Iestyn (13/02/19) +static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap, + INT32 pblockheight, INT32 blockmodulo, + fixed_t yfracstep, fixed_t scale_y, + texpatch_t *originPatch, INT32 patchheight, + INT32 bpp) +{ + fixed_t yfrac, position, count; + UINT8 *dest; + const UINT8 *source; + INT32 topdelta, prevdelta = -1; + INT32 originy = 0; + + // for writing a pixel to dest + RGBA_t colortemp; + UINT8 alpha; + UINT8 texel; + UINT16 texelu16; + + (void)patchheight; // This parameter is unused + + if (originPatch) // originPatch can be NULL here, unlike in the software version + originy = originPatch->originy; + + while (patchcol->topdelta != 0xff) + { + topdelta = patchcol->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (const UINT8 *)patchcol + 3; + count = ((patchcol->length * scale_y) + (FRACUNIT/2)) >> FRACBITS; + position = originy + topdelta; + + yfrac = 0; + //yfracstep = (patchcol->length << FRACBITS) / count; + if (position < 0) + { + yfrac = -position<> FRACBITS); + position = 0; + } + + position = ((position * scale_y) + (FRACUNIT/2)) >> FRACBITS; + + if (position < 0) + position = 0; + + if (position + count >= pblockheight) + count = pblockheight - position; + + dest = block + (position*blockmodulo); + while (count > 0) + { + count--; + + texel = source[yfrac>>FRACBITS]; + + //Hurdler: 25/04/2000: now support colormap in hardware mode + if (mipmap->colormap) + texel = mipmap->colormap[texel]; + + // If the mipmap is chromakeyed, check if the texel's color + // is equivalent to the chroma key's color index. + alpha = 0xff; + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) + alpha = 0x00; + + // hope compiler will get this switch out of the loops (dreams...) + // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) + // Alam: SRB2 uses Mingw, HUGS + switch (bpp) + { + case 2 : // uhhhhhhhh.......... + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + texel = ASTBlendPixel_8bpp(*(dest+1), texel, originPatch->style, originPatch->alpha); + texelu16 = (UINT16)((alpha<<8) | texel); + memcpy(dest, &texelu16, sizeof(UINT16)); + break; + case 3 : colortemp = V_GetColor(texel); + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + { + RGBA_t rgbatexel; + rgbatexel.rgba = *(UINT32 *)dest; + colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + } + memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8)); + break; + case 4 : colortemp = V_GetColor(texel); + colortemp.s.alpha = alpha; + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + { + RGBA_t rgbatexel; + rgbatexel.rgba = *(UINT32 *)dest; + colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + } + memcpy(dest, &colortemp, sizeof(RGBA_t)); + break; + // default is 1 + default: + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + *dest = ASTBlendPixel_8bpp(*dest, texel, originPatch->style, originPatch->alpha); + else + *dest = texel; + break; + } + + dest += blockmodulo; + yfrac += yfracstep; + } + patchcol = (const column_t *)((const UINT8 *)patchcol + patchcol->length + 4); + } +} + +static void HWR_DrawFlippedColumnInCache(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap, + INT32 pblockheight, INT32 blockmodulo, + fixed_t yfracstep, fixed_t scale_y, + texpatch_t *originPatch, INT32 patchheight, + INT32 bpp) +{ + fixed_t yfrac, position, count; + UINT8 *dest; + const UINT8 *source; + INT32 topdelta, prevdelta = -1; + INT32 originy = 0; + + // for writing a pixel to dest + RGBA_t colortemp; + UINT8 alpha; + UINT8 texel; + UINT16 texelu16; + + if (originPatch) // originPatch can be NULL here, unlike in the software version + originy = originPatch->originy; + + while (patchcol->topdelta != 0xff) + { + topdelta = patchcol->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + topdelta = patchheight-patchcol->length-topdelta; + source = (const UINT8 *)patchcol + 3; + count = ((patchcol->length * scale_y) + (FRACUNIT/2)) >> FRACBITS; + position = originy + topdelta; + + yfrac = (patchcol->length-1) << FRACBITS; + + if (position < 0) + { + yfrac += position<> FRACBITS); + position = 0; + } + + position = ((position * scale_y) + (FRACUNIT/2)) >> FRACBITS; + + if (position < 0) + position = 0; + + if (position + count >= pblockheight) + count = pblockheight - position; + + dest = block + (position*blockmodulo); + while (count > 0) + { + count--; + + texel = source[yfrac>>FRACBITS]; + + //Hurdler: 25/04/2000: now support colormap in hardware mode + if (mipmap->colormap) + texel = mipmap->colormap[texel]; + + // If the mipmap is chromakeyed, check if the texel's color + // is equivalent to the chroma key's color index. + alpha = 0xff; + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) + alpha = 0x00; + + // hope compiler will get this switch out of the loops (dreams...) + // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) + // Alam: SRB2 uses Mingw, HUGS + switch (bpp) + { + case 2 : // uhhhhhhhh.......... + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + texel = ASTBlendPixel_8bpp(*(dest+1), texel, originPatch->style, originPatch->alpha); + texelu16 = (UINT16)((alpha<<8) | texel); + memcpy(dest, &texelu16, sizeof(UINT16)); + break; + case 3 : colortemp = V_GetColor(texel); + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + { + RGBA_t rgbatexel; + rgbatexel.rgba = *(UINT32 *)dest; + colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + } + memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8)); + break; + case 4 : colortemp = V_GetColor(texel); + colortemp.s.alpha = alpha; + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + { + RGBA_t rgbatexel; + rgbatexel.rgba = *(UINT32 *)dest; + colortemp.rgba = ASTBlendPixel(rgbatexel, colortemp, originPatch->style, originPatch->alpha); + } + memcpy(dest, &colortemp, sizeof(RGBA_t)); + break; + // default is 1 + default: + if ((originPatch != NULL) && (originPatch->style != AST_COPY)) + *dest = ASTBlendPixel_8bpp(*dest, texel, originPatch->style, originPatch->alpha); + else + *dest = texel; + break; + } + + dest += blockmodulo; + yfrac -= yfracstep; + } + patchcol = (const column_t *)((const UINT8 *)patchcol + patchcol->length + 4); + } +} + + +// Simplified patch caching function +// for use by sprites and other patches that are not part of a wall texture +// no alpha or flipping should be present since we do not want non-texture graphics to have them +// no offsets are used either +// -- Monster Iestyn (13/02/19) static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, - INT32 pblockwidth, INT32 pblockheight, INT32 blockmodulo, - INT32 ptexturewidth, INT32 ptextureheight, - INT32 originx, INT32 originy, // where to draw patch in surface block - const patch_t *realpatch, INT32 bpp) + INT32 pblockwidth, INT32 pblockheight, + INT32 pwidth, INT32 pheight, + const patch_t *realpatch) +{ + INT32 ncols; + fixed_t xfrac, xfracstep; + fixed_t yfracstep, scale_y; + const column_t *patchcol; + UINT8 *block = mipmap->grInfo.data; + INT32 bpp; + INT32 blockmodulo; + + if (pwidth <= 0 || pheight <= 0) + return; + + ncols = (pwidth * pblockwidth) / pwidth; + + // source advance + xfrac = 0; + xfracstep = (pwidth << FRACBITS) / pblockwidth; + yfracstep = (pheight << FRACBITS) / pblockheight; + scale_y = (pblockheight << FRACBITS) / pheight; + + bpp = format2bpp[mipmap->grInfo.format]; + + if (bpp < 1 || bpp > 4) + I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); + + // NOTE: should this actually be pblockwidth*bpp? + blockmodulo = blockwidth*bpp; + + // Draw each column to the block cache + for (; ncols--; block += bpp, xfrac += xfracstep) + { + patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS])); + + HWR_DrawColumnInCache(patchcol, block, mipmap, + pblockheight, blockmodulo, + yfracstep, scale_y, + NULL, pheight, // not that pheight is going to get used anyway... + bpp); + } +} + +// This function we use for caching patches that belong to textures +static void HWR_DrawTexturePatchInCache(GLMipmap_t *mipmap, + INT32 pblockwidth, INT32 pblockheight, + texture_t *texture, texpatch_t *patch, + const patch_t *realpatch) { INT32 x, x1, x2; INT32 col, ncols; fixed_t xfrac, xfracstep; - fixed_t yfrac, yfracstep, position, count; - fixed_t scale_y; - RGBA_t colortemp; - UINT8 *dest; - const UINT8 *source; + fixed_t yfracstep, scale_y; const column_t *patchcol; - UINT8 alpha; UINT8 *block = mipmap->grInfo.data; - UINT8 texel; - UINT16 texelu16; + INT32 bpp; + INT32 blockmodulo; + INT32 width, height; + // Column drawing function pointer. + static void (*ColumnDrawerPointer)(const column_t *patchcol, UINT8 *block, GLMipmap_t *mipmap, + INT32 pblockheight, INT32 blockmodulo, + fixed_t yfracstep, fixed_t scale_y, + texpatch_t *originPatch, INT32 patchheight, + INT32 bpp); - x1 = originx; - x2 = x1 + SHORT(realpatch->width); + if (texture->width <= 0 || texture->height <= 0) + return; + ColumnDrawerPointer = (patch->flip & 2) ? HWR_DrawFlippedColumnInCache : HWR_DrawColumnInCache; + + x1 = patch->originx; + width = SHORT(realpatch->width); + height = SHORT(realpatch->height); + x2 = x1 + width; + + if (x1 > texture->width || x2 < 0) + return; // patch not located within texture's x bounds, ignore + + if (patch->originy > texture->height || (patch->originy + height) < 0) + return; // patch not located within texture's y bounds, ignore + + // patch is actually inside the texture! + // now check if texture is partly off-screen and adjust accordingly + + // left edge if (x1 < 0) x = 0; else x = x1; - if (x2 > ptexturewidth) - x2 = ptexturewidth; + // right edge + if (x2 > texture->width) + x2 = texture->width; - if (!ptexturewidth) - return; - col = x * pblockwidth / ptexturewidth; - ncols = ((x2 - x) * pblockwidth) / ptexturewidth; + col = x * pblockwidth / texture->width; + ncols = ((x2 - x) * pblockwidth) / texture->width; /* - CONS_Debug(DBG_RENDER, "patch %dx%d texture %dx%d block %dx%d\n", SHORT(realpatch->width), - SHORT(realpatch->height), - ptexturewidth, - textureheight, - pblockwidth,pblockheight); + CONS_Debug(DBG_RENDER, "patch %dx%d texture %dx%d block %dx%d\n", + width, height, + texture->width, texture->height, + pblockwidth, pblockheight); CONS_Debug(DBG_RENDER, " col %d ncols %d x %d\n", col, ncols, x); */ @@ -93,90 +405,31 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, if (x1 < 0) xfrac = -x1<width << FRACBITS) / pblockwidth; + yfracstep = (texture->height<< FRACBITS) / pblockheight; + scale_y = (pblockheight << FRACBITS) / texture->height; + + bpp = format2bpp[mipmap->grInfo.format]; + if (bpp < 1 || bpp > 4) I_Error("HWR_DrawPatchInCache: no drawer defined for this bpp (%d)\n",bpp); + // NOTE: should this actually be pblockwidth*bpp? + blockmodulo = blockwidth*bpp; + + // Draw each column to the block cache for (block += col*bpp; ncols--; block += bpp, xfrac += xfracstep) { - INT32 topdelta, prevdelta = -1; - patchcol = (const column_t *)((const UINT8 *)realpatch - + LONG(realpatch->columnofs[xfrac>>FRACBITS])); + if (patch->flip & 1) + patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[(width-1)-(xfrac>>FRACBITS)])); + else + patchcol = (const column_t *)((const UINT8 *)realpatch + LONG(realpatch->columnofs[xfrac>>FRACBITS])); - scale_y = (pblockheight << FRACBITS) / ptextureheight; - - while (patchcol->topdelta != 0xff) - { - topdelta = patchcol->topdelta; - if (topdelta <= prevdelta) - topdelta += prevdelta; - prevdelta = topdelta; - source = (const UINT8 *)patchcol + 3; - count = ((patchcol->length * scale_y) + (FRACUNIT/2)) >> FRACBITS; - position = originy + topdelta; - - yfrac = 0; - //yfracstep = (patchcol->length << FRACBITS) / count; - if (position < 0) - { - yfrac = -position<> FRACBITS); - position = 0; - } - - position = ((position * scale_y) + (FRACUNIT/2)) >> FRACBITS; - - if (position < 0) - position = 0; - - if (position + count >= pblockheight) - count = pblockheight - position; - - dest = block + (position*blockmodulo); - while (count > 0) - { - count--; - - texel = source[yfrac>>FRACBITS]; - - if (firetranslucent && (transtables[(texel<<8)+0x40000]!=texel)) - alpha = 0x80; - else - alpha = 0xff; - - //Hurdler: not perfect, but better than holes - if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX && (mipmap->flags & TF_CHROMAKEYED)) - texel = HWR_CHROMAKEY_EQUIVALENTCOLORINDEX; - //Hurdler: 25/04/2000: now support colormap in hardware mode - else if (mipmap->colormap) - texel = mipmap->colormap[texel]; - - // hope compiler will get this switch out of the loops (dreams...) - // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) - // Alam: SRB2 uses Mingw, HUGS - switch (bpp) - { - case 2 : texelu16 = (UINT16)((alpha<<8) | texel); - memcpy(dest, &texelu16, sizeof(UINT16)); - break; - case 3 : colortemp = V_GetColor(texel); - memcpy(dest, &colortemp, sizeof(RGBA_t)-sizeof(UINT8)); - break; - case 4 : colortemp = V_GetColor(texel); - colortemp.s.alpha = alpha; - memcpy(dest, &colortemp, sizeof(RGBA_t)); - break; - // default is 1 - default: *dest = texel; - break; - } - - dest += blockmodulo; - yfrac += yfracstep; - } - patchcol = (const column_t *)((const UINT8 *)patchcol + patchcol->length + 4); - } + ColumnDrawerPointer(patchcol, block, mipmap, + pblockheight, blockmodulo, + yfracstep, scale_y, + patch, height, + bpp); } } @@ -189,6 +442,7 @@ static void HWR_DrawPatchInCache(GLMipmap_t *mipmap, static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight, GrTexInfo *grInfo) { +#ifdef GLIDE_API_COMPATIBILITY // Build the full textures from patches. static const GrLOD_t gr_lods[9] = { @@ -225,6 +479,9 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight, INT32 j,k; INT32 max,min; +#else + (void)grInfo; +#endif // find a power of 2 width/height if (cv_grrounddown.value) @@ -241,45 +498,9 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight, if (blockheight < 1) I_Error("3D GenerateTexture : too small"); } - else if (cv_voodoocompatibility.value) - { - if (originalwidth > 256 || originalheight > 256) - { - blockwidth = 256; - while (originalwidth < blockwidth) - blockwidth >>= 1; - if (blockwidth < 1) - I_Error("3D GenerateTexture : too small"); - - blockheight = 256; - while (originalheight < blockheight) - blockheight >>= 1; - if (blockheight < 1) - I_Error("3D GenerateTexture : too small"); - } - else - { - //size up to nearest power of 2 - blockwidth = 1; - while (blockwidth < originalwidth) - blockwidth <<= 1; - // scale down the original graphics to fit in 256 - if (blockwidth > 256) - blockwidth = 256; - //I_Error("3D GenerateTexture : too big"); - - //size up to nearest power of 2 - blockheight = 1; - while (blockheight < originalheight) - blockheight <<= 1; - // scale down the original graphics to fit in 256 - if (blockheight > 256) - blockheight = 255; - //I_Error("3D GenerateTexture : too big"); - } - } else { +#ifdef GLIDE_API_COMPATIBILITY //size up to nearest power of 2 blockwidth = 1; while (blockwidth < originalwidth) @@ -297,9 +518,14 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight, if (blockheight > 2048) blockheight = 2048; //I_Error("3D GenerateTexture : too big"); +#else + blockwidth = originalwidth; + blockheight = originalheight; +#endif } // do the boring LOD stuff.. blech! +#ifdef GLIDE_API_COMPATIBILITY if (blockwidth >= blockheight) { max = blockwidth; @@ -331,37 +557,18 @@ static void HWR_ResizeBlock(INT32 originalwidth, INT32 originalheight, if (blockwidth < blockheight) j += 4; grInfo->aspectRatioLog2 = gr_aspects[j].aspect; +#endif blocksize = blockwidth * blockheight; //CONS_Debug(DBG_RENDER, "Width is %d, Height is %d\n", blockwidth, blockheight); } - -static const INT32 format2bpp[16] = -{ - 0, //0 - 0, //1 - 1, //2 GR_TEXFMT_ALPHA_8 - 1, //3 GR_TEXFMT_INTENSITY_8 - 1, //4 GR_TEXFMT_ALPHA_INTENSITY_44 - 1, //5 GR_TEXFMT_P_8 - 4, //6 GR_RGBA - 0, //7 - 0, //8 - 0, //9 - 2, //10 GR_TEXFMT_RGB_565 - 2, //11 GR_TEXFMT_ARGB_1555 - 2, //12 GR_TEXFMT_ARGB_4444 - 2, //13 GR_TEXFMT_ALPHA_INTENSITY_88 - 2, //14 GR_TEXFMT_AP_88 -}; - static UINT8 *MakeBlock(GLMipmap_t *grMipmap) { UINT8 *block; INT32 bpp, i; - UINT16 bu16 = ((0x00 <<8) | HWR_CHROMAKEY_EQUIVALENTCOLORINDEX); + UINT16 bu16 = ((0x00 <<8) | HWR_PATCHES_CHROMAKEY_COLORINDEX); bpp = format2bpp[grMipmap->grInfo.format]; block = Z_Malloc(blocksize*bpp, PU_HWRCACHE, &(grMipmap->grInfo.data)); @@ -391,6 +598,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) texture_t *texture; texpatch_t *patch; patch_t *realpatch; + UINT8 *pdata; INT32 i; boolean skyspecial = false; //poor hack for Legacy large skies.. @@ -423,7 +631,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) INT32 j; RGBA_t col; - col = V_GetColor(HWR_CHROMAKEY_EQUIVALENTCOLORINDEX); + col = V_GetColor(HWR_PATCHES_CHROMAKEY_COLORINDEX); for (j = 0; j < blockheight; j++) { for (i = 0; i < blockwidth; i++) @@ -439,15 +647,30 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); - HWR_DrawPatchInCache(&grtex->mipmap, - blockwidth, blockheight, - blockwidth*format2bpp[grtex->mipmap.grInfo.format], - texture->width, texture->height, - patch->originx, patch->originy, - realpatch, - format2bpp[grtex->mipmap.grInfo.format]); - Z_Unlock(realpatch); + boolean dealloc = true; + size_t lumplength = W_LumpLengthPwad(patch->wad, patch->lump); + pdata = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + realpatch = (patch_t *)pdata; + +#ifndef NO_PNG_LUMPS + if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) + realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL); + else +#endif +#ifdef WALLFLATS + if (texture->type == TEXTURETYPE_FLAT) + realpatch = R_FlatToPatch(pdata, texture->width, texture->height, 0, 0, NULL, false); + else +#endif + { + (void)lumplength; + dealloc = false; + } + + HWR_DrawTexturePatchInCache(&grtex->mipmap, blockwidth, blockheight, texture, patch, realpatch); + + if (dealloc) + Z_Unlock(realpatch); } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( if (format2bpp[grtex->mipmap.grInfo.format]==4) @@ -471,6 +694,13 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm { INT32 newwidth, newheight; +#ifndef NO_PNG_LUMPS + // lump is a png so convert it + size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum); + if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len)) + patch = R_PNGToPatch((const UINT8 *)patch, len, NULL); +#endif + // don't do it twice (like a cache) if (grMipmap->width == 0) { @@ -508,18 +738,6 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm newwidth = blockwidth; newheight = blockheight; } - else if (cv_voodoocompatibility.value) // Only scales down textures that exceed 256x256. - { - // no rounddown, do not size up patches, so they don't look 'scaled' - newwidth = min(grPatch->width, blockwidth); - newheight = min(grPatch->height, blockheight); - - if (newwidth > 256 || newheight > 256) - { - newwidth = blockwidth; - newheight = blockheight; - } - } else { // no rounddown, do not size up patches, so they don't look 'scaled' @@ -533,11 +751,8 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm HWR_DrawPatchInCache(grMipmap, newwidth, newheight, - blockwidth*format2bpp[grMipmap->grInfo.format], grPatch->width, grPatch->height, - 0, 0, - patch, - format2bpp[grMipmap->grInfo.format]); + patch); } grPatch->max_s = (float)newwidth / (float)blockwidth; @@ -549,88 +764,116 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // CACHING HANDLING // ================================================= -static size_t gr_numtextures; -static GLTexture_t *gr_textures; // for ALL Doom textures +static size_t gr_numtextures = 0; // Texture count +static GLTexture_t *gr_textures; // For all textures +static GLTexture_t *gr_flats; // For all (texture) flats, as normal flats don't need to be cached void HWR_InitTextureCache(void) { - gr_numtextures = 0; gr_textures = NULL; + gr_flats = NULL; } - // Callback function for HWR_FreeTextureCache. static void FreeMipmapColormap(INT32 patchnum, void *patch) { - GLPatch_t* const grpatch = patch; + GLPatch_t* const pat = patch; (void)patchnum; //unused - while (grpatch->mipmap.nextcolormap) + + // The patch must be valid, obviously + if (!pat) + return; + + // The mipmap must be valid, obviously + while (pat->mipmap) { - GLMipmap_t *grmip = grpatch->mipmap.nextcolormap; - grpatch->mipmap.nextcolormap = grmip->nextcolormap; - if (grmip->grInfo.data) Z_Free(grmip->grInfo.data); - free(grmip); + // Confusing at first, but pat->mipmap->nextcolormap + // at the beginning of the loop is the first colormap + // from the linked list of colormaps. + GLMipmap_t *next = NULL; + + // No mipmap in this patch, break out of the loop. + if (!pat->mipmap) + break; + + // No colormap mipmap either. + if (!pat->mipmap->nextcolormap) + break; + + // Set the first colormap to the one that comes after it. + next = pat->mipmap->nextcolormap; + pat->mipmap->nextcolormap = next->nextcolormap; + + // Free image data from memory. + if (next->grInfo.data) + Z_Free(next->grInfo.data); + next->grInfo.data = NULL; + + // Free the old colormap mipmap from memory. + free(next); } } -void HWR_FreeTextureCache(void) +void HWR_FreeMipmapCache(void) { INT32 i; + // free references to the textures HWD.pfnClearMipMapCache(); // free all hardware-converted graphics cached in the heap // our gool is only the textures since user of the texture is the texture cache - Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); + Z_FreeTag(PU_HWRCACHE); + Z_FreeTag(PU_HWRCACHE_UNLOCKED); // Alam: free the Z_Blocks before freeing it's users - - // free all skin after each level: must be done after pfnClearMipMapCache! + // free all patch colormaps after each level: must be done after ClearMipMapCache! for (i = 0; i < numwadfiles; i++) M_AATreeIterate(wadfiles[i]->hwrcache, FreeMipmapColormap); +} + +void HWR_FreeTextureCache(void) +{ + // free references to the textures + HWR_FreeMipmapCache(); // now the heap don't have any 'user' pointing to our // texturecache info, we can free it if (gr_textures) free(gr_textures); + if (gr_flats) + free(gr_flats); gr_textures = NULL; + gr_flats = NULL; gr_numtextures = 0; } -void HWR_PrepLevelCache(size_t pnumtextures) +void HWR_LoadTextures(size_t pnumtextures) { - // problem: the mipmap cache management hold a list of mipmaps.. but they are - // reallocated on each level.. - //sub-optimal, but 1) just need re-download stuff in hardware cache VERY fast - // 2) sprite/menu stuff mixed with level textures so can't do anything else - // we must free it since numtextures changed HWR_FreeTextureCache(); + // Why not Z_Malloc? gr_numtextures = pnumtextures; - gr_textures = calloc(pnumtextures, sizeof (*gr_textures)); - if (gr_textures == NULL) - I_Error("3D can't alloc gr_textures"); + gr_textures = calloc(gr_numtextures, sizeof(*gr_textures)); + gr_flats = calloc(gr_numtextures, sizeof(*gr_flats)); + + // Doesn't tell you which it _is_, but hopefully + // should never ever happen (right?!) + if ((gr_textures == NULL) || (gr_flats == NULL)) + I_Error("HWR_LoadTextures: ran out of memory for OpenGL textures. Sad!"); } void HWR_SetPalette(RGBA_t *palette) { - //Hudler: 16/10/99: added for OpenGL gamma correction - RGBA_t gamma_correction = {0x7F7F7F7F}; - - //Hurdler 16/10/99: added for OpenGL gamma correction - gamma_correction.s.red = (UINT8)cv_grgammared.value; - gamma_correction.s.green = (UINT8)cv_grgammagreen.value; - gamma_correction.s.blue = (UINT8)cv_grgammablue.value; - HWD.pfnSetPalette(palette, &gamma_correction); + HWD.pfnSetPalette(palette); // hardware driver will flush there own cache if cache is non paletized // now flush data texture cache so 32 bit texture are recomputed if (patchformat == GR_RGBA || textureformat == GR_RGBA) { - Z_FreeTags(PU_HWRCACHE, PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRCACHE_UNLOCKED); + Z_FreeTag(PU_HWRCACHE); + Z_FreeTag(PU_HWRCACHE_UNLOCKED); } } @@ -642,13 +885,18 @@ GLTexture_t *HWR_GetTexture(INT32 tex) GLTexture_t *grtex; #ifdef PARANOIA if ((unsigned)tex >= gr_numtextures) - I_Error(" HWR_GetTexture: tex >= numtextures\n"); + I_Error("HWR_GetTexture: tex >= numtextures\n"); #endif + + // Every texture in memory, stored in the + // hardware renderer's bit depth format. Wow! grtex = &gr_textures[tex]; + // Generate texture if missing from the cache if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) HWR_GenerateTexture(tex, grtex); + // Tell the hardware driver to bind the current texture to the flat's mipmap HWD.pfnSetTexture(&grtex->mipmap); // The system-memory data can be purged now. @@ -657,15 +905,16 @@ GLTexture_t *HWR_GetTexture(INT32 tex) return grtex; } - static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) { size_t size, pflatsize; // setup the texture info +#ifdef GLIDE_API_COMPATIBILITY grMipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_64; grMipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_64; grMipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; +#endif grMipmap->grInfo.format = GR_TEXFMT_P_8; grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; @@ -695,6 +944,7 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) pflatsize = 64; break; } + grMipmap->width = (UINT16)pflatsize; grMipmap->height = (UINT16)pflatsize; @@ -703,14 +953,42 @@ static void HWR_CacheFlat(GLMipmap_t *grMipmap, lumpnum_t flatlumpnum) PU_HWRCACHE, &grMipmap->grInfo.data)); } +static void HWR_CacheTextureAsFlat(GLMipmap_t *grMipmap, INT32 texturenum) +{ + UINT8 *flat; + + if (needpatchflush) + W_FlushCachedPatches(); + + // setup the texture info +#ifdef GLIDE_API_COMPATIBILITY + grMipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_64; + grMipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_64; + grMipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; +#endif + grMipmap->grInfo.format = GR_TEXFMT_P_8; + grMipmap->flags = TF_WRAPXY|TF_CHROMAKEYED; + + grMipmap->width = (UINT16)textures[texturenum]->width; + grMipmap->height = (UINT16)textures[texturenum]->height; + + flat = Z_Malloc(grMipmap->width * grMipmap->height, PU_HWRCACHE, &grMipmap->grInfo.data); + memset(flat, TRANSPARENTPIXEL, grMipmap->width * grMipmap->height); + + R_TextureToFlat(texturenum, flat); +} // Download a Doom 'flat' to the hardware cache and make it ready for use -void HWR_GetFlat(lumpnum_t flatlumpnum) +void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum) { GLMipmap_t *grmip; + if (flatlumpnum == LUMPERROR) + return; - grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap; + if (needpatchflush) + W_FlushCachedPatches(); + grmip = HWR_GetCachedGLPatch(flatlumpnum)->mipmap; if (!grmip->downloaded && !grmip->grInfo.data) HWR_CacheFlat(grmip, flatlumpnum); @@ -720,6 +998,44 @@ void HWR_GetFlat(lumpnum_t flatlumpnum) Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); } +void HWR_GetLevelFlat(levelflat_t *levelflat) +{ + // Who knows? + if (levelflat == NULL) + return; + + if (levelflat->type == LEVELFLAT_FLAT) + HWR_LiterallyGetFlat(levelflat->u.flat.lumpnum); + else if (levelflat->type == LEVELFLAT_TEXTURE) + { + GLTexture_t *grtex; + INT32 texturenum = levelflat->u.texture.num; +#ifdef PARANOIA + if ((unsigned)texturenum >= gr_numtextures) + I_Error("HWR_GetLevelFlat: texturenum >= numtextures\n"); +#endif + + // Who knows? + if (texturenum == 0 || texturenum == -1) + return; + + // Every texture in memory, stored as a 8-bit flat. Wow! + grtex = &gr_flats[texturenum]; + + // Generate flat if missing from the cache + if (!grtex->mipmap.grInfo.data && !grtex->mipmap.downloaded) + HWR_CacheTextureAsFlat(&grtex->mipmap, texturenum); + + // Tell the hardware driver to bind the current texture to the flat's mipmap + HWD.pfnSetTexture(&grtex->mipmap); + + // The system-memory data can be purged now. + Z_ChangeTag(grtex->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); + } + else // set no texture + HWD.pfnSetTexture(NULL); +} + // // HWR_LoadMappedPatch(): replace the skin color of the sprite in cache // : load it first in doom cache if not already @@ -728,10 +1044,15 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) { if (!grmip->downloaded && !grmip->grInfo.data) { - patch_t *patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); + patch_t *patch = gpatch->rawpatch; + if (!patch) + patch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); HWR_MakePatch(patch, gpatch, grmip, true); - Z_Free(patch); + // You can't free rawpatch for some reason? + // (Obviously I can't, sprite rotation needs that...) + if (!gpatch->rawpatch) + Z_Free(patch); } HWD.pfnSetTexture(grmip); @@ -745,23 +1066,29 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch) // -----------------+ void HWR_GetPatch(GLPatch_t *gpatch) { + if (needpatchflush) + W_FlushCachedPatches(); + // is it in hardware cache - if (!gpatch->mipmap.downloaded && !gpatch->mipmap.grInfo.data) + if (!gpatch->mipmap->downloaded && !gpatch->mipmap->grInfo.data) { // load the software patch, PU_STATIC or the Z_Malloc for hardware patch will // flush the software patch before the conversion! oh yeah I suffered - patch_t *ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); - HWR_MakePatch(ptr, gpatch, &gpatch->mipmap, true); + patch_t *ptr = gpatch->rawpatch; + if (!ptr) + ptr = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); + HWR_MakePatch(ptr, gpatch, gpatch->mipmap, true); // this is inefficient.. but the hardware patch in heap is purgeable so it should // not fragment memory, and besides the REAL cache here is the hardware memory - Z_Free(ptr); + if (!gpatch->rawpatch) + Z_Free(ptr); } - HWD.pfnSetTexture(&gpatch->mipmap); + HWD.pfnSetTexture(gpatch->mipmap); // The system-memory patch data can be purged now. - Z_ChangeTag(gpatch->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); } @@ -772,6 +1099,9 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap) { GLMipmap_t *grmip, *newmip; + if (needpatchflush) + W_FlushCachedPatches(); + if (colormap == colormaps || colormap == NULL) { // Load the default (green) color in doom cache (temporary?) AND hardware cache @@ -781,7 +1111,7 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap) // search for the mimmap // skip the first (no colormap translated) - for (grmip = &gpatch->mipmap; grmip->nextcolormap; ) + for (grmip = gpatch->mipmap; grmip->nextcolormap; ) { grmip = grmip->nextcolormap; if (grmip->colormap == colormap) @@ -811,7 +1141,7 @@ void HWR_UnlockCachedPatch(GLPatch_t *gpatch) if (!gpatch) return; - Z_ChangeTag(gpatch->mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(gpatch->mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); Z_ChangeTag(gpatch, PU_HWRPATCHINFO_UNLOCKED); } @@ -897,9 +1227,12 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) { GLPatch_t *grpatch; + if (needpatchflush) + W_FlushCachedPatches(); + grpatch = HWR_GetCachedGLPatch(lumpnum); - if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) { pic_t *pic; UINT8 *block; @@ -915,19 +1248,19 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) grpatch->topoffset = 0; // find the good 3dfx size (boring spec) - HWR_ResizeBlock (grpatch->width, grpatch->height, &grpatch->mipmap.grInfo); - grpatch->mipmap.width = (UINT16)blockwidth; - grpatch->mipmap.height = (UINT16)blockheight; + HWR_ResizeBlock (grpatch->width, grpatch->height, &grpatch->mipmap->grInfo); + grpatch->mipmap->width = (UINT16)blockwidth; + grpatch->mipmap->height = (UINT16)blockheight; if (pic->mode == PALETTE) - grpatch->mipmap.grInfo.format = textureformat; // can be set by driver + grpatch->mipmap->grInfo.format = textureformat; // can be set by driver else - grpatch->mipmap.grInfo.format = picmode2GR[pic->mode]; + grpatch->mipmap->grInfo.format = picmode2GR[pic->mode]; - Z_Free(grpatch->mipmap.grInfo.data); + Z_Free(grpatch->mipmap->grInfo.data); // allocate block - block = MakeBlock(&grpatch->mipmap); + block = MakeBlock(grpatch->mipmap); // if rounddown, rounddown patches as well as textures if (cv_grrounddown.value) @@ -935,18 +1268,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) newwidth = blockwidth; newheight = blockheight; } - else if (cv_voodoocompatibility.value) // Only scales down textures that exceed 256x256. - { - // no rounddown, do not size up patches, so they don't look 'scaled' - newwidth = min(SHORT(pic->width),blockwidth); - newheight = min(SHORT(pic->height),blockheight); - - if (newwidth > 256 || newheight > 256) - { - newwidth = blockwidth; - newheight = blockheight; - } - } else { // no rounddown, do not size up patches, so they don't look 'scaled' @@ -957,25 +1278,25 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum) if (grpatch->width == blockwidth && grpatch->height == blockheight && - format2bpp[grpatch->mipmap.grInfo.format] == format2bpp[picmode2GR[pic->mode]]) + format2bpp[grpatch->mipmap->grInfo.format] == format2bpp[picmode2GR[pic->mode]]) { // no conversion needed - M_Memcpy(grpatch->mipmap.grInfo.data, pic->data,len); + M_Memcpy(grpatch->mipmap->grInfo.data, pic->data,len); } else HWR_DrawPicInCache(block, newwidth, newheight, - blockwidth*format2bpp[grpatch->mipmap.grInfo.format], + blockwidth*format2bpp[grpatch->mipmap->grInfo.format], pic, - format2bpp[grpatch->mipmap.grInfo.format]); + format2bpp[grpatch->mipmap->grInfo.format]); Z_Unlock(pic); Z_ChangeTag(block, PU_HWRCACHE_UNLOCKED); - grpatch->mipmap.flags = 0; + grpatch->mipmap->flags = 0; grpatch->max_s = (float)newwidth / (float)blockwidth; grpatch->max_t = (float)newheight / (float)blockheight; } - HWD.pfnSetTexture(&grpatch->mipmap); + HWD.pfnSetTexture(grpatch->mipmap); //CONS_Debug(DBG_RENDER, "picloaded at %x as texture %d\n",grpatch->mipmap.grInfo.data, grpatch->mipmap.downloaded); return grpatch; @@ -991,6 +1312,7 @@ GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wadnum, UINT16 lumpnum) grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); grpatch->wadnum = wadnum; grpatch->lumpnum = lumpnum; + grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); M_AATreeSet(hwrcache, lumpnum, grpatch); } @@ -1094,7 +1416,10 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum) { GLMipmap_t *grmip; - grmip = &HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; + if (needpatchflush) + W_FlushCachedPatches(); + + grmip = HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; if (!grmip->downloaded && !grmip->grInfo.data) HWR_CacheFadeMask(grmip, fademasklumpnum); diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 6d120efe7..a63527083 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -72,13 +72,14 @@ #include "../v_video.h" #include "hw_clip.h" #include "hw_glob.h" +#include "../r_main.h" #include "../r_state.h" #include "../tables.h" #include "r_opengl/r_opengl.h" #ifdef HAVE_SPHEREFRUSTRUM -static GLdouble viewMatrix[16]; -static GLdouble projMatrix[16]; +static GLfloat viewMatrix[16]; +static GLfloat projMatrix[16]; float frustum[6][4]; #endif @@ -328,7 +329,7 @@ angle_t gld_FrustumAngle(void) // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function - float render_fov = FIXED_TO_FLOAT(cv_grfov.value); + float render_fov = FIXED_TO_FLOAT(cv_fov.value); float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right? float render_multiplier = 64.0f / render_fovratio / RMUL; @@ -380,8 +381,8 @@ void gld_FrustrumSetup(void) float t; float clip[16]; - pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); - pglGetDoublev(GL_MODELVIEW_MATRIX, viewMatrix); + pglGeFloatv(GL_PROJECTION_MATRIX, projMatrix); + pglGetFloatv(GL_MODELVIEW_MATRIX, viewMatrix); clip[0] = CALCMATRIX(0, 0, 1, 4, 2, 8, 3, 12); clip[1] = CALCMATRIX(0, 1, 1, 5, 2, 9, 3, 13); diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 4bbc578ed..ef57426a4 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -20,7 +20,7 @@ #ifndef _HWR_DATA_ #define _HWR_DATA_ -#if defined (_WIN32) && !defined (__CYGWIN__) && !defined (_XBOX) +#if defined (_WIN32) && !defined (__CYGWIN__) //#define WIN32_LEAN_AND_MEAN #define RPC_NO_WINDOWS_H #include @@ -83,8 +83,9 @@ struct GLPatch_s float max_s,max_t; UINT16 wadnum; // the software patch lump num for when the hardware patch UINT16 lumpnum; // was flushed, and we need to re-create it - GLMipmap_t mipmap; -}; + void *rawpatch; // :^) + GLMipmap_t *mipmap; +} ATTRPACK; typedef struct GLPatch_s GLPatch_t; #endif //_HWR_DATA_ diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index c05ff3e79..95882b03e 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -41,14 +41,8 @@ typedef unsigned char FBOOLEAN; // ========================================================================== // byte value for paletted graphics, which represent the transparent color -#ifdef _NDS -// NDS is hardwired to use zero as transparent color -#define HWR_PATCHES_CHROMAKEY_COLORINDEX 0 -#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 1 -#else -#define HWR_PATCHES_CHROMAKEY_COLORINDEX 247 -#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 220 -#endif +#define HWR_PATCHES_CHROMAKEY_COLORINDEX 255 +//#define HWR_CHROMAKEY_EQUIVALENTCOLORINDEX 130 // the chroma key color shows on border sprites, set it to black #define HWR_PATCHES_CHROMAKEY_COLORVALUE (0x00000000) //RGBA format as in grSstWinOpen() @@ -101,14 +95,34 @@ typedef struct //Hurdler: Transform (coords + angles) //BP: transform order : scale(rotation_x(rotation_y(translation(v)))) + +// Kart features +//#define USE_FTRANSFORM_ANGLEZ +//#define USE_FTRANSFORM_MIRROR + +// Vanilla features +#define USE_MODEL_NEXTFRAME + typedef struct { FLOAT x,y,z; // position +#ifdef USE_FTRANSFORM_ANGLEZ + FLOAT anglex,angley,anglez; // aimingangle / viewangle +#else FLOAT anglex,angley; // aimingangle / viewangle +#endif FLOAT scalex,scaley,scalez; FLOAT fovxangle, fovyangle; - INT32 splitscreen; + UINT8 splitscreen; boolean flip; // screenflip + boolean roll; + SINT8 rollflip; + FLOAT rollangle; // done to not override USE_FTRANSFORM_ANGLEZ + UINT8 rotaxis; + FLOAT centerx, centery; +#ifdef USE_FTRANSFORM_MIRROR + boolean mirror; // SRB2Kart: Encore Mode +#endif } FTransform; // Transformed vector, as passed to HWR API @@ -151,7 +165,7 @@ enum EPolyFlags // When set, pass the color constant into the FSurfaceInfo -> FlatColor PF_NoTexture = 0x00002000, // Use the small white texture PF_Corona = 0x00004000, // Tell the rendrer we are drawing a corona - PF_MD2 = 0x00008000, // Tell the rendrer we are drawing an MD2 + PF_Unused = 0x00008000, // Unused PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y PF_ForceWrapX = 0x00020000, // Force repeat texture on X PF_ForceWrapY = 0x00040000, // Force repeat texture on Y @@ -204,13 +218,10 @@ typedef struct FSurfaceInfo FSurfaceInfo; //Hurdler: added for backward compatibility enum hwdsetspecialstate { - HWD_SET_FOG_TABLE = 1, + HWD_SET_MODEL_LIGHTING = 1, HWD_SET_FOG_MODE, HWD_SET_FOG_COLOR, HWD_SET_FOG_DENSITY, - HWD_SET_FOV, - HWD_SET_POLYGON_SMOOTH, - HWD_SET_PALETTECOLOR, HWD_SET_TEXTUREFILTERMODE, HWD_SET_TEXTUREANISOTROPICMODE, HWD_NUMSTATE diff --git a/src/hardware/hw_dll.h b/src/hardware/hw_dll.h index 6b9f4d538..3fa5852d8 100644 --- a/src/hardware/hw_dll.h +++ b/src/hardware/hw_dll.h @@ -40,14 +40,14 @@ #define EXPORT #endif #endif - #if defined (_WIN32) && !defined (_XBOX) + #ifdef _WIN32 #define HWRAPI(fn) WINAPI fn #else #define HWRAPI(fn) fn #endif #else // _CREATE_DLL_ #define EXPORT typedef - #if defined (_WIN32) && !defined (_XBOX) + #ifdef _WIN32 #define HWRAPI(fn) (WINAPI *fn) #else #define HWRAPI(fn) (*fn) @@ -61,9 +61,6 @@ typedef void (*I_Error_t) (const char *error, ...) FUNCIERROR; // ========================================================================== // Constants -#ifndef M_PIl -#define M_PIl 3.1415926535897932384626433832795029L -#endif #define DEGREE (0.017453292519943295769236907684883l) // 2*PI/360 void DBG_Printf(const char *lpFmt, ...) /*FUNCPRINTF*/; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 55bbde459..598a635aa 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -33,6 +33,8 @@ #include "../z_zone.h" #include "../v_video.h" #include "../st_stuff.h" +#include "../p_local.h" // stplyr +#include "../g_game.h" // players #include #include "../i_video.h" // for rendermode != render_glide @@ -135,7 +137,7 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) HWD.pfnDrawPolygon(NULL, v, 4, flags); } -void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, const UINT8 *colormap) +void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap) { FOutVector v[4]; FBITFIELD flags; @@ -147,7 +149,9 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // | /| // |/ | // 0--1 - float dupx, dupy, fscale, fwidth, fheight; + float dupx, dupy, fscalew, fscaleh, fwidth, fheight; + + UINT8 perplayershuffle = 0; if (alphalevel >= 10 && alphalevel < 13) return; @@ -177,7 +181,9 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, } dupx = dupy = (dupx < dupy ? dupx : dupy); - fscale = FIXED_TO_FLOAT(pscale); + fscalew = fscaleh = FIXED_TO_FLOAT(pscale); + if (vscale != pscale) + fscaleh = FIXED_TO_FLOAT(vscale); // See my comments in v_video.c's V_DrawFixedPatch // -- Monster Iestyn 29/10/18 @@ -186,13 +192,13 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // left offset if (option & V_FLIP) - offsetx = (float)(SHORT(gpatch->width) - SHORT(gpatch->leftoffset)) * fscale; + offsetx = (float)(SHORT(gpatch->width) - SHORT(gpatch->leftoffset)) * fscalew; else - offsetx = (float)SHORT(gpatch->leftoffset) * fscale; + offsetx = (float)SHORT(gpatch->leftoffset) * fscalew; // top offset // TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!? - offsety = (float)SHORT(gpatch->topoffset) * fscale; + offsety = (float)SHORT(gpatch->topoffset) * fscaleh; if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs { @@ -204,8 +210,73 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, cy -= offsety; } - if (option & V_SPLITSCREEN) + if (splitscreen && (option & V_PERPLAYER)) + { + float adjusty = ((option & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + fscaleh /= 2; cy /= 2; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + float adjustx = ((option & V_NOSCALESTART) ? vid.width : BASEVIDWIDTH)/2.0f; + fscalew /= 2; + cx /= 2; + if (stplyr == &players[displayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + option &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + cx += adjustx; + option &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + cy += adjusty; + option &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else if (stplyr == &players[fourthdisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(option & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + cx += adjustx; + cy += adjusty; + option &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle = 1; + option &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(option & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle = 2; + cy += adjusty; + option &= ~V_SNAPTOTOP; + } + } + } if (!(option & V_NOSCALESTART)) { @@ -214,7 +285,7 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, if (!(option & V_SCALEPATCHMASK)) { - // if it's meant to cover the whole screen, black out the rest + // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) @@ -222,8 +293,11 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, // Need to temporarily cache the real patch to get the colour of the top left pixel patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0])); - const UINT8 *source = (const UINT8 *)(column) + 3; - HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + if (!column->topdelta) + { + const UINT8 *source = (const UINT8 *)(column) + 3; + HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + } Z_Free(realpatch); } // centre screen @@ -233,23 +307,29 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; + if (perplayershuffle & 4) + cx -= ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/4; + else if (perplayershuffle & 8) + cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/4; } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) - cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); - else if (option & V_SNAPTOBOTTOM) + if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; + if (perplayershuffle & 1) + cy -= ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/4; + else if (perplayershuffle & 2) + cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/4; } } } - if (pscale != FRACUNIT) + if (pscale != FRACUNIT || (splitscreen && option & V_PERPLAYER)) { - fwidth = (float)SHORT(gpatch->width) * fscale * dupx; - fheight = (float)SHORT(gpatch->height) * fscale * dupy; + fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; + fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; } else { @@ -300,9 +380,9 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, { FSurfaceInfo Surf; Surf.FlatColor.s.red = Surf.FlatColor.s.green = Surf.FlatColor.s.blue = 0xff; - if (alphalevel == 13) Surf.FlatColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value]; - else if (alphalevel == 14) Surf.FlatColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; - else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; + if (alphalevel == 13) Surf.FlatColor.s.alpha = softwaretranstogl_lo[st_translucency]; + else if (alphalevel == 14) Surf.FlatColor.s.alpha = softwaretranstogl[st_translucency]; + else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[st_translucency]; else Surf.FlatColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); @@ -352,6 +432,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal dupx = dupy = (dupx < dupy ? dupx : dupy); fscale = FIXED_TO_FLOAT(pscale); + // fuck it, no GL support for croppedpatch v_perplayer right now. it's not like it's accessible to Lua or anything, and we only use it for menus... + cy -= (float)SHORT(gpatch->topoffset) * fscale; cx -= (float)SHORT(gpatch->leftoffset) * fscale; @@ -362,7 +444,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal if (!(option & V_SCALEPATCHMASK)) { - // if it's meant to cover the whole screen, black out the rest + // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) // cx and cy are possibly *slightly* off from float maths // This is done before here compared to software because we directly alter cx and cy to centre if (cx >= -0.1f && cx <= 0.1f && SHORT(gpatch->width) == BASEVIDWIDTH && cy >= -0.1f && cy <= 0.1f && SHORT(gpatch->height) == BASEVIDHEIGHT) @@ -370,8 +452,11 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal // Need to temporarily cache the real patch to get the colour of the top left pixel patch_t *realpatch = W_CacheLumpNumPwad(gpatch->wadnum, gpatch->lumpnum, PU_STATIC); const column_t *column = (const column_t *)((const UINT8 *)(realpatch) + LONG((realpatch)->columnofs[0])); - const UINT8 *source = (const UINT8 *)(column) + 3; - HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + if (!column->topdelta) + { + const UINT8 *source = (const UINT8 *)(column) + 3; + HWR_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + } Z_Free(realpatch); } // centre screen @@ -384,9 +469,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { - if ((option & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) - cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); - else if (option & V_SNAPTOBOTTOM) + if (option & V_SNAPTOBOTTOM) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; @@ -397,12 +480,6 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal fwidth = w; fheight = h; - if (fwidth > w - sx) - fwidth = w - sx; - - if (fheight > h - sy) - fheight = h - sy; - if (fwidth > SHORT(gpatch->width)) fwidth = SHORT(gpatch->width); @@ -437,10 +514,17 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; - v[0].sow = v[3].sow = ((sx)/(float)SHORT(gpatch->width) )*gpatch->max_s; - v[2].sow = v[1].sow = ((w )/(float)SHORT(gpatch->width) )*gpatch->max_s; - v[0].tow = v[1].tow = ((sy)/(float)SHORT(gpatch->height))*gpatch->max_t; - v[2].tow = v[3].tow = ((h )/(float)SHORT(gpatch->height))*gpatch->max_t; + v[0].sow = v[3].sow = ((sx )/(float)SHORT(gpatch->width) )*gpatch->max_s; + if (sx + w > SHORT(gpatch->width)) + v[2].sow = v[1].sow = gpatch->max_s; + else + v[2].sow = v[1].sow = ((sx+w)/(float)SHORT(gpatch->width) )*gpatch->max_s; + + v[0].tow = v[1].tow = ((sy )/(float)SHORT(gpatch->height))*gpatch->max_t; + if (sy + h > SHORT(gpatch->height)) + v[2].tow = v[3].tow = gpatch->max_t; + else + v[2].tow = v[3].tow = ((sy+h)/(float)SHORT(gpatch->height))*gpatch->max_t; flags = BLENDMODE|PF_Clip|PF_NoZClip|PF_NoDepthTest; @@ -454,9 +538,9 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal { FSurfaceInfo Surf; Surf.FlatColor.s.red = Surf.FlatColor.s.green = Surf.FlatColor.s.blue = 0xff; - if (alphalevel == 13) Surf.FlatColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value]; - else if (alphalevel == 14) Surf.FlatColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; - else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; + if (alphalevel == 13) Surf.FlatColor.s.alpha = softwaretranstogl_lo[st_translucency]; + else if (alphalevel == 14) Surf.FlatColor.s.alpha = softwaretranstogl[st_translucency]; + else if (alphalevel == 15) Surf.FlatColor.s.alpha = softwaretranstogl_hi[st_translucency]; else Surf.FlatColor.s.alpha = softwaretranstogl[10-alphalevel]; flags |= PF_Modulated; HWD.pfnDrawPolygon(&Surf, v, 4, flags); @@ -565,7 +649,7 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum v[0].tow = v[1].tow = (float)((y & flatflag)/dflatsize); v[2].tow = v[3].tow = (float)(v[0].tow + h/dflatsize); - HWR_GetFlat(flatlumpnum); + HWR_LiterallyGetFlat(flatlumpnum); //Hurdler: Boris, the same comment as above... but maybe for pics // it not a problem since they don't have any transparent pixel @@ -584,18 +668,14 @@ void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum // | /| // |/ | // 0--1 -void HWR_FadeScreenMenuBack(UINT32 color, INT32 height) +void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) { FOutVector v[4]; FSurfaceInfo Surf; - // setup some neat-o translucency effect - if (!height) //cool hack 0 height is full height - height = vid.height; - v[0].x = v[3].x = -1.0f; v[2].x = v[1].x = 1.0f; - v[0].y = v[1].y = 1.0f-((height<<1)/(float)vid.height); + v[0].y = v[1].y = -1.0f; v[2].y = v[3].y = 1.0f; v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; @@ -604,8 +684,191 @@ void HWR_FadeScreenMenuBack(UINT32 color, INT32 height) v[0].tow = v[1].tow = 1.0f; v[2].tow = v[3].tow = 0.0f; - Surf.FlatColor.rgba = UINT2RGBA(color); - Surf.FlatColor.s.alpha = (UINT8)((0xff/2) * ((float)height / vid.height)); //calum: varies console alpha + if (color & 0xFF00) // Do COLORMAP fade. + { + Surf.FlatColor.rgba = UINT2RGBA(0x01010160); + Surf.FlatColor.s.alpha = (strength*8); + } + else // Do TRANSMAP** fade. + { + Surf.FlatColor.rgba = V_GetColor(color).rgba; + Surf.FlatColor.s.alpha = softwaretranstogl[strength]; + } + HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); +} + +// -----------------+ +// HWR_DrawFadeFill : draw flat coloured rectangle, with transparency +// -----------------+ +void HWR_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT16 actualcolor, UINT8 strength) +{ + FOutVector v[4]; + FSurfaceInfo Surf; + float fx, fy, fw, fh; + + UINT8 perplayershuffle = 0; + +// 3--2 +// | /| +// |/ | +// 0--1 + + if (splitscreen && (color & V_PERPLAYER)) + { + fixed_t adjusty = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + h >>= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + w >>= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + color &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + color &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + color &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + color &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + color &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + color &= ~V_SNAPTOTOP; + } + } + } + + fx = (float)x; + fy = (float)y; + fw = (float)w; + fh = (float)h; + + if (!(color & V_NOSCALESTART)) + { + float dupx = (float)vid.dupx, dupy = (float)vid.dupy; + + fx *= dupx; + fy *= dupy; + fw *= dupx; + fh *= dupy; + + if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + { + if (color & V_SNAPTORIGHT) + fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + else if (!(color & V_SNAPTOLEFT)) + fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + fx -= ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 4; + } + if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + { + // same thing here + if (color & V_SNAPTOBOTTOM) + fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + else if (!(color & V_SNAPTOTOP)) + fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + fy -= ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 4; + } + } + + if (fx >= vid.width || fy >= vid.height) + return; + if (fx < 0) + { + fw += fx; + fx = 0; + } + if (fy < 0) + { + fh += fy; + fy = 0; + } + + if (fw <= 0 || fh <= 0) + return; + if (fx + fw > vid.width) + fw = (float)vid.width - fx; + if (fy + fh > vid.height) + fh = (float)vid.height - fy; + + fx = -1 + fx / (vid.width / 2); + fy = 1 - fy / (vid.height / 2); + fw = fw / (vid.width / 2); + fh = fh / (vid.height / 2); + + v[0].x = v[3].x = fx; + v[2].x = v[1].x = fx + fw; + v[0].y = v[1].y = fy; + v[2].y = v[3].y = fy - fh; + + //Hurdler: do we still use this argb color? if not, we should remove it + v[0].argb = v[1].argb = v[2].argb = v[3].argb = 0xff00ff00; //; + v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; + + v[0].sow = v[3].sow = 0.0f; + v[2].sow = v[1].sow = 1.0f; + v[0].tow = v[1].tow = 0.0f; + v[2].tow = v[3].tow = 1.0f; + + if (actualcolor & 0xFF00) // Do COLORMAP fade. + { + Surf.FlatColor.rgba = UINT2RGBA(0x01010160); + Surf.FlatColor.s.alpha = (strength*8); + } + else // Do TRANSMAP** fade. + { + Surf.FlatColor.rgba = V_GetColor(actualcolor).rgba; + Surf.FlatColor.s.alpha = softwaretranstogl[strength]; + } HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } @@ -636,6 +899,32 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height) HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); } +// Very similar to HWR_DrawConsoleBack, except we draw from the middle(-ish) of the screen to the bottom. +void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight) +{ + FOutVector v[4]; + FSurfaceInfo Surf; + INT32 height = (boxheight * 4) + (boxheight/2)*5; // 4 lines of space plus gaps between and some leeway + + // setup some neat-o translucency effect + + v[0].x = v[3].x = -1.0f; + v[2].x = v[1].x = 1.0f; + v[0].y = v[1].y = -1.0f; + v[2].y = v[3].y = -1.0f+((height<<1)/(float)vid.height); + v[0].z = v[1].z = v[2].z = v[3].z = 1.0f; + + v[0].sow = v[3].sow = 0.0f; + v[2].sow = v[1].sow = 1.0f; + v[0].tow = v[1].tow = 1.0f; + v[2].tow = v[3].tow = 0.0f; + + Surf.FlatColor.rgba = UINT2RGBA(color); + Surf.FlatColor.s.alpha = (color == 0 ? 0xC0 : 0x80); // make black darker, like software + + HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); +} + // ========================================================================== // R_DRAW.C STUFF @@ -703,7 +992,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // top edge if (clearlines > basewindowy - 8) { - patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH); for (x = 0; x < baseviewwidth; x += 8) HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8, 0); @@ -712,7 +1001,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // bottom edge if (clearlines > basewindowy + baseviewheight) { - patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH); for (x = 0; x < baseviewwidth; x += 8) HWR_DrawPatch(patch, basewindowx + x, basewindowy + baseviewheight, 0); @@ -721,7 +1010,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // left edge if (clearlines > basewindowy) { - patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH); for (y = 0; y < baseviewheight && basewindowy + y < clearlines; y += 8) { @@ -733,7 +1022,7 @@ void HWR_DrawViewBorder(INT32 clearlines) // right edge if (clearlines > basewindowy) { - patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_CACHE); + patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH); for (y = 0; y < baseviewheight && basewindowy+y < clearlines; y += 8) { @@ -745,22 +1034,22 @@ void HWR_DrawViewBorder(INT32 clearlines) // Draw beveled corners. if (clearlines > basewindowy - 8) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TL], - PU_CACHE), + PU_PATCH), basewindowx - 8, basewindowy - 8, 0); if (clearlines > basewindowy - 8) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TR], - PU_CACHE), + PU_PATCH), basewindowx + baseviewwidth, basewindowy - 8, 0); if (clearlines > basewindowy+baseviewheight) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BL], - PU_CACHE), + PU_PATCH), basewindowx - 8, basewindowy + baseviewheight, 0); if (clearlines > basewindowy + baseviewheight) HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BR], - PU_CACHE), + PU_PATCH), basewindowx + baseviewwidth, basewindowy + baseviewheight, 0); } @@ -793,60 +1082,123 @@ void HWR_drawAMline(const fline_t *fl, INT32 color) // -------------------+ // HWR_DrawConsoleFill : draw flat coloured transparent rectangle because that's cool, and hw sucks less than sw for that. // -------------------+ -void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options) +void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32 actualcolor) { FOutVector v[4]; FSurfaceInfo Surf; float fx, fy, fw, fh; - if (w < 0 || h < 0) - return; // consistency w/ software + UINT8 perplayershuffle = 0; // 3--2 // | /| // |/ | // 0--1 + if (splitscreen && (color & V_PERPLAYER)) + { + fixed_t adjusty = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + h >>= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + w >>= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + color &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + color &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + color &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + color &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + color &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + color &= ~V_SNAPTOTOP; + } + } + } + fx = (float)x; fy = (float)y; fw = (float)w; fh = (float)h; - if (!(options & V_NOSCALESTART)) + if (!(color & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; - if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT) - { - RGBA_t rgbaColour = V_GetColor(color); - FRGBAFloat clearColour; - clearColour.red = (float)rgbaColour.s.red / 255; - clearColour.green = (float)rgbaColour.s.green / 255; - clearColour.blue = (float)rgbaColour.s.blue / 255; - clearColour.alpha = 1; - HWD.pfnClearBuffer(true, false, &clearColour); - return; - } - fx *= dupx; fy *= dupy; fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f) + if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) { - if (options & V_SNAPTORIGHT) + if (color & V_SNAPTORIGHT) fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); - else if (!(options & V_SNAPTOLEFT)) + else if (!(color & V_SNAPTOLEFT)) fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + fx -= ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 4; } - if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f) + if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { // same thing here - if (options & V_SNAPTOBOTTOM) + if (color & V_SNAPTOBOTTOM) fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); - else if (!(options & V_SNAPTOTOP)) + else if (!(color & V_SNAPTOTOP)) fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + fy -= ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 4; } } @@ -889,7 +1241,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 v[0].tow = v[1].tow = 0.0f; v[2].tow = v[3].tow = 1.0f; - Surf.FlatColor.rgba = UINT2RGBA(color); + Surf.FlatColor.rgba = UINT2RGBA(actualcolor); Surf.FlatColor.s.alpha = 0x80; HWD.pfnDrawPolygon(&Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest); @@ -904,14 +1256,81 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) FSurfaceInfo Surf; float fx, fy, fw, fh; - if (w < 0 || h < 0) - return; // consistency w/ software + UINT8 perplayershuffle = 0; // 3--2 // | /| // |/ | // 0--1 + if (splitscreen && (color & V_PERPLAYER)) + { + fixed_t adjusty = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + h >>= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((color & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)/2.0f; + w >>= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + color &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + color &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + color &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(color & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + color &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + color &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(color & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + color &= ~V_SNAPTOTOP; + } + } + } + fx = (float)x; fy = (float)y; fw = (float)w; @@ -944,6 +1363,10 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + fx -= ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 4; } if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) { @@ -952,6 +1375,10 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); else if (!(color & V_SNAPTOTOP)) fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + fy -= ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 4; } } @@ -1082,21 +1509,24 @@ UINT8 *HWR_GetScreenshot(void) return buf; } -boolean HWR_Screenshot(const char *lbmname) +boolean HWR_Screenshot(const char *pathname) { boolean ret; UINT8 *buf = malloc(vid.width * vid.height * 3 * sizeof (*buf)); if (!buf) + { + CONS_Debug(DBG_RENDER, "HWR_Screenshot: Failed to allocate memory\n"); return false; + } // returns 24bit 888 RGB HWD.pfnReadRect(0, 0, vid.width, vid.height, vid.width * 3, (void *)buf); #ifdef USE_PNG - ret = M_SavePNG(lbmname, buf, vid.width, vid.height, NULL); + ret = M_SavePNG(pathname, buf, vid.width, vid.height, NULL); #else - ret = saveTGA(lbmname, buf, vid.width, vid.height); + ret = saveTGA(pathname, buf, vid.width, vid.height); #endif free(buf); return ret; diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index e2fa90eb0..3314fb015 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -39,14 +39,11 @@ EXPORT void HWRAPI(Shutdown) (void); #ifdef _WINDOWS EXPORT void HWRAPI(GetModeList) (vmode_t **pvidmodes, INT32 *numvidmodes); #endif -#if defined (PURESDL) || defined (macintosh) -EXPORT void HWRAPI(SetPalette) (INT32 *, RGBA_t *gamma); -#else -EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal, RGBA_t *pgamma); -#endif +EXPORT void HWRAPI(SetPalette) (RGBA_t *ppal); EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl); EXPORT void HWRAPI(Draw2DLine) (F2DCoord *v1, F2DCoord *v2, RGBA_t Color); EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags); +EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform); EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags); EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); EXPORT void HWRAPI(SetTexture) (FTextureInfo *TexInfo); @@ -58,20 +55,18 @@ EXPORT void HWRAPI(ClearMipMapCache) (void); EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value); //Hurdler: added for new development -EXPORT void HWRAPI(DrawMD2) (INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale); -EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, INT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color); +EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 *color); +EXPORT void HWRAPI(CreateModelVBOs) (model_t *model); EXPORT void HWRAPI(SetTransform) (FTransform *ptransform); EXPORT INT32 HWRAPI(GetTextureUsed) (void); EXPORT INT32 HWRAPI(GetRenderVersion) (void); -#ifdef SHUFFLE #define SCREENVERTS 10 EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]); -#endif EXPORT void HWRAPI(FlushScreenTextures) (void); EXPORT void HWRAPI(StartScreenWipe) (void); EXPORT void HWRAPI(EndScreenWipe) (void); -EXPORT void HWRAPI(DoScreenWipe) (float alpha); +EXPORT void HWRAPI(DoScreenWipe) (void); EXPORT void HWRAPI(DrawIntermissionBG) (void); EXPORT void HWRAPI(MakeScreenTexture) (void); EXPORT void HWRAPI(MakeScreenFinalTexture) (void); @@ -89,6 +84,7 @@ struct hwdriver_s FinishUpdate pfnFinishUpdate; Draw2DLine pfnDraw2DLine; DrawPolygon pfnDrawPolygon; + RenderSkyDome pfnRenderSkyDome; SetBlend pfnSetBlend; ClearBuffer pfnClearBuffer; SetTexture pfnSetTexture; @@ -96,8 +92,8 @@ struct hwdriver_s GClipRect pfnGClipRect; ClearMipMapCache pfnClearMipMapCache; SetSpecialState pfnSetSpecialState;//Hurdler: added for backward compatibility - DrawMD2 pfnDrawMD2; - DrawMD2i pfnDrawMD2i; + DrawModel pfnDrawModel; + CreateModelVBOs pfnCreateModelVBOs; SetTransform pfnSetTransform; GetTextureUsed pfnGetTextureUsed; GetRenderVersion pfnGetRenderVersion; @@ -107,9 +103,7 @@ struct hwdriver_s #ifndef HAVE_SDL Shutdown pfnShutdown; #endif -#ifdef SHUFFLE PostImgRedraw pfnPostImgRedraw; -#endif FlushScreenTextures pfnFlushScreenTextures; StartScreenWipe pfnStartScreenWipe; EndScreenWipe pfnEndScreenWipe; diff --git a/src/hardware/hw_glide.h b/src/hardware/hw_glide.h index 2625d5864..bf91229ef 100644 --- a/src/hardware/hw_glide.h +++ b/src/hardware/hw_glide.h @@ -59,9 +59,11 @@ typedef FxI32 GrTextureFormat_t; typedef struct { +#ifdef GLIDE_API_COMPATIBILITY GrLOD_t smallLodLog2; GrLOD_t largeLodLog2; GrAspectRatio_t aspectRatioLog2; +#endif GrTextureFormat_t format; void *data; } GrTexInfo; diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index bdf219464..a2bf79817 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -23,6 +23,7 @@ #include "hw_defs.h" #include "hw_main.h" #include "../m_misc.h" +#include "../p_setup.h" // the original aspect ratio of Doom graphics isn't square #define ORIGINAL_ASPECT (320.0f/200.0f) @@ -71,9 +72,9 @@ typedef struct gr_vissprite_s struct gr_vissprite_s *prev; struct gr_vissprite_s *next; float x1, x2; - float z1, z2; float tz, ty; - lumpnum_t patchlumpnum; + //lumpnum_t patchlumpnum; + GLPatch_t *gpatch; boolean flip; UINT8 translucency; //alpha level 0-255 mobj_t *mobj; @@ -82,6 +83,7 @@ typedef struct gr_vissprite_s //Hurdler: 25/04/2000: now support colormap in hardware mode UINT8 *colormap; INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing + float z1, z2; } gr_vissprite_t; // -------- @@ -98,9 +100,11 @@ void HWR_FreePolyPool(void); // -------- void HWR_InitTextureCache(void); void HWR_FreeTextureCache(void); +void HWR_FreeMipmapCache(void); void HWR_FreeExtraSubsectors(void); -void HWR_GetFlat(lumpnum_t flatlumpnum); +void HWR_GetLevelFlat(levelflat_t *levelflat); +void HWR_LiterallyGetFlat(lumpnum_t flatlumpnum); GLTexture_t *HWR_GetTexture(INT32 tex); void HWR_GetPatch(GLPatch_t *gpatch); void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap); @@ -121,6 +125,5 @@ extern consvar_t cv_grrounddown; // on/off extern INT32 patchformat; extern INT32 textureformat; -extern boolean firetranslucent; #endif //_HW_GLOB_ diff --git a/src/hardware/hw_light.c b/src/hardware/hw_light.c index a93e96dc3..c5af8d6d3 100644 --- a/src/hardware/hw_light.c +++ b/src/hardware/hw_light.c @@ -62,7 +62,7 @@ static dynlights_t *dynlights = &view_dynlights[0]; light_t lspr[NUMLIGHTS] = { // type offset x, y coronas color, c_size,light color,l_radius, sqr radius computed at init - // UNDEFINED: 0 + // NOLIGHT: 0 { UNDEFINED_SPR, 0.0f, 0.0f, 0x00000000, 24.0f, 0x00000000, 0.0f, 0.0f}, // weapons // RINGSPARK_L @@ -151,10 +151,9 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_POSS &lspr[NOLIGHT], // SPR_SPOS &lspr[NOLIGHT], // SPR_FISH - &lspr[NOLIGHT], // SPR_BUZZ Graue 03-10-2004 - &lspr[NOLIGHT], // SPR_RBUZ Graue 03-10-2004 + &lspr[NOLIGHT], // SPR_BUZZ + &lspr[NOLIGHT], // SPR_RBUZ &lspr[NOLIGHT], // SPR_JETB - &lspr[NOLIGHT], // SPR_JETW &lspr[NOLIGHT], // SPR_JETG &lspr[NOLIGHT], // SPR_CCOM &lspr[NOLIGHT], // SPR_DETN @@ -162,44 +161,64 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_TRET &lspr[NOLIGHT], // SPR_TURR &lspr[NOLIGHT], // SPR_SHRP + &lspr[NOLIGHT], // SPR_CRAB + &lspr[NOLIGHT], // SPR_CR2B + &lspr[NOLIGHT], // SPR_CSPR &lspr[NOLIGHT], // SPR_JJAW &lspr[NOLIGHT], // SPR_SNLR &lspr[NOLIGHT], // SPR_VLTR &lspr[NOLIGHT], // SPR_PNTY &lspr[NOLIGHT], // SPR_ARCH &lspr[NOLIGHT], // SPR_CBFS + &lspr[JETLIGHT_L], // SPR_STAB &lspr[NOLIGHT], // SPR_SPSH &lspr[NOLIGHT], // SPR_ESHI &lspr[NOLIGHT], // SPR_GSNP + &lspr[NOLIGHT], // SPR_GSNL + &lspr[NOLIGHT], // SPR_GSNH &lspr[NOLIGHT], // SPR_MNUS + &lspr[NOLIGHT], // SPR_MNUD &lspr[NOLIGHT], // SPR_SSHL &lspr[NOLIGHT], // SPR_UNID - &lspr[NOLIGHT], // SPR_BBUZ + &lspr[NOLIGHT], // SPR_CANA + &lspr[NOLIGHT], // SPR_CANG + &lspr[NOLIGHT], // SPR_PYRE + &lspr[NOLIGHT], // SPR_PTER + &lspr[NOLIGHT], // SPR_DRAB // Generic Boos Items &lspr[JETLIGHT_L], // SPR_JETF // Boss jet fumes // Boss 1, (Greenflower) &lspr[NOLIGHT], // SPR_EGGM + &lspr[NOLIGHT], // SPR_EGLZ // Boss 2, (Techno Hill) &lspr[NOLIGHT], // SPR_EGGN - &lspr[NOLIGHT], // SPR_TNKA - &lspr[NOLIGHT], // SPR_TNKB - &lspr[NOLIGHT], // SPR_SPNK + &lspr[NOLIGHT], // SPR_TANK &lspr[NOLIGHT], // SPR_GOOP // Boss 3 (Deep Sea) &lspr[NOLIGHT], // SPR_EGGO - &lspr[NOLIGHT], // SPR_PRPL + &lspr[NOLIGHT], // SPR_SEBH &lspr[NOLIGHT], // SPR_FAKE + &lspr[LBLUESHINE_L],// SPR_SHCK // Boss 4 (Castle Eggman) &lspr[NOLIGHT], // SPR_EGGP &lspr[REDBALL_L], // SPR_EFIR + &lspr[NOLIGHT], // SPR_EGR1 // Boss 5 (Arid Canyon) - &lspr[NOLIGHT], // SPR_EGGQ + &lspr[NOLIGHT], // SPR_FANG // replaces EGGQ + &lspr[NOLIGHT], // SPR_BRKN + &lspr[NOLIGHT], // SPR_WHAT + &lspr[INVINCIBLE_L], // SPR_VWRE + &lspr[INVINCIBLE_L], // SPR_PROJ + &lspr[NOLIGHT], // SPR_FBOM + &lspr[NOLIGHT], // SPR_FSGN + &lspr[REDBALL_L], // SPR_BARX // bomb explosion (also used by barrel) + &lspr[NOLIGHT], // SPR_BARD // bomb dust (also used by barrel) // Boss 6 (Red Volcano) &lspr[NOLIGHT], // SPR_EEGR @@ -226,48 +245,56 @@ light_t *t_lspr[NUMSPRITES] = // Collectible Items &lspr[NOLIGHT], // SPR_RING &lspr[NOLIGHT], // SPR_TRNG - &lspr[NOLIGHT], // SPR_EMMY - &lspr[BLUEBALL_L], // SPR_TOKE - &lspr[REDBALL_L], // SPR_RFLG - &lspr[BLUEBALL_L], // SPR_BFLG - &lspr[NOLIGHT], // SPR_NWNG + &lspr[NOLIGHT], // SPR_TOKE + &lspr[REDBALL_L], // SPR_RFLG + &lspr[BLUEBALL_L], // SPR_BFLG + &lspr[NOLIGHT], // SPR_SPHR + &lspr[NOLIGHT], // SPR_NCHP + &lspr[NOLIGHT], // SPR_NSTR &lspr[NOLIGHT], // SPR_EMBM &lspr[NOLIGHT], // SPR_CEMG - &lspr[NOLIGHT], // SPR_EMER + &lspr[NOLIGHT], // SPR_SHRD // Interactive Objects - &lspr[NOLIGHT], // SPR_FANS - &lspr[NOLIGHT], // SPR_BUBL + &lspr[NOLIGHT], // SPR_BBLS &lspr[NOLIGHT], // SPR_SIGN - &lspr[NOLIGHT], // SPR_STEM &lspr[NOLIGHT], // SPR_SPIK &lspr[NOLIGHT], // SPR_SFLM &lspr[NOLIGHT], // SPR_USPK + &lspr[NOLIGHT], // SPR_WSPK + &lspr[NOLIGHT], // SPR_WSPB &lspr[NOLIGHT], // SPR_STPT &lspr[NOLIGHT], // SPR_BMNE + &lspr[NOLIGHT], // SPR_PUMI // Monitor Boxes - &lspr[NOLIGHT], // SPR_SRBX - &lspr[NOLIGHT], // SPR_RRBX - &lspr[NOLIGHT], // SPR_BRBX - &lspr[NOLIGHT], // SPR_SHTV - &lspr[NOLIGHT], // SPR_PINV - &lspr[NOLIGHT], // SPR_YLTV - &lspr[NOLIGHT], // SPR_BLTV - &lspr[NOLIGHT], // SPR_BKTV - &lspr[NOLIGHT], // SPR_WHTV - &lspr[NOLIGHT], // SPR_GRTV - &lspr[NOLIGHT], // SPR_ELTV - &lspr[NOLIGHT], // SPR_EGGB - &lspr[NOLIGHT], // SPR_MIXU - &lspr[NOLIGHT], // SPR_RECY - &lspr[NOLIGHT], // SPR_QUES - &lspr[NOLIGHT], // SPR_GBTV - &lspr[NOLIGHT], // SPR_PRUP - &lspr[NOLIGHT], // SPR_PTTV + &lspr[NOLIGHT], // SPR_MSTV + &lspr[NOLIGHT], // SPR_XLTV - // Monitor Miscellany - &lspr[NOLIGHT], // SPR_MTEX + &lspr[NOLIGHT], // SPR_TRRI + &lspr[NOLIGHT], // SPR_TBRI + + &lspr[NOLIGHT], // SPR_TVRI + &lspr[NOLIGHT], // SPR_TVPI + &lspr[NOLIGHT], // SPR_TVAT + &lspr[NOLIGHT], // SPR_TVFO + &lspr[NOLIGHT], // SPR_TVAR + &lspr[NOLIGHT], // SPR_TVWW + &lspr[NOLIGHT], // SPR_TVEL + &lspr[NOLIGHT], // SPR_TVSS + &lspr[NOLIGHT], // SPR_TVIV + &lspr[NOLIGHT], // SPR_TV1U + &lspr[NOLIGHT], // SPR_TV1P + &lspr[NOLIGHT], // SPR_TVEG + &lspr[NOLIGHT], // SPR_TVMX + &lspr[NOLIGHT], // SPR_TVMY + &lspr[NOLIGHT], // SPR_TVGV + &lspr[NOLIGHT], // SPR_TVRC + &lspr[NOLIGHT], // SPR_TV1K + &lspr[NOLIGHT], // SPR_TVTK + &lspr[NOLIGHT], // SPR_TVFL + &lspr[NOLIGHT], // SPR_TVBB + &lspr[NOLIGHT], // SPR_TVZP // Projectiles &lspr[NOLIGHT], // SPR_MISL @@ -287,10 +314,19 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_FWR4 &lspr[NOLIGHT], // SPR_BUS1 &lspr[NOLIGHT], // SPR_BUS2 + &lspr[NOLIGHT], // SPR_BUS3 + // Trees (both GFZ and misc) + &lspr[NOLIGHT], // SPR_TRE1 + &lspr[NOLIGHT], // SPR_TRE2 + &lspr[NOLIGHT], // SPR_TRE3 + &lspr[NOLIGHT], // SPR_TRE4 + &lspr[NOLIGHT], // SPR_TRE5 + &lspr[NOLIGHT], // SPR_TRE6 // Techno Hill Scenery &lspr[NOLIGHT], // SPR_THZP - &lspr[REDBALL_L], // SPR_ALRM + &lspr[NOLIGHT], // SPR_FWR5 + &lspr[REDBALL_L], // SPR_ALRM // Deep Sea Scenery &lspr[NOLIGHT], // SPR_GARG @@ -309,15 +345,47 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_BMCH &lspr[NOLIGHT], // SPR_SMCE &lspr[NOLIGHT], // SPR_BMCE + &lspr[NOLIGHT], // SPR_YSPB + &lspr[NOLIGHT], // SPR_RSPB + &lspr[REDBALL_L], // SPR_SFBR + &lspr[REDBALL_L], // SPR_BFBR + &lspr[NOLIGHT], // SPR_BANR + &lspr[NOLIGHT], // SPR_PINE + &lspr[NOLIGHT], // SPR_CEZB + &lspr[REDBALL_L], // SPR_CNDL + &lspr[NOLIGHT], // SPR_FLMH + &lspr[REDBALL_L], // SPR_CTRC + &lspr[NOLIGHT], // SPR_CFLG + &lspr[NOLIGHT], // SPR_CSTA + &lspr[NOLIGHT], // SPR_CBBS // Arid Canyon Scenery &lspr[NOLIGHT], // SPR_BTBL &lspr[NOLIGHT], // SPR_STBL &lspr[NOLIGHT], // SPR_CACT + &lspr[NOLIGHT], // SPR_WWSG + &lspr[NOLIGHT], // SPR_WWS2 + &lspr[NOLIGHT], // SPR_WWS3 + &lspr[NOLIGHT], // SPR_OILL + &lspr[NOLIGHT], // SPR_OILF + &lspr[NOLIGHT], // SPR_BARR + &lspr[NOLIGHT], // SPR_REMT + &lspr[NOLIGHT], // SPR_TAZD + &lspr[NOLIGHT], // SPR_ADST + &lspr[NOLIGHT], // SPR_MCRT + &lspr[NOLIGHT], // SPR_MCSP + &lspr[NOLIGHT], // SPR_SALD + &lspr[NOLIGHT], // SPR_TRAE + &lspr[NOLIGHT], // SPR_TRAI + &lspr[NOLIGHT], // SPR_STEA // Red Volcano Scenery &lspr[REDBALL_L], // SPR_FLME &lspr[REDBALL_L], // SPR_DFLM + &lspr[NOLIGHT], // SPR_LFAL + &lspr[NOLIGHT], // SPR_JPLA + &lspr[NOLIGHT], // SPR_TFLO + &lspr[NOLIGHT], // SPR_WVIN // Dark City Scenery @@ -327,26 +395,43 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_XMS1 &lspr[NOLIGHT], // SPR_XMS2 &lspr[NOLIGHT], // SPR_XMS3 + &lspr[NOLIGHT], // SPR_XMS4 + &lspr[NOLIGHT], // SPR_XMS5 + &lspr[NOLIGHT], // SPR_XMS6 + &lspr[NOLIGHT], // SPR_FHZI + &lspr[NOLIGHT], // SPR_ROSY + + // Halloween Scenery + &lspr[RINGLIGHT_L], // SPR_PUMK + &lspr[NOLIGHT], // SPR_HHPL + &lspr[NOLIGHT], // SPR_SHRM + &lspr[NOLIGHT], // SPR_HHZM + + // Azure Temple Scenery + &lspr[NOLIGHT], // SPR_BGAR + &lspr[NOLIGHT], // SPR_RCRY + &lspr[GREENBALL_L], // SPR_CFLM // Botanic Serenity Scenery &lspr[NOLIGHT], // SPR_BSZ1 &lspr[NOLIGHT], // SPR_BSZ2 &lspr[NOLIGHT], // SPR_BSZ3 - &lspr[NOLIGHT], // SPR_BSZ4 + //&lspr[NOLIGHT], -- SPR_BSZ4 + &lspr[NOLIGHT], // SPR_BST1 + &lspr[NOLIGHT], // SPR_BST2 + &lspr[NOLIGHT], // SPR_BST3 + &lspr[NOLIGHT], // SPR_BST4 + &lspr[NOLIGHT], // SPR_BST5 + &lspr[NOLIGHT], // SPR_BST6 &lspr[NOLIGHT], // SPR_BSZ5 &lspr[NOLIGHT], // SPR_BSZ6 &lspr[NOLIGHT], // SPR_BSZ7 &lspr[NOLIGHT], // SPR_BSZ8 - // Stalagmites + // Misc Scenery &lspr[NOLIGHT], // SPR_STLG - - // Disco Ball &lspr[NOLIGHT], // SPR_DBAL - // ATZ Red Crystal - &lspr[NOLIGHT], // SPR_RCRY - // Powerup Indicators &lspr[NOLIGHT], // SPR_ARMA &lspr[NOLIGHT], // SPR_ARMF @@ -356,46 +441,78 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_ELEM &lspr[NOLIGHT], // SPR_FORC &lspr[NOLIGHT], // SPR_PITY - &lspr[INVINCIBLE_L], // SPR_IVSP - &lspr[SUPERSPARK_L], // SPR_SSPK + &lspr[NOLIGHT], // SPR_FIRS + &lspr[NOLIGHT], // SPR_BUBS + &lspr[NOLIGHT], // SPR_ZAPS + &lspr[INVINCIBLE_L], // SPR_IVSP + &lspr[SUPERSPARK_L], // SPR_SSPK &lspr[NOLIGHT], // SPR_GOAL - // Freed Animals - &lspr[NOLIGHT], // SPR_BIRD - &lspr[NOLIGHT], // SPR_BUNY - &lspr[NOLIGHT], // SPR_MOUS - &lspr[NOLIGHT], // SPR_CHIC - &lspr[NOLIGHT], // SPR_COWZ - &lspr[NOLIGHT], // SPR_RBRD + // Flickies + &lspr[NOLIGHT], // SPR_FBUB + &lspr[NOLIGHT], // SPR_FL01 + &lspr[NOLIGHT], // SPR_FL02 + &lspr[NOLIGHT], // SPR_FL03 + &lspr[NOLIGHT], // SPR_FL04 + &lspr[NOLIGHT], // SPR_FL05 + &lspr[NOLIGHT], // SPR_FL06 + &lspr[NOLIGHT], // SPR_FL07 + &lspr[NOLIGHT], // SPR_FL08 + &lspr[NOLIGHT], // SPR_FL09 + &lspr[NOLIGHT], // SPR_FL10 + &lspr[NOLIGHT], // SPR_FL11 + &lspr[NOLIGHT], // SPR_FL12 + &lspr[NOLIGHT], // SPR_FL13 + &lspr[NOLIGHT], // SPR_FL14 + &lspr[NOLIGHT], // SPR_FL15 + &lspr[NOLIGHT], // SPR_FL16 + &lspr[NOLIGHT], // SPR_FS01 + &lspr[NOLIGHT], // SPR_FS02 // Springs + &lspr[NOLIGHT], // SPR_FANS + &lspr[NOLIGHT], // SPR_STEM + &lspr[NOLIGHT], // SPR_BUMP + &lspr[NOLIGHT], // SPR_BLON &lspr[NOLIGHT], // SPR_SPRY &lspr[NOLIGHT], // SPR_SPRR - &lspr[NOLIGHT], // SPR_SPRB Graue + &lspr[NOLIGHT], // SPR_SPRB &lspr[NOLIGHT], // SPR_YSPR &lspr[NOLIGHT], // SPR_RSPR + &lspr[NOLIGHT], // SPR_BSPR + &lspr[NOLIGHT], // SPR_SSWY + &lspr[NOLIGHT], // SPR_SSWR + &lspr[NOLIGHT], // SPR_SSWB + &lspr[NOLIGHT], // SPR_BSTY + &lspr[NOLIGHT], // SPR_BSTR - // Environmentals Effects + // Environmental Effects &lspr[NOLIGHT], // SPR_RAIN &lspr[NOLIGHT], // SPR_SNO1 &lspr[NOLIGHT], // SPR_SPLH + &lspr[NOLIGHT], // SPR_LSPL &lspr[NOLIGHT], // SPR_SPLA &lspr[NOLIGHT], // SPR_SMOK - &lspr[NOLIGHT], // SPR_BUBP - &lspr[NOLIGHT], // SPR_BUBO - &lspr[NOLIGHT], // SPR_BUBN - &lspr[NOLIGHT], // SPR_BUBM - &lspr[NOLIGHT], // SPR_POPP + &lspr[NOLIGHT], // SPR_BUBL + &lspr[RINGLIGHT_L], // SPR_WZAP + &lspr[NOLIGHT], // SPR_DUST + &lspr[NOLIGHT], // SPR_FPRT &lspr[SUPERSPARK_L], // SPR_TFOG - &lspr[NIGHTSLIGHT_L], // SPR_SEED // Sonic CD flower seed + &lspr[NIGHTSLIGHT_L], // SPR_SEED &lspr[NOLIGHT], // SPR_PRTL // Game Indicators &lspr[NOLIGHT], // SPR_SCOR &lspr[NOLIGHT], // SPR_DRWN + &lspr[NOLIGHT], // SPR_FLII + &lspr[NOLIGHT], // SPR_LCKN &lspr[NOLIGHT], // SPR_TTAG &lspr[NOLIGHT], // SPR_GFLG + &lspr[NOLIGHT], // SPR_FNSF + + &lspr[NOLIGHT], // SPR_CORK + &lspr[NOLIGHT], // SPR_LHRT // Ring Weapons &lspr[RINGLIGHT_L], // SPR_RRNG @@ -424,29 +541,43 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_GOOM &lspr[NOLIGHT], // SPR_BGOM &lspr[REDBALL_L], // SPR_FFWR - &lspr[SMALLREDBALL_L], // SPR_FBLL + &lspr[SMALLREDBALL_L], // SPR_FBLL &lspr[NOLIGHT], // SPR_SHLL - &lspr[REDBALL_L], // SPR_PUMA + &lspr[REDBALL_L], // SPR_PUMA &lspr[NOLIGHT], // SPR_HAMM &lspr[NOLIGHT], // SPR_KOOP - &lspr[REDBALL_L], // SPR_BFLM + &lspr[REDBALL_L], // SPR_BFLM &lspr[NOLIGHT], // SPR_MAXE &lspr[NOLIGHT], // SPR_MUS1 &lspr[NOLIGHT], // SPR_MUS2 &lspr[NOLIGHT], // SPR_TOAD // NiGHTS Stuff - &lspr[SUPERSONIC_L], // SPR_NDRN // NiGHTS drone - &lspr[SUPERSONIC_L], // SPR_SUPE // NiGHTS character flying - &lspr[SUPERSONIC_L], // SPR_SUPZ // NiGHTS hurt - &lspr[SUPERSONIC_L], // SPR_NDRL // NiGHTS character drilling + &lspr[SUPERSONIC_L], // SPR_NDRN // NiGHTS drone &lspr[NOLIGHT], // SPR_NSPK &lspr[NOLIGHT], // SPR_NBMP &lspr[NOLIGHT], // SPR_HOOP &lspr[NOLIGHT], // SPR_HSCR &lspr[NOLIGHT], // SPR_NPRU &lspr[NOLIGHT], // SPR_CAPS - &lspr[SUPERSONIC_L], // SPR_SUPT + &lspr[INVINCIBLE_L], // SPR_IDYA + &lspr[NOLIGHT], // SPR_NTPN + &lspr[NOLIGHT], // SPR_SHLP + + // Secret badniks and hazards, shhhh + &lspr[NOLIGHT], // SPR_PENG + &lspr[NOLIGHT], // SPR_POPH, + &lspr[NOLIGHT], // SPR_HIVE + &lspr[NOLIGHT], // SPR_BUMB, + &lspr[NOLIGHT], // SPR_BBUZ + &lspr[NOLIGHT], // SPR_FMCE, + &lspr[NOLIGHT], // SPR_HMCE, + &lspr[NOLIGHT], // SPR_CACO, + &lspr[BLUEBALL_L], // SPR_BAL2, + &lspr[NOLIGHT], // SPR_SBOB, + &lspr[BLUEBALL_L], // SPR_SBFL, + &lspr[BLUEBALL_L], // SPR_SBSK, + &lspr[NOLIGHT], // SPR_BATT, // Debris &lspr[RINGSPARK_L], // SPR_SPRK @@ -454,6 +585,7 @@ light_t *t_lspr[NUMSPRITES] = &lspr[SUPERSPARK_L], // SPR_BOM2 &lspr[SUPERSPARK_L], // SPR_BOM3 &lspr[NOLIGHT], // SPR_BOM4 + &lspr[REDBALL_L], // SPR_BMNB // Crumbly rocks &lspr[NOLIGHT], // SPR_ROIA @@ -473,30 +605,15 @@ light_t *t_lspr[NUMSPRITES] = &lspr[NOLIGHT], // SPR_ROIO &lspr[NOLIGHT], // SPR_ROIP - // Blue Spheres - &lspr[NOLIGHT], // SPR_BBAL + // Level debris + &lspr[NOLIGHT], // SPR_GFZD + &lspr[NOLIGHT], // SPR_BRIC + &lspr[NOLIGHT], // SPR_WDDB // Gravity Well Objects &lspr[NOLIGHT], // SPR_GWLG &lspr[NOLIGHT], // SPR_GWLR - // SRB1 Sprites - &lspr[NOLIGHT], // SPR_SRBA - &lspr[NOLIGHT], // SPR_SRBB - &lspr[NOLIGHT], // SPR_SRBC - &lspr[NOLIGHT], // SPR_SRBD - &lspr[NOLIGHT], // SPR_SRBE - &lspr[NOLIGHT], // SPR_SRBF - &lspr[NOLIGHT], // SPR_SRBG - &lspr[NOLIGHT], // SPR_SRBH - &lspr[NOLIGHT], // SPR_SRBI - &lspr[NOLIGHT], // SPR_SRBJ - &lspr[NOLIGHT], // SPR_SRBK - &lspr[NOLIGHT], // SPR_SRBL - &lspr[NOLIGHT], // SPR_SRBM - &lspr[NOLIGHT], // SPR_SRBN - &lspr[NOLIGHT], // SPR_SRBO - // Free slots &lspr[NOLIGHT], &lspr[NOLIGHT], @@ -712,6 +829,14 @@ void HWR_WallLighting(FOutVector *wlVerts) FSurfaceInfo Surf; float dist_p2d, d[4], s; + if (!dynlights->mo[j]) + continue; + if (P_MobjWasRemoved(dynlights->mo[j])) + { + P_SetTarget(&dynlights->mo[j], NULL); + continue; + } + // check bounding box first if (SphereTouchBBox3D(&wlVerts[2], &wlVerts[0], &LIGHT_POS(j), DL_RADIUS(j))==false) continue; @@ -762,8 +887,6 @@ void HWR_WallLighting(FOutVector *wlVerts) #ifdef DL_HIGH_QUALITY Surf.FlatColor.s.alpha = (UINT8)((1-dist_p2d/DL_SQRRADIUS(j))*Surf.FlatColor.s.alpha); #endif - if (!dynlights->mo[j]->state) - return; // next state is null so fade out with alpha if (dynlights->mo[j]->state->nextstate == S_NULL) Surf.FlatColor.s.alpha = (UINT8)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha); @@ -794,6 +917,14 @@ void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts) FSurfaceInfo Surf; float dist_p2d, s; + if (!dynlights->mo[j]) + continue; + if (P_MobjWasRemoved(dynlights->mo[j])) + { + P_SetTarget(&dynlights->mo[j], NULL); + continue; + } + // BP: The kickass Optimization: check if light touch bounding box if (SphereTouchBBox3D(&p1, &p2, &dynlights->position[j], DL_RADIUS(j))==false) continue; @@ -825,8 +956,6 @@ void HWR_PlaneLighting(FOutVector *clVerts, int nrClipVerts) #ifdef DL_HIGH_QUALITY Surf.FlatColor.s.alpha = (unsigned char)((1 - dist_p2d/DL_SQRRADIUS(j))*Surf.FlatColor.s.alpha); #endif - if (!dynlights->mo[j]->state) - return; // next state is null so fade out with alpha if ((dynlights->mo[j]->state->nextstate == S_NULL)) Surf.FlatColor.s.alpha = (unsigned char)(((float)dynlights->mo[j]->tics/(float)dynlights->mo[j]->state->tics)*Surf.FlatColor.s.alpha); @@ -957,6 +1086,14 @@ void HWR_DrawCoronas(void) if (!(p_lspr->type & CORONA_SPR)) continue; + if (!dynlights->mo[j]) + continue; + if (P_MobjWasRemoved(dynlights->mo[j])) + { + P_SetTarget(&dynlights->mo[j], NULL); + continue; + } + transform(&cx,&cy,&cz); // more realistique corona ! @@ -1018,7 +1155,8 @@ void HWR_DrawCoronas(void) // -------------------------------------------------------------------------- void HWR_ResetLights(void) { - dynlights->nb = 0; + while (dynlights->nb) + P_SetTarget(&dynlights->mo[--dynlights->nb], NULL); } // -------------------------------------------------------------------------- @@ -1049,27 +1187,29 @@ void HWR_DL_AddLight(gr_vissprite_t *spr, GLPatch_t *patch) return; #endif + if (dynlights->nb >= DL_MAX_LIGHT) + return; + // check if sprite contain dynamic light p_lspr = t_lspr[spr->mobj->sprite]; - if ((p_lspr->type&DYNLIGHT_SPR) - && ((p_lspr->type != LIGHT_SPR) || cv_grstaticlighting.value) - && (dynlights->nb < DL_MAX_LIGHT) + if (!(p_lspr->type & DYNLIGHT_SPR)) + return; + if ((p_lspr->type != LIGHT_SPR) || cv_grstaticlighting.value) + return; - && spr->mobj->state) - { - LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(spr->mobj->x); - LIGHT_POS(dynlights->nb).y = FIXED_TO_FLOAT(spr->mobj->z)+FIXED_TO_FLOAT(spr->mobj->height>>1)+p_lspr->light_yoffset; - LIGHT_POS(dynlights->nb).z = FIXED_TO_FLOAT(spr->mobj->y); + LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(spr->mobj->x); + LIGHT_POS(dynlights->nb).y = FIXED_TO_FLOAT(spr->mobj->z)+FIXED_TO_FLOAT(spr->mobj->height>>1)+p_lspr->light_yoffset; + LIGHT_POS(dynlights->nb).z = FIXED_TO_FLOAT(spr->mobj->y); - P_SetTarget(&dynlights->mo[dynlights->nb], spr->mobj); + P_SetTarget(&dynlights->mo[dynlights->nb], spr->mobj); - dynlights->p_lspr[dynlights->nb] = p_lspr; + dynlights->p_lspr[dynlights->nb] = p_lspr; - dynlights->nb++; - } + dynlights->nb++; } -static GLPatch_t lightmappatch; +static GLMipmap_t lightmappatchmipmap; +static GLPatch_t lightmappatch = { .mipmap = &lightmappatchmipmap }; void HWR_InitLight(void) { @@ -1079,7 +1219,7 @@ void HWR_InitLight(void) for (i = 0;i < NUMLIGHTS;i++) lspr[i].dynamic_sqrradius = lspr[i].dynamic_radius*lspr[i].dynamic_radius; - lightmappatch.mipmap.downloaded = false; + lightmappatch.mipmap->downloaded = false; coronalumpnum = W_CheckNumForName("CORONA"); } @@ -1090,10 +1230,10 @@ static void HWR_SetLight(void) { int i, j; - if (!lightmappatch.mipmap.downloaded && !lightmappatch.mipmap.grInfo.data) + if (!lightmappatch.mipmap->downloaded && !lightmappatch.mipmap->grInfo.data) { - UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap.grInfo.data); + UINT16 *Data = Z_Malloc(129*128*sizeof (UINT16), PU_HWRCACHE, &lightmappatch.mipmap->grInfo.data); for (i = 0; i < 128; i++) { @@ -1106,21 +1246,23 @@ static void HWR_SetLight(void) Data[i*128+j] = 0; } } - lightmappatch.mipmap.grInfo.format = GR_TEXFMT_ALPHA_INTENSITY_88; + lightmappatch.mipmap->grInfo.format = GR_TEXFMT_ALPHA_INTENSITY_88; lightmappatch.width = 128; lightmappatch.height = 128; - lightmappatch.mipmap.width = 128; - lightmappatch.mipmap.height = 128; - lightmappatch.mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_128; - lightmappatch.mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_128; - lightmappatch.mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; - lightmappatch.mipmap.flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw ! + lightmappatch.mipmap->width = 128; + lightmappatch.mipmap->height = 128; +#ifdef GLIDE_API_COMPATIBILITY + lightmappatch.mipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_128; + lightmappatch.mipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_128; + lightmappatch.mipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; +#endif + lightmappatch.mipmap->flags = 0; //TF_WRAPXY; // DEBUG: view the overdraw ! } - HWD.pfnSetTexture(&lightmappatch.mipmap); + HWD.pfnSetTexture(lightmappatch.mipmap); // The system-memory data can be purged now. - Z_ChangeTag(lightmappatch.mipmap.grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(lightmappatch.mipmap->grInfo.data, PU_HWRCACHE_UNLOCKED); } //********************************************************** @@ -1220,6 +1362,14 @@ static void HWR_CheckSubsector(size_t num, fixed_t *bbox) // if (CircleTouchBBox(&p1, &p2, &LIGHT_POS(lightnum), DL_RADIUS(lightnum))==false) // continue; + if (!dynlights->mo[lightnum]) + continue; + if (P_MobjWasRemoved(dynlights->mo[lightnum])) + { + P_SetTarget(&dynlights->mo[lightnum], NULL); + continue; + } + count = sub->numlines; // how many linedefs line = &segs[sub->firstline]; // first line seg while (count--) @@ -1237,18 +1387,20 @@ static void HWR_CheckSubsector(size_t num, fixed_t *bbox) // -------------------------------------------------------------------------- static void HWR_AddMobjLights(mobj_t *thing) { - if (t_lspr[thing->sprite]->type & CORONA_SPR) - { - LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(thing->x); - LIGHT_POS(dynlights->nb).y = FIXED_TO_FLOAT(thing->z) + t_lspr[thing->sprite]->light_yoffset; - LIGHT_POS(dynlights->nb).z = FIXED_TO_FLOAT(thing->y); + if (dynlights->nb >= DL_MAX_LIGHT) + return; + if (!(t_lspr[thing->sprite]->type & CORONA_SPR)) + return; - dynlights->p_lspr[dynlights->nb] = t_lspr[thing->sprite]; + LIGHT_POS(dynlights->nb).x = FIXED_TO_FLOAT(thing->x); + LIGHT_POS(dynlights->nb).y = FIXED_TO_FLOAT(thing->z) + t_lspr[thing->sprite]->light_yoffset; + LIGHT_POS(dynlights->nb).z = FIXED_TO_FLOAT(thing->y); - dynlights->nb++; - if (dynlights->nb > DL_MAX_LIGHT) - dynlights->nb = DL_MAX_LIGHT; - } + P_SetTarget(&dynlights->mo[dynlights->nb], thing); + + dynlights->p_lspr[dynlights->nb] = t_lspr[thing->sprite]; + + dynlights->nb++; } //Hurdler: The goal of this function is to walk through all the bsp starting @@ -1274,12 +1426,9 @@ static void HWR_SearchLightsInMobjs(void) //mobj_t * mobj; // search in the list of thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - // a mobj ? - if (th->function.acp1 == (actionf_p1)P_MobjThinker) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) HWR_AddMobjLights((mobj_t *)th); - } } #endif @@ -1291,7 +1440,7 @@ void HWR_CreateStaticLightmaps(int bspnum) #ifdef STATICLIGHT CONS_Debug(DBG_RENDER, "HWR_CreateStaticLightmaps\n"); - dynlights->nb = 0; + HWR_ResetLights(); // First: Searching for lights // BP: if i was you, I will make it in create mobj since mobj can be create @@ -1302,8 +1451,6 @@ void HWR_CreateStaticLightmaps(int bspnum) // Second: Build all lightmap for walls covered by lights validcount++; // to be sure HWR_ComputeLightMapsInBSPNode(bspnum, NULL); - - dynlights->nb = 0; #else (void)bspnum; #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index efecac524..efed9b602 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -30,6 +30,7 @@ #include "../p_local.h" #include "../p_setup.h" #include "../r_local.h" +#include "../r_patch.h" #include "../r_bsp.h" #include "../d_clisrv.h" #include "../w_wad.h" @@ -39,6 +40,8 @@ #include "../st_stuff.h" #include "../i_system.h" #include "../m_cheat.h" +#include "../f_finale.h" +#include "../r_things.h" // R_GetShadowZ #ifdef ESLOPE #include "../p_slopes.h" #endif @@ -70,12 +73,12 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing); #endif #ifdef SORTING -void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, +void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); -void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, +void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); #else -static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, fixed_t fixedheight, +static void HWR_Add3DWater(levelflat_t *levelflat, extrasubsector_t *xsub, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector); static void HWR_Render3DWater(void); static void HWR_RenderTransparentWalls(void); @@ -83,63 +86,8 @@ static void HWR_RenderTransparentWalls(void); static void HWR_FoggingOn(void); static UINT32 atohex(const char *s); -static void CV_filtermode_ONChange(void); -static void CV_anisotropic_ONChange(void); -static void CV_FogDensity_ONChange(void); -static void CV_grFov_OnChange(void); -// ========================================================================== -// 3D ENGINE COMMANDS & CONSOLE VARS -// ========================================================================== - -static CV_PossibleValue_t grfov_cons_t[] = {{0, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, - {HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"}, - {HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"}, - {HWD_SET_TEXTUREFILTER_MIXED2, "Nearest_Linear"}, - {HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"}, - {0, NULL}}; -CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; - boolean drawsky = true; -// needs fix: walls are incorrectly clipped one column less -#ifndef NEWCLIP -static consvar_t cv_grclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif -//development variables for diverse uses -static consvar_t cv_gralpha = {"gr_alpha", "160", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_grbeta = {"gr_beta", "0", 0, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static float HWRWipeCounter = 1.0f; -consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfov = {"gr_fov", "90", CV_FLOAT|CV_CALL, grfov_cons_t, CV_grFov_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfogdensity = {"gr_fogdensity", "150", CV_CALL|CV_NOINIT, CV_Unsigned, - CV_FogDensity_ONChange, 0, NULL, NULL, 0, 0, NULL}; - -// Unfortunately, this can no longer be saved.. -consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_CALL, grfiltermode_cons_t, - CV_filtermode_ONChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, - CV_anisotropic_ONChange, 0, NULL, NULL, 0, 0, NULL}; -//static consvar_t cv_grzbuffer = {"gr_zbuffer", "On", 0, CV_OnOff}; -consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -static void CV_FogDensity_ONChange(void) -{ - HWD.pfnSetSpecialState(HWD_SET_FOG_DENSITY, cv_grfogdensity.value); -} - -static void CV_filtermode_ONChange(void) -{ - HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value); -} - -static void CV_anisotropic_ONChange(void) -{ - HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value); -} - /* * lookuptable for lightvalues * calculated as follow: @@ -522,7 +470,7 @@ static UINT8 HWR_FogBlockAlpha(INT32 light, UINT32 color) // Let's see if this c // HWR_RenderPlane : Render a floor or ceiling convex polygon // -----------------+ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, - FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap) + FBITFIELD PolyFlags, INT32 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, boolean fogplane, extracolormap_t *planecolormap) { polyvertex_t * pv; float height; //constant y for all points on the convex flat polygon @@ -530,8 +478,9 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is INT32 nrPlaneVerts; //verts original define of convex flat polygon INT32 i; float flatxref,flatyref; - float fflatsize; - INT32 flatflag; + float fflatwidth = 64.0f, fflatheight = 64.0f; + INT32 flatflag = 63; + boolean texflat = false; size_t len; float scrollx = 0.0f, scrolly = 0.0f; angle_t angle = 0; @@ -580,9 +529,10 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is if (nrPlaneVerts < 3) //not even a triangle ? return; - if (nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size + // This check is so inconsistent between functions, it hurts. + if (nrPlaneVerts > INT16_MAX) // FIXME: exceeds plVerts size { - CONS_Debug(DBG_RENDER, "polygon size of %d exceeds max value of %d vertices\n", nrPlaneVerts, UINT16_MAX); + CONS_Debug(DBG_RENDER, "polygon size of %d exceeds max value of %d vertices\n", nrPlaneVerts, INT16_MAX); return; } @@ -594,43 +544,53 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); } - len = W_LumpLength(lumpnum); - - switch (len) + // set texture for polygon + if (levelflat != NULL) { - case 4194304: // 2048x2048 lump - fflatsize = 2048.0f; - flatflag = 2047; - break; - case 1048576: // 1024x1024 lump - fflatsize = 1024.0f; - flatflag = 1023; - break; - case 262144:// 512x512 lump - fflatsize = 512.0f; - flatflag = 511; - break; - case 65536: // 256x256 lump - fflatsize = 256.0f; - flatflag = 255; - break; - case 16384: // 128x128 lump - fflatsize = 128.0f; - flatflag = 127; - break; - case 1024: // 32x32 lump - fflatsize = 32.0f; - flatflag = 31; - break; - default: // 64x64 lump - fflatsize = 64.0f; - flatflag = 63; - break; + if (levelflat->type == LEVELFLAT_TEXTURE) + { + fflatwidth = textures[levelflat->u.texture.num]->width; + fflatheight = textures[levelflat->u.texture.num]->height; + texflat = true; + } + else if (levelflat->type == LEVELFLAT_FLAT) + { + len = W_LumpLength(levelflat->u.flat.lumpnum); + + switch (len) + { + case 4194304: // 2048x2048 lump + fflatwidth = fflatheight = 2048.0f; + break; + case 1048576: // 1024x1024 lump + fflatwidth = fflatheight = 1024.0f; + break; + case 262144:// 512x512 lump + fflatwidth = fflatheight = 512.0f; + break; + case 65536: // 256x256 lump + fflatwidth = fflatheight = 256.0f; + break; + case 16384: // 128x128 lump + fflatwidth = fflatheight = 128.0f; + break; + case 1024: // 32x32 lump + fflatwidth = fflatheight = 32.0f; + break; + default: // 64x64 lump + fflatwidth = fflatheight = 64.0f; + break; + } + + flatflag = ((INT32)fflatwidth)-1; + } } + else // set no texture + HWD.pfnSetTexture(NULL); // reference point for flat texture coord for each vertex around the polygon - flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatsize); - flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatsize); + flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatwidth); + flatyref = (float)(((fixed_t)pv->y & (~flatflag)) / fflatheight); // transform v3d = planeVerts; @@ -639,42 +599,36 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; - angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT; + scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatheight; + angle = FOFsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; - angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; + scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatheight; + angle = FOFsector->ceilingpic_angle; } } else if (gr_frontsector) { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize; - angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT; + scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatheight; + angle = gr_frontsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatsize; - angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; + scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatheight; + angle = gr_frontsector->ceilingpic_angle; } } if (angle) // Only needs to be done if there's an altered angle { - - // This needs to be done so that it scrolls in a different direction after rotation like software - tempxsow = FLOAT_TO_FIXED(scrollx); - tempytow = FLOAT_TO_FIXED(scrolly); - scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); - + angle = InvAngle(angle)>>ANGLETOFINESHIFT; // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does tempxsow = FLOAT_TO_FIXED(flatxref); @@ -686,19 +640,26 @@ static void HWR_RenderPlane(sector_t *sector, extrasubsector_t *xsub, boolean is for (i = 0; i < nrPlaneVerts; i++,v3d++,pv++) { // Hurdler: add scrolling texture on floor/ceiling - v3d->sow = (float)((pv->x / fflatsize) - flatxref + scrollx); - v3d->tow = (float)(flatyref - (pv->y / fflatsize) + scrolly); - - //v3d->sow = (float)(pv->x / fflatsize); - //v3d->tow = (float)(pv->y / fflatsize); + if (texflat) + { + v3d->sow = (float)(pv->x / fflatwidth) + scrollx; + v3d->tow = -(float)(pv->y / fflatheight) + scrolly; + } + else + { + v3d->sow = (float)((pv->x / fflatwidth) - flatxref + scrollx); + v3d->tow = (float)(flatyref - (pv->y / fflatheight) + scrolly); + } // Need to rotate before translate if (angle) // Only needs to be done if there's an altered angle { tempxsow = FLOAT_TO_FIXED(v3d->sow); tempytow = FLOAT_TO_FIXED(v3d->tow); + if (texflat) + tempytow = -tempytow; v3d->sow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - v3d->tow = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle)))); + v3d->tow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } //v3d->sow = (float)(v3d->sow - flatxref + scrollx); @@ -872,7 +833,7 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) if (!M_PointInBox(segbbox,splat->v1.x,splat->v1.y) && !M_PointInBox(segbbox,splat->v2.x,splat->v2.y)) continue; - gpatch = W_CachePatchNum(splat->patch, PU_CACHE); + gpatch = W_CachePatchNum(splat->patch, PU_PATCH); HWR_GetPatch(gpatch); wallVerts[0].x = wallVerts[3].x = FIXED_TO_FLOAT(splat->v1.x); @@ -1066,6 +1027,34 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) } #endif +static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y) +{ + INT16 finallight = lightnum; + + if (cv_grfakecontrast.value != 0) + { + const UINT8 contrast = 8; + fixed_t extralight = 0; + + if (v1y == v2y) + extralight = -contrast; + else if (v1x == v2x) + extralight = contrast; + + if (extralight != 0) + { + finallight += extralight; + + if (finallight < 0) + finallight = 0; + if (finallight > 255) + finallight = 255; + } + } + + return (FUINT)finallight; +} + // // HWR_SplitWall // @@ -1084,19 +1073,20 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; - fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); - fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo - fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); - fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly // use this as a temp var to store P_GetZAt's return value each time fixed_t temp; #endif - INT32 solid, i; + fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); + fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo + fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); + fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo + + INT32 solid, i; lightlist_t * list = sector->lightlist; const UINT8 alpha = Surf->FlatColor.s.alpha; - FUINT lightnum = sector->lightlevel; + FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; @@ -1126,13 +1116,13 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, { if (pfloor && (pfloor->flags & FF_FOG)) { - lightnum = pfloor->master->frontsector->lightlevel; + lightnum = HWR_CalcWallLight(pfloor->master->frontsector->lightlevel, v1x, v1y, v2x, v2y); colormap = pfloor->master->frontsector->extra_colormap; } else { - lightnum = *list[i].lightlevel; - colormap = list[i].extra_colormap; + lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y); + colormap = *list[i].extra_colormap; } } @@ -1314,9 +1304,9 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, HWR_ProjectWall(wallVerts, Surf, PF_Masked, lightnum, colormap); } -// HWR_DrawSkyWalls +// HWR_DrawSkyWall // Draw walls into the depth buffer so that anything behind is culled properly -static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf, fixed_t bottom, fixed_t top) +static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf) { HWD.pfnSetTexture(NULL); // no texture @@ -1324,9 +1314,7 @@ static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf, fixed_t b wallVerts[0].t = wallVerts[1].t = 0; wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - // set top/bottom coords - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(top); // No real way to find the correct height of this - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(bottom); // worldlow/bottom because it needs to cover up the lower thok barrier wall + // this no longer sets top/bottom coords, this should be done before caling the function HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_Clip|PF_NoTexture, 255, NULL); // PF_Invisible so it's not drawn into the colour buffer // PF_NoTexture for no texture @@ -1437,7 +1425,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); } - lightnum = gr_frontsector->lightlevel; + lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = gr_frontsector->extra_colormap; if (gr_frontsector) @@ -1447,8 +1435,10 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) if (gr_backsector) { - INT32 gr_toptexture, gr_bottomtexture; + INT32 gr_toptexture = 0, gr_bottomtexture = 0; // two sided line + boolean bothceilingssky = false; // turned on if both back and front ceilings are sky + boolean bothfloorssky = false; // likewise, but for floors #ifdef ESLOPE SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) @@ -1461,17 +1451,23 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) // hack to allow height changes in outdoor areas // This is what gets rid of the upper textures if there should be sky - if (gr_frontsector->ceilingpic == skyflatnum && - gr_backsector->ceilingpic == skyflatnum) + if (gr_frontsector->ceilingpic == skyflatnum + && gr_backsector->ceilingpic == skyflatnum) { - worldtop = worldhigh; -#ifdef ESLOPE - worldtopslope = worldhighslope; -#endif + bothceilingssky = true; } - gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture); - gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture); + // likewise, but for floors and upper textures + if (gr_frontsector->floorpic == skyflatnum + && gr_backsector->floorpic == skyflatnum) + { + bothfloorssky = true; + } + + if (!bothceilingssky) + gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture); + if (!bothfloorssky) + gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture); // check TOP TEXTURE if (( @@ -1912,90 +1908,48 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) }*/ } - // Isn't this just the most lovely mess +#if 1 + // Sky culling + // No longer so much a mess as before! if (!gr_curline->polyseg) // Don't do it for polyobjects { - if (gr_frontsector->ceilingpic == skyflatnum || gr_backsector->ceilingpic == skyflatnum) + if (gr_frontsector->ceilingpic == skyflatnum) { - fixed_t depthwallheight; - - if (!gr_sidedef->toptexture || (gr_frontsector->ceilingpic == skyflatnum && gr_backsector->ceilingpic == skyflatnum)) // when both sectors are sky, the top texture isn't drawn - depthwallheight = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight; - else - depthwallheight = gr_frontsector->ceilingheight > gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight; - - if (gr_frontsector->ceilingheight-gr_frontsector->floorheight <= 0) // current sector is a thok barrier + if (gr_backsector->ceilingpic != skyflatnum) // don't cull if back sector is also sky { - if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is also a thok barrier - { - if (!gr_sidedef->bottomtexture) // Only extend further down if there's no texture - HWR_DrawSkyWall(wallVerts, &Surf, worldbottom < worldlow ? worldbottom : worldlow, INT32_MAX); - else - HWR_DrawSkyWall(wallVerts, &Surf, worldbottom > worldlow ? worldbottom : worldlow, INT32_MAX); - } - // behind sector is not a thok barrier - else if (gr_backsector->ceilingheight <= gr_frontsector->ceilingheight) // behind sector ceiling is lower or equal to current sector - HWR_DrawSkyWall(wallVerts, &Surf, depthwallheight, INT32_MAX); - // gr_front/backsector heights need to be used here because of the worldtop being set to worldhigh earlier on - } - else if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is a thok barrier, current sector is not - { - if (gr_backsector->ceilingheight >= gr_frontsector->ceilingheight // thok barrier ceiling height is equal to or greater than current sector ceiling height - || gr_backsector->floorheight <= gr_frontsector->floorheight // thok barrier ceiling height is equal to or less than current sector floor height - || gr_backsector->ceilingpic != skyflatnum) // thok barrier is not a sky - HWR_DrawSkyWall(wallVerts, &Surf, depthwallheight, INT32_MAX); - } - else // neither sectors are thok barriers - { - if ((gr_backsector->ceilingheight < gr_frontsector->ceilingheight && !gr_sidedef->toptexture) // no top texture and sector behind is lower - || gr_backsector->ceilingpic != skyflatnum) // behind sector is not a sky - HWR_DrawSkyWall(wallVerts, &Surf, depthwallheight, INT32_MAX); + wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space +#ifdef ESLOPE + wallVerts[0].y = FIXED_TO_FLOAT(worldtop); + wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); +#else + wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); +#endif + HWR_DrawSkyWall(wallVerts, &Surf); } } - // And now for sky floors! - if (gr_frontsector->floorpic == skyflatnum || gr_backsector->floorpic == skyflatnum) + + if (gr_frontsector->floorpic == skyflatnum) { - fixed_t depthwallheight; - - if (!gr_sidedef->bottomtexture) - depthwallheight = worldbottom > worldlow ? worldbottom : worldlow; - else - depthwallheight = worldbottom < worldlow ? worldbottom : worldlow; - - if (gr_frontsector->ceilingheight-gr_frontsector->floorheight <= 0) // current sector is a thok barrier + if (gr_backsector->floorpic != skyflatnum) // don't cull if back sector is also sky { - if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is also a thok barrier - { - if (!gr_sidedef->toptexture) // Only extend up if there's no texture - HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, worldtop > worldhigh ? worldtop : worldhigh); - else - HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, worldtop < worldhigh ? worldtop : worldhigh); - } - // behind sector is not a thok barrier - else if (gr_backsector->floorheight >= gr_frontsector->floorheight) // behind sector floor is greater or equal to current sector - HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, depthwallheight); - } - else if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is a thok barrier, current sector is not - { - if (gr_backsector->floorheight <= gr_frontsector->floorheight // thok barrier floor height is equal to or less than current sector floor height - || gr_backsector->ceilingheight >= gr_frontsector->ceilingheight // thok barrier floor height is equal to or greater than current sector ceiling height - || gr_backsector->floorpic != skyflatnum) // thok barrier is not a sky - HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, depthwallheight); - } - else // neither sectors are thok barriers - { - if ((gr_backsector->floorheight > gr_frontsector->floorheight && !gr_sidedef->bottomtexture) // no bottom texture and sector behind is higher - || gr_backsector->floorpic != skyflatnum) // behind sector is not a sky - HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, depthwallheight); +#ifdef ESLOPE + wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); + wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); +#else + wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); +#endif + wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space + HWR_DrawSkyWall(wallVerts, &Surf); } } } +#endif } else { // Single sided line... Deal only with the middletexture (if one exists) gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); - if (gr_midtexture) + if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { { fixed_t texturevpeg; @@ -2060,9 +2014,27 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) if (!gr_curline->polyseg) { if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector - HWR_DrawSkyWall(wallVerts, &Surf, worldtop, INT32_MAX); + { + wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space +#ifdef ESLOPE + wallVerts[0].y = FIXED_TO_FLOAT(worldtop); + wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); +#else + wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop); +#endif + HWR_DrawSkyWall(wallVerts, &Surf); + } if (gr_frontsector->floorpic == skyflatnum) - HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, worldbottom); + { +#ifdef ESLOPE + wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); + wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); +#else + wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); +#endif + wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space + HWR_DrawSkyWall(wallVerts, &Surf); + } } } @@ -2208,7 +2180,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) blendmode = PF_Fog|PF_NoTexture; - lightnum = rover->master->frontsector->lightlevel; + lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = rover->master->frontsector->extra_colormap; if (rover->master->frontsector->extra_colormap) @@ -2328,7 +2300,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) blendmode = PF_Fog|PF_NoTexture; - lightnum = rover->master->frontsector->lightlevel; + lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = rover->master->frontsector->extra_colormap; if (rover->master->frontsector->extra_colormap) @@ -2384,6 +2356,12 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks { fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends + boolean bothceilingssky = false, bothfloorssky = false; + + if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) + bothceilingssky = true; + if (abacksector->floorpic == skyflatnum && afrontsector->floorpic == skyflatnum) + bothfloorssky = true; // GZDoom method of sloped line clipping @@ -2416,62 +2394,45 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks backf1 = backf2 = abacksector->floorheight; backc1 = backc2 = abacksector->ceilingheight; } - - // now check for closed sectors! - if (backc1 <= frontf1 && backc2 <= frontf2) + // properly render skies (consider door "open" if both ceilings are sky) + // same for floors + if (!bothceilingssky && !bothfloorssky) { - checkforemptylines = false; - if (!seg->sidedef->toptexture) - return false; - - if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) - return false; - - return true; - } - - if (backf1 >= frontc1 && backf2 >= frontc2) - { - checkforemptylines = false; - if (!seg->sidedef->bottomtexture) - return false; - - // properly render skies (consider door "open" if both floors are sky): - if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) - return false; - - return true; - } - - if (backc1 <= backf1 && backc2 <= backf2) - { - checkforemptylines = false; - // preserve a kind of transparent door/lift special effect: - if (backc1 < frontc1 || backc2 < frontc2) + // now check for closed sectors! + if ((backc1 <= frontf1 && backc2 <= frontf2) + || (backf1 >= frontc1 && backf2 >= frontc2)) { - if (!seg->sidedef->toptexture) - return false; + checkforemptylines = false; + return true; } - if (backf1 > frontf1 || backf2 > frontf2) + + if (backc1 <= backf1 && backc2 <= backf2) { - if (!seg->sidedef->bottomtexture) - return false; + // preserve a kind of transparent door/lift special effect: + if (((backc1 >= frontc1 && backc2 >= frontc2) || seg->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 <= frontf2) || seg->sidedef->bottomtexture)) + { + checkforemptylines = false; + return true; + } } - if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum) - return false; - - if (abacksector->floorpic == skyflatnum && afrontsector->floorpic == skyflatnum) - return false; - - return true; } - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) + if (!bothceilingssky) { + if (backc1 != frontc1 || backc2 != frontc2) { checkforemptylines = false; return false; } + } + + if (!bothfloorssky) { + if (backf1 != frontf1 || backf2 != frontf2) + { + checkforemptylines = false; + return false; + } + } return false; } @@ -2488,11 +2449,13 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks static cliprange_t * hw_newend; static cliprange_t gr_solidsegs[MAXSEGS]; +// needs fix: walls are incorrectly clipped one column less +static consvar_t cv_grclipwalls = {"gr_clipwalls", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void printsolidsegs(void) { cliprange_t * start; - if (!hw_newend || cv_grbeta.value != 2) + if (!hw_newend) return; for (start = gr_solidsegs;start != hw_newend;start++) { @@ -2774,6 +2737,7 @@ static void HWR_AddLine(seg_t * line) #ifndef NEWCLIP INT32 x1, x2; angle_t span, tspan; + boolean bothceilingssky = false, bothfloorssky = false; #endif // SoM: Backsector needs to be run through R_FakeFlat @@ -2899,7 +2863,30 @@ static void HWR_AddLine(seg_t * line) } else { + boolean bothceilingssky = false, bothfloorssky = false; + gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + + if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) + bothceilingssky = true; + if (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) + bothfloorssky = true; + + if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then + { + if ( +#ifdef POLYOBJECTS + !line->polyseg && +#endif + !line->sidedef->midtexture + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || (gr_frontsector->tag == gr_backsector->tag))) + return; // line is empty, don't even bother + // treat like wide open window instead + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; + } + if (CheckClip(line, gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); @@ -2922,6 +2909,25 @@ static void HWR_AddLine(seg_t * line) gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + if (gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) + bothceilingssky = true; + if (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum) + bothfloorssky = true; + + if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then + { + if ( +#ifdef POLYOBJECTS + !line->polyseg && +#endif + !line->sidedef->midtexture + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || (gr_frontsector->tag == gr_backsector->tag))) + return; // line is empty, don't even bother + + goto clippass; // treat like wide open window instead + } + #ifdef ESLOPE if (gr_frontsector->f_slope || gr_frontsector->c_slope || gr_backsector->f_slope || gr_backsector->c_slope) { @@ -2940,47 +2946,58 @@ static void HWR_AddLine(seg_t * line) SLOPEPARAMS( gr_backsector->f_slope, backf1, backf2, gr_backsector->floorheight) SLOPEPARAMS( gr_backsector->c_slope, backc1, backc2, gr_backsector->ceilingheight) #undef SLOPEPARAMS - - // Closed door. - if ((backc1 <= frontf1 && backc2 <= frontf2) - || (backf1 >= frontc1 && backf2 >= frontc2)) + // if both ceilings are skies, consider it always "open" + // same for floors + if (!bothceilingssky && !bothfloorssky) { - goto clipsolid; - } + // Closed door. + if ((backc1 <= frontf1 && backc2 <= frontf2) + || (backf1 >= frontc1 && backf2 >= frontc2)) + { + goto clipsolid; + } - // Check for automap fix. - if (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture) - && (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)) - goto clipsolid; + // Check for automap fix. + if (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture)) + goto clipsolid; + } // Window. - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) - { - goto clippass; - } + if (!bothceilingssky) // ceilings are always the "same" when sky + if (backc1 != frontc1 || backc2 != frontc2) + goto clippass; + if (!bothfloorssky) // floors are always the "same" when sky + if (backf1 != frontf1 || backf2 != frontf2) + goto clippass; } else #endif { - // Closed door. - if (gr_backsector->ceilingheight <= gr_frontsector->floorheight || - gr_backsector->floorheight >= gr_frontsector->ceilingheight) - goto clipsolid; + // if both ceilings are skies, consider it always "open" + // same for floors + if (!bothceilingssky && !bothfloorssky) + { + // Closed door. + if (gr_backsector->ceilingheight <= gr_frontsector->floorheight || + gr_backsector->floorheight >= gr_frontsector->ceilingheight) + goto clipsolid; - // Check for automap fix. - if (gr_backsector->ceilingheight <= gr_backsector->floorheight - && ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture) - && ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture) - && (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)) - goto clipsolid; + // Check for automap fix. + if (gr_backsector->ceilingheight <= gr_backsector->floorheight + && ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture) + && ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture)) + goto clipsolid; + } // Window. - if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight || - gr_backsector->floorheight != gr_frontsector->floorheight) - goto clippass; + if (!bothceilingssky) // ceilings are always the "same" when sky + if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight) + goto clippass; + if (!bothfloorssky) // floors are always the "same" when sky + if (gr_backsector->floorheight != gr_frontsector->floorheight) + goto clippass; } // Reject empty lines used for triggers and special events. @@ -3145,15 +3162,16 @@ static inline void HWR_AddPolyObjectSegs(void) #ifdef POLYOBJECTS_PLANES static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, - FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, + FBITFIELD blendmode, UINT8 lightlevel, levelflat_t *levelflat, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap) { float height; //constant y for all points on the convex flat polygon FOutVector *v3d; INT32 i; float flatxref,flatyref; - float fflatsize; - INT32 flatflag; + float fflatwidth = 64.0f, fflatheight = 64.0f; + INT32 flatflag = 63; + boolean texflat = false; size_t len; float scrollx = 0.0f, scrolly = 0.0f; angle_t angle = 0; @@ -3171,7 +3189,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, if (nrPlaneVerts < 3) //not even a triangle ? return; - if (nrPlaneVerts > UINT16_MAX) // FIXME: exceeds plVerts size + if (nrPlaneVerts > (size_t)UINT16_MAX) // FIXME: exceeds plVerts size { CONS_Debug(DBG_RENDER, "polygon size of %s exceeds max value of %d vertices\n", sizeu1(nrPlaneVerts), UINT16_MAX); return; @@ -3185,43 +3203,53 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); } - len = W_LumpLength(lumpnum); - - switch (len) + // set texture for polygon + if (levelflat != NULL) { - case 4194304: // 2048x2048 lump - fflatsize = 2048.0f; - flatflag = 2047; - break; - case 1048576: // 1024x1024 lump - fflatsize = 1024.0f; - flatflag = 1023; - break; - case 262144:// 512x512 lump - fflatsize = 512.0f; - flatflag = 511; - break; - case 65536: // 256x256 lump - fflatsize = 256.0f; - flatflag = 255; - break; - case 16384: // 128x128 lump - fflatsize = 128.0f; - flatflag = 127; - break; - case 1024: // 32x32 lump - fflatsize = 32.0f; - flatflag = 31; - break; - default: // 64x64 lump - fflatsize = 64.0f; - flatflag = 63; - break; + if (levelflat->type == LEVELFLAT_TEXTURE) + { + fflatwidth = textures[levelflat->u.texture.num]->width; + fflatheight = textures[levelflat->u.texture.num]->height; + texflat = true; + } + else if (levelflat->type == LEVELFLAT_FLAT) + { + len = W_LumpLength(levelflat->u.flat.lumpnum); + + switch (len) + { + case 4194304: // 2048x2048 lump + fflatwidth = fflatheight = 2048.0f; + break; + case 1048576: // 1024x1024 lump + fflatwidth = fflatheight = 1024.0f; + break; + case 262144:// 512x512 lump + fflatwidth = fflatheight = 512.0f; + break; + case 65536: // 256x256 lump + fflatwidth = fflatheight = 256.0f; + break; + case 16384: // 128x128 lump + fflatwidth = fflatheight = 128.0f; + break; + case 1024: // 32x32 lump + fflatwidth = fflatheight = 32.0f; + break; + default: // 64x64 lump + fflatwidth = fflatheight = 64.0f; + break; + } + + flatflag = ((INT32)fflatwidth)-1; + } } + else // set no texture + HWD.pfnSetTexture(NULL); // reference point for flat texture coord for each vertex around the polygon - flatxref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].x) & (~flatflag)) / fflatsize); - flatyref = (float)(((fixed_t)FIXED_TO_FLOAT(polysector->origVerts[0].y) & (~flatflag)) / fflatsize); + flatxref = (float)((polysector->origVerts[0].x & (~flatflag)) / fflatwidth); + flatyref = (float)((polysector->origVerts[0].y & (~flatflag)) / fflatheight); // transform v3d = planeVerts; @@ -3230,14 +3258,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; + scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatheight; angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; + scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatheight; angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -3245,14 +3273,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatsize; + scrollx = FIXED_TO_FLOAT(gr_frontsector->floor_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gr_frontsector->floor_yoffs)/fflatheight; angle = gr_frontsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatsize; + scrollx = FIXED_TO_FLOAT(gr_frontsector->ceiling_xoffs)/fflatwidth; + scrolly = FIXED_TO_FLOAT(gr_frontsector->ceiling_yoffs)/fflatheight; angle = gr_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -3275,15 +3303,26 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++) { - // Hurdler: add scrolling texture on floor/ceiling - v3d->sow = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations - v3d->tow = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations + // Go from the polysector's original vertex locations + // Means the flat is offset based on the original vertex locations + if (texflat) + { + v3d->sow = (float)(FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) + scrollx; + v3d->tow = -(float)(FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly; + } + else + { + v3d->sow = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatwidth) - flatxref + scrollx); + v3d->tow = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatheight) + scrolly); + } // Need to rotate before translate if (angle) // Only needs to be done if there's an altered angle { tempxsow = FLOAT_TO_FIXED(v3d->sow); tempytow = FLOAT_TO_FIXED(v3d->tow); + if (texflat) + tempytow = -tempytow; v3d->sow = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); v3d->tow = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle)))); } @@ -3314,6 +3353,7 @@ static void HWR_AddPolyObjectPlanes(void) { size_t i; sector_t *polyobjsector; + INT32 light = 0; // Polyobject Planes need their own function for drawing because they don't have extrasubsectors by themselves // It should be okay because polyobjects should always be convex anyway @@ -3332,19 +3372,22 @@ static void HWR_AddPolyObjectPlanes(void) && polyobjsector->floorheight >= gr_frontsector->floorheight && (viewz < polyobjsector->floorheight)) { + light = R_GetPlaneLight(gr_frontsector, polyobjsector->floorheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; - FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); - HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, - polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL); + FBITFIELD blendmode; + memset(&Surf, 0x00, sizeof(Surf)); + blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); + HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->floorpic], po_ptrs[i], false, polyobjsector->floorheight, + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.FlatColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); } else { - HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum); + HWR_GetLevelFlat(&levelflats[polyobjsector->floorpic]); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, - polyobjsector, 255, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->floorpic], + polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); } } @@ -3352,21 +3395,22 @@ static void HWR_AddPolyObjectPlanes(void) && polyobjsector->ceilingheight <= gr_frontsector->ceilingheight && (viewz > polyobjsector->ceilingheight)) { + light = R_GetPlaneLight(gr_frontsector, polyobjsector->ceilingheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; FBITFIELD blendmode; memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); - HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, - polyobjsector->lightlevel, Surf.FlatColor.s.alpha, polyobjsector, blendmode, NULL); + HWR_AddTransparentPolyobjectFloor(&levelflats[polyobjsector->ceilingpic], po_ptrs[i], true, polyobjsector->ceilingheight, + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.FlatColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); } else { - HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum); + HWR_GetLevelFlat(&levelflats[polyobjsector->ceilingpic]); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, - polyobjsector, 255, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), &levelflats[polyobjsector->ceilingpic], + polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : *gr_frontsector->lightlist[light].extra_colormap)); } } } @@ -3497,12 +3541,12 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gr_frontsector, locFloorHeight, false); if (gr_frontsector->floorlightsec == -1) floorlightlevel = *gr_frontsector->lightlist[light].lightlevel; - floorcolormap = gr_frontsector->lightlist[light].extra_colormap; + floorcolormap = *gr_frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(gr_frontsector, locCeilingHeight, false); if (gr_frontsector->ceilinglightsec == -1) ceilinglightlevel = *gr_frontsector->lightlist[light].lightlevel; - ceilingcolormap = gr_frontsector->lightlist[light].extra_colormap; + ceilingcolormap = *gr_frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = gr_frontsector->extra_colormap; @@ -3516,12 +3560,12 @@ static void HWR_Subsector(size_t num) { if (sub->validcount != validcount) { - HWR_GetFlat(levelflats[gr_frontsector->floorpic].lumpnum); + HWR_GetLevelFlat(&levelflats[gr_frontsector->floorpic]); HWR_RenderPlane(gr_frontsector, &extrasubsectors[num], false, // Hack to make things continue to work around slopes. locFloorHeight == cullFloorHeight ? locFloorHeight : gr_frontsector->floorheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, floorlightlevel, levelflats[gr_frontsector->floorpic].lumpnum, NULL, 255, false, floorcolormap); + PF_Occlude, floorlightlevel, &levelflats[gr_frontsector->floorpic], NULL, 255, false, floorcolormap); } } else @@ -3538,12 +3582,12 @@ static void HWR_Subsector(size_t num) { if (sub->validcount != validcount) { - HWR_GetFlat(levelflats[gr_frontsector->ceilingpic].lumpnum); + HWR_GetLevelFlat(&levelflats[gr_frontsector->ceilingpic]); HWR_RenderPlane(NULL, &extrasubsectors[num], true, // Hack to make things continue to work around slopes. locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gr_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, ceilinglightlevel, levelflats[gr_frontsector->ceilingpic].lumpnum,NULL, 255, false, ceilingcolormap); + PF_Occlude, ceilinglightlevel, &levelflats[gr_frontsector->ceilingpic], NULL, 255, false, ceilingcolormap); } } else @@ -3602,7 +3646,7 @@ static void HWR_Subsector(size_t num) else alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG); - HWR_AddTransparentFloor(0, + HWR_AddTransparentFloor(NULL, &extrasubsectors[num], false, *rover->bottomheight, @@ -3614,27 +3658,27 @@ static void HWR_Subsector(size_t num) { light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); #ifndef SORTING - HWR_Add3DWater(levelflats[*rover->bottompic].lumpnum, + HWR_Add3DWater(&levelflats[*rover->bottompic], &extrasubsectors[num], *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1, rover->master->frontsector); #else - HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, + HWR_AddTransparentFloor(&levelflats[*rover->bottompic], &extrasubsectors[num], false, *rover->bottomheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + false, *gr_frontsector->lightlist[light].extra_colormap); #endif } else { - HWR_GetFlat(levelflats[*rover->bottompic].lumpnum); + HWR_GetLevelFlat(&levelflats[*rover->bottompic]); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); + HWR_RenderPlane(NULL, &extrasubsectors[num], false, *rover->bottomheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, &levelflats[*rover->bottompic], + rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); } } @@ -3665,7 +3709,7 @@ static void HWR_Subsector(size_t num) else alpha = HWR_FogBlockAlpha(*gr_frontsector->lightlist[light].lightlevel, NORMALFOG); - HWR_AddTransparentFloor(0, + HWR_AddTransparentFloor(NULL, &extrasubsectors[num], true, *rover->topheight, @@ -3677,28 +3721,28 @@ static void HWR_Subsector(size_t num) { light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); #ifndef SORTING - HWR_Add3DWater(levelflats[*rover->toppic].lumpnum, + HWR_Add3DWater(&levelflats[*rover->toppic], &extrasubsectors[num], *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1, rover->master->frontsector); #else - HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, + HWR_AddTransparentFloor(&levelflats[*rover->toppic], &extrasubsectors[num], true, *rover->topheight, *gr_frontsector->lightlist[light].lightlevel, rover->alpha-1 > 255 ? 255 : rover->alpha-1, rover->master->frontsector, PF_Translucent, - false, gr_frontsector->lightlist[light].extra_colormap); + false, *gr_frontsector->lightlist[light].extra_colormap); #endif } else { - HWR_GetFlat(levelflats[*rover->toppic].lumpnum); + HWR_GetLevelFlat(&levelflats[*rover->toppic]); light = R_GetPlaneLight(gr_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, false, gr_frontsector->lightlist[light].extra_colormap); + HWR_RenderPlane(NULL, &extrasubsectors[num], true, *rover->topheight, PF_Occlude, *gr_frontsector->lightlist[light].lightlevel, &levelflats[*rover->toppic], + rover->master->frontsector, 255, false, *gr_frontsector->lightlist[light].extra_colormap); } } } @@ -3757,11 +3801,16 @@ static void HWR_Subsector(size_t num) while (count--) { + + if (!line->glseg #ifdef POLYOBJECTS - if (!line->polyseg) // ignore segs that belong to polyobjects + && !line->polyseg // ignore segs that belong to polyobjects #endif + ) + { HWR_AddLine(line); - line++; + } + line++; } } @@ -4002,37 +4051,6 @@ static gr_vissprite_t *HWR_NewVisSprite(void) return HWR_GetVisSprite(gr_visspritecount++); } -// Finds a floor through which light does not pass. -static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) -{ - const sector_t *sec = R_PointInSubsector(x, y)->sector; - fixed_t floorz = sec->floorheight; - - if (sec->ffloors) - { - ffloor_t *rover; - fixed_t delta1, delta2; - const fixed_t thingtop = z + height; - - for (rover = sec->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) - || !(rover->flags & FF_RENDERPLANES) - || rover->flags & FF_TRANSLUCENT - || rover->flags & FF_FOG - || rover->flags & FF_INVERTPLANES) - continue; - - delta1 = z - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)); - delta2 = thingtop - (*rover->bottomheight + ((*rover->topheight - *rover->bottomheight)/2)); - if (*rover->topheight > floorz && abs(delta1) < abs(delta2)) - floorz = *rover->topheight; - } - } - - return floorz; -} - // // HWR_DoCulling // Hardware version of R_DoCulling @@ -4073,176 +4091,155 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v return false; } -static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float this_scale) +static void HWR_DrawDropShadow(mobj_t *thing, gr_vissprite_t *spr, fixed_t scale) { - FOutVector swallVerts[4]; + GLPatch_t *gpatch; + FOutVector shadowVerts[4]; FSurfaceInfo sSurf; - fixed_t floorheight, mobjfloor; - float offset = 0; + float fscale; float fx; float fy; float offset; + UINT8 lightlevel = 255; + extracolormap_t *colormap = NULL; + UINT8 i; - mobjfloor = HWR_OpaqueFloorAtPos( - spr->mobj->x, spr->mobj->y, - spr->mobj->z, spr->mobj->height); - if (cv_shadowoffs.value) - { - angle_t shadowdir; + INT32 light; + fixed_t scalemul; + UINT16 alpha; + fixed_t floordiff; + fixed_t floorz; + fixed_t slopez; + pslope_t *floorslope; - // Set direction - if (splitscreen && stplyr == &players[secondarydisplayplayer]) - shadowdir = localangle2 + FixedAngle(cv_cam2_rotate.value); - else - shadowdir = localangle + FixedAngle(cv_cam_rotate.value); + floorz = R_GetShadowZ(thing, &floorslope); - // Find floorheight - floorheight = HWR_OpaqueFloorAtPos( - spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - mobjfloor), - spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - mobjfloor), - spr->mobj->z, spr->mobj->height); + //if (abs(floorz - gr_viewz) / tz > 4) return; // Prevent stretchy shadows and possible crashes - // The shadow is falling ABOVE it's mobj? - // Don't draw it, then! - if (spr->mobj->z < floorheight) - return; - else - { - fixed_t floorz; - floorz = HWR_OpaqueFloorAtPos( - spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight), - spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight), - spr->mobj->z, spr->mobj->height); - // The shadow would be falling on a wall? Don't draw it, then. - // Would draw midair otherwise. - if (floorz < floorheight) - return; - } + floordiff = abs(thing->z - floorz); - floorheight = FixedInt(spr->mobj->z - floorheight); + alpha = floordiff / (4*FRACUNIT) + 75; + if (alpha >= 255) return; + alpha = 255 - alpha; - offset = floorheight; - } - else - floorheight = FixedInt(spr->mobj->z - mobjfloor); + gpatch = (GLPatch_t *)W_CachePatchName("DSHADOW", PU_CACHE); + if (!(gpatch && gpatch->mipmap->grInfo.format)) return; + HWR_GetPatch(gpatch); + + scalemul = FixedMul(FRACUNIT - floordiff/640, scale); + scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); + + fscale = FIXED_TO_FLOAT(scalemul); + fx = FIXED_TO_FLOAT(thing->x); + fy = FIXED_TO_FLOAT(thing->y); - // create the sprite billboard - // // 3--2 // | /| // |/ | // 0--1 - // x1/x2 were already scaled in HWR_ProjectSprite - // First match the normal sprite - swallVerts[0].x = swallVerts[3].x = spr->x1; - swallVerts[2].x = swallVerts[1].x = spr->x2; - swallVerts[0].z = swallVerts[3].z = spr->z1; - swallVerts[2].z = swallVerts[1].z = spr->z2; + if (thing && fabsf(fscale - 1.0f) > 1.0E-36f) + offset = (gpatch->height/2) * fscale; + else + offset = (float)(gpatch->height/2); - if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) + shadowVerts[0].x = shadowVerts[3].x = fx - offset; + shadowVerts[2].x = shadowVerts[1].x = fx + offset; + shadowVerts[0].z = shadowVerts[1].z = fy - offset; + shadowVerts[3].z = shadowVerts[2].z = fy + offset; + + if (floorslope) { - // Always a pixel above the floor, perfectly flat. - swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->ty - gpatch->topoffset * this_scale - (floorheight+3); - - // Now transform the TOP vertices along the floor in the direction of the camera - swallVerts[3].x = spr->x1 + ((gpatch->height * this_scale) + offset) * gr_viewcos; - swallVerts[2].x = spr->x2 + ((gpatch->height * this_scale) + offset) * gr_viewcos; - swallVerts[3].z = spr->z1 + ((gpatch->height * this_scale) + offset) * gr_viewsin; - swallVerts[2].z = spr->z2 + ((gpatch->height * this_scale) + offset) * gr_viewsin; + for (i = 0; i < 4; i++) + { + slopez = P_GetZAt(floorslope, FLOAT_TO_FIXED(shadowVerts[i].x), FLOAT_TO_FIXED(shadowVerts[i].z)); + shadowVerts[i].y = FIXED_TO_FLOAT(slopez) + 0.05f; + } } else { - // Always a pixel above the floor, perfectly flat. - swallVerts[0].y = swallVerts[1].y = swallVerts[2].y = swallVerts[3].y = spr->ty - gpatch->topoffset - (floorheight+3); - - // Now transform the TOP vertices along the floor in the direction of the camera - swallVerts[3].x = spr->x1 + (gpatch->height + offset) * gr_viewcos; - swallVerts[2].x = spr->x2 + (gpatch->height + offset) * gr_viewcos; - swallVerts[3].z = spr->z1 + (gpatch->height + offset) * gr_viewsin; - swallVerts[2].z = spr->z2 + (gpatch->height + offset) * gr_viewsin; - } - - // We also need to move the bottom ones away when shadowoffs is on - if (cv_shadowoffs.value) - { - swallVerts[0].x = spr->x1 + offset * gr_viewcos; - swallVerts[1].x = spr->x2 + offset * gr_viewcos; - swallVerts[0].z = spr->z1 + offset * gr_viewsin; - swallVerts[1].z = spr->z2 + offset * gr_viewsin; + for (i = 0; i < 4; i++) + shadowVerts[i].y = FIXED_TO_FLOAT(floorz) + 0.05f; } if (spr->flip) { - swallVerts[0].sow = swallVerts[3].sow = gpatch->max_s; - swallVerts[2].sow = swallVerts[1].sow = 0; + shadowVerts[0].sow = shadowVerts[3].sow = gpatch->max_s; + shadowVerts[2].sow = shadowVerts[1].sow = 0; } else { - swallVerts[0].sow = swallVerts[3].sow = 0; - swallVerts[2].sow = swallVerts[1].sow = gpatch->max_s; + shadowVerts[0].sow = shadowVerts[3].sow = 0; + shadowVerts[2].sow = shadowVerts[1].sow = gpatch->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - swallVerts[3].tow = swallVerts[2].tow = gpatch->max_t; - swallVerts[0].tow = swallVerts[1].tow = 0; + shadowVerts[3].tow = shadowVerts[2].tow = gpatch->max_t; + shadowVerts[0].tow = shadowVerts[1].tow = 0; } else { - swallVerts[3].tow = swallVerts[2].tow = 0; - swallVerts[0].tow = swallVerts[1].tow = gpatch->max_t; + shadowVerts[3].tow = shadowVerts[2].tow = 0; + shadowVerts[0].tow = shadowVerts[1].tow = gpatch->max_t; } - sSurf.FlatColor.s.red = 0x00; - sSurf.FlatColor.s.blue = 0x00; - sSurf.FlatColor.s.green = 0x00; - - /*if (spr->mobj->frame & FF_TRANSMASK || spr->mobj->flags2 & MF2_SHADOW) + if (thing->subsector->sector->numlights) { - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + light = R_GetPlaneLight(thing->subsector->sector, floorz, false); // Always use the light at the top instead of whatever I was doing before - if (sector->numlights) - { - INT32 light = R_GetPlaneLight(sector, spr->mobj->floorz, false); + lightlevel = *thing->subsector->sector->lightlist[light].lightlevel; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) - lightlevel = *sector->lightlist[light].lightlevel; - - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; - } - else - { - lightlevel = sector->lightlevel; - - if (sector->extra_colormap) - colormap = sector->extra_colormap; - } - - if (colormap) - sSurf.FlatColor.rgba = HWR_Lighting(lightlevel/2, colormap->rgba, colormap->fadergba, false, true); - else - sSurf.FlatColor.rgba = HWR_Lighting(lightlevel/2, NORMALFOG, FADEFOG, false, true); - }*/ - - // shadow is always half as translucent as the sprite itself - if (!cv_translucency.value) // use default translucency (main sprite won't have any translucency) - sSurf.FlatColor.s.alpha = 0x80; // default - else if (spr->mobj->flags2 & MF2_SHADOW) - sSurf.FlatColor.s.alpha = 0x20; - else if (spr->mobj->frame & FF_TRANSMASK) - { - HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &sSurf); - sSurf.FlatColor.s.alpha /= 2; //cut alpha in half! + if (*thing->subsector->sector->lightlist[light].extra_colormap) + colormap = *thing->subsector->sector->lightlist[light].extra_colormap; } else - sSurf.FlatColor.s.alpha = 0x80; // default - - if (sSurf.FlatColor.s.alpha > floorheight/4) { - sSurf.FlatColor.s.alpha = (UINT8)(sSurf.FlatColor.s.alpha - floorheight/4); - HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated|PF_Clip); + lightlevel = thing->subsector->sector->lightlevel; + + if (thing->subsector->sector->extra_colormap) + colormap = thing->subsector->sector->extra_colormap; + } + + if (colormap) + sSurf.FlatColor.rgba = HWR_Lighting(lightlevel, colormap->rgba, colormap->fadergba, false, false); + else + sSurf.FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false); + + sSurf.FlatColor.s.alpha = alpha; + + HWD.pfnDrawPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated|PF_Clip); +} + +// This is expecting a pointer to an array containing 4 wallVerts for a sprite +static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts) +{ + if (cv_grspritebillboarding.value + && spr && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE) + && wallVerts) + { + float basey = FIXED_TO_FLOAT(spr->mobj->z); + float lowy = wallVerts[0].y; + if (P_MobjFlip(spr->mobj) == -1) + { + basey = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height); + } + // Rotate sprites to fully billboard with the camera + // X, Y, AND Z need to be manipulated for the polys to rotate around the + // origin, because of how the origin setting works I believe that should + // be mobj->z or mobj->z + mobj->height + wallVerts[2].y = wallVerts[3].y = (spr->ty - basey) * gr_viewludsin + basey; + wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gr_viewludsin + basey; + // translate back to be around 0 before translating back + wallVerts[3].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos; + wallVerts[2].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos; + + wallVerts[0].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos; + wallVerts[1].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos; + + wallVerts[3].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin; + wallVerts[2].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin; + + wallVerts[0].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin; + wallVerts[1].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin; } } @@ -4250,6 +4247,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { float this_scale = 1.0f; FOutVector wallVerts[4]; + FOutVector baseWallVerts[4]; // This is what the verts should end up as GLPatch_t *gpatch; FSurfaceInfo Surf; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); @@ -4262,11 +4260,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) float realtop, realbot, top, bot; float towtop, towbot, towmult; float bheight; + float realheight, heightmult; const sector_t *sector = spr->mobj->subsector->sector; const lightlist_t *list = sector->lightlist; #ifdef ESLOPE float endrealtop, endrealbot, endtop, endbot; float endbheight; + float endrealheight; fixed_t temp; fixed_t v1x, v1y, v2x, v2y; #endif @@ -4276,39 +4276,23 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (hires) this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale); - gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); // cache the patch in the graphics card memory //12/12/99: Hurdler: same comment as above (for md2) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); - // Draw shadow BEFORE sprite - if (cv_shadow.value // Shadows enabled - && (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. - && !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. -#ifdef ALAM_LIGHTING - && !(t_lspr[spr->mobj->sprite]->type // Things with dynamic lights have no shadow. - && (!spr->mobj->player || spr->mobj->player->powers[pw_super])) // Except for non-super players. -#endif - && (spr->mobj->z >= spr->mobj->floorz)) // Without this, your shadow shows on the floor, even after you die and fall through the ground. - { - //////////////////// - // SHADOW SPRITE! // - //////////////////// - HWR_DrawSpriteShadow(spr, gpatch, this_scale); - } + baseWallVerts[0].x = baseWallVerts[3].x = spr->x1; + baseWallVerts[2].x = baseWallVerts[1].x = spr->x2; + baseWallVerts[0].z = baseWallVerts[3].z = spr->z1; + baseWallVerts[1].z = baseWallVerts[2].z = spr->z2; - wallVerts[0].x = wallVerts[3].x = spr->x1; - wallVerts[2].x = wallVerts[1].x = spr->x2; - wallVerts[0].z = wallVerts[3].z = spr->z1; - wallVerts[1].z = wallVerts[2].z = spr->z2; - - wallVerts[2].y = wallVerts[3].y = spr->ty; + baseWallVerts[2].y = baseWallVerts[3].y = spr->ty; if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale; + baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height * this_scale; else - wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; + baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height; v1x = FLOAT_TO_FIXED(spr->x1); v1y = FLOAT_TO_FIXED(spr->z1); @@ -4317,44 +4301,56 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) if (spr->flip) { - wallVerts[0].sow = wallVerts[3].sow = gpatch->max_s; - wallVerts[2].sow = wallVerts[1].sow = 0; - }else{ - wallVerts[0].sow = wallVerts[3].sow = 0; - wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s; + baseWallVerts[0].sow = baseWallVerts[3].sow = gpatch->max_s; + baseWallVerts[2].sow = baseWallVerts[1].sow = 0; + } + else + { + baseWallVerts[0].sow = baseWallVerts[3].sow = 0; + baseWallVerts[2].sow = baseWallVerts[1].sow = gpatch->max_s; } // flip the texture coords (look familiar?) if (spr->vflip) { - wallVerts[3].tow = wallVerts[2].tow = gpatch->max_t; - wallVerts[0].tow = wallVerts[1].tow = 0; - }else{ - wallVerts[3].tow = wallVerts[2].tow = 0; - wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t; + baseWallVerts[3].tow = baseWallVerts[2].tow = gpatch->max_t; + baseWallVerts[0].tow = baseWallVerts[1].tow = 0; + } + else + { + baseWallVerts[3].tow = baseWallVerts[2].tow = 0; + baseWallVerts[0].tow = baseWallVerts[1].tow = gpatch->max_t; } // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { float co = -gr_viewcos*(0.05f*spr->dispoffset); float si = -gr_viewsin*(0.05f*spr->dispoffset); - wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; - wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; - wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; - wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; + baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si; + baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si; + baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co; + baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co; } - realtop = top = wallVerts[3].y; - realbot = bot = wallVerts[0].y; - towtop = wallVerts[3].tow; - towbot = wallVerts[0].tow; + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, baseWallVerts); + + realtop = top = baseWallVerts[3].y; + realbot = bot = baseWallVerts[0].y; + towtop = baseWallVerts[3].tow; + towbot = baseWallVerts[0].tow; towmult = (towbot - towtop) / (top - bot); #ifdef ESLOPE - endrealtop = endtop = wallVerts[2].y; - endrealbot = endbot = wallVerts[1].y; + endrealtop = endtop = baseWallVerts[2].y; + endrealbot = endbot = baseWallVerts[1].y; #endif + // copy the contents of baseWallVerts into the drawn wallVerts array + // baseWallVerts is used to know the final shape to easily get the vertex + // co-ordinates + memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); + if (!cv_translucency.value) // translucency disabled { Surf.FlatColor.s.alpha = 0xFF; @@ -4381,7 +4377,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) // Start with the lightlevel and colormap from the top of the sprite lightlevel = *list[sector->numlights - 1].lightlevel; - colormap = list[sector->numlights - 1].extra_colormap; + colormap = *list[sector->numlights - 1].extra_colormap; i = 0; temp = FLOAT_TO_FIXED(realtop); @@ -4397,7 +4393,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i-1].lightlevel; - colormap = list[i-1].extra_colormap; + colormap = *list[i-1].extra_colormap; break; } } @@ -4405,7 +4401,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) i = R_GetPlaneLight(sector, temp, false); if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; #endif for (i = 0; i < sector->numlights; i++) @@ -4421,7 +4417,7 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) { if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *list[i].lightlevel; - colormap = list[i].extra_colormap; + colormap = *list[i].extra_colormap; } #ifdef ESLOPE @@ -4481,12 +4477,55 @@ static void HWR_SplitSprite(gr_vissprite_t *spr) wallVerts[2].y = endtop; wallVerts[0].y = bot; wallVerts[1].y = endbot; + + // The x and y only need to be adjusted in the case that it's not a papersprite + if (cv_grspritebillboarding.value + && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) + { + // Get the x and z of the vertices so billboarding draws correctly + realheight = realbot - realtop; + endrealheight = endrealbot - endrealtop; + heightmult = (realtop - top) / realheight; + wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + + heightmult = (endrealtop - endtop) / endrealheight; + wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + + heightmult = (realtop - bot) / realheight; + wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + + heightmult = (endrealtop - endbot) / endrealheight; + wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + } #else wallVerts[3].tow = wallVerts[2].tow = towtop + ((realtop - top) * towmult); wallVerts[0].tow = wallVerts[1].tow = towtop + ((realtop - bot) * towmult); wallVerts[2].y = wallVerts[3].y = top; wallVerts[0].y = wallVerts[1].y = bot; + + // The x and y only need to be adjusted in the case that it's not a papersprite + if (cv_grspritebillboarding.value + && spr->mobj && !(spr->mobj->frame & FF_PAPERSPRITE)) + { + // Get the x and z of the vertices so billboarding draws correctly + realheight = realbot - realtop; + heightmult = (realtop - top) / realheight; + wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + + heightmult = (realtop - bot) / realheight; + wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult; + wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult; + wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult; + wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; + } #endif if (colormap) @@ -4553,6 +4592,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) GLPatch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); + //const boolean papersprite = (spr->mobj && (spr->mobj->frame & FF_PAPERSPRITE)); if (spr->mobj) this_scale = FIXED_TO_FLOAT(spr->mobj->scale); if (hires) @@ -4576,7 +4616,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) // sure to do it the right way. So actually, we keep normal sprite // in memory and we add the md2 model if it exists for that sprite - gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); #ifdef ALAM_LIGHTING if (!(spr->mobj->flags2 & MF2_DEBRIS) && (spr->mobj->sprite != SPR_PLAY || @@ -4629,22 +4669,6 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) //Hurdler: 25/04/2000: now support colormap in hardware mode HWR_GetMappedPatch(gpatch, spr->colormap); - // Draw shadow BEFORE sprite - if (cv_shadow.value // Shadows enabled - && (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow. - && !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow. -#ifdef ALAM_LIGHTING - && !(t_lspr[spr->mobj->sprite]->type // Things with dynamic lights have no shadow. - && (!spr->mobj->player || spr->mobj->player->powers[pw_super])) // Except for non-super players. -#endif - && (spr->mobj->z >= spr->mobj->floorz)) // Without this, your shadow shows on the floor, even after you die and fall through the ground. - { - //////////////////// - // SHADOW SPRITE! // - //////////////////// - HWR_DrawSpriteShadow(spr, gpatch, this_scale); - } - // if it has a dispoffset, push it a little towards the camera if (spr->dispoffset) { float co = -gr_viewcos*(0.05f*spr->dispoffset); @@ -4655,6 +4679,9 @@ static void HWR_DrawSprite(gr_vissprite_t *spr) wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; } + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, wallVerts); + // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // sprite lighting by modulating the RGB components /// \todo coloured @@ -4718,7 +4745,7 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) return; // cache sprite graphics - gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); // create the sprite billboard // @@ -4736,6 +4763,9 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) wallVerts[0].z = wallVerts[3].z = spr->z1; wallVerts[1].z = wallVerts[2].z = spr->z2; + // Let dispoffset work first since this adjust each vertex + HWR_RotateSpritePolyToAim(spr, wallVerts); + wallVerts[0].sow = wallVerts[3].sow = 0; wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s; @@ -4762,8 +4792,8 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { @@ -4926,7 +4956,7 @@ typedef struct boolean isceiling; fixed_t fixedheight; INT32 lightlevel; - lumpnum_t lumpnum; + levelflat_t *levelflat; INT32 alpha; sector_t *FOFSector; FBITFIELD blend; @@ -4944,7 +4974,7 @@ typedef struct boolean isceiling; fixed_t fixedheight; INT32 lightlevel; - lumpnum_t lumpnum; + levelflat_t *levelflat; INT32 alpha; sector_t *FOFSector; FBITFIELD blend; @@ -4958,8 +4988,6 @@ static polyplaneinfo_t *polyplaneinfo = NULL; #ifndef SORTING size_t numfloors = 0; #else -//static floorinfo_t *floorinfo = NULL; -//static size_t numfloors = 0; //Hurdler: 3D water sutffs typedef struct gr_drawnode_s { @@ -4977,7 +5005,7 @@ static INT32 drawcount = 0; #define MAX_TRANSPARENTFLOOR 512 // This will likely turn into a copy of HWR_Add3DWater and replace it. -void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, +void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap) { static size_t allocedplanes = 0; @@ -4994,8 +5022,8 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean planeinfo[numplanes].isceiling = isceiling; planeinfo[numplanes].fixedheight = fixedheight; - planeinfo[numplanes].lightlevel = lightlevel; - planeinfo[numplanes].lumpnum = lumpnum; + planeinfo[numplanes].lightlevel = (planecolormap && (planecolormap->flags & CMF_FOG)) ? lightlevel : 255; + planeinfo[numplanes].levelflat = levelflat; planeinfo[numplanes].xsub = xsub; planeinfo[numplanes].alpha = alpha; planeinfo[numplanes].FOFSector = FOFSector; @@ -5009,7 +5037,7 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean // Adding this for now until I can create extrasubsector info for polyobjects // When that happens it'll just be done through HWR_AddTransparentFloor and HWR_RenderPlane -void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, +void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap) { static size_t allocedpolyplanes = 0; @@ -5026,8 +5054,8 @@ void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, polyplaneinfo[numpolyplanes].isceiling = isceiling; polyplaneinfo[numpolyplanes].fixedheight = fixedheight; - polyplaneinfo[numpolyplanes].lightlevel = lightlevel; - polyplaneinfo[numpolyplanes].lumpnum = lumpnum; + polyplaneinfo[numpolyplanes].lightlevel = (planecolormap && (planecolormap->flags & CMF_FOG)) ? lightlevel : 255; + polyplaneinfo[numpolyplanes].levelflat = levelflat; polyplaneinfo[numpolyplanes].polysector = polysector; polyplaneinfo[numpolyplanes].alpha = alpha; polyplaneinfo[numpolyplanes].FOFSector = FOFSector; @@ -5189,9 +5217,9 @@ static void HWR_CreateDrawNodes(void) gr_frontsector = NULL; if (!(sortnode[sortindex[i]].plane->blend & PF_NoTexture)) - HWR_GetFlat(sortnode[sortindex[i]].plane->lumpnum); + HWR_GetLevelFlat(sortnode[sortindex[i]].plane->levelflat); HWR_RenderPlane(NULL, sortnode[sortindex[i]].plane->xsub, sortnode[sortindex[i]].plane->isceiling, sortnode[sortindex[i]].plane->fixedheight, sortnode[sortindex[i]].plane->blend, sortnode[sortindex[i]].plane->lightlevel, - sortnode[sortindex[i]].plane->lumpnum, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap); + sortnode[sortindex[i]].plane->levelflat, sortnode[sortindex[i]].plane->FOFSector, sortnode[sortindex[i]].plane->alpha, sortnode[sortindex[i]].plane->fogplane, sortnode[sortindex[i]].plane->planecolormap); } else if (sortnode[sortindex[i]].polyplane) { @@ -5199,9 +5227,9 @@ static void HWR_CreateDrawNodes(void) gr_frontsector = NULL; if (!(sortnode[sortindex[i]].polyplane->blend & PF_NoTexture)) - HWR_GetFlat(sortnode[sortindex[i]].polyplane->lumpnum); + HWR_GetLevelFlat(sortnode[sortindex[i]].polyplane->levelflat); HWR_RenderPolyObjectPlane(sortnode[sortindex[i]].polyplane->polysector, sortnode[sortindex[i]].polyplane->isceiling, sortnode[sortindex[i]].polyplane->fixedheight, sortnode[sortindex[i]].polyplane->blend, sortnode[sortindex[i]].polyplane->lightlevel, - sortnode[sortindex[i]].polyplane->lumpnum, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap); + sortnode[sortindex[i]].polyplane->levelflat, sortnode[sortindex[i]].polyplane->FOFSector, sortnode[sortindex[i]].polyplane->alpha, sortnode[sortindex[i]].polyplane->planecolormap); } else if (sortnode[sortindex[i]].wall) { @@ -5244,20 +5272,33 @@ static void HWR_DrawSprites(void) HWR_DrawPrecipitationSprite(spr); else #endif + { + if (spr->mobj && spr->mobj->shadowscale && cv_shadow.value) + { + HWR_DrawDropShadow(spr->mobj, spr, spr->mobj->shadowscale); + } + if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) { - if (!cv_grmd2.value || md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) + if (!cv_grmodels.value || md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) HWR_DrawSprite(spr); else - HWR_DrawMD2(spr); + { + if (!HWR_DrawModel(spr)) + HWR_DrawSprite(spr); + } } else { - if (!cv_grmd2.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) + if (!cv_grmodels.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) HWR_DrawSprite(spr); else - HWR_DrawMD2(spr); + { + if (!HWR_DrawModel(spr)) + HWR_DrawSprite(spr); + } } + } } } } @@ -5274,7 +5315,7 @@ static void HWR_AddSprites(sector_t *sec) #ifdef HWPRECIP precipmobj_t *precipthing; #endif - fixed_t approx_dist, limit_dist; + fixed_t limit_dist, hoop_limit_dist; // BSP is traversed by subsector. // A sector might have been split into several @@ -5291,52 +5332,23 @@ static void HWR_AddSprites(sector_t *sec) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if ((limit_dist = (fixed_t)((maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : cv_drawdist.value) << FRACBITS)) + limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS; + hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS; + for (thing = sec->thinglist; thing; thing = thing->snext) { - for (thing = sec->thinglist; thing; thing = thing->snext) - { - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - - if (approx_dist > limit_dist) - continue; - + if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist)) HWR_ProjectSprite(thing); - } - } - else - { - // Draw everything in sector, no checks - for (thing = sec->thinglist; thing; thing = thing->snext) - if (!(thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)) - HWR_ProjectSprite(thing); } #ifdef HWPRECIP - // Someone seriously wants infinite draw distance for precipitation? + // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) { for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) { - if (precipthing->precipflags & PCF_INVISIBLE) - continue; - - approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - - if (approx_dist > limit_dist) - continue; - - HWR_ProjectPrecipitationSprite(precipthing); - } - } - else - { - // Draw everything in sector, no checks - for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) - if (!(precipthing->precipflags & PCF_INVISIBLE)) + if (R_PrecipThingVisible(precipthing, limit_dist)) HWR_ProjectPrecipitationSprite(precipthing); + } } #endif } @@ -5352,22 +5364,35 @@ static void HWR_ProjectSprite(mobj_t *thing) float tr_x, tr_y; float tz; float x1, x2; - float z1, z2; float rightsin, rightcos; float this_scale; float gz, gzt; spritedef_t *sprdef; spriteframe_t *sprframe; + spriteinfo_t *sprinfo; + md2_t *md2; size_t lumpoff; unsigned rot; - UINT8 flip; + UINT16 flip; + boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); + angle_t ang; INT32 heightsec, phs; + const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle); + float z1, z2; + + fixed_t spr_width, spr_height; + fixed_t spr_offset, spr_topoffset; +#ifdef ROTSPRITE + patch_t *rotsprite = NULL; + INT32 rollangle = 0; +#endif if (!thing) return; - else - this_scale = FIXED_TO_FLOAT(thing->scale); + + this_scale = FIXED_TO_FLOAT(thing->scale); // transform the origin point tr_x = FIXED_TO_FLOAT(thing->x) - gr_viewx; @@ -5377,8 +5402,21 @@ static void HWR_ProjectSprite(mobj_t *thing) tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin); // thing is behind view plane? - if (tz < ZCLIP_PLANE && (!cv_grmd2.value || md2_models[thing->sprite].notfound == true)) //Yellow: Only MD2's dont disappear - return; + if (tz < ZCLIP_PLANE && !papersprite) + { + if (cv_grmodels.value) //Yellow: Only MD2's dont disappear + { + if (thing->skin && thing->sprite == SPR_PLAY) + md2 = &md2_playermodels[( (skin_t *)thing->skin - skins )]; + else + md2 = &md2_models[thing->sprite]; + + if (md2->notfound || md2->scale < 0.0f) + return; + } + else + return; + } // The above can stay as it works for cutting sprites that are too close tr_x = FIXED_TO_FLOAT(thing->x); @@ -5394,9 +5432,15 @@ static void HWR_ProjectSprite(mobj_t *thing) //Fab : 02-08-98: 'skin' override spritedef currently used for skin if (thing->skin && thing->sprite == SPR_PLAY) - sprdef = &((skin_t *)thing->skin)->spritedef; + { + sprdef = &((skin_t *)thing->skin)->sprites[thing->sprite2]; + sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2]; + } else + { sprdef = &sprites[thing->sprite]; + sprinfo = NULL; + } if (rot >= sprdef->numframes) { @@ -5405,6 +5449,7 @@ static void HWR_ProjectSprite(mobj_t *thing) thing->sprite = states[S_UNKNOWN].sprite; thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; + sprinfo = NULL; rot = thing->frame&FF_FRAMEMASK; thing->state->sprite = thing->sprite; thing->state->frame = thing->frame; @@ -5417,53 +5462,116 @@ static void HWR_ProjectSprite(mobj_t *thing) I_Error("sprframes NULL for sprite %d\n", thing->sprite); #endif - if (sprframe->rotate) - { - // choose a different rotation based on player view - ang = R_PointToAngle(thing->x, thing->y); // uses viewx,viewy - rot = (ang-thing->angle+ANGLE_202h)>>29; - //Fab: lumpid is the index for spritewidth,spriteoffset... tables - lumpoff = sprframe->lumpid[rot]; - flip = sprframe->flip & (1<x, thing->y) - mobjangle; + + if (sprframe->rotate == SRF_SINGLE) { // use single rotation for all views rot = 0; //Fab: for vis->patch below lumpoff = sprframe->lumpid[0]; //Fab: see note above flip = sprframe->flip; // Will only be 0x00 or 0xFF + + if (papersprite && ang < ANGLE_180) + flip ^= 0xFFFF; + } + else + { + // choose a different rotation based on player view + if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right + rot = 6; // F7 slot + else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left + rot = 2; // F3 slot + else if (sprframe->rotate & SRF_3DGE) // 16-angle mode + { + rot = (ang+ANGLE_180+ANGLE_11hh)>>28; + rot = ((rot & 1)<<3)|(rot>>1); + } + else // Normal behaviour + rot = (ang+ANGLE_202h)>>29; + + //Fab: lumpid is the index for spritewidth,spriteoffset... tables + lumpoff = sprframe->lumpid[rot]; + flip = sprframe->flip & (1<skin && ((skin_t *)thing->skin)->flags & SF_HIRES) this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)thing->skin)->highresscale); - rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - if (flip) + spr_width = spritecachedinfo[lumpoff].width; + spr_height = spritecachedinfo[lumpoff].height; + spr_offset = spritecachedinfo[lumpoff].offset; + spr_topoffset = spritecachedinfo[lumpoff].topoffset; + +#ifdef ROTSPRITE + if (thing->rollangle) { - x1 = (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset) * this_scale); - x2 = (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset) * this_scale); + rollangle = R_GetRollAngle(thing->rollangle); + if (!(sprframe->rotsprite.cached & (1<sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip); + rotsprite = sprframe->rotsprite.patch[rot][rollangle]; + if (rotsprite != NULL) + { + spr_width = rotsprite->width << FRACBITS; + spr_height = rotsprite->height << FRACBITS; + spr_offset = rotsprite->leftoffset << FRACBITS; + spr_topoffset = rotsprite->topoffset << FRACBITS; + // flip -> rotate, not rotate -> flip + flip = 0; + } + } +#endif + + if (papersprite) + { + rightsin = FIXED_TO_FLOAT(FINESINE((mobjangle)>>ANGLETOFINESHIFT)); + rightcos = FIXED_TO_FLOAT(FINECOSINE((mobjangle)>>ANGLETOFINESHIFT)); } else { - x1 = (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset) * this_scale); - x2 = (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset) * this_scale); + rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); } + if (flip) + { + x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_scale); + x2 = (FIXED_TO_FLOAT(spr_offset) * this_scale); + } + else + { + x1 = (FIXED_TO_FLOAT(spr_offset) * this_scale); + x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * this_scale); + } + + // test if too close +/* + if (papersprite) + { + z1 = tz - x1 * angle_scalez; + z2 = tz + x2 * angle_scalez; + + if (max(z1, z2) < ZCLIP_PLANE) + return; + } +*/ + z1 = tr_y + x1 * rightsin; z2 = tr_y - x2 * rightsin; x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { - gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale; - gzt = gz + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale; + gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spr_topoffset) * this_scale; + gzt = gz + FIXED_TO_FLOAT(spr_height) * this_scale; } else { - gzt = FIXED_TO_FLOAT(thing->z) + FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale; - gz = gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale; + gzt = FIXED_TO_FLOAT(thing->z) + FIXED_TO_FLOAT(spr_topoffset) * this_scale; + gz = gzt - FIXED_TO_FLOAT(spr_height) * this_scale; } if (thing->subsector->sector->cullheight) @@ -5490,22 +5598,35 @@ static void HWR_ProjectSprite(mobj_t *thing) return; } + if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) + { + // bodge support - not nearly as comprehensive as r_things.c, but better than nothing + if (! R_ThingVisible(thing->tracer)) + return; + } + // store information in a vissprite vis = HWR_NewVisSprite(); vis->x1 = x1; vis->x2 = x2; - vis->z1 = z1; - vis->z2 = z2; vis->tz = tz; // Keep tz for the simple sprite sorting that happens vis->dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - vis->patchlumpnum = sprframe->lumppat[rot]; + //vis->patchlumpnum = sprframe->lumppat[rot]; +#ifdef ROTSPRITE + if (rotsprite) + vis->gpatch = (GLPatch_t *)rotsprite; + else +#endif + vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->flip = flip; vis->mobj = thing; + vis->z1 = z1; + vis->z2 = z2; //Hurdler: 25/04/2000: now support colormap in hardware mode - if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" + if ((vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" { - if (vis->mobj->type == MT_CYBRAKDEMON) + if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized) vis->colormap = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); else if (vis->mobj->type == MT_METALSONIC_BATTLE) vis->colormap = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); @@ -5515,7 +5636,18 @@ static void HWR_ProjectSprite(mobj_t *thing) else if (thing->color) { // New colormap stuff for skins Tails 06-07-2002 - if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player! + if (thing->colorized) + vis->colormap = R_GetTranslationColormap(TC_RAINBOW, thing->color, GTC_CACHE); + else if (thing->player && thing->player->dashmode >= DASHMODE_THRESHOLD + && (thing->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) + { + if (thing->player->charflags & SF_MACHINE) + vis->colormap = R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); + else + vis->colormap = R_GetTranslationColormap(TC_RAINBOW, thing->color, GTC_CACHE); + } + else if (thing->skin && thing->sprite == SPR_PLAY) // This thing is a player! { size_t skinnum = (skin_t*)thing->skin-skins; vis->colormap = R_GetTranslationColormap((INT32)skinnum, thing->color, GTC_CACHE); @@ -5532,10 +5664,7 @@ static void HWR_ProjectSprite(mobj_t *thing) //CONS_Debug(DBG_RENDER, "------------------\nH: sprite : %d\nH: frame : %x\nH: type : %d\nH: sname : %s\n\n", // thing->sprite, thing->frame, thing->type, sprnames[thing->sprite]); - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; + vis->vflip = vflip; vis->precip = false; } @@ -5613,16 +5742,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) x1 = tr_x + x1 * rightcos; x2 = tr_x - x2 * rightcos; - // okay, we can't return now... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); - thing->precipflags |= PCF_THUNK; - } - // // store information in a vissprite // @@ -5633,7 +5752,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->z2 = z2; vis->tz = tz; vis->dispoffset = 0; // Monster Iestyn: 23/11/15: HARDWARE SUPPORT AT LAST - vis->patchlumpnum = sprframe->lumppat[rot]; + //vis->patchlumpnum = sprframe->lumppat[rot]; + vis->gpatch = (GLPatch_t *)W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); vis->flip = flip; vis->mobj = (mobj_t *)thing; @@ -5643,90 +5763,144 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) vis->ty = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); vis->precip = true; + + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + if (thing->precipflags & PCF_RAIN) + P_RainThinker(thing); + else + P_SnowThinker(thing); + thing->precipflags |= PCF_THUNK; + } } #endif // ========================================================================== // // ========================================================================== -static void HWR_DrawSkyBackground(void) +static void HWR_DrawSkyBackground(player_t *player) { - FOutVector v[4]; - angle_t angle; - float dimensionmultiply; - float aspectratio; - float angleturn; - - HWR_GetTexture(skytexture); - aspectratio = (float)vid.width/(float)vid.height; - - //Hurdler: the sky is the only texture who need 4.0f instead of 1.0 - // because it's called just after clearing the screen - // and thus, the near clipping plane is set to 3.99 - // Sryder: Just use the near clipping plane value then - - // 3--2 - // | /| - // |/ | - // 0--1 - v[0].x = v[3].x = -ZCLIP_PLANE-1; - v[1].x = v[2].x = ZCLIP_PLANE+1; - v[0].y = v[1].y = -ZCLIP_PLANE-1; - v[2].y = v[3].y = ZCLIP_PLANE+1; - - v[0].z = v[1].z = v[2].z = v[3].z = ZCLIP_PLANE+1; - - // X - - // NOTE: This doesn't work right with texture widths greater than 1024 - // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly - // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture - - angle = (dup_viewangle + gr_xtoviewangle[0]); - dimensionmultiply = ((float)textures[skytexture]->width/256.0f); - - v[0].sow = v[3].sow = ((float) angle / ((ANGLE_90-1)*dimensionmultiply)); - v[2].sow = v[1].sow = (-1.0f/dimensionmultiply)+((float) angle / ((ANGLE_90-1)*dimensionmultiply)); - - // Y - angle = aimingangle; - dimensionmultiply = ((float)textures[skytexture]->height/(128.0f*aspectratio)); - - if (splitscreen) + if (cv_grskydome.value) { - dimensionmultiply *= 2; - angle *= 2; - } + FTransform dometransform; + const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); + postimg_t *type; - // Middle of the sky should always be at angle 0 - // need to keep correct aspect ratio with X - if (atransform.flip) - { - // During vertical flip the sky should be flipped and it's y movement should also be flipped obviously - v[3].tow = v[2].tow = -(0.5f-(0.5f/dimensionmultiply)); - v[0].tow = v[1].tow = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply)); + if (splitscreen && player == &players[secondarydisplayplayer]) + type = &postimgtype2; + else + type = &postimgtype; + + memset(&dometransform, 0x00, sizeof(FTransform)); + + //04/01/2000: Hurdler: added for T&L + // It should replace all other gr_viewxxx when finished + dometransform.anglex = (float)(aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + + if (*type == postimg_flip) + dometransform.flip = true; + else + dometransform.flip = false; + + dometransform.scalex = 1; + dometransform.scaley = (float)vid.width/vid.height; + dometransform.scalez = 1; + dometransform.fovxangle = fpov; // Tails + dometransform.fovyangle = fpov; // Tails + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + dometransform.rollangle = FIXED_TO_FLOAT(rol); + dometransform.roll = true; + } + dometransform.splitscreen = splitscreen; + + HWR_GetTexture(texturetranslation[skytexture]); + HWD.pfnRenderSkyDome(skytexture, textures[skytexture]->width, textures[skytexture]->height, dometransform); } else { - v[3].tow = v[2].tow = (-1.0f/dimensionmultiply)-(0.5f-(0.5f/dimensionmultiply)); - v[0].tow = v[1].tow = -(0.5f-(0.5f/dimensionmultiply)); - } + FOutVector v[4]; + angle_t angle; + float dimensionmultiply; + float aspectratio; + float angleturn; - angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply; + HWR_GetTexture(texturetranslation[skytexture]); + aspectratio = (float)vid.width/(float)vid.height; - if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa - { - angle = InvAngle(angle); - v[3].tow = v[2].tow += ((float) angle / angleturn); - v[0].tow = v[1].tow += ((float) angle / angleturn); - } - else - { - v[3].tow = v[2].tow -= ((float) angle / angleturn); - v[0].tow = v[1].tow -= ((float) angle / angleturn); - } + //Hurdler: the sky is the only texture who need 4.0f instead of 1.0 + // because it's called just after clearing the screen + // and thus, the near clipping plane is set to 3.99 + // Sryder: Just use the near clipping plane value then - HWD.pfnDrawPolygon(NULL, v, 4, 0); + // 3--2 + // | /| + // |/ | + // 0--1 + v[0].x = v[3].x = -ZCLIP_PLANE-1; + v[1].x = v[2].x = ZCLIP_PLANE+1; + v[0].y = v[1].y = -ZCLIP_PLANE-1; + v[2].y = v[3].y = ZCLIP_PLANE+1; + + v[0].z = v[1].z = v[2].z = v[3].z = ZCLIP_PLANE+1; + + // X + + // NOTE: This doesn't work right with texture widths greater than 1024 + // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly + // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture + + angle = (dup_viewangle + gr_xtoviewangle[0]); + + dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->width/256.0f); + + v[0].sow = v[3].sow = (-1.0f * angle) / ((ANGLE_90-1)*dimensionmultiply); // left + v[2].sow = v[1].sow = v[0].sow + (1.0f/dimensionmultiply); // right (or left + 1.0f) + // use +angle and -1.0f above instead if you wanted old backwards behavior + + // Y + angle = aimingangle; + dimensionmultiply = ((float)textures[texturetranslation[skytexture]]->height/(128.0f*aspectratio)); + + if (splitscreen) + { + dimensionmultiply *= 2; + angle *= 2; + } + + // Middle of the sky should always be at angle 0 + // need to keep correct aspect ratio with X + if (atransform.flip) + { + // During vertical flip the sky should be flipped and it's y movement should also be flipped obviously + v[3].tow = v[2].tow = -(0.5f-(0.5f/dimensionmultiply)); // top + v[0].tow = v[1].tow = v[3].tow - (1.0f/dimensionmultiply); // bottom (or top - 1.0f) + } + else + { + v[0].tow = v[1].tow = -(0.5f-(0.5f/dimensionmultiply)); // bottom + v[3].tow = v[2].tow = v[0].tow - (1.0f/dimensionmultiply); // top (or bottom - 1.0f) + } + + angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply; + + if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa + { + angle = InvAngle(angle); + v[3].tow = v[2].tow += ((float) angle / angleturn); + v[0].tow = v[1].tow += ((float) angle / angleturn); + } + else + { + v[3].tow = v[2].tow -= ((float) angle / angleturn); + v[0].tow = v[1].tow -= ((float) angle / angleturn); + } + + HWD.pfnDrawPolygon(NULL, v, 4, 0); + } } @@ -5794,7 +5968,7 @@ void HWR_SetViewSize(void) // ========================================================================== void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) { - const float fpov = FIXED_TO_FLOAT(cv_grfov.value+player->fovadd); + const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); postimg_t *type; if (splitscreen && player == &players[secondarydisplayplayer]) @@ -5846,6 +6020,8 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) //04/01/2000: Hurdler: added for T&L // It should replace all other gr_viewxxx when finished + memset(&atransform, 0x00, sizeof(FTransform)); + atransform.anglex = (float)(aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); @@ -5862,6 +6038,12 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + atransform.rollangle = FIXED_TO_FLOAT(rol); + atransform.roll = true; + } atransform.splitscreen = splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -5878,7 +6060,7 @@ if (0) } if (drawsky) - HWR_DrawSkyBackground(); + HWR_DrawSkyBackground(player); //Hurdler: it doesn't work in splitscreen mode drawsky = splitscreen; @@ -5918,7 +6100,7 @@ if (0) viewangle = localaiming2; // Handle stuff when you are looking farther up or down. - if ((aimingangle || cv_grfov.value+player->fovadd > 90*FRACUNIT)) + if ((aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) { dup_viewangle += ANGLE_90; HWR_ClearClipSegs(); @@ -5996,7 +6178,7 @@ if (0) // ========================================================================== void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) { - const float fpov = FIXED_TO_FLOAT(cv_grfov.value+player->fovadd); + const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); postimg_t *type; const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on @@ -6031,7 +6213,8 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) } // note: sets viewangle, viewx, viewy, viewz - R_SetupFrame(player, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here + R_SetupFrame(player); + framecount++; // timedemo // copy view cam position for local use dup_viewx = viewx; @@ -6063,6 +6246,8 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) //04/01/2000: Hurdler: added for T&L // It should replace all other gr_viewxxx when finished + memset(&atransform, 0x00, sizeof(FTransform)); + atransform.anglex = (float)(aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); @@ -6079,6 +6264,12 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) atransform.scalez = 1; atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails + if (player->viewrollangle != 0) + { + fixed_t rol = AngleFixed(player->viewrollangle); + atransform.rollangle = FIXED_TO_FLOAT(rol); + atransform.roll = true; + } atransform.splitscreen = splitscreen; gr_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -6095,7 +6286,7 @@ if (0) } if (!skybox && drawsky) // Don't draw the regular sky if there's a skybox - HWR_DrawSkyBackground(); + HWR_DrawSkyBackground(player); //Hurdler: it doesn't work in splitscreen mode drawsky = splitscreen; @@ -6135,7 +6326,7 @@ if (0) viewangle = localaiming2; // Handle stuff when you are looking farther up or down. - if ((aimingangle || cv_grfov.value+player->fovadd > 90*FRACUNIT)) + if ((aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) { dup_viewangle += ANGLE_90; HWR_ClearClipSegs(); @@ -6257,59 +6448,123 @@ static void HWR_FoggingOn(void) // 3D ENGINE COMMANDS // ========================================================================== +static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "LightPlanes"}, {0, NULL}}; +static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}}; -static void CV_grFov_OnChange(void) +static void CV_grmodellighting_OnChange(void); +static void CV_grfiltermode_OnChange(void); +static void CV_granisotropic_OnChange(void); +static void CV_grfogdensity_OnChange(void); + +static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"}, + {HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"}, + {HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"}, + {HWD_SET_TEXTUREFILTER_MIXED2, "Nearest_Linear"}, + {HWD_SET_TEXTUREFILTER_MIXED3, "Nearest_Mipmap"}, + {0, NULL}}; +CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}}; + +consvar_t cv_fovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfog = {"gr_fog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfogcolor = {"gr_fogcolor", "AAAAAA", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grsoftwarefog = {"gr_softwarefog", "Off", CV_SAVE, grsoftwarefog_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +#ifdef ALAM_LIGHTING +consvar_t cv_grdynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE|CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL}; +#endif + +consvar_t cv_grmodels = {"gr_models", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grmodelinterpolation = {"gr_modelinterpolation", "Sometimes", CV_SAVE, grmodelinterpolation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grmodellighting = {"gr_modellighting", "Off", CV_SAVE|CV_CALL, CV_OnOff, CV_grmodellighting_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfakecontrast = {"gr_fakecontrast", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfogdensity = {"gr_fogdensity", "150", CV_CALL|CV_NOINIT, CV_Unsigned, + CV_grfogdensity_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grfiltermode = {"gr_filtermode", "Nearest", CV_SAVE|CV_CALL, grfiltermode_cons_t, + CV_grfiltermode_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_granisotropicmode = {"gr_anisotropicmode", "1", CV_CALL, granisotropicmode_cons_t, + CV_granisotropic_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_grcorrecttricks = {"gr_correcttricks", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grsolvetjoin = {"gr_solvetjoin", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static void CV_grmodellighting_OnChange(void) { - if ((netgame || multiplayer) && !cv_debug && cv_grfov.value != 90*FRACUNIT) - CV_Set(&cv_grfov, cv_grfov.defaultvalue); + if (rendermode == render_opengl) + HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value); } -static void Command_GrStats_f(void) +static void CV_grfogdensity_OnChange(void) { - Z_CheckHeap(9875); // debug - - CONS_Printf(M_GetText("Patch info headers: %7s kb\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); - CONS_Printf(M_GetText("3D Texture cache : %7s kb\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); - CONS_Printf(M_GetText("Plane polygon : %7s kb\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); + if (rendermode == render_opengl) + HWD.pfnSetSpecialState(HWD_SET_FOG_DENSITY, cv_grfogdensity.value); } +static void CV_grfiltermode_OnChange(void) +{ + if (rendermode == render_opengl) + HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value); +} -// ************************************************************************** -// 3D ENGINE SETUP -// ************************************************************************** +static void CV_granisotropic_OnChange(void) +{ + if (rendermode == render_opengl) + HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value); +} -// -------------------------------------------------------------------------- -// Add hardware engine commands & consvars -// -------------------------------------------------------------------------- //added by Hurdler: console varibale that are saved void HWR_AddCommands(void) { - CV_RegisterVar(&cv_grrounddown); - CV_RegisterVar(&cv_grfov); + CV_RegisterVar(&cv_fovchange); + CV_RegisterVar(&cv_grfogdensity); + CV_RegisterVar(&cv_grfogcolor); + CV_RegisterVar(&cv_grfog); + CV_RegisterVar(&cv_grsoftwarefog); + +#ifdef ALAM_LIGHTING + CV_RegisterVar(&cv_grstaticlighting); + CV_RegisterVar(&cv_grdynamiclighting); + CV_RegisterVar(&cv_grcoronasize); + CV_RegisterVar(&cv_grcoronas); +#endif + + CV_RegisterVar(&cv_grmodellighting); + CV_RegisterVar(&cv_grmodelinterpolation); + CV_RegisterVar(&cv_grmodels); + + CV_RegisterVar(&cv_grskydome); + CV_RegisterVar(&cv_grspritebillboarding); + CV_RegisterVar(&cv_grfakecontrast); + CV_RegisterVar(&cv_grfiltermode); - CV_RegisterVar(&cv_granisotropicmode); + CV_RegisterVar(&cv_grrounddown); CV_RegisterVar(&cv_grcorrecttricks); CV_RegisterVar(&cv_grsolvetjoin); -} -static inline void HWR_AddEngineCommands(void) -{ - // engine state variables - //CV_RegisterVar(&cv_grzbuffer); #ifndef NEWCLIP CV_RegisterVar(&cv_grclipwalls); #endif - - // engine development mode variables - // - usage may vary from version to version.. - CV_RegisterVar(&cv_gralpha); - CV_RegisterVar(&cv_grbeta); - - // engine commands - COM_AddCommand("gr_stats", Command_GrStats_f); } +void HWR_AddSessionCommands(void) +{ + static boolean alreadycalled = false; + if (alreadycalled) + return; + + CV_RegisterVar(&cv_granisotropicmode); + + alreadycalled = true; +} // -------------------------------------------------------------------------- // Setup the hardware renderer @@ -6328,30 +6583,33 @@ void HWR_Startup(void) // do this once if (!startupdone) { - CONS_Printf("HWR_Startup()\n"); + CONS_Printf("HWR_Startup()...\n"); HWR_InitPolyPool(); - // add console cmds & vars - HWR_AddEngineCommands(); + HWR_AddSessionCommands(); HWR_InitTextureCache(); - - HWR_InitMD2(); - + HWR_InitModels(); #ifdef ALAM_LIGHTING HWR_InitLight(); #endif } if (rendermode == render_opengl) - textureformat = patchformat = -#ifdef _NDS - GR_TEXFMT_P_8; -#else - GR_RGBA; -#endif + textureformat = patchformat = GR_RGBA; startupdone = true; } +// -------------------------------------------------------------------------- +// Called after switching to the hardware renderer +// -------------------------------------------------------------------------- +void HWR_Switch(void) +{ + // Set special states from CVARs + HWD.pfnSetSpecialState(HWD_SET_MODEL_LIGHTING, cv_grmodellighting.value); + HWD.pfnSetSpecialState(HWD_SET_FOG_DENSITY, cv_grfogdensity.value); + HWD.pfnSetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_grfiltermode.value); + HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value); +} // -------------------------------------------------------------------------- // Free resources allocated by the hardware renderer @@ -6361,6 +6619,7 @@ void HWR_Shutdown(void) CONS_Printf("HWR_Shutdown()\n"); HWR_FreeExtraSubsectors(); HWR_FreePolyPool(); + HWR_FreeMipmapCache(); HWR_FreeTextureCache(); HWD.pfnFlushScreenTextures(); } @@ -6390,10 +6649,11 @@ void transform(float *cx, float *cy, float *cz) //Hurdler: 3D Water stuff +#ifndef SORTING + #define MAX_3DWATER 512 -#ifndef SORTING -static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, +static void HWR_Add3DWater(levelflat_t *levelflat, extrasubsector_t *xsub, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector) { static size_t allocedplanes = 0; @@ -6409,17 +6669,15 @@ static void HWR_Add3DWater(lumpnum_t lumpnum, extrasubsector_t *xsub, } planeinfo[numfloors].fixedheight = fixedheight; planeinfo[numfloors].lightlevel = lightlevel; - planeinfo[numfloors].lumpnum = lumpnum; + planeinfo[numfloors].levelflat = levelflat; planeinfo[numfloors].xsub = xsub; planeinfo[numfloors].alpha = alpha; planeinfo[numfloors].FOFSector = FOFSector; numfloors++; } -#endif #define DIST_PLANE(i) ABS(planeinfo[(i)].fixedheight-dup_viewz) -#if 0 static void HWR_QuickSortPlane(INT32 start, INT32 finish) { INT32 left = start; @@ -6449,9 +6707,7 @@ static void HWR_QuickSortPlane(INT32 start, INT32 finish) if (start < right) HWR_QuickSortPlane(start, right); if (left < finish) HWR_QuickSortPlane(left, finish); } -#endif -#ifndef SORTING static void HWR_Render3DWater(void) { size_t i; @@ -6482,8 +6738,8 @@ static void HWR_Render3DWater(void) gr_frontsector = NULL; //Hurdler: gr_fronsector is no longer valid for (i = 0; i < numfloors; i++) { - HWR_GetFlat(planeinfo[i].lumpnum); - HWR_RenderPlane(NULL, planeinfo[i].xsub, planeinfo[i].isceiling, planeinfo[i].fixedheight, PF_Translucent, planeinfo[i].lightlevel, planeinfo[i].lumpnum, + HWR_GetLevelFlat(planeinfo[i].levelflat); + HWR_RenderPlane(NULL, planeinfo[i].xsub, planeinfo[i].isceiling, planeinfo[i].fixedheight, PF_Translucent, planeinfo[i].lightlevel, planeinfo[i].levelflat, planeinfo[i].FOFSector, planeinfo[i].alpha, planeinfo[i].fogplane, planeinfo[i].planecolormap); } numfloors = 0; @@ -6516,6 +6772,7 @@ static void HWR_AddTransparentWall(wallVert3D *wallVerts, FSurfaceInfo *pSurf, I wallinfo[numwalls].wallcolormap = wallcolormap; numwalls++; } + #ifndef SORTING static void HWR_RenderTransparentWalls(void) { @@ -6548,6 +6805,7 @@ static void HWR_RenderTransparentWalls(void) numwalls = 0; } #endif + static void HWR_RenderWall(wallVert3D *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) { FOutVector trVerts[4]; @@ -6606,11 +6864,6 @@ static void HWR_RenderWall(wallVert3D *wallVerts, FSurfaceInfo *pSurf, FBITFIE #endif } -void HWR_SetPaletteColor(INT32 palcolor) -{ - HWD.pfnSetSpecialState(HWD_SET_PALETTECOLOR, palcolor); -} - INT32 HWR_GetTextureUsed(void) { return HWD.pfnGetTextureUsed(); @@ -6657,7 +6910,6 @@ void HWR_DoPostProcessor(player_t *player) if (splitscreen) // Not supported in splitscreen - someone want to add support? return; -#ifdef SHUFFLE // Drunken vision! WooOOooo~ if (*type == postimg_water || *type == postimg_heat) { @@ -6700,7 +6952,6 @@ void HWR_DoPostProcessor(player_t *player) HWD.pfnMakeScreenTexture(); } // Flipping of the screen isn't done here anymore -#endif // SHUFFLE } void HWR_StartScreenWipe(void) @@ -6711,7 +6962,6 @@ void HWR_StartScreenWipe(void) void HWR_EndScreenWipe(void) { - HWRWipeCounter = 0.0f; //CONS_Debug(DBG_RENDER, "In HWR_EndScreenWipe()\n"); HWD.pfnEndScreenWipe(); } @@ -6721,38 +6971,55 @@ void HWR_DrawIntermissionBG(void) HWD.pfnDrawIntermissionBG(); } -void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) +// +// hwr mode wipes +// +static lumpnum_t wipelumpnum; + +// puts wipe lumpname in wipename[9] +static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum) { static char lumpname[9] = "FADEmmss"; - lumpnum_t lumpnum; size_t lsize; - if (wipenum > 99 || scrnnum > 99) // not a valid wipe number - return; // shouldn't end up here really, the loop should've stopped running beforehand + // not a valid wipe number + if (wipenum > 99 || scrnnum > 99) + return false; // shouldn't end up here really, the loop should've stopped running beforehand - // puts the numbers into the lumpname - sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipenum, (UINT16)scrnnum); - lumpnum = W_CheckNumForName(lumpname); + // puts the numbers into the wipename + lumpname[4] = '0'+(wipenum/10); + lumpname[5] = '0'+(wipenum%10); + lumpname[6] = '0'+(scrnnum/10); + lumpname[7] = '0'+(scrnnum%10); + wipelumpnum = W_CheckNumForName(lumpname); - if (lumpnum == LUMPERROR) // again, shouldn't be here really - return; - - lsize = W_LumpLength(lumpnum); + // again, shouldn't be here really + if (wipelumpnum == LUMPERROR) + return false; + lsize = W_LumpLength(wipelumpnum); if (!(lsize == 256000 || lsize == 64000 || lsize == 16000 || lsize == 4000)) { CONS_Alert(CONS_WARNING, "Fade mask lump %s of incorrect size, ignored\n", lumpname); - return; // again, shouldn't get here if it is a bad size + return false; // again, shouldn't get here if it is a bad size } - HWR_GetFadeMask(lumpnum); + return true; +} - HWD.pfnDoScreenWipe(HWRWipeCounter); // Still send in wipecounter since old stuff might not support multitexturing +void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) +{ + if (!HWR_WipeCheck(wipenum, scrnnum)) + return; - HWRWipeCounter += 0.05f; // increase opacity of end screen + HWR_GetFadeMask(wipelumpnum); + HWD.pfnDoScreenWipe(); +} - if (HWRWipeCounter > 1.0f) - HWRWipeCounter = 1.0f; +void HWR_DoTintedWipe(UINT8 wipenum, UINT8 scrnnum) +{ + // It does the same thing + HWR_DoWipe(wipenum, scrnnum); } void HWR_MakeScreenFinalTexture(void) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 59042cf3b..ec5362194 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -29,42 +29,46 @@ // Startup & Shutdown the hardware mode renderer void HWR_Startup(void); +void HWR_Switch(void); void HWR_Shutdown(void); void HWR_drawAMline(const fline_t *fl, INT32 color); -void HWR_FadeScreenMenuBack(UINT32 color, INT32 height); +void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength); void HWR_DrawConsoleBack(UINT32 color, INT32 height); +void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight); void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player); void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); -UINT8 *HWR_GetScreenshot(void); -boolean HWR_Screenshot(const char *lbmname); void HWR_InitTextureMapping(void); void HWR_SetViewSize(void); void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option); -void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, const UINT8 *colormap); +void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t scale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); -void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, INT32 option, fixed_t scale, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); -void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); +void HWR_MakePatch(const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipmap, boolean makebitmap); void HWR_CreatePlanePolygons(INT32 bspnum); void HWR_CreateStaticLightmaps(INT32 bspnum); -void HWR_PrepLevelCache(size_t pnumtextures); +void HWR_LoadTextures(size_t pnumtextures); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); -void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right. +void HWR_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT16 actualcolor, UINT8 strength); +void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color, UINT32 actualcolor); // Lat: separate flags from color since color needs to be an uint to work right. void HWR_DrawPic(INT32 x,INT32 y,lumpnum_t lumpnum); +UINT8 *HWR_GetScreenshot(void); +boolean HWR_Screenshot(const char *pathname); + void HWR_AddCommands(void); +void HWR_AddSessionCommands(void); void HWR_CorrectSWTricks(void); void transform(float *cx, float *cy, float *cz); FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); -void HWR_SetPaletteColor(INT32 palcolor); INT32 HWR_GetTextureUsed(void); void HWR_DoPostProcessor(player_t *player); void HWR_StartScreenWipe(void); void HWR_EndScreenWipe(void); void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); +void HWR_DoTintedWipe(UINT8 wipenum, UINT8 scrnnum); void HWR_MakeScreenFinalTexture(void); void HWR_DrawScreenFinalTexture(int width, int height); @@ -80,21 +84,21 @@ extern consvar_t cv_grstaticlighting; extern consvar_t cv_grcoronas; extern consvar_t cv_grcoronasize; #endif -extern consvar_t cv_grfov; -extern consvar_t cv_grmd2; +extern consvar_t cv_grmodels; +extern consvar_t cv_grmodelinterpolation; +extern consvar_t cv_grmodellighting; extern consvar_t cv_grfog; extern consvar_t cv_grfogcolor; extern consvar_t cv_grfogdensity; extern consvar_t cv_grsoftwarefog; -extern consvar_t cv_grgammared; -extern consvar_t cv_grgammagreen; -extern consvar_t cv_grgammablue; extern consvar_t cv_grfiltermode; extern consvar_t cv_granisotropicmode; extern consvar_t cv_grcorrecttricks; -extern consvar_t cv_voodoocompatibility; -extern consvar_t cv_grfovchange; +extern consvar_t cv_fovchange; extern consvar_t cv_grsolvetjoin; +extern consvar_t cv_grspritebillboarding; +extern consvar_t cv_grskydome; +extern consvar_t cv_grfakecontrast; extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy; @@ -104,13 +108,4 @@ extern float gr_viewwindowx, gr_basewindowcentery; extern fixed_t *hwbbox; extern FTransform atransform; -typedef struct -{ - wallVert3D floorVerts[4]; - FSurfaceInfo Surf; - INT32 texnum; - INT32 blend; - INT32 drawcount; -} floorinfo_t; - #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index cb33562d8..5c3cd40a6 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -26,8 +26,10 @@ #include #include +#include "../d_main.h" #include "../doomdef.h" #include "../doomstat.h" +#include "../fastcmp.h" #ifdef HWRENDER #include "hw_drv.h" @@ -40,6 +42,9 @@ #include "../w_wad.h" #include "../z_zone.h" #include "../r_things.h" +#include "../r_draw.h" +#include "../p_tick.h" +#include "hw_model.h" #include "hw_main.h" #include "../v_video.h" @@ -72,172 +77,6 @@ #include "errno.h" #endif -#define NUMVERTEXNORMALS 162 -float avertexnormals[NUMVERTEXNORMALS][3] = { -{-0.525731f, 0.000000f, 0.850651f}, -{-0.442863f, 0.238856f, 0.864188f}, -{-0.295242f, 0.000000f, 0.955423f}, -{-0.309017f, 0.500000f, 0.809017f}, -{-0.162460f, 0.262866f, 0.951056f}, -{0.000000f, 0.000000f, 1.000000f}, -{0.000000f, 0.850651f, 0.525731f}, -{-0.147621f, 0.716567f, 0.681718f}, -{0.147621f, 0.716567f, 0.681718f}, -{0.000000f, 0.525731f, 0.850651f}, -{0.309017f, 0.500000f, 0.809017f}, -{0.525731f, 0.000000f, 0.850651f}, -{0.295242f, 0.000000f, 0.955423f}, -{0.442863f, 0.238856f, 0.864188f}, -{0.162460f, 0.262866f, 0.951056f}, -{-0.681718f, 0.147621f, 0.716567f}, -{-0.809017f, 0.309017f, 0.500000f}, -{-0.587785f, 0.425325f, 0.688191f}, -{-0.850651f, 0.525731f, 0.000000f}, -{-0.864188f, 0.442863f, 0.238856f}, -{-0.716567f, 0.681718f, 0.147621f}, -{-0.688191f, 0.587785f, 0.425325f}, -{-0.500000f, 0.809017f, 0.309017f}, -{-0.238856f, 0.864188f, 0.442863f}, -{-0.425325f, 0.688191f, 0.587785f}, -{-0.716567f, 0.681718f, -0.147621f}, -{-0.500000f, 0.809017f, -0.309017f}, -{-0.525731f, 0.850651f, 0.000000f}, -{0.000000f, 0.850651f, -0.525731f}, -{-0.238856f, 0.864188f, -0.442863f}, -{0.000000f, 0.955423f, -0.295242f}, -{-0.262866f, 0.951056f, -0.162460f}, -{0.000000f, 1.000000f, 0.000000f}, -{0.000000f, 0.955423f, 0.295242f}, -{-0.262866f, 0.951056f, 0.162460f}, -{0.238856f, 0.864188f, 0.442863f}, -{0.262866f, 0.951056f, 0.162460f}, -{0.500000f, 0.809017f, 0.309017f}, -{0.238856f, 0.864188f, -0.442863f}, -{0.262866f, 0.951056f, -0.162460f}, -{0.500000f, 0.809017f, -0.309017f}, -{0.850651f, 0.525731f, 0.000000f}, -{0.716567f, 0.681718f, 0.147621f}, -{0.716567f, 0.681718f, -0.147621f}, -{0.525731f, 0.850651f, 0.000000f}, -{0.425325f, 0.688191f, 0.587785f}, -{0.864188f, 0.442863f, 0.238856f}, -{0.688191f, 0.587785f, 0.425325f}, -{0.809017f, 0.309017f, 0.500000f}, -{0.681718f, 0.147621f, 0.716567f}, -{0.587785f, 0.425325f, 0.688191f}, -{0.955423f, 0.295242f, 0.000000f}, -{1.000000f, 0.000000f, 0.000000f}, -{0.951056f, 0.162460f, 0.262866f}, -{0.850651f, -0.525731f, 0.000000f}, -{0.955423f, -0.295242f, 0.000000f}, -{0.864188f, -0.442863f, 0.238856f}, -{0.951056f, -0.162460f, 0.262866f}, -{0.809017f, -0.309017f, 0.500000f}, -{0.681718f, -0.147621f, 0.716567f}, -{0.850651f, 0.000000f, 0.525731f}, -{0.864188f, 0.442863f, -0.238856f}, -{0.809017f, 0.309017f, -0.500000f}, -{0.951056f, 0.162460f, -0.262866f}, -{0.525731f, 0.000000f, -0.850651f}, -{0.681718f, 0.147621f, -0.716567f}, -{0.681718f, -0.147621f, -0.716567f}, -{0.850651f, 0.000000f, -0.525731f}, -{0.809017f, -0.309017f, -0.500000f}, -{0.864188f, -0.442863f, -0.238856f}, -{0.951056f, -0.162460f, -0.262866f}, -{0.147621f, 0.716567f, -0.681718f}, -{0.309017f, 0.500000f, -0.809017f}, -{0.425325f, 0.688191f, -0.587785f}, -{0.442863f, 0.238856f, -0.864188f}, -{0.587785f, 0.425325f, -0.688191f}, -{0.688191f, 0.587785f, -0.425325f}, -{-0.147621f, 0.716567f, -0.681718f}, -{-0.309017f, 0.500000f, -0.809017f}, -{0.000000f, 0.525731f, -0.850651f}, -{-0.525731f, 0.000000f, -0.850651f}, -{-0.442863f, 0.238856f, -0.864188f}, -{-0.295242f, 0.000000f, -0.955423f}, -{-0.162460f, 0.262866f, -0.951056f}, -{0.000000f, 0.000000f, -1.000000f}, -{0.295242f, 0.000000f, -0.955423f}, -{0.162460f, 0.262866f, -0.951056f}, -{-0.442863f, -0.238856f, -0.864188f}, -{-0.309017f, -0.500000f, -0.809017f}, -{-0.162460f, -0.262866f, -0.951056f}, -{0.000000f, -0.850651f, -0.525731f}, -{-0.147621f, -0.716567f, -0.681718f}, -{0.147621f, -0.716567f, -0.681718f}, -{0.000000f, -0.525731f, -0.850651f}, -{0.309017f, -0.500000f, -0.809017f}, -{0.442863f, -0.238856f, -0.864188f}, -{0.162460f, -0.262866f, -0.951056f}, -{0.238856f, -0.864188f, -0.442863f}, -{0.500000f, -0.809017f, -0.309017f}, -{0.425325f, -0.688191f, -0.587785f}, -{0.716567f, -0.681718f, -0.147621f}, -{0.688191f, -0.587785f, -0.425325f}, -{0.587785f, -0.425325f, -0.688191f}, -{0.000000f, -0.955423f, -0.295242f}, -{0.000000f, -1.000000f, 0.000000f}, -{0.262866f, -0.951056f, -0.162460f}, -{0.000000f, -0.850651f, 0.525731f}, -{0.000000f, -0.955423f, 0.295242f}, -{0.238856f, -0.864188f, 0.442863f}, -{0.262866f, -0.951056f, 0.162460f}, -{0.500000f, -0.809017f, 0.309017f}, -{0.716567f, -0.681718f, 0.147621f}, -{0.525731f, -0.850651f, 0.000000f}, -{-0.238856f, -0.864188f, -0.442863f}, -{-0.500000f, -0.809017f, -0.309017f}, -{-0.262866f, -0.951056f, -0.162460f}, -{-0.850651f, -0.525731f, 0.000000f}, -{-0.716567f, -0.681718f, -0.147621f}, -{-0.716567f, -0.681718f, 0.147621f}, -{-0.525731f, -0.850651f, 0.000000f}, -{-0.500000f, -0.809017f, 0.309017f}, -{-0.238856f, -0.864188f, 0.442863f}, -{-0.262866f, -0.951056f, 0.162460f}, -{-0.864188f, -0.442863f, 0.238856f}, -{-0.809017f, -0.309017f, 0.500000f}, -{-0.688191f, -0.587785f, 0.425325f}, -{-0.681718f, -0.147621f, 0.716567f}, -{-0.442863f, -0.238856f, 0.864188f}, -{-0.587785f, -0.425325f, 0.688191f}, -{-0.309017f, -0.500000f, 0.809017f}, -{-0.147621f, -0.716567f, 0.681718f}, -{-0.425325f, -0.688191f, 0.587785f}, -{-0.162460f, -0.262866f, 0.951056f}, -{0.442863f, -0.238856f, 0.864188f}, -{0.162460f, -0.262866f, 0.951056f}, -{0.309017f, -0.500000f, 0.809017f}, -{0.147621f, -0.716567f, 0.681718f}, -{0.000000f, -0.525731f, 0.850651f}, -{0.425325f, -0.688191f, 0.587785f}, -{0.587785f, -0.425325f, 0.688191f}, -{0.688191f, -0.587785f, 0.425325f}, -{-0.955423f, 0.295242f, 0.000000f}, -{-0.951056f, 0.162460f, 0.262866f}, -{-1.000000f, 0.000000f, 0.000000f}, -{-0.850651f, 0.000000f, 0.525731f}, -{-0.955423f, -0.295242f, 0.000000f}, -{-0.951056f, -0.162460f, 0.262866f}, -{-0.864188f, 0.442863f, -0.238856f}, -{-0.951056f, 0.162460f, -0.262866f}, -{-0.809017f, 0.309017f, -0.500000f}, -{-0.864188f, -0.442863f, -0.238856f}, -{-0.951056f, -0.162460f, -0.262866f}, -{-0.809017f, -0.309017f, -0.500000f}, -{-0.681718f, 0.147621f, -0.716567f}, -{-0.681718f, -0.147621f, -0.716567f}, -{-0.850651f, 0.000000f, -0.525731f}, -{-0.688191f, 0.587785f, -0.425325f}, -{-0.587785f, 0.425325f, -0.688191f}, -{-0.425325f, 0.688191f, -0.587785f}, -{-0.425325f, -0.688191f, -0.587785f}, -{-0.587785f, -0.425325f, -0.688191f}, -{-0.688191f, -0.587785f, -0.425325f}, -}; - md2_t md2_models[NUMSPRITES]; md2_t md2_playermodels[MAXSKINS]; @@ -245,194 +84,25 @@ md2_t md2_playermodels[MAXSKINS]; /* * free model */ -static void md2_freeModel (md2_model_t *model) +#if 0 +static void md2_freeModel (model_t *model) { - if (model) - { - if (model->skins) - free(model->skins); - - if (model->texCoords) - free(model->texCoords); - - if (model->triangles) - free(model->triangles); - - if (model->frames) - { - size_t i; - - for (i = 0; i < model->header.numFrames; i++) - { - if (model->frames[i].vertices) - free(model->frames[i].vertices); - } - free(model->frames); - } - - if (model->glCommandBuffer) - free(model->glCommandBuffer); - - free(model); - } + UnloadModel(model); } +#endif // // load model // // Hurdler: the current path is the Legacy.exe path -static md2_model_t *md2_readModel(const char *filename) +static model_t *md2_readModel(const char *filename) { - FILE *file; - md2_model_t *model; - UINT8 buffer[MD2_MAX_FRAMESIZE]; - size_t i; - - model = calloc(1, sizeof (*model)); - if (model == NULL) - return 0; - //Filename checking fixed ~Monster Iestyn and Golden - file = fopen(va("%s"PATHSEP"%s", srb2home, filename), "rb"); - if (!file) - { - free(model); - return 0; - } - - // initialize model and read header - - if (fread(&model->header, sizeof (model->header), 1, file) != 1 - || model->header.magic != MD2_IDENT - || model->header.version != MD2_VERSION) - { - fclose(file); - free(model); - return 0; - } - - model->header.numSkins = 1; - -#define MD2LIMITCHECK(field, max, msgname) \ - if (field > max) \ - { \ - CONS_Alert(CONS_ERROR, "md2_readModel: %s has too many " msgname " (# found: %d, maximum: %d)\n", filename, field, max); \ - md2_freeModel (model); \ - fclose(file); \ - return 0; \ - } - - // Uncomment if these are actually needed -// MD2LIMITCHECK(model->header.numSkins, MD2_MAX_SKINS, "skins") -// MD2LIMITCHECK(model->header.numTexCoords, MD2_MAX_TEXCOORDS, "texture coordinates") - MD2LIMITCHECK(model->header.numTriangles, MD2_MAX_TRIANGLES, "triangles") - MD2LIMITCHECK(model->header.numFrames, MD2_MAX_FRAMES, "frames") - MD2LIMITCHECK(model->header.numVertices, MD2_MAX_VERTICES, "vertices") - -#undef MD2LIMITCHECK - - // read skins - fseek(file, model->header.offsetSkins, SEEK_SET); - if (model->header.numSkins > 0) - { - model->skins = calloc(sizeof (md2_skin_t), model->header.numSkins); - if (!model->skins || model->header.numSkins != - fread(model->skins, sizeof (md2_skin_t), model->header.numSkins, file)) - { - md2_freeModel (model); - fclose(file); - return 0; - } - } - - // read texture coordinates - fseek(file, model->header.offsetTexCoords, SEEK_SET); - if (model->header.numTexCoords > 0) - { - model->texCoords = calloc(sizeof (md2_textureCoordinate_t), model->header.numTexCoords); - if (!model->texCoords || model->header.numTexCoords != - fread(model->texCoords, sizeof (md2_textureCoordinate_t), model->header.numTexCoords, file)) - { - md2_freeModel (model); - fclose(file); - return 0; - } - } - - // read triangles - fseek(file, model->header.offsetTriangles, SEEK_SET); - if (model->header.numTriangles > 0) - { - model->triangles = calloc(sizeof (md2_triangle_t), model->header.numTriangles); - if (!model->triangles || model->header.numTriangles != - fread(model->triangles, sizeof (md2_triangle_t), model->header.numTriangles, file)) - { - md2_freeModel (model); - fclose(file); - return 0; - } - } - - // read alias frames - fseek(file, model->header.offsetFrames, SEEK_SET); - if (model->header.numFrames > 0) - { - model->frames = calloc(sizeof (md2_frame_t), model->header.numFrames); - if (!model->frames) - { - md2_freeModel (model); - fclose(file); - return 0; - } - - for (i = 0; i < model->header.numFrames; i++) - { - md2_alias_frame_t *frame = (md2_alias_frame_t *)(void *)buffer; - size_t j; - - model->frames[i].vertices = calloc(sizeof (md2_triangleVertex_t), model->header.numVertices); - if (!model->frames[i].vertices || model->header.frameSize != - fread(frame, 1, model->header.frameSize, file)) - { - md2_freeModel (model); - fclose(file); - return 0; - } - - strcpy(model->frames[i].name, frame->name); - for (j = 0; j < model->header.numVertices; j++) - { - model->frames[i].vertices[j].vertex[0] = (float) ((INT32) frame->alias_vertices[j].vertex[0]) * frame->scale[0] + frame->translate[0]; - model->frames[i].vertices[j].vertex[2] = -1* ((float) ((INT32) frame->alias_vertices[j].vertex[1]) * frame->scale[1] + frame->translate[1]); - model->frames[i].vertices[j].vertex[1] = (float) ((INT32) frame->alias_vertices[j].vertex[2]) * frame->scale[2] + frame->translate[2]; - model->frames[i].vertices[j].normal[0] = avertexnormals[frame->alias_vertices[j].lightNormalIndex][0]; - model->frames[i].vertices[j].normal[1] = avertexnormals[frame->alias_vertices[j].lightNormalIndex][1]; - model->frames[i].vertices[j].normal[2] = avertexnormals[frame->alias_vertices[j].lightNormalIndex][2]; - } - } - } - - // read gl commands - fseek(file, model->header.offsetGlCommands, SEEK_SET); - if (model->header.numGlCommands) - { - model->glCommandBuffer = calloc(sizeof (INT32), model->header.numGlCommands); - if (!model->glCommandBuffer || model->header.numGlCommands != - fread(model->glCommandBuffer, sizeof (INT32), model->header.numGlCommands, file)) - { - md2_freeModel (model); - fclose(file); - return 0; - } - } - - fclose(file); - - return model; + return LoadModel(va("%s"PATHSEP"%s", srb2home, filename), PU_STATIC); } -static inline void md2_printModelInfo (md2_model_t *model) +static inline void md2_printModelInfo (model_t *model) { #if 0 INT32 i; @@ -491,7 +161,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ #endif png_FILE_p png_FILE; //Filename checking fixed ~Monster Iestyn and Golden - char *pngfilename = va("%s"PATHSEP"md2"PATHSEP"%s", srb2home, filename); + char *pngfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2home, filename); FIL_ForceExtension(pngfilename, ".png"); png_FILE = fopen(pngfilename, "rb"); @@ -528,7 +198,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ //CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename); png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); fclose(png_FILE); - Z_Free(grpatch->mipmap.grInfo.data); + Z_Free(grpatch->mipmap->grInfo.data); return 0; } #ifdef USE_FAR_KEYWORD @@ -569,7 +239,7 @@ static GrTextureFormat_t PNG_Load(const char *filename, int *w, int *h, GLPatch_ { png_uint_32 i, pitch = png_get_rowbytes(png_ptr, png_info_ptr); - png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRCACHE, &grpatch->mipmap.grInfo.data); + png_bytep PNG_image = Z_Malloc(pitch*height, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data); png_bytepp row_pointers = png_malloc(png_ptr, height * sizeof (png_bytep)); for (i = 0; i < height; i++) row_pointers[i] = PNG_image + i*pitch; @@ -620,7 +290,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h, INT32 ch, rep; FILE *file; //Filename checking fixed ~Monster Iestyn and Golden - char *pcxfilename = va("%s"PATHSEP"md2"PATHSEP"%s", srb2home, filename); + char *pcxfilename = va("%s"PATHSEP"models"PATHSEP"%s", srb2home, filename); FIL_ForceExtension(pcxfilename, ".pcx"); file = fopen(pcxfilename, "rb"); @@ -643,7 +313,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h, pw = *w = header.xmax - header.xmin + 1; ph = *h = header.ymax - header.ymin + 1; - image = Z_Malloc(pw*ph*4, PU_HWRCACHE, &grpatch->mipmap.grInfo.data); + image = Z_Malloc(pw*ph*4, PU_HWRMODELTEXTURE, &grpatch->mipmap->grInfo.data); if (fread(palette, sizeof (UINT8), PALSIZE, file) != PALSIZE) { @@ -681,7 +351,7 @@ static GrTextureFormat_t PCX_Load(const char *filename, int *w, int *h, } // -----------------+ -// md2_loadTexture : Download a pcx or png texture for MD2 models +// md2_loadTexture : Download a pcx or png texture for models // -----------------+ static void md2_loadTexture(md2_t *model) { @@ -691,38 +361,54 @@ static void md2_loadTexture(md2_t *model) if (model->grpatch) { grpatch = model->grpatch; - Z_Free(grpatch->mipmap.grInfo.data); + Z_Free(grpatch->mipmap->grInfo.data); } else + { grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO, &(model->grpatch)); + grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); + } - if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) { int w = 0, h = 0; + UINT32 size; + RGBA_t *image; + #ifdef HAVE_PNG - grpatch->mipmap.grInfo.format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap.grInfo.format == 0) + grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->grInfo.format == 0) #endif - grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap.grInfo.format == 0) + grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->grInfo.format == 0) return; - grpatch->mipmap.downloaded = 0; - grpatch->mipmap.flags = 0; + grpatch->mipmap->downloaded = 0; + grpatch->mipmap->flags = 0; grpatch->width = (INT16)w; grpatch->height = (INT16)h; - grpatch->mipmap.width = (UINT16)w; - grpatch->mipmap.height = (UINT16)h; + grpatch->mipmap->width = (UINT16)w; + grpatch->mipmap->height = (UINT16)h; + // Lactozilla: Apply colour cube + image = grpatch->mipmap->grInfo.data; + size = w*h; + while (size--) + { + V_CubeApply(&image->s.red, &image->s.green, &image->s.blue); + image++; + } + +#ifdef GLIDE_API_COMPATIBILITY // not correct! - grpatch->mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_256; - grpatch->mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_256; - grpatch->mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; + grpatch->mipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; +#endif } - HWD.pfnSetTexture(&grpatch->mipmap); - HWR_UnlockCachedPatch(grpatch); + HWD.pfnSetTexture(grpatch->mipmap); } // -----------------+ @@ -739,41 +425,45 @@ static void md2_loadBlendTexture(md2_t *model) if (model->blendgrpatch) { grpatch = model->blendgrpatch; - Z_Free(grpatch->mipmap.grInfo.data); + Z_Free(grpatch->mipmap->grInfo.data); } else + { grpatch = Z_Calloc(sizeof *grpatch, PU_HWRPATCHINFO, &(model->blendgrpatch)); + grpatch->mipmap = Z_Calloc(sizeof (GLMipmap_t), PU_HWRPATCHINFO, NULL); + } - if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data) + if (!grpatch->mipmap->downloaded && !grpatch->mipmap->grInfo.data) { int w = 0, h = 0; #ifdef HAVE_PNG - grpatch->mipmap.grInfo.format = PNG_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap.grInfo.format == 0) + grpatch->mipmap->grInfo.format = PNG_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->grInfo.format == 0) #endif - grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); - if (grpatch->mipmap.grInfo.format == 0) + grpatch->mipmap->grInfo.format = PCX_Load(filename, &w, &h, grpatch); + if (grpatch->mipmap->grInfo.format == 0) { Z_Free(filename); return; } - grpatch->mipmap.downloaded = 0; - grpatch->mipmap.flags = 0; + grpatch->mipmap->downloaded = 0; + grpatch->mipmap->flags = 0; grpatch->width = (INT16)w; grpatch->height = (INT16)h; - grpatch->mipmap.width = (UINT16)w; - grpatch->mipmap.height = (UINT16)h; + grpatch->mipmap->width = (UINT16)w; + grpatch->mipmap->height = (UINT16)h; +#ifdef GLIDE_API_COMPATIBILITY // not correct! - grpatch->mipmap.grInfo.smallLodLog2 = GR_LOD_LOG2_256; - grpatch->mipmap.grInfo.largeLodLog2 = GR_LOD_LOG2_256; - grpatch->mipmap.grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; + grpatch->mipmap->grInfo.smallLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap->grInfo.largeLodLog2 = GR_LOD_LOG2_256; + grpatch->mipmap->grInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1; +#endif } - HWD.pfnSetTexture(&grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary - HWR_UnlockCachedPatch(grpatch); + HWD.pfnSetTexture(grpatch->mipmap); // We do need to do this so that it can be cleared and knows to recreate it when necessary Z_Free(filename); } @@ -781,15 +471,16 @@ static void md2_loadBlendTexture(md2_t *model) // Don't spam the console, or the OS with fopen requests! static boolean nomd2s = false; -void HWR_InitMD2(void) +void HWR_InitModels(void) { size_t i; INT32 s; FILE *f; - char name[18], filename[32]; + char name[24], filename[32]; float scale, offset; + size_t prefixlen; - CONS_Printf("InitMD2()...\n"); + CONS_Printf("HWR_InitModels()...\n"); for (s = 0; s < MAXSKINS; s++) { md2_playermodels[s].scale = -1.0f; @@ -809,111 +500,129 @@ void HWR_InitMD2(void) md2_models[i].error = false; } - // read the md2.dat file + // read the models.dat file //Filename checking fixed ~Monster Iestyn and Golden - f = fopen(va("%s"PATHSEP"%s", srb2home, "md2.dat"), "rt"); + f = fopen(va("%s"PATHSEP"%s", srb2home, "models.dat"), "rt"); if (!f) { - CONS_Printf("%s %s\n", M_GetText("Error while loading md2.dat:"), strerror(errno)); + CONS_Printf("%s %s\n", M_GetText("Error while loading models.dat:"), strerror(errno)); nomd2s = true; return; } - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) + + // length of the player model prefix + prefixlen = strlen(PLAYERMODELPREFIX); + + while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4) { - if (stricmp(name, "PLAY") == 0) + char *skinname = name; + size_t len = strlen(name); + + // check for the player model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, prefixlen) && (len > prefixlen)) { - CONS_Printf("MD2 for sprite PLAY detected in md2.dat, use a player skin instead!\n"); - continue; + skinname += prefixlen; + goto addskinmodel; } - for (i = 0; i < NUMSPRITES; i++) + // add sprite model + if (len == 4) // must be 4 characters long exactly. otherwise it's not a sprite name. { - if (stricmp(name, sprnames[i]) == 0) + for (i = 0; i < NUMSPRITES; i++) { - //if (stricmp(name, "PLAY") == 0) - //continue; - - //CONS_Debug(DBG_RENDER, " Found: %s %s %f %f\n", name, filename, scale, offset); - md2_models[i].scale = scale; - md2_models[i].offset = offset; - md2_models[i].notfound = false; - strcpy(md2_models[i].filename, filename); - goto md2found; + if (stricmp(name, sprnames[i]) == 0) + { + md2_models[i].scale = scale; + md2_models[i].offset = offset; + md2_models[i].notfound = false; + strcpy(md2_models[i].filename, filename); + goto modelfound; + } } } +addskinmodel: + // add player model for (s = 0; s < MAXSKINS; s++) { - if (stricmp(name, skins[s].name) == 0) + if (stricmp(skinname, skins[s].name) == 0) { - //CONS_Printf(" Found: %s %s %f %f\n", name, filename, scale, offset); md2_playermodels[s].skin = s; md2_playermodels[s].scale = scale; md2_playermodels[s].offset = offset; md2_playermodels[s].notfound = false; strcpy(md2_playermodels[s].filename, filename); - goto md2found; + goto modelfound; } } - // no sprite/player skin name found?!? - CONS_Printf("Unknown sprite/player skin %s detected in md2.dat\n", name); -md2found: + +modelfound: // move on to next line... continue; } fclose(f); } -void HWR_AddPlayerMD2(int skin) // For MD2's that were added after startup +void HWR_AddPlayerModel(int skin) // For skins that were added after startup { FILE *f; - char name[18], filename[32]; + char name[24], filename[32]; float scale, offset; + size_t prefixlen; if (nomd2s) return; - CONS_Printf("AddPlayerMD2()...\n"); + //CONS_Printf("HWR_AddPlayerModel()...\n"); - // read the md2.dat file + // read the models.dat file //Filename checking fixed ~Monster Iestyn and Golden - f = fopen(va("%s"PATHSEP"%s", srb2home, "md2.dat"), "rt"); + f = fopen(va("%s"PATHSEP"%s", srb2home, "models.dat"), "rt"); if (!f) { - CONS_Printf("Error while loading md2.dat\n"); + CONS_Printf("Error while loading models.dat\n"); nomd2s = true; return; } - // Check for any MD2s that match the names of player skins! - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) + // length of the player model prefix + prefixlen = strlen(PLAYERMODELPREFIX); + + // Check for any models that match the names of player skins! + while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4) { - if (stricmp(name, skins[skin].name) == 0) + char *skinname = name; + size_t len = strlen(name); + + // ignore the player model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, prefixlen) && (len > prefixlen)) + skinname += prefixlen; + + if (stricmp(skinname, skins[skin].name) == 0) { md2_playermodels[skin].skin = skin; md2_playermodels[skin].scale = scale; md2_playermodels[skin].offset = offset; md2_playermodels[skin].notfound = false; strcpy(md2_playermodels[skin].filename, filename); - goto playermd2found; + goto playermodelfound; } } - //CONS_Printf("MD2 for player skin %s not found\n", skins[skin].name); md2_playermodels[skin].notfound = true; -playermd2found: +playermodelfound: fclose(f); } - -void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startup +void HWR_AddSpriteModel(size_t spritenum) // For sprites that were added after startup { FILE *f; - // name[18] is used to check for names in the md2.dat file that match with sprites or player skins + // name[24] is used to check for names in the models.dat file that match with sprites or player skins // sprite names are always 4 characters long, and names is for player skins can be up to 19 characters long - char name[18], filename[32]; + // PLAYERMODELPREFIX is 6 characters long + char name[24], filename[32]; float scale, offset; if (nomd2s) @@ -922,45 +631,68 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu if (spritenum == SPR_PLAY) // Handled already NEWMD2: Per sprite, per-skin check return; - // Read the md2.dat file + // Read the models.dat file //Filename checking fixed ~Monster Iestyn and Golden - f = fopen(va("%s"PATHSEP"%s", srb2home, "md2.dat"), "rt"); + f = fopen(va("%s"PATHSEP"%s", srb2home, "models.dat"), "rt"); if (!f) { - CONS_Printf("Error while loading md2.dat\n"); + CONS_Printf("Error while loading models.dat\n"); nomd2s = true; return; } - // Check for any MD2s that match the names of player skins! - while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) + // Check for any models that match the names of sprite names! + while (fscanf(f, "%25s %31s %f %f", name, filename, &scale, &offset) == 4) { + // length of the sprite name + size_t len = strlen(name); + if (len != 4) // must be 4 characters long exactly. otherwise it's not a sprite name. + continue; + + // check for the player model prefix. + if (!strnicmp(name, PLAYERMODELPREFIX, strlen(PLAYERMODELPREFIX))) + continue; // that's not a sprite... + if (stricmp(name, sprnames[spritenum]) == 0) { md2_models[spritenum].scale = scale; md2_models[spritenum].offset = offset; md2_models[spritenum].notfound = false; strcpy(md2_models[spritenum].filename, filename); - goto spritemd2found; + goto spritemodelfound; } } - //CONS_Printf("MD2 for sprite %s not found\n", sprnames[spritenum]); md2_models[spritenum].notfound = true; -spritemd2found: +spritemodelfound: fclose(f); } -static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, skincolors_t color) +// Define for getting accurate color brightness readings according to how the human eye sees them. +// https://en.wikipedia.org/wiki/Relative_luminance +// 0.2126 to red +// 0.7152 to green +// 0.0722 to blue +#define SETBRIGHTNESS(brightness,r,g,b) \ + brightness = (UINT8)(((1063*(UINT16)(r))/5000) + ((3576*(UINT16)(g))/5000) + ((361*(UINT16)(b))/5000)) + +static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, GLMipmap_t *grmip, INT32 skinnum, skincolors_t color) { UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; + UINT8 translation[16]; // First the color index + UINT8 cutoff[16]; // Brightness cutoff before using the next color + UINT8 translen = 0; + UINT8 i; + + blendcolor = V_GetColor(0); // initialize + memset(translation, 0, sizeof(translation)); + memset(cutoff, 0, sizeof(cutoff)); if (grmip->width == 0) { - grmip->width = gpatch->width; grmip->height = gpatch->height; @@ -970,184 +702,348 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, grmip->grInfo.format = GR_RGBA; } - Z_Free(grmip->grInfo.data); - grmip->grInfo.data = NULL; + if (grmip->grInfo.data) + { + Z_Free(grmip->grInfo.data); + grmip->grInfo.data = NULL; + } - cur = Z_Malloc(size*4, PU_HWRCACHE, &grmip->grInfo.data); + cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &grmip->grInfo.data); memset(cur, 0x00, size*4); - image = gpatch->mipmap.grInfo.data; - blendimage = blendgpatch->mipmap.grInfo.data; + image = gpatch->mipmap->grInfo.data; + blendimage = blendgpatch->mipmap->grInfo.data; - switch (color) + // TC_METALSONIC includes an actual skincolor translation, on top of its flashing. + if (skinnum == TC_METALSONIC) + color = SKINCOLOR_COBALT; + + if (color != SKINCOLOR_NONE) { - case SKINCOLOR_WHITE: - blendcolor = V_GetColor(3); - break; - case SKINCOLOR_SILVER: - blendcolor = V_GetColor(10); - break; - case SKINCOLOR_GREY: - blendcolor = V_GetColor(15); - break; - case SKINCOLOR_BLACK: - blendcolor = V_GetColor(27); - break; - case SKINCOLOR_CYAN: - blendcolor = V_GetColor(215); - break; - case SKINCOLOR_TEAL: - blendcolor = V_GetColor(221); - break; - case SKINCOLOR_STEELBLUE: - blendcolor = V_GetColor(203); - break; - case SKINCOLOR_BLUE: - blendcolor = V_GetColor(232); - break; - case SKINCOLOR_PEACH: - blendcolor = V_GetColor(71); - break; - case SKINCOLOR_TAN: - blendcolor = V_GetColor(79); - break; - case SKINCOLOR_PINK: - blendcolor = V_GetColor(147); - break; - case SKINCOLOR_LAVENDER: - blendcolor = V_GetColor(251); - break; - case SKINCOLOR_PURPLE: - blendcolor = V_GetColor(195); - break; - case SKINCOLOR_ORANGE: - blendcolor = V_GetColor(87); - break; - case SKINCOLOR_ROSEWOOD: - blendcolor = V_GetColor(94); - break; - case SKINCOLOR_BEIGE: - blendcolor = V_GetColor(40); - break; - case SKINCOLOR_BROWN: - blendcolor = V_GetColor(57); - break; - case SKINCOLOR_RED: - blendcolor = V_GetColor(130); - break; - case SKINCOLOR_DARKRED: - blendcolor = V_GetColor(139); - break; - case SKINCOLOR_NEONGREEN: - blendcolor = V_GetColor(184); - break; - case SKINCOLOR_GREEN: - blendcolor = V_GetColor(166); - break; - case SKINCOLOR_ZIM: - blendcolor = V_GetColor(180); - break; - case SKINCOLOR_OLIVE: - blendcolor = V_GetColor(108); - break; - case SKINCOLOR_YELLOW: - blendcolor = V_GetColor(104); - break; - case SKINCOLOR_GOLD: - blendcolor = V_GetColor(115); - break; + UINT8 numdupes = 1; - case SKINCOLOR_SUPER1: - blendcolor = V_GetColor(97); - break; - case SKINCOLOR_SUPER2: - blendcolor = V_GetColor(100); - break; - case SKINCOLOR_SUPER3: - blendcolor = V_GetColor(103); - break; - case SKINCOLOR_SUPER4: - blendcolor = V_GetColor(113); - break; - case SKINCOLOR_SUPER5: - blendcolor = V_GetColor(116); - break; + translation[translen] = Color_Index[color-1][0]; + cutoff[translen] = 255; - case SKINCOLOR_TSUPER1: - blendcolor = V_GetColor(81); - break; - case SKINCOLOR_TSUPER2: - blendcolor = V_GetColor(82); - break; - case SKINCOLOR_TSUPER3: - blendcolor = V_GetColor(84); - break; - case SKINCOLOR_TSUPER4: - blendcolor = V_GetColor(85); - break; - case SKINCOLOR_TSUPER5: - blendcolor = V_GetColor(87); - break; + for (i = 1; i < 16; i++) + { + if (translation[translen] == Color_Index[color-1][i]) + { + numdupes++; + continue; + } - case SKINCOLOR_KSUPER1: - blendcolor = V_GetColor(122); - break; - case SKINCOLOR_KSUPER2: - blendcolor = V_GetColor(123); - break; - case SKINCOLOR_KSUPER3: - blendcolor = V_GetColor(124); - break; - case SKINCOLOR_KSUPER4: - blendcolor = V_GetColor(125); - break; - case SKINCOLOR_KSUPER5: - blendcolor = V_GetColor(126); - break; - default: - blendcolor = V_GetColor(247); - break; + if (translen > 0) + { + cutoff[translen] = cutoff[translen-1] - (256 / (16 / numdupes)); + } + + numdupes = 1; + translen++; + + translation[translen] = (UINT8)Color_Index[color-1][i]; + } + + translen++; } while (size--) { - if (blendimage->s.alpha == 0) + if (skinnum == TC_BOSS) { - // Don't bother with blending the pixel if the alpha of the blend pixel is 0 - cur->rgba = image->rgba; + // Turn everything below a certain threshold white + if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127) + { + // Lactozilla: Invert the colors + cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue); + } + else + { + cur->s.red = image->s.red; + cur->s.green = image->s.green; + cur->s.blue = image->s.blue; + } + + cur->s.alpha = image->s.alpha; + } + else if (skinnum == TC_ALLWHITE) + { + // Turn everything white + cur->s.red = cur->s.green = cur->s.blue = 255; + cur->s.alpha = image->s.alpha; } else { - INT32 tempcolor; - INT16 tempmult, tempalpha; - tempalpha = -(abs(blendimage->s.red-127)-127)*2; - if (tempalpha > 255) - tempalpha = 255; - else if (tempalpha < 0) - tempalpha = 0; + // Everything below requires a blend image + if (blendimage == NULL) + { + cur->rgba = image->rgba; + goto skippixel; + } - tempmult = (blendimage->s.red-127)*2; - if (tempmult > 255) - tempmult = 255; - else if (tempmult < 0) - tempmult = 0; + // Metal Sonic dash mode + if (skinnum == TC_DASHMODE) + { + if (image->s.alpha == 0 && blendimage->s.alpha == 0) + { + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 + cur->rgba = image->rgba; + } + else + { + UINT8 ialpha = 255 - blendimage->s.alpha, balpha = blendimage->s.alpha; + RGBA_t icolor = *image, bcolor; - tempcolor = (image->s.red*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.red)/255)) * blendimage->s.alpha)/255; - cur->s.red = (UINT8)tempcolor; - tempcolor = (image->s.green*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.green)/255)) * blendimage->s.alpha)/255; - cur->s.green = (UINT8)tempcolor; - tempcolor = (image->s.blue*(255-blendimage->s.alpha))/255 + ((tempmult + ((tempalpha*blendcolor.s.blue)/255)) * blendimage->s.alpha)/255; - cur->s.blue = (UINT8)tempcolor; - cur->s.alpha = image->s.alpha; + memset(&bcolor, 0x00, sizeof(RGBA_t)); + + if (blendimage->s.alpha) + { + bcolor.s.blue = 0; + bcolor.s.red = 255; + bcolor.s.green = (blendimage->s.red + blendimage->s.green + blendimage->s.blue) / 3; + } + + if (image->s.alpha && image->s.red > image->s.green << 1) // this is pretty arbitrary, but it works well for Metal Sonic + { + icolor.s.red = image->s.blue; + icolor.s.blue = image->s.red; + } + + cur->s.red = (ialpha * icolor.s.red + balpha * bcolor.s.red)/255; + cur->s.green = (ialpha * icolor.s.green + balpha * bcolor.s.green)/255; + cur->s.blue = (ialpha * icolor.s.blue + balpha * bcolor.s.blue)/255; + cur->s.alpha = image->s.alpha; + } + } + else + { + // All settings that use skincolors! + UINT16 brightness; + + if (translen <= 0) + { + cur->rgba = image->rgba; + goto skippixel; + } + + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 + if (skinnum == TC_RAINBOW) + { + if (image->s.alpha == 0 && blendimage->s.alpha == 0) + { + cur->rgba = image->rgba; + goto skippixel; + } + else + { + UINT16 imagebright, blendbright; + SETBRIGHTNESS(imagebright,image->s.red,image->s.green,image->s.blue); + SETBRIGHTNESS(blendbright,blendimage->s.red,blendimage->s.green,blendimage->s.blue); + // slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway + brightness = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255; + } + } + else + { + if (blendimage->s.alpha == 0) + { + cur->rgba = image->rgba; + goto skippixel; // for metal sonic blend + } + else + { + SETBRIGHTNESS(brightness,blendimage->s.red,blendimage->s.green,blendimage->s.blue); + } + } + + // Calculate a sort of "gradient" for the skincolor + // (Me splitting this into a function didn't work, so I had to ruin this entire function's groove...) + { + RGBA_t nextcolor; + UINT8 firsti, secondi, mul, mulmax; + INT32 r, g, b; + + // Rainbow needs to find the closest match to the textures themselves, instead of matching brightnesses to other colors. + // Ensue horrible mess. + if (skinnum == TC_RAINBOW) + { + UINT16 brightdif = 256; + UINT8 colorbrightnesses[16]; + INT32 compare, m, d; + + // Ignore pure white & pitch black + if (brightness > 253 || brightness < 2) + { + cur->rgba = image->rgba; + cur++; image++; blendimage++; + continue; + } + + firsti = 0; + mul = 0; + mulmax = 1; + + for (i = 0; i < translen; i++) + { + RGBA_t tempc = V_GetColor(translation[i]); + SETBRIGHTNESS(colorbrightnesses[i], tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison + } + + for (i = 0; i < translen; i++) + { + if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) + continue; + + compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(brightness)); + + if (compare < brightdif) + { + brightdif = (UINT16)compare; + firsti = i; // best matching color that's equal brightness or darker + } + } + + secondi = firsti+1; // next color in line + if (secondi >= translen) + { + m = (INT16)brightness; // - 0; + d = (INT16)colorbrightnesses[firsti]; // - 0; + } + else + { + m = (INT16)brightness - (INT16)colorbrightnesses[secondi]; + d = (INT16)colorbrightnesses[firsti] - (INT16)colorbrightnesses[secondi]; + } + + if (m >= d) + m = d-1; + + mulmax = 16; + + // calculate the "gradient" multiplier based on how close this color is to the one next in line + if (m <= 0 || d <= 0) + mul = 0; + else + mul = (mulmax-1) - ((m * mulmax) / d); + } + else + { + // Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler + firsti = 0; + + for (i = 1; i < translen; i++) + { + if (brightness >= cutoff[i]) + break; + firsti = i; + } + + secondi = firsti+1; + + mulmax = cutoff[firsti]; + if (secondi < translen) + mulmax -= cutoff[secondi]; + + mul = cutoff[firsti] - brightness; + } + + blendcolor = V_GetColor(translation[firsti]); + + if (mul > 0) // If it's 0, then we only need the first color. + { + if (secondi >= translen) // blend to black + nextcolor = V_GetColor(31); + else + nextcolor = V_GetColor(translation[secondi]); + + // Find difference between points + r = (INT32)(nextcolor.s.red - blendcolor.s.red); + g = (INT32)(nextcolor.s.green - blendcolor.s.green); + b = (INT32)(nextcolor.s.blue - blendcolor.s.blue); + + // Find the gradient of the two points + r = ((mul * r) / mulmax); + g = ((mul * g) / mulmax); + b = ((mul * b) / mulmax); + + // Add gradient value to color + blendcolor.s.red += r; + blendcolor.s.green += g; + blendcolor.s.blue += b; + } + } + + if (skinnum == TC_RAINBOW) + { + UINT32 tempcolor; + UINT16 colorbright; + + SETBRIGHTNESS(colorbright,blendcolor.s.red,blendcolor.s.green,blendcolor.s.blue); + if (colorbright == 0) + colorbright = 1; // no dividing by 0 please + + tempcolor = (brightness * blendcolor.s.red) / colorbright; + tempcolor = min(255, tempcolor); + cur->s.red = (UINT8)tempcolor; + + tempcolor = (brightness * blendcolor.s.green) / colorbright; + tempcolor = min(255, tempcolor); + cur->s.green = (UINT8)tempcolor; + + tempcolor = (brightness * blendcolor.s.blue) / colorbright; + tempcolor = min(255, tempcolor); + cur->s.blue = (UINT8)tempcolor; + cur->s.alpha = image->s.alpha; + } + else + { + // Color strength depends on image alpha + INT32 tempcolor; + + tempcolor = ((image->s.red * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.red * blendimage->s.alpha) / 255); + tempcolor = min(255, tempcolor); + cur->s.red = (UINT8)tempcolor; + + tempcolor = ((image->s.green * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.green * blendimage->s.alpha) / 255); + tempcolor = min(255, tempcolor); + cur->s.green = (UINT8)tempcolor; + + tempcolor = ((image->s.blue * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.blue * blendimage->s.alpha) / 255); + tempcolor = min(255, tempcolor); + cur->s.blue = (UINT8)tempcolor; + cur->s.alpha = image->s.alpha; + } + +skippixel: + + // *Now* we can do Metal Sonic's flashing + if (skinnum == TC_METALSONIC) + { + // Blend dark blue into white + if (cur->s.alpha > 0 && cur->s.red == 0 && cur->s.green == 0 && cur->s.blue < 255 && cur->s.blue > 31) + { + // Sal: Invert non-blue + cur->s.red = cur->s.green = (255 - cur->s.blue); + cur->s.blue = 255; + } + + cur->s.alpha = image->s.alpha; + } + } } - cur++; image++; blendimage++; + cur++; image++; + + if (blendimage != NULL) + blendimage++; } return; } -static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, const UINT8 *colormap, skincolors_t color) +#undef SETBRIGHTNESS + +static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT32 skinnum, const UINT8 *colormap, skincolors_t color) { // mostly copied from HWR_GetMappedPatch, hence the similarities and comment GLMipmap_t *grmip, *newmip; @@ -1155,13 +1051,21 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, con if (colormap == colormaps || colormap == NULL) { // Don't do any blending - HWD.pfnSetTexture(&gpatch->mipmap); + HWD.pfnSetTexture(gpatch->mipmap); return; } - // search for the mimmap + if ((blendgpatch && blendgpatch->mipmap->grInfo.format) + && (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height)) + { + // Blend image exists, but it's bad. + HWD.pfnSetTexture(gpatch->mipmap); + return; + } + + // search for the mipmap // skip the first (no colormap translated) - for (grmip = &gpatch->mipmap; grmip->nextcolormap; ) + for (grmip = gpatch->mipmap; grmip->nextcolormap; ) { grmip = grmip->nextcolormap; if (grmip->colormap == colormap) @@ -1169,7 +1073,7 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, con if (grmip->downloaded && grmip->grInfo.data) { HWD.pfnSetTexture(grmip); // found the colormap, set it to the correct texture - Z_ChangeTag(grmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(grmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); return; } } @@ -1184,60 +1088,131 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, con // (...) unfortunately z_malloc fragment alot the memory :(so malloc is better newmip = calloc(1, sizeof (*newmip)); if (newmip == NULL) - I_Error("%s: Out of memory", "HWR_GetMappedPatch"); + I_Error("%s: Out of memory", "HWR_GetBlendedTexture"); grmip->nextcolormap = newmip; newmip->colormap = colormap; - HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, color); + HWR_CreateBlendedTexture(gpatch, blendgpatch, newmip, skinnum, color); HWD.pfnSetTexture(newmip); - Z_ChangeTag(newmip->grInfo.data, PU_HWRCACHE_UNLOCKED); + Z_ChangeTag(newmip->grInfo.data, PU_HWRMODELTEXTURE_UNLOCKED); } - -// -----------------+ -// HWR_DrawMD2 : Draw MD2 -// : (monsters, bonuses, weapons, lights, ...) -// Returns : -// -----------------+ - /* - wait/stand - death - pain - walk - shoot/fire - - die? - atka? - atkb? - attacka/b/c/d? - res? - run? - */ #define NORMALFOG 0x00000000 #define FADEFOG 0x19000000 -void HWR_DrawMD2(gr_vissprite_t *spr) + +static boolean HWR_AllowModel(mobj_t *mobj) +{ + // Signpost overlay. Not needed. + if (mobj->state-states == S_PLAY_SIGN) + return false; + + // Otherwise, render the model. + return true; +} + +static boolean HWR_CanInterpolateModel(mobj_t *mobj, model_t *model) +{ + if (cv_grmodelinterpolation.value == 2) // Always interpolate + return true; + return model->interpolate[(mobj->frame & FF_FRAMEMASK)]; +} + +static boolean HWR_CanInterpolateSprite2(modelspr2frames_t *spr2frame) +{ + if (cv_grmodelinterpolation.value == 2) // Always interpolate + return true; + return spr2frame->interpolate; +} + +// +// HWR_GetModelSprite2 (see P_GetSkinSprite2) +// For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing. +// For super players, does the same as above - but tries the super equivalent for each sprite2 before the non-super version. +// + +static UINT8 HWR_GetModelSprite2(md2_t *md2, skin_t *skin, UINT8 spr2, player_t *player) +{ + UINT8 super = 0, i = 0; + + if (!md2 || !md2->model || !md2->model->spr2frames || !skin) + return 0; + + if ((playersprite_t)(spr2 & ~FF_SPR2SUPER) >= free_spr2) + return 0; + + while (!md2->model->spr2frames[spr2].numframes + && spr2 != SPR2_STND + && ++i != 32) // recursion limiter + { + if (spr2 & FF_SPR2SUPER) + { + super = FF_SPR2SUPER; + spr2 &= ~FF_SPR2SUPER; + continue; + } + + switch(spr2) + { + // Normal special cases. + case SPR2_JUMP: + spr2 = ((player + ? player->charflags + : skin->flags) + & SF_NOJUMPSPIN) ? SPR2_SPNG : SPR2_ROLL; + break; + case SPR2_TIRE: + spr2 = ((player + ? player->charability + : skin->ability) + == CA_SWIM) ? SPR2_SWIM : SPR2_FLY; + break; + // Use the handy list, that's what it's there for! + default: + spr2 = spr2defaults[spr2]; + break; + } + + spr2 |= super; + } + + if (i >= 32) // probably an infinite loop... + return 0; + + return spr2; +} + +// +// HWR_DrawModel +// + +boolean HWR_DrawModel(gr_vissprite_t *spr) { FSurfaceInfo Surf; char filename[64]; - INT32 frame; + INT32 frame = 0; + INT32 nextFrame = -1; + UINT8 spr2 = 0; FTransform p; md2_t *md2; UINT8 color[4]; - if (!cv_grmd2.value) - return; + if (!cv_grmodels.value) + return false; if (spr->precip) - return; + return false; + + memset(&p, 0x00, sizeof(FTransform)); // MD2 colormap fix // colormap test + if (spr->mobj->subsector) { sector_t *sector = spr->mobj->subsector->sector; UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + extracolormap_t *colormap = NULL; if (sector->numlights) { @@ -1248,8 +1223,8 @@ void HWR_DrawMD2(gr_vissprite_t *spr) if (!(spr->mobj->frame & FF_FULLBRIGHT)) lightlevel = *sector->lightlist[light].lightlevel; - if (sector->lightlist[light].extra_colormap) - colormap = sector->lightlist[light].extra_colormap; + if (*sector->lightlist[light].extra_colormap) + colormap = *sector->lightlist[light].extra_colormap; } else { @@ -1265,17 +1240,22 @@ void HWR_DrawMD2(gr_vissprite_t *spr) else Surf.FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false); } + else + Surf.FlatColor.rgba = 0xFFFFFFFF; // Look at HWR_ProjectSprite for more { GLPatch_t *gpatch; - INT32 *buff; INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; - md2_frame_t *curr, *next = NULL; - const UINT8 flip = (UINT8)((spr->mobj->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP); + //mdlframe_t *next = NULL; + const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); + const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP)); spritedef_t *sprdef; spriteframe_t *sprframe; + spriteinfo_t *sprinfo; + angle_t ang; + INT32 mod; float finalscale; // Apparently people don't like jump frames like that, so back it goes @@ -1298,59 +1278,90 @@ void HWR_DrawMD2(gr_vissprite_t *spr) { md2 = &md2_playermodels[(skin_t*)spr->mobj->skin-skins]; md2->skin = (skin_t*)spr->mobj->skin-skins; + sprinfo = &((skin_t *)spr->mobj->skin)->sprinfo[spr->mobj->sprite2]; } else + { md2 = &md2_models[spr->mobj->sprite]; + sprinfo = &spriteinfo[spr->mobj->sprite]; + } if (md2->error) - return; // we already failed loading this before :( + return false; // we already failed loading this before :( if (!md2->model) { - //CONS_Debug(DBG_RENDER, "Loading MD2... (%s)", sprnames[spr->mobj->sprite]); - sprintf(filename, "md2/%s", md2->filename); + //CONS_Debug(DBG_RENDER, "Loading model... (%s)", sprnames[spr->mobj->sprite]); + sprintf(filename, "models/%s", md2->filename); md2->model = md2_readModel(filename); if (md2->model) { md2_printModelInfo(md2->model); + HWD.pfnCreateModelVBOs(md2->model); } else { //CONS_Debug(DBG_RENDER, " FAILED\n"); md2->error = true; // prevent endless fail - return; + return false; } } + + // Lactozilla: Disallow certain models from rendering + if (!HWR_AllowModel(spr->mobj)) + return false; + //HWD.pfnSetBlend(blend); // This seems to actually break translucency? finalscale = md2->scale; //Hurdler: arf, I don't like that implementation at all... too much crappy gpatch = md2->grpatch; - if (!gpatch || !gpatch->mipmap.grInfo.format || !gpatch->mipmap.downloaded) + if (!gpatch || !gpatch->mipmap->grInfo.format || !gpatch->mipmap->downloaded) md2_loadTexture(md2); gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... - if ((gpatch && gpatch->mipmap.grInfo.format) // don't load the blend texture if the base texture isn't available - && (!md2->blendgrpatch || !((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap.downloaded)) + if ((gpatch && gpatch->mipmap->grInfo.format) // don't load the blend texture if the base texture isn't available + && (!md2->blendgrpatch || !((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap->downloaded)) md2_loadBlendTexture(md2); - if (gpatch && gpatch->mipmap.grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture + if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { - if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE && - md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format - && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) + INT32 skinnum = TC_DEFAULT; + + if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" { - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, spr->colormap, (skincolors_t)spr->mobj->color); + if (spr->mobj->type == MT_CYBRAKDEMON || spr->mobj->colorized) + skinnum = TC_ALLWHITE; + else if (spr->mobj->type == MT_METALSONIC_BATTLE) + skinnum = TC_METALSONIC; + else + skinnum = TC_BOSS; } - else + else if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE) { - // This is safe, since we know the texture has been downloaded - HWD.pfnSetTexture(&gpatch->mipmap); + if (spr->mobj->colorized) + skinnum = TC_RAINBOW; + else if (spr->mobj->player && spr->mobj->player->dashmode >= DASHMODE_THRESHOLD + && (spr->mobj->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) + { + if (spr->mobj->player->charflags & SF_MACHINE) + skinnum = TC_DASHMODE; + else + skinnum = TC_RAINBOW; + } + else if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) + skinnum = (INT32)((skin_t*)spr->mobj->skin-skins); + else + skinnum = TC_DEFAULT; } + + // Translation or skin number found + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else { // Sprite - gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE); + gpatch = spr->gpatch; //W_CachePatchNum(spr->patchlumpnum, PU_CACHE); HWR_GetMappedPatch(gpatch, spr->colormap); } @@ -1361,51 +1372,93 @@ void HWR_DrawMD2(gr_vissprite_t *spr) tics = spr->mobj->anim_duration; } - //FIXME: this is not yet correct - frame = (spr->mobj->frame & FF_FRAMEMASK) % md2->model->header.numFrames; - buff = md2->model->glCommandBuffer; - curr = &md2->model->frames[frame]; - if (cv_grmd2.value == 1 && tics <= durs) + frame = (spr->mobj->frame & FF_FRAMEMASK); + if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && md2->model->spr2frames) { - // frames are handled differently for states with FF_ANIMATE, so get the next frame differently for the interpolation - if (spr->mobj->frame & FF_ANIMATE) + spr2 = HWR_GetModelSprite2(md2, spr->mobj->skin, spr->mobj->sprite2, spr->mobj->player); + mod = md2->model->spr2frames[spr2].numframes; +#ifndef DONTHIDEDIFFANIMLENGTH // by default, different anim length is masked by the mod + if (mod > (INT32)((skin_t *)spr->mobj->skin)->sprites[spr2].numframes) + mod = ((skin_t *)spr->mobj->skin)->sprites[spr2].numframes; +#endif + if (!mod) + mod = 1; + frame = md2->model->spr2frames[spr2].frames[frame%mod]; + } + else + { + mod = md2->model->meshes[0].numFrames; + if (!mod) + mod = 1; + } + +#ifdef USE_MODEL_NEXTFRAME +#define INTERPOLERATION_LIMIT TICRATE/4 + if (cv_grmodelinterpolation.value && tics <= durs && tics <= INTERPOLERATION_LIMIT) + { + if (durs > INTERPOLERATION_LIMIT) + durs = INTERPOLERATION_LIMIT; + + if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY && md2->model->spr2frames) { - UINT32 nextframe = (spr->mobj->frame & FF_FRAMEMASK) + 1; - if (nextframe >= (UINT32)spr->mobj->state->var1) - nextframe = (spr->mobj->state->frame & FF_FRAMEMASK); - nextframe %= md2->model->header.numFrames; - next = &md2->model->frames[nextframe]; - } - else - { - if (spr->mobj->state->nextstate != S_NULL && states[spr->mobj->state->nextstate].sprite != SPR_NULL - && !(spr->mobj->player && (spr->mobj->state->nextstate == S_PLAY_TAP1 || spr->mobj->state->nextstate == S_PLAY_TAP2) && spr->mobj->state == &states[S_PLAY_STND])) + if (HWR_CanInterpolateSprite2(&md2->model->spr2frames[spr2]) + && (spr->mobj->frame & FF_ANIMATE + || (spr->mobj->state->nextstate != S_NULL + && states[spr->mobj->state->nextstate].sprite == SPR_PLAY + && ((P_GetSkinSprite2(spr->mobj->skin, (((spr->mobj->player && spr->mobj->player->powers[pw_super]) ? FF_SPR2SUPER : 0)|states[spr->mobj->state->nextstate].frame) & FF_FRAMEMASK, spr->mobj->player) == spr->mobj->sprite2))))) { - const UINT32 nextframe = (states[spr->mobj->state->nextstate].frame & FF_FRAMEMASK) % md2->model->header.numFrames; - next = &md2->model->frames[nextframe]; + nextFrame = (spr->mobj->frame & FF_FRAMEMASK) + 1; + if (nextFrame >= mod) + nextFrame = 0; + if (frame || !(spr->mobj->state->frame & FF_SPR2ENDSTATE)) + nextFrame = md2->model->spr2frames[spr2].frames[nextFrame]; + else + nextFrame = -1; + } + } + else if (HWR_CanInterpolateModel(spr->mobj, md2->model)) + { + // frames are handled differently for states with FF_ANIMATE, so get the next frame differently for the interpolation + if (spr->mobj->frame & FF_ANIMATE) + { + nextFrame = (spr->mobj->frame & FF_FRAMEMASK) + 1; + if (nextFrame >= (INT32)(spr->mobj->state->var1 + (spr->mobj->state->frame & FF_FRAMEMASK))) + nextFrame = (spr->mobj->state->frame & FF_FRAMEMASK) % mod; + } + else + { + if (spr->mobj->state->nextstate != S_NULL && states[spr->mobj->state->nextstate].sprite != SPR_NULL + && !(spr->mobj->player && (spr->mobj->state->nextstate == S_PLAY_WAIT) && spr->mobj->state == &states[S_PLAY_STND])) + nextFrame = (states[spr->mobj->state->nextstate].frame & FF_FRAMEMASK) % mod; } } } +#undef INTERPOLERATION_LIMIT +#endif //Hurdler: it seems there is still a small problem with mobj angle p.x = FIXED_TO_FLOAT(spr->mobj->x); p.y = FIXED_TO_FLOAT(spr->mobj->y)+md2->offset; - if (spr->mobj->eflags & MFE_VERTICALFLIP) + if (flip) p.z = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height); else p.z = FIXED_TO_FLOAT(spr->mobj->z); if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - sprdef = &((skin_t *)spr->mobj->skin)->spritedef; + sprdef = &((skin_t *)spr->mobj->skin)->sprites[spr->mobj->sprite2]; else sprdef = &sprites[spr->mobj->sprite]; sprframe = &sprdef->spriteframes[spr->mobj->frame & FF_FRAMEMASK]; - if (sprframe->rotate) + if (sprframe->rotate || papersprite) { - const fixed_t anglef = AngleFixed(spr->mobj->angle); + fixed_t anglef = AngleFixed(spr->mobj->angle); + + if (spr->mobj->player) + anglef = AngleFixed(spr->mobj->player->drawangle); + p.angley = FIXED_TO_FLOAT(anglef); } else @@ -1413,8 +1466,49 @@ void HWR_DrawMD2(gr_vissprite_t *spr) const fixed_t anglef = AngleFixed((R_PointToAngle(spr->mobj->x, spr->mobj->y))-ANGLE_180); p.angley = FIXED_TO_FLOAT(anglef); } + + p.rollangle = 0.0f; + p.rollflip = 1; + p.rotaxis = 0; + if (spr->mobj->rollangle) + { + fixed_t anglef = AngleFixed(spr->mobj->rollangle); + p.rollangle = FIXED_TO_FLOAT(anglef); + p.roll = true; + + // rotation pivot + p.centerx = FIXED_TO_FLOAT(spr->mobj->radius/2); + p.centery = FIXED_TO_FLOAT(spr->mobj->height/2); + + // rotation axis + if (sprinfo->available) + p.rotaxis = (UINT8)(sprinfo->pivot[(spr->mobj->frame & FF_FRAMEMASK)].rotaxis); + + // for NiGHTS specifically but should work everywhere else + ang = R_PointToAngle (spr->mobj->x, spr->mobj->y) - (spr->mobj->player ? spr->mobj->player->drawangle : spr->mobj->angle); + if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right + p.rollflip = 1; + else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left + p.rollflip = -1; + } + p.anglex = 0.0f; +#ifdef USE_FTRANSFORM_ANGLEZ + // Slope rotation from Kart + p.anglez = 0.0f; + if (spr->mobj->standingslope) + { + fixed_t tempz = spr->mobj->standingslope->normal.z; + fixed_t tempy = spr->mobj->standingslope->normal.y; + fixed_t tempx = spr->mobj->standingslope->normal.x; + fixed_t tempangle = AngleFixed(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); + p.anglez = FIXED_TO_FLOAT(tempangle); + tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy)); + p.anglex = FIXED_TO_FLOAT(tempangle); + } +#endif + color[0] = Surf.FlatColor.s.red; color[1] = Surf.FlatColor.s.green; color[2] = Surf.FlatColor.s.blue; @@ -1424,9 +1518,14 @@ void HWR_DrawMD2(gr_vissprite_t *spr) finalscale *= FIXED_TO_FLOAT(spr->mobj->scale); p.flip = atransform.flip; +#ifdef USE_FTRANSFORM_MIRROR + p.mirror = atransform.mirror; // from Kart +#endif - HWD.pfnDrawMD2i(buff, curr, durs, tics, next, &p, finalscale, flip, color); + HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, color); } + + return true; } #endif //HWRENDER diff --git a/src/hardware/hw_md2.h b/src/hardware/hw_md2.h index 299d12400..3bbe30053 100644 --- a/src/hardware/hw_md2.h +++ b/src/hardware/hw_md2.h @@ -22,97 +22,7 @@ #define _HW_MD2_H_ #include "hw_glob.h" - -// magic number "IDP2" or 844121161 -#define MD2_IDENT (INT32)(('2' << 24) + ('P' << 16) + ('D' << 8) + 'I') -// model version -#define MD2_VERSION 8 - -#define MD2_MAX_TRIANGLES 8192 -#define MD2_MAX_VERTICES 4096 -#define MD2_MAX_TEXCOORDS 4096 -#define MD2_MAX_FRAMES 512 -#define MD2_MAX_SKINS 32 -#define MD2_MAX_FRAMESIZE (MD2_MAX_VERTICES * 4 + 128) - -#if defined(_MSC_VER) -#pragma pack(1) -#endif -typedef struct -{ - UINT32 magic; - UINT32 version; - UINT32 skinWidth; - UINT32 skinHeight; - UINT32 frameSize; - UINT32 numSkins; - UINT32 numVertices; - UINT32 numTexCoords; - UINT32 numTriangles; - UINT32 numGlCommands; - UINT32 numFrames; - UINT32 offsetSkins; - UINT32 offsetTexCoords; - UINT32 offsetTriangles; - UINT32 offsetFrames; - UINT32 offsetGlCommands; - UINT32 offsetEnd; -} ATTRPACK md2_header_t; //NOTE: each of md2_header's members are 4 unsigned bytes - -typedef struct -{ - UINT8 vertex[3]; - UINT8 lightNormalIndex; -} ATTRPACK md2_alias_triangleVertex_t; - -typedef struct -{ - float vertex[3]; - float normal[3]; -} ATTRPACK md2_triangleVertex_t; - -typedef struct -{ - INT16 vertexIndices[3]; - INT16 textureIndices[3]; -} ATTRPACK md2_triangle_t; - -typedef struct -{ - INT16 s, t; -} ATTRPACK md2_textureCoordinate_t; - -typedef struct -{ - float scale[3]; - float translate[3]; - char name[16]; - md2_alias_triangleVertex_t alias_vertices[1]; -} ATTRPACK md2_alias_frame_t; - -typedef struct -{ - char name[16]; - md2_triangleVertex_t *vertices; -} ATTRPACK md2_frame_t; - -typedef char md2_skin_t[64]; - -typedef struct -{ - float s, t; - INT32 vertexIndex; -} ATTRPACK md2_glCommandVertex_t; - -typedef struct -{ - md2_header_t header; - md2_skin_t *skins; - md2_textureCoordinate_t *texCoords; - md2_triangle_t *triangles; - md2_frame_t *frames; - INT32 *glCommandBuffer; -} ATTRPACK md2_model_t; +#include "hw_model.h" #if defined(_MSC_VER) #pragma pack() @@ -123,7 +33,7 @@ typedef struct char filename[32]; float scale; float offset; - md2_model_t *model; + model_t *model; void *grpatch; void *blendgrpatch; boolean notfound; @@ -134,9 +44,11 @@ typedef struct extern md2_t md2_models[NUMSPRITES]; extern md2_t md2_playermodels[MAXSKINS]; -void HWR_InitMD2(void); -void HWR_DrawMD2(gr_vissprite_t *spr); -void HWR_AddPlayerMD2(INT32 skin); -void HWR_AddSpriteMD2(size_t spritenum); +void HWR_InitModels(void); +void HWR_AddPlayerModel(INT32 skin); +void HWR_AddSpriteModel(size_t spritenum); +boolean HWR_DrawModel(gr_vissprite_t *spr); + +#define PLAYERMODELPREFIX "PLAYER" #endif // _HW_MD2_H_ diff --git a/src/hardware/hw_md2load.c b/src/hardware/hw_md2load.c new file mode 100644 index 000000000..fed81e411 --- /dev/null +++ b/src/hardware/hw_md2load.c @@ -0,0 +1,576 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#include +#include +#include +#include "../doomdef.h" +#include "hw_md2load.h" +#include "hw_model.h" +#include "../z_zone.h" + +#define NUMVERTEXNORMALS 162 + +// Quake 2 normals are indexed. Use avertexnormals[normalindex][x/y/z] and +// you'll have your normals. +float avertexnormals[NUMVERTEXNORMALS][3] = { +{-0.525731f, 0.000000f, 0.850651f}, +{-0.442863f, 0.238856f, 0.864188f}, +{-0.295242f, 0.000000f, 0.955423f}, +{-0.309017f, 0.500000f, 0.809017f}, +{-0.162460f, 0.262866f, 0.951056f}, +{0.000000f, 0.000000f, 1.000000f}, +{0.000000f, 0.850651f, 0.525731f}, +{-0.147621f, 0.716567f, 0.681718f}, +{0.147621f, 0.716567f, 0.681718f}, +{0.000000f, 0.525731f, 0.850651f}, +{0.309017f, 0.500000f, 0.809017f}, +{0.525731f, 0.000000f, 0.850651f}, +{0.295242f, 0.000000f, 0.955423f}, +{0.442863f, 0.238856f, 0.864188f}, +{0.162460f, 0.262866f, 0.951056f}, +{-0.681718f, 0.147621f, 0.716567f}, +{-0.809017f, 0.309017f, 0.500000f}, +{-0.587785f, 0.425325f, 0.688191f}, +{-0.850651f, 0.525731f, 0.000000f}, +{-0.864188f, 0.442863f, 0.238856f}, +{-0.716567f, 0.681718f, 0.147621f}, +{-0.688191f, 0.587785f, 0.425325f}, +{-0.500000f, 0.809017f, 0.309017f}, +{-0.238856f, 0.864188f, 0.442863f}, +{-0.425325f, 0.688191f, 0.587785f}, +{-0.716567f, 0.681718f, -0.147621f}, +{-0.500000f, 0.809017f, -0.309017f}, +{-0.525731f, 0.850651f, 0.000000f}, +{0.000000f, 0.850651f, -0.525731f}, +{-0.238856f, 0.864188f, -0.442863f}, +{0.000000f, 0.955423f, -0.295242f}, +{-0.262866f, 0.951056f, -0.162460f}, +{0.000000f, 1.000000f, 0.000000f}, +{0.000000f, 0.955423f, 0.295242f}, +{-0.262866f, 0.951056f, 0.162460f}, +{0.238856f, 0.864188f, 0.442863f}, +{0.262866f, 0.951056f, 0.162460f}, +{0.500000f, 0.809017f, 0.309017f}, +{0.238856f, 0.864188f, -0.442863f}, +{0.262866f, 0.951056f, -0.162460f}, +{0.500000f, 0.809017f, -0.309017f}, +{0.850651f, 0.525731f, 0.000000f}, +{0.716567f, 0.681718f, 0.147621f}, +{0.716567f, 0.681718f, -0.147621f}, +{0.525731f, 0.850651f, 0.000000f}, +{0.425325f, 0.688191f, 0.587785f}, +{0.864188f, 0.442863f, 0.238856f}, +{0.688191f, 0.587785f, 0.425325f}, +{0.809017f, 0.309017f, 0.500000f}, +{0.681718f, 0.147621f, 0.716567f}, +{0.587785f, 0.425325f, 0.688191f}, +{0.955423f, 0.295242f, 0.000000f}, +{1.000000f, 0.000000f, 0.000000f}, +{0.951056f, 0.162460f, 0.262866f}, +{0.850651f, -0.525731f, 0.000000f}, +{0.955423f, -0.295242f, 0.000000f}, +{0.864188f, -0.442863f, 0.238856f}, +{0.951056f, -0.162460f, 0.262866f}, +{0.809017f, -0.309017f, 0.500000f}, +{0.681718f, -0.147621f, 0.716567f}, +{0.850651f, 0.000000f, 0.525731f}, +{0.864188f, 0.442863f, -0.238856f}, +{0.809017f, 0.309017f, -0.500000f}, +{0.951056f, 0.162460f, -0.262866f}, +{0.525731f, 0.000000f, -0.850651f}, +{0.681718f, 0.147621f, -0.716567f}, +{0.681718f, -0.147621f, -0.716567f}, +{0.850651f, 0.000000f, -0.525731f}, +{0.809017f, -0.309017f, -0.500000f}, +{0.864188f, -0.442863f, -0.238856f}, +{0.951056f, -0.162460f, -0.262866f}, +{0.147621f, 0.716567f, -0.681718f}, +{0.309017f, 0.500000f, -0.809017f}, +{0.425325f, 0.688191f, -0.587785f}, +{0.442863f, 0.238856f, -0.864188f}, +{0.587785f, 0.425325f, -0.688191f}, +{0.688191f, 0.587785f, -0.425325f}, +{-0.147621f, 0.716567f, -0.681718f}, +{-0.309017f, 0.500000f, -0.809017f}, +{0.000000f, 0.525731f, -0.850651f}, +{-0.525731f, 0.000000f, -0.850651f}, +{-0.442863f, 0.238856f, -0.864188f}, +{-0.295242f, 0.000000f, -0.955423f}, +{-0.162460f, 0.262866f, -0.951056f}, +{0.000000f, 0.000000f, -1.000000f}, +{0.295242f, 0.000000f, -0.955423f}, +{0.162460f, 0.262866f, -0.951056f}, +{-0.442863f, -0.238856f, -0.864188f}, +{-0.309017f, -0.500000f, -0.809017f}, +{-0.162460f, -0.262866f, -0.951056f}, +{0.000000f, -0.850651f, -0.525731f}, +{-0.147621f, -0.716567f, -0.681718f}, +{0.147621f, -0.716567f, -0.681718f}, +{0.000000f, -0.525731f, -0.850651f}, +{0.309017f, -0.500000f, -0.809017f}, +{0.442863f, -0.238856f, -0.864188f}, +{0.162460f, -0.262866f, -0.951056f}, +{0.238856f, -0.864188f, -0.442863f}, +{0.500000f, -0.809017f, -0.309017f}, +{0.425325f, -0.688191f, -0.587785f}, +{0.716567f, -0.681718f, -0.147621f}, +{0.688191f, -0.587785f, -0.425325f}, +{0.587785f, -0.425325f, -0.688191f}, +{0.000000f, -0.955423f, -0.295242f}, +{0.000000f, -1.000000f, 0.000000f}, +{0.262866f, -0.951056f, -0.162460f}, +{0.000000f, -0.850651f, 0.525731f}, +{0.000000f, -0.955423f, 0.295242f}, +{0.238856f, -0.864188f, 0.442863f}, +{0.262866f, -0.951056f, 0.162460f}, +{0.500000f, -0.809017f, 0.309017f}, +{0.716567f, -0.681718f, 0.147621f}, +{0.525731f, -0.850651f, 0.000000f}, +{-0.238856f, -0.864188f, -0.442863f}, +{-0.500000f, -0.809017f, -0.309017f}, +{-0.262866f, -0.951056f, -0.162460f}, +{-0.850651f, -0.525731f, 0.000000f}, +{-0.716567f, -0.681718f, -0.147621f}, +{-0.716567f, -0.681718f, 0.147621f}, +{-0.525731f, -0.850651f, 0.000000f}, +{-0.500000f, -0.809017f, 0.309017f}, +{-0.238856f, -0.864188f, 0.442863f}, +{-0.262866f, -0.951056f, 0.162460f}, +{-0.864188f, -0.442863f, 0.238856f}, +{-0.809017f, -0.309017f, 0.500000f}, +{-0.688191f, -0.587785f, 0.425325f}, +{-0.681718f, -0.147621f, 0.716567f}, +{-0.442863f, -0.238856f, 0.864188f}, +{-0.587785f, -0.425325f, 0.688191f}, +{-0.309017f, -0.500000f, 0.809017f}, +{-0.147621f, -0.716567f, 0.681718f}, +{-0.425325f, -0.688191f, 0.587785f}, +{-0.162460f, -0.262866f, 0.951056f}, +{0.442863f, -0.238856f, 0.864188f}, +{0.162460f, -0.262866f, 0.951056f}, +{0.309017f, -0.500000f, 0.809017f}, +{0.147621f, -0.716567f, 0.681718f}, +{0.000000f, -0.525731f, 0.850651f}, +{0.425325f, -0.688191f, 0.587785f}, +{0.587785f, -0.425325f, 0.688191f}, +{0.688191f, -0.587785f, 0.425325f}, +{-0.955423f, 0.295242f, 0.000000f}, +{-0.951056f, 0.162460f, 0.262866f}, +{-1.000000f, 0.000000f, 0.000000f}, +{-0.850651f, 0.000000f, 0.525731f}, +{-0.955423f, -0.295242f, 0.000000f}, +{-0.951056f, -0.162460f, 0.262866f}, +{-0.864188f, 0.442863f, -0.238856f}, +{-0.951056f, 0.162460f, -0.262866f}, +{-0.809017f, 0.309017f, -0.500000f}, +{-0.864188f, -0.442863f, -0.238856f}, +{-0.951056f, -0.162460f, -0.262866f}, +{-0.809017f, -0.309017f, -0.500000f}, +{-0.681718f, 0.147621f, -0.716567f}, +{-0.681718f, -0.147621f, -0.716567f}, +{-0.850651f, 0.000000f, -0.525731f}, +{-0.688191f, 0.587785f, -0.425325f}, +{-0.587785f, 0.425325f, -0.688191f}, +{-0.425325f, 0.688191f, -0.587785f}, +{-0.425325f, -0.688191f, -0.587785f}, +{-0.587785f, -0.425325f, -0.688191f}, +{-0.688191f, -0.587785f, -0.425325f}, +}; + +typedef struct +{ + int ident; // A "magic number" that's used to identify the .md2 file + int version; // The version of the file, always 8 + int skinwidth; // Width of the skin(s) in pixels + int skinheight; // Height of the skin(s) in pixels + int framesize; // Size of each frame in bytes + int numSkins; // Number of skins with the model + int numXYZ; // Number of vertices in each frame + int numST; // Number of texture coordinates in each frame. + int numTris; // Number of triangles in each frame + int numGLcmds; // Number of dwords (4 bytes) in the gl command list. + int numFrames; // Number of frames + int offsetSkins; // Offset, in bytes from the start of the file, to the list of skin names. + int offsetST; // Offset, in bytes from the start of the file, to the list of texture coordinates + int offsetTris; // Offset, in bytes from the start of the file, to the list of triangles + int offsetFrames; // Offset, in bytes from the start of the file, to the list of frames + int offsetGLcmds; // Offset, in bytes from the start of the file, to the list of gl commands + int offsetEnd; // Offset, in bytes from the start of the file, to the end of the file (filesize) +} md2header_t; + +typedef struct +{ + unsigned short meshIndex[3]; // indices into the array of vertices in each frames + unsigned short stIndex[3]; // indices into the array of texture coordinates +} md2triangle_t; + +typedef struct +{ + short s; + short t; +} md2texcoord_t; + +typedef struct +{ + unsigned char v[3]; // Scaled vertices. You'll need to multiply them with scale[x] to make them normal. + unsigned char lightNormalIndex; // Index to the array of normals +} md2vertex_t; + +typedef struct +{ + float scale[3]; // Used by the v member in the md2framePoint structure + float translate[3]; // Used by the v member in the md2framePoint structure + char name[16]; // Name of the frame +} md2frame_t; + +// Load the model +model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat) +{ + FILE *f; + + model_t *retModel = NULL; + md2header_t *header; + + size_t fileLen; + int i, j; + size_t namelen; + char *texturefilename; + const char *texPos; + + char *buffer; + + const float WUNITS = 1.0f; + float dataScale = WUNITS; + + md2triangle_t *tris; + md2texcoord_t *texcoords; + md2frame_t *frames; + char *fname = NULL; + int foffset = 0; + + int t; + + // MD2 currently does not work with tinyframes, so force useFloat = true + // + // + // the UV coordinates in MD2 are not compatible with glDrawElements like MD3 is. So they need to be loaded as full float. + // + // MD2 is intended to be draw in triangle strips and fans + // not very compatible with a modern GL implementation, either + // so the idea would be to full float expand it, and put it in a vertex buffer object + // I'm sure there's a way to convert the UVs to 'tinyframes', but maybe that's a job for someone else. + // You'd have to decompress the model, then recompress, reindexing the triangles and weeding out duplicate coordinates + // I already have the decompression work done + + useFloat = true; + + f = fopen(fileName, "rb"); + + if (!f) + return NULL; + + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + + //size_t fileLen; + + //int i, j; + + //size_t namelen; + //char *texturefilename; + texPos = strchr(fileName, '/'); + + if (texPos) + { + texPos++; + namelen = strlen(texPos) + 1; + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + strcpy(texturefilename, texPos); + } + else + { + namelen = strlen(fileName) + 1; + texturefilename = (char*)Z_Malloc(namelen, PU_CACHE, 0); + strcpy(texturefilename, fileName); + } + + texturefilename[namelen - 2] = 'z'; + texturefilename[namelen - 3] = 'u'; + texturefilename[namelen - 4] = 'b'; + + // find length of file + fseek(f, 0, SEEK_END); + fileLen = ftell(f); + fseek(f, 0, SEEK_SET); + + // read in file + buffer = malloc(fileLen); + if (fread(buffer, fileLen, 1, f)) { } // squash ignored fread error + fclose(f); + + // get pointer to file header + header = (md2header_t*)buffer; + + retModel->numMeshes = 1; // MD2 only has one mesh + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * retModel->numMeshes, ztag, 0); + retModel->meshes[0].numFrames = header->numFrames; + // const float WUNITS = 1.0f; + // float dataScale = WUNITS; + + // Tris and ST are simple structures that can be straight-copied + tris = (md2triangle_t*)&buffer[header->offsetTris]; + texcoords = (md2texcoord_t*)&buffer[header->offsetST]; + frames = (md2frame_t*)&buffer[header->offsetFrames]; + + retModel->framenames = (char*)Z_Calloc(header->numFrames*16, ztag, 0); + fname = retModel->framenames; + for (i = 0; i < header->numFrames; i++) + { + md2frame_t *fr = (md2frame_t*)&buffer[header->offsetFrames + foffset]; + memcpy(fname, fr->name, 16); + foffset += sizeof(md2frame_t) + (sizeof(md2vertex_t) * header->numXYZ); + fname += 16; + } + + // Read in textures + retModel->numMaterials = header->numSkins; + + if (retModel->numMaterials <= 0) // Always at least one skin, duh + retModel->numMaterials = 1; + + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + + // int t; + for (t = 0; t < retModel->numMaterials; t++) + { + retModel->materials[t].ambient[0] = 0.8f; + retModel->materials[t].ambient[1] = 0.8f; + retModel->materials[t].ambient[2] = 0.8f; + retModel->materials[t].ambient[3] = 1.0f; + retModel->materials[t].diffuse[0] = 0.8f; + retModel->materials[t].diffuse[1] = 0.8f; + retModel->materials[t].diffuse[2] = 0.8f; + retModel->materials[t].diffuse[3] = 1.0f; + retModel->materials[t].emissive[0] = 0.0f; + retModel->materials[t].emissive[1] = 0.0f; + retModel->materials[t].emissive[2] = 0.0f; + retModel->materials[t].emissive[3] = 1.0f; + retModel->materials[t].specular[0] = 0.0f; + retModel->materials[t].specular[1] = 0.0f; + retModel->materials[t].specular[2] = 0.0f; + retModel->materials[t].specular[3] = 1.0f; + retModel->materials[t].shininess = 0.0f; + retModel->materials[t].spheremap = false; + + /* retModel->materials[t].texture = Texture::ReadTexture((char*)texturefilename, ZT_TEXTURE); + + if (!systemSucks) + { + // Check for a normal map...?? + char openfilename[1024]; + char normalMapName[1024]; + strcpy(normalMapName, texturefilename); + size_t len = strlen(normalMapName); + char *ptr = &normalMapName[len]; + ptr--; // z + ptr--; // u + ptr--; // b + ptr--; // . + *ptr++ = '_'; + *ptr++ = 'n'; + *ptr++ = '.'; + *ptr++ = 'b'; + *ptr++ = 'u'; + *ptr++ = 'z'; + *ptr++ = '\0'; + + sprintf(openfilename, "%s/%s", "textures", normalMapName); + // Convert backslashes to forward slashes + for (int k = 0; k < 1024; k++) + { + if (openfilename[k] == '\0') + break; + + if (openfilename[k] == '\\') + openfilename[k] = '/'; + } + + Resource::resource_t *res = Resource::Open(openfilename); + if (res) + { + Resource::Close(res); + retModel->materials[t].lightmap = Texture::ReadTexture(normalMapName, ZT_TEXTURE); + } + }*/ + } + + retModel->meshes[0].numTriangles = header->numTris; + + if (!useFloat) // Decompress to MD3 'tinyframe' space + { + char *ptr; + + md2triangle_t *trisPtr; + unsigned short *indexptr; + float *uvptr; + + dataScale = 0.015624f; // 1 / 64.0f + retModel->meshes[0].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].numVertices = header->numXYZ; + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + + ptr = (char*)frames; + for (i = 0; i < header->numFrames; i++, ptr += header->framesize) + { + short *vertptr; + char *normptr; + // char *tanptr; + + md2vertex_t *vertex; + + md2frame_t *framePtr = (md2frame_t*)ptr; + retModel->meshes[0].tinyframes[i].vertices = (short*)Z_Malloc(sizeof(short) * 3 * header->numXYZ, ztag, 0); + retModel->meshes[0].tinyframes[i].normals = (char*)Z_Malloc(sizeof(char) * 3 * header->numXYZ, ztag, 0); + + // if (retModel->materials[0].lightmap) + // retModel->meshes[0].tinyframes[i].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*header->numVerts, ztag); + retModel->meshes[0].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * header->numTris, ztag, 0); + + vertptr = retModel->meshes[0].tinyframes[i].vertices; + normptr = retModel->meshes[0].tinyframes[i].normals; + + // tanptr = retModel->meshes[0].tinyframes[i].tangents; + retModel->meshes[0].tinyframes[i].material = &retModel->materials[0]; + + framePtr++; // Advance to vertex list + vertex = (md2vertex_t*)framePtr; + framePtr--; + for (j = 0; j < header->numXYZ; j++, vertex++) + { + *vertptr = (short)(((vertex->v[0] * framePtr->scale[0]) + framePtr->translate[0]) / dataScale); + vertptr++; + *vertptr = (short)(((vertex->v[2] * framePtr->scale[2]) + framePtr->translate[2]) / dataScale); + vertptr++; + *vertptr = -1.0f * (short)(((vertex->v[1] * framePtr->scale[1]) + framePtr->translate[1]) / dataScale); + vertptr++; + + // Normal + *normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][0] * 127); + *normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][2] * 127); + *normptr++ = (char)(avertexnormals[vertex->lightNormalIndex][1] * 127); + } + } + + // This doesn't need to be done every frame! + trisPtr = tris; + indexptr = retModel->meshes[0].indices; + uvptr = (float*)retModel->meshes[0].uvs; + for (j = 0; j < header->numTris; j++, trisPtr++) + { + *indexptr = trisPtr->meshIndex[0]; + indexptr++; + *indexptr = trisPtr->meshIndex[1]; + indexptr++; + *indexptr = trisPtr->meshIndex[2]; + indexptr++; + + uvptr[trisPtr->meshIndex[0] * 2] = texcoords[trisPtr->stIndex[0]].s / (float)header->skinwidth; + uvptr[trisPtr->meshIndex[0] * 2 + 1] = (texcoords[trisPtr->stIndex[0]].t / (float)header->skinheight); + uvptr[trisPtr->meshIndex[1] * 2] = texcoords[trisPtr->stIndex[1]].s / (float)header->skinwidth; + uvptr[trisPtr->meshIndex[1] * 2 + 1] = (texcoords[trisPtr->stIndex[1]].t / (float)header->skinheight); + uvptr[trisPtr->meshIndex[2] * 2] = texcoords[trisPtr->stIndex[2]].s / (float)header->skinwidth; + uvptr[trisPtr->meshIndex[2] * 2 + 1] = (texcoords[trisPtr->stIndex[2]].t / (float)header->skinheight); + } + } + else // Full float loading method + { + md2triangle_t *trisPtr; + float *uvptr; + + char *ptr; + + retModel->meshes[0].numVertices = header->numTris * 3; + retModel->meshes[0].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*header->numFrames, ztag, 0); + retModel->meshes[0].uvs = (float*)Z_Malloc(sizeof(float) * 2 * retModel->meshes[0].numVertices, ztag, 0); + + trisPtr = tris; + uvptr = retModel->meshes[0].uvs; + for (i = 0; i < retModel->meshes[0].numTriangles; i++, trisPtr++) + { + *uvptr++ = texcoords[trisPtr->stIndex[0]].s / (float)header->skinwidth; + *uvptr++ = (texcoords[trisPtr->stIndex[0]].t / (float)header->skinheight); + *uvptr++ = texcoords[trisPtr->stIndex[1]].s / (float)header->skinwidth; + *uvptr++ = (texcoords[trisPtr->stIndex[1]].t / (float)header->skinheight); + *uvptr++ = texcoords[trisPtr->stIndex[2]].s / (float)header->skinwidth; + *uvptr++ = (texcoords[trisPtr->stIndex[2]].t / (float)header->skinheight); + } + + ptr = (char*)frames; + for (i = 0; i < header->numFrames; i++, ptr += header->framesize) + { + float *vertptr, *normptr; + + md2vertex_t *vertex; + + md2frame_t *framePtr = (md2frame_t*)ptr; + retModel->meshes[0].frames[i].normals = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + retModel->meshes[0].frames[i].vertices = (float*)Z_Malloc(sizeof(float) * 3 * header->numTris * 3, ztag, 0); + // if (retModel->materials[0].lightmap) + // retModel->meshes[0].frames[i].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*header->numTris*3, ztag); + //float *vertptr, *normptr; + normptr = (float*)retModel->meshes[0].frames[i].normals; + vertptr = (float*)retModel->meshes[0].frames[i].vertices; + trisPtr = tris; + + retModel->meshes[0].frames[i].material = &retModel->materials[0]; + + framePtr++; // Advance to vertex list + vertex = (md2vertex_t*)framePtr; + framePtr--; + for (j = 0; j < header->numTris; j++, trisPtr++) + { + *vertptr = ((vertex[trisPtr->meshIndex[0]].v[0] * framePtr->scale[0]) + framePtr->translate[0]) * WUNITS; + vertptr++; + *vertptr = ((vertex[trisPtr->meshIndex[0]].v[2] * framePtr->scale[2]) + framePtr->translate[2]) * WUNITS; + vertptr++; + *vertptr = -1.0f * ((vertex[trisPtr->meshIndex[0]].v[1] * framePtr->scale[1]) + framePtr->translate[1]) * WUNITS; + vertptr++; + + *vertptr = ((vertex[trisPtr->meshIndex[1]].v[0] * framePtr->scale[0]) + framePtr->translate[0]) * WUNITS; + vertptr++; + *vertptr = ((vertex[trisPtr->meshIndex[1]].v[2] * framePtr->scale[2]) + framePtr->translate[2]) * WUNITS; + vertptr++; + *vertptr = -1.0f * ((vertex[trisPtr->meshIndex[1]].v[1] * framePtr->scale[1]) + framePtr->translate[1]) * WUNITS; + vertptr++; + + *vertptr = ((vertex[trisPtr->meshIndex[2]].v[0] * framePtr->scale[0]) + framePtr->translate[0]) * WUNITS; + vertptr++; + *vertptr = ((vertex[trisPtr->meshIndex[2]].v[2] * framePtr->scale[2]) + framePtr->translate[2]) * WUNITS; + vertptr++; + *vertptr = -1.0f * ((vertex[trisPtr->meshIndex[2]].v[1] * framePtr->scale[1]) + framePtr->translate[1]) * WUNITS; + vertptr++; + + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][0]; + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][2]; + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[0]].lightNormalIndex][1]; + + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][0]; + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][2]; + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[1]].lightNormalIndex][1]; + + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][0]; + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][2]; + *normptr++ = avertexnormals[vertex[trisPtr->meshIndex[2]].lightNormalIndex][1]; + } + } + } + + free(buffer); + return retModel; +} diff --git a/src/hardware/hw_md2load.h b/src/hardware/hw_md2load.h new file mode 100644 index 000000000..1662d6471 --- /dev/null +++ b/src/hardware/hw_md2load.h @@ -0,0 +1,19 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#ifndef _HW_MD2LOAD_H_ +#define _HW_MD2LOAD_H_ + +#include "hw_model.h" +#include "../doomtype.h" + +// Load the Model +model_t *MD2_LoadModel(const char *fileName, int ztag, boolean useFloat); + +#endif diff --git a/src/hardware/hw_md3load.c b/src/hardware/hw_md3load.c new file mode 100644 index 000000000..87931d27b --- /dev/null +++ b/src/hardware/hw_md3load.c @@ -0,0 +1,522 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#include +#include +#include +#include "../doomdef.h" +#include "hw_md3load.h" +#include "hw_model.h" +#include "../z_zone.h" + +typedef struct +{ + int ident; // A "magic number" that's used to identify the .md3 file + int version; // The version of the file, always 15 + char name[64]; + int flags; + int numFrames; // Number of frames + int numTags; + int numSurfaces; + int numSkins; // Number of skins with the model + int offsetFrames; + int offsetTags; + int offsetSurfaces; + int offsetEnd; // Offset, in bytes from the start of the file, to the end of the file (filesize) +} md3modelHeader; + +typedef struct +{ + float minBounds[3]; // First corner of the bounding box + float maxBounds[3]; // Second corner of the bounding box + float localOrigin[3]; // Local origin, usually (0, 0, 0) + float radius; // Radius of bounding sphere + char name[16]; // Name of frame +} md3Frame; + +typedef struct +{ + char name[64]; // Name of tag + float origin[3]; // Coordinates of tag + float axis[9]; // Orientation of tag object +} md3Tag; + +typedef struct +{ + int ident; + char name[64]; // Name of this surface + int flags; + int numFrames; // # of keyframes + int numShaders; // # of shaders + int numVerts; // # of vertices + int numTriangles; // # of triangles + int offsetTriangles; // Relative offset from start of this struct to where the list of Triangles start + int offsetShaders; // Relative offset from start of this struct to where the list of Shaders start + int offsetST; // Relative offset from start of this struct to where the list of tex coords start + int offsetXYZNormal; // Relative offset from start of this struct to where the list of vertices start + int offsetEnd; // Relative offset from start of this struct to where this surface ends +} md3Surface; + +typedef struct +{ + char name[64]; // Name of this shader + int shaderIndex; // Shader index number +} md3Shader; + +typedef struct +{ + int index[3]; // List of offset values into the list of Vertex objects that constitute the corners of the Triangle object. +} md3Triangle; + +typedef struct +{ + float st[2]; +} md3TexCoord; + +typedef struct +{ + short x, y, z, n; +} md3Vertex; + +static float latlnglookup[256][256][3]; + +static void GetNormalFromLatLong(short latlng, float *out) +{ + float *lookup = latlnglookup[(unsigned char)(latlng >> 8)][(unsigned char)(latlng & 255)]; + + out[0] = *lookup++; + out[1] = *lookup++; + out[2] = *lookup++; +} + +#if 0 +static void NormalToLatLng(float *n, short *out) +{ + // Special cases + if (0.0f == n[0] && 0.0f == n[1]) + { + if (n[2] > 0.0f) + *out = 0; + else + *out = 128; + } + else + { + char x, y; + + x = (char)(57.2957795f * (atan2(n[1], n[0])) * (255.0f / 360.0f)); + y = (char)(57.2957795f * (acos(n[2])) * (255.0f / 360.0f)); + + *out = (x << 8) + y; + } +} +#endif + +static inline void LatLngToNormal(short n, float *out) +{ + const float PI = (3.1415926535897932384626433832795f); + float lat = (float)(n >> 8); + float lng = (float)(n & 255); + + lat *= PI / 128.0f; + lng *= PI / 128.0f; + + out[0] = cosf(lat) * sinf(lng); + out[1] = sinf(lat) * sinf(lng); + out[2] = cosf(lng); +} + +static void LatLngInit(void) +{ + int i, j; + for (i = 0; i < 256; i++) + { + for (j = 0; j < 256; j++) + LatLngToNormal((short)((i << 8) + j), latlnglookup[i][j]); + } +} + +static boolean latlnginit = false; + +model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat) +{ + const float WUNITS = 1.0f; + model_t *retModel = NULL; + md3Frame *frames = NULL; + char *fname = NULL; + md3modelHeader *mdh; + long fileLen; + long fileReadLen; + char *buffer; + int surfEnd; + int i, t; + int matCount; + FILE *f; + + if (!latlnginit) + { + LatLngInit(); + latlnginit = true; + } + + f = fopen(fileName, "rb"); + + if (!f) + return NULL; + + retModel = (model_t*)Z_Calloc(sizeof(model_t), ztag, 0); + + // find length of file + fseek(f, 0, SEEK_END); + fileLen = ftell(f); + fseek(f, 0, SEEK_SET); + + // read in file + buffer = malloc(fileLen); + fileReadLen = fread(buffer, fileLen, 1, f); + fclose(f); + + (void)fileReadLen; // intentionally ignore return value, per buildbot + + // get pointer to file header + mdh = (md3modelHeader*)buffer; + + retModel->numMeshes = mdh->numSurfaces; + + retModel->numMaterials = 0; + surfEnd = 0; + for (i = 0; i < mdh->numSurfaces; i++) + { + md3Surface *mdS = (md3Surface*)&buffer[mdh->offsetSurfaces]; + surfEnd += mdS->offsetEnd; + + retModel->numMaterials += mdS->numShaders; + } + + // Initialize materials + if (retModel->numMaterials <= 0) // Always at least one skin, duh + retModel->numMaterials = 1; + + retModel->materials = (material_t*)Z_Calloc(sizeof(material_t)*retModel->numMaterials, ztag, 0); + + for (t = 0; t < retModel->numMaterials; t++) + { + retModel->materials[t].ambient[0] = 0.3686f; + retModel->materials[t].ambient[1] = 0.3684f; + retModel->materials[t].ambient[2] = 0.3684f; + retModel->materials[t].ambient[3] = 1.0f; + retModel->materials[t].diffuse[0] = 0.8863f; + retModel->materials[t].diffuse[1] = 0.8850f; + retModel->materials[t].diffuse[2] = 0.8850f; + retModel->materials[t].diffuse[3] = 1.0f; + retModel->materials[t].emissive[0] = 0.0f; + retModel->materials[t].emissive[1] = 0.0f; + retModel->materials[t].emissive[2] = 0.0f; + retModel->materials[t].emissive[3] = 1.0f; + retModel->materials[t].specular[0] = 0.4902f; + retModel->materials[t].specular[1] = 0.4887f; + retModel->materials[t].specular[2] = 0.4887f; + retModel->materials[t].specular[3] = 1.0f; + retModel->materials[t].shininess = 25.0f; + retModel->materials[t].spheremap = false; + } + + retModel->meshes = (mesh_t*)Z_Calloc(sizeof(mesh_t)*retModel->numMeshes, ztag, 0); + + frames = (md3Frame*)&buffer[mdh->offsetFrames]; + retModel->framenames = (char*)Z_Calloc(mdh->numFrames*16, ztag, 0); + fname = retModel->framenames; + for (i = 0; i < mdh->numFrames; i++) + { + memcpy(fname, frames->name, 16); + fname += 16; + frames++; + } + + matCount = 0; + for (i = 0, surfEnd = 0; i < mdh->numSurfaces; i++) + { + int j; + md3Shader *mdShader; + md3Surface *mdS = (md3Surface*)&buffer[mdh->offsetSurfaces + surfEnd]; + surfEnd += mdS->offsetEnd; + + mdShader = (md3Shader*)((char*)mdS + mdS->offsetShaders); + + for (j = 0; j < mdS->numShaders; j++, matCount++) + { + size_t len = strlen(mdShader[j].name); + mdShader[j].name[len-1] = 'z'; + mdShader[j].name[len-2] = 'u'; + mdShader[j].name[len-3] = 'b'; + + // Load material +/* retModel->materials[matCount].texture = Texture::ReadTexture(mdShader[j].name, ZT_TEXTURE); + + if (!systemSucks) + { + // Check for a normal map...?? + char openfilename[1024]; + char normalMapName[1024]; + strcpy(normalMapName, mdShader[j].name); + len = strlen(normalMapName); + char *ptr = &normalMapName[len]; + ptr--; // z + ptr--; // u + ptr--; // b + ptr--; // . + *ptr++ = '_'; + *ptr++ = 'n'; + *ptr++ = '.'; + *ptr++ = 'b'; + *ptr++ = 'u'; + *ptr++ = 'z'; + *ptr++ = '\0'; + + sprintf(openfilename, "%s/%s", "textures", normalMapName); + // Convert backslashes to forward slashes + for (int k = 0; k < 1024; k++) + { + if (openfilename[k] == '\0') + break; + + if (openfilename[k] == '\\') + openfilename[k] = '/'; + } + + Resource::resource_t *res = Resource::Open(openfilename); + if (res) + { + Resource::Close(res); + retModel->materials[matCount].lightmap = Texture::ReadTexture(normalMapName, ZT_TEXTURE); + } + }*/ + } + + retModel->meshes[i].numFrames = mdS->numFrames; + retModel->meshes[i].numTriangles = mdS->numTriangles; + + if (!useFloat) // 'tinyframe' mode with indices + { + float tempNormal[3]; + float *uvptr; + md3TexCoord *mdST; + unsigned short *indexptr; + md3Triangle *mdT; + + retModel->meshes[i].tinyframes = (tinyframe_t*)Z_Calloc(sizeof(tinyframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].numVertices = mdS->numVerts; + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numVerts, ztag, 0); + for (j = 0; j < mdS->numFrames; j++) + { + short *vertptr; + char *normptr; + // char *tanptr; + int k; + md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); + retModel->meshes[i].tinyframes[j].vertices = (short*)Z_Malloc(sizeof(short)*3*mdS->numVerts, ztag, 0); + retModel->meshes[i].tinyframes[j].normals = (char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag, 0); + +// if (retModel->materials[0].lightmap) +// retModel->meshes[i].tinyframes[j].tangents = (char*)malloc(sizeof(char));//(char*)Z_Malloc(sizeof(char)*3*mdS->numVerts, ztag); + retModel->meshes[i].indices = (unsigned short*)Z_Malloc(sizeof(unsigned short) * 3 * mdS->numTriangles, ztag, 0); + vertptr = retModel->meshes[i].tinyframes[j].vertices; + normptr = retModel->meshes[i].tinyframes[j].normals; + +// tanptr = retModel->meshes[i].tinyframes[j].tangents; + retModel->meshes[i].tinyframes[j].material = &retModel->materials[i]; + + for (k = 0; k < mdS->numVerts; k++) + { + // Vertex + *vertptr = mdV[k].x; + vertptr++; + *vertptr = mdV[k].z; + vertptr++; + *vertptr = 1.0f - mdV[k].y; + vertptr++; + + // Normal + GetNormalFromLatLong(mdV[k].n, tempNormal); + *normptr = (char)(tempNormal[0] * 127); + normptr++; + *normptr = (char)(tempNormal[2] * 127); + normptr++; + *normptr = (char)(tempNormal[1] * 127); + normptr++; + } + } + + uvptr = (float*)retModel->meshes[i].uvs; + mdST = (md3TexCoord*)((char*)mdS + mdS->offsetST); + for (j = 0; j < mdS->numVerts; j++) + { + *uvptr = mdST[j].st[0]; + uvptr++; + *uvptr = mdST[j].st[1]; + uvptr++; + } + + indexptr = retModel->meshes[i].indices; + mdT = (md3Triangle*)((char*)mdS + mdS->offsetTriangles); + for (j = 0; j < mdS->numTriangles; j++, mdT++) + { + // Indices + *indexptr = (unsigned short)mdT->index[0]; + indexptr++; + *indexptr = (unsigned short)mdT->index[1]; + indexptr++; + *indexptr = (unsigned short)mdT->index[2]; + indexptr++; + } + } + else // Traditional full-float loading method + { + float dataScale = 0.015624f * WUNITS; + float tempNormal[3]; + md3TexCoord *mdST; + md3Triangle *mdT; + float *uvptr; + int k; + + retModel->meshes[i].numVertices = mdS->numTriangles * 3;//mdS->numVerts; + retModel->meshes[i].frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t)*mdS->numFrames, ztag, 0); + retModel->meshes[i].uvs = (float*)Z_Malloc(sizeof(float)*2*mdS->numTriangles*3, ztag, 0); + + for (j = 0; j < mdS->numFrames; j++) + { + float *vertptr; + float *normptr; + md3Vertex *mdV = (md3Vertex*)((char*)mdS + mdS->offsetXYZNormal + (mdS->numVerts*j*sizeof(md3Vertex))); + retModel->meshes[i].frames[j].vertices = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); + retModel->meshes[i].frames[j].normals = (float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag, 0); +// if (retModel->materials[i].lightmap) +// retModel->meshes[i].frames[j].tangents = (float*)malloc(sizeof(float));//(float*)Z_Malloc(sizeof(float)*3*mdS->numTriangles*3, ztag); + vertptr = retModel->meshes[i].frames[j].vertices; + normptr = retModel->meshes[i].frames[j].normals; + retModel->meshes[i].frames[j].material = &retModel->materials[i]; + + mdT = (md3Triangle*)((char*)mdS + mdS->offsetTriangles); + + for (k = 0; k < mdS->numTriangles; k++) + { + // Vertex 1 + *vertptr = mdV[mdT->index[0]].x * dataScale; + vertptr++; + *vertptr = mdV[mdT->index[0]].z * dataScale; + vertptr++; + *vertptr = 1.0f - mdV[mdT->index[0]].y * dataScale; + vertptr++; + + GetNormalFromLatLong(mdV[mdT->index[0]].n, tempNormal); + *normptr = tempNormal[0]; + normptr++; + *normptr = tempNormal[2]; + normptr++; + *normptr = tempNormal[1]; + normptr++; + + // Vertex 2 + *vertptr = mdV[mdT->index[1]].x * dataScale; + vertptr++; + *vertptr = mdV[mdT->index[1]].z * dataScale; + vertptr++; + *vertptr = 1.0f - mdV[mdT->index[1]].y * dataScale; + vertptr++; + + GetNormalFromLatLong(mdV[mdT->index[1]].n, tempNormal); + *normptr = tempNormal[0]; + normptr++; + *normptr = tempNormal[2]; + normptr++; + *normptr = tempNormal[1]; + normptr++; + + // Vertex 3 + *vertptr = mdV[mdT->index[2]].x * dataScale; + vertptr++; + *vertptr = mdV[mdT->index[2]].z * dataScale; + vertptr++; + *vertptr = 1.0f - mdV[mdT->index[2]].y * dataScale; + vertptr++; + + GetNormalFromLatLong(mdV[mdT->index[2]].n, tempNormal); + *normptr = tempNormal[0]; + normptr++; + *normptr = tempNormal[2]; + normptr++; + *normptr = tempNormal[1]; + normptr++; + + mdT++; // Advance to next triangle + } + } + + mdST = (md3TexCoord*)((char*)mdS + mdS->offsetST); + uvptr = (float*)retModel->meshes[i].uvs; + mdT = (md3Triangle*)((char*)mdS + mdS->offsetTriangles); + + for (k = 0; k < mdS->numTriangles; k++) + { + *uvptr = mdST[mdT->index[0]].st[0]; + uvptr++; + *uvptr = mdST[mdT->index[0]].st[1]; + uvptr++; + + *uvptr = mdST[mdT->index[1]].st[0]; + uvptr++; + *uvptr = mdST[mdT->index[1]].st[1]; + uvptr++; + + *uvptr = mdST[mdT->index[2]].st[0]; + uvptr++; + *uvptr = mdST[mdT->index[2]].st[1]; + uvptr++; + + mdT++; // Advance to next triangle + } + } + } + /* + // Tags? + retModel->numTags = mdh->numTags; + retModel->maxNumFrames = mdh->numFrames; + retModel->tags = (tag_t*)Z_Calloc(sizeof(tag_t) * retModel->numTags * mdh->numFrames, ztag); + md3Tag *mdTag = (md3Tag*)&buffer[mdh->offsetTags]; + tag_t *curTag = retModel->tags; + for (i = 0; i < mdh->numFrames; i++) + { + int j; + for (j = 0; j < retModel->numTags; j++, mdTag++) + { + strcpys(curTag->name, mdTag->name, sizeof(curTag->name) / sizeof(char)); + curTag->transform.m[0][0] = mdTag->axis[0]; + curTag->transform.m[0][1] = mdTag->axis[1]; + curTag->transform.m[0][2] = mdTag->axis[2]; + curTag->transform.m[1][0] = mdTag->axis[3]; + curTag->transform.m[1][1] = mdTag->axis[4]; + curTag->transform.m[1][2] = mdTag->axis[5]; + curTag->transform.m[2][0] = mdTag->axis[6]; + curTag->transform.m[2][1] = mdTag->axis[7]; + curTag->transform.m[2][2] = mdTag->axis[8]; + curTag->transform.m[3][0] = mdTag->origin[0] * WUNITS; + curTag->transform.m[3][1] = mdTag->origin[1] * WUNITS; + curTag->transform.m[3][2] = mdTag->origin[2] * WUNITS; + curTag->transform.m[3][3] = 1.0f; + + Matrix::Rotate(&curTag->transform, 90.0f, &Vector::Xaxis); + curTag++; + } + }*/ + + + free(buffer); + + return retModel; +} diff --git a/src/hardware/hw_md3load.h b/src/hardware/hw_md3load.h new file mode 100644 index 000000000..c0e0522ff --- /dev/null +++ b/src/hardware/hw_md3load.h @@ -0,0 +1,19 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#ifndef _HW_MD3LOAD_H_ +#define _HW_MD3LOAD_H_ + +#include "hw_model.h" +#include "../doomtype.h" + +// Load the Model +model_t *MD3_LoadModel(const char *fileName, int ztag, boolean useFloat); + +#endif diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c new file mode 100644 index 000000000..ac73f8aca --- /dev/null +++ b/src/hardware/hw_model.c @@ -0,0 +1,737 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#include "../doomdef.h" +#include "../doomtype.h" +#include "../info.h" +#include "../z_zone.h" +#include "hw_model.h" +#include "hw_md2load.h" +#include "hw_md3load.h" +#include "hw_md2.h" +#include "u_list.h" +#include + +static float PI = (3.1415926535897932384626433832795f); +static float U_Deg2Rad(float deg) +{ + return deg * ((float)PI / 180.0f); +} + +vector_t vectorXaxis = { 1.0f, 0.0f, 0.0f }; +vector_t vectorYaxis = { 0.0f, 1.0f, 0.0f }; +vector_t vectorZaxis = { 0.0f, 0.0f, 1.0f }; + +void VectorRotate(vector_t *rotVec, const vector_t *axisVec, float angle) +{ + float ux, uy, uz, vx, vy, vz, wx, wy, wz, sa, ca; + + angle = U_Deg2Rad(angle); + + // Rotate the point (x,y,z) around the vector (u,v,w) + ux = axisVec->x * rotVec->x; + uy = axisVec->x * rotVec->y; + uz = axisVec->x * rotVec->z; + vx = axisVec->y * rotVec->x; + vy = axisVec->y * rotVec->y; + vz = axisVec->y * rotVec->z; + wx = axisVec->z * rotVec->x; + wy = axisVec->z * rotVec->y; + wz = axisVec->z * rotVec->z; + sa = sinf(angle); + ca = cosf(angle); + + rotVec->x = axisVec->x*(ux + vy + wz) + (rotVec->x*(axisVec->y*axisVec->y + axisVec->z*axisVec->z) - axisVec->x*(vy + wz))*ca + (-wy + vz)*sa; + rotVec->y = axisVec->y*(ux + vy + wz) + (rotVec->y*(axisVec->x*axisVec->x + axisVec->z*axisVec->z) - axisVec->y*(ux + wz))*ca + (wx - uz)*sa; + rotVec->z = axisVec->z*(ux + vy + wz) + (rotVec->z*(axisVec->x*axisVec->x + axisVec->y*axisVec->y) - axisVec->z*(ux + vy))*ca + (-vx + uy)*sa; +} + +void UnloadModel(model_t *model) +{ + // Wouldn't it be great if C just had destructors? + int i; + for (i = 0; i < model->numMeshes; i++) + { + mesh_t *mesh = &model->meshes[i]; + + if (mesh->frames) + { + int j; + for (j = 0; j < mesh->numFrames; j++) + { + if (mesh->frames[j].normals) + Z_Free(mesh->frames[j].normals); + + if (mesh->frames[j].tangents) + Z_Free(mesh->frames[j].tangents); + + if (mesh->frames[j].vertices) + Z_Free(mesh->frames[j].vertices); + + if (mesh->frames[j].colors) + Z_Free(mesh->frames[j].colors); + } + + Z_Free(mesh->frames); + } + else if (mesh->tinyframes) + { + int j; + for (j = 0; j < mesh->numFrames; j++) + { + if (mesh->tinyframes[j].normals) + Z_Free(mesh->tinyframes[j].normals); + + if (mesh->tinyframes[j].tangents) + Z_Free(mesh->tinyframes[j].tangents); + + if (mesh->tinyframes[j].vertices) + Z_Free(mesh->tinyframes[j].vertices); + } + + if (mesh->indices) + Z_Free(mesh->indices); + + Z_Free(mesh->tinyframes); + } + + if (mesh->uvs) + Z_Free(mesh->uvs); + + if (mesh->lightuvs) + Z_Free(mesh->lightuvs); + } + + if (model->meshes) + Z_Free(model->meshes); + + if (model->tags) + Z_Free(model->tags); + + if (model->materials) + Z_Free(model->materials); + + DeleteVBOs(model); + Z_Free(model); +} + +tag_t *GetTagByName(model_t *model, char *name, int frame) +{ + if (frame < model->maxNumFrames) + { + tag_t *iterator = &model->tags[frame * model->numTags]; + + int i; + for (i = 0; i < model->numTags; i++) + { + if (!stricmp(iterator[i].name, name)) + return &iterator[i]; + } + } + + return NULL; +} + +// +// LoadModel +// +// Load a model and +// convert it to the +// internal format. +// +model_t *LoadModel(const char *filename, int ztag) +{ + model_t *model; + + // What type of file? + const char *extension = NULL; + int i; + for (i = (int)strlen(filename)-1; i >= 0; i--) + { + if (filename[i] != '.') + continue; + + extension = &filename[i]; + break; + } + + if (!extension) + { + CONS_Printf("Model %s is lacking a file extension, unable to determine type!\n", filename); + return NULL; + } + + if (!strcmp(extension, ".md3")) + { + if (!(model = MD3_LoadModel(filename, ztag, false))) + return NULL; + } + else if (!strcmp(extension, ".md3s")) // MD3 that will be converted in memory to use full floats + { + if (!(model = MD3_LoadModel(filename, ztag, true))) + return NULL; + } + else if (!strcmp(extension, ".md2")) + { + if (!(model = MD2_LoadModel(filename, ztag, false))) + return NULL; + } + else if (!strcmp(extension, ".md2s")) + { + if (!(model = MD2_LoadModel(filename, ztag, true))) + return NULL; + } + else + { + CONS_Printf("Unknown model format: %s\n", extension); + return NULL; + } + + model->mdlFilename = (char*)Z_Malloc(strlen(filename)+1, ztag, 0); + strcpy(model->mdlFilename, filename); + + Optimize(model); + GeneratePolygonNormals(model, ztag); + LoadModelSprite2(model); + if (!model->spr2frames) + LoadModelInterpolationSettings(model); + + // Default material properties + for (i = 0 ; i < model->numMaterials; i++) + { + material_t *material = &model->materials[i]; + material->ambient[0] = 0.7686f; + material->ambient[1] = 0.7686f; + material->ambient[2] = 0.7686f; + material->ambient[3] = 1.0f; + material->diffuse[0] = 0.5863f; + material->diffuse[1] = 0.5863f; + material->diffuse[2] = 0.5863f; + material->diffuse[3] = 1.0f; + material->specular[0] = 0.4902f; + material->specular[1] = 0.4902f; + material->specular[2] = 0.4902f; + material->specular[3] = 1.0f; + material->shininess = 25.0f; + } + + return model; +} + +void HWR_ReloadModels(void) +{ + size_t i; + INT32 s; + + for (s = 0; s < MAXSKINS; s++) + { + if (md2_playermodels[s].model) + LoadModelSprite2(md2_playermodels[s].model); + } + + for (i = 0; i < NUMSPRITES; i++) + { + if (md2_models[i].model) + LoadModelInterpolationSettings(md2_models[i].model); + } +} + +void LoadModelInterpolationSettings(model_t *model) +{ + INT32 i; + INT32 numframes = model->meshes[0].numFrames; + char *framename = model->framenames; + + if (!framename) + return; + + #define GET_OFFSET \ + memcpy(&interpolation_flag, framename + offset, 2); \ + model->interpolate[i] = (!memcmp(interpolation_flag, MODEL_INTERPOLATION_FLAG, 2)); + + for (i = 0; i < numframes; i++) + { + int offset = (strlen(framename) - 4); + char interpolation_flag[3]; + memset(&interpolation_flag, 0x00, 3); + + // find the +i on the frame name + // ANIM+i00 + // so the offset is (frame name length - 4) + GET_OFFSET; + + // maybe the frame had three digits? + // ANIM+i000 + // so the offset is (frame name length - 5) + if (!model->interpolate[i]) + { + offset--; + GET_OFFSET; + } + + framename += 16; + } + + #undef GET_OFFSET +} + +void LoadModelSprite2(model_t *model) +{ + INT32 i; + modelspr2frames_t *spr2frames = NULL; + INT32 numframes = model->meshes[0].numFrames; + char *framename = model->framenames; + + if (!framename) + return; + + for (i = 0; i < numframes; i++) + { + char prefix[6]; + char name[5]; + char interpolation_flag[3]; + char framechars[4]; + UINT8 frame = 0; + UINT8 spr2idx; + boolean interpolate = false; + + memset(&prefix, 0x00, 6); + memset(&name, 0x00, 5); + memset(&interpolation_flag, 0x00, 3); + memset(&framechars, 0x00, 4); + + if (strlen(framename) >= 9) + { + boolean super; + char *modelframename = framename; + memcpy(&prefix, modelframename, 5); + modelframename += 5; + memcpy(&name, modelframename, 4); + modelframename += 4; + // Oh look + memcpy(&interpolation_flag, modelframename, 2); + if (!memcmp(interpolation_flag, MODEL_INTERPOLATION_FLAG, 2)) + { + interpolate = true; + modelframename += 2; + } + memcpy(&framechars, modelframename, 3); + + if ((super = (!memcmp(prefix, "SUPER", 5))) || (!memcmp(prefix, "SPR2_", 5))) + { + spr2idx = 0; + while (spr2idx < free_spr2) + { + if (!memcmp(spr2names[spr2idx], name, 4)) + { + if (!spr2frames) + spr2frames = (modelspr2frames_t*)Z_Calloc(sizeof(modelspr2frames_t)*NUMPLAYERSPRITES*2, PU_STATIC, NULL); + if (super) + spr2idx |= FF_SPR2SUPER; + if (framechars[0]) + { + frame = atoi(framechars); + if (spr2frames[spr2idx].numframes < frame+1) + spr2frames[spr2idx].numframes = frame+1; + } + else + { + frame = spr2frames[spr2idx].numframes; + spr2frames[spr2idx].numframes++; + } + spr2frames[spr2idx].frames[frame] = i; + spr2frames[spr2idx].interpolate = interpolate; + break; + } + spr2idx++; + } + } + } + + framename += 16; + } + + if (model->spr2frames) + Z_Free(model->spr2frames); + model->spr2frames = spr2frames; +} + +// +// GenerateVertexNormals +// +// Creates a new normal for a vertex using the average of all of the polygons it belongs to. +// +void GenerateVertexNormals(model_t *model) +{ + int i; + for (i = 0; i < model->numMeshes; i++) + { + int j; + + mesh_t *mesh = &model->meshes[i]; + + if (!mesh->frames) + continue; + + for (j = 0; j < mesh->numFrames; j++) + { + mdlframe_t *frame = &mesh->frames[j]; + int memTag = PU_STATIC; + float *newNormals = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag, 0); + int k; + float *vertPtr = frame->vertices; + float *oldNormals; + + M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3); + +/* if (!systemSucks) + { + memTag = Z_GetTag(frame->tangents); + float *newTangents = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag); + M_Memcpy(newTangents, frame->tangents, sizeof(float)*3*mesh->numTriangles*3); + }*/ + + for (k = 0; k < mesh->numVertices; k++) + { + float x, y, z; + int vCount = 0; + vector_t normal; + int l; + float *testPtr = frame->vertices; + + x = *vertPtr++; + y = *vertPtr++; + z = *vertPtr++; + + normal.x = normal.y = normal.z = 0; + + for (l = 0; l < mesh->numVertices; l++) + { + float testX, testY, testZ; + testX = *testPtr++; + testY = *testPtr++; + testZ = *testPtr++; + + if (fabsf(x - testX) > FLT_EPSILON + || fabsf(y - testY) > FLT_EPSILON + || fabsf(z - testZ) > FLT_EPSILON) + continue; + + // Found a vertex match! Add it... + normal.x += frame->normals[3 * l + 0]; + normal.y += frame->normals[3 * l + 1]; + normal.z += frame->normals[3 * l + 2]; + vCount++; + } + + if (vCount > 1) + { +// Vector::Normalize(&normal); + newNormals[3 * k + 0] = (float)normal.x; + newNormals[3 * k + 1] = (float)normal.y; + newNormals[3 * k + 2] = (float)normal.z; + +/* if (!systemSucks) + { + Vector::vector_t tangent; + Vector::Tangent(&normal, &tangent); + newTangents[3 * k + 0] = tangent.x; + newTangents[3 * k + 1] = tangent.y; + newTangents[3 * k + 2] = tangent.z; + }*/ + } + } + + oldNormals = frame->normals; + frame->normals = newNormals; + Z_Free(oldNormals); + +/* if (!systemSucks) + { + float *oldTangents = frame->tangents; + frame->tangents = newTangents; + Z_Free(oldTangents); + }*/ + } + } +} + +typedef struct materiallist_s +{ + struct materiallist_s *next; + struct materiallist_s *prev; + material_t *material; +} materiallist_t; + +static boolean AddMaterialToList(materiallist_t **head, material_t *material) +{ + materiallist_t *node, *newMatNode; + for (node = *head; node; node = node->next) + { + if (node->material == material) + return false; + } + + // Didn't find it, so add to the list + newMatNode = (materiallist_t*)Z_Malloc(sizeof(materiallist_t), PU_CACHE, 0); + newMatNode->material = material; + ListAdd(newMatNode, (listitem_t**)head); + return true; +} + +// +// Optimize +// +// Groups triangles from meshes in the model +// Only works for models with 1 frame +// +void Optimize(model_t *model) +{ + int numMeshes = 0; + int i; + materiallist_t *matListHead = NULL; + int memTag; + mesh_t *newMeshes; + materiallist_t *node; + + if (model->numMeshes <= 1) + return; // No need + + for (i = 0; i < model->numMeshes; i++) + { + mesh_t *curMesh = &model->meshes[i]; + + if (curMesh->numFrames > 1) + return; // Can't optimize models with > 1 frame + + if (!curMesh->frames) + return; // Don't optimize tinyframe models (no need) + + // We are condensing to 1 mesh per material, so + // the # of materials we use will be the new + // # of meshes + if (AddMaterialToList(&matListHead, curMesh->frames[0].material)) + numMeshes++; + } + + memTag = PU_STATIC; + newMeshes = (mesh_t*)Z_Calloc(sizeof(mesh_t) * numMeshes, memTag, 0); + + i = 0; + for (node = matListHead; node; node = node->next) + { + material_t *curMat = node->material; + mesh_t *newMesh = &newMeshes[i]; + mdlframe_t *curFrame; + int uvCount; + int vertCount; + int colorCount; + + // Find all triangles with this material and count them + int numTriangles = 0; + int j; + for (j = 0; j < model->numMeshes; j++) + { + mesh_t *curMesh = &model->meshes[j]; + + if (curMesh->frames[0].material == curMat) + numTriangles += curMesh->numTriangles; + } + + newMesh->numFrames = 1; + newMesh->numTriangles = numTriangles; + newMesh->numVertices = numTriangles * 3; + newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); +// if (node->material->lightmap) +// newMesh->lightuvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0); + newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0); + curFrame = &newMesh->frames[0]; + + curFrame->material = curMat; + curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); +// if (!systemSucks) +// curFrame->tangents = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); + curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0); + curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0); + + // Now traverse the meshes of the model, adding in + // vertices/normals/uvs that match the current material + uvCount = 0; + vertCount = 0; + colorCount = 0; + for (j = 0; j < model->numMeshes; j++) + { + mesh_t *curMesh = &model->meshes[j]; + + if (curMesh->frames[0].material == curMat) + { + float *dest; + float *src; + char *destByte; + char *srcByte; + + M_Memcpy(&newMesh->uvs[uvCount], + curMesh->uvs, + sizeof(float)*2*curMesh->numTriangles*3); + +/* if (node->material->lightmap) + { + M_Memcpy(&newMesh->lightuvs[uvCount], + curMesh->lightuvs, + sizeof(float)*2*curMesh->numTriangles*3); + }*/ + uvCount += 2*curMesh->numTriangles*3; + + dest = (float*)newMesh->frames[0].vertices; + src = (float*)curMesh->frames[0].vertices; + M_Memcpy(&dest[vertCount], + src, + sizeof(float)*3*curMesh->numTriangles*3); + + dest = (float*)newMesh->frames[0].normals; + src = (float*)curMesh->frames[0].normals; + M_Memcpy(&dest[vertCount], + src, + sizeof(float)*3*curMesh->numTriangles*3); + +/* if (!systemSucks) + { + dest = (float*)newMesh->frames[0].tangents; + src = (float*)curMesh->frames[0].tangents; + M_Memcpy(&dest[vertCount], + src, + sizeof(float)*3*curMesh->numTriangles*3); + }*/ + + vertCount += 3 * curMesh->numTriangles * 3; + + destByte = (char*)newMesh->frames[0].colors; + srcByte = (char*)curMesh->frames[0].colors; + + if (srcByte) + { + M_Memcpy(&destByte[colorCount], + srcByte, + sizeof(char)*4*curMesh->numTriangles*3); + } + else + { + memset(&destByte[colorCount], + 255, + sizeof(char)*4*curMesh->numTriangles*3); + } + + colorCount += 4 * curMesh->numTriangles * 3; + } + } + + i++; + } + + CONS_Printf("Model::Optimize(): Model reduced from %d to %d meshes.\n", model->numMeshes, numMeshes); + model->meshes = newMeshes; + model->numMeshes = numMeshes; +} + +void GeneratePolygonNormals(model_t *model, int ztag) +{ + int i; + for (i = 0; i < model->numMeshes; i++) + { + int j; + mesh_t *mesh = &model->meshes[i]; + + if (!mesh->frames) + continue; + + for (j = 0; j < mesh->numFrames; j++) + { + int k; + mdlframe_t *frame = &mesh->frames[j]; + const float *vertices = frame->vertices; + vector_t *polyNormals; + + frame->polyNormals = (vector_t*)Z_Malloc(sizeof(vector_t) * mesh->numTriangles, ztag, 0); + + polyNormals = frame->polyNormals; + + for (k = 0; k < mesh->numTriangles; k++) + { +// Vector::Normal(vertices, polyNormals); + vertices += 3 * 3; + polyNormals++; + } + } + } +} + +// +// Reload +// +// Reload VBOs +// +#if 0 +static void Reload(void) +{ +/* model_t *node; + for (node = modelHead; node; node = node->next) + { + int i; + for (i = 0; i < node->numMeshes; i++) + { + mesh_t *mesh = &node->meshes[i]; + + if (mesh->frames) + { + int j; + for (j = 0; j < mesh->numFrames; j++) + CreateVBO(mesh, &mesh->frames[j]); + } + else if (mesh->tinyframes) + { + int j; + for (j = 0; j < mesh->numFrames; j++) + CreateVBO(mesh, &mesh->tinyframes[j]); + } + } + }*/ +} +#endif + +void DeleteVBOs(model_t *model) +{ + (void)model; +/* for (int i = 0; i < model->numMeshes; i++) + { + mesh_t *mesh = &model->meshes[i]; + + if (mesh->frames) + { + for (int j = 0; j < mesh->numFrames; j++) + { + mdlframe_t *frame = &mesh->frames[j]; + if (!frame->vboID) + continue; + bglDeleteBuffers(1, &frame->vboID); + frame->vboID = 0; + } + } + else if (mesh->tinyframes) + { + for (int j = 0; j < mesh->numFrames; j++) + { + tinyframe_t *frame = &mesh->tinyframes[j]; + if (!frame->vboID) + continue; + bglDeleteBuffers(1, &frame->vboID); + frame->vboID = 0; + } + } + }*/ +} diff --git a/src/hardware/hw_model.h b/src/hardware/hw_model.h new file mode 100644 index 000000000..2a5240bde --- /dev/null +++ b/src/hardware/hw_model.h @@ -0,0 +1,121 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#ifndef _HW_MODEL_H_ +#define _HW_MODEL_H_ + +#include "../doomtype.h" + +typedef struct +{ + float x, y, z; +} vector_t; + +extern vector_t vectorXaxis; +extern vector_t vectorYaxis; +extern vector_t vectorZaxis; + +void VectorRotate(vector_t *rotVec, const vector_t *axisVec, float angle); + +typedef struct +{ + float ambient[4], diffuse[4], specular[4], emissive[4]; + float shininess; + boolean spheremap; +// Texture::texture_t *texture; +// Texture::texture_t *lightmap; +} material_t; + +typedef struct +{ + material_t *material; // Pointer to the allocated 'materials' list in model_t + float *vertices; + float *normals; + float *tangents; + char *colors; + unsigned int vboID; + vector_t *polyNormals; +} mdlframe_t; + +typedef struct +{ + material_t *material; + short *vertices; + char *normals; + char *tangents; + unsigned int vboID; +} tinyframe_t; + +// Equivalent to MD3's many 'surfaces' +typedef struct mesh_s +{ + int numVertices; + int numTriangles; + + float *uvs; + float *lightuvs; + + int numFrames; + mdlframe_t *frames; + tinyframe_t *tinyframes; + unsigned short *indices; +} mesh_t; + +typedef struct tag_s +{ + char name[64]; +// matrix_t transform; +} tag_t; + +#define MODEL_INTERPOLATION_FLAG "+i" + +typedef struct +{ + INT32 frames[256]; + UINT8 numframes; + boolean interpolate; +} modelspr2frames_t; + +typedef struct model_s +{ + int maxNumFrames; + + int numMaterials; + material_t *materials; + int numMeshes; + mesh_t *meshes; + int numTags; + tag_t *tags; + + char *mdlFilename; + boolean unloaded; + + char *framenames; + boolean interpolate[256]; + modelspr2frames_t *spr2frames; +} model_t; + +extern int numModels; +extern model_t *modelHead; + +void HWR_ReloadModels(void); + +tag_t *GetTagByName(model_t *model, char *name, int frame); +model_t *LoadModel(const char *filename, int ztag); +void UnloadModel(model_t *model); +void Optimize(model_t *model); +void LoadModelInterpolationSettings(model_t *model); +void LoadModelSprite2(model_t *model); +void GenerateVertexNormals(model_t *model); +void GeneratePolygonNormals(model_t *model, int ztag); +void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame); +void CreateVBO(mesh_t *mesh, mdlframe_t *frame); +void DeleteVBOs(model_t *model); + +#endif diff --git a/src/hardware/hws_data.h b/src/hardware/hws_data.h index 9e2d0547e..b890d976b 100644 --- a/src/hardware/hws_data.h +++ b/src/hardware/hws_data.h @@ -114,7 +114,7 @@ typedef struct snddev_s size_t numsfxs; // Windows specific data -#if defined (_WIN32) && !defined (_XBOX) +#ifdef _WIN32 UINT32 cooplevel; HWND hWnd; #endif diff --git a/src/hardware/r_minigl/r_minigl.c b/src/hardware/r_minigl/r_minigl.c deleted file mode 100644 index b2482a552..000000000 --- a/src/hardware/r_minigl/r_minigl.c +++ /dev/null @@ -1,33 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief MiniGL API for Doom Legacy - - -// tell r_opengl.cpp to compile for MiniGL Drivers -#define MINI_GL_COMPATIBILITY - -// tell r_opengl.cpp to compile for ATI Rage Pro OpenGL driver -//#define ATI_RAGE_PRO_COMPATIBILITY - -#define DRIVER_STRING "HWRAPI Init(): SRB2 MiniGL renderer" - -// Include this at end -#include "../r_opengl/r_opengl.c" -#include "../r_opengl/ogl_win.c" - -// That's all ;-) -// Just, be sure to do the right changes in r_opengl.cpp diff --git a/src/hardware/r_minigl/r_minigl.dev b/src/hardware/r_minigl/r_minigl.dev deleted file mode 100644 index edf725ac5..000000000 --- a/src/hardware/r_minigl/r_minigl.dev +++ /dev/null @@ -1,89 +0,0 @@ -[Project] -FileName=r_minigl.dev -Name=r_minigl -Ver=1 -IsCpp=1 -Type=3 -Compiler=-D_M_IX86=500_@@_-Wall_@@_-D_WINDOWS_@@_-DUSE_WGL_SWAP_@@_-Os_@@_-fomit-frame-pointer_@@_ -CppCompiler= -Includes= -Linker=--def ../r_mingw.def_@@_-lgdi32_@@_ -Libs= -UnitCount=4 -Folders= -ObjFiles= -PrivateResource= -ResourceIncludes= -MakeIncludes= -Icon= -ExeOutput=C:\srb2demo2 -ObjectOutput=..\..\..\objs\Mingw\r_minigl -OverrideOutput=1 -OverrideOutputName=r_minigl.dll -HostApplication= -CommandLine= -IncludeVersionInfo=0 -SupportXPThemes=0 -CompilerSet=0 -CompilerSettings=00000000000000000111d0 -UseCustomMakefile=0 -CustomMakefile= - -[Unit1] -FileName=..\r_opengl\ogl_win.c -Folder= -Compile=0 -CompileCpp=0 -Link=0 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd=$(CC) -c ogl_win.c -o ../../../objs/Mingw/r_minigl/ogl_win.o $(CFLAGS) - -[Unit2] -FileName=..\r_opengl\r_opengl.c -Folder= -Compile=0 -CompileCpp=0 -Link=0 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd=$(CC) -c r_opengl.c -o ../../../objs/Mingw/r_minigl/r_opengl.o $(CFLAGS) - -[Unit3] -FileName=..\r_opengl\r_opengl.h -Folder= -Compile=1 -CompileCpp=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd= - -[VersionInfo] -Major=0 -Minor=1 -Release=1 -Build=1 -LanguageID=1033 -CharsetID=1252 -CompanyName= -FileVersion=0.1 -FileDescription=Developed using the Dev-C++ IDE -InternalName= -LegalCopyright= -LegalTrademarks= -OriginalFilename=r_opengl.exe -ProductName=r_opengl -ProductVersion=0.1 -AutoIncBuildNr=0 - -[Unit4] -FileName=r_minigl.c -CompileCpp=0 -Folder=r_minigl -Compile=1 -Link=1 -Priority=1000 -OverrideBuildCmd=0 -BuildCmd=$(CC) -c r_minigl.c -o ../../../objs/Mingw/r_minigl/r_minigl.o $(CFLAGS) - diff --git a/src/hardware/r_minigl/r_minigl.dsp b/src/hardware/r_minigl/r_minigl.dsp deleted file mode 100644 index 686ca35a3..000000000 --- a/src/hardware/r_minigl/r_minigl.dsp +++ /dev/null @@ -1,103 +0,0 @@ -# Microsoft Developer Studio Project File - Name="r_minigl" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=r_minigl - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "r_minigl.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "r_minigl.mak" CFG="r_minigl - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "r_minigl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "r_minigl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "r_minigl - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "..\..\..\objs\Release" -# PROP BASE Intermediate_Dir "..\..\..\objs\Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\..\bin\VC\Release\r_minigl" -# PROP Intermediate_Dir "..\..\..\objs\VC\Release\r_minigl" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "R_MINIGL_EXPORTS" /YX /FD /c -# ADD CPP /nologo /G5 /MT /W3 /GX /Zi /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /FR /FD /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x80c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 user32.lib gdi32.lib /nologo /dll /pdb:"..\..\..\bin\VC\Release\r_minigl.pdb" /machine:I386 /out:"..\..\..\bin\VC\Release\r_minigl.dll" -# SUBTRACT LINK32 /pdb:none /debug - -!ELSEIF "$(CFG)" == "r_minigl - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "..\..\..\objs\Debug" -# PROP BASE Intermediate_Dir "..\..\..\objs\Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\..\bin\VC\Debug\r_minigl" -# PROP Intermediate_Dir "..\..\..\objs\VC\Debug\r_minigl" -# PROP Ignore_Export_Lib 1 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "R_MINIGL_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "__WIN32__" /D "__MSC__" /D "_MBCS" /D "_USRDLL" /D "R_MINIGL_EXPORTS" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x80c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 ouser32.lib gdi32.lib /nologo /dll /pdb:"..\..\..\bin\VC\Debug\r_minigl.pdb" /debug /machine:I386 /out:"..\..\..\bin\VC\Debug\r_minigl.dll" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "r_minigl - Win32 Release" -# Name "r_minigl - Win32 Debug" -# Begin Source File - -SOURCE=.\r_minigl.c -# End Source File -# Begin Source File - -SOURCE=..\r_opengl\r_opengl.h -# End Source File -# End Target -# End Project diff --git a/src/hardware/r_opengl/ogl_win.c b/src/hardware/r_opengl/ogl_win.c index eb9a31a7d..e4a71734b 100644 --- a/src/hardware/r_opengl/ogl_win.c +++ b/src/hardware/r_opengl/ogl_win.c @@ -347,13 +347,6 @@ static INT32 WINAPI SetRes(viddef_t *lvid, vmode_t *pcurrentmode) if (strstr(renderer, "810")) oglflags |= GLF_NOZBUFREAD; DBG_Printf("oglflags : 0x%X\n", oglflags); -#ifdef USE_PALETTED_TEXTURE - if (isExtAvailable("GL_EXT_paletted_texture",gl_extensions)) - glColorTableEXT = GetGLFunc("glColorTableEXT"); - else - glColorTableEXT = NULL; -#endif - #ifdef USE_WGL_SWAP if (isExtAvailable("WGL_EXT_swap_control",gl_extensions)) wglSwapIntervalEXT = GetGLFunc("wglSwapIntervalEXT"); @@ -571,31 +564,15 @@ EXPORT void HWRAPI(FinishUpdate) (INT32 waitvbl) // : in OpenGL, we store values for conversion of paletted graphics when // : they are downloaded to the 3D card. // -----------------+ -EXPORT void HWRAPI(SetPalette) (RGBA_t *pal, RGBA_t *gamma) +EXPORT void HWRAPI(SetPalette) (RGBA_t *pal) { - INT32 i; - - for (i = 0; i < 256; i++) + size_t palsize = (sizeof(RGBA_t) * 256); + // on a palette change, you have to reload all of the textures + if (memcmp(&myPaletteData, pal, palsize)) { - myPaletteData[i].s.red = (UINT8)MIN((pal[i].s.red*gamma->s.red)/127, 255); - myPaletteData[i].s.green = (UINT8)MIN((pal[i].s.green*gamma->s.green)/127, 255); - myPaletteData[i].s.blue = (UINT8)MIN((pal[i].s.blue*gamma->s.blue)/127, 255); - myPaletteData[i].s.alpha = pal[i].s.alpha; + memcpy(&myPaletteData, pal, palsize); + Flush(); } -#ifdef USE_PALETTED_TEXTURE - if (glColorTableEXT) - { - for (i = 0; i < 256; i++) - { - palette_tex[3*i+0] = pal[i].s.red; - palette_tex[3*i+1] = pal[i].s.green; - palette_tex[3*i+2] = pal[i].s.blue; - } - glColorTableEXT(GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, palette_tex); - } -#endif - // on a chang� de palette, il faut recharger toutes les textures - Flush(); } #endif diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index b324fced9..ed60f2175 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// Copyright (C) 1998-2018 by Sonic Team Junior. +// Copyright (C) 1998-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -29,15 +29,10 @@ #include #include -#ifndef SHUFFLE -#ifndef KOS_GL_COMPATIBILITY -#define SHUFFLE -#endif -#endif #include "r_opengl.h" +#include "r_vbo.h" #if defined (HWRENDER) && !defined (NOROPENGL) -// for KOS: GL_TEXTURE_ENV, glAlphaFunc, glColorMask, glPolygonOffset, glReadPixels, GL_ALPHA_TEST, GL_POLYGON_OFFSET_FILL struct GLRGBAFloat { @@ -47,14 +42,14 @@ struct GLRGBAFloat GLfloat alpha; }; typedef struct GLRGBAFloat GLRGBAFloat; +static const GLubyte white[4] = { 255, 255, 255, 255 }; // ========================================================================== // CONSTANTS // ========================================================================== // With OpenGL 1.1+, the first texture should be 1 -#define NOTEXTURE_NUM 1 // small white texture -#define FIRST_TEX_AVAIL (NOTEXTURE_NUM + 1) +static GLuint NOTEXTURE_NUM = 0; #define N_PI_DEMI (M_PIl/2.0f) //(1.5707963268f) @@ -67,15 +62,16 @@ static float NEAR_CLIPPING_PLANE = NZCLIP_PLANE; // ************************************************************************** -static GLuint NextTexAvail = FIRST_TEX_AVAIL; static GLuint tex_downloaded = 0; static GLfloat fov = 90.0f; +#if 0 static GLuint pal_col = 0; static FRGBAFloat const_pal_col; +#endif static FBITFIELD CurrentPolyFlags; -static FTextureInfo* gr_cachetail = NULL; -static FTextureInfo* gr_cachehead = NULL; +static FTextureInfo *gr_cachetail = NULL; +static FTextureInfo *gr_cachehead = NULL; RGBA_t myPaletteData[256]; GLint screen_width = 0; // used by Draw2DLine() @@ -83,39 +79,23 @@ GLint screen_height = 0; GLbyte screen_depth = 0; GLint textureformatGL = 0; GLint maximumAnisotropy = 0; -#ifndef KOS_GL_COMPATIBILITY static GLboolean MipMap = GL_FALSE; -#endif static GLint min_filter = GL_LINEAR; static GLint mag_filter = GL_LINEAR; static GLint anisotropic_filter = 0; -static FTransform md2_transform; +static boolean model_lighting = true; const GLubyte *gl_extensions = NULL; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -#ifndef MINI_GL_COMPATIBILITY -static GLdouble modelMatrix[16]; -static GLdouble projMatrix[16]; +static GLfloat modelMatrix[16]; +static GLfloat projMatrix[16]; static GLint viewport[4]; -#endif - -#ifdef USE_PALETTED_TEXTURE - PFNGLCOLORTABLEEXTPROC glColorTableEXT = NULL; - GLubyte palette_tex[256*3]; -#endif - -// Yay for arbitrary numbers! NextTexAvail is buggy for some reason. // Sryder: NextTexAvail is broken for these because palette changes or changes to the texture filter or antialiasing // flush all of the stored textures, leaving them unavailable at times such as between levels // These need to start at 0 and be set to their number, and be reset to 0 when deleted so that intel GPUs // can know when the textures aren't there, as textures are always considered resident in their virtual memory -// TODO: Store them in a more normal way -#define SCRTEX_SCREENTEXTURE 65535 -#define SCRTEX_STARTSCREENWIPE 65534 -#define SCRTEX_ENDSCREENWIPE 65533 -#define SCRTEX_FINALSCREENTEXTURE 65532 static GLuint screentexture = 0; static GLuint startScreenWipe = 0; static GLuint endScreenWipe = 0; @@ -167,11 +147,6 @@ float byteasfloat(UINT8 fbyte) static I_Error_t I_Error_GL = NULL; -#ifndef MINI_GL_COMPATIBILITY -static boolean gl13 = false; // whether we can use opengl 1.3 functions -#endif - - // -----------------+ // DBG_Printf : Output error messages to debug log if DEBUG_TO_FILE is defined, // : else do nothing @@ -202,19 +177,14 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...) #define pglAlphaFunc glAlphaFunc #define pglBlendFunc glBlendFunc #define pglCullFace glCullFace -#define pglPolygonMode glPolygonMode #define pglPolygonOffset glPolygonOffset #define pglScissor glScissor #define pglEnable glEnable #define pglDisable glDisable -#ifndef MINI_GL_COMPATIBILITY -#define pglGetDoublev glGetDoublev -#endif +#define pglGetFloatv glGetFloatv //glGetIntegerv //glGetString -#ifdef KOS_GL_COMPATIBILITY #define pglHint glHint -#endif /* Depth Buffer */ #define pglClearDepth glClearDepth @@ -228,23 +198,21 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...) #define pglPushMatrix glPushMatrix #define pglPopMatrix glPopMatrix #define pglLoadIdentity glLoadIdentity -#ifdef MINI_GL_COMPATIBILITY #define pglMultMatrixf glMultMatrixf -#else -#define pglMultMatrixd glMultMatrixd -#endif #define pglRotatef glRotatef #define pglScalef glScalef #define pglTranslatef glTranslatef /* Drawing Functions */ -#define pglBegin glBegin -#define pglEnd glEnd -#define pglVertex3f glVertex3f -#define pglNormal3f glNormal3f -#define pglColor4f glColor4f -#define pglColor4fv glColor4fv -#define pglTexCoord2f glTexCoord2f +#define pglColor4ubv glColor4ubv +#define pglVertexPointer glVertexPointer +#define pglNormalPointer glNormalPointer +#define pglTexCoordPointer glTexCoordPointer +#define pglColorPointer glColorPointer +#define pglDrawArrays glDrawArrays +#define pglDrawElements glDrawElements +#define pglEnableClientState glEnableClientState +#define pglDisableClientState glDisableClientState /* Lighting */ #define pglShadeModel glShadeModel @@ -267,13 +235,12 @@ FUNCPRINTF void DBG_Printf(const char *lpFmt, ...) /* 1.1 functions */ /* texture objects */ //GL_EXT_texture_object +#define pglGenTextures glGenTextures #define pglDeleteTextures glDeleteTextures #define pglBindTexture glBindTexture /* texture mapping */ //GL_EXT_copy_texture -#ifndef KOS_GL_COMPATIBILITY #define pglCopyTexImage2D glCopyTexImage2D #define pglCopyTexSubImage2D glCopyTexSubImage2D -#endif #else //!STATIC_OPENGL @@ -290,8 +257,6 @@ typedef void (APIENTRY * PFNglBlendFunc) (GLenum sfactor, GLenum dfactor); static PFNglBlendFunc pglBlendFunc; typedef void (APIENTRY * PFNglCullFace) (GLenum mode); static PFNglCullFace pglCullFace; -typedef void (APIENTRY * PFNglPolygonMode) (GLenum face, GLenum mode); -static PFNglPolygonMode pglPolygonMode; typedef void (APIENTRY * PFNglPolygonOffset) (GLfloat factor, GLfloat units); static PFNglPolygonOffset pglPolygonOffset; typedef void (APIENTRY * PFNglScissor) (GLint x, GLint y, GLsizei width, GLsizei height); @@ -300,10 +265,8 @@ typedef void (APIENTRY * PFNglEnable) (GLenum cap); static PFNglEnable pglEnable; typedef void (APIENTRY * PFNglDisable) (GLenum cap); static PFNglDisable pglDisable; -#ifndef MINI_GL_COMPATIBILITY -typedef void (APIENTRY * PFNglGetDoublev) (GLenum pname, GLdouble *params); -static PFNglGetDoublev pglGetDoublev; -#endif +typedef void (APIENTRY * PFNglGetFloatv) (GLenum pname, GLfloat *params); +static PFNglGetFloatv pglGetFloatv; //glGetIntegerv //glGetString @@ -328,13 +291,8 @@ typedef void (APIENTRY * PFNglPopMatrix) (void); static PFNglPopMatrix pglPopMatrix; typedef void (APIENTRY * PFNglLoadIdentity) (void); static PFNglLoadIdentity pglLoadIdentity; -#ifdef MINI_GL_COMPATIBILITY typedef void (APIENTRY * PFNglMultMatrixf) (const GLfloat *m); static PFNglMultMatrixf pglMultMatrixf; -#else -typedef void (APIENTRY * PFNglMultMatrixd) (const GLdouble *m); -static PFNglMultMatrixd pglMultMatrixd; -#endif typedef void (APIENTRY * PFNglRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); static PFNglRotatef pglRotatef; typedef void (APIENTRY * PFNglScalef) (GLfloat x, GLfloat y, GLfloat z); @@ -343,20 +301,24 @@ typedef void (APIENTRY * PFNglTranslatef) (GLfloat x, GLfloat y, GLfloat z); static PFNglTranslatef pglTranslatef; /* Drawing Functions */ -typedef void (APIENTRY * PFNglBegin) (GLenum mode); -static PFNglBegin pglBegin; -typedef void (APIENTRY * PFNglEnd) (void); -static PFNglEnd pglEnd; -typedef void (APIENTRY * PFNglVertex3f) (GLfloat x, GLfloat y, GLfloat z); -static PFNglVertex3f pglVertex3f; -typedef void (APIENTRY * PFNglNormal3f) (GLfloat x, GLfloat y, GLfloat z); -static PFNglNormal3f pglNormal3f; -typedef void (APIENTRY * PFNglColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -static PFNglColor4f pglColor4f; -typedef void (APIENTRY * PFNglColor4fv) (const GLfloat *v); -static PFNglColor4fv pglColor4fv; -typedef void (APIENTRY * PFNglTexCoord2f) (GLfloat s, GLfloat t); -static PFNglTexCoord2f pglTexCoord2f; +typedef void (APIENTRY * PFNglColor4ubv) (const GLubyte *v); +static PFNglColor4ubv pglColor4ubv; +typedef void (APIENTRY * PFNglVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static PFNglVertexPointer pglVertexPointer; +typedef void (APIENTRY * PFNglNormalPointer) (GLenum type, GLsizei stride, const GLvoid *pointer); +static PFNglNormalPointer pglNormalPointer; +typedef void (APIENTRY * PFNglTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static PFNglTexCoordPointer pglTexCoordPointer; +typedef void (APIENTRY * PFNglColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +static PFNglColorPointer pglColorPointer; +typedef void (APIENTRY * PFNglDrawArrays) (GLenum mode, GLint first, GLsizei count); +static PFNglDrawArrays pglDrawArrays; +typedef void (APIENTRY * PFNglDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +static PFNglDrawElements pglDrawElements; +typedef void (APIENTRY * PFNglEnableClientState) (GLenum cap); +static PFNglEnableClientState pglEnableClientState; +typedef void (APIENTRY * PFNglDisableClientState) (GLenum cap); +static PFNglDisableClientState pglDisableClientState; /* Lighting */ typedef void (APIENTRY * PFNglShadeModel) (GLenum mode); @@ -390,6 +352,8 @@ static PFNglFogfv pglFogfv; /* 1.1 functions */ /* texture objects */ //GL_EXT_texture_object +typedef void (APIENTRY * PFNglGenTextures) (GLsizei n, const GLuint *textures); +static PFNglGenTextures pglGenTextures; typedef void (APIENTRY * PFNglDeleteTextures) (GLsizei n, const GLuint *textures); static PFNglDeleteTextures pglDeleteTextures; typedef void (APIENTRY * PFNglBindTexture) (GLenum target, GLuint texture); @@ -404,15 +368,27 @@ static PFNglCopyTexSubImage2D pglCopyTexSubImage2D; typedef GLint (APIENTRY * PFNgluBuild2DMipmaps) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); static PFNgluBuild2DMipmaps pgluBuild2DMipmaps; -#ifndef MINI_GL_COMPATIBILITY /* 1.3 functions for multitexturing */ typedef void (APIENTRY *PFNglActiveTexture) (GLenum); static PFNglActiveTexture pglActiveTexture; typedef void (APIENTRY *PFNglMultiTexCoord2f) (GLenum, GLfloat, GLfloat); static PFNglMultiTexCoord2f pglMultiTexCoord2f; -#endif +typedef void (APIENTRY *PFNglMultiTexCoord2fv) (GLenum target, const GLfloat *v); +static PFNglMultiTexCoord2fv pglMultiTexCoord2fv; +typedef void (APIENTRY *PFNglClientActiveTexture) (GLenum); +static PFNglClientActiveTexture pglClientActiveTexture; + +/* 1.5 functions for buffers */ +typedef void (APIENTRY * PFNglGenBuffers) (GLsizei n, GLuint *buffers); +static PFNglGenBuffers pglGenBuffers; +typedef void (APIENTRY * PFNglBindBuffer) (GLenum target, GLuint buffer); +static PFNglBindBuffer pglBindBuffer; +typedef void (APIENTRY * PFNglBufferData) (GLenum target, GLsizei size, const GLvoid *data, GLenum usage); +static PFNglBufferData pglBufferData; +typedef void (APIENTRY * PFNglDeleteBuffers) (GLsizei n, const GLuint *buffers); +static PFNglDeleteBuffers pglDeleteBuffers; + -#ifndef MINI_GL_COMPATIBILITY /* 1.2 Parms */ /* GL_CLAMP_TO_EDGE_EXT */ #ifndef GL_CLAMP_TO_EDGE @@ -433,12 +409,12 @@ static PFNglMultiTexCoord2f pglMultiTexCoord2f; #define GL_TEXTURE1 0x84C1 #endif +/* 1.5 Parms */ +#ifndef GL_ARRAY_BUFFER +#define GL_ARRAY_BUFFER 0x8892 #endif - -#ifdef MINI_GL_COMPATIBILITY -#undef GL_CLAMP_TO_EDGE -#undef GL_TEXTURE_MIN_LOD -#undef GL_TEXTURE_MAX_LOD +#ifndef GL_STATIC_DRAW +#define GL_STATIC_DRAW 0x88E4 #endif boolean SetupGLfunc(void) @@ -453,21 +429,18 @@ boolean SetupGLfunc(void) GETOPENGLFUNC(pglClearColor, glClearColor) - GETOPENGLFUNC(pglClear , glClear) - GETOPENGLFUNC(pglColorMask , glColorMask) - GETOPENGLFUNC(pglAlphaFunc , glAlphaFunc) - GETOPENGLFUNC(pglBlendFunc , glBlendFunc) - GETOPENGLFUNC(pglCullFace , glCullFace) - GETOPENGLFUNC(pglPolygonMode , glPolygonMode) - GETOPENGLFUNC(pglPolygonOffset , glPolygonOffset) - GETOPENGLFUNC(pglScissor , glScissor) - GETOPENGLFUNC(pglEnable , glEnable) - GETOPENGLFUNC(pglDisable , glDisable) -#ifndef MINI_GL_COMPATIBILITY - GETOPENGLFUNC(pglGetDoublev , glGetDoublev) -#endif - GETOPENGLFUNC(pglGetIntegerv , glGetIntegerv) - GETOPENGLFUNC(pglGetString , glGetString) + GETOPENGLFUNC(pglClear, glClear) + GETOPENGLFUNC(pglColorMask, glColorMask) + GETOPENGLFUNC(pglAlphaFunc, glAlphaFunc) + GETOPENGLFUNC(pglBlendFunc, glBlendFunc) + GETOPENGLFUNC(pglCullFace, glCullFace) + GETOPENGLFUNC(pglPolygonOffset, glPolygonOffset) + GETOPENGLFUNC(pglScissor, glScissor) + GETOPENGLFUNC(pglEnable, glEnable) + GETOPENGLFUNC(pglDisable, glDisable) + GETOPENGLFUNC(pglGetFloatv, glGetFloatv) + GETOPENGLFUNC(pglGetIntegerv, glGetIntegerv) + GETOPENGLFUNC(pglGetString, glGetString) GETOPENGLFUNC(pglClearDepth , glClearDepth) GETOPENGLFUNC(pglDepthFunc , glDepthFunc) @@ -479,22 +452,20 @@ boolean SetupGLfunc(void) GETOPENGLFUNC(pglPushMatrix , glPushMatrix) GETOPENGLFUNC(pglPopMatrix , glPopMatrix) GETOPENGLFUNC(pglLoadIdentity , glLoadIdentity) -#ifdef MINI_GL_COMPATIBILITY GETOPENGLFUNC(pglMultMatrixf , glMultMatrixf) -#else - GETOPENGLFUNC(pglMultMatrixd , glMultMatrixd) -#endif GETOPENGLFUNC(pglRotatef , glRotatef) GETOPENGLFUNC(pglScalef , glScalef) GETOPENGLFUNC(pglTranslatef , glTranslatef) - GETOPENGLFUNC(pglBegin , glBegin) - GETOPENGLFUNC(pglEnd , glEnd) - GETOPENGLFUNC(pglVertex3f , glVertex3f) - GETOPENGLFUNC(pglNormal3f , glNormal3f) - GETOPENGLFUNC(pglColor4f , glColor4f) - GETOPENGLFUNC(pglColor4fv , glColor4fv) - GETOPENGLFUNC(pglTexCoord2f , glTexCoord2f) + GETOPENGLFUNC(pglColor4ubv, glColor4ubv) + GETOPENGLFUNC(pglVertexPointer, glVertexPointer) + GETOPENGLFUNC(pglNormalPointer, glNormalPointer) + GETOPENGLFUNC(pglTexCoordPointer, glTexCoordPointer) + GETOPENGLFUNC(pglColorPointer, glColorPointer) + GETOPENGLFUNC(pglDrawArrays, glDrawArrays) + GETOPENGLFUNC(pglDrawElements, glDrawElements) + GETOPENGLFUNC(pglEnableClientState, glEnableClientState) + GETOPENGLFUNC(pglDisableClientState, glDisableClientState) GETOPENGLFUNC(pglShadeModel , glShadeModel) GETOPENGLFUNC(pglLightfv, glLightfv) @@ -511,6 +482,7 @@ boolean SetupGLfunc(void) GETOPENGLFUNC(pglFogf , glFogf) GETOPENGLFUNC(pglFogfv , glFogfv) + GETOPENGLFUNC(pglGenTextures , glGenTextures) GETOPENGLFUNC(pglDeleteTextures , glDeleteTextures) GETOPENGLFUNC(pglBindTexture , glBindTexture) @@ -526,47 +498,21 @@ boolean SetupGLfunc(void) } // This has to be done after the context is created so the version number can be obtained +// This is stupid -- even some of the oldest usable OpenGL hardware today supports 1.3-level featureset. boolean SetupGLFunc13(void) { -#ifdef MINI_GL_COMPATIBILITY - return false; -#else - const GLubyte *version = pglGetString(GL_VERSION); - int glmajor, glminor; + pglActiveTexture = GetGLFunc("glActiveTexture"); + pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2f"); + pglClientActiveTexture = GetGLFunc("glClientActiveTexture"); + pglMultiTexCoord2fv = GetGLFunc("glMultiTexCoord2fv"); - gl13 = false; - // Parse the GL version - if (version != NULL) - { - if (sscanf((const char*)version, "%d.%d", &glmajor, &glminor) == 2) - { - // Look, we gotta prepare for the inevitable arrival of GL 2.0 code... - if (glmajor == 1 && glminor >= 3) - gl13 = true; - else if (glmajor > 1) - gl13 = true; - } - } + /* 1.5 funcs */ + pglGenBuffers = GetGLFunc("glGenBuffers"); + pglBindBuffer = GetGLFunc("glBindBuffer"); + pglBufferData = GetGLFunc("glBufferData"); + pglDeleteBuffers = GetGLFunc("glDeleteBuffers"); - if (gl13) - { - pglActiveTexture = GetGLFunc("glActiveTexture"); - pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2f"); - } - else if (isExtAvailable("GL_ARB_multitexture", gl_extensions)) - { - // Get the functions - pglActiveTexture = GetGLFunc("glActiveTextureARB"); - pglMultiTexCoord2f = GetGLFunc("glMultiTexCoord2fARB"); - - gl13 = true; // This is now true, so the new fade mask stuff can be done, if OpenGL version is less than 1.3, it still uses the old fade stuff. - DBG_Printf("GL_ARB_multitexture support: enabled\n"); - - } - else - DBG_Printf("GL_ARB_multitexture support: disabled\n"); return true; -#endif } // -----------------+ @@ -577,53 +523,47 @@ static void SetNoTexture(void) // Set small white texture. if (tex_downloaded != NOTEXTURE_NUM) { + if (NOTEXTURE_NUM == 0) + pglGenTextures(1, &NOTEXTURE_NUM); pglBindTexture(GL_TEXTURE_2D, NOTEXTURE_NUM); tex_downloaded = NOTEXTURE_NUM; } } -static void GLPerspective(GLdouble fovy, GLdouble aspect) +static void GLPerspective(GLfloat fovy, GLfloat aspect) { -#ifdef MINI_GL_COMPATIBILITY GLfloat m[4][4] = -#else - GLdouble m[4][4] = -#endif { { 1.0f, 0.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f, 0.0f}, { 0.0f, 0.0f, 1.0f,-1.0f}, { 0.0f, 0.0f, 0.0f, 0.0f}, }; - const GLdouble zNear = NEAR_CLIPPING_PLANE; - const GLdouble zFar = FAR_CLIPPING_PLANE; - const GLdouble radians = (GLdouble)(fovy / 2.0f * M_PIl / 180.0f); - const GLdouble sine = sin(radians); - const GLdouble deltaZ = zFar - zNear; - GLdouble cotangent; + const GLfloat zNear = NEAR_CLIPPING_PLANE; + const GLfloat zFar = FAR_CLIPPING_PLANE; + const GLfloat radians = (GLfloat)(fovy / 2.0f * M_PIl / 180.0f); + const GLfloat sine = sinf(radians); + const GLfloat deltaZ = zFar - zNear; + GLfloat cotangent; if ((fabsf((float)deltaZ) < 1.0E-36f) || fpclassify(sine) == FP_ZERO || fpclassify(aspect) == FP_ZERO) { return; } - cotangent = cos(radians) / sine; + cotangent = cosf(radians) / sine; m[0][0] = cotangent / aspect; m[1][1] = cotangent; m[2][2] = -(zFar + zNear) / deltaZ; m[3][2] = -2.0f * zNear * zFar / deltaZ; -#ifdef MINI_GL_COMPATIBILITY + pglMultMatrixf(&m[0][0]); -#else - pglMultMatrixd(&m[0][0]); -#endif } -#ifndef MINI_GL_COMPATIBILITY -static void GLProject(GLdouble objX, GLdouble objY, GLdouble objZ, - GLdouble* winX, GLdouble* winY, GLdouble* winZ) +static void GLProject(GLfloat objX, GLfloat objY, GLfloat objZ, + GLfloat* winX, GLfloat* winY, GLfloat* winZ) { - GLdouble in[4], out[4]; + GLfloat in[4], out[4]; int i; for (i=0; i<4; i++) @@ -659,7 +599,6 @@ static void GLProject(GLdouble objX, GLdouble objY, GLdouble objZ, *winY=in[1]; *winZ=in[2]; } -#endif // -----------------+ // SetModelView : @@ -690,10 +629,8 @@ void SetModelView(GLint w, GLint h) //pglScalef(1.0f, 320.0f/200.0f, 1.0f); // gr_scalefrustum (ORIGINAL_ASPECT) // added for new coronas' code (without depth buffer) -#ifndef MINI_GL_COMPATIBILITY pglGetIntegerv(GL_VIEWPORT, viewport); - pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); -#endif + pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); } @@ -702,11 +639,6 @@ void SetModelView(GLint w, GLint h) // -----------------+ void SetStates(void) { - // Bind little white RGBA texture to ID NOTEXTURE_NUM. - /* - FUINT Data[8*8]; - INT32 i; - */ #ifdef GL_LIGHT_MODEL_AMBIENT GLfloat LightDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f}; #endif @@ -718,17 +650,15 @@ void SetStates(void) //pglShadeModel(GL_FLAT); pglEnable(GL_TEXTURE_2D); // two-dimensional texturing -#ifndef KOS_GL_COMPATIBILITY + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); pglAlphaFunc(GL_NOTEQUAL, 0.0f); -#endif + //pglBlendFunc(GL_ONE, GL_ZERO); // copy pixel to frame buffer (opaque) pglEnable(GL_BLEND); // enable color blending -#ifndef KOS_GL_COMPATIBILITY pglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); -#endif //pglDisable(GL_DITHER); // faB: ??? (undocumented in OpenGL 1.1) // Hurdler: yes, it is! @@ -742,25 +672,13 @@ void SetStates(void) CurrentPolyFlags = 0xffffffff; SetBlend(0); - /* - for (i = 0; i < 64; i++) - Data[i] = 0xffFFffFF; // white pixel - */ - - tex_downloaded = (GLuint)-1; + tex_downloaded = 0; SetNoTexture(); - //pglBindTexture(GL_TEXTURE_2D, NOTEXTURE_NUM); - //tex_downloaded = NOTEXTURE_NUM; - //pglTexImage2D(GL_TEXTURE_2D, 0, 4, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data); -#ifndef KOS_GL_COMPATIBILITY pglPolygonOffset(-1.0f, -1.0f); -#endif //pglEnable(GL_CULL_FACE); //pglCullFace(GL_FRONT); - //pglPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - //pglPolygonMode(GL_FRONT, GL_LINE); //glFogi(GL_FOG_MODE, GL_EXP); //pglHint(GL_FOG_HINT, GL_FASTEST); @@ -776,9 +694,7 @@ void SetStates(void) // bp : when no t&l :) pglLoadIdentity(); pglScalef(1.0f, 1.0f, -1.0f); -#ifndef MINI_GL_COMPATIBILITY - pglGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer) -#endif + pglGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer) } @@ -792,33 +708,12 @@ void Flush(void) while (gr_cachehead) { - // ceci n'est pas du tout necessaire vu que tu les a charger normalement et - // donc il sont dans ta liste ! -#if 0 - //Hurdler: 25/04/2000: now support colormap in hardware mode - FTextureInfo *tmp = gr_cachehead->nextskin; - - // The memory should be freed in the main code - while (tmp) - { - pglDeleteTextures(1, &tmp->downloaded); - tmp->downloaded = 0; - tmp = tmp->nextcolormap; - } -#endif - pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded); + if (gr_cachehead->downloaded) + pglDeleteTextures(1, (GLuint *)&gr_cachehead->downloaded); gr_cachehead->downloaded = 0; gr_cachehead = gr_cachehead->nextmipmap; } gr_cachetail = gr_cachehead = NULL; //Hurdler: well, gr_cachehead is already NULL - NextTexAvail = FIRST_TEX_AVAIL; -#if 0 - if (screentexture != FIRST_TEX_AVAIL) - { - pglDeleteTextures(1, &screentexture); - screentexture = FIRST_TEX_AVAIL; - } -#endif tex_downloaded = 0; } @@ -882,14 +777,6 @@ EXPORT void HWRAPI(ClearMipMapCache) (void) EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 * dst_data) { -#ifdef KOS_GL_COMPATIBILITY - (void)x; - (void)y; - (void)width; - (void)height; - (void)dst_stride; - (void)dst_data; -#else INT32 i; // DBG_Printf ("ReadRect()\n"); if (dst_stride == width*3) @@ -931,7 +818,6 @@ EXPORT void HWRAPI(ReadRect) (INT32 x, INT32 y, INT32 width, INT32 height, } free(image); } -#endif } @@ -952,10 +838,8 @@ EXPORT void HWRAPI(GClipRect) (INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, f pglMatrixMode(GL_MODELVIEW); // added for new coronas' code (without depth buffer) -#ifndef MINI_GL_COMPATIBILITY pglGetIntegerv(GL_VIEWPORT, viewport); - pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); -#endif + pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); } @@ -989,6 +873,8 @@ EXPORT void HWRAPI(ClearBuffer) (FBOOLEAN ColorMask, SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude); pglClear(ClearMask); + pglEnableClientState(GL_VERTEX_ARRAY); // We always use this one + pglEnableClientState(GL_TEXTURE_COORD_ARRAY); // And mostly this one, too } @@ -999,63 +885,42 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1, F2DCoord * v2, RGBA_t Color) { - GLRGBAFloat c; - // DBG_Printf ("DrawLine() (%f %f %f) %d\n", v1->x, -v1->y, -v1->z, v1->argb); -#ifdef MINI_GL_COMPATIBILITY - GLfloat px1, px2, px3, px4; - GLfloat py1, py2, py3, py4; + GLfloat p[12]; GLfloat dx, dy; GLfloat angle; -#endif // BP: we should reflect the new state in our variable //SetBlend(PF_Modulated|PF_NoTexture); pglDisable(GL_TEXTURE_2D); - c.red = byte2float[Color.s.red]; - c.green = byte2float[Color.s.green]; - c.blue = byte2float[Color.s.blue]; - c.alpha = byte2float[Color.s.alpha]; - -#ifndef MINI_GL_COMPATIBILITY - pglColor4fv(&c.red); // is in RGBA float format - pglBegin(GL_LINES); - pglVertex3f(v1->x, -v1->y, 1.0f); - pglVertex3f(v2->x, -v2->y, 1.0f); - pglEnd(); -#else - if (v2->x != v1->x) + // This is the preferred, 'modern' way of rendering lines -- creating a polygon. + if (fabsf(v2->x - v1->x) > FLT_EPSILON) angle = (float)atan((v2->y-v1->y)/(v2->x-v1->x)); else - angle = N_PI_DEMI; + angle = (float)N_PI_DEMI; dx = (float)sin(angle) / (float)screen_width; dy = (float)cos(angle) / (float)screen_height; - px1 = v1->x - dx; py1 = v1->y + dy; - px2 = v2->x - dx; py2 = v2->y + dy; - px3 = v2->x + dx; py3 = v2->y - dy; - px4 = v1->x + dx; py4 = v1->y - dy; + p[0] = v1->x - dx; p[1] = -(v1->y + dy); p[2] = 1; + p[3] = v2->x - dx; p[4] = -(v2->y + dy); p[5] = 1; + p[6] = v2->x + dx; p[7] = -(v2->y - dy); p[8] = 1; + p[9] = v1->x + dx; p[10] = -(v1->y - dy); p[11] = 1; - pglColor4f(c.red, c.green, c.blue, c.alpha); - pglBegin(GL_TRIANGLE_FAN); - pglVertex3f(px1, -py1, 1); - pglVertex3f(px2, -py2, 1); - pglVertex3f(px3, -py3, 1); - pglVertex3f(px4, -py4, 1); - pglEnd(); -#endif + pglDisableClientState(GL_TEXTURE_COORD_ARRAY); + pglColor4ubv((GLubyte*)&Color.s); + pglVertexPointer(3, GL_FLOAT, 0, p); + pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); + pglEnableClientState(GL_TEXTURE_COORD_ARRAY); pglEnable(GL_TEXTURE_2D); } static void Clamp2D(GLenum pname) { pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP); // fallback clamp -#ifdef GL_CLAMP_TO_EDGE pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP_TO_EDGE); -#endif } @@ -1075,60 +940,41 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) switch (PolyFlags & PF_Blending) { case PF_Translucent & PF_Blending: pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_NOTEQUAL, 0.0f); -#endif break; case PF_Masked & PF_Blending: // Hurdler: does that mean lighting is only made by alpha src? // it sounds ok, but not for polygonsmooth pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_GREATER, 0.5f); -#endif break; case PF_Additive & PF_Blending: -#ifdef ATI_RAGE_PRO_COMPATIBILITY - pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency -#else pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest -#endif -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_NOTEQUAL, 0.0f); -#endif break; case PF_Environment & PF_Blending: pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_NOTEQUAL, 0.0f); -#endif break; case PF_Substractive & PF_Blending: // good for shadow - // not realy but what else ? + // not really but what else ? pglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_NOTEQUAL, 0.0f); -#endif break; case PF_Fog & PF_Fog: // Sryder: Fog // multiplies input colour by input alpha, and destination colour by input colour, then adds them pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_NOTEQUAL, 0.0f); -#endif break; default : // must be 0, otherwise it's an error // No blending pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending -#ifndef KOS_GL_COMPATIBILITY pglAlphaFunc(GL_GREATER, 0.5f); -#endif break; } } -#ifndef KOS_GL_COMPATIBILITY if (Xor & PF_NoAlphaTest) { if (PolyFlags & PF_NoAlphaTest) @@ -1144,7 +990,7 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) else pglDisable(GL_POLYGON_OFFSET_FILL); } -#endif + if (Xor&PF_NoDepthTest) { if (PolyFlags & PF_NoDepthTest) @@ -1171,17 +1017,13 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } -#ifdef KOS_GL_COMPATIBILITY - if (Xor&PF_Modulated && !(PolyFlags & PF_Modulated)) - pglColor4f(1.0f, 1.0f, 1.0f, 1.0f); -#else if (Xor&PF_Modulated) { #if defined (__unix__) || defined (UNIXCOMMON) if (oglflags & GLF_NOTEXENV) { if (!(PolyFlags & PF_Modulated)) - pglColor4f(1.0f, 1.0f, 1.0f, 1.0f); + pglColor4ubv(white); } else #endif @@ -1194,7 +1036,6 @@ EXPORT void HWRAPI(SetBlend) (FBITFIELD PolyFlags) pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); } } -#endif if (Xor & PF_Occlude) // depth test but (no) depth write { @@ -1248,125 +1089,17 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) else { // Download a mipmap -#ifdef KOS_GL_COMPATIBILITY - static GLushort tex[2048*2048]; -#else static RGBA_t tex[2048*2048]; -#endif const GLvoid *ptex = tex; INT32 w, h; + GLuint texnum = 0; - //DBG_Printf ("DownloadMipmap %d %x\n",NextTexAvail,pTexInfo->grInfo.data); + pglGenTextures(1, &texnum); + //DBG_Printf ("DownloadMipmap %d %x\n",(INT32)texnum,pTexInfo->grInfo.data); w = pTexInfo->width; h = pTexInfo->height; -#ifdef USE_PALETTED_TEXTURE - if (glColorTableEXT && - (pTexInfo->grInfo.format == GR_TEXFMT_P_8) && - !(pTexInfo->flags & TF_CHROMAKEYED)) - { - // do nothing here. - // Not a problem with MiniGL since we don't use paletted texture - } - else -#endif -#ifdef KOS_GL_COMPATIBILITY - if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) || - (pTexInfo->grInfo.format == GR_TEXFMT_AP_88)) - { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; - INT32 i, j; - - for (j = 0; j < h; j++) - { - for (i = 0; i < w; i++) - { - if ((*pImgData == HWR_PATCHES_CHROMAKEY_COLORINDEX) && - (pTexInfo->flags & TF_CHROMAKEYED)) - { - tex[w*j+i] = 0; - } - else - { - if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88 && !(pTexInfo->flags & TF_CHROMAKEYED)) - tex[w*j+i] = 0; - else - tex[w*j+i] = (myPaletteData[*pImgData].s.alpha>>4)<<12; - - tex[w*j+i] |= (myPaletteData[*pImgData].s.red >>4)<<8; - tex[w*j+i] |= (myPaletteData[*pImgData].s.green>>4)<<4; - tex[w*j+i] |= (myPaletteData[*pImgData].s.blue >>4); - } - - pImgData++; - - if (pTexInfo->grInfo.format == GR_TEXFMT_AP_88) - { - if (!(pTexInfo->flags & TF_CHROMAKEYED)) - tex[w*j+i] |= ((*pImgData)>>4)<<12; - pImgData++; - } - - } - } - } - else if (pTexInfo->grInfo.format == GR_RGBA) - { - // corona test : passed as ARGB 8888, which is not in glide formats - // Hurdler: not used for coronas anymore, just for dynamic lighting - const RGBA_t *pImgData = (const RGBA_t *)pTexInfo->grInfo.data; - INT32 i, j; - - for (j = 0; j < h; j++) - { - for (i = 0; i < w; i++) - { - tex[w*j+i] = (pImgData->s.alpha>>4)<<12; - tex[w*j+i] |= (pImgData->s.red >>4)<<8; - tex[w*j+i] |= (pImgData->s.green>>4)<<4; - tex[w*j+i] |= (pImgData->s.blue >>4); - pImgData++; - } - } - } - else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) - { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; - INT32 i, j; - - for (j = 0; j < h; j++) - { - for (i = 0; i < w; i++) - { - const GLubyte sID = (*pImgData)>>4; - tex[w*j+i] = sID<<8 | sID<<4 | sID; - pImgData++; - tex[w*j+i] |= ((*pImgData)>>4)<<12; - pImgData++; - } - } - } - else if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_8) // Used for fade masks - { - const GLubyte *pImgData = (const GLubyte *)pTexInfo->grInfo.data; - INT32 i, j; - - for (j = 0; j < h; j++) - { - for (i = 0; i < w; i++) - { - tex[w*j+i] = (pImgData>>4)<<12; - tex[w*j+i] |= (255>>4)<<8; - tex[w*j+i] |= (255>>4)<<4; - tex[w*j+i] |= (255>>4); - pImgData++; - } - } - } - else - DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format); -#else if ((pTexInfo->grInfo.format == GR_TEXFMT_P_8) || (pTexInfo->grInfo.format == GR_TEXFMT_AP_88)) { @@ -1449,22 +1182,17 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) } else DBG_Printf ("SetTexture(bad format) %ld\n", pTexInfo->grInfo.format); -#endif - pTexInfo->downloaded = NextTexAvail++; - tex_downloaded = pTexInfo->downloaded; - pglBindTexture(GL_TEXTURE_2D, pTexInfo->downloaded); + // the texture number was already generated by pglGenTextures + pglBindTexture(GL_TEXTURE_2D, texnum); + pTexInfo->downloaded = texnum; + tex_downloaded = texnum; // disable texture filtering on any texture that has holes so there's no dumb borders or blending issues if (pTexInfo->flags & TF_TRANSPARENT) { -#ifdef KOS_GL_COMPATIBILITY - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NONE); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NONE); -#else pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); -#endif } else { @@ -1472,44 +1200,17 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter); } -#ifdef KOS_GL_COMPATIBILITY - pglTexImage2D(GL_TEXTURE_2D, 0, GL_ARGB4444, w, h, 0, GL_ARGB4444, GL_UNSIGNED_BYTE, ptex); -#else -#ifdef MINI_GL_COMPATIBILITY - //if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) - //pglTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); - //else - if (MipMap) - pgluBuild2DMipmaps(GL_TEXTURE_2D, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); - else - pglTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); -#else -#ifdef USE_PALETTED_TEXTURE - //Hurdler: not really supported and not tested recently - if (glColorTableEXT && - (pTexInfo->grInfo.format == GR_TEXFMT_P_8) && - !(pTexInfo->flags & TF_CHROMAKEYED)) - { - glColorTableEXT(GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, palette_tex); - pglTexImage2D(GL_TEXTURE_2D, 0, GL_COLOR_INDEX8_EXT, w, h, 0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, pTexInfo->grInfo.data); - } - else -#endif if (pTexInfo->grInfo.format == GR_TEXFMT_ALPHA_INTENSITY_88) { //pglTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); if (MipMap) { pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); -#ifdef GL_TEXTURE_MIN_LOD pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); -#endif -#ifdef GL_TEXTURE_MAX_LOD if (pTexInfo->flags & TF_TRANSPARENT) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff else pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); -#endif //pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR_MIPMAP_LINEAR); } else @@ -1521,15 +1222,11 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) if (MipMap) { pgluBuild2DMipmaps(GL_TEXTURE_2D, GL_ALPHA, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); -#ifdef GL_TEXTURE_MIN_LOD pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); -#endif -#ifdef GL_TEXTURE_MAX_LOD if (pTexInfo->flags & TF_TRANSPARENT) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff else pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); -#endif //pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_LINEAR_MIPMAP_LINEAR); } else @@ -1541,21 +1238,15 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) { pgluBuild2DMipmaps(GL_TEXTURE_2D, textureformatGL, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ptex); // Control the mipmap level of detail -#ifdef GL_TEXTURE_MIN_LOD pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); // the lower the number, the higer the detail -#endif -#ifdef GL_TEXTURE_MAX_LOD if (pTexInfo->flags & TF_TRANSPARENT) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mippmaps on transparent stuff else pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5); -#endif } else pglTexImage2D(GL_TEXTURE_2D, 0, textureformatGL, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, ptex); } -#endif -#endif if (pTexInfo->flags & TF_WRAPX) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -1572,26 +1263,13 @@ EXPORT void HWRAPI(SetTexture) (FTextureInfo *pTexInfo) pTexInfo->nextmipmap = NULL; if (gr_cachetail) - { // insertion en fin de liste + { // insertion at the tail gr_cachetail->nextmipmap = pTexInfo; gr_cachetail = pTexInfo; } - else // initialisation de la liste + else // initialization of the linked list gr_cachetail = gr_cachehead = pTexInfo; } -#ifdef MINI_GL_COMPATIBILITY - switch (pTexInfo->flags) - { - case 0 : - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - break; - default: - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - break; - } -#endif } @@ -1605,57 +1283,31 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, FBITFIELD PolyFlags) { FUINT i; -#ifndef MINI_GL_COMPATIBILITY FUINT j; -#endif - GLRGBAFloat c = {0,0,0,0}; -#ifdef MINI_GL_COMPATIBILITY - if (PolyFlags & PF_Corona) - PolyFlags &= ~PF_NoDepthTest; -#else if ((PolyFlags & PF_Corona) && (oglflags & GLF_NOZBUFREAD)) PolyFlags &= ~(PF_NoDepthTest|PF_Corona); -#endif SetBlend(PolyFlags); //TODO: inline (#pragma..) // If Modulated, mix the surface colour to the texture if ((CurrentPolyFlags & PF_Modulated) && pSurf) - { - if (pal_col) - { // hack for non-palettized mode - c.red = (const_pal_col.red +byte2float[pSurf->FlatColor.s.red]) /2.0f; - c.green = (const_pal_col.green+byte2float[pSurf->FlatColor.s.green])/2.0f; - c.blue = (const_pal_col.blue +byte2float[pSurf->FlatColor.s.blue]) /2.0f; - c.alpha = byte2float[pSurf->FlatColor.s.alpha]; - } - else - { - c.red = byte2float[pSurf->FlatColor.s.red]; - c.green = byte2float[pSurf->FlatColor.s.green]; - c.blue = byte2float[pSurf->FlatColor.s.blue]; - c.alpha = byte2float[pSurf->FlatColor.s.alpha]; - } - -#ifdef MINI_GL_COMPATIBILITY - pglColor4f(c.red, c.green, c.blue, c.alpha); -#else - pglColor4fv(&c.red); // is in RGBA float format -#endif - } + pglColor4ubv((GLubyte*)&pSurf->FlatColor.s); // this test is added for new coronas' code (without depth buffer) // I think I should do a separate function for drawing coronas, so it will be a little faster -#ifndef MINI_GL_COMPATIBILITY if (PolyFlags & PF_Corona) // check to see if we need to draw the corona { //rem: all 8 (or 8.0f) values are hard coded: it can be changed to a higher value GLfloat buf[8][8]; - GLdouble cx, cy, cz; - GLdouble px = 0.0f, py = 0.0f, pz = -1.0f; + GLfloat cx, cy, cz; + GLfloat px = 0.0f, py = 0.0f, pz = -1.0f; GLfloat scalef = 0.0f; + GLubyte c[4]; + + float alpha; + cx = (pOutVerts[0].x + pOutVerts[2].x) / 2.0f; // we should change the coronas' ... cy = (pOutVerts[0].y + pOutVerts[2].y) / 2.0f; // ... code so its only done once. cz = pOutVerts[0].z; @@ -1691,22 +1343,20 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, if (scalef < 0.05f) return; - c.alpha *= scalef; // change the alpha value (it seems better than changing the size of the corona) - pglColor4fv(&c.red); - } -#endif - if (PolyFlags & PF_MD2) - return; + // GLubyte c[4]; + c[0] = pSurf->FlatColor.s.red; + c[1] = pSurf->FlatColor.s.green; + c[2] = pSurf->FlatColor.s.blue; - pglBegin(GL_TRIANGLE_FAN); - for (i = 0; i < iNumPts; i++) - { - pglTexCoord2f(pOutVerts[i].sow, pOutVerts[i].tow); - //Hurdler: test code: -pOutVerts[i].z => pOutVerts[i].z - pglVertex3f(pOutVerts[i].x, pOutVerts[i].y, pOutVerts[i].z); - //pglVertex3f(pOutVerts[i].x, pOutVerts[i].y, -pOutVerts[i].z); + alpha = byte2float[pSurf->FlatColor.s.alpha]; + alpha *= scalef; // change the alpha value (it seems better than changing the size of the corona) + c[3] = (unsigned char)(alpha * 255); + pglColor4ubv(c); } - pglEnd(); + + pglVertexPointer(3, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].x); + pglTexCoordPointer(2, GL_FLOAT, sizeof(FOutVector), &pOutVerts[0].sow); + pglDrawArrays(GL_TRIANGLE_FAN, 0, iNumPts); if (PolyFlags & PF_RemoveYWrap) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); @@ -1718,6 +1368,256 @@ EXPORT void HWRAPI(DrawPolygon) (FSurfaceInfo *pSurf, Clamp2D(GL_TEXTURE_WRAP_T); } +typedef struct vbo_vertex_s +{ + float x, y, z; + float u, v; + unsigned char r, g, b, a; +} vbo_vertex_t; + +typedef struct +{ + int mode; + int vertexcount; + int vertexindex; + int use_texture; +} GLSkyLoopDef; + +typedef struct +{ + unsigned int id; + int rows, columns; + int loopcount; + GLSkyLoopDef *loops; + vbo_vertex_t *data; +} GLSkyVBO; + +static const boolean gl_ext_arb_vertex_buffer_object = true; + +#define NULL_VBO_VERTEX ((vbo_vertex_t*)NULL) +#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &vbo->data[0].x) +#define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &vbo->data[0].u) +#define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &vbo->data[0].r) + +// The texture offset to be applied to the texture coordinates in SkyVertex(). +static int rows, columns; +static signed char yflip; +static int texw, texh; +static boolean foglayer; +static float delta = 0.0f; + +static int gl_sky_detail = 16; + +static INT32 lasttex = -1; + +#define MAP_COEFF 128.0f + +static void SkyVertex(vbo_vertex_t *vbo, int r, int c) +{ + const float radians = (float)(M_PIl / 180.0f); + const float scale = 10000.0f; + const float maxSideAngle = 60.0f; + + float topAngle = (c / (float)columns * 360.0f); + float sideAngle = (maxSideAngle * (rows - r) / rows); + float height = (float)(sin(sideAngle * radians)); + float realRadius = (float)(scale * cos(sideAngle * radians)); + float x = (float)(realRadius * cos(topAngle * radians)); + float y = (!yflip) ? scale * height : -scale * height; + float z = (float)(realRadius * sin(topAngle * radians)); + float timesRepeat = (4 * (256.0f / texw)); + if (fpclassify(timesRepeat) == FP_ZERO) + timesRepeat = 1.0f; + + if (!foglayer) + { + vbo->r = 255; + vbo->g = 255; + vbo->b = 255; + vbo->a = (r == 0 ? 0 : 255); + + // And the texture coordinates. + vbo->u = (-timesRepeat * c / (float)columns); + if (!yflip) // Flipped Y is for the lower hemisphere. + vbo->v = (r / (float)rows) + 0.5f; + else + vbo->v = 1.0f + ((rows - r) / (float)rows) + 0.5f; + } + + if (r != 4) + { + y += 300.0f; + } + + // And finally the vertex. + vbo->x = x; + vbo->y = y + delta; + vbo->z = z; +} + +static GLSkyVBO sky_vbo; + +static void gld_BuildSky(int row_count, int col_count) +{ + int c, r; + vbo_vertex_t *vertex_p; + int vertex_count = 2 * row_count * (col_count * 2 + 2) + col_count * 2; + + GLSkyVBO *vbo = &sky_vbo; + + if ((vbo->columns != col_count) || (vbo->rows != row_count)) + { + free(vbo->loops); + free(vbo->data); + memset(vbo, 0, sizeof(&vbo)); + } + + if (!vbo->data) + { + memset(vbo, 0, sizeof(&vbo)); + vbo->loops = malloc((row_count * 2 + 2) * sizeof(vbo->loops[0])); + // create vertex array + vbo->data = malloc(vertex_count * sizeof(vbo->data[0])); + } + + vbo->columns = col_count; + vbo->rows = row_count; + + vertex_p = &vbo->data[0]; + vbo->loopcount = 0; + + for (yflip = 0; yflip < 2; yflip++) + { + vbo->loops[vbo->loopcount].mode = GL_TRIANGLE_FAN; + vbo->loops[vbo->loopcount].vertexindex = vertex_p - &vbo->data[0]; + vbo->loops[vbo->loopcount].vertexcount = col_count; + vbo->loops[vbo->loopcount].use_texture = false; + vbo->loopcount++; + + delta = 0.0f; + foglayer = true; + for (c = 0; c < col_count; c++) + { + SkyVertex(vertex_p, 1, c); + vertex_p->r = 255; + vertex_p->g = 255; + vertex_p->b = 255; + vertex_p->a = 255; + vertex_p++; + } + foglayer = false; + + delta = (yflip ? 5.0f : -5.0f) / MAP_COEFF; + + for (r = 0; r < row_count; r++) + { + vbo->loops[vbo->loopcount].mode = GL_TRIANGLE_STRIP; + vbo->loops[vbo->loopcount].vertexindex = vertex_p - &vbo->data[0]; + vbo->loops[vbo->loopcount].vertexcount = 2 * col_count + 2; + vbo->loops[vbo->loopcount].use_texture = true; + vbo->loopcount++; + + for (c = 0; c <= col_count; c++) + { + SkyVertex(vertex_p++, r + (yflip ? 1 : 0), (c ? c : 0)); + SkyVertex(vertex_p++, r + (yflip ? 0 : 1), (c ? c : 0)); + } + } + } +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +static void RenderDome(INT32 skytexture) +{ + int i, j; + int vbosize; + GLSkyVBO *vbo = &sky_vbo; + + rows = 4; + columns = 4 * gl_sky_detail; + + vbosize = 2 * rows * (columns * 2 + 2) + columns * 2; + + // Build the sky dome! Yes! + if (lasttex != skytexture) + { + // delete VBO when already exists + if (gl_ext_arb_vertex_buffer_object) + { + if (vbo->id) + pglDeleteBuffers(1, &vbo->id); + } + + lasttex = skytexture; + gld_BuildSky(rows, columns); + + if (gl_ext_arb_vertex_buffer_object) + { + // generate a new VBO and get the associated ID + pglGenBuffers(1, &vbo->id); + + // bind VBO in order to use + pglBindBuffer(GL_ARRAY_BUFFER, vbo->id); + + // upload data to VBO + pglBufferData(GL_ARRAY_BUFFER, vbosize * sizeof(vbo->data[0]), vbo->data, GL_STATIC_DRAW); + } + } + + // bind VBO in order to use + if (gl_ext_arb_vertex_buffer_object) + pglBindBuffer(GL_ARRAY_BUFFER, vbo->id); + + // activate and specify pointers to arrays + pglVertexPointer(3, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_x); + pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_u); + pglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vbo->data[0]), sky_vbo_r); + + // activate color arrays + pglEnableClientState(GL_COLOR_ARRAY); + + // set transforms + pglScalef(1.0f, (float)texh / 230.0f, 1.0f); + pglRotatef(270.0f, 0.0f, 1.0f, 0.0f); + + for (j = 0; j < 2; j++) + { + for (i = 0; i < vbo->loopcount; i++) + { + GLSkyLoopDef *loop = &vbo->loops[i]; + + if (j == 0 ? loop->use_texture : !loop->use_texture) + continue; + + pglDrawArrays(loop->mode, loop->vertexindex, loop->vertexcount); + } + } + + pglScalef(1.0f, 1.0f, 1.0f); + pglColor4ubv(white); + + // bind with 0, so, switch back to normal pointer operation + if (gl_ext_arb_vertex_buffer_object) + pglBindBuffer(GL_ARRAY_BUFFER, 0); + + // deactivate color array + pglDisableClientState(GL_COLOR_ARRAY); +} + +EXPORT void HWRAPI(RenderSkyDome) (INT32 tex, INT32 texture_width, INT32 texture_height, FTransform transform) +{ + SetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated); + SetTransform(&transform); + texw = texture_width; + texh = texture_height; + RenderDome(tex); + SetBlend(0); +} // ========================================================================== // @@ -1726,25 +1626,9 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) { switch (IdState) { - -#if 0 - case 77: - { - //08/01/00: Hurdler this is a test for mirror - if (!Value) - ClearBuffer(false, true, 0); // clear depth buffer + case HWD_SET_MODEL_LIGHTING: + model_lighting = Value; break; - } -#endif - - case HWD_SET_PALETTECOLOR: - { - pal_col = Value; - const_pal_col.blue = byte2float[((Value>>16)&0xff)]; - const_pal_col.green = byte2float[((Value>>8)&0xff)]; - const_pal_col.red = byte2float[((Value)&0xff)]; - break; - } case HWD_SET_FOG_COLOR: { @@ -1757,6 +1641,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) pglFogfv(GL_FOG_COLOR, fogcolor); break; } + case HWD_SET_FOG_DENSITY: pglFogf(GL_FOG_DENSITY, Value*1200/(500*1000000.0f)); break; @@ -1787,42 +1672,9 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) pglDisable(GL_FOG); break; - case HWD_SET_POLYGON_SMOOTH: -#ifdef KOS_GL_COMPATIBILITY // GL_POLYGON_SMOOTH_HINT - if (Value) - pglHint(GL_POLYGON_SMOOTH_HINT,GL_NICEST); - else - pglHint(GL_POLYGON_SMOOTH_HINT,GL_FASTEST); -#else - if (Value) - pglEnable(GL_POLYGON_SMOOTH); - else - pglDisable(GL_POLYGON_SMOOTH); -#endif - break; - case HWD_SET_TEXTUREFILTERMODE: switch (Value) { -#ifdef KOS_GL_COMPATIBILITY - case HWD_SET_TEXTUREFILTER_TRILINEAR: - case HWD_SET_TEXTUREFILTER_BILINEAR: - min_filter = mag_filter = GL_FILTER_BILINEAR; - break; - case HWD_SET_TEXTUREFILTER_POINTSAMPLED: - min_filter = mag_filter = GL_FILTER_NONE; - case HWD_SET_TEXTUREFILTER_MIXED1: - min_filter = GL_FILTER_NONE; - mag_filter = GL_LINEAR; - case HWD_SET_TEXTUREFILTER_MIXED2: - min_filter = GL_LINEAR; - mag_filter = GL_FILTER_NONE; - break; - case HWD_SET_TEXTUREFILTER_MIXED3: - min_filter = GL_FILTER_BILINEAR; - mag_filter = GL_FILTER_NONE; - break; -#elif !defined (MINI_GL_COMPATIBILITY) case HWD_SET_TEXTUREFILTER_TRILINEAR: min_filter = GL_LINEAR_MIPMAP_LINEAR; mag_filter = GL_LINEAR; @@ -1851,14 +1703,9 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) mag_filter = GL_NEAREST; MipMap = GL_TRUE; break; -#endif default: -#ifdef KOS_GL_COMPATIBILITY - min_filter = mag_filter = GL_FILTER_NONE; -#else mag_filter = GL_LINEAR; min_filter = GL_NEAREST; -#endif } if (!pgluBuild2DMipmaps) { @@ -1879,20 +1726,226 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value) } } -static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, INT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) +static float *vertBuffer = NULL; +static float *normBuffer = NULL; +static size_t lerpBufferSize = 0; +static short *vertTinyBuffer = NULL; +static char *normTinyBuffer = NULL; +static size_t lerpTinyBufferSize = 0; + +// Static temporary buffer for doing frame interpolation +// 'size' is the vertex size +static void AllocLerpBuffer(size_t size) +{ + if (lerpBufferSize >= size) + return; + + if (vertBuffer != NULL) + free(vertBuffer); + + if (normBuffer != NULL) + free(normBuffer); + + lerpBufferSize = size; + vertBuffer = malloc(lerpBufferSize); + normBuffer = malloc(lerpBufferSize); +} + +// Static temporary buffer for doing frame interpolation +// 'size' is the vertex size +static void AllocLerpTinyBuffer(size_t size) +{ + if (lerpTinyBufferSize >= size) + return; + + if (vertTinyBuffer != NULL) + free(vertTinyBuffer); + + if (normTinyBuffer != NULL) + free(normTinyBuffer); + + lerpTinyBufferSize = size; + vertTinyBuffer = malloc(lerpTinyBufferSize); + normTinyBuffer = malloc(lerpTinyBufferSize / 2); +} + +#ifndef GL_STATIC_DRAW +#define GL_STATIC_DRAW 0x88E4 +#endif + +#ifndef GL_ARRAY_BUFFER +#define GL_ARRAY_BUFFER 0x8892 +#endif + +static void CreateModelVBO(mesh_t *mesh, mdlframe_t *frame) +{ + int bufferSize = sizeof(vbo64_t)*mesh->numTriangles * 3; + vbo64_t *buffer = (vbo64_t*)malloc(bufferSize); + vbo64_t *bufPtr = buffer; + + float *vertPtr = frame->vertices; + float *normPtr = frame->normals; + float *tanPtr = frame->tangents; + float *uvPtr = mesh->uvs; + float *lightPtr = mesh->lightuvs; + char *colorPtr = frame->colors; + + int i; + for (i = 0; i < mesh->numTriangles * 3; i++) + { + bufPtr->x = *vertPtr++; + bufPtr->y = *vertPtr++; + bufPtr->z = *vertPtr++; + + bufPtr->nx = *normPtr++; + bufPtr->ny = *normPtr++; + bufPtr->nz = *normPtr++; + + bufPtr->s0 = *uvPtr++; + bufPtr->t0 = *uvPtr++; + + if (tanPtr != NULL) + { + bufPtr->tan0 = *tanPtr++; + bufPtr->tan1 = *tanPtr++; + bufPtr->tan2 = *tanPtr++; + } + + if (lightPtr != NULL) + { + bufPtr->s1 = *lightPtr++; + bufPtr->t1 = *lightPtr++; + } + + if (colorPtr) + { + bufPtr->r = *colorPtr++; + bufPtr->g = *colorPtr++; + bufPtr->b = *colorPtr++; + bufPtr->a = *colorPtr++; + } + else + { + bufPtr->r = 255; + bufPtr->g = 255; + bufPtr->b = 255; + bufPtr->a = 255; + } + + bufPtr++; + } + + pglGenBuffers(1, &frame->vboID); + pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID); + pglBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW); + free(buffer); + + // Don't leave the array buffer bound to the model, + // since this is called mid-frame + pglBindBuffer(GL_ARRAY_BUFFER, 0); +} + +static void CreateModelVBOTiny(mesh_t *mesh, tinyframe_t *frame) +{ + int bufferSize = sizeof(vbotiny_t)*mesh->numTriangles * 3; + vbotiny_t *buffer = (vbotiny_t*)malloc(bufferSize); + vbotiny_t *bufPtr = buffer; + + short *vertPtr = frame->vertices; + char *normPtr = frame->normals; + float *uvPtr = mesh->uvs; + char *tanPtr = frame->tangents; + + int i; + for (i = 0; i < mesh->numVertices; i++) + { + bufPtr->x = *vertPtr++; + bufPtr->y = *vertPtr++; + bufPtr->z = *vertPtr++; + + bufPtr->nx = *normPtr++; + bufPtr->ny = *normPtr++; + bufPtr->nz = *normPtr++; + + bufPtr->s0 = *uvPtr++; + bufPtr->t0 = *uvPtr++; + + if (tanPtr) + { + bufPtr->tanx = *tanPtr++; + bufPtr->tany = *tanPtr++; + bufPtr->tanz = *tanPtr++; + } + + bufPtr++; + } + + pglGenBuffers(1, &frame->vboID); + pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID); + pglBufferData(GL_ARRAY_BUFFER, bufferSize, buffer, GL_STATIC_DRAW); + free(buffer); + + // Don't leave the array buffer bound to the model, + // since this is called mid-frame + pglBindBuffer(GL_ARRAY_BUFFER, 0); +} + +EXPORT void HWRAPI(CreateModelVBOs) (model_t *model) +{ + int i; + for (i = 0; i < model->numMeshes; i++) + { + mesh_t *mesh = &model->meshes[i]; + + if (mesh->frames) + { + int j; + for (j = 0; j < model->meshes[i].numFrames; j++) + { + mdlframe_t *frame = &mesh->frames[j]; + if (frame->vboID) + pglDeleteBuffers(1, &frame->vboID); + frame->vboID = 0; + CreateModelVBO(mesh, frame); + } + } + else if (mesh->tinyframes) + { + int j; + for (j = 0; j < model->meshes[i].numFrames; j++) + { + tinyframe_t *frame = &mesh->tinyframes[j]; + if (frame->vboID) + pglDeleteBuffers(1, &frame->vboID); + frame->vboID = 0; + CreateModelVBOTiny(mesh, frame); + } + } + } +} + +#define BUFFER_OFFSET(i) ((char*)NULL + (i)) + +static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) { - INT32 val, count, pindex; - GLfloat s, t; GLfloat ambient[4]; GLfloat diffuse[4]; float pol = 0.0f; - float scalex = scale, scaley = scale, scalez = scale; + float scalex, scaley, scalez; + + boolean useTinyFrames; + + int i; // Because Otherwise, scaling the screen negatively vertically breaks the lighting -#ifndef KOS_GL_COMPATIBILITY GLfloat LightPos[] = {0.0f, 1.0f, 0.0f, 0.0f}; -#endif + + // Affect input model scaling + scale *= 0.5f; + scalex = scale; + scaley = scale; + scalez = scale; if (duration != 0 && duration != -1 && tics != -1) // don't interpolate if instantaneous or infinite in length { @@ -1927,7 +1980,21 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, } pglEnable(GL_CULL_FACE); + pglEnable(GL_NORMALIZE); +#ifdef USE_FTRANSFORM_MIRROR + // flipped is if the object is flipped + // pos->flip is if the screen is flipped vertically + // pos->mirror is if the screen is flipped horizontally + // XOR all the flips together to figure out what culling to use! + { + boolean reversecull = (flipped ^ pos->flip ^ pos->mirror); + if (reversecull) + pglCullFace(GL_FRONT); + else + pglCullFace(GL_BACK); + } +#else // pos->flip is if the screen is flipped too if (flipped != pos->flip) // If either are active, but not both, invert the model's culling { @@ -1937,19 +2004,27 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, { pglCullFace(GL_BACK); } - -#ifndef KOS_GL_COMPATIBILITY - pglLightfv(GL_LIGHT0, GL_POSITION, LightPos); #endif - pglShadeModel(GL_SMOOTH); + if (model_lighting) + { + pglLightfv(GL_LIGHT0, GL_POSITION, LightPos); + pglShadeModel(GL_SMOOTH); + } + if (color) { #ifdef GL_LIGHT_MODEL_AMBIENT - pglEnable(GL_LIGHTING); - pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); - pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + if (model_lighting) + { + pglEnable(GL_LIGHTING); + pglMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); + pglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + } + else #endif + pglColor4ubv((GLubyte*)color); + if (color[3] < 255) SetBlend(PF_Translucent|PF_Modulated|PF_Clip); else @@ -1961,159 +2036,232 @@ static void DrawMD2Ex(INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, pglTranslatef(pos->x, pos->z, pos->y); if (flipped) scaley = -scaley; + +#ifdef USE_FTRANSFORM_ANGLEZ + pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); // rotate by slope from Kart +#endif pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); - pglRotatef(pos->anglex, -1.0f, 0.0f, 0.0f); + pglRotatef(pos->anglex, 1.0f, 0.0f, 0.0f); - val = *gl_cmd_buffer++; - - while (val != 0) + if (pos->roll) { - if (val < 0) - { - pglBegin(GL_TRIANGLE_FAN); - count = -val; - } - else - { - pglBegin(GL_TRIANGLE_STRIP); - count = val; - } + float roll = (1.0f * pos->rollflip); + pglTranslatef(pos->centerx, pos->centery, 0); + if (pos->rotaxis == 2) // Z + pglRotatef(pos->rollangle, 0.0f, 0.0f, roll); + else if (pos->rotaxis == 1) // Y + pglRotatef(pos->rollangle, 0.0f, roll, 0.0f); + else // X + pglRotatef(pos->rollangle, roll, 0.0f, 0.0f); + pglTranslatef(-pos->centerx, -pos->centery, 0); + } - while (count--) - { - s = *(float *) gl_cmd_buffer++; - t = *(float *) gl_cmd_buffer++; - pindex = *gl_cmd_buffer++; + pglScalef(scalex, scaley, scalez); - pglTexCoord2f(s, t); + useTinyFrames = model->meshes[0].tinyframes != NULL; + + if (useTinyFrames) + pglScalef(1 / 64.0f, 1 / 64.0f, 1 / 64.0f); + + pglEnableClientState(GL_NORMAL_ARRAY); + + for (i = 0; i < model->numMeshes; i++) + { + mesh_t *mesh = &model->meshes[i]; + + if (useTinyFrames) + { + tinyframe_t *frame = &mesh->tinyframes[frameIndex % mesh->numFrames]; + tinyframe_t *nextframe = NULL; + + if (nextFrameIndex != -1) + nextframe = &mesh->tinyframes[nextFrameIndex % mesh->numFrames]; if (!nextframe || fpclassify(pol) == FP_ZERO) { - pglNormal3f(frame->vertices[pindex].normal[0], - frame->vertices[pindex].normal[1], - frame->vertices[pindex].normal[2]); + pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID); + pglVertexPointer(3, GL_SHORT, sizeof(vbotiny_t), BUFFER_OFFSET(0)); + pglNormalPointer(GL_BYTE, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short)*3)); + pglTexCoordPointer(2, GL_FLOAT, sizeof(vbotiny_t), BUFFER_OFFSET(sizeof(short) * 3 + sizeof(char) * 6)); - pglVertex3f(frame->vertices[pindex].vertex[0]*scalex/2.0f, - frame->vertices[pindex].vertex[1]*scaley/2.0f, - frame->vertices[pindex].vertex[2]*scalez/2.0f); + pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices); + pglBindBuffer(GL_ARRAY_BUFFER, 0); } else { - // Interpolate - float px1 = frame->vertices[pindex].vertex[0]*scalex/2.0f; - float px2 = nextframe->vertices[pindex].vertex[0]*scalex/2.0f; - float py1 = frame->vertices[pindex].vertex[1]*scaley/2.0f; - float py2 = nextframe->vertices[pindex].vertex[1]*scaley/2.0f; - float pz1 = frame->vertices[pindex].vertex[2]*scalez/2.0f; - float pz2 = nextframe->vertices[pindex].vertex[2]*scalez/2.0f; - float nx1 = frame->vertices[pindex].normal[0]; - float nx2 = nextframe->vertices[pindex].normal[0]; - float ny1 = frame->vertices[pindex].normal[1]; - float ny2 = nextframe->vertices[pindex].normal[1]; - float nz1 = frame->vertices[pindex].normal[2]; - float nz2 = nextframe->vertices[pindex].normal[2]; + short *vertPtr; + char *normPtr; + int j; - pglNormal3f((nx1 + pol * (nx2 - nx1)), - (ny1 + pol * (ny2 - ny1)), - (nz1 + pol * (nz2 - nz1))); - pglVertex3f((px1 + pol * (px2 - px1)), - (py1 + pol * (py2 - py1)), - (pz1 + pol * (pz2 - pz1))); + // Dangit, I soooo want to do this in a GLSL shader... + AllocLerpTinyBuffer(mesh->numVertices * sizeof(short) * 3); + vertPtr = vertTinyBuffer; + normPtr = normTinyBuffer; + j = 0; + + for (j = 0; j < mesh->numVertices * 3; j++) + { + // Interpolate + *vertPtr++ = (short)(frame->vertices[j] + (pol * (nextframe->vertices[j] - frame->vertices[j]))); + *normPtr++ = (char)(frame->normals[j] + (pol * (nextframe->normals[j] - frame->normals[j]))); + } + + pglVertexPointer(3, GL_SHORT, 0, vertTinyBuffer); + pglNormalPointer(GL_BYTE, 0, normTinyBuffer); + pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs); + pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices); } } + else + { + mdlframe_t *frame = &mesh->frames[frameIndex % mesh->numFrames]; + mdlframe_t *nextframe = NULL; - pglEnd(); + if (nextFrameIndex != -1) + nextframe = &mesh->frames[nextFrameIndex % mesh->numFrames]; - val = *gl_cmd_buffer++; + if (!nextframe || fpclassify(pol) == FP_ZERO) + { + // Zoom! Take advantage of just shoving the entire arrays to the GPU. +/* pglVertexPointer(3, GL_FLOAT, 0, frame->vertices); + pglNormalPointer(GL_FLOAT, 0, frame->normals); + pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs); + pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3);*/ + + pglBindBuffer(GL_ARRAY_BUFFER, frame->vboID); + pglVertexPointer(3, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(0)); + pglNormalPointer(GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 3)); + pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo64_t), BUFFER_OFFSET(sizeof(float) * 6)); + + pglDrawArrays(GL_TRIANGLES, 0, mesh->numTriangles * 3); + // No tinyframes, no mesh indices + //pglDrawElements(GL_TRIANGLES, mesh->numTriangles * 3, GL_UNSIGNED_SHORT, mesh->indices); + pglBindBuffer(GL_ARRAY_BUFFER, 0); + } + else + { + float *vertPtr; + float *normPtr; + int j = 0; + + // Dangit, I soooo want to do this in a GLSL shader... + AllocLerpBuffer(mesh->numVertices * sizeof(float) * 3); + vertPtr = vertBuffer; + normPtr = normBuffer; + //int j = 0; + + for (j = 0; j < mesh->numVertices * 3; j++) + { + // Interpolate + *vertPtr++ = frame->vertices[j] + (pol * (nextframe->vertices[j] - frame->vertices[j])); + *normPtr++ = frame->normals[j] + (pol * (nextframe->normals[j] - frame->normals[j])); + } + + pglVertexPointer(3, GL_FLOAT, 0, vertBuffer); + pglNormalPointer(GL_FLOAT, 0, normBuffer); + pglTexCoordPointer(2, GL_FLOAT, 0, mesh->uvs); + pglDrawArrays(GL_TRIANGLES, 0, mesh->numVertices); + } + } } + + pglDisableClientState(GL_NORMAL_ARRAY); + pglPopMatrix(); // should be the same as glLoadIdentity if (color) pglDisable(GL_LIGHTING); pglShadeModel(GL_FLAT); pglDisable(GL_CULL_FACE); + pglDisable(GL_NORMALIZE); } // -----------------+ // HWRAPI DrawMD2 : Draw an MD2 model with glcommands // -----------------+ -EXPORT void HWRAPI(DrawMD2i) (INT32 *gl_cmd_buffer, md2_frame_t *frame, INT32 duration, INT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) +EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) { - DrawMD2Ex(gl_cmd_buffer, frame, duration, tics, nextframe, pos, scale, flipped, color); + DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, scale, flipped, color); } -EXPORT void HWRAPI(DrawMD2) (INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale) -{ - DrawMD2Ex(gl_cmd_buffer, frame, 0, 0, NULL, pos, scale, false, NULL); -} - - // -----------------+ // SetTransform : // -----------------+ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) { - static INT32 special_splitscreen; + static boolean special_splitscreen; + float used_fov; pglLoadIdentity(); if (stransform) { - boolean fovx90; - // keep a trace of the transformation for md2 - memcpy(&md2_transform, stransform, sizeof (md2_transform)); - + used_fov = stransform->fovxangle; +#ifdef USE_FTRANSFORM_MIRROR + // mirroring from Kart + if (stransform->mirror) + pglScalef(-stransform->scalex, stransform->scaley, -stransform->scalez); + else +#endif if (stransform->flip) pglScalef(stransform->scalex, -stransform->scaley, -stransform->scalez); else pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez); + if (stransform->roll) + pglRotatef(stransform->rollangle, 0.0f, 0.0f, 1.0f); pglRotatef(stransform->anglex , 1.0f, 0.0f, 0.0f); pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); - pglMatrixMode(GL_PROJECTION); - pglLoadIdentity(); - fovx90 = stransform->fovxangle > 0.0f && fabsf(stransform->fovxangle - 90.0f) < 0.5f; - special_splitscreen = (stransform->splitscreen && fovx90); - if (special_splitscreen) - GLPerspective(53.13l, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5) - else - GLPerspective(stransform->fovxangle, ASPECT_RATIO); -#ifndef MINI_GL_COMPATIBILITY - pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) -#endif - pglMatrixMode(GL_MODELVIEW); + special_splitscreen = stransform->splitscreen; } else { + used_fov = fov; pglScalef(1.0f, 1.0f, -1.0f); - - pglMatrixMode(GL_PROJECTION); - pglLoadIdentity(); - if (special_splitscreen) - GLPerspective(53.13l, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5) - else - //Hurdler: is "fov" correct? - GLPerspective(fov, ASPECT_RATIO); -#ifndef MINI_GL_COMPATIBILITY - pglGetDoublev(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) -#endif - pglMatrixMode(GL_MODELVIEW); } -#ifndef MINI_GL_COMPATIBILITY - pglGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer) -#endif + pglMatrixMode(GL_PROJECTION); + pglLoadIdentity(); + + if (special_splitscreen) + { + used_fov = atan(tan(used_fov*M_PI/360)*0.8)*360/M_PI; + GLPerspective(used_fov, 2*ASPECT_RATIO); + } + else + GLPerspective(used_fov, ASPECT_RATIO); + + pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) + pglMatrixMode(GL_MODELVIEW); + + pglGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer) } EXPORT INT32 HWRAPI(GetTextureUsed) (void) { - FTextureInfo* tmp = gr_cachehead; - INT32 res = 0; + FTextureInfo *tmp = gr_cachehead; + INT32 res = 0; while (tmp) { - res += tmp->height*tmp->width*(screen_depth/8); + // Figure out the correct bytes-per-pixel for this texture + // I don't know which one the game actually _uses_ but this + // follows format2bpp in hw_cache.c + int bpp = 1; + int format = tmp->grInfo.format; + if (format == GR_RGBA) + bpp = 4; + else if (format == GR_TEXFMT_RGB_565 + || format == GR_TEXFMT_ARGB_1555 + || format == GR_TEXFMT_ARGB_4444 + || format == GR_TEXFMT_ALPHA_INTENSITY_88 + || format == GR_TEXFMT_AP_88) + bpp = 2; + + // Add it up! + res += tmp->height*tmp->width*bpp; tmp = tmp->nextmipmap; } + return res; } @@ -2122,7 +2270,6 @@ EXPORT INT32 HWRAPI(GetRenderVersion) (void) return VERSION; } -#ifdef SHUFFLE EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) { INT32 x, y; @@ -2130,6 +2277,14 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) float xfix, yfix; INT32 texsize = 2048; + const float blackBack[16] = + { + -16.0f, -16.0f, 6.0f, + -16.0f, 16.0f, 6.0f, + 16.0f, 16.0f, 6.0f, + 16.0f, -16.0f, 6.0f + }; + // Use a power of two texture, dammit if(screen_width <= 1024) texsize = 1024; @@ -2142,47 +2297,66 @@ EXPORT void HWRAPI(PostImgRedraw) (float points[SCREENVERTS][SCREENVERTS][2]) pglDisable(GL_DEPTH_TEST); pglDisable(GL_BLEND); - pglBegin(GL_QUADS); - // Draw a black square behind the screen texture, - // so nothing shows through the edges - pglColor4f(1.0f, 1.0f, 1.0f, 1.0f); - pglVertex3f(-16.0f, -16.0f, 6.0f); - pglVertex3f(-16.0f, 16.0f, 6.0f); - pglVertex3f(16.0f, 16.0f, 6.0f); - pglVertex3f(16.0f, -16.0f, 6.0f); + // const float blackBack[16] - for(x=0;x #include -#ifndef MINI_GL_COMPATIBILITY #ifdef STATIC_OPENGL // Because of the 1.3 functions, you'll need GLext to compile it if static #define GL_GLEXT_PROTOTYPES #include #endif #endif -#endif #define _CREATE_DLL_ // necessary for Unix AND Windows #include "../../doomdef.h" @@ -73,7 +71,6 @@ extern FILE *gllogstream; #endif #ifndef DRIVER_STRING -// #define USE_PALETTED_TEXTURE #define DRIVER_STRING "HWRAPI Init(): SRB2 OpenGL renderer" // Tails #endif @@ -91,10 +88,6 @@ int SetupPixelFormat(INT32 WantColorBits, INT32 WantStencilBits, INT32 WantDepth void SetModelView(GLint w, GLint h); void SetStates(void); FUNCMATH float byteasfloat(UINT8 fbyte); -#ifdef USE_PALETTED_TEXTURE -extern PFNGLCOLORTABLEEXTPROC glColorTableEXT; -extern GLubyte palette_tex[256*3]; -#endif #ifndef GL_EXT_texture_filter_anisotropic #define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE @@ -120,6 +113,10 @@ typedef void (APIENTRY * PFNglGetIntegerv) (GLenum pname, GLint *params); extern PFNglGetIntegerv pglGetIntegerv; typedef const GLubyte* (APIENTRY * PFNglGetString) (GLenum name); extern PFNglGetString pglGetString; +#if 0 +typedef void (APIENTRY * PFNglEnableClientState) (GLenum cap); // redefined in r_opengl.c +static PFNglEnableClientState pglEnableClientState; +#endif #endif // ========================================================================== diff --git a/src/hardware/r_opengl/r_vbo.h b/src/hardware/r_opengl/r_vbo.h new file mode 100644 index 000000000..ca1a974da --- /dev/null +++ b/src/hardware/r_opengl/r_vbo.h @@ -0,0 +1,52 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ +#ifndef _R_VBO_H_ +#define _R_VBO_H_ + +typedef struct +{ + float x, y, z; // Vertex + float nx, ny, nz; // Normal + float s0, t0; // Texcoord0 +} vbo32_t; + +typedef struct +{ + float x, y, z; // Vertex + float s0, t0; // Texcoord0 + unsigned char r, g, b, a; // Color + float pad[2]; // Pad +} vbo2d32_t; + +typedef struct +{ + float x, y; // Vertex + float s0, t0; // Texcoord0 +} vbofont_t; + +typedef struct +{ + short x, y, z; // Vertex + char nx, ny, nz; // Normal + char tanx, tany, tanz; // Tangent + float s0, t0; // Texcoord0 +} vbotiny_t; + +typedef struct +{ + float x, y, z; // Vertex + float nx, ny, nz; // Normal + float s0, t0; // Texcoord0 + float s1, t1; // Texcoord1 + float s2, t2; // Texcoord2 + float tan0, tan1, tan2; // Tangent + unsigned char r, g, b, a; // Color +} vbo64_t; + +#endif diff --git a/src/hardware/u_list.c b/src/hardware/u_list.c new file mode 100644 index 000000000..dc49a74e7 --- /dev/null +++ b/src/hardware/u_list.c @@ -0,0 +1,230 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#include "u_list.h" +#include "../z_zone.h" + +// Utility for managing +// structures in a linked +// list. +// +// Struct must have "next" and "prev" pointers +// as its first two variables. +// + +// +// ListAdd +// +// Adds an item to the list +// +void ListAdd(void *pItem, listitem_t **itemHead) +{ + listitem_t *item = (listitem_t*)pItem; + + if (*itemHead == NULL) + { + *itemHead = item; + (*itemHead)->prev = (*itemHead)->next = NULL; + } + else + { + listitem_t *tail; + tail = *itemHead; + + while (tail->next != NULL) + tail = tail->next; + + tail->next = item; + + tail->next->prev = tail; + + item->next = NULL; + } +} + +// +// ListAddFront +// +// Adds an item to the front of the list +// (This is much faster) +// +void ListAddFront(void *pItem, listitem_t **itemHead) +{ + listitem_t *item = (listitem_t*)pItem; + + if (*itemHead == NULL) + { + *itemHead = item; + (*itemHead)->prev = (*itemHead)->next = NULL; + } + else + { + (*itemHead)->prev = item; + item->next = (*itemHead); + item->prev = NULL; + *itemHead = item; + } +} + +// +// ListAddBefore +// +// Adds an item before the item specified in the list +// +void ListAddBefore(void *pItem, void *pSpot, listitem_t **itemHead) +{ + listitem_t *item = (listitem_t*)pItem; + listitem_t *spot = (listitem_t*)pSpot; + + listitem_t *prev = spot->prev; + + if (!prev) + ListAddFront(pItem, itemHead); + else + { + item->next = spot; + spot->prev = item; + item->prev = prev; + prev->next = item; + } +} + +// +// ListAddAfter +// +// Adds an item after the item specified in the list +// +void ListAddAfter(void *pItem, void *pSpot, listitem_t **itemHead) +{ + listitem_t *item = (listitem_t*)pItem; + listitem_t *spot = (listitem_t*)pSpot; + + listitem_t *next = spot->next; + + if (!next) + ListAdd(pItem, itemHead); + else + { + item->prev = spot; + spot->next = item; + item->next = next; + next->prev = item; + } +} + +// +// ListRemove +// +// Take an item out of the list and free its memory. +// +void ListRemove(void *pItem, listitem_t **itemHead) +{ + listitem_t *item = (listitem_t*)pItem; + + if (item == *itemHead) // Start of list + { + *itemHead = item->next; + + if (*itemHead) + (*itemHead)->prev = NULL; + } + else if (item->next == NULL) // end of list + { + item->prev->next = NULL; + } + else // Somewhere in between + { + item->prev->next = item->next; + item->next->prev = item->prev; + } + + Z_Free (item); +} + +// +// ListRemoveAll +// +// Removes all items from the list, freeing their memory. +// +void ListRemoveAll(listitem_t **itemHead) +{ + listitem_t *item; + listitem_t *next; + for (item = *itemHead; item; item = next) + { + next = item->next; + ListRemove(item, itemHead); + } +} + +// +// ListRemoveNoFree +// +// Take an item out of the list, but don't free its memory. +// +void ListRemoveNoFree(void *pItem, listitem_t **itemHead) +{ + listitem_t *item = (listitem_t*)pItem; + + if (item == *itemHead) // Start of list + { + *itemHead = item->next; + + if (*itemHead) + (*itemHead)->prev = NULL; + } + else if (item->next == NULL) // end of list + { + item->prev->next = NULL; + } + else // Somewhere in between + { + item->prev->next = item->next; + item->next->prev = item->prev; + } +} + +// +// ListGetCount +// +// Counts the # of items in a list +// Should not be used in performance-minded code +// +unsigned int ListGetCount(void *itemHead) +{ + listitem_t *item = (listitem_t*)itemHead; + + unsigned int count = 0; + for (; item; item = item->next) + count++; + + return count; +} + +// +// ListGetByIndex +// +// Gets an item in the list by its index +// Should not be used in performance-minded code +// +listitem_t *ListGetByIndex(void *itemHead, unsigned int index) +{ + listitem_t *head = (listitem_t*)itemHead; + unsigned int count = 0; + listitem_t *node; + for (node = head; node; node = node->next) + { + if (count == index) + return node; + + count++; + } + + return NULL; +} diff --git a/src/hardware/u_list.h b/src/hardware/u_list.h new file mode 100644 index 000000000..7e9a3cabd --- /dev/null +++ b/src/hardware/u_list.h @@ -0,0 +1,29 @@ +/* + From the 'Wizard2' engine by Spaddlewit Inc. ( http://www.spaddlewit.com ) + An experimental work-in-progress. + + Donated to Sonic Team Junior and adapted to work with + Sonic Robo Blast 2. The license of this code matches whatever + the licensing is for Sonic Robo Blast 2. +*/ + +#ifndef _U_LIST_H_ +#define _U_LIST_H_ + +typedef struct listitem_s +{ + struct listitem_s *next; + struct listitem_s *prev; +} listitem_t; + +void ListAdd(void *pItem, listitem_t **itemHead); +void ListAddFront(void *pItem, listitem_t **itemHead); +void ListAddBefore(void *pItem, void *pSpot, listitem_t **itemHead); +void ListAddAfter(void *pItem, void *pSpot, listitem_t **itemHead); +void ListRemove(void *pItem, listitem_t **itemHead); +void ListRemoveAll(listitem_t **itemHead); +void ListRemoveNoFree(void *pItem, listitem_t **itemHead); +unsigned int ListGetCount(void *itemHead); +listitem_t *ListGetByIndex(void *itemHead, unsigned int index); + +#endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e34e5c35c..6aa5a4510 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -17,6 +17,7 @@ #include "m_menu.h" // gametype_cons_t #include "m_cond.h" // emblems +#include "m_misc.h" // word jumping #include "d_clisrv.h" @@ -46,10 +47,8 @@ #include "hardware/hw_main.h" #endif -#ifdef HAVE_BLUA #include "lua_hud.h" #include "lua_hook.h" -#endif // coords are scaled #define HU_INPUTX 0 @@ -69,6 +68,11 @@ patch_t *nightsnum[10]; // 0-9 // Level title and credits fonts patch_t *lt_font[LT_FONTSIZE]; patch_t *cred_font[CRED_FONTSIZE]; +patch_t *ttlnum[20]; // act numbers (0-19) + +// Name tag fonts +patch_t *ntb_font[NT_FONTSIZE]; +patch_t *nto_font[NT_FONTSIZE]; static player_t *plr; boolean chat_on; // entering a chat message? @@ -84,15 +88,16 @@ patch_t *rmatcico; patch_t *bmatcico; patch_t *tagico; patch_t *tallminus; +patch_t *tallinfin; //------------------------------------------- // coop hud //------------------------------------------- -patch_t *emeraldpics[7]; -patch_t *tinyemeraldpics[7]; +patch_t *emeraldpics[3][8]; // 0 = normal, 1 = tiny, 2 = coinbox static patch_t *emblemicon; -static patch_t *tokenicon; +patch_t *tokenicon; +static patch_t *exiticon; //------------------------------------------- // misc vars @@ -199,21 +204,6 @@ void HU_LoadGraphics(void) tny_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); } - // cache the level title font for entire game execution - lt_font[0] = (patch_t *)W_CachePatchName("LTFNT039", PU_HUDGFX); /// \note fake start hack - - // Number support - lt_font[9] = (patch_t *)W_CachePatchName("LTFNT048", PU_HUDGFX); - lt_font[10] = (patch_t *)W_CachePatchName("LTFNT049", PU_HUDGFX); - lt_font[11] = (patch_t *)W_CachePatchName("LTFNT050", PU_HUDGFX); - lt_font[12] = (patch_t *)W_CachePatchName("LTFNT051", PU_HUDGFX); - lt_font[13] = (patch_t *)W_CachePatchName("LTFNT052", PU_HUDGFX); - lt_font[14] = (patch_t *)W_CachePatchName("LTFNT053", PU_HUDGFX); - lt_font[15] = (patch_t *)W_CachePatchName("LTFNT054", PU_HUDGFX); - lt_font[16] = (patch_t *)W_CachePatchName("LTFNT055", PU_HUDGFX); - lt_font[17] = (patch_t *)W_CachePatchName("LTFNT056", PU_HUDGFX); - lt_font[18] = (patch_t *)W_CachePatchName("LTFNT057", PU_HUDGFX); - j = LT_FONTSTART; for (i = 0; i < LT_FONTSIZE; i++) { @@ -250,6 +240,40 @@ void HU_LoadGraphics(void) // minus for negative tallnums tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX); + tallinfin = (patch_t *)W_CachePatchName("STTINFIN", PU_HUDGFX); + + // cache act numbers for level titles + for (i = 0; i < 20; i++) + { + sprintf(buffer, "TTL%.2d", i); + ttlnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // cache the base name tag font for entire game execution + j = NT_FONTSTART; + for (i = 0; i < NT_FONTSIZE; i++) + { + sprintf(buffer, "NTFNT%.3d", j); + j++; + + if (W_CheckNumForName(buffer) == LUMPERROR) + ntb_font[i] = NULL; + else + ntb_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } + + // cache the outline name tag font for entire game execution + j = NT_FONTSTART; + for (i = 0; i < NT_FONTSIZE; i++) + { + sprintf(buffer, "NTFNO%.3d", j); + j++; + + if (W_CheckNumForName(buffer) == LUMPERROR) + nto_font[i] = NULL; + else + nto_font[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); + } // cache the crosshairs, don't bother to know which one is being used, // just cache all 3, they're so small anyway. @@ -261,21 +285,34 @@ void HU_LoadGraphics(void) emblemicon = W_CachePatchName("EMBLICON", PU_HUDGFX); tokenicon = W_CachePatchName("TOKNICON", PU_HUDGFX); + exiticon = W_CachePatchName("EXITICON", PU_HUDGFX); - emeraldpics[0] = W_CachePatchName("CHAOS1", PU_HUDGFX); - emeraldpics[1] = W_CachePatchName("CHAOS2", PU_HUDGFX); - emeraldpics[2] = W_CachePatchName("CHAOS3", PU_HUDGFX); - emeraldpics[3] = W_CachePatchName("CHAOS4", PU_HUDGFX); - emeraldpics[4] = W_CachePatchName("CHAOS5", PU_HUDGFX); - emeraldpics[5] = W_CachePatchName("CHAOS6", PU_HUDGFX); - emeraldpics[6] = W_CachePatchName("CHAOS7", PU_HUDGFX); - tinyemeraldpics[0] = W_CachePatchName("TEMER1", PU_HUDGFX); - tinyemeraldpics[1] = W_CachePatchName("TEMER2", PU_HUDGFX); - tinyemeraldpics[2] = W_CachePatchName("TEMER3", PU_HUDGFX); - tinyemeraldpics[3] = W_CachePatchName("TEMER4", PU_HUDGFX); - tinyemeraldpics[4] = W_CachePatchName("TEMER5", PU_HUDGFX); - tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX); - tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); + emeraldpics[0][0] = W_CachePatchName("CHAOS1", PU_HUDGFX); + emeraldpics[0][1] = W_CachePatchName("CHAOS2", PU_HUDGFX); + emeraldpics[0][2] = W_CachePatchName("CHAOS3", PU_HUDGFX); + emeraldpics[0][3] = W_CachePatchName("CHAOS4", PU_HUDGFX); + emeraldpics[0][4] = W_CachePatchName("CHAOS5", PU_HUDGFX); + emeraldpics[0][5] = W_CachePatchName("CHAOS6", PU_HUDGFX); + emeraldpics[0][6] = W_CachePatchName("CHAOS7", PU_HUDGFX); + emeraldpics[0][7] = W_CachePatchName("CHAOS8", PU_HUDGFX); + + emeraldpics[1][0] = W_CachePatchName("TEMER1", PU_HUDGFX); + emeraldpics[1][1] = W_CachePatchName("TEMER2", PU_HUDGFX); + emeraldpics[1][2] = W_CachePatchName("TEMER3", PU_HUDGFX); + emeraldpics[1][3] = W_CachePatchName("TEMER4", PU_HUDGFX); + emeraldpics[1][4] = W_CachePatchName("TEMER5", PU_HUDGFX); + emeraldpics[1][5] = W_CachePatchName("TEMER6", PU_HUDGFX); + emeraldpics[1][6] = W_CachePatchName("TEMER7", PU_HUDGFX); + //emeraldpics[1][7] = W_CachePatchName("TEMER8", PU_HUDGFX); -- unused + + emeraldpics[2][0] = W_CachePatchName("EMBOX1", PU_HUDGFX); + emeraldpics[2][1] = W_CachePatchName("EMBOX2", PU_HUDGFX); + emeraldpics[2][2] = W_CachePatchName("EMBOX3", PU_HUDGFX); + emeraldpics[2][3] = W_CachePatchName("EMBOX4", PU_HUDGFX); + emeraldpics[2][4] = W_CachePatchName("EMBOX5", PU_HUDGFX); + emeraldpics[2][5] = W_CachePatchName("EMBOX6", PU_HUDGFX); + emeraldpics[2][6] = W_CachePatchName("EMBOX7", PU_HUDGFX); + //emeraldpics[2][7] = W_CachePatchName("EMBOX8", PU_HUDGFX); -- unused } // Initialise Heads up @@ -424,7 +461,7 @@ void HU_AddChatText(const char *text, boolean playsound) static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) { - XBOXSTATIC char buf[254]; + char buf[254]; size_t numwords, ix; char *msg = &buf[2]; const size_t msgspace = sizeof buf - 2; @@ -460,40 +497,34 @@ static void DoSayCommand(SINT8 target, size_t usedargs, UINT8 flags) if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { - // what we're gonna do now is check if the node exists + // what we're gonna do now is check if the player exists // with that logic, characters 4 and 5 are our numbers: const char *newmsg; - char *nodenum = (char*) malloc(3); - INT32 spc = 1; // used if nodenum[1] is a space. + char playernum[3]; + INT32 spc = 1; // used if playernum[1] is a space. - strncpy(nodenum, msg+3, 3); + strncpy(playernum, msg+3, 3); // check for undesirable characters in our "number" - if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) + if (((playernum[0] < '0') || (playernum[0] > '9')) || ((playernum[1] < '0') || (playernum[1] > '9'))) { - // check if nodenum[1] is a space - if (nodenum[1] == ' ') + // check if playernum[1] is a space + if (playernum[1] == ' ') spc = 0; - // let it slide + // let it slide else { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); return; } } // I'm very bad at C, I swear I am, additional checks eww! - if (spc != 0) - { - if (msg[5] != ' ') - { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); - return; - } - } + if (spc != 0 && msg[5] != ' ') + { + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); + return; + } - target = atoi((const char*) nodenum); // turn that into a number - free(nodenum); + target = atoi(playernum); // turn that into a number //CONS_Printf("%d\n", target); // check for target player, if it doesn't exist then we can't send the message! @@ -621,13 +652,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) M_GetText("Illegal say command received from %s while muted\n") : M_GetText("Illegal csay command received from non-admin %s\n"), player_names[playernum]); if (server) - { - XBOXSTATIC UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); - } + SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); return; } @@ -641,13 +666,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) { CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[playernum]); if (server) - { - XBOXSTATIC char buf[2]; - - buf[0] = (char)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); - } + SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); return; } } @@ -667,10 +686,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) // run the lua hook even if we were supposed to eat the msg, netgame consistency goes first. -#ifdef HAVE_BLUA if (LUAh_PlayerMsg(playernum, target, flags, msg)) return; -#endif if (spam_eatmsg) return; // don't proceed if we were supposed to eat the message. @@ -742,26 +759,109 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) cstart = "\x83"; - if (color <= SKINCOLOR_SILVER) - cstart = "\x80"; // White - else if (color <= SKINCOLOR_BLACK) - cstart = "\x86"; // Grey - else if (color <= SKINCOLOR_BLUE) - cstart = "\x84"; // Blue - else if (color <= SKINCOLOR_PEACH) - cstart = "\x87"; //... Orange??? - else if (color == SKINCOLOR_PINK) - cstart = "\x85"; // Red. - else if (color <= SKINCOLOR_PURPLE) - cstart = "\x81"; // Purple - else if (color <= SKINCOLOR_ROSEWOOD) - cstart = "\x87"; // Orange - else if (color <= SKINCOLOR_DARKRED) - cstart = "\x85"; // Red - else if (color <= SKINCOLOR_OLIVE) - cstart = "\x83"; // green - else if (color <= SKINCOLOR_GOLD) - cstart = "\x82"; // Yellow + // Follow palette order at r_draw.c Color_Names + switch (color) + { + default: + case SKINCOLOR_WHITE: + case SKINCOLOR_BONE: + case SKINCOLOR_CLOUDY: + case SKINCOLOR_GREY: + case SKINCOLOR_SILVER: + case SKINCOLOR_AETHER: + case SKINCOLOR_SLATE: + cstart = "\x80"; // white + break; + case SKINCOLOR_CARBON: + case SKINCOLOR_JET: + case SKINCOLOR_BLACK: + cstart = "\x86"; // V_GRAYMAP + break; + case SKINCOLOR_PINK: + case SKINCOLOR_RUBY: + case SKINCOLOR_SALMON: + case SKINCOLOR_RED: + case SKINCOLOR_CRIMSON: + case SKINCOLOR_FLAME: + case SKINCOLOR_KETCHUP: + cstart = "\x85"; // V_REDMAP + break; + case SKINCOLOR_YOGURT: + case SKINCOLOR_BROWN: + case SKINCOLOR_BRONZE: + case SKINCOLOR_TAN: + case SKINCOLOR_BEIGE: + case SKINCOLOR_QUAIL: + cstart = "\x8d"; // V_BROWNMAP + break; + case SKINCOLOR_MOSS: + case SKINCOLOR_GREEN: + case SKINCOLOR_FOREST: + case SKINCOLOR_EMERALD: + case SKINCOLOR_MINT: + cstart = "\x83"; // V_GREENMAP + break; + case SKINCOLOR_AZURE: + cstart = "\x8c"; // V_AZUREMAP + break; + case SKINCOLOR_LAVENDER: + case SKINCOLOR_PASTEL: + case SKINCOLOR_PURPLE: + cstart = "\x89"; // V_PURPLEMAP + break; + case SKINCOLOR_PEACHY: + case SKINCOLOR_LILAC: + case SKINCOLOR_PLUM: + case SKINCOLOR_ROSY: + cstart = "\x8e"; // V_ROSYMAP + break; + case SKINCOLOR_SUNSET: + case SKINCOLOR_COPPER: + case SKINCOLOR_APRICOT: + case SKINCOLOR_ORANGE: + case SKINCOLOR_RUST: + cstart = "\x87"; // V_ORANGEMAP + break; + case SKINCOLOR_GOLD: + case SKINCOLOR_SANDY: + case SKINCOLOR_YELLOW: + case SKINCOLOR_OLIVE: + cstart = "\x82"; // V_YELLOWMAP + break; + case SKINCOLOR_LIME: + case SKINCOLOR_PERIDOT: + case SKINCOLOR_APPLE: + cstart = "\x8b"; // V_PERIDOTMAP + break; + case SKINCOLOR_SEAFOAM: + case SKINCOLOR_AQUA: + cstart = "\x8a"; // V_AQUAMAP + break; + case SKINCOLOR_TEAL: + case SKINCOLOR_WAVE: + case SKINCOLOR_CYAN: + case SKINCOLOR_SKY: + case SKINCOLOR_CERULEAN: + case SKINCOLOR_ICY: + case SKINCOLOR_SAPPHIRE: + case SKINCOLOR_VAPOR: + cstart = "\x88"; // V_SKYMAP + break; + case SKINCOLOR_CORNFLOWER: + case SKINCOLOR_BLUE: + case SKINCOLOR_COBALT: + case SKINCOLOR_DUSK: + case SKINCOLOR_BLUEBELL: + cstart = "\x84"; // V_BLUEMAP + break; + case SKINCOLOR_BUBBLEGUM: + case SKINCOLOR_MAGENTA: + case SKINCOLOR_NEON: + case SKINCOLOR_VIOLET: + case SKINCOLOR_RASPBERRY: + cstart = "\x81"; // V_MAGENTAMAP + break; + } } prefix = cstart; @@ -918,9 +1018,6 @@ void HU_Ticker(void) #ifndef NONET static boolean teamtalk = false; -/*static char chatchars[QUEUESIZE]; -static INT32 head = 0, tail = 0;*/ -// WHY DO YOU OVERCOMPLICATE EVERYTHING????????? // Clear spaces so we don't end up with messages only made out of emptiness static boolean HU_clearChatSpaces(void) @@ -979,11 +1076,11 @@ static void HU_queueChatChar(char c) if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm { - INT32 spc = 1; // used if nodenum[1] is a space. - char *nodenum = (char*) malloc(3); + INT32 spc = 1; // used if playernum[1] is a space. + char playernum[3]; const char *newmsg; - // what we're gonna do now is check if the node exists + // what we're gonna do now is check if the player exists // with that logic, characters 4 and 5 are our numbers: // teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko. @@ -993,18 +1090,17 @@ static void HU_queueChatChar(char c) return; } - strncpy(nodenum, msg+3, 3); + strncpy(playernum, msg+3, 3); // check for undesirable characters in our "number" - if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9'))) + if (((playernum[0] < '0') || (playernum[0] > '9')) || ((playernum[1] < '0') || (playernum[1] > '9'))) { - // check if nodenum[1] is a space - if (nodenum[1] == ' ') + // check if playernum[1] is a space + if (playernum[1] == ' ') spc = 0; // let it slide else { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); return; } } @@ -1013,14 +1109,12 @@ static void HU_queueChatChar(char c) { if (msg[5] != ' ') { - HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); - free(nodenum); + HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm \'.", false); return; } } - target = atoi((const char*) nodenum); // turn that into a number - free(nodenum); + target = atoi(playernum); // turn that into a number //CONS_Printf("%d\n", target); // check for target player, if it doesn't exist then we can't send the message! @@ -1032,7 +1126,7 @@ static void HU_queueChatChar(char c) return; } - // we need to get rid of the /pm + // we need to get rid of the /pm newmsg = msg+5+spc; strlcpy(msg, newmsg, 255); } @@ -1058,6 +1152,8 @@ void HU_clearChatChars(void) w_chat[i] = 0; // reset this. chat_on = false; c_input = 0; + + I_UpdateMouseGrab(); } #ifndef NONET @@ -1072,7 +1168,9 @@ static INT16 typelines = 1; // number of drawfill lines we need when drawing the // boolean HU_Responder(event_t *ev) { +#ifndef NONET INT32 c=0; +#endif if (ev->type != ev_keydown) return false; @@ -1099,19 +1197,9 @@ boolean HU_Responder(event_t *ev) return false; }*/ //We don't actually care about that unless we get splitscreen netgames. :V +#ifndef NONET c = (INT32)ev->data1; - // capslock (now handled outside of chat on so that it works everytime......) - if (c && c == KEY_CAPSLOCK) // it's a toggle. - { - if (capslock) - capslock = false; - else - capslock = true; - return true; - } - -#ifndef NONET if (!chat_on) { // enter chat mode @@ -1216,6 +1304,7 @@ boolean HU_Responder(event_t *ev) chat_on = false; c_input = 0; // reset input cursor chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) + I_UpdateMouseGrab(); } else if (c == KEY_ESCAPE || ((c == gamecontrol[gc_talkkey][0] || c == gamecontrol[gc_talkkey][1] @@ -1224,6 +1313,7 @@ boolean HU_Responder(event_t *ev) { chat_on = false; c_input = 0; // reset input cursor + I_UpdateMouseGrab(); } else if ((c == KEY_UPARROW || c == KEY_MOUSEWHEELUP) && chat_scroll > 0 && !OLDCHAT) // CHAT SCROLLING YAYS! { @@ -1238,9 +1328,19 @@ boolean HU_Responder(event_t *ev) chat_scrolltime = 4; } else if (c == KEY_LEFTARROW && c_input != 0 && !OLDCHAT) // i said go back - c_input--; + { + if (ctrldown) + c_input = M_JumpWordReverse(w_chat, c_input); + else + c_input--; + } else if (c == KEY_RIGHTARROW && c_input < strlen(w_chat) && !OLDCHAT) // don't need to check for admin or w/e here since the chat won't ever contain anything if it's muted. - c_input++; + { + if (ctrldown) + c_input += M_JumpWord(&w_chat[c_input]); + else + c_input++; + } return true; } #endif @@ -1312,7 +1412,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) // 30/7/18: chaty is now the distance at which the lowest point of the chat will be drawn if that makes any sense. -INT16 chatx = 13, chaty = 169; // let's use this as our coordinates, shh +INT16 chatx = 13, chaty = 169; // let's use this as our coordinates // chat stuff by VincyTM LOL XD! @@ -1339,7 +1439,7 @@ static void HU_drawMiniChat(void) for (; i>0; i--) { - const char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]); + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]); size_t j = 0; INT32 linescount = 0; @@ -1381,6 +1481,9 @@ static void HU_drawMiniChat(void) dy = 0; dx = 0; msglines += linescount+1; + + if (msg) + Z_Free(msg); } y = chaty - charheight*(msglines+1); @@ -1391,7 +1494,6 @@ static void HU_drawMiniChat(void) if (splitscreen > 1) y += 16; }*/ - y -= (G_RingSlingerGametype() ? 16 : 0); dx = 0; dy = 0; @@ -1404,7 +1506,7 @@ static void HU_drawMiniChat(void) INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below... INT32 transflag = (timer >= 0 && timer <= 9) ? (timer*V_10TRANS) : 0; // you can make bad jokes out of this one. size_t j = 0; - const char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; while(msg[j]) // iterate through msg @@ -1450,6 +1552,9 @@ static void HU_drawMiniChat(void) } dy += charheight; dx = 0; + + if (msg) + Z_Free(msg); } // decrement addy and make that shit smooth: @@ -1487,12 +1592,10 @@ static void HU_drawChatLog(INT32 offset) if (splitscreen) { y -= BASEVIDHEIGHT/2; - if (splitscreen > 1) - y += 16; + //if (splitscreen > 1) + //y += 16; } #endif - y -= (G_RingSlingerGametype() ? 16 : 0); - chat_topy = y + chat_scroll*charheight; chat_bottomy = chat_topy + boxh*charheight; @@ -1503,7 +1606,7 @@ static void HU_drawChatLog(INT32 offset) { INT32 clrflag = 0; INT32 j = 0; - const char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it. + char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_log[i]); // get the current message, and word wrap it. UINT8 *colormap = NULL; while(msg[j]) // iterate through msg { @@ -1543,6 +1646,9 @@ static void HU_drawChatLog(INT32 offset) } dy += charheight; dx = 0; + + if (msg) + Z_Free(msg); } @@ -1552,22 +1658,20 @@ static void HU_drawChatLog(INT32 offset) } chat_scrollmedown = false; - // getmaxscroll through a lazy hack. We do all these loops, so let's not do more loops that are gonna lag the game more. :P - chat_maxscroll = (dy/charheight); // welcome to C, we don't know what min() and max() are. - if (chat_maxscroll <= (UINT32)cv_chatheight.value) - chat_maxscroll = 0; - else - chat_maxscroll -= cv_chatheight.value; + // getmaxscroll through a lazy hack. We do all these loops, + // so let's not do more loops that are gonna lag the game more. :P + chat_maxscroll = max(dy / charheight - cv_chatheight.value, 0); // if we're not bound by the time, autoscroll for next frame: if (atbottom) chat_scroll = chat_maxscroll; // draw arrows to indicate that we can (or not) scroll. + // account for Y = -1 offset in tinyfont if (chat_scroll > 0) - V_DrawThinString(chatx-8, ((justscrolledup) ? (chat_topy-1) : (chat_topy)), V_SNAPTOBOTTOM | V_SNAPTOLEFT | V_YELLOWMAP, "\x1A"); // up arrow + V_DrawThinString(chatx-8, ((justscrolledup) ? (chat_topy-1) : (chat_topy)) - 1, V_SNAPTOBOTTOM | V_SNAPTOLEFT | V_YELLOWMAP, "\x1A"); // up arrow if (chat_scroll < chat_maxscroll) - V_DrawThinString(chatx-8, chat_bottomy-((justscrolleddown) ? 5 : 6), V_SNAPTOBOTTOM | V_SNAPTOLEFT | V_YELLOWMAP, "\x1B"); // down arrow + V_DrawThinString(chatx-8, chat_bottomy-((justscrolleddown) ? 5 : 6) - 1, V_SNAPTOBOTTOM | V_SNAPTOLEFT | V_YELLOWMAP, "\x1B"); // down arrow justscrolleddown = false; justscrolledup = false; @@ -1601,7 +1705,6 @@ static void HU_DrawChat(void) } } #endif - y -= (G_RingSlingerGametype() ? 16 : 0); if (teamtalk) { @@ -1694,26 +1797,21 @@ static void HU_DrawChat(void) p_dispy += 16; } #endif - p_dispy -= (G_RingSlingerGametype() ? 16 : 0); i = 0; for(i=0; (i '9'))) || ((w_chat[4] != 0) && (((w_chat[4] < '0') || (w_chat[4] > '9'))))) && (w_chat[4] != ' ')) break; - - nodenum = (char*) malloc(3); - strncpy(nodenum, w_chat+3, 3); - n = atoi((const char*) nodenum); // turn that into a number - free(nodenum); + strncpy(playernum, w_chat+3, 3); + n = atoi(playernum); // turn that into a number // special cases: if ((n == 0) && !(w_chat[4] == '0')) @@ -1760,7 +1858,6 @@ static void HU_DrawChat(void) } HU_drawChatLog(typelines-1); // typelines is the # of lines we're typing. If there's more than 1 then the log should scroll up to give us more space. - } @@ -1795,7 +1892,7 @@ static void HU_DrawChat_Old(void) else { //charwidth = SHORT(hu_font[talk[i]-HU_FONTSTART]->width) * con_scalefactor; - V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); + V_DrawCharacter(HU_INPUTX + c, y, talk[i++] | cv_constextsize.value | V_NOSCALESTART, true); } c += charwidth; } @@ -1823,7 +1920,7 @@ static void HU_DrawChat_Old(void) else { //charwidth = SHORT(hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor; - V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); + V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, true); } c += charwidth; @@ -1833,6 +1930,9 @@ static void HU_DrawChat_Old(void) y += charheight; } } + + if (hu_tick < 4) + V_DrawCharacter(HU_INPUTX + c, y, '_' | cv_constextsize.value |V_NOSCALESTART|t, true); } #endif @@ -1898,7 +1998,7 @@ static void HU_DrawCEcho(void) INT32 y = (BASEVIDHEIGHT/2)-4; INT32 pnumlines = 0; - UINT32 realflags = cechoflags; + UINT32 realflags = cechoflags|V_PERPLAYER; // requested as part of splitscreen's stuff INT32 realalpha = (INT32)((cechoflags & V_ALPHAMASK) >> V_ALPHASHIFT); char *line; @@ -1941,6 +2041,12 @@ static void HU_DrawCEcho(void) *line = '\0'; V_DrawCenteredString(BASEVIDWIDTH/2, y, realflags, echoptr); + if (splitscreen) + { + stplyr = ((stplyr == &players[displayplayer]) ? &players[secondarydisplayplayer] : &players[displayplayer]); + V_DrawCenteredString(BASEVIDWIDTH/2, y, realflags, echoptr); + stplyr = ((stplyr == &players[displayplayer]) ? &players[secondarydisplayplayer] : &players[displayplayer]); + } y += ((realflags & V_RETURN8) ? 8 : 12); echoptr = line; @@ -1952,19 +2058,17 @@ static void HU_DrawCEcho(void) static void HU_drawGametype(void) { - INT32 i = 0; + const char *strvalue = NULL; - for (i = 0; gametype_cons_t[i].strvalue; i++) - { - if (gametype_cons_t[i].value == gametype) - { - if (splitscreen) - V_DrawString(4, 184, 0, gametype_cons_t[i].strvalue); - else - V_DrawString(4, 192, 0, gametype_cons_t[i].strvalue); - return; - } - } + if (gametype < 0 || gametype >= gametypecount) + return; // not a valid gametype??? + + strvalue = Gametype_Names[gametype]; + + if (splitscreen) + V_DrawString(4, 184, 0, strvalue); + else + V_DrawString(4, 192, 0, strvalue); } // @@ -1976,25 +2080,29 @@ UINT16 hu_demorings; static void HU_DrawDemoInfo(void) { - V_DrawString(4, 188-24, V_YELLOWMAP, va(M_GetText("%s's replay"), player_names[0])); + INT32 h = 188; + if (modeattacking == ATTACKING_NIGHTS) + h -= 12; + + V_DrawString(4, h-24, V_YELLOWMAP|V_ALLOWLOWERCASE, va(M_GetText("%s's replay"), player_names[0])); if (modeattacking) { - V_DrawString(4, 188-16, V_YELLOWMAP|V_MONOSPACE, "SCORE:"); - V_DrawRightAlignedString(120, 188-16, V_MONOSPACE, va("%d", hu_demoscore)); + V_DrawString(4, h-16, V_YELLOWMAP|V_MONOSPACE, "SCORE:"); + V_DrawRightAlignedString(120, h-16, V_MONOSPACE, va("%d", hu_demoscore)); - V_DrawString(4, 188- 8, V_YELLOWMAP|V_MONOSPACE, "TIME:"); + V_DrawString(4, h-8, V_YELLOWMAP|V_MONOSPACE, "TIME:"); if (hu_demotime != UINT32_MAX) - V_DrawRightAlignedString(120, 188- 8, V_MONOSPACE, va("%i:%02i.%02i", + V_DrawRightAlignedString(120, h-8, V_MONOSPACE, va("%i:%02i.%02i", G_TicsToMinutes(hu_demotime,true), G_TicsToSeconds(hu_demotime), G_TicsToCentiseconds(hu_demotime))); else - V_DrawRightAlignedString(120, 188- 8, V_MONOSPACE, "--:--.--"); + V_DrawRightAlignedString(120, h-8, V_MONOSPACE, "--:--.--"); if (modeattacking == ATTACKING_RECORD) { - V_DrawString(4, 188 , V_YELLOWMAP|V_MONOSPACE, "RINGS:"); - V_DrawRightAlignedString(120, 188 , V_MONOSPACE, va("%d", hu_demorings)); + V_DrawString(4, h, V_YELLOWMAP|V_MONOSPACE, "RINGS:"); + V_DrawRightAlignedString(120, h, V_MONOSPACE, va("%d", hu_demorings)); } } } @@ -2003,6 +2111,9 @@ static void HU_DrawDemoInfo(void) // void HU_Drawer(void) { + if (needpatchrecache) + R_ReloadHUDGraphics(); + #ifndef NONET // draw chat string plus cursor if (chat_on) @@ -2054,7 +2165,7 @@ void HU_Drawer(void) if (!Playing() || gamestate == GS_INTERMISSION || gamestate == GS_CUTSCENE || gamestate == GS_CREDITS || gamestate == GS_EVALUATION - || gamestate == GS_GAMEEND) + || gamestate == GS_ENDING || gamestate == GS_GAMEEND) return; // draw multiplayer rankings @@ -2062,28 +2173,28 @@ void HU_Drawer(void) { if (netgame || multiplayer) { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_rankings)) -#endif - HU_DrawRankings(); + HU_DrawRankings(); if (gametype == GT_COOP) HU_DrawNetplayCoopOverlay(); } else HU_DrawCoopOverlay(); -#ifdef HAVE_BLUA LUAh_ScoresHUD(); -#endif } if (gamestate != GS_LEVEL) return; // draw the crosshair, not when viewing demos nor with chasecam - if (!automapactive && cv_crosshair.value && !demoplayback && !camera.chase && !players[displayplayer].spectator) + if (!automapactive && cv_crosshair.value && !demoplayback && + (!camera.chase || ticcmd_ztargetfocus[0]) + && !players[displayplayer].spectator) HU_DrawCrosshair(); - if (!automapactive && cv_crosshair2.value && !demoplayback && !camera2.chase && !players[secondarydisplayplayer].spectator) + if (!automapactive && cv_crosshair2.value && !demoplayback && + (!camera2.chase || ticcmd_ztargetfocus[1]) + && !players[secondarydisplayplayer].spectator) HU_DrawCrosshair2(); // draw desynch text @@ -2101,6 +2212,31 @@ void HU_Drawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_YELLOWMAP | V_ALLOWLOWERCASE, resynch_text); } + + if (modeattacking && pausedelay > 0 && !pausebreakkey) + { + INT32 strength = ((pausedelay - 1 - NEWTICRATE/2)*10)/(NEWTICRATE/3); + INT32 y = hudinfo[HUD_LIVES].y - 13; + + if (players[consoleplayer].powers[pw_carry] == CR_NIGHTSMODE) + y -= 16; + else + { + if (players[consoleplayer].pflags & PF_AUTOBRAKE) + y -= 8; + if (players[consoleplayer].pflags & PF_ANALOGMODE) + y -= 8; + } + + V_DrawThinString(hudinfo[HUD_LIVES].x-2, y, + hudinfo[HUD_LIVES].f|((leveltime & 4) ? V_SKYMAP : V_BLUEMAP), + "HOLD TO RETRY..."); + + if (strength > 9) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); + else if (strength > 0) + V_DrawFadeScreen(0, strength); + } } //====================================================================== @@ -2177,36 +2313,40 @@ void HU_Erase(void) // IN-LEVEL MULTIPLAYER RANKINGS //====================================================================== +#define supercheckdef ((players[tab[i].num].powers[pw_super] && players[tab[i].num].mo && (players[tab[i].num].mo->state < &states[S_PLAY_SUPER_TRANS1] || players[tab[i].num].mo->state >= &states[S_PLAY_SUPER_TRANS6])) || (players[tab[i].num].powers[pw_carry] == CR_NIGHTSMODE && skins[players[tab[i].num].skin].flags & SF_SUPER)) +#define greycheckdef (players[tab[i].num].spectator || players[tab[i].num].playerstate == PST_DEAD || (G_IsSpecialStage(gamemap) && players[tab[i].num].exiting)) + // // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext) +void HU_drawPing(INT32 x, INT32 y, UINT32 ping, boolean notext, INT32 flags) { UINT8 numbars = 1; // how many ping bars do we draw? - UINT8 barcolor = 128; // color we use for the bars (green, yellow or red) + UINT8 barcolor = 35; // color we use for the bars (green, yellow or red) SINT8 i = 0; SINT8 yoffset = 6; - INT32 dx = x+1 - (V_SmallStringWidth(va("%dms", ping), V_ALLOWLOWERCASE)/2); + INT32 dx = x+1 - (V_SmallStringWidth(va("%dms", ping), + V_ALLOWLOWERCASE|flags)/2); if (ping < 128) { numbars = 3; - barcolor = 184; + barcolor = 112; } else if (ping < 256) { numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. - barcolor = 103; + barcolor = 73; } if (!notext || vid.width >= 640) // how sad, we're using a shit resolution. - V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE, va("%dms", ping)); + V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|flags, va("%dms", ping)); for (i=0; (i<3); i++) // Draw the ping bar { - V_DrawFill(x+2 *(i-1), y+yoffset-4, 2, 8-yoffset, 31); + V_DrawFill(x+2 *(i-1), y+yoffset-4, 2, 8-yoffset, 31|flags); if (i < numbars) - V_DrawFill(x+2 *(i-1), y+yoffset-3, 1, 8-yoffset-1, barcolor); + V_DrawFill(x+2 *(i-1), y+yoffset-3, 1, 8-yoffset-1, barcolor|flags); yoffset -= 2; } @@ -2219,6 +2359,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I { INT32 i; const UINT8 *colormap; + boolean greycheck, supercheck; //this function is designed for 9 or less score lines only I_Assert(scorelines <= 9); @@ -2227,30 +2368,35 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I for (i = 0; i < scorelines; i++) { - if (players[tab[i].num].spectator) + if (players[tab[i].num].spectator && gametyperankings[gametype] != GT_COOP) continue; //ignore them. + greycheck = greycheckdef; + supercheck = supercheckdef; + if (!splitscreen) // don't draw it on splitscreen, { - if (!(tab[i].num == serverplayer)) - HU_drawPing(x+ 253, y+2, playerpingtable[tab[i].num], false); + if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) + HU_drawPing(x+ 253, y, playerpingtable[tab[i].num], false, 0); //else // V_DrawSmallString(x+ 246, y+4, V_YELLOWMAP, "SERVER"); } V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | ((players[tab[i].num].health > 0) ? 0 : V_60TRANS) + | (greycheck ? V_60TRANS : 0) | V_ALLOWLOWERCASE, tab[i].name); // Draw emeralds - if (!players[tab[i].num].powers[pw_super] + if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) + HU_DrawEmeralds(x-12,y+2,255); + else if (!players[tab[i].num].powers[pw_super] || ((leveltime/7) & 1)) { HU_DrawEmeralds(x-12,y+2,tab[i].emeralds); } - if (players[tab[i].num].health <= 0) + if (greycheck) V_DrawSmallTranslucentPatch (x, y-4, V_80TRANS, livesback); else V_DrawSmallScaledPatch (x, y-4, 0, livesback); @@ -2258,11 +2404,11 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (tab[i].color == 0) { colormap = colormaps; - if (players[tab[i].num].powers[pw_super]) + if (supercheck) V_DrawSmallScaledPatch(x, y-4, 0, superprefix[players[tab[i].num].skin]); else { - if (players[tab[i].num].health <= 0) + if (greycheck) V_DrawSmallTranslucentPatch(x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin]); else V_DrawSmallScaledPatch(x, y-4, 0, faceprefix[players[tab[i].num].skin]); @@ -2270,45 +2416,48 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I } else { - if (players[tab[i].num].powers[pw_super]) + if (supercheck) { - colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); + colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo->color, GTC_CACHE); V_DrawSmallMappedPatch (x, y-4, 0, superprefix[players[tab[i].num].skin], colormap); } else { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); - if (players[tab[i].num].health <= 0) + if (greycheck) V_DrawSmallTranslucentMappedPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin], colormap); else V_DrawSmallMappedPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin], colormap); } } - if (G_GametypeUsesLives()) //show lives - V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE|((players[tab[i].num].health > 0) ? 0 : V_60TRANS), va("%dx", players[tab[i].num].lives)); + if (G_GametypeUsesLives() && !(G_GametypeUsesCoopLives() && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives + V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE|(greycheck ? V_60TRANS : 0), va("%dx", players[tab[i].num].lives)); else if (G_TagGametype() && players[tab[i].num].pflags & PF_TAGIT) { - if (players[tab[i].num].health <= 0) + if (greycheck) V_DrawSmallTranslucentPatch(x-32, y-4, V_60TRANS, tagico); else V_DrawSmallScaledPatch(x-32, y-4, 0, tagico); } - if (gametype == GT_RACE) + if (players[tab[i].num].exiting || (players[tab[i].num].pflags & PF_FINISHED)) + V_DrawSmallScaledPatch(x - SHORT(exiticon->width)/2 - 1, y-3, 0, exiticon); + + if (gametyperankings[gametype] == GT_RACE) { if (circuitmap) { if (players[tab[i].num].exiting) V_DrawRightAlignedString(x+240, y, 0, va("%i:%02i.%02i", G_TicsToMinutes(players[tab[i].num].realtime,true), G_TicsToSeconds(players[tab[i].num].realtime), G_TicsToCentiseconds(players[tab[i].num].realtime))); else - V_DrawRightAlignedString(x+240, y, ((players[tab[i].num].health > 0) ? 0 : V_60TRANS), va("%u", tab[i].count)); + V_DrawRightAlignedString(x+240, y, (greycheck ? V_60TRANS : 0), va("%u", tab[i].count)); } else - V_DrawRightAlignedString(x+240, y, ((players[tab[i].num].health > 0) ? 0 : V_60TRANS), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); + V_DrawRightAlignedString(x+240, y, (greycheck ? V_60TRANS : 0), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); } else - V_DrawRightAlignedString(x+240, y, ((players[tab[i].num].health > 0) ? 0 : V_60TRANS), va("%u", tab[i].count)); + V_DrawRightAlignedString(x+240, y, (greycheck ? V_60TRANS : 0), va("%u", tab[i].count)); y += 16; } @@ -2321,25 +2470,25 @@ static void HU_Draw32Emeralds(INT32 x, INT32 y, INT32 pemeralds) { //Draw the emeralds, in the CORRECT order, using tiny emerald sprites. if (pemeralds & EMERALD1) - V_DrawSmallScaledPatch(x , y, 0, tinyemeraldpics[0]); + V_DrawSmallScaledPatch(x , y, 0, emeraldpics[1][0]); if (pemeralds & EMERALD2) - V_DrawSmallScaledPatch(x+4, y, 0, tinyemeraldpics[1]); + V_DrawSmallScaledPatch(x+4, y, 0, emeraldpics[1][1]); if (pemeralds & EMERALD3) - V_DrawSmallScaledPatch(x+8, y, 0, tinyemeraldpics[2]); + V_DrawSmallScaledPatch(x+8, y, 0, emeraldpics[1][2]); if (pemeralds & EMERALD4) - V_DrawSmallScaledPatch(x+12 , y, 0, tinyemeraldpics[3]); + V_DrawSmallScaledPatch(x+12 , y, 0, emeraldpics[1][3]); if (pemeralds & EMERALD5) - V_DrawSmallScaledPatch(x+16, y, 0, tinyemeraldpics[4]); + V_DrawSmallScaledPatch(x+16, y, 0, emeraldpics[1][4]); if (pemeralds & EMERALD6) - V_DrawSmallScaledPatch(x+20, y, 0, tinyemeraldpics[5]); + V_DrawSmallScaledPatch(x+20, y, 0, emeraldpics[1][5]); if (pemeralds & EMERALD7) - V_DrawSmallScaledPatch(x+24, y, 0, tinyemeraldpics[6]); + V_DrawSmallScaledPatch(x+24, y, 0, emeraldpics[1][6]); } // @@ -2351,6 +2500,7 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) INT32 redplayers = 0, blueplayers = 0; const UINT8 *colormap; char name[MAXPLAYERNAME+1]; + boolean greycheck, supercheck; V_DrawFill(160, 26, 1, 154, 0); //Draw a vertical line to separate the two teams. V_DrawFill(1, 26, 318, 1, 0); //And a horizontal line to make a T. @@ -2361,6 +2511,9 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) if (players[tab[i].num].spectator) continue; //ignore them. + greycheck = greycheckdef; + supercheck = supercheckdef; + if (tab[i].color == skincolor_redteam) //red { redplayers++; @@ -2376,13 +2529,16 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) else //er? not on red or blue, so ignore them continue; + greycheck = greycheckdef; + supercheck = supercheckdef; + strlcpy(name, tab[i].name, 8); V_DrawString(x + 10, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT) + | (greycheck ? 0 : V_TRANSLUCENT) | V_ALLOWLOWERCASE, name); - if (gametype == GT_CTF) + if (gametyperules & GTR_TEAMFLAGS) { if (players[tab[i].num].gotflag & GF_REDFLAG) // Red V_DrawFixedPatch((x-10)*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, 0, rflagico, 0); @@ -2391,13 +2547,19 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) } // Draw emeralds - if (!players[tab[i].num].powers[pw_super] + if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) + { + HU_Draw32Emeralds(x+60, y+2, 255); + //HU_DrawEmeralds(x-12,y+2,255); + } + else if (!players[tab[i].num].powers[pw_super] || ((leveltime/7) & 1)) { HU_Draw32Emeralds(x+60, y+2, tab[i].emeralds); + //HU_DrawEmeralds(x-12,y+2,tab[i].emeralds); } - if (players[tab[i].num].powers[pw_super]) + if (supercheck) { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, 0, superprefix[players[tab[i].num].skin], colormap); @@ -2405,16 +2567,16 @@ static void HU_Draw32TeamTabRankings(playersort_t *tab, INT32 whiteplayer) else { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); - if (players[tab[i].num].health <= 0) + if (players[tab[i].num].spectator || players[tab[i].num].playerstate == PST_DEAD) V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, V_HUDTRANSHALF, faceprefix[players[tab[i].num].skin], colormap); else V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, 0, faceprefix[players[tab[i].num].skin], colormap); } - V_DrawRightAlignedThinString(x+128, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+128, y, ((players[tab[i].num].spectator || players[tab[i].num].playerstate == PST_DEAD) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); if (!splitscreen) { - if (!(tab[i].num == serverplayer)) - HU_drawPing(x+ 135, y+3, playerpingtable[tab[i].num], true); + if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) + HU_drawPing(x+ 135, y+1, playerpingtable[tab[i].num], true, 0); //else //V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); } @@ -2431,6 +2593,7 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer) boolean smol = false; const UINT8 *colormap; char name[MAXPLAYERNAME+1]; + boolean greycheck, supercheck; // before we draw, we must count how many players are in each team. It makes an additional loop, but we need to know if we have to draw a big or a small ranking. for (i = 0; i < MAXPLAYERS; i++) @@ -2494,13 +2657,16 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer) else //er? not on red or blue, so ignore them continue; + greycheck = greycheckdef; + supercheck = supercheckdef; + strlcpy(name, tab[i].name, 7); V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT) + | (greycheck ? V_TRANSLUCENT : 0) | V_ALLOWLOWERCASE, name); - if (gametype == GT_CTF) + if (gametyperules & GTR_TEAMFLAGS) { if (players[tab[i].num].gotflag & GF_REDFLAG) // Red V_DrawSmallScaledPatch(x-28, y-4, 0, rflagico); @@ -2509,13 +2675,15 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer) } // Draw emeralds - if (!players[tab[i].num].powers[pw_super] + if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) + HU_DrawEmeralds(x-12,y+2,255); + else if (!players[tab[i].num].powers[pw_super] || ((leveltime/7) & 1)) { HU_DrawEmeralds(x-12,y+2,tab[i].emeralds); } - if (players[tab[i].num].powers[pw_super]) + if (supercheck) { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); V_DrawSmallMappedPatch (x, y-4, 0, superprefix[players[tab[i].num].skin], colormap); @@ -2523,16 +2691,16 @@ void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer) else { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); - if (players[tab[i].num].health <= 0) - V_DrawSmallTranslucentMappedPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin], colormap); + if (greycheck) + V_DrawSmallTranslucentMappedPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin], colormap); else V_DrawSmallMappedPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin], colormap); } - V_DrawRightAlignedThinString(x+100, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+100, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); if (!splitscreen) { - if (!(tab[i].num == serverplayer)) - HU_drawPing(x+ 113, y+2, playerpingtable[tab[i].num], false); + if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) + HU_drawPing(x+ 113, y, playerpingtable[tab[i].num], false, 0); //else // V_DrawSmallString(x+ 94, y+4, V_YELLOWMAP, "SERVER"); } @@ -2547,6 +2715,7 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline INT32 i; const UINT8 *colormap; char name[MAXPLAYERNAME+1]; + boolean greycheck, supercheck; V_DrawFill(160, 26, 1, 154, 0); //Draw a vertical line to separate the two sides. V_DrawFill(1, 26, 318, 1, 0); //And a horizontal line to make a T. @@ -2554,27 +2723,35 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline for (i = 0; i < scorelines; i++) { - if (players[tab[i].num].spectator) + if (players[tab[i].num].spectator && gametyperankings[gametype] != GT_COOP) continue; //ignore them. + greycheck = greycheckdef; + supercheck = supercheckdef; + strlcpy(name, tab[i].name, 7); - if (!(tab[i].num == serverplayer)) - HU_drawPing(x+ 113, y+2, playerpingtable[tab[i].num], false); + if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) + HU_drawPing(x+ 113, y, playerpingtable[tab[i].num], false, 0); //else // V_DrawSmallString(x+ 94, y+4, V_YELLOWMAP, "SERVER"); V_DrawString(x + 20, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT) + | (greycheck ? V_TRANSLUCENT : 0) | V_ALLOWLOWERCASE, name); - if (G_GametypeUsesLives()) //show lives + if (G_GametypeUsesLives() && !(G_GametypeUsesCoopLives() && (cv_cooplives.value == 0 || cv_cooplives.value == 3)) && (players[tab[i].num].lives != INFLIVES)) //show lives V_DrawRightAlignedString(x, y+4, V_ALLOWLOWERCASE, va("%dx", players[tab[i].num].lives)); else if (G_TagGametype() && players[tab[i].num].pflags & PF_TAGIT) V_DrawSmallScaledPatch(x-28, y-4, 0, tagico); + if (players[tab[i].num].exiting || (players[tab[i].num].pflags & PF_FINISHED)) + V_DrawSmallScaledPatch(x - SHORT(exiticon->width)/2 - 1, y-3, 0, exiticon); + // Draw emeralds - if (!players[tab[i].num].powers[pw_super] + if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) + HU_DrawEmeralds(x-12,y+2,255); + else if (!players[tab[i].num].powers[pw_super] || ((leveltime/7) & 1)) { HU_DrawEmeralds(x-12,y+2,tab[i].emeralds); @@ -2584,19 +2761,19 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline if (tab[i].color == 0) { colormap = colormaps; - if (players[tab[i].num].powers[pw_super]) + if (supercheck) V_DrawSmallScaledPatch (x, y-4, 0, superprefix[players[tab[i].num].skin]); else { - if (players[tab[i].num].health <= 0) - V_DrawSmallTranslucentPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin]); + if (greycheck) + V_DrawSmallTranslucentPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin]); else V_DrawSmallScaledPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin]); } } else { - if (players[tab[i].num].powers[pw_super]) + if (supercheck) { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); V_DrawSmallMappedPatch (x, y-4, 0, superprefix[players[tab[i].num].skin], colormap); @@ -2604,28 +2781,28 @@ void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scoreline else { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); - if (players[tab[i].num].health <= 0) - V_DrawSmallTranslucentMappedPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin], colormap); + if (greycheck) + V_DrawSmallTranslucentMappedPatch (x, y-4, V_80TRANS, faceprefix[players[tab[i].num].skin], colormap); else V_DrawSmallMappedPatch (x, y-4, 0, faceprefix[players[tab[i].num].skin], colormap); } } // All data drawn with thin string for space. - if (gametype == GT_RACE) + if (gametyperankings[gametype] == GT_RACE) { if (circuitmap) { if (players[tab[i].num].exiting) V_DrawRightAlignedThinString(x+146, y, 0, va("%i:%02i.%02i", G_TicsToMinutes(players[tab[i].num].realtime,true), G_TicsToSeconds(players[tab[i].num].realtime), G_TicsToCentiseconds(players[tab[i].num].realtime))); else - V_DrawRightAlignedThinString(x+146, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+146, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); } else - V_DrawRightAlignedThinString(x+146, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); + V_DrawRightAlignedThinString(x+146, y, (greycheck ? V_TRANSLUCENT : 0), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); } else - V_DrawRightAlignedThinString(x+100, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+100, y, (greycheck ? V_TRANSLUCENT : 0), va("%u", tab[i].count)); y += 16; if (y > 160) @@ -2644,6 +2821,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor INT32 i; const UINT8 *colormap; char name[MAXPLAYERNAME+1]; + boolean greycheck, supercheck; V_DrawFill(160, 26, 1, 154, 0); //Draw a vertical line to separate the two sides. V_DrawFill(1, 26, 318, 1, 0); //And a horizontal line to make a T. @@ -2651,21 +2829,24 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor for (i = 0; i < scorelines; i++) { - if (players[tab[i].num].spectator) + if (players[tab[i].num].spectator && gametyperankings[gametype] != GT_COOP) continue; //ignore them. + greycheck = greycheckdef; + supercheck = supercheckdef; + strlcpy(name, tab[i].name, 7); if (!splitscreen) // don't draw it on splitscreen, { - if (!(tab[i].num == serverplayer)) - HU_drawPing(x+ 135, y+3, playerpingtable[tab[i].num], true); + if (!(tab[i].num == serverplayer || players[tab[i].num].quittime)) + HU_drawPing(x+ 135, y+1, playerpingtable[tab[i].num], true, 0); //else // V_DrawSmallString(x+ 129, y+4, V_YELLOWMAP, "HOST"); } V_DrawString(x + 10, y, ((tab[i].num == whiteplayer) ? V_YELLOWMAP : 0) - | ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT) + | (greycheck ? 0 : V_TRANSLUCENT) | V_ALLOWLOWERCASE, name); if (G_GametypeUsesLives()) //show lives @@ -2674,7 +2855,12 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor V_DrawFixedPatch((x-10)*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, 0, tagico, 0); // Draw emeralds - if (!players[tab[i].num].powers[pw_super] + if (players[tab[i].num].powers[pw_invulnerability] && (players[tab[i].num].powers[pw_invulnerability] == players[tab[i].num].powers[pw_sneakers]) && ((leveltime/7) & 1)) + { + HU_Draw32Emeralds(x+60, y+2, 255); + //HU_DrawEmeralds(x-12,y+2,255); + } + else if (!players[tab[i].num].powers[pw_super] || ((leveltime/7) & 1)) { HU_Draw32Emeralds(x+60, y+2, tab[i].emeralds); @@ -2689,7 +2875,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, 0, superprefix[players[tab[i].num].skin], 0); else { - if (players[tab[i].num].health <= 0) + if (greycheck) V_DrawFixedPatch(x*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, V_HUDTRANSHALF, faceprefix[players[tab[i].num].skin], 0); else V_DrawFixedPatch(x*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, 0, faceprefix[players[tab[i].num].skin], 0); @@ -2697,7 +2883,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor } else { - if (players[tab[i].num].powers[pw_super]) + if (supercheck) { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); V_DrawFixedPatch(x*FRACUNIT, y*FRACUNIT, FRACUNIT/4, 0, superprefix[players[tab[i].num].skin], colormap); @@ -2705,7 +2891,7 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor else { colormap = R_GetTranslationColormap(players[tab[i].num].skin, players[tab[i].num].mo ? players[tab[i].num].mo->color : tab[i].color, GTC_CACHE); - if (players[tab[i].num].health <= 0) + if (greycheck) V_DrawFixedPatch(x*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, V_HUDTRANSHALF, faceprefix[players[tab[i].num].skin], colormap); else V_DrawFixedPatch(x*FRACUNIT, (y)*FRACUNIT, FRACUNIT/4, 0, faceprefix[players[tab[i].num].skin], colormap); @@ -2713,20 +2899,20 @@ static void HU_Draw32TabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scor } // All data drawn with thin string for space. - if (gametype == GT_RACE) + if (gametyperankings[gametype] == GT_RACE) { if (circuitmap) { if (players[tab[i].num].exiting) V_DrawRightAlignedThinString(x+128, y, 0, va("%i:%02i.%02i", G_TicsToMinutes(players[tab[i].num].realtime,true), G_TicsToSeconds(players[tab[i].num].realtime), G_TicsToCentiseconds(players[tab[i].num].realtime))); else - V_DrawRightAlignedThinString(x+128, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+128, y, (greycheck ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); } else - V_DrawRightAlignedThinString(x+128, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); + V_DrawRightAlignedThinString(x+128, y, (greycheck ? 0 : V_TRANSLUCENT), va("%i:%02i.%02i", G_TicsToMinutes(tab[i].count,true), G_TicsToSeconds(tab[i].count), G_TicsToCentiseconds(tab[i].count))); } else - V_DrawRightAlignedThinString(x+128, y, ((players[tab[i].num].health > 0) ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); + V_DrawRightAlignedThinString(x+128, y, (greycheck ? 0 : V_TRANSLUCENT), va("%u", tab[i].count)); y += 9; if (i == 16) @@ -2744,25 +2930,25 @@ void HU_DrawEmeralds(INT32 x, INT32 y, INT32 pemeralds) { //Draw the emeralds, in the CORRECT order, using tiny emerald sprites. if (pemeralds & EMERALD1) - V_DrawSmallScaledPatch(x , y-6, 0, tinyemeraldpics[0]); + V_DrawSmallScaledPatch(x , y-6, 0, emeraldpics[1][0]); if (pemeralds & EMERALD2) - V_DrawSmallScaledPatch(x+4, y-3, 0, tinyemeraldpics[1]); + V_DrawSmallScaledPatch(x+4, y-3, 0, emeraldpics[1][1]); if (pemeralds & EMERALD3) - V_DrawSmallScaledPatch(x+4, y+3, 0, tinyemeraldpics[2]); + V_DrawSmallScaledPatch(x+4, y+3, 0, emeraldpics[1][2]); if (pemeralds & EMERALD4) - V_DrawSmallScaledPatch(x , y+6, 0, tinyemeraldpics[3]); + V_DrawSmallScaledPatch(x , y+6, 0, emeraldpics[1][3]); if (pemeralds & EMERALD5) - V_DrawSmallScaledPatch(x-4, y+3, 0, tinyemeraldpics[4]); + V_DrawSmallScaledPatch(x-4, y+3, 0, emeraldpics[1][4]); if (pemeralds & EMERALD6) - V_DrawSmallScaledPatch(x-4, y-3, 0, tinyemeraldpics[5]); + V_DrawSmallScaledPatch(x-4, y-3, 0, emeraldpics[1][5]); if (pemeralds & EMERALD7) - V_DrawSmallScaledPatch(x, y, 0, tinyemeraldpics[6]); + V_DrawSmallScaledPatch(x, y, 0, emeraldpics[1][6]); } // @@ -2817,7 +3003,7 @@ static inline void HU_DrawSpectatorTicker(void) templength = length; } - V_DrawString(templength, height + 8, V_TRANSLUCENT, current); + V_DrawString(templength, height + 8, V_TRANSLUCENT|V_ALLOWLOWERCASE, current); } length += (signed)strlen(player_names[i]) * 8 + 16; @@ -2829,7 +3015,6 @@ static inline void HU_DrawSpectatorTicker(void) // static void HU_DrawRankings(void) { - patch_t *p; playersort_t tab[MAXPLAYERS]; INT32 i, j, scorelines; boolean completed[MAXPLAYERS]; @@ -2838,52 +3023,21 @@ static void HU_DrawRankings(void) // draw the current gametype in the lower right HU_drawGametype(); - if (G_GametypeHasTeams()) + if (gametyperules & (GTR_TIMELIMIT|GTR_POINTLIMIT)) { - if (gametype == GT_CTF) - p = bflagico; - else - p = bmatcico; - - V_DrawSmallScaledPatch(128 - SHORT(p->width)/4, 4, 0, p); - V_DrawCenteredString(128, 16, 0, va("%u", bluescore)); - - if (gametype == GT_CTF) - p = rflagico; - else - p = rmatcico; - - V_DrawSmallScaledPatch(192 - SHORT(p->width)/4, 4, 0, p); - V_DrawCenteredString(192, 16, 0, va("%u", redscore)); - } - - if (gametype != GT_RACE && gametype != GT_COMPETITION && gametype != GT_COOP) - { - if (cv_timelimit.value && timelimitintics > 0) + if ((gametyperules & GTR_TIMELIMIT) && cv_timelimit.value && timelimitintics > 0) { - INT32 timeval = (timelimitintics+1-leveltime)/TICRATE; - - if (leveltime <= timelimitintics) - { - V_DrawCenteredString(64, 8, 0, "TIME LEFT"); - V_DrawCenteredString(64, 16, 0, va("%u", timeval)); - } - - // overtime - if ((leveltime > (timelimitintics + TICRATE/2)) && cv_overtime.value) - { - V_DrawCenteredString(64, 8, 0, "TIME LEFT"); - V_DrawCenteredString(64, 16, 0, "OVERTIME"); - } + V_DrawCenteredString(64, 8, 0, "TIME"); + V_DrawCenteredString(64, 16, 0, va("%i:%02i", G_TicsToMinutes(stplyr->realtime, true), G_TicsToSeconds(stplyr->realtime))); } - if (cv_pointlimit.value > 0) + if ((gametyperules & GTR_POINTLIMIT) && cv_pointlimit.value > 0) { V_DrawCenteredString(256, 8, 0, "POINT LIMIT"); V_DrawCenteredString(256, 16, 0, va("%d", cv_pointlimit.value)); } } - else if (gametype == GT_COOP) + else if (gametyperankings[gametype] == GT_COOP) { INT32 totalscore = 0; for (i = 0; i < MAXPLAYERS; i++) @@ -2917,67 +3071,73 @@ static void HU_DrawRankings(void) tab[i].num = -1; tab[i].name = 0; - if (gametype == GT_RACE && !circuitmap) + if (gametyperankings[gametype] == GT_RACE && !circuitmap) tab[i].count = INT32_MAX; } for (j = 0; j < MAXPLAYERS; j++) { - if (!playeringame[j] || players[j].spectator) + if (!playeringame[j]) + continue; + + if (!G_PlatformGametype() && players[j].spectator) continue; for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && !players[i].spectator) + if (!playeringame[i]) + continue; + + if (!G_PlatformGametype() && players[i].spectator) + continue; + + if (gametyperankings[gametype] == GT_RACE) { - if (gametype == GT_RACE) + if (circuitmap) { - if (circuitmap) + if ((unsigned)players[i].laps+1 >= tab[scorelines].count && completed[i] == false) { - if ((unsigned)players[i].laps+1 >= tab[scorelines].count && completed[i] == false) - { - tab[scorelines].count = players[i].laps+1; - tab[scorelines].num = i; - tab[scorelines].color = players[i].skincolor; - tab[scorelines].name = player_names[i]; - } - } - else - { - if (players[i].realtime <= tab[scorelines].count && completed[i] == false) - { - tab[scorelines].count = players[i].realtime; - tab[scorelines].num = i; - tab[scorelines].color = players[i].skincolor; - tab[scorelines].name = player_names[i]; - } - } - } - else if (gametype == GT_COMPETITION) - { - // todo put something more fitting for the gametype here, such as current - // number of categories led - if (players[i].score >= tab[scorelines].count && completed[i] == false) - { - tab[scorelines].count = players[i].score; + tab[scorelines].count = players[i].laps+1; tab[scorelines].num = i; tab[scorelines].color = players[i].skincolor; tab[scorelines].name = player_names[i]; - tab[scorelines].emeralds = players[i].powers[pw_emeralds]; } } else { - if (players[i].score >= tab[scorelines].count && completed[i] == false) + if (players[i].realtime <= tab[scorelines].count && completed[i] == false) { - tab[scorelines].count = players[i].score; + tab[scorelines].count = players[i].realtime; tab[scorelines].num = i; tab[scorelines].color = players[i].skincolor; tab[scorelines].name = player_names[i]; - tab[scorelines].emeralds = players[i].powers[pw_emeralds]; } } } + else if (gametyperankings[gametype] == GT_COMPETITION) + { + // todo put something more fitting for the gametype here, such as current + // number of categories led + if (players[i].score >= tab[scorelines].count && completed[i] == false) + { + tab[scorelines].count = players[i].score; + tab[scorelines].num = i; + tab[scorelines].color = players[i].skincolor; + tab[scorelines].name = player_names[i]; + tab[scorelines].emeralds = players[i].powers[pw_emeralds]; + } + } + else + { + if (players[i].score >= tab[scorelines].count && completed[i] == false) + { + tab[scorelines].count = players[i].score; + tab[scorelines].num = i; + tab[scorelines].color = players[i].skincolor; + tab[scorelines].name = player_names[i]; + tab[scorelines].emeralds = players[i].powers[pw_emeralds]; + } + } } completed[tab[scorelines].num] = true; scorelines++; @@ -2988,7 +3148,7 @@ static void HU_DrawRankings(void) // shush, we'll do it anyway. if (G_GametypeHasTeams()) - HU_DrawTeamTabRankings(tab, whiteplayer); //separate function for Spazzo's silly request + HU_DrawTeamTabRankings(tab, whiteplayer); else if (scorelines <= 9 && !cv_compactscoreboard.value) HU_DrawTabRankings(40, 32, tab, scorelines, whiteplayer); else if (scorelines <= 20 && !cv_compactscoreboard.value) @@ -3003,59 +3163,54 @@ static void HU_DrawRankings(void) static void HU_DrawCoopOverlay(void) { - if (token -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_tokens) -#endif - ) + if (token && LUA_HudEnabled(hud_tokens)) { V_DrawString(168, 176, 0, va("- %d", token)); V_DrawSmallScaledPatch(148, 172, 0, tokenicon); } -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_tabemblems)) -#endif - if (!modifiedgame || savemoddata) + if (LUA_HudEnabled(hud_tabemblems) && (!modifiedgame || savemoddata)) { V_DrawString(160, 144, 0, va("- %d/%d", M_CountEmblems(), numemblems+numextraemblems)); V_DrawScaledPatch(128, 144 - SHORT(emblemicon->height)/4, 0, emblemicon); } -#ifdef HAVE_BLUA if (!LUA_HudEnabled(hud_coopemeralds)) return; -#endif if (emeralds & EMERALD1) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)-32, 0, emeraldpics[0]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)-32, 0, emeraldpics[0][0]); if (emeralds & EMERALD2) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8+24, (BASEVIDHEIGHT/3)-16, 0, emeraldpics[1]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8+24, (BASEVIDHEIGHT/3)-16, 0, emeraldpics[0][1]); if (emeralds & EMERALD3) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8+24, (BASEVIDHEIGHT/3)+16, 0, emeraldpics[2]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8+24, (BASEVIDHEIGHT/3)+16, 0, emeraldpics[0][2]); if (emeralds & EMERALD4) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)+32, 0, emeraldpics[3]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3)+32, 0, emeraldpics[0][3]); if (emeralds & EMERALD5) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8-24, (BASEVIDHEIGHT/3)+16, 0, emeraldpics[4]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8-24, (BASEVIDHEIGHT/3)+16, 0, emeraldpics[0][4]); if (emeralds & EMERALD6) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8-24, (BASEVIDHEIGHT/3)-16, 0, emeraldpics[5]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8-24, (BASEVIDHEIGHT/3)-16, 0, emeraldpics[0][5]); if (emeralds & EMERALD7) - V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3) , 0, emeraldpics[6]); + V_DrawScaledPatch((BASEVIDWIDTH/2)-8 , (BASEVIDHEIGHT/3) , 0, emeraldpics[0][6]); } static void HU_DrawNetplayCoopOverlay(void) { int i; -#ifdef HAVE_BLUA + if (token && LUA_HudEnabled(hud_tokens)) + { + V_DrawString(168, 10, 0, va("- %d", token)); + V_DrawSmallScaledPatch(148, 6, 0, tokenicon); + } + if (!LUA_HudEnabled(hud_coopemeralds)) return; -#endif for (i = 0; i < 7; ++i) { if (emeralds & (1 << i)) - V_DrawScaledPatch(20 + (i * 20), 6, 0, emeraldpics[i]); + V_DrawScaledPatch(20 + (i * 10), 9, 0, emeraldpics[1][i]); } } diff --git a/src/hu_stuff.h b/src/hu_stuff.h index b1d391828..9e3c66747 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,13 +28,19 @@ // Level title font #define LT_FONTSTART '!' // the first font characters -#define LT_FONTEND 'Z' // the last font characters +#define LT_FONTEND 'z' // the last font characters #define LT_FONTSIZE (LT_FONTEND - LT_FONTSTART + 1) #define CRED_FONTSTART '!' // the first font character #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) +// Name tag font +// Used by base and outline font set +#define NT_FONTSTART '!' // the first font character +#define NT_FONTEND 'Z' // the last font character +#define NT_FONTSIZE (NT_FONTEND - NT_FONTSTART + 1) + #define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init(); extern char *shiftxform; // english translation shift table @@ -77,14 +83,18 @@ extern patch_t *tallnum[10]; extern patch_t *nightsnum[10]; extern patch_t *lt_font[LT_FONTSIZE]; extern patch_t *cred_font[CRED_FONTSIZE]; -extern patch_t *emeraldpics[7]; -extern patch_t *tinyemeraldpics[7]; +extern patch_t *ntb_font[NT_FONTSIZE]; +extern patch_t *nto_font[NT_FONTSIZE]; +extern patch_t *ttlnum[20]; +extern patch_t *emeraldpics[3][8]; extern patch_t *rflagico; extern patch_t *bflagico; extern patch_t *rmatcico; extern patch_t *bmatcico; extern patch_t *tagico; extern patch_t *tallminus; +extern patch_t *tallinfin; +extern patch_t *tokenicon; // set true whenever the tab rankings are being shown for any reason extern boolean hu_showscores; @@ -103,7 +113,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(INT32 x, INT32 y, INT32 ping, boolean notext); // Lat': Ping drawer for scoreboard. +void HU_drawPing(INT32 x, INT32 y, UINT32 ping, boolean notext, INT32 flags); // Lat': Ping drawer for scoreboard. void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); diff --git a/src/i_addrinfo.c b/src/i_addrinfo.c index 03edf732d..e77774549 100644 --- a/src/i_addrinfo.c +++ b/src/i_addrinfo.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2011-2018 by Sonic Team Junior. +// Copyright (C) 2011-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -20,17 +20,11 @@ #else #include #endif -#elif !defined (__DJGPP__) && !defined(_WII) +#elif !defined (__DJGPP__) #include -#ifndef _NDS #include -#endif -#ifdef _PS3 -#include -#elif ! defined (_arch_dreamcast) #include #endif -#endif #include "i_addrinfo.h" @@ -74,10 +68,10 @@ static int inet_aton(const char *cp, struct in_addr *addr) #ifdef USE_WINSOCK2 static HMODULE ipv6dll = NULL; -typedef int (WSAAPI *p_getaddrinfo) (const char *node, const char *service, - const struct my_addrinfo *hints, - struct my_addrinfo **res); -typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *res); +typedef int (WSAAPI *p_getaddrinfo) (const char *, const char *, + const struct my_addrinfo *, + struct my_addrinfo **); +typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *); static p_getaddrinfo WS_getaddrinfo = NULL; static p_freeaddrinfo WS_freeaddrinfo = NULL; @@ -86,10 +80,10 @@ static HMODULE WS_getfunctions(HMODULE tmp) { if (tmp != NULL) { - WS_getaddrinfo = (p_getaddrinfo)GetProcAddress(tmp, "getaddrinfo"); + WS_getaddrinfo = (p_getaddrinfo)(LPVOID)GetProcAddress(tmp, "getaddrinfo"); if (WS_getaddrinfo == NULL) return NULL; - WS_freeaddrinfo = (p_freeaddrinfo)GetProcAddress(tmp, "freeaddrinfo"); + WS_freeaddrinfo = (p_freeaddrinfo)(LPVOID)GetProcAddress(tmp, "freeaddrinfo"); if (WS_freeaddrinfo == NULL) { WS_getaddrinfo = NULL; @@ -262,9 +256,6 @@ int I_getaddrinfo(const char *node, const char *service, for (i = 0, j = 0; i < ailen; i++, j++) { ai = *res+i; -#ifdef _PS3 - addr[i].sin_len = famsize; -#endif addr[i].sin_port = htons((UINT16)sockport); if (nodename) { diff --git a/src/i_addrinfo.h b/src/i_addrinfo.h index 1b8ce9153..7ae006719 100644 --- a/src/i_addrinfo.h +++ b/src/i_addrinfo.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2011-2018 by Sonic Team Junior. +// Copyright (C) 2011-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -39,17 +39,7 @@ #define EAI_NONAME -2 #endif -#ifdef _PS3 // PSL1GHT v2 -struct my_addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - struct sockaddr *ai_addr; - struct my_addrinfo *ai_next; -}; -#elif defined (_WIN32) // already use the stub for Win32 +#ifdef _WIN32 // already use the stub for Win32 // w32api, ws2tcpip.h, r1.12 struct my_addrinfo { int ai_flags; diff --git a/src/i_joy.h b/src/i_joy.h index 27013f011..2a2797fc4 100644 --- a/src/i_joy.h +++ b/src/i_joy.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_net.h b/src/i_net.h index 0e17077bb..5d93f191e 100644 --- a/src/i_net.h +++ b/src/i_net.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_sound.h b/src/i_sound.h index fd73d1454..4bd05d234 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -30,7 +30,9 @@ typedef enum { MU_MP3_MAD_UNUSED, // use MU_MP3 instead MU_FLAC, MU_MODPLUG_UNUSED, // use MU_MOD instead - MU_GME + MU_GME, + MU_MOD_EX, // libopenmpt + MU_MID_EX // Non-native MIDI } musictype_t; /** \brief Sound subsystem runing and waiting @@ -146,6 +148,18 @@ boolean I_SongPaused(void); boolean I_SetSongSpeed(float speed); +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void); + +boolean I_SetSongLoopPoint(UINT32 looppoint); +UINT32 I_GetSongLoopPoint(void); + +boolean I_SetSongPosition(UINT32 position); +UINT32 I_GetSongPosition(void); + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -216,6 +230,17 @@ void I_SetMusicVolume(UINT8 volume); boolean I_SetSongTrack(INT32 track); +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume); +void I_StopFadingSong(void); +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)); +boolean I_FadeOutStopSong(UINT32 ms); +boolean I_FadeInPlaySong(UINT32 ms, boolean looping); + /// ------------------------ // CD MUSIC I/O /// ------------------------ diff --git a/src/i_system.h b/src/i_system.h index a8d707d16..b38748244 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -184,10 +184,6 @@ void I_StartupMouse(void); */ void I_StartupMouse2(void); -/** \brief keyboard startup, shutdown, handler -*/ -void I_StartupKeyboard(void); - /** \brief setup timer irq and user timer routine. */ void I_StartupTimer(void); @@ -292,6 +288,10 @@ void I_GetJoystick2Events(void); */ void I_GetMouseEvents(void); +/** \brief Checks if the mouse needs to be grabbed +*/ +void I_UpdateMouseGrab(void); + char *I_GetEnv(const char *name); INT32 I_PutEnv(char *variable); diff --git a/src/i_tcp.c b/src/i_tcp.c index 11a84ceba..34cad1765 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -18,20 +18,12 @@ #ifdef __GNUC__ #include #endif -#ifdef __OS2__ -#include -#include -#endif // __OS2__ - -#ifdef _PS3 -#define NO_IPV6 // PSL1GHT v2 do not have IPv6 support -#endif #ifndef NO_IPV6 #define HAVE_IPV6 #endif -#if defined (_WIN32) || defined (_WIN32_WCE) +#ifdef _WIN32 #define USE_WINSOCK #if defined (_WIN64) || defined (HAVE_IPV6) #define USE_WINSOCK2 @@ -40,12 +32,6 @@ #endif #endif //WIN32 OS -#ifdef _XBOX // XBox have on WinSock API? -#undef USE_WINSOCK -#undef USE_WINSOCK1 -#undef USE_WINSOCK2 -#endif - #ifdef USE_WINSOCK2 #include #endif @@ -61,17 +47,12 @@ #else #ifdef USE_WINSOCK1 #include -#elif !defined (SCOUW2) && !defined (SCOUW7) && !defined (__OS2__) -#ifdef HAVE_LWIP -#include -#elif !defined (USE_WINSOCK) +#elif !defined (SCOUW2) && !defined (SCOUW7) +#ifndef USE_WINSOCK #include #endif //normal BSD API -#ifdef HAVE_LWIP -#include -#define ioctl lwip_ioctl -#elif !defined (USE_WINSOCK) //!HAVE_LWIP +#ifndef USE_WINSOCK #ifdef __APPLE_CC__ #ifndef _BSD_SOCKLEN_T_ #define _BSD_SOCKLEN_T_ @@ -81,14 +62,7 @@ #include #endif //normal BSD API -#if defined(_arch_dreamcast) && !defined(HAVE_LWIP) -#include -#elif defined(HAVE_LWIP) -#include -#elif defined (_PS3) -#include -#include -#elif !defined(USE_WINSOCK) //!HAVE_LWIP +#ifndef USE_WINSOCK #include #include #endif //normal BSD API @@ -96,10 +70,6 @@ #include #include -#ifdef _arch_dreamcast -#include "sdl12/SRB2DC/dchelp.h" -#endif - #if (defined (__unix__) && !defined (MSDOS)) || defined(__APPLE__) || defined (UNIXCOMMON) #include #endif // UNIXCOMMON @@ -190,11 +160,6 @@ static UINT8 UPNP_support = TRUE; // winsock stuff (in winsock a socket is not a file) #define ioctl ioctlsocket #define close closesocket - - #ifdef _WIN32_WCE - #include "sdl12/SRB2CE/cehelp.h" - #endif - #endif #include "i_addrinfo.h" @@ -205,9 +170,7 @@ static UINT8 UPNP_support = TRUE; #define SELECTTEST #endif -#elif defined(HAVE_LWIP) -#define SELECTTEST -#elif !defined( _arch_dreamcast) +#else #define SELECTTEST #endif @@ -217,7 +180,7 @@ static UINT8 UPNP_support = TRUE; typedef SOCKET SOCKET_TYPE; #define ERRSOCKET (SOCKET_ERROR) #else -#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__) || defined(_PS3) +#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__) typedef int SOCKET_TYPE; #else typedef unsigned long SOCKET_TYPE; @@ -246,7 +209,8 @@ static size_t numbans = 0; static boolean SOCK_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? static boolean init_tcp_driver = false; -static char port_name[8] = DEFAULTPORT; +static const char *serverport_name = DEFAULTPORT; +static const char *clientport_name;/* any port */ #ifndef NONET @@ -813,6 +777,8 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen #endif #endif mysockaddr_t straddr; + struct sockaddr_in sin; + socklen_t len = sizeof(sin); if (s == (SOCKET_TYPE)ERRSOCKET) return (SOCKET_TYPE)ERRSOCKET; @@ -906,18 +872,23 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10); } + if (getsockname(s, (struct sockaddr *)&sin, &len) == -1) + CONS_Alert(CONS_WARNING, M_GetText("Failed to get port number\n")); + else + current_port = (UINT16)ntohs(sin.sin_port); + return s; } static boolean UDP_Socket(void) { - const char *sock_port = NULL; size_t s; struct my_addrinfo *ai, *runp, hints; int gaie; #ifdef HAVE_IPV6 const INT32 b_ipv6 = M_CheckParm("-ipv6"); #endif + const char *serv; for (s = 0; s < mysocketses; s++) @@ -933,20 +904,16 @@ static boolean UDP_Socket(void) hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; - if (M_CheckParm("-clientport")) - { - if (!M_IsNextParm()) - I_Error("syntax: -clientport "); - sock_port = M_GetNextParm(); - } + if (serverrunning) + serv = serverport_name; else - sock_port = port_name; + serv = clientport_name; if (M_CheckParm("-bindaddr")) { while (M_IsNextParm()) { - gaie = I_getaddrinfo(M_GetNextParm(), sock_port, &hints, &ai); + gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -967,7 +934,7 @@ static boolean UDP_Socket(void) } else { - gaie = I_getaddrinfo("0.0.0.0", sock_port, &hints, &ai); + gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -982,8 +949,8 @@ static boolean UDP_Socket(void) #ifdef HAVE_MINIUPNPC if (UPNP_support) { - I_UPnP_rem(sock_port, "UDP"); - I_UPnP_add(NULL, sock_port, "UDP"); + I_UPnP_rem(serverport_name, "UDP"); + I_UPnP_add(NULL, serverport_name, "UDP"); } #endif } @@ -1000,7 +967,7 @@ static boolean UDP_Socket(void) { while (M_IsNextParm()) { - gaie = I_getaddrinfo(M_GetNextParm(), sock_port, &hints, &ai); + gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1021,7 +988,7 @@ static boolean UDP_Socket(void) } else { - gaie = I_getaddrinfo("::", sock_port, &hints, &ai); + gaie = I_getaddrinfo("::", serv, &hints, &ai); if (gaie == 0) { runp = ai; @@ -1177,12 +1144,6 @@ boolean I_InitTcpDriver(void) CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription); CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus); #endif -#ifdef HAVE_LWIP - lwip_kos_init(); -#elif defined(_arch_dreamcast) - //return; - net_init(); -#endif #ifdef __DJGPP__ #ifdef WATTCP // Alam_GBC: survive bootp, dhcp, rarp and wattcp/pktdrv from failing to load survive_eth = 1; // would be needed to not exit if pkt_eth_init() fails @@ -1235,9 +1196,6 @@ boolean I_InitTcpDriver(void) CONS_Debug(DBG_NETPLAY, "No TCP/IP driver detected\n"); #endif // libsocket #endif // __DJGPP__ -#ifdef _PS3 - netInitialize(); -#endif #ifndef __DJGPP__ init_tcp_driver = true; #endif @@ -1285,11 +1243,6 @@ void I_ShutdownTcpDriver(void) WS_addrinfocleanup(); WSACleanup(); #endif -#ifdef HAVE_LWIP - lwip_kos_shutdown(); -#elif defined(_arch_dreamcast) - net_shutdown(); -#endif #ifdef __DJGPP__ #ifdef WATTCP // wattcp //_outch = NULL; @@ -1298,9 +1251,6 @@ void I_ShutdownTcpDriver(void) __lsck_uninit(); #endif // libsocket #endif // __DJGPP__ -#ifdef _PS3 - netDeinitialize(); -#endif CONS_Printf("shut down\n"); init_tcp_driver = false; #endif @@ -1314,7 +1264,7 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port) int gaie; if (!port || !port[0]) - port = port_name; + port = DEFAULTPORT; DEBFILE(va("Creating new node: %s@%s\n", address, port)); @@ -1478,14 +1428,19 @@ boolean I_InitTcpNetwork(void) if (!I_InitTcpDriver()) return false; - if (M_CheckParm("-udpport")) + if (M_CheckParm("-port") || M_CheckParm("-serverport")) + // Combined -udpport and -clientport into -port + // As it was really redundant having two seperate parms that does the same thing + /* Sorry Steel, I'm adding these back. But -udpport is a stupid name. */ { - if (M_IsNextParm()) - strcpy(port_name, M_GetNextParm()); - else - strcpy(port_name, "0"); + /* + If it's NULL, that's okay! Because then + we'll get a random port from getaddrinfo. + */ + serverport_name = M_GetNextParm(); } - current_port = (UINT16)atoi(port_name); + if (M_CheckParm("-clientport")) + clientport_name = M_GetNextParm(); // parse network game options, if (M_CheckParm("-server") || dedicated) diff --git a/src/i_tcp.h b/src/i_tcp.h index 06680cd9b..738b8b4d1 100644 --- a/src/i_tcp.h +++ b/src/i_tcp.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/i_video.h b/src/i_video.h index 4bb2c5829..bdc10c9c5 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -32,10 +32,14 @@ typedef enum render_none = 3 // for dedicated server } rendermode_t; -/** \brief currect render mode +/** \brief current render mode */ extern rendermode_t rendermode; +/** \brief hardware renderer loaded + 0 = never loaded, 1 = loaded successfully, -1 = failed loading +*/ +extern INT32 hwrenderloaded; /** \brief use highcolor modes if true */ @@ -45,6 +49,10 @@ extern boolean highcolor; */ void I_StartupGraphics(void); +/** \brief setup hardware mode +*/ +void I_StartupHardwareGraphics(void); + /** \brief restore old video mode */ void I_ShutdownGraphics(void); @@ -81,10 +89,14 @@ INT32 VID_GetModeForSize(INT32 w, INT32 h); \param modenum video mode to set to - \return currect video mode + \return current video mode */ INT32 VID_SetMode(INT32 modenum); +/** \brief Checks the render state +*/ +void VID_CheckRenderer(void); + /** \brief The VID_GetModeName function \param modenum video mode number diff --git a/src/info.c b/src/info.c index 08470d4cd..bd6ccb527 100644 --- a/src/info.c +++ b/src/info.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -16,6 +16,7 @@ #include "doomstat.h" #include "sounds.h" #include "p_mobj.h" +#include "p_local.h" // DMG_ constants #include "m_misc.h" #include "z_zone.h" #include "d_player.h" @@ -25,43 +26,653 @@ #endif // Hey, moron! If you change this table, don't forget about the sprite enum in info.h and the sprite lights in hw_light.c! +// For the sake of constant merge conflicts, let's spread this out char sprnames[NUMSPRITES + 1][5] = { - "NULL","UNKN","THOK","PLAY","POSS","SPOS","FISH","BUZZ","RBUZ","JETB", - "JETW","JETG","CCOM","DETN","SKIM","TRET","TURR","SHRP","JJAW","SNLR", - "VLTR","PNTY","ARCH","CBFS","SPSH","ESHI","GSNP","MNUS","SSHL","UNID", - "BBUZ","JETF","EGGM","EGGN","TNKA","TNKB","SPNK","GOOP","EGGO","PRPL", - "FAKE","EGGP","EFIR","EGGQ","EGGR","BRAK","BGOO","BMSL","EGGT","RCKT", - "ELEC","TARG","NPLM","MNPL","METL","MSCF","MSCB","RING","TRNG","EMMY", - "TOKE","RFLG","BFLG","NWNG","EMBM","CEMG","EMER","FANS","BUBL","SIGN", - "STEM","SPIK","SFLM","USPK","STPT","BMNE","SRBX","RRBX","BRBX","SHTV", - "PINV","YLTV","BLTV","BKTV","WHTV","GRTV","ELTV","EGGB","MIXU","RECY", - "QUES","GBTV","PRUP","PTTV","MTEX","MISL","TORP","ENRG","MINE","JBUL", - "TRLS","CBLL","AROW","CFIR","FWR1","FWR2","FWR3","FWR4","BUS1","BUS2", - "THZP","ALRM","GARG","SEWE","DRIP","CRL1","CRL2","CRL3","BCRY","CHAN", - "FLAM","ESTA","SMCH","BMCH","SMCE","BMCE","BTBL","STBL","CACT","FLME", - "DFLM","XMS1","XMS2","XMS3","BSZ1","BSZ2","BSZ3","BSZ4","BSZ5","BSZ6", - "BSZ7","BSZ8","STLG","DBAL","RCRY","ARMA","ARMF","ARMB","WIND","MAGN", - "ELEM","FORC","PITY","IVSP","SSPK","GOAL","BIRD","BUNY","MOUS","CHIC", - "COWZ","RBRD","SPRY","SPRR","SPRB","YSPR","RSPR","RAIN","SNO1","SPLH", - "SPLA","SMOK","BUBP","BUBO","BUBN","BUBM","POPP","TFOG","SEED","PRTL", - "SCOR","DRWN","TTAG","GFLG","RRNG","RNGB","RNGR","RNGI","RNGA","RNGE", - "RNGS","RNGG","PIKB","PIKR","PIKA","PIKE","PIKS","PIKG","TAUT","TGRE", - "TSCR","COIN","CPRK","GOOM","BGOM","FFWR","FBLL","SHLL","PUMA","HAMM", - "KOOP","BFLM","MAXE","MUS1","MUS2","TOAD","NDRN","SUPE","SUPZ","NDRL", - "NSPK","NBMP","HOOP","NSCR","NPRU","CAPS","SUPT","SPRK","BOM1","BOM2", - "BOM3","BOM4","ROIA","ROIB","ROIC","ROID","ROIE","ROIF","ROIG","ROIH", - "ROII","ROIJ","ROIK","ROIL","ROIM","ROIN","ROIO","ROIP","BBAL","GWLG", - "GWLR","SRBA","SRBB","SRBC","SRBD","SRBE","SRBF","SRBG","SRBH","SRBI", - "SRBJ","SRBK","SRBL","SRBM","SRBN","SRBO", + "NULL", // invisible object + "UNKN", + + "THOK", // Thok! mobj + "PLAY", + + // Enemies + "POSS", // Crawla (Blue) + "SPOS", // Crawla (Red) + "FISH", // SDURF + "BUZZ", // Buzz (Gold) + "RBUZ", // Buzz (Red) + "JETB", // Jetty-Syn Bomber + "JETG", // Jetty-Syn Gunner + "CCOM", // Crawla Commander + "DETN", // Deton + "SKIM", // Skim mine dropper + "TRET", // Industrial Turret + "TURR", // Pop-Up Turret + "SHRP", // Sharp + "CRAB", // Crushstacean + "CR2B", // Banpyura + "CSPR", // Banpyura spring + "JJAW", // Jet Jaw + "SNLR", // Snailer + "VLTR", // BASH + "PNTY", // Pointy + "ARCH", // Robo-Hood + "CBFS", // Castlebot Facestabber + "STAB", // Castlebot Facestabber spear aura + "SPSH", // Egg Guard + "ESHI", // Egg Guard's shield + "GSNP", // Green Snapper + "GSNL", // Green Snapper leg + "GSNH", // Green Snapper head + "MNUS", // Minus + "MNUD", // Minus dirt + "SSHL", // Spring Shell + "UNID", // Unidus + "CANA", // Canarivore + "CANG", // Canarivore gas + "PYRE", // Pyre Fly + "PTER", // Pterabyte + "DRAB", // Dragonbomber + + // Generic Boss Items + "JETF", // Boss jet fumes + + // Boss 1 (Greenflower) + "EGGM", // Boss 1 + "EGLZ", // Boss 1 Junk + + // Boss 2 (Techno Hill) + "EGGN", // Boss 2 + "TANK", // Boss 2 Junk + "GOOP", // Boss 2 Goop + + // Boss 3 (Deep Sea) + "EGGO", // Boss 3 + "SEBH", // Boss 3 Junk + "FAKE", // Boss 3 Fakemobile + "SHCK", // Boss 3 Shockwave + + // Boss 4 (Castle Eggman) + "EGGP", + "EFIR", // Boss 4 jet flame + "EGR1", // Boss 4 Spectator Eggrobo + + // Boss 5 (Arid Canyon) + "FANG", // replaces EGGQ + "BRKN", // broken robot chunk + "WHAT", // alart + "VWRE", + "PROJ", // projector light + "FBOM", + "FSGN", + "BARX", // bomb explosion (also used by barrel) + "BARD", // bomb dust (also used by barrel) + + // Boss 6 (Red Volcano) + "EGGR", + + // Boss 7 (Dark City) + "BRAK", + "BGOO", // Goop + "BMSL", + + // Boss 8 (Egg Rock) + "EGGT", + + // Cy-Brak-Demon; uses "BRAK" as well, but has some extras + "RCKT", // Rockets! + "ELEC", // Electricity! + "TARG", // Targeting reticules! + "NPLM", // Big napalm bombs! + "MNPL", // Mini napalm bombs! + + // Metal Sonic + "METL", + "MSCF", + "MSCB", + + // Collectible Items + "RING", + "TRNG", // Team Rings + "TOKE", // Special Stage Token + "RFLG", // Red CTF Flag + "BFLG", // Blue CTF Flag + "SPHR", // Sphere + "NCHP", // NiGHTS chip + "NSTR", // NiGHTS star + "EMBM", // Emblem + "CEMG", // Chaos Emeralds + "SHRD", // Emerald hunt shards + + // Interactive Objects + "BBLS", // water bubble source + "SIGN", // Level end sign + "SPIK", // Spike Ball + "SFLM", // Spin fire + "USPK", // Floor spike + "WSPK", // Wall spike + "WSPB", // Wall spike base + "STPT", // Starpost + "BMNE", // Big floating mine + "PUMI", // Rollout Rock + + // Monitor Boxes + "MSTV", // MiSc TV sprites + "XLTV", // eXtra Large TV sprites + + "TRRI", // Red team: 10 RIngs + "TBRI", // Blue team: 10 RIngs + + "TVRI", // 10 RIng + "TVPI", // PIty shield + "TVAT", // ATtraction shield + "TVFO", // FOrce shield + "TVAR", // ARmageddon shield + "TVWW", // WhirlWind shield + "TVEL", // ELemental shield + "TVSS", // Super Sneakers + "TVIV", // InVincibility + "TV1U", // 1Up + "TV1P", // 1uP (textless) + "TVEG", // EGgman + "TVMX", // MiXup + "TVMY", // MYstery + "TVGV", // GraVity boots + "TVRC", // ReCycler + "TV1K", // 1,000 points (1 K) + "TVTK", // 10,000 points (Ten K) + "TVFL", // FLame shield + "TVBB", // BuBble shield + "TVZP", // Thunder shield (ZaP) + + // Projectiles + "MISL", + "TORP", // Torpedo + "ENRG", // Energy ball + "MINE", // Skim mine + "JBUL", // Jetty-Syn Bullet + "TRLS", + "CBLL", // Cannonball + "AROW", // Arrow + "CFIR", // Colored fire of various sorts + + // The letter + "LETR", + + // Greenflower Scenery + "FWR1", + "FWR2", // GFZ Sunflower + "FWR3", // GFZ budding flower + "FWR4", + "BUS1", // GFZ Bush w/ berries + "BUS2", // GFZ Bush w/o berries + "BUS3", // GFZ Bush w/ BLUE berries + // Trees (both GFZ and misc) + "TRE1", // GFZ + "TRE2", // Checker + "TRE3", // Frozen Hillside + "TRE4", // Polygon + "TRE5", // Bush tree + "TRE6", // Spring tree + + // Techno Hill Scenery + "THZP", // THZ1 Steam Flower + "FWR5", // THZ1 Spin flower (red) + "FWR6", // THZ1 Spin flower (yellow) + "THZT", // Steam Whistle tree/bush + "ALRM", // THZ2 Alarm + + // Deep Sea Scenery + "GARG", // Deep Sea Gargoyle + "SEWE", // Deep Sea Seaweed + "DRIP", // Dripping water + "CORL", // Coral + "BCRY", // Blue Crystal + "KELP", // Kelp + "ALGA", // Animated algae top + "ALGB", // Animated algae segment + "DSTG", // DSZ Stalagmites + "LIBE", // DSZ Light beam + + // Castle Eggman Scenery + "CHAN", // CEZ Chain + "FLAM", // Flame + "ESTA", // Eggman esta una estatua! + "SMCH", // Small Mace Chain + "BMCH", // Big Mace Chain + "SMCE", // Small Mace + "BMCE", // Big Mace + "YSPB", // Yellow spring on a ball + "RSPB", // Red spring on a ball + "SFBR", // Small Firebar + "BFBR", // Big Firebar + "BANR", // Banner + "PINE", // Pine Tree + "CEZB", // Bush + "CNDL", // Candle/pricket + "FLMH", // Flame holder + "CTRC", // Fire torch + "CFLG", // Waving flag/segment + "CSTA", // Crawla statue + "CBBS", // Facestabber statue + "CABR", // Brambles + + // Arid Canyon Scenery + "BTBL", // Big tumbleweed + "STBL", // Small tumbleweed + "CACT", // Cacti + "WWSG", // Caution Sign + "WWS2", // Cacti Sign + "WWS3", // Sharp Turn Sign + "OILL", // Oil lamp + "OILF", // Oil lamp flare + "BARR", // TNT barrel + "REMT", // TNT proximity shell + "TAZD", // Dust devil + "ADST", // Arid dust + "MCRT", // Minecart + "MCSP", // Minecart spark + "SALD", // Saloon door + "TRAE", // Train cameo locomotive + "TRAI", // Train cameo wagon + "STEA", // Train steam + + // Red Volcano Scenery + "FLME", // Flame jet + "DFLM", // Blade's flame + "LFAL", // Lavafall + "JPLA", // Jungle palm + "TFLO", // Torch flower + "WVIN", // Wall vines + + // Dark City Scenery + + // Egg Rock Scenery + + // Christmas Scenery + "XMS1", // Christmas Pole + "XMS2", // Candy Cane + "XMS3", // Snowman + "XMS4", // Lamppost + "XMS5", // Hanging Star + "XMS6", // Mistletoe + "FHZI", // FHZ ice + "ROSY", + + // Halloween Scenery + "PUMK", // Pumpkins + "HHPL", // Dr Seuss Trees + "SHRM", // Mushroom + "HHZM", // Misc + + // Azure Temple Scenery + "BGAR", // ATZ Gargoyles + "RCRY", // ATZ Red Crystal (Target) + "CFLM", // Green torch flame + + // Botanic Serenity Scenery + "BSZ1", // Tall flowers + "BSZ2", // Medium flowers + "BSZ3", // Small flowers + //"BSZ4", -- Tulips + "BST1", // Red tulip + "BST2", // Purple tulip + "BST3", // Blue tulip + "BST4", // Cyan tulip + "BST5", // Yellow tulip + "BST6", // Orange tulip + "BSZ5", // Cluster of Tulips + "BSZ6", // Bush + "BSZ7", // Vine + "BSZ8", // Misc things + + // Misc Scenery + "STLG", // Stalagmites + "DBAL", // Disco + + // Powerup Indicators + "ARMA", // Armageddon Shield Orb + "ARMF", // Armageddon Shield Ring, Front + "ARMB", // Armageddon Shield Ring, Back + "WIND", // Whirlwind Shield Orb + "MAGN", // Attract Shield Orb + "ELEM", // Elemental Shield Orb and Fire + "FORC", // Force Shield Orb + "PITY", // Pity Shield Orb + "FIRS", // Flame Shield Orb + "BUBS", // Bubble Shield Orb + "ZAPS", // Thunder Shield Orb + "IVSP", // invincibility sparkles + "SSPK", // Super Sonic Spark + + "GOAL", // Special Stage goal (here because lol NiGHTS) + + // Flickies + "FBUB", // Flicky-sized bubble + "FL01", // Bluebird + "FL02", // Rabbit + "FL03", // Chicken + "FL04", // Seal + "FL05", // Pig + "FL06", // Chipmunk + "FL07", // Penguin + "FL08", // Fish + "FL09", // Ram + "FL10", // Puffin + "FL11", // Cow + "FL12", // Rat + "FL13", // Bear + "FL14", // Dove + "FL15", // Cat + "FL16", // Canary + "FS01", // Spider + "FS02", // Bat + + // Springs + "FANS", // Fan + "STEM", // Steam riser + "BUMP", // Bumpers + "BLON", // Balloons + "SPRY", // Yellow spring + "SPRR", // Red spring + "SPRB", // Blue spring + "YSPR", // Yellow Diagonal Spring + "RSPR", // Red Diagonal Spring + "BSPR", // Blue Diagonal Spring + "SSWY", // Yellow Side Spring + "SSWR", // Red Side Spring + "SSWB", // Blue Side Spring + "BSTY", // Yellow Booster + "BSTR", // Red Booster + + // Environmental Effects + "RAIN", // Rain + "SNO1", // Snowflake + "SPLH", // Water Splish + "LSPL", // Lava Splish + "SPLA", // Water Splash + "SMOK", + "BUBL", // Bubble + "WZAP", + "DUST", // Spindash dust + "FPRT", // Spindash dust (flame) + "TFOG", // Teleport Fog + "SEED", // Sonic CD flower seed + "PRTL", // Particle (for fans, etc.) + + // Game Indicators + "SCOR", // Score logo + "DRWN", // Drowning Timer + "FLII", // Flight indicator + "LCKN", // Target + "TTAG", // Tag Sign + "GFLG", // Got Flag sign + "FNSF", // Finish flag + + "CORK", + "LHRT", + + // Ring Weapons + "RRNG", // Red Ring + "RNGB", // Bounce Ring + "RNGR", // Rail Ring + "RNGI", // Infinity Ring + "RNGA", // Automatic Ring + "RNGE", // Explosion Ring + "RNGS", // Scatter Ring + "RNGG", // Grenade Ring + + "PIKB", // Bounce Ring Pickup + "PIKR", // Rail Ring Pickup + "PIKA", // Automatic Ring Pickup + "PIKE", // Explosion Ring Pickup + "PIKS", // Scatter Ring Pickup + "PIKG", // Grenade Ring Pickup + + "TAUT", // Thrown Automatic Ring + "TGRE", // Thrown Grenade Ring + "TSCR", // Thrown Scatter Ring + + // Mario-specific stuff + "COIN", + "CPRK", + "GOOM", + "BGOM", + "FFWR", + "FBLL", + "SHLL", + "PUMA", + "HAMM", + "KOOP", + "BFLM", + "MAXE", + "MUS1", + "MUS2", + "TOAD", + + // NiGHTS Stuff + "NDRN", // NiGHTS drone + "NSPK", // NiGHTS sparkle + "NBMP", // NiGHTS Bumper + "HOOP", // NiGHTS hoop sprite + "NSCR", // NiGHTS score sprite + "NPRU", // Nights Powerups + "CAPS", // Capsule thingy for NiGHTS + "IDYA", // Ideya + "NTPN", // Nightopian + "SHLP", // Shleep + + // Secret badniks and hazards, shhhh + "PENG", + "POPH", + "HIVE", + "BUMB", + "BBUZ", + "FMCE", + "HMCE", + "CACO", + "BAL2", + "SBOB", + "SBFL", + "SBSK", + "HBAT", + + // Debris + "SPRK", // Sparkle + "BOM1", // Robot Explosion + "BOM2", // Boss Explosion 1 + "BOM3", // Boss Explosion 2 + "BOM4", // Underwater Explosion + "BMNB", // Mine Explosion + + // Crumbly rocks + "ROIA", + "ROIB", + "ROIC", + "ROID", + "ROIE", + "ROIF", + "ROIG", + "ROIH", + "ROII", + "ROIJ", + "ROIK", + "ROIL", + "ROIM", + "ROIN", + "ROIO", + "ROIP", + + // Level debris + "GFZD", // GFZ debris + "BRIC", // Bricks + "WDDB", // Wood Debris + + // Gravity Well Objects + "GWLG", + "GWLR", +}; + +char spr2names[NUMPLAYERSPRITES][5] = +{ + "STND", + "WAIT", + "WALK", + "SKID", + "RUN_", + "DASH", + "PAIN", + "STUN", + "DEAD", + "DRWN", + "ROLL", + "GASP", + "JUMP", + "SPNG", + "FALL", + "EDGE", + "RIDE", + + "SPIN", + + "FLY_", + "SWIM", + "TIRE", + + "GLID", + "LAND", + "CLNG", + "CLMB", + + "FLT_", + "FRUN", + + "BNCE", + + "FIRE", + + "TWIN", + + "MLEE", + "MLEL", + + "TRNS", + + "NSTD", + "NFLT", + "NFLY", + "NDRL", + "NSTN", + "NPUL", + "NATK", + + "TAL0", + "TAL1", + "TAL2", + "TAL3", + "TAL4", + "TAL5", + "TAL6", + "TAL7", + "TAL8", + "TAL9", + "TALA", + "TALB", + + "CNT1", + "CNT2", + "CNT3", + "CNT4", + + "SIGN", + "LIFE", + + "XTRA", +}; +playersprite_t free_spr2 = SPR2_FIRSTFREESLOT; + +playersprite_t spr2defaults[NUMPLAYERSPRITES] = { + 0, // SPR2_STND, + 0, // SPR2_WAIT, + 0, // SPR2_WALK, + SPR2_WALK, // SPR2_SKID, + SPR2_WALK, // SPR2_RUN , + SPR2_FRUN, // SPR2_DASH, + 0, // SPR2_PAIN, + SPR2_PAIN, // SPR2_STUN, + SPR2_PAIN, // SPR2_DEAD, + SPR2_DEAD, // SPR2_DRWN, + 0, // SPR2_ROLL, + SPR2_SPNG, // SPR2_GASP, + 0, // SPR2_JUMP, (conditional, will never be referenced) + SPR2_FALL, // SPR2_SPNG, + SPR2_WALK, // SPR2_FALL, + 0, // SPR2_EDGE, + SPR2_FALL, // SPR2_RIDE, + + SPR2_ROLL, // SPR2_SPIN, + + SPR2_SPNG, // SPR2_FLY , + SPR2_FLY , // SPR2_SWIM, + 0, // SPR2_TIRE, (conditional, will never be referenced) + + SPR2_FLY , // SPR2_GLID, + SPR2_ROLL, // SPR2_LAND, + SPR2_CLMB, // SPR2_CLNG, + SPR2_ROLL, // SPR2_CLMB, + + SPR2_WALK, // SPR2_FLT , + SPR2_RUN , // SPR2_FRUN, + + SPR2_FALL, // SPR2_BNCE, + + 0, // SPR2_FIRE, + + SPR2_ROLL, // SPR2_TWIN, + + SPR2_TWIN, // SPR2_MLEE, + 0, // SPR2_MLEL, + + 0, // SPR2_TRNS, + + FF_SPR2SUPER|SPR2_STND, // SPR2_NSTD, + FF_SPR2SUPER|SPR2_FALL, // SPR2_NFLT, + 0, // SPR2_NFLY, (will never be referenced unless skin 0 lacks this) + SPR2_NFLY, // SPR2_NDRL, + FF_SPR2SUPER|SPR2_STUN, // SPR2_NSTN, + SPR2_NSTN, // SPR2_NPUL, + FF_SPR2SUPER|SPR2_ROLL, // SPR2_NATK, + + 0, // SPR2_TAL0, (this will look mighty stupid but oh well) + SPR2_TAL0, // SPR2_TAL1, + SPR2_TAL1, // SPR2_TAL2, + SPR2_TAL2, // SPR2_TAL3, + SPR2_TAL1, // SPR2_TAL4, + SPR2_TAL4, // SPR2_TAL5, + SPR2_TAL0, // SPR2_TAL6, + SPR2_TAL3, // SPR2_TAL7, + SPR2_TAL7, // SPR2_TAL8, + SPR2_TAL0, // SPR2_TAL9, + SPR2_TAL9, // SPR2_TALA, + SPR2_TAL0, // SPR2_TALB, + + SPR2_WAIT, // SPR2_CNT1, + SPR2_FALL, // SPR2_CNT2, + SPR2_SPNG, // SPR2_CNT3, + SPR2_CNT1, // SPR2_CNT4, + + 0, // SPR2_SIGN, + 0, // SPR2_LIFE, + + 0, // SPR2_XTRA (should never be referenced) }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) state_t states[NUMSTATES] = { // frame is masked through FF_FRAMEMASK - // FF_ANIMATE (0x4000) makes simple state animations (var1 #frames, var2 tic delay) - // FF_FULLBRIGHT (0x8000) activates the fullbright colormap + // FF_ANIMATE makes simple state animations (var1 #frames, var2 tic delay) + // FF_FULLBRIGHT activates the fullbright colormap // use FF_TRANS10 - FF_TRANS90 for easy translucency // (or tr_trans10< "player_t" +// or players[0].powers -> "player_t.powers" +static int lib_userdataType(lua_State *L) +{ + lua_settop(L, 1); // pop everything except arg 1 (in case somebody decided to add more) + luaL_checktype(L, 1, LUA_TUSERDATA); + lua_pushstring(L, GetUserdataUType(L)); return 1; } @@ -154,6 +236,18 @@ static int lib_isPlayerAdmin(lua_State *L) return 1; } +static int lib_reserveLuabanks(lua_State *L) +{ + static boolean reserved = false; + if (!lua_lumploading) + return luaL_error(L, "luabanks[] cannot be reserved from within a hook or coroutine!"); + if (reserved) + return luaL_error(L, "luabanks[] has already been reserved! Only one savedata-enabled mod at a time may use this feature."); + reserved = true; + LUA_PushUserdata(L, &luabanks, META_LUABANKS); + return 1; +} + // M_RANDOM ////////////// @@ -199,15 +293,7 @@ static int lib_pRandomRange(lua_State *L) return 1; } -// Deprecated, macros, etc. -static int lib_pRandom(lua_State *L) -{ - NOHUD - LUA_Deprecated(L, "P_Random", "P_RandomByte"); - lua_pushinteger(L, P_RandomByte()); - return 1; -} - +// Macros. static int lib_pSignedRandom(lua_State *L) { NOHUD @@ -274,6 +360,41 @@ static int lib_pClosestPointOnLine(lua_State *L) return 2; } +static int lib_pPointOnLineSide(lua_State *L) +{ + int n = lua_gettop(L); + fixed_t x = luaL_checkfixed(L, 1); + fixed_t y = luaL_checkfixed(L, 2); + //HUDSAFE + if (lua_isuserdata(L, 3)) // use a real linedef to get our points + { + line_t *line = *((line_t **)luaL_checkudata(L, 3, META_LINE)); + if (!line) + return LUA_ErrInvalid(L, "line_t"); + lua_pushinteger(L, P_PointOnLineSide(x, y, line)); + } + else // use custom coordinates of our own! + { + vertex_t v1, v2; // fake vertexes + line_t junk; // fake linedef + + if (n < 6) + return luaL_error(L, "arguments 3 to 6 not all given (expected 4 fixed-point integers)"); + + v1.x = luaL_checkfixed(L, 3); + v1.y = luaL_checkfixed(L, 4); + v2.x = luaL_checkfixed(L, 5); + v2.y = luaL_checkfixed(L, 6); + + junk.v1 = &v1; + junk.v2 = &v2; + junk.dx = v2.x - v1.x; + junk.dy = v2.y - v1.y; + lua_pushinteger(L, P_PointOnLineSide(x, y, &junk)); + } + return 1; +} + // P_ENEMY ///////////// @@ -281,6 +402,7 @@ static int lib_pCheckMeleeRange(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_CheckMeleeRange(actor)); @@ -291,6 +413,7 @@ static int lib_pJetbCheckMeleeRange(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_JetbCheckMeleeRange(actor)); @@ -301,6 +424,7 @@ static int lib_pFaceStabCheckMeleeRange(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_FaceStabCheckMeleeRange(actor)); @@ -311,6 +435,7 @@ static int lib_pSkimCheckMeleeRange(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_SkimCheckMeleeRange(actor)); @@ -321,6 +446,7 @@ static int lib_pCheckMissileRange(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_CheckMissileRange(actor)); @@ -331,6 +457,7 @@ static int lib_pNewChaseDir(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); P_NewChaseDir(actor); @@ -344,6 +471,7 @@ static int lib_pLookForPlayers(lua_State *L) boolean allaround = lua_optboolean(L, 3); boolean tracer = lua_optboolean(L, 4); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_LookForPlayers(actor, allaround, tracer, dist)); @@ -360,16 +488,35 @@ static int lib_pSpawnMobj(lua_State *L) fixed_t z = luaL_checkfixed(L, 3); mobjtype_t type = luaL_checkinteger(L, 4); NOHUD + INLEVEL if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); LUA_PushUserdata(L, P_SpawnMobj(x, y, z, type), META_MOBJ); return 1; } +static int lib_pSpawnMobjFromMobj(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + fixed_t z = luaL_checkfixed(L, 4); + mobjtype_t type = luaL_checkinteger(L, 5); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + if (type >= NUMMOBJTYPES) + return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); + LUA_PushUserdata(L, P_SpawnMobjFromMobj(actor, x, y, z, type), META_MOBJ); + return 1; +} + static int lib_pRemoveMobj(lua_State *L) { mobj_t *th = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!th) return LUA_ErrInvalid(L, "mobj_t"); if (th->player) @@ -378,12 +525,52 @@ static int lib_pRemoveMobj(lua_State *L) return 0; } +// P_IsValidSprite2 technically doesn't exist, and probably never should... but too much would need to be exposed to allow this to be checked by other methods. + +static int lib_pIsValidSprite2(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + UINT8 spr2 = (UINT8)luaL_checkinteger(L, 2); + //HUDSAFE + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, (mobj->skin && (((skin_t *)mobj->skin)->sprites[spr2].numframes))); + return 1; +} + +// P_SpawnLockOn doesn't exist either, but we want to expose making a local mobj without encouraging hacks. + +static int lib_pSpawnLockOn(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *lockon = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + statenum_t state = luaL_checkinteger(L, 3); + NOHUD + INLEVEL + if (!lockon) + return LUA_ErrInvalid(L, "mobj_t"); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (state >= NUMSTATES) + return luaL_error(L, "state %d out of range (0 - %d)", state, NUMSTATES-1); + if (P_IsLocalPlayer(player)) // Only display it on your own view. + { + mobj_t *visual = P_SpawnMobj(lockon->x, lockon->y, lockon->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&visual->target, lockon); + visual->flags2 |= MF2_DONTDRAW; + P_SetMobjStateNF(visual, state); + } + return 0; +} + static int lib_pSpawnMissile(lua_State *L) { mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *dest = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); mobjtype_t type = luaL_checkinteger(L, 3); NOHUD + INLEVEL if (!source || !dest) return LUA_ErrInvalid(L, "mobj_t"); if (type >= NUMMOBJTYPES) @@ -401,6 +588,7 @@ static int lib_pSpawnXYZMissile(lua_State *L) fixed_t y = luaL_checkfixed(L, 5); fixed_t z = luaL_checkfixed(L, 6); NOHUD + INLEVEL if (!source || !dest) return LUA_ErrInvalid(L, "mobj_t"); if (type >= NUMMOBJTYPES) @@ -420,6 +608,7 @@ static int lib_pSpawnPointMissile(lua_State *L) fixed_t y = luaL_checkfixed(L, 7); fixed_t z = luaL_checkfixed(L, 8); NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (type >= NUMMOBJTYPES) @@ -437,6 +626,7 @@ static int lib_pSpawnAlteredDirectionMissile(lua_State *L) fixed_t z = luaL_checkfixed(L, 5); INT32 shiftingAngle = (INT32)luaL_checkinteger(L, 5); NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (type >= NUMMOBJTYPES) @@ -450,6 +640,7 @@ static int lib_pColorTeamMissile(lua_State *L) mobj_t *missile = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); player_t *source = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); NOHUD + INLEVEL if (!missile) return LUA_ErrInvalid(L, "mobj_t"); if (!source) @@ -466,6 +657,7 @@ static int lib_pSPMAngle(lua_State *L) UINT8 allowaim = (UINT8)luaL_optinteger(L, 4, 0); UINT32 flags2 = (UINT32)luaL_optinteger(L, 5, 0); NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (type >= NUMMOBJTYPES) @@ -480,6 +672,7 @@ static int lib_pSpawnPlayerMissile(lua_State *L) mobjtype_t type = luaL_checkinteger(L, 2); UINT32 flags2 = (UINT32)luaL_optinteger(L, 3, 0); NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (type >= NUMMOBJTYPES) @@ -492,6 +685,7 @@ static int lib_pMobjFlip(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); lua_pushinteger(L, P_MobjFlip(mobj)); @@ -502,6 +696,7 @@ static int lib_pGetMobjGravity(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); lua_pushfixed(L, P_GetMobjGravity(mobj)); @@ -524,6 +719,7 @@ static int lib_pFlashPal(lua_State *L) UINT16 type = (UINT16)luaL_checkinteger(L, 2); UINT16 duration = (UINT16)luaL_checkinteger(L, 3); NOHUD + INLEVEL if (!pl) return LUA_ErrInvalid(L, "player_t"); P_FlashPal(pl, type, duration); @@ -534,6 +730,7 @@ static int lib_pGetClosestAxis(lua_State *L) { mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); LUA_PushUserdata(L, P_GetClosestAxis(source), META_MOBJ); @@ -552,6 +749,7 @@ static int lib_pSpawnParaloop(lua_State *L) statenum_t nstate = luaL_optinteger(L, 8, S_NULL); boolean spawncenter = lua_optboolean(L, 9); NOHUD + INLEVEL if (type >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); if (nstate >= NUMSTATES) @@ -565,6 +763,7 @@ static int lib_pBossTargetPlayer(lua_State *L) mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); boolean closest = lua_optboolean(L, 2); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_BossTargetPlayer(actor, closest)); @@ -575,6 +774,7 @@ static int lib_pSupermanLook4Players(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_SupermanLook4Players(actor)); @@ -586,6 +786,7 @@ static int lib_pSetScale(lua_State *L) mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); fixed_t newscale = luaL_checkfixed(L, 2); NOHUD + INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); if (newscale < FRACUNIT/100) @@ -599,6 +800,7 @@ static int lib_pInsideANonSolidFFloor(lua_State *L) mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); ffloor_t *rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR)); //HUDSAFE + INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); if (!rover) @@ -611,6 +813,7 @@ static int lib_pCheckDeathPitCollide(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_CheckDeathPitCollide(mo)); @@ -619,14 +822,12 @@ static int lib_pCheckDeathPitCollide(lua_State *L) static int lib_pCheckSolidLava(lua_State *L) { - mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); ffloor_t *rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR)); //HUDSAFE - if (!mo) - return LUA_ErrInvalid(L, "mobj_t"); + INLEVEL if (!rover) return LUA_ErrInvalid(L, "ffloor_t"); - lua_pushboolean(L, P_CheckSolidLava(mo, rover)); + lua_pushboolean(L, P_CheckSolidLava(rover)); return 1; } @@ -635,6 +836,7 @@ static int lib_pCanRunOnWater(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); ffloor_t *rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR)); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); if (!rover) @@ -643,6 +845,19 @@ static int lib_pCanRunOnWater(lua_State *L) return 1; } +static int lib_pMaceRotate(lua_State *L) +{ + mobj_t *center = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + INT32 baserot = luaL_checkinteger(L, 2); + INT32 baseprevrot = luaL_checkinteger(L, 3); + NOHUD + INLEVEL + if (!center) + return LUA_ErrInvalid(L, "mobj_t"); + P_MaceRotate(center, baserot, baseprevrot); + return 0; +} + // P_USER //////////// @@ -650,6 +865,7 @@ static int lib_pGetPlayerHeight(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); lua_pushfixed(L, P_GetPlayerHeight(player)); @@ -660,6 +876,7 @@ static int lib_pGetPlayerSpinHeight(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); lua_pushfixed(L, P_GetPlayerSpinHeight(player)); @@ -670,6 +887,7 @@ static int lib_pGetPlayerControlDirection(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); lua_pushinteger(L, P_GetPlayerControlDirection(player)); @@ -681,16 +899,41 @@ static int lib_pAddPlayerScore(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); UINT32 amount = (UINT32)luaL_checkinteger(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_AddPlayerScore(player, amount); return 0; } +static int lib_pStealPlayerScore(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + UINT32 amount = (UINT32)luaL_checkinteger(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_StealPlayerScore(player, amount); + return 0; +} + +static int lib_pGetJumpFlags(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushinteger(L, P_GetJumpFlags(player)); + return 1; +} + static int lib_pPlayerInPain(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); lua_pushboolean(L, P_PlayerInPain(player)); @@ -702,6 +945,7 @@ static int lib_pDoPlayerPain(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); mobj_t *source = NULL, *inflictor = NULL; NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) @@ -716,16 +960,33 @@ static int lib_pResetPlayer(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_ResetPlayer(player); return 0; } +static int lib_pPlayerCanDamage(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + NOHUD // was hud safe but then i added a lua hook + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + if (!thing) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_PlayerCanDamage(player, thing)); + return 1; +} + + static int lib_pIsObjectInGoop(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_IsObjectInGoop(mo)); @@ -736,6 +997,7 @@ static int lib_pIsObjectOnGround(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_IsObjectOnGround(mo)); @@ -746,6 +1008,7 @@ static int lib_pInSpaceSector(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_InSpaceSector(mo)); @@ -756,6 +1019,7 @@ static int lib_pInQuicksand(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); //HUDSAFE + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_InQuicksand(mo)); @@ -768,19 +1032,71 @@ static int lib_pSetObjectMomZ(lua_State *L) fixed_t value = luaL_checkfixed(L, 2); boolean relative = lua_optboolean(L, 3); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); P_SetObjectMomZ(mo, value, relative); return 0; } +static int lib_pPlayJingle(lua_State *L) +{ + player_t *player = NULL; + jingletype_t jingletype = luaL_checkinteger(L, 2); + //NOHUD + //INLEVEL + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (jingletype >= NUMJINGLES) + return luaL_error(L, "jingletype %d out of range (0 - %d)", jingletype, NUMJINGLES-1); + P_PlayJingle(player, jingletype); + return 0; +} + +static int lib_pPlayJingleMusic(lua_State *L) +{ + player_t *player = NULL; + const char *musnamearg = luaL_checkstring(L, 2); + char musname[7], *p = musname; + UINT16 musflags = luaL_optinteger(L, 3, 0); + boolean looping = lua_opttrueboolean(L, 4); + jingletype_t jingletype = luaL_optinteger(L, 5, JT_OTHER); + //NOHUD + //INLEVEL + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (jingletype >= NUMJINGLES) + return luaL_error(L, "jingletype %d out of range (0 - %d)", jingletype, NUMJINGLES-1); + + musname[6] = '\0'; + strncpy(musname, musnamearg, 6); + + while (*p) { + *p = tolower(*p); + ++p; + } + + P_PlayJingleMusic(player, musname, musflags, looping, jingletype); + return 0; +} + static int lib_pRestoreMusic(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD + //NOHUD + //INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); - P_RestoreMusic(player); + if (P_IsLocalPlayer(player)) + P_RestoreMusic(player); return 0; } @@ -788,6 +1104,7 @@ static int lib_pSpawnShieldOrb(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_SpawnShieldOrb(player); @@ -798,6 +1115,7 @@ static int lib_pSpawnGhostMobj(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); LUA_PushUserdata(L, P_SpawnGhostMobj(mobj), META_MOBJ); @@ -809,6 +1127,7 @@ static int lib_pGivePlayerRings(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); INT32 num_rings = (INT32)luaL_checkinteger(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_GivePlayerRings(player, num_rings); @@ -820,16 +1139,31 @@ static int lib_pGivePlayerLives(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); INT32 numlives = (INT32)luaL_checkinteger(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_GivePlayerLives(player, numlives); return 0; } +static int lib_pGiveCoopLives(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT32 numlives = (INT32)luaL_checkinteger(L, 2); + boolean sound = (boolean)lua_opttrueboolean(L, 3); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_GiveCoopLives(player, numlives, sound); + return 0; +} + static int lib_pResetScore(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_ResetScore(player); @@ -840,29 +1174,55 @@ static int lib_pDoJumpShield(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_DoJumpShield(player); return 0; } +static int lib_pDoBubbleBounce(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_DoBubbleBounce(player); + return 0; +} + static int lib_pBlackOw(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_BlackOw(player); return 0; } -static int lib_pElementalFireTrail(lua_State *L) +static int lib_pElementalFire(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean cropcircle = lua_optboolean(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_ElementalFire(player, cropcircle); + return 0; +} + +static int lib_pDoPlayerFinish(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); - P_ElementalFireTrail(player); + P_DoPlayerFinish(player); return 0; } @@ -870,6 +1230,7 @@ static int lib_pDoPlayerExit(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_DoPlayerExit(player); @@ -882,6 +1243,7 @@ static int lib_pInstaThrust(lua_State *L) angle_t angle = luaL_checkangle(L, 2); fixed_t move = luaL_checkfixed(L, 3); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); P_InstaThrust(mo, angle, move); @@ -917,10 +1279,13 @@ static int lib_pReturnThrustY(lua_State *L) static int lib_pLookForEnemies(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + boolean nonenemies = lua_opttrueboolean(L, 2); + boolean bullet = lua_optboolean(L, 3); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); - lua_pushboolean(L, P_LookForEnemies(player)); + LUA_PushUserdata(L, P_LookForEnemies(player, nonenemies, bullet), META_MOBJ); return 1; } @@ -930,6 +1295,7 @@ static int lib_pNukeEnemies(lua_State *L) mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); fixed_t radius = luaL_checkfixed(L, 3); NOHUD + INLEVEL if (!inflictor || !source) return LUA_ErrInvalid(L, "mobj_t"); P_NukeEnemies(inflictor, source, radius); @@ -941,16 +1307,18 @@ static int lib_pHomingAttack(lua_State *L) mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *enemy = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); NOHUD + INLEVEL if (!source || !enemy) return LUA_ErrInvalid(L, "mobj_t"); - P_HomingAttack(source, enemy); - return 0; + lua_pushboolean(L, P_HomingAttack(source, enemy)); + return 1; } static int lib_pSuperReady(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); lua_pushboolean(L, P_SuperReady(player)); @@ -962,6 +1330,7 @@ static int lib_pDoJump(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); boolean soundandstate = (boolean)lua_opttrueboolean(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_DoJump(player, soundandstate); @@ -972,6 +1341,7 @@ static int lib_pSpawnThokMobj(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_SpawnThokMobj(player); @@ -983,6 +1353,7 @@ static int lib_pSpawnSpinMobj(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); mobjtype_t type = luaL_checkinteger(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); if (type >= NUMMOBJTYPES) @@ -997,12 +1368,25 @@ static int lib_pTelekinesis(lua_State *L) fixed_t thrust = luaL_checkfixed(L, 2); fixed_t range = luaL_checkfixed(L, 3); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_Telekinesis(player, thrust, range); return 0; } +static int lib_pSwitchShield(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + UINT16 shield = luaL_checkinteger(L, 2); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_SwitchShield(player, shield); + return 0; +} + // P_MAP /////////// @@ -1013,6 +1397,7 @@ static int lib_pCheckPosition(lua_State *L) fixed_t x = luaL_checkfixed(L, 2); fixed_t y = luaL_checkfixed(L, 3); NOHUD + INLEVEL if (!thing) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_CheckPosition(thing, x, y)); @@ -1029,6 +1414,7 @@ static int lib_pTryMove(lua_State *L) fixed_t y = luaL_checkfixed(L, 3); boolean allowdropoff = lua_optboolean(L, 4); NOHUD + INLEVEL if (!thing) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_TryMove(thing, x, y, allowdropoff)); @@ -1043,6 +1429,7 @@ static int lib_pMove(lua_State *L) mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); fixed_t speed = luaL_checkfixed(L, 2); NOHUD + INLEVEL if (!actor) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_Move(actor, speed)); @@ -1059,6 +1446,7 @@ static int lib_pTeleportMove(lua_State *L) fixed_t y = luaL_checkfixed(L, 3); fixed_t z = luaL_checkfixed(L, 4); NOHUD + INLEVEL if (!thing) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_TeleportMove(thing, x, y, z)); @@ -1071,6 +1459,7 @@ static int lib_pSlideMove(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); P_SlideMove(mo); @@ -1081,6 +1470,7 @@ static int lib_pBounceMove(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); P_BounceMove(mo); @@ -1092,6 +1482,7 @@ static int lib_pCheckSight(lua_State *L) mobj_t *t1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *t2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); //HUDSAFE? + INLEVEL if (!t1 || !t2) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_CheckSight(t1, t2)); @@ -1106,6 +1497,7 @@ static int lib_pCheckHoopPosition(lua_State *L) fixed_t z = luaL_checkfixed(L, 4); fixed_t radius = luaL_checkfixed(L, 5); NOHUD + INLEVEL if (!hoopthing) return LUA_ErrInvalid(L, "mobj_t"); P_CheckHoopPosition(hoopthing, x, y, z, radius); @@ -1117,10 +1509,12 @@ static int lib_pRadiusAttack(lua_State *L) mobj_t *spot = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); fixed_t damagedist = luaL_checkfixed(L, 3); + UINT8 damagetype = luaL_optinteger(L, 4, 0); NOHUD + INLEVEL if (!spot || !source) return LUA_ErrInvalid(L, "mobj_t"); - P_RadiusAttack(spot, source, damagedist); + P_RadiusAttack(spot, source, damagedist, damagetype); return 0; } @@ -1131,6 +1525,7 @@ static int lib_pFloorzAtPos(lua_State *L) fixed_t z = luaL_checkfixed(L, 3); fixed_t height = luaL_checkfixed(L, 4); //HUDSAFE + INLEVEL lua_pushfixed(L, P_FloorzAtPos(x, y, z, height)); return 1; } @@ -1140,6 +1535,7 @@ static int lib_pDoSpring(lua_State *L) mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *object = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); NOHUD + INLEVEL if (!spring || !object) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, P_DoSpring(spring, object)); @@ -1153,6 +1549,7 @@ static int lib_pRemoveShield(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_RemoveShield(player); @@ -1163,7 +1560,9 @@ static int lib_pDamageMobj(lua_State *L) { mobj_t *target = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)), *inflictor = NULL, *source = NULL; INT32 damage; + UINT8 damagetype; NOHUD + INLEVEL if (!target) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) @@ -1171,21 +1570,25 @@ static int lib_pDamageMobj(lua_State *L) if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) source = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); damage = (INT32)luaL_optinteger(L, 4, 1); - lua_pushboolean(L, P_DamageMobj(target, inflictor, source, damage)); + damagetype = (UINT8)luaL_optinteger(L, 5, 0); + lua_pushboolean(L, P_DamageMobj(target, inflictor, source, damage, damagetype)); return 1; } static int lib_pKillMobj(lua_State *L) { mobj_t *target = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)), *inflictor = NULL, *source = NULL; + UINT8 damagetype; NOHUD + INLEVEL if (!target) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) inflictor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) source = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); - P_KillMobj(target, inflictor, source); + damagetype = (UINT8)luaL_optinteger(L, 4, 0); + P_KillMobj(target, inflictor, source, damagetype); return 0; } @@ -1194,10 +1597,11 @@ static int lib_pPlayerRingBurst(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); INT32 num_rings = (INT32)luaL_optinteger(L, 2, -1); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); if (num_rings == -1) - num_rings = player->health - 1; + num_rings = player->rings; P_PlayerRingBurst(player, num_rings); return 0; } @@ -1206,6 +1610,7 @@ static int lib_pPlayerWeaponPanelBurst(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_PlayerWeaponPanelBurst(player); @@ -1216,17 +1621,30 @@ static int lib_pPlayerWeaponAmmoBurst(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_PlayerWeaponAmmoBurst(player); return 0; } +static int lib_pPlayerWeaponPanelOrAmmoBurst(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_PlayerWeaponPanelOrAmmoBurst(player); + return 0; +} + static int lib_pPlayerEmeraldBurst(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); boolean toss = lua_optboolean(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_PlayerEmeraldBurst(player, toss); @@ -1238,6 +1656,7 @@ static int lib_pPlayerFlagBurst(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); boolean toss = lua_optboolean(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_PlayerFlagBurst(player, toss); @@ -1249,6 +1668,7 @@ static int lib_pPlayRinglossSound(lua_State *L) mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); player_t *player = NULL; NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) @@ -1267,6 +1687,7 @@ static int lib_pPlayDeathSound(lua_State *L) mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); player_t *player = NULL; NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) @@ -1285,6 +1706,7 @@ static int lib_pPlayVictorySound(lua_State *L) mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); player_t *player = NULL; NOHUD + INLEVEL if (!source) return LUA_ErrInvalid(L, "mobj_t"); if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) @@ -1300,10 +1722,15 @@ static int lib_pPlayVictorySound(lua_State *L) static int lib_pPlayLivesJingle(lua_State *L) { - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - if (!player) - return LUA_ErrInvalid(L, "player_t"); + player_t *player = NULL; + //NOHUD + //INLEVEL + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } P_PlayLivesJingle(player); return 0; } @@ -1313,6 +1740,7 @@ static int lib_pCanPickupItem(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); boolean weapon = lua_optboolean(L, 2); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); lua_pushboolean(L, P_CanPickupItem(player, weapon)); @@ -1323,12 +1751,24 @@ static int lib_pDoNightsScore(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_DoNightsScore(player); return 0; } +static int lib_pDoMatchSuper(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + NOHUD + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + P_DoMatchSuper(player); + return 0; +} + // P_SPEC //////////// @@ -1338,6 +1778,7 @@ static int lib_pThrust(lua_State *L) angle_t angle = luaL_checkangle(L, 2); fixed_t move = luaL_checkfixed(L, 3); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); P_Thrust(mo, angle, move); @@ -1349,6 +1790,7 @@ static int lib_pSetMobjStateNF(lua_State *L) mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); statenum_t state = luaL_checkinteger(L, 2); NOHUD + INLEVEL if (!mobj) return LUA_ErrInvalid(L, "mobj_t"); if (state >= NUMSTATES) @@ -1364,6 +1806,7 @@ static int lib_pDoSuperTransformation(lua_State *L) player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); boolean giverings = lua_optboolean(L, 2); NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); P_DoSuperTransformation(player, giverings); @@ -1374,6 +1817,7 @@ static int lib_pExplodeMissile(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); P_ExplodeMissile(mo); @@ -1386,18 +1830,92 @@ static int lib_pPlayerTouchingSectorSpecial(lua_State *L) INT32 section = (INT32)luaL_checkinteger(L, 2); INT32 number = (INT32)luaL_checkinteger(L, 3); //HUDSAFE + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); LUA_PushUserdata(L, P_PlayerTouchingSectorSpecial(player, section, number), META_SECTOR); return 1; } +static int lib_pFindLowestFloorSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindLowestFloorSurrounding(sector)); + return 1; +} + +static int lib_pFindHighestFloorSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindHighestFloorSurrounding(sector)); + return 1; +} + +static int lib_pFindNextHighestFloor(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + fixed_t currentheight; + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + // defaults to floorheight of sector arg + currentheight = (fixed_t)luaL_optinteger(L, 2, sector->floorheight); + lua_pushfixed(L, P_FindNextHighestFloor(sector, currentheight)); + return 1; +} + +static int lib_pFindNextLowestFloor(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + fixed_t currentheight; + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + // defaults to floorheight of sector arg + currentheight = (fixed_t)luaL_optinteger(L, 2, sector->floorheight); + lua_pushfixed(L, P_FindNextLowestFloor(sector, currentheight)); + return 1; +} + +static int lib_pFindLowestCeilingSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindLowestCeilingSurrounding(sector)); + return 1; +} + +static int lib_pFindHighestCeilingSurrounding(lua_State *L) +{ + sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + //HUDSAFE + INLEVEL + if (!sector) + return LUA_ErrInvalid(L, "sector_t"); + lua_pushfixed(L, P_FindHighestCeilingSurrounding(sector)); + return 1; +} + static int lib_pFindSpecialLineFromTag(lua_State *L) { INT16 special = (INT16)luaL_checkinteger(L, 1); INT16 line = (INT16)luaL_checkinteger(L, 2); INT32 start = (INT32)luaL_optinteger(L, 3, -1); NOHUD + INLEVEL lua_pushinteger(L, P_FindSpecialLineFromTag(special, line, start)); return 1; } @@ -1407,6 +1925,7 @@ static int lib_pSwitchWeather(lua_State *L) INT32 weathernum = (INT32)luaL_checkinteger(L, 1); player_t *user = NULL; NOHUD + INLEVEL if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) // if a player, setup weather for only the player, otherwise setup weather for all players user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); if (!user) // global @@ -1422,6 +1941,7 @@ static int lib_pLinedefExecute(lua_State *L) mobj_t *actor = NULL; sector_t *caller = NULL; NOHUD + INLEVEL if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) actor = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) @@ -1434,6 +1954,7 @@ static int lib_pSpawnLightningFlash(lua_State *L) { sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); NOHUD + INLEVEL if (!sector) return LUA_ErrInvalid(L, "sector_t"); P_SpawnLightningFlash(sector); @@ -1445,8 +1966,11 @@ static int lib_pFadeLight(lua_State *L) INT16 tag = (INT16)luaL_checkinteger(L, 1); INT32 destvalue = (INT32)luaL_checkinteger(L, 2); INT32 speed = (INT32)luaL_checkinteger(L, 3); + boolean ticbased = lua_optboolean(L, 4); + boolean force = lua_optboolean(L, 5); NOHUD - P_FadeLight(tag, destvalue, speed); + INLEVEL + P_FadeLight(tag, destvalue, speed, ticbased, force); return 0; } @@ -1454,6 +1978,7 @@ static int lib_pThingOnSpecial3DFloor(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); NOHUD + INLEVEL if (!mo) return LUA_ErrInvalid(L, "mobj_t"); LUA_PushUserdata(L, P_ThingOnSpecial3DFloor(mo), META_SECTOR); @@ -1464,6 +1989,7 @@ static int lib_pIsFlagAtBase(lua_State *L) { mobjtype_t flag = luaL_checkinteger(L, 1); NOHUD + INLEVEL if (flag >= NUMMOBJTYPES) return luaL_error(L, "mobj type %d out of range (0 - %d)", flag, NUMMOBJTYPES-1); lua_pushboolean(L, P_IsFlagAtBase(flag)); @@ -1475,6 +2001,7 @@ static int lib_pSetupLevelSky(lua_State *L) INT32 skynum = (INT32)luaL_checkinteger(L, 1); player_t *user = NULL; NOHUD + INLEVEL if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) // if a player, setup sky for only the player, otherwise setup sky for all players user = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); if (!user) // global @@ -1493,6 +2020,7 @@ static int lib_pSetSkyboxMobj(lua_State *L) int w = 0; NOHUD + INLEVEL if (!lua_isnil(L,1)) // nil leaves mo as NULL to remove the skybox rendering. { mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); // otherwise it is a skybox mobj. @@ -1539,6 +2067,7 @@ static int lib_pStartQuake(lua_State *L) static mappoint_t q_epicenter = {0,0,0}; NOHUD + INLEVEL // While technically we don't support epicenter and radius, // we get their values anyway if they exist. @@ -1596,15 +2125,53 @@ static int lib_pStartQuake(lua_State *L) } static int lib_evCrumbleChain(lua_State *L) +{ + sector_t *sec = NULL; + ffloor_t *rover = NULL; + NOHUD + INLEVEL + if (!lua_isnone(L, 2)) + { + if (!lua_isnil(L, 1)) + { + sec = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); + if (!sec) + return LUA_ErrInvalid(L, "sector_t"); + } + rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR)); + } + else + rover = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR)); + if (!rover) + return LUA_ErrInvalid(L, "ffloor_t"); + EV_CrumbleChain(sec, rover); + return 0; +} + +static int lib_evStartCrumble(lua_State *L) { sector_t *sec = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); ffloor_t *rover = *((ffloor_t **)luaL_checkudata(L, 2, META_FFLOOR)); + boolean floating = lua_optboolean(L, 3); + player_t *player = NULL; + fixed_t origalpha; + boolean crumblereturn = lua_optboolean(L, 6); NOHUD if (!sec) return LUA_ErrInvalid(L, "sector_t"); if (!rover) return LUA_ErrInvalid(L, "ffloor_t"); - EV_CrumbleChain(sec, rover); + if (!lua_isnone(L, 4) && lua_isuserdata(L, 4)) + { + player = *((player_t **)luaL_checkudata(L, 4, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!lua_isnone(L,5)) + origalpha = luaL_checkfixed(L, 5); + else + origalpha = rover->alpha; + lua_pushboolean(L, EV_StartCrumble(sec, rover, floating, player, origalpha, crumblereturn) != 0); return 0; } @@ -1674,10 +2241,25 @@ static int lib_rPointInSubsector(lua_State *L) fixed_t x = luaL_checkfixed(L, 1); fixed_t y = luaL_checkfixed(L, 2); //HUDSAFE + INLEVEL LUA_PushUserdata(L, R_PointInSubsector(x, y), META_SUBSECTOR); return 1; } +static int lib_rPointInSubsectorOrNil(lua_State *L) +{ + fixed_t x = luaL_checkfixed(L, 1); + fixed_t y = luaL_checkfixed(L, 2); + subsector_t *sub = R_PointInSubsectorOrNull(x, y); + //HUDSAFE + INLEVEL + if (sub) + LUA_PushUserdata(L, sub, META_SUBSECTOR); + else + lua_pushnil(L); + return 1; +} + // R_THINGS //////////// @@ -1707,26 +2289,64 @@ static int lib_rFrame2Char(lua_State *L) static int lib_rSetPlayerSkin(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT32 i = -1, j = -1; NOHUD + INLEVEL if (!player) return LUA_ErrInvalid(L, "player_t"); + + j = (player-players); + if (lua_isnoneornil(L, 2)) return luaL_error(L, "argument #2 not given (expected number or string)"); else if (lua_type(L, 2) == LUA_TNUMBER) // skin number { - INT32 i = luaL_checkinteger(L, 2); - if (i < 0 || i >= MAXSKINS) - return luaL_error(L, "skin number (argument #2) %d out of range (0 - %d)", i, MAXSKINS-1); - SetPlayerSkinByNum(player-players, i); + i = luaL_checkinteger(L, 2); + if (i < 0 || i >= numskins) + return luaL_error(L, "skin %d (argument #2) out of range (0 - %d)", i, numskins-1); } else // skin name { const char *skinname = luaL_checkstring(L, 2); - SetPlayerSkin(player-players, skinname); + i = R_SkinAvailable(skinname); + if (i == -1) + return luaL_error(L, "skin %s (argument 2) is not loaded", skinname); } + + if (!R_SkinUsable(j, i)) + return luaL_error(L, "skin %d (argument 2) not usable - check with R_SkinUsable(player_t, skin) first.", i); + SetPlayerSkinByNum(j, i); return 0; } +static int lib_rSkinUsable(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INT32 i = -1, j = -1; + if (player) + j = (player-players); + else if (netgame || multiplayer) + return luaL_error(L, "player_t (argument #1) must be provided in multiplayer games"); + if (lua_isnoneornil(L, 2)) + return luaL_error(L, "argument #2 not given (expected number or string)"); + else if (lua_type(L, 2) == LUA_TNUMBER) // skin number + { + i = luaL_checkinteger(L, 2); + if (i < 0 || i >= numskins) + return luaL_error(L, "skin %d (argument #2) out of range (0 - %d)", i, numskins-1); + } + else // skin name + { + const char *skinname = luaL_checkstring(L, 2); + i = R_SkinAvailable(skinname); + if (i == -1) + return luaL_error(L, "skin %s (argument 2) is not loaded", skinname); + } + + lua_pushboolean(L, R_SkinUsable(j, i)); + return 1; +} + // R_DATA //////////// @@ -1746,15 +2366,35 @@ static int lib_rTextureNumForName(lua_State *L) return 1; } +// R_DRAW +//////////// +static int lib_rGetColorByName(lua_State *L) +{ + const char* colorname = luaL_checkstring(L, 1); + //HUDSAFE + lua_pushinteger(L, R_GetColorByName(colorname)); + return 1; +} + +// Lua exclusive function, returns the name of a color from the SKINCOLOR_ constant. +// SKINCOLOR_GREEN > "Green" for example +static int lib_rGetNameByColor(lua_State *L) +{ + UINT8 colornum = (UINT8)luaL_checkinteger(L, 1); + if (!colornum || colornum >= MAXSKINCOLORS) + return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, MAXSKINCOLORS-1); + lua_pushstring(L, Color_Names[colornum]); + return 1; +} + // S_SOUND //////////// - static int lib_sStartSound(lua_State *L) { const void *origin = NULL; sfxenum_t sound_id = luaL_checkinteger(L, 2); player_t *player = NULL; - //NOHUD // kys @whoever did this. + //NOHUD if (sound_id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", sound_id, NUMSFX-1); if (!lua_isnil(L, 1)) @@ -1785,7 +2425,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) sfxenum_t sound_id = luaL_checkinteger(L, 2); INT32 volume = (INT32)luaL_checkinteger(L, 3); player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnil(L, 1)) { @@ -1809,7 +2449,7 @@ static int lib_sStartSoundAtVolume(lua_State *L) static int lib_sStopSound(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - NOHUD + //NOHUD if (!origin) return LUA_ErrInvalid(L, "mobj_t"); S_StopSound(origin); @@ -1820,13 +2460,13 @@ static int lib_sChangeMusic(lua_State *L) { #ifdef MUSICSLOT_COMPATIBILITY const char *music_name; - UINT32 music_num; + UINT32 music_num, position, prefadems, fadeinms; char music_compat_name[7]; boolean looping; player_t *player = NULL; UINT16 music_flags = 0; - NOHUD + //NOHUD if (lua_isnumber(L, 1)) { @@ -1848,7 +2488,6 @@ static int lib_sChangeMusic(lua_State *L) music_name = luaL_checkstring(L, 1); } - looping = (boolean)lua_opttrueboolean(L, 2); #else @@ -1856,7 +2495,7 @@ static int lib_sChangeMusic(lua_State *L) boolean looping = (boolean)lua_opttrueboolean(L, 2); player_t *player = NULL; UINT16 music_flags = 0; - NOHUD + //NOHUD #endif if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) @@ -1873,8 +2512,12 @@ static int lib_sChangeMusic(lua_State *L) #endif music_flags = (UINT16)luaL_optinteger(L, 4, 0); + position = (UINT32)luaL_optinteger(L, 5, 0); + prefadems = (UINT32)luaL_optinteger(L, 6, 0); + fadeinms = (UINT32)luaL_optinteger(L, 7, 0); + if (!player || P_IsLocalPlayer(player)) - S_ChangeMusic(music_name, music_flags, looping); + S_ChangeMusicEx(music_name, music_flags, looping, position, prefadems, fadeinms); return 0; } @@ -1883,7 +2526,7 @@ static int lib_sSpeedMusic(lua_State *L) fixed_t fixedspeed = luaL_checkfixed(L, 1); float speed = FIXED_TO_FLOAT(fixedspeed); player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) { player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); @@ -1891,16 +2534,14 @@ static int lib_sSpeedMusic(lua_State *L) return LUA_ErrInvalid(L, "player_t"); } if (!player || P_IsLocalPlayer(player)) - lua_pushboolean(L, S_SpeedMusic(speed)); - else - lua_pushboolean(L, false); - return 1; + S_SpeedMusic(speed); + return 0; } static int lib_sStopMusic(lua_State *L) { player_t *player = NULL; - NOHUD + //NOHUD if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) { player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -1912,10 +2553,132 @@ static int lib_sStopMusic(lua_State *L) return 0; } +static int lib_sSetInternalMusicVolume(lua_State *L) +{ + UINT32 volume = (UINT32)luaL_checkinteger(L, 1); + player_t *player = NULL; + //NOHUD + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + { + player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + S_SetInternalMusicVolume(volume); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; +} + +static int lib_sStopFadingMusic(lua_State *L) +{ + player_t *player = NULL; + //NOHUD + if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) + { + player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + S_StopFadingMusic(); + lua_pushboolean(L, true); + } + else + lua_pushnil(L); + return 1; +} + +static int lib_sFadeMusic(lua_State *L) +{ + UINT32 target_volume = (UINT32)luaL_checkinteger(L, 1); + UINT32 ms; + INT32 source_volume; + player_t *player = NULL; + //NOHUD + if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) + { + player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + ms = (UINT32)luaL_checkinteger(L, 2); + source_volume = -1; + } + else if (!lua_isnone(L, 4) && lua_isuserdata(L, 4)) + { + player = *((player_t **)luaL_checkudata(L, 4, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + source_volume = (INT32)luaL_checkinteger(L, 2); + ms = (UINT32)luaL_checkinteger(L, 3); + } + else if (luaL_optinteger(L, 3, INT32_MAX) == INT32_MAX) + { + ms = (UINT32)luaL_checkinteger(L, 2); + source_volume = -1; + } + else + { + source_volume = (INT32)luaL_checkinteger(L, 2); + ms = (UINT32)luaL_checkinteger(L, 3); + } + + if (!player || P_IsLocalPlayer(player)) + lua_pushboolean(L, S_FadeMusicFromVolume(target_volume, source_volume, ms)); + else + lua_pushnil(L); + return 1; +} + +static int lib_sFadeOutStopMusic(lua_State *L) +{ + UINT32 ms = (UINT32)luaL_checkinteger(L, 1); + player_t *player = NULL; + //NOHUD + if (!lua_isnone(L, 2) && lua_isuserdata(L, 2)) + { + player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + if (!player || P_IsLocalPlayer(player)) + { + lua_pushboolean(L, S_FadeOutStopMusic(ms)); + } + else + lua_pushnil(L); + return 1; +} + +static int lib_sGetMusicLength(lua_State *L) +{ + lua_pushinteger(L, S_GetMusicLength()); + return 1; +} + +static int lib_sGetMusicPosition(lua_State *L) +{ + lua_pushinteger(L, S_GetMusicPosition()); + return 1; +} + +static int lib_sSetMusicPosition(lua_State *L) +{ + UINT32 pos = (UINT32)luaL_checkinteger(L, 1); + lua_pushboolean(L, S_SetMusicPosition(pos)); + return 1; +} + static int lib_sOriginPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - NOHUD + //NOHUD + INLEVEL if (!origin) return LUA_ErrInvalid(L, "mobj_t"); lua_pushboolean(L, S_OriginPlaying(origin)); @@ -1925,7 +2688,7 @@ static int lib_sOriginPlaying(lua_State *L) static int lib_sIdPlaying(lua_State *L) { sfxenum_t id = luaL_checkinteger(L, 1); - NOHUD + //NOHUD if (id >= NUMSFX) return luaL_error(L, "sfx %d out of range (0 - %d)", id, NUMSFX-1); lua_pushboolean(L, S_IdPlaying(id)); @@ -1936,7 +2699,8 @@ static int lib_sSoundPlaying(lua_State *L) { void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); sfxenum_t id = luaL_checkinteger(L, 2); - NOHUD + //NOHUD + INLEVEL if (!origin) return LUA_ErrInvalid(L, "mobj_t"); if (id >= NUMSFX) @@ -1945,13 +2709,178 @@ static int lib_sSoundPlaying(lua_State *L) return 1; } +// This doesn't really exist, but we're providing it as a handy netgame-safe wrapper for stuff that should be locally handled. + +static int lib_sStartMusicCaption(lua_State *L) +{ + player_t *player = NULL; + const char *caption = luaL_checkstring(L, 1); + UINT16 lifespan = (UINT16)luaL_checkinteger(L, 2); + //HUDSAFE + //INLEVEL + + if (!lua_isnone(L, 3) && lua_isuserdata(L, 3)) + { + player = *((player_t **)luaL_checkudata(L, 3, META_PLAYER)); + if (!player) + return LUA_ErrInvalid(L, "player_t"); + } + + if (lifespan && (!player || P_IsLocalPlayer(player))) + { + strlcpy(S_sfx[sfx_None].caption, caption, sizeof(S_sfx[sfx_None].caption)); + S_StartCaption(sfx_None, -1, lifespan); + } + return 0; +} + // G_GAME //////////// +// Copypasted from lib_cvRegisterVar :] +static int lib_gAddGametype(lua_State *L) +{ + const char *k; + lua_Integer i; + + const char *gtname = NULL; + const char *gtconst = NULL; + const char *gtdescription = NULL; + INT16 newgtidx = 0; + UINT32 newgtrules = 0; + UINT32 newgttol = 0; + INT32 newgtpointlimit = 0; + INT32 newgttimelimit = 0; + UINT8 newgtleftcolor = 0; + UINT8 newgtrightcolor = 0; + INT16 newgtrankingstype = -1; + int newgtinttype = 0; + + luaL_checktype(L, 1, LUA_TTABLE); + lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one. + + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); + + // Ran out of gametype slots + if (gametypecount == NUMGAMETYPEFREESLOTS) + return luaL_error(L, "Ran out of free gametype slots!"); + +#define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to " LUA_QL("G_AddGametype") " (%s)", e); +#define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1))) + + lua_pushnil(L); + while (lua_next(L, 1)) { + // stack: gametype table, key/index, value + // 1 2 3 + i = 0; + k = NULL; + if (lua_isnumber(L, 2)) + i = lua_tointeger(L, 2); + else if (lua_isstring(L, 2)) + k = lua_tostring(L, 2); + + // Sorry, no gametype rules as key names. + if (i == 1 || (k && fasticmp(k, "name"))) { + if (!lua_isstring(L, 3)) + TYPEERROR("name", LUA_TSTRING) + gtname = Z_StrDup(lua_tostring(L, 3)); + } else if (i == 2 || (k && fasticmp(k, "identifier"))) { + if (!lua_isstring(L, 3)) + TYPEERROR("identifier", LUA_TSTRING) + gtconst = Z_StrDup(lua_tostring(L, 3)); + } else if (i == 3 || (k && fasticmp(k, "rules"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("rules", LUA_TNUMBER) + newgtrules = (UINT32)lua_tointeger(L, 3); + } else if (i == 4 || (k && fasticmp(k, "typeoflevel"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("typeoflevel", LUA_TNUMBER) + newgttol = (UINT32)lua_tointeger(L, 3); + } else if (i == 5 || (k && fasticmp(k, "rankingtype"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("rankingtype", LUA_TNUMBER) + newgtrankingstype = (INT16)lua_tointeger(L, 3); + } else if (i == 6 || (k && fasticmp(k, "intermissiontype"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("intermissiontype", LUA_TNUMBER) + newgtinttype = (int)lua_tointeger(L, 3); + } else if (i == 7 || (k && fasticmp(k, "defaultpointlimit"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("defaultpointlimit", LUA_TNUMBER) + newgtpointlimit = (INT32)lua_tointeger(L, 3); + } else if (i == 8 || (k && fasticmp(k, "defaulttimelimit"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("defaulttimelimit", LUA_TNUMBER) + newgttimelimit = (INT32)lua_tointeger(L, 3); + } else if (i == 9 || (k && fasticmp(k, "description"))) { + if (!lua_isstring(L, 3)) + TYPEERROR("description", LUA_TSTRING) + gtdescription = Z_StrDup(lua_tostring(L, 3)); + } else if (i == 10 || (k && fasticmp(k, "headerleftcolor"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("headerleftcolor", LUA_TNUMBER) + newgtleftcolor = (UINT8)lua_tointeger(L, 3); + } else if (i == 11 || (k && fasticmp(k, "headerrightcolor"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("headerrightcolor", LUA_TNUMBER) + newgtrightcolor = (UINT8)lua_tointeger(L, 3); + // Key name specified + } else if ((!i) && (k && fasticmp(k, "headercolor"))) { + if (!lua_isnumber(L, 3)) + TYPEERROR("headercolor", LUA_TNUMBER) + newgtleftcolor = newgtrightcolor = (UINT8)lua_tointeger(L, 3); + } + lua_pop(L, 1); + } + +#undef FIELDERROR +#undef TYPEERROR + + // pop gametype table + lua_pop(L, 1); + + // Set defaults + if (gtname == NULL) + gtname = Z_StrDup("Unnamed gametype"); + if (gtdescription == NULL) + gtdescription = Z_StrDup("???"); + + // Add the new gametype + newgtidx = G_AddGametype(newgtrules); + G_AddGametypeTOL(newgtidx, newgttol); + G_SetGametypeDescription(newgtidx, NULL, newgtleftcolor, newgtrightcolor); + strncpy(gametypedesc[newgtidx].notes, gtdescription, 441); + + // Not covered by G_AddGametype alone. + if (newgtrankingstype == -1) + newgtrankingstype = newgtidx; + gametyperankings[newgtidx] = newgtrankingstype; + intermissiontypes[newgtidx] = newgtinttype; + pointlimits[newgtidx] = newgtpointlimit; + timelimits[newgtidx] = newgttimelimit; + + // Write the new gametype name. + Gametype_Names[newgtidx] = gtname; + + // Write the constant name. + if (gtconst == NULL) + gtconst = gtname; + G_AddGametypeConstant(newgtidx, gtconst); + + // Update gametype_cons_t accordingly. + G_UpdateGametypeSelections(); + + // done + CONS_Printf("Added gametype %s\n", Gametype_Names[newgtidx]); + return 0; +} + static int lib_gBuildMapName(lua_State *L) { INT32 map = luaL_optinteger(L, 1, gamemap); //HUDSAFE + INLEVEL lua_pushstring(L, G_BuildMapName(map)); return 1; } @@ -1960,6 +2889,7 @@ static int lib_gDoReborn(lua_State *L) { INT32 playernum = luaL_checkinteger(L, 1); NOHUD + INLEVEL if (playernum >= MAXPLAYERS) return luaL_error(L, "playernum %d out of range (0 - %d)", playernum, MAXPLAYERS-1); G_DoReborn(playernum); @@ -1972,32 +2902,34 @@ static int lib_gSetCustomExitVars(lua_State *L) { int n = lua_gettop(L); // Num arguments NOHUD + INLEVEL // LUA EXTENSION: Custom exit like support // Supported: // G_SetCustomExitVars(); [reset to defaults] // G_SetCustomExitVars(int) [nextmap override only] - // G_SetCustomExitVars(bool) [skipstats only] - // G_SetCustomExitVars(int, bool) [both of the above] + // G_SetCustomExitVars(nil, int) [skipstats only] + // G_SetCustomExitVars(int, int) [both of the above] + + nextmapoverride = 0; + skipstats = 0; + if (n >= 1) { - if (lua_isnumber(L, 1) || n >= 2) - { - nextmapoverride = (INT16)luaL_checknumber(L, 1); - lua_remove(L, 1); // remove nextmapoverride; skipstats now 1 if available - } - skipstats = lua_optboolean(L, 1); + nextmapoverride = (INT16)luaL_optinteger(L, 1, 0); + skipstats = (INT16)luaL_optinteger(L, 2, 0); } - else - { - nextmapoverride = 0; - skipstats = false; - } - // --- return 0; } +static int lib_gEnoughPlayersFinished(lua_State *L) +{ + INLEVEL + lua_pushboolean(L, G_EnoughPlayersFinished()); + return 1; +} + static int lib_gExitLevel(lua_State *L) { int n = lua_gettop(L); // Num arguments @@ -2013,6 +2945,7 @@ static int lib_gIsSpecialStage(lua_State *L) { INT32 mapnum = luaL_optinteger(L, 1, gamemap); //HUDSAFE + INLEVEL lua_pushboolean(L, G_IsSpecialStage(mapnum)); return 1; } @@ -2020,13 +2953,31 @@ static int lib_gIsSpecialStage(lua_State *L) static int lib_gGametypeUsesLives(lua_State *L) { //HUDSAFE + INLEVEL lua_pushboolean(L, G_GametypeUsesLives()); return 1; } +static int lib_gGametypeUsesCoopLives(lua_State *L) +{ + //HUDSAFE + INLEVEL + lua_pushboolean(L, G_GametypeUsesCoopLives()); + return 1; +} + +static int lib_gGametypeUsesCoopStarposts(lua_State *L) +{ + //HUDSAFE + INLEVEL + lua_pushboolean(L, G_GametypeUsesCoopStarposts()); + return 1; +} + static int lib_gGametypeHasTeams(lua_State *L) { //HUDSAFE + INLEVEL lua_pushboolean(L, G_GametypeHasTeams()); return 1; } @@ -2034,6 +2985,7 @@ static int lib_gGametypeHasTeams(lua_State *L) static int lib_gGametypeHasSpectators(lua_State *L) { //HUDSAFE + INLEVEL lua_pushboolean(L, G_GametypeHasSpectators()); return 1; } @@ -2041,6 +2993,7 @@ static int lib_gGametypeHasSpectators(lua_State *L) static int lib_gRingSlingerGametype(lua_State *L) { //HUDSAFE + INLEVEL lua_pushboolean(L, G_RingSlingerGametype()); return 1; } @@ -2048,6 +3001,7 @@ static int lib_gRingSlingerGametype(lua_State *L) static int lib_gPlatformGametype(lua_State *L) { //HUDSAFE + INLEVEL lua_pushboolean(L, G_PlatformGametype()); return 1; } @@ -2055,10 +3009,19 @@ static int lib_gPlatformGametype(lua_State *L) static int lib_gTagGametype(lua_State *L) { //HUDSAFE + INLEVEL lua_pushboolean(L, G_TagGametype()); return 1; } +static int lib_gCompetitionGametype(lua_State *L) +{ + //HUDSAFE + INLEVEL + lua_pushboolean(L, G_CompetitionGametype()); + return 1; +} + static int lib_gTicsToHours(lua_State *L) { tic_t rtic = luaL_checkinteger(L, 1); @@ -2104,21 +3067,22 @@ static luaL_Reg lib[] = { {"print", lib_print}, {"chatprint", lib_chatprint}, {"chatprintf", lib_chatprintf}, - {"EvalMath", lib_evalMath}, + {"userdataType", lib_userdataType}, {"IsPlayerAdmin", lib_isPlayerAdmin}, + {"reserveLuabanks", lib_reserveLuabanks}, // m_random {"P_RandomFixed",lib_pRandomFixed}, {"P_RandomByte",lib_pRandomByte}, {"P_RandomKey",lib_pRandomKey}, {"P_RandomRange",lib_pRandomRange}, - {"P_Random",lib_pRandom}, // DEPRECATED {"P_SignedRandom",lib_pSignedRandom}, // MACRO {"P_RandomChance",lib_pRandomChance}, // MACRO // p_maputil {"P_AproxDistance",lib_pAproxDistance}, {"P_ClosestPointOnLine",lib_pClosestPointOnLine}, + {"P_PointOnLineSide",lib_pPointOnLineSide}, // p_enemy {"P_CheckMeleeRange", lib_pCheckMeleeRange}, @@ -2132,7 +3096,10 @@ static luaL_Reg lib[] = { // p_mobj // don't add P_SetMobjState or P_SetPlayerMobjState, use "mobj.state = S_NEWSTATE" instead. {"P_SpawnMobj",lib_pSpawnMobj}, + {"P_SpawnMobjFromMobj",lib_pSpawnMobjFromMobj}, {"P_RemoveMobj",lib_pRemoveMobj}, + {"P_IsValidSprite2", lib_pIsValidSprite2}, + {"P_SpawnLockOn", lib_pSpawnLockOn}, {"P_SpawnMissile",lib_pSpawnMissile}, {"P_SpawnXYZMissile",lib_pSpawnXYZMissile}, {"P_SpawnPointMissile",lib_pSpawnPointMissile}, @@ -2153,29 +3120,38 @@ static luaL_Reg lib[] = { {"P_CheckDeathPitCollide",lib_pCheckDeathPitCollide}, {"P_CheckSolidLava",lib_pCheckSolidLava}, {"P_CanRunOnWater",lib_pCanRunOnWater}, + {"P_MaceRotate",lib_pMaceRotate}, // p_user {"P_GetPlayerHeight",lib_pGetPlayerHeight}, {"P_GetPlayerSpinHeight",lib_pGetPlayerSpinHeight}, {"P_GetPlayerControlDirection",lib_pGetPlayerControlDirection}, {"P_AddPlayerScore",lib_pAddPlayerScore}, + {"P_StealPlayerScore",lib_pStealPlayerScore}, + {"P_GetJumpFlags",lib_pGetJumpFlags}, {"P_PlayerInPain",lib_pPlayerInPain}, {"P_DoPlayerPain",lib_pDoPlayerPain}, {"P_ResetPlayer",lib_pResetPlayer}, + {"P_PlayerCanDamage",lib_pPlayerCanDamage}, {"P_IsObjectInGoop",lib_pIsObjectInGoop}, {"P_IsObjectOnGround",lib_pIsObjectOnGround}, {"P_InSpaceSector",lib_pInSpaceSector}, {"P_InQuicksand",lib_pInQuicksand}, {"P_SetObjectMomZ",lib_pSetObjectMomZ}, + {"P_PlayJingle",lib_pPlayJingle}, + {"P_PlayJingleMusic",lib_pPlayJingleMusic}, {"P_RestoreMusic",lib_pRestoreMusic}, {"P_SpawnShieldOrb",lib_pSpawnShieldOrb}, {"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_GivePlayerRings",lib_pGivePlayerRings}, {"P_GivePlayerLives",lib_pGivePlayerLives}, + {"P_GiveCoopLives",lib_pGiveCoopLives}, {"P_ResetScore",lib_pResetScore}, {"P_DoJumpShield",lib_pDoJumpShield}, + {"P_DoBubbleBounce",lib_pDoBubbleBounce}, {"P_BlackOw",lib_pBlackOw}, - {"P_ElementalFireTrail",lib_pElementalFireTrail}, + {"P_ElementalFire",lib_pElementalFire}, + {"P_DoPlayerFinish",lib_pDoPlayerFinish}, {"P_DoPlayerExit",lib_pDoPlayerExit}, {"P_InstaThrust",lib_pInstaThrust}, {"P_ReturnThrustX",lib_pReturnThrustX}, @@ -2188,6 +3164,7 @@ static luaL_Reg lib[] = { {"P_SpawnThokMobj",lib_pSpawnThokMobj}, {"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_Telekinesis",lib_pTelekinesis}, + {"P_SwitchShield",lib_pSwitchShield}, // p_map {"P_CheckPosition",lib_pCheckPosition}, @@ -2209,6 +3186,7 @@ static luaL_Reg lib[] = { {"P_PlayerRingBurst",lib_pPlayerRingBurst}, {"P_PlayerWeaponPanelBurst",lib_pPlayerWeaponPanelBurst}, {"P_PlayerWeaponAmmoBurst",lib_pPlayerWeaponAmmoBurst}, + {"P_PlayerWeaponPanelOrAmmoBurst", lib_pPlayerWeaponPanelOrAmmoBurst}, {"P_PlayerEmeraldBurst",lib_pPlayerEmeraldBurst}, {"P_PlayerFlagBurst",lib_pPlayerFlagBurst}, {"P_PlayRinglossSound",lib_pPlayRinglossSound}, @@ -2217,6 +3195,7 @@ static luaL_Reg lib[] = { {"P_PlayLivesJingle",lib_pPlayLivesJingle}, {"P_CanPickupItem",lib_pCanPickupItem}, {"P_DoNightsScore",lib_pDoNightsScore}, + {"P_DoMatchSuper",lib_pDoMatchSuper}, // p_spec {"P_Thrust",lib_pThrust}, @@ -2224,6 +3203,12 @@ static luaL_Reg lib[] = { {"P_DoSuperTransformation",lib_pDoSuperTransformation}, {"P_ExplodeMissile",lib_pExplodeMissile}, {"P_PlayerTouchingSectorSpecial",lib_pPlayerTouchingSectorSpecial}, + {"P_FindLowestFloorSurrounding",lib_pFindLowestFloorSurrounding}, + {"P_FindHighestFloorSurrounding",lib_pFindHighestFloorSurrounding}, + {"P_FindNextHighestFloor",lib_pFindNextHighestFloor}, + {"P_FindNextLowestFloor",lib_pFindNextLowestFloor}, + {"P_FindLowestCeilingSurrounding",lib_pFindLowestCeilingSurrounding}, + {"P_FindHighestCeilingSurrounding",lib_pFindHighestCeilingSurrounding}, {"P_FindSpecialLineFromTag",lib_pFindSpecialLineFromTag}, {"P_SwitchWeather",lib_pSwitchWeather}, {"P_LinedefExecute",lib_pLinedefExecute}, @@ -2235,6 +3220,7 @@ static luaL_Reg lib[] = { {"P_SetSkyboxMobj",lib_pSetSkyboxMobj}, {"P_StartQuake",lib_pStartQuake}, {"EV_CrumbleChain",lib_evCrumbleChain}, + {"EV_StartCrumble",lib_evStartCrumble}, #ifdef ESLOPE // p_slopes @@ -2247,16 +3233,22 @@ static luaL_Reg lib[] = { {"R_PointToDist",lib_rPointToDist}, {"R_PointToDist2",lib_rPointToDist2}, {"R_PointInSubsector",lib_rPointInSubsector}, + {"R_PointInSubsectorOrNil",lib_rPointInSubsectorOrNil}, // r_things (sprite) {"R_Char2Frame",lib_rChar2Frame}, {"R_Frame2Char",lib_rFrame2Char}, {"R_SetPlayerSkin",lib_rSetPlayerSkin}, + {"R_SkinUsable",lib_rSkinUsable}, // r_data {"R_CheckTextureNumForName",lib_rCheckTextureNumForName}, {"R_TextureNumForName",lib_rTextureNumForName}, + // r_draw + {"R_GetColorByName", lib_rGetColorByName}, + {"R_GetNameByColor", lib_rGetNameByColor}, + // s_sound {"S_StartSound",lib_sStartSound}, {"S_StartSoundAtVolume",lib_sStartSoundAtVolume}, @@ -2264,22 +3256,35 @@ static luaL_Reg lib[] = { {"S_ChangeMusic",lib_sChangeMusic}, {"S_SpeedMusic",lib_sSpeedMusic}, {"S_StopMusic",lib_sStopMusic}, + {"S_SetInternalMusicVolume", lib_sSetInternalMusicVolume}, + {"S_StopFadingMusic",lib_sStopFadingMusic}, + {"S_FadeMusic",lib_sFadeMusic}, + {"S_FadeOutStopMusic",lib_sFadeOutStopMusic}, + {"S_GetMusicLength",lib_sGetMusicLength}, + {"S_GetMusicPosition",lib_sGetMusicPosition}, + {"S_SetMusicPosition",lib_sSetMusicPosition}, {"S_OriginPlaying",lib_sOriginPlaying}, {"S_IdPlaying",lib_sIdPlaying}, {"S_SoundPlaying",lib_sSoundPlaying}, + {"S_StartMusicCaption", lib_sStartMusicCaption}, // g_game + {"G_AddGametype", lib_gAddGametype}, {"G_BuildMapName",lib_gBuildMapName}, {"G_DoReborn",lib_gDoReborn}, {"G_SetCustomExitVars",lib_gSetCustomExitVars}, + {"G_EnoughPlayersFinished",lib_gEnoughPlayersFinished}, {"G_ExitLevel",lib_gExitLevel}, {"G_IsSpecialStage",lib_gIsSpecialStage}, {"G_GametypeUsesLives",lib_gGametypeUsesLives}, + {"G_GametypeUsesCoopLives",lib_gGametypeUsesCoopLives}, + {"G_GametypeUsesCoopStarposts",lib_gGametypeUsesCoopStarposts}, {"G_GametypeHasTeams",lib_gGametypeHasTeams}, {"G_GametypeHasSpectators",lib_gGametypeHasSpectators}, {"G_RingSlingerGametype",lib_gRingSlingerGametype}, {"G_PlatformGametype",lib_gPlatformGametype}, {"G_TagGametype",lib_gTagGametype}, + {"G_CompetitionGametype",lib_gCompetitionGametype}, {"G_TicsToHours",lib_gTicsToHours}, {"G_TicsToMinutes",lib_gTicsToMinutes}, {"G_TicsToSeconds",lib_gTicsToSeconds}, @@ -2306,5 +3311,3 @@ int LUA_BaseLib(lua_State *L) luaL_register(L, NULL, lib); return 0; } - -#endif diff --git a/src/lua_blockmaplib.c b/src/lua_blockmaplib.c index dabbdd9f6..bc8d20e8e 100644 --- a/src/lua_blockmaplib.c +++ b/src/lua_blockmaplib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2016 by Iestyn "Monster Iestyn" Jealous. -// Copyright (C) 2016 by Sonic Team Junior. +// Copyright (C) 2016-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,7 +11,6 @@ /// \brief blockmap library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "r_main.h" // validcount #include "lua_script.h" @@ -54,10 +53,12 @@ static UINT8 lib_searchBlockmap_Objects(lua_State *L, INT32 x, INT32 y, mobj_t * CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); blockfuncerror = true; + P_SetTarget(&bnext, NULL); return 0; // *shrugs* } if (!lua_isnil(gL, -1)) { // if nil, continue + P_SetTarget(&bnext, NULL); if (lua_toboolean(gL, -1)) return 2; // stop whole search else @@ -262,5 +263,3 @@ int LUA_BlockmapLib(lua_State *L) lua_register(L, "searchBlockmap", lib_searchBlockmap); return 0; } - -#endif diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index dced4e43c..a9fbad65f 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,7 +11,6 @@ /// \brief console modifying/etc library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "p_local.h" #include "g_game.h" @@ -22,7 +21,12 @@ #include "lua_libs.h" #include "lua_hud.h" // hud_running errors -#define NOHUD if (hud_running) return luaL_error(L, "HUD rendering code should not call this function!"); +// for functions not allowed in hud.add hooks +#define NOHUD if (hud_running)\ +return luaL_error(L, "HUD rendering code should not call this function!"); +// for functions not allowed in hooks or coroutines (supercedes above) +#define NOHOOK if (!lua_lumploading)\ + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); static const char *cvname = NULL; @@ -82,13 +86,7 @@ deny: CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]); if (server) - { - XBOXSTATIC UINT8 bufn[2]; - - bufn[0] = (UINT8)playernum; - bufn[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &bufn, 2); - } + SendKick(playernum, KICK_MSG_CON_FAIL | KICK_MSG_KEEP_BODY); } // Wrapper for COM_AddCommand commands @@ -113,12 +111,12 @@ void COM_Lua_f(void) lua_rawgeti(gL, -1, 2); // push flags from command info table if (lua_isboolean(gL, -1)) - flags = (lua_toboolean(gL, -1) ? 1 : 0); + flags = (lua_toboolean(gL, -1) ? COM_ADMIN : 0); else flags = (UINT8)lua_tointeger(gL, -1); lua_pop(gL, 1); // pop flags - if (flags & 2) // flag 2: splitscreen player command. + if (flags & COM_SPLITSCREEN) // flag 2: splitscreen player command. { if (!splitscreen) { @@ -128,12 +126,12 @@ void COM_Lua_f(void) playernum = secondarydisplayplayer; } - if (netgame) + if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */ { // Send the command through the network UINT8 argc; lua_pop(gL, 1); // pop command info table - if (flags & 1 && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command. + if (flags & COM_ADMIN && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command. { CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); return; @@ -153,7 +151,7 @@ void COM_Lua_f(void) WRITEUINT8(p, argc); for (i = 0; i < argc; i++) WRITESTRINGN(p, COM_Argv(i), 255); - if (flags & 2) + if (flags & COM_SPLITSCREEN) SendNetXCmd2(XD_LUACMD, buf, p-buf); else SendNetXCmd(XD_LUACMD, buf, p-buf); @@ -183,11 +181,19 @@ static int lib_comAddCommand(lua_State *L) strlwr(name); luaL_checktype(L, 2, LUA_TFUNCTION); - NOHUD + NOHOOK if (lua_gettop(L) >= 3) { // For the third argument, only take a boolean or a number. lua_settop(L, 3); - if (lua_type(L, 3) != LUA_TBOOLEAN) + if (lua_type(L, 3) == LUA_TBOOLEAN) + { + CONS_Alert(CONS_WARNING, + "Using a boolean for admin commands is " + "deprecated and will be removed.\n" + "Use \"COM_ADMIN\" instead.\n" + ); + } + else luaL_checktype(L, 3, LUA_TNUMBER); } else @@ -240,7 +246,7 @@ static int lib_comBufAddText(lua_State *L) return LUA_ErrInvalid(L, "player_t"); if (plr != &players[consoleplayer]) return 0; - COM_BufAddText(va("%s\n", luaL_checkstring(L, 2))); + COM_BufAddTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE); return 0; } @@ -257,7 +263,7 @@ static int lib_comBufInsertText(lua_State *L) return LUA_ErrInvalid(L, "player_t"); if (plr != &players[consoleplayer]) return 0; - COM_BufInsertText(va("%s\n", luaL_checkstring(L, 2))); + COM_BufInsertTextEx(va("%s\n", luaL_checkstring(L, 2)), COM_SAFE); return 0; } @@ -295,7 +301,7 @@ static int lib_cvRegisterVar(lua_State *L) consvar_t *cvar; luaL_checktype(L, 1, LUA_TTABLE); lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one. - NOHUD + NOHOOK cvar = lua_newuserdata(L, sizeof(consvar_t)); luaL_getmetatable(L, META_CVAR); lua_setmetatable(L, -2); @@ -303,6 +309,8 @@ static int lib_cvRegisterVar(lua_State *L) #define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to " LUA_QL("CV_RegisterVar") " (%s)", e); #define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1))) + memset(cvar, 0x00, sizeof(consvar_t)); // zero everything by default + lua_pushnil(L); while (lua_next(L, 1)) { // stack: cvar table, cvar userdata, key/index, value @@ -390,6 +398,13 @@ static int lib_cvRegisterVar(lua_State *L) #undef FIELDERROR #undef TYPEERROR + if (!cvar->name) + return luaL_error(L, M_GetText("Variable has no name!\n")); + if ((cvar->flags & CV_NOINIT) && !(cvar->flags & CV_CALL)) + return luaL_error(L, M_GetText("Variable %s has CV_NOINIT without CV_CALL\n"), cvar->name); + if ((cvar->flags & CV_CALL) && !cvar->func) + return luaL_error(L, M_GetText("Variable %s has CV_CALL without a function\n"), cvar->name); + // stack: cvar table, cvar userdata lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars"); I_Assert(lua_istable(L, 3)); @@ -413,6 +428,26 @@ static int lib_cvRegisterVar(lua_State *L) return 1; } +static int lib_cvFindVar(lua_State *L) +{ + consvar_t *cv; + if (( cv = CV_FindVar(luaL_checkstring(L,1)) )) + { + lua_settop(L,1);/* We only want one argument in the stack. */ + lua_pushlightuserdata(L, cv);/* Now the second value on stack. */ + luaL_getmetatable(L, META_CVAR); + /* + The metatable is the last value on the stack, so this + applies it to the second value, which is the cvar. + */ + lua_setmetatable(L,2); + lua_pushvalue(L,2); + return 1; + } + else + return 0; +} + // CONS_Printf for a single player // Use 'print' in baselib for a global message. static int lib_consPrintf(lua_State *L) @@ -423,6 +458,7 @@ static int lib_consPrintf(lua_State *L) if (n < 2) return luaL_error(L, "CONS_Printf requires at least two arguments: player and text."); //HUDSAFE + INLEVEL plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); if (!plr) return LUA_ErrInvalid(L, "player_t"); @@ -451,6 +487,7 @@ static luaL_Reg lib[] = { {"COM_BufAddText", lib_comBufAddText}, {"COM_BufInsertText", lib_comBufInsertText}, {"CV_RegisterVar", lib_cvRegisterVar}, + {"CV_FindVar", lib_cvFindVar}, {"CONS_Printf", lib_consPrintf}, {NULL, NULL} }; @@ -513,5 +550,3 @@ int LUA_ConsoleLib(lua_State *L) luaL_register(L, NULL, lib); return 0; } - -#endif diff --git a/src/lua_hook.h b/src/lua_hook.h index 252960edf..244b1bbb8 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -10,8 +10,6 @@ /// \file lua_hook.h /// \brief hooks for Lua scripting -#ifdef HAVE_BLUA - #include "r_defs.h" #include "d_player.h" @@ -20,9 +18,12 @@ enum hook { hook_MapChange, hook_MapLoad, hook_PlayerJoin, + hook_PreThinkFrame, hook_ThinkFrame, + hook_PostThinkFrame, hook_MobjSpawn, hook_MobjCollide, + hook_MobjLineCollide, hook_MobjMoveCollide, hook_TouchSpecial, hook_MobjFuse, @@ -43,7 +44,19 @@ enum hook { hook_PlayerMsg, hook_HurtMsg, hook_PlayerSpawn, + hook_ShieldSpawn, + hook_ShieldSpecial, + hook_MobjMoveBlocked, + hook_MapThingSpawn, + hook_FollowMobj, + hook_PlayerCanDamage, hook_PlayerQuit, + hook_IntermissionThinker, + hook_TeamSwitch, + hook_ViewpointSwitch, + hook_SeenPlayer, + hook_PlayerThink, + hook_ShouldJingleContinue, hook_MAX // last hook }; @@ -52,32 +65,48 @@ extern const char *const hookNames[]; void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) void LUAh_MapLoad(void); // Hook for map load void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer +void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers) void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers) +void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials) boolean LUAh_MobjHook(mobj_t *mo, enum hook which); boolean LUAh_PlayerHook(player_t *plr, enum hook which); #define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which); +UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which); #define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type +#define LUAh_MobjLineCollide(thing, line) LUAh_MobjLineCollideHook(thing, line, hook_MobjLineCollide) // Hook for PIT_CheckThing by (thing) mobj type #define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type #define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type #define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type -UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?) -boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!) -boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source); // Hook for P_KillMobj by mobj type +UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); // Hook for P_DamageMobj by mobj type (Should mobj take damage?) +boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!) +boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for P_KillMobj by mobj type #define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type #define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type #define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping) #define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping) -#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinDash (Spin button effect) +#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinAbility (Spin button effect) #define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air)) boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages -boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages +boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for hurt messages #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer -void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting - +#define LUAh_ShieldSpawn(player) LUAh_PlayerHook(player, hook_ShieldSpawn) // Hook for P_SpawnShieldOrb +#define LUAh_ShieldSpecial(player) LUAh_PlayerHook(player, hook_ShieldSpecial) // Hook for shield abilities +#define LUAh_MobjMoveBlocked(mo) LUAh_MobjHook(mo, hook_MobjMoveBlocked) // Hook for P_XYMovement (when movement is blocked) +boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnMapThing by mobj type +boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following +UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage +void LUAh_PlayerQuit(player_t *plr, kickreason_t reason); // Hook for player quitting +void LUAh_IntermissionThinker(void); // Hook for Y_Ticker +boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); // Hook for team switching in... uh.... +UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); // Hook for spy mode +#ifdef SEENAMES +boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK #endif +#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink +boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 948eca84c..522be8c32 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,11 +11,10 @@ /// \brief hooks for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "doomstat.h" #include "p_mobj.h" #include "g_game.h" -#include "r_things.h" +#include "r_skins.h" #include "b_bot.h" #include "z_zone.h" @@ -31,9 +30,12 @@ const char *const hookNames[hook_MAX+1] = { "MapChange", "MapLoad", "PlayerJoin", + "PreThinkFrame", "ThinkFrame", + "PostThinkFrame", "MobjSpawn", "MobjCollide", + "MobjLineCollide", "MobjMoveCollide", "TouchSpecial", "MobjFuse", @@ -54,7 +56,19 @@ const char *const hookNames[hook_MAX+1] = { "PlayerMsg", "HurtMsg", "PlayerSpawn", + "ShieldSpawn", + "ShieldSpecial", + "MobjMoveBlocked", + "MapThingSpawn", + "FollowMobj", + "PlayerCanDamage", "PlayerQuit", + "IntermissionThinker", + "TeamSwitch", + "ViewpointSwitch", + "SeenPlayer", + "PlayerThink", + "ShouldJingleContinue", NULL }; @@ -67,6 +81,7 @@ struct hook_s union { mobjtype_t mt; char *skinname; + char *musname; char *funcname; } s; boolean error; @@ -106,14 +121,15 @@ static int lib_addHook(lua_State *L) luaL_checktype(L, 1, LUA_TFUNCTION); - if (hud_running) - return luaL_error(L, "HUD rendering code should not call this function!"); + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); switch(hook.type) { // Take a mobjtype enum which this hook is specifically for. case hook_MobjSpawn: case hook_MobjCollide: + case hook_MobjLineCollide: case hook_MobjMoveCollide: case hook_TouchSpecial: case hook_MobjFuse: @@ -125,12 +141,16 @@ static int lib_addHook(lua_State *L) case hook_BossDeath: case hook_MobjRemoved: case hook_HurtMsg: + case hook_MobjMoveBlocked: + case hook_MapThingSpawn: + case hook_FollowMobj: hook.s.mt = MT_NULL; if (lua_isnumber(L, 2)) hook.s.mt = lua_tonumber(L, 2); luaL_argcheck(L, hook.s.mt < NUMMOBJTYPES, 2, "invalid mobjtype_t"); break; case hook_BotAI: + case hook_ShouldJingleContinue: hook.s.skinname = NULL; if (lua_isstring(L, 2)) { // lowercase copy @@ -171,6 +191,7 @@ static int lib_addHook(lua_State *L) lastp = &mobjthinkerhooks[hook.s.mt]; break; case hook_MobjCollide: + case hook_MobjLineCollide: case hook_MobjMoveCollide: lastp = &mobjcollidehooks[hook.s.mt]; break; @@ -183,6 +204,9 @@ static int lib_addHook(lua_State *L) case hook_MobjDeath: case hook_BossDeath: case hook_MobjRemoved: + case hook_MobjMoveBlocked: + case hook_MapThingSpawn: + case hook_FollowMobj: lastp = &mobjhooks[hook.s.mt]; break; case hook_JumpSpecial: @@ -190,6 +214,13 @@ static int lib_addHook(lua_State *L) case hook_SpinSpecial: case hook_JumpSpinSpecial: case hook_PlayerSpawn: + case hook_PlayerCanDamage: + case hook_TeamSwitch: + case hook_ViewpointSwitch: + case hook_SeenPlayer: + case hook_ShieldSpawn: + case hook_ShieldSpecial: + case hook_PlayerThink: lastp = &playerhooks; break; case hook_LinedefExecute: @@ -238,44 +269,48 @@ boolean LUAh_MobjHook(mobj_t *mo, enum hook which) // Look for all generic mobj hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == which) - { - if (lua_gettop(gL) == 0) - LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) + LUA_PushUserdata(gL, mo, META_MOBJ); + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); + hookp->error = true; + continue; } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next) - if (hookp->type == which) - { - if (lua_gettop(gL) == 0) - LUA_PushUserdata(gL, mo, META_MOBJ); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) + LUA_PushUserdata(gL, mo, META_MOBJ); + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); + hookp->error = true; + continue; } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -291,24 +326,26 @@ boolean LUAh_PlayerHook(player_t *plr, enum hook which) lua_settop(gL, 0); for (hookp = playerhooks; hookp; hookp = hookp->next) - if (hookp->type == which) - { - if (lua_gettop(gL) == 0) - LUA_PushUserdata(gL, plr, META_PLAYER); - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); - if (lua_pcall(gL, 1, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) + LUA_PushUserdata(gL, plr, META_PLAYER); + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); + if (lua_pcall(gL, 1, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); lua_pop(gL, 1); + hookp->error = true; + continue; } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -325,13 +362,15 @@ void LUAh_MapChange(INT16 mapnumber) lua_pushinteger(gL, mapnumber); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_MapChange) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); - LUA_Call(gL, 1); - } + { + if (hookp->type != hook_MapChange) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); + LUA_Call(gL, 1); + } lua_settop(gL, 0); } @@ -347,13 +386,15 @@ void LUAh_MapLoad(void) lua_pushinteger(gL, gamemap); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_MapLoad) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); - LUA_Call(gL, 1); - } + { + if (hookp->type != hook_MapLoad) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); + LUA_Call(gL, 1); + } lua_settop(gL, 0); } @@ -369,17 +410,42 @@ void LUAh_PlayerJoin(int playernum) lua_pushinteger(gL, playernum); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerJoin) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); - LUA_Call(gL, 1); - } + { + if (hookp->type != hook_PlayerJoin) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); + LUA_Call(gL, 1); + } lua_settop(gL, 0); } +// Hook for frame (before mobj and player thinkers) +void LUAh_PreThinkFrame(void) +{ + hook_p hookp; + if (!gL || !(hooksAvailable[hook_PreThinkFrame/8] & (1<<(hook_PreThinkFrame%8)))) + return; + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_PreThinkFrame) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + } +} + // Hook for frame (after mobj and player thinkers) void LUAh_ThinkFrame(void) { @@ -388,17 +454,43 @@ void LUAh_ThinkFrame(void) return; for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_ThinkFrame) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } + { + if (hookp->type != hook_ThinkFrame) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; } + } +} + + +// Hook for frame (at end of tick, ie after overlays, precipitation, specials) +void LUAh_PostThinkFrame(void) +{ + hook_p hookp; + if (!gL || !(hooksAvailable[hook_PostThinkFrame/8] & (1<<(hook_PostThinkFrame%8)))) + return; + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_PostThinkFrame) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + } } // Hook for mobj collisions @@ -415,62 +507,144 @@ UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) // Look for all generic mobj collision hooks for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == which) + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, thing1, META_MOBJ); - LUA_PushUserdata(gL, thing2, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, thing1, META_MOBJ); + LUA_PushUserdata(gL, thing2, META_MOBJ); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } for (hookp = mobjcollidehooks[thing1->type]; hookp; hookp = hookp->next) - if (hookp->type == which) + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, thing1, META_MOBJ); - LUA_PushUserdata(gL, thing2, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { // if nil, leave shouldCollide = 0. - if (lua_toboolean(gL, -1)) - shouldCollide = 1; // Force yes - else - shouldCollide = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, thing1, META_MOBJ); + LUA_PushUserdata(gL, thing2, META_MOBJ); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return shouldCollide; +} + +UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which) +{ + hook_p hookp; + UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no. + if (!gL || !(hooksAvailable[which/8] & (1<<(which%8)))) + return 0; + + I_Assert(thing->type < NUMMOBJTYPES); + + lua_settop(gL, 0); + + // Look for all generic mobj collision hooks + for (hookp = mobjcollidehooks[MT_NULL]; hookp; hookp = hookp->next) + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, thing, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } + + for (hookp = mobjcollidehooks[thing->type]; hookp; hookp = hookp->next) + { + if (hookp->type != which) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, thing, META_MOBJ); + LUA_PushUserdata(gL, line, META_LINE); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldCollide; @@ -545,59 +719,63 @@ boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher) // Look for all generic touch special hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_TouchSpecial) + { + if (hookp->type != hook_TouchSpecial) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, special, META_MOBJ); - LUA_PushUserdata(gL, toucher, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, special, META_MOBJ); + LUA_PushUserdata(gL, toucher, META_MOBJ); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[special->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_TouchSpecial) + { + if (hookp->type != hook_TouchSpecial) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, special, META_MOBJ); - LUA_PushUserdata(gL, toucher, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, special, META_MOBJ); + LUA_PushUserdata(gL, toucher, META_MOBJ); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; } // Hook for P_DamageMobj by mobj type (Should mobj take damage?) -UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { hook_p hookp; UINT8 shouldDamage = 0; // 0 = default, 1 = force yes, 2 = force no. @@ -610,77 +788,84 @@ UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 // Look for all generic should damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_ShouldDamage) + { + if (hookp->type != hook_ShouldDamage) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + if (lua_pcall(gL, 5, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_ShouldDamage) + { + if (hookp->type != hook_ShouldDamage) + continue; + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (!lua_isnil(gL, -1)) - { - if (lua_toboolean(gL, -1)) - shouldDamage = 1; // Force yes - else - shouldDamage = 2; // Force no - } - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + if (lua_pcall(gL, 5, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { + if (lua_toboolean(gL, -1)) + shouldDamage = 1; // Force yes + else + shouldDamage = 2; // Force no + } + lua_pop(gL, 1); + } lua_settop(gL, 0); return shouldDamage; } // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!) -boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { hook_p hookp; boolean hooked = false; @@ -693,67 +878,75 @@ boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 // Look for all generic mobj damage hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDamage) + { + if (hookp->type != hook_MobjDamage) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + if (lua_pcall(gL, 5, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDamage) + { + if (hookp->type != hook_MobjDamage) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - lua_pushinteger(gL, damage); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damage); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + if (lua_pcall(gL, 5, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; } // Hook for P_KillMobj by mobj type -boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source) +boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { hook_p hookp; boolean hooked = false; @@ -766,56 +959,64 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source) // Look for all generic mobj death hooks for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDeath) + { + if (hookp->type != hook_MobjDeath) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } for (hookp = mobjhooks[target->type]; hookp; hookp = hookp->next) - if (hookp->type == hook_MobjDeath) + { + if (hookp->type != hook_MobjDeath) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, target, META_MOBJ); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, target, META_MOBJ); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -832,28 +1033,30 @@ boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd) lua_settop(gL, 0); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_BotTiccmd) + { + if (hookp->type != hook_BotTiccmd) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, bot, META_PLAYER); - LUA_PushUserdata(gL, cmd, META_TICCMD); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, bot, META_PLAYER); + LUA_PushUserdata(gL, cmd, META_TICCMD); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -870,51 +1073,53 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) lua_settop(gL, 0); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_BotAI - && (hookp->s.skinname == NULL || !strcmp(hookp->s.skinname, ((skin_t*)tails->skin)->name))) + { + if (hookp->type != hook_BotAI + || (hookp->s.skinname && strcmp(hookp->s.skinname, ((skin_t*)tails->skin)->name))) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, sonic, META_MOBJ); - LUA_PushUserdata(gL, tails, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 8, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - - // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. - if (lua_istable(gL, 2+1)) { - boolean forward=false, backward=false, left=false, right=false, strafeleft=false, straferight=false, jump=false, spin=false; -#define CHECKFIELD(field) \ - lua_getfield(gL, 2+1, #field);\ - if (lua_toboolean(gL, -1))\ - field = true;\ - lua_pop(gL, 1); - - CHECKFIELD(forward) - CHECKFIELD(backward) - CHECKFIELD(left) - CHECKFIELD(right) - CHECKFIELD(strafeleft) - CHECKFIELD(straferight) - CHECKFIELD(jump) - CHECKFIELD(spin) -#undef CHECKFIELD - B_KeysToTiccmd(tails, cmd, forward, backward, left, right, strafeleft, straferight, jump, spin); - } else - B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, 2+1), lua_toboolean(gL, 2+2), lua_toboolean(gL, 2+3), lua_toboolean(gL, 2+4), lua_toboolean(gL, 2+5), lua_toboolean(gL, 2+6), lua_toboolean(gL, 2+7), lua_toboolean(gL, 2+8)); - - lua_pop(gL, 8); - hooked = true; + LUA_PushUserdata(gL, sonic, META_MOBJ); + LUA_PushUserdata(gL, tails, META_MOBJ); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 8, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + + // This turns forward, backward, left, right, jump, and spin into a proper ticcmd for tails. + if (lua_istable(gL, 2+1)) { + boolean forward=false, backward=false, left=false, right=false, strafeleft=false, straferight=false, jump=false, spin=false; +#define CHECKFIELD(field) \ + lua_getfield(gL, 2+1, #field);\ + if (lua_toboolean(gL, -1))\ + field = true;\ + lua_pop(gL, 1); + + CHECKFIELD(forward) + CHECKFIELD(backward) + CHECKFIELD(left) + CHECKFIELD(right) + CHECKFIELD(strafeleft) + CHECKFIELD(straferight) + CHECKFIELD(jump) + CHECKFIELD(spin) +#undef CHECKFIELD + B_KeysToTiccmd(tails, cmd, forward, backward, left, right, strafeleft, straferight, jump, spin); + } else + B_KeysToTiccmd(tails, cmd, lua_toboolean(gL, 2+1), lua_toboolean(gL, 2+2), lua_toboolean(gL, 2+3), lua_toboolean(gL, 2+4), lua_toboolean(gL, 2+5), lua_toboolean(gL, 2+6), lua_toboolean(gL, 2+7), lua_toboolean(gL, 2+8)); + + lua_pop(gL, 8); + hooked = true; + } lua_settop(gL, 0); return hooked; @@ -931,22 +1136,24 @@ boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector) lua_settop(gL, 0); for (hookp = linedefexecutorhooks; hookp; hookp = hookp->next) - if (!strcmp(hookp->s.funcname, line->text)) + { + if (strcmp(hookp->s.funcname, line->text)) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, line, META_LINE); - LUA_PushUserdata(gL, mo, META_MOBJ); - LUA_PushUserdata(gL, sector, META_SECTOR); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - LUA_Call(gL, 3); - hooked = true; + LUA_PushUserdata(gL, line, META_LINE); + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, sector, META_SECTOR); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + LUA_Call(gL, 3); + hooked = true; + } lua_settop(gL, 0); return hooked; @@ -963,43 +1170,45 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg) lua_settop(gL, 0); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerMsg) + { + if (hookp->type != hook_PlayerMsg) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player - if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c - lua_pushinteger(gL, 3); // type - lua_pushnil(gL); // target - } else if (target == -1) { // sayteam - lua_pushinteger(gL, 1); // type - lua_pushnil(gL); // target - } else if (target == 0) { // say - lua_pushinteger(gL, 0); // type - lua_pushnil(gL); // target - } else { // sayto - lua_pushinteger(gL, 2); // type - LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target - } - lua_pushstring(gL, msg); // msg + LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player + if (flags & 2 /*HU_CSAY*/) { // csay TODO: make HU_CSAY accessible outside hu_stuff.c + lua_pushinteger(gL, 3); // type + lua_pushnil(gL); // target + } else if (target == -1) { // sayteam + lua_pushinteger(gL, 1); // type + lua_pushnil(gL); // target + } else if (target == 0) { // say + lua_pushinteger(gL, 0); // type + lua_pushnil(gL); // target + } else { // sayto + lua_pushinteger(gL, 2); // type + LUA_PushUserdata(gL, &players[target-1], META_PLAYER); // target } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - lua_pushvalue(gL, -5); - if (lua_pcall(gL, 4, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + lua_pushstring(gL, msg); // msg } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1007,7 +1216,7 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg) // Hook for hurt messages -boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) +boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { hook_p hookp; boolean hooked = false; @@ -1017,31 +1226,35 @@ boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) lua_settop(gL, 0); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_HurtMsg - && (hookp->s.mt == MT_NULL || (inflictor && hookp->s.mt == inflictor->type))) + { + if (hookp->type != hook_HurtMsg + || (hookp->s.mt && !(inflictor && hookp->s.mt == inflictor->type))) + continue; + + if (lua_gettop(gL) == 0) { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, inflictor, META_MOBJ); - LUA_PushUserdata(gL, source, META_MOBJ); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - lua_pushvalue(gL, -4); - if (lua_pcall(gL, 3, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, inflictor, META_MOBJ); + LUA_PushUserdata(gL, source, META_MOBJ); + lua_pushinteger(gL, damagetype); } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + lua_pushvalue(gL, -5); + if (lua_pcall(gL, 4, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } lua_settop(gL, 0); return hooked; @@ -1064,19 +1277,199 @@ void LUAh_NetArchiveHook(lua_CFunction archFunc) // stack: tables, archFunc for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_NetVars) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -2); // archFunc - LUA_Call(gL, 1); - } + { + if (hookp->type != hook_NetVars) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -2); // archFunc + LUA_Call(gL, 1); + } lua_pop(gL, 1); // pop archFunc // stack: tables } -void LUAh_PlayerQuit(player_t *plr, int reason) +boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing) +{ + hook_p hookp; + boolean hooked = false; + if (!gL || !(hooksAvailable[hook_MapThingSpawn/8] & (1<<(hook_MapThingSpawn%8)))) + return false; + + lua_settop(gL, 0); + + // Look for all generic mobj map thing spawn hooks + for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) + { + if (hookp->type != hook_MapThingSpawn) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, mthing, META_MAPTHING); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + for (hookp = mobjhooks[mo->type]; hookp; hookp = hookp->next) + { + if (hookp->type != hook_MapThingSpawn) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, mo, META_MOBJ); + LUA_PushUserdata(gL, mthing, META_MAPTHING); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return hooked; +} + +// Hook for P_PlayerAfterThink Smiles mobj-following +boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj) +{ + hook_p hookp; + boolean hooked = false; + if (!gL || !(hooksAvailable[hook_FollowMobj/8] & (1<<(hook_FollowMobj%8)))) + return 0; + + lua_settop(gL, 0); + + // Look for all generic mobj follow item hooks + for (hookp = mobjhooks[MT_NULL]; hookp; hookp = hookp->next) + { + if (hookp->type != hook_FollowMobj) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, mobj, META_MOBJ); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + for (hookp = mobjhooks[mobj->type]; hookp; hookp = hookp->next) + { + if (hookp->type != hook_FollowMobj) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, mobj, META_MOBJ); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return hooked; +} + +// Hook for P_PlayerCanDamage +UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj) +{ + hook_p hookp; + UINT8 shouldCollide = 0; // 0 = default, 1 = force yes, 2 = force no. + if (!gL || !(hooksAvailable[hook_PlayerCanDamage/8] & (1<<(hook_PlayerCanDamage%8)))) + return 0; + + lua_settop(gL, 0); + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_PlayerCanDamage) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, mobj, META_MOBJ); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave shouldCollide = 0. + if (lua_toboolean(gL, -1)) + shouldCollide = 1; // Force yes + else + shouldCollide = 2; // Force no + } + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return shouldCollide; +} + +void LUAh_PlayerQuit(player_t *plr, kickreason_t reason) { hook_p hookp; if (!gL || !(hooksAvailable[hook_PlayerQuit/8] & (1<<(hook_PlayerQuit%8)))) @@ -1085,21 +1478,229 @@ void LUAh_PlayerQuit(player_t *plr, int reason) lua_settop(gL, 0); for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_PlayerQuit) - { - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit - lua_pushinteger(gL, reason); // Reason for quitting - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - LUA_Call(gL, 2); - } + { + if (hookp->type != hook_PlayerQuit) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit + lua_pushinteger(gL, reason); // Reason for quitting + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + LUA_Call(gL, 2); + } lua_settop(gL, 0); } -#endif +// Hook for Y_Ticker +void LUAh_IntermissionThinker(void) +{ + hook_p hookp; + if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) + return; + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_IntermissionThinker) + continue; + + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + } +} + +// Hook for team switching +// It's just an edit of LUAh_ViewpointSwitch. +boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble) +{ + hook_p hookp; + boolean canSwitchTeam = true; + if (!gL || !(hooksAvailable[hook_TeamSwitch/8] & (1<<(hook_TeamSwitch%8)))) + return true; + + lua_settop(gL, 0); + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_TeamSwitch) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + lua_pushinteger(gL, newteam); + lua_pushboolean(gL, fromspectators); + lua_pushboolean(gL, tryingautobalance); + lua_pushboolean(gL, tryingscramble); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + lua_pushvalue(gL, -6); + if (lua_pcall(gL, 5, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1) && !lua_toboolean(gL, -1)) + canSwitchTeam = false; // Can't switch team + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return canSwitchTeam; +} + +// Hook for spy mode +UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced) +{ + hook_p hookp; + UINT8 canSwitchView = 0; // 0 = default, 1 = force yes, 2 = force no. + if (!gL || !(hooksAvailable[hook_ViewpointSwitch/8] & (1<<(hook_ViewpointSwitch%8)))) + return 0; + + lua_settop(gL, 0); + hud_running = true; // local hook + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_ViewpointSwitch) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, newdisplayplayer, META_PLAYER); + lua_pushboolean(gL, forced); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + lua_pushvalue(gL, -4); + if (lua_pcall(gL, 3, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1)) + { // if nil, leave canSwitchView = 0. + if (lua_toboolean(gL, -1)) + canSwitchView = 1; // Force viewpoint switch + else + canSwitchView = 2; // Skip viewpoint switch + } + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + hud_running = false; + + return canSwitchView; +} + +// Hook for MT_NAMECHECK +#ifdef SEENAMES +boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend) +{ + hook_p hookp; + boolean hasSeenPlayer = true; + if (!gL || !(hooksAvailable[hook_SeenPlayer/8] & (1<<(hook_SeenPlayer%8)))) + return true; + + lua_settop(gL, 0); + hud_running = true; // local hook + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_SeenPlayer) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, seenfriend, META_PLAYER); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1) && !lua_toboolean(gL, -1)) + hasSeenPlayer = false; // Hasn't seen player + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + hud_running = false; + + return hasSeenPlayer; +} +#endif // SEENAMES + +boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname) +{ + hook_p hookp; + boolean keepplaying = false; + if (!gL || !(hooksAvailable[hook_ShouldJingleContinue/8] & (1<<(hook_ShouldJingleContinue%8)))) + return true; + + lua_settop(gL, 0); + hud_running = true; // local hook + + for (hookp = roothook; hookp; hookp = hookp->next) + { + if (hookp->type != hook_ShouldJingleContinue + || (hookp->s.musname && strcmp(hookp->s.musname, musname))) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + lua_pushstring(gL, musname); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (!lua_isnil(gL, -1) && lua_toboolean(gL, -1)) + keepplaying = true; // Keep playing this boolean + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + hud_running = false; + + return keepplaying; +} diff --git a/src/lua_hud.h b/src/lua_hud.h index f96618e07..4a7c596c8 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -21,10 +21,11 @@ enum hud { // Match / CTF / Tag / Ringslinger hud_weaponrings, hud_powerstones, + hud_teamscores, // NiGHTS mode hud_nightslink, hud_nightsdrill, - hud_nightsrings, + hud_nightsspheres, hud_nightsscore, hud_nightstime, hud_nightsrecords, @@ -33,6 +34,9 @@ enum hud { hud_coopemeralds, hud_tokens, hud_tabemblems, + // Intermission + hud_intermissiontally, + hud_intermissionmessages, hud_MAX }; @@ -42,3 +46,6 @@ boolean LUA_HudEnabled(enum hud option); void LUAh_GameHUD(player_t *stplyr); void LUAh_ScoresHUD(void); +void LUAh_TitleHUD(void); +void LUAh_TitleCardHUD(player_t *stplayr); +void LUAh_IntermissionHUD(void); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index b16125395..818e760c9 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,7 +11,7 @@ /// \brief custom HUD rendering library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA +#include "fastcmp.h" #include "r_defs.h" #include "r_local.h" #include "st_stuff.h" // hudinfo[] @@ -19,6 +19,7 @@ #include "i_video.h" // rendermode #include "p_local.h" // camera_t #include "screen.h" // screen width/height +#include "m_random.h" // m_random #include "v_video.h" #include "w_wad.h" #include "z_zone.h" @@ -34,6 +35,11 @@ static UINT8 hud_enabled[(hud_MAX/8)+1]; static UINT8 hudAvailable; // hud hooks field +#ifdef LUA_PATCH_SAFETY +static patchinfo_t *patchinfo, *patchinfohead; +static int numluapatches; +#endif + // must match enum hud in lua_hud.h static const char *const hud_disable_options[] = { "stagetitle", @@ -46,6 +52,7 @@ static const char *const hud_disable_options[] = { "weaponrings", "powerstones", + "teamscores", "nightslink", "nightsdrill", @@ -58,16 +65,21 @@ static const char *const hud_disable_options[] = { "coopemeralds", "tokens", "tabemblems", + + "intermissiontally", + "intermissionmessages", NULL}; enum hudinfo { hudinfo_x = 0, - hudinfo_y + hudinfo_y, + hudinfo_f }; static const char *const hudinfo_opt[] = { "x", "y", + "f", NULL}; enum patch { @@ -87,11 +99,17 @@ static const char *const patch_opt[] = { enum hudhook { hudhook_game = 0, - hudhook_scores + hudhook_scores, + hudhook_intermission, + hudhook_title, + hudhook_titlecard }; static const char *const hudhook_opt[] = { "game", "scores", + "intermission", + "title", + "titlecard", NULL}; // alignment types for v.drawString @@ -100,9 +118,25 @@ enum align { align_center, align_right, align_fixed, + align_fixedcenter, + align_fixedright, align_small, + align_smallfixed, + align_smallfixedcenter, + align_smallfixedright, + align_smallcenter, align_smallright, + align_smallthin, + align_smallthincenter, + align_smallthinright, + align_smallthinfixed, + align_smallthinfixedcenter, + align_smallthinfixedright, align_thin, + align_thinfixed, + align_thinfixedcenter, + align_thinfixedright, + align_thincenter, align_thinright }; static const char *const align_opt[] = { @@ -110,9 +144,25 @@ static const char *const align_opt[] = { "center", "right", "fixed", + "fixed-center", + "fixed-right", "small", + "small-fixed", + "small-fixed-center", + "small-fixed-right", + "small-center", "small-right", + "small-thin", + "small-thin-center", + "small-thin-right", + "small-thin-fixed", + "small-thin-fixed-center", + "small-thin-fixed-right", "thin", + "thin-fixed", + "thin-fixed-center", + "thin-fixed-right", + "thin-center", "thin-right", NULL}; @@ -195,6 +245,9 @@ static int hudinfo_get(lua_State *L) case hudinfo_y: lua_pushinteger(L, info->y); break; + case hudinfo_f: + lua_pushinteger(L, info->f); + break; } return 1; } @@ -213,6 +266,9 @@ static int hudinfo_set(lua_State *L) case hudinfo_y: info->y = (INT32)luaL_checkinteger(L, 3); break; + case hudinfo_f: + info->f = (INT32)luaL_checkinteger(L, 3); + break; } return 0; } @@ -226,17 +282,31 @@ static int hudinfo_num(lua_State *L) static int colormap_get(lua_State *L) { - return luaL_error(L, "colormap is not a struct."); + const UINT8 *colormap = *((UINT8 **)luaL_checkudata(L, 1, META_COLORMAP)); + UINT32 i = luaL_checkinteger(L, 2); + if (i >= 256) + return luaL_error(L, "colormap index %d out of range (0 - %d)", i, 255); + lua_pushinteger(L, colormap[i]); + return 1; } static int patch_get(lua_State *L) { +#ifdef LUA_PATCH_SAFETY patch_t *patch = *((patch_t **)luaL_checkudata(L, 1, META_PATCH)); +#else + patchinfo_t *patch = *((patchinfo_t **)luaL_checkudata(L, 1, META_PATCH)); +#endif enum patch field = luaL_checkoption(L, 2, NULL, patch_opt); - // patches are CURRENTLY always valid, expected to be cached with PU_STATIC - // this may change in the future, so patch.valid still exists - I_Assert(patch != NULL); + // patches are invalidated when switching renderers + if (!patch) { + if (field == patch_valid) { + lua_pushboolean(L, 0); + return 1; + } + return LUA_ErrInvalid(L, "patch_t"); + } switch (field) { @@ -333,21 +403,270 @@ static int libd_patchExists(lua_State *L) static int libd_cachePatch(lua_State *L) { +#ifdef LUA_PATCH_SAFETY + int i; + lumpnum_t lumpnum; + patchinfo_t *luapat; + patch_t *realpatch; + HUDONLY - LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_STATIC), META_PATCH); + + luapat = patchinfohead; + lumpnum = W_CheckNumForName(luaL_checkstring(L, 1)); + if (lumpnum == LUMPERROR) + lumpnum = W_GetNumForName("MISSING"); + + for (i = 0; i < numluapatches; i++) + { + // check if already cached + if (luapat->wadnum == WADFILENUM(lumpnum) && luapat->lumpnum == LUMPNUM(lumpnum)) + { + LUA_PushUserdata(L, luapat, META_PATCH); + return 1; + } + luapat = luapat->next; + if (!luapat) + break; + } + + if (numluapatches > 0) + { + patchinfo->next = Z_Malloc(sizeof(patchinfo_t), PU_STATIC, NULL); + patchinfo = patchinfo->next; + } + else + { + patchinfo = Z_Malloc(sizeof(patchinfo_t), PU_STATIC, NULL); + patchinfohead = patchinfo; + } + + realpatch = W_CachePatchNum(lumpnum, PU_PATCH); + + patchinfo->width = realpatch->width; + patchinfo->height = realpatch->height; + patchinfo->leftoffset = realpatch->leftoffset; + patchinfo->topoffset = realpatch->topoffset; + + patchinfo->wadnum = WADFILENUM(lumpnum); + patchinfo->lumpnum = LUMPNUM(lumpnum); + + LUA_PushUserdata(L, patchinfo, META_PATCH); + numluapatches++; +#else + HUDONLY + LUA_PushUserdata(L, W_CachePatchName(luaL_checkstring(L, 1), PU_PATCH), META_PATCH); +#endif return 1; } +// v.getSpritePatch(sprite, [frame, [angle, [rollangle]]]) +static int libd_getSpritePatch(lua_State *L) +{ + UINT32 i; // sprite prefix + UINT32 frame = 0; // 'A' + UINT8 angle = 0; + spritedef_t *sprdef; + spriteframe_t *sprframe; + HUDONLY + + if (lua_isnumber(L, 1)) // sprite number given, e.g. SPR_THOK + { + i = lua_tonumber(L, 1); + if (i >= NUMSPRITES) + return 0; + } + else if (lua_isstring(L, 1)) // sprite prefix name given, e.g. "THOK" + { + const char *name = lua_tostring(L, 1); + for (i = 0; i < NUMSPRITES; i++) + if (fastcmp(name, sprnames[i])) + break; + if (i >= NUMSPRITES) + return 0; + } + else + return 0; + + if (i == SPR_PLAY) // Use getSprite2Patch instead! + return 0; + + sprdef = &sprites[i]; + + // set frame number + frame = luaL_optinteger(L, 2, 0); + frame &= FF_FRAMEMASK; // ignore any bits that are not the actual frame, just in case + if (frame >= sprdef->numframes) + return 0; + // set angle number + sprframe = &sprdef->spriteframes[frame]; + angle = luaL_optinteger(L, 3, 1); + + // convert WAD editor angle numbers (1-8) to internal angle numbers (0-7) + // keep 0 the same since we'll make it default to angle 1 (which is internally 0) + // in case somebody didn't know that angle 0 really just maps all 8/16 angles to the same patch + if (angle != 0) + angle--; + + if (angle >= ((sprframe->rotate & SRF_3DGE) ? 16 : 8)) // out of range? + return 0; + +#ifdef ROTSPRITE + if (lua_isnumber(L, 4)) + { + // rotsprite????? + angle_t rollangle = luaL_checkangle(L, 4); + INT32 rot = R_GetRollAngle(rollangle); + + if (rot) { + if (!(sprframe->rotsprite.cached & (1<flip & (1<rotsprite.patch[angle][rot], META_PATCH); + lua_pushboolean(L, false); + lua_pushboolean(L, true); + return 3; + } + } +#endif + + // push both the patch and it's "flip" value + LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_PATCH), META_PATCH); + lua_pushboolean(L, (sprframe->flip & (1<= MAXSKINS) + return luaL_error(L, "skin number %d out of range (0 - %d)", i, MAXSKINS-1); + if (i >= numskins) + return 0; + } + else // find skin by name + { + const char *name = luaL_checkstring(L, 1); + for (i = 0; i < numskins; i++) + if (fastcmp(skins[i].name, name)) + break; + if (i >= numskins) + return 0; + } + + lua_remove(L, 1); // remove skin now + + if (lua_isnumber(L, 1)) // sprite number given, e.g. SPR2_STND + { + j = lua_tonumber(L, 1); + if (j & FF_SPR2SUPER) // e.g. SPR2_STND|FF_SPR2SUPER + { + super = true; + j &= ~FF_SPR2SUPER; // remove flag so the next check doesn't fail + } + if (j >= free_spr2) + return 0; + } + else if (lua_isstring(L, 1)) // sprite prefix name given, e.g. "STND" + { + const char *name = lua_tostring(L, 1); + for (j = 0; j < free_spr2; j++) + if (fastcmp(name, spr2names[j])) + break; + // if you want super flags you'll have to use the optional boolean following this + if (j >= free_spr2) + return 0; + } + else + return 0; + + if (lua_isboolean(L, 2)) // optional boolean for superness + { + super = lua_toboolean(L, 2); // note: this can override FF_SPR2SUPER from sprite number + lua_remove(L, 2); // remove + } + // if it's not boolean then just assume it's the frame number + + if (super) + j |= FF_SPR2SUPER; + + j = P_GetSkinSprite2(&skins[i], j, NULL); // feed skin and current sprite2 through to change sprite2 used if necessary + + sprdef = &skins[i].sprites[j]; + + // set frame number + frame = luaL_optinteger(L, 2, 0); + frame &= FF_FRAMEMASK; // ignore any bits that are not the actual frame, just in case + if (frame >= sprdef->numframes) + return 0; + // set angle number + sprframe = &sprdef->spriteframes[frame]; + angle = luaL_optinteger(L, 3, 1); + + // convert WAD editor angle numbers (1-8) to internal angle numbers (0-7) + // keep 0 the same since we'll make it default to angle 1 (which is internally 0) + // in case somebody didn't know that angle 0 really just maps all 8/16 angles to the same patch + if (angle != 0) + angle--; + + if (angle >= ((sprframe->rotate & SRF_3DGE) ? 16 : 8)) // out of range? + return 0; + +#ifdef ROTSPRITE + if (lua_isnumber(L, 4)) + { + // rotsprite????? + angle_t rollangle = luaL_checkangle(L, 4); + INT32 rot = R_GetRollAngle(rollangle); + + if (rot) { + if (!(sprframe->rotsprite.cached & (1<flip & (1<rotsprite.patch[angle][rot], META_PATCH); + lua_pushboolean(L, false); + lua_pushboolean(L, true); + return 3; + } + } +#endif + + // push both the patch and it's "flip" value + LUA_PushUserdata(L, W_CachePatchNum(sprframe->lumppat[angle], PU_PATCH), META_PATCH); + lua_pushboolean(L, (sprframe->flip & (1<wadnum<<16)+luapat->lumpnum, PU_PATCH); +#else patch = *((patch_t **)luaL_checkudata(L, 3, META_PATCH)); + if (!patch) + return LUA_ErrInvalid(L, "patch_t"); +#endif flags = luaL_optinteger(L, 4, 0); if (!lua_isnoneornil(L, 5)) colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); @@ -363,6 +682,9 @@ static int libd_drawScaled(lua_State *L) fixed_t x, y, scale; INT32 flags; patch_t *patch; +#ifdef LUA_PATCH_SAFETY + patchinfo_t *luapat; +#endif const UINT8 *colormap = NULL; HUDONLY @@ -371,7 +693,14 @@ static int libd_drawScaled(lua_State *L) scale = luaL_checkinteger(L, 3); if (scale < 0) return luaL_error(L, "negative scale"); +#ifdef LUA_PATCH_SAFETY + luapat = *((patchinfo_t **)luaL_checkudata(L, 4, META_PATCH)); + patch = W_CachePatchNum((luapat->wadnum<<16)+luapat->lumpnum, PU_PATCH); +#else patch = *((patch_t **)luaL_checkudata(L, 4, META_PATCH)); + if (!patch) + return LUA_ErrInvalid(L, "patch_t"); +#endif flags = luaL_optinteger(L, 5, 0); if (!lua_isnoneornil(L, 6)) colormap = *((UINT8 **)luaL_checkudata(L, 6, META_COLORMAP)); @@ -382,6 +711,33 @@ static int libd_drawScaled(lua_State *L) return 0; } +static int libd_drawStretched(lua_State *L) +{ + fixed_t x, y, hscale, vscale; + INT32 flags; + patch_t *patch; + const UINT8 *colormap = NULL; + + HUDONLY + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + hscale = luaL_checkinteger(L, 3); + if (hscale < 0) + return luaL_error(L, "negative horizontal scale"); + vscale = luaL_checkinteger(L, 4); + if (vscale < 0) + return luaL_error(L, "negative vertical scale"); + patch = *((patch_t **)luaL_checkudata(L, 5, META_PATCH)); + flags = luaL_optinteger(L, 6, 0); + if (!lua_isnoneornil(L, 7)) + colormap = *((UINT8 **)luaL_checkudata(L, 7, META_COLORMAP)); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + + V_DrawStretchyFixedPatch(x, y, hscale, vscale, flags, patch, colormap); + return 0; +} + static int libd_drawNum(lua_State *L) { INT32 x, y, flags, num; @@ -450,24 +806,134 @@ static int libd_drawString(lua_State *L) case align_fixed: V_DrawStringAtFixed(x, y, flags, str); break; + case align_fixedcenter: + V_DrawCenteredStringAtFixed(x, y, flags, str); + break; + case align_fixedright: + V_DrawRightAlignedStringAtFixed(x, y, flags, str); + break; // hu_font, 0.5x scale case align_small: V_DrawSmallString(x, y, flags, str); break; + case align_smallfixed: + V_DrawSmallStringAtFixed(x, y, flags, str); + break; + case align_smallfixedcenter: + V_DrawCenteredSmallStringAtFixed(x, y, flags, str); + break; + case align_smallfixedright: + V_DrawRightAlignedSmallStringAtFixed(x, y, flags, str); + break; + case align_smallcenter: + V_DrawCenteredSmallString(x, y, flags, str); + break; case align_smallright: V_DrawRightAlignedSmallString(x, y, flags, str); break; + case align_smallthin: + V_DrawSmallThinString(x, y, flags, str); + break; + case align_smallthincenter: + V_DrawCenteredSmallThinString(x, y, flags, str); + break; + case align_smallthinright: + V_DrawRightAlignedSmallThinString(x, y, flags, str); + break; + case align_smallthinfixed: + V_DrawSmallThinStringAtFixed(x, y, flags, str); + break; + case align_smallthinfixedcenter: + V_DrawCenteredSmallThinStringAtFixed(x, y, flags, str); + break; + case align_smallthinfixedright: + V_DrawRightAlignedSmallThinStringAtFixed(x, y, flags, str); + break; // tny_font case align_thin: V_DrawThinString(x, y, flags, str); break; + case align_thincenter: + V_DrawCenteredThinString(x, y, flags, str); + break; case align_thinright: V_DrawRightAlignedThinString(x, y, flags, str); break; + case align_thinfixed: + V_DrawThinStringAtFixed(x, y, flags, str); + break; + case align_thinfixedcenter: + V_DrawCenteredThinStringAtFixed(x, y, flags, str); + break; + case align_thinfixedright: + V_DrawRightAlignedThinStringAtFixed(x, y, flags, str); + break; } return 0; } +static int libd_drawNameTag(lua_State *L) +{ + INT32 x; + INT32 y; + const char *str; + INT32 flags; + UINT8 basecolor; + UINT8 outlinecolor; + UINT8 *basecolormap = NULL; + UINT8 *outlinecolormap = NULL; + + HUDONLY + + x = luaL_checkinteger(L, 1); + y = luaL_checkinteger(L, 2); + str = luaL_checkstring(L, 3); + flags = luaL_optinteger(L, 4, 0); + basecolor = luaL_optinteger(L, 5, SKINCOLOR_BLUE); + outlinecolor = luaL_optinteger(L, 6, SKINCOLOR_ORANGE); + if (basecolor != SKINCOLOR_NONE) + basecolormap = R_GetTranslationColormap(TC_DEFAULT, basecolor, GTC_CACHE); + if (outlinecolor != SKINCOLOR_NONE) + outlinecolormap = R_GetTranslationColormap(TC_DEFAULT, outlinecolor, GTC_CACHE); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + V_DrawNameTag(x, y, flags, FRACUNIT, basecolormap, outlinecolormap, str); + return 0; +} + +static int libd_drawScaledNameTag(lua_State *L) +{ + fixed_t x; + fixed_t y; + const char *str; + INT32 flags; + fixed_t scale; + UINT8 basecolor; + UINT8 outlinecolor; + UINT8 *basecolormap = NULL; + UINT8 *outlinecolormap = NULL; + + HUDONLY + + x = luaL_checkfixed(L, 1); + y = luaL_checkfixed(L, 2); + str = luaL_checkstring(L, 3); + flags = luaL_optinteger(L, 4, 0); + scale = luaL_optinteger(L, 5, FRACUNIT); + if (scale < 0) + return luaL_error(L, "negative scale"); + basecolor = luaL_optinteger(L, 6, SKINCOLOR_BLUE); + outlinecolor = luaL_optinteger(L, 7, SKINCOLOR_ORANGE); + if (basecolor != SKINCOLOR_NONE) + basecolormap = R_GetTranslationColormap(TC_DEFAULT, basecolor, GTC_CACHE); + if (outlinecolor != SKINCOLOR_NONE) + outlinecolormap = R_GetTranslationColormap(TC_DEFAULT, outlinecolor, GTC_CACHE); + + flags &= ~V_PARAMMASK; // Don't let crashes happen. + V_DrawNameTag(FixedInt(x), FixedInt(y), flags, scale, basecolormap, outlinecolormap, str); + return 0; +} + static int libd_stringWidth(lua_State *L) { const char *str = luaL_checkstring(L, 1); @@ -490,6 +956,13 @@ static int libd_stringWidth(lua_State *L) return 1; } +static int libd_nameTagWidth(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, V_NameTagWidth(luaL_checkstring(L, 1))); + return 1; +} + static int libd_getColormap(lua_State *L) { INT32 skinnum = TC_DEFAULT; @@ -501,8 +974,8 @@ static int libd_getColormap(lua_State *L) else if (lua_type(L, 1) == LUA_TNUMBER) // skin number { skinnum = (INT32)luaL_checkinteger(L, 1); - if (skinnum < TC_ALLWHITE || skinnum >= MAXSKINS) - return luaL_error(L, "skin number %d is out of range (%d - %d)", skinnum, TC_ALLWHITE, MAXSKINS-1); + if (skinnum < TC_BLINK || skinnum >= MAXSKINS) + return luaL_error(L, "skin number %d is out of range (%d - %d)", skinnum, TC_BLINK, MAXSKINS-1); } else // skin name { @@ -519,6 +992,30 @@ static int libd_getColormap(lua_State *L) return 1; } +static int libd_fadeScreen(lua_State *L) +{ + UINT16 color = luaL_checkinteger(L, 1); + UINT8 strength = luaL_checkinteger(L, 2); + const UINT8 maxstrength = ((color & 0xFF00) ? 32 : 10); + + HUDONLY + + if (!strength) + return 0; + + if (strength > maxstrength) + return luaL_error(L, "%s fade strength %d out of range (0 - %d)", ((color & 0xFF00) ? "COLORMAP" : "TRANSMAP"), strength, maxstrength); + + if (strength == maxstrength) // Allow as a shortcut for drawfill... + { + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, ((color & 0xFF00) ? 31 : color)); + return 0; + } + + V_DrawFadeScreen(color, strength); + return 0; +} + static int libd_width(lua_State *L) { HUDONLY @@ -560,9 +1057,78 @@ static int libd_renderer(lua_State *L) return 1; } -// 30/10/18 Lat': Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int +// M_RANDOM +////////////// + +static int libd_RandomFixed(lua_State *L) +{ + HUDONLY + lua_pushfixed(L, M_RandomFixed()); + return 1; +} + +static int libd_RandomByte(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, M_RandomByte()); + return 1; +} + +static int libd_RandomKey(lua_State *L) +{ + INT32 a = (INT32)luaL_checkinteger(L, 1); + + HUDONLY + if (a > 65536) + LUA_UsageWarning(L, "v.RandomKey: range > 65536 is undefined behavior"); + lua_pushinteger(L, M_RandomKey(a)); + return 1; +} + +static int libd_RandomRange(lua_State *L) +{ + INT32 a = (INT32)luaL_checkinteger(L, 1); + INT32 b = (INT32)luaL_checkinteger(L, 2); + + HUDONLY + if (b < a) { + INT32 c = a; + a = b; + b = c; + } + if ((b-a+1) > 65536) + LUA_UsageWarning(L, "v.RandomRange: range > 65536 is undefined behavior"); + lua_pushinteger(L, M_RandomRange(a, b)); + return 1; +} + +// Macros. +static int libd_SignedRandom(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, M_SignedRandom()); + return 1; +} + +static int libd_RandomChance(lua_State *L) +{ + fixed_t p = luaL_checkfixed(L, 1); + HUDONLY + lua_pushboolean(L, M_RandomChance(p)); + return 1; +} + +// 30/10/18 Lat': Get st_translucency's value for HUD rendering as a normal V_xxTRANS int // Could as well be thrown in global vars for ease of access but I guess it makes sense for it to be a HUD fn static int libd_getlocaltransflag(lua_State *L) +{ + HUDONLY + lua_pushinteger(L, (10-st_translucency)*V_10TRANS); + return 1; +} + +// Get cv_translucenthud's value for HUD rendering as a normal V_xxTRANS int +static int libd_getusertransflag(lua_State *L) { HUDONLY lua_pushinteger(L, (10-cv_translucenthud.value)*V_10TRANS); // A bit weird that it's called "translucenthud" yet 10 is fully opaque :V @@ -570,22 +1136,41 @@ static int libd_getlocaltransflag(lua_State *L) } static luaL_Reg lib_draw[] = { + // cache {"patchExists", libd_patchExists}, {"cachePatch", libd_cachePatch}, + {"getSpritePatch", libd_getSpritePatch}, + {"getSprite2Patch", libd_getSprite2Patch}, + {"getColormap", libd_getColormap}, + // drawing {"draw", libd_draw}, {"drawScaled", libd_drawScaled}, + {"drawStretched", libd_drawStretched}, {"drawNum", libd_drawNum}, {"drawPaddedNum", libd_drawPaddedNum}, {"drawFill", libd_drawFill}, {"drawString", libd_drawString}, + {"drawNameTag", libd_drawNameTag}, + {"drawScaledNameTag", libd_drawScaledNameTag}, + {"fadeScreen", libd_fadeScreen}, + // misc {"stringWidth", libd_stringWidth}, - {"getColormap", libd_getColormap}, + {"nameTagWidth", libd_nameTagWidth}, + // m_random + {"RandomFixed",libd_RandomFixed}, + {"RandomByte",libd_RandomByte}, + {"RandomKey",libd_RandomKey}, + {"RandomRange",libd_RandomRange}, + {"SignedRandom",libd_SignedRandom}, // MACRO + {"RandomChance",libd_RandomChance}, // MACRO + // properties {"width", libd_width}, {"height", libd_height}, {"dupx", libd_dupx}, {"dupy", libd_dupy}, {"renderer", libd_renderer}, {"localTransFlag", libd_getlocaltransflag}, + {"userTransFlag", libd_getusertransflag}, {NULL, NULL} }; @@ -630,6 +1215,9 @@ static int lib_hudadd(lua_State *L) luaL_checktype(L, 1, LUA_TFUNCTION); field = luaL_checkoption(L, 2, "game", hudhook_opt); + if (!lua_lumploading) + return luaL_error(L, "This function cannot be called from within a hook or coroutine!"); + lua_getfield(L, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(L, -1)); lua_rawgeti(L, -1, field+2); // HUD[2+] @@ -659,6 +1247,10 @@ int LUA_HudLib(lua_State *L) { memset(hud_enabled, 0xff, (hud_MAX/8)+1); +#ifdef LUA_PATCH_SAFETY + numluapatches = 0; +#endif + lua_newtable(L); // HUD registry table lua_newtable(L); luaL_register(L, NULL, lib_draw); @@ -668,7 +1260,16 @@ int LUA_HudLib(lua_State *L) lua_rawseti(L, -2, 2); // HUD[2] = game rendering functions array lua_newtable(L); - lua_rawseti(L, -2, 3); // HUD[2] = scores rendering functions array + lua_rawseti(L, -2, 3); // HUD[3] = scores rendering functions array + + lua_newtable(L); + lua_rawseti(L, -2, 4); // HUD[4] = intermission rendering functions array + + lua_newtable(L); + lua_rawseti(L, -2, 5); // HUD[5] = title rendering functions array + + lua_newtable(L); + lua_rawseti(L, -2, 6); // HUD[6] = title card rendering functions array lua_setfield(L, LUA_REGISTRYINDEX, "HUD"); luaL_newmetatable(L, META_HUDINFO); @@ -732,7 +1333,7 @@ void LUAh_GameHUD(player_t *stplayr) lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); - lua_rawgeti(gL, -1, 2); // HUD[2] = rendering funcs + lua_rawgeti(gL, -1, 2+hudhook_game); // HUD[2] = rendering funcs I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw @@ -766,7 +1367,7 @@ void LUAh_ScoresHUD(void) lua_getfield(gL, LUA_REGISTRYINDEX, "HUD"); I_Assert(lua_istable(gL, -1)); - lua_rawgeti(gL, -1, 3); // HUD[3] = rendering funcs + lua_rawgeti(gL, -1, 2+hudhook_scores); // HUD[3] = rendering funcs I_Assert(lua_istable(gL, -1)); lua_rawgeti(gL, -2, 1); // HUD[1] = lib_draw @@ -781,4 +1382,86 @@ void LUAh_ScoresHUD(void) hud_running = false; } -#endif +void LUAh_TitleHUD(void) +{ + if (!gL || !(hudAvailable & (1<= free_spr2) + return 0; + lua_pushlstring(L, spr2names[i], 4); + return 1; + } + else if (lua_isstring(L, 1)) + { + const char *name = lua_tostring(L, 1); + for (i = 0; i < free_spr2; i++) + if (fastcmp(name, spr2names[i])) + { + lua_pushinteger(L, i); + return 1; + } + } + return 0; +} + +static int lib_getSpr2default(lua_State *L) +{ + playersprite_t i; + + lua_remove(L, 1); // don't care about spr2defaults[] dummy userdata. + + if (lua_isnumber(L, 1)) + i = lua_tonumber(L, 1); + else if (lua_isstring(L, 1)) + { + const char *name = lua_tostring(L, 1); + for (i = 0; i < free_spr2; i++) + if (fastcmp(name, spr2names[i])) + break; + } + else + return luaL_error(L, "spr2defaults[] invalid index"); + + if (i >= free_spr2) + return luaL_error(L, "spr2defaults[] index %d out of range (%d - %d)", i, 0, free_spr2-1); + + lua_pushinteger(L, spr2defaults[i]); + return 1; +} + +static int lib_setSpr2default(lua_State *L) +{ + playersprite_t i; + UINT8 j = 0; + + if (hud_running) + return luaL_error(L, "Do not alter spr2defaults[] in HUD rendering code!"); + +// todo: maybe allow setting below first freeslot..? step 1 is toggling this, step 2 is testing to see whether it's net-safe +#ifdef SETALLSPR2DEFAULTS +#define FIRSTMODIFY 0 +#else +#define FIRSTMODIFY SPR2_FIRSTFREESLOT + if (free_spr2 == SPR2_FIRSTFREESLOT) + return luaL_error(L, "You can only modify the spr2defaults[] entries of sprite2 freeslots, and none are currently added."); +#endif + + lua_remove(L, 1); // don't care about spr2defaults[] dummy userdata. + + if (lua_isnumber(L, 1)) + i = lua_tonumber(L, 1); + else if (lua_isstring(L, 1)) + { + const char *name = lua_tostring(L, 1); + for (i = 0; i < free_spr2; i++) + { + if (fastcmp(name, spr2names[i])) + break; + } + if (i == free_spr2) + return luaL_error(L, "spr2defaults[] invalid index"); + } + else + return luaL_error(L, "spr2defaults[] invalid index"); + + if (i < FIRSTMODIFY || i >= free_spr2) + return luaL_error(L, "spr2defaults[] index %d out of range (%d - %d)", i, FIRSTMODIFY, free_spr2-1); +#undef FIRSTMODIFY + + if (lua_isnumber(L, 2)) + j = lua_tonumber(L, 2); + else if (lua_isstring(L, 2)) + { + const char *name = lua_tostring(L, 2); + for (j = 0; j < free_spr2; j++) + { + if (fastcmp(name, spr2names[j])) + break; + } + if (j == free_spr2) + return luaL_error(L, "spr2defaults[] invalid set"); + } + else + return luaL_error(L, "spr2defaults[] invalid set"); + + if (j >= free_spr2) + return luaL_error(L, "spr2defaults[] set %d out of range (%d - %d)", j, 0, free_spr2-1); + + spr2defaults[i] = j; + return 0; +} + +static int lib_spr2namelen(lua_State *L) +{ + lua_pushinteger(L, free_spr2); + return 1; +} + +///////////////// +// SPRITE INFO // +///////////////// + +// spriteinfo[] +static int lib_getSpriteInfo(lua_State *L) +{ + UINT32 i = NUMSPRITES; + lua_remove(L, 1); + + if (lua_isstring(L, 1)) + { + const char *name = lua_tostring(L, 1); + INT32 spr; + for (spr = 0; spr < NUMSPRITES; spr++) + { + if (fastcmp(name, sprnames[spr])) + { + i = spr; + break; + } + } + if (i == NUMSPRITES) + { + char *check; + i = strtol(name, &check, 10); + if (check == name || *check != '\0') + return luaL_error(L, "unknown sprite name %s", name); + } + } + else + i = luaL_checkinteger(L, 1); + + if (i == 0 || i >= NUMSPRITES) + return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1); + + LUA_PushUserdata(L, &spriteinfo[i], META_SPRITEINFO); + return 1; +} + +#define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to spriteinfo[] (%s)", e); +#define TYPEERROR(f, t1, t2) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t1), lua_typename(L, t2))) + +static int PopPivotSubTable(spriteframepivot_t *pivot, lua_State *L, int stk, int idx) +{ + int okcool = 0; + switch (lua_type(L, stk)) + { + case LUA_TTABLE: + lua_pushnil(L); + while (lua_next(L, stk)) + { + const char *key = NULL; + lua_Integer ikey = -1; + lua_Integer value = 0; + // x or y? + switch (lua_type(L, stk+1)) + { + case LUA_TSTRING: + key = lua_tostring(L, stk+1); + break; + case LUA_TNUMBER: + ikey = lua_tointeger(L, stk+1); + break; + default: + FIELDERROR("pivot key", va("string or number expected, got %s", luaL_typename(L, stk+1))) + } + // then get value + switch (lua_type(L, stk+2)) + { + case LUA_TNUMBER: + value = lua_tonumber(L, stk+2); + break; + case LUA_TBOOLEAN: + value = (UINT8)lua_toboolean(L, stk+2); + break; + default: + TYPEERROR("pivot value", LUA_TNUMBER, lua_type(L, stk+2)) + } + // finally set omg!!!!!!!!!!!!!!!!!! + if (ikey == 1 || (key && fastcmp(key, "x"))) + pivot[idx].x = (INT32)value; + else if (ikey == 2 || (key && fastcmp(key, "y"))) + pivot[idx].y = (INT32)value; + else if (ikey == 3 || (key && fastcmp(key, "rotaxis"))) + pivot[idx].rotaxis = (UINT8)value; + else if (ikey == -1 && (key != NULL)) + FIELDERROR("pivot key", va("invalid option %s", key)); + okcool = 1; + lua_pop(L, 1); + } + break; + default: + TYPEERROR("sprite pivot", LUA_TTABLE, lua_type(L, stk)) + } + return okcool; +} + +static int PopPivotTable(spriteinfo_t *info, lua_State *L, int stk) +{ + // Just in case? + if (!lua_istable(L, stk)) + TYPEERROR("pivot table", LUA_TTABLE, lua_type(L, stk)); + + lua_pushnil(L); + // stk = 0 has the pivot table + // stk = 1 has the frame key + // stk = 2 has the frame table + // stk = 3 has either a string or a number as key + // stk = 4 has the value for the key mentioned above + while (lua_next(L, stk)) + { + int idx = 0; + const char *framestr = NULL; + switch (lua_type(L, stk+1)) + { + case LUA_TSTRING: + framestr = lua_tostring(L, stk+1); + idx = R_Char2Frame(framestr[0]); + break; + case LUA_TNUMBER: + idx = lua_tonumber(L, stk+1); + break; + default: + TYPEERROR("pivot frame", LUA_TNUMBER, lua_type(L, stk+1)); + } + if ((idx < 0) || (idx >= 64)) + return luaL_error(L, "pivot frame %d out of range (0 - %d)", idx, 63); + // the values in pivot[] are also tables + if (PopPivotSubTable(info->pivot, L, stk+2, idx)) + info->available = true; + lua_pop(L, 1); + } + + return 0; +} + +static int lib_setSpriteInfo(lua_State *L) +{ + spriteinfo_t *info; + + if (!lua_lumploading) + return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!"); + if (hud_running) + return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!"); + + lua_remove(L, 1); + { + UINT32 i = luaL_checkinteger(L, 1); + if (i == 0 || i >= NUMSPRITES) + return luaL_error(L, "spriteinfo[] index %d out of range (1 - %d)", i, NUMSPRITES-1); +#ifdef ROTSPRITE + if (sprites != NULL) + R_FreeSingleRotSprite(&sprites[i]); +#endif + info = &spriteinfo[i]; // get the spriteinfo to assign to. + } + luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table. + lua_remove(L, 1); // pop sprite num, don't need it any more. + lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the spriteinfo. + + lua_pushnil(L); + while (lua_next(L, 1)) { + lua_Integer i = 0; + const char *str = NULL; + if (lua_isnumber(L, 2)) + { + i = lua_tointeger(L, 2); + i++; // shift index in case of missing rotsprite support + } + else + str = luaL_checkstring(L, 2); + + if (i == 1 || (str && fastcmp(str, "pivot"))) + { + // pivot[] is a table + if (lua_istable(L, 3)) + return PopPivotTable(info, L, 3); + else + FIELDERROR("pivot", va("%s expected, got %s", lua_typename(L, LUA_TTABLE), luaL_typename(L, -1))) + } + + lua_pop(L, 1); + } + + return 0; +} + +#undef FIELDERROR +#undef TYPEERROR + +static int lib_spriteinfolen(lua_State *L) +{ + lua_pushinteger(L, NUMSPRITES); + return 1; +} + +// spriteinfo_t +static int spriteinfo_get(lua_State *L) +{ + spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO)); + const char *field = luaL_checkstring(L, 2); + + I_Assert(sprinfo != NULL); + + // push spriteframepivot_t userdata + if (fastcmp(field, "pivot")) + { + // bypass LUA_PushUserdata + void **userdata = lua_newuserdata(L, sizeof(void *)); + *userdata = &sprinfo->pivot; + luaL_getmetatable(L, META_PIVOTLIST); + lua_setmetatable(L, -2); + + // stack is left with the userdata on top, as if getting it had originally succeeded. + return 1; + } + else + return luaL_error(L, LUA_QL("spriteinfo_t") " has no field named " LUA_QS, field); + + return 0; +} + +static int spriteinfo_set(lua_State *L) +{ + spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO)); + const char *field = luaL_checkstring(L, 2); + + if (!lua_lumploading) + return luaL_error(L, "Do not alter spriteinfo_t from within a hook or coroutine!"); + if (hud_running) + return luaL_error(L, "Do not alter spriteinfo_t in HUD rendering code!"); + + I_Assert(sprinfo != NULL); + + lua_remove(L, 1); // remove spriteinfo + lua_remove(L, 1); // remove field + lua_settop(L, 1); // leave only one value + +#ifdef ROTSPRITE + if (sprites != NULL) + R_FreeSingleRotSprite(&sprites[sprinfo-spriteinfo]); +#endif + + if (fastcmp(field, "pivot")) + { + // pivot[] is a table + if (lua_istable(L, 1)) + return PopPivotTable(sprinfo, L, 1); + // pivot[] is userdata + else if (lua_isuserdata(L, 1)) + { + spriteframepivot_t *pivot = *((spriteframepivot_t **)luaL_checkudata(L, 1, META_PIVOTLIST)); + memcpy(&sprinfo->pivot, pivot, sizeof(spriteframepivot_t)); + sprinfo->available = true; // Just in case? + } + } + else + return luaL_error(L, va("Field %s does not exist in spriteinfo_t", field)); + + return 0; +} + +static int spriteinfo_num(lua_State *L) +{ + spriteinfo_t *sprinfo = *((spriteinfo_t **)luaL_checkudata(L, 1, META_SPRITEINFO)); + + I_Assert(sprinfo != NULL); + I_Assert(sprinfo >= spriteinfo); + + lua_pushinteger(L, (UINT32)(sprinfo-spriteinfo)); + return 1; +} + +// framepivot_t +static int pivotlist_get(lua_State *L) +{ + void **userdata; + spriteframepivot_t *framepivot = *((spriteframepivot_t **)luaL_checkudata(L, 1, META_PIVOTLIST)); + const char *field = luaL_checkstring(L, 2); + UINT8 frame; + + I_Assert(framepivot != NULL); + + frame = R_Char2Frame(field[0]); + if (frame == 255) + luaL_error(L, "invalid frame %s", field); + + // bypass LUA_PushUserdata + userdata = lua_newuserdata(L, sizeof(void *)); + *userdata = &framepivot[frame]; + luaL_getmetatable(L, META_FRAMEPIVOT); + lua_setmetatable(L, -2); + + // stack is left with the userdata on top, as if getting it had originally succeeded. + return 1; +} + +static int pivotlist_set(lua_State *L) +{ + // Because I already know it's a spriteframepivot_t anyway + spriteframepivot_t *pivotlist = *((spriteframepivot_t **)lua_touserdata(L, 1)); + //spriteframepivot_t *framepivot = *((spriteframepivot_t **)luaL_checkudata(L, 1, META_FRAMEPIVOT)); + const char *field = luaL_checkstring(L, 2); + UINT8 frame; + + if (!lua_lumploading) + return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!"); + if (hud_running) + return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!"); + + I_Assert(pivotlist != NULL); + + frame = R_Char2Frame(field[0]); + if (frame == 255) + luaL_error(L, "invalid frame %s", field); + + // pivot[] is a table + if (lua_istable(L, 3)) + return PopPivotSubTable(pivotlist, L, 3, frame); + // pivot[] is userdata + else if (lua_isuserdata(L, 3)) + { + spriteframepivot_t *copypivot = *((spriteframepivot_t **)luaL_checkudata(L, 3, META_FRAMEPIVOT)); + memcpy(&pivotlist[frame], copypivot, sizeof(spriteframepivot_t)); + } + + return 0; +} + +static int pivotlist_num(lua_State *L) +{ + lua_pushinteger(L, 64); + return 1; +} + +static int framepivot_get(lua_State *L) +{ + spriteframepivot_t *framepivot = *((spriteframepivot_t **)luaL_checkudata(L, 1, META_FRAMEPIVOT)); + const char *field = luaL_checkstring(L, 2); + + I_Assert(framepivot != NULL); + + if (fastcmp("x", field)) + lua_pushinteger(L, framepivot->x); + else if (fastcmp("y", field)) + lua_pushinteger(L, framepivot->y); + else if (fastcmp("rotaxis", field)) + lua_pushinteger(L, (UINT8)framepivot->rotaxis); + else + return luaL_error(L, va("Field %s does not exist in spriteframepivot_t", field)); + + return 1; +} + +static int framepivot_set(lua_State *L) +{ + spriteframepivot_t *framepivot = *((spriteframepivot_t **)luaL_checkudata(L, 1, META_FRAMEPIVOT)); + const char *field = luaL_checkstring(L, 2); + + if (!lua_lumploading) + return luaL_error(L, "Do not alter spriteframepivot_t from within a hook or coroutine!"); + if (hud_running) + return luaL_error(L, "Do not alter spriteframepivot_t in HUD rendering code!"); + + I_Assert(framepivot != NULL); + + if (fastcmp("x", field)) + framepivot->x = luaL_checkinteger(L, 3); + else if (fastcmp("y", field)) + framepivot->y = luaL_checkinteger(L, 3); + else if (fastcmp("rotaxis", field)) + framepivot->rotaxis = luaL_checkinteger(L, 3); + else + return luaL_error(L, va("Field %s does not exist in spriteframepivot_t", field)); + + return 0; +} + +static int framepivot_num(lua_State *L) +{ + lua_pushinteger(L, 2); + return 1; +} + //////////////// // STATE INFO // //////////////// @@ -202,6 +718,18 @@ static int lib_setState(lua_State *L) case LUA_TSTRING: // It's a string, expect the name of a built-in action LUA_SetActionByName(state, lua_tostring(L, 3)); break; + case LUA_TUSERDATA: // It's a userdata, expect META_ACTION of a built-in action + { + actionf_t *action = *((actionf_t **)luaL_checkudata(L, 3, META_ACTION)); + + if (!action) + return luaL_error(L, "not a valid action?"); + + state->action = *action; + state->action.acv = action->acv; + state->action.acp1 = action->acp1; + break; + } case LUA_TFUNCTION: // It's a function (a Lua function or a C function? either way!) lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION); I_Assert(lua_istable(L, -1)); @@ -351,9 +879,8 @@ static int state_get(lua_State *L) return 0; // Just what is this?? // get the function from the global // because the metatable will trigger. - lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a new C closure if not. - lua_pushstring(L, name); // push the name we found. - return 2; // return both the function and its name, in case somebody wanted to do a comparison by name or something? + lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a META_ACTION userdata if not. + return 1; // return just the function } else if (fastcmp(field,"var1")) number = st->var1; else if (fastcmp(field,"var2")) @@ -397,6 +924,18 @@ static int state_set(lua_State *L) case LUA_TSTRING: // It's a string, expect the name of a built-in action LUA_SetActionByName(st, lua_tostring(L, 3)); break; + case LUA_TUSERDATA: // It's a userdata, expect META_ACTION of a built-in action + { + actionf_t *action = *((actionf_t **)luaL_checkudata(L, 3, META_ACTION)); + + if (!action) + return luaL_error(L, "not a valid action?"); + + st->action = *action; + st->action.acv = action->acv; + st->action.acp1 = action->acp1; + break; + } case LUA_TFUNCTION: // It's a function (a Lua function or a C function? either way!) lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION); I_Assert(lua_istable(L, -1)); @@ -731,8 +1270,8 @@ static int lib_getSfxInfo(lua_State *L) lua_remove(L, 1); i = luaL_checkinteger(L, 1); - if (i >= NUMSFX) - return luaL_error(L, "sfxinfo[] index %d out of range (0 - %d)", i, NUMSFX-1); + if (i == 0 || i >= NUMSFX) + return luaL_error(L, "sfxinfo[] index %d out of range (1 - %d)", i, NUMSFX-1); LUA_PushUserdata(L, &S_sfx[i], META_SFXINFO); return 1; } @@ -745,13 +1284,13 @@ static int lib_setSfxInfo(lua_State *L) lua_remove(L, 1); { UINT32 i = luaL_checkinteger(L, 1); - if (i >= NUMSFX) - return luaL_error(L, "sfxinfo[] index %d out of range (0 - %d)", i, NUMSFX-1); - info = &S_sfx[i]; // get the mobjinfo to assign to. + if (i == 0 || i >= NUMSFX) + return luaL_error(L, "sfxinfo[] index %d out of range (1 - %d)", i, NUMSFX-1); + info = &S_sfx[i]; // get the sfxinfo to assign to. } luaL_checktype(L, 2, LUA_TTABLE); // check that we've been passed a table. - lua_remove(L, 1); // pop mobjtype num, don't need it any more. - lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the mobjinfo. + lua_remove(L, 1); // pop sfx num, don't need it any more. + lua_settop(L, 1); // cut the stack here. the only thing left now is the table of data we're assigning to the sfx. if (hud_running) return luaL_error(L, "Do not alter sfxinfo in HUD rendering code!"); @@ -776,6 +1315,9 @@ static int lib_setSfxInfo(lua_State *L) case sfxinfow_flags: info->pitch = (INT32)luaL_checkinteger(L, 3); break; + case sfxinfow_caption: + strlcpy(info->caption, luaL_checkstring(L, 3), sizeof(info->caption)); + break; default: break; } @@ -813,11 +1355,14 @@ static int sfxinfo_get(lua_State *L) case sfxinfor_flags: lua_pushinteger(L, sfx->pitch); return 1; + case sfxinfor_caption: + lua_pushstring(L, sfx->caption); + return 1; case sfxinfor_skinsound: lua_pushinteger(L, sfx->skinsound); return 1; default: - return luaL_error(L, "impossible error"); + return luaL_error(L, "Field does not exist in sfxinfo_t"); } return 0; } @@ -848,8 +1393,11 @@ static int sfxinfo_set(lua_State *L) case sfxinfow_flags: sfx->pitch = luaL_checkinteger(L, 1); break; + case sfxinfow_caption: + strlcpy(sfx->caption, luaL_checkstring(L, 1), sizeof(sfx->caption)); + break; default: - return luaL_error(L, "impossible error"); + return luaL_error(L, "Field does not exist in sfxinfo_t"); } return 0; } @@ -865,6 +1413,61 @@ static int sfxinfo_num(lua_State *L) return 1; } +////////////// +// LUABANKS // +////////////// + +static int lib_getluabanks(lua_State *L) +{ + UINT8 i; + + lua_remove(L, 1); // don't care about luabanks[] dummy userdata. + + if (lua_isnumber(L, 1)) + i = lua_tonumber(L, 1); + else + return luaL_error(L, "luabanks[] invalid index"); + + if (i >= NUM_LUABANKS) + luaL_error(L, "luabanks[] index %d out of range (%d - %d)", i, 0, NUM_LUABANKS-1); + + lua_pushinteger(L, luabanks[i]); + return 1; +} + +static int lib_setluabanks(lua_State *L) +{ + UINT8 i; + INT32 j = 0; + + if (hud_running) + return luaL_error(L, "Do not alter luabanks[] in HUD rendering code!"); + + lua_remove(L, 1); // don't care about luabanks[] dummy userdata. + + if (lua_isnumber(L, 1)) + i = lua_tonumber(L, 1); + else + return luaL_error(L, "luabanks[] invalid index"); + + if (i >= NUM_LUABANKS) + luaL_error(L, "luabanks[] index %d out of range (%d - %d)", i, 0, NUM_LUABANKS-1); + + if (lua_isnumber(L, 2)) + j = lua_tonumber(L, 2); + else + return luaL_error(L, "luabanks[] invalid set"); + + luabanks[i] = j; + return 0; +} + +static int lib_luabankslen(lua_State *L) +{ + lua_pushinteger(L, NUM_LUABANKS); + return 1; +} + ////////////////////////////// // // Now push all these functions into the Lua state! @@ -913,6 +1516,39 @@ int LUA_InfoLib(lua_State *L) lua_setfield(L, -2, "__len"); lua_pop(L, 1); + luaL_newmetatable(L, META_SPRITEINFO); + lua_pushcfunction(L, spriteinfo_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, spriteinfo_set); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, spriteinfo_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_PIVOTLIST); + lua_pushcfunction(L, pivotlist_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, pivotlist_set); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, pivotlist_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_FRAMEPIVOT); + lua_pushcfunction(L, framepivot_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, framepivot_set); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, framepivot_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getSprname); @@ -923,6 +1559,29 @@ int LUA_InfoLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "sprnames"); + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getSpr2name); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_spr2namelen); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "spr2names"); + + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getSpr2default); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setSpr2default); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_spr2namelen); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "spr2defaults"); + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getState); @@ -963,7 +1622,31 @@ int LUA_InfoLib(lua_State *L) lua_pushvalue(L, -1); lua_setglobal(L, "S_sfx"); lua_setglobal(L, "sfxinfo"); + + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getSpriteInfo); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setSpriteInfo); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_spriteinfolen); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_pushvalue(L, -1); + lua_setglobal(L, "spriteinfo"); + + luaL_newmetatable(L, META_LUABANKS); + lua_pushcfunction(L, lib_getluabanks); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_setluabanks); + lua_setfield(L, -2, "__newindex"); + + lua_pushcfunction(L, lib_luabankslen); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + return 0; } - -#endif diff --git a/src/lua_libs.h b/src/lua_libs.h index 9c6050bea..bf1e28b5d 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -10,8 +10,6 @@ /// \file lua_libs.h /// \brief libraries for Lua scripting -#ifdef HAVE_BLUA - extern lua_State *gL; #define LREG_VALID "VALID_USERDATA" @@ -22,6 +20,9 @@ extern lua_State *gL; #define META_STATE "STATE_T*" #define META_MOBJINFO "MOBJINFO_T*" #define META_SFXINFO "SFXINFO_T*" +#define META_SPRITEINFO "SPRITEINFO_T*" +#define META_PIVOTLIST "SPRITEFRAMEPIVOT_T[]" +#define META_FRAMEPIVOT "SPRITEFRAMEPIVOT_T*" #define META_MOBJ "MOBJ_T*" #define META_MAPTHING "MAPTHING_T*" @@ -38,6 +39,10 @@ extern lua_State *gL; #define META_SUBSECTOR "SUBSECTOR_T*" #define META_SECTOR "SECTOR_T*" #define META_FFLOOR "FFLOOR_T*" +#ifdef HAVE_LUA_SEGS +#define META_SEG "SEG_T*" +#define META_NODE "NODE_T*" +#endif #ifdef ESLOPE #define META_SLOPE "PSLOPE_T*" #define META_VECTOR2 "VECTOR2_T" @@ -49,12 +54,22 @@ extern lua_State *gL; #define META_SECTORLINES "SECTOR_T*LINES" #define META_SIDENUM "LINE_T*SIDENUM" +#ifdef HAVE_LUA_SEGS +#define META_NODEBBOX "NODE_T*BBOX" +#define META_NODECHILDREN "NODE_T*CHILDREN" +#endif + +#define META_BBOX "BOUNDING_BOX" #define META_HUDINFO "HUDINFO_T*" #define META_PATCH "PATCH_T*" #define META_COLORMAP "COLORMAP" #define META_CAMERA "CAMERA_T*" +#define META_ACTION "ACTIONF_T*" + +#define META_LUABANKS "LUABANKS[]*" + boolean luaL_checkboolean(lua_State *L, int narg); int LUA_EnumLib(lua_State *L); @@ -71,5 +86,3 @@ int LUA_ThinkerLib(lua_State *L); int LUA_MapLib(lua_State *L); int LUA_BlockmapLib(lua_State *L); int LUA_HudLib(lua_State *L); - -#endif diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 1f2414ba5..32150a4bc 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,7 +11,6 @@ /// \brief game map library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "r_state.h" #include "p_local.h" #include "p_setup.h" @@ -134,6 +133,7 @@ enum side_e { side_toptexture, side_bottomtexture, side_midtexture, + side_line, side_sector, side_special, side_repeatcnt, @@ -157,14 +157,20 @@ enum vertex_e { vertex_valid = 0, vertex_x, vertex_y, - vertex_z + vertex_floorz, + vertex_floorzset, + vertex_ceilingz, + vertex_ceilingzset }; static const char *const vertex_opt[] = { "valid", "x", "y", - "z", + "floorz", + "floorzset", + "ceilingz", + "ceilingzset", NULL}; enum ffloor_e { @@ -207,6 +213,82 @@ static const char *const ffloor_opt[] = { "alpha", NULL}; +#ifdef HAVE_LUA_SEGS +enum seg_e { + seg_valid = 0, + seg_v1, + seg_v2, + seg_side, + seg_offset, + seg_angle, + seg_sidedef, + seg_linedef, + seg_frontsector, + seg_backsector, +}; + +static const char *const seg_opt[] = { + "valid", + "v1", + "v2", + "side", + "offset", + "angle", + "sidedef", + "linedef", + "frontsector", + "backsector", + NULL}; + +enum node_e { + node_valid = 0, + node_x, + node_y, + node_dx, + node_dy, + node_bbox, + node_children, +}; + +static const char *const node_opt[] = { + "valid", + "x", + "y", + "dx", + "dy", + "bbox", + "children", + NULL}; + +enum nodechild_e { + nodechild_valid = 0, + nodechild_right, + nodechild_left, +}; + +static const char *const nodechild_opt[] = { + "valid", + "right", + "left", + NULL}; +#endif + +enum bbox_e { + bbox_valid = 0, + bbox_top, + bbox_bottom, + bbox_left, + bbox_right, +}; + +static const char *const bbox_opt[] = { + "valid", + "top", + "bottom", + "left", + "right", + NULL}; + #ifdef ESLOPE enum slope_e { slope_valid = 0, @@ -216,8 +298,6 @@ enum slope_e { slope_normal, slope_zangle, slope_xydirection, - slope_sourceline, - slope_refpos, slope_flags }; @@ -229,8 +309,6 @@ static const char *const slope_opt[] = { "normal", "zangle", "xydirection", - "sourceline", - "refpos", "flags", NULL}; @@ -251,12 +329,18 @@ static const char *const vector_opt[] = { static const char *const array_opt[] ={"iterate",NULL}; static const char *const valid_opt[] ={"valid",NULL}; +/////////////////////////////////// +// sector list iterate functions // +/////////////////////////////////// + // iterates through a sector's thinglist! static int lib_iterateSectorThinglist(lua_State *L) { mobj_t *state = NULL; mobj_t *thing = NULL; + INLEVEL + if (lua_gettop(L) < 2) return luaL_error(L, "Don't call sector.thinglist() directly, use it as 'for rover in sector.thinglist do end'."); @@ -290,6 +374,8 @@ static int lib_iterateSectorFFloors(lua_State *L) ffloor_t *state = NULL; ffloor_t *ffloor = NULL; + INLEVEL + if (lua_gettop(L) < 2) return luaL_error(L, "Don't call sector.ffloors() directly, use it as 'for rover in sector.ffloors do end'."); @@ -325,39 +411,59 @@ static int sector_iterate(lua_State *L) return 3; } +//////////////////// +// sector.lines[] // +//////////////////// + // sector.lines, i -> sector.lines[i] // sector.lines.valid, for validity checking +// +// 25/9/19 Monster Iestyn +// Modified this and _num to use triple pointers, to allow for a new hack of mine involving offsetof +// this way we don't need to check frontsector or backsector of line #0 in the array +// static int sectorlines_get(lua_State *L) { - line_t **seclines = *((line_t ***)luaL_checkudata(L, 1, META_SECTORLINES)); + line_t ***seclines = *((line_t ****)luaL_checkudata(L, 1, META_SECTORLINES)); size_t i; size_t numoflines = 0; lua_settop(L, 2); if (!lua_isnumber(L, 2)) { int field = luaL_checkoption(L, 2, NULL, valid_opt); - if (!seclines) + if (!seclines || !(*seclines)) { if (field == 0) { lua_pushboolean(L, 0); return 1; } - return luaL_error(L, "accessed sector_t doesn't exist anymore."); + return luaL_error(L, "accessed sector_t.lines doesn't exist anymore."); } else if (field == 0) { lua_pushboolean(L, 1); return 1; } } +/* a snip from sector_t struct in r_defs.h, for reference + size_t linecount; + struct line_s **lines; // [linecount] size +*/ + // get the "linecount" by shifting our retrieved memory address of "lines" to where "linecount" is in the sector_t, then dereferencing the result + // we need this to determine the array's actual size, and therefore also the maximum value allowed as an index + // this only works if seclines is actually a pointer to a sector's lines member in memory, oh boy + numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount)))); + +/* OLD HACK // check first linedef to figure which of its sectors owns this sector->lines pointer // then check that sector's linecount to get a maximum index - //if (!seclines[0]) + //if (!(*seclines)[0]) //return luaL_error(L, "no lines found!"); // no first linedef????? - if (seclines[0]->frontsector->lines == seclines) - numoflines = seclines[0]->frontsector->linecount; - else if (seclines[0]->backsector && seclines[0]->backsector->lines == seclines) // check backsector exists first - numoflines = seclines[0]->backsector->linecount; + if ((*seclines)[0]->frontsector->lines == *seclines) + numoflines = (*seclines)[0]->frontsector->linecount; + else if ((*seclines)[0]->backsector && *seclines[0]->backsector->lines == *seclines) // check backsector exists first + numoflines = (*seclines)[0]->backsector->linecount; //if neither sector has it then ??? +*/ if (!numoflines) return luaL_error(L, "no lines found!"); @@ -365,27 +471,29 @@ static int sectorlines_get(lua_State *L) i = (size_t)lua_tointeger(L, 2); if (i >= numoflines) return 0; - LUA_PushUserdata(L, seclines[i], META_LINE); + LUA_PushUserdata(L, (*seclines)[i], META_LINE); return 1; } +// #(sector.lines) -> sector.linecount static int sectorlines_num(lua_State *L) { - line_t **seclines = *((line_t ***)luaL_checkudata(L, 1, META_SECTORLINES)); + line_t ***seclines = *((line_t ****)luaL_checkudata(L, 1, META_SECTORLINES)); size_t numoflines = 0; - // check first linedef to figure which of its sectors owns this sector->lines pointer - // then check that sector's linecount to get a maximum index - //if (!seclines[0]) - //return luaL_error(L, "no lines found!"); // no first linedef????? - if (seclines[0]->frontsector->lines == seclines) - numoflines = seclines[0]->frontsector->linecount; - else if (seclines[0]->backsector && seclines[0]->backsector->lines == seclines) // check backsector exists first - numoflines = seclines[0]->backsector->linecount; - //if neither sector has it then ??? + + if (!seclines || !(*seclines)) + return luaL_error(L, "accessed sector_t.lines doesn't exist anymore."); + + // see comments in the _get function above + numoflines = (size_t)(*(size_t *)(((size_t)seclines) - (offsetof(sector_t, lines) - offsetof(sector_t, linecount)))); lua_pushinteger(L, numoflines); return 1; } +////////////// +// sector_t // +////////////// + static int sector_get(lua_State *L) { sector_t *sector = *((sector_t **)luaL_checkudata(L, 1, META_SECTOR)); @@ -455,7 +563,7 @@ static int sector_get(lua_State *L) LUA_PushUserdata(L, §ors[sector->camsec], META_SECTOR); return 1; case sector_lines: // lines - LUA_PushUserdata(L, sector->lines, META_SECTORLINES); + LUA_PushUserdata(L, §or->lines, META_SECTORLINES); // push the address of the "lines" member in the struct, to allow our hacks in sectorlines_get/_num to work return 1; case sector_ffloors: // ffloors lua_pushcfunction(L, lib_iterateSectorFFloors); @@ -491,6 +599,7 @@ static int sector_set(lua_State *L) case sector_thinglist: // thinglist case sector_heightsec: // heightsec case sector_camsec: // camsec + case sector_lines: // lines case sector_ffloors: // ffloors #ifdef ESLOPE case sector_fslope: // f_slope @@ -552,6 +661,10 @@ static int sector_num(lua_State *L) return 1; } +///////////////// +// subsector_t // +///////////////// + static int subsector_get(lua_State *L) { subsector_t *subsector = *((subsector_t **)luaL_checkudata(L, 1, META_SUBSECTOR)); @@ -591,6 +704,10 @@ static int subsector_num(lua_State *L) return 1; } +//////////// +// line_t // +//////////// + static int line_get(lua_State *L) { line_t *line = *((line_t **)luaL_checkudata(L, 1, META_LINE)); @@ -688,6 +805,10 @@ static int line_num(lua_State *L) return 1; } +//////////////////// +// line.sidenum[] // +//////////////////// + static int sidenum_get(lua_State *L) { UINT16 *sidenum = *((UINT16 **)luaL_checkudata(L, 1, META_SIDENUM)); @@ -716,6 +837,10 @@ static int sidenum_get(lua_State *L) return 1; } +//////////// +// side_t // +//////////// + static int side_get(lua_State *L) { side_t *side = *((side_t **)luaL_checkudata(L, 1, META_SIDE)); @@ -750,6 +875,9 @@ static int side_get(lua_State *L) case side_midtexture: lua_pushinteger(L, side->midtexture); return 1; + case side_line: + LUA_PushUserdata(L, side->line, META_LINE); + return 1; case side_sector: LUA_PushUserdata(L, side->sector, META_SECTOR); return 1; @@ -783,6 +911,7 @@ static int side_set(lua_State *L) switch(field) { case side_valid: // valid + case side_line: case side_sector: case side_special: case side_text: @@ -817,6 +946,10 @@ static int side_num(lua_State *L) return 1; } +////////////// +// vertex_t // +////////////// + static int vertex_get(lua_State *L) { vertex_t *vertex = *((vertex_t **)luaL_checkudata(L, 1, META_VERTEX)); @@ -842,8 +975,17 @@ static int vertex_get(lua_State *L) case vertex_y: lua_pushfixed(L, vertex->y); return 1; - case vertex_z: - lua_pushfixed(L, vertex->z); + case vertex_floorzset: + lua_pushboolean(L, vertex->floorzset); + return 1; + case vertex_ceilingzset: + lua_pushboolean(L, vertex->ceilingzset); + return 1; + case vertex_floorz: + lua_pushfixed(L, vertex->floorz); + return 1; + case vertex_ceilingz: + lua_pushfixed(L, vertex->ceilingz); return 1; } return 0; @@ -856,9 +998,292 @@ static int vertex_num(lua_State *L) return 1; } +#ifdef HAVE_LUA_SEGS + +/////////// +// seg_t // +/////////// + +static int seg_get(lua_State *L) +{ + seg_t *seg = *((seg_t **)luaL_checkudata(L, 1, META_SEG)); + enum seg_e field = luaL_checkoption(L, 2, seg_opt[0], seg_opt); + + if (!seg) + { + if (field == seg_valid) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed seg_t doesn't exist anymore."); + } + + switch(field) + { + case seg_valid: // valid + lua_pushboolean(L, 1); + return 1; + case seg_v1: + LUA_PushUserdata(L, seg->v1, META_VERTEX); + return 1; + case seg_v2: + LUA_PushUserdata(L, seg->v2, META_VERTEX); + return 1; + case seg_side: + lua_pushinteger(L, seg->side); + return 1; + case seg_offset: + lua_pushfixed(L, seg->offset); + return 1; + case seg_angle: + lua_pushangle(L, seg->angle); + return 1; + case seg_sidedef: + LUA_PushUserdata(L, seg->sidedef, META_SIDE); + return 1; + case seg_linedef: + LUA_PushUserdata(L, seg->linedef, META_LINE); + return 1; + case seg_frontsector: + LUA_PushUserdata(L, seg->frontsector, META_SECTOR); + return 1; + case seg_backsector: + LUA_PushUserdata(L, seg->backsector, META_SECTOR); + return 1; + } + return 0; +} + +static int seg_num(lua_State *L) +{ + seg_t *seg = *((seg_t **)luaL_checkudata(L, 1, META_SEG)); + lua_pushinteger(L, seg-segs); + return 1; +} + +//////////// +// node_t // +//////////// + +static int node_get(lua_State *L) +{ + node_t *node = *((node_t **)luaL_checkudata(L, 1, META_NODE)); + enum node_e field = luaL_checkoption(L, 2, node_opt[0], node_opt); + + if (!node) + { + if (field == node_valid) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed node_t doesn't exist anymore."); + } + + switch(field) + { + case node_valid: // valid + lua_pushboolean(L, 1); + return 1; + case node_x: + lua_pushfixed(L, node->x); + return 1; + case node_y: + lua_pushfixed(L, node->y); + return 1; + case node_dx: + lua_pushfixed(L, node->x); + return 1; + case node_dy: + lua_pushfixed(L, node->x); + return 1; + case node_bbox: + LUA_PushUserdata(L, node->bbox, META_NODEBBOX); + return 1; + case node_children: + LUA_PushUserdata(L, node->children, META_NODECHILDREN); + return 1; + } + return 0; +} + +static int node_num(lua_State *L) +{ + node_t *node = *((node_t **)luaL_checkudata(L, 1, META_NODE)); + lua_pushinteger(L, node-nodes); + return 1; +} + +/////////////// +// node.bbox // +/////////////// + +/* +// node.bbox[i][j]: i = 0 or 1, j = 0 1 2 or 3 +// NOTE: 2D arrays are NOT double pointers, +// the second bbox will be directly after the first in memory (hence the way the bbox is pushed here) +// this function handles the [i] part, bbox_get handles the [j] part +static int nodebbox_get(lua_State *L) +{ + fixed_t *bbox = *((fixed_t **)luaL_checkudata(L, 1, META_NODEBBOX)); + int i; + lua_settop(L, 2); + if (!lua_isnumber(L, 2)) + { + int field = luaL_checkoption(L, 2, NULL, valid_opt); + if (!bbox) + { + if (field == 0) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed node_t doesn't exist anymore."); + } else if (field == 0) { + lua_pushboolean(L, 1); + return 1; + } + } + + i = lua_tointeger(L, 2); + if (i < 0 || i > 1) + return 0; + LUA_PushUserdata(L, bbox + i*4*sizeof(fixed_t), META_BBOX); + return 1; +} +*/ +static int nodebbox_call(lua_State *L) +{ + fixed_t *bbox = *((fixed_t **)luaL_checkudata(L, 1, META_NODEBBOX)); + int i, j; + int n = lua_gettop(L); + + if (!bbox) + return luaL_error(L, "accessed node bbox doesn't exist anymore."); + if (n < 3) + return luaL_error(L, "arguments 2 and/or 3 not given (expected node.bbox(child, coord))"); + // get child + if (!lua_isnumber(L, 2)) { + enum nodechild_e field = luaL_checkoption(L, 2, nodechild_opt[0], nodechild_opt); + switch (field) { + case nodechild_right: i = 0; break; + case nodechild_left: i = 1; break; + default: + return luaL_error(L, "invalid node child \"%s\".", lua_tostring(L, 2)); + } + } + else { + i = lua_tointeger(L, 2); + if (i < 0 || i > 1) + return 0; + } + // get bbox coord + if (!lua_isnumber(L, 3)) { + enum bbox_e field = luaL_checkoption(L, 3, bbox_opt[0], bbox_opt); + switch (field) { + case bbox_top: j = BOXTOP; break; + case bbox_bottom: j = BOXBOTTOM; break; + case bbox_left: j = BOXLEFT; break; + case bbox_right: j = BOXRIGHT; break; + default: + return luaL_error(L, "invalid bbox coordinate \"%s\".", lua_tostring(L, 3)); + } + } + else { + j = lua_tointeger(L, 3); + if (j < 0 || j > 3) + return 0; + } + lua_pushinteger(L, bbox[i*4 + j]); + return 1; +} + +///////////////////// +// node.children[] // +///////////////////// + +// node.children[i]: i = 0 or 1 +static int nodechildren_get(lua_State *L) +{ + UINT16 *children = *((UINT16 **)luaL_checkudata(L, 1, META_NODECHILDREN)); + int i; + lua_settop(L, 2); + if (!lua_isnumber(L, 2)) + { + enum nodechild_e field = luaL_checkoption(L, 2, nodechild_opt[0], nodechild_opt); + if (!children) + { + if (field == nodechild_valid) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed node_t doesn't exist anymore."); + } else if (field == nodechild_valid) { + lua_pushboolean(L, 1); + return 1; + } else switch (field) { + case nodechild_right: i = 0; break; + case nodechild_left: i = 1; break; + default: return 0; + } + } + else { + i = lua_tointeger(L, 2); + if (i < 0 || i > 1) + return 0; + } + lua_pushinteger(L, children[i]); + return 1; +} +#endif + +////////// +// bbox // +////////// + +// bounding box (aka fixed_t array with four elements) +// NOTE: may be useful for polyobjects or other things later +static int bbox_get(lua_State *L) +{ + fixed_t *bbox = *((fixed_t **)luaL_checkudata(L, 1, META_BBOX)); + int i; + lua_settop(L, 2); + if (!lua_isnumber(L, 2)) + { + enum bbox_e field = luaL_checkoption(L, 2, bbox_opt[0], bbox_opt); + if (!bbox) + { + if (field == bbox_valid) { + lua_pushboolean(L, 0); + return 1; + } + return luaL_error(L, "accessed bbox doesn't exist anymore."); + } else if (field == bbox_valid) { + lua_pushboolean(L, 1); + return 1; + } else switch (field) { + case bbox_top: i = BOXTOP; break; + case bbox_bottom: i = BOXBOTTOM; break; + case bbox_left: i = BOXLEFT; break; + case bbox_right: i = BOXRIGHT; break; + default: return 0; + } + } + else { + i = lua_tointeger(L, 2); + if (i < 0 || i > 3) + return 0; + } + lua_pushinteger(L, bbox[i]); + return 1; +} + +/////////////// +// sectors[] // +/////////////// + static int lib_iterateSectors(lua_State *L) { size_t i = 0; + INLEVEL if (lua_gettop(L) < 2) return luaL_error(L, "Don't call sectors.iterate() directly, use it as 'for sector in sectors.iterate do end'."); lua_settop(L, 2); @@ -876,6 +1301,7 @@ static int lib_iterateSectors(lua_State *L) static int lib_getSector(lua_State *L) { int field; + INLEVEL lua_settop(L, 2); lua_remove(L, 1); // dummy userdata table is unused. if (lua_isnumber(L, 1)) @@ -902,9 +1328,14 @@ static int lib_numsectors(lua_State *L) return 1; } +////////////////// +// subsectors[] // +////////////////// + static int lib_iterateSubsectors(lua_State *L) { size_t i = 0; + INLEVEL if (lua_gettop(L) < 2) return luaL_error(L, "Don't call subsectors.iterate() directly, use it as 'for subsector in subsectors.iterate do end'."); lua_settop(L, 2); @@ -922,6 +1353,7 @@ static int lib_iterateSubsectors(lua_State *L) static int lib_getSubsector(lua_State *L) { int field; + INLEVEL lua_settop(L, 2); lua_remove(L, 1); // dummy userdata table is unused. if (lua_isnumber(L, 1)) @@ -948,9 +1380,14 @@ static int lib_numsubsectors(lua_State *L) return 1; } +///////////// +// lines[] // +///////////// + static int lib_iterateLines(lua_State *L) { size_t i = 0; + INLEVEL if (lua_gettop(L) < 2) return luaL_error(L, "Don't call lines.iterate() directly, use it as 'for line in lines.iterate do end'."); lua_settop(L, 2); @@ -968,6 +1405,7 @@ static int lib_iterateLines(lua_State *L) static int lib_getLine(lua_State *L) { int field; + INLEVEL lua_settop(L, 2); lua_remove(L, 1); // dummy userdata table is unused. if (lua_isnumber(L, 1)) @@ -994,9 +1432,14 @@ static int lib_numlines(lua_State *L) return 1; } +///////////// +// sides[] // +///////////// + static int lib_iterateSides(lua_State *L) { size_t i = 0; + INLEVEL if (lua_gettop(L) < 2) return luaL_error(L, "Don't call sides.iterate() directly, use it as 'for side in sides.iterate do end'."); lua_settop(L, 2); @@ -1014,6 +1457,7 @@ static int lib_iterateSides(lua_State *L) static int lib_getSide(lua_State *L) { int field; + INLEVEL lua_settop(L, 2); lua_remove(L, 1); // dummy userdata table is unused. if (lua_isnumber(L, 1)) @@ -1040,9 +1484,14 @@ static int lib_numsides(lua_State *L) return 1; } +//////////////// +// vertexes[] // +//////////////// + static int lib_iterateVertexes(lua_State *L) { size_t i = 0; + INLEVEL if (lua_gettop(L) < 2) return luaL_error(L, "Don't call vertexes.iterate() directly, use it as 'for vertex in vertexes.iterate do end'."); lua_settop(L, 2); @@ -1060,6 +1509,7 @@ static int lib_iterateVertexes(lua_State *L) static int lib_getVertex(lua_State *L) { int field; + INLEVEL lua_settop(L, 2); lua_remove(L, 1); // dummy userdata table is unused. if (lua_isnumber(L, 1)) @@ -1086,6 +1536,117 @@ static int lib_numvertexes(lua_State *L) return 1; } +#ifdef HAVE_LUA_SEGS + +//////////// +// segs[] // +//////////// + +static int lib_iterateSegs(lua_State *L) +{ + size_t i = 0; + INLEVEL + if (lua_gettop(L) < 2) + return luaL_error(L, "Don't call segs.iterate() directly, use it as 'for seg in segs.iterate do end'."); + lua_settop(L, 2); + lua_remove(L, 1); // state is unused. + if (!lua_isnil(L, 1)) + i = (size_t)(*((seg_t **)luaL_checkudata(L, 1, META_SEG)) - segs)+1; + if (i < numsegs) + { + LUA_PushUserdata(L, &segs[i], META_SEG); + return 1; + } + return 0; +} + +static int lib_getSeg(lua_State *L) +{ + int field; + INLEVEL + lua_settop(L, 2); + lua_remove(L, 1); // dummy userdata table is unused. + if (lua_isnumber(L, 1)) + { + size_t i = lua_tointeger(L, 1); + if (i >= numsegs) + return 0; + LUA_PushUserdata(L, &segs[i], META_SEG); + return 1; + } + field = luaL_checkoption(L, 1, NULL, array_opt); + switch(field) + { + case 0: // iterate + lua_pushcfunction(L, lib_iterateSegs); + return 1; + } + return 0; +} + +static int lib_numsegs(lua_State *L) +{ + lua_pushinteger(L, numsegs); + return 1; +} + +///////////// +// nodes[] // +///////////// + +static int lib_iterateNodes(lua_State *L) +{ + size_t i = 0; + INLEVEL + if (lua_gettop(L) < 2) + return luaL_error(L, "Don't call nodes.iterate() directly, use it as 'for node in nodes.iterate do end'."); + lua_settop(L, 2); + lua_remove(L, 1); // state is unused. + if (!lua_isnil(L, 1)) + i = (size_t)(*((node_t **)luaL_checkudata(L, 1, META_NODE)) - nodes)+1; + if (i < numsegs) + { + LUA_PushUserdata(L, &nodes[i], META_NODE); + return 1; + } + return 0; +} + +static int lib_getNode(lua_State *L) +{ + int field; + INLEVEL + lua_settop(L, 2); + lua_remove(L, 1); // dummy userdata table is unused. + if (lua_isnumber(L, 1)) + { + size_t i = lua_tointeger(L, 1); + if (i >= numnodes) + return 0; + LUA_PushUserdata(L, &nodes[i], META_NODE); + return 1; + } + field = luaL_checkoption(L, 1, NULL, array_opt); + switch(field) + { + case 0: // iterate + lua_pushcfunction(L, lib_iterateNodes); + return 1; + } + return 0; +} + +static int lib_numnodes(lua_State *L) +{ + lua_pushinteger(L, numnodes); + return 1; +} +#endif + +////////////// +// ffloor_t // +////////////// + static int ffloor_get(lua_State *L) { ffloor_t *ffloor = *((ffloor_t **)luaL_checkudata(L, 1, META_FFLOOR)); @@ -1243,6 +1804,10 @@ static int ffloor_set(lua_State *L) } #ifdef ESLOPE +////////////// +// pslope_t // +////////////// + static int slope_get(lua_State *L) { pslope_t *slope = *((pslope_t **)luaL_checkudata(L, 1, META_SLOPE)); @@ -1280,12 +1845,6 @@ static int slope_get(lua_State *L) case slope_xydirection: // xydirection lua_pushangle(L, slope->xydirection); return 1; - case slope_sourceline: // source linedef - LUA_PushUserdata(L, slope->sourceline, META_LINE); - return 1; - case slope_refpos: // refpos - lua_pushinteger(L, slope->refpos); - return 1; case slope_flags: // flags lua_pushinteger(L, slope->flags); return 1; @@ -1307,11 +1866,9 @@ static int slope_set(lua_State *L) switch(field) // todo: reorganize this shit { case slope_valid: // valid - case slope_sourceline: // sourceline case slope_d: // d case slope_flags: // flags case slope_normal: // normal - case slope_refpos: // refpos default: return luaL_error(L, "pslope_t field " LUA_QS " cannot be set.", slope_opt[field]); case slope_o: { // o @@ -1379,6 +1936,10 @@ static int slope_set(lua_State *L) return 0; } +/////////////// +// vector*_t // +/////////////// + static int vector2_get(lua_State *L) { vector2_t *vec = *((vector2_t **)luaL_checkudata(L, 1, META_VECTOR2)); @@ -1417,6 +1978,10 @@ static int vector3_get(lua_State *L) } #endif +///////////////////// +// mapheaderinfo[] // +///////////////////// + static int lib_getMapheaderinfo(lua_State *L) { // i -> mapheaderinfo[i-1] @@ -1449,6 +2014,10 @@ static int lib_nummapheaders(lua_State *L) return 1; } +///////////////// +// mapheader_t // +///////////////// + static int mapheaderinfo_get(lua_State *L) { mapheader_t *header = *((mapheader_t **)luaL_checkudata(L, 1, META_MAPHEADER)); @@ -1464,10 +2033,28 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->typeoflevel); else if (fastcmp(field,"nextlevel")) lua_pushinteger(L, header->nextlevel); + else if (fastcmp(field,"keywords")) + lua_pushstring(L, header->keywords); else if (fastcmp(field,"musname")) lua_pushstring(L, header->musname); else if (fastcmp(field,"mustrack")) lua_pushinteger(L, header->mustrack); + else if (fastcmp(field,"muspos")) + lua_pushinteger(L, header->muspos); + else if (fastcmp(field,"musinterfadeout")) + lua_pushinteger(L, header->musinterfadeout); + else if (fastcmp(field,"musintername")) + lua_pushstring(L, header->musintername); + else if (fastcmp(field,"muspostbossname")) + lua_pushstring(L, header->muspostbossname); + else if (fastcmp(field,"muspostbosstrack")) + lua_pushinteger(L, header->muspostbosstrack); + else if (fastcmp(field,"muspostbosspos")) + lua_pushinteger(L, header->muspostbosspos); + else if (fastcmp(field,"muspostbossfadein")) + lua_pushinteger(L, header->muspostbossfadein); + else if (fastcmp(field,"musforcereset")) + lua_pushinteger(L, header->musforcereset); else if (fastcmp(field,"forcecharacter")) lua_pushstring(L, header->forcecharacter); else if (fastcmp(field,"weather")) @@ -1505,12 +2092,20 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->levelselect); else if (fastcmp(field,"bonustype")) lua_pushinteger(L, header->bonustype); - else if (fastcmp(field,"saveoverride")) - lua_pushinteger(L, header->saveoverride); + else if (fastcmp(field,"ltzzpatch")) + lua_pushstring(L, header->ltzzpatch); + else if (fastcmp(field,"ltzztext")) + lua_pushstring(L, header->ltzztext); + else if (fastcmp(field,"ltactdiamond")) + lua_pushstring(L, header->ltactdiamond); + else if (fastcmp(field,"maxbonuslives")) + lua_pushinteger(L, header->maxbonuslives); else if (fastcmp(field,"levelflags")) lua_pushinteger(L, header->levelflags); else if (fastcmp(field,"menuflags")) lua_pushinteger(L, header->menuflags); + else if (fastcmp(field,"startrings")) + lua_pushinteger(L, header->startrings); // TODO add support for reading numGradedMares and grades else { // Read custom vars now @@ -1595,6 +2190,41 @@ int LUA_MapLib(lua_State *L) lua_setfield(L, -2, "__newindex"); lua_pop(L, 1); +#ifdef HAVE_LUA_SEGS + luaL_newmetatable(L, META_SEG); + lua_pushcfunction(L, seg_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, seg_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_NODE); + lua_pushcfunction(L, node_get); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, node_num); + lua_setfield(L, -2, "__len"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_NODEBBOX); + //lua_pushcfunction(L, nodebbox_get); + //lua_setfield(L, -2, "__index"); + lua_pushcfunction(L, nodebbox_call); + lua_setfield(L, -2, "__call"); + lua_pop(L, 1); + + luaL_newmetatable(L, META_NODECHILDREN); + lua_pushcfunction(L, nodechildren_get); + lua_setfield(L, -2, "__index"); + lua_pop(L, 1); +#endif + + luaL_newmetatable(L, META_BBOX); + lua_pushcfunction(L, bbox_get); + lua_setfield(L, -2, "__index"); + lua_pop(L, 1); + #ifdef ESLOPE luaL_newmetatable(L, META_SLOPE); lua_pushcfunction(L, slope_get); @@ -1673,6 +2303,28 @@ int LUA_MapLib(lua_State *L) lua_setmetatable(L, -2); lua_setglobal(L, "vertexes"); +#ifdef HAVE_LUA_SEGS + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getSeg); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_numsegs); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "segs"); + + lua_newuserdata(L, 0); + lua_createtable(L, 0, 2); + lua_pushcfunction(L, lib_getNode); + lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_numnodes); + lua_setfield(L, -2, "__len"); + lua_setmetatable(L, -2); + lua_setglobal(L, "nodes"); +#endif + lua_newuserdata(L, 0); lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_getMapheaderinfo); @@ -1684,5 +2336,3 @@ int LUA_MapLib(lua_State *L) lua_setglobal(L, "mapheaderinfo"); return 0; } - -#endif diff --git a/src/lua_mathlib.c b/src/lua_mathlib.c index 6cc8c0077..215903278 100644 --- a/src/lua_mathlib.c +++ b/src/lua_mathlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,7 +11,6 @@ /// \brief basic math library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA //#include "fastcmp.h" #include "tables.h" #include "p_local.h" @@ -81,20 +80,9 @@ static int lib_finecosine(lua_State *L) static int lib_finetangent(lua_State *L) { - // 2.1.15 ONLY HACK: optional boolean argument, only add ANGLE_90 if true - boolean newtan = lua_optboolean(L, 2); - - if (newtan) - { - // HACK: add ANGLE_90 to make tan() in Lua start at 0 like it should - // use & 4095 instead of & FINEMASK (8191), so it doesn't go out of the array's bounds - lua_pushfixed(L, FINETANGENT(((luaL_checkangle(L, 1)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); - } - else - { - LUA_Deprecated(L, "tan(angle)", "tan(angle, true)"); - lua_pushfixed(L, FINETANGENT((luaL_checkangle(L, 1)>>ANGLETOFINESHIFT) & 4095)); - } + // HACK: add ANGLE_90 to make tan() in Lua start at 0 like it should + // use & 4095 instead of & FINEMASK (8191), so it doesn't go out of the array's bounds + lua_pushfixed(L, FINETANGENT(((luaL_checkangle(L, 1)+ANGLE_90)>>ANGLETOFINESHIFT) & 4095)); return 1; } @@ -184,15 +172,15 @@ static int lib_all7emeralds(lua_State *L) return 1; } -// Whee, special Lua-exclusive function for making use of Color_Opposite[] without needing *2 or +1 -// Returns both color and frame numbers! +// Whee, special Lua-exclusive function for making use of Color_Opposite[] +// Returns both color and signpost shade numbers! static int lib_coloropposite(lua_State *L) { UINT8 colornum = (UINT8)luaL_checkinteger(L, 1); - if (colornum >= MAXSKINCOLORS) - return luaL_error(L, "skincolor %d out of range (0 - %d).", colornum, MAXSKINCOLORS-1); - lua_pushinteger(L, Color_Opposite[colornum*2]); // push color - lua_pushinteger(L, Color_Opposite[colornum*2+1]); // push frame + if (!colornum || colornum >= MAXSKINCOLORS) + return luaL_error(L, "skincolor %d out of range (1 - %d).", colornum, MAXSKINCOLORS-1); + lua_pushinteger(L, Color_Opposite[colornum-1][0]); // push color + lua_pushinteger(L, Color_Opposite[colornum-1][1]); // push sign shade index, 0-15 return 2; } @@ -228,5 +216,3 @@ int LUA_MathLib(lua_State *L) luaL_register(L, NULL, lib); return 0; } - -#endif diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index aca501221..4b580a2fe 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,9 +11,8 @@ /// \brief mobj/thing library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" -#include "r_things.h" +#include "r_skins.h" #include "p_local.h" #include "g_game.h" #include "p_setup.h" @@ -32,13 +31,17 @@ enum mobj_e { mobj_snext, mobj_sprev, mobj_angle, + mobj_rollangle, mobj_sprite, mobj_frame, + mobj_sprite2, mobj_anim_duration, mobj_touching_sectorlist, mobj_subsector, mobj_floorz, mobj_ceilingz, + mobj_floorrover, + mobj_ceilingrover, mobj_radius, mobj_height, mobj_momx, @@ -80,12 +83,12 @@ enum mobj_e { mobj_extravalue1, mobj_extravalue2, mobj_cusval, -#ifdef ESLOPE mobj_cvmem, - mobj_standingslope -#else - mobj_cvmem +#ifdef ESLOPE + mobj_standingslope, #endif + mobj_colorized, + mobj_shadowscale }; static const char *const mobj_opt[] = { @@ -96,13 +99,17 @@ static const char *const mobj_opt[] = { "snext", "sprev", "angle", + "rollangle", "sprite", "frame", + "sprite2", "anim_duration", "touching_sectorlist", "subsector", "floorz", "ceilingz", + "floorrover", + "ceilingrover", "radius", "height", "momx", @@ -148,6 +155,8 @@ static const char *const mobj_opt[] = { #ifdef ESLOPE "standingslope", #endif + "colorized", + "shadowscale", NULL}; #define UNIMPLEMENTED luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", mobj_opt[field]) @@ -158,6 +167,8 @@ static int mobj_get(lua_State *L) enum mobj_e field = Lua_optoption(L, 2, NULL, mobj_opt); lua_settop(L, 2); + INLEVEL + if (!mo) { if (field == mobj_valid) { lua_pushboolean(L, 0); @@ -191,12 +202,18 @@ static int mobj_get(lua_State *L) case mobj_angle: lua_pushangle(L, mo->angle); break; + case mobj_rollangle: + lua_pushangle(L, mo->rollangle); + break; case mobj_sprite: lua_pushinteger(L, mo->sprite); break; case mobj_frame: lua_pushinteger(L, mo->frame); break; + case mobj_sprite2: + lua_pushinteger(L, mo->sprite2); + break; case mobj_anim_duration: lua_pushinteger(L, mo->anim_duration); break; @@ -211,6 +228,12 @@ static int mobj_get(lua_State *L) case mobj_ceilingz: lua_pushfixed(L, mo->ceilingz); break; + case mobj_floorrover: + LUA_PushUserdata(L, mo->floorrover, META_FFLOOR); + break; + case mobj_ceilingrover: + LUA_PushUserdata(L, mo->ceilingrover, META_FFLOOR); + break; case mobj_radius: lua_pushfixed(L, mo->radius); break; @@ -259,10 +282,19 @@ static int mobj_get(lua_State *L) // bprev -- same deal as sprev above, but for the blockmap. return UNIMPLEMENTED; case mobj_hnext: + if (mo->hnext && P_MobjWasRemoved(mo->hnext)) + { // don't put invalid mobj back into Lua. + P_SetTarget(&mo->hnext, NULL); + return 0; + } LUA_PushUserdata(L, mo->hnext, META_MOBJ); break; case mobj_hprev: - // implimented differently from sprev and bprev because SSNTails. + if (mo->hprev && P_MobjWasRemoved(mo->hprev)) + { // don't put invalid mobj back into Lua. + P_SetTarget(&mo->hprev, NULL); + return 0; + } LUA_PushUserdata(L, mo->hprev, META_MOBJ); break; case mobj_type: @@ -356,6 +388,12 @@ static int mobj_get(lua_State *L) LUA_PushUserdata(L, mo->standingslope, META_SLOPE); break; #endif + case mobj_colorized: + lua_pushboolean(L, mo->colorized); + break; + case mobj_shadowscale: + lua_pushfixed(L, mo->shadowscale); + break; default: // extra custom variables in Lua memory lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); @@ -382,6 +420,8 @@ static int mobj_set(lua_State *L) enum mobj_e field = Lua_optoption(L, 2, mobj_opt[0], mobj_opt); lua_settop(L, 3); + INLEVEL + if (!mo) return LUA_ErrInvalid(L, "mobj_t"); @@ -404,6 +444,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -418,12 +460,18 @@ static int mobj_set(lua_State *L) else if (mo->player == &players[secondarydisplayplayer]) localangle2 = mo->angle; break; + case mobj_rollangle: + mo->rollangle = luaL_checkangle(L, 3); + break; case mobj_sprite: mo->sprite = luaL_checkinteger(L, 3); break; case mobj_frame: mo->frame = (UINT32)luaL_checkinteger(L, 3); break; + case mobj_sprite2: + mo->sprite2 = P_GetSkinSprite2(((skin_t *)mo->skin), (UINT8)luaL_checkinteger(L, 3), mo->player); + break; case mobj_anim_duration: mo->anim_duration = (UINT16)luaL_checkinteger(L, 3); break; @@ -435,6 +483,10 @@ static int mobj_set(lua_State *L) return NOSETPOS; case mobj_ceilingz: return NOSETPOS; + case mobj_floorrover: + return NOSET; + case mobj_ceilingrover: + return NOSET; case mobj_radius: { mobj_t *ptmthing = tmthing; @@ -444,6 +496,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -456,6 +510,8 @@ static int mobj_set(lua_State *L) P_CheckPosition(mo, mo->x, mo->y); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; P_SetTarget(&tmthing, ptmthing); break; } @@ -516,7 +572,8 @@ static int mobj_set(lua_State *L) for (i = 0; i < numskins; i++) if (fastcmp(skins[i].name, skin)) { - mo->skin = &skins[i]; + if (!mo->player || R_SkinUsable(mo->player-players, i)) + mo->skin = &skins[i]; return 0; } return luaL_error(L, "mobj.skin '%s' not found!", skin); @@ -534,10 +591,22 @@ static int mobj_set(lua_State *L) case mobj_bprev: return UNIMPLEMENTED; case mobj_hnext: - mo->hnext = luaL_checkudata(L, 3, META_MOBJ); + if (lua_isnil(L, 3)) + P_SetTarget(&mo->hnext, NULL); + else + { + mobj_t *hnext = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&mo->hnext, hnext); + } break; case mobj_hprev: - mo->hprev = luaL_checkudata(L, 3, META_MOBJ); + if (lua_isnil(L, 3)) + P_SetTarget(&mo->hprev, NULL); + else + { + mobj_t *hprev = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&mo->hprev, hprev); + } break; case mobj_type: // yeah sure, we'll let you change the mobj's type. { @@ -651,6 +720,12 @@ static int mobj_set(lua_State *L) case mobj_standingslope: return NOSET; #endif + case mobj_colorized: + mo->colorized = luaL_checkboolean(L, 3); + break; + case mobj_shadowscale: + mo->shadowscale = luaL_checkfixed(L, 3); + break; default: lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); @@ -748,7 +823,12 @@ static int mapthing_set(lua_State *L) else if(fastcmp(field,"z")) mt->z = (INT16)luaL_checkinteger(L, 3); else if(fastcmp(field,"extrainfo")) - mt->extrainfo = (UINT8)luaL_checkinteger(L, 3); + { + INT32 extrainfo = luaL_checkinteger(L, 3); + if (extrainfo & ~15) + return luaL_error(L, "mapthing_t extrainfo set %d out of range (%d - %d)", extrainfo, 0, 15); + mt->extrainfo = (UINT8)extrainfo; + } else if(fastcmp(field,"mobj")) mt->mobj = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); else @@ -760,6 +840,7 @@ static int mapthing_set(lua_State *L) static int lib_iterateMapthings(lua_State *L) { size_t i = 0; + INLEVEL if (lua_gettop(L) < 2) return luaL_error(L, "Don't call mapthings.iterate() directly, use it as 'for mapthing in mapthings.iterate do end'."); lua_settop(L, 2); @@ -777,6 +858,7 @@ static int lib_iterateMapthings(lua_State *L) static int lib_getMapthing(lua_State *L) { int field; + INLEVEL lua_settop(L, 2); lua_remove(L, 1); // dummy userdata table is unused. if (lua_isnumber(L, 1)) @@ -832,5 +914,3 @@ int LUA_MobjLib(lua_State *L) lua_setglobal(L, "mapthings"); return 0; } - -#endif diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dd7439321..cdece1fb7 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,7 +11,6 @@ /// \brief player object library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "p_mobj.h" #include "d_player.h" @@ -97,6 +96,10 @@ static int player_get(lua_State *L) lua_pushboolean(L, true); else if (fastcmp(field,"name")) lua_pushstring(L, player_names[plr-players]); + else if (fastcmp(field,"realmo")) + LUA_PushUserdata(L, plr->mo, META_MOBJ); + // Kept for backward-compatibility + // Should be fixed to work like "realmo" later else if (fastcmp(field,"mo")) { if (plr->spectator) @@ -108,6 +111,10 @@ static int player_get(lua_State *L) LUA_PushUserdata(L, &plr->cmd, META_TICCMD); else if (fastcmp(field,"playerstate")) lua_pushinteger(L, plr->playerstate); + else if (fastcmp(field,"camerascale")) + lua_pushfixed(L, plr->camerascale); + else if (fastcmp(field,"shieldscale")) + lua_pushfixed(L, plr->shieldscale); else if (fastcmp(field,"viewz")) lua_pushfixed(L, plr->viewz); else if (fastcmp(field,"viewheight")) @@ -116,16 +123,28 @@ static int player_get(lua_State *L) lua_pushfixed(L, plr->deltaviewheight); else if (fastcmp(field,"bob")) lua_pushfixed(L, plr->bob); + else if (fastcmp(field,"viewrollangle")) + lua_pushangle(L, plr->viewrollangle); else if (fastcmp(field,"aiming")) lua_pushangle(L, plr->aiming); - else if (fastcmp(field,"health")) - lua_pushinteger(L, plr->health); + else if (fastcmp(field,"drawangle")) + lua_pushangle(L, plr->drawangle); + else if (fastcmp(field,"rings")) + lua_pushinteger(L, plr->rings); + else if (fastcmp(field,"spheres")) + lua_pushinteger(L, plr->spheres); else if (fastcmp(field,"pity")) lua_pushinteger(L, plr->pity); else if (fastcmp(field,"currentweapon")) lua_pushinteger(L, plr->currentweapon); else if (fastcmp(field,"ringweapons")) lua_pushinteger(L, plr->ringweapons); + else if (fastcmp(field,"ammoremoval")) + lua_pushinteger(L, plr->ammoremoval); + else if (fastcmp(field,"ammoremovaltimer")) + lua_pushinteger(L, plr->ammoremovaltimer); + else if (fastcmp(field,"ammoremovalweapon")) + lua_pushinteger(L, plr->ammoremovalweapon); else if (fastcmp(field,"powers")) LUA_PushUserdata(L, plr->powers, META_POWERS); else if (fastcmp(field,"pflags")) @@ -142,8 +161,6 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->score); else if (fastcmp(field,"dashspeed")) lua_pushfixed(L, plr->dashspeed); - else if (fastcmp(field,"dashtime")) - lua_pushinteger(L, plr->dashtime); else if (fastcmp(field,"normalspeed")) lua_pushfixed(L, plr->normalspeed); else if (fastcmp(field,"runspeed")) @@ -166,6 +183,10 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->spinitem); else if (fastcmp(field,"revitem")) lua_pushinteger(L, plr->revitem); + else if (fastcmp(field,"followitem")) + lua_pushinteger(L, plr->followitem); + else if (fastcmp(field,"followmobj")) + LUA_PushUserdata(L, plr->followmobj, META_MOBJ); else if (fastcmp(field,"actionspd")) lua_pushfixed(L, plr->actionspd); else if (fastcmp(field,"mindash")) @@ -174,6 +195,10 @@ static int player_get(lua_State *L) lua_pushfixed(L, plr->maxdash); else if (fastcmp(field,"jumpfactor")) lua_pushfixed(L, plr->jumpfactor); + else if (fastcmp(field,"height")) + lua_pushfixed(L, plr->height); + else if (fastcmp(field,"spinheight")) + lua_pushfixed(L, plr->spinheight); else if (fastcmp(field,"lives")) lua_pushinteger(L, plr->lives); else if (fastcmp(field,"continues")) @@ -184,8 +209,6 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->gotcontinue); else if (fastcmp(field,"speed")) lua_pushfixed(L, plr->speed); - else if (fastcmp(field,"jumping")) - lua_pushboolean(L, plr->jumping); else if (fastcmp(field,"secondjump")) lua_pushinteger(L, plr->secondjump); else if (fastcmp(field,"fly1")) @@ -202,6 +225,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->exiting); else if (fastcmp(field,"homing")) lua_pushinteger(L, plr->homing); + else if (fastcmp(field,"dashmode")) + lua_pushinteger(L, plr->dashmode); else if (fastcmp(field,"skidtime")) lua_pushinteger(L, plr->skidtime); else if (fastcmp(field,"cmomx")) @@ -240,6 +265,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->starposttime); else if (fastcmp(field,"starpostangle")) lua_pushangle(L, plr->starpostangle); + else if (fastcmp(field,"starpostscale")) + lua_pushfixed(L, plr->starpostscale); else if (fastcmp(field,"angle_pos")) lua_pushangle(L, plr->angle_pos); else if (fastcmp(field,"old_angle_pos")) @@ -270,22 +297,46 @@ static int player_get(lua_State *L) lua_pushboolean(L, plr->bonustime); else if (fastcmp(field,"capsule")) LUA_PushUserdata(L, plr->capsule, META_MOBJ); + else if (fastcmp(field,"drone")) + LUA_PushUserdata(L, plr->drone, META_MOBJ); + else if (fastcmp(field,"oldscale")) + lua_pushfixed(L, plr->oldscale); else if (fastcmp(field,"mare")) lua_pushinteger(L, plr->mare); + else if (fastcmp(field,"marelap")) + lua_pushinteger(L, plr->marelap); + else if (fastcmp(field,"marebonuslap")) + lua_pushinteger(L, plr->marebonuslap); else if (fastcmp(field,"marebegunat")) lua_pushinteger(L, plr->marebegunat); else if (fastcmp(field,"startedtime")) lua_pushinteger(L, plr->startedtime); else if (fastcmp(field,"finishedtime")) lua_pushinteger(L, plr->finishedtime); + else if (fastcmp(field,"lapbegunat")) + lua_pushinteger(L, plr->lapbegunat); + else if (fastcmp(field,"lapstartedtime")) + lua_pushinteger(L, plr->lapstartedtime); + else if (fastcmp(field,"finishedspheres")) + lua_pushinteger(L, plr->finishedspheres); else if (fastcmp(field,"finishedrings")) lua_pushinteger(L, plr->finishedrings); else if (fastcmp(field,"marescore")) lua_pushinteger(L, plr->marescore); else if (fastcmp(field,"lastmarescore")) lua_pushinteger(L, plr->lastmarescore); + else if (fastcmp(field,"totalmarescore")) + lua_pushinteger(L, plr->totalmarescore); else if (fastcmp(field,"lastmare")) lua_pushinteger(L, plr->lastmare); + else if (fastcmp(field,"lastmarelap")) + lua_pushinteger(L, plr->lastmarelap); + else if (fastcmp(field,"lastmarebonuslap")) + lua_pushinteger(L, plr->lastmarebonuslap); + else if (fastcmp(field,"totalmarelap")) + lua_pushinteger(L, plr->totalmarelap); + else if (fastcmp(field,"totalmarebonuslap")) + lua_pushinteger(L, plr->totalmarebonuslap); else if (fastcmp(field,"maxlink")) lua_pushinteger(L, plr->maxlink); else if (fastcmp(field,"texttimer")) @@ -310,10 +361,14 @@ static int player_get(lua_State *L) lua_pushangle(L, plr->awayviewaiming); else if (fastcmp(field,"spectator")) lua_pushboolean(L, plr->spectator); + else if (fastcmp(field,"outofcoop")) + lua_pushboolean(L, plr->outofcoop); else if (fastcmp(field,"bot")) lua_pushinteger(L, plr->bot); else if (fastcmp(field,"jointime")) lua_pushinteger(L, plr->jointime); + else if (fastcmp(field,"quittime")) + lua_pushinteger(L, plr->quittime); #ifdef HWRENDER else if (fastcmp(field,"fovadd")) lua_pushfixed(L, plr->fovadd); @@ -346,7 +401,7 @@ static int player_set(lua_State *L) if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); - if (fastcmp(field,"mo")) { + if (fastcmp(field,"mo") || fastcmp(field,"realmo")) { mobj_t *newmo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); plr->mo->player = NULL; // remove player pointer from old mobj (newmo->player = plr)->mo = newmo; // set player pointer for new mobj, and set new mobj as the player's mobj @@ -355,6 +410,10 @@ static int player_set(lua_State *L) return NOSET; else if (fastcmp(field,"playerstate")) plr->playerstate = luaL_checkinteger(L, 3); + else if (fastcmp(field,"camerascale")) + plr->camerascale = luaL_checkfixed(L, 3); + else if (fastcmp(field,"shieldscale")) + plr->shieldscale = luaL_checkfixed(L, 3); else if (fastcmp(field,"viewz")) plr->viewz = luaL_checkfixed(L, 3); else if (fastcmp(field,"viewheight")) @@ -363,6 +422,8 @@ static int player_set(lua_State *L) plr->deltaviewheight = luaL_checkfixed(L, 3); else if (fastcmp(field,"bob")) plr->bob = luaL_checkfixed(L, 3); + else if (fastcmp(field,"viewrollangle")) + plr->viewrollangle = luaL_checkangle(L, 3); else if (fastcmp(field,"aiming")) { plr->aiming = luaL_checkangle(L, 3); if (plr == &players[consoleplayer]) @@ -370,14 +431,24 @@ static int player_set(lua_State *L) else if (plr == &players[secondarydisplayplayer]) localaiming2 = plr->aiming; } - else if (fastcmp(field,"health")) - plr->health = (INT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"drawangle")) + plr->drawangle = luaL_checkangle(L, 3); + else if (fastcmp(field,"rings")) + plr->rings = (INT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"spheres")) + plr->spheres = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"pity")) plr->pity = (SINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"currentweapon")) plr->currentweapon = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"ringweapons")) plr->ringweapons = (INT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"ammoremoval")) + plr->ammoremoval = (UINT16)luaL_checkinteger(L, 3); + else if (fastcmp(field,"ammoremovaltimer")) + plr->ammoremovaltimer = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"ammoremovalweapon")) + plr->ammoremovalweapon = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"powers")) return NOSET; else if (fastcmp(field,"pflags")) @@ -399,8 +470,6 @@ static int player_set(lua_State *L) plr->score = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"dashspeed")) plr->dashspeed = luaL_checkfixed(L, 3); - else if (fastcmp(field,"dashtime")) - plr->dashtime = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"normalspeed")) plr->normalspeed = luaL_checkfixed(L, 3); else if (fastcmp(field,"runspeed")) @@ -423,6 +492,15 @@ static int player_set(lua_State *L) plr->spinitem = luaL_checkinteger(L, 3); else if (fastcmp(field,"revitem")) plr->revitem = luaL_checkinteger(L, 3); + else if (fastcmp(field,"followitem")) + plr->followitem = luaL_checkinteger(L, 3); + else if (fastcmp(field,"followmobj")) + { + mobj_t *mo = NULL; + if (!lua_isnil(L, 3)) + mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&plr->followmobj, mo); + } else if (fastcmp(field,"actionspd")) plr->actionspd = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"mindash")) @@ -431,6 +509,10 @@ static int player_set(lua_State *L) plr->maxdash = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"jumpfactor")) plr->jumpfactor = (INT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"height")) + plr->height = luaL_checkfixed(L, 3); + else if (fastcmp(field,"spinheight")) + plr->spinheight = luaL_checkfixed(L, 3); else if (fastcmp(field,"lives")) plr->lives = (SINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"continues")) @@ -441,8 +523,6 @@ static int player_set(lua_State *L) plr->gotcontinue = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"speed")) plr->speed = luaL_checkfixed(L, 3); - else if (fastcmp(field,"jumping")) - plr->jumping = luaL_checkboolean(L, 3); else if (fastcmp(field,"secondjump")) plr->secondjump = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"fly1")) @@ -459,6 +539,8 @@ static int player_set(lua_State *L) plr->exiting = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"homing")) plr->homing = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"dashmode")) + plr->dashmode = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"skidtime")) plr->skidtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"cmomx")) @@ -497,14 +579,26 @@ static int player_set(lua_State *L) plr->starposttime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"starpostangle")) plr->starpostangle = luaL_checkangle(L, 3); + else if (fastcmp(field,"starpostscale")) + plr->starpostscale = luaL_checkfixed(L, 3); else if (fastcmp(field,"angle_pos")) plr->angle_pos = luaL_checkangle(L, 3); else if (fastcmp(field,"old_angle_pos")) plr->old_angle_pos = luaL_checkangle(L, 3); else if (fastcmp(field,"axis1")) - P_SetTarget(&plr->axis1, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ))); + { + mobj_t *mo = NULL; + if (!lua_isnil(L, 3)) + mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&plr->axis1, mo); + } else if (fastcmp(field,"axis2")) - P_SetTarget(&plr->axis2, *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ))); + { + mobj_t *mo = NULL; + if (!lua_isnil(L, 3)) + mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&plr->axis2, mo); + } else if (fastcmp(field,"bumpertime")) plr->bumpertime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"flyangle")) @@ -532,22 +626,51 @@ static int player_set(lua_State *L) mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); P_SetTarget(&plr->capsule, mo); } + else if (fastcmp(field,"drone")) + { + mobj_t *mo = NULL; + if (!lua_isnil(L, 3)) + mo = *((mobj_t **)luaL_checkudata(L, 3, META_MOBJ)); + P_SetTarget(&plr->drone, mo); + } + else if (fastcmp(field,"oldscale")) + plr->oldscale = luaL_checkfixed(L, 3); else if (fastcmp(field,"mare")) plr->mare = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"marelap")) + plr->marelap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"marebonuslap")) + plr->marebonuslap = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"marebegunat")) plr->marebegunat = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"startedtime")) plr->startedtime = (tic_t)luaL_checkinteger(L, 3); else if (fastcmp(field,"finishedtime")) plr->finishedtime = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"lapbegunat")) + plr->lapbegunat = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"lapstartedtime")) + plr->lapstartedtime = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"finishedspheres")) + plr->finishedspheres = (INT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"finishedrings")) plr->finishedrings = (INT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"marescore")) plr->marescore = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmarescore")) plr->lastmarescore = (UINT32)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarescore")) + plr->totalmarescore = (UINT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"lastmare")) plr->lastmare = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"lastmarelap")) + plr->lastmarelap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"lastmarebonuslap")) + plr->lastmarebonuslap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarelap")) + plr->totalmarelap = (UINT8)luaL_checkinteger(L, 3); + else if (fastcmp(field,"totalmarebonuslap")) + plr->totalmarebonuslap = (UINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"maxlink")) plr->maxlink = (INT32)luaL_checkinteger(L, 3); else if (fastcmp(field,"texttimer")) @@ -581,10 +704,14 @@ static int player_set(lua_State *L) plr->awayviewaiming = luaL_checkangle(L, 3); else if (fastcmp(field,"spectator")) plr->spectator = lua_toboolean(L, 3); + else if (fastcmp(field,"outofcoop")) + plr->outofcoop = lua_toboolean(L, 3); else if (fastcmp(field,"bot")) return NOSET; else if (fastcmp(field,"jointime")) plr->jointime = (tic_t)luaL_checkinteger(L, 3); + else if (fastcmp(field,"quittime")) + plr->quittime = (tic_t)luaL_checkinteger(L, 3); #ifdef HWRENDER else if (fastcmp(field,"fovadd")) plr->fovadd = luaL_checkfixed(L, 3); @@ -628,7 +755,7 @@ static int power_get(lua_State *L) UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); lua_pushinteger(L, powers[p]); return 1; } @@ -640,7 +767,7 @@ static int power_set(lua_State *L) powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); powers[p] = i; @@ -750,5 +877,3 @@ int LUA_PlayerLib(lua_State *L) lua_setglobal(L, "players"); return 0; } - -#endif diff --git a/src/lua_script.c b/src/lua_script.c index edf8ac3c5..6fa6cf57d 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,14 +11,15 @@ /// \brief Lua scripting basics #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" #include "dehacked.h" #include "z_zone.h" #include "w_wad.h" #include "p_setup.h" #include "r_state.h" +#include "r_sky.h" #include "g_game.h" +#include "f_finale.h" #include "byteptr.h" #include "p_saveg.h" #include "p_local.h" @@ -79,8 +80,234 @@ FUNCNORETURN static int LUA_Panic(lua_State *L) #endif } +// Moved here from lib_getenum. +int LUA_PushGlobals(lua_State *L, const char *word) +{ + if (fastcmp(word,"gamemap")) { + lua_pushinteger(L, gamemap); + return 1; + } else if (fastcmp(word,"maptol")) { + lua_pushinteger(L, maptol); + return 1; + } else if (fastcmp(word,"ultimatemode")) { + lua_pushboolean(L, ultimatemode != 0); + return 1; + } else if (fastcmp(word,"mariomode")) { + lua_pushboolean(L, mariomode != 0); + return 1; + } else if (fastcmp(word,"twodlevel")) { + lua_pushboolean(L, twodlevel != 0); + return 1; + } else if (fastcmp(word,"circuitmap")) { + lua_pushboolean(L, circuitmap); + return 1; + } else if (fastcmp(word,"stoppedclock")) { + lua_pushboolean(L, stoppedclock); + return 1; + } else if (fastcmp(word,"netgame")) { + lua_pushboolean(L, netgame); + return 1; + } else if (fastcmp(word,"multiplayer")) { + lua_pushboolean(L, multiplayer); + return 1; + } else if (fastcmp(word,"modeattacking")) { + lua_pushboolean(L, modeattacking); + return 1; + } else if (fastcmp(word,"splitscreen")) { + lua_pushboolean(L, splitscreen); + return 1; + } else if (fastcmp(word,"gamecomplete")) { + lua_pushboolean(L, gamecomplete); + return 1; + } else if (fastcmp(word,"devparm")) { + lua_pushboolean(L, devparm); + return 1; + } else if (fastcmp(word,"modifiedgame")) { + lua_pushboolean(L, modifiedgame && !savemoddata); + return 1; + } else if (fastcmp(word,"menuactive")) { + lua_pushboolean(L, menuactive); + return 1; + } else if (fastcmp(word,"paused")) { + lua_pushboolean(L, paused); + return 1; + } else if (fastcmp(word,"bluescore")) { + lua_pushinteger(L, bluescore); + return 1; + } else if (fastcmp(word,"redscore")) { + lua_pushinteger(L, redscore); + return 1; + } else if (fastcmp(word,"timelimit")) { + lua_pushinteger(L, cv_timelimit.value); + return 1; + } else if (fastcmp(word,"pointlimit")) { + lua_pushinteger(L, cv_pointlimit.value); + return 1; + // begin map vars + } else if (fastcmp(word,"spstage_start")) { + lua_pushinteger(L, spstage_start); + return 1; + } else if (fastcmp(word,"sstage_start")) { + lua_pushinteger(L, sstage_start); + return 1; + } else if (fastcmp(word,"sstage_end")) { + lua_pushinteger(L, sstage_end); + return 1; + } else if (fastcmp(word,"smpstage_start")) { + lua_pushinteger(L, smpstage_start); + return 1; + } else if (fastcmp(word,"smpstage_end")) { + lua_pushinteger(L, smpstage_end); + return 1; + } else if (fastcmp(word,"titlemap")) { + lua_pushinteger(L, titlemap); + return 1; + } else if (fastcmp(word,"titlemapinaction")) { + lua_pushboolean(L, (titlemapinaction != TITLEMAP_OFF)); + return 1; + } else if (fastcmp(word,"bootmap")) { + lua_pushinteger(L, bootmap); + return 1; + } else if (fastcmp(word,"tutorialmap")) { + lua_pushinteger(L, tutorialmap); + return 1; + } else if (fastcmp(word,"tutorialmode")) { + lua_pushboolean(L, tutorialmode); + return 1; + // end map vars + // begin CTF colors + } else if (fastcmp(word,"skincolor_redteam")) { + lua_pushinteger(L, skincolor_redteam); + return 1; + } else if (fastcmp(word,"skincolor_blueteam")) { + lua_pushinteger(L, skincolor_blueteam); + return 1; + } else if (fastcmp(word,"skincolor_redring")) { + lua_pushinteger(L, skincolor_redring); + return 1; + } else if (fastcmp(word,"skincolor_bluering")) { + lua_pushinteger(L, skincolor_bluering); + return 1; + // end CTF colors + // begin timers + } else if (fastcmp(word,"invulntics")) { + lua_pushinteger(L, invulntics); + return 1; + } else if (fastcmp(word,"sneakertics")) { + lua_pushinteger(L, sneakertics); + return 1; + } else if (fastcmp(word,"flashingtics")) { + lua_pushinteger(L, flashingtics); + return 1; + } else if (fastcmp(word,"tailsflytics")) { + lua_pushinteger(L, tailsflytics); + return 1; + } else if (fastcmp(word,"underwatertics")) { + lua_pushinteger(L, underwatertics); + return 1; + } else if (fastcmp(word,"spacetimetics")) { + lua_pushinteger(L, spacetimetics); + return 1; + } else if (fastcmp(word,"extralifetics")) { + lua_pushinteger(L, extralifetics); + return 1; + } else if (fastcmp(word,"nightslinktics")) { + lua_pushinteger(L, nightslinktics); + return 1; + } else if (fastcmp(word,"gameovertics")) { + lua_pushinteger(L, gameovertics); + return 1; + } else if (fastcmp(word,"ammoremovaltics")) { + lua_pushinteger(L, ammoremovaltics); + return 1; + // end timers + } else if (fastcmp(word,"gametype")) { + lua_pushinteger(L, gametype); + return 1; + } else if (fastcmp(word,"gametyperules")) { + lua_pushinteger(L, gametyperules); + return 1; + } else if (fastcmp(word,"leveltime")) { + lua_pushinteger(L, leveltime); + return 1; + } else if (fastcmp(word,"sstimer")) { + lua_pushinteger(L, sstimer); + return 1; + } else if (fastcmp(word,"curWeather")) { + lua_pushinteger(L, curWeather); + return 1; + } else if (fastcmp(word,"globalweather")) { + lua_pushinteger(L, globalweather); + return 1; + } else if (fastcmp(word,"levelskynum")) { + lua_pushinteger(L, levelskynum); + return 1; + } else if (fastcmp(word,"globallevelskynum")) { + lua_pushinteger(L, globallevelskynum); + return 1; + } else if (fastcmp(word,"mapmusname")) { + lua_pushstring(L, mapmusname); + return 1; + } else if (fastcmp(word,"mapmusflags")) { + lua_pushinteger(L, mapmusflags); + return 1; + } else if (fastcmp(word,"mapmusposition")) { + lua_pushinteger(L, mapmusposition); + return 1; + // local player variables, by popular request + } else if (fastcmp(word,"consoleplayer")) { // player controlling console (aka local player 1) + if (consoleplayer < 0 || !playeringame[consoleplayer]) + return 0; + LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER); + return 1; + } else if (fastcmp(word,"displayplayer")) { // player visible on screen (aka display player 1) + if (displayplayer < 0 || !playeringame[displayplayer]) + return 0; + LUA_PushUserdata(L, &players[displayplayer], META_PLAYER); + return 1; + } else if (fastcmp(word,"secondarydisplayplayer")) { // local/display player 2, for splitscreen + if (!splitscreen || secondarydisplayplayer < 0 || !playeringame[secondarydisplayplayer]) + return 0; + LUA_PushUserdata(L, &players[secondarydisplayplayer], META_PLAYER); + return 1; + // end local player variables + } else if (fastcmp(word,"server")) { + if ((!multiplayer || !netgame) && !playeringame[serverplayer]) + return 0; + LUA_PushUserdata(L, &players[serverplayer], META_PLAYER); + return 1; + } else if (fastcmp(word,"emeralds")) { + lua_pushinteger(L, emeralds); + return 1; + } else if (fastcmp(word,"gravity")) { + lua_pushinteger(L, gravity); + return 1; + } else if (fastcmp(word,"VERSIONSTRING")) { + lua_pushstring(L, VERSIONSTRING); + return 1; + } else if (fastcmp(word, "token")) { + lua_pushinteger(L, token); + return 1; + } + return 0; +} + +// See the above. +int LUA_CheckGlobals(lua_State *L, const char *word) +{ + if (fastcmp(word, "redscore")) + redscore = (UINT32)luaL_checkinteger(L, 2); + else if (fastcmp(word, "bluescore")) + bluescore = (UINT32)luaL_checkinteger(L, 2); + else + return 0; + + // Global variable set, so return and don't error. + return 1; +} + // This function decides which global variables you are allowed to set. -static int noglobals(lua_State *L) +static int setglobals(lua_State *L) { const char *csname; char *name; @@ -106,6 +333,9 @@ static int noglobals(lua_State *L) return 0; } + if (LUA_CheckGlobals(L, csname)) + return 0; + Z_Free(name); return luaL_error(L, "Implicit global " LUA_QS " prevented. Create a local variable instead.", csname); } @@ -144,7 +374,7 @@ static void LUA_ClearState(void) // lock the global namespace lua_getmetatable(L, LUA_GLOBALSINDEX); - lua_pushcfunction(L, noglobals); + lua_pushcfunction(L, setglobals); lua_setfield(L, -2, "__newindex"); lua_newtable(L); lua_setfield(L, -2, "__metatable"); @@ -164,6 +394,11 @@ void LUA_ClearExtVars(void) } #endif +// Use this variable to prevent certain functions from running +// if they were not called on lump load +// (i.e. they were called in hooks or coroutines etc) +boolean lua_lumploading = false; + // Load a script from a MYFILE static inline void LUA_LoadFile(MYFILE *f, char *name) { @@ -175,11 +410,15 @@ static inline void LUA_LoadFile(MYFILE *f, char *name) lua_pushinteger(gL, f->wad); lua_setfield(gL, LUA_REGISTRYINDEX, "WAD"); + lua_lumploading = true; // turn on loading flag + if (luaL_loadbuffer(gL, f->data, f->size, va("@%s",name)) || lua_pcall(gL, 0, 0, 0)) { CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL,-1)); lua_pop(gL,1); } lua_gc(gL, LUA_GCCOLLECT, 0); + + lua_lumploading = false; // turn off again } // Load a script from a lump @@ -408,18 +647,27 @@ void LUA_InvalidateLevel(void) { thinker_t *th; size_t i; + ffloor_t *rover = NULL; if (!gL) return; - - for (th = thinkercap.next; th && th != &thinkercap; th = th->next) - LUA_InvalidateUserdata(th); + for (i = 0; i < NUM_THINKERLISTS; i++) + for (th = thlist[i].next; th && th != &thlist[i]; th = th->next) + LUA_InvalidateUserdata(th); LUA_InvalidateMapthings(); for (i = 0; i < numsubsectors; i++) LUA_InvalidateUserdata(&subsectors[i]); for (i = 0; i < numsectors; i++) + { LUA_InvalidateUserdata(§ors[i]); + LUA_InvalidateUserdata(§ors[i].lines); + if (sectors[i].ffloors) + { + for (rover = sectors[i].ffloors; rover; rover = rover->next) + LUA_InvalidateUserdata(rover); + } + } for (i = 0; i < numlines; i++) { LUA_InvalidateUserdata(&lines[i]); @@ -429,6 +677,16 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(&sides[i]); for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); +#ifdef HAVE_LUA_SEGS + for (i = 0; i < numsegs; i++) + LUA_InvalidateUserdata(&segs[i]); + for (i = 0; i < numnodes; i++) + { + LUA_InvalidateUserdata(&nodes[i]); + LUA_InvalidateUserdata(nodes[i].bbox); + LUA_InvalidateUserdata(nodes[i].children); + } +#endif } void LUA_InvalidateMapthings(void) @@ -468,6 +726,11 @@ enum ARCH_SIDE, ARCH_SUBSECTOR, ARCH_SECTOR, +#ifdef HAVE_LUA_SEGS + ARCH_SEG, + ARCH_NODE, +#endif + ARCH_FFLOOR, #ifdef ESLOPE ARCH_SLOPE, #endif @@ -490,6 +753,11 @@ static const struct { {META_SIDE, ARCH_SIDE}, {META_SUBSECTOR,ARCH_SUBSECTOR}, {META_SECTOR, ARCH_SECTOR}, +#ifdef HAVE_LUA_SEGS + {META_SEG, ARCH_SEG}, + {META_NODE, ARCH_NODE}, +#endif + {META_FFLOOR, ARCH_FFLOOR}, #ifdef ESLOPE {META_SLOPE, ARCH_SLOPE}, #endif @@ -697,6 +965,56 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) } break; } +#ifdef HAVE_LUA_SEGS + case ARCH_SEG: + { + seg_t *seg = *((seg_t **)lua_touserdata(gL, myindex)); + if (!seg) + WRITEUINT8(save_p, ARCH_NULL); + else { + WRITEUINT8(save_p, ARCH_SEG); + WRITEUINT16(save_p, seg - segs); + } + break; + } + case ARCH_NODE: + { + node_t *node = *((node_t **)lua_touserdata(gL, myindex)); + if (!node) + WRITEUINT8(save_p, ARCH_NULL); + else { + WRITEUINT8(save_p, ARCH_NODE); + WRITEUINT16(save_p, node - nodes); + } + break; + } +#endif + case ARCH_FFLOOR: + { + ffloor_t *rover = *((ffloor_t **)lua_touserdata(gL, myindex)); + if (!rover) + WRITEUINT8(save_p, ARCH_NULL); + else { + ffloor_t *r2; + UINT16 i = 0; + // search for id + for (r2 = rover->target->ffloors; r2; r2 = r2->next) + { + if (r2 == rover) + break; + i++; + } + if (!r2) + WRITEUINT8(save_p, ARCH_NULL); + else + { + WRITEUINT8(save_p, ARCH_FFLOOR); + WRITEUINT16(save_p, rover->target - sectors); + WRITEUINT16(save_p, i); + } + } + break; + } #ifdef ESLOPE case ARCH_SLOPE: { @@ -914,6 +1232,23 @@ static UINT8 UnArchiveValue(int TABLESINDEX) case ARCH_SECTOR: LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_SECTOR); break; +#ifdef HAVE_LUA_SEGS + case ARCH_SEG: + LUA_PushUserdata(gL, &segs[READUINT16(save_p)], META_SEG); + break; + case ARCH_NODE: + LUA_PushUserdata(gL, &nodes[READUINT16(save_p)], META_NODE); + break; +#endif + case ARCH_FFLOOR: + { + sector_t *sector = §ors[READUINT16(save_p)]; + UINT16 id = READUINT16(save_p); + ffloor_t *rover = P_GetFFloorByID(sector, id); + if (rover) + LUA_PushUserdata(gL, rover, META_FFLOOR); + break; + } #ifdef ESLOPE case ARCH_SLOPE: LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE); @@ -1016,19 +1351,22 @@ void LUA_Archive(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!playeringame[i] && i > 0) // dedicated servers... continue; // all players in game will be archived, even if they just add a 0. ArchiveExtVars(&players[i], "player"); } - for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); - } + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(th, "mobj"); + } + WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. LUAh_NetArchiveHook(NetArchive); // call the NetArchive hook in archive mode @@ -1049,17 +1387,21 @@ void LUA_UnArchive(void) for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i]) + if (!playeringame[i] && i > 0) // dedicated servers... continue; UnArchiveExtVars(&players[i]); } do { mobjnum = READUINT32(save_p); // read a mobjnum - for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker - && ((mobj_t *)th)->mobjnum == mobjnum) // find matching mobj - UnArchiveExtVars(th); // apply variables + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj + continue; + UnArchiveExtVars(th); // apply variables + } } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode @@ -1080,5 +1422,3 @@ int Lua_optoption(lua_State *L, int narg, return i; return -1; } - -#endif // HAVE_BLUA diff --git a/src/lua_script.h b/src/lua_script.h index f944149d7..7bdf7685b 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -10,11 +10,10 @@ /// \file lua_script.h /// \brief Lua scripting basics -#ifdef HAVE_BLUA - #include "m_fixed.h" #include "doomtype.h" #include "d_player.h" +#include "g_state.h" #include "blua/lua.h" #include "blua/lualib.h" @@ -38,6 +37,8 @@ void LUA_ClearExtVars(void); #endif +extern boolean lua_lumploading; // is LUA_LoadLump being called? + void LUA_LoadLump(UINT16 wad, UINT16 lump); #ifdef LUA_ALLOW_BYTECODE void LUA_DumpFile(const char *filename); @@ -51,6 +52,8 @@ void LUA_InvalidatePlayer(player_t *player); void LUA_Step(void); void LUA_Archive(void); void LUA_UnArchive(void); +int LUA_PushGlobals(lua_State *L, const char *word); +int LUA_CheckGlobals(lua_State *L, const char *word); void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c void LUA_CVarChanged(const char *name); // lua_consolelib.c int Lua_optoption(lua_State *L, int narg, @@ -92,4 +95,8 @@ void COM_Lua_f(void); }\ } -#endif +// uncomment if you want seg_t/node_t in Lua +// #define HAVE_LUA_SEGS + +#define INLEVEL if (gamestate != GS_LEVEL && !titlemapinaction)\ +return luaL_error(L, "This can only be used in a level!"); diff --git a/src/lua_skinlib.c b/src/lua_skinlib.c index 0fbcb2fd3..3e4ddb9f0 100644 --- a/src/lua_skinlib.c +++ b/src/lua_skinlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2014-2016 by John "JTE" Muniz. -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,9 +11,8 @@ /// \brief player skin structure library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "fastcmp.h" -#include "r_things.h" +#include "r_skins.h" #include "sounds.h" #include "lua_script.h" @@ -27,14 +26,12 @@ enum skin { skin_flags, skin_realname, skin_hudname, - skin_charsel, - skin_face, - skin_superface, skin_ability, skin_ability2, skin_thokitem, skin_spinitem, skin_revitem, + skin_followitem, skin_actionspd, skin_mindash, skin_maxdash, @@ -44,10 +41,20 @@ enum skin { skin_accelstart, skin_acceleration, skin_jumpfactor, + skin_radius, + skin_height, + skin_spinheight, + skin_shieldscale, + skin_camerascale, skin_starttranscolor, skin_prefcolor, + skin_supercolor, + skin_prefoppositecolor, skin_highresscale, - skin_soundsid + skin_contspeed, + skin_contangle, + skin_soundsid, + skin_availability }; static const char *const skin_opt[] = { "valid", @@ -57,14 +64,12 @@ static const char *const skin_opt[] = { "flags", "realname", "hudname", - "charsel", - "face", - "superface", "ability", "ability2", "thokitem", "spinitem", "revitem", + "followitem", "actionspd", "mindash", "maxdash", @@ -74,10 +79,20 @@ static const char *const skin_opt[] = { "accelstart", "acceleration", "jumpfactor", + "radius", + "height", + "spinheight", + "shieldscale", + "camerascale", "starttranscolor", "prefcolor", + "supercolor", + "prefoppositecolor", "highresscale", + "contspeed", + "contangle", "soundsid", + "availability", NULL}; #define UNIMPLEMENTED luaL_error(L, LUA_QL("skin_t") " field " LUA_QS " is not implemented for Lua and cannot be accessed.", skin_opt[field]) @@ -86,7 +101,6 @@ static int skin_get(lua_State *L) { skin_t *skin = *((skin_t **)luaL_checkudata(L, 1, META_SKIN)); enum skin field = luaL_checkoption(L, 2, NULL, skin_opt); - INT32 i; // skins are always valid, only added, never removed I_Assert(skin != NULL); @@ -113,24 +127,6 @@ static int skin_get(lua_State *L) case skin_hudname: lua_pushstring(L, skin->hudname); break; - case skin_charsel: - for (i = 0; i < 8; i++) - if (!skin->charsel[i]) - break; - lua_pushlstring(L, skin->charsel, i); - break; - case skin_face: - for (i = 0; i < 8; i++) - if (!skin->face[i]) - break; - lua_pushlstring(L, skin->face, i); - break; - case skin_superface: - for (i = 0; i < 8; i++) - if (!skin->superface[i]) - break; - lua_pushlstring(L, skin->superface, i); - break; case skin_ability: lua_pushinteger(L, skin->ability); break; @@ -146,6 +142,9 @@ static int skin_get(lua_State *L) case skin_revitem: lua_pushinteger(L, skin->revitem); break; + case skin_followitem: + lua_pushinteger(L, skin->followitem); + break; case skin_actionspd: lua_pushfixed(L, skin->actionspd); break; @@ -173,18 +172,48 @@ static int skin_get(lua_State *L) case skin_jumpfactor: lua_pushfixed(L, skin->jumpfactor); break; + case skin_radius: + lua_pushfixed(L, skin->radius); + break; + case skin_height: + lua_pushfixed(L, skin->height); + break; + case skin_spinheight: + lua_pushfixed(L, skin->spinheight); + break; + case skin_shieldscale: + lua_pushfixed(L, skin->shieldscale); + break; + case skin_camerascale: + lua_pushfixed(L, skin->camerascale); + break; case skin_starttranscolor: lua_pushinteger(L, skin->starttranscolor); break; case skin_prefcolor: lua_pushinteger(L, skin->prefcolor); break; + case skin_supercolor: + lua_pushinteger(L, skin->supercolor); + break; + case skin_prefoppositecolor: + lua_pushinteger(L, skin->prefoppositecolor); + break; case skin_highresscale: lua_pushinteger(L, skin->highresscale); break; + case skin_contspeed: + lua_pushinteger(L, skin->contspeed); + break; + case skin_contangle: + lua_pushinteger(L, skin->contangle); + break; case skin_soundsid: LUA_PushUserdata(L, skin->soundsid, META_SOUNDSID); break; + case skin_availability: + lua_pushinteger(L, skin->availability); + break; } return 1; } @@ -328,5 +357,3 @@ int LUA_SkinLib(lua_State *L) return 0; } - -#endif diff --git a/src/lua_thinkerlib.c b/src/lua_thinkerlib.c index ae859d46e..82baa6469 100644 --- a/src/lua_thinkerlib.c +++ b/src/lua_thinkerlib.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2012-2016 by John "JTE" Muniz. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -11,14 +11,13 @@ /// \brief thinker library for Lua scripting #include "doomdef.h" -#ifdef HAVE_BLUA #include "p_local.h" #include "lua_script.h" #include "lua_libs.h" #define META_ITERATIONSTATE "iteration state" -static const char *const iter_opt[] = { +/*static const char *const iter_opt[] = { "all", "mobj", NULL}; @@ -26,7 +25,7 @@ static const char *const iter_opt[] = { static const actionf_p1 iter_funcs[] = { NULL, (actionf_p1)P_MobjThinker -}; +};*/ struct iterationState { actionf_p1 filter; @@ -54,11 +53,16 @@ static int iterationState_gc(lua_State *L) static int lib_iterateThinkers(lua_State *L) { thinker_t *th = NULL, *next = NULL; - struct iterationState *it = luaL_checkudata(L, 1, META_ITERATIONSTATE); + struct iterationState *it; + + INLEVEL + + it = luaL_checkudata(L, 1, META_ITERATIONSTATE); + lua_settop(L, 2); if (lua_isnil(L, 2)) - th = &thinkercap; + th = &thlist[THINK_MOBJ]; else if (lua_isuserdata(L, 2)) { if (lua_islightuserdata(L, 2)) @@ -88,11 +92,11 @@ static int lib_iterateThinkers(lua_State *L) if (!next) return luaL_error(L, "next thinker invalidated during iteration"); - for (; next != &thinkercap; next = next->next) + for (; next != &thlist[THINK_MOBJ]; next = next->next) if (!it->filter || next->function.acp1 == it->filter) { push_thinker(next); - if (next->next != &thinkercap) + if (next->next != &thlist[THINK_MOBJ]) { push_thinker(next->next); it->next = luaL_ref(L, LUA_REGISTRYINDEX); @@ -106,12 +110,14 @@ static int lib_startIterate(lua_State *L) { struct iterationState *it; + INLEVEL + lua_pushvalue(L, lua_upvalueindex(1)); it = lua_newuserdata(L, sizeof(struct iterationState)); luaL_getmetatable(L, META_ITERATIONSTATE); lua_setmetatable(L, -2); - it->filter = iter_funcs[luaL_checkoption(L, 1, "mobj", iter_opt)]; + it->filter = (actionf_p1)P_MobjThinker; //iter_funcs[luaL_checkoption(L, 1, "mobj", iter_opt)]; it->next = LUA_REFNIL; return 2; } @@ -129,8 +135,6 @@ int LUA_ThinkerLib(lua_State *L) lua_pushcfunction(L, lib_iterateThinkers); lua_pushcclosure(L, lib_startIterate, 1); lua_setfield(L, -2, "iterate"); - lua_setglobal(L, "thinkers"); + lua_setglobal(L, "mobjs"); return 0; } - -#endif diff --git a/src/lzf.c b/src/lzf.c index 272174f30..f81c3ee0a 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -119,9 +119,7 @@ /*****************************************************************************/ /* nothing should be changed below */ -#ifndef _NDS typedef unsigned char u8; -#endif typedef const u8 *LZF_STATE[1 << (HLOG)]; @@ -159,7 +157,7 @@ typedef const u8 *LZF_STATE[1 << (HLOG)]; * lzfP.h ends here. lzf_d.c follows. */ -#if AVOID_ERRNO || defined(_WIN32_WCE) +#if AVOID_ERRNO # define SET_ERRNO(n) #else # include diff --git a/src/m_aatree.c b/src/m_aatree.c index f19fa1dc0..c0bb739f8 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_aatree.h b/src/m_aatree.h index e7f1eba05..b784eb17a 100644 --- a/src/m_aatree.h +++ b/src/m_aatree.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_anigif.c b/src/m_anigif.c index 4e68819bc..ce2ca20b9 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -1,8 +1,8 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013 by "Ninji". -// Copyright (C) 2013-2018 by Sonic Team Junior. +// Copyright (C) 2013-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -18,17 +18,30 @@ #include "z_zone.h" #include "v_video.h" #include "i_video.h" +#include "m_misc.h" +#include "st_stuff.h" // st_palette + +#ifdef HWRENDER +#include "hardware/hw_main.h" +#endif // GIFs are always little-endian #include "byteptr.h" consvar_t cv_gif_optimize = {"gif_optimize", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gif_downscale = {"gif_downscale", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gif_localcolortable = {"gif_localcolortable", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output +// Palette handling +static boolean gif_localcolortable = false; +static boolean gif_colorprofile = false; +static RGBA_t *gif_headerpalette = NULL; +static RGBA_t *gif_framepalette = NULL; + static FILE *gif_out = NULL; static INT32 gif_frames = 0; static UINT8 gif_writeover = 0; @@ -387,17 +400,47 @@ const UINT8 gifhead_nsid[19] = {0x21,0xFF,0x0B, // extension block + size 0x4E,0x45,0x54,0x53,0x43,0x41,0x50,0x45,0x32,0x2E,0x30, // NETSCAPE2.0 0x03,0x01,0xFF,0xFF,0x00}; // sub-block, repetitions + +// +// GIF_getpalette +// determine the palette for the current frame. +// +static RGBA_t *GIF_getpalette(size_t palnum) +{ + // In hardware mode, always returns the local palette +#ifdef HWRENDER + if (rendermode == render_opengl) + return pLocalPalette; + else +#endif + return (gif_colorprofile ? &pLocalPalette[palnum*256] : &pMasterPalette[palnum*256]); +} + +// +// GIF_palwrite +// writes the gif palette. +// used both for the header and local color tables. +// +static UINT8 *GIF_palwrite(UINT8 *p, RGBA_t *pal) +{ + INT32 i; + for (i = 0; i < 256; i++) + { + WRITEUINT8(p, pal[i].s.red); + WRITEUINT8(p, pal[i].s.green); + WRITEUINT8(p, pal[i].s.blue); + } + return p; +} + // // GIF_headwrite // writes the gif header to the currently open output file. -// NOTE that this code does not accomodate for palette changes. // static void GIF_headwrite(void) { UINT8 *gifhead = Z_Malloc(800, PU_STATIC, NULL); UINT8 *p = gifhead; - RGBA_t *c; - INT32 i; UINT16 rwidth, rheight; if (!gif_out) @@ -418,22 +461,17 @@ static void GIF_headwrite(void) rwidth = vid.width; rheight = vid.height; } + WRITEUINT16(p, rwidth); WRITEUINT16(p, rheight); // colors, aspect, etc - WRITEUINT8(p, 0xF7); + WRITEUINT8(p, 0xF7); // (0xF7 = 1111 0111) WRITEUINT8(p, 0x00); WRITEUINT8(p, 0x00); // write color table - for (i = 0; i < 256; ++i) - { - c = &pLocalPalette[i]; - WRITEUINT8(p, c->s.red); - WRITEUINT8(p, c->s.green); - WRITEUINT8(p, c->s.blue); - } + p = GIF_palwrite(p, gif_headerpalette); // write extension block WRITEMEM(p, gifhead_nsid, sizeof(gifhead_nsid)); @@ -452,6 +490,32 @@ const UINT8 gifframe_gchead[4] = {0x21,0xF9,0x04,0x04}; // GCE, bytes, packed by static UINT8 *gifframe_data = NULL; static size_t gifframe_size = 8192; +#ifdef HWRENDER +static void hwrconvert(void) +{ + UINT8 *linear = HWR_GetScreenshot(); + UINT8 *dest = screens[2]; + UINT8 r, g, b; + INT32 x, y; + size_t i = 0; + + InitColorLUT(gif_framepalette); + + for (y = 0; y < vid.height; y++) + { + for (x = 0; x < vid.width; x++, i += 3) + { + r = (UINT8)linear[i]; + g = (UINT8)linear[i + 1]; + b = (UINT8)linear[i + 2]; + dest[(y * vid.width) + x] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS]; + } + } + + free(linear); +} +#endif + // // GIF_framewrite // writes a frame into the file. @@ -461,6 +525,7 @@ static void GIF_framewrite(void) UINT8 *p; UINT8 *movie_screen = screens[2]; INT32 blitx, blity, blitw, blith; + boolean palchanged; if (!gifframe_data) gifframe_data = Z_Malloc(gifframe_size, PU_STATIC, NULL); @@ -469,15 +534,30 @@ static void GIF_framewrite(void) if (!gif_out) return; + // Lactozilla: Compare the header's palette with the current frame's palette and see if it changed. + if (gif_localcolortable) + { + gif_framepalette = GIF_getpalette(max(st_palette, 0)); + palchanged = memcmp(gif_headerpalette, gif_framepalette, sizeof(RGBA_t) * 256); + } + else + palchanged = false; + // Compare image data (for optimizing GIF) - if (gif_optimize && gif_frames > 0) + // If the palette has changed, the entire frame is considered to be different. + if (gif_optimize && gif_frames > 0 && (!palchanged)) { // before blit movie_screen points to last frame, cur_screen points to this frame UINT8 *cur_screen = screens[0]; GIF_optimizeregion(cur_screen, movie_screen, &blitx, &blity, &blitw, &blith); // blit to temp screen - I_ReadScreen(movie_screen); + if (rendermode == render_soft) + I_ReadScreen(movie_screen); +#ifdef HWRENDER + else if (rendermode == render_opengl) + hwrconvert(); +#endif } else { @@ -486,7 +566,18 @@ static void GIF_framewrite(void) blith = vid.height; if (gif_frames == 0) - I_ReadScreen(movie_screen); + { + if (rendermode == render_soft) + I_ReadScreen(movie_screen); +#ifdef HWRENDER + else if (rendermode == render_opengl) + { + hwrconvert(); + VID_BlitLinearScreen(screens[2], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); + } +#endif + } + movie_screen = screens[0]; } @@ -517,7 +608,20 @@ static void GIF_framewrite(void) WRITEUINT16(p, (UINT16)(blity / scrbuf_downscaleamt)); WRITEUINT16(p, (UINT16)(blitw / scrbuf_downscaleamt)); WRITEUINT16(p, (UINT16)(blith / scrbuf_downscaleamt)); - WRITEUINT8(p, 0); // no local table of colors + + if (!gif_localcolortable) + WRITEUINT8(p, 0); // no local table of colors + else + { + if (palchanged) + { + // The palettes are different, so write the Local Color Table! + WRITEUINT8(p, 0x87); // (0x87 = 1000 0111) + p = GIF_palwrite(p, gif_framepalette); + } + else + WRITEUINT8(p, 0); // They are equal, no Local Color Table needed. + } scrbuf_pos = movie_screen + blitx + (blity * vid.width); scrbuf_writeend = scrbuf_pos + (blitw - 1) + ((blith - 1) * vid.width); @@ -575,20 +679,16 @@ static void GIF_framewrite(void) // INT32 GIF_open(const char *filename) { -#ifdef HWRENDER - if (rendermode != render_soft) - { - CONS_Alert(CONS_WARNING, M_GetText("GIFs cannot be taken in non-software modes!\n")); - return 0; - } -#endif - gif_out = fopen(filename, "wb"); if (!gif_out) return 0; gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); + gif_localcolortable = (!!cv_gif_localcolortable.value); + gif_colorprofile = (!!cv_screenshot_colorprofile.value); + gif_headerpalette = GIF_getpalette(0); + GIF_headwrite(); gif_frames = 0; return 1; diff --git a/src/m_anigif.h b/src/m_anigif.h index 6d94ecf8c..4bb45b67d 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 2013-2018 by Sonic Team Junior. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 2013-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,6 +27,6 @@ void GIF_frame(void); INT32 GIF_close(void); #endif -extern consvar_t cv_gif_optimize, cv_gif_downscale; +extern consvar_t cv_gif_optimize, cv_gif_downscale, cv_gif_localcolortable; #endif diff --git a/src/m_argv.c b/src/m_argv.c index e8bfdd3db..acb74cff4 100644 --- a/src/m_argv.c +++ b/src/m_argv.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -16,6 +16,7 @@ #include "doomdef.h" #include "command.h" #include "m_argv.h" +#include "m_misc.h" /** \brief number of arg */ @@ -91,48 +92,28 @@ const char *M_GetNextParm(void) void M_PushSpecialParameters(void) { INT32 i; - char s[256]; - boolean onetime = false; - for (i = 1; i < myargc; i++) { if (myargv[i][0] == '+') { - strcpy(s, &myargv[i][1]); + COM_BufAddText(&myargv[i][1]); i++; // get the parameters of the command too for (; i < myargc && myargv[i][0] != '+' && myargv[i][0] != '-'; i++) { - strcat(s, " "); - if (!onetime) - { - strcat(s, "\""); - onetime = true; - } - strcat(s, myargv[i]); + COM_BufAddText(va(" \"%s\"", myargv[i])); } - if (onetime) - { - strcat(s, "\""); - onetime = false; - } - strcat(s, "\n"); // push it - COM_BufAddText(s); + COM_BufAddText("\n"); i--; } } } /// \brief max args - -#if defined (_arch_dreamcast) || defined (_XBOX) || defined (_WII) -#define MAXARGVS 1 -#else #define MAXARGVS 256 -#endif /** \brief the M_FindResponseFile function Find a response file @@ -166,7 +147,7 @@ void M_FindResponseFile(void) if (!file) I_Error("No more free memory for the response file"); if (fread(file, size, 1, handle) != 1) - I_Error("Couldn't read response file because %s", strerror(ferror(handle))); + I_Error("Couldn't read response file because %s", M_FileError(handle)); fclose(handle); // keep all the command line arguments following @responsefile diff --git a/src/m_argv.h b/src/m_argv.h index d654dcc19..ca97d9b12 100644 --- a/src/m_argv.h +++ b/src/m_argv.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_bbox.c b/src/m_bbox.c index 0c57de43e..02d534164 100644 --- a/src/m_bbox.c +++ b/src/m_bbox.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_bbox.h b/src/m_bbox.h index db5c2b4a7..9b63c61b6 100644 --- a/src/m_bbox.h +++ b/src/m_bbox.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_cheat.c b/src/m_cheat.c index 6fa3ea113..93e8f2911 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -61,7 +61,7 @@ static UINT8 cheatf_ultimate(void) if (menuactive && (currentMenu != &MainDef && currentMenu != &SP_LoadDef)) return 0; // Only on the main menu, or the save select! - S_StartSound(0, sfx_itemup); + BwehHehHe(); ultimate_selectable = (!ultimate_selectable); // If on the save select, move to what is now Ultimate Mode! @@ -82,9 +82,9 @@ static UINT8 cheatf_warp(void) // Temporarily unlock stuff. G_SetGameModified(false); - unlockables[2].unlocked = true; // credits - unlockables[3].unlocked = true; // sound test - unlockables[16].unlocked = true; // level select + unlockables[31].unlocked = true; // credits + unlockables[30].unlocked = true; // sound test + unlockables[28].unlocked = true; // level select // Refresh secrets menu existing. M_ClearMenus(true); @@ -109,7 +109,7 @@ static UINT8 cheatf_devmode(void) G_SetGameModified(false); for (i = 0; i < MAXUNLOCKABLES; i++) unlockables[i].unlocked = true; - devparm = TRUE; + devparm = true; cv_debug |= 0x8000; // Refresh secrets menu existing. @@ -133,14 +133,14 @@ static cheatseq_t cheat_ultimate_joy = { static cheatseq_t cheat_warp = { 0, cheatf_warp, - { SCRAMBLE('r'), SCRAMBLE('e'), SCRAMBLE('d'), SCRAMBLE('x'), SCRAMBLE('v'), SCRAMBLE('i'), 0xff } + { SCRAMBLE('c'), SCRAMBLE('a'), SCRAMBLE('s'), SCRAMBLE('h'), SCRAMBLE('r'), SCRAMBLE('i'), SCRAMBLE('d'), SCRAMBLE('a'), 0xff } }; static cheatseq_t cheat_warp_joy = { 0, cheatf_warp, - { SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), - SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_UPARROW), - SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_UPARROW), + { SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_DOWNARROW), + SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_LEFTARROW), SCRAMBLE(KEY_DOWNARROW), + SCRAMBLE(KEY_RIGHTARROW), SCRAMBLE(KEY_DOWNARROW), SCRAMBLE(KEY_ENTER), 0xff } }; @@ -353,7 +353,7 @@ void Command_Hurtme_f(void) return; } - P_DamageMobj(players[consoleplayer].mo, NULL, NULL, atoi(COM_Argv(1))); + P_DamageMobj(players[consoleplayer].mo, NULL, NULL, atoi(COM_Argv(1)), 0); } // Moves the NiGHTS player to another axis within the current mare @@ -452,7 +452,7 @@ void Command_RTeleport_f(void) else inty = 0; - ss = R_IsPointInSubsector(p->mo->x + intx*FRACUNIT, p->mo->y + inty*FRACUNIT); + ss = R_PointInSubsectorOrNull(p->mo->x + intx*FRACUNIT, p->mo->y + inty*FRACUNIT); if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height) { CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n")); @@ -493,56 +493,205 @@ void Command_Teleport_f(void) REQUIRE_INLEVEL; REQUIRE_SINGLEPLAYER; - if (COM_Argc() < 3 || COM_Argc() > 7) + if (COM_Argc() < 3 || COM_Argc() > 11) { - CONS_Printf(M_GetText("teleport -x -y -z : teleport to a location\n")); + CONS_Printf(M_GetText("teleport -x -y -z -ang -aim : teleport to a location\nteleport -sp : teleport to specified checkpoint\n")); return; } if (!p->mo) return; - i = COM_CheckParm("-x"); - if (i) - intx = atoi(COM_Argv(i + 1)); - else - { - CONS_Alert(CONS_NOTICE, M_GetText("%s value not specified\n"), "X"); - return; - } - - i = COM_CheckParm("-y"); - if (i) - inty = atoi(COM_Argv(i + 1)); - else - { - CONS_Alert(CONS_NOTICE, M_GetText("%s value not specified\n"), "Y"); - return; - } - - ss = R_PointInSubsector(intx*FRACUNIT, inty*FRACUNIT); - if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height) - { - CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n")); - return; - } - i = COM_CheckParm("-z"); + i = COM_CheckParm("-sp"); if (i) { - intz = atoi(COM_Argv(i + 1)); - intz <<= FRACBITS; - if (intz < ss->sector->floorheight) - intz = ss->sector->floorheight; - if (intz > ss->sector->ceilingheight - p->mo->height) - intz = ss->sector->ceilingheight - p->mo->height; + INT32 starpostnum = atoi(COM_Argv(i + 1)); // starpost number + INT32 starpostpath = atoi(COM_Argv(i + 2)); // quick, dirty way to distinguish between paths + + if (starpostnum < 0 || starpostpath < 0) + { + CONS_Alert(CONS_NOTICE, M_GetText("Negative starpost indexing is not valid.\n")); + return; + } + + if (!starpostnum) // spawnpoints... + { + mapthing_t *mt; + fixed_t offset; + + if (starpostpath >= numcoopstarts) + { + CONS_Alert(CONS_NOTICE, M_GetText("Player %d spawnpoint not found (%d max).\n"), starpostpath+1, numcoopstarts-1); + return; + } + + mt = playerstarts[starpostpath]; // Given above check, should never be NULL. + intx = mt->x<y<z<sector->ceilingheight - ss->sector->floorheight < p->mo->height) + { + CONS_Alert(CONS_NOTICE, M_GetText("Spawnpoint not in a valid location.\n")); + return; + } + + // Flagging a player's ambush will make them start on the ceiling + // Objectflip inverts + if (!!(mt->options & MTF_AMBUSH) ^ !!(mt->options & MTF_OBJECTFLIP)) + intz = ss->sector->ceilingheight - p->mo->height - offset; + else + intz = ss->sector->floorheight + offset; + + if (mt->options & MTF_OBJECTFLIP) // flip the player! + { + p->mo->eflags |= MFE_VERTICALFLIP; + p->mo->flags2 |= MF2_OBJECTFLIP; + } + else + { + p->mo->eflags &= ~MFE_VERTICALFLIP; + p->mo->flags2 &= ~MF2_OBJECTFLIP; + } + + localangle = p->mo->angle = p->drawangle = FixedAngle(mt->angle<next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_STARPOST) + continue; + + if (mo2->health != starpostnum) + { + if (mo2->health > starpostmax) + starpostmax = mo2->health; + continue; + } + + if (intz--) + continue; + + break; + } + + if (th == &thlist[THINK_MOBJ]) + { + if (intz == starpostpath) + CONS_Alert(CONS_NOTICE, M_GetText("No starpost of position %d found (%d max).\n"), starpostnum, starpostmax); + else + CONS_Alert(CONS_NOTICE, M_GetText("Starpost of position %d, %d not found (%d, %d max).\n"), starpostnum, starpostpath, starpostmax, (starpostpath-intz)-1); + return; + } + + ss = R_PointInSubsectorOrNull(mo2->x, mo2->y); + if (!ss || ss->sector->ceilingheight - ss->sector->floorheight < p->mo->height) + { + CONS_Alert(CONS_NOTICE, M_GetText("Starpost not in a valid location.\n")); + return; + } + + intx = mo2->x; + inty = mo2->y; + intz = mo2->z; + + if (mo2->flags2 & MF2_OBJECTFLIP) // flip the player! + { + p->mo->eflags |= MFE_VERTICALFLIP; + p->mo->flags2 |= MF2_OBJECTFLIP; + } + else + { + p->mo->eflags &= ~MFE_VERTICALFLIP; + p->mo->flags2 &= ~MF2_OBJECTFLIP; + } + + localangle = p->mo->angle = p->drawangle = mo2->angle; + } + + CONS_Printf(M_GetText("Teleporting to checkpoint %d, %d...\n"), starpostnum, starpostpath); } else - intz = ss->sector->floorheight; + { + i = COM_CheckParm("-nop"); // undocumented stupid addition to allow pivoting on the spot with -ang and -aim + if (i) + { + intx = p->mo->x; + inty = p->mo->y; + } + else + { + i = COM_CheckParm("-x"); + if (i) + intx = atoi(COM_Argv(i + 1))<sector->ceilingheight - ss->sector->floorheight < p->mo->height) + { + CONS_Alert(CONS_NOTICE, M_GetText("Not a valid location.\n")); + return; + } + i = COM_CheckParm("-z"); + if (i) + { + intz = atoi(COM_Argv(i + 1))<sector->floorheight) + intz = ss->sector->floorheight; + if (intz > ss->sector->ceilingheight - p->mo->height) + intz = ss->sector->ceilingheight - p->mo->height; + } + else + intz = ((p->mo->eflags & MFE_VERTICALFLIP) ? ss->sector->ceilingheight : ss->sector->floorheight); + + i = COM_CheckParm("-ang"); + if (i) + localangle = p->drawangle = p->mo->angle = FixedAngle(atoi(COM_Argv(i + 1))<= ANGLE_90 && aim <= ANGLE_270) + { + CONS_Alert(CONS_NOTICE, M_GetText("Not a valid aiming angle (between +/-90).\n")); + return; + } + localaiming = p->aiming = aim; + } + + CONS_Printf(M_GetText("Teleporting to %d, %d, %d...\n"), FixedInt(intx), FixedInt(inty), FixedInt(intz)); + } P_MapStart(); - if (!P_TeleportMove(p->mo, intx*FRACUNIT, inty*FRACUNIT, intz)) + if (!P_TeleportMove(p->mo, intx, inty, intz)) CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n")); else S_StartSound(p->mo, sfx_mixup); @@ -585,6 +734,18 @@ void Command_Weather_f(void) P_SwitchWeather(atoi(COM_Argv(1))); } +void Command_Toggletwod_f(void) +{ + player_t *p = &players[consoleplayer]; + + REQUIRE_DEVMODE; + REQUIRE_INLEVEL; + REQUIRE_SINGLEPLAYER; + + if (p->mo) + p->mo->flags2 ^= MF2_TWOD; +} + #ifdef _DEBUG // You never thought you needed this, did you? >=D // Yes, this has the specific purpose of completely screwing you up @@ -606,12 +767,12 @@ void Command_CauseCfail_f(void) players[consoleplayer].mo->y = 123311; //cfail cansuled kthxbye players[consoleplayer].mo->z = 123311; players[consoleplayer].score = 1337; - players[consoleplayer].health = 1337; + players[consoleplayer].rings = 1337; players[consoleplayer].mo->destscale = 25; P_SetThingPosition(players[consoleplayer].mo); // CTF consistency test - if (gametype == GT_CTF) + if (gametyperules & GTR_TEAMFLAGS) { if (blueflag) { P_RemoveMobj(blueflag); @@ -627,7 +788,7 @@ void Command_CauseCfail_f(void) } #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#ifdef LUA_ALLOW_BYTECODE void Command_Dumplua_f(void) { if (modifiedgame) @@ -658,6 +819,12 @@ void Command_Savecheckpoint_f(void) players[consoleplayer].starposty = players[consoleplayer].mo->y>>FRACBITS; players[consoleplayer].starpostz = players[consoleplayer].mo->floorz>>FRACBITS; players[consoleplayer].starpostangle = players[consoleplayer].mo->angle; + players[consoleplayer].starpostscale = players[consoleplayer].mo->destscale; + if (players[consoleplayer].mo->flags2 & MF2_OBJECTFLIP) + { + players[consoleplayer].starpostscale *= -1; + players[consoleplayer].starpostz += players[consoleplayer].mo->height; + } CONS_Printf(M_GetText("Temporary checkpoint created at %d, %d, %d\n"), players[consoleplayer].starpostx, players[consoleplayer].starposty, players[consoleplayer].starpostz); } @@ -719,11 +886,19 @@ void Command_Setrings_f(void) if (COM_Argc() > 1) { - // P_GivePlayerRings does value clamping - players[consoleplayer].health = players[consoleplayer].mo->health = 1; - P_GivePlayerRings(&players[consoleplayer], atoi(COM_Argv(1))); - if (!G_IsSpecialStage(gamemap) || !useNightsSS) + if (!(maptol & TOL_NIGHTS)) + { + // P_GivePlayerRings does value clamping + players[consoleplayer].rings = 0; + P_GivePlayerRings(&players[consoleplayer], atoi(COM_Argv(1))); players[consoleplayer].totalring -= atoi(COM_Argv(1)); //undo totalring addition done in P_GivePlayerRings + } + else + { + players[consoleplayer].spheres = 0; + P_GivePlayerSpheres(&players[consoleplayer], atoi(COM_Argv(1))); + // no totalsphere addition to revert + } G_SetGameModified(multiplayer); } @@ -738,9 +913,15 @@ void Command_Setlives_f(void) if (COM_Argc() > 1) { - // P_GivePlayerLives does value clamping - players[consoleplayer].lives = 0; - P_GivePlayerLives(&players[consoleplayer], atoi(COM_Argv(1))); + SINT8 lives = atoi(COM_Argv(1)); + if (lives == -1) + players[consoleplayer].lives = INFLIVES; // infinity! + else + { + // P_GivePlayerLives does value clamping + players[consoleplayer].lives = 0; + P_GivePlayerLives(&players[consoleplayer], atoi(COM_Argv(1))); + } G_SetGameModified(multiplayer); } @@ -773,10 +954,12 @@ void Command_Setcontinues_f(void) static CV_PossibleValue_t op_mapthing_t[] = {{0, "MIN"}, {4095, "MAX"}, {0, NULL}}; static CV_PossibleValue_t op_speed_t[] = {{1, "MIN"}, {128, "MAX"}, {0, NULL}}; static CV_PossibleValue_t op_flags_t[] = {{0, "MIN"}, {15, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t op_hoopflags_t[] = {{0, "MIN"}, {15, "MAX"}, {0, NULL}}; consvar_t cv_mapthingnum = {"op_mapthingnum", "0", CV_NOTINNET, op_mapthing_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_speed = {"op_speed", "16", CV_NOTINNET, op_speed_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_opflags = {"op_flags", "0", CV_NOTINNET, op_flags_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ophoopflags = {"op_hoopflags", "4", CV_NOTINNET, op_hoopflags_t, NULL, 0, NULL, NULL, 0, 0, NULL}; boolean objectplacing = false; mobjtype_t op_currentthing = 0; // For the object placement mode @@ -879,9 +1062,7 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mapthing_t *mt = mapthings; sector_t *sec = player->mo->subsector->sector; -#ifdef HAVE_BLUA LUA_InvalidateMapthings(); -#endif mapthings = Z_Realloc(mapthings, ++nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); @@ -892,15 +1073,16 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c thinker_t *th; mobj_t *mo; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo = (mobj_t *)th; // get offset from mt, which points to old mapthings, then add new location - if (mo->spawnpoint) - mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; + if (!mo->spawnpoint) + continue; + mo->spawnpoint = (mo->spawnpoint - mt) + mapthings; } } @@ -916,7 +1098,7 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c #else fixed_t cheight = sec->ceilingheight; #endif - mt->options = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS); + mt->z = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS); } else { @@ -925,12 +1107,11 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c #else fixed_t fheight = sec->floorheight; #endif - mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS); + mt->z = (UINT16)((player->mo->z - fheight)>>FRACBITS); } - mt->options <<= ZSHIFT; mt->angle = (INT16)(FixedInt(AngleFixed(player->mo->angle))); - mt->options |= (UINT16)cv_opflags.value; + mt->options = (mt->z << ZSHIFT) | (UINT16)cv_opflags.value; return mt; } @@ -942,7 +1123,7 @@ boolean OP_FreezeObjectplace(void) if (!objectplacing) return false; - if ((maptol & TOL_NIGHTS) && (players[consoleplayer].pflags & PF_NIGHTSMODE)) + if ((maptol & TOL_NIGHTS) && (players[consoleplayer].powers[pw_carry] == CR_NIGHTSMODE)) return false; return true; @@ -968,7 +1149,7 @@ void OP_NightsObjectplace(player_t *player) if (player->pflags & PF_ATTACKDOWN) { // Are ANY objectplace buttons pressed? If no, remove flag. - if (!(cmd->buttons & (BT_ATTACK|BT_TOSSFLAG|BT_USE|BT_CAMRIGHT|BT_CAMLEFT))) + if (!(cmd->buttons & (BT_ATTACK|BT_TOSSFLAG|BT_USE|BT_WEAPONNEXT|BT_WEAPONPREV))) player->pflags &= ~PF_ATTACKDOWN; // Do nothing. @@ -980,17 +1161,10 @@ void OP_NightsObjectplace(player_t *player) { UINT16 angle = (UINT16)(player->anotherflyangle % 360); INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle - sector_t *sec = player->mo->subsector->sector; -#ifdef ESLOPE - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; -#else - fixed_t fheight = sec->floorheight; -#endif - player->pflags |= PF_ATTACKDOWN; - mt = OP_CreateNewMapThing(player, 1705, false); + mt = OP_CreateNewMapThing(player, 1713, false); // Tilt mt->angle = (INT16)FixedInt(FixedDiv(angle*FRACUNIT, 360*(FRACUNIT/256))); @@ -1001,43 +1175,84 @@ void OP_NightsObjectplace(player_t *player) temp += 90; temp %= 360; - mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS); + mt->options = (mt->options & ~(UINT16)cv_opflags.value) | (UINT16)cv_ophoopflags.value; mt->angle = (INT16)(mt->angle+(INT16)((FixedInt(FixedDiv(temp*FRACUNIT, 360*(FRACUNIT/256))))<<8)); - P_SpawnHoopsAndRings(mt); + P_SpawnHoop(mt); } // This places a bumper! if (cmd->buttons & BT_TOSSFLAG) { + UINT16 vertangle = (UINT16)(player->anotherflyangle % 360); + UINT16 newflags; + player->pflags |= PF_ATTACKDOWN; if (!OP_HeightOkay(player, false)) return; mt = OP_CreateNewMapThing(player, (UINT16)mobjinfo[MT_NIGHTSBUMPER].doomednum, false); + mt->z = min(mt->z - (mobjinfo[MT_NIGHTSBUMPER].height/4), 0); + // height offset: from P_TouchSpecialThing case MT_NIGHTSBUMPER + + // clockwise + if (vertangle >= 75 && vertangle < 105) // up + newflags = 3; + else if (vertangle >= 105 && vertangle < 135) // 60 upward tilt + newflags = 2; + else if (vertangle >= 135 && vertangle < 165) // 30 upward tilt + newflags = 1; + //else if (vertangle >= 165 && vertangle < 195) // forward, see else case + // newflags = 0; + else if (vertangle >= 195 && vertangle < 225) // 30 downward tilt + newflags = 11; + else if (vertangle >= 225 && vertangle < 255) // 60 downward tilt + newflags = 10; + else if (vertangle >= 255 && vertangle < 285) // down + newflags = 9; + else if (vertangle >= 285 && vertangle < 315) // 60 downward tilt backwards + newflags = 8; + else if (vertangle >= 315 && vertangle < 345) // 30 downward tilt backwards + newflags = 7; + else if (vertangle >= 345 || vertangle < 15) // backwards + newflags = 6; + else if (vertangle >= 15 && vertangle < 45) // 30 upward tilt backwards + newflags = 5; + else if (vertangle >= 45 && vertangle < 75) // 60 upward tilt backwards + newflags = 4; + else // forward + newflags = 0; + + mt->options = (mt->z << ZSHIFT) | newflags; + + // if NiGHTS is facing backwards, orient the Thing angle forwards so that the sprite angle + // displays correctly. Backwards movement via the Thing flags is unaffected. + if (vertangle < 90 || vertangle > 270) + mt->angle = (mt->angle + 180) % 360; + + P_SpawnMapThing(mt); + } + + // This places a sphere! + if (cmd->buttons & BT_WEAPONNEXT) + { + player->pflags |= PF_ATTACKDOWN; + if (!OP_HeightOkay(player, false)) + return; + + mt = OP_CreateNewMapThing(player, (UINT16)mobjinfo[MT_BLUESPHERE].doomednum, false); P_SpawnMapThing(mt); } // This places a ring! - if (cmd->buttons & BT_CAMRIGHT) + if (cmd->buttons & BT_WEAPONPREV) { player->pflags |= PF_ATTACKDOWN; if (!OP_HeightOkay(player, false)) return; mt = OP_CreateNewMapThing(player, (UINT16)mobjinfo[MT_RING].doomednum, false); - P_SpawnHoopsAndRings(mt); - } - - // This places a wing item! - if (cmd->buttons & BT_CAMLEFT) - { - player->pflags |= PF_ATTACKDOWN; - if (!OP_HeightOkay(player, false)) - return; - - mt = OP_CreateNewMapThing(player, (UINT16)mobjinfo[MT_NIGHTSWING].doomednum, false); - P_SpawnHoopsAndRings(mt); + P_SpawnMapThing(mt); } // This places a custom object as defined in the console cv_mapthingnum. @@ -1054,7 +1269,7 @@ void OP_NightsObjectplace(player_t *player) if (!OP_HeightOkay(player, false)) return; - if (player->mo->target->flags & MF_AMBUSH) + if (player->mo->target->flags2 & MF2_AMBUSH) angle = (UINT16)player->anotherflyangle; else { @@ -1069,15 +1284,10 @@ void OP_NightsObjectplace(player_t *player) mt = OP_CreateNewMapThing(player, (UINT16)cv_mapthingnum.value, false); mt->angle = angle; - if (mt->type == 300 // Ring - || mt->type == 308 || mt->type == 309 // Team Rings - || mt->type == 1706 // Nights Wing - || (mt->type >= 600 && mt->type <= 609) // Placement patterns - || mt->type == 1705 || mt->type == 1713 // NiGHTS Hoops - || mt->type == 1800) // Mario Coin - { - P_SpawnHoopsAndRings(mt); - } + if (mt->type >= 600 && mt->type <= 609) // Placement patterns + P_SpawnItemPattern(mt, false); + else if (mt->type == 1705 || mt->type == 1713) // NiGHTS Hoops + P_SpawnHoop(mt); else P_SpawnMapThing(mt); } @@ -1092,8 +1302,8 @@ void OP_ObjectplaceMovement(player_t *player) { ticcmd_t *cmd = &player->cmd; - if (!player->climbing && (netgame || !cv_analog.value || (player->pflags & PF_SPINNING))) - player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + if (!player->climbing && (netgame || !cv_analog[0].value || (player->pflags & PF_SPINNING))) + player->drawangle = player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); ticruned++; if (!(cmd->angleturn & TICCMD_RECEIVED)) @@ -1129,7 +1339,7 @@ void OP_ObjectplaceMovement(player_t *player) // make sure viewz follows player if in 1st person mode player->deltaviewheight = 0; - player->viewheight = FixedMul(cv_viewheight.value << FRACBITS, player->mo->scale); + player->viewheight = FixedMul(41*player->height/48, player->mo->scale); if (player->mo->eflags & MFE_VERTICALFLIP) player->viewz = player->mo->z + player->mo->height - player->viewheight; else @@ -1165,19 +1375,20 @@ void OP_ObjectplaceMovement(player_t *player) if (player->pflags & PF_ATTACKDOWN) { // Are ANY objectplace buttons pressed? If no, remove flag. - if (!(cmd->buttons & (BT_ATTACK|BT_TOSSFLAG|BT_CAMRIGHT|BT_CAMLEFT))) + if (!(cmd->buttons & (BT_ATTACK|BT_TOSSFLAG|BT_WEAPONNEXT|BT_WEAPONPREV))) player->pflags &= ~PF_ATTACKDOWN; // Do nothing. return; } - if (cmd->buttons & BT_CAMLEFT) + if (cmd->buttons & BT_WEAPONPREV) { OP_CycleThings(-1); player->pflags |= PF_ATTACKDOWN; } - else if (cmd->buttons & BT_CAMRIGHT) + + if (cmd->buttons & BT_WEAPONNEXT) { OP_CycleThings(1); player->pflags |= PF_ATTACKDOWN; @@ -1213,19 +1424,14 @@ void OP_ObjectplaceMovement(player_t *player) return; mt = OP_CreateNewMapThing(player, (UINT16)spawnthing, ceiling); - if (mt->type == 300 // Ring - || mt->type == 308 || mt->type == 309 // Team Rings - || mt->type == 1706 // Nights Wing - || (mt->type >= 600 && mt->type <= 609) // Placement patterns - || mt->type == 1705 || mt->type == 1713 // NiGHTS Hoops - || mt->type == 1800) // Mario Coin - { - P_SpawnHoopsAndRings(mt); - } + if (mt->type >= 600 && mt->type <= 609) // Placement patterns + P_SpawnItemPattern(mt, false); + else if (mt->type == 1705 || mt->type == 1713) // NiGHTS Hoops + P_SpawnHoop(mt); else P_SpawnMapThing(mt); - CONS_Printf(M_GetText("Placed object type %d at %d, %d, %d, %d\n"), mt->type, mt->x, mt->y, mt->options>>ZSHIFT, mt->angle); + CONS_Printf(M_GetText("Placed object type %d at %d, %d, %d, %d\n"), mt->type, mt->x, mt->y, mt->z, mt->angle); } } @@ -1254,20 +1460,20 @@ void Command_ObjectPlace_f(void) { objectplacing = true; - if ((players[0].pflags & PF_NIGHTSMODE)) + if (players[0].powers[pw_carry] == CR_NIGHTSMODE) return; if (!COM_CheckParm("-silent")) { - HU_SetCEchoFlags(V_RETURN8|V_MONOSPACE); + HU_SetCEchoFlags(V_RETURN8|V_MONOSPACE|V_AUTOFADEOUT); HU_SetCEchoDuration(10); HU_DoCEcho(va(M_GetText( "\\\\\\\\\\\\\\\\\\\\\\\\\x82" " Objectplace Controls: \x80\\\\" - "Camera L/R: Cycle mapthings\\" - " Jump: Float up \\" - " Spin: Float down \\" - " Fire Ring: Place object \\"))); + "Weapon Next/Prev: Cycle mapthings\\" + " Jump: Float up \\" + " Spin: Float down \\" + " Fire Ring: Place object \\"))); } // Save all the player's data. @@ -1297,7 +1503,7 @@ void Command_ObjectPlace_f(void) // Like the classics, recover from death by entering objectplace if (players[0].mo->health <= 0) { - players[0].mo->health = players[0].health = 1; + players[0].mo->health = 1; players[0].deadtimer = 0; op_oldflags1 = mobjinfo[MT_PLAYER].flags; ++players[0].lives; @@ -1325,7 +1531,7 @@ void Command_ObjectPlace_f(void) // Don't touch the NiGHTS Objectplace stuff. // ... or if the mo mysteriously vanished. - if (!players[0].mo || (players[0].pflags & PF_NIGHTSMODE)) + if (!players[0].mo || (players[0].powers[pw_carry] == CR_NIGHTSMODE)) return; // If still in dummy state, get out of it. diff --git a/src/m_cheat.h b/src/m_cheat.h index bb901af74..ac2540408 100644 --- a/src/m_cheat.h +++ b/src/m_cheat.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,7 +28,7 @@ void cht_Init(void); void Command_ObjectPlace_f(void); void Command_Writethings_f(void); -extern consvar_t cv_opflags, cv_mapthingnum, cv_speed; +extern consvar_t cv_opflags, cv_ophoopflags, cv_mapthingnum, cv_speed; //extern consvar_t cv_snapto, cv_grid; extern boolean objectplacing; @@ -64,10 +64,11 @@ void Command_Teleport_f(void); void Command_RTeleport_f(void); void Command_Skynum_f(void); void Command_Weather_f(void); +void Command_Toggletwod_f(void); #ifdef _DEBUG void Command_CauseCfail_f(void); #endif -#if defined(HAVE_BLUA) && defined(LUA_ALLOW_BYTECODE) +#ifdef LUA_ALLOW_BYTECODE void Command_Dumplua_f(void); #endif diff --git a/src/m_cond.c b/src/m_cond.c index 4c824b180..0abc7adf8 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -18,7 +18,7 @@ #include "v_video.h" // video flags #include "g_game.h" // record info -#include "r_things.h" // numskins +#include "r_skins.h" // numskins #include "r_draw.h" // R_GetColorByName // Map triggers for linedef executors @@ -28,652 +28,18 @@ UINT32 unlocktriggers; // The meat of this system lies in condition sets conditionset_t conditionSets[MAXCONDITIONSETS]; -// Default Emblem locations -emblem_t emblemlocations[MAXEMBLEMS] = -{ - // GREEN FLOWER 1 - // --- - {0, 8156, 6936, 129, 1, 'A', SKINCOLOR_BLUE, 0, - "Go get your feet wet\n" - "to find this, the first emblem.\n" - "Yes, it's very deep.", 0}, - {0, 3184, 1812, 928, 1, 'B', SKINCOLOR_LAVENDER, 0, - "There are many rings,\n" - "but this one's not what you think.\n" - "There lies the emblem.", 0}, - {0, 9024, 6716, 769, 1, 'C', SKINCOLOR_RED, 0, - "Right next to a lake,\n" - "a ledge has been constructed.\n" - "Near there is the goal.", 0}, - {0, 2080, -384, 512, 1, 'D', SKINCOLOR_ORANGE, 0, - "Streams come to an end\n" - "where they can no longer fall.\n" - "But if you went up...", 0}, - {0, -336, 2064, 195, 1, 'E', SKINCOLOR_NEONGREEN, 0, - "This one's in plain sight.\n" - "Why haven't you claimed it?\n" - "Surely you saw it.", 0}, +// Emblem locations +emblem_t emblemlocations[MAXEMBLEMS]; - {ET_SCORE, 0,0,0, 1, 'S', SKINCOLOR_BROWN, 125000, "", 0}, - {ET_TIME, 0,0,0, 1, 'T', SKINCOLOR_GREY, 20*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 1, 'R', SKINCOLOR_GOLD, 200, "", 0}, +// Extra emblems +extraemblem_t extraemblems[MAXEXTRAEMBLEMS]; +// Unlockables +unlockable_t unlockables[MAXUNLOCKABLES]; - // GREEN FLOWER 2 - // --- - {0, 2624, -6816, 1332, 2, 'A', SKINCOLOR_BLUE, 0, - "Near the giant lake\n" - "lies a cave with a 1-Up.\n" - "An emblem's there, too!", 0}, - {0, -5728, -2848, 2848, 2, 'B', SKINCOLOR_LAVENDER, 0, - "Near the final lake,\n" - "a higher lake falls on in.\n" - "Three platforms await.", 0}, - {0, 3648, 6464, 2576, 2, 'C', SKINCOLOR_RED, 0, - "Near the level's start,\n" - "a bridge crosses a river.\n" - "What's that river's source?", 0}, - {0, -2032,-10048, 986, 2, 'D', SKINCOLOR_ORANGE, 0, - "Near the level's end,\n" - "another bridge spans a lake.\n" - "What could be under...?", 0}, - {0, -170, 491, 3821, 2, 'E', SKINCOLOR_NEONGREEN, 0, - "An ivied tunnel\n" - "has a corner that's sunlit.\n" - "Go reach for the sky!", 0}, - - {ET_SCORE, 0,0,0, 2, 'S', SKINCOLOR_BROWN, 150000, "", 0}, - {ET_TIME, 0,0,0, 2, 'T', SKINCOLOR_GREY, 40*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 2, 'R', SKINCOLOR_GOLD, 200, "", 0}, - - - // GREEN FLOWER 3 - // --- - {ET_TIME, 0,0,0, 3, 'T', SKINCOLOR_GREY, 30*TICRATE, "", 0}, - - - // TECHNO HILL 1 - // --- - {0, -5664, -5072, 2396, 4, 'A', SKINCOLOR_BLUE, 0, - "Three pipes reside near\n" - "where our heroes' paths split off.\n" - "You'll have to look up!", 0}, - {0, -784,-13968, 2888, 4, 'B', SKINCOLOR_LAVENDER, 0, - "Climbing yields great range.\n" - "Yet, on a path for climbers,\n" - "flying is the key.", 0}, - {0, 4160, -5824, 3776, 4, 'C', SKINCOLOR_RED, 0, - "That's sure lots of slime.\n" - "Say, do you ever wonder\n" - "what's dumping it all?", 0}, - {0, 6400, -8352, 1764, 4, 'D', SKINCOLOR_ORANGE, 0, - "Spinning through small gaps\n" - "can slip you into a cave.\n" - "In that cave's first stretch...", 0}, - {0, 2848, -9088, 488, 4, 'E', SKINCOLOR_NEONGREEN, 0, - "The slime lake is deep,\n" - "but reaching the floor takes height.\n" - "Scream \"Geronimo!\"...", 0}, - - {ET_SCORE, 0,0,0, 4, 'S', SKINCOLOR_BROWN, 75000, "", 0}, - {ET_TIME, 0,0,0, 4, 'T', SKINCOLOR_GREY, 75*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 4, 'R', SKINCOLOR_GOLD, 300, "", 0}, - - - // TECHNO HILL 2 - // --- - {0,-19138, -2692, 688, 5, 'A', SKINCOLOR_BLUE, 0, - "Near the first checkpoint,\n" - "a bridge crosses a slime pool.\n" - "(Sensing a pattern?)", 0}, - {0,-13120, 8062, 1248, 5, 'B', SKINCOLOR_LAVENDER, 0, - "Behind the windows,\n" - "near crushers, ever smashing\n" - "a conveyor belt.", 0}, - {0, 580, 4552, 1344, 5, 'C', SKINCOLOR_RED, 0, - "A pipe drops onto\n" - "a half-outdoors conveyor.\n" - "But is it empty?", 0}, - {0, 192, -8768, 24, 5, 'D', SKINCOLOR_ORANGE, 0, - "There is a hallway\n" - "that a button floods with slime.\n" - "Go through it again!", 0}, - {0, -2468,-12128, 1312, 5, 'E', SKINCOLOR_NEONGREEN, 0, - "Jumping on turtles\n" - "will send you springing skyward.\n" - "Now, do that six times...", 0}, - - {ET_SCORE, 0,0,0, 5, 'S', SKINCOLOR_BROWN, 100000, "", 0}, - {ET_TIME, 0,0,0, 5, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 5, 'R', SKINCOLOR_GOLD, 600, "", 0}, - - - // TECHNO HILL 3 - // --- - {ET_TIME, 0,0,0, 6, 'T', SKINCOLOR_GREY, 40*TICRATE, "", 0}, - - - // DEEP SEA 1 - // --- - {0,-16224, -2880, 3530, 7, 'A', SKINCOLOR_BLUE, 0, - "Climb up two maze walls.\n" - "Break the roof, then a corner.\n" - "There, glide, but stay dry.", 0}, - {0, -8224, 896, 1056, 7, 'B', SKINCOLOR_LAVENDER, 0, - "Follow the left path.\n" - "A square green button lurks deep.\n" - "Weight it down, somehow.", 0}, - {0, 4992, -5072, 4136, 7, 'C', SKINCOLOR_RED, 0, - "A certain path holds\n" - "many gargoyle puzzles.\n" - "Victors reach a \"V\".", 0}, - {0, 4576, 5168, 2660, 7, 'D', SKINCOLOR_ORANGE, 0, - "A caved-in hallway?\n" - "The floor falls; the path goes down.\n" - "But those rocks looked weak...", 0}, - {0, 12576, 16096, -992, 7, 'E', SKINCOLOR_NEONGREEN, 0, - "The end is quite dry.\n" - "Some rocks dam the water in.\n" - "Knuckles can fix that...", 0}, - - {ET_SCORE, 0,0,0, 7, 'S', SKINCOLOR_BROWN, 75000, "", 0}, - {ET_TIME, 0,0,0, 7, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 7, 'R', SKINCOLOR_GOLD, 400, "", 0}, - - - // DEEP SEA 2 - // --- - {0,-15040, 6976, 2016, 8, 'A', SKINCOLOR_BLUE, 0, - "A waterfall lands\n" - "near a starpost in a cave.\n" - "It's dark up there, but...", 0}, - {0, 4288, 2912, 544, 8, 'B', SKINCOLOR_LAVENDER, 0, - "So many blocks here!\n" - "Take five; bathe in the fountain.\n" - "Hmmm? A hidden path...?", 0}, - {0, -5696, 16992, 791, 8, 'C', SKINCOLOR_RED, 0, - "An ornate dragon\n" - "faces a secret passage.\n" - "Knuckles! Don't get crushed!", 0}, - {0,-13344, 18688, 1034, 8, 'D', SKINCOLOR_ORANGE, 0, - "In the current maze\n" - "hides a dark room of columns.\n" - "Find it, then look up.", 0}, - {0, 3104, 16192, 2408, 8, 'E', SKINCOLOR_NEONGREEN, 0, - "That same dragon's eye\n" - "hides another secret room.\n" - "There, solve its riddle.", 0}, - - {ET_SCORE, 0,0,0, 8, 'S', SKINCOLOR_BROWN, 50000, "", 0}, - {ET_TIME, 0,0,0, 8, 'T', SKINCOLOR_GREY, 150*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 8, 'R', SKINCOLOR_GOLD, 250, "", 0}, - - - // DEEP SEA 3 - // --- - {ET_TIME, 0,0,0, 9, 'T', SKINCOLOR_GREY, 90*TICRATE, "", 0}, - - - // CASTLE EGGMAN 1 - // --- - {0, -6176, -5184, -128, 10, 'A', SKINCOLOR_BLUE, 0, - "A drain feeds the lake.\n" - "Water rushes quickly through.\n" - "Go against the flow.", 0}, - {0, 3648,-15296, -992, 10, 'B', SKINCOLOR_LAVENDER, 0, - "The left starting path\n" - "goes atop a large wood deck.\n" - "Checked underneath yet?", 0}, - {0, 11712, 21312, 5472, 10, 'C', SKINCOLOR_RED, 0, - "At last, the castle!\n" - "Hold up! Don't just barge right in!\n" - "What's the facade hold...?", 0}, - {0, 20224, 13344, 3104, 10, 'D', SKINCOLOR_ORANGE, 0, - "The final approach!\n" - "A tower holds the emblem\n" - "near a ring arrow.", 0}, - {0, 9472, -5890, 710, 10, 'E', SKINCOLOR_NEONGREEN, 0, - "The right starting path\n" - "hides this near a canopy,\n" - "high, where two trees meet.", 0}, - - {ET_SCORE, 0,0,0, 10, 'S', SKINCOLOR_BROWN, 50000, "", 0}, - {ET_TIME, 0,0,0, 10, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 10, 'R', SKINCOLOR_GOLD, 200, "", 0}, - - - // CASTLE EGGMAN 2 - // --- - {0, 832,-15168, 7808, 11, 'A', SKINCOLOR_BLUE, 0, - "Find a trick bookcase\n" - "that hides a darkened hallway.\n" - "There, climb a tower.", 0}, - {0,-18460,-22180, 2416, 11, 'B', SKINCOLOR_LAVENDER, 0, - "Down in the dungeon,\n" - "a cracked wall hides secret paths.\n" - "Echidnas only!", 0}, - {0, -6144,-11792, 3232, 11, 'C', SKINCOLOR_RED, 0, - "A room you can flood!\n" - "A brown grate's near its exit.\n" - "Knuckles can break it...", 0}, - {0, 4608, -7024, 4256, 11, 'D', SKINCOLOR_ORANGE, 0, - "Some of these bookshelves\n" - "are not flush against the walls.\n" - "Wonder why that is?", 0}, - {0, 12708,-13536, 4768, 11, 'E', SKINCOLOR_NEONGREEN, 0, - "The ending's towers\n" - "are hiding a small alcove.\n" - "Check around outside.", 0}, - - {ET_SCORE, 0,0,0, 11, 'S', SKINCOLOR_BROWN, 400000, "", 0}, - {ET_TIME, 0,0,0, 11, 'T', SKINCOLOR_GREY, 210*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 11, 'R', SKINCOLOR_GOLD, 600, "", 0}, - - - // CASTLE EGGMAN 3 - // --- - {ET_TIME, 0,0,0, 12, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - - - // ARID CANYON 1 - // --- - {0, 3488, 2208, 3072, 13, 'A', SKINCOLOR_BLUE, 0, - "A rather large gap\n" - "must be crossed by way of tram.\n" - "At its end, jump left.", 0}, - {0, -7552, 10464, 4094, 13, 'B', SKINCOLOR_LAVENDER, 0, - "Crushers that go up!\n" - "Mind your step; if they're triggered,\n" - "they'll block this emblem.", 0}, - {0,-12093, 14575, 5752, 13, 'C', SKINCOLOR_RED, 0, - "There's an oil lake\n" - "that you can sink deep into.\n" - "Drain it, and explore.", 0}, - {0, 512, -7136, 4640, 13, 'D', SKINCOLOR_ORANGE, 0, - "Not far from the start,\n" - "if you climb toward the sky,\n" - "the cliffs hide something.", 0}, - {0, 12504, 6848, 3424, 13, 'E', SKINCOLOR_NEONGREEN, 0, - "Right by the exit,\n" - "an emblem lies on a cliff.\n" - "Ride ropes to reach it.", 0}, - - {ET_SCORE, 0,0,0, 13, 'S', SKINCOLOR_BROWN, 50000, "", 0}, - {ET_TIME, 0,0,0, 13, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 13, 'R', SKINCOLOR_GOLD, 300, "", 0}, - - - // RED VOLCANO 1 - // --- - {0,-13184, 11424, 3080, 16, 'A', SKINCOLOR_BLUE, 0, - "Look around the room,\n" - "just before you clear the stage;\n" - "something's hidden there!", 0}, - {0, -2816, 3120, 3044, 16, 'B', SKINCOLOR_LAVENDER, 0, - "Ever look upwards\n" - "when you're traversing across\n" - "collapsing platforms?", 0}, - {0, 6720, 6784, 1452, 16, 'C', SKINCOLOR_RED, 0, - "Check out a corner\n" - "of a lake of magma near\n" - "spinning jets of flame.", 0}, - {0, -5504, 9824, 800, 16, 'D', SKINCOLOR_ORANGE, 0, - "Where once a bridge stood,\n" - "now magma falls from above.\n" - "The bridge dropped something...", 0}, - {0, 8287,-11043, 1328, 16, 'E', SKINCOLOR_NEONGREEN, 0, - "A lake of magma\n" - "ebbs and flows unendingly.\n" - "Wait for its nadir.", 0}, - - {ET_SCORE, 0,0,0, 16, 'S', SKINCOLOR_BROWN, 30000, "", 0}, - {ET_TIME, 0,0,0, 16, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 16, 'R', SKINCOLOR_GOLD, 100, "", 0}, - - - // EGG ROCK 1 - // --- - {0,-10976, -7328, 1584, 22, 'A', SKINCOLOR_BLUE, 0, - "Vanishing platforms,\n" - "then collapsing ones herald\n" - "a last-second jump.", 0}, - {0, -6592,-11200, 2208, 22, 'B', SKINCOLOR_LAVENDER, 0, - "What is this red stuff?\n" - "You can't breathe it in, but look!\n" - "It can't reach up there...", 0}, - {0, 6816, 832, 936, 22, 'C', SKINCOLOR_RED, 0, - "The team's paths diverge.\n" - "Should Tails run the crusher path?\n" - "No! Fly outside it!", 0}, - {0, 6942, -8902, 2080, 22, 'D', SKINCOLOR_ORANGE, 0, - "Don't jump too high here!\n" - "No conveyor will catch you;\n" - "you'd fall to your death.", 0}, - {0, -6432, -6192, 584, 22, 'E', SKINCOLOR_NEONGREEN, 0, - "Conveyors! Magma!\n" - "What an intense room this is!\n" - "But, what brought you here?", 0}, - - {ET_SCORE, 0,0,0, 22, 'S', SKINCOLOR_BROWN, 25000, "", 0}, - {ET_TIME, 0,0,0, 22, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 22, 'R', SKINCOLOR_GOLD, 150, "", 0}, - - - // EGG ROCK 2 - // --- - {0, -6672, 7792, 352, 23, 'A', SKINCOLOR_BLUE, 0, - "Walk on the ceiling;\n" - "resist the urge to flip back!\n" - "Find the cyan path...", 0}, - {0,-12256, 15136, -288, 23, 'B', SKINCOLOR_LAVENDER, 0, - "X marks the spot? Nope!\n" - "Try standing further away\n" - "when the timer flips.", 0}, - {0, 1536, 16224, 1144, 23, 'C', SKINCOLOR_RED, 0, - "There is more than one\n" - "elevator inside the\n" - "elevator shaft...", 0}, - {0,-15968, 14192, 3152, 23, 'D', SKINCOLOR_ORANGE, 0, - "Gears with missing teeth\n" - "can hide a clever secret!\n" - "Think Green Hill Zone boss.", 0}, - {0, 1920, 20608, 1064, 23, 'E', SKINCOLOR_NEONGREEN, 0, - "Just before you reach\n" - "the defective cargo bay,\n" - "fly under a bridge.", 0}, - - {ET_SCORE, 0,0,0, 23, 'S', SKINCOLOR_BROWN, 60000, "", 0}, - {ET_TIME, 0,0,0, 23, 'T', SKINCOLOR_GREY, 300*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 23, 'R', SKINCOLOR_GOLD, 250, "", 0}, - - - // EGG ROCK 3 - // --- -/* Just in case, I'll leave these here in the source. - {0, 848, -3584, 592, 24, 'A', SKINCOLOR_BLUE, 0, - "[PH] Hiding at the end of the first hallway.", 0}, - {0,-10368, -2816, 144, 24, 'B', SKINCOLOR_LAVENDER, 0, - "Directions are meaningless.", 0}, - {0, -8160, -5952, 560, 24, 'C', SKINCOLOR_RED, 0, - "[PH] In the ceiling of the conveyor belt + laser hallway.", 0}, - {0,-13728,-13728, 1552, 24, 'D', SKINCOLOR_ORANGE, 0, - "[PH] On top of the platform with rows of spikes in reverse gravity.", 0}, - {0,-14944, 768, 1232, 24, 'E', SKINCOLOR_NEONGREEN, 0, - "Follow the leader.", 0}, -*/ - - {ET_SCORE, 0,0,0, 24, 'S', SKINCOLOR_BROWN, 14000, "", 0}, - {ET_TIME, 0,0,0, 24, 'T', SKINCOLOR_GREY, 210*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 24, 'R', SKINCOLOR_GOLD, 100, "", 0}, - - - // EGG ROCK CORE - // --- - {ET_TIME, 0,0,0, 25, 'T', SKINCOLOR_GREY, 100*TICRATE, "", 0}, - - - // PIPE TOWERS - // --- - {0, 3182, 5040, 3008, 30, 'A', SKINCOLOR_BLUE, 0, - "A pipe in the roof\n" - "eternally drops water.\n" - "Something's stuck up there.", 0}, - {0, -2400, 5984, 2752, 30, 'B', SKINCOLOR_LAVENDER, 0, - "Pushing a red switch\n" - "raises the water level;\n" - "from there, can't miss it.", 0}, - {0, 6112, 7008, 4032, 30, 'C', SKINCOLOR_RED, 0, - "A high-up passage\n" - "hides near the second checkpoint.\n" - "Climb in; then, climb more.", 0}, - {0, 11424, -4832, 1376, 30, 'D', SKINCOLOR_ORANGE, 0, - "The underground room\n" - "with platforms that fall and rise\n" - "only LOOKS empty...", 0}, - {0 , 4960, -6112, 1312, 30, 'E', SKINCOLOR_NEONGREEN, 0, - "This one's straightforward.\n" - "What comes to mind when I say:\n" - "\"WELCOME TO WARP ZONE!\"?", 0}, - - {ET_SCORE, 0,0,0, 30, 'S', SKINCOLOR_BROWN, 75000, "", 0}, - {ET_TIME, 0,0,0, 30, 'T', SKINCOLOR_GREY, 100*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 30, 'R', SKINCOLOR_GOLD, 300, "", 0}, - - - // AERIAL GARDEN - // --- - {0, 10176,-14304, 1796, 40, 'A', SKINCOLOR_BLUE, 0, - "A central tower,\n" - "one with many waterfalls,\n" - "hides a secret room.", 0}, - {0, 480, 17696, 6496, 40, 'B', SKINCOLOR_LAVENDER, 0, - "Hidden off the path\n" - "lies a skyscraping tower.\n" - "A lake's at the top.", 0}, - {0, -8896, 13248, 3362, 40, 'C', SKINCOLOR_RED, 0, - "Find all four buttons\n" - "that sink when you stand on them.\n" - "They'll open a door...", 0}, - {0, -8896, -9952, 2480, 40, 'D', SKINCOLOR_ORANGE, 0, - "Much like the last one,\n" - "you need to find some switches.\n" - "Only two, this time.", 0}, - {0, 13184, 18880, 6672, 40, 'E', SKINCOLOR_NEONGREEN, 0, - "The inner sanctum!\n" - "Teleport to its switches;\n" - "then, check near the goal.", 0}, - - {ET_SCORE, 0,0,0, 40, 'S', SKINCOLOR_BROWN, 300000, "", 0}, - {ET_TIME, 0,0,0, 40, 'T', SKINCOLOR_GREY, 240*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 40, 'R', SKINCOLOR_GOLD, 1200, "", 0}, - - - // AZURE TEMPLE - // --- - {0, -2400, 7552, 1120, 41, 'A', SKINCOLOR_BLUE, 0, - "For those who can swim,\n" - "a long tunnel hides rewards.\n" - "Do mind the Buzzes!", 0}, - {0, -64, 14016, 2072, 41, 'B', SKINCOLOR_LAVENDER, 0, - "So many skylights!\n" - "A markedly large one hides\n" - "behind a starpost...", 0}, - {0, 2976, 13920, -32, 41, 'C', SKINCOLOR_RED, 0, - "When you reach gauntlets\n" - "of diagonal fire,\n" - "check out the corners.", 0}, - {0, 2176, 22592, 1376, 41, 'D', SKINCOLOR_ORANGE, 0, - "A room of currents;\n" - "most of them are marked by spikes.\n" - "This one? A corner.", 0}, - {0, -4128, 21344, 1120, 41, 'E', SKINCOLOR_NEONGREEN, 0, - "The only way to hit\n" - "all those gems at once is with\n" - "a radial blast.", 0}, - - {ET_SCORE, 0,0,0, 41, 'S', SKINCOLOR_BROWN, 425000, "", 0}, - {ET_TIME, 0,0,0, 41, 'T', SKINCOLOR_GREY, 240*TICRATE, "", 0}, - {ET_RINGS, 0,0,0, 41, 'R', SKINCOLOR_GOLD, 300, "", 0}, - - - // FLORAL FIELD - // --- - {0, 5394, -996, 160, 50, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 50, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 50, 'T', SKINCOLOR_GREY, 40*TICRATE, "", 0}, - - - // TOXIC PLATEAU - // --- - {0, 780, -1664, 32, 51, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 51, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 51, 'T', SKINCOLOR_GREY, 50*TICRATE, "", 0}, - - - // FLOODED COVE - // --- - {0, 1824, -1888, 2448, 52, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 52, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 52, 'T', SKINCOLOR_GREY, 90*TICRATE, "", 0}, - - - // CAVERN FORTRESS - // --- - {0, -3089, -431, 1328, 53, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 53, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 53, 'T', SKINCOLOR_GREY, 75*TICRATE, "", 0}, - - - // DUSTY WASTELAND - // --- - {0, 957, 924, 2956, 54, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 54, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 54, 'T', SKINCOLOR_GREY, 65*TICRATE, "", 0}, - - - // MAGMA CAVES - // --- - {0, -2752, 3104, 1800, 55, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 55, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 55, 'T', SKINCOLOR_GREY, 80*TICRATE, "", 0}, - - - // EGG SATELLITE - // --- - {0, 5334, -609, 3426, 56, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 56, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 56, 'T', SKINCOLOR_GREY, 120*TICRATE, "", 0}, - - - // BLACK HOLE - // --- - {0, 2108, 3776, 32, 57, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 57, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 57, 'T', SKINCOLOR_GREY, 150*TICRATE, "", 0}, - - - // SPRING HILL - // --- - {0, -1840, -1024, 1644, 58, 'N', SKINCOLOR_ROSEWOOD, 0, "", 0}, - {ET_NGRADE, 0,0,0, 58, 'Q', SKINCOLOR_TEAL, GRADE_A, "", 0}, - {ET_NTIME, 0,0,0, 58, 'T', SKINCOLOR_GREY, 60*TICRATE, "", 0}, -}; - -// Default Extra Emblems -extraemblem_t extraemblems[MAXEXTRAEMBLEMS] = -{ - {"Game Complete", "Complete 1P Mode", 10, 'X', SKINCOLOR_BLUE, 0}, - {"All Emeralds", "Complete 1P Mode with all Emeralds", 11, 'V', SKINCOLOR_GREY, 0}, - {"Perfect Bonus", "Perfect Bonus on a non-secret stage", 30, 'P', SKINCOLOR_GOLD, 0}, - {"SRB1 Remake", "Complete SRB1 Remake", 21, 'O', SKINCOLOR_ROSEWOOD, 0}, - {"NiGHTS Mastery", "Show your mastery of NiGHTS!", 22, 'W', SKINCOLOR_TEAL, 0}, -}; - -// Default Unlockables -unlockable_t unlockables[MAXUNLOCKABLES] = -{ - // Name, Objective, Menu Height, ConditionSet, Unlock Type, Variable, NoCecho, NoChecklist - /* 01 */ {"Record Attack", "Complete Greenflower Zone, Act 1", 0, 1, SECRET_RECORDATTACK, 0, true, true, 0}, - /* 02 */ {"NiGHTS Mode", "Complete Floral Field", 0, 2, SECRET_NIGHTSMODE, 0, true, true, 0}, - - /* 03 */ {"Play Credits", "Complete 1P Mode", 30, 10, SECRET_CREDITS, 0, true, true, 0}, - /* 04 */ {"Sound Test", "Complete 1P Mode", 40, 10, SECRET_SOUNDTEST, 0, false, false, 0}, - - /* 05 */ {"EXTRA LEVELS", "", 60, 0, SECRET_HEADER, 0, true, true, 0}, - - /* 06 */ {"Aerial Garden Zone", "Complete 1P Mode w/ all emeralds", 70, 11, SECRET_WARP, 40, false, false, 0}, - /* 07 */ {"Azure Temple Zone", "Complete Aerial Garden Zone", 80, 20, SECRET_WARP, 41, false, false, 0}, - - /* 08 */ {"BONUS LEVELS", "", 100, 0, SECRET_HEADER, 0, true, true, 0}, - - /* 09 */ {"SRB1 Remake", "Collect 20 Emblems", 130, 40, SECRET_WARP, 101, false, false, 0}, - /* 10 */ {"Mario Koopa Blast", "Collect 60 Emblems", 110, 42, SECRET_WARP, 30, false, false, 0}, - /* 11 */ {"SRB1 Level Select", "Complete SRB1 Remake", 140, 21, SECRET_LEVELSELECT, 2, false, true, 0}, - - /* 12 */ {"Spring Hill Zone", "Collect 100 Emblems", 0, 44, SECRET_NONE, 0, false, false, 0}, - /* 13 */ {"Black Hole", "A Rank in all Special Stages", 0, 50, SECRET_NONE, 0, false, true, 0}, - - /* 14 */ {"Emblem Hints", "Collect 40 Emblems", 0, 41, SECRET_EMBLEMHINTS, 0, false, true, 0}, - /* 15 */ {"Emblem Radar", "Collect 80 Emblems", 0, 43, SECRET_ITEMFINDER, 0, false, true, 0}, - - /* 16 */ {"Pandora's Box", "Collect All Emblems", 0, 45, SECRET_PANDORA, 0, false, false, 0}, - /* 17 */ {"Level Select", "Collect All Emblems", 20, 45, SECRET_LEVELSELECT, 1, false, true, 0}, -}; - -// Default number of emblems and extra emblems -INT32 numemblems = 155; -INT32 numextraemblems = 5; - -// DEFAULT CONDITION SETS FOR SRB2 2.1: -void M_SetupDefaultConditionSets(void) -{ - memset(conditionSets, 0, sizeof(conditionSets)); - - // -- 1: Complete GFZ1 - M_AddRawCondition(1, 1, UC_MAPBEATEN, 1, 0, 0); - - // -- 2: Complete SS1 - M_AddRawCondition(2, 1, UC_MAPBEATEN, 50, 0, 0); - - // -- 10: Complete the game - M_AddRawCondition(10, 1, UC_GAMECLEAR, 1, 0, 0); - - // -- 11: Complete the game with all emeralds - M_AddRawCondition(11, 1, UC_ALLEMERALDS, 1, 0, 0); - - // -- 20: Beat AGZ - M_AddRawCondition(20, 1, UC_MAPBEATEN, 40, 0, 0); - - // -- 21: Beat SRB1 Remake - M_AddRawCondition(21, 1, UC_MAPBEATEN, 132, 0, 0); - - // -- 22: Beat Black Hole - M_AddRawCondition(22, 1, UC_MAPBEATEN, 57, 0, 0); - - // -- 30: Perfect Bonus - M_AddRawCondition(30, 1, UC_MAPPERFECT, 1, 0, 0); - M_AddRawCondition(30, 2, UC_MAPPERFECT, 2, 0, 0); - M_AddRawCondition(30, 3, UC_MAPPERFECT, 4, 0, 0); - M_AddRawCondition(30, 4, UC_MAPPERFECT, 5, 0, 0); - M_AddRawCondition(30, 5, UC_MAPPERFECT, 7, 0, 0); - M_AddRawCondition(30, 6, UC_MAPPERFECT, 8, 0, 0); - M_AddRawCondition(30, 7, UC_MAPPERFECT, 10, 0, 0); - M_AddRawCondition(30, 8, UC_MAPPERFECT, 11, 0, 0); - M_AddRawCondition(30, 9, UC_MAPPERFECT, 13, 0, 0); - M_AddRawCondition(30, 10, UC_MAPPERFECT, 16, 0, 0); - M_AddRawCondition(30, 11, UC_MAPPERFECT, 22, 0, 0); - M_AddRawCondition(30, 12, UC_MAPPERFECT, 23, 0, 0); - M_AddRawCondition(30, 13, UC_MAPPERFECT, 24, 0, 0); - M_AddRawCondition(30, 14, UC_MAPPERFECT, 40, 0, 0); - M_AddRawCondition(30, 15, UC_MAPPERFECT, 41, 0, 0); - - // -- 40: Find 20 emblems - M_AddRawCondition(40, 1, UC_TOTALEMBLEMS, 20, 0, 0); - - // -- 41: Find 40 emblems - M_AddRawCondition(41, 1, UC_TOTALEMBLEMS, 40, 0, 0); - - // -- 42: Find 60 emblems - M_AddRawCondition(42, 1, UC_TOTALEMBLEMS, 60, 0, 0); - - // -- 43: Find 80 emblems - M_AddRawCondition(43, 1, UC_TOTALEMBLEMS, 80, 0, 0); - - // -- 44: Find 100 emblems - M_AddRawCondition(44, 1, UC_TOTALEMBLEMS, 100, 0, 0); - - // -- 45: Find 160 (all) emblems - M_AddRawCondition(45, 1, UC_TOTALEMBLEMS, 160, 0, 0); - - // -- 50: A rank all NiGHTS special stages - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 50, 0); - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 51, 0); - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 52, 0); - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 53, 0); - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 54, 0); - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 55, 0); - M_AddRawCondition(50, 1, UC_NIGHTSGRADE, GRADE_A, 56, 0); -} +// Number of emblems and extra emblems +INT32 numemblems = 0; +INT32 numextraemblems = 0; void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1, INT16 x2) { @@ -874,7 +240,7 @@ UINT8 M_UpdateUnlockablesAndExtraEmblems(void) if (cechoLines) { char slashed[1024] = ""; - for (i = 0; (i < 21) && (i < 24 - cechoLines); ++i) + for (i = 0; (i < 19) && (i < 24 - cechoLines); ++i) slashed[i] = '\\'; slashed[i] = 0; @@ -918,6 +284,8 @@ void M_SilentUpdateUnlockablesAndEmblems(void) continue; unlockables[i].unlocked = M_Achieved(unlockables[i].conditionset - 1); } + + players[consoleplayer].availabilities = players[1].availabilities = R_GetSkinAvailabilities(); // players[1] is supposed to be for 2p } // Emblem unlocking shit @@ -932,7 +300,7 @@ UINT8 M_CheckLevelEmblems(void) // Update Score, Time, Rings emblems for (i = 0; i < numemblems; ++i) { - if (emblemlocations[i].type <= ET_SKIN || emblemlocations[i].collected) + if (emblemlocations[i].type <= ET_SKIN || emblemlocations[i].type == ET_MAP || emblemlocations[i].collected) continue; levelnum = emblemlocations[i].level; @@ -966,6 +334,42 @@ UINT8 M_CheckLevelEmblems(void) return somethingUnlocked; } +UINT8 M_CompletionEmblems(void) // Bah! Duplication sucks, but it's for a separate print when awarding emblems and it's sorta different enough. +{ + INT32 i; + INT32 embtype; + INT16 levelnum; + UINT8 res; + UINT8 somethingUnlocked = 0; + UINT8 flags; + + for (i = 0; i < numemblems; ++i) + { + if (emblemlocations[i].type != ET_MAP || emblemlocations[i].collected) + continue; + + levelnum = emblemlocations[i].level; + embtype = emblemlocations[i].var; + flags = MV_BEATEN; + + if (embtype & ME_ALLEMERALDS) + flags |= MV_ALLEMERALDS; + + if (embtype & ME_ULTIMATE) + flags |= MV_ULTIMATE; + + if (embtype & ME_PERFECT) + flags |= MV_PERFECT; + + res = ((mapvisited[levelnum - 1] & flags) == flags); + + emblemlocations[i].collected = res; + if (res) + ++somethingUnlocked; + } + return somethingUnlocked; +} + // ------------------- // Quick unlock checks // ------------------- @@ -1126,12 +530,22 @@ skincolors_t M_GetEmblemColor(emblem_t *em) return em->color; } -const char *M_GetEmblemPatch(emblem_t *em) +const char *M_GetEmblemPatch(emblem_t *em, boolean big) { - static char pnamebuf[7] = "GOTITn"; + static char pnamebuf[7]; + + if (!big) + strcpy(pnamebuf, "GOTITn"); + else + strcpy(pnamebuf, "EMBMn0"); I_Assert(em->sprite >= 'A' && em->sprite <= 'Z'); - pnamebuf[5] = em->sprite; + + if (!big) + pnamebuf[5] = em->sprite; + else + pnamebuf[4] = em->sprite; + return pnamebuf; } @@ -1142,11 +556,21 @@ skincolors_t M_GetExtraEmblemColor(extraemblem_t *em) return em->color; } -const char *M_GetExtraEmblemPatch(extraemblem_t *em) +const char *M_GetExtraEmblemPatch(extraemblem_t *em, boolean big) { - static char pnamebuf[7] = "GOTITn"; + static char pnamebuf[7]; + + if (!big) + strcpy(pnamebuf, "GOTITn"); + else + strcpy(pnamebuf, "EMBMn0"); I_Assert(em->sprite >= 'A' && em->sprite <= 'Z'); - pnamebuf[5] = em->sprite; + + if (!big) + pnamebuf[5] = em->sprite; + else + pnamebuf[4] = em->sprite; + return pnamebuf; } diff --git a/src/m_cond.h b/src/m_cond.h index 351704064..d7b9704dd 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 2012-2018 by Sonic Team Junior. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 2012-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -66,20 +66,28 @@ typedef struct } conditionset_t; // Emblem information -#define ET_GLOBAL 0 // Global map emblem, var == color -#define ET_SKIN 1 // Skin specific emblem, var == skin -#define ET_SCORE 2 -#define ET_TIME 3 -#define ET_RINGS 4 -#define ET_NGRADE 5 -#define ET_NTIME 6 +#define ET_GLOBAL 0 // Emblem with a position in space +#define ET_SKIN 1 // Skin specific emblem with a position in space, var == skin +#define ET_MAP 2 // Beat the map +#define ET_SCORE 3 // Get the score +#define ET_TIME 4 // Get the time +#define ET_RINGS 5 // Get the rings +#define ET_NGRADE 6 // Get the grade +#define ET_NTIME 7 // Get the time (NiGHTS mode) + +// Global emblem flags +#define GE_NIGHTSPULL 1 // sun off the nights track - loop it +#define GE_NIGHTSITEM 2 // moon on the nights track - find it + +// Map emblem flags +#define ME_ALLEMERALDS 1 +#define ME_ULTIMATE 2 +#define ME_PERFECT 4 typedef struct { UINT8 type; ///< Emblem type - INT16 x; ///< X coordinate. - INT16 y; ///< Y coordinate. - INT16 z; ///< Z coordinate. + INT16 tag; ///< Tag of emblem mapthing INT16 level; ///< Level on which this emblem can be found. UINT8 sprite; ///< emblem sprite to use, 0 - 25 UINT8 color; ///< skincolor to use @@ -89,12 +97,13 @@ typedef struct } emblem_t; typedef struct { - char name[20]; ///< Name of the goal (used in the "emblem awarded" cecho) - char description[40];///< Description of goal (used in statistics) - UINT8 conditionset; ///< Condition set that awards this emblem. - UINT8 sprite; ///< emblem sprite to use, 0 - 25 - UINT8 color; ///< skincolor to use - UINT8 collected; ///< Do you have this emblem? + char name[20]; ///< Name of the goal (used in the "emblem awarded" cecho) + char description[40]; ///< Description of goal (used in statistics) + UINT8 conditionset; ///< Condition set that awards this emblem. + UINT8 showconditionset; ///< Condition set that shows this emblem. + UINT8 sprite; ///< emblem sprite to use, 0 - 25 + UINT8 color; ///< skincolor to use + UINT8 collected; ///< Do you have this emblem? } extraemblem_t; // Unlockable information @@ -104,6 +113,7 @@ typedef struct char objective[64]; UINT16 height; // menu height UINT8 conditionset; + UINT8 showconditionset; INT16 type; INT16 variable; UINT8 nocecho; @@ -140,8 +150,7 @@ extern INT32 numextraemblems; extern UINT32 unlocktriggers; -// Condition Set Setup -void M_SetupDefaultConditionSets(void); +// Condition set setup void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1, INT16 x2); // Clearing secrets @@ -153,6 +162,7 @@ void M_CheckUnlockConditions(void); UINT8 M_UpdateUnlockablesAndExtraEmblems(void); void M_SilentUpdateUnlockablesAndEmblems(void); UINT8 M_CheckLevelEmblems(void); +UINT8 M_CompletionEmblems(void); // Checking unlockable status UINT8 M_AnySecretUnlocked(void); @@ -163,9 +173,9 @@ INT32 M_CountEmblems(void); // Emblem shit emblem_t *M_GetLevelEmblems(INT32 mapnum); skincolors_t M_GetEmblemColor(emblem_t *em); -const char *M_GetEmblemPatch(emblem_t *em); +const char *M_GetEmblemPatch(emblem_t *em, boolean big); skincolors_t M_GetExtraEmblemColor(extraemblem_t *em); -const char *M_GetExtraEmblemPatch(extraemblem_t *em); +const char *M_GetExtraEmblemPatch(extraemblem_t *em, boolean big); // If you're looking to compare stats for unlocks or what not, use these // They stop checking upon reaching the target number so they diff --git a/src/m_dllist.h b/src/m_dllist.h index 18f351144..680c2cd80 100644 --- a/src/m_dllist.h +++ b/src/m_dllist.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2005 by James Haley -// Copyright (C) 2005-2018 by Sonic Team Junior. +// Copyright (C) 2005-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_fixed.c b/src/m_fixed.c index d45bb70bf..eb10fd5f8 100644 --- a/src/m_fixed.c +++ b/src/m_fixed.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -56,7 +56,7 @@ fixed_t FixedDiv2(fixed_t a, fixed_t b) if (b == 0) I_Error("FixedDiv: divide by zero"); - ret = (((INT64)a * FRACUNIT) ) / b; + ret = (((INT64)a * FRACUNIT)) / b; if ((ret > INT32_MAX) || (ret < INT32_MIN)) I_Error("FixedDiv: divide by zero"); @@ -117,7 +117,7 @@ fixed_t FixedHypot(fixed_t x, fixed_t y) yx = FixedDiv(y, x); // (x/y) } yx2 = FixedMul(yx, yx); // (x/y)^2 - yx1 = FixedSqrt(1*FRACUNIT + yx2); // (1 + (x/y)^2)^1/2 + yx1 = FixedSqrt(1 * FRACUNIT + yx2); // (1 + (x/y)^2)^1/2 return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2) } @@ -191,8 +191,8 @@ vector2_t *FV2_Divide(vector2_t *a_i, fixed_t a_c) // Vector Complex Math vector2_t *FV2_Midpoint(const vector2_t *a_1, const vector2_t *a_2, vector2_t *a_o) { - a_o->x = FixedDiv(a_2->x - a_1->x, 2*FRACUNIT); - a_o->y = FixedDiv(a_2->y - a_1->y, 2*FRACUNIT); + a_o->x = FixedDiv(a_2->x - a_1->x, 2 * FRACUNIT); + a_o->y = FixedDiv(a_2->y - a_1->y, 2 * FRACUNIT); a_o->x = a_1->x + a_o->x; a_o->y = a_1->y + a_o->y; return a_o; @@ -200,16 +200,16 @@ vector2_t *FV2_Midpoint(const vector2_t *a_1, const vector2_t *a_2, vector2_t *a fixed_t FV2_Distance(const vector2_t *p1, const vector2_t *p2) { - fixed_t xs = FixedMul(p2->x-p1->x,p2->x-p1->x); - fixed_t ys = FixedMul(p2->y-p1->y,p2->y-p1->y); - return FixedSqrt(xs+ys); + fixed_t xs = FixedMul(p2->x - p1->x, p2->x - p1->x); + fixed_t ys = FixedMul(p2->y - p1->y, p2->y - p1->y); + return FixedSqrt(xs + ys); } fixed_t FV2_Magnitude(const vector2_t *a_normal) { - fixed_t xs = FixedMul(a_normal->x,a_normal->x); - fixed_t ys = FixedMul(a_normal->y,a_normal->y); - return FixedSqrt(xs+ys); + fixed_t xs = FixedMul(a_normal->x, a_normal->x); + fixed_t ys = FixedMul(a_normal->y, a_normal->y); + return FixedSqrt(xs + ys); } // Also returns the magnitude @@ -240,7 +240,7 @@ vector2_t *FV2_Negate(vector2_t *a_1) boolean FV2_Equal(const vector2_t *a_1, const vector2_t *a_2) { - fixed_t Epsilon = FRACUNIT/FRACUNIT; + fixed_t Epsilon = FRACUNIT / FRACUNIT; if ((abs(a_2->x - a_1->x) > Epsilon) || (abs(a_2->y - a_1->y) > Epsilon)) @@ -261,7 +261,7 @@ fixed_t FV2_Dot(const vector2_t *a_1, const vector2_t *a_2) // // Given two points, create a vector between them. // -vector2_t *FV2_Point2Vec (const vector2_t *point1, const vector2_t *point2, vector2_t *a_o) +vector2_t *FV2_Point2Vec(const vector2_t *point1, const vector2_t *point2, vector2_t *a_o) { a_o->x = point1->x - point2->x; a_o->y = point1->y - point2->y; @@ -344,9 +344,9 @@ vector3_t *FV3_Divide(vector3_t *a_i, fixed_t a_c) // Vector Complex Math vector3_t *FV3_Midpoint(const vector3_t *a_1, const vector3_t *a_2, vector3_t *a_o) { - a_o->x = FixedDiv(a_2->x - a_1->x, 2*FRACUNIT); - a_o->y = FixedDiv(a_2->y - a_1->y, 2*FRACUNIT); - a_o->z = FixedDiv(a_2->z - a_1->z, 2*FRACUNIT); + a_o->x = FixedDiv(a_2->x - a_1->x, 2 * FRACUNIT); + a_o->y = FixedDiv(a_2->y - a_1->y, 2 * FRACUNIT); + a_o->z = FixedDiv(a_2->z - a_1->z, 2 * FRACUNIT); a_o->x = a_1->x + a_o->x; a_o->y = a_1->y + a_o->y; a_o->z = a_1->z + a_o->z; @@ -355,18 +355,18 @@ vector3_t *FV3_Midpoint(const vector3_t *a_1, const vector3_t *a_2, vector3_t *a fixed_t FV3_Distance(const vector3_t *p1, const vector3_t *p2) { - fixed_t xs = FixedMul(p2->x-p1->x,p2->x-p1->x); - fixed_t ys = FixedMul(p2->y-p1->y,p2->y-p1->y); - fixed_t zs = FixedMul(p2->z-p1->z,p2->z-p1->z); - return FixedSqrt(xs+ys+zs); + fixed_t xs = FixedMul(p2->x - p1->x, p2->x - p1->x); + fixed_t ys = FixedMul(p2->y - p1->y, p2->y - p1->y); + fixed_t zs = FixedMul(p2->z - p1->z, p2->z - p1->z); + return FixedSqrt(xs + ys + zs); } fixed_t FV3_Magnitude(const vector3_t *a_normal) { - fixed_t xs = FixedMul(a_normal->x,a_normal->x); - fixed_t ys = FixedMul(a_normal->y,a_normal->y); - fixed_t zs = FixedMul(a_normal->z,a_normal->z); - return FixedSqrt(xs+ys+zs); + fixed_t xs = FixedMul(a_normal->x, a_normal->x); + fixed_t ys = FixedMul(a_normal->y, a_normal->y); + fixed_t zs = FixedMul(a_normal->z, a_normal->z); + return FixedSqrt(xs + ys + zs); } // Also returns the magnitude @@ -399,7 +399,7 @@ vector3_t *FV3_Negate(vector3_t *a_1) boolean FV3_Equal(const vector3_t *a_1, const vector3_t *a_2) { - fixed_t Epsilon = FRACUNIT/FRACUNIT; + fixed_t Epsilon = FRACUNIT / FRACUNIT; if ((abs(a_2->x - a_1->x) > Epsilon) || (abs(a_2->y - a_1->y) > Epsilon) || @@ -458,6 +458,20 @@ vector3_t *FV3_ClosestPointOnLine(const vector3_t *Line, const vector3_t *p, vec return FV3_AddEx(&Line[0], &V, out); } +// +// ClosestPointOnVector +// +// Similar to ClosestPointOnLine, but uses a vector instead of two points. +// +void FV3_ClosestPointOnVector(const vector3_t *dir, const vector3_t *p, vector3_t *out) +{ + fixed_t t = FV3_Dot(dir, p); + + // Return the point on the line closest + FV3_MulEx(dir, t, out); + return; +} + // // ClosestPointOnTriangle // @@ -465,7 +479,7 @@ vector3_t *FV3_ClosestPointOnLine(const vector3_t *Line, const vector3_t *p, vec // the closest point on the edge of // the triangle is returned. // -void FV3_ClosestPointOnTriangle (const vector3_t *tri, const vector3_t *point, vector3_t *result) +void FV3_ClosestPointOnTriangle(const vector3_t *tri, const vector3_t *point, vector3_t *result) { UINT8 i; fixed_t dist, closestdist; @@ -506,7 +520,7 @@ void FV3_ClosestPointOnTriangle (const vector3_t *tri, const vector3_t *point, v // // Given two points, create a vector between them. // -vector3_t *FV3_Point2Vec (const vector3_t *point1, const vector3_t *point2, vector3_t *a_o) +vector3_t *FV3_Point2Vec(const vector3_t *point1, const vector3_t *point2, vector3_t *a_o) { a_o->x = point1->x - point2->x; a_o->y = point1->y - point2->y; @@ -519,7 +533,7 @@ vector3_t *FV3_Point2Vec (const vector3_t *point1, const vector3_t *point2, vect // // Calculates the normal of a polygon. // -void FV3_Normal (const vector3_t *a_triangle, vector3_t *a_normal) +fixed_t FV3_Normal(const vector3_t *a_triangle, vector3_t *a_normal) { vector3_t a_1; vector3_t a_2; @@ -529,7 +543,28 @@ void FV3_Normal (const vector3_t *a_triangle, vector3_t *a_normal) FV3_Cross(&a_1, &a_2, a_normal); - FV3_NormalizeEx(a_normal, a_normal); + return FV3_NormalizeEx(a_normal, a_normal); +} + +// +// Strength +// +// Measures the 'strength' of a vector in a particular direction. +// +fixed_t FV3_Strength(const vector3_t *a_1, const vector3_t *dir) +{ + vector3_t normal; + fixed_t dist = FV3_NormalizeEx(a_1, &normal); + fixed_t dot = FV3_Dot(&normal, dir); + + FV3_ClosestPointOnVector(dir, a_1, &normal); + + dist = FV3_Magnitude(&normal); + + if (dot < 0) // Not facing same direction, so negate result. + dist = -dist; + + return dist; } // @@ -550,11 +585,11 @@ boolean FV3_IntersectedPlane(const vector3_t *a_triangle, const vector3_t *a_lin *originDistance = FV3_PlaneDistance(a_normal, &a_triangle[0]); - distance1 = (FixedMul(a_normal->x, a_line[0].x) + FixedMul(a_normal->y, a_line[0].y) - + FixedMul(a_normal->z, a_line[0].z)) + *originDistance; + distance1 = (FixedMul(a_normal->x, a_line[0].x) + FixedMul(a_normal->y, a_line[0].y) + + FixedMul(a_normal->z, a_line[0].z)) + *originDistance; - distance2 = (FixedMul(a_normal->x, a_line[1].x) + FixedMul(a_normal->y, a_line[1].y) - + FixedMul(a_normal->z, a_line[1].z)) + *originDistance; + distance2 = (FixedMul(a_normal->x, a_line[1].x) + FixedMul(a_normal->y, a_line[1].y) + + FixedMul(a_normal->z, a_line[1].z)) + *originDistance; // Positive or zero number means no intersection if (FixedMul(distance1, distance2) >= 0) @@ -575,8 +610,8 @@ boolean FV3_IntersectedPlane(const vector3_t *a_triangle, const vector3_t *a_lin fixed_t FV3_PlaneIntersection(const vector3_t *pOrigin, const vector3_t *pNormal, const vector3_t *rOrigin, const vector3_t *rVector) { fixed_t d = -(FV3_Dot(pNormal, pOrigin)); - fixed_t number = FV3_Dot(pNormal,rOrigin) + d; - fixed_t denom = FV3_Dot(pNormal,rVector); + fixed_t number = FV3_Dot(pNormal, rOrigin) + d; + fixed_t denom = FV3_Dot(pNormal, rVector); return -FixedDiv(number, denom); } @@ -597,11 +632,11 @@ fixed_t FV3_IntersectRaySphere(const vector3_t *rO, const vector3_t *rV, const v c = FV3_Magnitude(&Q); v = FV3_Dot(&Q, rV); - d = FixedMul(sR, sR) - (FixedMul(c,c) - FixedMul(v,v)); + d = FixedMul(sR, sR) - (FixedMul(c, c) - FixedMul(v, v)); // If there was no intersection, return -1 - if (d < 0*FRACUNIT) - return (-1*FRACUNIT); + if (d < 0 * FRACUNIT) + return (-1 * FRACUNIT); // Return the distance to the [first] intersecting point return (v - FixedSqrt(d)); @@ -629,9 +664,9 @@ vector3_t *FV3_IntersectionPoint(const vector3_t *vNormal, const vector3_t *vLin // Here I just chose a arbitrary point as the point to find that distance. You notice we negate that // distance. We negate the distance because we want to eventually go BACKWARDS from our point to the plane. // By doing this is will basically bring us back to the plane to find our intersection point. - Numerator = - (FixedMul(vNormal->x, vLine[0].x) + // Use the plane equation with the normal and the line - FixedMul(vNormal->y, vLine[0].y) + - FixedMul(vNormal->z, vLine[0].z) + distance); + Numerator = -(FixedMul(vNormal->x, vLine[0].x) + // Use the plane equation with the normal and the line + FixedMul(vNormal->y, vLine[0].y) + + FixedMul(vNormal->z, vLine[0].z) + distance); // 3) If we take the dot product between our line vector and the normal of the polygon, // this will give us the cosine of the angle between the 2 (since they are both normalized - length 1). @@ -643,7 +678,7 @@ vector3_t *FV3_IntersectionPoint(const vector3_t *vNormal, const vector3_t *vLin // on the plane (the normal is perpendicular to the line - (Normal.Vector = 0)). // In this case, we should just return any point on the line. - if( Denominator == 0*FRACUNIT) // Check so we don't divide by zero + if (Denominator == 0 * FRACUNIT) // Check so we don't divide by zero { ReturnVec->x = vLine[0].x; ReturnVec->y = vLine[0].y; @@ -686,8 +721,8 @@ vector3_t *FV3_IntersectionPoint(const vector3_t *vNormal, const vector3_t *vLin // UINT8 FV3_PointOnLineSide(const vector3_t *point, const vector3_t *line) { - fixed_t s1 = FixedMul((point->y - line[0].y),(line[1].x - line[0].x)); - fixed_t s2 = FixedMul((point->x - line[0].x),(line[1].y - line[0].y)); + fixed_t s1 = FixedMul((point->y - line[0].y), (line[1].x - line[0].x)); + fixed_t s2 = FixedMul((point->x - line[0].x), (line[1].y - line[0].y)); return (UINT8)(s1 - s2 < 0); } @@ -752,7 +787,7 @@ void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fi matrix->m[0] = upcross.x; matrix->m[1] = upcross.y; matrix->m[2] = upcross.z; - matrix->m[3] = 0*FRACUNIT; + matrix->m[3] = 0 * FRACUNIT; matrix->m[4] = upx; matrix->m[5] = upy; @@ -764,9 +799,9 @@ void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fi matrix->m[10] = anglez; matrix->m[11] = 0; - matrix->m[12] = x - FixedMul(upx,radius); - matrix->m[13] = y - FixedMul(upy,radius); - matrix->m[14] = z - FixedMul(upz,radius); + matrix->m[12] = x - FixedMul(upx, radius); + matrix->m[13] = y - FixedMul(upy, radius); + matrix->m[14] = z - FixedMul(upz, radius); matrix->m[15] = FRACUNIT; } @@ -778,20 +813,20 @@ void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fi void FM_MultMatrixVec3(const matrix_t *matrix, const vector3_t *vec, vector3_t *out) { #define M(row,col) matrix->m[col * 4 + row] - out->x = FixedMul(vec->x,M(0, 0)) - + FixedMul(vec->y,M(0, 1)) - + FixedMul(vec->z,M(0, 2)) - + M(0, 3); + out->x = FixedMul(vec->x, M(0, 0)) + + FixedMul(vec->y, M(0, 1)) + + FixedMul(vec->z, M(0, 2)) + + M(0, 3); - out->y = FixedMul(vec->x,M(1, 0)) - + FixedMul(vec->y,M(1, 1)) - + FixedMul(vec->z,M(1, 2)) - + M(1, 3); + out->y = FixedMul(vec->x, M(1, 0)) + + FixedMul(vec->y, M(1, 1)) + + FixedMul(vec->z, M(1, 2)) + + M(1, 3); - out->z = FixedMul(vec->x,M(2, 0)) - + FixedMul(vec->y,M(2, 1)) - + FixedMul(vec->z,M(2, 2)) - + M(2, 3); + out->z = FixedMul(vec->x, M(2, 0)) + + FixedMul(vec->y, M(2, 1)) + + FixedMul(vec->z, M(2, 2)) + + M(2, 3); #undef M } @@ -811,7 +846,7 @@ void FM_MultMatrix(matrix_t *dest, const matrix_t *multme) for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) - R(i, j) = FixedMul(D(i, 0),M(0, j)) + FixedMul(D(i, 1),M(1, j)) + FixedMul(D(i, 2),M(2, j)) + FixedMul(D(i, 3),M(3, j)); + R(i, j) = FixedMul(D(i, 0), M(0, j)) + FixedMul(D(i, 1), M(1, j)) + FixedMul(D(i, 2), M(2, j)) + FixedMul(D(i, 3), M(3, j)); } M_Memcpy(dest, &result, sizeof(matrix_t)); @@ -869,8 +904,8 @@ void FM_Scale(matrix_t *dest, fixed_t x, fixed_t y, fixed_t z) static inline void M_print(INT64 a) { - const fixed_t w = (a>>FRACBITS); - fixed_t f = a%FRACUNIT; + const fixed_t w = (a >> FRACBITS); + fixed_t f = a % FRACUNIT; fixed_t d = FRACUNIT; if (f == 0) @@ -878,7 +913,7 @@ static inline void M_print(INT64 a) printf("%d", (fixed_t)w); return; } - else while (f != 1 && f/2 == f>>1) + else while (f != 1 && f / 2 == f >> 1) { d /= 2; f /= 2; @@ -892,7 +927,7 @@ static inline void M_print(INT64 a) FUNCMATH FUNCINLINE static inline fixed_t FixedMulC(fixed_t a, fixed_t b) { - return (fixed_t)((((INT64)a * b) ) / FRACUNIT); + return (fixed_t)((((INT64)a * b)) / FRACUNIT); } FUNCMATH FUNCINLINE static inline fixed_t FixedDivC2(fixed_t a, fixed_t b) @@ -902,7 +937,7 @@ FUNCMATH FUNCINLINE static inline fixed_t FixedDivC2(fixed_t a, fixed_t b) if (b == 0) I_Error("FixedDiv: divide by zero"); - ret = (((INT64)a * FRACUNIT) ) / b; + ret = (((INT64)a * FRACUNIT)) / b; if ((ret > INT32_MAX) || (ret < INT32_MIN)) I_Error("FixedDiv: divide by zero"); @@ -911,7 +946,7 @@ FUNCMATH FUNCINLINE static inline fixed_t FixedDivC2(fixed_t a, fixed_t b) FUNCMATH FUNCINLINE static inline fixed_t FixedDivC(fixed_t a, fixed_t b) { - if ((abs(a) >> (FRACBITS-2)) >= abs(b)) + if ((abs(a) >> (FRACBITS - 2)) >= abs(b)) return (a^b) < 0 ? INT32_MIN : INT32_MAX; return FixedDivC2(a, b); @@ -938,43 +973,43 @@ int main(int argc, char** argv) #ifdef MULDIV_TEST for (a = 1; a <= INT32_MAX; a += FRACUNIT) - for (b = 0; b <= INT32_MAX; b += FRACUNIT) - { - c = FixedMul(a, b); - d = FixedMulC(a, b); - if (c != d) + for (b = 0; b <= INT32_MAX; b += FRACUNIT) { - printf("("); - M_print(a); - printf(") * ("); - M_print(b); - printf(") = ("); - M_print(c); - printf(") != ("); - M_print(d); - printf(") \n"); - n--; - printf("%d != %d\n", c, d); + c = FixedMul(a, b); + d = FixedMulC(a, b); + if (c != d) + { + printf("("); + M_print(a); + printf(") * ("); + M_print(b); + printf(") = ("); + M_print(c); + printf(") != ("); + M_print(d); + printf(") \n"); + n--; + printf("%d != %d\n", c, d); + } + c = FixedDiv(a, b); + d = FixedDivC(a, b); + if (c != d) + { + printf("("); + M_print(a); + printf(") / ("); + M_print(b); + printf(") = ("); + M_print(c); + printf(") != ("); + M_print(d); + printf(")\n"); + n--; + printf("%d != %d\n", c, d); + } + if (n <= 0) + exit(-1); } - c = FixedDiv(a, b); - d = FixedDivC(a, b); - if (c != d) - { - printf("("); - M_print(a); - printf(") / ("); - M_print(b); - printf(") = ("); - M_print(c); - printf(") != ("); - M_print(d); - printf(")\n"); - n--; - printf("%d != %d\n", c, d); - } - if (n <= 0) - exit(-1); - } #endif #ifdef SQRT_TEST @@ -982,7 +1017,7 @@ int main(int argc, char** argv) { c = FixedSqrt(a); d = FixedSqrtC(a); - b = abs(c-d); + b = abs(c - d); if (b > 1) { printf("sqrt("); diff --git a/src/m_fixed.h b/src/m_fixed.h index 4609913b7..7fdb9ad0a 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -20,11 +20,6 @@ #include #endif -// Was this just for the #define USEASM? -//#ifdef _WIN32_WCE -//#include "sdl12/SRB2CE/cehelp.h" -//#endif - /*! \brief bits of the fraction */ @@ -206,14 +201,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b) */ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRem(fixed_t x, fixed_t y) { - const boolean n = x < 0; - x = abs(x); - while (x >= y) - x -= y; - if (n) - return -x; - else - return x; + return x % y; } /** \brief The FixedSqrt function @@ -394,9 +382,11 @@ boolean FV3_Equal(const vector3_t *a_1, const vector3_t *a_2); fixed_t FV3_Dot(const vector3_t *a_1, const vector3_t *a_2); vector3_t *FV3_Cross(const vector3_t *a_1, const vector3_t *a_2, vector3_t *a_o); vector3_t *FV3_ClosestPointOnLine(const vector3_t *Line, const vector3_t *p, vector3_t *out); +void FV3_ClosestPointOnVector(const vector3_t *dir, const vector3_t *p, vector3_t *out); void FV3_ClosestPointOnTriangle(const vector3_t *tri, const vector3_t *point, vector3_t *result); vector3_t *FV3_Point2Vec(const vector3_t *point1, const vector3_t *point2, vector3_t *a_o); -void FV3_Normal(const vector3_t *a_triangle, vector3_t *a_normal); +fixed_t FV3_Normal(const vector3_t *a_triangle, vector3_t *a_normal); +fixed_t FV3_Strength(const vector3_t *a_1, const vector3_t *dir); fixed_t FV3_PlaneDistance(const vector3_t *a_normal, const vector3_t *a_point); boolean FV3_IntersectedPlane(const vector3_t *a_triangle, const vector3_t *a_line, vector3_t *a_normal, fixed_t *originDistance); fixed_t FV3_PlaneIntersection(const vector3_t *pOrigin, const vector3_t *pNormal, const vector3_t *rOrigin, const vector3_t *rVector); diff --git a/src/m_menu.c b/src/m_menu.c index c241a0880..84ee898d6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2011-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -56,6 +56,7 @@ #include "byteptr.h" #include "st_stuff.h" #include "i_sound.h" +#include "fastcmp.h" #include "i_joy.h" // for joystick menu controls @@ -65,19 +66,30 @@ // And just some randomness for the exits. #include "m_random.h" +#if defined(HAVE_SDL) +#include "SDL.h" +#if SDL_VERSION_ATLEAST(2,0,0) +#include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG +#endif +#endif + #ifdef PC_DOS #include // for snprintf int snprintf(char *str, size_t n, const char *fmt, ...); //int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); #endif +#if defined (__GNUC__) && (__GNUC__ >= 4) +#define FIXUPO0 +#endif + #define SKULLXOFF -32 #define LINEHEIGHT 16 #define STRINGHEIGHT 8 #define FONTBHEIGHT 20 #define SMALLLINEHEIGHT 8 -#define SLIDER_RANGE 10 -#define SLIDER_WIDTH (8*SLIDER_RANGE+6) +#define SLIDER_RANGE 9 +#define SLIDER_WIDTH 78 #define SERVERS_PER_PAGE 11 typedef enum @@ -112,43 +124,9 @@ typedef enum const char *quitmsg[NUM_QUITMESSAGES]; // Stuff for customizing the player select screen Tails 09-22-2003 -description_t description[32] = -{ - {"\x82Sonic\x80 is the fastest of the three, but also the hardest to control. Beginners beware, but experts will find Sonic very powerful.\n\n\x82""Ability:\x80 Speed Thok\nDouble jump to zoom forward with a huge burst of speed.\n\n\x82Tip:\x80 Simply letting go of forward does not slow down in SRB2. To slow down, hold the opposite direction.", "", "sonic"}, - {"\x82Tails\x80 is the most mobile of the three, but has the slowest speed. Because of his mobility, he's well-\nsuited to beginners.\n\n\x82""Ability:\x80 Fly\nDouble jump to start flying for a limited time. Repetitively hit the jump button to ascend.\n\n\x82Tip:\x80 To quickly descend while flying, hit the spin button.", "", "tails"}, - {"\x82Knuckles\x80 is well-\nrounded and can destroy breakable walls simply by touching them, but he can't jump as high as the other two.\n\n\x82""Ability:\x80 Glide & Climb\nDouble jump to glide in the air as long as jump is held. Glide into a wall to climb it.\n\n\x82Tip:\x80 Press spin while climbing to jump off the wall; press jump instead to jump off\nand face away from\nthe wall.", "", "knuckles"}, - {"\x82Sonic & Tails\x80 team up to take on Dr. Eggman!\nControl Sonic while Tails desperately struggles to keep up.\n\nPlayer 2 can control Tails directly by setting the controls in the options menu.\nTails's directional controls are relative to Player 1's camera.\n\nTails can pick up Sonic while flying and carry him around.", "CHRS&T", "sonic&tails"}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""}, - {"???", "", ""} -}; +description_t description[MAXSKINS]; +INT16 char_on = -1, startchar = 0; static char *char_notes = NULL; -static fixed_t char_scroll = 0; boolean menuactive = false; boolean fromlevelselect = false; @@ -164,12 +142,14 @@ typedef enum levellist_mode_t levellistmode = LLM_CREATESERVER; UINT8 maplistoption = 0; -static char joystickInfo[8][29]; +static char joystickInfo[MAX_JOYSTICKS+1][29]; #ifndef NONET static UINT32 serverlistpage; #endif -static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games. +static UINT8 numsaves = 0; +static saveinfo_t* savegameinfo = NULL; // Extra info about the save games. +static patch_t *savselp[7]; INT16 startmap; // Mario, NiGHTS, or just a plain old normal game? @@ -186,10 +166,21 @@ static INT32 vidm_selected = 0; static INT32 vidm_nummodes; static INT32 vidm_column_size; +// new menus +static tic_t recatkdrawtimer = 0; +static tic_t ntsatkdrawtimer = 0; + +static tic_t charseltimer = 0; +static fixed_t char_scroll = 0; +#define charscrollamt 128*FRACUNIT + +static tic_t keydown = 0; + // // PROTOTYPES // +static void M_GoBack(INT32 choice); static void M_StopMessage(INT32 choice); #ifndef NONET @@ -207,21 +198,46 @@ menu_t MessageDef; menu_t SPauseDef; +// Level Select +static levelselect_t levelselect = {0, NULL}; +static UINT8 levelselectselect[3]; +static patch_t *levselp[2][3]; +static INT32 lsoffs[2]; + +#define lsrow levelselectselect[0] +#define lscol levelselectselect[1] +#define lshli levelselectselect[2] + +#define lshseperation 101 +#define lsbasevseperation (62*vid.height)/(BASEVIDHEIGHT*vid.dupy) //62 #define lsheadingheight 16 +#define getheadingoffset(row) (levelselect.rows[row].header[0] ? lsheadingheight : 0) +#define lsvseperation(row) lsbasevseperation + getheadingoffset(row) +#define lswide(row) levelselect.rows[row].mapavailable[3] + +#define lsbasex 19 +#define lsbasey 59+lsheadingheight // Sky Room static void M_CustomLevelSelect(INT32 choice); static void M_CustomWarp(INT32 choice); FUNCNORETURN static ATTRNORETURN void M_UltimateCheat(INT32 choice); static void M_LoadGameLevelSelect(INT32 choice); +static void M_AllowSuper(INT32 choice); static void M_GetAllEmeralds(INT32 choice); static void M_DestroyRobots(INT32 choice); static void M_LevelSelectWarp(INT32 choice); static void M_Credits(INT32 choice); +static void M_SoundTest(INT32 choice); static void M_PandorasBox(INT32 choice); static void M_EmblemHints(INT32 choice); +static void M_HandleEmblemHints(INT32 choice); +UINT32 hintpage = 1; +static void M_HandleChecklist(INT32 choice); menu_t SR_MainDef, SR_UnlockChecklistDef; +static UINT8 check_on; + // Misc. Main Menu static void M_SinglePlayerMenu(INT32 choice); static void M_Options(INT32 choice); @@ -237,122 +253,140 @@ static void M_ConfirmTeamChange(INT32 choice); static void M_SecretsMenu(INT32 choice); static void M_SetupChoosePlayer(INT32 choice); static void M_QuitSRB2(INT32 choice); -menu_t SP_MainDef, MP_MainDef, OP_MainDef; +menu_t SP_MainDef, OP_MainDef; menu_t MISC_ScrambleTeamDef, MISC_ChangeTeamDef; // Single Player +static void M_StartTutorial(INT32 choice); static void M_LoadGame(INT32 choice); +static void M_HandleTimeAttackLevelSelect(INT32 choice); +static void M_TimeAttackLevelSelect(INT32 choice); static void M_TimeAttack(INT32 choice); +static void M_NightsAttackLevelSelect(INT32 choice); static void M_NightsAttack(INT32 choice); static void M_Statistics(INT32 choice); static void M_ReplayTimeAttack(INT32 choice); static void M_ChooseTimeAttack(INT32 choice); static void M_ChooseNightsAttack(INT32 choice); -static void M_ModeAttackRetry(INT32 choice); static void M_ModeAttackEndGame(INT32 choice); static void M_SetGuestReplay(INT32 choice); +static void M_HandleChoosePlayerMenu(INT32 choice); static void M_ChoosePlayer(INT32 choice); -menu_t SP_GameStatsDef, SP_LevelStatsDef; +menu_t SP_LevelStatsDef; static menu_t SP_TimeAttackDef, SP_ReplayDef, SP_GuestReplayDef, SP_GhostDef; static menu_t SP_NightsAttackDef, SP_NightsReplayDef, SP_NightsGuestReplayDef, SP_NightsGhostDef; // Multiplayer +static void M_SetupMultiPlayer(INT32 choice); +static void M_SetupMultiPlayer2(INT32 choice); +static void M_StartSplitServerMenu(INT32 choice); +static void M_StartServer(INT32 choice); +static void M_ServerOptions(INT32 choice); #ifndef NONET static void M_StartServerMenu(INT32 choice); static void M_ConnectMenu(INT32 choice); -static void M_ConnectIPMenu(INT32 choice); -#endif -static void M_StartSplitServerMenu(INT32 choice); -static void M_StartServer(INT32 choice); -#ifndef NONET +static void M_ConnectMenuModChecks(INT32 choice); static void M_Refresh(INT32 choice); static void M_Connect(INT32 choice); static void M_ChooseRoom(INT32 choice); +menu_t MP_MainDef; #endif -static void M_SetupMultiPlayer(INT32 choice); -static void M_SetupMultiPlayer2(INT32 choice); // Options // Split into multiple parts due to size // Controls -menu_t OP_ControlsDef, OP_ControlListDef, OP_MoveControlsDef; +menu_t OP_ChangeControlsDef; menu_t OP_MPControlsDef, OP_MiscControlsDef; menu_t OP_P1ControlsDef, OP_P2ControlsDef, OP_MouseOptionsDef; menu_t OP_Mouse2OptionsDef, OP_Joystick1Def, OP_Joystick2Def; +menu_t OP_CameraOptionsDef, OP_Camera2OptionsDef; +menu_t OP_PlaystyleDef; static void M_VideoModeMenu(INT32 choice); static void M_Setup1PControlsMenu(INT32 choice); static void M_Setup2PControlsMenu(INT32 choice); static void M_Setup1PJoystickMenu(INT32 choice); static void M_Setup2PJoystickMenu(INT32 choice); +static void M_Setup1PPlaystyleMenu(INT32 choice); +static void M_Setup2PPlaystyleMenu(INT32 choice); static void M_AssignJoystick(INT32 choice); static void M_ChangeControl(INT32 choice); // Video & Sound -menu_t OP_VideoOptionsDef, OP_VideoModeDef; +static void M_VideoOptions(INT32 choice); +menu_t OP_VideoOptionsDef, OP_VideoModeDef, OP_ColorOptionsDef; #ifdef HWRENDER -menu_t OP_OpenGLOptionsDef, OP_OpenGLFogDef, OP_OpenGLColorDef; +static void M_OpenGLOptionsMenu(void); +menu_t OP_OpenGLOptionsDef, OP_OpenGLFogDef; #endif menu_t OP_SoundOptionsDef; +menu_t OP_SoundAdvancedDef; //Misc menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef; -menu_t OP_GameOptionsDef, OP_ChatOptionsDef, OP_ServerOptionsDef; -menu_t OP_NetgameOptionsDef, OP_GametypeOptionsDef; +menu_t OP_ServerOptionsDef; menu_t OP_MonitorToggleDef; static void M_ScreenshotOptions(INT32 choice); +static void M_SetupScreenshotMenu(void); static void M_EraseData(INT32 choice); static void M_Addons(INT32 choice); static void M_AddonsOptions(INT32 choice); static patch_t *addonsp[NUM_EXT+5]; -#define numaddonsshown 4 +#define addonmenusize 9 // number of items actually displayed in the addons menu view, formerly (2*numaddonsshown + 1) +#define numaddonsshown 4 // number of items to each side of the currently selected item, unless at top/bottom ends of directory + +static void M_DrawLevelPlatterHeader(INT32 y, const char *header, boolean headerhighlight, boolean allowlowercase); // Drawing functions static void M_DrawGenericMenu(void); +static void M_DrawGenericScrollMenu(void); static void M_DrawCenteredMenu(void); static void M_DrawAddons(void); -static void M_DrawSkyRoom(void); static void M_DrawChecklist(void); +static void M_DrawSoundTest(void); static void M_DrawEmblemHints(void); static void M_DrawPauseMenu(void); static void M_DrawServerMenu(void); -static void M_DrawLevelSelectMenu(void); +static void M_DrawLevelPlatterMenu(void); static void M_DrawImageDef(void); static void M_DrawLoad(void); static void M_DrawLevelStats(void); -static void M_DrawGameStats(void); static void M_DrawTimeAttackMenu(void); static void M_DrawNightsAttackMenu(void); static void M_DrawSetupChoosePlayerMenu(void); +static void M_DrawControlsDefMenu(void); +static void M_DrawCameraOptionsMenu(void); +static void M_DrawPlaystyleMenu(void); static void M_DrawControl(void); +static void M_DrawMainVideoMenu(void); static void M_DrawVideoMode(void); +static void M_DrawColorMenu(void); +static void M_DrawScreenshotMenu(void); static void M_DrawMonitorToggles(void); #ifdef HWRENDER static void M_OGL_DrawFogMenu(void); -static void M_OGL_DrawColorMenu(void); #endif #ifndef NONET static void M_DrawConnectMenu(void); -static void M_DrawConnectIPMenu(void); +static void M_DrawMPMainMenu(void); static void M_DrawRoomMenu(void); #endif static void M_DrawJoystick(void); static void M_DrawSetupMultiPlayerMenu(void); // Handling functions -#ifndef NONET -static boolean M_CancelConnect(void); -#endif static boolean M_ExitPandorasBox(void); static boolean M_QuitMultiPlayerMenu(void); static void M_HandleAddons(INT32 choice); +static void M_HandleLevelPlatter(INT32 choice); static void M_HandleSoundTest(INT32 choice); static void M_HandleImageDef(INT32 choice); static void M_HandleLoadSave(INT32 choice); -static void M_HandleGameStats(INT32 choice); static void M_HandleLevelStats(INT32 choice); +static void M_HandlePlaystyleMenu(INT32 choice); #ifndef NONET +static boolean M_CancelConnect(void); static void M_HandleConnectIP(INT32 choice); #endif static void M_HandleSetupMultiPlayer(INT32 choice); @@ -361,18 +395,25 @@ static void M_HandleFogColor(INT32 choice); #endif static void M_HandleVideoMode(INT32 choice); +static void M_ResetCvars(void); + // Consvar onchange functions -static void Nextmap_OnChange(void); static void Newgametype_OnChange(void); +#ifdef HWRENDER +static void Newrenderer_OnChange(void); +#endif static void Dummymares_OnChange(void); // ========================================================================== // CONSOLE VARIABLES AND THEIR POSSIBLE VALUES GO HERE. // ========================================================================== +consvar_t cv_showfocuslost = {"showfocuslost", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL }; + static CV_PossibleValue_t map_cons_t[] = { {1,"MIN"}, - {NUMMAPS, "MAX"} + {NUMMAPS, "MAX"}, + {0,NULL} }; consvar_t cv_nextmap = {"nextmap", "1", CV_HIDEN|CV_CALL, map_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -380,36 +421,30 @@ static CV_PossibleValue_t skins_cons_t[MAXSKINS+1] = {{1, DEFAULTSKIN}}; consvar_t cv_chooseskin = {"chooseskin", DEFAULTSKIN, CV_HIDEN|CV_CALL, skins_cons_t, Nextmap_OnChange, 0, NULL, NULL, 0, 0, NULL}; // This gametype list is integral for many different reasons. -// When you add gametypes here, don't forget to update them in CV_AddValue! -CV_PossibleValue_t gametype_cons_t[] = -{ - {GT_COOP, "Co-op"}, +// When you add gametypes here, don't forget to update them in dehacked.c and doomstat.h! +CV_PossibleValue_t gametype_cons_t[NUMGAMETYPES+1]; - {GT_COMPETITION, "Competition"}, - {GT_RACE, "Race"}, - - {GT_MATCH, "Match"}, - {GT_TEAMMATCH, "Team Match"}, - - {GT_TAG, "Tag"}, - {GT_HIDEANDSEEK, "Hide and Seek"}, - - {GT_CTF, "CTF"}, - {0, NULL} -}; consvar_t cv_newgametype = {"newgametype", "Co-op", CV_HIDEN|CV_CALL, gametype_cons_t, Newgametype_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#ifdef HWRENDER +consvar_t cv_newrenderer = {"newrenderer", "Software", CV_HIDEN|CV_CALL, cv_renderer_t, Newrenderer_OnChange, 0, NULL, NULL, 0, 0, NULL}; +static int newrenderer_set = 1;/* Software doesn't need confirmation! */ +#endif + static CV_PossibleValue_t serversort_cons_t[] = { {0,"Ping"}, {1,"Modified State"}, {2,"Most Players"}, {3,"Least Players"}, - {4,"Max Players"}, + {4,"Max Player Slots"}, {5,"Gametype"}, {0,NULL} }; consvar_t cv_serversort = {"serversort", "Ping", CV_HIDEN | CV_CALL, serversort_cons_t, M_SortServerList, 0, NULL, NULL, 0, 0, NULL}; +// first time memory +consvar_t cv_tutorialprompt = {"tutorialprompt", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // autorecord demos for time attack static consvar_t cv_autorecord = {"autorecord", "Yes", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -428,7 +463,8 @@ consvar_t cv_ghost_guest = {"ghost_guest", "Show", CV_SAVE, ghost2_cons_ static CV_PossibleValue_t dummyteam_cons_t[] = {{0, "Spectator"}, {1, "Red"}, {2, "Blue"}, {0, NULL}}; static CV_PossibleValue_t dummyscramble_cons_t[] = {{0, "Random"}, {1, "Points"}, {0, NULL}}; static CV_PossibleValue_t ringlimit_cons_t[] = {{0, "MIN"}, {9999, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t liveslimit_cons_t[] = {{0, "MIN"}, {99, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t liveslimit_cons_t[] = {{1, "MIN"}, {99, "MAX"}, {-1, "Infinite"}, {0, NULL}}; +static CV_PossibleValue_t contlimit_cons_t[] = {{0, "MIN"}, {99, "MAX"}, {0, NULL}}; static CV_PossibleValue_t dummymares_cons_t[] = { {-1, "END"}, {0,"Overall"}, {1,"Mare 1"}, {2,"Mare 2"}, {3,"Mare 3"}, {4,"Mare 4"}, {5,"Mare 5"}, {6,"Mare 6"}, {7,"Mare 7"}, {8,"Mare 8"}, {0,NULL} }; @@ -437,7 +473,7 @@ static consvar_t cv_dummyteam = {"dummyteam", "Spectator", CV_HIDEN, dummyteam_c static consvar_t cv_dummyscramble = {"dummyscramble", "Random", CV_HIDEN, dummyscramble_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_dummyrings = {"dummyrings", "0", CV_HIDEN, ringlimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_dummylives = {"dummylives", "0", CV_HIDEN, liveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_dummycontinues = {"dummycontinues", "0", CV_HIDEN, liveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_dummycontinues = {"dummycontinues", "0", CV_HIDEN, contlimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_dummymares = {"dummymares", "Overall", CV_HIDEN|CV_CALL, dummymares_cons_t, Dummymares_OnChange, 0, NULL, NULL, 0, 0, NULL}; // ========================================================================== @@ -454,21 +490,25 @@ static consvar_t cv_dummymares = {"dummymares", "Overall", CV_HIDEN|CV_CALL, dum // --------- static menuitem_t MainMenu[] = { - {IT_CALL |IT_STRING, NULL, "Secrets", M_SecretsMenu, 76}, - {IT_CALL |IT_STRING, NULL, "1 player", M_SinglePlayerMenu, 84}, - {IT_SUBMENU|IT_STRING, NULL, "multiplayer", &MP_MainDef, 92}, - {IT_CALL |IT_STRING, NULL, "options", M_Options, 100}, - {IT_CALL |IT_STRING, NULL, "Addons", M_Addons, 108}, - {IT_CALL |IT_STRING, NULL, "quit game", M_QuitSRB2, 116}, + {IT_STRING|IT_CALL, NULL, "1 Player", M_SinglePlayerMenu, 76}, +#ifndef NONET + {IT_STRING|IT_SUBMENU, NULL, "Multiplayer", &MP_MainDef, 84}, +#else + {IT_STRING|IT_CALL, NULL, "Multiplayer", M_StartSplitServerMenu, 84}, +#endif + {IT_STRING|IT_CALL, NULL, "Extras", M_SecretsMenu, 92}, + {IT_CALL |IT_STRING, NULL, "Addons", M_Addons, 100}, + {IT_STRING|IT_CALL, NULL, "Options", M_Options, 108}, + {IT_STRING|IT_CALL, NULL, "Quit Game", M_QuitSRB2, 116}, }; typedef enum { - secrets = 0, - singleplr, + singleplr = 0, multiplr, - options, + secrets, addons, + options, quitdoom } main_e; @@ -499,22 +539,22 @@ typedef enum // --------------------- static menuitem_t MPauseMenu[] = { - {IT_STRING | IT_CALL, NULL, "Add-ons...", M_Addons, 8}, - {IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 16}, - {IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 24}, + {IT_STRING | IT_CALL, NULL, "Add-ons...", M_Addons, 8}, + {IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 16}, + {IT_STRING | IT_CALL, NULL, "Switch Gametype/Level...", M_MapChange, 24}, - {IT_CALL | IT_STRING, NULL, "Continue", M_SelectableClearMenus,40}, - {IT_CALL | IT_STRING, NULL, "Player 1 Setup", M_SetupMultiPlayer, 48}, // splitscreen - {IT_CALL | IT_STRING, NULL, "Player 2 Setup", M_SetupMultiPlayer2, 56}, // splitscreen + {IT_STRING | IT_CALL, NULL, "Continue", M_SelectableClearMenus,40}, + {IT_STRING | IT_CALL, NULL, "Player 1 Setup", M_SetupMultiPlayer, 48}, // splitscreen + {IT_STRING | IT_CALL, NULL, "Player 2 Setup", M_SetupMultiPlayer2, 56}, // splitscreen - {IT_STRING | IT_CALL, NULL, "Spectate", M_ConfirmSpectate, 48}, - {IT_STRING | IT_CALL, NULL, "Enter Game", M_ConfirmEnterGame, 48}, - {IT_STRING | IT_SUBMENU, NULL, "Switch Team...", &MISC_ChangeTeamDef, 48}, - {IT_CALL | IT_STRING, NULL, "Player Setup", M_SetupMultiPlayer, 56}, // alone - {IT_CALL | IT_STRING, NULL, "Options", M_Options, 64}, + {IT_STRING | IT_CALL, NULL, "Spectate", M_ConfirmSpectate, 48}, + {IT_STRING | IT_CALL, NULL, "Enter Game", M_ConfirmEnterGame, 48}, + {IT_STRING | IT_SUBMENU, NULL, "Switch Team...", &MISC_ChangeTeamDef, 48}, + {IT_STRING | IT_CALL, NULL, "Player Setup", M_SetupMultiPlayer, 56}, // alone + {IT_STRING | IT_CALL, NULL, "Options", M_Options, 64}, - {IT_CALL | IT_STRING, NULL, "Return to Title", M_EndGame, 80}, - {IT_CALL | IT_STRING, NULL, "Quit Game", M_QuitSRB2, 88}, + {IT_STRING | IT_CALL, NULL, "Return to Title", M_EndGame, 80}, + {IT_STRING | IT_CALL, NULL, "Quit Game", M_QuitSRB2, 88}, }; typedef enum @@ -563,6 +603,7 @@ typedef enum spause_continue, spause_retry, spause_options, + spause_title, spause_quit } spause_e; @@ -583,11 +624,21 @@ static menuitem_t MISC_ChangeTeamMenu[] = {IT_WHITESTRING|IT_CALL, NULL, "Confirm", M_ConfirmTeamChange, 90}, }; +gtdesc_t gametypedesc[NUMGAMETYPES] = +{ + {{ 54, 54}, "Play through the single-player campaign with your friends, teaming up to beat Dr Eggman's nefarious challenges!"}, + {{103, 103}, "Speed your way through the main acts, competing in several different categories to see who's the best."}, + {{190, 190}, "There's not much to it - zoom through the level faster than everyone else."}, + {{ 66, 66}, "Sling rings at your foes in a free-for-all battle. Use the special weapon rings to your advantage!"}, + {{153, 37}, "Sling rings at your foes in a color-coded battle. Use the special weapon rings to your advantage!"}, + {{123, 123}, "Whoever's IT has to hunt down everyone else. If you get caught, you have to turn on your former friends!"}, + {{150, 150}, "Try and find a good hiding place in these maps - we dare you."}, + {{ 37, 153}, "Steal the flag from the enemy's base and bring it back to your own, but watch out - they could just as easily steal yours!"}, +}; + static menuitem_t MISC_ChangeLevelMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 30}, - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 60}, - {IT_WHITESTRING|IT_CALL, NULL, "Change Level", M_ChangeLevel, 120}, + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelPlatter, 0}, // dummy menuitem for the control func }; static menuitem_t MISC_HelpMenu[] = @@ -607,23 +658,26 @@ static menuitem_t MISC_HelpMenu[] = // Pause Menu Pandora's Box Options static menuitem_t SR_PandorasBox[] = { - {IT_STRING | IT_CVAR, NULL, "Rings", &cv_dummyrings, 20}, - {IT_STRING | IT_CVAR, NULL, "Lives", &cv_dummylives, 30}, - {IT_STRING | IT_CVAR, NULL, "Continues", &cv_dummycontinues, 40}, + {IT_STRING | IT_CALL, NULL, "Mid-game add-ons...", M_Addons, 0}, - {IT_STRING | IT_CVAR, NULL, "Gravity", &cv_gravity, 60}, - {IT_STRING | IT_CVAR, NULL, "Throw Rings", &cv_ringslinger, 70}, + {IT_STRING | IT_CVAR, NULL, "Rings", &cv_dummyrings, 20}, + {IT_STRING | IT_CVAR, NULL, "Lives", &cv_dummylives, 30}, + {IT_STRING | IT_CVAR, NULL, "Continues", &cv_dummycontinues, 40}, - {IT_STRING | IT_CALL, NULL, "Get All Emeralds", M_GetAllEmeralds, 90}, - {IT_STRING | IT_CALL, NULL, "Destroy All Robots", M_DestroyRobots, 100}, + {IT_STRING | IT_CVAR, NULL, "Gravity", &cv_gravity, 60}, + {IT_STRING | IT_CVAR, NULL, "Throw Rings", &cv_ringslinger, 70}, - {IT_STRING | IT_CALL, NULL, "Ultimate Cheat", M_UltimateCheat, 130}, + {IT_STRING | IT_CALL, NULL, "Enable Super form", M_AllowSuper, 90}, + {IT_STRING | IT_CALL, NULL, "Get All Emeralds", M_GetAllEmeralds, 100}, + {IT_STRING | IT_CALL, NULL, "Destroy All Robots", M_DestroyRobots, 110}, + + {IT_STRING | IT_CALL, NULL, "Ultimate Cheat", M_UltimateCheat, 130}, }; // Sky Room Custom Unlocks static menuitem_t SR_MainMenu[] = { - {IT_STRING|IT_SUBMENU,NULL, "Secrets Checklist", &SR_UnlockChecklistDef, 0}, + {IT_STRING|IT_SUBMENU,NULL, "Extras Checklist", &SR_UnlockChecklistDef, 0}, {IT_DISABLED, NULL, "", NULL, 0}, // Custom1 {IT_DISABLED, NULL, "", NULL, 0}, // Custom2 {IT_DISABLED, NULL, "", NULL, 0}, // Custom3 @@ -661,20 +715,24 @@ static menuitem_t SR_MainMenu[] = static menuitem_t SR_LevelSelectMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 60}, - - {IT_WHITESTRING|IT_CALL, NULL, "Start", M_LevelSelectWarp, 120}, + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelPlatter, 0}, // dummy menuitem for the control func }; static menuitem_t SR_UnlockChecklistMenu[] = { - {IT_SUBMENU | IT_STRING, NULL, "NEXT", &SR_MainDef, 192}, + {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleChecklist, 0}, +}; + +static menuitem_t SR_SoundTestMenu[] = +{ + {IT_KEYHANDLER | IT_STRING, NULL, "", M_HandleSoundTest, 0}, }; static menuitem_t SR_EmblemHintMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 10}, - {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 20} + {IT_STRING | IT_ARROWS, NULL, "Page", M_HandleEmblemHints, 10}, + {IT_STRING|IT_CVAR, NULL, "Emblem Radar", &cv_itemfinder, 20}, + {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SPauseDef, 30} }; // -------------------------------- @@ -685,10 +743,11 @@ static menuitem_t SR_EmblemHintMenu[] = // Single Player Main static menuitem_t SP_MainMenu[] = { - {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 92}, - {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 100}, - {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 108}, - {IT_CALL | IT_STRING | IT_CALL_NOTMODIFIED, NULL, "Statistics", M_Statistics, 116}, + {IT_CALL | IT_STRING, NULL, "Start Game", M_LoadGame, 84}, + {IT_SECRET, NULL, "Record Attack", M_TimeAttack, 92}, + {IT_SECRET, NULL, "NiGHTS Mode", M_NightsAttack, 100}, + {IT_CALL | IT_STRING, NULL, "Tutorial", M_StartTutorial, 108}, + {IT_CALL | IT_STRING | IT_CALL_NOTMODIFIED, NULL, "Statistics", M_Statistics, 116} }; enum @@ -696,32 +755,37 @@ enum sploadgame, sprecordattack, spnightsmode, + sptutorial, spstatistics }; // Single Player Load Game static menuitem_t SP_LoadGameMenu[] = { - {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLoadSave, '\0'}, // dummy menuitem for the control func + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLoadSave, 0}, // dummy menuitem for the control func }; // Single Player Level Select static menuitem_t SP_LevelSelectMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 60}, + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelPlatter, 0}, // dummy menuitem for the control func +}; - {IT_WHITESTRING|IT_CALL, NULL, "Start", M_LevelSelectWarp, 120}, +// Single Player Time Attack Level Select +static menuitem_t SP_TimeAttackLevelSelectMenu[] = +{ + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelPlatter, 0}, // dummy menuitem for the control func }; // Single Player Time Attack static menuitem_t SP_TimeAttackMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 52}, - {IT_STRING|IT_CVAR, NULL, "Player", &cv_chooseskin, 62}, + {IT_STRING|IT_KEYHANDLER, NULL, "Level Select...", M_HandleTimeAttackLevelSelect, 62}, + {IT_STRING|IT_CVAR, NULL, "Character", &cv_chooseskin, 72}, {IT_DISABLED, NULL, "Guest Option...", &SP_GuestReplayDef, 100}, - {IT_DISABLED, NULL, "Replay...", &SP_ReplayDef, 110}, - {IT_DISABLED, NULL, "Ghosts...", &SP_GhostDef, 120}, + {IT_DISABLED, NULL, "Replay...", &SP_ReplayDef, 110}, + {IT_DISABLED, NULL, "Ghosts...", &SP_GhostDef, 120}, {IT_WHITESTRING|IT_CALL|IT_CALL_NOTMODIFIED, NULL, "Start", M_ChooseTimeAttack, 130}, }; @@ -805,16 +869,22 @@ static menuitem_t SP_NightsGhostMenu[] = {IT_WHITESTRING|IT_SUBMENU, NULL, "Back", &SP_NightsAttackDef, 50} }; +// Single Player Nights Attack Level Select +static menuitem_t SP_NightsAttackLevelSelectMenu[] = +{ + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelPlatter, 0}, // dummy menuitem for the control func +}; + // Single Player Nights Attack static menuitem_t SP_NightsAttackMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 44}, - {IT_STRING|IT_CVAR, NULL, "Show Records For", &cv_dummymares, 54}, + {IT_STRING|IT_KEYHANDLER, NULL, "Level Select...", &M_HandleTimeAttackLevelSelect, 52}, + {IT_STRING|IT_CVAR, NULL, "Show Records For", &cv_dummymares, 62}, - {IT_DISABLED, NULL, "Guest Option...", &SP_NightsGuestReplayDef, 108}, - {IT_DISABLED, NULL, "Replay...", &SP_NightsReplayDef, 118}, - {IT_DISABLED, NULL, "Ghosts...", &SP_NightsGhostDef, 128}, - {IT_WHITESTRING|IT_CALL|IT_CALL_NOTMODIFIED, NULL, "Start", M_ChooseNightsAttack, 138}, + {IT_DISABLED, NULL, "Guest Option...", &SP_NightsGuestReplayDef, 100}, + {IT_DISABLED, NULL, "Replay...", &SP_NightsReplayDef, 110}, + {IT_DISABLED, NULL, "Ghosts...", &SP_NightsGhostDef, 120}, + {IT_WHITESTRING|IT_CALL|IT_CALL_NOTMODIFIED, NULL, "Start", M_ChooseNightsAttack, 130}, }; enum @@ -829,97 +899,71 @@ enum }; // Statistics -static menuitem_t SP_GameStatsMenu[] = -{ - {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleGameStats, '\0'}, // dummy menuitem for the control func -}; - static menuitem_t SP_LevelStatsMenu[] = { - {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelStats, '\0'}, // dummy menuitem for the control func + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleLevelStats, 0}, // dummy menuitem for the control func }; -// A rare case. -// External files modify this menu, so we can't call it static. -// And I'm too lazy to go through and rename it everywhere. ARRGH! -menuitem_t PlayerMenu[32] = +// Player menu dummy +static menuitem_t SP_PlayerMenu[] = { - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_CALL, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0}, - {IT_DISABLED, NULL, NULL, M_ChoosePlayer, 0} + {IT_NOTHING | IT_KEYHANDLER, NULL, "", M_HandleChoosePlayerMenu, 0}, // dummy menuitem for the control func }; // ----------------------------------- // Multiplayer and all of its submenus // ----------------------------------- // Prefix: MP_ + +// Separated splitscreen and normal servers. +static menuitem_t MP_SplitServerMenu[] = +{ + {IT_STRING|IT_CALL, NULL, "Select Gametype/Level...", M_MapChange, 100}, +#ifdef NONET // In order to keep player setup accessible. + {IT_STRING|IT_CALL, NULL, "Player 1 setup...", M_SetupMultiPlayer, 110}, + {IT_STRING|IT_CALL, NULL, "Player 2 setup...", M_SetupMultiPlayer2, 120}, +#endif + {IT_STRING|IT_CALL, NULL, "More Options...", M_ServerOptions, 130}, + {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 140}, +}; + +#ifndef NONET + static menuitem_t MP_MainMenu[] = { -#ifndef NONET - {IT_CALL | IT_STRING, NULL, "HOST GAME", M_StartServerMenu, 10}, - {IT_CALL | IT_STRING, NULL, "JOIN GAME (Search)", M_ConnectMenu, 30}, - {IT_CALL | IT_STRING, NULL, "JOIN GAME (Specify IP)", M_ConnectIPMenu, 40}, -#endif - {IT_CALL | IT_STRING, NULL, "TWO PLAYER GAME", M_StartSplitServerMenu, 60}, - - {IT_CALL | IT_STRING, NULL, "SETUP PLAYER 1", M_SetupMultiPlayer, 80}, - {IT_CALL | IT_STRING, NULL, "SETUP PLAYER 2", M_SetupMultiPlayer2, 90}, + {IT_HEADER, NULL, "Join a game", NULL, 0}, + {IT_STRING|IT_CALL, NULL, "Server browser...", M_ConnectMenuModChecks, 12}, + {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 22}, + {IT_HEADER, NULL, "Host a game", NULL, 54}, + {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_StartServerMenu, 66}, + {IT_STRING|IT_CALL, NULL, "Splitscreen...", M_StartSplitServerMenu, 76}, + {IT_HEADER, NULL, "Player setup", NULL, 94}, + {IT_STRING|IT_CALL, NULL, "Player 1...", M_SetupMultiPlayer, 106}, + {IT_STRING|IT_CALL, NULL, "Player 2... ", M_SetupMultiPlayer2, 116}, }; static menuitem_t MP_ServerMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 10}, -#ifndef NONET - {IT_STRING|IT_CALL, NULL, "Room...", M_RoomMenu, 20}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 30}, -#endif - - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 80}, - - {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 130}, + {IT_STRING|IT_CALL, NULL, "Room...", M_RoomMenu, 10}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 20}, + {IT_STRING|IT_CVAR, NULL, "Max Players", &cv_maxplayers, 46}, + {IT_STRING|IT_CVAR, NULL, "Allow Add-on Downloading", &cv_downloading, 56}, + {IT_STRING|IT_CALL, NULL, "Select Gametype/Level...", M_MapChange, 100}, + {IT_STRING|IT_CALL, NULL, "More Options...", M_ServerOptions, 130}, + {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 140}, }; enum { - mp_server_gametype = 0, -#ifndef NONET - mp_server_room, + mp_server_room = 0, mp_server_name, -#endif - mp_server_level, + mp_server_maxpl, + mp_server_waddl, + mp_server_levelgt, + mp_server_options, mp_server_start }; -#ifndef NONET static menuitem_t MP_ConnectMenu[] = { {IT_STRING | IT_CALL, NULL, "Room...", M_RoomMenu, 4}, @@ -951,7 +995,7 @@ enum static menuitem_t MP_RoomMenu[] = { - {IT_STRING | IT_CALL, NULL, "", M_ChooseRoom, 9}, + {IT_STRING | IT_CALL, NULL, "", M_ChooseRoom, 9}, {IT_DISABLED, NULL, "", M_ChooseRoom, 18}, {IT_DISABLED, NULL, "", M_ChooseRoom, 27}, {IT_DISABLED, NULL, "", M_ChooseRoom, 36}, @@ -971,25 +1015,14 @@ static menuitem_t MP_RoomMenu[] = {IT_DISABLED, NULL, "", M_ChooseRoom, 162}, }; -static menuitem_t MP_ConnectIPMenu[] = -{ - {IT_KEYHANDLER | IT_STRING, NULL, " IP Address:", M_HandleConnectIP, 0}, -}; #endif -// Separated splitscreen and normal servers. -static menuitem_t MP_SplitServerMenu[] = -{ - {IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 10}, - {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 80}, - {IT_WHITESTRING|IT_CALL, NULL, "Start", M_StartServer, 130}, -}; - static menuitem_t MP_PlayerSetupMenu[] = { - {IT_KEYHANDLER | IT_STRING, NULL, "Your name", M_HandleSetupMultiPlayer, 0}, - {IT_KEYHANDLER | IT_STRING, NULL, "Your color", M_HandleSetupMultiPlayer, 16}, - {IT_KEYHANDLER | IT_STRING, NULL, "Your player", M_HandleSetupMultiPlayer, 96}, // Tails 01-18-2001 + {IT_KEYHANDLER, NULL, "", M_HandleSetupMultiPlayer, 0}, // name + {IT_KEYHANDLER, NULL, "", M_HandleSetupMultiPlayer, 0}, // skin + {IT_KEYHANDLER, NULL, "", M_HandleSetupMultiPlayer, 0}, // colour + {IT_KEYHANDLER, NULL, "", M_HandleSetupMultiPlayer, 0}, // default }; // ------------------------------------ @@ -998,154 +1031,134 @@ static menuitem_t MP_PlayerSetupMenu[] = // Prefix: OP_ static menuitem_t OP_MainMenu[] = { - {IT_SUBMENU | IT_STRING, NULL, "Setup Controls...", &OP_ControlsDef, 10}, + {IT_SUBMENU | IT_STRING, NULL, "Player 1 Controls...", &OP_P1ControlsDef, 10}, + {IT_SUBMENU | IT_STRING, NULL, "Player 2 Controls...", &OP_P2ControlsDef, 20}, + {IT_CVAR | IT_STRING, NULL, "Controls per key", &cv_controlperkey, 30}, - {IT_SUBMENU | IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 30}, - {IT_SUBMENU | IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 40}, - {IT_SUBMENU | IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 50}, + {IT_CALL | IT_STRING, NULL, "Video Options...", M_VideoOptions, 50}, + {IT_SUBMENU | IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 60}, - {IT_SUBMENU | IT_STRING, NULL, "Game Options...", &OP_GameOptionsDef, 70}, - {IT_SUBMENU | IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 80}, - {IT_STRING | IT_CALL, NULL, "Add-on Options...", M_AddonsOptions, 90}, -}; + {IT_CALL | IT_STRING, NULL, "Server Options...", M_ServerOptions, 80}, -static menuitem_t OP_ControlsMenu[] = -{ - {IT_SUBMENU | IT_STRING, NULL, "Player 1 Controls...", &OP_P1ControlsDef, 10}, - {IT_SUBMENU | IT_STRING, NULL, "Player 2 Controls...", &OP_P2ControlsDef, 20}, - - {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 40}, + {IT_SUBMENU | IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 100}, }; static menuitem_t OP_P1ControlsMenu[] = { {IT_CALL | IT_STRING, NULL, "Control Configuration...", M_Setup1PControlsMenu, 10}, {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 20}, - {IT_SUBMENU | IT_STRING, NULL, "Joystick Options...", &OP_Joystick1Def , 30}, + {IT_SUBMENU | IT_STRING, NULL, "Gamepad Options...", &OP_Joystick1Def , 30}, - {IT_STRING | IT_CVAR, NULL, "Camera" , &cv_chasecam , 50}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair , 60}, + {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_CameraOptionsDef, 50}, - {IT_STRING | IT_CVAR, NULL, "Analog Control", &cv_useranalog, 80}, + {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake, 70}, + {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup1PPlaystyleMenu, 80}, }; static menuitem_t OP_P2ControlsMenu[] = { {IT_CALL | IT_STRING, NULL, "Control Configuration...", M_Setup2PControlsMenu, 10}, {IT_SUBMENU | IT_STRING, NULL, "Second Mouse Options...", &OP_Mouse2OptionsDef, 20}, - {IT_SUBMENU | IT_STRING, NULL, "Second Joystick Options...", &OP_Joystick2Def , 30}, + {IT_SUBMENU | IT_STRING, NULL, "Second Gamepad Options...", &OP_Joystick2Def , 30}, - {IT_STRING | IT_CVAR, NULL, "Camera" , &cv_chasecam2 , 50}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 60}, + {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_Camera2OptionsDef, 50}, - {IT_STRING | IT_CVAR, NULL, "Analog Control", &cv_useranalog2, 80}, + {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake2, 70}, + {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup2PPlaystyleMenu, 80}, }; -static menuitem_t OP_ControlListMenu[] = +static menuitem_t OP_ChangeControlsMenu[] = { - {IT_SUBMENU | IT_STRING, NULL, "Movement Controls...", &OP_MoveControlsDef, 10}, - {IT_SUBMENU | IT_STRING, NULL, "Multiplayer Controls...", &OP_MPControlsDef, 20}, - {IT_SUBMENU | IT_STRING, NULL, "Miscellaneous Controls...", &OP_MiscControlsDef, 30}, -}; - -static menuitem_t OP_MoveControlsMenu[] = -{ - {IT_HEADER, NULL, " Movement", NULL, 0}, + {IT_HEADER, NULL, "Movement", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, // padding {IT_CALL | IT_STRING2, NULL, "Move Forward", M_ChangeControl, gc_forward }, {IT_CALL | IT_STRING2, NULL, "Move Backward", M_ChangeControl, gc_backward }, {IT_CALL | IT_STRING2, NULL, "Move Left", M_ChangeControl, gc_strafeleft }, {IT_CALL | IT_STRING2, NULL, "Move Right", M_ChangeControl, gc_straferight }, {IT_CALL | IT_STRING2, NULL, "Jump", M_ChangeControl, gc_jump }, {IT_CALL | IT_STRING2, NULL, "Spin", M_ChangeControl, gc_use }, - {IT_HEADER, NULL, " Camera", NULL, 0}, + {IT_HEADER, NULL, "Camera", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, // padding {IT_CALL | IT_STRING2, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CALL | IT_STRING2, NULL, "Look Down", M_ChangeControl, gc_lookdown }, - {IT_CALL | IT_STRING2, NULL, "Turn Left", M_ChangeControl, gc_turnleft }, - {IT_CALL | IT_STRING2, NULL, "Turn Right", M_ChangeControl, gc_turnright }, + {IT_CALL | IT_STRING2, NULL, "Look Left", M_ChangeControl, gc_turnleft }, + {IT_CALL | IT_STRING2, NULL, "Look Right", M_ChangeControl, gc_turnright }, {IT_CALL | IT_STRING2, NULL, "Center View", M_ChangeControl, gc_centerview }, {IT_CALL | IT_STRING2, NULL, "Toggle Mouselook", M_ChangeControl, gc_mouseaiming }, {IT_CALL | IT_STRING2, NULL, "Toggle Third-Person", M_ChangeControl, gc_camtoggle}, {IT_CALL | IT_STRING2, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, - {IT_HEADER, NULL, " Advanced", NULL, 0}, - {IT_CALL | IT_STRING2, NULL, "Rotate Camera L", M_ChangeControl, gc_camleft }, - {IT_CALL | IT_STRING2, NULL, "Rotate Camera R", M_ChangeControl, gc_camright }, -}; - -static menuitem_t OP_MPControlsMenu[] = -{ - {IT_CALL | IT_STRING2, NULL, "Talk key", M_ChangeControl, gc_talkkey }, - {IT_CALL | IT_STRING2, NULL, "Team-Talk key", M_ChangeControl, gc_teamkey }, - {IT_CALL | IT_STRING2, NULL, "Rankings/Scores", M_ChangeControl, gc_scores }, - {IT_CALL | IT_STRING2, NULL, "Toss Flag", M_ChangeControl, gc_tossflag }, - {IT_CALL | IT_STRING2, NULL, "Next Weapon", M_ChangeControl, gc_weaponnext }, - {IT_CALL | IT_STRING2, NULL, "Prev Weapon", M_ChangeControl, gc_weaponprev }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 1", M_ChangeControl, gc_wepslot1 }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 2", M_ChangeControl, gc_wepslot2 }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 3", M_ChangeControl, gc_wepslot3 }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 4", M_ChangeControl, gc_wepslot4 }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 5", M_ChangeControl, gc_wepslot5 }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 6", M_ChangeControl, gc_wepslot6 }, - {IT_CALL | IT_STRING2, NULL, "Weapon Slot 7", M_ChangeControl, gc_wepslot7 }, - {IT_CALL | IT_STRING2, NULL, "Ring Toss", M_ChangeControl, gc_fire }, - {IT_CALL | IT_STRING2, NULL, "Ring Toss Normal", M_ChangeControl, gc_firenormal }, -}; - -static menuitem_t OP_MiscControlsMenu[] = -{ - {IT_CALL | IT_STRING2, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, - {IT_CALL | IT_STRING2, NULL, "Custom Action 2", M_ChangeControl, gc_custom2 }, - {IT_CALL | IT_STRING2, NULL, "Custom Action 3", M_ChangeControl, gc_custom3 }, - - {IT_CALL | IT_STRING2, NULL, "Pause", M_ChangeControl, gc_pause }, + {IT_HEADER, NULL, "Meta", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, // padding + {IT_CALL | IT_STRING2, NULL, "Game Status", + M_ChangeControl, gc_scores }, + {IT_CALL | IT_STRING2, NULL, "Pause / Run Retry", M_ChangeControl, gc_pause }, {IT_CALL | IT_STRING2, NULL, "Screenshot", M_ChangeControl, gc_screenshot }, {IT_CALL | IT_STRING2, NULL, "Toggle GIF Recording", M_ChangeControl, gc_recordgif }, {IT_CALL | IT_STRING2, NULL, "Open/Close Menu (ESC)", M_ChangeControl, gc_systemmenu }, {IT_CALL | IT_STRING2, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, - {IT_CALL | IT_STRING2, NULL, "Console", M_ChangeControl, gc_console }, + {IT_CALL | IT_STRING2, NULL, "Console", M_ChangeControl, gc_console }, + {IT_HEADER, NULL, "Multiplayer", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, // padding + {IT_CALL | IT_STRING2, NULL, "Talk", M_ChangeControl, gc_talkkey }, + {IT_CALL | IT_STRING2, NULL, "Talk (Team only)", M_ChangeControl, gc_teamkey }, + {IT_HEADER, NULL, "Ringslinger (Match, CTF, Tag, H&S)", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, // padding + {IT_CALL | IT_STRING2, NULL, "Fire", M_ChangeControl, gc_fire }, + {IT_CALL | IT_STRING2, NULL, "Fire Normal", M_ChangeControl, gc_firenormal }, + {IT_CALL | IT_STRING2, NULL, "Toss Flag", M_ChangeControl, gc_tossflag }, + {IT_CALL | IT_STRING2, NULL, "Next Weapon", M_ChangeControl, gc_weaponnext }, + {IT_CALL | IT_STRING2, NULL, "Prev Weapon", M_ChangeControl, gc_weaponprev }, + {IT_CALL | IT_STRING2, NULL, "Normal / Infinity", M_ChangeControl, gc_wepslot1 }, + {IT_CALL | IT_STRING2, NULL, "Automatic", M_ChangeControl, gc_wepslot2 }, + {IT_CALL | IT_STRING2, NULL, "Bounce", M_ChangeControl, gc_wepslot3 }, + {IT_CALL | IT_STRING2, NULL, "Scatter", M_ChangeControl, gc_wepslot4 }, + {IT_CALL | IT_STRING2, NULL, "Grenade", M_ChangeControl, gc_wepslot5 }, + {IT_CALL | IT_STRING2, NULL, "Explosion", M_ChangeControl, gc_wepslot6 }, + {IT_CALL | IT_STRING2, NULL, "Rail", M_ChangeControl, gc_wepslot7 }, + {IT_HEADER, NULL, "Add-ons", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, // padding + {IT_CALL | IT_STRING2, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, + {IT_CALL | IT_STRING2, NULL, "Custom Action 2", M_ChangeControl, gc_custom2 }, + {IT_CALL | IT_STRING2, NULL, "Custom Action 3", M_ChangeControl, gc_custom3 }, }; static menuitem_t OP_Joystick1Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Joystick...", M_Setup1PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Axis For Turning" , &cv_turnaxis , 30}, - {IT_STRING | IT_CVAR, NULL, "Axis For Moving" , &cv_moveaxis , 40}, - {IT_STRING | IT_CVAR, NULL, "Axis For Strafe" , &cv_sideaxis , 50}, - {IT_STRING | IT_CVAR, NULL, "Axis For Looking" , &cv_lookaxis , 60}, - {IT_STRING | IT_CVAR, NULL, "Axis For Jumping" , &cv_jumpaxis , 70}, - {IT_STRING | IT_CVAR, NULL, "Axis For Spinning" , &cv_spinaxis , 80}, - {IT_STRING | IT_CVAR, NULL, "Axis For Firing" , &cv_fireaxis , 90}, - {IT_STRING | IT_CVAR, NULL, "Axis For NFiring" , &cv_firenaxis , 100}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad...", M_Setup1PJoystickMenu, 10}, + {IT_STRING | IT_CVAR, NULL, "Move \x17 Axis" , &cv_moveaxis , 30}, + {IT_STRING | IT_CVAR, NULL, "Move \x18 Axis" , &cv_sideaxis , 40}, + {IT_STRING | IT_CVAR, NULL, "Camera \x17 Axis" , &cv_lookaxis , 50}, + {IT_STRING | IT_CVAR, NULL, "Camera \x18 Axis" , &cv_turnaxis , 60}, + {IT_STRING | IT_CVAR, NULL, "Jump Axis" , &cv_jumpaxis , 70}, + {IT_STRING | IT_CVAR, NULL, "Spin Axis" , &cv_spinaxis , 80}, + {IT_STRING | IT_CVAR, NULL, "Fire Axis" , &cv_fireaxis , 90}, + {IT_STRING | IT_CVAR, NULL, "Fire Normal Axis" , &cv_firenaxis ,100}, {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Analog Deadzone", &cv_deadzone, 140}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Digital Deadzone", &cv_digitaldeadzone, 150}, }; static menuitem_t OP_Joystick2Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Joystick...", M_Setup2PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Axis For Turning" , &cv_turnaxis2 , 30}, - {IT_STRING | IT_CVAR, NULL, "Axis For Moving" , &cv_moveaxis2 , 40}, - {IT_STRING | IT_CVAR, NULL, "Axis For Strafe" , &cv_sideaxis2 , 50}, - {IT_STRING | IT_CVAR, NULL, "Axis For Looking" , &cv_lookaxis2 , 60}, - {IT_STRING | IT_CVAR, NULL, "Axis For Jumping" , &cv_jumpaxis2 , 70}, - {IT_STRING | IT_CVAR, NULL, "Axis For Spinning" , &cv_spinaxis2 , 80}, - {IT_STRING | IT_CVAR, NULL, "Axis For Firing" , &cv_fireaxis2 , 90}, - {IT_STRING | IT_CVAR, NULL, "Axis For NFiring" , &cv_firenaxis2 , 100}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad...", M_Setup2PJoystickMenu, 10}, + {IT_STRING | IT_CVAR, NULL, "Move \x17 Axis" , &cv_moveaxis2 , 30}, + {IT_STRING | IT_CVAR, NULL, "Move \x18 Axis" , &cv_sideaxis2 , 40}, + {IT_STRING | IT_CVAR, NULL, "Camera \x17 Axis" , &cv_lookaxis2 , 50}, + {IT_STRING | IT_CVAR, NULL, "Camera \x18 Axis" , &cv_turnaxis2 , 60}, + {IT_STRING | IT_CVAR, NULL, "Jump Axis" , &cv_jumpaxis2 , 70}, + {IT_STRING | IT_CVAR, NULL, "Spin Axis" , &cv_spinaxis2 , 80}, + {IT_STRING | IT_CVAR, NULL, "Fire Axis" , &cv_fireaxis2 , 90}, + {IT_STRING | IT_CVAR, NULL, "Fire Normal Axis" , &cv_firenaxis2 ,100}, {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Analog Deadzone", &cv_deadzone2,140}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Digital Deadzone", &cv_digitaldeadzone2,150}, }; -static menuitem_t OP_JoystickSetMenu[] = -{ - {IT_CALL | IT_NOTHING, "None", NULL, M_AssignJoystick, '0'}, - {IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, '1'}, - {IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, '2'}, - {IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, '3'}, - {IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, '4'}, - {IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, '5'}, - {IT_CALL | IT_NOTHING, "", NULL, M_AssignJoystick, '6'}, -}; +static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS]; static menuitem_t OP_MouseOptionsMenu[] = { @@ -1155,11 +1168,11 @@ static menuitem_t OP_MouseOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook, 30}, {IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook, 40}, {IT_STRING | IT_CVAR, NULL, "Mouse Move", &cv_mousemove, 50}, - {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 60}, + {IT_STRING | IT_CVAR, NULL, "Invert Y Axis", &cv_invertmouse, 60}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse X Speed", &cv_mousesens, 70}, + NULL, "Mouse X Sensitivity", &cv_mousesens, 70}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse Y Speed", &cv_mouseysens, 80}, + NULL, "Mouse Y Sensitivity", &cv_mouseysens, 80}, }; static menuitem_t OP_Mouse2OptionsMenu[] = @@ -1170,57 +1183,247 @@ static menuitem_t OP_Mouse2OptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook2, 30}, {IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook2, 40}, {IT_STRING | IT_CVAR, NULL, "Mouse Move", &cv_mousemove2, 50}, - {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse2, 60}, + {IT_STRING | IT_CVAR, NULL, "Invert Y Axis", &cv_invertmouse2, 60}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse X Speed", &cv_mousesens2, 70}, + NULL, "Mouse X Sensitivity", &cv_mousesens2, 70}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse Y Speed", &cv_mouseysens2, 80}, + NULL, "Mouse Y Sensitivity", &cv_mouseysens2, 80}, +}; + +static menuitem_t OP_CameraOptionsMenu[] = +{ + {IT_HEADER, NULL, "General Toggles", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 21}, + + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[0][0], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[0][0], 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam_turnmultiplier, 51}, + + {IT_HEADER, NULL, "Display Options", NULL, 60}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 66}, +}; + +static menuitem_t OP_Camera2OptionsMenu[] = +{ + {IT_HEADER, NULL, "General Toggles", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 21}, + + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[0][1], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[0][1], 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam2_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam2_turnmultiplier, 51}, + + {IT_HEADER, NULL, "Display Options", NULL, 60}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 66}, +}; + +static menuitem_t OP_CameraExtendedOptionsMenu[] = +{ + {IT_HEADER, NULL, "General Toggles", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 21}, + + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[1][0], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[1][0], 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam_turnmultiplier, 51}, + + {IT_HEADER, NULL, "Automatic Camera Options", NULL, 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 66}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 71}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 76}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 81}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 86}, + + {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, + {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[0], 101}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 106}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[0], 111}, + + {IT_HEADER, NULL, "Display Options", NULL, 120}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 126}, +}; + +static menuitem_t OP_Camera2ExtendedOptionsMenu[] = +{ + {IT_HEADER, NULL, "General Toggles", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 21}, + + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[1][1], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[1][1], 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam2_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam2_turnmultiplier, 51}, + + {IT_HEADER, NULL, "Automatic Camera Options", NULL, 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[1], 66}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[1], 71}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 76}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 81}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 86}, + + {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, + {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[1], 101}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 106}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[1], 111}, + + {IT_HEADER, NULL, "Display Options", NULL, 120}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 126}, +}; + +enum +{ + op_video_resolution = 1, +#if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) + op_video_fullscreen, +#endif + op_video_vsync, + op_video_renderer, }; static menuitem_t OP_VideoOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Video Modes...", M_VideoModeMenu, 10}, - -#ifdef HWRENDER - {IT_SUBMENU|IT_STRING, NULL, "3D Card Options...", &OP_OpenGLOptionsDef, 20}, -#endif + {IT_HEADER, NULL, "Screen", NULL, 0}, + {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 6}, #if (defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL) - {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 30}, + {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 11}, +#endif + {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 16}, +#ifdef HWRENDER + {IT_STRING | IT_CVAR, NULL, "Renderer", &cv_newrenderer, 21}, +#else + {IT_TRANSTEXT | IT_PAIR, "Renderer", "Software", &cv_renderer, 21}, #endif - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Brightness", &cv_usegamma, 50}, - {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 60}, - {IT_STRING | IT_CVAR, NULL, "NiGHTS Draw Dist", &cv_drawdist_nights, 70}, - {IT_STRING | IT_CVAR, NULL, "Precip Draw Dist", &cv_drawdist_precip, 80}, - {IT_STRING | IT_CVAR, NULL, "Precip Density", &cv_precipdensity, 90}, + {IT_HEADER, NULL, "Color Profile", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness (F11)", &cv_globalgamma,36}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_globalsaturation, 41}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Settings...", &OP_ColorOptionsDef, 46}, - {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 110}, - {IT_STRING | IT_CVAR, NULL, "Clear Before Redraw", &cv_homremoval, 120}, - {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 130}, + {IT_HEADER, NULL, "Heads-Up Display", NULL, 55}, + {IT_STRING | IT_CVAR, NULL, "Show HUD", &cv_showhud, 61}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, + NULL, "HUD Transparency", &cv_translucenthud, 66}, + {IT_STRING | IT_CVAR, NULL, "Score/Time/Rings", &cv_timetic, 71}, + {IT_STRING | IT_CVAR, NULL, "Show Powerups", &cv_powerupdisplay, 76}, + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 81}, // shows ping next to framerate if we want to. +#ifdef SEENAMES + {IT_STRING | IT_CVAR, NULL, "Show player names", &cv_seenames, 86}, +#endif + + {IT_HEADER, NULL, "Console", NULL, 95}, + {IT_STRING | IT_CVAR, NULL, "Background color", &cons_backcolor, 101}, + {IT_STRING | IT_CVAR, NULL, "Text Size", &cv_constextsize, 106}, + + {IT_HEADER, NULL, "Chat", NULL, 115}, + {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 121}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat Box Width", &cv_chatwidth, 126}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat Box Height", &cv_chatheight, 131}, + {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 136}, + {IT_STRING | IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 141}, + {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 146}, + {IT_STRING | IT_CVAR, NULL, "Chat background tint", &cv_chatbacktint, 151}, + + {IT_HEADER, NULL, "Level", NULL, 160}, + {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 166}, + {IT_STRING | IT_CVAR, NULL, "Weather Draw Dist.", &cv_drawdist_precip, 171}, + {IT_STRING | IT_CVAR, NULL, "NiGHTS Hoop Draw Dist.", &cv_drawdist_nights, 176}, + + {IT_HEADER, NULL, "Diagnostic", NULL, 184}, + {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 190}, + {IT_STRING | IT_CVAR, NULL, "Clear Before Redraw", &cv_homremoval, 195}, + {IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 200}, + +#ifdef HWRENDER + {IT_HEADER, NULL, "Renderer", NULL, 208}, + {IT_CALL | IT_STRING, NULL, "OpenGL Options...", M_OpenGLOptionsMenu, 214}, +#endif }; static menuitem_t OP_VideoModeMenu[] = { - {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleVideoMode, '\0'}, // dummy menuitem for the control func + {IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandleVideoMode, 0}, // dummy menuitem for the control func +}; + +static menuitem_t OP_ColorOptionsMenu[] = +{ + {IT_STRING | IT_CALL, NULL, "Reset to defaults", M_ResetCvars, 0}, + + {IT_HEADER, NULL, "Red", NULL, 9}, + {IT_DISABLED, NULL, NULL, NULL, 35}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_rhue, 15}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_rsaturation, 20}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_rgamma, 25}, + + {IT_HEADER, NULL, "Yellow", NULL, 34}, + {IT_DISABLED, NULL, NULL, NULL, 73}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_yhue, 40}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_ysaturation, 45}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_ygamma, 50}, + + {IT_HEADER, NULL, "Green", NULL, 59}, + {IT_DISABLED, NULL, NULL, NULL, 112}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_ghue, 65}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_gsaturation, 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_ggamma, 75}, + + {IT_HEADER, NULL, "Cyan", NULL, 84}, + {IT_DISABLED, NULL, NULL, NULL, 255}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_chue, 90}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_csaturation, 95}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_cgamma, 100}, + + {IT_HEADER, NULL, "Blue", NULL, 109}, + {IT_DISABLED, NULL, NULL, NULL, 152}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_bhue, 115}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_bsaturation, 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_bgamma, 125}, + + {IT_HEADER, NULL, "Magenta", NULL, 134}, + {IT_DISABLED, NULL, NULL, NULL, 181}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_mhue, 140}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_msaturation, 145}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_mgamma, 150}, }; #ifdef HWRENDER static menuitem_t OP_OpenGLOptionsMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Field of view", &cv_grfov, 10}, - {IT_STRING|IT_CVAR, NULL, "Quality", &cv_scr_depth, 20}, - {IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 30}, - {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode,40}, -#ifdef _WINDOWS - {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 50}, -#endif + {IT_HEADER, NULL, "3D Models", NULL, 0}, + {IT_STRING|IT_CVAR, NULL, "Models", &cv_grmodels, 12}, + {IT_STRING|IT_CVAR, NULL, "Model interpolation", &cv_grmodelinterpolation, 22}, + {IT_STRING|IT_CVAR, NULL, "Model lighting", &cv_grmodellighting, 32}, + + {IT_HEADER, NULL, "General", NULL, 51}, + {IT_STRING|IT_CVAR, NULL, "Field of view", &cv_fov, 63}, + {IT_STRING|IT_CVAR, NULL, "Quality", &cv_scr_depth, 73}, + {IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 83}, + {IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode,93}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_SUBMENU|IT_STRING, NULL, "Fog...", &OP_OpenGLFogDef, 124}, #ifdef ALAM_LIGHTING - {IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "Lighting...", &OP_OpenGLLightingDef, 134}, +#endif +#if defined (_WINDOWS) && (!((defined (__unix__) && !defined (MSDOS)) || defined (UNIXCOMMON) || defined (HAVE_SDL))) + {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 144}, #endif - {IT_SUBMENU|IT_STRING, NULL, "Fog...", &OP_OpenGLFogDef, 80}, - {IT_SUBMENU|IT_STRING, NULL, "Gamma...", &OP_OpenGLColorDef, 90}, }; #ifdef ALAM_LIGHTING @@ -1240,92 +1443,131 @@ static menuitem_t OP_OpenGLFogMenu[] = {IT_STRING|IT_CVAR, NULL, "Fog density", &cv_grfogdensity, 30}, {IT_STRING|IT_CVAR, NULL, "Software Fog",&cv_grsoftwarefog,40}, }; - -static menuitem_t OP_OpenGLColorMenu[] = -{ - {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "red", &cv_grgammared, 10}, - {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "green", &cv_grgammagreen, 20}, - {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "blue", &cv_grgammablue, 30}, -}; #endif static menuitem_t OP_SoundOptionsMenu[] = { - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Sound Volume" , &cv_soundvolume, 10}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Music Volume" , &cv_digmusicvolume, 20}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "MIDI Volume" , &cv_midimusicvolume, 30}, -#ifdef PC_DOS - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "CD Volume" , &cd_volume, 40}, + {IT_HEADER, NULL, "Game Audio", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Sound Effects", &cv_gamesounds, 12}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Sound Volume", &cv_soundvolume, 22}, + + {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 42}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Digital Music Volume", &cv_digmusicvolume, 52}, + + {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 72}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "MIDI Music Volume", &cv_midimusicvolume, 82}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 102}, + {IT_STRING | IT_CVAR, NULL, "Closed Captioning", &cv_closedcaptioning, 114}, + {IT_STRING | IT_CVAR, NULL, "Reset Music Upon Dying", &cv_resetmusic, 124}, + {IT_STRING | IT_CVAR, NULL, "Default 1-Up sound", &cv_1upsound, 134}, + + {IT_STRING | IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 154}, +}; + +#ifdef HAVE_OPENMPT +#define OPENMPT_MENUOFFSET 32 +#else +#define OPENMPT_MENUOFFSET 0 #endif - {IT_STRING | IT_CVAR, NULL, "SFX" , &cv_gamesounds, 50}, - {IT_STRING | IT_CVAR, NULL, "Digital Music", &cv_gamedigimusic, 60}, - {IT_STRING | IT_CVAR, NULL, "MIDI Music", &cv_gamemidimusic, 70}, +#ifdef HAVE_MIXERX +#define MIXERX_MENUOFFSET 81 +#else +#define MIXERX_MENUOFFSET 0 +#endif + +static menuitem_t OP_SoundAdvancedMenu[] = +{ +#ifdef HAVE_OPENMPT + {IT_HEADER, NULL, "OpenMPT Settings", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 12}, +#endif + +#ifdef HAVE_MIXERX + {IT_HEADER, NULL, "MIDI Settings", NULL, OPENMPT_MENUOFFSET}, + {IT_STRING | IT_CVAR, NULL, "MIDI Player", &cv_midiplayer, OPENMPT_MENUOFFSET+12}, + {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "FluidSynth Sound Font File", &cv_midisoundfontpath, OPENMPT_MENUOFFSET+24}, + {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "TiMidity++ Config Folder", &cv_miditimiditypath, OPENMPT_MENUOFFSET+51}, +#endif + + {IT_HEADER, NULL, "Miscellaneous", NULL, OPENMPT_MENUOFFSET+MIXERX_MENUOFFSET}, + {IT_STRING | IT_CVAR, NULL, "Play Sound Effects if Unfocused", &cv_playsoundsifunfocused, OPENMPT_MENUOFFSET+MIXERX_MENUOFFSET+12}, + {IT_STRING | IT_CVAR, NULL, "Play Music if Unfocused", &cv_playmusicifunfocused, OPENMPT_MENUOFFSET+MIXERX_MENUOFFSET+22}, + {IT_STRING | IT_CVAR, NULL, "Let Levels Force Reset Music", &cv_resetmusicbyheader, OPENMPT_MENUOFFSET+MIXERX_MENUOFFSET+32}, }; +#undef OPENMPT_MENUOFFSET +#undef MIXERX_MENUOFFSET + static menuitem_t OP_DataOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10}, + {IT_STRING | IT_CALL, NULL, "Add-on Options...", M_AddonsOptions, 10}, + {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Erase Data...", &OP_EraseDataDef, 30}, + {IT_STRING | IT_SUBMENU, NULL, "\x85" "Erase Data...", &OP_EraseDataDef, 40}, }; static menuitem_t OP_ScreenshotOptionsMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 10}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 20}, + {IT_HEADER, NULL, "General", NULL, 0}, + {IT_STRING|IT_CVAR, NULL, "Use color profile", &cv_screenshot_colorprofile, 6}, - {IT_HEADER, NULL, "Screenshots (F8)", NULL, 50}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, + {IT_HEADER, NULL, "Screenshots (F8)", NULL, 16}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 22}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 27}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 42}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 47}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 52}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 57}, - {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 105}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, + {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 64}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 70}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 75}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 90}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 125}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 95}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 100}, + {IT_STRING|IT_CVAR, NULL, "Local Color Table", &cv_gif_localcolortable, 105}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 95}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 100}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 105}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 110}, }; enum { - op_screenshot_folder = 1, - op_screenshot_capture = 8, - op_screenshot_gif_start = 9, - op_screenshot_gif_end = 10, - op_screenshot_apng_start = 11, - op_screenshot_apng_end = 14, + op_screenshot_colorprofile = 1, + op_screenshot_storagelocation = 3, + op_screenshot_folder = 4, + op_movie_folder = 11, + op_screenshot_capture = 12, + op_screenshot_gif_start = 13, + op_screenshot_gif_end = 15, + op_screenshot_apng_start = 16, + op_screenshot_apng_end = 19, }; static menuitem_t OP_EraseDataMenu[] = { {IT_STRING | IT_CALL, NULL, "Erase Record Data", M_EraseData, 10}, - {IT_STRING | IT_CALL, NULL, "Erase Secrets Data", M_EraseData, 20}, + {IT_STRING | IT_CALL, NULL, "Erase Extras Data", M_EraseData, 20}, {IT_STRING | IT_CALL, NULL, "\x85" "Erase ALL Data", M_EraseData, 40}, }; static menuitem_t OP_AddonsOptionsMenu[] = { - {IT_HEADER, NULL, "Menu", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Location", &cv_addons_option, 10}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_addons_folder, 20}, - {IT_STRING|IT_CVAR, NULL, "Identify add-ons via", &cv_addons_md5, 48}, - {IT_STRING|IT_CVAR, NULL, "Show unsupported file types", &cv_addons_showall, 58}, + {IT_HEADER, NULL, "Menu", NULL, 0}, + {IT_STRING|IT_CVAR, NULL, "Location", &cv_addons_option, 12}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_addons_folder, 22}, + {IT_STRING|IT_CVAR, NULL, "Identify add-ons via", &cv_addons_md5, 50}, + {IT_STRING|IT_CVAR, NULL, "Show unsupported file types", &cv_addons_showall, 60}, - {IT_HEADER, NULL, "Search", NULL, 76}, - {IT_STRING|IT_CVAR, NULL, "Matching", &cv_addons_search_type, 86}, - {IT_STRING|IT_CVAR, NULL, "Case-sensitive", &cv_addons_search_case, 96}, + {IT_HEADER, NULL, "Search", NULL, 78}, + {IT_STRING|IT_CVAR, NULL, "Matching", &cv_addons_search_type, 90}, + {IT_STRING|IT_CVAR, NULL, "Case-sensitive", &cv_addons_search_case, 100}, }; enum @@ -1333,125 +1575,77 @@ enum op_addons_folder = 2, }; -static menuitem_t OP_GameOptionsMenu[] = -{ -#ifndef NONET - {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Master server", &cv_masterserver, 10}, - {IT_STRING | IT_SUBMENU, NULL, "Chat Options...", &OP_ChatOptionsDef, 40}, -#endif - {IT_STRING | IT_CVAR, NULL, "Show HUD", &cv_showhud, 50}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "HUD Visibility", &cv_translucenthud, 60}, - {IT_STRING | IT_CVAR, NULL, "Timer Display", &cv_timetic, 70}, - {IT_STRING | IT_CVAR, NULL, "Always Compact Rankings", &cv_compactscoreboard, 80}, -#ifdef SEENAMES - {IT_STRING | IT_CVAR, NULL, "HUD Player Names", &cv_seenames, 90}, -#endif - {IT_STRING | IT_CVAR, NULL, "Log Hazard Damage", &cv_hazardlog, 100}, - - {IT_STRING | IT_CVAR, NULL, "Console Back Color", &cons_backcolor, 110}, - {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize,120}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Console", &cv_allcaps, 130}, - - {IT_STRING | IT_CVAR, NULL, "Title Screen Demos", &cv_rollingdemos, 140}, -}; - -static menuitem_t OP_ChatOptionsMenu[] = -{ - {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 10}, - - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat Box Width", &cv_chatwidth, 30}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Chat Box Height", &cv_chatheight, 40}, - {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 50}, - {IT_STRING | IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 60}, - {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 70}, - {IT_STRING | IT_CVAR, NULL, "Chat background tint", &cv_chatbacktint, 80}, -}; - static menuitem_t OP_ServerOptionsMenu[] = { - {IT_STRING | IT_SUBMENU, NULL, "General netgame options...", &OP_NetgameOptionsDef, 10}, - {IT_STRING | IT_SUBMENU, NULL, "Gametype options...", &OP_GametypeOptionsDef, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Random Monitor Toggles...", &OP_MonitorToggleDef, 30}, - + {IT_HEADER, NULL, "General", NULL, 0}, #ifndef NONET {IT_STRING | IT_CVAR | IT_CV_STRING, - NULL, "Server name", &cv_servername, 50}, + NULL, "Server name", &cv_servername, 7}, + {IT_STRING | IT_CVAR, NULL, "Max Players", &cv_maxplayers, 21}, + {IT_STRING | IT_CVAR, NULL, "Allow Add-on Downloading", &cv_downloading, 26}, + {IT_STRING | IT_CVAR, NULL, "Allow players to join", &cv_allownewplayer, 31}, #endif + {IT_STRING | IT_CVAR, NULL, "Map progression", &cv_advancemap, 36}, + {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 41}, - {IT_STRING | IT_CVAR, NULL, "Intermission Timer", &cv_inttime, 80}, - {IT_STRING | IT_CVAR, NULL, "Advance to next map", &cv_advancemap, 90}, + {IT_HEADER, NULL, "Characters", NULL, 50}, + {IT_STRING | IT_CVAR, NULL, "Force a character", &cv_forceskin, 56}, + {IT_STRING | IT_CVAR, NULL, "Restrict character changes", &cv_restrictskinchange, 61}, + + {IT_HEADER, NULL, "Items", NULL, 70}, + {IT_STRING | IT_CVAR, NULL, "Item respawn delay", &cv_itemrespawntime, 76}, + {IT_STRING | IT_SUBMENU, NULL, "Mystery Item Monitor Toggles...", &OP_MonitorToggleDef, 81}, + + {IT_HEADER, NULL, "Cooperative", NULL, 90}, + {IT_STRING | IT_CVAR, NULL, "Players required for exit", &cv_playersforexit, 96}, + {IT_STRING | IT_CVAR, NULL, "Starposts", &cv_coopstarposts, 101}, + {IT_STRING | IT_CVAR, NULL, "Life sharing", &cv_cooplives, 106}, + {IT_STRING | IT_CVAR, NULL, "Post-goal free roaming", &cv_exitmove, 111}, + + {IT_HEADER, NULL, "Race, Competition", NULL, 120}, + {IT_STRING | IT_CVAR, NULL, "Level completion countdown", &cv_countdowntime, 126}, + {IT_STRING | IT_CVAR, NULL, "Item Monitors", &cv_competitionboxes, 131}, + + {IT_HEADER, NULL, "Ringslinger (Match, CTF, Tag, H&S)", NULL, 140}, + {IT_STRING | IT_CVAR, NULL, "Time Limit", &cv_timelimit, 146}, + {IT_STRING | IT_CVAR, NULL, "Score Limit", &cv_pointlimit, 151}, + {IT_STRING | IT_CVAR, NULL, "Overtime on Tie", &cv_overtime, 156}, + {IT_STRING | IT_CVAR, NULL, "Player respawn delay", &cv_respawntime, 161}, + + {IT_STRING | IT_CVAR, NULL, "Item Monitors", &cv_matchboxes, 171}, + {IT_STRING | IT_CVAR, NULL, "Weapon Rings", &cv_specialrings, 176}, + {IT_STRING | IT_CVAR, NULL, "Power Stones", &cv_powerstones, 181}, + + {IT_STRING | IT_CVAR, NULL, "Flag respawn delay", &cv_flagtime, 191}, + {IT_STRING | IT_CVAR, NULL, "Hiding time", &cv_hidetime, 196}, + + {IT_HEADER, NULL, "Teams", NULL, 205}, + {IT_STRING | IT_CVAR, NULL, "Autobalance sizes", &cv_autobalance, 211}, + {IT_STRING | IT_CVAR, NULL, "Scramble on Map Change", &cv_scrambleonchange, 216}, #ifndef NONET - {IT_STRING | IT_CVAR, NULL, "Max Players", &cv_maxplayers, 110}, - {IT_STRING | IT_CVAR, NULL, "Allow players to join", &cv_allownewplayer, 120}, - {IT_STRING | IT_CVAR, NULL, "Allow WAD Downloading", &cv_downloading, 130}, - {IT_STRING | IT_CVAR, NULL, "Attempts to Resynch", &cv_resynchattempts, 140}, + {IT_HEADER, NULL, "Advanced", NULL, 225}, + {IT_STRING | IT_CVAR | IT_CV_STRING, NULL, "Master server", &cv_masterserver, 231}, + {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 245}, #endif }; -static menuitem_t OP_NetgameOptionsMenu[] = -{ - {IT_STRING | IT_CVAR, NULL, "Time Limit", &cv_timelimit, 10}, - {IT_STRING | IT_CVAR, NULL, "Point Limit", &cv_pointlimit, 18}, - {IT_STRING | IT_CVAR, NULL, "Overtime Tie-Breaker", &cv_overtime, 26}, - - {IT_STRING | IT_CVAR, NULL, "Special Ring Weapons", &cv_specialrings, 42}, - {IT_STRING | IT_CVAR, NULL, "Emeralds", &cv_powerstones, 50}, - {IT_STRING | IT_CVAR, NULL, "Item Boxes", &cv_matchboxes, 58}, - {IT_STRING | IT_CVAR, NULL, "Item Respawn", &cv_itemrespawn, 66}, - {IT_STRING | IT_CVAR, NULL, "Item Respawn time", &cv_itemrespawntime, 74}, - - {IT_STRING | IT_CVAR, NULL, "Sudden Death", &cv_suddendeath, 90}, - {IT_STRING | IT_CVAR, NULL, "Player respawn delay", &cv_respawntime, 98}, - - {IT_STRING | IT_CVAR, NULL, "Force Skin #", &cv_forceskin, 114}, - {IT_STRING | IT_CVAR, NULL, "Restrict skin changes", &cv_restrictskinchange, 122}, - - {IT_STRING | IT_CVAR, NULL, "Autobalance Teams", &cv_autobalance, 138}, - {IT_STRING | IT_CVAR, NULL, "Scramble Teams on Map Change", &cv_scrambleonchange, 146}, -}; - -static menuitem_t OP_GametypeOptionsMenu[] = -{ - {IT_HEADER, NULL, "CO-OP", NULL, 2}, - {IT_STRING | IT_CVAR, NULL, "Players for exit", &cv_playersforexit, 10}, - {IT_STRING | IT_CVAR, NULL, "Starting Lives", &cv_startinglives, 18}, - - {IT_HEADER, NULL, "COMPETITION", NULL, 34}, - {IT_STRING | IT_CVAR, NULL, "Item Boxes", &cv_competitionboxes, 42}, - {IT_STRING | IT_CVAR, NULL, "Countdown Time", &cv_countdowntime, 50}, - - {IT_HEADER, NULL, "RACE", NULL, 66}, - {IT_STRING | IT_CVAR, NULL, "Number of Laps", &cv_numlaps, 74}, - {IT_STRING | IT_CVAR, NULL, "Use Map Lap Counts", &cv_usemapnumlaps, 82}, - - {IT_HEADER, NULL, "MATCH", NULL, 98}, - {IT_STRING | IT_CVAR, NULL, "Scoring Type", &cv_match_scoring, 106}, - - {IT_HEADER, NULL, "TAG", NULL, 122}, - {IT_STRING | IT_CVAR, NULL, "Hide Time", &cv_hidetime, 130}, - - {IT_HEADER, NULL, "CTF", NULL, 146}, - {IT_STRING | IT_CVAR, NULL, "Flag Respawn Time", &cv_flagtime, 154}, -}; - static menuitem_t OP_MonitorToggleMenu[] = { // Printing handled by drawing function - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Recycler", &cv_recycler, 20}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Teleporters", &cv_teleporters, 30}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Super Ring", &cv_superring, 40}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Super Sneakers", &cv_supersneakers, 50}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Invincibility", &cv_invincibility, 60}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Jump Shield", &cv_jumpshield, 70}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Elemental Shield", &cv_watershield, 80}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Attraction Shield", &cv_ringshield, 90}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Force Shield", &cv_forceshield, 100}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Armageddon Shield", &cv_bombshield, 110}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "1 Up", &cv_1up, 120}, - {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Eggman Box", &cv_eggmanbox, 130}, + {IT_STRING|IT_CALL, NULL, "Reset to defaults", M_ResetCvars, 15}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Recycler", &cv_recycler, 30}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Teleport", &cv_teleporters, 40}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Super Ring", &cv_superring, 50}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Super Sneakers", &cv_supersneakers, 60}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Invincibility", &cv_invincibility, 70}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Whirlwind Shield", &cv_jumpshield, 80}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Elemental Shield", &cv_watershield, 90}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Attraction Shield", &cv_ringshield, 100}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Force Shield", &cv_forceshield, 110}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Armageddon Shield", &cv_bombshield, 120}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "1 Up", &cv_1up, 130}, + {IT_STRING|IT_CVAR|IT_CV_INVISSLIDER, NULL, "Eggman Box", &cv_eggmanbox, 140}, }; // ========================================================================== @@ -1459,10 +1653,11 @@ static menuitem_t OP_MonitorToggleMenu[] = // ========================================================================== // Main Menu and related -menu_t MainDef = CENTERMENUSTYLE(NULL, MainMenu, NULL, 72); +menu_t MainDef = CENTERMENUSTYLE(MN_MAIN, NULL, MainMenu, NULL, 72); menu_t MISC_AddonsDef = { + MN_AD_MAIN, NULL, sizeof (MISC_AddonsMenu)/sizeof (menuitem_t), &MainDef, @@ -1478,9 +1673,23 @@ menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72); menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72); // Misc Main Menu -menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40); -menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef); +menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(MN_SPECIAL, NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40); +menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(MN_SPECIAL, NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40); + +// MP Gametype and map change menu +menu_t MISC_ChangeLevelDef = +{ + MN_SPECIAL, + NULL, + sizeof (MISC_ChangeLevelMenu)/sizeof (menuitem_t), + &MainDef, // Doesn't matter. + MISC_ChangeLevelMenu, + M_DrawLevelPlatterMenu, + 0, 0, + 0, + NULL +}; + menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu); static INT32 highlightflags, recommendedflags, warningflags; @@ -1489,50 +1698,52 @@ static INT32 highlightflags, recommendedflags, warningflags; // Sky Room menu_t SR_PandoraDef = { + MN_SR_MAIN + (MN_SR_PANDORA << 6), "M_PANDRA", sizeof (SR_PandorasBox)/sizeof (menuitem_t), &SPauseDef, SR_PandorasBox, M_DrawGenericMenu, - 60, 40, + 60, 30, 0, M_ExitPandorasBox }; -menu_t SR_MainDef = -{ - "M_SECRET", - sizeof (SR_MainMenu)/sizeof (menuitem_t), - &MainDef, - SR_MainMenu, - M_DrawSkyRoom, - 60, 40, - 0, - NULL -}; -menu_t SR_LevelSelectDef = -{ - 0, - sizeof (SR_LevelSelectMenu)/sizeof (menuitem_t), - &SR_MainDef, - SR_LevelSelectMenu, - M_DrawLevelSelectMenu, - 40, 40, - 0, - NULL -}; + +menu_t SR_MainDef = DEFAULTMENUSTYLE(MN_SR_MAIN, "M_SECRET", SR_MainMenu, &MainDef, 60, 40); + +menu_t SR_LevelSelectDef = MAPPLATTERMENUSTYLE( + MN_SR_MAIN + (MN_SR_LEVELSELECT << 6), + NULL, SR_LevelSelectMenu); + menu_t SR_UnlockChecklistDef = { - NULL, + MN_SR_MAIN + (MN_SR_UNLOCKCHECKLIST << 6), + "M_SECRET", 1, &SR_MainDef, SR_UnlockChecklistMenu, M_DrawChecklist, - 280, 185, + 30, 30, 0, NULL }; + +menu_t SR_SoundTestDef = +{ + MN_SR_MAIN + (MN_SR_SOUNDTEST << 6), + NULL, + sizeof (SR_SoundTestMenu)/sizeof (menuitem_t), + &SR_MainDef, + SR_SoundTestMenu, + M_DrawSoundTest, + 60, 150, + 0, + NULL +}; + menu_t SR_EmblemHintDef = { + MN_SR_MAIN + (MN_SR_EMBLEMHINT << 6), NULL, sizeof (SR_EmblemHintMenu)/sizeof (menuitem_t), &SPauseDef, @@ -1544,9 +1755,22 @@ menu_t SR_EmblemHintDef = }; // Single Player -menu_t SP_MainDef = CENTERMENUSTYLE(NULL, SP_MainMenu, &MainDef, 72); +menu_t SP_MainDef = //CENTERMENUSTYLE(NULL, SP_MainMenu, &MainDef, 72); +{ + MN_SP_MAIN, + NULL, + sizeof(SP_MainMenu)/sizeof(menuitem_t), + &MainDef, + SP_MainMenu, + M_DrawCenteredMenu, + BASEVIDWIDTH/2, 72, + 0, + NULL +}; + menu_t SP_LoadDef = { + MN_SP_MAIN + (MN_SP_LOAD << 6), "M_PICKG", 1, &SP_MainDef, @@ -1556,21 +1780,14 @@ menu_t SP_LoadDef = 0, NULL }; -menu_t SP_LevelSelectDef = MAPICONMENUSTYLE(NULL, SP_LevelSelectMenu, &SP_LoadDef); -menu_t SP_GameStatsDef = -{ - "M_STATS", - 1, - &SP_MainDef, - SP_GameStatsMenu, - M_DrawGameStats, - 280, 185, - 0, - NULL -}; +menu_t SP_LevelSelectDef = MAPPLATTERMENUSTYLE( + MN_SP_MAIN + (MN_SP_LOAD << 6) + (MN_SP_PLAYER << 12) + (MN_SP_LEVELSELECT << 18), + NULL, SP_LevelSelectMenu); + menu_t SP_LevelStatsDef = { + MN_SP_MAIN + (MN_SP_LEVELSTATS << 6), "M_STATS", 1, &SP_MainDef, @@ -1581,8 +1798,13 @@ menu_t SP_LevelStatsDef = NULL }; +menu_t SP_TimeAttackLevelSelectDef = MAPPLATTERMENUSTYLE( + MN_SP_MAIN + (MN_SP_TIMEATTACK << 6) + (MN_SP_TIMEATTACK_LEVELSELECT << 12), + "M_ATTACK", SP_TimeAttackLevelSelectMenu); + static menu_t SP_TimeAttackDef = { + MN_SP_MAIN + (MN_SP_TIMEATTACK << 6), "M_ATTACK", sizeof (SP_TimeAttackMenu)/sizeof (menuitem_t), &MainDef, // Doesn't matter. @@ -1594,6 +1816,7 @@ static menu_t SP_TimeAttackDef = }; static menu_t SP_ReplayDef = { + MN_SP_MAIN + (MN_SP_TIMEATTACK << 6) + (MN_SP_REPLAY << 12), "M_ATTACK", sizeof(SP_ReplayMenu)/sizeof(menuitem_t), &SP_TimeAttackDef, @@ -1605,6 +1828,7 @@ static menu_t SP_ReplayDef = }; static menu_t SP_GuestReplayDef = { + MN_SP_MAIN + (MN_SP_TIMEATTACK << 6) + (MN_SP_GUESTREPLAY << 12), "M_ATTACK", sizeof(SP_GuestReplayMenu)/sizeof(menuitem_t), &SP_TimeAttackDef, @@ -1616,6 +1840,7 @@ static menu_t SP_GuestReplayDef = }; static menu_t SP_GhostDef = { + MN_SP_MAIN + (MN_SP_TIMEATTACK << 6) + (MN_SP_GHOST << 12), "M_ATTACK", sizeof(SP_GhostMenu)/sizeof(menuitem_t), &SP_TimeAttackDef, @@ -1626,8 +1851,13 @@ static menu_t SP_GhostDef = NULL }; +menu_t SP_NightsAttackLevelSelectDef = MAPPLATTERMENUSTYLE( + MN_SP_MAIN + (MN_SP_NIGHTSATTACK << 6) + (MN_SP_NIGHTS_LEVELSELECT << 12), + "M_NIGHTS", SP_NightsAttackLevelSelectMenu); + static menu_t SP_NightsAttackDef = { + MN_SP_MAIN + (MN_SP_NIGHTSATTACK << 6), "M_NIGHTS", sizeof (SP_NightsAttackMenu)/sizeof (menuitem_t), &MainDef, // Doesn't matter. @@ -1639,6 +1869,7 @@ static menu_t SP_NightsAttackDef = }; static menu_t SP_NightsReplayDef = { + MN_SP_MAIN + (MN_SP_NIGHTSATTACK << 6) + (MN_SP_NIGHTS_REPLAY << 12), "M_NIGHTS", sizeof(SP_NightsReplayMenu)/sizeof(menuitem_t), &SP_NightsAttackDef, @@ -1650,6 +1881,7 @@ static menu_t SP_NightsReplayDef = }; static menu_t SP_NightsGuestReplayDef = { + MN_SP_MAIN + (MN_SP_NIGHTSATTACK << 6) + (MN_SP_NIGHTS_GUESTREPLAY << 12), "M_NIGHTS", sizeof(SP_NightsGuestReplayMenu)/sizeof(menuitem_t), &SP_NightsAttackDef, @@ -1661,6 +1893,7 @@ static menu_t SP_NightsGuestReplayDef = }; static menu_t SP_NightsGhostDef = { + MN_SP_MAIN + (MN_SP_NIGHTSATTACK << 6) + (MN_SP_NIGHTS_GHOST << 12), "M_NIGHTS", sizeof(SP_NightsGhostMenu)/sizeof(menuitem_t), &SP_NightsAttackDef, @@ -1674,10 +1907,11 @@ static menu_t SP_NightsGhostDef = menu_t SP_PlayerDef = { + MN_SP_MAIN + (MN_SP_LOAD << 6) + (MN_SP_PLAYER << 12), "M_PICKP", - sizeof (PlayerMenu)/sizeof (menuitem_t),//player_end, + sizeof (SP_PlayerMenu)/sizeof (menuitem_t), &SP_MainDef, - PlayerMenu, + SP_PlayerMenu, M_DrawSetupChoosePlayerMenu, 24, 32, 0, @@ -1685,11 +1919,55 @@ menu_t SP_PlayerDef = }; // Multiplayer -menu_t MP_MainDef = DEFAULTMENUSTYLE("M_MULTI", MP_MainMenu, &MainDef, 60, 40); -menu_t MP_ServerDef = MAPICONMENUSTYLE("M_MULTI", MP_ServerMenu, &MP_MainDef); + +menu_t MP_SplitServerDef = +{ + MN_MP_MAIN + (MN_MP_SPLITSCREEN << 6), + "M_MULTI", + sizeof (MP_SplitServerMenu)/sizeof (menuitem_t), #ifndef NONET + &MP_MainDef, +#else + &MainDef, +#endif + MP_SplitServerMenu, + M_DrawServerMenu, + 27, 30 - 50, + 0, + NULL +}; + +#ifndef NONET + +menu_t MP_MainDef = +{ + MN_MP_MAIN, + "M_MULTI", + sizeof (MP_MainMenu)/sizeof (menuitem_t), + &MainDef, + MP_MainMenu, + M_DrawMPMainMenu, + 27, 40, + 0, + M_CancelConnect +}; + +menu_t MP_ServerDef = +{ + MN_MP_MAIN + (MN_MP_SERVER << 6), + "M_MULTI", + sizeof (MP_ServerMenu)/sizeof (menuitem_t), + &MP_MainDef, + MP_ServerMenu, + M_DrawServerMenu, + 27, 30, + 0, + NULL +}; + menu_t MP_ConnectDef = { + MN_MP_MAIN + (MN_MP_CONNECT << 6), "M_MULTI", sizeof (MP_ConnectMenu)/sizeof (menuitem_t), &MP_MainDef, @@ -1699,19 +1977,10 @@ menu_t MP_ConnectDef = 0, M_CancelConnect }; -menu_t MP_ConnectIPDef = -{ - "M_MULTI", - sizeof (MP_ConnectIPMenu)/sizeof (menuitem_t), - &MP_MainDef, - MP_ConnectIPMenu, - M_DrawConnectIPMenu, - 27,40, - 0, - M_CancelConnect -}; + menu_t MP_RoomDef = { + MN_MP_MAIN + (MN_MP_ROOM << 6), "M_MULTI", sizeof (MP_RoomMenu)/sizeof (menuitem_t), &MP_ConnectDef, @@ -1722,47 +1991,139 @@ menu_t MP_RoomDef = NULL }; #endif -menu_t MP_SplitServerDef = MAPICONMENUSTYLE("M_MULTI", MP_SplitServerMenu, &MP_MainDef); + menu_t MP_PlayerSetupDef = { +#ifdef NONET + MN_MP_MAIN + (MN_MP_PLAYERSETUP << 6), +#else + MN_MP_MAIN + (MN_MP_SPLITSCREEN << 6) + (MN_MP_PLAYERSETUP << 12), +#endif "M_SPLAYR", sizeof (MP_PlayerSetupMenu)/sizeof (menuitem_t), - &MP_MainDef, + &MainDef, // doesn't matter MP_PlayerSetupMenu, M_DrawSetupMultiPlayerMenu, - 27, 40, + 19, 22, 0, M_QuitMultiPlayerMenu }; // Options -menu_t OP_MainDef = DEFAULTMENUSTYLE("M_OPTTTL", OP_MainMenu, &MainDef, 60, 30); -menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30); -menu_t OP_ControlListDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlListMenu, &OP_ControlsDef, 60, 30); -menu_t OP_MoveControlsDef = CONTROLMENUSTYLE(OP_MoveControlsMenu, &OP_ControlListDef); -menu_t OP_MPControlsDef = CONTROLMENUSTYLE(OP_MPControlsMenu, &OP_ControlListDef); -menu_t OP_MiscControlsDef = CONTROLMENUSTYLE(OP_MiscControlsMenu, &OP_ControlListDef); -menu_t OP_P1ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_P1ControlsMenu, &OP_ControlsDef, 60, 30); -menu_t OP_P2ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_P2ControlsMenu, &OP_ControlsDef, 60, 30); -menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_P1ControlsDef, 60, 30); -menu_t OP_Mouse2OptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_Mouse2OptionsMenu, &OP_P2ControlsDef, 60, 30); -menu_t OP_Joystick1Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_P1ControlsDef, 60, 30); -menu_t OP_Joystick2Def = DEFAULTMENUSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_P2ControlsDef, 60, 30); +menu_t OP_MainDef = DEFAULTMENUSTYLE( + MN_OP_MAIN, + "M_OPTTTL", OP_MainMenu, &MainDef, 50, 30); +menu_t OP_ChangeControlsDef = CONTROLMENUSTYLE( + MN_OP_MAIN + (MN_OP_CHANGECONTROLS << 12), // second level (<<6) set on runtime + OP_ChangeControlsMenu, &OP_MainDef); + +menu_t OP_P1ControlsDef = { + MN_OP_MAIN + (MN_OP_P1CONTROLS << 6), + "M_CONTRO", + sizeof(OP_P1ControlsMenu)/sizeof(menuitem_t), + &OP_MainDef, + OP_P1ControlsMenu, + M_DrawControlsDefMenu, + 50, 30, 0, NULL}; +menu_t OP_P2ControlsDef = { + MN_OP_MAIN + (MN_OP_P2CONTROLS << 6), + "M_CONTRO", + sizeof(OP_P2ControlsMenu)/sizeof(menuitem_t), + &OP_MainDef, + OP_P2ControlsMenu, + M_DrawControlsDefMenu, + 50, 30, 0, NULL}; + +menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_P1MOUSE << 12), + "M_CONTRO", OP_MouseOptionsMenu, &OP_P1ControlsDef, 35, 30); +menu_t OP_Mouse2OptionsDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_P2CONTROLS << 6) + (MN_OP_P2MOUSE << 12), + "M_CONTRO", OP_Mouse2OptionsMenu, &OP_P2ControlsDef, 35, 30); +menu_t OP_Joystick1Def = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_P1JOYSTICK << 12), + "M_CONTRO", OP_Joystick1Menu, &OP_P1ControlsDef, 50, 30); +menu_t OP_Joystick2Def = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_P2CONTROLS << 6) + (MN_OP_P2JOYSTICK << 12), + "M_CONTRO", OP_Joystick2Menu, &OP_P2ControlsDef, 50, 30); menu_t OP_JoystickSetDef = { + MN_OP_MAIN + (MN_OP_JOYSTICKSET << MENUBITS*3), // second (<<6) and third level (<<12) set on runtime "M_CONTRO", sizeof (OP_JoystickSetMenu)/sizeof (menuitem_t), &OP_Joystick1Def, OP_JoystickSetMenu, M_DrawJoystick, - 50, 40, + 60, 40, 0, NULL }; -menu_t OP_VideoOptionsDef = DEFAULTMENUSTYLE("M_VIDEO", OP_VideoOptionsMenu, &OP_MainDef, 60, 30); +menu_t OP_CameraOptionsDef = { + MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_P1CAMERA << 12), + "M_CONTRO", + sizeof (OP_CameraOptionsMenu)/sizeof (menuitem_t), + &OP_P1ControlsDef, + OP_CameraOptionsMenu, + M_DrawCameraOptionsMenu, + 35, 30, + 0, + NULL +}; +menu_t OP_Camera2OptionsDef = { + MN_OP_MAIN + (MN_OP_P2CONTROLS << 6) + (MN_OP_P2CAMERA << 12), + "M_CONTRO", + sizeof (OP_Camera2OptionsMenu)/sizeof (menuitem_t), + &OP_P2ControlsDef, + OP_Camera2OptionsMenu, + M_DrawCameraOptionsMenu, + 35, 30, + 0, + NULL +}; + +static menuitem_t OP_PlaystyleMenu[] = {{IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandlePlaystyleMenu, 0}}; + +menu_t OP_PlaystyleDef = { + MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_PLAYSTYLE << 12), + NULL, + 1, + &OP_P1ControlsDef, + OP_PlaystyleMenu, + M_DrawPlaystyleMenu, + 0, 0, 0, NULL +}; + +static void M_VideoOptions(INT32 choice) +{ + (void)choice; +#ifdef HWRENDER + if (hwrenderloaded == -1) + { + OP_VideoOptionsMenu[op_video_renderer].status = (IT_TRANSTEXT | IT_PAIR); + OP_VideoOptionsMenu[op_video_renderer].patch = "Renderer"; + OP_VideoOptionsMenu[op_video_renderer].text = "Software"; + } + +#endif + M_SetupNextMenu(&OP_VideoOptionsDef); +} + +menu_t OP_VideoOptionsDef = +{ + MN_OP_MAIN + (MN_OP_VIDEO << 6), + "M_VIDEO", + sizeof (OP_VideoOptionsMenu)/sizeof (menuitem_t), + &OP_MainDef, + OP_VideoOptionsMenu, + M_DrawMainVideoMenu, + 30, 30, + 0, + NULL +}; menu_t OP_VideoModeDef = { + MN_OP_MAIN + (MN_OP_VIDEO << 6) + (MN_OP_VIDEOMODE << 12), "M_VIDEO", 1, &OP_VideoOptionsDef, @@ -1772,15 +2133,30 @@ menu_t OP_VideoModeDef = 0, NULL }; -menu_t OP_SoundOptionsDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 60, 30); -menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 30); -menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 30, 30); +menu_t OP_ColorOptionsDef = +{ + MN_OP_MAIN + (MN_OP_VIDEO << 6) + (MN_OP_COLOR << 12), + "M_VIDEO", + sizeof (OP_ColorOptionsMenu)/sizeof (menuitem_t), + &OP_VideoOptionsDef, + OP_ColorOptionsMenu, + M_DrawColorMenu, + 30, 30, + 0, + NULL +}; +menu_t OP_SoundOptionsDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_SOUND << 6), + "M_SOUND", OP_SoundOptionsMenu, &OP_MainDef, 30, 30); +menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE(MN_OP_MAIN + (MN_OP_SOUND << 6), "M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); + +menu_t OP_ServerOptionsDef = DEFAULTSCROLLMENUSTYLE( + MN_OP_MAIN + (MN_OP_SERVER << 6), + "M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 30, 30); -menu_t OP_NetgameOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_NetgameOptionsMenu, &OP_ServerOptionsDef, 30, 30); -menu_t OP_GametypeOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_GametypeOptionsMenu, &OP_ServerOptionsDef, 30, 30); -menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_ChatOptionsMenu, &OP_GameOptionsDef, 30, 30); menu_t OP_MonitorToggleDef = { + MN_OP_MAIN + (MN_OP_SERVER << 6) + (MN_OP_MONITORTOGGLE << 12), "M_SERVER", sizeof (OP_MonitorToggleMenu)/sizeof (menuitem_t), &OP_ServerOptionsDef, @@ -1792,12 +2168,25 @@ menu_t OP_MonitorToggleDef = }; #ifdef HWRENDER -menu_t OP_OpenGLOptionsDef = DEFAULTMENUSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); +static void M_OpenGLOptionsMenu(void) +{ + if (rendermode == render_opengl) + M_SetupNextMenu(&OP_OpenGLOptionsDef); + else + M_StartMessage(M_GetText("You must be in OpenGL mode\nto access this menu.\n\n(Press a key)\n"), NULL, MM_NOTHING); +} + +menu_t OP_OpenGLOptionsDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_VIDEO << 6) + (MN_OP_OPENGL << 12), + "M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); #ifdef ALAM_LIGHTING -menu_t OP_OpenGLLightingDef = DEFAULTMENUSTYLE("M_VIDEO", OP_OpenGLLightingMenu, &OP_OpenGLOptionsDef, 60, 40); +menu_t OP_OpenGLLightingDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_VIDEO << 6) + (MN_OP_OPENGL << 12) + (MN_OP_OPENGL_LIGHTING << 18), + "M_VIDEO", OP_OpenGLLightingMenu, &OP_OpenGLOptionsDef, 60, 40); #endif menu_t OP_OpenGLFogDef = { + MN_OP_MAIN + (MN_OP_VIDEO << 6) + (MN_OP_OPENGL << 12) + (MN_OP_OPENGL_FOG << 18), "M_VIDEO", sizeof (OP_OpenGLFogMenu)/sizeof (menuitem_t), &OP_OpenGLOptionsDef, @@ -1807,22 +2196,31 @@ menu_t OP_OpenGLFogDef = 0, NULL }; -menu_t OP_OpenGLColorDef = +#endif +menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_DATA << 6), + "M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); + +menu_t OP_ScreenshotOptionsDef = { - "M_VIDEO", - sizeof (OP_OpenGLColorMenu)/sizeof (menuitem_t), - &OP_OpenGLOptionsDef, - OP_OpenGLColorMenu, - M_OGL_DrawColorMenu, - 60, 40, + MN_OP_MAIN + (MN_OP_DATA << 6) + (MN_OP_SCREENSHOTS << 12), + "M_SCREEN", + sizeof (OP_ScreenshotOptionsMenu)/sizeof (menuitem_t), + &OP_DataOptionsDef, + OP_ScreenshotOptionsMenu, + M_DrawScreenshotMenu, + 30, 30, 0, NULL }; -#endif -menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); -menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30); -menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_MainDef, 30, 30); -menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 60, 30); + +menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_DATA << 6) + (MN_OP_ADDONS << 12), + "M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30); + +menu_t OP_EraseDataDef = DEFAULTMENUSTYLE( + MN_OP_MAIN + (MN_OP_DATA << 6) + (MN_OP_ERASEDATA << 12), + "M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 60, 30); // ========================================================================== // CVAR ONCHANGE EVENTS GO HERE @@ -1830,11 +2228,11 @@ menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOp // (there's only a couple anyway) // Prototypes -static INT32 M_FindFirstMap(INT32 gtype); -static INT32 M_GetFirstLevelInList(void); +static INT32 M_GetFirstLevelInList(INT32 gt); +static boolean M_CanShowLevelOnPlatter(INT32 mapnum, INT32 gt); -// Nextmap. Used for Time Attack. -static void Nextmap_OnChange(void) +// Nextmap. Used for Level select. +void Nextmap_OnChange(void) { char *leveltitle; char tabase[256]; @@ -1906,7 +2304,7 @@ static void Nextmap_OnChange(void) SP_TimeAttackMenu[taghost].status = IT_DISABLED; // Check if file exists, if not, disable REPLAY option - sprintf(tabase,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s",srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string); + sprintf(tabase,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s",srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name); for (i = 0; i < 5; i++) { SP_ReplayMenu[i].status = IT_DISABLED; SP_GuestReplayMenu[i].status = IT_DISABLED; @@ -1978,46 +2376,51 @@ static void Newgametype_OnChange(void) if(!mapheaderinfo[cv_nextmap.value-1]) P_AllocMapHeader((INT16)(cv_nextmap.value-1)); - if ((cv_newgametype.value == GT_COOP && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_COOP)) || - (cv_newgametype.value == GT_COMPETITION && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_COMPETITION)) || - (cv_newgametype.value == GT_RACE && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_RACE)) || - ((cv_newgametype.value == GT_MATCH || cv_newgametype.value == GT_TEAMMATCH) && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_MATCH)) || - ((cv_newgametype.value == GT_TAG || cv_newgametype.value == GT_HIDEANDSEEK) && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_TAG)) || - (cv_newgametype.value == GT_CTF && !(mapheaderinfo[cv_nextmap.value-1]->typeoflevel & TOL_CTF))) - { - INT32 value = 0; - - switch (cv_newgametype.value) - { - case GT_COOP: - value = TOL_COOP; - break; - case GT_COMPETITION: - value = TOL_COMPETITION; - break; - case GT_RACE: - value = TOL_RACE; - break; - case GT_MATCH: - case GT_TEAMMATCH: - value = TOL_MATCH; - break; - case GT_TAG: - case GT_HIDEANDSEEK: - value = TOL_TAG; - break; - case GT_CTF: - value = TOL_CTF; - break; - } - - CV_SetValue(&cv_nextmap, M_FindFirstMap(value)); - CV_AddValue(&cv_nextmap, -1); - CV_AddValue(&cv_nextmap, 1); - } + if (!M_CanShowLevelOnPlatter(cv_nextmap.value-1, cv_newgametype.value)) + CV_SetValue(&cv_nextmap, M_GetFirstLevelInList(cv_newgametype.value)); } } +#ifdef HWRENDER +static void Newrenderer_AREYOUSURE(INT32 c) +{ + int n; + switch (c) + { + case 'y': + case KEY_ENTER: + n = cv_newrenderer.value; + newrenderer_set |= n; + CV_SetValue(&cv_renderer, n); + break; + default: + CV_StealthSetValue(&cv_newrenderer, cv_renderer.value); + } +} + +static void Newrenderer_OnChange(void) +{ + /* Well this works for now because there's only two options. */ + int n; + n = cv_newrenderer.value; + newrenderer_set |= cv_renderer.value; + if (( newrenderer_set & n )) + CV_SetValue(&cv_renderer, n); + else + { + M_StartMessage( + "The OpenGL renderer is incomplete.\n" + "Some visuals may fail to appear, or\n" + "appear incorrectly.\n" + "Do you still want to switch to it?\n" + "\n" + "(Press 'y' or 'n')", + Newrenderer_AREYOUSURE, MM_YESNO + ); + } +} +#endif/*HWRENDER*/ + void Screenshot_option_Onchange(void) { OP_ScreenshotOptionsMenu[op_screenshot_folder].status = @@ -2053,6 +2456,12 @@ void Addons_option_Onchange(void) (cv_addons_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); } +void Moviemode_option_Onchange(void) +{ + OP_ScreenshotOptionsMenu[op_movie_folder].status = + (cv_movie_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); +} + // ========================================================================== // END ORGANIZATION STUFF. // ========================================================================== @@ -2060,36 +2469,615 @@ void Addons_option_Onchange(void) // current menudef menu_t *currentMenu = &MainDef; +// ========================================================================= +// MENU PRESENTATION PARAMETER HANDLING (BACKGROUNDS) +// ========================================================================= + +// menu IDs are equal to current/prevMenu in most cases, except MN_SPECIAL when we don't want to operate on Message, Pause, etc. +UINT32 prevMenuId = 0; +UINT32 activeMenuId = 0; + +menupres_t menupres[NUMMENUTYPES]; + +void M_InitMenuPresTables(void) +{ + INT32 i; + + // Called in d_main before SOC can get to the tables + // Set menupres defaults + for (i = 0; i < NUMMENUTYPES; i++) + { + // so-called "undefined" + menupres[i].fadestrength = -1; + menupres[i].hidetitlepics = -1; // inherits global hidetitlepics + menupres[i].ttmode = TTMODE_NONE; + menupres[i].ttscale = UINT8_MAX; + menupres[i].ttname[0] = 0; + menupres[i].ttx = INT16_MAX; + menupres[i].tty = INT16_MAX; + menupres[i].ttloop = INT16_MAX; + menupres[i].tttics = UINT16_MAX; + menupres[i].enterwipe = -1; + menupres[i].exitwipe = -1; + menupres[i].bgcolor = -1; + menupres[i].titlescrollxspeed = INT32_MAX; + menupres[i].titlescrollyspeed = INT32_MAX; + menupres[i].bghide = true; + // default true + menupres[i].enterbubble = true; + menupres[i].exitbubble = true; + + if (i != MN_MAIN) + { + menupres[i].muslooping = true; + } + if (i == MN_SP_TIMEATTACK) + strncpy(menupres[i].musname, "_recat", 7); + else if (i == MN_SP_NIGHTSATTACK) + strncpy(menupres[i].musname, "_nitat", 7); + else if (i == MN_SP_PLAYER || i == MN_SR_PLAYER) + strncpy(menupres[i].musname, "_chsel", 7); + else if (i == MN_SR_SOUNDTEST) + { + *menupres[i].musname = '\0'; + menupres[i].musstop = true; + } + } +} + +// ==================================== +// TREE ITERATION +// ==================================== + +// UINT32 menutype - current menutype_t +// INT32 level - current level up the tree, higher means younger +// INT32 *retval - Return value +// void *input - Pointer to input of any type +// +// return true - stop iterating +// return false - continue +typedef boolean (*menutree_iterator)(UINT32, INT32, INT32 *, void **, boolean fromoldest); + +// HACK: Used in the ChangeMusic iterator because we only allow +// a single input. Maybe someday use this struct program-wide. +typedef struct +{ + char musname[7]; + UINT16 mustrack; + boolean muslooping; +} menupresmusic_t; + +static INT32 M_IterateMenuTree(menutree_iterator itfunc, void *input) +{ + INT32 i, retval = 0; + UINT32 bitmask, menutype; + + for (i = NUMMENULEVELS; i >= 0; i--) + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + menutype = (activeMenuId & bitmask) >> (MENUBITS*i); + if (itfunc(menutype, i, &retval, &input, false)) + break; + } + + return retval; +} + +// ==================================== +// ITERATORS +// ==================================== + +static boolean MIT_GetMenuAtLevel(UINT32 menutype, INT32 level, INT32 *retval, void **input, boolean fromoldest) +{ + INT32 *inputptr = (INT32*)*input; + INT32 targetlevel = *inputptr; + if (menutype) + { + if (level == targetlevel || targetlevel < 0) + { + *retval = menutype; + return true; + } + } + else if (targetlevel >= 0) + { + // offset targetlevel by failed attempts; this should only happen in beginning of iteration + if (fromoldest) + (*inputptr)++; + else + (*inputptr)--; // iterating backwards, so count from highest + } + return false; +} + +static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, void **input, boolean fromoldest) +{ + char *defaultname = (char*)*input; + + (void)retval; + (void)fromoldest; + + if (!menutype) // if there's nothing in this level, do nothing + return false; + + if (menupres[menutype].bgcolor >= 0) + { + curbgcolor = menupres[menutype].bgcolor; + return true; + } + else if (menupres[menutype].bghide && titlemapinaction) // hide the background + { + curbghide = true; + return true; + } + else if (menupres[menutype].bgname[0]) + { + strncpy(curbgname, menupres[menutype].bgname, 8); + curbgxspeed = menupres[menutype].titlescrollxspeed != INT32_MAX ? menupres[menutype].titlescrollxspeed : titlescrollxspeed; + curbgyspeed = menupres[menutype].titlescrollyspeed != INT32_MAX ? menupres[menutype].titlescrollyspeed : titlescrollyspeed; + return true; + } + else if (!level) + { + if (M_GetYoungestChildMenu() == MN_SP_PLAYER || !defaultname || !defaultname[0]) + curbgcolor = 31; + else if (titlemapinaction) // hide the background by default in titlemap + curbghide = true; + else + { + strncpy(curbgname, defaultname, 9); + curbgxspeed = (gamestate == GS_TIMEATTACK) ? 0 : titlescrollxspeed; + curbgyspeed = (gamestate == GS_TIMEATTACK) ? 0 : titlescrollyspeed; + } + } + return false; +} + +static boolean MIT_ChangeMusic(UINT32 menutype, INT32 level, INT32 *retval, void **input, boolean fromoldest) +{ + menupresmusic_t *defaultmusic = (menupresmusic_t*)*input; + + (void)retval; + (void)fromoldest; + + if (!menutype) // if there's nothing in this level, do nothing + return false; + + if (menupres[menutype].musname[0]) + { + S_ChangeMusic(menupres[menutype].musname, menupres[menutype].mustrack, menupres[menutype].muslooping); + return true; + } + else if (menupres[menutype].musstop) + { + S_StopMusic(); + return true; + } + else if (menupres[menutype].musignore) + return true; + else if (!level && defaultmusic && defaultmusic->musname[0]) + S_ChangeMusic(defaultmusic->musname, defaultmusic->mustrack, defaultmusic->muslooping); + return false; +} + +static boolean MIT_SetCurFadeValue(UINT32 menutype, INT32 level, INT32 *retval, void **input, boolean fromoldest) +{ + UINT8 defaultvalue = *(UINT8*)*input; + + (void)retval; + (void)fromoldest; + + if (!menutype) // if there's nothing in this level, do nothing + return false; + + if (menupres[menutype].fadestrength >= 0) + { + curfadevalue = (menupres[menutype].fadestrength % 32); + return true; + } + else if (!level) + curfadevalue = (gamestate == GS_TIMEATTACK) ? 0 : (defaultvalue % 32); + return false; +} + +static boolean MIT_SetCurTitlePics(UINT32 menutype, INT32 level, INT32 *retval, void **input, boolean fromoldest) +{ + (void)input; + (void)retval; + (void)fromoldest; + + if (!menutype) // if there's nothing in this level, do nothing + return false; + + if (menupres[menutype].hidetitlepics >= 0) + { + curhidepics = menupres[menutype].hidetitlepics; + return true; + } + else if (menupres[menutype].ttmode == TTMODE_USER) + { + if (menupres[menutype].ttname[0]) + { + curhidepics = menupres[menutype].hidetitlepics; + curttmode = menupres[menutype].ttmode; + curttscale = (menupres[menutype].ttscale != UINT8_MAX ? menupres[menutype].ttscale : ttscale); + strncpy(curttname, menupres[menutype].ttname, 9); + curttx = (menupres[menutype].ttx != INT16_MAX ? menupres[menutype].ttx : ttx); + curtty = (menupres[menutype].tty != INT16_MAX ? menupres[menutype].tty : tty); + curttloop = (menupres[menutype].ttloop != INT16_MAX ? menupres[menutype].ttloop : ttloop); + curtttics = (menupres[menutype].tttics != UINT16_MAX ? menupres[menutype].tttics : tttics); + } + else + curhidepics = menupres[menutype].hidetitlepics; + return true; + } + else if (menupres[menutype].ttmode != TTMODE_NONE) + { + curhidepics = menupres[menutype].hidetitlepics; + curttmode = menupres[menutype].ttmode; + curttscale = (menupres[menutype].ttscale != UINT8_MAX ? menupres[menutype].ttscale : ttscale); + return true; + } + else if (!level) + { + curhidepics = hidetitlepics; + curttmode = ttmode; + curttscale = ttscale; + strncpy(curttname, ttname, 9); + curttx = ttx; + curtty = tty; + curttloop = ttloop; + curtttics = tttics; + } + return false; +} + +// ==================================== +// TREE RETRIEVAL +// ==================================== + +UINT8 M_GetYoungestChildMenu(void) // aka the active menu +{ + INT32 targetlevel = -1; + return M_IterateMenuTree(MIT_GetMenuAtLevel, &targetlevel); +} + +// ==================================== +// EFFECTS +// ==================================== + +void M_ChangeMenuMusic(const char *defaultmusname, boolean defaultmuslooping) +{ + menupresmusic_t defaultmusic; + + if (!defaultmusname) + defaultmusname = ""; + + strncpy(defaultmusic.musname, defaultmusname, 7); + defaultmusic.musname[6] = 0; + defaultmusic.mustrack = 0; + defaultmusic.muslooping = defaultmuslooping; + + M_IterateMenuTree(MIT_ChangeMusic, &defaultmusic); +} + +void M_SetMenuCurBackground(const char *defaultname) +{ + char name[9]; + strncpy(name, defaultname, 8); + M_IterateMenuTree(MIT_SetCurBackground, &name); +} + +void M_SetMenuCurFadeValue(UINT8 defaultvalue) +{ + M_IterateMenuTree(MIT_SetCurFadeValue, &defaultvalue); +} + +void M_SetMenuCurTitlePics(void) +{ + M_IterateMenuTree(MIT_SetCurTitlePics, NULL); +} + +// ==================================== +// MENU STATE +// ==================================== + +static INT32 exitlevel, enterlevel, anceslevel; +static INT16 exittype, entertype; +static INT16 exitwipe, enterwipe; +static boolean exitbubble, enterbubble; +static INT16 exittag, entertag; + +static void M_HandleMenuPresState(menu_t *newMenu) +{ + INT32 i; + UINT32 bitmask; + SINT8 prevtype, activetype, menutype; + + if (!newMenu) + return; + + // Look for MN_SPECIAL here, because our iterators can't look at new menu IDs + for (i = 0; i <= NUMMENULEVELS; i++) + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + menutype = (newMenu->menuid & bitmask) >> (MENUBITS*i); + prevtype = (currentMenu->menuid & bitmask) >> (MENUBITS*i); + if (menutype == MN_SPECIAL || prevtype == MN_SPECIAL) + return; + } + + if (currentMenu && newMenu && currentMenu->menuid == newMenu->menuid) // same menu? + return; + + exittype = entertype = exitlevel = enterlevel = anceslevel = exitwipe = enterwipe = -1; + exitbubble = enterbubble = true; + + prevMenuId = currentMenu ? currentMenu->menuid : 0; + activeMenuId = newMenu ? newMenu->menuid : 0; + + // Set defaults for presentation values + strncpy(curbgname, "TITLESKY", 9); + curfadevalue = 16; + curhidepics = hidetitlepics; + curbgcolor = -1; + curbgxspeed = titlescrollxspeed; + curbgyspeed = titlescrollyspeed; + curbghide = (gamestate != GS_TIMEATTACK); // show in time attack, hide in other menus + + curttmode = ttmode; + curttscale = ttscale; + strncpy(curttname, ttname, 9); + curttx = ttx; + curtty = tty; + curttloop = ttloop; + curtttics = tttics; + + // don't do the below during the in-game menus + if (gamestate != GS_TITLESCREEN && gamestate != GS_TIMEATTACK) + return; + + M_SetMenuCurFadeValue(16); + M_SetMenuCurTitlePics(); + + // Loop through both menu IDs in parallel and look for type changes + // The youngest child in activeMenuId is the entered menu + // The youngest child in prevMenuId is the exited menu + + // 0. Get the type and level of each menu, and level of common ancestor + // 1. Get the wipes for both, then run the exit wipe + // 2. Change music (so that execs can change it again later) + // 3. Run each exit exec on the prevMenuId up to the common ancestor (UNLESS NoBubbleExecs) + // 4. Run each entrance exec on the activeMenuId down from the common ancestor (UNLESS NoBubbleExecs) + // 5. Run the entrance wipe + + // Get the parameters for each menu + for (i = NUMMENULEVELS; i >= 0; i--) + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + prevtype = (prevMenuId & bitmask) >> (MENUBITS*i); + activetype = (activeMenuId & bitmask) >> (MENUBITS*i); + + if (prevtype && (exittype < 0)) + { + exittype = prevtype; + exitlevel = i; + exitwipe = menupres[exittype].exitwipe; + exitbubble = menupres[exittype].exitbubble; + exittag = menupres[exittype].exittag; + } + + if (activetype && (entertype < 0)) + { + entertype = activetype; + enterlevel = i; + enterwipe = menupres[entertype].enterwipe; + enterbubble = menupres[entertype].enterbubble; + entertag = menupres[entertype].entertag; + } + + if (prevtype && activetype && prevtype == activetype && anceslevel < 0) + { + anceslevel = i; + break; + } + } + + // if no common ancestor (top menu), force a wipe. Look for a specified wipe first. + // Don't force a wipe if you're actually going to/from the main menu + if (anceslevel < 0 && exitwipe < 0 && newMenu != &MainDef && currentMenu != &MainDef) + { + for (i = NUMMENULEVELS; i >= 0; i--) + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + prevtype = (prevMenuId & bitmask) >> (MENUBITS*i); + + if (menupres[prevtype].exitwipe >= 0) + { + exitwipe = menupres[prevtype].exitwipe; + break; + } + } + + if (exitwipe < 0) + exitwipe = menupres[MN_MAIN].exitwipe; + } + + // do the same for enter wipe + if (anceslevel < 0 && enterwipe < 0 && newMenu != &MainDef && currentMenu != &MainDef) + { + for (i = NUMMENULEVELS; i >= 0; i--) + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + activetype = (activeMenuId & bitmask) >> (MENUBITS*i); + + if (menupres[activetype].enterwipe >= 0) + { + exitwipe = menupres[activetype].enterwipe; + break; + } + } + + if (enterwipe < 0) + enterwipe = menupres[MN_MAIN].enterwipe; + } + + // Change the music + M_ChangeMenuMusic("_title", false); + + // Run the linedef execs + if (titlemapinaction) + { + // Run the exit tags + if (enterlevel <= exitlevel) // equals is an edge case + { + if (exitbubble) + { + for (i = exitlevel; i > anceslevel; i--) // don't run the common ancestor's exit tag + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + menutype = (prevMenuId & bitmask) >> (MENUBITS*i); + if (menupres[menutype].exittag) + P_LinedefExecute(menupres[menutype].exittag, players[displayplayer].mo, NULL); + } + } + else if (exittag) + P_LinedefExecute(exittag, players[displayplayer].mo, NULL); + } + + // Run the enter tags + if (enterlevel >= exitlevel) // equals is an edge case + { + if (enterbubble) + { + for (i = anceslevel+1; i <= enterlevel; i++) // don't run the common ancestor's enter tag + { + bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); + menutype = (activeMenuId & bitmask) >> (MENUBITS*i); + if (menupres[menutype].entertag) + P_LinedefExecute(menupres[menutype].entertag, players[displayplayer].mo, NULL); + } + } + else if (entertag) + P_LinedefExecute(entertag, players[displayplayer].mo, NULL); + } + } + + + // Set the wipes for next frame + if ( + (exitwipe >= 0 && enterlevel <= exitlevel) || + (enterwipe >= 0 && enterlevel >= exitlevel) || + (anceslevel < 0 && newMenu != &MainDef && currentMenu != &MainDef) + ) + { + if (gamestate == GS_TIMEATTACK) + wipetypepre = ((exitwipe && enterlevel <= exitlevel) || anceslevel < 0) ? exitwipe : -1; // force default + else + // HACK: INT16_MAX signals to not wipe + // because 0 is a valid index and -1 means default + wipetypepre = ((exitwipe && enterlevel <= exitlevel) || anceslevel < 0) ? exitwipe : INT16_MAX; + wipetypepost = ((enterwipe && enterlevel >= exitlevel) || anceslevel < 0) ? enterwipe : INT16_MAX; + wipegamestate = FORCEWIPE; + + // If just one of the above is a force not-wipe, + // mirror the other wipe. + if (wipetypepre != INT16_MAX && wipetypepost == INT16_MAX) + wipetypepost = wipetypepre; + else if (wipetypepost != INT16_MAX && wipetypepre == INT16_MAX) + wipetypepre = wipetypepost; + + // D_Display runs the next step of processing + } +} + // ========================================================================= // BASIC MENU HANDLING // ========================================================================= +static void M_GoBack(INT32 choice) +{ + (void)choice; + + if (currentMenu->prevMenu) + { + //If we entered the game search menu, but didn't enter a game, + //make sure the game doesn't still think we're in a netgame. + if (!Playing() && netgame && multiplayer) + { + MSCloseUDPSocket(); // Clean up so we can re-open the connection later. + netgame = multiplayer = false; + } + + if ((currentMenu->prevMenu == &MainDef) && (currentMenu == &SP_TimeAttackDef || currentMenu == &SP_NightsAttackDef)) + { + // D_StartTitle does its own wipe, since GS_TIMEATTACK is now a complete gamestate. + + if (levelselect.rows) + { + Z_Free(levelselect.rows); + levelselect.rows = NULL; + } + + menuactive = false; + wipetypepre = menupres[M_GetYoungestChildMenu()].exitwipe; + I_UpdateMouseGrab(); + D_StartTitle(); + } + else + M_SetupNextMenu(currentMenu->prevMenu); + } + else + M_ClearMenus(true); +} + static void M_ChangeCvar(INT32 choice) { consvar_t *cv = (consvar_t *)currentMenu->menuitems[itemOn].itemaction; - if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD)) + if (choice == -1) { - CV_SetValue(cv,cv->value+(choice*2-1)); + if (cv == &cv_playercolor) + { + SINT8 skinno = R_SkinAvailable(cv_chooseskin.string); + if (skinno != -1) + CV_SetValue(cv,skins[skinno].prefcolor); + return; + } + CV_Set(cv,cv->defaultvalue); + return; } - else if (cv->flags & CV_FLOAT) + + choice = (choice<<1) - 1; + + if (cv->flags & CV_FLOAT) { - char s[20]; - sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice*2-1)*(1.0f/16.0f)); - CV_Set(cv,s); + if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD) + || !(currentMenu->menuitems[itemOn].status & IT_CV_INTEGERSTEP)) + { + char s[20]; + float n = FIXED_TO_FLOAT(cv->value)+(choice)*(1.0f/16.0f); + sprintf(s,"%ld%s",(long)n,M_Ftrim(n)); + CV_Set(cv,s); + } + else + CV_SetValue(cv,FIXED_TO_FLOAT(cv->value)+(choice)); } else - CV_AddValue(cv,choice*2-1); + CV_AddValue(cv,choice); } static boolean M_ChangeStringCvar(INT32 choice) { consvar_t *cv = (consvar_t *)currentMenu->menuitems[itemOn].itemaction; - char buf[255]; + char buf[MAXSTRINGLENGTH]; size_t len; + if (shiftdown && choice >= 32 && choice <= 127) + choice = shiftxform[choice]; + switch (choice) { case KEY_BACKSPACE: @@ -2119,36 +3107,56 @@ static boolean M_ChangeStringCvar(INT32 choice) return false; } +// resets all cvars on a menu - assumes that all that have itemactions are cvars +static void M_ResetCvars(void) +{ + INT32 i; + consvar_t *cv; + for (i = 0; i < currentMenu->numitems; i++) + { + if (!(currentMenu->menuitems[i].status & IT_CVAR) || !(cv = (consvar_t *)currentMenu->menuitems[i].itemaction)) + continue; + CV_SetValue(cv, atoi(cv->defaultvalue)); + } +} + static void M_NextOpt(void) { INT16 oldItemOn = itemOn; // prevent infinite loop - do { if (itemOn + 1 > currentMenu->numitems - 1) itemOn = 0; else itemOn++; - } while (oldItemOn != itemOn && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE); + } while (oldItemOn != itemOn && ( (currentMenu->menuitems[itemOn].status & IT_TYPE) & IT_SPACE )); } static void M_PrevOpt(void) { INT16 oldItemOn = itemOn; // prevent infinite loop - do { if (!itemOn) itemOn = currentMenu->numitems - 1; else itemOn--; - } while (oldItemOn != itemOn && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE); + } while (oldItemOn != itemOn && ( (currentMenu->menuitems[itemOn].status & IT_TYPE) & IT_SPACE )); } // lock out further input in a tic when important buttons are pressed // (in other words -- stop bullshit happening by mashing buttons in fades) static boolean noFurtherInput = false; +static void Command_Manual_f(void) +{ + if (modeattacking) + return; + M_StartControlPanel(); + currentMenu = &MISC_HelpDef; + itemOn = 0; +} + // // M_Responder // @@ -2163,8 +3171,14 @@ boolean M_Responder(event_t *ev) void (*routine)(INT32 choice); // for some casting problem if (dedicated || (demoplayback && titledemo) - || gamestate == GS_INTRO || gamestate == GS_CUTSCENE || gamestate == GS_GAMEEND - || gamestate == GS_CREDITS || gamestate == GS_EVALUATION) + || gamestate == GS_INTRO || gamestate == GS_ENDING || gamestate == GS_CUTSCENE + || gamestate == GS_CREDITS || gamestate == GS_EVALUATION || gamestate == GS_GAMEEND) + return false; + + if (gamestate == GS_TITLESCREEN && finalecount < TICRATE) + return false; + + if (CON_Ready()) return false; if (noFurtherInput) @@ -2177,6 +3191,7 @@ boolean M_Responder(event_t *ev) { if (ev->type == ev_keydown) { + keydown++; ch = ev->data1; // added 5-2-98 remap virtual keys (mouse & joystick buttons) @@ -2212,7 +3227,7 @@ boolean M_Responder(event_t *ev) } else if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime()) { - const INT32 jdeadzone = JOYAXISRANGE/4; + const INT32 jdeadzone = (JOYAXISRANGE * cv_digitaldeadzone.value) / FRACUNIT; if (ev->data3 != INT32_MAX) { if (Joystick.bGamepadStyle || abs(ev->data3) > jdeadzone) @@ -2283,6 +3298,8 @@ boolean M_Responder(event_t *ev) pmousex = lastx += 30; } } + else if (ev->type == ev_keyup) // Preserve event for other responders + keydown = 0; } else if (ev->type == ev_keydown) // Preserve event for other responders ch = ev->data1; @@ -2299,11 +3316,7 @@ boolean M_Responder(event_t *ev) switch (ch) { case KEY_F1: // Help key - if (modeattacking) - return true; - M_StartControlPanel(); - currentMenu = &MISC_HelpDef; - itemOn = 0; + Command_Manual_f(); return true; case KEY_F2: // Empty @@ -2318,11 +3331,11 @@ boolean M_Responder(event_t *ev) return true; M_StartControlPanel(); M_Options(0); - currentMenu = &OP_SoundOptionsDef; - itemOn = 0; + // Uncomment the below if you want the menu to reset to the top each time like before. M_SetupNextMenu will fix it automatically. + //OP_SoundOptionsDef.lastOn = 0; + M_SetupNextMenu(&OP_SoundOptionsDef); return true; -#ifndef DC case KEY_F5: // Video Mode if (modeattacking) return true; @@ -2330,7 +3343,6 @@ boolean M_Responder(event_t *ev) M_Options(0); M_VideoModeMenu(0); return true; -#endif case KEY_F6: // Empty return true; @@ -2351,17 +3363,14 @@ boolean M_Responder(event_t *ev) return true; case KEY_F11: // Gamma Level - CV_AddValue(&cv_usegamma, 1); + CV_AddValue(&cv_globalgamma, 1); return true; // Spymode on F12 handled in game logic case KEY_ESCAPE: // Pop up menu if (chat_on) - { HU_clearChatChars(); - chat_on = false; - } else M_StartControlPanel(); return true; @@ -2415,8 +3424,6 @@ boolean M_Responder(event_t *ev) { if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING) { - if (shiftdown && ch >= 32 && ch <= 127) - ch = shiftxform[ch]; if (M_ChangeStringCvar(ch)) return true; else @@ -2432,29 +3439,18 @@ boolean M_Responder(event_t *ev) case KEY_DOWNARROW: M_NextOpt(); S_StartSound(NULL, sfx_menu1); - if (currentMenu == &SP_PlayerDef) - { - Z_Free(char_notes); - char_notes = NULL; - } return true; case KEY_UPARROW: M_PrevOpt(); S_StartSound(NULL, sfx_menu1); - if (currentMenu == &SP_PlayerDef) - { - Z_Free(char_notes); - char_notes = NULL; - } return true; case KEY_LEFTARROW: if (routine && ((currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_ARROWS || (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_CVAR)) { - if (currentMenu != &OP_SoundOptionsDef) - S_StartSound(NULL, sfx_menu1); + S_StartSound(NULL, sfx_menu1); routine(0); } return true; @@ -2463,8 +3459,7 @@ boolean M_Responder(event_t *ev) if (routine && ((currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_ARROWS || (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_CVAR)) { - if (currentMenu != &OP_SoundOptionsDef) - S_StartSound(NULL, sfx_menu1); + S_StartSound(NULL, sfx_menu1); routine(1); } return true; @@ -2478,12 +3473,14 @@ boolean M_Responder(event_t *ev) || (currentMenu->menuitems[itemOn].status & IT_TYPE)==IT_SUBMENU) && (currentMenu->menuitems[itemOn].status & IT_CALLTYPE)) { +#ifndef DEVELOP if (((currentMenu->menuitems[itemOn].status & IT_CALLTYPE) & IT_CALL_NOTMODIFIED) && modifiedgame && !savemoddata) { - S_StartSound(NULL, sfx_menu1); + S_StartSound(NULL, sfx_skid); M_StartMessage(M_GetText("This cannot be done in a modified game.\n\n(Press a key)\n"), NULL, MM_NOTHING); return true; } +#endif } S_StartSound(NULL, sfx_menu1); switch (currentMenu->menuitems[itemOn].status & IT_TYPE) @@ -2506,28 +3503,8 @@ boolean M_Responder(event_t *ev) case KEY_ESCAPE: noFurtherInput = true; currentMenu->lastOn = itemOn; - if (currentMenu->prevMenu) - { - //If we entered the game search menu, but didn't enter a game, - //make sure the game doesn't still think we're in a netgame. - if (!Playing() && netgame && multiplayer) - { - MSCloseUDPSocket(); // Clean up so we can re-open the connection later. - netgame = false; - multiplayer = false; - } - if (currentMenu == &SP_TimeAttackDef || currentMenu == &SP_NightsAttackDef) - { - // D_StartTitle does its own wipe, since GS_TIMEATTACK is now a complete gamestate. - menuactive = false; - D_StartTitle(); - } - else - M_SetupNextMenu(currentMenu->prevMenu); - } - else - M_ClearMenus(true); + M_GoBack(0); return true; @@ -2536,8 +3513,26 @@ boolean M_Responder(event_t *ev) { // detach any keys associated with the game control G_ClearControlKeys(setupcontrols, currentMenu->menuitems[itemOn].alphaKey); + S_StartSound(NULL, sfx_shldls); return true; } + + if (routine && ((currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_ARROWS + || (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_CVAR)) + { + consvar_t *cv = (consvar_t *)currentMenu->menuitems[itemOn].itemaction; + + if (cv == &cv_chooseskin + || cv == &cv_nextmap + || cv == &cv_newgametype) + return true; + + if (currentMenu != &OP_SoundOptionsDef || itemOn > 3) + S_StartSound(NULL, sfx_menu1); + routine(-1); + return true; + } + // Why _does_ backspace go back anyway? //currentMenu->lastOn = itemOn; //if (currentMenu->prevMenu) @@ -2545,6 +3540,7 @@ boolean M_Responder(event_t *ev) return false; default: + CON_Responder(ev); break; } @@ -2558,14 +3554,16 @@ boolean M_Responder(event_t *ev) // void M_Drawer(void) { + boolean wipe = WipeInAction; + if (currentMenu == &MessageDef) menuactive = true; if (menuactive) { // now that's more readable with a faded background (yeah like Quake...) - if (!WipeInAction) - V_DrawFadeScreen(); + if (!wipe && (curfadevalue || (gamestate != GS_TITLESCREEN && gamestate != GS_TIMEATTACK))) + V_DrawFadeScreen(0xFF00, (gamestate != GS_TITLESCREEN && gamestate != GS_TIMEATTACK) ? 16 : curfadevalue); if (currentMenu->drawroutine) currentMenu->drawroutine(); // call current menu Draw routine @@ -2592,7 +3590,7 @@ void M_Drawer(void) } // focus lost notification goes on top of everything, even the former everything - if (window_notinfocus) + if (window_notinfocus && cv_showfocuslost.value) { M_DrawTextBox((BASEVIDWIDTH/2) - (60), (BASEVIDHEIGHT/2) - (16), 13, 2); if (gamestate == GS_LEVEL && (P_AutoPause() || paused)) @@ -2626,6 +3624,8 @@ void M_StartControlPanel(void) if (!Playing()) { // Secret menu! + MainMenu[singleplr].alphaKey = (M_AnySecretUnlocked()) ? 76 : 84; + MainMenu[multiplr].alphaKey = (M_AnySecretUnlocked()) ? 84 : 92; MainMenu[secrets].status = (M_AnySecretUnlocked()) ? (IT_STRING | IT_CALL) : (IT_DISABLED); currentMenu = &MainDef; @@ -2701,10 +3701,14 @@ void M_StartControlPanel(void) } if (splitscreen) + { MPauseMenu[mpause_psetupsplit].status = MPauseMenu[mpause_psetupsplit2].status = IT_STRING | IT_CALL; + MPauseMenu[mpause_psetup].text = "Player 1 Setup"; + } else { MPauseMenu[mpause_psetup].status = IT_STRING | IT_CALL; + MPauseMenu[mpause_psetup].text = "Player Setup"; if (G_GametypeHasTeams()) MPauseMenu[mpause_switchteam].status = IT_STRING | IT_SUBMENU; @@ -2723,6 +3727,7 @@ void M_StartControlPanel(void) void M_EndModeAttackRun(void) { + G_ClearModeAttackRetryFlag(); M_ModeAttackEndGame(0); } @@ -2737,13 +3742,15 @@ void M_ClearMenus(boolean callexitmenufunc) if (currentMenu->quitroutine && callexitmenufunc && !currentMenu->quitroutine()) return; // we can't quit this menu (also used to set parameter from the menu) -#ifndef DC // Save the config file. I'm sick of crashing the game later and losing all my changes! + // Save the config file. I'm sick of crashing the game later and losing all my changes! COM_BufAddText(va("saveconfig \"%s\" -silent\n", configfile)); -#endif //Alam: But not on the Dreamcast's VMUs if (currentMenu == &MessageDef) // Oh sod off! currentMenu = &MainDef; // Not like it matters menuactive = false; + hidetitlemap = false; + + I_UpdateMouseGrab(); } // @@ -2759,6 +3766,9 @@ void M_SetupNextMenu(menu_t *menudef) if (currentMenu != menudef && !currentMenu->quitroutine()) return; // we can't quit this menu (also used to set parameter from the menu) } + + M_HandleMenuPresState(menudef); + currentMenu = menudef; itemOn = currentMenu->lastOn; @@ -2768,17 +3778,25 @@ void M_SetupNextMenu(menu_t *menudef) // the curent item can be disabled, // this code go up until an enabled item found - if ((currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE) + if (( (currentMenu->menuitems[itemOn].status & IT_TYPE) & IT_SPACE )) { for (i = 0; i < currentMenu->numitems; i++) { - if ((currentMenu->menuitems[i].status & IT_TYPE) != IT_SPACE) + if (!( (currentMenu->menuitems[i].status & IT_TYPE) & IT_SPACE )) { itemOn = i; break; } } } + + hidetitlemap = false; +} + +// Guess I'll put this here, idk +boolean M_MouseNeeded(void) +{ + return (currentMenu == &MessageDef && currentMenu->prevMenu == &OP_ChangeControlsDef); } // @@ -2802,6 +3820,9 @@ void M_Ticker(void) if (--vidm_testingmode == 0) setmodeneeded = vidm_previousmode + 1; } + + if (currentMenu == &OP_ScreenshotOptionsDef) + M_SetupScreenshotMenu(); } // @@ -2809,6 +3830,10 @@ void M_Ticker(void) // void M_Init(void) { + int i; + + COM_AddCommand("manual", Command_Manual_f); + CV_RegisterVar(&cv_nextmap); CV_RegisterVar(&cv_newgametype); CV_RegisterVar(&cv_chooseskin); @@ -2850,18 +3875,40 @@ void M_Init(void) quitmsg[QUIT3MSG5] = M_GetText("You'll be back to play soon, though...\n......right?\n\n(Press 'Y' to quit)"); quitmsg[QUIT3MSG6] = M_GetText("Aww, is Egg Rock Zone too\ndifficult for you?\n\n(Press 'Y' to quit)"); -#ifdef HWRENDER - // Permanently hide some options based on render mode - if (rendermode == render_soft) - OP_VideoOptionsMenu[1].status = IT_DISABLED; -#endif + /* + Well the menu sucks for forcing us to have an item set + at all if every item just calls the same function, and + nothing more. Now just automate the definition. + */ + for (i = 0; i <= MAX_JOYSTICKS; ++i) + { + OP_JoystickSetMenu[i].status = ( IT_NOTHING|IT_CALL ); + OP_JoystickSetMenu[i].itemaction = M_AssignJoystick; + } #ifndef NONET CV_RegisterVar(&cv_serversort); #endif +} - //todo put this somewhere better... - CV_RegisterVar(&cv_allcaps); +void M_InitCharacterTables(void) +{ + UINT8 i; + + // Setup description table + for (i = 0; i < MAXSKINS; i++) + { + description[i].used = false; + strcpy(description[i].notes, "???"); + strcpy(description[i].picname, ""); + strcpy(description[i].nametag, ""); + strcpy(description[i].skinname, ""); + strcpy(description[i].displayname, ""); + description[i].prev = description[i].next = 0; + description[i].charpic = NULL; + description[i].namepic = NULL; + description[i].oppositecolor = description[i].tagtextcolor = description[i].tagoutlinecolor = 0; + } } // ========================================================================== @@ -2904,52 +3951,79 @@ static void M_DrawThermo(INT32 x, INT32 y, consvar_t *cv) centerlump[1] = W_GetNumForName("M_THERMM"); cursorlump = W_GetNumForName("M_THERMO"); - V_DrawScaledPatch(xx, y, 0, p = W_CachePatchNum(leftlump,PU_CACHE)); + V_DrawScaledPatch(xx, y, 0, p = W_CachePatchNum(leftlump,PU_PATCH)); xx += SHORT(p->width) - SHORT(p->leftoffset); for (i = 0; i < 16; i++) { - V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_CACHE)); + V_DrawScaledPatch(xx, y, V_WRAPX, W_CachePatchNum(centerlump[i & 1], PU_PATCH)); xx += 8; } - V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(rightlump, PU_CACHE)); + V_DrawScaledPatch(xx, y, 0, W_CachePatchNum(rightlump, PU_PATCH)); xx = (cv->value - cv->PossibleValue[0].value) * (15*8) / (cv->PossibleValue[1].value - cv->PossibleValue[0].value); - V_DrawScaledPatch((x + 8) + xx, y, 0, W_CachePatchNum(cursorlump, PU_CACHE)); + V_DrawScaledPatch((x + 8) + xx, y, 0, W_CachePatchNum(cursorlump, PU_PATCH)); } // A smaller 'Thermo', with range given as percents (0-100) -static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv) +static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) { INT32 i; INT32 range; patch_t *p; + x = BASEVIDWIDTH - x - SLIDER_WIDTH; + + V_DrawScaledPatch(x, y, 0, W_CachePatchName("M_SLIDEL", PU_PATCH)); + + p = W_CachePatchName("M_SLIDEM", PU_PATCH); + for (i = 1; i < SLIDER_RANGE; i++) + V_DrawScaledPatch (x+i*8, y, 0,p); + + if (ontop) + { + V_DrawCharacter(x - 6 - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(x+i*8 + 8 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + + p = W_CachePatchName("M_SLIDER", PU_PATCH); + V_DrawScaledPatch(x+i*8, y, 0, p); + + // draw the slider cursor + p = W_CachePatchName("M_SLIDEC", PU_PATCH); + for (i = 0; cv->PossibleValue[i+1].strvalue; i++); + if (cv->flags & CV_FLOAT) + range = (INT32)(atof(cv->defaultvalue)*FRACUNIT); + else + range = atoi(cv->defaultvalue); + + if (range != cv->value) + { + range = ((range - cv->PossibleValue[0].value) * 100 / + (cv->PossibleValue[i].value - cv->PossibleValue[0].value)); + + if (range < 0) + range = 0; + else if (range > 100) + range = 100; + + V_DrawMappedPatch(x + 2 + (SLIDER_RANGE*8*range)/100, y, V_TRANSLUCENT, p, yellowmap); + } + range = ((cv->value - cv->PossibleValue[0].value) * 100 / (cv->PossibleValue[i].value - cv->PossibleValue[0].value)); if (range < 0) range = 0; - if (range > 100) + else if (range > 100) range = 100; - x = BASEVIDWIDTH - x - SLIDER_WIDTH; - - V_DrawScaledPatch(x - 8, y, 0, W_CachePatchName("M_SLIDEL", PU_CACHE)); - - p = W_CachePatchName("M_SLIDEM", PU_CACHE); - for (i = 0; i < SLIDER_RANGE; i++) - V_DrawScaledPatch (x+i*8, y, 0,p); - - p = W_CachePatchName("M_SLIDER", PU_CACHE); - V_DrawScaledPatch(x+SLIDER_RANGE*8, y, 0, p); - - // draw the slider cursor - p = W_CachePatchName("M_SLIDEC", PU_CACHE); - V_DrawMappedPatch(x + ((SLIDER_RANGE-1)*8*range)/100, y, 0, p, yellowmap); + V_DrawMappedPatch(x + 2 + (SLIDER_RANGE*8*range)/100, y, 0, p, yellowmap); } // @@ -2959,7 +4033,7 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv) void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) { // Solid color textbox. - V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 239); + V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 159); //V_DrawFill(x+8, y+8, width*8, boxlines*8, 31); /* patch_t *p; @@ -2972,15 +4046,15 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) // draw left side cx = x; cy = y; - V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_TL], PU_CACHE)); + V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_TL], PU_PATCH)); cy += boff; - p = W_CachePatchNum(viewborderlump[BRDR_L], PU_CACHE); + p = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH); for (n = 0; n < boxlines; n++) { V_DrawScaledPatch(cx, cy, V_WRAPY, p); cy += step; } - V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BL], PU_CACHE)); + V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BL], PU_PATCH)); // draw middle V_DrawFlatFill(x + boff, y + boff, width*step, boxlines*step, st_borderpatchnum); @@ -2989,43 +4063,73 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines) cy = y; while (width > 0) { - V_DrawScaledPatch(cx, cy, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_T], PU_CACHE)); - V_DrawScaledPatch(cx, y + boff + boxlines*step, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_B], PU_CACHE)); + V_DrawScaledPatch(cx, cy, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH)); + V_DrawScaledPatch(cx, y + boff + boxlines*step, V_WRAPX, W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH)); width--; cx += step; } // draw right side cy = y; - V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_TR], PU_CACHE)); + V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_TR], PU_PATCH)); cy += boff; - p = W_CachePatchNum(viewborderlump[BRDR_R], PU_CACHE); + p = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH); for (n = 0; n < boxlines; n++) { V_DrawScaledPatch(cx, cy, V_WRAPY, p); cy += step; } - V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BR], PU_CACHE)); + V_DrawScaledPatch(cx, cy, 0, W_CachePatchNum(viewborderlump[BRDR_BR], PU_PATCH)); */ } +static fixed_t staticalong = 0; + +static void M_DrawStaticBox(fixed_t x, fixed_t y, INT32 flags, fixed_t w, fixed_t h) +{ + patch_t *patch; + fixed_t sw, pw; + + patch = W_CachePatchName("LSSTATIC", PU_PATCH); + pw = SHORT(patch->width) - (sw = w*2); //FixedDiv(w, scale); -- for scale FRACUNIT/2 + + /*if (pw > 0) -- model code for modders providing weird LSSTATIC + { + if (staticalong > pw) + staticalong -= pw; + } + else + staticalong = 0;*/ + + if (staticalong > pw) // simplified for base LSSTATIC + staticalong -= pw; + + V_DrawCroppedPatch(x<collected) - V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE), + V_DrawSmallMappedPatch(x, y, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); else - V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(x, y, 0, W_CachePatchName("NEEDIT", PU_PATCH)); emblem = M_GetLevelEmblems(-1); x -= 12; @@ -3078,7 +4184,7 @@ static void M_DrawMenuTitle(void) { if (currentMenu->menutitlepic) { - patch_t *p = W_CachePatchName(currentMenu->menutitlepic, PU_CACHE); + patch_t *p = W_CachePatchName(currentMenu->menutitlepic, PU_PATCH); if (p->height > 24) // title is larger than normal { @@ -3130,13 +4236,13 @@ static void M_DrawGenericMenu(void) if (currentMenu->menuitems[i].status & IT_CENTER) { patch_t *p; - p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); } else { V_DrawScaledPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); + W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH)); } } /* FALLTHRU */ @@ -3168,7 +4274,7 @@ static void M_DrawGenericMenu(void) switch (currentMenu->menuitems[i].status & IT_CVARTYPE) { case IT_CV_SLIDER: - M_DrawSlider(x, y, cv); + M_DrawSlider(x, y, cv, (i == itemOn)); case IT_CV_NOPRINT: // color use this case IT_CV_INVISSLIDER: // monitor toggles use this break; @@ -3181,8 +4287,15 @@ static void M_DrawGenericMenu(void) y += 16; break; default: - V_DrawString(BASEVIDWIDTH - x - V_StringWidth(cv->string, 0), y, + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? V_REDMAP : V_YELLOWMAP), cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(cv->string, 0) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } break; } break; @@ -3198,7 +4311,7 @@ static void M_DrawGenericMenu(void) case IT_GRAYPATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) V_DrawMappedPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch,PU_CACHE), graymap); + W_CachePatchName(currentMenu->menuitems[i].patch,PU_PATCH), graymap); y += LINEHEIGHT; break; case IT_TRANSTEXT: @@ -3220,7 +4333,8 @@ static void M_DrawGenericMenu(void) if (currentMenu->menuitems[i].alphaKey) y = currentMenu->y+currentMenu->menuitems[i].alphaKey; - V_DrawString(x-16, y, V_YELLOWMAP, currentMenu->menuitems[i].text); + //V_DrawString(x-16, y, V_YELLOWMAP, currentMenu->menuitems[i].text); + M_DrawLevelPlatterHeader(y - (lsheadingheight - 12), currentMenu->menuitems[i].text, true, false); y += SMALLLINEHEIGHT; break; } @@ -3231,16 +4345,261 @@ static void M_DrawGenericMenu(void) || ((currentMenu->menuitems[itemOn].status & IT_DISPLAY) == IT_NOTHING)) { V_DrawScaledPatch(currentMenu->x + SKULLXOFF, cursory - 5, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } else { V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawString(currentMenu->x, cursory, V_YELLOWMAP, currentMenu->menuitems[itemOn].text); } } +const char *PlaystyleNames[4] = {"Legacy", "Standard", "Simple", "Old Analog??"}; +const char *PlaystyleDesc[4] = { + // Legacy + "The play style used for\n" + "old-school SRB2.\n" + "\n" + "This play style is identical\n" + "to Standard, except that the\n" + "player always looks in the\n" + "direction of the camera." + , + + // Standard + "The default play style,\n" + "designed for full control\n" + "with a keyboard and mouse.\n" + "\n" + "The camera rotates only when\n" + "you tell it to. The player\n" + "looks in the direction they're\n" + "moving, but acts in the direction\n" + "the camera is facing.\n" + "\n" + "Mastery of this play style will\n" + "open up the highest level of play!" + , + + // Simple + "A play style designed for\n" + "gamepads and hassle-free play.\n" + "\n" + "The camera rotates automatically\n" + "as you move, and the player faces\n" + "and acts in the direction\n" + "they're moving.\n" + "\n" + "Hold \x82" "Center View\x80 to lock the\n" + "camera behind the player!\n" + , + + // Old Analog + "I see.\n" + "\n" + "You really liked the old analog mode,\n" + "so when 2.2 came out, you opened up\n" + "your config file and brought it back.\n" + "\n" + "That's absolutely valid, but I implore\n" + "you to try the new Simple play style\n" + "instead!" +}; + +static UINT8 playstyle_activeplayer = 0, playstyle_currentchoice = 0; + +static void M_DrawControlsDefMenu(void) +{ + UINT8 opt = 0; + + M_DrawGenericMenu(); + + if (currentMenu == &OP_P1ControlsDef) + { + opt = cv_directionchar[0].value ? 1 : 0; + opt = playstyle_currentchoice = cv_useranalog[0].value ? 3 - opt : opt; + + if (opt == 2) + { + OP_CameraOptionsDef.menuitems = OP_CameraExtendedOptionsMenu; + OP_CameraOptionsDef.numitems = sizeof (OP_CameraExtendedOptionsMenu) / sizeof (menuitem_t); + } + else + { + OP_CameraOptionsDef.menuitems = OP_CameraOptionsMenu; + OP_CameraOptionsDef.numitems = sizeof (OP_CameraOptionsMenu) / sizeof (menuitem_t); + } + } + else + { + opt = cv_directionchar[1].value ? 1 : 0; + opt = playstyle_currentchoice = cv_useranalog[1].value ? 3 - opt : opt; + + if (opt == 2) + { + OP_Camera2OptionsDef.menuitems = OP_Camera2ExtendedOptionsMenu; + OP_Camera2OptionsDef.numitems = sizeof (OP_Camera2ExtendedOptionsMenu) / sizeof (menuitem_t); + } + else + { + OP_Camera2OptionsDef.menuitems = OP_Camera2OptionsMenu; + OP_Camera2OptionsDef.numitems = sizeof (OP_Camera2OptionsMenu) / sizeof (menuitem_t); + } + } + + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + 80, V_YELLOWMAP, PlaystyleNames[opt]); +} + +#define scrollareaheight 72 + +// note that alphakey is multiplied by 2 for scrolling menus to allow greater usage in UINT8 range. +static void M_DrawGenericScrollMenu(void) +{ + INT32 x, y, i, max, bottom, tempcentery, cursory = 0; + + // DRAW MENU + x = currentMenu->x; + y = currentMenu->y; + + if (currentMenu->menuitems[currentMenu->numitems-1].alphaKey < scrollareaheight) + tempcentery = currentMenu->y; // Not tall enough to scroll, but this thinker is used in case it becomes so + else if ((currentMenu->menuitems[itemOn].alphaKey*2 - currentMenu->menuitems[0].alphaKey*2) <= scrollareaheight) + tempcentery = currentMenu->y - currentMenu->menuitems[0].alphaKey*2; + else if ((currentMenu->menuitems[currentMenu->numitems-1].alphaKey*2 - currentMenu->menuitems[itemOn].alphaKey*2) <= scrollareaheight) + tempcentery = currentMenu->y - currentMenu->menuitems[currentMenu->numitems-1].alphaKey*2 + 2*scrollareaheight; + else + tempcentery = currentMenu->y - currentMenu->menuitems[itemOn].alphaKey*2 + scrollareaheight; + + for (i = 0; i < currentMenu->numitems; i++) + { + if (currentMenu->menuitems[i].status != IT_DISABLED && currentMenu->menuitems[i].alphaKey*2 + tempcentery >= currentMenu->y) + break; + } + + for (bottom = currentMenu->numitems; bottom > 0; bottom--) + { + if (currentMenu->menuitems[bottom-1].status != IT_DISABLED) + break; + } + + for (max = bottom; max > 0; max--) + { + if (currentMenu->menuitems[max-1].status != IT_DISABLED && currentMenu->menuitems[max-1].alphaKey*2 + tempcentery <= (currentMenu->y + 2*scrollareaheight)) + break; + } + + if (i) + V_DrawString(currentMenu->x - 20, currentMenu->y - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); // up arrow + if (max != bottom) + V_DrawString(currentMenu->x - 20, currentMenu->y + 2*scrollareaheight + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); // down arrow + + // draw title (or big pic) + M_DrawMenuTitle(); + + for (; i < max; i++) + { + y = currentMenu->menuitems[i].alphaKey*2 + tempcentery; + if (i == itemOn) + cursory = y; + switch (currentMenu->menuitems[i].status & IT_DISPLAY) + { + case IT_PATCH: + case IT_DYBIGSPACE: + case IT_BIGSLIDER: + case IT_STRING2: + case IT_DYLITLSPACE: + case IT_GRAYPATCH: + case IT_TRANSTEXT2: + // unsupported + break; + case IT_NOTHING: + break; + case IT_STRING: + case IT_WHITESTRING: + if (i != itemOn && (currentMenu->menuitems[i].status & IT_DISPLAY)==IT_STRING) + V_DrawString(x, y, 0, currentMenu->menuitems[i].text); + else + V_DrawString(x, y, V_YELLOWMAP, currentMenu->menuitems[i].text); + + // Cvar specific handling + switch (currentMenu->menuitems[i].status & IT_TYPE) + case IT_CVAR: + { + consvar_t *cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + switch (currentMenu->menuitems[i].status & IT_CVARTYPE) + { + case IT_CV_SLIDER: + M_DrawSlider(x, y, cv, (i == itemOn)); + case IT_CV_NOPRINT: // color use this + case IT_CV_INVISSLIDER: // monitor toggles use this + break; + case IT_CV_STRING: +#if 1 + if (y + 12 > (currentMenu->y + 2*scrollareaheight)) + break; + M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1); + V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string); + if (skullAnimCounter < 4 && i == itemOn) + V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12, + '_' | 0x80, false); +#else // cool new string type stuff, not ready for limelight + if (i == itemOn) + { + V_DrawFill(x-2, y-1, MAXSTRINGLENGTH*8 + 4, 8+3, 159); + V_DrawString(x, y, V_ALLOWLOWERCASE, cv->string); + if (skullAnimCounter < 4) + V_DrawCharacter(x + V_StringWidth(cv->string, 0), y, '_' | 0x80, false); + } + else + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, + V_YELLOWMAP|V_ALLOWLOWERCASE, cv->string); +#endif + break; + default: + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, + ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? V_REDMAP : V_YELLOWMAP), cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(cv->string, 0) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + break; + } + break; + } + break; + case IT_TRANSTEXT: + switch (currentMenu->menuitems[i].status & IT_TYPE) + { + case IT_PAIR: + V_DrawString(x, y, + V_TRANSLUCENT, currentMenu->menuitems[i].patch); + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, + V_TRANSLUCENT, currentMenu->menuitems[i].text); + break; + default: + V_DrawString(x, y, + V_TRANSLUCENT, currentMenu->menuitems[i].text); + } + break; + case IT_QUESTIONMARKS: + V_DrawString(x, y, V_TRANSLUCENT|V_OLDSPACING, M_CreateSecretMenuOption(currentMenu->menuitems[i].text)); + break; + case IT_HEADERTEXT: + //V_DrawString(x-16, y, V_YELLOWMAP, currentMenu->menuitems[i].text); + M_DrawLevelPlatterHeader(y - (lsheadingheight - 12), currentMenu->menuitems[i].text, true, false); + break; + } + } + + // DRAW THE SKULL CURSOR + V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, + W_CachePatchName("M_CURSOR", PU_PATCH)); +} + static void M_DrawPauseMenu(void) { if (!netgame && !multiplayer && (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION)) @@ -3359,10 +4718,10 @@ static void M_DrawPauseMenu(void) continue; if (emblem->collected) - V_DrawSmallMappedPatch(40, 44 + (i*8), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE), + V_DrawSmallMappedPatch(40, 44 + (i*8), 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); else - V_DrawSmallScaledPatch(40, 44 + (i*8), 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(40, 44 + (i*8), 0, W_CachePatchName("NEEDIT", PU_PATCH)); switch (emblem->type) { @@ -3408,13 +4767,13 @@ static void M_DrawCenteredMenu(void) if (currentMenu->menuitems[i].status & IT_CENTER) { patch_t *p; - p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH); V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); } else { V_DrawScaledPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); + W_CachePatchName(currentMenu->menuitems[i].patch, PU_PATCH)); } } /* FALLTHRU */ @@ -3446,7 +4805,7 @@ static void M_DrawCenteredMenu(void) switch(currentMenu->menuitems[i].status & IT_CVARTYPE) { case IT_CV_SLIDER: - M_DrawSlider(x, y, cv); + M_DrawSlider(x, y, cv, (i == itemOn)); case IT_CV_NOPRINT: // color use this break; case IT_CV_STRING: @@ -3460,6 +4819,13 @@ static void M_DrawCenteredMenu(void) default: V_DrawString(BASEVIDWIDTH - x - V_StringWidth(cv->string, 0), y, ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? V_REDMAP : V_YELLOWMAP), cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(cv->string, 0) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } break; } break; @@ -3482,7 +4848,7 @@ static void M_DrawCenteredMenu(void) case IT_GRAYPATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) V_DrawMappedPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch,PU_CACHE), graymap); + W_CachePatchName(currentMenu->menuitems[i].patch,PU_PATCH), graymap); y += LINEHEIGHT; break; } @@ -3493,12 +4859,12 @@ static void M_DrawCenteredMenu(void) || ((currentMenu->menuitems[itemOn].status & IT_DISPLAY) == IT_NOTHING)) { V_DrawScaledPatch(x + SKULLXOFF, cursory - 5, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); } else { V_DrawScaledPatch(x - V_StringWidth(currentMenu->menuitems[itemOn].text, 0)/2 - 24, cursory, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawCenteredString(x, cursory, V_YELLOWMAP, currentMenu->menuitems[itemOn].text); } } @@ -3536,9 +4902,9 @@ static void M_PatchSkinNameTable(void) for (j = 0; j < MAXSKINS; j++) { - if (skins[j].name[0] != '\0') + if (skins[j].name[0] != '\0' && R_SkinUsable(-1, j)) { - skins_cons_t[j].strvalue = skins[j].name; + skins_cons_t[j].strvalue = skins[j].realname; skins_cons_t[j].value = j+1; } else @@ -3548,31 +4914,64 @@ static void M_PatchSkinNameTable(void) } } - CV_SetValue(&cv_chooseskin, cv_chooseskin.value); // This causes crash sometimes?! - CV_SetValue(&cv_chooseskin, 1); - CV_AddValue(&cv_chooseskin, -1); - CV_AddValue(&cv_chooseskin, 1); + Nextmap_OnChange(); return; } -// Call before showing any level-select menus -static void M_PrepareLevelSelect(void) +// +// M_LevelAvailableOnPlatter +// +// Okay, you know that the level SHOULD show up on the platter already. +// The only question is whether it should be as a question mark, +// (hinting as to its existence), or as its pure, unfettered self. +// +static boolean M_LevelAvailableOnPlatter(INT32 mapnum) { - if (levellistmode != LLM_CREATESERVER) - CV_SetValue(&cv_nextmap, M_GetFirstLevelInList()); - else - Newgametype_OnChange(); // Make sure to start on an appropriate map if wads have been added + if (M_MapLocked(mapnum+1)) + return false; // not unlocked + + switch (levellistmode) + { + case LLM_CREATESERVER: + if (!(mapheaderinfo[mapnum]->typeoflevel & TOL_COOP)) + return true; + + if (mapnum+1 == spstage_start) + return true; + +#ifndef DEVELOP + if (mapvisited[mapnum]) // MV_MP +#endif + return true; + + /* FALLTHRU */ + case LLM_RECORDATTACK: + case LLM_NIGHTSATTACK: +#ifndef DEVELOP + if (mapvisited[mapnum] & MV_MAX) + return true; + + if (mapheaderinfo[mapnum]->menuflags & LF2_NOVISITNEEDED) +#endif + return true; + + return false; + case LLM_LEVELSELECT: + default: + return true; + } + return true; } // -// M_CanShowLevelInList +// M_CanShowLevelOnPlatter // // Determines whether to show a given map in the various level-select lists. // Set gt = -1 to ignore gametype. // -boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) +static boolean M_CanShowLevelOnPlatter(INT32 mapnum, INT32 gt) { // Does the map exist? if (!mapheaderinfo[mapnum]) @@ -3582,6 +4981,9 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) if (!mapheaderinfo[mapnum]->lvlttl[0]) return false; + /*if (M_MapLocked(mapnum+1)) + return false; // not unlocked*/ + switch (levellistmode) { case LLM_CREATESERVER: @@ -3589,8 +4991,8 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) if (mapheaderinfo[mapnum]->menuflags & LF2_HIDEINMENU) return false; - if (M_MapLocked(mapnum+1)) - return false; // not unlocked + if (G_IsSpecialStage(mapnum+1)) + return false; if (gt == GT_COOP && (mapheaderinfo[mapnum]->typeoflevel & TOL_COOP)) return true; @@ -3610,43 +5012,25 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) if (gt == GT_RACE && (mapheaderinfo[mapnum]->typeoflevel & TOL_RACE)) return true; + if (gt >= 0 && gt < gametypecount && (mapheaderinfo[mapnum]->typeoflevel & gametypetol[gt])) + return true; + return false; case LLM_LEVELSELECT: - if (mapheaderinfo[mapnum]->levelselect != maplistoption) + if (!(mapheaderinfo[mapnum]->levelselect & maplistoption)) return false; - if (M_MapLocked(mapnum+1)) - return false; // not unlocked - return true; case LLM_RECORDATTACK: if (!(mapheaderinfo[mapnum]->menuflags & LF2_RECORDATTACK)) return false; - if (M_MapLocked(mapnum+1)) - return false; // not unlocked - - if (mapheaderinfo[mapnum]->menuflags & LF2_NOVISITNEEDED) - return true; - - if (!mapvisited[mapnum]) - return false; - return true; case LLM_NIGHTSATTACK: if (!(mapheaderinfo[mapnum]->menuflags & LF2_NIGHTSATTACK)) return false; - if (M_MapLocked(mapnum+1)) - return false; // not unlocked - - if (mapheaderinfo[mapnum]->menuflags & LF2_NOVISITNEEDED) - return true; - - if (!mapvisited[mapnum]) - return false; - return true; } @@ -3654,23 +5038,822 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) return false; } -static INT32 M_CountLevelsToShowInList(void) +#if 0 +static INT32 M_CountLevelsToShowOnPlatter(INT32 gt) { INT32 mapnum, count = 0; for (mapnum = 0; mapnum < NUMMAPS; mapnum++) - if (M_CanShowLevelInList(mapnum, -1)) + if (M_CanShowLevelOnPlatter(mapnum, gt)) count++; return count; } +#endif -static INT32 M_GetFirstLevelInList(void) +#if 0 +static boolean M_SetNextMapOnPlatter(void) +{ + INT32 row, col = 0; + while (col < 3) + { + row = 0; + while (row < levelselect.numrows) + { + if (levelselect.rows[row].maplist[col] == cv_nextmap.value) + { + lsrow = row; + lscol = col; + return true; + } + row++; + } + col++; + } + return true; +} +#endif + +static INT32 M_CountRowsToShowOnPlatter(INT32 gt) +{ + INT32 mapnum = 0, prevmapnum = 0, col = 0, rows = 0; + + while (mapnum < NUMMAPS) + { + if (M_CanShowLevelOnPlatter(mapnum, gt)) + { + if (rows == 0) + rows++; + else + { + if (col == 2 + || (mapheaderinfo[prevmapnum]->menuflags & LF2_WIDEICON) + || (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON) + || !(fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[prevmapnum]->selectheading))) + { + col = 0; + rows++; + } + else + col++; + } + prevmapnum = mapnum; + } + mapnum++; + } + + if (levellistmode == LLM_CREATESERVER) + rows++; + + return rows; +} + +// +// M_CacheLevelPlatter +// +// Cache every patch used by the level platter. +// +static void M_CacheLevelPlatter(void) +{ + levselp[0][0] = W_CachePatchName("SLCT1LVL", PU_PATCH); + levselp[0][1] = W_CachePatchName("SLCT2LVL", PU_PATCH); + levselp[0][2] = W_CachePatchName("BLANKLVL", PU_PATCH); + + levselp[1][0] = W_CachePatchName("SLCT1LVW", PU_PATCH); + levselp[1][1] = W_CachePatchName("SLCT2LVW", PU_PATCH); + levselp[1][2] = W_CachePatchName("BLANKLVW", PU_PATCH); +} + +// +// M_PrepareLevelPlatter +// +// Prepares a tasty dish of zones and acts! +// Call before any attempt to access a level platter. +// +static boolean M_PrepareLevelPlatter(INT32 gt, boolean nextmappick) +{ + INT32 numrows = M_CountRowsToShowOnPlatter(gt); + INT32 mapnum = 0, prevmapnum = 0, col = 0, row = 0, startrow = 0; + + if (!numrows) + return false; + + if (levelselect.rows) + Z_Free(levelselect.rows); + levelselect.rows = NULL; + + levelselect.numrows = numrows; + levelselect.rows = Z_Realloc(levelselect.rows, numrows*sizeof(levelselectrow_t), PU_STATIC, NULL); + if (!levelselect.rows) + I_Error("Insufficient memory to prepare level platter"); + + // done here so lsrow and lscol can be set if cv_nextmap is on the platter + lsrow = lscol = lshli = lsoffs[0] = lsoffs[1] = 0; + + if (levellistmode == LLM_CREATESERVER) + { + sprintf(levelselect.rows[0].header, "Gametype"); + lswide(0) = true; + levelselect.rows[row].mapavailable[2] = levelselect.rows[row].mapavailable[1] = levelselect.rows[row].mapavailable[0] = false; + startrow = row = 1; + + Z_Free(char_notes); + char_notes = NULL; + } + + while (mapnum < NUMMAPS) + { + if (M_CanShowLevelOnPlatter(mapnum, gt)) + { + const INT32 actnum = mapheaderinfo[mapnum]->actnum; + const boolean headingisname = (fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[mapnum]->lvlttl)); + const boolean wide = (mapheaderinfo[mapnum]->menuflags & LF2_WIDEICON); + + // preparing next position to drop mapnum into + if (levelselect.rows[startrow].maplist[0]) + { + if (col == 2 // no more space on the row? + || wide + || (mapheaderinfo[prevmapnum]->menuflags & LF2_WIDEICON) + || !(fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[prevmapnum]->selectheading))) // a new heading is starting? + { + col = 0; + row++; + } + else + col++; + } + + levelselect.rows[row].maplist[col] = mapnum+1; // putting the map on the platter + levelselect.rows[row].mapavailable[col] = M_LevelAvailableOnPlatter(mapnum); + + if ((lswide(row) = wide)) // intentionally assignment + { + levelselect.rows[row].maplist[2] = levelselect.rows[row].maplist[1] = levelselect.rows[row].maplist[0]; + levelselect.rows[row].mapavailable[2] = levelselect.rows[row].mapavailable[1] = levelselect.rows[row].mapavailable[0]; + } + + if (nextmappick && cv_nextmap.value == mapnum+1) // A little quality of life improvement. + { + lsrow = row; + lscol = col; + } + + // individual map name + if (levelselect.rows[row].mapavailable[col]) + { + if (headingisname) + { + if (actnum) + sprintf(levelselect.rows[row].mapnames[col], "ACT %d", actnum); + else + sprintf(levelselect.rows[row].mapnames[col], "THE ACT"); + } + else if (wide) + { + // Yes, with LF2_WIDEICON it'll continue on over into the next 17+1 char block. That's alright; col is always zero, the string is contiguous, and the maximum length is lvlttl[22] + ' ' + ZONE + ' ' + INT32, which is about 39 or so - barely crossing into the third column. + char* mapname = G_BuildMapTitle(mapnum+1); + strcpy(levelselect.rows[row].mapnames[col], (const char *)mapname); + Z_Free(mapname); + } + else + { + char mapname[22+1+11]; // lvlttl[22] + ' ' + INT32 + + if (actnum) + sprintf(mapname, "%s %d", mapheaderinfo[mapnum]->lvlttl, actnum); + else + strcpy(mapname, mapheaderinfo[mapnum]->lvlttl); + + if (strlen(mapname) >= 17) + strcpy(mapname+17-3, "..."); + + strcpy(levelselect.rows[row].mapnames[col], (const char *)mapname); + } + } + else + sprintf(levelselect.rows[row].mapnames[col], "???"); + + // creating header text + if (!col && ((row == startrow) || !(fastcmp(mapheaderinfo[mapnum]->selectheading, mapheaderinfo[levelselect.rows[row-1].maplist[0]-1]->selectheading)))) + { + if (!levelselect.rows[row].mapavailable[col]) + sprintf(levelselect.rows[row].header, "???"); + else + { + sprintf(levelselect.rows[row].header, "%s", mapheaderinfo[mapnum]->selectheading); + if (!(mapheaderinfo[mapnum]->levelflags & LF_NOZONE) && headingisname) + { + sprintf(levelselect.rows[row].header + strlen(levelselect.rows[row].header), " ZONE"); + } + } + } + + prevmapnum = mapnum; + } + + mapnum++; + } + +#ifdef SYMMETRICAL_PLATTER + // horizontally space out rows with missing right sides + for (; row >= 0; row--) + { + if (!levelselect.rows[row].maplist[2] // no right side + && levelselect.rows[row].maplist[0] && levelselect.rows[row].maplist[1]) // all the left filled in + { + levelselect.rows[row].maplist[2] = levelselect.rows[row].maplist[1]; + STRBUFCPY(levelselect.rows[row].mapnames[2], levelselect.rows[row].mapnames[1]); + levelselect.rows[row].mapavailable[2] = levelselect.rows[row].mapavailable[1]; + + levelselect.rows[row].maplist[1] = -1; // diamond + levelselect.rows[row].mapnames[1][0] = '\0'; + levelselect.rows[row].mapavailable[1] = false; + } + } +#endif + + M_CacheLevelPlatter(); + + return true; +} + +#define ifselectvalnextmapnobrace(column) if ((selectval = levelselect.rows[lsrow].maplist[column]) && levelselect.rows[lsrow].mapavailable[column])\ + {\ + CV_SetValue(&cv_nextmap, selectval); + +#define ifselectvalnextmap(column) ifselectvalnextmapnobrace(column)} + +// +// M_HandleLevelPlatter +// +// Reacts to your key inputs. Basically a mini menu thinker. +// +static void M_HandleLevelPlatter(INT32 choice) +{ + boolean exitmenu = false; // exit to previous menu + INT32 selectval; + UINT8 iter; + + switch (choice) + { + case KEY_DOWNARROW: + if (lsrow == levelselect.numrows-1) + { + if (levelselect.numrows < 3) + { + if (!lsoffs[0]) // prevent sound spam + { + lsoffs[0] = -8; + S_StartSound(NULL,sfx_s3kb7); + } + return; + } + lsrow = UINT8_MAX; + } + lsrow++; + + lsoffs[0] = lsvseperation(lsrow); + + if (levelselect.rows[lsrow].header[0]) + lshli = lsrow; + // no else needed - headerless lines associate upwards, so moving down to a row without a header is identity + + S_StartSound(NULL,sfx_s3kb7); + + ifselectvalnextmap(lscol) else ifselectvalnextmap(0) + break; + + case KEY_UPARROW: + iter = lsrow; + if (!lsrow) + { + if (levelselect.numrows < 3) + { + if (!lsoffs[0]) // prevent sound spam + { + lsoffs[0] = 8; + S_StartSound(NULL,sfx_s3kb7); + } + return; + } + lsrow = levelselect.numrows; + } + lsrow--; + + lsoffs[0] = -lsvseperation(iter); + + if (levelselect.rows[lsrow].header[0]) + lshli = lsrow; + else + { + iter = lsrow; + do + iter = ((iter == 0) ? levelselect.numrows-1 : iter-1); + while ((iter != lsrow) && !(levelselect.rows[iter].header[0])); + lshli = iter; + } + + S_StartSound(NULL,sfx_s3kb7); + + ifselectvalnextmap(lscol) else ifselectvalnextmap(0) + break; + + case KEY_ENTER: + if (!(levellistmode == LLM_CREATESERVER && !lsrow)) + { + ifselectvalnextmapnobrace(lscol) + lsoffs[0] = lsoffs[1] = 0; + S_StartSound(NULL,sfx_menu1); + if (gamestate == GS_TIMEATTACK) + M_SetupNextMenu(currentMenu->prevMenu); + else if (currentMenu == &MISC_ChangeLevelDef) + { + if (currentMenu->prevMenu && currentMenu->prevMenu != &MPauseDef) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ChangeLevel(0); + Z_Free(levelselect.rows); + levelselect.rows = NULL; + } + else + M_LevelSelectWarp(0); + Nextmap_OnChange(); + } + else if (!lsoffs[0]) // prevent sound spam + { + lsoffs[0] = -8; + S_StartSound(NULL,sfx_s3kb2); + } + break; + } + /* FALLTHRU */ + case KEY_RIGHTARROW: + if (levellistmode == LLM_CREATESERVER && !lsrow) + { + CV_AddValue(&cv_newgametype, 1); + S_StartSound(NULL,sfx_menu1); + lscol = 0; + + Z_Free(char_notes); + char_notes = NULL; + + if (!M_PrepareLevelPlatter(cv_newgametype.value, false)) + I_Error("Unidentified level platter failure!"); + } + else if (lscol < 2) + { + lscol++; + + lsoffs[1] = (lswide(lsrow) ? 8 : -lshseperation); + S_StartSound(NULL,sfx_s3kb7); + + ifselectvalnextmap(lscol) else ifselectvalnextmap(0) + } + else if (!lsoffs[1]) // prevent sound spam + { + lsoffs[1] = 8; + S_StartSound(NULL,sfx_s3kb7); + } + break; + + case KEY_LEFTARROW: + if (levellistmode == LLM_CREATESERVER && !lsrow) + { + CV_AddValue(&cv_newgametype, -1); + S_StartSound(NULL,sfx_menu1); + lscol = 0; + + Z_Free(char_notes); + char_notes = NULL; + + if (!M_PrepareLevelPlatter(cv_newgametype.value, false)) + I_Error("Unidentified level platter failure!"); + } + else if (lscol > 0) + { + lscol--; + + lsoffs[1] = (lswide(lsrow) ? -8 : lshseperation); + S_StartSound(NULL,sfx_s3kb7); + + ifselectvalnextmap(lscol) else ifselectvalnextmap(0) + } + else if (!lsoffs[1]) // prevent sound spam + { + lsoffs[1] = -8; + S_StartSound(NULL,sfx_s3kb7); + } + break; + + case KEY_ESCAPE: + exitmenu = true; + break; + + default: + break; + } + + if (exitmenu) + { + if (gamestate != GS_TIMEATTACK) + { + Z_Free(levelselect.rows); + levelselect.rows = NULL; + } + + if (currentMenu->prevMenu) + { + M_SetupNextMenu(currentMenu->prevMenu); + Nextmap_OnChange(); + } + else + M_ClearMenus(true); + + Z_Free(char_notes); + char_notes = NULL; + } +} + +void M_DrawLevelPlatterHeader(INT32 y, const char *header, boolean headerhighlight, boolean allowlowercase) +{ + y += lsheadingheight - 12; + V_DrawString(19, y, (headerhighlight ? V_YELLOWMAP : 0)|(allowlowercase ? V_ALLOWLOWERCASE : 0), header); + y += 9; + V_DrawFill(19, y, 281, 1, (headerhighlight ? yellowmap[3] : 3)); + V_DrawFill(300, y, 1, 1, 26); + y++; + V_DrawFill(19, y, 282, 1, 26); +} + +static void M_DrawLevelPlatterWideMap(UINT8 row, UINT8 col, INT32 x, INT32 y, boolean highlight) +{ + patch_t *patch; + + INT32 map = levelselect.rows[row].maplist[col]; + if (map <= 0) + return; + + if (needpatchrecache) + M_CacheLevelPlatter(); + + // A 564x100 image of the level as entry MAPxxW + if (!(levelselect.rows[row].mapavailable[col])) + { + V_DrawSmallScaledPatch(x, y, 0, levselp[1][2]); + M_DrawStaticBox(x, y, V_80TRANS, 282, 50); + } + else + { + if (W_CheckNumForName(va("%sW", G_BuildMapName(map))) != LUMPERROR) + patch = W_CachePatchName(va("%sW", G_BuildMapName(map)), PU_PATCH); + else + patch = levselp[1][2]; // don't static to indicate that it's just a normal level + + V_DrawSmallScaledPatch(x, y, 0, patch); + } + + V_DrawFill(x, y+50, 282, 8, + ((mapheaderinfo[map-1]->unlockrequired < 0) + ? 159 : 63)); + + V_DrawString(x, y+50, (highlight ? V_YELLOWMAP : 0), levelselect.rows[row].mapnames[col]); +} + +static void M_DrawLevelPlatterMap(UINT8 row, UINT8 col, INT32 x, INT32 y, boolean highlight) +{ + patch_t *patch; + + INT32 map = levelselect.rows[row].maplist[col]; + if (map <= 0) + return; + + if (needpatchrecache) + M_CacheLevelPlatter(); + + // A 160x100 image of the level as entry MAPxxP + if (!(levelselect.rows[row].mapavailable[col])) + { + V_DrawSmallScaledPatch(x, y, 0, levselp[0][2]); + M_DrawStaticBox(x, y, V_80TRANS, 80, 50); + } + else + { + if (W_CheckNumForName(va("%sP", G_BuildMapName(map))) != LUMPERROR) + patch = W_CachePatchName(va("%sP", G_BuildMapName(map)), PU_PATCH); + else + patch = levselp[0][2]; // don't static to indicate that it's just a normal level + + V_DrawSmallScaledPatch(x, y, 0, patch); + } + + V_DrawFill(x, y+50, 80, 8, + ((mapheaderinfo[map-1]->unlockrequired < 0) + ? 159 : 63)); + + if (strlen(levelselect.rows[row].mapnames[col]) > 6) // "AERIAL GARDEN" vs "ACT 18" - "THE ACT" intentionally compressed + V_DrawThinString(x, y+50, (highlight ? V_YELLOWMAP : 0), levelselect.rows[row].mapnames[col]); + else + V_DrawString(x, y+50, (highlight ? V_YELLOWMAP : 0), levelselect.rows[row].mapnames[col]); +} + +static void M_DrawLevelPlatterRow(UINT8 row, INT32 y) +{ + UINT8 col; + const boolean rowhighlight = (row == lsrow); + if (levelselect.rows[row].header[0]) + { + M_DrawLevelPlatterHeader(y, levelselect.rows[row].header, (rowhighlight || (row == lshli)), false); + y += lsheadingheight; + } + + if (levellistmode == LLM_CREATESERVER && !row) + { + if (!char_notes) + char_notes = V_WordWrap(0, 282 - 8, V_ALLOWLOWERCASE, gametypedesc[cv_newgametype.value].notes); + + V_DrawFill(lsbasex, y, 282, 50, 27); + V_DrawString(lsbasex + 4, y + 4, V_RETURN8|V_ALLOWLOWERCASE, char_notes); + + V_DrawFill(lsbasex, y+50, 141, 8, gametypedesc[cv_newgametype.value].col[0]); + V_DrawFill(lsbasex+141, y+50, 141, 8, gametypedesc[cv_newgametype.value].col[1]); + + V_DrawString(lsbasex, y+50, 0, gametype_cons_t[cv_newgametype.value].strvalue); + + if (!lsrow) + { + V_DrawCharacter(lsbasex - 10 - (skullAnimCounter/5), y+25, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(lsbasex+282 + 2 + (skullAnimCounter/5), y+25, + '\x1D' | V_YELLOWMAP, false); + } + } + else if (lswide(row)) + M_DrawLevelPlatterWideMap(row, 0, lsbasex, y, rowhighlight); + else + { + for (col = 0; col < 3; col++) + M_DrawLevelPlatterMap(row, col, lsbasex+(col*lshseperation), y, (rowhighlight && (col == lscol))); + } +} + +// new menus +static void M_DrawRecordAttackForeground(void) +{ + patch_t *fg = W_CachePatchName("RECATKFG", PU_PATCH); + patch_t *clock = W_CachePatchName("RECCLOCK", PU_PATCH); + angle_t fa; + + INT32 i; + INT32 height = (SHORT(fg->height)/2); + INT32 dupz = (vid.dupx < vid.dupy ? vid.dupx : vid.dupy); + + for (i = -12; i < (BASEVIDHEIGHT/height) + 12; i++) + { + INT32 y = ((i*height) - (height - ((recatkdrawtimer*2)%height))); + // don't draw above the screen + { + INT32 sy = FixedMul(y, dupz<> FRACBITS; + if (vid.height != BASEVIDHEIGHT * dupz) + sy += (vid.height - (BASEVIDHEIGHT * dupz)) / 2; + if ((sy+height) < 0) + continue; + } + V_DrawFixedPatch(0, y< vid.height) + break; + } + + // draw clock + fa = (FixedAngle(((recatkdrawtimer * 4) % 360)<>ANGLETOFINESHIFT) & FINEMASK; + V_DrawSciencePatch(160<width); + INT32 x = FixedInt(-bgscrollx) % w; + INT32 y = BASEVIDHEIGHT - SHORT(background->height)*2; + + if (vid.height != BASEVIDHEIGHT * dupz) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 158); + V_DrawFill(0, y+50, vid.width, BASEVIDHEIGHT, V_SNAPTOLEFT|31); + + V_DrawScaledPatch(x, y, V_SNAPTOLEFT, background); + x += w; + if (x < BASEVIDWIDTH) + V_DrawScaledPatch(x, y, V_SNAPTOLEFT, background); + + bgscrollx += (FRACUNIT/2); + if (bgscrollx > w<width); + //INT32 backtopheight = SHORT(backtopfg->height); + INT32 fronttopwidth = SHORT(fronttopfg->width); + //INT32 fronttopheight = SHORT(fronttopfg->height); + + // bottom + patch_t *backbottomfg = W_CachePatchName("NTSATKB1", PU_PATCH); + patch_t *frontbottomfg = W_CachePatchName("NTSATKB2", PU_PATCH); + INT32 backbottomwidth = SHORT(backbottomfg->width); + INT32 backbottomheight = SHORT(backbottomfg->height); + INT32 frontbottomwidth = SHORT(frontbottomfg->width); + INT32 frontbottomheight = SHORT(frontbottomfg->height); + + // background + M_DrawNightsAttackMountains(); + + // back top foreground patch + x = 0-(ntsatkdrawtimer%backtopwidth); + V_DrawScaledPatch(x, y, V_SNAPTOTOP|V_SNAPTOLEFT, backtopfg); + for (i = 0; i < 3; i++) + { + x += (backtopwidth); + if (x >= vid.width) + break; + V_DrawScaledPatch(x, y, V_SNAPTOTOP|V_SNAPTOLEFT, backtopfg); + } + + // front top foreground patch + x = 0-((ntsatkdrawtimer*2)%fronttopwidth); + V_DrawScaledPatch(x, y, V_SNAPTOTOP|V_SNAPTOLEFT, fronttopfg); + for (i = 0; i < 3; i++) + { + x += (fronttopwidth); + if (x >= vid.width) + break; + V_DrawScaledPatch(x, y, V_SNAPTOTOP|V_SNAPTOLEFT, fronttopfg); + } + + // back bottom foreground patch + x = 0-(ntsatkdrawtimer%backbottomwidth); + y = BASEVIDHEIGHT - backbottomheight; + V_DrawScaledPatch(x, y, V_SNAPTOBOTTOM|V_SNAPTOLEFT, backbottomfg); + for (i = 0; i < 3; i++) + { + x += (backbottomwidth); + if (x >= vid.width) + break; + V_DrawScaledPatch(x, y, V_SNAPTOBOTTOM|V_SNAPTOLEFT, backbottomfg); + } + + // front bottom foreground patch + x = 0-((ntsatkdrawtimer*2)%frontbottomwidth); + y = BASEVIDHEIGHT - frontbottomheight; + V_DrawScaledPatch(x, y, V_SNAPTOBOTTOM|V_SNAPTOLEFT, frontbottomfg); + for (i = 0; i < 3; i++) + { + x += (frontbottomwidth); + if (x >= vid.width) + break; + V_DrawScaledPatch(x, y, V_SNAPTOBOTTOM|V_SNAPTOLEFT, frontbottomfg); + } + + // Increment timer. + ntsatkdrawtimer++; +} + +// NiGHTS Attack floating Super Sonic. +static patch_t *ntssupersonic[2]; +static void M_DrawNightsAttackSuperSonic(void) +{ + const UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_YELLOW, GTC_CACHE); + INT32 timer = (ntsatkdrawtimer/4) % 2; + angle_t fa = (FixedAngle(((ntsatkdrawtimer * 4) % 360)<>ANGLETOFINESHIFT) & FINEMASK; + ntssupersonic[0] = W_CachePatchName("NTSSONC1", PU_PATCH); + ntssupersonic[1] = W_CachePatchName("NTSSONC2", PU_PATCH); + V_DrawFixedPatch(235<prevMenu == &SP_TimeAttackDef) + { + M_SetMenuCurBackground("RECATKBG"); + + curbgxspeed = 0; + curbgyspeed = 18; + + if (curbgcolor >= 0) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor); + else if (!curbghide || !titlemapinaction) + { + F_SkyScroll(curbgxspeed, curbgyspeed, curbgname); + // Draw and animate foreground + if (!strncmp("RECATKBG", curbgname, 8)) + M_DrawRecordAttackForeground(); + } + + if (curfadevalue) + V_DrawFadeScreen(0xFF00, curfadevalue); + } + + if (currentMenu->prevMenu == &SP_NightsAttackDef) + { + M_SetMenuCurBackground("NTSATKBG"); + + if (curbgcolor >= 0) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor); + else if (!curbghide || !titlemapinaction) + { + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 158); + M_DrawNightsAttackMountains(); + } + if (curfadevalue) + V_DrawFadeScreen(0xFF00, curfadevalue); + } + + // finds row at top of the screen + while (y > -8) + { + if (iter == 0) + { + if (levelselect.numrows < 3) + break; + iter = levelselect.numrows; + } + iter--; + y -= lsvseperation(iter); + } + + // draw from top to bottom + while (y < (vid.height/vid.dupy)) + { + M_DrawLevelPlatterRow(iter, y); + y += lsvseperation(iter); + if (iter == levelselect.numrows-1) + { + if (levelselect.numrows < 3) + break; + iter = UINT8_MAX; + } + iter++; + } + + // draw cursor box + if (levellistmode != LLM_CREATESERVER || lsrow) + V_DrawSmallScaledPatch(lsbasex + cursorx + lsoffs[1], lsbasey+lsoffs[0], 0, (levselp[sizeselect][((skullAnimCounter/4) ? 1 : 0)])); + +#if 0 + if (levelselect.rows[lsrow].maplist[lscol] > 0) + V_DrawScaledPatch(lsbasex + cursorx-17, lsbasey+50+lsoffs[0], 0, W_CachePatchName("M_CURSOR", PU_PATCH)); +#endif + + // handle movement of cursor box + if (lsoffs[0] > 1 || lsoffs[0] < -1) + lsoffs[0] = 2*lsoffs[0]/3; + else + lsoffs[0] = 0; + + if (lsoffs[1] > 1 || lsoffs[1] < -1) + lsoffs[1] = 2*lsoffs[1]/3; + else + lsoffs[1] = 0; + + M_DrawMenuTitle(); +} + +// +// M_CanShowLevelInList +// +// Determines whether to show a given map in level-select lists where you don't want to see locked levels. +// Set gt = -1 to ignore gametype. +// +boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt) +{ + return (M_CanShowLevelOnPlatter(mapnum, gt) && M_LevelAvailableOnPlatter(mapnum)); +} + +static INT32 M_GetFirstLevelInList(INT32 gt) { INT32 mapnum; for (mapnum = 0; mapnum < NUMMAPS; mapnum++) - if (M_CanShowLevelInList(mapnum, -1)) + if (M_CanShowLevelInList(mapnum, gt)) return mapnum + 1; return 1; @@ -3690,6 +5873,7 @@ static menuitem_t MessageMenu[] = menu_t MessageDef = { + MN_SPECIAL, NULL, // title 1, // # of menu items NULL, // previous menu (TO HACK) @@ -3815,7 +5999,26 @@ static void M_DrawMessageMenu(void) // hack: draw RA background in RA menus if (gamestate == GS_TIMEATTACK) - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + { + if (curbgcolor >= 0) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor); + else if (!curbghide || !titlemapinaction) + { + if (levellistmode == LLM_NIGHTSATTACK) + { + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 158); + M_DrawNightsAttackMountains(); + } + else + { + F_SkyScroll(curbgxspeed, curbgyspeed, curbgname); + if (!strncmp("RECATKBG", curbgname, 8)) + M_DrawRecordAttackForeground(); + } + } + if (curfadevalue) + V_DrawFadeScreen(0xFF00, curfadevalue); + } M_DrawTextBox(currentMenu->x, y - 8, (max+7)>>3, mlines); @@ -3887,7 +6090,7 @@ static void M_DrawImageDef(void) V_DrawScaledPic(0,0,0,W_GetNumForName(currentMenu->menuitems[itemOn].text)); else { - patch_t *patch = W_CachePatchName(currentMenu->menuitems[itemOn].text,PU_CACHE); + patch_t *patch = W_CachePatchName(currentMenu->menuitems[itemOn].text,PU_PATCH); if (patch->width <= BASEVIDWIDTH) V_DrawScaledPatch(0,0,0,patch); else @@ -3946,6 +6149,27 @@ static void M_AddonsOptions(INT32 choice) #define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make add-ons!" //#define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make add-ons!" +static void M_LoadAddonsPatches(void) +{ + addonsp[EXT_FOLDER] = W_CachePatchName("M_FFLDR", PU_PATCH); + addonsp[EXT_UP] = W_CachePatchName("M_FBACK", PU_PATCH); + addonsp[EXT_NORESULTS] = W_CachePatchName("M_FNOPE", PU_PATCH); + addonsp[EXT_TXT] = W_CachePatchName("M_FTXT", PU_PATCH); + addonsp[EXT_CFG] = W_CachePatchName("M_FCFG", PU_PATCH); + addonsp[EXT_WAD] = W_CachePatchName("M_FWAD", PU_PATCH); +#ifdef USE_KART + addonsp[EXT_KART] = W_CachePatchName("M_FKART", PU_PATCH); +#endif + addonsp[EXT_PK3] = W_CachePatchName("M_FPK3", PU_PATCH); + addonsp[EXT_SOC] = W_CachePatchName("M_FSOC", PU_PATCH); + addonsp[EXT_LUA] = W_CachePatchName("M_FLUA", PU_PATCH); + addonsp[NUM_EXT] = W_CachePatchName("M_FUNKN", PU_PATCH); + addonsp[NUM_EXT+1] = W_CachePatchName("M_FSEL", PU_PATCH); + addonsp[NUM_EXT+2] = W_CachePatchName("M_FLOAD", PU_PATCH); + addonsp[NUM_EXT+3] = W_CachePatchName("M_FSRCH", PU_PATCH); + addonsp[NUM_EXT+4] = W_CachePatchName("M_FSAVE", PU_PATCH); +} + static void M_Addons(INT32 choice) { const char *pathname = "."; @@ -3989,30 +6213,7 @@ static void M_Addons(INT32 choice) else dir_on[menudepthleft] = 0; - if (addonsp[0]) // never going to have some provided but not all, saves individually checking - { - size_t i; - for (i = 0; i < NUM_EXT+5; i++) - W_UnlockCachedPatch(addonsp[i]); - } - - addonsp[EXT_FOLDER] = W_CachePatchName("M_FFLDR", PU_STATIC); - addonsp[EXT_UP] = W_CachePatchName("M_FBACK", PU_STATIC); - addonsp[EXT_NORESULTS] = W_CachePatchName("M_FNOPE", PU_STATIC); - addonsp[EXT_TXT] = W_CachePatchName("M_FTXT", PU_STATIC); - addonsp[EXT_CFG] = W_CachePatchName("M_FCFG", PU_STATIC); - addonsp[EXT_WAD] = W_CachePatchName("M_FWAD", PU_STATIC); -#ifdef USE_KART - addonsp[EXT_KART] = W_CachePatchName("M_FKART", PU_STATIC); -#endif - addonsp[EXT_PK3] = W_CachePatchName("M_FPK3", PU_STATIC); - addonsp[EXT_SOC] = W_CachePatchName("M_FSOC", PU_STATIC); - addonsp[EXT_LUA] = W_CachePatchName("M_FLUA", PU_STATIC); - addonsp[NUM_EXT] = W_CachePatchName("M_FUNKN", PU_STATIC); - addonsp[NUM_EXT+1] = W_CachePatchName("M_FSEL", PU_STATIC); - addonsp[NUM_EXT+2] = W_CachePatchName("M_FLOAD", PU_STATIC); - addonsp[NUM_EXT+3] = W_CachePatchName("M_FSRCH", PU_STATIC); - addonsp[NUM_EXT+4] = W_CachePatchName("M_FSAVE", PU_STATIC); + M_LoadAddonsPatches(); MISC_AddonsDef.prevMenu = currentMenu; M_SetupNextMenu(&MISC_AddonsDef); @@ -4037,21 +6238,21 @@ static void M_DrawTemperature(INT32 x, fixed_t t) t = (FixedMul(h<>FRACBITS); // border - V_DrawFill(x - 1, vpadding, 1, h, 120); - V_DrawFill(x + width, vpadding, 1, h, 120); - V_DrawFill(x - 1, vpadding-1, width+2, 1, 120); - V_DrawFill(x - 1, vpadding+h, width+2, 1, 120); + V_DrawFill(x - 1, vpadding, 1, h, 3); + V_DrawFill(x + width, vpadding, 1, h, 3); + V_DrawFill(x - 1, vpadding-1, width+2, 1, 3); + V_DrawFill(x - 1, vpadding+h, width+2, 1, 3); // bar itself y = h; if (t) for (t = h - t; y > 0; y--) { - UINT8 colours[NUMCOLOURS] = {135, 133, 92, 77, 114, 178, 161, 162}; + UINT8 colours[NUMCOLOURS] = {42, 40, 58, 222, 65, 90, 97, 98}; UINT8 c; if (y <= t) break; if (y+vpadding >= BASEVIDHEIGHT/2) - c = 185; + c = 113; else c = colours[(NUMCOLOURS*(y-1))/(h/2)]; V_DrawFill(x, y-1 + vpadding, width, 1, c); @@ -4059,7 +6260,7 @@ static void M_DrawTemperature(INT32 x, fixed_t t) // fill the rest of the backing if (y) - V_DrawFill(x, vpadding, width, y, 30); + V_DrawFill(x, vpadding, width, y, 27); } #undef width #undef vpadding @@ -4114,7 +6315,7 @@ static boolean M_AddonsRefresh(void) { S_StartSound(NULL, sfx_lose); if (refreshdirmenu & REFRESHDIR_MAX) - message = va("%c%s\x80\nMaximum number of add-ons reached.\nA file could not be loaded.\nIf you want to play with this add-on, restart the game to clear existing ones.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nMaximum number of add-ons reached.\nA file could not be loaded.\nIf you wish to play with this add-on, restart the game to clear existing ones.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); else message = va("%c%s\x80\nA file was not loaded.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); } @@ -4140,7 +6341,8 @@ static boolean M_AddonsRefresh(void) static void M_DrawAddons(void) { INT32 x, y; - ssize_t i, m; + size_t i, m; + size_t t, b; // top and bottom item #s to draw in directory const UINT8 *flashcol = NULL; UINT8 hilicol; @@ -4151,6 +6353,10 @@ static void M_DrawAddons(void) return; } + // Lactozilla: Load addons menu patches. + if (needpatchrecache) + M_LoadAddonsPatches(); + if (Playing()) V_DrawCenteredString(BASEVIDWIDTH/2, 5, warningflags, "Adding files mid-game may cause problems."); else @@ -4177,53 +6383,65 @@ static void M_DrawAddons(void) x = currentMenu->x; y = currentMenu->y + 1; - hilicol = V_GetStringColormap(highlightflags)[120]; + hilicol = 0; // white +#define boxwidth (MAXSTRINGLENGTH*8+6) + + // draw the file path and the top white + black lines of the box V_DrawString(x-21, (y - 16) + (lsheadingheight - 12), highlightflags|V_ALLOWLOWERCASE, M_AddonsHeaderPath()); - V_DrawFill(x-21, (y - 16) + (lsheadingheight - 3), MAXSTRINGLENGTH*8+6, 1, hilicol); - V_DrawFill(x-21, (y - 16) + (lsheadingheight - 2), MAXSTRINGLENGTH*8+6, 1, 30); + V_DrawFill(x-21, (y - 16) + (lsheadingheight - 3), boxwidth, 1, hilicol); + V_DrawFill(x-21, (y - 16) + (lsheadingheight - 2), boxwidth, 1, 30); m = (BASEVIDHEIGHT - currentMenu->y + 2) - (y - 1); - V_DrawFill(x - 21, y - 1, MAXSTRINGLENGTH*8+6, m, 239); + // addons menu back color + V_DrawFill(x-21, y - 1, boxwidth, m, 159); - // scrollbar! - if (sizedirmenu <= (2*numaddonsshown + 1)) - i = 0; + // The directory is too small for a scrollbar, so just draw a tall white line + if (sizedirmenu <= addonmenusize) + { + t = 0; // first item + b = sizedirmenu - 1; // last item + i = 0; // "scrollbar" at "top" position + } else { - ssize_t q = m; - m = ((2*numaddonsshown + 1) * m)/sizedirmenu; + size_t q = m; + m = (addonmenusize * m)/sizedirmenu; // height of scroll bar if (dir_on[menudepthleft] <= numaddonsshown) // all the way up - i = 0; - else if (sizedirmenu <= (dir_on[menudepthleft] + numaddonsshown + 1)) // all the way down - i = q-m; - else - i = ((dir_on[menudepthleft] - numaddonsshown) * (q-m))/(sizedirmenu - (2*numaddonsshown + 1)); + { + t = 0; // first item + b = addonmenusize - 1; //9th item + i = 0; // scrollbar at top position + } + else if (dir_on[menudepthleft] >= sizedirmenu - (numaddonsshown + 1)) // all the way down + { + t = sizedirmenu - addonmenusize; // # 9th last + b = sizedirmenu - 1; // last item + i = q-m; // scrollbar at bottom position + } + else // somewhere in the middle + { + t = dir_on[menudepthleft] - numaddonsshown; // 4 items above + b = dir_on[menudepthleft] + numaddonsshown; // 4 items below + i = (t * (q-m))/(sizedirmenu - addonmenusize); // calculate position of scrollbar + } } - V_DrawFill(x + MAXSTRINGLENGTH*8+5 - 21, (y - 1) + i, 1, m, hilicol); + // draw the scrollbar! + V_DrawFill((x-21) + boxwidth-1, (y - 1) + i, 1, m, hilicol); - // get bottom... - m = dir_on[menudepthleft] + numaddonsshown + 1; - if (m > (ssize_t)sizedirmenu) - m = sizedirmenu; +#undef boxwidth - // then compute top and adjust bottom if needed! - if (m < (2*numaddonsshown + 1)) - { - m = min(sizedirmenu, 2*numaddonsshown + 1); - i = 0; - } - else - i = m - (2*numaddonsshown + 1); - - if (i != 0) + // draw up arrow that bobs up and down + if (t != 0) V_DrawString(19, y+4 - (skullAnimCounter/5), highlightflags, "\x1A"); + // make the selection box flash yellow if (skullAnimCounter < 4) flashcol = V_GetStringColormap(highlightflags); - for (; i < m; i++) + // draw icons and item names + for (i = t; i <= b; i++) { UINT32 flags = V_ALLOWLOWERCASE; if (y > BASEVIDHEIGHT) break; @@ -4239,12 +6457,14 @@ static void M_DrawAddons(void) else V_DrawSmallScaledPatch(x-(16+4), y, 0, addonsp[(type & ~EXT_LOADED)]); + // draw selection box for the item currently selected if ((size_t)i == dir_on[menudepthleft]) { V_DrawFixedPatch((x-(16+4))< (charsonside*2 + 3)) V_DrawString(x, y+4, flags, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1))); @@ -4256,9 +6476,11 @@ static void M_DrawAddons(void) y += 16; } - if (m != (ssize_t)sizedirmenu) + // draw down arrow that bobs down and up + if (b != sizedirmenu) V_DrawString(19, y-12 + (skullAnimCounter/5), highlightflags, "\x1B"); + // draw search box y = BASEVIDHEIGHT - currentMenu->y + 1; M_DrawTextBox(x - (21 + 5), y, MAXSTRINGLENGTH, 1); @@ -4270,9 +6492,11 @@ static void M_DrawAddons(void) V_DrawCharacter(x - 18 + V_StringWidth(menusearch+1, 0), y + 8, '_' | 0x80, false); + // draw search icon x -= (21 + 5 + 16); V_DrawSmallScaledPatch(x, y + 4, (menusearch[0] ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+3]); + // draw save icon x = BASEVIDWIDTH - x - 16; V_DrawSmallScaledPatch(x, y + 4, ((!modifiedgame || savemoddata) ? 0 : V_TRANSLUCENT), addonsp[NUM_EXT+4]); @@ -4433,12 +6657,6 @@ static void M_HandleAddons(INT32 choice) M_AddonExec(KEY_ENTER); break; case EXT_LUA: -#ifndef HAVE_BLUA - S_StartSound(NULL, sfx_lose); - M_StartMessage(va("%c%s\x80\nThis copy of SRB2 was compiled\nwithout support for .lua files.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); - break; -#endif - // else intentional fallthrough case EXT_SOC: case EXT_WAD: #ifdef USE_KART @@ -4467,7 +6685,7 @@ static void M_HandleAddons(INT32 choice) { closefilemenu(true); - // Secret menu! + // secrets disabled by addfile... MainMenu[secrets].status = (M_AnySecretUnlocked()) ? (IT_STRING | IT_CALL) : (IT_DISABLED); if (currentMenu->prevMenu) @@ -4480,16 +6698,29 @@ static void M_HandleAddons(INT32 choice) static void M_PandorasBox(INT32 choice) { (void)choice; - CV_StealthSetValue(&cv_dummyrings, max(players[consoleplayer].health - 1, 0)); - CV_StealthSetValue(&cv_dummylives, players[consoleplayer].lives); + if (maptol & TOL_NIGHTS) + CV_StealthSetValue(&cv_dummyrings, max(players[consoleplayer].spheres, 0)); + else + CV_StealthSetValue(&cv_dummyrings, max(players[consoleplayer].rings, 0)); + if (players[consoleplayer].lives == INFLIVES) + CV_StealthSet(&cv_dummylives, "Infinite"); + else + CV_StealthSetValue(&cv_dummylives, max(players[consoleplayer].lives, 1)); CV_StealthSetValue(&cv_dummycontinues, players[consoleplayer].continues); + SR_PandorasBox[6].status = (players[consoleplayer].charflags & SF_SUPER) ? (IT_GRAYEDOUT) : (IT_STRING | IT_CALL); + SR_PandorasBox[7].status = (emeralds == ((EMERALD7)*2)-1) ? (IT_GRAYEDOUT) : (IT_STRING | IT_CALL); M_SetupNextMenu(&SR_PandoraDef); } static boolean M_ExitPandorasBox(void) { - if (cv_dummyrings.value != max(players[consoleplayer].health - 1, 0)) - COM_ImmedExecute(va("setrings %d", cv_dummyrings.value)); + if (cv_dummyrings.value != max(players[consoleplayer].rings, 0)) + { + if (maptol & TOL_NIGHTS) + COM_ImmedExecute(va("setspheres %d", cv_dummyrings.value)); + else + COM_ImmedExecute(va("setrings %d", cv_dummyrings.value)); + } if (cv_dummylives.value != players[consoleplayer].lives) COM_ImmedExecute(va("setlives %d", cv_dummylives.value)); if (cv_dummycontinues.value != players[consoleplayer].continues) @@ -4576,10 +6807,10 @@ static void M_Options(INT32 choice) (void)choice; // if the player is not admin or server, disable server options - OP_MainMenu[5].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); + OP_MainMenu[5].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // if the player is playing _at all_, disable the erase data options - OP_DataOptionsMenu[1].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); + OP_DataOptionsMenu[2].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); OP_MainDef.prevMenu = currentMenu; M_SetupNextMenu(&OP_MainDef); @@ -4619,12 +6850,24 @@ static void M_UltimateCheat(INT32 choice) I_Quit(); } +static void M_AllowSuper(INT32 choice) +{ + (void)choice; + + players[consoleplayer].charflags |= SF_SUPER; + M_StartMessage(M_GetText("You are now capable of turning super.\nRemember to get all the emeralds!\n"),NULL,MM_NOTHING); + SR_PandorasBox[6].status = IT_GRAYEDOUT; + + G_SetGameModified(multiplayer); +} + static void M_GetAllEmeralds(INT32 choice) { (void)choice; emeralds = ((EMERALD7)*2)-1; M_StartMessage(M_GetText("You now have all 7 emeralds.\nUse them wisely.\nWith great power comes great ring drain.\n"),NULL,MM_NOTHING); + SR_PandorasBox[7].status = IT_GRAYEDOUT; G_SetGameModified(multiplayer); } @@ -4655,7 +6898,7 @@ static void M_LevelSelectWarp(INT32 choice) if (W_CheckNumForName(G_BuildMapName(cv_nextmap.value)) == LUMPERROR) { -// CONS_Alert(CONS_WARNING, "Internal game map '%s' not found\n", G_BuildMapName(cv_nextmap.value)); + CONS_Alert(CONS_WARNING, "Internal game map '%s' not found\n", G_BuildMapName(cv_nextmap.value)); return; } @@ -4667,7 +6910,7 @@ static void M_LevelSelectWarp(INT32 choice) G_LoadGame((UINT32)cursaveslot, startmap); else { - cursaveslot = -1; + cursaveslot = 0; M_SetupChoosePlayer(0); } } @@ -4678,43 +6921,380 @@ static void M_LevelSelectWarp(INT32 choice) UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES]; -#define NUMCHECKLIST 8 -static void M_DrawChecklist(void) +static boolean checklist_cangodown; // uuuueeerggghhhh HACK + +static void M_HandleChecklist(INT32 choice) { - INT32 i, j = 0; - - for (i = 0; i < MAXUNLOCKABLES; i++) + INT32 j; + switch (choice) { - if (unlockables[i].name[0] == 0 || unlockables[i].nochecklist - || !unlockables[i].conditionset || unlockables[i].conditionset > MAXCONDITIONSETS) - continue; + case KEY_DOWNARROW: + S_StartSound(NULL, sfx_menu1); + if ((check_on != MAXUNLOCKABLES) && checklist_cangodown) + { + for (j = check_on+1; j < MAXUNLOCKABLES; j++) + { + if (!unlockables[j].name[0]) + continue; + // if (unlockables[j].nochecklist) + // continue; + if (!unlockables[j].conditionset) + continue; + if (unlockables[j].conditionset > MAXCONDITIONSETS) + continue; + if (!unlockables[j].unlocked && unlockables[j].showconditionset && !M_Achieved(unlockables[j].showconditionset)) + continue; + if (unlockables[j].conditionset == unlockables[check_on].conditionset) + continue; + break; + } + if (j != MAXUNLOCKABLES) + check_on = j; + } + return; - V_DrawString(8, 8+(24*j), V_RETURN8, unlockables[i].name); - V_DrawString(160, 8+(24*j), V_RETURN8, V_WordWrap(160, 292, 0, unlockables[i].objective)); + case KEY_UPARROW: + S_StartSound(NULL, sfx_menu1); + if (check_on) + { + for (j = check_on-1; j > -1; j--) + { + if (!unlockables[j].name[0]) + continue; + // if (unlockables[j].nochecklist) + // continue; + if (!unlockables[j].conditionset) + continue; + if (unlockables[j].conditionset > MAXCONDITIONSETS) + continue; + if (!unlockables[j].unlocked && unlockables[j].showconditionset && !M_Achieved(unlockables[j].showconditionset)) + continue; + if (j && unlockables[j].conditionset == unlockables[j-1].conditionset) + continue; + break; + } + if (j != -1) + check_on = j; + } + return; - if (unlockables[i].unlocked) - V_DrawString(308, 8+(24*j), V_YELLOWMAP, "Y"); - else - V_DrawString(308, 8+(24*j), V_YELLOWMAP, "N"); - - if (++j >= NUMCHECKLIST) + case KEY_ESCAPE: + if (currentMenu->prevMenu) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ClearMenus(true); + return; + default: break; } } +#define addy(add) { y += add; if ((y - currentMenu->y) > (scrollareaheight*2)) goto finishchecklist; } + +static void M_DrawChecklist(void) +{ + INT32 i = check_on, j = 0, y = currentMenu->y; + UINT32 condnum, previd, maxcond; + condition_t *cond; + + // draw title (or big pic) + M_DrawMenuTitle(); + + if (check_on) + V_DrawString(10, y-(skullAnimCounter/5), V_YELLOWMAP, "\x1A"); + + while (i < MAXUNLOCKABLES) + { + if (unlockables[i].name[0] == 0 //|| unlockables[i].nochecklist + || !unlockables[i].conditionset || unlockables[i].conditionset > MAXCONDITIONSETS + || (!unlockables[i].unlocked && unlockables[i].showconditionset && !M_Achieved(unlockables[i].showconditionset))) + { + i += 1; + continue; + } + + V_DrawString(currentMenu->x, y, ((unlockables[i].unlocked) ? V_GREENMAP : V_TRANSLUCENT)|V_ALLOWLOWERCASE, ((unlockables[i].unlocked || !unlockables[i].nochecklist) ? unlockables[i].name : M_CreateSecretMenuOption(unlockables[i].name))); + + for (j = i+1; j < MAXUNLOCKABLES; j++) + { + if (!(unlockables[j].name[0] == 0 //|| unlockables[j].nochecklist + || !unlockables[j].conditionset || unlockables[j].conditionset > MAXCONDITIONSETS)) + break; + } + if ((j != MAXUNLOCKABLES) && (unlockables[i].conditionset == unlockables[j].conditionset)) + addy(8) + else + { + if ((maxcond = conditionSets[unlockables[i].conditionset-1].numconditions)) + { + cond = conditionSets[unlockables[i].conditionset-1].condition; + previd = cond[0].id; + addy(2); + + if (unlockables[i].objective[0] != '/') + { + addy(16); + V_DrawString(currentMenu->x, y-8, + V_ALLOWLOWERCASE, + va("\x1E %s", unlockables[i].objective)); + y -= 8; + } + else + { + for (condnum = 0; condnum < maxcond; condnum++) + { + const char *beat = "!"; + + if (cond[condnum].id != previd) + { + addy(8); + V_DrawString(currentMenu->x + 4, y, V_YELLOWMAP, "OR"); + } + + addy(8); + + switch (cond[condnum].type) + { + case UC_PLAYTIME: + { + UINT32 hours = G_TicsToHours(cond[condnum].requirement); + UINT32 minutes = G_TicsToMinutes(cond[condnum].requirement, false); + UINT32 seconds = G_TicsToSeconds(cond[condnum].requirement); + +#define getplural(field) ((field == 1) ? "" : "s") + if (hours) + { + if (minutes) + beat = va("Play the game for %d hour%s %d minute%s", hours, getplural(hours), minutes, getplural(minutes)); + else + beat = va("Play the game for %d hour%s", hours, getplural(hours)); + } + else + { + if (minutes && seconds) + beat = va("Play the game for %d minute%s %d second%s", minutes, getplural(minutes), seconds, getplural(seconds)); + else if (minutes) + beat = va("Play the game for %d minute%s", minutes, getplural(minutes)); + else + beat = va("Play the game for %d second%s", seconds, getplural(seconds)); + } +#undef getplural + } + break; + case UC_MAPVISITED: + case UC_MAPBEATEN: + case UC_MAPALLEMERALDS: + case UC_MAPULTIMATE: + case UC_MAPPERFECT: + { + char *title = G_BuildMapTitle(cond[condnum].requirement); + + if (title) + { + const char *level = ((M_MapLocked(cond[condnum].requirement) || !((mapheaderinfo[cond[condnum].requirement-1]->menuflags & LF2_NOVISITNEEDED) || (mapvisited[cond[condnum].requirement-1] & MV_MAX))) ? M_CreateSecretMenuOption(title) : title); + + switch (cond[condnum].type) + { + case UC_MAPVISITED: + beat = va("Visit %s", level); + break; + case UC_MAPALLEMERALDS: + beat = va("Beat %s with all emeralds", level); + break; + case UC_MAPULTIMATE: + beat = va("Beat %s in Ultimate mode", level); + break; + case UC_MAPPERFECT: + beat = va("Get all rings in %s", level); + break; + case UC_MAPBEATEN: + default: + beat = va("Beat %s", level); + break; + } + Z_Free(title); + } + } + break; + case UC_MAPSCORE: + case UC_MAPTIME: + case UC_MAPRINGS: + { + char *title = G_BuildMapTitle(cond[condnum].extrainfo1); + + if (title) + { + const char *level = ((M_MapLocked(cond[condnum].extrainfo1) || !((mapheaderinfo[cond[condnum].extrainfo1-1]->menuflags & LF2_NOVISITNEEDED) || (mapvisited[cond[condnum].extrainfo1-1] & MV_MAX))) ? M_CreateSecretMenuOption(title) : title); + + switch (cond[condnum].type) + { + case UC_MAPSCORE: + beat = va("Get %d points in %s", cond[condnum].requirement, level); + break; + case UC_MAPTIME: + beat = va("Beat %s in %d:%02d.%02d", level, + G_TicsToMinutes(cond[condnum].requirement, true), + G_TicsToSeconds(cond[condnum].requirement), + G_TicsToCentiseconds(cond[condnum].requirement)); + break; + case UC_MAPRINGS: + beat = va("Get %d rings in %s", cond[condnum].requirement, level); + break; + default: + break; + } + Z_Free(title); + } + } + break; + case UC_OVERALLSCORE: + case UC_OVERALLTIME: + case UC_OVERALLRINGS: + { + switch (cond[condnum].type) + { + case UC_OVERALLSCORE: + beat = va("Get %d points over all maps", cond[condnum].requirement); + break; + case UC_OVERALLTIME: + beat = va("Get a total time of less than %d:%02d.%02d", + G_TicsToMinutes(cond[condnum].requirement, true), + G_TicsToSeconds(cond[condnum].requirement), + G_TicsToCentiseconds(cond[condnum].requirement)); + break; + case UC_OVERALLRINGS: + beat = va("Get %d rings over all maps", cond[condnum].requirement); + break; + default: + break; + } + } + break; + case UC_GAMECLEAR: + case UC_ALLEMERALDS: + { + const char *emeraldtext = ((cond[condnum].type == UC_ALLEMERALDS) ? " with all emeralds" : ""); + if (cond[condnum].requirement != 1) + beat = va("Beat the game %d times%s", + cond[condnum].requirement, emeraldtext); + else + beat = va("Beat the game%s", + emeraldtext); + } + break; + case UC_TOTALEMBLEMS: + beat = va("Collect %s%d emblems", ((numemblems+numextraemblems == cond[condnum].requirement) ? "all " : ""), cond[condnum].requirement); + break; + case UC_NIGHTSTIME: + case UC_NIGHTSSCORE: + case UC_NIGHTSGRADE: + { + char *title = G_BuildMapTitle(cond[condnum].extrainfo1); + + if (title) + { + const char *level = ((M_MapLocked(cond[condnum].extrainfo1) || !((mapheaderinfo[cond[condnum].extrainfo1-1]->menuflags & LF2_NOVISITNEEDED) || (mapvisited[cond[condnum].extrainfo1-1] & MV_MAX))) ? M_CreateSecretMenuOption(title) : title); + + switch (cond[condnum].type) + { + case UC_NIGHTSSCORE: + if (cond[condnum].extrainfo2) + beat = va("Get %d points in %s, mare %d", cond[condnum].requirement, level, cond[condnum].extrainfo2); + else + beat = va("Get %d points in %s", cond[condnum].requirement, level); + break; + case UC_NIGHTSTIME: + if (cond[condnum].extrainfo2) + beat = va("Beat %s, mare %d in %d:%02d.%02d", level, cond[condnum].extrainfo2, + G_TicsToMinutes(cond[condnum].requirement, true), + G_TicsToSeconds(cond[condnum].requirement), + G_TicsToCentiseconds(cond[condnum].requirement)); + else + beat = va("Beat %s in %d:%02d.%02d", + level, + G_TicsToMinutes(cond[condnum].requirement, true), + G_TicsToSeconds(cond[condnum].requirement), + G_TicsToCentiseconds(cond[condnum].requirement)); + break; + case UC_NIGHTSGRADE: + { + char grade = ('F' - (char)cond[condnum].requirement); + if (grade < 'A') + grade = 'A'; + if (cond[condnum].extrainfo2) + beat = va("Get grade %c in %s, mare %d", grade, level, cond[condnum].extrainfo2); + else + beat = va("Get grade %c in %s", grade, level); + } + break; + default: + break; + } + Z_Free(title); + } + } + break; + case UC_TRIGGER: + case UC_EMBLEM: + case UC_CONDITIONSET: + default: + y -= 8; // Nope, not showing this. + break; + } + if (beat[0] != '!') + { + V_DrawString(currentMenu->x, y, 0, "\x1E"); + V_DrawString(currentMenu->x+12, y, V_ALLOWLOWERCASE, beat); + } + previd = cond[condnum].id; + } + } + } + addy(12); + } + i = j; + + /*V_DrawString(160, 8+(24*j), V_RETURN8, V_WordWrap(160, 292, 0, unlockables[i].objective)); + + if (unlockables[i].unlocked) + V_DrawString(308, 8+(24*j), V_YELLOWMAP, "Y"); + else + V_DrawString(308, 8+(24*j), V_YELLOWMAP, "N");*/ + } + +finishchecklist: + if ((checklist_cangodown = ((y - currentMenu->y) > (scrollareaheight*2)))) // haaaaaaacks. + V_DrawString(10, currentMenu->y+(scrollareaheight*2)+(skullAnimCounter/5), V_YELLOWMAP, "\x1B"); +} + #define NUMHINTS 5 + static void M_EmblemHints(INT32 choice) { + INT32 i; + UINT32 local = 0; + emblem_t *emblem; + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + if (++local > NUMHINTS*2) + break; + } + (void)choice; - SR_EmblemHintMenu[0].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET); + SR_EmblemHintMenu[0].status = (local > NUMHINTS*2) ? (IT_STRING | IT_ARROWS) : (IT_DISABLED); + SR_EmblemHintMenu[1].status = (M_SecretUnlocked(SECRET_ITEMFINDER)) ? (IT_CVAR|IT_STRING) : (IT_SECRET); + hintpage = 1; M_SetupNextMenu(&SR_EmblemHintDef); - itemOn = 1; // always start on back. + itemOn = 2; // always start on back. } static void M_DrawEmblemHints(void) { - INT32 i, j = 0; - UINT32 collected = 0; + INT32 i, j = 0, x, y, left_hints = NUMHINTS, pageflag = 0; + UINT32 collected = 0, totalemblems = 0, local = 0; emblem_t *emblem; const char *hint; @@ -4724,56 +7304,117 @@ static void M_DrawEmblemHints(void) if (emblem->level != gamemap || emblem->type > ET_SKIN) continue; - if (emblem->collected) - { - collected = V_GREENMAP; - V_DrawMappedPatch(12, 12+(28*j), 0, W_CachePatchName(M_GetEmblemPatch(emblem), PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); - } - else - { - collected = 0; - V_DrawScaledPatch(12, 12+(28*j), 0, W_CachePatchName("NEEDIT", PU_CACHE)); - } - - if (emblem->hint[0]) - hint = emblem->hint; - else - hint = M_GetText("No hints available."); - hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); - V_DrawString(40, 8+(28*j), V_RETURN8|V_ALLOWLOWERCASE|collected, hint); - - if (++j >= NUMHINTS) - break; + local++; } - if (!j) + + x = (local > NUMHINTS ? 4 : 12); + y = 8; + + if (local > NUMHINTS){ + if (local > ((hintpage-1)*NUMHINTS*2) && local < ((hintpage)*NUMHINTS*2)){ + if (NUMHINTS % 2 == 1) + left_hints = (local - ((hintpage-1)*NUMHINTS*2) + 1) / 2; + else + left_hints = (local - ((hintpage-1)*NUMHINTS*2)) / 2; + }else{ + left_hints = NUMHINTS; + } + } + + if (local > NUMHINTS*2){ + if (itemOn == 0){ + pageflag = V_YELLOWMAP; + } + V_DrawString(currentMenu->x + 40, currentMenu->y + 10, pageflag, va("%d of %d",hintpage, local/(NUMHINTS*2) + 1)); + } + + // If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page, + // put half (rounded up) of the hints on the left, and half (rounded down) on the right + + + if (!local) V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); - - M_DrawGenericMenu(); -} - -static void M_DrawLevelSelectMenu(void) -{ - M_DrawGenericMenu(); - - if (cv_nextmap.value) + else for (i = 0; i < numemblems; i++) { - lumpnum_t lumpnum; - patch_t *PictureOfLevel; + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; - // A 160x100 image of the level as entry MAPxxP - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + totalemblems++; - if (lumpnum != LUMPERROR) - PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_CACHE); - else - PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE); + if (totalemblems >= ((hintpage-1)*(NUMHINTS*2) + 1) && totalemblems < (hintpage*NUMHINTS*2)+1){ - V_DrawSmallScaledPatch(200, 110, 0, PictureOfLevel); + if (emblem->collected) + { + collected = V_GREENMAP; + V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_PATCH), + R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); + } + else + { + collected = 0; + V_DrawScaledPatch(x, y+4, 0, W_CachePatchName("NEEDIT", PU_PATCH)); + } + + if (emblem->hint[0]) + hint = emblem->hint; + else + hint = M_GetText("No hint available for this emblem."); + hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); + //always draw tiny if we have more than NUMHINTS*2, visually more appealing + if (local > NUMHINTS) + V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + else + V_DrawString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + + y += 28; + + // If there are more than 1 page's but less than 2 pages' worth of emblems on the last possible page, + // put half (rounded up) of the hints on the left, and half (rounded down) on the right + + if (++j == left_hints) + { + x = 4+(BASEVIDWIDTH/2); + y = 8; + } + else if (j >= NUMHINTS*2) + break; + } } + + M_DrawGenericMenu(); } -static void M_DrawSkyRoom(void) + +static void M_HandleEmblemHints(INT32 choice) +{ + INT32 i; + emblem_t *emblem; + UINT32 stageemblems = 0; + + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + + stageemblems++; + } + + + if (choice == 0){ + if (hintpage > 1){ + hintpage--; + } + }else{ + if (hintpage < ((stageemblems-1)/(NUMHINTS*2) + 1)){ + hintpage++; + } + } + +} + +/*static void M_DrawSkyRoom(void) { INT32 i, y = 0; @@ -4791,8 +7432,282 @@ static void M_DrawSkyRoom(void) return; V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + y, V_YELLOWMAP, cv_soundtest.string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - currentMenu->x - 10 - V_StringWidth(cv_soundtest.string, 0) - (skullAnimCounter/5), currentMenu->y + y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - currentMenu->x + 2 + (skullAnimCounter/5), currentMenu->y + y, + '\x1D' | V_YELLOWMAP, false); + } if (cv_soundtest.value) V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + y + 8, V_YELLOWMAP, S_sfx[cv_soundtest.value].name); +}*/ + +static musicdef_t *curplaying = NULL; +static INT32 st_sel = 0, st_cc = 0; +static tic_t st_time = 0; +static patch_t* st_radio[9]; +static patch_t* st_launchpad[4]; + +static void M_CacheSoundTest(void) +{ + UINT8 i; + char buf[8]; + + STRBUFCPY(buf, "M_RADIOn"); + for (i = 0; i < 9; i++) + { + buf[7] = (char)('0'+i); + st_radio[i] = W_CachePatchName(buf, PU_PATCH); + } + + STRBUFCPY(buf, "M_LPADn"); + for (i = 0; i < 4; i++) + { + buf[6] = (char)('0'+i); + st_launchpad[i] = W_CachePatchName(buf, PU_PATCH); + } +} + +static void M_SoundTest(INT32 choice) +{ + INT32 ul = skyRoomMenuTranslations[choice-1]; + + soundtestpage = (UINT8)(unlockables[ul].variable); + if (!soundtestpage) + soundtestpage = 1; + + if (!S_PrepareSoundTest()) + { + M_StartMessage(M_GetText("No selectable tracks found.\n"),NULL,MM_NOTHING); + return; + } + + M_CacheSoundTest(); + + curplaying = NULL; + st_time = 0; + + st_sel = 0; + + st_cc = cv_closedcaptioning.value; // hack; + cv_closedcaptioning.value = 1; // hack + + M_SetupNextMenu(&SR_SoundTestDef); +} + +static void M_DrawSoundTest(void) +{ + INT32 x, y, i; + fixed_t hscale = FRACUNIT/2, vscale = FRACUNIT/2, bounce = 0; + UINT8 frame[4] = {0, 0, -1, SKINCOLOR_RUBY}; + + if (needpatchrecache) + M_CacheSoundTest(); + + // let's handle the ticker first. ideally we'd tick this somewhere else, BUT... + if (curplaying) + { + if (curplaying == &soundtestsfx) + { + if (cv_soundtest.value) + { + frame[1] = (2-st_time); + frame[2] = ((cv_soundtest.value - 1) % 9); + frame[3] += (((cv_soundtest.value - 1) / 9) % (MAXSKINCOLORS - frame[3])); + if (st_time < 2) + st_time++; + } + } + else + { + if (curplaying->stoppingtics && st_time >= curplaying->stoppingtics) + { + curplaying = NULL; + st_time = 0; + } + else + { + fixed_t work, bpm = curplaying->bpm; + angle_t ang; + //bpm = FixedDiv((60*TICRATE)<= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes of loop on the same song to reach + st_time = (work>>FRACBITS); + + work = FixedDiv(work*180, bpm); + frame[0] = 8-(work/(20< 8) // VERY small likelihood for the above calculation to wrap, but it turns out it IS possible lmao + frame[0] = 0; + ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK; + bounce = (FINESINE(ang) - FRACUNIT/2); + hscale -= bounce/16; + vscale += bounce/16; + + st_time++; + } + } + } + + x = 90<alttitle[0]) + titl = va("%s - %s - ", curplaying->title, curplaying->alttitle); + else + titl = va("%s - ", curplaying->title); + } + else + titl = "None - "; + + i = V_LevelNameWidth(titl); + + if (++st_scroll >= i) + st_scroll %= i; + + x -= st_scroll; + + while (x < BASEVIDWIDTH-y) + x += i; + while (x > y) + { + x -= i; + V_DrawLevelTitle(x, 22, 0, titl); + } + + if (curplaying) + V_DrawRightAlignedThinString(BASEVIDWIDTH-16, 46, V_ALLOWLOWERCASE, curplaying->authors); + } + + V_DrawFill(165, 60, 140, 112, 159); + + { + INT32 t, b, q, m = 112; + + if (numsoundtestdefs <= 7) + { + t = 0; + b = numsoundtestdefs - 1; + i = 0; + } + else + { + q = m; + m = (5*m)/numsoundtestdefs; + if (st_sel < 3) + { + t = 0; + b = 6; + i = 0; + } + else if (st_sel >= numsoundtestdefs-4) + { + t = numsoundtestdefs - 7; + b = numsoundtestdefs - 1; + i = q-m; + } + else + { + t = st_sel - 3; + b = st_sel + 3; + i = (t * (q-m))/(numsoundtestdefs - 7); + } + } + + V_DrawFill(165+140-1, 60 + i, 1, m, 0); + + if (t != 0) + V_DrawString(165+140+4, 60+4 - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); + + if (b != numsoundtestdefs - 1) + V_DrawString(165+140+4, 60+112-12 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); + + x = 169; + y = 64; + + while (t <= b) + { + if (t == st_sel) + V_DrawFill(165, y-4, 140-1, 16, 155); + if (!soundtestdefs[t]->allowed) + { + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, "???"); + } + else if (soundtestdefs[t] == &soundtestsfx) + { + const char *sfxstr = va("SFX %s", cv_soundtest.string); + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0), sfxstr); + if (t == st_sel) + { + V_DrawCharacter(x - 10 - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(x + 2 + V_StringWidth(sfxstr, 0) + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + + if (curplaying == soundtestdefs[t]) + { + sfxstr = (cv_soundtest.value) ? S_sfx[cv_soundtest.value].name : "N/A"; + i = V_StringWidth(sfxstr, 0); + V_DrawFill(165+140-9-i, y-4, i+8, 16, 150); + V_DrawRightAlignedString(165+140-5, y, V_YELLOWMAP, sfxstr); + } + } + else + { + V_DrawString(x, y, (t == st_sel ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, soundtestdefs[t]->title); + if (curplaying == soundtestdefs[t]) + { + V_DrawFill(165+140-9, y-4, 8, 16, 150); + //V_DrawCharacter(165+140-8, y, '\x19' | V_YELLOWMAP, false); + V_DrawFixedPatch((165+140-9)<= numsoundtestdefs-1) + st_sel = 0; + { + cv_closedcaptioning.value = st_cc; // hack + S_StartSound(NULL, sfx_menu1); + cv_closedcaptioning.value = 1; // hack + } break; case KEY_UPARROW: - M_PrevOpt(); - S_StartSound(NULL, sfx_menu1); + if (!st_sel--) + st_sel = numsoundtestdefs-1; + { + cv_closedcaptioning.value = st_cc; // hack + S_StartSound(NULL, sfx_menu1); + cv_closedcaptioning.value = 1; // hack + } + break; + case KEY_PGDN: + if (st_sel < numsoundtestdefs-1) + { + st_sel += 3; + if (st_sel >= numsoundtestdefs-1) + st_sel = numsoundtestdefs-1; + cv_closedcaptioning.value = st_cc; // hack + S_StartSound(NULL, sfx_menu1); + cv_closedcaptioning.value = 1; // hack + } + break; + case KEY_PGUP: + if (st_sel) + { + st_sel -= 3; + if (st_sel < 0) + st_sel = 0; + cv_closedcaptioning.value = st_cc; // hack + S_StartSound(NULL, sfx_menu1); + cv_closedcaptioning.value = 1; // hack + } break; case KEY_BACKSPACE: + if (curplaying) + { + S_StopSounds(); + S_StopMusic(); + curplaying = NULL; + st_time = 0; + cv_closedcaptioning.value = st_cc; // hack + S_StartSound(NULL, sfx_skid); + cv_closedcaptioning.value = 1; // hack + } + break; case KEY_ESCAPE: exitmenu = true; break; case KEY_RIGHTARROW: - CV_AddValue(&cv_soundtest, 1); + if (soundtestdefs[st_sel] == &soundtestsfx && soundtestdefs[st_sel]->allowed) + { + S_StopSounds(); + S_StopMusic(); + curplaying = soundtestdefs[st_sel]; + st_time = 0; + CV_AddValue(&cv_soundtest, 1); + } break; case KEY_LEFTARROW: - CV_AddValue(&cv_soundtest, -1); + if (soundtestdefs[st_sel] == &soundtestsfx && soundtestdefs[st_sel]->allowed) + { + S_StopSounds(); + S_StopMusic(); + curplaying = soundtestdefs[st_sel]; + st_time = 0; + CV_AddValue(&cv_soundtest, -1); + } break; case KEY_ENTER: S_StopSounds(); - S_StartSound(NULL, cv_soundtest.value); + S_StopMusic(); + st_time = 0; + if (soundtestdefs[st_sel]->allowed) + { + curplaying = soundtestdefs[st_sel]; + if (curplaying == &soundtestsfx) + { + // S_StopMusic() -- is this necessary? + if (cv_soundtest.value) + S_StartSound(NULL, cv_soundtest.value); + } + else + S_ChangeMusicInternal(curplaying->name, !curplaying->stoppingtics); + } + else + { + curplaying = NULL; + S_StartSound(NULL, sfx_lose); + } break; default: @@ -4830,6 +7820,11 @@ static void M_HandleSoundTest(INT32 choice) } if (exitmenu) { + Z_Free(soundtestdefs); + soundtestdefs = NULL; + + cv_closedcaptioning.value = st_cc; // undo hack + if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else @@ -4904,8 +7899,8 @@ static void M_SecretsMenu(INT32 choice) SR_MainMenu[i].itemaction = M_Credits; break; case SECRET_SOUNDTEST: - SR_MainMenu[i].status = IT_STRING|IT_KEYHANDLER; - SR_MainMenu[i].itemaction = M_HandleSoundTest; + SR_MainMenu[i].status = IT_STRING|IT_CALL; + SR_MainMenu[i].itemaction = M_SoundTest; default: break; } @@ -4943,7 +7938,7 @@ static void M_CustomWarp(INT32 choice) static void M_Credits(INT32 choice) { (void)choice; - cursaveslot = -2; + cursaveslot = -1; M_ClearMenus(true); F_StartCredits(); } @@ -4955,13 +7950,13 @@ static void M_CustomLevelSelect(INT32 choice) SR_LevelSelectDef.prevMenu = currentMenu; levellistmode = LLM_LEVELSELECT; maplistoption = (UINT8)(unlockables[ul].variable); - if (M_CountLevelsToShowInList() == 0) + + if (!M_PrepareLevelPlatter(-1, true)) { M_StartMessage(M_GetText("No selectable levels found.\n"),NULL,MM_NOTHING); return; } - M_PrepareLevelSelect(); M_SetupNextMenu(&SR_LevelSelectDef); } @@ -4972,6 +7967,8 @@ static void M_CustomLevelSelect(INT32 choice) static void M_SinglePlayerMenu(INT32 choice) { (void)choice; + SP_MainMenu[sptutorial].status = + tutorialmap ? IT_CALL|IT_STRING : IT_NOTHING|IT_DISABLED; SP_MainMenu[sprecordattack].status = (M_SecretUnlocked(SECRET_RECORDATTACK)) ? IT_CALL|IT_STRING : IT_SECRET; SP_MainMenu[spnightsmode].status = @@ -4983,167 +7980,400 @@ static void M_SinglePlayerMenu(INT32 choice) static void M_LoadGameLevelSelect(INT32 choice) { (void)choice; + + SP_LevelSelectDef.prevMenu = currentMenu; levellistmode = LLM_LEVELSELECT; - maplistoption = 1; - if (M_CountLevelsToShowInList() == 0) + maplistoption = 1+2; + + if (!M_PrepareLevelPlatter(-1, true)) { M_StartMessage(M_GetText("No selectable levels found.\n"),NULL,MM_NOTHING); return; } - SP_LevelSelectDef.prevMenu = currentMenu; - - M_PrepareLevelSelect(); M_SetupNextMenu(&SP_LevelSelectDef); } +void M_TutorialSaveControlResponse(INT32 ch) +{ + if (ch == 'y' || ch == KEY_ENTER) + { + G_CopyControls(gamecontrol, gamecontroldefault[tutorialgcs], gcl_tutorial_full, num_gcl_tutorial_full); + CV_Set(&cv_usemouse, cv_usemouse.defaultvalue); + CV_Set(&cv_alwaysfreelook, cv_alwaysfreelook.defaultvalue); + CV_Set(&cv_mousemove, cv_mousemove.defaultvalue); + CV_Set(&cv_analog[0], cv_analog[0].defaultvalue); + S_StartSound(NULL, sfx_itemup); + } + else + S_StartSound(NULL, sfx_menu1); +} + +static void M_TutorialControlResponse(INT32 ch) +{ + if (ch != KEY_ESCAPE) + { + G_CopyControls(gamecontroldefault[gcs_custom], gamecontrol, NULL, 0); // using gcs_custom as temp storage for old controls + if (ch == 'y' || ch == KEY_ENTER) + { + tutorialgcs = gcs_fps; + tutorialusemouse = cv_usemouse.value; + tutorialfreelook = cv_alwaysfreelook.value; + tutorialmousemove = cv_mousemove.value; + tutorialanalog = cv_analog[0].value; + + G_CopyControls(gamecontrol, gamecontroldefault[tutorialgcs], gcl_tutorial_full, num_gcl_tutorial_full); + CV_Set(&cv_usemouse, cv_usemouse.defaultvalue); + CV_Set(&cv_alwaysfreelook, cv_alwaysfreelook.defaultvalue); + CV_Set(&cv_mousemove, cv_mousemove.defaultvalue); + CV_Set(&cv_analog[0], cv_analog[0].defaultvalue); + + //S_StartSound(NULL, sfx_itemup); + } + else + { + tutorialgcs = gcs_custom; + S_StartSound(NULL, sfx_menu1); + } + M_StartTutorial(INT32_MAX); + } + else + S_StartSound(NULL, sfx_menu1); + + MessageDef.prevMenu = &SP_MainDef; // if FirstPrompt -> ControlsPrompt -> ESC, we would go to the main menu unless we force this +} + +// Starts up the tutorial immediately (tbh I wasn't sure where else to put this) +static void M_StartTutorial(INT32 choice) +{ + if (!tutorialmap) + return; // no map to go to, don't bother + + if (choice != INT32_MAX && G_GetControlScheme(gamecontrol, gcl_tutorial_check, num_gcl_tutorial_check) != gcs_fps) + { + M_StartMessage("Do you want to try the \202recommended \202movement controls\x80?\n\nWe will set them just for this tutorial.\n\nPress 'Y' or 'Enter' to confirm\nPress 'N' or any key to keep \nyour current controls.\n",M_TutorialControlResponse,MM_YESNO); + return; + } + else if (choice != INT32_MAX) + tutorialgcs = gcs_custom; + + CV_SetValue(&cv_tutorialprompt, 0); // first-time prompt + + tutorialmode = true; // turn on tutorial mode + + emeralds = 0; + memset(&luabanks, 0, sizeof(luabanks)); + M_ClearMenus(true); + gamecomplete = false; + cursaveslot = 0; + G_DeferedInitNew(false, G_BuildMapName(tutorialmap), 0, false, false); +} + // ============== // LOAD GAME MENU // ============== -static INT32 saveSlotSelected = 0; -static short menumovedir = 0; +static INT32 saveSlotSelected = 1; +static INT32 loadgamescroll = 0; +static UINT8 loadgameoffset = 0; + +static void M_CacheLoadGameData(void) +{ + savselp[0] = W_CachePatchName("SAVEBACK", PU_PATCH); + savselp[1] = W_CachePatchName("SAVENONE", PU_PATCH); + savselp[2] = W_CachePatchName("ULTIMATE", PU_PATCH); + + savselp[3] = W_CachePatchName("GAMEDONE", PU_PATCH); + savselp[4] = W_CachePatchName("BLACXLVL", PU_PATCH); + savselp[5] = W_CachePatchName("BLANKLVL", PU_PATCH); +} static void M_DrawLoadGameData(void) { - INT32 ecks; - INT32 i; + INT32 i, savetodraw, x, y, hsep = 90; + skin_t *charskin = NULL; - ecks = SP_LoadDef.x + 24; - M_DrawTextBox(SP_LoadDef.x-12,144, 24, 4); + if (vid.width != BASEVIDWIDTH*vid.dupx) + hsep = (hsep*vid.width)/(BASEVIDWIDTH*vid.dupx); - if (saveSlotSelected == NOSAVESLOT) // last slot is play without saving + if (needpatchrecache) + M_CacheLoadGameData(); + + for (i = -2; i <= 2; i++) { - if (ultimate_selectable) + savetodraw = (saveSlotSelected + i + numsaves)%numsaves; + x = (BASEVIDWIDTH/2 - 42 + loadgamescroll) + (i*hsep); + y = 33 + 9; + { - V_DrawCenteredString(ecks + 68, 144, V_ORANGEMAP, "ULTIMATE MODE"); - V_DrawCenteredString(ecks + 68, 156, 0, "NO RINGS, NO ONE-UPS,"); - V_DrawCenteredString(ecks + 68, 164, 0, "NO CONTINUES, ONE LIFE,"); - V_DrawCenteredString(ecks + 68, 172, 0, "FINAL DESTINATION."); + INT32 diff = x - (BASEVIDWIDTH/2 - 42); + if (diff < 0) + diff = -diff; + diff = (42 - diff)/3 - loadgameoffset; + if (diff < 0) + diff = 0; + y -= diff; } - else - { - V_DrawCenteredString(ecks + 68, 144, V_ORANGEMAP, "PLAY WITHOUT SAVING"); - V_DrawCenteredString(ecks + 68, 156, 0, "THIS GAME WILL NOT BE"); - V_DrawCenteredString(ecks + 68, 164, 0, "SAVED, BUT YOU CAN STILL"); - V_DrawCenteredString(ecks + 68, 172, 0, "GET EMBLEMS AND SECRETS."); - } - return; - } - - if (savegameinfo[saveSlotSelected].lives == -42) // Empty - { - V_DrawCenteredString(ecks + 68, 160, 0, "NO DATA"); - return; - } - - if (savegameinfo[saveSlotSelected].lives == -666) // savegame is bad - { - V_DrawCenteredString(ecks + 68, 144, V_REDMAP, "CORRUPT SAVE FILE"); - V_DrawCenteredString(ecks + 68, 156, 0, "THIS SAVE FILE"); - V_DrawCenteredString(ecks + 68, 164, 0, "CAN NOT BE LOADED."); - V_DrawCenteredString(ecks + 68, 172, 0, "DELETE USING BACKSPACE."); - return; - } - - // Draw the back sprite, it looks ugly if we don't - V_DrawScaledPatch(SP_LoadDef.x, 144+8, 0, livesback); - if (savegameinfo[saveSlotSelected].skincolor == 0) - V_DrawScaledPatch(SP_LoadDef.x,144+8,0,W_CachePatchName(skins[savegameinfo[saveSlotSelected].skinnum].face, PU_CACHE)); - else - { - UINT8 *colormap = R_GetTranslationColormap(savegameinfo[saveSlotSelected].skinnum, savegameinfo[saveSlotSelected].skincolor, 0); - V_DrawMappedPatch(SP_LoadDef.x,144+8,0,W_CachePatchName(skins[savegameinfo[saveSlotSelected].skinnum].face, PU_CACHE), colormap); - } - - V_DrawString(ecks + 12, 152, 0, savegameinfo[saveSlotSelected].playername); - -#ifdef SAVEGAMES_OTHERVERSIONS - if (savegameinfo[saveSlotSelected].gamemap & 16384) - V_DrawCenteredString(ecks + 68, 144, V_REDMAP, "OUTDATED SAVE FILE!"); -#endif - - if (savegameinfo[saveSlotSelected].gamemap & 8192) - V_DrawString(ecks + 12, 160, V_GREENMAP, "CLEAR!"); - else - V_DrawString(ecks + 12, 160, 0, va("%s", savegameinfo[saveSlotSelected].levelname)); - - // Use the big face pic for lives, duh. :3 - V_DrawScaledPatch(ecks + 12, 175, 0, W_CachePatchName("STLIVEX", PU_HUDGFX)); - V_DrawTallNum(ecks + 40, 172, 0, savegameinfo[saveSlotSelected].lives); - - // Absolute ridiculousness, condensed into another function. - V_DrawContinueIcon(ecks + 58, 182, 0, savegameinfo[saveSlotSelected].skinnum, savegameinfo[saveSlotSelected].skincolor); - V_DrawScaledPatch(ecks + 68, 175, 0, W_CachePatchName("STLIVEX", PU_HUDGFX)); - V_DrawTallNum(ecks + 96, 172, 0, savegameinfo[saveSlotSelected].continues); - - for (i = 0; i < 7; ++i) - { - if (savegameinfo[saveSlotSelected].numemeralds & (1 << i)) - V_DrawScaledPatch(ecks + 104 + (i * 8), 172, 0, tinyemeraldpics[i]); - } -} - -#define LOADBARHEIGHT SP_LoadDef.y + (LINEHEIGHT * (j+1)) + ymod -#define CURSORHEIGHT SP_LoadDef.y + (LINEHEIGHT*3) - 1 -static void M_DrawLoad(void) -{ - INT32 i, j; - INT32 ymod = 0, offset = 0; - - M_DrawMenuTitle(); - - if (menumovedir != 0) //movement illusion - { - ymod = (-(LINEHEIGHT/4))*menumovedir; - offset = ((menumovedir > 0) ? -1 : 1); - } - - V_DrawCenteredString(BASEVIDWIDTH/2, 40, 0, "Press backspace to delete a save."); - - for (i = MAXSAVEGAMES + saveSlotSelected - 2 + offset, j = 0;i <= MAXSAVEGAMES + saveSlotSelected + 2 + offset; i++, j++) - { - if ((menumovedir < 0 && j == 4) || (menumovedir > 0 && j == 0)) - continue; //this helps give the illusion of movement - - M_DrawSaveLoadBorder(SP_LoadDef.x, LOADBARHEIGHT); - - if ((i%MAXSAVEGAMES) == NOSAVESLOT) // play without saving + + if (savetodraw == 0) { + V_DrawSmallScaledPatch(x, y, 0, + savselp[((ultimate_selectable) ? 2 : 1)]); + x += 2; + y += 1; + V_DrawString(x, y, + ((savetodraw == saveSlotSelected) ? V_YELLOWMAP : 0), + "NO FILE"); + if (savetodraw == saveSlotSelected) + V_DrawFill(x, y+9, 80, 1, yellowmap[3]); + y += 11; + V_DrawSmallScaledPatch(x, y, 0, savselp[4]); + M_DrawStaticBox(x, y, V_80TRANS, 80, 50); + y += 41; if (ultimate_selectable) - V_DrawCenteredString(SP_LoadDef.x+92, LOADBARHEIGHT - 1, V_ORANGEMAP, "ULTIMATE MODE"); + V_DrawRightAlignedThinString(x + 79, y, V_REDMAP, "ULTIMATE."); else - V_DrawCenteredString(SP_LoadDef.x+92, LOADBARHEIGHT - 1, V_ORANGEMAP, "PLAY WITHOUT SAVING"); + V_DrawRightAlignedThinString(x + 79, y, V_GRAYMAP, "DON'T SAVE!"); + continue; } - if (savegameinfo[i%MAXSAVEGAMES].lives == -42) - V_DrawString(SP_LoadDef.x-6, LOADBARHEIGHT - 1, V_TRANSLUCENT, "NO DATA"); - else if (savegameinfo[i%MAXSAVEGAMES].lives == -666) - V_DrawString(SP_LoadDef.x-6, LOADBARHEIGHT - 1, V_REDMAP, "CORRUPT SAVE FILE"); - else if (savegameinfo[i%MAXSAVEGAMES].gamemap & 8192) - V_DrawString(SP_LoadDef.x-6, LOADBARHEIGHT - 1, V_GREENMAP, "CLEAR!"); - else - V_DrawString(SP_LoadDef.x-6, LOADBARHEIGHT - 1, 0, va("%s", savegameinfo[i%MAXSAVEGAMES].levelname)); + savetodraw--; - //Draw the save slot number on the right side - V_DrawRightAlignedString(SP_LoadDef.x+192, LOADBARHEIGHT - 1, 0, va("%d",(i%MAXSAVEGAMES) + 1)); + if (savegameinfo[savetodraw].lives > 0) + charskin = &skins[savegameinfo[savetodraw].skinnum]; + + // signpost background + { + UINT8 col; + if (savegameinfo[savetodraw].lives == -666) + { + V_DrawSmallScaledPatch(x+2, y+64, 0, savselp[5]); + } +#ifdef PERFECTSAVE // disabled on request + else if ((savegameinfo[savetodraw].skinnum == 1) + && (savegameinfo[savetodraw].lives == 99) + && (savegameinfo[savetodraw].gamemap & 8192) + && (savegameinfo[savetodraw].numgameovers == 0) + && (savegameinfo[savetodraw].numemeralds == ((1<<7) - 1))) // perfect save + { + V_DrawFill(x+6, y+64, 72, 50, 134); + V_DrawFill(x+6, y+74, 72, 30, 201); + V_DrawFill(x+6, y+84, 72, 10, 1); + } +#endif + else + { + if (savegameinfo[savetodraw].lives == -42) + col = 26; + else if (savegameinfo[savetodraw].botskin == 3) // & knuckles + col = 105; + else if (savegameinfo[savetodraw].botskin) // tailsbot or custom + col = 134; + else + { + if (charskin->prefoppositecolor) + { + col = charskin->prefoppositecolor - 1; + col = Color_Index[col][Color_Opposite[Color_Opposite[col][0] - 1][1]]; + } + else + { + col = charskin->prefcolor - 1; + col = Color_Index[Color_Opposite[col][0]-1][Color_Opposite[col][1]]; + } + } + + V_DrawFill(x+6, y+64, 72, 50, col); + } + } + + V_DrawSmallScaledPatch(x, y, 0, savselp[0]); + x += 2; + y += 1; + V_DrawString(x, y, + ((savetodraw == saveSlotSelected-1) ? V_YELLOWMAP : 0), + va("FILE %d", savetodraw+1)); + if (savetodraw == saveSlotSelected-1) + V_DrawFill(x, y+9, 80, 1, yellowmap[3]); + y += 11; + + // level image area + { + if ((savegameinfo[savetodraw].lives == -42) + || (savegameinfo[savetodraw].lives == -666)) + { + V_DrawFill(x, y, 80, 50, 31); + M_DrawStaticBox(x, y, V_80TRANS, 80, 50); + } + else + { + patch_t *patch; + if (savegameinfo[savetodraw].gamemap & 8192) + patch = savselp[3]; + else + { + lumpnum_t lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName((savegameinfo[savetodraw].gamemap) & 8191))); + if (lumpnum != LUMPERROR) + patch = W_CachePatchNum(lumpnum, PU_PATCH); + else + patch = savselp[5]; + } + V_DrawSmallScaledPatch(x, y, 0, patch); + } + + y += 41; + + if (savegameinfo[savetodraw].lives == -42) + V_DrawRightAlignedThinString(x + 79, y, V_GRAYMAP, "NEW GAME"); + else if (savegameinfo[savetodraw].lives == -666) + V_DrawRightAlignedThinString(x + 79, y, V_REDMAP, "CAN'T LOAD!"); + else if (savegameinfo[savetodraw].gamemap & 8192) + V_DrawRightAlignedThinString(x + 79, y, V_GREENMAP, "CLEAR!"); + else + V_DrawRightAlignedThinString(x + 79, y, V_YELLOWMAP, savegameinfo[savetodraw].levelname); + } + + if ((savegameinfo[savetodraw].lives == -42) + || (savegameinfo[savetodraw].lives == -666)) + continue; + + y += 64; + + // tiny emeralds + { + INT32 j, workx = x + 6; + for (j = 0; j < 7; ++j) + { + if (savegameinfo[savetodraw].numemeralds & (1 << j)) + V_DrawScaledPatch(workx, y, 0, emeraldpics[1][j]); + workx += 10; + } + } + + y -= 4; + + // character heads, lives, and continues + { + spritedef_t *sprdef; + spriteframe_t *sprframe; + patch_t *patch; + UINT8 *colormap = NULL; + + INT32 tempx = (x+40)<sprites[SPR2_SIGN]; + if (!sprdef->numframes) + goto skipbot; + colormap = R_GetTranslationColormap(savegameinfo[savetodraw].botskin, charbotskin->prefcolor, 0); + sprframe = &sprdef->spriteframes[0]; + patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + + V_DrawFixedPatch( + tempx + (18<highresscale, + 0, patch, colormap); + + Z_Free(colormap); + + tempx -= (20<sprites[SPR2_SIGN]; + colormap = R_GetTranslationColormap(savegameinfo[savetodraw].skinnum, charskin->prefcolor, 0); + if (!sprdef->numframes) + goto skipsign; + sprframe = &sprdef->spriteframes[0]; + patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + + V_DrawFixedPatch( + tempx, + y<highresscale, + flip, patch, colormap); + +skipsign: + y += 16; + + tempx = x + 10; + if (savegameinfo[savetodraw].lives != INFLIVES + && savegameinfo[savetodraw].lives > 9) + tempx -= 4; + + if (!charskin) // shut up compiler + goto skiplife; + + // lives + sprdef = &charskin->sprites[SPR2_LIFE]; + if (!sprdef->numframes) + goto skiplife; + sprframe = &sprdef->spriteframes[0]; + patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + + V_DrawFixedPatch( + (tempx + 4)<highresscale/2, + 0, patch, colormap); +skiplife: + if (colormap) + Z_Free(colormap); + + patch = W_CachePatchName("STLIVEX", PU_PATCH); + + V_DrawScaledPatch(tempx + 9, y + 2, 0, patch); + tempx += 16; + if (savegameinfo[savetodraw].lives == INFLIVES) + V_DrawCharacter(tempx, y + 1, '\x16', false); + else + V_DrawString(tempx, y, 0, va("%d", savegameinfo[savetodraw].lives)); + + tempx = x + 47; + if (savegameinfo[savetodraw].continues > 9) + tempx -= 4; + + // continues + if (savegameinfo[savetodraw].continues > 0) + { + V_DrawSmallScaledPatch(tempx, y, 0, W_CachePatchName("CONTSAVE", PU_PATCH)); + V_DrawScaledPatch(tempx + 9, y + 2, 0, patch); + V_DrawString(tempx + 16, y, 0, va("%d", savegameinfo[savetodraw].continues)); + } + else + { + V_DrawSmallScaledPatch(tempx, y, 0, W_CachePatchName("CONTNONE", PU_PATCH)); + V_DrawScaledPatch(tempx + 9, y + 2, 0, W_CachePatchName("STNONEX", PU_PATCH)); + V_DrawString(tempx + 16, y, V_GRAYMAP, "0"); + } + } } +} - //Draw cursors on both sides. - V_DrawScaledPatch( 32, CURSORHEIGHT, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); - V_DrawScaledPatch(274, CURSORHEIGHT, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); +static void M_DrawLoad(void) +{ + M_DrawMenuTitle(); + + if (loadgamescroll > 1 || loadgamescroll < -1) + loadgamescroll = 2*loadgamescroll/3; + else + loadgamescroll = 0; + + if (loadgameoffset > 1) + loadgameoffset = 2*loadgameoffset/3; + else + loadgameoffset = 0; M_DrawLoadGameData(); - - //finishing the movement illusion - if (menumovedir) - menumovedir += ((menumovedir > 0) ? 1 : -1); - if (abs(menumovedir) > 3) - menumovedir = 0; } -#undef LOADBARHEIGHT -#undef CURSORHEIGHT // // User wants to load this game @@ -5155,7 +8385,7 @@ static void M_LoadSelect(INT32 choice) if (saveSlotSelected == NOSAVESLOT) //last slot is play without saving { M_NewGame(); - cursaveslot = -1; + cursaveslot = 0; return; } @@ -5164,8 +8394,8 @@ static void M_LoadSelect(INT32 choice) // This slot is empty, so start a new game here. M_NewGame(); } - else if (savegameinfo[saveSlotSelected].gamemap & 8192) // Completed - M_LoadGameLevelSelect(saveSlotSelected + 1); + else if (savegameinfo[saveSlotSelected-1].gamemap & 8192) // Completed + M_LoadGameLevelSelect(0); else G_LoadGame((UINT32)saveSlotSelected, 0); @@ -5187,12 +8417,11 @@ static void M_ReadSavegameInfo(UINT32 slot) INT32 fake; // Dummy variable char temp[sizeof(timeattackfolder)]; char vcheck[VERSIONSIZE]; -#ifdef SAVEGAMES_OTHERVERSIONS - boolean oldversion = false; -#endif sprintf(savename, savegamename, slot); + slot--; + length = FIL_ReadFile(savename, &savebuffer); if (length == 0) { @@ -5208,14 +8437,7 @@ static void M_ReadSavegameInfo(UINT32 slot) // Version check memset(vcheck, 0, sizeof (vcheck)); sprintf(vcheck, "version %d", VERSION); - if (strcmp((const char *)save_p, (const char *)vcheck)) - { -#ifdef SAVEGAMES_OTHERVERSIONS - oldversion = true; -#else - BADSAVE // Incompatible versions? -#endif - } + if (strcmp((const char *)save_p, (const char *)vcheck)) BADSAVE save_p += VERSIONSIZE; // dearchive all the modifications @@ -5227,30 +8449,19 @@ static void M_ReadSavegameInfo(UINT32 slot) if (((fake-1) & 8191) >= NUMMAPS) BADSAVE if(!mapheaderinfo[(fake-1) & 8191]) - { savegameinfo[slot].levelname[0] = '\0'; - savegameinfo[slot].actnum = 0; - } else { - strcpy(savegameinfo[slot].levelname, mapheaderinfo[(fake-1) & 8191]->lvlttl); - savegameinfo[slot].actnum = mapheaderinfo[(fake-1) & 8191]->actnum; + strlcpy(savegameinfo[slot].levelname, mapheaderinfo[(fake-1) & 8191]->lvlttl, 17+1); + + if (strlen(mapheaderinfo[(fake-1) & 8191]->lvlttl) >= 17) + strcpy(savegameinfo[slot].levelname+17-3, "..."); } -#ifdef SAVEGAMES_OTHERVERSIONS - if (oldversion) - { - if (fake == 24) //meh, let's count old Clear! saves too - fake |= 8192; - fake |= 16384; // marker for outdated version - } -#endif savegameinfo[slot].gamemap = fake; CHECKPOS - fake = READUINT16(save_p)-357; // emeralds - - savegameinfo[slot].numemeralds = (UINT8)fake; + savegameinfo[slot].numemeralds = READUINT16(save_p)-357; // emeralds CHECKPOS READSTRINGN(save_p, temp, sizeof(temp)); // mod it belongs to @@ -5259,42 +8470,50 @@ static void M_ReadSavegameInfo(UINT32 slot) // P_UnArchivePlayer() CHECKPOS - savegameinfo[slot].skincolor = READUINT8(save_p); - CHECKPOS - savegameinfo[slot].skinnum = READUINT8(save_p); + fake = READUINT16(save_p); + savegameinfo[slot].skinnum = fake & ((1<<5) - 1); + if (savegameinfo[slot].skinnum >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].skinnum)) + BADSAVE + savegameinfo[slot].botskin = fake >> 5; + if (savegameinfo[slot].botskin-1 >= numskins + || !R_SkinUsable(-1, savegameinfo[slot].botskin-1)) + BADSAVE + CHECKPOS + savegameinfo[slot].numgameovers = READUINT8(save_p); // numgameovers + CHECKPOS + savegameinfo[slot].lives = READSINT8(save_p); // lives CHECKPOS (void)READINT32(save_p); // Score - - CHECKPOS - savegameinfo[slot].lives = READINT32(save_p); // lives CHECKPOS savegameinfo[slot].continues = READINT32(save_p); // continues - if (fake & (1<<10)) - { - CHECKPOS - savegameinfo[slot].botskin = READUINT8(save_p); - if (savegameinfo[slot].botskin-1 >= numskins) - savegameinfo[slot].botskin = 0; - CHECKPOS - savegameinfo[slot].botcolor = READUINT8(save_p); // because why not. - } - else - savegameinfo[slot].botskin = 0; - - if (savegameinfo[slot].botskin) - snprintf(savegameinfo[slot].playername, 36, "%s & %s", - skins[savegameinfo[slot].skinnum].realname, - skins[savegameinfo[slot].botskin-1].realname); - else - strcpy(savegameinfo[slot].playername, skins[savegameinfo[slot].skinnum].realname); - - savegameinfo[slot].playername[31] = 0; - // File end marker check CHECKPOS - if (READUINT8(save_p) != 0x1d) BADSAVE; + switch (READUINT8(save_p)) + { + case 0xb7: + { + UINT8 i, banksinuse; + CHECKPOS + banksinuse = READUINT8(save_p); + CHECKPOS + if (banksinuse > NUM_LUABANKS) + BADSAVE + for (i = 0; i < banksinuse; i++) + { + (void)READINT32(save_p); + CHECKPOS + } + if (READUINT8(save_p) != 0x1d) + BADSAVE + } + case 0x1d: + break; + default: + BADSAVE + } // done Z_Free(savebuffer); @@ -5310,23 +8529,61 @@ static void M_ReadSavegameInfo(UINT32 slot) static void M_ReadSaveStrings(void) { FILE *handle; - UINT32 i; + SINT8 i; char name[256]; + boolean nofile[MAXSAVEGAMES-1]; + SINT8 tolerance = 3; // empty slots at any time + UINT8 lastseen = 0; - for (i = 0; i < MAXSAVEGAMES; i++) + loadgamescroll = 0; + loadgameoffset = 14; + + for (i = 1; (i < MAXSAVEGAMES); i++) // slot 0 is no save { snprintf(name, sizeof name, savegamename, i); name[sizeof name - 1] = '\0'; handle = fopen(name, "rb"); - if (handle == NULL) + if ((nofile[i-1] = (handle == NULL))) + continue; + fclose(handle); + lastseen = i; + } + + if (savegameinfo) + Z_Free(savegameinfo); + savegameinfo = NULL; + + if (lastseen < saveSlotSelected) + lastseen = saveSlotSelected; + + i = lastseen; + + for (; (lastseen > 0 && tolerance); lastseen--) + { + if (nofile[lastseen-1]) + tolerance--; + } + + if ((i += tolerance+1) > MAXSAVEGAMES) // show 3 empty slots at minimum + i = MAXSAVEGAMES; + + numsaves = i; + savegameinfo = Z_Realloc(savegameinfo, numsaves*sizeof(saveinfo_t), PU_STATIC, NULL); + if (!savegameinfo) + I_Error("Insufficient memory to prepare save platter"); + + for (; i > 0; i--) + { + if (nofile[i-1] == true) { - savegameinfo[i].lives = -42; + savegameinfo[i-1].lives = -42; continue; } - fclose(handle); M_ReadSavegameInfo(i); } + + M_CacheLoadGameData(); } // @@ -5344,8 +8601,19 @@ static void M_SaveGameDeleteResponse(INT32 ch) name[sizeof name - 1] = '\0'; remove(name); - // Refresh savegame menu info - M_ReadSaveStrings(); + BwehHehHe(); + M_ReadSaveStrings(); // reload the menu +} + +static void M_SaveGameUltimateResponse(INT32 ch) +{ + if (ch != 'y' && ch != KEY_ENTER) + return; + + S_StartSound(NULL, sfx_menu1); + M_LoadSelect(saveSlotSelected); + SP_PlayerDef.prevMenu = MessageDef.prevMenu; + MessageDef.prevMenu = &SP_PlayerDef; } static void M_HandleLoadSave(INT32 choice) @@ -5354,26 +8622,46 @@ static void M_HandleLoadSave(INT32 choice) switch (choice) { - case KEY_DOWNARROW: - S_StartSound(NULL, sfx_menu1); + case KEY_RIGHTARROW: + S_StartSound(NULL, sfx_s3kb7); ++saveSlotSelected; - if (saveSlotSelected >= MAXSAVEGAMES) - saveSlotSelected -= MAXSAVEGAMES; - menumovedir = 1; + if (saveSlotSelected >= numsaves) + saveSlotSelected -= numsaves; + loadgamescroll = 90; break; - case KEY_UPARROW: - S_StartSound(NULL, sfx_menu1); + case KEY_LEFTARROW: + S_StartSound(NULL, sfx_s3kb7); --saveSlotSelected; if (saveSlotSelected < 0) - saveSlotSelected += MAXSAVEGAMES; - menumovedir = -1; + saveSlotSelected += numsaves; + loadgamescroll = -90; break; case KEY_ENTER: - S_StartSound(NULL, sfx_menu1); - if (savegameinfo[saveSlotSelected].lives != -666) // don't allow loading of "bad saves" + if (ultimate_selectable && saveSlotSelected == NOSAVESLOT) + { + loadgamescroll = 0; + S_StartSound(NULL, sfx_skid); + M_StartMessage("Are you sure you want to play\n\x85ultimate mode\x80? It isn't remotely fair,\nand you don't even get an emblem for it.\n\n(Press 'Y' to confirm)\n",M_SaveGameUltimateResponse,MM_YESNO); + } + else if (saveSlotSelected != NOSAVESLOT && savegameinfo[saveSlotSelected-1].lives == -42 && !(!modifiedgame || savemoddata)) + { + loadgamescroll = 0; + S_StartSound(NULL, sfx_skid); + M_StartMessage(M_GetText("This cannot be done in a modified game.\n\n(Press a key)\n"), NULL, MM_NOTHING); + } + else if (saveSlotSelected == NOSAVESLOT || savegameinfo[saveSlotSelected-1].lives != -666) // don't allow loading of "bad saves" + { + loadgamescroll = 0; + S_StartSound(NULL, sfx_menu1); M_LoadSelect(saveSlotSelected); + } + else if (!loadgameoffset) + { + S_StartSound(NULL, sfx_lose); + loadgameoffset = 14; + } break; case KEY_ESCAPE: @@ -5381,19 +8669,57 @@ static void M_HandleLoadSave(INT32 choice) break; case KEY_BACKSPACE: - S_StartSound(NULL, sfx_menu1); // Don't allow people to 'delete' "Play without Saving." // Nor allow people to 'delete' slots with no saves in them. - if (saveSlotSelected != NOSAVESLOT && savegameinfo[saveSlotSelected].lives != -42) - M_StartMessage(M_GetText("Are you sure you want to delete\nthis save game?\n\n(Press 'Y' to confirm)\n"),M_SaveGameDeleteResponse,MM_YESNO); + if (saveSlotSelected != NOSAVESLOT && savegameinfo[saveSlotSelected-1].lives != -42) + { + loadgamescroll = 0; + S_StartSound(NULL, sfx_skid); + M_StartMessage(va("Are you sure you want to delete\nsave file %d?\n\n(Press 'Y' to confirm)\n", saveSlotSelected),M_SaveGameDeleteResponse,MM_YESNO); + } + else if (!loadgameoffset) + { + if (saveSlotSelected == NOSAVESLOT && ultimate_selectable) + { + ultimate_selectable = false; + S_StartSound(NULL, sfx_strpst); + } + else + S_StartSound(NULL, sfx_lose); + loadgameoffset = 14; + } break; } if (exitmenu) { + // Is this a hack? + charseltimer = 0; if (currentMenu->prevMenu) M_SetupNextMenu(currentMenu->prevMenu); else M_ClearMenus(true); + Z_Free(savegameinfo); + savegameinfo = NULL; + } +} + +static void M_FirstTimeResponse(INT32 ch) +{ + S_StartSound(NULL, sfx_menu1); + + if (ch == KEY_ESCAPE) + return; + + if (ch != 'y' && ch != KEY_ENTER) + { + CV_SetValue(&cv_tutorialprompt, 0); + M_ReadSaveStrings(); + MessageDef.prevMenu = &SP_LoadDef; // calls M_SetupNextMenu + } + else + { + M_StartTutorial(0); + MessageDef.prevMenu = &MessageDef; // otherwise, the controls prompt won't fire } } @@ -5404,6 +8730,13 @@ static void M_LoadGame(INT32 choice) { (void)choice; + if (tutorialmap && cv_tutorialprompt.value) + { + M_StartMessage("Do you want to \x82play a brief Tutorial\x80?\n\nWe highly recommend this because \nthe controls are slightly different \nfrom other games.\n\nPress 'Y' or 'Enter' to go\nPress 'N' or any key to skip\n", + M_FirstTimeResponse, MM_YESNO); + return; + } + M_ReadSaveStrings(); M_SetupNextMenu(&SP_LoadDef); } @@ -5413,14 +8746,15 @@ static void M_LoadGame(INT32 choice) // void M_ForceSaveSlotSelected(INT32 sslot) { - // Already there? Out of bounds? Whatever, then! - if (sslot == saveSlotSelected || sslot >= MAXSAVEGAMES) + loadgameoffset = 14; + + // Already there? Whatever, then! + if (sslot == saveSlotSelected) return; - // Figure out whether to display up movement or down movement - menumovedir = (saveSlotSelected - sslot) > 0 ? -1 : 1; - if (abs(saveSlotSelected - sslot) > (MAXSAVEGAMES>>1)) - menumovedir *= -1; + loadgamescroll = 90; + if (saveSlotSelected <= numsaves/2) + loadgamescroll = -loadgamescroll; saveSlotSelected = sslot; } @@ -5429,200 +8763,479 @@ void M_ForceSaveSlotSelected(INT32 sslot) // CHARACTER SELECT // ================ +// lactozilla: sometimes the renderer changes and these patches don't exist anymore +static void M_CacheCharacterSelectEntry(INT32 i, INT32 skinnum) +{ + if (!(description[i].picname[0])) + { + if (skins[skinnum].sprites[SPR2_XTRA].numframes > XTRA_CHARSEL) + { + spritedef_t *sprdef = &skins[skinnum].sprites[SPR2_XTRA]; + spriteframe_t *sprframe = &sprdef->spriteframes[XTRA_CHARSEL]; + description[i].charpic = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + } + else + description[i].charpic = W_CachePatchName("MISSING", PU_PATCH); + } + else + description[i].charpic = W_CachePatchName(description[i].picname, PU_PATCH); + + if (description[i].nametag[0]) + description[i].namepic = W_CachePatchName(description[i].nametag, PU_PATCH); +} + +static void M_CacheCharacterSelect(void) +{ + INT32 i, skinnum; + + for (i = 0; i < 32; i++) + { + if (!description[i].used) + continue; + + // Already set in M_SetupChoosePlayer + skinnum = description[i].skinnum[0]; + if ((skinnum != -1) && (R_SkinUsable(-1, skinnum))) + M_CacheCharacterSelectEntry(i, skinnum); + } +} + static void M_SetupChoosePlayer(INT32 choice) { + INT32 skinnum; + UINT8 i; + UINT8 firstvalid = 255, lastvalid = 255; + boolean allowed = false; + char *and; (void)choice; - if (mapheaderinfo[startmap-1] && mapheaderinfo[startmap-1]->forcecharacter[0] != '\0') + if (!mapheaderinfo[startmap-1] || mapheaderinfo[startmap-1]->forcecharacter[0] == '\0') { - M_ChoosePlayer(0); //oh for crying out loud just get STARTED, it doesn't matter! + for (i = 0; i < 32; i++) // Handle charsels, availability, and unlocks. + { + if (description[i].used) // If the character's disabled through SOC, there's nothing we can do for it. + { + and = strchr(description[i].skinname, '&'); + if (and) + { + char firstskin[SKINNAMESIZE+1]; + if (mapheaderinfo[startmap-1]->typeoflevel & TOL_NIGHTS) // skip tagteam characters for NiGHTS levels + continue; + strncpy(firstskin, description[i].skinname, (and - description[i].skinname)); + firstskin[(and - description[i].skinname)] = '\0'; + description[i].skinnum[0] = R_SkinAvailable(firstskin); + description[i].skinnum[1] = R_SkinAvailable(and+1); + } + else + { + description[i].skinnum[0] = R_SkinAvailable(description[i].skinname); + description[i].skinnum[1] = -1; + } + skinnum = description[i].skinnum[0]; + if ((skinnum != -1) && (R_SkinUsable(-1, skinnum))) + { + // Handling order. + if (firstvalid == 255) + firstvalid = i; + else + { + description[i].prev = lastvalid; + description[lastvalid].next = i; + } + lastvalid = i; + + if (i == char_on) + allowed = true; + + M_CacheCharacterSelectEntry(i, skinnum); + } + // else -- Technically, character select icons without corresponding skins get bundled away behind this too. Sucks to be them. + } + } + } + + if (firstvalid == lastvalid) // We're being forced into a specific character, so might as well just skip it. + { + M_ChoosePlayer(firstvalid); return; } - if (Playing() == false) + // One last bit of order we can't do in the iteration above. + description[firstvalid].prev = lastvalid; + description[lastvalid].next = firstvalid; + + M_ChangeMenuMusic("_chsel", true); + + /* the menus suck -James */ + if (currentMenu == &SP_LoadDef)/* from save states */ { - S_StopMusic(); - S_ChangeMusicInternal("chrsel", true); + SP_PlayerDef.menuid = + MN_SP_MAIN + + ( MN_SP_LOAD << 6 ) + + ( MN_SP_PLAYER << 12 ); + } + else/* from Secret level select */ + { + SP_PlayerDef.menuid = + MN_SR_MAIN + + ( MN_SR_PLAYER << 6 ); } SP_PlayerDef.prevMenu = currentMenu; M_SetupNextMenu(&SP_PlayerDef); - char_scroll = itemOn*128*FRACUNIT; // finish scrolling the menu + if (!allowed) + { + char_on = firstvalid; + if (startchar > 0 && startchar < 32) + { + INT16 workchar = startchar; + while (workchar--) + char_on = description[char_on].next; + } + } + + // finish scrolling the menu + char_scroll = 0; + charseltimer = 0; + Z_Free(char_notes); - char_notes = NULL; + char_notes = V_WordWrap(0, 21*8, V_ALLOWLOWERCASE, description[char_on].notes); +} + +// +// M_HandleChoosePlayerMenu +// +// Reacts to your key inputs. Basically a mini menu thinker. +// +static void M_HandleChoosePlayerMenu(INT32 choice) +{ + boolean exitmenu = false; // exit to previous menu + INT32 selectval; + + if (keydown > 1) + return; + + switch (choice) + { + case KEY_DOWNARROW: + if ((selectval = description[char_on].next) != char_on) + { + S_StartSound(NULL,sfx_s3kb7); + char_on = selectval; + char_scroll = -charscrollamt; + Z_Free(char_notes); + char_notes = V_WordWrap(0, 21*8, V_ALLOWLOWERCASE, description[char_on].notes); + } + else if (!char_scroll) + { + S_StartSound(NULL,sfx_s3kb7); + char_scroll = 16*FRACUNIT; + } + break; + + case KEY_UPARROW: + if ((selectval = description[char_on].prev) != char_on) + { + S_StartSound(NULL,sfx_s3kb7); + char_on = selectval; + char_scroll = charscrollamt; + Z_Free(char_notes); + char_notes = V_WordWrap(0, 21*8, V_ALLOWLOWERCASE, description[char_on].notes); + } + else if (!char_scroll) + { + S_StartSound(NULL,sfx_s3kb7); + char_scroll = -16*FRACUNIT; + } + break; + + case KEY_ENTER: + S_StartSound(NULL, sfx_menu1); + M_ChoosePlayer(char_on); + break; + + case KEY_ESCAPE: + exitmenu = true; + break; + + default: + break; + } + + if (exitmenu) + { + // Is this a hack? + charseltimer = 0; + if (currentMenu->prevMenu) + M_SetupNextMenu(currentMenu->prevMenu); + else + M_ClearMenus(true); + } } // Draw the choose player setup menu, had some fun with player anim +//define CHOOSEPLAYER_DRAWHEADER + static void M_DrawSetupChoosePlayerMenu(void) { - const INT32 my = 24; - patch_t *patch; - INT32 i, o, j; - char *picname; + const INT32 my = 16; - // Black BG - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - //V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + skin_t *charskin = &skins[0]; + INT32 skinnum = 0; + UINT8 col; + UINT8 *colormap = NULL; + INT32 prev = -1, next = -1; - // Character select profile images!1 - M_DrawTextBox(0, my, 16, 20); + patch_t *charbg = W_CachePatchName("CHARBG", PU_PATCH); + patch_t *charfg = W_CachePatchName("CHARFG", PU_PATCH); + INT16 bgheight = SHORT(charbg->height); + INT16 fgheight = SHORT(charfg->height); + INT16 bgwidth = SHORT(charbg->width); + INT16 fgwidth = SHORT(charfg->width); + INT32 x, y; + INT32 w = (vid.width/vid.dupx); - if (abs(itemOn*128*FRACUNIT - char_scroll) > 256*FRACUNIT) - char_scroll = itemOn*128*FRACUNIT; - else if (itemOn*128*FRACUNIT - char_scroll > 128*FRACUNIT) - char_scroll += 48*FRACUNIT; - else if (itemOn*128*FRACUNIT - char_scroll < -128*FRACUNIT) - char_scroll -= 48*FRACUNIT; - else if (itemOn*128*FRACUNIT > char_scroll+16*FRACUNIT) - char_scroll += 16*FRACUNIT; - else if (itemOn*128*FRACUNIT < char_scroll-16*FRACUNIT) - char_scroll -= 16*FRACUNIT; + // lactozilla: the renderer changed so recache patches + if (needpatchrecache) + M_CacheCharacterSelect(); + + if (abs(char_scroll) > FRACUNIT) + char_scroll -= (char_scroll>>2); else // close enough. - char_scroll = itemOn*128*FRACUNIT; // just be exact now. - i = (char_scroll+16*FRACUNIT)/(128*FRACUNIT); - o = ((char_scroll/FRACUNIT)+16)%128; + char_scroll = 0; // just be exact now. - // prev character - if (i-1 >= 0 && PlayerMenu[i-1].status != IT_DISABLED - && o < 32) + // Get prev character... + prev = description[char_on].prev; + // If there's more than one character available... + if (prev != char_on) + // Let's get the next character now. + next = description[char_on].next; + else + // No there isn't. + prev = -1; + + // Find skin number from description[] + skinnum = description[char_on].skinnum[0]; + charskin = &skins[skinnum]; + + // Use the opposite of the character's skincolor + col = description[char_on].oppositecolor; + if (!col) + col = Color_Opposite[charskin->prefcolor - 1][0]; + + // Make the translation colormap + colormap = R_GetTranslationColormap(TC_DEFAULT, col, 0); + + // Don't render the title map + hidetitlemap = true; + charseltimer++; + + // Background and borders + V_DrawFill(0, 0, bgwidth, vid.height, V_SNAPTOTOP|colormap[101]); { - picname = description[i-1].picname; - if (picname[0] == '\0') - { - picname = strtok(Z_StrDup(description[i-1].skinname), "&"); - for (j = 0; j < numskins; j++) - if (stricmp(skins[j].name, picname) == 0) - { - Z_Free(picname); - picname = skins[j].charsel; - break; - } - if (j == numskins) // AAAAAAAAAA - picname = skins[0].charsel; - } - patch = W_CachePatchName(picname, PU_CACHE); - if (SHORT(patch->width) >= 256) - V_DrawCroppedPatch(8<height) - 64 + o*2, SHORT(patch->width), SHORT(patch->height)); - else - V_DrawCroppedPatch(8<height) - 32 + o, SHORT(patch->width), SHORT(patch->height)); - W_UnlockCachedPatch(patch); + INT32 sw = (BASEVIDWIDTH * vid.dupx); + INT32 bw = (vid.width - sw) / 2; + col = colormap[106]; + if (bw) + V_DrawFill(0, 0, bw, vid.height, V_NOSCALESTART|col); } - // next character - if (i+1 < currentMenu->numitems && PlayerMenu[i+1].status != IT_DISABLED - && o < 128) - { - picname = description[i+1].picname; - if (picname[0] == '\0') - { - picname = strtok(Z_StrDup(description[i+1].skinname), "&"); - for (j = 0; j < numskins; j++) - if (stricmp(skins[j].name, picname) == 0) - { - Z_Free(picname); - picname = skins[j].charsel; - break; - } - if (j == numskins) // AAAAAAAAAA - picname = skins[0].charsel; - } - patch = W_CachePatchName(picname, PU_CACHE); - if (SHORT(patch->width) >= 256) - V_DrawCroppedPatch(8<width), o*2); - else - V_DrawCroppedPatch(8<width), o); - W_UnlockCachedPatch(patch); - } + y = (charseltimer%32); + V_DrawMappedPatch(0, y-bgheight, V_SNAPTOTOP, charbg, colormap); + V_DrawMappedPatch(0, y, V_SNAPTOTOP, charbg, colormap); + V_DrawMappedPatch(0, y+bgheight, V_SNAPTOTOP, charbg, colormap); + V_DrawMappedPatch(0, -y, V_SNAPTOTOP, charfg, colormap); + V_DrawMappedPatch(0, -y+fgheight, V_SNAPTOTOP, charfg, colormap); + V_DrawFill(fgwidth, 0, vid.width, vid.height, V_SNAPTOTOP|colormap[106]); - // current character - if (i < currentMenu->numitems && PlayerMenu[i].status != IT_DISABLED) + // Character pictures { - picname = description[i].picname; - if (picname[0] == '\0') - { - picname = strtok(Z_StrDup(description[i].skinname), "&"); - for (j = 0; j < numskins; j++) - if (stricmp(skins[j].name, picname) == 0) - { - Z_Free(picname); - picname = skins[j].charsel; - break; - } - if (j == numskins) // AAAAAAAAAA - picname = skins[0].charsel; - } - patch = W_CachePatchName(picname, PU_CACHE); - if (o >= 0 && o <= 32) - { - if (SHORT(patch->width) >= 256) - V_DrawSmallScaledPatch(8, my + 40 - o, 0, patch); - else - V_DrawScaledPatch(8, my + 40 - o, 0, patch); - } - else - { - if (SHORT(patch->width) >= 256) - V_DrawCroppedPatch(8<width), SHORT(patch->height)); - else - V_DrawCroppedPatch(8<width), SHORT(patch->height)); - } - W_UnlockCachedPatch(patch); + x = 8; + y = (my+16) - FixedInt(char_scroll); + V_DrawScaledPatch(x, y, 0, description[char_on].charpic); + if (prev != -1) + V_DrawScaledPatch(x, y - 144, 0, description[prev].charpic); + if (next != -1) + V_DrawScaledPatch(x, y + 144, 0, description[next].charpic); } - // draw title (or big pic) - M_DrawMenuTitle(); - // Character description - M_DrawTextBox(136, my, 21, 20); - if (!char_notes) - char_notes = V_WordWrap(0, 21*8, V_ALLOWLOWERCASE, description[itemOn].notes); - V_DrawString(146, my + 9, V_RETURN8|V_ALLOWLOWERCASE, char_notes); + { + INT32 flags = V_ALLOWLOWERCASE|V_RETURN8; + x = 146; + y = my + 9; + V_DrawString(x, y, flags, char_notes); + } + + // Name tags + { + INT32 ox, oxsh = FixedInt(FixedMul(BASEVIDWIDTH*FRACUNIT, FixedDiv(char_scroll, 128*FRACUNIT))), txsh; + patch_t *curpatch = NULL, *prevpatch = NULL, *nextpatch = NULL; + const char *curtext = NULL, *prevtext = NULL, *nexttext = NULL; + UINT8 curtextcolor = 0, prevtextcolor = 0, nexttextcolor = 0; + UINT8 curoutlinecolor = 0, prevoutlinecolor = 0, nextoutlinecolor = 0; + + // Name tag + curtext = description[char_on].displayname; + curtextcolor = description[char_on].tagtextcolor; + curoutlinecolor = description[char_on].tagoutlinecolor; + if (curtext[0] == '\0') + curpatch = description[char_on].namepic; + if (!curtextcolor) + curtextcolor = charskin->prefcolor; + if (!curoutlinecolor) + curoutlinecolor = Color_Opposite[charskin->prefcolor - 1][0]; + + txsh = oxsh; + ox = 8 + SHORT((description[char_on].charpic)->width)/2; + y = my + 144; + + // cur + { + x = ox - txsh; + if (curpatch) + x -= (SHORT(curpatch->width)/2); + + if (curtext[0] != '\0') + { + V_DrawNameTag( + x, y, V_CENTERNAMETAG, FRACUNIT, + R_GetTranslationColormap(TC_DEFAULT, curtextcolor, 0), + R_GetTranslationColormap(TC_DEFAULT, curoutlinecolor, 0), + curtext + ); + } + else if (curpatch) + V_DrawScaledPatch(x, y, 0, curpatch); + } + + if (char_scroll) + { + // prev + if ((prev != -1) && char_scroll < 0) + { + prevtext = description[prev].displayname; + prevtextcolor = description[prev].tagtextcolor; + prevoutlinecolor = description[prev].tagoutlinecolor; + if (prevtext[0] == '\0') + prevpatch = description[prev].namepic; + charskin = &skins[description[prev].skinnum[0]]; + if (!prevtextcolor) + prevtextcolor = charskin->prefcolor; + if (!prevoutlinecolor) + prevoutlinecolor = Color_Opposite[charskin->prefcolor - 1][0]; + + x = (ox - txsh) - w; + if (prevpatch) + x -= (SHORT(prevpatch->width)/2); + + if (prevtext[0] != '\0') + { + V_DrawNameTag( + x, y, V_CENTERNAMETAG, FRACUNIT, + R_GetTranslationColormap(TC_DEFAULT, prevtextcolor, 0), + R_GetTranslationColormap(TC_DEFAULT, prevoutlinecolor, 0), + prevtext + ); + } + else if (prevpatch) + V_DrawScaledPatch(x, y, 0, prevpatch); + } + // next + else if ((next != -1) && char_scroll > 0) + { + nexttext = description[next].displayname; + nexttextcolor = description[next].tagtextcolor; + nextoutlinecolor = description[next].tagoutlinecolor; + if (nexttext[0] == '\0') + nextpatch = description[next].namepic; + charskin = &skins[description[next].skinnum[0]]; + if (!nexttextcolor) + nexttextcolor = charskin->prefcolor; + if (!nextoutlinecolor) + nextoutlinecolor = Color_Opposite[charskin->prefcolor - 1][0]; + + x = (ox - txsh) + w; + if (nextpatch) + x -= (SHORT(nextpatch->width)/2); + + if (nexttext[0] != '\0') + { + V_DrawNameTag( + x, y, V_CENTERNAMETAG, FRACUNIT, + R_GetTranslationColormap(TC_DEFAULT, nexttextcolor, 0), + R_GetTranslationColormap(TC_DEFAULT, nextoutlinecolor, 0), + nexttext + ); + } + else if (nextpatch) + V_DrawScaledPatch(x, y, 0, nextpatch); + } + } + } + + // Alternative menu header +#ifdef CHOOSEPLAYER_DRAWHEADER + { + patch_t *header = W_CachePatchName("M_PICKP", PU_PATCH); + INT32 xtitle = 146; + INT32 ytitle = (35 - SHORT(header->height))/2; + V_DrawFixedPatch(xtitle<forcecharacter[0] == '\0') + // skip this if forcecharacter or no characters available + if (choice == 255) { - // M_SetupChoosePlayer didn't call us directly, that means we've been properly set up. - char_scroll = itemOn*128*FRACUNIT; // finish scrolling the menu - M_DrawSetupChoosePlayerMenu(); // draw the finally selected character one last time for the fadeout + skinnum = botskin = 0; + botingame = false; } + // M_SetupChoosePlayer didn't call us directly, that means we've been properly set up. + else + { + char_scroll = 0; // finish scrolling the menu + M_DrawSetupChoosePlayerMenu(); // draw the finally selected character one last time for the fadeout + // Is this a hack? + charseltimer = 0; + + skinnum = description[choice].skinnum[0]; + + if ((botingame = (description[choice].skinnum[1] != -1))) { + // this character has a second skin + botskin = (UINT8)(description[choice].skinnum[1]+1); + botcolor = skins[description[choice].skinnum[1]].prefcolor; + } + else + botskin = botcolor = 0; + } + M_ClearMenus(true); - skin1 = strtok(description[choice].skinname, "&"); - skin2 = strtok(NULL, "&"); - - if (skin2) { - // this character has a second skin - skinnum = R_SkinAvailable(skin1); - botskin = (UINT8)(R_SkinAvailable(skin2)+1); - botingame = true; - - botcolor = skins[botskin-1].prefcolor; - - // undo the strtok - description[choice].skinname[strlen(skin1)] = '&'; - } else { - skinnum = R_SkinAvailable(description[choice].skinname); - botingame = false; - botskin = 0; - botcolor = 0; - } - if (startmap != spstage_start) - cursaveslot = -1; + cursaveslot = 0; - lastmapsaved = 0; + //lastmapsaved = 0; gamecomplete = false; - G_DeferedInitNew(ultmode, G_BuildMapName(startmap), (UINT8)skinnum, false, fromlevelselect); + G_DeferedInitNew(ultmode, G_BuildMapName(startmap), skinnum, false, fromlevelselect); COM_BufAddText("dummyconsvar 1\n"); // G_DeferedInitNew doesn't do this + + if (levelselect.rows) + Z_Free(levelselect.rows); + levelselect.rows = NULL; + + if (savegameinfo) + Z_Free(savegameinfo); + savegameinfo = NULL; } // =============== @@ -5649,29 +9262,30 @@ static void M_Statistics(INT32 choice) if (!(mapheaderinfo[i]->typeoflevel & TOL_SP) || (mapheaderinfo[i]->menuflags & LF2_HIDEINSTATS)) continue; - if (!mapvisited[i]) + if (!(mapvisited[i] & MV_MAX)) continue; statsMapList[j++] = i; } statsMapList[j] = -1; - statsMax = j - 13 + numextraemblems; + statsMax = j - 11 + numextraemblems; statsLocation = 0; if (statsMax < 0) statsMax = 0; - M_SetupNextMenu(&SP_GameStatsDef); + M_SetupNextMenu(&SP_LevelStatsDef); } static void M_DrawStatsMaps(int location) { - INT32 y = 76, i = -1; + INT32 y = 80, i = -1; INT16 mnum; extraemblem_t *exemblem; + boolean dotopname = true, dobottomarrow = (location < statsMax); - V_DrawString(20, y-12, 0, "LEVEL NAME"); - V_DrawString(248, y-12, 0, "EMBLEMS"); + if (location) + V_DrawString(10, y-(skullAnimCounter/5), V_YELLOWMAP, "\x1A"); while (statsMapList[++i] != -1) { @@ -5680,59 +9294,154 @@ static void M_DrawStatsMaps(int location) --location; continue; } + else if (dotopname) + { + V_DrawString(20, y, V_GREENMAP, "LEVEL NAME"); + V_DrawString(248, y, V_GREENMAP, "EMBLEMS"); + y += 8; + dotopname = false; + } mnum = statsMapList[i]; M_DrawMapEmblems(mnum+1, 292, y); if (mapheaderinfo[mnum]->actnum != 0) - V_DrawString(20, y, V_YELLOWMAP, va("%s %d", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->actnum)); + V_DrawString(20, y, V_YELLOWMAP|V_ALLOWLOWERCASE, va("%s %d", mapheaderinfo[mnum]->lvlttl, mapheaderinfo[mnum]->actnum)); else - V_DrawString(20, y, V_YELLOWMAP, mapheaderinfo[mnum]->lvlttl); + V_DrawString(20, y, V_YELLOWMAP|V_ALLOWLOWERCASE, mapheaderinfo[mnum]->lvlttl); y += 8; if (y >= BASEVIDHEIGHT-8) - return; + goto bottomarrow; } + if (dotopname && !location) + { + V_DrawString(20, y, V_GREENMAP, "LEVEL NAME"); + V_DrawString(248, y, V_GREENMAP, "EMBLEMS"); + y += 8; + } + else if (location) + --location; // Extra Emblems for (i = -2; i < numextraemblems; ++i) { + if (i == -1) + { + V_DrawString(20, y, V_GREENMAP, "EXTRA EMBLEMS"); + if (location) + { + y += 8; + location++; + } + } if (location) { --location; continue; } - if (i == -1) - V_DrawString(20, y, V_GREENMAP, "EXTRA EMBLEMS"); - else if (i >= 0) + if (i >= 0) { exemblem = &extraemblems[i]; if (exemblem->collected) - V_DrawSmallMappedPatch(292, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem), PU_CACHE), + V_DrawSmallMappedPatch(292, y, 0, W_CachePatchName(M_GetExtraEmblemPatch(exemblem, false), PU_PATCH), R_GetTranslationColormap(TC_DEFAULT, M_GetExtraEmblemColor(exemblem), GTC_CACHE)); else - V_DrawSmallScaledPatch(292, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawSmallScaledPatch(292, y, 0, W_CachePatchName("NEEDIT", PU_PATCH)); - V_DrawString(20, y, V_YELLOWMAP, va("%s", exemblem->description)); + V_DrawString(20, y, V_YELLOWMAP|V_ALLOWLOWERCASE, + (!exemblem->collected && exemblem->showconditionset && !M_Achieved(exemblem->showconditionset)) + ? M_CreateSecretMenuOption(exemblem->description) + : exemblem->description); } y += 8; if (y >= BASEVIDHEIGHT-8) - return; + goto bottomarrow; } +bottomarrow: + if (dobottomarrow) + V_DrawString(10, y-8 + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); } static void M_DrawLevelStats(void) { - M_DrawMenuTitle(); - V_DrawCenteredString(BASEVIDWIDTH/2, 24, V_YELLOWMAP, "PAGE 2 OF 2"); + char beststr[40]; - V_DrawString(72, 48, 0, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); - V_DrawScaledPatch(40, 48-4, 0, W_CachePatchName("EMBLICON", PU_STATIC)); + tic_t besttime = 0; + UINT32 bestscore = 0; + UINT32 bestrings = 0; + + INT32 i; + INT32 mapsunfinished = 0; + boolean bestunfinished[3] = {false, false, false}; + + M_DrawMenuTitle(); + + V_DrawString(20, 24, V_YELLOWMAP, "Total Play Time:"); + V_DrawCenteredString(BASEVIDWIDTH/2, 32, 0, va("%i hours, %i minutes, %i seconds", + G_TicsToHours(totalplaytime), + G_TicsToMinutes(totalplaytime, false), + G_TicsToSeconds(totalplaytime))); + + for (i = 0; i < NUMMAPS; i++) + { + boolean mapunfinished = false; + + if (!mapheaderinfo[i] || !(mapheaderinfo[i]->menuflags & LF2_RECORDATTACK)) + continue; + + if (!mainrecords[i]) + { + mapsunfinished++; + bestunfinished[0] = bestunfinished[1] = bestunfinished[2] = true; + continue; + } + + if (mainrecords[i]->score > 0) + bestscore += mainrecords[i]->score; + else + mapunfinished = bestunfinished[0] = true; + + if (mainrecords[i]->time > 0) + besttime += mainrecords[i]->time; + else + mapunfinished = bestunfinished[1] = true; + + if (mainrecords[i]->rings > 0) + bestrings += mainrecords[i]->rings; + else + mapunfinished = bestunfinished[2] = true; + + if (mapunfinished) + mapsunfinished++; + } + + V_DrawString(20, 48, 0, "Combined records:"); + + if (mapsunfinished) + V_DrawString(20, 56, V_REDMAP, va("(%d unfinished)", mapsunfinished)); + else + V_DrawString(20, 56, V_GREENMAP, "(complete)"); + + V_DrawString(36, 64, 0, va("x %d/%d", M_CountEmblems(), numemblems+numextraemblems)); + V_DrawSmallScaledPatch(20, 64, 0, W_CachePatchName("EMBLICON", PU_PATCH)); + + sprintf(beststr, "%u", bestscore); + V_DrawString(BASEVIDWIDTH/2, 48, V_YELLOWMAP, "SCORE:"); + V_DrawRightAlignedString(BASEVIDWIDTH-16, 48, (bestunfinished[0] ? V_REDMAP : 0), beststr); + + sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); + V_DrawString(BASEVIDWIDTH/2, 56, V_YELLOWMAP, "TIME:"); + V_DrawRightAlignedString(BASEVIDWIDTH-16, 56, (bestunfinished[1] ? V_REDMAP : 0), beststr); + + sprintf(beststr, "%u", bestrings); + V_DrawString(BASEVIDWIDTH/2, 64, V_YELLOWMAP, "RINGS:"); + V_DrawRightAlignedString(BASEVIDWIDTH-16, 64, (bestunfinished[2] ? V_REDMAP : 0), beststr); M_DrawStatsMaps(statsLocation); } @@ -5756,120 +9465,19 @@ static void M_HandleLevelStats(INT32 choice) --statsLocation; break; - case KEY_RIGHTARROW: + case KEY_PGDN: S_StartSound(NULL, sfx_menu1); - statsLocation += (statsLocation+15 >= statsMax) ? statsMax-statsLocation : 15; + statsLocation += (statsLocation+13 >= statsMax) ? statsMax-statsLocation : 13; break; - case KEY_LEFTARROW: + case KEY_PGUP: S_StartSound(NULL, sfx_menu1); - statsLocation -= (statsLocation < 15) ? statsLocation : 15; + statsLocation -= (statsLocation < 13) ? statsLocation : 13; break; case KEY_ESCAPE: exitmenu = true; break; - - case KEY_ENTER: - S_StartSound(NULL, sfx_menu1); - M_SetupNextMenu(&SP_GameStatsDef); - break; - } - if (exitmenu) - { - if (currentMenu->prevMenu) - M_SetupNextMenu(currentMenu->prevMenu); - else - M_ClearMenus(true); - } -} - -// Handle GAME statistics. -static void M_DrawGameStats(void) -{ - char beststr[40]; - - tic_t besttime = 0; - UINT32 bestscore = 0; - UINT32 bestrings = 0; - - INT32 i; - INT32 mapsunfinished[3] = {0, 0, 0}; - - M_DrawMenuTitle(); - V_DrawCenteredString(BASEVIDWIDTH/2, 24, V_YELLOWMAP, "PAGE 1 OF 2"); - - V_DrawString(32, 60, V_YELLOWMAP, "Total Play Time:"); - V_DrawRightAlignedString(BASEVIDWIDTH-32, 70, 0, va("%i hours, %i minutes, %i seconds", - G_TicsToHours(totalplaytime), - G_TicsToMinutes(totalplaytime, false), - G_TicsToSeconds(totalplaytime))); - - for (i = 0; i < NUMMAPS; i++) - { - if (!mapheaderinfo[i] || !(mapheaderinfo[i]->menuflags & LF2_RECORDATTACK)) - continue; - - if (!mainrecords[i]) - { - mapsunfinished[0]++; - mapsunfinished[1]++; - mapsunfinished[2]++; - continue; - } - - if (mainrecords[i]->score > 0) - bestscore += mainrecords[i]->score; - else - mapsunfinished[0]++; - - if (mainrecords[i]->time > 0) - besttime += mainrecords[i]->time; - else - mapsunfinished[1]++; - - if (mainrecords[i]->rings > 0) - bestrings += mainrecords[i]->rings; - else - mapsunfinished[2]++; - - } - - V_DrawCenteredString(BASEVIDWIDTH/2, 90, 0, "* COMBINED RECORDS *"); - - sprintf(beststr, "%u", bestscore); - V_DrawString(32, 100, V_YELLOWMAP, "SCORE:"); - V_DrawRightAlignedString(BASEVIDWIDTH-32, 100, 0, beststr); - if (mapsunfinished[0]) - V_DrawRightAlignedString(BASEVIDWIDTH-32, 108, V_REDMAP, va("(%d unfinished)", mapsunfinished[0])); - - sprintf(beststr, "%i:%02i:%02i.%02i", G_TicsToHours(besttime), G_TicsToMinutes(besttime, false), G_TicsToSeconds(besttime), G_TicsToCentiseconds(besttime)); - V_DrawString(32, 120, V_YELLOWMAP, "TIME:"); - V_DrawRightAlignedString(BASEVIDWIDTH-32, 120, 0, beststr); - if (mapsunfinished[1]) - V_DrawRightAlignedString(BASEVIDWIDTH-32, 128, V_REDMAP, va("(%d unfinished)", mapsunfinished[1])); - - sprintf(beststr, "%u", bestrings); - V_DrawString(32, 140, V_YELLOWMAP, "RINGS:"); - V_DrawRightAlignedString(BASEVIDWIDTH-32, 140, 0, beststr); - if (mapsunfinished[2]) - V_DrawRightAlignedString(BASEVIDWIDTH-32, 148, V_REDMAP, va("(%d unfinished)", mapsunfinished[2])); -} - -static void M_HandleGameStats(INT32 choice) -{ - boolean exitmenu = false; // exit to previous menu - - switch (choice) - { - case KEY_ESCAPE: - exitmenu = true; - break; - - case KEY_ENTER: - S_StartSound(NULL, sfx_menu1); - M_SetupNextMenu(&SP_LevelStatsDef); - break; } if (exitmenu) { @@ -5887,15 +9495,29 @@ static void M_HandleGameStats(INT32 choice) // Drawing function for Time Attack void M_DrawTimeAttackMenu(void) { - INT32 i, x, y, cursory = 0; + INT32 i, x, y, empatx, empaty, cursory = 0; UINT16 dispstatus; - patch_t *PictureOfLevel, *PictureOfUrFace; - lumpnum_t lumpnum; - char beststr[40]; + patch_t *PictureOfUrFace; // my WHAT + patch_t *empatch; - S_ChangeMusicInternal("racent", true); // Eww, but needed for when user hits escape during demo playback + M_SetMenuCurBackground("RECATKBG"); - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + curbgxspeed = 0; + curbgyspeed = 18; + + M_ChangeMenuMusic("_recat", true); // Eww, but needed for when user hits escape during demo playback + + if (curbgcolor >= 0) + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, curbgcolor); + else if (!curbghide || !titlemapinaction) + { + F_SkyScroll(curbgxspeed, curbgyspeed, curbgname); + // Draw and animate foreground + if (!strncmp("RECATKBG", curbgname, 8)) + M_DrawRecordAttackForeground(); + } + if (curfadevalue) + V_DrawFadeScreen(0xFF00, curfadevalue); M_DrawMenuTitle(); @@ -5928,27 +9550,31 @@ void M_DrawTimeAttackMenu(void) // Should see nothing but strings V_DrawString(BASEVIDWIDTH - x - soffset - V_StringWidth(cv->string, 0), y, V_YELLOWMAP, cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - soffset - 10 - V_StringWidth(cv->string, 0) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x - soffset + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } } } // DRAW THE SKULL CURSOR - V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); + V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_PATCH)); V_DrawString(currentMenu->x, cursory, V_YELLOWMAP, currentMenu->menuitems[itemOn].text); - // A 160x100 image of the level as entry MAPxxP - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); - - if (lumpnum != LUMPERROR) - PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_CACHE); - else - PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE); - - V_DrawSmallScaledPatch(208, 32, 0, PictureOfLevel); - // Character face! - if (W_CheckNumForName(skins[cv_chooseskin.value-1].charsel) != LUMPERROR) { - PictureOfUrFace = W_CachePatchName(skins[cv_chooseskin.value-1].charsel, PU_CACHE); + if (skins[cv_chooseskin.value-1].sprites[SPR2_XTRA].numframes > XTRA_CHARSEL) + { + spritedef_t *sprdef = &skins[cv_chooseskin.value-1].sprites[SPR2_XTRA]; + spriteframe_t *sprframe = &sprdef->spriteframes[XTRA_CHARSEL]; + PictureOfUrFace = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + } + else + PictureOfUrFace = W_CachePatchName("MISSING", PU_PATCH); + if (PictureOfUrFace->width >= 256) V_DrawTinyScaledPatch(224, 120, 0, PictureOfUrFace); else @@ -5960,16 +9586,91 @@ void M_DrawTimeAttackMenu(void) { emblem_t *em; INT32 yHeight; + patch_t *PictureOfLevel; + lumpnum_t lumpnum; + char beststr[40]; + char reqscore[40], reqtime[40], reqrings[40]; - V_DrawCenteredString(104, 32, 0, "* LEVEL RECORDS *"); + strcpy(reqscore, "\0"); + strcpy(reqtime, "\0"); + strcpy(reqrings, "\0"); + + M_DrawLevelPlatterHeader(32-lsheadingheight/2, cv_nextmap.string, true, false); + + // A 160x100 image of the level as entry MAPxxP + lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + + if (lumpnum != LUMPERROR) + PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_PATCH); + else + PictureOfLevel = W_CachePatchName("BLANKLVL", PU_PATCH); + + y = 32+lsheadingheight; + V_DrawSmallScaledPatch(216, y, 0, PictureOfLevel); + + + if (currentMenu == &SP_TimeAttackDef) + { + if (itemOn == talevel) + { + /* Draw arrows !! */ + y = y + 25 - 4; + V_DrawCharacter(216 - 10 - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(216 + 80 + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + // Draw press ESC to exit string on main record attack menu + V_DrawString(104-72, 180, V_TRANSLUCENT, M_GetText("Press ESC to exit")); + } + + em = M_GetLevelEmblems(cv_nextmap.value); + // Draw record emblems. + while (em) + { + switch (em->type) + { + case ET_SCORE: + yHeight = 33; + sprintf(reqscore, "(%u)", em->var); + break; + case ET_TIME: + yHeight = 53; + sprintf(reqtime, "(%i:%02i.%02i)", G_TicsToMinutes((tic_t)em->var, true), + G_TicsToSeconds((tic_t)em->var), + G_TicsToCentiseconds((tic_t)em->var)); + break; + case ET_RINGS: + yHeight = 73; + sprintf(reqrings, "(%u)", em->var); + break; + default: + goto skipThisOne; + } + + empatch = W_CachePatchName(M_GetEmblemPatch(em, true), PU_PATCH); + + empatx = SHORT(empatch->leftoffset)/2; + empaty = SHORT(empatch->topoffset)/2; + + if (em->collected) + V_DrawSmallMappedPatch(104+76+empatx, yHeight+lsheadingheight/2+empaty, 0, empatch, + R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE)); + else + V_DrawSmallScaledPatch(104+76, yHeight+lsheadingheight/2, 0, W_CachePatchName("NEEDITL", PU_PATCH)); + + skipThisOne: + em = M_GetLevelEmblems(-1); + } if (!mainrecords[cv_nextmap.value-1] || !mainrecords[cv_nextmap.value-1]->score) sprintf(beststr, "(none)"); else sprintf(beststr, "%u", mainrecords[cv_nextmap.value-1]->score); - V_DrawString(104-72, 48, V_YELLOWMAP, "SCORE:"); - V_DrawRightAlignedString(104+72, 48, V_ALLOWLOWERCASE, beststr); + V_DrawString(104-72, 33+lsheadingheight/2, V_YELLOWMAP, "SCORE:"); + V_DrawRightAlignedString(104+64, 33+lsheadingheight/2, V_ALLOWLOWERCASE, beststr); + V_DrawRightAlignedString(104+72, 43+lsheadingheight/2, V_ALLOWLOWERCASE, reqscore); if (!mainrecords[cv_nextmap.value-1] || !mainrecords[cv_nextmap.value-1]->time) sprintf(beststr, "(none)"); @@ -5978,42 +9679,23 @@ void M_DrawTimeAttackMenu(void) G_TicsToSeconds(mainrecords[cv_nextmap.value-1]->time), G_TicsToCentiseconds(mainrecords[cv_nextmap.value-1]->time)); - V_DrawString(104-72, 58, V_YELLOWMAP, "TIME:"); - V_DrawRightAlignedString(104+72, 58, V_ALLOWLOWERCASE, beststr); + V_DrawString(104-72, 53+lsheadingheight/2, V_YELLOWMAP, "TIME:"); + V_DrawRightAlignedString(104+64, 53+lsheadingheight/2, V_ALLOWLOWERCASE, beststr); + V_DrawRightAlignedString(104+72, 63+lsheadingheight/2, V_ALLOWLOWERCASE, reqtime); if (!mainrecords[cv_nextmap.value-1] || !mainrecords[cv_nextmap.value-1]->rings) sprintf(beststr, "(none)"); else sprintf(beststr, "%hu", mainrecords[cv_nextmap.value-1]->rings); - V_DrawString(104-72, 68, V_YELLOWMAP, "RINGS:"); - V_DrawRightAlignedString(104+72, 68, V_ALLOWLOWERCASE, beststr); + V_DrawString(104-72, 73+lsheadingheight/2, V_YELLOWMAP, "RINGS:"); - // Draw record emblems. - em = M_GetLevelEmblems(cv_nextmap.value); - while (em) - { - switch (em->type) - { - case ET_SCORE: yHeight = 48; break; - case ET_TIME: yHeight = 58; break; - case ET_RINGS: yHeight = 68; break; - default: - goto skipThisOne; - } + V_DrawRightAlignedString(104+64, 73+lsheadingheight/2, V_ALLOWLOWERCASE|((mapvisited[cv_nextmap.value-1] & MV_PERFECTRA) ? V_YELLOWMAP : 0), beststr); - if (em->collected) - V_DrawSmallMappedPatch(104+76, yHeight, 0, W_CachePatchName(M_GetEmblemPatch(em), PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE)); - else - V_DrawSmallScaledPatch(104+76, yHeight, 0, W_CachePatchName("NEEDIT", PU_CACHE)); - - skipThisOne: - em = M_GetLevelEmblems(-1); - } + V_DrawRightAlignedString(104+72, 83+lsheadingheight/2, V_ALLOWLOWERCASE, reqrings); } - // ALWAYS DRAW level name and skin even when not on this menu! + // ALWAYS DRAW level and skin even when not on this menu! if (currentMenu != &SP_TimeAttackDef) { consvar_t *ncv; @@ -6021,27 +9703,66 @@ void M_DrawTimeAttackMenu(void) x = SP_TimeAttackDef.x; y = SP_TimeAttackDef.y; - for (i = 0; i < 2; ++i) - { - ncv = (consvar_t *)SP_TimeAttackMenu[i].itemaction; + V_DrawString(x, y + SP_TimeAttackMenu[talevel].alphaKey, V_TRANSLUCENT, SP_TimeAttackMenu[talevel].text); - V_DrawString(x, y + SP_TimeAttackMenu[i].alphaKey, V_TRANSLUCENT, SP_TimeAttackMenu[i].text); - V_DrawString(BASEVIDWIDTH - x - V_StringWidth(ncv->string, 0), - y + SP_TimeAttackMenu[i].alphaKey, V_YELLOWMAP|V_TRANSLUCENT, ncv->string); - } + ncv = (consvar_t *)SP_TimeAttackMenu[taplayer].itemaction; + V_DrawString(x, y + SP_TimeAttackMenu[taplayer].alphaKey, V_TRANSLUCENT, SP_TimeAttackMenu[taplayer].text); + V_DrawString(BASEVIDWIDTH - x - V_StringWidth(ncv->string, 0), y + SP_TimeAttackMenu[taplayer].alphaKey, V_YELLOWMAP|V_TRANSLUCENT, ncv->string); } } +static void M_HandleTimeAttackLevelSelect(INT32 choice) +{ + switch (choice) + { + case KEY_DOWNARROW: + M_NextOpt(); + break; + case KEY_UPARROW: + M_PrevOpt(); + break; + + case KEY_LEFTARROW: + CV_AddValue(&cv_nextmap, -1); + break; + case KEY_RIGHTARROW: + CV_AddValue(&cv_nextmap, 1); + break; + + case KEY_ENTER: + if (levellistmode == LLM_NIGHTSATTACK) + M_NightsAttackLevelSelect(0); + else + M_TimeAttackLevelSelect(0); + break; + + case KEY_ESCAPE: + noFurtherInput = true; + M_GoBack(0); + return; + + default: + return; + } + S_StartSound(NULL, sfx_menu1); +} + +static void M_TimeAttackLevelSelect(INT32 choice) +{ + (void)choice; + SP_TimeAttackLevelSelectDef.prevMenu = currentMenu; + M_SetupNextMenu(&SP_TimeAttackLevelSelectDef); +} + // Going to Time Attack menu... static void M_TimeAttack(INT32 choice) { (void)choice; - memset(skins_cons_t, 0, sizeof (skins_cons_t)); - + SP_TimeAttackDef.prevMenu = &MainDef; levellistmode = LLM_RECORDATTACK; // Don't be dependent on cv_newgametype - if (M_CountLevelsToShowInList() == 0) + if (!M_PrepareLevelPlatter(-1, true)) { M_StartMessage(M_GetText("No record-attackable levels found.\n"),NULL,MM_NOTHING); return; @@ -6049,119 +9770,192 @@ static void M_TimeAttack(INT32 choice) M_PatchSkinNameTable(); - M_PrepareLevelSelect(); + G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please M_SetupNextMenu(&SP_TimeAttackDef); - Nextmap_OnChange(); + if (!M_CanShowLevelInList(cv_nextmap.value-1, -1) && levelselect.rows[0].maplist[0]) + CV_SetValue(&cv_nextmap, levelselect.rows[0].maplist[0]); + else + Nextmap_OnChange(); itemOn = tastart; // "Start" is selected. - - G_SetGamestate(GS_TIMEATTACK); - S_ChangeMusicInternal("racent", true); } // Drawing function for Nights Attack void M_DrawNightsAttackMenu(void) { - patch_t *PictureOfLevel; - lumpnum_t lumpnum; - char beststr[40]; + INT32 i, x, y, cursory = 0; + UINT16 dispstatus; - S_ChangeMusicInternal("racent", true); // Eww, but needed for when user hits escape during demo playback + M_SetMenuCurBackground("NTSATKBG"); - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); + M_ChangeMenuMusic("_nitat", true); // Eww, but needed for when user hits escape during demo playback + + M_DrawNightsAttackBackground(); + if (curfadevalue) + V_DrawFadeScreen(0xFF00, curfadevalue); + + M_DrawMenuTitle(); // draw menu (everything else goes on top of it) - M_DrawGenericMenu(); + // Sadly we can't just use generic mode menus because we need some extra hacks + x = currentMenu->x; + y = currentMenu->y; - // A 160x100 image of the level as entry MAPxxP - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + for (i = 0; i < currentMenu->numitems; ++i) + { + dispstatus = (currentMenu->menuitems[i].status & IT_DISPLAY); + if (dispstatus != IT_STRING && dispstatus != IT_WHITESTRING) + continue; - if (lumpnum != LUMPERROR) - PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_CACHE); - else - PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE); + y = currentMenu->y+currentMenu->menuitems[i].alphaKey; + if (i == itemOn) + cursory = y; - V_DrawSmallScaledPatch(90, 28, 0, PictureOfLevel); + V_DrawString(x, y, (dispstatus == IT_WHITESTRING) ? V_YELLOWMAP : 0 , currentMenu->menuitems[i].text); + + // Cvar specific handling + if ((currentMenu->menuitems[i].status & IT_TYPE) == IT_CVAR) + { + consvar_t *cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + INT32 soffset = 0; + + // hack to keep the menu from overlapping the overall grade icon + if (currentMenu != &SP_NightsAttackDef) + soffset = 80; + + // Should see nothing but strings + V_DrawString(BASEVIDWIDTH - x - soffset - V_StringWidth(cv->string, 0), y, V_YELLOWMAP, cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - soffset - 10 - V_StringWidth(cv->string, 0) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x - soffset + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + } + } + + // DRAW THE SKULL CURSOR + V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, W_CachePatchName("M_CURSOR", PU_PATCH)); + V_DrawString(currentMenu->x, cursory, V_YELLOWMAP, currentMenu->menuitems[itemOn].text); // Level record list if (cv_nextmap.value) { emblem_t *em; INT32 yHeight; + INT32 xpos; + patch_t *PictureOfLevel; + lumpnum_t lumpnum; + char beststr[40]; - UINT8 bestoverall = G_GetBestNightsGrade(cv_nextmap.value, 0); + //UINT8 bestoverall = G_GetBestNightsGrade(cv_nextmap.value, 0); UINT8 bestgrade = G_GetBestNightsGrade(cv_nextmap.value, cv_dummymares.value); UINT32 bestscore = G_GetBestNightsScore(cv_nextmap.value, cv_dummymares.value); tic_t besttime = G_GetBestNightsTime(cv_nextmap.value, cv_dummymares.value); - if (P_HasGrades(cv_nextmap.value, 0)) - V_DrawScaledPatch(200, 28 + 8, 0, ngradeletters[bestoverall]); + M_DrawLevelPlatterHeader(32-lsheadingheight/2, cv_nextmap.string, true, false); + // A 160x100 image of the level as entry MAPxxP + lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + + if (lumpnum != LUMPERROR) + PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_PATCH); + else + PictureOfLevel = W_CachePatchName("BLANKLVL", PU_PATCH); + + y = 32+lsheadingheight; + V_DrawSmallScaledPatch(208, y, 0, PictureOfLevel); + + // Draw press ESC to exit string on main nights attack menu if (currentMenu == &SP_NightsAttackDef) { - if (P_HasGrades(cv_nextmap.value, cv_dummymares.value)) + if (itemOn == nalevel) { - V_DrawString(160-88, 112, V_YELLOWMAP, "BEST GRADE:"); - V_DrawSmallScaledPatch(160 + 86 - (ngradeletters[bestgrade]->width/2), - 112 + 8 - (ngradeletters[bestgrade]->height/2), - 0, ngradeletters[bestgrade]); - } - - if (!bestscore) - sprintf(beststr, "(none)"); - else - sprintf(beststr, "%u", bestscore); - - V_DrawString(160 - 88, 122, V_YELLOWMAP, "BEST SCORE:"); - V_DrawRightAlignedString(160 + 88, 122, V_ALLOWLOWERCASE, beststr); - - if (besttime == UINT32_MAX) - sprintf(beststr, "(none)"); - else - sprintf(beststr, "%i:%02i.%02i", G_TicsToMinutes(besttime, true), - G_TicsToSeconds(besttime), - G_TicsToCentiseconds(besttime)); - - V_DrawString(160-88, 132, V_YELLOWMAP, "BEST TIME:"); - V_DrawRightAlignedString(160+88, 132, V_ALLOWLOWERCASE, beststr); - - if (cv_dummymares.value == 0) { - // Draw record emblems. - em = M_GetLevelEmblems(cv_nextmap.value); - while (em) - { - switch (em->type) - { - case ET_NGRADE: yHeight = 112; break; - case ET_NTIME: yHeight = 132; break; - default: - goto skipThisOne; - } - - if (em->collected) - V_DrawSmallMappedPatch(160+88, yHeight, 0, W_CachePatchName(M_GetEmblemPatch(em), PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE)); - else - V_DrawSmallScaledPatch(160+88, yHeight, 0, W_CachePatchName("NEEDIT", PU_CACHE)); - - skipThisOne: - em = M_GetLevelEmblems(-1); - } + /* Draw arrows !! */ + y = y + 25 - 4; + V_DrawCharacter(208 - 10 - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(208 + 80 + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); } + // Draw press ESC to exit string on main record attack menu + V_DrawString(104-72, 180, V_TRANSLUCENT, M_GetText("Press ESC to exit")); } - // ALWAYS DRAW level name even when not on this menu! - else - { - consvar_t *ncv; - INT32 x = SP_NightsAttackDef.x; - INT32 y = SP_NightsAttackDef.y; - ncv = (consvar_t *)SP_NightsAttackMenu[0].itemaction; - V_DrawString(x, y + SP_NightsAttackMenu[0].alphaKey, V_TRANSLUCENT, SP_NightsAttackMenu[0].text); - V_DrawString(BASEVIDWIDTH - x - V_StringWidth(ncv->string, 0), - y + SP_NightsAttackMenu[0].alphaKey, V_YELLOWMAP|V_TRANSLUCENT, ncv->string); + // Super Sonic + M_DrawNightsAttackSuperSonic(); + //if (P_HasGrades(cv_nextmap.value, 0)) + // V_DrawScaledPatch(235 - (SHORT((ngradeletters[bestoverall])->width)*3)/2, 135, 0, ngradeletters[bestoverall]); + + if (P_HasGrades(cv_nextmap.value, cv_dummymares.value)) + {//make bigger again + V_DrawString(104 - 72, 48+lsheadingheight/2, V_YELLOWMAP, "BEST GRADE:"); + V_DrawSmallScaledPatch(104 + 72 - (ngradeletters[bestgrade]->width/2), + 48+lsheadingheight/2 + 8 - (ngradeletters[bestgrade]->height/2), + 0, ngradeletters[bestgrade]); + } + + if (!bestscore) + sprintf(beststr, "(none)"); + else + sprintf(beststr, "%u", bestscore); + + V_DrawString(104 - 72, 58+lsheadingheight/2, V_YELLOWMAP, "BEST SCORE:"); + V_DrawRightAlignedString(104 + 72, 58+lsheadingheight/2, V_ALLOWLOWERCASE, beststr); + + if (besttime == UINT32_MAX) + sprintf(beststr, "(none)"); + else + sprintf(beststr, "%i:%02i.%02i", G_TicsToMinutes(besttime, true), + G_TicsToSeconds(besttime), + G_TicsToCentiseconds(besttime)); + + V_DrawString(104 - 72, 68+lsheadingheight/2, V_YELLOWMAP, "BEST TIME:"); + V_DrawRightAlignedString(104 + 72, 68+lsheadingheight/2, V_ALLOWLOWERCASE, beststr); + + if (cv_dummymares.value == 0) { + // Draw record emblems. + em = M_GetLevelEmblems(cv_nextmap.value); + while (em) + { + switch (em->type) + { + case ET_NGRADE: + xpos = 104+38; + yHeight = 48; + break; + case ET_NTIME: + xpos = 104+76; + yHeight = 68; + break; + default: + goto skipThisOne; + } + + if (em->collected) + V_DrawSmallMappedPatch(xpos, yHeight+lsheadingheight/2, 0, W_CachePatchName(M_GetEmblemPatch(em, false), PU_PATCH), + R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_CACHE)); + else + V_DrawSmallScaledPatch(xpos, yHeight+lsheadingheight/2, 0, W_CachePatchName("NEEDIT", PU_PATCH)); + + skipThisOne: + em = M_GetLevelEmblems(-1); + } } } + + // ALWAYS DRAW level even when not on this menu! + if (currentMenu != &SP_NightsAttackDef) + V_DrawString(SP_NightsAttackDef.x, SP_NightsAttackDef.y + SP_TimeAttackMenu[nalevel].alphaKey, V_TRANSLUCENT, SP_NightsAttackMenu[nalevel].text); +} + +static void M_NightsAttackLevelSelect(INT32 choice) +{ + (void)choice; + SP_NightsAttackLevelSelectDef.prevMenu = currentMenu; + M_SetupNextMenu(&SP_NightsAttackLevelSelectDef); } // Going to Nights Attack menu... @@ -6169,27 +9963,26 @@ static void M_NightsAttack(INT32 choice) { (void)choice; - memset(skins_cons_t, 0, sizeof (skins_cons_t)); - + SP_NightsAttackDef.prevMenu = &MainDef; levellistmode = LLM_NIGHTSATTACK; // Don't be dependent on cv_newgametype - if (M_CountLevelsToShowInList() == 0) + if (!M_PrepareLevelPlatter(-1, true)) { M_StartMessage(M_GetText("No NiGHTS-attackable levels found.\n"),NULL,MM_NOTHING); return; } - // This is really just to make sure Sonic is the played character, just in case M_PatchSkinNameTable(); - M_PrepareLevelSelect(); + G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please M_SetupNextMenu(&SP_NightsAttackDef); - Nextmap_OnChange(); + if (!M_CanShowLevelInList(cv_nextmap.value-1, -1) && levelselect.rows[0].maplist[0]) + CV_SetValue(&cv_nextmap, levelselect.rows[0].maplist[0]); + else + Nextmap_OnChange(); itemOn = nastart; // "Start" is selected. - - G_SetGamestate(GS_TIMEATTACK); - S_ChangeMusicInternal("racent", true); } // Player has selected the "START" from the nights attack screen @@ -6198,6 +9991,7 @@ static void M_ChooseNightsAttack(INT32 choice) char nameofdemo[256]; (void)choice; emeralds = 0; + memset(&luabanks, 0, sizeof(luabanks)); M_ClearMenus(true); modeattacking = ATTACKING_NIGHTS; @@ -6222,6 +10016,7 @@ static void M_ChooseTimeAttack(INT32 choice) char nameofdemo[256]; (void)choice; emeralds = 0; + memset(&luabanks, 0, sizeof(luabanks)); M_ClearMenus(true); modeattacking = ATTACKING_RECORD; @@ -6232,7 +10027,7 @@ static void M_ChooseTimeAttack(INT32 choice) I_Error("Out of memory for replay filepath\n"); sprintf(gpath,"replay"PATHSEP"%s"PATHSEP"%s", timeattackfolder, G_BuildMapName(cv_nextmap.value)); - snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, cv_chooseskin.string); + snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, skins[cv_chooseskin.value-1].name); if (!cv_autorecord.value) remove(va("%s"PATHSEP"%s.lmp", srb2home, nameofdemo)); @@ -6271,7 +10066,7 @@ static void M_ReplayTimeAttack(INT32 choice) return; } // srb2/replay/main/map01-sonic-time-best.lmp - G_DoPlayDemo(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which)); + G_DoPlayDemo(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name, which)); } else if (currentMenu == &SP_NightsReplayDef) { @@ -6298,15 +10093,14 @@ static void M_ReplayTimeAttack(INT32 choice) static void M_EraseGuest(INT32 choice) { const char *rguest = va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); - (void)choice; - if (FIL_FileExists(rguest)) - remove(rguest); - if (currentMenu == &SP_NightsGuestReplayDef) - M_SetupNextMenu(&SP_NightsAttackDef); - else - M_SetupNextMenu(&SP_TimeAttackDef); - CV_AddValue(&cv_nextmap, -1); - CV_AddValue(&cv_nextmap, 1); + + if (choice == 'y' || choice == KEY_ENTER) + { + if (FIL_FileExists(rguest)) + remove(rguest); + } + M_SetupNextMenu(currentMenu->prevMenu->prevMenu); + Nextmap_OnChange(); M_StartMessage(M_GetText("Guest replay data erased.\n"),NULL,MM_NOTHING); } @@ -6316,7 +10110,7 @@ static void M_OverwriteGuest(const char *which, boolean nights) UINT8 *buf; size_t len; if (!nights) - len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which), &buf); + len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name, which), &buf); else len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), which), &buf); if (!len) { @@ -6332,8 +10126,7 @@ static void M_OverwriteGuest(const char *which, boolean nights) M_SetupNextMenu(&SP_NightsAttackDef); else M_SetupNextMenu(&SP_TimeAttackDef); - CV_AddValue(&cv_nextmap, -1); - CV_AddValue(&cv_nextmap, 1); + Nextmap_OnChange(); M_StartMessage(M_GetText("Guest replay data saved.\n"),NULL,MM_NOTHING); } @@ -6391,9 +10184,10 @@ static void M_SetGuestReplay(INT32 choice) which(0); } -static void M_ModeAttackRetry(INT32 choice) +void M_ModeAttackRetry(INT32 choice) { (void)choice; + // todo -- maybe seperate this out and G_SetRetryFlag() here instead? is just calling this from the menu 100% safe? G_CheckDemoStatus(); // Cancel recording if (modeattacking == ATTACKING_RECORD) M_ChooseTimeAttack(0); @@ -6415,18 +10209,18 @@ static void M_ModeAttackEndGame(INT32 choice) default: case ATTACKING_RECORD: currentMenu = &SP_TimeAttackDef; + wipetypepost = menupres[MN_SP_TIMEATTACK].enterwipe; break; case ATTACKING_NIGHTS: currentMenu = &SP_NightsAttackDef; + wipetypepost = menupres[MN_SP_NIGHTSATTACK].enterwipe; break; } itemOn = currentMenu->lastOn; G_SetGamestate(GS_TIMEATTACK); modeattacking = ATTACKING_NONE; - S_ChangeMusicInternal("racent", true); - // Update replay availability. - CV_AddValue(&cv_nextmap, 1); - CV_AddValue(&cv_nextmap, -1); + M_ChangeMenuMusic("_title", true); + Nextmap_OnChange(); } // ======== @@ -6563,8 +10357,8 @@ static void M_DrawRoomMenu(void) static void M_DrawConnectMenu(void) { - UINT16 i, j; - const char *gt = "Unknown"; + UINT16 i; + char *gt; INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE; for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++) @@ -6576,7 +10370,7 @@ static void M_DrawConnectMenu(void) // Room name if (ms_RoomId < 0) V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_room].alphaKey, - V_YELLOWMAP, (itemOn == mp_connect_room) ? "" : ""); else V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ConnectMenu[mp_connect_room].alphaKey, V_YELLOWMAP, room_list[menuRoomIndex].name); @@ -6594,7 +10388,7 @@ static void M_DrawConnectMenu(void) for (i = 0; i < min(serverlistcount - serverlistpage * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++) { INT32 slindex = i + serverlistpage * SERVERS_PER_PAGE; - UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0) + UINT32 globalflags = (serverlist[slindex].info.refusereason ? V_TRANSLUCENT : 0) |((itemOn == FIRSTSERVERLINE+i) ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE; V_DrawString(currentMenu->x, S_LINEY(i), globalflags, serverlist[slindex].info.servername); @@ -6608,17 +10402,17 @@ static void M_DrawConnectMenu(void) V_DrawSmallString(currentMenu->x, S_LINEY(i)+8, globalflags, va("Ping: %u", (UINT32)LONG(serverlist[slindex].info.time))); - gt = "Unknown"; - for (j = 0; gametype_cons_t[j].strvalue; j++) - { - if (gametype_cons_t[j].value == serverlist[slindex].info.gametype) - gt = gametype_cons_t[j].strvalue; - } + gt = serverlist[slindex].info.gametypename; V_DrawSmallString(currentMenu->x+46,S_LINEY(i)+8, globalflags, va("Players: %02d/%02d", serverlist[slindex].info.numberofplayer, serverlist[slindex].info.maxplayer)); - V_DrawSmallString(currentMenu->x+112, S_LINEY(i)+8, globalflags, va("Gametype: %s", gt)); + if (strlen(gt) > 11) + gt = va("Gametype: %.11s...", gt); + else + gt = va("Gametype: %s", gt); + + V_DrawSmallString(currentMenu->x+112, S_LINEY(i)+8, globalflags, gt); MP_ConnectMenu[i+FIRSTSERVERLINE].status = IT_STRING | IT_CALL; } @@ -6659,7 +10453,15 @@ SERVER_LIST_ENTRY_COMPARATOR(time) SERVER_LIST_ENTRY_COMPARATOR(numberofplayer) SERVER_LIST_ENTRY_COMPARATOR_REVERSE(numberofplayer) SERVER_LIST_ENTRY_COMPARATOR_REVERSE(maxplayer) -SERVER_LIST_ENTRY_COMPARATOR(gametype) + +static int ServerListEntryComparator_gametypename(const void *entry1, const void *entry2) +{ + const serverelem_t *sa = (const serverelem_t*)entry1, *sb = (const serverelem_t*)entry2; + int c; + if (( c = strcasecmp(sa->info.gametypename, sb->info.gametypename) )) + return c; + return strcmp(sa->info.servername, sb->info.servername); \ +} // Special one for modified state. static int ServerListEntryComparator_modified(const void *entry1, const void *entry2) @@ -6699,7 +10501,7 @@ void M_SortServerList(void) qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_maxplayer_reverse); break; case 5: // Gametype. - qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametype); + qsort(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametypename); break; } #endif @@ -6729,11 +10531,32 @@ static void M_ConnectMenu(INT32 choice) // first page of servers serverlistpage = 0; - M_SetupNextMenu(&MP_ConnectDef); + if (ms_RoomId < 0) + { + M_RoomMenu(0); // Select a room instead of staring at an empty list + // This prevents us from returning to the modified game alert. + currentMenu->prevMenu = &MP_MainDef; + } + else + M_SetupNextMenu(&MP_ConnectDef); itemOn = 0; M_Refresh(0); } +static void M_ConnectMenuModChecks(INT32 choice) +{ + (void)choice; + // okay never mind we want to COMMUNICATE to the player pre-emptively instead of letting them try and then get confused when it doesn't work + + if (modifiedgame) + { + M_StartMessage(M_GetText("Add-ons are currently loaded.\n\nYou will only be able to join a server if\nit has the same ones loaded in the same order, which may be unlikely.\n\nIf you wish to play on other servers,\nrestart the game to clear existing add-ons.\n\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER); + return; + } + + M_ConnectMenu(-1); +} + static UINT32 roomIds[NUM_LIST_ROOMS]; static void M_RoomMenu(INT32 choice) @@ -6788,7 +10611,16 @@ static void M_ChooseRoom(INT32 choice) } serverlistpage = 0; - M_SetupNextMenu(currentMenu->prevMenu); + /* + We were on the Multiplayer menu? That means that we must have been trying to + view the server browser, but we hadn't selected a room yet. So we need to go + to the browser next, not back there. + */ + if (currentMenu->prevMenu == &MP_MainDef) + M_SetupNextMenu(&MP_ConnectDef); + else + M_SetupNextMenu(currentMenu->prevMenu); + if (currentMenu == &MP_ConnectDef) M_Refresh(0); } @@ -6798,25 +10630,6 @@ static void M_ChooseRoom(INT32 choice) // Start Server Menu //=========================================================================== -// -// FindFirstMap -// -// Finds the first map of a particular gametype -// Defaults to 1 if nothing found. -// -static INT32 M_FindFirstMap(INT32 gtype) -{ - INT32 i; - - for (i = 0; i < NUMMAPS; i++) - { - if (mapheaderinfo[i] && (mapheaderinfo[i]->typeoflevel & gtype)) - return i + 1; - } - - return 1; -} - static void M_StartServer(INT32 choice) { boolean StartSplitScreenGame = (currentMenu == &MP_SplitServerDef); @@ -6857,45 +10670,65 @@ static void M_StartServer(INT32 choice) static void M_DrawServerMenu(void) { - lumpnum_t lumpnum; - patch_t *PictureOfLevel; - M_DrawGenericMenu(); #ifndef NONET // Room name if (currentMenu == &MP_ServerDef) { + M_DrawLevelPlatterHeader(currentMenu->y - lsheadingheight/2, "Server settings", true, false); if (ms_RoomId < 0) V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ServerMenu[mp_server_room].alphaKey, - V_YELLOWMAP, (itemOn == mp_server_room) ? "" : ""); else V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + MP_ServerMenu[mp_server_room].alphaKey, V_YELLOWMAP, room_list[menuRoomIndex].name); } #endif - // A 160x100 image of the level as entry MAPxxP - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + if (cv_nextmap.value) + { +#ifndef NONET +#define imgheight MP_ServerMenu[mp_server_levelgt].alphaKey +#else +#define imgheight 100 +#endif + patch_t *PictureOfLevel; + lumpnum_t lumpnum; + char headerstr[40]; - if (lumpnum != LUMPERROR) - PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_CACHE); - else - PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE); + sprintf(headerstr, "%s - %s", cv_newgametype.string, cv_nextmap.string); - V_DrawSmallScaledPatch((BASEVIDWIDTH*3/4)-(SHORT(PictureOfLevel->width)/4), ((BASEVIDHEIGHT*3/4)-(SHORT(PictureOfLevel->height)/4)+10), 0, PictureOfLevel); + M_DrawLevelPlatterHeader(currentMenu->y + imgheight - 10 - lsheadingheight/2, (const char *)headerstr, true, false); + + // A 160x100 image of the level as entry MAPxxP + lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); + + if (lumpnum != LUMPERROR) + PictureOfLevel = W_CachePatchName(va("%sP", G_BuildMapName(cv_nextmap.value)), PU_PATCH); + else + PictureOfLevel = W_CachePatchName("BLANKLVL", PU_PATCH); + + V_DrawSmallScaledPatch(319 - (currentMenu->x + (SHORT(PictureOfLevel->width)/2)), currentMenu->y + imgheight, 0, PictureOfLevel); + } } static void M_MapChange(INT32 choice) { (void)choice; + MISC_ChangeLevelDef.prevMenu = currentMenu; levellistmode = LLM_CREATESERVER; - CV_SetValue(&cv_newgametype, gametype); - CV_SetValue(&cv_nextmap, gamemap); + if (Playing() && !(M_CanShowLevelOnPlatter(cv_nextmap.value-1, cv_newgametype.value)) && (M_CanShowLevelOnPlatter(gamemap-1, cv_newgametype.value))) + CV_SetValue(&cv_nextmap, gamemap); + + if (!M_PrepareLevelPlatter(cv_newgametype.value, (currentMenu == &MPauseDef))) + { + M_StartMessage(M_GetText("No selectable levels found.\n"),NULL,MM_NOTHING); + return; + } - M_PrepareLevelSelect(); M_SetupNextMenu(&MISC_ChangeLevelDef); } @@ -6903,51 +10736,94 @@ static void M_StartSplitServerMenu(INT32 choice) { (void)choice; levellistmode = LLM_CREATESERVER; - M_PrepareLevelSelect(); + Newgametype_OnChange(); M_SetupNextMenu(&MP_SplitServerDef); } +static void M_ServerOptions(INT32 choice) +{ + (void)choice; + +#ifndef NONET + if ((splitscreen && !netgame) || currentMenu == &MP_SplitServerDef) + { + OP_ServerOptionsMenu[ 1].status = IT_GRAYEDOUT; // Server name + OP_ServerOptionsMenu[ 2].status = IT_GRAYEDOUT; // Max players + OP_ServerOptionsMenu[ 3].status = IT_GRAYEDOUT; // Allow add-on downloading + OP_ServerOptionsMenu[ 4].status = IT_GRAYEDOUT; // Allow players to join + OP_ServerOptionsMenu[35].status = IT_GRAYEDOUT; // Master server + OP_ServerOptionsMenu[36].status = IT_GRAYEDOUT; // Attempts to resynchronise + } + else + { + OP_ServerOptionsMenu[ 1].status = IT_STRING | IT_CVAR | IT_CV_STRING; + OP_ServerOptionsMenu[ 2].status = IT_STRING | IT_CVAR; + OP_ServerOptionsMenu[ 3].status = IT_STRING | IT_CVAR; + OP_ServerOptionsMenu[ 4].status = IT_STRING | IT_CVAR; + OP_ServerOptionsMenu[35].status = (netgame + ? IT_GRAYEDOUT + : (IT_STRING | IT_CVAR | IT_CV_STRING)); + OP_ServerOptionsMenu[36].status = IT_STRING | IT_CVAR; + } +#endif + + /* Disable fading because of different menu head. */ + if (currentMenu == &OP_MainDef)/* from Options menu */ + OP_ServerOptionsDef.menuid = MN_OP_MAIN + ( MN_OP_SERVER << 6 ); + else/* from Multiplayer menu */ + OP_ServerOptionsDef.menuid = MN_MP_MAIN + ( MN_MP_SERVER_OPTIONS << 6 ); + + OP_ServerOptionsDef.prevMenu = currentMenu; + M_SetupNextMenu(&OP_ServerOptionsDef); +} + #ifndef NONET static void M_StartServerMenu(INT32 choice) { (void)choice; - levellistmode = LLM_CREATESERVER; - M_PrepareLevelSelect(); ms_RoomId = -1; + levellistmode = LLM_CREATESERVER; + Newgametype_OnChange(); M_SetupNextMenu(&MP_ServerDef); - + itemOn = 1; } // ============== // CONNECT VIA IP // ============== -static char setupm_ip[16]; - -// Connect using IP address Tails 11-19-2002 -static void M_ConnectIPMenu(INT32 choice) -{ - (void)choice; - // modified game check: no longer handled - // we don't request a restart unless the filelist differs - - M_SetupNextMenu(&MP_ConnectIPDef); -} +static char setupm_ip[28]; // Draw the funky Connect IP menu. Tails 11-19-2002 // So much work for such a little thing! -static void M_DrawConnectIPMenu(void) +static void M_DrawMPMainMenu(void) { + INT32 x = currentMenu->x; + INT32 y = currentMenu->y; + // use generic drawer for cursor, items and title M_DrawGenericMenu(); + V_DrawRightAlignedString(BASEVIDWIDTH-x, y+66, + ((itemOn == 4) ? V_YELLOWMAP : 0), va("(2-%d players)", MAXPLAYERS)); + + V_DrawRightAlignedString(BASEVIDWIDTH-x, y+76, + ((itemOn == 5) ? V_YELLOWMAP : 0), "(2 players)"); + + V_DrawRightAlignedString(BASEVIDWIDTH-x, y+116, + ((itemOn == 8) ? V_YELLOWMAP : 0), "(splitscreen)"); + + y += 22; + + V_DrawFill(x+5, y+4+5, /*16*8 + 6,*/ BASEVIDWIDTH - 2*(x+5), 8+6, 159); + // draw name string - V_DrawString(128,40, V_MONOSPACE, setupm_ip); + V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip); // draw text cursor for name - if (itemOn == 0 && - skullAnimCounter < 4) //blink cursor - V_DrawCharacter(128+V_StringWidth(setupm_ip, V_MONOSPACE),40,'_',false); + if (itemOn == 2 //0 + && skullAnimCounter < 4) //blink cursor + V_DrawCharacter(x+8+V_StringWidth(setupm_ip, V_ALLOWLOWERCASE),y+12,'_',false); } // Tails 11-19-2002 @@ -6961,6 +10837,8 @@ static void M_ConnectIP(INT32 choice) return; } + M_ClearMenus(true); + COM_BufAddText(va("connect \"%s\"\n", setupm_ip)); // A little "please wait" message. @@ -6975,14 +10853,23 @@ static void M_ConnectIP(INT32 choice) // Tails 11-19-2002 static void M_HandleConnectIP(INT32 choice) { - size_t l; - boolean exitmenu = false; // exit to previous menu and send name change + size_t l; + boolean exitmenu = false; // exit to previous menu and send name change switch (choice) { + case KEY_DOWNARROW: + M_NextOpt(); + S_StartSound(NULL,sfx_menu1); // Tails + break; + + case KEY_UPARROW: + M_PrevOpt(); + S_StartSound(NULL,sfx_menu1); // Tails + break; + case KEY_ENTER: S_StartSound(NULL,sfx_menu1); // Tails - M_ClearMenus(true); M_ConnectIP(1); break; @@ -6991,34 +10878,110 @@ static void M_HandleConnectIP(INT32 choice) break; case KEY_BACKSPACE: - if ((l = strlen(setupm_ip))!=0 && itemOn == 0) + if ((l = strlen(setupm_ip)) != 0) { S_StartSound(NULL,sfx_menu1); // Tails - setupm_ip[l-1] =0; + setupm_ip[l-1] = 0; } break; + case KEY_DEL: + if (setupm_ip[0] && !shiftdown) // Shift+Delete is used for something else. + { + S_StartSound(NULL,sfx_menu1); // Tails + setupm_ip[0] = 0; + } + if (!shiftdown) // Shift+Delete is used for something else. + break; + + /* FALLTHRU */ default: l = strlen(setupm_ip); - if (l < 16-1 && (choice == 46 || (choice >= 48 && choice <= 57))) // Rudimentary number and period enforcing + + if ( ctrldown ) { + switch (choice) { + case 'v': + case 'V': // ctrl+v, pasting + { + const char *paste = I_ClipboardPaste(); + + if (paste != NULL) { + strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard + if (strlen(paste) != 0) // Don't play sound if nothing was pasted + S_StartSound(NULL,sfx_menu1); // Tails + } + + break; + } + case KEY_INS: + case 'c': + case 'C': // ctrl+c, ctrl+insert, copying + I_ClipboardCopy(setupm_ip, l); + S_StartSound(NULL,sfx_menu1); // Tails + break; + + case 'x': + case 'X': // ctrl+x, cutting + I_ClipboardCopy(setupm_ip, l); + S_StartSound(NULL,sfx_menu1); // Tails + setupm_ip[0] = 0; + break; + + default: // otherwise do nothing + break; + } + break; // don't check for typed keys + } + + if ( shiftdown ) { + switch (choice) { + case KEY_INS: // shift+insert, pasting + { + const char *paste = I_ClipboardPaste(); + + if (paste != NULL) { + strncat(setupm_ip, paste, 28-1 - l); // Concat the ip field with clipboard + if (strlen(paste) != 0) // Don't play sound if nothing was pasted + S_StartSound(NULL,sfx_menu1); // Tails + } + + break; + } + case KEY_DEL: // shift+delete, cutting + I_ClipboardCopy(setupm_ip, l); + S_StartSound(NULL,sfx_menu1); // Tails + setupm_ip[0] = 0; + break; + default: // otherwise do nothing. + break; + } + } + + if (l >= 28-1) + break; + + // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead + if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z')) { S_StartSound(NULL,sfx_menu1); // Tails - setupm_ip[l] =(char)choice; - setupm_ip[l+1] =0; + setupm_ip[l] = (char)choice; + setupm_ip[l+1] = 0; } - else if (l < 16-1 && choice >= 199 && choice <= 211 && choice != 202 && choice != 206) //numpad too! + else if (choice >= 199 && choice <= 211 && choice != 202 && choice != 206) //numpad too! { - XBOXSTATIC char keypad_translation[] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'}; + char keypad_translation[] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'}; choice = keypad_translation[choice - 199]; S_StartSound(NULL,sfx_menu1); // Tails - setupm_ip[l] =(char)choice; - setupm_ip[l+1] =0; + setupm_ip[l] = (char)choice; + setupm_ip[l+1] = 0; } + break; } if (exitmenu) { + currentMenu->lastOn = itemOn; if (currentMenu->prevMenu) M_SetupNextMenu (currentMenu->prevMenu); else @@ -7032,11 +10995,9 @@ static void M_HandleConnectIP(INT32 choice) // ======================== // Tails 03-02-2002 -#define PLBOXW 8 -#define PLBOXH 9 - -static INT32 multi_tics; -static state_t *multi_state; +static UINT8 multi_tics; +static UINT8 multi_frame; +static UINT8 multi_spr2; // this is set before entering the MultiPlayer setup menu, // for either player 1 or 2 @@ -7045,107 +11006,186 @@ static player_t *setupm_player; static consvar_t *setupm_cvskin; static consvar_t *setupm_cvcolor; static consvar_t *setupm_cvname; +static consvar_t *setupm_cvdefaultskin; +static consvar_t *setupm_cvdefaultcolor; static INT32 setupm_fakeskin; static INT32 setupm_fakecolor; static void M_DrawSetupMultiPlayerMenu(void) { - INT32 mx, my, st, flags = 0; + INT32 x, y, cursory = 0, flags = 0; spritedef_t *sprdef; spriteframe_t *sprframe; patch_t *patch; - UINT8 frame; + UINT8 *colormap; - mx = MP_PlayerSetupDef.x; - my = MP_PlayerSetupDef.y; + x = MP_PlayerSetupDef.x; + y = MP_PlayerSetupDef.y; // use generic drawer for cursor, items and title - M_DrawGenericMenu(); + //M_DrawGenericMenu(); + + // draw title (or big pic) + M_DrawMenuTitle(); + + M_DrawLevelPlatterHeader(y - (lsheadingheight - 12), "Name", true, false); + if (itemOn == 0) + cursory = y; + y += 11; // draw name string - M_DrawTextBox(mx + 90, my - 8, MAXPLAYERNAME, 1); - V_DrawString(mx + 98, my, V_ALLOWLOWERCASE, setupm_name); + V_DrawFill(x, y, 282/*(MAXPLAYERNAME+1)*8+6*/, 14, 159); + V_DrawString(x + 8, y + 3, V_ALLOWLOWERCASE, setupm_name); + if (skullAnimCounter < 4 && itemOn == 0) + V_DrawCharacter(x + 8 + V_StringWidth(setupm_name, V_ALLOWLOWERCASE), y + 3, + '_' | 0x80, false); + + y += 20; + + M_DrawLevelPlatterHeader(y - (lsheadingheight - 12), "Character", true, false); + if (itemOn == 1) + cursory = y; // draw skin string - V_DrawString(mx + 90, my + 96, - ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0)|V_YELLOWMAP|V_ALLOWLOWERCASE, + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, + ((MP_PlayerSetupMenu[1].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0)|(itemOn == 1 ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, skins[setupm_fakeskin].realname); - // draw the name of the color you have chosen - // Just so people don't go thinking that "Default" is Green. - V_DrawString(208, 72, V_YELLOWMAP|V_ALLOWLOWERCASE, Color_Names[setupm_fakecolor]); + if (itemOn == 1 && (MP_PlayerSetupMenu[1].status & IT_TYPE) != IT_SPACE) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(skins[setupm_fakeskin].realname, V_ALLOWLOWERCASE) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } - // draw text cursor for name - if (!itemOn && skullAnimCounter < 4) // blink cursor - V_DrawCharacter(mx + 98 + V_StringWidth(setupm_name, 0), my, '_',false); + x = BASEVIDWIDTH/2; + y += 11; // anim the player in the box if (--multi_tics <= 0) { - st = multi_state->nextstate; - if (st != S_NULL) - multi_state = &states[st]; - multi_tics = multi_state->tics; - if (multi_tics == -1) - multi_tics = 15; + multi_frame++; + multi_tics = 4; } - // skin 0 is default player sprite - if (R_SkinAvailable(skins[setupm_fakeskin].name) != -1) - sprdef = &skins[R_SkinAvailable(skins[setupm_fakeskin].name)].spritedef; - else - sprdef = &skins[0].spritedef; +#define charw 74 - if (!sprdef->numframes) // No frames ?? - return; // Can't render! + // draw box around character + V_DrawFill(x-(charw/2), y, charw, 84, 159); - frame = multi_state->frame & FF_FRAMEMASK; - if (frame >= sprdef->numframes) // Walking animation missing - frame = 0; // Try to use standing frame + sprdef = &skins[setupm_fakeskin].sprites[multi_spr2]; - sprframe = &sprdef->spriteframes[frame]; - patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); + if (!setupm_fakecolor || !sprdef->numframes) // should never happen but hey, who knows + goto faildraw; + + // ok, draw player sprite for sure now + colormap = R_GetTranslationColormap(setupm_fakeskin, setupm_fakecolor, 0); + + if (multi_frame >= sprdef->numframes) + multi_frame = 0; + + sprframe = &sprdef->spriteframes[multi_frame]; + patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); if (sprframe->flip & 1) // Only for first sprite flags |= V_FLIP; // This sprite is left/right flipped! - // draw box around guy - M_DrawTextBox(mx + 90, my + 8, PLBOXW, PLBOXH); +#define chary (y+64) - // draw player sprite - if (!setupm_fakecolor) // should never happen but hey, who knows + V_DrawFixedPatch( + x<numframes) // No frames ?? + return; // Can't render! + + sprframe = &sprdef->spriteframes[0]; + patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); + if (sprframe->flip & 1) // Only for first sprite + flags |= V_FLIP; // This sprite is left/right flipped! + + V_DrawScaledPatch(x, chary, flags, patch); + +#undef chary + +colordraw: + x = MP_PlayerSetupDef.x; + y += 75; + + M_DrawLevelPlatterHeader(y - (lsheadingheight - 12), "Color", true, false); + if (itemOn == 2) + cursory = y; + + // draw color string + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, + ((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0)|(itemOn == 2 ? V_YELLOWMAP : 0)|V_ALLOWLOWERCASE, + Color_Names[setupm_fakecolor]); + + if (itemOn == 2 && (MP_PlayerSetupMenu[2].status & IT_TYPE) != IT_SPACE) { - if (skins[setupm_fakeskin].flags & SF_HIRES) - { - V_DrawSciencePatch((mx+98+(PLBOXW*8/2))<= MAXSKINCOLORS) + col -= MAXSKINCOLORS-1; + x += w; } - else - V_DrawMappedPatch(mx + 98 + (PLBOXW*8/2), my + 16 + (PLBOXH*8) - 12, flags, patch, colormap); - - Z_Free(colormap); } +#undef charw +#undef indexwidth + + x = MP_PlayerSetupDef.x; + y += 20; + + V_DrawString(x, y, + ((R_SkinAvailable(setupm_cvdefaultskin->string) != setupm_fakeskin + || setupm_cvdefaultcolor->value != setupm_fakecolor) + ? 0 + : V_TRANSLUCENT) + | ((itemOn == 3) ? V_YELLOWMAP : 0), + "Save as default"); + if (itemOn == 3) + cursory = y; + + V_DrawScaledPatch(x - 17, cursory, 0, + W_CachePatchName("M_CURSOR", PU_PATCH)); } // Handle 1P/2P MP Setup static void M_HandleSetupMultiPlayer(INT32 choice) { size_t l; + INT32 prev_setupm_fakeskin; boolean exitmenu = false; // exit to previous menu and send name change switch (choice) @@ -7161,25 +11201,53 @@ static void M_HandleSetupMultiPlayer(INT32 choice) break; case KEY_LEFTARROW: - if (itemOn == 2) //player skin + if (itemOn == 1) //player skin { S_StartSound(NULL,sfx_menu1); // Tails - setupm_fakeskin--; + prev_setupm_fakeskin = setupm_fakeskin; + do + { + setupm_fakeskin--; + if (setupm_fakeskin < 0) + setupm_fakeskin = numskins-1; + } + while ((prev_setupm_fakeskin != setupm_fakeskin) && !(R_SkinUsable(-1, setupm_fakeskin))); + multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); } - else if (itemOn == 1) // player color + else if (itemOn == 2) // player color { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor--; } break; + case KEY_ENTER: + if (itemOn == 3 + && (R_SkinAvailable(setupm_cvdefaultskin->string) != setupm_fakeskin + || setupm_cvdefaultcolor->value != setupm_fakecolor)) + { + S_StartSound(NULL,sfx_strpst); + // you know what? always putting these in the buffer won't hurt anything. + COM_BufAddText (va("%s \"%s\"\n",setupm_cvdefaultskin->name,skins[setupm_fakeskin].name)); + COM_BufAddText (va("%s %d\n",setupm_cvdefaultcolor->name,setupm_fakecolor)); + break; + } + /* FALLTHRU */ case KEY_RIGHTARROW: - if (itemOn == 2) //player skin + if (itemOn == 1) //player skin { S_StartSound(NULL,sfx_menu1); // Tails - setupm_fakeskin++; + prev_setupm_fakeskin = setupm_fakeskin; + do + { + setupm_fakeskin++; + if (setupm_fakeskin > numskins-1) + setupm_fakeskin = 0; + } + while ((prev_setupm_fakeskin != setupm_fakeskin) && !(R_SkinUsable(-1, setupm_fakeskin))); + multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); } - else if (itemOn == 1) // player color + else if (itemOn == 2) // player color { S_StartSound(NULL,sfx_menu1); // Tails setupm_fakecolor++; @@ -7191,32 +11259,44 @@ static void M_HandleSetupMultiPlayer(INT32 choice) break; case KEY_BACKSPACE: - if ((l = strlen(setupm_name))!=0 && itemOn == 0) + if (itemOn == 0 && (l = strlen(setupm_name))!=0) { S_StartSound(NULL,sfx_menu1); // Tails - setupm_name[l-1] =0; + setupm_name[l-1] = 0; + } + else if (itemOn == 2) + { + UINT8 col = skins[setupm_fakeskin].prefcolor; + if (setupm_fakecolor != col) + { + S_StartSound(NULL,sfx_menu1); // Tails + setupm_fakecolor = col; + } + } + break; + break; + + case KEY_DEL: + if (itemOn == 0 && (l = strlen(setupm_name))!=0) + { + S_StartSound(NULL,sfx_menu1); // Tails + setupm_name[0] = 0; } break; default: - if (choice < 32 || choice > 127 || itemOn != 0) + if (itemOn != 0 || choice < 32 || choice > 127) break; + S_StartSound(NULL,sfx_menu1); // Tails l = strlen(setupm_name); if (l < MAXPLAYERNAME) { - S_StartSound(NULL,sfx_menu1); // Tails - setupm_name[l] =(char)choice; - setupm_name[l+1] =0; + setupm_name[l] = (char)choice; + setupm_name[l+1] = 0; } break; } - // check skin - if (setupm_fakeskin < 0) - setupm_fakeskin = numskins-1; - if (setupm_fakeskin > numskins-1) - setupm_fakeskin = 0; - // check color if (setupm_fakecolor < 1) setupm_fakecolor = MAXSKINCOLORS-1; @@ -7237,8 +11317,8 @@ static void M_SetupMultiPlayer(INT32 choice) { (void)choice; - multi_state = &states[mobjinfo[MT_PLAYER].seestate]; - multi_tics = multi_state->tics; + multi_frame = 0; + multi_tics = 4; strcpy(setupm_name, cv_playername.string); // set for player 1 @@ -7246,6 +11326,8 @@ static void M_SetupMultiPlayer(INT32 choice) setupm_cvskin = &cv_skin; setupm_cvcolor = &cv_playercolor; setupm_cvname = &cv_playername; + setupm_cvdefaultskin = &cv_defaultskin; + setupm_cvdefaultcolor = &cv_defaultplayercolor; // For whatever reason this doesn't work right if you just use ->value setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); @@ -7255,10 +11337,18 @@ static void M_SetupMultiPlayer(INT32 choice) // disable skin changes if we can't actually change skins if (!CanChangeSkin(consoleplayer)) + MP_PlayerSetupMenu[1].status = (IT_GRAYEDOUT); + else + MP_PlayerSetupMenu[1].status = (IT_KEYHANDLER|IT_STRING); + + // ditto with colour + if (Playing() && G_GametypeHasTeams()) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER|IT_STRING); + multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -7268,8 +11358,8 @@ static void M_SetupMultiPlayer2(INT32 choice) { (void)choice; - multi_state = &states[mobjinfo[MT_PLAYER].seestate]; - multi_tics = multi_state->tics; + multi_frame = 0; + multi_tics = 4; strcpy (setupm_name, cv_playername2.string); // set for splitscreen secondary player @@ -7277,6 +11367,8 @@ static void M_SetupMultiPlayer2(INT32 choice) setupm_cvskin = &cv_skin2; setupm_cvcolor = &cv_playercolor2; setupm_cvname = &cv_playername2; + setupm_cvdefaultskin = &cv_defaultskin2; + setupm_cvdefaultcolor = &cv_defaultplayercolor2; // For whatever reason this doesn't work right if you just use ->value setupm_fakeskin = R_SkinAvailable(setupm_cvskin->string); @@ -7286,9 +11378,17 @@ static void M_SetupMultiPlayer2(INT32 choice) // disable skin changes if we can't actually change skins if (splitscreen && !CanChangeSkin(secondarydisplayplayer)) + MP_PlayerSetupMenu[1].status = (IT_GRAYEDOUT); + else + MP_PlayerSetupMenu[1].status = (IT_KEYHANDLER | IT_STRING); + + // ditto with colour + if (Playing() && G_GametypeHasTeams()) MP_PlayerSetupMenu[2].status = (IT_GRAYEDOUT); else - MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER | IT_STRING); + MP_PlayerSetupMenu[2].status = (IT_KEYHANDLER|IT_STRING); + + multi_spr2 = P_GetSkinSprite2(&skins[setupm_fakeskin], SPR2_WALK, NULL); MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); @@ -7332,6 +11432,7 @@ static void M_EraseDataResponse(INT32 ch) totalplaytime = 0; F_StartIntro(); } + BwehHehHe(); M_ClearMenus(true); } @@ -7344,7 +11445,7 @@ static void M_EraseData(INT32 choice) if (choice == 0) eschoice = M_GetText("Record Attack data"); else if (choice == 1) - eschoice = M_GetText("Secrets data"); + eschoice = M_GetText("Extras data"); else eschoice = M_GetText("ALL game data"); @@ -7357,9 +11458,27 @@ static void M_ScreenshotOptions(INT32 choice) Screenshot_option_Onchange(); Moviemode_mode_Onchange(); + M_SetupScreenshotMenu(); M_SetupNextMenu(&OP_ScreenshotOptionsDef); } +static void M_SetupScreenshotMenu(void) +{ + menuitem_t *item = &OP_ScreenshotOptionsMenu[op_screenshot_colorprofile]; + +#ifdef HWRENDER + // Hide some options based on render mode + if (rendermode == render_opengl) + { + item->status = IT_GRAYEDOUT; + if ((currentMenu == &OP_ScreenshotOptionsDef) && (itemOn == op_screenshot_colorprofile)) // Can't select that + itemOn = op_screenshot_storagelocation; + } + else +#endif + item->status = (IT_STRING | IT_CVAR); +} + // ============= // JOYSTICK MENU // ============= @@ -7369,24 +11488,46 @@ static void M_ScreenshotOptions(INT32 choice) static void M_DrawJoystick(void) { - INT32 i; + INT32 i, compareval2, compareval; - M_DrawGenericMenu(); + // draw title (or big pic) + M_DrawMenuTitle(); - for (i = 0;i < 7; i++) + for (i = 0; i <= MAX_JOYSTICKS; i++) // See MAX_JOYSTICKS { M_DrawTextBox(OP_JoystickSetDef.x-8, OP_JoystickSetDef.y+LINEHEIGHT*i-12, 28, 1); - //M_DrawSaveLoadBorder(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i); + //M_DrawSaveLoadBorder(OP_JoystickSetDef.x+4, OP_JoystickSetDef.y+1+LINEHEIGHT*i); - if ((setupcontrols_secondaryplayer && (i == cv_usejoystick2.value)) - || (!setupcontrols_secondaryplayer && (i == cv_usejoystick.value))) +#ifdef JOYSTICK_HOTPLUG + if (atoi(cv_usejoystick2.string) > I_NumJoys()) + compareval2 = atoi(cv_usejoystick2.string); + else + compareval2 = cv_usejoystick2.value; + + if (atoi(cv_usejoystick.string) > I_NumJoys()) + compareval = atoi(cv_usejoystick.string); + else + compareval = cv_usejoystick.value; +#else + compareval2 = cv_usejoystick2.value; + compareval = cv_usejoystick.value; +#endif + + if ((setupcontrols_secondaryplayer && (i == compareval2)) + || (!setupcontrols_secondaryplayer && (i == compareval))) V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,V_GREENMAP,joystickInfo[i]); else V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,0,joystickInfo[i]); + + if (i == itemOn) + { + V_DrawScaledPatch(currentMenu->x - 24, OP_JoystickSetDef.y+LINEHEIGHT*i-4, 0, + W_CachePatchName("M_CURSOR", PU_PATCH)); + } } } -static void M_SetupJoystickMenu(INT32 choice) +void M_SetupJoystickMenu(INT32 choice) { INT32 i = 0; const char *joyNA = "Unavailable"; @@ -7395,12 +11536,27 @@ static void M_SetupJoystickMenu(INT32 choice) strcpy(joystickInfo[i], "None"); - for (i = 1; i < 8; i++) + for (i = 1; i <= MAX_JOYSTICKS; i++) { if (i <= n && (I_GetJoyName(i)) != NULL) strncpy(joystickInfo[i], I_GetJoyName(i), 28); else strcpy(joystickInfo[i], joyNA); + +#ifdef JOYSTICK_HOTPLUG + // We use cv_usejoystick.string as the USER-SET var + // and cv_usejoystick.value as the INTERNAL var + // + // In practice, if cv_usejoystick.string == 0, this overrides + // cv_usejoystick.value and always disables + // + // Update cv_usejoystick.string here so that the user can + // properly change this value. + if (i == cv_usejoystick.value) + CV_SetValue(&cv_usejoystick, i); + if (i == cv_usejoystick2.value) + CV_SetValue(&cv_usejoystick2, i); +#endif } M_SetupNextMenu(&OP_JoystickSetDef); @@ -7410,6 +11566,10 @@ static void M_Setup1PJoystickMenu(INT32 choice) { setupcontrols_secondaryplayer = false; OP_JoystickSetDef.prevMenu = &OP_Joystick1Def; + OP_JoystickSetDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); + OP_JoystickSetDef.menuid &= ~(((1 << MENUBITS) - 1) << (MENUBITS*2)); + OP_JoystickSetDef.menuid |= MN_OP_P1CONTROLS << MENUBITS; + OP_JoystickSetDef.menuid |= MN_OP_P1JOYSTICK << (MENUBITS*2); M_SetupJoystickMenu(choice); } @@ -7417,15 +11577,85 @@ static void M_Setup2PJoystickMenu(INT32 choice) { setupcontrols_secondaryplayer = true; OP_JoystickSetDef.prevMenu = &OP_Joystick2Def; + OP_JoystickSetDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); + OP_JoystickSetDef.menuid &= ~(((1 << MENUBITS) - 1) << (MENUBITS*2)); + OP_JoystickSetDef.menuid |= MN_OP_P2CONTROLS << MENUBITS; + OP_JoystickSetDef.menuid |= MN_OP_P2JOYSTICK << (MENUBITS*2); M_SetupJoystickMenu(choice); } static void M_AssignJoystick(INT32 choice) { +#ifdef JOYSTICK_HOTPLUG + INT32 oldchoice, oldstringchoice; + INT32 numjoys = I_NumJoys(); + + if (setupcontrols_secondaryplayer) + { + oldchoice = oldstringchoice = atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value; + CV_SetValue(&cv_usejoystick2, choice); + + // Just in case last-minute changes were made to cv_usejoystick.value, + // update the string too + // But don't do this if we're intentionally setting higher than numjoys + if (choice <= numjoys) + { + CV_SetValue(&cv_usejoystick2, cv_usejoystick2.value); + + // reset this so the comparison is valid + if (oldchoice > numjoys) + oldchoice = cv_usejoystick2.value; + + if (oldchoice != choice) + { + if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device + CV_SetValue(&cv_usejoystick2, (oldstringchoice > numjoys ? oldstringchoice : oldchoice)); + + if (oldstringchoice == + (atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value)) + M_StartMessage("This gamepad is used by another\n" + "player. Reset the gamepad\n" + "for that player first.\n\n" + "(Press a key)\n", NULL, MM_NOTHING); + } + } + } + else + { + oldchoice = oldstringchoice = atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value; + CV_SetValue(&cv_usejoystick, choice); + + // Just in case last-minute changes were made to cv_usejoystick.value, + // update the string too + // But don't do this if we're intentionally setting higher than numjoys + if (choice <= numjoys) + { + CV_SetValue(&cv_usejoystick, cv_usejoystick.value); + + // reset this so the comparison is valid + if (oldchoice > numjoys) + oldchoice = cv_usejoystick.value; + + if (oldchoice != choice) + { + if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device + CV_SetValue(&cv_usejoystick, (oldstringchoice > numjoys ? oldstringchoice : oldchoice)); + + if (oldstringchoice == + (atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value)) + M_StartMessage("This gamepad is used by another\n" + "player. Reset the gamepad\n" + "for that player first.\n\n" + "(Press a key)\n", NULL, MM_NOTHING); + } + } + } +#else if (setupcontrols_secondaryplayer) CV_SetValue(&cv_usejoystick2, choice); else CV_SetValue(&cv_usejoystick, choice); +#endif } // ============= @@ -7439,16 +11669,28 @@ static void M_Setup1PControlsMenu(INT32 choice) setupcontrols = gamecontrol; // was called from main Options (for console player, then) currentMenu->lastOn = itemOn; - // Unhide the three non-P2 controls - OP_MPControlsMenu[0].status = IT_CALL|IT_STRING2; - OP_MPControlsMenu[1].status = IT_CALL|IT_STRING2; - OP_MPControlsMenu[2].status = IT_CALL|IT_STRING2; - // Unide the pause/console controls too - OP_MiscControlsMenu[3].status = IT_CALL|IT_STRING2; - OP_MiscControlsMenu[4].status = IT_CALL|IT_STRING2; + // Unhide the nine non-P2 controls and their headers + //OP_ChangeControlsMenu[18+0].status = IT_HEADER; + //OP_ChangeControlsMenu[18+1].status = IT_SPACE; + // ... + OP_ChangeControlsMenu[18+2].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[18+3].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[18+4].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[18+5].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[18+6].status = IT_CALL|IT_STRING2; + //OP_ChangeControlsMenu[18+7].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[18+8].status = IT_CALL|IT_STRING2; + // ... + OP_ChangeControlsMenu[27+0].status = IT_HEADER; + OP_ChangeControlsMenu[27+1].status = IT_SPACE; + // ... + OP_ChangeControlsMenu[27+2].status = IT_CALL|IT_STRING2; + OP_ChangeControlsMenu[27+3].status = IT_CALL|IT_STRING2; - OP_ControlListDef.prevMenu = &OP_P1ControlsDef; - M_SetupNextMenu(&OP_ControlListDef); + OP_ChangeControlsDef.prevMenu = &OP_P1ControlsDef; + OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove first level (<< 6) + OP_ChangeControlsDef.menuid |= MN_OP_P1CONTROLS << MENUBITS; // combine first level (<< 6) + M_SetupNextMenu(&OP_ChangeControlsDef); } static void M_Setup2PControlsMenu(INT32 choice) @@ -7458,63 +11700,151 @@ static void M_Setup2PControlsMenu(INT32 choice) setupcontrols = gamecontrolbis; currentMenu->lastOn = itemOn; - // Hide the three non-P2 controls - OP_MPControlsMenu[0].status = IT_GRAYEDOUT2; - OP_MPControlsMenu[1].status = IT_GRAYEDOUT2; - OP_MPControlsMenu[2].status = IT_GRAYEDOUT2; - // Hide the pause/console and system menu controls too - OP_MiscControlsMenu[3].status = IT_GRAYEDOUT2; - OP_MiscControlsMenu[6].status = IT_GRAYEDOUT2; - OP_MiscControlsMenu[8].status = IT_GRAYEDOUT2; + // Hide the nine non-P2 controls and their headers + //OP_ChangeControlsMenu[18+0].status = IT_GRAYEDOUT2; + //OP_ChangeControlsMenu[18+1].status = IT_GRAYEDOUT2; + // ... + OP_ChangeControlsMenu[18+2].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[18+3].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[18+4].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[18+5].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[18+6].status = IT_GRAYEDOUT2; + //OP_ChangeControlsMenu[18+7].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[18+8].status = IT_GRAYEDOUT2; + // ... + OP_ChangeControlsMenu[27+0].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[27+1].status = IT_GRAYEDOUT2; + // ... + OP_ChangeControlsMenu[27+2].status = IT_GRAYEDOUT2; + OP_ChangeControlsMenu[27+3].status = IT_GRAYEDOUT2; - OP_ControlListDef.prevMenu = &OP_P2ControlsDef; - M_SetupNextMenu(&OP_ControlListDef); + OP_ChangeControlsDef.prevMenu = &OP_P2ControlsDef; + OP_ChangeControlsDef.menuid &= ~(((1 << MENUBITS) - 1) << MENUBITS); // remove first level (<< 6) + OP_ChangeControlsDef.menuid |= MN_OP_P2CONTROLS << MENUBITS; // combine first level (<< 6) + M_SetupNextMenu(&OP_ChangeControlsDef); } +#define controlheight 18 + // Draws the Customise Controls menu static void M_DrawControl(void) { char tmp[50]; - INT32 i; + INT32 x, y, i, max, cursory = 0, iter; INT32 keys[2]; - // draw title, strings and submenu - M_DrawGenericMenu(); + x = currentMenu->x; + y = currentMenu->y; - M_CentreText(30, - (setupcontrols_secondaryplayer ? "SET CONTROLS FOR SECONDARY PLAYER" : - "PRESS ENTER TO CHANGE, BACKSPACE TO CLEAR")); + /*i = itemOn - (controlheight/2); + if (i < 0) + i = 0; + */ - for (i = 0;i < currentMenu->numitems;i++) + iter = (controlheight/2); + for (i = itemOn; ((iter || currentMenu->menuitems[i].status == IT_GRAYEDOUT2) && i > 0); i--) { - if (currentMenu->menuitems[i].status != IT_CONTROL) + if (currentMenu->menuitems[i].status != IT_GRAYEDOUT2) + iter--; + } + if (currentMenu->menuitems[i].status == IT_GRAYEDOUT2) + i--; + + iter += (controlheight/2); + for (max = itemOn; (iter && max < currentMenu->numitems); max++) + { + if (currentMenu->menuitems[max].status != IT_GRAYEDOUT2) + iter--; + } + + if (iter) + { + iter += (controlheight/2); + for (i = itemOn; ((iter || currentMenu->menuitems[i].status == IT_GRAYEDOUT2) && i > 0); i--) + { + if (currentMenu->menuitems[i].status != IT_GRAYEDOUT2) + iter--; + } + } + + /*max = i + controlheight; + if (max > currentMenu->numitems) + { + max = currentMenu->numitems; + if (max < controlheight) + i = 0; + else + i = max - controlheight; + }*/ + + // draw title (or big pic) + M_DrawMenuTitle(); + + if (tutorialmode && tutorialgcs) + { + if ((gametic / TICRATE) % 2) + M_CentreText(30, "\202EXIT THE TUTORIAL TO CHANGE THE CONTROLS"); + else + M_CentreText(30, "EXIT THE TUTORIAL TO CHANGE THE CONTROLS"); + } + else + M_CentreText(30, + (setupcontrols_secondaryplayer ? "SET CONTROLS FOR SECONDARY PLAYER" : + "PRESS ENTER TO CHANGE, BACKSPACE TO CLEAR")); + + if (i) + V_DrawString(currentMenu->x - 16, y-(skullAnimCounter/5), V_YELLOWMAP, "\x1A"); // up arrow + if (max != currentMenu->numitems) + V_DrawString(currentMenu->x - 16, y+(SMALLLINEHEIGHT*(controlheight-1))+(skullAnimCounter/5), V_YELLOWMAP, "\x1B"); // down arrow + + for (; i < max; i++) + { + if (currentMenu->menuitems[i].status == IT_GRAYEDOUT2) continue; - keys[0] = setupcontrols[currentMenu->menuitems[i].alphaKey][0]; - keys[1] = setupcontrols[currentMenu->menuitems[i].alphaKey][1]; + if (i == itemOn) + cursory = y; - tmp[0] ='\0'; - if (keys[0] == KEY_NULL && keys[1] == KEY_NULL) + if (currentMenu->menuitems[i].status == IT_CONTROL) { - strcpy(tmp, "---"); + V_DrawString(x, y, ((i == itemOn) ? V_YELLOWMAP : 0), currentMenu->menuitems[i].text); + keys[0] = setupcontrols[currentMenu->menuitems[i].alphaKey][0]; + keys[1] = setupcontrols[currentMenu->menuitems[i].alphaKey][1]; + + tmp[0] ='\0'; + if (keys[0] == KEY_NULL && keys[1] == KEY_NULL) + { + strcpy(tmp, "---"); + } + else + { + if (keys[0] != KEY_NULL) + strcat (tmp, G_KeynumToString (keys[0])); + + if (keys[0] != KEY_NULL && keys[1] != KEY_NULL) + strcat(tmp," or "); + + if (keys[1] != KEY_NULL) + strcat (tmp, G_KeynumToString (keys[1])); + + + } + V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, y, V_YELLOWMAP, tmp); } - else - { - if (keys[0] != KEY_NULL) - strcat (tmp, G_KeynumToString (keys[0])); + /*else if (currentMenu->menuitems[i].status == IT_GRAYEDOUT2) + V_DrawString(x, y, V_TRANSLUCENT, currentMenu->menuitems[i].text);*/ + else if ((currentMenu->menuitems[i].status == IT_HEADER) && (i != max-1)) + M_DrawLevelPlatterHeader(y, currentMenu->menuitems[i].text, true, false); - if (keys[0] != KEY_NULL && keys[1] != KEY_NULL) - strcat(tmp," or "); - - if (keys[1] != KEY_NULL) - strcat (tmp, G_KeynumToString (keys[1])); - - - } - V_DrawRightAlignedString(BASEVIDWIDTH-currentMenu->x, currentMenu->y + i*8, V_YELLOWMAP, tmp); + y += SMALLLINEHEIGHT; } + + V_DrawScaledPatch(currentMenu->x - 20, cursory, 0, + W_CachePatchName("M_CURSOR", PU_PATCH)); } +#undef controlbuffer + static INT32 controltochange; static char controltochangetext[33]; @@ -7593,7 +11923,7 @@ static void M_ChangecontrolResponse(event_t *ev) menu_t *prev = currentMenu->prevMenu; if (controltochange == gc_pause) - sprintf(tmp, M_GetText("The \x82Pause Key \x80is enabled, but \nyou may select another key. \n\nHit another key for\n%s\nESC for Cancel"), + sprintf(tmp, M_GetText("The \x82Pause Key \x80is enabled, but \nit cannot be used to retry runs \nduring Record Attack. \n\nHit another key for\n%s\nESC for Cancel"), controltochangetext); else sprintf(tmp, M_GetText("The \x82Pause Key \x80is enabled, but \nit is not configurable. \n\nHit another key for\n%s\nESC for Cancel"), @@ -7617,6 +11947,9 @@ static void M_ChangeControl(INT32 choice) // If you change the below message, then change the size of this buffer! static char tmp[68]; + if (tutorialmode && tutorialgcs) // don't allow control changes if temp control override is active + return; + controltochange = currentMenu->menuitems[choice].alphaKey; sprintf(tmp, M_GetText("Hit the new key for\n%s\nESC for Cancel"), currentMenu->menuitems[choice].text); @@ -7625,6 +11958,88 @@ static void M_ChangeControl(INT32 choice) M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER); } +static void M_Setup1PPlaystyleMenu(INT32 choice) +{ + (void)choice; + + playstyle_activeplayer = 0; + OP_PlaystyleDef.prevMenu = &OP_P1ControlsDef; + M_SetupNextMenu(&OP_PlaystyleDef); +} + +static void M_Setup2PPlaystyleMenu(INT32 choice) +{ + (void)choice; + + playstyle_activeplayer = 1; + OP_PlaystyleDef.prevMenu = &OP_P2ControlsDef; + M_SetupNextMenu(&OP_PlaystyleDef); +} + +static void M_DrawPlaystyleMenu(void) +{ + size_t i; + + for (i = 0; i < 4; i++) + { + if (i != 3) + V_DrawCenteredString((i+1)*BASEVIDWIDTH/4, 20, (i == playstyle_currentchoice) ? V_YELLOWMAP : 0, PlaystyleNames[i]); + + if (i == playstyle_currentchoice) + { + V_DrawScaledPatch((i+1)*BASEVIDWIDTH/4 - 8, 10, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); + V_DrawString(30, 50, V_ALLOWLOWERCASE, PlaystyleDesc[i]); + } + } +} + +static void M_HandlePlaystyleMenu(INT32 choice) +{ + switch (choice) + { + case KEY_ESCAPE: + case KEY_BACKSPACE: + M_SetupNextMenu(currentMenu->prevMenu); + break; + + case KEY_ENTER: + S_StartSound(NULL, sfx_menu1); + CV_SetValue((playstyle_activeplayer ? &cv_directionchar[1] : &cv_directionchar[0]), playstyle_currentchoice ? 1 : 0); + CV_SetValue((playstyle_activeplayer ? &cv_useranalog[1] : &cv_useranalog[0]), playstyle_currentchoice/2); + + if (playstyle_activeplayer) + CV_UpdateCam2Dist(); + else + CV_UpdateCamDist(); + + M_SetupNextMenu(currentMenu->prevMenu); + break; + + case KEY_LEFTARROW: + S_StartSound(NULL, sfx_menu1); + playstyle_currentchoice = (playstyle_currentchoice+2)%3; + break; + + case KEY_RIGHTARROW: + S_StartSound(NULL, sfx_menu1); + playstyle_currentchoice = (playstyle_currentchoice+1)%3; + break; + } +} + +static void M_DrawCameraOptionsMenu(void) +{ + M_DrawGenericScrollMenu(); + + if (gamestate == GS_LEVEL && (paused || P_AutoPause())) + { + if (currentMenu == &OP_Camera2OptionsDef && splitscreen && camera2.chase) + P_MoveChaseCamera(&players[secondarydisplayplayer], &camera2, false); + if (currentMenu == &OP_CameraOptionsDef && camera.chase) + P_MoveChaseCamera(&players[displayplayer], &camera, false); + } +} + // =============== // VIDEO MODE MENU // =============== @@ -7715,6 +12130,20 @@ static void M_VideoModeMenu(INT32 choice) M_SetupNextMenu(&OP_VideoModeDef); } +static void M_DrawMainVideoMenu(void) +{ + M_DrawGenericScrollMenu(); + if (itemOn < 8) // where it starts to go offscreen; change this number if you change the layout of the video menu + { + INT32 y = currentMenu->y+currentMenu->menuitems[1].alphaKey*2; + if (itemOn == 7) + y -= 10; + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, y, + (SCR_IsAspectCorrect(vid.width, vid.height) ? V_GREENMAP : V_YELLOWMAP), + va("%dx%d", vid.width, vid.height)); + } +} + // Draw the video modes list, a-la-Quake static void M_DrawVideoMode(void) { @@ -7773,10 +12202,10 @@ static void M_DrawVideoMode(void) V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 138, V_GREENMAP, "Green modes are recommended."); - V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 150, + V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 146, V_YELLOWMAP, "Other modes may have visual errors."); V_DrawCenteredString(BASEVIDWIDTH/2, OP_VideoModeDef.y + 158, - V_YELLOWMAP, "Use at own risk."); + V_YELLOWMAP, "Larger modes may have performance issues."); } // Draw the cursor for the VidMode menu @@ -7784,7 +12213,135 @@ static void M_DrawVideoMode(void) j = OP_VideoModeDef.y + 14 + ((vidm_selected % vidm_column_size)*8); V_DrawScaledPatch(i - 8, j, 0, - W_CachePatchName("M_CURSOR", PU_CACHE)); + W_CachePatchName("M_CURSOR", PU_PATCH)); +} + +// Just M_DrawGenericScrollMenu but showing a backing behind the headers. +static void M_DrawColorMenu(void) +{ + INT32 x, y, i, max, tempcentery, cursory = 0; + + // DRAW MENU + x = currentMenu->x; + y = currentMenu->y; + + V_DrawFill(19 , y-4, 47, 1, 35); + V_DrawFill(19+( 47), y-4, 47, 1, 73); + V_DrawFill(19+(2*47), y-4, 47, 1, 112); + V_DrawFill(19+(3*47), y-4, 47, 1, 255); + V_DrawFill(19+(4*47), y-4, 47, 1, 152); + V_DrawFill(19+(5*47), y-4, 46, 1, 181); + + V_DrawFill(300, y-4, 1, 1, 26); + V_DrawFill( 19, y-3, 282, 1, 26); + + if ((currentMenu->menuitems[itemOn].alphaKey*2 - currentMenu->menuitems[0].alphaKey*2) <= scrollareaheight) + tempcentery = currentMenu->y - currentMenu->menuitems[0].alphaKey*2; + else if ((currentMenu->menuitems[currentMenu->numitems-1].alphaKey*2 - currentMenu->menuitems[itemOn].alphaKey*2) <= scrollareaheight) + tempcentery = currentMenu->y - currentMenu->menuitems[currentMenu->numitems-1].alphaKey*2 + 2*scrollareaheight; + else + tempcentery = currentMenu->y - currentMenu->menuitems[itemOn].alphaKey*2 + scrollareaheight; + + for (i = 0; i < currentMenu->numitems; i++) + { + if (currentMenu->menuitems[i].status != IT_DISABLED && currentMenu->menuitems[i].alphaKey*2 + tempcentery >= currentMenu->y) + break; + } + + for (max = currentMenu->numitems; max > 0; max--) + { + if (currentMenu->menuitems[max].status != IT_DISABLED && currentMenu->menuitems[max-1].alphaKey*2 + tempcentery <= (currentMenu->y + 2*scrollareaheight)) + break; + } + + if (i) + V_DrawString(currentMenu->x - 20, currentMenu->y - (skullAnimCounter/5), V_YELLOWMAP, "\x1A"); // up arrow + if (max != currentMenu->numitems) + V_DrawString(currentMenu->x - 20, currentMenu->y + 2*scrollareaheight + (skullAnimCounter/5), V_YELLOWMAP, "\x1B"); // down arrow + + // draw title (or big pic) + M_DrawMenuTitle(); + + for (; i < max; i++) + { + y = currentMenu->menuitems[i].alphaKey*2 + tempcentery; + if (i == itemOn) + cursory = y; + switch (currentMenu->menuitems[i].status & IT_DISPLAY) + { + case IT_PATCH: + case IT_DYBIGSPACE: + case IT_BIGSLIDER: + case IT_STRING2: + case IT_DYLITLSPACE: + case IT_GRAYPATCH: + case IT_TRANSTEXT2: + // unsupported + break; + case IT_NOTHING: + break; + case IT_STRING: + case IT_WHITESTRING: + if (i != itemOn && (currentMenu->menuitems[i].status & IT_DISPLAY)==IT_STRING) + V_DrawString(x, y, 0, currentMenu->menuitems[i].text); + else + V_DrawString(x, y, V_YELLOWMAP, currentMenu->menuitems[i].text); + + // Cvar specific handling + switch (currentMenu->menuitems[i].status & IT_TYPE) + case IT_CVAR: + { + consvar_t *cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + switch (currentMenu->menuitems[i].status & IT_CVARTYPE) + { + case IT_CV_SLIDER: + M_DrawSlider(x, y, cv, (i == itemOn)); + case IT_CV_NOPRINT: // color use this + case IT_CV_INVISSLIDER: // monitor toggles use this + break; + case IT_CV_STRING: + if (y + 12 > (currentMenu->y + 2*scrollareaheight)) + break; + M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1); + V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string); + if (skullAnimCounter < 4 && i == itemOn) + V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12, + '_' | 0x80, false); + y += 16; + break; + default: + V_DrawRightAlignedString(BASEVIDWIDTH - x, y, + ((cv->flags & CV_CHEAT) && !CV_IsSetToDefault(cv) ? V_REDMAP : V_YELLOWMAP), cv->string); + if (i == itemOn) + { + V_DrawCharacter(BASEVIDWIDTH - x - 10 - V_StringWidth(cv->string, 0) - (skullAnimCounter/5), y, + '\x1C' | V_YELLOWMAP, false); + V_DrawCharacter(BASEVIDWIDTH - x + 2 + (skullAnimCounter/5), y, + '\x1D' | V_YELLOWMAP, false); + } + break; + } + break; + } + break; + case IT_TRANSTEXT: + V_DrawString(x, y, V_TRANSLUCENT, currentMenu->menuitems[i].text); + break; + case IT_QUESTIONMARKS: + V_DrawString(x, y, V_TRANSLUCENT|V_OLDSPACING, M_CreateSecretMenuOption(currentMenu->menuitems[i].text)); + break; + case IT_HEADERTEXT: + //V_DrawString(x-16, y, V_YELLOWMAP, currentMenu->menuitems[i].text); + V_DrawFill(19, y, 281, 9, currentMenu->menuitems[i+1].alphaKey); + V_DrawFill(300, y, 1, 9, 26); + M_DrawLevelPlatterHeader(y - (lsheadingheight - 12), currentMenu->menuitems[i].text, false, false); + break; + } + } + + // DRAW THE SKULL CURSOR + V_DrawScaledPatch(currentMenu->x - 24, cursory, 0, + W_CachePatchName("M_CURSOR", PU_PATCH)); } // special menuitem key handler for video mode list @@ -7860,6 +12417,20 @@ static void M_HandleVideoMode(INT32 ch) } } +static void M_DrawScreenshotMenu(void) +{ + M_DrawGenericScrollMenu(); +#ifdef HWRENDER + if ((rendermode == render_opengl) && (itemOn < 7)) // where it starts to go offscreen; change this number if you change the layout of the screenshot menu + { + INT32 y = currentMenu->y+currentMenu->menuitems[op_screenshot_colorprofile].alphaKey*2; + if (itemOn == 6) + y -= 10; + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, y, V_REDMAP, "Yes"); + } +#endif +} + // =============== // Monitor Toggles // =============== @@ -7875,7 +12446,8 @@ static void M_DrawMonitorToggles(void) // Assumes all are cvar type. for (i = 0; i < currentMenu->numitems; ++i) { - cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + if (!(currentMenu->menuitems[i].status & IT_CVAR) || !(cv = (consvar_t *)currentMenu->menuitems[i].itemaction)) + continue; sum += cv->value; if (!CV_IsSetToDefault(cv)) @@ -7884,10 +12456,11 @@ static void M_DrawMonitorToggles(void) for (i = 0; i < currentMenu->numitems; ++i) { - cv = (consvar_t *)currentMenu->menuitems[i].itemaction; + if (!(currentMenu->menuitems[i].status & IT_CVAR) || !(cv = (consvar_t *)currentMenu->menuitems[i].itemaction)) + continue; y = currentMenu->y + currentMenu->menuitems[i].alphaKey; - M_DrawSlider(currentMenu->x + 20, y, cv); + M_DrawSlider(currentMenu->x + 20, y, cv, (i == itemOn)); if (!cv->value) V_DrawRightAlignedString(312, y, V_OLDSPACING|((i == itemOn) ? V_YELLOWMAP : 0), "None"); @@ -7931,6 +12504,8 @@ void M_QuitResponse(INT32 ch) return; if (!(netgame || cv_debug)) { + S_ResetCaptions(); + mrand = M_RandomKey(sizeof(quitsounds)/sizeof(INT32)); if (quitsounds[mrand]) S_StartSound(NULL, quitsounds[mrand]); @@ -7938,7 +12513,7 @@ void M_QuitResponse(INT32 ch) ptime = I_GetTime() + NEWTICRATE*2; // Shortened the quit time, used to be 2 seconds Tails 03-26-2001 while (ptime > I_GetTime()) { - V_DrawScaledPatch(0, 0, 0, W_CachePatchName("GAMEQUIT", PU_CACHE)); // Demo 3 Quit Screen Tails 06-16-2001 + V_DrawScaledPatch(0, 0, 0, W_CachePatchName("GAMEQUIT", PU_PATCH)); // Demo 3 Quit Screen Tails 06-16-2001 I_FinishUpdate(); // Update the screen with the image Tails 06-19-2001 I_Sleep(); } @@ -7978,20 +12553,6 @@ static void M_OGL_DrawFogMenu(void) my + currentMenu->menuitems[FOG_COLOR_ITEM].alphaKey, '_' | 0x80,false); } -// ===================== -// M_OGL_DrawColorMenu() -// ===================== -static void M_OGL_DrawColorMenu(void) -{ - INT32 mx, my; - - mx = currentMenu->x; - my = currentMenu->y; - M_DrawGenericMenu(); // use generic drawer for cursor, items and title - V_DrawString(mx, my + currentMenu->menuitems[0].alphaKey - 10, - V_YELLOWMAP, "Gamma correction"); -} - //=================== // M_HandleFogColor() //=================== @@ -8014,7 +12575,6 @@ static void M_HandleFogColor(INT32 choice) break; case KEY_ESCAPE: - S_StartSound(NULL, sfx_menu1); exitmenu = true; break; diff --git a/src/m_menu.h b/src/m_menu.h index eb770c194..e7270380d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2011-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,13 +15,164 @@ #ifndef __X_MENU__ #define __X_MENU__ +#include "doomstat.h" // for NUMGAMETYPES #include "d_event.h" #include "command.h" -#include "r_things.h" // for SKINNAMESIZE +#include "r_skins.h" // for SKINNAMESIZE +#include "f_finale.h" // for ttmode_enum // // MENUS // + +// If menu hierarchies go deeper, change this up to 5. +// Zero-based, inclusive. +#define NUMMENULEVELS 3 +#define MENUBITS 6 + +// Menu IDs sectioned by numeric places to signify hierarchy +typedef enum +{ + MN_NONE, + + MN_MAIN, + + // Single Player + MN_SP_MAIN, + + MN_SP_LOAD, + MN_SP_PLAYER, + + MN_SP_LEVELSELECT, + MN_SP_LEVELSTATS, + + MN_SP_TIMEATTACK, + MN_SP_TIMEATTACK_LEVELSELECT, + MN_SP_GUESTREPLAY, + MN_SP_REPLAY, + MN_SP_GHOST, + + MN_SP_NIGHTSATTACK, + MN_SP_NIGHTS_LEVELSELECT, + MN_SP_NIGHTS_GUESTREPLAY, + MN_SP_NIGHTS_REPLAY, + MN_SP_NIGHTS_GHOST, + + // Multiplayer + MN_MP_MAIN, + MN_MP_SPLITSCREEN, // SplitServer + MN_MP_SERVER, + MN_MP_CONNECT, + MN_MP_ROOM, + MN_MP_PLAYERSETUP, // MP_PlayerSetupDef shared with SPLITSCREEN if #defined NONET + MN_MP_SERVER_OPTIONS, + + // Options + MN_OP_MAIN, + + MN_OP_P1CONTROLS, + MN_OP_CHANGECONTROLS, // OP_ChangeControlsDef shared with P2 + MN_OP_P1MOUSE, + MN_OP_P1JOYSTICK, + MN_OP_JOYSTICKSET, // OP_JoystickSetDef shared with P2 + MN_OP_P1CAMERA, + + MN_OP_P2CONTROLS, + MN_OP_P2MOUSE, + MN_OP_P2JOYSTICK, + MN_OP_P2CAMERA, + + MN_OP_PLAYSTYLE, + + MN_OP_VIDEO, + MN_OP_VIDEOMODE, + MN_OP_COLOR, + MN_OP_OPENGL, + MN_OP_OPENGL_LIGHTING, + MN_OP_OPENGL_FOG, + MN_OP_OPENGL_COLOR, + + MN_OP_SOUND, + + MN_OP_SERVER, + MN_OP_MONITORTOGGLE, + + MN_OP_DATA, + MN_OP_ADDONS, + MN_OP_SCREENSHOTS, + MN_OP_ERASEDATA, + + // Extras + MN_SR_MAIN, + MN_SR_PANDORA, + MN_SR_LEVELSELECT, + MN_SR_UNLOCKCHECKLIST, + MN_SR_EMBLEMHINT, + MN_SR_PLAYER, + MN_SR_SOUNDTEST, + + // Addons (Part of MISC, but let's make it our own) + MN_AD_MAIN, + + // MISC + // MN_MESSAGE, + // MN_SPAUSE, + + // MN_MPAUSE, + // MN_SCRAMBLETEAM, + // MN_CHANGETEAM, + // MN_CHANGELEVEL, + + // MN_MAPAUSE, + // MN_HELP, + + MN_SPECIAL, + NUMMENUTYPES, +} menutype_t; // up to 63; MN_SPECIAL = 53 + +typedef struct +{ + char bgname[8]; // name for background gfx lump; lays over titlemap if this is set + SINT8 fadestrength; // darken background when displaying this menu, strength 0-31 or -1 for undefined + INT32 bgcolor; // fill color, overrides bg name. -1 means follow bg name rules. + INT32 titlescrollxspeed; // background gfx scroll per menu; inherits global setting + INT32 titlescrollyspeed; // y scroll + boolean bghide; // for titlemaps, hide the background. + + SINT8 hidetitlepics; // hide title gfx per menu; -1 means undefined, inherits global setting + ttmode_enum ttmode; // title wing animation mode; default TTMODE_OLD + UINT8 ttscale; // scale of title wing gfx (FRACUNIT / ttscale); -1 means undefined, inherits global setting + char ttname[9]; // lump name of title wing gfx. If name length is <= 6, engine will attempt to load numbered frames (TTNAMExx) + INT16 ttx; // X position of title wing + INT16 tty; // Y position of title wing + INT16 ttloop; // # frame to loop; -1 means dont loop + UINT16 tttics; // # of tics per frame + + char musname[7]; ///< Music track to play. "" for no music. + UINT16 mustrack; ///< Subsong to play. Only really relevant for music modules and specific formats supported by GME. 0 to ignore. + boolean muslooping; ///< Loop the music + boolean musstop; ///< Don't play any music + boolean musignore; ///< Let the current music keep playing + + boolean enterbubble; // run all entrance line execs after common ancestor and up to child. If false, only run the child's exec + boolean exitbubble; // run all exit line execs from child and up to before common ancestor. If false, only run the child's exec + INT32 entertag; // line exec to run on menu enter, if titlemap + INT32 exittag; // line exec to run on menu exit, if titlemap + INT16 enterwipe; // wipe type to run on menu enter, -1 means default + INT16 exitwipe; // wipe type to run on menu exit, -1 means default +} menupres_t; + +extern menupres_t menupres[NUMMENUTYPES]; +extern UINT32 prevMenuId; +extern UINT32 activeMenuId; + +void M_InitMenuPresTables(void); +UINT8 M_GetYoungestChildMenu(void); +void M_ChangeMenuMusic(const char *defaultmusname, boolean defaultmuslooping); +void M_SetMenuCurBackground(const char *defaultname); +void M_SetMenuCurFadeValue(UINT8 defaultvalue); +void M_SetMenuCurTitlePics(void); + // Called by main loop, // saves config file and calls I_Quit when user exits. // Even when the menu is not displayed, @@ -38,6 +189,9 @@ void M_Drawer(void); // Called by D_SRB2Main, loads the config file. void M_Init(void); +// Called by D_SRB2Main also, sets up the playermenu and description tables. +void M_InitCharacterTables(void); + // Called by intro code to force menu up upon a keypress, // does nothing if menu is already up. void M_StartControlPanel(void); @@ -66,20 +220,20 @@ void M_StartMessage(const char *string, void *routine, menumessagetype_t itemtyp // Called by linux_x/i_video_xshm.c void M_QuitResponse(INT32 ch); -// Determines whether to show a level in the list +// Determines whether to show a level in the list (platter version does not need to be exposed) boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); - // flags for items in the menu // menu handle (what we do when key is pressed -#define IT_TYPE 14 // (2+4+8) +#define IT_TYPE 15 // (1+2+4+8) #define IT_CALL 0 // call the function +#define IT_SPACE 1 // no handling #define IT_ARROWS 2 // call function with 0 for left arrow and 1 for right arrow in param #define IT_KEYHANDLER 4 // call with the key in param #define IT_SUBMENU 6 // go to sub menu #define IT_CVAR 8 // handle as a cvar -#define IT_SPACE 10 // no handling -#define IT_MSGHANDLER 12 // same as key but with event and sometime can handle y/n key (special for message +#define IT_PAIR 11 // no handling, define both sides of text +#define IT_MSGHANDLER 12 // same as key but with event and sometime can handle y/n key (special for message) #define IT_DISPLAY (48+64+128) // 16+32+64+128 #define IT_NOTHING 0 // space @@ -105,6 +259,8 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); #define IT_CV_NOPRINT 1536 #define IT_CV_NOMOD 2048 #define IT_CV_INVISSLIDER 2560 +#define IT_CV_INTEGERSTEP 4096 // if IT_CV_NORMAL and cvar is CV_FLOAT, modify it by 1 instead of 0.0625 +#define IT_CV_FLOATSLIDER 4608 // IT_CV_SLIDER, value modified by 0.0625 instead of 1 (for CV_FLOAT cvars) //call/submenu specific // There used to be a lot more here but ... @@ -151,10 +307,9 @@ typedef struct menuitem_s UINT8 alphaKey; } menuitem_t; -extern menuitem_t PlayerMenu[32]; - typedef struct menu_s { + UINT32 menuid; // ID to encode menu type and hierarchy const char *menutitlepic; INT16 numitems; // # of menu items struct menu_s *prevMenu; // previous menu @@ -168,19 +323,63 @@ typedef struct menu_s void M_SetupNextMenu(menu_t *menudef); void M_ClearMenus(boolean callexitmenufunc); +// Maybe this goes here????? Who knows. +boolean M_MouseNeeded(void); + extern menu_t *currentMenu; extern menu_t MainDef; extern menu_t SP_LoadDef; +// Call upon joystick hotplug +void M_SetupJoystickMenu(INT32 choice); +extern menu_t OP_JoystickSetDef; + // Stuff for customizing the player select screen typedef struct { + boolean used; char notes[441]; char picname[8]; char skinname[SKINNAMESIZE*2+2]; // skin&skin\0 + patch_t *charpic; + UINT8 prev; + UINT8 next; + + // new character select + char displayname[SKINNAMESIZE+1]; + SINT8 skinnum[2]; + UINT8 oppositecolor; + char nametag[8]; + patch_t *namepic; + UINT8 tagtextcolor; + UINT8 tagoutlinecolor; } description_t; +// level select platter +typedef struct +{ + char header[22+5]; // mapheader_t lvltttl max length + " ZONE" + INT32 maplist[3]; + char mapnames[3][17+1]; + boolean mapavailable[4]; // mapavailable[3] == wide or not +} levelselectrow_t; + +typedef struct +{ + UINT8 numrows; + levelselectrow_t *rows; +} levelselect_t; +// experimental level select end + +// descriptions for gametype select screen +typedef struct +{ + UINT8 col[2]; + char notes[441]; +} gtdesc_t; +extern gtdesc_t gametypedesc[NUMGAMETYPES]; + // mode descriptions for video mode menu typedef struct { @@ -192,35 +391,42 @@ typedef struct // savegame struct for save game menu typedef struct { - char playername[37]; char levelname[32]; - UINT8 actnum; - UINT8 skincolor; UINT8 skinnum; UINT8 botskin; - UINT8 botcolor; UINT8 numemeralds; + UINT8 numgameovers; INT32 lives; INT32 continues; INT32 gamemap; - UINT8 netgame; } saveinfo_t; -extern description_t description[32]; +extern description_t description[MAXSKINS]; +extern consvar_t cv_showfocuslost; extern consvar_t cv_newgametype, cv_nextmap, cv_chooseskin, cv_serversort; extern CV_PossibleValue_t gametype_cons_t[]; extern INT16 startmap; extern INT32 ultimate_selectable; +extern INT16 char_on, startchar; -#define MAXSAVEGAMES 31 //note: last save game is "no save" -#define NOSAVESLOT MAXSAVEGAMES-1 //slot where Play Without Saving appears +#define MAXSAVEGAMES 31 +#define NOSAVESLOT 0 //slot where Play Without Saving appears + +#define BwehHehHe() S_StartSound(NULL, sfx_bewar1+M_RandomKey(4)) // Bweh heh he + +void M_TutorialSaveControlResponse(INT32 ch); void M_ForceSaveSlotSelected(INT32 sslot); void M_CheatActivationResponder(INT32 ch); +void M_ModeAttackRetry(INT32 choice); + +// Level select updating +void Nextmap_OnChange(void); + // Screenshot menu updating void Moviemode_mode_Onchange(void); void Screenshot_option_Onchange(void); @@ -228,9 +434,13 @@ void Screenshot_option_Onchange(void); // Addons menu updating void Addons_option_Onchange(void); +// Moviemode menu updating +void Moviemode_option_Onchange(void); + // These defines make it a little easier to make menus -#define DEFAULTMENUSTYLE(header, source, prev, x, y)\ +#define DEFAULTMENUSTYLE(id, header, source, prev, x, y)\ {\ + id,\ header,\ sizeof(source)/sizeof(menuitem_t),\ prev,\ @@ -241,8 +451,22 @@ void Addons_option_Onchange(void); NULL\ } +#define DEFAULTSCROLLMENUSTYLE(id, header, source, prev, x, y)\ +{\ + id,\ + header,\ + sizeof(source)/sizeof(menuitem_t),\ + prev,\ + source,\ + M_DrawGenericScrollMenu,\ + x, y,\ + 0,\ + NULL\ +} + #define PAUSEMENUSTYLE(source, x, y)\ {\ + MN_SPECIAL,\ NULL,\ sizeof(source)/sizeof(menuitem_t),\ NULL,\ @@ -253,8 +477,9 @@ void Addons_option_Onchange(void); NULL\ } -#define CENTERMENUSTYLE(header, source, prev, y)\ +#define CENTERMENUSTYLE(id, header, source, prev, y)\ {\ + id,\ header,\ sizeof(source)/sizeof(menuitem_t),\ prev,\ @@ -265,20 +490,22 @@ void Addons_option_Onchange(void); NULL\ } -#define MAPICONMENUSTYLE(header, source, prev)\ +#define MAPPLATTERMENUSTYLE(id, header, source)\ {\ + id,\ header,\ sizeof (source)/sizeof (menuitem_t),\ - prev,\ + &MainDef,\ source,\ - M_DrawServerMenu,\ - 27,40,\ + M_DrawLevelPlatterMenu,\ + 0,0,\ 0,\ NULL\ } -#define CONTROLMENUSTYLE(source, prev)\ +#define CONTROLMENUSTYLE(id, source, prev)\ {\ + id,\ "M_CONTRO",\ sizeof (source)/sizeof (menuitem_t),\ prev,\ @@ -291,6 +518,7 @@ void Addons_option_Onchange(void); #define IMAGEDEF(source)\ {\ + MN_SPECIAL,\ NULL,\ sizeof (source)/sizeof (menuitem_t),\ NULL,\ diff --git a/src/m_misc.c b/src/m_misc.c index fe5215922..920a13198 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -23,6 +23,8 @@ #include #endif +#include + // Extended map support. #include @@ -30,6 +32,7 @@ #include "g_game.h" #include "m_misc.h" #include "hu_stuff.h" +#include "st_stuff.h" #include "v_video.h" #include "z_zone.h" #include "g_input.h" @@ -57,11 +60,11 @@ typedef off_t off64_t; #endif #endif -#if defined(__MINGW32__) && ((__GNUC__ > 7) || (__GNUC__ == 6 && __GNUC_MINOR__ >= 3)) +#if defined(__MINGW32__) && ((__GNUC__ > 7) || (__GNUC__ == 6 && __GNUC_MINOR__ >= 3)) && (__GNUC__ < 8) #define PRIdS "u" #elif defined (_WIN32) #define PRIdS "Iu" -#elif defined (_PSP) || defined (_arch_dreamcast) || defined (DJGPP) || defined (_WII) || defined (_NDS) || defined (_PS3) +#elif defined (DJGPP) #define PRIdS "u" #else #define PRIdS "zu" @@ -70,12 +73,10 @@ typedef off_t off64_t; #ifdef HAVE_PNG #ifndef _MSC_VER -#ifndef _WII #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #endif -#endif #ifndef _LFS64_LARGEFILE #define _LFS64_LARGEFILE @@ -104,9 +105,14 @@ static CV_PossibleValue_t screenshot_cons_t[] = {{0, "Default"}, {1, "HOME"}, {2 consvar_t cv_screenshot_option = {"screenshot_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Screenshot_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_screenshot_folder = {"screenshot_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_screenshot_colorprofile = {"screenshot_colorprofile", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}}; consvar_t cv_moviemode = {"moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_option = {"movie_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Moviemode_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_folder = {"movie_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t zlib_mem_level_t[] = { {1, "(Min Memory) 1"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, @@ -193,7 +199,7 @@ INT32 M_MapNumber(char first, char second) // ========================================================================== // some libcs has no access function, make our own -#if defined (_WIN32_WCE) || defined (_XBOX) || defined (_WII) || defined (_PS3) +#if 0 int access(const char *path, int amode) { int accesshandle = -1; @@ -445,7 +451,8 @@ void Command_LoadConfig_f(void) // load default control G_ClearAllControlKeys(); - G_Controldefault(); + G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps], NULL, 0); + G_CopyControls(gamecontrolbis, gamecontrolbisdefault[gcs_fps], NULL, 0); // temporarily reset execversion to default CV_ToggleExecVersion(true); @@ -492,7 +499,9 @@ void M_FirstLoadConfig(void) } // load default control - G_Controldefault(); + G_DefineDefaultControls(); + G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps], NULL, 0); + G_CopyControls(gamecontrolbis, gamecontrolbisdefault[gcs_fps], NULL, 0); // register execversion here before we load any configs CV_RegisterVar(&cv_execversion); @@ -514,6 +523,12 @@ void M_FirstLoadConfig(void) // make sure I_Quit() will write back the correct config // (do not write back the config if it crash before) gameconfig_loaded = true; + + // reset to default player stuff + COM_BufAddText (va("%s \"%s\"\n",cv_skin.name,cv_defaultskin.string)); + COM_BufAddText (va("%s \"%s\"\n",cv_playercolor.name,cv_defaultplayercolor.string)); + COM_BufAddText (va("%s \"%s\"\n",cv_skin2.name,cv_defaultskin2.string)); + COM_BufAddText (va("%s \"%s\"\n",cv_playercolor2.name,cv_defaultplayercolor2.string)); } /** Saves the game configuration. @@ -580,12 +595,49 @@ void M_SaveConfig(const char *filename) // FIXME: save key aliases if ever implemented.. - CV_SaveVariables(f); - if (!dedicated) G_SaveKeySetting(f); + if (tutorialmode && tutorialgcs) + { + CV_SetValue(&cv_usemouse, tutorialusemouse); + CV_SetValue(&cv_alwaysfreelook, tutorialfreelook); + CV_SetValue(&cv_mousemove, tutorialmousemove); + CV_SetValue(&cv_analog[0], tutorialanalog); + CV_SaveVariables(f); + CV_Set(&cv_usemouse, cv_usemouse.defaultvalue); + CV_Set(&cv_alwaysfreelook, cv_alwaysfreelook.defaultvalue); + CV_Set(&cv_mousemove, cv_mousemove.defaultvalue); + CV_Set(&cv_analog[0], cv_analog[0].defaultvalue); + } + else + CV_SaveVariables(f); + + if (!dedicated) + { + if (tutorialmode && tutorialgcs) + G_SaveKeySetting(f, gamecontroldefault[gcs_custom], gamecontrolbis); // using gcs_custom as temp storage + else + G_SaveKeySetting(f, gamecontrol, gamecontrolbis); + } fclose(f); } +// ========================================================================== +// SCREENSHOTS +// ========================================================================== +static UINT8 screenshot_palette[768]; +static void M_CreateScreenShotPalette(void) +{ + size_t i, j; + for (i = 0, j = 0; i < 768; i += 3, j++) + { + RGBA_t locpal = ((cv_screenshot_colorprofile.value) + ? pLocalPalette[(max(st_palette,0)*256)+j] + : pMasterPalette[(max(st_palette,0)*256)+j]); + screenshot_palette[i] = locpal.s.red; + screenshot_palette[i+1] = locpal.s.green; + screenshot_palette[i+2] = locpal.s.blue; + } +} #if NUMSCREENS > 2 static const char *Newsnapshotfile(const char *pathname, const char *ext) @@ -737,7 +789,7 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png if (gamestate == GS_LEVEL && mapheaderinfo[gamemap-1]->lvlttl[0] != '\0') snprintf(lvlttltext, 48, "%s%s%s", mapheaderinfo[gamemap-1]->lvlttl, - (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE", + (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone", (mapheaderinfo[gamemap-1]->actnum > 0) ? va(" %d",mapheaderinfo[gamemap-1]->actnum) : ""); else snprintf(lvlttltext, 48, "Unknown"); @@ -1016,6 +1068,7 @@ static boolean M_SetupaPNG(png_const_charp filename, png_bytep pal) static inline moviemode_t M_StartMovieAPNG(const char *pathname) { #ifdef USE_APNG + UINT8 *palette = NULL; const char *freename = NULL; boolean ret = false; @@ -1032,9 +1085,12 @@ static inline moviemode_t M_StartMovieAPNG(const char *pathname) } if (rendermode == render_soft) - ret = M_SetupaPNG(va(pandf,pathname,freename), W_CacheLumpName(GetPalette(), PU_CACHE)); - else - ret = M_SetupaPNG(va(pandf,pathname,freename), NULL); + { + M_CreateScreenShotPalette(); + palette = screenshot_palette; + } + + ret = M_SetupaPNG(va(pandf,pathname,freename), palette); if (!ret) { @@ -1079,19 +1135,25 @@ static inline moviemode_t M_StartMovieGIF(const char *pathname) void M_StartMovie(void) { #if NUMSCREENS > 2 - const char *pathname = "."; + char pathname[MAX_WADPATH]; if (moviemode) return; - if (cv_screenshot_option.value == 0) - pathname = usehome ? srb2home : srb2path; - else if (cv_screenshot_option.value == 1) - pathname = srb2home; - else if (cv_screenshot_option.value == 2) - pathname = srb2path; - else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0') - pathname = cv_screenshot_folder.string; + if (cv_movie_option.value == 0) + strcpy(pathname, usehome ? srb2home : srb2path); + else if (cv_movie_option.value == 1) + strcpy(pathname, srb2home); + else if (cv_movie_option.value == 2) + strcpy(pathname, srb2path); + else if (cv_movie_option.value == 3 && *cv_movie_folder.string != '\0') + strcpy(pathname, cv_movie_folder.string); + + if (cv_movie_option.value != 3) + { + strcat(pathname, PATHSEP"movies"PATHSEP); + I_mkdir(pathname, 0755); + } if (rendermode == render_none) I_Error("Can't make a movie without a render system\n"); @@ -1099,12 +1161,8 @@ void M_StartMovie(void) switch (cv_moviemode.value) { case MM_GIF: - if (rendermode == render_soft) - { - moviemode = M_StartMovieGIF(pathname); - break; - } - /* FALLTHRU */ + moviemode = M_StartMovieGIF(pathname); + break; case MM_APNG: moviemode = M_StartMovieAPNG(pathname); break; @@ -1237,7 +1295,7 @@ void M_StopMovie(void) * \param data The image data. * \param width Width of the picture. * \param height Height of the picture. - * \param palette Palette of image data + * \param palette Palette of image data. * \note if palette is NULL, BGR888 format */ boolean M_SavePNG(const char *filename, void *data, int width, int height, const UINT8 *palette) @@ -1259,8 +1317,7 @@ boolean M_SavePNG(const char *filename, void *data, int width, int height, const return false; } - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, - PNG_error, PNG_warn); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn); if (!png_ptr) { CONS_Debug(DBG_RENDER, "M_SavePNG: Error on initialize libpng\n"); @@ -1354,7 +1411,7 @@ typedef struct * \param palette Palette of image data */ #if NUMSCREENS > 2 -static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, int height, const UINT8 *palette) +static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, int height, const UINT8 *pal) { int i; size_t length; @@ -1395,8 +1452,16 @@ static boolean WritePCXfile(const char *filename, const UINT8 *data, int width, // write the palette *pack++ = 0x0c; // palette ID byte - for (i = 0; i < 768; i++) - *pack++ = *palette++; + + // write color table + { + for (i = 0; i < 256; i++) + { + *pack++ = *pal; pal++; + *pack++ = *pal; pal++; + *pack++ = *pal; pal++; + } + } // write output file length = pack - (UINT8 *)pcx; @@ -1414,42 +1479,49 @@ void M_ScreenShot(void) } /** Takes a screenshot. - * The screenshot is saved as "srb2xxxx.pcx" (or "srb2xxxx.tga" in hardware - * rendermode) where xxxx is the lowest four-digit number for which a file - * does not already exist. + * The screenshot is saved as "srb2xxxx.png" where xxxx is the lowest + * four-digit number for which a file does not already exist. * * \sa HWR_ScreenShot */ void M_DoScreenShot(void) { #if NUMSCREENS > 2 - const char *freename = NULL, *pathname = "."; + const char *freename = NULL; + char pathname[MAX_WADPATH]; boolean ret = false; UINT8 *linear = NULL; // Don't take multiple screenshots, obviously takescreenshot = false; + // how does one take a screenshot without a render system? + if (rendermode == render_none) + return; + if (cv_screenshot_option.value == 0) - pathname = usehome ? srb2home : srb2path; + strcpy(pathname, usehome ? srb2home : srb2path); else if (cv_screenshot_option.value == 1) - pathname = srb2home; + strcpy(pathname, srb2home); else if (cv_screenshot_option.value == 2) - pathname = srb2path; + strcpy(pathname, srb2path); else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0') - pathname = cv_screenshot_folder.string; + strcpy(pathname, cv_screenshot_folder.string); + + if (cv_screenshot_option.value != 3) + { + strcat(pathname, PATHSEP"screenshots"PATHSEP); + I_mkdir(pathname, 0755); + } #ifdef USE_PNG - if (rendermode != render_none) - freename = Newsnapshotfile(pathname,"png"); + freename = Newsnapshotfile(pathname,"png"); #else if (rendermode == render_soft) freename = Newsnapshotfile(pathname,"pcx"); - else if (rendermode != render_none) + else if (rendermode == render_opengl) freename = Newsnapshotfile(pathname,"tga"); #endif - else - I_Error("Can't take a screenshot without a render system"); if (rendermode == render_soft) { @@ -1463,18 +1535,16 @@ void M_DoScreenShot(void) // save the pcx file #ifdef HWRENDER - if (rendermode != render_soft) + if (rendermode == render_opengl) ret = HWR_Screenshot(va(pandf,pathname,freename)); else #endif - if (rendermode != render_none) { + M_CreateScreenShotPalette(); #ifdef USE_PNG - ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, - W_CacheLumpName(GetPalette(), PU_CACHE)); + ret = M_SavePNG(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette); #else - ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, - W_CacheLumpName(GetPalette(), PU_CACHE)); + ret = WritePCXfile(va(pandf,pathname,freename), linear, vid.width, vid.height, screenshot_palette); #endif } @@ -1482,14 +1552,14 @@ failure: if (ret) { if (moviemode != MM_SCREENSHOT) - CONS_Printf(M_GetText("screen shot %s saved in %s\n"), freename, pathname); + CONS_Printf(M_GetText("Screen shot %s saved in %s\n"), freename, pathname); } else { if (freename) - CONS_Printf(M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname); + CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot %s in %s\n"), freename, pathname); else - CONS_Printf(M_GetText("Couldn't create screen shot (all 10000 slots used!) in %s\n"), pathname); + CONS_Alert(CONS_ERROR, M_GetText("Couldn't create screen shot in %s (all 10000 slots used!)\n"), pathname); if (moviemode == MM_SCREENSHOT) M_StopMovie(); @@ -1524,16 +1594,19 @@ boolean M_ScreenshotResponder(event_t *ev) // M_StartupLocale. // Sets up gettext to translate SRB2's strings. #ifdef GETTEXT -#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#define GETTEXTDOMAIN1 "/usr/share/locale" -#define GETTEXTDOMAIN2 "/usr/local/share/locale" -#elif defined (_WIN32) -#define GETTEXTDOMAIN1 "." -#endif + #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) + #define GETTEXTDOMAIN1 "/usr/share/locale" + #define GETTEXTDOMAIN2 "/usr/local/share/locale" + #elif defined (_WIN32) + #define GETTEXTDOMAIN1 "." + #endif +#endif // GETTEXT void M_StartupLocale(void) { +#ifdef GETTEXT char *textdomhandle = NULL; +#endif //GETTEXT CONS_Printf("M_StartupLocale...\n"); @@ -1542,6 +1615,7 @@ void M_StartupLocale(void) // Do not set numeric locale as that affects atof setlocale(LC_NUMERIC, "C"); +#ifdef GETTEXT // FIXME: global name define anywhere? #ifdef GETTEXTDOMAIN1 textdomhandle = bindtextdomain("srb2", GETTEXTDOMAIN1); @@ -1562,8 +1636,8 @@ void M_StartupLocale(void) textdomain("srb2"); else CONS_Printf("Could not find locale text domain!\n"); +#endif //GETTEXT } -#endif // ========================================================================== // MISC STRING FUNCTIONS @@ -1646,6 +1720,11 @@ INT32 axtoi(const char *hexStg) return intValue; } +// Token parser variables + +static UINT32 oldendPos = 0; // old value of endPos, used by M_UnGetToken +static UINT32 endPos = 0; // now external to M_GetToken, but still static + /** Token parser for TEXTURES, ANIMDEFS, and potentially other lumps later down the line. * Was originally R_GetTexturesToken when I was coding up the TEXTURES parser, until I realized I needed it for ANIMDEFS too. * Parses up to the next whitespace character or comma. When finding the start of the next token, whitespace is skipped. @@ -1660,7 +1739,7 @@ char *M_GetToken(const char *inputString) { static const char *stringToUse = NULL; // Populated if inputString != NULL; used otherwise static UINT32 startPos = 0; - static UINT32 endPos = 0; +// static UINT32 endPos = 0; static UINT32 stringLength = 0; static UINT8 inComment = 0; // 0 = not in comment, 1 = // Single-line, 2 = /* Multi-line */ char *texturesToken = NULL; @@ -1670,12 +1749,12 @@ char *M_GetToken(const char *inputString) { stringToUse = inputString; startPos = 0; - endPos = 0; + oldendPos = endPos = 0; stringLength = strlen(inputString); } else { - startPos = endPos; + startPos = oldendPos = endPos; } if (stringToUse == NULL) return NULL; @@ -1704,7 +1783,7 @@ char *M_GetToken(const char *inputString) || stringToUse[startPos] == '\r' || stringToUse[startPos] == '\n' || stringToUse[startPos] == '\0' - || stringToUse[startPos] == '"' // we're treating this as whitespace because SLADE likes adding it for no good reason + || stringToUse[startPos] == '=' || stringToUse[startPos] == ';' // UDMF TEXTMAP. || inComment != 0) && startPos < stringLength) { @@ -1762,6 +1841,23 @@ char *M_GetToken(const char *inputString) texturesToken[1] = '\0'; return texturesToken; } + // Return entire string within quotes, except without the quotes. + else if (stringToUse[startPos] == '"') + { + endPos = ++startPos; + while (stringToUse[endPos] != '"' && endPos < stringLength) + endPos++; + + texturesTokenLength = endPos++ - startPos; + // Assign the memory. Don't forget an extra byte for the end of the string! + texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); + // Copy the string. + M_Memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength); + // Make the final character NUL. + texturesToken[texturesTokenLength] = '\0'; + + return texturesToken; + } // Now find the end of the token. This includes several additional characters that are okay to capture as one character, but not trailing at the end of another token. endPos = startPos + 1; @@ -1772,7 +1868,7 @@ char *M_GetToken(const char *inputString) && stringToUse[endPos] != ',' && stringToUse[endPos] != '{' && stringToUse[endPos] != '}' - && stringToUse[endPos] != '"' // see above + && stringToUse[endPos] != '=' && stringToUse[endPos] != ';' // UDMF TEXTMAP. && inComment == 0) && endPos < stringLength) { @@ -1806,6 +1902,30 @@ char *M_GetToken(const char *inputString) return texturesToken; } +/** Undoes the last M_GetToken call + * The current position along the string being parsed is reset to the last saved position. + * This exists mostly because of R_ParseTexture/R_ParsePatch honestly, but could be useful elsewhere? + * -Monster Iestyn (22/10/16) + */ +void M_UnGetToken(void) +{ + endPos = oldendPos; +} + +/** Returns the current token's position. + */ +UINT32 M_GetTokenPos(void) +{ + return endPos; +} + +/** Sets the current token's position. + */ +void M_SetTokenPos(UINT32 newPos) +{ + endPos = newPos; +} + /** Count bits in a number. */ UINT8 M_CountBits(UINT32 num, UINT8 size) @@ -2354,3 +2474,159 @@ void M_SetupMemcpy(void) M_Memcpy = cpu_cpy; #endif } + +/** Return the appropriate message for a file error or end of file. +*/ +const char *M_FileError(FILE *fp) +{ + if (ferror(fp)) + return strerror(errno); + else + return "end-of-file"; +} + +/** Return the number of parts of this path. +*/ +int M_PathParts(const char *path) +{ + int n; + const char *p; + const char *t; + if (path == NULL) + return 0; + for (n = 0, p = path ;; ++n) + { + t = p; + if (( p = strchr(p, PATHSEP[0]) )) + p += strspn(p, PATHSEP); + else + { + if (*t)/* there is something after the final delimiter */ + n++; + break; + } + } + return n; +} + +/** Check whether a path is an absolute path. +*/ +boolean M_IsPathAbsolute(const char *path) +{ +#ifdef _WIN32 + return ( strncmp(&path[1], ":\\", 2) == 0 ); +#else + return ( path[0] == '/' ); +#endif +} + +/** I_mkdir for each part of the path. +*/ +void M_MkdirEachUntil(const char *cpath, int start, int end, int mode) +{ + char path[MAX_WADPATH]; + char *p; + char *t; + + if (end > 0 && end <= start) + return; + + strlcpy(path, cpath, sizeof path); +#ifdef _WIN32 + if (strncmp(&path[1], ":\\", 2) == 0) + p = &path[3]; + else +#endif + p = path; + + if (end > 0) + end -= start; + + for (; start > 0; --start) + { + p += strspn(p, PATHSEP); + if (!( p = strchr(p, PATHSEP[0]) )) + return; + } + p += strspn(p, PATHSEP); + for (;;) + { + if (end > 0 && !--end) + break; + + t = p; + if (( p = strchr(p, PATHSEP[0]) )) + { + *p = '\0'; + I_mkdir(path, mode); + *p = PATHSEP[0]; + p += strspn(p, PATHSEP); + } + else + { + if (*t) + I_mkdir(path, mode); + break; + } + } +} + +void M_MkdirEach(const char *path, int start, int mode) +{ + M_MkdirEachUntil(path, start, -1, mode); +} + +int M_JumpWord(const char *line) +{ + int c; + + c = line[0]; + + if (isspace(c)) + return strspn(line, " "); + else if (ispunct(c)) + return strspn(line, PUNCTUATION); + else + { + if (isspace(line[1])) + return 1 + strspn(&line[1], " "); + else + return strcspn(line, " "PUNCTUATION); + } +} + +int M_JumpWordReverse(const char *line, int offset) +{ + int (*is)(int); + int c; + c = line[--offset]; + if (isspace(c)) + is = isspace; + else if (ispunct(c)) + is = ispunct; + else + is = isalnum; + c = (*is)(line[offset]); + while (offset > 0 && + (*is)(line[offset - 1]) == c) + offset--; + return offset; +} + +const char * M_Ftrim (double f) +{ + static char dig[9];/* "0." + 6 digits (6 is printf's default) */ + int i; + /* I know I said it's the default, but just in case... */ + sprintf(dig, "%.6f", fabs(modf(f, &f))); + /* trim trailing zeroes */ + for (i = strlen(dig)-1; dig[i] == '0'; --i) + ; + if (dig[i] == '.')/* :NOTHING: */ + return ""; + else + { + dig[i + 1] = '\0'; + return &dig[1];/* skip the 0 */ + } +} diff --git a/src/m_misc.h b/src/m_misc.h index 7dd8baabf..d64faea59 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -29,8 +29,8 @@ typedef enum { } moviemode_t; extern moviemode_t moviemode; -extern consvar_t cv_screenshot_option, cv_screenshot_folder; -extern consvar_t cv_moviemode; +extern consvar_t cv_screenshot_option, cv_screenshot_folder, cv_screenshot_colorprofile; +extern consvar_t cv_moviemode, cv_movie_folder, cv_movie_option; extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits; extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa; extern consvar_t cv_apng_delay; @@ -40,13 +40,7 @@ void M_SaveFrame(void); void M_StopMovie(void); // the file where game vars and settings are saved -#ifdef DC -#define CONFIGFILENAME "srb2dc.cfg" -#elif defined (PSP) -#define CONFIGFILENAME "srb2psp.cfg" -#else #define CONFIGFILENAME "config.cfg" -#endif INT32 M_MapNumber(char first, char second); @@ -100,6 +94,27 @@ void strcatbf(char *s1, const char *s2, const char *s3); void M_SetupMemcpy(void); +const char *M_FileError(FILE *handle); + +int M_PathParts (const char *path); +boolean M_IsPathAbsolute (const char *path); +void M_MkdirEach (const char *path, int start, int mode); +void M_MkdirEachUntil (const char *path, int start, int end, int mode); + +/* Return offset to the first word in a string. */ +/* E.g. cursor += M_JumpWord(line + cursor); */ +int M_JumpWord (const char *s); + +/* Return index of the last word behind offset bytes in a string. */ +/* E.g. cursor = M_JumpWordReverse(line, cursor); */ +int M_JumpWordReverse (const char *line, int offset); + +/* +Return dot and then the fractional part of a float, without +trailing zeros, or "" if the fractional part is zero. +*/ +const char * M_Ftrim (double); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); diff --git a/src/m_queue.c b/src/m_queue.c index a3aa04871..8603ab202 100644 --- a/src/m_queue.c +++ b/src/m_queue.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2003 by James Haley -// Copyright (C) 2003-2018 by Sonic Team Junior. +// Copyright (C) 2003-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_queue.h b/src/m_queue.h index eebb21468..3e9579e11 100644 --- a/src/m_queue.h +++ b/src/m_queue.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2003 by James Haley -// Copyright (C) 2003-2018 by Sonic Team Junior. +// Copyright (C) 2003-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_random.c b/src/m_random.c index 3d46f76b7..481fdb72b 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_random.h b/src/m_random.h index 6187bcf1c..01190e046 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/m_swap.h b/src/m_swap.h index 2d42f6138..b44d6de8c 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -14,29 +14,39 @@ #ifndef __M_SWAP__ #define __M_SWAP__ -#include "endian.h" - // Endianess handling. // WAD files are stored little endian. +#include "endian.h" + +// Little to big endian #ifdef SRB2_BIG_ENDIAN -#define SHORT(x) ((INT16)(\ -(((UINT16)(x) & (UINT16)0x00ffU) << 8) \ -| \ -(((UINT16)(x) & (UINT16)0xff00U) >> 8))) \ + #define SHORT(x) ((INT16)(\ + (((UINT16)(x) & (UINT16)0x00ffU) << 8) \ + | \ + (((UINT16)(x) & (UINT16)0xff00U) >> 8))) \ -#define LONG(x) ((INT32)(\ -(((UINT32)(x) & (UINT32)0x000000ffUL) << 24) \ -| \ -(((UINT32)(x) & (UINT32)0x0000ff00UL) << 8) \ -| \ -(((UINT32)(x) & (UINT32)0x00ff0000UL) >> 8) \ -| \ -(((UINT32)(x) & (UINT32)0xff000000UL) >> 24))) + #define LONG(x) ((INT32)(\ + (((UINT32)(x) & (UINT32)0x000000ffUL) << 24) \ + | \ + (((UINT32)(x) & (UINT32)0x0000ff00UL) << 8) \ + | \ + (((UINT32)(x) & (UINT32)0x00ff0000UL) >> 8) \ + | \ + (((UINT32)(x) & (UINT32)0xff000000UL) >> 24))) #else -#define SHORT(x) ((INT16)(x)) -#define LONG(x) ((INT32)(x)) + #define SHORT(x) ((INT16)(x)) + #define LONG(x) ((INT32)(x)) +#endif + +// Big to little endian +#ifdef SRB2_LITTLE_ENDIAN + #define BIGENDIAN_LONG(x) ((INT32)(((x)>>24)&0xff)|(((x)<<8)&0xff0000)|(((x)>>8)&0xff00)|(((x)<<24)&0xff000000)) + #define BIGENDIAN_SHORT(x) ((INT16)(((x)>>8)|((x)<<8))) +#else + #define BIGENDIAN_LONG(x) ((INT32)(x)) + #define BIGENDIAN_SHORT(x) ((INT16)(x)) #endif #endif diff --git a/src/md5.c b/src/md5.c index 8031650e6..66d563666 100644 --- a/src/md5.c +++ b/src/md5.c @@ -19,9 +19,7 @@ #endif #include -#ifndef _WIN32_WCE #include -#endif #ifdef _MSC_VER #pragma warning(disable : 4127) #endif @@ -30,7 +28,7 @@ #include #else #ifndef HAVE_MEMCPY - #if !((defined (_WIN32) || defined (_WIN32_WCE)) && !defined (__CYGWIN__)) && !defined (__APPLE__) + #if !(defined (_WIN32) && !defined (__CYGWIN__)) && !defined (__APPLE__) #define memcpy(d, s, n) bcopy ((s), (d), (n)) #endif #endif diff --git a/src/mserv.c b/src/mserv.c index 3fbb63760..05a5344ba 100644 --- a/src/mserv.c +++ b/src/mserv.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -16,11 +16,9 @@ #include #endif -#if !defined (UNDER_CE) #include -#endif -#if (defined (NOMD5) || defined (NOMSERV)) && !defined (NONET) +#if (defined (NOMSERV)) && !defined (NONET) #define NONET #endif @@ -30,7 +28,7 @@ #define HAVE_IPV6 #endif -#if (defined (_WIN32) || defined (_WIN32_WCE)) && !defined (_XBOX) +#ifdef _WIN32 #define RPC_NO_WINDOWS_H #ifdef HAVE_IPV6 #include @@ -38,16 +36,6 @@ #include // socket(),... #endif //!HAVE_IPV6 #else -#ifdef __OS2__ -#include -#endif // __OS2__ - -#ifdef HAVE_LWIP -#include -#include -#include -#define ioctl lwip_ioctl -#else #include #ifdef __APPLE_CC__ #ifndef _BSD_SOCKLEN_T_ @@ -56,25 +44,12 @@ #endif #include // socket(),... #include // sockaddr_in -#ifdef _PS3 -#include -#elif !defined(_arch_dreamcast) #include // getaddrinfo(),... #include -#endif -#endif - -#ifdef _arch_dreamcast -#include "sdl12/SRB2DC/dchelp.h" -#endif #include // timeval,... (TIMEOUT) #include -#endif // _WIN32/_WIN32_WCE - -#ifdef __OS2__ -#include -#endif // __OS2__ +#endif // _WIN32 #endif // !NONET #include "doomstat.h" @@ -91,10 +66,6 @@ #include "m_argv.h" // Alam is going to kill me <3 #include "m_misc.h" // GetRevisionString() -#ifdef _WIN32_WCE -#include "sdl12/SRB2CE/cehelp.h" -#endif - #include "i_addrinfo.h" // ================================ DEFINITIONS =============================== @@ -183,13 +154,13 @@ typedef struct #endif // win32 or djgpp -#if defined (_WIN32) || defined (_WIN32_WCE) || defined (__DJGPP__) +#if defined (_WIN32) || defined (__DJGPP__) #define ioctl ioctlsocket #define close closesocket #ifdef WATTCP #define strerror strerror_s #endif -#if defined (_WIN32) || defined (_WIN32_WCE) +#ifdef _WIN32 #undef errno #define errno h_errno // some very strange things happen when not using h_error #endif @@ -215,11 +186,11 @@ static enum { MSCS_NONE, MSCS_WAITING, MSCS_REGISTERED, MSCS_FAILED } con_state static INT32 msnode = -1; UINT16 current_port = 0; -#if (defined (_WIN32) || defined (_WIN32_WCE) || defined (_WIN32)) && !defined (NONET) +#if defined (_WIN32) && !defined (NONET) typedef SOCKET SOCKET_TYPE; #define ERRSOCKET (SOCKET_ERROR) #else -#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__) || defined (_PS3) +#if (defined (__unix__) && !defined (MSDOS)) || defined (__APPLE__) || defined (__HAIKU__) typedef int SOCKET_TYPE; #else typedef unsigned long SOCKET_TYPE; @@ -352,13 +323,9 @@ static INT32 GetServersList(void) // // MS_Connect() // -static INT32 MS_Connect(const char *ip_addr, const char *str_port, INT32 async) +#ifndef NONET +static INT32 MS_SubConnect(const char *ip_addr, const char *str_port, INT32 async, struct sockaddr *bindaddr, socklen_t bindaddrlen) { -#ifdef NONET - (void)ip_addr; - (void)str_port; - (void)async; -#else struct my_addrinfo *ai, *runp, hints; int gaie; @@ -385,50 +352,100 @@ static INT32 MS_Connect(const char *ip_addr, const char *str_port, INT32 async) socket_fd = socket(runp->ai_family, runp->ai_socktype, runp->ai_protocol); if (socket_fd != (SOCKET_TYPE)ERRSOCKET) { - if (async) // do asynchronous connection + if (!bindaddr || bind(socket_fd, bindaddr, bindaddrlen) == 0) { + if (async) // do asynchronous connection + { #ifdef FIONBIO #ifdef WATTCP - char res = 1; + char res = 1; #else - unsigned long res = 1; + unsigned long res = 1; #endif - ioctl(socket_fd, FIONBIO, &res); + ioctl(socket_fd, FIONBIO, &res); #endif - if (connect(socket_fd, runp->ai_addr, (socklen_t)runp->ai_addrlen) == ERRSOCKET) - { -#ifdef _WIN32 // humm, on win32/win64 it doesn't work with EINPROGRESS (stupid windows) - if (WSAGetLastError() != WSAEWOULDBLOCK) -#else - if (errno != EINPROGRESS) -#endif + if (connect(socket_fd, runp->ai_addr, (socklen_t)runp->ai_addrlen) == ERRSOCKET) { - con_state = MSCS_FAILED; - CloseConnection(); - I_freeaddrinfo(ai); - return MS_CONNECT_ERROR; +#ifdef _WIN32 // humm, on win32/win64 it doesn't work with EINPROGRESS (stupid windows) + if (WSAGetLastError() != WSAEWOULDBLOCK) +#else + if (errno != EINPROGRESS) +#endif + { + con_state = MSCS_FAILED; + CloseConnection(); + I_freeaddrinfo(ai); + return MS_CONNECT_ERROR; + } } + con_state = MSCS_WAITING; + FD_ZERO(&wset); + FD_SET(socket_fd, &wset); + select_timeout.tv_sec = 0, select_timeout.tv_usec = 0; + I_freeaddrinfo(ai); + return 0; + } + else if (connect(socket_fd, runp->ai_addr, (socklen_t)runp->ai_addrlen) != ERRSOCKET) + { + I_freeaddrinfo(ai); + return 0; } - con_state = MSCS_WAITING; - FD_ZERO(&wset); - FD_SET(socket_fd, &wset); - select_timeout.tv_sec = 0, select_timeout.tv_usec = 0; - I_freeaddrinfo(ai); - return 0; } - else if (connect(socket_fd, runp->ai_addr, (socklen_t)runp->ai_addrlen) != ERRSOCKET) + close(socket_fd); + } + runp = runp->ai_next; + } + I_freeaddrinfo(ai); + return MS_CONNECT_ERROR; +} +#endif/*NONET xd*/ + +static INT32 MS_Connect(const char *ip_addr, const char *str_port, INT32 async) +{ +#ifdef NONET + (void)ip_addr; + (void)str_port; + (void)async; + return MS_CONNECT_ERROR; +#else + const char *lhost; + struct my_addrinfo hints; + struct my_addrinfo *ai, *aip; + int c; + if (M_CheckParm("-bindaddr") && ( lhost = M_GetNextParm() )) + { + memset (&hints, 0x00, sizeof(hints)); +#ifdef AI_ADDRCONFIG + hints.ai_flags = AI_ADDRCONFIG; +#endif + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + if (( c = I_getaddrinfo(lhost, 0, &hints, &ai) ) != 0) + { + CONS_Printf( + "mserv.c: bind to %s: %s\n", + lhost, + gai_strerror(c)); + return MS_GETHOSTBYNAME_ERROR; + } + for (aip = ai; aip; aip = aip->ai_next) + { + c = MS_SubConnect(ip_addr, str_port, async, aip->ai_addr, aip->ai_addrlen); + if (c == 0) { I_freeaddrinfo(ai); return 0; } } - runp = runp->ai_next; + I_freeaddrinfo(ai); + return c; } - I_freeaddrinfo(ai); -#endif - return MS_CONNECT_ERROR; + else + return MS_SubConnect(ip_addr, str_port, async, 0, 0); +#endif/*NONET xd*/ } #define NUM_LIST_SERVER MAXSERVERLIST diff --git a/src/mserv.h b/src/mserv.h index 09cd4f089..6d91da643 100644 --- a/src/mserv.h +++ b/src/mserv.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/nds/Makefile.cfg b/src/nds/Makefile.cfg deleted file mode 100644 index c2d915924..000000000 --- a/src/nds/Makefile.cfg +++ /dev/null @@ -1,31 +0,0 @@ -# Adapted in part from devkitPRO makefiles. - -NOMD5=1 - -# Check if DEVKITARM is set in the environment. If so, continue with compilation. -.SUFFIXES: - -ifeq ($(strip $(DEVKITARM)),) -$(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") -endif - -# use absolute paths because changing PATH variable breaks distcc -PREFIX := $(DEVKITARM)/bin/arm-eabi -NDSTOOL := $(DEVKITARM)/bin/ndstool - -# Disable same warning flags -WFLAGS+=-Wno-inline -Wno-cast-align -WFLAGS+=-Wno-shadow -Wno-char-subscripts -WFLAGS+=-Wno-declaration-after-statement -WFLAGS+=-Wno-old-style-definition -WFLAGS+=-Wno-undef -WFLAGS+=-Wno-unsuffixed-float-constants - -ifndef NOHW - OBJS+=$(OBJDIR)/r_nds3d.o -endif - -ARCH = -mthumb -mthumb-interwork -LDFLAGS += -L$(DEVKITPRO)/libnds/lib -specs=ds_arm9.specs -g $(ARCH) -mno-fpu -LIBS += -lfat -lnds9 -CFLAGS += -D_NDS -DARM9 -I$(DEVKITPRO)/libnds/include $(ARCH) -march=armv5te -mtune=arm946e-s -fomit-frame-pointer -ffast-math diff --git a/src/nds/i_cdmus.c b/src/nds/i_cdmus.c deleted file mode 100644 index f3f703667..000000000 --- a/src/nds/i_cdmus.c +++ /dev/null @@ -1,37 +0,0 @@ -#include "../command.h" -#include "../s_sound.h" -#include "../i_sound.h" - -// -// CD MUSIC I/O -// - -UINT8 cdaudio_started = 0; - -consvar_t cd_volume = {"cd_volume","31",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; - - -void I_InitCD(void){} - -void I_StopCD(void){} - -void I_PauseCD(void){} - -void I_ResumeCD(void){} - -void I_ShutdownCD(void){} - -void I_UpdateCD(void){} - -void I_PlayCD(UINT8 track, UINT8 looping) -{ - (void)track; - (void)looping; -} - -boolean I_SetVolumeCD(int volume) -{ - (void)volume; - return false; -} diff --git a/src/nds/i_main.c b/src/nds/i_main.c deleted file mode 100644 index 292a5f91d..000000000 --- a/src/nds/i_main.c +++ /dev/null @@ -1,25 +0,0 @@ -#include "../doomdef.h" -#include "../d_main.h" -#include "../m_argv.h" -#include "../i_system.h" - -int main(int argc, char **argv) -{ - myargc = argc; - myargv = argv; /// \todo pull out path to exe from this string - - CONS_Printf("I_StartupSystem..."); - I_StartupSystem(); - - // startup SRB2 - CONS_Printf("Setting up SRB2...\n"); - D_SRB2Main(); - CONS_Printf("Entering main game loop...\n"); - // never return - D_SRB2Loop(); - - // return to OS -#ifndef __GNUC__ - return 0; -#endif -} diff --git a/src/nds/i_net.c b/src/nds/i_net.c deleted file mode 100644 index f6e642022..000000000 --- a/src/nds/i_net.c +++ /dev/null @@ -1,6 +0,0 @@ -#include "../i_net.h" - -boolean I_InitNetwork(void) -{ - return false; -} diff --git a/src/nds/i_sound.c b/src/nds/i_sound.c deleted file mode 100644 index a17c7f66a..000000000 --- a/src/nds/i_sound.c +++ /dev/null @@ -1,151 +0,0 @@ -#include "../i_sound.h" - -UINT8 sound_started = 0; - -void *I_GetSfx(sfxinfo_t *sfx) -{ - (void)sfx; - return NULL; -} - -void I_FreeSfx(sfxinfo_t *sfx) -{ - (void)sfx; -} - -void I_StartupSound(void){} - -void I_ShutdownSound(void){} - -// -// SFX I/O -// - -INT32 I_StartSound(sfxenum_t id, INT32 vol, INT32 sep, INT32 pitch, INT32 priority, INT32 channel) -{ - (void)id; - (void)vol; - (void)sep; - (void)pitch; - (void)priority; - (void)channel; - return -1; -} - -void I_StopSound(INT32 handle) -{ - (void)handle; -} - -INT32 I_SoundIsPlaying(INT32 handle) -{ - (void)handle; - return false; -} - -void I_UpdateSoundParams(INT32 handle, INT32 vol, INT32 sep, INT32 pitch) -{ - (void)handle; - (void)vol; - (void)sep; - (void)pitch; -} - -void I_SetSfxVolume(INT32 volume) -{ - (void)volume; -} - -// -// MUSIC I/O -// -UINT8 music_started = 0; - -void I_InitMusic(void){} - -void I_ShutdownMusic(void){} - -void I_PauseSong(INT32 handle) -{ - (void)handle; -} - -void I_ResumeSong(INT32 handle) -{ - (void)handle; -} - -// -// MIDI I/O -// - -UINT8 midimusic_started = 0; - -void I_InitMIDIMusic(void){} - -void I_ShutdownMIDIMusic(void){} - -void I_SetMIDIMusicVolume(INT32 volume) -{ - (void)volume; -} - -INT32 I_RegisterSong(void *data, size_t len) -{ - (void)data; - (void)len; - return -1; -} - -boolean I_PlaySong(INT32 handle, INT32 looping) -{ - (void)handle; - (void)looping; - return false; -} - -void I_StopSong(INT32 handle) -{ - (void)handle; -} - -void I_UnRegisterSong(INT32 handle) -{ - (void)handle; -} - -// -// DIGMUSIC I/O -// - -UINT8 digmusic_started = 0; - -void I_InitDigMusic(void){} - -void I_ShutdownDigMusic(void){} - -boolean I_StartDigSong(const char *musicname, INT32 looping) -{ - (void)musicname; - (void)looping; - return false; -} - -void I_StopDigSong(void){} - -void I_SetDigMusicVolume(INT32 volume) -{ - (void)volume; -} - -boolean I_SetSongSpeed(float speed) -{ - (void)speed; - return false; -} - -boolean I_SetSongTrack(int track) -{ - (void)track; - return false; -} diff --git a/src/nds/i_system.c b/src/nds/i_system.c deleted file mode 100644 index 3e5c4b8c6..000000000 --- a/src/nds/i_system.c +++ /dev/null @@ -1,286 +0,0 @@ -#include -#include - -#include "../doomdef.h" -#include "../d_main.h" -#include "../i_system.h" -#include "../i_joy.h" - -UINT8 graphics_started = 0; - -UINT8 keyboard_started = 0; - -static volatile tic_t ticcount; - - -UINT32 I_GetFreeMem(UINT32 *total) -{ - *total = 0; - return 0; -} - -tic_t I_GetTime(void) -{ - return ticcount; -} - -void I_Sleep(void){} - -void I_GetEvent(void) -{ - // Mappings of DS keys to SRB2 keys - UINT32 dskeys[] = - { - KEY_A, - KEY_B, - KEY_X, - KEY_Y, - KEY_L, - KEY_R, - KEY_START, - KEY_SELECT - }; - - event_t event; - UINT32 held, up, down; - UINT32 i; - - // Check how the state has changed since last time - scanKeys(); - - // For the d-pad, we only care about the current state - held = keysHeld(); - event.type = ev_joystick; - event.data1 = 0; // First (and only) axis set - - if (held & KEY_LEFT) event.data2 = -1; - else if (held & KEY_RIGHT) event.data2 = 1; - else event.data2 = 0; - - if (held & KEY_UP) event.data3 = -1; - else if (held & KEY_DOWN) event.data3 = 1; - else event.data3 = 0; - - D_PostEvent(&event); - - // For the buttons, we need to report changes in state - up = keysUp(); - down = keysDown(); - for (i = 0; i < sizeof(dskeys)/sizeof(dskeys[0]); i++) - { - // Has this button's state changed? - if ((up | down) & dskeys[i]) - { - event.type = (up & dskeys[i]) ? ev_keyup : ev_keydown; - event.data1 = KEY_JOY1 + i; - D_PostEvent(&event); - } - } -} - -void I_OsPolling(void) -{ - I_GetEvent(); -} - -ticcmd_t *I_BaseTiccmd(void) -{ - static ticcmd_t emptyticcmd; - return &emptyticcmd; -} - -ticcmd_t *I_BaseTiccmd2(void) -{ - static ticcmd_t emptyticcmd2; - return &emptyticcmd2; -} - -void I_Quit(void) -{ - exit(0); -} - -void I_Error(const char *error, ...) -{ - va_list argptr; - - va_start(argptr, error); - viprintf(error, argptr); - va_end(argptr); - - for(;;); -} - -void I_Tactile(FFType Type, const JoyFF_t *Effect) -{ - (void)Type; - (void)Effect; -} - -void I_Tactile2(FFType Type, const JoyFF_t *Effect) -{ - (void)Type; - (void)Effect; -} - -void I_JoyScale(void){} - -void I_JoyScale2(void){} - -void I_InitJoystick(void) -{ - Joystick.bGamepadStyle = true; -} - -void I_InitJoystick2(void){} - -INT32 I_NumJoys(void) -{ - return 0; -} - -const char *I_GetJoyName(INT32 joyindex) -{ - (void)joyindex; - return NULL; -} - -void I_SetupMumble(void) -{ -} - -#ifndef NOMUMBLE -void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) -{ - (void)mobj; - (void)listener; -} -#endif - -void I_OutputMsg(const char *error, ...) -{ - va_list argptr; - - va_start(argptr, error); - viprintf(error, argptr); - va_end(argptr); -} - -void I_StartupMouse(void){} - -void I_StartupMouse2(void){} - -void I_StartupKeyboard(void){} - -INT32 I_GetKey(void) -{ - return 0; -} - -static void NDS_VBlankHandler(void) -{ - ticcount++; -} - -void I_StartupTimer(void) -{ - irqSet(IRQ_VBLANK, NDS_VBlankHandler); -} - -void I_AddExitFunc(void (*func)()) -{ - (void)func; -} - -void I_RemoveExitFunc(void (*func)()) -{ - (void)func; -} - -// Adapted in part from the devkitPro examples. -INT32 I_StartupSystem(void) -{ - lcdMainOnTop(); - - videoSetModeSub(MODE_0_2D); - vramSetBankC(VRAM_C_MAIN_BG); // Get this mapped *out* of the sub BG - vramSetBankI(VRAM_I_SUB_BG_0x06208000); - - // The background VRAM that's mapped starts at 0x06208000. - // The map base is specified in an offset of multiples of 2 KB - // from 0x06200000, and the tile base in multiples of 16 KB. - // We put the tiles at the start and the map 2 KB from the end - // (i.e. 14 KB from the start). - // The map base is then at 0x0620B800 = 0x06200000 + 16 * 0x800 + 7 * 0x800, - // and the tile base is at 0x06208000 = 0x06200000 + 2 * 0x4000. - consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 16+7, 2, false, true); - - // start FAT filesystem code, required for reading SD card - if(!fatInitDefault()) - I_Error("Couldn't init FAT."); - - return 0; -} - -void I_ShutdownSystem(void){} - -void I_GetDiskFreeSpace(INT64* freespace) -{ - *freespace = 0; -} - -char *I_GetUserName(void) -{ - return NULL; -} - -INT32 I_mkdir(const char *dirname, INT32 unixright) -{ - (void)dirname; - (void)unixright; - return -1; -} - -const CPUInfoFlags *I_CPUInfo(void) -{ - return NULL; -} - -const char *I_LocateWad(void) -{ - return NULL; -} - -void I_GetJoystickEvents(void){} - -void I_GetJoystick2Events(void){} - -void I_GetMouseEvents(void){} - -char *I_GetEnv(const char *name) -{ - (void)name; - return NULL; -} - -INT32 I_PutEnv(char *variable) -{ - (void)variable; - return -1; -} - -INT32 I_ClipboardCopy(const char *data, size_t size) -{ - (void)data; - (void)size; - return -1; -} - -char *I_ClipboardPaste(void) -{ - return NULL; -} - -void I_RegisterSysCommands(void) {} - -#include "../sdl/dosstr.c" diff --git a/src/nds/i_video.c b/src/nds/i_video.c deleted file mode 100644 index 3dfb99557..000000000 --- a/src/nds/i_video.c +++ /dev/null @@ -1,148 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SRB2 graphics stuff for NDS - - -#include "../doomdef.h" -#include "../command.h" -#include "../i_video.h" - -#include "../hardware/hw_drv.h" -#include "../hardware/hw_main.h" -#include "r_nds3d.h" - -rendermode_t rendermode = render_opengl; - -boolean highcolor = false; - -boolean allow_fullscreen = false; - -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -void I_StartupGraphics(void) -{ - vid.width = 256; - vid.height = 192; - vid.bpp = 1; - vid.rowbytes = vid.width * vid.bpp; - vid.recalc = true; - - HWD.pfnInit = NDS3D_Init; - HWD.pfnShutdown = NDS3D_Shutdown; - HWD.pfnFinishUpdate = NDS3D_FinishUpdate; - HWD.pfnDraw2DLine = NDS3D_Draw2DLine; - HWD.pfnDrawPolygon = NDS3D_DrawPolygon; - HWD.pfnSetBlend = NDS3D_SetBlend; - HWD.pfnClearBuffer = NDS3D_ClearBuffer; - HWD.pfnSetTexture = NDS3D_SetTexture; - HWD.pfnReadRect = NDS3D_ReadRect; - HWD.pfnGClipRect = NDS3D_GClipRect; - HWD.pfnClearMipMapCache = NDS3D_ClearMipMapCache; - HWD.pfnSetSpecialState = NDS3D_SetSpecialState; - HWD.pfnSetPalette = NDS3D_SetPalette; - HWD.pfnGetTextureUsed = NDS3D_GetTextureUsed; - HWD.pfnDrawMD2 = NDS3D_DrawMD2; - HWD.pfnDrawMD2i = NDS3D_DrawMD2i; - HWD.pfnSetTransform = NDS3D_SetTransform; - HWD.pfnGetRenderVersion = NDS3D_GetRenderVersion; - - videoSetMode(MODE_0_3D); - vramSetBankA(VRAM_A_TEXTURE); - vramSetBankB(VRAM_B_TEXTURE); - vramSetBankC(VRAM_C_TEXTURE); - vramSetBankD(VRAM_D_TEXTURE); - vramSetBankE(VRAM_E_TEX_PALETTE); - - glInit(); - - glEnable(GL_TEXTURE_2D); - - glClearColor(16,16,16,31); - glClearPolyID(63); - glClearDepth(0x7FFF); - - glViewport(0, 0, vid.width - 1, vid.height - 1); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - gluPerspective(fov, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glScalef(1.0f, 1.0f, -1.0f); - - HWD.pfnInit(I_Error); - HWR_Startup(); -} - -void I_ShutdownGraphics(void){} - -void I_SetPalette(RGBA_t *palette) -{ - (void)palette; -} - -INT32 VID_NumModes(void) -{ - return 0; -} - -INT32 VID_GetModeForSize(INT32 w, INT32 h) -{ - (void)w; - (void)h; - return 0; -} - -void VID_PrepareModeList(void){} - -INT32 VID_SetMode(INT32 modenum) -{ - (void)modenum; - return 0; -} - -const char *VID_GetModeName(INT32 modenum) -{ - (void)modenum; - return NULL; -} - -void I_UpdateNoBlit(void){} - -void I_FinishUpdate(void) -{ - HWD.pfnFinishUpdate(true); -} - -void I_UpdateNoVsync(void) {} - -void I_WaitVBL(INT32 count) -{ - (void)count; -} - -void I_ReadScreen(UINT8 *scr) -{ - (void)scr; -} - -void I_BeginRead(void){} - -void I_EndRead(void){} diff --git a/src/nds/r_nds3d.c b/src/nds/r_nds3d.c deleted file mode 100644 index dbdcec158..000000000 --- a/src/nds/r_nds3d.c +++ /dev/null @@ -1,389 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief NDS 3D API for SRB2. -// -// In an ideal world, we would share as much code as possible with r_opengl.c, -// but this will do for now. - -#include "../doomtype.h" -#include "../hardware/hw_defs.h" -#include "../hardware/hw_dll.h" -#include "../hardware/hw_md2.h" -#include "r_nds3d.h" - -static I_Error_t I_Error_GL = NULL; - -#define NOTEXTURE_NUM 0 // small white texture -#define FIRST_TEX_AVAIL (NOTEXTURE_NUM + 1) -#define MAX_SRB2_TEXTURES 256 - -FCOORD NEAR_CLIPPING_PLANE = 0.9f; -float fov = 90.0f; - -static FBITFIELD CurrentPolyFlags = 0xFFFFFFFF; -static UINT32 CurrentGLPolyFmt = POLY_CULL_NONE; -static UINT8 CurrentPolyAlpha = 31; -static UINT16 myPaletteData[256]; -static FTextureInfo* gr_cachetail = NULL; -static FTextureInfo* gr_cachehead = NULL; -static INT32 NextTexAvail = FIRST_TEX_AVAIL; -static UINT32 tex_downloaded = 0; -static INT32 texids[MAX_SRB2_TEXTURES]; -static boolean scalehack = false; - - -static void GenerateTextureNames(void) -{ - glGenTextures(MAX_SRB2_TEXTURES - 1, texids + 1); - texids[NOTEXTURE_NUM] = 0; -} - -static void Flush(void) -{ - // Delete all textures at once, since libnds's glDeleteTextures seems to be buggy. - glResetTextures(); - GenerateTextureNames(); - while (gr_cachehead) - { - gr_cachehead->downloaded = 0; - gr_cachehead = gr_cachehead->nextmipmap; - } - gr_cachetail = gr_cachehead = NULL; - NextTexAvail = FIRST_TEX_AVAIL; - tex_downloaded = 0; -} - -static void SetNoTexture(void) -{ - // Set small white texture. - if (tex_downloaded != NOTEXTURE_NUM) - { - glBindTexture(GL_TEXTURE_2D, texids[NOTEXTURE_NUM]); - tex_downloaded = NOTEXTURE_NUM; - } -} - - -static void SetAlpha(UINT8 alpha) -{ - CurrentPolyAlpha = alpha >> 3; - glPolyFmt(CurrentGLPolyFmt | POLY_ALPHA(CurrentPolyAlpha)); -} - - - -boolean NDS3D_Init(I_Error_t ErrorFunction) -{ - I_Error_GL = ErrorFunction; - glPolyFmt(CurrentGLPolyFmt | POLY_ALPHA(CurrentPolyAlpha)); - GenerateTextureNames(); - return true; -} - -void NDS3D_Shutdown(void) {} - -void NDS3D_SetPalette(RGBA_t *ppal, RGBA_t *pgamma) -{ - INT32 i; - - for (i = 0; i < 256; i++) - { - UINT8 red = (UINT8)min((ppal[i].s.red*pgamma->s.red)/127, 255) >> 3; - UINT8 green = (UINT8)min((ppal[i].s.green*pgamma->s.green)/127, 255) >> 3; - UINT8 blue = (UINT8)min((ppal[i].s.blue*pgamma->s.blue)/127, 255) >> 3; - - myPaletteData[i] = ARGB16(ppal[i].s.alpha ? 1 : 0, red, green, blue); - } - - Flush(); -} - -void NDS3D_FinishUpdate(INT32 waitvbl) -{ - (void)waitvbl; - - glFlush(0); -} - -void NDS3D_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color) -{ - (void)v1; - (void)v2; - (void)Color; -} - -void NDS3D_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags) -{ - FUINT i; - - NDS3D_SetBlend(PolyFlags); - - // If Modulated, mix the surface colour to the texture - if ((CurrentPolyFlags & PF_Modulated) && pSurf) - { - glColor3b(pSurf->FlatColor.s.red, pSurf->FlatColor.s.green, pSurf->FlatColor.s.blue); - SetAlpha(pSurf->FlatColor.s.alpha); - } - - // libnds doesn't have GL_TRIANGLE_FAN, so use GL_TRIANGLE_STRIP instead - glBegin(GL_TRIANGLE_STRIP); - for (i = 0; i < iNumPts; i++) - { - FUINT index = (i & 1) ? (i >> 1) : (iNumPts - 1 - (i >> 1)); - FLOAT x, y, z; - - if (scalehack) - { - x = pOutVerts[index].x/4096.0f; - y = pOutVerts[index].y/4096.0f; - z = pOutVerts[index].z/4096.0f; - } - else - { - x = pOutVerts[index].x; - y = pOutVerts[index].y; - z = pOutVerts[index].z; - } - - glTexCoord2f(pOutVerts[index].sow, pOutVerts[index].tow); - glVertex3f(x,y,z); - } - glEnd(); -} - -void NDS3D_SetBlend(FBITFIELD PolyFlags) -{ - FBITFIELD Xor = PolyFlags ^ CurrentPolyFlags; - - if (Xor & (PF_NoTexture|PF_Modulated)) - { - if (Xor&PF_Modulated) - { - if(!(PolyFlags & PF_Modulated)) - { - glColor3b(255, 255, 255); - CurrentPolyAlpha = 31; - } - } - - if (PolyFlags & PF_NoTexture) - { - SetNoTexture(); - } - } - - CurrentPolyFlags = PolyFlags; - glPolyFmt(CurrentGLPolyFmt | POLY_ALPHA(CurrentPolyAlpha)); -} - -void NDS3D_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor) -{ - (void)ClearColor; - - if (ColorMask && ClearColor) - { - // TODO: Fixed-ify - glClearColor((uint8)(ClearColor->red*31), - (uint8)(ClearColor->green*31), - (uint8)(ClearColor->blue*31), - (uint8)(ClearColor->alpha*31)); - } - - if (DepthMask) - glClearDepth(GL_MAX_DEPTH); - - NDS3D_SetBlend(DepthMask ? PF_Occlude | CurrentPolyFlags : CurrentPolyFlags&~PF_Occlude); -} - -void NDS3D_SetTexture(FTextureInfo *TexInfo) -{ - if (!TexInfo) - { - SetNoTexture(); - return; - } - else if (TexInfo->downloaded) - { - if (TexInfo->downloaded != tex_downloaded) - { - glBindTexture(GL_TEXTURE_2D, texids[TexInfo->downloaded]); - tex_downloaded = TexInfo->downloaded; - } - } - else if (TexInfo->grInfo.data) - { - UINT8 wtype, htype; - INT32 texparam = GL_TEXTURE_COLOR0_TRANSPARENT; - - // We rely on the numerical values of GL_TEXTURE_SIZE_ENUM here. - wtype = TEXTURE_SIZE_8; - while(TexInfo->width > 1 << (wtype + 3)) wtype++; - - htype = TEXTURE_SIZE_8; - while(TexInfo->height > 1 << (htype + 3)) htype++; - - TexInfo->downloaded = NextTexAvail++; - tex_downloaded = TexInfo->downloaded; - glBindTexture(GL_TEXTURE_2D, texids[TexInfo->downloaded]); - - if(!glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB256, wtype, htype, 0, TEXGEN_TEXCOORD, TexInfo->grInfo.data)) - { - // HACK: If we're out of memory, flush and try again. - // This will result in artefacts for one frame. - Flush(); - TexInfo->downloaded = 0; - NDS3D_SetTexture(TexInfo); - return; - } - - if (TexInfo->downloaded > FIRST_TEX_AVAIL) - { - // We already have a texture using the palette, so it's already in VRAM - glAssignColorTable(GL_TEXTURE_2D, texids[FIRST_TEX_AVAIL]); - } - else - { - // Generate the palette in hardware - glColorTableEXT(0, 0, 256, 0, 0, myPaletteData); - } - - if (TexInfo->flags & TF_WRAPX) - texparam |= GL_TEXTURE_WRAP_S; - - if (TexInfo->flags & TF_WRAPY) - texparam |= GL_TEXTURE_WRAP_T; - - glTexParameter(0, texparam); - - TexInfo->nextmipmap = NULL; - if (gr_cachetail) - { - gr_cachetail->nextmipmap = TexInfo; - gr_cachetail = TexInfo; - } - else - gr_cachetail = gr_cachehead = TexInfo; - } -} - -void NDS3D_ReadRect(INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data) -{ - (void)x; - (void)y; - (void)width; - (void)height; - (void)dst_stride; - (void)dst_data; -} - -void NDS3D_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip) -{ - (void)minx; - (void)miny; - (void)maxx; - (void)maxy; - //glViewport(minx, vid.height-maxy, maxx-minx, maxy-miny); - NEAR_CLIPPING_PLANE = nearclip; - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(fov, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE); - glMatrixMode(GL_MODELVIEW); -} - -void NDS3D_ClearMipMapCache(void) {} - -void NDS3D_SetSpecialState(hwdspecialstate_t IdState, INT32 Value) -{ - (void)IdState; - (void)Value; -} - -void NDS3D_DrawMD2(INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale) -{ - (void)gl_cmd_buffer; - (void)frame; - (void)pos; - (void)scale; -} - -void NDS3D_DrawMD2i(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color) -{ - (void)gl_cmd_buffer; - (void)frame; - (void)duration; - (void)tics; - (void)nextframe; - (void)pos; - (void)scale; - (void)flipped; - (void)color; -} - -void NDS3D_SetTransform(FTransform *ptransform) -{ - static INT32 special_splitscreen; - glLoadIdentity(); - if (ptransform) - { - scalehack = true; - - glScalef(ptransform->scalex*4096.0f, ptransform->scaley*4096.0f, -ptransform->scalez*4096.0f); - glRotatef(ptransform->anglex , 1.0f, 0.0f, 0.0f); - glRotatef(ptransform->angley+270.0f, 0.0f, 1.0f, 0.0f); - glTranslatef(-ptransform->x/4096.0f, -ptransform->z/4096.0f, -ptransform->y/4096.0f); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - special_splitscreen = (ptransform->splitscreen && ptransform->fovxangle == 90.0f); - if (special_splitscreen) - gluPerspective(53.13l, 2*ASPECT_RATIO, // 53.13 = 2*atan(0.5) - NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE); - else - gluPerspective(ptransform->fovxangle, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE); - - glMatrixMode(GL_MODELVIEW); - } - else - { - scalehack = false; - - glScalef(1.0f, 1.0f, -1.0f); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - if (special_splitscreen) - gluPerspective(53.13l, 2*ASPECT_RATIO, // 53.13 = 2*atan(0.5) - NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE); - else - //Hurdler: is "fov" correct? - gluPerspective(fov, ASPECT_RATIO, NEAR_CLIPPING_PLANE, FAR_CLIPPING_PLANE); - - glMatrixMode(GL_MODELVIEW); - } -} - -INT32 NDS3D_GetTextureUsed(void) -{ - return 0; -} - -INT32 NDS3D_GetRenderVersion(void) -{ - return 0; -} diff --git a/src/nds/r_nds3d.h b/src/nds/r_nds3d.h deleted file mode 100644 index 3a7075bcd..000000000 --- a/src/nds/r_nds3d.h +++ /dev/null @@ -1,55 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief NDS 3D API for SRB2. - -#ifndef __R_NDS3D__ -#define __R_NDS3D__ - -#include "../doomtype.h" -#include "../hardware/hw_defs.h" -#include "../hardware/hw_dll.h" -#include "../hardware/hw_md2.h" - -#define FAR_CLIPPING_PLANE 150000.0f -#define ASPECT_RATIO 1.0f - -typedef float FCOORD; - -extern FCOORD NEAR_CLIPPING_PLANE; -extern float fov; - -boolean NDS3D_Init(I_Error_t ErrorFunction); -void NDS3D_Shutdown(void); -void NDS3D_SetPalette(RGBA_t *ppal, RGBA_t *pgamma); -void NDS3D_FinishUpdate(INT32 waitvbl); -void NDS3D_Draw2DLine(F2DCoord *v1, F2DCoord *v2, RGBA_t Color); -void NDS3D_DrawPolygon(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT iNumPts, FBITFIELD PolyFlags); -void NDS3D_SetBlend(FBITFIELD PolyFlags); -void NDS3D_ClearBuffer(FBOOLEAN ColorMask, FBOOLEAN DepthMask, FRGBAFloat *ClearColor); -void NDS3D_SetTexture(FTextureInfo *TexInfo); -void NDS3D_ReadRect(INT32 x, INT32 y, INT32 width, INT32 height, INT32 dst_stride, UINT16 *dst_data); -void NDS3D_GClipRect(INT32 minx, INT32 miny, INT32 maxx, INT32 maxy, float nearclip); -void NDS3D_ClearMipMapCache(void); -void NDS3D_SetSpecialState(hwdspecialstate_t IdState, INT32 Value); -void NDS3D_DrawMD2(INT32 *gl_cmd_buffer, md2_frame_t *frame, FTransform *pos, float scale); -void NDS3D_DrawMD2i(INT32 *gl_cmd_buffer, md2_frame_t *frame, UINT32 duration, UINT32 tics, md2_frame_t *nextframe, FTransform *pos, float scale, UINT8 flipped, UINT8 *color); -void NDS3D_SetTransform(FTransform *ptransform); -INT32 NDS3D_GetTextureUsed(void); -INT32 NDS3D_GetRenderVersion(void); - -#endif diff --git a/src/p_ceilng.c b/src/p_ceilng.c index 757edebae..c65156b6f 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -409,7 +409,7 @@ INT32 EV_DoCeiling(line_t *line, ceiling_e type) // new door thinker rtn = 1; ceiling = Z_Calloc(sizeof (*ceiling), PU_LEVSPEC, NULL); - P_AddThinker(&ceiling->thinker); + P_AddThinker(THINK_MAIN, &ceiling->thinker); sec->ceilingdata = ceiling; ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; ceiling->sector = sec; @@ -629,7 +629,7 @@ INT32 EV_DoCrush(line_t *line, ceiling_e type) // new door thinker rtn = 1; ceiling = Z_Calloc(sizeof (*ceiling), PU_LEVSPEC, NULL); - P_AddThinker(&ceiling->thinker); + P_AddThinker(THINK_MAIN, &ceiling->thinker); sec->ceilingdata = ceiling; ceiling->thinker.function.acp1 = (actionf_p1)T_CrushCeiling; ceiling->sector = sec; diff --git a/src/p_enemy.c b/src/p_enemy.c index 7c28854ea..9dea0ecc5 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,26 +15,27 @@ #include "doomdef.h" #include "g_game.h" #include "p_local.h" +#include "p_setup.h" #include "r_main.h" #include "r_state.h" #include "s_sound.h" #include "m_random.h" #include "m_misc.h" -#include "r_things.h" +#include "r_skins.h" #include "i_video.h" +#include "z_zone.h" #include "lua_hook.h" #ifdef HW3SOUND #include "hardware/hw3sound.h" #endif -#ifdef HAVE_BLUA boolean LUA_CallAction(const char *action, mobj_t *actor); -#endif player_t *stplyr; INT32 var1; INT32 var2; +INT32 modulothing; // // P_NewChaseDir related LUT. @@ -55,17 +56,31 @@ void A_Fall(mobj_t *actor); void A_Look(mobj_t *actor); void A_Chase(mobj_t *actor); void A_FaceStabChase(mobj_t *actor); +void A_FaceStabRev(mobj_t *actor); +void A_FaceStabHurl(mobj_t *actor); +void A_FaceStabMiss(mobj_t *actor); +void A_StatueBurst(mobj_t *actor); void A_JetJawRoam(mobj_t *actor); void A_JetJawChomp(mobj_t *actor); void A_PointyThink(mobj_t *actor); void A_CheckBuddy(mobj_t *actor); +void A_HoodFire(mobj_t *actor); void A_HoodThink(mobj_t *actor); -void A_ArrowCheck(mobj_t *actor); +void A_HoodFall(mobj_t *actor); +void A_ArrowBonks(mobj_t *actor); void A_SnailerThink(mobj_t *actor); void A_SharpChase(mobj_t *actor); void A_SharpSpin(mobj_t *actor); +void A_SharpDecel(mobj_t *actor); +void A_CrushstaceanWalk(mobj_t *actor); +void A_CrushstaceanPunch(mobj_t *actor); +void A_CrushclawAim(mobj_t *actor); +void A_CrushclawLaunch(mobj_t *actor); void A_VultureVtol(mobj_t *actor); void A_VultureCheck(mobj_t *actor); +void A_VultureHover(mobj_t *actor); +void A_VultureBlast(mobj_t *actor); +void A_VultureFly(mobj_t *actor); void A_SkimChase(mobj_t *actor); void A_FaceTarget(mobj_t *actor); void A_FaceTracer(mobj_t *actor); @@ -86,24 +101,21 @@ void A_Scream(mobj_t *actor); void A_Pain(mobj_t *actor); void A_1upThinker(mobj_t *actor); void A_MonitorPop(mobj_t *actor); +void A_GoldMonitorPop(mobj_t *actor); +void A_GoldMonitorRestore(mobj_t *actor); +void A_GoldMonitorSparkle(mobj_t *actor); void A_Explode(mobj_t *actor); void A_BossDeath(mobj_t *actor); void A_CustomPower(mobj_t *actor); void A_GiveWeapon(mobj_t *actor); -void A_JumpShield(mobj_t *actor); -void A_RingShield(mobj_t *actor); void A_RingBox(mobj_t *actor); void A_Invincibility(mobj_t *actor); void A_SuperSneakers(mobj_t *actor); void A_AwardScore(mobj_t *actor); void A_ExtraLife(mobj_t *actor); -void A_BombShield(mobj_t *actor); -void A_WaterShield(mobj_t *actor); -void A_ForceShield(mobj_t *actor); -void A_PityShield(mobj_t *actor); +void A_GiveShield(mobj_t *actor); void A_GravityBox(mobj_t *actor); void A_ScoreRise(mobj_t *actor); -void A_ParticleSpawn(mobj_t *actor); void A_BunnyHop(mobj_t *actor); void A_BubbleSpawn(mobj_t *actor); void A_FanBubbleSpawn(mobj_t *actor); @@ -115,6 +127,7 @@ void A_FishJump(mobj_t *actor); void A_ThrownRing(mobj_t *actor); void A_SetSolidSteam(mobj_t *actor); void A_UnsetSolidSteam(mobj_t *actor); +void A_SignSpin(mobj_t *actor); void A_SignPlayer(mobj_t *actor); void A_OverlayThink(mobj_t *actor); void A_JetChase(mobj_t *actor); @@ -131,7 +144,6 @@ void A_DetonChase(mobj_t *actor); void A_CapeChase(mobj_t *actor); void A_RotateSpikeBall(mobj_t *actor); void A_SlingAppear(mobj_t *actor); -void A_MaceRotate(mobj_t *actor); void A_UnidusBall(mobj_t *actor); void A_RockSpawn(mobj_t *actor); void A_SetFuse(mobj_t *actor); @@ -157,6 +169,7 @@ void A_SetReactionTime(mobj_t *actor); void A_Boss1Spikeballs(mobj_t *actor); void A_Boss3TakeDamage(mobj_t *actor); void A_Boss3Path(mobj_t *actor); +void A_Boss3ShockThink(mobj_t *actor); void A_LinedefExecute(mobj_t *actor); void A_PlaySeeSound(mobj_t *actor); void A_PlayAttackSound(mobj_t *actor); @@ -166,6 +179,9 @@ void A_SpawnObjectAbsolute(mobj_t *actor); void A_SpawnObjectRelative(mobj_t *actor); void A_ChangeAngleRelative(mobj_t *actor); void A_ChangeAngleAbsolute(mobj_t *actor); +void A_RollAngle(mobj_t *actor); +void A_ChangeRollAngleRelative(mobj_t *actor); +void A_ChangeRollAngleAbsolute(mobj_t *actor); void A_PlaySound(mobj_t *actor); void A_FindTarget(mobj_t *actor); void A_FindTracer(mobj_t *actor); @@ -223,7 +239,6 @@ void A_SetScale(mobj_t *actor); void A_RemoteDamage(mobj_t *actor); void A_HomingChase(mobj_t *actor); void A_TrapShot(mobj_t *actor); -//for p_enemy.c void A_Boss1Chase(mobj_t *actor); void A_Boss2Chase(mobj_t *actor); void A_Boss2Pogo(mobj_t *actor); @@ -236,6 +251,68 @@ void A_BrakFireShot(mobj_t *actor); void A_BrakLobShot(mobj_t *actor); void A_NapalmScatter(mobj_t *actor); void A_SpawnFreshCopy(mobj_t *actor); +void A_FlickySpawn(mobj_t *actor); +void A_FlickyCenter(mobj_t *actor); +void A_FlickyAim(mobj_t *actor); +void A_FlickyFly(mobj_t *actor); +void A_FlickySoar(mobj_t *actor); +void A_FlickyCoast(mobj_t *actor); +void A_FlickyHop(mobj_t *actor); +void A_FlickyFlounder(mobj_t *actor); +void A_FlickyCheck(mobj_t *actor); +void A_FlickyHeightCheck(mobj_t *actor); +void A_FlickyFlutter(mobj_t *actor); +void A_FlameParticle(mobj_t *actor); +void A_FadeOverlay(mobj_t *actor); +void A_Boss5Jump(mobj_t *actor); +void A_LightBeamReset(mobj_t *actor); +void A_MineExplode(mobj_t *actor); +void A_MineRange(mobj_t *actor); +void A_ConnectToGround(mobj_t *actor); +void A_SpawnParticleRelative(mobj_t *actor); +void A_MultiShotDist(mobj_t *actor); +void A_WhoCaresIfYourSonIsABee(mobj_t *actor); +void A_ParentTriesToSleep(mobj_t *actor); +void A_CryingToMomma(mobj_t *actor); +void A_CheckFlags2(mobj_t *actor); +void A_Boss5FindWaypoint(mobj_t *actor); +void A_DoNPCSkid(mobj_t *actor); +void A_DoNPCPain(mobj_t *actor); +void A_PrepareRepeat(mobj_t *actor); +void A_Boss5ExtraRepeat(mobj_t *actor); +void A_Boss5Calm(mobj_t *actor); +void A_Boss5CheckOnGround(mobj_t *actor); +void A_Boss5CheckFalling(mobj_t *actor); +void A_Boss5PinchShot(mobj_t *actor); +void A_Boss5MakeItRain(mobj_t *actor); +void A_Boss5MakeJunk(mobj_t *actor); +void A_LookForBetter(mobj_t *actor); +void A_Boss5BombExplode(mobj_t *actor); +void A_DustDevilThink(mobj_t *actor); +void A_TNTExplode(mobj_t *actor); +void A_DebrisRandom(mobj_t *actor); +void A_TrainCameo(mobj_t *actor); +void A_TrainCameo2(mobj_t *actor); +void A_CanarivoreGas(mobj_t *actor); +void A_KillSegments(mobj_t *actor); +void A_SnapperSpawn(mobj_t *actor); +void A_SnapperThinker(mobj_t *actor); +void A_SaloonDoorSpawn(mobj_t *actor); +void A_MinecartSparkThink(mobj_t *actor); +void A_ModuloToState(mobj_t *actor); +void A_LavafallRocks(mobj_t *actor); +void A_LavafallLava(mobj_t *actor); +void A_FallingLavaCheck(mobj_t *actor); +void A_FireShrink(mobj_t *actor); +void A_SpawnPterabytes(mobj_t *actor); +void A_PterabyteHover(mobj_t *actor); +void A_RolloutSpawn(mobj_t *actor); +void A_RolloutRock(mobj_t *actor); +void A_DragonbomberSpawn(mobj_t *actor); +void A_DragonWing(mobj_t *actor); +void A_DragonSegment(mobj_t *actor); + +//for p_enemy.c // // ENEMY THINKING @@ -655,15 +732,21 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if ((netgame || multiplayer) && player->spectator) continue; - if (player->health <= 0) - continue; // dead - if (player->pflags & PF_INVIS) continue; // ignore notarget if (!player->mo || P_MobjWasRemoved(player->mo)) continue; + if (player->mo->health <= 0) + continue; // dead + + if (player->bot) + continue; // ignore bots + + if (player->quittime) + continue; // Ignore uncontrolled bodies + if (dist > 0 && P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) continue; // Too far away @@ -727,7 +810,7 @@ static boolean P_LookForShield(mobj_t *actor) player = &players[actor->lastlook]; - if (player->health <= 0 || !player->mo) + if (!player->mo || player->mo->health <= 0) continue; // dead //When in CTF, don't pull rings that you cannot pick up. @@ -735,10 +818,16 @@ static boolean P_LookForShield(mobj_t *actor) (actor->type == MT_BLUETEAMRING && player->ctfteam != 2)) continue; - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT + if ((player->powers[pw_shield] & SH_PROTECTELECTRIC) && (P_AproxDistance(P_AproxDistance(actor->x-player->mo->x, actor->y-player->mo->y), actor->z-player->mo->z) < FixedMul(RING_DIST, player->mo->scale))) { P_SetTarget(&actor->tracer, player->mo); + + if (actor->hnext) + P_SetTarget(&actor->hnext->hprev, actor->hprev); + if (actor->hprev) + P_SetTarget(&actor->hprev->hnext, actor->hnext); + return true; } } @@ -818,6 +907,60 @@ static int P_RecycleCompare(const void *p1, const void *p2) } #endif +// Handles random monitor weights via console. +static mobjtype_t P_DoRandomBoxChances(void) +{ + mobjtype_t spawnchance[256]; + INT32 numchoices = 0, i = 0; + + if (!(netgame || multiplayer)) + { + switch (P_RandomKey(10)) + { + case 0: + return MT_RING_ICON; + case 1: + return MT_SNEAKERS_ICON; + case 2: + return MT_INVULN_ICON; + case 3: + return MT_WHIRLWIND_ICON; + case 4: + return MT_ELEMENTAL_ICON; + case 5: + return MT_ATTRACT_ICON; + case 6: + return MT_FORCE_ICON; + case 7: + return MT_ARMAGEDDON_ICON; + case 8: + return MT_1UP_ICON; + case 9: + return MT_EGGMAN_ICON; + } + return MT_NULL; + } + +#define QUESTIONBOXCHANCES(type, cvar) \ +for (i = cvar.value; i; --i) spawnchance[numchoices++] = type + QUESTIONBOXCHANCES(MT_RING_ICON, cv_superring); + QUESTIONBOXCHANCES(MT_SNEAKERS_ICON, cv_supersneakers); + QUESTIONBOXCHANCES(MT_INVULN_ICON, cv_invincibility); + QUESTIONBOXCHANCES(MT_WHIRLWIND_ICON, cv_jumpshield); + QUESTIONBOXCHANCES(MT_ELEMENTAL_ICON, cv_watershield); + QUESTIONBOXCHANCES(MT_ATTRACT_ICON, cv_ringshield); + QUESTIONBOXCHANCES(MT_FORCE_ICON, cv_forceshield); + QUESTIONBOXCHANCES(MT_ARMAGEDDON_ICON, cv_bombshield); + QUESTIONBOXCHANCES(MT_1UP_ICON, cv_1up); + QUESTIONBOXCHANCES(MT_EGGMAN_ICON, cv_eggmanbox); + QUESTIONBOXCHANCES(MT_MIXUP_ICON, cv_teleporters); + QUESTIONBOXCHANCES(MT_RECYCLER_ICON, cv_recycler); +#undef QUESTIONBOXCHANCES + + if (numchoices == 0) return MT_NULL; + return spawnchance[P_RandomKey(numchoices)]; +} + // // ACTION ROUTINES // @@ -836,10 +979,8 @@ void A_Look(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Look", actor)) return; -#endif if (!P_LookForPlayers(actor, locvar1 & 65535, false , FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale))) return; @@ -871,10 +1012,8 @@ void A_Chase(mobj_t *actor) INT32 delta; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Chase", actor)) return; -#endif I_Assert(actor != NULL); I_Assert(!P_MobjWasRemoved(actor)); @@ -955,7 +1094,7 @@ nomissile: // Function: A_FaceStabChase // -// Description: A_Chase for CastleBot FaceStabber. +// Description: Unused variant of A_Chase for Castlebot Facestabber. // // var1 = unused // var2 = unused @@ -964,10 +1103,8 @@ void A_FaceStabChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceStabChase", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -1043,6 +1180,260 @@ nomissile: P_NewChaseDir(actor); } +static void P_SharpDust(mobj_t *actor, mobjtype_t type, angle_t ang) +{ + mobj_t *dust; + + if (!type || !P_IsObjectOnGround(actor)) + return; + + dust = P_SpawnMobjFromMobj(actor, + -P_ReturnThrustX(actor, ang, 16<angle, actor->radius), + -P_ReturnThrustY(actor, actor->angle, actor->radius), + actor->height/3, + MT_PARTICLE); + flume->destscale = actor->scale*3; + P_SetScale(flume, flume->destscale); + P_SetTarget(&flume->target, actor); + flume->sprite = SPR_JETF; + flume->frame = FF_FULLBRIGHT; + flume->tics = 2; +} + +// Function: A_FaceStabRev +// +// Description: Facestabber rev action +// +// var1 = effective duration +// var2 = effective nextstate +// +void A_FaceStabRev(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FaceStabRev", actor)) + return; + + if (!actor->target) + { + P_SetMobjState(actor, actor->info->spawnstate); + return; + } + + actor->extravalue1 = 0; + + if (!actor->reactiontime) + { + actor->reactiontime = locvar1; + S_StartSound(actor, actor->info->activesound); + } + else + { + if ((--actor->reactiontime) == 0) + { + S_StartSound(actor, actor->info->attacksound); + P_SetMobjState(actor, locvar2); + } + else + { + P_TryMove(actor, actor->x - P_ReturnThrustX(actor, actor->angle, 2<y - P_ReturnThrustY(actor, actor->angle, 2<target) + { + angle_t visang = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + // Calculate new direction. + angle_t dirang = actor->angle; + angle_t diffang = visang - dirang; + + if (locvar1) // Allow homing? + { + if (diffang > ANGLE_180) + { + angle_t workang = locvar1*(InvAngle(diffang)>>5); + diffang += InvAngle(workang); + } + else + diffang += (locvar1*(diffang>>5)); + } + diffang += ANGLE_45; + + // Check the sight cone. + if (diffang < ANGLE_90) + { + actor->angle = dirang; + if (++actor->extravalue2 < 4) + actor->extravalue2 = 4; + else if (actor->extravalue2 > 26) + actor->extravalue2 = 26; + + if (P_TryMove(actor, + actor->x + P_ReturnThrustX(actor, dirang, actor->extravalue2<y + P_ReturnThrustY(actor, dirang, actor->extravalue2<extravalue1); + fixed_t basesize = FRACUNIT/MAXVAL; + mobj_t *hwork = actor; + INT32 dist = 113; + fixed_t xo = P_ReturnThrustX(actor, actor->angle, dist*basesize); + fixed_t yo = P_ReturnThrustY(actor, actor->angle, dist*basesize); + + while (step > 0) + { + if (!hwork->hnext) + P_SetTarget(&hwork->hnext, P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_FACESTABBERSPEAR)); + hwork = hwork->hnext; + hwork->angle = actor->angle + ANGLE_90; + hwork->destscale = FixedSqrt(step*basesize); + P_SetScale(hwork, hwork->destscale); + hwork->fuse = 2; + P_TeleportMove(hwork, actor->x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<extravalue1 >= MAXVAL) + actor->extravalue1 -= NUMGRADS; + + if ((step % 5) == 0) + P_SharpDust(actor, MT_SPINDUST, actor->angle); + + P_FaceStabFlume(actor); + return; +#undef MAXVAL +#undef NUMGRADS +#undef NUMSTEPS + } + } + } + + P_SetMobjState(actor, locvar2); + actor->reactiontime = actor->info->reactiontime; +} + +// Function: A_FaceStabMiss +// +// Description: Facestabber miss action +// +// var1 = unused +// var2 = effective nextstate +// +void A_FaceStabMiss(mobj_t *actor) +{ + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FaceStabMiss", actor)) + return; + + if (++actor->extravalue1 >= 3) + { + actor->extravalue2 -= 2; + actor->extravalue1 = 0; + S_StartSound(actor, sfx_s3k47); + P_SharpDust(actor, MT_SPINDUST, actor->angle); + } + + if (actor->extravalue2 <= 0 || !P_TryMove(actor, + actor->x + P_ReturnThrustX(actor, actor->angle, actor->extravalue2<y + P_ReturnThrustY(actor, actor->angle, actor->extravalue2<extravalue2 = 0; + P_SetMobjState(actor, locvar2); + } +} + +// Function: A_StatueBurst +// +// Description: For suspicious statues only... +// +// var1 = object to create +// var2 = effective nextstate for created object +// +void A_StatueBurst(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + mobjtype_t chunktype = (mobjtype_t)actor->info->raisestate; + mobj_t *new; + + if (LUA_CallAction("A_StatueBurst", actor)) + return; + + if (!locvar1 || !(new = P_SpawnMobjFromMobj(actor, 0, 0, 0, locvar1))) + return; + + new->angle = actor->angle; + P_SetTarget(&new->target, actor->target); + if (locvar2) + P_SetMobjState(new, (statenum_t)locvar2); + S_StartSound(new, new->info->attacksound); + S_StopSound(actor); + S_StartSound(actor, sfx_s3k96); + + { + fixed_t a, b; + fixed_t c = (actor->height>>2) - FixedMul(actor->scale, mobjinfo[chunktype].height>>1); + fixed_t v = 4<radius>>1); + mobj_t *spawned; + UINT8 i; + for (i = 0; i < 8; i++) + { + a = ((i & 1) ? r : (-r)); + b = ((i & 2) ? r : (-r)); + if (i == 4) + { + c += (actor->height>>1); + v = 8<fuse = 3*TICRATE; + } + } +} + // Function: A_JetJawRoam // // Description: Roaming routine for JetJaw @@ -1052,10 +1443,9 @@ nomissile: // void A_JetJawRoam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_JetJawRoam", actor)) return; -#endif + if (actor->reactiontime) { actor->reactiontime--; @@ -1081,10 +1471,9 @@ void A_JetJawRoam(mobj_t *actor) void A_JetJawChomp(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetJawChomp", actor)) return; -#endif // turn towards movement direction if not there yet if (actor->movedir < NUMDIRS) @@ -1130,10 +1519,9 @@ void A_PointyThink(mobj_t *actor) boolean firsttime = true; INT32 sign; -#ifdef HAVE_BLUA if (LUA_CallAction("A_PointyThink", actor)) return; -#endif + actor->momx = actor->momy = actor->momz = 0; // Find nearest player @@ -1229,16 +1617,69 @@ void A_CheckBuddy(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckBuddy", actor)) return; -#endif + if (locvar1 && (!actor->tracer || actor->tracer->health <= 0)) P_RemoveMobj(actor); else if (!locvar1 && (!actor->target || actor->target->health <= 0)) P_RemoveMobj(actor); } +// Helper function for the Robo Hood. +// Don't ask me how it works. Nev3r made it with dark majyks. +static void P_ParabolicMove(mobj_t *actor, fixed_t x, fixed_t y, fixed_t z, fixed_t speed) +{ + fixed_t dh; + + x -= actor->x; + y -= actor->y; + z -= actor->z; + + dh = P_AproxDistance(x, y); + + actor->momx = FixedMul(FixedDiv(x, dh), speed); + actor->momy = FixedMul(FixedDiv(y, dh), speed); + + if (!gravity) + return; + + dh = FixedDiv(FixedMul(dh, gravity), speed); + actor->momz = (dh>>1) + FixedDiv(z, dh<<1); +} + +// Function: A_HoodFire +// +// Description: Firing Robo-Hood +// +// var1 = object type to fire +// var2 = unused +// +void A_HoodFire(mobj_t *actor) +{ + mobj_t *arrow; + INT32 locvar1 = var1; + + if (LUA_CallAction("A_HoodFire", actor)) + return; + + // Check target first. + if (!actor->target) + { + actor->reactiontime = actor->info->reactiontime; + P_SetMobjState(actor, actor->info->spawnstate); + return; + } + + A_FaceTarget(actor); + + if (!(arrow = P_SpawnMissile(actor, actor->target, (mobjtype_t)locvar1))) + return; + + // Set a parabolic trajectory for the arrow. + P_ParabolicMove(arrow, actor->target->x, actor->target->y, actor->target->z, arrow->info->speed); +} + // Function: A_HoodThink // // Description: Thinker for Robo-Hood @@ -1248,97 +1689,108 @@ void A_CheckBuddy(mobj_t *actor) // void A_HoodThink(mobj_t *actor) { -#ifdef HAVE_BLUA + fixed_t dx, dy, dz, dm; + boolean checksight; + if (LUA_CallAction("A_HoodThink", actor)) return; -#endif - // Currently in the air... - if (!(actor->eflags & MFE_VERTICALFLIP) && actor->z > actor->floorz) - { - if (actor->momz > 0) - P_SetMobjStateNF(actor, actor->info->xdeathstate); // Rising - else - P_SetMobjStateNF(actor, actor->info->raisestate); // Falling - - return; - } - else if ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height < actor->ceilingz) - { - if (actor->momz < 0) - P_SetMobjStateNF(actor, actor->info->xdeathstate); // Rising - else - P_SetMobjStateNF(actor, actor->info->raisestate); // Falling - - return; - } - - if (actor->state == &states[actor->info->xdeathstate] - || actor->state == &states[actor->info->raisestate]) - P_SetMobjStateNF(actor, actor->info->seestate); + // Check target first. if (!actor->target) { + actor->reactiontime = actor->info->reactiontime; P_SetMobjState(actor, actor->info->spawnstate); return; } - A_FaceTarget(actor); // Aiming... aiming... - - if (--actor->reactiontime > 0) + dx = (actor->target->x - actor->x), dy = (actor->target->y - actor->y), dz = (actor->target->z - actor->z); + dm = P_AproxDistance(dx, dy); + // Target dangerously close to robohood, retreat then. + if ((dm < 256<info->attacksound); + P_SetMobjState(actor, actor->info->raisestate); return; + } - // Shoot, if not too close (cheap shots are lame) - if ((P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) > FixedMul(192*FRACUNIT, actor->scale)) - || (actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH))) // If you can't jump, might as well shoot regardless of distance! - P_SetMobjState(actor, actor->info->missilestate); - else if (!(actor->spawnpoint && (actor->spawnpoint->options & MTF_AMBUSH)))// But we WILL jump! - P_SetMobjState(actor, actor->info->painstate); + // If target on sight, look at it. + if ((checksight = P_CheckSight(actor, actor->target))) + { + angle_t dang = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + if (actor->angle >= ANGLE_180) + { + actor->angle = InvAngle(actor->angle)>>1; + actor->angle = InvAngle(actor->angle); + } + else + actor->angle >>= 1; - actor->reactiontime = actor->info->reactiontime; + if (dang >= ANGLE_180) + { + dang = InvAngle(dang)>>1; + dang = InvAngle(dang); + } + else + dang >>= 1; + + actor->angle += dang; + } + + // Check whether to do anything. + if ((--actor->reactiontime) <= 0) + { + actor->reactiontime = actor->info->reactiontime; + + // If way too far, don't shoot. + if ((dm < (3072<info->missilestate); + return; + } + } } -// Function: A_ArrowCheck +// Function: A_HoodFall // -// Description: Checks arrow direction and adjusts sprite accordingly +// Description: Falling Robo-Hood // // var1 = unused // var2 = unused // -void A_ArrowCheck(mobj_t *actor) +void A_HoodFall(mobj_t *actor) { - fixed_t x,y,z; - angle_t angle; - fixed_t dist; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_ArrowCheck", actor)) + if (LUA_CallAction("A_HoodFall", actor)) return; -#endif - // Movement vector - x = actor->momx; - y = actor->momy; - z = actor->momz; + if (!P_IsObjectOnGround(actor)) + return; - // Calculate the angle of movement. - /* - Z - / | - / | - / | - 0------dist(X,Y) - */ + actor->momx = actor->momy = 0; + actor->reactiontime = actor->info->reactiontime; + P_SetMobjState(actor, actor->info->seestate); +} - dist = P_AproxDistance(x, y); +// Function: A_ArrowBonks +// +// Description: Arrow momentum setting on collision +// +// var1 = unused +// var2 = unused +// +void A_ArrowBonks(mobj_t *actor) +{ + if (LUA_CallAction("A_ArrowBonks", actor)) + return; - angle = R_PointToAngle2(0, 0, dist, z); + if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) + || (!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz)) + actor->angle += ANGLE_180; - if (angle > ANG20 && angle <= ANGLE_180) - P_SetMobjStateNF(actor, actor->info->raisestate); - else if (angle < ANG340 && angle > ANGLE_180) - P_SetMobjStateNF(actor, actor->info->xdeathstate); - else - P_SetMobjStateNF(actor, actor->info->spawnstate); + P_SetObjectMomZ(actor, 8*actor->scale, false); + P_InstaThrust(actor, actor->angle, -6*actor->scale); + + actor->flags = (actor->flags|MF_NOCLIPHEIGHT) & ~MF_NOGRAVITY; + actor->z += P_MobjFlip(actor); } // Function: A_SnailerThink @@ -1350,10 +1802,8 @@ void A_ArrowCheck(mobj_t *actor) // void A_SnailerThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SnailerThink", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -1418,23 +1868,15 @@ void A_SnailerThink(mobj_t *actor) // Function: A_SharpChase // -// Description: Thinker/Chase routine for Sharps +// Description: Thinker/Chase routine for Spincushions // // var1 = unused // var2 = unused // void A_SharpChase(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SharpChase", actor)) return; -#endif - - if (!actor->health) - { - P_SetMobjState(actor, actor->info->deathstate); - return; - } if (actor->reactiontime) { @@ -1478,40 +1920,317 @@ void A_SharpChase(mobj_t *actor) // Function: A_SharpSpin // -// Description: Spin chase routine for Sharps +// Description: Spin chase routine for Spincushions // -// var1 = unused -// var2 = unused +// var1 = object # to spawn as dust (if not provided not done) +// var2 = if nonzero, do the old-style spinning using this as the angle difference // void A_SharpSpin(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 locvar1 = var1; + INT32 locvar2 = var2; + angle_t oldang = actor->angle; + if (LUA_CallAction("A_SharpSpin", actor)) return; -#endif - - if (!actor->health) - { - P_SetMobjState(actor, actor->info->deathstate); - return; - } if (actor->threshold && actor->target) { - actor->angle += ANGLE_22h; - P_Thrust(actor, R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y), FixedMul(actor->info->speed*FRACUNIT, actor->scale)); + angle_t ang = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + P_Thrust(actor, ang, actor->info->speed*actor->scale); + if (locvar2) + actor->angle += locvar2; // ANGLE_22h; + else + actor->angle = ang; actor->threshold--; + if (leveltime & 1) + S_StartSound(actor, actor->info->painsound); } else { actor->reactiontime = actor->info->reactiontime; - P_SetMobjState(actor, actor->info->spawnstate); - - var1 = 1; - A_Look(actor); - if (actor->target) - actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + P_SetMobjState(actor, actor->info->meleestate); } + + P_SharpDust(actor, locvar1, oldang); +} + +// Function: A_SharpDecel +// +// Description: Slow down the Spincushion +// +// var1 = unused +// var2 = unused +// +void A_SharpDecel(mobj_t *actor) +{ + if (LUA_CallAction("A_SharpDecel", actor)) + return; + + if (actor->momx > 2 || actor->momy > 2) + { + actor->momx >>= 1; + actor->momy >>= 1; + } + else + P_SetMobjState(actor, actor->info->xdeathstate); +} + +// Function: A_CrushstaceanWalk +// +// Description: Crushstacean movement +// +// var1 = speed (actor info's speed if 0) +// var2 = state to switch to when blocked (spawnstate if 0) +// +void A_CrushstaceanWalk(mobj_t *actor) +{ + INT32 locvar1 = (var1 ? var1 : (INT32)actor->info->speed); + INT32 locvar2 = (var2 ? var2 : (INT32)actor->info->spawnstate); + angle_t ang = actor->angle + ((actor->flags2 & MF2_AMBUSH) ? ANGLE_90 : ANGLE_270); + + if (LUA_CallAction("A_CrushstaceanWalk", actor)) + return; + + actor->reactiontime--; + + if (!P_TryMove(actor, + actor->x + P_ReturnThrustX(actor, ang, locvar1*actor->scale), + actor->y + P_ReturnThrustY(actor, ang, locvar1*actor->scale), + false) + || (actor->reactiontime-- <= 0)) + { + actor->flags2 ^= MF2_AMBUSH; + P_SetTarget(&actor->target, NULL); + P_SetMobjState(actor, locvar2); + actor->reactiontime = actor->info->reactiontime; + } +} + +// Function: A_CrushstaceanPunch +// +// Description: Crushstacean attack +// +// var1 = unused +// var2 = state to go to if unsuccessful (spawnstate if 0) +// +void A_CrushstaceanPunch(mobj_t *actor) +{ + INT32 locvar2 = (var2 ? var2 : (INT32)actor->info->spawnstate); + + if (LUA_CallAction("A_CrushstaceanPunch", actor)) + return; + + if (!actor->tracer) + return; + + if (!actor->target) + { + P_SetMobjState(actor, locvar2); + return; + } + + actor->tracer->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + P_SetMobjState(actor->tracer, actor->tracer->info->missilestate); + actor->tracer->extravalue1 = actor->tracer->extravalue2 = 0; + S_StartSound(actor, actor->info->attacksound); +} + +// Function: A_CrushclawAim +// +// Description: Crushstacean claw aiming +// +// var1 = sideways offset +// var2 = vertical offset +// +void A_CrushclawAim(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + mobj_t *crab = actor->tracer; + angle_t ang; + + if (LUA_CallAction("A_CrushclawAim", actor)) + return; + + if (!crab) + { + P_RemoveMobj(actor); + return; // there is only one step and it is crab + } + + if (crab->target || P_LookForPlayers(crab, true, false, actor->info->speed*crab->scale)) + ang = R_PointToAngle2(crab->x, crab->y, crab->target->x, crab->target->y); + else + ang = crab->angle + ((crab->flags2 & MF2_AMBUSH) ? ANGLE_90 : ANGLE_270); + ang -= actor->angle; + +#define anglimit ANGLE_22h +#define angfactor 5 + if (ang < ANGLE_180) + { + if (ang > anglimit) + ang = anglimit; + ang /= angfactor; + } + else + { + ang = InvAngle(ang); + if (ang > anglimit) + ang = anglimit; + ang = InvAngle(ang/angfactor); + } + actor->angle += ang; +#undef anglimit +#undef angfactor + + P_TeleportMove(actor, + crab->x + P_ReturnThrustX(actor, actor->angle, locvar1*crab->scale), + crab->y + P_ReturnThrustY(actor, actor->angle, locvar1*crab->scale), + crab->z + locvar2*crab->scale); + + if (!crab->target || !crab->info->missilestate || (statenum_t)(crab->state-states) == crab->info->missilestate) + return; + + if (((ang + ANG1) < ANG2) || P_AproxDistance(crab->x - crab->target->x, crab->y - crab->target->y) < 333*crab->scale) + P_SetMobjState(crab, crab->info->missilestate); +} + +// Function: A_CrushclawLaunch +// +// Description: Crushstacean claw launching +// +// var1: +// 0 - forwards +// anything else - backwards +// var2 = state to change to when done +// +void A_CrushclawLaunch(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + mobj_t *crab = actor->tracer; + + if (LUA_CallAction("A_CrushclawLaunch", actor)) + return; + + if (!crab) + { + mobj_t *chainnext; + while (actor) + { + chainnext = actor->target; + P_RemoveMobj(actor); + actor = chainnext; + } + return; // there is only one step and it is crab + } + + if (!actor->extravalue1) + { + S_StartSound(actor, actor->info->activesound); + actor->extravalue1 = ((locvar1) ? -1 : 32); + } + else if (actor->extravalue1 != 1) + actor->extravalue1 -= 1; + +#define CSEGS 5 + if (!actor->target) + { + mobj_t *prevchain = actor; + UINT8 i = 0; + for (i = 0; (i < CSEGS); i++) + { + mobj_t *newchain = P_SpawnMobjFromMobj(actor, 0, 0, 0, (mobjtype_t)actor->info->raisestate); + P_SetTarget(&prevchain->target, newchain); + prevchain = newchain; + } + actor->target->angle = R_PointToAngle2(actor->target->x, actor->target->y, crab->target->x, crab->target->y); + } + + if ((!locvar1) && crab->target) + { +#define anglimit ANGLE_22h +#define angfactor 7 + angle_t ang = R_PointToAngle2(actor->target->x, actor->target->y, crab->target->x, crab->target->y) - actor->target->angle; + if (ang < ANGLE_180) + { + if (ang > anglimit) + ang = anglimit; + ang /= angfactor; + } + else + { + ang = InvAngle(ang); + if (ang > anglimit) + ang = anglimit; + ang /= angfactor; + ang = InvAngle(ang); + } + actor->target->angle += ang; + actor->angle = actor->target->angle; + } + + actor->extravalue2 += actor->extravalue1; + + if (!P_TryMove(actor, + actor->target->x + P_ReturnThrustX(actor, actor->target->angle, actor->extravalue2*actor->scale), + actor->target->y + P_ReturnThrustY(actor, actor->target->angle, actor->extravalue2*actor->scale), + true) + && !locvar1) + { + actor->extravalue1 = 0; + actor->extravalue2 = FixedHypot(actor->x - actor->target->x, actor->y - actor->target->y)>>FRACBITS; + P_SetMobjState(actor, locvar2); + S_StopSound(actor); + S_StartSound(actor, sfx_s3k49); + } + else + { + actor->z = actor->target->z; + if ((!locvar1 && (actor->extravalue2 > 256)) || (locvar1 && (actor->extravalue2 < 16))) + { + if (locvar1) // In case of retracting, resume crab and remove the chain. + { + mobj_t *chain = actor->target, *chainnext; + while (chain) + { + chainnext = chain->target; + P_RemoveMobj(chain); + chain = chainnext; + } + actor->extravalue2 = 0; + actor->angle = R_PointToAngle2(crab->x, crab->y, actor->x, actor->y); + P_SetTarget(&actor->target, NULL); + P_SetTarget(&crab->target, NULL); + P_SetMobjState(crab, crab->state->nextstate); + } + actor->extravalue1 = 0; + P_SetMobjState(actor, locvar2); + S_StopSound(actor); + if (!locvar1) + S_StartSound(actor, sfx_s3k64); + } + } + + if (!actor->target) + return; + + { + mobj_t *chain = actor->target->target; + fixed_t dx = (actor->x - actor->target->x)/CSEGS, dy = (actor->y - actor->target->y)/CSEGS, dz = (actor->z - actor->target->z)/CSEGS; + fixed_t idx = dx, idy = dy, idz = dz; + while (chain) + { + P_TeleportMove(chain, actor->target->x + idx, actor->target->y + idy, actor->target->z + idz); + chain->movefactor = chain->z; + idx += dx; + idy += dy; + idz += dz; + chain = chain->target; + } + } +#undef CSEGS } // Function: A_VultureVtol @@ -1523,10 +2242,8 @@ void A_SharpSpin(mobj_t *actor) // void A_VultureVtol(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_VultureVtol", actor)) return; -#endif if (!actor->target) return; @@ -1560,10 +2277,8 @@ void A_VultureVtol(mobj_t *actor) // void A_VultureCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_VultureCheck", actor)) return; -#endif if (actor->momx || actor->momy) return; @@ -1577,6 +2292,229 @@ void A_VultureCheck(mobj_t *actor) } } +static void P_VultureHoverParticle(mobj_t *actor) +{ + fixed_t fdist = actor->z - P_FloorzAtPos(actor->x, actor->y, actor->z, actor->height); + + if (fdist < 128*FRACUNIT) + { + mobj_t *dust; + UINT8 i; + angle_t angle = (leveltime % 2)*ANGLE_45/2; + + for (i = 0; i <= 7; i++) + { + angle_t fa = (angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t px = actor->x + FixedMul(fdist + 64*FRACUNIT, FINECOSINE(fa)); + fixed_t py = actor->y + FixedMul(fdist + 64*FRACUNIT, FINESINE(fa)); + fixed_t pz = P_FloorzAtPos(px, py, actor->z, actor->height); + + dust = P_SpawnMobj(px, py, pz, MT_ARIDDUST); + P_SetMobjState(dust, (statenum_t)(dust->state - states + P_RandomRange(0, 2))); + P_Thrust(dust, angle, FixedDiv(12*FRACUNIT, max(FRACUNIT, fdist/2))); + dust->momx += actor->momx; + dust->momy += actor->momy; + angle += ANGLE_45; + } + } +} + +// Function: A_VultureHover +// +// Description: Vulture hovering and checking whether to attack. +// +// var1 = unused +// var2 = unused +// +void A_VultureHover(mobj_t *actor) +{ + fixed_t targetz; + fixed_t distdif; + fixed_t memz = actor->z; + SINT8 i; + + if (LUA_CallAction("A_VultureHover", actor)) + return; + + if (!actor->target || P_MobjWasRemoved(actor->target)) + { + P_SetMobjState(actor, actor->info->spawnstate); + return; + } + + actor->flags |= MF_NOGRAVITY; + + actor->momx -= actor->momx/24; + actor->momy -= actor->momy/24; + + P_VultureHoverParticle(actor); + + A_FaceTarget(actor); + targetz = actor->target->z + actor->target->height / 2; + for (i = -1; i <= 1; i++) + { + actor->z = targetz - i * 128 * FRACUNIT; + if (P_CheckSight(actor, actor->target)) + { + targetz -= i * 128 * FRACUNIT; + break; + } + } + actor->z = memz; + + distdif = (actor->z + actor->height/2) - targetz; + + if (abs(actor->momz*16) > abs(distdif)) + actor->momz -= actor->momz/16; + else if (distdif < 0) + actor->momz = min(actor->momz+FRACUNIT/8, actor->info->speed*FRACUNIT); + else + actor->momz = max(actor->momz-FRACUNIT/8, -actor->info->speed*FRACUNIT); + + if (abs(distdif) < 128*FRACUNIT && abs(actor->momz) < FRACUNIT && P_CheckSight(actor, actor->target)) + { + P_SetMobjState(actor, actor->info->missilestate); + actor->momx = 0; + actor->momy = 0; + actor->momz = 0; + actor->extravalue1 = 0; + } +} + +// Function: A_VultureBlast +// +// Description: Vulture spawning a dust cloud. +// +// var1 = unused +// var2 = unused +// +void A_VultureBlast(mobj_t *actor) +{ + mobj_t *dust; + UINT8 i; + angle_t faa; + fixed_t faacos, faasin; + + if (LUA_CallAction("A_VultureBlast", actor)) + return; + + S_StartSound(actor, actor->info->attacksound); + + faa = (actor->angle >> ANGLETOFINESHIFT) & FINEMASK; + faacos = FINECOSINE(faa); + faasin = FINESINE(faa); + + for (i = 0; i <= 7; i++) + { + angle_t fa = ((i*(angle_t)ANGLE_45) >> ANGLETOFINESHIFT) & FINEMASK; + dust = P_SpawnMobj(actor->x + 48*FixedMul(FINECOSINE(fa), -faasin), actor->y + 48*FixedMul(FINECOSINE(fa), faacos), actor->z + actor->height/2 + 48*FINESINE(fa), MT_PARTICLE); + + P_SetScale(dust, 4*FRACUNIT); + dust->destscale = FRACUNIT; + dust->scalespeed = 4*FRACUNIT/TICRATE; + dust->fuse = TICRATE; + dust->momx = FixedMul(FINECOSINE(fa), -faasin)*3; + dust->momy = FixedMul(FINECOSINE(fa), faacos)*3; + dust->momz = FINESINE(fa)*6; + } +} + +// Function: A_VultureFly +// +// Description: Vulture charging towards target. +// +// var1 = unused +// var2 = unused +// +void A_VultureFly(mobj_t *actor) +{ + fixed_t speedmax = 18*FRACUNIT; + angle_t angledif; + fixed_t dx, dy, dz, dxy, dm; + mobj_t *dust; + fixed_t momm; + + if (LUA_CallAction("A_VultureFly", actor)) + return; + + if (!actor->target || P_MobjWasRemoved(actor->target)) + { + P_SetMobjState(actor, actor->info->spawnstate); + return; + } + + angledif = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) - actor->angle; + dx = actor->target->x - actor->x; + dy = actor->target->y - actor->y; + dz = actor->target->z - actor->z; + dxy = FixedHypot(dx, dy); + + if (leveltime % 4 == 0) + S_StartSound(actor, actor->info->activesound); + + if (angledif > ANGLE_180) + angledif = InvAngle(angledif); + + // Tweak the target height according to the position. + if (angledif < ANGLE_45) // Centered? + { + actor->reactiontime = actor->info->reactiontime; + if (dxy > 768*FRACUNIT) + dz = max(P_FloorzAtPos(actor->target->x, actor->target->y, actor->target->z, 0) - actor->z + min(dxy/8, 128*FRACUNIT), dz); + } + else + { + actor->reactiontime--; + + if (angledif < ANGLE_90) + dz = max(P_FloorzAtPos(actor->target->x, actor->target->y, actor->target->z, 0) - actor->z + min(dxy/2, 192*FRACUNIT), dz); + else + dz = max(P_FloorzAtPos(actor->target->x, actor->target->y, actor->target->z, 0) - actor->z + 232*FRACUNIT, dz); + } + + dm = FixedHypot(dz, dxy); + + P_VultureHoverParticle(actor); + + dust = P_SpawnMobj(actor->x + P_RandomFixed() - FRACUNIT/2, actor->y + P_RandomFixed() - FRACUNIT/2, actor->z + actor->height/2 + P_RandomFixed() - FRACUNIT/2, MT_PARTICLE); + P_SetScale(dust, 2*FRACUNIT); + dust->destscale = FRACUNIT/3; + dust->scalespeed = FRACUNIT/40; + dust->fuse = TICRATE*2; + + actor->momx += FixedDiv(dx, dm)*2; + actor->momy += FixedDiv(dy, dm)*2; + actor->momz += FixedDiv(dz, dm)*2; + + momm = FixedHypot(actor->momz, FixedHypot(actor->momx, actor->momy)); + + if (momm > speedmax/2 && actor->reactiontime == 0) + { + P_SetMobjState(actor, actor->info->seestate); + return; + } + + //Hits a wall hard? + if (actor->extravalue1 - momm > 15*FRACUNIT) + { + actor->flags &= ~MF_NOGRAVITY; + P_SetMobjState(actor, actor->info->painstate); + S_StopSound(actor); + S_StartSound(actor, actor->info->painsound); + return; + } + actor->extravalue1 = momm; + + if (momm > speedmax) + { + actor->momx = FixedMul(FixedDiv(actor->momx, momm), speedmax); + actor->momy = FixedMul(FixedDiv(actor->momy, momm), speedmax); + actor->momz = FixedMul(FixedDiv(actor->momz, momm), speedmax); + } + + actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy); +} + // Function: A_SkimChase // // Description: Thinker/Chase routine for Skims @@ -1588,10 +2526,9 @@ void A_SkimChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SkimChase", actor)) return; -#endif + if (actor->reactiontime) actor->reactiontime--; @@ -1675,10 +2612,9 @@ nomissile: // void A_FaceTarget(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceTarget", actor)) return; -#endif + if (!actor->target) return; @@ -1694,10 +2630,9 @@ void A_FaceTarget(mobj_t *actor) // void A_FaceTracer(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_FaceTracer", actor)) return; -#endif + if (!actor->tracer) return; @@ -1724,10 +2659,9 @@ void A_LobShot(mobj_t *actor) fixed_t vertical, horizontal; fixed_t airtime = var2 & 65535; -#ifdef HAVE_BLUA if (LUA_CallAction("A_LobShot", actor)) return; -#endif + if (!actor->target) return; @@ -1825,10 +2759,9 @@ void A_FireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_FireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1864,10 +2797,9 @@ void A_SuperFireShot(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SuperFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1910,11 +2842,11 @@ void A_BossFireShot(mobj_t *actor) fixed_t x, y, z; INT32 locvar1 = var1; INT32 locvar2 = var2; + mobj_t *missile; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -1977,7 +2909,10 @@ void A_BossFireShot(mobj_t *actor) break; } - P_SpawnXYZMissile(actor, actor->target, locvar1, x, y, z); + missile = P_SpawnXYZMissile(actor, actor->target, locvar1, x, y, z); + + if (missile && actor->tracer && (actor->tracer->flags & MF_BOSS)) // Don't harm your papa. + P_SetTarget(&missile->target, actor->tracer); } // Function: A_Boss7FireMissiles @@ -1993,10 +2928,8 @@ void A_Boss7FireMissiles(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss7FireMissiles", actor)) return; -#endif if (!actor->target) { @@ -2042,41 +2975,69 @@ void A_Boss7FireMissiles(mobj_t *actor) // var2: // 0 - Boss 1 Left side // 1 - Boss 1 Right side +// 2 - Triple laser +// 3 - Boss 1 Middle +// >=3 - Generic middle // void A_Boss1Laser(mobj_t *actor) { fixed_t x, y, z, floorz, speed; INT32 locvar1 = var1; - INT32 locvar2 = var2; + INT32 locvar2 = (var2 & 65535); + INT32 upperend = (var2>>16); INT32 i; angle_t angle; mobj_t *point; + tic_t dur; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss1Laser", actor)) return; -#endif + if (!actor->target) return; + if (actor->state->tics > 1) + dur = actor->tics; + else + { + if ((upperend & 1) && (actor->extravalue2 > 1)) + actor->extravalue2--; + + dur = actor->extravalue2; + } + switch (locvar2) { case 0: - x = actor->x + P_ReturnThrustX(actor, actor->angle+ANGLE_90, FixedMul(43*FRACUNIT, actor->scale)); - y = actor->y + P_ReturnThrustY(actor, actor->angle+ANGLE_90, FixedMul(43*FRACUNIT, actor->scale)); + x = actor->x + P_ReturnThrustX(actor, actor->angle+ANGLE_90, FixedMul(44*FRACUNIT, actor->scale)); + y = actor->y + P_ReturnThrustY(actor, actor->angle+ANGLE_90, FixedMul(44*FRACUNIT, actor->scale)); if (actor->eflags & MFE_VERTICALFLIP) z = actor->z + actor->height - FixedMul(56*FRACUNIT, actor->scale) - mobjinfo[locvar1].height; else z = actor->z + FixedMul(56*FRACUNIT, actor->scale); break; case 1: - x = actor->x + P_ReturnThrustX(actor, actor->angle-ANGLE_90, FixedMul(43*FRACUNIT, actor->scale)); - y = actor->y + P_ReturnThrustY(actor, actor->angle-ANGLE_90, FixedMul(43*FRACUNIT, actor->scale)); + x = actor->x + P_ReturnThrustX(actor, actor->angle-ANGLE_90, FixedMul(44*FRACUNIT, actor->scale)); + y = actor->y + P_ReturnThrustY(actor, actor->angle-ANGLE_90, FixedMul(44*FRACUNIT, actor->scale)); if (actor->eflags & MFE_VERTICALFLIP) z = actor->z + actor->height - FixedMul(56*FRACUNIT, actor->scale) - mobjinfo[locvar1].height; else z = actor->z + FixedMul(56*FRACUNIT, actor->scale); break; + case 2: + var2 = 3; // Fire middle laser + A_Boss1Laser(actor); + var2 = 0; // Fire left laser + A_Boss1Laser(actor); + var2 = 1; // Fire right laser + A_Boss1Laser(actor); + return; + break; + case 3: + x = actor->x + P_ReturnThrustX(actor, actor->angle, FixedMul(42*FRACUNIT, actor->scale)); + y = actor->y + P_ReturnThrustY(actor, actor->angle, FixedMul(42*FRACUNIT, actor->scale)); + z = actor->z + actor->height/2; + break; default: x = actor->x; y = actor->y; @@ -2084,26 +3045,21 @@ void A_Boss1Laser(mobj_t *actor) break; } - if (!(actor->flags2 & MF2_FIRING)) + if (!(actor->flags2 & MF2_FIRING) && dur > 1) { actor->angle = R_PointToAngle2(x, y, actor->target->x, actor->target->y); if (mobjinfo[locvar1].seesound) S_StartSound(actor, mobjinfo[locvar1].seesound); - if (!(actor->spawnpoint && actor->spawnpoint->options & MTF_AMBUSH)) - { - point = P_SpawnMobj(x + P_ReturnThrustX(actor, actor->angle, actor->radius), y + P_ReturnThrustY(actor, actor->angle, actor->radius), actor->z - actor->height / 2, MT_EGGMOBILE_TARGET); - point->fuse = actor->tics+1; - P_SetTarget(&point->target, actor->target); - P_SetTarget(&actor->target, point); - } - } - else if (actor->target && !(actor->spawnpoint && actor->spawnpoint->options & MTF_AMBUSH)) - actor->angle = R_PointToAngle2(x, y, actor->target->x, actor->target->y); - if (actor->spawnpoint && actor->spawnpoint->options & MTF_AMBUSH) - angle = FixedAngle(FixedDiv(actor->tics*160*FRACUNIT, actor->state->tics*FRACUNIT) + 10*FRACUNIT); - else - angle = R_PointToAngle2(z + (mobjinfo[locvar1].height>>1), 0, actor->target->z, R_PointToDist2(x, y, actor->target->x, actor->target->y)); + point = P_SpawnMobj(x + P_ReturnThrustX(actor, actor->angle, actor->radius), y + P_ReturnThrustY(actor, actor->angle, actor->radius), actor->z - actor->height / 2, MT_EGGMOBILE_TARGET); + point->angle = actor->angle; + point->fuse = dur+1; + P_SetTarget(&point->target, actor->target); + P_SetTarget(&actor->target, point); + } + + angle = R_PointToAngle2(z + (mobjinfo[locvar1].height>>1), 0, actor->target->z, R_PointToDist2(x, y, actor->target->x, actor->target->y)); + point = P_SpawnMobj(x, y, z, locvar1); P_SetTarget(&point->target, actor); point->angle = actor->angle; @@ -2129,13 +3085,13 @@ void A_Boss1Laser(mobj_t *actor) if (z - floorz < mobjinfo[MT_EGGMOBILE_FIRE].height>>1) { point = P_SpawnMobj(x, y, floorz+1, MT_EGGMOBILE_FIRE); - point->target = actor; + P_SetTarget(&point->target, actor); point->destscale = 3*FRACUNIT; point->scalespeed = FRACUNIT>>2; point->fuse = TICRATE; } - if (actor->tics > 1) + if (dur > 1) actor->flags2 |= MF2_FIRING; else actor->flags2 &= ~MF2_FIRING; @@ -2148,22 +3104,26 @@ void A_Boss1Laser(mobj_t *actor) // var1: // 0 - accelerative focus with friction // 1 - steady focus with fixed movement speed -// var2 = unused +// anything else - don't move +// var2: +// 0 - don't trace target, just move forwards +// & 1 - change horizontal angle +// & 2 - change vertical angle // void A_FocusTarget(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + INT32 locvar2 = var2; + if (LUA_CallAction("A_FocusTarget", actor)) return; -#endif if (actor->target) { fixed_t speed = FixedMul(actor->info->speed, actor->scale); - fixed_t dist = R_PointToDist2(actor->x, actor->y, actor->target->x, actor->target->y); - angle_t vangle = R_PointToAngle2(actor->z , 0, actor->target->z + (actor->target->height>>1), dist); - angle_t hangle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); + fixed_t dist = (locvar2 ? R_PointToDist2(actor->x, actor->y, actor->target->x, actor->target->y) : speed+1); + angle_t hangle = ((locvar2 & 1) ? R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) : actor->angle); + angle_t vangle = ((locvar2 & 2) ? R_PointToAngle2(actor->z , 0, actor->target->z + (actor->target->height>>1), dist) : ANGLE_90); switch(locvar1) { case 0: @@ -2199,21 +3159,35 @@ void A_FocusTarget(mobj_t *actor) // Description: Reverse arms direction. // // var1 = sfx to play -// var2 = unused +// var2 = sfx to play in pinch // void A_Boss4Reverse(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + sfxenum_t locvar2 = (sfxenum_t)var2; + if (LUA_CallAction("A_Boss4Reverse", actor)) return; -#endif - S_StartSound(NULL, locvar1); + actor->reactiontime = 0; - if (actor->movedir == 1) - actor->movedir = 2; + if (actor->movedir < 3) + { + S_StartSound(NULL, locvar1); + if (actor->movedir == 1) + actor->movedir = 2; + else + actor->movedir = 1; + } else - actor->movedir = 1; + { + S_StartSound(NULL, locvar2); + if (actor->movedir == 4) + actor->movedir = 5; + else + actor->movedir = 4; + actor->angle += ANGLE_180; + actor->movefactor = -actor->movefactor; + } } // Function: A_Boss4SpeedUp @@ -2226,10 +3200,10 @@ void A_Boss4Reverse(mobj_t *actor) void A_Boss4SpeedUp(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4SpeedUp", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 2; } @@ -2244,10 +3218,10 @@ void A_Boss4SpeedUp(mobj_t *actor) void A_Boss4Raise(mobj_t *actor) { sfxenum_t locvar1 = (sfxenum_t)var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss4Raise", actor)) return; -#endif + S_StartSound(NULL, locvar1); actor->reactiontime = 1; } @@ -2260,6 +3234,7 @@ void A_Boss4Raise(mobj_t *actor) // 0 - Fly at the player // 1 - Fly away from the player // 2 - Strafe in relation to the player +// 3 - Dynamic mode - don't get too close to walls // var2: // 0 - Fly horizontally and vertically // 1 - Fly horizontal-only (momz = 0) @@ -2275,10 +3250,9 @@ void A_SkullAttack(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SkullAttack", actor)) return; -#endif + if (!actor->target) return; @@ -2290,16 +3264,84 @@ void A_SkullAttack(mobj_t *actor) S_StartSound(actor, actor->info->activesound); A_FaceTarget(actor); + dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); + if (locvar1 == 1) actor->angle += ANGLE_180; else if (locvar1 == 2) actor->angle += (P_RandomChance(FRACUNIT/2)) ? ANGLE_90 : -ANGLE_90; + else if (locvar1 == 3) + { + statenum_t oldspawnstate = mobjinfo[MT_NULL].spawnstate; + UINT32 oldflags = mobjinfo[MT_NULL].flags; + fixed_t oldradius = mobjinfo[MT_NULL].radius; + fixed_t oldheight = mobjinfo[MT_NULL].height; + mobj_t *check; + INT32 i, j; + static INT32 k;/* static for (at least) GCC 9.1 weirdness */ + boolean allow; + angle_t testang = 0; + + mobjinfo[MT_NULL].spawnstate = S_INVISIBLE; + mobjinfo[MT_NULL].flags = MF_NOGRAVITY|MF_NOTHINK|MF_NOCLIPTHING|MF_NOBLOCKMAP; + mobjinfo[MT_NULL].radius = mobjinfo[actor->type].radius; + mobjinfo[MT_NULL].height = mobjinfo[actor->type].height; + + if (P_RandomChance(FRACUNIT/2)) // port priority 1? + { + i = 9; + j = 27; + } + else + { + i = 27; + j = 9; + } + +#define dostuff(q) check = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_NULL);\ + testang = actor->angle + ((i+(q))*ANG10);\ + allow = (P_TryMove(check,\ + P_ReturnThrustX(check, testang, dist + 2*actor->radius),\ + P_ReturnThrustY(check, testang, dist + 2*actor->radius),\ + true));\ + P_RemoveMobj(check);\ + if (allow)\ + break; + + if (P_RandomChance(FRACUNIT/2)) // port priority 2? + { + for (k = 0; k < 9; k++) + { + dostuff(i+k) + dostuff(i-k) + dostuff(j+k) + dostuff(j-k) + } + } + else + { + for (k = 0; k < 9; k++) + { + dostuff(i-k) + dostuff(i+k) + dostuff(j-k) + dostuff(j+k) + } + } + actor->angle = testang; + +#undef dostuff + + mobjinfo[MT_NULL].spawnstate = oldspawnstate; + mobjinfo[MT_NULL].flags = oldflags; + mobjinfo[MT_NULL].radius = oldradius; + mobjinfo[MT_NULL].height = oldheight; + } an = actor->angle >> ANGLETOFINESHIFT; actor->momx = FixedMul(speed, FINECOSINE(an)); actor->momy = FixedMul(speed, FINESINE(an)); - dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); dist = dist / speed; if (dist < 1) @@ -2326,10 +3368,9 @@ void A_BossZoom(mobj_t *actor) angle_t an; INT32 dist; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossZoom", actor)) return; -#endif + if (!actor->target) return; @@ -2354,9 +3395,9 @@ void A_BossZoom(mobj_t *actor) // Description: Spawns explosions and plays appropriate sounds around the defeated boss. // // var1: -// 0 - Use movecount to spawn explosions evenly -// 1 - Use P_Random to spawn explosions at complete random -// var2 = Object to spawn. Default is MT_BOSSEXPLODE. +// & 1 - Use P_Random to spawn explosions at complete random +// & 2 - Use entire vertical range of object to spawn +// var2 = Object to spawn. Default is MT_SONIC3KBOSSEXPLODE. // void A_BossScream(mobj_t *actor) { @@ -2367,32 +3408,29 @@ void A_BossScream(mobj_t *actor) INT32 locvar2 = var2; mobjtype_t explodetype; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BossScream", actor)) return; -#endif - switch (locvar1) + + if (locvar1 & 1) + fa = (FixedAngle(P_RandomKey(360)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; + else { - default: - case 0: actor->movecount += 4*16; actor->movecount %= 360; fa = (FixedAngle(actor->movecount*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - break; - case 1: - fa = (FixedAngle(P_RandomKey(360)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; - break; } x = actor->x + FixedMul(FINECOSINE(fa),actor->radius); y = actor->y + FixedMul(FINESINE(fa),actor->radius); // Determine what mobj to spawn. If undefined or invalid, use MT_BOSSEXPLODE as default. if (locvar2 <= 0 || locvar2 >= NUMMOBJTYPES) - explodetype = MT_BOSSEXPLODE; + explodetype = MT_SONIC3KBOSSEXPLODE; //MT_BOSSEXPLODE; -- piss to you, sonic 2 else explodetype = (mobjtype_t)locvar2; - if (actor->eflags & MFE_VERTICALFLIP) + if (locvar1 & 2) + z = actor->z + (P_RandomKey((actor->height - mobjinfo[explodetype].height)>>FRACBITS)<eflags & MFE_VERTICALFLIP) z = actor->z + actor->height - mobjinfo[explodetype].height - FixedMul((P_RandomByte()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale); else z = actor->z + FixedMul((P_RandomByte()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale); @@ -2415,10 +3453,9 @@ void A_BossScream(mobj_t *actor) // void A_Scream(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Scream", actor)) return; -#endif + if (actor->tracer && (actor->tracer->type == MT_SHELL || actor->tracer->type == MT_FIREBALL)) S_StartScreamSound(actor, sfx_mario2); else if (actor->info->deathsound) @@ -2434,10 +3471,9 @@ void A_Scream(mobj_t *actor) // void A_Pain(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Pain", actor)) return; -#endif + if (actor->info->painsound) S_StartSound(actor, actor->info->painsound); @@ -2449,15 +3485,16 @@ void A_Pain(mobj_t *actor) // // Description: Changes a dying object's flags to reflect its having fallen to the ground. // -// var1 = unused +// var1 = value to set repeat to if nonzero // var2 = unused // void A_Fall(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 locvar1 = var1; + if (LUA_CallAction("A_Fall", actor)) return; -#endif + // actor is on ground, it can be walked over actor->flags &= ~MF_SOLID; @@ -2466,6 +3503,9 @@ void A_Fall(mobj_t *actor) // So change this if corpse objects // are meant to be obstacles. + + if (locvar1) + actor->extravalue2 = locvar1; } #define LIVESBOXDISPLAYPLAYER // Use displayplayer instead of closest player @@ -2484,10 +3524,9 @@ void A_1upThinker(mobj_t *actor) fixed_t temp; INT32 closestplayer = -1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_1upThinker", actor)) return; -#endif + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].bot || players[i].spectator) @@ -2508,21 +3547,31 @@ void A_1upThinker(mobj_t *actor) } } - if (closestplayer == -1 || skins[players[closestplayer].skin].spritedef.numframes <= states[S_PLAY_BOX1].frame) + if (closestplayer == -1 || skins[players[closestplayer].skin].sprites[SPR2_LIFE].numframes == 0) { // Closest player not found (no players in game?? may be empty dedicated server!), or does not have correct sprite. - actor->frame = 0; - if (actor->tracer) { - P_RemoveMobj(actor->tracer); - actor->tracer = NULL; + if (actor->tracer) + { + mobj_t *tracer = actor->tracer; + P_SetTarget(&actor->tracer, NULL); + P_RemoveMobj(tracer); } return; } + // We're using the overlay, so use the overlay 1up box (no text) + actor->sprite = SPR_TV1P; + if (!actor->tracer) { P_SetTarget(&actor->tracer, P_SpawnMobj(actor->x, actor->y, actor->z, MT_OVERLAY)); P_SetTarget(&actor->tracer->target, actor); + actor->tracer->skin = &skins[players[closestplayer].skin]; // required here to prevent spr2 default showing stand for a single frame P_SetMobjState(actor->tracer, actor->info->seestate); + + // The overlay is going to be one tic early turning off and on + // because it's going to get its thinker run the frame we spawned it. + // So make it take one tic longer if it just spawned. + ++actor->tracer->tics; } actor->tracer->color = players[closestplayer].mo->color; @@ -2538,155 +3587,217 @@ void A_1upThinker(mobj_t *actor) // void A_MonitorPop(mobj_t *actor) { - mobj_t *remains; - mobjtype_t explode; mobjtype_t item = 0; - mobjtype_t newbox; + mobj_t *newmobj; -#ifdef HAVE_BLUA if (LUA_CallAction("A_MonitorPop", actor)) return; -#endif - // de-solidify + // Spawn the "pop" explosion. + if (actor->info->deathsound) + S_StartSound(actor, actor->info->deathsound); + P_SpawnMobjFromMobj(actor, 0, 0, actor->height/4, MT_EXPLODE); + + // We're dead now. De-solidify. actor->health = 0; P_UnsetThingPosition(actor); actor->flags &= ~MF_SOLID; actor->flags |= MF_NOCLIP; P_SetThingPosition(actor); - // Monitor explosion - explode = mobjinfo[actor->info->speed].mass; - remains = P_SpawnMobj(actor->x, actor->y, - ((actor->eflags & MFE_VERTICALFLIP) ? (actor->z + 3*(actor->height/4) - FixedMul(mobjinfo[explode].height, actor->scale)) : (actor->z + actor->height/4)), explode); - if (actor->eflags & MFE_VERTICALFLIP) + if (actor->info->damage == MT_UNKNOWN) { - remains->eflags |= MFE_VERTICALFLIP; - remains->flags2 |= MF2_OBJECTFLIP; - } - remains->destscale = actor->destscale; - P_SetScale(remains, actor->scale); + // MT_UNKNOWN is random. Because it's unknown to us... get it? + item = P_DoRandomBoxChances(); - remains = P_SpawnMobj(actor->x, actor->y, - ((actor->eflags & MFE_VERTICALFLIP) ? (actor->z + actor->height - FixedMul(mobjinfo[actor->info->speed].height, actor->scale)) : actor->z), - actor->info->speed); - remains->type = actor->type; // Transfer type information - P_UnsetThingPosition(remains); - if (sector_list) - { - P_DelSeclist(sector_list); - sector_list = NULL; - } - P_SetThingPosition(remains); - remains->destscale = actor->destscale; - P_SetScale(remains, actor->scale); - remains->flags = actor->flags; // Transfer flags - remains->flags2 = actor->flags2; // Transfer flags2 - remains->fuse = actor->fuse; // Transfer respawn timer - remains->threshold = 68; - remains->skin = NULL; - - P_SetTarget(&tmthing, remains); - - if (actor->info->deathsound) - S_StartSound(remains, actor->info->deathsound); - - switch (actor->type) - { - case MT_QUESTIONBOX: // Random! + if (item == MT_NULL) { - mobjtype_t spawnchance[256]; - INT32 numchoices = 0, i = 0; - -#define QUESTIONBOXCHANCES(type, cvar) \ -for (i = cvar.value; i; --i) spawnchance[numchoices++] = type - - QUESTIONBOXCHANCES(MT_SUPERRINGBOX, cv_superring); - QUESTIONBOXCHANCES(MT_SNEAKERTV, cv_supersneakers); - QUESTIONBOXCHANCES(MT_INV, cv_invincibility); - QUESTIONBOXCHANCES(MT_WHITETV, cv_jumpshield); - QUESTIONBOXCHANCES(MT_GREENTV, cv_watershield); - QUESTIONBOXCHANCES(MT_YELLOWTV, cv_ringshield); - QUESTIONBOXCHANCES(MT_BLUETV, cv_forceshield); - QUESTIONBOXCHANCES(MT_BLACKTV, cv_bombshield); - QUESTIONBOXCHANCES(MT_PRUP, cv_1up); - QUESTIONBOXCHANCES(MT_EGGMANBOX, cv_eggmanbox); - QUESTIONBOXCHANCES(MT_MIXUPBOX, cv_teleporters); - QUESTIONBOXCHANCES(MT_RECYCLETV, cv_recycler); - -#undef QUESTIONBOXCHANCES - - if (numchoices == 0) - { - CONS_Alert(CONS_WARNING, M_GetText("All monitors turned off.\n")); - return; - } - - newbox = spawnchance[P_RandomKey(numchoices)]; - item = mobjinfo[newbox].damage; - - remains->flags &= ~MF_AMBUSH; - break; - } - default: - item = actor->info->damage; - break; - } - - if (item != 0) - { - mobj_t *newmobj; - - if (actor->eflags & MFE_VERTICALFLIP) - { - newmobj = P_SpawnMobj(actor->x, actor->y, actor->z + actor->height - FixedMul(13*FRACUNIT + mobjinfo[item].height, actor->scale), item); - newmobj->eflags |= MFE_VERTICALFLIP; - } - else - newmobj = P_SpawnMobj(actor->x, actor->y, actor->z + FixedMul(13*FRACUNIT, actor->scale), item); - - newmobj->destscale = actor->destscale; - P_SetScale(newmobj, actor->scale); - P_SetTarget(&newmobj->target, actor->target); // Transfer target - if (item == MT_1UPICO && newmobj->target->player) - { - if (actor->tracer) // Remove the old lives icon. - P_RemoveMobj(actor->tracer); - - if (!newmobj->target->skin || ((skin_t *)newmobj->target->skin)->spritedef.numframes <= states[S_PLAY_BOX1].frame) - newmobj->frame -= 2; // No lives icon for this player, use the default. - else - { // Spawn the lives icon. - remains = P_SpawnMobj(newmobj->x, newmobj->y, newmobj->z, MT_OVERLAY); - P_SetTarget(&remains->target, newmobj); - P_SetTarget(&newmobj->tracer, remains); - - remains->color = newmobj->target->player->mo->color; - remains->skin = &skins[newmobj->target->player->skin]; - P_SetMobjState(remains, newmobj->info->seestate); - } + CONS_Alert(CONS_WARNING, M_GetText("All monitors turned off.\n")); + return; } } else - CONS_Debug(DBG_GAMELOGIC, "Powerup item not defined in 'damage' field for A_MonitorPop\n"); + item = actor->info->damage; - P_RemoveMobj(actor); + if (item == 0) + { + CONS_Debug(DBG_GAMELOGIC, "Powerup item not defined in 'damage' field for A_MonitorPop\n"); + return; + } + + newmobj = P_SpawnMobjFromMobj(actor, 0, 0, 13*FRACUNIT, item); + P_SetTarget(&newmobj->target, actor->target); // Transfer target + + if (item == MT_1UP_ICON) + { + if (actor->tracer) // Remove the old lives icon. + P_RemoveMobj(actor->tracer); + + if (!newmobj->target + || !newmobj->target->player + || !newmobj->target->skin + || ((skin_t *)newmobj->target->skin)->sprites[SPR2_LIFE].numframes == 0) + {} // No lives icon for this player, use the default. + else + { // Spawn the lives icon. + mobj_t *livesico = P_SpawnMobjFromMobj(newmobj, 0, 0, 0, MT_OVERLAY); + P_SetTarget(&livesico->target, newmobj); + P_SetTarget(&newmobj->tracer, livesico); + + livesico->color = newmobj->target->player->mo->color; + livesico->skin = &skins[newmobj->target->player->skin]; + P_SetMobjState(livesico, newmobj->info->seestate); + + // We're using the overlay, so use the overlay 1up sprite (no text) + newmobj->sprite = SPR_TV1P; + } + } + + // Run a linedef executor immediately upon popping + // You may want to delay your effects by 18 tics to sync with the reward giving + if (actor->spawnpoint && actor->lastlook) + P_LinedefExecute(actor->lastlook, actor->target, NULL); +} + +// Function: A_GoldMonitorPop +// +// Description: Used by repeating monitors when they turn off. They don't really pop, but, you know... +// +// var1 = unused +// var2 = unused +// +void A_GoldMonitorPop(mobj_t *actor) +{ + mobjtype_t item = 0; + mobj_t *newmobj; + + if (LUA_CallAction("A_GoldMonitorPop", actor)) + return; + + // Don't spawn the "pop" explosion, because the monitor isn't broken. + if (actor->info->deathsound) + S_StartSound(actor, actor->info->deathsound); + //P_SpawnMobjFromMobj(actor, 0, 0, actor.height/4, MT_EXPLODE); + + // Remove our flags for a bit. + // Players can now stand on top of us. + P_UnsetThingPosition(actor); + actor->flags &= ~(MF_MONITOR|MF_SHOOTABLE); + P_SetThingPosition(actor); + + // Don't count this box in statistics. Sorry. + if (actor->target && actor->target->player) + --actor->target->player->numboxes; + actor->fuse = 0; // Don't let the monitor code screw us up. + + if (actor->info->damage == MT_UNKNOWN) + { + // MT_UNKNOWN is random. Because it's unknown to us... get it? + item = P_DoRandomBoxChances(); + + if (item == MT_NULL) + { + CONS_Alert(CONS_WARNING, M_GetText("All monitors turned off.\n")); + return; + } + } + else + item = actor->info->damage; + + if (item == 0) + { + CONS_Debug(DBG_GAMELOGIC, "Powerup item not defined in 'damage' field for A_GoldMonitorPop\n"); + return; + } + + // Note: the icon spawns 1 fracunit higher + newmobj = P_SpawnMobjFromMobj(actor, 0, 0, 14*FRACUNIT, item); + P_SetTarget(&newmobj->target, actor->target); // Transfer target + + if (item == MT_1UP_ICON) + { + if (actor->tracer) // Remove the old lives icon. + P_RemoveMobj(actor->tracer); + + if (!newmobj->target + || !newmobj->target->player + || !newmobj->target->skin + || ((skin_t *)newmobj->target->skin)->sprites[SPR2_LIFE].numframes == 0) + {} // No lives icon for this player, use the default. + else + { // Spawn the lives icon. + mobj_t *livesico = P_SpawnMobjFromMobj(newmobj, 0, 0, 0, MT_OVERLAY); + P_SetTarget(&livesico->target, newmobj); + P_SetTarget(&newmobj->tracer, livesico); + + livesico->color = newmobj->target->player->mo->color; + livesico->skin = &skins[newmobj->target->player->skin]; + P_SetMobjState(livesico, newmobj->info->seestate); + + // We're using the overlay, so use the overlay 1up sprite (no text) + newmobj->sprite = SPR_TV1P; + } + } + + // Run a linedef executor immediately upon popping + // You may want to delay your effects by 18 tics to sync with the reward giving + if (actor->spawnpoint && actor->lastlook) + P_LinedefExecute(actor->lastlook, actor->target, NULL); +} + +// Function: A_GoldMonitorRestore +// +// Description: A repeating monitor is coming back to life. Reset monitor flags, etc. +// +// var1 = unused +// var2 = unused +// +void A_GoldMonitorRestore(mobj_t *actor) +{ + if (LUA_CallAction("A_GoldMonitorRestore", actor)) + return; + + actor->flags |= MF_MONITOR|MF_SHOOTABLE; + actor->health = 1; // Just in case. +} + +// Function: A_GoldMonitorSparkle +// +// Description: Spawns the little sparkly effect around big monitors. Looks pretty, doesn't it? +// +// var1 = unused +// var2 = unused +// +void A_GoldMonitorSparkle(mobj_t *actor) +{ + fixed_t i, ngangle, xofs, yofs; + + if (LUA_CallAction("A_GoldMonitorSparkle", actor)) + return; + + ngangle = FixedAngle(((leveltime * 21) % 360) << FRACBITS); + xofs = FINESINE((ngangle>>ANGLETOFINESHIFT) & FINEMASK) * (actor->radius>>FRACBITS); + yofs = FINECOSINE((ngangle>>ANGLETOFINESHIFT) & FINEMASK) * (actor->radius>>FRACBITS); + + for (i = FRACUNIT*2; i <= FRACUNIT*3; i += FRACUNIT/2) + P_SetObjectMomZ(P_SpawnMobjFromMobj(actor, xofs, yofs, 0, MT_BOXSPARKLE), i, false); } // Function: A_Explode // // Description: Explodes an object, doing damage to any objects nearby. The target is used as the cause of the explosion. Damage value is used as explosion range. // -// var1 = unused +// var1 = damagetype // var2 = unused // void A_Explode(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 locvar1 = var1; + if (LUA_CallAction("A_Explode", actor)) return; -#endif - P_RadiusAttack(actor, actor->target, actor->info->damage); + + P_RadiusAttack(actor, actor->target, actor->info->damage, locvar1); } // Function: A_BossDeath @@ -2702,12 +3813,14 @@ void A_BossDeath(mobj_t *mo) mobj_t *mo2; line_t junk; INT32 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BossDeath", mo)) return; -#endif - P_LinedefExecute(LE_BOSSDEAD, mo, NULL); + if (mo->spawnpoint && mo->spawnpoint->extrainfo) + P_LinedefExecute(LE_BOSSDEAD+(mo->spawnpoint->extrainfo*LE_PARAMWIDTH), mo, NULL); + else + P_LinedefExecute(LE_BOSSDEAD, mo, NULL); mo->health = 0; // Boss is dead (but not necessarily fleeing...) @@ -2716,8 +3829,8 @@ void A_BossDeath(mobj_t *mo) // make sure there is a player alive for victory for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (players[i].health > 0 - || ((netgame || multiplayer) && (players[i].lives > 0 || players[i].continues > 0)))) + if (playeringame[i] && ((players[i].mo && players[i].mo->health) + || ((netgame || multiplayer) && (players[i].lives || players[i].continues)))) break; if (i == MAXPLAYERS) @@ -2725,9 +3838,9 @@ void A_BossDeath(mobj_t *mo) // scan the remaining thinkers to see // if all bosses are dead - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -2737,126 +3850,261 @@ void A_BossDeath(mobj_t *mo) // victory! P_LinedefExecute(LE_ALLBOSSESDEAD, mo, NULL); + if (stoppedclock && modeattacking) // if you're just time attacking, skip making the capsule appear since you don't need to step on it anyways. + goto bossjustdie; if (mo->flags2 & MF2_BOSSNOTRAP) { for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; P_DoPlayerExit(&players[i]); + } } else { // Bring the egg trap up to the surface - junk.tag = 680; + junk.tag = LE_CAPSULE0; EV_DoElevator(&junk, elevateHighest, false); - junk.tag = 681; + junk.tag = LE_CAPSULE1; EV_DoElevator(&junk, elevateUp, false); - junk.tag = 682; + junk.tag = LE_CAPSULE2; EV_DoElevator(&junk, elevateHighest, false); + + if (mapheaderinfo[gamemap-1]->muspostbossname[0] && + S_MusicExists(mapheaderinfo[gamemap-1]->muspostbossname, !midi_disabled, !digital_disabled)) + { + // Touching the egg trap button calls P_DoPlayerExit, which calls P_RestoreMusic. + // So just park ourselves in the mapmus variables. + // But don't change the mapmus variables if they were modified from their level header values (e.g., TUNES). + boolean changed = strnicmp(mapheaderinfo[gamemap-1]->musname, S_MusicName(), 7); + if (!strnicmp(mapheaderinfo[gamemap-1]->musname, mapmusname, 7)) + { + strncpy(mapmusname, mapheaderinfo[gamemap-1]->muspostbossname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->muspostbosstrack & MUSIC_TRACKMASK) | MUSIC_RELOADRESET; + mapmusposition = mapheaderinfo[gamemap-1]->muspostbosspos; + } + + // don't change if we're in another tune + // but in case we're in jingle, use our parked mapmus variables so the correct track restores + if (!changed) + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, (1*MUSICRATE)+(MUSICRATE/2), + mapheaderinfo[gamemap-1]->muspostbossfadein); + } } bossjustdie: -#ifdef HAVE_BLUA if (LUAh_BossDeath(mo)) return; else if (P_MobjWasRemoved(mo)) return; -#endif - if (mo->type == MT_BLACKEGGMAN || mo->type == MT_CYBRAKDEMON) + + // Spawn your junk + switch (mo->type) { - mo->flags |= MF_NOCLIP; - mo->flags &= ~MF_SPECIAL; - - S_StartSound(NULL, sfx_befall); - } - else if (mo->type == MT_KOOPA) - { - junk.tag = 650; - EV_DoCeiling(&junk, raiseToHighest); - return; - } - else // eggmobiles - { - // Stop exploding and prepare to run. - P_SetMobjState(mo, mo->info->xdeathstate); - if (P_MobjWasRemoved(mo)) - return; - - P_SetTarget(&mo->target, NULL); - - // Flee! Flee! Find a point to escape to! If none, just shoot upward! - // scan the thinkers to find the runaway point - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2->type == MT_BOSSFLYPOINT) + default: + break; + case MT_EGGMOBILE: // twin laser pods { - // If this one's closer then the last one, go for it. - if (!mo->target || - P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) < - P_AproxDistance(P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z)) - P_SetTarget(&mo->target, mo2); - // Otherwise... Don't! + mo2 = P_SpawnMobjFromMobj(mo, + P_ReturnThrustX(mo, mo->angle - ANGLE_90, 32<angle - ANGLE_90, 32<angle = mo->angle; + P_InstaThrust(mo2, mo2->angle - ANGLE_90, 4*mo2->scale); + P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + P_SetMobjState(mo2, S_BOSSEGLZ1); + + mo2 = P_SpawnMobjFromMobj(mo, + P_ReturnThrustX(mo, mo->angle + ANGLE_90, 32<angle + ANGLE_90, 32<angle = mo->angle; + P_InstaThrust(mo2, mo2->angle + ANGLE_90, 4*mo2->scale); + P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + P_SetMobjState(mo2, S_BOSSEGLZ2); } - } + break; + case MT_EGGMOBILE2: // twin tanks + spigot + { + mo2 = P_SpawnMobjFromMobj(mo, + P_ReturnThrustX(mo, mo->angle - ANGLE_90, 32<angle - ANGLE_90, 32<angle = mo->angle; + P_InstaThrust(mo2, mo2->angle - ANGLE_90, 4*mo2->scale); + P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + P_SetMobjState(mo2, S_BOSSTANK1); - mo->flags |= MF_NOGRAVITY|MF_NOCLIP; - mo->flags |= MF_NOCLIPHEIGHT; + mo2 = P_SpawnMobjFromMobj(mo, + P_ReturnThrustX(mo, mo->angle + ANGLE_90, 32<angle + ANGLE_90, 32<angle = mo->angle; + P_InstaThrust(mo2, mo2->angle + ANGLE_90, 4*mo2->scale); + P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + P_SetMobjState(mo2, S_BOSSTANK2); - if (mo->target) - { - mo->angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y); - mo->flags2 |= MF2_BOSSFLEE; - mo->momz = FixedMul(FixedDiv(mo->target->z - mo->z, P_AproxDistance(mo->x-mo->target->x,mo->y-mo->target->y)), FixedMul(2*FRACUNIT, mo->scale)); - } - else - mo->momz = FixedMul(2*FRACUNIT, mo->scale); + mo2 = P_SpawnMobjFromMobj(mo, 0, 0, + mobjinfo[MT_EGGMOBILE2].height + (32<angle = mo->angle; + P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + mo2->momz += mo->momz; + P_SetMobjState(mo2, S_BOSSSPIGOT); + } + break; + case MT_EGGMOBILE3: + { + mo2 = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_BOSSJUNK); + mo2->angle = mo->angle; + P_SetMobjState(mo2, S_BOSSSEBH1); + } + break; } - if (mo->type == MT_EGGMOBILE2) + // now do another switch case for escaping + switch (mo->type) { - mo2 = P_SpawnMobj(mo->x + P_ReturnThrustX(mo, mo->angle - ANGLE_90, FixedMul(32*FRACUNIT, mo->scale)), - mo->y + P_ReturnThrustY(mo, mo->angle - ANGLE_90, FixedMul(32*FRACUNIT, mo->scale)), - mo->z + mo->height/2 + ((mo->eflags & MFE_VERTICALFLIP)? FixedMul(8*FRACUNIT, mo->scale)-mobjinfo[MT_BOSSTANK1].height : -FixedMul(8*FRACUNIT, mo->scale)), MT_BOSSTANK1); // Right tank - mo2->angle = mo->angle; - mo2->destscale = mo->scale; - P_SetScale(mo2, mo2->destscale); - if (mo->eflags & MFE_VERTICALFLIP) + case MT_BLACKEGGMAN: { - mo2->eflags |= MFE_VERTICALFLIP; - mo2->flags2 |= MF2_OBJECTFLIP; - } - P_InstaThrust(mo2, mo2->angle - ANGLE_90, FixedMul(4*FRACUNIT, mo2->scale)); - P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + mo->flags |= MF_NOCLIP; + mo->flags &= ~MF_SPECIAL; - mo2 = P_SpawnMobj(mo->x + P_ReturnThrustX(mo, mo->angle + ANGLE_90, FixedMul(32*FRACUNIT, mo->scale)), - mo->y + P_ReturnThrustY(mo, mo->angle + ANGLE_90, FixedMul(32*FRACUNIT, mo->scale)), - mo->z + mo->height/2 + ((mo->eflags & MFE_VERTICALFLIP)? FixedMul(8*FRACUNIT, mo->scale)-mobjinfo[MT_BOSSTANK2].height : -FixedMul(8*FRACUNIT, mo->scale)), MT_BOSSTANK2); // Left tank - mo2->angle = mo->angle; - mo2->destscale = mo->scale; - P_SetScale(mo2, mo2->destscale); - if (mo->eflags & MFE_VERTICALFLIP) - { - mo2->eflags |= MFE_VERTICALFLIP; - mo2->flags2 |= MF2_OBJECTFLIP; + S_StartSound(NULL, sfx_befall); + break; } - P_InstaThrust(mo2, mo2->angle + ANGLE_90, FixedMul(4*FRACUNIT, mo2->scale)); - P_SetObjectMomZ(mo2, 4*FRACUNIT, false); + case MT_CYBRAKDEMON: + { + mo->flags |= MF_NOCLIP; + mo->flags &= ~(MF_SPECIAL|MF_NOGRAVITY|MF_NOCLIPHEIGHT); - mo2 = P_SpawnMobj(mo->x, mo->y, - mo->z + ((mo->eflags & MFE_VERTICALFLIP)? mobjinfo[MT_BOSSSPIGOT].height-FixedMul(32*FRACUNIT,mo->scale): mo->height + FixedMul(32*FRACUNIT, mo->scale)), MT_BOSSSPIGOT); - mo2->angle = mo->angle; - mo2->destscale = mo->scale; - P_SetScale(mo2, mo2->destscale); - if (mo->eflags & MFE_VERTICALFLIP) - { - mo2->eflags |= MFE_VERTICALFLIP; - mo2->flags2 |= MF2_OBJECTFLIP; + S_StartSound(NULL, sfx_bedie2); + P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_CYBRAKDEMON_VILE_EXPLOSION); + mo->z += P_MobjFlip(mo); + P_SetObjectMomZ(mo, 12*FRACUNIT, false); + S_StartSound(mo, sfx_bgxpld); + if (mo->spawnpoint && !(mo->spawnpoint->options & MTF_EXTRA)) + P_InstaThrust(mo, R_PointToAngle2(0, 0, mo->x, mo->y), 14*FRACUNIT); + break; + } + case MT_KOOPA: + { + junk.tag = LE_KOOPA; + EV_DoCeiling(&junk, raiseToHighest); + return; + } + case MT_FANG: + { + if (mo->flags2 & MF2_SLIDEPUSH) + { + P_RemoveMobj(mo); + return; + } + if (mo->tracer) + { + var1 = var2 = 0; + A_Boss5Jump(mo); + mo->momx = ((16 - 1)*mo->momx)/16; + mo->momy = ((16 - 1)*mo->momy)/16; + { + const fixed_t time = FixedHypot(mo->tracer->x - mo->x, mo->tracer->y - mo->y)/FixedHypot(mo->momx, mo->momy); + const fixed_t speed = 64*FRACUNIT; + mobj_t *pole = P_SpawnMobj( + mo->tracer->x - P_ReturnThrustX(mo->tracer, mo->tracer->angle, speed*time), + mo->tracer->y - P_ReturnThrustY(mo->tracer, mo->tracer->angle, speed*time), + mo->tracer->floorz + (256+1)*FRACUNIT, + MT_FSGNB); + P_SetTarget(&pole->tracer, P_SpawnMobj( + pole->x, pole->y, + pole->z - 256*FRACUNIT, + MT_FSGNB)); + P_SetTarget(&pole->tracer->tracer, P_SpawnMobj( + pole->x + P_ReturnThrustX(pole, mo->tracer->angle, FRACUNIT), + pole->y + P_ReturnThrustY(pole, mo->tracer->angle, FRACUNIT), + pole->z + 256*FRACUNIT, + MT_FSGNA)); + pole->tracer->flags |= MF_NOCLIPTHING; + P_SetScale(pole, (pole->destscale = 2*FRACUNIT)); + P_SetScale(pole->tracer, (pole->tracer->destscale = 2*FRACUNIT)); + pole->angle = pole->tracer->angle = mo->tracer->angle; + pole->tracer->tracer->angle = pole->angle - ANGLE_90; + pole->momx = P_ReturnThrustX(pole, pole->angle, speed); + pole->momy = P_ReturnThrustY(pole, pole->angle, speed); + pole->tracer->momx = pole->momx; + pole->tracer->momy = pole->momy; + pole->tracer->tracer->momx = pole->momx; + pole->tracer->tracer->momy = pole->momy; + } + } + else + { + P_SetObjectMomZ(mo, 10*FRACUNIT, false); + mo->flags |= MF_NOGRAVITY; + } + mo->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; + return; + } + default: //eggmobiles + { + UINT8 extrainfo = (mo->spawnpoint ? mo->spawnpoint->extrainfo : 0); + + // Stop exploding and prepare to run. + P_SetMobjState(mo, mo->info->xdeathstate); + if (P_MobjWasRemoved(mo)) + return; + + P_SetTarget(&mo->target, NULL); + + // Flee! Flee! Find a point to escape to! If none, just shoot upward! + // scan the thinkers to find the runaway point + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_BOSSFLYPOINT) + continue; + + if (mo2->spawnpoint && mo2->spawnpoint->extrainfo != extrainfo) + continue; + + // If this one's further then the last one, don't go for it. + if (mo->target && + P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z) > + P_AproxDistance(P_AproxDistance(mo->x - mo->target->x, mo->y - mo->target->y), mo->z - mo->target->z)) + continue; + + // Otherwise... Do! + P_SetTarget(&mo->target, mo2); + } + + mo->flags |= MF_NOGRAVITY|MF_NOCLIP; + mo->flags |= MF_NOCLIPHEIGHT; + + mo->movedir = 0; + mo->extravalue1 = 35; + mo->flags2 |= MF2_BOSSFLEE; + mo->momz = P_MobjFlip(mo)*2*mo->scale; + + if (mo->target) + { + angle_t diff = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y) - mo->angle; + if (diff) + { + if (diff > ANGLE_180) + diff = InvAngle(InvAngle(diff)/mo->extravalue1); + else + diff /= mo->extravalue1; + mo->movedir = diff; + } + } + + break; } - P_SetObjectMomZ(mo2, 4*FRACUNIT, false); - return; } } @@ -2874,10 +4122,9 @@ void A_CustomPower(mobj_t *actor) INT32 locvar2 = var2; boolean spawnshield = false; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CustomPower", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2915,10 +4162,9 @@ void A_GiveWeapon(mobj_t *actor) player_t *player; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_GiveWeapon", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -2938,70 +4184,6 @@ void A_GiveWeapon(mobj_t *actor) S_StartSound(player->mo, actor->info->seesound); } -// Function: A_JumpShield -// -// Description: Awards the player a jump shield. -// -// var1 = unused -// var2 = unused -// -void A_JumpShield(mobj_t *actor) -{ - player_t *player; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_JumpShield", actor)) - return; -#endif - if (!actor->target || !actor->target->player) - { - CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); - return; - } - - player = actor->target->player; - - if ((player->powers[pw_shield] & SH_NOSTACK) != SH_JUMP) - { - player->powers[pw_shield] = SH_JUMP|(player->powers[pw_shield] & SH_STACK); - P_SpawnShieldOrb(player); - } - - S_StartSound(player->mo, actor->info->seesound); -} - -// Function: A_RingShield -// -// Description: Awards the player a ring shield. -// -// var1 = unused -// var2 = unused -// -void A_RingShield(mobj_t *actor) -{ - player_t *player; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_RingShield", actor)) - return; -#endif - if (!actor->target || !actor->target->player) - { - CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); - return; - } - - player = actor->target->player; - - if ((player->powers[pw_shield] & SH_NOSTACK) != SH_ATTRACT) - { - player->powers[pw_shield] = SH_ATTRACT|(player->powers[pw_shield] & SH_STACK); - P_SpawnShieldOrb(player); - } - - S_StartSound(player->mo, actor->info->seesound); -} - // Function: A_RingBox // // Description: Awards the player 10 rings. @@ -3013,10 +4195,9 @@ void A_RingBox(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RingBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3041,10 +4222,9 @@ void A_Invincibility(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Invincibility", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3056,10 +4236,11 @@ void A_Invincibility(mobj_t *actor) if (P_IsLocalPlayer(player) && !player->powers[pw_super]) { - S_StopMusic(); if (mariomode) G_GhostAddColor(GHC_INVINCIBLE); - S_ChangeMusicInternal((mariomode) ? "minvnc" : "invinc", false); + P_PlayJingle(player, (mariomode) ? JT_MINV : JT_INV); + strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14); + S_StartCaption(sfx_None, -1, player->powers[pw_invulnerability]); } } @@ -3074,10 +4255,9 @@ void A_SuperSneakers(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SuperSneakers", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3093,10 +4273,9 @@ void A_SuperSneakers(mobj_t *actor) if (S_SpeedMusic(0.0f) && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) S_SpeedMusic(1.4f); else - { - S_StopMusic(); - S_ChangeMusicInternal("shoes", false); - } + P_PlayJingle(player, JT_SHOES); + strlcpy(S_sfx[sfx_None].caption, "Speed shoes", 12); + S_StartCaption(sfx_None, -1, player->powers[pw_sneakers]); } } @@ -3111,10 +4290,9 @@ void A_AwardScore(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_AwardScore", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3139,10 +4317,9 @@ void A_ExtraLife(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ExtraLife", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3151,8 +4328,11 @@ void A_ExtraLife(mobj_t *actor) player = actor->target->player; - if (actor->type == MT_1UPICO && !actor->tracer) - actor->frame -= 2; // No lives icon for this player, use the default. + if (actor->type == MT_1UP_ICON && actor->tracer) + { + // We're using the overlay, so use the overlay 1up sprite (no text) + actor->sprite = SPR_TV1P; + } if (ultimatemode) //I don't THINK so! { @@ -3160,29 +4340,24 @@ void A_ExtraLife(mobj_t *actor) return; } - // In shooter gametypes, give the player 100 rings instead of an extra life. - if (gametype != GT_COOP && gametype != GT_COMPETITION) - P_GivePlayerRings(player, 100); - else - P_GivePlayerLives(player, 1); - P_PlayLivesJingle(player); + P_GiveCoopLives(player, 1, true); } -// Function: A_BombShield +// Function: A_GiveShield // -// Description: Awards the player a bomb shield. +// Description: Awards the player a specified shield. // -// var1 = unused +// var1 = Shield type (make with SH_ constants) // var2 = unused // -void A_BombShield(mobj_t *actor) +void A_GiveShield(mobj_t *actor) { player_t *player; + UINT16 locvar1 = var1; -#ifdef HAVE_BLUA - if (LUA_CallAction("A_BombShield", actor)) + if (LUA_CallAction("A_GiveShield", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3191,128 +4366,10 @@ void A_BombShield(mobj_t *actor) player = actor->target->player; - if ((player->powers[pw_shield] & SH_NOSTACK) != SH_BOMB) - { - player->powers[pw_shield] = SH_BOMB|(player->powers[pw_shield] & SH_STACK); - P_SpawnShieldOrb(player); - } - + P_SwitchShield(player, locvar1); S_StartSound(player->mo, actor->info->seesound); } -// Function: A_WaterShield -// -// Description: Awards the player a water shield. -// -// var1 = unused -// var2 = unused -// -void A_WaterShield(mobj_t *actor) -{ - player_t *player; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_WaterShield", actor)) - return; -#endif - if (!actor->target || !actor->target->player) - { - CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); - return; - } - - player = actor->target->player; - - if ((player->powers[pw_shield] & SH_NOSTACK) != SH_ELEMENTAL) - { - player->powers[pw_shield] = SH_ELEMENTAL|(player->powers[pw_shield] & SH_STACK); - P_SpawnShieldOrb(player); - } - - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - player->powers[pw_underwater] = 0; - - if (player->powers[pw_spacetime] > 1) - { - player->powers[pw_spacetime] = 0; - P_RestoreMusic(player); - } - S_StartSound(player->mo, actor->info->seesound); -} - -// Function: A_ForceShield -// -// Description: Awards the player a force shield. -// -// var1 = unused -// var2 = unused -// -void A_ForceShield(mobj_t *actor) -{ - player_t *player; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_ForceShield", actor)) - return; -#endif - if (!actor->target || !actor->target->player) - { - CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); - return; - } - - player = actor->target->player; - - if (!(player->powers[pw_shield] & SH_FORCE)) - { - player->powers[pw_shield] = SH_FORCE|(player->powers[pw_shield] & SH_STACK)|0x01; - P_SpawnShieldOrb(player); - } - else - player->powers[pw_shield] = SH_FORCE|(player->powers[pw_shield] & SH_STACK)|0x01; - - S_StartSound(player->mo, actor->info->seesound); -} - -// Function: A_PityShield -// -// Description: Awards the player a pity shield. -// Because you fail it. -// Your skill is not enough. -// See you next time. -// Bye-bye. -// -// var1 = unused -// var2 = unused -// -void A_PityShield(mobj_t *actor) -{ - player_t *player; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_PityShield", actor)) - return; -#endif - if (!actor->target || !actor->target->player) - { - CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); - return; - } - - player = actor->target->player; - - if ((player->powers[pw_shield] & SH_NOSTACK) != SH_PITY) - { - player->powers[pw_shield] = SH_PITY+(player->powers[pw_shield] & SH_STACK); - P_SpawnShieldOrb(player); - } - - S_StartSound(player->mo, actor->info->seesound); -} - - // Function: A_GravityBox // // Description: Awards the player gravity boots. @@ -3324,10 +4381,9 @@ void A_GravityBox(mobj_t *actor) { player_t *player; -#ifdef HAVE_BLUA if (LUA_CallAction("A_GravityBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); @@ -3335,9 +4391,10 @@ void A_GravityBox(mobj_t *actor) } player = actor->target->player; - player->powers[pw_gravityboots] = (UINT16)(actor->info->reactiontime + 1); S_StartSound(player, actor->info->activesound); + + player->powers[pw_gravityboots] = (UINT16)(actor->info->reactiontime + 1); } // Function: A_ScoreRise @@ -3349,53 +4406,13 @@ void A_GravityBox(mobj_t *actor) // void A_ScoreRise(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ScoreRise", actor)) return; -#endif + // make logo rise! P_SetObjectMomZ(actor, actor->info->speed, false); } -// Function: A_ParticleSpawn -// -// Description: Spawns a particle at a specified interval -// -// var1 = type (if 0, defaults to MT_PARTICLE) -// var2 = unused -// -void A_ParticleSpawn(mobj_t *actor) -{ - INT32 locvar1 = var1; - fixed_t speed; - mobjtype_t type; - mobj_t *spawn; - -#ifdef HAVE_BLUA - if (LUA_CallAction("A_ParticleSpawn", actor)) - return; -#endif - if (!actor->spawnpoint) - { - P_RemoveMobj(actor); - return; - } - - if (locvar1) - type = (mobjtype_t)locvar1; - else - type = MT_PARTICLE; - - speed = FixedMul((actor->spawnpoint->angle >> 12)<scale); - - spawn = P_SpawnMobj(actor->x, actor->y, actor->z, type); - P_SetScale(spawn, actor->scale); - spawn->momz = speed; - spawn->destscale = FixedDiv(spawn->scale<scalespeed = FixedDiv(((actor->spawnpoint->angle >> 8) & 63) << FRACBITS, 100<tics = actor->spawnpoint->extrainfo + 1; -} - // Function: A_BunnyHop // // Description: Makes object hop like a bunny. @@ -3408,10 +4425,9 @@ void A_BunnyHop(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BunnyHop", actor)) return; -#endif + if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) || (!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz)) { @@ -3432,10 +4448,10 @@ void A_BubbleSpawn(mobj_t *actor) INT32 i, locvar1 = var1; UINT8 prandom; mobj_t *bubble = NULL; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BubbleSpawn", actor)) return; -#endif + if (!(actor->eflags & MFE_UNDERWATER)) { // Don't draw or spawn bubbles above water @@ -3444,10 +4460,10 @@ void A_BubbleSpawn(mobj_t *actor) } actor->flags2 &= ~MF2_DONTDRAW; - if (!(actor->flags & MF_AMBUSH)) + if (!(actor->flags2 & MF2_AMBUSH)) { // Quick! Look through players! - // Don't spawn bubbles unless a player is relatively close by (var2). + // Don't spawn bubbles unless a player is relatively close by (var1). for (i = 0; i < MAXPLAYERS; ++i) if (playeringame[i] && players[i].mo && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (locvar1<z + (4*actor->height)/5; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FanBubbleSpawn", actor)) return; -#endif + if (!(actor->eflags & MFE_UNDERWATER)) return; - if (!(actor->flags & MF_AMBUSH)) + if (!(actor->flags2 & MF2_AMBUSH)) { // Quick! Look through players! // Don't spawn bubbles unless a player is relatively close by (var2). @@ -3532,10 +4548,9 @@ void A_BubbleRise(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BubbleRise", actor)) return; -#endif + if (actor->type == MT_EXTRALARGEBUBBLE) P_SetObjectMomZ(actor, FixedDiv(6*FRACUNIT,5*FRACUNIT), false); // make bubbles rise! else @@ -3569,10 +4584,9 @@ void A_BubbleRise(mobj_t *actor) // void A_BubbleCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_BubbleCheck", actor)) return; -#endif + if (actor->eflags & MFE_UNDERWATER) actor->flags2 &= ~MF2_DONTDRAW; // underwater so draw else @@ -3588,10 +4602,9 @@ void A_BubbleCheck(mobj_t *actor) // void A_AttractChase(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_AttractChase", actor)) return; -#endif + if (actor->flags2 & MF2_NIGHTSPULL || !actor->health) return; @@ -3603,7 +4616,7 @@ void A_AttractChase(mobj_t *actor) // Turn flingrings back into regular rings if attracted. if (actor->tracer && actor->tracer->player - && (actor->tracer->player->powers[pw_shield] & SH_NOSTACK) != SH_ATTRACT && actor->info->reactiontime && actor->type != (mobjtype_t)actor->info->reactiontime) + && !(actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC) && actor->info->reactiontime && actor->type != (mobjtype_t)actor->info->reactiontime) { mobj_t *newring; newring = P_SpawnMobj(actor->x, actor->y, actor->z, actor->info->reactiontime); @@ -3659,10 +4672,9 @@ void A_DropMine(mobj_t *actor) INT32 locvar2 = var2; fixed_t z; mobj_t *mine; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DropMine", actor)) return; -#endif if (locvar2 & 65535) { @@ -3702,15 +4714,30 @@ void A_DropMine(mobj_t *actor) // Description: Makes the stupid harmless fish in Greenflower Zone jump. // // var1 = Jump strength (in FRACBITS), if specified. Otherwise, uses the angle value. -// var2 = unused +// var2 = Trail object to spawn, if desired. // void A_FishJump(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + INT32 locvar2 = var2; + if (LUA_CallAction("A_FishJump", actor)) return; -#endif + + if (locvar2) + { + UINT8 i; + // Don't spawn trail unless a player is nearby. + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && players[i].mo + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) + break; // Stop looking. + if (i < MAXPLAYERS) + { + fixed_t rad = actor->radius>>FRACBITS; + P_SpawnMobjFromMobj(actor, P_RandomRange(rad, -rad)<z <= actor->floorz) || (actor->z <= actor->watertop - FixedMul((64 << FRACBITS), actor->scale))) { @@ -3744,10 +4771,9 @@ void A_ThrownRing(mobj_t *actor) INT32 stop; player_t *player; fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ThrownRing", actor)) return; -#endif if (leveltime % (TICRATE/7) == 0) { @@ -3808,7 +4834,7 @@ void A_ThrownRing(mobj_t *actor) // A non-homing ring getting attracted by a // magnetic player. If he gets too far away, make // sure to stop the attraction! - if ((!actor->tracer->health) || (actor->tracer->player && (actor->tracer->player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT + if ((!actor->tracer->health) || (actor->tracer->player && (actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC) && P_AproxDistance(P_AproxDistance(actor->tracer->x-actor->x, actor->tracer->y-actor->y), actor->tracer->z-actor->z) > FixedMul(RING_DIST/4, actor->tracer->scale))) { @@ -3816,7 +4842,7 @@ void A_ThrownRing(mobj_t *actor) } if (actor->tracer && (actor->tracer->health) - && (actor->tracer->player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT)// Already found someone to follow. + && (actor->tracer->player->powers[pw_shield] & SH_PROTECTELECTRIC))// Already found someone to follow. { const INT32 temp = actor->threshold; actor->threshold = 32000; @@ -3863,7 +4889,7 @@ void A_ThrownRing(mobj_t *actor) continue; // Don't home in on teammates. - if (gametype == GT_CTF + if ((gametyperules & GTR_TEAMFLAGS) && actor->target->player->ctfteam == player->ctfteam) continue; } @@ -3884,7 +4910,7 @@ void A_ThrownRing(mobj_t *actor) if (!P_CheckSight(actor, player->mo)) continue; // out of sight - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT + if ((player->powers[pw_shield] & SH_PROTECTELECTRIC) && dist < FixedMul(RING_DIST/4, player->mo->scale)) P_SetTarget(&actor->tracer, player->mo); return; @@ -3902,21 +4928,23 @@ void A_ThrownRing(mobj_t *actor) // void A_SetSolidSteam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetSolidSteam", actor)) return; -#endif + actor->flags &= ~MF_NOCLIP; actor->flags |= MF_SOLID; - if (P_RandomChance(FRACUNIT/8)) + if (!(actor->flags2 & MF2_AMBUSH)) { - if (actor->info->deathsound) - S_StartSound(actor, actor->info->deathsound); // Hiss! - } - else - { - if (actor->info->painsound) - S_StartSound(actor, actor->info->painsound); + if (P_RandomChance(FRACUNIT/8)) + { + if (actor->info->deathsound) + S_StartSound(actor, actor->info->deathsound); // Hiss! + } + else + { + if (actor->info->painsound) + S_StartSound(actor, actor->info->painsound); + } } P_SetObjectMomZ (actor, 1, true); @@ -3931,44 +4959,212 @@ void A_SetSolidSteam(mobj_t *actor) // void A_UnsetSolidSteam(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_UnsetSolidSteam", actor)) return; -#endif + actor->flags &= ~MF_SOLID; actor->flags |= MF_NOCLIP; } +// Function: A_SignSpin +// +// Description: Spins a signpost until it hits the ground and reaches its mapthing's angle. +// +// var1 = degrees to rotate object (must be positive, because I'm lazy) +// var2 = unused +// +void A_SignSpin(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT16 i; + angle_t rotateangle = FixedAngle(locvar1 << FRACBITS); + + if (LUA_CallAction("A_SignSpin", actor)) + return; + + if (P_IsObjectOnGround(actor) && P_MobjFlip(actor) * actor->momz <= 0) + { + if (actor->flags2 & MF2_BOSSFLEE) + { + S_StartSound(actor, actor->info->deathsound); + actor->flags2 &= ~MF2_BOSSFLEE; + } + if (actor->spawnpoint) + { + angle_t mapangle = FixedAngle(actor->spawnpoint->angle << FRACBITS); + angle_t diff = mapangle - actor->angle; + if (diff < ANG2) + { + actor->angle = mapangle; + P_SetMobjState(actor, actor->info->deathstate); + return; + } + if ((statenum_t)(actor->state-states) != actor->info->painstate) + P_SetMobjState(actor, actor->info->painstate); + actor->movedir = min((mapangle - actor->angle) >> 2, actor->movedir); + } + else // no mapthing? just finish in your current angle + { + P_SetMobjState(actor, actor->info->deathstate); + return; + } + } + else + { + if (!(actor->flags2 & MF2_BOSSFLEE)) + { + S_StartSound(actor, actor->info->painsound); + actor->flags2 |= MF2_BOSSFLEE; + } + actor->movedir = rotateangle; + } + + actor->angle += actor->movedir; + if (actor->tracer == NULL || P_MobjWasRemoved(actor->tracer)) return; + for (i = -1; i < 2; i += 2) + { + P_SpawnMobjFromMobj(actor, + P_ReturnThrustX(actor, actor->tracer->angle, i * actor->radius), + P_ReturnThrustY(actor, actor->tracer->angle, i * actor->radius), + (actor->eflags & MFE_VERTICALFLIP) ? 0 : actor->height, + actor->info->painchance)->destscale >>= 1; + } +} + // Function: A_SignPlayer // // Description: Changes the state of a level end sign to reflect the player that hit it. +// Also used to display Eggman or the skin roulette whilst spinning. // -// var1 = unused -// var2 = unused +// var1 = number of skin to display (e.g. 2 = Knuckles; special cases: -1 = target's skin, -2 = skin roulette, -3 = Eggman) +// var2 = custom sign color, if desired. // void A_SignPlayer(mobj_t *actor) { + INT32 locvar1 = var1; + INT32 locvar2 = var2; + skin_t *skin = NULL; mobj_t *ov; -#ifdef HAVE_BLUA + UINT8 facecolor, signcolor = (UINT8)locvar2; + UINT32 signframe = states[actor->info->raisestate].frame; + if (LUA_CallAction("A_SignPlayer", actor)) return; -#endif - if (!actor->target) + + if (actor->tracer == NULL || locvar1 < -3 || locvar1 >= numskins || signcolor >= MAXTRANSLATIONS) return; - if (!actor->target->player) - return; + // if no face overlay, spawn one + if (actor->tracer->tracer == NULL || P_MobjWasRemoved(actor->tracer->tracer)) + { + ov = P_SpawnMobj(actor->x, actor->y, actor->z, MT_OVERLAY); + P_SetTarget(&ov->target, actor->tracer); + P_SetTarget(&actor->tracer->tracer, ov); + } + else + ov = actor->tracer->tracer; - // Set the sign to be an appropriate background color for this player's skincolor. - actor->color = Color_Opposite[actor->target->player->skincolor*2]; - actor->frame += Color_Opposite[actor->target->player->skincolor*2+1]; + if (locvar1 == -1) // set to target's skin + { + if (!actor->target) + return; - // spawn an overlay of the player's face. - ov = P_SpawnMobj(actor->x, actor->y, actor->z, MT_OVERLAY); - P_SetTarget(&ov->target, actor); - ov->color = actor->target->player->skincolor; - ov->skin = &skins[actor->target->player->skin]; - P_SetMobjState(ov, actor->info->seestate); // S_PLAY_SIGN + if (!actor->target->player) + return; + + skin = &skins[actor->target->player->skin]; + facecolor = actor->target->player->skincolor; + + if (signcolor) + ; + else if (!skin->sprites[SPR2_SIGN].numframes) + signcolor = facecolor; + else if ((actor->target->player->skincolor == skin->prefcolor) && (skin->prefoppositecolor)) // Set it as the skin's preferred oppositecolor? + signcolor = skin->prefoppositecolor; + else if (actor->target->player->skincolor) // Set the sign to be an appropriate background color for this player's skincolor. + signcolor = Color_Opposite[actor->target->player->skincolor - 1][0]; + else + signcolor = SKINCOLOR_NONE; + } + else if (locvar1 != -3) // set to a defined skin + { + // I turned this function into a fucking mess. I'm so sorry. -Lach + if (locvar1 == -2) // random skin + { +#define skincheck(num) (player ? !R_SkinUsable(player-players, num) : skins[num].availability > 0) + player_t *player = actor->target ? actor->target->player : NULL; + UINT8 skinnum; + UINT8 skincount = 0; + for (skinnum = 0; skinnum < numskins; skinnum++) + if (!skincheck(skinnum)) + skincount++; + skinnum = P_RandomKey(skincount); + for (skincount = 0; skincount < numskins; skincount++) + { + if (skincount > skinnum) + break; + if (skincheck(skincount)) + skinnum++; + } + skin = &skins[skinnum]; +#undef skincheck + } + else // specific skin + skin = &skins[locvar1]; + + facecolor = skin->prefcolor; + if (signcolor) + ; + else if (!skin->sprites[SPR2_SIGN].numframes) + signcolor = facecolor; + else if (skin->prefoppositecolor) + signcolor = skin->prefoppositecolor; + else if (facecolor) + signcolor = Color_Opposite[facecolor - 1][0]; + } + + if (skin) + { + if (skin->sprites[SPR2_SIGN].numframes) // player face + { + ov->color = facecolor; + ov->skin = skin; + if ((statenum_t)(ov->state-states) != actor->info->seestate) + P_SetMobjState(ov, actor->info->seestate); // S_PLAY_SIGN + } + else // CLEAR! sign + { + ov->color = SKINCOLOR_NONE; + ov->skin = NULL; // needs to be NULL in the case of SF_HIRES characters + if ((statenum_t)(ov->state-states) != actor->info->missilestate) + P_SetMobjState(ov, actor->info->missilestate); // S_CLEARSIGN + } + } + else // Eggman face + { + ov->color = SKINCOLOR_NONE; + ov->skin = NULL; + if ((statenum_t)(ov->state-states) != actor->info->meleestate) + P_SetMobjState(ov, actor->info->meleestate); // S_EGGMANSIGN + if (!signcolor) + signcolor = SKINCOLOR_CARBON; + } + + actor->tracer->color = signcolor; + /* + If you're here from the comment above Color_Opposite, + the following line is the one which is dependent on the + array being symmetrical. It gets the opposite of the + opposite of your desired colour just so it can get the + brightness frame for the End Sign. It's not a great + design choice, but it's constant time array access and + the idea that the colours should be OPPOSITES is kind + of in the name. If you have a better idea, feel free + to let me know. ~toast 2016/07/20 + */ + if (signcolor && signcolor < MAXSKINCOLORS) + signframe += (15 - Color_Opposite[Color_Opposite[signcolor - 1][0] - 1][1]); + actor->tracer->frame = signframe; } // Function: A_OverlayThink @@ -3981,10 +5177,10 @@ void A_SignPlayer(mobj_t *actor) void A_OverlayThink(mobj_t *actor) { fixed_t destx, desty; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_OverlayThink", actor)) return; -#endif + if (!actor->target) return; @@ -4015,7 +5211,7 @@ void A_OverlayThink(mobj_t *actor) actor->z = actor->target->z + actor->target->height - mobjinfo[actor->type].height - ((var2>>16) ? -1 : 1)*(var2&0xFFFF)*FRACUNIT; else actor->z = actor->target->z + ((var2>>16) ? -1 : 1)*(var2&0xFFFF)*FRACUNIT; - actor->angle = actor->target->angle; + actor->angle = actor->target->angle + actor->movedir; actor->eflags = actor->target->eflags; actor->momx = actor->target->momx; @@ -4033,12 +5229,11 @@ void A_OverlayThink(mobj_t *actor) void A_JetChase(mobj_t *actor) { fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetChase", actor)) return; -#endif - if (actor->flags & MF_AMBUSH) + if (actor->flags2 & MF2_AMBUSH) return; if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz @@ -4130,10 +5325,9 @@ void A_JetbThink(mobj_t *actor) { sector_t *nextsector; fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetbThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -4145,7 +5339,8 @@ void A_JetbThink(mobj_t *actor) { A_JetChase(actor); // check for melee attack - if ((actor->z > (actor->floorz + FixedMul((32<scale))) + if (actor->info->raisestate + && (actor->z > (actor->floorz + FixedMul((32<scale))) && P_JetbCheckMeleeRange(actor) && !actor->reactiontime && (actor->target->z >= actor->floorz)) { @@ -4195,10 +5390,9 @@ void A_JetbThink(mobj_t *actor) void A_JetgShoot(mobj_t *actor) { fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetgShoot", actor)) return; -#endif if (!actor->target) return; @@ -4236,10 +5430,9 @@ void A_JetgShoot(mobj_t *actor) void A_ShootBullet(mobj_t *actor) { fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ShootBullet", actor)) return; -#endif if (!actor->target) return; @@ -4256,56 +5449,114 @@ void A_ShootBullet(mobj_t *actor) S_StartSound(actor, actor->info->attacksound); } +static mobj_t *minus; + +static boolean PIT_MinusCarry(mobj_t *thing) +{ + if (minus->tracer) + return true; + + if (minus->type == thing->type) + return true; + + if (!(thing->flags & (MF_PUSHABLE|MF_ENEMY))) + return true; + + if (P_AproxDistance(minus->x - thing->x, minus->y - thing->y) >= minus->radius*3) + return true; + + if (abs(thing->z - minus->z) > minus->height) + return true; + + P_SetTarget(&minus->tracer, thing); + + return true; +} + // Function: A_MinusDigging // // Description: Minus digging in the ground. // -// var1 = unused +// var1 = If 1, play digging sound. // var2 = unused // void A_MinusDigging(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 locvar1 = var1; + INT32 rad = 32; + angle_t fa = (actor->angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t dis = actor->info->speed*4; + fixed_t x = FINECOSINE(fa)*dis + actor->x + FRACUNIT*P_RandomRange(-rad, rad); + fixed_t y = FINESINE(fa)*dis + actor->y + FRACUNIT*P_RandomRange(-rad, rad); + fixed_t mz = (actor->eflags & MFE_VERTICALFLIP) ? actor->ceilingz : actor->floorz; + mobj_t *par; + if (LUA_CallAction("A_MinusDigging", actor)) return; -#endif - actor->flags &= ~MF_SPECIAL; - actor->flags &= ~MF_SHOOTABLE; if (!actor->target) { - A_Look(actor); + P_SetMobjState(actor, actor->info->spawnstate); return; } - if (actor->reactiontime) + par = P_SpawnMobj(actor->x, actor->y, mz, MT_MINUSDIRT); + if (actor->eflags & MFE_VERTICALFLIP) + par->eflags |= MFE_VERTICALFLIP; + P_TryMove(par, x, y, false); + + // If close enough, prepare to attack + if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < actor->radius*2) { - actor->reactiontime--; + P_SetMobjState(actor, actor->info->meleestate); + P_TryMove(actor, actor->target->x, actor->target->y, false); + S_StartSound(actor, actor->info->attacksound); + + // Spawn growing dirt pile. + par = P_SpawnMobj(actor->x, actor->y, mz, MT_MINUSDIRT); + P_SetMobjState(par, actor->info->raisestate); + P_SetScale(par, actor->scale*2); + if (actor->eflags & MFE_VERTICALFLIP) + par->eflags |= MFE_VERTICALFLIP; return; } - // Dirt trail - P_SpawnGhostMobj(actor); - - actor->flags |= MF_NOCLIPTHING; - var1 = 3; - A_Chase(actor); - actor->flags &= ~MF_NOCLIPTHING; - // Play digging sound - if (!(leveltime & 15)) - S_StartSound(actor, actor->info->activesound); + if (locvar1 == 1) + A_PlayActiveSound(actor); - // If we're close enough to our target, pop out of the ground - if (P_AproxDistance(actor->target->x-actor->x, actor->target->y-actor->y) < actor->radius - && abs(actor->target->z - actor->z) < actor->height) - P_SetMobjState(actor, actor->info->missilestate); + // Move + var1 = 3; + A_Chase(actor); - // Snap to ground - if (actor->eflags & MFE_VERTICALFLIP) - actor->z = actor->ceilingz - actor->height; + // Carry over shit, maybe + if (P_MobjWasRemoved(actor->tracer) || !actor->tracer->health) + P_SetTarget(&actor->tracer, NULL); + + if (!actor->tracer) + { + fixed_t radius = 3*actor->radius; + fixed_t yh = (unsigned)(actor->y + radius - bmaporgy) >> MAPBLOCKSHIFT; + fixed_t yl = (unsigned)(actor->y - radius - bmaporgy) >> MAPBLOCKSHIFT; + fixed_t xh = (unsigned)(actor->x + radius - bmaporgx) >> MAPBLOCKSHIFT; + fixed_t xl = (unsigned)(actor->x - radius - bmaporgx) >> MAPBLOCKSHIFT; + fixed_t bx, by; + + BMBOUNDFIX(xl, xh, yl, yh); + + minus = actor; + + for (bx = xl; bx <= xh; bx++) + for (by = yl; by <= yh; by++) + P_BlockThingsIterator(bx, by, PIT_MinusCarry); + } else - actor->z = actor->floorz; + { + if (P_TryMove(actor->tracer, actor->x, actor->y, false)) + actor->tracer->z = mz; + else + P_SetTarget(&actor->tracer, NULL); + } } // Function: A_MinusPopup @@ -4317,45 +5568,65 @@ void A_MinusDigging(mobj_t *actor) // void A_MinusPopup(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 num = 6; + angle_t ani = FixedAngle(FRACUNIT*360/num); + INT32 i; + if (LUA_CallAction("A_MinusPopup", actor)) return; -#endif - P_SetObjectMomZ(actor, 10*FRACUNIT, false); - actor->flags |= MF_SPECIAL; - actor->flags |= MF_SHOOTABLE; + if (actor->eflags & MFE_VERTICALFLIP) + actor->momz = -10*FRACUNIT; + else + actor->momz = 10*FRACUNIT; - // Sound for busting out of the ground. - S_StartSound(actor, actor->info->attacksound); + S_StartSound(actor, sfx_s3k82); + for (i = 1; i <= num; i++) + { + mobj_t *rock = P_SpawnMobjFromMobj(actor, 0, 0, actor->height/4, MT_ROCKCRUMBLE1); + P_Thrust(rock, ani*i, FRACUNIT); + P_SetObjectMomZ(rock, 3*FRACUNIT, false); + P_SetScale(rock, rock->scale/3); + } + P_RadiusAttack(actor, actor, 2*actor->radius, 0); + if (actor->tracer) + P_DamageMobj(actor->tracer, actor, actor, 1, 0); + + actor->flags = (actor->flags & ~MF_NOCLIPTHING)|MF_SPECIAL|MF_SHOOTABLE; } // Function: A_MinusCheck // // Description: If the minus hits the floor, dig back into the ground. // -// var1 = unused -// var2 = unused +// var1 = State to switch to (if 0, use seestate). +// var2 = If not 0, spawn debris when hitting the floor. // void A_MinusCheck(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 locvar1 = var1; + INT32 locvar2 = var2; + if (LUA_CallAction("A_MinusCheck", actor)) return; -#endif - if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) - || ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz)) - { - actor->flags &= ~MF_SPECIAL; - actor->flags &= ~MF_SHOOTABLE; - actor->reactiontime = TICRATE; - P_SetMobjState(actor, actor->info->seestate); - return; - } - // 'Falling' animation - if (P_MobjFlip(actor)*actor->momz < 0 && actor->state < &states[actor->info->meleestate]) - P_SetMobjState(actor, actor->info->meleestate); + if (((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz) || (!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz)) + { + P_SetMobjState(actor, locvar1 ? (statenum_t)locvar1 : actor->info->seestate); + actor->flags = actor->info->flags; + if (locvar2) + { + INT32 i, num = 6; + angle_t ani = FixedAngle(FRACUNIT*360/num); + for (i = 1; i <= num; i++) + { + mobj_t *rock = P_SpawnMobjFromMobj(actor, 0, 0, actor->height/4, MT_ROCKCRUMBLE1); + P_Thrust(rock, ani*i, FRACUNIT); + P_SetObjectMomZ(rock, 3*FRACUNIT, false); + P_SetScale(rock, rock->scale/3); + } + } + } } // Function: A_ChickenCheck @@ -4367,10 +5638,9 @@ void A_MinusCheck(mobj_t *actor) // void A_ChickenCheck(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ChickenCheck", actor)) return; -#endif + if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height >= actor->ceilingz)) { @@ -4398,10 +5668,9 @@ void A_JetgThink(mobj_t *actor) sector_t *nextsector; fixed_t thefloor; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_JetgThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -4450,10 +5719,8 @@ void A_JetgThink(mobj_t *actor) // void A_MouseThink(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_MouseThink", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; @@ -4488,10 +5755,9 @@ void A_DetonChase(mobj_t *actor) { angle_t exact; fixed_t xydist, dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DetonChase", actor)) return; -#endif // modify tracer threshold if (!actor->tracer || actor->tracer->health <= 0) @@ -4635,10 +5901,10 @@ void A_CapeChase(mobj_t *actor) fixed_t foffsetx, foffsety, boffsetx, boffsety; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + angle_t angle; + if (LUA_CallAction("A_CapeChase", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_CapeChase called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -4656,11 +5922,13 @@ void A_CapeChase(mobj_t *actor) return; } - foffsetx = P_ReturnThrustX(chaser, chaser->angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale)); - foffsety = P_ReturnThrustY(chaser, chaser->angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale)); + angle = (chaser->player ? chaser->player->drawangle : chaser->angle); - boffsetx = P_ReturnThrustX(chaser, chaser->angle-ANGLE_90, FixedMul((locvar2 & 65535)*FRACUNIT, actor->scale)); - boffsety = P_ReturnThrustY(chaser, chaser->angle-ANGLE_90, FixedMul((locvar2 & 65535)*FRACUNIT, actor->scale)); + foffsetx = P_ReturnThrustX(chaser, angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale)); + foffsety = P_ReturnThrustY(chaser, angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale)); + + boffsetx = P_ReturnThrustX(chaser, angle-ANGLE_90, FixedMul((locvar2 & 65535)*FRACUNIT, actor->scale)); + boffsety = P_ReturnThrustY(chaser, angle-ANGLE_90, FixedMul((locvar2 & 65535)*FRACUNIT, actor->scale)); P_UnsetThingPosition(actor); actor->x = chaser->x + foffsetx + boffsetx; @@ -4677,7 +5945,7 @@ void A_CapeChase(mobj_t *actor) actor->flags2 &= ~MF2_OBJECTFLIP; actor->z = chaser->z + FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale); } - actor->angle = chaser->angle; + actor->angle = angle; P_SetThingPosition(actor); } @@ -4694,12 +5962,8 @@ void A_RotateSpikeBall(mobj_t *actor) { INT32 locvar1 = var1; const fixed_t radius = FixedMul(12*actor->info->speed, actor->scale); -#ifdef HAVE_BLUA - if (LUA_CallAction("A_RotateSpikeBall", actor)) - return; -#endif - if (actor->type == MT_SPECIALSPIKEBALL) // don't remove this, these spikeballs share the same states as the rotating spikeballs + if (LUA_CallAction("A_RotateSpikeBall", actor)) return; if (!((!locvar1 && (actor->target)) || (locvar1 && (actor->tracer))))// This should NEVER happen. @@ -4750,10 +6014,8 @@ void A_UnidusBall(mobj_t *actor) INT32 locvar1 = var1; boolean canthrow = false; -#ifdef HAVE_BLUA if (LUA_CallAction("A_UnidusBall", actor)) return; -#endif actor->angle += ANGLE_11hh; @@ -4804,7 +6066,7 @@ void A_UnidusBall(mobj_t *actor) boolean skull = (actor->target->flags2 & MF2_SKULLFLY) == MF2_SKULLFLY; if (actor->target->state == &states[actor->target->info->painstate]) { - P_KillMobj(actor, NULL, NULL); + P_KillMobj(actor, NULL, NULL, 0); return; } switch(actor->extravalue2) @@ -4848,10 +6110,9 @@ void A_RockSpawn(mobj_t *actor) line_t *line; fixed_t dist; fixed_t randomoomph; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RockSpawn", actor)) return; -#endif if (i == -1) { @@ -4900,170 +6161,45 @@ void A_RockSpawn(mobj_t *actor) // void A_SlingAppear(mobj_t *actor) { - boolean firsttime = true; UINT8 mlength = 4; - mobj_t *spawnee; -#ifdef HAVE_BLUA + mobj_t *spawnee, *hprev; + if (LUA_CallAction("A_SlingAppear", actor)) return; -#endif P_UnsetThingPosition(actor); actor->flags &= ~(MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); P_SetThingPosition(actor); actor->lastlook = 128; actor->movecount = actor->lastlook; - actor->health = actor->angle>>ANGLETOFINESHIFT; actor->threshold = 0; actor->movefactor = actor->threshold; actor->friction = 128; - actor->flags |= MF_SLIDEME; + hprev = P_SpawnMobj(actor->x, actor->y, actor->z, MT_SMALLGRABCHAIN); + P_SetTarget(&hprev->tracer, actor); + P_SetTarget(&hprev->hprev, actor); + P_SetTarget(&actor->hnext, hprev); + hprev->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; + hprev->movecount = mlength; + + mlength--; while (mlength > 0) { spawnee = P_SpawnMobj(actor->x, actor->y, actor->z, MT_SMALLMACECHAIN); + P_SetTarget(&spawnee->tracer, actor); + P_SetTarget(&spawnee->hprev, hprev); + P_SetTarget(&hprev->hnext, spawnee); + hprev = spawnee; - P_SetTarget(&spawnee->target, actor); - - spawnee->movecount = 0; - spawnee->threshold = 0; - spawnee->reactiontime = mlength; - - if (firsttime) - { - // This is the outermost link in the chain - spawnee->flags |= MF_AMBUSH; - firsttime = false; - } + spawnee->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; + spawnee->movecount = mlength; mlength--; } } -// -// Function: A_MaceRotate -// -// Spins an object around its target, or, swings it from side to side. -// -// var1 = unused -// var2 = unused -// -// So NOBODY forgets: -// actor-> -// threshold - X tilt -// movecount - Z tilt -// reactiontime - link # in the chain (1 is closest) -// lastlook - speed -// friction - top speed -// movedir - current angle holder -// extravalue1 - smoothly move link into place -// -void A_MaceRotate(mobj_t *actor) -{ - TVector v; - TVector *res; - fixed_t radius; -#ifdef HAVE_BLUA - if (LUA_CallAction("A_MaceRotate", actor)) - return; -#endif - - // Target was removed. - if (!actor->target) - { - P_RemoveMobj(actor); - return; - } - - P_UnsetThingPosition(actor); - - // Radius of the link's rotation. - radius = FixedMul(actor->info->speed * actor->reactiontime, actor->target->scale); - - // Double the radius if the chain links are made up of maces. - if (actor->target->type == MT_AXIS && (actor->type == MT_SMALLMACE || actor->type == MT_BIGMACE)) - radius *= 2; - - // Axis offset for the axis. - radius += actor->target->extravalue1; - - // Smoothly move the link into position. - if (actor->extravalue1) - { - radius = FixedMul(radius, FixedDiv(actor->extravalue1, 100)); - actor->extravalue1 += 1; - if (actor->extravalue1 >= 100) - actor->extravalue1 = 0; - } - - actor->x = actor->target->x; - actor->y = actor->target->y; - actor->z = actor->target->z; - - // Cut the height to align the link with the axis. - if (actor->type == MT_SMALLMACECHAIN || actor->type == MT_BIGMACECHAIN) - actor->z -= actor->height/4; - else - actor->z -= actor->height/2; - - // Set the top speed for the link if it happens to be over that speed. - if (actor->target->lastlook > actor->target->friction) - actor->target->lastlook = actor->target->friction; - - // Swinging Chain. - if (actor->target->type == MT_HANGMACEPOINT || actor->target->type == MT_SWINGMACEPOINT) - { - actor->movecount += actor->target->lastlook; - actor->movecount &= FINEMASK; - - actor->threshold = FixedMul(FINECOSINE(actor->movecount), actor->target->lastlook << FRACBITS); - - v[0] = FRACUNIT; - v[1] = 0; - v[2] = -radius; - v[3] = FRACUNIT; - - // Calculate the angle matrixes for the link. - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->threshold))); - M_Memcpy(&v, res, sizeof(v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); - M_Memcpy(&v, res, sizeof(v)); - } - // Rotating Chain. - else - { - angle_t fa; - - actor->threshold += actor->target->lastlook; - actor->threshold &= FINEMASK; - actor->target->health &= FINEMASK; - - fa = actor->threshold; - v[0] = FixedMul(FINECOSINE(fa), radius); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa), radius); - v[3] = FRACUNIT; - - // Calculate the angle matrixes for the link. - res = VectorMatrixMultiply(v, *RotateXMatrix(actor->target->threshold << ANGLETOFINESHIFT)); - M_Memcpy(&v, res, sizeof(v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); - M_Memcpy(&v, res, sizeof(v)); - } - - // Add on the appropriate distances to the actor's co-ordinates. - actor->x += v[0]; - actor->y += v[1]; - actor->z += v[2]; - - P_SetThingPosition(actor); - - if (!(actor->target->flags2 & MF2_BOSSNOTRAP) // flag that makes maces shut up on request - && !(leveltime & 63) && (actor->type == MT_BIGMACE || actor->type == MT_SMALLMACE) && actor->target->type == MT_MACEPOINT) - S_StartSound(actor, actor->info->activesound); -} - // Function: A_SetFuse // // Description: Sets the actor's fuse timer if not set already. May also change state when fuse reaches the last tic, otherwise by default the actor will die or disappear. (Replaces A_SnowBall) @@ -5077,10 +6213,9 @@ void A_SetFuse(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetFuse", actor)) return; -#endif if ((!actor->fuse || (locvar2 >> 16)) && (locvar2 >> 16) != 2) // set the actor's fuse value actor->fuse = locvar1; @@ -5106,10 +6241,10 @@ void A_CrawlaCommanderThink(mobj_t *actor) fixed_t thefloor; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + boolean hovermode = (actor->health > 1 || actor->fuse); + if (LUA_CallAction("A_CrawlaCommanderThink", actor)) return; -#endif if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz && actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale)) @@ -5117,10 +6252,16 @@ void A_CrawlaCommanderThink(mobj_t *actor) else thefloor = actor->floorz; - if (actor->fuse & 1) - actor->flags2 |= MF2_DONTDRAW; - else - actor->flags2 &= ~MF2_DONTDRAW; + if (!actor->fuse && actor->flags2 & MF2_FRET) + { + if (actor->info->painsound) + S_StartSound(actor, actor->info->painsound); + + actor->fuse = TICRATE/2; + actor->momz = 0; + + P_InstaThrust(actor, actor->angle-ANGLE_180, FixedMul(5*FRACUNIT, actor->scale)); + } if (actor->reactiontime > 0) actor->reactiontime--; @@ -5132,7 +6273,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) } // Hover mode - if (actor->health > 1 || actor->fuse) + if (hovermode) { if (actor->z < thefloor + FixedMul(16*FRACUNIT, actor->scale)) actor->momz += FixedMul(FRACUNIT, actor->scale); @@ -5142,7 +6283,7 @@ void A_CrawlaCommanderThink(mobj_t *actor) actor->momz += FixedMul(16, actor->scale); } - if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) + if (!actor->target) { // look for a new target if (P_LookForPlayers(actor, true, false, 0)) @@ -5155,14 +6296,13 @@ void A_CrawlaCommanderThink(mobj_t *actor) dist = P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y); - if (actor->target->player && actor->health > 1) + if (actor->target->player && (!hovermode || actor->reactiontime <= 2*TICRATE)) { - if (dist < FixedMul(128*FRACUNIT, actor->scale) + if (dist < FixedMul(64<<(FRACBITS+(hovermode ? 1 : 0)), actor->scale) && ((actor->target->player->pflags & PF_JUMPED) || (actor->target->player->pflags & PF_SPINNING))) { - // Auugh! He's trying to kill you! Strafe! STRAAAAFFEEE!! - if (actor->target->momx || actor->target->momy) - P_InstaThrust(actor, actor->angle - ANGLE_180, FixedMul(20*FRACUNIT, actor->scale)); + // Auugh! She's trying to kill you! Strafe! STRAAAAFFEEE!! + P_InstaThrust(actor, actor->angle - ANGLE_180, FixedMul(20*FRACUNIT, actor->scale)); return; } } @@ -5187,29 +6327,44 @@ void A_CrawlaCommanderThink(mobj_t *actor) actor->angle += (P_RandomByte()<<10); actor->angle -= (P_RandomByte()<<10); - if (actor->health > 1) - P_InstaThrust(actor, actor->angle, FixedMul(10*FRACUNIT, actor->scale)); + if (hovermode) + { + fixed_t mom; + P_Thrust(actor, actor->angle, 2*actor->scale); + mom = P_AproxDistance(actor->momx, actor->momy); + if (mom > 20*actor->scale) + { + mom += 20*actor->scale; + mom >>= 1; + P_InstaThrust(actor, R_PointToAngle2(0, 0, actor->momx, actor->momy), mom); + } + } } else if (!actor->reactiontime) { - if (actor->health > 1) // Hover Mode + if (hovermode && !(actor->flags2 & MF2_FRET)) // Hover Mode { if (dist < FixedMul(512*FRACUNIT, actor->scale)) { actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y); - P_InstaThrust(actor, actor->angle, FixedMul(60*FRACUNIT, actor->scale)); + P_InstaThrust(actor, actor->angle, FixedMul(40*FRACUNIT, actor->scale)); actor->threshold = 1; + if (actor->info->attacksound) + S_StartSound(actor, actor->info->attacksound); } } - actor->reactiontime = 2*TICRATE + P_RandomByte()/2; + actor->reactiontime = 3*TICRATE + (P_RandomByte()>>2); } if (actor->health == 1) P_Thrust(actor, actor->angle, 1); // Pogo Mode - if (!actor->fuse && actor->health == 1 && actor->z <= actor->floorz) + if (!hovermode && actor->z <= actor->floorz) { + if (actor->info->activesound) + S_StartSound(actor, actor->info->activesound); + if (dist < FixedMul(256*FRACUNIT, actor->scale)) { actor->momz = FixedMul(locvar2, actor->scale); @@ -5245,19 +6400,18 @@ void A_RingExplode(mobj_t *actor) mobj_t *mo2; thinker_t *th; angle_t d; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RingExplode", actor)) return; -#endif for (d = 0; d < 16; d++) P_SpawnParaloop(actor->x, actor->y, actor->z + actor->height, FixedMul(actor->info->painchance, actor->scale), 16, MT_NIGHTSPARKLE, S_NULL, d*(ANGLE_22h), true); S_StartSound(actor, sfx_prloop); - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -5271,7 +6425,7 @@ void A_RingExplode(mobj_t *actor) if (mo2->flags & MF_SHOOTABLE) { actor->flags2 |= MF2_DEBRIS; - P_DamageMobj(mo2, actor, actor->target, 1); + P_DamageMobj(mo2, actor, actor->target, 1, 0); continue; } } @@ -5290,12 +6444,10 @@ void A_OldRingExplode(mobj_t *actor) { mobj_t *mo; const fixed_t ns = FixedMul(20 * FRACUNIT, actor->scale); INT32 locvar1 = var1; - //INT32 locvar2 = var2; boolean changecolor = (actor->target && actor->target->player); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_OldRingExplode", actor)) return; -#endif for (i = 0; i < 32; i++) { @@ -5320,7 +6472,7 @@ void A_OldRingExplode(mobj_t *actor) { if (changecolor) { - if (gametype != GT_CTF) + if (!(gametyperules & GTR_TEAMFLAGS)) mo->color = actor->target->color; //copy color else if (actor->target->player->ctfteam == 2) mo->color = skincolor_bluering; @@ -5336,7 +6488,7 @@ void A_OldRingExplode(mobj_t *actor) { if (changecolor) { - if (gametype != GT_CTF) + if (!(gametyperules & GTR_TEAMFLAGS)) mo->color = actor->target->color; //copy color else if (actor->target->player->ctfteam == 2) mo->color = skincolor_bluering; @@ -5351,7 +6503,7 @@ void A_OldRingExplode(mobj_t *actor) { if (changecolor) { - if (gametype != GT_CTF) + if (!(gametyperules & GTR_TEAMFLAGS)) mo->color = actor->target->color; //copy color else if (actor->target->player->ctfteam == 2) mo->color = skincolor_bluering; @@ -5369,12 +6521,9 @@ void A_MixUp(mobj_t *actor) { boolean teleported[MAXPLAYERS]; INT32 i, numplayers = 0, prandom = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MixUp", actor)) return; -#else - (void)actor; -#endif if (!multiplayer) return; @@ -5382,7 +6531,10 @@ void A_MixUp(mobj_t *actor) // No mix-up monitors in hide and seek or time only race. // The random factor is okay for other game modes, but in these, it is cripplingly unfair. if (gametype == GT_HIDEANDSEEK || gametype == GT_RACE) + { + S_StartSound(actor, sfx_lose); return; + } numplayers = 0; memset(teleported, 0, sizeof (teleported)); @@ -5391,7 +6543,7 @@ void A_MixUp(mobj_t *actor) // and grab their xyz coords for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE - && !players[i].exiting && !players[i].powers[pw_super]) + && !players[i].exiting && !players[i].powers[pw_super] && players[i].powers[pw_carry] != CR_NIGHTSMODE) { if ((netgame || multiplayer) && players[i].spectator) // Ignore spectators continue; @@ -5400,23 +6552,27 @@ void A_MixUp(mobj_t *actor) } if (numplayers <= 1) // Not enough players to mix up. + { + S_StartSound(actor, sfx_lose); return; + } else if (numplayers == 2) // Special case -- simple swap { fixed_t x, y, z; - angle_t angle; + angle_t angle, drawangle; INT32 one = -1, two = 0; // default value 0 to make the compiler shut up // Zoom tube stuff mobj_t *tempthing = NULL; //tracer - pflags_t flags1,flags2; //player pflags - INT32 transspeed; //player speed + UINT16 carry1,carry2; //carry + INT32 transspeed; //player speed // Starpost stuff INT16 starpostx, starposty, starpostz; INT32 starpostnum; tic_t starposttime; angle_t starpostangle; + fixed_t starpostscale; INT32 mflags2; @@ -5437,6 +6593,10 @@ void A_MixUp(mobj_t *actor) } //get this done first! + if (players[one].powers[pw_carry] == CR_MINECART && players[one].mo->tracer && !(P_MobjWasRemoved(players[one].mo->tracer))) + P_SetTarget(&players[one].mo->tracer->target, players[two].mo); + if (players[two].powers[pw_carry] == CR_MINECART && players[two].mo->tracer && !(P_MobjWasRemoved(players[two].mo->tracer))) + P_SetTarget(&players[two].mo->tracer->target, players[one].mo); tempthing = players[one].mo->tracer; P_SetTarget(&players[one].mo->tracer, players[two].mo->tracer); P_SetTarget(&players[two].mo->tracer, tempthing); @@ -5447,18 +6607,20 @@ void A_MixUp(mobj_t *actor) players[two].speed = transspeed; //set flags variables now but DON'T set them. - flags1 = (players[one].pflags & (PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG)); - flags2 = (players[two].pflags & (PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG)); + carry1 = (players[one].powers[pw_carry] == CR_PLAYER ? CR_NONE : players[one].powers[pw_carry]); + carry2 = (players[two].powers[pw_carry] == CR_PLAYER ? CR_NONE : players[two].powers[pw_carry]); x = players[one].mo->x; y = players[one].mo->y; z = players[one].mo->z; angle = players[one].mo->angle; + drawangle = players[one].drawangle; starpostx = players[one].starpostx; starposty = players[one].starposty; starpostz = players[one].starpostz; starpostangle = players[one].starpostangle; + starpostscale = players[one].starpostscale; starpostnum = players[one].starpostnum; starposttime = players[one].starposttime; @@ -5467,18 +6629,16 @@ void A_MixUp(mobj_t *actor) P_MixUp(players[one].mo, players[two].mo->x, players[two].mo->y, players[two].mo->z, players[two].mo->angle, players[two].starpostx, players[two].starposty, players[two].starpostz, players[two].starpostnum, players[two].starposttime, players[two].starpostangle, - players[two].mo->flags2); + players[two].starpostscale, players[two].drawangle, players[two].mo->flags2); P_MixUp(players[two].mo, x, y, z, angle, starpostx, starposty, starpostz, starpostnum, starposttime, starpostangle, - mflags2); + starpostscale, drawangle, mflags2); - //flags set after mixup. Stupid P_ResetPlayer() takes away some of the flags we look for... - //but not all of them! So we need to make sure they aren't set wrong or anything. - players[one].pflags &= ~(PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG); - players[one].pflags |= flags2; - players[two].pflags &= ~(PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG); - players[two].pflags |= flags1; + //carry set after mixup. Stupid P_ResetPlayer() takes away some of the stuff we look for... + //but not all of it! So we need to make sure they aren't set wrong or anything. + players[one].powers[pw_carry] = carry2; + players[two].powers[pw_carry] = carry1; teleported[one] = true; teleported[two] = true; @@ -5486,12 +6646,13 @@ void A_MixUp(mobj_t *actor) else { fixed_t position[MAXPLAYERS][3]; - angle_t anglepos[MAXPLAYERS]; + angle_t anglepos[MAXPLAYERS][2]; INT32 pindex[MAXPLAYERS], counter = 0, teleportfrom = 0; // Zoom tube stuff - mobj_t *transtracer[MAXPLAYERS]; //tracer - pflags_t transflag[MAXPLAYERS]; //player pflags + mobj_t *transtracer[MAXPLAYERS]; //tracer + //pflags_t transflag[MAXPLAYERS]; //cyan pink white pink cyan + UINT16 transcarry[MAXPLAYERS]; //player carry INT32 transspeed[MAXPLAYERS]; //player speed // Star post stuff @@ -5499,19 +6660,20 @@ void A_MixUp(mobj_t *actor) INT32 starpostnum[MAXPLAYERS]; tic_t starposttime[MAXPLAYERS]; angle_t starpostangle[MAXPLAYERS]; + fixed_t starpostscale[MAXPLAYERS]; INT32 flags2[MAXPLAYERS]; for (i = 0; i < MAXPLAYERS; i++) { - position[i][0] = position[i][1] = position[i][2] = anglepos[i] = pindex[i] = -1; + position[i][0] = position[i][1] = position[i][2] = anglepos[i][0] = anglepos[i][1] = pindex[i] = -1; teleported[i] = false; } for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && players[i].playerstate == PST_LIVE - && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super]) + && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super] && players[i].powers[pw_carry] != CR_NIGHTSMODE) { if ((netgame || multiplayer) && players[i].spectator)// Ignore spectators continue; @@ -5520,12 +6682,13 @@ void A_MixUp(mobj_t *actor) position[counter][1] = players[i].mo->y; position[counter][2] = players[i].mo->z; pindex[counter] = i; - anglepos[counter] = players[i].mo->angle; + anglepos[counter][0] = players[i].mo->angle; + anglepos[counter][1] = players[i].drawangle; players[i].mo->momx = players[i].mo->momy = players[i].mo->momz = players[i].rmomx = players[i].rmomy = 1; players[i].cmomx = players[i].cmomy = 0; - transflag[counter] = (players[i].pflags & (PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG)); + transcarry[counter] = (players[i].powers[pw_carry] == CR_PLAYER ? CR_NONE : players[i].powers[pw_carry]); transspeed[counter] = players[i].speed; transtracer[counter] = players[i].mo->tracer; @@ -5535,6 +6698,7 @@ void A_MixUp(mobj_t *actor) starpostnum[counter] = players[i].starpostnum; starposttime[counter] = players[i].starposttime; starpostangle[counter] = players[i].starpostangle; + starpostscale[counter] = players[i].starpostscale; flags2[counter] = players[i].mo->flags2; @@ -5561,7 +6725,7 @@ void A_MixUp(mobj_t *actor) for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && players[i].playerstate == PST_LIVE - && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super]) + && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super] && players[i].powers[pw_carry] != CR_NIGHTSMODE) { if ((netgame || multiplayer) && players[i].spectator)// Ignore spectators continue; @@ -5572,14 +6736,15 @@ void A_MixUp(mobj_t *actor) players[i].speed = transspeed[teleportfrom]; P_SetTarget(&players[i].mo->tracer, transtracer[teleportfrom]); - P_MixUp(players[i].mo, position[teleportfrom][0], position[teleportfrom][1], position[teleportfrom][2], anglepos[teleportfrom], + P_MixUp(players[i].mo, position[teleportfrom][0], position[teleportfrom][1], position[teleportfrom][2], anglepos[teleportfrom][0], spposition[teleportfrom][0], spposition[teleportfrom][1], spposition[teleportfrom][2], starpostnum[teleportfrom], starposttime[teleportfrom], starpostangle[teleportfrom], - flags2[teleportfrom]); + starpostscale[teleportfrom], anglepos[teleportfrom][1], flags2[teleportfrom]); - //...flags after. same reasoning. - players[i].pflags &= ~(PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG); - players[i].pflags |= transflag[teleportfrom]; + //...carry after. same reasoning. + players[i].powers[pw_carry] = transcarry[teleportfrom]; + if (transcarry[teleportfrom] == CR_MINECART && transtracer[teleportfrom] && !(P_MobjWasRemoved(transtracer[teleportfrom]))) + P_SetTarget(&transtracer[teleportfrom]->target, players[i].mo); teleported[i] = true; counter++; @@ -5592,7 +6757,7 @@ void A_MixUp(mobj_t *actor) if (teleported[i]) { if (playeringame[i] && players[i].playerstate == PST_LIVE - && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super]) + && players[i].mo && players[i].mo->health > 0 && !players[i].exiting && !players[i].powers[pw_super] && players[i].powers[pw_carry] != CR_NIGHTSMODE) { if ((netgame || multiplayer) && players[i].spectator)// Ignore spectators continue; @@ -5637,18 +6802,14 @@ void A_RecyclePowers(mobj_t *actor) INT32 weapons[MAXPLAYERS]; INT32 weaponheld[MAXPLAYERS]; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RecyclePowers", actor)) return; -#endif - -#if !defined(WEIGHTEDRECYCLER) && !defined(HAVE_BLUA) - // actor is used in all scenarios but this one, funny enough - (void)actor; -#endif if (!multiplayer) + { + S_StartSound(actor, sfx_lose); return; + } numplayers = 0; @@ -5684,7 +6845,10 @@ void A_RecyclePowers(mobj_t *actor) } if (numplayers <= 1) + { + S_StartSound(actor, sfx_lose); return; //nobody to touch! + } //shuffle the post scramble list, whee! // hardcoded 0-1 to 1-0 for two players @@ -5734,7 +6898,7 @@ void A_RecyclePowers(mobj_t *actor) for (j = 0; j < NUMPOWERS; j++) { - if (j == pw_flashing || j == pw_underwater || j == pw_spacetime + if (j == pw_flashing || j == pw_underwater || j == pw_spacetime || j == pw_carry || j == pw_tailsfly || j == pw_extralife || j == pw_nocontrol || j == pw_super) continue; players[recv_pl].powers[j] = powers[send_pl][j]; @@ -5744,6 +6908,9 @@ void A_RecyclePowers(mobj_t *actor) players[recv_pl].ringweapons = weapons[send_pl]; players[recv_pl].currentweapon = weaponheld[send_pl]; + if (((players[recv_pl].powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (players[recv_pl].revitem == MT_LHRT || players[recv_pl].spinitem == MT_LHRT || players[recv_pl].thokitem == MT_LHRT)) // Healers can't keep their buff. + players[recv_pl].powers[pw_shield] &= SH_STACK; + P_SpawnShieldOrb(&players[recv_pl]); if (P_IsLocalPlayer(&players[recv_pl])) P_RestoreMusic(&players[recv_pl]); @@ -5763,10 +6930,9 @@ void A_RecyclePowers(mobj_t *actor) void A_Boss1Chase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss1Chase", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -5818,7 +6984,10 @@ void A_Boss1Chase(mobj_t *actor) } else { - P_LinedefExecute(LE_PINCHPHASE, actor, NULL); + if (actor->spawnpoint && actor->spawnpoint->extrainfo) + P_LinedefExecute(LE_PINCHPHASE+(actor->spawnpoint->extrainfo*LE_PARAMWIDTH), actor, NULL); + else + P_LinedefExecute(LE_PINCHPHASE, actor, NULL); P_SetMobjState(actor, actor->info->raisestate); } @@ -5884,10 +7053,9 @@ void A_Boss2Chase(mobj_t *actor) fixed_t radius; boolean reverse = false; INT32 speedvar; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2Chase", actor)) return; -#endif if (actor->health <= 0) return; @@ -5918,7 +7086,7 @@ void A_Boss2Chase(mobj_t *actor) { actor->watertop = -actor->watertop; actor->extravalue1 = 18; - if (actor->flags & MF_AMBUSH) + if (actor->flags2 & MF2_AMBUSH) actor->extravalue1 -= (actor->info->spawnhealth - actor->health)*2; actor->extravalue2 = actor->extravalue1; } @@ -5944,7 +7112,7 @@ void A_Boss2Chase(mobj_t *actor) else { // Only speed up if you have the 'Deaf' flag. - if (actor->flags & MF_AMBUSH) + if (actor->flags2 & MF2_AMBUSH) speedvar = actor->health; else speedvar = actor->info->spawnhealth; @@ -6012,10 +7180,9 @@ void A_Boss2Chase(mobj_t *actor) // void A_Boss2Pogo(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss2Pogo", actor)) return; -#endif + if (actor->z <= actor->floorz + FixedMul(8*FRACUNIT, actor->scale) && actor->momz <= 0) { if (actor->state != &states[actor->info->raisestate]) @@ -6060,10 +7227,10 @@ void A_Boss2Pogo(mobj_t *actor) void A_Boss2TakeDamage(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2TakeDamage", actor)) return; -#endif + A_Pain(actor); actor->reactiontime = 1; // turn around if (locvar1 == 0) // old A_Invincibilerize behavior @@ -6083,10 +7250,9 @@ void A_Boss7Chase(mobj_t *actor) { INT32 delta; INT32 i; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss7Chase", actor)) return; -#endif if (actor->z != actor->floorz) return; @@ -6146,7 +7312,7 @@ void A_Boss7Chase(mobj_t *actor) if (actor->health <= actor->info->damage && actor->target && actor->target->player - && (actor->target->player->pflags & PF_ITEMHANG)) + && (actor->target->player->powers[pw_carry] == CR_GENERIC)) { A_FaceTarget(actor); P_SetMobjState(actor, S_BLACKEGG_SHOOT1); @@ -6215,10 +7381,9 @@ void A_Boss7Chase(mobj_t *actor) // void A_GoopSplat(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_GoopSplat", actor)) return; -#endif + P_UnsetThingPosition(actor); if (sector_list) { @@ -6240,10 +7405,9 @@ void A_Boss2PogoSFX(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Boss2PogoSFX", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -6284,10 +7448,8 @@ void A_Boss2PogoTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss2PogoTarget", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE) || (actor->target->player && actor->target->player->powers[pw_flashing]) || P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) >= FixedMul(512*FRACUNIT, actor->scale)) @@ -6356,7 +7518,7 @@ void A_Boss2PogoTarget(mobj_t *actor) if (actor->info->missilestate) // spawn the pogo stick collision box { mobj_t *pogo = P_SpawnMobj(actor->x, actor->y, actor->z - mobjinfo[actor->info->missilestate].height, (mobjtype_t)actor->info->missilestate); - pogo->target = actor; + P_SetTarget(&pogo->target, actor); } actor->reactiontime = 1; @@ -6371,17 +7533,16 @@ void A_Boss2PogoTarget(mobj_t *actor) // void A_EggmanBox(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_EggmanBox", actor)) return; -#endif + if (!actor->target || !actor->target->player) { CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); return; } - P_DamageMobj(actor->target, actor, actor, 1); // Ow! + P_DamageMobj(actor->target, actor, actor, 1, 0); // Ow! } // Function: A_TurretFire @@ -6397,10 +7558,9 @@ void A_TurretFire(mobj_t *actor) fixed_t dist; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TurretFire", actor)) return; -#endif if (locvar2) dist = FixedMul(locvar2*FRACUNIT, actor->scale); @@ -6436,10 +7596,9 @@ void A_SuperTurretFire(mobj_t *actor) fixed_t dist; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SuperTurretFire", actor)) return; -#endif if (locvar2) dist = FixedMul(locvar2*FRACUNIT, actor->scale); @@ -6473,10 +7632,9 @@ void A_SuperTurretFire(mobj_t *actor) void A_TurretStop(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TurretStop", actor)) return; -#endif actor->flags2 &= ~MF2_FIRING; actor->flags2 &= ~MF2_SUPERFIRE; @@ -6494,10 +7652,8 @@ void A_TurretStop(mobj_t *actor) // void A_SparkFollow(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SparkFollow", actor)) return; -#endif if ((!actor->target || (actor->target->health <= 0)) || (actor->target->player && !actor->target->player->powers[pw_super])) @@ -6531,11 +7687,11 @@ void A_BuzzFly(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BuzzFly", actor)) return; -#endif - if (actor->flags & MF_AMBUSH) + + if (actor->flags2 & MF2_AMBUSH) return; if (actor->reactiontime) @@ -6630,55 +7786,84 @@ void A_BuzzFly(mobj_t *actor) void A_GuardChase(mobj_t *actor) { INT32 delta; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_GuardChase", actor)) return; -#endif if (actor->reactiontime) actor->reactiontime--; - if ((!actor->tracer || !actor->tracer->health) && actor->threshold != 42) + if (actor->threshold != 42) // In formation... { - P_SetTarget(&actor->tracer, NULL); - actor->threshold = 42; - P_SetMobjState(actor, actor->info->painstate); - actor->flags |= MF_SPECIAL|MF_SHOOTABLE; - return; + fixed_t speed; + + if (!actor->tracer || !actor->tracer->health) + { + P_SetTarget(&actor->tracer, NULL); + actor->threshold = 42; + P_SetMobjState(actor, actor->info->painstate); + actor->flags |= MF_SPECIAL|MF_SHOOTABLE; + return; + } + + speed = actor->extravalue1*actor->scale; + + if (actor->flags2 & MF2_AMBUSH) + speed <<= 1; + + if (speed + && !P_TryMove(actor, + actor->x + P_ReturnThrustX(actor, actor->angle, speed), + actor->y + P_ReturnThrustY(actor, actor->angle, speed), + false) + && speed > 0) // can't be the same check as previous so that P_TryMove gets to happen. + { + if (actor->spawnpoint && ((actor->spawnpoint->options & (MTF_EXTRA|MTF_OBJECTSPECIAL)) == MTF_OBJECTSPECIAL)) + actor->angle += ANGLE_90; + else if (actor->spawnpoint && ((actor->spawnpoint->options & (MTF_EXTRA|MTF_OBJECTSPECIAL)) == MTF_EXTRA)) + actor->angle -= ANGLE_90; + else + actor->angle += ANGLE_180; + } + + if (actor->extravalue1 < actor->info->speed) + actor->extravalue1++; } - - // turn towards movement direction if not there yet - if (actor->movedir < NUMDIRS) + else // Break ranks! { - actor->angle &= (7<<29); - delta = actor->angle - (actor->movedir << 29); + // turn towards movement direction if not there yet + if (actor->movedir < NUMDIRS) + { + actor->angle &= (7<<29); + delta = actor->angle - (actor->movedir << 29); - if (delta > 0) - actor->angle -= ANGLE_45; - else if (delta < 0) - actor->angle += ANGLE_45; - } + if (delta > 0) + actor->angle -= ANGLE_45; + else if (delta < 0) + actor->angle += ANGLE_45; + } - if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) - { - // look for a new target - if (P_LookForPlayers(actor, true, false, 0)) + if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) + { + // look for a new target + if (P_LookForPlayers(actor, true, false, 0)) + return; // got a new target + + P_SetMobjStateNF(actor, actor->info->spawnstate); + return; + } + + // possibly choose another target + if (multiplayer && (actor->target->health <= 0 || !P_CheckSight(actor, actor->target)) + && P_LookForPlayers(actor, true, false, 0)) return; // got a new target - P_SetMobjStateNF(actor, actor->info->spawnstate); - return; - } - - // possibly choose another target - if (multiplayer && (actor->target->health <= 0 || !P_CheckSight(actor, actor->target)) - && P_LookForPlayers(actor, true, false, 0)) - return; // got a new target - - // chase towards player - if (--actor->movecount < 0 || !P_Move(actor, (actor->flags & MF_AMBUSH) ? actor->info->speed * 2 : actor->info->speed)) - { - P_NewChaseDir(actor); - actor->movecount += 5; // Increase tics before change in direction allowed. + // chase towards player + if (--actor->movecount < 0 || !P_Move(actor, (actor->flags2 & MF2_AMBUSH) ? actor->info->speed * 2 : actor->info->speed)) + { + P_NewChaseDir(actor); + actor->movecount += 5; // Increase tics before change in direction allowed. + } } // Now that we've moved, its time for our shield to move! @@ -6706,10 +7891,9 @@ void A_EggShield(mobj_t *actor) fixed_t newx, newy; fixed_t movex, movey; angle_t angle; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_EggShield", actor)) return; -#endif if (!actor->target || !actor->target->health) { @@ -6790,10 +7974,9 @@ void A_EggShield(mobj_t *actor) // void A_SetReactionTime(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetReactionTime", actor)) return; -#endif + if (var1) actor->reactiontime = var2; else @@ -6813,10 +7996,8 @@ void A_Boss1Spikeballs(mobj_t *actor) INT32 locvar2 = var2; mobj_t *ball; -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss1Spikeballs", actor)) return; -#endif ball = P_SpawnMobj(actor->x, actor->y, actor->z, MT_EGGMOBILE_BALL); P_SetTarget(&ball->target, actor); @@ -6837,14 +8018,15 @@ void A_Boss1Spikeballs(mobj_t *actor) // void A_Boss3TakeDamage(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss3TakeDamage", actor)) return; -#endif - actor->movecount = var1; - if (actor->target && actor->target->spawnpoint) - actor->threshold = actor->target->spawnpoint->extrainfo; + actor->movecount = var1; + actor->movefactor = -512*FRACUNIT; + + /*if (actor->target && actor->target->spawnpoint) + actor->threshold = actor->target->spawnpoint->extrainfo;*/ + } // Function: A_Boss3Path @@ -6856,10 +8038,8 @@ void A_Boss3TakeDamage(mobj_t *actor) // void A_Boss3Path(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_Boss3Path", actor)) return; -#endif if (actor->tracer && actor->tracer->health && actor->tracer->movecount) actor->movecount |= 1; @@ -6881,24 +8061,34 @@ void A_Boss3Path(mobj_t *actor) } else if (actor->threshold >= 0) // Traveling mode { - thinker_t *th; - mobj_t *mo2; - fixed_t dist, dist2; + fixed_t dist = 0; fixed_t speed; - P_SetTarget(&actor->target, NULL); - - // scan the thinkers - // to find a point that matches - // the number - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!(actor->flags2 & MF2_STRONGBOX)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; + thinker_t *th; + mobj_t *mo2; - mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == actor->threshold) + P_SetTarget(&actor->target, NULL); + + // scan the thinkers + // to find a point that matches + // the number + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + if (!mo2->spawnpoint) + continue; + if (mo2->spawnpoint->angle != actor->threshold) + continue; + if (mo2->spawnpoint->extrainfo != actor->cusval) + continue; + P_SetTarget(&actor->target, mo2); break; } @@ -6906,67 +8096,111 @@ void A_Boss3Path(mobj_t *actor) if (!actor->target) // Should NEVER happen { - CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 Dummy was unable to find specified waypoint: %d\n", actor->threshold); + CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 Dummy was unable to find specified waypoint: %d, %d\n", actor->threshold, actor->cusval); return; } - dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z - actor->z); - - if (dist < 1) - dist = 1; - if (actor->tracer && ((actor->tracer->movedir) || (actor->tracer->health <= actor->tracer->info->damage))) speed = actor->info->speed * 2; else speed = actor->info->speed; - actor->momx = FixedMul(FixedDiv(actor->target->x - actor->x, dist), speed); - actor->momy = FixedMul(FixedDiv(actor->target->y - actor->y, dist), speed); - actor->momz = FixedMul(FixedDiv(actor->target->z - actor->z, dist), speed); + if (actor->target->x == actor->x && actor->target->y == actor->y) + { + dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z); - if (actor->momx != 0 || actor->momy != 0) - actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy); + if (dist < 1) + dist = 1; - dist2 = P_AproxDistance(P_AproxDistance(actor->target->x - (actor->x + actor->momx), actor->target->y - (actor->y + actor->momy)), actor->target->z - (actor->z + actor->momz)); + actor->momx = FixedMul(FixedDiv(actor->target->x - actor->x, dist), speed); + actor->momy = FixedMul(FixedDiv(actor->target->y - actor->y, dist), speed); + actor->momz = FixedMul(FixedDiv(actor->target->z + actor->movefactor - actor->z, dist), speed); - if (dist2 < 1) - dist2 = 1; + if (actor->momx != 0 || actor->momy != 0) + actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy); + } - if ((dist >> FRACBITS) <= (dist2 >> FRACBITS)) + if (dist <= speed) { // If further away, set XYZ of mobj to waypoint location P_UnsetThingPosition(actor); actor->x = actor->target->x; actor->y = actor->target->y; - actor->z = actor->target->z; + actor->z = actor->target->z + actor->movefactor; actor->momx = actor->momy = actor->momz = 0; P_SetThingPosition(actor); - if (actor->threshold == 0) + if (!actor->movefactor) // firing mode + { + actor->movecount |= 2; + actor->movefactor = -512*FRACUNIT; + actor->flags2 &= ~MF2_STRONGBOX; + } + else if (!(actor->flags2 & MF2_STRONGBOX)) // just spawned or going down + { + actor->flags2 |= MF2_STRONGBOX; + actor->movefactor = -512*FRACUNIT; + } + else if (!(actor->flags2 & MF2_AMBUSH)) // just shifted tube + { + actor->flags2 |= MF2_AMBUSH; + actor->movefactor = 0; + } + else // just hit the bottom of your tube { P_RemoveMobj(actor); // Cycle completed. Dummy removed. return; } + } + } +} - // Set to next waypoint in sequence - if (actor->target->spawnpoint) - { - // From the center point, choose one of the five paths - if (actor->target->spawnpoint->angle == 0) - { - P_RemoveMobj(actor); // Cycle completed. Dummy removed. - return; - } - else - actor->threshold = actor->target->spawnpoint->extrainfo; +// Function: A_Boss3ShockThink +// +// Description: Inserts new interstitial shockwave objects when the space between others spreads too much. +// +// var1 = unused +// var2 = unused +// +void A_Boss3ShockThink(mobj_t *actor) +{ + if (LUA_CallAction("A_Boss3ShockThink", actor)) + return; - // If the deaf flag is set, go into firing mode - if (actor->target->spawnpoint->options & MTF_AMBUSH) - actor->movecount |= 2; - } - else // This should never happen, as well - CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 Dummy waypoint has no spawnpoint associated with it.\n"); + if (actor->momx || actor->momy) + actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy) + ANGLE_90; + + if (actor->hnext && !P_MobjWasRemoved(actor->hnext)) + { + mobj_t *snext = actor->hnext; + mobj_t *snew; + fixed_t x0, y0, x1, y1; + + // Break the link if movements are too different + if (FixedHypot(snext->momx - actor->momx, snext->momy - actor->momy) > 12*actor->scale) + { + P_SetTarget(&actor->hnext, NULL); + return; + } + + // Check distance between shockwave objects to determine whether interstitial ones should be spawned + x0 = actor->x; + y0 = actor->y; + x1 = snext->x; + y1 = snext->y; + if (FixedHypot(x1 - x0, y1 - y0) > 2*actor->radius) + { + snew = P_SpawnMobj((x0 + x1) >> 1, (y0 + y1) >> 1, (actor->z + snext->z) >> 1, actor->type); + snew->momx = (actor->momx + snext->momx) >> 1; + snew->momy = (actor->momy + snext->momy) >> 1; + snew->momz = (actor->momz + snext->momz) >> 1; // is this really needed? + snew->angle = (actor->angle + snext->angle) >> 1; + P_SetTarget(&snew->target, actor->target); + snew->fuse = actor->fuse; + + P_SetTarget(&actor->hnext, snew); + P_SetTarget(&snew->hnext, snext); } } } @@ -6983,16 +8217,17 @@ void A_LinedefExecute(mobj_t *actor) INT32 tagnum; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_LinedefExecute", actor)) return; -#endif tagnum = locvar1; // state numbers option is no more, custom states cannot be guaranteed to stay the same number anymore, now that they can be defined by names instead if (locvar2) tagnum += locvar2*(AngleFixed(actor->angle)>>FRACBITS); + else if (actor->spawnpoint && actor->spawnpoint->extrainfo) + tagnum += (actor->spawnpoint->extrainfo*LE_PARAMWIDTH); CONS_Debug(DBG_GAMELOGIC, "A_LinedefExecute: Running mobjtype %d's sector with tag %d\n", actor->type, tagnum); @@ -7009,10 +8244,9 @@ void A_LinedefExecute(mobj_t *actor) // void A_PlaySeeSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlaySeeSound", actor)) return; -#endif + if (actor->info->seesound) S_StartScreamSound(actor, actor->info->seesound); } @@ -7026,10 +8260,9 @@ void A_PlaySeeSound(mobj_t *actor) // void A_PlayAttackSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlayAttackSound", actor)) return; -#endif + if (actor->info->attacksound) S_StartAttackSound(actor, actor->info->attacksound); } @@ -7043,10 +8276,9 @@ void A_PlayAttackSound(mobj_t *actor) // void A_PlayActiveSound(mobj_t *actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_PlayActiveSound", actor)) return; -#endif + if (actor->info->activesound) S_StartSound(actor, actor->info->activesound); } @@ -7062,10 +8294,9 @@ void A_SmokeTrailer(mobj_t *actor) { mobj_t *th; INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SmokeTrailer", actor)) return; -#endif if (leveltime % 4) return; @@ -7104,10 +8335,9 @@ void A_SpawnObjectAbsolute(mobj_t *actor) mobj_t *mo; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpawnObjectAbsolute", actor)) return; -#endif x = (INT16)(locvar1>>16); y = (INT16)(locvar1&65535); @@ -7141,10 +8371,9 @@ void A_SpawnObjectRelative(mobj_t *actor) mobj_t *mo; INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpawnObjectRelative", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_SpawnObjectRelative called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); @@ -7164,6 +8393,7 @@ void A_SpawnObjectRelative(mobj_t *actor) if (actor->eflags & MFE_VERTICALFLIP) mo->flags2 |= MF2_OBJECTFLIP; + } // Function: A_ChangeAngleRelative @@ -7185,14 +8415,13 @@ void A_ChangeAngleRelative(mobj_t *actor) const fixed_t amax = locvar2*FRACUNIT; //const angle_t amin = FixedAngle(locvar1*FRACUNIT); //const angle_t amax = FixedAngle(locvar2*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeAngleRelative", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) - I_Error("A_ChangeAngleRelative: var1 is greater then var2"); + I_Error("A_ChangeAngleRelative: var1 is greater than var2"); #endif /* if (angle < amin) @@ -7219,14 +8448,13 @@ void A_ChangeAngleAbsolute(mobj_t *actor) const fixed_t amax = locvar2*FRACUNIT; //const angle_t amin = FixedAngle(locvar1*FRACUNIT); //const angle_t amax = FixedAngle(locvar2*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeAngleAbsolute", actor)) return; -#endif #ifdef PARANOIA if (amin > amax) - I_Error("A_ChangeAngleAbsolute: var1 is greater then var2"); + I_Error("A_ChangeAngleAbsolute: var1 is greater than var2"); #endif /* if (angle < amin) @@ -7237,25 +8465,101 @@ void A_ChangeAngleAbsolute(mobj_t *actor) actor->angle = FixedAngle(P_RandomRange(amin, amax)); } +// Function: A_RollAngle +// +// Description: Changes the roll angle. +// +// var1 = angle +// var2 = relative? (default) +// +void A_RollAngle(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + const angle_t angle = FixedAngle(locvar1*FRACUNIT); + + if (LUA_CallAction("A_RollAngle", actor)) + return; + + // relative (default) + if (!locvar2) + actor->rollangle += angle; + // absolute + else + actor->rollangle = angle; +} + +// Function: A_ChangeRollAngleRelative +// +// Description: Changes the roll angle to a random relative value between the min and max. Set min and max to the same value to eliminate randomness +// +// var1 = min +// var2 = max +// +void A_ChangeRollAngleRelative(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + const fixed_t amin = locvar1*FRACUNIT; + const fixed_t amax = locvar2*FRACUNIT; + + if (LUA_CallAction("A_ChangeRollAngleRelative", actor)) + return; + +#ifdef PARANOIA + if (amin > amax) + I_Error("A_ChangeRollAngleRelative: var1 is greater than var2"); +#endif + + actor->rollangle += FixedAngle(P_RandomRange(amin, amax)); +} + +// Function: A_ChangeRollAngleAbsolute +// +// Description: Changes the roll angle to a random absolute value between the min and max. Set min and max to the same value to eliminate randomness +// +// var1 = min +// var2 = max +// +void A_ChangeRollAngleAbsolute(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + const fixed_t amin = locvar1*FRACUNIT; + const fixed_t amax = locvar2*FRACUNIT; + + if (LUA_CallAction("A_ChangeRollAngleAbsolute", actor)) + return; + +#ifdef PARANOIA + if (amin > amax) + I_Error("A_ChangeRollAngleAbsolute: var1 is greater than var2"); +#endif + + actor->rollangle = FixedAngle(P_RandomRange(amin, amax)); +} + // Function: A_PlaySound // // Description: Plays a sound // // var1 = sound # to play // var2: -// 0 = Play sound without an origin -// 1 = Play sound using calling object as origin +// lower 16 bits = If 1, play sound using calling object as origin. If 0, play sound without an origin +// upper 16 bits = If 1, do not play sound during preticker. // void A_PlaySound(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_PlaySound", actor)) return; -#endif - S_StartSound(locvar2 ? actor : NULL, locvar1); + if (leveltime < 2 && (locvar2 >> 16)) + return; + + S_StartSound((locvar2 & 65535) ? actor : NULL, locvar1); } // Function: A_FindTarget @@ -7273,17 +8577,16 @@ void A_FindTarget(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FindTarget", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_FindTarget called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); // scan the thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7338,17 +8641,16 @@ void A_FindTracer(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist1 = 0, dist2 = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_FindTracer", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_FindTracer called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); // scan the thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7399,10 +8701,9 @@ void A_SetTics(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetTics", actor)) return; -#endif if (locvar1) actor->tics = locvar1; @@ -7421,10 +8722,9 @@ void A_SetRandomTics(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetRandomTics", actor)) return; -#endif actor->tics = P_RandomRange(locvar1, locvar2); } @@ -7440,10 +8740,9 @@ void A_ChangeColorRelative(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeColorRelative", actor)) return; -#endif if (locvar1) { @@ -7466,10 +8765,9 @@ void A_ChangeColorAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ChangeColorAbsolute", actor)) return; -#endif if (locvar1) { @@ -7491,10 +8789,9 @@ void A_MoveRelative(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MoveRelative", actor)) return; -#endif P_Thrust(actor, actor->angle+FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -7510,10 +8807,9 @@ void A_MoveAbsolute(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MoveAbsolute", actor)) return; -#endif P_InstaThrust(actor, FixedAngle(locvar1*FRACUNIT), FixedMul(locvar2*FRACUNIT, actor->scale)); } @@ -7529,10 +8825,9 @@ void A_Thrust(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Thrust", actor)) return; -#endif if (!locvar1) CONS_Debug(DBG_GAMELOGIC, "A_Thrust: Var1 not specified!\n"); @@ -7556,10 +8851,9 @@ void A_ZThrust(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ZThrust", actor)) return; -#endif if (!locvar1) CONS_Debug(DBG_GAMELOGIC, "A_ZThrust: Var1 not specified!\n"); @@ -7591,10 +8885,9 @@ void A_SetTargetsTarget(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *oldtarg = NULL, *newtarg = NULL; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetTargetsTarget", actor)) return; -#endif // actor's target if (locvar1) // or tracer @@ -7636,10 +8929,9 @@ void A_SetObjectFlags(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; boolean unlinkthings = false; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectFlags", actor)) return; -#endif if (locvar2 == 2) locvar1 = actor->flags | locvar1; @@ -7678,10 +8970,9 @@ void A_SetObjectFlags2(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectFlags2", actor)) return; -#endif if (locvar2 == 2) actor->flags2 |= locvar1; @@ -7697,7 +8988,7 @@ void A_SetObjectFlags2(mobj_t *actor) // // var1: // 0 - Triple jet fume pattern -// 1 - Boss 3's propeller +// 1 - Unused (formerly Boss 3's propeller) // 2 - Metal Sonic jet fume // 3 - Boss 4 jet flame // var2 = unused @@ -7706,10 +8997,9 @@ void A_BossJetFume(mobj_t *actor) { mobj_t *filler; INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_BossJetFume", actor)) return; -#endif if (locvar1 == 0) // Boss1 jet fumes { @@ -7757,12 +9047,12 @@ void A_BossJetFume(mobj_t *actor) P_SetTarget(&actor->tracer, filler); } - else if (locvar1 == 1) // Boss 3 propeller + /*else if (locvar1 == 1) // Boss 3 propeller { fixed_t jetx, jety, jetz; - jetx = actor->x + P_ReturnThrustX(actor, actor->angle, -FixedMul(60*FRACUNIT, actor->scale)); - jety = actor->y + P_ReturnThrustY(actor, actor->angle, -FixedMul(60*FRACUNIT, actor->scale)); + jetx = actor->x + P_ReturnThrustX(actor, actor->angle, -60*actor->scale); + jety = actor->y + P_ReturnThrustY(actor, actor->angle, -60*actor->scale); if (actor->eflags & MFE_VERTICALFLIP) jetz = actor->z + actor->height - FixedMul(17*FRACUNIT + mobjinfo[MT_PROPELLER].height, actor->scale); else @@ -7777,17 +9067,18 @@ void A_BossJetFume(mobj_t *actor) filler->angle = actor->angle - ANGLE_180; P_SetTarget(&actor->tracer, filler); - } + }*/ else if (locvar1 == 2) // Metal Sonic jet fumes { filler = P_SpawnMobj(actor->x, actor->y, actor->z, MT_JETFUME1); P_SetTarget(&filler->target, actor); filler->fuse = 59; P_SetTarget(&actor->tracer, filler); - filler->destscale = actor->scale/2; - P_SetScale(filler, filler->destscale); + P_SetScale(filler, (filler->destscale = actor->scale/3)); if (actor->eflags & MFE_VERTICALFLIP) filler->flags2 |= MF2_OBJECTFLIP; + filler->color = SKINCOLOR_ICY; + filler->colorized = true; } else if (locvar1 == 3) // Boss 4 jet flame { @@ -7795,7 +9086,7 @@ void A_BossJetFume(mobj_t *actor) if (actor->eflags & MFE_VERTICALFLIP) jetz = actor->z + actor->height + FixedMul(50*FRACUNIT - mobjinfo[MT_JETFLAME].height, actor->scale); else - jetz = actor->z - FixedMul(50*FRACUNIT, actor->scale); + jetz = actor->z - 50*actor->scale; filler = P_SpawnMobj(actor->x, actor->y, jetz, MT_JETFLAME); P_SetTarget(&filler->target, actor); // Boss 4 already uses its tracer for other things @@ -7804,6 +9095,30 @@ void A_BossJetFume(mobj_t *actor) if (actor->eflags & MFE_VERTICALFLIP) filler->flags2 |= MF2_OBJECTFLIP; } + else if (locvar1 == 4) // Boss 4 Spectator Eggrobo jet flame + { + fixed_t jetx, jety, jetz, movefactor = 12; + + jetz = actor->z; + if (actor->eflags & MFE_VERTICALFLIP) + jetz += (actor->height - FixedMul(mobjinfo[MT_EGGROBO1JET].height, actor->scale)); + + while (true) + { + jetx = actor->x + P_ReturnThrustX(actor, actor->angle+ANGLE_90, movefactor*actor->scale) - P_ReturnThrustX(actor, actor->angle, 19*actor->scale); + jety = actor->y + P_ReturnThrustY(actor, actor->angle+ANGLE_90, movefactor*actor->scale) - P_ReturnThrustY(actor, actor->angle, 19*actor->scale); + filler = P_SpawnMobj(jetx, jety, jetz, MT_EGGROBO1JET); + filler->movefactor = movefactor; + P_SetTarget(&filler->target, actor); + filler->destscale = actor->scale; + P_SetScale(filler, filler->destscale); + if (actor->eflags & MFE_VERTICALFLIP) + filler->flags2 |= MF2_OBJECTFLIP; + if (movefactor <= 0) + break; + movefactor = -movefactor; + } + } } // Function: A_RandomState @@ -7817,10 +9132,9 @@ void A_RandomState(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RandomState", actor)) return; -#endif P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2); } @@ -7837,10 +9151,8 @@ void A_RandomStateRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_RandomStateRange", actor)) return; -#endif P_SetMobjState(actor, P_RandomRange(locvar1, locvar2)); } @@ -7856,27 +9168,22 @@ void A_DualAction(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_DualAction", actor)) return; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); var1 = states[locvar1].var1; var2 = states[locvar1].var2; -#ifdef HAVE_BLUA astate = &states[locvar1]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction: Calling First Action (state %d)...\n", locvar1); states[locvar1].action.acp1(actor); var1 = states[locvar2].var1; var2 = states[locvar2].var2; -#ifdef HAVE_BLUA astate = &states[locvar2]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_DualAction: Calling Second Action (state %d)...\n", locvar2); states[locvar2].action.acp1(actor); @@ -7894,10 +9201,9 @@ void A_RemoteAction(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *originaltarget = actor->target; // Hold on to the target for later. -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RemoteAction", actor)) return; -#endif // If >=0, find the closest target. if (locvar1 >= 0) @@ -7909,9 +9215,9 @@ void A_RemoteAction(mobj_t *actor) fixed_t dist1 = 0, dist2 = 0; // scan the thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7959,9 +9265,7 @@ void A_RemoteAction(mobj_t *actor) // Steal the var1 and var2 from "locvar2" var1 = states[locvar2].var1; var2 = states[locvar2].var2; -#ifdef HAVE_BLUA astate = &states[locvar2]; -#endif CONS_Debug(DBG_GAMELOGIC, "A_RemoteAction: Calling action on %p\n" "var1 is %d\nvar2 is %d\n", actor->target, var1, var2); @@ -7980,10 +9284,9 @@ void A_RemoteAction(mobj_t *actor) // void A_ToggleFlameJet(mobj_t* actor) { -#ifdef HAVE_BLUA if (LUA_CallAction("A_ToggleFlameJet", actor)) return; -#endif + // threshold - off delay // movecount - on timer @@ -8008,21 +9311,48 @@ void A_ToggleFlameJet(mobj_t* actor) // Description: Used by Chaos Emeralds to orbit around Nights (aka Super Sonic.) // // var1 = Angle adjustment (aka orbit speed) -// var2 = Lower four bits: height offset, Upper 4 bits = set if object is Nightopian Helper +// var2: +// Bits 1-10: height offset, max 1023 +// Bits 11-16: X radius factor (max 63, default 20) +// Bit 17: set if object is Nightopian Helper +// Bit 18: set to define X/Y/Z rotation factor +// Bits 19-20: Unused +// Bits 21-26: Y radius factor (max 63, default 32) +// Bits 27-32: Z radius factor (max 63, default 32) // +// If MF_GRENADEBOUNCE is flagged on mobj, use actor->threshold to define X/Y/Z radius factor, max 1023 each: +// Bits 1-10: X factor +// Bits 11-20: Y factor +// Bits 21-30: Z factor void A_OrbitNights(mobj_t* actor) { - INT32 ofs = (var2 & 0xFFFF); - boolean ishelper = (var2 & 0xFFFF0000); -#ifdef HAVE_BLUA + INT32 ofs = (var2 & 0x3FF); + boolean ishelper = (var2 & 0x10000); + boolean donotrescale = (var2 & 0x40000); + INT32 xfactor = 32, yfactor = 32, zfactor = 20; + if (LUA_CallAction("A_OrbitNights", actor)) return; -#endif - if (!actor->target || !actor->target->player || - !actor->target->tracer || !actor->target->player->nightstime + if (actor->flags & MF_GRENADEBOUNCE) + { + xfactor = (actor->threshold & 0x3FF); + yfactor = (actor->threshold & 0xFFC00) >> 10; + zfactor = (actor->threshold & 0x3FF00000) >> 20; + } + else if (var2 & 0x20000) + { + xfactor = (var2 & 0xFC00) >> 10; + yfactor = (var2 & 0x3F00000) >> 20; + zfactor = (var2 & 0xFC000000) >> 26; + } + + if (!actor->target + || (actor->target->player && + // if NiGHTS special stage and not NiGHTSmode. + (((maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap) && !(actor->target->player->powers[pw_carry] == CR_NIGHTSMODE)) // Also remove this object if they no longer have a NiGHTS helper - || (ishelper && !actor->target->player->powers[pw_nights_helper])) + || (ishelper && !actor->target->player->powers[pw_nights_helper])))) { P_RemoveMobj(actor); return; @@ -8035,18 +9365,30 @@ void A_OrbitNights(mobj_t* actor) const angle_t fa = (angle_t)actor->extravalue1 >> ANGLETOFINESHIFT; const angle_t ofa = ((angle_t)actor->extravalue1 + (ofs*ANG1)) >> ANGLETOFINESHIFT; - const fixed_t fc = FixedMul(FINECOSINE(fa),FixedMul(32*FRACUNIT, actor->scale)); - const fixed_t fh = FixedMul(FINECOSINE(ofa),FixedMul(20*FRACUNIT, actor->scale)); - const fixed_t fs = FixedMul(FINESINE(fa),FixedMul(32*FRACUNIT, actor->scale)); + const fixed_t fc = FixedMul(FINECOSINE(fa),FixedMul(xfactor*FRACUNIT, actor->scale)); + const fixed_t fh = FixedMul(FINECOSINE(ofa),FixedMul(zfactor*FRACUNIT, actor->scale)); + const fixed_t fs = FixedMul(FINESINE(fa),FixedMul(yfactor*FRACUNIT, actor->scale)); - actor->x = actor->target->tracer->x + fc; - actor->y = actor->target->tracer->y + fs; - actor->z = actor->target->tracer->z + fh + FixedMul(16*FRACUNIT, actor->scale); + actor->x = actor->target->x + fc; + actor->y = actor->target->y + fs; + actor->z = actor->target->z + fh + FixedMul(16*FRACUNIT, actor->scale); // Semi-lazy hack actor->angle = (angle_t)actor->extravalue1 + ANGLE_90; } P_SetThingPosition(actor); + + if (ishelper && actor->target->player) // Flash a helper that's about to be removed. + { + if ((actor->target->player->powers[pw_nights_helper] < TICRATE) + && (actor->target->player->powers[pw_nights_helper] & 1)) + actor->flags2 |= MF2_DONTDRAW; + else + actor->flags2 &= ~MF2_DONTDRAW; + } + + if (!donotrescale && actor->destscale != actor->target->destscale) + actor->destscale = actor->target->destscale; } } @@ -8054,16 +9396,20 @@ void A_OrbitNights(mobj_t* actor) // // Description: Spawns a "ghost" mobj of this actor, ala spindash trails and the minus's digging "trails" // -// var1 = unused +// var1 = duration in tics // var2 = unused // void A_GhostMe(mobj_t *actor) { -#ifdef HAVE_BLUA + INT32 locvar1 = var1; + mobj_t *ghost; + if (LUA_CallAction("A_GhostMe", actor)) return; -#endif - P_SpawnGhostMobj(actor); + + ghost = P_SpawnGhostMobj(actor); + if (ghost && locvar1 > 0) + ghost->fuse = locvar1; } // Function: A_SetObjectState @@ -8080,10 +9426,9 @@ void A_SetObjectState(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetObjectState", actor)) return; -#endif if ((!locvar2 && !actor->target) || (locvar2 && !actor->tracer)) { @@ -8126,14 +9471,12 @@ void A_SetObjectTypeState(mobj_t *actor) mobj_t *mo2; fixed_t dist = 0; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SetObjectTypeState", actor)) return; -#endif - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -8169,10 +9512,9 @@ void A_KnockBack(mobj_t *actor) { INT32 locvar1 = var1; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_KnockBack", actor)) return; -#endif if (!locvar1) target = actor->target; @@ -8205,10 +9547,9 @@ void A_PushAway(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; // target angle_t an; // actor to target angle -#ifdef HAVE_BLUA + if (LUA_CallAction("A_PushAway", actor)) return; -#endif if ((!(locvar2 >> 16) && !actor->target) || ((locvar2 >> 16) && !actor->tracer)) return; @@ -8240,10 +9581,9 @@ void A_RingDrain(mobj_t *actor) { INT32 locvar1 = var1; player_t *player; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RingDrain", actor)) return; -#endif if (!actor->target || !actor->target->player) { @@ -8253,7 +9593,7 @@ void A_RingDrain(mobj_t *actor) } player = actor->target->player; - P_GivePlayerRings(player, -min(locvar1, player->mo->health-1)); + P_GivePlayerRings(player, -min(locvar1, player->rings)); } // Function: A_SplitShot @@ -8273,10 +9613,9 @@ void A_SplitShot(mobj_t *actor) const UINT16 loc2up = (UINT16)(locvar2 >> 16); const fixed_t offs = (fixed_t)(locvar1*FRACUNIT); const fixed_t hoffs = (fixed_t)(loc2up*FRACUNIT); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SplitShot", actor)) return; -#endif A_FaceTarget(actor); { @@ -8308,10 +9647,10 @@ void A_MissileSplit(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MissileSplit", actor)) return; -#endif + if (actor->eflags & MFE_VERTICALFLIP) P_SpawnAlteredDirectionMissile(actor, locvar1, actor->x, actor->y, actor->z+actor->height, locvar2); else @@ -8336,10 +9675,9 @@ void A_MultiShot(mobj_t *actor) const UINT16 loc1up = (UINT16)(locvar1 >> 16); INT32 count = 0; fixed_t ad; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_MultiShot", actor)) return; -#endif if (actor->target) A_FaceTarget(actor); @@ -8398,10 +9736,9 @@ void A_InstaLoop(mobj_t *actor) const angle_t fa = FixedAngleC(loc1lw*FRACUNIT*360, loc1up*FRACUNIT)>>ANGLETOFINESHIFT; const fixed_t ac = FINECOSINE(fa); const fixed_t as = FINESINE(fa); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_InstaLoop", actor)) return; -#endif P_InstaThrust(actor, actor->angle, FixedMul(ac, FixedMul(force, actor->scale))); P_SetObjectMomZ(actor, FixedMul(as, force), false); @@ -8432,10 +9769,9 @@ void A_Custom3DRotate(mobj_t *actor) const fixed_t hOff = FixedMul(loc1up*FRACUNIT, actor->scale); const fixed_t hspeed = FixedMul(loc2up*FRACUNIT/10, actor->scale); const fixed_t vspeed = FixedMul(loc2lw*FRACUNIT/10, actor->scale); -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Custom3DRotate", actor)) return; -#endif if (actor->target->health == 0) { @@ -8492,10 +9828,9 @@ void A_SearchForPlayers(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SearchForPlayers", actor)) return; -#endif if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { @@ -8526,10 +9861,9 @@ void A_CheckRandom(mobj_t *actor) INT32 locvar2 = var2; fixed_t chance = FRACUNIT; -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckRandom", actor)) return; -#endif + if ((locvar1 & 0xFFFF) == 0) return; @@ -8553,15 +9887,14 @@ void A_CheckTargetRings(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTargetRings", actor)) return; -#endif if (!(actor->target) || !(actor->target->player)) return; - if (actor->target->player->health >= locvar1) + if (actor->target->player->rings >= locvar1) P_SetMobjState(actor, locvar2); } @@ -8577,13 +9910,12 @@ void A_CheckRings(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; INT32 i, cntr = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckRings", actor)) return; -#endif for (i = 0; i < MAXPLAYERS; i++) - cntr += players[i].health-1; + cntr += players[i].rings; if (cntr >= locvar1) P_SetMobjState(actor, locvar2); @@ -8602,10 +9934,9 @@ void A_CheckTotalRings(mobj_t *actor) INT32 locvar2 = var2; INT32 i, cntr = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTotalRings", actor)) return; -#endif for (i = 0; i < MAXPLAYERS; i++) cntr += players[i].totalring; @@ -8625,10 +9956,9 @@ void A_CheckHealth(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckHealth", actor)) return; -#endif if (actor->health <= locvar1) P_SetMobjState(actor, locvar2); @@ -8648,10 +9978,9 @@ void A_CheckRange(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; fixed_t dist; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckRange", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -8679,10 +10008,9 @@ void A_CheckHeight(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; fixed_t height; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckHeight", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -8712,10 +10040,9 @@ void A_CheckTrueRange(mobj_t *actor) fixed_t height; // vertical range fixed_t dist; // horizontal range fixed_t l; // true range -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckTrueRange", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -8764,14 +10091,13 @@ void A_CheckThingCount(mobj_t *actor) thinker_t *th; mobj_t *mo2; fixed_t dist = 0; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckThingCount", actor)) return; -#endif - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -8811,10 +10137,8 @@ void A_CheckAmbush(mobj_t *actor) angle_t atp; // actor to target angle angle_t an; // angle between at and atp -#ifdef HAVE_BLUA if (LUA_CallAction("A_CheckAmbush", actor)) return; -#endif if ((!locvar1 && !actor->target) || (locvar1 && !actor->tracer)) return; @@ -8850,10 +10174,9 @@ void A_CheckCustomValue(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckCustomValue", actor)) return; -#endif if (actor->cusval >= locvar1) P_SetMobjState(actor, locvar2); @@ -8870,10 +10193,9 @@ void A_CheckCusValMemo(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CheckCusValMemo", actor)) return; -#endif if (actor->cvmem >= locvar1) P_SetMobjState(actor, locvar2); @@ -8896,10 +10218,9 @@ void A_SetCustomValue(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetCustomValue", actor)) return; -#endif if (cv_debug) CONS_Printf("Init custom value is %d\n", actor->cusval); @@ -8947,10 +10268,9 @@ void A_UseCusValMemo(mobj_t *actor) INT32 temp = actor->cusval; // value being manipulated INT32 tempM = actor->cvmem; // value used to manipulate temp with -#ifdef HAVE_BLUA + if (LUA_CallAction("A_UseCusValMemo", actor)) return; -#endif if (locvar1 == 1) // cvmem being changed using cusval { @@ -9011,10 +10331,9 @@ void A_RelayCustomValue(mobj_t *actor) INT32 temp; // reference value - var1 lower 16 bits changes this INT32 tempT; // target's value - changed to tracer if var1 upper 16 bits set, then modified to become final value -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RelayCustomValue", actor)) return; -#endif if ((!(locvar1 >> 16) && !actor->target) || ((locvar1 >> 16) && !actor->tracer)) return; @@ -9071,10 +10390,9 @@ void A_CusValAction(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_CusValAction", actor)) return; -#endif if (locvar2 == 5) { @@ -9107,9 +10425,7 @@ void A_CusValAction(mobj_t *actor) var2 = states[locvar1].var2; } -#ifdef HAVE_BLUA astate = &states[locvar1]; -#endif states[locvar1].action.acp1(actor); } @@ -9125,10 +10441,9 @@ void A_CusValAction(mobj_t *actor) void A_ForceStop(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_ForceStop", actor)) return; -#endif actor->momx = actor->momy = 0; if (locvar1 == 0) @@ -9146,17 +10461,13 @@ void A_ForceWin(mobj_t *actor) { INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_ForceWin", actor)) return; -#else - (void)actor; -#endif for (i = 0; i < MAXPLAYERS; i++) { - if (playeringame[i] && (players[i].health > 0 - || ((netgame || multiplayer) && (players[i].lives > 0 || players[i].continues > 0)))) + if (playeringame[i] && ((players[i].mo && players[i].mo->health) + || ((netgame || multiplayer) && (players[i].lives || players[i].continues)))) break; } @@ -9164,7 +10475,11 @@ void A_ForceWin(mobj_t *actor) return; for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; P_DoPlayerExit(&players[i]); + } } // Function: A_SpikeRetract @@ -9179,10 +10494,9 @@ void A_ForceWin(mobj_t *actor) void A_SpikeRetract(mobj_t *actor) { INT32 locvar1 = var1; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SpikeRetract", actor)) return; -#endif if (actor->flags & MF_NOBLOCKMAP) return; @@ -9264,12 +10578,11 @@ void A_Repeat(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_Repeat", actor)) return; -#endif - if ((!(actor->extravalue2)) || actor->extravalue2 > locvar1) + if (locvar1 && (!actor->extravalue2 || actor->extravalue2 > locvar1)) actor->extravalue2 = locvar1; if (--actor->extravalue2 > 0) @@ -9290,10 +10603,9 @@ void A_SetScale(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; mobj_t *target; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_SetScale", actor)) return; -#endif if (locvar1 <= 0) { @@ -9334,10 +10646,10 @@ void A_RemoteDamage(mobj_t *actor) INT32 locvar2 = var2; mobj_t *target; // we MUST have a target mobj_t *source = NULL; // on the other hand we don't necessarily need a source -#ifdef HAVE_BLUA + if (LUA_CallAction("A_RemoteDamage", actor)) return; -#endif + if (locvar1 == 1) target = actor->target; else if (locvar1 == 2) @@ -9358,9 +10670,9 @@ void A_RemoteDamage(mobj_t *actor) if (locvar2 == 1) // Kill mobj! { if (target->player) // players die using P_DamageMobj instead for some reason - P_DamageMobj(target, source, source, 10000); + P_DamageMobj(target, source, source, 1, DMG_INSTAKILL); else - P_KillMobj(target, source, source); + P_KillMobj(target, source, source, 0); } else if (locvar2 == 2) // Remove mobj! { @@ -9370,7 +10682,7 @@ void A_RemoteDamage(mobj_t *actor) P_RemoveMobj(target); } else // default: Damage mobj! - P_DamageMobj(target, source, source, 1); + P_DamageMobj(target, source, source, 1, 0); } // Function: A_HomingChase @@ -9387,10 +10699,9 @@ void A_HomingChase(mobj_t *actor) mobj_t *dest; fixed_t dist; fixed_t speedmul; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_HomingChase", actor)) return; -#endif if (locvar2 == 1) dest = actor->tracer; @@ -9422,33 +10733,34 @@ void A_HomingChase(mobj_t *actor) // lower 16 bits = object # to fire // upper 16 bits = front offset // var2: -// lower 16 bits = vertical angle +// lower 15 bits = vertical angle variable +// 16th bit: +// - 0: use vertical angle variable as vertical angle in degrees +// - 1: mimic P_SpawnXYZMissile +// use z of actor minus z of missile as vertical distance to cover during momz calculation +// use vertical angle variable as horizontal distance to cover during momz calculation // upper 16 bits = height offset // void A_TrapShot(mobj_t *actor) { INT32 locvar1 = var1; INT32 locvar2 = var2; - angle_t vertang = FixedAngle(((INT16)(locvar2 & 65535))*FRACUNIT); + boolean oldstyle = (locvar2 & 32768) ? true : false; mobjtype_t type = (mobjtype_t)(locvar1 & 65535); mobj_t *missile; INT16 frontoff = (INT16)(locvar1 >> 16); INT16 vertoff = (INT16)(locvar2 >> 16); fixed_t x, y, z; fixed_t speed; -#ifdef HAVE_BLUA + if (LUA_CallAction("A_TrapShot", actor)) return; -#endif x = actor->x + P_ReturnThrustX(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); y = actor->y + P_ReturnThrustY(actor, actor->angle, FixedMul(frontoff*FRACUNIT, actor->scale)); if (actor->eflags & MFE_VERTICALFLIP) - { z = actor->z + actor->height - FixedMul(vertoff*FRACUNIT, actor->scale) - FixedMul(mobjinfo[type].height, actor->scale); - vertang = InvAngle(vertang); // flip firing angle - } else z = actor->z + FixedMul(vertoff*FRACUNIT, actor->scale); @@ -9459,20 +10771,35 @@ void A_TrapShot(mobj_t *actor) if (actor->eflags & MFE_VERTICALFLIP) missile->flags2 |= MF2_OBJECTFLIP; - missile->destscale = actor->destscale; - P_SetScale(missile, missile->destscale); + + missile->destscale = actor->scale; + P_SetScale(missile, actor->scale); if (missile->info->seesound) - S_StartSound(actor, missile->info->seesound); + S_StartSound(missile, missile->info->seesound); P_SetTarget(&missile->target, actor); missile->angle = actor->angle; speed = FixedMul(missile->info->speed, missile->scale); - missile->momx = FixedMul(FINECOSINE(vertang>>ANGLETOFINESHIFT), FixedMul(FINECOSINE(missile->angle>>ANGLETOFINESHIFT), speed)); - missile->momy = FixedMul(FINECOSINE(vertang>>ANGLETOFINESHIFT), FixedMul(FINESINE(missile->angle>>ANGLETOFINESHIFT), speed)); - missile->momz = FixedMul(FINESINE(vertang>>ANGLETOFINESHIFT), speed); + if (oldstyle) + { + missile->momx = FixedMul(FINECOSINE(missile->angle>>ANGLETOFINESHIFT), speed); + missile->momy = FixedMul(FINESINE(missile->angle>>ANGLETOFINESHIFT), speed); + // The below line basically mimics P_SpawnXYZMissile's momz calculation. + missile->momz = (actor->z + ((actor->eflags & MFE_VERTICALFLIP) ? actor->height : 0) - z) / ((fixed_t)(locvar2 & 32767)*FRACUNIT / speed); + P_CheckMissileSpawn(missile); + } + else + { + angle_t vertang = FixedAngle(((INT16)(locvar2 & 32767))*FRACUNIT); + if (actor->eflags & MFE_VERTICALFLIP) + vertang = InvAngle(vertang); // flip firing angle + missile->momx = FixedMul(FINECOSINE(vertang>>ANGLETOFINESHIFT), FixedMul(FINECOSINE(missile->angle>>ANGLETOFINESHIFT), speed)); + missile->momy = FixedMul(FINECOSINE(vertang>>ANGLETOFINESHIFT), FixedMul(FINESINE(missile->angle>>ANGLETOFINESHIFT), speed)); + missile->momz = FixedMul(FINESINE(vertang>>ANGLETOFINESHIFT), speed); + } } // Function: A_VileTarget @@ -9491,10 +10818,8 @@ void A_VileTarget(mobj_t *actor) mobjtype_t fogtype; INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileTarget", actor)) return; -#endif if (!actor->target) return; @@ -9580,10 +10905,8 @@ void A_VileAttack(mobj_t *actor) mobj_t *fire; INT32 i; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileAttack", actor)) return; -#endif if (!actor->target) return; @@ -9605,7 +10928,7 @@ void A_VileAttack(mobj_t *actor) return; S_StartSound(actor, soundtoplay); - P_DamageMobj(actor->target, actor, actor, 1); + P_DamageMobj(actor->target, actor, actor, 1, 0); //actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; // How id did it actor->target->momz += FixedMul(10*FRACUNIT, actor->scale)*P_MobjFlip(actor->target); // How we're doing it if (explosionType != MT_NULL) @@ -9626,7 +10949,7 @@ void A_VileAttack(mobj_t *actor) actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), fire->z); - P_RadiusAttack(fire, actor, 70*FRACUNIT); + P_RadiusAttack(fire, actor, 70*FRACUNIT, 0); } else { @@ -9646,7 +10969,7 @@ void A_VileAttack(mobj_t *actor) continue; S_StartSound(actor, soundtoplay); - P_DamageMobj(players[i].mo, actor, actor, 1); + P_DamageMobj(players[i].mo, actor, actor, 1, 0); //actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; // How id did it players[i].mo->momz += FixedMul(10*FRACUNIT, actor->scale)*P_MobjFlip(players[i].mo); // How we're doing it if (explosionType != MT_NULL) @@ -9671,7 +10994,7 @@ void A_VileAttack(mobj_t *actor) actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), fire->z); - P_RadiusAttack(fire, actor, 70*FRACUNIT); + P_RadiusAttack(fire, actor, 70*FRACUNIT, 0); } } @@ -9694,10 +11017,8 @@ void A_VileFire(mobj_t *actor) INT32 locvar2 = var2; mobj_t *dest; -#ifdef HAVE_BLUA if (LUA_CallAction("A_VileFire", actor)) return; -#endif dest = actor->tracer; if (!dest) @@ -9782,10 +11103,8 @@ void A_BrakChase(mobj_t *actor) INT32 locvar1 = var1; INT32 locvar2 = var2; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakChase", actor)) return; -#endif // Set new tics NOW, in case the state changes while we're doing this and we try applying this to the painstate or something silly if (actor->tics > 1 && locvar1 < actor->tics) // Not much point, otherwise @@ -9904,10 +11223,9 @@ void A_BrakFireShot(mobj_t *actor) fixed_t x, y, z; INT32 locvar1 = var1; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakFireShot", actor)) return; -#endif + if (!actor->target) return; @@ -9968,10 +11286,8 @@ void A_BrakLobShot(mobj_t *actor) INT32 locvar2 = var2 & 0x0000FFFF; INT32 aimDirect = var2 & 0xFFFF0000; -#ifdef HAVE_BLUA if (LUA_CallAction("A_BrakLobShot", actor)) return; -#endif if (!actor->target) return; // Don't even bother if we've got nothing to aim at. @@ -10076,10 +11392,8 @@ void A_NapalmScatter(mobj_t *actor) INT32 i; // for-loop cursor mobj_t *mo; // each and every spawned napalm burst -#ifdef HAVE_BLUA if (LUA_CallAction("A_NapalmScatter", actor)) return; -#endif // Some quick sanity-checking if (typeOfShot >= NUMMOBJTYPES) // I'd add a <0 check, too, but 0x0000FFFF isn't negative in this case @@ -10130,18 +11444,2936 @@ void A_SpawnFreshCopy(mobj_t *actor) { mobj_t *newObject; -#ifdef HAVE_BLUA if (LUA_CallAction("A_SpawnFreshCopy", actor)) return; -#endif - newObject = P_SpawnMobj(actor->x, actor->y, actor->z, actor->type); + newObject = P_SpawnMobjFromMobj(actor, 0, 0, 0, actor->type); + newObject->flags2 = actor->flags2 & MF2_AMBUSH; newObject->angle = actor->angle; - P_SetScale(newObject, actor->scale); - newObject->destscale = actor->destscale; + newObject->color = actor->color; P_SetTarget(&newObject->target, actor->target); P_SetTarget(&newObject->tracer, actor->tracer); if (newObject->info->seesound) S_StartSound(newObject, newObject->info->seesound); } + +// Internal Flicky spawning function. +mobj_t *P_InternalFlickySpawn(mobj_t *actor, mobjtype_t flickytype, fixed_t momz, boolean lookforplayers, SINT8 moveforward) +{ + mobj_t *flicky; + fixed_t offsx = 0, offsy = 0; + + if (!flickytype) + { + if (!mapheaderinfo[gamemap-1] || !mapheaderinfo[gamemap-1]->numFlickies) // No mapheader, no shoes, no service. + return NULL; + else + { + INT32 prandom = P_RandomKey(mapheaderinfo[gamemap-1]->numFlickies); + flickytype = mapheaderinfo[gamemap-1]->flickies[prandom]; + } + } + + if (moveforward) + { + fixed_t scal = mobjinfo[flickytype].radius*((fixed_t)moveforward); + offsx = P_ReturnThrustX(actor, actor->angle, scal); + offsy = P_ReturnThrustY(actor, actor->angle, scal); + } + + flicky = P_SpawnMobjFromMobj(actor, offsx, offsy, 0, flickytype); + flicky->angle = actor->angle; + + if (flickytype == MT_SEED) + flicky->z += P_MobjFlip(actor)*(actor->height - flicky->height)/2; + + if (actor->eflags & MFE_UNDERWATER) + momz = FixedDiv(momz, FixedSqrt(3*FRACUNIT)); + + P_SetObjectMomZ(flicky, momz, false); + flicky->movedir = (P_RandomChance(FRACUNIT/2) ? -1 : 1); + flicky->fuse = P_RandomRange(595, 700); // originally 300, 350 + flicky->threshold = 0; + + if (lookforplayers) + P_LookForPlayers(flicky, true, false, 0); + + return flicky; +} + +// Function: A_FlickySpawn +// +// Description: Flicky spawning function. +// +// var1: +// lower 16 bits: if 0, spawns random flicky based on level header. Else, spawns the designated thing type. +// bit 17: if 0, no sound is played. Else, A_Scream is called. +// bit 18: if 1, spawn flicky slightly forward from spawn position, to avoid being stuck in wall. doesn't stack with 19. (snailers) +// bit 19: if 1, spawn flicky slightly backward from spawn position. doesn't stack with 18. +// var2 = upwards thrust for spawned flicky. If zero, default value is provided. +// +void A_FlickySpawn(mobj_t *actor) +{ + INT32 locvar1 = var1 & 65535; + INT32 locvar2 = var2; + INT32 test = (var1 >> 16); + SINT8 moveforward = 0; + + if (LUA_CallAction("A_FlickySpawn", actor)) + return; + + if (test & 1) + A_Scream(actor); // A shortcut for the truly lazy. + if (test & 2) + moveforward = 1; + else if (test & 4) + moveforward = -1; + + P_InternalFlickySpawn(actor, locvar1, ((locvar2) ? locvar2 : 8*FRACUNIT), true, moveforward); +} + +// Internal Flicky color setting +void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo) +{ + UINT8 flickycolors[] = { + SKINCOLOR_RED, + SKINCOLOR_CYAN, + SKINCOLOR_BLUE, + SKINCOLOR_VAPOR, + SKINCOLOR_PURPLE, + SKINCOLOR_BUBBLEGUM, + SKINCOLOR_NEON, + SKINCOLOR_BLACK, + SKINCOLOR_BEIGE, + SKINCOLOR_LAVENDER, + SKINCOLOR_RUBY, + SKINCOLOR_SALMON, + SKINCOLOR_SUNSET, + SKINCOLOR_ORANGE, + SKINCOLOR_YELLOW, + }; + + if (extrainfo == 0) + // until we can customize flicky colors by level header, just stick to SRB2's defaults + actor->color = flickycolors[P_RandomKey(2)]; //flickycolors[P_RandomKey(sizeof(flickycolors))]; + else + actor->color = flickycolors[min(extrainfo-1, 14)]; // sizeof(flickycolors)-1 +} + +// Function: A_FlickyCenter +// +// Description: Place flickies in-level. +// +// var1: +// Lower 16 bits = if 0, spawns random flicky based on level header. Else, spawns the designated thing type. +// Bits 17-20 = Flicky color, up to 15. Applies to fish. +// Bit 21 = Flag MF_SLIDEME (see below) +// Bit 22 = Flag MF_GRENADEBOUNCE (see below) +// Bit 23 = Flag MF_NOCLIPTHING (see below) +// +// If actor is placed from a spawnpoint (map Thing), the Thing's properties take precedence. +// +// var2 = maximum default distance away from spawn the flickies are allowed to travel. If angle != 0, then that's the radius. +// +// If MTF_EXTRA (MF_SLIDEME): is flagged, Flickies move aimlessly. Else, orbit around the target. +// If MTF_OBJECTSPECIAL (MF_GRENADEBOUNCE): Flickies stand in-place without gravity (unless they hop, then gravity is applied.) +// If MTF_AMBUSH (MF_NOCLIPTHING): is flagged, Flickies hop. +// +void A_FlickyCenter(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + UINT16 flickytype = (locvar1 & 0xFFFF); + UINT8 flickycolor = ((locvar1 >> 16) & 0xFF); + UINT8 flickyflags = ((locvar1 >> 20) & 0xF); + + if (LUA_CallAction("A_FlickyCenter", actor)) + return; + + if (!actor->tracer) + { + mobj_t *flicky = P_InternalFlickySpawn(actor, locvar1, 1, false, 0); + P_SetTarget(&flicky->target, actor); + P_SetTarget(&actor->tracer, flicky); + + if (actor->spawnpoint) + { + actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING); + actor->flags |= ( + ((actor->spawnpoint->options & MTF_EXTRA) ? MF_SLIDEME : 0) + | ((actor->spawnpoint->options & MTF_OBJECTSPECIAL) ? MF_GRENADEBOUNCE : 0) + | ((actor->spawnpoint->options & MTF_AMBUSH) ? MF_NOCLIPTHING : 0) + ); + actor->extravalue1 = actor->spawnpoint->angle ? abs(actor->spawnpoint->angle) * FRACUNIT + : locvar2 ? abs(locvar2) : 384 * FRACUNIT; + actor->extravalue2 = actor->spawnpoint->extrainfo; + actor->friction = actor->spawnpoint->x*FRACUNIT; + actor->movefactor = actor->spawnpoint->y*FRACUNIT; + actor->watertop = actor->spawnpoint->z*FRACUNIT; + } + else + { + actor->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE|MF_NOCLIPTHING); + actor->flags |= ( + ((flickyflags & 1) ? MF_SLIDEME : 0) + | ((flickyflags & 2) ? MF_GRENADEBOUNCE : 0) + | ((flickyflags & 4) ? MF_NOCLIPTHING : 0) + ); + actor->extravalue1 = abs(locvar2); + actor->extravalue2 = flickycolor; + actor->friction = actor->x; + actor->movefactor = actor->y; + actor->watertop = actor->z; + locvar1 = flickytype; + } + + if (actor->flags & MF_GRENADEBOUNCE) // in-place + actor->tracer->fuse = 0; + else if (actor->flags & MF_SLIDEME) // aimless + { + actor->tracer->fuse = 0; // less than 2*TICRATE means move aimlessly. + actor->tracer->angle = P_RandomKey(180)*ANG2; + } + else //orbit + actor->tracer->fuse = FRACUNIT; + + if (locvar1 == MT_FLICKY_08) + P_InternalFlickySetColor(actor->tracer, actor->extravalue2); + + actor->extravalue2 = 0; + } + + if (!(actor->flags & MF_SLIDEME) && !(actor->flags & MF_GRENADEBOUNCE)) + { + fixed_t originx = actor->friction; + fixed_t originy = actor->movefactor; + fixed_t originz = actor->watertop; + + actor->tracer->fuse = FRACUNIT; + + // Impose default home radius if flicky orbits around player + if (!actor->extravalue1) + actor->extravalue1 = locvar2 ? abs(locvar2) : 384 * FRACUNIT; + + P_LookForPlayers(actor, true, false, actor->extravalue1); + + if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) + { + actor->extravalue2 = 1; + P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); + } + else if(actor->extravalue2) + { + actor->extravalue2 = 0; + P_TeleportMove(actor, originx, originy, originz); + } + } +} + +// Internal Flicky bubbling function. +void P_InternalFlickyBubble(mobj_t *actor) +{ + if (actor->eflags & MFE_UNDERWATER) + { + mobj_t *overlay; + + if (!((actor->z + 3*actor->height/2) < actor->watertop) || !mobjinfo[actor->type].raisestate || actor->tracer) + return; + + overlay = P_SpawnMobj(actor->x, actor->y, actor->z, MT_OVERLAY); + P_SetMobjStateNF(overlay, mobjinfo[actor->type].raisestate); + P_SetTarget(&actor->tracer, overlay); + P_SetTarget(&overlay->target, actor); + return; + } + + if (!actor->tracer || P_MobjWasRemoved(actor->tracer)) + return; + + P_RemoveMobj(actor->tracer); + P_SetTarget(&actor->tracer, NULL); +} + +// Function: A_FlickyAim +// +// Description: Flicky aiming function. +// +// var1 = how far around the target (in angle constants) the flicky should look +// var2 = distance from target to aim for +// +void A_FlickyAim(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + boolean flickyhitwall = false; + + if (LUA_CallAction("A_FlickyAim", actor)) + return; + + if ((actor->momx == actor->momy && actor->momy == 0) + || (actor->target && P_IsFlickyCenter(actor->target->type) + && actor->target->extravalue1 && (actor->target->flags & MF_SLIDEME) + && P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) >= actor->target->extravalue1)) + flickyhitwall = true; + + P_InternalFlickyBubble(actor); + P_InstaThrust(actor, 0, 0); + + if (!actor->target) + { + P_LookForPlayers(actor, true, false, 0); + actor->angle = P_RandomKey(36)*ANG10; + return; + } + + if (actor->fuse > 2*TICRATE) + { + angle_t posvar; + fixed_t chasevar, chasex, chasey; + + if (flickyhitwall) + actor->movedir *= -1; + + posvar = ((R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + actor->movedir*locvar1) >> ANGLETOFINESHIFT) & FINEMASK; + chasevar = FixedSqrt(max(FRACUNIT, P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y) - locvar2)) + locvar2; + + chasex = actor->target->x + FixedMul(FINECOSINE(posvar), chasevar); + chasey = actor->target->y + FixedMul(FINESINE(posvar), chasevar); + + if (P_AproxDistance(chasex - actor->x, chasey - actor->y)) + actor->angle = R_PointToAngle2(actor->x, actor->y, chasex, chasey); + } + else if (flickyhitwall) + { + if (actor->target && P_IsFlickyCenter(actor->target->type)) + actor->angle = R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + P_RandomRange(112, 248) * ANG1; + else + actor->angle += P_RandomRange(112, 248)*ANG1; + actor->threshold = 0; + } +} + +//Internal Flicky flying function. Also usuable as an underwater swim thrust. +void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fixed_t chasez) +{ + angle_t vertangle; + + flyspeed = FixedMul(flyspeed, actor->scale); + actor->flags |= MF_NOGRAVITY; + + var1 = ANG30; + var2 = 32*FRACUNIT; + A_FlickyAim(actor); + + chasez *= 8; + if (!actor->target || !(actor->fuse > 2*TICRATE)) + chasez += ((actor->eflags & MFE_VERTICALFLIP) ? actor->ceilingz - 24*FRACUNIT : actor->floorz + 24*FRACUNIT); + else + { + fixed_t add = actor->target->z + (actor->target->height - actor->height)/2; + if (add > (actor->ceilingz - 24*actor->scale - actor->height)) + add = actor->ceilingz - 24*actor->scale - actor->height; + else if (add < (actor->floorz + 24*actor->scale)) + add = actor->floorz + 24*actor->scale; + chasez += add; + } + + if (!targetdist) + targetdist = 16*FRACUNIT; //Default! + + if (actor->target && abs(chasez - actor->z) > targetdist) + targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y); + + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && (actor->target->flags & MF_SLIDEME)) + vertangle = 0; + else + vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK; + + P_InstaThrust(actor, actor->angle, FixedMul(FINECOSINE(vertangle), flyspeed)); + actor->momz = FixedMul(FINESINE(vertangle), flyspeed); +} + +// Function: A_FlickyFly +// +// Description: Flicky flying function. +// +// var1 = how fast to fly +// var2 = how far ahead the target should be considered +// +void A_FlickyFly(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickyFly", actor)) + return; + + P_InternalFlickyFly(actor, locvar1, locvar2, + FINECOSINE((((actor->fuse % 36) * ANG10) >> ANGLETOFINESHIFT) & FINEMASK) + ); +} + +// Function: A_FlickySoar +// +// Description: Flicky soaring function - specific to puffin. +// +// var1 = how fast to fly +// var2 = how far ahead the target should be considered +// +void A_FlickySoar(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickySoar", actor)) + return; + + P_InternalFlickyFly(actor, locvar1, locvar2, + 2*(FRACUNIT/2 - abs(FINECOSINE((((actor->fuse % 144) * 5*ANG1/2) >> ANGLETOFINESHIFT) & FINEMASK))) + ); + + if (P_MobjFlip(actor)*actor->momz > 0 && actor->frame == 1 && actor->sprite == SPR_FL10) + actor->frame = 3; +} + +//Function: A_FlickyCoast +// +// Description: Flicky swim-coasting function. +// +// var1 = speed to change state upon reaching +// var2 = state to change to upon slowing down +// the spawnstate of the mobj = state to change to when above water +// +void A_FlickyCoast(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickyCoast", actor)) + return; + + if (actor->eflags & MFE_UNDERWATER) + { + actor->momx = (11*actor->momx)/12; + actor->momy = (11*actor->momy)/12; + actor->momz = (11*actor->momz)/12; + + if (P_AproxDistance(P_AproxDistance(actor->momx, actor->momy), actor->momz) < locvar1) + P_SetMobjState(actor, locvar2); + + return; + } + + actor->flags &= ~MF_NOGRAVITY; + P_SetMobjState(actor, mobjinfo[actor->type].spawnstate); +} + +// Internal Flicky hopping function. +void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angle) +{ + if (((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) + || ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz))) + { + if (momz) + { + if (actor->eflags & MFE_UNDERWATER) + momz = FixedDiv(momz, FixedSqrt(3*FRACUNIT)); + P_SetObjectMomZ(actor, momz, false); + } + P_InstaThrust(actor, angle, FixedMul(momh, actor->scale)); + } +} + +// Function: A_FlickyHop +// +// Description: Flicky hopping function. +// +// var1 = vertical thrust +// var2 = horizontal thrust +// +void A_FlickyHop(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickyHop", actor)) + return; + + P_InternalFlickyHop(actor, locvar1, locvar2, actor->angle); +} + +// Function: A_FlickyFlounder +// +// Description: Flicky floundering function. +// +// var1 = intended vertical thrust +// var2 = intended horizontal thrust +// +void A_FlickyFlounder(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + angle_t hopangle; + + if (LUA_CallAction("A_FlickyFlounder", actor)) + return; + + locvar1 *= (P_RandomKey(2) + 1); + locvar2 *= (P_RandomKey(2) + 1); + hopangle = (actor->angle + (P_RandomKey(9) - 4)*ANG2); + P_InternalFlickyHop(actor, locvar1, locvar2, hopangle); +} + +// Function: A_FlickyCheck +// +// Description: Flicky airtime check function. +// +// var1 = state to change to upon touching the floor +// var2 = state to change to upon falling +// the meleestate of the mobj = state to change to when underwater +// +void A_FlickyCheck(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickyCheck", actor)) + return; + + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && (actor->target->flags & MF_GRENADEBOUNCE)) + { + if (!(actor->target->flags & MF_NOCLIPTHING)) // no hopping + { + actor->momz = 0; + actor->flags |= MF_NOGRAVITY; + } + actor->flags |= MF_NOCLIP | MF_NOBLOCKMAP | MF_SCENERY; + P_SetMobjState(actor, mobjinfo[actor->type].seestate); + } + else if (locvar2 && P_MobjFlip(actor)*actor->momz < 1) + P_SetMobjState(actor, locvar2); + else if (locvar1 && ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) + || ((actor->eflags & MFE_VERTICALFLIP) && actor->z + actor->height >= actor->ceilingz))) + P_SetMobjState(actor, locvar1); + else if (mobjinfo[actor->type].meleestate && (actor->eflags & MFE_UNDERWATER)) + P_SetMobjState(actor, mobjinfo[actor->type].meleestate); + P_InternalFlickyBubble(actor); +} + +// Function: A_FlickyHeightCheck +// +// Description: Flicky height check function. +// +// var1 = state to change to when falling below height relative to target +// var2 = height relative to target to change state at +// +void A_FlickyHeightCheck(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickyHeightCheck", actor)) + return; + + if (actor->target + && P_IsFlickyCenter(actor->target->type) + && (actor->target->flags & MF_GRENADEBOUNCE)) + { + if (!(actor->target->flags & MF_NOCLIPTHING)) // no hopping + { + actor->momz = 0; + actor->flags |= MF_NOGRAVITY; + } + actor->flags |= MF_NOCLIP | MF_NOBLOCKMAP | MF_SCENERY; + P_SetMobjState(actor, mobjinfo[actor->type].seestate); + } + else if (locvar1 && actor->target && P_MobjFlip(actor)*actor->momz < 1 + && ((P_MobjFlip(actor)*((actor->z + actor->height/2) - (actor->target->z + actor->target->height/2)) < locvar2) + || (actor->z - actor->height < actor->floorz) || (actor->z + 2*actor->height > actor->ceilingz))) + P_SetMobjState(actor, locvar1); + P_InternalFlickyBubble(actor); +} + +// Function: A_FlickyFlutter +// +// Description: Flicky fluttering function - specific to chicken. +// +// var1 = state to change to upon touching the floor +// var2 = state to change to upon falling +// the meleestate of the mobj = state to change to when underwater +// +void A_FlickyFlutter(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FlickyFlutter", actor)) + return; + + var1 = locvar1; + var2 = locvar2; + A_FlickyCheck(actor); + + var1 = ANG30; + var2 = 32*FRACUNIT; + A_FlickyAim(actor); + + P_InstaThrust(actor, actor->angle, 2*actor->scale); + if (P_MobjFlip(actor)*actor->momz < -FRACUNIT/2) + actor->momz = -P_MobjFlip(actor)*actor->scale/2; +} + +#undef FLICKYHITWALL + +// Function: A_FlameParticle +// +// Description: Creates the mobj's painchance at a random position around the object's radius. +// +// var1 = unused +// var2 = unused +// +void A_FlameParticle(mobj_t *actor) +{ + mobjtype_t type = (mobjtype_t)(mobjinfo[actor->type].painchance); + fixed_t rad, hei; + mobj_t *particle; + + if (LUA_CallAction("A_FlameParticle", actor)) + return; + + if (!type) + return; + + rad = actor->radius>>FRACBITS; + hei = actor->height>>FRACBITS; + particle = P_SpawnMobjFromMobj(actor, + P_RandomRange(rad, -rad)<frame = actor->frame; + + if (!(locvar1 & 1)) + { + fade->fuse = 15; + fade->flags2 |= MF2_BOSSNOTRAP; + } + else + fade->fuse = 20; + + if (!(locvar1 & 2)) + P_SetTarget(&actor->tracer, fade); +} + +// Function: A_Boss5Jump +// +// Description: Makes an object jump in an arc to land on their tracer precicely. +// Adapted from A_BrakLobShot, see there for explanation. +// +// var1 = unused +// var2 = unused +// +void A_Boss5Jump(mobj_t *actor) +{ + fixed_t v; // Velocity to jump at + fixed_t a1, a2, aToUse; // Velocity squared + fixed_t g; // Gravity + fixed_t x; // Horizontal difference + INT32 x_int; // x! But in integer form! + fixed_t y; // Vertical difference (yes that's normally z in SRB2 shut up) + INT32 y_int; // y! But in integer form! + INT32 intHypotenuse; // x^2 + y^2. Frequently overflows fixed point, hence why we need integers proper. + fixed_t fixedHypotenuse; // However, we can work around that and still get a fixed-point number. + angle_t theta; // Angle of attack + // INT32 locvar1 = var1; + // INT32 locvar2 = var2; + + if (LUA_CallAction("A_Boss5Jump", actor)) + return; + + if (!actor->tracer) + return; // Don't even bother if we've got nothing to aim at. + + // Look up actor's current gravity situation + if (actor->subsector->sector->gravity) + g = FixedMul(gravity,(FixedDiv(*actor->subsector->sector->gravity>>FRACBITS, 1000))); + else + g = gravity; + + // Look up distance between actor and its tracer + x = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y); + // Look up height difference between actor and its tracer + y = actor->tracer->z - actor->z; + + // Get x^2 + y^2. Have to do it in a roundabout manner, because this overflows fixed_t way too easily otherwise. + x_int = x>>FRACBITS; + y_int = y>>FRACBITS; + intHypotenuse = (x_int*x_int) + (y_int*y_int); + fixedHypotenuse = FixedSqrt(intHypotenuse) *256; + + // a = g(y+/-sqrt(x^2+y^2)). a1 can be +, a2 can be -. + a1 = FixedMul(g,y+fixedHypotenuse); + a2 = FixedMul(g,y-fixedHypotenuse); + + // Determine which one isn't actually an imaginary number (or the smaller of the two, if both are real), and use that for v. + if (a1 < 0 || a2 < 0) + { + if (a1 < 0 && a2 < 0) + { + //Somehow, v^2 is negative in both cases. v is therefore imaginary and something is horribly wrong. Abort! + return; + } + // Just find which one's NOT negative, and use that + aToUse = max(a1,a2); + } + else + { + // Both are positive; use whichever's smaller so it can decay faster + aToUse = min(a1,a2); + } + v = FixedSqrt(aToUse); + // Okay, so we know the velocity. Let's actually find theta. + // We can cut the "+/- sqrt" part out entirely, since v was calculated specifically for it to equal zero. So: + //theta = tantoangle[FixedDiv(aToUse,FixedMul(g,x)) >> DBITS]; + theta = tantoangle[SlopeDiv(aToUse,FixedMul(g,x))]; + + // Okay, complicated math done. Let's make this object jump already. + A_FaceTracer(actor); + + if (actor->eflags & MFE_VERTICALFLIP) + actor->z--; + else + actor->z++; + + // Horizontal axes first. First parameter is initial horizontal impulse, second is to correct its angle. + fixedHypotenuse = FixedMul(v, FINECOSINE(theta >> ANGLETOFINESHIFT)); // variable reuse + actor->momx = FixedMul(fixedHypotenuse, FINECOSINE(actor->angle >> ANGLETOFINESHIFT)); + actor->momy = FixedMul(fixedHypotenuse, FINESINE(actor->angle >> ANGLETOFINESHIFT)); + // Then the vertical axis. No angle-correction needed here. + actor->momz = FixedMul(v, FINESINE(theta >> ANGLETOFINESHIFT)); + // I hope that's all that's needed, ugh +} + +// Function: A_LightBeamReset +// Description: Resets momentum and position for DSZ's projecting light beams +// +// var1 = unused +// var2 = unused +// +void A_LightBeamReset(mobj_t *actor) +{ + // INT32 locvar1 = var1; + // INT32 locvar2 = var2; + + if (LUA_CallAction("A_LightBeamReset", actor)) + return; + + actor->destscale = FRACUNIT + P_SignedRandom()*FRACUNIT/256; + P_SetScale(actor, actor->destscale); + + if (!actor->spawnpoint) + return; // this can't work properly welp + + actor->momx = -(P_SignedRandom()*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128; + actor->momy = (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128; + actor->momz = (P_SignedRandom()*FRACUNIT)/128; + + P_TeleportMove(actor, + actor->spawnpoint->x*FRACUNIT - (P_SignedRandom()*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2, + actor->spawnpoint->y*FRACUNIT + (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2, + actor->spawnpoint->z*FRACUNIT + (P_SignedRandom()*FRACUNIT)/2); +} + +// Function: A_MineExplode +// Description: Handles the explosion of a DSZ mine. +// +// var1 = unused +// var2 = unused +// +void A_MineExplode(mobj_t *actor) +{ + // INT32 locvar1 = var1; + // INT32 locvar2 = var2; + + if (LUA_CallAction("A_MineExplode", actor)) + return; + + A_Scream(actor); + actor->flags = MF_NOGRAVITY|MF_NOCLIP; + + quake.epicenter = NULL; + quake.radius = 512*FRACUNIT; + quake.intensity = 8*FRACUNIT; + quake.time = TICRATE/3; + + P_RadiusAttack(actor, actor->tracer, 192*FRACUNIT, DMG_CANHURTSELF); + P_MobjCheckWater(actor); + + { +#define dist 64 + UINT8 i; + mobjtype_t type = ((actor->eflags & MFE_UNDERWATER) ? MT_UWEXPLODE : MT_SONIC3KBOSSEXPLODE); + S_StartSound(actor, ((actor->eflags & MFE_UNDERWATER) ? sfx_s3k57 : sfx_s3k4e)); + P_SpawnMobj(actor->x, actor->y, actor->z, type); + for (i = 0; i < 16; i++) + { + mobj_t *b = P_SpawnMobj(actor->x+P_RandomRange(-dist, dist)*FRACUNIT, + actor->y+P_RandomRange(-dist, dist)*FRACUNIT, + actor->z+P_RandomRange(((actor->eflags & MFE_UNDERWATER) ? -dist : 0), dist)*FRACUNIT, + type); + fixed_t dx = b->x - actor->x, dy = b->y - actor->y, dz = b->z - actor->z; + fixed_t dm = P_AproxDistance(dz, P_AproxDistance(dy, dx)); + b->momx = FixedDiv(dx, dm)*3; + b->momy = FixedDiv(dy, dm)*3; + b->momz = FixedDiv(dz, dm)*3; + if ((actor->watertop == INT32_MAX) || (b->z + b->height > actor->watertop)) + b->flags &= ~MF_NOGRAVITY; + } +#undef dist + + if (actor->watertop != INT32_MAX) + P_SpawnMobj(actor->x, actor->y, actor->watertop, (actor->eflags & MFE_TOUCHLAVA) ? MT_LAVASPLISH : MT_SPLISH); + } +} + +// Function: A_MineRange +// Description: If the target gets too close, change the state to meleestate. +// +// var1 = Distance to alert at +// var2 = unused +// +void A_MineRange(mobj_t *actor) +{ + fixed_t dm; + INT32 locvar1 = var1; + // INT32 locvar2 = var2; + + if (LUA_CallAction("A_MineRange", actor)) + return; + + if (!actor->target) + return; + + dm = P_AproxDistance(actor->z - actor->target->z, P_AproxDistance(actor->y - actor->target->y, actor->x - actor->target->x)); + if ((dm>>FRACBITS) < locvar1) + P_SetMobjState(actor, actor->info->meleestate); +} + +// Function: A_ConnectToGround +// Description: Create a palm tree trunk/mine chain. +// +// var1 = Object type to connect to ground +// var2 = Object type to place on ground +// +void A_ConnectToGround(mobj_t *actor) +{ + mobj_t *work; + fixed_t workz; + fixed_t workh; + angle_t ang; + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_ConnectToGround", actor)) + return; + + if (actor->subsector->sector->ffloors) + P_AdjustMobjFloorZ_FFloors(actor, actor->subsector->sector, 2); + + if (actor->flags2 & MF2_OBJECTFLIP) + workz = (actor->z + actor->height) - actor->ceilingz; + else + workz = actor->floorz - actor->z; + + if (locvar2) + { + workh = FixedMul(mobjinfo[locvar2].height, actor->scale); + if (actor->flags2 & MF2_OBJECTFLIP) + workz += workh; + work = P_SpawnMobjFromMobj(actor, 0, 0, workz, locvar2); + workz += workh; + } + + if (!locvar1) + return; + + if (!(workh = FixedMul(mobjinfo[locvar1].height, actor->scale))) + return; + + ang = actor->angle + ANGLE_45; + while (workz < 0) + { + work = P_SpawnMobjFromMobj(actor, 0, 0, workz, locvar1); + if (work) + work->angle = ang; + ang += ANGLE_90; + workz += workh; + } + + if (workz != 0) + actor->z += P_MobjFlip(actor)*workz; +} + +// Function: A_SpawnParticleRelative +// +// Description: Spawns a particle effect relative to the location of the actor +// +// var1: +// var1 >> 16 = x +// var1 & 65535 = y +// var2: +// var2 >> 16 = z +// var2 & 65535 = state +// +void A_SpawnParticleRelative(mobj_t *actor) +{ + INT16 x, y, z; // Want to be sure we can use negative values + statenum_t state; + mobj_t *mo; + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_SpawnParticleRelative", actor)) + return; + + + CONS_Debug(DBG_GAMELOGIC, "A_SpawnParticleRelative called from object type %d, var1: %d, var2: %d\n", actor->type, locvar1, locvar2); + + x = (INT16)(locvar1>>16); + y = (INT16)(locvar1&65535); + z = (INT16)(locvar2>>16); + state = (statenum_t)(locvar2&65535); + + // Spawn objects correctly in reverse gravity. + // NOTE: Doing actor->z + actor->height is the bottom of the object while the object has reverse gravity. - Flame + mo = P_SpawnMobj(actor->x + FixedMul(x<scale), + actor->y + FixedMul(y<scale), + (actor->eflags & MFE_VERTICALFLIP) ? ((actor->z + actor->height - mobjinfo[MT_PARTICLE].height) - FixedMul(z<scale)) : (actor->z + FixedMul(z<scale)), MT_PARTICLE); + + // Spawn objects with an angle matching the spawner's, rather than spawning Eastwards - Monster Iestyn + mo->angle = actor->angle; + + if (actor->eflags & MFE_VERTICALFLIP) + mo->flags2 |= MF2_OBJECTFLIP; + + P_SetMobjState(mo, state); +} + +// Function: A_MultiShotDist +// +// Description: Spawns multiple shots based on player proximity +// +// var1 = same as A_MultiShot +// var2 = same as A_MultiShot +// +void A_MultiShotDist(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_MultiShotDist", actor)) + return; + + { + UINT8 i; + // Quick! Look through players! + // Don't spawn dust unless a player is relatively close by (var1). + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && players[i].mo + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (1600<> 16 = mobjtype of child +// var2 & 65535 = vertical momentum +// var2: +// var2 >> 16 = forward offset +// var2 & 65535 = vertical offset +// +void A_WhoCaresIfYourSonIsABee(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + fixed_t foffsetx; + fixed_t foffsety; + mobj_t *son; + + if (LUA_CallAction("A_WhoCaresIfYourSonIsABee", actor)) + return; + + A_FaceTarget(actor); + + if (actor->extravalue1) + actor->extravalue1--; + + if (actor->info->attacksound) + S_StartSound(actor, actor->info->attacksound); + + foffsetx = P_ReturnThrustX(actor, actor->angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale)); + foffsety = P_ReturnThrustY(actor, actor->angle, FixedMul((locvar2 >> 16)*FRACUNIT, actor->scale)); + + if (!(son = P_SpawnMobjFromMobj(actor, foffsetx, foffsety, (locvar2&65535)*FRACUNIT, (mobjtype_t)(locvar1 >> 16)))) + return; + + P_SetObjectMomZ(son, (locvar1 & 65535)<tracer, actor); + P_SetTarget(&son->target, actor->target); +} + +// Function: A_ParentTriesToSleep +// +// Description: If extravalue1 is less than or equal to var1, go to var2. +// +// var1 = state to go to when extravalue1 +// var2 = unused +// +void A_ParentTriesToSleep(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction("A_ParentTriesToSleep", actor)) + return; + + if (actor->extravalue1) + { + if (actor->info->seesound) + S_StartSound(actor, actor->info->seesound); + actor->reactiontime = 0; + P_SetMobjState(actor, locvar1); + } + else if (!actor->reactiontime) + { + actor->reactiontime = 1; + if (actor->info->activesound) // more like INactivesound doy hoy hoy + S_StartSound(actor, actor->info->activesound); + } +} + + +// Function: A_CryingToMomma +// +// Description: If you're a child, let your parent know something's happened to you through extravalue1. Also, prepare to die. +// +// var1 = unused +// var2 = unused +// +void A_CryingToMomma(mobj_t *actor) +{ + if (LUA_CallAction("A_CryingToMomma", actor)) + return; + + if (actor->tracer) + actor->tracer->extravalue1++; + + actor->momx = actor->momy = actor->momz = 0; + + P_UnsetThingPosition(actor); + if (sector_list) + { + P_DelSeclist(sector_list); + sector_list = NULL; + } + actor->flags = MF_NOBLOCKMAP|MF_NOCLIPTHING; + P_SetThingPosition(actor); +} + +// Function: A_CheckFlags2 +// +// Description: If actor->flags2 & var1, goto var2. +// +// var1 = mask +// var2 = state to go +// +void A_CheckFlags2(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_CheckFlags2", actor)) + return; + + if (actor->flags2 & locvar1) + P_SetMobjState(actor, (statenum_t)locvar2); +} + +// Function: A_Boss5FindWaypoint +// +// Description: Finds the next waypoint in sequence and sets it as its tracer. +// +// var1 = if 1, always go to ambush-marked waypoint. if 2, go to MT_BOSSFLYPOINT. +// var2 = unused +// +void A_Boss5FindWaypoint(mobj_t *actor) +{ + INT32 locvar1 = var1; + boolean avoidcenter; + UINT32 i; + UINT8 extrainfo = (actor->spawnpoint ? actor->spawnpoint->extrainfo : 0); + + if (LUA_CallAction("A_Boss5FindWaypoint", actor)) + return; + + avoidcenter = !actor->tracer || (actor->health == actor->info->damage+1); + + if (locvar1 == 2) // look for the boss waypoint + { + thinker_t *th; + mobj_t *mo2; + P_SetTarget(&actor->tracer, NULL); + // Flee! Flee! Find a point to escape to! If none, just shoot upward! + // scan the thinkers to find the runaway point + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_BOSSFLYPOINT) + continue; + + if (mo2->spawnpoint && mo2->spawnpoint->extrainfo != extrainfo) + continue; + + // If this one's further then the last one, don't go for it. + if (actor->tracer && + P_AproxDistance(P_AproxDistance(actor->x - mo2->x, actor->y - mo2->y), actor->z - mo2->z) > + P_AproxDistance(P_AproxDistance(actor->x - actor->tracer->x, actor->y - actor->tracer->y), actor->z - actor->tracer->z)) + continue; + + // Otherwise... Do! + P_SetTarget(&actor->tracer, mo2); + } + if (!actor->tracer) + return; // no boss flypoints found + } + else if (locvar1 == 1) // always go to ambush-marked waypoint + { + if (avoidcenter) + goto nowaypoints; // if we can't go the center, why on earth are we doing this? + + for (i = 0; i < nummapthings; i++) + { + if (!mapthings[i].mobj) + continue; + if (mapthings[i].mobj->type != MT_FANGWAYPOINT) + continue; + if (mapthings[i].extrainfo != extrainfo) + continue; + if (!(mapthings[i].options & MTF_AMBUSH)) + continue; + + P_SetTarget(&actor->tracer, mapthings[i].mobj); + break; + } + + if (i == nummapthings) + goto nowaypoints; + } + else // locvar1 == 0 + { + fixed_t hackoffset = P_MobjFlip(actor)*56*FRACUNIT; + INT32 numwaypoints = 0; + mobj_t **waypoints; + INT32 key; + + actor->z += hackoffset; + + // first, count how many waypoints we have + for (i = 0; i < nummapthings; i++) + { + if (!mapthings[i].mobj) + continue; + if (mapthings[i].mobj->type != MT_FANGWAYPOINT) + continue; + if (actor->tracer == mapthings[i].mobj) // this was your tracer last time + continue; + if (mapthings[i].extrainfo != extrainfo) + continue; + if (mapthings[i].options & MTF_AMBUSH) + { + if (avoidcenter) + continue; + } + else if (mapthings[i].mobj->reactiontime > 0) + continue; + if (!P_CheckSight(actor, mapthings[i].mobj)) + continue; + numwaypoints++; + } + + // players also count as waypoints apparently + if (actor->extravalue2 > 1) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + if (!players[i].mo) + continue; + if (players[i].spectator) + continue; + if (players[i].mo->health <= 0) + continue; + if (players[i].powers[pw_flashing]) + continue; + if (actor->tracer == players[i].mo) // this was your tracer last time + continue; + if (!P_CheckSight(actor, players[i].mo)) + continue; + numwaypoints++; + } + } + + if (!numwaypoints) + { + // restore z position + actor->z -= hackoffset; + goto nowaypoints; // no waypoints :( + } + + // allocate the table and reset count to zero + waypoints = Z_Calloc(sizeof(*waypoints)*numwaypoints, PU_STATIC, NULL); + numwaypoints = 0; + + // now find them again and add them to the table! + for (i = 0; i < nummapthings; i++) + { + if (!mapthings[i].mobj) + continue; + if (mapthings[i].mobj->type != MT_FANGWAYPOINT) + continue; + if (actor->tracer == mapthings[i].mobj) // this was your tracer last time + continue; + if (mapthings[i].extrainfo != extrainfo) + continue; + if (mapthings[i].options & MTF_AMBUSH) + { + if (avoidcenter) + continue; + } + else if (mapthings[i].mobj->reactiontime > 0) + { + mapthings[i].mobj->reactiontime--; + continue; + } + if (!P_CheckSight(actor, mapthings[i].mobj)) + continue; + waypoints[numwaypoints++] = mapthings[i].mobj; + } + + if (actor->extravalue2 > 1) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + if (!players[i].mo) + continue; + if (players[i].spectator) + continue; + if (players[i].mo->health <= 0) + continue; + if (players[i].powers[pw_flashing]) + continue; + if (actor->tracer == players[i].mo) // this was your tracer last time + continue; + if (!P_CheckSight(actor, players[i].mo)) + continue; + waypoints[numwaypoints++] = players[i].mo; + } + } + + // restore z position + actor->z -= hackoffset; + + if (!numwaypoints) + { + Z_Free(waypoints); // free table + goto nowaypoints; // ??? + } + + key = P_RandomKey(numwaypoints); + + P_SetTarget(&actor->tracer, waypoints[key]); + if (actor->tracer->type == MT_FANGWAYPOINT) + actor->tracer->reactiontime = numwaypoints/4; // Monster Iestyn: is this how it should be? I count center waypoints as waypoints unlike the original Lua script + Z_Free(waypoints); // free table + } + + // now face the tracer you just set! + A_FaceTracer(actor); + return; + +nowaypoints: + // no waypoints at all, guess the mobj has to disappear + if (actor->health) + P_KillMobj(actor, NULL, NULL, 0); + else + P_RemoveMobj(actor); + return; +} + +// Function: A_DoNPCSkid +// +// Description: Something that looks like a player is skidding. +// +// var1 = state to change to upon being slow enough +// var2 = minimum speed +// +void A_DoNPCSkid(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + fixed_t x, y, z; + + if (LUA_CallAction("A_DoNPCSkid", actor)) + return; + + x = actor->x; + y = actor->y; + z = actor->z; + + if (!locvar2) + locvar2 = FRACUNIT/2; + + if ((FixedHypot(actor->momx, actor->momy) < locvar2) + || !P_TryMove(actor, actor->x + actor->momx, actor->y + actor->momy, false)) + { + actor->momx = actor->momy = 0; + P_SetMobjState(actor, locvar1); + return; + } + else + { + actor->momx = (2*actor->momx)/3; + actor->momy = (2*actor->momy)/3; + } + + P_TeleportMove(actor, x, y, z); + + // Spawn a particle every 3 tics. + if (!(leveltime % 3)) + { + mobj_t *particle = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_SPINDUST); + particle->tics = 10; + + P_SetScale(particle, 2*actor->scale/3); + particle->destscale = actor->scale; + P_SetObjectMomZ(particle, FRACUNIT, false); + } +} + +// Function: A_DoNPCPain +// +// Description: Something that looks like a player was hit, put them in pain. +// +// var1 = If zero, always fling the same amount. +// Otherwise, slowly reduce the vertical +// and horizontal speed to the base value +// multiplied by this the more damage is done. +// var2 = If zero, use default fling values. +// Otherwise, vertical and horizontal speed +// will be multiplied by this. +// +void A_DoNPCPain(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + fixed_t vspeed = 0; + fixed_t hspeed = FixedMul(4*FRACUNIT, actor->scale); + + if (LUA_CallAction("A_DoNPCPain", actor)) + return; + + actor->flags &= ~(MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT); + + var1 = var2 = 0; + A_Pain(actor); + + actor->z += P_MobjFlip(actor); + + if (actor->eflags & MFE_UNDERWATER) + vspeed = FixedDiv(10511*FRACUNIT,2600*FRACUNIT); + else + vspeed = FixedDiv(69*FRACUNIT,10*FRACUNIT); + + if (actor->target) + actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x + actor->target->momx, actor->target->y + actor->target->momy); + + if (locvar1) + { + if (!actor->info->spawnhealth) + return; // there's something very wrong here if you're using this action on something with no starting health + locvar1 += ((FRACUNIT - locvar1)/actor->info->spawnhealth)*actor->health; + hspeed = FixedMul(hspeed, locvar1); + vspeed = FixedMul(vspeed, locvar1); + } + + if (locvar2) + { + hspeed = FixedMul(hspeed, locvar2); + vspeed = FixedMul(vspeed, locvar2); + } + + P_SetObjectMomZ(actor, vspeed, false); + P_InstaThrust(actor, actor->angle, -hspeed); +} + +// Function: A_PrepareRepeat +// +// Description: Simple way to prepare A_Repeat. +// +// var1 = value to set extravalue2 to +// var2 = unused +// +void A_PrepareRepeat(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction("A_PrepareRepeat", actor)) + return; + + actor->extravalue2 = locvar1; +} + +// Function: A_Boss5ExtraRepeat +// +// Description: Simple way to prepare A_Repeat. +// +// var1 = maximum value to setextravalue2 to (normally) +// var2 = pinch annoyance +// +void A_Boss5ExtraRepeat(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + INT32 calc; + INT32 locspawn; + INT32 lochealth; + + if (LUA_CallAction("A_Boss5ExtraRepeat", actor)) + return; + + if (actor->extravalue2 > 0 && !(actor->flags2 & MF2_FRET)) + return; + + locspawn = actor->info->spawnhealth - actor->info->damage; + lochealth = actor->health - actor->info->damage; + + if (locspawn <= 0 || lochealth <= 0) + calc = locvar1; + else + calc = (locvar1*(locspawn - lochealth))/locspawn; + + if (calc > 2) + actor->extravalue2 = 1 + calc/2 + P_RandomKey(calc/2); + else + actor->extravalue2 = 1 + calc; + + if (lochealth <= 0) + actor->extravalue2 += locvar2; +} + +// Function: A_Boss5Calm +// +// Description: Simple way to disable MF2_FRET (and enable MF_SHOOTABLE the first time it's called) +// +// var1 = unused +// var2 = unused +// +void A_Boss5Calm(mobj_t *actor) +{ + if (LUA_CallAction("A_Boss5Calm", actor)) + return; + + actor->flags |= MF_SHOOTABLE; + actor->flags2 &= ~MF2_FRET; +} + +// Function: A_Boss5CheckOnGround +// +// Description: Ground checker. +// +// var1 = state to change to upon hitting ground. +// var2 = state to change to upon hitting ground if health == pinchhealth, assuming it exists +// +void A_Boss5CheckOnGround(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_Boss5CheckOnGround", actor)) + return; + + if ((!(actor->eflags & MFE_VERTICALFLIP) && actor->z <= actor->floorz) + || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height >= actor->ceilingz)) + { + if (locvar2 && (!actor->health || (actor->health == actor->info->damage && !(actor->flags2 & MF2_STRONGBOX)))) + P_SetMobjState(actor, locvar2); + else + P_SetMobjState(actor, locvar1); + } + + if (actor->tracer && P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y) < 2*actor->radius) + { + actor->momx = (4*actor->momx)/5; + actor->momy = (4*actor->momy)/5; + } +} + +// Function: A_Boss5CheckFalling +// +// Description: Falling checker. +// +// var1 = state to change to when hitting ground. +// var2 = state to change to when falling. +// +void A_Boss5CheckFalling(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_Boss5CheckFalling", actor)) + return; + + if (actor->health && actor->extravalue2 > 1) + { + var1 = locvar1; + var2 = 0; + A_Boss5CheckOnGround(actor); + return; + } + + if (P_MobjFlip(actor)*actor->momz <= 0) + P_SetMobjState(actor, locvar2); +} + +// Function: A_Boss5PinchShot +// +// Description: Fires a missile directly upwards if in pinch. +// +// var1 = object # to shoot +// var2 = height offset (from default of +48 FU) +// +void A_Boss5PinchShot(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + fixed_t zoffset; + mobj_t *missile; + + if (LUA_CallAction("A_Boss5PinchShot", actor)) + return; + + if (actor->health > actor->info->damage) + return; + + if (actor->eflags & MFE_VERTICALFLIP) + zoffset = actor->z + actor->height - FixedMul((48 + locvar2)*FRACUNIT, actor->scale); + else + zoffset = actor->z + FixedMul((48 + locvar2)*FRACUNIT, actor->scale); + + missile = P_SpawnPointMissile(actor, actor->x, actor->y, zoffset, locvar1, + actor->x, actor->y, zoffset); + + if (!missile) + return; + + missile->momx = missile->momy = 0; + missile->momz = P_MobjFlip(actor)*missile->info->speed/2; +} + +// Function: A_Boss5MakeItRain +// +// Description: Pinch crisis. +// +// var1 = object # to shoot +// var2 = height offset (from default of +48 FU) +// +void A_Boss5MakeItRain(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + INT32 offset = (48 + locvar2)<<16; // upper 16 bits, not fixed_t! + INT32 i; + + if (LUA_CallAction("A_Boss5MakeItRain", actor)) + return; + + actor->flags2 |= MF2_STRONGBOX; + + var1 = locvar1; + var2 = offset + 90; + A_TrapShot(actor); + + for (i = 0; i < 8; i++) + { + actor->angle += ANGLE_45; + + var1 = locvar1; + var2 = offset + (i & 1) ? 80 : 85; + A_TrapShot(actor); + } + + actor->extravalue2 = 0; +} + +// Function: A_Boss5MakeJunk +// +// Description: Make a mess. +// +// var1 = state # to set on MT_BROKENROBOT (if 0 do nothing, if -1 go to if colorized) +// var2 = mode (-1 = spin, 0 = make 1, & 1 make 8, & 2 alart mode) +// +void A_Boss5MakeJunk(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + mobj_t *broked = NULL; + angle_t ang; + INT32 i = ((locvar2 & 1) ? 8 : 1); + + if (LUA_CallAction("A_Boss5MakeJunk", actor)) + return; + + if (locvar1 < 0 && (actor->flags2 & MF2_SLIDEPUSH)) // this entire action is a hack, don't judge me + { + INT32 curextravalue2 = actor->extravalue2; + P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_PROJECTORLIGHT); + actor->z += P_MobjFlip(actor)*actor->height; + actor->flags |= MF_NOGRAVITY; + S_StartSound(actor, sfx_vwre); + actor->extravalue2 = 49; + P_SetMobjState(actor, -locvar1); + actor->extravalue2 = curextravalue2; + actor->angle -= FixedAngle((49*45)<extravalue2)/50; + if (trans > 9) + trans = 9; + if (trans < 0) + trans = 0; + if (!(actor->extravalue2 & 1)) + { + if (actor->extravalue2 > 10) + { + mobj_t *front = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_VWREF); + broked = P_SpawnMobjFromMobj(front, 0, 0, 0, MT_VWREB); + front->z = broked->z = front->z - broked->height; + P_SetObjectMomZ(front, (4<momz = front->momz; + broked->fuse = front->fuse = (actor->height+(2*front->height))/front->momz; + } + if (!(actor->colorized = !actor->colorized)) + actor->frame |= FF_FULLBRIGHT; + } + actor->angle += ANGLE_45; + actor->frame = (actor->frame & ~FF_TRANSMASK)|(trans<fuse = TICRATE; + else + broked->fuse = (((locvar2 & 1) ? 4 : 2)*TICRATE)/3; + broked->angle = ang; + P_InstaThrust(broked, ang, ((locvar2 & 2) ? 8 : 5)*actor->scale); + P_SetObjectMomZ(broked, (((locvar2) ? 4 : 0) + P_RandomRange(2, 5))< 0) + P_SetMobjState(broked, locvar1); + if (!P_MobjWasRemoved(broked)) + P_TeleportMove(broked, broked->x + broked->momx, broked->y + broked->momy, broked->z); + ang += ANGLE_45; + } + + if (locvar2 & 2) + { + broked = P_SpawnMobjFromMobj(actor, 0, 0, 64<fuse = states[S_FANG_INTRO12].tics+10; + P_SetMobjState(broked, S_ALART1); + } + else if (locvar2 & 1) + { + broked->z += broked->momz; + S_StartSound(actor, sfx_s3kccs); + actor->flags &= ~MF_NOCLIPTHING; + } + else + S_StartSound(actor, sfx_s3kd3s); +} + +// Function: A_LookForBetter +// +// Description: A_Look, except it finds a better target in multiplayer, and doesn't lose the target in singleplayer. +// +// var1 lower 16 bits = 0 - looks only in front, 1 - looks all around +// var1 upper 16 bits = distance limit +// var2 = unused +// +void A_LookForBetter(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction("A_LookForBetter", actor)) + return; + + P_LookForPlayers(actor, (locvar1 & 65535), false, FixedMul((locvar1 >> 16)*FRACUNIT, actor->scale)); + A_FaceTarget(actor); +} + +/* * Spawns a dust ring. + * The dust ring behaves slightly randomly so it doesn't look too uniform. + * + * \param mobjtype Thing type to make a ring of. + * \param div Amount of things to spawn on the ring. + * \param x Center X coordinates. + * \param y Center Y coordinates. + * \param z Center Z coordinates. + * \param radius Radius. + * \param speed Additional thrust on particles. + * \param initscale Initial scale when spawning. + * \param scale "Default" scale. + */ +static void P_DustRing(mobjtype_t mobjtype, UINT32 div, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t speed, fixed_t initscale, fixed_t scale) +{ + angle_t ang = FixedAngle(FixedDiv(360*FRACUNIT, div*FRACUNIT)); //(ANGLE_180/div)*2; + UINT32 i; + + // it turned out the radius was effectively nullified thanks to errors in the original script + // BUT people preferred how it looked before I "fixed" it, so I got rid of the radius calculations altogether + // this was a bit of a mess to sort out, but at least it's probably somewhat fine now? + // -- Monster Iestyn (21/05/19) + (void)radius; + + for (i = 0; i < div; i++) + { + mobj_t *dust = P_SpawnMobj( + x, //+ FixedMul(radius, FINECOSINE((ang*i) >> ANGLETOFINESHIFT)), + y, //+ FixedMul(radius, FINESINE((ang*i) >> ANGLETOFINESHIFT)), + z, + mobjtype + ); + + dust->angle = ang*i + ANGLE_90; + P_SetScale(dust, FixedMul(initscale, scale)); + dust->destscale = FixedMul(4*FRACUNIT + P_RandomFixed(), scale); + dust->scalespeed = scale/24; + P_Thrust(dust, ang*i, speed + FixedMul(P_RandomFixed(), scale)); + dust->momz = P_SignedRandom()*scale/64; + } +} + +// Function: A_Boss5BombExplode +// +// Description: Boss 5's bomb exploding. +// +// var1 = Thing type to spawn as dust +// var2 = unused +// +void A_Boss5BombExplode(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction("A_Boss5BombExplode", actor)) + return; + + // The original Lua script did not use |= to add flags but just set these flags exactly apparently? + // (I may modify this later) + // -- Monster Iestyn (21/05/19) + actor->flags = MF_NOCLIP|MF_NOGRAVITY|MF_NOBLOCKMAP; + actor->flags2 = MF2_EXPLOSION; + + if (actor->target) + P_RadiusAttack(actor, actor->target, 7*actor->radius, 0); + + P_DustRing(locvar1, 4, actor->x, actor->y, actor->z+actor->height, 2*actor->radius, 0, FRACUNIT, actor->scale); + P_DustRing(locvar1, 6, actor->x, actor->y, actor->z+actor->height/2, 3*actor->radius, FRACUNIT, FRACUNIT, actor->scale); + //P_StartQuake(9*actor->scale, TICRATE/6, {actor->x, actor->y, actor->z}, 20*actor->radius); + // the above does not exist, so we set the quake values directly instead + quake.intensity = 9*actor->scale; + quake.time = TICRATE/6; + // the following quake values have no effect atm? ah well, may as well set them anyway + { + mappoint_t q_epicenter = {actor->x, actor->y, actor->z}; + quake.epicenter = &q_epicenter; + } + quake.radius = 20*actor->radius; +} + +static mobj_t *dustdevil; + +static boolean PIT_DustDevilLaunch(mobj_t *thing) +{ + player_t *player = thing->player; + + if (!player) + return true; + + if (abs(thing->x - dustdevil->x) > dustdevil->radius || abs(thing->y - dustdevil->y) > dustdevil->radius) + return true; + + if (thing->z + thing->height >= dustdevil->z && dustdevil->z + dustdevil->height >= thing->z) { + fixed_t pos = thing->z - dustdevil->z; + fixed_t thrust = max(FixedDiv(pos, dustdevil->height) * 20, 8 * FRACUNIT); + angle_t fa = R_PointToAngle2(thing->x, thing->y, dustdevil->x, dustdevil->y) >> ANGLETOFINESHIFT; + fixed_t c = FINECOSINE(fa); + fixed_t s = FINESINE(fa); + fixed_t thresh = dustdevil->scale * 20; + + //Player in the swirl part. + if (dustdevil->height - pos > thresh) + { + fixed_t dist = FixedHypot(thing->x - dustdevil->x, thing->y - dustdevil->y); + fixed_t dragamount = player->speed; + fixed_t x, y; + + if (player->powers[pw_nocontrol] == 0) + { + P_ResetPlayer(player); + A_PlayActiveSound(dustdevil); + } + player->powers[pw_nocontrol] = 2; + player->drawangle += ANG20; + P_SetPlayerMobjState(thing, S_PLAY_PAIN); + + if (dist > dragamount) + { + x = thing->x + FixedMul(c, dragamount); + y = thing->y + FixedMul(s, dragamount); + } + else + { + x = dustdevil->x; + y = dustdevil->y; + } + P_TryMove(thing, x - thing->momx, y - thing->momy, true); + } + else + { //Player on the top of the tornado. + P_ResetPlayer(player); + thing->z = dustdevil->z + dustdevil->height; + thrust = 20 * FRACUNIT; + player->powers[pw_nocontrol] = 0; + S_StartSound(thing, sfx_wdjump); + P_SetPlayerMobjState(thing, S_PLAY_FALL); + } + + thing->momz = thrust; + } + + return true; +} + +// Function: A_DustDevilThink +// +// Description: Thinker for the dust devil. +// +// var1 = unused +// var2 = unused +// +void A_DustDevilThink(mobj_t *actor) +{ + fixed_t scale = actor->scale; + mobj_t *layer = actor->tracer; + INT32 bx, by, xl, xh, yl, yh; + fixed_t radius = actor->radius; + + if (LUA_CallAction("A_DustDevilThink", actor)) + return; + + //Chained thinker for the spiralling dust column. + while (layer && !P_MobjWasRemoved(layer)) { + angle_t fa = layer->angle >> ANGLETOFINESHIFT; + P_TeleportMove(layer, layer->x + 5 * FixedMul(scale, FINECOSINE(fa)), layer->y + 5 * FixedMul(scale, FINESINE(fa)), layer->z); + layer->scale = scale; + layer->angle += ANG10 / 2; + layer->momx = actor->momx; + layer->momy = actor->momy; + layer = layer->tracer; + } + + //Spawn random dust around the column on the base. + if (P_IsObjectOnGround(actor)) { + angle_t dustang = ((P_RandomRange(0, 7)*ANGLE_45)>>ANGLETOFINESHIFT) & FINEMASK; + mobj_t *dust = P_SpawnMobj(actor->x + 96 * FixedMul(scale, FINECOSINE(dustang)), actor->y + 96 * FixedMul(scale, FINESINE(dustang)), actor->z, MT_ARIDDUST); + P_SetMobjState(dust, dust->info->spawnstate + P_RandomRange(0, 2)); + dust->destscale = scale * 3; + P_SetScale(dust, dust->destscale); + } + + actor->extravalue1++; + if (actor->extravalue1 == 12) { + size_t i = 0; + actor->extravalue1 = 0; + + //Create a set of items for the rising dust column + for (; i <= 3; i++) { + fixed_t fa = (ANGLE_90*i) >> ANGLETOFINESHIFT; + fixed_t px = actor->x + 70 * FixedMul(scale, FINECOSINE(fa)); + fixed_t py = actor->y + 70 * FixedMul(scale, FINESINE(fa)); + fixed_t pz = actor->z; + + layer = P_SpawnMobj(px, py, pz, MT_DUSTLAYER); + layer->momz = 5 * scale; + layer->angle = ANGLE_90 + ANGLE_90*i; + layer->extravalue1 = TICRATE * 3; + + //Chain them + P_SetTarget(&layer->tracer, actor->tracer); + P_SetTarget(&actor->tracer, layer); + } + } + + //The physics are handled here. + yh = (unsigned)(actor->y + radius - bmaporgy) >> MAPBLOCKSHIFT; + yl = (unsigned)(actor->y - radius - bmaporgy) >> MAPBLOCKSHIFT; + xh = (unsigned)(actor->x + radius - bmaporgx) >> MAPBLOCKSHIFT; + xl = (unsigned)(actor->x - radius - bmaporgx) >> MAPBLOCKSHIFT; + + BMBOUNDFIX(xl, xh, yl, yh); + + dustdevil = actor; + + for (bx = xl; bx <= xh; bx++) + for (by = yl; by <= yh; by++) + P_BlockThingsIterator(bx, by, PIT_DustDevilLaunch); + + //Whirlwind sound effect. + if (leveltime % 70 == 0) + S_StartSound(actor, sfx_s3kcel); +} + +// stuff used by A_TNTExplode +static mobj_t *barrel; +static fixed_t exploderadius; +static fixed_t explodethrust; + +static boolean PIT_TNTExplode(mobj_t *nearby) +{ + fixed_t dx, dy, dz; + fixed_t dm; + + if (nearby == barrel) + return true; + + dx = nearby->x - barrel->x; + dy = nearby->y - barrel->y; + dz = nearby->z - barrel->z + (nearby->height - barrel->height/2)/2; + dm = P_AproxDistance(P_AproxDistance(dx, dy), dz); + + if (dm >= exploderadius || !P_CheckSight(barrel, nearby)) // out of range or not visible + return true; + + if (barrel->type == nearby->type) // nearby is also a barrel + { + if (nearby->state == &states[nearby->info->spawnstate]) + { + if (barrel->info->attacksound) + S_StartSound(nearby, barrel->info->attacksound); + nearby->momx = FixedMul(FixedDiv(dx, dm), explodethrust); + nearby->momy = FixedMul(FixedDiv(dy, dm), explodethrust); + nearby->momz = FixedMul(FixedDiv(dz, dm), explodethrust); + P_UnsetThingPosition(nearby); + if (sector_list) + { + P_DelSeclist(sector_list); + sector_list = NULL; + } + nearby->flags = MF_NOBLOCKMAP|MF_MISSILE; + P_SetThingPosition(nearby); + P_SetMobjState(nearby, nearby->info->missilestate); + } + } + else + { + if (barrel->target == nearby) + { + mobj_t *tar = barrel->target; // temporarily store barrel's target + P_SetTarget(&barrel->target, NULL); + P_DamageMobj(nearby, barrel, NULL, 1, 0); + if (!P_MobjWasRemoved(barrel)) + P_SetTarget(&barrel->target, tar); + } + else + { + P_DamageMobj(nearby, + (barrel->target) ? barrel->target : barrel, + (barrel->target) ? barrel->target : barrel, + 1, 0); + } + } + + return true; +} + +// Function: A_TNTExplode +// +// Description: Creates a TNT explosion. Used by TNT barrels and the like. +// +// var1 = Thing type to spawn as dust. +// var2 = unused +// +void A_TNTExplode(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 x, y; + INT32 xl, xh, yl, yh; + static mappoint_t epicenter = {0,0,0}; + + if (LUA_CallAction("A_TNTExplode", actor)) + return; + + if (actor->tracer) + { + P_SetTarget(&actor->tracer->tracer, NULL); + P_SetTarget(&actor->tracer, NULL); + } + + P_UnsetThingPosition(actor); + if (sector_list) + { + P_DelSeclist(sector_list); + sector_list = NULL; + } + actor->flags = MF_NOCLIP|MF_NOGRAVITY|MF_NOBLOCKMAP; + P_SetThingPosition(actor); + actor->flags2 = MF2_EXPLOSION; + if (actor->info->deathsound) + S_StartSound(actor, actor->info->deathsound); + + explodethrust = 32*FRACUNIT; + exploderadius = 256*FRACUNIT; + + xl = (unsigned)(actor->x - exploderadius - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(actor->x + exploderadius - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(actor->y - exploderadius - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(actor->y + exploderadius - bmaporgy)>>MAPBLOCKSHIFT; + + BMBOUNDFIX(xl, xh, yl, yh); + + barrel = actor; + + for (x = xl; x <= xh; x++) + for (y = yl; y <= yh; y++) + P_BlockThingsIterator(x, y, PIT_TNTExplode); + + // cause a quake -- P_StartQuake does not exist yet + epicenter.x = actor->x; + epicenter.y = actor->y; + epicenter.z = actor->z; + quake.intensity = 9*FRACUNIT; + quake.time = TICRATE/6; + quake.epicenter = &epicenter; + quake.radius = 512*FRACUNIT; + + if (locvar1) + { + P_DustRing(locvar1, 4, actor->x, actor->y, actor->z+actor->height, 64, 0, FRACUNIT, actor->scale); + P_DustRing(locvar1, 6, actor->x, actor->y, actor->z+actor->height/2, 96, FRACUNIT, FRACUNIT, actor->scale); + } + + actor->destscale *= 4; +} + +// Function: A_DebrisRandom +// +// Description: Randomizes debris frame and movement. +// +// var1 = Frame range. +// var2 = unused +// +void A_DebrisRandom(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction("A_DebrisRandom", actor)) + return; + + actor->frame |= P_RandomRange(0, locvar1); + var1 = 0; + var2 = 359; + A_ChangeAngleAbsolute(actor); + P_Thrust(actor, actor->angle, FRACUNIT * 2); +} + +static mobj_t *P_TrainSeg(mobj_t *src, fixed_t x, fixed_t y, fixed_t z, angle_t ang, spritenum_t spr, UINT32 frame) +{ + mobj_t *s = P_SpawnMobj(x, y, z, MT_TRAINSEG); + s->fuse = 16*TICRATE; + s->sprite = spr; + s->frame = frame|FF_PAPERSPRITE; + s->angle = ang; + P_Thrust(s, src->angle, 7*FRACUNIT); + return s; +} + +// Function: A_TrainCameo +// +// Description: Sets up train cameo locomotive. +// +// var1 = Train width. +// var2 = Train length. +// +void A_TrainCameo(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + fixed_t x = actor->x; + fixed_t y = actor->y; + fixed_t z = actor->z; + angle_t ang = actor->angle; + mobj_t *m; + spritenum_t spr = SPR_TRAE; + fixed_t span = locvar1*FRACUNIT; + fixed_t len = locvar2*FRACUNIT; + + if (LUA_CallAction("A_TrainCameo", actor)) + return; + + //Spawn sides. + P_TrainSeg(actor, x, y + span, z, ang, spr, 0); + P_TrainSeg(actor, x, y - span, z, ang, spr, 0); + + //Center. + P_TrainSeg(actor, x, y, z, ang, spr, 1); + + //Front and back. + P_TrainSeg(actor, x + len, y, z, ang + ANGLE_90, spr, 2); + P_TrainSeg(actor, x - len, y, z, ang + ANGLE_90, spr, 2); + + //Smoke spawner. + m = P_TrainSeg(actor, x - (20 * FRACUNIT), y, z + (30 * FRACUNIT), ang + ANGLE_90, spr, 0); + P_SetMobjState(m, S_TRAINPUFFMAKER); +} + +// Function: A_TrainCameo2 +// +// Description: Sets up train cameo wagon. +// +// var1 = Train width. +// var2 = Train length. +// +void A_TrainCameo2(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + fixed_t x = actor->x; + fixed_t y = actor->y; + fixed_t z = actor->z; + angle_t ang = actor->angle; + spritenum_t spr = SPR_TRAI; + fixed_t span = locvar1*FRACUNIT; + fixed_t len = locvar2*FRACUNIT; + + if (LUA_CallAction("A_TrainCameo2", actor)) + return; + + //Spawn sides. + P_TrainSeg(actor, x, y + span, z, ang, spr, 0); + P_TrainSeg(actor, x, y - span, z, ang, spr, 0); + + //Center. + P_TrainSeg(actor, x, y, z, ang, spr, 1); + + //Front and back. + P_TrainSeg(actor, x + len, y, z, ang + ANGLE_90, spr, 2); + P_TrainSeg(actor, x - len, y, z, ang + ANGLE_90, spr, 2); +} + +// Function: A_CanarivoreGas +// +// Description: Releases gas clouds. Used by the Canarivore. +// +// var1 = Mobj type. +// var2 = Unused +// +void A_CanarivoreGas(mobj_t *actor) +{ + INT32 locvar1 = var1; + + if (LUA_CallAction("A_CanarivoreGas", actor)) + return; + + P_DustRing(locvar1, 4, actor->x, actor->y, actor->z + actor->height / 5, 18, 0, FRACUNIT/10, actor->scale); + P_DustRing(locvar1, 6, actor->x, actor->y, actor->z + actor->height / 5, 28, FRACUNIT, FRACUNIT/10, actor->scale); +} + +// +// Function: A_KillSegments +// +// Description: Causes segments attached via tracer chain to be killed. +// +// var1 = Fuse (if 0, default to TICRATE/2). +// var2 = Unused +// +void A_KillSegments(mobj_t *actor) +{ + INT32 locvar1 = var1; + mobj_t *seg = actor->tracer; + INT32 fuse = locvar1 ? locvar1 : TICRATE/2; + + if (LUA_CallAction("A_KillSegments", actor)) + return; + + while (seg) + { + mobj_t *kseg = seg; + seg = seg->tracer; + + kseg->flags = MF_NOBLOCKMAP|MF_BOUNCE; + kseg->flags2 = 0; + kseg->fuse = fuse; + P_Thrust(kseg, R_PointToAngle2(actor->x, actor->y, kseg->x, kseg->y), 3*actor->scale); + kseg->momz = 3*actor->scale; + } +} + +static void P_SnapperLegPlace(mobj_t *mo) +{ + mobj_t *seg = mo->tracer; + angle_t a = mo->angle; + angle_t fa = (a >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t c = FINECOSINE(fa); + fixed_t s = FINESINE(fa); + fixed_t x, y; + INT32 o1, o2; + INT32 woffset = mo->extravalue1; + INT32 side = mo->extravalue2; + INT32 alt; + + // Move head first. + fixed_t rad = mo->radius; + INT32 necklen = (32*(mo->info->reactiontime - mo->reactiontime))/mo->info->reactiontime; // Not in FU + + seg->z = mo->z + ((mo->eflags & MFE_VERTICALFLIP) ? (((mo->height<<1)/3) - seg->height) : mo->height/3); + P_TryMove(seg, mo->x + FixedMul(c, rad) + necklen*c, mo->y + FixedMul(s, rad) + necklen*s, true); + seg->angle = a; + + // Move as many legs as available. + seg = seg->tracer; + do + { + o1 = seg->extravalue1; + o2 = seg->extravalue2; + alt = seg->cusval; + + if (alt == 1) + o2 += woffset; + else + o2 -= woffset; + + if (alt != side) + { + x = c*o2 + s*o1; + y = s*o2 - c*o1; + seg->z = mo->z + (((mo->eflags & MFE_VERTICALFLIP) ? (mo->height - seg->height) : 0)); + P_TryMove(seg, mo->x + x, mo->y + y, true); + P_SetMobjState(seg, seg->info->raisestate); + } + else + P_SetMobjState(seg, seg->info->spawnstate); + + seg->angle = R_PointToAngle2(mo->x, mo->y, seg->x, seg->y); + + seg = seg->tracer; + } while (seg); +} + +// +// Function: A_SnapperSpawn +// +// Description: Sets up Green Snapper legs and head. +// +// var1 = Leg mobj type. +// var2 = Head mobj type. +// +void A_SnapperSpawn(mobj_t *actor) +{ + mobjtype_t legtype = (mobjtype_t)var1; + mobjtype_t headtype = (mobjtype_t)var2; + mobj_t *ptr = actor; + INT32 i; + mobj_t *seg; + + if (LUA_CallAction("A_SnapperSpawn", actor)) + return; + + // It spawns 1 head. + seg = P_SpawnMobjFromMobj(actor, 0, 0, 0, headtype); + P_SetTarget(&ptr->tracer, seg); + ptr = seg; + + // It spawns 4 legs which will be handled in the thinker function. + for (i = 1; i <= 4; i++) + { + seg = P_SpawnMobjFromMobj(actor, 0, 0, 0, legtype); + P_SetTarget(&ptr->tracer, seg); + ptr = seg; + + // The legs' base offsets are stored as extravalues, as relative coordinates in xy space. + seg->extravalue1 = 28; + seg->extravalue2 = 28; + if (i % 2) + seg->extravalue1 = -seg->extravalue1; + + if ((i/2) % 2) + seg->extravalue2 = -seg->extravalue2; + + // Alternating motion stuff. + seg->cusval = ((i + 1)/2) % 2; + } + + actor->extravalue1 = 0; + actor->extravalue2 = 0; + P_SnapperLegPlace(actor); +} + +// +// Function: A_SnapperThinker +// +// Description: Thinker for Green Snapper. +// +// var1 = Unused +// var2 = Unused +// +void A_SnapperThinker(mobj_t *actor) +{ + fixed_t x0 = actor->x; + fixed_t y0 = actor->y; + fixed_t xs, ys; + fixed_t x1, y1; + fixed_t dist; + boolean chasing; + + if (LUA_CallAction("A_SnapperThinker", actor)) + return; + + // We make a check just in case there's no spawnpoint. + if (actor->spawnpoint) + { + xs = actor->spawnpoint->x*FRACUNIT; + ys = actor->spawnpoint->y*FRACUNIT; + } + else + { + xs = x0; + ys = y0; + } + + // Look for nearby, valid players to chase angrily at. + if ((actor->target || P_LookForPlayers(actor, true, false, 1024*FRACUNIT)) + && P_AproxDistance(actor->target->x - xs, actor->target->y - ys) < 2048*FRACUNIT + && abs(actor->target->z - actor->z) < 80*FRACUNIT + && P_CheckSight(actor, actor->target)) + { + chasing = true; + x1 = actor->target->x; + y1 = actor->target->y; + } + else + { + chasing = false; + x1 = xs; + y1 = ys; + } + + dist = P_AproxDistance(x1 - x0, y1 - y0); + + // The snapper either chases what it considers to be a nearby player, or instead decides to go back to its spawnpoint. + if (chasing || dist > 32*FRACUNIT) + { + INT32 speed = actor->info->speed + actor->info->reactiontime - actor->reactiontime; + + angle_t maxang = FixedAngle(speed*FRACUNIT/2); + angle_t ang = actor->angle; + angle_t realang = R_PointToAngle2(x0, y0, x1, y1); + angle_t dif = realang - ang; + angle_t fa; + fixed_t c, s; + + if (dif < ANGLE_180 && dif > maxang) + actor->angle += maxang; + else if (dif >= ANGLE_180 && dif < InvAngle(maxang)) + actor->angle -= maxang; + else + actor->angle = realang; + + fa = (actor->angle >> ANGLETOFINESHIFT) & FINEMASK; + c = FINECOSINE(fa); + s = FINESINE(fa); + + P_TryMove(actor, actor->x + c*speed, actor->y + s*speed, false); + + // The snapper spawns dust if going fast! + if (actor->reactiontime < 4) + { + mobj_t *dust = P_SpawnMobj(x0, y0, actor->z, MT_SPINDUST); + P_Thrust(dust, ang + ANGLE_180 + FixedAngle(P_RandomRange(-20, 20)*FRACUNIT), speed*FRACUNIT); + } + + if (actor->extravalue2 == 0) + { + if (actor->extravalue1 > 16) + { + A_PlayActiveSound(actor); + actor->extravalue2 = 1; + + // If the snapper is chasing, accelerate; otherwise, decelerate. + if (chasing) + actor->reactiontime = max(0, actor->reactiontime - 1); + else + actor->reactiontime = min(actor->info->reactiontime, actor->reactiontime + 1); + } + else + actor->extravalue1 += speed; + } + else + { + if (actor->extravalue1 < -16) + { + A_PlayActiveSound(actor); + actor->extravalue2 = 0; + + // If the snapper is chasing, accelerate; otherwise, decelerate. + if (chasing) + actor->reactiontime = max(0, actor->reactiontime - 1); + else + actor->reactiontime = min(actor->info->reactiontime, actor->reactiontime + 1); + } + else + actor->extravalue1 -= speed; + } + } + + P_SnapperLegPlace(actor); +} + +// Function: A_SaloonDoorSpawn +// +// Description: Spawns a saloon door. +// +// var1 = mobjtype for sides +// var2 = distance sides should be placed apart +// +void A_SaloonDoorSpawn(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + angle_t ang = actor->angle; + angle_t fa = (ang >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t c = FINECOSINE(fa)*locvar2; + fixed_t s = FINESINE(fa)*locvar2; + mobj_t *door; + mobjflag2_t ambush = (actor->flags2 & MF2_AMBUSH); + + if (LUA_CallAction("A_SaloonDoorSpawn", actor)) + return; + + if (!locvar1) + return; + + // One door... + if (!(door = P_SpawnMobjFromMobj(actor, c, s, 0, locvar1))) return; + door->angle = ang + ANGLE_180; + door->extravalue1 = AngleFixed(door->angle); // Origin angle + door->extravalue2 = 0; // Angular speed + P_SetTarget(&door->tracer, actor); // Origin door + door->flags2 |= ambush; // Can be opened by normal players? + + // ...two door! + if (!(door = P_SpawnMobjFromMobj(actor, -c, -s, 0, locvar1))) return; + door->angle = ang; + door->extravalue1 = AngleFixed(door->angle); // Origin angle + door->extravalue2 = 0; // Angular speed + P_SetTarget(&door->tracer, actor); // Origin door + door->flags2 |= ambush; // Can be opened by normal players? +} + +// Function: A_MinecartSparkThink +// +// Description: Thinker for the minecart spark. +// +// var1 = unused +// var2 = unused +// +void A_MinecartSparkThink(mobj_t *actor) +{ + fixed_t dx = actor->momx; + fixed_t dy = actor->momy; + fixed_t dz, dm; + UINT8 i; + + if (LUA_CallAction("A_MinecartSparkThink", actor)) + return; + + if (actor->momz == 0 && P_IsObjectOnGround(actor)) + actor->momz = P_RandomRange(2, 4)*FRACUNIT; + + dz = actor->momz; + dm = FixedHypot(FixedHypot(dx, dy), dz); + dx = FixedDiv(dx, dm); + dy = FixedDiv(dy, dm); + dz = FixedDiv(dz, dm); + + for (i = 1; i <= 8; i++) + { + mobj_t *trail = P_SpawnMobj(actor->x - dx*i, actor->y - dy*i, actor->z - dz*i, MT_PARTICLE); + trail->tics = 2; + trail->sprite = actor->sprite; + P_SetScale(trail, trail->scale/4); + trail->destscale = trail->scale; + } +} + +// Function: A_ModuloToState +// +// Description: Modulo operation to state +// +// var1 = Modulo +// var2 = State +// +void A_ModuloToState(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_ModuloToState", actor)) + return; + + if ((modulothing % locvar1 == 0)) + P_SetMobjState(actor, (locvar2)); + modulothing++; +} + +// Function: A_LavafallRocks +// +// Description: Spawn random rock particles. +// +// var1 = unused +// var2 = unused +// +void A_LavafallRocks(mobj_t *actor) +{ + UINT8 i; + + if (LUA_CallAction("A_LavafallRocks", actor)) + return; + + // Don't spawn rocks unless a player is relatively close by. + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && players[i].mo + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed >> 1)) + break; // Stop looking. + + if (i < MAXPLAYERS) + { + angle_t fa = (FixedAngle(P_RandomKey(360) << FRACBITS) >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t offset = P_RandomRange(4, 12) << FRACBITS; + fixed_t xoffs = FixedMul(FINECOSINE(fa), actor->radius + offset); + fixed_t yoffs = FixedMul(FINESINE(fa), actor->radius + offset); + P_SpawnMobjFromMobj(actor, xoffs, yoffs, 0, MT_LAVAFALLROCK); + } +} + +// Function: A_LavafallLava +// +// Description: Spawn lava from lavafall. +// +// var1 = unused +// var2 = unused +// +void A_LavafallLava(mobj_t *actor) +{ + mobj_t *lavafall; + UINT8 i; + + if (LUA_CallAction("A_LavafallLava", actor)) + return; + + if ((40 - actor->fuse) % (2*(actor->scale >> FRACBITS))) + return; + + // Don't spawn lava unless a player is nearby. + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && players[i].mo + && P_AproxDistance(actor->x - players[i].mo->x, actor->y - players[i].mo->y) < (actor->info->speed)) + break; // Stop looking. + + if (i >= MAXPLAYERS) + return; + + lavafall = P_SpawnMobjFromMobj(actor, 0, 0, -8*FRACUNIT, MT_LAVAFALL_LAVA); + lavafall->momz = -P_MobjFlip(actor)*25*FRACUNIT; +} + +// Function: A_FallingLavaCheck +// +// Description: If actor hits the ground or a water surface, enter the death animation. +// +// var1 = unused +// var2 = unused +// +void A_FallingLavaCheck(mobj_t *actor) +{ + if (LUA_CallAction("A_FallingLavaCheck", actor)) + return; + + if (actor->eflags & MFE_TOUCHWATER || P_IsObjectOnGround(actor)) + { + actor->flags = MF_NOGRAVITY|MF_NOCLIPTHING; + actor->momz = 0; + if (actor->eflags & MFE_TOUCHWATER) + actor->z = (actor->eflags & MFE_VERTICALFLIP) ? actor->waterbottom : actor->watertop; + P_SetMobjState(actor, actor->info->deathstate); + } +} + +// Function: A_FireShrink +// +// Description: Shrink the actor down to the specified scale at the specified speed. +// +// var1 = Scale to shrink to +// var2 = Shrinking speed +// +void A_FireShrink(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_FireShrink", actor)) + return; + + actor->destscale = locvar1; + actor->scalespeed = FRACUNIT/locvar2; +} + +// Function: A_SpawnPterabytes +// +// Description: Spawn Pterabytes around the actor in a circle. +// +// var1 = unused +// var2 = unused +// +void A_SpawnPterabytes(mobj_t *actor) +{ + mobj_t *waypoint, *ptera; + fixed_t c, s; + fixed_t rad = 280*FRACUNIT; + angle_t ang = 0; + angle_t interval, fa; + UINT8 amount = 1; + UINT8 i; + + if (LUA_CallAction("A_SpawnPterabytes", actor)) + return; + + if (actor->spawnpoint) + amount = actor->spawnpoint->extrainfo + 1; + + interval = FixedAngle(FRACUNIT*360/amount); + + for (i = 0; i < amount; i++) + { + fa = (ang >> ANGLETOFINESHIFT) & FINEMASK; + c = FINECOSINE(fa); + s = FINESINE(fa); + waypoint = P_SpawnMobjFromMobj(actor, FixedMul(c, rad), FixedMul(s, rad), 0, MT_PTERABYTEWAYPOINT); + waypoint->angle = ang + ANGLE_90; + P_SetTarget(&waypoint->tracer, actor); + ptera = P_SpawnMobjFromMobj(waypoint, 0, 0, 0, MT_PTERABYTE); + ptera->angle = waypoint->angle; + P_SetTarget(&ptera->tracer, waypoint); + ptera->extravalue1 = 0; + ang += interval; + } +} + +// Function: A_PterabyteHover +// +// Description: Hover in a circular fashion, bobbing up and down slightly. +// +// var1 = unused +// var2 = unused +// +void A_PterabyteHover(mobj_t *actor) +{ + angle_t ang, fa; + + if (LUA_CallAction("A_PterabyteHover", actor)) + return; + + P_InstaThrust(actor, actor->angle, actor->info->speed); + actor->angle += ANG1; + actor->extravalue1 = (actor->extravalue1 + 3) % 360; + ang = actor->extravalue1*ANG1; + fa = (ang >> ANGLETOFINESHIFT) & FINEMASK; + actor->z += FINESINE(fa); +} +// Function: A_RolloutSpawn +// +// Description: Spawns a new Rollout Rock when the currently spawned rock is destroyed or moves far enough away. +// +// var1 = Distance currently spawned rock should travel before spawning a new one +// var2 = Object type to spawn +// +void A_RolloutSpawn(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + + if (LUA_CallAction("A_RolloutSpawn", actor)) + return; + + if (!(actor->target) + || P_MobjWasRemoved(actor->target) + || P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) > locvar1) + { + actor->target = P_SpawnMobj(actor->x, actor->y, actor->z, locvar2); + actor->target->flags2 |= (actor->flags2 & (MF2_AMBUSH | MF2_OBJECTFLIP)) | MF2_SLIDEPUSH; + actor->target->eflags |= (actor->eflags & MFE_VERTICALFLIP); + + if (actor->target->flags2 & MF2_AMBUSH) + { + actor->target->color = SKINCOLOR_SUPERRUST3; + actor->target->colorized = true; + } + } +} + +// Function: A_RolloutRock +// +// Description: Thinker for Rollout Rock. +// +// var1 = Drag +// var2 = Vertical bobbing speed factor +// +void A_RolloutRock(mobj_t *actor) +{ + INT32 locvar1 = var1; + INT32 locvar2 = var2; + UINT8 maxframes = actor->info->reactiontime; // number of frames the mobj cycles through + fixed_t pi = (22*FRACUNIT/7); + fixed_t circumference = FixedMul(2 * pi, actor->radius); // used to calculate when to change frame + fixed_t speed = P_AproxDistance(actor->momx, actor->momy), topspeed = FixedMul(actor->info->speed, actor->scale); + boolean inwater = actor->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER); + + if (LUA_CallAction("A_RolloutRock", actor)) + return; + + actor->friction = FRACUNIT; // turns out riding on solids sucks, so let's just make it easier on ourselves + + if (actor->eflags & MFE_JUSTHITFLOOR) + S_StartSound(actor, actor->info->painsound); + + if (actor->threshold) + actor->threshold--; + + if (inwater && !(actor->flags2 & MF2_AMBUSH)) // buoyancy in water (or lava) + { + UINT8 flip = P_MobjFlip(actor); + fixed_t prevmomz = actor->momz; + actor->momz = FixedMul(actor->momz, locvar2); + actor->momz += flip * FixedMul(locvar2, actor->scale); + if (flip*prevmomz < 0 && flip*actor->momz >= 0 && !actor->threshold) + { + if (actor->eflags & MFE_UNDERWATER) + S_StartSound(actor, sfx_splash); + else if (!actor->threshold) + S_StartSound(actor, sfx_splish); + actor->threshold = max((topspeed - speed) >> FRACBITS, 8); + } + } + + if (speed > topspeed) // cap speed + { + actor->momx = FixedMul(FixedDiv(actor->momx, speed), topspeed); + actor->momy = FixedMul(FixedDiv(actor->momy, speed), topspeed); + } + + if (P_IsObjectOnGround(actor) || inwater) // apply drag to speed (compensates for lack of friction but also works in liquids) + { + actor->momx = FixedMul(actor->momx, locvar1); + actor->momy = FixedMul(actor->momy, locvar1); + } + + speed = P_AproxDistance(actor->momx, actor->momy); // recalculate speed for visual rolling + + if (speed < actor->scale >> 1) // stop moving if speed is insignificant + { + actor->momx = 0; + actor->momy = 0; + } + else if (speed > actor->scale) + { + actor->movecount = 1; // rock has moved; fuse should be set so we don't have a trillion rocks lying around + actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy); // set rock's angle to movement direction + actor->movefactor += speed; + if (actor->movefactor > circumference / maxframes) // if distance moved is enough to change frame, change it! + { + actor->reactiontime++; + actor->reactiontime %= maxframes; + actor->movefactor = 0; + } + } + + actor->frame = actor->reactiontime % maxframes; // set frame + + if (!actor->tracer || P_MobjWasRemoved(actor->tracer) || !actor->tracer->health) + actor->flags |= MF_PUSHABLE; + + if (!(actor->flags & MF_PUSHABLE) || (actor->movecount != 1)) // if being ridden or haven't moved, don't disappear + actor->fuse = actor->info->painchance; + else if (actor->fuse < 2*TICRATE) + actor->flags2 ^= MF2_DONTDRAW; + +} + +// Function: A_DragonbomberSpawn +// +// Description: Spawns the body parts for Dragonbomber +// +// var1 = Tail segments to spawn +// var2 = unused +// +void A_DragonbomberSpawn(mobj_t *actor) +{ + UINT8 i; + mobj_t *mo = actor; + + if (LUA_CallAction("A_DragonbomberSpawn", actor)) + return; + + for (i = 0; i < var1; i++) // spawn tail segments + { + mobj_t *segment; + fixed_t x, y; + x = P_ReturnThrustX(mo, mo->angle, -mo->radius << 1); + y = P_ReturnThrustY(mo, mo->angle, -mo->radius << 1); + segment = P_SpawnMobjFromMobj(mo, x, y, 0, MT_DRAGONTAIL); + P_SetTarget(&segment->target, mo); + P_SetTarget(&mo->tracer, segment); + segment->angle = mo->angle; + mo = segment; + } + for (i = 0; i < 2; i++) // spawn wings + { + mo = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_DRAGONWING); + P_SetTarget(&mo->target, actor); + mo->movedir = ANGLE_90 + i * ANGLE_180; + } +} + +// Function: A_DragonWing +// +// Description: Moves actor such that it is placed away from its target at a distance equal to the target's radius in the direction of its target's angle. +// The actor's movedir can be used to offset the angle. +// +// var1 = unused +// var2 = unused +// +void A_DragonWing(mobj_t *actor) +{ + mobj_t *target = actor->target; + fixed_t x, y; + + if (LUA_CallAction("A_DragonWing", actor)) + return; + + if (target == NULL || !target->health) + { + P_RemoveMobj(actor); + return; + } + actor->angle = target->angle + actor->movedir; + x = target->x + P_ReturnThrustX(actor, actor->angle, -target->radius); + y = target->y + P_ReturnThrustY(actor, actor->angle, -target->radius); + P_TeleportMove(actor, x, y, target->z); +} + +// Function: A_DragonSegment +// +// Description: Moves actor such that it is placed away from its target at an absolute distance equal to the sum of the two mobjs' radii. +// +// var1 = unused +// var2 = unused +// +void A_DragonSegment(mobj_t *actor) +{ + mobj_t *target = actor->target; + fixed_t dist; + fixed_t radius; + angle_t hangle; + angle_t zangle; + fixed_t hdist; + fixed_t xdist; + fixed_t ydist; + fixed_t zdist; + + if (LUA_CallAction("A_DragonSegment", actor)) + return; + + if (target == NULL || !target->health) + { + P_RemoveMobj(actor); + return; + } + + dist = P_AproxDistance(P_AproxDistance(actor->x - target->x, actor->y - target->y), actor->z - target->z); + radius = actor->radius + target->radius; + hangle = R_PointToAngle2(target->x, target->y, actor->x, actor->y); + zangle = R_PointToAngle2(0, target->z, dist, actor->z); + hdist = P_ReturnThrustX(target, zangle, radius); + xdist = P_ReturnThrustX(target, hangle, hdist); + ydist = P_ReturnThrustY(target, hangle, hdist); + zdist = P_ReturnThrustY(target, zangle, radius); + + actor->angle = hangle; + P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist); +} diff --git a/src/p_floor.c b/src/p_floor.c index 6db4310ac..9c5ab9057 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -13,7 +13,11 @@ #include "doomdef.h" #include "doomstat.h" +#include "m_random.h" #include "p_local.h" +#ifdef ESLOPE +#include "p_slopes.h" +#endif #include "r_state.h" #include "s_sound.h" #include "z_zone.h" @@ -715,6 +719,8 @@ void T_ContinuousFalling(levelspecthink_t *faller) } } + P_CheckSector(faller->sector, false); // you might think this is irrelevant. you would be wrong + faller->sector->floorspeed = faller->speed*faller->direction; faller->sector->ceilspeed = 42; faller->sector->moved = true; @@ -1149,6 +1155,7 @@ void T_MarioBlock(levelspecthink_t *block) block->sector->ceilingdata = NULL; block->sector->floorspeed = 0; block->sector->ceilspeed = 0; + block->direction = 0; } for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) @@ -1228,9 +1235,7 @@ void T_SpikeSector(levelspecthink_t *spikes) if (dothepain) { - mobj_t *killer = P_SpawnMobj(thing->x, thing->y, thing->z, MT_NULL); - killer->threshold = 43; // Special flag that it was spikes which hurt you. - P_DamageMobj(thing, killer, killer, 1); + P_DamageMobj(thing, NULL, NULL, 1, DMG_SPIKE); break; } } @@ -1754,21 +1759,26 @@ static mobj_t *SearchMarioNode(msecnode_t *node) { case MT_NULL: case MT_UNKNOWN: + case MT_TAILSOVERLAY: case MT_THOK: case MT_GHOST: case MT_OVERLAY: case MT_EMERALDSPAWN: - case MT_GREENORB: - case MT_YELLOWORB: - case MT_BLUEORB: - case MT_BLACKORB: - case MT_WHITEORB: - case MT_PITYORB: + case MT_ELEMENTAL_ORB: + case MT_ATTRACT_ORB: + case MT_FORCE_ORB: + case MT_ARMAGEDDON_ORB: + case MT_WHIRLWIND_ORB: + case MT_PITY_ORB: + case MT_FLAMEAURA_ORB: + case MT_BUBBLEWRAP_ORB: + case MT_THUNDERCOIN_ORB: case MT_IVSP: case MT_SUPERSPARK: case MT_RAIN: case MT_SNOWFLAKE: case MT_SPLISH: + case MT_LAVASPLISH: case MT_SMOKE: case MT_SMALLBUBBLE: case MT_MEDIUMBUBBLE: @@ -1778,9 +1788,9 @@ static mobj_t *SearchMarioNode(msecnode_t *node) case MT_SCORE: case MT_DROWNNUMBERS: case MT_GOTEMERALD: + case MT_LOCKON: case MT_TAG: case MT_GOTFLAG: - case MT_GOTFLAG2: case MT_HOOP: case MT_HOOPCOLLIDE: case MT_NIGHTSCORE: @@ -1792,8 +1802,8 @@ static mobj_t *SearchMarioNode(msecnode_t *node) break; } // Ignore popped monitors, too. - if (node->m_thing->flags & MF_MONITOR - && node->m_thing->threshold == 68) + if (node->m_thing->health == 0 // this only really applies for monitors + || (!(node->m_thing->flags & MF_MONITOR) && (mobjinfo[node->m_thing->type].flags & MF_MONITOR))) // gold monitor support continue; // Okay, we found something valid. if (!thing // take either the first thing @@ -1807,10 +1817,24 @@ static mobj_t *SearchMarioNode(msecnode_t *node) void T_MarioBlockChecker(levelspecthink_t *block) { line_t *masterline = block->sourceline; + if (block->vars[2] == 1) // Don't update the textures when the block's being bumped upwards. + return; if (SearchMarioNode(block->sector->touching_thinglist)) - sides[masterline->sidenum[0]].midtexture = sides[masterline->sidenum[0]].bottomtexture; + { + sides[masterline->sidenum[0]].midtexture = sides[masterline->sidenum[0]].bottomtexture; // Update textures + if (masterline->backsector) + { + block->sector->ceilingpic = block->sector->floorpic = masterline->backsector->ceilingpic; // Update flats to be backside's ceiling + } + } else + { sides[masterline->sidenum[0]].midtexture = sides[masterline->sidenum[0]].toptexture; + if (masterline->backsector) + { + block->sector->ceilingpic = block->sector->floorpic = masterline->backsector->floorpic; // Update flats to be backside's floor + } + } } // This is the Thwomp's 'brain'. It looks around for players nearby, and if @@ -1954,25 +1978,27 @@ void T_ThwompSector(levelspecthink_t *thwomp) } else // Not going anywhere, so look for players. { - thinker_t *th; - mobj_t *mo; - if (!rover || (rover->flags & FF_EXISTS)) { - // scan the thinkers to find players! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + UINT8 i; + // scan the players to find victims! + for (i = 0; i < MAXPLAYERS; i++) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (!playeringame[i]) + continue; + if (players[i].spectator) + continue; + if (!players[i].mo) + continue; + if (!players[i].mo->health) + continue; + if (players[i].mo->z > thwomp->sector->ceilingheight) + continue; + if (P_AproxDistance(thwompx - players[i].mo->x, thwompy - players[i].mo->y) > 96 * FRACUNIT) continue; - mo = (mobj_t *)th; - if (mo->type == MT_PLAYER && mo->health && mo->player && !mo->player->spectator - && mo->z <= thwomp->sector->ceilingheight - && P_AproxDistance(thwompx - mo->x, thwompy - mo->y) <= 96*FRACUNIT) - { - thwomp->direction = -1; - break; - } + thwomp->direction = -1; + break; } } @@ -1998,51 +2024,71 @@ void T_NoEnemiesSector(levelspecthink_t *nobaddies) { size_t i; fixed_t upperbound, lowerbound; - INT32 s; - sector_t *checksector; + sector_t *sec = NULL; + sector_t *targetsec = NULL; + INT32 secnum = -1; msecnode_t *node; mobj_t *thing; - boolean exists = false; + boolean FOFsector = false; - for (i = 0; i < nobaddies->sector->linecount; i++) + while ((secnum = P_FindSectorFromLineTag(nobaddies->sourceline, secnum)) >= 0) { - if (nobaddies->sector->lines[i]->special == 223) + sec = §ors[secnum]; + + FOFsector = false; + + // Check the lines of this sector, to see if it is a FOF control sector. + for (i = 0; i < sec->linecount; i++) { + INT32 targetsecnum = -1; - upperbound = nobaddies->sector->ceilingheight; - lowerbound = nobaddies->sector->floorheight; + if (sec->lines[i]->special < 100 || sec->lines[i]->special >= 300) + continue; - for (s = -1; (s = P_FindSectorFromLineTag(nobaddies->sector->lines[i], s)) >= 0 ;) + FOFsector = true; + + while ((targetsecnum = P_FindSectorFromLineTag(sec->lines[i], targetsecnum)) >= 0) { - checksector = §ors[s]; + targetsec = §ors[targetsecnum]; - node = checksector->touching_thinglist; // things touching this sector + upperbound = targetsec->ceilingheight; + lowerbound = targetsec->floorheight; + node = targetsec->touching_thinglist; // things touching this sector while (node) { thing = node->m_thing; if ((thing->flags & (MF_ENEMY|MF_BOSS)) && thing->health > 0 - && thing->z < upperbound && thing->z+thing->height > lowerbound) - { - exists = true; - goto foundenemy; - } + && thing->z < upperbound && thing->z+thing->height > lowerbound) + return; node = node->m_thinglist_next; } } } + + if (!FOFsector) + { + upperbound = sec->ceilingheight; + lowerbound = sec->floorheight; + node = sec->touching_thinglist; // things touching this sector + while (node) + { + thing = node->m_thing; + + if ((thing->flags & (MF_ENEMY|MF_BOSS)) && thing->health > 0 + && thing->z < upperbound && thing->z+thing->height > lowerbound) + return; + + node = node->m_thinglist_next; + } + } } -foundenemy: - if (exists) - return; - s = P_AproxDistance(nobaddies->sourceline->dx, nobaddies->sourceline->dy)>>FRACBITS; + CONS_Debug(DBG_GAMELOGIC, "Running no-more-enemies exec with tag of %d\n", nobaddies->sourceline->tag); - CONS_Debug(DBG_GAMELOGIC, "Running no-more-enemies exec with tag of %d\n", s); - - // Otherwise, run the linedef exec and terminate this thinker - P_LinedefExecute((INT16)s, NULL, NULL); + // No enemies found, run the linedef exec and terminate this thinker + P_RunTriggerLinedef(nobaddies->sourceline, NULL, NULL); P_RemoveThinker(&nobaddies->thinker); } @@ -2379,7 +2425,7 @@ void T_RaiseSector(levelspecthink_t *raise) mobj_t *thing; sector_t *sector; INT32 i; - boolean playeronme = false; + boolean playeronme = false, active = false; fixed_t ceilingdestination, floordestination; result_e res = 0; @@ -2414,7 +2460,52 @@ void T_RaiseSector(levelspecthink_t *raise) } } - if (playeronme) + if (raise->vars[9]) // Dynamically Sinking Platform^tm + { +#define shaketime 10 + if (raise->vars[11] > shaketime) // State: moving + { + if (playeronme) // If player is standing on the platform, accelerate + { + raise->vars[10] += (FRACUNIT >> 5); + } + else // otherwise, decelerate until inflection + { + raise->vars[10] -= FRACUNIT >> 3; + if (raise->vars[10] <= 0) // inflection! + { + raise->vars[10] = 0; + raise->vars[11] = 0; // allow the shake to occur again (fucks over players attempting to jump-cheese) + } + } + active = raise->vars[10] > 0; + } + else // State: shaking + { + if (playeronme || raise->vars[11]) + { + active = true; + if (++raise->vars[11] > shaketime) + { + if (playeronme) + raise->vars[10] = FRACUNIT >> 5; + else + raise->vars[10] = FRACUNIT << 1; + } + else + { + raise->vars[10] = ((shaketime/2) - raise->vars[11]) << FRACBITS; + if (raise->vars[10] < -raise->vars[2]/2) + raise->vars[10] = -raise->vars[2]/2; + } + } + } +#undef shaketime + } + else // Air bobbing platform (not a Dynamically Sinking Platform^tm) + active = playeronme; + + if (active) { raise->vars[3] = raise->vars[2]; @@ -2508,6 +2599,8 @@ void T_RaiseSector(levelspecthink_t *raise) raise->vars[3] = origspeed; } + raise->vars[3] += raise->vars[10]; + res = T_MovePlane ( raise->sector, // sector @@ -2605,6 +2698,35 @@ void T_CameraScanner(elevator_t *elevator) } } +void T_PlaneDisplace(planedisplace_t *pd) +{ + sector_t *control, *target; + INT32 direction; + fixed_t diff; + + control = §ors[pd->control]; + target = §ors[pd->affectee]; + + if (control->floorheight == pd->last_height) + return; // no change, no movement + + direction = (control->floorheight > pd->last_height) ? 1 : -1; + diff = FixedMul(control->floorheight-pd->last_height, pd->speed); + + if (pd->reverse) // reverse direction? + { + direction *= -1; + diff *= -1; + } + + if (pd->type == pd_floor || pd->type == pd_both) + T_MovePlane(target, INT32_MAX/2, target->floorheight+diff, 0, 0, direction); // move floor + if (pd->type == pd_ceiling || pd->type == pd_both) + T_MovePlane(target, INT32_MAX/2, target->ceilingheight+diff, 0, 1, direction); // move ceiling + + pd->last_height = control->floorheight; +} + // // EV_DoFloor // @@ -2631,7 +2753,7 @@ INT32 EV_DoFloor(line_t *line, floor_e floortype) // new floor thinker rtn = 1; dofloor = Z_Calloc(sizeof (*dofloor), PU_LEVSPEC, NULL); - P_AddThinker(&dofloor->thinker); + P_AddThinker(THINK_MAIN, &dofloor->thinker); // make sure another floor thinker won't get started over this one sec->floordata = dofloor; @@ -2852,7 +2974,7 @@ INT32 EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) // create and initialize new elevator thinker rtn = 1; elevator = Z_Calloc(sizeof (*elevator), PU_LEVSPEC, NULL); - P_AddThinker(&elevator->thinker); + P_AddThinker(THINK_MAIN, &elevator->thinker); sec->floordata = elevator; sec->ceilingdata = elevator; elevator->thinker.function.acp1 = (actionf_p1)T_MoveElevator; @@ -2957,23 +3079,66 @@ INT32 EV_DoElevator(line_t *line, elevator_e elevtype, boolean customspeed) void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) { - size_t i; - size_t leftmostvertex = 0, rightmostvertex = 0; - size_t topmostvertex = 0, bottommostvertex = 0; - fixed_t leftx, rightx; - fixed_t topy, bottomy; - fixed_t topz; - fixed_t a, b, c; - mobjtype_t type = MT_ROCKCRUMBLE1; + size_t i, leftmostvertex, rightmostvertex, topmostvertex, bottommostvertex; + fixed_t leftx, rightx, topy, bottomy, topz, bottomz, widthfactor, heightfactor, a, b, c, spacing; + mobjtype_t type; + tic_t lifetime; + INT16 flags; - // If the control sector has a special - // of Section3:7-15, use the custom debris. - if (GETSECSPECIAL(rover->master->frontsector->special, 3) >= 8) - type = MT_ROCKCRUMBLE1+(GETSECSPECIAL(rover->master->frontsector->special, 3)-7); + sector_t *controlsec = rover->master->frontsector; + + if (sec == NULL) + { + if (controlsec->numattached) + { + for (i = 0; i < controlsec->numattached; i++) + { + sec = §ors[controlsec->attached[i]]; + if (!sec->ffloors) + continue; + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector == controlsec) + EV_CrumbleChain(sec, rover); + } + } + } + return; + } + + leftmostvertex = rightmostvertex = topmostvertex = bottommostvertex = 0; + widthfactor = heightfactor = FRACUNIT; + spacing = (32<tag != 0) + { + INT32 tagline = P_FindSpecialLineFromTag(14, controlsec->tag, -1); + if (tagline != -1) + { + if (sides[lines[tagline].sidenum[0]].toptexture) + type = (mobjtype_t)sides[lines[tagline].sidenum[0]].toptexture; // Set as object type in p_setup.c... + if (sides[lines[tagline].sidenum[0]].textureoffset) + spacing = sides[lines[tagline].sidenum[0]].textureoffset; + if (sides[lines[tagline].sidenum[0]].rowoffset) + { + if (sides[lines[tagline].sidenum[0]].rowoffset>>FRACBITS != -1) + lifetime = (sides[lines[tagline].sidenum[0]].rowoffset>>FRACBITS); + else + lifetime = 0; + } + flags = lines[tagline].flags; + } + } + +#undef controlsec // soundorg z height never gets set normally, so MEH. sec->soundorg.z = sec->floorheight; - S_StartSound(&sec->soundorg, sfx_crumbl); + S_StartSound(&sec->soundorg, mobjinfo[type].activesound); // Find the outermost vertexes in the subsector for (i = 0; i < sec->linecount; i++) @@ -2992,23 +3157,46 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) bottommostvertex = i; } - leftx = sec->lines[leftmostvertex]->v1->x+(16<lines[leftmostvertex]->v1->x+(spacing>>1); rightx = sec->lines[rightmostvertex]->v1->x; - topy = sec->lines[topmostvertex]->v1->y-(16<lines[topmostvertex]->v1->y-(spacing>>1); bottomy = sec->lines[bottommostvertex]->v1->y; - topz = *rover->topheight-(16<topheight-(spacing>>1); + bottomz = *rover->bottomheight; + + if (flags & ML_EFFECT1) { - for (b = topy; b > bottomy; b -= (32<>3; + heightfactor = (topz - *rover->bottomheight)>>2; + } + + for (a = leftx; a < rightx; a += spacing) + { + for (b = topy; b > bottomy; b -= spacing) { if (R_PointInSubsector(a, b)->sector == sec) { mobj_t *spawned = NULL; - for (c = topz; c > *rover->bottomheight; c -= (32<t_slope) + topz = P_GetZAt(*rover->t_slope, a, b) - (spacing>>1); + if (*rover->b_slope) + bottomz = P_GetZAt(*rover->b_slope, a, b); +#endif + + for (c = topz; c > bottomz; c -= spacing) { spawned = P_SpawnMobj(a, b, c, type); - spawned->fuse = 3*TICRATE; + spawned->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones + + if (flags & ML_EFFECT1) + { + P_InstaThrust(spawned, R_PointToAngle2(sec->soundorg.x, sec->soundorg.y, a, b), FixedDiv(P_AproxDistance(a - sec->soundorg.x, b - sec->soundorg.y), widthfactor)); + P_SetObjectMomZ(spawned, FixedDiv((c - bottomz), heightfactor), false); + } + + spawned->fuse = lifetime; } } } @@ -3017,7 +3205,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) // no longer exists (can't collide with again) rover->flags &= ~FF_EXISTS; rover->master->frontsector->moved = true; - sec->moved = true; + P_RecalcPrecipInSector(sec); } // Used for bobbing platforms on the water @@ -3033,7 +3221,7 @@ INT32 EV_BounceSector(sector_t *sec, fixed_t momz, line_t *sourceline) return 0; bouncer = Z_Calloc(sizeof (*bouncer), PU_LEVSPEC, NULL); - P_AddThinker(&bouncer->thinker); + P_AddThinker(THINK_MAIN, &bouncer->thinker); sec->ceilingdata = bouncer; bouncer->thinker.function.acp1 = (actionf_p1)T_BounceCheese; @@ -3067,7 +3255,7 @@ INT32 EV_DoContinuousFall(sector_t *sec, sector_t *backsector, fixed_t spd, bool // create and initialize new thinker faller = Z_Calloc(sizeof (*faller), PU_LEVSPEC, NULL); - P_AddThinker(&faller->thinker); + P_AddThinker(THINK_MAIN, &faller->thinker); faller->thinker.function.acp1 = (actionf_p1)T_ContinuousFalling; // set up the fields @@ -3116,7 +3304,7 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, // create and initialize new elevator thinker elevator = Z_Calloc(sizeof (*elevator), PU_LEVSPEC, NULL); - P_AddThinker(&elevator->thinker); + P_AddThinker(THINK_MAIN, &elevator->thinker); elevator->thinker.function.acp1 = (actionf_p1)T_StartCrumble; // Does this crumbler return? @@ -3168,8 +3356,10 @@ INT32 EV_StartCrumble(sector_t *sec, ffloor_t *rover, boolean floating, return 1; } -INT32 EV_MarioBlock(sector_t *sec, sector_t *roversector, fixed_t topheight, mobj_t *puncher) +INT32 EV_MarioBlock(ffloor_t *rover, sector_t *sector, mobj_t *puncher) { + sector_t *roversec = rover->master->frontsector; + fixed_t topheight = *rover->topheight; levelspecthink_t *block; mobj_t *thing; fixed_t oldx = 0, oldy = 0, oldz = 0; @@ -3177,11 +3367,14 @@ INT32 EV_MarioBlock(sector_t *sec, sector_t *roversector, fixed_t topheight, mob I_Assert(puncher != NULL); I_Assert(puncher->player != NULL); - if (sec->floordata || sec->ceilingdata) + if (roversec->floordata || roversec->ceilingdata) return 0; + if (!(rover->flags & FF_SOLID)) + rover->flags |= (FF_SOLID|FF_RENDERALL|FF_CUTLEVEL); + // Find an item to pop out! - thing = SearchMarioNode(sec->touching_thinglist); + thing = SearchMarioNode(roversec->touching_thinglist); // Found something! if (thing) @@ -3190,14 +3383,14 @@ INT32 EV_MarioBlock(sector_t *sec, sector_t *roversector, fixed_t topheight, mob // create and initialize new elevator thinker block = Z_Calloc(sizeof (*block), PU_LEVSPEC, NULL); - P_AddThinker(&block->thinker); - sec->floordata = block; - sec->ceilingdata = block; + P_AddThinker(THINK_MAIN, &block->thinker); + roversec->floordata = block; + roversec->ceilingdata = block; block->thinker.function.acp1 = (actionf_p1)T_MarioBlock; // Set up the fields - block->sector = sec; - block->vars[0] = roversector->tag; // actionsector + block->sector = roversec; + block->vars[0] = sector->tag; // actionsector block->vars[1] = 4*FRACUNIT; // speed block->vars[2] = 1; // Up // direction block->vars[3] = block->sector->floorheight; // floorwasheight @@ -3213,14 +3406,14 @@ INT32 EV_MarioBlock(sector_t *sec, sector_t *roversector, fixed_t topheight, mob } P_UnsetThingPosition(thing); - thing->x = roversector->soundorg.x; - thing->y = roversector->soundorg.y; + thing->x = sector->soundorg.x; + thing->y = sector->soundorg.y; thing->z = topheight; thing->momz = FixedMul(6*FRACUNIT, thing->scale); P_SetThingPosition(thing); if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, puncher, puncher, 1); - else if (thing->type == MT_RING || thing->type == MT_COIN) + P_DamageMobj(thing, puncher, puncher, 1, 0); + else if (thing->type == MT_RING || thing->type == MT_COIN || thing->type == MT_TOKEN) { thing->momz = FixedMul(3*FRACUNIT, thing->scale); P_TouchSpecialThing(thing, puncher, false); @@ -3229,27 +3422,19 @@ INT32 EV_MarioBlock(sector_t *sec, sector_t *roversector, fixed_t topheight, mob } else { - if (thing->type == MT_EMMY && thing->spawnpoint && (thing->spawnpoint->options & MTF_OBJECTSPECIAL)) - { - mobj_t *tokenobj = P_SpawnMobj(roversector->soundorg.x, roversector->soundorg.y, topheight, MT_TOKEN); - P_SetTarget(&thing->tracer, tokenobj); - P_SetTarget(&tokenobj->target, thing); - P_SetMobjState(tokenobj, mobjinfo[MT_TOKEN].seestate); - } - // "Powerup rise" sound S_StartSound(puncher, sfx_mario9); // Puncher is "close enough" } - if (itsamonitor) + if (itsamonitor && thing) { - P_UnsetThingPosition(tmthing); - tmthing->x = oldx; - tmthing->y = oldy; - tmthing->z = oldz; - tmthing->momx = 1; - tmthing->momy = 1; - P_SetThingPosition(tmthing); + P_UnsetThingPosition(thing); + thing->x = oldx; + thing->y = oldy; + thing->z = oldz; + thing->momx = 1; + thing->momy = 1; + P_SetThingPosition(thing); } } else diff --git a/src/p_inter.c b/src/p_inter.c index 29450f6e1..67d197375 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -23,9 +23,11 @@ #include "hu_stuff.h" #include "lua_hook.h" #include "m_cond.h" // unlockables, emblems, etc +#include "p_setup.h" #include "m_cheat.h" // objectplace #include "m_misc.h" #include "v_video.h" // video flags for CEchos +#include "f_finale.h" // CTF player names #define CTFTEAMCODE(pl) pl->ctfteam ? (pl->ctfteam == 1 ? "\x85" : "\x84") : "" @@ -96,15 +98,20 @@ void P_ClearStarPost(INT32 postnum) mobj_t *mo2; // scan the thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_STARPOST && mo2->health <= postnum) - P_SetMobjState(mo2, mo2->info->seestate); + if (mo2->type != MT_STARPOST) + continue; + + if (mo2->health > postnum) + continue; + + P_SetMobjState(mo2, mo2->info->seestate); } return; } @@ -120,15 +127,17 @@ void P_ResetStarposts(void) thinker_t *th; mobj_t *post; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; post = (mobj_t *)th; - if (post->type == MT_STARPOST) - P_SetMobjState(post, post->info->spawnstate); + if (post->type != MT_STARPOST) + continue; + + P_SetMobjState(post, post->info->spawnstate); } } @@ -139,10 +148,17 @@ void P_ResetStarposts(void) // boolean P_CanPickupItem(player_t *player, boolean weapon) { - if (player->bot && weapon) + if (!player->mo || player->mo->health <= 0) return false; - if (player->powers[pw_flashing] > (flashingtics/4)*3 && player->powers[pw_flashing] <= flashingtics) + if (player->bot) + { + if (weapon) + return false; + return P_CanPickupItem(&players[consoleplayer], true); // weapon is true to prevent infinite recursion if p1 is bot - doesn't occur in vanilla, but may be relevant for mods + } + + if (player->powers[pw_flashing] > (flashingtics/4)*3 && player->powers[pw_flashing] < UINT16_MAX) return false; return true; @@ -173,14 +189,14 @@ void P_DoNightsScore(player_t *player) { if (++players[i].linkcount > players[i].maxlink) players[i].maxlink = players[i].linkcount; - players[i].linktimer = 2*TICRATE; + players[i].linktimer = nightslinktics; } } else // Individual link counts { if (++player->linkcount > player->maxlink) player->maxlink = player->linkcount; - player->linktimer = 2*TICRATE; + player->linktimer = nightslinktics; } if (player->linkcount < 10) @@ -221,6 +237,69 @@ void P_DoNightsScore(player_t *player) dummymo->destscale = 2*FRACUNIT; } +// +// P_DoMatchSuper +// +// Checks if you have all 7 pw_emeralds, then turns you "super". =P +// +void P_DoMatchSuper(player_t *player) +{ + UINT16 match_emeralds = player->powers[pw_emeralds]; + boolean doteams = false; + int i; + + // If this gametype has teams, check every player on your team for emeralds. + if (G_GametypeHasTeams()) + { + doteams = true; + for (i = 0; i < MAXPLAYERS; i++) + if (players[i].ctfteam == player->ctfteam) + match_emeralds |= players[i].powers[pw_emeralds]; + } + + if (!ALL7EMERALDS(match_emeralds)) + return; + + // Got 'em all? Turn "super"! + emeraldspawndelay = invulntics + 1; + player->powers[pw_emeralds] = 0; + player->powers[pw_invulnerability] = emeraldspawndelay; + player->powers[pw_sneakers] = emeraldspawndelay; + if (P_IsLocalPlayer(player) && !player->powers[pw_super]) + { + S_StopMusic(); + if (mariomode) + G_GhostAddColor(GHC_INVINCIBLE); + strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14); + S_StartCaption(sfx_None, -1, player->powers[pw_invulnerability]); + S_ChangeMusicInternal((mariomode) ? "_minv" : "_inv", false); + } + + // Also steal 50 points from every enemy, sealing your victory. + P_StealPlayerScore(player, 50); + + // In a team game? + // Check everyone else on your team for emeralds, and turn those helpful assisting players invincible too. + if (doteams) + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && players[i].ctfteam == player->ctfteam + && players[i].powers[pw_emeralds] != 0) + { + players[i].powers[pw_emeralds] = 0; + player->powers[pw_invulnerability] = invulntics + 1; + player->powers[pw_sneakers] = player->powers[pw_invulnerability]; + if (P_IsLocalPlayer(player) && !player->powers[pw_super]) + { + S_StopMusic(); + if (mariomode) + G_GhostAddColor(GHC_INVINCIBLE); + strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14); + S_StartCaption(sfx_None, -1, player->powers[pw_invulnerability]); + S_ChangeMusicInternal((mariomode) ? "_minv" : "_inv", false); + } + } +} + /** Takes action based on a ::MF_SPECIAL thing touched by a player. * Actually, this just checks a few things (heights, toucher->player, no * objectplace, no dead or disappearing things) @@ -237,6 +316,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { player_t *player; INT32 i; + UINT8 elementalpierce; if (objectplacing) return; @@ -248,6 +328,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Can happen with a sliding player corpse. if (toucher->health <= 0) return; + if (special->health <= 0) + return; if (heightcheck) { @@ -273,103 +355,160 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } } - if (special->health <= 0) - return; - player = toucher->player; I_Assert(player != NULL); // Only players can touch stuff! if (player->spectator) return; - // Ignore eggman in "ouchie" mode - if (special->flags & MF_BOSS && special->flags2 & MF2_FRET) + // Ignore multihits in "ouchie" mode + if (special->flags & (MF_ENEMY|MF_BOSS) && special->flags2 & MF2_FRET) return; -#ifdef HAVE_BLUA if (LUAh_TouchSpecial(special, toucher) || P_MobjWasRemoved(special)) return; -#endif - if (special->flags & MF_BOSS) - { - if (special->type == MT_BLACKEGGMAN) - { - P_DamageMobj(toucher, special, special, 1); // ouch - return; - } + // 0 = none, 1 = elemental pierce, 2 = bubble bounce + elementalpierce = (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (player->pflags & PF_SHIELDABILITY) + ? (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) ? 1 : 2) + : 0); - if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) - || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? - { - if (P_MobjFlip(toucher)*toucher->momz < 0) - toucher->momz = -toucher->momz; - toucher->momx = -toucher->momx; - toucher->momy = -toucher->momy; - P_DamageMobj(special, toucher, toucher, 1); - } - else if (((toucher->z < special->z && !(toucher->eflags & MFE_VERTICALFLIP)) - || (toucher->z + toucher->height > special->z + special->height && (toucher->eflags & MFE_VERTICALFLIP))) - && player->charability == CA_FLY - && (player->powers[pw_tailsfly] - || (toucher->state >= &states[S_PLAY_SPC1] && toucher->state <= &states[S_PLAY_SPC4]))) // Tails can shred stuff with his propeller. - { - toucher->momz = -toucher->momz/2; - - P_DamageMobj(special, toucher, toucher, 1); - } - else - P_DamageMobj(toucher, special, special, 1); - - return; - } - else if ((special->flags & MF_ENEMY) && !(special->flags & MF_MISSILE)) + if ((special->flags & (MF_ENEMY|MF_BOSS)) && !(special->flags & MF_MISSILE)) { //////////////////////////////////////////////////////// - /////ENEMIES!!////////////////////////////////////////// + /////ENEMIES & BOSSES!!///////////////////////////////// //////////////////////////////////////////////////////// - if (special->type == MT_GSNAPPER && !(((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || player->powers[pw_invulnerability] || player->powers[pw_super]) - && toucher->z < special->z + special->height && toucher->z + toucher->height > special->z) - { - // Can only hit snapper from above - P_DamageMobj(toucher, special, special, 1); - } - else if (special->type == MT_SHARP - && ((special->state == &states[special->info->xdeathstate]) || (toucher->z > special->z + special->height/2))) - { - // Cannot hit sharp from above or when red and angry - P_DamageMobj(toucher, special, special, 1); - } - else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) - || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) - || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? - { - if (P_MobjFlip(toucher)*toucher->momz < 0) - toucher->momz = -toucher->momz; - P_DamageMobj(special, toucher, toucher, 1); - } - else if (((toucher->z < special->z && !(toucher->eflags & MFE_VERTICALFLIP)) - || (toucher->z + toucher->height > special->z + special->height && (toucher->eflags & MFE_VERTICALFLIP))) // Flame is bad at logic - JTE - && player->charability == CA_FLY - && (player->powers[pw_tailsfly] - || (toucher->state >= &states[S_PLAY_SPC1] && toucher->state <= &states[S_PLAY_SPC4]))) // Tails can shred stuff with his propeller. + switch (special->type) { - if (P_MobjFlip(toucher)*toucher->momz < 0) - toucher->momz = -toucher->momz/2; + case MT_BLACKEGGMAN: + { + P_DamageMobj(toucher, special, special, 1, 0); // ouch + return; + } + case MT_BIGMINE: + { + special->momx = toucher->momx/3; + special->momy = toucher->momy/3; + special->momz = toucher->momz/3; + toucher->momx /= -8; + toucher->momy /= -8; + toucher->momz /= -8; + special->flags &= ~MF_SPECIAL; + if (special->info->activesound) + S_StartSound(special, special->info->activesound); + P_SetTarget(&special->tracer, toucher); + player->homing = 0; + return; + } + case MT_GSNAPPER: + if (!elementalpierce + && toucher->z < special->z + special->height + && toucher->z + toucher->height > special->z + && P_DamageMobj(toucher, special, special, 1, DMG_SPIKE)) + return; // Can only hit snapper from above + break; - P_DamageMobj(special, toucher, toucher, 1); + case MT_SPINCUSHION: + if (P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) + { + if (player->pflags & PF_BOUNCING) + { + toucher->momz = -toucher->momz; + P_DoAbilityBounce(player, false); + return; + } + else if (P_DamageMobj(toucher, special, special, 1, DMG_SPIKE)) + return; // Cannot hit sharp from above + } + break; + case MT_FANG: + if (!player->powers[pw_flashing] + && !(player->charability == CA_TWINSPIN && player->panim == PA_ABILITY) + && !(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) + { + if ((special->state == &states[S_FANG_BOUNCE3] + || special->state == &states[S_FANG_BOUNCE4] + || special->state == &states[S_FANG_PINCHBOUNCE3] + || special->state == &states[S_FANG_PINCHBOUNCE4]) + && P_MobjFlip(special)*((special->z + special->height/2) - (toucher->z + toucher->height/2)) > (toucher->height/2)) + { + P_DamageMobj(toucher, special, special, 1, 0); + P_SetTarget(&special->tracer, toucher); + + if (special->state == &states[S_FANG_PINCHBOUNCE3] + || special->state == &states[S_FANG_PINCHBOUNCE4]) + P_SetMobjState(special, S_FANG_PINCHPATHINGSTART2); + else + { + var1 = var2 = 4; + A_Boss5ExtraRepeat(special); + P_SetMobjState(special, S_FANG_PATHINGCONT2); //S_FANG_PATHINGCONT1 if you want him to drop a bomb on the player + } + if (special->eflags & MFE_VERTICALFLIP) + special->z = toucher->z - special->height; + else + special->z = toucher->z + toucher->height; + return; + } + } + break; + case MT_PYREFLY: + if (special->extravalue2 == 2 && P_DamageMobj(player->mo, special, special, 1, DMG_FIRE)) + return; + default: + break; + } + + if (P_PlayerCanDamage(player, special)) // Do you possess the ability to subdue the object? + { + if (special->type == MT_PTERABYTE && special->target == player->mo && special->extravalue1 == 1) + return; // Can't hurt a Pterabyte if it's trying to pick you up + + if ((P_MobjFlip(toucher)*toucher->momz < 0) && (elementalpierce != 1)) + { + if (elementalpierce == 2) + P_DoBubbleBounce(player); + else if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) + toucher->momz = -toucher->momz; + } + if (player->pflags & PF_BOUNCING) + P_DoAbilityBounce(player, false); + if (special->info->spawnhealth > 1) // Multi-hit? Bounce back! + { + toucher->momx = -toucher->momx; + toucher->momy = -toucher->momy; + if (player->charability == CA_FLY && player->panim == PA_ABILITY) + toucher->momz = -toucher->momz/2; + else if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher)) + { + player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); + P_SetPlayerMobjState(toucher, S_PLAY_FALL); + toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3); + toucher->momx = 7*toucher->momx>>3; + toucher->momy = 7*toucher->momy>>3; + } + else if (player->dashmode >= DASHMODE_THRESHOLD && (player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE) + && player->panim == PA_DASH) + P_DoPlayerPain(player, special, special); + } + P_DamageMobj(special, toucher, toucher, 1, 0); + if (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY) + P_TwinSpinRejuvenate(player, player->thokitem); } else - P_DamageMobj(toucher, special, special, 1); + { + if (special->type == MT_PTERABYTE && special->target == player->mo) + return; // Don't hurt the player you're trying to grab + + P_DamageMobj(toucher, special, special, 1, 0); + } return; } else if (special->flags & MF_FIRE) { - P_DamageMobj(toucher, special, special, 1); + P_DamageMobj(toucher, special, special, 1, DMG_FIRE); return; } else @@ -390,43 +529,47 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) /* FALLTHRU */ case MT_RING: case MT_FLINGRING: - if (!(P_CanPickupItem(player, false))) - return; - - special->momx = special->momy = special->momz = 0; - P_GivePlayerRings(player, 1); - - if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING) - P_DoNightsScore(player); - break; - case MT_COIN: case MT_FLINGCOIN: - if (!(P_CanPickupItem(player, false))) + case MT_NIGHTSSTAR: + if (!(P_CanPickupItem(player, false)) && !(special->flags2 & MF2_NIGHTSPULL)) return; - special->momx = special->momy = 0; - P_GivePlayerRings(player, 1); - - if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGCOIN) - P_DoNightsScore(player); - break; - case MT_BLUEBALL: - if (!(P_CanPickupItem(player, false))) - return; - - P_GivePlayerRings(player, 1); - special->momx = special->momy = special->momz = 0; - special->destscale = FixedMul(8*FRACUNIT, special->scale); - if (states[special->info->deathstate].tics > 0) - special->scalespeed = FixedDiv(FixedDiv(special->destscale, special->scale), states[special->info->deathstate].tics<scalespeed = 4*FRACUNIT/5; + P_GivePlayerRings(player, 1); + + if ((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING && special->type != MT_FLINGCOIN) + P_DoNightsScore(player); + break; + case MT_BLUESPHERE: + case MT_FLINGBLUESPHERE: + case MT_NIGHTSCHIP: + case MT_FLINGNIGHTSCHIP: + if (!(P_CanPickupItem(player, false)) && !(special->flags2 & MF2_NIGHTSPULL)) + return; + + special->momx = special->momy = special->momz = 0; + P_GivePlayerSpheres(player, 1); + + if (special->type == MT_BLUESPHERE) + { + special->destscale = ((player->powers[pw_carry] == CR_NIGHTSMODE) ? 4 : 2)*special->scale; + if (states[special->info->deathstate].tics > 0) + special->scalespeed = FixedDiv(FixedDiv(special->destscale, special->scale), states[special->info->deathstate].tics<scalespeed = 4*FRACUNIT/5; + } if (maptol & TOL_NIGHTS) P_DoNightsScore(player); break; + case MT_BOMBSPHERE: + if (!(P_CanPickupItem(player, false)) && !(special->flags2 & MF2_NIGHTSPULL)) + return; + + special->momx = special->momy = special->momz = 0; + P_DamageMobj(toucher, special, special, 1, 0); + break; case MT_AUTOPICKUP: case MT_BOUNCEPICKUP: case MT_SCATTERPICKUP: @@ -441,7 +584,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { INT32 pindex = special->info->mass - (INT32)pw_infinityring; - player->powers[special->info->mass] += (UINT16)special->info->reactiontime; + player->powers[special->info->mass] += (UINT16)special->reactiontime; player->ringweapons |= 1 << (pindex-1); if (player->powers[special->info->mass] > rw_maximums[pindex]) @@ -474,21 +617,40 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Gameplay related collectibles // // ***************************** // // Special Stage Token - case MT_EMMY: + case MT_TOKEN: if (player->bot) return; + + P_AddPlayerScore(player, 1000); + + if (!(gametyperules & GTR_SPECIALSTAGES) || modeattacking) // score only? + { + S_StartSound(toucher, sfx_chchng); + break; + } + tokenlist += special->health; if (ALL7EMERALDS(emeralds)) // Got all 7 { - P_GivePlayerRings(player, 50); - nummaprings += 50; // no cheating towards Perfect! + if (!(netgame || multiplayer)) + { + player->continues += 1; + player->gotcontinue = true; + if (P_IsLocalPlayer(player)) + S_StartSound(NULL, sfx_s3kac); + else + S_StartSound(toucher, sfx_chchng); + } + else + S_StartSound(toucher, sfx_chchng); } else + { token++; + S_StartSound(toucher, sfx_token); + } - if (special->tracer) // token BG - P_RemoveMobj(special->tracer); break; // Emerald Hunt @@ -512,7 +674,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) players[i].exiting = (14*TICRATE)/5 + 1; } - S_StartSound(NULL, sfx_lvpass); + //S_StartSound(NULL, sfx_lvpass); } break; @@ -528,9 +690,15 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; if (special->threshold) + { player->powers[pw_emeralds] |= special->info->speed; + P_DoMatchSuper(player); + } else + { emeralds |= special->info->speed; + stagefailed = false; + } if (special->target && special->target->type == MT_EMERALDSPAWN) { @@ -549,6 +717,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; player->powers[pw_emeralds] |= special->threshold; + P_DoMatchSuper(player); break; // Secret emblem thingy @@ -639,45 +808,134 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // NiGHTS gameplay items and powerups // // ********************************** // case MT_NIGHTSDRONE: - if (player->bot) - return; - if (player->exiting) - return; - if (player->bonustime) { - if (G_IsSpecialStage(gamemap)) //After-mare bonus time/emerald reward in special stages. + boolean spec = G_IsSpecialStage(gamemap); + boolean cangiveemmy = false; + if (player->bot) + return; + if (player->exiting) + return; + if (player->bonustime) { - // only allow the player with the emerald in-hand to leave. - if (toucher->tracer && toucher->tracer->target - && toucher->tracer->target->type == MT_GOTEMERALD) + if (spec) //After-mare bonus time/emerald reward in special stages. { + // only allow the player with the emerald in-hand to leave. + if (toucher->tracer + && toucher->tracer->type == MT_GOTEMERALD) + {} + else // Make sure that SOMEONE has the emerald, at least! + { + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && players[i].playerstate == PST_LIVE + && players[i].mo->tracer + && players[i].mo->tracer->type == MT_GOTEMERALD) + return; + // Well no one has an emerald, so exit anyway! + } + cangiveemmy = true; + // Don't play Ideya sound in special stage mode } - else // Make sure that SOMEONE has the emerald, at least! - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].playerstate == PST_LIVE - && players[i].mo->tracer && players[i].mo->tracer->target - && players[i].mo->tracer->target->type == MT_GOTEMERALD) - return; - // Well no one has an emerald, so exit anyway! - } - P_GiveEmerald(false); - // Don't play Ideya sound in special stage mode + else + S_StartSound(toucher, special->info->activesound); } - else - S_StartSound(toucher, special->info->activesound); - } - else //Initial transformation. Don't allow second chances in special stages! - { - if (player->pflags & PF_NIGHTSMODE) + else //Initial transformation. Don't allow second chances in special stages! + { + if (player->powers[pw_carry] == CR_NIGHTSMODE) + return; + + S_StartSound(toucher, sfx_supert); + } + P_SwitchSpheresBonusMode(false); + if (!(netgame || multiplayer) && !(player->powers[pw_carry] == CR_NIGHTSMODE)) + P_SetTarget(&special->tracer, toucher); + P_SetTarget(&player->drone, special); // Mark the player as 'center into the drone' + P_NightserizePlayer(player, special->health); // Transform! + if (!spec) + { + if (toucher->tracer) // Move the Ideya to an anchor! + { + mobj_t *orbittarget = special->target ? special->target : special; + mobj_t *hnext = orbittarget->hnext, *anchorpoint = NULL, *anchorpoint2 = NULL; + mobj_t *mo2; + thinker_t *th; + + // The player might have two Ideyas: toucher->tracer and toucher->tracer->hnext + // so handle their anchorpoints accordingly. + // scan the thinkers to find the corresponding anchorpoint + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_IDEYAANCHOR) + continue; + + if (mo2->health == toucher->tracer->health) // do ideya numberes match? + anchorpoint = mo2; + else if (toucher->tracer->hnext && mo2->health == toucher->tracer->hnext->health) + anchorpoint2 = mo2; + + if ((!toucher->tracer->hnext && anchorpoint) + || (toucher->tracer->hnext && anchorpoint && anchorpoint2)) + break; + } + + if (anchorpoint) + { + toucher->tracer->flags |= MF_GRENADEBOUNCE; // custom radius factors + toucher->tracer->threshold = 8 << 20; // X factor 0, Y factor 0, Z factor 8 + } + + if (anchorpoint2) + { + toucher->tracer->hnext->flags |= MF_GRENADEBOUNCE; // custom radius factors + toucher->tracer->hnext->threshold = 8 << 20; // X factor 0, Y factor 0, Z factor 8 + } + + P_SetTarget(&orbittarget->hnext, toucher->tracer); + if (!orbittarget->hnext->hnext) + P_SetTarget(&orbittarget->hnext->hnext, hnext); // Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. + else + P_SetTarget(&orbittarget->hnext->hnext->target, anchorpoint2 ? anchorpoint2 : orbittarget); + P_SetTarget(&orbittarget->hnext->target, anchorpoint ? anchorpoint : orbittarget); + P_SetTarget(&toucher->tracer, NULL); + + if (hnext) + { + orbittarget->hnext->extravalue1 = (angle_t)(hnext->extravalue1 - 72*ANG1); + if (orbittarget->hnext->extravalue1 > hnext->extravalue1) + orbittarget->hnext->extravalue1 -= (72*ANG1)/orbittarget->hnext->extravalue1; + } + } + if (player->exiting) // ...then move it back? + { + mobj_t *hnext = special->target ? special->target : special; // goalpost + while ((hnext = hnext->hnext)) + { + hnext->flags &= ~MF_GRENADEBOUNCE; + hnext->threshold = 0; + P_SetTarget(&hnext->target, toucher); + } + } + return; + } + + if (!cangiveemmy) return; - S_StartSound(toucher, sfx_supert); + if (player->exiting) + P_GiveEmerald(false); + else if (player->mo->tracer && player->mare) + { + P_KillMobj(toucher->tracer, NULL, NULL, 0); // No emerald for you just yet! + S_StartSound(NULL, sfx_ghosty); + special->flags2 |= MF2_DONTDRAW; + } + + return; } - if (!(netgame || multiplayer) && !(player->pflags & PF_NIGHTSMODE)) - P_SetTarget(&special->tracer, toucher); - P_NightserizePlayer(player, special->health); // Transform! - return; case MT_NIGHTSLOOPHELPER: // One second delay if (special->fuse < toucher->fuse - TICRATE) @@ -698,9 +956,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) count = 1; // scan the remaining thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -748,9 +1006,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Now we RE-scan all the thinkers to find close objects to pull // in from the paraloop. Isn't this just so efficient? - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -760,7 +1018,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (mo2->flags & MF_SHOOTABLE) { - P_DamageMobj(mo2, toucher, toucher, 1); + P_DamageMobj(mo2, toucher, toucher, 1, 0); continue; } @@ -774,7 +1032,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!(mo2->flags & MF_SPECIAL) && mo2->health) { - P_SetMobjState(mo2, mo2->info->seestate); + mo2->flags2 &= ~MF2_DONTDRAW; mo2->flags |= MF_SPECIAL; mo2->flags &= ~MF_NIGHTSITEM; S_StartSound(toucher, sfx_hidden); @@ -782,13 +1040,18 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } } - if (!(mo2->type == MT_NIGHTSWING || mo2->type == MT_RING || mo2->type == MT_COIN - || mo2->type == MT_BLUEBALL)) + if (!(mo2->type == MT_RING || mo2->type == MT_COIN + || mo2->type == MT_BLUESPHERE || mo2->type == MT_BOMBSPHERE + || mo2->type == MT_NIGHTSCHIP || mo2->type == MT_NIGHTSSTAR + || ((mo2->type == MT_EMBLEM) && (mo2->reactiontime & GE_NIGHTSPULL)))) continue; // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; + // New NiGHTS attract speed dummied out because the older behavior + // is exploited as a mechanic. Uncomment to enable. + mo2->movefactor = 0; // 32*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, toucher); } } @@ -798,9 +1061,12 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; // make sure everything is as it should be, THEN take rings from players in special stages - if (player->pflags & PF_NIGHTSMODE && !toucher->target) + if (player->powers[pw_carry] == CR_NIGHTSMODE && !toucher->target) return; + if (toucher->tracer && toucher->tracer->health > 0) + return; // Don't have multiple ideya, unless it's the first one given (health = 0) + if (player->mare != special->threshold) // wrong mare return; @@ -808,18 +1074,16 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; if (G_IsSpecialStage(gamemap) && !player->exiting) - { // In special stages, share rings. Everyone gives up theirs to the player who touched the capsule + { // In special stages, share spheres. Everyone gives up theirs to the player who touched the capsule for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (&players[i] != player) && players[i].mo->health > 1) + if (playeringame[i] && (&players[i] != player) && players[i].spheres > 0) { - toucher->health += players[i].mo->health-1; - player->health = toucher->health; - players[i].mo->health = 1; - players[i].health = players[i].mo->health; + player->spheres += players[i].spheres; + players[i].spheres = 0; } } - if (!(player->health > 1) || player->exiting) + if (player->spheres <= 0 || player->exiting) return; // Mark the player as 'pull into the capsule' @@ -835,10 +1099,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->exiting) return; - if (player->bumpertime < TICRATE/4) + if (player->bumpertime <= (TICRATE/2)-5) { S_StartSound(toucher, special->info->seesound); - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) { player->bumpertime = TICRATE/2; if (special->threshold > 0) @@ -847,13 +1111,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->flyangle = special->threshold; player->speed = FixedMul(special->info->speed, special->scale); - // Potentially causes axis transfer failures. - // Also rarely worked properly anyway. - //P_UnsetThingPosition(player->mo); - //player->mo->x = special->x; - //player->mo->y = special->y; - //P_SetThingPosition(player->mo); - toucher->z = special->z+(special->height/4); + P_SetTarget(&player->mo->hnext, special); // Reference bumper for position correction on next tic } else // More like a spring { @@ -889,19 +1147,19 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_ResetPlayer(player); - P_SetPlayerMobjState(toucher, S_PLAY_FALL1); + P_SetPlayerMobjState(toucher, S_PLAY_FALL); } } return; case MT_NIGHTSSUPERLOOP: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) + if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) player->powers[pw_nights_superloop] = (UINT16)special->info->speed; else { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) players[i].powers[pw_nights_superloop] = (UINT16)special->info->speed; if (special->info->deathsound != sfx_None) S_StartSound(NULL, special->info->deathsound); @@ -916,14 +1174,14 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSDRILLREFILL: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) + if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) player->drillmeter = special->info->speed; else { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) players[i].drillmeter = special->info->speed; if (special->info->deathsound != sfx_None) S_StartSound(NULL, special->info->deathsound); @@ -938,7 +1196,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSHELPER: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) + if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { @@ -952,7 +1210,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { mobj_t *flickyobj; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].pflags & PF_NIGHTSMODE) { + if (playeringame[i] && players[i].mo && players[i].powers[pw_carry] == CR_NIGHTSMODE) { players[i].powers[pw_nights_helper] = (UINT16)special->info->speed; flickyobj = P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_NIGHTOPIANHELPER); P_SetTarget(&flickyobj->target, players[i].mo); @@ -970,21 +1228,23 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSEXTRATIME: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) + if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { player->nightstime += special->info->speed; player->startedtime += special->info->speed; + player->lapstartedtime += special->info->speed; P_RestoreMusic(player); } else { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) { players[i].nightstime += special->info->speed; players[i].startedtime += special->info->speed; + players[i].lapstartedtime += special->info->speed; P_RestoreMusic(&players[i]); } if (special->info->deathsound != sfx_None) @@ -1000,20 +1260,20 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } break; case MT_NIGHTSLINKFREEZE: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) + if (player->bot || !(player->powers[pw_carry] == CR_NIGHTSMODE)) return; if (!G_IsSpecialStage(gamemap)) { player->powers[pw_nights_linkfreeze] = (UINT16)special->info->speed; - player->linktimer = 2*TICRATE; + player->linktimer = nightslinktics; } else { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) { players[i].powers[pw_nights_linkfreeze] += (UINT16)special->info->speed; - players[i].linktimer = 2*TICRATE; + players[i].linktimer = nightslinktics; } if (special->info->deathsound != sfx_None) S_StartSound(NULL, special->info->deathsound); @@ -1027,17 +1287,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Link Freeze")); } break; - case MT_NIGHTSWING: - if (G_IsSpecialStage(gamemap) && useNightsSS) - { // Pseudo-ring. - S_StartSound(toucher, special->info->painsound); - player->totalring++; - } - else - S_StartSound(toucher, special->info->activesound); - - P_DoNightsScore(player); - break; case MT_HOOPCOLLIDE: // This produces a kind of 'domino effect' with the hoop's pieces. for (; special->hprev != NULL; special = special->hprev); // Move to the first sprite in the hoop @@ -1068,7 +1317,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (G_IsSpecialStage(gamemap)) { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) players[i].drillmeter += TICRATE/2; } else if (player->bot) @@ -1089,15 +1338,33 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Mario // // ***** // case MT_SHELL: - if (special->state == &states[S_SHELL]) // Resting anim { - // Kick that sucker around! - special->angle = toucher->angle; - P_InstaThrust(special, special->angle, FixedMul(special->info->speed, special->scale)); - S_StartSound(toucher, sfx_mario2); - P_SetMobjState(special, S_SHELL1); - P_SetTarget(&special->target, toucher); - special->threshold = (3*TICRATE)/2; + boolean bounceon = ((P_MobjFlip(toucher)*(toucher->z - (special->z + special->height/2)) > 0) && (P_MobjFlip(toucher)*toucher->momz < 0)); + if (special->threshold == TICRATE) // it's moving + { + if (bounceon) + { + // Stop it! + special->momx = special->momy = 0; + S_StartSound(toucher, sfx_mario2); + P_SetTarget(&special->target, NULL); + special->threshold = TICRATE - 1; + toucher->momz = -toucher->momz; + } + else // can't handle in PIT_CheckThing because of landing-on causing it to stop + P_DamageMobj(toucher, special, special->target, 1, 0); + } + else if (special->threshold == 0) + { + // Kick that sucker around! + special->movedir = ((special->movedir == 1) ? -1 : 1); + P_InstaThrust(special, toucher->angle, (special->info->speed*special->scale)); + S_StartSound(toucher, sfx_mario2); + P_SetTarget(&special->target, toucher); + special->threshold = (3*TICRATE)/2; + if (bounceon) + toucher->momz = -toucher->momz; + } } return; case MT_AXE: @@ -1109,95 +1376,57 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->bot) return; - junk.tag = 649; + junk.tag = LE_AXE; EV_DoElevator(&junk, bridgeFall, false); // scan the remaining thinkers to find koopa - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_KOOPA) - { - mo2->momz = 5*FRACUNIT; - break; - } + + if (mo2->type != MT_KOOPA) + continue; + + mo2->momz = 5*FRACUNIT; + break; } } break; + case MT_LETTER: + { + if (special->health && !player->bot) + { + F_StartTextPrompt(199, 0, toucher, 0, true, false); + special->health = 0; + if (ultimatemode && player->continues < 99) + player->continues++; + } + return; + } case MT_FIREFLOWER: if (player->bot) return; - player->powers[pw_shield] |= SH_FIREFLOWER; - toucher->color = SKINCOLOR_WHITE; - G_GhostAddColor(GHC_FIREFLOWER); + + S_StartSound(toucher, sfx_mario3); + + player->powers[pw_shield] = (player->powers[pw_shield] & SH_NOSTACK)|SH_FIREFLOWER; + + if (!(player->powers[pw_super] || (mariomode && player->powers[pw_invulnerability]))) + { + player->mo->color = SKINCOLOR_WHITE; + G_GhostAddColor(GHC_FIREFLOWER); + } + break; // *************** // // Misc touchables // // *************** // case MT_STARPOST: - if (player->bot) - return; - // In circuit, player must have touched all previous starposts - if (circuitmap - && special->health - player->starpostnum > 1) - { - // blatant reuse of a variable that's normally unused in circuit - if (!player->tossdelay) - S_StartSound(toucher, sfx_lose); - player->tossdelay = 3; - return; - } - - // We could technically have 91.1 Star Posts. 90 is cleaner. - if (special->health > 90) - { - CONS_Debug(DBG_GAMELOGIC, "Bad Starpost Number!\n"); - return; - } - - if (player->starpostnum >= special->health) - return; // Already hit this post - - // Save the player's time and position. - player->starposttime = leveltime; - player->starpostx = toucher->x>>FRACBITS; - player->starposty = toucher->y>>FRACBITS; - player->starpostz = special->z>>FRACBITS; - player->starpostangle = special->angle; - player->starpostnum = special->health; - P_ClearStarPost(special->health); - - // Find all starposts in the level with this value. - { - thinker_t *th; - mobj_t *mo2; - - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo2 = (mobj_t *)th; - - if (mo2 == special) - continue; - - if (mo2->type == MT_STARPOST && mo2->health == special->health) - { - if (!(netgame && circuitmap && player != &players[consoleplayer])) - P_SetMobjState(mo2, mo2->info->painstate); - } - } - } - - S_StartSound(toucher, special->info->painsound); - - if (!(netgame && circuitmap && player != &players[consoleplayer])) - P_SetMobjState(special, special->info->painstate); + P_TouchStarPost(special, player, special->spawnpoint && (special->spawnpoint->options & MTF_OBJECTSPECIAL)); return; case MT_FAKEMOBILE: @@ -1223,11 +1452,15 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->momx = P_ReturnThrustX(special, angle, touchspeed); toucher->momy = P_ReturnThrustY(special, angle, touchspeed); toucher->momz = -toucher->momz; - if (player->pflags & PF_GLIDING) + if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher)) { - player->pflags &= ~(PF_GLIDING|PF_JUMPED); - P_SetPlayerMobjState(toucher, S_PLAY_FALL1); + player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); + P_SetPlayerMobjState(toucher, S_PLAY_FALL); + toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3); + toucher->momx = 7*toucher->momx>>3; + toucher->momy = 7*toucher->momy>>3; } + player->homing = 0; // Play a bounce sound? S_StartSound(toucher, special->info->painsound); @@ -1235,7 +1468,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; case MT_BLACKEGGMAN_GOOPFIRE: - if (toucher->state != &states[S_PLAY_PAIN] && !player->powers[pw_flashing]) + if (!player->powers[pw_flashing]) { toucher->momx = 0; toucher->momy = 0; @@ -1243,13 +1476,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (toucher->momz != 0) special->momz = toucher->momz; - player->powers[pw_ingoop] = 2; - - if (player->pflags & PF_ITEMHANG) - { - P_SetTarget(&toucher->tracer, NULL); - player->pflags &= ~PF_ITEMHANG; - } + player->powers[pw_carry] = CR_BRAKGOOP; + P_SetTarget(&toucher->tracer, special); P_ResetPlayer(player); @@ -1261,28 +1489,13 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_SetMobjState(special->target, special->target->info->raisestate); } } - else - player->powers[pw_ingoop] = 0; return; case MT_EGGSHIELD: { - fixed_t touchx, touchy, touchspeed; - angle_t angle; - - if (P_AproxDistance(toucher->x-special->x, toucher->y-special->y) > - P_AproxDistance((toucher->x-toucher->momx)-special->x, (toucher->y-toucher->momy)-special->y)) - { - touchx = toucher->x + toucher->momx; - touchy = toucher->y + toucher->momy; - } - else - { - touchx = toucher->x; - touchy = toucher->y; - } - - angle = R_PointToAngle2(special->x, special->y, touchx, touchy) - special->angle; - touchspeed = P_AproxDistance(toucher->momx, toucher->momy); + angle_t angle = R_PointToAngle2(special->x, special->y, toucher->x, toucher->y) - special->angle; + fixed_t touchspeed = P_AproxDistance(toucher->momx, toucher->momy); + if (touchspeed < special->scale) + touchspeed = special->scale; // Blocked by the shield? if (!(angle > ANGLE_90 && angle < ANGLE_270)) @@ -1290,18 +1503,24 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->momx = P_ReturnThrustX(special, special->angle, touchspeed); toucher->momy = P_ReturnThrustY(special, special->angle, touchspeed); toucher->momz = -toucher->momz; - if (player->pflags & PF_GLIDING) + if (player->pflags & PF_GLIDING && !P_IsObjectOnGround(toucher)) { - player->pflags &= ~(PF_GLIDING|PF_JUMPED); - P_SetPlayerMobjState(toucher, S_PLAY_FALL1); + player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); + P_SetPlayerMobjState(toucher, S_PLAY_FALL); + toucher->momz += P_MobjFlip(toucher) * (player->speed >> 3); + toucher->momx = 7*toucher->momx>>3; + toucher->momy = 7*toucher->momy>>3; } + player->homing = 0; // Play a bounce sound? S_StartSound(toucher, special->info->painsound); - return; + + // experimental bounce + if (special->target) + special->target->extravalue1 = -special->target->info->speed; } - else if (((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) - || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? + else { // Shatter the shield! toucher->momx = -toucher->momx/2; @@ -1312,6 +1531,46 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; + case MT_EGGROBO1: + if (special->state == &states[special->info->deathstate]) + return; + if (P_PlayerInPain(player)) + return; + + P_SetMobjState(special, special->info->meleestate); + special->angle = special->movedir; + special->momx = special->momy = 0; + + // Buenos Dias Mandy + P_SetPlayerMobjState(toucher, S_PLAY_STUN); + player->pflags &= ~PF_APPLYAUTOBRAKE; + P_ResetPlayer(player); + player->drawangle = special->angle + ANGLE_180; + P_InstaThrust(toucher, special->angle, FixedMul(3*special->info->speed, special->scale/2)); + toucher->z += P_MobjFlip(toucher); + if (toucher->eflags & MFE_UNDERWATER) // unlikely. + P_SetObjectMomZ(toucher, FixedDiv(10511*FRACUNIT,2600*FRACUNIT), false); + else + P_SetObjectMomZ(toucher, FixedDiv(69*FRACUNIT,10*FRACUNIT), false); + if (P_IsLocalPlayer(player)) + { + quake.intensity = 9*FRACUNIT; + quake.time = TICRATE/2; + quake.epicenter = NULL; + } + +#if 0 // camera redirection - deemed unnecessary + toucher->angle = special->angle; + if (player == &players[consoleplayer]) + localangle = toucher->angle; + else if (player == &players[secondarydisplayplayer]) + localangle2 = toucher->angle; +#endif + + S_StartSound(toucher, special->info->attacksound); // home run + + return; + case MT_BIGTUMBLEWEED: case MT_LITTLETUMBLEWEED: if (toucher->momx || toucher->momy) @@ -1326,11 +1585,10 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_SetMobjState(special, special->info->seestate); } return; - case MT_SMALLMACECHAIN: - case MT_BIGMACECHAIN: - // Is this the last link in the chain? - if (toucher->momz > 0 || !(special->flags & MF_AMBUSH) - || (player->pflags & PF_ITEMHANG) || (player->pflags & PF_MACESPIN)) + case MT_SMALLGRABCHAIN: + case MT_BIGGRABCHAIN: + if (P_MobjFlip(toucher)*toucher->momz > 0 + || (player->powers[pw_carry])) return; if (toucher->z > special->z + special->height/2) @@ -1342,55 +1600,30 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (player->powers[pw_flashing]) return; + if (special->movefactor && special->tracer && special->tracer->angle != ANGLE_90 && special->tracer->angle != ANGLE_270) + { // I don't expect you to understand this, Mr Bond... + angle_t ang = R_PointToAngle2(special->x, special->y, toucher->x, toucher->y) - special->tracer->angle; + if ((special->movefactor > 0) == (special->tracer->angle > ANGLE_90 && special->tracer->angle < ANGLE_270)) + ang += ANGLE_180; + if (ang < ANGLE_180) + return; // I expect you to die. + } + P_ResetPlayer(player); P_SetTarget(&toucher->tracer, special); - if (special->target && (special->target->type == MT_SPINMACEPOINT || special->target->type == MT_HIDDEN_SLING)) + if (special->tracer && !(special->tracer->flags2 & MF2_STRONGBOX)) { - player->pflags |= PF_MACESPIN; + player->powers[pw_carry] = CR_MACESPIN; S_StartSound(toucher, sfx_spin); - P_SetPlayerMobjState(toucher, S_PLAY_ATK1); + P_SetPlayerMobjState(toucher, S_PLAY_ROLL); } else - player->pflags |= PF_ITEMHANG; + player->powers[pw_carry] = CR_GENERIC; // Can't jump first frame player->pflags |= PF_JUMPSTASIS; - return; - case MT_BIGMINE: - case MT_BIGAIRMINE: - // Spawn explosion! - P_SpawnMobj(special->x, special->y, special->z, special->info->mass); - P_RadiusAttack(special, special, special->info->damage); - S_StartSound(special, special->info->deathsound); - P_SetMobjState(special, special->info->deathstate); - return; - case MT_SPECIALSPIKEBALL: - if (!(!useNightsSS && G_IsSpecialStage(gamemap))) // Only for old special stages - { - P_DamageMobj(toucher, special, special, 1); - return; - } - if (player->powers[pw_invulnerability] || player->powers[pw_flashing] - || (player->powers[pw_super] && !(ALL7EMERALDS(player->powers[pw_emeralds])))) - return; - if (player->powers[pw_shield] || player->bot) //If One-Hit Shield - { - P_RemoveShield(player); - S_StartSound(toucher, sfx_shldls); // Ba-Dum! Shield loss. - } - else - { - P_PlayRinglossSound(toucher); - if (toucher->health > 10) - toucher->health -= 10; - else - toucher->health = 1; - player->health = toucher->health; - } - - P_DoPlayerPain(player, special, NULL); return; case MT_EGGMOBILE2_POGO: // sanity checks @@ -1399,7 +1632,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Goomba Stomp'd! if (special->target->momz < 0) { - P_DamageMobj(toucher, special, special->target, 1); + P_DamageMobj(toucher, special, special->target, 1, 0); //special->target->momz = -special->target->momz; special->target->momx = special->target->momy = 0; special->target->momz = 0; @@ -1411,37 +1644,48 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; case MT_EXTRALARGEBUBBLE: - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) + if (player->powers[pw_shield] & SH_PROTECTWATER) return; if (maptol & TOL_NIGHTS) return; if (mariomode) return; + if (special->state-states != S_EXTRALARGEBUBBLE) + return; // Don't grab the bubble during its spawn animation else if (toucher->eflags & MFE_VERTICALFLIP) { - if (special->z+special->height < toucher->z + toucher->height / 3 - || special->z+special->height > toucher->z + (toucher->height*2/3)) + if (special->z+special->height < toucher->z + || special->z+special->height > toucher->z + (toucher->height*2/3)) return; // Only go in the mouth } - else if (special->z < toucher->z + toucher->height / 3 + else if (special->z < toucher->z || special->z > toucher->z + (toucher->height*2/3)) return; // Only go in the mouth // Eaten by player! - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) + if ((!player->bot) && (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1)) + { + player->powers[pw_underwater] = underwatertics + 1; P_RestoreMusic(player); + } if (player->powers[pw_underwater] < underwatertics + 1) player->powers[pw_underwater] = underwatertics + 1; if (!player->climbing) { + if (player->bot && toucher->state-states != S_PLAY_GASP) + S_StartSound(toucher, special->info->deathsound); // Force it to play a sound for bots P_SetPlayerMobjState(toucher, S_PLAY_GASP); P_ResetPlayer(player); } toucher->momx = toucher->momy = toucher->momz = 0; - break; + + if (player->bot) + return; + else + break; case MT_WATERDROP: if (special->state == &states[special->info->spawnstate]) @@ -1454,6 +1698,74 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } return; + case MT_CANARIVORE_GAS: + // if player and gas touch, attach gas to player (overriding any gas that already attached) and apply slowdown effect + special->flags |= MF_NOGRAVITY|MF_NOCLIPHEIGHT; + P_UnsetThingPosition(special); + special->x = toucher->x - toucher->momx/2; + special->y = toucher->y - toucher->momy/2; + special->z = toucher->z - toucher->momz/2; + P_SetThingPosition(special); + toucher->momx = FixedMul(toucher->momx, 50*FRACUNIT/51); + toucher->momy = FixedMul(toucher->momy, 50*FRACUNIT/51); + special->momx = toucher->momx; + special->momy = toucher->momy; + special->momz = toucher->momz; + return; + + case MT_MINECARTSPAWNER: + if (!player->bot && special->fuse <= TICRATE && player->powers[pw_carry] != CR_MINECART) + { + mobj_t *mcart = P_SpawnMobj(special->x, special->y, special->z, MT_MINECART); + P_SetTarget(&mcart->target, toucher); + mcart->angle = toucher->angle = player->drawangle = special->angle; + mcart->friction = FRACUNIT; + + P_ResetPlayer(player); + player->pflags |= PF_JUMPDOWN; + player->powers[pw_carry] = CR_MINECART; + player->pflags &= ~PF_APPLYAUTOBRAKE; + P_SetTarget(&toucher->tracer, mcart); + toucher->momx = toucher->momy = toucher->momz = 0; + + special->fuse = 3*TICRATE; + special->flags2 |= MF2_DONTDRAW; + } + return; + + case MT_MINECARTEND: + if (player->powers[pw_carry] == CR_MINECART && toucher->tracer && !P_MobjWasRemoved(toucher->tracer) && toucher->tracer->health) + { + fixed_t maxz = max(toucher->z, special->z + 35*special->scale); + + toucher->momx = toucher->tracer->momx/2; + toucher->momy = toucher->tracer->momy/2; + toucher->momz = toucher->tracer->momz + P_AproxDistance(toucher->tracer->momx, toucher->tracer->momy)/2; + P_ResetPlayer(player); + player->pflags &= ~PF_APPLYAUTOBRAKE; + P_SetPlayerMobjState(toucher, S_PLAY_FALL); + P_SetTarget(&toucher->tracer->target, NULL); + P_KillMobj(toucher->tracer, toucher, special, 0); + P_SetTarget(&toucher->tracer, NULL); + player->powers[pw_carry] = CR_NONE; + P_UnsetThingPosition(toucher); + toucher->x = special->x; + toucher->y = special->y; + toucher->z = maxz; + P_SetThingPosition(toucher); + } + return; + + case MT_MINECARTSWITCHPOINT: + if (player->powers[pw_carry] == CR_MINECART && toucher->tracer && !P_MobjWasRemoved(toucher->tracer) && toucher->tracer->health) + { + mobjflag2_t destambush = special->flags2 & MF2_AMBUSH; + angle_t angdiff = toucher->tracer->angle - special->angle; + if (angdiff > ANGLE_90 && angdiff < ANGLE_270) + destambush ^= MF2_AMBUSH; + toucher->tracer->flags2 = (toucher->tracer->flags2 & ~MF2_AMBUSH) | destambush; + } + return; default: // SOC or script pickup if (player->bot) return; @@ -1463,7 +1775,114 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } S_StartSound(toucher, special->info->deathsound); // was NULL, but changed to player so you could hear others pick up rings - P_KillMobj(special, NULL, toucher); + P_KillMobj(special, NULL, toucher, 0); + special->shadowscale = 0; +} + +/** Saves a player's level progress at a star post + * + * \param post The star post to trigger + * \param player The player that should receive the checkpoint + * \param snaptopost If true, the respawn point will use the star post's position, otherwise player x/y and star post z + */ +void P_TouchStarPost(mobj_t *post, player_t *player, boolean snaptopost) +{ + size_t i; + mobj_t *toucher = player->mo; + mobj_t *checkbase = snaptopost ? post : toucher; + + if (player->bot) + return; + // In circuit, player must have touched all previous starposts + if (circuitmap + && post->health - player->starpostnum > 1) + { + // blatant reuse of a variable that's normally unused in circuit + if (!player->tossdelay) + S_StartSound(toucher, sfx_lose); + player->tossdelay = 3; + return; + } + + // With the parameter + angle setup, we can go up to 1365 star posts. Who needs that many? + if (post->health > 1365) + { + CONS_Debug(DBG_GAMELOGIC, "Bad Starpost Number!\n"); + return; + } + + if (player->starpostnum >= post->health) + return; // Already hit this post + + if (cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (netgame || multiplayer)) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i]) + { + if (players[i].bot) // ignore dumb, stupid tails + continue; + + players[i].starposttime = leveltime; + players[i].starpostx = checkbase->x>>FRACBITS; + players[i].starposty = checkbase->y>>FRACBITS; + players[i].starpostz = post->z>>FRACBITS; + players[i].starpostangle = post->angle; + players[i].starpostscale = player->mo->destscale; + if (post->flags2 & MF2_OBJECTFLIP) + { + players[i].starpostscale *= -1; + players[i].starpostz += post->height>>FRACBITS; + } + players[i].starpostnum = post->health; + + if (cv_coopstarposts.value == 2 && (players[i].playerstate == PST_DEAD || players[i].spectator) && P_GetLives(&players[i])) + P_SpectatorJoinGame(&players[i]); //players[i].playerstate = PST_REBORN; + } + } + S_StartSound(NULL, post->info->painsound); + } + else + { + // Save the player's time and position. + player->starposttime = leveltime; + player->starpostx = checkbase->x>>FRACBITS; + player->starposty = checkbase->y>>FRACBITS; + player->starpostz = post->z>>FRACBITS; + player->starpostangle = post->angle; + player->starpostscale = player->mo->destscale; + if (post->flags2 & MF2_OBJECTFLIP) + { + player->starpostscale *= -1; + player->starpostz += post->height>>FRACBITS; + } + player->starpostnum = post->health; + S_StartSound(toucher, post->info->painsound); + } + + P_ClearStarPost(post->health); + + // Find all starposts in the level with this value - INCLUDING this one! + if (!(netgame && circuitmap && player != &players[consoleplayer])) + { + thinker_t *th; + mobj_t *mo2; + + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + + if (mo2->type != MT_STARPOST) + continue; + if (mo2->health != post->health) + continue; + + P_SetMobjState(mo2, mo2->info->painstate); + } + } } /** Prints death messages relating to a dying or hit player. @@ -1471,8 +1890,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) * \param player Affected player. * \param inflictor The attack weapon used, can be NULL. * \param source The attacker, can be NULL. + * \param damagetype The type of damage dealt to the player. If bit 7 (0x80) is set, this was an instant-kill. */ -static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *source) +static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { const char *str = NULL; boolean deathonly = false; @@ -1482,24 +1902,29 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour char targetname[MAXPLAYERNAME+4]; char sourcename[MAXPLAYERNAME+4]; - if (G_PlatformGametype()) + if (!(gametyperules & (GTR_RINGSLINGER|GTR_HURTMESSAGES))) return; // Not in coop, etc. if (!player) return; // Impossible! + if (!player->mo) + return; // Also impossible! + if (player->spectator) return; // No messages for dying (crushed) spectators. if (!netgame) return; // Presumably it's obvious what's happening in splitscreen. -#ifdef HAVE_BLUA - if (LUAh_HurtMsg(player, inflictor, source)) + if (LUAh_HurtMsg(player, inflictor, source, damagetype)) return; -#endif - deadtarget = (player->health <= 0); + deadtarget = (player->mo->health <= 0); + + // Don't log every hazard hit if they don't want us to. + if (!deadtarget && !cv_hazardlog.value) + return; // Target's name snprintf(targetname, sizeof(targetname), "%s%s%s", @@ -1533,8 +1958,10 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour else switch (inflictor->type) { case MT_PLAYER: - if ((inflictor->player->powers[pw_shield] & SH_NOSTACK) == SH_BOMB) + if (damagetype == DMG_NUKE) // SH_ARMAGEDDON, armageddon shield str = M_GetText("%s%s's armageddon blast %s %s.\n"); + else if ((inflictor->player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && (inflictor->player->pflags & PF_SHIELDABILITY)) + str = M_GetText("%s%s's elemental stomp %s %s.\n"); else if (inflictor->player->powers[pw_invulnerability]) str = M_GetText("%s%s's invincibility aura %s %s.\n"); else if (inflictor->player->powers[pw_super]) @@ -1584,27 +2011,11 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour } else switch (source->type) { - case MT_NULL: - switch(source->threshold) - { - case 42: - deathonly = true; - str = M_GetText("%s drowned.\n"); - break; - case 43: - str = M_GetText("%s was %s by spikes.\n"); - break; - case 44: - deathonly = true; - str = M_GetText("%s was crushed.\n"); - break; - } - break; - case MT_EGGMANICO: - case MT_EGGMANBOX: + case MT_EGGMAN_ICON: str = M_GetText("%s was %s by Eggman's nefarious TV magic.\n"); break; case MT_SPIKE: + case MT_WALLSPIKE: str = M_GetText("%s was %s by spikes.\n"); break; default: @@ -1615,39 +2026,57 @@ static void P_HitDeathMessages(player_t *player, mobj_t *inflictor, mobj_t *sour else { // null source, environment kills - // TERRIBLE HACK for hit damage because P_DoPlayerPain moves the player... - // I'll put it back, I promise! - player->mo->z -= player->mo->momz+1; - if (P_PlayerTouchingSectorSpecial(player, 1, 2)) - str = M_GetText("%s was %s by chemical water.\n"); - else if (P_PlayerTouchingSectorSpecial(player, 1, 3)) - str = M_GetText("%s was %s by molten lava.\n"); - else if (P_PlayerTouchingSectorSpecial(player, 1, 4)) - str = M_GetText("%s was %s by electricity.\n"); - else if (deadtarget) + switch (damagetype) { - deathonly = true; - if (P_PlayerTouchingSectorSpecial(player, 1, 6) - || P_PlayerTouchingSectorSpecial(player, 1, 7)) - str = M_GetText("%s fell into a bottomless pit.\n"); - else if (P_PlayerTouchingSectorSpecial(player, 1, 12)) - str = M_GetText("%s asphyxiated in space.\n"); - else - str = M_GetText("%s died.\n"); + case DMG_WATER: + str = M_GetText("%s was %s by dangerous water.\n"); + break; + case DMG_FIRE: + str = M_GetText("%s was %s by molten lava.\n"); + break; + case DMG_ELECTRIC: + str = M_GetText("%s was %s by electricity.\n"); + break; + case DMG_SPIKE: + str = M_GetText("%s was %s by spikes.\n"); + break; + case DMG_DROWNED: + deathonly = true; + str = M_GetText("%s drowned.\n"); + break; + case DMG_CRUSHED: + deathonly = true; + str = M_GetText("%s was crushed.\n"); + break; + case DMG_DEATHPIT: + if (deadtarget) + { + deathonly = true; + str = M_GetText("%s fell into a bottomless pit.\n"); + } + break; + case DMG_SPACEDROWN: + if (deadtarget) + { + deathonly = true; + str = M_GetText("%s asphyxiated in space.\n"); + } + break; + default: + if (deadtarget) + { + deathonly = true; + str = M_GetText("%s died.\n"); + } + break; } if (!str) str = M_GetText("%s was %s by an environmental hazard.\n"); - - player->mo->z += player->mo->momz+1; } if (!str) // Should not happen! Unless we missed catching something above. return; - // Don't log every hazard hit if they don't want us to. - if (!deadtarget && !cv_hazardlog.value) - return; - if (deathonly) { if (!deadtarget) @@ -1676,7 +2105,7 @@ void P_CheckTimeLimit(void) if (!(multiplayer || netgame)) return; - if (G_PlatformGametype()) + if (!(gametyperules & GTR_TIMELIMIT)) return; if (leveltime < timelimitintics) @@ -1694,7 +2123,7 @@ void P_CheckTimeLimit(void) for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator - || (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT)) + || (players[i].pflags & PF_GAMETYPEOVER) || (players[i].pflags & PF_TAGIT)) continue; CONS_Printf(M_GetText("%s received double points for surviving the round.\n"), player_names[i]); @@ -1707,7 +2136,7 @@ void P_CheckTimeLimit(void) } //Optional tie-breaker for Match/CTF - else if (cv_overtime.value) + else if ((cv_overtime.value) && (gametyperules & GTR_OVERTIME)) { INT32 playerarray[MAXPLAYERS]; INT32 tempplayer = 0; @@ -1789,7 +2218,7 @@ void P_CheckPointLimit(void) if (!(multiplayer || netgame)) return; - if (G_PlatformGametype()) + if (!(gametyperules & GTR_POINTLIMIT)) return; // pointlimit is nonzero, check if it's been reached by this player @@ -1839,9 +2268,9 @@ void P_CheckSurvivors(void) { if (players[i].spectator) spectators++; - else if (players[i].pflags & PF_TAGIT) + else if ((players[i].pflags & PF_TAGIT) && players[i].quittime < 30 * TICRATE) taggers++; - else if (!(players[i].pflags & PF_TAGGED)) + else if (!(players[i].pflags & PF_GAMETYPEOVER) && players[i].quittime < 30 * TICRATE) { survivorarray[survivors] = i; survivors++; @@ -1931,19 +2360,19 @@ boolean P_CheckRacers(void) * \param target The victim. * \param inflictor The attack weapon. May be NULL (environmental damage). * \param source The attacker. May be NULL. + * \param damagetype The type of damage dealt that killed the target. If bit 7 (0x80) was set, this was an instant-death. * \todo Cleanup, refactor, split up. * \sa P_DamageMobj */ -void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) +void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype) { - mobjtype_t item; mobj_t *mo; if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) P_SetTarget(&target->tracer, inflictor); - if (!useNightsSS && G_IsSpecialStage(gamemap) && target->player && sstimer > 6) - sstimer = 6; // Just let P_Ticker take care of the rest. + if (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap) && target->player && target->player->nightstime > 6) + target->player->nightstime = 6; // Just let P_Ticker take care of the rest. if (target->flags & (MF_ENEMY|MF_BOSS)) target->momx = target->momy = target->momz = 0; @@ -1952,24 +2381,25 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->flags |= MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT; // Don't drop Tails 03-08-2000 if (target->flags2 & MF2_NIGHTSPULL) + { P_SetTarget(&target->tracer, NULL); + target->movefactor = 0; // reset NightsItemChase timer + } // dead target is no more shootable target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); target->flags2 &= ~(MF2_SKULLFLY|MF2_NIGHTSPULL); target->health = 0; // This makes it easy to check if something's dead elsewhere. -#ifdef HAVE_BLUA - if (LUAh_MobjDeath(target, inflictor, source) || P_MobjWasRemoved(target)) + if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) return; -#endif // Let EVERYONE know what happened to a player! 01-29-2002 Tails if (target->player && !target->player->spectator) { if (metalrecording) // Ack! Metal Sonic shouldn't die! Cut the tape, end recording! - G_StopMetalRecording(); - if (gametype == GT_MATCH && cv_match_scoring.value == 0 // note, no team match suicide penalty + G_StopMetalRecording(true); + if ((gametyperules & GTR_DEATHPENALTY) // note, no team match suicide penalty && ((target == source) || (source == NULL && inflictor == NULL) || (source && !source->player))) { // Suicide penalty if (target->player->score >= 50) @@ -1988,7 +2418,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { P_SetTarget(&target->target, source); source->player->numboxes++; - if ((cv_itemrespawn.value && gametype != GT_COOP && (modifiedgame || netgame || multiplayer))) + if (cv_itemrespawn.value && gametype != GT_COOP && (modifiedgame || netgame || multiplayer)) target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation } @@ -2011,28 +2441,34 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // to make people want to actually dash towards/paraloop enemies if (++source->player->linkcount > source->player->maxlink) source->player->maxlink = source->player->linkcount; - source->player->linktimer = 2*TICRATE; + source->player->linktimer = nightslinktics; } } else { if (target->flags & MF_BOSS) score = 1000; - else if ((target->flags & MF_ENEMY) && !(target->flags & MF_MISSILE)) + else if ((target->flags & MF_ENEMY) && !(target->flags & MF_MISSILE) && target->info->spawnhealth) { + UINT8 locscoreadd = source->player->scoreadd + target->info->spawnhealth; mobj_t *scoremobj; UINT32 scorestate = mobjinfo[MT_SCORE].spawnstate; scoremobj = P_SpawnMobj(target->x, target->y, target->z + (target->height / 2), MT_SCORE); - // On ground? No chain starts. - if (!source->player->powers[pw_invulnerability] && P_IsObjectOnGround(source)) + // More Sonic-like point system + if (!mariomode) switch (locscoreadd) { - source->player->scoreadd = 0; - score = 100; + case 1: score = 100; break; + case 2: score = 200; scorestate += 1; break; + case 3: score = 500; scorestate += 2; break; + case 4: case 5: case 6: case 7: case 8: case 9: + case 10: case 11: case 12: case 13: case 14: + score = 1000; scorestate += 3; break; + default: score = 10000; scorestate += 4; break; } // Mario Mode has Mario-like chain point values - else if (mariomode) switch (++source->player->scoreadd) + else switch (locscoreadd) { case 1: score = 100; break; case 2: score = 200; scorestate += 1; break; @@ -2052,19 +2488,10 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) scorestate += 10; break; } - // More Sonic-like point system - else switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 500; scorestate += 2; break; - case 4: case 5: case 6: case 7: case 8: case 9: - case 10: case 11: case 12: case 13: case 14: - score = 1000; scorestate += 3; break; - default: score = 10000; scorestate += 4; break; - } P_SetMobjState(scoremobj, scorestate); + + source->player->scoreadd = locscoreadd; } } @@ -2077,20 +2504,70 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { target->flags &= ~(MF_SOLID|MF_SHOOTABLE); // does not block P_UnsetThingPosition(target); - target->flags |= MF_NOBLOCKMAP; + target->flags |= MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY; P_SetThingPosition(target); + target->standingslope = NULL; + target->pmomz = 0; - if (!target->player->bot && !G_IsSpecialStage(gamemap) + if (target->player->powers[pw_super]) + { + target->player->powers[pw_super] = 0; + if (P_IsLocalPlayer(target->player)) + { + music_stack_noposition = true; // HACK: Do not reposition next music + music_stack_fadeout = MUSICRATE/2; // HACK: Fade out current music + } + P_RestoreMusic(target->player); + + if (gametype != GT_COOP) + { + HU_SetCEchoFlags(0); + HU_SetCEchoDuration(5); + HU_DoCEcho(va("%s\\is no longer super.\\\\\\\\", player_names[target->player-players])); + } + } + + target->color = target->player->skincolor; + target->colorized = false; + G_GhostAddColor(GHC_NORMAL); + + if ((target->player->lives <= 1) && (netgame || multiplayer) && G_GametypeUsesCoopLives() && (cv_cooplives.value == 0)) + ; + else if (!target->player->bot && !target->player->spectator && (target->player->lives != INFLIVES) && G_GametypeUsesLives()) { - target->player->lives -= 1; // Lose a life Tails 03-11-2000 + if (!(target->player->pflags & PF_FINISHED)) + target->player->lives -= 1; // Lose a life Tails 03-11-2000 if (target->player->lives <= 0) // Tails 03-14-2000 { - if (P_IsLocalPlayer(target->player)/* && target->player == &players[consoleplayer] */) + boolean gameovermus = false; + if ((netgame || multiplayer) && G_GametypeUsesCoopLives() && (cv_cooplives.value != 1)) { - S_StopMusic(); // Stop the Music! Tails 03-14-2000 - S_ChangeMusicInternal("gmover", false); // Yousa dead now, Okieday? Tails 03-14-2000 + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].lives > 0) + break; + } + if (i == MAXPLAYERS) + gameovermus = true; + } + else if (P_IsLocalPlayer(target->player)) + gameovermus = true; + + if (gameovermus) // Yousa dead now, Okieday? Tails 03-14-2000 + S_ChangeMusicEx("_gover", 0, 0, 0, (2*MUSICRATE) - (MUSICRATE/25), 0); // 1.96 seconds + //P_PlayJingle(target->player, JT_GOVER); // can't be used because incompatible with track fadeout + + if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking) && numgameovers < maxgameovers) + { + numgameovers++; + if ((!modifiedgame || savemoddata) && cursaveslot > 0) + G_SaveGameOver((UINT32)cursaveslot, (target->player->continues <= 0)); } } } @@ -2128,7 +2605,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } else { - if (!(target->player->pflags & PF_TAGGED)) + if (!(target->player->pflags & PF_GAMETYPEOVER)) { //otherwise, increment the tagger's score. //in hide and seek, suiciding players are counted as found. @@ -2140,7 +2617,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) P_AddPlayerScore(&players[w], 100); } - target->player->pflags |= PF_TAGGED; + target->player->pflags |= PF_GAMETYPEOVER; CONS_Printf(M_GetText("%s was found!\n"), player_names[target->player-players]); P_CheckSurvivors(); } @@ -2152,81 +2629,8 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) if (source && target && target->player && source->player) P_PlayVictorySound(source); // Killer laughs at you. LAUGHS! BWAHAHAHA! - // Drop stuff. - // This determines the kind of object spawned - // during the death frame of a thing. - if (!mariomode // Don't show birds, etc. in Mario Mode Tails 12-23-2001 - && target->flags & MF_ENEMY) - { - if (cv_soniccd.value) - item = MT_SEED; - else - { - INT32 prandom; - - switch (target->type) - { - case MT_REDCRAWLA: - case MT_GOLDBUZZ: - case MT_SKIM: - case MT_UNIDUS: - item = MT_BUNNY; - break; - - case MT_BLUECRAWLA: - case MT_JETTBOMBER: - case MT_GFZFISH: - item = MT_BIRD; - break; - - case MT_JETTGUNNER: - case MT_CRAWLACOMMANDER: - case MT_REDBUZZ: - case MT_DETON: - item = MT_MOUSE; - break; - - case MT_GSNAPPER: - case MT_EGGGUARD: - case MT_SPRINGSHELL: - item = MT_COW; - break; - - case MT_MINUS: - case MT_VULTURE: - case MT_POINTY: - case MT_YELLOWSHELL: - item = MT_CHICKEN; - break; - - case MT_AQUABUZZ: - item = MT_REDBIRD; - break; - - default: - if (target->info->doomednum) - prandom = target->info->doomednum%5; // "Random" animal for new enemies. - else - prandom = P_RandomKey(5); // No placable object, just use a random number. - - switch(prandom) - { - default: item = MT_BUNNY; break; - case 1: item = MT_BIRD; break; - case 2: item = MT_MOUSE; break; - case 3: item = MT_COW; break; - case 4: item = MT_CHICKEN; break; - } - break; - } - } - - mo = P_SpawnMobj(target->x, target->y, target->z + (target->height / 2) - FixedMul(mobjinfo[item].height / 2, target->scale), item); - mo->destscale = target->scale; - P_SetScale(mo, mo->destscale); - } // Other death animation effects - else switch(target->type) + switch(target->type) { case MT_BOUNCEPICKUP: case MT_RAILPICKUP: @@ -2238,166 +2642,323 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->fuse = target->info->damage; break; + case MT_BUGGLE: + if (inflictor && inflictor->player // did a player kill you? Spawn relative to the player so they're bound to get it + && P_AproxDistance(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough? + && inflictor->z <= target->z + target->height + FixedMul(8*FRACUNIT, inflictor->scale) + && inflictor->z + inflictor->height >= target->z - FixedMul(8*FRACUNIT, inflictor->scale)) + mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE); + else + mo = P_SpawnMobj(target->x, target->y, target->z, MT_EXTRALARGEBUBBLE); + mo->destscale = target->scale; + P_SetScale(mo, mo->destscale); + P_SetMobjState(mo, mo->info->raisestate); + break; + + case MT_YELLOWSHELL: + P_SpawnMobjFromMobj(target, 0, 0, 0, MT_YELLOWSPRING); + break; + + case MT_CRAWLACOMMANDER: + target->momx = target->momy = target->momz = 0; + break; + + case MT_CRUSHSTACEAN: + if (target->tracer) + { + mobj_t *chain = target->tracer->target, *chainnext; + while (chain) + { + chainnext = chain->target; + P_RemoveMobj(chain); + chain = chainnext; + } + S_StopSound(target->tracer); + P_KillMobj(target->tracer, inflictor, source, damagetype); + } + break; + + case MT_BANPYURA: + if (target->tracer) + { + S_StopSound(target->tracer); + P_KillMobj(target->tracer, inflictor, source, damagetype); + } + break; + + case MT_EGGSHIELD: + P_SetObjectMomZ(target, 4*target->scale, false); + P_InstaThrust(target, target->angle, 3*target->scale); + target->flags = (target->flags|MF_NOCLIPHEIGHT) & ~MF_NOGRAVITY; + break; + + case MT_DRAGONBOMBER: + { + mobj_t *segment = target; + while (segment->tracer != NULL) + { + P_KillMobj(segment->tracer, NULL, NULL, 0); + segment = segment->tracer; + } + break; + } + + case MT_EGGMOBILE3: + { + mobj_t *mo2; + thinker_t *th; + UINT32 i = 0; // to check how many clones we've removed + + // scan the thinkers to make sure all the old pinch dummies are gone on death + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)th; + if (mo->type != (mobjtype_t)target->info->mass) + continue; + if (mo->tracer != target) + continue; + + P_KillMobj(mo, inflictor, source, damagetype); + mo->destscale = mo->scale/8; + mo->scalespeed = (mo->scale - mo->destscale)/(2*TICRATE); + mo->momz = mo->info->speed; + mo->angle = FixedAngle((P_RandomKey(36)*10)<angle = mo->angle; + P_SetMobjState(mo2, S_BOSSSEBH2); + + if (++i == 2) // we've already removed 2 of these, let's stop now + break; + else + S_StartSound(mo, mo->info->deathsound); // done once to prevent sound stacking + } + } + break; + + case MT_BIGMINE: + if (inflictor) + { + fixed_t dx = target->x - inflictor->x, dy = target->y - inflictor->y, dz = target->z - inflictor->z; + fixed_t dm = FixedHypot(dz, FixedHypot(dy, dx)); + target->momx = FixedDiv(FixedDiv(dx, dm), dm)*512; + target->momy = FixedDiv(FixedDiv(dy, dm), dm)*512; + target->momz = FixedDiv(FixedDiv(dz, dm), dm)*512; + } + if (source) + P_SetTarget(&target->tracer, source); + break; + + case MT_BLASTEXECUTOR: + if (target->spawnpoint) + P_LinedefExecute(target->spawnpoint->angle, (source ? source : inflictor), target->subsector->sector); + break; + + case MT_SPINBOBERT: + if (target->hnext) + P_KillMobj(target->hnext, inflictor, source, damagetype); + if (target->hprev) + P_KillMobj(target->hprev, inflictor, source, damagetype); + break; + case MT_EGGTRAP: // Time for birdies! Yaaaaaaaay! - target->fuse = TICRATE*2; + target->fuse = TICRATE; + break; + + case MT_MINECART: + A_Scream(target); + target->momx = target->momy = target->momz = 0; + if (target->target && target->target->health) + P_KillMobj(target->target, target, source, 0); break; case MT_PLAYER: - target->fuse = TICRATE*3; // timer before mobj disappears from view (even if not an actual player) - target->momx = target->momy = target->momz = 0; - if (!(source && source->type == MT_NULL && source->threshold == 42)) // Don't jump up when drowning - P_SetObjectMomZ(target, 14*FRACUNIT, false); + { + target->fuse = TICRATE*3; // timer before mobj disappears from view (even if not an actual player) + target->momx = target->momy = target->momz = 0; - if (source && source->type == MT_NULL && source->threshold == 42) // drowned - S_StartSound(target, sfx_drown); - else if (source && (source->type == MT_SPIKE || (source->type == MT_NULL && source->threshold == 43))) // Spikes - S_StartSound(target, sfx_spkdth); - else - P_PlayDeathSound(target); + if (damagetype == DMG_DROWNED) // drowned + { + target->movedir = damagetype; // we're MOVING the Damage Into anotheR function... Okay, this is a bit of a hack. + if (target->player->charflags & SF_MACHINE) + S_StartSound(target, sfx_fizzle); + else + S_StartSound(target, sfx_drown); + // Don't jump up when drowning + } + else + { + P_SetObjectMomZ(target, 14*FRACUNIT, false); + if (damagetype == DMG_SPIKE) // Spikes + S_StartSound(target, sfx_spkdth); + else + P_PlayDeathSound(target); + } + } + break; + case MT_METALSONIC_RACE: + target->fuse = TICRATE*3; + target->momx = target->momy = target->momz = 0; + P_SetObjectMomZ(target, 14*FRACUNIT, false); + target->flags = (target->flags & ~MF_NOGRAVITY)|(MF_NOCLIP|MF_NOCLIPTHING); break; default: break; } - // Enemy drops that ALWAYS occur regardless of mode - if (target->type == MT_AQUABUZZ) // Additionally spawns breathable bubble for players to get + // Final state setting - do something instead of P_SetMobjState; + if (target->type == MT_SPIKE && target->info->deathstate != S_NULL) { - if (inflictor && inflictor->player // did a player kill you? Spawn relative to the player so he's bound to get it - && P_AproxDistance(inflictor->x - target->x, inflictor->y - target->y) <= inflictor->radius + target->radius + FixedMul(8*FRACUNIT, inflictor->scale) // close enough? - && inflictor->z <= target->z + target->height + FixedMul(8*FRACUNIT, inflictor->scale) - && inflictor->z + inflictor->height >= target->z - FixedMul(8*FRACUNIT, inflictor->scale)) - mo = P_SpawnMobj(inflictor->x + inflictor->momx, inflictor->y + inflictor->momy, inflictor->z + (inflictor->height / 2) + inflictor->momz, MT_EXTRALARGEBUBBLE); - else - mo = P_SpawnMobj(target->x, target->y, target->z, MT_EXTRALARGEBUBBLE); - mo->destscale = target->scale; - P_SetScale(mo, mo->destscale); - } - else if (target->type == MT_YELLOWSHELL) // Spawns a spring that falls to the ground - { - mobjtype_t spawnspring = MT_YELLOWSPRING; - fixed_t spawnheight = target->z; - if (!(target->eflags & MFE_VERTICALFLIP)) - spawnheight += target->height; + const angle_t ang = ((inflictor) ? inflictor->angle : 0) + ANGLE_90; + const fixed_t scale = target->scale; + const fixed_t xoffs = P_ReturnThrustX(target, ang, 8*scale), yoffs = P_ReturnThrustY(target, ang, 8*scale); + const UINT16 flip = (target->eflags & MFE_VERTICALFLIP); + mobj_t *chunk; + fixed_t momz; - mo = P_SpawnMobj(target->x, target->y, spawnheight, spawnspring); - mo->destscale = target->scale; - P_SetScale(mo, mo->destscale); - - if (target->flags2 & MF2_OBJECTFLIP) - mo->flags2 |= MF2_OBJECTFLIP; - } - - if (target->type == MT_EGGMOBILE3) - { - thinker_t *th; - UINT32 i = 0; // to check how many clones we've removed - - // scan the thinkers to make sure all the old pinch dummies are gone on death - // this can happen if the boss was hurt earlier than expected - for (th = thinkercap.next; th != &thinkercap; th = th->next) - { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; - - mo = (mobj_t *)th; - if (mo->type == (mobjtype_t)target->info->mass && mo->tracer == target) - { - P_RemoveMobj(mo); - i++; - } - if (i == 2) // we've already removed 2 of these, let's stop now - break; - } - } - - if (target->type == MT_SPIKE && inflictor && target->info->deathstate != S_NULL) - { - const fixed_t x=target->x,y=target->y,z=target->z; - const fixed_t scale=target->scale; - const boolean flip=(target->eflags & MFE_VERTICALFLIP) == MFE_VERTICALFLIP; - S_StartSound(target,target->info->deathsound); - - P_SetMobjState(target, target->info->deathstate); - target->health = 0; - target->angle = inflictor->angle + ANGLE_90; - P_UnsetThingPosition(target); - target->flags = MF_NOCLIP; - target->x += P_ReturnThrustX(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - target->y += P_ReturnThrustY(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - if (flip) - target->z -= FixedMul(12*FRACUNIT, target->scale); - else - target->z += FixedMul(12*FRACUNIT, target->scale); - P_SetThingPosition(target); - P_InstaThrust(target,target->angle,FixedMul(2*FRACUNIT, target->scale)); - target->momz = FixedMul(7*FRACUNIT, target->scale); - if (flip) - target->momz = -target->momz; - - if (flip) - { - target = P_SpawnMobj(x,y,z-FixedMul(12*FRACUNIT, target->scale),MT_SPIKE); - target->eflags |= MFE_VERTICALFLIP; - } - else - target = P_SpawnMobj(x,y,z+FixedMul(12*FRACUNIT, target->scale),MT_SPIKE); - P_SetMobjState(target, target->info->deathstate); - target->health = 0; - target->angle = inflictor->angle - ANGLE_90; - target->destscale = scale; - P_SetScale(target, scale); - P_UnsetThingPosition(target); - target->flags = MF_NOCLIP; - target->x += P_ReturnThrustX(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - target->y += P_ReturnThrustY(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - P_SetThingPosition(target); - P_InstaThrust(target,target->angle,FixedMul(2*FRACUNIT, target->scale)); - target->momz = FixedMul(7*FRACUNIT, target->scale); - if (flip) - target->momz = -target->momz; + S_StartSound(target, target->info->deathsound); if (target->info->xdeathstate != S_NULL) { - target = P_SpawnMobj(x,y,z,MT_SPIKE); + momz = 6*scale; if (flip) - target->eflags |= MFE_VERTICALFLIP; - P_SetMobjState(target, target->info->xdeathstate); - target->health = 0; - target->angle = inflictor->angle + ANGLE_90; - target->destscale = scale; - P_SetScale(target, scale); - P_UnsetThingPosition(target); - target->flags = MF_NOCLIP; - target->x += P_ReturnThrustX(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - target->y += P_ReturnThrustY(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - P_SetThingPosition(target); - P_InstaThrust(target,target->angle,FixedMul(4*FRACUNIT, target->scale)); - target->momz = FixedMul(6*FRACUNIT, target->scale); - if (flip) - target->momz = -target->momz; + momz *= -1; +#define makechunk(angtweak, xmov, ymov) \ + chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_SPIKE);\ + P_SetMobjState(chunk, target->info->xdeathstate);\ + chunk->health = 0;\ + chunk->angle = angtweak;\ + P_UnsetThingPosition(chunk);\ + chunk->flags = MF_NOCLIP;\ + chunk->x += xmov;\ + chunk->y += ymov;\ + P_SetThingPosition(chunk);\ + P_InstaThrust(chunk,chunk->angle, 4*scale);\ + chunk->momz = momz - target = P_SpawnMobj(x,y,z,MT_SPIKE); - if (flip) - target->eflags |= MFE_VERTICALFLIP; - P_SetMobjState(target, target->info->xdeathstate); - target->health = 0; - target->angle = inflictor->angle - ANGLE_90; - target->destscale = scale; - P_SetScale(target, scale); - P_UnsetThingPosition(target); - target->flags = MF_NOCLIP; - target->x += P_ReturnThrustX(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - target->y += P_ReturnThrustY(target, target->angle, FixedMul(8*FRACUNIT, target->scale)); - P_SetThingPosition(target); - P_InstaThrust(target,target->angle,FixedMul(4*FRACUNIT, target->scale)); - target->momz = FixedMul(6*FRACUNIT, target->scale); - if (flip) - target->momz = -target->momz; + makechunk(ang + ANGLE_180, -xoffs, -yoffs); + makechunk(ang, xoffs, yoffs); + +#undef makechunk } + + momz = 7*scale; + if (flip) + momz *= -1; + + chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_SPIKE); + P_SetMobjState(chunk, target->info->deathstate); + chunk->health = 0; + chunk->angle = ang + ANGLE_180; + P_UnsetThingPosition(chunk); + chunk->flags = MF_NOCLIP; + chunk->x -= xoffs; + chunk->y -= yoffs; + if (flip) + chunk->z -= 12*scale; + else + chunk->z += 12*scale; + P_SetThingPosition(chunk); + P_InstaThrust(chunk, chunk->angle, 2*scale); + chunk->momz = momz; + + P_SetMobjState(target, target->info->deathstate); + target->health = 0; + target->angle = ang; + P_UnsetThingPosition(target); + target->flags = MF_NOCLIP; + target->x += xoffs; + target->y += yoffs; + target->z = chunk->z; + P_SetThingPosition(target); + P_InstaThrust(target, target->angle, 2*scale); + target->momz = momz; + } + else if (target->type == MT_WALLSPIKE && target->info->deathstate != S_NULL) + { + const angle_t ang = (/*(inflictor) ? inflictor->angle : */target->angle) + ANGLE_90; + const fixed_t scale = target->scale; + const fixed_t xoffs = P_ReturnThrustX(target, ang, 8*scale), yoffs = P_ReturnThrustY(target, ang, 8*scale), forwardxoffs = P_ReturnThrustX(target, target->angle, 7*scale), forwardyoffs = P_ReturnThrustY(target, target->angle, 7*scale); + const UINT16 flip = (target->eflags & MFE_VERTICALFLIP); + mobj_t *chunk; + boolean sprflip; + + S_StartSound(target, target->info->deathsound); + if (!P_MobjWasRemoved(target->tracer)) + P_RemoveMobj(target->tracer); + + if (target->info->xdeathstate != S_NULL) + { + sprflip = P_RandomChance(FRACUNIT/2); + +#define makechunk(angtweak, xmov, ymov) \ + chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);\ + P_SetMobjState(chunk, target->info->xdeathstate);\ + chunk->health = 0;\ + chunk->angle = target->angle;\ + P_UnsetThingPosition(chunk);\ + chunk->flags = MF_NOCLIP;\ + chunk->x += xmov - forwardxoffs;\ + chunk->y += ymov - forwardyoffs;\ + P_SetThingPosition(chunk);\ + P_InstaThrust(chunk, angtweak, 4*scale);\ + chunk->momz = P_RandomRange(5, 7)*scale;\ + if (flip)\ + chunk->momz *= -1;\ + if (sprflip)\ + chunk->frame |= FF_VERTICALFLIP + + makechunk(ang + ANGLE_180, -xoffs, -yoffs); + sprflip = !sprflip; + makechunk(ang, xoffs, yoffs); + +#undef makechunk + } + + sprflip = P_RandomChance(FRACUNIT/2); + + chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE); + + P_SetMobjState(chunk, target->info->deathstate); + chunk->health = 0; + chunk->angle = target->angle; + P_UnsetThingPosition(chunk); + chunk->flags = MF_NOCLIP; + chunk->x += forwardxoffs - xoffs; + chunk->y += forwardyoffs - yoffs; + P_SetThingPosition(chunk); + P_InstaThrust(chunk, ang + ANGLE_180, 2*scale); + chunk->momz = P_RandomRange(5, 7)*scale; + if (flip) + chunk->momz *= -1; + if (sprflip) + chunk->frame |= FF_VERTICALFLIP; + + P_SetMobjState(target, target->info->deathstate); + target->health = 0; + P_UnsetThingPosition(target); + target->flags = MF_NOCLIP; + target->x += forwardxoffs + xoffs; + target->y += forwardyoffs + yoffs; + P_SetThingPosition(target); + P_InstaThrust(target, ang, 2*scale); + target->momz = P_RandomRange(5, 7)*scale; + if (flip) + target->momz *= -1; + if (!sprflip) + target->frame |= FF_VERTICALFLIP; } else if (target->player) - P_SetPlayerMobjState(target, target->info->deathstate); + { + if (damagetype == DMG_DROWNED || damagetype == DMG_SPACEDROWN) + P_SetPlayerMobjState(target, target->info->xdeathstate); + else + P_SetPlayerMobjState(target, target->info->deathstate); + } else #ifdef DEBUG_NULL_DEATHSTATE P_SetMobjState(target, S_NULL); @@ -2410,13 +2971,14 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) Graue 12-22-2003 */ } -static inline void P_NiGHTSDamage(mobj_t *target, mobj_t *source) +static void P_NiGHTSDamage(mobj_t *target, mobj_t *source) { player_t *player = target->player; tic_t oldnightstime = player->nightstime; - if (!player->powers[pw_flashing] - && !(player->pflags & PF_GODMODE)) + (void)source; // unused + + if (!player->powers[pw_flashing]) { angle_t fa; @@ -2425,24 +2987,14 @@ static inline void P_NiGHTSDamage(mobj_t *target, mobj_t *source) player->flyangle += 180; // Shuffle's BETTERNIGHTSMOVEMENT? player->flyangle %= 360; - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) player->drillmeter -= 5*20; else { - if (source && source->player) - { - if (player->nightstime > 20*TICRATE) - player->nightstime -= 20*TICRATE; - else - player->nightstime = 1; - } + if (player->nightstime > 5*TICRATE) + player->nightstime -= 5*TICRATE; else - { - if (player->nightstime > 5*TICRATE) - player->nightstime -= 5*TICRATE; - else - player->nightstime = 1; - } + player->nightstime = 1; } if (player->pflags & PF_TRANSFERTOCLOSEST) @@ -2459,19 +3011,31 @@ static inline void P_NiGHTSDamage(mobj_t *target, mobj_t *source) } player->powers[pw_flashing] = flashingtics; - P_SetMobjState(target->tracer, S_NIGHTSHURT1); + P_SetPlayerMobjState(target, S_PLAY_NIGHTS_STUN); S_StartSound(target, sfx_nghurt); + player->mo->rollangle = 0; + if (oldnightstime > 10*TICRATE && player->nightstime < 10*TICRATE) { - //S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - S_ChangeMusicInternal("drown",false); + if ((mapheaderinfo[gamemap-1]->levelflags & LF_MIXNIGHTSCOUNTDOWN) +#ifdef _WIN32 + // win32 MIDI volume hack means we cannot fade down the music + && S_MusicType() != MU_MID +#endif + ) + { + S_FadeMusic(0, 10*MUSICRATE); + S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. + } + else + P_PlayJingle(player, ((maptol & TOL_NIGHTS) && !G_IsSpecialStage(gamemap)) ? JT_NIGHTSTIMEOUT : JT_SSTIMEOUT); } } } -static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +static boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { player_t *player = target->player; (void)damage; //unused parm @@ -2480,31 +3044,52 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou if (player->powers[pw_flashing] || player->powers[pw_invulnerability]) return false; - // Ignore IT players shooting each other, unless friendlyfire is on. - if ((player->pflags & PF_TAGIT && !(cv_friendlyfire.value && - source && source->player && source->player->pflags & PF_TAGIT))) - return false; - // Don't allow any damage before the round starts. if (leveltime <= hidetime * TICRATE) return false; + // Ignore IT players shooting each other, unless friendlyfire is on. + if ((player->pflags & PF_TAGIT && !((cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE) || (damagetype & DMG_CANHURTSELF)) && + source && source->player && source->player->pflags & PF_TAGIT))) + { + if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) + { + if (player->revitem != MT_LHRT && player->spinitem != MT_LHRT && player->thokitem != MT_LHRT) // Healers do not get to heal other healers. + { + P_SwitchShield(player, SH_PINK); + S_StartSound(target, mobjinfo[MT_PITY_ICON].seesound); + } + } + return false; + } + // Don't allow players on the same team to hurt one another, // unless cv_friendlyfire is on. - if (!cv_friendlyfire.value && (player->pflags & PF_TAGIT) == (source->player->pflags & PF_TAGIT)) + if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE) || (damagetype & DMG_CANHURTSELF)) && (player->pflags & PF_TAGIT) == (source->player->pflags & PF_TAGIT)) { - if (!(inflictor->flags & MF_FIRE)) + if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) + { + if (player->revitem != MT_LHRT && player->spinitem != MT_LHRT && player->thokitem != MT_LHRT) // Healers do not get to heal other healers. + { + P_SwitchShield(player, SH_PINK); + S_StartSound(target, mobjinfo[MT_PITY_ICON].seesound); + } + } + else if (!(inflictor->flags & MF_FIRE)) P_GivePlayerRings(player, 1); if (inflictor->flags2 & MF2_BOUNCERING) inflictor->fuse = 0; // bounce ring disappears at -1 not 0 return false; } + if (inflictor->type == MT_LHRT) + return false; + // The tag occurs so long as you aren't shooting another tagger with friendlyfire on. if (source->player->pflags & PF_TAGIT && !(player->pflags & PF_TAGIT)) { P_AddPlayerScore(source->player, 100); //award points to tagger. - P_HitDeathMessages(player, inflictor, source); + P_HitDeathMessages(player, inflictor, source, 0); if (gametype == GT_TAG) //survivor { @@ -2513,7 +3098,7 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou } else { - player->pflags |= PF_TAGGED; //in hide and seek, the player is tagged and stays stationary. + player->pflags |= PF_GAMETYPEOVER; //in hide and seek, the player is tagged and stays stationary. CONS_Printf(M_GetText("%s was found!\n"), player_names[player-players]); // Tell everyone who is it! } @@ -2531,52 +3116,74 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou return true; } - if (target->health <= 1) // Death + if (player->powers[pw_carry] == CR_NIGHTSFALL) + { + if (player->spheres > 0) + { + P_PlayRinglossSound(target); + P_PlayerRingBurst(player, player->spheres); + player->spheres = 0; + } + } + else if (player->rings > 0) // Ring loss + { + P_PlayRinglossSound(target); + P_PlayerRingBurst(player, player->rings); + player->rings = 0; + } + else // Death { P_PlayDeathSound(target); P_PlayVictorySound(source); // Killer laughs at you! LAUGHS! BWAHAHAHHAHAA!! } - else if (target->health > 1) // Ring loss - { - P_PlayRinglossSound(target); - P_PlayerRingBurst(player, player->mo->health - 1); - } - - if (inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - { - player->health -= 10; - if (player->health < 2) - player->health = 2; - target->health = player->health; - } - else - player->health = target->health = 1; - return true; } -static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +static boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { player_t *player = target->player; - // You can't kill yourself, idiot... - if (source == target) - return false; + if (!(damagetype & DMG_CANHURTSELF)) + { + // You can't kill yourself, idiot... + if (source == target) + return false; - // In COOP/RACE/CHAOS, you can't hurt other players unless cv_friendlyfire is on - if (!cv_friendlyfire.value && (G_PlatformGametype())) - return false; + // In COOP/RACE, you can't hurt other players unless cv_friendlyfire is on + if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) && (G_PlatformGametype())) + { + if (gametype == GT_COOP && inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) // co-op only + { + if (player->revitem != MT_LHRT && player->spinitem != MT_LHRT && player->thokitem != MT_LHRT) // Healers do not get to heal other healers. + { + P_SwitchShield(player, SH_PINK); + S_StartSound(target, mobjinfo[MT_PITY_ICON].seesound); + } + } + return false; + } + } // Tag handling if (G_TagGametype()) - return P_TagDamage(target, inflictor, source, damage); + return P_TagDamage(target, inflictor, source, damage, damagetype); + else if (damagetype & DMG_CANHURTSELF) + return true; else if (G_GametypeHasTeams()) // CTF + Team Match { // Don't allow players on the same team to hurt one another, // unless cv_friendlyfire is on. - if (!cv_friendlyfire.value && target->player->ctfteam == source->player->ctfteam) + if (!(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) && target->player->ctfteam == source->player->ctfteam) { - if (!(inflictor->flags & MF_FIRE)) + if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) + { + if (player->revitem != MT_LHRT && player->spinitem != MT_LHRT && player->thokitem != MT_LHRT) // Healers do not get to heal other healers. + { + P_SwitchShield(player, SH_PINK); + S_StartSound(target, mobjinfo[MT_PITY_ICON].seesound); + } + } + else if (!(inflictor->flags & MF_FIRE)) P_GivePlayerRings(target->player, 1); if (inflictor->flags2 & MF2_BOUNCERING) inflictor->fuse = 0; // bounce ring disappears at -1 not 0 @@ -2585,6 +3192,9 @@ static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj } } + if (inflictor->type == MT_LHRT) + return false; + // Add pity. if (!player->powers[pw_flashing] && !player->powers[pw_invulnerability] && !player->powers[pw_super] && source->player->score > player->score) @@ -2595,13 +3205,17 @@ static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) { - player->pflags &= ~(PF_CARRIED|PF_SLIDING|PF_ITEMHANG|PF_MACESPIN|PF_ROPEHANG|PF_NIGHTSMODE); + player->pflags &= ~PF_SLIDING; + + player->powers[pw_carry] = CR_NONE; // Burst weapons and emeralds in Match/CTF only - if (source && (gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF)) + if (source) { - P_PlayerRingBurst(player, player->health - 1); - P_PlayerEmeraldBurst(player, false); + if ((gametyperules & GTR_RINGSLINGER) && !(gametyperules & GTR_TAG)) + P_PlayerRingBurst(player, player->rings); + if (gametyperules & GTR_POWERSTONES) + P_PlayerEmeraldBurst(player, false); } // Get rid of shield @@ -2615,8 +3229,11 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) P_ResetPlayer(player); + if (!player->spectator) + player->mo->flags2 &= ~MF2_DONTDRAW; + P_SetPlayerMobjState(player->mo, player->mo->info->deathstate); - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) + if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) { P_PlayerFlagBurst(player, false); if (source && source->player) @@ -2689,10 +3306,7 @@ static void P_SuperDamage(player_t *player, mobj_t *inflictor, mobj_t *source, I P_InstaThrust(player->mo, ang, fallbackspeed); - if (player->charflags & SF_SUPERANIMS) - P_SetPlayerMobjState(player->mo, S_PLAY_SUPERHIT); - else - P_SetPlayerMobjState(player->mo, player->mo->info->painstate); + P_SetPlayerMobjState(player->mo, S_PLAY_STUN); P_ResetPlayer(player); @@ -2704,31 +3318,33 @@ void P_RemoveShield(player_t *player) { if (player->powers[pw_shield] & SH_FORCE) { // Multi-hit - if ((player->powers[pw_shield] & 0xFF) == 0) - player->powers[pw_shield] &= ~SH_FORCE; - else + if (player->powers[pw_shield] & SH_FORCEHP) player->powers[pw_shield]--; + else + player->powers[pw_shield] &= SH_STACK; } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_NONE) + else if (player->powers[pw_shield] & SH_NOSTACK) + { // First layer shields + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ARMAGEDDON) // Give them what's coming to them! + { + P_BlackOw(player); // BAM! + player->pflags |= PF_JUMPDOWN; + } + else + player->powers[pw_shield] &= SH_STACK; + } + else { // Second layer shields - player->powers[pw_shield] = SH_NONE; - // Reset fireflower - if (!player->powers[pw_super]) + if (((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) && !(player->powers[pw_super] || (mariomode && player->powers[pw_invulnerability]))) { player->mo->color = player->skincolor; G_GhostAddColor(GHC_NORMAL); } + player->powers[pw_shield] = SH_NONE; } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BOMB) // Give them what's coming to them! - { - P_BlackOw(player); // BAM! - player->pflags |= PF_JUMPDOWN; - } - else - player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; } -static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) +static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { // Must do pain first to set flashing -- P_RemoveShield can cause damage P_DoPlayerPain(player, source, inflictor); @@ -2737,12 +3353,12 @@ static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); - if (source && (source->type == MT_SPIKE || (source->type == MT_NULL && source->threshold == 43))) // spikes + if (damagetype == DMG_SPIKE) // spikes S_StartSound(player->mo, sfx_spkdth); else S_StartSound (player->mo, sfx_shldls); // Ba-Dum! Shield loss. - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) + if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) { P_PlayerFlagBurst(player, false); if (source && source->player) @@ -2756,21 +3372,18 @@ static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, { // Award no points when players shoot each other when cv_friendlyfire is on. if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, cv_match_scoring.value == 1 ? 25 : 50); + P_AddPlayerScore(source->player, 50); } } -static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) +static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype, boolean dospheres) { - if (!(inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) - { - P_DoPlayerPain(player, source, inflictor); + P_DoPlayerPain(player, source, inflictor); - P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); + P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); - if (source && (source->type == MT_SPIKE || (source->type == MT_NULL && source->threshold == 43))) // spikes - S_StartSound(player->mo, sfx_spkdth); - } + if (damagetype == DMG_SPIKE) // spikes + S_StartSound(player->mo, sfx_spkdth); if (source && source->player && !player->powers[pw_super]) //don't score points against super players { @@ -2779,7 +3392,7 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN P_AddPlayerScore(source->player, 50); } - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) + if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) { P_PlayerFlagBurst(player, false); if (source && source->player) @@ -2792,33 +3405,107 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN // Ring loss sound plays despite hitting spikes P_PlayRinglossSound(player->mo); // Ringledingle! + P_PlayerRingBurst(player, damage); + + if (dospheres) + { + player->spheres -= damage; + if (player->spheres < 0) + player->spheres = 0; + } + else + { + player->rings -= damage; + if (player->rings < 0) + player->rings = 0; + } +} + +// +// P_SpecialStageDamage +// +// Do old special stage-style damaging +// Removes 5 seconds from the player, or knocks off their shield if they have one. +// If they don't have anything, just knock the player back anyway (this doesn't kill them). +// +void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source) +{ + tic_t oldnightstime = player->nightstime; + + if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super]) + return; + + if (!cv_friendlyfire.value && source && source->player) + { + if (inflictor->type == MT_LHRT && !(player->powers[pw_shield] & SH_NOSTACK)) + { + if (player->revitem != MT_LHRT && player->spinitem != MT_LHRT && player->thokitem != MT_LHRT) // Healers do not get to heal other healers. + { + P_SwitchShield(player, SH_PINK); + S_StartSound(player->mo, mobjinfo[MT_PITY_ICON].seesound); + } + } + + if (source->player->ctfteam == player->ctfteam) + return; + } + + if (inflictor && inflictor->type == MT_LHRT) + return; + + if (player->powers[pw_shield] || player->bot) //If One-Hit Shield + { + P_RemoveShield(player); + S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss. + } + else + { + S_StartSound(player->mo, sfx_nghurt); + if (player->nightstime > 5*TICRATE) + player->nightstime -= 5*TICRATE; + else + player->nightstime = 0; + } + + P_DoPlayerPain(player, inflictor, source); + + if ((gametyperules & GTR_TEAMFLAGS) && player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) + P_PlayerFlagBurst(player, false); + + if (oldnightstime > 10*TICRATE + && player->nightstime < 10*TICRATE) + { + if (mapheaderinfo[gamemap-1]->levelflags & LF_MIXNIGHTSCOUNTDOWN) + { + S_FadeMusic(0, 10*MUSICRATE); + S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. + } + else + S_ChangeMusicInternal((((maptol & TOL_NIGHTS) && !G_IsSpecialStage(gamemap)) ? "_ntime" : "_drown"), false); + } } /** Damages an object, which may or may not be a player. * For melee attacks, source and inflictor are the same. * - * \param target The object being damaged. - * \param inflictor The thing that caused the damage: creature, missile, - * gargoyle, and so forth. Can be NULL in the case of - * environmental damage, such as slime or crushing. - * \param source The creature or person responsible. For example, if a - * player is hit by a ring, the player who shot it. In some - * cases, the target will go after this object after - * receiving damage. This can be NULL. - * \param damage Amount of damage to be dealt. 10000 is instant death. + * \param target The object being damaged. + * \param inflictor The thing that caused the damage: creature, missile, + * gargoyle, and so forth. Can be NULL in the case of + * environmental damage, such as slime or crushing. + * \param source The creature or person responsible. For example, if a + * player is hit by a ring, the player who shot it. In some + * cases, the target will go after this object after + * receiving damage. This can be NULL. + * \param damage Amount of damage to be dealt. + * \param damagetype Type of damage to be dealt. If bit 7 (0x80) is set, this is an instant-kill. * \return True if the target sustained damage, otherwise false. * \todo Clean up this mess, split into multiple functions. - * \todo Get rid of the magic number 10000. * \sa P_KillMobj */ -boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) +boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype) { player_t *player; -#ifdef HAVE_BLUA boolean force = false; -#else - static const boolean force = false; -#endif if (objectplacing) return false; @@ -2827,22 +3514,19 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // Spectator handling - if (netgame) + if (multiplayer) { - if (damage == 42000 && target->player && target->player->spectator) - damage = 10000; - else if (target->player && target->player->spectator) + if (damagetype != DMG_SPECTATOR && target->player && target->player->spectator) return false; if (source && source->player && source->player->spectator) return false; } -#ifdef HAVE_BLUA // Everything above here can't be forced. if (!metalrecording) { - UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage); + UINT8 shouldForce = LUAh_ShouldDamage(target, inflictor, source, damage, damagetype); if (P_MobjWasRemoved(target)) return (shouldForce == 1); // mobj was removed if (shouldForce == 1) @@ -2850,7 +3534,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else if (shouldForce == 2) return false; } -#endif if (!force) { @@ -2861,7 +3544,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // Make sure that boxes cannot be popped by enemies, red rings, etc. - if (target->flags & MF_MONITOR && ((!source || !source->player || source->player->bot) || (inflictor && !inflictor->player))) + if (target->flags & MF_MONITOR && ((!source || !source->player || source->player->bot) + || (inflictor && (inflictor->type == MT_REDRING || (inflictor->type >= MT_THROWNBOUNCE && inflictor->type <= MT_THROWNGRENADE))))) return false; } @@ -2871,62 +3555,24 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!force) { // Special case for team ring boxes - if (target->type == MT_REDRINGBOX && !(source->player->ctfteam == 1)) + if (target->type == MT_RING_REDBOX && !(source->player->ctfteam == 1)) return false; - if (target->type == MT_BLUERINGBOX && !(source->player->ctfteam == 2)) + if (target->type == MT_RING_BLUEBOX && !(source->player->ctfteam == 2)) return false; } - // Special case for Crawla Commander - if (target->type == MT_CRAWLACOMMANDER) - { - if (!force && target->fuse) // Invincible - return false; - -#ifdef HAVE_BLUA - if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) - return true; -#endif - - if (target->health > 1) - { - if (target->info->painsound) - S_StartSound(target, target->info->painsound); - - target->fuse = TICRATE/2; - target->flags2 |= MF2_FRET; - } - else - { - target->flags |= MF_NOGRAVITY; - target->fuse = 0; - } - - target->momx = target->momy = target->momz = 0; - - P_InstaThrust(target, target->angle-ANGLE_180, FixedMul(5*FRACUNIT, target->scale)); - } - else if (target->flags & MF_BOSS) + if (target->flags & (MF_ENEMY|MF_BOSS)) { if (!force && target->flags2 & MF2_FRET) // Currently flashing from being hit return false; -#ifdef HAVE_BLUA - if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) + if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype) || P_MobjWasRemoved(target)) return true; -#endif if (target->health > 1) target->flags2 |= MF2_FRET; } -#ifdef HAVE_BLUA - else if (target->flags & MF_ENEMY) - { - if (LUAh_MobjDamage(target, inflictor, source, damage) || P_MobjWasRemoved(target)) - return true; - } -#endif player = target->player; @@ -2937,58 +3583,70 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (player->exiting) return false; - if (!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && (maptol & TOL_NIGHTS)) + if (player->pflags & PF_GODMODE) return false; + + if ((maptol & TOL_NIGHTS) && target->player->powers[pw_carry] != CR_NIGHTSMODE && target->player->powers[pw_carry] != CR_NIGHTSFALL) + return false; + + switch (damagetype) + { +#define DAMAGECASE(type)\ + case DMG_##type:\ + if (player->powers[pw_shield] & SH_PROTECT##type)\ + return false;\ + break + DAMAGECASE(WATER); + DAMAGECASE(FIRE); + DAMAGECASE(ELECTRIC); + DAMAGECASE(SPIKE); +#undef DAMAGECASE + default: + break; + } } - if (player->pflags & PF_NIGHTSMODE) // NiGHTS damage handling + if (player->powers[pw_carry] == CR_NIGHTSMODE) // NiGHTS damage handling { if (!force) { if (source == target) return false; // Don't hit yourself with your own paraloop, baka - if (source && source->player && !cv_friendlyfire.value + if (source && source->player && !(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE)) && (gametype == GT_COOP - || (G_GametypeHasTeams() && target->player->ctfteam == source->player->ctfteam))) + || (G_GametypeHasTeams() && player->ctfteam == source->player->ctfteam))) return false; // Don't run eachother over in special stages and team games and such } -#ifdef HAVE_BLUA - if (LUAh_MobjDamage(target, inflictor, source, damage)) + if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) return true; -#endif P_NiGHTSDamage(target, source); // -5s :( return true; } - if (!force && inflictor && (inflictor->flags & MF_FIRE)) + if (G_IsSpecialStage(gamemap) && !(damagetype & DMG_DEATHMASK)) { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) - return false; // Invincible to fire objects - - if (G_PlatformGametype() && source && source->player) - return false; // Don't get hurt by fire generated from friends. + P_SpecialStageDamage(player, inflictor, source); + return true; } - // Sudden-Death mode - if (source && source->type == MT_PLAYER) + if (!force && inflictor && inflictor->flags & MF_FIRE) { - if ((gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF) && cv_suddendeath.value - && !player->powers[pw_flashing] && !player->powers[pw_invulnerability]) - damage = 10000; + if (player->powers[pw_shield] & SH_PROTECTFIRE) + return false; // Invincible to fire objects + + if (G_PlatformGametype() && inflictor && source && source->player) + return false; // Don't get hurt by fire generated from friends. } // Player hits another player if (!force && source && source->player) { - if (!P_PlayerHitsPlayer(target, inflictor, source, damage)) + if (!P_PlayerHitsPlayer(target, inflictor, source, damage, damagetype)) return false; } - if (!force && player->pflags & PF_GODMODE) - return false; - // Instant-Death - if (damage == 10000) + if (damagetype & DMG_DEATHMASK) P_KillPlayer(player, source, damage); else if (metalrecording) { @@ -2996,144 +3654,100 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da inflictor = source; if (inflictor && inflictor->flags & MF_ENEMY) { // Metal Sonic destroy enemy !! - P_KillMobj(inflictor, NULL, target); + P_KillMobj(inflictor, NULL, target, damagetype); return false; } else if (inflictor && inflictor->flags & MF_MISSILE) return false; // Metal Sonic walk through flame !! - else + else if (!player->powers[pw_flashing]) { // Oh no! Metal Sonic is hit !! - P_ShieldDamage(player, inflictor, source, damage); + P_ShieldDamage(player, inflictor, source, damage, damagetype); return true; } + return false; } - else if (player->powers[pw_invulnerability] || player->powers[pw_flashing] // ignore bouncing & such in invulnerability - || (player->powers[pw_super] && !(ALL7EMERALDS(player->powers[pw_emeralds]) && inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player)))) + else if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super]) // ignore bouncing & such in invulnerability { - if (force || (inflictor && (inflictor->flags & MF_MISSILE) - && (inflictor->flags2 & MF2_SUPERFIRE) - && player->powers[pw_super])) + if (force + || (inflictor && inflictor->flags & MF_MISSILE && inflictor->flags2 & MF2_SUPERFIRE)) // Super Sonic is stunned! { -#ifdef HAVE_BLUA - if (!LUAh_MobjDamage(target, inflictor, source, damage)) -#endif + if (!LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) P_SuperDamage(player, inflictor, source, damage); return true; } - else - return false; + return false; } -#ifdef HAVE_BLUA - else if (LUAh_MobjDamage(target, inflictor, source, damage)) + else if (LUAh_MobjDamage(target, inflictor, source, damage, damagetype)) return true; -#endif - else if (!player->powers[pw_super] && (player->powers[pw_shield] || player->bot)) //If One-Hit Shield + else if (player->powers[pw_shield] || (player->bot && !ultimatemode)) //If One-Hit Shield { - P_ShieldDamage(player, inflictor, source, damage); + P_ShieldDamage(player, inflictor, source, damage, damagetype); damage = 0; } - else if (player->mo->health > 1) // No shield but have rings. + else if (player->powers[pw_carry] == CR_NIGHTSFALL) { - damage = player->mo->health - 1; - P_RingDamage(player, inflictor, source, damage); + // always damage so we can recoil upon losing points + damage = player->spheres; + P_RingDamage(player, inflictor, source, damage, damagetype, true); + damage = 0; + } + else if (player->rings > 0) // No shield but have rings. + { + damage = player->rings; + P_RingDamage(player, inflictor, source, damage, damagetype, false); + damage = 0; + } + // To reduce griefing potential, don't allow players to be killed + // by friendly fire. Spilling their rings and other items is enough. + else if (!force && G_GametypeHasTeams() + && source && source->player && (source->player->ctfteam == player->ctfteam) + && (cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE))) + { + damage = 0; + P_ShieldDamage(player, inflictor, source, damage, damagetype); } else // No shield, no rings, no invincibility. { - // To reduce griefing potential, don't allow players to be killed - // by friendly fire. Spilling their rings and other items is enough. - if (force || !(G_GametypeHasTeams() - && source && source->player && (source->player->ctfteam == player->ctfteam) - && cv_friendlyfire.value)) - { - damage = 1; - P_KillPlayer(player, source, damage); - } - else - { - damage = 0; - P_ShieldDamage(player, inflictor, source, damage); - } + damage = 1; + P_KillPlayer(player, source, damage); } - if (inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - { - if (player->powers[pw_shield]) - { - P_RemoveShield(player); - return true; - } - else - { - player->health -= (10 * (1 << (INT32)(player->powers[pw_super] / 10500))); - if (player->health < 2) - player->health = 2; - } - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - P_PlayerFlagBurst(player, false); - } - else - { - player->health -= damage; // mirror mobj health here - if (damage < 10000) - { - target->player->powers[pw_flashing] = flashingtics; - if (damage > 0) // don't spill emeralds/ammo/panels for shield damage - P_PlayerRingBurst(player, damage); - } - } - - if (player->health < 0) - player->health = 0; - - P_HitDeathMessages(player, inflictor, source); - P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); } // Killing dead. Just for kicks. // Require source and inflictor be player. Don't hurt for firing rings. if (cv_killingdead.value && (source && source->player) && (inflictor && inflictor->player) && P_RandomChance(5*FRACUNIT/16)) - P_DamageMobj(source, target, target, 1); + P_DamageMobj(source, target, target, 1, 0); // do the damage - if (player && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player)) - { - target->health -= (10 * (1 << (INT32)(player->powers[pw_super] / 10500))); - if (target->health < 2) - target->health = 2; - } + if (damagetype & DMG_DEATHMASK) + target->health = 0; else target->health -= damage; + if (player) + P_HitDeathMessages(player, inflictor, source, damagetype); + if (source && source->player && target) G_GhostAddHit(target); if (target->health <= 0) { - P_KillMobj(target, inflictor, source); + P_KillMobj(target, inflictor, source, damagetype); return true; } if (player) - { - if (!(player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) - P_ResetPlayer(target->player); - } + P_ResetPlayer(target->player); + else if ((target->type == MT_EGGMOBILE2) // egg slimer + && (target->health < target->info->damage)) // in pinch phase + P_SetMobjState(target, target->info->meleestate); // go to pinch pain state else - switch (target->type) - { - case MT_EGGMOBILE2: // egg slimer - if (target->health < target->info->damage) // in pinch phase - { - P_SetMobjState(target, target->info->meleestate); // go to pinch pain state - break; - } - /* FALLTHRU */ - default: - P_SetMobjState(target, target->info->painstate); - break; - } + P_SetMobjState(target, target->info->painstate); + + if (target->type == MT_HIVEELEMENTAL) + target->extravalue1 += 3; target->reactiontime = 0; // we're awake now... @@ -3142,16 +3756,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da // if not intent on another player, // chase after this one P_SetTarget(&target->target, source); - if (target->state == &states[target->info->spawnstate] && target->info->seestate != S_NULL) - { - if (player) - { - if (!(player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) - P_SetPlayerMobjState(target, target->info->seestate); - } - else - P_SetMobjState(target, target->info->seestate); - } } return true; @@ -3168,36 +3772,40 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) { INT32 i; mobj_t *mo; - angle_t fa; + angle_t fa, va; fixed_t ns; fixed_t z; + boolean nightsreplace = ((maptol & TOL_NIGHTS) && !G_IsSpecialStage(gamemap)); // Better safe than sorry. if (!player) return; // If no health, don't spawn ring! - if (player->mo->health <= 1) + if (((maptol & TOL_NIGHTS) && player->spheres <= 0) || (!(maptol & TOL_NIGHTS) && player->rings <= 0)) num_rings = 0; - if (num_rings > 32 && !(player->pflags & PF_NIGHTSFALL)) + if (num_rings > 32 && player->powers[pw_carry] != CR_NIGHTSFALL) num_rings = 32; if (player->powers[pw_emeralds]) P_PlayerEmeraldBurst(player, false); // Spill weapons first - if (player->ringweapons) - P_PlayerWeaponPanelBurst(player); + P_PlayerWeaponPanelOrAmmoBurst(player); - // Spill the ammo - P_PlayerWeaponAmmoBurst(player); + if (abs(player->mo->momx) > player->mo->scale || abs(player->mo->momy) > player->mo->scale) + va = R_PointToAngle2(player->mo->momx, player->mo->momy, 0, 0)>>ANGLETOFINESHIFT; + else + va = player->mo->angle>>ANGLETOFINESHIFT; for (i = 0; i < num_rings; i++) { INT32 objType = mobjinfo[MT_RING].reactiontime; if (mariomode) objType = mobjinfo[MT_COIN].reactiontime; + else if (player->powers[pw_carry] == CR_NIGHTSFALL) + objType = mobjinfo[(nightsreplace ? MT_NIGHTSCHIP : MT_BLUESPHERE)].reactiontime; z = player->mo->z; if (player->mo->eflags & MFE_VERTICALFLIP) @@ -3212,11 +3820,11 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) P_SetScale(mo, player->mo->scale); // Angle offset by player angle, then slightly offset by amount of rings - fa = ((i*FINEANGLES/16) + (player->mo->angle>>ANGLETOFINESHIFT) - ((num_rings-1)*FINEANGLES/32)) & FINEMASK; + fa = ((i*FINEANGLES/16) + va - ((num_rings-1)*FINEANGLES/32)) & FINEMASK; // Make rings spill out around the player in 16 directions like SA, but spill like Sonic 2. // Technically a non-SA way of spilling rings. They just so happen to be a little similar. - if (player->pflags & PF_NIGHTSFALL) + if (player->powers[pw_carry] == CR_NIGHTSFALL) { ns = FixedMul(((i*FRACUNIT)/16)+2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); @@ -3226,6 +3834,9 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) P_SetObjectMomZ(mo, 8*FRACUNIT, false); mo->fuse = 20*TICRATE; // Adjust fuse for NiGHTS + + // Toggle bonus time colors + P_SetMobjState(mo, (player->bonustime ? mo->info->raisestate : mo->info->spawnstate)); } else { @@ -3260,9 +3871,6 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) player->losstime += 10*TICRATE; - if (P_IsObjectOnGround(player->mo)) - player->pflags &= ~PF_NIGHTSFALL; - return; } @@ -3448,6 +4056,75 @@ void P_PlayerWeaponAmmoBurst(player_t *player) } } +void P_PlayerWeaponPanelOrAmmoBurst(player_t *player) +{ + mobj_t *mo; + angle_t fa; + fixed_t ns; + INT32 i = 0; + fixed_t z; + + #define SETUP_DROP(thingtype) \ + z = player->mo->z; \ + if (player->mo->eflags & MFE_VERTICALFLIP) \ + z += player->mo->height - mobjinfo[thingtype].height; \ + fa = ((i*FINEANGLES/16) + (player->mo->angle>>ANGLETOFINESHIFT)) & FINEMASK; \ + ns = FixedMul(3*FRACUNIT, player->mo->scale); \ + + #define DROP_WEAPON(rwflag, pickup, ammo, power) \ + if (player->ringweapons & rwflag) \ + { \ + player->ringweapons &= ~rwflag; \ + SETUP_DROP(pickup) \ + mo = P_SpawnMobj(player->mo->x, player->mo->y, z, pickup); \ + mo->reactiontime = 0; \ + mo->flags2 |= MF2_DONTRESPAWN; \ + mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \ + P_SetTarget(&mo->target, player->mo); \ + mo->fuse = 12*TICRATE; \ + mo->destscale = player->mo->scale; \ + P_SetScale(mo, player->mo->scale); \ + mo->momx = FixedMul(FINECOSINE(fa),ns); \ + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \ + mo->momy = FixedMul(FINESINE(fa),ns); \ + P_SetObjectMomZ(mo, 4*FRACUNIT, false); \ + if (i & 1) \ + P_SetObjectMomZ(mo, 4*FRACUNIT, true); \ + ++i; \ + } \ + else if (player->powers[power] > 0) \ + { \ + SETUP_DROP(ammo) \ + mo = P_SpawnMobj(player->mo->x, player->mo->y, z, ammo); \ + mo->health = player->powers[power]; \ + mo->flags2 |= MF2_DONTRESPAWN; \ + mo->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); \ + P_SetTarget(&mo->target, player->mo); \ + mo->fuse = 12*TICRATE; \ + mo->destscale = player->mo->scale; \ + P_SetScale(mo, player->mo->scale); \ + mo->momx = FixedMul(FINECOSINE(fa),ns); \ + if (!(twodlevel || (player->mo->flags2 & MF2_TWOD))) \ + mo->momy = FixedMul(FINESINE(fa),ns); \ + P_SetObjectMomZ(mo, 3*FRACUNIT, false); \ + if (i & 1) \ + P_SetObjectMomZ(mo, 3*FRACUNIT, true); \ + player->powers[power] = 0; \ + ++i; \ + } + + DROP_WEAPON(RW_BOUNCE, MT_BOUNCEPICKUP, MT_BOUNCERING, pw_bouncering); + DROP_WEAPON(RW_RAIL, MT_RAILPICKUP, MT_RAILRING, pw_railring); + DROP_WEAPON(RW_AUTO, MT_AUTOPICKUP, MT_AUTOMATICRING, pw_automaticring); + DROP_WEAPON(RW_EXPLODE, MT_EXPLODEPICKUP, MT_EXPLOSIONRING, pw_explosionring); + DROP_WEAPON(RW_SCATTER, MT_SCATTERPICKUP, MT_SCATTERRING, pw_scatterring); + DROP_WEAPON(RW_GRENADE, MT_GRENADEPICKUP, MT_GRENADERING, pw_grenadering); + DROP_WEAPON(0, 0, MT_INFINITYRING, pw_infinityring); + + #undef DROP_WEAPON + #undef SETUP_DROP +} + // // P_PlayerEmeraldBurst // diff --git a/src/p_lights.c b/src/p_lights.c index 2da38d1dc..371077a30 100644 --- a/src/p_lights.c +++ b/src/p_lights.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -23,7 +23,7 @@ * * \param sector The sector to remove effects from. */ -static void P_RemoveLighting(sector_t *sector) +void P_RemoveLighting(sector_t *sector) { if (sector->lightingdata) { @@ -76,7 +76,7 @@ fireflicker_t *P_SpawnAdjustableFireFlicker(sector_t *minsector, sector_t *maxse P_RemoveLighting(maxsector); // out with the old, in with the new flick = Z_Calloc(sizeof (*flick), PU_LEVSPEC, NULL); - P_AddThinker(&flick->thinker); + P_AddThinker(THINK_MAIN, &flick->thinker); flick->thinker.function.acp1 = (actionf_p1)T_FireFlicker; flick->sector = maxsector; @@ -155,7 +155,7 @@ void P_SpawnLightningFlash(sector_t *sector) flash = Z_Calloc(sizeof (*flash), PU_LEVSPEC, NULL); - P_AddThinker(&flash->thinker); + P_AddThinker(THINK_MAIN, &flash->thinker); flash->thinker.function.acp1 = (actionf_p1)T_LightningFlash; flash->sector = sector; @@ -214,7 +214,7 @@ strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector, P_RemoveLighting(maxsector); // out with the old, in with the new flash = Z_Calloc(sizeof (*flash), PU_LEVSPEC, NULL); - P_AddThinker(&flash->thinker); + P_AddThinker(THINK_MAIN, &flash->thinker); flash->sector = maxsector; flash->darktime = darktime; @@ -289,7 +289,7 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, P_RemoveLighting(maxsector); // out with the old, in with the new g = Z_Calloc(sizeof (*g), PU_LEVSPEC, NULL); - P_AddThinker(&g->thinker); + P_AddThinker(THINK_MAIN, &g->thinker); g->sector = maxsector; g->minlight = minsector->lightlevel; @@ -322,39 +322,70 @@ glow_t *P_SpawnAdjustableGlowingLight(sector_t *minsector, sector_t *maxsector, return g; } -/** Fades all the lights in sectors with a particular tag to a new +/** Fades all the lights in specified sector to a new * value. * - * \param tag Tag to look for sectors by. + * \param sector Target sector * \param destvalue The final light value in these sectors. - * \param speed Speed of the fade; the change to the ligh + * \param speed If tic-based: total duration of effect. + * If speed-based: Speed of the fade; the change to the ligh * level in each sector per tic. - * \todo Calculate speed better so that it is possible to specify - * the time for completion of the fade, and all lights fade - * in this time regardless of initial values. + * \param ticbased Use a specific duration for the fade, defined by speed * \sa T_LightFade */ -void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) +void P_FadeLightBySector(sector_t *sector, INT32 destvalue, INT32 speed, boolean ticbased) +{ + lightlevel_t *ll; + + P_RemoveLighting(sector); // remove the old lighting effect first + + if ((ticbased && !speed) || sector->lightlevel == destvalue) // set immediately + { + sector->lightlevel = destvalue; + return; + } + + ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); + ll->thinker.function.acp1 = (actionf_p1)T_LightFade; + sector->lightingdata = ll; // set it to the lightlevel_t + + P_AddThinker(THINK_MAIN, &ll->thinker); // add thinker + + ll->sector = sector; + ll->sourcelevel = sector->lightlevel; + ll->destlevel = destvalue; + + ll->fixedcurlevel = sector->lightlevel<timer = abs(speed); + ll->fixedpertic = FixedDiv((destvalue<fixedcurlevel, speed<timer = FixedDiv((destvalue<fixedcurlevel, speed<>FRACBITS; + ll->fixedpertic = speed<= 0 ;) { - sector = §ors[i]; - - P_RemoveLighting(sector); // remove the old lighting effect first - ll = Z_Calloc(sizeof (*ll), PU_LEVSPEC, NULL); - ll->thinker.function.acp1 = (actionf_p1)T_LightFade; - sector->lightingdata = ll; // set it to the lightlevel_t - - P_AddThinker(&ll->thinker); // add thinker - - ll->sector = sector; - ll->destlevel = destvalue; - ll->speed = speed; + if (!force && ticbased // always let speed fader execute + && sectors[i].lightingdata + && ((lightlevel_t*)sectors[i].lightingdata)->thinker.function.acp1 == (actionf_p1)T_LightFade) + // && ((lightlevel_t*)sectors[i].lightingdata)->timer > 2) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 420 Executor: Fade light thinker already exists, timer: %d\n", ((lightlevel_t*)sectors[i].lightingdata)->timer); + continue; + } + P_FadeLightBySector(§ors[i], destvalue, speed, ticbased); } } @@ -365,30 +396,13 @@ void P_FadeLight(INT16 tag, INT32 destvalue, INT32 speed) */ void T_LightFade(lightlevel_t *ll) { - if (ll->sector->lightlevel < ll->destlevel) + if (--ll->timer <= 0) { - // increase the lightlevel - if (ll->sector->lightlevel + ll->speed >= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel + (INT16)ll->speed); // move lightlevel + ll->sector->lightlevel = ll->destlevel; // set to dest lightlevel + P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker + return; } - else - { - // decrease lightlevel - if (ll->sector->lightlevel - ll->speed <= ll->destlevel) - { - // stop changing light level - ll->sector->lightlevel = (INT16)ll->destlevel; // set to dest lightlevel - P_RemoveLighting(ll->sector); // clear lightingdata, remove thinker - } - else - ll->sector->lightlevel = (INT16)(ll->sector->lightlevel - (INT16)ll->speed); // move lightlevel - } + ll->fixedcurlevel = ll->fixedcurlevel + ll->fixedpertic; + ll->sector->lightlevel = (ll->fixedcurlevel)>>FRACBITS; } diff --git a/src/p_local.h b/src/p_local.h index 9164fa7a0..99c465f9b 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -25,10 +25,8 @@ #define FLOATSPEED (FRACUNIT*4) -#define VIEWHEIGHTS "41" - // Maximum player score. -#define MAXSCORE 999999990 +#define MAXSCORE 99999990 // 999999990 // mapblocks are used to check movement // against lines and things @@ -56,18 +54,28 @@ #define AIMINGTOSLOPE(aiming) FINESINE((aiming>>ANGLETOFINESHIFT) & FINEMASK) -#define mariomode (maptol & TOL_MARIO) #define twodlevel (maptol & TOL_2D) -// -// P_TICK -// +#define mariomode (maptol & TOL_MARIO) -// both the head and tail of the thinker list -extern thinker_t thinkercap; +#define P_GetPlayerHeight(player) FixedMul(player->height, player->mo->scale) +#define P_GetPlayerSpinHeight(player) FixedMul(player->spinheight, player->mo->scale) + +typedef enum +{ + THINK_POLYOBJ, + THINK_MAIN, + THINK_MOBJ, +#ifdef ESLOPE + THINK_DYNSLOPE, +#endif + THINK_PRECIP, + NUM_THINKERLISTS +} thinklistnum_t; /**< Thinker lists. */ +extern thinker_t thlist[]; void P_InitThinkers(void); -void P_AddThinker(thinker_t *thinker); +void P_AddThinker(const thinklistnum_t n, thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); // @@ -107,25 +115,30 @@ typedef struct camera_s extern camera_t camera, camera2; extern consvar_t cv_cam_dist, cv_cam_still, cv_cam_height; -extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed; +extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed, cv_cam_turnmultiplier, cv_cam_orbit, cv_cam_adjust; extern consvar_t cv_cam2_dist, cv_cam2_still, cv_cam2_height; -extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed; +extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed, cv_cam2_turnmultiplier, cv_cam2_orbit, cv_cam2_adjust; + +extern consvar_t cv_cam_savedist[2][2], cv_cam_saveheight[2][2]; +void CV_UpdateCamDist(void); +void CV_UpdateCam2Dist(void); extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; -fixed_t P_GetPlayerHeight(player_t *player); -fixed_t P_GetPlayerSpinHeight(player_t *player); INT32 P_GetPlayerControlDirection(player_t *player); void P_AddPlayerScore(player_t *player, UINT32 amount); +void P_StealPlayerScore(player_t *player, UINT32 amount); void P_ResetCamera(player_t *player, camera_t *thiscam); boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); +pflags_t P_GetJumpFlags(player_t *player); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); +boolean P_PlayerCanDamage(player_t *player, mobj_t *thing); boolean P_IsLocalPlayer(player_t *player); boolean P_IsObjectInGoop(mobj_t *mo); @@ -133,25 +146,38 @@ boolean P_IsObjectOnGround(mobj_t *mo); boolean P_IsObjectOnGroundIn(mobj_t *mo, sector_t *sec); boolean P_InSpaceSector(mobj_t *mo); boolean P_InQuicksand(mobj_t *mo); +boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff); void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative); void P_RestoreMusic(player_t *player); void P_SpawnShieldOrb(player_t *player); +void P_SwitchShield(player_t *player, UINT16 shieldtype); mobj_t *P_SpawnGhostMobj(mobj_t *mobj); void P_GivePlayerRings(player_t *player, INT32 num_rings); +void P_GivePlayerSpheres(player_t *player, INT32 num_spheres); void P_GivePlayerLives(player_t *player, INT32 numlives); +void P_GiveCoopLives(player_t *player, INT32 numlives, boolean sound); UINT8 P_GetNextEmerald(void); void P_GiveEmerald(boolean spawnObj); +void P_GiveFinishFlags(player_t *player); +#if 0 void P_ResetScore(player_t *player); +#else +#define P_ResetScore(player) player->scoreadd = 0 +#endif boolean P_AutoPause(void); void P_DoJumpShield(player_t *player); +void P_DoBubbleBounce(player_t *player); +void P_DoAbilityBounce(player_t *player, boolean changemomz); +void P_TwinSpinRejuvenate(player_t *player, mobjtype_t type); void P_BlackOw(player_t *player); -void P_ElementalFireTrail(player_t *player); +void P_ElementalFire(player_t *player, boolean cropcircle); void P_DoPityCheck(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); +void P_DoPlayerFinish(player_t *player); void P_DoPlayerExit(player_t *player); void P_NightserizePlayer(player_t *player, INT32 ptime); @@ -160,12 +186,14 @@ fixed_t P_ReturnThrustX(mobj_t *mo, angle_t angle, fixed_t move); fixed_t P_ReturnThrustY(mobj_t *mo, angle_t angle, fixed_t move); void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); -boolean P_LookForEnemies(player_t *player); +mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, UINT8 lockonflags); + +mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); -void P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user +boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user boolean P_SuperReady(player_t *player); void P_DoJump(player_t *player, boolean soundandstate); -boolean P_AnalogMove(player_t *player); +#define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG) boolean P_TransferToNextMare(player_t *player); UINT8 P_FindLowestMare(void); void P_FindEmerald(void); @@ -180,6 +208,50 @@ void P_PlayLivesJingle(player_t *player); #define P_PlayDeathSound(s) S_StartSound(s, sfx_altdi1 + P_RandomKey(4)); #define P_PlayVictorySound(s) S_StartSound(s, sfx_victr1 + P_RandomKey(4)); +boolean P_GetLives(player_t *player); +boolean P_SpectatorJoinGame(player_t *player); +void P_RestoreMultiMusic(player_t *player); + +/// ------------------------ +/// Jingle stuff +/// ------------------------ + +typedef enum +{ + JT_NONE, // Null state + JT_OTHER, // Other state + JT_MASTER, // Main level music + JT_1UP, // Extra life + JT_SHOES, // Speed shoes + JT_INV, // Invincibility + JT_MINV, // Mario Invincibility + JT_DROWN, // Drowning + JT_SUPER, // Super Sonic + JT_GOVER, // Game Over + JT_NIGHTSTIMEOUT, // NiGHTS Time Out (10 seconds) + JT_SSTIMEOUT, // NiGHTS Special Stage Time Out (10 seconds) + + // these are not jingles + // JT_LCLEAR, // Level Clear + // JT_RACENT, // Multiplayer Intermission + // JT_CONTSC, // Continue + + NUMJINGLES +} jingletype_t; + +typedef struct +{ + char musname[7]; + boolean looping; +} jingle_t; + +extern jingle_t jingleinfo[NUMJINGLES]; + +#define JINGLEPOSTFADE 1000 + +void P_PlayJingle(player_t *player, jingletype_t jingletype); +boolean P_EvaluateMusicStatus(UINT16 status, const char *musname); +void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status); // // P_MOBJ @@ -194,7 +266,7 @@ void P_PlayLivesJingle(player_t *player); extern mapthing_t *itemrespawnque[ITEMQUESIZE]; extern tic_t itemrespawntime[ITEMQUESIZE]; extern size_t iquehead, iquetail; -extern consvar_t cv_gravity, cv_viewheight; +extern consvar_t cv_gravity, cv_movebob; void P_RespawnSpecials(void); @@ -210,6 +282,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state); boolean P_SetMobjState(mobj_t *mobj, statenum_t state); void P_RunShields(void); void P_RunOverlays(void); +void P_HandleMinecartSegments(mobj_t *mobj); void P_MobjThinker(mobj_t *mobj); boolean P_RailThinker(mobj_t *mobj); void P_PushableThinker(mobj_t *mobj); @@ -234,7 +307,10 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f boolean P_InsideANonSolidFFloor(mobj_t *mobj, ffloor_t *rover); boolean P_CheckDeathPitCollide(mobj_t *mo); -boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover); +boolean P_CheckSolidLava(ffloor_t *rover); +void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype); + +mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type); mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type); mobj_t *P_SpawnXYZMissile(mobj_t *source, mobj_t *dest, mobjtype_t type, fixed_t x, fixed_t y, fixed_t z); @@ -250,6 +326,7 @@ SINT8 P_MobjFlip(mobj_t *mobj); fixed_t P_GetMobjGravity(mobj_t *mo); FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type); +void P_CalcChasePostImg(player_t *player, camera_t *thiscam); boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled); void P_Attract(mobj_t *source, mobj_t *enemy, boolean nightsgrab); @@ -257,6 +334,8 @@ mobj_t *P_GetClosestAxis(mobj_t *source); boolean P_CanRunOnWater(player_t *player, ffloor_t *rover); +void P_MaceRotate(mobj_t *center, INT32 baserot, INT32 baseprevrot); + void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration); #define PAL_WHITE 1 #define PAL_MIXUP 2 @@ -283,6 +362,13 @@ boolean P_CheckMissileRange(mobj_t *actor); void P_NewChaseDir(mobj_t *actor); boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed_t dist); +mobj_t *P_InternalFlickySpawn(mobj_t *actor, mobjtype_t flickytype, fixed_t momz, boolean lookforplayers, SINT8 moveforward); +void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo); +#define P_IsFlickyCenter(type) (type > MT_FLICKY_01 && type < MT_SEED && (type - MT_FLICKY_01) % 2 ? 1 : 0) +void P_InternalFlickyBubble(mobj_t *actor); +void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fixed_t chasez); +void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angle); + // // P_MAP // @@ -292,6 +378,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed extern boolean floatok; extern fixed_t tmfloorz; extern fixed_t tmceilingz; +extern ffloor_t *tmfloorrover, *tmceilingrover; extern mobj_t *tmfloorthing, *tmhitthing, *tmthing; extern camera_t *mapcampointer; extern fixed_t tmx; @@ -332,7 +419,7 @@ void P_DelPrecipSeclist(mprecipsecnode_t *node); void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y); void P_Initsecnode(void); -void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist); +void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist, UINT8 damagetype); fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height); boolean PIT_PushableMoved(mobj_t *thing); @@ -366,18 +453,41 @@ typedef struct BasicFF_s INT32 Magnitude; ///< Magnitude of the effect, in the range from 0 through 10,000. } BasicFF_t; +/* Damage/death types, for P_DamageMobj and related */ +//// Damage types +//#define DMG_NORMAL 0 (unneeded?) +#define DMG_WATER 1 +#define DMG_FIRE 2 +#define DMG_ELECTRIC 3 +#define DMG_SPIKE 4 +#define DMG_NUKE 5 // bomb shield +//#define DMG_SPECIALSTAGE 6 +//// Death types - cannot be combined with damage types +#define DMG_INSTAKILL 0x80 +#define DMG_DROWNED 0x80+1 +#define DMG_SPACEDROWN 0x80+2 +#define DMG_DEATHPIT 0x80+3 +#define DMG_CRUSHED 0x80+4 +#define DMG_SPECTATOR 0x80+5 +// Masks +#define DMG_CANHURTSELF 0x40 // Flag - can hurt self/team indirectly, such as through mines +#define DMG_DEATHMASK DMG_INSTAKILL // if bit 7 is set, this is a death type instead of a damage type + void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period); void P_ForceConstant(const BasicFF_t *FFInfo); void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End); void P_RemoveShield(player_t *player); -boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); -void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source); +void P_SpecialStageDamage(player_t *player, mobj_t *inflictor, mobj_t *source); +boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage, UINT8 damagetype); +void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); void P_PlayerRingBurst(player_t *player, INT32 num_rings); /// \todo better fit in p_user.c void P_PlayerWeaponPanelBurst(player_t *player); void P_PlayerWeaponAmmoBurst(player_t *player); +void P_PlayerWeaponPanelOrAmmoBurst(player_t *player); void P_PlayerEmeraldBurst(player_t *player, boolean toss); void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck); +void P_TouchStarPost(mobj_t *starpost, player_t *player, boolean snaptopost); void P_PlayerFlagBurst(player_t *player, boolean toss); void P_CheckTimeLimit(void); void P_CheckPointLimit(void); @@ -389,6 +499,7 @@ void P_ResetStarposts(void); boolean P_CanPickupItem(player_t *player, boolean weapon); void P_DoNightsScore(player_t *player); +void P_DoMatchSuper(player_t *player); // // P_SPEC @@ -404,7 +515,7 @@ extern INT32 ceilmovesound; void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, INT16 starpostx, INT16 starposty, INT16 starpostz, INT32 starpostnum, tic_t starposttime, angle_t starpostangle, - INT32 flags2); + fixed_t starpostscale, angle_t drawangle, INT32 flags2); boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, boolean flash, boolean dontstopmove); boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state); boolean P_CheckMissileSpawn(mobj_t *th); diff --git a/src/p_map.c b/src/p_map.c index 95ad02588..988089989 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -52,6 +52,7 @@ fixed_t tmfloorz, tmceilingz; static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) +ffloor_t *tmfloorrover, *tmceilingrover; #ifdef ESLOPE pslope_t *tmfloorslope, *tmceilingslope; #endif @@ -101,6 +102,8 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; return true; } @@ -109,68 +112,247 @@ boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) // MOVEMENT ITERATOR FUNCTIONS // ========================================================================= +// P_DoSpring +// +// MF_SPRING does some weird, mildly hacky stuff sometimes. +// mass = vertical speed +// damage = horizontal speed +// raisestate = state to change spring to on collision +// reactiontime = number of times it can give 10 points (0 is standard) +// painchance = spring mode: +// 0 = standard vanilla spring behaviour +// Positive spring modes are minor variants of vanilla spring behaviour. +// 1 = launch players in jump +// 2 = don't modify player at all, just add momentum +// 3 = speed-booster mode (force onto ground, MF_AMBUSH causes auto-spin) +// Negative spring modes are mildly-related gimmicks with customisation. +// -1 = pinball bumper +// Any other spring mode defaults to standard vanilla spring behaviour, +// ****** but forward compatibility is not guaranteed for these. ****** +// + boolean P_DoSpring(mobj_t *spring, mobj_t *object) { - INT32 pflags; - fixed_t offx, offy; fixed_t vertispeed = spring->info->mass; fixed_t horizspeed = spring->info->damage; + boolean final = false; + UINT8 strong = 0; - if (object->eflags & MFE_SPRUNG) // Object was already sprung this tic + // Object was already sprung this tic + if (object->eflags & MFE_SPRUNG) return false; // Spectators don't trigger springs. if (object->player && object->player->spectator) return false; - if (object->player && (object->player->pflags & PF_NIGHTSMODE)) + // "Even in Death" is a song from Volume 8, not a command. + if (!spring->health || !object->health) + return false; + + if (object->player) + { + if (spring->info->painchance == 3) + ; + else if (object->player->charability == CA_TWINSPIN && object->player->panim == PA_ABILITY) + strong = 1; + else if (object->player->charability2 == CA2_MELEE && object->player->panim == PA_ABILITY2) + strong = 2; + } + + if (spring->info->painchance == -1) // Pinball bumper mode. + { + // The first of the entirely different spring modes! + // Some of the attributes mean different things here. + // mass = default strength (can be controlled by mapthing's spawnangle) + // damage = unused + angle_t horizangle, vertiangle; + + if (!vertispeed) + return false; + + if (object->player && object->player->homing) // Sonic Heroes and Shadow the Hedgehog are the only games to contain homing-attackable bumpers! + { + horizangle = 0; + vertiangle = ((object->eflags & MFE_VERTICALFLIP) ? ANGLE_270 : ANGLE_90) >> ANGLETOFINESHIFT; + object->player->pflags &= ~PF_THOKKED; + if (spring->eflags & MFE_VERTICALFLIP) + object->z = spring->z - object->height - 1; + else + object->z = spring->z + spring->height + 1; + } + else + { + horizangle = R_PointToAngle2(spring->x, spring->y, object->x, object->y); + vertiangle = (R_PointToAngle2( + 0, + spring->z + spring->height/2, + FixedHypot(object->x - spring->x, object->y - spring->y), + object->z + object->height/2) + >> ANGLETOFINESHIFT) & FINEMASK; + } + + if (spring->spawnpoint && spring->spawnpoint->angle > 0) + vertispeed = (spring->spawnpoint->angle<<(FRACBITS-1))/5; + vertispeed = FixedMul(vertispeed, FixedMul(object->scale, spring->scale)); + + if (object->player) + { + fixed_t playervelocity; + + if (strong) + vertispeed <<= 1; + + if (!(object->player->pflags & PF_THOKKED) && !(object->player->homing) + && ((playervelocity = FixedDiv(9*FixedHypot(object->player->speed, object->momz), 10< vertispeed)) + vertispeed = playervelocity; + + if (object->player->powers[pw_carry] == CR_NIGHTSMODE) // THIS has NiGHTS support, at least... + { + angle_t nightsangle = 0; + + if (object->player->bumpertime > (TICRATE/2)-5) + return false; + + if ((object->player->pflags & PF_TRANSFERTOCLOSEST) && object->player->axis1 && object->player->axis2) + { + nightsangle = R_PointToAngle2(object->player->axis1->x, object->player->axis1->y, object->player->axis2->x, object->player->axis2->y); + nightsangle += ANGLE_90; + } + else if (object->target) + { + if (object->target->flags2 & MF2_AMBUSH) + nightsangle = R_PointToAngle2(object->target->x, object->target->y, object->x, object->y); + else + nightsangle = R_PointToAngle2(object->x, object->y, object->target->x, object->target->y); + } + + object->player->flyangle = AngleFixed(R_PointToAngle2( + 0, + spring->z + spring->height/2, + FixedMul( + FINESINE(((nightsangle - horizangle) >> ANGLETOFINESHIFT) & FINEMASK), + FixedHypot(object->x - spring->x, object->y - spring->y)), + object->z + object->height/2))>>FRACBITS; + + object->player->bumpertime = TICRATE/2; + } + else + { + INT32 pflags = object->player->pflags & (PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_THOKKED|PF_BOUNCING); // Not identical to below... + UINT8 secondjump = object->player->secondjump; + if (object->player->pflags & PF_GLIDING) + P_SetPlayerMobjState(object, S_PLAY_FALL); + P_ResetPlayer(object->player); + object->player->pflags |= pflags; + object->player->secondjump = secondjump; + } + } + + if (!P_IsObjectOnGround(object)) // prevents uncurling when spinning due to "landing" + object->momz = FixedMul(vertispeed, FINESINE(vertiangle)); + P_InstaThrust(object, horizangle, FixedMul(vertispeed, FINECOSINE(vertiangle))); + + object->eflags |= MFE_SPRUNG; // apply this flag asap! + + goto springstate; + } + + // Does nothing? + if (!vertispeed && !horizspeed) + return false; + +#ifdef ESLOPE + object->standingslope = NULL; // Okay, now we know it's not going to be relevant - no launching off at silly angles for you. +#endif + + if (spring->eflags & MFE_VERTICALFLIP) + vertispeed *= -1; + + if (object->player && (object->player->powers[pw_carry] == CR_NIGHTSMODE)) { /*Someone want to make these work like bumpers?*/ return false; } -#ifdef ESLOPE - object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you. -#endif - - object->eflags |= MFE_SPRUNG; // apply this flag asap! - spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify - - if (horizspeed && vertispeed) // Mimic SA + if (strong) { - object->momx = object->momy = 0; - P_TryMove(object, spring->x, spring->y, true); + if (horizspeed) + horizspeed = FixedMul(horizspeed, (4*FRACUNIT)/3); + if (vertispeed) + vertispeed = FixedMul(vertispeed, (6*FRACUNIT)/5); // aprox square root of above } - if (spring->eflags & MFE_VERTICALFLIP) - vertispeed *= -1; + object->eflags |= MFE_SPRUNG; // apply this flag asap! + spring->flags &= ~(MF_SPRING|MF_SPECIAL); // De-solidify - if (vertispeed > 0) - object->z = spring->z + spring->height + 1; - else if (vertispeed < 0) - object->z = spring->z - object->height - 1; - else + if (spring->info->painchance != 2) { - // Horizontal springs teleport you in FRONT of them. - object->momx = object->momy = 0; + if (object->player) + { + object->player->pflags &= ~PF_APPLYAUTOBRAKE; +#ifndef SPRINGSPIN + object->player->powers[pw_justsprung] = 5; + if (horizspeed) + object->player->powers[pw_noautobrake] = ((horizspeed*TICRATE)>>(FRACBITS+3))/9; // TICRATE at 72*FRACUNIT + else if (P_MobjFlip(object) == P_MobjFlip(spring)) + object->player->powers[pw_justsprung] |= (1<<15); +#else + object->player->powers[pw_justsprung] = 15; + if (horizspeed) + object->player->powers[pw_noautobrake] = ((horizspeed*TICRATE)>>(FRACBITS+3))/9; // TICRATE at 72*FRACUNIT + else + { + if (abs(object->player->rmomx) > object->scale || abs(object->player->rmomy) > object->scale) + object->player->drawangle = R_PointToAngle2(0, 0, object->player->rmomx, object->player->rmomy); + if (P_MobjFlip(object) == P_MobjFlip(spring)) + object->player->powers[pw_justsprung] |= (1<<15); + } +#endif + } - // Overestimate the distance to position you at - offx = P_ReturnThrustX(spring, spring->angle, (spring->radius + object->radius + 1) * 2); - offy = P_ReturnThrustY(spring, spring->angle, (spring->radius + object->radius + 1) * 2); + if ((horizspeed && vertispeed) || (object->player && object->player->homing)) // Mimic SA + { + object->momx = object->momy = 0; + P_TryMove(object, spring->x, spring->y, true); + } - // Make it square by clipping - if (offx > (spring->radius + object->radius + 1)) - offx = spring->radius + object->radius + 1; - else if (offx < -(spring->radius + object->radius + 1)) - offx = -(spring->radius + object->radius + 1); + if (vertispeed > 0) + object->z = spring->z + spring->height + 1; + else if (vertispeed < 0) + object->z = spring->z - object->height - 1; + else + { + fixed_t offx, offy; + // Horizontal springs teleport you in FRONT of them. + object->momx = object->momy = 0; - if (offy > (spring->radius + object->radius + 1)) - offy = spring->radius + object->radius + 1; - else if (offy < -(spring->radius + object->radius + 1)) - offy = -(spring->radius + object->radius + 1); + // Overestimate the distance to position you at + offx = P_ReturnThrustX(spring, spring->angle, (spring->radius + object->radius + 1) * 2); + offy = P_ReturnThrustY(spring, spring->angle, (spring->radius + object->radius + 1) * 2); - // Set position! - P_TryMove(object, spring->x + offx, spring->y + offy, true); + // Make it square by clipping + if (offx > (spring->radius + object->radius + 1)) + offx = spring->radius + object->radius + 1; + else if (offx < -(spring->radius + object->radius + 1)) + offx = -(spring->radius + object->radius + 1); + + if (offy > (spring->radius + object->radius + 1)) + offy = spring->radius + object->radius + 1; + else if (offy < -(spring->radius + object->radius + 1)) + offy = -(spring->radius + object->radius + 1); + + // Set position! + P_TryMove(object, spring->x + offx, spring->y + offy, true); + + if ((spring->info->painchance == 3)) + { + object->z = spring->z; + if (spring->eflags & MFE_VERTICALFLIP) + object->z -= object->height; + object->momz = 0; + } + } } if (vertispeed) @@ -180,20 +362,22 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) P_InstaThrustEvenIn2D(object, spring->angle, FixedMul(horizspeed,FixedSqrt(FixedMul(object->scale, spring->scale)))); // Re-solidify - spring->flags |= (spring->info->flags & (MF_SPECIAL|MF_SOLID)); - - P_SetMobjState(spring, spring->info->raisestate); + spring->flags |= (spring->info->flags & (MF_SPRING|MF_SPECIAL)); if (object->player) { + INT32 pflags; + UINT8 secondjump; + boolean washoming; + if (spring->flags & MF_ENEMY) // Spring shells P_SetTarget(&spring->target, object); - if (horizspeed && object->player->cmd.forwardmove == 0 && object->player->cmd.sidemove == 0) + if (horizspeed) { - object->angle = spring->angle; + object->angle = object->player->drawangle = spring->angle; - if (!demoplayback || P_AnalogMove(object->player)) + if (!demoplayback || P_ControlStyle(object->player) == CS_LMAOGALOG) { if (object->player == &players[consoleplayer]) localangle = spring->angle; @@ -202,28 +386,85 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) } } - pflags = object->player->pflags & (PF_JUMPED|PF_SPINNING|PF_THOKKED); // I still need these. + if (object->player->pflags & PF_GLIDING) + P_SetPlayerMobjState(object, S_PLAY_FALL); + if ((spring->info->painchance == 3)) + { + if (!(pflags = (object->player->pflags & PF_SPINNING)) && + (((object->player->charability2 == CA2_SPINDASH) && (object->player->cmd.buttons & BT_USE)) + || (spring->flags2 & MF2_AMBUSH))) + { + pflags = PF_SPINNING; + P_SetPlayerMobjState(object, S_PLAY_ROLL); + S_StartSound(object, sfx_spin); + } + else + P_SetPlayerMobjState(object, S_PLAY_ROLL); + } + else + pflags = object->player->pflags & (PF_STARTJUMP|PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_THOKKED|PF_BOUNCING); // I still need these. + secondjump = object->player->secondjump; + washoming = object->player->homing; P_ResetPlayer(object->player); - if (P_MobjFlip(object)*vertispeed > 0) - P_SetPlayerMobjState(object, S_PLAY_SPRING); - else if (P_MobjFlip(object)*vertispeed < 0) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - else // horizontal spring + if (spring->info->painchance == 1) // For all those ancient, SOC'd abilities. { - if (pflags & (PF_JUMPED|PF_SPINNING) && object->player->panim == PA_ROLL) - object->player->pflags = pflags; + object->player->pflags |= P_GetJumpFlags(object->player); + P_SetPlayerMobjState(object, S_PLAY_JUMP); + } + else if ((spring->info->painchance == 2) || ((spring->info->painchance != 3) && (pflags & PF_BOUNCING))) // Adding momentum only. + { + object->player->pflags |= (pflags &~ PF_STARTJUMP); + object->player->secondjump = secondjump; + if (washoming) + object->player->pflags &= ~PF_THOKKED; + } + else if (!vertispeed) + { + if (pflags & (PF_JUMPED|PF_SPINNING)) + { + object->player->pflags |= pflags; + object->player->secondjump = secondjump; + } + else if (object->player->dashmode >= DASHMODE_THRESHOLD) + P_SetPlayerMobjState(object, S_PLAY_DASH); + else if (P_IsObjectOnGround(object) && horizspeed >= FixedMul(object->player->runspeed, object->scale)) + P_SetPlayerMobjState(object, S_PLAY_RUN); else - P_SetPlayerMobjState(object, S_PLAY_RUN1); + P_SetPlayerMobjState(object, S_PLAY_WALK); + } + else if (P_MobjFlip(object)*vertispeed > 0) + P_SetPlayerMobjState(object, S_PLAY_SPRING); + else + P_SetPlayerMobjState(object, S_PLAY_FALL); + } + +#ifdef ESLOPE + object->standingslope = NULL; // And again. +#endif + + final = true; + +springstate: + if ((statenum_t)(spring->state-states) < spring->info->raisestate) + { + P_SetMobjState(spring, spring->info->raisestate); + if (object->player && spring->reactiontime && !(spring->info->flags & MF_ENEMY)) + { + if (object->player->powers[pw_carry] != CR_NIGHTSMODE) // don't make graphic in NiGHTS + P_SetMobjState(P_SpawnMobj(spring->x, spring->y, spring->z + (spring->height/2), MT_SCORE), mobjinfo[MT_SCORE].spawnstate+11); + P_AddPlayerScore(object->player, 10); + spring->reactiontime--; } - if (spring->info->painchance) + if (strong) { - object->player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(object, S_PLAY_ATK1); + P_TwinSpinRejuvenate(object->player, (strong == 1 ? object->player->thokitem : object->player->revitem)); + S_StartSound(object, sfx_sprong); // strong spring. sprong. } } - return true; + + return final; } static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) @@ -274,7 +515,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) { P_ResetPlayer(p); if (p->panim != PA_FALL) - P_SetPlayerMobjState(object, S_PLAY_FALL1); + P_SetPlayerMobjState(object, S_PLAY_FALL); } break; case MT_STEAM: // Steam @@ -289,7 +530,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) { P_ResetPlayer(p); if (p->panim != PA_FALL) - P_SetPlayerMobjState(object, S_PLAY_FALL1); + P_SetPlayerMobjState(object, S_PLAY_FALL); } break; default: @@ -297,29 +538,60 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) } } +static void P_DoPterabyteCarry(player_t *player, mobj_t *ptera) +{ + if (player->powers[pw_carry] && player->powers[pw_carry] != CR_ROLLOUT) + return; + if (ptera->extravalue1 != 1) + return; // Not swooping + if (ptera->target != player->mo) + return; // Not swooping for you! + + if (player->spectator) + return; + + if ((player->mo->eflags & MFE_VERTICALFLIP) != (ptera->eflags & MFE_VERTICALFLIP)) + return; // Both should be in same gravity + + if (ptera->eflags & MFE_VERTICALFLIP) + { + if (ptera->ceilingz - (ptera->z + ptera->height) < player->mo->height - FixedMul(2*FRACUNIT, player->mo->scale)) + return; + } + else if (ptera->z - ptera->floorz < player->mo->height - FixedMul(2*FRACUNIT, player->mo->scale)) + return; // No room to pick up this guy! + + P_ResetPlayer(player); + P_SetTarget(&player->mo->tracer, ptera); + player->pflags &= ~PF_APPLYAUTOBRAKE; + player->powers[pw_carry] = CR_PTERABYTE; + S_StartSound(player->mo, sfx_s3k4a); + P_UnsetThingPosition(player->mo); + player->mo->x = ptera->x; + player->mo->y = ptera->y; + P_SetThingPosition(player->mo); + ptera->movefactor = 3*TICRATE; + ptera->watertop = ptera->waterbottom = ptera->cusval = 0; +} + static void P_DoTailsCarry(player_t *sonic, player_t *tails) { INT32 p; fixed_t zdist; // z distance between the two players' bottoms - if ((tails->pflags & PF_CARRIED) && tails->mo->tracer == sonic->mo) + if (tails->powers[pw_carry]) return; - if ((sonic->pflags & PF_CARRIED) && sonic->mo->tracer == tails->mo) + if (sonic->powers[pw_carry]) return; - if (!tails->powers[pw_tailsfly] && !(tails->charability == CA_FLY && (tails->mo->state >= &states[S_PLAY_SPC1] && tails->mo->state <= &states[S_PLAY_SPC4]))) + if (tails->spectator) + return; + if (sonic->spectator) return; - if (tails->bot == 1) + if (!(tails->pflags & PF_CANCARRY)) return; - if (sonic->pflags & PF_NIGHTSMODE) - return; - - if (sonic->mo->tracer && sonic->mo->tracer->type == MT_TUBEWAYPOINT - && !(sonic->pflags & PF_ROPEHANG)) - return; // don't steal players from zoomtubes! - if ((sonic->mo->eflags & MFE_VERTICALFLIP) != (tails->mo->eflags & MFE_VERTICALFLIP)) return; // Both should be in same gravity @@ -334,57 +606,120 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) // Search in case another player is already being carried by this fox. for (p = 0; p < MAXPLAYERS; p++) if (playeringame[p] && players[p].mo - && players[p].pflags & PF_CARRIED && players[p].mo->tracer == tails->mo) + && players[p].powers[pw_carry] == CR_PLAYER && players[p].mo->tracer == tails->mo) return; + // Why block opposing teams from tailsflying each other? + // Sneaking into the hands of a flying tails player in Race might be a viable strategy, who knows. + /* + if ((gametyperules & GTR_RACE) + || (netgame && (tails->spectator || sonic->spectator)) + || (G_TagGametype() && (!(tails->pflags & PF_TAGIT) != !(sonic->pflags & PF_TAGIT))) + || (gametype == GT_MATCH) + || (G_GametypeHasTeams() && tails->ctfteam != sonic->ctfteam)) + return; */ + if (tails->mo->eflags & MFE_VERTICALFLIP) zdist = (sonic->mo->z + sonic->mo->height) - (tails->mo->z + tails->mo->height); else zdist = tails->mo->z - sonic->mo->z; - if (zdist <= sonic->mo->height + FixedMul(FRACUNIT, sonic->mo->scale) + if (zdist <= sonic->mo->height + sonic->mo->scale // FixedMul(FRACUNIT, sonic->mo->scale), but scale == FRACUNIT by default && zdist > sonic->mo->height*2/3 && P_MobjFlip(tails->mo)*sonic->mo->momz <= 0) { - // Why block opposing teams from tailsflying each other? - // Sneaking into the hands of a flying tails player in Race might be a viable strategy, who knows. - /* - if (gametype == GT_RACE || gametype == GT_COMPETITION - || (netgame && (tails->spectator || sonic->spectator)) - || (G_TagGametype() && (!(tails->pflags & PF_TAGIT) != !(sonic->pflags & PF_TAGIT))) - || (gametype == GT_MATCH) - || (G_GametypeHasTeams() && tails->ctfteam != sonic->ctfteam)) - sonic->pflags &= ~PF_CARRIED; */ - if (tails->spectator || sonic->spectator) - sonic->pflags &= ~PF_CARRIED; - else - { - if (sonic-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, false); - P_ResetPlayer(sonic); - P_SetTarget(&sonic->mo->tracer, tails->mo); - sonic->pflags |= PF_CARRIED; - S_StartSound(sonic->mo, sfx_s3k4a); - P_UnsetThingPosition(sonic->mo); - sonic->mo->x = tails->mo->x; - sonic->mo->y = tails->mo->y; - P_SetThingPosition(sonic->mo); - } + if (sonic-players == consoleplayer && botingame) + CV_SetValue(&cv_analog[1], false); + P_ResetPlayer(sonic); + P_SetTarget(&sonic->mo->tracer, tails->mo); + sonic->powers[pw_carry] = CR_PLAYER; + S_StartSound(sonic->mo, sfx_s3k4a); + P_UnsetThingPosition(sonic->mo); + sonic->mo->x = tails->mo->x; + sonic->mo->y = tails->mo->y; + P_SetThingPosition(sonic->mo); } else { if (sonic-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); - sonic->pflags &= ~PF_CARRIED; + CV_SetValue(&cv_analog[1], true); + P_SetTarget(&sonic->mo->tracer, NULL); + sonic->powers[pw_carry] = CR_NONE; } } +// Boss 5 post-defeat comedy +static void P_SlapStick(mobj_t *fang, mobj_t *pole) +{ + fixed_t momx1, momx2, momy1, momy2; + +#define dist 3 + momx1 = pole->momx/dist; + momy1 = pole->momy/dist; + momx2 = fang->momx/dist; + momy2 = fang->momy/dist; + + pole->tracer->tracer->momx = momx1 + (dist-1)*momx2; + pole->tracer->tracer->momy = momy1 + (dist-1)*momy2; + fang->momx = (dist-1)*momx1 + momx2; + fang->momy = (dist-1)*momy1 + momy2; +#undef dist + + P_SetObjectMomZ(pole->tracer->tracer, 6*FRACUNIT, false); + pole->tracer->tracer->flags &= ~(MF_NOGRAVITY|MF_NOCLIP); + pole->tracer->tracer->movedir = ANGLE_67h; + if ((R_PointToAngle(fang->x - pole->tracer->tracer->x, fang->y - pole->tracer->tracer->y) - pole->angle) > ANGLE_180) + pole->tracer->tracer->movedir = InvAngle(pole->tracer->movedir); + + P_SetObjectMomZ(fang, 14*FRACUNIT, false); + fang->flags |= MF_NOGRAVITY|MF_NOCLIP; + P_SetMobjState(fang, fang->info->xdeathstate); + + pole->tracer->tracer->tics = pole->tracer->tics = pole->tics = fang->tics; + + var1 = var2 = 0; + A_Scream(pole->tracer->tracer); + S_StartSound(fang, sfx_altdi1); + + P_SetTarget(&pole->tracer->tracer, NULL); + P_SetMobjState(pole->tracer, pole->info->xdeathstate); + P_SetTarget(&pole->tracer, NULL); + P_SetMobjState(pole, pole->info->deathstate); +} + +static void P_PlayerBarrelCollide(mobj_t *toucher, mobj_t *barrel) +{ + if (toucher->momz < 0) + { + if (toucher->z + toucher->momz > barrel->z + barrel->height) + return; + } + else + { + if (toucher->z > barrel->z + barrel->height) + return; + } + + if (toucher->momz > 0) + { + if (toucher->z + toucher->height + toucher->momz < barrel->z) + return; + } + else + { + if (toucher->z + toucher->height < barrel->z) + return; + } + + if (P_PlayerCanDamage(toucher->player, barrel)) + P_DamageMobj(barrel, toucher, toucher, 1, 0); +} + // // PIT_CheckThing // static boolean PIT_CheckThing(mobj_t *thing) { fixed_t blockdist; - boolean iwassprung = false; // don't clip against self if (thing == tmthing) @@ -407,9 +742,8 @@ static boolean PIT_CheckThing(mobj_t *thing) // So that NOTHING ELSE can see MT_NAMECHECK because it is client-side. if (tmthing->type == MT_NAMECHECK) { - // Ignore things that aren't players, ignore spectators, ignore yourself. - // (also don't bother to check that tmthing->target->player is non-NULL because we're not actually using it here.) - if (!thing->player || thing->player->spectator || (tmthing->target && thing->player == tmthing->target->player)) + // Ignore things that aren't players, ignore spectators, ignore yourself. + if (!thing->player || !(tmthing->target && tmthing->target->player) || thing->player->spectator || (tmthing->target && thing->player == tmthing->target->player)) return true; // Now check that you actually hit them. @@ -422,6 +756,10 @@ static boolean PIT_CheckThing(mobj_t *thing) if (tmthing->z + tmthing->height < thing->z) return true; // underneath + // REX HAS SEEN YOU + if (!LUAh_SeenPlayer(tmthing->target->player, thing->player)) + return false; + seenplayer = thing->player; return false; } @@ -429,7 +767,9 @@ static boolean PIT_CheckThing(mobj_t *thing) // Metal Sonic destroys tiny baby objects. if (tmthing->type == MT_METALSONIC_RACE - && (thing->flags & (MF_MISSILE|MF_ENEMY|MF_BOSS) || thing->type == MT_SPIKE)) + && (thing->flags & (MF_MISSILE|MF_ENEMY|MF_BOSS) + || (thing->type == MT_SPIKE + || thing->type == MT_WALLSPIKE))) { if ((thing->flags & (MF_ENEMY|MF_BOSS)) && (thing->health <= 0 || !(thing->flags & MF_SHOOTABLE))) return true; @@ -441,27 +781,90 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; // overhead if (tmthing->z + tmthing->height < thing->z) return true; // underneath - if (thing->type == MT_SPIKE) + if (thing->type == MT_SPIKE + || thing->type == MT_WALLSPIKE) { - S_StartSound(tmthing, thing->info->deathsound); - for (thing = thing->subsector->sector->thinglist; thing; thing = thing->snext) - if (thing->type == MT_SPIKE && thing->health > 0 && thing->flags & MF_SOLID && P_AproxDistance(thing->x - tmthing->x, thing->y - tmthing->y) < FixedMul(56*FRACUNIT, thing->scale)) - P_KillMobj(thing, tmthing, tmthing); + mobj_t *iter; + if (thing->flags & MF_SOLID) + S_StartSound(tmthing, thing->info->deathsound); + for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext) + if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) + P_KillMobj(iter, tmthing, tmthing, 0); } else { thing->health = 0; - P_KillMobj(thing, tmthing, tmthing); + P_KillMobj(thing, tmthing, tmthing, 0); } return true; } - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) + // SF_DASHMODE users destroy spikes and monitors, CA_TWINSPIN users and CA2_MELEE users destroy spikes. + if ((tmthing->player) + && ((((tmthing->player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) && (tmthing->player->dashmode >= DASHMODE_THRESHOLD) + && (thing->flags & (MF_MONITOR) + || (thing->type == MT_SPIKE + || thing->type == MT_WALLSPIKE))) + || ((((tmthing->player->charability == CA_TWINSPIN) && (tmthing->player->panim == PA_ABILITY)) + || (tmthing->player->charability2 == CA2_MELEE && tmthing->player->panim == PA_ABILITY2)) + && (thing->type == MT_SPIKE + || thing->type == MT_WALLSPIKE)))) + { + if ((thing->flags & (MF_MONITOR)) && (thing->health <= 0 || !(thing->flags & MF_SHOOTABLE))) + return true; + blockdist = thing->radius + tmthing->radius; + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) + return true; // didn't hit it + // see if it went over / under + if (tmthing->z > thing->z + thing->height) + return true; // overhead + if (tmthing->z + tmthing->height < thing->z) + return true; // underneath + if (thing->type == MT_SPIKE + || thing->type == MT_WALLSPIKE) + { + mobj_t *iter; + if (thing->flags & MF_SOLID) + S_StartSound(tmthing, thing->info->deathsound); + for (iter = thing->subsector->sector->thinglist; iter; iter = iter->snext) + if (iter->type == thing->type && iter->health > 0 && iter->flags & MF_SOLID && (iter == thing || P_AproxDistance(P_AproxDistance(thing->x - iter->x, thing->y - iter->y), thing->z - iter->z) < 56*thing->scale))//FixedMul(56*FRACUNIT, thing->scale)) + P_KillMobj(iter, tmthing, tmthing, 0); + return true; + } + else + { + if (P_DamageMobj(thing, tmthing, tmthing, 1, 0)) + return true; + } + } + + // vectorise metal - done in a special case as at this point neither has the right flags for touching + if (thing->type == MT_METALSONIC_BATTLE + && (tmthing->flags & MF_MISSILE) + && tmthing->target != thing + && thing->state == &states[thing->info->spawnstate]) + { + blockdist = thing->radius + tmthing->radius; + + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) + return true; // didn't hit it + + if (tmthing->z > thing->z + thing->height) + return true; // overhead + if (tmthing->z + tmthing->height < thing->z) + return true; // underneath + + thing->flags2 |= MF2_CLASSICPUSH; + + return true; + } + + if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE|MF_SPRING))) return true; // Don't collide with your buddies while NiGHTS-flying. if (tmthing->player && thing->player && (maptol & TOL_NIGHTS) - && ((tmthing->player->pflags & PF_NIGHTSMODE) || (thing->player->pflags & PF_NIGHTSMODE))) + && ((tmthing->player->powers[pw_carry] == CR_NIGHTSMODE) || (thing->player->powers[pw_carry] == CR_NIGHTSMODE))) return true; blockdist = thing->radius + tmthing->radius; @@ -469,7 +872,80 @@ static boolean PIT_CheckThing(mobj_t *thing) if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) return true; // didn't hit it -#ifdef HAVE_BLUA + if (thing->flags & MF_PAPERCOLLISION) // CAUTION! Very easy to get stuck inside MF_SOLID objects. Giving the player MF_PAPERCOLLISION is a bad idea unless you know what you're doing. + { + fixed_t cosradius, sinradius; + vertex_t v1, v2; // fake vertexes + line_t junk; // fake linedef + + cosradius = FixedMul(thing->radius, FINECOSINE(thing->angle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(thing->radius, FINESINE(thing->angle>>ANGLETOFINESHIFT)); + + v1.x = thing->x - cosradius; + v1.y = thing->y - sinradius; + v2.x = thing->x + cosradius; + v2.y = thing->y + sinradius; + + junk.v1 = &v1; + junk.v2 = &v2; + junk.dx = 2*cosradius; // v2.x - v1.x; + junk.dy = 2*sinradius; // v2.y - v1.y; + + if (tmthing->flags & MF_PAPERCOLLISION) // more strenuous checking to prevent clipping issues + { + INT32 check1, check2, check3, check4; + fixed_t tmcosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); + fixed_t tmsinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); + if (abs(thing->x - tmx) >= (abs(tmcosradius) + abs(cosradius)) || abs(thing->y - tmy) >= (abs(tmsinradius) + abs(sinradius))) + return true; // didn't hit it + check1 = P_PointOnLineSide(tmx - tmcosradius, tmy - tmsinradius, &junk); + check2 = P_PointOnLineSide(tmx + tmcosradius, tmy + tmsinradius, &junk); + check3 = P_PointOnLineSide(tmx + tmthing->momx - tmcosradius, tmy + tmthing->momy - tmsinradius, &junk); + check4 = P_PointOnLineSide(tmx + tmthing->momx + tmcosradius, tmy + tmthing->momy + tmsinradius, &junk); + if ((check1 == check2) && (check2 == check3) && (check3 == check4)) + return true; // the line doesn't cross between collider's start or end + } + else + { + if (abs(thing->x - tmx) >= (tmthing->radius + abs(cosradius)) || abs(thing->y - tmy) >= (tmthing->radius + abs(sinradius))) + return true; // didn't hit it + if ((P_PointOnLineSide(tmx - tmthing->radius, tmy - tmthing->radius, &junk) + == P_PointOnLineSide(tmx + tmthing->radius, tmy + tmthing->radius, &junk)) + && (P_PointOnLineSide(tmx + tmthing->radius, tmy - tmthing->radius, &junk) + == P_PointOnLineSide(tmx - tmthing->radius, tmy + tmthing->radius, &junk))) + return true; // the line doesn't cross between either pair of opposite corners + } + } + else if (tmthing->flags & MF_PAPERCOLLISION) + { + fixed_t tmcosradius, tmsinradius; + vertex_t v1, v2; // fake vertexes + line_t junk; // fake linedef + + tmcosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); + tmsinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); + + if (abs(thing->x - tmx) >= (thing->radius + abs(tmcosradius)) || abs(thing->y - tmy) >= (thing->radius + abs(tmsinradius))) + return true; // didn't hit it + + v1.x = tmx - tmcosradius; + v1.y = tmy - tmsinradius; + v2.x = tmx + tmcosradius; + v2.y = tmy + tmsinradius; + + junk.v1 = &v1; + junk.v2 = &v2; + junk.dx = 2*tmcosradius; // v2.x - v1.x; + junk.dy = 2*tmsinradius; // v2.y - v1.y; + + // no need to check whether other thing has MF_PAPERCOLLISION, since would fall under other condition + if ((P_PointOnLineSide(thing->x - thing->radius, thing->y - thing->radius, &junk) + == P_PointOnLineSide(thing->x + thing->radius, thing->y + thing->radius, &junk)) + && (P_PointOnLineSide(thing->x + thing->radius, thing->y - thing->radius, &junk) + == P_PointOnLineSide(thing->x - thing->radius, thing->y + thing->radius, &junk))) + return true; // the line doesn't cross between either pair of opposite corners + } + { UINT8 shouldCollide = LUAh_MobjCollide(thing, tmthing); // checks hook for thing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) @@ -478,9 +954,8 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; // force collide else if (shouldCollide == 2) return true; // force no collide - } - { - UINT8 shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type + + shouldCollide = LUAh_MobjMoveCollide(tmthing, thing); // checks hook for tmthing's type if (P_MobjWasRemoved(tmthing) || P_MobjWasRemoved(thing)) return true; // one of them was removed??? if (shouldCollide == 1) @@ -488,7 +963,186 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (shouldCollide == 2) return true; // force no collide } -#endif + + if (tmthing->type == MT_LAVAFALL_LAVA && (thing->type == MT_RING || thing->type == MT_REDTEAMRING || thing->type == MT_BLUETEAMRING || thing->type == MT_FLINGRING)) + { + //height check + if (tmthing->z > thing->z + thing->height || thing->z > tmthing->z + tmthing->height || !(thing->health)) + return true; + + P_KillMobj(thing, tmthing, tmthing, DMG_FIRE); + } + + if (tmthing->type == MT_MINECART) + { + //height check + if (tmthing->z > thing->z + thing->height || thing->z > tmthing->z + tmthing->height || !(thing->health)) + return true; + + if (thing->type == MT_TNTBARREL) + P_KillMobj(thing, tmthing, tmthing->target, 0); + else if ((thing->flags & MF_MONITOR) || (thing->flags & MF_ENEMY)) + { + P_KillMobj(thing, tmthing, tmthing->target, 0); + if (tmthing->momz*P_MobjFlip(tmthing) < 0) + tmthing->momz = abs(tmthing->momz)*P_MobjFlip(tmthing); + } + } + + if (thing->type == MT_SALOONDOOR && tmthing->player) + { + mobj_t *ref = (tmthing->player->powers[pw_carry] == CR_MINECART && tmthing->tracer && !P_MobjWasRemoved(tmthing->tracer)) ? tmthing->tracer : tmthing; + if ((thing->flags2 & MF2_AMBUSH) || ref != tmthing) + { + fixed_t dm = min(FixedHypot(ref->momx, ref->momy), 16*FRACUNIT); + angle_t ang = R_PointToAngle2(0, 0, ref->momx, ref->momy) - thing->angle; + fixed_t s = FINESINE((ang >> ANGLETOFINESHIFT) & FINEMASK); + S_StartSound(tmthing, thing->info->activesound); + thing->extravalue2 += 2*FixedMul(s, dm)/3; + return true; + } + } + + if (thing->type == MT_SALOONDOORCENTER && tmthing->player) + { + if ((thing->flags2 & MF2_AMBUSH) || (tmthing->player->powers[pw_carry] == CR_MINECART && tmthing->tracer && !P_MobjWasRemoved(tmthing->tracer))) + return true; + } + + if (thing->type == MT_ROLLOUTROCK && tmthing->player && tmthing->health) + { + if (tmthing->player->powers[pw_carry] == CR_ROLLOUT) + { + return true; + } + if ((thing->flags & MF_PUSHABLE) // not carrying a player + && (tmthing->player->powers[pw_carry] == CR_NONE) // player is not already riding something + && ((tmthing->eflags & MFE_VERTICALFLIP) == (thing->eflags & MFE_VERTICALFLIP)) + && (P_MobjFlip(tmthing)*tmthing->momz <= 0) + && ((!(tmthing->eflags & MFE_VERTICALFLIP) && abs(thing->z + thing->height - tmthing->z) < (thing->height>>2)) + || (tmthing->eflags & MFE_VERTICALFLIP && abs(tmthing->z + tmthing->height - thing->z) < (thing->height>>2)))) + { + thing->flags &= ~MF_PUSHABLE; // prevent riding player from applying pushable movement logic + thing->flags2 &= ~MF2_DONTDRAW; // don't leave the rock invisible if it was flashing prior to boarding + P_SetTarget(&thing->tracer, tmthing); + P_ResetPlayer(tmthing->player); + P_SetPlayerMobjState(tmthing, S_PLAY_WALK); + tmthing->player->powers[pw_carry] = CR_ROLLOUT; + P_SetTarget(&tmthing->tracer, thing); + if (!P_IsObjectOnGround(thing)) + thing->momz += tmthing->momz; + return true; + } + } + else if (tmthing->type == MT_ROLLOUTROCK) + { + if (tmthing->z > thing->z + thing->height || thing->z > tmthing->z + tmthing->height || !thing->health) + return true; + + if (thing == tmthing->tracer) // don't collide with rider + return true; + + if (thing->flags & MF_SPRING) // bounce on springs + { + P_DoSpring(thing, tmthing); + return true; + } + else if ((thing->flags & (MF_MONITOR|MF_SHOOTABLE)) == (MF_MONITOR|MF_SHOOTABLE) && !(tmthing->flags & MF_PUSHABLE)) // pop monitors while carrying a player + { + P_KillMobj(thing, tmthing, tmthing->tracer, 0); + return true; + } + + if (thing->type == tmthing->type // bounce against other rollout rocks + && (tmthing->momx || tmthing->momy || thing->momx || thing->momy)) + { + fixed_t tempmomx = thing->momx, tempmomy = thing->momy; + thing->momx = tmthing->momx; + thing->momy = tmthing->momy; + tmthing->momx = tempmomx; + tmthing->momy = tempmomy; + S_StartSound(thing, thing->info->painsound); + } + } + + if (thing->type == MT_PTERABYTE && tmthing->player) + P_DoPterabyteCarry(tmthing->player, thing); + + if (thing->type == MT_TNTBARREL && tmthing->player) + P_PlayerBarrelCollide(tmthing, thing); + + if (thing->type == MT_VULTURE && tmthing->type == MT_VULTURE) + { + fixed_t dx = thing->x - tmthing->x; + fixed_t dy = thing->y - tmthing->y; + fixed_t dz = thing->z - tmthing->z; + fixed_t dm = FixedHypot(dz, FixedHypot(dx, dy)); + thing->momx += FixedDiv(dx, dm); + thing->momy += FixedDiv(dy, dm); + thing->momz += FixedDiv(dz, dm); + } + + if (tmthing->type == MT_FANG && thing->type == MT_FSGNB) + { + if (thing->z > tmthing->z + tmthing->height) + return true; // overhead + if (thing->z + thing->height < tmthing->z) + return true; // underneath + if (!thing->tracer || !thing->tracer->tracer) + return true; + P_SlapStick(tmthing, thing); + // no return value was used in the original prototype script at this point, + // so I'm assuming we fall back on the solid code to determine how it all ends? + // -- Monster Iestyn + } + + // Billiards mines! + if (thing->type == MT_BIGMINE) + { + if (tmthing->type == MT_BIGMINE) + { + if (!tmthing->momx && !tmthing->momy) + return true; + if ((statenum_t)(thing->state-states) >= thing->info->meleestate) + return true; + if (thing->z > tmthing->z + tmthing->height) + return true; // overhead + if (thing->z + thing->height < tmthing->z) + return true; // underneath + + thing->momx = tmthing->momx/3; + thing->momy = tmthing->momy/3; + thing->momz = tmthing->momz/3; + tmthing->momx /= -8; + tmthing->momy /= -8; + tmthing->momz /= -8; + if (thing->info->activesound) + S_StartSound(thing, thing->info->activesound); + P_SetMobjState(thing, thing->info->meleestate); + P_SetTarget(&thing->tracer, tmthing->tracer); + return true; + } + else if (tmthing->type == MT_CRUSHCLAW) + { + if (tmthing->extravalue1 <= 0) + return true; + if ((statenum_t)(thing->state-states) >= thing->info->meleestate) + return true; + if (thing->z > tmthing->z + tmthing->height) + return true; // overhead + if (thing->z + thing->height < tmthing->z) + return true; // underneath + + thing->momx = P_ReturnThrustX(tmthing, tmthing->angle, 2*tmthing->extravalue1*tmthing->scale/3); + thing->momy = P_ReturnThrustY(tmthing, tmthing->angle, 2*tmthing->extravalue1*tmthing->scale/3); + if (thing->info->activesound) + S_StartSound(thing, thing->info->activesound); + P_SetMobjState(thing, thing->info->meleestate); + if (tmthing->tracer) + P_SetTarget(&thing->tracer, tmthing->tracer->target); + return false; + } + } // When solid spikes move, assume they just popped up and teleport things on top of them to hurt. if (tmthing->type == MT_SPIKE && tmthing->flags & MF_SOLID) @@ -503,30 +1157,42 @@ static boolean PIT_CheckThing(mobj_t *thing) else thing->z = tmthing->z + tmthing->height + FixedMul(FRACUNIT, tmthing->scale); if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, tmthing, tmthing, 1); + P_DamageMobj(thing, tmthing, tmthing, 1, 0); return true; } - if (thing->flags & MF_PAIN) + if (thing->flags & MF_PAIN && tmthing->player) { // Player touches painful thing sitting on the floor // see if it went over / under if (thing->z > tmthing->z + tmthing->height) return true; // overhead if (thing->z + thing->height < tmthing->z) return true; // underneath - if (tmthing->player && tmthing->flags & MF_SHOOTABLE && thing->health > 0) - P_DamageMobj(tmthing, thing, thing, 1); + if (tmthing->flags & MF_SHOOTABLE && thing->health > 0) + { + UINT32 damagetype = (thing->info->mass & 0xFF); + if (!damagetype && thing->flags & MF_FIRE) // BURN! + damagetype = DMG_FIRE; + if (P_DamageMobj(tmthing, thing, thing, 1, damagetype) && (damagetype = (thing->info->mass>>8))) + S_StartSound(thing, damagetype); + } return true; } - else if (tmthing->flags & MF_PAIN) + else if (tmthing->flags & MF_PAIN && thing->player) { // Painful thing splats player in the face // see if it went over / under if (tmthing->z > thing->z + thing->height) return true; // overhead if (tmthing->z + tmthing->height < thing->z) return true; // underneath - if (thing->player && thing->flags & MF_SHOOTABLE && tmthing->health > 0) - P_DamageMobj(thing, tmthing, tmthing, 1); + if (thing->flags & MF_SHOOTABLE && tmthing->health > 0) + { + UINT32 damagetype = (tmthing->info->mass & 0xFF); + if (!damagetype && tmthing->flags & MF_FIRE) // BURN! + damagetype = DMG_FIRE; + if (P_DamageMobj(thing, tmthing, tmthing, 1, damagetype) && (damagetype = (tmthing->info->mass>>8))) + S_StartSound(tmthing, damagetype); + } return true; } @@ -572,6 +1238,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (tmz > thzh - sprarea && tmz < thzh) // Don't damage people springing up / down return true; } + // missiles can hit other things if (tmthing->flags & MF_MISSILE || tmthing->type == MT_SHELL) { @@ -621,42 +1288,21 @@ static boolean PIT_CheckThing(mobj_t *thing) if (tmthing->flags & MF_MISSILE && thing->player && tmthing->target && tmthing->target->player && thing->player->ctfteam == tmthing->target->player->ctfteam - && thing->player->pflags & PF_CARRIED && thing->tracer == tmthing->target) + && thing->player->powers[pw_carry] == CR_PLAYER && thing->tracer == tmthing->target) return true; // Don't give rings to your carry player by accident. if (thing->type == MT_EGGSHIELD) { - fixed_t touchx, touchy; - angle_t angle; + angle_t angle = (R_PointToAngle2(thing->x, thing->y, tmthing->x - tmthing->momx, tmthing->y - tmthing->momy) - thing->angle) - ANGLE_90; - if (P_AproxDistance(tmthing->x-thing->x, tmthing->y-thing->y) > - P_AproxDistance((tmthing->x-tmthing->momx)-thing->x, (tmthing->y-tmthing->momy)-thing->y)) - { - touchx = tmthing->x + tmthing->momx; - touchy = tmthing->y + tmthing->momy; - } - else - { - touchx = tmthing->x; - touchy = tmthing->y; - } - - angle = R_PointToAngle2(thing->x, thing->y, touchx, touchy) - thing->angle; - - if (!(angle > ANGLE_90 && angle < ANGLE_270)) // hit front of shield, didn't destroy it - return false; - else // hit shield from behind, shield is destroyed! - { - P_KillMobj(thing, tmthing, tmthing); - return false; - } + if (angle < ANGLE_180) // hit shield from behind, shield is destroyed! + P_KillMobj(thing, tmthing, tmthing, 0); + return false; } - if (tmthing->type == MT_SHELL && tmthing->threshold > TICRATE) - return true; // damage / explode if (tmthing->flags & MF_ENEMY) // An actual ENEMY! (Like the deton, for example) - P_DamageMobj(thing, tmthing, tmthing, 1); + P_DamageMobj(thing, tmthing, tmthing, 1, 0); else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player && (thing->player->pflags & PF_JUMPED) && !thing->player->powers[pw_flashing] @@ -664,8 +1310,8 @@ static boolean PIT_CheckThing(mobj_t *thing) && tmthing->target != thing) { // Hop on the missile for a ride! - thing->player->pflags |= PF_ITEMHANG; - thing->player->pflags &= ~PF_JUMPED; + thing->player->powers[pw_carry] = CR_GENERIC; + thing->player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE); P_SetTarget(&thing->tracer, tmthing); P_SetTarget(&tmthing->target, thing); // Set owner to the player P_SetTarget(&tmthing->tracer, NULL); // Disable homing-ness @@ -673,7 +1319,7 @@ static boolean PIT_CheckThing(mobj_t *thing) thing->angle = tmthing->angle; - if (!demoplayback || P_AnalogMove(thing->player)) + if (!demoplayback || P_ControlStyle(thing->player) == CS_LMAOGALOG) { if (thing->player == &players[consoleplayer]) localangle = thing->angle; @@ -683,7 +1329,7 @@ static boolean PIT_CheckThing(mobj_t *thing) return true; } - else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player && ((thing->player->pflags & PF_ITEMHANG) || (thing->player->pflags & PF_JUMPED))) + else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player && ((thing->player->powers[pw_carry] == CR_GENERIC) || (thing->player->pflags & PF_JUMPED))) { // Ignore } @@ -694,8 +1340,18 @@ static boolean PIT_CheckThing(mobj_t *thing) tmthing->y = thing->y; P_SetThingPosition(tmthing); } - else - P_DamageMobj(thing, tmthing, tmthing->target, 1); + else if (!(tmthing->type == MT_SHELL && thing->player)) // player collision handled in touchspecial for shell + { + UINT8 damagetype = tmthing->info->mass; + if (!damagetype && tmthing->flags & MF_FIRE) // BURN! + damagetype = DMG_FIRE; + P_DamageMobj(thing, tmthing, tmthing->target, 1, damagetype); + } + + // Fireball touched an enemy + // Don't bounce though, just despawn right there + if ((tmthing->type == MT_FIREBALL) && (thing->flags & MF_ENEMY)) + P_KillMobj(tmthing, NULL, NULL, 0); // don't traverse any more @@ -765,24 +1421,37 @@ static boolean PIT_CheckThing(mobj_t *thing) P_SetTarget(&thing->target, tmthing); } - // Respawn rings and items + // NiGHTS lap logic if ((tmthing->type == MT_NIGHTSDRONE || thing->type == MT_NIGHTSDRONE) && (tmthing->player || thing->player)) { mobj_t *droneobj = (tmthing->type == MT_NIGHTSDRONE) ? tmthing : thing; player_t *pl = (droneobj == thing) ? tmthing->player : thing->player; - // Must be in bonus time, and must be NiGHTS, must wait about a second + // Must be NiGHTS, must wait about a second // must be flying in the SAME DIRECTION as the last time you came through. // not (your direction) xor (stored direction) // In other words, you can't u-turn and respawn rings near the drone. - if (pl->bonustime && (pl->pflags & PF_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && ( + if ((pl->powers[pw_carry] == CR_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && ( !(pl->flyangle > 90 && pl->flyangle < 270) ^ (droneobj->extravalue1 > 90 && droneobj->extravalue1 < 270) )) { - // Reload all the fancy ring stuff! - P_ReloadRings(); + pl->marelap++; + pl->totalmarelap++; + pl->lapbegunat = leveltime; + pl->lapstartedtime = pl->nightstime; + + if (pl->bonustime) + { + pl->marebonuslap++; + pl->totalmarebonuslap++; + + // Respawn rings and items + P_ReloadRings(); + } + + P_RunNightsLapExecutors(pl->mo); } droneobj->extravalue1 = pl->flyangle; droneobj->extravalue2 = (INT32)leveltime + TICRATE; @@ -808,24 +1477,77 @@ static boolean PIT_CheckThing(mobj_t *thing) if (tmthing->eflags & MFE_VERTICALFLIP) { if (thing->z + thing->height <= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) - && thing->z + thing->height + thing->momz >= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz) - P_DamageMobj(thing, tmthing, tmthing, 1); + && thing->z + thing->height + thing->momz >= tmthing->z + FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz + && !(thing->player->charability == CA_BOUNCE && thing->player->panim == PA_ABILITY && thing->eflags & MFE_VERTICALFLIP)) + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); } else if (thing->z >= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) - && thing->z + thing->momz <= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz) - P_DamageMobj(thing, tmthing, tmthing, 1); + && thing->z + thing->momz <= tmthing->z + tmthing->height - FixedMul(FRACUNIT, tmthing->scale) + tmthing->momz + && !(thing->player->charability == CA_BOUNCE && thing->player->panim == PA_ABILITY && !(thing->eflags & MFE_VERTICALFLIP))) + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); } else if (thing->type == MT_SPIKE && thing->flags & MF_SOLID && tmthing->player) // unfortunate player falls into spike?! { if (thing->eflags & MFE_VERTICALFLIP) { if (tmthing->z + tmthing->height <= thing->z - FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale)) - P_DamageMobj(tmthing, thing, thing, 1); + && tmthing->z + tmthing->height + tmthing->momz >= thing->z - FixedMul(FRACUNIT, thing->scale) + && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && tmthing->eflags & MFE_VERTICALFLIP)) + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); } else if (tmthing->z >= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) - && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale)) - P_DamageMobj(tmthing, thing, thing, 1); + && tmthing->z + tmthing->momz <= thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) + && !(tmthing->player->charability == CA_BOUNCE && tmthing->player->panim == PA_ABILITY && !(tmthing->eflags & MFE_VERTICALFLIP))) + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } + + if (tmthing->type == MT_WALLSPIKE && tmthing->flags & MF_SOLID && thing->player) // wall spike impales player + { + fixed_t bottomz, topz; + bottomz = tmthing->z; + topz = tmthing->z + tmthing->height; + if (tmthing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, tmthing->scale); + else + topz += FixedMul(FRACUNIT, tmthing->scale); + + if (thing->z + thing->height > bottomz // above bottom + && thing->z < topz) // below top + // don't check angle, the player was clearly in the way in this case + P_DamageMobj(thing, tmthing, tmthing, 1, DMG_SPIKE); + } + else if (thing->type == MT_WALLSPIKE && thing->flags & MF_SOLID && tmthing->player) + { + fixed_t bottomz, topz; + angle_t touchangle = R_PointToAngle2(thing->tracer->x, thing->tracer->y, tmthing->x, tmthing->y); + + if (P_PlayerInPain(tmthing->player) && (tmthing->momx || tmthing->momy)) + { + angle_t playerangle = R_PointToAngle2(0, 0, tmthing->momx, tmthing->momy) - touchangle; + if (playerangle > ANGLE_180) + playerangle = InvAngle(playerangle); + if (playerangle < ANGLE_90) + return true; // Yes, this is intentionally outside the z-height check. No standing on spikes whilst moving away from them. + } + + bottomz = thing->z; + topz = thing->z + thing->height; + + if (thing->eflags & MFE_VERTICALFLIP) + bottomz -= FixedMul(FRACUNIT, thing->scale); + else + topz += FixedMul(FRACUNIT, thing->scale); + + if (tmthing->z + tmthing->height > bottomz // above bottom + && tmthing->z < topz // below top + && !P_MobjWasRemoved(thing->tracer)) // this probably wouldn't work if we didn't have a tracer + { // use base as a reference point to determine what angle you touched the spike at + touchangle = thing->angle - touchangle; + if (touchangle > ANGLE_180) + touchangle = InvAngle(touchangle); + if (touchangle <= ANGLE_22h) // if you touched it at this close an angle, you get poked! + P_DamageMobj(tmthing, thing, thing, 1, DMG_SPIKE); + } } if (thing->flags & MF_PUSHABLE) @@ -837,15 +1559,28 @@ static boolean PIT_CheckThing(mobj_t *thing) if (tmthing->flags & MF_PUSHABLE) { if (thing->type == MT_FAN || thing->type == MT_STEAM) + { P_DoFanAndGasJet(thing, tmthing); + return true; + } else if (thing->flags & MF_SPRING) { if ( thing->z <= tmthing->z + tmthing->height && tmthing->z <= thing->z + thing->height) - iwassprung = P_DoSpring(thing, tmthing); + if (P_DoSpring(thing, tmthing)) + return false; + return true; } } + // thanks to sal for solidenemies dot lua + if (thing->flags & (MF_ENEMY|MF_BOSS) && tmthing->flags & (MF_ENEMY|MF_BOSS)) + { + if ((thing->z + thing->height >= tmthing->z) + && (tmthing->z + tmthing->height >= thing->z)) + return false; + } + // Damage other players when invincible if (tmthing->player && thing->player // Make sure they aren't able to damage you ANYWHERE along the Z axis, you have to be TOUCHING the person. @@ -853,12 +1588,12 @@ static boolean PIT_CheckThing(mobj_t *thing) { if (G_RingSlingerGametype() && (!G_GametypeHasTeams() || tmthing->player->ctfteam != thing->player->ctfteam)) { - if ((tmthing->player->powers[pw_invulnerability] || tmthing->player->powers[pw_super]) + if ((tmthing->player->powers[pw_invulnerability] || tmthing->player->powers[pw_super] || (((tmthing->player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) && (tmthing->player->pflags & PF_SHIELDABILITY))) && !thing->player->powers[pw_super]) - P_DamageMobj(thing, tmthing, tmthing, 1); - else if ((thing->player->powers[pw_invulnerability] || thing->player->powers[pw_super]) + P_DamageMobj(thing, tmthing, tmthing, 1, 0); + else if ((thing->player->powers[pw_invulnerability] || thing->player->powers[pw_super] || (((thing->player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) && (thing->player->pflags & PF_SHIELDABILITY))) && !tmthing->player->powers[pw_super]) - P_DamageMobj(tmthing, thing, thing, 1); + P_DamageMobj(tmthing, thing, thing, 1, 0); } // If players are using touch tag, seekers damage hiders. @@ -866,9 +1601,9 @@ static boolean PIT_CheckThing(mobj_t *thing) ((thing->player->pflags & PF_TAGIT) != (tmthing->player->pflags & PF_TAGIT))) { if ((tmthing->player->pflags & PF_TAGIT) && !(thing->player->pflags & PF_TAGIT)) - P_DamageMobj(thing, tmthing, tmthing, 1); + P_DamageMobj(thing, tmthing, tmthing, 1, 0); else if ((thing->player->pflags & PF_TAGIT) && !(tmthing->player->pflags & PF_TAGIT)) - P_DamageMobj(tmthing, thing, tmthing, 1); + P_DamageMobj(tmthing, thing, tmthing, 1, 0); } } @@ -883,8 +1618,12 @@ static boolean PIT_CheckThing(mobj_t *thing) } else if (thing->player) { if (thing->player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); - thing->player->pflags &= ~PF_CARRIED; + CV_SetValue(&cv_analog[1], true); + if (thing->player->powers[pw_carry] == CR_PLAYER) + { + P_SetTarget(&thing->tracer, NULL); + thing->player->powers[pw_carry] = CR_NONE; + } } if (thing->player) @@ -906,7 +1645,7 @@ static boolean PIT_CheckThing(mobj_t *thing) { // Objects kill you if it falls from above. if (thing != tmthing->target) - P_DamageMobj(thing, tmthing, tmthing->target, 10000); + P_DamageMobj(thing, tmthing, tmthing->target, 1, DMG_CRUSHED); tmthing->momz = -tmthing->momz/2; // Bounce, just for fun! // The tmthing->target allows the pusher of the object @@ -925,44 +1664,60 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->type == MT_FAN || thing->type == MT_STEAM) P_DoFanAndGasJet(thing, tmthing); - else if (thing->flags & MF_SPRING) + else if (thing->flags & MF_SPRING && tmthing->player->powers[pw_carry] != CR_MINECART) { if ( thing->z <= tmthing->z + tmthing->height && tmthing->z <= thing->z + thing->height) - iwassprung = P_DoSpring(thing, tmthing); + if (P_DoSpring(thing, tmthing)) + return false; + return true; } - // Are you touching the side of the object you're interacting with? - else if (thing->z - FixedMul(FRACUNIT, thing->scale) <= tmthing->z + tmthing->height - && thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) >= tmthing->z) + // Monitor? + else if (thing->flags & MF_MONITOR + && !((thing->type == MT_RING_REDBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_RING_BLUEBOX && tmthing->player->ctfteam != 2)) + && (!(thing->flags & MF_SOLID) || P_PlayerCanDamage(tmthing->player, thing))) { - if (thing->flags & MF_MONITOR - && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) + if (thing->z - thing->scale <= tmthing->z + tmthing->height + && thing->z + thing->height + thing->scale >= tmthing->z) { + player_t *player = tmthing->player; + // 0 = none, 1 = elemental pierce, 2 = bubble bounce + UINT8 elementalpierce = (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (player->pflags & PF_SHIELDABILITY) + ? (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) ? 1 : 2) + : 0); SINT8 flipval = P_MobjFlip(thing); // Save this value in case monitor gets removed. fixed_t *momz = &tmthing->momz; // tmthing gets changed by P_DamageMobj, so we need a new pointer?! X_x;; - P_DamageMobj(thing, tmthing, tmthing, 1); // break the monitor + fixed_t *z = &tmthing->z; // aau. // Going down? Then bounce back up. - if ((P_MobjWasRemoved(thing) // Monitor was removed - || !thing->health) // or otherwise popped - && (flipval*(*momz) < 0)) // monitor is on the floor and you're going down, or on the ceiling and you're going up - *momz = -*momz; // Therefore, you should be thrust in the opposite direction, vertically. - return false; + if (P_DamageMobj(thing, tmthing, tmthing, 1, 0) // break the monitor + && (flipval*(*momz) < 0) // monitor is on the floor and you're going down, or on the ceiling and you're going up + && (elementalpierce != 1)) // you're not piercing through the monitor... + { + if (elementalpierce == 2) + P_DoBubbleBounce(player); + else if (!(player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) + { + *momz = -*momz; // Therefore, you should be thrust in the opposite direction, vertically. + if (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY) + P_TwinSpinRejuvenate(player, player->thokitem); + } + } + if (!(elementalpierce == 1 && thing->flags & MF_GRENADEBOUNCE)) // prevent gold monitor clipthrough. + { + if (player->pflags & PF_BOUNCING) + P_DoAbilityBounce(player, false); + return false; + } + else + *z -= *momz; // to ensure proper collision. } + + return true; } } - if (thing->flags & MF_SPRING && (tmthing->player || tmthing->flags & MF_PUSHABLE)) - { - if (iwassprung) // this spring caused you to gain MFE_SPRUNG just now... - return false; // "cancel" P_TryMove via blocking so you keep your current position - } - else if (tmthing->flags & MF_SPRING && (thing->player || thing->flags & MF_PUSHABLE)) - ; // Fix a few nasty spring-jumping bugs that happen sometimes. - // Monitors are not treated as solid to players who are jumping, spinning or gliding, - // unless it's a CTF team monitor and you're on the wrong team - else if (thing->flags & MF_MONITOR && tmthing->player && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING) - && !((thing->type == MT_REDRINGBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_BLUERINGBOX && tmthing->player->ctfteam != 2))) - ; + if ((tmthing->flags & MF_SPRING || tmthing->type == MT_STEAM || tmthing->type == MT_SPIKE || tmthing->type == MT_WALLSPIKE) && (thing->player)) + ; // springs, gas jets and springs should never be able to step up onto a player // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID @@ -980,6 +1735,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z + thing->height > tmfloorz) { tmfloorz = thing->z + thing->height; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -989,16 +1745,18 @@ static boolean PIT_CheckThing(mobj_t *thing) topz = thing->z - thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways - if (thing->flags & MF_SPRING) - ; // block only when jumping not high enough, // (dont climb max. 24units while already in air) // since return false doesn't handle momentum properly, // we lie to P_TryMove() so it's always too high - else if (tmthing->player && tmthing->z + tmthing->height > topz + if (tmthing->player && tmthing->z + tmthing->height > topz && tmthing->z + tmthing->height < tmthing->ceilingz) { + if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... + return false; + tmfloorz = tmceilingz = topz; // block while in air + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1007,6 +1765,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz < tmceilingz && tmthing->z <= thing->z+thing->height) { tmceilingz = topz; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1023,6 +1782,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing->z < tmceilingz) { tmceilingz = thing->z; + tmceilingrover = NULL; #ifdef ESLOPE tmceilingslope = NULL; #endif @@ -1032,16 +1792,18 @@ static boolean PIT_CheckThing(mobj_t *thing) topz = thing->z + thing->height + thing->scale; // FixedMul(FRACUNIT, thing->scale), but thing->scale == FRACUNIT in base scale anyways - if (thing->flags & MF_SPRING) - ; // block only when jumping not high enough, // (dont climb max. 24units while already in air) // since return false doesn't handle momentum properly, // we lie to P_TryMove() so it's always too high - else if (tmthing->player && tmthing->z < topz + if (tmthing->player && tmthing->z < topz && tmthing->z > tmthing->floorz) { + if (thing->flags & MF_GRENADEBOUNCE && (thing->flags & MF_MONITOR || thing->info->flags & MF_MONITOR)) // Gold monitor hack... + return false; + tmfloorz = tmceilingz = topz; // block while in air + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1050,6 +1812,7 @@ static boolean PIT_CheckThing(mobj_t *thing) else if (topz > tmfloorz && tmthing->z+tmthing->height >= thing->z) { tmfloorz = topz; + tmfloorrover = NULL; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1138,6 +1901,32 @@ static boolean PIT_CheckLine(line_t *ld) if (P_BoxOnLineSide(tmbbox, ld) != -1) return true; + if (tmthing->flags & MF_PAPERCOLLISION) // Caution! Turning whilst up against a wall will get you stuck. You probably shouldn't give the player this flag. + { + fixed_t cosradius, sinradius; + cosradius = FixedMul(tmthing->radius, FINECOSINE(tmthing->angle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(tmthing->radius, FINESINE(tmthing->angle>>ANGLETOFINESHIFT)); + if (P_PointOnLineSide(tmx - cosradius, tmy - sinradius, ld) + == P_PointOnLineSide(tmx + cosradius, tmy + sinradius, ld)) + return true; // the line doesn't cross between collider's start or end +#ifdef PAPER_COLLISIONCORRECTION + { + fixed_t dist; + vertex_t result; + angle_t langle; + P_ClosestPointOnLine(tmx, tmy, ld, &result); + langle = R_PointToAngle2(ld->v1->x, ld->v1->y, ld->v2->x, ld->v2->y); + langle += ANGLE_90*(P_PointOnLineSide(tmx, tmy, ld) ? -1 : 1); + dist = abs(FixedMul(tmthing->radius, FINECOSINE((tmthing->angle - langle)>>ANGLETOFINESHIFT))); + cosradius = FixedMul(dist, FINECOSINE(langle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(dist, FINESINE(langle>>ANGLETOFINESHIFT)); + tmthing->flags |= MF_NOCLIP; + P_TeleportMove(tmthing, result.x + cosradius - tmthing->momx, result.y + sinradius - tmthing->momy, tmthing->z); + tmthing->flags &= ~MF_NOCLIP; + } +#endif + } + // A line has been hit // The moving thing's destination position will cross @@ -1151,6 +1940,17 @@ static boolean PIT_CheckLine(line_t *ld) // this line is out of the if so upper and lower textures can be hit by a splat blockingline = ld; + + { + UINT8 shouldCollide = LUAh_MobjLineCollide(tmthing, blockingline); // checks hook for thing's type + if (P_MobjWasRemoved(tmthing)) + return true; // one of them was removed??? + if (shouldCollide == 1) + return false; // force collide + else if (shouldCollide == 2) + return true; // force no collide + } + if (!ld->backsector) // one sided line { if (P_PointOnLineSide(tmthing->x, tmthing->y, ld)) @@ -1175,6 +1975,7 @@ static boolean PIT_CheckLine(line_t *ld) { tmceilingz = opentop; ceilingline = ld; + tmceilingrover = openceilingrover; #ifdef ESLOPE tmceilingslope = opentopslope; #endif @@ -1183,6 +1984,7 @@ static boolean PIT_CheckLine(line_t *ld) if (openbottom > tmfloorz) { tmfloorz = openbottom; + tmfloorrover = openfloorrover; #ifdef ESLOPE tmfloorslope = openbottomslope; #endif @@ -1264,6 +2066,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) // will adjust them. tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight; tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; + tmfloorrover = NULL; + tmceilingrover = NULL; #ifdef ESLOPE tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -1307,6 +2111,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < topheight - sinklevel) { tmfloorz = topheight - sinklevel; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1316,6 +2121,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmceilingz > bottomheight + sinklevel) { tmceilingz = bottomheight + sinklevel; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -1325,12 +2131,12 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) continue; } - if (thing->player && (P_CheckSolidLava(thing, rover) || P_CanRunOnWater(thing->player, rover))) + if (thing->player && (P_CheckSolidLava(rover) || P_CanRunOnWater(thing->player, rover))) ; else if (thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE)) ; else if (!((rover->flags & FF_BLOCKPLAYER && thing->player) - || (rover->flags & FF_BLOCKOTHERS && !thing->player) + || (rover->flags & FF_BLOCKOTHERS && !thing->player) || rover->flags & FF_QUICKSAND)) continue; @@ -1340,6 +2146,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) { if (tmfloorz < thing->z) { tmfloorz = thing->z; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = NULL; #endif @@ -1358,6 +2165,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(rover->flags & FF_REVERSEPLATFORM)) { tmfloorz = tmdropoffz = topheight; + tmfloorrover = rover; #ifdef ESLOPE tmfloorslope = *rover->t_slope; #endif @@ -1367,6 +2175,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) && !(thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE))) { tmceilingz = tmdrpoffceilz = bottomheight; + tmceilingrover = rover; #ifdef ESLOPE tmceilingslope = *rover->b_slope; #endif @@ -1447,6 +2256,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) #ifdef ESLOPE tmfloorslope = NULL; #endif + tmfloorrover = NULL; } if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) { @@ -1454,6 +2264,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) #ifdef ESLOPE tmceilingslope = NULL; #endif + tmceilingrover = NULL; } } plink = (polymaplink_t *)(plink->link.next); @@ -1851,6 +2662,8 @@ boolean PIT_PushableMoved(mobj_t *thing) mobj_t *oldthing = tmthing; line_t *oldceilline = ceilingline; line_t *oldblockline = blockingline; + ffloor_t *oldflrrover = tmfloorrover; + ffloor_t *oldceilrover = tmceilingrover; #ifdef ESLOPE pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; @@ -1867,6 +2680,8 @@ boolean PIT_PushableMoved(mobj_t *thing) P_SetTarget(&tmthing, oldthing); ceilingline = oldceilline; blockingline = oldblockline; + tmfloorrover = oldflrrover; + tmceilingrover = oldceilrover; #ifdef ESLOPE tmfloorslope = oldfslope; tmceilingslope = oldcslope; @@ -1936,7 +2751,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // Don't 'step up' while springing, // Only step up "if needed". - if (thing->state == &states[S_PLAY_SPRING] + if (thing->player->panim == PA_SPRING && P_MobjFlip(thing)*thing->momz > FixedMul(FRACUNIT, thing->scale)) maxstep = 0; } @@ -1977,13 +2792,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thingtop == thing->ceilingz && tmceilingz > thingtop && tmceilingz - thingtop <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE - // HACK TO FIX DSZ2: apply only if slopes are involved - else if (tmceilingslope && tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) + else if (tmceilingz < thingtop && thingtop - tmceilingz <= maxstep) { thing->z = (thing->ceilingz = thingtop = tmceilingz) - thing->height; + thing->ceilingrover = tmceilingrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -1991,13 +2807,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (thing->z == thing->floorz && tmfloorz < thing->z && thing->z - tmfloorz <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #ifdef ESLOPE - // HACK TO FIX DSZ2: apply only if slopes are involved - else if (tmfloorslope && tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) + else if (tmfloorz > thing->z && tmfloorz - thing->z <= maxstep) { thing->z = thing->floorz = tmfloorz; + thing->floorrover = tmfloorrover; thing->eflags |= MFE_JUSTSTEPPEDDOWN; } #endif @@ -2061,6 +2878,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; #ifdef ESLOPE if (!(thing->flags & MF_NOCLIPHEIGHT)) @@ -2141,6 +2960,8 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; thing->x = x; thing->y = y; @@ -2166,8 +2987,11 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) static boolean P_ThingHeightClip(mobj_t *thing) { boolean floormoved; - fixed_t oldfloorz = thing->floorz; + fixed_t oldfloorz = thing->floorz, oldz = thing->z; + ffloor_t *oldfloorrover = thing->floorrover; + ffloor_t *oldceilingrover = thing->ceilingrover; boolean onfloor = P_IsObjectOnGround(thing);//(thing->z <= thing->floorz); + ffloor_t *rover = NULL; if (thing->flags & MF_NOCLIPHEIGHT) return true; @@ -2182,6 +3006,8 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; + thing->floorrover = tmfloorrover; + thing->ceilingrover = tmceilingrover; // Ugly hack?!?! As long as just ceilingz is the lowest, // you'll still get crushed, right? @@ -2190,16 +3016,23 @@ static boolean P_ThingHeightClip(mobj_t *thing) if (onfloor && !(thing->flags & MF_NOGRAVITY) && floormoved) { - if (thing->eflags & MFE_VERTICALFLIP) - thing->pmomz = thing->ceilingz - (thing->z + thing->height); - else - thing->pmomz = thing->floorz - thing->z; - thing->eflags |= MFE_APPLYPMOMZ; + rover = (thing->eflags & MFE_VERTICALFLIP) ? oldceilingrover : oldfloorrover; - if (thing->eflags & MFE_VERTICALFLIP) - thing->z = thing->ceilingz - thing->height; - else - thing->z = thing->floorz; + // Match the Thing's old floorz to an FOF and check for FF_EXISTS + // If ~FF_EXISTS, don't set mobj Z. + if (!rover || ((rover->flags & FF_EXISTS) && (rover->flags & FF_SOLID))) + { + if (thing->eflags & MFE_VERTICALFLIP) + thing->pmomz = thing->ceilingz - (thing->z + thing->height); + else + thing->pmomz = thing->floorz - thing->z; + thing->eflags |= MFE_APPLYPMOMZ; + + if (thing->eflags & MFE_VERTICALFLIP) + thing->z = thing->ceilingz - thing->height; + else + thing->z = thing->floorz; + } } else if (!tmfloorthing) { @@ -2213,6 +3046,9 @@ static boolean P_ThingHeightClip(mobj_t *thing) thing->z = thing->ceilingz - thing->height; } + if (P_MobjFlip(thing)*(thing->z - oldz) > 0 && thing->player) + P_PlayerHitFloor(thing->player, !onfloor); + // debug: be sure it falls to the floor thing->eflags &= ~MFE_ONGROUND; @@ -2525,7 +3361,7 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle) && glidesector->sector->ceilingpic == skyflatnum) return false; - if ((player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale) < ceilingz) + if ((player->mo->z + FixedMul(16*FRACUNIT,player->mo->scale) < floorz) || (player->mo->z >= ceilingz)) floorclimb = true; } @@ -2643,7 +3479,7 @@ isblocking: } // see about climbing on the wall - if (!(checkline->flags & ML_NOCLIMB)) + if (!(checkline->flags & ML_NOCLIMB) && checkline->special != HORIZONSPECIAL) { boolean canclimb; angle_t climbangle, climbline; @@ -2663,13 +3499,13 @@ isblocking: && canclimb) { slidemo->angle = climbangle; - if (!demoplayback || P_AnalogMove(slidemo->player)) + /*if (!demoplayback || P_ControlStyle(slidemo->player) == CS_LMAOGALOG) { if (slidemo->player == &players[consoleplayer]) localangle = slidemo->angle; else if (slidemo->player == &players[secondarydisplayplayer]) localangle2 = slidemo->angle; - } + }*/ if (!slidemo->player->climbing) { @@ -2677,7 +3513,7 @@ isblocking: slidemo->player->climbing = 5; } - slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_THOKKED); + slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED); slidemo->player->glidetime = 0; slidemo->player->secondjump = 0; @@ -2808,6 +3644,64 @@ stairstep: goto retry; } +static void P_CheckLavaWall(mobj_t *mo, sector_t *sec) +{ + ffloor_t *rover; + fixed_t topheight, bottomheight; + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (!(rover->flags & FF_SWIMMABLE)) + continue; + + if (GETSECSPECIAL(rover->master->frontsector->special, 1) != 3) + continue; + + if (rover->master->flags & ML_BLOCKMONSTERS) + continue; + + topheight = +#ifdef ESLOPE + *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : +#endif + *rover->topheight; + + if (mo->eflags & MFE_VERTICALFLIP) + { + if (topheight < mo->z - mo->height) + continue; + } + else + { + if (topheight < mo->z) + continue; + } + + bottomheight = +#ifdef ESLOPE + *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : +#endif + *rover->bottomheight; + + if (mo->eflags & MFE_VERTICALFLIP) + { + if (bottomheight > mo->z) + continue; + } + else + { + if (bottomheight > mo->z + mo->height) + continue; + } + + P_DamageMobj(mo, NULL, NULL, 1, DMG_FIRE); + return; + } +} + // // P_SlideMove // The momx / momy move is bad, so try to slide @@ -2823,12 +3717,113 @@ void P_SlideMove(mobj_t *mo) INT16 hitcount = 0; boolean success = false; + boolean papercol = false; + vertex_t v1, v2; // fake vertexes + line_t junk; // fake linedef + if (tmhitthing && mo->z + mo->height > tmhitthing->z && mo->z < tmhitthing->z + tmhitthing->height) { // Don't mess with your momentum if it's a pushable object. Pushables do their own crazy things already. if (tmhitthing->flags & MF_PUSHABLE) return; + if (tmhitthing->flags & MF_PAPERCOLLISION) + { + fixed_t cosradius, sinradius, num, den; + + // trace along the three leading corners + if (mo->momx > 0) + { + leadx = mo->x + mo->radius; + trailx = mo->x - mo->radius; + } + else + { + leadx = mo->x - mo->radius; + trailx = mo->x + mo->radius; + } + + if (mo->momy > 0) + { + leady = mo->y + mo->radius; + traily = mo->y - mo->radius; + } + else + { + leady = mo->y - mo->radius; + traily = mo->y + mo->radius; + } + + papercol = true; + slidemo = mo; + bestslideline = &junk; + + cosradius = FixedMul(tmhitthing->radius, FINECOSINE(tmhitthing->angle>>ANGLETOFINESHIFT)); + sinradius = FixedMul(tmhitthing->radius, FINESINE(tmhitthing->angle>>ANGLETOFINESHIFT)); + + v1.x = tmhitthing->x - cosradius; + v1.y = tmhitthing->y - sinradius; + v2.x = tmhitthing->x + cosradius; + v2.y = tmhitthing->y + sinradius; + + // Can we box collision our way into smooth movement..? + if (sinradius && mo->y + mo->radius <= min(v1.y, v2.y)) + { + mo->momy = 0; + P_TryMove(mo, mo->x + mo->momx, min(v1.y, v2.y) - mo->radius, true); + return; + } + else if (sinradius && mo->y - mo->radius >= max(v1.y, v2.y)) + { + mo->momy = 0; + P_TryMove(mo, mo->x + mo->momx, max(v1.y, v2.y) + mo->radius, true); + return; + } + else if (cosradius && mo->x + mo->radius <= min(v1.x, v2.x)) + { + mo->momx = 0; + P_TryMove(mo, min(v1.x, v2.x) - mo->radius, mo->y + mo->momy, true); + return; + } + else if (cosradius && mo->x - mo->radius >= max(v1.x, v2.x)) + { + mo->momx = 0; + P_TryMove(mo, max(v1.x, v2.x) + mo->radius, mo->y + mo->momy, true); + return; + } + + // nope, gotta fuck around with a fake linedef! + junk.v1 = &v1; + junk.v2 = &v2; + junk.dx = 2*cosradius; // v2.x - v1.x; + junk.dy = 2*sinradius; // v2.y - v1.y; + + junk.slopetype = !cosradius ? ST_VERTICAL : !sinradius ? ST_HORIZONTAL : + ((sinradius > 0) == (cosradius > 0)) ? ST_POSITIVE : ST_NEGATIVE; + + bestslidefrac = FRACUNIT+1; + + den = FixedMul(junk.dy>>8, mo->momx) - FixedMul(junk.dx>>8, mo->momy); + + if (!den) + bestslidefrac = 0; + else + { + fixed_t frac; +#define P_PaperTraverse(startx, starty) \ + num = FixedMul((v1.x - leadx)>>8, junk.dy) + FixedMul((leady - v1.y)>>8, junk.dx); \ + frac = FixedDiv(num, den); \ + if (frac < bestslidefrac) \ + bestslidefrac = frac + P_PaperTraverse(leadx, leady); + P_PaperTraverse(trailx, leady); + P_PaperTraverse(leadx, traily); +#undef dowork + } + + goto papercollision; + } + // Thankfully box collisions are a lot simpler than arbitrary lines. There's only four possible cases. if (mo->y + mo->radius <= tmhitthing->y - tmhitthing->radius) { @@ -2859,7 +3854,7 @@ void P_SlideMove(mobj_t *mo) bestslideline = NULL; retry: - if (++hitcount == 3) + if ((++hitcount == 3) || papercol) goto stairstep; // don't loop forever // trace along the three leading corners @@ -2894,6 +3889,12 @@ retry: P_PathTraverse(leadx, traily, leadx + mo->momx, traily + mo->momy, PT_ADDLINES, PTR_SlideTraverse); + if (bestslideline && mo->player && bestslideline->sidenum[1] != 0xffff) + { + sector_t *sec = P_PointOnLineSide(mo->x, mo->y, bestslideline) ? bestslideline->frontsector : bestslideline->backsector; + P_CheckLavaWall(mo, sec); + } + // Some walls are bouncy even if you're not if (bestslideline && bestslideline->flags & ML_BOUNCY) { @@ -2901,6 +3902,7 @@ retry: return; } +papercollision: // move up to the wall if (bestslidefrac == FRACUNIT+1) { @@ -3128,6 +4130,7 @@ bounceback: static fixed_t bombdamage; static mobj_t *bombsource; static mobj_t *bombspot; +static UINT8 bombdamagetype; // // PIT_RadiusAttack @@ -3138,17 +4141,13 @@ static boolean PIT_RadiusAttack(mobj_t *thing) { fixed_t dx, dy, dz, dist; - if (thing == bombspot // ignore the bomb itself (Deton fix) - || (bombsource && thing->type == bombsource->type)) // ignore the type of guys who dropped the bomb (Jetty-Syn Bomber or Skim can bomb eachother, but not themselves.) + if (thing == bombspot) // ignore the bomb itself (Deton fix) return true; - if (!(thing->flags & MF_SHOOTABLE)) + if ((thing->flags & (MF_MONITOR|MF_SHOOTABLE)) != MF_SHOOTABLE) return true; - if (thing->flags & MF_BOSS) - return true; - - if (thing->flags & MF_MONITOR) + if (bombsource && thing->type == bombsource->type && !(bombdamagetype & DMG_CANHURTSELF)) // ignore the type of guys who dropped the bomb (Jetty-Syn Bomber or Skim can bomb eachother, but not themselves.) return true; dx = abs(thing->x - bombspot->x); @@ -3172,7 +4171,7 @@ static boolean PIT_RadiusAttack(mobj_t *thing) if (P_CheckSight(thing, bombspot)) { // must be in direct path - P_DamageMobj(thing, bombspot, bombsource, 1); // Tails 01-11-2001 + P_DamageMobj(thing, bombspot, bombsource, 1, bombdamagetype); // Tails 01-11-2001 } return true; @@ -3182,7 +4181,7 @@ static boolean PIT_RadiusAttack(mobj_t *thing) // P_RadiusAttack // Source is the creature that caused the explosion at spot. // -void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist) +void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist, UINT8 damagetype) { INT32 x, y; INT32 xl, xh, yl, yh; @@ -3199,6 +4198,7 @@ void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist) bombspot = spot; bombsource = source; bombdamage = FixedMul(damagedist, spot->scale); + bombdamagetype = damagetype; for (y = yl; y <= yh; y++) for (x = xl; x <= xh; x++) @@ -3227,6 +4227,8 @@ static boolean nofit; static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) { mobj_t *killer = NULL; + //If a thing is both pushable and vulnerable, it doesn't block the crusher because it gets killed. + boolean immunepushable = ((thing->flags & (MF_PUSHABLE | MF_SHOOTABLE)) == MF_PUSHABLE); if (P_ThingHeightClip(thing)) { @@ -3245,7 +4247,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) // just be blocked by another object - check if it's really a ceiling! if (thing->z + thing->height > thing->ceilingz && thing->z <= thing->ceilingz) { - if (thing->flags & MF_PUSHABLE && thing->z + thing->height > thing->subsector->sector->ceilingheight) + if (immunepushable && thing->z + thing->height > thing->subsector->sector->ceilingheight) { //Thing is a pushable and blocks the moving ceiling nofit = true; @@ -3253,7 +4255,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) } //Check FOFs in the sector - if (thing->subsector->sector->ffloors && (realcrush || thing->flags & MF_PUSHABLE)) + if (thing->subsector->sector->ffloors && (realcrush || immunepushable)) { ffloor_t *rover; fixed_t topheight, bottomheight; @@ -3280,7 +4282,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) delta2 = thingtop - (bottomheight + topheight)/2; if (bottomheight <= thing->ceilingz && abs(delta1) >= abs(delta2)) { - if (thing->flags & MF_PUSHABLE) + if (immunepushable) { //FOF is blocked by pushable nofit = true; @@ -3292,7 +4294,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) thinker_t *think; elevator_t *crumbler; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MAIN].next; think != &thlist[THINK_MAIN]; think = think->next) { if (think->function.acp1 != (actionf_p1)T_StartCrumble) continue; @@ -3318,22 +4320,15 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) { // Crush the object if (netgame && thing->player && thing->player->spectator) - P_DamageMobj(thing, NULL, NULL, 42000); // Respawn crushed spectators + P_DamageMobj(thing, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators else - { - if (!killer) - { - //Nobody is responsible for crushing the object, so give a generic crush message - killer = P_SpawnMobj(thing->x, thing->y, thing->z, MT_NULL); - killer->threshold = 44; // Special flag for crushing - } - P_DamageMobj(thing, killer, killer, 10000); - } + P_DamageMobj(thing, killer, killer, 1, DMG_CRUSHED); + return true; } } if (realcrush && crushchange) - P_DamageMobj(thing, NULL, NULL, 1); + P_DamageMobj(thing, NULL, NULL, 1, 0); // keep checking (crush other things) return true; @@ -3345,6 +4340,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) boolean P_CheckSector(sector_t *sector, boolean crunch) { msecnode_t *n; + size_t i; nofit = false; crushchange = crunch; @@ -3359,9 +4355,57 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) // First, let's see if anything will keep it from crushing. + + // Sal: This stupid function chain is required to fix polyobjects not being able to crush. + // Monster Iestyn: don't use P_CheckSector actually just look for objects in the blockmap instead + validcount++; + + for (i = 0; i < sector->linecount; i++) + { + if (sector->lines[i]->polyobj) + { + polyobj_t *po = sector->lines[i]->polyobj; + if (po->validcount == validcount) + continue; // skip if already checked + if (!(po->flags & POF_SOLID)) + continue; + if (po->lines[0]->backsector == sector) // Make sure you're currently checking the control sector + { + INT32 x, y; + po->validcount = validcount; + + for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y) + { + for (x = po->blockbox[BOXLEFT]; x <= po->blockbox[BOXRIGHT]; ++x) + { + mobj_t *mo; + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) + continue; + + mo = blocklinks[y * bmapwidth + x]; + + for (; mo; mo = mo->bnext) + { + // Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect + + if (!P_MobjInsidePolyobj(po, mo)) + continue; + + if (!PIT_ChangeSector(mo, false)) + { + nofit = true; + return nofit; + } + } + } + } + } + } + } + if (sector->numattached) { - size_t i; sector_t *sec; for (i = 0; i < sector->numattached; i++) { @@ -3421,9 +4465,53 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) } while (n); // repeat from scratch until all things left are marked valid // Nothing blocked us, so lets crush for real! + + // Sal: This stupid function chain is required to fix polyobjects not being able to crush. + // Monster Iestyn: don't use P_CheckSector actually just look for objects in the blockmap instead + validcount++; + + for (i = 0; i < sector->linecount; i++) + { + if (sector->lines[i]->polyobj) + { + polyobj_t *po = sector->lines[i]->polyobj; + if (po->validcount == validcount) + continue; // skip if already checked + if (!(po->flags & POF_SOLID)) + continue; + if (po->lines[0]->backsector == sector) // Make sure you're currently checking the control sector + { + INT32 x, y; + po->validcount = validcount; + + for (y = po->blockbox[BOXBOTTOM]; y <= po->blockbox[BOXTOP]; ++y) + { + for (x = po->blockbox[BOXLEFT]; x <= po->blockbox[BOXRIGHT]; ++x) + { + mobj_t *mo; + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) + continue; + + mo = blocklinks[y * bmapwidth + x]; + + for (; mo; mo = mo->bnext) + { + // Monster Iestyn: do we need to check if a mobj has already been checked? ...probably not I suspect + + if (!P_MobjInsidePolyobj(po, mo)) + continue; + + PIT_ChangeSector(mo, true); + return nofit; + } + } + } + } + } + } if (sector->numattached) { - size_t i; sector_t *sec; for (i = 0; i < sector->numattached; i++) { diff --git a/src/p_maputl.c b/src/p_maputl.c index 1be57399c..69be5a70f 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -78,68 +78,37 @@ void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result) return; } -// -// P_ClosestPointOnLine3D -// Finds the closest point on a given line to the supplied point IN 3D!!! -// -void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result) +/// Similar to FV3_ClosestPointOnLine() except it actually works. +void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *Line, vector3_t *result) { - fixed_t startx = line->v1->x; - fixed_t starty = line->v1->y; - fixed_t startz = line->v1->z; - fixed_t dx = line->dx; - fixed_t dy = line->dy; - fixed_t dz = line->v2->z - line->v1->z; + const vector3_t* v1 = &Line[0]; + const vector3_t* v2 = &Line[1]; + vector3_t c, V, n; + fixed_t t, d; + FV3_SubEx(v2, v1, &V); + FV3_SubEx(p, v1, &c); - // Determine t (the length of the vector from �Line[0]� to �p�) - fixed_t cx, cy, cz; - fixed_t vx, vy, vz; - fixed_t magnitude; - fixed_t t; + d = R_PointToDist2(0, v2->z, R_PointToDist2(v2->x, v2->y, v1->x, v1->y), v1->z); + FV3_Copy(&n, &V); + FV3_Divide(&n, d); - //Sub (p, &Line[0], &c); - cx = x - startx; - cy = y - starty; - cz = z - startz; - - //Sub (&Line[1], &Line[0], &V); - vx = dx; - vy = dy; - vz = dz; - - //Normalize (&V, &V); - magnitude = R_PointToDist2(0, line->v2->z, R_PointToDist2(line->v2->x, line->v2->y, startx, starty), startz); - vx = FixedDiv(vx, magnitude); - vy = FixedDiv(vy, magnitude); - vz = FixedDiv(vz, magnitude); - - t = (FixedMul(vx, cx) + FixedMul(vy, cy) + FixedMul(vz, cz)); + t = FV3_Dot(&n, &c); // Set closest point to the end if it extends past -Red if (t <= 0) { - result->x = line->v1->x; - result->y = line->v1->y; - result->z = line->v1->z; + FV3_Copy(result, v1); return; } - else if (t >= magnitude) + else if (t >= d) { - result->x = line->v2->x; - result->y = line->v2->y; - result->z = line->v2->z; + FV3_Copy(result, v2); return; } - // Return the point between �Line[0]� and �Line[1]� - vx = FixedMul(vx, t); - vy = FixedMul(vy, t); - vz = FixedMul(vz, t); + FV3_Mul(&n, t); - //Add (&Line[0], &V, out); - result->x = startx + vx; - result->y = starty + vy; - result->z = startz + vz; + FV3_AddEx(v1, &n, result); return; } @@ -311,6 +280,7 @@ fixed_t opentop, openbottom, openrange, lowfloor, highceiling; #ifdef ESLOPE pslope_t *opentopslope, *openbottomslope; #endif +ffloor_t *openfloorrover, *openceilingrover; // P_CameraLineOpening // P_LineOpening, but for camera @@ -418,10 +388,6 @@ void P_CameraLineOpening(line_t *linedef) if (front->ffloors || back->ffloors) { ffloor_t *rover; - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; fixed_t delta1, delta2; // Check for frontsector's fake floors @@ -437,15 +403,15 @@ void P_CameraLineOpening(line_t *linedef) delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; + if (bottomheight < opentop && delta1 >= delta2) + opentop = bottomheight; + else if (bottomheight < highceiling && delta1 >= delta2) + highceiling = bottomheight; - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; + if (topheight > openbottom && delta1 < delta2) + openbottom = topheight; + else if (topheight > lowfloor && delta1 < delta2) + lowfloor = topheight; } // Check for backsectors fake floors @@ -461,28 +427,16 @@ void P_CameraLineOpening(line_t *linedef) delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; + if (bottomheight < opentop && delta1 >= delta2) + opentop = bottomheight; + else if (bottomheight < highceiling && delta1 >= delta2) + highceiling = bottomheight; - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; + if (topheight > openbottom && delta1 < delta2) + openbottom = topheight; + else if (topheight > lowfloor && delta1 < delta2) + lowfloor = topheight; } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) - openbottom = highestfloor; - - if (lowestceiling < opentop) - opentop = lowestceiling; - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; } openrange = opentop - openbottom; return; @@ -500,23 +454,27 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) return; } - // Treat polyobjects kind of like 3D Floors -#ifdef POLYOBJECTS - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) - { - front = linedef->frontsector; - back = linedef->frontsector; - } - else -#endif - { - front = linedef->frontsector; - back = linedef->backsector; - } + front = linedef->frontsector; + back = linedef->backsector; I_Assert(front != NULL); I_Assert(back != NULL); + openfloorrover = openceilingrover = NULL; +#ifdef POLYOBJECTS + if (linedef->polyobj) + { + // set these defaults so that polyobjects don't interfere with collision above or below them + opentop = INT32_MAX; + openbottom = INT32_MIN; + highceiling = INT32_MIN; + lowfloor = INT32_MAX; +#ifdef ESLOPE + opentopslope = openbottomslope = NULL; +#endif + } + else +#endif { // Set open and high/low values here fixed_t frontheight, backheight; @@ -622,25 +580,49 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } } } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors #ifdef POLYOBJECTS - || linedef->polyobj + if (linedef->polyobj) + { + // Treat polyobj's backsector like a 3D Floor + if (linedef->polyobj->flags & POF_TESTHEIGHT) + { + const sector_t *polysec = linedef->backsector; + fixed_t polytop, polybottom; + fixed_t delta1, delta2; + + if (linedef->polyobj->flags & POF_CLIPPLANES) + { + polytop = polysec->ceilingheight; + polybottom = polysec->floorheight; + } + else + { + polytop = INT32_MAX; + polybottom = INT32_MIN; + } + + delta1 = abs(mobj->z - (polybottom + ((polytop - polybottom)/2))); + delta2 = abs(thingtop - (polybottom + ((polytop - polybottom)/2))); + + if (polybottom < opentop && delta1 >= delta2) + opentop = polybottom; + else if (polybottom < highceiling && delta1 >= delta2) + highceiling = polybottom; + + if (polytop > openbottom && delta1 < delta2) + openbottom = polytop; + else if (polytop > lowfloor && delta1 < delta2) + lowfloor = polytop; + } + // otherwise don't do anything special, pretend there's nothing else there + } + else #endif - ) + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) { ffloor_t *rover; - - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; fixed_t delta1, delta2; -#ifdef ESLOPE - pslope_t *ceilingslope = opentopslope; - pslope_t *floorslope = openbottomslope; -#endif // Check for frontsector's fake floors for (rover = front->ffloors; rover; rover = rover->next) @@ -649,7 +631,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (!(rover->flags & FF_EXISTS)) continue; - if (mobj->player && (P_CheckSolidLava(mobj, rover) || P_CanRunOnWater(mobj->player, rover))) + if (mobj->player && (P_CheckSolidLava(rover) || P_CanRunOnWater(mobj->player, rover))) ; else if (!((rover->flags & FF_BLOCKPLAYER && mobj->player) || (rover->flags & FF_BLOCKOTHERS && !mobj->player))) @@ -661,28 +643,30 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF + if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < lowestceiling) { - lowestceiling = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; #ifdef ESLOPE - ceilingslope = *rover->b_slope; + opentopslope = *rover->b_slope; #endif + openceilingrover = rover; } - else if (bottomheight < highestceiling) - highestceiling = bottomheight; + else if (bottomheight < highceiling) + highceiling = bottomheight; } - if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF + if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > highestfloor) { - highestfloor = topheight; + if (topheight > openbottom) { + openbottom = topheight; #ifdef ESLOPE - floorslope = *rover->t_slope; + openbottomslope = *rover->t_slope; #endif + openfloorrover = rover; } - else if (topheight > lowestfloor) - lowestfloor = topheight; + else if (topheight > lowfloor) + lowfloor = topheight; } } @@ -693,7 +677,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (!(rover->flags & FF_EXISTS)) continue; - if (mobj->player && (P_CheckSolidLava(mobj, rover) || P_CanRunOnWater(mobj->player, rover))) + if (mobj->player && (P_CheckSolidLava(rover) || P_CanRunOnWater(mobj->player, rover))) ; else if (!((rover->flags & FF_BLOCKPLAYER && mobj->player) || (rover->flags & FF_BLOCKOTHERS && !mobj->player))) @@ -705,77 +689,32 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (bottomheight + ((topheight - bottomheight)/2))); delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF + if (delta1 >= delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_PLATFORM) // thing is below FOF { - if (bottomheight < lowestceiling) { - lowestceiling = bottomheight; + if (bottomheight < opentop) { + opentop = bottomheight; #ifdef ESLOPE - ceilingslope = *rover->b_slope; + opentopslope = *rover->b_slope; #endif + openceilingrover = rover; } - else if (bottomheight < highestceiling) - highestceiling = bottomheight; + else if (bottomheight < highceiling) + highceiling = bottomheight; } - if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF + if (delta1 < delta2 && (rover->flags & FF_INTANGIBLEFLATS) != FF_REVERSEPLATFORM) // thing is above FOF { - if (topheight > highestfloor) { - highestfloor = topheight; + if (topheight > openbottom) { + openbottom = topheight; #ifdef ESLOPE - floorslope = *rover->t_slope; + openbottomslope = *rover->t_slope; #endif + openfloorrover = rover; } - else if (topheight > lowestfloor) - lowestfloor = topheight; + else if (topheight > lowfloor) + lowfloor = topheight; } } - -#ifdef POLYOBJECTS - // Treat polyobj's backsector like a 3D Floor - if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) - { - const sector_t *polysec = linedef->backsector; - - delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - if (polysec->floorheight < lowestceiling && delta1 >= delta2) { - lowestceiling = polysec->floorheight; -#ifdef ESLOPE - ceilingslope = NULL; -#endif - } - else if (polysec->floorheight < highestceiling && delta1 >= delta2) - highestceiling = polysec->floorheight; - - if (polysec->ceilingheight > highestfloor && delta1 < delta2) { - highestfloor = polysec->ceilingheight; -#ifdef ESLOPE - floorslope = NULL; -#endif - } - else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) - lowestfloor = polysec->ceilingheight; - } -#endif - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) { - openbottom = highestfloor; -#ifdef ESLOPE - openbottomslope = floorslope; -#endif - } - - if (lowestceiling < opentop) { - opentop = lowestceiling; -#ifdef ESLOPE - opentopslope = ceilingslope; -#endif - } - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; } } @@ -1093,7 +1032,10 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) { P_SetTarget(&bnext, mobj->bnext); // We want to note our reference to bnext here incase it is MF_NOTHINK and gets removed! if (!func(mobj)) + { + P_SetTarget(&bnext, NULL); return false; + } if (P_MobjWasRemoved(tmthing) // func just popped our tmthing, cannot continue. || (bnext && P_MobjWasRemoved(bnext))) // func just broke blockmap chain, cannot continue. { diff --git a/src/p_maputl.h b/src/p_maputl.h index 1fcb68d4c..bb09c3ed1 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -43,7 +43,7 @@ boolean P_PathTraverse(fixed_t px1, fixed_t py1, fixed_t px2, fixed_t py2, FUNCMATH fixed_t P_AproxDistance(fixed_t dx, fixed_t dy); void P_ClosestPointOnLine(fixed_t x, fixed_t y, line_t *line, vertex_t *result); -void P_ClosestPointOnLine3D(fixed_t x, fixed_t y, fixed_t z, line_t *line, vertex_t *result); +void P_ClosestPointOnLine3D(const vector3_t *p, const vector3_t *line, vector3_t *result); INT32 P_PointOnLineSide(fixed_t x, fixed_t y, line_t *line); void P_MakeDivline(line_t *li, divline_t *dl); void P_CameraLineOpening(line_t *plinedef); @@ -58,6 +58,7 @@ extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; #ifdef ESLOPE extern pslope_t *opentopslope, *openbottomslope; #endif +extern ffloor_t *openfloorrover, *openceilingrover; void P_LineOpening(line_t *plinedef, mobj_t *mobj); diff --git a/src/p_mobj.c b/src/p_mobj.c index 850ec2987..8ba1adc73 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -19,7 +19,7 @@ #include "p_local.h" #include "p_setup.h" #include "r_main.h" -#include "r_things.h" +#include "r_skins.h" #include "r_sky.h" #include "r_splats.h" #include "s_sound.h" @@ -34,10 +34,12 @@ #ifdef ESLOPE #include "p_slopes.h" #endif +#include "f_finale.h" +#include "m_cond.h" + +static CV_PossibleValue_t CV_BobSpeed[] = {{0, "MIN"}, {4*FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_movebob = {"movebob", "1.0", CV_FLOAT|CV_SAVE, CV_BobSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; -// protos. -static CV_PossibleValue_t viewheight_cons_t[] = {{16, "MIN"}, {56, "MAX"}, {0, NULL}}; -consvar_t cv_viewheight = {"viewheight", VIEWHEIGHTS, 0, viewheight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef WALLSPLATS consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; #endif @@ -60,9 +62,7 @@ void P_RunCachedActions(void) { var1 = states[ac->statenum].var1; var2 = states[ac->statenum].var2; -#ifdef HAVE_BLUA astate = &states[ac->statenum]; -#endif if (ac->mobj && !P_MobjWasRemoved(ac->mobj)) // just in case... states[ac->statenum].action.acp1(ac->mobj); next = ac->next; @@ -81,6 +81,41 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum) actioncachehead.prev = newaction; } +// +// P_SetupStateAnimation +// +FUNCINLINE static ATTRINLINE void P_SetupStateAnimation(mobj_t *mobj, state_t *st) +{ + INT32 animlength = (mobj->sprite == SPR_PLAY && mobj->skin) + ? (INT32)(((skin_t *)mobj->skin)->sprites[mobj->sprite2].numframes) - 1 + : st->var1; + + if (!(st->frame & FF_ANIMATE)) + return; + + if (animlength <= 0 || st->var2 == 0) + { + mobj->frame &= ~FF_ANIMATE; + return; // Crash/stupidity prevention + } + + mobj->anim_duration = (UINT16)st->var2; + + if (st->frame & FF_GLOBALANIM) + { + // Attempt to account for the pre-ticker for objects spawned on load + if (!leveltime) return; + + mobj->anim_duration -= (leveltime + 2) % st->var2; // Duration synced to timer + mobj->frame += ((leveltime + 2) / st->var2) % (animlength + 1); // Frame synced to timer (duration taken into account) + } + else if (st->frame & FF_RANDOMANIM) + { + mobj->frame += P_RandomKey(animlength + 1); // Random starting frame + mobj->anim_duration -= P_RandomKey(st->var2); // Random duration for first frame + } +} + // // P_CycleStateAnimation // @@ -89,13 +124,23 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj) // var2 determines delay between animation frames if (!(mobj->frame & FF_ANIMATE) || --mobj->anim_duration != 0) return; + mobj->anim_duration = (UINT16)mobj->state->var2; - // compare the current sprite frame to the one we started from - // if more than var1 away from it, swap back to the original - // else just advance by one - if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1) - mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK); + if (mobj->sprite != SPR_PLAY) + { + // compare the current sprite frame to the one we started from + // if more than var1 away from it, swap back to the original + // else just advance by one + if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1) + mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK); + + return; + } + + // sprite2 version of above + if (mobj->skin && (((++mobj->frame) & FF_FRAMEMASK) >= (UINT32)(((skin_t *)mobj->skin)->sprites[mobj->sprite2].numframes))) + mobj->frame &= ~FF_FRAMEMASK; } // @@ -163,54 +208,27 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) I_Error("P_SetPlayerMobjState used for non-player mobj. Use P_SetMobjState instead!\n(Mobj type: %d, State: %d)", mobj->type, state); #endif - // Catch state changes for Super Sonic - if (player->powers[pw_super] && (player->charflags & SF_SUPERANIMS)) + // Catch falling for nojumpspin + if ((state == S_PLAY_JUMP) && (player->charflags & SF_NOJUMPSPIN) && (P_MobjFlip(mobj)*mobj->momz < 0)) + return P_SetPlayerMobjState(mobj, S_PLAY_FALL); + + // Catch swimming versus flying + if (state == S_PLAY_FLY && player->mo->eflags & MFE_UNDERWATER) + return P_SetPlayerMobjState(player->mo, S_PLAY_SWIM); + else if (state == S_PLAY_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) + return P_SetPlayerMobjState(player->mo, S_PLAY_FLY); + + // Catch SF_NOSUPERSPIN jumps for Supers + if (player->powers[pw_super] && (player->charflags & SF_NOSUPERSPIN)) { - switch (state) + if (state == S_PLAY_JUMP) { - case S_PLAY_STND: - case S_PLAY_TAP1: - case S_PLAY_TAP2: - case S_PLAY_GASP: - P_SetPlayerMobjState(mobj, S_PLAY_SUPERSTAND); + if (player->mo->state-states == S_PLAY_WALK) + return P_SetPlayerMobjState(mobj, S_PLAY_FLOAT); return true; - case S_PLAY_FALL1: - case S_PLAY_SPRING: - case S_PLAY_RUN1: - case S_PLAY_RUN2: - case S_PLAY_RUN3: - case S_PLAY_RUN4: - P_SetPlayerMobjState(mobj, S_PLAY_SUPERWALK1); - return true; - case S_PLAY_FALL2: - case S_PLAY_RUN5: - case S_PLAY_RUN6: - case S_PLAY_RUN7: - case S_PLAY_RUN8: - P_SetPlayerMobjState(mobj, S_PLAY_SUPERWALK2); - return true; - case S_PLAY_SPD1: - case S_PLAY_SPD2: - P_SetPlayerMobjState(mobj, S_PLAY_SUPERFLY1); - return true; - case S_PLAY_SPD3: - case S_PLAY_SPD4: - P_SetPlayerMobjState(mobj, S_PLAY_SUPERFLY2); - return true; - case S_PLAY_TEETER1: - case S_PLAY_TEETER2: - P_SetPlayerMobjState(mobj, S_PLAY_SUPERTEETER); - return true; - case S_PLAY_ATK1: - case S_PLAY_ATK2: - case S_PLAY_ATK3: - case S_PLAY_ATK4: - if (!(player->charflags & SF_SUPERSPIN)) - return true; - break; - default: - break; } + else if (player->mo->state-states == S_PLAY_FLOAT && state == S_PLAY_STND) + return true; } // You were in pain state after taking a hit, and you're moving out of pain state now? else if (mobj->state == &states[mobj->info->painstate] && player->powers[pw_flashing] == flashingtics && state != mobj->info->painstate) @@ -222,23 +240,71 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) // Set animation state // The pflags version of this was just as convoluted. - if ((state >= S_PLAY_STND && state <= S_PLAY_TAP2) || (state >= S_PLAY_TEETER1 && state <= S_PLAY_TEETER2) || state == S_PLAY_CARRY - || state == S_PLAY_SUPERSTAND || state == S_PLAY_SUPERTEETER) + switch(state) + { + case S_PLAY_STND: + case S_PLAY_WAIT: + case S_PLAY_NIGHTS_STAND: player->panim = PA_IDLE; - else if ((state >= S_PLAY_RUN1 && state <= S_PLAY_RUN8) - || (state >= S_PLAY_SUPERWALK1 && state <= S_PLAY_SUPERWALK2)) + break; + case S_PLAY_EDGE: + player->panim = PA_EDGE; + break; + case S_PLAY_WALK: + case S_PLAY_SKID: + case S_PLAY_FLOAT: player->panim = PA_WALK; - else if ((state >= S_PLAY_SPD1 && state <= S_PLAY_SPD4) - || (state >= S_PLAY_SUPERFLY1 && state <= S_PLAY_SUPERFLY2)) + break; + case S_PLAY_RUN: + case S_PLAY_FLOAT_RUN: player->panim = PA_RUN; - else if (state >= S_PLAY_ATK1 && state <= S_PLAY_ATK4) + break; + case S_PLAY_DASH: + player->panim = PA_DASH; + break; + case S_PLAY_PAIN: + case S_PLAY_STUN: + player->panim = PA_PAIN; + break; + case S_PLAY_ROLL: + //case S_PLAY_SPINDASH: -- everyone can ROLL thanks to zoom tubes... + case S_PLAY_NIGHTS_ATTACK: player->panim = PA_ROLL; - else if (state >= S_PLAY_FALL1 && state <= S_PLAY_FALL2) + break; + case S_PLAY_JUMP: + player->panim = PA_JUMP; + break; + case S_PLAY_SPRING: + player->panim = PA_SPRING; + break; + case S_PLAY_FALL: + case S_PLAY_NIGHTS_FLOAT: player->panim = PA_FALL; - else if (state >= S_PLAY_ABL1 && state <= S_PLAY_ABL2) + break; + case S_PLAY_FLY: + case S_PLAY_FLY_TIRED: + case S_PLAY_SWIM: + case S_PLAY_GLIDE: + case S_PLAY_BOUNCE: + case S_PLAY_BOUNCE_LANDING: + case S_PLAY_TWINSPIN: player->panim = PA_ABILITY; - else + break; + case S_PLAY_SPINDASH: // ...but the act of SPINDASHING is charability2 specific. + case S_PLAY_FIRE: + case S_PLAY_FIRE_FINISH: + case S_PLAY_MELEE: + case S_PLAY_MELEE_FINISH: + case S_PLAY_MELEE_LANDING: + player->panim = PA_ABILITY2; + break; + case S_PLAY_RIDE: + player->panim = PA_RIDE; + break; + default: player->panim = PA_ETC; + break; + } if (recursion++) // if recursion detected, memset(seenstate = tempstate, 0, sizeof tempstate); // clear state table @@ -259,17 +325,14 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; // Adjust the player's animation speed to match their velocity. - if (!(disableSpeedAdjust || player->charflags & SF_NOSPEEDADJUST)) + if (state == S_PLAY_STND && player->powers[pw_super] && skins[player->skin].sprites[SPR2_WAIT|FF_SPR2SUPER].numframes == 0) // if no super wait, don't wait at all + mobj->tics = -1; + else if (player->panim == PA_EDGE && (player->charflags & SF_FASTEDGE)) + mobj->tics = 2; + else if (!(disableSpeedAdjust || player->charflags & SF_NOSPEEDADJUST)) { - fixed_t speed = FixedDiv(player->speed, mobj->scale); - if (player->panim == PA_ROLL) - { - if (speed > 16<tics = 1; - else - mobj->tics = 2; - } - else if (player->panim == PA_FALL) + fixed_t speed;// = FixedDiv(player->speed, FixedMul(mobj->scale, player->mo->movefactor)); + if (player->panim == PA_FALL) { speed = FixedDiv(abs(mobj->momz), mobj->scale); if (speed < 10<tics = 1; } - else if (P_IsObjectOnGround(mobj) || player->powers[pw_super]) // Only if on the ground or superflying. + else if (player->panim == PA_ABILITY2 && player->charability2 == CA2_SPINDASH) { - if (player->panim == PA_WALK) + fixed_t step = (player->maxdash - player->mindash)/4; + speed = (player->dashspeed - player->mindash); + if (speed > 3*step) + mobj->tics = 1; + else if (speed > step) + mobj->tics = 2; + else + mobj->tics = 3; + } + else + { + speed = FixedDiv(player->speed, FixedMul(mobj->scale, player->mo->movefactor)); + if (player->panim == PA_ROLL || player->panim == PA_JUMP) { - if (speed > 12<tics = 2; - else if (speed > 6<tics = 3; - else - mobj->tics = 4; - } - else if (player->panim == PA_RUN) - { - if (speed > 52< 16<tics = 1; else mobj->tics = 2; } + else if (P_IsObjectOnGround(mobj) || ((player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) && player->secondjump == 1) || player->powers[pw_super]) // Only if on the ground or superflying. + { + if (player->panim == PA_WALK) + { + if (speed > 12<tics = 2; + else if (speed > 6<tics = 3; + else + mobj->tics = 4; + } + else if ((player->panim == PA_RUN) || (player->panim == PA_DASH)) + { + if (speed > 52<tics = 1; + else + mobj->tics = 2; + } + } } } - mobj->sprite = st->sprite; - mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + // Player animations + if (st->sprite == SPR_PLAY) + { + skin_t *skin = ((skin_t *)mobj->skin); + UINT16 frame = (mobj->frame & FF_FRAMEMASK)+1; + UINT8 numframes, spr2; + + if (skin) + { + spr2 = P_GetSkinSprite2(skin, (((player->powers[pw_super]) ? FF_SPR2SUPER : 0)|st->frame) & FF_FRAMEMASK, mobj->player); + numframes = skin->sprites[spr2].numframes; + } + else + { + spr2 = 0; + frame = 0; + numframes = 0; + } + + if (mobj->sprite != SPR_PLAY) + { + mobj->sprite = SPR_PLAY; + frame = 0; + } + else if (mobj->sprite2 != spr2) + { + if ((st->frame & FF_SPR2MIDSTART) && numframes && P_RandomChance(FRACUNIT/2)) + frame = numframes/2; + else + frame = 0; + } + + if (frame >= numframes) + { + if (st->frame & FF_SPR2ENDSTATE) // no frame advancement + { + if (st->var1 == mobj->state-states) + frame--; + else + { + if (mobj->frame & FF_FRAMEMASK) + mobj->frame--; + return P_SetPlayerMobjState(mobj, st->var1); + } + } + else + frame = 0; + } + + mobj->sprite2 = spr2; + mobj->frame = frame|(st->frame&~FF_FRAMEMASK); + if (mobj->color >= MAXSKINCOLORS && mobj->color < MAXTRANSLATIONS) // Super colours? Super bright! + mobj->frame |= FF_FULLBRIGHT; + } + // Regular sprites + else + { + mobj->sprite = st->sprite; + mobj->frame = st->frame; + } + + P_SetupStateAnimation(mobj, st); // Modified handling. // Call action functions when the state is set @@ -313,9 +457,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif st->action.acp1(mobj); // woah. a player was removed by an action. @@ -370,9 +512,67 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) st = &states[state]; mobj->state = st; mobj->tics = st->tics; - mobj->sprite = st->sprite; - mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + + // Player animations + if (st->sprite == SPR_PLAY) + { + skin_t *skin = ((skin_t *)mobj->skin); + UINT16 frame = (mobj->frame & FF_FRAMEMASK)+1; + UINT8 numframes, spr2; + + if (skin) + { + spr2 = P_GetSkinSprite2(skin, st->frame & FF_FRAMEMASK, mobj->player); + numframes = skin->sprites[spr2].numframes; + } + else + { + spr2 = 0; + frame = 0; + numframes = 0; + } + + if (mobj->sprite != SPR_PLAY) + { + mobj->sprite = SPR_PLAY; + frame = 0; + } + else if (mobj->sprite2 != spr2) + { + if ((st->frame & FF_SPR2MIDSTART) && numframes && P_RandomChance(FRACUNIT/2)) + frame = numframes/2; + else + frame = 0; + } + + if (frame >= numframes) + { + if (st->frame & FF_SPR2ENDSTATE) // no frame advancement + { + if (st->var1 == mobj->state-states) + frame--; + else + { + if (mobj->frame & FF_FRAMEMASK) + mobj->frame--; + return P_SetMobjState(mobj, st->var1); + } + } + else + frame = 0; + } + + mobj->sprite2 = spr2; + mobj->frame = frame|(st->frame&~FF_FRAMEMASK); + } + // Regular sprites + else + { + mobj->sprite = st->sprite; + mobj->frame = st->frame; + } + + P_SetupStateAnimation(mobj, st); // Modified handling. // Call action functions when the state is set @@ -381,9 +581,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif st->action.acp1(mobj); if (P_MobjWasRemoved(mobj)) return false; @@ -426,7 +624,7 @@ boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation(mobj, st); return true; } @@ -445,7 +643,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation((mobj_t*)mobj, st); return true; } @@ -513,10 +711,10 @@ void P_EmeraldManager(void) spawnpoints[i] = NULL; } - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; @@ -653,14 +851,12 @@ void P_EmeraldManager(void) else break; - if (leveltime < TICRATE) // Start of map - spawnpoints[j]->threshold = 60*TICRATE + P_RandomByte() * (TICRATE/5); - else - spawnpoints[j]->threshold = P_RandomByte() * (TICRATE/5); - + spawnpoints[j]->threshold = emeraldspawndelay + P_RandomByte() * (TICRATE/5); break; } } + + emeraldspawndelay = 0; } // @@ -680,7 +876,7 @@ void P_ExplodeMissile(mobj_t *mo) if (mo->type == MT_DETON) { - P_RadiusAttack(mo, mo, 96*FRACUNIT); + P_RadiusAttack(mo, mo, 96*FRACUNIT, 0); explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); P_SetScale(explodemo, mo->scale); @@ -706,9 +902,6 @@ void P_ExplodeMissile(mobj_t *mo) explodemo->momx -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); explodemo->momy -= (P_RandomByte() % 96) * FixedMul(FRACUNIT/8, explodemo->scale); S_StartSound(explodemo, sfx_cybdth); - - // Hack: Release an animal. - P_DamageMobj(mo, NULL, NULL, 10000); } mo->flags &= ~MF_MISSILE; @@ -1220,11 +1413,8 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip(); // Flip aiming to match! - if (mo->player->pflags & PF_NIGHTSMODE) // NiGHTS doesn't use flipcam - { - if (mo->tracer) - mo->tracer->eflags ^= MFE_VERTICALFLIP; - } + if (mo->player->powers[pw_carry] == CR_NIGHTSMODE) // NiGHTS doesn't use flipcam + ; else if (mo->player->pflags & PF_FLIPCAM) { mo->player->aiming = InvAngle(mo->player->aiming); @@ -1317,10 +1507,9 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player) { if ((mo->player->pflags & PF_GLIDING) - || (mo->player->charability == CA_FLY && (mo->player->powers[pw_tailsfly] - || (mo->state >= &states[S_PLAY_SPC1] && mo->state <= &states[S_PLAY_SPC4])))) + || (mo->player->charability == CA_FLY && mo->player->panim == PA_ABILITY)) gravityadd = gravityadd/3; // less gravity while flying/gliding - if (mo->player->climbing || (mo->player->pflags & PF_NIGHTSMODE)) + if (mo->player->climbing || (mo->player->powers[pw_carry] == CR_NIGHTSMODE)) gravityadd = 0; if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be @@ -1348,6 +1537,8 @@ fixed_t P_GetMobjGravity(mobj_t *mo) { case MT_FLINGRING: case MT_FLINGCOIN: + case MT_FLINGBLUESPHERE: + case MT_FLINGNIGHTSCHIP: case MT_FLINGEMERALD: case MT_BOUNCERING: case MT_RAILRING: @@ -1375,6 +1566,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) } break; case MT_WATERDROP: + case MT_CYBRAKDEMON: gravityadd >>= 1; default: break; @@ -1384,7 +1576,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) // Goop has slower, reversed gravity if (goopgravity) - gravityadd = -gravityadd/5; + gravityadd = -((gravityadd/5) + (gravityadd/8)); gravityadd = FixedMul(gravityadd, mo->scale); @@ -1416,7 +1608,6 @@ void P_CheckGravity(mobj_t *mo, boolean affect) } #define STOPSPEED (FRACUNIT) -#define FRICTION (ORIG_FRICTION) // 0.90625 // // P_SceneryXYFriction @@ -1449,7 +1640,6 @@ static void P_SceneryXYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) { // Stolen from P_SpawnFriction mo->friction = FRACUNIT - 0x100; - mo->movefactor = ((0x10092 - mo->friction)*(0x70))/0x158; } else mo->friction = ORIG_FRICTION; @@ -1474,9 +1664,12 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) // spinning friction if (player->pflags & PF_SPINNING && (player->rmomx || player->rmomy) && !(player->pflags & PF_STARTDASH)) { - const fixed_t ns = FixedDiv(549*FRICTION,500*FRACUNIT); - mo->momx = FixedMul(mo->momx, ns); - mo->momy = FixedMul(mo->momy, ns); + if (twodlevel || player->mo->flags2 & MF2_TWOD) // Otherwise handled in P_3DMovement + { + const fixed_t ns = FixedDiv(549*ORIG_FRICTION,500*FRACUNIT); + mo->momx = FixedMul(mo->momx, ns); + mo->momy = FixedMul(mo->momy, ns); + } } else if (abs(player->rmomx) < FixedMul(STOPSPEED, mo->scale) && abs(player->rmomy) < FixedMul(STOPSPEED, mo->scale) @@ -1492,7 +1685,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) mo->momx = player->cmomx; mo->momy = player->cmomy; } - else + else if (!(mo->eflags & MFE_SPRUNG)) { if (oldx == mo->x && oldy == mo->y) // didn't go anywhere { @@ -1589,7 +1782,7 @@ static void P_PushableCheckBustables(mobj_t *mo) continue; } - EV_CrumbleChain(node->m_sector, rover); + EV_CrumbleChain(NULL, rover); // node->m_sector // Run a linedef executor?? if (rover->master->flags & ML_EFFECT5) @@ -1666,6 +1859,9 @@ void P_XYMovement(mobj_t *mo) oldy = mo->y; #ifdef ESLOPE + if (mo->flags & MF_NOCLIPHEIGHT) + mo->standingslope = NULL; + // adjust various things based on slope if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) { if (!P_IsObjectOnGround(mo)) { // We fell off at some point? Do the twisty thing! @@ -1690,10 +1886,11 @@ void P_XYMovement(mobj_t *mo) #endif // Pushables can break some blocks - if (CheckForBustableBlocks && mo->flags & MF_PUSHABLE) + if (CheckForBustableBlocks && ((mo->flags & MF_PUSHABLE) || ((mo->info->flags & MF_PUSHABLE) && mo->fuse))) P_PushableCheckBustables(mo); - if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) && !(mo->eflags & MFE_SPRUNG)) + if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) + && !(P_MobjWasRemoved(mo) || mo->eflags & MFE_SPRUNG)) { // blocked move moved = false; @@ -1703,7 +1900,14 @@ void P_XYMovement(mobj_t *mo) B_MoveBlocked(player); } - if (mo->flags & MF_BOUNCE) + if (LUAh_MobjMoveBlocked(mo)) + { + if (P_MobjWasRemoved(mo)) + return; + } + else if (P_MobjWasRemoved(mo)) + return; + else if (mo->flags & MF_BOUNCE) { P_BounceMove(mo); xmove = ymove = 0; @@ -1752,8 +1956,47 @@ void P_XYMovement(mobj_t *mo) } else if (player || mo->flags & (MF_SLIDEME|MF_PUSHABLE)) { // try to slide along it +#ifdef ESLOPE + // Wall transfer part 1. + pslope_t *transferslope = NULL; + fixed_t transfermomz = 0; + if (oldslope && (P_MobjFlip(mo)*(predictedz - mo->z) > 0)) // Only for moving up (relative to gravity), otherwise there's a failed launch when going down slopes and hitting walls + { + transferslope = ((mo->standingslope) ? mo->standingslope : oldslope); + if (((transferslope->zangle < ANGLE_180) ? transferslope->zangle : InvAngle(transferslope->zangle)) >= ANGLE_45) // Prevent some weird stuff going on on shallow slopes. + transfermomz = P_GetWallTransferMomZ(mo, transferslope); + } +#endif + P_SlideMove(mo); + if (player) + player->powers[pw_pushing] = 3; xmove = ymove = 0; + +#ifdef ESLOPE + // Wall transfer part 2. + if (transfermomz && transferslope) // Are we "transferring onto the wall" (really just a disguised vertical launch)? + { + angle_t relation; // Scale transfer momentum based on how head-on it is to the slope. + if (mo->momx || mo->momy) // "Guess" the angle of the wall you hit using new momentum + relation = transferslope->xydirection - R_PointToAngle2(0, 0, mo->momx, mo->momy); + else // Give it for free, I guess. + relation = ANGLE_90; + transfermomz = FixedMul(transfermomz, + abs(FINESINE((relation >> ANGLETOFINESHIFT) & FINEMASK))); + if (P_MobjFlip(mo)*(transfermomz - mo->momz) > 2*FRACUNIT) // Do the actual launch! + { + mo->momz = transfermomz; + mo->standingslope = NULL; + if (player) + { + player->powers[pw_justlaunched] = 2; + if (player->pflags & PF_SPINNING) + player->pflags |= PF_THOKKED; + } + } + } +#endif } else if (mo->type == MT_SPINFIRE) { @@ -1810,7 +2053,7 @@ void P_XYMovement(mobj_t *mo) return; #ifdef ESLOPE - if (moved && oldslope) { // Check to see if we ran off + if (moved && oldslope && !(mo->flags & MF_NOCLIPHEIGHT)) { // Check to see if we ran off if (oldslope != mo->standingslope) { // First, compare different slopes angle_t oldangle, newangle; @@ -1860,7 +2103,7 @@ void P_XYMovement(mobj_t *mo) // Check the gravity status. P_CheckGravity(mo, false); - if (player && !moved && player->pflags & PF_NIGHTSMODE && mo->target) + if (player && !moved && player->powers[pw_carry] == CR_NIGHTSMODE && mo->target) { angle_t fa; @@ -1897,13 +2140,13 @@ void P_XYMovement(mobj_t *mo) if (mo->flags & MF_NOCLIPHEIGHT) return; // no frictions for objects that can pass through floors - if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE) + if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE || mo->type == MT_PENGUINATOR) return; // no friction for missiles ever if (player && player->homing) // no friction for homing return; - if (player && player->pflags & PF_NIGHTSMODE) + if (player && player->powers[pw_carry] == CR_NIGHTSMODE) return; // no friction for NiGHTS players #ifdef ESLOPE @@ -1964,7 +2207,7 @@ static void P_SceneryXYMovement(mobj_t *mo) // 1 - forces false check for water (rings) // 2 - forces false check for water + different quicksand behaviour (scenery) // -static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype) +void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype) { ffloor_t *rover; fixed_t delta1, delta2, thingtop; @@ -1983,14 +2226,16 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp topheight = P_GetFOFTopZ(mo, sector, rover, mo->x, mo->y, NULL); bottomheight = P_GetFOFBottomZ(mo, sector, rover, mo->x, mo->y, NULL); - if (mo->player && (P_CheckSolidLava(mo, rover) || P_CanRunOnWater(mo->player, rover))) // only the player should be affected + if (mo->player && (P_CheckSolidLava(rover) || P_CanRunOnWater(mo->player, rover))) // only the player should stand on lava or run on water ; else if (motype != 0 && rover->flags & FF_SWIMMABLE) // "scenery" only continue; else if (rover->flags & FF_QUICKSAND) // quicksand ; - else if (!((rover->flags & FF_BLOCKPLAYER && mo->player) // solid to players? - || (rover->flags & FF_BLOCKOTHERS && !mo->player))) // solid to others? + else if (!( // if it's not either of the following... + (rover->flags & (FF_BLOCKPLAYER|FF_MARIO) && mo->player) // ...solid to players? (mario blocks are always solid from beneath to players) + || (rover->flags & FF_BLOCKOTHERS && !mo->player) // ...solid to others? + )) // ...don't take it into account. continue; if (rover->flags & FF_QUICKSAND) { @@ -2015,7 +2260,9 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp delta1 = mo->z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); + if (topheight > mo->floorz && abs(delta1) < abs(delta2) + && (rover->flags & FF_SOLID) // Non-FF_SOLID Mario blocks are only solid from bottom && !(rover->flags & FF_REVERSEPLATFORM) && ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_PLATFORM)))) // In reverse gravity, only clip for FOFs that are intangible from their bottom (the "top" you're falling through) if you're coming from above ("below" in your frame of reference) { @@ -2023,7 +2270,7 @@ static void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motyp } if (bottomheight < mo->ceilingz && abs(delta1) >= abs(delta2) && !(rover->flags & FF_PLATFORM) - && ((P_MobjFlip(mo)*mo->momz >= 0) || (!(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below + && ((P_MobjFlip(mo)*mo->momz >= 0) || ((rover->flags & FF_SOLID) && !(rover->flags & FF_REVERSEPLATFORM)))) // In normal gravity, only clip for FOFs that are intangible from the top if you're coming from below { mo->ceilingz = bottomheight; } @@ -2098,6 +2345,7 @@ static void P_RingZMovement(mobj_t *mo) if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; + mo->pmomz = 0; mo->eflags &= ~MFE_APPLYPMOMZ; } mo->z += mo->momz; @@ -2122,10 +2370,13 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); + if (mo->player && mo->player->pflags & PF_GODMODE) + return false; + if (((mo->z <= mo->subsector->sector->floorheight - && !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)) + && ((mo->subsector->sector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)) || (mo->z + mo->height >= mo->subsector->sector->ceilingheight - && (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING))) + && ((mo->subsector->sector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING))) && (GETSECSPECIAL(mo->subsector->sector->special, 1) == 6 || GETSECSPECIAL(mo->subsector->sector->special, 1) == 7)) return true; @@ -2133,23 +2384,11 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) return false; } -boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) +boolean P_CheckSolidLava(ffloor_t *rover) { - I_Assert(mo != NULL); - I_Assert(!P_MobjWasRemoved(mo)); - - { - fixed_t topheight = - #ifdef ESLOPE - *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : - #endif - *rover->topheight; - - if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 - && !(rover->master->flags & ML_BLOCKMONSTERS) - && ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale))) - return true; - } + if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3 + && !(rover->master->flags & ML_BLOCKMONSTERS)) + return true; return false; } @@ -2161,6 +2400,7 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) static boolean P_ZMovement(mobj_t *mo) { fixed_t dist, delta; + boolean onground; I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); @@ -2175,16 +2415,18 @@ static boolean P_ZMovement(mobj_t *mo) if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; + mo->pmomz = 0; mo->eflags &= ~MFE_APPLYPMOMZ; } mo->z += mo->momz; + onground = P_IsObjectOnGround(mo); #ifdef ESLOPE if (mo->standingslope) { if (mo->flags & MF_NOCLIPHEIGHT) mo->standingslope = NULL; - else if (!P_IsObjectOnGround(mo)) + else if (!onground) P_SlopeLaunch(mo); } #endif @@ -2215,6 +2457,13 @@ static boolean P_ZMovement(mobj_t *mo) mo->flags |= MF_NOGRAVITY; } break; + case MT_SPINFIRE: + if (P_CheckDeathPitCollide(mo)) + { + P_RemoveMobj(mo); + return false; + } + break; case MT_GOOP: if (P_CheckDeathPitCollide(mo)) { @@ -2253,11 +2502,16 @@ static boolean P_ZMovement(mobj_t *mo) case MT_RING: // Ignore still rings case MT_COIN: - case MT_BLUEBALL: + case MT_BLUESPHERE: + case MT_BOMBSPHERE: + case MT_NIGHTSCHIP: + case MT_NIGHTSSTAR: case MT_REDTEAMRING: case MT_BLUETEAMRING: case MT_FLINGRING: case MT_FLINGCOIN: + case MT_FLINGBLUESPHERE: + case MT_FLINGNIGHTSCHIP: case MT_FLINGEMERALD: // Remove flinged stuff from death pits. if (P_CheckDeathPitCollide(mo)) @@ -2290,18 +2544,15 @@ static boolean P_ZMovement(mobj_t *mo) if (!(mo->momx || mo->momy || mo->momz)) return true; break; - case MT_NIGHTSWING: - if (!(mo->momx || mo->momy || mo->momz)) - return true; - break; case MT_FLAMEJET: case MT_VERTICALFLAMEJET: if (!(mo->flags & MF_BOUNCE)) return true; break; case MT_SPIKE: + case MT_WALLSPIKE: // Dead spike particles disappear upon ground contact - if ((mo->z <= mo->floorz || mo->z + mo->height >= mo->ceilingz) && mo->health <= 0) + if (!mo->health && (mo->z <= mo->floorz || mo->z + mo->height >= mo->ceilingz)) { P_RemoveMobj(mo); return false; @@ -2311,22 +2562,32 @@ static boolean P_ZMovement(mobj_t *mo) break; } - if (P_CheckDeathPitCollide(mo)) + if (!mo->player && P_CheckDeathPitCollide(mo)) { - if (mo->flags & MF_PUSHABLE) + switch (mo->type) { - // Remove other pushable items from death pits. - P_RemoveMobj(mo); - return false; - } - else if (mo->flags & MF_ENEMY || mo->flags & MF_BOSS) - { - // Kill enemies and bosses that fall into death pits. - if (mo->health) - { - P_KillMobj(mo, NULL, NULL); - return false; - } + case MT_GHOST: + case MT_METALSONIC_RACE: + case MT_EXPLODE: + case MT_BOSSEXPLODE: + case MT_SONIC3KBOSSEXPLODE: + break; + default: + if (mo->flags & MF_ENEMY || mo->flags & MF_BOSS || mo->type == MT_MINECART) + { + // Kill enemies, bosses and minecarts that fall into death pits. + if (mo->health) + { + P_KillMobj(mo, NULL, NULL, 0); + } + return false; + } + else + { + P_RemoveMobj(mo); + return false; + } + break; } } @@ -2440,9 +2701,7 @@ static boolean P_ZMovement(mobj_t *mo) if (P_MobjFlip(mo)*mom.z < 0) // falling { - if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) - mo->eflags |= MFE_JUSTHITFLOOR; + mo->eflags |= MFE_JUSTHITFLOOR; if (mo->flags2 & MF2_SKULLFLY) // the skull slammed into something mom.z = -mom.z; @@ -2450,6 +2709,8 @@ static boolean P_ZMovement(mobj_t *mo) // Flingrings bounce if (mo->type == MT_FLINGRING || mo->type == MT_FLINGCOIN + || mo->type == MT_FLINGBLUESPHERE + || mo->type == MT_FLINGNIGHTSCHIP || P_WeaponOrPanel(mo->type) || mo->type == MT_FLINGEMERALD || mo->type == MT_BIGTUMBLEWEED @@ -2468,7 +2729,7 @@ static boolean P_ZMovement(mobj_t *mo) && abs(mom.y) < FixedMul(STOPSPEED, mo->scale) && abs(mom.z) < FixedMul(STOPSPEED*3, mo->scale)) { - if (mo->flags & MF_AMBUSH) + if (mo->flags2 & MF2_AMBUSH) { // If deafed, give the tumbleweed another random kick if it runs out of steam. mom.z += P_MobjFlip(mo)*FixedMul(6*FRACUNIT, mo->scale); @@ -2499,12 +2760,11 @@ static boolean P_ZMovement(mobj_t *mo) // Stolen from P_SpawnFriction mo->friction = FRACUNIT - 0x100; - mo->movefactor = ((0x10092 - mo->friction)*(0x70))/0x158; } else if (mo->type == MT_FALLINGROCK) { if (P_MobjFlip(mo)*mom.z > FixedMul(2*FRACUNIT, mo->scale)) - S_StartSound(mo, mo->info->activesound + P_RandomKey(mo->info->mass)); + S_StartSound(mo, mo->info->activesound + P_RandomKey(mo->info->reactiontime)); mom.z /= 2; // Rocks not so bouncy @@ -2523,14 +2783,11 @@ static boolean P_ZMovement(mobj_t *mo) mom.z = 0; } } - else if (tmfloorthing && (tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER)) - mom.z = tmfloorthing->momz; - else if (!tmfloorthing) - mom.z = 0; + else + mom.z = (tmfloorthing ? tmfloorthing->momz : 0); + } - else if (tmfloorthing && (tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER)) + else if (tmfloorthing) mom.z = tmfloorthing->momz; #ifdef ESLOPE @@ -2616,6 +2873,8 @@ static boolean P_ZMovement(mobj_t *mo) static void P_PlayerZMovement(mobj_t *mo) { + boolean onground; + I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); @@ -2638,17 +2897,19 @@ static void P_PlayerZMovement(mobj_t *mo) mo->player->viewheight -= mo->floorz - mo->z; mo->player->deltaviewheight = - (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3; + (FixedMul(41*mo->player->height/48, mo->scale) - mo->player->viewheight)>>3; } // adjust height if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; + mo->pmomz = 0; mo->eflags &= ~MFE_APPLYPMOMZ; } mo->z += mo->momz; + onground = P_IsObjectOnGround(mo); // Have player fall through floor? if (mo->player->playerstate == PST_DEAD @@ -2660,20 +2921,20 @@ static void P_PlayerZMovement(mobj_t *mo) { if (mo->flags & MF_NOCLIPHEIGHT) mo->standingslope = NULL; - else if (!P_IsObjectOnGround(mo)) + else if (!onground) P_SlopeLaunch(mo); } #endif // clip movement - if (P_IsObjectOnGround(mo) && !(mo->flags & MF_NOCLIPHEIGHT)) + if (onground && !(mo->flags & MF_NOCLIPHEIGHT)) { if (mo->eflags & MFE_VERTICALFLIP) mo->z = mo->ceilingz - mo->height; else mo->z = mo->floorz; - if (mo->player->pflags & PF_NIGHTSMODE) + if (mo->player->powers[pw_carry] == CR_NIGHTSMODE) { // bounce off floor if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180) @@ -2688,8 +2949,8 @@ static void P_PlayerZMovement(mobj_t *mo) goto nightsdone; } // Get up if you fell. - if (mo->state == &states[mo->info->painstate] || mo->state == &states[S_PLAY_SUPERHIT]) - P_SetPlayerMobjState(mo, S_PLAY_STND); + if (mo->player->panim == PA_PAIN) + P_SetPlayerMobjState(mo, S_PLAY_WALK); #ifdef ESLOPE if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) { @@ -2700,147 +2961,97 @@ static void P_PlayerZMovement(mobj_t *mo) if (P_MobjFlip(mo)*mo->momz < 0) // falling { + boolean clipmomz = !(P_CheckDeathPitCollide(mo)); + mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement. // Squat down. Decrease viewheight for a moment after hitting the ground (hard), if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) mo->player->deltaviewheight = (P_MobjFlip(mo)*mo->momz)>>3; // make sure momz is negative - if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack + mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack + { - mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack - - if (mo->eflags & MFE_JUSTHITFLOOR) - { #ifdef POLYOBJECTS - // Check if we're on a polyobject - // that triggers a linedef executor. - msecnode_t *node; - boolean stopmovecut = false; + // Check if we're on a polyobject + // that triggers a linedef executor. + msecnode_t *node; + boolean stopmovecut = false; - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + sector_t *sec = node->m_sector; + subsector_t *newsubsec; + size_t i; + + for (i = 0; i < numsubsectors; i++) { - sector_t *sec = node->m_sector; - subsector_t *newsubsec; - size_t i; + newsubsec = &subsectors[i]; - for (i = 0; i < numsubsectors; i++) + if (newsubsec->sector != sec) + continue; + + if (newsubsec->polyList) { - newsubsec = &subsectors[i]; + polyobj_t *po = newsubsec->polyList; + sector_t *polysec; - if (newsubsec->sector != sec) - continue; - - if (newsubsec->polyList) + while(po) { - polyobj_t *po = newsubsec->polyList; - sector_t *polysec; - - while(po) + if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red - if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) - stopmovecut = true; - - if (!(po->flags & POF_LDEXEC)) - { - po = (polyobj_t *)(po->link.next); - continue; - } - - if (mo->z == polysec->ceilingheight) - { - // We're landing on a PO, so check for - // a linedef executor. - // Trigger tags are 32000 + the PO's ID number. - P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); - } - po = (polyobj_t *)(po->link.next); + continue; } + + // We're inside it! Yess... + polysec = po->lines[0]->backsector; + + // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red + if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) + stopmovecut = true; + + if (!(po->flags & POF_LDEXEC)) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + if (mo->z == polysec->ceilingheight) + { + // We're landing on a PO, so check for + // a linedef executor. + // Trigger tags are 32000 + the PO's ID number. + P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); + } + + po = (polyobj_t *)(po->link.next); } } } + } - if (!stopmovecut) + if (!stopmovecut) #endif - // Cut momentum in half when you hit the ground and - // aren't pressing any controls. - if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy && !(mo->player->pflags & PF_SPINNING)) - { - mo->momx = mo->momx/2; - mo->momy = mo->momy/2; - } - } - - if (mo->health) + // Cut momentum in half when you hit the ground and + // aren't pressing any controls. + if (!(mo->player->cmd.forwardmove || mo->player->cmd.sidemove) && !mo->player->cmomx && !mo->player->cmomy && !(mo->player->pflags & PF_SPINNING)) { - if (mo->player->pflags & PF_GLIDING) // ground gliding - { - mo->player->skidtime = TICRATE; - mo->tics = -1; - } - else if (mo->player->pflags & PF_JUMPED || (mo->player->pflags & (PF_SPINNING|PF_USEDOWN)) != (PF_SPINNING|PF_USEDOWN) - || mo->player->powers[pw_tailsfly] || (mo->state >= &states[S_PLAY_SPC1] && mo->state <= &states[S_PLAY_SPC4])) - { - if (mo->player->cmomx || mo->player->cmomy) - { - if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) - P_SetPlayerMobjState(mo, S_PLAY_SPD1); - else if ((mo->player->rmomx || mo->player->rmomy) && mo->player->panim != PA_WALK) - P_SetPlayerMobjState(mo, S_PLAY_RUN1); - else if (!mo->player->rmomx && !mo->player->rmomy && mo->player->panim != PA_IDLE) - P_SetPlayerMobjState(mo, S_PLAY_STND); - } - else - { - if (mo->player->speed >= FixedMul(mo->player->runspeed, mo->scale) && mo->player->panim != PA_RUN) - P_SetPlayerMobjState(mo, S_PLAY_SPD1); - else if ((mo->momx || mo->momy) && mo->player->panim != PA_WALK) - P_SetPlayerMobjState(mo, S_PLAY_RUN1); - else if (!mo->momx && !mo->momy && mo->player->panim != PA_IDLE) - P_SetPlayerMobjState(mo, S_PLAY_STND); - } - } - - if (mo->player->pflags & PF_JUMPED) - mo->player->pflags &= ~PF_SPINNING; - else if (!(mo->player->pflags & PF_USEDOWN)) - mo->player->pflags &= ~PF_SPINNING; - - if (!(mo->player->pflags & PF_GLIDING)) - mo->player->pflags &= ~PF_JUMPED; - mo->player->pflags &= ~PF_THOKKED; - //mo->player->pflags &= ~PF_GLIDING; - mo->player->jumping = 0; - mo->player->secondjump = 0; - mo->player->glidetime = 0; - mo->player->climbing = 0; - mo->player->powers[pw_tailsfly] = 0; + mo->momx >>= 1; + mo->momy >>= 1; } } - if (!(mo->player->pflags & PF_SPINNING)) + + clipmomz = P_PlayerHitFloor(mo->player, true); + + if (!(mo->player->pflags & PF_SPINNING) && mo->player->powers[pw_carry] != CR_NIGHTSMODE) mo->player->pflags &= ~PF_STARTDASH; - if (tmfloorthing && (tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER)) - mo->momz = tmfloorthing->momz; - else if (!tmfloorthing) - mo->momz = 0; + if (clipmomz) + mo->momz = (tmfloorthing ? tmfloorthing->momz : 0); } - else if (tmfloorthing && (tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER)) + else if (tmfloorthing) mo->momz = tmfloorthing->momz; } else if (!(mo->flags & MF_NOGRAVITY)) // Gravity here! @@ -2873,7 +3084,7 @@ nightsdone: else mo->z = mo->ceilingz - mo->height; - if (mo->player->pflags & PF_NIGHTSMODE) + if (mo->player->powers[pw_carry] == CR_NIGHTSMODE) { // bounce off ceiling if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359) @@ -2911,8 +3122,13 @@ nightsdone: if (rover->flags & FF_MARIO && !(mo->eflags & MFE_VERTICALFLIP) // if you were flipped, your head isn't actually hitting your ceilingz is it? && *rover->bottomheight == mo->ceilingz) // The player's head hit the bottom! + { // DO THE MARIO! - EV_MarioBlock(rover->master->frontsector, node->m_sector, *rover->topheight, mo); + if (rover->flags & FF_SHATTERBOTTOM) // Brick block! + EV_CrumbleChain(node->m_sector, rover); + else // Question block! + EV_MarioBlock(rover, node->m_sector, mo); + } } } // Ugly ugly billions of braces! Argh! } @@ -2939,6 +3155,7 @@ static boolean P_SceneryZMovement(mobj_t *mo) if (mo->eflags & MFE_APPLYPMOMZ && !P_IsObjectOnGround(mo)) { mo->momz += mo->pmomz; + mo->pmomz = 0; mo->eflags &= ~MFE_APPLYPMOMZ; } mo->z += mo->momz; @@ -3001,34 +3218,26 @@ static boolean P_SceneryZMovement(mobj_t *mo) if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= mo->floorz) || (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height >= mo->ceilingz)) { - // DO NOT use random numbers here. - // SonicCD mode is console togglable and - // affects demos. - UINT8 rltime = (leveltime & 4); - - if (!rltime) - P_SpawnMobj(mo->x, mo->y, mo->floorz, MT_GFZFLOWER3); - else if (rltime == 2) - P_SpawnMobj(mo->x, mo->y, mo->floorz, MT_GFZFLOWER2); - else - P_SpawnMobj(mo->x, mo->y, mo->floorz, MT_GFZFLOWER1); + mobjtype_t flowertype = ((P_RandomChance(FRACUNIT/2)) ? MT_GFZFLOWER1 : MT_GFZFLOWER3); + mobj_t *flower = P_SpawnMobjFromMobj(mo, 0, 0, 0, flowertype); + if (flower) + { + P_SetScale(flower, mo->scale/16); + flower->destscale = mo->scale; + flower->scalespeed = mo->scale/8; + } P_RemoveMobj(mo); return false; } - default: break; } - // Fix for any silly pushables like the egg statues that are also scenery for some reason -- Monster Iestyn if (P_CheckDeathPitCollide(mo)) { - if (mo->flags & MF_PUSHABLE) - { - P_RemoveMobj(mo); - return false; - } + P_RemoveMobj(mo); + return false; } // clip movement @@ -3043,12 +3252,9 @@ static boolean P_SceneryZMovement(mobj_t *mo) if (P_MobjFlip(mo)*mo->momz < 0) // falling { - if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) - mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack + mo->eflags |= MFE_JUSTHITFLOOR; // Spin Attack - if (tmfloorthing && (tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) - || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER)) + if (tmfloorthing) mo->momz = tmfloorthing->momz; else if (!tmfloorthing) mo->momz = 0; @@ -3090,8 +3296,8 @@ boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) #endif *rover->topheight; - if (!(player->pflags & PF_NIGHTSMODE) && !player->homing - && (((player->charability == CA_SWIM) || player->powers[pw_super] || player->charflags & SF_RUNONWATER) && player->mo->ceilingz-topheight >= player->mo->height) + if (!player->powers[pw_carry] && !player->homing + && ((player->powers[pw_super] || player->charflags & SF_RUNONWATER || player->dashmode >= DASHMODE_THRESHOLD) && player->mo->ceilingz-topheight >= player->mo->height) && (rover->flags & FF_SWIMMABLE) && !(player->pflags & PF_SPINNING) && player->speed > FixedMul(player->runspeed, player->mo->scale) && !(player->pflags & PF_SLIDING) && abs(player->mo->z - topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) @@ -3110,16 +3316,18 @@ void P_MobjCheckWater(mobj_t *mobj) boolean waterwasnotset = (mobj->watertop == INT32_MAX); boolean wasinwater = (mobj->eflags & MFE_UNDERWATER) == MFE_UNDERWATER; boolean wasingoo = (mobj->eflags & MFE_GOOWATER) == MFE_GOOWATER; - fixed_t thingtop = mobj->z + mobj->height; // especially for players, infotable height does not neccessarily match actual height + fixed_t thingtop = mobj->z + mobj->height; sector_t *sector = mobj->subsector->sector; ffloor_t *rover; player_t *p = mobj->player; // Will just be null if not a player. + fixed_t height = (p ? P_GetPlayerHeight(p) : mobj->height); // for players, calculation height does not necessarily match actual height for gameplay reasons (spin, etc) + boolean wasgroundpounding = (p && ((p->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (p->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (p->pflags & PF_SHIELDABILITY)); // Default if no water exists. mobj->watertop = mobj->waterbottom = mobj->z - 1000*FRACUNIT; // Reset water state. - mobj->eflags &= ~(MFE_UNDERWATER|MFE_TOUCHWATER|MFE_GOOWATER); + mobj->eflags &= ~(MFE_UNDERWATER|MFE_TOUCHWATER|MFE_GOOWATER|MFE_TOUCHLAVA); for (rover = sector->ffloors; rover; rover = rover->next) { @@ -3142,14 +3350,14 @@ void P_MobjCheckWater(mobj_t *mobj) if (mobj->eflags & MFE_VERTICALFLIP) { - if (topheight < (thingtop - FixedMul(mobj->info->height/2, mobj->scale)) + if (topheight < (thingtop - (height>>1)) || bottomheight > thingtop) continue; } else { if (topheight < mobj->z - || bottomheight > (mobj->z + FixedMul(mobj->info->height/2, mobj->scale))) + || bottomheight > (mobj->z + (height>>1))) continue; } @@ -3158,38 +3366,49 @@ void P_MobjCheckWater(mobj_t *mobj) mobj->waterbottom = bottomheight; // Just touching the water? - if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - FixedMul(mobj->info->height, mobj->scale) < bottomheight) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + FixedMul(mobj->info->height, mobj->scale) > topheight)) - { + if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - height < bottomheight) + || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + height > topheight)) mobj->eflags |= MFE_TOUCHWATER; - if (rover->flags & FF_GOOWATER && !(mobj->flags & MF_NOGRAVITY)) - mobj->eflags |= MFE_GOOWATER; - } + // Actually in the water? - if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - FixedMul(mobj->info->height/2, mobj->scale) > bottomheight) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + FixedMul(mobj->info->height/2, mobj->scale) < topheight)) - { + if (((mobj->eflags & MFE_VERTICALFLIP) && thingtop - (height>>1) > bottomheight) + || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + (height>>1) < topheight)) mobj->eflags |= MFE_UNDERWATER; + + if (mobj->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) + { + if (GETSECSPECIAL(rover->master->frontsector->special, 1) == 3) + mobj->eflags |= MFE_TOUCHLAVA; + if (rover->flags & FF_GOOWATER && !(mobj->flags & MF_NOGRAVITY)) mobj->eflags |= MFE_GOOWATER; } } + // Spectators and dead players don't get to do any of the things after this. + if (p && (p->spectator || p->playerstate != PST_LIVE)) + return; + // Specific things for underwater players if (p && (mobj->eflags & MFE_UNDERWATER) == MFE_UNDERWATER) { if (!((p->powers[pw_super]) || (p->powers[pw_invulnerability]))) { - if ((p->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) - { // Water removes attract shield. + boolean electric = !!(p->powers[pw_shield] & SH_PROTECTELECTRIC); + if (electric || ((p->powers[pw_shield] & SH_PROTECTFIRE) && !(p->powers[pw_shield] & SH_PROTECTWATER) && !(mobj->eflags & MFE_TOUCHLAVA))) + { // Water removes electric and non-water fire shields... + P_FlashPal(p, + electric + ? PAL_WHITE + : PAL_NUKE, + 1); p->powers[pw_shield] = p->powers[pw_shield] & SH_STACK; - P_FlashPal(p, PAL_WHITE, 1); } } // Drown timer setting - if ((p->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL // Has elemental - || (p->exiting) // Or exiting + if ((p->powers[pw_shield] & SH_PROTECTWATER) // Has water protection + || (p->exiting) || (p->pflags & PF_FINISHED) // Or finished/exiting || (maptol & TOL_NIGHTS) // Or in NiGHTS mode || (mariomode)) // Or in Mario mode... { @@ -3201,16 +3420,18 @@ void P_MobjCheckWater(mobj_t *mobj) // Then we'll set it! p->powers[pw_underwater] = underwatertics + 1; } + + if ((wasgroundpounding = ((mobj->eflags & MFE_GOOWATER) && wasgroundpounding))) + { + p->pflags &= ~PF_SHIELDABILITY; + mobj->momz >>= 1; + } } // The rest of this code only executes on a water state change. if (waterwasnotset || !!(mobj->eflags & MFE_UNDERWATER) == wasinwater) return; - // Spectators and dead players also don't count. - if (p && (p->spectator || p->playerstate != PST_LIVE)) - return; - if ((p) // Players || (mobj->flags & MF_PUSHABLE) // Pushables || ((mobj->info->flags & MF_PUSHABLE) && mobj->fuse) // Previously pushable, might be moving still @@ -3218,34 +3439,42 @@ void P_MobjCheckWater(mobj_t *mobj) { // Check to make sure you didn't just cross into a sector to jump out of // that has shallower water than the block you were originally in. - if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= FixedMul(mobj->info->height, mobj->scale)>>1) + if ((!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= height>>1) + || ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= height>>1)) return; - if ((mobj->eflags & MFE_VERTICALFLIP) && mobj->ceilingz-mobj->waterbottom <= FixedMul(mobj->info->height, mobj->scale)>>1) - return; - - if ((mobj->eflags & MFE_GOOWATER || wasingoo)) { // Decide what happens to your momentum when you enter/leave goopy water. - if (P_MobjFlip(mobj)*mobj->momz < 0) // You are entering the goo? - mobj->momz = FixedMul(mobj->momz, FixedDiv(2*FRACUNIT, 5*FRACUNIT)); // kill momentum significantly, to make the goo feel thick. + if (mobj->eflags & MFE_GOOWATER || wasingoo) { // Decide what happens to your momentum when you enter/leave goopy water. + if (P_MobjFlip(mobj)*mobj->momz > 0) + { + mobj->momz -= (mobj->momz/8); // cut momentum a little bit to prevent multiple bobs + //CONS_Printf("leaving\n"); + } + else + { + if (!wasgroundpounding) + mobj->momz >>= 1; // kill momentum significantly, to make the goo feel thick. + //CONS_Printf("entering\n"); + } } else if (wasinwater && P_MobjFlip(mobj)*mobj->momz > 0) mobj->momz = FixedMul(mobj->momz, FixedDiv(780*FRACUNIT, 457*FRACUNIT)); // Give the mobj a little out-of-water boost. if (P_MobjFlip(mobj)*mobj->momz < 0) { - if ((mobj->eflags & MFE_VERTICALFLIP && thingtop-(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz <= mobj->waterbottom) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz >= mobj->watertop)) + if ((mobj->eflags & MFE_VERTICALFLIP && thingtop-(height>>1)-mobj->momz <= mobj->waterbottom) + || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(height>>1)-mobj->momz >= mobj->watertop)) { // Spawn a splash mobj_t *splish; + mobjtype_t splishtype = (mobj->eflags & MFE_TOUCHLAVA) ? MT_LAVASPLISH : MT_SPLISH; if (mobj->eflags & MFE_VERTICALFLIP) { - splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH); + splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[splishtype].height, mobj->scale), splishtype); splish->flags2 |= MF2_OBJECTFLIP; splish->eflags |= MFE_VERTICALFLIP; } else - splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, MT_SPLISH); + splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, splishtype); splish->destscale = mobj->scale; P_SetScale(splish, mobj->scale); } @@ -3267,20 +3496,21 @@ void P_MobjCheckWater(mobj_t *mobj) } else if (P_MobjFlip(mobj)*mobj->momz > 0) { - if (((mobj->eflags & MFE_VERTICALFLIP && thingtop-(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz > mobj->waterbottom) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(FixedMul(mobj->info->height, mobj->scale)>>1)-mobj->momz < mobj->watertop)) + if (((mobj->eflags & MFE_VERTICALFLIP && thingtop-(height>>1)-mobj->momz > mobj->waterbottom) + || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z+(height>>1)-mobj->momz < mobj->watertop)) && !(mobj->eflags & MFE_UNDERWATER)) // underwater check to prevent splashes on opposite side { // Spawn a splash mobj_t *splish; + mobjtype_t splishtype = (mobj->eflags & MFE_TOUCHLAVA) ? MT_LAVASPLISH : MT_SPLISH; if (mobj->eflags & MFE_VERTICALFLIP) { - splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[MT_SPLISH].height, mobj->scale), MT_SPLISH); + splish = P_SpawnMobj(mobj->x, mobj->y, mobj->waterbottom-FixedMul(mobjinfo[splishtype].height, mobj->scale), splishtype); splish->flags2 |= MF2_OBJECTFLIP; splish->eflags |= MFE_VERTICALFLIP; } else - splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, MT_SPLISH); + splish = P_SpawnMobj(mobj->x, mobj->y, mobj->watertop, splishtype); splish->destscale = mobj->scale; P_SetScale(splish, mobj->scale); } @@ -3296,6 +3526,8 @@ void P_MobjCheckWater(mobj_t *mobj) if (mobj->eflags & MFE_GOOWATER || wasingoo) S_StartSound(mobj, sfx_ghit); + else if (mobj->eflags & MFE_TOUCHLAVA) + S_StartSound(mobj, sfx_splash); else S_StartSound(mobj, sfx_splish); // And make a sound! @@ -3373,10 +3605,10 @@ static void P_SceneryCheckWater(mobj_t *mobj) #endif if (topheight <= mobj->z - || bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) + || bottomheight > (mobj->z + (mobj->height>>1))) continue; - if (mobj->z + FixedMul(mobj->info->height, mobj->scale) > topheight) + if (mobj->z + mobj->height > topheight) mobj->eflags |= MFE_TOUCHWATER; else mobj->eflags &= ~MFE_TOUCHWATER; @@ -3385,7 +3617,7 @@ static void P_SceneryCheckWater(mobj_t *mobj) mobj->watertop = topheight; mobj->waterbottom = bottomheight; - if (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale) < topheight) + if (mobj->z + (mobj->height>>1) < topheight) mobj->eflags |= MFE_UNDERWATER; else mobj->eflags &= ~MFE_UNDERWATER; @@ -3475,36 +3707,29 @@ void P_DestroyRobots(void) mobj_t *mo; thinker_t *think; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; - if (mo->health <= 0 || !(mo->flags & MF_ENEMY || mo->flags & MF_BOSS)) + if (mo->health <= 0 || !(mo->flags & (MF_ENEMY|MF_BOSS))) continue; // not a valid enemy if (mo->type == MT_PLAYER) // Don't chase after other players! continue; // Found a target enemy - P_KillMobj(mo, players[consoleplayer].mo, players[consoleplayer].mo); + P_KillMobj(mo, players[consoleplayer].mo, players[consoleplayer].mo, 0); } } -// P_CameraThinker -// -// Process the mobj-ish required functions of the camera -boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) +// the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person +void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { - boolean itsatwodlevel = false; postimg_t postimg = postimg_none; - if (twodlevel - || (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD)) - || (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD))) - itsatwodlevel = true; - if (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP) + if (player->pflags & PF_FLIPCAM && !(player->powers[pw_carry] == CR_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP) postimg = postimg_flip; else if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { @@ -3530,17 +3755,31 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled postimg = postimg_heat; } - if (postimg != postimg_none) - { - if (splitscreen && player == &players[secondarydisplayplayer]) - postimgtype2 = postimg; - else - postimgtype = postimg; - } + if (postimg == postimg_none) + return; + + if (splitscreen && player == &players[secondarydisplayplayer]) + postimgtype2 = postimg; + else + postimgtype = postimg; +} + +// P_CameraThinker +// +// Process the mobj-ish required functions of the camera +boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled) +{ + boolean itsatwodlevel = false; + if (twodlevel + || (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD)) + || (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD))) + itsatwodlevel = true; + + P_CalcChasePostImg(player, thiscam); if (thiscam->momx || thiscam->momy) { - if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) + if (!P_TryCameraMove(thiscam->x + thiscam->momx, thiscam->y + thiscam->momy, thiscam)) // Thanks for the greatly improved camera, Lach -- Sev { // Never fails for 2D mode. mobj_t dummy; dummy.thinker.function.acp1 = (actionf_p1)P_MobjThinker; @@ -3552,7 +3791,17 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled if (!resetcalled && !(player->pflags & PF_NOCLIP) && !P_CheckSight(&dummy, player->mo)) // TODO: "P_CheckCameraSight" instead. P_ResetCamera(player, thiscam); else + { + fixed_t camspeed = P_AproxDistance(thiscam->momx, thiscam->momy); + P_SlideCameraMove(thiscam); + + if (!resetcalled && P_AproxDistance(thiscam->momx, thiscam->momy) == camspeed) + { + P_ResetCamera(player, thiscam); + resetcalled = true; + } + } if (resetcalled) // Okay this means the camera is fully reset. return true; } @@ -3638,26 +3887,37 @@ static void P_PlayerMobjThinker(mobj_t *mobj) // momentum movement mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN; + if (mobj->state-states == S_PLAY_BOUNCE_LANDING) + goto animonly; // no need for checkposition - doesn't move at ALL + // Zoom tube - if (mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT) + if (mobj->tracer) { - P_UnsetThingPosition(mobj); - mobj->x += mobj->momx; - mobj->y += mobj->momy; - mobj->z += mobj->momz; - P_SetThingPosition(mobj); - P_CheckPosition(mobj, mobj->x, mobj->y); - goto animonly; - } - else if (mobj->player->pflags & PF_MACESPIN && mobj->tracer) - { - P_CheckPosition(mobj, mobj->x, mobj->y); - goto animonly; + if (mobj->player->powers[pw_carry] == CR_ZOOMTUBE || mobj->player->powers[pw_carry] == CR_ROPEHANG) + { + P_UnsetThingPosition(mobj); + mobj->x += mobj->momx; + mobj->y += mobj->momy; + mobj->z += mobj->momz; + P_SetThingPosition(mobj); + P_CheckPosition(mobj, mobj->x, mobj->y); + mobj->floorz = tmfloorz; + mobj->ceilingz = tmceilingz; + goto animonly; + } + else if (mobj->player->powers[pw_carry] == CR_MACESPIN) + { + P_CheckPosition(mobj, mobj->x, mobj->y); + mobj->floorz = tmfloorz; + mobj->ceilingz = tmceilingz; + goto animonly; + } } // Needed for gravity boots P_CheckGravity(mobj, false); + mobj->player->powers[pw_justlaunched] = 0; if (mobj->momx || mobj->momy) { P_XYMovement(mobj); @@ -3755,30 +4015,22 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } else { - if (!(mobj->player->pflags & PF_NIGHTSMODE)) // "jumping" is used for drilling - mobj->player->jumping = 0; - mobj->player->pflags &= ~PF_JUMPED; +#if 0 // i don't know why this is here, it's causing a few undesired state glitches, and disabling it doesn't appear to negatively affect the game, but i don't want it gone permanently just in case some obscure bug crops up + if (!(mobj->player->powers[pw_carry] == CR_NIGHTSMODE)) // used for drilling + mobj->player->pflags &= ~PF_STARTJUMP; + mobj->player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE); if (mobj->player->secondjump || mobj->player->powers[pw_tailsfly]) { mobj->player->secondjump = 0; mobj->player->powers[pw_tailsfly] = 0; - P_SetPlayerMobjState(mobj, S_PLAY_RUN1); + P_SetPlayerMobjState(mobj, S_PLAY_WALK); } +#endif mobj->eflags &= ~MFE_JUSTHITFLOOR; } animonly: - // cycle through states, - // calling action functions at transitions - if (mobj->tics != -1) - { - mobj->tics--; - - // you can cycle through multiple states in a tic - if (!mobj->tics) - if (!P_SetPlayerMobjState(mobj, mobj->state->nextstate)) - return; // freed itself - } + P_CyclePlayerMobjState(mobj); } static void CalculatePrecipFloor(precipmobj_t *mobj) @@ -3881,15 +4133,55 @@ void P_RainThinker(precipmobj_t *mobj) } // adjust height - if ((mobj->z += mobj->momz) <= mobj->floorz) + if ((mobj->z += mobj->momz) > mobj->floorz) + return; + + // no splashes on sky or bottomless pits + if (mobj->precipflags & PCF_PIT) { - // no splashes on sky or bottomless pits - if (mobj->precipflags & PCF_PIT) - mobj->z = mobj->ceilingz; - else + mobj->z = mobj->ceilingz; + return; + } + + mobj->z = mobj->floorz; + P_SetPrecipMobjState(mobj, S_SPLASH1); +} + +static void P_KillRingsInLava(mobj_t *mo) +{ + msecnode_t *node; + I_Assert(mo != NULL); + I_Assert(!P_MobjWasRemoved(mo)); + + // go through all sectors being touched by the ring + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (!node->m_sector) + break; + + if (node->m_sector->ffloors) { - mobj->z = mobj->floorz; - P_SetPrecipMobjState(mobj, S_SPLASH1); + ffloor_t *rover; + fixed_t topheight, bottomheight; + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) // go through all fofs in the sector + { + if (!(rover->flags & FF_EXISTS)) continue; // fof must be real + + if (!(rover->flags & FF_SWIMMABLE // fof must be water + && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3)) // fof must be lava water + continue; + + // find heights of FOF + topheight = P_GetFOFTopZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); + bottomheight = P_GetFOFBottomZ(mo, node->m_sector, rover, mo->x, mo->y, NULL); + + if (mo->z <= topheight && mo->z + mo->height >= bottomheight) // if ring touches it, KILL IT + { + P_KillMobj(mo, NULL, NULL, DMG_FIRE); + return; + } + } } } } @@ -3951,15 +4243,15 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) player = &players[actor->lastlook]; - if (player->health <= 0) - continue; // dead - if (player->pflags & PF_INVIS || player->bot || player->spectator) continue; // ignore notarget if (!player->mo || P_MobjWasRemoved(player->mo)) continue; + if (player->mo->health <= 0) + continue; //dead + if (!P_CheckSight(actor, player->mo)) continue; // out of sight @@ -3989,15 +4281,15 @@ boolean P_SupermanLook4Players(mobj_t *actor) { if (playeringame[c]) { - if (players[c].health <= 0) - continue; // dead - if (players[c].pflags & PF_INVIS) continue; // ignore notarget if (!players[c].mo || players[c].bot) continue; + if (players[c].mo->health <= 0) + continue; // dead + playersinthegame[stop] = &players[c]; stop++; } @@ -4019,12 +4311,7 @@ static void P_GenericBossThinker(mobj_t *mobj) if (!mobj->target || !(mobj->target->flags & MF_SHOOTABLE)) { if (mobj->health <= 0) - { - // look for a new target - if (P_BossTargetPlayer(mobj, false) && mobj->info->mass) // Bid farewell! - S_StartSound(mobj, mobj->info->mass); return; - } // look for a new target if (P_BossTargetPlayer(mobj, false) && mobj->info->seesound) @@ -4046,7 +4333,7 @@ static void P_GenericBossThinker(mobj_t *mobj) // AI for the first boss. static void P_Boss1Thinker(mobj_t *mobj) { - if (mobj->flags2 & MF2_FRET && (statenum_t)(mobj->state-states) == mobj->info->spawnstate) { + if (mobj->flags2 & MF2_FRET && mobj->state->nextstate == mobj->info->spawnstate && mobj->tics == 1) { mobj->flags2 &= ~(MF2_FRET|MF2_SKULLFLY); mobj->momx = mobj->momy = mobj->momz = 0; } @@ -4064,11 +4351,7 @@ static void P_Boss1Thinker(mobj_t *mobj) return; // It's okay, then. if (mobj->health <= 0) - { - if (P_BossTargetPlayer(mobj, false) && mobj->info->mass) // Bid farewell! - S_StartSound(mobj, mobj->info->mass); return; - } // look for a new target if (P_BossTargetPlayer(mobj, false) && mobj->info->seesound) @@ -4077,7 +4360,15 @@ static void P_Boss1Thinker(mobj_t *mobj) return; } - if (mobj->state != &states[mobj->info->spawnstate] && mobj->health > 0 && mobj->flags & MF_FLOAT && !(mobj->flags2 & MF2_SKULLFLY)) + if (mobj->flags2 & MF2_SKULLFLY) + { + fixed_t dist = (mobj->eflags & MFE_VERTICALFLIP) + ? ((mobj->ceilingz-(2*mobj->height)) - (mobj->z+mobj->height)) + : (mobj->z - (mobj->floorz+(2*mobj->height))); + if (dist > 0 && P_MobjFlip(mobj)*mobj->momz > 0) + mobj->momz = FixedMul(mobj->momz, FRACUNIT - (dist>>12)); + } + else if (mobj->state != &states[mobj->info->spawnstate] && mobj->health > 0 && mobj->flags & MF_FLOAT) mobj->momz = FixedMul(mobj->momz,7*FRACUNIT/8); if (mobj->state == &states[mobj->info->meleestate] @@ -4107,12 +4398,7 @@ static void P_Boss2Thinker(mobj_t *mobj) if (mobj->health <= mobj->info->damage && (!mobj->target || !(mobj->target->flags & MF_SHOOTABLE))) { if (mobj->health <= 0) - { - // look for a new target - if (P_BossTargetPlayer(mobj, false) && mobj->info->mass) // Bid farewell! - S_StartSound(mobj, mobj->info->mass); return; - } // look for a new target if (P_BossTargetPlayer(mobj, false) && mobj->info->seesound) @@ -4148,13 +4434,9 @@ static void P_Boss3Thinker(mobj_t *mobj) if (mobj->flags2 & MF2_FRET) mobj->movedir = 1; - if (!mobj->tracer) - { - var1 = 1; - A_BossJetFume(mobj); - } - if (mobj->health <= 0) + return; + /* { mobj->movecount = 0; mobj->reactiontime = 0; @@ -4167,174 +4449,131 @@ static void P_Boss3Thinker(mobj_t *mobj) mobj->momz = mobj->info->speed; return; } - } + else + { + mobj->flags |= MF_NOGRAVITY|MF_NOCLIP; + mobj->flags |= MF_NOCLIPHEIGHT; + mobj->threshold = -1; + return; + } + }*/ - if (mobj->reactiontime) // Shock mode + if (mobj->reactiontime) // At the bottom of the water { UINT32 i; + SINT8 curpath = mobj->threshold; + + // Choose one of the paths you're not already on + mobj->threshold = P_RandomKey(8-1); + if (mobj->threshold >= curpath) + mobj->threshold++; if (mobj->state != &states[mobj->info->spawnstate]) P_SetMobjState(mobj, mobj->info->spawnstate); mobj->reactiontime--; - if (!mobj->reactiontime) - { - ffloor_t *rover; - - // Shock the water - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - if (!players[i].mo) - continue; - - if (players[i].mo->health <= 0) - continue; - - if (players[i].mo->eflags & MFE_UNDERWATER) - P_DamageMobj(players[i].mo, mobj, mobj, 1); - } - - // Make the water flash - for (i = 0; i < numsectors; i++) - { - if (!sectors[i].ffloors) - continue; - - for (rover = sectors[i].ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - - if (!(rover->flags & FF_SWIMMABLE)) - continue; - - P_SpawnLightningFlash(rover->master->frontsector); - break; - } - } - - if ((UINT32)mobj->extravalue1 + TICRATE*2 < leveltime) - { - mobj->extravalue1 = (INT32)leveltime; - S_StartSound(0, sfx_buzz1); - } - - // If in the center, check to make sure - // none of the players are in the water - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - if (!players[i].mo || players[i].bot) - continue; - - if (players[i].mo->health <= 0) - continue; - - if (players[i].mo->eflags & MFE_UNDERWATER) - { // Stay put - mobj->reactiontime = 2*TICRATE; - return; - } - } - } if (!mobj->reactiontime && mobj->health <= mobj->info->damage) { // Spawn pinch dummies from the center when we're leaving it. thinker_t *th; mobj_t *mo2; mobj_t *dummy; - SINT8 way = mobj->threshold - 1; // 0 through 4. - SINT8 way2; + SINT8 way0 = mobj->threshold; // 0 through 4. + SINT8 way1, way2; i = 0; // reset i to 0 so we can check how many clones we've removed // scan the thinkers to make sure all the old pinch dummies are gone before making new ones // this can happen if the boss was hurt earlier than expected - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == (mobjtype_t)mobj->info->mass && mo2->tracer == mobj) - { - P_RemoveMobj(mo2); - i++; - } - if (i == 2) // we've already removed 2 of these, let's stop now + if (mo2->type != (mobjtype_t)mobj->info->mass) + continue; + if (mo2->tracer != mobj) + continue; + + P_RemoveMobj(mo2); + if (++i == 2) // we've already removed 2 of these, let's stop now break; } - way = (way + P_RandomRange(1,3)) % 5; // dummy 1 at one of the first three options after eggmobile + way1 = P_RandomKey(8-2); + if (way1 >= curpath) + way1++; + if (way1 >= way0) + { + way1++; + if (way1 == curpath) + way1++; + } + dummy = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->info->mass); dummy->angle = mobj->angle; - dummy->threshold = way + 1; - dummy->tracer = mobj; + dummy->threshold = way1; + P_SetTarget(&dummy->tracer, mobj); + dummy->movefactor = mobj->movefactor; + dummy->cusval = mobj->cusval; + + way2 = P_RandomKey(8-3); + if (way2 >= curpath) + way2++; + if (way2 >= way0) + { + way2++; + if (way2 == curpath) + way2++; + } + if (way2 >= way1) + { + way2++; + if (way2 == curpath || way2 == way0) + way2++; + } - do - way2 = (way + P_RandomRange(1,3)) % 5; // dummy 2 has to be careful, - while (way2 == mobj->threshold - 1); // to make sure it doesn't try to go the Eggman Way if dummy 1 rolled high. dummy = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->info->mass); dummy->angle = mobj->angle; - dummy->threshold = way2 + 1; - dummy->tracer = mobj; + dummy->threshold = way2; + P_SetTarget(&dummy->tracer, mobj); + dummy->movefactor = mobj->movefactor; + dummy->cusval = mobj->cusval; - CONS_Debug(DBG_GAMELOGIC, "Eggman path %d - Dummy selected paths %d and %d\n", mobj->threshold, way + 1, dummy->threshold); - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); + CONS_Debug(DBG_GAMELOGIC, "Eggman path %d - Dummy selected paths %d and %d\n", way0, way1, way2); + P_LinedefExecute(LE_PINCHPHASE+(mobj->cusval*LE_PARAMWIDTH), mobj, NULL); } } else if (mobj->movecount) // Firing mode { - UINT32 i; - - // look for a new target - P_BossTargetPlayer(mobj, false); - - if (!mobj->target || !mobj->target->player) - return; - - // Are there any players underwater? If so, shock them! - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - if (!players[i].mo || players[i].bot) - continue; - - if (players[i].mo->health <= 0) - continue; - - if (players[i].mo->eflags & MFE_UNDERWATER) - { - mobj->movecount = 0; - P_SetMobjState(mobj, mobj->info->spawnstate); - return; - } - } - - // Always face your target. - A_FaceTarget(mobj); - // Check if the attack animation is running. If not, play it. if (mobj->state < &states[mobj->info->missilestate] || mobj->state > &states[mobj->info->raisestate]) { + // look for a new target + P_BossTargetPlayer(mobj, true); + + if (!mobj->target || !mobj->target->player) + return; + if (mobj->health <= mobj->info->damage) // pinch phase mobj->movecount--; // limited number of shots before diving again if (mobj->movecount) - P_SetMobjState(mobj, mobj->info->missilestate); + P_SetMobjState(mobj, mobj->info->missilestate+1); + } + else if (mobj->target && mobj->target->player) + { + angle_t diff = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y) - mobj->angle; + if (diff > ANGLE_180) + diff = InvAngle(InvAngle(diff)/4); + else + diff /= 4; + mobj->angle += diff; } } else if (mobj->threshold >= 0) // Traveling mode { - thinker_t *th; - mobj_t *mo2; - fixed_t dist, dist2; + fixed_t dist = 0; fixed_t speed; P_SetTarget(&mobj->target, NULL); @@ -4343,97 +4582,133 @@ static void P_Boss3Thinker(mobj_t *mobj) && !(mobj->flags2 & MF2_FRET)) P_SetMobjState(mobj, mobj->info->spawnstate); - // scan the thinkers - // to find a point that matches - // the number - for (th = thinkercap.next; th != &thinkercap; th = th->next) + if (!(mobj->flags2 & MF2_STRONGBOX)) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) - continue; + thinker_t *th; + mobj_t *mo2; - mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && mo2->spawnpoint->angle == mobj->threshold) + P_SetTarget(&mobj->tracer, NULL); + + // scan the thinkers + // to find a point that matches + // the number + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - P_SetTarget(&mobj->target, mo2); + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)th; + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + if (!mo2->spawnpoint) + continue; + if (mo2->spawnpoint->angle != mobj->threshold) + continue; + if (mo2->spawnpoint->extrainfo != mobj->cusval) + continue; + + P_SetTarget(&mobj->tracer, mo2); break; } } - if (!mobj->target) // Should NEVER happen + if (!mobj->tracer) // Should NEVER happen { - CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 was unable to find specified waypoint: %d\n", mobj->threshold); + CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 was unable to find specified waypoint: %d, %d\n", mobj->threshold, mobj->cusval); return; } - dist = P_AproxDistance(P_AproxDistance(mobj->target->x - mobj->x, mobj->target->y - mobj->y), mobj->target->z - mobj->z); - - if (dist < 1) - dist = 1; - if ((mobj->movedir) || (mobj->health <= mobj->info->damage)) speed = mobj->info->speed * 2; else speed = mobj->info->speed; - mobj->momx = FixedMul(FixedDiv(mobj->target->x - mobj->x, dist), speed); - mobj->momy = FixedMul(FixedDiv(mobj->target->y - mobj->y, dist), speed); - mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, dist), speed); - - if (mobj->momx != 0 || mobj->momy != 0) - mobj->angle = R_PointToAngle2(0, 0, mobj->momx, mobj->momy); - - dist2 = P_AproxDistance(P_AproxDistance(mobj->target->x - (mobj->x + mobj->momx), mobj->target->y - (mobj->y + mobj->momy)), mobj->target->z - (mobj->z + mobj->momz)); - - if (dist2 < 1) - dist2 = 1; - - if ((dist >> FRACBITS) <= (dist2 >> FRACBITS)) + if (mobj->tracer->x == mobj->x && mobj->tracer->y == mobj->y) { - // If further away, set XYZ of mobj to waypoint location + // apply ambush for old routing, otherwise whack a mole only + dist = P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z + mobj->movefactor - mobj->z); + + if (dist < 1) + dist = 1; + + mobj->momx = FixedMul(FixedDiv(mobj->tracer->x - mobj->x, dist), speed); + mobj->momy = FixedMul(FixedDiv(mobj->tracer->y - mobj->y, dist), speed); + mobj->momz = FixedMul(FixedDiv(mobj->tracer->z + mobj->movefactor - mobj->z, dist), speed); + + if (mobj->momx != 0 || mobj->momy != 0) + mobj->angle = R_PointToAngle2(0, 0, mobj->momx, mobj->momy); + } + + if (dist <= speed) + { + // If distance to point is less than travel in that frame, set XYZ of mobj to waypoint location P_UnsetThingPosition(mobj); - mobj->x = mobj->target->x; - mobj->y = mobj->target->y; - mobj->z = mobj->target->z; + mobj->x = mobj->tracer->x; + mobj->y = mobj->tracer->y; + mobj->z = mobj->tracer->z + mobj->movefactor; mobj->momx = mobj->momy = mobj->momz = 0; P_SetThingPosition(mobj); - if (mobj->threshold == 0) + if (!mobj->movefactor) // to firing mode { - mobj->reactiontime = 1; // Bzzt! Shock the water! - mobj->movedir = 0; + UINT8 i, numtospawn = 24; + angle_t ang = 0, interval = FixedAngle((360 << FRACBITS) / numtospawn); + mobj_t *shock = NULL, *sfirst = NULL, *sprev = NULL; - if (mobj->health <= 0) + mobj->movecount = mobj->health+1; + mobj->movefactor = -512*FRACUNIT; + + // shock the water! + for (i = 0; i < numtospawn; i++) { - mobj->flags |= MF_NOGRAVITY|MF_NOCLIP; - mobj->flags |= MF_NOCLIPHEIGHT; - mobj->threshold = -1; - return; + shock = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SHOCKWAVE); + P_SetTarget(&shock->target, mobj); + shock->fuse = shock->info->painchance; + + if (i % 2 == 0) + P_SetMobjState(shock, shock->state->nextstate); + + if (!sprev) + sfirst = shock; + else + { + if (i == numtospawn - 1) + P_SetTarget(&shock->hnext, sfirst); + P_SetTarget(&sprev->hnext, shock); + } + + P_Thrust(shock, ang, shock->info->speed); + ang += interval; + sprev = shock; } - } + S_StartSound(mobj, shock->info->seesound); - // Set to next waypoint in sequence - if (mobj->target->spawnpoint) + // look for a new target + P_BossTargetPlayer(mobj, true); + + if (mobj->target && mobj->target->player) + P_SetMobjState(mobj, mobj->info->missilestate); + } + else if (mobj->flags2 & (MF2_STRONGBOX|MF2_CLASSICPUSH)) // just hit the bottom of your tube { - // From the center point, choose one of the five paths - if (mobj->target->spawnpoint->angle == 0) - mobj->threshold = P_RandomRange(1,5); - else - mobj->threshold = mobj->target->spawnpoint->extrainfo; - - // If the deaf flag is set, go into firing mode - if (mobj->target->spawnpoint->options & MTF_AMBUSH) - mobj->movecount = mobj->health+1; + mobj->flags2 &= ~(MF2_STRONGBOX|MF2_CLASSICPUSH); + mobj->reactiontime = 1; // spawn pinch dummies + mobj->movedir = 0; + } + else // just shifted to another tube + { + mobj->flags2 |= MF2_STRONGBOX; + if (mobj->health > 0) + mobj->movefactor = 0; } - else // This should never happen, as well - CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 waypoint has no spawnpoint associated with it.\n"); } } } // Move Boss4's sectors by delta. -static boolean P_Boss4MoveCage(fixed_t delta) +static boolean P_Boss4MoveCage(mobj_t *mobj, fixed_t delta) { - const UINT16 tag = 65534; + const UINT16 tag = 65534 + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0); INT32 snum; sector_t *sector; for (snum = sectors[tag%numsectors].firsttag; snum != -1; snum = sector->nexttag) @@ -4453,7 +4728,7 @@ static void P_Boss4MoveSpikeballs(mobj_t *mobj, angle_t angle, fixed_t fz) { INT32 s; mobj_t *base = mobj, *seg; - fixed_t dist, bz = mobj->watertop+(16<watertop+(8<tracer)) { for (seg = base, dist = 172*FRACUNIT, s = 9; seg; seg = seg->hnext, dist += 124*FRACUNIT, --s) @@ -4462,27 +4737,61 @@ static void P_Boss4MoveSpikeballs(mobj_t *mobj, angle_t angle, fixed_t fz) } } +#define CEZ3TILT + // Pull them closer. -static void P_Boss4PinchSpikeballs(mobj_t *mobj, angle_t angle, fixed_t fz) +static void P_Boss4PinchSpikeballs(mobj_t *mobj, angle_t angle, fixed_t dz) { INT32 s; mobj_t *base = mobj, *seg; - fixed_t dist, bz = mobj->watertop+(16<tracer)) + fixed_t workx, worky, dx, dy, bz = mobj->watertop+(8<spawnpoint) { - for (seg = base, dist = 112*FRACUNIT, s = 9; seg; seg = seg->hnext, dist += 132*FRACUNIT, --s) + originx = mobj->spawnpoint->x << FRACBITS; + originy = mobj->spawnpoint->y << FRACBITS; + } + else + { + originx = mobj->x; + originy = mobj->y; + } +#else + if (mobj->spawnpoint) + { + rad -= R_PointToDist2(mobj->x, mobj->y, + (mobj->spawnpoint->x<spawnpoint->y<tracer)) // there are 10 per spoke, remember that + { +#ifdef CEZ3TILT + dx = (originx + P_ReturnThrustX(mobj, angle, rad) - mobj->x)/9; + dy = (originy + P_ReturnThrustY(mobj, angle, rad) - mobj->y)/9; +#else + dx = P_ReturnThrustX(mobj, angle, rad)/9; + dy = P_ReturnThrustY(mobj, angle, rad)/9; +#endif + workx = mobj->x + P_ReturnThrustX(mobj, angle, (112)<y + P_ReturnThrustY(mobj, angle, (112)<hnext, --s) { - seg->z = bz + FixedMul(fz, FixedDiv(s<x + P_ReturnThrustX(mobj, angle, dist), mobj->y + P_ReturnThrustY(mobj, angle, dist), true); + seg->z = bz + (dz*(9-s)); + P_TryMove(seg, workx + (dx*s), worky + (dy*s), true); } angle += ANGLE_MAX/3; } } // Destroy cage FOFs. -static void P_Boss4DestroyCage(void) +static void P_Boss4DestroyCage(mobj_t *mobj) { - const UINT16 tag = 65534; + const UINT16 tag = 65534 + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0); INT32 snum, next; size_t a; sector_t *sector, *rsec; @@ -4535,7 +4844,7 @@ static void P_Boss4PopSpikeballs(mobj_t *mobj) P_SetTarget(&base->tracer, NULL); for (seg = base; seg; seg = seg->hnext) if (seg->health) - P_KillMobj(seg, NULL, NULL); + P_KillMobj(seg, NULL, NULL, 0); base = next; } } @@ -4545,9 +4854,11 @@ static void P_Boss4PopSpikeballs(mobj_t *mobj) // static void P_Boss4Thinker(mobj_t *mobj) { + fixed_t movespeed = 0; + if ((statenum_t)(mobj->state-states) == mobj->info->spawnstate) { - if (mobj->health > mobj->info->damage || mobj->movedir == 4) + if (mobj->flags2 & MF2_FRET && (mobj->health > mobj->info->damage)) mobj->flags2 &= ~MF2_FRET; mobj->reactiontime = 0; // Drop the cage immediately. } @@ -4557,12 +4868,50 @@ static void P_Boss4Thinker(mobj_t *mobj) { if (mobj->tracer) // need to clean up! { - P_Boss4DestroyCage(); // Just in case pinch phase was skipped. + P_Boss4DestroyCage(mobj); // Just in case pinch phase was skipped. P_Boss4PopSpikeballs(mobj); } return; } + if (mobj->movedir) // only not during init + { + INT32 oldmovecount = mobj->movecount; + if (mobj->movedir == 3) // pinch start + movespeed = -(210<<(FRACBITS>>1)); + else if (mobj->movedir > 3) // pinch + { + movespeed = 420<<(FRACBITS>>1); + movespeed += (420*(mobj->info->damage-mobj->health)<<(FRACBITS>>1)); + if (mobj->movedir == 4) + movespeed = -movespeed; + } + else // normal + { + movespeed = 170<<(FRACBITS>>1); + movespeed += ((50*(mobj->info->spawnhealth-mobj->health))<<(FRACBITS>>1)); + if (mobj->movedir == 2) + movespeed = -movespeed; + if (mobj->movefactor) + movespeed /= 2; + else if (mobj->threshold) + { + // 1 -> 1.5 second timer + INT32 maxtimer = TICRATE+(TICRATE*(mobj->info->spawnhealth-mobj->health)/10); + if (maxtimer < 1) + maxtimer = 1; + maxtimer = ((mobj->threshold*movespeed)/(2*maxtimer)); + movespeed -= maxtimer; + } + } + + mobj->movecount += movespeed + 360*FRACUNIT; + mobj->movecount %= 360*FRACUNIT; + + if (((oldmovecount>>FRACBITS)%120 >= 60) && !((mobj->movecount>>FRACBITS)%120 >= 60)) + S_StartSound(NULL, sfx_mswing); + } + // movedir == battle stage: // 0: initialization // 1: phase 1 forward @@ -4593,17 +4942,17 @@ static void P_Boss4Thinker(mobj_t *mobj) P_SetTarget(&seg->target, mobj); for (i = 0; i < 9; i++) { - seg->hnext = P_SpawnMobj(mobj->x, mobj->y, z, MT_EGGMOBILE4_MACE); - seg->hnext->hprev = seg; + P_SetTarget(&seg->hnext, P_SpawnMobj(mobj->x, mobj->y, z, MT_EGGMOBILE4_MACE)); + P_SetTarget(&seg->hnext->hprev, seg); seg = seg->hnext; } } // Move the cage up to the sky. mobj->movecount = 800*FRACUNIT; - if (!P_Boss4MoveCage(mobj->movecount)) + if (!P_Boss4MoveCage(mobj, mobj->movecount)) { mobj->movecount = 0; - mobj->threshold = 3*TICRATE; + //mobj->threshold = 3*TICRATE; mobj->extravalue1 = 1; mobj->movedir++; // We don't have a cage, just continue. } @@ -4615,17 +4964,14 @@ static void P_Boss4Thinker(mobj_t *mobj) fixed_t oldz = mobj->movecount; mobj->threshold -= 5*FRACUNIT; mobj->movecount += mobj->threshold; - if (mobj->movecount < 0) - mobj->movecount = 0; - P_Boss4MoveCage(mobj->movecount - oldz); - P_Boss4MoveSpikeballs(mobj, 0, mobj->movecount); - if (mobj->movecount == 0) + if (mobj->movecount <= 0) { - mobj->threshold = 3*TICRATE; - mobj->extravalue1 = 1; - P_LinedefExecute(LE_BOSS4DROP, mobj, NULL); + mobj->flags2 &= ~MF2_INVERTAIMABLE; + mobj->movecount = 0; mobj->movedir++; // Initialization complete, next phase! } + P_Boss4MoveCage(mobj, mobj->movecount - oldz); + P_Boss4MoveSpikeballs(mobj, 0, mobj->movecount); } return; } @@ -4639,17 +4985,18 @@ static void P_Boss4Thinker(mobj_t *mobj) case 3: { fixed_t z; - if (mobj->z < mobj->watertop+(512<z < mobj->watertop+(400<momz = 8*FRACUNIT; else { - mobj->momz = 0; + mobj->momz = mobj->movefactor = 0; + mobj->threshold = 1110<movedir++; } - mobj->movecount += 400<<(FRACBITS>>1); - mobj->movecount %= 360*FRACUNIT; + z = mobj->z - mobj->watertop - mobjinfo[MT_EGGMOBILE4_MACE].height - mobj->height/2; - if (z < 0) // We haven't risen high enough to pull the spikeballs along yet + if (z < (8<movecount), 0); // So don't pull the spikeballs along yet. else P_Boss4PinchSpikeballs(mobj, FixedAngle(mobj->movecount), z); @@ -4657,18 +5004,32 @@ static void P_Boss4Thinker(mobj_t *mobj) } // Pinch phase! case 4: + case 5: { - if (mobj->z < (mobj->watertop + ((512+128*(mobj->info->damage-mobj->health))<momz = 8*FRACUNIT; - else - mobj->momz = 0; - mobj->movecount += (800+800*(mobj->info->damage-mobj->health))<<(FRACBITS>>1); - mobj->movecount %= 360*FRACUNIT; + mobj->angle -= FixedAngle(movespeed/8); + + if (mobj->movefactor != mobj->threshold) + { + if (mobj->threshold - mobj->movefactor < FRACUNIT) + { + mobj->movefactor = mobj->threshold; + mobj->flags2 &= ~MF2_FRET; + } + else + mobj->movefactor += (mobj->threshold - mobj->movefactor)/8; + } + + if (mobj->spawnpoint) + P_TryMove(mobj, + (mobj->spawnpoint->x<angle, mobj->movefactor), + (mobj->spawnpoint->y<angle, mobj->movefactor), + true); + P_Boss4PinchSpikeballs(mobj, FixedAngle(mobj->movecount), mobj->z - mobj->watertop - mobjinfo[MT_EGGMOBILE4_MACE].height - mobj->height/2); if (!mobj->target || !mobj->target->health) P_SupermanLook4Players(mobj); - A_FaceTarget(mobj); + //A_FaceTarget(mobj); return; } @@ -4688,10 +5049,23 @@ static void P_Boss4Thinker(mobj_t *mobj) if (mobj->reactiontime == 1) { fixed_t oldz = mobj->movefactor; - mobj->movefactor += 8*FRACUNIT; - if (mobj->movefactor > 128*FRACUNIT) - mobj->movefactor = 128*FRACUNIT; - P_Boss4MoveCage(mobj->movefactor - oldz); + if (mobj->movefactor != 128*FRACUNIT) + { + if (mobj->movefactor < 128*FRACUNIT) + { + mobj->movefactor += 8*FRACUNIT; + if (!oldz) + { + // 5 -> 2.5 second timer + mobj->threshold = 5*TICRATE-(TICRATE*(mobj->info->spawnhealth-mobj->health)/2); + if (mobj->threshold < 1) + mobj->threshold = 1; + } + } + else + mobj->movefactor = 128*FRACUNIT; + P_Boss4MoveCage(mobj, mobj->movefactor - oldz); + } } // Drop the cage! else if (mobj->movefactor) @@ -4700,64 +5074,38 @@ static void P_Boss4Thinker(mobj_t *mobj) mobj->movefactor -= 4*FRACUNIT; if (mobj->movefactor < 0) mobj->movefactor = 0; - P_Boss4MoveCage(mobj->movefactor - oldz); + P_Boss4MoveCage(mobj, mobj->movefactor - oldz); if (!mobj->movefactor) { if (mobj->health <= mobj->info->damage) { // Proceed to pinch phase! - P_Boss4DestroyCage(); + P_Boss4DestroyCage(mobj); mobj->movedir = 3; - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); + P_LinedefExecute(LE_PINCHPHASE + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0), mobj, NULL); + P_Boss4MoveSpikeballs(mobj, FixedAngle(mobj->movecount), 0); + var1 = 3; + A_BossJetFume(mobj); return; } - P_LinedefExecute(LE_BOSS4DROP, mobj, NULL); + P_LinedefExecute(LE_BOSS4DROP - (mobj->info->spawnhealth-mobj->health) + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0), mobj, NULL); + // 1 -> 1.5 second timer + mobj->threshold = TICRATE+(TICRATE*(mobj->info->spawnhealth-mobj->health)/10); + if (mobj->threshold < 1) + mobj->threshold = 1; } } - { - fixed_t movespeed = 170<<(FRACBITS>>1); - if (mobj->reactiontime == 2) - movespeed *= 3; - if (mobj->movedir == 2) - mobj->movecount -= movespeed; - else - mobj->movecount += movespeed; - } - mobj->movecount %= 360*FRACUNIT; P_Boss4MoveSpikeballs(mobj, FixedAngle(mobj->movecount), mobj->movefactor); // Check for attacks, always tick the timer even while animating!! - if (!(mobj->flags2 & MF2_FRET) // but pause for pain so we don't interrupt pinch phase, eep! - && mobj->threshold-- == 0) + if (mobj->threshold) { - // 5 -> 2.5 second timer - mobj->threshold = 5*TICRATE-(TICRATE/2)*(mobj->info->spawnhealth-mobj->health); - if (mobj->threshold < 1) - mobj->threshold = 1; - - if (mobj->extravalue1-- == 0) - { - P_SetMobjState(mobj, mobj->info->raisestate); - mobj->extravalue1 = 3; - } - else + if (!(mobj->flags2 & MF2_FRET) && !(--mobj->threshold)) // but pause for pain so we don't interrupt pinch phase, eep! { if (mobj->reactiontime == 1) // Cage is raised? - mobj->reactiontime = 0; // Drop it! - switch(P_RandomKey(10)) { - // Telegraph Right (Speed Up!!) - case 1: - case 3: - case 4: - case 5: - case 6: - P_SetMobjState(mobj, mobj->info->missilestate); - break; - // Telegraph Left (Reverse Direction) - default: - P_SetMobjState(mobj, mobj->info->meleestate); - break; + P_SetMobjState(mobj, mobj->info->spawnstate); + mobj->reactiontime = 0; // Drop it! } } } @@ -4769,13 +5117,11 @@ static void P_Boss4Thinker(mobj_t *mobj) // Map allows us to get killed despite cage being down? if (mobj->health <= mobj->info->damage) { // Proceed to pinch phase! - P_Boss4DestroyCage(); - // spawn jet's flame now you're flying upwards - // tracer is already used, so if this ever gets reached again we've got problems + P_Boss4DestroyCage(mobj); + mobj->movedir = 3; + P_LinedefExecute(LE_PINCHPHASE + (mobj->spawnpoint ? mobj->spawnpoint->extrainfo*LE_PARAMWIDTH : 0), mobj, NULL); var1 = 3; A_BossJetFume(mobj); - mobj->movedir = 3; - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); return; } @@ -4785,6 +5131,65 @@ static void P_Boss4Thinker(mobj_t *mobj) A_FaceTarget(mobj); } +// +// AI for the fifth boss. +// +static void P_Boss5Thinker(mobj_t *mobj) +{ + if (!mobj->health) + { + if (mobj->fuse) + { + if (mobj->flags2 & MF2_SLIDEPUSH) + { + INT32 trans = 10-((10*mobj->fuse)/70); + if (trans > 9) + trans = 9; + if (trans < 0) + trans = 0; + mobj->frame = (mobj->frame & ~FF_TRANSMASK)|(trans<fuse & 1)) + { + mobj->colorized = !mobj->colorized; + mobj->frame ^= FF_FULLBRIGHT; + } + } + return; + } + if (mobj->state == &states[mobj->info->xdeathstate]) + mobj->momz -= (2*FRACUNIT)/3; + else if (mobj->tracer && P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y) < 2*mobj->radius) + mobj->flags &= ~MF_NOCLIP; + } + else + { + if (mobj->flags2 & MF2_FRET && (leveltime & 1) + && mobj->state != &states[S_FANG_PAIN1] && mobj->state != &states[S_FANG_PAIN2]) + mobj->flags2 |= MF2_DONTDRAW; + else + mobj->flags2 &= ~MF2_DONTDRAW; + } + + if (mobj->state == &states[S_FANG_BOUNCE3] + || mobj->state == &states[S_FANG_BOUNCE4] + || mobj->state == &states[S_FANG_PINCHBOUNCE3] + || mobj->state == &states[S_FANG_PINCHBOUNCE4]) + { + if (P_MobjFlip(mobj)*mobj->momz > 0 + && abs(mobj->momx) < FRACUNIT/2 && abs(mobj->momy) < FRACUNIT/2 + && !P_IsObjectOnGround(mobj)) + { + mobj_t *prevtarget = mobj->target; + P_SetTarget(&mobj->target, NULL); + var1 = var2 = 0; + A_DoNPCPain(mobj); + P_SetTarget(&mobj->target, prevtarget); + P_SetMobjState(mobj, S_FANG_WALLHIT); + mobj->extravalue2++; + } + } +} + // // AI for Black Eggman // Note: You CANNOT have more than ONE Black Eggman @@ -4835,7 +5240,7 @@ static void P_Boss7Thinker(mobj_t *mobj) { INT32 i; - P_KillMobj(mobj, NULL, NULL); + P_KillMobj(mobj, NULL, NULL, 0); // It was a team effort for (i = 0; i < MAXPLAYERS; i++) @@ -4886,7 +5291,7 @@ static void P_Boss7Thinker(mobj_t *mobj) && players[i].mo->z < mobj->z + mobj->height + 128*FRACUNIT) // You can't be in the vicinity, either... { // Punch him! - P_DamageMobj(players[i].mo, mobj, mobj, 1); + P_DamageMobj(players[i].mo, mobj, mobj, 1, 0); mobj->state->nextstate = mobj->info->spawnstate; // Laugh @@ -4948,6 +5353,7 @@ static void P_Boss7Thinker(mobj_t *mobj) INT32 i; boolean foundgoop = false; INT32 closestNum; + UINT8 extrainfo = (mobj->spawnpoint ? mobj->spawnpoint->extrainfo : 0); // Looks for players in goop. If you find one, try to jump on him. for (i = 0; i < MAXPLAYERS; i++) @@ -4961,29 +5367,35 @@ static void P_Boss7Thinker(mobj_t *mobj) if (players[i].mo->health <= 0) continue; - if (players[i].powers[pw_ingoop]) + if (players[i].powers[pw_carry] == CR_BRAKGOOP) { closestNum = -1; - closestdist = 16384*FRACUNIT; // Just in case... + closestdist = INT32_MAX; // Just in case... // Find waypoint he is closest to - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint) - { - dist = P_AproxDistance(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + if (!mo2->spawnpoint) + continue; + if (mo2->spawnpoint->extrainfo != extrainfo) + continue; + if (mobj->health <= mobj->info->damage && !(mo2->spawnpoint->options & 7)) + continue; // don't jump to center - if (closestNum == -1 || dist < closestdist) - { - closestNum = (mo2->spawnpoint->options & 7); - closestdist = dist; - foundgoop = true; - } - } + dist = P_AproxDistance(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); + + if (!(closestNum == -1 || dist < closestdist)) + continue; + + closestNum = (mo2->spawnpoint->options & 7); + closestdist = dist; + foundgoop = true; } waypointNum = closestNum; break; @@ -4992,17 +5404,14 @@ static void P_Boss7Thinker(mobj_t *mobj) if (!foundgoop) { - if (mobj->z > 1056*FRACUNIT) - waypointNum = 0; - else + // Don't jump to the center when health is low. + // Force the player to beat you with missiles. + if (mobj->z <= 1056*FRACUNIT || mobj->health <= mobj->info->damage) waypointNum = 1 + P_RandomKey(4); + else + waypointNum = 0; } - // Don't jump to the center when health is low. - // Force the player to beat you with missiles. - if (mobj->health <= mobj->info->damage && waypointNum == 0) - waypointNum = 1 + P_RandomKey(4); - if (mobj->tracer && mobj->tracer->type == MT_BOSS3WAYPOINT && mobj->tracer->spawnpoint && (mobj->tracer->spawnpoint->options & 7) == waypointNum) { @@ -5011,28 +5420,31 @@ static void P_Boss7Thinker(mobj_t *mobj) else waypointNum--; - waypointNum %= 5; - - if (waypointNum < 0) - waypointNum = 0; + if (mobj->health <= mobj->info->damage) + waypointNum = ((waypointNum + 3) % 4) + 1; // plus four to avoid modulo being negative, minus one to avoid waypoint #0 + else + waypointNum = ((waypointNum + 5) % 5); } - if (waypointNum == 0 && mobj->health <= mobj->info->damage) - waypointNum = 1 + (P_RandomFixed() & 1); - // scan the thinkers to find // the waypoint to use - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && (mo2->spawnpoint->options & 7) == waypointNum) - { - hitspot = mo2; - break; - } + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + if (!mo2->spawnpoint) + continue; + if ((mo2->spawnpoint->options & 7) != waypointNum) + continue; + if (mo2->spawnpoint->extrainfo != extrainfo) + continue; + + hitspot = mo2; + break; } if (hitspot == NULL) @@ -5109,7 +5521,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (players[i].mo->z < mobj->z - 64*FRACUNIT) continue; - P_DamageMobj(players[i].mo, mobj, mobj, 1); + P_DamageMobj(players[i].mo, mobj, mobj, 1, 0); // Laugh S_StartSound(0, sfx_bewar1 + P_RandomKey(4)); @@ -5122,6 +5534,16 @@ static void P_Boss7Thinker(mobj_t *mobj) } +#define vectorise mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<movedir = InvAngle(mobj->movedir);\ + mobj->threshold = 6 + (FixedMul(24<info->spawnhealth - mobj->health)<info->spawnhealth-1)<>FRACBITS);\ + if (mobj->info->activesound)\ + S_StartSound(mobj, mobj->info->activesound);\ + if (mobj->info->painchance)\ + P_SetMobjState(mobj, mobj->info->painchance);\ + mobj->flags2 &= ~MF2_INVERTAIMABLE;\ + // Metal Sonic battle boss // You CAN put multiple Metal Sonics in a single map // because I am a totally competent programmer who can do shit right. @@ -5145,19 +5567,19 @@ static void P_Boss9Thinker(mobj_t *mobj) // Run through the thinkers ONCE and find all of the MT_BOSS9GATHERPOINT in the map. // Build a hoop linked list of 'em! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; if (mo2->type == MT_BOSS9GATHERPOINT) { if (last) - last->hnext = mo2; + P_SetTarget(&last->hnext, mo2); else - mobj->hnext = mo2; - mo2->hprev = last; + P_SetTarget(&mobj->hnext, mo2); + P_SetTarget(&mo2->hprev, last); last = mo2; } } @@ -5166,48 +5588,66 @@ static void P_Boss9Thinker(mobj_t *mobj) if (mobj->health <= 0) return; + if ((statenum_t)(mobj->state-states) == mobj->info->meleestate) + { + P_InstaThrust(mobj, mobj->angle, -4*FRACUNIT); + P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true); + mobj->momz -= gravity; + if (mobj->z < mobj->watertop || mobj->z < (mobj->floorz + 16*FRACUNIT)) + { + mobj->watertop = mobj->floorz + 32*FRACUNIT; + P_SetMobjState(mobj, mobj->info->spawnstate); + } + return; + } + if ((!mobj->target || !(mobj->target->flags & MF_SHOOTABLE))) { + if (mobj->hprev) + { + P_RemoveMobj(mobj->hprev); + P_SetTarget(&mobj->hprev, NULL); + } P_BossTargetPlayer(mobj, false); if (mobj->target && (!P_IsObjectOnGround(mobj->target) || mobj->target->player->pflags & PF_SPINNING)) P_SetTarget(&mobj->target, NULL); // Wait for them to hit the ground first if (!mobj->target) // Still no target, aww. { // Reset the boss. + if (mobj->hprev) + { + P_RemoveMobj(mobj->hprev); + P_SetTarget(&mobj->hprev, NULL); + } P_SetMobjState(mobj, mobj->info->spawnstate); mobj->fuse = 0; mobj->momx = FixedDiv(mobj->momx, FRACUNIT + (FRACUNIT>>2)); mobj->momy = FixedDiv(mobj->momy, FRACUNIT + (FRACUNIT>>2)); mobj->momz = FixedDiv(mobj->momz, FRACUNIT + (FRACUNIT>>2)); + mobj->watertop = mobj->floorz + 32*FRACUNIT; + mobj->momz = (mobj->watertop - mobj->z)>>3; + mobj->threshold = 0; + mobj->movecount = 0; + mobj->flags = mobj->info->flags; return; } else if (!mobj->fuse) - mobj->fuse = 10*TICRATE; + mobj->fuse = 8*TICRATE; } // AI goes here. { - boolean danger = true; angle_t angle; - if (mobj->threshold) + if (mobj->threshold || mobj->movecount) mobj->momz = (mobj->watertop-mobj->z)/16; // Float to your desired position FASTER else mobj->momz = (mobj->watertop-mobj->z)/40; // Float to your desired position - if (mobj->movecount == 2) { + if (mobj->movecount == 2) + { mobj_t *spawner; fixed_t dist = 0; - angle = 0x06000000*leveltime; - - // Alter your energy bubble's size/position - if (mobj->health > 3) { - mobj->tracer->destscale = FRACUNIT + (4*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2); - P_SetScale(mobj->tracer, mobj->tracer->destscale); - P_TeleportMove(mobj->tracer, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->tracer->height/2); - mobj->tracer->momx = mobj->momx; - mobj->tracer->momy = mobj->momy; - mobj->tracer->momz = mobj->momz; - } + angle = 0x06000000*leveltime; // wtf? // Face your target P_BossTargetPlayer(mobj, true); @@ -5218,47 +5658,183 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->angle -= InvAngle(angle)/8; + // Alter your energy bubble's size/position + if (mobj->health > mobj->info->damage) + { + if (mobj->hprev) + { + mobj->hprev->destscale = FRACUNIT + (2*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2); + P_SetScale(mobj->hprev, mobj->hprev->destscale); + + P_TeleportMove(mobj->hprev, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->hprev->height/2); + mobj->hprev->momx = mobj->momx; + mobj->hprev->momy = mobj->momy; + mobj->hprev->momz = mobj->momz; + } + + // Firin' mah lazors - INDICATOR + if (mobj->fuse > TICRATE/2) + { + tic_t shoottime, worktime, calctime; + shoottime = (TICRATE/((mobj->extravalue1 == 3) ? 8 : 4)); + shoottime += (shoottime>>1); + worktime = shoottime*(mobj->threshold/2); + calctime = mobj->fuse-(TICRATE/2); + + if (calctime <= worktime && (calctime % shoottime == 0)) + { + mobj_t *missile; + + missile = P_SpawnMissile(mobj, mobj->target, MT_MSGATHER); + S_StopSound(missile); + if (mobj->extravalue1 >= 2) + P_SetScale(missile, FRACUNIT>>1); + missile->destscale = missile->scale>>1; + missile->fuse = TICRATE/2; + missile->scalespeed = abs(missile->destscale - missile->scale)/missile->fuse; + missile->z -= missile->height/2; + missile->momx *= -1; + missile->momy *= -1; + missile->momz *= -1; + + if (mobj->extravalue1 == 2) + { + UINT8 i; + mobj_t *spread; + for (i = 0; i < 5; i++) + { + if (i == 2) + continue; + spread = P_SpawnMobj(missile->x, missile->y, missile->z, missile->type); + spread->angle = missile->angle+(ANGLE_11hh/2)*(i-2); + P_InstaThrust(spread,spread->angle,-spread->info->speed); + spread->momz = missile->momz; + P_SetScale(spread, missile->scale); + spread->destscale = missile->destscale; + spread->scalespeed = missile->scalespeed; + spread->fuse = missile->fuse; + P_UnsetThingPosition(spread); + spread->x -= spread->fuse*spread->momx; + spread->y -= spread->fuse*spread->momy; + spread->z -= spread->fuse*spread->momz; + P_SetThingPosition(spread); + } + P_InstaThrust(missile,missile->angle,-missile->info->speed); + } + else if (mobj->extravalue1 >= 3) + { + UINT8 i; + mobj_t *spread; + mobj->target->z -= (4*missile->height); + for (i = 0; i < 5; i++) + { + if (i != 2) + { + spread = P_SpawnMissile(mobj, mobj->target, missile->type); + P_SetScale(spread, missile->scale); + spread->destscale = missile->destscale; + spread->fuse = missile->fuse; + spread->z -= spread->height/2; + spread->momx *= -1; + spread->momy *= -1; + spread->momz *= -1; + P_UnsetThingPosition(spread); + spread->x -= spread->fuse*spread->momx; + spread->y -= spread->fuse*spread->momy; + spread->z -= spread->fuse*spread->momz; + P_SetThingPosition(spread); + } + mobj->target->z += missile->height*2; + } + mobj->target->z -= (6*missile->height); + } + + P_UnsetThingPosition(missile); + missile->x -= missile->fuse*missile->momx; + missile->y -= missile->fuse*missile->momy; + missile->z -= missile->fuse*missile->momz; + P_SetThingPosition(missile); + + S_StartSound(mobj, sfx_s3kb3); + } + } + } + + // up... + mobj->z += mobj->height/2; + // Spawn energy particles - for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) { + for (spawner = mobj->hnext; spawner; spawner = spawner->hnext) + { dist = P_AproxDistance(spawner->x - mobj->x, spawner->y - mobj->y); if (P_RandomRange(1,(dist>>FRACBITS)/16) == 1) break; } - if (spawner) { + if (spawner) + { mobj_t *missile = P_SpawnMissile(spawner, mobj, MT_MSGATHER); - missile->momz = FixedDiv(missile->momz, 7*FRACUNIT/4); + if (dist == 0) missile->fuse = 0; else missile->fuse = (dist/P_AproxDistance(missile->momx, missile->momy)); + if (missile->fuse > mobj->fuse) P_RemoveMobj(missile); + + if (mobj->health > mobj->info->damage) + { + P_SetScale(missile, FRACUNIT/3); + missile->color = SKINCOLOR_MAGENTA; // sonic OVA/4 purple power + } + else + { + P_SetScale(missile, FRACUNIT/5); + missile->color = SKINCOLOR_SUNSET; // sonic cd electric power + } + missile->destscale = missile->scale*2; + missile->scalespeed = abs(missile->scale - missile->destscale)/missile->fuse; + missile->colorized = true; } + + // ...then down. easier than changing the missile's momz after-the-fact + mobj->z -= mobj->height/2; } // Pre-threshold reactiontime stuff for attack phases - if (mobj->reactiontime && mobj->movecount == 3) { + if (mobj->reactiontime && mobj->movecount == 3) + { + mobj->reactiontime--; + if (mobj->movedir == 0 || mobj->movedir == 2) { // Pausing between bounces in the pinball phase if (mobj->target->player->powers[pw_tailsfly]) // Trying to escape, eh? mobj->watertop = mobj->target->z + mobj->target->momz*6; // Readjust your aim. >:3 - else + else if (mobj->target->floorz > mobj->floorz) mobj->watertop = mobj->target->floorz + 16*FRACUNIT; - if (!(mobj->threshold%4)) + else + mobj->watertop = mobj->floorz + 16*FRACUNIT; + + if (!(mobj->threshold%4)) { mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx*4, mobj->target->y + mobj->target->momy*4); + if (!mobj->reactiontime) + S_StartSound(mobj, sfx_zoom); // zoom! + } } - // Pausing between energy ball shots - mobj->reactiontime--; + // else -- Pausing between energy ball shots + return; } // threshold is used for attacks/maneuvers. - if (mobj->threshold) { + if (mobj->threshold && mobj->movecount != 2) { fixed_t speed = 20*FRACUNIT + FixedMul(40*FRACUNIT, FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth<movecount == 3 && mobj->movedir == 1) { - if (!(mobj->threshold&1)) { + if (mobj->movecount == 3 && mobj->movedir == 1) + { + if (!(mobj->threshold & 1)) + { mobj_t *missile; if (mobj->info->seesound) S_StartSound(mobj, mobj->info->seesound); @@ -5270,18 +5846,20 @@ static void P_Boss9Thinker(mobj_t *mobj) A_FaceTarget(mobj); missile = P_SpawnMissile(mobj, mobj->target, mobj->info->speed); - if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) { + if (mobj->extravalue1 >= 2) + { missile->destscale = FRACUNIT>>1; P_SetScale(missile, missile->destscale); } missile->fuse = 3*TICRATE; missile->z -= missile->height/2; - if (mobj->extravalue1 == 2) { - int i; + if (mobj->extravalue1 == 2) + { + UINT8 i; mobj_t *spread; - missile->flags |= MF_MISSILE; - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) + { if (i == 2) continue; spread = P_SpawnMobj(missile->x, missile->y, missile->z, missile->type); @@ -5290,11 +5868,32 @@ static void P_Boss9Thinker(mobj_t *mobj) spread->momz = missile->momz; spread->destscale = FRACUNIT>>1; P_SetScale(spread, spread->destscale); - spread->fuse = 3*TICRATE; + spread->fuse = missile->fuse; } - missile->flags &= ~MF_MISSILE; + P_InstaThrust(missile,missile->angle,missile->info->speed); } - } else { + else if (mobj->extravalue1 >= 3) + { + UINT8 i; + mobj_t *spread; + mobj->target->z -= (2*missile->height); + for (i = 0; i < 5; i++) + { + if (i != 2) + { + spread = P_SpawnMissile(mobj, mobj->target, missile->type); + spread->destscale = FRACUNIT>>1; + P_SetScale(spread, spread->destscale); + spread->fuse = missile->fuse; + spread->z -= spread->height/2; + } + mobj->target->z += missile->height; + } + mobj->target->z -= (3*missile->height); + } + } + else + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->extravalue1 == 3) mobj->reactiontime = TICRATE/8; @@ -5305,10 +5904,9 @@ static void P_Boss9Thinker(mobj_t *mobj) return; } - P_SpawnGhostMobj(mobj); - // Pinball attack! - if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) { + if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) + { if ((statenum_t)(mobj->state-states) != mobj->info->seestate) P_SetMobjState(mobj, mobj->info->seestate); if (mobj->movedir == 0) // mobj health == 1 @@ -5317,32 +5915,49 @@ static void P_Boss9Thinker(mobj_t *mobj) P_InstaThrust(mobj, mobj->angle, 22*FRACUNIT); else // mobj health == 2 P_InstaThrust(mobj, mobj->angle, 30*FRACUNIT); - if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) { // Hit a wall? Find a direction to bounce + if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) + { // Hit a wall? Find a direction to bounce mobj->threshold--; - if (mobj->threshold) { - P_SetMobjState(mobj, mobj->state->nextstate); - if (mobj->info->mass) - S_StartSound(mobj, mobj->info->mass); - if (!(mobj->threshold%4)) { // We've decided to lock onto the player this bounce. - mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx*4, mobj->target->y + mobj->target->momy*4); - mobj->reactiontime = TICRATE; // targetting time - } else { // No homing, just use P_BounceMove - P_BounceMove(mobj); - mobj->angle = R_PointToAngle2(0,0,mobj->momx,mobj->momy); - mobj->reactiontime = TICRATE/4; // just a pause before you bounce away - } - mobj->momx = mobj->momy = 0; + if (!mobj->threshold) { // failed bounce! + S_StartSound(mobj, sfx_mspogo); + P_BounceMove(mobj); + mobj->angle = R_PointToAngle2(mobj->momx, mobj->momy,0,0); + mobj->momz = 4*FRACUNIT; + mobj->flags &= ~MF_PAIN; + mobj->fuse = 8*TICRATE; + mobj->movecount = 0; + P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_CYBRAKDEMON_VILE_EXPLOSION); + P_SetMobjState(mobj, mobj->info->meleestate); } + else if (!(mobj->threshold%4)) + { // We've decided to lock onto the player this bounce. + P_SetMobjState(mobj, mobj->state->nextstate); + S_StartSound(mobj, sfx_s3k5a); + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx*4, mobj->target->y + mobj->target->momy*4); + mobj->reactiontime = TICRATE - 5*(mobj->info->damage - mobj->health); // targetting time + } + else + { // No homing, just use P_BounceMove + S_StartSound(mobj, sfx_s3kaa); // make the bounces distinct... + P_BounceMove(mobj); + mobj->angle = R_PointToAngle2(0,0,mobj->momx,mobj->momy); + mobj->reactiontime = 1; // TICRATE/4; // just a pause before you bounce away + } + mobj->momx = mobj->momy = 0; } return; } + P_SpawnGhostMobj(mobj)->colorized = false; + // Vector form dodge! mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); - while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) { - mobj->angle += mobj->movedir; - P_InstaThrust(mobj, mobj->angle, -speed); + while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) + { + S_StartSound(mobj, sfx_mspogo); + P_BounceMove(mobj); + mobj->angle = R_PointToAngle2(mobj->momx, mobj->momy,0,0); } mobj->momx = mobj->momy = 0; mobj->threshold--; @@ -5396,7 +6011,7 @@ static void P_Boss9Thinker(mobj_t *mobj) if (mobj->flags2 & MF2_FRET) return; - if (mobj->state == &states[mobj->info->raisestate]) + if (mobj->movecount == 1 || mobj->movecount == 2) { // Charging energy if (mobj->momx != 0 || mobj->momy != 0) { // Apply the air breaks if (abs(mobj->momx)+abs(mobj->momy) < FRACUNIT) @@ -5404,11 +6019,13 @@ static void P_Boss9Thinker(mobj_t *mobj) else P_Thrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), -6*FRACUNIT/8); } - return; + if (mobj->state == states+mobj->info->raisestate) + return; } if (mobj->fuse == 0) { + mobj->flags2 &= ~MF2_INVERTAIMABLE; // It's time to attack! What are we gonna do?! switch(mobj->movecount) { @@ -5416,6 +6033,7 @@ static void P_Boss9Thinker(mobj_t *mobj) default: // Fly up and prepare for an attack! // We have to charge up first, so let's go up into the air + S_StartSound(mobj, sfx_beflap); P_SetMobjState(mobj, mobj->info->raisestate); if (mobj->floorz >= mobj->target->floorz) mobj->watertop = mobj->floorz + 256*FRACUNIT; @@ -5423,33 +6041,69 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->watertop = mobj->target->floorz + 256*FRACUNIT; break; - case 1: { + case 1: // Okay, we're up? Good, time to gather energy... if (mobj->health > mobj->info->damage) { // No more bubble if we're broken (pinch phase) mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT); - P_SetTarget(&mobj->tracer, shield); + P_SetTarget(&mobj->hprev, shield); P_SetTarget(&shield->target, mobj); + + // Attack 2: Energy shot! + switch (mobj->health) + { + case 8: // shoot once + default: + mobj->extravalue1 = 0; + mobj->threshold = 2; + break; + case 7: // spread shot (vertical) + mobj->extravalue1 = 4; + mobj->threshold = 2; + break; + case 6: // three shots + mobj->extravalue1 = 1; + mobj->threshold = 3*2; + break; + case 5: // spread shot (horizontal) + mobj->extravalue1 = 2; + mobj->threshold = 2; + break; + case 4: // machine gun + mobj->extravalue1 = 3; + mobj->threshold = 5*2; + break; + } } else - P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - mobj->fuse = 4*TICRATE; + { + /*mobj_t *shield = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_MSSHIELD_FRONT); + P_SetTarget(&mobj->tracer, shield); + P_SetTarget(&shield->target, mobj); + shield->height -= 20*FRACUNIT; // different offset... + P_SetMobjState(shield, S_MSSHIELD_F2);*/ + P_SetMobjState(mobj, S_METALSONIC_BOUNCE); + //P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); -- why does this happen twice? see case 2... + } + mobj->fuse = 3*TICRATE; mobj->flags |= MF_PAIN; if (mobj->info->attacksound) S_StartSound(mobj, mobj->info->attacksound); A_FaceTarget(mobj); + break; - } case 2: + { // We're all charged and ready now! Unleash the fury!! - if (mobj->health > mobj->info->damage) + S_StopSound(mobj); + if (mobj->hprev) { - mobj_t *removemobj = mobj->tracer; - P_SetTarget(&mobj->tracer, mobj->hnext); - P_RemoveMobj(removemobj); + P_RemoveMobj(mobj->hprev); + P_SetTarget(&mobj->hprev, NULL); } - if (mobj->health <= mobj->info->damage) { + if (mobj->health <= mobj->info->damage) + { // Attack 1: Pinball dash! if (mobj->health == 1) mobj->movedir = 0; @@ -5459,46 +6113,48 @@ static void P_Boss9Thinker(mobj_t *mobj) S_StartSound(mobj, mobj->info->seesound); P_SetMobjState(mobj, mobj->info->seestate); if (mobj->movedir == 2) - mobj->threshold = 16; // bounce 16 times + mobj->threshold = 12; // bounce 12 times else - mobj->threshold = 32; // bounce 32 times - mobj->watertop = mobj->target->floorz + 16*FRACUNIT; + mobj->threshold = 24; // bounce 24 times + if (mobj->floorz >= mobj->target->floorz) + mobj->watertop = mobj->floorz + 16*FRACUNIT; + else + mobj->watertop = mobj->target->floorz + 16*FRACUNIT; P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - } else { + +#if 0 + whoosh = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_GHOST); // done here so the offset is correct + whoosh->frame = FF_FULLBRIGHT; + whoosh->sprite = SPR_ARMA; + whoosh->destscale = whoosh->scale<<1; + whoosh->scalespeed = FixedMul(whoosh->scalespeed, whoosh->scale); + whoosh->height = 38*whoosh->scale; + whoosh->fuse = 10; + whoosh->color = SKINCOLOR_SUNSET; + whoosh->colorized = true; + whoosh->flags |= MF_NOCLIPHEIGHT; +#endif + + P_SetMobjState(mobj->tracer, S_JETFUMEFLASH); + P_SetScale(mobj->tracer, mobj->scale << 1); + } + else + { // Attack 2: Energy shot! mobj->movedir = 1; - - if (mobj->health >= 8) - mobj->extravalue1 = 0; - else if (mobj->health >= 5) - mobj->extravalue1 = 2; - else if (mobj->health >= 4) - mobj->extravalue1 = 1; - else - mobj->extravalue1 = 3; - - switch(mobj->extravalue1) { - case 0: // shoot once - case 2: // spread-shot - default: - mobj->threshold = 2; - break; - case 1: // shoot 3 times - mobj->threshold = 3*2; - break; - case 3: // shoot like a goddamn machinegun - mobj->threshold = 8*2; - break; - } + // looking for the number of things to fire? that's done in case 1 now } break; - + } case 3: // Return to idle. - mobj->watertop = mobj->target->floorz + 32*FRACUNIT; + if (mobj->floorz >= mobj->target->floorz) + mobj->watertop = mobj->floorz + 32*FRACUNIT; + else + mobj->watertop = mobj->target->floorz + 32*FRACUNIT; P_SetMobjState(mobj, mobj->info->spawnstate); mobj->flags &= ~MF_PAIN; - mobj->fuse = 10*TICRATE; + mobj->fuse = 8*TICRATE; break; } mobj->movecount++; @@ -5523,49 +6179,49 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->angle -= InvAngle(angle)/8; //A_FaceTarget(mobj); - // Check if we're being attacked - if (!(mobj->target->player->pflags & (PF_JUMPED|PF_SPINNING) - || mobj->target->player->powers[pw_tailsfly] - || mobj->target->player->powers[pw_invulnerability] - || mobj->target->player->powers[pw_super])) - danger = false; - if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) - danger = false; - if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) - danger = false; - if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) - danger = false; - if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) - danger = false; - if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) - danger = false; - if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) - danger = false; - if (danger) { - // An incoming attack is detected! What should we do?! - // Go into vector form! - mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<movedir = InvAngle(mobj->movedir); - mobj->threshold = 6 + (FixedMul(24<info->spawnhealth - mobj->health)<info->spawnhealth-1)<>FRACBITS); - if (mobj->info->activesound) - S_StartSound(mobj, mobj->info->activesound); - if (mobj->info->painchance) - P_SetMobjState(mobj, mobj->info->painchance); - return; + if (mobj->flags2 & MF2_CLASSICPUSH) + mobj->flags2 &= ~MF2_CLASSICPUSH; // a missile caught us in PIT_CheckThing! + else + { + // Check if we're being attacked + if (!mobj->target || !mobj->target->player || !P_PlayerCanDamage(mobj->target->player, mobj)) + goto nodanger; + if (mobj->target->x+mobj->target->radius+abs(mobj->target->momx*2) < mobj->x-mobj->radius) + goto nodanger; + if (mobj->target->x-mobj->target->radius-abs(mobj->target->momx*2) > mobj->x+mobj->radius) + goto nodanger; + if (mobj->target->y+mobj->target->radius+abs(mobj->target->momy*2) < mobj->y-mobj->radius) + goto nodanger; + if (mobj->target->y-mobj->target->radius-abs(mobj->target->momy*2) > mobj->y+mobj->radius) + goto nodanger; + if (mobj->target->z+mobj->target->height+mobj->target->momz*2 < mobj->z) + goto nodanger; + if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) + goto nodanger; } + // An incoming attack is detected! What should we do?! + // Go into vector form! + vectorise; + return; +nodanger: + + mobj->flags2 |= MF2_INVERTAIMABLE; + // Move normally: Approach the player using normal thrust and simulated friction. dist = P_AproxDistance(mobj->x-mobj->target->x, mobj->y-mobj->target->y); P_Thrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), -3*FRACUNIT/8); - if (dist < 64*FRACUNIT) + if (dist < 64*FRACUNIT && !(mobj->target->player && mobj->target->player->homing)) P_Thrust(mobj, mobj->angle, -4*FRACUNIT); else if (dist > 180*FRACUNIT) P_Thrust(mobj, mobj->angle, FRACUNIT); + else + P_Thrust(mobj, mobj->angle + ANGLE_90, FINECOSINE((((angle_t)(leveltime*ANG1))>>ANGLETOFINESHIFT) & FINEMASK)>>1); mobj->momz += P_AproxDistance(mobj->momx, mobj->momy)/12; // Move up higher the faster you're going. } } } +#undef vectorise // // P_GetClosestAxis @@ -5579,9 +6235,9 @@ mobj_t *P_GetClosestAxis(mobj_t *source) fixed_t dist1, dist2 = 0; // scan the thinkers to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -5822,8 +6478,8 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) mobj->scale = newscale; - mobj->radius = FixedMul(mobj->info->radius, newscale); - mobj->height = FixedMul(mobj->info->height, newscale); + mobj->radius = FixedMul(FixedDiv(mobj->radius, oldscale), newscale); + mobj->height = FixedMul(FixedDiv(mobj->height, oldscale), newscale); player = mobj->player; @@ -5831,16 +6487,17 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) { G_GhostAddScale(newscale); player->viewheight = FixedMul(FixedDiv(player->viewheight, oldscale), newscale); // Nonono don't calculate viewheight elsewhere, this is the best place for it! - player->dashspeed = FixedMul(FixedDiv(player->dashspeed, oldscale), newscale); // Prevents the player from having to re-charge up spindash if the player grew in size } } void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target { fixed_t dist, ndist, speedmul; + angle_t vangle; fixed_t tx = dest->x; fixed_t ty = dest->y; fixed_t tz = dest->z + (dest->height/2); // Aim for center + fixed_t xydist = P_AproxDistance(tx - source->x, ty - source->y); if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; @@ -5849,19 +6506,40 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y source->angle = R_PointToAngle2(source->x, source->y, tx, ty); // change slope - dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z); + dist = P_AproxDistance(xydist, tz - source->z); if (dist < 1) dist = 1; - if (nightsgrab) - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); - else - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + if (nightsgrab && source->movefactor) + { + source->movefactor += FRACUNIT/2; - source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); - source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); - source->momz = FixedMul(FixedDiv(tz - source->z, dist), speedmul); + if (dist < source->movefactor) + { + source->momx = source->momy = source->momz = 0; + P_TeleportMove(source, tx, ty, tz); + } + else + { + vangle = R_PointToAngle2(source->z, 0, tz, xydist); + + source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movefactor)); + source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movefactor)); + source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movefactor); + } + } + else + { + if (nightsgrab) + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); + else + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + + source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); + source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); + source->momz = FixedMul(FixedDiv(tz - source->z, dist), speedmul); + } // Instead of just unsetting NOCLIP like an idiot, let's check the distance to our target. ndist = P_AproxDistance(P_AproxDistance(tx - (source->x+source->momx), @@ -5886,6 +6564,7 @@ static void P_NightsItemChase(mobj_t *thing) { P_SetTarget(&thing->tracer, NULL); thing->flags2 &= ~MF2_NIGHTSPULL; + thing->movefactor = 0; return; } @@ -5895,6 +6574,222 @@ static void P_NightsItemChase(mobj_t *thing) P_Attract(thing, thing->tracer, true); } +// +// P_MaceRotate +// Spins a hnext-chain of objects around its centerpoint, side to side or periodically. +// +void P_MaceRotate(mobj_t *center, INT32 baserot, INT32 baseprevrot) +{ + TVector unit_lengthways, unit_sideways, pos_lengthways, pos_sideways; + TVector *res; + fixed_t radius, dist, zstore; + angle_t fa; + boolean dosound = false; + mobj_t *mobj = center->hnext, *hnext = NULL; + + INT32 lastthreshold = -1; // needs to never be equal at start of loop + fixed_t lastfriction = INT32_MIN; // ditto; almost certainly never, but... + + INT32 rot; + INT32 prevrot; + + dist = pos_sideways[0] = pos_sideways[1] = pos_sideways[2] = pos_sideways[3] = unit_sideways[3] =\ + pos_lengthways[0] = pos_lengthways[1] = pos_lengthways[2] = pos_lengthways[3] = 0; + + while (mobj) + { + if (P_MobjWasRemoved(mobj) || !mobj->health) + { + mobj = mobj->hnext; + continue; + } + + mobj->momx = mobj->momy = mobj->momz = 0; + + if (mobj->threshold != lastthreshold + || mobj->friction != lastfriction) + { + rot = (baserot + mobj->threshold) & FINEMASK; + prevrot = (baseprevrot + mobj->threshold) & FINEMASK; + + pos_lengthways[0] = pos_lengthways[1] = pos_lengthways[2] = pos_lengthways[3] = 0; + + dist = ((mobj->info->speed) ? mobj->info->speed : mobjinfo[MT_SMALLMACECHAIN].speed); + dist = ((center->scale == FRACUNIT) ? dist : FixedMul(dist, center->scale)); + + fa = (FixedAngle(center->movefactor*FRACUNIT) >> ANGLETOFINESHIFT); + radius = FixedMul(dist, FINECOSINE(fa)); + unit_lengthways[1] = -FixedMul(dist, FINESINE(fa)); + unit_lengthways[3] = FRACUNIT; + + // Swinging Chain. + if (center->flags2 & MF2_STRONGBOX) + { + fixed_t swingmag = FixedMul(FINECOSINE(rot), center->lastlook << FRACBITS); + fixed_t prevswingmag = FINECOSINE(prevrot); + + if ((prevswingmag > 0) != (swingmag > 0)) // just passed its lowest point + dosound = true; + + fa = ((FixedAngle(swingmag) >> ANGLETOFINESHIFT) + mobj->friction) & FINEMASK; + + unit_lengthways[0] = FixedMul(FINESINE(fa), -radius); + unit_lengthways[2] = FixedMul(FINECOSINE(fa), -radius); + } + // Rotating Chain. + else + { + angle_t prevfa = (prevrot + mobj->friction) & FINEMASK; + fa = (rot + mobj->friction) & FINEMASK; + + if (!(prevfa > (FINEMASK/2)) && (fa > (FINEMASK/2))) // completed a full swing + dosound = true; + + unit_lengthways[0] = FixedMul(FINECOSINE(fa), radius); + unit_lengthways[2] = FixedMul(FINESINE(fa), radius); + } + + // Calculate the angle matrixes for the link. + res = VectorMatrixMultiply(unit_lengthways, *RotateXMatrix(center->threshold << ANGLETOFINESHIFT)); + M_Memcpy(&unit_lengthways, res, sizeof(unit_lengthways)); + res = VectorMatrixMultiply(unit_lengthways, *RotateZMatrix(center->angle)); + M_Memcpy(&unit_lengthways, res, sizeof(unit_lengthways)); + + lastthreshold = mobj->threshold; + lastfriction = mobj->friction; + } + + if (dosound && (mobj->flags2 & MF2_BOSSNOTRAP)) + { + S_StartSound(mobj, mobj->info->activesound); + dosound = false; + } + + if (pos_sideways[3] != mobj->movefactor) + { + if (!unit_sideways[3]) + { + unit_sideways[1] = dist; + unit_sideways[0] = unit_sideways[2] = 0; + unit_sideways[3] = FRACUNIT; + + res = VectorMatrixMultiply(unit_sideways, *RotateXMatrix(center->threshold << ANGLETOFINESHIFT)); + M_Memcpy(&unit_sideways, res, sizeof(unit_sideways)); + res = VectorMatrixMultiply(unit_sideways, *RotateZMatrix(center->angle)); + M_Memcpy(&unit_sideways, res, sizeof(unit_sideways)); + } + + if (pos_sideways[3] > mobj->movefactor) + { + do + { + pos_sideways[0] -= unit_sideways[0]; + pos_sideways[1] -= unit_sideways[1]; + pos_sideways[2] -= unit_sideways[2]; + } + while ((--pos_sideways[3]) != mobj->movefactor); + } + else + { + do + { + pos_sideways[0] += unit_sideways[0]; + pos_sideways[1] += unit_sideways[1]; + pos_sideways[2] += unit_sideways[2]; + } + while ((++pos_sideways[3]) != mobj->movefactor); + } + } + + hnext = mobj->hnext; // just in case the mobj is removed + + if (pos_lengthways[3] > mobj->movecount) + { + do + { + pos_lengthways[0] -= unit_lengthways[0]; + pos_lengthways[1] -= unit_lengthways[1]; + pos_lengthways[2] -= unit_lengthways[2]; + } + while ((--pos_lengthways[3]) != mobj->movecount); + } + else if (pos_lengthways[3] < mobj->movecount) + { + do + { + pos_lengthways[0] += unit_lengthways[0]; + pos_lengthways[1] += unit_lengthways[1]; + pos_lengthways[2] += unit_lengthways[2]; + } + while ((++pos_lengthways[3]) != mobj->movecount); + } + + P_UnsetThingPosition(mobj); + + mobj->x = center->x; + mobj->y = center->y; + mobj->z = center->z; + + // Add on the appropriate distances to the center's co-ordinates. + if (pos_lengthways[3]) + { + mobj->x += pos_lengthways[0]; + mobj->y += pos_lengthways[1]; + zstore = pos_lengthways[2] + pos_sideways[2]; + } + else + zstore = pos_sideways[2]; + + mobj->x += pos_sideways[0]; + mobj->y += pos_sideways[1]; + + // Cut the height to align the link with the axis. + if (mobj->type == MT_SMALLMACECHAIN || mobj->type == MT_BIGMACECHAIN || mobj->type == MT_SMALLGRABCHAIN || mobj->type == MT_BIGGRABCHAIN) + zstore -= P_MobjFlip(mobj)*mobj->height/4; + else + zstore -= P_MobjFlip(mobj)*mobj->height/2; + + mobj->z += zstore; + +#if 0 // toaster's testing flashie! + if (!(mobj->movecount & 1) && !(leveltime & TICRATE)) // I had a brainfart and the flashing isn't exactly what I expected it to be, but it's actually much more useful. + mobj->flags2 ^= MF2_DONTDRAW; +#endif + + P_SetThingPosition(mobj); + +#if 0 // toaster's height-clipping dealie! + if (!pos_lengthways[3] || P_MobjWasRemoved(mobj) || (mobj->flags & MF_NOCLIPHEIGHT)) + goto cont; + + if ((fa = ((center->threshold & (FINEMASK/2)) << ANGLETOFINESHIFT)) > ANGLE_45 && fa < ANGLE_135) // only move towards center when the motion is towards/away from the ground, rather than alongside it + goto cont; + + if (mobj->subsector->sector->ffloors) + P_AdjustMobjFloorZ_FFloors(mobj, mobj->subsector->sector, 2); + + if (mobj->floorz > mobj->z) + zstore = (mobj->floorz - zstore); + else if (mobj->ceilingz < mobj->z) + zstore = (mobj->ceilingz - mobj->height - zstore); + else + goto cont; + + zstore = FixedDiv(zstore, dist); // Still needs work... scaling factor is wrong! + + P_UnsetThingPosition(mobj); + + mobj->x -= FixedMul(unit_lengthways[0], zstore); + mobj->y -= FixedMul(unit_lengthways[1], zstore); + + P_SetThingPosition(mobj); + +cont: +#endif + mobj = hnext; + } +} + static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield) { if (!thing->target || thing->target->health <= 0 || !thing->target->player @@ -5907,7 +6802,7 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield) // TODO: Make an MT_SHIELDORB which changes color/states to always match the appropriate shield, // instead of having completely seperate mobjtypes. - if (shield != SH_FORCE) + if (!(shield & SH_FORCE)) { // Regular shields check for themselves only if ((shieldtype_t)(thing->target->player->powers[pw_shield] & SH_NOSTACK) != shield) { @@ -5921,9 +6816,9 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield) return false; } - if (shield == SH_FORCE && thing->movecount != (thing->target->player->powers[pw_shield] & 0xFF)) + if (shield & SH_FORCE && thing->movecount != (thing->target->player->powers[pw_shield] & SH_FORCEHP)) { - thing->movecount = (thing->target->player->powers[pw_shield] & 0xFF); + thing->movecount = (thing->target->player->powers[pw_shield] & SH_FORCEHP); if (thing->movecount < 1) { if (thing->info->painstate) @@ -5943,14 +6838,15 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield) thing->flags |= MF_NOCLIPHEIGHT; thing->eflags = (thing->eflags & ~MFE_VERTICALFLIP)|(thing->target->eflags & MFE_VERTICALFLIP); - P_SetScale(thing, thing->target->scale); + P_SetScale(thing, FixedMul(thing->target->scale, thing->target->player->shieldscale)); + thing->destscale = thing->scale; P_UnsetThingPosition(thing); thing->x = thing->target->x; thing->y = thing->target->y; if (thing->eflags & MFE_VERTICALFLIP) - thing->z = thing->target->z + thing->target->height - thing->height + FixedDiv(P_GetPlayerHeight(thing->target->player) - thing->target->height, 3*FRACUNIT) - FixedMul(2*FRACUNIT, thing->target->scale); + thing->z = thing->target->z + (thing->target->height - thing->height + FixedDiv(P_GetPlayerHeight(thing->target->player) - thing->target->height, 3*FRACUNIT)) - FixedMul(2*FRACUNIT, thing->target->scale); else - thing->z = thing->target->z - FixedDiv(P_GetPlayerHeight(thing->target->player) - thing->target->height, 3*FRACUNIT) + FixedMul(2*FRACUNIT, thing->target->scale); + thing->z = thing->target->z - (FixedDiv(P_GetPlayerHeight(thing->target->player) - thing->target->height, 3*FRACUNIT)) + FixedMul(2*FRACUNIT, thing->target->scale); P_SetThingPosition(thing); P_CheckPosition(thing, thing->x, thing->y); @@ -5973,7 +6869,7 @@ void P_RunShields(void) // run shields for (i = 0; i < numshields; i++) { - P_ShieldLook(shields[i], shields[i]->info->speed); + P_ShieldLook(shields[i], shields[i]->threshold); P_SetTarget(&shields[i], NULL); } numshields = 0; @@ -5981,7 +6877,7 @@ void P_RunShields(void) static boolean P_AddShield(mobj_t *thing) { - shieldtype_t shield = thing->info->speed; + shieldtype_t shield = thing->threshold; if (!thing->target || thing->target->health <= 0 || !thing->target->player || (thing->target->player->powers[pw_shield] & SH_NOSTACK) == SH_NONE || thing->target->player->powers[pw_super] @@ -5991,7 +6887,7 @@ static boolean P_AddShield(mobj_t *thing) return false; } - if (shield != SH_FORCE) + if (!(shield & SH_FORCE)) { // Regular shields check for themselves only if ((shieldtype_t)(thing->target->player->powers[pw_shield] & SH_NOSTACK) != shield) { @@ -6029,11 +6925,18 @@ void P_RunOverlays(void) if (!mo->target) continue; + + if (P_MobjWasRemoved(mo->target)) + { + P_RemoveMobj(mo); + continue; + } + if (!splitscreen /*&& rendermode != render_soft*/) { angle_t viewingangle; - if (players[displayplayer].awayviewtics) + if (players[displayplayer].awayviewtics && players[displayplayer].awayviewmobj != NULL && !P_MobjWasRemoved(players[displayplayer].awayviewmobj)) viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayer].awayviewmobj->x, players[displayplayer].awayviewmobj->y); else if (!camera.chase && players[displayplayer].mo) viewingangle = R_PointToAngle2(mo->target->x, mo->target->y, players[displayplayer].mo->x, players[displayplayer].mo->y); @@ -6053,7 +6956,7 @@ void P_RunOverlays(void) mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP) | (mo->target->eflags & MFE_VERTICALFLIP); mo->scale = mo->destscale = mo->target->scale; - mo->angle = mo->target->angle; + mo->angle = mo->target->angle + mo->movedir; if (!(mo->state->frame & FF_ANIMATE)) zoffs = FixedMul(((signed)mo->state->var2)*FRACUNIT, mo->scale); @@ -6106,12 +7009,14 @@ static void P_RemoveOverlay(mobj_t *thing) { mobj_t *mo; for (mo = overlaycap; mo; mo = mo->hnext) - if (mo->hnext == thing) - { - P_SetTarget(&mo->hnext, thing->hnext); - P_SetTarget(&thing->hnext, NULL); - return; - } + { + if (mo->hnext != thing) + continue; + + P_SetTarget(&mo->hnext, thing->hnext); + P_SetTarget(&thing->hnext, NULL); + return; + } } void A_BossDeath(mobj_t *mo); @@ -6171,6 +7076,3025 @@ static void P_KoopaThinker(mobj_t *koopa) } } +// Spawns and chains the minecart sides. +static void P_SpawnMinecartSegments(mobj_t *mobj, boolean mode) +{ + fixed_t x = mobj->x; + fixed_t y = mobj->y; + fixed_t z = mobj->z; + mobj_t *prevseg = mobj; + mobj_t *seg; + UINT8 i; + + for (i = 0; i < 4; i++) + { + seg = P_SpawnMobj(x, y, z, MT_MINECARTSEG); + P_SetMobjState(seg, (statenum_t)(S_MINECARTSEG_FRONT + i)); + if (i >= 2) + seg->extravalue1 = (i == 2) ? -18 : 18; // make -20/20 when papersprite projection fixed + else + { + seg->extravalue2 = (i == 0) ? 24 : -24; + seg->cusval = -90; + } + if (!mode) + seg->frame &= ~FF_ANIMATE; + P_SetTarget(&prevseg->tracer, seg); + prevseg = seg; + } +} + +// Updates the chained segments. +static void P_UpdateMinecartSegments(mobj_t *mobj) +{ + mobj_t *seg = mobj->tracer; + fixed_t x = mobj->x; + fixed_t y = mobj->y; + fixed_t z = mobj->z; + angle_t ang = mobj->angle; + angle_t fa = (ang >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t c = FINECOSINE(fa); + fixed_t s = FINESINE(fa); + INT32 dx, dy; + INT32 sang; + + while (seg) + { + dx = seg->extravalue1; + dy = seg->extravalue2; + sang = seg->cusval; + P_TeleportMove(seg, x + s*dx + c*dy, y - c*dx + s*dy, z); + seg->angle = ang + FixedAngle(FRACUNIT*sang); + seg->flags2 = (seg->flags2 & ~MF2_DONTDRAW) | (mobj->flags2 & MF2_DONTDRAW); + seg = seg->tracer; + } +} + +void P_HandleMinecartSegments(mobj_t *mobj) +{ + if (!mobj->tracer) + P_SpawnMinecartSegments(mobj, (mobj->type == MT_MINECART)); + P_UpdateMinecartSegments(mobj); +} + +static void P_PyreFlyBurn(mobj_t *mobj, fixed_t hoffs, INT16 vrange, mobjtype_t mobjtype, fixed_t momz) +{ + angle_t fa = (FixedAngle(P_RandomKey(360)*FRACUNIT) >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t xoffs = FixedMul(FINECOSINE(fa), mobj->radius + hoffs); + fixed_t yoffs = FixedMul(FINESINE(fa), mobj->radius + hoffs); + fixed_t zoffs = P_RandomRange(-vrange, vrange)*FRACUNIT; + mobj_t *particle = P_SpawnMobjFromMobj(mobj, xoffs, yoffs, zoffs, mobjtype); + particle->momz = momz; +} + +static void P_MobjScaleThink(mobj_t *mobj) +{ + fixed_t oldheight = mobj->height; + UINT8 correctionType = 0; // Don't correct Z position, just gain height + + if ((mobj->flags & MF_NOCLIPHEIGHT || (mobj->z > mobj->floorz && mobj->z + mobj->height < mobj->ceilingz)) + && mobj->type != MT_EGGMOBILE_FIRE) + correctionType = 1; // Correct Z position by centering + else if (mobj->eflags & MFE_VERTICALFLIP) + correctionType = 2; // Correct Z position by moving down + + if (abs(mobj->scale - mobj->destscale) < mobj->scalespeed) + P_SetScale(mobj, mobj->destscale); + else if (mobj->scale < mobj->destscale) + P_SetScale(mobj, mobj->scale + mobj->scalespeed); + else if (mobj->scale > mobj->destscale) + P_SetScale(mobj, mobj->scale - mobj->scalespeed); + + if (correctionType == 1) + mobj->z -= (mobj->height - oldheight)/2; + else if (correctionType == 2) + mobj->z -= mobj->height - oldheight; + + if (mobj->scale == mobj->destscale) + /// \todo Lua hook for "reached destscale"? + switch (mobj->type) + { + case MT_EGGMOBILE_FIRE: + mobj->destscale = FRACUNIT; + mobj->scalespeed = FRACUNIT>>4; + break; + default: + break; + } +} + +static void P_MaceSceneryThink(mobj_t *mobj) +{ + angle_t oldmovedir = mobj->movedir; + + // Always update movedir to prevent desyncing (in the traditional sense, not the netplay sense). + mobj->movedir = (mobj->movedir + mobj->lastlook) & FINEMASK; + + // If too far away and not deliberately spitting in the face of optimisation, don't think! + if (!(mobj->flags2 & MF2_BOSSNOTRAP)) + { + UINT8 i; + // Quick! Look through players! Don't move unless a player is relatively close by. + // The below is selected based on CEZ2's first room. I promise you it is a coincidence that it looks like the weed number. + for (i = 0; i < MAXPLAYERS; ++i) + if (playeringame[i] && players[i].mo + && P_AproxDistance(P_AproxDistance(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y), mobj->z - players[i].mo->z) < (4200 << FRACBITS)) + break; // Stop looking. + if (i == MAXPLAYERS) + { + if (!(mobj->flags2 & MF2_BEYONDTHEGRAVE)) + { + mobj_t *ref = mobj; + + // stop/hide all your babies + while ((ref = ref->hnext)) + { + ref->eflags = (((ref->flags & MF_NOTHINK) ? 0 : 1) + | ((ref->flags & MF_NOCLIPTHING) ? 0 : 2) + | ((ref->flags2 & MF2_DONTDRAW) ? 0 : 4)); // oh my god this is nasty. + ref->flags |= MF_NOTHINK|MF_NOCLIPTHING; + ref->flags2 |= MF2_DONTDRAW; + ref->momx = ref->momy = ref->momz = 0; + } + + mobj->flags2 |= MF2_BEYONDTHEGRAVE; + } + return; // don't make bubble! + } + else if (mobj->flags2 & MF2_BEYONDTHEGRAVE) + { + mobj_t *ref = mobj; + + // start/show all your babies + while ((ref = ref->hnext)) + { + if (ref->eflags & 1) + ref->flags &= ~MF_NOTHINK; + if (ref->eflags & 2) + ref->flags &= ~MF_NOCLIPTHING; + if (ref->eflags & 4) + ref->flags2 &= ~MF2_DONTDRAW; + ref->eflags = 0; // le sign + } + + mobj->flags2 &= ~MF2_BEYONDTHEGRAVE; + } + } + + // Okay, time to MOVE + P_MaceRotate(mobj, mobj->movedir, oldmovedir); +} + +static boolean P_DrownNumbersSceneryThink(mobj_t *mobj) +{ + if (!mobj->target) + { + P_RemoveMobj(mobj); + return false; + } + if (!mobj->target->player || !(mobj->target->player->powers[pw_underwater] || mobj->target->player->powers[pw_spacetime])) + { + P_RemoveMobj(mobj); + return false; + } + mobj->x = mobj->target->x; + mobj->y = mobj->target->y; + + mobj->destscale = mobj->target->destscale; + P_SetScale(mobj, mobj->target->scale); + + if (mobj->target->eflags & MFE_VERTICALFLIP) + { + mobj->z = mobj->target->z - FixedMul(16*FRACUNIT, mobj->target->scale) - mobj->height; + if (mobj->target->player->pflags & PF_FLIPCAM) + mobj->eflags |= MFE_VERTICALFLIP; + } + else + mobj->z = mobj->target->z + (mobj->target->height) + FixedMul(8*FRACUNIT, mobj->target->scale); // Adjust height for height changes + + if (mobj->threshold <= 35) + mobj->flags2 |= MF2_DONTDRAW; + else + mobj->flags2 &= ~MF2_DONTDRAW; + if (mobj->threshold <= 30) + mobj->threshold = 40; + mobj->threshold--; + return true; +} + +static void P_FlameJetSceneryThink(mobj_t *mobj) +{ + mobj_t *flame; + fixed_t strength; + + if (!(mobj->flags2 & MF2_FIRING)) + return; + + if ((leveltime & 3) != 0) + return; + + // Wave the flames back and forth. Reactiontime determines which direction it's going. + if (mobj->fuse <= -16) + mobj->reactiontime = 1; + else if (mobj->fuse >= 16) + mobj->reactiontime = 0; + + if (mobj->reactiontime) + mobj->fuse += 2; + else + mobj->fuse -= 2; + + flame = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_FLAMEJETFLAME); + P_SetMobjState(flame, S_FLAMEJETFLAME4); + + flame->angle = mobj->angle; + + if (mobj->flags2 & MF2_AMBUSH) // Wave up and down instead of side-to-side + flame->momz = mobj->fuse << (FRACBITS - 2); + else + flame->angle += FixedAngle(mobj->fuse<movedir; + + P_InstaThrust(flame, flame->angle, strength); + S_StartSound(flame, sfx_fire); +} + +static void P_VerticalFlameJetSceneryThink(mobj_t *mobj) +{ + mobj_t *flame; + fixed_t strength; + + if (!(mobj->flags2 & MF2_FIRING)) + return; + + if ((leveltime & 3) != 0) + return; + + // Wave the flames back and forth. Reactiontime determines which direction it's going. + if (mobj->fuse <= -16) + mobj->reactiontime = 1; + else if (mobj->fuse >= 16) + mobj->reactiontime = 0; + + if (mobj->reactiontime) + mobj->fuse++; + else + mobj->fuse--; + + flame = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_FLAMEJETFLAME); + + strength = 20*FRACUNIT; + strength -= ((20*FRACUNIT)/16)*mobj->movedir; + + // If deaf'd, the object spawns on the ceiling. + if (mobj->flags2 & MF2_AMBUSH) + { + mobj->z = mobj->ceilingz - mobj->height; + flame->momz = -strength; + } + else + { + flame->momz = strength; + P_SetMobjState(flame, S_FLAMEJETFLAME7); + } + P_InstaThrust(flame, mobj->angle, FixedDiv(mobj->fuse*FRACUNIT, 3*FRACUNIT)); + S_StartSound(flame, sfx_fire); +} + +static boolean P_ParticleGenSceneryThink(mobj_t *mobj) +{ + if (!mobj->lastlook) + return false; + + if (!mobj->threshold) + return false; + + if (--mobj->fuse <= 0) + { + INT32 i = 0; + mobj_t *spawn; + fixed_t bottomheight, topheight; + INT32 type = mobj->threshold, line = mobj->cvmem; + + mobj->fuse = (tic_t)mobj->reactiontime; + + bottomheight = lines[line].frontsector->floorheight; + topheight = lines[line].frontsector->ceilingheight - mobjinfo[(mobjtype_t)type].height; + + if (mobj->waterbottom != bottomheight || mobj->watertop != topheight) + { + if (mobj->movefactor && (topheight > bottomheight)) + mobj->health = (tic_t)(FixedDiv((topheight - bottomheight), abs(mobj->movefactor)) >> FRACBITS); + else + mobj->health = 0; + + mobj->z = ((mobj->flags2 & MF2_OBJECTFLIP) ? topheight : bottomheight); + } + + if (!mobj->health) + return false; + + for (i = 0; i < mobj->lastlook; i++) + { + spawn = P_SpawnMobj( + mobj->x + FixedMul(FixedMul(mobj->friction, mobj->scale), FINECOSINE(mobj->angle >> ANGLETOFINESHIFT)), + mobj->y + FixedMul(FixedMul(mobj->friction, mobj->scale), FINESINE(mobj->angle >> ANGLETOFINESHIFT)), + mobj->z, + (mobjtype_t)mobj->threshold); + P_SetScale(spawn, mobj->scale); + spawn->momz = FixedMul(mobj->movefactor, spawn->scale); + spawn->destscale = spawn->scale/100; + spawn->scalespeed = spawn->scale/mobj->health; + spawn->tics = (tic_t)mobj->health; + spawn->flags2 |= (mobj->flags2 & MF2_OBJECTFLIP); + spawn->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones + + mobj->angle += mobj->movedir; + } + + mobj->angle += (angle_t)mobj->movecount; + } + + return true; +} + +static void P_RosySceneryThink(mobj_t *mobj) +{ + UINT8 i; + fixed_t pdist = 1700*mobj->scale, work, actualwork; + player_t *player = NULL; + statenum_t stat = (mobj->state - states); + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + if (!players[i].mo) + continue; + if (players[i].bot) + continue; + if (!players[i].mo->health) + continue; + actualwork = work = FixedHypot(mobj->x - players[i].mo->x, mobj->y - players[i].mo->y); + if (player) + { + if (players[i].skin == 0 || players[i].skin == 5) + work = (2*work)/3; + if (work >= pdist) + continue; + } + pdist = actualwork; + player = &players[i]; + } + + if (stat == S_ROSY_JUMP || stat == S_ROSY_PAIN) + { + if (P_IsObjectOnGround(mobj)) + { + mobj->momx = mobj->momy = 0; + if (player && mobj->cvmem < (-2*TICRATE)) + stat = S_ROSY_UNHAPPY; + else + stat = S_ROSY_WALK; + P_SetMobjState(mobj, stat); + } + else if (P_MobjFlip(mobj)*mobj->momz < 0) + mobj->frame = mobj->state->frame + mobj->state->var1; + } + + if (!player) + { + if ((stat < S_ROSY_IDLE1 || stat > S_ROSY_IDLE4) && stat != S_ROSY_JUMP) + { + mobj->momx = mobj->momy = 0; + P_SetMobjState(mobj, S_ROSY_IDLE1); + } + } + else + { + boolean dojump = false, targonground, love, makeheart = false; + if (mobj->target != player->mo) + P_SetTarget(&mobj->target, player->mo); + // Tatsuru: Don't try to hug them if they're above or below you! + targonground = (P_IsObjectOnGround(mobj->target) && (player->panim == PA_IDLE || player->panim == PA_WALK || player->panim == PA_RUN) && player->mo->z == mobj->z); + love = (player->skin == 0 || player->skin == 5); + + switch (stat) + { + case S_ROSY_IDLE1: + case S_ROSY_IDLE2: + case S_ROSY_IDLE3: + case S_ROSY_IDLE4: + dojump = true; + break; + case S_ROSY_JUMP: + case S_ROSY_PAIN: + // handled above + break; + case S_ROSY_WALK: + { + fixed_t x = mobj->x, y = mobj->y, z = mobj->z; + angle_t angletoplayer = R_PointToAngle2(x, y, mobj->target->x, mobj->target->y); + boolean allowed = P_TryMove(mobj, mobj->target->x, mobj->target->y, false); + + P_UnsetThingPosition(mobj); + mobj->x = x; + mobj->y = y; + mobj->z = z; + P_SetThingPosition(mobj); + + if (allowed) + { + fixed_t mom, max; + P_Thrust(mobj, angletoplayer, (3*FRACUNIT) >> 1); + mom = FixedHypot(mobj->momx, mobj->momy); + max = pdist; + if ((--mobj->extravalue1) <= 0) + { + if (++mobj->frame > mobj->state->frame + mobj->state->var1) + mobj->frame = mobj->state->frame; + if (mom > 12*mobj->scale) + mobj->extravalue1 = 2; + else if (mom > 6*mobj->scale) + mobj->extravalue1 = 3; + else + mobj->extravalue1 = 4; + } + if (max < (mobj->radius + mobj->target->radius)) + { + mobj->momx = mobj->target->player->cmomx; + mobj->momy = mobj->target->player->cmomy; + if ((mobj->cvmem > TICRATE && !player->exiting) || !targonground) + P_SetMobjState(mobj, (stat = S_ROSY_STND)); + else + { + mobj->target->momx = mobj->momx; + mobj->target->momy = mobj->momy; + P_SetMobjState(mobj, (stat = S_ROSY_HUG)); + S_StartSound(mobj, sfx_cdpcm6); + mobj->angle = angletoplayer; + } + } + else + { + max /= 3; + if (max > 30*mobj->scale) + max = 30*mobj->scale; + if (mom > max && max > mobj->scale) + { + max = FixedDiv(max, mom); + mobj->momx = FixedMul(mobj->momx, max); + mobj->momy = FixedMul(mobj->momy, max); + } + if (abs(mobj->momx) > mobj->scale || abs(mobj->momy) > mobj->scale) + mobj->angle = R_PointToAngle2(0, 0, mobj->momx, mobj->momy); + } + } + else + dojump = true; + } + break; + case S_ROSY_HUG: + if (targonground) + { + player->pflags |= PF_STASIS; + if (mobj->cvmem < 5*TICRATE) + mobj->cvmem++; + if (love && !(leveltime & 7)) + makeheart = true; + } + else + { + if (mobj->cvmem < (love ? 5*TICRATE : 0)) + { + P_SetMobjState(mobj, (stat = S_ROSY_PAIN)); + S_StartSound(mobj, sfx_cdpcm7); + } + else + P_SetMobjState(mobj, (stat = S_ROSY_JUMP)); + var1 = var2 = 0; + A_DoNPCPain(mobj); + mobj->cvmem -= TICRATE; + } + break; + case S_ROSY_STND: + if ((pdist > (mobj->radius + mobj->target->radius + 3*(mobj->scale + mobj->target->scale)))) + P_SetMobjState(mobj, (stat = S_ROSY_WALK)); + else if (!targonground) + ; + else + { + if (love && !(leveltime & 15)) + makeheart = true; + if (player->exiting || --mobj->cvmem < TICRATE) + { + P_SetMobjState(mobj, (stat = S_ROSY_HUG)); + S_StartSound(mobj, sfx_cdpcm6); + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + mobj->target->momx = mobj->momx; + mobj->target->momy = mobj->momy; + } + } + break; + case S_ROSY_UNHAPPY: + default: + break; + } + + if (stat == S_ROSY_HUG) + { + if (player->panim != PA_IDLE) + P_SetPlayerMobjState(mobj->target, S_PLAY_STND); + player->pflags |= PF_STASIS; + } + + if (dojump) + { + P_SetMobjState(mobj, S_ROSY_JUMP); + mobj->z += P_MobjFlip(mobj); + mobj->momx = mobj->momy = 0; + P_SetObjectMomZ(mobj, 6 << FRACBITS, false); + S_StartSound(mobj, sfx_cdfm02); + } + + if (makeheart) + { + mobj_t *cdlhrt = P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_CDLHRT); + cdlhrt->destscale = (5*mobj->scale) >> 4; + P_SetScale(cdlhrt, cdlhrt->destscale); + cdlhrt->fuse = (5*TICRATE) >> 1; + cdlhrt->momz = mobj->scale; + P_SetTarget(&cdlhrt->target, mobj); + cdlhrt->extravalue1 = mobj->x; + cdlhrt->extravalue2 = mobj->y; + } + } +} + +static void P_MobjSceneryThink(mobj_t *mobj) +{ + if (LUAh_MobjThinker(mobj)) + return; + if (P_MobjWasRemoved(mobj)) + return; + + if ((mobj->flags2 & MF2_SHIELD) && !P_AddShield(mobj)) + return; + + switch (mobj->type) + { + case MT_BOSSJUNK: + mobj->flags2 ^= MF2_DONTDRAW; + break; + case MT_MACEPOINT: + case MT_CHAINMACEPOINT: + case MT_SPRINGBALLPOINT: + case MT_CHAINPOINT: + case MT_FIREBARPOINT: + case MT_CUSTOMMACEPOINT: + case MT_HIDDEN_SLING: + P_MaceSceneryThink(mobj); + break; + case MT_HOOP: + if (mobj->fuse > 1) + P_MoveHoop(mobj); + else if (mobj->fuse == 1) + mobj->movecount = 1; + + if (mobj->movecount) + { + mobj->fuse++; + + if (mobj->fuse > 32) + { + // Don't kill the hoop center. For the sake of respawning. + //if (mobj->target) + // P_RemoveMobj(mobj->target); + + P_RemoveMobj(mobj); + } + } + else + mobj->fuse--; + return; + case MT_NIGHTSPARKLE: + if (mobj->tics != -1) + { + mobj->tics--; + + // you can cycle through multiple states in a tic + if (!mobj->tics) + if (!P_SetMobjState(mobj, mobj->state->nextstate)) + return; // freed itself + } + + P_UnsetThingPosition(mobj); + mobj->x += mobj->momx; + mobj->y += mobj->momy; + mobj->z += mobj->momz; + P_SetThingPosition(mobj); + return; + case MT_NIGHTSLOOPHELPER: + if (--mobj->tics <= 0) + P_RemoveMobj(mobj); + + // Don't touch my fuse! + return; + case MT_OVERLAY: + if (!mobj->target) + { + P_RemoveMobj(mobj); + return; + } + else + P_AddOverlay(mobj); + break; + case MT_PITY_ORB: + case MT_WHIRLWIND_ORB: + case MT_ARMAGEDDON_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + break; + case MT_ATTRACT_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + if (/*(mobj->target) -- the following is implicit by P_AddShield + && (mobj->target->player) + && */ (mobj->target->player->homing) && (mobj->target->player->pflags & PF_SHIELDABILITY)) + { + P_SetMobjState(mobj, mobj->info->painstate); + mobj->tics++; + } + break; + case MT_ELEMENTAL_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + if (mobj->tracer + /* && mobj->target -- the following is implicit by P_AddShield + && mobj->target->player + && (mobj->target->player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL */ + && mobj->target->player->pflags & PF_SHIELDABILITY + && ((statenum_t)(mobj->tracer->state - states) < mobj->info->raisestate + || (mobj->tracer->state->nextstate < mobj->info->raisestate && mobj->tracer->tics == 1))) + { + P_SetMobjState(mobj, mobj->info->painstate); + mobj->tics++; + P_SetMobjState(mobj->tracer, mobj->info->raisestate); + mobj->tracer->tics++; + } + break; + case MT_FORCE_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + if (/* + && mobj->target -- the following is implicit by P_AddShield + && mobj->target->player + && (mobj->target->player->powers[pw_shield] & SH_FORCE) + && */ (mobj->target->player->pflags & PF_SHIELDABILITY)) + { + mobj_t *whoosh = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_GHOST); // done here so the offset is correct + P_SetMobjState(whoosh, mobj->info->raisestate); + whoosh->destscale = whoosh->scale << 1; + whoosh->scalespeed = FixedMul(whoosh->scalespeed, whoosh->scale); + whoosh->height = 38*whoosh->scale; + whoosh->fuse = 10; + whoosh->flags |= MF_NOCLIPHEIGHT; + whoosh->momz = mobj->target->momz; // Stay reasonably centered for a few frames + mobj->target->player->pflags &= ~PF_SHIELDABILITY; // prevent eternal whoosh + } + /* FALLTHRU */ + case MT_FLAMEAURA_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + if ((statenum_t)(mobj->state - states) < mobj->info->painstate) + mobj->angle = mobj->target->angle; // implicitly okay because of P_AddShield + if (mobj->tracer + /* && mobj->target -- the following is implicit by P_AddShield + && mobj->target->player + && (mobj->target->player->powers[pw_shield] & SH_NOSTACK) == SH_FLAMEAURA */ + && mobj->target->player->pflags & PF_SHIELDABILITY + && ((statenum_t)(mobj->tracer->state - states) < mobj->info->raisestate + || (mobj->tracer->state->nextstate < mobj->info->raisestate && mobj->tracer->tics == 1))) + { + P_SetMobjState(mobj, mobj->info->painstate); + mobj->tics++; + P_SetMobjState(mobj->tracer, mobj->info->raisestate); + mobj->tracer->tics++; + } + break; + case MT_BUBBLEWRAP_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + if (mobj->tracer + /* && mobj->target -- the following is implicit by P_AddShield + && mobj->target->player + && (mobj->target->player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP */ + ) + { + if (mobj->target->player->pflags & PF_SHIELDABILITY + && ((statenum_t)(mobj->state - states) < mobj->info->painstate + || (mobj->state->nextstate < mobj->info->painstate && mobj->tics == 1))) + { + P_SetMobjState(mobj, mobj->info->painstate); + mobj->tics++; + P_SetMobjState(mobj->tracer, mobj->info->raisestate); + mobj->tracer->tics++; + } + else if (mobj->target->eflags & MFE_JUSTHITFLOOR + && (statenum_t)(mobj->state - states) == mobj->info->painstate) + { + P_SetMobjState(mobj, mobj->info->painstate + 1); + mobj->tics++; + P_SetMobjState(mobj->tracer, mobj->info->raisestate + 1); + mobj->tracer->tics++; + } + } + break; + case MT_THUNDERCOIN_ORB: + if (!(mobj->flags2 & MF2_SHIELD)) + return; + if (mobj->tracer + /* && mobj->target -- the following is implicit by P_AddShield + && mobj->target->player + && (mobj->target->player->powers[pw_shield] & SH_NOSTACK) == SH_THUNDERCOIN */ + && (mobj->target->player->pflags & PF_SHIELDABILITY)) + { + P_SetMobjState(mobj, mobj->info->painstate); + mobj->tics++; + P_SetMobjState(mobj->tracer, mobj->info->raisestate); + mobj->tracer->tics++; + mobj->target->player->pflags &= ~PF_SHIELDABILITY; // prevent eternal spark + } + break; + case MT_WATERDROP: + P_SceneryCheckWater(mobj); + if ((mobj->z <= mobj->floorz || mobj->z <= mobj->watertop) + && mobj->health > 0) + { + mobj->health = 0; + P_SetMobjState(mobj, mobj->info->deathstate); + S_StartSound(mobj, mobj->info->deathsound + P_RandomKey(mobj->info->mass)); + return; + } + break; + case MT_BUBBLES: + P_SceneryCheckWater(mobj); + break; + case MT_SMALLBUBBLE: + case MT_MEDIUMBUBBLE: + case MT_EXTRALARGEBUBBLE: // start bubble dissipate + P_SceneryCheckWater(mobj); + if (P_MobjWasRemoved(mobj)) // bubble was removed by not being in water + return; + if (!(mobj->eflags & MFE_UNDERWATER) + || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + mobj->height >= mobj->ceilingz) + || (mobj->eflags & MFE_VERTICALFLIP && mobj->z <= mobj->floorz) + || (P_CheckDeathPitCollide(mobj)) + || --mobj->fuse <= 0) // Bubbles eventually dissipate if they can't reach the surface. + { + // no playing sound: no point; the object is being removed + P_RemoveMobj(mobj); + return; + } + break; + case MT_LOCKON: + if (!mobj->target) + { + P_RemoveMobj(mobj); + return; + } + + mobj->flags2 &= ~MF2_DONTDRAW; + + mobj->x = mobj->target->x; + mobj->y = mobj->target->y; + + mobj->eflags |= (mobj->target->eflags & MFE_VERTICALFLIP); + + mobj->destscale = mobj->target->destscale; + P_SetScale(mobj, mobj->target->scale); + + if (!(mobj->eflags & MFE_VERTICALFLIP)) + mobj->z = mobj->target->z + mobj->target->height + FixedMul((16 + abs((signed)(leveltime % TICRATE) - TICRATE/2))*FRACUNIT, mobj->target->scale); + else + mobj->z = mobj->target->z - FixedMul((16 + abs((signed)(leveltime % TICRATE) - TICRATE/2))*FRACUNIT, mobj->target->scale) - mobj->height; + break; + case MT_LOCKONINF: + if (!(mobj->flags2 & MF2_STRONGBOX)) + { + mobj->threshold = mobj->z; + mobj->flags2 |= MF2_STRONGBOX; + } + if (!(mobj->eflags & MFE_VERTICALFLIP)) + mobj->z = mobj->threshold + FixedMul((16 + abs((signed)(leveltime % TICRATE) - TICRATE/2))*FRACUNIT, mobj->scale); + else + mobj->z = mobj->threshold - FixedMul((16 + abs((signed)(leveltime % TICRATE) - TICRATE/2))*FRACUNIT, mobj->scale); + break; + case MT_DROWNNUMBERS: + if (!P_DrownNumbersSceneryThink(mobj)) + return; + break; + case MT_FLAMEJET: + P_FlameJetSceneryThink(mobj); + break; + case MT_VERTICALFLAMEJET: + P_VerticalFlameJetSceneryThink(mobj); + break; + case MT_FLICKY_01_CENTER: + case MT_FLICKY_02_CENTER: + case MT_FLICKY_03_CENTER: + case MT_FLICKY_04_CENTER: + case MT_FLICKY_05_CENTER: + case MT_FLICKY_06_CENTER: + case MT_FLICKY_07_CENTER: + case MT_FLICKY_08_CENTER: + case MT_FLICKY_09_CENTER: + case MT_FLICKY_10_CENTER: + case MT_FLICKY_11_CENTER: + case MT_FLICKY_12_CENTER: + case MT_FLICKY_13_CENTER: + case MT_FLICKY_14_CENTER: + case MT_FLICKY_15_CENTER: + case MT_FLICKY_16_CENTER: + case MT_SECRETFLICKY_01_CENTER: + case MT_SECRETFLICKY_02_CENTER: + if (mobj->tracer && (mobj->flags & MF_NOCLIPTHING) + && (mobj->flags & MF_GRENADEBOUNCE)) + // for now: only do this bounce routine if flicky is in-place. \todo allow in all movements + { + if (!(mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z <= mobj->tracer->floorz) + mobj->tracer->momz = 7*FRACUNIT; + else if ((mobj->tracer->flags2 & MF2_OBJECTFLIP) && mobj->tracer->z >= mobj->tracer->ceilingz - mobj->tracer->height) + mobj->tracer->momz = -7*FRACUNIT; + } + break; + case MT_SEED: + if (P_MobjFlip(mobj)*mobj->momz < mobj->info->speed) + mobj->momz = P_MobjFlip(mobj)*mobj->info->speed; + break; + case MT_ROCKCRUMBLE1: + case MT_ROCKCRUMBLE2: + case MT_ROCKCRUMBLE3: + case MT_ROCKCRUMBLE4: + case MT_ROCKCRUMBLE5: + case MT_ROCKCRUMBLE6: + case MT_ROCKCRUMBLE7: + case MT_ROCKCRUMBLE8: + case MT_ROCKCRUMBLE9: + case MT_ROCKCRUMBLE10: + case MT_ROCKCRUMBLE11: + case MT_ROCKCRUMBLE12: + case MT_ROCKCRUMBLE13: + case MT_ROCKCRUMBLE14: + case MT_ROCKCRUMBLE15: + case MT_ROCKCRUMBLE16: + case MT_WOODDEBRIS: + case MT_BRICKDEBRIS: + case MT_BROKENROBOT: + if (mobj->z <= P_FloorzAtPos(mobj->x, mobj->y, mobj->z, mobj->height) + && mobj->state != &states[mobj->info->deathstate]) + { + P_SetMobjState(mobj, mobj->info->deathstate); + return; + } + break; + case MT_PARTICLEGEN: + if (!P_ParticleGenSceneryThink(mobj)) + return; + break; + case MT_FSGNA: + if (mobj->movedir) + mobj->angle += mobj->movedir; + break; + case MT_ROSY: + P_RosySceneryThink(mobj); + break; + case MT_CDLHRT: + { + if (mobj->cvmem < 24) + mobj->cvmem++; + mobj->movedir += ANG10; + P_UnsetThingPosition(mobj); + mobj->x = mobj->extravalue1 + P_ReturnThrustX(mobj, mobj->movedir, mobj->cvmem*mobj->scale); + mobj->y = mobj->extravalue2 + P_ReturnThrustY(mobj, mobj->movedir, mobj->cvmem*mobj->scale); + P_SetThingPosition(mobj); + + if (!mobj->fuse) + { + if (!LUAh_MobjFuse(mobj)) + P_RemoveMobj(mobj); + return; + } + if (mobj->fuse < 0) + return; + if (mobj->fuse < 6) + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | ((10 - (mobj->fuse*2)) << (FF_TRANSSHIFT)); + mobj->fuse--; + } + break; + case MT_FINISHFLAG: + { + if (!mobj->target || mobj->target->player->playerstate == PST_DEAD || !cv_exitmove.value) + { + P_RemoveMobj(mobj); + return; + } + + if (!camera.chase) + mobj->flags2 |= MF2_DONTDRAW; + else + mobj->flags2 &= ~MF2_DONTDRAW; + + P_UnsetThingPosition(mobj); + { + fixed_t radius = FixedMul(10*mobj->info->speed, mobj->target->scale); + angle_t fa; + + mobj->angle += FixedAngle(mobj->info->speed); + + fa = mobj->angle >> ANGLETOFINESHIFT; + + mobj->x = mobj->target->x + FixedMul(FINECOSINE(fa),radius); + mobj->y = mobj->target->y + FixedMul(FINESINE(fa),radius); + mobj->z = mobj->target->z + mobj->target->height/2; + } + P_SetThingPosition(mobj); + + P_SetScale(mobj, mobj->target->scale); + } + break; + case MT_VWREF: + case MT_VWREB: + { + INT32 strength; + ++mobj->movedir; + mobj->frame &= ~FF_TRANSMASK; + strength = min(mobj->fuse, (INT32)mobj->movedir)*3; + if (strength < 10) + mobj->frame |= ((10 - strength) << (FF_TRANSSHIFT)); + } + /* FALLTHRU */ + default: + if (mobj->fuse) + { // Scenery object fuse! Very basic! + mobj->fuse--; + if (!mobj->fuse) + { + if (!LUAh_MobjFuse(mobj)) + P_RemoveMobj(mobj); + return; + } + } + break; + } + + P_SceneryThinker(mobj); +} + +static boolean P_MobjPushableThink(mobj_t *mobj) +{ + P_MobjCheckWater(mobj); + P_PushableThinker(mobj); + + // Extinguish fire objects in water. (Yes, it's extraordinarily rare to have a pushable flame object, but Brak uses such a case.) + if (mobj->flags & MF_FIRE && mobj->type != MT_PUMA && mobj->type != MT_FIREBALL + && (mobj->eflags & (MFE_UNDERWATER | MFE_TOUCHWATER))) + { + P_KillMobj(mobj, NULL, NULL, 0); + return false; + } + + return true; +} + +static boolean P_MobjBossThink(mobj_t *mobj) +{ + if (LUAh_BossThinker(mobj)) + { + if (P_MobjWasRemoved(mobj)) + return false; + } + else if (P_MobjWasRemoved(mobj)) + return false; + else + switch (mobj->type) + { + case MT_EGGMOBILE: + if (mobj->health < mobj->info->damage + 1 && leveltime & 2) + { + fixed_t rad = mobj->radius >> FRACBITS; + fixed_t hei = mobj->height >> FRACBITS; + mobj_t *particle = P_SpawnMobjFromMobj(mobj, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(hei / 2, hei) << FRACBITS, + MT_SMOKE); + P_SetObjectMomZ(particle, 2 << FRACBITS, false); + particle->momz += mobj->momz; + } + if (mobj->flags2 & MF2_SKULLFLY) +#if 1 + P_SpawnGhostMobj(mobj); +#else // all the way back from final demo... MT_THOK isn't even the same size anymore! + { + mobj_t *spawnmobj; + spawnmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->info->painchance); + P_SetTarget(&spawnmobj->target, mobj); + spawnmobj->color = SKINCOLOR_GREY; + } +#endif + P_Boss1Thinker(mobj); + break; + case MT_EGGMOBILE2: + if (mobj->health < mobj->info->damage + 1 && leveltime & 2) + { + fixed_t rad = mobj->radius >> FRACBITS; + fixed_t hei = mobj->height >> FRACBITS; + mobj_t *particle = P_SpawnMobjFromMobj(mobj, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(hei/2, hei) << FRACBITS, + MT_SMOKE); + P_SetObjectMomZ(particle, 2 << FRACBITS, false); + particle->momz += mobj->momz; + } + P_Boss2Thinker(mobj); + break; + case MT_EGGMOBILE3: + if (mobj->health < mobj->info->damage + 1 && leveltime & 2) + { + fixed_t rad = mobj->radius >> FRACBITS; + fixed_t hei = mobj->height >> FRACBITS; + mobj_t *particle = P_SpawnMobjFromMobj(mobj, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(hei/2, hei) << FRACBITS, + MT_SMOKE); + P_SetObjectMomZ(particle, 2 << FRACBITS, false); + particle->momz += mobj->momz; + } + P_Boss3Thinker(mobj); + break; + case MT_EGGMOBILE4: + if (mobj->health < mobj->info->damage + 1 && leveltime & 2) + { + fixed_t rad = mobj->radius >> FRACBITS; + fixed_t hei = mobj->height >> FRACBITS; + mobj_t* particle = P_SpawnMobjFromMobj(mobj, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(rad, -rad) << FRACBITS, + P_RandomRange(hei/2, hei) << FRACBITS, + MT_SMOKE); + P_SetObjectMomZ(particle, 2 << FRACBITS, false); + particle->momz += mobj->momz; + } + P_Boss4Thinker(mobj); + break; + case MT_FANG: + P_Boss5Thinker(mobj); + break; + case MT_BLACKEGGMAN: + P_Boss7Thinker(mobj); + break; + case MT_METALSONIC_BATTLE: + P_Boss9Thinker(mobj); + break; + default: // Generic SOC-made boss + if (mobj->flags2 & MF2_SKULLFLY) + P_SpawnGhostMobj(mobj); + P_GenericBossThinker(mobj); + break; + } + if (mobj->flags2 & MF2_BOSSFLEE) + { + if (mobj->extravalue1) + { + if (!(--mobj->extravalue1)) + { + if (mobj->target) + { + mobj->momz = FixedMul(FixedDiv(mobj->target->z - mobj->z, P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y)), mobj->scale << 1); + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + } + else + mobj->momz = 8*mobj->scale; + } + else + mobj->angle += mobj->movedir; + } + else if (mobj->target) + P_InstaThrust(mobj, mobj->angle, FixedMul(12*FRACUNIT, mobj->scale)); + } + if (mobj->type == MT_CYBRAKDEMON && !mobj->health) + { + if (!(mobj->tics & 1)) + { + var1 = 2; + var2 = 0; + A_BossScream(mobj); + } + if (P_CheckDeathPitCollide(mobj)) + { + P_RemoveMobj(mobj); + return false; + } + if (mobj->momz && mobj->z + mobj->momz <= mobj->floorz) + { + S_StartSound(mobj, sfx_befall); + if (mobj->state != states + S_CYBRAKDEMON_DIE8) + P_SetMobjState(mobj, S_CYBRAKDEMON_DIE8); + } + } + return true; +} + +static boolean P_MobjDeadThink(mobj_t *mobj) +{ + switch (mobj->type) + { + case MT_BLUESPHERE: + if ((mobj->tics >> 2) + 1 > 0 && (mobj->tics >> 2) + 1 <= tr_trans60) // tr_trans50 through tr_trans90, shifting once every second frame + mobj->frame = (NUMTRANSMAPS - ((mobj->tics >> 2) + 1)) << FF_TRANSSHIFT; + else // tr_trans60 otherwise + mobj->frame = tr_trans60 << FF_TRANSSHIFT; + break; + case MT_EGGCAPSULE: + if (mobj->z <= mobj->floorz) + { + P_RemoveMobj(mobj); + return false; + } + break; + case MT_FAKEMOBILE: + if (mobj->scale == mobj->destscale) + { + if (!mobj->fuse) + { + S_StartSound(mobj, sfx_s3k77); + mobj->flags2 |= MF2_DONTDRAW; + mobj->fuse = TICRATE; + } + return false; + } + if (!mobj->reactiontime) + { + if (P_RandomChance(FRACUNIT/2)) + mobj->movefactor = FRACUNIT; + else + mobj->movefactor = -FRACUNIT; + if (P_RandomChance(FRACUNIT/2)) + mobj->movedir = ANG20; + else + mobj->movedir = -ANG20; + mobj->reactiontime = 5; + } + mobj->momz += mobj->movefactor; + mobj->angle += mobj->movedir; + P_InstaThrust(mobj, mobj->angle, -mobj->info->speed); + mobj->reactiontime--; + break; + case MT_EGGSHIELD: + mobj->flags2 ^= MF2_DONTDRAW; + break; + case MT_EGGTRAP: // Egg Capsule animal release + if (mobj->fuse > 0)// && mobj->fuse < TICRATE-(TICRATE/7)) + { + INT32 i; + fixed_t x, y, z; + fixed_t ns; + mobj_t* mo2; + mobj_t* flicky; + + z = mobj->subsector->sector->floorheight + FRACUNIT + (P_RandomKey(64) << FRACBITS); + for (i = 0; i < 3; i++) + { + const angle_t fa = P_RandomKey(FINEANGLES) & FINEMASK; + ns = 64*FRACUNIT; + x = mobj->x + FixedMul(FINESINE(fa), ns); + y = mobj->y + FixedMul(FINECOSINE(fa), ns); + + mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE); + P_SetMobjStateNF(mo2, S_XPLD_EGGTRAP); // so the flickies don't lose their target if they spawn + ns = 4*FRACUNIT; + mo2->momx = FixedMul(FINESINE(fa), ns); + mo2->momy = FixedMul(FINECOSINE(fa), ns); + mo2->angle = fa << ANGLETOFINESHIFT; + + if (!i && !(mobj->fuse & 2)) + S_StartSound(mo2, mobj->info->deathsound); + + flicky = P_InternalFlickySpawn(mo2, 0, 8*FRACUNIT, false, -1); + if (!flicky) + break; + + P_SetTarget(&flicky->target, mo2); + flicky->momx = mo2->momx; + flicky->momy = mo2->momy; + } + + mobj->fuse--; + } + break; + case MT_PLAYER: + /// \todo Have the player's dead body completely finish its animation even if they've already respawned. + if (!mobj->fuse) + { // Go away. + /// \todo Actually go ahead and remove mobj completely, and fix any bugs and crashes doing this creates. Chasecam should stop moving, and F12 should never return to it. + mobj->momz = 0; + if (mobj->player) + mobj->flags2 |= MF2_DONTDRAW; + else // safe to remove, nobody's going to complain! + { + P_RemoveMobj(mobj); + return false; + } + } + else // Apply gravity to fall downwards. + { + if (mobj->player && !(mobj->fuse % 8) && (mobj->player->charflags & SF_MACHINE)) + { + fixed_t r = mobj->radius >> FRACBITS; + mobj_t *explosion = P_SpawnMobj( + mobj->x + (P_RandomRange(r, -r) << FRACBITS), + mobj->y + (P_RandomRange(r, -r) << FRACBITS), + mobj->z + (P_RandomKey(mobj->height >> FRACBITS) << FRACBITS), + MT_SONIC3KBOSSEXPLODE); + S_StartSound(explosion, sfx_s3kb4); + } + if (mobj->movedir == DMG_DROWNED) + P_SetObjectMomZ(mobj, -FRACUNIT/2, true); // slower fall from drowning + else + P_SetObjectMomZ(mobj, -2*FRACUNIT/3, true); + } + break; + case MT_METALSONIC_RACE: + { + if (!(mobj->fuse % 8)) + { + fixed_t r = mobj->radius >> FRACBITS; + mobj_t *explosion = P_SpawnMobj( + mobj->x + (P_RandomRange(r, -r) << FRACBITS), + mobj->y + (P_RandomRange(r, -r) << FRACBITS), + mobj->z + (P_RandomKey(mobj->height >> FRACBITS) << FRACBITS), + MT_SONIC3KBOSSEXPLODE); + S_StartSound(explosion, sfx_s3kb4); + } + P_SetObjectMomZ(mobj, -2*FRACUNIT/3, true); + } + break; + default: + break; + } + return true; +} + +// Angle-to-tracer to trigger a linedef exec +// See Linedef Exec 457 (Track mobj angle to point) +static void P_TracerAngleThink(mobj_t *mobj) +{ + angle_t ang; + + if (!mobj->tracer) + return; + + if (!mobj->extravalue2) + return; + + // mobj->lastlook - Don't disable behavior after first failure + // mobj->extravalue1 - Angle tolerance + // mobj->extravalue2 - Exec tag upon failure + // mobj->cvval - Allowable failure delay + // mobj->cvmem - Failure timer + + ang = mobj->angle - R_PointToAngle2(mobj->x, mobj->y, mobj->tracer->x, mobj->tracer->y); + + // \todo account for distance between mobj and tracer + // Because closer mobjs can be facing beyond the angle tolerance + // yet tracer is still in the camera view + + // failure state: mobj is not facing tracer + // Reasaonable defaults: ANGLE_67h, ANGLE_292h + if (ang >= (angle_t)mobj->extravalue1 && ang <= ANGLE_MAX - (angle_t)mobj->extravalue1) + { + if (mobj->cvmem) + mobj->cvmem--; + else + { + INT32 exectag = mobj->extravalue2; // remember this before we erase the values + + if (mobj->lastlook) + mobj->cvmem = mobj->cusval; // reset timer for next failure + else + { + // disable after first failure + mobj->eflags &= ~MFE_TRACERANGLE; + mobj->lastlook = mobj->extravalue1 = mobj->extravalue2 = mobj->cvmem = mobj->cusval = 0; + } + + P_LinedefExecute(exectag, mobj, NULL); + } + } + else + mobj->cvmem = mobj->cusval; // reset failure timer +} + +static void P_ArrowThink(mobj_t *mobj) +{ + if (mobj->flags & MF_MISSILE) + { + // Calculate the angle of movement. + /* + momz + / | + / | + / | + 0------dist(momx,momy) + */ + + fixed_t dist = P_AproxDistance(mobj->momx, mobj->momy); + angle_t angle = R_PointToAngle2(0, 0, dist, mobj->momz); + + if (angle > ANG20 && angle <= ANGLE_180) + mobj->frame = 2; + else if (angle < ANG340 && angle > ANGLE_180) + mobj->frame = 0; + else + mobj->frame = 1; + + if (!(mobj->extravalue1) && (mobj->momz < 0)) + { + mobj->extravalue1 = 1; + S_StartSound(mobj, mobj->info->activesound); + } + if (leveltime & 1) + { + mobj_t *dust = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_PARTICLE); + dust->tics = 18; + dust->scalespeed = 4096; + dust->destscale = FRACUNIT/32; + } + } + else + mobj->flags2 ^= MF2_DONTDRAW; +} + +static void P_BumbleboreThink(mobj_t *mobj) +{ + statenum_t st = mobj->state - states; + if (st == S_BUMBLEBORE_FLY1 || st == S_BUMBLEBORE_FLY2) + { + if (!mobj->target) + P_SetMobjState(mobj, mobj->info->spawnstate); + else if (P_MobjFlip(mobj)*((mobj->z + (mobj->height >> 1)) - (mobj->target->z + (mobj->target->height >> 1))) > 0 + && R_PointToDist2(mobj->x, mobj->y, mobj->target->x, mobj->target->y) <= 32*FRACUNIT) + { + mobj->momx >>= 1; + mobj->momy >>= 1; + if (++mobj->movefactor == 4) + { + S_StartSound(mobj, mobj->info->seesound); + mobj->momx = mobj->momy = mobj->momz = 0; + mobj->flags = (mobj->flags|MF_PAIN) & ~MF_NOGRAVITY; + P_SetMobjState(mobj, mobj->info->meleestate); + } + } + else + mobj->movefactor = 0; + } + else if (st == S_BUMBLEBORE_RAISE || st == S_BUMBLEBORE_FALL2) // no _FALL1 because it's an 0-tic + { + if (P_IsObjectOnGround(mobj)) + { + S_StopSound(mobj); + S_StartSound(mobj, mobj->info->attacksound); + mobj->flags = (mobj->flags | MF_NOGRAVITY) & ~MF_PAIN; + mobj->momx = mobj->momy = mobj->momz = 0; + P_SetMobjState(mobj, mobj->info->painstate); + } + else + { + mobj->angle += ANGLE_22h; + mobj->frame = mobj->state->frame + ((mobj->tics & 2) >> 1); + } + } + else if (st == S_BUMBLEBORE_STUCK2 && mobj->tics < TICRATE) + mobj->frame = mobj->state->frame + ((mobj->tics & 2) >> 1); +} + +static boolean P_HangsterThink(mobj_t *mobj) +{ + statenum_t st = mobj->state - states; + //ghost image trail when flying down + if (st == S_HANGSTER_SWOOP1 || st == S_HANGSTER_SWOOP2) + { + P_SpawnGhostMobj(mobj); + //curve when in line with target, otherwise curve to avoid crashing into floor + if ((mobj->z - mobj->floorz <= 80*FRACUNIT) || (mobj->target && (mobj->z - mobj->target->z <= 80*FRACUNIT))) + P_SetMobjState(mobj, (st = S_HANGSTER_ARC1)); + } + + //swoop arc movement stuff + if (st == S_HANGSTER_ARC1) + { + A_FaceTarget(mobj); + P_Thrust(mobj, mobj->angle, 1*FRACUNIT); + } + else if (st == S_HANGSTER_ARC2) + P_Thrust(mobj, mobj->angle, 2*FRACUNIT); + else if (st == S_HANGSTER_ARC3) + P_Thrust(mobj, mobj->angle, 4*FRACUNIT); + //if movement has stopped while flying (like hitting a wall), fly up immediately + else if (st == S_HANGSTER_FLY1 && !mobj->momx && !mobj->momy) + { + mobj->extravalue1 = 0; + P_SetMobjState(mobj, S_HANGSTER_ARCUP1); + } + //after swooping back up, check for ceiling + else if ((st == S_HANGSTER_RETURN1 || st == S_HANGSTER_RETURN2) && mobj->momz == 0 && mobj->ceilingz == (mobj->z + mobj->height)) + P_SetMobjState(mobj, (st = S_HANGSTER_RETURN3)); + + //should you roost on a ceiling with F_SKY1 as its flat, disappear forever + if (st == S_HANGSTER_RETURN3 && mobj->momz == 0 && mobj->ceilingz == (mobj->z + mobj->height) + && mobj->subsector->sector->ceilingpic == skyflatnum + && mobj->subsector->sector->ceilingheight == mobj->ceilingz) + { + P_RemoveMobj(mobj); + return false; + } + + return true; +} + +static boolean P_JetFume1Think(mobj_t *mobj) +{ + fixed_t jetx, jety; + + if (!mobj->target // if you have no target + || (!(mobj->target->flags & MF_BOSS) && mobj->target->health <= 0)) // or your target isn't a boss and it's popped now + { // then remove yourself as well! + P_RemoveMobj(mobj); + return false; + } + + jetx = mobj->target->x + P_ReturnThrustX(mobj->target, mobj->target->angle, FixedMul(-64*FRACUNIT, mobj->target->scale)); + jety = mobj->target->y + P_ReturnThrustY(mobj->target, mobj->target->angle, FixedMul(-64*FRACUNIT, mobj->target->scale)); + + if (mobj->fuse == 56) // First one + { + P_UnsetThingPosition(mobj); + mobj->x = jetx; + mobj->y = jety; + if (mobj->target->eflags & MFE_VERTICALFLIP) + mobj->z = mobj->target->z + mobj->target->height - mobj->height - FixedMul(38*FRACUNIT, mobj->target->scale); + else + mobj->z = mobj->target->z + FixedMul(38*FRACUNIT, mobj->target->scale); + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z + mobj->height; + P_SetThingPosition(mobj); + } + else if (mobj->fuse == 57) + { + P_UnsetThingPosition(mobj); + mobj->x = jetx + P_ReturnThrustX(mobj->target, mobj->target->angle - ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); + mobj->y = jety + P_ReturnThrustY(mobj->target, mobj->target->angle - ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); + if (mobj->target->eflags & MFE_VERTICALFLIP) + mobj->z = mobj->target->z + mobj->target->height - mobj->height - FixedMul(12*FRACUNIT, mobj->target->scale); + else + mobj->z = mobj->target->z + FixedMul(12*FRACUNIT, mobj->target->scale); + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z + mobj->height; + P_SetThingPosition(mobj); + } + else if (mobj->fuse == 58) + { + P_UnsetThingPosition(mobj); + mobj->x = jetx + P_ReturnThrustX(mobj->target, mobj->target->angle + ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); + mobj->y = jety + P_ReturnThrustY(mobj->target, mobj->target->angle + ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); + if (mobj->target->eflags & MFE_VERTICALFLIP) + mobj->z = mobj->target->z + mobj->target->height - mobj->height - FixedMul(12*FRACUNIT, mobj->target->scale); + else + mobj->z = mobj->target->z + FixedMul(12*FRACUNIT, mobj->target->scale); + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z + mobj->height; + P_SetThingPosition(mobj); + } + else if (mobj->fuse == 59) + { + boolean dashmod = ((mobj->target->flags & MF_PAIN) && (mobj->target->health <= mobj->target->info->damage)); + jetx = mobj->target->x + P_ReturnThrustX(mobj->target, mobj->target->angle, -mobj->target->radius); + jety = mobj->target->y + P_ReturnThrustY(mobj->target, mobj->target->angle, -mobj->target->radius); + P_UnsetThingPosition(mobj); + mobj->x = jetx; + mobj->y = jety; + mobj->destscale = mobj->target->scale; + if (!(dashmod && mobj->target->state == states + S_METALSONIC_BOUNCE)) + { + mobj->destscale = (mobj->destscale + FixedDiv(R_PointToDist2(0, 0, mobj->target->momx, mobj->target->momy), 36*mobj->target->scale))/3; + } + if (mobj->target->eflags & MFE_VERTICALFLIP) + mobj->z = mobj->target->z + mobj->target->height/2 + mobj->height/2; + else + mobj->z = mobj->target->z + mobj->target->height/2 - mobj->height/2; + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z + mobj->height; + P_SetThingPosition(mobj); + if (dashmod) + { + mobj->color = SKINCOLOR_SUNSET; + if (mobj->target->movecount == 3 && !mobj->target->reactiontime && (mobj->target->movedir == 0 || mobj->target->movedir == 2)) + P_SpawnGhostMobj(mobj); + } + else + mobj->color = SKINCOLOR_ICY; + } + mobj->fuse++; + return true; +} + +static boolean P_EggRobo1Think(mobj_t *mobj) +{ +#define SPECTATORRADIUS (96*mobj->scale) + if (!(mobj->flags2 & MF2_STRONGBOX)) + { + mobj->cusval = mobj->x; // eat my SOCs, p_mobj.h warning, we have lua now + mobj->cvmem = mobj->y; // ditto + mobj->movedir = mobj->angle; + mobj->threshold = P_MobjFlip(mobj)*10*mobj->scale; + if (mobj->threshold < 0) + mobj->threshold += (mobj->ceilingz - mobj->height); + else + mobj->threshold += mobj->floorz; + var1 = 4; + A_BossJetFume(mobj); + mobj->flags2 |= MF2_STRONGBOX; + } + + if (mobj->state == &states[mobj->info->deathstate]) // todo: make map actually set health to 0 for these + { + if (mobj->movecount) + { + if (!(--mobj->movecount)) + S_StartSound(mobj, mobj->info->deathsound); + } + else + { + mobj->momz += P_MobjFlip(mobj)*mobj->scale; + if (mobj->momz > 0) + { + if (mobj->z + mobj->momz > mobj->ceilingz + (1000 << FRACBITS)) + { + P_RemoveMobj(mobj); + return false; + } + } + else if (mobj->z + mobj->height + mobj->momz < mobj->floorz - (1000 << FRACBITS)) + { + P_RemoveMobj(mobj); + return false; + } + } + } + else + { + fixed_t basex = mobj->cusval, basey = mobj->cvmem; + + if (mobj->spawnpoint && mobj->spawnpoint->options & (MTF_AMBUSH|MTF_OBJECTSPECIAL)) + { + angle_t sideang = mobj->movedir + ((mobj->spawnpoint->options & MTF_AMBUSH) ? ANGLE_90 : -ANGLE_90); + fixed_t oscillate = FixedMul(FINESINE(((leveltime * ANG1) >> (ANGLETOFINESHIFT + 2)) & FINEMASK), 250*mobj->scale); + basex += P_ReturnThrustX(mobj, sideang, oscillate); + basey += P_ReturnThrustY(mobj, sideang, oscillate); + } + + mobj->z = mobj->threshold + FixedMul(FINESINE(((leveltime + mobj->movecount)*ANG2 >> (ANGLETOFINESHIFT - 2)) & FINEMASK), 8*mobj->scale); + if (mobj->state != &states[mobj->info->meleestate]) + { + boolean didmove = false; + + if (mobj->state == &states[mobj->info->spawnstate]) + { + UINT8 i; + fixed_t dist = INT32_MAX; + + for (i = 0; i < MAXPLAYERS; i++) + { + fixed_t compdist; + if (!playeringame[i]) + continue; + if (players[i].spectator) + continue; + if (!players[i].mo) + continue; + if (!players[i].mo->health) + continue; + if (P_PlayerInPain(&players[i])) + continue; + if (players[i].mo->z > mobj->z + mobj->height + 8*mobj->scale) + continue; + if (players[i].mo->z + players[i].mo->height < mobj->z - 8*mobj->scale) + continue; + compdist = P_AproxDistance( + players[i].mo->x + players[i].mo->momx - basex, + players[i].mo->y + players[i].mo->momy - basey); + if (compdist >= dist) + continue; + dist = compdist; + P_SetTarget(&mobj->target, players[i].mo); + } + + if (dist < (SPECTATORRADIUS << 1)) + { + didmove = true; + mobj->frame = 3 + ((leveltime & 2) >> 1); + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + + if (P_AproxDistance( + mobj->x - basex, + mobj->y - basey) + < mobj->scale) + S_StartSound(mobj, mobj->info->seesound); + + P_TeleportMove(mobj, + (15*(mobj->x >> 4)) + (basex >> 4) + P_ReturnThrustX(mobj, mobj->angle, SPECTATORRADIUS >> 4), + (15*(mobj->y >> 4)) + (basey >> 4) + P_ReturnThrustY(mobj, mobj->angle, SPECTATORRADIUS >> 4), + mobj->z); + } + else + { + angle_t diff = (mobj->movedir - mobj->angle); + if (diff > ANGLE_180) + diff = InvAngle(InvAngle(diff)/8); + else + diff /= 8; + mobj->angle += diff; + + dist = FINECOSINE(((leveltime + mobj->movecount)*ANG2 >> (ANGLETOFINESHIFT - 2)) & FINEMASK); + + if (abs(dist) < FRACUNIT/2) + mobj->frame = 0; + else + mobj->frame = (dist > 0) ? 1 : 2; + } + } + + if (!didmove) + { + if (P_AproxDistance(mobj->x - basex, mobj->y - basey) < mobj->scale) + P_TeleportMove(mobj, basex, basey, mobj->z); + else + P_TeleportMove(mobj, + (15*(mobj->x >> 4)) + (basex >> 4), + (15*(mobj->y >> 4)) + (basey >> 4), + mobj->z); + } + } + } + return true; +#undef SPECTATORRADIUS +} + +static void P_NiGHTSDroneThink(mobj_t *mobj) +{ + { + // variable setup + mobj_t *goalpost = NULL; + mobj_t *sparkle = NULL; + mobj_t *droneman = NULL; + + boolean flip = mobj->flags2 & MF2_OBJECTFLIP; + boolean topaligned = (mobj->flags & MF_SLIDEME) && !(mobj->flags & MF_GRENADEBOUNCE); + boolean middlealigned = (mobj->flags & MF_GRENADEBOUNCE) && !(mobj->flags & MF_SLIDEME); + boolean bottomoffsetted = !(mobj->flags & MF_SLIDEME) && !(mobj->flags & MF_GRENADEBOUNCE); + boolean flipchanged = false; + + fixed_t dronemanoffset, goaloffset, sparkleoffset, droneboxmandiff, dronemangoaldiff; + + if (mobj->target && mobj->target->type == MT_NIGHTSDRONE_GOAL) + { + goalpost = mobj->target; + if (goalpost->target && goalpost->target->type == MT_NIGHTSDRONE_SPARKLING) + sparkle = goalpost->target; + if (goalpost->tracer && goalpost->tracer->type == MT_NIGHTSDRONE_MAN) + droneman = goalpost->tracer; + } + + if (!goalpost || !sparkle || !droneman) + return; + + // did NIGHTSDRONE position, scale, flip, or flags change? all elements need to be synced + droneboxmandiff = max(mobj->height - droneman->height, 0); + dronemangoaldiff = max(droneman->height - goalpost->height, 0); + + if (!(goalpost->flags2 & MF2_OBJECTFLIP) && (mobj->flags2 & MF2_OBJECTFLIP)) + { + goalpost->eflags |= MFE_VERTICALFLIP; + goalpost->flags2 |= MF2_OBJECTFLIP; + sparkle->eflags |= MFE_VERTICALFLIP; + sparkle->flags2 |= MF2_OBJECTFLIP; + droneman->eflags |= MFE_VERTICALFLIP; + droneman->flags2 |= MF2_OBJECTFLIP; + flipchanged = true; + } + else if ((goalpost->flags2 & MF2_OBJECTFLIP) && !(mobj->flags2 & MF2_OBJECTFLIP)) + { + goalpost->eflags &= ~MFE_VERTICALFLIP; + goalpost->flags2 &= ~MF2_OBJECTFLIP; + sparkle->eflags &= ~MFE_VERTICALFLIP; + sparkle->flags2 &= ~MF2_OBJECTFLIP; + droneman->eflags &= ~MFE_VERTICALFLIP; + droneman->flags2 &= ~MF2_OBJECTFLIP; + flipchanged = true; + } + + if (goalpost->destscale != mobj->destscale + || goalpost->movefactor != mobj->z + || goalpost->friction != mobj->height + || flipchanged + || goalpost->threshold != (INT32)(mobj->flags & (MF_SLIDEME|MF_GRENADEBOUNCE))) + { + goalpost->destscale = sparkle->destscale = droneman->destscale = mobj->destscale; + + // straight copy-pasta from P_SpawnMapThing, case MT_NIGHTSDRONE + if (!flip) + { + if (topaligned) // Align droneman to top of hitbox + { + dronemanoffset = droneboxmandiff; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (middlealigned) // Align droneman to center of hitbox + { + dronemanoffset = droneboxmandiff/2; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (bottomoffsetted) + { + dronemanoffset = 24*FRACUNIT; + goaloffset = dronemangoaldiff + dronemanoffset; + } + else + { + dronemanoffset = 0; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + + sparkleoffset = goaloffset - FixedMul(15*FRACUNIT, mobj->scale); + } + else + { + if (topaligned) // Align droneman to top of hitbox + { + dronemanoffset = 0; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (middlealigned) // Align droneman to center of hitbox + { + dronemanoffset = droneboxmandiff/2; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (bottomoffsetted) + { + dronemanoffset = droneboxmandiff - FixedMul(24*FRACUNIT, mobj->scale); + goaloffset = dronemangoaldiff + dronemanoffset; + } + else + { + dronemanoffset = droneboxmandiff; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + + sparkleoffset = goaloffset + FixedMul(15*FRACUNIT, mobj->scale); + } + + P_TeleportMove(goalpost, mobj->x, mobj->y, mobj->z + goaloffset); + P_TeleportMove(sparkle, mobj->x, mobj->y, mobj->z + sparkleoffset); + if (goalpost->movefactor != mobj->z || goalpost->friction != mobj->height) + { + P_TeleportMove(droneman, mobj->x, mobj->y, mobj->z + dronemanoffset); + goalpost->movefactor = mobj->z; + goalpost->friction = mobj->height; + } + goalpost->threshold = mobj->flags & (MF_SLIDEME|MF_GRENADEBOUNCE); + } + else + { + if (goalpost->x != mobj->x || goalpost->y != mobj->y) + { + P_TeleportMove(goalpost, mobj->x, mobj->y, goalpost->z); + P_TeleportMove(sparkle, mobj->x, mobj->y, sparkle->z); + } + + if (droneman->x != mobj->x || droneman->y != mobj->y) + P_TeleportMove(droneman, mobj->x, mobj->y, + droneman->z >= mobj->floorz && droneman->z <= mobj->ceilingz ? droneman->z : mobj->z); + } + + // now toggle states! + // GOAL mode? + if (sparkle->state >= &states[S_NIGHTSDRONE_SPARKLING1] && sparkle->state <= &states[S_NIGHTSDRONE_SPARKLING16]) + { + INT32 i; + boolean bonustime = false; + + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && players[i].bonustime && players[i].powers[pw_carry] == CR_NIGHTSMODE) + { + bonustime = true; + break; + } + + if (!bonustime) + { + CONS_Debug(DBG_NIGHTSBASIC, "Removing goal post\n"); + if (goalpost && goalpost->state != &states[S_INVISIBLE]) + P_SetMobjState(goalpost, S_INVISIBLE); + if (sparkle && sparkle->state != &states[S_INVISIBLE]) + P_SetMobjState(sparkle, S_INVISIBLE); + } + } + // Invisible/bouncing mode. + else + { + INT32 i; + boolean bonustime = false; + fixed_t zcomp; + + // Bouncy bouncy! + if (!flip) + { + if (topaligned) + zcomp = droneboxmandiff + mobj->z; + else if (middlealigned) + zcomp = (droneboxmandiff/2) + mobj->z; + else if (bottomoffsetted) + zcomp = mobj->z + FixedMul(24*FRACUNIT, mobj->scale); + else + zcomp = mobj->z; + } + else + { + if (topaligned) + zcomp = mobj->z; + else if (middlealigned) + zcomp = (droneboxmandiff/2) + mobj->z; + else if (bottomoffsetted) + zcomp = mobj->z + droneboxmandiff - FixedMul(24*FRACUNIT, mobj->scale); + else + zcomp = mobj->z + droneboxmandiff; + } + + droneman->angle += ANG10; + if (!flip && droneman->z <= zcomp) + droneman->momz = FixedMul(5*FRACUNIT, droneman->scale); + else if (flip && droneman->z >= zcomp) + droneman->momz = FixedMul(-5*FRACUNIT, droneman->scale); + + // state switching logic + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && players[i].bonustime && players[i].powers[pw_carry] == CR_NIGHTSMODE) + { + bonustime = true; + break; + } + + if (bonustime) + { + CONS_Debug(DBG_NIGHTSBASIC, "Adding goal post\n"); + if (!(droneman->flags2 & MF2_DONTDRAW)) + droneman->flags2 |= MF2_DONTDRAW; + if (goalpost->state == &states[S_INVISIBLE]) + P_SetMobjState(goalpost, mobjinfo[goalpost->type].meleestate); + if (sparkle->state == &states[S_INVISIBLE]) + P_SetMobjState(sparkle, mobjinfo[sparkle->type].meleestate); + } + else if (!G_IsSpecialStage(gamemap)) + { + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && players[i].powers[pw_carry] != CR_NIGHTSMODE) + { + bonustime = true; // variable reuse + break; + } + + if (bonustime) + { + // show droneman if at least one player is non-nights + if (goalpost->state != &states[S_INVISIBLE]) + P_SetMobjState(goalpost, S_INVISIBLE); + if (sparkle->state != &states[S_INVISIBLE]) + P_SetMobjState(sparkle, S_INVISIBLE); + if (droneman->state != &states[mobjinfo[droneman->type].meleestate]) + P_SetMobjState(droneman, mobjinfo[droneman->type].meleestate); + if (droneman->flags2 & MF2_DONTDRAW) + droneman->flags2 &= ~MF2_DONTDRAW; + } + else + { + // else, hide it + if (!(droneman->flags2 & MF2_DONTDRAW)) + droneman->flags2 |= MF2_DONTDRAW; + } + } + } + } +} + +static boolean P_TurretThink(mobj_t *mobj) +{ + P_MobjCheckWater(mobj); + P_CheckPosition(mobj, mobj->x, mobj->y); + if (P_MobjWasRemoved(mobj)) + return false; + mobj->floorz = tmfloorz; + mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; + + if ((mobj->eflags & MFE_UNDERWATER) && mobj->health > 0) + { + P_SetMobjState(mobj, mobj->info->deathstate); + mobj->health = 0; + mobj->flags2 &= ~MF2_FIRING; + } + else if (mobj->health > 0 && mobj->z + mobj->height > mobj->ceilingz) // Crushed + { + INT32 i, j; + fixed_t ns; + fixed_t x, y, z; + mobj_t* mo2; + + z = mobj->subsector->sector->floorheight + FixedMul(64*FRACUNIT, mobj->scale); + for (j = 0; j < 2; j++) + { + for (i = 0; i < 32; i++) + { + const angle_t fa = (i*FINEANGLES/16) & FINEMASK; + ns = FixedMul(64*FRACUNIT, mobj->scale); + x = mobj->x + FixedMul(FINESINE(fa), ns); + y = mobj->y + FixedMul(FINECOSINE(fa), ns); + + mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE); + ns = FixedMul(16*FRACUNIT, mobj->scale); + mo2->momx = FixedMul(FINESINE(fa), ns); + mo2->momy = FixedMul(FINECOSINE(fa), ns); + } + z -= FixedMul(32*FRACUNIT, mobj->scale); + } + P_SetMobjState(mobj, mobj->info->deathstate); + mobj->health = 0; + mobj->flags2 &= ~MF2_FIRING; + } + return true; +} + +static void P_SaloonDoorThink(mobj_t *mobj) +{ + fixed_t x = mobj->tracer->x; + fixed_t y = mobj->tracer->y; + fixed_t z = mobj->tracer->z; + angle_t oang = FixedAngle(mobj->extravalue1); + angle_t fa = (oang >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t c0 = -96*FINECOSINE(fa); + fixed_t s0 = -96*FINESINE(fa); + angle_t fma; + fixed_t c, s; + angle_t angdiff; + + // Adjust angular speed + fixed_t da = AngleFixed(mobj->angle - oang); + if (da > 180*FRACUNIT) + da -= 360*FRACUNIT; + mobj->extravalue2 = 8*(mobj->extravalue2 - da/32)/9; + + // Update angle + mobj->angle += FixedAngle(mobj->extravalue2); + + angdiff = mobj->angle - FixedAngle(mobj->extravalue1); + if (angdiff > (ANGLE_90 - ANG2) && angdiff < ANGLE_180) + { + mobj->angle = FixedAngle(mobj->extravalue1) + (ANGLE_90 - ANG2); + mobj->extravalue2 /= 2; + } + else if (angdiff < (ANGLE_270 + ANG2) && angdiff >= ANGLE_180) + { + mobj->angle = FixedAngle(mobj->extravalue1) + (ANGLE_270 + ANG2); + mobj->extravalue2 /= 2; + } + + // Update position + fma = (mobj->angle >> ANGLETOFINESHIFT) & FINEMASK; + c = 48*FINECOSINE(fma); + s = 48*FINESINE(fma); + P_TeleportMove(mobj, x + c0 + c, y + s0 + s, z); +} + +static void P_PyreFlyThink(mobj_t *mobj) +{ + fixed_t hdist; + + mobj->extravalue1 = (mobj->extravalue1 + 3) % 360; + mobj->z += FINESINE(((mobj->extravalue1 * ANG1) >> ANGLETOFINESHIFT) & FINEMASK); + + if (!(mobj->flags2 & MF2_BOSSNOTRAP)) + P_LookForPlayers(mobj, true, false, 1500*FRACUNIT); + + if (!mobj->target) + return; + + if (mobj->extravalue2 == 1) + P_PyreFlyBurn(mobj, 0, 20, MT_SMOKE, 4*FRACUNIT); + else if (mobj->extravalue2 == 2) + { + INT32 fireradius = min(100 - mobj->fuse, 52); + P_PyreFlyBurn(mobj, P_RandomRange(0, fireradius) << FRACBITS, 20, MT_FLAMEPARTICLE, 4*FRACUNIT); + P_PyreFlyBurn(mobj, fireradius*FRACUNIT, 40, MT_PYREFLY_FIRE, 0); + } + + hdist = R_PointToDist2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + + if (hdist > 1500*FRACUNIT) + { + mobj->flags2 &= ~MF2_BOSSNOTRAP; + P_SetTarget(&mobj->target, NULL); + return; + } + + if (!(mobj->flags2 & MF2_BOSSNOTRAP) && hdist <= 450*FRACUNIT) + mobj->flags2 |= MF2_BOSSNOTRAP; + + if (!(mobj->flags2 & MF2_BOSSNOTRAP)) + return; + + if (hdist < 1000*FRACUNIT) + { + //Aim for player z position. If too close to floor/ceiling, aim just above/below them. + fixed_t destz = min(max(mobj->target->z, mobj->target->floorz + 70*FRACUNIT), mobj->target->ceilingz - 80*FRACUNIT - mobj->height); + fixed_t dist = P_AproxDistance(hdist, destz - mobj->z); + P_InstaThrust(mobj, R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y), 2*FRACUNIT); + mobj->momz = FixedMul(FixedDiv(destz - mobj->z, dist), 2*FRACUNIT); + } + else + { + mobj->momx = 0; + mobj->momy = 0; + mobj->momz = 0; + } +} + +static void P_PterabyteThink(mobj_t *mobj) +{ + if (mobj->extravalue1 & 4) // Cooldown after grabbing + { + if (mobj->movefactor) + mobj->movefactor--; + else + { + P_SetTarget(&mobj->target, NULL); + mobj->extravalue1 &= 3; + } + } + + if ((mobj->extravalue1 & 3) == 0) // Hovering + { + fixed_t vdist, hdist, time; + fixed_t hspeed = 3*mobj->info->speed; + angle_t fa; + + var1 = 1; + var2 = 0; + A_CapeChase(mobj); + + if (mobj->target) + return; // Still carrying a player or in cooldown + + P_LookForPlayers(mobj, true, false, 256*FRACUNIT); + + if (!mobj->target) + return; + + if (mobj->target->player->powers[pw_flashing]) + { + P_SetTarget(&mobj->target, NULL); + return; + } + + vdist = mobj->z - mobj->target->z - mobj->target->height; + if (P_MobjFlip(mobj)*vdist <= 0) + { + P_SetTarget(&mobj->target, NULL); + return; + } + + hdist = R_PointToDist2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + if (hdist > 450*FRACUNIT) + { + P_SetTarget(&mobj->target, NULL); + return; + } + + P_SetMobjState(mobj, S_PTERABYTE_SWOOPDOWN); + mobj->extravalue1++; + S_StartSound(mobj, mobj->info->attacksound); + time = FixedDiv(hdist, hspeed); + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + fa = (mobj->angle >> ANGLETOFINESHIFT) & FINEMASK; + mobj->momx = FixedMul(FINECOSINE(fa), hspeed); + mobj->momy = FixedMul(FINESINE(fa), hspeed); + mobj->momz = -2*FixedDiv(vdist, time); + mobj->extravalue2 = -FixedDiv(mobj->momz, time); //Z accel + mobj->movecount = time >> FRACBITS; + mobj->reactiontime = mobj->movecount; + } + else if ((mobj->extravalue1 & 3) == 1) // Swooping + { + mobj->reactiontime--; + mobj->momz += mobj->extravalue2; + if (mobj->reactiontime) + return; + + if (mobj->state - states == S_PTERABYTE_SWOOPDOWN) + { + P_SetMobjState(mobj, S_PTERABYTE_SWOOPUP); + mobj->reactiontime = mobj->movecount; + } + else if (mobj->state - states == S_PTERABYTE_SWOOPUP) + { + P_SetMobjState(mobj, S_PTERABYTE_FLY1); + mobj->extravalue1++; + if (mobj->target && mobj->target->tracer != mobj) + P_SetTarget(&mobj->target, NULL); // Failed to grab the target + mobj->momx = mobj->momy = mobj->momz = 0; + } + } + else // Returning + { + var1 = 2*mobj->info->speed; + var2 = 1; + A_HomingChase(mobj); + if (P_AproxDistance(mobj->x - mobj->tracer->x, mobj->y - mobj->tracer->y) <= mobj->info->speed) + { + mobj->extravalue1 -= 2; + mobj->momx = mobj->momy = mobj->momz = 0; + } + } +} + +static void P_DragonbomberThink(mobj_t *mobj) +{ +#define DRAGONTURNSPEED ANG2 + mobj->movecount = (mobj->movecount + 9) % 360; + P_SetObjectMomZ(mobj, 4*FINESINE(((mobj->movecount*ANG1) >> ANGLETOFINESHIFT) & FINEMASK), false); + if (mobj->threshold > 0) // are we dropping mines? + { + mobj->threshold--; + if (mobj->threshold == 0) // if the timer hits 0, look for a mine to drop! + { + mobj_t *segment = mobj; + while (segment->tracer != NULL && !P_MobjWasRemoved(segment->tracer) && segment->tracer->state == &states[segment->tracer->info->spawnstate]) + segment = segment->tracer; + if (segment != mobj) // found an unactivated segment? + { + mobj_t *mine = P_SpawnMobjFromMobj(segment, 0, 0, 0, segment->info->painchance); + mine->angle = segment->angle; + P_InstaThrust(mine, mobj->angle, P_AproxDistance(mobj->momx, mobj->momy) >> 1); + P_SetObjectMomZ(mine, -2*FRACUNIT, true); + S_StartSound(mine, mine->info->seesound); + P_SetMobjState(segment, segment->info->raisestate); + mobj->threshold = mobj->info->painchance; + } + } + } + if (mobj->target) // Are we chasing a player? + { + fixed_t dist = P_AproxDistance(mobj->x - mobj->target->x, mobj->y - mobj->target->y); + if (dist > 2000*mobj->scale) // Not anymore! + P_SetTarget(&mobj->target, NULL); + else + { + fixed_t vspeed = FixedMul(mobj->info->speed >> 3, mobj->scale); + fixed_t z = mobj->target->z + (mobj->height >> 1) + (mobj->flags & MFE_VERTICALFLIP ? -128*mobj->scale : 128*mobj->scale + mobj->target->height); + angle_t diff = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y) - mobj->angle; + if (diff > ANGLE_180) + mobj->angle -= DRAGONTURNSPEED; + else + mobj->angle += DRAGONTURNSPEED; + if (!mobj->threshold && dist < 512*mobj->scale) // Close enough to drop bombs + { + mobj->threshold = mobj->info->painchance; + } + mobj->momz += max(min(z - mobj->z, vspeed), -vspeed); + } + } + else // Can we find a player to chase? + { + if (mobj->tracer == NULL || mobj->tracer->state != &states[mobj->tracer->info->spawnstate] + || !P_LookForPlayers(mobj, true, false, 2000*mobj->scale)) // if not, circle around the spawnpoint + { + if (!mobj->spawnpoint) // unless we don't have one, in which case uhhh just circle around wherever we currently are I guess?? + mobj->angle += DRAGONTURNSPEED; + else + { + fixed_t vspeed = FixedMul(mobj->info->speed >> 3, mobj->scale); + fixed_t x = mobj->spawnpoint->x << FRACBITS; + fixed_t y = mobj->spawnpoint->y << FRACBITS; + fixed_t z = mobj->spawnpoint->z << FRACBITS; + angle_t diff = R_PointToAngle2(mobj->x, mobj->y, x, y) - mobj->angle; + if (diff > ANGLE_180) + mobj->angle -= DRAGONTURNSPEED; + else + mobj->angle += DRAGONTURNSPEED; + mobj->momz += max(min(z - mobj->z, vspeed), -vspeed); + } + } + } + P_InstaThrust(mobj, mobj->angle, FixedMul(mobj->info->speed, mobj->scale)); +#undef DRAGONTURNSPEED +} + +static boolean P_MobjRegularThink(mobj_t *mobj) +{ + if ((mobj->flags & MF_ENEMY) && (mobj->state->nextstate == mobj->info->spawnstate && mobj->tics == 1)) + mobj->flags2 &= ~MF2_FRET; + + if (mobj->eflags & MFE_TRACERANGLE) + P_TracerAngleThink(mobj); + + switch (mobj->type) + { + case MT_WALLSPIKEBASE: + if (!mobj->target) { + P_RemoveMobj(mobj); + return false; + } + mobj->frame = (mobj->frame & ~FF_FRAMEMASK)|(mobj->target->frame & FF_FRAMEMASK); +#if 0 + if (mobj->angle != mobj->target->angle + ANGLE_90) // reposition if not the correct angle + { + mobj_t* target = mobj->target; // shortcut + const fixed_t baseradius = target->radius - (target->scale/2); //FixedMul(FRACUNIT/2, target->scale); + P_UnsetThingPosition(mobj); + mobj->x = target->x - P_ReturnThrustX(target, target->angle, baseradius); + mobj->y = target->y - P_ReturnThrustY(target, target->angle, baseradius); + P_SetThingPosition(mobj); + mobj->angle = target->angle + ANGLE_90; + } +#endif + break; + case MT_FALLINGROCK: + // Despawn rocks here in case zmovement code can't do so (blame slopes) + if (!mobj->momx && !mobj->momy && !mobj->momz + && ((mobj->eflags & MFE_VERTICALFLIP) ? + mobj->z + mobj->height >= mobj->ceilingz + : mobj->z <= mobj->floorz)) + { + P_RemoveMobj(mobj); + return false; + } + P_MobjCheckWater(mobj); + break; + case MT_ARROW: + P_ArrowThink(mobj); + break; + case MT_EMERALDSPAWN: + if (mobj->threshold) + { + mobj->threshold--; + + if (!mobj->threshold && !mobj->target && mobj->reactiontime) + { + mobj_t *emerald = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->reactiontime); + emerald->threshold = 42; + P_SetTarget(&mobj->target, emerald); + P_SetTarget(&emerald->target, mobj); + } + } + break; + case MT_BUGGLE: + mobj->eflags |= MFE_UNDERWATER; //P_MobjCheckWater(mobj); // solely for MFE_UNDERWATER for A_FlickySpawn + { + if (mobj->tracer && mobj->tracer->player && mobj->tracer->health > 0 + && P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius*16) + { + // Home in on the target. + P_HomingAttack(mobj, mobj->tracer); + + if (mobj->z < mobj->floorz) + mobj->z = mobj->floorz; + + if (leveltime % mobj->info->painchance == 0) + S_StartSound(mobj, mobj->info->activesound); + + if ((statenum_t)(mobj->state - states) != mobj->info->seestate) + P_SetMobjState(mobj, mobj->info->seestate); + } + else + { + // Try to find a player + P_LookForPlayers(mobj, true, true, mobj->radius*16); + mobj->momx >>= 1; + mobj->momy >>= 1; + mobj->momz >>= 1; + if ((statenum_t)(mobj->state - states) != mobj->info->spawnstate) + P_SetMobjState(mobj, mobj->info->spawnstate); + } + } + break; + case MT_BUMBLEBORE: + P_BumbleboreThink(mobj); + break; + case MT_BIGMINE: + mobj->extravalue1 += 3; + mobj->extravalue1 %= 360; + P_UnsetThingPosition(mobj); + mobj->z += FINESINE(mobj->extravalue1*(FINEMASK + 1)/360); + P_SetThingPosition(mobj); + break; + case MT_FLAME: + if (mobj->flags2 & MF2_BOSSNOTRAP) + { + if (!mobj->target || P_MobjWasRemoved(mobj->target)) + { + if (mobj->tracer && !P_MobjWasRemoved(mobj->tracer)) + P_RemoveMobj(mobj->tracer); + P_RemoveMobj(mobj); + return false; + } + mobj->z = mobj->target->z + mobj->target->momz; + if (!(mobj->eflags & MFE_VERTICALFLIP)) + mobj->z += mobj->target->height; + } + if (mobj->tracer && !P_MobjWasRemoved(mobj->tracer)) + { + mobj->tracer->z = mobj->z + P_MobjFlip(mobj)*20*mobj->scale; + if (mobj->eflags & MFE_VERTICALFLIP) + mobj->tracer->z += mobj->height; + } + break; + case MT_WAVINGFLAG1: + case MT_WAVINGFLAG2: + { + fixed_t base = (leveltime << (FRACBITS + 1)); + mobj_t *seg = mobj->tracer, *prev = mobj; + mobj->movedir = mobj->angle + + ((((FINESINE((FixedAngle(base << 1) >> ANGLETOFINESHIFT) & FINEMASK) + + FINESINE((FixedAngle(base << 4) >> ANGLETOFINESHIFT) & FINEMASK)) >> 1) + + FINESINE((FixedAngle(base*9) >> ANGLETOFINESHIFT) & FINEMASK) + + FINECOSINE(((FixedAngle(base*9)) >> ANGLETOFINESHIFT) & FINEMASK)) << 12); //*2^12 + while (seg) + { + seg->movedir = seg->angle; + seg->angle = prev->movedir; + P_UnsetThingPosition(seg); + seg->x = prev->x + P_ReturnThrustX(prev, prev->angle, prev->radius); + seg->y = prev->y + P_ReturnThrustY(prev, prev->angle, prev->radius); + seg->z = prev->z + prev->height - (seg->scale >> 1); + P_SetThingPosition(seg); + prev = seg; + seg = seg->tracer; + } + } + break; + case MT_SPINCUSHION: + if (mobj->target && mobj->state - states >= S_SPINCUSHION_AIM1 && mobj->state - states <= S_SPINCUSHION_AIM5) + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + break; + case MT_CRUSHCLAW: + if (mobj->state - states == S_CRUSHCLAW_STAY && mobj->target) + { + mobj_t *chain = mobj->target->target; + SINT8 sign = ((mobj->tics & 1) ? mobj->tics : -(SINT8)(mobj->tics)); + while (chain) + { + chain->z = chain->movefactor + sign*mobj->scale; + sign = -sign; + chain = chain->target; + } + } + break; + case MT_SMASHINGSPIKEBALL: + mobj->momx = mobj->momy = 0; + if (mobj->state - states == S_SMASHSPIKE_FALL && P_IsObjectOnGround(mobj)) + { + P_SetMobjState(mobj, S_SMASHSPIKE_STOMP1); + S_StartSound(mobj, sfx_spsmsh); + } + else if (mobj->state - states == S_SMASHSPIKE_RISE2 && P_MobjFlip(mobj)*(mobj->z - mobj->movecount) >= 0) + { + mobj->momz = 0; + P_SetMobjState(mobj, S_SMASHSPIKE_FLOAT); + } + break; + case MT_HANGSTER: + if (!P_HangsterThink(mobj)) + return false; + break; + case MT_LHRT: + mobj->momx = FixedMul(mobj->momx, mobj->extravalue2); + mobj->momy = FixedMul(mobj->momy, mobj->extravalue2); + break; + case MT_EGGCAPSULE: + if (!mobj->reactiontime) + { + // Target nearest player on your mare. + // (You can make it float up/down by adding MF_FLOAT, + // but beware level design pitfalls.) + fixed_t shortest = 1024*FRACUNIT; + INT32 i; + P_SetTarget(&mobj->target, NULL); + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && players[i].mo + && players[i].mare == mobj->threshold && players[i].spheres > 0) + { + fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); + if (dist < shortest) + { + P_SetTarget(&mobj->target, players[i].mo); + shortest = dist; + } + } + } + break; + case MT_EGGMOBILE2_POGO: + if (!mobj->target + || !mobj->target->health + || mobj->target->state == &states[mobj->target->info->spawnstate] + || mobj->target->state == &states[mobj->target->info->raisestate]) + { + P_RemoveMobj(mobj); + return false; + } + P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z - mobj->height); + break; + case MT_HAMMER: + if (mobj->z <= mobj->floorz) + { + P_RemoveMobj(mobj); + return false; + } + break; + case MT_KOOPA: + P_KoopaThinker(mobj); + break; + case MT_FIREBALL: + if (P_AproxDistance(mobj->momx, mobj->momy) <= 16*FRACUNIT) // Once fireballs lose enough speed, kill them + { + P_KillMobj(mobj, NULL, NULL, 0); + return false; + } + break; + case MT_REDRING: + if (((mobj->z < mobj->floorz) || (mobj->z + mobj->height > mobj->ceilingz)) + && mobj->flags & MF_MISSILE) + { + P_ExplodeMissile(mobj); + return false; + } + break; + case MT_BOSSFLYPOINT: + return false; + case MT_NIGHTSCORE: + mobj->color = (UINT8)(leveltime % SKINCOLOR_WHITE); + break; + case MT_JETFUME1: + if (!P_JetFume1Think(mobj)) + return false; + break; + case MT_JETFLAME: + { + if (!mobj->target // if you have no target + || (!(mobj->target->flags & MF_BOSS) && mobj->target->health <= 0)) // or your target isn't a boss and it's popped now + { // then remove yourself as well! + P_RemoveMobj(mobj); + return false; + } + + P_UnsetThingPosition(mobj); + mobj->x = mobj->target->x; + mobj->y = mobj->target->y; + mobj->z = mobj->target->z - 50*mobj->target->scale; + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z + mobj->height; + P_SetThingPosition(mobj); + } + break; + case MT_EGGROBO1: + if (!P_EggRobo1Think(mobj)) + return false; + break; + case MT_EGGROBO1JET: + { + if (!mobj->target || P_MobjWasRemoved(mobj->target) // if you have no target + || (mobj->target->health <= 0)) // or your target isn't a boss and it's popped now + { // then remove yourself as well! + P_RemoveMobj(mobj); + return false; + } + + mobj->flags2 ^= MF2_DONTDRAW; + + P_UnsetThingPosition(mobj); + mobj->x = mobj->target->x + P_ReturnThrustX(mobj, mobj->target->angle + ANGLE_90, mobj->movefactor*mobj->target->scale) - P_ReturnThrustX(mobj, mobj->target->angle, 19*mobj->target->scale); + mobj->y = mobj->target->y + P_ReturnThrustY(mobj, mobj->target->angle + ANGLE_90, mobj->movefactor*mobj->target->scale) - P_ReturnThrustY(mobj, mobj->target->angle, 19*mobj->target->scale); + mobj->z = mobj->target->z; + if (mobj->target->eflags & MFE_VERTICALFLIP) + mobj->z += (mobj->target->height - mobj->height); + mobj->floorz = mobj->z; + mobj->ceilingz = mobj->z + mobj->height; + P_SetThingPosition(mobj); + } + break; + case MT_NIGHTSDRONE: + P_NiGHTSDroneThink(mobj); + break; + case MT_PLAYER: + if (mobj->player) + P_PlayerMobjThinker(mobj); + return false; + case MT_SKIM: + // check mobj against possible water content, before movement code + P_MobjCheckWater(mobj); + + // Keep Skim at water surface + if (mobj->z <= mobj->watertop) + { + mobj->flags |= MF_NOGRAVITY; + if (mobj->z < mobj->watertop) + { + if (mobj->watertop - mobj->z <= FixedMul(mobj->info->speed*FRACUNIT, mobj->scale)) + mobj->z = mobj->watertop; + else + mobj->momz = FixedMul(mobj->info->speed*FRACUNIT, mobj->scale); + } + } + else + { + mobj->flags &= ~MF_NOGRAVITY; + if (mobj->z > mobj->watertop && mobj->z - mobj->watertop < FixedMul(MAXSTEPMOVE, mobj->scale)) + mobj->z = mobj->watertop; + } + break; + case MT_RING: + case MT_REDTEAMRING: + case MT_BLUETEAMRING: + P_KillRingsInLava(mobj); + if (P_MobjWasRemoved(mobj)) + return false; + /* FALLTHRU */ + case MT_COIN: + case MT_BLUESPHERE: + case MT_BOMBSPHERE: + case MT_NIGHTSCHIP: + case MT_NIGHTSSTAR: + // No need to check water. Who cares? + P_RingThinker(mobj); + if (mobj->flags2 & MF2_NIGHTSPULL) + P_NightsItemChase(mobj); + else + A_AttractChase(mobj); + return false; + // Flung items + case MT_FLINGRING: + P_KillRingsInLava(mobj); + if (P_MobjWasRemoved(mobj)) + return false; + /* FALLTHRU */ + case MT_FLINGCOIN: + case MT_FLINGBLUESPHERE: + case MT_FLINGNIGHTSCHIP: + if (mobj->flags2 & MF2_NIGHTSPULL) + P_NightsItemChase(mobj); + else + A_AttractChase(mobj); + break; + case MT_EMBLEM: + if (mobj->flags2 & MF2_NIGHTSPULL) + P_NightsItemChase(mobj); + break; + case MT_SHELL: + if (mobj->threshold && mobj->threshold != TICRATE) + mobj->threshold--; + + if (mobj->threshold >= TICRATE) + { + mobj->angle += ((mobj->movedir == 1) ? ANGLE_22h : ANGLE_337h); + P_InstaThrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), (mobj->info->speed*mobj->scale)); + } + break; + case MT_TURRET: + if (!P_TurretThink(mobj)) + return false; + break; + case MT_BLUEFLAG: + case MT_REDFLAG: + { + sector_t* sec2; + sec2 = P_ThingOnSpecial3DFloor(mobj); + if ((sec2 && GETSECSPECIAL(sec2->special, 4) == 2) || (GETSECSPECIAL(mobj->subsector->sector->special, 4) == 2)) + mobj->fuse = 1; // Return to base. + break; + } + case MT_CANNONBALL: +#ifdef FLOORSPLATS + R_AddFloorSplat(mobj->tracer->subsector, mobj->tracer, "TARGET", mobj->tracer->x, + mobj->tracer->y, mobj->tracer->floorz, SPLATDRAWMODE_SHADE); +#endif + break; + case MT_SPINDUST: // Spindash dust + mobj->momx = FixedMul(mobj->momx, (3*FRACUNIT)/4); // originally 50000 + mobj->momy = FixedMul(mobj->momy, (3*FRACUNIT)/4); // same + //mobj->momz = mobj->momz+P_MobjFlip(mobj)/3; // no meaningful change in value to be frank + if (mobj->state >= &states[S_SPINDUST_BUBBLE1] && mobj->state <= &states[S_SPINDUST_BUBBLE4]) // bubble dust! + { + P_MobjCheckWater(mobj); + if (mobj->watertop != mobj->subsector->sector->floorheight - 1000*FRACUNIT + && mobj->z + mobj->height >= mobj->watertop - 5*FRACUNIT) + mobj->flags2 |= MF2_DONTDRAW; + } + break; + case MT_TRAINDUSTSPAWNER: + if (leveltime % 5 == 0) { + mobj_t* traindust = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_PARTICLE); + traindust->flags = MF_SCENERY; + P_SetMobjState(traindust, S_TRAINDUST); + traindust->frame = P_RandomRange(0, 8)|FF_TRANS90; + traindust->angle = mobj->angle; + traindust->tics = TICRATE*4; + traindust->destscale = FRACUNIT*64; + traindust->scalespeed = FRACUNIT/24; + P_SetScale(traindust, FRACUNIT*6); + } + break; + case MT_TRAINSTEAMSPAWNER: + if (leveltime % 5 == 0) { + mobj_t *steam = P_SpawnMobj(mobj->x + FRACUNIT*P_SignedRandom()/2, mobj->y + FRACUNIT*P_SignedRandom()/2, mobj->z, MT_PARTICLE); + P_SetMobjState(steam, S_TRAINSTEAM); + steam->frame = P_RandomRange(0, 1)|FF_TRANS90; + steam->tics = TICRATE*8; + steam->destscale = FRACUNIT*64; + steam->scalespeed = FRACUNIT/8; + P_SetScale(steam, FRACUNIT*16); + steam->momx = P_SignedRandom()*32; + steam->momy = -64*FRACUNIT; + steam->momz = 2*FRACUNIT; + } + break; + case MT_CANARIVORE_GAS: + { + fixed_t momz; + + if (mobj->flags2 & MF2_AMBUSH) + { + mobj->momx = FixedMul(mobj->momx, 50*FRACUNIT/51); + mobj->momy = FixedMul(mobj->momy, 50*FRACUNIT/51); + break; + } + + if (mobj->eflags & MFE_VERTICALFLIP) + { + if ((mobj->z + mobj->height + mobj->momz) <= mobj->ceilingz) + break; + } + else + { + if ((mobj->z + mobj->momz) >= mobj->floorz) + break; + } + + momz = abs(mobj->momz); + if (R_PointToDist2(0, 0, mobj->momx, mobj->momy) < momz) + P_InstaThrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), momz); + mobj->flags2 |= MF2_AMBUSH; + break; + } + case MT_SALOONDOOR: + P_SaloonDoorThink(mobj); + break; + case MT_MINECARTSPAWNER: + P_HandleMinecartSegments(mobj); + if (!mobj->fuse || mobj->fuse > TICRATE) + break; + if (mobj->fuse == 2) + { + mobj->fuse = 0; + break; + } + mobj->flags2 ^= MF2_DONTDRAW; + break; + case MT_LAVAFALLROCK: + if (P_IsObjectOnGround(mobj)) + P_RemoveMobj(mobj); + break; + case MT_PYREFLY: + P_PyreFlyThink(mobj); + break; + case MT_PTERABYTE: + P_PterabyteThink(mobj); + break; + case MT_DRAGONBOMBER: + P_DragonbomberThink(mobj); + break; + case MT_MINUS: + if (P_IsObjectOnGround(mobj)) + mobj->rollangle = 0; + else + mobj->rollangle = R_PointToAngle2(0, 0, mobj->momz, (mobj->scale << 1) - min(abs(mobj->momz), mobj->scale << 1)); + break; + case MT_SPINFIRE: + if (mobj->flags & MF_NOGRAVITY) + { + if (mobj->eflags & MFE_VERTICALFLIP) + mobj->z = mobj->ceilingz - mobj->height; + else + mobj->z = mobj->floorz; + } + else if ((!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z <= mobj->floorz) + || ((mobj->eflags & MFE_VERTICALFLIP) && mobj->z + mobj->height >= mobj->ceilingz)) + { + mobj->flags |= MF_NOGRAVITY; + mobj->momx = 8; // this is a hack which is used to ensure it still behaves as a missile and can damage others + mobj->momy = mobj->momz = 0; + mobj->z = ((mobj->eflags & MFE_VERTICALFLIP) ? mobj->ceilingz - mobj->height : mobj->floorz); + } + /* FALLTHRU */ + default: + // check mobj against possible water content, before movement code + P_MobjCheckWater(mobj); + + // Extinguish fire objects in water + if (mobj->flags & MF_FIRE && mobj->type != MT_PUMA && mobj->type != MT_FIREBALL + && (mobj->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) + { + P_KillMobj(mobj, NULL, NULL, 0); + return false; + } + break; + } + return true; +} + +static void P_FiringThink(mobj_t *mobj) +{ + if (!mobj->target) + return; + + if (mobj->health <= 0) + return; + + if (mobj->state->action.acp1 == (actionf_p1)A_Boss1Laser) + { + if (mobj->state->tics > 1) + { + var1 = mobj->state->var1; + var2 = mobj->state->var2 & 65535; + mobj->state->action.acp1(mobj); + } + } + else if (leveltime & 1) // Fire mode + { + mobj_t *missile; + + if (mobj->target->player && mobj->target->player->powers[pw_carry] == CR_NIGHTSMODE) + { + fixed_t oldval = mobjinfo[mobj->extravalue1].speed; + + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx, mobj->target->y + mobj->target->momy); + mobjinfo[mobj->extravalue1].speed = FixedMul(60*FRACUNIT, mobj->scale); + missile = P_SpawnMissile(mobj, mobj->target, mobj->extravalue1); + mobjinfo[mobj->extravalue1].speed = oldval; + } + else + { + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); + missile = P_SpawnMissile(mobj, mobj->target, mobj->extravalue1); + } + + if (missile) + { + if (mobj->flags2 & MF2_SUPERFIRE) + missile->flags2 |= MF2_SUPERFIRE; + + if (mobj->info->attacksound) + S_StartSound(missile, mobj->info->attacksound); + } + } + else + mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); +} + +static void P_MonitorFuseThink(mobj_t *mobj) +{ + mobj_t *newmobj; + + // Special case for ALL monitors. + // If a box's speed is nonzero, it's allowed to respawn as a WRM/SRM. + if (mobj->info->speed != 0 && (mobj->flags2 & (MF2_AMBUSH|MF2_STRONGBOX))) + { + mobjtype_t spawnchance[64]; + INT32 numchoices = 0, i = 0; + + // This define should make it a lot easier to organize and change monitor weights +#define SETMONITORCHANCES(type, strongboxamt, weakboxamt) \ +for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type + + // Type SRM WRM + SETMONITORCHANCES(MT_SNEAKERS_BOX, 0, 10); // Super Sneakers + SETMONITORCHANCES(MT_INVULN_BOX, 2, 0); // Invincibility + SETMONITORCHANCES(MT_WHIRLWIND_BOX, 3, 8); // Whirlwind Shield + SETMONITORCHANCES(MT_ELEMENTAL_BOX, 3, 8); // Elemental Shield + SETMONITORCHANCES(MT_ATTRACT_BOX, 2, 0); // Attraction Shield + SETMONITORCHANCES(MT_FORCE_BOX, 3, 3); // Force Shield + SETMONITORCHANCES(MT_ARMAGEDDON_BOX, 2, 0); // Armageddon Shield + SETMONITORCHANCES(MT_MIXUP_BOX, 0, 1); // Teleporters + SETMONITORCHANCES(MT_RECYCLER_BOX, 0, 1); // Recycler + SETMONITORCHANCES(MT_1UP_BOX, 1, 1); // 1-Up + // ======================================= + // Total 16 32 + +#undef SETMONITORCHANCES + + i = P_RandomKey(numchoices); // Gotta love those random numbers! + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); + } + else + newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); + + // Transfer flags2 (ambush, strongbox, objectflip) + newmobj->flags2 = mobj->flags2; + P_RemoveMobj(mobj); // make sure they disappear +} + +static void P_FlagFuseThink(mobj_t *mobj) +{ + subsector_t *ss; + fixed_t x, y, z; + mobj_t* flagmo; + + if (!mobj->spawnpoint) + return; + + x = mobj->spawnpoint->x << FRACBITS; + y = mobj->spawnpoint->y << FRACBITS; + z = mobj->spawnpoint->z << FRACBITS; + ss = R_PointInSubsector(x, y); + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + z = ss->sector->ceilingheight - mobjinfo[mobj->type].height - z; + else + z = ss->sector->floorheight + z; + flagmo = P_SpawnMobj(x, y, z, mobj->type); + flagmo->spawnpoint = mobj->spawnpoint; + if (mobj->spawnpoint->options & MTF_OBJECTFLIP) + { + flagmo->eflags |= MFE_VERTICALFLIP; + flagmo->flags2 |= MF2_OBJECTFLIP; + } + + if (mobj->type == MT_REDFLAG) + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 1 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 2) + S_StartSound(NULL, sfx_hoop3); + + redflag = flagmo; + } + else // MT_BLUEFLAG + { + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); + + // Assumedly in splitscreen players will be on opposing teams + if (players[consoleplayer].ctfteam == 2 || splitscreen) + S_StartSound(NULL, sfx_hoop1); + else if (players[consoleplayer].ctfteam == 1) + S_StartSound(NULL, sfx_hoop3); + + blueflag = flagmo; + } +} + +static boolean P_FuseThink(mobj_t *mobj) +{ + if (mobj->type == MT_SNAPPER_HEAD || mobj->type == MT_SNAPPER_LEG || mobj->type == MT_MINECARTSEG) + mobj->flags2 ^= MF2_DONTDRAW; + + mobj->fuse--; + + if (mobj->fuse) + return true; + + if (LUAh_MobjFuse(mobj) || P_MobjWasRemoved(mobj)) + ; + else if (mobj->info->flags & MF_MONITOR) + { + P_MonitorFuseThink(mobj); + return false; + } + else switch (mobj->type) + { + // gargoyle and snowman handled in P_PushableThinker, not here + case MT_THROWNGRENADE: + case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: + P_SetMobjState(mobj, mobj->info->deathstate); + break; + case MT_LHRT: + P_KillMobj(mobj, NULL, NULL, 0); + break; + case MT_BLUEFLAG: + case MT_REDFLAG: + P_FlagFuseThink(mobj); + P_RemoveMobj(mobj); + return false; + case MT_FANG: + if (mobj->flags2 & MF2_SLIDEPUSH) + { + var1 = 0; + var2 = 0; + A_BossDeath(mobj); + return false; + } + P_SetMobjState(mobj, mobj->state->nextstate); + if (P_MobjWasRemoved(mobj)) + return false; + break; + case MT_METALSONIC_BATTLE: + break; // don't remove + case MT_SPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += mobj->spawnpoint->angle; + break; + case MT_WALLSPIKE: + P_SetMobjState(mobj, mobj->state->nextstate); + mobj->fuse = mobj->info->speed; + if (mobj->spawnpoint) + mobj->fuse += (mobj->spawnpoint->angle / 360); + break; + case MT_NIGHTSCORE: + P_RemoveMobj(mobj); + return false; + case MT_LAVAFALL: + if (mobj->state - states == S_LAVAFALL_DORMANT) + { + mobj->fuse = 30; + P_SetMobjState(mobj, S_LAVAFALL_TELL); + S_StartSound(mobj, mobj->info->seesound); + } + else if (mobj->state - states == S_LAVAFALL_TELL) + { + mobj->fuse = 40; + P_SetMobjState(mobj, S_LAVAFALL_SHOOT); + S_StopSound(mobj); + S_StartSound(mobj, mobj->info->attacksound); + } + else + { + mobj->fuse = 30; + P_SetMobjState(mobj, S_LAVAFALL_DORMANT); + S_StopSound(mobj); + } + return false; + case MT_PYREFLY: + if (mobj->health <= 0) + break; + + mobj->extravalue2 = (mobj->extravalue2 + 1) % 3; + if (mobj->extravalue2 == 0) + { + P_SetMobjState(mobj, mobj->info->spawnstate); + mobj->fuse = 100; + S_StopSound(mobj); + S_StartSound(mobj, sfx_s3k8c); + } + else if (mobj->extravalue2 == 1) + { + mobj->fuse = 50; + S_StartSound(mobj, sfx_s3ka3); + } + else + { + P_SetMobjState(mobj, mobj->info->meleestate); + mobj->fuse = 100; + S_StopSound(mobj); + S_StartSound(mobj, sfx_s3kc2l); + } + return false; + case MT_PLAYER: + break; // don't remove + default: + P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. + break; + // Looking for monitors? They moved to a special condition above. + } + + return !P_MobjWasRemoved(mobj); +} + // // P_MobjThinker // @@ -6182,18 +10106,24 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->flags & MF_NOTHINK) return; + if ((mobj->flags & MF_BOSS) && mobj->spawnpoint && (bossdisabled & (1<spawnpoint->extrainfo))) + return; + // Remove dead target/tracer. if (mobj->target && P_MobjWasRemoved(mobj->target)) P_SetTarget(&mobj->target, NULL); if (mobj->tracer && P_MobjWasRemoved(mobj->tracer)) P_SetTarget(&mobj->tracer, NULL); + if (mobj->hnext && P_MobjWasRemoved(mobj->hnext)) + P_SetTarget(&mobj->hnext, NULL); + if (mobj->hprev && P_MobjWasRemoved(mobj->hprev)) + P_SetTarget(&mobj->hprev, NULL); - mobj->flags2 &= ~MF2_PUSHED; - mobj->eflags &= ~MFE_SPRUNG; + mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG); tmfloorthing = tmhitthing = NULL; - // 970 allows ANY mobj to trigger a linedef exec + // Sector special (2,8) allows ANY mobj to trigger a linedef exec if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8) { sector_t *sec2; @@ -6203,301 +10133,32 @@ void P_MobjThinker(mobj_t *mobj) P_LinedefExecute(sec2->tag, mobj, sec2); } - // Slowly scale up/down to reach your destscale. if (mobj->scale != mobj->destscale) + P_MobjScaleThink(mobj); // Slowly scale up/down to reach your destscale. + + if ((mobj->type == MT_GHOST || mobj->type == MT_THOK) && mobj->fuse > 0) // Not guaranteed to be MF_SCENERY or not MF_SCENERY! { - fixed_t oldheight = mobj->height; - UINT8 correctionType = 0; // Don't correct Z position, just gain height - - if (mobj->z > mobj->floorz && mobj->z + mobj->height < mobj->ceilingz - && mobj->type != MT_EGGMOBILE_FIRE) - correctionType = 1; // Correct Z position by centering - else if (mobj->eflags & MFE_VERTICALFLIP) - correctionType = 2; // Correct Z position by moving down - - if (abs(mobj->scale - mobj->destscale) < mobj->scalespeed) - P_SetScale(mobj, mobj->destscale); - else if (mobj->scale < mobj->destscale) - P_SetScale(mobj, mobj->scale + mobj->scalespeed); - else if (mobj->scale > mobj->destscale) - P_SetScale(mobj, mobj->scale - mobj->scalespeed); - - if (correctionType == 1) - mobj->z -= (mobj->height - oldheight)/2; - else if (correctionType == 2) - mobj->z -= mobj->height - oldheight; - - if (mobj->scale == mobj->destscale) - /// \todo Lua hook for "reached destscale"? - switch(mobj->type) - { - case MT_EGGMOBILE_FIRE: - mobj->destscale = FRACUNIT; - mobj->scalespeed = FRACUNIT>>4; - break; - default: - break; - } + if (mobj->flags2 & MF2_BOSSNOTRAP) // "fast" flag + { + if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - (2*mobj->fuse)/3) + // fade out when nearing the end of fuse... + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - (2*mobj->fuse)/3) << FF_TRANSSHIFT); + } + else + { + if ((signed)((mobj->frame & FF_TRANSMASK) >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - mobj->fuse / 2) + // fade out when nearing the end of fuse... + mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); + } } - if (mobj->type == MT_GHOST && mobj->fuse > 0 // Not guaranteed to be MF_SCENERY or not MF_SCENERY! - && (signed)(mobj->frame >> FF_TRANSSHIFT) < (NUMTRANSMAPS-1) - mobj->fuse / 2) - // fade out when nearing the end of fuse... - mobj->frame = (mobj->frame & ~FF_TRANSMASK) | (((NUMTRANSMAPS-1) - mobj->fuse / 2) << FF_TRANSSHIFT); - // Special thinker for scenery objects if (mobj->flags & MF_SCENERY) { -#ifdef HAVE_BLUA - if (LUAh_MobjThinker(mobj)) - return; - if (P_MobjWasRemoved(mobj)) - return; -#endif - switch (mobj->type) - { - case MT_HOOP: - if (mobj->fuse > 1) - P_MoveHoop(mobj); - else if (mobj->fuse == 1) - mobj->movecount = 1; - - if (mobj->movecount) - { - mobj->fuse++; - - if (mobj->fuse > 32) - { - // Don't kill the hoop center. For the sake of respawning. - //if (mobj->target) - // P_RemoveMobj(mobj->target); - - P_RemoveMobj(mobj); - } - } - else - mobj->fuse--; - return; - case MT_NIGHTSPARKLE: - if (mobj->tics != -1) - { - mobj->tics--; - - // you can cycle through multiple states in a tic - if (!mobj->tics) - if (!P_SetMobjState(mobj, mobj->state->nextstate)) - return; // freed itself - } - - P_UnsetThingPosition(mobj); - mobj->x += mobj->momx; - mobj->y += mobj->momy; - mobj->z += mobj->momz; - P_SetThingPosition(mobj); - return; - case MT_NIGHTSLOOPHELPER: - if (--mobj->tics <= 0) - P_RemoveMobj(mobj); - - // Don't touch my fuse! - return; - case MT_OVERLAY: - if (!mobj->target) - { - P_RemoveMobj(mobj); - return; - } - else - P_AddOverlay(mobj); - break; - case MT_BLACKORB: - case MT_WHITEORB: - case MT_GREENORB: - case MT_YELLOWORB: - case MT_BLUEORB: - case MT_PITYORB: - if (!P_AddShield(mobj)) - return; - break; - case MT_WATERDROP: - P_SceneryCheckWater(mobj); - if ((mobj->z <= mobj->floorz || mobj->z <= mobj->watertop) - && mobj->health > 0) - { - mobj->health = 0; - P_SetMobjState(mobj, mobj->info->deathstate); - S_StartSound(mobj, mobj->info->deathsound+P_RandomKey(mobj->info->mass)); - return; - } - break; - case MT_BUBBLES: - P_SceneryCheckWater(mobj); - break; - case MT_SMALLBUBBLE: - case MT_MEDIUMBUBBLE: - case MT_EXTRALARGEBUBBLE: // start bubble dissipate - P_SceneryCheckWater(mobj); - if (P_MobjWasRemoved(mobj)) // bubble was removed by not being in water - return; - if (!(mobj->eflags & MFE_UNDERWATER) - || (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->z + mobj->height >= mobj->ceilingz) - || (mobj->eflags & MFE_VERTICALFLIP && mobj->z <= mobj->floorz) - || (P_CheckDeathPitCollide(mobj)) - || --mobj->fuse <= 0) // Bubbles eventually dissipate if they can't reach the surface. - { - // no playing sound: no point; the object is being removed - P_RemoveMobj(mobj); - return; - } - break; - case MT_DROWNNUMBERS: - if (!mobj->target) - { - P_RemoveMobj(mobj); - return; - } - if (!mobj->target->player || !(mobj->target->player->powers[pw_underwater] || mobj->target->player->powers[pw_spacetime])) - { - P_RemoveMobj(mobj); - return; - } - mobj->x = mobj->target->x; - mobj->y = mobj->target->y; - - mobj->destscale = mobj->target->destscale; - P_SetScale(mobj, mobj->target->scale); - - if (mobj->target->eflags & MFE_VERTICALFLIP) - { - mobj->z = mobj->target->z - FixedMul(16*FRACUNIT, mobj->target->scale) - mobj->height; - if (mobj->target->player->pflags & PF_FLIPCAM) - mobj->eflags |= MFE_VERTICALFLIP; - } - else - mobj->z = mobj->target->z + (mobj->target->height) + FixedMul(8*FRACUNIT, mobj->target->scale); // Adjust height for height changes - - if (mobj->threshold <= 35) - mobj->flags2 |= MF2_DONTDRAW; - else - mobj->flags2 &= ~MF2_DONTDRAW; - if (mobj->threshold <= 30) - mobj->threshold = 40; - mobj->threshold--; - break; - case MT_FLAMEJET: - if ((mobj->flags2 & MF2_FIRING) && (leveltime & 3) == 0) - { - mobj_t *flame; - fixed_t strength; - - // Wave the flames back and forth. Reactiontime determines which direction it's going. - if (mobj->fuse <= -16) - mobj->reactiontime = 1; - else if (mobj->fuse >= 16) - mobj->reactiontime = 0; - - if (mobj->reactiontime) - mobj->fuse += 2; - else - mobj->fuse -= 2; - - flame = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_FLAMEJETFLAME); - - flame->angle = mobj->angle; - - if (mobj->flags & MF_AMBUSH) // Wave up and down instead of side-to-side - flame->momz = mobj->fuse << (FRACBITS-2); - else - flame->angle += FixedAngle(mobj->fuse*FRACUNIT); - - strength = 20*FRACUNIT; - strength -= ((20*FRACUNIT)/16)*mobj->movedir; - - P_InstaThrust(flame, flame->angle, strength); - S_StartSound(flame, sfx_fire); - } - break; - case MT_VERTICALFLAMEJET: - if ((mobj->flags2 & MF2_FIRING) && (leveltime & 3) == 0) - { - mobj_t *flame; - fixed_t strength; - - // Wave the flames back and forth. Reactiontime determines which direction it's going. - if (mobj->fuse <= -16) - mobj->reactiontime = 1; - else if (mobj->fuse >= 16) - mobj->reactiontime = 0; - - if (mobj->reactiontime) - mobj->fuse++; - else - mobj->fuse--; - - flame = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_FLAMEJETFLAME); - - strength = 20*FRACUNIT; - strength -= ((20*FRACUNIT)/16)*mobj->movedir; - - // If deaf'd, the object spawns on the ceiling. - if (mobj->flags & MF_AMBUSH) - { - mobj->z = mobj->ceilingz-mobj->height; - flame->momz = -strength; - } - else - flame->momz = strength; - P_InstaThrust(flame, mobj->angle, FixedDiv(mobj->fuse*FRACUNIT,3*FRACUNIT)); - S_StartSound(flame, sfx_fire); - } - break; - case MT_SEED: - mobj->momz = mobj->info->speed; - break; - case MT_ROCKCRUMBLE1: - case MT_ROCKCRUMBLE2: - case MT_ROCKCRUMBLE3: - case MT_ROCKCRUMBLE4: - case MT_ROCKCRUMBLE5: - case MT_ROCKCRUMBLE6: - case MT_ROCKCRUMBLE7: - case MT_ROCKCRUMBLE8: - case MT_ROCKCRUMBLE9: - case MT_ROCKCRUMBLE10: - case MT_ROCKCRUMBLE11: - case MT_ROCKCRUMBLE12: - case MT_ROCKCRUMBLE13: - case MT_ROCKCRUMBLE14: - case MT_ROCKCRUMBLE15: - case MT_ROCKCRUMBLE16: - if (mobj->z <= P_FloorzAtPos(mobj->x, mobj->y, mobj->z, mobj->height) - && mobj->state != &states[mobj->info->deathstate]) - { - P_SetMobjState(mobj, mobj->info->deathstate); - return; - } - break; - default: - if (mobj->fuse) - { // Scenery object fuse! Very basic! - mobj->fuse--; - if (!mobj->fuse) - { -#ifdef HAVE_BLUA - if (!LUAh_MobjFuse(mobj)) -#endif - P_RemoveMobj(mobj); - return; - } - } - break; - } - - P_SceneryThinker(mobj); + P_MobjSceneryThink(mobj); return; } -#ifdef HAVE_BLUA // Check for a Lua thinker first if (!mobj->player) { @@ -6511,706 +10172,34 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; } -#endif + // if it's pushable, or if it would be pushable other than temporary disablement, use the // separate thinker if (mobj->flags & MF_PUSHABLE || (mobj->info->flags & MF_PUSHABLE && mobj->fuse)) { - P_MobjCheckWater(mobj); - P_PushableThinker(mobj); - - // Extinguish fire objects in water. (Yes, it's extraordinarily rare to have a pushable flame object, but Brak uses such a case.) - if (mobj->flags & MF_FIRE && mobj->type != MT_PUMA && mobj->type != MT_FIREBALL - && (mobj->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - { - P_KillMobj(mobj, NULL, NULL); + if (!P_MobjPushableThink(mobj)) return; - } } else if (mobj->flags & MF_BOSS) { -#ifdef HAVE_BLUA - if (LUAh_BossThinker(mobj)) - { - if (P_MobjWasRemoved(mobj)) - return; - } - else if (P_MobjWasRemoved(mobj)) + if (!P_MobjBossThink(mobj)) return; - else -#endif - switch (mobj->type) - { - case MT_EGGMOBILE: - if (mobj->health < mobj->info->damage+1 && leveltime & 1 && mobj->health > 0) - P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMOKE); - if (mobj->flags2 & MF2_SKULLFLY) -#if 1 - P_SpawnGhostMobj(mobj); -#else - { - mobj_t *spawnmobj; - spawnmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->info->painchance); - P_SetTarget(&spawnmobj->target, mobj); - spawnmobj->color = SKINCOLOR_GREY; - } -#endif - P_Boss1Thinker(mobj); - break; - case MT_EGGMOBILE2: - P_Boss2Thinker(mobj); - break; - case MT_EGGMOBILE3: - P_Boss3Thinker(mobj); - break; - case MT_EGGMOBILE4: - P_Boss4Thinker(mobj); - break; - case MT_BLACKEGGMAN: - P_Boss7Thinker(mobj); - break; - case MT_METALSONIC_BATTLE: - P_Boss9Thinker(mobj); - break; - default: // Generic SOC-made boss - if (mobj->flags2 & MF2_SKULLFLY) - P_SpawnGhostMobj(mobj); - P_GenericBossThinker(mobj); - break; - } - if (mobj->flags2 & MF2_BOSSFLEE) - P_InstaThrust(mobj, mobj->angle, FixedMul(12*FRACUNIT, mobj->scale)); } else if (mobj->health <= 0) // Dead things think differently than the living. - switch (mobj->type) - { - case MT_BLUEBALL: - if ((mobj->tics>>2)+1 > 0 && (mobj->tics>>2)+1 <= tr_trans60) // tr_trans50 through tr_trans90, shifting once every second frame - mobj->frame = (NUMTRANSMAPS-((mobj->tics>>2)+1))<frame = tr_trans60<z <= mobj->floorz) - { - P_RemoveMobj(mobj); - return; - } - break; - case MT_EGGTRAP: // Egg Capsule animal release - if (mobj->fuse > 0 && mobj->fuse < 2*TICRATE-(TICRATE/7) - && (mobj->fuse & 3)) - { - INT32 i,j; - fixed_t x,y,z; - fixed_t ns; - mobj_t *mo2; - - i = P_RandomByte(); - z = mobj->subsector->sector->floorheight + ((P_RandomByte()&63)*FRACUNIT); - for (j = 0; j < 2; j++) - { - const angle_t fa = (P_RandomByte()*FINEANGLES/16) & FINEMASK; - ns = 64 * FRACUNIT; - x = mobj->x + FixedMul(FINESINE(fa),ns); - y = mobj->y + FixedMul(FINECOSINE(fa),ns); - - mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE); - ns = 4 * FRACUNIT; - mo2->momx = FixedMul(FINESINE(fa),ns); - mo2->momy = FixedMul(FINECOSINE(fa),ns); - - i = P_RandomByte(); - - if (i % 5 == 0) - P_SpawnMobj(x, y, z, MT_CHICKEN); - else if (i % 4 == 0) - P_SpawnMobj(x, y, z, MT_COW); - else if (i % 3 == 0) - { - P_SpawnMobj(x, y, z, MT_BIRD); - S_StartSound(mo2, mobj->info->deathsound); - } - else if ((i & 1) == 0) - P_SpawnMobj(x, y, z, MT_BUNNY); - else - P_SpawnMobj(x, y, z, MT_MOUSE); - } - - mobj->fuse--; - } - break; - case MT_PLAYER: - /// \todo Have the player's dead body completely finish its animation even if they've already respawned. - if (!(mobj->flags2 & MF2_DONTDRAW)) - { - if (!mobj->fuse) - { // Go away. - /// \todo Actually go ahead and remove mobj completely, and fix any bugs and crashes doing this creates. Chasecam should stop moving, and F12 should never return to it. - mobj->momz = 0; - if (mobj->player) - mobj->flags2 |= MF2_DONTDRAW; - else // safe to remove, nobody's going to complain! - { - P_RemoveMobj(mobj); - return; - } - } - else // Apply gravity to fall downwards. - P_SetObjectMomZ(mobj, -2*FRACUNIT/3, true); - } - break; - default: - break; - } - else switch (mobj->type) { - case MT_FALLINGROCK: - // Despawn rocks here in case zmovement code can't do so (blame slopes) - if (!mobj->momx && !mobj->momy && !mobj->momz - && ((mobj->eflags & MFE_VERTICALFLIP) ? - mobj->z + mobj->height >= mobj->ceilingz - : mobj->z <= mobj->floorz)) - { - P_RemoveMobj(mobj); - return; - } - P_MobjCheckWater(mobj); - break; - case MT_EMERALDSPAWN: - if (mobj->threshold) - { - mobj->threshold--; - - if (!mobj->threshold && !mobj->target && mobj->reactiontime) - { - mobj_t *emerald = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->reactiontime); - emerald->threshold = 42; - P_SetTarget(&mobj->target, emerald); - P_SetTarget(&emerald->target, mobj); - } - } - break; - case MT_AQUABUZZ: - case MT_BIGAIRMINE: - { - if (mobj->tracer && mobj->tracer->player && mobj->tracer->health > 0 - && P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius * 16) - { - // Home in on the target. - P_HomingAttack(mobj, mobj->tracer); - - if (mobj->z < mobj->floorz) - mobj->z = mobj->floorz; - - if (leveltime % mobj->info->painchance == 0) - S_StartSound(mobj, mobj->info->activesound); - } - else - { - // Try to find a player - P_LookForPlayers(mobj, true, true, mobj->radius * 16); - mobj->momx >>= 1; - mobj->momy >>= 1; - mobj->momz >>= 1; - } - } - break; - case MT_BIGMINE: - { - if (mobj->tracer && mobj->tracer->player && mobj->tracer->health > 0 - && P_AproxDistance(P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y), mobj->tracer->z - mobj->z) <= mobj->radius * 16) - { - P_MobjCheckWater(mobj); - - // Home in on the target. - P_HomingAttack(mobj, mobj->tracer); - - // Don't let it go out of water - if (mobj->z + mobj->height > mobj->watertop) - mobj->z = mobj->watertop - mobj->height; - - if (mobj->z < mobj->floorz) - mobj->z = mobj->floorz; - - if (leveltime % mobj->info->painchance == 0) - S_StartSound(mobj, mobj->info->activesound); - } - else - { - // Try to find a player - P_LookForPlayers(mobj, true, true, mobj->radius * 16); - mobj->momx >>= 1; - mobj->momy >>= 1; - mobj->momz >>= 1; - } - } - break; - case MT_SPINMACEPOINT: - if (leveltime & 1) - { - if (mobj->lastlook > mobj->movecount) - mobj->lastlook--; -/* - if (mobj->threshold > mobj->movefactor) - mobj->threshold -= FRACUNIT; - else if (mobj->threshold < mobj->movefactor) - mobj->threshold += FRACUNIT;*/ - } - break; - case MT_EGGCAPSULE: - if (!mobj->reactiontime) - { - // Target nearest player on your mare. - // (You can make it float up/down by adding MF_FLOAT, - // but beware level design pitfalls.) - fixed_t shortest = 1024*FRACUNIT; - INT32 i; - P_SetTarget(&mobj->target, NULL); - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo - && players[i].mare == mobj->threshold && players[i].health > 1) - { - fixed_t dist = P_AproxDistance(players[i].mo->x - mobj->x, players[i].mo->y - mobj->y); - if (dist < shortest) - { - P_SetTarget(&mobj->target, players[i].mo); - shortest = dist; - } - } - } - break; - case MT_EGGMOBILE2_POGO: - if (!mobj->target - || !mobj->target->health - || mobj->target->state == &states[mobj->target->info->spawnstate] - || mobj->target->state == &states[mobj->target->info->raisestate]) - { - P_RemoveMobj(mobj); - return; - } - P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z - mobj->height); - break; - case MT_HAMMER: - if (mobj->z <= mobj->floorz) - { - P_RemoveMobj(mobj); - return; - } - break; - case MT_KOOPA: - P_KoopaThinker(mobj); - break; - case MT_REDRING: - if (((mobj->z < mobj->floorz) || (mobj->z + mobj->height > mobj->ceilingz)) - && mobj->flags & MF_MISSILE) - { - P_ExplodeMissile(mobj); - return; - } - break; - case MT_BOSSFLYPOINT: + if (!P_MobjDeadThink(mobj)) return; - case MT_NIGHTSCORE: - mobj->color = (UINT8)(leveltime % SKINCOLOR_WHITE); - break; - case MT_JETFUME1: - { - fixed_t jetx, jety; - - if (!mobj->target // if you have no target - || (!(mobj->target->flags & MF_BOSS) && mobj->target->health <= 0)) // or your target isn't a boss and it's popped now - { // then remove yourself as well! - P_RemoveMobj(mobj); - return; - } - - jetx = mobj->target->x + P_ReturnThrustX(mobj->target, mobj->target->angle, FixedMul(-64*FRACUNIT, mobj->target->scale)); - jety = mobj->target->y + P_ReturnThrustY(mobj->target, mobj->target->angle, FixedMul(-64*FRACUNIT, mobj->target->scale)); - - if (mobj->fuse == 56) // First one - { - P_UnsetThingPosition(mobj); - mobj->x = jetx; - mobj->y = jety; - if (mobj->target->eflags & MFE_VERTICALFLIP) - mobj->z = mobj->target->z + mobj->target->height - mobj->height - FixedMul(38*FRACUNIT, mobj->target->scale); - else - mobj->z = mobj->target->z + FixedMul(38*FRACUNIT, mobj->target->scale); - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_SetThingPosition(mobj); - } - else if (mobj->fuse == 57) - { - P_UnsetThingPosition(mobj); - mobj->x = jetx + P_ReturnThrustX(mobj->target, mobj->target->angle-ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); - mobj->y = jety + P_ReturnThrustY(mobj->target, mobj->target->angle-ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); - if (mobj->target->eflags & MFE_VERTICALFLIP) - mobj->z = mobj->target->z + mobj->target->height - mobj->height - FixedMul(12*FRACUNIT, mobj->target->scale); - else - mobj->z = mobj->target->z + FixedMul(12*FRACUNIT, mobj->target->scale); - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_SetThingPosition(mobj); - } - else if (mobj->fuse == 58) - { - P_UnsetThingPosition(mobj); - mobj->x = jetx + P_ReturnThrustX(mobj->target, mobj->target->angle+ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); - mobj->y = jety + P_ReturnThrustY(mobj->target, mobj->target->angle+ANGLE_90, FixedMul(24*FRACUNIT, mobj->target->scale)); - if (mobj->target->eflags & MFE_VERTICALFLIP) - mobj->z = mobj->target->z + mobj->target->height - mobj->height - FixedMul(12*FRACUNIT, mobj->target->scale); - else - mobj->z = mobj->target->z + FixedMul(12*FRACUNIT, mobj->target->scale); - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_SetThingPosition(mobj); - } - else if (mobj->fuse == 59) - { - jetx = mobj->target->x + P_ReturnThrustX(mobj->target, mobj->target->angle, -mobj->target->radius); - jety = mobj->target->y + P_ReturnThrustY(mobj->target, mobj->target->angle, -mobj->target->radius); - P_UnsetThingPosition(mobj); - mobj->x = jetx; - mobj->y = jety; - if (mobj->target->eflags & MFE_VERTICALFLIP) - mobj->z = mobj->target->z + mobj->target->height/2 + mobj->height/2; - else - mobj->z = mobj->target->z + mobj->target->height/2 - mobj->height/2; - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_SetThingPosition(mobj); - } - mobj->fuse++; - } - break; - case MT_PROPELLER: - { - fixed_t jetx, jety; - - if (!mobj->target // if you have no target - || (!(mobj->target->flags & MF_BOSS) && mobj->target->health <= 0)) // or your target isn't a boss and it's popped now - { // then remove yourself as well! - P_RemoveMobj(mobj); - return; - } - - jetx = mobj->target->x + P_ReturnThrustX(mobj->target, mobj->target->angle, FixedMul(-60*FRACUNIT, mobj->target->scale)); - jety = mobj->target->y + P_ReturnThrustY(mobj->target, mobj->target->angle, FixedMul(-60*FRACUNIT, mobj->target->scale)); - - P_UnsetThingPosition(mobj); - mobj->x = jetx; - mobj->y = jety; - mobj->z = mobj->target->z + FixedMul(17*FRACUNIT, mobj->target->scale); - mobj->angle = mobj->target->angle - ANGLE_180; - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_SetThingPosition(mobj); - } - break; - case MT_JETFLAME: - { - if (!mobj->target // if you have no target - || (!(mobj->target->flags & MF_BOSS) && mobj->target->health <= 0)) // or your target isn't a boss and it's popped now - { // then remove yourself as well! - P_RemoveMobj(mobj); - return; - } - - P_UnsetThingPosition(mobj); - mobj->x = mobj->target->x; - mobj->y = mobj->target->y; - mobj->z = mobj->target->z - FixedMul(50*FRACUNIT, mobj->target->scale); - mobj->floorz = mobj->z; - mobj->ceilingz = mobj->z+mobj->height; - P_SetThingPosition(mobj); - } - break; - case MT_NIGHTSDRONE: - if (mobj->state >= &states[S_NIGHTSDRONE_SPARKLING1] && mobj->state <= &states[S_NIGHTSDRONE_SPARKLING16]) - { - mobj->flags2 &= ~MF2_DONTDRAW; - mobj->z = mobj->floorz + mobj->height + (mobj->spawnpoint->options >> ZSHIFT) * FRACUNIT; - mobj->angle = 0; - - if (!mobj->target) - { - mobj_t *goalpost = P_SpawnMobj(mobj->x, mobj->y, mobj->z + FRACUNIT, MT_NIGHTSGOAL); - CONS_Debug(DBG_NIGHTSBASIC, "Adding goal post\n"); - goalpost->angle = mobj->angle; - P_SetTarget(&mobj->target, goalpost); - } - - if (G_IsSpecialStage(gamemap)) - { // Never show the NiGHTS drone in special stages. Check ANYONE for bonustime. - INT32 i; - boolean bonustime = false; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].bonustime) - { - bonustime = true; - break; - } - if (!bonustime) - { - mobj->flags &= ~MF_NOGRAVITY; - P_SetMobjState(mobj, S_NIGHTSDRONE1); - mobj->flags2 |= MF2_DONTDRAW; - } - } - else if (mobj->tracer && mobj->tracer->player) - { - if (!(mobj->tracer->player->pflags & PF_NIGHTSMODE)) - { - mobj->flags &= ~MF_NOGRAVITY; - mobj->flags2 &= ~MF2_DONTDRAW; - P_SetMobjState(mobj, S_NIGHTSDRONE1); - } - else if (!mobj->tracer->player->bonustime) - { - mobj->flags &= ~MF_NOGRAVITY; - P_SetMobjState(mobj, S_NIGHTSDRONE1); - } - } - } - else - { - if (G_IsSpecialStage(gamemap)) - { // Never show the NiGHTS drone in special stages. Check ANYONE for bonustime. - INT32 i; - - boolean bonustime = false; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].bonustime) - { - bonustime = true; - break; - } - - if (bonustime) - { - P_SetMobjState(mobj, S_NIGHTSDRONE_SPARKLING1); - mobj->flags |= MF_NOGRAVITY; - } - else - { - if (mobj->target) - { - CONS_Debug(DBG_NIGHTSBASIC, "Removing goal post\n"); - P_RemoveMobj(mobj->target); - P_SetTarget(&mobj->target, NULL); - } - mobj->flags2 |= MF2_DONTDRAW; - } - } - else if (mobj->tracer && mobj->tracer->player) - { - if (mobj->target) - { - CONS_Debug(DBG_NIGHTSBASIC, "Removing goal post\n"); - P_RemoveMobj(mobj->target); - P_SetTarget(&mobj->target, NULL); - } - - if (mobj->tracer->player->pflags & PF_NIGHTSMODE) - { - if (mobj->tracer->player->bonustime) - { - P_SetMobjState(mobj, S_NIGHTSDRONE_SPARKLING1); - mobj->flags |= MF_NOGRAVITY; - } - else - mobj->flags2 |= MF2_DONTDRAW; - } - else // Not NiGHTS - mobj->flags2 &= ~MF2_DONTDRAW; - } - mobj->angle += ANG10; - if (mobj->z <= mobj->floorz) - mobj->momz = 5*FRACUNIT; - } - break; - case MT_PLAYER: - if (mobj->player) - P_PlayerMobjThinker(mobj); + } + else + { + if (!P_MobjRegularThink(mobj)) return; - case MT_SKIM: - // check mobj against possible water content, before movement code - P_MobjCheckWater(mobj); - - // Keep Skim at water surface - if (mobj->z <= mobj->watertop) - { - mobj->flags |= MF_NOGRAVITY; - if (mobj->z < mobj->watertop) - { - if (mobj->watertop - mobj->z <= FixedMul(mobj->info->speed*FRACUNIT, mobj->scale)) - mobj->z = mobj->watertop; - else - mobj->momz = FixedMul(mobj->info->speed*FRACUNIT, mobj->scale); - } - } - else - { - mobj->flags &= ~MF_NOGRAVITY; - if (mobj->z > mobj->watertop && mobj->z - mobj->watertop < FixedMul(MAXSTEPMOVE, mobj->scale)) - mobj->z = mobj->watertop; - } - break; - case MT_RING: - case MT_COIN: - case MT_BLUEBALL: - case MT_REDTEAMRING: - case MT_BLUETEAMRING: - // No need to check water. Who cares? - P_RingThinker(mobj); - if (mobj->flags2 & MF2_NIGHTSPULL) - P_NightsItemChase(mobj); - else - A_AttractChase(mobj); - return; - // Flung items - case MT_FLINGRING: - case MT_FLINGCOIN: - if (mobj->flags2 & MF2_NIGHTSPULL) - P_NightsItemChase(mobj); - else - A_AttractChase(mobj); - break; - case MT_NIGHTSWING: - if (mobj->flags2 & MF2_NIGHTSPULL) - P_NightsItemChase(mobj); - break; - case MT_SHELL: - if (mobj->threshold > TICRATE) - mobj->threshold--; - - if (mobj->state != &states[S_SHELL]) - { - mobj->angle = R_PointToAngle2(0, 0, mobj->momx, mobj->momy); - P_InstaThrust(mobj, mobj->angle, FixedMul(mobj->info->speed, mobj->scale)); - } - break; - case MT_TURRET: - P_MobjCheckWater(mobj); - P_CheckPosition(mobj, mobj->x, mobj->y); - if (P_MobjWasRemoved(mobj)) - return; - mobj->floorz = tmfloorz; - mobj->ceilingz = tmceilingz; - - if ((mobj->eflags & MFE_UNDERWATER) && mobj->health > 0) - { - P_SetMobjState(mobj, mobj->info->deathstate); - mobj->health = 0; - mobj->flags2 &= ~MF2_FIRING; - } - else if (mobj->health > 0 && mobj->z + mobj->height > mobj->ceilingz) // Crushed - { - INT32 i,j; - fixed_t ns; - fixed_t x,y,z; - mobj_t *mo2; - - z = mobj->subsector->sector->floorheight + FixedMul(64*FRACUNIT, mobj->scale); - for (j = 0; j < 2; j++) - { - for (i = 0; i < 32; i++) - { - const angle_t fa = (i*FINEANGLES/16) & FINEMASK; - ns = FixedMul(64 * FRACUNIT, mobj->scale); - x = mobj->x + FixedMul(FINESINE(fa),ns); - y = mobj->y + FixedMul(FINECOSINE(fa),ns); - - mo2 = P_SpawnMobj(x, y, z, MT_EXPLODE); - ns = FixedMul(16 * FRACUNIT, mobj->scale); - mo2->momx = FixedMul(FINESINE(fa),ns); - mo2->momy = FixedMul(FINECOSINE(fa),ns); - } - z -= FixedMul(32*FRACUNIT, mobj->scale); - } - P_SetMobjState(mobj, mobj->info->deathstate); - mobj->health = 0; - mobj->flags2 &= ~MF2_FIRING; - } - break; - case MT_BLUEFLAG: - case MT_REDFLAG: - { - sector_t *sec2; - sec2 = P_ThingOnSpecial3DFloor(mobj); - if ((sec2 && GETSECSPECIAL(sec2->special, 4) == 2) || (GETSECSPECIAL(mobj->subsector->sector->special, 4) == 2)) - mobj->fuse = 1; // Return to base. - break; - } - case MT_CANNONBALL: -#ifdef FLOORSPLATS - R_AddFloorSplat(mobj->tracer->subsector, mobj->tracer, "TARGET", mobj->tracer->x, - mobj->tracer->y, mobj->tracer->floorz, SPLATDRAWMODE_SHADE); -#endif - break; - case MT_SPINFIRE: - if (mobj->eflags & MFE_VERTICALFLIP) - mobj->z = mobj->ceilingz - mobj->height; - else - mobj->z = mobj->floorz; - /* FALLTHRU */ - default: - // check mobj against possible water content, before movement code - P_MobjCheckWater(mobj); - - // Extinguish fire objects in water - if (mobj->flags & MF_FIRE && mobj->type != MT_PUMA && mobj->type != MT_FIREBALL - && (mobj->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - { - P_KillMobj(mobj, NULL, NULL); - return; - } - break; } if (P_MobjWasRemoved(mobj)) return; - if (mobj->flags2 & MF2_FIRING && mobj->target && mobj->health > 0) - { - if (mobj->state->action.acp1 == (actionf_p1)A_Boss1Laser) - { - var1 = mobj->state->var1; - var2 = mobj->state->var2; - mobj->state->action.acp1(mobj); - } - else if (leveltime & 1) // Fire mode - { - mobj_t *missile; - - if (mobj->target->player && mobj->target->player->nightstime) - { - fixed_t oldval = mobjinfo[mobj->extravalue1].speed; - - mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x+mobj->target->momx, mobj->target->y+mobj->target->momy); - mobjinfo[mobj->extravalue1].speed = FixedMul(60*FRACUNIT, mobj->scale); - missile = P_SpawnMissile(mobj, mobj->target, mobj->extravalue1); - mobjinfo[mobj->extravalue1].speed = oldval; - } - else - { - mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); - missile = P_SpawnMissile(mobj, mobj->target, mobj->extravalue1); - } - - if (missile) - { - if (mobj->flags2 & MF2_SUPERFIRE) - missile->flags2 |= MF2_SUPERFIRE; - - if (mobj->info->attacksound) - S_StartSound(missile, mobj->info->attacksound); - } - } - else - mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y); - } + if (mobj->flags2 & MF2_FIRING) + P_FiringThink(mobj); if (mobj->flags & MF_AMBIENT) { @@ -7220,164 +10209,8 @@ void P_MobjThinker(mobj_t *mobj) } // Check fuse - if (mobj->fuse) - { - mobj->fuse--; - if (!mobj->fuse) - { - subsector_t *ss; - fixed_t x, y, z; - mobj_t *flagmo, *newmobj; - -#ifdef HAVE_BLUA - if (!LUAh_MobjFuse(mobj) && !P_MobjWasRemoved(mobj)) -#endif - switch (mobj->type) - { - // gargoyle and snowman handled in P_PushableThinker, not here - case MT_THROWNGRENADE: - case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: - P_SetMobjState(mobj, mobj->info->deathstate); - break; - case MT_BLUEFLAG: - case MT_REDFLAG: - if (mobj->spawnpoint) - { - x = mobj->spawnpoint->x << FRACBITS; - y = mobj->spawnpoint->y << FRACBITS; - ss = R_PointInSubsector(x, y); - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) - { - z = ss->sector->ceilingheight - mobjinfo[mobj->type].height; - if (mobj->spawnpoint->options >> ZSHIFT) - z -= (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; - } - else - { - z = ss->sector->floorheight; - if (mobj->spawnpoint->options >> ZSHIFT) - z += (mobj->spawnpoint->options >> ZSHIFT) << FRACBITS; - } - flagmo = P_SpawnMobj(x, y, z, mobj->type); - flagmo->spawnpoint = mobj->spawnpoint; - if (mobj->spawnpoint->options & MTF_OBJECTFLIP) - { - flagmo->eflags |= MFE_VERTICALFLIP; - flagmo->flags2 |= MF2_OBJECTFLIP; - } - - if (mobj->type == MT_REDFLAG) - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x85, M_GetText("Red flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 1 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 2) - S_StartSound(NULL, sfx_hoop3); - - redflag = flagmo; - } - else // MT_BLUEFLAG - { - if (!(mobj->flags2 & MF2_JUSTATTACKED)) - CONS_Printf(M_GetText("The %c%s%c has returned to base.\n"), 0x84, M_GetText("Blue flag"), 0x80); - - // Assumedly in splitscreen players will be on opposing teams - if (players[consoleplayer].ctfteam == 2 || splitscreen) - S_StartSound(NULL, sfx_hoop1); - else if (players[consoleplayer].ctfteam == 1) - S_StartSound(NULL, sfx_hoop3); - - blueflag = flagmo; - } - } - P_RemoveMobj(mobj); - return; - case MT_YELLOWTV: // Ring shield box - case MT_BLUETV: // Force shield box - case MT_GREENTV: // Water shield box - case MT_BLACKTV: // Bomb shield box - case MT_WHITETV: // Jump shield box - case MT_SNEAKERTV: // Super Sneaker box - case MT_SUPERRINGBOX: // 10-Ring box - case MT_REDRINGBOX: // Red Team 10-Ring box - case MT_BLUERINGBOX: // Blue Team 10-Ring box - case MT_INV: // Invincibility box - case MT_MIXUPBOX: // Teleporter Mixup box - case MT_RECYCLETV: // Recycler box - case MT_SCORETVSMALL: - case MT_SCORETVLARGE: - case MT_PRUP: // 1up! - case MT_EGGMANBOX: // Eggman box - case MT_GRAVITYBOX: // Gravity box - case MT_QUESTIONBOX: - if ((mobj->flags & MF_AMBUSH || mobj->flags2 & MF2_STRONGBOX) && mobj->type != MT_QUESTIONBOX) - { - mobjtype_t spawnchance[64]; - INT32 numchoices = 0, i = 0; - -// This define should make it a lot easier to organize and change monitor weights -#define SETMONITORCHANCES(type, strongboxamt, weakboxamt) \ -for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) spawnchance[numchoices++] = type - - // Type SRM WRM - SETMONITORCHANCES(MT_SNEAKERTV, 0, 10); // Super Sneakers - SETMONITORCHANCES(MT_INV, 2, 0); // Invincibility - SETMONITORCHANCES(MT_WHITETV, 3, 8); // Whirlwind Shield - SETMONITORCHANCES(MT_GREENTV, 3, 8); // Elemental Shield - SETMONITORCHANCES(MT_YELLOWTV, 2, 0); // Attraction Shield - SETMONITORCHANCES(MT_BLUETV, 3, 3); // Force Shield - SETMONITORCHANCES(MT_BLACKTV, 2, 0); // Armageddon Shield - SETMONITORCHANCES(MT_MIXUPBOX, 0, 1); // Teleporters - SETMONITORCHANCES(MT_RECYCLETV, 0, 1); // Recycler - SETMONITORCHANCES(MT_PRUP, 1, 1); // 1-Up - // ====================================== - // Total 16 32 - -#undef SETMONITORCHANCES - - i = P_RandomKey(numchoices); // Gotta love those random numbers! - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]); - - // If the monitor respawns randomly, transfer the flag. - if (mobj->flags & MF_AMBUSH) - newmobj->flags |= MF_AMBUSH; - - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2; - } - else - { - newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobj->type); - - // Transfer flags2 (strongbox, objectflip) - newmobj->flags2 = mobj->flags2; - } - P_RemoveMobj(mobj); // make sure they disappear - return; - case MT_METALSONIC_BATTLE: - break; // don't remove - case MT_SPIKE: - P_SetMobjState(mobj, mobj->state->nextstate); - mobj->fuse = mobj->info->speed; - if (mobj->spawnpoint) - mobj->fuse += mobj->spawnpoint->angle; - break; - case MT_NIGHTSCORE: - P_RemoveMobj(mobj); - return; - case MT_PLAYER: - break; // don't remove - default: - P_SetMobjState(mobj, mobj->info->xdeathstate); // will remove the mobj if S_NULL. - break; - } - if (P_MobjWasRemoved(mobj)) - return; - } - } + if (mobj->fuse && !P_FuseThink(mobj)) + return; I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); @@ -7411,6 +10244,8 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s #ifdef ESLOPE // Sliding physics for slidey mobjs! if (mobj->type == MT_FLINGRING || mobj->type == MT_FLINGCOIN + || mobj->type == MT_FLINGBLUESPHERE + || mobj->type == MT_FLINGNIGHTSCHIP || P_WeaponOrPanel(mobj->type) || mobj->type == MT_FLINGEMERALD || mobj->type == MT_BIGTUMBLEWEED @@ -7426,7 +10261,7 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health && P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz { - P_KillMobj(mobj, NULL, NULL); + P_KillMobj(mobj, NULL, NULL, DMG_DEATHPIT); return; } @@ -7440,7 +10275,7 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s && !(mobj->flags & MF_NOCLIPHEIGHT) && mobj->health > 0) { - P_KillMobj(mobj, NULL, NULL); + P_KillMobj(mobj, NULL, NULL, DMG_CRUSHED); return; } } @@ -7534,6 +10369,16 @@ void P_PushableThinker(mobj_t *mobj) if (mobj->flags & MF_PUSHABLE && !(mobj->momx || mobj->momy)) P_TryMove(mobj, mobj->x, mobj->y, true); + if (mobj->type == MT_MINECART && mobj->health) + { + // If player is ded, remove this minecart + if (!mobj->target || P_MobjWasRemoved(mobj->target) || !mobj->target->health || !mobj->target->player || mobj->target->player->powers[pw_carry] != CR_MINECART) + { + P_KillMobj(mobj, NULL, NULL, 0); + return; + } + } + if (mobj->fuse == 1) // it would explode in the MobjThinker code { mobj_t *spawnmo; @@ -7616,6 +10461,8 @@ void P_SceneryThinker(mobj_t *mobj) return; mobj->floorz = tmfloorz; mobj->ceilingz = tmceilingz; + mobj->floorrover = tmfloorrover; + mobj->ceilingrover = tmceilingrover; } else { @@ -7630,12 +10477,68 @@ void P_SceneryThinker(mobj_t *mobj) // GAME SPAWN FUNCTIONS // +static fixed_t P_DefaultMobjShadowScale (mobj_t *thing) +{ + switch (thing->type) + { + case MT_PLAYER: + case MT_ROLLOUTROCK: + + case MT_EGGMOBILE4_MACE: + case MT_SMALLMACE: + case MT_BIGMACE: + + case MT_SMALLGRABCHAIN: + case MT_BIGGRABCHAIN: + + case MT_YELLOWSPRINGBALL: + case MT_REDSPRINGBALL: + + return FRACUNIT; + + case MT_RING: + case MT_FLINGRING: + + case MT_BLUESPHERE: + case MT_FLINGBLUESPHERE: + case MT_BOMBSPHERE: + + case MT_REDTEAMRING: + case MT_BLUETEAMRING: + case MT_REDFLAG: + case MT_BLUEFLAG: + + case MT_EMBLEM: + + case MT_TOKEN: + case MT_EMERALD1: + case MT_EMERALD2: + case MT_EMERALD3: + case MT_EMERALD4: + case MT_EMERALD5: + case MT_EMERALD6: + case MT_EMERALD7: + case MT_EMERHUNT: + case MT_FLINGEMERALD: + + return 2*FRACUNIT/3; + + default: + + if (thing->flags & (MF_ENEMY|MF_BOSS)) + return FRACUNIT; + else + return 0; + } +} + // // P_SpawnMobj // mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { const mobjinfo_t *info = &mobjinfo[type]; + SINT8 sc = -1; state_t *st; mobj_t *mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); @@ -7651,7 +10554,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->height = info->height; mobj->flags = info->flags; - mobj->health = info->spawnhealth; + mobj->health = (info->spawnhealth ? info->spawnhealth : 1); mobj->reactiontime = info->reactiontime; @@ -7665,11 +10568,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation(mobj, st); mobj->friction = ORIG_FRICTION; - mobj->movefactor = ORIG_FRICTION_FACTOR; + mobj->movefactor = FRACUNIT; // All mobjs are created at 100% scale. mobj->scale = FRACUNIT; @@ -7698,6 +10601,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -7726,7 +10632,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) else mobj->z = z; -#ifdef HAVE_BLUA + // Set shadowscale here, before spawn hook so that Lua can change it + mobj->shadowscale = P_DefaultMobjShadowScale(mobj); + // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using P_RemoveMobj on the newly created mobj in "MobjSpawn" Lua hooks! if (LUAh_MobjSpawn(mobj)) @@ -7737,11 +10645,16 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) else if (P_MobjWasRemoved(mobj)) return NULL; else -#endif switch (mobj->type) { + case MT_ALTVIEWMAN: + if (titlemapinaction) mobj->flags &= ~MF_NOTHINK; + break; + case MT_LOCKONINF: + P_SetScale(mobj, (mobj->destscale = 3*mobj->scale)); + break; case MT_CYBRAKDEMON_NAPALM_BOMB_LARGE: - mobj->fuse = mobj->info->mass; + mobj->fuse = mobj->info->painchance; break; case MT_BLACKEGGMAN: { @@ -7751,12 +10664,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) P_SetTarget(&spawn->target, mobj); } break; - case MT_BLACKEGGMAN_HELPER: - // Collision helper can be stood on but not pushed - mobj->flags2 |= MF2_STANDONME; - break; - case MT_SPIKE: - mobj->flags2 |= MF2_STANDONME; + case MT_FAKEMOBILE: + case MT_EGGSHIELD: + mobj->flags2 |= MF2_INVERTAIMABLE; break; case MT_DETON: mobj->movedir = 0; @@ -7771,52 +10681,113 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) } break; case MT_UNIDUS: - { - INT32 i; - mobj_t *ball; - // Spawn "damage" number of "painchance" spikeball mobjs - // threshold is the distance they should keep from the MT_UNIDUS (touching radius + ball painchance) - for (i = 0; i < mobj->info->damage; i++) { - ball = P_SpawnMobj(x, y, z, mobj->info->painchance); - ball->destscale = mobj->scale; - P_SetScale(ball, mobj->scale); - P_SetTarget(&ball->target, mobj); - ball->movedir = FixedAngle(FixedMul(FixedDiv(i<info->damage<threshold = ball->radius + mobj->radius + FixedMul(ball->info->painchance, ball->scale); + INT32 i; + mobj_t *ball; + // Spawn "damage" number of "painchance" spikeball mobjs + // threshold is the distance they should keep from the MT_UNIDUS (touching radius + ball painchance) + for (i = 0; i < mobj->info->damage; i++) + { + ball = P_SpawnMobj(x, y, z, mobj->info->painchance); + ball->destscale = mobj->scale; + P_SetScale(ball, mobj->scale); + P_SetTarget(&ball->target, mobj); + ball->movedir = FixedAngle(FixedMul(FixedDiv(i<info->damage<threshold = ball->radius + mobj->radius + FixedMul(ball->info->painchance, ball->scale); - var1 = ball->state->var1, var2 = ball->state->var2; - ball->state->action.acp1(ball); + var1 = ball->state->var1, var2 = ball->state->var2; + ball->state->action.acp1(ball); + } } break; - } case MT_POINTY: - { - INT32 q; - mobj_t *ball, *lastball = mobj; - - for (q = 0; q < mobj->info->painchance; q++) { - ball = P_SpawnMobj(x, y, z, mobj->info->mass); - ball->destscale = mobj->scale; - P_SetScale(ball, mobj->scale); - P_SetTarget(&lastball->tracer, ball); - P_SetTarget(&ball->target, mobj); - lastball = ball; + INT32 q; + mobj_t *ball, *lastball = mobj; + + for (q = 0; q < mobj->info->painchance; q++) + { + ball = P_SpawnMobj(x, y, z, mobj->info->mass); + ball->destscale = mobj->scale; + P_SetScale(ball, mobj->scale); + P_SetTarget(&lastball->tracer, ball); + P_SetTarget(&ball->target, mobj); + lastball = ball; + } + } + break; + case MT_CRUSHSTACEAN: + { + mobj_t *bigmeatyclaw = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_CRUSHCLAW); + bigmeatyclaw->angle = mobj->angle + ((mobj->flags2 & MF2_AMBUSH) ? ANGLE_90 : ANGLE_270);; + P_SetTarget(&mobj->tracer, bigmeatyclaw); + P_SetTarget(&bigmeatyclaw->tracer, mobj); + mobj->reactiontime >>= 1; + } + break; + case MT_BANPYURA: + { + mobj_t *bigmeatyclaw = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_BANPSPRING); + bigmeatyclaw->angle = mobj->angle + ((mobj->flags2 & MF2_AMBUSH) ? ANGLE_90 : ANGLE_270);; + P_SetTarget(&mobj->tracer, bigmeatyclaw); + P_SetTarget(&bigmeatyclaw->tracer, mobj); + mobj->reactiontime >>= 1; + } + break; + case MT_BIGMINE: + mobj->extravalue1 = FixedHypot(mobj->x, mobj->y)>>FRACBITS; + break; + case MT_WAVINGFLAG1: + case MT_WAVINGFLAG2: + { + mobj_t *prev = mobj, *cur; + UINT8 i; + for (i = 0; i <= 16; i++) // probably should be < but staying authentic to the Lua version + { + cur = P_SpawnMobjFromMobj(mobj, 0, 0, 0, ((mobj->type == MT_WAVINGFLAG1) ? MT_WAVINGFLAGSEG1 : MT_WAVINGFLAGSEG2));; + P_SetTarget(&prev->tracer, cur); + cur->extravalue1 = i; + prev = cur; + } } break; - } case MT_EGGMOBILE2: // Special condition for the 2nd boss. mobj->watertop = mobj->info->speed; break; - case MT_BIRD: - case MT_BUNNY: - case MT_MOUSE: - case MT_CHICKEN: - case MT_COW: - case MT_REDBIRD: - mobj->fuse = P_RandomRange(300, 350); + case MT_EGGMOBILE3: + mobj->movefactor = -512*FRACUNIT; + mobj->flags2 |= MF2_CLASSICPUSH; + break; + case MT_EGGMOBILE4: + mobj->flags2 |= MF2_INVERTAIMABLE; + break; + case MT_FLICKY_08: + mobj->color = (P_RandomChance(FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_AQUA); + break; + case MT_BALLOON: + mobj->color = SKINCOLOR_RED; + break; + case MT_EGGROBO1: + mobj->movecount = P_RandomKey(13); + mobj->color = SKINCOLOR_RUBY + P_RandomKey(MAXSKINCOLORS - SKINCOLOR_RUBY); + break; + case MT_HIVEELEMENTAL: + mobj->extravalue1 = 5; + break; + case MT_SMASHINGSPIKEBALL: + mobj->movecount = mobj->z; + break; + case MT_SPINBOBERT: + { + mobj_t *fire; + fire = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_SPINBOBERT_FIRE1); + P_SetTarget(&fire->target, mobj); + P_SetTarget(&mobj->hnext, fire); + fire = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_SPINBOBERT_FIRE2); + P_SetTarget(&fire->target, mobj); + P_SetTarget(&mobj->hprev, fire); + } break; case MT_REDRING: // Make MT_REDRING red by default mobj->color = skincolor_redring; @@ -7826,8 +10797,14 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) case MT_EXTRALARGEBUBBLE: mobj->fuse += 30 * TICRATE; break; + case MT_NIGHTSDRONE: + nummaprings = -1; // no perfect bonus, rings are free + break; case MT_EGGCAPSULE: - mobj->extravalue1 = -1; // timer for how long a player has been at the capsule + mobj->reactiontime = 0; + mobj->extravalue1 = mobj->cvmem =\ + mobj->cusval = mobj->movecount =\ + mobj->lastlook = mobj->extravalue2 = -1; break; case MT_REDTEAMRING: mobj->color = skincolor_redteam; @@ -7837,14 +10814,90 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) break; case MT_RING: case MT_COIN: - case MT_BLUEBALL: - nummaprings++; + case MT_NIGHTSSTAR: + if (nummaprings >= 0) + nummaprings++; + break; + case MT_METALSONIC_RACE: + mobj->skin = &skins[5]; + /* FALLTHRU */ + case MT_METALSONIC_BATTLE: + mobj->color = skins[5].prefcolor; + sc = 5; + break; + case MT_FANG: + sc = 4; + break; + case MT_ROSY: + sc = 3; + break; + case MT_CORK: + mobj->flags2 |= MF2_SUPERFIRE; + break; + case MT_FBOMB: + mobj->flags2 |= MF2_EXPLOSION; + break; + case MT_OILLAMP: + { + mobj_t* overlay = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_OVERLAY); + P_SetTarget(&overlay->target, mobj); + P_SetMobjState(overlay, S_OILLAMPFLARE); + break; + } + case MT_TNTBARREL: + mobj->momx = 1; //stack hack + mobj->flags2 |= MF2_INVERTAIMABLE; + break; + case MT_MINECARTEND: + P_SetTarget(&mobj->tracer, P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_MINECARTENDSOLID)); + mobj->tracer->angle = mobj->angle + ANGLE_90; + break; + case MT_TORCHFLOWER: + { + mobj_t *fire = P_SpawnMobjFromMobj(mobj, 0, 0, 46*FRACUNIT, MT_FLAME); + P_SetTarget(&mobj->target, fire); + break; + } + case MT_PYREFLY: + mobj->extravalue1 = (FixedHypot(mobj->x, mobj->y)/FRACUNIT) % 360; + mobj->extravalue2 = 0; + mobj->fuse = 100; + break; + case MT_SIGN: + P_SetTarget(&mobj->tracer, P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_OVERLAY)); + P_SetTarget(&mobj->tracer->target, mobj); + P_SetMobjState(mobj->tracer, S_SIGNBOARD); + mobj->tracer->movedir = ANGLE_90; default: break; } + if (sc != -1 && !(mobj->flags2 & MF2_SLIDEPUSH)) + { + UINT8 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + if (players[i].skin == sc) + { + mobj->color = SKINCOLOR_SILVER; + mobj->colorized = true; + mobj->flags2 |= MF2_SLIDEPUSH; + break; + } + } + } + if (!(mobj->flags & MF_NOTHINK)) - P_AddThinker(&mobj->thinker); + P_AddThinker(THINK_MOBJ, &mobj->thinker); + + if (mobj->skin) // correct inadequecies above. + { + mobj->sprite2 = P_GetSkinSprite2(mobj->skin, (mobj->frame & FF_FRAMEMASK), NULL); + mobj->frame &= ~FF_FRAMEMASK; + } // Call action functions when the state is set if (st->action.acp1 && (mobj->flags & MF_RUNSPAWNFUNC)) @@ -7861,9 +10914,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { var1 = st->var1; var2 = st->var2; -#ifdef HAVE_BLUA astate = st; -#endif st->action.acp1(mobj); // DANGER! This can cause P_SpawnMobj to return NULL! // Avoid using MF_RUNSPAWNFUNC on mobjs whose spawn state expects target or tracer to already be set! @@ -7896,7 +10947,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits.. - mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set + P_SetupStateAnimation((mobj_t*)mobj, st); // set subsector and/or block links P_SetPrecipitationThingPosition(mobj); @@ -7912,11 +10963,14 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype #endif mobj->subsector->sector->ceilingheight; + mobj->floorrover = NULL; + mobj->ceilingrover = NULL; + mobj->z = z; mobj->momz = mobjinfo[type].speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; - P_AddThinker(&mobj->thinker); + P_AddThinker(THINK_PRECIP, &mobj->thinker); CalculatePrecipFloor(mobj); @@ -7958,22 +11012,18 @@ size_t iquehead, iquetail; void P_RemoveMobj(mobj_t *mobj) { I_Assert(mobj != NULL); -#ifdef HAVE_BLUA if (P_MobjWasRemoved(mobj)) return; // something already removing this mobj. mobj->thinker.function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; // shh. no recursing. LUAh_MobjRemoved(mobj); mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work. -#else - I_Assert(!P_MobjWasRemoved(mobj)); -#endif // Rings only, please! if (mobj->spawnpoint && (mobj->type == MT_RING || mobj->type == MT_COIN - || mobj->type == MT_BLUEBALL + || mobj->type == MT_NIGHTSSTAR || mobj->type == MT_REDTEAMRING || mobj->type == MT_BLUETEAMRING || P_WeaponOrPanel(mobj->type)) @@ -7990,6 +11040,12 @@ void P_RemoveMobj(mobj_t *mobj) if (mobj->type == MT_OVERLAY) P_RemoveOverlay(mobj); + if (mobj->player && mobj->player->followmobj) + { + P_RemoveMobj(mobj->player->followmobj); + P_SetTarget(&mobj->player->followmobj, NULL); + } + mobj->health = 0; // Just because // unlink from sector and block lists @@ -8012,37 +11068,35 @@ void P_RemoveMobj(mobj_t *mobj) // Remove any references to other mobjs. P_SetTarget(&mobj->target, P_SetTarget(&mobj->tracer, NULL)); - // free block + if (mobj->hnext && !P_MobjWasRemoved(mobj->hnext)) + P_SetTarget(&mobj->hnext->hprev, mobj->hprev); + if (mobj->hprev && !P_MobjWasRemoved(mobj->hprev)) + P_SetTarget(&mobj->hprev->hnext, mobj->hnext); + + P_SetTarget(&mobj->hnext, P_SetTarget(&mobj->hprev, NULL)); + // DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error. - if (mobj->flags & MF_NOTHINK && !mobj->thinker.next) +#ifdef SCRAMBLE_REMOVED + // Invalidate mobj_t data to cause crashes if accessed! + memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); +#endif + + // free block + if (!mobj->thinker.next) { // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through! + INT32 prevreferences; if (!mobj->thinker.references) { -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset(mobj, 0xff, sizeof(mobj_t)); -#endif - Z_Free(mobj); // No refrences? Can be removed immediately! :D - } - else - { // Add thinker just to delay removing it until refrences are gone. - mobj->flags &= ~MF_NOTHINK; - P_AddThinker((thinker_t *)mobj); -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif - P_RemoveThinker((thinker_t *)mobj); + Z_Free(mobj); // No refrrences? Can be removed immediately! :D + return; } + + prevreferences = mobj->thinker.references; + P_AddThinker(THINK_MOBJ, (thinker_t *)mobj); + mobj->thinker.references = prevreferences; } - else - { -#ifdef SCRAMBLE_REMOVED - // Invalidate mobj_t data to cause crashes if accessed! - memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t)); -#endif - P_RemoveThinker((thinker_t *)mobj); - } + + P_RemoveThinker((thinker_t *)mobj); } // This does not need to be added to Lua. @@ -8094,16 +11148,15 @@ consvar_t cv_itemrespawntime = {"respawnitemtime", "30", CV_NETVAR|CV_CHEAT, res consvar_t cv_itemrespawn = {"respawnitem", "On", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t flagtime_cons_t[] = {{0, "MIN"}, {300, "MAX"}, {0, NULL}}; consvar_t cv_flagtime = {"flagtime", "30", CV_NETVAR|CV_CHEAT, flagtime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; void P_SpawnPrecipitation(void) { - INT32 i, j, mrand; + INT32 i, mrand; fixed_t basex, basey, x, y, height; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; - if (dedicated || !cv_precipdensity.value || curWeather == PRECIP_NONE) + if (dedicated || !(cv_drawdist_precip.value) || curWeather == PRECIP_NONE) return; // Use the blockmap to narrow down our placing patterns @@ -8112,50 +11165,47 @@ void P_SpawnPrecipitation(void) basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; - for (j = 0; j < cv_precipdensity.value; ++j) + x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); + y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); + + precipsector = R_PointInSubsectorOrNull(x, y); + + // No sector? Stop wasting time, + // move on to the next entry in the blockmap + if (!precipsector) + continue; + + // Exists, but is too small for reasonable precipitation. + if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingheight; + + if (curWeather == PRECIP_SNOW) { - x = basex + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); - y = basey + ((M_RandomKey(MAPBLOCKUNITS<<3)<>3); - - precipsector = R_IsPointInSubsector(x, y); - - // No sector? Stop wasting time, - // move on to the next entry in the blockmap - if (!precipsector) - break; - - // Exists, but is too small for reasonable precipitation. - if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<sector->ceilingpic != skyflatnum)) == !(precipsector->sector->flags & SF_INVERTPRECIP)) continue; - // Don't set height yet... - height = precipsector->sector->ceilingheight; - - if (curWeather == PRECIP_SNOW) - { - // Not in a sector with visible sky -- exception for NiGHTS. - if (!(maptol & TOL_NIGHTS) && precipsector->sector->ceilingpic != skyflatnum) - continue; - - rainmo = P_SpawnSnowMobj(x, y, height, MT_SNOWFLAKE); - mrand = M_RandomByte(); - if (mrand < 64) - P_SetPrecipMobjState(rainmo, S_SNOW3); - else if (mrand < 144) - P_SetPrecipMobjState(rainmo, S_SNOW2); - } - else // everything else. - { - // Not in a sector with visible sky. - if (precipsector->sector->ceilingpic != skyflatnum) - continue; - - rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); - } - - // Randomly assign a height, now that floorz is set. - rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<sector->ceilingpic != skyflatnum) == !(precipsector->sector->flags & SF_INVERTPRECIP)) + continue; + + rainmo = P_SpawnRainMobj(x, y, height, MT_RAIN); + } + + // Randomly assign a height, now that floorz is set. + rainmo->z = M_RandomRange(rainmo->floorz>>FRACBITS, rainmo->ceilingz>>FRACBITS)<x << FRACBITS; - y = mthing->y << FRACBITS; - ss = R_PointInSubsector(x, y); + P_SpawnMapThing(mthing); - // find which type to spawn - for (i = 0; i < NUMMOBJTYPES; i++) - if (mthing->type == mobjinfo[i].doomednum) - break; - - if (i == NUMMOBJTYPES) // prevent creation of objects with this type -- Monster Iestyn 17/12/17 - { - // 3D Mode start Thing is unlikely to be added to the que, - // so don't bother checking for that specific type - CONS_Alert(CONS_WARNING, M_GetText("P_RespawnSpecials: Unknown thing type %d attempted to respawn at (%d, %d)\n"), mthing->type, mthing->x, mthing->y); - // pull it from the que - iquetail = (iquetail+1)&(ITEMQUESIZE-1); - return; - } - - //CTF rings should continue to respawn as normal rings outside of CTF. - if (gametype != GT_CTF) - { - if (i == MT_REDTEAMRING || i == MT_BLUETEAMRING) - i = MT_RING; - } - - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( -#ifdef ESLOPE - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : -#endif - ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT; - if (mthing->options & MTF_AMBUSH - && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) - z -= 24*FRACUNIT; - z -= mobjinfo[i].height; // Don't forget the height! - } - else - { - z = ( -#ifdef ESLOPE - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : -#endif - ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT; - if (mthing->options & MTF_AMBUSH - && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) - z += 24*FRACUNIT; - } - - mo = P_SpawnMobj(x, y, z, i); - mo->spawnpoint = mthing; - mo->angle = ANGLE_45 * (mthing->angle/45); - - if (mthing->options & MTF_OBJECTFLIP) - { - mo->eflags |= MFE_VERTICALFLIP; - mo->flags2 |= MF2_OBJECTFLIP; - } - } // pull it from the que iquetail = (iquetail+1)&(ITEMQUESIZE-1); } @@ -8406,45 +11406,52 @@ void P_SpawnPlayer(INT32 playernum) mobj_t *mobj; if (p->playerstate == PST_REBORN) - G_PlayerReborn(playernum); + G_PlayerReborn(playernum, false); // spawn as spectator determination if (!G_GametypeHasSpectators()) { - // Special case for (NiGHTS) special stages! - // if stage has already started, force players to become spectators until the next stage - if (multiplayer && netgame && G_IsSpecialStage(gamemap) && useNightsSS && leveltime > 0) - p->spectator = true; - else - p->spectator = false; + p->spectator = p->outofcoop = + (((multiplayer || netgame) && gametype == GT_COOP) // only question status in coop + && ((leveltime > 0 + && ((G_IsSpecialStage(gamemap)) // late join special stage + || (cv_coopstarposts.value == 2 && (p->jointime < 1 || p->outofcoop)))) // late join or die in new coop + || (!P_GetLives(p) && p->lives <= 0))); // game over and can't redistribute lives } - else if (netgame && p->jointime < 1) - p->spectator = true; - else if (multiplayer && !netgame) + else { - // If you're in a team game and you don't have a team assigned yet... - if (G_GametypeHasTeams() && p->ctfteam == 0) + p->outofcoop = false; + if (netgame && p->jointime < 1) { - changeteam_union NetPacket; - UINT16 usvalue; - NetPacket.value.l = NetPacket.value.b = 0; - - // Spawn as a spectator, - // yes even in splitscreen mode - p->spectator = true; - if (playernum&1) p->skincolor = skincolor_redteam; - else p->skincolor = skincolor_blueteam; - - // but immediately send a team change packet. - NetPacket.packet.playernum = playernum; - NetPacket.packet.verification = true; - NetPacket.packet.newteam = !(playernum&1) + 1; - - usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); - SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + // Averted by GTR_NOSPECTATORSPAWN. + p->spectator = (gametyperules & GTR_NOSPECTATORSPAWN) ? false : true; + } + else if (multiplayer && !netgame) + { + // If you're in a team game and you don't have a team assigned yet... + if (G_GametypeHasTeams() && p->ctfteam == 0) + { + changeteam_union NetPacket; + UINT16 usvalue; + NetPacket.value.l = NetPacket.value.b = 0; + + // Spawn as a spectator, + // yes even in splitscreen mode + p->spectator = true; + if (playernum&1) p->skincolor = skincolor_redteam; + else p->skincolor = skincolor_blueteam; + + // but immediately send a team change packet. + NetPacket.packet.playernum = playernum; + NetPacket.packet.verification = true; + NetPacket.packet.newteam = !(playernum&1) + 1; + + usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); + SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); + } + else // Otherwise, never spectator. + p->spectator = false; } - else // Otherwise, never spectator. - p->spectator = false; } if (G_GametypeHasTeams()) @@ -8461,6 +11468,9 @@ void P_SpawnPlayer(INT32 playernum) p->skincolor = skincolor_blueteam; } + if ((netgame || multiplayer) && ((gametyperules & GTR_SPAWNINVUL) || leveltime) && !p->spectator && !(maptol & TOL_NIGHTS)) + p->powers[pw_flashing] = flashingtics-1; // Babysitting deterrent + mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); (mobj->player = p)->mo = mobj; @@ -8473,12 +11483,14 @@ void P_SpawnPlayer(INT32 playernum) // (usefulness: when body mobj is detached from player (who respawns), // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; + P_SetupStateAnimation(mobj, mobj->state); - mobj->health = p->health; + mobj->health = 1; p->playerstate = PST_LIVE; p->bonustime = false; p->realtime = leveltime; + p->followitem = skins[p->skin].followitem; //awayview stuff p->awayviewmobj = NULL; @@ -8488,6 +11500,27 @@ void P_SpawnPlayer(INT32 playernum) P_SetScale(mobj, mobj->destscale); P_FlashPal(p, 0, 0); // Resets + // Set bounds accurately. + mobj->radius = FixedMul(skins[p->skin].radius, mobj->scale); + mobj->height = P_GetPlayerHeight(p); + + if (!leveltime && !p->spectator && ((maptol & TOL_NIGHTS) == TOL_NIGHTS) != (G_IsSpecialStage(gamemap))) // non-special NiGHTS stage or special non-NiGHTS stage + { + if (maptol & TOL_NIGHTS) + { + if (p == players) // this is totally the wrong place to do this aaargh. + { + mobj_t *idya = P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_GOTEMERALD); + idya->health = 0; // for identification + P_SetTarget(&idya->target, mobj); + P_SetMobjState(idya, mobjinfo[MT_GOTEMERALD].missilestate); + P_SetTarget(&mobj->tracer, idya); + } + } + else if (sstimer) + p->nightstime = sstimer; + } + // Spawn with a pity shield if necessary. P_DoPityCheck(p); } @@ -8502,16 +11535,13 @@ void P_AfterPlayerSpawn(INT32 playernum) else if (playernum == secondarydisplayplayer) localangle2 = mobj->angle; - p->viewheight = cv_viewheight.value<viewheight = 41*p->height/48; if (p->mo->eflags & MFE_VERTICALFLIP) p->viewz = p->mo->z + p->mo->height - p->viewheight; else p->viewz = p->mo->z + p->viewheight; - P_SetPlayerMobjState(p->mo, S_PLAY_STND); - p->pflags &= ~PF_SPINNING; - if (playernum == consoleplayer) { // wake up the status bar @@ -8521,6 +11551,7 @@ void P_AfterPlayerSpawn(INT32 playernum) } SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); + p->drawangle = mobj->angle; if (camera.chase) { @@ -8535,6 +11566,9 @@ void P_AfterPlayerSpawn(INT32 playernum) if (CheckForReverseGravity) P_CheckGravity(mobj, false); + + if (p->pflags & PF_FINISHED) + P_GiveFinishFlags(p); } // spawn it at a playerspawn mapthing @@ -8545,7 +11579,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) fixed_t z; sector_t *sector; - fixed_t floor, ceiling; + fixed_t floor, ceiling, ceilingspawn; player_t *p = &players[playernum]; mobj_t *mobj = p->mo; @@ -8555,7 +11589,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) { x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - angle = FixedAngle(mthing->angle*FRACUNIT); + angle = FixedAngle(mthing->angle<c_slope ? P_GetZAt(sector->c_slope, x, y) : #endif sector->ceilingheight; + ceilingspawn = ceiling - mobjinfo[MT_PLAYER].height; if (mthing) { + fixed_t offset = mthing->z << FRACBITS; + // Flagging a player's ambush will make them start on the ceiling // Objectflip inverts if (!!(mthing->options & MTF_AMBUSH) ^ !!(mthing->options & MTF_OBJECTFLIP)) - { - z = ceiling - mobjinfo[MT_PLAYER].height; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } + z = ceilingspawn - offset; else - { - z = floor; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } + z = floor + offset; if (mthing->options & MTF_OBJECTFLIP) // flip the player! { mobj->eflags |= MFE_VERTICALFLIP; mobj->flags2 |= MF2_OBJECTFLIP; } + if (mthing->options & MTF_AMBUSH) + P_SetPlayerMobjState(mobj, S_PLAY_FALL); + else if (metalrecording) + P_SetPlayerMobjState(mobj, S_PLAY_WAIT); } else z = floor; if (z < floor) z = floor; - else if (z > ceiling - mobjinfo[MT_PLAYER].height) - z = ceiling - mobjinfo[MT_PLAYER].height; + else if (z > ceilingspawn) + z = ceilingspawn; mobj->floorz = floor; mobj->ceilingz = ceiling; @@ -8613,7 +11646,12 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) P_SetThingPosition(mobj); mobj->z = z; - if (mobj->z == mobj->floorz) + if (mobj->flags2 & MF2_OBJECTFLIP) + { + if (mobj->z + mobj->height == mobj->ceilingz) + mobj->eflags |= MFE_ONGROUND; + } + else if (mobj->z == mobj->floorz) mobj->eflags |= MFE_ONGROUND; mobj->angle = angle; @@ -8649,17 +11687,29 @@ void P_MovePlayerToStarpost(INT32 playernum) sector->ceilingheight; z = p->starpostz << FRACBITS; - if (z < floor) + + P_SetScale(mobj, (mobj->destscale = abs(p->starpostscale))); + + if (p->starpostscale < 0) + { + mobj->flags2 |= MF2_OBJECTFLIP; + if (z >= ceiling) + { + mobj->eflags |= MFE_ONGROUND; + z = ceiling; + } + z -= mobj->height; + } + else if (z <= floor) + { + mobj->eflags |= MFE_ONGROUND; z = floor; - else if (z > ceiling - mobjinfo[MT_PLAYER].height) - z = ceiling - mobjinfo[MT_PLAYER].height; + } mobj->floorz = floor; mobj->ceilingz = ceiling; mobj->z = z; - if (mobj->z == mobj->floorz) - mobj->eflags |= MFE_ONGROUND; mobj->angle = p->starpostangle; @@ -8673,42 +11723,113 @@ void P_MovePlayerToStarpost(INT32 playernum) mapthing_t *huntemeralds[MAXHUNTEMERALDS]; INT32 numhuntemeralds; -// -// P_SpawnMapThing -// The fields of the mapthing should -// already be in host byte order. -// -void P_SpawnMapThing(mapthing_t *mthing) +static fixed_t P_GetMobjSpawnHeight(const mobjtype_t mobjtype, const fixed_t x, const fixed_t y, const fixed_t offset, const boolean flip) { - mobjtype_t i; - mobj_t *mobj; - fixed_t x, y, z; - subsector_t *ss; + const subsector_t *ss = R_PointInSubsector(x, y); - if (!mthing->type) - return; // Ignore type-0 things as NOPs + // Axis objects snap to the floor. + if (mobjtype == MT_AXIS || mobjtype == MT_AXISTRANSFER || mobjtype == MT_AXISTRANSFERLINE) + return ONFLOORZ; - // Always spawn in objectplace. - // Skip all returning code. - if (objectplacing) + // Establish height. + if (flip) + return ( +#ifdef ESLOPE + ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : +#endif + ss->sector->ceilingheight) - offset - mobjinfo[mobjtype].height; + else + return ( +#ifdef ESLOPE + ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : +#endif + ss->sector->floorheight) + offset; +} + +static fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mthing, const fixed_t x, const fixed_t y) +{ + fixed_t offset = mthing->z << FRACBITS; + boolean flip = (!!(mobjinfo[mobjtype].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP)); + + switch (mobjtype) { - // find which type to spawn - for (i = 0; i < NUMMOBJTYPES; i++) - if (mthing->type == mobjinfo[i].doomednum) - break; + // Bumpers never spawn flipped. + case MT_NIGHTSBUMPER: + flip = false; + break; - if (i == NUMMOBJTYPES) - { - if (mthing->type == 3328) // 3D Mode start Thing - return; - CONS_Alert(CONS_WARNING, M_GetText("Unknown thing type %d placed at (%d, %d)\n"), mthing->type, mthing->x, mthing->y); - i = MT_UNKNOWN; - } - goto noreturns; + // Objects with a non-zero default height. + case MT_CRAWLACOMMANDER: + case MT_DETON: + case MT_JETTBOMBER: + case MT_JETTGUNNER: + case MT_EGGMOBILE2: + if (!offset) + offset = 33*FRACUNIT; + break; + case MT_EGGMOBILE: + if (!offset) + offset = 128*FRACUNIT; + break; + case MT_GOLDBUZZ: + case MT_REDBUZZ: + if (!offset) + offset = 288*FRACUNIT; + break; + + // Horizontal springs, may float additional units with MTF_AMBUSH. + case MT_YELLOWHORIZ: + case MT_REDHORIZ: + case MT_BLUEHORIZ: + offset += mthing->options & MTF_AMBUSH ? 16*FRACUNIT : 0; + break; + + // Ring-like items, may float additional units with MTF_AMBUSH. + case MT_SPIKEBALL: + case MT_EMERALDSPAWN: + case MT_TOKEN: + case MT_EMBLEM: + case MT_RING: + case MT_REDTEAMRING: + case MT_BLUETEAMRING: + case MT_COIN: + case MT_BLUESPHERE: + case MT_BOMBSPHERE: + case MT_NIGHTSCHIP: + case MT_NIGHTSSTAR: + offset += mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0; + break; + + // Remaining objects. + default: + if (P_WeaponOrPanel(mobjtype)) + offset += mthing->options & MTF_AMBUSH ? 24*FRACUNIT : 0; } - // count deathmatch start positions - if (mthing->type == 33) + if (!offset) // Snap to the surfaces when there's no offset set. + { + if (flip) + return ONCEILINGZ; + else + return ONFLOORZ; + } + + return P_GetMobjSpawnHeight(mobjtype, x, y, offset, flip); +} + +static boolean P_SpawnNonMobjMapThing(mapthing_t *mthing) +{ +#if MAXPLAYERS > 32 + You should think about modifying the deathmatch starts to take full advantage of this! +#endif + if (mthing->type <= MAXPLAYERS) // Player starts + { + // save spots for respawning in network games + if (!metalrecording) + playerstarts[mthing->type - 1] = mthing; + return true; + } + else if (mthing->type == 33) // Match starts { if (numdmstarts < MAX_DM_STARTS) { @@ -8716,10 +11837,9 @@ void P_SpawnMapThing(mapthing_t *mthing) mthing->type = 0; numdmstarts++; } - return; + return true; } - - else if (mthing->type == 34) // Red CTF Starts + else if (mthing->type == 34) // Red CTF starts { if (numredctfstarts < MAXPLAYERS) { @@ -8727,10 +11847,9 @@ void P_SpawnMapThing(mapthing_t *mthing) mthing->type = 0; numredctfstarts++; } - return; + return true; } - - else if (mthing->type == 35) // Blue CTF Starts + else if (mthing->type == 35) // Blue CTF starts { if (numbluectfstarts < MAXPLAYERS) { @@ -8738,305 +11857,861 @@ void P_SpawnMapThing(mapthing_t *mthing) mthing->type = 0; numbluectfstarts++; } - return; + return true; } - - else if (mthing->type == 750) // Slope vertex point (formerly chaos spawn) - return; - - else if (mthing->type == 300 // Ring - || mthing->type == 308 || mthing->type == 309 // Team Rings - || mthing->type == 1706 // Nights Wing - || (mthing->type >= 600 && mthing->type <= 609) // Placement patterns - || mthing->type == 1705 || mthing->type == 1713 // NiGHTS Hoops - || mthing->type == 1800) // Mario Coin - { - // Don't spawn hoops, wings, or rings yet! - return; - } - - // check for players specially - if (mthing->type > 0 && mthing->type <= 32) - { - // save spots for respawning in network games - if (!metalrecording) - playerstarts[mthing->type-1] = mthing; - return; - } - - if (metalrecording && mthing->type == mobjinfo[MT_METALSONIC_RACE].doomednum) + else if (metalrecording && mthing->type == mobjinfo[MT_METALSONIC_RACE].doomednum) { // If recording, you ARE Metal Sonic. Do not spawn it, do not save normal spawnpoints. playerstarts[0] = mthing; - return; + return true; + } + else if (mthing->type == 750 // Slope vertex point (formerly chaos spawn) + || (mthing->type >= 600 && mthing->type <= 609) // Special placement patterns + || mthing->type == 1705 || mthing->type == 1713) // Hoops + return true; // These are handled elsewhere. + else if (mthing->type == mobjinfo[MT_EMERHUNT].doomednum) + { + // Emerald Hunt is Coop only. Don't spawn the emerald yet, but save the spawnpoint for later. + if ((gametyperules & GTR_EMERALDHUNT) && numhuntemeralds < MAXHUNTEMERALDS) + huntemeralds[numhuntemeralds++] = mthing; + return true; } - // find which type to spawn - for (i = 0; i < NUMMOBJTYPES; i++) - if (mthing->type == mobjinfo[i].doomednum) - break; + return false; +} - if (i == NUMMOBJTYPES) +static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i) +{ + switch (i) { - if (mthing->type == 3328) // 3D Mode start Thing - return; - CONS_Alert(CONS_WARNING, M_GetText("Unknown thing type %d placed at (%d, %d)\n"), mthing->type, mthing->x, mthing->y); - i = MT_UNKNOWN; + case MT_EMERALD1: + case MT_EMERALD2: + case MT_EMERALD3: + case MT_EMERALD4: + case MT_EMERALD5: + case MT_EMERALD6: + case MT_EMERALD7: + if (gametype != GT_COOP) // Don't place emeralds in non-coop modes + return false; + + if (metalrecording) + return false; // Metal Sonic isn't for collecting emeralds. + + if (emeralds & mobjinfo[i].speed) // You already have this emerald! + return false; + + break; + case MT_EMERALDSPAWN: + if (!cv_powerstones.value) + return false; + + if (!(gametyperules & GTR_POWERSTONES)) + return false; + + runemeraldmanager = true; + break; + case MT_ROSY: + if (!(gametype == GT_COOP || (mthing->options & MTF_EXTRA))) + return false; // she doesn't hang out here + + if (!mariomode && !(netgame || multiplayer) && players[consoleplayer].skin == 3) + return false; // no doubles + + break; + case MT_TOKEN: + if (!(gametyperules & GTR_EMERALDTOKENS)) + return false; // Gametype's not right + + if (tokenbits == 30) + return false; // Too many tokens + + if (tokenlist & (1 << tokenbits++)) + return false; // You already got this token + + break; + case MT_EMBLEM: + if (netgame || multiplayer) + return false; // Single player + + if (modifiedgame && !savemoddata) + return false; // No cheating!! + + break; + default: + break; } if (metalrecording) // Metal Sonic can't use these things. - if (mobjinfo[i].flags & (MF_ENEMY|MF_BOSS) || i == MT_EMMY || i == MT_STARPOST) - return; - - if (i >= MT_EMERALD1 && i <= MT_EMERALD7) // Pickupable Emeralds { - if (gametype != GT_COOP) // Don't place emeralds in non-coop modes - return; - - if (metalrecording) - return; // Metal Sonic isn't for collecting emeralds. - - if (emeralds & mobjinfo[i].speed) // You already have this emerald! - return; + if ((mobjinfo[i].flags & (MF_ENEMY|MF_BOSS)) || i == MT_TOKEN || i == MT_STARPOST + || i == MT_RING || i == MT_BLUETEAMRING || i == MT_REDTEAMRING || i == MT_COIN + || i == MT_BLUESPHERE || i == MT_BOMBSPHERE || i == MT_NIGHTSCHIP || i == MT_NIGHTSSTAR) + return false; } + if (((mobjinfo[i].flags & MF_ENEMY) || (mobjinfo[i].flags & MF_BOSS)) && !(gametyperules & GTR_SPAWNENEMIES)) + return false; // No enemies in ringslinger modes + + if (!(gametyperules & GTR_ALLOWEXIT) && (i == MT_SIGN)) + return false; // Don't spawn exit signs in wrong game modes + + if (!G_PlatformGametype() && (i == MT_STARPOST)) + return false; // Don't spawn starposts in wrong game modes + if (!G_RingSlingerGametype() || !cv_specialrings.value) if (P_WeaponOrPanel(i)) - return; // Don't place weapons/panels in non-ringslinger modes + return false; // Don't place weapons/panels in non-ringslinger modes - if (i == MT_EMERHUNT) + if (!(gametyperules & GTR_TEAMFLAGS)) // CTF specific things { - // Emerald Hunt is Coop only. - if (gametype != GT_COOP) - return; - - ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS); - mthing->z = (INT16)((( -#ifdef ESLOPE - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, mthing->x << FRACBITS, mthing->y << FRACBITS) : -#endif - ss->sector->floorheight)>>FRACBITS) + (mthing->options >> ZSHIFT)); - - if (numhuntemeralds < MAXHUNTEMERALDS) - huntemeralds[numhuntemeralds++] = mthing; - return; - } - - if (i == MT_EMERALDSPAWN) - { - if (!cv_powerstones.value) - return; - - if (!(gametype == GT_MATCH || gametype == GT_CTF)) - return; - - runemeraldmanager = true; - } - - if (!G_PlatformGametype()) // No enemies in match or CTF modes - if ((mobjinfo[i].flags & MF_ENEMY) || (mobjinfo[i].flags & MF_BOSS)) - return; - - // Set powerup boxes to user settings for competition. - if (gametype == GT_COMPETITION) - { - if ((mobjinfo[i].flags & MF_MONITOR) && cv_competitionboxes.value) // not Normal - { - if (cv_competitionboxes.value == 1) // Random - i = MT_QUESTIONBOX; - else if (cv_competitionboxes.value == 2) // Teleports - i = MT_MIXUPBOX; - else if (cv_competitionboxes.value == 3) // None - return; // Don't spawn! - } - } - - // Set powerup boxes to user settings for other netplay modes - else if (gametype != GT_COOP) - { - if ((mobjinfo[i].flags & MF_MONITOR) && cv_matchboxes.value) // not Normal - { - if (cv_matchboxes.value == 1) // Random - i = MT_QUESTIONBOX; - else if (cv_matchboxes.value == 3) // Don't spawn - return; - else // cv_matchboxes.value == 2, Non-Random - { - if (i == MT_QUESTIONBOX) - return; // don't spawn in Non-Random - - mthing->options &= ~(MTF_AMBUSH|MTF_OBJECTSPECIAL); // no random respawning! - } - } - } - - if (gametype != GT_CTF) // CTF specific things - { - if (i == MT_BLUETEAMRING || i == MT_REDTEAMRING) - i = MT_RING; - else if (i == MT_BLUERINGBOX || i == MT_REDRINGBOX) - i = MT_SUPERRINGBOX; - else if (i == MT_BLUEFLAG || i == MT_REDFLAG) - return; // No flags in non-CTF modes! + if (i == MT_BLUEFLAG || i == MT_REDFLAG) + return false; // No flags in non-CTF modes! } else { if ((i == MT_BLUEFLAG && blueflag) || (i == MT_REDFLAG && redflag)) { CONS_Alert(CONS_ERROR, M_GetText("Only one flag per team allowed in CTF!\n")); - return; + return false; } } - if (!G_PlatformGametype() && (i == MT_SIGN || i == MT_STARPOST)) - return; // Don't spawn exit signs or starposts in wrong game modes - if (modeattacking) // Record Attack special stuff { // Don't spawn starposts that wouldn't be usable if (i == MT_STARPOST) - return; - - // Emerald Tokens -->> Score Tokens - else if (i == MT_EMMY) - return; /// \todo - - // 1UPs -->> Score TVs - else if (i == MT_PRUP) // 1UP - { - // Either or, doesn't matter which. - if (mthing->options & (MTF_AMBUSH|MTF_OBJECTSPECIAL)) - i = MT_SCORETVLARGE; // 10,000 - else - i = MT_SCORETVSMALL; // 1,000 - } + return false; } if (ultimatemode) { - if (i == MT_PITYTV || i == MT_GREENTV || i == MT_YELLOWTV || i == MT_BLUETV || i == MT_BLACKTV || i == MT_WHITETV) - return; // No shields in Ultimate mode + if (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING + || i == MT_COIN || i == MT_NIGHTSSTAR || i == MT_NIGHTSCHIP + || i == MT_PITY_BOX || i == MT_ELEMENTAL_BOX || i == MT_ATTRACT_BOX + || i == MT_FORCE_BOX || i == MT_ARMAGEDDON_BOX || i == MT_WHIRLWIND_BOX + || i == MT_FLAMEAURA_BOX || i == MT_BUBBLEWRAP_BOX || i == MT_THUNDERCOIN_BOX + || i == MT_RING_BOX || i == MT_STARPOST) + return false; // No rings or shields in Ultimate mode - if (i == MT_SUPERRINGBOX && !G_IsSpecialStage(gamemap)) - return; // No rings in Ultimate mode (except special stages) + // Don't include the gold repeating boxes here please. + // They're likely facets of the level's design and therefore required to progress. } - if (i == MT_EMMY && (gametype != GT_COOP || ultimatemode || tokenbits == 30 || tokenlist & (1 << tokenbits++))) - return; // you already got this token, or there are too many, or the gametype's not right + return true; +} - // Objectplace landing point - noreturns: +#define nightsreplace ((maptol & TOL_NIGHTS) && !G_IsSpecialStage(gamemap)) - // spawn it - x = mthing->x << FRACBITS; - y = mthing->y << FRACBITS; - ss = R_PointInSubsector(x, y); - - if (i == MT_NIGHTSBUMPER) - z = ( -#ifdef ESLOPE - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : -#endif - ss->sector->floorheight) + ((mthing->options >> ZSHIFT) << FRACBITS); - else if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE) - z = ONFLOORZ; - else if (i == MT_SPECIALSPIKEBALL || P_WeaponOrPanel(i) || i == MT_EMERALDSPAWN || i == MT_EMMY) +static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i) +{ + // Altering monitor spawns via cvars + // If MF_GRENADEBOUNCE is set in the monitor's info, + // skip this step. (Used for gold monitors) + // Yeah, this is a dirty hack. + if ((mobjinfo[i].flags & (MF_MONITOR|MF_GRENADEBOUNCE)) == MF_MONITOR) { - if (mthing->options & MTF_OBJECTFLIP) + if (gametyperules & GTR_RACE) { - z = ( -#ifdef ESLOPE - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : -#endif - ss->sector->ceilingheight); - - if (mthing->options & MTF_AMBUSH) // Special flag for rings - z -= 24*FRACUNIT; - if (mthing->options >> ZSHIFT) - z -= (mthing->options >> ZSHIFT)*FRACUNIT; - - z -= mobjinfo[i].height; //Don't forget the height! + // Set powerup boxes to user settings for competition. + switch (cv_competitionboxes.value) + { + case 1: // Mystery + return MT_MYSTERY_BOX; + case 2: // Teleport + return MT_MIXUP_BOX; + case 3: // None + return MT_NULL; // Don't spawn! + default: + return i; + } } - else + // Set powerup boxes to user settings for other netplay modes + else if (gametype != GT_COOP) { - z = ( -#ifdef ESLOPE - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : -#endif - ss->sector->floorheight); - - if (mthing->options & MTF_AMBUSH) // Special flag for rings - z += 24*FRACUNIT; - if (mthing->options >> ZSHIFT) - z += (mthing->options >> ZSHIFT)*FRACUNIT; + switch (cv_matchboxes.value) + { + case 1: // Mystery + return MT_MYSTERY_BOX; + case 2: // Unchanging + if (i == MT_MYSTERY_BOX) + return MT_NULL; // don't spawn + mthing->options &= ~(MTF_AMBUSH|MTF_OBJECTSPECIAL); // no random respawning! + return i; + case 3: // Don't spawn + return MT_NULL; + default: + return i; + } } + } - if (z == ONFLOORZ) - mthing->z = 0; + if (nightsreplace) + { + if (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN) + return MT_NIGHTSSTAR; + + if (i == MT_BLUESPHERE) + return MT_NIGHTSCHIP; + } + + if (!(gametyperules & GTR_TEAMS)) + { + if (i == MT_BLUETEAMRING || i == MT_REDTEAMRING) + return MT_RING; + + if (i == MT_RING_BLUEBOX || i == MT_RING_REDBOX) + return MT_RING_BOX; + } + + if (modeattacking && i == MT_1UP_BOX) // 1UPs -->> Score TVs + { + // Either or, doesn't matter which. + if (mthing->options & (MTF_AMBUSH | MTF_OBJECTSPECIAL)) + return MT_SCORE10K_BOX; // 10,000 else - mthing->z = (INT16)(z>>FRACBITS); + return MT_SCORE1K_BOX; // 1,000 + } + + if (mariomode && i == MT_ROSY) + return MT_TOAD; // don't remove on penalty of death + + return i; +} + +static boolean P_SetupEmblem(mapthing_t *mthing, mobj_t *mobj) +{ + INT32 j; + emblem_t* emblem = M_GetLevelEmblems(gamemap); + skincolors_t emcolor; + + while (emblem) + { + if ((emblem->type == ET_GLOBAL || emblem->type == ET_SKIN) && emblem->tag == mthing->angle) + break; + + emblem = M_GetLevelEmblems(-1); + } + + if (!emblem) + { + CONS_Debug(DBG_GAMELOGIC, "No map emblem for map %d with tag %d found!\n", gamemap, mthing->angle); + return false; + } + + j = emblem - emblemlocations; + + I_Assert(emblemlocations[j].sprite >= 'A' && emblemlocations[j].sprite <= 'Z'); + P_SetMobjState(mobj, mobj->info->spawnstate + (emblemlocations[j].sprite - 'A')); + + mobj->health = j + 1; + emcolor = M_GetEmblemColor(&emblemlocations[j]); // workaround for compiler complaint about bad function casting + mobj->color = (UINT8)emcolor; + + if (emblemlocations[j].collected + || (emblemlocations[j].type == ET_SKIN && emblemlocations[j].var != players[0].skin)) + { + P_UnsetThingPosition(mobj); + mobj->flags |= MF_NOCLIP; + mobj->flags &= ~MF_SPECIAL; + mobj->flags |= MF_NOBLOCKMAP; + mobj->frame |= (tr_trans50 << FF_TRANSSHIFT); + P_SetThingPosition(mobj); } else { - fixed_t offset = 0; - boolean flip = (!!(mobjinfo[i].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP)); + mobj->frame &= ~FF_TRANSMASK; - // base positions - if (flip) - z = ( -#ifdef ESLOPE - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : -#endif - ss->sector->ceilingheight) - mobjinfo[i].height; - else - z = ( -#ifdef ESLOPE - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : -#endif - ss->sector->floorheight); - - // offsetting - if (mthing->options >> ZSHIFT) - offset = ((mthing->options >> ZSHIFT) << FRACBITS); - else if (i == MT_CRAWLACOMMANDER || i == MT_DETON || i == MT_JETTBOMBER || i == MT_JETTGUNNER || i == MT_EGGMOBILE2) - offset = 33*FRACUNIT; - else if (i == MT_EGGMOBILE) - offset = 128*FRACUNIT; - else if (i == MT_GOLDBUZZ || i == MT_REDBUZZ) - offset = 288*FRACUNIT; - - // applying offsets! (if any) - if (flip) + if (emblemlocations[j].type == ET_GLOBAL) { - if (offset) - z -= offset; - else - z = ONCEILINGZ; + mobj->reactiontime = emblemlocations[j].var; + if (emblemlocations[j].var & GE_NIGHTSITEM) + { + mobj->flags |= MF_NIGHTSITEM; + mobj->flags &= ~MF_SPECIAL; + mobj->flags2 |= MF2_DONTDRAW; + } + } + } + return true; +} + +static boolean P_SetupMace(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) +{ + fixed_t mlength, mmaxlength, mlengthset, mspeed, mphase, myaw, mpitch, mminlength, mnumspokes, mpinch, mroll, mnumnospokes, mwidth, mwidthset, mmin, msound, radiusfactor, widthfactor; + angle_t mspokeangle; + mobjtype_t chainlink, macetype, firsttype, linktype; + boolean mdosound, mdocenter, mchainlike = false; + mobj_t *spawnee = NULL, *hprev = mobj; + mobjflag_t mflagsapply; + mobjflag2_t mflags2apply; + mobjeflag_t meflagsapply; + INT32 line; + const size_t mthingi = (size_t)(mthing - mapthings); + + // Find the corresponding linedef special, using angle as tag + // P_FindSpecialLineFromTag works here now =D + line = P_FindSpecialLineFromTag(9, mthing->angle, -1); + + if (line == -1) + { + CONS_Debug(DBG_GAMELOGIC, "Mace chain (mapthing #%s) needs to be tagged to a #9 parameter line (trying to find tag %d).\n", sizeu1(mthingi), mthing->angle); + return false; + } + /* + mapthing - + MTF_AMBUSH : + MT_SPRINGBALLPOINT - upgrade from yellow to red spring + anything else - bigger mace/chain theory + MTF_OBJECTSPECIAL - force silent + MTF_GRAVFLIP - flips objects, doesn't affect chain arrangements + Parameter value : number of "spokes" + + linedef - + ML_NOCLIMB : + MT_CHAINPOINT/MT_CHAINMACEPOINT with ML_EFFECT1 applied - Direction not controllable + anything else - no functionality + ML_EFFECT1 : Swings instead of spins + ML_EFFECT2 : Linktype is replaced with macetype for all spokes not ending in chains (inverted for MT_FIREBARPOINT) + ML_EFFECT3 : Spawn a bonus linktype at the hinge point + ML_EFFECT4 : Don't clip inside the ground + ML_EFFECT5 : Don't stop thinking when too far away + */ + mlength = abs(lines[line].dx >> FRACBITS); + mspeed = abs(lines[line].dy >> (FRACBITS - 4)); + mphase = (sides[lines[line].sidenum[0]].textureoffset >> FRACBITS) % 360; + if ((mminlength = -sides[lines[line].sidenum[0]].rowoffset >> FRACBITS) < 0) + mminlength = 0; + else if (mminlength > mlength - 1) + mminlength = mlength - 1; + mpitch = (lines[line].frontsector->floorheight >> FRACBITS) % 360; + myaw = (lines[line].frontsector->ceilingheight >> FRACBITS) % 360; + + mnumspokes = mthing->extrainfo + 1; + mspokeangle = FixedAngle((360*FRACUNIT)/mnumspokes) >> ANGLETOFINESHIFT; + + if (lines[line].backsector) + { + mpinch = (lines[line].backsector->floorheight >> FRACBITS) % 360; + mroll = (lines[line].backsector->ceilingheight >> FRACBITS) % 360; + mnumnospokes = (sides[lines[line].sidenum[1]].textureoffset >> FRACBITS); + if ((mwidth = sides[lines[line].sidenum[1]].rowoffset >> FRACBITS) < 0) + mwidth = 0; + } + else + mpinch = mroll = mnumnospokes = mwidth = 0; + + CONS_Debug(DBG_GAMELOGIC, "Mace/Chain (mapthing #%s):\n" + "Length is %d (minus %d)\n" + "Speed is %d\n" + "Phase is %d\n" + "Yaw is %d\n" + "Pitch is %d\n" + "No. of spokes is %d (%d antispokes)\n" + "Pinch is %d\n" + "Roll is %d\n" + "Width is %d\n", + sizeu1(mthingi), mlength, mminlength, mspeed, mphase, myaw, mpitch, mnumspokes, mnumnospokes, mpinch, mroll, mwidth); + + if (mnumnospokes > 0 && (mnumnospokes < mnumspokes)) + mnumnospokes = mnumspokes/mnumnospokes; + else + mnumnospokes = ((mobj->type == MT_CHAINMACEPOINT) ? (mnumspokes) : 0); + + mobj->lastlook = mspeed; + mobj->movecount = mobj->lastlook; + mobj->angle = FixedAngle(myaw << FRACBITS); + *doangle = false; + mobj->threshold = (FixedAngle(mpitch << FRACBITS) >> ANGLETOFINESHIFT); + mobj->movefactor = mpinch; + mobj->movedir = 0; + + // Mobjtype selection + switch (mobj->type) + { + case MT_SPRINGBALLPOINT: + macetype = ((mthing->options & MTF_AMBUSH) + ? MT_REDSPRINGBALL + : MT_YELLOWSPRINGBALL); + chainlink = MT_SMALLMACECHAIN; + break; + case MT_FIREBARPOINT: + macetype = ((mthing->options & MTF_AMBUSH) + ? MT_BIGFIREBAR + : MT_SMALLFIREBAR); + chainlink = MT_NULL; + break; + case MT_CUSTOMMACEPOINT: + macetype = (mobjtype_t)sides[lines[line].sidenum[0]].toptexture; + if (lines[line].backsector) + chainlink = (mobjtype_t)sides[lines[line].sidenum[1]].toptexture; + else + chainlink = MT_NULL; + break; + case MT_CHAINPOINT: + if (mthing->options & MTF_AMBUSH) + { + macetype = MT_BIGGRABCHAIN; + chainlink = MT_BIGMACECHAIN; } else { - if (offset) - z += offset; - else - z = ONFLOORZ; + macetype = MT_SMALLGRABCHAIN; + chainlink = MT_SMALLMACECHAIN; + } + mchainlike = true; + break; + default: + if (mthing->options & MTF_AMBUSH) + { + macetype = MT_BIGMACE; + chainlink = MT_BIGMACECHAIN; } - - if (z == ONFLOORZ) - mthing->z = 0; else - mthing->z = (INT16)(z>>FRACBITS); + { + macetype = MT_SMALLMACE; + chainlink = MT_SMALLMACECHAIN; + } + break; } - mobj = P_SpawnMobj(x, y, z, i); - mobj->spawnpoint = mthing; + if (!macetype && !chainlink) + return true; - switch(mobj->type) + if (mobj->type == MT_CHAINPOINT) { - case MT_SKYBOX: - mobj->angle = 0; - if (mthing->options & MTF_OBJECTSPECIAL) - skyboxmo[1] = mobj; + if (!mlength) + return true; + } + else + mlength++; + + firsttype = macetype; + + // Adjustable direction + if (lines[line].flags & ML_NOCLIMB) + mobj->flags |= MF_SLIDEME; + + // Swinging + if (lines[line].flags & ML_EFFECT1) + { + mobj->flags2 |= MF2_STRONGBOX; + mmin = ((mnumnospokes > 1) ? 1 : 0); + } + else + mmin = mnumspokes; + + // If over distance away, don't move UNLESS this flag is applied + if (lines[line].flags & ML_EFFECT5) + mobj->flags2 |= MF2_BOSSNOTRAP; + + // Make the links the same type as the end - repeated below + if ((mobj->type != MT_CHAINPOINT) && (((lines[line].flags & ML_EFFECT2) == ML_EFFECT2) != (mobj->type == MT_FIREBARPOINT))) // exclusive or + { + linktype = macetype; + radiusfactor = 2; // Double the radius. + } + else + radiusfactor = (((linktype = chainlink) == MT_NULL) ? 2 : 1); + + if (!mchainlike) + mchainlike = (firsttype == chainlink); + widthfactor = (mchainlike ? 1 : 2); + + mflagsapply = ((lines[line].flags & ML_EFFECT4) ? 0 : (MF_NOCLIP | MF_NOCLIPHEIGHT)); + mflags2apply = ((mthing->options & MTF_OBJECTFLIP) ? MF2_OBJECTFLIP : 0); + meflagsapply = ((mthing->options & MTF_OBJECTFLIP) ? MFE_VERTICALFLIP : 0); + + msound = (mchainlike ? 0 : (mwidth & 1)); + + // Quick and easy preparatory variable setting + mphase = (FixedAngle(mphase << FRACBITS) >> ANGLETOFINESHIFT); + mroll = (FixedAngle(mroll << FRACBITS) >> ANGLETOFINESHIFT); + +#define makemace(mobjtype, dist, moreflags2) {\ + spawnee = P_SpawnMobj(mobj->x, mobj->y, mobj->z, mobjtype);\ + P_SetTarget(&spawnee->tracer, mobj);\ + spawnee->threshold = mphase;\ + spawnee->friction = mroll;\ + spawnee->movefactor = mwidthset;\ + spawnee->movecount = dist;\ + spawnee->angle = myaw;\ + spawnee->flags |= (MF_NOGRAVITY|mflagsapply);\ + spawnee->flags2 |= (mflags2apply|moreflags2);\ + spawnee->eflags |= meflagsapply;\ + P_SetTarget(&hprev->hnext, spawnee);\ + P_SetTarget(&spawnee->hprev, hprev);\ + hprev = spawnee;\ +} + + mdosound = (mspeed && !(mthing->options & MTF_OBJECTSPECIAL)); + mdocenter = (macetype && (lines[line].flags & ML_EFFECT3)); + + // The actual spawning of spokes + while (mnumspokes-- > 0) + { + // Offsets + if (lines[line].flags & ML_EFFECT1) // Swinging + mroll = (mroll - mspokeangle) & FINEMASK; + else // Spinning + mphase = (mphase - mspokeangle) & FINEMASK; + + if (mnumnospokes && !(mnumspokes % mnumnospokes)) // Skipping a "missing" spoke + { + if (mobj->type != MT_CHAINMACEPOINT) + continue; + + linktype = chainlink; + firsttype = ((mthing->options & MTF_AMBUSH) ? MT_BIGGRABCHAIN : MT_SMALLGRABCHAIN); + mmaxlength = 1 + (mlength - 1) * radiusfactor; + radiusfactor = widthfactor = 1; + } else - skyboxmo[0] = mobj; + { + if (mobj->type == MT_CHAINMACEPOINT) + { + // Make the links the same type as the end - repeated above + if (lines[line].flags & ML_EFFECT2) + { + linktype = macetype; + radiusfactor = 2; + } + else + radiusfactor = (((linktype = chainlink) == MT_NULL) ? 2 : 1); + + firsttype = macetype; + widthfactor = 2; + } + + mmaxlength = mlength; + } + + mwidthset = mwidth; + mlengthset = mminlength; + + if (mdocenter) // Innermost link + makemace(linktype, 0, 0); + + // Out from the center... + if (linktype) + { + while ((++mlengthset) < mmaxlength) + makemace(linktype, radiusfactor*mlengthset, 0); + } + else + mlengthset = mmaxlength; + + // Outermost mace/link + if (firsttype) + makemace(firsttype, radiusfactor*mlengthset, MF2_AMBUSH); + + if (!mwidth) + { + if (mdosound && mnumspokes <= mmin) // Can it make a sound? + spawnee->flags2 |= MF2_BOSSNOTRAP; + } + else + { + // Across the bar! + if (!firsttype) + mwidthset = -mwidth; + else if (mwidth > 0) + { + while ((mwidthset -= widthfactor) > -mwidth) + { + makemace(firsttype, radiusfactor*mlengthset, MF2_AMBUSH); + if (mdosound && (mwidthset == msound) && mnumspokes <= mmin) // Can it make a sound? + spawnee->flags2 |= MF2_BOSSNOTRAP; + } + } + else + { + while ((mwidthset += widthfactor) < -mwidth) + { + makemace(firsttype, radiusfactor*mlengthset, MF2_AMBUSH); + if (mdosound && (mwidthset == msound) && mnumspokes <= mmin) // Can it make a sound? + spawnee->flags2 |= MF2_BOSSNOTRAP; + } + } + mwidth = -mwidth; + + // Outermost mace/link again! + if (firsttype) + makemace(firsttype, radiusfactor*(mlengthset--), MF2_AMBUSH); + + // ...and then back into the center! + if (linktype) + while (mlengthset > mminlength) + makemace(linktype, radiusfactor*(mlengthset--), 0); + + if (mdocenter) // Innermost link + makemace(linktype, 0, 0); + } + } +#undef makemace + return true; +} + +static boolean P_SetupParticleGen(mapthing_t *mthing, mobj_t *mobj) +{ + fixed_t radius, speed; + INT32 type, numdivisions, anglespeed, ticcount; + angle_t angledivision; + INT32 line; + const size_t mthingi = (size_t)(mthing - mapthings); + + // Find the corresponding linedef special, using angle as tag + line = P_FindSpecialLineFromTag(15, mthing->angle, -1); + + if (line == -1) + { + CONS_Debug(DBG_GAMELOGIC, "Particle generator (mapthing #%s) needs to be tagged to a #15 parameter line (trying to find tag %d).\n", sizeu1(mthingi), mthing->angle); + return false; + } + + if (sides[lines[line].sidenum[0]].toptexture) + type = sides[lines[line].sidenum[0]].toptexture; // Set as object type in p_setup.c... + else + type = (INT32)MT_PARTICLE; + + if (!lines[line].backsector + || (ticcount = (sides[lines[line].sidenum[1]].textureoffset >> FRACBITS)) < 1) + ticcount = 3; + + numdivisions = mthing->z; + + if (numdivisions) + { + radius = R_PointToDist2(lines[line].v1->x, lines[line].v1->y, lines[line].v2->x, lines[line].v2->y); + anglespeed = (sides[lines[line].sidenum[0]].rowoffset >> FRACBITS) % 360; + angledivision = 360/numdivisions; + } + else + { + numdivisions = 1; // Simple trick to make A_ParticleSpawn simpler. + radius = 0; + anglespeed = 0; + angledivision = 0; + } + + speed = abs(sides[lines[line].sidenum[0]].textureoffset); + if (mthing->options & MTF_OBJECTFLIP) + speed *= -1; + + CONS_Debug(DBG_GAMELOGIC, "Particle Generator (mapthing #%s):\n" + "Radius is %d\n" + "Speed is %d\n" + "Anglespeed is %d\n" + "Numdivisions is %d\n" + "Angledivision is %d\n" + "Type is %d\n" + "Tic seperation is %d\n", + sizeu1(mthingi), radius, speed, anglespeed, numdivisions, angledivision, type, ticcount); + + mobj->angle = 0; + mobj->movefactor = speed; + mobj->lastlook = numdivisions; + mobj->movedir = angledivision*ANG1; + mobj->movecount = anglespeed*ANG1; + mobj->friction = radius; + mobj->threshold = type; + mobj->reactiontime = ticcount; + mobj->cvmem = line; + mobj->watertop = mobj->waterbottom = 0; + return true; +} + +static boolean P_SetupNiGHTSDrone(mapthing_t* mthing, mobj_t* mobj) +{ + boolean flip = mthing->options & MTF_OBJECTFLIP; + boolean topaligned = (mthing->options & MTF_OBJECTSPECIAL) && !(mthing->options & MTF_EXTRA); + boolean middlealigned = (mthing->options & MTF_EXTRA) && !(mthing->options & MTF_OBJECTSPECIAL); + boolean bottomoffsetted = !(mthing->options & MTF_OBJECTSPECIAL) && !(mthing->options & MTF_EXTRA); + + INT16 timelimit = mthing->angle & 0xFFF; + fixed_t hitboxradius = ((mthing->angle & 0xF000) >> 12)*32*FRACUNIT; + fixed_t hitboxheight = mthing->extrainfo*32*FRACUNIT; + fixed_t oldheight = mobj->height; + fixed_t dronemanoffset, goaloffset, sparkleoffset, droneboxmandiff, dronemangoaldiff; + + if (timelimit > 0) + mobj->health = timelimit; + + if (hitboxradius > 0) + mobj->radius = hitboxradius; + + if (hitboxheight > 0) + mobj->height = hitboxheight; + else + mobj->height = mobjinfo[MT_NIGHTSDRONE].height; + + droneboxmandiff = max(mobj->height - mobjinfo[MT_NIGHTSDRONE_MAN].height, 0); + dronemangoaldiff = max(mobjinfo[MT_NIGHTSDRONE_MAN].height - mobjinfo[MT_NIGHTSDRONE_GOAL].height, 0); + + if (flip && mobj->height != oldheight) + P_TeleportMove(mobj, mobj->x, mobj->y, mobj->z - (mobj->height - oldheight)); + + if (!flip) + { + if (topaligned) // Align droneman to top of hitbox + { + dronemanoffset = droneboxmandiff; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (middlealigned) // Align droneman to center of hitbox + { + dronemanoffset = droneboxmandiff/2; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (bottomoffsetted) + { + dronemanoffset = 24*FRACUNIT; + goaloffset = dronemangoaldiff + dronemanoffset; + } + else + { + dronemanoffset = 0; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + + sparkleoffset = goaloffset - FixedMul(15*FRACUNIT, mobj->scale); + } + else + { + mobj->eflags |= MFE_VERTICALFLIP; + mobj->flags2 |= MF2_OBJECTFLIP; + + if (topaligned) // Align droneman to top of hitbox + { + dronemanoffset = 0; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (middlealigned) // Align droneman to center of hitbox + { + dronemanoffset = droneboxmandiff/2; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + else if (bottomoffsetted) + { + dronemanoffset = droneboxmandiff - FixedMul(24*FRACUNIT, mobj->scale); + goaloffset = dronemangoaldiff + dronemanoffset; + } + else + { + dronemanoffset = droneboxmandiff; + goaloffset = dronemangoaldiff/2 + dronemanoffset; + } + + sparkleoffset = goaloffset + FixedMul(15*FRACUNIT, mobj->scale); + } + + // spawn visual elements + { + mobj_t* goalpost = P_SpawnMobjFromMobj(mobj, 0, 0, goaloffset, MT_NIGHTSDRONE_GOAL); + mobj_t* sparkle = P_SpawnMobjFromMobj(mobj, 0, 0, sparkleoffset, MT_NIGHTSDRONE_SPARKLING); + mobj_t* droneman = P_SpawnMobjFromMobj(mobj, 0, 0, dronemanoffset, MT_NIGHTSDRONE_MAN); + + P_SetTarget(&mobj->target, goalpost); + P_SetTarget(&goalpost->target, sparkle); + P_SetTarget(&goalpost->tracer, droneman); + + // correct Z position + if (flip) + { + P_TeleportMove(goalpost, goalpost->x, goalpost->y, mobj->z + goaloffset); + P_TeleportMove(sparkle, sparkle->x, sparkle->y, mobj->z + sparkleoffset); + P_TeleportMove(droneman, droneman->x, droneman->y, mobj->z + dronemanoffset); + } + + // Remember position preference for later + mobj->flags &= ~(MF_SLIDEME|MF_GRENADEBOUNCE); + if (topaligned) + mobj->flags |= MF_SLIDEME; + else if (middlealigned) + mobj->flags |= MF_GRENADEBOUNCE; + else if (!bottomoffsetted) + mobj->flags |= MF_SLIDEME|MF_GRENADEBOUNCE; + + // Remember old Z position and flags for correction detection + goalpost->movefactor = mobj->z; + goalpost->friction = mobj->height; + goalpost->threshold = mobj->flags & (MF_SLIDEME|MF_GRENADEBOUNCE); + } + return true; +} + +static boolean P_SetupBooster(mapthing_t* mthing, mobj_t* mobj, boolean strong) +{ + angle_t angle = FixedAngle(mthing->angle << FRACBITS); + fixed_t x1 = FINECOSINE((angle >> ANGLETOFINESHIFT) & FINEMASK); + fixed_t y1 = FINESINE((angle >> ANGLETOFINESHIFT) & FINEMASK); + fixed_t x2 = FINECOSINE(((angle + ANGLE_90) >> ANGLETOFINESHIFT) & FINEMASK); + fixed_t y2 = FINESINE(((angle + ANGLE_90) >> ANGLETOFINESHIFT) & FINEMASK); + statenum_t facestate = strong ? S_REDBOOSTERSEG_FACE : S_YELLOWBOOSTERSEG_FACE; + statenum_t leftstate = strong ? S_REDBOOSTERSEG_LEFT : S_YELLOWBOOSTERSEG_LEFT; + statenum_t rightstate = strong ? S_REDBOOSTERSEG_RIGHT : S_YELLOWBOOSTERSEG_RIGHT; + statenum_t rollerstate = strong ? S_REDBOOSTERROLLER : S_YELLOWBOOSTERROLLER; + + mobj_t *seg = P_SpawnMobjFromMobj(mobj, 26*x1, 26*y1, 0, MT_BOOSTERSEG); + seg->angle = angle - ANGLE_90; + P_SetMobjState(seg, facestate); + seg = P_SpawnMobjFromMobj(mobj, -26*x1, -26*y1, 0, MT_BOOSTERSEG); + seg->angle = angle + ANGLE_90; + P_SetMobjState(seg, facestate); + seg = P_SpawnMobjFromMobj(mobj, 21*x2, 21*y2, 0, MT_BOOSTERSEG); + seg->angle = angle; + P_SetMobjState(seg, leftstate); + seg = P_SpawnMobjFromMobj(mobj, -21*x2, -21*y2, 0, MT_BOOSTERSEG); + seg->angle = angle; + P_SetMobjState(seg, rightstate); + + seg = P_SpawnMobjFromMobj(mobj, 13*(x1 + x2), 13*(y1 + y2), 0, MT_BOOSTERROLLER); + seg->angle = angle; + P_SetMobjState(seg, rollerstate); + seg = P_SpawnMobjFromMobj(mobj, 13*(x1 - x2), 13*(y1 - y2), 0, MT_BOOSTERROLLER); + seg->angle = angle; + P_SetMobjState(seg, rollerstate); + seg = P_SpawnMobjFromMobj(mobj, -13*(x1 + x2), -13*(y1 + y2), 0, MT_BOOSTERROLLER); + seg->angle = angle; + P_SetMobjState(seg, rollerstate); + seg = P_SpawnMobjFromMobj(mobj, -13*(x1 - x2), -13*(y1 - y2), 0, MT_BOOSTERROLLER); + seg->angle = angle; + P_SetMobjState(seg, rollerstate); + + return true; +} + +static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean *doangle) +{ + boolean override = LUAh_MapThingSpawn(mobj, mthing); + + if (P_MobjWasRemoved(mobj)) + return false; + + if (override) + return true; + + switch (mobj->type) + { + case MT_EMBLEM: + { + if (!P_SetupEmblem(mthing, mobj)) + return false; + break; + } + case MT_SKYBOX: + if (mthing->options & MTF_OBJECTSPECIAL) + skyboxcenterpnts[mthing->extrainfo] = mobj; + else + skyboxviewpnts[mthing->extrainfo] = mobj; + break; + case MT_EGGSTATUE: + if (mthing->options & MTF_EXTRA) + { + mobj->color = SKINCOLOR_GOLD; + mobj->colorized = true; + } + break; + case MT_EGGMOBILE3: + mobj->cusval = mthing->extrainfo; break; case MT_FAN: if (mthing->options & MTF_OBJECTSPECIAL) @@ -9053,13 +12728,73 @@ void P_SpawnMapThing(mapthing_t *mthing) if (mthing->angle) mobj->health = mthing->angle; else - mobj->health = FixedMul(ss->sector->ceilingheight-ss->sector->floorheight, 3*(FRACUNIT/4))>>FRACBITS; + mobj->health = FixedMul(mobj->subsector->sector->ceilingheight - mobj->subsector->sector->floorheight, 3*(FRACUNIT/4)) >> FRACBITS; + break; + case MT_METALSONIC_RACE: + case MT_METALSONIC_BATTLE: + case MT_FANG: + case MT_ROSY: + if (mthing->options & MTF_EXTRA) + { + mobj->color = SKINCOLOR_SILVER; + mobj->colorized = true; + mobj->flags2 |= MF2_SLIDEPUSH; + } + break; + case MT_BALLOON: + if (mthing->angle > 0) + mobj->color = ((mthing->angle - 1) % (MAXSKINCOLORS - 1)) + 1; + break; +#define makesoftwarecorona(mo, h) \ + corona = P_SpawnMobjFromMobj(mo, 0, 0, h<sprite = SPR_FLAM;\ + corona->frame = (FF_FULLBRIGHT|FF_TRANS90|12);\ + corona->tics = -1 + case MT_FLAME: + if (mthing->options & MTF_EXTRA) + { + mobj_t *corona; + makesoftwarecorona(mobj, 20); + P_SetScale(corona, (corona->destscale = mobj->scale*3)); + P_SetTarget(&mobj->tracer, corona); + } + break; + case MT_FLAMEHOLDER: + if (!(mthing->options & MTF_OBJECTSPECIAL)) // Spawn the fire + { + mobj_t *flame = P_SpawnMobjFromMobj(mobj, 0, 0, mobj->height, MT_FLAME); + P_SetTarget(&flame->target, mobj); + flame->flags2 |= MF2_BOSSNOTRAP; + if (mthing->options & MTF_EXTRA) + { + mobj_t *corona; + makesoftwarecorona(flame, 20); + P_SetScale(corona, (corona->destscale = flame->scale*3)); + P_SetTarget(&flame->tracer, corona); + } + } + break; + case MT_CANDLE: + case MT_CANDLEPRICKET: + if (mthing->options & MTF_EXTRA) + { + mobj_t *corona; + makesoftwarecorona(mobj, ((mobj->type == MT_CANDLE) ? 42 : 176)); + } + break; +#undef makesoftwarecorona + case MT_JACKO1: + case MT_JACKO2: + case MT_JACKO3: + if (!(mthing->options & MTF_EXTRA)) // take the torch out of the crafting recipe + { + mobj_t *overlay = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_OVERLAY); + P_SetTarget(&overlay->target, mobj); + P_SetMobjState(overlay, mobj->info->raisestate); + } break; case MT_WATERDRIP: - if (mthing->angle) - mobj->tics = 3*TICRATE + mthing->angle; - else - mobj->tics = 3*TICRATE; + mobj->tics = 3*TICRATE + mthing->angle; break; case MT_FLAMEJET: case MT_VERTICALFLAMEJET: @@ -9072,121 +12807,18 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj->movedir = mthing->extrainfo; break; case MT_MACEPOINT: - case MT_SWINGMACEPOINT: - case MT_HANGMACEPOINT: - case MT_SPINMACEPOINT: - { - fixed_t mlength, mspeed, mxspeed, mzspeed, mstartangle, mmaxspeed; - mobjtype_t chainlink = MT_SMALLMACECHAIN; - mobjtype_t macetype = MT_SMALLMACE; - boolean firsttime; - mobj_t *spawnee; - size_t line; - const size_t mthingi = (size_t)(mthing - mapthings); - - // Why does P_FindSpecialLineFromTag not work here?!? - // Monster Iestyn: tag lists haven't been initialised yet for the map, that's why - for (line = 0; line < numlines; line++) - { - if (lines[line].special == 9 && lines[line].tag == mthing->angle) - break; - } - - if (line == numlines) - { - CONS_Debug(DBG_GAMELOGIC, "Mace chain (mapthing #%s) needs tagged to a #9 parameter line (trying to find tag %d).\n", sizeu1(mthingi), mthing->angle); - return; - } -/* -No deaf - small mace -Deaf - big mace - -ML_NOCLIMB : Direction not controllable -*/ - mlength = abs(lines[line].dx >> FRACBITS); - mspeed = abs(lines[line].dy >> FRACBITS); - mxspeed = sides[lines[line].sidenum[0]].textureoffset >> FRACBITS; - mzspeed = sides[lines[line].sidenum[0]].rowoffset >> FRACBITS; - mstartangle = lines[line].frontsector->floorheight >> FRACBITS; - mmaxspeed = lines[line].frontsector->ceilingheight >> FRACBITS; - - mstartangle %= 360; - mxspeed %= 360; - mzspeed %= 360; - - CONS_Debug(DBG_GAMELOGIC, "Mace Chain (mapthing #%s):\n" - "Length is %d\n" - "Speed is %d\n" - "Xspeed is %d\n" - "Zspeed is %d\n" - "startangle is %d\n" - "maxspeed is %d\n", - sizeu1(mthingi), mlength, mspeed, mxspeed, mzspeed, mstartangle, mmaxspeed); - - mobj->lastlook = mspeed << 4; - mobj->movecount = mobj->lastlook; - mobj->health = (FixedAngle(mzspeed*FRACUNIT)>>ANGLETOFINESHIFT) + (FixedAngle(mstartangle*FRACUNIT)>>ANGLETOFINESHIFT); - mobj->threshold = (FixedAngle(mxspeed*FRACUNIT)>>ANGLETOFINESHIFT) + (FixedAngle(mstartangle*FRACUNIT)>>ANGLETOFINESHIFT); - mobj->movefactor = mobj->threshold; - mobj->friction = mmaxspeed; - - if (lines[line].flags & ML_NOCLIMB) - mobj->flags |= MF_SLIDEME; - - mobj->reactiontime = 0; - - if (mthing->options & MTF_AMBUSH) - { - chainlink = MT_BIGMACECHAIN; - macetype = MT_BIGMACE; - } - - if (mthing->options & MTF_OBJECTSPECIAL) - mobj->flags2 |= MF2_BOSSNOTRAP; // shut up maces. - - if (mobj->type == MT_HANGMACEPOINT || mobj->type == MT_SPINMACEPOINT) - firsttime = true; - else - { - firsttime = false; - - spawnee = P_SpawnMobj(mobj->x, mobj->y, mobj->z, macetype); - P_SetTarget(&spawnee->target, mobj); - - if (mobj->type == MT_SWINGMACEPOINT) - spawnee->movecount = FixedAngle(mstartangle*FRACUNIT)>>ANGLETOFINESHIFT; - else - spawnee->movecount = 0; - - spawnee->threshold = FixedAngle(mstartangle*FRACUNIT)>>ANGLETOFINESHIFT; - spawnee->reactiontime = mlength+1; - } - - while (mlength > 0) - { - spawnee = P_SpawnMobj(mobj->x, mobj->y, mobj->z, chainlink); - - P_SetTarget(&spawnee->target, mobj); - - if (mobj->type == MT_HANGMACEPOINT || mobj->type == MT_SWINGMACEPOINT) - spawnee->movecount = FixedAngle(mstartangle*FRACUNIT)>>ANGLETOFINESHIFT; - else - spawnee->movecount = 0; - - spawnee->threshold = FixedAngle(mstartangle*FRACUNIT)>>ANGLETOFINESHIFT; - spawnee->reactiontime = mlength; - - if (firsttime) - { - // This is the outermost link in the chain - spawnee->flags |= MF_AMBUSH; - firsttime = false; - } - - mlength--; - } + case MT_CHAINMACEPOINT: + case MT_SPRINGBALLPOINT: + case MT_CHAINPOINT: + case MT_FIREBARPOINT: + case MT_CUSTOMMACEPOINT: + if (!P_SetupMace(mthing, mobj, doangle)) + return false; + break; + case MT_PARTICLEGEN: + if (!P_SetupParticleGen(mthing, mobj)) + return false; break; - } case MT_ROCKSPAWNER: mobj->threshold = mthing->angle; mobj->movecount = mthing->extrainfo; @@ -9201,7 +12833,7 @@ ML_NOCLIMB : Direction not controllable // Lower 4 bits specify the angle of // the bumper in 30 degree increments. mobj->threshold = (mthing->options & 15) % 12; // It loops over, etc - P_SetMobjState(mobj, mobj->info->spawnstate+mobj->threshold); + P_SetMobjState(mobj, mobj->info->spawnstate + mobj->threshold); break; case MT_EGGCAPSULE: if (mthing->angle <= 0) @@ -9214,28 +12846,117 @@ ML_NOCLIMB : Direction not controllable mobj->health = mthing->angle & 255; mobj->threshold = mthing->angle >> 8; break; + case MT_IDEYAANCHOR: + mobj->health = mthing->extrainfo; + break; case MT_NIGHTSDRONE: - if (mthing->angle > 0) - mobj->health = mthing->angle; + if (!P_SetupNiGHTSDrone(mthing, mobj)) + return false; break; - case MT_TRAPGOYLE: - case MT_TRAPGOYLEUP: - case MT_TRAPGOYLEDOWN: - case MT_TRAPGOYLELONG: + case MT_HIVEELEMENTAL: + if (mthing->extrainfo) + mobj->extravalue1 = mthing->extrainfo; + break; + case MT_GLAREGOYLE: + case MT_GLAREGOYLEUP: + case MT_GLAREGOYLEDOWN: + case MT_GLAREGOYLELONG: if (mthing->angle >= 360) - mobj->tics += 7*(mthing->angle / 360) + 1; // starting delay - default: + mobj->tics += 7*(mthing->angle/360) + 1; // starting delay + break; + case MT_DSZSTALAGMITE: + case MT_DSZ2STALAGMITE: + case MT_KELP: + if (mthing->options & MTF_OBJECTSPECIAL) { // make mobj twice as big as normal + P_SetScale(mobj, 2*mobj->scale); // not 2*FRACUNIT in case of something like the old ERZ3 mode + mobj->destscale = mobj->scale; + } + break; + case MT_THZTREE: + { // Spawn the branches + angle_t mobjangle = FixedAngle((mthing->angle % 113) << FRACBITS); + P_SpawnMobjFromMobj(mobj, FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_22h; + P_SpawnMobjFromMobj(mobj, 0, FRACUNIT, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_157h; + P_SpawnMobjFromMobj(mobj, -FRACUNIT, 0, 0, MT_THZTREEBRANCH)->angle = mobjangle + ANGLE_270; + } + break; + case MT_CEZPOLE1: + case MT_CEZPOLE2: + { // Spawn the banner + angle_t mobjangle = FixedAngle(mthing->angle << FRACBITS); + P_SpawnMobjFromMobj(mobj, + P_ReturnThrustX(mobj, mobjangle, 4 << FRACBITS), + P_ReturnThrustY(mobj, mobjangle, 4 << FRACBITS), + 0, ((mobj->type == MT_CEZPOLE1) ? MT_CEZBANNER1 : MT_CEZBANNER2))->angle = mobjangle + ANGLE_90; + } + break; + case MT_HHZTREE_TOP: + { // Spawn the branches + angle_t mobjangle = FixedAngle(mthing->angle << FRACBITS) & (ANGLE_90 - 1); + mobj_t* leaf; +#define doleaf(x, y) \ + leaf = P_SpawnMobjFromMobj(mobj, x, y, 0, MT_HHZTREE_PART);\ + leaf->angle = mobjangle;\ + P_SetMobjState(leaf, leaf->info->seestate);\ + mobjangle += ANGLE_90 + doleaf(FRACUNIT, 0); + doleaf(0, FRACUNIT); + doleaf(-FRACUNIT, 0); + doleaf(0, -FRACUNIT); +#undef doleaf + } + break; + case MT_SMASHINGSPIKEBALL: + if (mthing->angle > 0) + mobj->tics += mthing->angle; + break; + case MT_LAVAFALL: + mobj->fuse = 30 + mthing->angle; + if (mthing->options & MTF_AMBUSH) + { + P_SetScale(mobj, 2*mobj->scale); + mobj->destscale = mobj->scale; + } + break; + case MT_PYREFLY: + //start on fire if Ambush flag is set, otherwise behave normally + if (mthing->options & MTF_AMBUSH) + { + P_SetMobjState(mobj, mobj->info->meleestate); + mobj->extravalue2 = 2; + S_StartSound(mobj, sfx_s3kc2l); + } + break; + case MT_BIGFERN: + { + angle_t angle = FixedAngle(mthing->angle << FRACBITS); + UINT8 j; + for (j = 0; j < 8; j++) + { + angle_t fa = (angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t xoffs = FINECOSINE(fa); + fixed_t yoffs = FINESINE(fa); + mobj_t* leaf = P_SpawnMobjFromMobj(mobj, xoffs, yoffs, 0, MT_BIGFERNLEAF); + leaf->angle = angle; + angle += ANGLE_45; + } break; } + case MT_REDBOOSTER: + case MT_YELLOWBOOSTER: + if (!P_SetupBooster(mthing, mobj, mobj->type == MT_REDBOOSTER)) + return false; + break; + case MT_AXIS: + // Inverted if uppermost bit is set + if (mthing->angle & 16384) + mobj->flags2 |= MF2_AMBUSH; - if (mobj->flags & MF_BOSS) - { - if (mthing->options & MTF_OBJECTSPECIAL) // No egg trap for this boss - mobj->flags2 |= MF2_BOSSNOTRAP; - } - - if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE) // Axis Points - { + if (mthing->angle > 0) + mobj->radius = (mthing->angle & 16383) << FRACBITS; + // FALLTHRU + case MT_AXISTRANSFER: + case MT_AXISTRANSFERLINE: // Mare it belongs to mobj->threshold = min(mthing->extrainfo, 7); @@ -9243,67 +12964,46 @@ ML_NOCLIMB : Direction not controllable mobj->health = mthing->options; mobj->flags2 |= MF2_AXIS; - - if (i == MT_AXIS) - { - // Inverted if uppermost bit is set - if (mthing->angle & 16384) - mobj->flags |= MF_AMBUSH; - - if (mthing->angle > 0) - mobj->radius = (mthing->angle & 16383)*FRACUNIT; - } - } - else if (i == MT_EMMY) - { - if (mthing->options & MTF_OBJECTSPECIAL) // Mario Block version - mobj->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); - else - { - fixed_t zheight = mobj->z; - mobj_t *tokenobj; - - if (mthing->options & MTF_OBJECTFLIP) - zheight += mobj->height-FixedMul(mobjinfo[MT_TOKEN].height, mobj->scale); // align with emmy properly! - - tokenobj = P_SpawnMobj(x, y, zheight, MT_TOKEN); - P_SetTarget(&mobj->tracer, tokenobj); - tokenobj->destscale = mobj->scale; - P_SetScale(tokenobj, mobj->scale); - if (mthing->options & MTF_OBJECTFLIP) // flip token to match emmy - { - tokenobj->eflags |= MFE_VERTICALFLIP; - tokenobj->flags2 |= MF2_OBJECTFLIP; - } - } - + break; + case MT_TOKEN: // We advanced tokenbits earlier due to the return check. // Subtract 1 here for the correct value. mobj->health = 1 << (tokenbits - 1); - } - else if (i == MT_CYBRAKDEMON && mthing->options & MTF_AMBUSH) + break; + case MT_CYBRAKDEMON: + if (mthing->options & MTF_AMBUSH) + { + mobj_t* elecmobj; + elecmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_CYBRAKDEMON_ELECTRIC_BARRIER); + P_SetTarget(&elecmobj->target, mobj); + elecmobj->angle = FixedAngle(mthing->angle << FRACBITS); + elecmobj->destscale = mobj->scale*2; + P_SetScale(elecmobj, elecmobj->destscale); + } + break; + case MT_STARPOST: { - mobj_t *elecmobj; - elecmobj = P_SpawnMobj(x, y, z, MT_CYBRAKDEMON_ELECTRIC_BARRIER); - P_SetTarget(&elecmobj->target, mobj); - elecmobj->angle = FixedAngle(mthing->angle*FRACUNIT);; - elecmobj->destscale = mobj->scale*2; - P_SetScale(elecmobj, elecmobj->destscale); - } - else if (i == MT_STARPOST) - { - thinker_t *th; - mobj_t *mo2; + thinker_t* th; + mobj_t* mo2; boolean foundanother = false; - mobj->health = (mthing->angle / 360) + 1; + + if (mthing->extrainfo) + // Allow thing Parameter to define star post num too! + // For starposts above param 15 (the 16th), add 360 to the angle like before and start parameter from 1 (NOT 0)! + // So the 16th starpost is angle=0 param=15, the 17th would be angle=360 param=1. + // This seems more intuitive for mappers to use until UDMF is ready, since most SP maps won't have over 16 consecutive star posts. + mobj->health = mthing->extrainfo + (mthing->angle/360)*15 + 1; + else + // Old behavior if Parameter is 0; add 360 to the angle for each consecutive star post. + mobj->health = (mthing->angle/360) + 1; // See if other starposts exist in this level that have the same value. - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; - mo2 = (mobj_t *)th; + mo2 = (mobj_t*)th; if (mo2 == mobj) continue; @@ -9317,62 +13017,84 @@ ML_NOCLIMB : Direction not controllable if (!foundanother) numstarposts++; + break; } - else if (i == MT_SPIKE) - { + case MT_SPIKE: // Pop up spikes! if (mthing->options & MTF_OBJECTSPECIAL) { mobj->flags &= ~MF_SCENERY; - mobj->fuse = mthing->angle + mobj->info->speed; + mobj->fuse = (16 - mthing->extrainfo)*(mthing->angle + mobj->info->speed)/16; + if (mthing->options & MTF_EXTRA) + P_SetMobjState(mobj, mobj->info->meleestate); } - // Use per-thing collision for spikes if the deaf flag is checked. - if (mthing->options & MTF_AMBUSH && !metalrecording) + // Use per-thing collision for spikes if the deaf flag isn't checked. + if (!(mthing->options & MTF_AMBUSH) && !metalrecording) { P_UnsetThingPosition(mobj); mobj->flags &= ~(MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIPHEIGHT); mobj->flags |= MF_SOLID; P_SetThingPosition(mobj); } - } + break; + case MT_WALLSPIKE: + // Pop up spikes! + if (mthing->options & MTF_OBJECTSPECIAL) + { + mobj->flags &= ~MF_SCENERY; + mobj->fuse = (16 - mthing->extrainfo)*((mthing->angle/360) + mobj->info->speed)/16; + if (mthing->options & MTF_EXTRA) + P_SetMobjState(mobj, mobj->info->meleestate); + } + // Use per-thing collision for spikes if the deaf flag isn't checked. + if (!(mthing->options & MTF_AMBUSH) && !metalrecording) + { + P_UnsetThingPosition(mobj); + mobj->flags &= ~(MF_NOBLOCKMAP | MF_NOCLIPHEIGHT); + mobj->flags |= MF_SOLID; + P_SetThingPosition(mobj); + } - //count 10 ring boxes into the number of rings equation too. - if (i == MT_SUPERRINGBOX) - nummaprings += 10; - - if (i == MT_BIGTUMBLEWEED || i == MT_LITTLETUMBLEWEED) - { + // spawn base + { + const angle_t mobjangle = FixedAngle(mthing->angle << FRACBITS); // the mobj's own angle hasn't been set quite yet so... + const fixed_t baseradius = mobj->radius - mobj->scale; + mobj_t* base = P_SpawnMobj( + mobj->x - P_ReturnThrustX(mobj, mobjangle, baseradius), + mobj->y - P_ReturnThrustY(mobj, mobjangle, baseradius), + mobj->z, MT_WALLSPIKEBASE); + base->angle = mobjangle + ANGLE_90; + base->destscale = mobj->destscale; + P_SetScale(base, mobj->scale); + P_SetTarget(&base->target, mobj); + P_SetTarget(&mobj->tracer, base); + } + break; + case MT_RING_BOX: + //count 10 ring boxes into the number of rings equation too. + if (nummaprings >= 0) + nummaprings += 10; + break; + case MT_BIGTUMBLEWEED: + case MT_LITTLETUMBLEWEED: if (mthing->options & MTF_AMBUSH) { - mobj->momz += FixedMul(16*FRACUNIT, mobj->scale); - - if (P_RandomChance(FRACUNIT/2)) - mobj->momx += FixedMul(16*FRACUNIT, mobj->scale); - else - mobj->momx -= FixedMul(16*FRACUNIT, mobj->scale); - - if (P_RandomChance(FRACUNIT/2)) - mobj->momy += FixedMul(16*FRACUNIT, mobj->scale); - else - mobj->momy -= FixedMul(16*FRACUNIT,mobj->scale); + fixed_t offset = FixedMul(16*FRACUNIT, mobj->scale); + mobj->momx += P_RandomChance(FRACUNIT/2) ? offset : -offset; + mobj->momy += P_RandomChance(FRACUNIT/2) ? offset : -offset; + mobj->momz += offset; } - } - - // CTF flag pointers - if (i == MT_REDFLAG) - { + break; + case MT_REDFLAG: redflag = mobj; rflagpoint = mobj->spawnpoint; - } - if (i == MT_BLUEFLAG) - { + break; + case MT_BLUEFLAG: blueflag = mobj; bflagpoint = mobj->spawnpoint; - } - - // special push/pull stuff - if (i == MT_PUSH || i == MT_PULL) - { + break; + case MT_PUSH: + case MT_PULL: mobj->health = 0; // Default behaviour: pushing uses XY, fading uses XYZ if (mthing->options & MTF_AMBUSH) @@ -9381,91 +13103,110 @@ ML_NOCLIMB : Direction not controllable mobj->health |= 2; // If object special is set, fade using XY if (G_IsSpecialStage(gamemap)) - { - if (i == MT_PUSH) - P_SetMobjState(mobj, S_GRAVWELLGREEN); - if (i == MT_PULL) - P_SetMobjState(mobj, S_GRAVWELLRED); - } + P_SetMobjState(mobj, (mobj->type == MT_PUSH) ? S_GRAVWELLGREEN : S_GRAVWELLRED); + break; + case MT_NIGHTSSTAR: + if (maptol & TOL_XMAS) + P_SetMobjState(mobj, mobj->info->seestate); + break; + default: + break; } + if (mobj->flags & MF_BOSS) + { + if (mthing->options & MTF_OBJECTSPECIAL) // No egg trap for this boss + mobj->flags2 |= MF2_BOSSNOTRAP; + } + + return true; +} + +static void P_SetAmbush(mobj_t *mobj) +{ + if (mobj->type == MT_YELLOWDIAG || mobj->type == MT_REDDIAG || mobj->type == MT_BLUEDIAG) + mobj->angle += ANGLE_22h; + + if (mobj->flags & MF_NIGHTSITEM) + { + // Spawn already displayed + mobj->flags |= MF_SPECIAL; + mobj->flags &= ~MF_NIGHTSITEM; + } + + if (mobj->flags & MF_PUSHABLE) + mobj->flags &= ~MF_PUSHABLE; + + if ((mobj->flags & MF_MONITOR) && mobj->info->speed != 0) + { + // flag for strong/weak random boxes + // any monitor with nonzero speed is allowed to respawn like this + mobj->flags2 |= MF2_AMBUSH; + } + + else if (mobj->type != MT_AXIS && + mobj->type != MT_AXISTRANSFER && + mobj->type != MT_AXISTRANSFERLINE && + mobj->type != MT_NIGHTSBUMPER && + mobj->type != MT_STARPOST) + mobj->flags2 |= MF2_AMBUSH; +} + +static void P_SetObjectSpecial(mobj_t *mobj) +{ + if (mobj->type == MT_YELLOWDIAG || mobj->type == MT_REDDIAG || mobj->type == MT_BLUEDIAG) + mobj->flags |= MF_NOGRAVITY; + + if ((mobj->flags & MF_MONITOR) && mobj->info->speed != 0) + { + // flag for strong/weak random boxes + // any monitor with nonzero speed is allowed to respawn like this + mobj->flags2 |= MF2_STRONGBOX; + } + + // Requires you to be in bonus time to activate + if (mobj->flags & MF_NIGHTSITEM) + mobj->flags2 |= MF2_STRONGBOX; + + // Pushables bounce and slide coolly with object special flag set + if (mobj->flags & MF_PUSHABLE) + { + mobj->flags2 |= MF2_SLIDEPUSH; + mobj->flags |= MF_BOUNCE; + } +} + +static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, fixed_t z, mobjtype_t i) +{ + mobj_t *mobj = NULL; + boolean doangle = true; + + mobj = P_SpawnMobj(x, y, z, i); + mobj->spawnpoint = mthing; + + if (!P_SetupSpawnedMapThing(mthing, mobj, &doangle)) + return mobj; + + if (doangle) + mobj->angle = FixedAngle(mthing->angle << FRACBITS); + + mthing->mobj = mobj; + // ignore MTF_ flags and return early if (i == MT_NIGHTSBUMPER) - { - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - mthing->mobj = mobj; - return; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); + return mobj; if ((mthing->options & MTF_AMBUSH) - && (mthing->options & MTF_OBJECTSPECIAL) - && (mobj->flags & MF_PUSHABLE)) + && (mthing->options & MTF_OBJECTSPECIAL) + && (mobj->flags & MF_PUSHABLE)) mobj->flags2 |= MF2_CLASSICPUSH; else { if (mthing->options & MTF_AMBUSH) - { - if (i == MT_YELLOWDIAG || i == MT_REDDIAG) - mobj->angle += ANGLE_22h; - - if (mobj->flags & MF_NIGHTSITEM) - { - // Spawn already displayed - mobj->flags |= MF_SPECIAL; - mobj->flags &= ~MF_NIGHTSITEM; - P_SetMobjState(mobj, mobj->info->seestate); - } - - if (mobj->flags & MF_PUSHABLE) - { - mobj->flags &= ~MF_PUSHABLE; - mobj->flags2 |= MF2_STANDONME; - } - - if (mobj->flags & MF_MONITOR) - { - // flag for strong/weak random boxes - if (mthing->type == mobjinfo[MT_SUPERRINGBOX].doomednum || mthing->type == mobjinfo[MT_PRUP].doomednum || - mthing->type == mobjinfo[MT_SNEAKERTV].doomednum || mthing->type == mobjinfo[MT_INV].doomednum || - mthing->type == mobjinfo[MT_WHITETV].doomednum || mthing->type == mobjinfo[MT_GREENTV].doomednum || - mthing->type == mobjinfo[MT_YELLOWTV].doomednum || mthing->type == mobjinfo[MT_BLUETV].doomednum || - mthing->type == mobjinfo[MT_BLACKTV].doomednum || mthing->type == mobjinfo[MT_PITYTV].doomednum || - mthing->type == mobjinfo[MT_RECYCLETV].doomednum || mthing->type == mobjinfo[MT_MIXUPBOX].doomednum) - mobj->flags |= MF_AMBUSH; - } - - else if (mthing->type != mobjinfo[MT_AXIS].doomednum && - mthing->type != mobjinfo[MT_AXISTRANSFER].doomednum && - mthing->type != mobjinfo[MT_AXISTRANSFERLINE].doomednum && - mthing->type != mobjinfo[MT_NIGHTSBUMPER].doomednum && - mthing->type != mobjinfo[MT_STARPOST].doomednum) - mobj->flags |= MF_AMBUSH; - } + P_SetAmbush(mobj); if (mthing->options & MTF_OBJECTSPECIAL) - { - // flag for strong/weak random boxes - if (mthing->type == mobjinfo[MT_SUPERRINGBOX].doomednum || mthing->type == mobjinfo[MT_PRUP].doomednum || - mthing->type == mobjinfo[MT_SNEAKERTV].doomednum || mthing->type == mobjinfo[MT_INV].doomednum || - mthing->type == mobjinfo[MT_WHITETV].doomednum || mthing->type == mobjinfo[MT_GREENTV].doomednum || - mthing->type == mobjinfo[MT_YELLOWTV].doomednum || mthing->type == mobjinfo[MT_BLUETV].doomednum || - mthing->type == mobjinfo[MT_BLACKTV].doomednum || mthing->type == mobjinfo[MT_PITYTV].doomednum || - mthing->type == mobjinfo[MT_RECYCLETV].doomednum || mthing->type == mobjinfo[MT_MIXUPBOX].doomednum) - mobj->flags2 |= MF2_STRONGBOX; - - // Requires you to be in bonus time to activate - if (mobj->flags & MF_NIGHTSITEM) - mobj->flags2 |= MF2_STRONGBOX; - - // Pushables bounce and slide coolly with object special flag set - if (mobj->flags & MF_PUSHABLE) - { - mobj->flags2 |= MF2_SLIDEPUSH; - mobj->flags |= MF_BOUNCE; - } - } + P_SetObjectSpecial(mobj); } // Generic reverse gravity for individual objects flag. @@ -9475,581 +13216,347 @@ ML_NOCLIMB : Direction not controllable mobj->flags2 |= MF2_OBJECTFLIP; } - mthing->mobj = mobj; + // Extra functionality + if (mthing->options & MTF_EXTRA) + { + if (mobj->flags & MF_MONITOR && (mthing->angle & 16384)) + { + // Store line exec tag to run upon popping + mobj->lastlook = (mthing->angle & 16383); + } + } + + // Final set of not being able to draw nightsitems. + if (mobj->flags & MF_NIGHTSITEM) + mobj->flags2 |= MF2_DONTDRAW; + + return mobj; } -void P_SpawnHoopsAndRings(mapthing_t *mthing) +// +// P_SpawnMapThing +// The fields of the mapthing should +// already be in host byte order. +// +mobj_t *P_SpawnMapThing(mapthing_t *mthing) { + mobjtype_t i; mobj_t *mobj = NULL; - INT32 r, i; - fixed_t x, y, z, finalx, finaly, finalz; - sector_t *sec; - TVector v, *res; - angle_t closestangle, fa; + fixed_t x, y, z; + + if (!mthing->type) + return mobj; // Ignore type-0 things as NOPs + + if (mthing->type == 3328) // 3D Mode start Thing + return mobj; + + if (!objectplacing && P_SpawnNonMobjMapThing(mthing)) + return mobj; + + i = P_GetMobjtype(mthing->type); + if (i == MT_UNKNOWN) + CONS_Alert(CONS_WARNING, M_GetText("Unknown thing type %d placed at (%d, %d)\n"), mthing->type, mthing->x, mthing->y); + + // Skip all returning/substitution code in objectplace. + if (!objectplacing) + { + if (!P_AllowMobjSpawn(mthing, i)) + return mobj; + + i = P_GetMobjtypeSubstitute(mthing, i); + if (i == MT_NULL) // Don't spawn mobj + return mobj; + } x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; + z = P_GetMapThingSpawnHeight(i, mthing, x, y); + return P_SpawnMobjFromMapThing(mthing, x, y, z, i); +} - sec = R_PointInSubsector(x, y)->sector; +static void P_SpawnHoopInternal(mapthing_t *mthing, INT32 hoopsize, fixed_t sizefactor) +{ + mobj_t *mobj = NULL; + mobj_t *nextmobj = NULL; + mobj_t *hoopcenter; + TMatrix *pitchmatrix, *yawmatrix; + fixed_t radius = hoopsize*sizefactor; + INT32 i; + angle_t fa; + TVector v, *res; + fixed_t x = mthing->x << FRACBITS; + fixed_t y = mthing->y << FRACBITS; + fixed_t z = P_GetMobjSpawnHeight(MT_HOOP, x, y, mthing->z << FRACBITS, false); - // NiGHTS hoop! - if (mthing->type == 1705) + hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); + hoopcenter->spawnpoint = mthing; + hoopcenter->z -= hoopcenter->height/2; + + P_UnsetThingPosition(hoopcenter); + hoopcenter->x = x; + hoopcenter->y = y; + P_SetThingPosition(hoopcenter); + + // Scale 0-255 to 0-359 =( + hoopcenter->movedir = ((mthing->angle & 255)*360)/256; // Pitch + pitchmatrix = RotateXMatrix(FixedAngle(hoopcenter->movedir << FRACBITS)); + hoopcenter->movecount = (((UINT16)mthing->angle >> 8)*360)/256; // Yaw + yawmatrix = RotateZMatrix(FixedAngle(hoopcenter->movecount << FRACBITS)); + + // For the hoop when it flies away + hoopcenter->extravalue1 = hoopsize; + hoopcenter->extravalue2 = radius/12; + + // Create the hoop! + for (i = 0; i < hoopsize; i++) { - mobj_t *nextmobj = NULL; - mobj_t *hoopcenter; - INT16 spewangle; + fa = i*(FINEANGLES/hoopsize); + v[0] = FixedMul(FINECOSINE(fa), radius); + v[1] = 0; + v[2] = FixedMul(FINESINE(fa), radius); + v[3] = FRACUNIT; - z = mthing->options << FRACBITS; + res = VectorMatrixMultiply(v, *pitchmatrix); + M_Memcpy(&v, res, sizeof(v)); + res = VectorMatrixMultiply(v, *yawmatrix); + M_Memcpy(&v, res, sizeof(v)); - hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); + mobj = P_SpawnMobj(x + v[0], y + v[1], z + v[2], MT_HOOP); + mobj->z -= mobj->height/2; - hoopcenter->spawnpoint = mthing; + if (maptol & TOL_XMAS) + P_SetMobjState(mobj, mobj->info->seestate + (i & 1)); - // Screw these damn hoops, I need this thinker. - //hoopcenter->flags |= MF_NOTHINK; + P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center. + mobj->fuse = 0; - z += -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight; - - hoopcenter->z = z - hoopcenter->height/2; - - P_UnsetThingPosition(hoopcenter); - hoopcenter->x = x; - hoopcenter->y = y; - P_SetThingPosition(hoopcenter); - - // Scale 0-255 to 0-359 =( - closestangle = FixedAngle(FixedMul((mthing->angle>>8)*FRACUNIT, - 360*(FRACUNIT/256))); - - hoopcenter->movedir = FixedInt(FixedMul((mthing->angle&255)*FRACUNIT, - 360*(FRACUNIT/256))); - hoopcenter->movecount = FixedInt(AngleFixed(closestangle)); - - // For the hoop when it flies away - hoopcenter->extravalue1 = 32; - hoopcenter->extravalue2 = 8 * FRACUNIT; - - spewangle = (INT16)hoopcenter->movedir; - - // Create the hoop! - for (i = 0; i < 32; i++) + // Link all the sprites in the hoop together + if (nextmobj) { - fa = i*(FINEANGLES/32); - v[0] = FixedMul(FINECOSINE(fa),96*FRACUNIT); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa),96*FRACUNIT); - v[3] = FRACUNIT; - - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOP); - - if (maptol & TOL_XMAS) - P_SetMobjState(mobj, mobj->info->seestate + (i & 1)); - - mobj->z -= mobj->height/2; - P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center. - mobj->fuse = 0; - - // Link all the sprites in the hoop together - if (nextmobj) - { - mobj->hprev = nextmobj; - mobj->hprev->hnext = mobj; - } - else - mobj->hprev = mobj->hnext = NULL; - - nextmobj = mobj; + P_SetTarget(&mobj->hprev, nextmobj); + P_SetTarget(&mobj->hprev->hnext, mobj); } + else + P_SetTarget(&mobj->hprev, P_SetTarget(&mobj->hnext, NULL)); - // Create the collision detectors! - for (i = 0; i < 16; i++) - { - fa = i*FINEANGLES/16; - v[0] = FixedMul(FINECOSINE(fa),32*FRACUNIT); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa),32*FRACUNIT); - v[3] = FRACUNIT; - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOPCOLLIDE); - mobj->z -= mobj->height/2; - - // Link all the collision sprites together. - mobj->hnext = NULL; - mobj->hprev = nextmobj; - mobj->hprev->hnext = mobj; - - nextmobj = mobj; - } - // Create the collision detectors! - for (i = 0; i < 16; i++) - { - fa = i*FINEANGLES/16; - v[0] = FixedMul(FINECOSINE(fa),64*FRACUNIT); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa),64*FRACUNIT); - v[3] = FRACUNIT; - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOPCOLLIDE); - mobj->z -= mobj->height/2; - - // Link all the collision sprites together. - mobj->hnext = NULL; - mobj->hprev = nextmobj; - mobj->hprev->hnext = mobj; - - nextmobj = mobj; - } - return; + nextmobj = mobj; } - // CUSTOMIZABLE NiGHTS hoop! - else if (mthing->type == 1713) + + // Create the collision detectors! + // Create them until the size is less than 8 + // But always create at least ONE set of collision detectors + do { - mobj_t *nextmobj = NULL; - mobj_t *hoopcenter; - INT16 spewangle; - INT32 hoopsize; - INT32 hoopplacement; + if (hoopsize >= 32) + hoopsize -= 16; + else + hoopsize /= 2; - // Save our flags! - z = (mthing->options>>ZSHIFT) << FRACBITS; + radius = hoopsize*sizefactor; - hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); - hoopcenter->spawnpoint = mthing; - - z += -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight; - hoopcenter->z = z - hoopcenter->height/2; - - P_UnsetThingPosition(hoopcenter); - hoopcenter->x = x; - hoopcenter->y = y; - P_SetThingPosition(hoopcenter); - - // Scale 0-255 to 0-359 =( - closestangle = FixedAngle(FixedMul((mthing->angle>>8)*FRACUNIT, - 360*(FRACUNIT/256))); - - hoopcenter->movedir = FixedInt(FixedMul((mthing->angle&255)*FRACUNIT, - 360*(FRACUNIT/256))); - hoopcenter->movecount = FixedInt(AngleFixed(closestangle)); - - spewangle = (INT16)hoopcenter->movedir; - - // Super happy fun time - // For each flag add 4 fracunits to the size - // Default (0 flags) is 8 fracunits - hoopsize = 8 + (4 * (mthing->options & 0xF)); - hoopplacement = hoopsize * (4*FRACUNIT); - - // For the hoop when it flies away - hoopcenter->extravalue1 = hoopsize; - hoopcenter->extravalue2 = FixedDiv(hoopplacement, 12*FRACUNIT); - - // Create the hoop! for (i = 0; i < hoopsize; i++) { fa = i*(FINEANGLES/hoopsize); - v[0] = FixedMul(FINECOSINE(fa), hoopplacement); + v[0] = FixedMul(FINECOSINE(fa), radius); v[1] = 0; - v[2] = FixedMul(FINESINE(fa), hoopplacement); + v[2] = FixedMul(FINESINE(fa), radius); v[3] = FRACUNIT; - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOP); - - if (maptol & TOL_XMAS) - P_SetMobjState(mobj, mobj->info->seestate + (i & 1)); + res = VectorMatrixMultiply(v, *pitchmatrix); + M_Memcpy(&v, res, sizeof(v)); + res = VectorMatrixMultiply(v, *yawmatrix); + M_Memcpy(&v, res, sizeof(v)); + mobj = P_SpawnMobj(x + v[0], y + v[1], z + v[2], MT_HOOPCOLLIDE); mobj->z -= mobj->height/2; - P_SetTarget(&mobj->target, hoopcenter); // Link the sprite to the center. - mobj->fuse = 0; - // Link all the sprites in the hoop together - if (nextmobj) - { - mobj->hprev = nextmobj; - mobj->hprev->hnext = mobj; - } - else - mobj->hprev = mobj->hnext = NULL; + // Link all the collision sprites together. + P_SetTarget(&mobj->hnext, NULL); + P_SetTarget(&mobj->hprev, nextmobj); + P_SetTarget(&mobj->hprev->hnext, mobj); nextmobj = mobj; } + } while (hoopsize >= 8); +} - // Create the collision detectors! - // Create them until the size is less than 8 - // But always create at least ONE set of collision detectors - do +void P_SpawnHoop(mapthing_t *mthing) +{ + if (metalrecording) + return; + + if (mthing->type == 1705) // Generic hoop + P_SpawnHoopInternal(mthing, 24, 4*FRACUNIT); + else // Customizable hoop + // For each flag add 16 fracunits to the size + // Default (0 flags) is 32 fracunits + P_SpawnHoopInternal(mthing, 8 + (4*(mthing->options & 0xF)), 4*FRACUNIT); +} + +void P_SetBonusTime(mobj_t *mobj) +{ + if (!mobj) + return; + + if (mobj->type != MT_BLUESPHERE && mobj->type != MT_NIGHTSCHIP) + return; + + P_SetMobjState(mobj, mobj->info->raisestate); +} + +static void P_SpawnItemRow(mapthing_t *mthing, mobjtype_t* itemtypes, UINT8 numitemtypes, INT32 numitems, fixed_t horizontalspacing, fixed_t verticalspacing, INT16 fixedangle, boolean bonustime) +{ + mapthing_t dummything; + mobj_t *mobj = NULL; + fixed_t x = mthing->x << FRACBITS; + fixed_t y = mthing->y << FRACBITS; + fixed_t z = mthing->z << FRACBITS; + INT32 r; + angle_t angle = FixedAngle(fixedangle << FRACBITS); + angle_t fineangle = (angle >> ANGLETOFINESHIFT) & FINEMASK; + + for (r = 0; r < numitemtypes; r++) + { + dummything = *mthing; + dummything.type = mobjinfo[itemtypes[r]].doomednum; + // Skip all returning/substitution code in objectplace. + if (!objectplacing) { - if (hoopsize >= 32) - hoopsize -= 16; - else - hoopsize /= 2; - - hoopplacement = hoopsize * (4*FRACUNIT); - - for (i = 0; i < hoopsize; i++) + if (!P_AllowMobjSpawn(&dummything, itemtypes[r])) { - fa = i*FINEANGLES/hoopsize; - v[0] = FixedMul(FINECOSINE(fa), hoopplacement); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa), hoopplacement); - v[3] = FRACUNIT; - res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle*FRACUNIT))); - M_Memcpy(&v, res, sizeof (v)); - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, MT_HOOPCOLLIDE); - mobj->z -= mobj->height/2; - - // Link all the collision sprites together. - mobj->hnext = NULL; - mobj->hprev = nextmobj; - mobj->hprev->hnext = mobj; - - nextmobj = mobj; + itemtypes[r] = MT_NULL; + continue; } - } while (hoopsize >= 8); + itemtypes[r] = P_GetMobjtypeSubstitute(&dummything, itemtypes[r]); + } + } + z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, mthing->options & MTF_OBJECTFLIP); + + for (r = 0; r < numitems; r++) + { + mobjtype_t itemtype = itemtypes[r % numitemtypes]; + if (itemtype == MT_NULL) + continue; + dummything.type = mobjinfo[itemtype].doomednum; + + x += FixedMul(horizontalspacing, FINECOSINE(fineangle)); + y += FixedMul(horizontalspacing, FINESINE(fineangle)); + z += (mthing->options & MTF_OBJECTFLIP) ? -verticalspacing : verticalspacing; + + mobj = P_SpawnMobjFromMapThing(&dummything, x, y, z, itemtype); + + if (!mobj) + continue; + + mobj->spawnpoint = NULL; + if (bonustime) + P_SetBonusTime(mobj); + } +} + +static void P_SpawnSingularItemRow(mapthing_t* mthing, mobjtype_t itemtype, INT32 numitems, fixed_t horizontalspacing, fixed_t verticalspacing, INT16 fixedangle, boolean bonustime) +{ + mobjtype_t itemtypes[1] = { itemtype }; + return P_SpawnItemRow(mthing, itemtypes, 1, numitems, horizontalspacing, verticalspacing, fixedangle, bonustime); +} + +static void P_SpawnItemCircle(mapthing_t *mthing, mobjtype_t *itemtypes, UINT8 numitemtypes, INT32 numitems, fixed_t size, boolean bonustime) +{ + mapthing_t dummything; + mobj_t* mobj = NULL; + fixed_t x = mthing->x << FRACBITS; + fixed_t y = mthing->y << FRACBITS; + fixed_t z = mthing->z << FRACBITS; + angle_t angle = FixedAngle(mthing->angle << FRACBITS); + angle_t fa; + INT32 i; + TVector v, *res; + + for (i = 0; i < numitemtypes; i++) + { + dummything = *mthing; + dummything.type = mobjinfo[itemtypes[i]].doomednum; + // Skip all returning/substitution code in objectplace. + if (!objectplacing) + { + if (!P_AllowMobjSpawn(&dummything, itemtypes[i])) + { + itemtypes[i] = MT_NULL; + continue; + } + + itemtypes[i] = P_GetMobjtypeSubstitute(&dummything, itemtypes[i]); + } + } + z = P_GetMobjSpawnHeight(itemtypes[0], x, y, z, false); + + for (i = 0; i < numitems; i++) + { + mobjtype_t itemtype = itemtypes[i % numitemtypes]; + if (itemtype == MT_NULL) + continue; + dummything.type = mobjinfo[itemtype].doomednum; + + fa = i*FINEANGLES/numitems; + v[0] = FixedMul(FINECOSINE(fa), size); + v[1] = 0; + v[2] = FixedMul(FINESINE(fa), size); + v[3] = FRACUNIT; + + res = VectorMatrixMultiply(v, *RotateZMatrix(angle)); + M_Memcpy(&v, res, sizeof(v)); + + mobj = P_SpawnMobjFromMapThing(&dummything, x + v[0], y + v[1], z + v[2], itemtype); + + if (!mobj) + continue; + + mobj->z -= mobj->height/2; + mobj->spawnpoint = NULL; + if (bonustime) + P_SetBonusTime(mobj); + } +} + +void P_SpawnItemPattern(mapthing_t *mthing, boolean bonustime) +{ + switch (mthing->type) + { + // Special placement patterns + case 600: // 5 vertical rings (yellow spring) + P_SpawnSingularItemRow(mthing, MT_RING, 5, 0, 64*FRACUNIT, 0, bonustime); + return; + case 601: // 5 vertical rings (red spring) + P_SpawnSingularItemRow(mthing, MT_RING, 5, 0, 128*FRACUNIT, 0, bonustime); + return; + case 602: // 5 diagonal rings (yellow spring) + P_SpawnSingularItemRow(mthing, MT_RING, 5, 64*FRACUNIT, 64*FRACUNIT, mthing->angle, bonustime); + return; + case 603: // 10 diagonal rings (red spring) + P_SpawnSingularItemRow(mthing, MT_RING, 10, 64*FRACUNIT, 64*FRACUNIT, mthing->angle, bonustime); + return; + case 604: // Circle of rings (8 items) + case 605: // Circle of rings (16 items) + case 606: // Circle of blue spheres (8 items) + case 607: // Circle of blue spheres (16 items) + { + INT32 numitems = (mthing->type & 1) ? 16 : 8; + fixed_t size = (mthing->type & 1) ? 192*FRACUNIT : 96*FRACUNIT; + mobjtype_t itemtypes[1] = { (mthing->type < 606) ? MT_RING : MT_BLUESPHERE }; + P_SpawnItemCircle(mthing, itemtypes, 1, numitems, size, bonustime); return; } - // Wing logo item. - else if (mthing->type == mobjinfo[MT_NIGHTSWING].doomednum) + case 608: // Circle of rings and blue spheres (8 items) + case 609: // Circle of rings and blue spheres (16 items) { - z = -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - - mthing->z = (INT16)(z>>FRACBITS); - - mobj = P_SpawnMobj(x, y, z, MT_NIGHTSWING); - mobj->spawnpoint = mthing; - - if (G_IsSpecialStage(gamemap) && useNightsSS) - P_SetMobjState(mobj, mobj->info->meleestate); - else if (maptol & TOL_XMAS) - P_SetMobjState(mobj, mobj->info->seestate); - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - mobj->flags |= MF_AMBUSH; - mthing->mobj = mobj; + INT32 numitems = (mthing->type & 1) ? 16 : 8; + fixed_t size = (mthing->type & 1) ? 192*FRACUNIT : 96*FRACUNIT; + mobjtype_t itemtypes[2] = { MT_RING, MT_BLUESPHERE }; + P_SpawnItemCircle(mthing, itemtypes, 2, numitems, size, bonustime); + return; } - // All manners of rings and coins - else if (mthing->type == mobjinfo[MT_RING].doomednum || mthing->type == mobjinfo[MT_COIN].doomednum || - mthing->type == mobjinfo[MT_REDTEAMRING].doomednum || mthing->type == mobjinfo[MT_BLUETEAMRING].doomednum) - { - mobjtype_t ringthing = MT_RING; - - // No rings in Ultimate! - if (ultimatemode && !(G_IsSpecialStage(gamemap) || maptol & TOL_NIGHTS)) - return; - - // Which ringthing to use - switch (mthing->type) - { - case 1800: - ringthing = MT_COIN; - break; - case 308: // No team rings in non-CTF - ringthing = (gametype == GT_CTF) ? MT_REDTEAMRING : MT_RING; - break; - case 309: // No team rings in non-CTF - ringthing = (gametype == GT_CTF) ? MT_BLUETEAMRING : MT_RING; - break; - default: - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - ringthing = MT_BLUEBALL; - break; - } - - // Set proper height - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( -#ifdef ESLOPE - sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : -#endif - sec->ceilingheight) - mobjinfo[ringthing].height; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } - else - { - z = -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } - - if (mthing->options & MTF_AMBUSH) // Special flag for rings - { - if (mthing->options & MTF_OBJECTFLIP) - z -= 24*FRACUNIT; - else - z += 24*FRACUNIT; - } - - mthing->z = (INT16)(z>>FRACBITS); - - mobj = P_SpawnMobj(x, y, z, ringthing); - mobj->spawnpoint = mthing; - - if (mthing->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - mobj->flags |= MF_AMBUSH; - mthing->mobj = mobj; - } - // *** - // Special placement patterns - // *** - - // Vertical Rings - Stack of 5 (handles both red and yellow) - else if (mthing->type == 600 || mthing->type == 601) - { - INT32 dist = 64*FRACUNIT; - mobjtype_t ringthing = MT_RING; - if (mthing->type == 601) - dist = 128*FRACUNIT; - - // No rings in Ultimate! - if (ultimatemode && !(G_IsSpecialStage(gamemap) || maptol & TOL_NIGHTS)) - return; - - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - ringthing = MT_BLUEBALL; - - for (r = 1; r <= 5; r++) - { - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( -#ifdef ESLOPE - sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : -#endif - sec->ceilingheight) - mobjinfo[ringthing].height - dist*r; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } - else - { - z = ( -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight) + dist*r; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } - - mobj = P_SpawnMobj(x, y, z, ringthing); - - if (mthing->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - if (mthing->options & MTF_AMBUSH) - mobj->flags |= MF_AMBUSH; - } - } - // Diagonal rings (handles both types) - else if (mthing->type == 602 || mthing->type == 603) // Diagonal rings (5) - { - angle_t angle = FixedAngle(mthing->angle*FRACUNIT); - mobjtype_t ringthing = MT_RING; - INT32 iterations = 5; - if (mthing->type == 603) - iterations = 10; - - // No rings in Ultimate! - if (ultimatemode && !(G_IsSpecialStage(gamemap) || maptol & TOL_NIGHTS)) - return; - - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - ringthing = MT_BLUEBALL; - - angle >>= ANGLETOFINESHIFT; - - for (r = 1; r <= iterations; r++) - { - x += FixedMul(64*FRACUNIT, FINECOSINE(angle)); - y += FixedMul(64*FRACUNIT, FINESINE(angle)); - - if (mthing->options & MTF_OBJECTFLIP) - { - z = ( -#ifdef ESLOPE - sec->c_slope ? P_GetZAt(sec->c_slope, x, y) : -#endif - sec->ceilingheight) - mobjinfo[ringthing].height - 64*FRACUNIT*r; - if (mthing->options >> ZSHIFT) - z -= ((mthing->options >> ZSHIFT) << FRACBITS); - } - else - { - z = ( -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight) + 64*FRACUNIT*r; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - } - - mobj = P_SpawnMobj(x, y, z, ringthing); - - if (mthing->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - mobj->angle = FixedAngle(mthing->angle*FRACUNIT); - if (mthing->options & MTF_AMBUSH) - mobj->flags |= MF_AMBUSH; - } - } - // Rings of items (all six of them) - else if (mthing->type >= 604 && mthing->type <= 609) - { - INT32 numitems = 8; - INT32 size = 96*FRACUNIT; - mobjtype_t itemToSpawn = MT_NIGHTSWING; - - if (mthing->type & 1) - { - numitems = 16; - size = 192*FRACUNIT; - } - - z = -#ifdef ESLOPE - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : -#endif - sec->floorheight; - if (mthing->options >> ZSHIFT) - z += ((mthing->options >> ZSHIFT) << FRACBITS); - - closestangle = FixedAngle(mthing->angle*FRACUNIT); - - // Create the hoop! - for (i = 0; i < numitems; i++) - { - switch (mthing->type) - { - case 604: - case 605: - itemToSpawn = MT_RING; - break; - case 608: - case 609: - itemToSpawn = (i & 1) ? MT_NIGHTSWING : MT_RING; - break; - case 606: - case 607: - itemToSpawn = MT_NIGHTSWING; - break; - default: - break; - } - - // No rings in Ultimate! - if (itemToSpawn == MT_RING) - { - if (ultimatemode && !(G_IsSpecialStage(gamemap) || (maptol & TOL_NIGHTS))) - continue; - - // Spawn rings as blue spheres in special stages, ala S3+K. - if (G_IsSpecialStage(gamemap) && useNightsSS) - itemToSpawn = MT_BLUEBALL; - } - - fa = i*FINEANGLES/numitems; - v[0] = FixedMul(FINECOSINE(fa),size); - v[1] = 0; - v[2] = FixedMul(FINESINE(fa),size); - v[3] = FRACUNIT; - - res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); - M_Memcpy(&v, res, sizeof (v)); - - finalx = x + v[0]; - finaly = y + v[1]; - finalz = z + v[2]; - - mobj = P_SpawnMobj(finalx, finaly, finalz, itemToSpawn); - mobj->z -= mobj->height/2; - - if (itemToSpawn == MT_NIGHTSWING) - { - if (G_IsSpecialStage(gamemap) && useNightsSS) - P_SetMobjState(mobj, mobj->info->meleestate); - else if ((maptol & TOL_XMAS)) - P_SetMobjState(mobj, mobj->info->seestate); - } - } + default: return; } } @@ -10377,7 +13884,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai { mobj_t *th; angle_t an; - fixed_t x, y, z, slope = 0; + fixed_t x, y, z, slope = 0, speed; // angle at which you fire, is player angle an = angle; @@ -10409,9 +13916,13 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai P_SetTarget(&th->target, source); + speed = th->info->speed; + if (source->player && source->player->charability == CA_FLY) + speed = FixedMul(speed, 3*FRACUNIT/2); + th->angle = an; - th->momx = FixedMul(th->info->speed, FINECOSINE(an>>ANGLETOFINESHIFT)); - th->momy = FixedMul(th->info->speed, FINESINE(an>>ANGLETOFINESHIFT)); + th->momx = FixedMul(speed, FINECOSINE(an>>ANGLETOFINESHIFT)); + th->momy = FixedMul(speed, FINESINE(an>>ANGLETOFINESHIFT)); if (allowaim) { @@ -10419,7 +13930,7 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle, UINT8 allowai th->momy = FixedMul(th->momy,FINECOSINE(source->player->aiming>>ANGLETOFINESHIFT)); } - th->momz = FixedMul(th->info->speed, slope); + th->momz = FixedMul(speed, slope); //scaling done here so it doesn't clutter up the code above th->momx = FixedMul(th->momx, th->scale); @@ -10442,3 +13953,34 @@ void P_FlashPal(player_t *pl, UINT16 type, UINT16 duration) pl->flashcount = duration; pl->flashpal = type; } + +// +// P_SpawnMobjFromMobj +// Spawns an object with offsets relative to the position of another object. +// Scale, gravity flip, etc. is taken into account automatically. +// +mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type) +{ + mobj_t *newmobj; + + xofs = FixedMul(xofs, mobj->scale); + yofs = FixedMul(yofs, mobj->scale); + zofs = FixedMul(zofs, mobj->scale); + + newmobj = P_SpawnMobj(mobj->x + xofs, mobj->y + yofs, mobj->z + zofs, type); + if (!newmobj) + return NULL; + + if (mobj->eflags & MFE_VERTICALFLIP) + { + fixed_t elementheight = FixedMul(newmobj->info->height, mobj->scale); + + newmobj->eflags |= MFE_VERTICALFLIP; + newmobj->flags2 |= MF2_OBJECTFLIP; + newmobj->z = mobj->z + mobj->height - zofs - elementheight; + } + + newmobj->destscale = mobj->destscale; + P_SetScale(newmobj, mobj->scale); + return newmobj; +} diff --git a/src/p_mobj.h b/src/p_mobj.h index a15a9fc85..63c91571b 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -107,8 +107,8 @@ typedef enum MF_NOSECTOR = 1<<3, // Don't use the blocklinks (inert but displayable) MF_NOBLOCKMAP = 1<<4, - // Not to be activated by sound, deaf monster. - MF_AMBUSH = 1<<5, + // Thin, paper-like collision bound (for visual equivalent, see FF_PAPERSPRITE) + MF_PAPERCOLLISION = 1<<5, // You can push this object. It can activate switches and things by pushing it on top. MF_PUSHABLE = 1<<6, // Object is a boss. @@ -151,10 +151,9 @@ typedef enum MF_PAIN = 1<<24, // This mobj will stick to any surface or solid object it touches. MF_STICKY = 1<<25, - // NiGHTS hidden item. Goes to seestate and turns MF_SPECIAL when paralooped. + // NiGHTS hidden item. Goes to seestate and turns MF_SPECIAL when paralooped. MF_NIGHTSITEM = 1<<26, // for chase camera, don't be blocked by things (partial clipping) - // (need comma at end of this for SOC editor) MF_NOCLIPTHING = 1<<27, // Missile bounces like a grenade. MF_GRENADEBOUNCE = 1<<28, @@ -175,24 +174,26 @@ typedef enum MF2_EXPLOSION = 1<<7, // Thrown ring has explosive properties MF2_SCATTER = 1<<8, // Thrown ring has scatter properties MF2_BEYONDTHEGRAVE = 1<<9, // Source of this missile has died and has since respawned. - MF2_PUSHED = 1<<10, // Mobj was already pushed this tic - MF2_SLIDEPUSH = 1<<11, // MF_PUSHABLE that pushes continuously. - MF2_CLASSICPUSH = 1<<12, // Drops straight down when object has negative Z. - MF2_STANDONME = 1<<13, // While not pushable, stand on me anyway. - MF2_INFLOAT = 1<<14, // Floating to a height for a move, don't auto float to target's height. - MF2_DEBRIS = 1<<15, // Splash ring from explosion ring - MF2_NIGHTSPULL = 1<<16, // Attracted from a paraloop - MF2_JUSTATTACKED = 1<<17, // can be pushed by other moving mobjs - MF2_FIRING = 1<<18, // turret fire - MF2_SUPERFIRE = 1<<19, // Firing something with Super Sonic-stopping properties. Or, if mobj has MF_MISSILE, this is the actual fire from it. - MF2_SHADOW = 1<<20, // Fuzzy draw, makes targeting harder. - MF2_STRONGBOX = 1<<21, // Flag used for "strong" random monitors. - MF2_OBJECTFLIP = 1<<22, // Flag for objects that always have flipped gravity. - MF2_SKULLFLY = 1<<23, // Special handling: skull in flight. - MF2_FRET = 1<<24, // Flashing from a previous hit - MF2_BOSSNOTRAP = 1<<25, // No Egg Trap after boss - MF2_BOSSFLEE = 1<<26, // Boss is fleeing! - MF2_BOSSDEAD = 1<<27, // Boss is dead! (Not necessarily fleeing, if a fleeing point doesn't exist.) + MF2_SLIDEPUSH = 1<<10, // MF_PUSHABLE that pushes continuously. + MF2_CLASSICPUSH = 1<<11, // Drops straight down when object has negative momz. + MF2_INVERTAIMABLE = 1<<12, // Flips whether it's targetable by A_LookForEnemies (enemies no, decoys yes) + MF2_INFLOAT = 1<<13, // Floating to a height for a move, don't auto float to target's height. + MF2_DEBRIS = 1<<14, // Splash ring from explosion ring + MF2_NIGHTSPULL = 1<<15, // Attracted from a paraloop + MF2_JUSTATTACKED = 1<<16, // can be pushed by other moving mobjs + MF2_FIRING = 1<<17, // turret fire + MF2_SUPERFIRE = 1<<18, // Firing something with Super Sonic-stopping properties. Or, if mobj has MF_MISSILE, this is the actual fire from it. + MF2_SHADOW = 1<<19, // Fuzzy draw, makes targeting harder. + MF2_STRONGBOX = 1<<20, // Flag used for "strong" random monitors. + MF2_OBJECTFLIP = 1<<21, // Flag for objects that always have flipped gravity. + MF2_SKULLFLY = 1<<22, // Special handling: skull in flight. + MF2_FRET = 1<<23, // Flashing from a previous hit + MF2_BOSSNOTRAP = 1<<24, // No Egg Trap after boss + MF2_BOSSFLEE = 1<<25, // Boss is fleeing! + MF2_BOSSDEAD = 1<<26, // Boss is dead! (Not necessarily fleeing, if a fleeing point doesn't exist.) + MF2_AMBUSH = 1<<27, // Alternate behaviour typically set by MTF_AMBUSH + MF2_LINKDRAW = 1<<28, // Draw vissprite of mobj immediately before/after tracer's vissprite (dependent on dispoffset and position) + MF2_SHIELD = 1<<29, // Thinker calls P_AddShield/P_ShieldLook (must be partnered with MF_SCENERY to use) // free: to and including 1<<31 } mobjflag2_t; @@ -232,11 +233,17 @@ typedef enum MFE_VERTICALFLIP = 1<<5, // Goo water MFE_GOOWATER = 1<<6, - // free: to and including 1<<7 + // The mobj is touching a lava block + MFE_TOUCHLAVA = 1<<7, + // Mobj was already pushed this tic + MFE_PUSHED = 1<<8, // Mobj was already sprung this tic - MFE_SPRUNG = 1<<8, + MFE_SPRUNG = 1<<9, // Platform movement - MFE_APPLYPMOMZ = 1<<9, + MFE_APPLYPMOMZ = 1<<10, + // Compute and trigger on mobj angle relative to tracer + // See Linedef Exec 457 (Track mobj angle to point) + MFE_TRACERANGLE = 1<<11, // free: to and including 1<<15 } mobjeflag_t; @@ -272,8 +279,10 @@ typedef struct mobj_s // More drawing info: to determine current sprite. angle_t angle; // orientation + angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h + UINT8 sprite2; // player sprites UINT16 anim_duration; // for FF_ANIMATE states struct msecnode_s *touching_sectorlist; // a linked list of sectors where this object appears @@ -283,6 +292,8 @@ typedef struct mobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; @@ -315,7 +326,7 @@ typedef struct mobj_s mobjtype_t type; const mobjinfo_t *info; // &mobjinfo[mobj->type] - INT32 health; // for player this is rings + 1 + INT32 health; // for player this is rings + 1 -- no it isn't, not any more!! // Movement direction, movement generation (zig-zagging). angle_t movedir; // dirtype_t 0-7; also used by Deton for up/down angle @@ -363,6 +374,9 @@ typedef struct mobj_s struct pslope_s *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?) #endif + boolean colorized; // Whether the mobj uses the rainbow colormap + fixed_t shadowscale; // If this object casts a shadow, and the size relative to radius + // WARNING: New fields must be added separately to savegame and Lua. } mobj_t; @@ -387,8 +401,10 @@ typedef struct precipmobj_s // More drawing info: to determine current sprite. angle_t angle; // orientation + angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h + UINT8 sprite2; // player sprites UINT16 anim_duration; // for FF_ANIMATE states struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears @@ -398,6 +414,8 @@ typedef struct precipmobj_s // The closest interval over all contacted sectors (or things). fixed_t floorz; // Nearest floor below. fixed_t ceilingz; // Nearest ceiling above. + struct ffloor_s *floorrover; // FOF referred by floorz + struct ffloor_s *ceilingrover; // FOF referred by ceilingz // For movement checking. fixed_t radius; // Fixed at 2*FRACUNIT @@ -435,8 +453,10 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing); void P_MovePlayerToStarpost(INT32 playernum); void P_AfterPlayerSpawn(INT32 playernum); -void P_SpawnMapThing(mapthing_t *mthing); -void P_SpawnHoopsAndRings(mapthing_t *mthing); +mobj_t *P_SpawnMapThing(mapthing_t *mthing); +void P_SpawnHoop(mapthing_t *mthing); +void P_SetBonusTime(mobj_t *mobj); +void P_SpawnItemPattern(mapthing_t *mthing, boolean bonustime); void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle); void P_SpawnPrecipitation(void); void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, statenum_t nstate, angle_t rotangle, boolean spawncenter); @@ -451,9 +471,14 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale); void P_XYMovement(mobj_t *mo); void P_EmeraldManager(void); +extern INT32 modulothing; + #define MAXHUNTEMERALDS 64 extern mapthing_t *huntemeralds[MAXHUNTEMERALDS]; extern INT32 numhuntemeralds; extern boolean runemeraldmanager; +extern UINT16 emeraldspawndelay; extern INT32 numstarposts; +extern UINT16 bossdisabled; +extern boolean stoppedclock; #endif diff --git a/src/p_polyobj.c b/src/p_polyobj.c index 82c57c85b..7e1ff1f49 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by James Haley -// Copyright (C) 2006-2018 by Sonic Team Junior. +// Copyright (C) 2006-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,6 +28,10 @@ #include "r_state.h" #include "r_defs.h" + +#define POLYOBJECTS + + #ifdef POLYOBJECTS /* @@ -142,16 +146,6 @@ FUNCINLINE static ATTRINLINE void Polyobj_vecSub2(vertex_t *dst, vertex_t *v1, v dst->y = v1->y - v2->y; } -// Add the polyobject's thinker to the thinker list -// Unlike P_AddThinker, this adds it to the front of the list instead of the back, so that carrying physics can work right. -Red -FUNCINLINE static ATTRINLINE void PolyObj_AddThinker(thinker_t *th) -{ - thinkercap.next->prev = th; - th->next = thinkercap.next; - th->prev = &thinkercap; - thinkercap.next = th; -} - // // P_PointInsidePolyobj // @@ -239,24 +233,39 @@ boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox) // // Polyobj_GetInfo // -// Finds the 'polyobject settings' linedef that shares the same tag -// as the polyobj linedef to get the settings for it. +// Finds the 'polyobject settings' linedef for a polyobject +// the polyobject's id should be set as its tag // -void Polyobj_GetInfo(INT16 tag, INT32 *polyID, INT32 *mirrorID, UINT16 *exparg) +void Polyobj_GetInfo(INT16 poid, INT32 *poflags, INT32 *parentID, INT32 *potrans) { - INT32 i = P_FindSpecialLineFromTag(POLYINFO_SPECIALNUM, tag, -1); + INT32 i = P_FindSpecialLineFromTag(POLYINFO_SPECIALNUM, poid, -1); if (i == -1) - I_Error("Polyobject (tag: %d) needs line %d for information.\n", tag, POLYINFO_SPECIALNUM); + return; // no extra settings to apply, let's leave it - if (polyID) - *polyID = lines[i].frontsector->floorheight>>FRACBITS; + if (parentID) + *parentID = lines[i].frontsector->special; - if (mirrorID) - *mirrorID = lines[i].frontsector->special; + if (potrans) + *potrans = (lines[i].frontsector->floorheight>>FRACBITS) / 100; - if (exparg) - *exparg = (UINT16)lines[i].frontsector->lightlevel; + if (lines[i].flags & ML_EFFECT1) + *poflags |= POF_ONESIDE; + + if (lines[i].flags & ML_EFFECT2) + *poflags &= ~POF_SOLID; + + if (lines[i].flags & ML_EFFECT3) + *poflags |= POF_PUSHABLESTOP; + + if (lines[i].flags & ML_EFFECT4) + *poflags |= POF_RENDERPLANES; + + /*if (lines[i].flags & ML_EFFECT5) + *poflags &= ~POF_CLIPPLANES;*/ + + if (lines[i].flags & ML_NOCLIMB) // Has a linedef executor + *poflags |= POF_LDEXEC; } // Reallocating array maintenance @@ -391,6 +400,8 @@ static void Polyobj_findSegs(polyobj_t *po, seg_t *seg) // Find backfacings for (s = 0; s < numsegs; s++) { + if (segs[s].glseg) + continue; if (segs[s].linedef == seg->linedef && segs[s].side == 1) { @@ -427,6 +438,8 @@ newseg: // seg's ending vertex. for (i = 0; i < numsegs; ++i) { + if (segs[i].glseg) + continue; if (segs[i].side != 0) // needs to be frontfacing continue; if (segs[i].v1->x == seg->v2->x && segs[i].v1->y == seg->v2->y) @@ -451,6 +464,9 @@ newseg: // Find backfacings for (q = 0; q < numsegs; q++) { + if (segs[q].glseg) + continue; + if (segs[q].linedef == segs[i].linedef && segs[q].side == 1) { @@ -480,6 +496,7 @@ newseg: CONS_Debug(DBG_POLYOBJ, "Polyobject %d is not closed\n", po->id); } +/* // structure used to store segs during explicit search process typedef struct segitem_s { @@ -555,7 +572,7 @@ static void Polyobj_findExplicit(polyobj_t *po) // free the temporary array Z_Free(segitems); -} +}*/ // Setup functions @@ -593,7 +610,11 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) for (i = 0; i < numsegs; ++i) { seg_t *seg = &segs[i]; - INT32 polyID, parentID; + INT32 poflags = POF_SOLID|POF_TESTHEIGHT|POF_RENDERSIDES; + INT32 parentID = 0, potrans = 0; + + if (seg->glseg) + continue; if (seg->side != 0) // needs to be frontfacing continue; @@ -601,42 +622,21 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) if (seg->linedef->special != POLYOBJ_START_LINE) continue; - Polyobj_GetInfo(seg->linedef->tag, &polyID, &parentID, NULL); + if (seg->linedef->tag != po->id) + continue; - // is it a START line with this polyobject's id? - if (polyID == po->id) - { - po->flags = POF_SOLID|POF_TESTHEIGHT|POF_RENDERSIDES; + Polyobj_GetInfo(po->id, &poflags, &parentID, &potrans); // apply extra settings if they exist! - if (seg->linedef->flags & ML_EFFECT1) - po->flags |= POF_ONESIDE; + // save original flags and translucency to reference later for netgames! + po->spawnflags = po->flags = poflags; + po->spawntrans = po->translucency = potrans; - if (seg->linedef->flags & ML_EFFECT2) - po->flags &= ~POF_SOLID; - - if (seg->linedef->flags & ML_EFFECT3) - po->flags |= POF_PUSHABLESTOP; - - if (seg->linedef->flags & ML_EFFECT4) - po->flags |= POF_RENDERPLANES; - - // TODO: Use a different linedef flag for this if we really need it!! - // This clashes with texture tiling, also done by Effect 5 flag - /*if (seg->linedef->flags & ML_EFFECT5) - po->flags &= ~POF_CLIPPLANES;*/ - - if (seg->linedef->flags & ML_NOCLIMB) // Has a linedef executor - po->flags |= POF_LDEXEC; - - po->spawnflags = po->flags; // save original flags to reference later for netgames! - - Polyobj_findSegs(po, seg); - po->parent = parentID; - if (po->parent == po->id) // do not allow a self-reference - po->parent = -1; - // TODO: sound sequence is in args[2] - break; - } + Polyobj_findSegs(po, seg); + po->parent = parentID; + if (po->parent == po->id) // do not allow a self-reference + po->parent = -1; + // TODO: sound sequence is in args[2] + break; } CONS_Debug(DBG_POLYOBJ, "PO ID: %d; Num verts: %s\n", po->id, sizeu1(po->numVertices)); @@ -645,6 +645,7 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) if (po->isBad) return; + /* // 2. If no such line existed in the first step, look for a seg with the // "explicit" special with tag matching this polyobject's id number. If // found, continue to search for all such lines, storing them in a @@ -663,8 +664,16 @@ static void Polyobj_spawnPolyObj(INT32 num, mobj_t *spawnSpot, INT32 id) if (po->parent == po->id) // do not allow a self-reference po->parent = -1; // TODO: sound sequence is in args[3] - } + }*/ + // make sure array isn't empty + // since Polyobj_findExplicit is disabled currently, we have to do things here instead now! + if (po->segCount == 0) + { + po->isBad = true; + CONS_Debug(DBG_POLYOBJ, "Polyobject %d is empty\n", po->id); + return; + } // set the polyobject's spawn spot po->spawnSpot.x = spawnSpot->x; @@ -980,6 +989,8 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo) P_CheckPosition(mo, mo->x + momx, mo->y + momy); mo->floorz = tmfloorz; mo->ceilingz = tmceilingz; + mo->floorrover = tmfloorrover; + mo->ceilingrover = tmceilingrover; } } @@ -990,15 +1001,35 @@ static void Polyobj_pushThing(polyobj_t *po, line_t *line, mobj_t *mo) // static void Polyobj_slideThing(mobj_t *mo, fixed_t dx, fixed_t dy) { - if (mo->player) { // Do something similar to conveyor movement. -Red - mo->player->cmomx += dx; - mo->player->cmomy += dy; + if (mo->player) { // Finally this doesn't suck eggs -fickle + fixed_t cdx, cdy; - dx = FixedMul(dx, CARRYFACTOR); - dy = FixedMul(dy, CARRYFACTOR); + cdx = FixedMul(dx, FRACUNIT-CARRYFACTOR); + cdy = FixedMul(dy, FRACUNIT-CARRYFACTOR); - mo->player->cmomx -= dx; - mo->player->cmomy -= dy; + if (mo->player->onconveyor == 1) + { + mo->momx += cdx; + mo->momy += cdy; + + // Multiple slides in the same tic, somehow + mo->player->cmomx += cdx; + mo->player->cmomy += cdy; + } + else + { + if (mo->player->onconveyor == 3) + { + mo->momx += cdx - mo->player->cmomx; + mo->momy += cdy - mo->player->cmomy; + } + + mo->player->cmomx = cdx; + mo->player->cmomy = cdy; + } + + dx = FixedMul(dx, FRACUNIT - mo->friction); + dy = FixedMul(dy, FRACUNIT - mo->friction); if (mo->player->pflags & PF_SPINNING && (mo->player->rmomx || mo->player->rmomy) && !(mo->player->pflags & PF_STARTDASH)) { #define SPINMULT 5184 // Consider this a substitute for properly calculating FRACUNIT-friction. I'm tired. -Red @@ -1143,7 +1174,7 @@ static INT32 Polyobj_clipThings(polyobj_t *po, line_t *line) // // Moves a polyobject on the x-y plane. // -static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y) +static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y, boolean checkmobjs) { size_t i; vertex_t vec; @@ -1164,9 +1195,12 @@ static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y) for (i = 0; i < po->numLines; ++i) Polyobj_bboxAdd(po->lines[i]->bbox, &vec); - // check for blocking things (yes, it needs to be done separately) - for (i = 0; i < po->numLines; ++i) - hitflags |= Polyobj_clipThings(po, po->lines[i]); + if (checkmobjs) + { + // check for blocking things (yes, it needs to be done separately) + for (i = 0; i < po->numLines; ++i) + hitflags |= Polyobj_clipThings(po, po->lines[i]); + } if (hitflags & 2) { @@ -1184,7 +1218,8 @@ static boolean Polyobj_moveXY(polyobj_t *po, fixed_t x, fixed_t y) po->spawnSpot.x += vec.x; po->spawnSpot.y += vec.y; - Polyobj_carryThings(po, x, y); + if (checkmobjs) + Polyobj_carryThings(po, x, y); Polyobj_removeFromBlockmap(po); // unlink it from the blockmap Polyobj_removeFromSubsec(po); // unlink it from its subsector Polyobj_linkToBlockmap(po); // relink to blockmap @@ -1232,7 +1267,7 @@ static void Polyobj_rotateLine(line_t *ld) // determine slopetype ld->slopetype = !ld->dx ? ST_VERTICAL : !ld->dy ? ST_HORIZONTAL : - FixedDiv(ld->dy, ld->dx) > 0 ? ST_POSITIVE : ST_NEGATIVE; + ((ld->dy > 0) == (ld->dx > 0)) ? ST_POSITIVE : ST_NEGATIVE; // update bounding box if (v1->x < v2->x) @@ -1267,7 +1302,8 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta, { static INT32 pomovecount = 10000; INT32 x, y; - angle_t deltafine = delta >> ANGLETOFINESHIFT; + angle_t deltafine = (((po->angle + delta) >> ANGLETOFINESHIFT) - (po->angle >> ANGLETOFINESHIFT)) & FINEMASK; + // This fineshift trickery replaces the old delta>>ANGLETOFINESHIFT; doing it this way avoids loss of precision causing objects to slide off -fickle pomovecount++; @@ -1319,26 +1355,17 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta, oldxoff = mo->x-origin.x; oldyoff = mo->y-origin.y; - if (mo->player) // Hack to fix players sliding off of spinning polys -Red - { - fixed_t temp; + newxoff = FixedMul(oldxoff, c)-FixedMul(oldyoff, s) - oldxoff; + newyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s) - oldyoff; - temp = FixedMul(oldxoff, c)-FixedMul(oldyoff, s); - oldyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s); - oldxoff = temp; - } - - newxoff = FixedMul(oldxoff, c)-FixedMul(oldyoff, s); - newyoff = FixedMul(oldyoff, c)+FixedMul(oldxoff, s); - - Polyobj_slideThing(mo, newxoff-oldxoff, newyoff-oldyoff); + Polyobj_slideThing(mo, newxoff, newyoff); if (turnthings == 2 || (turnthings == 1 && !mo->player)) { mo->angle += delta; if (mo->player == &players[consoleplayer]) - localangle = mo->angle; + localangle += delta; else if (mo->player == &players[secondarydisplayplayer]) - localangle2 = mo->angle; + localangle2 += delta; } } } @@ -1351,7 +1378,7 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta, // // Rotates a polyobject around its start point. // -static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings) +static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings, boolean checkmobjs) { size_t i; angle_t angle; @@ -1383,11 +1410,14 @@ static boolean Polyobj_rotate(polyobj_t *po, angle_t delta, UINT8 turnthings) for (i = 0; i < po->numLines; ++i) Polyobj_rotateLine(po->lines[i]); - // check for blocking things - for (i = 0; i < po->numLines; ++i) - hitflags |= Polyobj_clipThings(po, po->lines[i]); + if (checkmobjs) + { + // check for blocking things + for (i = 0; i < po->numLines; ++i) + hitflags |= Polyobj_clipThings(po, po->lines[i]); - Polyobj_rotateThings(po, origin, delta, turnthings); + Polyobj_rotateThings(po, origin, delta, turnthings); + } if (hitflags & 2) { @@ -1487,6 +1517,7 @@ void Polyobj_InitLevel(void) mqueue_t anchorqueue; mobjqitem_t *qitem; INT32 i, numAnchors = 0; + mobj_t *mo; M_QueueInit(&spawnqueue); M_QueueInit(&anchorqueue); @@ -1500,31 +1531,31 @@ void Polyobj_InitLevel(void) // run down the thinker list, count the number of spawn points, and save // the mobj_t pointers on a queue for use below. - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)th; + + if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || + mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) { - mobj_t *mo = (mobj_t *)th; + ++numPolyObjects; - if (mo->info->doomednum == POLYOBJ_SPAWN_DOOMEDNUM || - mo->info->doomednum == POLYOBJ_SPAWNCRUSH_DOOMEDNUM) - { - ++numPolyObjects; + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &spawnqueue); + } + else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) + { + ++numAnchors; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &spawnqueue); - } - else if (mo->info->doomednum == POLYOBJ_ANCHOR_DOOMEDNUM) - { - ++numAnchors; - - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); - qitem->mo = mo; - M_QueueInsert(&(qitem->mqitem), &anchorqueue); - } + qitem = malloc(sizeof(mobjqitem_t)); + memset(qitem, 0, sizeof(mobjqitem_t)); + qitem->mo = mo; + M_QueueInsert(&(qitem->mqitem), &anchorqueue); } } @@ -1603,19 +1634,23 @@ void Polyobj_InitLevel(void) // Called when a savegame is being loaded. Rotates and translates an // existing polyobject to its position when the game was saved. // +// Monster Iestyn 05/04/19: Please do not interact with mobjs! You +// can cause I_Error crashes that way, and all the important mobjs are +// going to be deleted afterwards anyway. +// void Polyobj_MoveOnLoad(polyobj_t *po, angle_t angle, fixed_t x, fixed_t y) { fixed_t dx, dy; // first, rotate to the saved angle - Polyobj_rotate(po, angle, false); + Polyobj_rotate(po, angle, false, false); // determine component distances to translate dx = x - po->spawnSpot.x; dy = y - po->spawnSpot.y; // translate - Polyobj_moveXY(po, dx, dy); + Polyobj_moveXY(po, dx, dy, false); } // Thinker Functions @@ -1635,7 +1670,7 @@ void T_PolyObjRotate(polyrotate_t *th) #else { CONS_Debug(DBG_POLYOBJ, "T_PolyObjRotate: thinker with invalid id %d removed.\n", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + P_RemoveThinker(&th->thinker); return; } #endif @@ -1655,7 +1690,7 @@ void T_PolyObjRotate(polyrotate_t *th) // rotate by 'speed' angle per frame // if distance == -1, this polyobject rotates perpetually - if (Polyobj_rotate(po, th->speed, th->turnobjs) && th->distance != -1) + if (Polyobj_rotate(po, th->speed, th->turnobjs, true) && th->distance != -1) { INT32 avel = abs(th->speed); @@ -1720,7 +1755,7 @@ void T_PolyObjMove(polymove_t *th) #else { CONS_Debug(DBG_POLYOBJ, "T_PolyObjMove: thinker with invalid id %d removed.\n", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + P_RemoveThinker(&th->thinker); return; } #endif @@ -1739,7 +1774,7 @@ void T_PolyObjMove(polymove_t *th) } // move the polyobject one step along its movement angle - if (Polyobj_moveXY(po, th->momx, th->momy)) + if (Polyobj_moveXY(po, th->momx, th->momy, true)) { INT32 avel = abs(th->speed); @@ -1793,7 +1828,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) #else { CONS_Debug(DBG_POLYOBJ, "T_PolyObjWaypoint: thinker with invalid id %d removed.", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + P_RemoveThinker(&th->thinker); return; } #endif @@ -1802,11 +1837,12 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (po->thinker == NULL) po->thinker = &th->thinker; +/* // Find out target first. // We redo this each tic to make savegame compatibility easier. - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next) { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)wp; @@ -1820,6 +1856,9 @@ void T_PolyObjWaypoint(polywaypoint_t *th) break; } } +*/ + + target = th->target; if (!target) { @@ -1853,14 +1892,15 @@ void T_PolyObjWaypoint(polywaypoint_t *th) fixed_t diffz; amtx = (target->x - th->diffx) - po->centerPt.x; amty = (target->y - th->diffy) - po->centerPt.y; - Polyobj_moveXY(po, amtx, amty); + Polyobj_moveXY(po, amtx, amty, true); // TODO: use T_MovePlane amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2; diffz = po->lines[0]->backsector->floorheight - (target->z - amtz); po->lines[0]->backsector->floorheight = target->z - amtz; po->lines[0]->backsector->ceilingheight = target->z + amtz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // Apply action to mirroring polyobjects as well start = 0; @@ -1869,12 +1909,13 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (po->isBad) continue; - Polyobj_moveXY(po, amtx, amty); + Polyobj_moveXY(po, amtx, amty, true); // TODO: use T_MovePlane po->lines[0]->backsector->floorheight += diffz; // move up/down by same amount as the parent did po->lines[0]->backsector->ceilingheight += diffz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); } @@ -1885,9 +1926,9 @@ void T_PolyObjWaypoint(polywaypoint_t *th) CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n"); // Find next waypoint - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next) { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)wp; @@ -1895,8 +1936,85 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) { + if (mo2->health == target->health - 1) + { + waypoint = mo2; + break; + } + } + else + { + if (mo2->health == target->health + 1) + { + waypoint = mo2; + break; + } + } + } + + if (!waypoint && th->wrap) // If specified, wrap waypoints + { + if (!th->continuous) + { + th->wrap = 0; + th->stophere = true; + } + + for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next) + { + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) + { + if (waypoint == NULL) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; + } + else + { + if (mo2->health == 0) + { + waypoint = mo2; + break; + } + } + } + } + else if (!waypoint && th->comeback) // Come back to the start + { + th->direction = -th->direction; + + if (!th->continuous) + th->comeback = false; + + for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next) + { + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo2 = (mobj_t *)wp; + + if (mo2->type != MT_TUBEWAYPOINT) + continue; + + if (mo2->threshold != th->sequence) + continue; + if (th->direction == -1) { if (mo2->health == target->health - 1) @@ -1915,83 +2033,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th) } } } - - if (!waypoint && th->wrap) // If specified, wrap waypoints - { - if (!th->continuous) - { - th->wrap = 0; - th->stophere = true; - } - - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) - { - if (waypoint == NULL) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } - else - { - if (mo2->health == 0) - { - waypoint = mo2; - break; - } - } - } - } - } - else if (!waypoint && th->comeback) // Come back to the start - { - th->direction = -th->direction; - - if (!th->continuous) - th->comeback = false; - - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) - { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker - continue; - - mo2 = (mobj_t *)wp; - - if (mo2->type != MT_TUBEWAYPOINT) - continue; - - if (mo2->threshold == th->sequence) - { - if (th->direction == -1) - { - if (mo2->health == target->health - 1) - { - waypoint = mo2; - break; - } - } - else - { - if (mo2->health == target->health + 1) - { - waypoint = mo2; - break; - } - } - } - } - } } if (waypoint) @@ -2000,6 +2041,8 @@ void T_PolyObjWaypoint(polywaypoint_t *th) target = waypoint; th->pointnum = target->health; + // Set the mobj as your target! -- Monster Iestyn 27/12/19 + P_SetTarget(&th->target, target); // calculate MOMX/MOMY/MOMZ for next waypoint // change slope @@ -2032,13 +2075,14 @@ void T_PolyObjWaypoint(polywaypoint_t *th) } // Move the polyobject - Polyobj_moveXY(po, momx, momy); + Polyobj_moveXY(po, momx, momy, true); // TODO: use T_MovePlane po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->ceilingheight += momz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); // frontsector is NEEDED for crushing - P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // backsector may not be necessary, but just in case + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs + P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); // Apply action to mirroring polyobjects as well start = 0; @@ -2047,12 +2091,13 @@ void T_PolyObjWaypoint(polywaypoint_t *th) if (po->isBad) continue; - Polyobj_moveXY(po, momx, momy); + Polyobj_moveXY(po, momx, momy, true); // TODO: use T_MovePlane po->lines[0]->backsector->floorheight += momz; po->lines[0]->backsector->ceilingheight += momz; // Sal: Remember to check your sectors! - P_CheckSector(po->lines[0]->frontsector, (boolean)(po->damage)); + // Monster Iestyn: we only need to bother with the back sector, now that P_CheckSector automatically checks the blockmap + // updating objects in the front one too just added teleporting to ground bugs P_CheckSector(po->lines[0]->backsector, (boolean)(po->damage)); } } @@ -2067,7 +2112,7 @@ void T_PolyDoorSlide(polyslidedoor_t *th) #else { CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSlide: thinker with invalid id %d removed.\n", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + P_RemoveThinker(&th->thinker); return; } #endif @@ -2096,7 +2141,7 @@ void T_PolyDoorSlide(polyslidedoor_t *th) } // move the polyobject one step along its movement angle - if (Polyobj_moveXY(po, th->momx, th->momy)) + if (Polyobj_moveXY(po, th->momx, th->momy, true)) { INT32 avel = abs(th->speed); @@ -2172,7 +2217,7 @@ void T_PolyDoorSwing(polyswingdoor_t *th) #else { CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSwing: thinker with invalid id %d removed.\n", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + P_RemoveThinker(&th->thinker); return; } #endif @@ -2202,7 +2247,7 @@ void T_PolyDoorSwing(polyswingdoor_t *th) // rotate by 'speed' angle per frame // if distance == -1, this polyobject rotates perpetually - if (Polyobj_rotate(po, th->speed, false) && th->distance != -1) + if (Polyobj_rotate(po, th->speed, false, true) && th->distance != -1) { INT32 avel = abs(th->speed); @@ -2258,7 +2303,7 @@ void T_PolyDoorSwing(polyswingdoor_t *th) } } -// T_PolyObjDisplace: shift a polyobject based on a control sector's heights. -Red +// T_PolyObjDisplace: shift a polyobject based on a control sector's heights. void T_PolyObjDisplace(polydisplace_t *th) { polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); @@ -2267,11 +2312,11 @@ void T_PolyObjDisplace(polydisplace_t *th) if (!po) #ifdef RANGECHECK - I_Error("T_PolyDoorSwing: thinker has invalid id %d\n", th->polyObjNum); + I_Error("T_PolyObjDisplace: thinker has invalid id %d\n", th->polyObjNum); #else { - CONS_Debug(DBG_POLYOBJ, "T_PolyDoorSwing: thinker with invalid id %d removed.\n", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + CONS_Debug(DBG_POLYOBJ, "T_PolyObjDisplace: thinker with invalid id %d removed.\n", th->polyObjNum); + P_RemoveThinker(&th->thinker); return; } #endif @@ -2294,7 +2339,46 @@ void T_PolyObjDisplace(polydisplace_t *th) dx = FixedMul(th->dx, delta); dy = FixedMul(th->dy, delta); - if (Polyobj_moveXY(po, dx, dy)) + if (Polyobj_moveXY(po, dx, dy, true)) + th->oldHeights = newheights; +} + +// T_PolyObjRotDisplace: rotate a polyobject based on a control sector's heights. +void T_PolyObjRotDisplace(polyrotdisplace_t *th) +{ + polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); + fixed_t newheights, delta; + fixed_t rotangle; + + if (!po) +#ifdef RANGECHECK + I_Error("T_PolyObjRotDisplace: thinker has invalid id %d\n", th->polyObjNum); +#else + { + CONS_Debug(DBG_POLYOBJ, "T_PolyObjRotDisplace: thinker with invalid id %d removed.\n", th->polyObjNum); + P_RemoveThinker(&th->thinker); + return; + } +#endif + + // check for displacement due to override and reattach when possible + if (po->thinker == NULL) + { + po->thinker = &th->thinker; + + // reset polyobject's thrust + po->thrust = FRACUNIT; + } + + newheights = th->controlSector->floorheight+th->controlSector->ceilingheight; + delta = newheights-th->oldHeights; + + if (!delta) + return; + + rotangle = FixedMul(th->rotscale, delta); + + if (Polyobj_rotate(po, FixedAngle(rotangle), th->turnobjs, true)) th->oldHeights = newheights; } @@ -2329,7 +2413,7 @@ INT32 EV_DoPolyObjRotate(polyrotdata_t *prdata) // create a new thinker th = Z_Malloc(sizeof(polyrotate_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjRotate; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); po->thinker = &th->thinker; // set fields @@ -2394,7 +2478,7 @@ INT32 EV_DoPolyObjMove(polymovedata_t *pmdata) // create a new thinker th = Z_Malloc(sizeof(polymove_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjMove; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); po->thinker = &th->thinker; // set fields @@ -2455,7 +2539,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // create a new thinker th = Z_Malloc(sizeof(polywaypoint_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjWaypoint; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); po->thinker = &th->thinker; // set fields @@ -2473,9 +2557,9 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) th->stophere = false; // Find the first waypoint we need to use - for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next) { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)wp; @@ -2483,31 +2567,31 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) // highest waypoint # { - if (th->direction == -1) // highest waypoint # + if (mo2->health == 0) + last = mo2; + else { - if (mo2->health == 0) - last = mo2; - else - { - if (first == NULL) - first = mo2; - else if (mo2->health > first->health) - first = mo2; - } - } - else // waypoint 0 - { - if (mo2->health == 0) + if (first == NULL) first = mo2; - else - { - if (last == NULL) - last = mo2; - else if (mo2->health > last->health) - last = mo2; - } + else if (mo2->health > first->health) + first = mo2; + } + } + else // waypoint 0 + { + if (mo2->health == 0) + first = mo2; + else + { + if (last == NULL) + last = mo2; + else if (mo2->health > last->health) + last = mo2; } } } @@ -2544,9 +2628,9 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // Find the actual target movement waypoint target = first; - /*for (wp = thinkercap.next; wp != &thinkercap; wp = wp->next) + /*for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next) { - if (wp->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)wp; @@ -2554,23 +2638,23 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == th->sequence) + if (mo2->threshold != th->sequence) + continue; + + if (th->direction == -1) // highest waypoint # { - if (th->direction == -1) // highest waypoint # + if (mo2->health == first->health - 1) { - if (mo2->health == first->health - 1) - { - target = mo2; - break; - } + target = mo2; + break; } - else // waypoint 0 + } + else // waypoint 0 + { + if (mo2->health == first->health + 1) { - if (mo2->health == first->health + 1) - { - target = mo2; - break; - } + target = mo2; + break; } } }*/ @@ -2585,6 +2669,9 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) // Set pointnum th->pointnum = target->health; + th->target = NULL; // set to NULL first so the below doesn't go wrong + // Set the mobj as your target! -- Monster Iestyn 27/12/19 + P_SetTarget(&th->target, target); // We don't deal with the mirror crap here, we'll // handle that in the T_Thinker function. @@ -2601,7 +2688,7 @@ static void Polyobj_doSlideDoor(polyobj_t *po, polydoordata_t *doordata) // allocate and add a new slide door thinker th = Z_Malloc(sizeof(polyslidedoor_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyDoorSlide; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); // point the polyobject to this thinker po->thinker = &th->thinker; @@ -2649,7 +2736,7 @@ static void Polyobj_doSwingDoor(polyobj_t *po, polydoordata_t *doordata) // allocate and add a new swing door thinker th = Z_Malloc(sizeof(polyswingdoor_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyDoorSwing; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); // point the polyobject to this thinker po->thinker = &th->thinker; @@ -2731,7 +2818,7 @@ INT32 EV_DoPolyObjDisplace(polydisplacedata_t *prdata) // create a new thinker th = Z_Malloc(sizeof(polydisplace_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjDisplace; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); po->thinker = &th->thinker; // set fields @@ -2757,6 +2844,52 @@ INT32 EV_DoPolyObjDisplace(polydisplacedata_t *prdata) return 1; } +INT32 EV_DoPolyObjRotDisplace(polyrotdisplacedata_t *prdata) +{ + polyobj_t *po; + polyobj_t *oldpo; + polyrotdisplace_t *th; + INT32 start; + + if (!(po = Polyobj_GetForNum(prdata->polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjRotate: bad polyobj %d\n", prdata->polyObjNum); + return 0; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return 0; + + // create a new thinker + th = Z_Malloc(sizeof(polyrotdisplace_t), PU_LEVSPEC, NULL); + th->thinker.function.acp1 = (actionf_p1)T_PolyObjRotDisplace; + P_AddThinker(THINK_POLYOBJ, &th->thinker); + po->thinker = &th->thinker; + + // set fields + th->polyObjNum = prdata->polyObjNum; + + th->controlSector = prdata->controlSector; + th->oldHeights = th->controlSector->floorheight+th->controlSector->ceilingheight; + + th->rotscale = prdata->rotscale; + th->turnobjs = prdata->turnobjs; + + oldpo = po; + + // apply action to mirroring polyobjects as well + start = 0; + while ((po = Polyobj_GetChild(oldpo, &start))) + { + prdata->polyObjNum = po->id; // change id to match child polyobject's + EV_DoPolyObjRotDisplace(prdata); + } + + // action was successful + return 1; +} + void T_PolyObjFlag(polymove_t *th) { polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); @@ -2768,7 +2901,7 @@ void T_PolyObjFlag(polymove_t *th) #else { CONS_Debug(DBG_POLYOBJ, "T_PolyObjFlag: thinker with invalid id %d removed.\n", th->polyObjNum); - P_RemoveThinkerDelayed(&th->thinker); + P_RemoveThinker(&th->thinker); return; } #endif @@ -2832,7 +2965,7 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) // create a new thinker th = Z_Malloc(sizeof(polymove_t), PU_LEVSPEC, NULL); th->thinker.function.acp1 = (actionf_p1)T_PolyObjFlag; - PolyObj_AddThinker(&th->thinker); + P_AddThinker(THINK_POLYOBJ, &th->thinker); po->thinker = &th->thinker; // set fields @@ -2860,6 +2993,165 @@ INT32 EV_DoPolyObjFlag(line_t *pfdata) return 1; } +void T_PolyObjFade(polyfade_t *th) +{ + boolean stillfading = false; + polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); + + if (!po) +#ifdef RANGECHECK + I_Error("T_PolyObjFade: thinker has invalid id %d\n", th->polyObjNum); +#else + { + CONS_Debug(DBG_POLYOBJ, "T_PolyObjFade: thinker with invalid id %d removed.\n", th->polyObjNum); + P_RemoveThinker(&th->thinker); + return; + } +#endif + + // check for displacement due to override and reattach when possible + if (po->thinker == NULL) + po->thinker = &th->thinker; + + stillfading = th->ticbased ? !(--(th->timer) <= 0) + : !((th->timer -= th->duration) <= 0); + + if (th->timer <= 0) + { + po->translucency = max(min(th->destvalue, NUMTRANSMAPS), 0); + + // remove thinker + if (po->thinker == &th->thinker) + po->thinker = NULL; + P_RemoveThinker(&th->thinker); + } + else + { + INT16 delta = abs(th->destvalue - th->sourcevalue); + INT32 duration = th->ticbased ? th->duration + : abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // speed-based internal counter duration: delta in 256 scale + fixed_t factor = min(FixedDiv(duration - th->timer, duration), 1*FRACUNIT); + if (th->destvalue < th->sourcevalue) + po->translucency = max(min(po->translucency, th->sourcevalue - (INT16)FixedMul(delta, factor)), th->destvalue); + else if (th->destvalue > th->sourcevalue) + po->translucency = min(max(po->translucency, th->sourcevalue + (INT16)FixedMul(delta, factor)), th->destvalue); + } + + if (!stillfading) + { + // set render flags + if (po->translucency >= NUMTRANSMAPS) // invisible + po->flags &= ~POF_RENDERALL; + else + po->flags |= (po->spawnflags & POF_RENDERALL); + + // set collision + if (th->docollision) + { + if (th->destvalue > th->sourcevalue) // faded out + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; + } + } + } + else + { + if (po->translucency >= NUMTRANSMAPS) + // HACK: OpenGL renders fully opaque when >= NUMTRANSMAPS + po->translucency = NUMTRANSMAPS-1; + + po->flags |= (po->spawnflags & POF_RENDERALL); + + // set collision + if (th->docollision) + { + if (th->doghostfade) + { + po->flags &= ~POF_SOLID; + po->flags |= POF_NOSPECIALS; + } + else + { + po->flags |= (po->spawnflags & POF_SOLID); + if (!(po->spawnflags & POF_NOSPECIALS)) + po->flags &= ~POF_NOSPECIALS; + } + } + } +} + +INT32 EV_DoPolyObjFade(polyfadedata_t *pfdata) +{ + polyobj_t *po; + polyobj_t *oldpo; + polyfade_t *th; + INT32 start; + + if (!(po = Polyobj_GetForNum(pfdata->polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "EV_DoPolyObjFade: bad polyobj %d\n", pfdata->polyObjNum); + return 0; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return 0; + + // already equal, nothing to do + if (po->translucency == pfdata->destvalue) + return 1; + + if (po->thinker && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + P_RemoveThinker(po->thinker); + + // create a new thinker + th = Z_Malloc(sizeof(polyfade_t), PU_LEVSPEC, NULL); + th->thinker.function.acp1 = (actionf_p1)T_PolyObjFade; + P_AddThinker(THINK_POLYOBJ, &th->thinker); + po->thinker = &th->thinker; + + // set fields + th->polyObjNum = pfdata->polyObjNum; + th->sourcevalue = po->translucency; + th->destvalue = pfdata->destvalue; + th->docollision = pfdata->docollision; + th->doghostfade = pfdata->doghostfade; + + if (pfdata->ticbased) + { + th->ticbased = true; + th->timer = th->duration = abs(pfdata->speed); // pfdata->speed is duration + } + else + { + th->ticbased = false; + th->timer = abs(FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->destvalue) + - FixedMul(FixedDiv(256, NUMTRANSMAPS), NUMTRANSMAPS - th->sourcevalue)); // delta converted to 256 scale, use as internal counter + th->duration = abs(pfdata->speed); // use th->duration as speed decrement + } + + oldpo = po; + + // apply action to mirroring polyobjects as well + start = 0; + while ((po = Polyobj_GetChild(oldpo, &start))) + { + pfdata->polyObjNum = po->id; + EV_DoPolyObjFade(pfdata); + } + + // action was successful + return 1; +} + #endif // ifdef POLYOBJECTS // EOF diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 60e996cae..d56701d2d 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by James Haley -// Copyright (C) 2006-2018 by Sonic Team Junior. +// Copyright (C) 2006-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,7 +28,7 @@ #define POLYOBJ_ANCHOR_DOOMEDNUM 760 #define POLYOBJ_SPAWN_DOOMEDNUM 761 -#define POLYOBJ_SPAWNCRUSH_DOOMEDNUM 762 +#define POLYOBJ_SPAWNCRUSH_DOOMEDNUM 762 // todo: REMOVE #define POLYOBJ_START_LINE 20 #define POLYOBJ_EXPLICIT_LINE 21 @@ -104,6 +104,7 @@ typedef struct polyobj_s // these are saved for netgames, so do not let Lua touch these! INT32 spawnflags; // Flags the polyobject originally spawned with + INT32 spawntrans; // Translucency the polyobject originally spawned with } polyobj_t; // @@ -160,6 +161,8 @@ typedef struct polywaypoint_s fixed_t diffx; fixed_t diffy; fixed_t diffz; + + mobj_t *target; // next waypoint mobj } polywaypoint_t; typedef struct polyslidedoor_s @@ -206,6 +209,31 @@ typedef struct polydisplace_s fixed_t oldHeights; } polydisplace_t; +typedef struct polyrotdisplace_s +{ + thinker_t thinker; // must be first + + INT32 polyObjNum; + struct sector_s *controlSector; + fixed_t rotscale; + UINT8 turnobjs; + fixed_t oldHeights; +} polyrotdisplace_t; + +typedef struct polyfade_s +{ + thinker_t thinker; // must be first + + INT32 polyObjNum; + INT32 sourcevalue; + INT32 destvalue; + boolean docollision; + boolean doghostfade; + boolean ticbased; + INT32 duration; + INT32 timer; +} polyfade_t; + // // Line Activation Data Structures // @@ -265,6 +293,24 @@ typedef struct polydisplacedata_s fixed_t dy; } polydisplacedata_t; +typedef struct polyrotdisplacedata_s +{ + INT32 polyObjNum; + struct sector_s *controlSector; + fixed_t rotscale; + UINT8 turnobjs; +} polyrotdisplacedata_t; + +typedef struct polyfadedata_s +{ + INT32 polyObjNum; + INT32 destvalue; + boolean docollision; + boolean doghostfade; + boolean ticbased; + INT32 speed; +} polyfadedata_t; + // // Functions // @@ -276,7 +322,7 @@ boolean P_PointInsidePolyobj(polyobj_t *po, fixed_t x, fixed_t y); boolean P_MobjTouchingPolyobj(polyobj_t *po, mobj_t *mo); boolean P_MobjInsidePolyobj(polyobj_t *po, mobj_t *mo); boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox); -void Polyobj_GetInfo(INT16 tag, INT32 *polyID, INT32 *parentID, UINT16 *exparg); +void Polyobj_GetInfo(INT16 poid, INT32 *poflags, INT32 *parentID, INT32 *potrans); // thinkers (needed in p_saveg.c) void T_PolyObjRotate(polyrotate_t *); @@ -285,14 +331,18 @@ void T_PolyObjWaypoint (polywaypoint_t *); void T_PolyDoorSlide(polyslidedoor_t *); void T_PolyDoorSwing(polyswingdoor_t *); void T_PolyObjDisplace (polydisplace_t *); +void T_PolyObjRotDisplace (polyrotdisplace_t *); void T_PolyObjFlag (polymove_t *); +void T_PolyObjFade (polyfade_t *); INT32 EV_DoPolyDoor(polydoordata_t *); INT32 EV_DoPolyObjMove(polymovedata_t *); INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *); INT32 EV_DoPolyObjRotate(polyrotdata_t *); INT32 EV_DoPolyObjDisplace(polydisplacedata_t *); +INT32 EV_DoPolyObjRotDisplace(polyrotdisplacedata_t *); INT32 EV_DoPolyObjFlag(struct line_s *); +INT32 EV_DoPolyObjFade(polyfadedata_t *); // diff --git a/src/p_pspr.h b/src/p_pspr.h index 16708bcb2..3c10e9be4 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -35,12 +35,16 @@ #pragma interface #endif -/// \brief Frame flags: only the frame number -#define FF_FRAMEMASK 0x3fff -/// \brief Frame flags: Simple stateless animation -#define FF_ANIMATE 0x4000 -/// \brief Frame flags: frame always appears full bright -#define FF_FULLBRIGHT 0x8000 +/// \brief Frame flags: only the frame number - 0 to 256 (Frames from 0 to 63, Sprite2 number uses 0 to 127 plus FF_SPR2SUPER) +#define FF_FRAMEMASK 0xff + +/// \brief Frame flags - SPR2: Super sprite2 +#define FF_SPR2SUPER 0x80 +/// \brief Frame flags - SPR2: A change of state at the end of Sprite2 animation +#define FF_SPR2ENDSTATE 0x1000 +/// \brief Frame flags - SPR2: 50% of starting in middle of Sprite2 animation +#define FF_SPR2MIDSTART 0x2000 + /// \brief Frame flags: 0 = no trans(opaque), 1-15 = transl. table #define FF_TRANSMASK 0xf0000 /// \brief shift for FF_TRANSMASK @@ -56,6 +60,20 @@ #define FF_TRANS80 (tr_trans80<lives; - if (pllives < 3) // Bump up to 3 lives if the player - pllives = 3; // has less than that. - - WRITEUINT8(save_p, player->skincolor); - WRITEUINT8(save_p, player->skin); + INT16 skininfo = player->skin + (botskin<<5); + SINT8 pllives = player->lives; + if (pllives < startinglivesbalance[numgameovers]) // Bump up to 3 lives if the player + pllives = startinglivesbalance[numgameovers]; // has less than that. + WRITEUINT16(save_p, skininfo); + WRITEUINT8(save_p, numgameovers); + WRITESINT8(save_p, pllives); WRITEUINT32(save_p, player->score); - WRITEINT32(save_p, pllives); WRITEINT32(save_p, player->continues); - - if (botskin) - { - WRITEUINT8(save_p, botskin); - WRITEUINT8(save_p, botcolor); - } } // @@ -87,22 +84,14 @@ static inline void P_ArchivePlayer(void) // static inline void P_UnArchivePlayer(void) { - savedata.skincolor = READUINT8(save_p); - savedata.skin = READUINT8(save_p); + INT16 skininfo = READUINT16(save_p); + savedata.skin = skininfo & ((1<<5) - 1); + savedata.botskin = skininfo >> 5; - savedata.score = READINT32(save_p); - savedata.lives = READINT32(save_p); + savedata.numgameovers = READUINT8(save_p); + savedata.lives = READSINT8(save_p); + savedata.score = READUINT32(save_p); savedata.continues = READINT32(save_p); - - if (savedata.botcolor) - { - savedata.botskin = READUINT8(save_p); - if (savedata.botskin-1 >= numskins) - savedata.botskin = 0; - savedata.botcolor = READUINT8(save_p); - } - else - savedata.botskin = 0; } // @@ -126,14 +115,21 @@ static void P_NetArchivePlayers(void) // no longer send ticcmds, player name, skin, or color WRITEANGLE(save_p, players[i].aiming); + WRITEANGLE(save_p, players[i].drawangle); + WRITEANGLE(save_p, players[i].viewrollangle); WRITEANGLE(save_p, players[i].awayviewaiming); WRITEINT32(save_p, players[i].awayviewtics); - WRITEINT32(save_p, players[i].health); + WRITEINT16(save_p, players[i].rings); + WRITEINT16(save_p, players[i].spheres); WRITESINT8(save_p, players[i].pity); WRITEINT32(save_p, players[i].currentweapon); WRITEINT32(save_p, players[i].ringweapons); + WRITEUINT16(save_p, players[i].ammoremoval); + WRITEUINT32(save_p, players[i].ammoremovaltimer); + WRITEINT32(save_p, players[i].ammoremovaltimer); + for (j = 0; j < NUMPOWERS; j++) WRITEUINT16(save_p, players[i].powers[j]); @@ -147,13 +143,11 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].score); WRITEFIXED(save_p, players[i].dashspeed); - WRITEINT32(save_p, players[i].dashtime); WRITESINT8(save_p, players[i].lives); WRITESINT8(save_p, players[i].continues); WRITESINT8(save_p, players[i].xtralife); WRITEUINT8(save_p, players[i].gotcontinue); WRITEFIXED(save_p, players[i].speed); - WRITEUINT8(save_p, players[i].jumping); WRITEUINT8(save_p, players[i].secondjump); WRITEUINT8(save_p, players[i].fly1); WRITEUINT8(save_p, players[i].scoreadd); @@ -162,6 +156,7 @@ static void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].deadtimer); WRITEUINT32(save_p, players[i].exiting); WRITEUINT8(save_p, players[i].homing); + WRITEUINT32(save_p, players[i].dashmode); WRITEUINT32(save_p, players[i].skidtime); //////////////////////////// @@ -195,6 +190,7 @@ static void P_NetArchivePlayers(void) WRITEINT16(save_p, players[i].starpostz); WRITEINT32(save_p, players[i].starpostnum); WRITEANGLE(save_p, players[i].starpostangle); + WRITEFIXED(save_p, players[i].starpostscale); WRITEANGLE(save_p, players[i].angle_pos); WRITEANGLE(save_p, players[i].old_angle_pos); @@ -209,15 +205,25 @@ static void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].drillmeter); WRITEUINT8(save_p, players[i].drilldelay); WRITEUINT8(save_p, players[i].bonustime); + WRITEFIXED(save_p, players[i].oldscale); WRITEUINT8(save_p, players[i].mare); - + WRITEUINT8(save_p, players[i].marelap); + WRITEUINT8(save_p, players[i].marebonuslap); WRITEUINT32(save_p, players[i].marebegunat); WRITEUINT32(save_p, players[i].startedtime); WRITEUINT32(save_p, players[i].finishedtime); + WRITEUINT32(save_p, players[i].lapbegunat); + WRITEUINT32(save_p, players[i].lapstartedtime); + WRITEINT16(save_p, players[i].finishedspheres); WRITEINT16(save_p, players[i].finishedrings); WRITEUINT32(save_p, players[i].marescore); WRITEUINT32(save_p, players[i].lastmarescore); + WRITEUINT32(save_p, players[i].totalmarescore); WRITEUINT8(save_p, players[i].lastmare); + WRITEUINT8(save_p, players[i].lastmarelap); + WRITEUINT8(save_p, players[i].lastmarebonuslap); + WRITEUINT8(save_p, players[i].totalmarelap); + WRITEUINT8(save_p, players[i].totalmarebonuslap); WRITEINT32(save_p, players[i].maxlink); WRITEUINT8(save_p, players[i].texttimer); WRITEUINT8(save_p, players[i].textvar); @@ -234,6 +240,12 @@ static void P_NetArchivePlayers(void) if (players[i].axis2) flags |= SECONDAXIS; + if (players[i].followmobj) + flags |= FOLLOW; + + if (players[i].drone) + flags |= DRONE; + WRITEINT16(save_p, players[i].lastsidehit); WRITEINT16(save_p, players[i].lastlinehit); @@ -244,6 +256,7 @@ static void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].onconveyor); WRITEUINT32(save_p, players[i].jointime); + WRITEUINT32(save_p, players[i].quittime); WRITEUINT16(save_p, flags); @@ -259,12 +272,22 @@ static void P_NetArchivePlayers(void) if (flags & AWAYVIEW) WRITEUINT32(save_p, players[i].awayviewmobj->mobjnum); + if (flags & FOLLOW) + WRITEUINT32(save_p, players[i].followmobj->mobjnum); + + if (flags & DRONE) + WRITEUINT32(save_p, players[i].drone->mobjnum); + + WRITEFIXED(save_p, players[i].camerascale); + WRITEFIXED(save_p, players[i].shieldscale); + WRITEUINT8(save_p, players[i].charability); WRITEUINT8(save_p, players[i].charability2); WRITEUINT32(save_p, players[i].charflags); WRITEUINT32(save_p, (UINT32)players[i].thokitem); WRITEUINT32(save_p, (UINT32)players[i].spinitem); WRITEUINT32(save_p, (UINT32)players[i].revitem); + WRITEUINT32(save_p, (UINT32)players[i].followitem); WRITEFIXED(save_p, players[i].actionspd); WRITEFIXED(save_p, players[i].mindash); WRITEFIXED(save_p, players[i].maxdash); @@ -274,6 +297,8 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].accelstart); WRITEUINT8(save_p, players[i].acceleration); WRITEFIXED(save_p, players[i].jumpfactor); + WRITEFIXED(save_p, players[i].height); + WRITEFIXED(save_p, players[i].spinheight); } } @@ -301,14 +326,21 @@ static void P_NetUnArchivePlayers(void) // (that data is handled in the server config now) players[i].aiming = READANGLE(save_p); + players[i].drawangle = READANGLE(save_p); + players[i].viewrollangle = READANGLE(save_p); players[i].awayviewaiming = READANGLE(save_p); players[i].awayviewtics = READINT32(save_p); - players[i].health = READINT32(save_p); + players[i].rings = READINT16(save_p); + players[i].spheres = READINT16(save_p); players[i].pity = READSINT8(save_p); players[i].currentweapon = READINT32(save_p); players[i].ringweapons = READINT32(save_p); + players[i].ammoremoval = READUINT16(save_p); + players[i].ammoremovaltimer = READUINT32(save_p); + players[i].ammoremovalweapon = READINT32(save_p); + for (j = 0; j < NUMPOWERS; j++) players[i].powers[j] = READUINT16(save_p); @@ -322,13 +354,11 @@ static void P_NetUnArchivePlayers(void) players[i].score = READUINT32(save_p); players[i].dashspeed = READFIXED(save_p); // dashing speed - players[i].dashtime = READINT32(save_p); // dashing speed players[i].lives = READSINT8(save_p); players[i].continues = READSINT8(save_p); // continues that player has acquired players[i].xtralife = READSINT8(save_p); // Ring Extra Life counter players[i].gotcontinue = READUINT8(save_p); // got continue from stage players[i].speed = READFIXED(save_p); // Player's speed (distance formula of MOMX and MOMY values) - players[i].jumping = READUINT8(save_p); // Jump counter players[i].secondjump = READUINT8(save_p); players[i].fly1 = READUINT8(save_p); // Tails flying players[i].scoreadd = READUINT8(save_p); // Used for multiple enemy attack bonus @@ -337,6 +367,7 @@ static void P_NetUnArchivePlayers(void) players[i].deadtimer = READINT32(save_p); // End game if game over lasts too long players[i].exiting = READUINT32(save_p); // Exitlevel timer players[i].homing = READUINT8(save_p); // Are you homing? + players[i].dashmode = READUINT32(save_p); // counter for dashmode ability players[i].skidtime = READUINT32(save_p); // Skid timer //////////////////////////// @@ -370,6 +401,7 @@ static void P_NetUnArchivePlayers(void) players[i].starpostz = READINT16(save_p); players[i].starpostnum = READINT32(save_p); players[i].starpostangle = READANGLE(save_p); + players[i].starpostscale = READFIXED(save_p); players[i].angle_pos = READANGLE(save_p); players[i].old_angle_pos = READANGLE(save_p); @@ -384,15 +416,25 @@ static void P_NetUnArchivePlayers(void) players[i].drillmeter = READINT32(save_p); players[i].drilldelay = READUINT8(save_p); players[i].bonustime = (boolean)READUINT8(save_p); + players[i].oldscale = READFIXED(save_p); players[i].mare = READUINT8(save_p); - + players[i].marelap = READUINT8(save_p); + players[i].marebonuslap = READUINT8(save_p); players[i].marebegunat = READUINT32(save_p); players[i].startedtime = READUINT32(save_p); players[i].finishedtime = READUINT32(save_p); + players[i].lapbegunat = READUINT32(save_p); + players[i].lapstartedtime = READUINT32(save_p); + players[i].finishedspheres = READINT16(save_p); players[i].finishedrings = READINT16(save_p); players[i].marescore = READUINT32(save_p); players[i].lastmarescore = READUINT32(save_p); + players[i].totalmarescore = READUINT32(save_p); players[i].lastmare = READUINT8(save_p); + players[i].lastmarelap = READUINT8(save_p); + players[i].lastmarebonuslap = READUINT8(save_p); + players[i].totalmarelap = READUINT8(save_p); + players[i].totalmarebonuslap = READUINT8(save_p); players[i].maxlink = READINT32(save_p); players[i].texttimer = READUINT8(save_p); players[i].textvar = READUINT8(save_p); @@ -407,6 +449,7 @@ static void P_NetUnArchivePlayers(void) players[i].onconveyor = READINT32(save_p); players[i].jointime = READUINT32(save_p); + players[i].quittime = READUINT32(save_p); flags = READUINT16(save_p); @@ -422,7 +465,14 @@ static void P_NetUnArchivePlayers(void) if (flags & AWAYVIEW) players[i].awayviewmobj = (mobj_t *)(size_t)READUINT32(save_p); - players[i].viewheight = cv_viewheight.value<next = 0; + net_colormaps->prev = 0; + num_net_colormaps = i+1; + return i; + } + + for (exc = net_colormaps; exc; exc_prev = exc, exc = exc->next) + { + if (R_CheckEqualColormaps(exc, extra_colormap, true, true, true)) + return i; + i++; + } + + exc_prev->next = R_CopyColormap(extra_colormap, false); + extra_colormap->prev = exc_prev; + extra_colormap->next = 0; + + num_net_colormaps = i+1; + return i; +} + +static extracolormap_t *GetNetColormapFromList(UINT32 index) +{ + // For loading, we have to be tricky: + // We load the sectors BEFORE knowing the colormap values + // So if an index doesn't exist, fill our list with dummy colormaps + // until we get the index we want + // Then when we load the color data, we set up the dummy colormaps + + extracolormap_t *exc, *last_exc = NULL; + UINT32 i = 0; + + if (!net_colormaps) // initialize our list + net_colormaps = R_CreateDefaultColormap(false); + + for (exc = net_colormaps; exc; last_exc = exc, exc = exc->next) + { + if (i++ == index) + return exc; + } + + + // LET'S HOPE that index is a sane value, because we create up to [index] + // entries in net_colormaps. At this point, we don't know + // what the total colormap count is + if (index >= numsectors*3 + num_ffloors) + // if every sector had a unique colormap change AND a fade color thinker which has two colormap entries + // AND every ffloor had a fade FOF thinker with one colormap entry + I_Error("Colormap %d from server is too high for sectors %d", index, (UINT32)numsectors); + + // our index doesn't exist, so just make the entry + for (; i <= index; i++) + { + exc = R_CreateDefaultColormap(false); + if (last_exc) + last_exc->next = exc; + exc->prev = last_exc; + exc->next = NULL; + last_exc = exc; + } + return exc; +} + +static void ClearNetColormaps(void) +{ + // We're actually Z_Freeing each entry here, + // so don't call this in P_NetUnArchiveColormaps (where entries will be used in-game) + extracolormap_t *exc, *exc_next; + + for (exc = net_colormaps; exc; exc = exc_next) + { + exc_next = exc->next; + Z_Free(exc); + } + num_net_colormaps = 0; + num_ffloors = 0; + net_colormaps = NULL; +} + +static void P_NetArchiveColormaps(void) +{ + // We save and then we clean up our colormap mess + extracolormap_t *exc, *exc_next; + UINT32 i = 0; + WRITEUINT32(save_p, num_net_colormaps); // save for safety + + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) + { + // We must save num_net_colormaps worth of data + // So fill non-existent entries with default. + if (!exc) + exc = R_CreateDefaultColormap(false); + + WRITEUINT8(save_p, exc->fadestart); + WRITEUINT8(save_p, exc->fadeend); + WRITEUINT8(save_p, exc->flags); + + WRITEINT32(save_p, exc->rgba); + WRITEINT32(save_p, exc->fadergba); + +#ifdef EXTRACOLORMAPLUMPS + WRITESTRINGN(save_p, exc->lumpname, 9); +#endif + + exc_next = exc->next; + Z_Free(exc); // don't need anymore + } + + num_net_colormaps = 0; + num_ffloors = 0; + net_colormaps = NULL; +} + +static void P_NetUnArchiveColormaps(void) +{ + // When we reach this point, we already populated our list with + // dummy colormaps. Now that we are loading the color data, + // set up the dummies. + extracolormap_t *exc, *existing_exc, *exc_next = NULL; + UINT32 i = 0; + + num_net_colormaps = READUINT32(save_p); + + for (exc = net_colormaps; i < num_net_colormaps; i++, exc = exc_next) + { + UINT8 fadestart, fadeend, flags; + INT32 rgba, fadergba; +#ifdef EXTRACOLORMAPLUMPS + char lumpname[9]; +#endif + + fadestart = READUINT8(save_p); + fadeend = READUINT8(save_p); + flags = READUINT8(save_p); + + rgba = READINT32(save_p); + fadergba = READINT32(save_p); + +#ifdef EXTRACOLORMAPLUMPS + READSTRINGN(save_p, lumpname, 9); + + if (lumpname[0]) + { + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now + existing_exc = R_ColormapForName(lumpname); + *exc = *existing_exc; + R_AddColormapToList(exc); // see HACK note below on why we're adding duplicates + continue; + } +#endif + + if (!exc) + // no point making a new entry since nothing points to it, + // but we needed to read the data so now continue + continue; + + exc_next = exc->next; // this gets overwritten during our operations here, so get it now + + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->flags = flags; + + exc->rgba = rgba; + exc->fadergba = fadergba; + +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + + existing_exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags); + + if (existing_exc) + exc->colormap = existing_exc->colormap; + else + // CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + // R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + // R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); + exc->colormap = R_CreateLightTable(exc); + + // HACK: If this dummy is a duplicate, we're going to add it + // to the extra_colormaps list anyway. I think this is faster + // than going through every loaded sector and correcting their + // colormap address to the pre-existing one, PER net_colormap entry + R_AddColormapToList(exc); + + if (i < num_net_colormaps-1 && !exc_next) + exc_next = R_CreateDefaultColormap(false); + } + + // if we still have a valid net_colormap after iterating up to num_net_colormaps, + // some sector had a colormap index higher than num_net_colormaps. We done goofed or $$$ was corrupted. + // In any case, add them to the colormap list too so that at least the sectors' colormap + // addresses are valid and accounted properly + if (exc_next) + { + existing_exc = R_GetDefaultColormap(); + for (exc = exc_next; exc; exc = exc->next) + { + exc->colormap = existing_exc->colormap; // all our dummies are default values + R_AddColormapToList(exc); + } + } + + // Don't need these anymore + num_net_colormaps = 0; + num_ffloors = 0; + net_colormaps = NULL; +} + +/// +/// World Archiving +/// + #define SD_FLOORHT 0x01 #define SD_CEILHT 0x02 #define SD_FLOORPIC 0x04 @@ -457,10 +749,14 @@ static void P_NetUnArchivePlayers(void) #define SD_FYOFFS 0x02 #define SD_CXOFFS 0x04 #define SD_CYOFFS 0x08 -#define SD_TAG 0x10 -#define SD_FLOORANG 0x20 -#define SD_CEILANG 0x40 -#define SD_TAGLIST 0x80 +#define SD_FLOORANG 0x10 +#define SD_CEILANG 0x20 +#define SD_TAG 0x40 +#define SD_DIFF3 0x80 + +// diff3 flags +#define SD_TAGLIST 0x01 +#define SD_COLORMAP 0x02 #define LD_FLAG 0x01 #define LD_SPECIAL 0x02 @@ -485,76 +781,61 @@ static void P_NetArchiveWorld(void) size_t i; INT32 statsec = 0, statline = 0; const line_t *li = lines; + const line_t *spawnli = spawnlines; const side_t *si; + const side_t *spawnsi; UINT8 *put; - // reload the map just to see difference - mapsector_t *ms; - mapsidedef_t *msd; - maplinedef_t *mld; const sector_t *ss = sectors; - UINT8 diff, diff2; + const sector_t *spawnss = spawnsectors; + UINT8 diff, diff2, diff3; + + // initialize colormap vars because paranoia + ClearNetColormaps(); WRITEUINT32(save_p, ARCHIVEBLOCK_WORLD); put = save_p; - if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 - { // HACK: Open wad file rather quickly so we can get the data from the relevant lumps - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); -#define retrieve_mapdata(d, f)\ - d = Z_Malloc((f)->size, PU_CACHE, NULL); \ - M_Memcpy(d, wadData + (f)->filepos, (f)->size) - retrieve_mapdata(ms, fileinfo + ML_SECTORS); - retrieve_mapdata(mld, fileinfo + ML_LINEDEFS); - retrieve_mapdata(msd, fileinfo + ML_SIDEDEFS); -#undef retrieve_mapdata - Z_Free(wadData); // we're done with this now - } - else // phew it's just a WAD + for (i = 0; i < numsectors; i++, ss++, spawnss++) { - ms = W_CacheLumpNum(lastloadedmaplumpnum+ML_SECTORS, PU_CACHE); - mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); - msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); - } - - for (i = 0; i < numsectors; i++, ss++, ms++) - { - diff = diff2 = 0; - if (ss->floorheight != SHORT(ms->floorheight)<floorheight != spawnss->floorheight) diff |= SD_FLOORHT; - if (ss->ceilingheight != SHORT(ms->ceilingheight)<ceilingheight != spawnss->ceilingheight) diff |= SD_CEILHT; // // flats // - if (ss->floorpic != P_CheckLevelFlat(ms->floorpic)) + if (ss->floorpic != spawnss->floorpic) diff |= SD_FLOORPIC; - if (ss->ceilingpic != P_CheckLevelFlat(ms->ceilingpic)) + if (ss->ceilingpic != spawnss->ceilingpic) diff |= SD_CEILPIC; - if (ss->lightlevel != SHORT(ms->lightlevel)) + if (ss->lightlevel != spawnss->lightlevel) diff |= SD_LIGHT; - if (ss->special != SHORT(ms->special)) + if (ss->special != spawnss->special) diff |= SD_SPECIAL; - if (ss->floor_xoffs != ss->spawn_flr_xoffs) + if (ss->floor_xoffs != spawnss->floor_xoffs) diff2 |= SD_FXOFFS; - if (ss->floor_yoffs != ss->spawn_flr_yoffs) + if (ss->floor_yoffs != spawnss->floor_yoffs) diff2 |= SD_FYOFFS; - if (ss->ceiling_xoffs != ss->spawn_ceil_xoffs) + if (ss->ceiling_xoffs != spawnss->ceiling_xoffs) diff2 |= SD_CXOFFS; - if (ss->ceiling_yoffs != ss->spawn_ceil_yoffs) + if (ss->ceiling_yoffs != spawnss->ceiling_yoffs) diff2 |= SD_CYOFFS; - if (ss->floorpic_angle != ss->spawn_flrpic_angle) + if (ss->floorpic_angle != spawnss->floorpic_angle) diff2 |= SD_FLOORANG; - if (ss->ceilingpic_angle != ss->spawn_flrpic_angle) + if (ss->ceilingpic_angle != spawnss->ceilingpic_angle) diff2 |= SD_CEILANG; - if (ss->tag != SHORT(ms->tag)) + if (ss->tag != spawnss->tag) diff2 |= SD_TAG; - if (ss->nexttag != ss->spawn_nexttag || ss->firsttag != ss->spawn_firsttag) - diff2 |= SD_TAGLIST; + if (ss->nexttag != spawnss->nexttag || ss->firsttag != spawnss->firsttag) + diff3 |= SD_TAGLIST; + + if (ss->extra_colormap != spawnss->extra_colormap) + diff3 |= SD_COLORMAP; // Check if any of the sector's FOFs differ from how they spawned if (ss->ffloors) @@ -571,6 +852,9 @@ static void P_NetArchiveWorld(void) } } + if (diff3) + diff2 |= SD_DIFF3; + if (diff2) diff |= SD_DIFF2; @@ -582,6 +866,8 @@ static void P_NetArchiveWorld(void) WRITEUINT8(put, diff); if (diff & SD_DIFF2) WRITEUINT8(put, diff2); + if (diff2 & SD_DIFF3) + WRITEUINT8(put, diff3); if (diff & SD_FLOORHT) WRITEFIXED(put, ss->floorheight); if (diff & SD_CEILHT) @@ -602,18 +888,22 @@ static void P_NetArchiveWorld(void) WRITEFIXED(put, ss->ceiling_xoffs); if (diff2 & SD_CYOFFS) WRITEFIXED(put, ss->ceiling_yoffs); - if (diff2 & SD_TAG) // save only the tag - WRITEINT16(put, ss->tag); if (diff2 & SD_FLOORANG) WRITEANGLE(put, ss->floorpic_angle); if (diff2 & SD_CEILANG) WRITEANGLE(put, ss->ceilingpic_angle); - if (diff2 & SD_TAGLIST) // save both firsttag and nexttag + if (diff2 & SD_TAG) // save only the tag + WRITEINT16(put, ss->tag); + if (diff3 & SD_TAGLIST) // save both firsttag and nexttag { // either of these could be changed even if tag isn't WRITEINT32(put, ss->firsttag); WRITEINT32(put, ss->nexttag); } + if (diff3 & SD_COLORMAP) + WRITEUINT32(put, CheckAddNetColormapToList(ss->extra_colormap)); + // returns existing index if already added, or appends to net_colormaps and returns new index + // Special case: save the stats of all modified ffloors along with their ffloor "number"s // we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed if (diff & SD_FFLOORS) @@ -647,48 +937,42 @@ static void P_NetArchiveWorld(void) WRITEUINT16(put, 0xffff); - mld = W_CacheLumpNum(lastloadedmaplumpnum+ML_LINEDEFS, PU_CACHE); - msd = W_CacheLumpNum(lastloadedmaplumpnum+ML_SIDEDEFS, PU_CACHE); // do lines - for (i = 0; i < numlines; i++, mld++, li++) + for (i = 0; i < numlines; i++, spawnli++, li++) { - diff = diff2 = 0; + diff = diff2 = diff3 = 0; - if (li->special != SHORT(mld->special)) + if (li->special != spawnli->special) diff |= LD_SPECIAL; - if (SHORT(mld->special) == 321 || SHORT(mld->special) == 322) // only reason li->callcount would be non-zero is if either of these are involved + if (spawnli->special == 321 || spawnli->special == 322) // only reason li->callcount would be non-zero is if either of these are involved diff |= LD_CLLCOUNT; if (li->sidenum[0] != 0xffff) { si = &sides[li->sidenum[0]]; - if (si->textureoffset != SHORT(msd[li->sidenum[0]].textureoffset)<sidenum[0]]; + if (si->textureoffset != spawnsi->textureoffset) diff |= LD_S1TEXOFF; //SoM: 4/1/2000: Some textures are colormaps. Don't worry about invalid textures. - if (R_CheckTextureNumForName(msd[li->sidenum[0]].toptexture) != -1 - && si->toptexture != R_TextureNumForName(msd[li->sidenum[0]].toptexture)) + if (si->toptexture != spawnsi->toptexture) diff |= LD_S1TOPTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[0]].bottomtexture) != -1 - && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[0]].bottomtexture)) + if (si->bottomtexture != spawnsi->bottomtexture) diff |= LD_S1BOTTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[0]].midtexture) != -1 - && si->midtexture != R_TextureNumForName(msd[li->sidenum[0]].midtexture)) + if (si->midtexture != spawnsi->midtexture) diff |= LD_S1MIDTEX; } if (li->sidenum[1] != 0xffff) { si = &sides[li->sidenum[1]]; - if (si->textureoffset != SHORT(msd[li->sidenum[1]].textureoffset)<sidenum[1]]; + if (si->textureoffset != spawnsi->textureoffset) diff2 |= LD_S2TEXOFF; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].toptexture) != -1 - && si->toptexture != R_TextureNumForName(msd[li->sidenum[1]].toptexture)) + if (si->toptexture != spawnsi->toptexture) diff2 |= LD_S2TOPTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].bottomtexture) != -1 - && si->bottomtexture != R_TextureNumForName(msd[li->sidenum[1]].bottomtexture)) + if (si->bottomtexture != spawnsi->bottomtexture) diff2 |= LD_S2BOTTEX; - if (R_CheckTextureNumForName(msd[li->sidenum[1]].midtexture) != -1 - && si->midtexture != R_TextureNumForName(msd[li->sidenum[1]].midtexture)) + if (si->midtexture != spawnsi->midtexture) diff2 |= LD_S2MIDTEX; if (diff2) diff |= LD_DIFF2; @@ -744,11 +1028,22 @@ static void P_NetUnArchiveWorld(void) line_t *li; side_t *si; UINT8 *get; - UINT8 diff, diff2; + UINT8 diff, diff2, diff3; if (READUINT32(save_p) != ARCHIVEBLOCK_WORLD) I_Error("Bad $$$.sav at archive block World"); + // initialize colormap vars because paranoia + ClearNetColormaps(); + + // count the level's ffloors so that colormap loading can have an upper limit + for (i = 0; i < numsectors; i++) + { + ffloor_t *rover; + for (rover = sectors[i].ffloors; rover; rover = rover->next) + num_ffloors++; + } + get = save_p; for (;;) @@ -766,6 +1061,10 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + if (diff2 & SD_DIFF3) + diff3 = READUINT8(get); + else + diff3 = 0; if (diff & SD_FLOORHT) sectors[i].floorheight = READFIXED(get); @@ -794,17 +1093,20 @@ static void P_NetUnArchiveWorld(void) sectors[i].ceiling_xoffs = READFIXED(get); if (diff2 & SD_CYOFFS) sectors[i].ceiling_yoffs = READFIXED(get); - if (diff2 & SD_TAG) - sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag - if (diff2 & SD_TAGLIST) - { - sectors[i].firsttag = READINT32(get); - sectors[i].nexttag = READINT32(get); - } if (diff2 & SD_FLOORANG) sectors[i].floorpic_angle = READANGLE(get); if (diff2 & SD_CEILANG) sectors[i].ceilingpic_angle = READANGLE(get); + if (diff2 & SD_TAG) + sectors[i].tag = READINT16(get); // DON'T use P_ChangeSectorTag + if (diff3 & SD_TAGLIST) + { + sectors[i].firsttag = READINT32(get); + sectors[i].nexttag = READINT32(get); + } + + if (diff3 & SD_COLORMAP) + sectors[i].extra_colormap = GetNetColormapFromList(READUINT32(get)); if (diff & SD_FFLOORS) { @@ -863,6 +1165,9 @@ static void P_NetUnArchiveWorld(void) diff2 = READUINT8(get); else diff2 = 0; + + diff3 = 0; + if (diff & LD_FLAG) li->flags = READINT16(get); if (diff & LD_SPECIAL) @@ -944,12 +1249,15 @@ typedef enum MD2_EXTVAL1 = 1<<5, MD2_EXTVAL2 = 1<<6, MD2_HNEXT = 1<<7, -#ifdef ESLOPE MD2_HPREV = 1<<8, - MD2_SLOPE = 1<<9 -#else - MD2_HPREV = 1<<8 + MD2_FLOORROVER = 1<<9, + MD2_CEILINGROVER = 1<<10, +#ifdef ESLOPE + MD2_SLOPE = 1<<11, #endif + MD2_COLORIZED = 1<<12, + MD2_ROLLANGLE = 1<<13, + MD2_SHADOWSCALE = 1<<14, } mobj_diff2_t; typedef enum @@ -983,6 +1291,13 @@ typedef enum tc_noenemies, tc_eachtime, tc_disappear, + tc_fade, + tc_fadecolormap, + tc_planedisplace, +#ifdef ESLOPE + tc_dynslopeline, + tc_dynslopevert, +#endif // ESLOPE #ifdef POLYOBJECTS tc_polyrotate, // haleyjd 03/26/06: polyobjects tc_polymove, @@ -991,6 +1306,8 @@ typedef enum tc_polyswingdoor, tc_polyflag, tc_polydisplace, + tc_polyrotdisplace, + tc_polyfade, #endif tc_end } specials_e; @@ -1019,6 +1336,14 @@ static inline UINT32 SavePlayer(const player_t *player) return 0xFFFFFFFF; } +#ifdef ESLOPE +static UINT32 SaveSlope(const pslope_t *slope) +{ + if (slope) return (UINT32)(slope->id); + return 0xFFFFFFFF; +} +#endif // ESLOPE + // // SaveMobjThinker // @@ -1081,6 +1406,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff |= MD_TICS; if (mobj->sprite != mobj->state->sprite) diff |= MD_SPRITE; + if (mobj->sprite == SPR_PLAY && mobj->sprite2 != (mobj->state->frame&FF_FRAMEMASK)) + diff |= MD_SPRITE; if (mobj->frame != mobj->state->frame) diff |= MD_FRAME; if (mobj->anim_duration != (UINT16)mobj->state->var2) @@ -1104,7 +1431,7 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff |= MD_TRACER; if (mobj->friction != ORIG_FRICTION) diff |= MD_FRICTION; - if (mobj->movefactor != ORIG_FRICTION_FACTOR) + if (mobj->movefactor != FRACUNIT) diff |= MD_MOVEFACTOR; if (mobj->fuse) diff |= MD_FUSE; @@ -1140,10 +1467,20 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_HNEXT; if (mobj->hprev) diff2 |= MD2_HPREV; + if (mobj->floorrover) + diff2 |= MD2_FLOORROVER; + if (mobj->ceilingrover) + diff2 |= MD2_CEILINGROVER; #ifdef ESLOPE if (mobj->standingslope) diff2 |= MD2_SLOPE; #endif + if (mobj->colorized) + diff2 |= MD2_COLORIZED; + if (mobj->rollangle) + diff2 |= MD2_ROLLANGLE; + if (mobj->shadowscale) + diff2 |= MD2_SHADOWSCALE; if (diff2 != 0) diff |= MD_MORE; @@ -1163,6 +1500,46 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, mobj->floorz); WRITEFIXED(save_p, mobj->ceilingz); + if (diff2 & MD2_FLOORROVER) + { + ffloor_t *rover; + size_t i = 0; + UINT32 roverindex = 0; + + for (rover = mobj->floorrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->floorrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, (UINT32)(mobj->floorrover->target - sectors)); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref + } + + if (diff2 & MD2_CEILINGROVER) + { + ffloor_t *rover; + size_t i = 0; + UINT32 roverindex = 0; + + for (rover = mobj->ceilingrover->target->ffloors; rover; rover = rover->next) + { + if (rover == mobj->ceilingrover) + { + roverindex = i; + break; + } + i++; + } + + WRITEUINT32(save_p, (UINT32)(mobj->ceilingrover->target - sectors)); + WRITEUINT32(save_p, rover ? roverindex : i); // store max index to denote invalid ffloor ref + } + if (diff & MD_SPAWNPOINT) { size_t z; @@ -1204,8 +1581,11 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT16(save_p, mobj->state-states); if (diff & MD_TICS) WRITEINT32(save_p, mobj->tics); - if (diff & MD_SPRITE) + if (diff & MD_SPRITE) { WRITEUINT16(save_p, mobj->sprite); + if (mobj->sprite == SPR_PLAY) + WRITEUINT8(save_p, mobj->sprite2); + } if (diff & MD_FRAME) { WRITEUINT32(save_p, mobj->frame); @@ -1263,6 +1643,12 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) if (diff2 & MD2_SLOPE) WRITEUINT16(save_p, mobj->standingslope->id); #endif + if (diff2 & MD2_COLORIZED) + WRITEUINT8(save_p, mobj->colorized); + if (diff2 & MD2_ROLLANGLE) + WRITEANGLE(save_p, mobj->rollangle); + if (diff2 & MD2_SHADOWSCALE) + WRITEFIXED(save_p, mobj->shadowscale); WRITEUINT32(save_p, mobj->mobjnum); } @@ -1507,8 +1893,11 @@ static void SaveLightlevelThinker(const thinker_t *th, const UINT8 type) const lightlevel_t *ht = (const void *)th; WRITEUINT8(save_p, type); WRITEUINT32(save_p, SaveSector(ht->sector)); - WRITEINT32(save_p, ht->destlevel); - WRITEINT32(save_p, ht->speed); + WRITEINT16(save_p, ht->sourcelevel); + WRITEINT16(save_p, ht->destlevel); + WRITEFIXED(save_p, ht->fixedcurlevel); + WRITEFIXED(save_p, ht->fixedpertic); + WRITEINT32(save_p, ht->timer); } // @@ -1544,6 +1933,83 @@ static void SaveDisappearThinker(const thinker_t *th, const UINT8 type) WRITEINT32(save_p, ht->exists); } +// +// SaveFadeThinker +// +// Saves a fade_t thinker +// +static void SaveFadeThinker(const thinker_t *th, const UINT8 type) +{ + const fade_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->dest_exc)); + WRITEUINT32(save_p, ht->sectornum); + WRITEUINT32(save_p, ht->ffloornum); + WRITEINT32(save_p, ht->alpha); + WRITEINT16(save_p, ht->sourcevalue); + WRITEINT16(save_p, ht->destvalue); + WRITEINT16(save_p, ht->destlightlevel); + WRITEINT16(save_p, ht->speed); + WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->timer); + WRITEUINT8(save_p, ht->doexists); + WRITEUINT8(save_p, ht->dotranslucent); + WRITEUINT8(save_p, ht->dolighting); + WRITEUINT8(save_p, ht->docolormap); + WRITEUINT8(save_p, ht->docollision); + WRITEUINT8(save_p, ht->doghostfade); + WRITEUINT8(save_p, ht->exactalpha); +} + +// +// SaveFadeColormapThinker +// +// Saves a fadecolormap_t thinker +// +static void SaveFadeColormapThinker(const thinker_t *th, const UINT8 type) +{ + const fadecolormap_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEUINT32(save_p, SaveSector(ht->sector)); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->source_exc)); + WRITEUINT32(save_p, CheckAddNetColormapToList(ht->dest_exc)); + WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); +} + +// +// SavePlaneDisplaceThinker +// +// Saves a planedisplace_t thinker +// +static void SavePlaneDisplaceThinker(const thinker_t *th, const UINT8 type) +{ + const planedisplace_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEINT32(save_p, ht->affectee); + WRITEINT32(save_p, ht->control); + WRITEFIXED(save_p, ht->last_height); + WRITEFIXED(save_p, ht->speed); + WRITEUINT8(save_p, ht->type); +} +#ifdef ESLOPE +/// Save a dynamic slope thinker. +static inline void SaveDynamicSlopeThinker(const thinker_t *th, const UINT8 type) +{ + const dynplanethink_t* ht = (const void*)th; + + WRITEUINT8(save_p, type); + WRITEUINT8(save_p, ht->type); + WRITEUINT32(save_p, SaveSlope(ht->slope)); + WRITEUINT32(save_p, SaveLine(ht->sourceline)); + WRITEFIXED(save_p, ht->extent); + + WRITEMEM(save_p, ht->tags, sizeof(ht->tags)); + WRITEMEM(save_p, ht->vex, sizeof(ht->vex)); +} +#endif // ESLOPE + #ifdef POLYOBJECTS // @@ -1598,6 +2064,7 @@ static void SavePolywaypointThinker(const thinker_t *th, UINT8 type) WRITEFIXED(save_p, ht->diffx); WRITEFIXED(save_p, ht->diffy); WRITEFIXED(save_p, ht->diffz); + WRITEUINT32(save_p, SaveMobjnum(ht->target)); } // @@ -1654,6 +2121,31 @@ static void SavePolydisplaceThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, ht->oldHeights); } +static void SavePolyrotdisplaceThinker(const thinker_t *th, const UINT8 type) +{ + const polyrotdisplace_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEINT32(save_p, ht->polyObjNum); + WRITEUINT32(save_p, SaveSector(ht->controlSector)); + WRITEFIXED(save_p, ht->rotscale); + WRITEUINT8(save_p, ht->turnobjs); + WRITEFIXED(save_p, ht->oldHeights); +} + +static void SavePolyfadeThinker(const thinker_t *th, const UINT8 type) +{ + const polyfade_t *ht = (const void *)th; + WRITEUINT8(save_p, type); + WRITEINT32(save_p, ht->polyObjNum); + WRITEINT32(save_p, ht->sourcevalue); + WRITEINT32(save_p, ht->destvalue); + WRITEUINT8(save_p, (UINT8)ht->docollision); + WRITEUINT8(save_p, (UINT8)ht->doghostfade); + WRITEUINT8(save_p, (UINT8)ht->ticbased); + WRITEINT32(save_p, ht->duration); + WRITEINT32(save_p, ht->timer); +} + #endif /* // @@ -1675,211 +2167,252 @@ static inline void SaveWhatThinker(const thinker_t *th, const UINT8 type) static void P_NetArchiveThinkers(void) { const thinker_t *th; - UINT32 numsaved = 0; + UINT32 i; WRITEUINT32(save_p, ARCHIVEBLOCK_THINKERS); - // save off the current thinkers - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (i = 0; i < NUM_THINKERLISTS; i++) { - if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed - || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) - numsaved++; + UINT32 numsaved = 0; + // save off the current thinkers + for (th = thlist[i].next; th != &thlist[i]; th = th->next) + { + if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed + || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) + numsaved++; - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - SaveMobjThinker(th, tc_mobj); - continue; - } -#ifdef PARANOIA - else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); -#endif - else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) - { - SaveCeilingThinker(th, tc_ceiling); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_CrushCeiling) - { - SaveCeilingThinker(th, tc_crushceiling); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_MoveFloor) - { - SaveFloormoveThinker(th, tc_floor); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_LightningFlash) - { - SaveLightflashThinker(th, tc_flash); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_StrobeFlash) - { - SaveStrobeThinker(th, tc_strobe); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_Glow) - { - SaveGlowThinker(th, tc_glow); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_FireFlicker) - { - SaveFireflickerThinker(th, tc_fireflicker); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_MoveElevator) - { - SaveElevatorThinker(th, tc_elevator); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_ContinuousFalling) - { - SaveSpecialLevelThinker(th, tc_continuousfalling); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_ThwompSector) - { - SaveSpecialLevelThinker(th, tc_thwomp); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_NoEnemiesSector) - { - SaveSpecialLevelThinker(th, tc_noenemies); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_EachTimeThinker) - { - SaveSpecialLevelThinker(th, tc_eachtime); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_RaiseSector) - { - SaveSpecialLevelThinker(th, tc_raisesector); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_CameraScanner) - { - SaveElevatorThinker(th, tc_camerascanner); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_Scroll) - { - SaveScrollThinker(th, tc_scroll); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_Friction) - { - SaveFrictionThinker(th, tc_friction); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_Pusher) - { - SavePusherThinker(th, tc_pusher); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_BounceCheese) - { - SaveSpecialLevelThinker(th, tc_bouncecheese); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_StartCrumble) - { - SaveElevatorThinker(th, tc_startcrumble); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_MarioBlock) - { - SaveSpecialLevelThinker(th, tc_marioblock); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker) - { - SaveSpecialLevelThinker(th, tc_marioblockchecker); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_SpikeSector) - { - SaveSpecialLevelThinker(th, tc_spikesector); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_FloatSector) - { - SaveSpecialLevelThinker(th, tc_floatsector); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_BridgeThinker) - { - SaveSpecialLevelThinker(th, tc_bridgethinker); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_LaserFlash) - { - SaveLaserThinker(th, tc_laserflash); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_LightFade) - { - SaveLightlevelThinker(th, tc_lightfade); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_ExecutorDelay) - { - SaveExecutorThinker(th, tc_executor); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_Disappear) - { - SaveDisappearThinker(th, tc_disappear); - continue; - } + if (th->function.acp1 == (actionf_p1)P_MobjThinker) + { + SaveMobjThinker(th, tc_mobj); + continue; + } + #ifdef PARANOIA + else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); + #endif + else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) + { + SaveCeilingThinker(th, tc_ceiling); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_CrushCeiling) + { + SaveCeilingThinker(th, tc_crushceiling); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_MoveFloor) + { + SaveFloormoveThinker(th, tc_floor); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_LightningFlash) + { + SaveLightflashThinker(th, tc_flash); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_StrobeFlash) + { + SaveStrobeThinker(th, tc_strobe); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_Glow) + { + SaveGlowThinker(th, tc_glow); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_FireFlicker) + { + SaveFireflickerThinker(th, tc_fireflicker); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_MoveElevator) + { + SaveElevatorThinker(th, tc_elevator); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_ContinuousFalling) + { + SaveSpecialLevelThinker(th, tc_continuousfalling); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_ThwompSector) + { + SaveSpecialLevelThinker(th, tc_thwomp); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_NoEnemiesSector) + { + SaveSpecialLevelThinker(th, tc_noenemies); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_EachTimeThinker) + { + SaveSpecialLevelThinker(th, tc_eachtime); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_RaiseSector) + { + SaveSpecialLevelThinker(th, tc_raisesector); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_CameraScanner) + { + SaveElevatorThinker(th, tc_camerascanner); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_Scroll) + { + SaveScrollThinker(th, tc_scroll); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_Friction) + { + SaveFrictionThinker(th, tc_friction); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_Pusher) + { + SavePusherThinker(th, tc_pusher); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_BounceCheese) + { + SaveSpecialLevelThinker(th, tc_bouncecheese); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_StartCrumble) + { + SaveElevatorThinker(th, tc_startcrumble); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_MarioBlock) + { + SaveSpecialLevelThinker(th, tc_marioblock); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_MarioBlockChecker) + { + SaveSpecialLevelThinker(th, tc_marioblockchecker); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_SpikeSector) + { + SaveSpecialLevelThinker(th, tc_spikesector); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_FloatSector) + { + SaveSpecialLevelThinker(th, tc_floatsector); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_BridgeThinker) + { + SaveSpecialLevelThinker(th, tc_bridgethinker); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_LaserFlash) + { + SaveLaserThinker(th, tc_laserflash); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_LightFade) + { + SaveLightlevelThinker(th, tc_lightfade); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_ExecutorDelay) + { + SaveExecutorThinker(th, tc_executor); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_Disappear) + { + SaveDisappearThinker(th, tc_disappear); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_Fade) + { + SaveFadeThinker(th, tc_fade); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_FadeColormap) + { + SaveFadeColormapThinker(th, tc_fadecolormap); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PlaneDisplace) + { + SavePlaneDisplaceThinker(th, tc_planedisplace); + continue; + } #ifdef POLYOBJECTS - else if (th->function.acp1 == (actionf_p1)T_PolyObjRotate) - { - SavePolyrotatetThinker(th, tc_polyrotate); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_PolyObjMove) - { - SavePolymoveThinker(th, tc_polymove); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_PolyObjWaypoint) - { - SavePolywaypointThinker(th, tc_polywaypoint); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_PolyDoorSlide) - { - SavePolyslidedoorThinker(th, tc_polyslidedoor); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_PolyDoorSwing) - { - SavePolyswingdoorThinker(th, tc_polyswingdoor); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_PolyObjFlag) - { - SavePolymoveThinker(th, tc_polyflag); - continue; - } - else if (th->function.acp1 == (actionf_p1)T_PolyObjDisplace) - { - SavePolydisplaceThinker(th, tc_polydisplace); - continue; - } + else if (th->function.acp1 == (actionf_p1)T_PolyObjRotate) + { + SavePolyrotatetThinker(th, tc_polyrotate); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyObjMove) + { + SavePolymoveThinker(th, tc_polymove); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyObjWaypoint) + { + SavePolywaypointThinker(th, tc_polywaypoint); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyDoorSlide) + { + SavePolyslidedoorThinker(th, tc_polyslidedoor); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyDoorSwing) + { + SavePolyswingdoorThinker(th, tc_polyswingdoor); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyObjFlag) + { + SavePolymoveThinker(th, tc_polyflag); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyObjDisplace) + { + SavePolydisplaceThinker(th, tc_polydisplace); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyObjRotDisplace) + { + SavePolyrotdisplaceThinker(th, tc_polyrotdisplace); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_PolyObjFade) + { + SavePolyfadeThinker(th, tc_polyfade); + continue; + } #endif +#ifdef ESLOPE + else if (th->function.acp1 == (actionf_p1)T_DynamicSlopeLine) + { + SaveDynamicSlopeThinker(th, tc_dynslopeline); + continue; + } + else if (th->function.acp1 == (actionf_p1)T_DynamicSlopeVert) + { + SaveDynamicSlopeThinker(th, tc_dynslopevert); + continue; + } +#endif // ESLOPE #ifdef PARANOIA - else if (th->function.acv != P_RemoveThinkerDelayed) // wait garbage collection - I_Error("unknown thinker type %p", th->function.acp1); + else if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) // wait garbage collection + I_Error("unknown thinker type %p", th->function.acp1); #endif + } + + CONS_Debug(DBG_NETPLAY, "%u thinkers saved in list %d\n", numsaved, i); + + WRITEUINT8(save_p, tc_end); } - - CONS_Debug(DBG_NETPLAY, "%u thinkers saved\n", numsaved); - - WRITEUINT8(save_p, tc_end); } // Now save the pointers, tracer and target, but at load time we must @@ -1891,14 +2424,16 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) thinker_t *th; mobj_t *mobj; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mobj = (mobj_t *)th; - if (mobj->mobjnum == oldposition) - return mobj; + if (mobj->mobjnum != oldposition) + continue; + + return mobj; } CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); return NULL; @@ -1928,12 +2463,26 @@ static inline player_t *LoadPlayer(UINT32 player) return &players[player]; } +#ifdef ESLOPE +static inline pslope_t *LoadSlope(UINT32 slopeid) +{ + pslope_t *p = slopelist; + if (slopeid > slopecount) return NULL; + do + { + if (p->id == slopeid) + return p; + } while ((p = p->next)); + return NULL; +} +#endif // ESLOPE + // // LoadMobjThinker // // Loads a mobj_t from a save game // -static void LoadMobjThinker(actionf_p1 thinker) +static thinker_t* LoadMobjThinker(actionf_p1 thinker) { thinker_t *next; mobj_t *mobj; @@ -1941,6 +2490,7 @@ static void LoadMobjThinker(actionf_p1 thinker) UINT16 diff2; INT32 i; fixed_t z, floorz, ceilingz; + ffloor_t *floorrover = NULL, *ceilingrover = NULL; diff = READUINT32(save_p); if (diff & MD_MORE) @@ -1954,14 +2504,46 @@ static void LoadMobjThinker(actionf_p1 thinker) floorz = READFIXED(save_p); ceilingz = READFIXED(save_p); + if (diff2 & MD2_FLOORROVER) + { + size_t floor_sectornum = (size_t)READUINT32(save_p); + size_t floor_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; + size_t rovernum = 0; + + for (rover = sectors[floor_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == floor_rovernum) + break; + rovernum++; + } + floorrover = rover; + } + + if (diff2 & MD2_CEILINGROVER) + { + size_t ceiling_sectornum = (size_t)READUINT32(save_p); + size_t ceiling_rovernum = (size_t)READUINT32(save_p); + ffloor_t *rover = NULL; + size_t rovernum = 0; + + for (rover = sectors[ceiling_sectornum].ffloors; rover; rover = rover->next) + { + if (rovernum == ceiling_rovernum) + break; + rovernum++; + } + ceilingrover = rover; + } + if (diff & MD_SPAWNPOINT) { UINT16 spawnpointnum = READUINT16(save_p); if (mapthings[spawnpointnum].type == 1705 || mapthings[spawnpointnum].type == 1713) // NiGHTS Hoop special case { - P_SpawnHoopsAndRings(&mapthings[spawnpointnum]); - return; + P_SpawnHoop(&mapthings[spawnpointnum]); + return NULL; } mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); @@ -1978,6 +2560,8 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->z = z; mobj->floorz = floorz; mobj->ceilingz = ceilingz; + mobj->floorrover = floorrover; + mobj->ceilingrover = ceilingrover; if (diff & MD_TYPE) mobj->type = READUINT32(save_p); @@ -2047,10 +2631,16 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->tics = READINT32(save_p); else mobj->tics = mobj->state->tics; - if (diff & MD_SPRITE) + if (diff & MD_SPRITE) { mobj->sprite = READUINT16(save_p); - else + if (mobj->sprite == SPR_PLAY) + mobj->sprite2 = READUINT8(save_p); + } + else { mobj->sprite = mobj->state->sprite; + if (mobj->sprite == SPR_PLAY) + mobj->sprite2 = mobj->state->frame&FF_FRAMEMASK; + } if (diff & MD_FRAME) { mobj->frame = READUINT32(save_p); @@ -2095,7 +2685,7 @@ static void LoadMobjThinker(actionf_p1 thinker) if (diff & MD_MOVEFACTOR) mobj->movefactor = READFIXED(save_p); else - mobj->movefactor = ORIG_FRICTION_FACTOR; + mobj->movefactor = FRACUNIT; if (diff & MD_FUSE) mobj->fuse = READINT32(save_p); if (diff & MD_WATERTOP) @@ -2134,7 +2724,12 @@ static void LoadMobjThinker(actionf_p1 thinker) if (diff2 & MD2_SLOPE) mobj->standingslope = P_SlopeById(READUINT16(save_p)); #endif - + if (diff2 & MD2_COLORIZED) + mobj->colorized = READUINT8(save_p); + if (diff2 & MD2_ROLLANGLE) + mobj->rollangle = READANGLE(save_p); + if (diff2 & MD2_SHADOWSCALE) + mobj->shadowscale = READFIXED(save_p); if (diff & MD_REDFLAG) { @@ -2160,9 +2755,9 @@ static void LoadMobjThinker(actionf_p1 thinker) mobj->player->viewz = mobj->player->mo->z + mobj->player->viewheight; } - P_AddThinker(&mobj->thinker); - mobj->info = (mobjinfo_t *)next; // temporarily, set when leave this function + + return &mobj->thinker; } // @@ -2176,7 +2771,7 @@ static void LoadMobjThinker(actionf_p1 thinker) // 2 - Ceiling Only // 3 - Both // -static void LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) +static thinker_t* LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) { levelspecthink_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); size_t i; @@ -2197,7 +2792,7 @@ static void LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) ht->sector->floordata = ht; } - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2205,7 +2800,7 @@ static void LoadSpecialLevelThinker(actionf_p1 thinker, UINT8 floorOrCeiling) // // Loads a ceiling_t from a save game // -static void LoadCeilingThinker(actionf_p1 thinker) +static thinker_t* LoadCeilingThinker(actionf_p1 thinker) { ceiling_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2226,7 +2821,7 @@ static void LoadCeilingThinker(actionf_p1 thinker) ht->sourceline = READFIXED(save_p); if (ht->sector) ht->sector->ceilingdata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2234,7 +2829,7 @@ static void LoadCeilingThinker(actionf_p1 thinker) // // Loads a floormove_t from a save game // -static void LoadFloormoveThinker(actionf_p1 thinker) +static thinker_t* LoadFloormoveThinker(actionf_p1 thinker) { floormove_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2250,7 +2845,7 @@ static void LoadFloormoveThinker(actionf_p1 thinker) ht->delaytimer = READFIXED(save_p); if (ht->sector) ht->sector->floordata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2258,7 +2853,7 @@ static void LoadFloormoveThinker(actionf_p1 thinker) // // Loads a lightflash_t from a save game // -static void LoadLightflashThinker(actionf_p1 thinker) +static thinker_t* LoadLightflashThinker(actionf_p1 thinker) { lightflash_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2267,7 +2862,7 @@ static void LoadLightflashThinker(actionf_p1 thinker) ht->minlight = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2275,7 +2870,7 @@ static void LoadLightflashThinker(actionf_p1 thinker) // // Loads a strobe_t from a save game // -static void LoadStrobeThinker(actionf_p1 thinker) +static thinker_t* LoadStrobeThinker(actionf_p1 thinker) { strobe_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2287,7 +2882,7 @@ static void LoadStrobeThinker(actionf_p1 thinker) ht->brighttime = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2295,7 +2890,7 @@ static void LoadStrobeThinker(actionf_p1 thinker) // // Loads a glow_t from a save game // -static void LoadGlowThinker(actionf_p1 thinker) +static thinker_t* LoadGlowThinker(actionf_p1 thinker) { glow_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2306,14 +2901,14 @@ static void LoadGlowThinker(actionf_p1 thinker) ht->speed = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // // LoadFireflickerThinker // // Loads a fireflicker_t from a save game // -static void LoadFireflickerThinker(actionf_p1 thinker) +static thinker_t* LoadFireflickerThinker(actionf_p1 thinker) { fireflicker_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2324,14 +2919,14 @@ static void LoadFireflickerThinker(actionf_p1 thinker) ht->minlight = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // // LoadElevatorThinker // // Loads a elevator_t from a save game // -static void LoadElevatorThinker(actionf_p1 thinker, UINT8 floorOrCeiling) +static thinker_t* LoadElevatorThinker(actionf_p1 thinker, UINT8 floorOrCeiling) { elevator_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2361,7 +2956,7 @@ static void LoadElevatorThinker(actionf_p1 thinker, UINT8 floorOrCeiling) ht->sector->floordata = ht; } - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2369,7 +2964,7 @@ static void LoadElevatorThinker(actionf_p1 thinker, UINT8 floorOrCeiling) // // Loads a scroll_t from a save game // -static void LoadScrollThinker(actionf_p1 thinker) +static thinker_t* LoadScrollThinker(actionf_p1 thinker) { scroll_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2383,7 +2978,7 @@ static void LoadScrollThinker(actionf_p1 thinker) ht->accel = READINT32(save_p); ht->exclusive = READINT32(save_p); ht->type = READUINT8(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2391,7 +2986,7 @@ static void LoadScrollThinker(actionf_p1 thinker) // // Loads a friction_t from a save game // -static inline void LoadFrictionThinker(actionf_p1 thinker) +static inline thinker_t* LoadFrictionThinker(actionf_p1 thinker) { friction_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2400,7 +2995,7 @@ static inline void LoadFrictionThinker(actionf_p1 thinker) ht->affectee = READINT32(save_p); ht->referrer = READINT32(save_p); ht->roverfriction = READUINT8(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2408,7 +3003,7 @@ static inline void LoadFrictionThinker(actionf_p1 thinker) // // Loads a pusher_t from a save game // -static void LoadPusherThinker(actionf_p1 thinker) +static thinker_t* LoadPusherThinker(actionf_p1 thinker) { pusher_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2426,7 +3021,7 @@ static void LoadPusherThinker(actionf_p1 thinker) ht->exclusive = READINT32(save_p); ht->slider = READINT32(save_p); ht->source = P_GetPushThing(ht->affectee); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2434,7 +3029,7 @@ static void LoadPusherThinker(actionf_p1 thinker) // // Loads a laserthink_t from a save game // -static inline void LoadLaserThinker(actionf_p1 thinker) +static inline thinker_t* LoadLaserThinker(actionf_p1 thinker) { laserthink_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ffloor_t *rover = NULL; @@ -2446,7 +3041,7 @@ static inline void LoadLaserThinker(actionf_p1 thinker) if (rover->secnum == (size_t)(ht->sec - sectors) && rover->master == ht->sourceline) ht->ffloor = rover; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2454,16 +3049,19 @@ static inline void LoadLaserThinker(actionf_p1 thinker) // // Loads a lightlevel_t from a save game // -static inline void LoadLightlevelThinker(actionf_p1 thinker) +static inline thinker_t* LoadLightlevelThinker(actionf_p1 thinker) { lightlevel_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->sector = LoadSector(READUINT32(save_p)); - ht->destlevel = READINT32(save_p); - ht->speed = READINT32(save_p); + ht->sourcelevel = READINT16(save_p); + ht->destlevel = READINT16(save_p); + ht->fixedcurlevel = READFIXED(save_p); + ht->fixedpertic = READFIXED(save_p); + ht->timer = READINT32(save_p); if (ht->sector) ht->sector->lightingdata = ht; - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2471,7 +3069,7 @@ static inline void LoadLightlevelThinker(actionf_p1 thinker) // // Loads a executor_t from a save game // -static inline void LoadExecutorThinker(actionf_p1 thinker) +static inline thinker_t* LoadExecutorThinker(actionf_p1 thinker) { executor_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2479,7 +3077,7 @@ static inline void LoadExecutorThinker(actionf_p1 thinker) ht->caller = LoadMobj(READUINT32(save_p)); ht->sector = LoadSector(READUINT32(save_p)); ht->timer = READINT32(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2487,7 +3085,7 @@ static inline void LoadExecutorThinker(actionf_p1 thinker) // // Loads a disappear_t thinker // -static inline void LoadDisappearThinker(actionf_p1 thinker) +static inline thinker_t* LoadDisappearThinker(actionf_p1 thinker) { disappear_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2498,9 +3096,110 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) ht->affectee = READINT32(save_p); ht->sourceline = READINT32(save_p); ht->exists = READINT32(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } +// +// LoadFadeThinker +// +// Loads a fade_t thinker +// +static inline thinker_t* LoadFadeThinker(actionf_p1 thinker) +{ + sector_t *ss; + fade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->dest_exc = GetNetColormapFromList(READUINT32(save_p)); + ht->sectornum = READUINT32(save_p); + ht->ffloornum = READUINT32(save_p); + ht->alpha = READINT32(save_p); + ht->sourcevalue = READINT16(save_p); + ht->destvalue = READINT16(save_p); + ht->destlightlevel = READINT16(save_p); + ht->speed = READINT16(save_p); + ht->ticbased = (boolean)READUINT8(save_p); + ht->timer = READINT32(save_p); + ht->doexists = READUINT8(save_p); + ht->dotranslucent = READUINT8(save_p); + ht->dolighting = READUINT8(save_p); + ht->docolormap = READUINT8(save_p); + ht->docollision = READUINT8(save_p); + ht->doghostfade = READUINT8(save_p); + ht->exactalpha = READUINT8(save_p); + + ss = LoadSector(ht->sectornum); + if (ss) + { + size_t j = 0; // ss->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc + ffloor_t *rover; + for (rover = ss->ffloors; rover; rover = rover->next) + { + if (j == ht->ffloornum) + { + ht->rover = rover; + rover->fadingdata = ht; + break; + } + j++; + } + } + return &ht->thinker; +} + +// LoadFadeColormapThinker +// +// Loads a fadecolormap_t from a save game +// +static inline thinker_t* LoadFadeColormapThinker(actionf_p1 thinker) +{ + fadecolormap_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->sector = LoadSector(READUINT32(save_p)); + ht->source_exc = GetNetColormapFromList(READUINT32(save_p)); + ht->dest_exc = GetNetColormapFromList(READUINT32(save_p)); + ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT32(save_p); + ht->timer = READINT32(save_p); + if (ht->sector) + ht->sector->fadecolormapdata = ht; + return &ht->thinker; +} + +// +// LoadPlaneDisplaceThinker +// +// Loads a planedisplace_t thinker +// +static inline thinker_t* LoadPlaneDisplaceThinker(actionf_p1 thinker) +{ + planedisplace_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + + ht->affectee = READINT32(save_p); + ht->control = READINT32(save_p); + ht->last_height = READFIXED(save_p); + ht->speed = READFIXED(save_p); + ht->type = READUINT8(save_p); + return &ht->thinker; +} + +#ifdef ESLOPE +/// Save a dynamic slope thinker. +static inline thinker_t* LoadDynamicSlopeThinker(actionf_p1 thinker) +{ + dynplanethink_t* ht = Z_Malloc(sizeof(*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + + ht->type = READUINT8(save_p); + ht->slope = LoadSlope(READUINT32(save_p)); + ht->sourceline = LoadLine(READUINT32(save_p)); + ht->extent = READFIXED(save_p); + READMEM(save_p, ht->tags, sizeof(ht->tags)); + READMEM(save_p, ht->vex, sizeof(ht->vex)); + return &ht->thinker; +} +#endif // ESLOPE + #ifdef POLYOBJECTS // @@ -2508,14 +3207,14 @@ static inline void LoadDisappearThinker(actionf_p1 thinker) // // Loads a polyrotate_t thinker // -static inline void LoadPolyrotatetThinker(actionf_p1 thinker) +static inline thinker_t* LoadPolyrotatetThinker(actionf_p1 thinker) { polyrotate_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; ht->polyObjNum = READINT32(save_p); ht->speed = READINT32(save_p); ht->distance = READINT32(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2523,7 +3222,7 @@ static inline void LoadPolyrotatetThinker(actionf_p1 thinker) // // Loads a polymovet_t thinker // -static void LoadPolymoveThinker(actionf_p1 thinker) +static thinker_t* LoadPolymoveThinker(actionf_p1 thinker) { polymove_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2533,7 +3232,7 @@ static void LoadPolymoveThinker(actionf_p1 thinker) ht->momy = READFIXED(save_p); ht->distance = READINT32(save_p); ht->angle = READANGLE(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2541,7 +3240,7 @@ static void LoadPolymoveThinker(actionf_p1 thinker) // // Loads a polywaypoint_t thinker // -static inline void LoadPolywaypointThinker(actionf_p1 thinker) +static inline thinker_t* LoadPolywaypointThinker(actionf_p1 thinker) { polywaypoint_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2557,7 +3256,8 @@ static inline void LoadPolywaypointThinker(actionf_p1 thinker) ht->diffx = READFIXED(save_p); ht->diffy = READFIXED(save_p); ht->diffz = READFIXED(save_p); - P_AddThinker(&ht->thinker); + ht->target = LoadMobj(READUINT32(save_p)); + return &ht->thinker; } // @@ -2565,7 +3265,7 @@ static inline void LoadPolywaypointThinker(actionf_p1 thinker) // // loads a polyslidedoor_t thinker // -static inline void LoadPolyslidedoorThinker(actionf_p1 thinker) +static inline thinker_t* LoadPolyslidedoorThinker(actionf_p1 thinker) { polyslidedoor_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2582,7 +3282,7 @@ static inline void LoadPolyslidedoorThinker(actionf_p1 thinker) ht->momx = READFIXED(save_p); ht->momy = READFIXED(save_p); ht->closing = READUINT8(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2590,7 +3290,7 @@ static inline void LoadPolyslidedoorThinker(actionf_p1 thinker) // // Loads a polyswingdoor_t thinker // -static inline void LoadPolyswingdoorThinker(actionf_p1 thinker) +static inline thinker_t* LoadPolyswingdoorThinker(actionf_p1 thinker) { polyswingdoor_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2602,7 +3302,7 @@ static inline void LoadPolyswingdoorThinker(actionf_p1 thinker) ht->initDistance = READINT32(save_p); ht->distance = READINT32(save_p); ht->closing = READUINT8(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; } // @@ -2610,7 +3310,7 @@ static inline void LoadPolyswingdoorThinker(actionf_p1 thinker) // // Loads a polydisplace_t thinker // -static inline void LoadPolydisplaceThinker(actionf_p1 thinker) +static inline thinker_t* LoadPolydisplaceThinker(actionf_p1 thinker) { polydisplace_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); ht->thinker.function.acp1 = thinker; @@ -2619,7 +3319,39 @@ static inline void LoadPolydisplaceThinker(actionf_p1 thinker) ht->dx = READFIXED(save_p); ht->dy = READFIXED(save_p); ht->oldHeights = READFIXED(save_p); - P_AddThinker(&ht->thinker); + return &ht->thinker; +} + +static inline thinker_t* LoadPolyrotdisplaceThinker(actionf_p1 thinker) +{ + polyrotdisplace_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->polyObjNum = READINT32(save_p); + ht->controlSector = LoadSector(READUINT32(save_p)); + ht->rotscale = READFIXED(save_p); + ht->turnobjs = READUINT8(save_p); + ht->oldHeights = READFIXED(save_p); + return &ht->thinker; +} + +// +// LoadPolyfadeThinker +// +// Loads a polyfadet_t thinker +// +static thinker_t* LoadPolyfadeThinker(actionf_p1 thinker) +{ + polyfade_t *ht = Z_Malloc(sizeof (*ht), PU_LEVSPEC, NULL); + ht->thinker.function.acp1 = thinker; + ht->polyObjNum = READINT32(save_p); + ht->sourcevalue = READINT32(save_p); + ht->destvalue = READINT32(save_p); + ht->docollision = (boolean)READUINT8(save_p); + ht->doghostfade = (boolean)READUINT8(save_p); + ht->ticbased = (boolean)READUINT8(save_p); + ht->duration = READINT32(save_p); + ht->timer = READINT32(save_p); + return &ht->thinker; } #endif @@ -2652,15 +3384,18 @@ static void P_NetUnArchiveThinkers(void) I_Error("Bad $$$.sav at archive block Thinkers"); // remove all the current thinkers - currentthinker = thinkercap.next; - for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = next) + for (i = 0; i < NUM_THINKERLISTS; i++) { - next = currentthinker->next; + currentthinker = thlist[i].next; + for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = next) + { + next = currentthinker->next; - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) - P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it - else - Z_Free(currentthinker); + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it + else + Z_Free(currentthinker); + } } // we don't want the removed mobjs to come back @@ -2670,187 +3405,233 @@ static void P_NetUnArchiveThinkers(void) // clear sector thinker pointers so they don't point to non-existant thinkers for all of eternity for (i = 0; i < numsectors; i++) { - sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = NULL; + sectors[i].floordata = sectors[i].ceilingdata = sectors[i].lightingdata = sectors[i].fadecolormapdata = NULL; } // read in saved thinkers - for (;;) + for (i = 0; i < NUM_THINKERLISTS; i++) { - tclass = READUINT8(save_p); - - if (tclass == tc_end) - break; // leave the saved thinker reading loop - numloaded++; - - switch (tclass) + for (;;) { - case tc_mobj: - LoadMobjThinker((actionf_p1)P_MobjThinker); - break; + thinker_t* th = NULL; + tclass = READUINT8(save_p); - case tc_ceiling: - LoadCeilingThinker((actionf_p1)T_MoveCeiling); - break; + if (tclass == tc_end) + break; // leave the saved thinker reading loop + numloaded++; - case tc_crushceiling: - LoadCeilingThinker((actionf_p1)T_CrushCeiling); - break; + switch (tclass) + { + case tc_mobj: + th = LoadMobjThinker((actionf_p1)P_MobjThinker); + break; - case tc_floor: - LoadFloormoveThinker((actionf_p1)T_MoveFloor); - break; + case tc_ceiling: + th = LoadCeilingThinker((actionf_p1)T_MoveCeiling); + break; - case tc_flash: - LoadLightflashThinker((actionf_p1)T_LightningFlash); - break; + case tc_crushceiling: + th = LoadCeilingThinker((actionf_p1)T_CrushCeiling); + break; - case tc_strobe: - LoadStrobeThinker((actionf_p1)T_StrobeFlash); - break; + case tc_floor: + th = LoadFloormoveThinker((actionf_p1)T_MoveFloor); + break; - case tc_glow: - LoadGlowThinker((actionf_p1)T_Glow); - break; + case tc_flash: + th = LoadLightflashThinker((actionf_p1)T_LightningFlash); + break; - case tc_fireflicker: - LoadFireflickerThinker((actionf_p1)T_FireFlicker); - break; + case tc_strobe: + th = LoadStrobeThinker((actionf_p1)T_StrobeFlash); + break; - case tc_elevator: - LoadElevatorThinker((actionf_p1)T_MoveElevator, 3); - break; + case tc_glow: + th = LoadGlowThinker((actionf_p1)T_Glow); + break; - case tc_continuousfalling: - LoadSpecialLevelThinker((actionf_p1)T_ContinuousFalling, 3); - break; + case tc_fireflicker: + th = LoadFireflickerThinker((actionf_p1)T_FireFlicker); + break; - case tc_thwomp: - LoadSpecialLevelThinker((actionf_p1)T_ThwompSector, 3); - break; + case tc_elevator: + th = LoadElevatorThinker((actionf_p1)T_MoveElevator, 3); + break; - case tc_noenemies: - LoadSpecialLevelThinker((actionf_p1)T_NoEnemiesSector, 0); - break; + case tc_continuousfalling: + th = LoadSpecialLevelThinker((actionf_p1)T_ContinuousFalling, 3); + break; - case tc_eachtime: - LoadSpecialLevelThinker((actionf_p1)T_EachTimeThinker, 0); - break; + case tc_thwomp: + th = LoadSpecialLevelThinker((actionf_p1)T_ThwompSector, 3); + break; - case tc_raisesector: - LoadSpecialLevelThinker((actionf_p1)T_RaiseSector, 0); - break; + case tc_noenemies: + th = LoadSpecialLevelThinker((actionf_p1)T_NoEnemiesSector, 0); + break; - /// \todo rewrite all the code that uses an elevator_t but isn't an elevator - /// \note working on it! - case tc_camerascanner: - LoadElevatorThinker((actionf_p1)T_CameraScanner, 0); - break; + case tc_eachtime: + th = LoadSpecialLevelThinker((actionf_p1)T_EachTimeThinker, 0); + break; - case tc_bouncecheese: - LoadSpecialLevelThinker((actionf_p1)T_BounceCheese, 2); - break; + case tc_raisesector: + th = LoadSpecialLevelThinker((actionf_p1)T_RaiseSector, 0); + break; - case tc_startcrumble: - LoadElevatorThinker((actionf_p1)T_StartCrumble, 1); - break; + /// \todo rewrite all the code that uses an elevator_t but isn't an elevator + /// \note working on it! + case tc_camerascanner: + th = LoadElevatorThinker((actionf_p1)T_CameraScanner, 0); + break; - case tc_marioblock: - LoadSpecialLevelThinker((actionf_p1)T_MarioBlock, 3); - break; + case tc_bouncecheese: + th = LoadSpecialLevelThinker((actionf_p1)T_BounceCheese, 2); + break; - case tc_marioblockchecker: - LoadSpecialLevelThinker((actionf_p1)T_MarioBlockChecker, 0); - break; + case tc_startcrumble: + th = LoadElevatorThinker((actionf_p1)T_StartCrumble, 1); + break; - case tc_spikesector: - LoadSpecialLevelThinker((actionf_p1)T_SpikeSector, 0); - break; + case tc_marioblock: + th = LoadSpecialLevelThinker((actionf_p1)T_MarioBlock, 3); + break; - case tc_floatsector: - LoadSpecialLevelThinker((actionf_p1)T_FloatSector, 0); - break; + case tc_marioblockchecker: + th = LoadSpecialLevelThinker((actionf_p1)T_MarioBlockChecker, 0); + break; - case tc_bridgethinker: - LoadSpecialLevelThinker((actionf_p1)T_BridgeThinker, 3); - break; + case tc_spikesector: + th = LoadSpecialLevelThinker((actionf_p1)T_SpikeSector, 0); + break; - case tc_laserflash: - LoadLaserThinker((actionf_p1)T_LaserFlash); - break; + case tc_floatsector: + th = LoadSpecialLevelThinker((actionf_p1)T_FloatSector, 0); + break; - case tc_lightfade: - LoadLightlevelThinker((actionf_p1)T_LightFade); - break; + case tc_bridgethinker: + th = LoadSpecialLevelThinker((actionf_p1)T_BridgeThinker, 3); + break; - case tc_executor: - LoadExecutorThinker((actionf_p1)T_ExecutorDelay); - restoreNum = true; - break; + case tc_laserflash: + th = LoadLaserThinker((actionf_p1)T_LaserFlash); + break; - case tc_disappear: - LoadDisappearThinker((actionf_p1)T_Disappear); - break; + case tc_lightfade: + th = LoadLightlevelThinker((actionf_p1)T_LightFade); + break; + + case tc_executor: + th = LoadExecutorThinker((actionf_p1)T_ExecutorDelay); + restoreNum = true; + break; + + case tc_disappear: + th = LoadDisappearThinker((actionf_p1)T_Disappear); + break; + + case tc_fade: + th = LoadFadeThinker((actionf_p1)T_Fade); + break; + + case tc_fadecolormap: + th = LoadFadeColormapThinker((actionf_p1)T_FadeColormap); + break; + + case tc_planedisplace: + th = LoadPlaneDisplaceThinker((actionf_p1)T_PlaneDisplace); + break; #ifdef POLYOBJECTS - case tc_polyrotate: - LoadPolyrotatetThinker((actionf_p1)T_PolyObjRotate); - break; + case tc_polyrotate: + th = LoadPolyrotatetThinker((actionf_p1)T_PolyObjRotate); + break; - case tc_polymove: - LoadPolymoveThinker((actionf_p1)T_PolyObjMove); - break; + case tc_polymove: + th = LoadPolymoveThinker((actionf_p1)T_PolyObjMove); + break; - case tc_polywaypoint: - LoadPolywaypointThinker((actionf_p1)T_PolyObjWaypoint); - break; + case tc_polywaypoint: + th = LoadPolywaypointThinker((actionf_p1)T_PolyObjWaypoint); + restoreNum = true; + break; - case tc_polyslidedoor: - LoadPolyslidedoorThinker((actionf_p1)T_PolyDoorSlide); - break; + case tc_polyslidedoor: + th = LoadPolyslidedoorThinker((actionf_p1)T_PolyDoorSlide); + break; - case tc_polyswingdoor: - LoadPolyswingdoorThinker((actionf_p1)T_PolyDoorSwing); - break; + case tc_polyswingdoor: + th = LoadPolyswingdoorThinker((actionf_p1)T_PolyDoorSwing); + break; - case tc_polyflag: - LoadPolymoveThinker((actionf_p1)T_PolyObjFlag); - break; + case tc_polyflag: + th = LoadPolymoveThinker((actionf_p1)T_PolyObjFlag); + break; - case tc_polydisplace: - LoadPolydisplaceThinker((actionf_p1)T_PolyObjDisplace); - break; + case tc_polydisplace: + th = LoadPolydisplaceThinker((actionf_p1)T_PolyObjDisplace); + break; + + case tc_polyrotdisplace: + th = LoadPolyrotdisplaceThinker((actionf_p1)T_PolyObjRotDisplace); + break; + + case tc_polyfade: + th = LoadPolyfadeThinker((actionf_p1)T_PolyObjFade); + break; #endif - case tc_scroll: - LoadScrollThinker((actionf_p1)T_Scroll); - break; +#ifdef ESLOPE + case tc_dynslopeline: + th = LoadDynamicSlopeThinker((actionf_p1)T_DynamicSlopeLine); + break; - case tc_friction: - LoadFrictionThinker((actionf_p1)T_Friction); - break; + case tc_dynslopevert: + th = LoadDynamicSlopeThinker((actionf_p1)T_DynamicSlopeVert); + break; +#endif // ESLOPE - case tc_pusher: - LoadPusherThinker((actionf_p1)T_Pusher); - break; + case tc_scroll: + th = LoadScrollThinker((actionf_p1)T_Scroll); + break; - default: - I_Error("P_UnarchiveSpecials: Unknown tclass %d in savegame", tclass); + case tc_friction: + th = LoadFrictionThinker((actionf_p1)T_Friction); + break; + + case tc_pusher: + th = LoadPusherThinker((actionf_p1)T_Pusher); + break; + + default: + I_Error("P_UnarchiveSpecials: Unknown tclass %d in savegame", tclass); + } + if (th) + P_AddThinker(i, th); } - } - CONS_Debug(DBG_NETPLAY, "%u thinkers loaded\n", numloaded); + CONS_Debug(DBG_NETPLAY, "%u thinkers loaded in list %d\n", numloaded, i); + } if (restoreNum) { executor_t *delay = NULL; + polywaypoint_t *polywp = NULL; UINT32 mobjnum; - for (currentthinker = thinkercap.next; currentthinker != &thinkercap; - currentthinker = currentthinker->next) + for (currentthinker = thlist[THINK_MAIN].next; currentthinker != &thlist[THINK_MAIN]; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)T_ExecutorDelay) - { - delay = (void *)currentthinker; - if ((mobjnum = (UINT32)(size_t)delay->caller)) - delay->caller = P_FindNewPosition(mobjnum); - } + if (currentthinker->function.acp1 != (actionf_p1)T_ExecutorDelay) + continue; + delay = (void *)currentthinker; + if (!(mobjnum = (UINT32)(size_t)delay->caller)) + continue; + delay->caller = P_FindNewPosition(mobjnum); + } + for (currentthinker = thlist[THINK_POLYOBJ].next; currentthinker != &thlist[THINK_POLYOBJ]; currentthinker = currentthinker->next) + { + if (currentthinker->function.acp1 != (actionf_p1)T_PolyObjWaypoint) + continue; + polywp = (void *)currentthinker; + if (!(mobjnum = (UINT32)(size_t)polywp->target)) + continue; + polywp->target = P_FindNewPosition(mobjnum); } } } @@ -2874,7 +3655,7 @@ static inline void P_ArchivePolyObj(polyobj_t *po) if (po->flags != po->spawnflags) diff |= PD_FLAGS; - if (po->translucency != 0) + if (po->translucency != po->spawntrans) diff |= PD_TRANS; WRITEUINT8(save_p, diff); @@ -2958,14 +3739,14 @@ static inline void P_FinishMobjs(void) mobj_t *mobj; // put info field there real value - for (currentthinker = thinkercap.next; currentthinker != &thinkercap; + for (currentthinker = thlist[THINK_MOBJ].next; currentthinker != &thlist[THINK_MOBJ]; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj = (mobj_t *)currentthinker; - mobj->info = &mobjinfo[mobj->type]; - } + if (currentthinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mobj = (mobj_t *)currentthinker; + mobj->info = &mobjinfo[mobj->type]; } } @@ -2976,72 +3757,86 @@ static void P_RelinkPointers(void) UINT32 temp; // use info field (value = oldposition) to relink mobjs - for (currentthinker = thinkercap.next; currentthinker != &thinkercap; + for (currentthinker = thlist[THINK_MOBJ].next; currentthinker != &thlist[THINK_MOBJ]; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) + if (currentthinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mobj = (mobj_t *)currentthinker; + + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + + if (mobj->tracer) { - mobj = (mobj_t *)currentthinker; - - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - - if (mobj->tracer) - { - temp = (UINT32)(size_t)mobj->tracer; - mobj->tracer = NULL; - if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); - } - if (mobj->target) - { - temp = (UINT32)(size_t)mobj->target; - mobj->target = NULL; - if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); - } - if (mobj->hnext) - { - temp = (UINT32)(size_t)mobj->hnext; - mobj->hnext = NULL; - if (!(mobj->hnext = P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); - } - if (mobj->hprev) - { - temp = (UINT32)(size_t)mobj->hprev; - mobj->hprev = NULL; - if (!(mobj->hprev = P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->capsule) - { - temp = (UINT32)(size_t)mobj->player->capsule; - mobj->player->capsule = NULL; - if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis1) - { - temp = (UINT32)(size_t)mobj->player->axis1; - mobj->player->axis1 = NULL; - if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis2) - { - temp = (UINT32)(size_t)mobj->player->axis2; - mobj->player->axis2 = NULL; - if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->awayviewmobj) - { - temp = (UINT32)(size_t)mobj->player->awayviewmobj; - mobj->player->awayviewmobj = NULL; - if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); - } + temp = (UINT32)(size_t)mobj->tracer; + mobj->tracer = NULL; + if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); + } + if (mobj->target) + { + temp = (UINT32)(size_t)mobj->target; + mobj->target = NULL; + if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); + } + if (mobj->hnext) + { + temp = (UINT32)(size_t)mobj->hnext; + mobj->hnext = NULL; + if (!(mobj->hnext = P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); + } + if (mobj->hprev) + { + temp = (UINT32)(size_t)mobj->hprev; + mobj->hprev = NULL; + if (!(mobj->hprev = P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->capsule) + { + temp = (UINT32)(size_t)mobj->player->capsule; + mobj->player->capsule = NULL; + if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis1) + { + temp = (UINT32)(size_t)mobj->player->axis1; + mobj->player->axis1 = NULL; + if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->axis2) + { + temp = (UINT32)(size_t)mobj->player->axis2; + mobj->player->axis2 = NULL; + if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->awayviewmobj) + { + temp = (UINT32)(size_t)mobj->player->awayviewmobj; + mobj->player->awayviewmobj = NULL; + if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->followmobj) + { + temp = (UINT32)(size_t)mobj->player->followmobj; + mobj->player->followmobj = NULL; + if (!P_SetTarget(&mobj->player->followmobj, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "followmobj not found on %d\n", mobj->type); + } + if (mobj->player && mobj->player->drone) + { + temp = (UINT32)(size_t)mobj->player->drone; + mobj->player->drone = NULL; + if (!P_SetTarget(&mobj->player->drone, P_FindNewPosition(temp))) + CONS_Debug(DBG_GAMELOGIC, "drone not found on %d\n", mobj->type); } } } @@ -3141,9 +3936,10 @@ static inline void P_ArchiveMisc(void) else WRITEINT16(save_p, gamemap); - lastmapsaved = gamemap; + //lastmapsaved = gamemap; + lastmaploaded = gamemap; - WRITEUINT16(save_p, (botskin ? (emeralds|(1<<10)) : emeralds)+357); + WRITEUINT16(save_p, emeralds+357); WRITESTRINGN(save_p, timeattackfolder, sizeof(timeattackfolder)); } @@ -3166,15 +3962,13 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride) if(!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); - lastmapsaved = gamemap; + //lastmapsaved = gamemap; + lastmaploaded = gamemap; tokenlist = 0; token = 0; savedata.emeralds = READUINT16(save_p)-357; - if (savedata.emeralds & (1<<10)) - savedata.botcolor = 0xFF; - savedata.emeralds &= 0xff; READSTRINGN(save_p, testname, sizeof(testname)); @@ -3192,7 +3986,6 @@ static inline void P_UnArchiveSPGame(INT16 mapoverride) static void P_NetArchiveMisc(void) { - UINT32 pig = 0; INT32 i; WRITEUINT32(save_p, ARCHIVEBLOCK_MISC); @@ -3200,25 +3993,37 @@ static void P_NetArchiveMisc(void) WRITEINT16(save_p, gamemap); WRITEINT16(save_p, gamestate); - for (i = 0; i < MAXPLAYERS; i++) - pig |= (playeringame[i] != 0)< NUM_LUABANKS) + return false; + for (i = 0; i < banksinuse; i++) + luabanks[i] = READINT32(save_p); + if (READUINT8(save_p) != 0x1d) + return false; + } + case 0x1d: + break; + default: + return false; + } + + return true; +} + void P_SaveGame(void) { P_ArchiveMisc(); P_ArchivePlayer(); - - WRITEUINT8(save_p, 0x1d); // consistency marker + P_ArchiveLuabanksAndConsistency(); } void P_SaveNetGame(void) @@ -3344,15 +4196,15 @@ void P_SaveNetGame(void) P_NetArchiveMisc(); // Assign the mobjnumber for pointer tracking - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 == (actionf_p1)P_MobjThinker) - { - mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) - continue; - mobj->mobjnum = i++; - } + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mobj = (mobj_t *)th; + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + continue; + mobj->mobjnum = i++; } P_NetArchivePlayers(); @@ -3364,12 +4216,11 @@ void P_SaveNetGame(void) #endif P_NetArchiveThinkers(); P_NetArchiveSpecials(); + P_NetArchiveColormaps(); } -#ifdef HAVE_BLUA LUA_Archive(); -#endif - WRITEUINT8(save_p, 0x1d); // consistency marker + P_ArchiveLuabanksAndConsistency(); } boolean P_LoadGame(INT16 mapoverride) @@ -3381,8 +4232,7 @@ boolean P_LoadGame(INT16 mapoverride) P_UnArchiveSPGame(mapoverride); P_UnArchivePlayer(); - // Savegame end marker - if (READUINT8(save_p) != 0x1d) + if (!P_UnArchiveLuabanksAndConsistency()) return false; // Only do this after confirming savegame is ok @@ -3406,12 +4256,11 @@ boolean P_LoadNetGame(void) #endif P_NetUnArchiveThinkers(); P_NetUnArchiveSpecials(); + P_NetUnArchiveColormaps(); P_RelinkPointers(); P_FinishMobjs(); } -#ifdef HAVE_BLUA LUA_UnArchive(); -#endif // This is stupid and hacky, but maybe it'll work! P_SetRandSeed(P_GetInitSeed()); @@ -3422,5 +4271,5 @@ boolean P_LoadNetGame(void) // precipitation when loading a netgame save. Instead, precip has to be spawned here. // This is done in P_NetUnArchiveSpecials now. - return READUINT8(save_p) == 0x1d; + return P_UnArchiveLuabanksAndConsistency(); } diff --git a/src/p_saveg.h b/src/p_saveg.h index 0992f1185..012e7023b 100644 --- a/src/p_saveg.h +++ b/src/p_saveg.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -30,14 +30,13 @@ mobj_t *P_FindNewPosition(UINT32 oldposition); typedef struct { - UINT8 skincolor; UINT8 skin; UINT8 botskin; - UINT8 botcolor; INT32 score; INT32 lives; INT32 continues; UINT16 emeralds; + UINT8 numgameovers; } savedata_t; extern savedata_t savedata; diff --git a/src/p_setup.c b/src/p_setup.c index 5e1355981..b3b86886f 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,7 +27,8 @@ #include "i_system.h" #include "r_data.h" -#include "r_things.h" +#include "r_things.h" // for R_AddSpriteDefs +#include "r_patch.h" #include "r_sky.h" #include "r_draw.h" @@ -56,8 +57,9 @@ #include "filesrch.h" // refreshdirmenu -// wipes -#include "f_finale.h" +#include "lua_hud.h" // level title + +#include "f_finale.h" // wipes #include "md5.h" // map MD5 @@ -65,19 +67,22 @@ #include "lua_script.h" #include "lua_hook.h" -#if defined (_WIN32) || defined (_WIN32_WCE) +#ifdef _WIN32 #include #include #endif #ifdef HWRENDER #include "hardware/hw_main.h" #include "hardware/hw_light.h" +#include "hardware/hw_model.h" #endif #ifdef ESLOPE #include "p_slopes.h" #endif +#include "fastcmp.h" // textmap parsing + // // Map MD5, calculated on level load. // Sent to clients in PT_SERVERINFO. @@ -98,8 +103,14 @@ node_t *nodes; line_t *lines; side_t *sides; mapthing_t *mapthings; +sector_t *spawnsectors; +line_t *spawnlines; +side_t *spawnsides; INT32 numstarposts; +UINT16 bossdisabled; +boolean stoppedclock; boolean levelloading; +UINT8 levelfadecol; // BLOCKMAP // Created from axis aligned bounding box @@ -162,6 +173,33 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) I_Error("Invalid or corrupt map.\nLook in log file or text console for technical details."); } +/** Sets a header's flickies to be equivalent to the original Freed Animals + * + * \param i The header to set flickies for + */ +void P_SetDemoFlickies(INT16 i) +{ + mapheaderinfo[i]->numFlickies = 5; + mapheaderinfo[i]->flickies = Z_Realloc(mapheaderinfo[i]->flickies, 5*sizeof(mobjtype_t), PU_STATIC, NULL); + mapheaderinfo[i]->flickies[0] = MT_FLICKY_02/*MT_BUNNY*/; + mapheaderinfo[i]->flickies[1] = MT_FLICKY_01/*MT_BIRD*/; + mapheaderinfo[i]->flickies[2] = MT_FLICKY_12/*MT_MOUSE*/; + mapheaderinfo[i]->flickies[3] = MT_FLICKY_11/*MT_COW*/; + mapheaderinfo[i]->flickies[4] = MT_FLICKY_03/*MT_CHICKEN*/; +} + +/** Clears a header's flickies + * + * \param i The header to clear flickies for + */ +void P_DeleteFlickies(INT16 i) +{ + if (mapheaderinfo[i]->flickies) + Z_Free(mapheaderinfo[i]->flickies); + mapheaderinfo[i]->flickies = NULL; + mapheaderinfo[i]->numFlickies = 0; +} + #define NUMLAPS_DEFAULT 4 /** Clears the data from a single map header. @@ -172,68 +210,56 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) static void P_ClearSingleMapHeaderInfo(INT16 i) { const INT16 num = (INT16)(i-1); - DEH_WriteUndoline("LEVELNAME", mapheaderinfo[num]->lvlttl, UNDO_NONE); mapheaderinfo[num]->lvlttl[0] = '\0'; - DEH_WriteUndoline("SUBTITLE", mapheaderinfo[num]->subttl, UNDO_NONE); + mapheaderinfo[num]->selectheading[0] = '\0'; mapheaderinfo[num]->subttl[0] = '\0'; - DEH_WriteUndoline("ACT", va("%d", mapheaderinfo[num]->actnum), UNDO_NONE); + mapheaderinfo[num]->ltzzpatch[0] = '\0'; + mapheaderinfo[num]->ltzztext[0] = '\0'; + mapheaderinfo[num]->ltactdiamond[0] = '\0'; mapheaderinfo[num]->actnum = 0; - DEH_WriteUndoline("TYPEOFLEVEL", va("%d", mapheaderinfo[num]->typeoflevel), UNDO_NONE); mapheaderinfo[num]->typeoflevel = 0; - DEH_WriteUndoline("NEXTLEVEL", va("%d", mapheaderinfo[num]->nextlevel), UNDO_NONE); mapheaderinfo[num]->nextlevel = (INT16)(i + 1); - DEH_WriteUndoline("MUSIC", mapheaderinfo[num]->musname, UNDO_NONE); + mapheaderinfo[num]->startrings = 0; + mapheaderinfo[num]->keywords[0] = '\0'; snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); mapheaderinfo[num]->musname[6] = 0; - DEH_WriteUndoline("MUSICTRACK", va("%d", mapheaderinfo[num]->mustrack), UNDO_NONE); mapheaderinfo[num]->mustrack = 0; - DEH_WriteUndoline("FORCECHARACTER", va("%d", mapheaderinfo[num]->forcecharacter), UNDO_NONE); + mapheaderinfo[num]->muspos = 0; + mapheaderinfo[num]->musinterfadeout = 0; + mapheaderinfo[num]->musintername[0] = '\0'; + mapheaderinfo[num]->muspostbossname[6] = 0; + mapheaderinfo[num]->muspostbosstrack = 0; + mapheaderinfo[num]->muspostbosspos = 0; + mapheaderinfo[num]->muspostbossfadein = 0; + mapheaderinfo[num]->musforcereset = -1; mapheaderinfo[num]->forcecharacter[0] = '\0'; - DEH_WriteUndoline("WEATHER", va("%d", mapheaderinfo[num]->weather), UNDO_NONE); mapheaderinfo[num]->weather = 0; - DEH_WriteUndoline("SKYNUM", va("%d", mapheaderinfo[num]->skynum), UNDO_NONE); mapheaderinfo[num]->skynum = 1; - DEH_WriteUndoline("SKYBOXSCALEX", va("%d", mapheaderinfo[num]->skybox_scalex), UNDO_NONE); mapheaderinfo[num]->skybox_scalex = 16; - DEH_WriteUndoline("SKYBOXSCALEY", va("%d", mapheaderinfo[num]->skybox_scaley), UNDO_NONE); mapheaderinfo[num]->skybox_scaley = 16; - DEH_WriteUndoline("SKYBOXSCALEZ", va("%d", mapheaderinfo[num]->skybox_scalez), UNDO_NONE); mapheaderinfo[num]->skybox_scalez = 16; - DEH_WriteUndoline("INTERSCREEN", mapheaderinfo[num]->interscreen, UNDO_NONE); mapheaderinfo[num]->interscreen[0] = '#'; - DEH_WriteUndoline("RUNSOC", mapheaderinfo[num]->runsoc, UNDO_NONE); mapheaderinfo[num]->runsoc[0] = '#'; - DEH_WriteUndoline("SCRIPTNAME", mapheaderinfo[num]->scriptname, UNDO_NONE); mapheaderinfo[num]->scriptname[0] = '#'; - DEH_WriteUndoline("PRECUTSCENENUM", va("%d", mapheaderinfo[num]->precutscenenum), UNDO_NONE); mapheaderinfo[num]->precutscenenum = 0; - DEH_WriteUndoline("CUTSCENENUM", va("%d", mapheaderinfo[num]->cutscenenum), UNDO_NONE); mapheaderinfo[num]->cutscenenum = 0; - DEH_WriteUndoline("COUNTDOWN", va("%d", mapheaderinfo[num]->countdown), UNDO_NONE); mapheaderinfo[num]->countdown = 0; - DEH_WriteUndoline("PALLETE", va("%u", mapheaderinfo[num]->palette), UNDO_NONE); mapheaderinfo[num]->palette = UINT16_MAX; - DEH_WriteUndoline("NUMLAPS", va("%u", mapheaderinfo[num]->numlaps), UNDO_NONE); mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT; - DEH_WriteUndoline("UNLOCKABLE", va("%s", mapheaderinfo[num]->unlockrequired), UNDO_NONE); mapheaderinfo[num]->unlockrequired = -1; - DEH_WriteUndoline("LEVELSELECT", va("%d", mapheaderinfo[num]->levelselect), UNDO_NONE); mapheaderinfo[num]->levelselect = 0; - DEH_WriteUndoline("BONUSTYPE", va("%d", mapheaderinfo[num]->bonustype), UNDO_NONE); mapheaderinfo[num]->bonustype = 0; - DEH_WriteUndoline("SAVEOVERRIDE", va("%d", mapheaderinfo[num]->saveoverride), UNDO_NONE); - mapheaderinfo[num]->saveoverride = SAVE_DEFAULT; - DEH_WriteUndoline("LEVELFLAGS", va("%d", mapheaderinfo[num]->levelflags), UNDO_NONE); + mapheaderinfo[num]->maxbonuslives = -1; mapheaderinfo[num]->levelflags = 0; - DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE); mapheaderinfo[num]->menuflags = 0; - // TODO grades support for delfile (pfft yeah right) +#if 1 // equivalent to "FlickyList = DEMO" + P_SetDemoFlickies(num); +#else // equivalent to "FlickyList = NONE" + P_DeleteFlickies(num); +#endif P_DeleteGrades(num); - // an even further impossibility, delfile custom opts support mapheaderinfo[num]->customopts = NULL; mapheaderinfo[num]->numCustomOptions = 0; - - DEH_WriteUndoline(va("# uload for map %d", i), NULL, UNDO_DONE); } /** Allocates a new map-header structure. @@ -245,6 +271,7 @@ void P_AllocMapHeader(INT16 i) if (!mapheaderinfo[i]) { mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL); + mapheaderinfo[i]->flickies = NULL; mapheaderinfo[i]->grades = NULL; } P_ClearSingleMapHeaderInfo(i + 1); @@ -347,175 +374,6 @@ UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) return mapheaderinfo[map-1]->grades[mare].grade[grade-1]; } -/** Loads the vertexes for a level. - * - * \param lump VERTEXES lump number. - * \sa ML_VERTEXES - */ - -static inline void P_LoadRawVertexes(UINT8 *data, size_t i) -{ - mapvertex_t *ml; - vertex_t *li; - - numvertexes = i / sizeof (mapvertex_t); - - if (numvertexes <= 0) - I_Error("Level has no vertices"); // instead of crashing - - // Allocate zone memory for buffer. - vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL); - - ml = (mapvertex_t *)data; - li = vertexes; - - // Copy and convert vertex coordinates, internal representation as fixed. - for (i = 0; i < numvertexes; i++, li++, ml++) - { - li->x = SHORT(ml->x)<y = SHORT(ml->y)<v2->x - seg->v1->x)>>1; - INT64 dy = (seg->v2->y - seg->v1->y)>>1; - return FixedHypot(dx, dy)<<1; -} - -#ifdef HWRENDER -/** Computes the length of a seg as a float. - * This is needed for OpenGL. - * - * \param seg Seg to compute length for. - * \return Length as a float. - */ -static inline float P_SegLengthFloat(seg_t *seg) -{ - float dx, dy; - - // make a vector (start at origin) - dx = FIXED_TO_FLOAT(seg->v2->x - seg->v1->x); - dy = FIXED_TO_FLOAT(seg->v2->y - seg->v1->y); - - return (float)hypot(dx, dy); -} -#endif - -/** Loads the SEGS resource from a level. - * - * \param lump Lump number of the SEGS resource. - * \sa ::ML_SEGS - */ -static void P_LoadRawSegs(UINT8 *data, size_t i) -{ - INT32 linedef, side; - mapseg_t *ml; - seg_t *li; - line_t *ldef; - - numsegs = i / sizeof (mapseg_t); - if (numsegs <= 0) - I_Error("Level has no segs"); // instead of crashing - segs = Z_Calloc(numsegs * sizeof (*segs), PU_LEVEL, NULL); - - ml = (mapseg_t *)data; - li = segs; - for (i = 0; i < numsegs; i++, li++, ml++) - { - li->v1 = &vertexes[SHORT(ml->v1)]; - li->v2 = &vertexes[SHORT(ml->v2)]; - - li->length = P_SegLength(li); -#ifdef HWRENDER - if (rendermode == render_opengl) - { - li->flength = P_SegLengthFloat(li); - //Hurdler: 04/12/2000: for now, only used in hardware mode - li->lightmaps = NULL; // list of static lightmap for this seg - } - li->pv1 = li->pv2 = NULL; -#endif - - li->angle = (SHORT(ml->angle))<offset = (SHORT(ml->offset))<linedef); - ldef = &lines[linedef]; - li->linedef = ldef; - li->side = side = SHORT(ml->side); - li->sidedef = &sides[ldef->sidenum[side]]; - li->frontsector = sides[ldef->sidenum[side]].sector; - if (ldef-> flags & ML_TWOSIDED) - li->backsector = sides[ldef->sidenum[side^1]].sector; - else - li->backsector = 0; - - li->numlights = 0; - li->rlights = NULL; - } -} - -static void P_LoadSegs(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSegs(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - - -/** Loads the SSECTORS resource from a level. - * - * \param lump Lump number of the SSECTORS resource. - * \sa ::ML_SSECTORS - */ -static inline void P_LoadRawSubsectors(void *data, size_t i) -{ - mapsubsector_t *ms; - subsector_t *ss; - - numsubsectors = i / sizeof (mapsubsector_t); - if (numsubsectors <= 0) - I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)"); - ss = subsectors = Z_Calloc(numsubsectors * sizeof (*subsectors), PU_LEVEL, NULL); - - ms = (mapsubsector_t *)data; - - for (i = 0; i < numsubsectors; i++, ss++, ms++) - { - ss->sector = NULL; - ss->numlines = SHORT(ms->numsegs); - ss->firstline = SHORT(ms->firstseg); -#ifdef FLOORSPLATS - ss->splats = NULL; -#endif - ss->validcount = 0; - } -} - -static void P_LoadSubsectors(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSubsectors(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - -// -// P_LoadSectors -// - // // levelflats // @@ -523,60 +381,131 @@ static void P_LoadSubsectors(lumpnum_t lumpnum) size_t numlevelflats; levelflat_t *levelflats; +levelflat_t *foundflats; //SoM: Other files want this info. size_t P_PrecacheLevelFlats(void) { lumpnum_t lump; - size_t i, flatmemory = 0; + size_t i; //SoM: 4/18/2000: New flat code to make use of levelflats. + flatmemory = 0; for (i = 0; i < numlevelflats; i++) { - lump = levelflats[i].lumpnum; - if (devparm) - flatmemory += W_LumpLength(lump); - R_GetFlat(lump); + if (levelflats[i].type == LEVELFLAT_FLAT) + { + lump = levelflats[i].u.flat.lumpnum; + if (devparm) + flatmemory += W_LumpLength(lump); + R_GetFlat(lump); + } } return flatmemory; } -// help function for P_LoadSectors, find a flat in the active wad files, -// allocate an id for it, and set the levelflat (to speedup search) -// -INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) +/* +levelflat refers to an array of level flats, +or NULL if we want to allocate it now. +*/ +static INT32 +Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) { - size_t i; - - // - // first scan through the already found flats - // - for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) - break; - - // that flat was already found in the level, return the id - if (i == numlevelflats) - { - // store the name - strlcpy(levelflat->name, flatname, sizeof (levelflat->name)); - strupr(levelflat->name); - - // store the flat lump number - levelflat->lumpnum = R_GetFlatNumForName(flatname); - -#ifndef ZDEBUG - CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); +#ifndef NO_PNG_LUMPS + UINT8 buffer[8]; #endif - numlevelflats++; + lumpnum_t flatnum; + int texturenum; - if (numlevelflats >= MAXLEVELFLATS) - I_Error("Too many flats in level\n"); + size_t i; + + // Scan through the already found flats, return if it matches. + for (i = 0; i < numlevelflats; i++) + { + if (strnicmp(levelflat[i].name, flatname, 8) == 0) + return i; } - // level flat id - return (INT32)i; + if (resize) + { + // allocate new flat memory + levelflats = Z_Realloc(levelflats, (numlevelflats + 1) * sizeof(*levelflats), PU_LEVEL, NULL); + levelflat = levelflats + numlevelflats; + } + else + { + if (numlevelflats >= MAXLEVELFLATS) + I_Error("Too many flats in level\n"); + + levelflat += numlevelflats; + } + + // Store the name. + strlcpy(levelflat->name, flatname, sizeof (levelflat->name)); + strupr(levelflat->name); + + /* If we can't find a flat, try looking for a texture! */ + if (( flatnum = R_GetFlatNumForName(flatname) ) == LUMPERROR) + { + if (( texturenum = R_CheckTextureNumForName(flatname) ) == -1) + { + // check for REDWALL + if (( texturenum = R_CheckTextureNumForName("REDWALL") ) != -1) + goto texturefound; + // check for REDFLR + else if (( flatnum = R_GetFlatNumForName("REDFLR") ) != LUMPERROR) + goto flatfound; + // nevermind + levelflat->type = LEVELFLAT_NONE; + } + else + { +texturefound: + levelflat->type = LEVELFLAT_TEXTURE; + levelflat->u.texture. num = texturenum; + levelflat->u.texture.lastnum = texturenum; + /* start out unanimated */ + levelflat->u.texture.basenum = -1; + } + } + else + { +flatfound: + /* This could be a flat, patch, or PNG. */ + if (R_CheckIfPatch(flatnum)) + levelflat->type = LEVELFLAT_PATCH; + else + { +#ifndef NO_PNG_LUMPS + /* + Only need eight bytes for PNG headers. + FIXME: Put this elsewhere. + */ + W_ReadLumpHeader(flatnum, buffer, 8, 0); + if (R_IsLumpPNG(buffer, W_LumpLength(flatnum))) + levelflat->type = LEVELFLAT_PNG; + else +#endif/*NO_PNG_LUMPS*/ + levelflat->type = LEVELFLAT_FLAT;/* phew */ + } + + levelflat->u.flat. lumpnum = flatnum; + levelflat->u.flat.baselumpnum = LUMPERROR; + } + +#ifndef ZDEBUG + CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); +#endif + + return ( numlevelflats++ ); +} + +// Auxiliary function. Find a flat in the active wad files, +// allocate an id for it, and set the levelflat (to speedup search) +INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) +{ + return Ploadflat(levelflat, flatname, false); } // help function for Lua and $$$.sav reading @@ -585,39 +514,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // INT32 P_AddLevelFlatRuntime(const char *flatname) { - size_t i; - levelflat_t *levelflat = levelflats; - - // - // first scan through the already found flats - // - for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) - break; - - // that flat was already found in the level, return the id - if (i == numlevelflats) - { - // allocate new flat memory - levelflats = Z_Realloc(levelflats, (numlevelflats + 1) * sizeof(*levelflats), PU_LEVEL, NULL); - levelflat = levelflats+i; - - // store the name - strlcpy(levelflat->name, flatname, sizeof (levelflat->name)); - strupr(levelflat->name); - - // store the flat lump number - levelflat->lumpnum = R_GetFlatNumForName(flatname); - -#ifndef ZDEBUG - CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); -#endif - - numlevelflats++; - } - - // level flat id - return (INT32)i; + return Ploadflat(levelflats, flatname, true); } // help function for $$$.sav checking @@ -642,162 +539,9 @@ INT32 P_CheckLevelFlat(const char *flatname) return (INT32)i; } -// Sets up the ingame sectors structures. -// Lumpnum is the lumpnum of a SECTORS lump. -static void P_LoadRawSectors(UINT8 *data, size_t i) -{ - mapsector_t *ms; - sector_t *ss; - levelflat_t *foundflats; - - // We count how many sectors we got. - numsectors = i / sizeof (mapsector_t); - if (numsectors <= 0) - I_Error("Level has no sectors"); - - // Allocate as much memory as we need into the global sectors table. - sectors = Z_Calloc(numsectors*sizeof (*sectors), PU_LEVEL, NULL); - - // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. - //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty - foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats)); - if (foundflats == NULL) - I_Error("Ran out of memory while loading sectors\n"); - - numlevelflats = 0; - - // For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss. - ms = (mapsector_t *)data; - ss = sectors; - for (i = 0; i < numsectors; i++, ss++, ms++) - { - ss->floorheight = SHORT(ms->floorheight)<ceilingheight = SHORT(ms->ceilingheight)<floorpic = P_AddLevelFlat(ms->floorpic, foundflats); - ss->ceilingpic = P_AddLevelFlat(ms->ceilingpic, foundflats); - - ss->lightlevel = SHORT(ms->lightlevel); - ss->special = SHORT(ms->special); - ss->tag = SHORT(ms->tag); - ss->nexttag = ss->firsttag = -1; - ss->spawn_nexttag = ss->spawn_firsttag = -1; - - memset(&ss->soundorg, 0, sizeof(ss->soundorg)); - ss->validcount = 0; - - ss->thinglist = NULL; - ss->touching_thinglist = NULL; - ss->preciplist = NULL; - ss->touching_preciplist = NULL; - - ss->floordata = NULL; - ss->ceilingdata = NULL; - ss->lightingdata = NULL; - - ss->linecount = 0; - ss->lines = NULL; - - ss->heightsec = -1; - ss->camsec = -1; - ss->floorlightsec = -1; - ss->ceilinglightsec = -1; - ss->crumblestate = 0; - ss->ffloors = NULL; - ss->lightlist = NULL; - ss->numlights = 0; - ss->attached = NULL; - ss->attachedsolid = NULL; - ss->numattached = 0; - ss->maxattached = 1; - ss->moved = true; - - ss->extra_colormap = NULL; - - ss->floor_xoffs = ss->ceiling_xoffs = ss->floor_yoffs = ss->ceiling_yoffs = 0; - ss->spawn_flr_xoffs = ss->spawn_ceil_xoffs = ss->spawn_flr_yoffs = ss->spawn_ceil_yoffs = 0; - ss->floorpic_angle = ss->ceilingpic_angle = 0; - ss->spawn_flrpic_angle = ss->spawn_ceilpic_angle = 0; - ss->bottommap = ss->midmap = ss->topmap = -1; - ss->gravity = NULL; - ss->cullheight = NULL; - ss->verticalflip = false; - ss->flags = 0; - ss->flags |= SF_FLIPSPECIAL_FLOOR; - - ss->floorspeed = 0; - ss->ceilspeed = 0; - -#ifdef HWRENDER // ----- for special tricks with HW renderer ----- - ss->pseudoSector = false; - ss->virtualFloor = false; - ss->virtualCeiling = false; - ss->sectorLines = NULL; - ss->stackList = NULL; - ss->lineoutLength = -1.0l; -#endif // ----- end special tricks ----- - } - - // set the sky flat num - skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); - - // copy table for global usage - levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); - free(foundflats); - - // search for animated flats and set up - P_SetupLevelFlatAnims(); -} - -static void P_LoadSectors(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSectors(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - -// -// P_LoadNodes -// -static void P_LoadRawNodes(UINT8 *data, size_t i) -{ - UINT8 j, k; - mapnode_t *mn; - node_t *no; - - numnodes = i / sizeof (mapnode_t); - if (numnodes <= 0) - I_Error("Level has no nodes"); - nodes = Z_Calloc(numnodes * sizeof (*nodes), PU_LEVEL, NULL); - - mn = (mapnode_t *)data; - no = nodes; - - for (i = 0; i < numnodes; i++, no++, mn++) - { - no->x = SHORT(mn->x)<y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j] = SHORT(mn->children[j]); - for (k = 0; k < 4; k++) - no->bbox[j][k] = SHORT(mn->bbox[j][k])<next) + // scan the thinkers to find rings/spheres/hoops to unset + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo = (mobj_t *)th; @@ -827,7 +571,9 @@ void P_ReloadRings(void) } continue; } - if (!(mo->type == MT_RING || mo->type == MT_NIGHTSWING || mo->type == MT_COIN || mo->type == MT_BLUEBALL)) + if (!(mo->type == MT_RING || mo->type == MT_COIN + || mo->type == MT_BLUESPHERE || mo->type == MT_BOMBSPHERE + || mo->type == MT_NIGHTSCHIP || mo->type == MT_NIGHTSSTAR)) continue; // Don't auto-disintegrate things being pulled to us @@ -841,22 +587,46 @@ void P_ReloadRings(void) for (i = 0; i < nummapthings; i++, mt++) { // Notice an omission? We handle hoops differently. - if (mt->type == 300 || mt->type == 308 || mt->type == 309 - || mt->type == 1706 || (mt->type >= 600 && mt->type <= 609) - || mt->type == 1800) + if (mt->type == mobjinfo[MT_RING].doomednum || mt->type == mobjinfo[MT_COIN].doomednum + || mt->type == mobjinfo[MT_REDTEAMRING].doomednum || mt->type == mobjinfo[MT_BLUETEAMRING].doomednum + || mt->type == mobjinfo[MT_BLUESPHERE].doomednum || mt->type == mobjinfo[MT_BOMBSPHERE].doomednum) { mt->mobj = NULL; - - // Z for objects Tails 05-26-2002 - mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS) - ->sector->floorheight>>FRACBITS); - - P_SpawnHoopsAndRings (mt); + P_SetBonusTime(P_SpawnMapThing(mt)); + } + else if (mt->type >= 600 && mt->type <= 609) // Item patterns + { + mt->mobj = NULL; + P_SpawnItemPattern(mt, true); } } for (i = 0; i < numHoops; i++) { - P_SpawnHoopsAndRings(hoopsToRespawn[i]); + P_SpawnHoop(hoopsToRespawn[i]); + } +} + +void P_SwitchSpheresBonusMode(boolean bonustime) +{ + mobj_t *mo; + thinker_t *th; + + // scan the thinkers to find spheres to switch + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)th; + + if (mo->type != MT_BLUESPHERE && mo->type != MT_NIGHTSCHIP + && mo->type != MT_FLINGBLUESPHERE && mo->type != MT_FLINGNIGHTSCHIP) + continue; + + if (!mo->health) + continue; + + P_SetMobjState(mo, ((bonustime) ? mo->info->raisestate : mo->info->spawnstate)); } } @@ -923,31 +693,59 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum) } #endif -// -// P_LoadThings -// - -static void P_PrepareRawThings(UINT8 *data, size_t i) +static void P_SpawnEmeraldHunt(void) { + INT32 emer1, emer2, emer3; + INT32 timeout = 0; // keeps from getting stuck + + emer1 = emer2 = emer3 = 0; + + //increment spawn numbers because zero is valid. + emer1 = (P_RandomKey(numhuntemeralds)) + 1; + while (timeout++ < 100) + { + emer2 = (P_RandomKey(numhuntemeralds)) + 1; + + if (emer2 != emer1) + break; + } + + timeout = 0; + while (timeout++ < 100) + { + emer3 = (P_RandomKey(numhuntemeralds)) + 1; + + if (emer3 != emer2 && emer3 != emer1) + break; + } + + //decrement spawn values to the actual number because zero is valid. + if (emer1--) + P_SpawnMobj(huntemeralds[emer1]->x<y<z<x<y<z<x<y<z<x = READINT16(data); - mt->y = READINT16(data); - mt->angle = READINT16(data); - mt->type = READUINT16(data); - mt->options = READUINT16(data); - mt->extrainfo = (UINT8)(mt->type >> 12); - - mt->type &= 4095; - switch (mt->type) { case 1700: // MT_AXIS @@ -960,154 +758,32 @@ static void P_PrepareRawThings(UINT8 *data, size_t i) break; } } -} -static void P_PrepareThings(lumpnum_t lumpnum) -{ - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_PrepareRawThings(data, W_LumpLength(lumpnum)); - Z_Free(data); -} - -static void P_LoadThings(void) -{ - size_t i; - mapthing_t *mt; - - // Loading the things lump itself into memory is now handled in P_PrepareThings, above - - mt = mapthings; numhuntemeralds = 0; - for (i = 0; i < nummapthings; i++, mt++) + + for (i = 0, mt = mapthings; i < nummapthings; i++, mt++) { - sector_t *mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector; - - // Z for objects - mt->z = (INT16)( -#ifdef ESLOPE - mtsector->f_slope ? P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : -#endif - mtsector->floorheight)>>FRACBITS; - if (mt->type == 1700 // MT_AXIS || mt->type == 1701 // MT_AXISTRANSFER || mt->type == 1702) // MT_AXISTRANSFERLINE continue; // These were already spawned + if (!spawnemblems && mt->type == mobjinfo[MT_EMBLEM].doomednum) + continue; + mt->mobj = NULL; - P_SpawnMapThing(mt); + + if (mt->type >= 600 && mt->type <= 609) // item patterns + P_SpawnItemPattern(mt, false); + else if (mt->type == 1705 || mt->type == 1713) // hoops + P_SpawnHoop(mt); + else // Everything else + P_SpawnMapThing(mt); } // random emeralds for hunt if (numhuntemeralds) - { - INT32 emer1, emer2, emer3; - INT32 timeout = 0; // keeps from getting stuck - - emer1 = emer2 = emer3 = 0; - - //increment spawn numbers because zero is valid. - emer1 = (P_RandomKey(numhuntemeralds)) + 1; - while (timeout++ < 100) - { - emer2 = (P_RandomKey(numhuntemeralds)) + 1; - - if (emer2 != emer1) - break; - } - - timeout = 0; - while (timeout++ < 100) - { - emer3 = (P_RandomKey(numhuntemeralds)) + 1; - - if (emer3 != emer2 && emer3 != emer1) - break; - } - - //decrement spawn values to the actual number because zero is valid. - if (emer1) - P_SpawnMobj(huntemeralds[emer1 - 1]->x<y<z<x<y<z<x<y<z<type == 300 || mt->type == 308 || mt->type == 309 - || mt->type == 1706 || (mt->type >= 600 && mt->type <= 609) - || mt->type == 1705 || mt->type == 1713 || mt->type == 1800) - { - mt->mobj = NULL; - - // Z for objects Tails 05-26-2002 - mt->z = (INT16)(R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS) - ->sector->floorheight>>FRACBITS); - - P_SpawnHoopsAndRings (mt); - } - } -} - -static inline void P_SpawnEmblems(void) -{ - INT32 i, color; - mobj_t *emblemmobj; - - for (i = 0; i < numemblems; i++) - { - if (emblemlocations[i].level != gamemap || emblemlocations[i].type > ET_SKIN) - continue; - - emblemmobj = P_SpawnMobj(emblemlocations[i].x<= 'A' && emblemlocations[i].sprite <= 'Z'); - P_SetMobjStateNF(emblemmobj, emblemmobj->info->spawnstate + (emblemlocations[i].sprite - 'A')); - - emblemmobj->health = i+1; - color = M_GetEmblemColor(&emblemlocations[i]); - - emblemmobj->color = (UINT8)color; - - if (emblemlocations[i].collected - || (emblemlocations[i].type == ET_SKIN && emblemlocations[i].var != players[0].skin)) - { - P_UnsetThingPosition(emblemmobj); - emblemmobj->flags |= MF_NOCLIP; - emblemmobj->flags &= ~MF_SPECIAL; - emblemmobj->flags |= MF_NOBLOCKMAP; - emblemmobj->frame |= (tr_trans50<frame &= ~FF_TRANSMASK; - } -} - -static void P_SpawnSecretItems(boolean loademblems) -{ - // Now let's spawn those funky emblem things! Tails 12-08-2002 - if (netgame || multiplayer || (modifiedgame && !savemoddata)) // No cheating!! - return; - - if (loademblems) - P_SpawnEmblems(); + P_SpawnEmeraldHunt(); } // Experimental groovy write function! @@ -1153,370 +829,306 @@ void P_WriteThings(lumpnum_t lumpnum) CONS_Printf(M_GetText("newthings%d.lmp saved.\n"), gamemap); } -static void P_LoadRawLineDefs(UINT8 *data, size_t i) +// +// MAP LOADING FUNCTIONS +// + +static void P_LoadVertices(UINT8 *data) { - maplinedef_t *mld; - line_t *ld; - vertex_t *v1, *v2; + mapvertex_t *mv = (mapvertex_t *)data; + vertex_t *v = vertexes; + size_t i; - numlines = i / sizeof (maplinedef_t); - if (numlines <= 0) - I_Error("Level has no linedefs"); - lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL); + // Copy and convert vertex coordinates, internal representation as fixed. + for (i = 0; i < numvertexes; i++, v++, mv++) + { + v->x = SHORT(mv->x)<y = SHORT(mv->y)<floorzset = v->ceilingzset = false; + v->floorz = v->ceilingz = 0; + } +} + +static void P_InitializeSector(sector_t *ss) +{ + ss->nexttag = ss->firsttag = -1; + + memset(&ss->soundorg, 0, sizeof(ss->soundorg)); + + ss->validcount = 0; + + ss->thinglist = NULL; + + ss->floordata = NULL; + ss->ceilingdata = NULL; + ss->lightingdata = NULL; + ss->fadecolormapdata = NULL; + + ss->heightsec = -1; + ss->camsec = -1; + + ss->floorlightsec = ss->ceilinglightsec = -1; + ss->crumblestate = 0; + + ss->touching_thinglist = NULL; + + ss->linecount = 0; + ss->lines = NULL; + ss->tagline = NULL; + + ss->ffloors = NULL; + ss->attached = NULL; + ss->attachedsolid = NULL; + ss->numattached = 0; + ss->maxattached = 1; + ss->lightlist = NULL; + ss->numlights = 0; + ss->moved = true; + + ss->extra_colormap = NULL; + +#ifdef HWRENDER // ----- for special tricks with HW renderer ----- + ss->pseudoSector = false; + ss->virtualFloor = false; + ss->virtualFloorheight = 0; + ss->virtualCeiling = false; + ss->virtualCeilingheight = 0; + ss->sectorLines = NULL; + ss->stackList = NULL; + ss->lineoutLength = -1.0l; +#endif // ----- end special tricks ----- + + ss->gravity = NULL; + ss->verticalflip = false; + ss->flags = SF_FLIPSPECIAL_FLOOR; + + ss->cullheight = NULL; + + ss->floorspeed = ss->ceilspeed = 0; + + ss->preciplist = NULL; + ss->touching_preciplist = NULL; + +#ifdef ESLOPE + ss->f_slope = NULL; + ss->c_slope = NULL; + ss->hasslope = false; +#endif + + ss->spawn_lightlevel = ss->lightlevel; + + ss->spawn_extra_colormap = NULL; +} + +static void P_LoadSectors(UINT8 *data) +{ + mapsector_t *ms = (mapsector_t *)data; + sector_t *ss = sectors; + size_t i; + + // For each counted sector, copy the sector raw data from our cache pointer ms, to the global table pointer ss. + for (i = 0; i < numsectors; i++, ss++, ms++) + { + ss->floorheight = SHORT(ms->floorheight)<ceilingheight = SHORT(ms->ceilingheight)<floorpic = P_AddLevelFlat(ms->floorpic, foundflats); + ss->ceilingpic = P_AddLevelFlat(ms->ceilingpic, foundflats); + + ss->lightlevel = SHORT(ms->lightlevel); + ss->special = SHORT(ms->special); + ss->tag = SHORT(ms->tag); + + ss->floor_xoffs = ss->floor_yoffs = 0; + ss->ceiling_xoffs = ss->ceiling_yoffs = 0; + + ss->floorpic_angle = ss->ceilingpic_angle = 0; + + P_InitializeSector(ss); + } +} + +static void P_InitializeLinedef(line_t *ld) +{ + vertex_t *v1 = ld->v1; + vertex_t *v2 = ld->v2; + UINT8 j; + + ld->dx = v2->x - v1->x; + ld->dy = v2->y - v1->y; + + ld->bbox[BOXLEFT] = min(v1->x, v2->x); + ld->bbox[BOXRIGHT] = max(v1->x, v2->x); + ld->bbox[BOXBOTTOM] = min(v1->y, v2->y); + ld->bbox[BOXTOP] = max(v1->y, v2->y); + + if (!ld->dx) + ld->slopetype = ST_VERTICAL; + else if (!ld->dy) + ld->slopetype = ST_HORIZONTAL; + else if ((ld->dy > 0) == (ld->dx > 0)) + ld->slopetype = ST_POSITIVE; + else + ld->slopetype = ST_NEGATIVE; + + ld->frontsector = ld->backsector = NULL; + + ld->validcount = 0; +#ifdef WALLSPLATS + ld->splats = NULL; +#endif + ld->firsttag = ld->nexttag = -1; +#ifdef POLYOBJECTS + ld->polyobj = NULL; +#endif + + ld->text = NULL; + ld->callcount = 0; + + // cph 2006/09/30 - fix sidedef errors right away. + // cph 2002/07/20 - these errors are fatal if not fixed, so apply them + for (j = 0; j < 2; j++) + if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides) + { + ld->sidenum[j] = 0xffff; + CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has out-of-range sidedef number\n", sizeu1((size_t)(ld - lines))); + } + + // killough 11/98: fix common wad errors (missing sidedefs): + if (ld->sidenum[0] == 0xffff) + { + ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side + // cph - print a warning about the bug + CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s missing first sidedef\n", sizeu1((size_t)(ld - lines))); + } + + if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) + { + ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side + // cph - print a warning about the bug + CONS_Debug(DBG_SETUP, "P_InitializeLinedef: Linedef %s has two-sided flag set, but no second sidedef\n", sizeu1((size_t)(ld - lines))); + } + + if (ld->sidenum[0] != 0xffff) + { + sides[ld->sidenum[0]].special = ld->special; + sides[ld->sidenum[0]].line = ld; + } + if (ld->sidenum[1] != 0xffff) + { + sides[ld->sidenum[1]].special = ld->special; + sides[ld->sidenum[1]].line = ld; + } +} + +static void P_SetLinedefV1(size_t i, UINT16 vertex_num) +{ + if (vertex_num >= numvertexes) + { + CONS_Debug(DBG_SETUP, "P_SetLinedefV1: linedef %s has out-of-range v1 num %u\n", sizeu1(i), vertex_num); + vertex_num = 0; + } + lines[i].v1 = &vertexes[vertex_num]; +} + +static void P_SetLinedefV2(size_t i, UINT16 vertex_num) +{ + if (vertex_num >= numvertexes) + { + CONS_Debug(DBG_SETUP, "P_SetLinedefV2: linedef %s has out-of-range v2 num %u\n", sizeu1(i), vertex_num); + vertex_num = 0; + } + lines[i].v2 = &vertexes[vertex_num]; +} + +static void P_LoadLinedefs(UINT8 *data) +{ + maplinedef_t *mld = (maplinedef_t *)data; + line_t *ld = lines; + size_t i; - mld = (maplinedef_t *)data; - ld = lines; for (i = 0; i < numlines; i++, mld++, ld++) { ld->flags = SHORT(mld->flags); ld->special = SHORT(mld->special); ld->tag = SHORT(mld->tag); - v1 = ld->v1 = &vertexes[SHORT(mld->v1)]; - v2 = ld->v2 = &vertexes[SHORT(mld->v2)]; - ld->dx = v2->x - v1->x; - ld->dy = v2->y - v1->y; - -#ifdef WALLSPLATS - ld->splats = NULL; -#endif - - if (!ld->dx) - ld->slopetype = ST_VERTICAL; - else if (!ld->dy) - ld->slopetype = ST_HORIZONTAL; - else if ((ld->dy > 0) == (ld->dx > 0)) - ld->slopetype = ST_POSITIVE; - else - ld->slopetype = ST_NEGATIVE; - - if (v1->x < v2->x) - { - ld->bbox[BOXLEFT] = v1->x; - ld->bbox[BOXRIGHT] = v2->x; - } - else - { - ld->bbox[BOXLEFT] = v2->x; - ld->bbox[BOXRIGHT] = v1->x; - } - - if (v1->y < v2->y) - { - ld->bbox[BOXBOTTOM] = v1->y; - ld->bbox[BOXTOP] = v2->y; - } - else - { - ld->bbox[BOXBOTTOM] = v2->y; - ld->bbox[BOXTOP] = v1->y; - } + P_SetLinedefV1(i, SHORT(mld->v1)); + P_SetLinedefV2(i, SHORT(mld->v2)); ld->sidenum[0] = SHORT(mld->sidenum[0]); ld->sidenum[1] = SHORT(mld->sidenum[1]); - { - // cph 2006/09/30 - fix sidedef errors right away. - // cph 2002/07/20 - these errors are fatal if not fixed, so apply them - UINT8 j; - - for (j=0; j < 2; j++) - { - if (ld->sidenum[j] != 0xffff && ld->sidenum[j] >= (UINT16)numsides) - { - ld->sidenum[j] = 0xffff; - CONS_Debug(DBG_SETUP, "P_LoadRawLineDefs: linedef %s has out-of-range sidedef number\n", sizeu1(numlines-i-1)); - } - } - } - - ld->frontsector = ld->backsector = NULL; - ld->validcount = 0; - ld->firsttag = ld->nexttag = -1; - ld->callcount = 0; - // killough 11/98: fix common wad errors (missing sidedefs): - - if (ld->sidenum[0] == 0xffff) - { - ld->sidenum[0] = 0; // Substitute dummy sidedef for missing right side - // cph - print a warning about the bug - CONS_Debug(DBG_SETUP, "P_LoadRawLineDefs: linedef %s missing first sidedef\n", sizeu1(numlines-i-1)); - } - - if ((ld->sidenum[1] == 0xffff) && (ld->flags & ML_TWOSIDED)) - { - ld->flags &= ~ML_TWOSIDED; // Clear 2s flag for missing left side - // cph - print a warning about the bug - CONS_Debug(DBG_SETUP, "P_LoadRawLineDefs: linedef %s has two-sided flag set, but no second sidedef\n", sizeu1(numlines-i-1)); - } - - if (ld->sidenum[0] != 0xffff && ld->special) - sides[ld->sidenum[0]].special = ld->special; - if (ld->sidenum[1] != 0xffff && ld->special) - sides[ld->sidenum[1]].special = ld->special; - -#ifdef POLYOBJECTS - ld->polyobj = NULL; -#endif + P_InitializeLinedef(ld); } } -static void P_LoadLineDefs(lumpnum_t lumpnum) +static void P_SetSidedefSector(size_t i, UINT16 sector_num) { - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawLineDefs(data, W_LumpLength(lumpnum)); - Z_Free(data); + // cph 2006/09/30 - catch out-of-range sector numbers; use sector 0 instead + if (sector_num >= numsectors) + { + CONS_Debug(DBG_SETUP, "P_SetSidedefSector: sidedef %s has out-of-range sector num %u\n", sizeu1(i), sector_num); + sector_num = 0; + } + sides[i].sector = §ors[sector_num]; } -static void P_LoadLineDefs2(void) +static void P_InitializeSidedef(side_t *sd) { - size_t i = numlines; - register line_t *ld = lines; - for (;i--;ld++) + if (!sd->line) { - ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here - ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + CONS_Debug(DBG_SETUP, "P_LoadSidedefs: Sidedef %s is not used by any linedef\n", sizeu1((size_t)(sd - sides))); + sd->line = &lines[0]; + sd->special = sd->line->special; + } + + sd->text = NULL; + sd->colormap_data = NULL; +} + +static void P_LoadSidedefs(UINT8 *data) +{ + mapsidedef_t *msd = (mapsidedef_t*)data; + side_t *sd = sides; + size_t i; + + for (i = 0; i < numsides; i++, sd++, msd++) + { + INT16 textureoffset = SHORT(msd->textureoffset); + boolean isfrontside; + + P_InitializeSidedef(sd); + + isfrontside = sd->line->sidenum[0] == i; // Repeat count for midtexture - if ((ld->flags & ML_EFFECT5) && (ld->sidenum[1] != 0xffff)) + if (((sd->line->flags & (ML_TWOSIDED|ML_EFFECT5)) == (ML_TWOSIDED|ML_EFFECT5)) + && !(sd->special >= 300 && sd->special < 500)) // exempt linedef exec specials { - sides[ld->sidenum[0]].repeatcnt = (INT16)(((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) >> 12); - sides[ld->sidenum[0]].textureoffset = (((unsigned)sides[ld->sidenum[0]].textureoffset >> FRACBITS) & 2047) << FRACBITS; - sides[ld->sidenum[1]].repeatcnt = (INT16)(((unsigned)sides[ld->sidenum[1]].textureoffset >> FRACBITS) >> 12); - sides[ld->sidenum[1]].textureoffset = (((unsigned)sides[ld->sidenum[1]].textureoffset >> FRACBITS) & 2047) << FRACBITS; + sd->repeatcnt = (INT16)(((UINT16)textureoffset) >> 12); + sd->textureoffset = (((UINT16)textureoffset) & 2047) << FRACBITS; } - - // Compile linedef 'text' from both sidedefs 'text' for appropriate specials. - switch(ld->special) + else { - case 443: // Calls a named Lua function - if (sides[ld->sidenum[0]].text) - { - size_t len = strlen(sides[ld->sidenum[0]].text)+1; - if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) - len += strlen(sides[ld->sidenum[1]].text); - ld->text = Z_Malloc(len, PU_LEVEL, NULL); - M_Memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1); - if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) - M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); - } - break; + sd->repeatcnt = 0; + sd->textureoffset = textureoffset << FRACBITS; } - } - - // Optimize sidedefs - if (M_CheckParm("-compress")) - { - side_t *newsides; - size_t numnewsides = 0; - size_t z; - - for (i = 0; i < numsides; i++) - { - size_t j, k; - if (sides[i].sector == NULL) - continue; - - for (k = numlines, ld = lines; k--; ld++) - { - if (ld->sidenum[0] == i) - ld->sidenum[0] = (UINT16)numnewsides; - - if (ld->sidenum[1] == i) - ld->sidenum[1] = (UINT16)numnewsides; - } - - for (j = i+1; j < numsides; j++) - { - if (sides[j].sector == NULL) - continue; - - if (!memcmp(&sides[i], &sides[j], sizeof(side_t))) - { - // Find the linedefs that belong to this one - for (k = numlines, ld = lines; k--; ld++) - { - if (ld->sidenum[0] == j) - ld->sidenum[0] = (UINT16)numnewsides; - - if (ld->sidenum[1] == j) - ld->sidenum[1] = (UINT16)numnewsides; - } - sides[j].sector = NULL; // Flag for deletion - } - } - numnewsides++; - } - - // We're loading crap into this block anyhow, so no point in zeroing it out. - newsides = Z_Malloc(numnewsides * sizeof(*newsides), PU_LEVEL, NULL); - - // Copy the sides to their new block of memory. - for (i = 0, z = 0; i < numsides; i++) - { - if (sides[i].sector != NULL) - M_Memcpy(&newsides[z++], &sides[i], sizeof(side_t)); - } - - CONS_Debug(DBG_SETUP, "Old sides is %s, new sides is %s\n", sizeu1(numsides), sizeu1(numnewsides)); - - Z_Free(sides); - sides = newsides; - numsides = numnewsides; - } -} - - - -static inline void P_LoadRawSideDefs(size_t i) -{ - numsides = i / sizeof (mapsidedef_t); - if (numsides <= 0) - I_Error("Level has no sidedefs"); - sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL); -} - -static inline void P_LoadSideDefs(lumpnum_t lumpnum) -{ - P_LoadRawSideDefs(W_LumpLength(lumpnum)); -} - - -static void P_LoadRawSideDefs2(void *data) -{ - UINT16 i; - INT32 num; - - for (i = 0; i < numsides; i++) - { - register mapsidedef_t *msd = (mapsidedef_t *)data + i; - register side_t *sd = sides + i; - register sector_t *sec; - - sd->textureoffset = SHORT(msd->textureoffset)<rowoffset = SHORT(msd->rowoffset)<sector); + P_SetSidedefSector(i, SHORT(msd->sector)); - if (sector_num >= numsectors) - { - CONS_Debug(DBG_SETUP, "P_LoadRawSideDefs2: sidedef %u has out-of-range sector num %u\n", i, sector_num); - sector_num = 0; - } - sd->sector = sec = §ors[sector_num]; - } - - // refined to allow colormaps to work as wall textures if invalid as colormaps - // but valid as textures. - - sd->sector = sec = §ors[SHORT(msd->sector)]; - - // Colormaps! + // Special info stored in texture fields! switch (sd->special) { - case 63: // variable colormap via 242 linedef case 606: //SoM: 4/4/2000: Just colormap transfer + case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 + case 455: // Fade colormaps! mazmazz 9/12/2018 (:flag_us:) // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. - if (rendermode == render_soft || rendermode == render_none) - { - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') - { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#ifdef HWRENDER - else - { - // for now, full support of toptexture only - if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) - { - char *col; - - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; -#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) -#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - sec->extra_colormap = &extra_colormaps[sec->midmap]; - - if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - { - col = msd->toptexture; - - sec->extra_colormap->rgba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); - - // alpha - if (msd->toptexture[7]) - sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->rgba += (25 << 24); - } - else - sec->extra_colormap->rgba = 0; - - if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) - { - col = msd->bottomtexture; - - sec->extra_colormap->fadergba = - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0) + - (HEX2INT(col[3]) << 12) + (HEX2INT(col[4]) << 8) + - (HEX2INT(col[5]) << 20) + (HEX2INT(col[6]) << 16); - - // alpha - if (msd->bottomtexture[7]) - sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->fadergba += (25 << 24); - } - else - sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) -#undef ALPHA2INT -#undef HEX2INT - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#endif + sd->colormap_data = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; + break; case 413: // Change music { @@ -1527,19 +1139,32 @@ static void P_LoadRawSideDefs2(void *data) { M_Memcpy(process,msd->bottomtexture,8); process[8] = '\0'; - sd->bottomtexture = get_number(process)-1; + sd->bottomtexture = get_number(process); } - M_Memcpy(process,msd->toptexture,8); - process[8] = '\0'; - sd->text = Z_Malloc(7, PU_LEVEL, NULL); - // If they type in O_ or D_ and their music name, just shrug, - // then copy the rest instead. - if ((process[0] == 'O' || process[0] == 'D') && process[7]) - M_Memcpy(sd->text, process+2, 6); - else // Assume it's a proper music name. - M_Memcpy(sd->text, process, 6); - sd->text[6] = 0; + if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') + { + M_Memcpy(process,msd->midtexture,8); + process[8] = '\0'; + sd->midtexture = get_number(process); + } + + sd->text = Z_Malloc(7, PU_LEVEL, NULL); + if (isfrontside && !(msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')) + { + M_Memcpy(process,msd->toptexture,8); + process[8] = '\0'; + + // If they type in O_ or D_ and their music name, just shrug, + // then copy the rest instead. + if ((process[0] == 'O' || process[0] == 'D') && process[7]) + M_Memcpy(sd->text, process+2, 6); + else // Assume it's a proper music name. + M_Memcpy(sd->text, process, 6); + sd->text[6] = 0; + } + else + sd->text[0] = 0; break; } @@ -1563,6 +1188,7 @@ static void P_LoadRawSideDefs2(void *data) case 425: // Calls P_SetMobjState on calling mobj case 434: // Custom Power case 442: // Calls P_SetMobjState on mobjs of a given type in the tagged sectors + case 461: // Spawns an object on the map based on texture offsets { char process[8*3+1]; memset(process,0,8*3+1); @@ -1579,7 +1205,11 @@ static void P_LoadRawSideDefs2(void *data) break; } + case 331: // Trigger linedef executor: Skin - Continuous + case 332: // Trigger linedef executor: Skin - Each time + case 333: // Trigger linedef executor: Skin - Once case 443: // Calls a named Lua function + case 459: // Control text prompt (named tag) { char process[8*3+1]; memset(process,0,8*3+1); @@ -1597,6 +1227,20 @@ static void P_LoadRawSideDefs2(void *data) break; } + case 259: // Custom FOF + if (!isfrontside) + { + if ((msd->toptexture[0] >= '0' && msd->toptexture[0] <= '9') + || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'F')) + sd->toptexture = axtoi(msd->toptexture); + else + I_Error("Custom FOF (tag %d) needs a value in the linedef's back side upper texture field.", sd->line->tag); + + sd->midtexture = R_TextureNumForName(msd->midtexture); + sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); + break; + } + // FALLTHRU default: // normal cases if (msd->toptexture[0] == '#') { @@ -1614,17 +1258,1011 @@ static void P_LoadRawSideDefs2(void *data) break; } } - R_ClearTextureNumCache(true); } -// Delay loading texture names until after loaded linedefs. -static void P_LoadSideDefs2(lumpnum_t lumpnum) +static void P_LoadThings(UINT8 *data) { - UINT8 *data = W_CacheLumpNum(lumpnum, PU_STATIC); - P_LoadRawSideDefs2(data); - Z_Free(data); + mapthing_t *mt; + size_t i; + + for (i = 0, mt = mapthings; i < nummapthings; i++, mt++) + { + mt->x = READINT16(data); + mt->y = READINT16(data); + + mt->angle = READINT16(data); + mt->type = READUINT16(data); + mt->options = READUINT16(data); + mt->extrainfo = (UINT8)(mt->type >> 12); + + mt->type &= 4095; + + if (mt->type == 1705 || (mt->type == 750 && mt->extrainfo)) + mt->z = mt->options; // NiGHTS Hoops use the full flags bits to set the height. + else + mt->z = mt->options >> ZSHIFT; + + mt->mobj = NULL; + } } +// Stores positions for relevant map data spread through a TEXTMAP. +UINT32 mapthingsPos[UINT16_MAX]; +UINT32 linesPos[UINT16_MAX]; +UINT32 sidesPos[UINT16_MAX]; +UINT32 vertexesPos[UINT16_MAX]; +UINT32 sectorsPos[UINT16_MAX]; + +// Determine total amount of map data in TEXTMAP. +static boolean TextmapCount(UINT8 *data, size_t size) +{ + char *tkn = M_GetToken((char *)data); + UINT8 brackets = 0; + + nummapthings = 0; + numlines = 0; + numsides = 0; + numvertexes = 0; + numsectors = 0; + + // Look for namespace at the beginning. + if (!fastcmp(tkn, "namespace")) + { + Z_Free(tkn); + CONS_Alert(CONS_ERROR, "No namespace at beginning of lump!\n"); + return false; + } + Z_Free(tkn); + + // Check if namespace is valid. + tkn = M_GetToken(NULL); + if (!fastcmp(tkn, "srb2")) + CONS_Alert(CONS_WARNING, "Invalid namespace '%s', only 'srb2' is supported.\n", tkn); + Z_Free(tkn); + + tkn = M_GetToken(NULL); + while (tkn && M_GetTokenPos() < size) + { + // Avoid anything inside bracketed stuff, only look for external keywords. + if (brackets) + { + if (fastcmp(tkn, "}")) + brackets--; + } + else if (fastcmp(tkn, "{")) + brackets++; + // Check for valid fields. + else if (fastcmp(tkn, "thing")) + mapthingsPos[nummapthings++] = M_GetTokenPos(); + else if (fastcmp(tkn, "linedef")) + linesPos[numlines++] = M_GetTokenPos(); + else if (fastcmp(tkn, "sidedef")) + sidesPos[numsides++] = M_GetTokenPos(); + else if (fastcmp(tkn, "vertex")) + vertexesPos[numvertexes++] = M_GetTokenPos(); + else if (fastcmp(tkn, "sector")) + sectorsPos[numsectors++] = M_GetTokenPos(); + else + CONS_Alert(CONS_NOTICE, "Unknown field '%s'.\n", tkn); + + Z_Free(tkn); + tkn = M_GetToken(NULL); + } + + Z_Free(tkn); + + if (brackets) + { + CONS_Alert(CONS_ERROR, "Unclosed brackets detected in textmap lump.\n"); + return false; + } + + return true; +} + +static void ParseTextmapVertexParameter(UINT32 i, char *param, char *val) +{ + if (fastcmp(param, "x")) + vertexes[i].x = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "y")) + vertexes[i].y = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "zfloor")) + { + vertexes[i].floorz = FLOAT_TO_FIXED(atof(val)); + vertexes[i].floorzset = true; + } + else if (fastcmp(param, "zceiling")) + { + vertexes[i].ceilingz = FLOAT_TO_FIXED(atof(val)); + vertexes[i].ceilingzset = true; + } +} + +static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val) +{ + if (fastcmp(param, "heightfloor")) + sectors[i].floorheight = atol(val) << FRACBITS; + else if (fastcmp(param, "heightceiling")) + sectors[i].ceilingheight = atol(val) << FRACBITS; + if (fastcmp(param, "texturefloor")) + sectors[i].floorpic = P_AddLevelFlat(val, foundflats); + else if (fastcmp(param, "textureceiling")) + sectors[i].ceilingpic = P_AddLevelFlat(val, foundflats); + else if (fastcmp(param, "lightlevel")) + sectors[i].lightlevel = atol(val); + else if (fastcmp(param, "special")) + sectors[i].special = atol(val); + else if (fastcmp(param, "id")) + sectors[i].tag = atol(val); + else if (fastcmp(param, "xpanningfloor")) + sectors[i].floor_xoffs = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "ypanningfloor")) + sectors[i].floor_yoffs = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "xpanningceiling")) + sectors[i].ceiling_xoffs = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "ypanningceiling")) + sectors[i].ceiling_yoffs = FLOAT_TO_FIXED(atof(val)); + else if (fastcmp(param, "rotationfloor")) + sectors[i].floorpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val))); + else if (fastcmp(param, "rotationceiling")) + sectors[i].ceilingpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val))); +} + +static void ParseTextmapSidedefParameter(UINT32 i, char *param, char *val) +{ + if (fastcmp(param, "offsetx")) + sides[i].textureoffset = atol(val)<floorpic_angle) + { + fixed_t pc = FINECOSINE(sec->floorpic_angle>>ANGLETOFINESHIFT); + fixed_t ps = FINESINE (sec->floorpic_angle>>ANGLETOFINESHIFT); + fixed_t xoffs = sec->floor_xoffs; + fixed_t yoffs = sec->floor_yoffs; + sec->floor_xoffs = (FixedMul(xoffs, pc) % MAXFLATSIZE) - (FixedMul(yoffs, ps) % MAXFLATSIZE); + sec->floor_yoffs = (FixedMul(xoffs, ps) % MAXFLATSIZE) + (FixedMul(yoffs, pc) % MAXFLATSIZE); + } + + if (sec->ceilingpic_angle) + { + fixed_t pc = FINECOSINE(sec->ceilingpic_angle>>ANGLETOFINESHIFT); + fixed_t ps = FINESINE (sec->ceilingpic_angle>>ANGLETOFINESHIFT); + fixed_t xoffs = sec->ceiling_xoffs; + fixed_t yoffs = sec->ceiling_yoffs; + sec->ceiling_xoffs = (FixedMul(xoffs, pc) % MAXFLATSIZE) - (FixedMul(yoffs, ps) % MAXFLATSIZE); + sec->ceiling_yoffs = (FixedMul(xoffs, ps) % MAXFLATSIZE) + (FixedMul(yoffs, pc) % MAXFLATSIZE); + } +} + +/** Loads the textmap data, after obtaining the elements count and allocating their respective space. + */ +static void P_LoadTextmap(void) +{ + UINT32 i; + + vertex_t *vt; + sector_t *sc; + line_t *ld; + side_t *sd; + mapthing_t *mt; + + CONS_Alert(CONS_NOTICE, "UDMF support is still a work-in-progress; its specs and features are prone to change until it is fully implemented.\n"); + + /// Given the UDMF specs, some fields are given a default value. + /// If an element's field has a default value set, it is omitted + /// from the textmap, and therefore we have to account for it by + /// preemptively setting that value beforehand. + + for (i = 0, vt = vertexes; i < numvertexes; i++, vt++) + { + // Defaults. + vt->x = vt->y = INT32_MAX; + vt->floorzset = vt->ceilingzset = false; + vt->floorz = vt->ceilingz = 0; + + TextmapParse(vertexesPos[i], i, ParseTextmapVertexParameter); + + if (vt->x == INT32_MAX) + I_Error("P_LoadTextmap: vertex %s has no x value set!\n", sizeu1(i)); + if (vt->y == INT32_MAX) + I_Error("P_LoadTextmap: vertex %s has no y value set!\n", sizeu1(i)); + } + + for (i = 0, sc = sectors; i < numsectors; i++, sc++) + { + // Defaults. + sc->floorheight = 0; + sc->ceilingheight = 0; + + sc->floorpic = 0; + sc->ceilingpic = 0; + + sc->lightlevel = 255; + + sc->special = 0; + sc->tag = 0; + + sc->floor_xoffs = sc->floor_yoffs = 0; + sc->ceiling_xoffs = sc->ceiling_yoffs = 0; + + sc->floorpic_angle = sc->ceilingpic_angle = 0; + + TextmapParse(sectorsPos[i], i, ParseTextmapSectorParameter); + P_InitializeSector(sc); + TextmapFixFlatOffsets(sc); + } + + for (i = 0, ld = lines; i < numlines; i++, ld++) + { + // Defaults. + ld->v1 = ld->v2 = NULL; + ld->flags = 0; + ld->special = 0; + ld->tag = 0; + ld->sidenum[0] = 0xffff; + ld->sidenum[1] = 0xffff; + + TextmapParse(linesPos[i], i, ParseTextmapLinedefParameter); + + if (!ld->v1) + I_Error("P_LoadTextmap: linedef %s has no v1 value set!\n", sizeu1(i)); + if (!ld->v2) + I_Error("P_LoadTextmap: linedef %s has no v2 value set!\n", sizeu1(i)); + if (ld->sidenum[0] == 0xffff) + I_Error("P_LoadTextmap: linedef %s has no sidefront value set!\n", sizeu1(i)); + + P_InitializeLinedef(ld); + } + + for (i = 0, sd = sides; i < numsides; i++, sd++) + { + // Defaults. + sd->textureoffset = 0; + sd->rowoffset = 0; + sd->toptexture = R_TextureNumForName("-"); + sd->midtexture = R_TextureNumForName("-"); + sd->bottomtexture = R_TextureNumForName("-"); + sd->sector = NULL; + sd->repeatcnt = 0; + + TextmapParse(sidesPos[i], i, ParseTextmapSidedefParameter); + + if (!sd->sector) + I_Error("P_LoadTextmap: sidedef %s has no sector value set!\n", sizeu1(i)); + + P_InitializeSidedef(sd); + } + + for (i = 0, mt = mapthings; i < nummapthings; i++, mt++) + { + // Defaults. + mt->x = mt->y = 0; + mt->angle = 0; + mt->type = 0; + mt->options = 0; + mt->z = 0; + mt->extrainfo = 0; + mt->mobj = NULL; + + TextmapParse(mapthingsPos[i], i, ParseTextmapThingParameter); + } +} + +static void P_ProcessLinedefsAfterSidedefs(void) +{ + size_t i = numlines; + register line_t *ld = lines; + for (; i--; ld++) + { + ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here + ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + + // Compile linedef 'text' from both sidedefs 'text' for appropriate specials. + switch (ld->special) + { + case 331: // Trigger linedef executor: Skin - Continuous + case 332: // Trigger linedef executor: Skin - Each time + case 333: // Trigger linedef executor: Skin - Once + case 443: // Calls a named Lua function + if (sides[ld->sidenum[0]].text) + { + size_t len = strlen(sides[ld->sidenum[0]].text) + 1; + if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) + len += strlen(sides[ld->sidenum[1]].text); + ld->text = Z_Malloc(len, PU_LEVEL, NULL); + M_Memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text) + 1); + if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) + M_Memcpy(ld->text + strlen(ld->text) + 1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text) + 1); + } + break; + } + } +} + +static boolean P_LoadMapData(const virtres_t *virt) +{ + virtlump_t *virtvertexes = NULL, *virtsectors = NULL, *virtsidedefs = NULL, *virtlinedefs = NULL, *virtthings = NULL; + virtlump_t *textmap = vres_Find(virt, "TEXTMAP"); + + // Count map data. + if (textmap) // Count how many entries for each type we got in textmap. + { + if (!TextmapCount(textmap->data, textmap->size)) + return false; + } + else + { + virtthings = vres_Find(virt, "THINGS"); + virtvertexes = vres_Find(virt, "VERTEXES"); + virtsectors = vres_Find(virt, "SECTORS"); + virtsidedefs = vres_Find(virt, "SIDEDEFS"); + virtlinedefs = vres_Find(virt, "LINEDEFS"); + + if (!virtthings) + I_Error("THINGS lump not found"); + if (!virtvertexes) + I_Error("VERTEXES lump not found"); + if (!virtsectors) + I_Error("SECTORS lump not found"); + if (!virtsidedefs) + I_Error("SIDEDEFS lump not found"); + if (!virtlinedefs) + I_Error("LINEDEFS lump not found"); + + // Traditional doom map format just assumes the number of elements from the lump sizes. + numvertexes = virtvertexes->size / sizeof (mapvertex_t); + numsectors = virtsectors->size / sizeof (mapsector_t); + numsides = virtsidedefs->size / sizeof (mapsidedef_t); + numlines = virtlinedefs->size / sizeof (maplinedef_t); + nummapthings = virtthings->size / (5 * sizeof (INT16)); + } + + if (numvertexes <= 0) + I_Error("Level has no vertices"); + if (numsectors <= 0) + I_Error("Level has no sectors"); + if (numsides <= 0) + I_Error("Level has no sidedefs"); + if (numlines <= 0) + I_Error("Level has no linedefs"); + + vertexes = Z_Calloc(numvertexes * sizeof (*vertexes), PU_LEVEL, NULL); + sectors = Z_Calloc(numsectors * sizeof (*sectors), PU_LEVEL, NULL); + sides = Z_Calloc(numsides * sizeof (*sides), PU_LEVEL, NULL); + lines = Z_Calloc(numlines * sizeof (*lines), PU_LEVEL, NULL); + mapthings = Z_Calloc(nummapthings * sizeof (*mapthings), PU_LEVEL, NULL); + + // Allocate a big chunk of memory as big as our MAXLEVELFLATS limit. + //Fab : FIXME: allocate for whatever number of flats - 512 different flats per level should be plenty + foundflats = calloc(MAXLEVELFLATS, sizeof (*foundflats)); + if (foundflats == NULL) + I_Error("Ran out of memory while loading sectors\n"); + + numlevelflats = 0; + + // Load map data. + if (textmap) + P_LoadTextmap(); + else + { + P_LoadVertices(virtvertexes->data); + P_LoadSectors(virtsectors->data); + P_LoadLinedefs(virtlinedefs->data); + P_LoadSidedefs(virtsidedefs->data); + P_LoadThings(virtthings->data); + } + + P_ProcessLinedefsAfterSidedefs(); + + R_ClearTextureNumCache(true); + + // set the sky flat num + skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); + + // copy table for global usage + levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); + free(foundflats); + + // search for animated flats and set up + P_SetupLevelFlatAnims(); + + return true; +} + +static void P_InitializeSubsector(subsector_t *ss) +{ + ss->sector = NULL; +#ifdef FLOORSPLATS + ss->splats = NULL; +#endif + ss->validcount = 0; +} + +static inline void P_LoadSubsectors(UINT8 *data) +{ + mapsubsector_t *ms = (mapsubsector_t*)data; + subsector_t *ss = subsectors; + size_t i; + + for (i = 0; i < numsubsectors; i++, ss++, ms++) + { + ss->numlines = SHORT(ms->numsegs); + ss->firstline = SHORT(ms->firstseg); + P_InitializeSubsector(ss); + } +} + +static void P_LoadNodes(UINT8 *data) +{ + UINT8 j, k; + mapnode_t *mn = (mapnode_t*)data; + node_t *no = nodes; + size_t i; + + for (i = 0; i < numnodes; i++, no++, mn++) + { + no->x = SHORT(mn->x)<y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<children[j] = SHORT(mn->children[j]); + for (k = 0; k < 4; k++) + no->bbox[j][k] = SHORT(mn->bbox[j][k])<v2->x - seg->v1->x)>>1; + INT64 dy = (seg->v2->y - seg->v1->y)>>1; + return FixedHypot(dx, dy)<<1; +} + +#ifdef HWRENDER +/** Computes the length of a seg as a float. + * This is needed for OpenGL. + * + * \param seg Seg to compute length for. + * \return Length as a float. + */ +static inline float P_SegLengthFloat(seg_t *seg) +{ + float dx, dy; + + // make a vector (start at origin) + dx = FIXED_TO_FLOAT(seg->v2->x - seg->v1->x); + dy = FIXED_TO_FLOAT(seg->v2->y - seg->v1->y); + + return (float)hypot(dx, dy); +} +#endif + +static void P_InitializeSeg(seg_t *seg) +{ + if (seg->linedef) + { + seg->sidedef = &sides[seg->linedef->sidenum[seg->side]]; + + seg->frontsector = seg->sidedef->sector; + seg->backsector = (seg->linedef->flags & ML_TWOSIDED) ? sides[seg->linedef->sidenum[seg->side ^ 1]].sector : NULL; + } + +#ifdef HWRENDER + seg->pv1 = seg->pv2 = NULL; + + //Hurdler: 04/12/2000: for now, only used in hardware mode + seg->lightmaps = NULL; // list of static lightmap for this seg +#endif + + seg->numlights = 0; + seg->rlights = NULL; +#ifdef POLYOBJECTS + seg->polyseg = NULL; + seg->dontrenderme = false; +#endif +} + +static void P_LoadSegs(UINT8 *data) +{ + mapseg_t *ms = (mapseg_t*)data; + seg_t *seg = segs; + size_t i; + + for (i = 0; i < numsegs; i++, seg++, ms++) + { + seg->v1 = &vertexes[SHORT(ms->v1)]; + seg->v2 = &vertexes[SHORT(ms->v2)]; + + seg->side = SHORT(ms->side); + + seg->offset = (SHORT(ms->offset)) << FRACBITS; + + seg->angle = (SHORT(ms->angle)) << FRACBITS; + + seg->linedef = &lines[SHORT(ms->linedef)]; + + seg->length = P_SegLength(seg); +#ifdef HWRENDER + seg->flength = (rendermode == render_opengl) ? P_SegLengthFloat(seg) : 0; +#endif + + seg->glseg = false; + P_InitializeSeg(seg); + } +} + +typedef enum { + NT_DOOM, + NT_XNOD, + NT_ZNOD, + NT_XGLN, + NT_ZGLN, + NT_XGL2, + NT_ZGL2, + NT_XGL3, + NT_ZGL3, + NT_UNSUPPORTED, + NUMNODETYPES +} nodetype_t; + +// Find out the BSP format. +static nodetype_t P_GetNodetype(const virtres_t *virt, UINT8 **nodedata) +{ + boolean supported[NUMNODETYPES] = {0}; + nodetype_t nodetype = NT_UNSUPPORTED; + char signature[4 + 1]; + + if (vres_Find(virt, "TEXTMAP")) + { + *nodedata = vres_Find(virt, "ZNODES")->data; + supported[NT_XGLN] = supported[NT_XGL3] = true; + } + else + { + virtlump_t *virtsegs = vres_Find(virt, "SEGS"); + virtlump_t *virtssectors; + + if (virtsegs && virtsegs->size) + { + *nodedata = vres_Find(virt, "NODES")->data; + return NT_DOOM; // Traditional map format BSP tree. + } + + virtssectors = vres_Find(virt, "SSECTORS"); + + if (virtssectors && virtssectors->size) + { // Possibly GL nodes: NODES ignored, SSECTORS takes precedence as nodes lump, (It is confusing yeah) and has a signature. + *nodedata = virtssectors->data; + supported[NT_XGLN] = supported[NT_ZGLN] = supported[NT_XGL3] = true; + } + else + { // Possibly ZDoom extended nodes: SSECTORS is empty, NODES has a signature. + *nodedata = vres_Find(virt, "NODES")->data; + supported[NT_XNOD] = supported[NT_ZNOD] = true; + } + } + + M_Memcpy(signature, *nodedata, 4); + signature[4] = '\0'; + (*nodedata) += 4; + + if (!strcmp(signature, "XNOD")) + nodetype = NT_XNOD; + else if (!strcmp(signature, "ZNOD")) + nodetype = NT_ZNOD; + else if (!strcmp(signature, "XGLN")) + nodetype = NT_XGLN; + else if (!strcmp(signature, "ZGLN")) + nodetype = NT_ZGLN; + else if (!strcmp(signature, "XGL3")) + nodetype = NT_XGL3; + + return supported[nodetype] ? nodetype : NT_UNSUPPORTED; +} + +// Extended node formats feature additional vertices; useful for OpenGL, but totally useless in gamelogic. +static boolean P_LoadExtraVertices(UINT8 **data) +{ + UINT32 origvrtx = READUINT32((*data)); + UINT32 xtrvrtx = READUINT32((*data)); + line_t* ld = lines; + vertex_t *oldpos = vertexes; + ssize_t offset; + size_t i; + + if (numvertexes != origvrtx) // If native vertex count doesn't match node original vertex count, bail out (broken data?). + { + CONS_Alert(CONS_WARNING, "Vertex count in map data and nodes differ!\n"); + return false; + } + + if (!xtrvrtx) + return true; + + // If extra vertexes were generated, reallocate the vertex array and fix the pointers. + numvertexes += xtrvrtx; + vertexes = Z_Realloc(vertexes, numvertexes*sizeof(*vertexes), PU_LEVEL, NULL); + offset = (size_t)(vertexes - oldpos); + + for (i = 0, ld = lines; i < numlines; i++, ld++) + { + ld->v1 += offset; + ld->v2 += offset; + } + + // Read extra vertex data. + for (i = origvrtx; i < numvertexes; i++) + { + vertexes[i].x = READFIXED((*data)); + vertexes[i].y = READFIXED((*data)); + } + + return true; +} + +static boolean P_LoadExtendedSubsectorsAndSegs(UINT8 **data, nodetype_t nodetype) +{ + size_t i, k; + INT16 m; + seg_t *seg; + + // Subsectors + numsubsectors = READUINT32((*data)); + subsectors = Z_Calloc(numsubsectors*sizeof(*subsectors), PU_LEVEL, NULL); + + for (i = 0; i < numsubsectors; i++) + subsectors[i].numlines = READUINT32((*data)); + + // Segs + numsegs = READUINT32((*data)); + segs = Z_Calloc(numsegs*sizeof(*segs), PU_LEVEL, NULL); + + for (i = 0, k = 0; i < numsubsectors; i++) + { + subsectors[i].firstline = k; + P_InitializeSubsector(&subsectors[i]); + + switch (nodetype) + { + case NT_XGLN: + case NT_XGL3: + for (m = 0; m < subsectors[i].numlines; m++, k++) + { + UINT32 vertexnum = READUINT32((*data)); + UINT16 linenum; + + if (vertexnum >= numvertexes) + I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid vertex %d!\n", sizeu1(k), m, vertexnum); + + segs[k - 1 + ((m == 0) ? subsectors[i].numlines : 0)].v2 = segs[k].v1 = &vertexes[vertexnum]; + + READUINT32((*data)); // partner, can be ignored by software renderer + if (nodetype == NT_XGL3) + READUINT16((*data)); // Line number is 32-bit in XGL3, but we're limited to 16 bits. + + linenum = READUINT16((*data)); + if (linenum != 0xFFFF && linenum >= numlines) + I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid linedef %d!\n", sizeu1(k), m, linenum); + segs[k].glseg = (linenum == 0xFFFF); + segs[k].linedef = (linenum == 0xFFFF) ? NULL : &lines[linenum]; + segs[k].side = READUINT8((*data)); + } + break; + + case NT_XNOD: + for (m = 0; m < subsectors[i].numlines; m++, k++) + { + UINT32 v1num = READUINT32((*data)); + UINT32 v2num = READUINT32((*data)); + UINT16 linenum = READUINT16((*data)); + + if (v1num >= numvertexes) + I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v1 %d!\n", sizeu1(k), m, v1num); + if (v2num >= numvertexes) + I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid v2 %d!\n", sizeu1(k), m, v2num); + if (linenum >= numlines) + I_Error("P_LoadExtendedSubsectorsAndSegs: Seg %s in subsector %d has invalid linedef %d!\n", sizeu1(k), m, linenum); + + segs[k].v1 = &vertexes[v1num]; + segs[k].v2 = &vertexes[v2num]; + segs[k].linedef = &lines[linenum]; + segs[k].side = READUINT8((*data)); + segs[k].glseg = false; + } + break; + + default: + return false; + } + } + + for (i = 0, seg = segs; i < numsegs; i++, seg++) + { + vertex_t *v1 = seg->v1; + vertex_t *v2 = seg->v2; + P_InitializeSeg(seg); + seg->angle = R_PointToAngle2(v1->x, v1->y, v2->x, v2->y); + if (seg->linedef) + segs[i].offset = FixedHypot(v1->x - seg->linedef->v1->x, v1->y - seg->linedef->v1->y); + } + + return true; +} + +// Auxiliary function: Shrink node ID from 32-bit to 16-bit. +static UINT16 ShrinkNodeID(UINT32 x) { + UINT16 mask = (x >> 16) & 0xC000; + UINT16 result = x; + return result | mask; +} + +static void P_LoadExtendedNodes(UINT8 **data, nodetype_t nodetype) +{ + node_t *mn; + size_t i, j, k; + boolean xgl3 = (nodetype == NT_XGL3); + + numnodes = READINT32((*data)); + nodes = Z_Calloc(numnodes*sizeof(*nodes), PU_LEVEL, NULL); + + for (i = 0, mn = nodes; i < numnodes; i++, mn++) + { + // Splitter + mn->x = xgl3 ? READINT32((*data)) : (READINT16((*data)) << FRACBITS); + mn->y = xgl3 ? READINT32((*data)) : (READINT16((*data)) << FRACBITS); + mn->dx = xgl3 ? READINT32((*data)) : (READINT16((*data)) << FRACBITS); + mn->dy = xgl3 ? READINT32((*data)) : (READINT16((*data)) << FRACBITS); + + // Bounding boxes + for (j = 0; j < 2; j++) + for (k = 0; k < 4; k++) + mn->bbox[j][k] = READINT16((*data)) << FRACBITS; + + //Children + mn->children[0] = ShrinkNodeID(READUINT32((*data))); /// \todo Use UINT32 for node children in a future, instead? + mn->children[1] = ShrinkNodeID(READUINT32((*data))); + } +} + +static void P_LoadMapBSP(const virtres_t *virt) +{ + UINT8 *nodedata = NULL; + nodetype_t nodetype = P_GetNodetype(virt, &nodedata); + + switch (nodetype) + { + case NT_DOOM: + { + virtlump_t *virtssectors = vres_Find(virt, "SSECTORS"); + virtlump_t* virtnodes = vres_Find(virt, "NODES"); + virtlump_t *virtsegs = vres_Find(virt, "SEGS"); + + numsubsectors = virtssectors->size / sizeof(mapsubsector_t); + numnodes = virtnodes->size / sizeof(mapnode_t); + numsegs = virtsegs->size / sizeof(mapseg_t); + + if (numsubsectors <= 0) + I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)"); + if (numnodes <= 0) + I_Error("Level has no nodes"); + if (numsegs <= 0) + I_Error("Level has no segs"); + + subsectors = Z_Calloc(numsubsectors * sizeof(*subsectors), PU_LEVEL, NULL); + nodes = Z_Calloc(numnodes * sizeof(*nodes), PU_LEVEL, NULL); + segs = Z_Calloc(numsegs * sizeof(*segs), PU_LEVEL, NULL); + + P_LoadSubsectors(virtssectors->data); + P_LoadNodes(virtnodes->data); + P_LoadSegs(virtsegs->data); + break; + } + case NT_XNOD: + case NT_XGLN: + case NT_XGL3: + if (!P_LoadExtraVertices(&nodedata)) + return; + if (!P_LoadExtendedSubsectorsAndSegs(&nodedata, nodetype)) + return; + P_LoadExtendedNodes(&nodedata, nodetype); + break; + default: + CONS_Alert(CONS_WARNING, "Unsupported BSP format detected.\n"); + return; + } + return; +} + +// Split from P_LoadBlockMap for convenience +// -- Monster Iestyn 08/01/18 +static void P_ReadBlockMapLump(INT16 *wadblockmaplump, size_t count) +{ + size_t i; + blockmaplump = Z_Calloc(sizeof (*blockmaplump) * count, PU_LEVEL, NULL); + + // killough 3/1/98: Expand wad blockmap into larger internal one, + // by treating all offsets except -1 as unsigned and zero-extending + // them. This potentially doubles the size of blockmaps allowed, + // because Doom originally considered the offsets as always signed. + + blockmaplump[0] = SHORT(wadblockmaplump[0]); + blockmaplump[1] = SHORT(wadblockmaplump[1]); + blockmaplump[2] = (INT32)(SHORT(wadblockmaplump[2])) & 0xffff; + blockmaplump[3] = (INT32)(SHORT(wadblockmaplump[3])) & 0xffff; + + for (i = 4; i < count; i++) + { + INT16 t = SHORT(wadblockmaplump[i]); // killough 3/1/98 + blockmaplump[i] = t == -1 ? (INT32)-1 : (INT32) t & 0xffff; + } +} + +// This needs to be a separate function +// because making both the WAD and PK3 loading code use +// the same functions is trickier than it looks for blockmap +// -- Monster Iestyn 09/01/18 +static boolean P_LoadBlockMap(UINT8 *data, size_t count) +{ + if (!count || count >= 0x20000) + return false; + + //CONS_Printf("Reading blockmap lump for pk3...\n"); + + // no need to malloc anything, assume the data is uncompressed for now + count /= 2; + P_ReadBlockMapLump((INT16 *)data, count); + + bmaporgx = blockmaplump[0]<= 0x20000) - return false; - - { - INT16 *wadblockmaplump = malloc(count); //INT16 *wadblockmaplump = W_CacheLumpNum (lump, PU_LEVEL); - if (!wadblockmaplump) - return false; - W_ReadLump(lumpnum, wadblockmaplump); - count /= 2; - P_ReadBlockMapLump(wadblockmaplump, count); - free(wadblockmaplump); - } - - bmaporgx = blockmaplump[0]<= 0x20000) - return false; +static void P_LoadMapLUT(const virtres_t *virt) +{ + virtlump_t* virtblockmap = vres_Find(virt, "BLOCKMAP"); + virtlump_t* virtreject = vres_Find(virt, "REJECT"); - //CONS_Printf("Reading blockmap lump for pk3...\n"); + // Lookup tables + if (virtreject) + P_LoadReject(virtreject->data, virtreject->size); + else + rejectmatrix = NULL; - // no need to malloc anything, assume the data is uncompressed for now - count /= 2; - P_ReadBlockMapLump((INT16 *)data, count); - - bmaporgx = blockmaplump[0]<data, virtblockmap->size))) + P_CreateBlockMap(); } // -// P_GroupLines +// P_LinkMapData // Builds sector line lists and subsector sector numbers. // Finds block bounding boxes for sectors. // -static void P_GroupLines(void) +static void P_LinkMapData(void) { size_t i, j; line_t *li; @@ -2044,20 +2569,20 @@ static void P_GroupLines(void) for (i = 0; i < numsubsectors; i++, ss++) { if (ss->firstline >= numsegs) - CorruptMapError(va("P_GroupLines: ss->firstline invalid " + CorruptMapError(va("P_LinkMapData: ss->firstline invalid " "(subsector %s, firstline refers to %d of %s)", sizeu1(i), ss->firstline, sizeu2(numsegs))); seg = &segs[ss->firstline]; sidei = (size_t)(seg->sidedef - sides); if (!seg->sidedef) - CorruptMapError(va("P_GroupLines: seg->sidedef is NULL " + CorruptMapError(va("P_LinkMapData: seg->sidedef is NULL " "(subsector %s, firstline is %d)", sizeu1(i), ss->firstline)); if (seg->sidedef - sides < 0 || seg->sidedef - sides > (UINT16)numsides) - CorruptMapError(va("P_GroupLines: seg->sidedef refers to sidedef %s of %s " + CorruptMapError(va("P_LinkMapData: seg->sidedef refers to sidedef %s of %s " "(subsector %s, firstline is %d)", sizeu1(sidei), sizeu2(numsides), sizeu3(i), ss->firstline)); if (!seg->sidedef->sector) - CorruptMapError(va("P_GroupLines: seg->sidedef->sector is NULL " + CorruptMapError(va("P_LinkMapData: seg->sidedef->sector is NULL " "(subsector %s, firstline is %d, sidedef is %s)", sizeu1(i), ss->firstline, sizeu1(sidei))); ss->sector = seg->sidedef->sector; @@ -2078,7 +2603,7 @@ static void P_GroupLines(void) if (sector->linecount == 0) // no lines found? { sector->lines = NULL; - CONS_Debug(DBG_SETUP, "P_GroupLines: sector %s has no lines\n", sizeu1(i)); + CONS_Debug(DBG_SETUP, "P_LinkMapData: sector %s has no lines\n", sizeu1(i)); } else { @@ -2121,95 +2646,95 @@ static void P_GroupLines(void) } } -// -// P_LoadReject -// -// Detect if the REJECT lump is valid, -// if not, rejectmatrix will be NULL -static void P_LoadReject(lumpnum_t lumpnum) -{ - size_t count; - const char *lumpname = W_CheckNameForNum(lumpnum); - - // Check if the lump exists, and if it's named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadReject: No valid REJECT lump found\n"); - return; - } - - count = W_LumpLength(lumpnum); - - if (!count) // zero length, someone probably used ZDBSP - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadReject: REJECT lump has size 0, will not be loaded\n"); - } - else - rejectmatrix = W_CacheLumpNum(lumpnum, PU_LEVEL); -} - -// PK3 version -// -- Monster Iestyn 09/01/18 -static void P_LoadRawReject(UINT8 *data, size_t count, const char *lumpname) -{ - // Check if the lump is named "REJECT" - if (!lumpname || memcmp(lumpname, "REJECT\0\0", 8) != 0) - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadRawReject: No valid REJECT lump found\n"); - return; - } - - if (!count) // zero length, someone probably used ZDBSP - { - rejectmatrix = NULL; - CONS_Debug(DBG_SETUP, "P_LoadRawReject: REJECT lump has size 0, will not be loaded\n"); - } - else - { - rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix - M_Memcpy(rejectmatrix, data, count); // copy the data into it - } -} - -#if 0 -static char *levellumps[] = -{ - "label", // ML_LABEL, A separator, name, MAPxx - "THINGS", // ML_THINGS, Enemies, items.. - "LINEDEFS", // ML_LINEDEFS, Linedefs, from editing - "SIDEDEFS", // ML_SIDEDEFS, Sidedefs, from editing - "VERTEXES", // ML_VERTEXES, Vertices, edited and BSP splits generated - "SEGS", // ML_SEGS, Linesegs, from linedefs split by BSP - "SSECTORS", // ML_SSECTORS, Subsectors, list of linesegs - "NODES", // ML_NODES, BSP nodes - "SECTORS", // ML_SECTORS, Sectors, from editing - "REJECT", // ML_REJECT, LUT, sector-sector visibility -}; - -/** Checks a lump and returns whether it is a valid start-of-level marker. +/** Compute MD5 message digest for bytes read from memory source * - * \param lumpnum Lump number to check. - * \return True if the lump is a valid level marker, false if not. + * The resulting message digest number will be written into the 16 bytes + * beginning at RESBLOCK. + * + * \param filename path of file + * \param resblock resulting MD5 checksum + * \return 0 if MD5 checksum was made, and is at resblock, 1 if error was found */ -static inline boolean P_CheckLevel(lumpnum_t lumpnum) +static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) { - UINT16 file, lump; - size_t i; - - for (i = ML_THINGS; i <= ML_REJECT; i++) - { - file = WADFILENUM(lumpnum); - lump = LUMPNUM(lumpnum+1); - if (file > numwadfiles || lump < LUMPNUM(lumpnum) || lump > wadfiles[file]->numlumps || - memcmp(wadfiles[file]->lumpinfo[lump].name, levellumps[i], 8) != 0) - return false; - } - return true; // all right -} +#ifdef NOMD5 + (void)buffer; + (void)len; + memset(resblock, 0x00, 16); + return 1; +#else + tic_t t = I_GetTime(); + CONS_Debug(DBG_SETUP, "Making MD5\n"); + if (md5_buffer(buffer, len, resblock) == NULL) + return 1; + CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetTime() - t)/NEWTICRATE); + return 0; #endif +} + +static void P_MakeMapMD5(virtres_t *virt, void *dest) +{ + virtlump_t *textmap = vres_Find(virt, "TEXTMAP"); + unsigned char resmd5[16]; + + if (textmap) + P_MakeBufferMD5((char*)textmap->data, textmap->size, resmd5); + else + { + unsigned char linemd5[16]; + unsigned char sectormd5[16]; + unsigned char thingmd5[16]; + unsigned char sidedefmd5[16]; + UINT8 i; + + // Create a hash for the current map + // get the actual lumps! + virtlump_t* virtlines = vres_Find(virt, "LINEDEFS"); + virtlump_t* virtsectors = vres_Find(virt, "SECTORS"); + virtlump_t* virtmthings = vres_Find(virt, "THINGS"); + virtlump_t* virtsides = vres_Find(virt, "SIDEDEFS"); + + P_MakeBufferMD5((char*)virtlines->data, virtlines->size, linemd5); + P_MakeBufferMD5((char*)virtsectors->data, virtsectors->size, sectormd5); + P_MakeBufferMD5((char*)virtmthings->data, virtmthings->size, thingmd5); + P_MakeBufferMD5((char*)virtsides->data, virtsides->size, sidedefmd5); + + for (i = 0; i < 16; i++) + resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF; + } + + M_Memcpy(dest, &resmd5, 16); +} + +static boolean P_LoadMapFromFile(void) +{ + virtres_t *virt = vres_GetMap(lastloadedmaplumpnum); + + if (!P_LoadMapData(virt)) + return false; + P_LoadMapBSP(virt); + P_LoadMapLUT(virt); + + P_LinkMapData(); + + // Copy relevant map data for NetArchive purposes. + spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL); + spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL); + spawnsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL); + + memcpy(spawnsectors, sectors, numsectors * sizeof(*sectors)); + memcpy(spawnlines, lines, numlines * sizeof(*lines)); + memcpy(spawnsides, sides, numsides * sizeof(*sides)); + + P_MakeMapMD5(virt, &mapmd5); + + vres_Free(virt); + return true; +} + +// +// LEVEL INITIALIZATION FUNCTIONS +// /** Sets up a sky texture to use for the level. * The sky texture is used instead of F_SKY1. @@ -2242,26 +2767,43 @@ lumpnum_t lastloadedmaplumpnum; // for comparative savegame // // Some player initialization for map start. // -static void P_LevelInitStuff(void) +static void P_InitLevelSettings(void) { INT32 i; + boolean canresetlives = true; leveltime = 0; localaiming = 0; localaiming2 = 0; + modulothing = 0; // special stage tokens, emeralds, and ring total tokenbits = 0; runemeraldmanager = false; - nummaprings = 0; + emeraldspawndelay = 60*TICRATE; + if ((netgame || multiplayer) && !G_IsSpecialStage(gamemap)) + nummaprings = -1; + else + nummaprings = mapheaderinfo[gamemap-1]->startrings; // emerald hunt hunt1 = hunt2 = hunt3 = NULL; // map time limit if (mapheaderinfo[gamemap-1]->countdown) + { + tic_t maxtime = 0; countdowntimer = mapheaderinfo[gamemap-1]->countdown * TICRATE; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + if (players[i].starposttime > maxtime) + maxtime = players[i].starposttime; + } + countdowntimer -= maxtime; + } else countdowntimer = 0; countdowntimeup = false; @@ -2273,157 +2815,86 @@ static void P_LevelInitStuff(void) // circuit, race and competition stuff circuitmap = false; numstarposts = 0; - totalrings = timeinmap = 0; + ssspheres = timeinmap = 0; // special stage - stagefailed = false; + stagefailed = true; // assume failed unless proven otherwise - P_GiveEmerald or emerald touchspecial // Reset temporary record data memset(&ntemprecords, 0, sizeof(nightsdata_t)); // earthquake camera memset(&quake,0,sizeof(struct quake)); + if ((netgame || multiplayer) && G_GametypeUsesCoopStarposts() && cv_coopstarposts.value == 2) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && players[i].lives > 0) + { + canresetlives = false; + break; + } + } + } + + countdown = countdown2 = exitfadestarted = 0; + for (i = 0; i < MAXPLAYERS; i++) { - if ((netgame || multiplayer) && (gametype == GT_COMPETITION || players[i].lives <= 0)) + G_PlayerReborn(i, true); + + if (canresetlives && (netgame || multiplayer) && playeringame[i] && (G_CompetitionGametype() || players[i].lives <= 0)) { // In Co-Op, replenish a user's lives if they are depleted. players[i].lives = cv_startinglives.value; } - players[i].realtime = countdown = countdown2 = 0; + // obliteration station... + players[i].numboxes = players[i].totalring =\ + players[i].laps = players[i].marescore = players[i].lastmarescore =\ + players[i].mare = players[i].exiting = 0; - players[i].gotcontinue = false; - - players[i].xtralife = players[i].deadtimer = players[i].numboxes = players[i].totalring = players[i].laps = 0; - players[i].health = 1; - players[i].aiming = 0; - players[i].pflags &= ~PF_TIMEOVER; - - players[i].losstime = 0; - players[i].timeshit = 0; - - players[i].marescore = players[i].lastmarescore = players[i].maxlink = 0; - players[i].startedtime = players[i].finishedtime = players[i].finishedrings = 0; - players[i].lastmare = players[i].marebegunat = 0; - - // Don't show anything - players[i].textvar = players[i].texttimer = 0; - - players[i].linkcount = players[i].linktimer = 0; - players[i].flyangle = players[i].anotherflyangle = 0; - players[i].nightstime = players[i].mare = 0; - P_SetTarget(&players[i].capsule, NULL); players[i].drillmeter = 40*20; - players[i].exiting = 0; - P_ResetPlayer(&players[i]); - - players[i].mo = NULL; - - // we must unset axis details too - players[i].axis1 = players[i].axis2 = NULL; - - // and this stupid flag as a result - players[i].pflags &= ~PF_TRANSFERTOCLOSEST; + // hit these too + players[i].pflags &= ~(PF_GAMETYPEOVER); } + + if (botingame) + CV_SetValue(&cv_analog[1], true); } -// -// P_LoadThingsOnly -// -// "Reloads" a level, but only reloads all of the mobjs. -// -void P_LoadThingsOnly(void) +// Respawns all the mapthings and mobjs in the map from the already loaded map data. +void P_RespawnThings(void) { // Search through all the thinkers. - mobj_t *mo; thinker_t *think; + INT32 i, viewid = -1, centerid = -1; // for skyboxes - for (think = thinkercap.next; think != &thinkercap; think = think->next) + // check if these are any of the normal viewpoint/centerpoint mobjs in the level or not + if (skyboxmo[0] || skyboxmo[1]) + for (i = 0; i < 16; i++) + { + if (skyboxmo[0] && skyboxmo[0] == skyboxviewpnts[i]) + viewid = i; // save id just in case + if (skyboxmo[1] && skyboxmo[1] == skyboxcenterpnts[i]) + centerid = i; // save id just in case + } + + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo) - P_RemoveMobj(mo); + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + P_RemoveMobj((mobj_t *)think); } - P_LevelInitStuff(); + P_InitLevelSettings(); - if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 - { // HACK: Open wad file rather quickly so we can use the things lump - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - fileinfo += ML_THINGS; // we only need the THINGS lump - P_PrepareRawThings(wadData + fileinfo->filepos, fileinfo->size); - Z_Free(wadData); // we're done with this now - } - else // phew it's just a WAD - P_PrepareThings(lastloadedmaplumpnum + ML_THINGS); - P_LoadThings(); + P_SpawnMapThings(true); - P_SpawnSecretItems(true); -} - -/** Compute MD5 message digest for bytes read from memory source - * - * The resulting message digest number will be written into the 16 bytes - * beginning at RESBLOCK. - * - * \param filename path of file - * \param resblock resulting MD5 checksum - * \return 0 if MD5 checksum was made, and is at resblock, 1 if error was found - */ -static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock) -{ -#ifdef NOMD5 - (void)buffer; - (void)len; - memset(resblock, 0x00, 16); - return 1; -#else - tic_t t = I_GetTime(); - CONS_Debug(DBG_SETUP, "Making MD5\n"); - if (md5_buffer(buffer, len, resblock) == NULL) - return 1; - CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetTime() - t)/NEWTICRATE); - return 0; -#endif -} - -static void P_MakeMapMD5(lumpnum_t maplumpnum, void *dest) -{ - unsigned char linemd5[16]; - unsigned char sectormd5[16]; - unsigned char thingmd5[16]; - unsigned char sidedefmd5[16]; - unsigned char resmd5[16]; - UINT8 i; - - // Create a hash for the current map - // get the actual lumps! - UINT8 *datalines = W_CacheLumpNum(maplumpnum + ML_LINEDEFS, PU_CACHE); - UINT8 *datasectors = W_CacheLumpNum(maplumpnum + ML_SECTORS, PU_CACHE); - UINT8 *datathings = W_CacheLumpNum(maplumpnum + ML_THINGS, PU_CACHE); - UINT8 *datasides = W_CacheLumpNum(maplumpnum + ML_SIDEDEFS, PU_CACHE); - - P_MakeBufferMD5((char*)datalines, W_LumpLength(maplumpnum + ML_LINEDEFS), linemd5); - P_MakeBufferMD5((char*)datasectors, W_LumpLength(maplumpnum + ML_SECTORS), sectormd5); - P_MakeBufferMD5((char*)datathings, W_LumpLength(maplumpnum + ML_THINGS), thingmd5); - P_MakeBufferMD5((char*)datasides, W_LumpLength(maplumpnum + ML_SIDEDEFS), sidedefmd5); - - Z_Free(datalines); - Z_Free(datasectors); - Z_Free(datathings); - Z_Free(datasides); - - for (i = 0; i < 16; i++) - resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF; - - M_Memcpy(dest, &resmd5, 16); + // restore skybox viewpoint/centerpoint if necessary, set them to defaults if we can't do that + skyboxmo[0] = skyboxviewpnts[(viewid >= 0) ? viewid : 0]; + skyboxmo[1] = skyboxcenterpnts[(centerid >= 0) ? centerid : 0]; } static void P_RunLevelScript(const char *scriptname) @@ -2490,6 +2961,26 @@ static void P_ForceCharacter(const char *forcecharskin) } } +static void P_ResetSpawnpoints(void) +{ + UINT8 i; + + numdmstarts = numredctfstarts = numbluectfstarts = 0; + + // reset the player starts + for (i = 0; i < MAXPLAYERS; i++) + playerstarts[i] = bluectfstarts[i] = redctfstarts[i] = NULL; + + for (i = 0; i < MAX_DM_STARTS; i++) + deathmatchstarts[i] = NULL; + + for (i = 0; i < 2; i++) + skyboxmo[i] = NULL; + + for (i = 0; i < 16; i++) + skyboxviewpnts[i] = skyboxcenterpnts[i] = NULL; +} + static void P_LoadRecordGhosts(void) { const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; @@ -2589,6 +3080,45 @@ static void P_LoadNightsGhosts(void) free(gpath); } +static void P_InitTagGametype(void) +{ + UINT8 i; + INT32 realnumplayers = 0; + INT32 playersactive[MAXPLAYERS]; + + //I just realized how problematic this code can be. + //D_NumPlayers() will not always cover the scope of the netgame. + //What if one player is node 0 and the other node 31? + //The solution? Make a temp array of all players that are currently playing and pick from them. + //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? + //Also, you'd never have to loop through all 32 players slots to find anything ever again. + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && !(players[i].spectator || players[i].quittime)) + { + playersactive[realnumplayers] = i; //stores the player's node in the array. + realnumplayers++; + } + } + + if (!realnumplayers) //this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. + { + CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); + return; + } + + i = P_RandomKey(realnumplayers); + players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. + + // Taken and modified from G_DoReborn() + // Remove the player so he can respawn elsewhere. + // first disassociate the corpse + if (players[playersactive[i]].mo) + P_RemoveMobj(players[playersactive[i]].mo); + + G_SpawnPlayer(playersactive[i]); //respawn the lucky player in his dedicated spawn location. +} + static void P_SetupCamera(void) { if (players[displayplayer].mo && (server || addedtogame)) @@ -2603,17 +3133,10 @@ static void P_SetupCamera(void) { mapthing_t *thing; - switch (gametype) - { - case GT_MATCH: - case GT_TAG: + if (gametyperules & GTR_DEATHMATCHSTARTS) thing = deathmatchstarts[0]; - break; - - default: + else thing = playerstarts[0]; - break; - } if (thing) { @@ -2626,54 +3149,257 @@ static void P_SetupCamera(void) } } -static boolean P_CanSave(void) +static void P_InitCamera(void) { - // Saving is completely ignored under these conditions: - if ((cursaveslot < 0) // Playing without saving - || (modifiedgame && !savemoddata) // Game is modified - || (netgame || multiplayer) // Not in single-player - || (demoplayback || demorecording || metalrecording) // Currently in demo - || (players[consoleplayer].lives <= 0) // Completely dead - || (modeattacking || ultimatemode || G_IsSpecialStage(gamemap))) // Specialized instances + if (!dedicated) + { + P_SetupCamera(); + + // Salt: CV_ClearChangedFlags() messes with your settings :( + /*if (!cv_cam_height.changed) + CV_Set(&cv_cam_height, cv_cam_height.defaultvalue); + if (!cv_cam2_height.changed) + CV_Set(&cv_cam2_height, cv_cam2_height.defaultvalue); + + if (!cv_cam_dist.changed) + CV_Set(&cv_cam_dist, cv_cam_dist.defaultvalue); + if (!cv_cam2_dist.changed) + CV_Set(&cv_cam2_dist, cv_cam2_dist.defaultvalue);*/ + + // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P + if (!cv_cam_rotate.changed) + CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); + if (!cv_cam2_rotate.changed) + CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); + + if (!cv_analog[0].changed) + CV_SetValue(&cv_analog[0], 0); + if (!cv_analog[1].changed) + CV_SetValue(&cv_analog[1], 0); + + displayplayer = consoleplayer; // Start with your OWN view, please! + } + + if (twodlevel) + { + CV_SetValue(&cv_analog[0], false); + CV_SetValue(&cv_analog[1], false); + } + else + { + if (cv_useranalog[0].value) + CV_SetValue(&cv_analog[0], true); + + if ((splitscreen && cv_useranalog[1].value) || botingame) + CV_SetValue(&cv_analog[1], true); + } +} + +static boolean CanSaveLevel(INT32 mapnum) +{ + if (ultimatemode) // never save in ultimate (probably redundant with cursaveslot also being checked) return false; - if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_ALWAYS) - return true; // Saving should ALWAYS happen! - else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER) - return false; // Saving should NEVER happen! + if (G_IsSpecialStage(mapnum) // don't save in special stages + || mapnum == lastmaploaded) // don't save if the last map loaded was this one + return false; - // Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload. - return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) - && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete) - && (gamemap != lastmapsaved)); + // Any levels that have the savegame flag can save normally. + // If the game is complete for this save slot, then any level can save! + // On the other side of the spectrum, if lastmaploaded is 0, then the save file has only just been created and needs to save ASAP! + return (mapheaderinfo[mapnum-1]->levelflags & LF_SAVEGAME || gamecomplete || !lastmaploaded); +} + +static void P_RunSpecialStageWipe(void) +{ + tic_t starttime = I_GetTime(); + tic_t endtime = starttime + (3*TICRATE)/2; + tic_t nowtime; + + S_StartSound(NULL, sfx_s3kaf); + + // Fade music! Time it to S3KAF: 0.25 seconds is snappy. + if (RESETMUSIC || + strnicmp(S_MusicName(), + (mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap - 1]->musname : mapmusname, 7)) + S_FadeOutStopMusic(MUSICRATE/4); //FixedMul(FixedDiv(F_GetWipeLength(wipedefs[wipe_speclevel_towhite])*NEWTICRATERATIO, NEWTICRATE), MUSICRATE) + + F_WipeStartScreen(); + wipestyleflags |= (WSF_FADEOUT|WSF_TOWHITE); + +#ifdef HWRENDER + // uh.......... + if (rendermode == render_opengl) + F_WipeColorFill(0); +#endif + + F_WipeEndScreen(); + F_RunWipe(wipedefs[wipe_speclevel_towhite], false); + + I_OsPolling(); + I_FinishUpdate(); // page flip or blit buffer + if (moviemode) + M_SaveFrame(); + + nowtime = lastwipetic; + + // Hold on white for extra effect. + while (nowtime < endtime) + { + // wait loop + while (!((nowtime = I_GetTime()) - lastwipetic)) + I_Sleep(); + lastwipetic = nowtime; + if (moviemode) // make sure we save frames for the white hold too + M_SaveFrame(); + } +} + +static void P_RunLevelWipe(void) +{ + F_WipeStartScreen(); + wipestyleflags |= WSF_FADEOUT; + +#ifdef HWRENDER + // uh.......... + if (rendermode == render_opengl) + F_WipeColorFill(31); +#endif + + F_WipeEndScreen(); + // for titlemap: run a specific wipe if specified + // needed for exiting time attack + if (wipetypepre != INT16_MAX) + F_RunWipe( + (wipetypepre >= 0 && F_WipeExists(wipetypepre)) ? wipetypepre : wipedefs[wipe_level_toblack], + false); + wipetypepre = -1; +} + +static void P_InitPlayers(void) +{ + UINT8 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + // Start players with pity shields if possible + players[i].pity = -1; + + players[i].mo = NULL; + + if (!G_PlatformGametype()) + G_DoReborn(i); + else // gametype is GT_COOP or GT_RACE + { + G_SpawnPlayer(i); + if (players[i].starposttime) + P_ClearStarPost(players[i].starpostnum); + } + } +} + +static void P_WriteLetter(void) +{ + char *buf, *b; + + if (!unlockables[27].unlocked) // pandora's box + return; + + if (modeattacking) + return; + +#ifndef DEVELOP + if (modifiedgame) + return; +#endif + + if (netgame || multiplayer) + return; + + if (gamemap != 0x1d35 - 016464) + return; + + P_SpawnMobj(0640370000, 0x11000000, 0x3180000, MT_LETTER)->angle = ANGLE_90; + + if (textprompts[199]->page[1].backcolor == 259) + return; + + buf = W_CacheLumpName("WATERMAP", PU_STATIC); + b = buf; + + while ((*b != 65) && (b - buf < 256)) + { + *b = (*b - 65) & 255; + b++; + } + *b = '\0'; + + Z_Free(textprompts[199]->page[1].text); + textprompts[199]->page[1].text = Z_StrDup(buf); + textprompts[199]->page[1].lines = 4; + textprompts[199]->page[1].backcolor = 259; + Z_Free(buf); +} + +static void P_InitGametype(void) +{ + UINT8 i; + + P_InitPlayers(); + + // restore time in netgame (see also g_game.c) + if ((netgame || multiplayer) && G_GametypeUsesCoopStarposts() && cv_coopstarposts.value == 2) + { + // is this a hack? maybe + tic_t maxstarposttime = 0; + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] && players[i].starposttime > maxstarposttime) + maxstarposttime = players[i].starposttime; + } + leveltime = maxstarposttime; + } + + P_WriteLetter(); + + if (modeattacking == ATTACKING_RECORD && !demoplayback) + P_LoadRecordGhosts(); + else if (modeattacking == ATTACKING_NIGHTS && !demoplayback) + P_LoadNightsGhosts(); + + if (G_TagGametype()) + P_InitTagGametype(); + else if (gametype == GT_RACE && server) + CV_StealthSetValue(&cv_numlaps, + (cv_basenumlaps.value) + ? cv_basenumlaps.value + : mapheaderinfo[gamemap - 1]->numlaps); } /** Loads a level from a lump or external wad. * - * \param skipprecip If true, don't spawn precipitation. + * \param fromnetsave If true, skip some stuff because we're loading a netgame snapshot. * \todo Clean up, refactor, split up; get rid of the bloat. */ -boolean P_SetupLevel(boolean skipprecip) +boolean P_LoadLevel(boolean fromnetsave) { // use gamemap to get map number. // 99% of the things already did, so. // Map header should always be in place at this point - INT32 i, loadprecip = 1, ranspecialwipe = 0; - INT32 loademblems = 1; - INT32 fromnetsave = 0; - boolean loadedbm = false; + INT32 i, ranspecialwipe = 0; sector_t *ss; - boolean chase; - levelloading = true; // This is needed. Don't touch. maptol = mapheaderinfo[gamemap-1]->typeoflevel; + gametyperules = gametypedefaultrules[gametype]; CON_Drawer(); // let the user know what we are going to do I_FinishUpdate(); // page flip or blit buffer - // Reset the palette if (rendermode != render_none) V_SetPaletteLump("PLAYPAL"); @@ -2696,25 +3422,25 @@ boolean P_SetupLevel(boolean skipprecip) if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); - P_LevelInitStuff(); + P_InitLevelSettings(); postimgtype = postimgtype2 = postimg_none; - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' - && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) + if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0') P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); - // chasecam on in chaos, race, coop - // chasecam off in match, tag, capture the flag - chase = (gametype == GT_RACE || gametype == GT_COMPETITION || gametype == GT_COOP) - || (maptol & TOL_2D); - if (!dedicated) { + // chasecam on in first-person gametypes and 2D + boolean chase = (!(gametyperules & GTR_FIRSTPERSON)) || (maptol & TOL_2D); + // Salt: CV_ClearChangedFlags() messes with your settings :( /*if (!cv_cam_speed.changed) CV_Set(&cv_cam_speed, cv_cam_speed.defaultvalue);*/ + CV_UpdateCamDist(); + CV_UpdateCam2Dist(); + if (!cv_chasecam.changed) CV_SetValue(&cv_chasecam, chase); @@ -2727,73 +3453,78 @@ boolean P_SetupLevel(boolean skipprecip) // will be set by player think. players[consoleplayer].viewz = 1; + // Cancel all d_main.c fadeouts (keep fade in though). + wipegamestate = FORCEWIPEOFF; + wipestyleflags = 0; + // Special stage fade to white // This is handled BEFORE sounds are stopped. - if (rendermode != render_none && G_IsSpecialStage(gamemap)) + if (modeattacking && !demoplayback && (pausedelay == INT32_MIN)) + ranspecialwipe = 2; + else if (rendermode != render_none && G_IsSpecialStage(gamemap)) { - tic_t starttime = I_GetTime(); - tic_t endtime = starttime + (3*TICRATE)/2; - tic_t nowtime; - - S_StartSound(NULL, sfx_s3kaf); - - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 0); - - F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_speclevel_towhite], false); - - nowtime = lastwipetic; - // Hold on white for extra effect. - while (nowtime < endtime) - { - // wait loop - while (!((nowtime = I_GetTime()) - lastwipetic)) - I_Sleep(); - lastwipetic = nowtime; - if (moviemode) // make sure we save frames for the white hold too - M_SaveFrame(); - } - + P_RunSpecialStageWipe(); ranspecialwipe = 1; } + if (G_GetModeAttackRetryFlag()) + { + if (modeattacking) + wipestyleflags |= (WSF_FADEOUT|WSF_TOWHITE); + G_ClearModeAttackRetryFlag(); + } + // Make sure all sounds are stopped before Z_FreeTags. S_StopSounds(); S_ClearSfx(); - // As oddly named as this is, this handles music only. - // We should be fine starting it here. - S_Start(); + // Fade out music here. Deduct 2 tics so the fade volume actually reaches 0. + // But don't halt the music! S_Start will take care of that. This dodges a MIDI crash bug. + if (!titlemapinaction && (RESETMUSIC || + strnicmp(S_MusicName(), + (mapmusflags & MUSIC_RELOADRESET) ? mapheaderinfo[gamemap-1]->musname : mapmusname, 7))) + S_FadeMusic(0, FixedMul( + FixedDiv((F_GetWipeLength(wipedefs[wipe_level_toblack])-2)*NEWTICRATERATIO, NEWTICRATE), MUSICRATE)); // Let's fade to black here // But only if we didn't do the special stage wipe if (rendermode != render_none && !ranspecialwipe) - { - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + P_RunLevelWipe(); - F_WipeEndScreen(); - F_RunWipe(wipedefs[wipe_level_toblack], false); + if (!titlemapinaction) + { + if (ranspecialwipe == 2) + { + pausedelay = -3; // preticker plus one + S_StartSound(NULL, sfx_s3k73); + } + + // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." + if (rendermode != render_none) + { + // Don't include these in the fade! + char tx[64]; + V_DrawSmallString(1, 191, V_ALLOWLOWERCASE|V_TRANSLUCENT|V_SNAPTOLEFT|V_SNAPTOBOTTOM, M_GetText("Speeding off to...")); + snprintf(tx, 63, "%s%s%s", + mapheaderinfo[gamemap-1]->lvlttl, + (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone", + (mapheaderinfo[gamemap-1]->actnum > 0) ? va(" %d",mapheaderinfo[gamemap-1]->actnum) : ""); + V_DrawSmallString(1, 195, V_ALLOWLOWERCASE|V_TRANSLUCENT|V_SNAPTOLEFT|V_SNAPTOBOTTOM, tx); + I_UpdateNoVsync(); + } + + // As oddly named as this is, this handles music only. + // We should be fine starting it here. + // Don't do this during titlemap, because the menu code handles music by itself. + S_Start(); } - // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." - if (rendermode != render_none) - { - // Don't include these in the fade! - char tx[64]; - V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); - snprintf(tx, 63, "%s%s%s", - mapheaderinfo[gamemap-1]->lvlttl, - (mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " ZONE", - (mapheaderinfo[gamemap-1]->actnum > 0) ? va(", Act %d",mapheaderinfo[gamemap-1]->actnum) : ""); - V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); - I_UpdateNoVsync(); - } + levelfadecol = (ranspecialwipe) ? 0 : 31; + + // Close text prompt before freeing the old level + F_EndTextPrompt(false, true); -#ifdef HAVE_BLUA LUA_InvalidateLevel(); -#endif for (ss = sectors; sectors+numsectors != ss; ss++) { @@ -2814,20 +3545,22 @@ boolean P_SetupLevel(boolean skipprecip) P_InitThinkers(); P_InitCachedActions(); - /// \note for not spawning precipitation, etc. when loading netgame snapshots - if (skipprecip) + if (!fromnetsave && savedata.lives > 0) { - fromnetsave = 1; - loadprecip = 0; - loademblems = 0; + numgameovers = savedata.numgameovers; + players[consoleplayer].continues = savedata.continues; + players[consoleplayer].lives = savedata.lives; + players[consoleplayer].score = savedata.score; + if ((botingame = ((botskin = savedata.botskin) != 0))) + botcolor = skins[botskin-1].prefcolor; + emeralds = savedata.emeralds; + savedata.lives = 0; } // internal game map maplumpname = G_BuildMapName(gamemap); - //lastloadedmaplumpnum = LUMPERROR; lastloadedmaplumpnum = W_CheckNumForName(maplumpname); - - if (lastloadedmaplumpnum == INT16_MAX) + if (lastloadedmaplumpnum == LUMPERROR) I_Error("Map %s not found.\n", maplumpname); R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette); @@ -2836,103 +3569,24 @@ boolean P_SetupLevel(boolean skipprecip) // SRB2 determines the sky texture to be used depending on the map header. P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); - P_MakeMapMD5(lastloadedmaplumpnum, &mapmd5); + P_ResetSpawnpoints(); - // HACK ALERT: Cache the WAD, get the map data into the tables, free memory. - // As it is implemented right now, we're assuming an uncompressed WAD. - // (As in, a normal PWAD, not ZWAD or anything. The lump itself can be compressed.) - // We're not accounting for extra lumps and scrambled lump positions. Any additional data will cause an error. - if (W_IsLumpWad(lastloadedmaplumpnum)) - { - // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - //filelump_t *fileinfo = wadData + ((wadinfo_t *)wadData)->infotableofs; - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - UINT32 numlumps = ((wadinfo_t *)wadData)->numlumps; + P_MapStart(); - if (numlumps < ML_REJECT) // at least 9 lumps should be in the wad for a map to be loaded - { - I_Error("Bad WAD file for map %s!\n", maplumpname); - } + if (!P_LoadMapFromFile()) + return false; - if (numlumps > ML_BLOCKMAP) // enough room for a BLOCKMAP lump at least - { - loadedbm = P_LoadRawBlockMap( - wadData + (fileinfo + ML_BLOCKMAP)->filepos, - (fileinfo + ML_BLOCKMAP)->size, - (fileinfo + ML_BLOCKMAP)->name); - } - P_LoadRawVertexes(wadData + (fileinfo + ML_VERTEXES)->filepos, (fileinfo + ML_VERTEXES)->size); - P_LoadRawSectors(wadData + (fileinfo + ML_SECTORS)->filepos, (fileinfo + ML_SECTORS)->size); - P_LoadRawSideDefs((fileinfo + ML_SIDEDEFS)->size); - P_LoadRawLineDefs(wadData + (fileinfo + ML_LINEDEFS)->filepos, (fileinfo + ML_LINEDEFS)->size); - P_LoadRawSideDefs2(wadData + (fileinfo + ML_SIDEDEFS)->filepos); - P_LoadRawSubsectors(wadData + (fileinfo + ML_SSECTORS)->filepos, (fileinfo + ML_SSECTORS)->size); - P_LoadRawNodes(wadData + (fileinfo + ML_NODES)->filepos, (fileinfo + ML_NODES)->size); - P_LoadRawSegs(wadData + (fileinfo + ML_SEGS)->filepos, (fileinfo + ML_SEGS)->size); - if (numlumps > ML_REJECT) // enough room for a REJECT lump at least - { - P_LoadRawReject( - wadData + (fileinfo + ML_REJECT)->filepos, - (fileinfo + ML_REJECT)->size, - (fileinfo + ML_REJECT)->name); - } - - // Important: take care of the ordering of the next functions. - if (!loadedbm) - P_CreateBlockMap(); // Graue 02-29-2004 - P_LoadLineDefs2(); - P_GroupLines(); - numdmstarts = numredctfstarts = numbluectfstarts = 0; - - // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; - P_MapStart(); - - P_PrepareRawThings(wadData + (fileinfo + ML_THINGS)->filepos, (fileinfo + ML_THINGS)->size); - Z_Free(wadData); - } - else - { - // Important: take care of the ordering of the next functions. - loadedbm = P_LoadBlockMap(lastloadedmaplumpnum + ML_BLOCKMAP); - P_LoadVertexes(lastloadedmaplumpnum + ML_VERTEXES); - P_LoadSectors(lastloadedmaplumpnum + ML_SECTORS); - P_LoadSideDefs(lastloadedmaplumpnum + ML_SIDEDEFS); - P_LoadLineDefs(lastloadedmaplumpnum + ML_LINEDEFS); - P_LoadSideDefs2(lastloadedmaplumpnum + ML_SIDEDEFS); - P_LoadSubsectors(lastloadedmaplumpnum + ML_SSECTORS); - P_LoadNodes(lastloadedmaplumpnum + ML_NODES); - P_LoadSegs(lastloadedmaplumpnum + ML_SEGS); - P_LoadReject(lastloadedmaplumpnum + ML_REJECT); - - // Important: take care of the ordering of the next functions. - if (!loadedbm) - P_CreateBlockMap(); // Graue 02-29-2004 - - P_LoadLineDefs2(); - P_GroupLines(); - numdmstarts = numredctfstarts = numbluectfstarts = 0; - - // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; - P_MapStart(); - P_PrepareThings(lastloadedmaplumpnum + ML_THINGS); - } + // init gravity, tag lists, + // anything that P_SpawnSlopes/P_LoadThings needs to know + P_InitSpecials(); #ifdef ESLOPE - P_ResetDynamicSlopes(); + P_SpawnSlopes(fromnetsave); #endif - P_LoadThings(); - - P_SpawnSecretItems(loademblems); + P_SpawnMapThings(!fromnetsave); + skyboxmo[0] = skyboxviewpnts[0]; + skyboxmo[1] = skyboxcenterpnts[0]; for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) if (!playerstarts[numcoopstarts]) @@ -2941,22 +3595,18 @@ boolean P_SetupLevel(boolean skipprecip) // set up world state P_SpawnSpecials(fromnetsave); - if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) + if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) P_SpawnPrecipitation(); - globalweather = mapheaderinfo[gamemap-1]->weather; - #ifdef HWRENDER // not win32 only 19990829 by Kin - if (rendermode != render_soft && rendermode != render_none) - { -#ifdef ALAM_LIGHTING - // BP: reset light between levels (we draw preview frame lights on current frame) - HWR_ResetLights(); -#endif - // Correct missing sidedefs & deep water trick - HWR_CorrectSWTricks(); - HWR_CreatePlanePolygons((INT32)numnodes - 1); - } + // Lactozilla: Free extrasubsectors regardless of renderer. + // Maybe we're not in OpenGL anymore. + if (extrasubsectors) + free(extrasubsectors); + extrasubsectors = NULL; + // stuff like HWR_CreatePlanePolygons is called there + if (rendermode == render_opengl) + HWR_SetupLevel(); #endif // oh god I hope this helps @@ -2964,136 +3614,10 @@ boolean P_SetupLevel(boolean skipprecip) // none of this needs to be done because it's not the beginning of the map when // a netgame save is being loaded, and could actively be harmful by messing with // the client's view of the data.) - if (fromnetsave) - goto netgameskip; - // ========== + if (!fromnetsave) + P_InitGametype(); - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - players[i].pflags &= ~PF_NIGHTSMODE; - - // Start players with pity shields if possible - players[i].pity = -1; - - if (!G_PlatformGametype()) - { - players[i].mo = NULL; - G_DoReborn(i); - } - else // gametype is GT_COOP or GT_RACE - { - players[i].mo = NULL; - - if (players[i].starposttime) - { - G_SpawnPlayer(i, true); - P_ClearStarPost(players[i].starpostnum); - } - else - G_SpawnPlayer(i, false); - } - } - - if (modeattacking == ATTACKING_RECORD && !demoplayback) - P_LoadRecordGhosts(); - else if (modeattacking == ATTACKING_NIGHTS && !demoplayback) - P_LoadNightsGhosts(); - - if (G_TagGametype()) - { - INT32 realnumplayers = 0; - INT32 playersactive[MAXPLAYERS]; - - //I just realized how problematic this code can be. - //D_NumPlayers() will not always cover the scope of the netgame. - //What if one player is node 0 and the other node 31? - //The solution? Make a temp array of all players that are currently playing and pick from them. - //Future todo? When a player leaves, shift all nodes down so D_NumPlayers() can be used as intended? - //Also, you'd never have to loop through all 32 players slots to find anything ever again. - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - { - playersactive[realnumplayers] = i; //stores the player's node in the array. - realnumplayers++; - } - } - - if (realnumplayers) //this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. - { - i = P_RandomKey(realnumplayers); - players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. - - // Taken and modified from G_DoReborn() - // Remove the player so he can respawn elsewhere. - // first dissasociate the corpse - if (players[playersactive[i]].mo) - P_RemoveMobj(players[playersactive[i]].mo); - - G_SpawnPlayer(playersactive[i], false); //respawn the lucky player in his dedicated spawn location. - } - else - CONS_Printf(M_GetText("No player currently available to become IT. Awaiting available players.\n")); - - } - else if (gametype == GT_RACE && server && cv_usemapnumlaps.value) - CV_StealthSetValue(&cv_numlaps, mapheaderinfo[gamemap - 1]->numlaps); - - // =========== - // landing point for netgames. - netgameskip: - - if (!dedicated) - { - P_SetupCamera(); - - // Salt: CV_ClearChangedFlags() messes with your settings :( - /*if (!cv_cam_height.changed) - CV_Set(&cv_cam_height, cv_cam_height.defaultvalue); - - if (!cv_cam_dist.changed) - CV_Set(&cv_cam_dist, cv_cam_dist.defaultvalue); - - if (!cv_cam2_height.changed) - CV_Set(&cv_cam2_height, cv_cam2_height.defaultvalue); - - if (!cv_cam2_dist.changed) - CV_Set(&cv_cam2_dist, cv_cam2_dist.defaultvalue);*/ - - // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P - if (!cv_cam_rotate.changed) - CV_Set(&cv_cam_rotate, cv_cam_rotate.defaultvalue); - - if (!cv_cam2_rotate.changed) - CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); - - if (!cv_analog.changed) - CV_SetValue(&cv_analog, 0); - if (!cv_analog2.changed) - CV_SetValue(&cv_analog2, 0); - -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - CV_Set(&cv_grfov, cv_grfov.defaultvalue); -#endif - - displayplayer = consoleplayer; // Start with your OWN view, please! - } - - if (cv_useranalog.value) - CV_SetValue(&cv_analog, true); - - if (splitscreen && cv_useranalog2.value) - CV_SetValue(&cv_analog2, true); - else if (botingame) - CV_SetValue(&cv_analog2, true); - - if (twodlevel) - { - CV_SetValue(&cv_analog2, false); - CV_SetValue(&cv_analog, false); - } + P_InitCamera(); // clear special respawning que iquehead = iquetail = 0; @@ -3101,50 +3625,34 @@ boolean P_SetupLevel(boolean skipprecip) // Fab : 19-07-98 : start cd music for this level (note: can be remapped) I_PlayCD((UINT8)(gamemap), false); - // preload graphics -#ifdef HWRENDER // not win32 only 19990829 by Kin - if (rendermode != render_soft && rendermode != render_none) - { - HWR_PrepLevelCache(numtextures); - } -#endif - P_MapEnd(); // Remove the loading shit from the screen - if (rendermode != render_none) - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (ranspecialwipe) ? 0 : 31); + if (rendermode != render_none && !titlemapinaction) + F_WipeColorFill(levelfadecol); if (precache || dedicated) R_PrecacheLevel(); nextmapoverride = 0; - skipstats = false; + skipstats = 0; if (!(netgame || multiplayer) && (!modifiedgame || savemoddata)) mapvisited[gamemap-1] |= MV_VISITED; + else + mapvisited[gamemap-1] |= MV_MP; // you want to record that you've been there this session, but not permanently levelloading = false; P_RunCachedActions(); - if (P_CanSave()) + if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || players[consoleplayer].lives <= 0) + && (!modifiedgame || savemoddata) && cursaveslot > 0 && CanSaveLevel(gamemap)) G_SaveGame((UINT32)cursaveslot); - if (savedata.lives > 0) - { - players[consoleplayer].continues = savedata.continues; - players[consoleplayer].lives = savedata.lives; - players[consoleplayer].score = savedata.score; - botskin = savedata.botskin; - botcolor = savedata.botcolor; - botingame = (savedata.botskin != 0); - emeralds = savedata.emeralds; - savedata.lives = 0; - } + lastmaploaded = gamemap; // HAS to be set after saving!! - skyVisible = skyVisible1 = skyVisible2 = true; // assume the skybox is visible on level load. - if (loadprecip) // uglier hack + if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. INT32 buf = gametic % BACKUPTICS; for (i = 0; i < MAXPLAYERS; i++) @@ -3153,14 +3661,53 @@ boolean P_SetupLevel(boolean skipprecip) G_CopyTiccmd(&players[i].cmd, &netcmds[buf][i], 1); } P_PreTicker(2); -#ifdef HAVE_BLUA LUAh_MapLoad(); -#endif } + // No render mode, stop here. + if (rendermode == render_none) + return true; + + // Title card! + G_StartTitleCard(); + + // Can the title card actually run, though? + if (!WipeStageTitle) + return true; + if (ranspecialwipe == 2) + return true; + + // If so... + G_PreLevelTitleCard(); + return true; } +#ifdef HWRENDER +void HWR_SetupLevel(void) +{ + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeMipmapCache(); + +#ifdef ALAM_LIGHTING + // BP: reset light between levels (we draw preview frame lights on current frame) + HWR_ResetLights(); +#endif + + // Correct missing sidedefs & deep water trick + HWR_CorrectSWTricks(); + HWR_CreatePlanePolygons((INT32)numnodes - 1); +} +#endif + // // P_RunSOC // @@ -3183,6 +3730,72 @@ boolean P_RunSOC(const char *socfilename) return true; } +// Auxiliary function for PK3 loading - looks for sound replacements. +// NOTE: it does not really add any new sound entry or anything. +void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num) +{ + size_t j; + lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo + first; + for (; num > 0; num--, lumpinfo++) + { + // Let's check whether it's replacing an existing sound or it's a brand new one. + for (j = 1; j < NUMSFX; j++) + { + if (S_sfx[j].name && !strnicmp(S_sfx[j].name, lumpinfo->name + 2, 6)) + { + // the sound will be reloaded when needed, + // since sfx->data will be NULL + CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", lumpinfo->name); + + I_FreeSfx(&S_sfx[j]); + break; // there shouldn't be two sounds with the same name, so stop looking + } + } + } +} + +// Auxiliary function for PK3 loading - looks for music and music replacements. +// NOTE: does nothing but print debug messages. The code is handled somewhere else. +void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num) +{ + lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo + first; + char *name; + for (; num > 0; num--, lumpinfo++) + { + name = lumpinfo->name; + if (name[0] == 'O' && name[1] == '_') + { + CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); + } + else if (name[0] == 'D' && name[1] == '_') + { + CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); + } + } + return; +} + +// Auxiliary function - input a folder name and gives us the resource markers positions. +static lumpinfo_t* FindFolder(const char *folName, UINT16 *start, UINT16 *end, lumpinfo_t *lumpinfo, UINT16 *pnumlumps, size_t *pi) +{ + UINT16 numlumps = *pnumlumps; + size_t i = *pi; + if (!stricmp(lumpinfo->name2, folName)) + { + lumpinfo++; + *start = ++i; + for (; i < numlumps; i++, lumpinfo++) + if (strnicmp(lumpinfo->name2, folName, strlen(folName))) + break; + lumpinfo--; + *end = i-- - *start; + *pi = i; + *pnumlumps = numlumps; + return lumpinfo; + } + return lumpinfo; +} + // // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps @@ -3193,59 +3806,105 @@ boolean P_AddWadFile(const char *wadfilename) UINT16 numlumps, wadnum; char *name; lumpinfo_t *lumpinfo; - boolean texturechange = false; + + //boolean texturechange = false; ///\todo Useless; broken when back-frontporting PK3 changes? boolean mapsadded = false; boolean replacedcurrentmap = false; - if ((numlumps = W_InitFile(wadfilename)) == INT16_MAX) + // Vars to help us with the position start and amount of each resource type. + // Useful for PK3s since they use folders. + // WADs use markers for some resources, but others such as sounds are checked lump-by-lump anyway. +// UINT16 luaPos, luaNum = 0; +// UINT16 socPos, socNum = 0; + UINT16 sfxPos = 0, sfxNum = 0; + UINT16 musPos = 0, musNum = 0; +// UINT16 sprPos, sprNum = 0; + UINT16 texPos = 0, texNum = 0; +// UINT16 patPos, patNum = 0; +// UINT16 flaPos, flaNum = 0; +// UINT16 mapPos, mapNum = 0; + + // Init file. + if ((numlumps = W_InitFile(wadfilename, false, false)) == INT16_MAX) { refreshdirmenu |= REFRESHDIR_NOTLOADED; - CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); return false; } - else wadnum = (UINT16)(numwadfiles-1); + else + wadnum = (UINT16)(numwadfiles-1); - // - // search for sound replacements - // - lumpinfo = wadfiles[wadnum]->lumpinfo; - for (i = 0; i < numlumps; i++, lumpinfo++) + switch(wadfiles[wadnum]->type) { - name = lumpinfo->name; - if (name[0] == 'D') + case RET_PK3: + // Look for the lumps that act as resource delimitation markers. + lumpinfo = wadfiles[wadnum]->lumpinfo; + for (i = 0; i < numlumps; i++, lumpinfo++) { - if (name[1] == 'S') for (j = 1; j < NUMSFX; j++) +// lumpinfo = FindFolder("Lua/", &luaPos, &luaNum, lumpinfo, &numlumps, &i); +// lumpinfo = FindFolder("SOC/", &socPos, &socNum, lumpinfo, &numlumps, &i); + lumpinfo = FindFolder("Sounds/", &sfxPos, &sfxNum, lumpinfo, &numlumps, &i); + lumpinfo = FindFolder("Music/", &musPos, &musNum, lumpinfo, &numlumps, &i); +// lumpinfo = FindFolder("Sprites/", &sprPos, &sprNum, lumpinfo, &numlumps, &i); + lumpinfo = FindFolder("Textures/", &texPos, &texNum, lumpinfo, &numlumps, &i); +// lumpinfo = FindFolder("Patches/", &patPos, &patNum, lumpinfo, &numlumps, &i); +// lumpinfo = FindFolder("Flats/", &flaPos, &flaNum, lumpinfo, &numlumps, &i); +// lumpinfo = FindFolder("Maps/", &mapPos, &mapNum, lumpinfo, &numlumps, &i); + } + + // Update the detected resources. + // Note: ALWAYS load Lua scripts first, SOCs right after, and the remaining resources afterwards. +// if (luaNum) // Lua scripts. +// P_LoadLuaScrRange(wadnum, luaPos, luaNum); +// if (socNum) // SOCs. +// P_LoadDehackRange(wadnum, socPos, socNum); + if (sfxNum) // Sounds. TODO: Function currently only updates already existing sounds, the rest is handled somewhere else. + P_LoadSoundsRange(wadnum, sfxPos, sfxNum); + if (musNum) // Music. TODO: Useless function right now. + P_LoadMusicsRange(wadnum, musPos, musNum); +// if (sprNum) // Sprites. +// R_LoadSpritsRange(wadnum, sprPos, sprNum); +// if (texNum) // Textures. TODO: R_LoadTextures() does the folder positioning once again. New function maybe? +// R_LoadTextures(); +// if (mapNum) // Maps. TODO: Actually implement the map WAD loading code, lulz. +// P_LoadWadMapRange(wadnum, mapPos, mapNum); + break; + default: + lumpinfo = wadfiles[wadnum]->lumpinfo; + for (i = 0; i < numlumps; i++, lumpinfo++) + { + name = lumpinfo->name; + if (name[0] == 'D') { - if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) + if (name[1] == 'S') { - // the sound will be reloaded when needed, - // since sfx->data will be NULL - CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); + for (j = 1; j < NUMSFX; j++) + { + if (S_sfx[j].name && !strnicmp(S_sfx[j].name, name + 2, 6)) + { + // the sound will be reloaded when needed, + // since sfx->data will be NULL + CONS_Debug(DBG_SETUP, "Sound %.8s replaced\n", name); - I_FreeSfx(&S_sfx[j]); + I_FreeSfx(&S_sfx[j]); - sreplaces++; + sreplaces++; + break; // there shouldn't be two sounds with the same name, so stop looking + } + } + } + else if (name[1] == '_') + { + CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); + mreplaces++; } } - else if (name[1] == '_') + else if (name[0] == 'O' && name[1] == '_') { CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); - mreplaces++; + digmreplaces++; } } - else if (name[0] == 'O' && name[1] == '_') - { - CONS_Debug(DBG_SETUP, "Music %.8s replaced\n", name); - digmreplaces++; - } -#if 0 - // - // search for texturechange replacements - // - else if (!memcmp(name, "TEXTURE1", 8) || !memcmp(name, "TEXTURE2", 8) - || !memcmp(name, "PNAMES", 6)) -#endif - texturechange = true; + break; } if (!devparm && sreplaces) CONS_Printf(M_GetText("%s sounds replaced\n"), sizeu1(sreplaces)); @@ -3262,25 +3921,28 @@ boolean P_AddWadFile(const char *wadfilename) // Reload it all anyway, just in case they // added some textures but didn't insert a - // TEXTURE1/PNAMES/etc. list. - if (texturechange) // initialized in the sound check - R_LoadTextures(); // numtexture changes - else - R_FlushTextureCache(); // just reload it from file + // TEXTURES/etc. list. + R_LoadTextures(); // numtexture changes - // Reload ANIMATED / ANIMDEFS + // Reload ANIMDEFS P_InitPicAnims(); // Flush and reload HUD graphics ST_UnloadGraphics(); HU_LoadGraphics(); ST_LoadGraphics(); - ST_ReloadSkinFaceGraphics(); // // look for skins // R_AddSkins(wadnum); // faB: wadfile index in wadfiles[] + R_PatchSkins(wadnum); // toast: PATCH PATCH + ST_ReloadSkinFaceGraphics(); + + // + // edit music defs + // + S_LoadMusicDefs(wadnum); // // search for maps @@ -3289,7 +3951,6 @@ boolean P_AddWadFile(const char *wadfilename) for (i = 0; i < numlumps; i++, lumpinfo++) { name = lumpinfo->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P') // Ignore the headers { INT16 num; @@ -3308,13 +3969,19 @@ boolean P_AddWadFile(const char *wadfilename) if (!mapsadded) CONS_Printf(M_GetText("No maps added\n")); + R_LoadSpriteInfoLumps(wadnum, numlumps); + +#ifdef HWRENDER + HWR_ReloadModels(); +#endif + // reload status bar (warning should have valid player!) if (gamestate == GS_LEVEL) ST_Start(); // Prevent savefile cheating - if (cursaveslot >= 0) - cursaveslot = -1; + if (cursaveslot > 0) + cursaveslot = 0; if (replacedcurrentmap && gamestate == GS_LEVEL && (netgame || multiplayer)) { @@ -3325,31 +3992,3 @@ boolean P_AddWadFile(const char *wadfilename) return true; } - -#ifdef DELFILE -boolean P_DelWadFile(void) -{ - sfxenum_t i; - const UINT16 wadnum = (UINT16)(numwadfiles - 1); - const lumpnum_t lumpnum = numwadfiles<<16; - //lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo; - R_DelSkins(wadnum); // only used by DELFILE - R_DelSpriteDefs(wadnum); // only used by DELFILE - for (i = 0; i < NUMSFX; i++) - { - if (S_sfx[i].lumpnum != LUMPERROR && S_sfx[i].lumpnum >= lumpnum) - { - S_StopSoundByNum(i); - S_RemoveSoundFx(i); - if (S_sfx[i].lumpnum != LUMPERROR) - { - I_FreeSfx(&S_sfx[i]); - S_sfx[i].lumpnum = LUMPERROR; - } - } - } - W_UnloadWadFile(wadnum); // only used by DELFILE - R_LoadTextures(); - return false; -} -#endif diff --git a/src/p_setup.h b/src/p_setup.h index 41c2bf133..e7150c0ae 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,21 +27,60 @@ extern mapthing_t *deathmatchstarts[MAX_DM_STARTS]; extern INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts; extern boolean levelloading; +extern UINT8 levelfadecol; extern lumpnum_t lastloadedmaplumpnum; // for comparative savegame + +/* for levelflat type */ +enum +{ + LEVELFLAT_NONE,/* HOM time my friend */ + LEVELFLAT_FLAT, + LEVELFLAT_PATCH, +#ifndef NO_PNG_LUMPS + LEVELFLAT_PNG, +#endif + LEVELFLAT_TEXTURE, +}; + // // MAP used flats lookup table // typedef struct { char name[9]; // resource name from wad - lumpnum_t lumpnum; // lump number of the flat + + UINT8 type; + union + { + struct + { + lumpnum_t lumpnum; // lump number of the flat + // for flat animation + lumpnum_t baselumpnum; + } + flat; + struct + { + INT32 num; + INT32 lastnum; // texture number of the flat + // for flat animation + INT32 basenum; + } + texture; + } + u; + + UINT16 width, height; + fixed_t topoffset, leftoffset; // for flat animation - lumpnum_t baselumpnum; INT32 animseq; // start pos. in the anim sequence INT32 numpics; INT32 speed; + + // for patchflats + UINT8 *flatpatch; } levelflat_t; extern size_t numlevelflats; @@ -57,19 +96,25 @@ void P_SetupLevelSky(INT32 skynum, boolean global); #ifdef SCANTHINGS void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); #endif -void P_LoadThingsOnly(void); -boolean P_SetupLevel(boolean skipprecip); -boolean P_AddWadFile(const char *wadfilename); -#ifdef DELFILE -boolean P_DelWadFile(void); +void P_RespawnThings(void); +boolean P_LoadLevel(boolean fromnetsave); +#ifdef HWRENDER +void HWR_SetupLevel(void); #endif +boolean P_AddWadFile(const char *wadfilename); boolean P_RunSOC(const char *socfilename); +void P_LoadSoundsRange(UINT16 wadnum, UINT16 first, UINT16 num); +void P_LoadMusicsRange(UINT16 wadnum, UINT16 first, UINT16 num); void P_WriteThings(lumpnum_t lump); size_t P_PrecacheLevelFlats(void); void P_AllocMapHeader(INT16 i); +void P_SetDemoFlickies(INT16 i); +void P_DeleteFlickies(INT16 i); + // Needed for NiGHTS void P_ReloadRings(void); +void P_SwitchSpheresBonusMode(boolean bonustime); void P_DeleteGrades(INT16 i); void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext); UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare); diff --git a/src/p_sight.c b/src/p_sight.c index 626f8bbef..4ea14cca0 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -14,6 +14,7 @@ #include "doomdef.h" #include "doomstat.h" #include "p_local.h" +#include "p_slopes.h" #include "r_main.h" #include "r_state.h" @@ -103,12 +104,20 @@ static fixed_t P_InterceptVector2(divline_t *v2, divline_t *v1) static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) { size_t i; + sector_t *polysec; + + if (!(po->flags & POF_RENDERALL)) + return true; // the polyobject isn't visible, so we can ignore it + + polysec = po->lines[0]->backsector; for (i = 0; i < po->numLines; ++i) { line_t *line = po->lines[i]; divline_t divl; const vertex_t *v1,*v2; + fixed_t frac; + fixed_t topslope, bottomslope; // already checked other side? if (line->validcount == validcount) @@ -140,7 +149,22 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) continue; // stop because it is not two sided - return false; + //if (!(po->flags & POF_TESTHEIGHT)) + //return false; + + frac = P_InterceptVector2(&los->strace, &divl); + + // get slopes of top and bottom of this polyobject line + topslope = FixedDiv(polysec->ceilingheight - los->sightzstart , frac); + bottomslope = FixedDiv(polysec->floorheight - los->sightzstart , frac); + + if (topslope >= los->topslope && bottomslope <= los->bottomslope) + return false; // view completely blocked + + // TODO: figure out if it's worth considering partially blocked cases or not? + // maybe to adjust los's top/bottom slopes if needed + //if (los->topslope <= los->bottomslope) + //return false; } return true; @@ -193,6 +217,13 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) const sector_t *front, *back; const vertex_t *v1,*v2; fixed_t frac; + fixed_t frontf, backf, frontc, backc; +#ifdef ESLOPE + fixed_t fracx, fracy; +#endif + + if (seg->glseg) + continue; // already checked other side? if (line->validcount == validcount) @@ -227,36 +258,51 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) if (!(line->flags & ML_TWOSIDED)) return false; + // calculate fractional intercept (how far along we are divided by how far we are from t2) + frac = P_InterceptVector2(&los->strace, &divl); + + front = seg->frontsector; + back = seg->backsector; +#ifdef ESLOPE + // calculate position at intercept + fracx = los->strace.x + FixedMul(los->strace.dx, frac); + fracy = los->strace.y + FixedMul(los->strace.dy, frac); + // calculate sector heights + frontf = (front->f_slope) ? P_GetZAt(front->f_slope, fracx, fracy) : front->floorheight; + frontc = (front->c_slope) ? P_GetZAt(front->c_slope, fracx, fracy) : front->ceilingheight; + backf = (back->f_slope) ? P_GetZAt(back->f_slope, fracx, fracy) : back->floorheight; + backc = (back->c_slope) ? P_GetZAt(back->c_slope, fracx, fracy) : back->ceilingheight; +#else + frontf = front->floorheight; + frontc = front->ceilingheight; + backf = back->floorheight; + backc = back->ceilingheight; +#endif // crosses a two sided line // no wall to block sight with? - if ((front = seg->frontsector)->floorheight == - (back = seg->backsector)->floorheight && - front->ceilingheight == back->ceilingheight) + if (frontf == backf && frontc == backc + && !front->ffloors & !back->ffloors) // (and no FOFs) continue; // possible occluder // because of ceiling height differences - popentop = front->ceilingheight < back->ceilingheight ? - front->ceilingheight : back->ceilingheight ; + popentop = min(frontc, backc); // because of floor height differences - popenbottom = front->floorheight > back->floorheight ? - front->floorheight : back->floorheight ; + popenbottom = max(frontf, backf); // quick test for totally closed doors if (popenbottom >= popentop) return false; - frac = P_InterceptVector2(&los->strace, &divl); - - if (front->floorheight != back->floorheight) + if (frontf != backf) { fixed_t slope = FixedDiv(popenbottom - los->sightzstart , frac); if (slope > los->bottomslope) los->bottomslope = slope; } - if (front->ceilingheight != back->ceilingheight) + if (frontc != backc) { fixed_t slope = FixedDiv(popentop - los->sightzstart , frac); if (slope < los->topslope) @@ -265,6 +311,58 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) if (los->topslope <= los->bottomslope) return false; + + // Monster Iestyn: check FOFs! + if (front->ffloors || back->ffloors) + { + ffloor_t *rover; + fixed_t topslope, bottomslope; + fixed_t topz, bottomz; + // check front sector's FOFs first + for (rover = front->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) + || !(rover->flags & FF_RENDERSIDES) || rover->flags & FF_TRANSLUCENT) + { + continue; + } + +#ifdef ESLOPE + topz = (*rover->t_slope) ? P_GetZAt(*rover->t_slope, fracx, fracy) : *rover->topheight; + bottomz = (*rover->b_slope) ? P_GetZAt(*rover->b_slope, fracx, fracy) : *rover->bottomheight; +#else + topz = *rover->topheight; + bottomz = *rover->bottomheight; +#endif + topslope = FixedDiv(topz - los->sightzstart , frac); + bottomslope = FixedDiv(bottomz - los->sightzstart , frac); + if (topslope >= los->topslope && bottomslope <= los->bottomslope) + return false; // view completely blocked + } + // check back sector's FOFs as well + for (rover = back->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) + || !(rover->flags & FF_RENDERSIDES) || rover->flags & FF_TRANSLUCENT) + { + continue; + } + +#ifdef ESLOPE + topz = (*rover->t_slope) ? P_GetZAt(*rover->t_slope, fracx, fracy) : *rover->topheight; + bottomz = (*rover->b_slope) ? P_GetZAt(*rover->b_slope, fracx, fracy) : *rover->bottomheight; +#else + topz = *rover->topheight; + bottomz = *rover->bottomheight; +#endif + topslope = FixedDiv(topz - los->sightzstart , frac); + bottomslope = FixedDiv(bottomz - los->sightzstart , frac); + if (topslope >= los->topslope && bottomslope <= los->bottomslope) + return false; // view completely blocked + } + // TODO: figure out if it's worth considering partially blocked cases or not? + // maybe to adjust los's top/bottom slopes if needed + } } // passed the subsector ok @@ -375,6 +473,8 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) if (s1 == s2) // Both sectors are the same. { ffloor_t *rover; + fixed_t topz1, bottomz1; // top, bottom heights at t1's position + fixed_t topz2, bottomz2; // likewise but for t2 for (rover = s1->ffloors; rover; rover = rover->next) { @@ -387,9 +487,30 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) continue; } +#ifdef ESLOPE + if (*rover->t_slope) + { + topz1 = P_GetZAt(*rover->t_slope, t1->x, t1->y); + topz2 = P_GetZAt(*rover->t_slope, t2->x, t2->y); + } + else + topz1 = topz2 = *rover->topheight; + + if (*rover->b_slope) + { + bottomz1 = P_GetZAt(*rover->b_slope, t1->x, t1->y); + bottomz2 = P_GetZAt(*rover->b_slope, t2->x, t2->y); + } + else + bottomz1 = bottomz2 = *rover->bottomheight; +#else + topz1 = topz2 = *rover->topheight; + bottomz1 = bottomz2 = *rover->bottomheight; +#endif + // Check for blocking floors here. - if ((los.sightzstart < *rover->bottomheight && t2->z >= *rover->topheight) - || (los.sightzstart >= *rover->topheight && t2->z + t2->height < *rover->bottomheight)) + if ((los.sightzstart < bottomz1 && t2->z >= topz2) + || (los.sightzstart >= topz1 && t2->z + t2->height < bottomz2)) { // no way to see through that return false; @@ -400,19 +521,19 @@ boolean P_CheckSight(mobj_t *t1, mobj_t *t2) if (!(rover->flags & FF_INVERTPLANES)) { - if (los.sightzstart >= *rover->topheight && t2->z + t2->height < *rover->topheight) + if (los.sightzstart >= topz1 && t2->z + t2->height < topz2) return false; // blocked by upper outside plane - if (los.sightzstart < *rover->bottomheight && t2->z >= *rover->bottomheight) + if (los.sightzstart < bottomz1 && t2->z >= bottomz2) return false; // blocked by lower outside plane } if (rover->flags & FF_INVERTPLANES || rover->flags & FF_BOTHPLANES) { - if (los.sightzstart < *rover->topheight && t2->z >= *rover->topheight) + if (los.sightzstart < topz1 && t2->z >= topz2) return false; // blocked by upper inside plane - if (los.sightzstart >= *rover->bottomheight && t2->z + t2->height < *rover->bottomheight) + if (los.sightzstart >= bottomz1 && t2->z + t2->height < bottomz2) return false; // blocked by lower inside plane } } diff --git a/src/p_slopes.c b/src/p_slopes.c index 68767b50c..e275964e3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2004 by Stephen McGranahan -// Copyright (C) 2015-2018 by Sonic Team Junior. +// Copyright (C) 2015-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -25,68 +25,66 @@ #ifdef ESLOPE -static pslope_t *slopelist = NULL; -static UINT16 slopecount = 0; +pslope_t *slopelist = NULL; +UINT16 slopecount = 0; // Calculate line normal void P_CalculateSlopeNormal(pslope_t *slope) { slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); - slope->normal.x = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x); - slope->normal.y = -FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y); + slope->normal.x = FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x); + slope->normal.y = FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y); } -// With a vertex slope that has its vertices set, configure relevant slope info -static void P_ReconfigureVertexSlope(pslope_t *slope) +/// Setup slope via 3 vertexes. +static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const vector3_t v2, const vector3_t v3) { vector3_t vec1, vec2; - // Set slope normal - vec1.x = (slope->vertices[1]->x - slope->vertices[0]->x) << FRACBITS; - vec1.y = (slope->vertices[1]->y - slope->vertices[0]->y) << FRACBITS; - vec1.z = (slope->vertices[1]->z - slope->vertices[0]->z) << FRACBITS; + // Set origin. + FV3_Copy(&slope->o, &v1); - vec2.x = (slope->vertices[2]->x - slope->vertices[0]->x) << FRACBITS; - vec2.y = (slope->vertices[2]->y - slope->vertices[0]->y) << FRACBITS; - vec2.z = (slope->vertices[2]->z - slope->vertices[0]->z) << FRACBITS; + // Get slope's normal. + FV3_SubEx(&v2, &v1, &vec1); + FV3_SubEx(&v3, &v1, &vec2); - // ugggggggh fixed-point maaaaaaath - slope->extent = max( - max(max(abs(vec1.x), abs(vec1.y)), abs(vec1.z)), - max(max(abs(vec2.x), abs(vec2.y)), abs(vec2.z)) - ) >> (FRACBITS+5); - vec1.x /= slope->extent; - vec1.y /= slope->extent; - vec1.z /= slope->extent; - vec2.x /= slope->extent; - vec2.y /= slope->extent; - vec2.z /= slope->extent; - - FV3_Cross(&vec1, &vec2, &slope->normal); - - slope->extent = R_PointToDist2(0, 0, R_PointToDist2(0, 0, slope->normal.x, slope->normal.y), slope->normal.z); - if (slope->normal.z < 0) - slope->extent = -slope->extent; - - slope->normal.x = FixedDiv(slope->normal.x, slope->extent); - slope->normal.y = FixedDiv(slope->normal.y, slope->extent); - slope->normal.z = FixedDiv(slope->normal.z, slope->extent); - - // Set origin - slope->o.x = slope->vertices[0]->x << FRACBITS; - slope->o.y = slope->vertices[0]->y << FRACBITS; - slope->o.z = slope->vertices[0]->z << FRACBITS; - - if (slope->normal.x == 0 && slope->normal.y == 0) { // Set some defaults for a non-sloped "slope" + // Set some defaults for a non-sloped "slope" + if (vec1.z == 0 && vec2.z == 0) + { slope->zangle = slope->xydirection = 0; slope->zdelta = slope->d.x = slope->d.y = 0; - } else { + slope->normal.x = slope->normal.y = 0; + slope->normal.z = FRACUNIT; + } + else + { + /// \note Using fixed point for vectorial products easily leads to overflows so we work around by downscaling them. + fixed_t m = max( + max(max(abs(vec1.x), abs(vec1.y)), abs(vec1.z)), + max(max(abs(vec2.x), abs(vec2.y)), abs(vec2.z)) + ) >> 5; // shifting right by 5 is good enough. + + FV3_Cross( + FV3_Divide(&vec1, m), + FV3_Divide(&vec2, m), + &slope->normal + ); + + // NOTE: FV3_Magnitude() doesn't work properly in some cases, and chaining FixedHypot() seems to give worse results. + m = R_PointToDist2(0, 0, R_PointToDist2(0, 0, slope->normal.x, slope->normal.y), slope->normal.z); + + // Invert normal if it's facing down. + if (slope->normal.z < 0) + m = -m; + + FV3_Divide(&slope->normal, m); + // Get direction vector - slope->extent = R_PointToDist2(0, 0, slope->normal.x, slope->normal.y); - slope->d.x = -FixedDiv(slope->normal.x, slope->extent); - slope->d.y = -FixedDiv(slope->normal.y, slope->extent); + m = FixedHypot(slope->normal.x, slope->normal.y); + slope->d.x = -FixedDiv(slope->normal.x, m); + slope->d.y = -FixedDiv(slope->normal.y, m); // Z delta - slope->zdelta = FixedDiv(slope->extent, slope->normal.z); + slope->zdelta = FixedDiv(m, slope->normal.z); // Get angles slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180; @@ -94,88 +92,95 @@ static void P_ReconfigureVertexSlope(pslope_t *slope) } } -// Recalculate dynamic slopes -void P_RunDynamicSlopes(void) { - pslope_t *slope; +/// Recalculate dynamic slopes. +void T_DynamicSlopeLine (dynplanethink_t* th) +{ + pslope_t* slope = th->slope; + line_t* srcline = th->sourceline; - for (slope = slopelist; slope; slope = slope->next) { - fixed_t zdelta; + fixed_t zdelta; - if (slope->flags & SL_NODYNAMIC) - continue; + switch(th->type) { + case DP_FRONTFLOOR: + zdelta = srcline->backsector->floorheight - srcline->frontsector->floorheight; + slope->o.z = srcline->frontsector->floorheight; + break; - switch(slope->refpos) { - case 1: // front floor - zdelta = slope->sourceline->backsector->floorheight - slope->sourceline->frontsector->floorheight; - slope->o.z = slope->sourceline->frontsector->floorheight; - break; - case 2: // front ceiling - zdelta = slope->sourceline->backsector->ceilingheight - slope->sourceline->frontsector->ceilingheight; - slope->o.z = slope->sourceline->frontsector->ceilingheight; - break; - case 3: // back floor - zdelta = slope->sourceline->frontsector->floorheight - slope->sourceline->backsector->floorheight; - slope->o.z = slope->sourceline->backsector->floorheight; - break; - case 4: // back ceiling - zdelta = slope->sourceline->frontsector->ceilingheight - slope->sourceline->backsector->ceilingheight; - slope->o.z = slope->sourceline->backsector->ceilingheight; - break; - case 5: // vertices - { - mapthing_t *mt; - size_t i; - INT32 l; - line_t *line; + case DP_FRONTCEIL: + zdelta = srcline->backsector->ceilingheight - srcline->frontsector->ceilingheight; + slope->o.z = srcline->frontsector->ceilingheight; + break; - for (i = 0; i < 3; i++) { - mt = slope->vertices[i]; - l = P_FindSpecialLineFromTag(799, mt->angle, -1); - if (l != -1) { - line = &lines[l]; - mt->z = line->frontsector->floorheight >> FRACBITS; - } - } + case DP_BACKFLOOR: + zdelta = srcline->frontsector->floorheight - srcline->backsector->floorheight; + slope->o.z = srcline->backsector->floorheight; + break; - P_ReconfigureVertexSlope(slope); - } - continue; // TODO + case DP_BACKCEIL: + zdelta = srcline->frontsector->ceilingheight - srcline->backsector->ceilingheight; + slope->o.z = srcline->backsector->ceilingheight; + break; - default: - I_Error("P_RunDynamicSlopes: slope has invalid type!"); - } + default: + return; + } - if (slope->zdelta != FixedDiv(zdelta, slope->extent)) { - slope->zdelta = FixedDiv(zdelta, slope->extent); - slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta); - P_CalculateSlopeNormal(slope); - } + if (slope->zdelta != FixedDiv(zdelta, th->extent)) { + slope->zdelta = FixedDiv(zdelta, th->extent); + slope->zangle = R_PointToAngle2(0, 0, th->extent, -zdelta); + P_CalculateSlopeNormal(slope); } } -// -// P_MakeSlope -// -// Alocates and fill the contents of a slope structure. -// -static pslope_t *P_MakeSlope(const vector3_t *o, const vector2_t *d, - const fixed_t zdelta, UINT8 flags) +/// Mapthing-defined +void T_DynamicSlopeVert (dynplanethink_t* th) { - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); + pslope_t* slope = th->slope; - ret->o.x = o->x; - ret->o.y = o->y; - ret->o.z = o->z; + size_t i; + INT32 l; - ret->d.x = d->x; - ret->d.y = d->y; + for (i = 0; i < 3; i++) { + l = P_FindSpecialLineFromTag(799, th->tags[i], -1); + if (l != -1) { + th->vex[i].z = lines[l].frontsector->floorheight; + } + else + th->vex[i].z = 0; + } - ret->zdelta = zdelta; + ReconfigureViaVertexes(slope, th->vex[0], th->vex[1], th->vex[2]); +} +static inline void P_AddDynSlopeThinker (pslope_t* slope, dynplanetype_t type, line_t* sourceline, fixed_t extent, const INT16 tags[3], const vector3_t vx[3]) +{ + dynplanethink_t* th = Z_Calloc(sizeof (*th), PU_LEVSPEC, NULL); + switch (type) + { + case DP_VERTEX: + th->thinker.function.acp1 = (actionf_p1)T_DynamicSlopeVert; + memcpy(th->tags, tags, sizeof(th->tags)); + memcpy(th->vex, vx, sizeof(th->vex)); + break; + default: + th->thinker.function.acp1 = (actionf_p1)T_DynamicSlopeLine; + th->sourceline = sourceline; + th->extent = extent; + } + + th->slope = slope; + th->type = type; + + P_AddThinker(THINK_DYNSLOPE, &th->thinker); +} + + +/// Create a new slope and add it to the slope list. +static inline pslope_t* Slope_Add (const UINT8 flags) +{ + pslope_t *ret = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); ret->flags = flags; - // Add to the slope list ret->next = slopelist; slopelist = ret; @@ -185,13 +190,24 @@ static pslope_t *P_MakeSlope(const vector3_t *o, const vector2_t *d, return ret; } -// -// P_GetExtent -// -// Returns the distance to the first line within the sector that -// is intersected by a line parallel to the plane normal with the point (ox, oy) -// -static fixed_t P_GetExtent(sector_t *sector, line_t *line) +/// Alocates and fill the contents of a slope structure. +static pslope_t *MakeViaVectors(const vector3_t *o, const vector2_t *d, + const fixed_t zdelta, UINT8 flags) +{ + pslope_t *ret = Slope_Add(flags); + + FV3_Copy(&ret->o, o); + FV2_Copy(&ret->d, d); + + ret->zdelta = zdelta; + + ret->flags = flags; + + return ret; +} + +/// Get furthest perpendicular distance from all vertexes in a sector for a given line. +static fixed_t GetExtent(sector_t *sector, line_t *line) { // ZDoom code reference: v3float_t = vertex_t fixed_t fardist = -FRACUNIT; @@ -224,14 +240,8 @@ static fixed_t P_GetExtent(sector_t *sector, line_t *line) return fardist; } - -// -// P_SpawnSlope_Line -// -// Creates one or more slopes based on the given line type and front/back -// sectors. -// -void P_SpawnSlope_Line(int linenum) +/// Creates one or more slopes based on the given line type and front/back sectors. +static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) { // With dynamic slopes, it's fine to just leave this function as normal, // because checking to see if a slope had changed will waste more memory than @@ -249,12 +259,10 @@ void P_SpawnSlope_Line(int linenum) boolean backceil = (special == 711 || special == 712 || special == 703); UINT8 flags = 0; // Slope flags - if (line->flags & ML_NOSONIC) + if (line->flags & ML_NETONLY) flags |= SL_NOPHYSICS; - if (line->flags & ML_NOTAILS) - flags |= SL_NODYNAMIC; - if (line->flags & ML_NOKNUX) - flags |= SL_ANCHORVERTEX; + if (line->flags & ML_NONET) + flags |= SL_DYNAMIC; if(!frontfloor && !backfloor && !frontceil && !backceil) { @@ -264,7 +272,7 @@ void P_SpawnSlope_Line(int linenum) if(!line->frontsector || !line->backsector) { - CONS_Printf("P_SpawnSlope_Line used on a line without two sides.\n"); + CONS_Debug(DBG_SETUP, "P_SpawnSlope_Line used on a line without two sides. (line number %i)\n", linenum); return; } @@ -274,6 +282,7 @@ void P_SpawnSlope_Line(int linenum) ny = -FixedDiv(line->dx, len); } + // Set origin to line's center. origin.x = line->v1->x + (line->v2->x - line->v1->x)/2; origin.y = line->v1->y + (line->v2->y - line->v1->y)/2; @@ -286,7 +295,7 @@ void P_SpawnSlope_Line(int linenum) direction.x = nx; direction.y = ny; - extent = P_GetExtent(line->frontsector, line); + extent = GetExtent(line->frontsector, line); if(extent < 0) { @@ -304,104 +313,43 @@ void P_SpawnSlope_Line(int linenum) if(frontfloor) { - fixed_t highest, lowest; - size_t l; point.z = line->frontsector->floorheight; // Startz dz = FixedDiv(origin.z - point.z, extent); // Destinationz // In P_SpawnSlopeLine the origin is the centerpoint of the sourcelinedef fslope = line->frontsector->f_slope = - P_MakeSlope(&point, &direction, dz, flags); - - // Set up some shit - fslope->extent = extent; - fslope->refpos = 1; + MakeViaVectors(&point, &direction, dz, flags); // Now remember that f_slope IS a vector // fslope->o = origin 3D point 1 of the vector // fslope->d = destination 3D point 2 of the vector // fslope->normal is a 3D line perpendicular to the 3D vector - // Sync the linedata of the line that started this slope - // TODO: Anything special for control sector based slopes later? - fslope->sourceline = line; - - // To find the real highz/lowz of a slope, you need to check all the vertexes - // in the slope's sector with P_GetZAt to get the REAL lowz & highz - // Although these slopes are set by floorheights the ANGLE is what a slope is, - // so technically any slope can extend on forever (they are just bound by sectors) - // *You can use sourceline as a reference to see if two slopes really are the same - - // Default points for high and low - highest = point.z > origin.z ? point.z : origin.z; - lowest = point.z < origin.z ? point.z : origin.z; - - // Now check to see what the REAL high and low points of the slope inside the sector - // TODO: Is this really needed outside of FOFs? -Red - - for (l = 0; l < line->frontsector->linecount; l++) - { - fixed_t height = P_GetZAt(line->frontsector->f_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); - - if (height > highest) - highest = height; - - if (height < lowest) - lowest = height; - } - - // Sets extra clipping data for the frontsector's slope - fslope->highz = highest; - fslope->lowz = lowest; - fslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(fslope); + + if (spawnthinker && (flags & SL_DYNAMIC)) + P_AddDynSlopeThinker(fslope, DP_FRONTFLOOR, line, extent, NULL, NULL); } if(frontceil) { - fixed_t highest, lowest; - size_t l; origin.z = line->backsector->ceilingheight; point.z = line->frontsector->ceilingheight; dz = FixedDiv(origin.z - point.z, extent); cslope = line->frontsector->c_slope = - P_MakeSlope(&point, &direction, dz, flags); - - // Set up some shit - cslope->extent = extent; - cslope->refpos = 2; - - // Sync the linedata of the line that started this slope - // TODO: Anything special for control sector based slopes later? - cslope->sourceline = line; - - // Remember the way the slope is formed - highest = point.z > origin.z ? point.z : origin.z; - lowest = point.z < origin.z ? point.z : origin.z; - - for (l = 0; l < line->frontsector->linecount; l++) - { - fixed_t height = P_GetZAt(line->frontsector->c_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); - - if (height > highest) - highest = height; - - if (height < lowest) - lowest = height; - } - - // This line special sets extra clipping data for the frontsector's slope - cslope->highz = highest; - cslope->lowz = lowest; + MakeViaVectors(&point, &direction, dz, flags); cslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(cslope); + + if (spawnthinker && (flags & SL_DYNAMIC)) + P_AddDynSlopeThinker(cslope, DP_FRONTCEIL, line, extent, NULL, NULL); } } if(backfloor || backceil) @@ -413,7 +361,7 @@ void P_SpawnSlope_Line(int linenum) direction.x = -nx; direction.y = -ny; - extent = P_GetExtent(line->backsector, line); + extent = GetExtent(line->backsector, line); if(extent < 0) { @@ -429,88 +377,36 @@ void P_SpawnSlope_Line(int linenum) if(backfloor) { - fixed_t highest, lowest; - size_t l; point.z = line->backsector->floorheight; dz = FixedDiv(origin.z - point.z, extent); fslope = line->backsector->f_slope = - P_MakeSlope(&point, &direction, dz, flags); - - // Set up some shit - fslope->extent = extent; - fslope->refpos = 3; - - // Sync the linedata of the line that started this slope - // TODO: Anything special for control sector based slopes later? - fslope->sourceline = line; - - // Remember the way the slope is formed - highest = point.z > origin.z ? point.z : origin.z; - lowest = point.z < origin.z ? point.z : origin.z; - - for (l = 0; l < line->backsector->linecount; l++) - { - fixed_t height = P_GetZAt(line->backsector->f_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); - - if (height > highest) - highest = height; - - if (height < lowest) - lowest = height; - } - - // This line special sets extra clipping data for the frontsector's slope - fslope->highz = highest; - fslope->lowz = lowest; + MakeViaVectors(&point, &direction, dz, flags); fslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(fslope); + + if (spawnthinker && (flags & SL_DYNAMIC)) + P_AddDynSlopeThinker(fslope, DP_BACKFLOOR, line, extent, NULL, NULL); } if(backceil) { - fixed_t highest, lowest; - size_t l; origin.z = line->frontsector->ceilingheight; point.z = line->backsector->ceilingheight; dz = FixedDiv(origin.z - point.z, extent); cslope = line->backsector->c_slope = - P_MakeSlope(&point, &direction, dz, flags); - - // Set up some shit - cslope->extent = extent; - cslope->refpos = 4; - - // Sync the linedata of the line that started this slope - // TODO: Anything special for control sector based slopes later? - cslope->sourceline = line; - - // Remember the way the slope is formed - highest = point.z > origin.z ? point.z : origin.z; - lowest = point.z < origin.z ? point.z : origin.z; - - for (l = 0; l < line->backsector->linecount; l++) - { - fixed_t height = P_GetZAt(line->backsector->c_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); - - if (height > highest) - highest = height; - - if (height < lowest) - lowest = height; - } - - // This line special sets extra clipping data for the backsector's slope - cslope->highz = highest; - cslope->lowz = lowest; + MakeViaVectors(&point, &direction, dz, flags); cslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z); cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(cslope); + + if (spawnthinker && (flags & SL_DYNAMIC)) + P_AddDynSlopeThinker(cslope, DP_BACKCEIL, line, extent, NULL, NULL); } } @@ -518,64 +414,148 @@ void P_SpawnSlope_Line(int linenum) return; } -// -// P_NewVertexSlope -// -// Creates a new slope from three vertices with the specified IDs -// -static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flags) +/// Creates a new slope from three mapthings with the specified IDs +static pslope_t *MakeViaMapthings(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flags, const boolean spawnthinker) { size_t i; - mapthing_t *mt = mapthings; + mapthing_t* mt = mapthings; + mapthing_t* vertices[3] = {0}; + INT16 tags[3] = {tag1, tag2, tag3}; - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); - - // Start by setting flags - ret->flags = flags; - - // Now set up the vertex list - ret->vertices = Z_Malloc(3*sizeof(mapthing_t), PU_LEVEL, NULL); - memset(ret->vertices, 0, 3*sizeof(mapthing_t)); + vector3_t vx[3]; + pslope_t* ret = Slope_Add(flags); // And... look for the vertices in question. for (i = 0; i < nummapthings; i++, mt++) { if (mt->type != 750) // Haha, I'm hijacking the old Chaos Spawn thingtype for something! continue; - if (!ret->vertices[0] && mt->angle == tag1) - ret->vertices[0] = mt; - else if (!ret->vertices[1] && mt->angle == tag2) - ret->vertices[1] = mt; - else if (!ret->vertices[2] && mt->angle == tag3) - ret->vertices[2] = mt; + if (!vertices[0] && mt->angle == tag1) + vertices[0] = mt; + else if (!vertices[1] && mt->angle == tag2) + vertices[1] = mt; + else if (!vertices[2] && mt->angle == tag3) + vertices[2] = mt; } // Now set heights for each vertex, because they haven't been set yet for (i = 0; i < 3; i++) { - mt = ret->vertices[i]; + mt = vertices[i]; if (!mt) // If a vertex wasn't found, it's game over. There's nothing you can do to recover (except maybe try and kill the slope instead - TODO?) - I_Error("P_NewVertexSlope: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1); - if (mt->extrainfo) - mt->z = mt->options; - else - mt->z = (R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector->floorheight >> FRACBITS) + (mt->options >> ZSHIFT); + I_Error("MakeViaMapthings: Slope vertex %s (for linedef tag %d) not found!", sizeu1(i), tag1); + vx[i].x = mt->x << FRACBITS; + vx[i].y = mt->y << FRACBITS; + vx[i].z = mt->z << FRACBITS; + if (!mt->extrainfo) + vx[i].z += R_PointInSubsector(vx[i].x, vx[i].y)->sector->floorheight; } - P_ReconfigureVertexSlope(ret); - ret->refpos = 5; + ReconfigureViaVertexes(ret, vx[0], vx[1], vx[2]); - // Add to the slope list - ret->next = slopelist; - slopelist = ret; - - slopecount++; - ret->id = slopecount; + if (spawnthinker && (flags & SL_DYNAMIC)) + P_AddDynSlopeThinker(ret, DP_VERTEX, NULL, 0, tags, vx); return ret; } +/// Create vertex based slopes using tagged mapthings. +static void line_SpawnViaMapthingVertexes(const int linenum, const boolean spawnthinker) +{ + line_t *line = lines + linenum; + side_t *side; + pslope_t **slopetoset; + UINT16 tag1, tag2, tag3; + UINT8 flags = 0; + if (line->flags & ML_NETONLY) + flags |= SL_NOPHYSICS; + if (line->flags & ML_NONET) + flags |= SL_DYNAMIC; + + switch(line->special) + { + case 704: + slopetoset = &line->frontsector->f_slope; + side = &sides[line->sidenum[0]]; + break; + case 705: + slopetoset = &line->frontsector->c_slope; + side = &sides[line->sidenum[0]]; + break; + case 714: + slopetoset = &line->backsector->f_slope; + side = &sides[line->sidenum[1]]; + break; + case 715: + slopetoset = &line->backsector->c_slope; + side = &sides[line->sidenum[1]]; + default: + return; + } + + if (line->flags & ML_EFFECT6) + { + tag1 = line->tag; + tag2 = side->textureoffset >> FRACBITS; + tag3 = side->rowoffset >> FRACBITS; + } + else + tag1 = tag2 = tag3 = line->tag; + + *slopetoset = MakeViaMapthings(tag1, tag2, tag3, flags, spawnthinker); + + side->sector->hasslope = true; +} + +/// Spawn textmap vertex slopes. +static void SpawnVertexSlopes(void) +{ + line_t *l1, *l2; + sector_t* sc; + vertex_t *v1, *v2, *v3; + size_t i; + for (i = 0, sc = sectors; i < numsectors; i++, sc++) + { + // The vertex slopes only work for 3-vertex sectors (and thus 3-sided sectors). + if (sc->linecount != 3) + continue; + + l1 = sc->lines[0]; + l2 = sc->lines[1]; + + // Determine the vertexes. + v1 = l1->v1; + v2 = l1->v2; + if ((l2->v1 != v1) && (l2->v1 != v2)) + v3 = l2->v1; + else + v3 = l2->v2; + + if (v1->floorzset || v2->floorzset || v3->floorzset) + { + vector3_t vtx[3] = { + {v1->x, v1->y, v1->floorzset ? v1->floorz : sc->floorheight}, + {v2->x, v2->y, v2->floorzset ? v2->floorz : sc->floorheight}, + {v3->x, v3->y, v3->floorzset ? v3->floorz : sc->floorheight}}; + pslope_t *slop = Slope_Add(0); + sc->f_slope = slop; + sc->hasslope = true; + ReconfigureViaVertexes(slop, vtx[0], vtx[1], vtx[2]); + } + + if (v1->ceilingzset || v2->ceilingzset || v3->ceilingzset) + { + vector3_t vtx[3] = { + {v1->x, v1->y, v1->ceilingzset ? v1->ceilingz : sc->ceilingheight}, + {v2->x, v2->y, v2->ceilingzset ? v2->ceilingz : sc->ceilingheight}, + {v3->x, v3->y, v3->ceilingzset ? v3->ceilingz : sc->ceilingheight}}; + pslope_t *slop = Slope_Add(0); + sc->c_slope = slop; + sc->hasslope = true; + ReconfigureViaVertexes(slop, vtx[0], vtx[1], vtx[2]); + } + } +} // // P_CopySectorSlope @@ -584,23 +564,28 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag // void P_CopySectorSlope(line_t *line) { - sector_t *fsec = line->frontsector; - int i, special = line->special; + sector_t *fsec = line->frontsector; + int i, special = line->special; - // Check for copy linedefs - for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) - { - sector_t *srcsec = sectors + i; + // Check for copy linedefs + for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) + { + sector_t *srcsec = sectors + i; - if((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope) - fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope); - if((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope) - fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope); - } + if ((special - 719) & 1 && !fsec->f_slope && srcsec->f_slope) + fsec->f_slope = srcsec->f_slope; //P_CopySlope(srcsec->f_slope); + if ((special - 719) & 2 && !fsec->c_slope && srcsec->c_slope) + fsec->c_slope = srcsec->c_slope; //P_CopySlope(srcsec->c_slope); + } - fsec->hasslope = true; + fsec->hasslope = true; - line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef + // if this is an FOF control sector, make sure any target sectors also are marked as having slopes + if (fsec->numattached) + for (i = 0; i < (int)fsec->numattached; i++) + sectors[fsec->attached[i]].hasslope = true; + + line->special = 0; // Linedef was use to set slopes, it finished its job, so now make it a normal linedef } // @@ -615,56 +600,21 @@ pslope_t *P_SlopeById(UINT16 id) return ret; } -// Reset the dynamic slopes pointer, and read all of the fancy schmancy slopes -void P_ResetDynamicSlopes(void) { +/// Initializes and reads the slopes from the map data. +void P_SpawnSlopes(const boolean fromsave) { size_t i; -#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning - boolean warned = false; -#endif slopelist = NULL; slopecount = 0; - // We'll handle copy slopes later, after all the tag lists have been made. - // Yes, this means copied slopes won't affect things' spawning heights. Too bad for you. + /// Generates vertex slopes. + SpawnVertexSlopes(); + + /// Generates line special-defined slopes. for (i = 0; i < numlines; i++) { switch (lines[i].special) { -#ifdef ESLOPE_TYPESHIM // Rewrite old specials to new ones, and give a console warning -#define WARNME if (!warned) {warned = true; CONS_Alert(CONS_WARNING, "This level uses old slope specials.\nA conversion will be needed before 2.2's release.\n");} - case 386: - case 387: - case 388: - lines[i].special += 700-386; - WARNME - P_SpawnSlope_Line(i); - break; - - case 389: - case 390: - case 391: - case 392: - lines[i].special += 710-389; - WARNME - P_SpawnSlope_Line(i); - break; - - case 393: - lines[i].special = 703; - WARNME - P_SpawnSlope_Line(i); - break; - - case 394: - case 395: - case 396: - lines[i].special += 720-394; - WARNME - break; - -#endif - case 700: case 701: case 702: @@ -673,63 +623,35 @@ void P_ResetDynamicSlopes(void) { case 711: case 712: case 713: - P_SpawnSlope_Line(i); + line_SpawnViaLine(i, !fromsave); break; case 704: case 705: case 714: case 715: - { - pslope_t **slopetoset; - size_t which = lines[i].special; - - UINT8 flags = SL_VERTEXSLOPE; - if (lines[i].flags & ML_NOSONIC) - flags |= SL_NOPHYSICS; - if (!(lines[i].flags & ML_NOTAILS)) - flags |= SL_NODYNAMIC; - - if (which == 704) - { - slopetoset = &lines[i].frontsector->f_slope; - which = 0; - } - else if (which == 705) - { - slopetoset = &lines[i].frontsector->c_slope; - which = 0; - } - else if (which == 714) - { - slopetoset = &lines[i].backsector->f_slope; - which = 1; - } - else // 715 - { - slopetoset = &lines[i].backsector->c_slope; - which = 1; - } - - if (lines[i].flags & ML_NOKNUX) - *slopetoset = P_NewVertexSlope(lines[i].tag, sides[lines[i].sidenum[which]].textureoffset >> FRACBITS, - sides[lines[i].sidenum[which]].rowoffset >> FRACBITS, flags); - else - *slopetoset = P_NewVertexSlope(lines[i].tag, lines[i].tag, lines[i].tag, flags); - - sides[lines[i].sidenum[which]].sector->hasslope = true; - } + line_SpawnViaMapthingVertexes(i, !fromsave); break; default: break; } } + + /// Copies slopes from tagged sectors via line specials. + /// \note Doesn't actually copy, but instead they share the same pointers. + for (i = 0; i < numlines; i++) + switch (lines[i].special) + { + case 720: + case 721: + case 722: + P_CopySectorSlope(&lines[i]); + default: + break; + } } - - - // ============================================================================ // // Various utilities related to slopes @@ -784,7 +706,9 @@ void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // Handles slope ejection for objects void P_SlopeLaunch(mobj_t *mo) { - if (!(mo->standingslope->flags & SL_NOPHYSICS)) // If there's physics, time for launching. + if (!(mo->standingslope->flags & SL_NOPHYSICS) // If there's physics, time for launching. + && (mo->standingslope->normal.x != 0 + || mo->standingslope->normal.y != 0)) { // Double the pre-rotation Z, then halve the post-rotation Z. This reduces the // vertical launch given from slopes while increasing the horizontal launch @@ -802,17 +726,54 @@ void P_SlopeLaunch(mobj_t *mo) //CONS_Printf("Launched off of slope.\n"); mo->standingslope = NULL; + + if (mo->player) + mo->player->powers[pw_justlaunched] = 1; +} + +// +// P_GetWallTransferMomZ +// +// It would be nice to have a single function that does everything necessary for slope-to-wall transfer. +// However, it needs to be seperated out in P_XYMovement to take into account momentum before and after hitting the wall. +// This just performs the necessary calculations for getting the base vertical momentum; the horizontal is already reasonably calculated by P_SlideMove. +fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope) +{ + vector3_t slopemom, axis; + angle_t ang; + + if (mo->standingslope->flags & SL_NOPHYSICS) + return 0; + + // If there's physics, time for launching. + // Doesn't kill the vertical momentum as much as P_SlopeLaunch does. + ang = slope->zangle + ANG15*((slope->zangle > 0) ? 1 : -1); + if (ang > ANGLE_90 && ang < ANGLE_180) + ang = ((slope->zangle > 0) ? ANGLE_90 : InvAngle(ANGLE_90)); // hard cap of directly upwards + + slopemom.x = mo->momx; + slopemom.y = mo->momy; + slopemom.z = 3*(mo->momz/2); + + axis.x = -slope->d.y; + axis.y = slope->d.x; + axis.z = 0; + + FV3_Rotate(&slopemom, &axis, ang >> ANGLETOFINESHIFT); + + return 2*(slopemom.z/3); } // Function to help handle landing on slopes void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { vector3_t mom; // Ditto. - - if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. - if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope - thing->momz = -P_MobjFlip(thing); + if (slope->flags & SL_NOPHYSICS || (slope->normal.x == 0 && slope->normal.y == 0)) { // No physics, no need to make anything complicated. + if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope + { thing->standingslope = slope; + if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) + thing->momz = -P_MobjFlip(thing); } return; } @@ -826,9 +787,9 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope thing->momx = mom.x; thing->momy = mom.y; - thing->momz = -P_MobjFlip(thing); - thing->standingslope = slope; + if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) + thing->momz = -P_MobjFlip(thing); } } diff --git a/src/p_slopes.h b/src/p_slopes.h index 708a9107d..f8159b884 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2004 by Stephen McGranahan -// Copyright (C) 2015-2018 by Sonic Team Junior. +// Copyright (C) 2015-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -13,14 +13,17 @@ #ifndef P_SLOPES_H__ #define P_SLOPES_H__ +#include "m_fixed.h" // Vectors + #ifdef ESLOPE + +extern pslope_t *slopelist; +extern UINT16 slopecount; + +void P_LinkSlopeThinkers (void); + void P_CalculateSlopeNormal(pslope_t *slope); -void P_ResetDynamicSlopes(void); -void P_RunDynamicSlopes(void); -// P_SpawnSlope_Line -// Creates one or more slopes based on the given line type and front/back -// sectors. -void P_SpawnSlope_Line(int linenum); +void P_SpawnSlopes(const boolean fromsave); // // P_CopySectorSlope @@ -38,10 +41,38 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y); void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_SlopeLaunch(mobj_t *mo); +fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_ButteredSlope(mobj_t *mo); -#endif -// EOF +/// Dynamic plane type enum for the thinker. Will have a different functionality depending on this. +typedef enum { + DP_FRONTFLOOR, + DP_FRONTCEIL, + DP_BACKFLOOR, + DP_BACKCEIL, + DP_VERTEX +} dynplanetype_t; + +/// Permit slopes to be dynamically altered through a thinker. +typedef struct +{ + thinker_t thinker; + + pslope_t* slope; + dynplanetype_t type; + + // Used by line slopes. + line_t* sourceline; + fixed_t extent; + + // Used by mapthing vertex slopes. + INT16 tags[3]; + vector3_t vex[3]; +} dynplanethink_t; + +void T_DynamicSlopeLine (dynplanethink_t* th); +void T_DynamicSlopeVert (dynplanethink_t* th); #endif // #ifdef ESLOPE +#endif // #ifndef P_SLOPES_H__ diff --git a/src/p_spec.c b/src/p_spec.c index 50b8aec9d..8938a51b6 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -31,22 +31,23 @@ #include "p_polyobj.h" #include "p_slopes.h" #include "hu_stuff.h" +#include "v_video.h" // V_AUTOFADEOUT|V_ALLOWLOWERCASE #include "m_misc.h" #include "m_cond.h" //unlock triggers #include "lua_hook.h" // LUAh_LinedefExecute +#include "f_finale.h" // control text prompt +#include "r_skins.h" // skins #ifdef HW3SOUND #include "hardware/hw3sound.h" #endif // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog -#ifdef _WIN32_WCE -#define AVOID_ERRNO -#else #include -#endif -mobj_t *skyboxmo[2]; +mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint +mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs +mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs // Amount (dx, dy) vector linedef is shifted right to get scroll amount #define SCROLL_SHIFT 5 @@ -69,7 +70,7 @@ typedef struct #endif /** Animated texture definition. - * Used for ::harddefs and for loading an ANIMATED lump from a wad. + * Used for loading an ANIMDEFS lump from a wad. * * Animations are defined by the first and last frame (i.e., flat or texture). * The animation sequence uses all flats between the start and end entry, in @@ -95,12 +96,23 @@ typedef struct thinker_t **thinkers; } thinkerlist_t; -static void P_SearchForDisableLinedefs(void); static void P_SpawnScrollers(void); static void P_SpawnFriction(void); static void P_SpawnPushers(void); static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t *source, INT32 affectee, INT32 referrer, INT32 exclusive, INT32 slider); //SoM: 3/9/2000 static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t offset, INT32 line, INT32 sourceline); +static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize); +#define P_RemoveFakeFloorFader(l) P_ResetFakeFloorFader(l, NULL, false); +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha); +static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, + INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha); +static void P_ResetColormapFader(sector_t *sector); +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + boolean ticbased, INT32 duration); static void P_AddBlockThinker(sector_t *sec, line_t *sourceline); static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline); //static void P_AddBridgeThinker(line_t *sourceline, sector_t *sec); @@ -108,6 +120,7 @@ static void P_AddFakeFloorsByLine(size_t line, ffloortype_e ffloorflags, thinker static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec); static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32 referrer); static void P_AddSpikeThinker(sector_t *sec, INT32 referrer); +static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control, INT32 affectee, UINT8 reverse); //SoM: 3/7/2000: New sturcture without limits. @@ -115,104 +128,6 @@ static anim_t *lastanim; static anim_t *anims = NULL; /// \todo free leak static size_t maxanims; -// -// P_InitPicAnims -// -/** Hardcoded animation sequences. - * Used if no ANIMATED lump is found in a loaded wad. - */ -static animdef_t harddefs[] = -{ - // flat animations. - {false, "LITEY3", "LITEY1", 4}, - {false, "FWATER16", "FWATER1", 4}, - {false, "BWATER16", "BWATER01", 4}, - {false, "LWATER16", "LWATER1", 4}, - {false, "WATER7", "WATER0", 4}, - {false, "LAVA4", "LAVA1", 8}, - {false, "DLAVA4", "DLAVA1", 8}, - {false, "RLAVA8", "RLAVA1", 8}, - {false, "LITER3", "LITER1", 8}, - {false, "SURF08", "SURF01", 4}, - - {false, "CHEMG16", "CHEMG01", 4}, // THZ Chemical gunk - {false, "GOOP16", "GOOP01", 4}, // Green chemical gunk - {false, "OIL16", "OIL01", 4}, // Oil - {false, "THZBOXF4", "THZBOXF1", 2}, // Moved up with the flats - {false, "ALTBOXF4", "ALTBOXF1", 2}, - - {false, "LITEB3", "LITEB1", 4}, - {false, "LITEN3", "LITEN1", 4}, - {false, "ACZRFL1H", "ACZRFL1A", 4}, - {false, "ACZRFL2H", "ACZRFL2A", 4}, - {false, "EGRIDF3", "EGRIDF1", 4}, - {false, "ERZFAN4", "ERZFAN1", 1}, - {false, "ERZFANR4", "ERZFANR1", 1}, - {false, "DISCO4", "DISCO1", 15}, - - // animated textures - {true, "GFALL4", "GFALL1", 2}, // Short waterfall - {true, "CFALL4", "CFALL1", 2}, // Long waterfall - {true, "TFALL4", "TFALL1", 2}, // THZ Chemical fall - {true, "AFALL4", "AFALL1", 2}, // Green Chemical fall - {true, "QFALL4", "QFALL1", 2}, // Quicksand fall - {true, "Q2FALL4", "Q2FALL1", 2}, - {true, "Q3FALL4", "Q3FALL1", 2}, - {true, "Q4FALL4", "Q4FALL1", 2}, - {true, "Q5FALL4", "Q5FALL1", 2}, - {true, "Q6FALL4", "Q6FALL1", 2}, - {true, "Q7FALL4", "Q7FALL1", 2}, - {true, "LFALL4", "LFALL1", 2}, - {true, "MFALL4", "MFALL1", 2}, - {true, "OFALL4", "OFALL1", 2}, - {true, "DLAVA4", "DLAVA1", 8}, - {true, "ERZLASA2", "ERZLASA1", 1}, - {true, "ERZLASB4", "ERZLASB1", 1}, - {true, "ERZLASC4", "ERZLASC1", 1}, - {true, "THZBOX04", "THZBOX01", 2}, - {true, "ALTBOX04", "ALTBOX01", 2}, - {true, "SFALL4", "SFALL1", 4}, // Lava fall - {true, "RVZFALL8", "RVZFALL1", 4}, - {true, "BFALL4", "BFALL1", 2}, // HPZ waterfall - {true, "GREYW3", "GREYW1", 4}, - {true, "BLUEW3", "BLUEW1", 4}, - {true, "COMP6", "COMP4", 4}, - {true, "RED3", "RED1", 4}, - {true, "YEL3", "YEL1", 4}, - {true, "ACWRFL1D", "ACWRFL1A", 1}, - {true, "ACWRFL2D", "ACWRFL2A", 1}, - {true, "ACWRFL3D", "ACWRFL3A", 1}, - {true, "ACWRFL4D", "ACWRFL4A", 1}, - {true, "ACWRP1D", "ACWRP1A", 1}, - {true, "ACWRP2D", "ACWRP2A", 1}, - {true, "ACZRP1D", "ACZRP1A", 1}, - {true, "ACZRP2D", "ACZRP2A", 1}, - {true, "OILFALL4", "OILFALL1", 2}, - {true, "SOLFALL4", "SOLFALL1", 2}, - {true, "DOWN1C", "DOWN1A", 4}, - {true, "DOWN2C", "DOWN2A", 4}, - {true, "DOWN3D", "DOWN3A", 4}, - {true, "DOWN4C", "DOWN4A", 4}, - {true, "DOWN5C", "DOWN5A", 4}, - {true, "UP1C", "UP1A", 4}, - {true, "UP2C", "UP2A", 4}, - {true, "UP3D", "UP3A", 4}, - {true, "UP4C", "UP4A", 4}, - {true, "UP5C", "UP5A", 4}, - {true, "EGRID3", "EGRID1", 4}, - {true, "ERFANW4", "ERFANW1", 1}, - {true, "ERFANX4", "ERFANX1", 1}, - {true, "DISCOD4", "DISCOD1", 15}, - {true, "DANCE4", "DANCE1", 8}, - {true, "SKY135", "SKY132", 2}, - {true, "APPLMS4", "APPLMS1", 2}, - {true, "APBOXW3", "APBOXW1", 2}, - {true, "ERZLAZC4", "ERZLAZC1", 4}, - - // End of line - { -1, "", "", 0}, -}; - // Animating line specials // Init animated textures @@ -220,13 +135,20 @@ static animdef_t harddefs[] = static animdef_t *animdefs = NULL; +// Increase the size of animdefs to make room for a new animation definition +static void GrowAnimDefs(void) +{ + maxanims++; + animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); +} + // A prototype; here instead of p_spec.h, so they're "private" void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum); void P_ParseAnimationDefintion(SINT8 istexture); /** Sets up texture and flat animations. * - * Converts an ::animdef_t array loaded from ::harddefs or a lump into + * Converts an ::animdef_t array loaded from a lump into * ::anim_t format. * * Issues an error if any animation cycles are invalid. @@ -238,73 +160,38 @@ void P_InitPicAnims(void) { // Init animation INT32 w; // WAD - UINT8 *animatedLump; - UINT8 *currentPos; size_t i; I_Assert(animdefs == NULL); - if (W_CheckNumForName("ANIMATED") != LUMPERROR || W_CheckNumForName("ANIMDEFS") != LUMPERROR) + maxanims = 0; + + for (w = numwadfiles-1; w >= 0; w--) { - for (w = numwadfiles-1, maxanims = 0; w >= 0; w--) + UINT16 animdefsLumpNum; + + // Find ANIMDEFS lump in the WAD + animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0); + + while (animdefsLumpNum != INT16_MAX) { - UINT16 animatedLumpNum; - UINT16 animdefsLumpNum; - - // Find ANIMATED lump in the WAD - animatedLumpNum = W_CheckNumForNamePwad("ANIMATED", w, 0); - if (animatedLumpNum != INT16_MAX) - { - animatedLump = (UINT8 *)W_CacheLumpNumPwad(w, animatedLumpNum, PU_STATIC); - - // Get the number of animations in the file - i = maxanims; - for (currentPos = animatedLump; *currentPos != UINT8_MAX; maxanims++, currentPos+=23); - - // Resize animdefs (or if it hasn't been created, create it) - animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); - // Sanity check it - if (!animdefs) - I_Error("Not enough free memory for ANIMATED data"); - - // Populate the new array - for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23) - { - M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte - M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes - M_Memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes - M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes - } - - Z_Free(animatedLump); - } - - // Find ANIMDEFS lump in the WAD - animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", w, 0); - while (animdefsLumpNum != INT16_MAX) - { - P_ParseANIMDEFSLump(w, animdefsLumpNum); - animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", (UINT16)w, animdefsLumpNum + 1); - } + P_ParseANIMDEFSLump(w, animdefsLumpNum); + animdefsLumpNum = W_CheckNumForNamePwad("ANIMDEFS", (UINT16)w, animdefsLumpNum + 1); } - // Define the last one - animdefs[maxanims].istexture = -1; - strncpy(animdefs[maxanims].endname, "", 9); - strncpy(animdefs[maxanims].startname, "", 9); - animdefs[maxanims].speed = 0; - } - else - { - animdefs = harddefs; - for (maxanims = 0; animdefs[maxanims].istexture != -1; maxanims++); } + // Define the last one + animdefs[maxanims].istexture = -1; + strncpy(animdefs[maxanims].endname, "", 9); + strncpy(animdefs[maxanims].startname, "", 9); + animdefs[maxanims].speed = 0; + if (anims) free(anims); anims = (anim_t *)malloc(sizeof (*anims)*(maxanims + 1)); if (!anims) - I_Error("Not enough free memory for ANIMATED data"); + I_Error("Not enough free memory for ANIMDEFS data"); lastanim = anims; for (i = 0; animdefs[i].istexture != -1; i++) @@ -322,8 +209,8 @@ void P_InitPicAnims(void) if ((W_CheckNumForName(animdefs[i].startname)) == LUMPERROR) continue; - lastanim->picnum = R_FlatNumForName(animdefs[i].endname); - lastanim->basepic = R_FlatNumForName(animdefs[i].startname); + lastanim->picnum = R_GetFlatNumForName(animdefs[i].endname); + lastanim->basepic = R_GetFlatNumForName(animdefs[i].startname); } lastanim->istexture = animdefs[i].istexture; @@ -336,10 +223,7 @@ void P_InitPicAnims(void) animdefs[i].startname, animdefs[i].endname); } - if (animdefs == harddefs) - lastanim->speed = animdefs[i].speed; - else - lastanim->speed = LONG(animdefs[i].speed); + lastanim->speed = LONG(animdefs[i].speed); lastanim++; } lastanim->istexture = -1; @@ -347,8 +231,7 @@ void P_InitPicAnims(void) // Clear animdefs now that we're done with it. // We'll only be using anims from now on. - if (animdefs != harddefs) - Z_Free(animdefs); + Z_Free(animdefs); animdefs = NULL; } @@ -453,7 +336,8 @@ void P_ParseAnimationDefintion(SINT8 istexture) // Search for existing animdef for (i = 0; i < maxanims; i++) - if (stricmp(animdefsToken, animdefs[i].startname) == 0) + if (animdefs[i].istexture == istexture // Check if it's the same type! + && stricmp(animdefsToken, animdefs[i].startname) == 0) { //CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken); @@ -467,8 +351,7 @@ void P_ParseAnimationDefintion(SINT8 istexture) if (i == maxanims) { // Increase the size to make room for the new animation definition - maxanims++; - animdefs = (animdef_t *)Z_Realloc(animdefs, sizeof(animdef_t)*(maxanims + 1), PU_STATIC, NULL); + GrowAnimDefs(); strncpy(animdefs[i].startname, animdefsToken, 9); } @@ -554,8 +437,17 @@ void P_ParseAnimationDefintion(SINT8 istexture) } animdefs[i].speed = animSpeed; Z_Free(animdefsToken); -} +#ifdef WALLFLATS + // hehe... uhh..... + if (!istexture) + { + GrowAnimDefs(); + M_Memcpy(&animdefs[maxanims-1], &animdefs[i], sizeof(animdef_t)); + animdefs[maxanims-1].istexture = 1; + } +#endif +} /** Checks for flats in levelflats that are part of a flat animation sequence * and sets them up for animation. @@ -584,10 +476,23 @@ static inline void P_FindAnimatedFlat(INT32 animnum) for (i = 0; i < numlevelflats; i++, foundflats++) { // is that levelflat from the flat anim sequence ? - if (foundflats->lumpnum >= startflatnum && foundflats->lumpnum <= endflatnum) + if ((anims[animnum].istexture) && (foundflats->type == LEVELFLAT_TEXTURE) + && ((UINT16)foundflats->u.texture.num >= startflatnum && (UINT16)foundflats->u.texture.num <= endflatnum)) { - foundflats->baselumpnum = startflatnum; - foundflats->animseq = foundflats->lumpnum - startflatnum; + foundflats->u.texture.basenum = startflatnum; + foundflats->animseq = foundflats->u.texture.num - startflatnum; + foundflats->numpics = endflatnum - startflatnum + 1; + foundflats->speed = anims[animnum].speed; + + CONS_Debug(DBG_SETUP, "animflat: #%03d name:%.8s animseq:%d numpics:%d speed:%d\n", + atoi(sizeu1(i)), foundflats->name, foundflats->animseq, + foundflats->numpics,foundflats->speed); + } + else if ((!anims[animnum].istexture) && (foundflats->type == LEVELFLAT_FLAT) + && (foundflats->u.flat.lumpnum >= startflatnum && foundflats->u.flat.lumpnum <= endflatnum)) + { + foundflats->u.flat.baselumpnum = startflatnum; + foundflats->animseq = foundflats->u.flat.lumpnum - startflatnum; foundflats->numpics = endflatnum - startflatnum + 1; foundflats->speed = anims[animnum].speed; @@ -608,10 +513,7 @@ void P_SetupLevelFlatAnims(void) // the original game flat anim sequences for (i = 0; anims[i].istexture != -1; i++) - { - if (!anims[i].istexture) - P_FindAnimatedFlat(i); - } + P_FindAnimatedFlat(i); } // @@ -1351,7 +1253,7 @@ static void PolyVisible(line_t *line) po->flags |= POF_SOLID; po->flags &= ~POF_NOSPECIALS; - po->flags |= POF_RENDERALL; + po->flags |= (po->spawnflags & POF_RENDERALL); } // @@ -1375,7 +1277,94 @@ static void PolyTranslucency(line_t *line) if (po->isBad) return; - po->translucency = (line->frontsector->floorheight >> FRACBITS) / 100; + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc + po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); +} + +// +// PolyFade +// +// Makes a polyobject translucency fade and applies tangibility +// +static boolean PolyFade(line_t *line) +{ + INT32 polyObjNum = line->tag; + polyobj_t *po; + polyfadedata_t pfd; + + if (!(po = Polyobj_GetForNum(polyObjNum))) + { + CONS_Debug(DBG_POLYOBJ, "PolyFade: bad polyobj %d\n", polyObjNum); + return 0; + } + + // don't allow line actions to affect bad polyobjects + if (po->isBad) + return 0; + + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && po->thinker + && po->thinker->function.acp1 == (actionf_p1)T_PolyObjFade) + { + CONS_Debug(DBG_POLYOBJ, "Line type 492 Executor: Fade PolyObject thinker already exists\n"); + return 0; + } + + pfd.polyObjNum = polyObjNum; + + // if DONTPEGBOTTOM, specify raw translucency value in Front X Offset + // else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. + if (line->flags & ML_EFFECT3) // relative calc + pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)), + NUMTRANSMAPS), 0); + else + pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? + (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) + : max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0)) + : (sides[line->sidenum[0]].textureoffset ? + max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100 + : max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100); + + // already equal, nothing to do + if (po->translucency == pfd.destvalue) + return 1; + + pfd.docollision = !(line->flags & ML_BOUNCY); // do not handle collision flags + pfd.doghostfade = (line->flags & ML_EFFECT1); // do ghost fade (no collision flags during fade) + pfd.ticbased = (line->flags & ML_EFFECT4); // Speed = Tic Duration + + // allow Back Y Offset to be consistent with other fade specials + pfd.speed = (line->sidenum[1] != 0xFFFF && !sides[line->sidenum[0]].rowoffset) ? + abs(sides[line->sidenum[1]].rowoffset>>FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + + + return EV_DoPolyObjFade(&pfd); } // @@ -1445,6 +1434,34 @@ static boolean PolyDisplace(line_t *line) return EV_DoPolyObjDisplace(&pdd); } + +/** Similar to PolyDisplace(). + */ +static boolean PolyRotDisplace(line_t *line) +{ + polyrotdisplacedata_t pdd; + fixed_t anginter, distinter; + + pdd.polyObjNum = line->tag; + pdd.controlSector = line->frontsector; + + // Rotate 'anginter' interval for each 'distinter' interval from the control sector. + // Use default values if not provided as fallback. + anginter = sides[line->sidenum[0]].rowoffset ? sides[line->sidenum[0]].rowoffset : 90*FRACUNIT; + distinter = sides[line->sidenum[0]].textureoffset ? sides[line->sidenum[0]].textureoffset : 128*FRACUNIT; + pdd.rotscale = FixedDiv(anginter, distinter); + + // Same behavior as other rotators when carrying things. + if (line->flags & ML_NOCLIMB) + pdd.turnobjs = 0; + else if (line->flags & ML_EFFECT4) + pdd.turnobjs = 2; + else + pdd.turnobjs = 1; + + return EV_DoPolyObjRotDisplace(&pdd); +} + #endif // ifdef POLYOBJECTS /** Changes a sector's tag. @@ -1508,6 +1525,67 @@ void P_ChangeSectorTag(UINT32 sector, INT16 newtag) } } +// +// P_RunNightserizeExecutors +// +void P_RunNightserizeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 323 || lines[i].special == 324) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunDeNightserizeExecutors +// +void P_RunDeNightserizeExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 325 || lines[i].special == 326) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunNightsLapExecutors +// +void P_RunNightsLapExecutors(mobj_t *actor) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == 327 || lines[i].special == 328) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + +// +// P_RunNightsCapsuleTouchExecutors +// +void P_RunNightsCapsuleTouchExecutors(mobj_t *actor, boolean entering, boolean enoughspheres) +{ + size_t i; + + for (i = 0; i < numlines; i++) + { + if ((lines[i].special == 329 || lines[i].special == 330) + && ((entering && (lines[i].flags & ML_TFERLINE)) + || (!entering && !(lines[i].flags & ML_TFERLINE))) + && ((lines[i].flags & ML_DONTPEGTOP) + || (enoughspheres && !(lines[i].flags & ML_BOUNCY)) + || (!enoughspheres && (lines[i].flags & ML_BOUNCY)))) + P_RunTriggerLinedef(&lines[i], actor, NULL); + } +} + /** Hashes the sector tags across the sectors and linedefs. * * \sa P_FindSectorFromTag, P_ChangeSectorTag @@ -1522,8 +1600,6 @@ static inline void P_InitTagLists(void) size_t j = (unsigned)sectors[i].tag % numsectors; sectors[i].nexttag = sectors[j].firsttag; sectors[j].firsttag = (INT32)i; - sectors[i].spawn_nexttag = sectors[i].nexttag; - sectors[j].spawn_firsttag = sectors[j].firsttag; } for (i = numlines - 1; i != (size_t)-1; i--) @@ -1588,7 +1664,147 @@ static void P_AddExecutorDelay(line_t *line, mobj_t *mobj, sector_t *sector) e->sector = sector; e->timer = (line->backsector->ceilingheight>>FRACBITS)+(line->backsector->floorheight>>FRACBITS); P_SetTarget(&e->caller, mobj); // Use P_SetTarget to make sure the mobj doesn't get freed while we're delaying. - P_AddThinker(&e->thinker); + P_AddThinker(THINK_MAIN, &e->thinker); +} + +/** Used by P_RunTriggerLinedef to check a NiGHTS trigger linedef's conditions + * + * \param triggerline Trigger linedef to check conditions for; should NEVER be NULL. + * \param actor Object initiating the action; should not be NULL. + * \sa P_RunTriggerLinedef + */ +static boolean P_CheckNightsTriggerLine(line_t *triggerline, mobj_t *actor) +{ + INT16 specialtype = triggerline->special; + size_t i; + + UINT8 inputmare = max(0, min(255, sides[triggerline->sidenum[0]].textureoffset>>FRACBITS)); + UINT8 inputlap = max(0, min(255, sides[triggerline->sidenum[0]].rowoffset>>FRACBITS)); + + boolean ltemare = triggerline->flags & ML_NOCLIMB; + boolean gtemare = triggerline->flags & ML_BLOCKMONSTERS; + boolean ltelap = triggerline->flags & ML_EFFECT1; + boolean gtelap = triggerline->flags & ML_EFFECT2; + + boolean lapfrombonustime = triggerline->flags & ML_EFFECT3; + boolean perglobalinverse = triggerline->flags & ML_DONTPEGBOTTOM; + boolean perglobal = !(triggerline->flags & ML_EFFECT4) && !perglobalinverse; + + boolean donomares = triggerline->flags & ML_BOUNCY; // nightserize: run at end of level (no mares) + boolean fromnonights = triggerline->flags & ML_TFERLINE; // nightserize: from non-nights // denightserize: all players no nights + boolean fromnights = triggerline->flags & ML_DONTPEGTOP; // nightserize: from nights // denightserize: >0 players are nights + + UINT8 currentmare = UINT8_MAX; + UINT8 currentlap = UINT8_MAX; + + // Do early returns for Nightserize + if (specialtype >= 323 && specialtype <= 324) + { + // run only when no mares are found + if (donomares && P_FindLowestMare() != UINT8_MAX) + return false; + + // run only if there is a mare present + if (!donomares && P_FindLowestMare() == UINT8_MAX) + return false; + + // run only if player is nightserizing from non-nights + if (fromnonights) + { + if (!actor->player) + return false; + else if (actor->player->powers[pw_carry] == CR_NIGHTSMODE) + return false; + } + // run only if player is nightserizing from nights + else if (fromnights) + { + if (!actor->player) + return false; + else if (actor->player->powers[pw_carry] != CR_NIGHTSMODE) + return false; + } + } + + // Get current mare and lap (and check early return for DeNightserize) + if (perglobal || perglobalinverse + || (specialtype >= 325 && specialtype <= 326 && (fromnonights || fromnights))) + { + UINT8 playersarenights = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + UINT8 lap; + if (!playeringame[i] || players[i].spectator) + continue; + + // denightserize: run only if all players are not nights + if (specialtype >= 325 && specialtype <= 326 && fromnonights + && players[i].powers[pw_carry] == CR_NIGHTSMODE) + return false; + + // count number of nights players for denightserize return + if (specialtype >= 325 && specialtype <= 326 && fromnights + && players[i].powers[pw_carry] == CR_NIGHTSMODE) + playersarenights++; + + lap = lapfrombonustime ? players[i].marebonuslap : players[i].marelap; + + // get highest mare/lap of players + if (perglobal) + { + if (players[i].mare > currentmare || currentmare == UINT8_MAX) + { + currentmare = players[i].mare; + currentlap = UINT8_MAX; + } + if (players[i].mare == currentmare + && (lap > currentlap || currentlap == UINT8_MAX)) + currentlap = lap; + } + // get lowest mare/lap of players + else if (perglobalinverse) + { + if (players[i].mare < currentmare || currentmare == UINT8_MAX) + { + currentmare = players[i].mare; + currentlap = UINT8_MAX; + } + if (players[i].mare == currentmare + && (lap < currentlap || currentlap == UINT8_MAX)) + currentlap = lap; + } + } + + // denightserize: run only if >0 players are nights + if (specialtype >= 325 && specialtype <= 326 && fromnights + && playersarenights < 1) + return false; + } + // get current mare/lap from triggering player + else if (!perglobal && !perglobalinverse) + { + if (!actor->player) + return false; + currentmare = actor->player->mare; + currentlap = lapfrombonustime ? actor->player->marebonuslap : actor->player->marelap; + } + + if (lapfrombonustime && !currentlap) + return false; // special case: player->marebonuslap is 0 until passing through on bonus time. Don't trigger lines looking for inputlap 0. + + // Compare current mare/lap to input mare/lap based on rules + if (!(specialtype >= 323 && specialtype <= 324 && donomares) // don't return false if donomares and we got this far + && ((ltemare && currentmare > inputmare) + || (gtemare && currentmare < inputmare) + || (!ltemare && !gtemare && currentmare != inputmare) + || (ltelap && currentlap > inputlap) + || (gtelap && currentlap < inputlap) + || (!ltelap && !gtelap && currentlap != inputlap)) + ) + return false; + + return true; } /** Used by P_LinedefExecute to check a trigger linedef's conditions @@ -1626,10 +1842,10 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (!playeringame[i] || players[i].spectator) continue; - if (!players[i].mo || players[i].mo->health < 1) + if (!players[i].mo || ((maptol & TOL_NIGHTS) ? players[i].spheres : players[i].rings) <= 0) continue; - rings += players[i].mo->health-1; + rings += (maptol & TOL_NIGHTS) ? players[i].spheres : players[i].rings; } } else @@ -1637,7 +1853,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (!(actor && actor->player)) return false; // no player to count rings from here, sorry - rings = actor->health-1; + rings = (maptol & TOL_NIGHTS) ? actor->player->spheres : actor->player->rings; } if (triggerline->flags & ML_NOCLIMB) @@ -1671,7 +1887,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller while (node) { mo = node->m_thing; - if (mo->flags & MF_PUSHABLE) + if ((mo->flags & MF_PUSHABLE) || ((mo->info->flags & MF_PUSHABLE) && mo->fuse)) numpush++; node = node->m_thinglist_next; } @@ -1801,6 +2017,23 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller return false; } break; + case 323: // nightserize - each time + case 324: // nightserize - once + case 325: // denightserize - each time + case 326: // denightserize - once + case 327: // nights lap - each time + case 328: // nights lap - once + case 329: // nights egg capsule touch - each time + case 330: // nights egg capsule touch - once + if (!P_CheckNightsTriggerLine(triggerline, actor)) + return false; + break; + case 331: // continuous + case 332: // each time + case 333: // once + if (!(actor && actor->player && ((stricmp(triggerline->text, skins[actor->player->skin].name) == 0) ^ ((triggerline->flags & ML_NOCLIMB) == ML_NOCLIMB)))) + return false; + break; default: break; } @@ -1924,10 +2157,16 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller || specialtype == 304 // Ring count - Once || specialtype == 307 // Character ability - Once || specialtype == 308 // Race only - Once + || specialtype == 313 // No More Enemies - Once || specialtype == 315 // No of pushables - Once || specialtype == 318 // Unlockable trigger - Once || specialtype == 320 // Unlockable - Once || specialtype == 321 || specialtype == 322 // Trigger on X calls - Continuous + Each Time + || specialtype == 324 // Nightserize - Once + || specialtype == 326 // DeNightserize - Once + || specialtype == 328 // Nights lap - Once + || specialtype == 330 // Nights Bonus Time - Once + || specialtype == 333 // Skin - Once || specialtype == 399) // Level Load triggerline->special = 0; // Clear it out @@ -1968,7 +2207,8 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) || lines[masterline].special == 306 // Character ability - Each time || lines[masterline].special == 310 // CTF Red team - Each time || lines[masterline].special == 312 // CTF Blue team - Each time - || lines[masterline].special == 322) // Trigger on X calls - Each Time + || lines[masterline].special == 322 // Trigger on X calls - Each Time + || lines[masterline].special == 332)// Skin - Each time continue; if (lines[masterline].special < 300 @@ -2040,7 +2280,7 @@ void P_SwitchWeather(INT32 weathernum) thinker_t *think; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_PRECIP].next; think != &thlist[THINK_PRECIP]; think = think->next) { if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker @@ -2056,7 +2296,7 @@ void P_SwitchWeather(INT32 weathernum) precipmobj_t *precipmobj; state_t *st; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_PRECIP].next; think != &thlist[THINK_PRECIP]; think = think->next) { if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker @@ -2406,18 +2646,70 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 413: // Change music // console player only unless NOCLIMB is set - if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player))) + if ((line->flags & ML_NOCLIMB) || (mo && mo->player && P_IsLocalPlayer(mo->player)) || titlemapinaction) { - UINT16 tracknum = (UINT16)sides[line->sidenum[0]].bottomtexture; + boolean musicsame = (!sides[line->sidenum[0]].text[0] || !strnicmp(sides[line->sidenum[0]].text, S_MusicName(), 7)); + UINT16 tracknum = (UINT16)max(sides[line->sidenum[0]].bottomtexture, 0); + INT32 position = (INT32)max(sides[line->sidenum[0]].midtexture, 0); + UINT32 prefadems = (UINT32)max(sides[line->sidenum[0]].textureoffset >> FRACBITS, 0); + UINT32 postfadems = (UINT32)max(sides[line->sidenum[0]].rowoffset >> FRACBITS, 0); + UINT8 fadetarget = (UINT8)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].textureoffset >> FRACBITS : 0, 0); + INT16 fadesource = (INT16)max((line->sidenum[1] != 0xffff) ? sides[line->sidenum[1]].rowoffset >> FRACBITS : -1, -1); - strncpy(mapmusname, sides[line->sidenum[0]].text, 7); - mapmusname[6] = 0; + // Seek offset from current song position + if (line->flags & ML_EFFECT1) + { + // adjust for loop point if subtracting + if (position < 0 && S_GetMusicLength() && + S_GetMusicPosition() > S_GetMusicLoopPoint() && + S_GetMusicPosition() + position < S_GetMusicLoopPoint()) + position = max(S_GetMusicLength() - (S_GetMusicLoopPoint() - (S_GetMusicPosition() + position)), 0); + else + position = max(S_GetMusicPosition() + position, 0); + } - mapmusflags = tracknum & MUSIC_TRACKMASK; - if (!(line->flags & ML_BLOCKMONSTERS)) - mapmusflags |= MUSIC_RELOADRESET; + // Fade current music to target volume (if music won't be changed) + if ((line->flags & ML_EFFECT2) && fadetarget && musicsame) + { + // 0 fadesource means fade from current volume. + // meaning that we can't specify volume 0 as the source volume -- this starts at 1. + if (!fadesource) + fadesource = -1; - S_ChangeMusic(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4)); + if (!postfadems) + S_SetInternalMusicVolume(fadetarget); + else + S_FadeMusicFromVolume(fadetarget, fadesource, postfadems); + + if (position) + S_SetMusicPosition(position); + } + // Change the music and apply position/fade operations + else + { + strncpy(mapmusname, sides[line->sidenum[0]].text, 7); + mapmusname[6] = 0; + + mapmusflags = tracknum & MUSIC_TRACKMASK; + if (!(line->flags & ML_BLOCKMONSTERS)) + mapmusflags |= MUSIC_RELOADRESET; + if (line->flags & ML_BOUNCY) + mapmusflags |= MUSIC_FORCERESET; + + mapmusposition = position; + + S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, + !(line->flags & ML_EFFECT2) ? prefadems : 0, + !(line->flags & ML_EFFECT2) ? postfadems : 0); + + if ((line->flags & ML_EFFECT2) && fadetarget) + { + if (!postfadems) + S_SetInternalMusicVolume(fadetarget); + else + S_FadeMusicFromVolume(fadetarget, fadesource, postfadems); + } + } // Except, you can use the ML_BLOCKMONSTERS flag to change this behavior. // if (mapmusflags & MUSIC_RELOADRESET) then it will reset the music in G_PlayerReborn. @@ -2428,7 +2720,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { INT32 sfxnum; - sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; + sfxnum = sides[line->sidenum[0]].toptexture; if (sfxnum == sfx_None) return; // Do nothing! @@ -2437,8 +2729,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) CONS_Debug(DBG_GAMELOGIC, "Line type 414 Executor: sfx number %d is invalid!\n", sfxnum); return; } + if (line->tag != 0) // Do special stuff only if a non-zero linedef tag is set { + // Play sounds from tagged sectors' origins. if (line->flags & ML_EFFECT5) // Repeat Midtexture { // Additionally play the sound from tagged sectors' soundorgs @@ -2450,57 +2744,73 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) S_StartSound(&sec->soundorg, sfxnum); } } - else if (mo) // A mobj must have triggered the executor + + // Play the sound without origin for anyone, as long as they're inside tagged areas. + else { - // Only trigger if mobj is touching the tag + UINT8 i = 0; + mobj_t* camobj = players[displayplayer].mo; ffloor_t *rover; boolean foundit = false; - for(rover = mo->subsector->sector->ffloors; rover; rover = rover->next) + for (i = 0; i < 2; camobj = players[secondarydisplayplayer].mo, i++) { - if (rover->master->frontsector->tag != line->tag) + if (!camobj) continue; - if (mo->z > P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector)) - continue; + if (foundit || (camobj->subsector->sector->tag == line->tag)) + { + foundit = true; + break; + } - if (mo->z + mo->height < P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) - continue; + // Only trigger if mobj is touching the tag + for(rover = camobj->subsector->sector->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag != line->tag) + continue; - foundit = true; + if (camobj->z > P_GetSpecialTopZ(camobj, sectors + rover->secnum, camobj->subsector->sector)) + continue; + + if (camobj->z + camobj->height < P_GetSpecialBottomZ(camobj, sectors + rover->secnum, camobj->subsector->sector)) + continue; + + foundit = true; + break; + } } - if (mo->subsector->sector->tag == line->tag) - foundit = true; - - if (!foundit) - return; + if (foundit) + S_StartSound(NULL, sfxnum); } } - - if (line->flags & ML_NOCLIMB) + else { - // play the sound from nowhere, but only if display player triggered it - if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer])) + if (line->flags & ML_NOCLIMB) + { + // play the sound from nowhere, but only if display player triggered it + if (mo && mo->player && (mo->player == &players[displayplayer] || mo->player == &players[secondarydisplayplayer])) + S_StartSound(NULL, sfxnum); + } + else if (line->flags & ML_EFFECT4) + { + // play the sound from nowhere S_StartSound(NULL, sfxnum); - } - else if (line->flags & ML_EFFECT4) - { - // play the sound from nowhere - S_StartSound(NULL, sfxnum); - } - else if (line->flags & ML_BLOCKMONSTERS) - { - // play the sound from calling sector's soundorg - if (callsec) - S_StartSound(&callsec->soundorg, sfxnum); + } + else if (line->flags & ML_BLOCKMONSTERS) + { + // play the sound from calling sector's soundorg + if (callsec) + S_StartSound(&callsec->soundorg, sfxnum); + else if (mo) + S_StartSound(&mo->subsector->sector->soundorg, sfxnum); + } else if (mo) - S_StartSound(&mo->subsector->sector->soundorg, sfxnum); - } - else if (mo) - { - // play the sound from mobj that triggered it - S_StartSound(mo, sfxnum); + { + // play the sound from mobj that triggered it + S_StartSound(mo, sfxnum); + } } } break; @@ -2679,7 +2989,17 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 420: // Fade light levels in tagged sectors to new value - P_FadeLight(line->tag, line->frontsector->lightlevel, P_AproxDistance(line->dx, line->dy)>>FRACBITS); + P_FadeLight(line->tag, + (line->flags & ML_DONTPEGBOTTOM) ? max(sides[line->sidenum[0]].textureoffset>>FRACBITS, 0) : line->frontsector->lightlevel, + // failsafe: if user specifies Back Y Offset and NOT Front Y Offset, use the Back Offset + // to be consistent with other light and fade specials + (line->flags & ML_DONTPEGBOTTOM) ? + ((line->sidenum[1] != 0xFFFF && !(sides[line->sidenum[0]].rowoffset>>FRACBITS)) ? + max(min(sides[line->sidenum[1]].rowoffset>>FRACBITS, 255), 0) + : max(min(sides[line->sidenum[0]].rowoffset>>FRACBITS, 255), 0)) + : abs(P_AproxDistance(line->dx, line->dy))>>FRACBITS, + (line->flags & ML_EFFECT4), + (line->flags & ML_EFFECT5)); break; case 421: // Stop lighting effect in tagged sectors @@ -2695,7 +3015,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { mobj_t *altview; - if (!mo || !mo->player) // only players have views + if ((!mo || !mo->player) && !titlemapinaction) // only players have views, and title screens return; if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) @@ -2705,6 +3025,14 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (!altview) return; + // If titlemap, set the camera ref for title's thinker + // This is not revoked until overwritten; awayviewtics is ignored + if (titlemapinaction) + { + titlemapcameraref = altview; + return; + } + P_SetTarget(&mo->player->awayviewmobj, altview); mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS; @@ -2806,7 +3134,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 432: // Enable 2D Mode (Disable if noclimb) - if (mo->player) + if (mo && mo->player) { if (line->flags & ML_NOCLIMB) mo->flags2 &= ~MF2_TWOD; @@ -2832,7 +3160,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 434: // Custom Power - if (mo->player) + if (mo && mo->player) { mobj_t *dummy = P_SpawnMobj(mo->x, mo->y, mo->z, MT_NULL); @@ -2861,7 +3189,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) scroll_t *scroller; thinker_t *th; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MAIN].next; th != &thlist[THINK_MAIN]; th = th->next) { if (th->function.acp1 != (actionf_p1)T_Scroll) continue; @@ -2883,6 +3211,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible in ffloor_t *rover; // FOF that we are going to crumble + boolean foundrover = false; // for debug, "Can't find a FOF" message for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) { @@ -2897,22 +3226,24 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = true; + + EV_CrumbleChain(sec, rover); + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 436 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - EV_CrumbleChain(sec, rover); } } break; case 437: // Disable Player Controls - if (mo->player) + if (mo && mo->player) { UINT16 fractime = (UINT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); if (fractime < 1) @@ -2986,7 +3317,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Unlocked something? if (M_UpdateUnlockablesAndExtraEmblems()) { - S_StartSound(NULL, sfx_ncitem); + S_StartSound(NULL, sfx_s3k68); G_SaveGameData(); // only save if unlocked something } } @@ -3035,14 +3366,10 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) } case 443: // Calls a named Lua function -#ifdef HAVE_BLUA if (line->text) LUAh_LinedefExecute(line, mo, callsec); else CONS_Alert(CONS_WARNING, "Linedef %s is missing the hook name of the Lua function to call! (This should be given in the front texture fields)\n", sizeu1(line-lines)); -#else - CONS_Alert(CONS_ERROR, "The map is trying to run a Lua script, but this exe was not compiled with Lua support!\n"); -#endif break; case 444: // Earthquake camera @@ -3067,6 +3394,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); sector_t *sec; // Sector that the FOF is visible (or not visible) in ffloor_t *rover; // FOF to vanish/un-vanish + boolean foundrover = false; // for debug, "Can't find a FOF" message ffloortype_e oldflags; // store FOF's old flags for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) @@ -3082,30 +3410,207 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) for (rover = sec->ffloors; rover; rover = rover->next) { if (rover->master->frontsector->tag == foftag) - break; + { + foundrover = true; + + oldflags = rover->flags; + + // Abracadabra! + if (line->flags & ML_NOCLIMB) + rover->flags |= FF_EXISTS; + else + rover->flags &= ~FF_EXISTS; + + // if flags changed, reset sector's light list + if (rover->flags != oldflags) + { + sec->moved = true; + P_RecalcPrecipInSector(sec); + } + } } - if (!rover) + if (!foundrover) { CONS_Debug(DBG_GAMELOGIC, "Line type 445 Executor: Can't find a FOF control sector with tag %d\n", foftag); return; } - - oldflags = rover->flags; - - // Abracadabra! - if (line->flags & ML_NOCLIMB) - rover->flags |= FF_EXISTS; - else - rover->flags &= ~FF_EXISTS; - - // if flags changed, reset sector's light list - if (rover->flags != oldflags) - sec->moved = true; } } break; + case 446: // Make block fall remotely (acts like FF_CRUMBLE) + { + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to make fall down + boolean foundrover = false; // for debug, "Can't find a FOF" message + player_t *player = NULL; // player that caused FOF to fall + boolean respawn = true; // should the fallen FOF respawn? + + if (mo) // NULL check + player = mo->player; + + if (line->flags & ML_NOCLIMB) // don't respawn! + respawn = false; + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 446 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + { + foundrover = true; + + if (line->flags & ML_BLOCKMONSTERS) // FOF flags determine respawn ability instead? + respawn = !(rover->flags & FF_NORETURN) ^ !!(line->flags & ML_NOCLIMB); // no climb inverts + + EV_StartCrumble(rover->master->frontsector, rover, (rover->flags & FF_FLOATBOB), player, rover->alpha, respawn); + } + } + + if (!foundrover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 446 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + } + } + break; + + case 447: // Change colormap of tagged sectors! + // Basically this special applies a colormap to the tagged sectors, just like 606 (the colormap linedef) + // Except it is activated by linedef executor, not level load + // This could even override existing colormaps I believe + // -- Monster Iestyn 14/06/18 + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + { + P_ResetColormapFader(§ors[secnum]); + + if (line->flags & ML_EFFECT3) // relative calc + { + extracolormap_t *exc = R_AddColormaps( + (line->flags & ML_TFERLINE) && line->sidenum[1] != 0xFFFF ? + sides[line->sidenum[1]].colormap_data : sectors[secnum].extra_colormap, // use back colormap instead of target sector + sides[line->sidenum[0]].colormap_data, + line->flags & ML_EFFECT1, // subtract R + line->flags & ML_NOCLIMB, // subtract G + line->flags & ML_EFFECT2, // subtract B + false, // subtract A (no flag for this, just pass negative alpha) + line->flags & ML_EFFECT1, // subtract FadeR + line->flags & ML_NOCLIMB, // subtract FadeG + line->flags & ML_EFFECT2, // subtract FadeB + false, // subtract FadeA (no flag for this, just pass negative alpha) + false, // subtract FadeStart (we ran out of flags) + false, // subtract FadeEnd (we ran out of flags) + false, // ignore Flags (we ran out of flags) + line->flags & ML_DONTPEGBOTTOM, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, + false); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; + } + else + Z_Free(exc); + } + else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) + { + extracolormap_t *exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + + if (!(sectors[secnum].extra_colormap = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + sectors[secnum].extra_colormap = exc; + } + else + Z_Free(exc); + } + else + sectors[secnum].extra_colormap = sides[line->sidenum[0]].colormap_data; + } + break; + + case 448: // Change skybox viewpoint/centerpoint + if ((mo && mo->player && P_IsLocalPlayer(mo->player)) || (line->flags & ML_NOCLIMB)) + { + INT32 viewid = sides[line->sidenum[0]].textureoffset>>FRACBITS; + INT32 centerid = sides[line->sidenum[0]].rowoffset>>FRACBITS; + + if ((line->flags & (ML_EFFECT4|ML_BLOCKMONSTERS)) == ML_EFFECT4) // Solid Midtexture is on but Block Enemies is off? + { + CONS_Alert(CONS_WARNING, + M_GetText("Skybox switch linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"), + line->tag); + } + else + { + // set viewpoint mobj + if (!(line->flags & ML_EFFECT4)) // Solid Midtexture turns off viewpoint setting + { + if (viewid >= 0 && viewid < 16) + skyboxmo[0] = skyboxviewpnts[viewid]; + else + skyboxmo[0] = NULL; + } + + // set centerpoint mobj + if (line->flags & ML_BLOCKMONSTERS) // Block Enemies turns ON centerpoint setting + { + if (centerid >= 0 && centerid < 16) + skyboxmo[1] = skyboxcenterpnts[centerid]; + else + skyboxmo[1] = NULL; + } + } + + CONS_Debug(DBG_GAMELOGIC, "Line type 448 Executor: viewid = %d, centerid = %d, viewpoint? = %s, centerpoint? = %s\n", + viewid, + centerid, + ((line->flags & ML_EFFECT4) ? "no" : "yes"), + ((line->flags & ML_BLOCKMONSTERS) ? "yes" : "no")); + } + break; + + case 449: // Enable bosses with parameter + { + INT32 bossid = sides[line->sidenum[0]].textureoffset>>FRACBITS; + if (bossid & ~15) // if any bits other than first 16 are set + { + CONS_Alert(CONS_WARNING, + M_GetText("Boss enable linedef (tag %d) has an invalid texture x offset.\nConsider changing it or removing it entirely.\n"), + line->tag); + break; + } + if (line->flags & ML_NOCLIMB) + { + bossdisabled |= (1<tag, mo, NULL); break; @@ -3125,6 +3630,414 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; } + case 452: // Set FOF alpha + { + INT16 destvalue = line->sidenum[1] != 0xffff ? + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(P_AproxDistance(line->dx, line->dy)>>FRACBITS); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to operate + boolean foundrover = false; // for debug, "Can't find a FOF" message + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + { + foundrover = true; + + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + // for relative alpha calc + if (!(line->flags & ML_NOCLIMB) && // do translucent + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + P_RemoveFakeFloorFader(rover); + P_FadeFakeFloor(rover, + rover->alpha, + max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), + 0, // set alpha immediately + false, NULL, // tic-based logic + false, // do not handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // handle FF_TRANSLUCENT + false, // do not handle lighting + false, // do not handle colormap + false, // do not handle collision + false, // do not do ghost fade (no collision during fade) + true); // use exact alpha values (for opengl) + } + } + + if (!foundrover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 452 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + } + break; + } + + case 453: // Fade FOF + { + INT16 destvalue = line->sidenum[1] != 0xffff ? + (INT16)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : (INT16)(line->dx>>FRACBITS); + INT16 speed = line->sidenum[1] != 0xffff ? + (INT16)(abs(sides[line->sidenum[1]].rowoffset>>FRACBITS)) : (INT16)(abs(line->dy)>>FRACBITS); + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to operate + boolean foundrover = false; // for debug, "Can't find a FOF" message + size_t j = 0; // sec->ffloors is saved as ffloor #0, ss->ffloors->next is #1, etc + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + { + foundrover = true; + + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && rover->fadingdata) + //&& ((fade_t*)rover->fadingdata)->timer > (ticbased ? 2 : speed*2)) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Fade FOF thinker already exists, timer: %d\n", ((fade_t*)rover->fadingdata)->timer); + continue; + } + + if (speed > 0) + P_AddFakeFloorFader(rover, secnum, j, + destvalue, + speed, + (line->flags & ML_EFFECT4), // tic-based logic + (line->flags & ML_EFFECT3), // Relative destvalue + !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) + !(line->flags & ML_BOUNCY), // do not handle collision + (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) + (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) + else + { + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + // for relative alpha calc + if (!(line->flags & ML_NOCLIMB) && // do translucent + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + P_RemoveFakeFloorFader(rover); + P_FadeFakeFloor(rover, + rover->alpha, + max(1, min(256, (line->flags & ML_EFFECT3) ? rover->alpha + destvalue : destvalue)), + 0, // set alpha immediately + false, NULL, // tic-based logic + !(line->flags & ML_BLOCKMONSTERS), // do not handle FF_EXISTS + !(line->flags & ML_NOCLIMB), // do not handle FF_TRANSLUCENT + !(line->flags & ML_EFFECT2), // do not handle lighting + !(line->flags & ML_EFFECT2), // do not handle colormap (ran out of flags) + !(line->flags & ML_BOUNCY), // do not handle collision + (line->flags & ML_EFFECT1), // do ghost fade (no collision during fade) + (line->flags & ML_TFERLINE)); // use exact alpha values (for opengl) + } + } + j++; + } + + if (!foundrover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 453 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + } + break; + } + + case 454: // Stop fading FOF + { + INT16 sectag = (INT16)(sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT16 foftag = (INT16)(sides[line->sidenum[0]].rowoffset>>FRACBITS); + sector_t *sec; // Sector that the FOF is visible in + ffloor_t *rover; // FOF that we are going to operate + boolean foundrover = false; // for debug, "Can't find a FOF" message + + for (secnum = -1; (secnum = P_FindSectorFromTag(sectag, secnum)) >= 0 ;) + { + sec = sectors + secnum; + + if (!sec->ffloors) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 454 Executor: Target sector #%d has no FOFs.\n", secnum); + return; + } + + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (rover->master->frontsector->tag == foftag) + { + foundrover = true; + + P_ResetFakeFloorFader(rover, NULL, + !(line->flags & ML_BLOCKMONSTERS)); // do not finalize collision flags + } + } + + if (!foundrover) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 454 Executor: Can't find a FOF control sector with tag %d\n", foftag); + return; + } + } + break; + } + + case 455: // Fade colormap + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + { + extracolormap_t *source_exc, *dest_exc, *exc; + INT32 speed = (INT32)((line->flags & ML_DONTPEGBOTTOM) || !sides[line->sidenum[0]].rowoffset) && line->sidenum[1] != 0xFFFF ? + abs(sides[line->sidenum[1]].rowoffset >> FRACBITS) + : abs(sides[line->sidenum[0]].rowoffset >> FRACBITS); + + // Prevent continuous execs from interfering on an existing fade + if (!(line->flags & ML_EFFECT5) + && sectors[secnum].fadecolormapdata) + //&& ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer > (ticbased ? 2 : speed*2)) + { + CONS_Debug(DBG_GAMELOGIC, "Line type 455 Executor: Fade color thinker already exists, timer: %d\n", ((fadecolormap_t*)sectors[secnum].fadecolormapdata)->timer); + continue; + } + + if (line->flags & ML_TFERLINE) // use back colormap instead of target sector + sectors[secnum].extra_colormap = (line->sidenum[1] != 0xFFFF) ? + sides[line->sidenum[1]].colormap_data : NULL; + + exc = sectors[secnum].extra_colormap; + + if (!(line->flags & ML_BOUNCY) // BOUNCY: Do not override fade from default rgba + && !R_CheckDefaultColormap(sides[line->sidenum[0]].colormap_data, true, false, false) + && R_CheckDefaultColormap(exc, true, false, false)) + { + exc = R_CopyColormap(exc, false); + exc->rgba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->rgba)); + //exc->fadergba = R_GetRgbaRGB(sides[line->sidenum[0]].colormap_data->rgba) + R_PutRgbaA(R_GetRgbaA(exc->fadergba)); + + if (!(source_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + source_exc = exc; + } + else + Z_Free(exc); + + sectors[secnum].extra_colormap = source_exc; + } + else + source_exc = exc ? exc : R_GetDefaultColormap(); + + if (line->flags & ML_EFFECT3) // relative calc + { + exc = R_AddColormaps( + source_exc, + sides[line->sidenum[0]].colormap_data, + line->flags & ML_EFFECT1, // subtract R + line->flags & ML_NOCLIMB, // subtract G + line->flags & ML_EFFECT2, // subtract B + false, // subtract A (no flag for this, just pass negative alpha) + line->flags & ML_EFFECT1, // subtract FadeR + line->flags & ML_NOCLIMB, // subtract FadeG + line->flags & ML_EFFECT2, // subtract FadeB + false, // subtract FadeA (no flag for this, just pass negative alpha) + false, // subtract FadeStart (we ran out of flags) + false, // subtract FadeEnd (we ran out of flags) + false, // ignore Flags (we ran out of flags) + line->flags & ML_DONTPEGBOTTOM, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].textureoffset >> FRACBITS) : 0, + (line->flags & ML_DONTPEGBOTTOM) ? (sides[line->sidenum[0]].rowoffset >> FRACBITS) : 0, + false); + } + else if (line->flags & ML_DONTPEGBOTTOM) // alternate alpha (by texture offsets) + { + exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); + exc->rgba = R_GetRgbaRGB(exc->rgba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].textureoffset >> FRACBITS, 25), 0)); + exc->fadergba = R_GetRgbaRGB(exc->fadergba) + R_PutRgbaA(max(min(sides[line->sidenum[0]].rowoffset >> FRACBITS, 25), 0)); + } + else + exc = R_CopyColormap(sides[line->sidenum[0]].colormap_data, false); + + if (!(dest_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + dest_exc = exc; + } + else + Z_Free(exc); + + Add_ColormapFader(§ors[secnum], source_exc, dest_exc, (line->flags & ML_EFFECT4), // tic-based timing + speed); + } + break; + + case 456: // Stop fade colormap + for (secnum = -1; (secnum = P_FindSectorFromLineTag(line, secnum)) >= 0 ;) + P_ResetColormapFader(§ors[secnum]); + break; + + case 457: // Track mobj angle to point + if (mo) + { + INT32 failureangle = FixedAngle((min(max(abs(sides[line->sidenum[0]].textureoffset>>FRACBITS), 0), 360))*FRACUNIT); + INT32 failuredelay = abs(sides[line->sidenum[0]].rowoffset>>FRACBITS); + INT32 failureexectag = line->sidenum[1] != 0xffff ? + (INT32)(sides[line->sidenum[1]].textureoffset>>FRACBITS) : 0; + boolean persist = (line->flags & ML_EFFECT2); + mobj_t *anchormo; + + if ((secnum = P_FindSectorFromLineTag(line, -1)) < 0) + return; + + anchormo = P_GetObjectTypeInSectorNum(MT_ANGLEMAN, secnum); + if (!anchormo) + return; + + mo->eflags |= MFE_TRACERANGLE; + P_SetTarget(&mo->tracer, anchormo); + mo->lastlook = persist; // don't disable behavior after first failure + mo->extravalue1 = failureangle; // angle to exceed for failure state + mo->extravalue2 = failureexectag; // exec tag for failure state (angle is not within range) + mo->cusval = mo->cvmem = failuredelay; // cusval = tics to allow failure before line trigger; cvmem = decrement timer + } + break; + + case 458: // Stop tracking mobj angle to point + if (mo && (mo->eflags & MFE_TRACERANGLE)) + { + mo->eflags &= ~MFE_TRACERANGLE; + P_SetTarget(&mo->tracer, NULL); + mo->lastlook = mo->cvmem = mo->cusval = mo->extravalue1 = mo->extravalue2 = 0; + } + break; + + case 459: // Control Text Prompt + // console player only unless NOCLIMB is set + if (mo && mo->player && P_IsLocalPlayer(mo->player) && (!bot || bot != mo)) + { + INT32 promptnum = max(0, (sides[line->sidenum[0]].textureoffset>>FRACBITS)-1); + INT32 pagenum = max(0, (sides[line->sidenum[0]].rowoffset>>FRACBITS)-1); + INT32 postexectag = abs((line->sidenum[1] != 0xFFFF) ? sides[line->sidenum[1]].textureoffset>>FRACBITS : line->tag); + + boolean closetextprompt = (line->flags & ML_BLOCKMONSTERS); + //boolean allplayers = (line->flags & ML_NOCLIMB); + boolean runpostexec = (line->flags & ML_EFFECT1); + boolean blockcontrols = !(line->flags & ML_EFFECT2); + boolean freezerealtime = !(line->flags & ML_EFFECT3); + //boolean freezethinkers = (line->flags & ML_EFFECT4); + boolean callbynamedtag = (line->flags & ML_TFERLINE); + + if (closetextprompt) + F_EndTextPrompt(false, false); + else + { + if (callbynamedtag && sides[line->sidenum[0]].text && sides[line->sidenum[0]].text[0]) + F_GetPromptPageByNamedTag(sides[line->sidenum[0]].text, &promptnum, &pagenum); + F_StartTextPrompt(promptnum, pagenum, mo, runpostexec ? postexectag : 0, blockcontrols, freezerealtime); + } + } + break; + + case 460: // Award rings + { + INT16 rings = (sides[line->sidenum[0]].textureoffset>>FRACBITS); + INT32 delay = (sides[line->sidenum[0]].rowoffset>>FRACBITS); + if (mo && mo->player) + { + if (delay <= 0 || !(leveltime % delay)) + P_GivePlayerRings(mo->player, rings); + } + } + break; + + case 461: // Spawns an object on the map based on texture offsets + { + const mobjtype_t type = (mobjtype_t)(sides[line->sidenum[0]].toptexture); + mobj_t *mobj; + + fixed_t x, y, z; + x = sides[line->sidenum[0]].textureoffset; + y = sides[line->sidenum[0]].rowoffset; + z = line->frontsector->floorheight; + + if (line->flags & ML_NOCLIMB) // If noclimb is set, spawn randomly within a range + { + if (line->sidenum[1] != 0xffff) // Make sure the linedef has a back side + { + x = P_RandomRange(sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[1]].textureoffset>>FRACBITS)<sidenum[0]].rowoffset>>FRACBITS, sides[line->sidenum[1]].rowoffset>>FRACBITS)<frontsector->floorheight>>FRACBITS, line->frontsector->ceilingheight>>FRACBITS)<special); + break; + } + } + + mobj = P_SpawnMobj(x, y, z, type); + if (mobj) + CONS_Debug(DBG_GAMELOGIC, "Linedef Type %d - Spawn Object: %d spawned at (%d, %d, %d)\n", line->special, mobj->type, mobj->x>>FRACBITS, mobj->y>>FRACBITS, mobj->z>>FRACBITS); //TODO: Convert mobj->type to a string somehow. + else + CONS_Alert(CONS_ERROR,"Linedef Type %d - Spawn Object: Object did not spawn!\n", line->special); + } + break; + + case 462: // Stop clock (and end level in record attack) + if (G_PlatformGametype()) + { + stoppedclock = true; + CONS_Debug(DBG_GAMELOGIC, "Clock stopped!\n"); + if (modeattacking) + { + UINT8 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + P_DoPlayerExit(&players[i]); + } + } + } + break; + #ifdef POLYOBJECTS case 480: // Polyobj_DoorSlide case 481: // Polyobj_DoorSwing @@ -3152,6 +4065,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) case 491: PolyTranslucency(line); break; + case 492: + PolyFade(line); + break; #endif default: @@ -3178,11 +4094,17 @@ void P_SetupSignExit(player_t *player) if (thing->type != MT_SIGN) continue; + if (!numfound + && !(player->mo->target && player->mo->target->type == MT_SIGN) + && !(gametype == GT_COOP && (netgame || multiplayer) && cv_exitmove.value)) + P_SetTarget(&player->mo->target, thing); + if (thing->state != &states[thing->info->spawnstate]) continue; P_SetTarget(&thing->target, player->mo); - P_SetMobjState(thing, S_SIGN1); + P_SetObjectMomZ(thing, 12*FRACUNIT, false); + P_SetMobjState(thing, S_SIGNSPIN1); if (thing->info->seesound) S_StartSound(thing, thing->info->seesound); @@ -3194,20 +4116,26 @@ void P_SetupSignExit(player_t *player) // didn't find any signposts in the exit sector. // spin all signposts in the level then. - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; thing = (mobj_t *)think; if (thing->type != MT_SIGN) continue; + if (!numfound + && !(player->mo->target && player->mo->target->type == MT_SIGN) + && !(gametype == GT_COOP && (netgame || multiplayer) && cv_exitmove.value)) + P_SetTarget(&player->mo->target, thing); + if (thing->state != &states[thing->info->spawnstate]) continue; P_SetTarget(&thing->target, player->mo); - P_SetMobjState(thing, S_SIGN1); + P_SetObjectMomZ(thing, 12*FRACUNIT, false); + P_SetMobjState(thing, S_SIGNSPIN1); if (thing->info->seesound) S_StartSound(thing, thing->info->seesound); @@ -3224,23 +4152,18 @@ boolean P_IsFlagAtBase(mobjtype_t flag) { thinker_t *think; mobj_t *mo; - INT32 specialnum = 0; + INT32 specialnum = (flag == MT_REDFLAG) ? 3 : 4; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; if (mo->type != flag) continue; - if (mo->type == MT_REDFLAG) - specialnum = 3; - else if (mo->type == MT_BLUEFLAG) - specialnum = 4; - if (GETSECSPECIAL(mo->subsector->sector->special, 4) == specialnum) return true; else if (mo->subsector->sector->ffloors) // Check the 3D floors @@ -3255,9 +4178,11 @@ boolean P_IsFlagAtBase(mobjtype_t flag) if (GETSECSPECIAL(rover->master->frontsector->special, 4) != specialnum) continue; - if (mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) - && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector)) - return true; + if (!(mo->z <= P_GetSpecialTopZ(mo, sectors + rover->secnum, mo->subsector->sector) + && mo->z >= P_GetSpecialBottomZ(mo, sectors + rover->secnum, mo->subsector->sector))) + continue; + + return true; } } } @@ -3304,26 +4229,11 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n // Check the 3D floor's type... if (rover->flags & FF_BLOCKPLAYER) { + boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == topheight)); + boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == bottomheight)); // Thing must be on top of the floor to be affected... - if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) - { - if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight) - continue; - } - else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) - { - if (!(player->mo->eflags & MFE_VERTICALFLIP) - || player->mo->z + player->mo->height != bottomheight) - continue; - } - else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) - { - if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight) - || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight))) - continue; - } + if (!(floorallowed || ceilingallowed)) + continue; } else { @@ -3364,26 +4274,11 @@ sector_t *P_PlayerTouchingSectorSpecial(player_t *player, INT32 section, INT32 n // Check the 3D floor's type... if (rover->flags & FF_BLOCKPLAYER) { + boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == topheight)); + boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == bottomheight)); // Thing must be on top of the floor to be affected... - if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) - { - if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight) - continue; - } - else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) - { - if (!(player->mo->eflags & MFE_VERTICALFLIP) - || player->mo->z + player->mo->height != bottomheight) - continue; - } - else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) - { - if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight) - || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight))) - continue; - } + if (!(floorallowed || ceilingallowed)) + continue; } else { @@ -3434,26 +4329,11 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar // Check the 3D floor's type... if (rover->flags & FF_BLOCKPLAYER) { + boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == top)); + boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == bottom)); // Thing must be on top of the floor to be affected... - if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) - { - if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != top) - return false; - } - else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) - { - if (!(mo->eflags & MFE_VERTICALFLIP) - || mo->z + mo->height != bottom) - return false; - } - else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) - { - if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottom) - || (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == top))) - return false; - } + if (!(floorallowed || ceilingallowed)) + continue; } else { @@ -3475,10 +4355,10 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar // static boolean P_MobjReadyToTrigger(mobj_t *mo, sector_t *sec) { - if (mo->eflags & MFE_VERTICALFLIP) - return (mo->z+mo->height == P_GetSpecialTopZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_CEILING); - else - return (mo->z == P_GetSpecialBottomZ(mo, sec, sec) && sec->flags & SF_FLIPSPECIAL_FLOOR); + boolean floorallowed = ((sec->flags & SF_FLIPSPECIAL_FLOOR) && ((sec->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == P_GetSpecialBottomZ(mo, sec, sec))); + boolean ceilingallowed = ((sec->flags & SF_FLIPSPECIAL_CEILING) && ((sec->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == P_GetSpecialTopZ(mo, sec, sec))); + // Thing must be on top of the floor to be affected... + return (floorallowed || ceilingallowed); } /** Applies a sector special to a player. @@ -3522,19 +4402,19 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers { case 1: // Damage (Generic) if (roversector || P_MobjReadyToTrigger(player->mo, sector)) - P_DamageMobj(player->mo, NULL, NULL, 1); + P_DamageMobj(player->mo, NULL, NULL, 1, 0); break; case 2: // Damage (Water) - if ((roversector || P_MobjReadyToTrigger(player->mo, sector)) && (player->powers[pw_underwater] || player->pflags & PF_NIGHTSMODE) && (player->powers[pw_shield] & SH_NOSTACK) != SH_ELEMENTAL) - P_DamageMobj(player->mo, NULL, NULL, 1); + if ((roversector || P_MobjReadyToTrigger(player->mo, sector)) && (player->powers[pw_underwater] || player->powers[pw_carry] == CR_NIGHTSMODE)) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_WATER); break; case 3: // Damage (Fire) - if ((roversector || P_MobjReadyToTrigger(player->mo, sector)) && (player->powers[pw_shield] & SH_NOSTACK) != SH_ELEMENTAL) - P_DamageMobj(player->mo, NULL, NULL, 1); + if (roversector || P_MobjReadyToTrigger(player->mo, sector)) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_FIRE); break; case 4: // Damage (Electrical) - if ((roversector || P_MobjReadyToTrigger(player->mo, sector)) && (player->powers[pw_shield] & SH_NOSTACK) != SH_ATTRACT) - P_DamageMobj(player->mo, NULL, NULL, 1); + if (roversector || P_MobjReadyToTrigger(player->mo, sector)) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_ELECTRIC); break; case 5: // Spikes // Don't do anything. In Soviet Russia, spikes find you. @@ -3542,49 +4422,38 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 6: // Death Pit (Camera Mod) case 7: // Death Pit (No Camera Mod) if (roversector || P_MobjReadyToTrigger(player->mo, sector)) - P_DamageMobj(player->mo, NULL, NULL, 10000); + { + if (player->quittime) + G_MovePlayerToSpawnOrStarpost(player - players); + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_DEATHPIT); + } break; case 8: // Instant Kill - P_DamageMobj(player->mo, NULL, NULL, 10000); + if (player->quittime) + G_MovePlayerToSpawnOrStarpost(player - players); + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_INSTAKILL); break; case 9: // Ring Drainer (Floor Touch) case 10: // Ring Drainer (No Floor Touch) - if (leveltime % (TICRATE/2) == 0 && player->mo->health > 1) + if (leveltime % (TICRATE/2) == 0 && player->rings > 0) { - player->mo->health--; - player->health--; + player->rings--; S_StartSound(player->mo, sfx_itemup); } break; - case 11: // Special Stage Damage - Kind of like a mini-P_DamageMobj() - if (player->powers[pw_invulnerability] || player->powers[pw_flashing] || player->powers[pw_super] || player->exiting || player->bot) + case 11: // Special Stage Damage + if (player->exiting || player->bot) // Don't do anything for bots or players who have just finished break; - if (!(player->powers[pw_shield] || player->mo->health > 1)) // Don't do anything if no shield or rings anyway + if (!(player->powers[pw_shield] || player->spheres > 0)) // Don't do anything if no shield or spheres anyway break; - if (player->powers[pw_shield]) - { - P_RemoveShield(player); - S_StartSound(player->mo, sfx_shldls); // Ba-Dum! Shield loss. - } - else if (player->mo->health > 1) - { - P_PlayRinglossSound(player->mo); - if (player->mo->health > 10) - player->mo->health -= 10; - else - player->mo->health = 1; - player->health = player->mo->health; - } - - P_DoPlayerPain(player, NULL, NULL); // this does basically everything that was here before - - if (gametype == GT_CTF && player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) - P_PlayerFlagBurst(player, false); + P_SpecialStageDamage(player, NULL, NULL); break; case 12: // Space Countdown - if ((player->powers[pw_shield] & SH_NOSTACK) != SH_ELEMENTAL && !player->powers[pw_spacetime]) + if (!(player->powers[pw_shield] & SH_PROTECTWATER) && !player->powers[pw_spacetime]) player->powers[pw_spacetime] = spacetimetics + 1; break; case 13: // Ramp Sector (Increase step-up/down) @@ -3604,59 +4473,55 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 3: // Linedef executor requires all players present /// \todo check continues for proper splitscreen support? for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !players[i].bot && players[i].mo && (gametype != GT_COOP || players[i].lives > 0)) + { + if (!playeringame[i]) + continue; + if (!players[i].mo) + continue; + if (players[i].spectator) + continue; + if (players[i].bot) + continue; + if (gametype == GT_COOP && players[i].lives <= 0) + continue; + if (roversector) { - if (roversector) + if (sector->flags & SF_TRIGGERSPECIAL_TOUCH) { - if (players[i].mo->subsector->sector == roversector) - ; - else if (sector->flags & SF_TRIGGERSPECIAL_TOUCH) + msecnode_t *node; + for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) { - boolean insector = false; - msecnode_t *node; - for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (node->m_sector == roversector) - { - insector = true; - break; - } - } - if (!insector) - goto DoneSection2; + if (P_ThingIsOnThe3DFloor(players[i].mo, sector, node->m_sector)) + break; } - else + if (!node) goto DoneSection2; - - if (!P_ThingIsOnThe3DFloor(players[i].mo, sector, roversector)) + } + else if (players[i].mo->subsector && !P_ThingIsOnThe3DFloor(players[i].mo, sector, players[i].mo->subsector->sector)) // this function handles basically everything for us lmao + goto DoneSection2; + } + else + { + if (players[i].mo->subsector->sector == sector) + ; + else if (sector->flags & SF_TRIGGERSPECIAL_TOUCH) + { + msecnode_t *node; + for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (node->m_sector == sector) + break; + } + if (!node) goto DoneSection2; } else - { - if (players[i].mo->subsector->sector == sector) - ; - else if (sector->flags & SF_TRIGGERSPECIAL_TOUCH) - { - boolean insector = false; - msecnode_t *node; - for (node = players[i].mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (node->m_sector == sector) - { - insector = true; - break; - } - } - if (!insector) - goto DoneSection2; - } - else - goto DoneSection2; + goto DoneSection2; - if (special == 3 && !P_MobjReadyToTrigger(players[i].mo, sector)) - goto DoneSection2; - } + if (special == 3 && !P_MobjReadyToTrigger(players[i].mo, sector)) + goto DoneSection2; } + } /* FALLTHRU */ case 4: // Linedef executor that doesn't require touching floor case 5: // Linedef executor @@ -3678,14 +4543,14 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers // Find the center of the Eggtrap and release all the pretty animals! // The chimps are my friends.. heeheeheheehehee..... - LouisJM - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; - mo2 = (mobj_t *)th; - if (mo2->type == MT_EGGTRAP) - P_KillMobj(mo2, NULL, player->mo); + if (mo2->type != MT_EGGTRAP) + continue; + P_KillMobj(mo2, NULL, player->mo, 0); } // clear the special so you can't push the button twice. @@ -3704,7 +4569,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers // Mark all players with the time to exit thingy! for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; P_DoPlayerExit(&players[i]); + } break; } case 10: // Special Stage Time/Rings @@ -3720,14 +4589,13 @@ DoneSection2: // Process Section 3 switch (special) { - case 1: // Ice/Sludge + case 1: // Unused case 2: // Wind/Current - case 3: // Ice/Sludge and Wind/Current + case 3: // Unused case 4: // Conveyor Belt break; - case 5: // Speed pad w/o spin - case 6: // Speed pad w/ spin + case 5: // Speed pad if (player->powers[pw_flashing] != 0 && player->powers[pw_flashing] < TICRATE/2) break; @@ -3737,13 +4605,20 @@ DoneSection2: { angle_t lineangle; fixed_t linespeed; + fixed_t sfxnum; lineangle = R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y); - linespeed = P_AproxDistance(lines[i].v2->x-lines[i].v1->x, lines[i].v2->y-lines[i].v1->y); + linespeed = sides[lines[i].sidenum[0]].textureoffset; - player->mo->angle = lineangle; + if (linespeed == 0) + { + CONS_Debug(DBG_GAMELOGIC, "ERROR: Speed pad (tag %d) at zero speed.\n", sector->tag); + break; + } - if (!demoplayback || P_AnalogMove(player)) + player->mo->angle = player->drawangle = lineangle; + + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; @@ -3769,28 +4644,35 @@ DoneSection2: P_InstaThrust(player->mo, player->mo->angle, linespeed); - if (GETSECSPECIAL(sector->special, 3) == 6 && (player->charability2 == CA2_SPINDASH)) + if ((lines[i].flags & ML_EFFECT5) && (player->charability2 == CA2_SPINDASH)) // Roll! { if (!(player->pflags & PF_SPINNING)) player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); } player->powers[pw_flashing] = TICRATE/3; - S_StartSound(player->mo, sfx_spdpad); + + sfxnum = sides[lines[i].sidenum[0]].toptexture; + + if (!sfxnum) + sfxnum = sfx_spdpad; + + S_StartSound(player->mo, sfxnum); } break; - case 7: // Bustable block sprite parameter - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: + case 6: // Unused + case 7: // Unused + case 8: // Unused + case 9: // Unused + case 10: // Unused + case 11: // Unused + case 12: // Unused + case 13: // Unused + case 14: // Unused + case 15: // Unused break; } @@ -3806,21 +4688,24 @@ DoneSection2: if (!post) break; - P_TouchSpecialThing(post, player->mo, false); + P_TouchStarPost(post, player, false); break; } case 2: // Special stage GOAL sector / Exit Sector / CTF Flag Return - if (player->bot) + if (player->bot || !(gametyperules & GTR_ALLOWEXIT)) break; - if (!useNightsSS && G_IsSpecialStage(gamemap) && sstimer > 6) - sstimer = 6; // Just let P_Ticker take care of the rest. + if (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap) && player->nightstime > 6) + { + player->nightstime = 6; // Just let P_Ticker take care of the rest. + return; + } // Exit (for FOF exits; others are handled in P_PlayerThink in p_user.c) { INT32 lineindex; - P_DoPlayerExit(player); + P_DoPlayerFinish(player); P_SetupSignExit(player); // important: use sector->tag on next line instead of player->mo->subsector->tag @@ -3837,13 +4722,13 @@ DoneSection2: nextmapoverride = (INT16)(lines[lineindex].frontsector->floorheight>>FRACBITS); if (lines[lineindex].flags & ML_NOCLIMB) - skipstats = true; + skipstats = 1; } } break; case 3: // Red Team's Base - if (gametype == GT_CTF && P_IsObjectOnGround(player->mo)) + if ((gametyperules & GTR_TEAMFLAGS) && P_IsObjectOnGround(player->mo)) { if (player->ctfteam == 1 && (player->gotflag & GF_BLUEFLAG)) { @@ -3854,9 +4739,9 @@ DoneSection2: if (!P_IsFlagAtBase(MT_REDFLAG)) break; - HU_SetCEchoFlags(0); + HU_SetCEchoFlags(V_AUTOFADEOUT|V_ALLOWLOWERCASE); HU_SetCEchoDuration(5); - HU_DoCEcho(va(M_GetText("%s\\captured the blue flag.\\\\\\\\"), player_names[player-players])); + HU_DoCEcho(va(M_GetText("%s%s%s\\CAPTURED THE %sBLUE FLAG%s.\\\\\\\\"), "\x85", player_names[player-players], "\x80", "\x84", "\x80")); if (splitscreen || players[consoleplayer].ctfteam == 1) S_StartSound(NULL, sfx_flgcap); @@ -3876,7 +4761,7 @@ DoneSection2: break; case 4: // Blue Team's Base - if (gametype == GT_CTF && P_IsObjectOnGround(player->mo)) + if ((gametyperules & GTR_TEAMFLAGS) && P_IsObjectOnGround(player->mo)) { if (player->ctfteam == 2 && (player->gotflag & GF_REDFLAG)) { @@ -3887,9 +4772,9 @@ DoneSection2: if (!P_IsFlagAtBase(MT_BLUEFLAG)) break; - HU_SetCEchoFlags(0); + HU_SetCEchoFlags(V_AUTOFADEOUT|V_ALLOWLOWERCASE); HU_SetCEchoDuration(5); - HU_DoCEcho(va(M_GetText("%s\\captured the red flag.\\\\\\\\"), player_names[player-players])); + HU_DoCEcho(va(M_GetText("%s%s%s\\CAPTURED THE %sRED FLAG%s.\\\\\\\\"), "\x84", player_names[player-players], "\x80", "\x85", "\x80")); if (splitscreen || players[consoleplayer].ctfteam == 2) S_StartSound(NULL, sfx_flgcap); @@ -3916,7 +4801,7 @@ DoneSection2: P_ResetPlayer(player); if (player->panim != PA_FALL) - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); break; case 6: // Super Sonic transformer @@ -3928,7 +4813,7 @@ DoneSection2: if (!(player->pflags & PF_SPINNING) && P_IsObjectOnGround(player->mo) && (player->charability2 == CA2_SPINDASH)) { player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartAttackSound(player->mo, sfx_spin); if (abs(player->rmomx) < FixedMul(5*FRACUNIT, player->mo->scale) @@ -3947,7 +4832,7 @@ DoneSection2: mobj_t *mo2; angle_t an; - if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) + if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE) break; // Find line #3 tagged to this sector @@ -3960,24 +4845,33 @@ DoneSection2: } // Grab speed and sequence values - speed = abs(lines[lineindex].dx)/8; - sequence = abs(lines[lineindex].dy)>>FRACBITS; + speed = abs(sides[lines[lineindex].sidenum[0]].textureoffset)/8; + sequence = abs(sides[lines[lineindex].sidenum[0]].rowoffset)>>FRACBITS; + + if (speed == 0) + { + CONS_Debug(DBG_GAMELOGIC, "ERROR: Waypoint sequence %d at zero speed.\n", sequence); + break; + } // scan the thinkers // to find the first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence - && mo2->health == 0) - { - waypoint = mo2; - break; - } + if (mo2->type != MT_TUBEWAYPOINT) + continue; + if (mo2->threshold != sequence) + continue; + if (mo2->health != 0) + continue; + + waypoint = mo2; + break; } if (!waypoint) @@ -3996,15 +4890,15 @@ DoneSection2: break; // behind back P_SetTarget(&player->mo->tracer, waypoint); + player->powers[pw_carry] = CR_ZOOMTUBE; player->speed = speed; player->pflags |= PF_SPINNING; - player->pflags &= ~PF_JUMPED; - player->pflags &= ~PF_GLIDING; + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_GLIDING|PF_BOUNCING|PF_SLIDING|PF_CANCARRY); player->climbing = 0; - if (!(player->mo->state >= &states[S_PLAY_ATK1] && player->mo->state <= &states[S_PLAY_ATK4])) + if (player->mo->state-states != S_PLAY_ROLL) { - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_spin); } } @@ -4020,7 +4914,7 @@ DoneSection2: mobj_t *mo2; angle_t an; - if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) + if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE) break; // Find line #3 tagged to this sector @@ -4033,25 +4927,33 @@ DoneSection2: } // Grab speed and sequence values - speed = -(abs(lines[lineindex].dx)/8); // Negative means reverse - sequence = abs(lines[lineindex].dy)>>FRACBITS; + speed = -abs(sides[lines[lineindex].sidenum[0]].textureoffset)/8; // Negative means reverse + sequence = abs(sides[lines[lineindex].sidenum[0]].rowoffset)>>FRACBITS; + + if (speed == 0) + { + CONS_Debug(DBG_GAMELOGIC, "ERROR: Waypoint sequence %d at zero speed.\n", sequence); + break; + } // scan the thinkers // to find the last waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_TUBEWAYPOINT && mo2->threshold == sequence) - { - if (!waypoint) - waypoint = mo2; - else if (mo2->health > waypoint->health) - waypoint = mo2; - } + if (mo2->type != MT_TUBEWAYPOINT) + continue; + if (mo2->threshold != sequence) + continue; + + if (!waypoint) + waypoint = mo2; + else if (mo2->health > waypoint->health) + waypoint = mo2; } if (!waypoint) @@ -4070,13 +4972,15 @@ DoneSection2: break; // behind back P_SetTarget(&player->mo->tracer, waypoint); + player->powers[pw_carry] = CR_ZOOMTUBE; player->speed = speed; player->pflags |= PF_SPINNING; - player->pflags &= ~PF_JUMPED; + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_GLIDING|PF_BOUNCING|PF_SLIDING|PF_CANCARRY); + player->climbing = 0; - if (!(player->mo->state >= &states[S_PLAY_ATK1] && player->mo->state <= &states[S_PLAY_ATK4])) + if (player->mo->state-states != S_PLAY_ROLL) { - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); S_StartSound(player->mo, sfx_spin); } } @@ -4089,7 +4993,7 @@ DoneSection2: { player->laps++; - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) player->drillmeter += 48*20; if (player->laps >= (UINT8)cv_numlaps.value) @@ -4098,7 +5002,7 @@ DoneSection2: CONS_Printf(M_GetText("%s started lap %u\n"), player_names[player-players], (UINT32)player->laps+1); // Reset starposts (checkpoints) info - player->starpostangle = player->starposttime = player->starpostnum = 0; + player->starpostscale = player->starpostangle = player->starposttime = player->starpostnum = 0; player->starpostx = player->starposty = player->starpostz = 0; P_ResetStarposts(); @@ -4138,11 +5042,10 @@ DoneSection2: mobj_t *waypointlow = NULL; mobj_t *mo2; mobj_t *closest = NULL; - line_t junk; - vertex_t v1, v2, resulthigh, resultlow; + vector3_t p, line[2], resulthigh, resultlow; mobj_t *highest = NULL; - if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) + if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG) break; if (player->mo->momz > 0) @@ -4171,8 +5074,14 @@ DoneSection2: } // Grab speed and sequence values - speed = abs(lines[lineindex].dx)/8; - sequence = abs(lines[lineindex].dy)>>FRACBITS; + speed = abs(sides[lines[lineindex].sidenum[0]].textureoffset)/8; + sequence = abs(sides[lines[lineindex].sidenum[0]].rowoffset)>>FRACBITS; + + if (speed == 0) + { + CONS_Debug(DBG_GAMELOGIC, "ERROR: Waypoint sequence %d at zero speed.\n", sequence); + break; + } // Find the closest waypoint // Find the preceding waypoint @@ -4182,9 +5091,9 @@ DoneSection2: // scan the thinkers // to find the first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -4220,9 +5129,9 @@ DoneSection2: } // Find waypoint before this one (waypointlow) - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -4247,9 +5156,9 @@ DoneSection2: } // Find waypoint after this one (waypointhigh) - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -4280,38 +5189,34 @@ DoneSection2: // Next, we need to find the closest point on the line between each set, and determine which one we're // closest to. + p.x = player->mo->x; + p.y = player->mo->y; + p.z = player->mo->z; + // Waypointmid and Waypointlow: if (waypointlow) { - v1.x = waypointmid->x; - v1.y = waypointmid->y; - v1.z = waypointmid->z; - v2.x = waypointlow->x; - v2.y = waypointlow->y; - v2.z = waypointlow->z; - junk.v1 = &v1; - junk.v2 = &v2; - junk.dx = v2.x - v1.x; - junk.dy = v2.y - v1.y; + line[0].x = waypointmid->x; + line[0].y = waypointmid->y; + line[0].z = waypointmid->z; + line[1].x = waypointlow->x; + line[1].y = waypointlow->y; + line[1].z = waypointlow->z; - P_ClosestPointOnLine3D(player->mo->x, player->mo->y, player->mo->z, &junk, &resultlow); + P_ClosestPointOnLine3D(&p, line, &resultlow); } // Waypointmid and Waypointhigh: if (waypointhigh) { - v1.x = waypointmid->x; - v1.y = waypointmid->y; - v1.z = waypointmid->z; - v2.x = waypointhigh->x; - v2.y = waypointhigh->y; - v2.z = waypointhigh->z; - junk.v1 = &v1; - junk.v2 = &v2; - junk.dx = v2.x - v1.x; - junk.dy = v2.y - v1.y; + line[0].x = waypointmid->x; + line[0].y = waypointmid->y; + line[0].z = waypointmid->z; + line[1].x = waypointhigh->x; + line[1].y = waypointhigh->y; + line[1].z = waypointhigh->z; - P_ClosestPointOnLine3D(player->mo->x, player->mo->y, player->mo->z, &junk, &resulthigh); + P_ClosestPointOnLine3D(&p, line, &resulthigh); } // 3D support now available. Disregard the previous notice here. -Red @@ -4363,6 +5268,7 @@ DoneSection2: } P_SetTarget(&player->mo->tracer, closest); + player->powers[pw_carry] = CR_ROPEHANG; // Option for static ropes. if (lines[lineindex].flags & ML_NOCLIMB) @@ -4370,16 +5276,12 @@ DoneSection2: else player->speed = speed; - player->pflags |= PF_ROPEHANG; - S_StartSound(player->mo, sfx_s3k4a); - player->pflags &= ~PF_JUMPED; - player->pflags &= ~PF_GLIDING; - player->pflags &= ~PF_SLIDING; + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_GLIDING|PF_BOUNCING|PF_SLIDING|PF_CANCARRY); player->climbing = 0; P_SetThingPosition(player->mo); - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); + P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); } break; case 12: // Camera noclip @@ -4423,26 +5325,11 @@ sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo) if (((rover->flags & FF_BLOCKPLAYER) && mo->player) || ((rover->flags & FF_BLOCKOTHERS) && !mo->player)) { + boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(mo->eflags & MFE_VERTICALFLIP)) && (mo->z == topheight)); + boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (mo->eflags & MFE_VERTICALFLIP)) && (mo->z + mo->height == bottomheight)); // Thing must be on top of the floor to be affected... - if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) - { - if ((mo->eflags & MFE_VERTICALFLIP) || mo->z != topheight) - continue; - } - else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) - { - if (!(mo->eflags & MFE_VERTICALFLIP) - || mo->z + mo->height != bottomheight) - continue; - } - else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) - { - if (!((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height == bottomheight) - || (!(mo->eflags & MFE_VERTICALFLIP) && mo->z == topheight))) - continue; - } + if (!(floorallowed || ceilingallowed)) + continue; } else { @@ -4485,26 +5372,11 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) // Check the 3D floor's type... if (rover->flags & FF_BLOCKPLAYER) { + boolean floorallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == topheight)); + boolean ceilingallowed = ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) && ((rover->master->frontsector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == bottomheight)); // Thing must be on top of the floor to be affected... - if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING)) - { - if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != topheight) - continue; - } - else if ((rover->master->frontsector->flags & SF_FLIPSPECIAL_CEILING) - && !(rover->master->frontsector->flags & SF_FLIPSPECIAL_FLOOR)) - { - if (!(player->mo->eflags & MFE_VERTICALFLIP) - || player->mo->z + player->mo->height != bottomheight) - continue; - } - else if (rover->master->frontsector->flags & SF_FLIPSPECIAL_BOTH) - { - if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == bottomheight) - || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == topheight))) - continue; - } + if (!(floorallowed || ceilingallowed)) + continue; } else { @@ -4561,38 +5433,16 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector) } if (!(po->flags & POF_TESTHEIGHT)) // Don't do height checking - { - } + ; else if (po->flags & POF_SOLID) { + boolean floorallowed = ((polysec->flags & SF_FLIPSPECIAL_FLOOR) && ((polysec->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == polysec->ceilingheight)); + boolean ceilingallowed = ((polysec->flags & SF_FLIPSPECIAL_CEILING) && ((polysec->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == polysec->floorheight)); // Thing must be on top of the floor to be affected... - if ((polysec->flags & SF_FLIPSPECIAL_FLOOR) - && !(polysec->flags & SF_FLIPSPECIAL_CEILING)) + if (!(floorallowed || ceilingallowed)) { - if ((player->mo->eflags & MFE_VERTICALFLIP) || player->mo->z != polysec->ceilingheight) - { - po = (polyobj_t *)(po->link.next); - continue; - } - } - else if ((polysec->flags & SF_FLIPSPECIAL_CEILING) - && !(polysec->flags & SF_FLIPSPECIAL_FLOOR)) - { - if (!(player->mo->eflags & MFE_VERTICALFLIP) - || player->mo->z + player->mo->height != polysec->floorheight) - { - po = (polyobj_t *)(po->link.next); - continue; - } - } - else if (polysec->flags & SF_FLIPSPECIAL_BOTH) - { - if (!((player->mo->eflags & MFE_VERTICALFLIP && player->mo->z + player->mo->height == polysec->floorheight) - || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->z == polysec->ceilingheight))) - { - po = (polyobj_t *)(po->link.next); - continue; - } + po = (polyobj_t *)(po->link.next); + continue; } } else @@ -4664,7 +5514,7 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) switch(GETSECSPECIAL(sector->special, 4)) { case 2: // Level Exit / GOAL Sector / Flag Return - if (!useNightsSS && G_IsSpecialStage(gamemap)) + if (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap)) { // Special stage GOAL sector // requires touching floor. @@ -4691,17 +5541,13 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) f_affectpoint = P_GetSpecialBottomZ(player->mo, sector, sector); c_affectpoint = P_GetSpecialTopZ(player->mo, sector, sector); - // Only go further if on the ground - if ((sector->flags & SF_FLIPSPECIAL_FLOOR) && !(sector->flags & SF_FLIPSPECIAL_CEILING) && player->mo->z != f_affectpoint) - return; - - if ((sector->flags & SF_FLIPSPECIAL_CEILING) && !(sector->flags & SF_FLIPSPECIAL_FLOOR) && player->mo->z + player->mo->height != c_affectpoint) - return; - - if ((sector->flags & SF_FLIPSPECIAL_BOTH) - && player->mo->z != f_affectpoint - && player->mo->z + player->mo->height != c_affectpoint) - return; + { + boolean floorallowed = ((sector->flags & SF_FLIPSPECIAL_FLOOR) && ((sector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || !(player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z == f_affectpoint)); + boolean ceilingallowed = ((sector->flags & SF_FLIPSPECIAL_CEILING) && ((sector->flags & SF_TRIGGERSPECIAL_HEADBUMP) || (player->mo->eflags & MFE_VERTICALFLIP)) && (player->mo->z + player->mo->height == c_affectpoint)); + // Thing must be on top of the floor to be affected... + if (!(floorallowed || ceilingallowed)) + return; + } P_ProcessSpecialSector(player, sector, NULL); } @@ -4769,11 +5615,6 @@ void P_UpdateSpecials(void) // POINT LIMIT P_CheckPointLimit(); -#ifdef ESLOPE - // Dynamic slopeness - P_RunDynamicSlopes(); -#endif - // ANIMATE TEXTURES for (anim = anims; anim < lastanim; anim++) { @@ -4794,13 +5635,23 @@ void P_UpdateSpecials(void) { if (foundflats->speed) // it is an animated flat { + // update the levelflat texture number + if ((foundflats->type == LEVELFLAT_TEXTURE) && (foundflats->u.texture.basenum != -1)) + foundflats->u.texture.num = foundflats->u.texture.basenum + ((leveltime/foundflats->speed + foundflats->animseq) % foundflats->numpics); // update the levelflat lump number - foundflats->lumpnum = foundflats->baselumpnum + - ((leveltime/foundflats->speed + foundflats->animseq) % foundflats->numpics); + else if ((foundflats->type == LEVELFLAT_FLAT) && (foundflats->u.flat.baselumpnum != LUMPERROR)) + foundflats->u.flat.lumpnum = foundflats->u.flat.baselumpnum + ((leveltime/foundflats->speed + foundflats->animseq) % foundflats->numpics); } } } +/** Gets a 3Dfloor by control sector. + * + * \param sec Target sector. + * \param sec2 Control sector. + * \return Pointer to found 3Dfloor, or NULL. + * \sa P_GetFFloorByID + */ static inline ffloor_t *P_GetFFloorBySec(sector_t *sec, sector_t *sec2) { ffloor_t *rover; @@ -4813,29 +5664,49 @@ static inline ffloor_t *P_GetFFloorBySec(sector_t *sec, sector_t *sec2) return NULL; } +/** Gets a 3Dfloor by ID number. + * + * \param sec Target sector. + * \param id ID of 3Dfloor in target sector. Note that the first FOF's ID is 0. + * \return Pointer to found 3Dfloor, or NULL. + * \sa P_GetFFloorBySec + */ +ffloor_t *P_GetFFloorByID(sector_t *sec, UINT16 id) +{ + ffloor_t *rover; + UINT16 i = 0; + + if (!sec->ffloors) + return NULL; + for (rover = sec->ffloors; rover; rover = rover->next) + if (i++ == id) + return rover; + return NULL; +} + /** Adds a newly formed 3Dfloor structure to a sector's ffloors list. * * \param sec Target sector. - * \param ffloor Newly formed 3Dfloor structure. + * \param fflr Newly formed 3Dfloor structure. * \sa P_AddFakeFloor */ -static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) +static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *fflr) { ffloor_t *rover; if (!sec->ffloors) { - sec->ffloors = ffloor; - ffloor->next = 0; - ffloor->prev = 0; + sec->ffloors = fflr; + fflr->next = 0; + fflr->prev = 0; return; } for (rover = sec->ffloors; rover->next; rover = rover->next); - rover->next = ffloor; - ffloor->prev = rover; - ffloor->next = 0; + rover->next = fflr; + fflr->prev = rover; + fflr->next = 0; } /** Adds a 3Dfloor. @@ -4850,7 +5721,7 @@ static inline void P_AddFFloorToList(sector_t *sec, ffloor_t *ffloor) */ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, ffloortype_e flags, thinkerlist_t *secthinkers) { - ffloor_t *ffloor; + ffloor_t *fflr; thinker_t *th; friction_t *f; pusher_t *p; @@ -4860,8 +5731,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (sec == sec2) return NULL; //Don't need a fake floor on a control sector. - if ((ffloor = (P_GetFFloorBySec(sec, sec2)))) - return ffloor; // If this ffloor already exists, return it + if ((fflr = (P_GetFFloorBySec(sec, sec2)))) + return fflr; // If this ffloor already exists, return it if (sec2->ceilingheight < sec2->floorheight) { @@ -4900,27 +5771,31 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f } // Add the floor - ffloor = Z_Calloc(sizeof (*ffloor), PU_LEVEL, NULL); - ffloor->secnum = sec2 - sectors; - ffloor->target = sec; - ffloor->bottomheight = &sec2->floorheight; - ffloor->bottompic = &sec2->floorpic; - ffloor->bottomxoffs = &sec2->floor_xoffs; - ffloor->bottomyoffs = &sec2->floor_yoffs; - ffloor->bottomangle = &sec2->floorpic_angle; + fflr = Z_Calloc(sizeof (*fflr), PU_LEVEL, NULL); + fflr->secnum = sec2 - sectors; + fflr->target = sec; + fflr->bottomheight = &sec2->floorheight; + fflr->bottompic = &sec2->floorpic; + fflr->bottomxoffs = &sec2->floor_xoffs; + fflr->bottomyoffs = &sec2->floor_yoffs; + fflr->bottomangle = &sec2->floorpic_angle; // Add the ceiling - ffloor->topheight = &sec2->ceilingheight; - ffloor->toppic = &sec2->ceilingpic; - ffloor->toplightlevel = &sec2->lightlevel; - ffloor->topxoffs = &sec2->ceiling_xoffs; - ffloor->topyoffs = &sec2->ceiling_yoffs; - ffloor->topangle = &sec2->ceilingpic_angle; + fflr->topheight = &sec2->ceilingheight; + fflr->toppic = &sec2->ceilingpic; + fflr->toplightlevel = &sec2->lightlevel; + fflr->topxoffs = &sec2->ceiling_xoffs; + fflr->topyoffs = &sec2->ceiling_yoffs; + fflr->topangle = &sec2->ceilingpic_angle; #ifdef ESLOPE // Add slopes - ffloor->t_slope = &sec2->c_slope; - ffloor->b_slope = &sec2->f_slope; + fflr->t_slope = &sec2->c_slope; + fflr->b_slope = &sec2->f_slope; + // mark the target sector as having slopes, if the FOF has any of its own + // (this fixes FOF slopes glitching initially at level load in software mode) + if (sec2->hasslope) + sec->hasslope = true; #endif if ((flags & FF_SOLID) && (master->flags & ML_EFFECT1)) // Block player only @@ -4929,10 +5804,10 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if ((flags & FF_SOLID) && (master->flags & ML_EFFECT2)) // Block all BUT player flags &= ~FF_BLOCKPLAYER; - ffloor->spawnflags = ffloor->flags = flags; - ffloor->master = master; - ffloor->norender = INFTICS; - + fflr->spawnflags = fflr->flags = flags; + fflr->master = master; + fflr->norender = INFTICS; + fflr->fadingdata = NULL; // Scan the thinkers to check for special conditions applying to this FOF. // If we have thinkers sorted by sector, just check the relevant ones; @@ -4942,7 +5817,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f // Just initialise both of these to placate the compiler. i = 0; - th = thinkercap.next; + th = thlist[THINK_MAIN].next; for(;;) { @@ -4952,7 +5827,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f th = secthinkers[sec2num].thinkers[i]; else break; } - else if (th == &thinkercap) + else if (th == &thlist[THINK_MAIN]) break; // Should this FOF have spikeness? @@ -4988,14 +5863,14 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if (flags & FF_TRANSLUCENT) { if (sides[master->sidenum[0]].toptexture > 0) - ffloor->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned + fflr->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned else - ffloor->alpha = 0x80; + fflr->alpha = 0x80; } else - ffloor->alpha = 0xff; + fflr->alpha = 0xff; - ffloor->spawnalpha = ffloor->alpha; // save for netgames + fflr->spawnalpha = fflr->alpha; // save for netgames if (flags & FF_QUICKSAND) CheckForQuicksand = true; @@ -5005,7 +5880,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f if ((flags & FF_MARIO)) { - P_AddBlockThinker(sec2, master); + if (!(flags & FF_SHATTERBOTTOM)) // Don't change the textures of a brick block, just a question block + P_AddBlockThinker(sec2, master); CheckForMarioBlocks = true; } @@ -5018,9 +5894,9 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f CheckForFloatBob = true; } - P_AddFFloorToList(sec, ffloor); + P_AddFFloorToList(sec, fflr); - return ffloor; + return fflr; } // @@ -5041,7 +5917,7 @@ static void P_AddSpikeThinker(sector_t *sec, INT32 referrer) // create and initialize new thinker spikes = Z_Calloc(sizeof (*spikes), PU_LEVSPEC, NULL); - P_AddThinker(&spikes->thinker); + P_AddThinker(THINK_MAIN, &spikes->thinker); spikes->thinker.function.acp1 = (actionf_p1)T_SpikeSector; @@ -5063,7 +5939,7 @@ static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline) // create and initialize new thinker floater = Z_Calloc(sizeof (*floater), PU_LEVSPEC, NULL); - P_AddThinker(&floater->thinker); + P_AddThinker(THINK_MAIN, &floater->thinker); floater->thinker.function.acp1 = (actionf_p1)T_FloatSector; @@ -5087,7 +5963,7 @@ static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec) // create an initialize new thinker bridge = Z_Calloc(sizeof (*bridge), PU_LEVSPEC, NULL); - P_AddThinker(&bridge->thinker); + P_AddThinker(THINK_MAIN, &bridge->thinker); bridge->thinker.function.acp1 = (actionf_p1)T_BridgeThinker; @@ -5105,6 +5981,35 @@ static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec) } */ +/** + * Adds a plane displacement thinker. + * Whenever the "control" sector moves, + * the "affectee" sector's floor or ceiling plane moves too! + * + * \param speed Rate of movement relative to control sector + * \param control Control sector. + * \param affectee Target sector. + * \param reverse Reverse direction? + * \sa P_SpawnSpecials, T_PlaneDisplace + * \author Monster Iestyn + */ +static void P_AddPlaneDisplaceThinker(INT32 type, fixed_t speed, INT32 control, INT32 affectee, UINT8 reverse) +{ + planedisplace_t *displace; + + // create and initialize new displacement thinker + displace = Z_Calloc(sizeof (*displace), PU_LEVSPEC, NULL); + P_AddThinker(THINK_MAIN, &displace->thinker); + + displace->thinker.function.acp1 = (actionf_p1)T_PlaneDisplace; + displace->affectee = affectee; + displace->control = control; + displace->last_height = sectors[control].floorheight; + displace->speed = speed; + displace->type = type; + displace->reverse = reverse; +} + /** Adds a Mario block thinker, which changes the block's texture between blank * and ? depending on whether it has contents. * Needed in case objects respawn inside. @@ -5121,7 +6026,7 @@ static void P_AddBlockThinker(sector_t *sec, line_t *sourceline) // create and initialize new elevator thinker block = Z_Calloc(sizeof (*block), PU_LEVSPEC, NULL); - P_AddThinker(&block->thinker); + P_AddThinker(THINK_MAIN, &block->thinker); block->thinker.function.acp1 = (actionf_p1)T_MarioBlockChecker; block->sourceline = sourceline; @@ -5137,8 +6042,6 @@ static void P_AddBlockThinker(sector_t *sec, line_t *sourceline) * to the lowest nearby height if not * there already. * - * Replaces the old "AirBob". - * * \param sec Control sector. * \param actionsector Target sector. * \param sourceline Control linedef. @@ -5150,7 +6053,7 @@ static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline) levelspecthink_t *raise; raise = Z_Calloc(sizeof (*raise), PU_LEVSPEC, NULL); - P_AddThinker(&raise->thinker); + P_AddThinker(THINK_MAIN, &raise->thinker); raise->thinker.function.acp1 = (actionf_p1)T_RaiseSector; @@ -5183,13 +6086,12 @@ static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline) raise->sourceline = sourceline; } -// Function to maintain backwards compatibility -static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust) +static void P_AddAirbob(sector_t *sec, line_t *sourceline, boolean noadjust, boolean dynamic) { levelspecthink_t *airbob; airbob = Z_Calloc(sizeof (*airbob), PU_LEVSPEC, NULL); - P_AddThinker(&airbob->thinker); + P_AddThinker(THINK_MAIN, &airbob->thinker); airbob->thinker.function.acp1 = (actionf_p1)T_RaiseSector; @@ -5222,6 +6124,8 @@ static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust) airbob->vars[4] = airbob->vars[5] - (sec->ceilingheight - sec->floorheight); + airbob->vars[9] = dynamic ? 1 : 0; + airbob->sourceline = sourceline; } @@ -5250,7 +6154,7 @@ static inline void P_AddThwompThinker(sector_t *sec, sector_t *actionsector, lin // create and initialize new elevator thinker thwomp = Z_Calloc(sizeof (*thwomp), PU_LEVSPEC, NULL); - P_AddThinker(&thwomp->thinker); + P_AddThinker(THINK_MAIN, &thwomp->thinker); thwomp->thinker.function.acp1 = (actionf_p1)T_ThwompSector; @@ -5286,7 +6190,7 @@ static inline void P_AddNoEnemiesThinker(sector_t *sec, line_t *sourceline) // create and initialize new thinker nobaddies = Z_Calloc(sizeof (*nobaddies), PU_LEVSPEC, NULL); - P_AddThinker(&nobaddies->thinker); + P_AddThinker(THINK_MAIN, &nobaddies->thinker); nobaddies->thinker.function.acp1 = (actionf_p1)T_NoEnemiesSector; @@ -5302,13 +6206,13 @@ static inline void P_AddNoEnemiesThinker(sector_t *sec, line_t *sourceline) * \sa P_SpawnSpecials, T_EachTimeThinker * \author SSNTails */ -static inline void P_AddEachTimeThinker(sector_t *sec, line_t *sourceline) +static void P_AddEachTimeThinker(sector_t *sec, line_t *sourceline) { levelspecthink_t *eachtime; // create and initialize new thinker eachtime = Z_Calloc(sizeof (*eachtime), PU_LEVSPEC, NULL); - P_AddThinker(&eachtime->thinker); + P_AddThinker(THINK_MAIN, &eachtime->thinker); eachtime->thinker.function.acp1 = (actionf_p1)T_EachTimeThinker; @@ -5330,7 +6234,7 @@ static inline void P_AddCameraScanner(sector_t *sourcesec, sector_t *actionsecto // create and initialize new elevator thinker elevator = Z_Calloc(sizeof (*elevator), PU_LEVSPEC, NULL); - P_AddThinker(&elevator->thinker); + P_AddThinker(THINK_MAIN, &elevator->thinker); elevator->thinker.function.acp1 = (actionf_p1)T_CameraScanner; elevator->type = elevateBounce; @@ -5341,7 +6245,7 @@ static inline void P_AddCameraScanner(sector_t *sourcesec, sector_t *actionsecto elevator->distance = FixedInt(AngleFixed(angle)); } -static const ffloortype_e laserflags = FF_EXISTS|FF_RENDERALL|FF_NOSHADE|FF_EXTRA|FF_CUTEXTRA; +static const ffloortype_e laserflags = FF_EXISTS|FF_RENDERALL|FF_NOSHADE|FF_EXTRA|FF_CUTEXTRA|FF_TRANSLUCENT; /** Flashes a laser block. * @@ -5354,28 +6258,30 @@ void T_LaserFlash(laserthink_t *flash) msecnode_t *node; mobj_t *thing; sector_t *sourcesec; - ffloor_t *ffloor = flash->ffloor; + ffloor_t *fflr = flash->ffloor; sector_t *sector = flash->sector; fixed_t top, bottom; - if (!ffloor || !(ffloor->flags & FF_EXISTS)) + if (!fflr || !(fflr->flags & FF_EXISTS)) return; - if (leveltime & 1) - ffloor->flags |= FF_RENDERALL; + if (leveltime & 2) + //fflr->flags |= FF_RENDERALL; + fflr->alpha = 0xB0; else - ffloor->flags &= ~FF_RENDERALL; + //fflr->flags &= ~FF_RENDERALL; + fflr->alpha = 0x90; - sourcesec = ffloor->master->frontsector; // Less to type! + sourcesec = fflr->master->frontsector; // Less to type! #ifdef ESLOPE - top = (*ffloor->t_slope) ? P_GetZAt(*ffloor->t_slope, sector->soundorg.x, sector->soundorg.y) - : *ffloor->topheight; - bottom = (*ffloor->b_slope) ? P_GetZAt(*ffloor->b_slope, sector->soundorg.x, sector->soundorg.y) - : *ffloor->bottomheight; + top = (*fflr->t_slope) ? P_GetZAt(*fflr->t_slope, sector->soundorg.x, sector->soundorg.y) + : *fflr->topheight; + bottom = (*fflr->b_slope) ? P_GetZAt(*fflr->b_slope, sector->soundorg.x, sector->soundorg.y) + : *fflr->bottomheight; sector->soundorg.z = (top + bottom)/2; #else - sector->soundorg.z = (*ffloor->topheight + *ffloor->bottomheight)/2; + sector->soundorg.z = (*fflr->topheight + *fflr->bottomheight)/2; #endif S_StartSound(§or->soundorg, sfx_laser); @@ -5384,7 +6290,7 @@ void T_LaserFlash(laserthink_t *flash) { thing = node->m_thing; - if ((ffloor->master->flags & ML_EFFECT1) + if ((fflr->master->flags & ML_EFFECT1) && thing->flags & MF_BOSS) continue; // Don't hurt bosses @@ -5400,15 +6306,15 @@ void T_LaserFlash(laserthink_t *flash) continue; if (thing->flags & MF_SHOOTABLE) - P_DamageMobj(thing, NULL, NULL, 1); + P_DamageMobj(thing, NULL, NULL, 1, 0); else if (thing->type == MT_EGGSHIELD) - P_KillMobj(thing, NULL, NULL); + P_KillMobj(thing, NULL, NULL, 0); } } /** Adds a laser thinker to a 3Dfloor. * - * \param ffloor 3Dfloor to turn into a laser block. + * \param fflr 3Dfloor to turn into a laser block. * \param sector Target sector. * \param secthkiners Lists of thinkers sorted by sector. May be NULL. * \sa T_LaserFlash @@ -5417,17 +6323,17 @@ void T_LaserFlash(laserthink_t *flash) static inline void EV_AddLaserThinker(sector_t *sec, sector_t *sec2, line_t *line, thinkerlist_t *secthinkers) { laserthink_t *flash; - ffloor_t *ffloor = P_AddFakeFloor(sec, sec2, line, laserflags, secthinkers); + ffloor_t *fflr = P_AddFakeFloor(sec, sec2, line, laserflags, secthinkers); - if (!ffloor) + if (!fflr) return; flash = Z_Calloc(sizeof (*flash), PU_LEVSPEC, NULL); - P_AddThinker(&flash->thinker); + P_AddThinker(THINK_MAIN, &flash->thinker); flash->thinker.function.acp1 = (actionf_p1)T_LaserFlash; - flash->ffloor = ffloor; + flash->ffloor = fflr; flash->sector = sec; // For finding mobjs flash->sec = sec2; flash->sourceline = line; @@ -5450,6 +6356,63 @@ static void P_RunLevelLoadExecutors(void) } } +/** Before things are loaded, initialises certain stuff in case they're needed + * by P_SpawnSlopes or P_LoadThings. This was split off from + * P_SpawnSpecials, in case you couldn't tell. + * + * \sa P_SpawnSpecials, P_InitTagLists + * \author Monster Iestyn + */ +void P_InitSpecials(void) +{ + // Set the default gravity. Custom gravity overrides this setting. + gravity = FRACUNIT/2; + + // Defaults in case levels don't have them set. + sstimer = 90*TICRATE + 6; + ssspheres = 1; + + CheckForBustableBlocks = CheckForBouncySector = CheckForQuicksand = CheckForMarioBlocks = CheckForFloatBob = CheckForReverseGravity = false; + + // Set curWeather + switch (mapheaderinfo[gamemap-1]->weather) + { + case PRECIP_SNOW: // snow + case PRECIP_RAIN: // rain + case PRECIP_STORM: // storm + case PRECIP_STORM_NORAIN: // storm w/o rain + case PRECIP_STORM_NOSTRIKES: // storm w/o lightning + curWeather = mapheaderinfo[gamemap-1]->weather; + break; + default: // blank/none + curWeather = PRECIP_NONE; + break; + } + + // Set globalweather + globalweather = mapheaderinfo[gamemap-1]->weather; + + P_InitTagLists(); // Create xref tables for tags +} + +static void P_ApplyFlatAlignment(line_t *master, sector_t *sector, angle_t flatangle, fixed_t xoffs, fixed_t yoffs) +{ + if (!(master->flags & ML_NETONLY)) // Modify floor flat alignment unless ML_NETONLY flag is set + { + sector->floorpic_angle = flatangle; + sector->floor_xoffs += xoffs; + sector->floor_yoffs += yoffs; + } + + if (!(master->flags & ML_NONET)) // Modify ceiling flat alignment unless ML_NONET flag is set + { + sector->ceilingpic_angle = flatangle; + sector->ceiling_xoffs += xoffs; + sector->ceiling_yoffs += yoffs; + } + +} + /** After the map has loaded, scans for specials that spawn 3Dfloors and * thinkers. * @@ -5459,26 +6422,20 @@ static void P_RunLevelLoadExecutors(void) * as they'll just be erased by UnArchiveThinkers. * \sa P_SpawnPrecipitation, P_SpawnFriction, P_SpawnPushers, P_SpawnScrollers */ -void P_SpawnSpecials(INT32 fromnetsave) +void P_SpawnSpecials(boolean fromnetsave) { sector_t *sector; size_t i; INT32 j; thinkerlist_t *secthinkers; thinker_t *th; - // This used to be used, and *should* be used in the future, // but currently isn't. (void)fromnetsave; - // Set the default gravity. Custom gravity overrides this setting. - gravity = FRACUNIT/2; - - // Defaults in case levels don't have them set. - sstimer = 90*TICRATE + 6; - totalrings = 1; - - CheckForBustableBlocks = CheckForBouncySector = CheckForQuicksand = CheckForMarioBlocks = CheckForFloatBob = CheckForReverseGravity = false; + // yep, we do this here - "bossdisabled" is considered an apparatus of specials. + bossdisabled = 0; + stoppedclock = false; // Init special SECTORs. sector = sectors; @@ -5504,7 +6461,7 @@ void P_SpawnSpecials(INT32 fromnetsave) { case 10: // Time for special stage sstimer = (sector->floorheight>>FRACBITS) * TICRATE + 6; // Time to finish - totalrings = sector->ceilingheight>>FRACBITS; // Ring count for special stage + ssspheres = sector->ceilingheight>>FRACBITS; // Ring count for special stage break; case 11: // Custom global gravity! @@ -5528,22 +6485,6 @@ void P_SpawnSpecials(INT32 fromnetsave) } } - if (mapheaderinfo[gamemap-1]->weather == 2) // snow - curWeather = PRECIP_SNOW; - else if (mapheaderinfo[gamemap-1]->weather == 3) // rain - curWeather = PRECIP_RAIN; - else if (mapheaderinfo[gamemap-1]->weather == 1) // storm - curWeather = PRECIP_STORM; - else if (mapheaderinfo[gamemap-1]->weather == 5) // storm w/o rain - curWeather = PRECIP_STORM_NORAIN; - else if (mapheaderinfo[gamemap-1]->weather == 6) // storm w/o lightning - curWeather = PRECIP_STORM_NOSTRIKES; - else - curWeather = PRECIP_NONE; - - P_InitTagLists(); // Create xref tables for tags - P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line - P_SpawnScrollers(); // Add generalized scrollers P_SpawnFriction(); // Friction model using linedefs P_SpawnPushers(); // Pusher model using linedefs @@ -5553,7 +6494,7 @@ void P_SpawnSpecials(INT32 fromnetsave) secthinkers = Z_Calloc(numsectors * sizeof(thinkerlist_t), PU_STATIC, NULL); // Firstly, find out how many there are in each sector - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MAIN].next; th != &thlist[THINK_MAIN]; th = th->next) { if (th->function.acp1 == (actionf_p1)T_SpikeSector) secthinkers[((levelspecthink_t *)th)->sector - sectors].count++; @@ -5573,7 +6514,7 @@ void P_SpawnSpecials(INT32 fromnetsave) } // Finally, populate the lists. - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MAIN].next; th != &thlist[THINK_MAIN]; th = th->next) { size_t secnum = (size_t)-1; @@ -5592,29 +6533,18 @@ void P_SpawnSpecials(INT32 fromnetsave) // Init line EFFECTs for (i = 0; i < numlines; i++) { - // set line specials to 0 here too, same reason as above - if (netgame || multiplayer) + if (lines[i].special != 7) // This is a hack. I can at least hope nobody wants to prevent flat alignment in netgames... { - // future: nonet flag? - } - else if ((lines[i].flags & ML_NETONLY) == ML_NETONLY) - { - lines[i].special = 0; - continue; - } - else - { - if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) + // set line specials to 0 here too, same reason as above + if (netgame || multiplayer) { - lines[i].special = 0; - continue; + if (lines[i].flags & ML_NONET) + { + lines[i].special = 0; + continue; + } } - if (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - { - lines[i].special = 0; - continue; - } - if (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX)) + else if (lines[i].flags & ML_NETONLY) { lines[i].special = 0; continue; @@ -5657,53 +6587,37 @@ void P_SpawnSpecials(INT32 fromnetsave) P_AddCameraScanner(§ors[sec], §ors[s], R_PointToAngle2(lines[i].v2->x, lines[i].v2->y, lines[i].v1->x, lines[i].v1->y)); break; -#ifdef PARANOIA - case 6: // Disable tags if level not cleared - I_Error("Failed to catch a disable linedef"); - break; -#endif - - case 7: // Flat alignment - if (lines[i].flags & ML_EFFECT4) // Align angle + case 7: // Flat alignment - redone by toast + if ((lines[i].flags & (ML_NETONLY|ML_NONET)) != (ML_NETONLY|ML_NONET)) // If you can do something... { - if (!(lines[i].flags & ML_EFFECT5)) // Align floor unless ALLTRIGGER flag is set + angle_t flatangle = InvAngle(R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y)); + fixed_t xoffs; + fixed_t yoffs; + + if (lines[i].flags & ML_EFFECT6) // Set offset through x and y texture offsets if ML_EFFECT6 flag is set { - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].spawn_flrpic_angle = sectors[s].floorpic_angle = R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y); + xoffs = sides[lines[i].sidenum[0]].textureoffset; + yoffs = sides[lines[i].sidenum[0]].rowoffset; + } + else // Otherwise, set calculated offsets such that line's v1 is the apparent origin + { + xoffs = -lines[i].v1->x; + yoffs = lines[i].v1->y; } - if (!(lines[i].flags & ML_BOUNCY)) // Align ceiling unless BOUNCY flag is set + //If no tag is given, apply to front sector + if (lines[i].tag == 0) + P_ApplyFlatAlignment(lines + i, lines[i].frontsector, flatangle, xoffs, yoffs); + else { - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - sectors[s].spawn_ceilpic_angle = sectors[s].ceilingpic_angle = R_PointToAngle2(lines[i].v1->x, lines[i].v1->y, lines[i].v2->x, lines[i].v2->y); - } - } - else // Do offsets - { - if (!(lines[i].flags & ML_BLOCKMONSTERS)) // Align floor unless BLOCKMONSTERS flag is set - { - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - { - sectors[s].floor_xoffs += lines[i].dx; - sectors[s].floor_yoffs += lines[i].dy; - // saved for netgames - sectors[s].spawn_flr_xoffs = sectors[s].floor_xoffs; - sectors[s].spawn_flr_yoffs = sectors[s].floor_yoffs; - } - } - - if (!(lines[i].flags & ML_NOCLIMB)) // Align ceiling unless NOCLIMB flag is set - { - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - { - sectors[s].ceiling_xoffs += lines[i].dx; - sectors[s].ceiling_yoffs += lines[i].dy; - // saved for netgames - sectors[s].spawn_ceil_xoffs = sectors[s].ceiling_xoffs; - sectors[s].spawn_ceil_yoffs = sectors[s].ceiling_yoffs; - } + for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0;) + P_ApplyFlatAlignment(lines + i, sectors + s, flatangle, xoffs, yoffs); } } + else // Otherwise, print a helpful warning. Can I do no less? + CONS_Alert(CONS_WARNING, + M_GetText("Flat alignment linedef (tag %d) doesn't have anything to do.\nConsider changing the linedef's flag configuration or removing it entirely.\n"), + lines[i].tag); break; case 8: // Sector Parameters @@ -5719,6 +6633,11 @@ void P_SpawnSpecials(INT32 fromnetsave) if (lines[i].flags & ML_EFFECT3) sectors[s].flags |= SF_TRIGGERSPECIAL_TOUCH; + if (lines[i].flags & ML_EFFECT2) + sectors[s].flags |= SF_TRIGGERSPECIAL_HEADBUMP; + + if (lines[i].flags & ML_EFFECT1) + sectors[s].flags |= SF_INVERTPRECIP; if (lines[i].frontsector && GETSECSPECIAL(lines[i].frontsector->special, 4) == 12) sectors[s].camsec = sides[*lines[i].sidenum].sector-sectors; @@ -5818,6 +6737,19 @@ void P_SpawnSpecials(INT32 fromnetsave) P_AddBridgeThinker(&lines[i], §ors[s]);*/ break; + case 66: // Displace floor by front sector + for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + P_AddPlaneDisplaceThinker(pd_floor, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + break; + case 67: // Displace ceiling by front sector + for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + P_AddPlaneDisplaceThinker(pd_ceiling, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + break; + case 68: // Displace both floor AND ceiling by front sector + for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) + P_AddPlaneDisplaceThinker(pd_both, P_AproxDistance(lines[i].dx, lines[i].dy)>>8, sides[lines[i].sidenum[0]].sector-sectors, s, !!(lines[i].flags & ML_NOCLIMB)); + break; + case 100: // FOF (solid, opaque, shadows) P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); break; @@ -5832,11 +6764,8 @@ void P_SpawnSpecials(INT32 fromnetsave) // Draw the 'insides' of the block too if (lines[i].flags & ML_NOCLIMB) { - ffloorflags |= FF_CUTLEVEL; - ffloorflags |= FF_BOTHPLANES; - ffloorflags |= FF_ALLSIDES; - ffloorflags &= ~FF_EXTRA; - ffloorflags &= ~FF_CUTEXTRA; + ffloorflags |= FF_CUTLEVEL|FF_BOTHPLANES|FF_ALLSIDES; + ffloorflags &= ~(FF_EXTRA|FF_CUTEXTRA); } P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); @@ -5943,11 +6872,8 @@ void P_SpawnSpecials(INT32 fromnetsave) // Draw the 'insides' of the block too if (lines[i].flags & ML_EFFECT2) { - ffloorflags |= FF_CUTLEVEL; - ffloorflags |= FF_BOTHPLANES; - ffloorflags |= FF_ALLSIDES; - ffloorflags &= ~FF_EXTRA; - ffloorflags &= ~FF_CUTEXTRA; + ffloorflags |= FF_CUTLEVEL|FF_BOTHPLANES|FF_ALLSIDES; + ffloorflags &= ~(FF_EXTRA|FF_CUTEXTRA); } P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); @@ -5961,11 +6887,8 @@ void P_SpawnSpecials(INT32 fromnetsave) // Draw the 'insides' of the block too if (lines[i].flags & ML_EFFECT2) { - ffloorflags |= FF_CUTLEVEL; - ffloorflags |= FF_BOTHPLANES; - ffloorflags |= FF_ALLSIDES; - ffloorflags &= ~FF_EXTRA; - ffloorflags &= ~FF_CUTEXTRA; + ffloorflags |= FF_CUTLEVEL|FF_BOTHPLANES|FF_ALLSIDES; + ffloorflags &= ~(FF_EXTRA|FF_CUTEXTRA); } P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); @@ -5989,11 +6912,8 @@ void P_SpawnSpecials(INT32 fromnetsave) // Draw the 'insides' of the block too if (lines[i].flags & ML_EFFECT2) { - ffloorflags |= FF_CUTLEVEL; - ffloorflags |= FF_BOTHPLANES; - ffloorflags |= FF_ALLSIDES; - ffloorflags &= ~FF_EXTRA; - ffloorflags &= ~FF_CUTEXTRA; + ffloorflags |= FF_CUTLEVEL|FF_BOTHPLANES|FF_ALLSIDES; + ffloorflags &= ~(FF_EXTRA|FF_CUTEXTRA); } P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); @@ -6007,29 +6927,31 @@ void P_SpawnSpecials(INT32 fromnetsave) // Draw the 'insides' of the block too if (lines[i].flags & ML_EFFECT2) { - ffloorflags |= FF_CUTLEVEL; - ffloorflags |= FF_BOTHPLANES; - ffloorflags |= FF_ALLSIDES; - ffloorflags &= ~FF_EXTRA; - ffloorflags &= ~FF_CUTEXTRA; + ffloorflags |= FF_CUTLEVEL|FF_BOTHPLANES|FF_ALLSIDES; + ffloorflags &= ~(FF_EXTRA|FF_CUTEXTRA); } P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; case 146: // Intangible floor/ceiling with solid sides (fences/hoops maybe?) - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERSIDES|FF_ALLSIDES|FF_INTANGABLEFLATS, secthinkers); + P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERSIDES|FF_ALLSIDES|FF_INTANGIBLEFLATS, secthinkers); break; case 150: // Air bobbing platform case 151: // Adjustable air bobbing platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151)); + P_AddAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151), false); break; case 152: // Adjustable air bobbing platform in reverse P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); + break; + case 153: // Dynamic Sinking Platform + P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); + lines[i].flags |= ML_BLOCKMONSTERS; + P_AddAirbob(lines[i].frontsector, lines + i, false, true); break; case 160: // Float/bob platform @@ -6080,14 +7002,14 @@ void P_SpawnSpecials(INT32 fromnetsave) case 176: // Air bobbing platform that will crumble and bob on the water when it falls and hits P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB|FF_CRUMBLE, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 177: // Air bobbing platform that will crumble and bob on // the water when it falls and hits, then never return P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_FLOATBOB|FF_CRUMBLE|FF_NORETURN, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 178: // Crumbling platform that will float when it hits water @@ -6101,7 +7023,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 180: // Air bobbing platform that will crumble P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_CRUMBLE, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 190: // Rising Platform FOF (solid, opaque, shadows) @@ -6155,10 +7077,9 @@ void P_SpawnSpecials(INT32 fromnetsave) case 202: // Fog ffloorflags = FF_EXISTS|FF_RENDERALL|FF_FOG|FF_BOTHPLANES|FF_INVERTPLANES|FF_ALLSIDES|FF_INVERTSIDES|FF_CUTEXTRA|FF_EXTRA|FF_DOUBLESHADOW|FF_CUTSPRITES; sec = sides[*lines[i].sidenum].sector - sectors; - // SoM: Because it's fog, check for an extra colormap and set - // the fog flag... + // SoM: Because it's fog, check for an extra colormap and set the fog flag... if (sectors[sec].extra_colormap) - sectors[sec].extra_colormap->fog = 1; + sectors[sec].extra_colormap->flags = CMF_FOG; P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; @@ -6189,7 +7110,13 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 250: // Mario Block - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_MARIO, secthinkers); + ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_MARIO; + if (lines[i].flags & ML_NOCLIMB) + ffloorflags |= FF_SHATTERBOTTOM; + if (lines[i].flags & ML_EFFECT1) + ffloorflags &= ~(FF_SOLID|FF_RENDERALL|FF_CUTLEVEL); + + P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; case 251: // A THWOMP! @@ -6203,21 +7130,23 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 252: // Shatter block (breaks when touched) + ffloorflags = FF_EXISTS|FF_BLOCKOTHERS|FF_RENDERALL|FF_BUSTUP|FF_SHATTER; if (lines[i].flags & ML_NOCLIMB) - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_BUSTUP|FF_SHATTER|FF_SHATTERBOTTOM, secthinkers); - else - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_RENDERALL|FF_BUSTUP|FF_SHATTER, secthinkers); + ffloorflags |= FF_BLOCKPLAYER|FF_SHATTERBOTTOM; + + P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; case 253: // Translucent shatter block (see 76) - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_RENDERALL|FF_BUSTUP|FF_SHATTER|FF_TRANSLUCENT, secthinkers); + P_AddFakeFloorsByLine(i, FF_EXISTS|FF_BLOCKOTHERS|FF_RENDERALL|FF_BUSTUP|FF_SHATTER|FF_TRANSLUCENT, secthinkers); break; case 254: // Bustable block + ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_BUSTUP; if (lines[i].flags & ML_NOCLIMB) - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_BUSTUP|FF_ONLYKNUX, secthinkers); - else - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_BUSTUP, secthinkers); + ffloorflags |= FF_STRONGBUST; + + P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; case 255: // Spin bust block (breaks when jumped or spun downwards onto) @@ -6229,10 +7158,11 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 257: // Quicksand + ffloorflags = FF_EXISTS|FF_QUICKSAND|FF_RENDERALL|FF_ALLSIDES|FF_CUTSPRITES; if (lines[i].flags & ML_EFFECT5) - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_QUICKSAND|FF_RENDERALL|FF_ALLSIDES|FF_CUTSPRITES|FF_RIPPLE, secthinkers); - else - P_AddFakeFloorsByLine(i, FF_EXISTS|FF_QUICKSAND|FF_RENDERALL|FF_ALLSIDES|FF_CUTSPRITES, secthinkers); + ffloorflags |= FF_RIPPLE; + + P_AddFakeFloorsByLine(i, ffloorflags, secthinkers); break; case 258: // Laser block @@ -6243,46 +7173,14 @@ void P_SpawnSpecials(INT32 fromnetsave) EV_AddLaserThinker(§ors[s], §ors[sec], lines + i, secthinkers); break; - case 259: // Make-Your-Own FOF! + case 259: // Custom FOF if (lines[i].sidenum[1] != 0xffff) { - UINT8 *data; - UINT16 b; - - if (W_IsLumpWad(lastloadedmaplumpnum)) // welp it's a map wad in a pk3 - { // HACK: Open wad file rather quickly so we can get the data from the sidedefs lump - UINT8 *wadData = W_CacheLumpNum(lastloadedmaplumpnum, PU_STATIC); - filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); - fileinfo += ML_SIDEDEFS; // we only need the SIDEDEFS lump - data = Z_Malloc(fileinfo->size, PU_STATIC, NULL); - M_Memcpy(data, wadData + fileinfo->filepos, fileinfo->size); // copy data - Z_Free(wadData); // we're done with this now - } - else // phew it's just a WAD - data = W_CacheLumpNum(lastloadedmaplumpnum + ML_SIDEDEFS,PU_STATIC); - - for (b = 0; b < (INT16)numsides; b++) - { - register mapsidedef_t *msd = (mapsidedef_t *)data + b; - - if (b == lines[i].sidenum[1]) - { - if ((msd->toptexture[0] >= '0' && msd->toptexture[0] <= '9') - || (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'F')) - { - ffloortype_e FOF_Flags = axtoi(msd->toptexture); - - P_AddFakeFloorsByLine(i, FOF_Flags, secthinkers); - break; - } - else - I_Error("Make-Your-Own-FOF (tag %d) needs a value in the linedef's second side upper texture field.", lines[i].tag); - } - } - Z_Free(data); + ffloortype_e fofflags = sides[lines[i].sidenum[1]].toptexture; + P_AddFakeFloorsByLine(i, fofflags, secthinkers); } else - I_Error("Make-Your-Own FOF (tag %d) found without a 2nd linedef side!", lines[i].tag); + I_Error("Custom FOF (tag %d) found without a linedef back side!", lines[i].tag); break; case 300: // Linedef executor (combines with sector special 974/975) and commands @@ -6296,14 +7194,14 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 308: // Race-only linedef executor. Triggers once. - if (gametype != GT_RACE && gametype != GT_COMPETITION) + if (!(gametyperules & GTR_RACE)) lines[i].special = 0; break; // Linedef executor triggers for CTF teams. case 309: case 311: - if (gametype != GT_CTF) + if (!(gametyperules & GTR_TEAMFLAGS)) lines[i].special = 0; break; @@ -6312,6 +7210,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 301: case 310: case 312: + case 332: sec = sides[*lines[i].sidenum].sector - sectors; P_AddEachTimeThinker(§ors[sec], &lines[i]); break; @@ -6349,6 +7248,22 @@ void P_SpawnSpecials(INT32 fromnetsave) } break; + // NiGHTS trigger executors + case 323: + case 324: + case 325: + case 326: + case 327: + case 328: + case 329: + case 330: + break; + + // Skin trigger executors + case 331: + case 333: + break; + case 399: // Linedef execute on map load // This is handled in P_RunLevelLoadExecutors. break; @@ -6387,6 +7302,24 @@ void P_SpawnSpecials(INT32 fromnetsave) case 431: break; + case 449: // Enable bosses with parameter + { + INT32 bossid = sides[*lines[i].sidenum].textureoffset>>FRACBITS; + if (bossid & ~15) // if any bits other than first 16 are set + { + CONS_Alert(CONS_WARNING, + M_GetText("Boss enable linedef (tag %d) has an invalid texture x offset.\nConsider changing it or removing it entirely.\n"), + lines[i].tag); + break; + } + if (!(lines[i].flags & ML_NOCLIMB)) + { + bossdisabled |= (1<= 0 ;) - sectors[s].midmap = lines[i].frontsector->midmap; + sectors[s].extra_colormap = sectors[s].spawn_extra_colormap = sides[lines[i].sidenum[0]].colormap_data; break; -#ifdef ESLOPE // Slope copy specials. Handled here for sanity. - case 720: - case 721: - case 722: - P_CopySectorSlope(&lines[i]); - break; -#endif - default: break; } @@ -6500,6 +7425,10 @@ void P_SpawnSpecials(INT32 fromnetsave) case 31: // Polyobj_Displace PolyDisplace(&lines[i]); break; + + case 32: // Polyobj_RotDisplace + PolyRotDisplace(&lines[i]); + break; } } #endif @@ -6570,7 +7499,7 @@ static void P_DoScrollMove(mobj_t *thing, fixed_t dx, fixed_t dy, INT32 exclusiv thing->momy += dy; if (exclusive) - thing->flags2 |= MF2_PUSHED; + thing->eflags |= MFE_PUSHED; } /** Processes an active scroller. @@ -6688,7 +7617,7 @@ void T_Scroll(scroll_t *s) { thing = node->m_thing; - if (thing->flags2 & MF2_PUSHED) // Already pushed this tic by an exclusive pusher. + if (thing->eflags & MFE_PUSHED) // Already pushed this tic by an exclusive pusher. continue; height = P_GetSpecialBottomZ(thing, sec, psec); @@ -6710,7 +7639,7 @@ void T_Scroll(scroll_t *s) { thing = node->m_thing; - if (thing->flags2 & MF2_PUSHED) + if (thing->eflags & MFE_PUSHED) continue; height = P_GetSpecialBottomZ(thing, sec, sec); @@ -6764,7 +7693,7 @@ void T_Scroll(scroll_t *s) { thing = node->m_thing; - if (thing->flags2 & MF2_PUSHED) + if (thing->eflags & MFE_PUSHED) continue; height = P_GetSpecialTopZ(thing, sec, psec); @@ -6786,7 +7715,7 @@ void T_Scroll(scroll_t *s) { thing = node->m_thing; - if (thing->flags2 & MF2_PUSHED) + if (thing->eflags & MFE_PUSHED) continue; height = P_GetSpecialTopZ(thing, sec, sec); @@ -6828,32 +7757,7 @@ static void Add_Scroller(INT32 type, fixed_t dx, fixed_t dy, INT32 control, INT3 if ((s->control = control) != -1) s->last_height = sectors[control].floorheight + sectors[control].ceilingheight; s->affectee = affectee; - P_AddThinker(&s->thinker); -} - -/** Adds a wall scroller. - * Scroll amount is rotated with respect to wall's linedef first, so that - * scrolling towards the wall in a perpendicular direction is translated into - * vertical motion, while scrolling along the wall in a parallel direction is - * translated into horizontal motion. - * - * \param dx x speed of scrolling or its acceleration. - * \param dy y speed of scrolling or its acceleration. - * \param l Line whose front side will scroll. - * \param control Sector whose heights control this scroller's effect - * remotely, or -1 if there is no control sector. - * \param accel Nonzero for an accelerative effect. - * \sa Add_Scroller, P_SpawnScrollers - */ -static void Add_WallScroller(fixed_t dx, fixed_t dy, const line_t *l, INT32 control, INT32 accel) -{ - fixed_t x = abs(l->dx), y = abs(l->dy), d; - if (y > x) - d = x, x = y, y = d; - d = FixedDiv(x, FINESINE((tantoangle[FixedDiv(y, x) >> DBITS] + ANGLE_90) >> ANGLETOFINESHIFT)); - x = -FixedDiv(FixedMul(dy, l->dy) + FixedMul(dx, l->dx), d); - y = -FixedDiv(FixedMul(dx, l->dy) - FixedMul(dy, l->dx), d); - Add_Scroller(sc_side, x, y, control, *l->sidenum, accel, 0); + P_AddThinker(THINK_MAIN, &s->thinker); } /** Initializes the scrollers. @@ -6940,7 +7844,7 @@ static void P_SpawnScrollers(void) case 502: for (s = -1; (s = P_FindLineFromLineTag(l, s)) >= 0 ;) if (s != (INT32)i) - Add_WallScroller(dx, dy, lines+s, control, accel); + Add_Scroller(sc_side, dx, dy, control, lines[s].sidenum[0], accel, 0); break; case 505: @@ -6987,7 +7891,7 @@ static void Add_MasterDisappearer(tic_t appeartime, tic_t disappeartime, tic_t o d->exists = true; d->timer = 1; - P_AddThinker(&d->thinker); + P_AddThinker(THINK_MAIN, &d->thinker); } /** Makes a FOF appear/disappear @@ -7034,6 +7938,7 @@ void T_Disappear(disappear_t *d) } } sectors[s].moved = true; + P_RecalcPrecipInSector(§ors[s]); } if (d->exists) @@ -7049,6 +7954,591 @@ void T_Disappear(disappear_t *d) } } +/** Removes fadingdata from FOF control sector + * + * \param line line to search for target faders + * \param data pointer to set new fadingdata to. Can be NULL to erase. + */ +static void P_ResetFakeFloorFader(ffloor_t *rover, fade_t *data, boolean finalize) +{ + fade_t *fadingdata = (fade_t *)rover->fadingdata; + // find any existing thinkers and remove them, then replace with new data + if (fadingdata != data) + { + if (fadingdata) + { + if (finalize) + P_FadeFakeFloor(rover, + fadingdata->sourcevalue, + fadingdata->alpha >= fadingdata->destvalue ? + fadingdata->alpha - 1 : // trigger fade-out finish + fadingdata->alpha + 1, // trigger fade-in finish + 0, + fadingdata->ticbased, + &fadingdata->timer, + fadingdata->doexists, + fadingdata->dotranslucent, + fadingdata->dolighting, + fadingdata->docolormap, + fadingdata->docollision, + fadingdata->doghostfade, + fadingdata->exactalpha); + rover->alpha = fadingdata->alpha; + + if (fadingdata->dolighting) + P_RemoveLighting(§ors[rover->secnum]); + + if (fadingdata->docolormap) + P_ResetColormapFader(§ors[rover->secnum]); + + P_RemoveThinker(&fadingdata->thinker); + } + + rover->fadingdata = data; + } +} + +static boolean P_FadeFakeFloor(ffloor_t *rover, INT16 sourcevalue, INT16 destvalue, INT16 speed, boolean ticbased, INT32 *timer, + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha) +{ + boolean stillfading = false; + INT32 alpha; + fade_t *fadingdata = (fade_t *)rover->fadingdata; + (void)docolormap; // *shrug* maybe we can use this in the future. For now, let's be consistent with our other function params + + if (rover->master->special == 258) // Laser block + return false; + + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + if (dotranslucent && + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->flags & FF_FOG) && // do not include fog + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + if (fadingdata) + alpha = fadingdata->alpha; + else + alpha = rover->alpha; + + // routines specific to fade in and fade out + if (!ticbased && alpha == destvalue) + return stillfading; + else if (alpha > destvalue) // fade out + { + // finish fading out + if (speed < 1 || (!ticbased && alpha - speed <= destvalue + speed) || + (ticbased && (--(*timer) <= 0 || alpha <= destvalue))) + { + alpha = destvalue; + + if (docollision) + { + if (rover->spawnflags & FF_SOLID) + rover->flags &= ~FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags &= ~FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags &= ~FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags &= ~FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags &= ~FF_MARIO; + } + } + else // continue fading out + { + if (!ticbased) + alpha -= speed; + else + { + INT16 delta = abs(destvalue - sourcevalue); + fixed_t factor = min(FixedDiv(speed - (*timer), speed), 1*FRACUNIT); + alpha = max(min(alpha, sourcevalue - (INT16)FixedMul(delta, factor)), destvalue); + } + stillfading = true; + } + } + else // fade in + { + // finish fading in + if (speed < 1 || (!ticbased && alpha + speed >= destvalue - speed) || + (ticbased && (--(*timer) <= 0 || alpha >= destvalue))) + { + alpha = destvalue; + + if (docollision) + { + if (rover->spawnflags & FF_SOLID) + rover->flags |= FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags |= FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags |= FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags |= FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags |= FF_MARIO; + } + } + else // continue fading in + { + if (!ticbased) + alpha += speed; + else + { + INT16 delta = abs(destvalue - sourcevalue); + fixed_t factor = min(FixedDiv(speed - (*timer), speed), 1*FRACUNIT); + alpha = min(max(alpha, sourcevalue + (INT16)FixedMul(delta, factor)), destvalue); + } + stillfading = true; + } + } + + // routines common to both fade in and fade out + if (!stillfading) + { + if (doexists && !(rover->spawnflags & FF_BUSTUP)) + { + if (alpha <= 1) + rover->flags &= ~FF_EXISTS; + else + rover->flags |= FF_EXISTS; + + // Re-render lighting at end of fade + if (dolighting && !(rover->spawnflags & FF_NOSHADE) && !(rover->flags & FF_EXISTS)) + rover->target->moved = true; + } + + if (dotranslucent && !(rover->flags & FF_FOG)) + { + if (alpha >= 256) + { + if (!(rover->flags & FF_CUTSOLIDS) && + (rover->spawnflags & FF_CUTSOLIDS)) + { + rover->flags |= FF_CUTSOLIDS; + rover->target->moved = true; + } + + rover->flags &= ~FF_TRANSLUCENT; + } + else + { + rover->flags |= FF_TRANSLUCENT; + + if ((rover->flags & FF_CUTSOLIDS) && + (rover->spawnflags & FF_CUTSOLIDS)) + { + rover->flags &= ~FF_CUTSOLIDS; + rover->target->moved = true; + } + } + + if ((rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES)) + { + if (rover->alpha > 1) + rover->flags |= FF_RENDERALL; + else + rover->flags &= ~FF_RENDERALL; + } + } + } + else + { + if (doexists && !(rover->spawnflags & FF_BUSTUP)) + { + // Re-render lighting if we haven't yet set FF_EXISTS (beginning of fade) + if (dolighting && !(rover->spawnflags & FF_NOSHADE) && !(rover->flags & FF_EXISTS)) + rover->target->moved = true; + + rover->flags |= FF_EXISTS; + } + + if (dotranslucent && !(rover->flags & FF_FOG)) + { + rover->flags |= FF_TRANSLUCENT; + + if ((rover->flags & FF_CUTSOLIDS) && + (rover->spawnflags & FF_CUTSOLIDS)) + { + rover->flags &= ~FF_CUTSOLIDS; + rover->target->moved = true; + } + + if ((rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES)) + rover->flags |= FF_RENDERALL; + } + + if (docollision) + { + if (doghostfade) // remove collision flags during fade + { + if (rover->spawnflags & FF_SOLID) + rover->flags &= ~FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags &= ~FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags &= ~FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags &= ~FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags &= ~FF_MARIO; + } + else // keep collision during fade + { + if (rover->spawnflags & FF_SOLID) + rover->flags |= FF_SOLID; + if (rover->spawnflags & FF_SWIMMABLE) + rover->flags |= FF_SWIMMABLE; + if (rover->spawnflags & FF_QUICKSAND) + rover->flags |= FF_QUICKSAND; + if (rover->spawnflags & FF_BUSTUP) + rover->flags |= FF_BUSTUP; + if (rover->spawnflags & FF_MARIO) + rover->flags |= FF_MARIO; + } + } + } + + if (!(rover->flags & FF_FOG)) // don't set FOG alpha + { + if (!stillfading || exactalpha) + rover->alpha = alpha; + else // clamp fadingdata->alpha to software's alpha levels + { + if (alpha < 12) + rover->alpha = destvalue < 12 ? destvalue : 1; // Don't even draw it + else if (alpha < 38) + rover->alpha = destvalue >= 12 && destvalue < 38 ? destvalue : 25; + else if (alpha < 64) + rover->alpha = destvalue >=38 && destvalue < 64 ? destvalue : 51; + else if (alpha < 89) + rover->alpha = destvalue >= 64 && destvalue < 89 ? destvalue : 76; + else if (alpha < 115) + rover->alpha = destvalue >= 89 && destvalue < 115 ? destvalue : 102; + else if (alpha < 140) + rover->alpha = destvalue >= 115 && destvalue < 140 ? destvalue : 128; + else if (alpha < 166) + rover->alpha = destvalue >= 140 && destvalue < 166 ? destvalue : 154; + else if (alpha < 192) + rover->alpha = destvalue >= 166 && destvalue < 192 ? destvalue : 179; + else if (alpha < 217) + rover->alpha = destvalue >= 192 && destvalue < 217 ? destvalue : 204; + else if (alpha < 243) + rover->alpha = destvalue >= 217 && destvalue < 243 ? destvalue : 230; + else // Opaque + rover->alpha = destvalue >= 243 ? destvalue : 256; + } + } + + if (fadingdata) + fadingdata->alpha = alpha; + + return stillfading; +} + +/** Adds fake floor fader thinker. + * + * \param destvalue transparency value to fade to + * \param speed speed to fade by + * \param ticbased tic-based logic, speed = duration + * \param relative Destvalue is relative to rover->alpha + * \param doexists handle FF_EXISTS + * \param dotranslucent handle FF_TRANSLUCENT + * \param dolighting fade FOF light + * \param docollision handle interactive flags + * \param doghostfade no interactive flags during fading + * \param exactalpha use exact alpha values (opengl) + */ +static void P_AddFakeFloorFader(ffloor_t *rover, size_t sectornum, size_t ffloornum, + INT16 destvalue, INT16 speed, boolean ticbased, boolean relative, + boolean doexists, boolean dotranslucent, boolean dolighting, boolean docolormap, + boolean docollision, boolean doghostfade, boolean exactalpha) +{ + fade_t *d; + + // If fading an invisible FOF whose render flags we did not yet set, + // initialize its alpha to 1 + if (dotranslucent && + (rover->spawnflags & FF_NOSHADE) && // do not include light blocks, which don't set FF_NOSHADE + !(rover->spawnflags & FF_RENDERSIDES) && + !(rover->spawnflags & FF_RENDERPLANES) && + !(rover->flags & FF_RENDERALL)) + rover->alpha = 1; + + // already equal, nothing to do + if (rover->alpha == max(1, min(256, relative ? rover->alpha + destvalue : destvalue))) + return; + + d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + + d->thinker.function.acp1 = (actionf_p1)T_Fade; + d->rover = rover; + d->sectornum = (UINT32)sectornum; + d->ffloornum = (UINT32)ffloornum; + + d->alpha = d->sourcevalue = rover->alpha; + d->destvalue = max(1, min(256, relative ? rover->alpha + destvalue : destvalue)); // rover->alpha is 1-256 + + if (ticbased) + { + d->ticbased = true; + d->timer = d->speed = abs(speed); // use d->speed as total duration + } + else + { + d->ticbased = false; + d->speed = max(1, speed); // minimum speed 1/tic // if speed < 1, alpha is set immediately in thinker + d->timer = -1; + } + + d->doexists = doexists; + d->dotranslucent = dotranslucent; + d->dolighting = dolighting; + d->docolormap = docolormap; + d->docollision = docollision; + d->doghostfade = doghostfade; + d->exactalpha = exactalpha; + + // find any existing thinkers and remove them, then replace with new data + P_ResetFakeFloorFader(rover, d, false); + + // Set a separate thinker for shadow fading + if (dolighting && !(rover->flags & FF_NOSHADE)) + { + UINT16 lightdelta = abs(sectors[rover->secnum].spawn_lightlevel - rover->target->lightlevel); + fixed_t alphapercent = min(FixedDiv(d->destvalue, rover->spawnalpha), 1*FRACUNIT); // don't make darker than spawn_lightlevel + fixed_t adjustedlightdelta = FixedMul(lightdelta, alphapercent); + + if (rover->target->lightlevel >= sectors[rover->secnum].spawn_lightlevel) // fading out, get lighter + d->destlightlevel = rover->target->lightlevel - adjustedlightdelta; + else // fading in, get darker + d->destlightlevel = rover->target->lightlevel + adjustedlightdelta; + + P_FadeLightBySector(§ors[rover->secnum], + d->destlightlevel, + ticbased ? d->timer : + FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT, + true); + } + else + d->destlightlevel = -1; + + // Set a separate thinker for colormap fading + if (docolormap && !(rover->flags & FF_NOSHADE) && sectors[rover->secnum].spawn_extra_colormap) + { + extracolormap_t *dest_exc, + *source_exc = sectors[rover->secnum].extra_colormap ? sectors[rover->secnum].extra_colormap : R_GetDefaultColormap(); + + INT32 colordelta = R_GetRgbaA(sectors[rover->secnum].spawn_extra_colormap->rgba); // alpha is from 0 + fixed_t alphapercent = min(FixedDiv(d->destvalue, rover->spawnalpha), 1*FRACUNIT); // don't make darker than spawn_lightlevel + fixed_t adjustedcolordelta = FixedMul(colordelta, alphapercent); + INT32 coloralpha; + + coloralpha = adjustedcolordelta; + + dest_exc = R_CopyColormap(sectors[rover->secnum].spawn_extra_colormap, false); + dest_exc->rgba = R_GetRgbaRGB(dest_exc->rgba) + R_PutRgbaA(coloralpha); + + if (!(d->dest_exc = R_GetColormapFromList(dest_exc))) + { + dest_exc->colormap = R_CreateLightTable(dest_exc); + R_AddColormapToList(dest_exc); + d->dest_exc = dest_exc; + } + else + Z_Free(dest_exc); + + // If fading from 0, set source_exc rgb same to dest_exc + if (!R_CheckDefaultColormap(d->dest_exc, true, false, false) + && R_CheckDefaultColormap(source_exc, true, false, false)) + { + extracolormap_t *exc = R_CopyColormap(source_exc, false); + exc->rgba = R_GetRgbaRGB(d->dest_exc->rgba) + R_PutRgbaA(R_GetRgbaA(source_exc->rgba)); + exc->fadergba = R_GetRgbaRGB(d->dest_exc->rgba) + R_PutRgbaA(R_GetRgbaA(source_exc->fadergba)); + + if (!(source_exc = R_GetColormapFromList(exc))) + { + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + source_exc = exc; + } + else + Z_Free(exc); + } + + Add_ColormapFader(§ors[rover->secnum], source_exc, d->dest_exc, true, + ticbased ? d->timer : + FixedFloor(FixedDiv(abs(d->destvalue - d->alpha), d->speed))/FRACUNIT); + } + + P_AddThinker(THINK_MAIN, &d->thinker); +} + +/** Makes a FOF fade + * + * \param d Fade thinker. + * \sa P_AddFakeFloorFader + */ +void T_Fade(fade_t *d) +{ + if (d->rover && !P_FadeFakeFloor(d->rover, d->sourcevalue, d->destvalue, d->speed, d->ticbased, &d->timer, + d->doexists, d->dotranslucent, d->dolighting, d->docolormap, d->docollision, d->doghostfade, d->exactalpha)) + { + // Finalize lighting, copypasta from P_AddFakeFloorFader + if (d->dolighting && !(d->rover->flags & FF_NOSHADE) && d->destlightlevel > -1) + sectors[d->rover->secnum].lightlevel = d->destlightlevel; + + // Finalize colormap + if (d->docolormap && !(d->rover->flags & FF_NOSHADE) && sectors[d->rover->secnum].spawn_extra_colormap) + sectors[d->rover->secnum].extra_colormap = d->dest_exc; + + P_RemoveFakeFloorFader(d->rover); + } +} + +static void P_ResetColormapFader(sector_t *sector) +{ + if (sector->fadecolormapdata) + { + // The thinker is the first member in all the action structs, + // so just let the thinker get freed, and that will free the whole + // structure. + P_RemoveThinker(&((elevator_t *)sector->fadecolormapdata)->thinker); + sector->fadecolormapdata = NULL; + } +} + +static void Add_ColormapFader(sector_t *sector, extracolormap_t *source_exc, extracolormap_t *dest_exc, + boolean ticbased, INT32 duration) +{ + fadecolormap_t *d; + + P_ResetColormapFader(sector); + + // nothing to do, set immediately + if (!duration || R_CheckEqualColormaps(source_exc, dest_exc, true, true, true)) + { + sector->extra_colormap = dest_exc; + return; + } + + d = Z_Malloc(sizeof *d, PU_LEVSPEC, NULL); + d->thinker.function.acp1 = (actionf_p1)T_FadeColormap; + d->sector = sector; + d->source_exc = source_exc; + d->dest_exc = dest_exc; + + if (ticbased) + { + d->ticbased = true; + d->duration = d->timer = duration; + } + else + { + d->ticbased = false; + d->timer = 256; + d->duration = duration; // use as speed + } + + sector->fadecolormapdata = d; + P_AddThinker(THINK_MAIN, &d->thinker); +} + +void T_FadeColormap(fadecolormap_t *d) +{ + if ((d->ticbased && --d->timer <= 0) + || (!d->ticbased && (d->timer -= d->duration) <= 0)) // d->duration used as speed decrement + { + d->sector->extra_colormap = d->dest_exc; + P_ResetColormapFader(d->sector); + } + else + { + extracolormap_t *exc; + INT32 duration = d->ticbased ? d->duration : 256; + fixed_t factor = min(FixedDiv(duration - d->timer, duration), 1*FRACUNIT); + INT16 cr, cg, cb, ca, fadestart, fadeend, flags; + INT32 rgba, fadergba; + + // NULL failsafes (or intentionally set to signify default) + if (!d->sector->extra_colormap) + d->sector->extra_colormap = R_GetDefaultColormap(); + + if (!d->source_exc) + d->source_exc = R_GetDefaultColormap(); + + if (!d->dest_exc) + d->dest_exc = R_GetDefaultColormap(); + + // For each var (rgba + fadergba + params = 11 vars), we apply + // percentage fading: currentval = sourceval + (delta * percent of duration elapsed) + // delta is negative when fading out (destval is lower) + // max/min are used to ensure progressive calcs don't go backwards and to cap values to dest. + +#define APPLYFADE(dest, src, cur) (\ +(dest-src < 0) ? \ + max(\ + min(cur,\ + src + (INT16)FixedMul(dest-src, factor)),\ + dest)\ +: (dest-src > 0) ? \ + min(\ + max(cur,\ + src + (INT16)FixedMul(dest-src, factor)),\ + dest)\ +: \ + dest\ +) + + cr = APPLYFADE(R_GetRgbaR(d->dest_exc->rgba), R_GetRgbaR(d->source_exc->rgba), R_GetRgbaR(d->sector->extra_colormap->rgba)); + cg = APPLYFADE(R_GetRgbaG(d->dest_exc->rgba), R_GetRgbaG(d->source_exc->rgba), R_GetRgbaG(d->sector->extra_colormap->rgba)); + cb = APPLYFADE(R_GetRgbaB(d->dest_exc->rgba), R_GetRgbaB(d->source_exc->rgba), R_GetRgbaB(d->sector->extra_colormap->rgba)); + ca = APPLYFADE(R_GetRgbaA(d->dest_exc->rgba), R_GetRgbaA(d->source_exc->rgba), R_GetRgbaA(d->sector->extra_colormap->rgba)); + + rgba = R_PutRgbaRGBA(cr, cg, cb, ca); + + cr = APPLYFADE(R_GetRgbaR(d->dest_exc->fadergba), R_GetRgbaR(d->source_exc->fadergba), R_GetRgbaR(d->sector->extra_colormap->fadergba)); + cg = APPLYFADE(R_GetRgbaG(d->dest_exc->fadergba), R_GetRgbaG(d->source_exc->fadergba), R_GetRgbaG(d->sector->extra_colormap->fadergba)); + cb = APPLYFADE(R_GetRgbaB(d->dest_exc->fadergba), R_GetRgbaB(d->source_exc->fadergba), R_GetRgbaB(d->sector->extra_colormap->fadergba)); + ca = APPLYFADE(R_GetRgbaA(d->dest_exc->fadergba), R_GetRgbaA(d->source_exc->fadergba), R_GetRgbaA(d->sector->extra_colormap->fadergba)); + + fadergba = R_PutRgbaRGBA(cr, cg, cb, ca); + + fadestart = APPLYFADE(d->dest_exc->fadestart, d->source_exc->fadestart, d->sector->extra_colormap->fadestart); + fadeend = APPLYFADE(d->dest_exc->fadeend, d->source_exc->fadeend, d->sector->extra_colormap->fadeend); + flags = abs(factor) > FRACUNIT/2 ? d->dest_exc->flags : d->source_exc->flags; // set new flags halfway through fade + +#undef APPLYFADE + + ////////////////// + // setup new colormap + ////////////////// + + if (!(d->sector->extra_colormap = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags))) + { + exc = R_CreateDefaultColormap(false); + exc->fadestart = fadestart; + exc->fadeend = fadeend; + exc->flags = flags; + exc->rgba = rgba; + exc->fadergba = fadergba; + exc->colormap = R_CreateLightTable(exc); + R_AddColormapToList(exc); + d->sector->extra_colormap = exc; + } + } +} + /* SoM: 3/8/2000: Friction functions start. Add_Friction, @@ -7059,7 +8549,6 @@ void T_Disappear(disappear_t *d) /** Adds friction thinker. * * \param friction Friction value, 0xe800 is normal. - * \param movefactor Inertia factor. * \param affectee Target sector. * \param roverfriction FOF or not * \sa T_Friction, P_SpawnFriction @@ -7081,7 +8570,7 @@ static void Add_Friction(INT32 friction, INT32 movefactor, INT32 affectee, INT32 else f->roverfriction = false; - P_AddThinker(&f->thinker); + P_AddThinker(THINK_MAIN, &f->thinker); } /** Applies friction to all things in a sector. @@ -7097,22 +8586,10 @@ void T_Friction(friction_t *f) sec = sectors + f->affectee; - // Make sure the sector type hasn't changed + // Get FOF control sector if (f->roverfriction) - { referrer = sectors + f->referrer; - if (!(GETSECSPECIAL(referrer->special, 3) == 1 - || GETSECSPECIAL(referrer->special, 3) == 3)) - return; - } - else - { - if (!(GETSECSPECIAL(sec->special, 3) == 1 - || GETSECSPECIAL(sec->special, 3) == 3)) - return; - } - // Assign the friction value to players on the floor, non-floating, // and clipped. Normally the object's friction value is kept at // ORIG_FRICTION and this thinker changes it for icy or muddy floors. @@ -7142,14 +8619,16 @@ void T_Friction(friction_t *f) || (f->friction < thing->friction)) { thing->friction = f->friction; - thing->movefactor = f->movefactor; + if (thing->player) + thing->movefactor = f->movefactor; } } else if (P_GetSpecialBottomZ(thing, sec, sec) == thing->floorz && (thing->friction == ORIG_FRICTION // normal friction? || f->friction < thing->friction)) { thing->friction = f->friction; - thing->movefactor = f->movefactor; + if (thing->player) + thing->movefactor = f->movefactor; } } node = node->m_thinglist_next; @@ -7165,33 +8644,32 @@ static void P_SpawnFriction(void) size_t i; line_t *l = lines; register INT32 s; - fixed_t length; // line length controls magnitude + fixed_t strength; // frontside texture offset controls magnitude fixed_t friction; // friction value to be applied during movement INT32 movefactor; // applied to each player move to simulate inertia for (i = 0; i < numlines; i++, l++) if (l->special == 540) { - length = P_AproxDistance(l->dx, l->dy)>>FRACBITS; - friction = (0x1EB8*length)/0x80 + 0xD000; + strength = sides[l->sidenum[0]].textureoffset>>FRACBITS; + if (strength > 0) // sludge + strength = strength*2; // otherwise, the maximum sludginess value is +967... + + // The following might seem odd. At the time of movement, + // the move distance is multiplied by 'friction/0x10000', so a + // higher friction value actually means 'less friction'. + friction = ORIG_FRICTION - (0x1EB8*strength)/0x80; // ORIG_FRICTION is 0xE800 if (friction > FRACUNIT) friction = FRACUNIT; if (friction < 0) friction = 0; - // The following check might seem odd. At the time of movement, - // the move distance is multiplied by 'friction/0x10000', so a - // higher friction value actually means 'less friction'. - - if (friction > ORIG_FRICTION) // ice - movefactor = ((0x10092 - friction)*(0x70))/0x158; + movefactor = FixedDiv(ORIG_FRICTION, friction); + if (movefactor < FRACUNIT) + movefactor = 8*movefactor - 7*FRACUNIT; else - movefactor = ((friction - 0xDB34)*(0xA))/0x80; - - // killough 8/28/98: prevent odd situations - if (movefactor < 32) - movefactor = 32; + movefactor = FRACUNIT; for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) Add_Friction(friction, movefactor, s, -1); @@ -7258,7 +8736,7 @@ static void Add_Pusher(pushertype_e type, fixed_t x_mag, fixed_t y_mag, mobj_t * p->z = p->source->z; } p->affectee = affectee; - P_AddThinker(&p->thinker); + P_AddThinker(THINK_MAIN, &p->thinker); } @@ -7276,14 +8754,14 @@ static pusher_t *tmpusher; // pusher structure for blockmap searches */ static inline boolean PIT_PushThing(mobj_t *thing) { - if (thing->flags2 & MF2_PUSHED) + if (thing->eflags & MFE_PUSHED) return false; - if (thing->player && thing->player->pflags & PF_ROPEHANG) + if (thing->player && thing->player->powers[pw_carry] == CR_ROPEHANG) return false; // Allow this to affect pushable objects at some point? - if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || thing->player->pflags & PF_NIGHTSMODE)) + if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || thing->player->powers[pw_carry] == CR_NIGHTSMODE)) { INT32 dist; INT32 speed; @@ -7314,7 +8792,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) // Written with bits and pieces of P_HomingAttack if ((speed > 0) && (P_CheckSight(thing, tmpusher->source))) { - if (!(thing->player->pflags & PF_NIGHTSMODE)) + if (thing->player->powers[pw_carry] != CR_NIGHTSMODE) { // only push wrt Z if health & 1 (mapthing has ambush flag) if (tmpusher->source->health & 1) @@ -7406,7 +8884,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) } if (tmpusher->exclusive) - thing->flags2 |= MF2_PUSHED; + thing->eflags |= MFE_PUSHED; return true; } @@ -7441,12 +8919,10 @@ void T_Pusher(pusher_t *p) { referrer = §ors[p->referrer]; - if (!(GETSECSPECIAL(referrer->special, 3) == 2 - || GETSECSPECIAL(referrer->special, 3) == 3)) + if (GETSECSPECIAL(referrer->special, 3) != 2) return; } - else if (!(GETSECSPECIAL(sec->special, 3) == 2 - || GETSECSPECIAL(sec->special, 3) == 3)) + else if (GETSECSPECIAL(sec->special, 3) != 2) return; // For constant pushers (wind/current) there are 3 situations: @@ -7501,7 +8977,8 @@ void T_Pusher(pusher_t *p) || thing->type == MT_EXTRALARGEBUBBLE)) continue; - if (!(thing->flags & MF_PUSHABLE) && !(thing->type == MT_PLAYER + if (!((thing->flags & MF_PUSHABLE) || ((thing->info->flags & MF_PUSHABLE) && thing->fuse)) + && !(thing->type == MT_PLAYER || thing->type == MT_SMALLBUBBLE || thing->type == MT_MEDIUMBUBBLE || thing->type == MT_EXTRALARGEBUBBLE @@ -7509,10 +8986,10 @@ void T_Pusher(pusher_t *p) || thing->type == MT_BIGTUMBLEWEED)) continue; - if (thing->flags2 & MF2_PUSHED) + if (thing->eflags & MFE_PUSHED) continue; - if (thing->player && thing->player->pflags & PF_ROPEHANG) + if (thing->player && thing->player->powers[pw_carry] == CR_ROPEHANG) continue; if (thing->player && (thing->state == &states[thing->info->painstate]) && (thing->player->powers[pw_flashing] > (flashingtics/4)*3 && thing->player->powers[pw_flashing] <= flashingtics)) @@ -7645,17 +9122,16 @@ void T_Pusher(pusher_t *p) { if (p->slider && thing->player) { - boolean jumped = (thing->player->pflags & PF_JUMPED); + pflags_t jumped = (thing->player->pflags & (PF_JUMPED|PF_NOJUMPDAMAGE)); P_ResetPlayer (thing->player); if (jumped) - thing->player->pflags |= PF_JUMPED; + thing->player->pflags |= jumped; thing->player->pflags |= PF_SLIDING; - P_SetPlayerMobjState (thing, thing->info->painstate); // Whee! thing->angle = R_PointToAngle2 (0, 0, xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)); - if (!demoplayback || P_AnalogMove(thing->player)) + if (!demoplayback || P_ControlStyle(thing->player) == CS_LMAOGALOG) { if (thing->player == &players[consoleplayer]) { @@ -7679,7 +9155,7 @@ void T_Pusher(pusher_t *p) } if (p->exclusive) - thing->flags2 |= MF2_PUSHED; + thing->eflags |= MFE_PUSHED; } } } @@ -7763,39 +9239,3 @@ static void P_SpawnPushers(void) break; } } - -static void P_SearchForDisableLinedefs(void) -{ - size_t i; - INT32 j; - - // Look for disable linedefs - for (i = 0; i < numlines; i++) - { - if (lines[i].special == 6) - { - // Remove special - // Do *not* remove tag. That would mess with the tag lists - // that P_InitTagLists literally just created! - lines[i].special = 0; - - // Ability flags can disable disable linedefs now, lol - if (netgame || multiplayer) - { - // future: nonet flag? - } - else if ((lines[i].flags & ML_NETONLY) == ML_NETONLY) - continue; // Net-only never triggers in single player - else if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - continue; - else if (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - continue; - else if (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX)) - continue; - - // Disable any linedef specials with our tag. - for (j = -1; (j = P_FindLineFromLineTag(&lines[i], j)) >= 0;) - lines[j].special = 0; - } - } -} diff --git a/src/p_spec.h b/src/p_spec.h index 17d9c7bd2..6377059b6 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -17,7 +17,9 @@ #ifndef __P_SPEC__ #define __P_SPEC__ -extern mobj_t *skyboxmo[2]; +extern mobj_t *skyboxmo[2]; // current skybox mobjs: 0 = viewpoint, 1 = centerpoint +extern mobj_t *skyboxviewpnts[16]; // array of MT_SKYBOX viewpoint mobjs +extern mobj_t *skyboxcenterpnts[16]; // array of MT_SKYBOX centerpoint mobjs // GETSECSPECIAL (specialval, section) // @@ -25,6 +27,9 @@ extern mobj_t *skyboxmo[2]; // #define GETSECSPECIAL(i,j) ((i >> ((j-1)*4))&15) +// This must be updated whenever we up the max flat size - quicker to assume rather than figuring out the sqrt of the specific flat's filesize. +#define MAXFLATSIZE (2048<player->starpostz = starpostz; thing->player->starposttime = starposttime; thing->player->starpostangle = starpostangle; + thing->player->starpostscale = starpostscale; thing->player->starpostnum = starpostnum; + thing->player->drawangle = drawangle; + // Reset map starposts for the player's new info. P_ResetStarposts(); P_ClearStarPost(starpostnum); @@ -125,12 +128,10 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle if (!P_TeleportMove(thing, x, y, z)) return false; - thing->angle = angle; - if (!dontstopmove) thing->momx = thing->momy = thing->momz = 0; else // Change speed to match direction - P_InstaThrust(thing, thing->angle, P_AproxDistance(thing->momx, thing->momy)); + P_InstaThrust(thing, angle, FixedHypot(thing->momx, thing->momy)); if (thing->player) { @@ -139,8 +140,29 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle else thing->player->viewz = thing->z + thing->player->viewheight; + // don't run in place after a teleport if (!dontstopmove) + { + INT32 p; + // Search for any players you might be carrying, so you can get them off before they end up being taken with you! + for (p = 0; p < MAXPLAYERS; p++) + if (playeringame[p] && players[p].mo && players[p].powers[pw_carry] == CR_PLAYER && players[p].mo->tracer == thing) + { + players[p].powers[pw_carry] = CR_NONE; + P_SetTarget(&players[p].mo->tracer, NULL); + break; + } + thing->player->cmomx = thing->player->cmomy = 0; + thing->player->rmomx = thing->player->rmomy = 0; + thing->player->speed = 0; + P_ResetPlayer(thing->player); + P_SetPlayerMobjState(thing, S_PLAY_STND); + thing->reactiontime = TICRATE/2; // don't move for about half a second + thing->player->drawangle = angle; + } + else + thing->player->drawangle += (angle - thing->angle); // absolute angle position if (thing->player == &players[consoleplayer]) @@ -154,27 +176,11 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle else if (camera.chase && thing->player == &players[displayplayer]) P_ResetCamera(thing->player, &camera); - // don't run in place after a teleport - if (!dontstopmove) - { - INT32 p; - // Search for any players you might be carrying, so you can get them off before they end up being taken with you! - for (p = 0; p < MAXPLAYERS; p++) - if (playeringame[p] && players[p].mo && players[p].pflags & PF_CARRIED && players[p].mo->tracer == thing) - { - players[p].pflags &= ~PF_CARRIED; - break; - } - thing->player->cmomx = thing->player->cmomy = 0; - thing->player->rmomx = thing->player->rmomy = 0; - thing->player->speed = 0; - P_ResetPlayer(thing->player); - P_SetPlayerMobjState(thing, S_PLAY_STND); - } - if (flash) P_FlashPal(thing->player, PAL_MIXUP, 10); } + thing->angle = angle; + return true; } diff --git a/src/p_tick.c b/src/p_tick.c index 75844b55e..7ea6edb2d 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -35,8 +35,8 @@ tic_t leveltime; // but the first element must be thinker_t. // -// Both the head and tail of the thinker list. -thinker_t thinkercap; +// The entries will behave like both the head and tail of the lists. +thinker_t thlist[NUM_THINKERLISTS]; void Command_Numthinkers_f(void) { @@ -44,6 +44,9 @@ void Command_Numthinkers_f(void) INT32 count = 0; actionf_p1 action; thinker_t *think; + thinklistnum_t start = 0; + thinklistnum_t end = NUM_THINKERLISTS - 1; + thinklistnum_t i; if (gamestate != GS_LEVEL) { @@ -70,6 +73,7 @@ void Command_Numthinkers_f(void) switch (num) { case 1: + start = end = THINK_MOBJ; action = (actionf_p1)P_MobjThinker; CONS_Printf(M_GetText("Number of %s: "), "P_MobjThinker"); break; @@ -82,14 +86,17 @@ void Command_Numthinkers_f(void) CONS_Printf(M_GetText("Number of %s: "), "P_SnowThinker"); break;*/ case 2: + start = end = THINK_PRECIP; action = (actionf_p1)P_NullPrecipThinker; CONS_Printf(M_GetText("Number of %s: "), "P_NullPrecipThinker"); break; case 3: + start = end = THINK_MAIN; action = (actionf_p1)T_Friction; CONS_Printf(M_GetText("Number of %s: "), "T_Friction"); break; case 4: + start = end = THINK_MAIN; action = (actionf_p1)T_Pusher; CONS_Printf(M_GetText("Number of %s: "), "T_Pusher"); break; @@ -102,12 +109,15 @@ void Command_Numthinkers_f(void) return; } - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (i = start; i <= end; i++) { - if (think->function.acp1 != action) - continue; + for (think = thlist[i].next; think != &thlist[i]; think = think->next) + { + if (think->function.acp1 != action) + continue; - count++; + count++; + } } CONS_Printf("%d\n", count); @@ -139,9 +149,9 @@ void Command_CountMobjs_f(void) count = 0; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; if (((mobj_t *)th)->type == i) @@ -159,9 +169,9 @@ void Command_CountMobjs_f(void) { count = 0; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; if (((mobj_t *)th)->type == i) @@ -178,19 +188,22 @@ void Command_CountMobjs_f(void) // void P_InitThinkers(void) { - thinkercap.prev = thinkercap.next = &thinkercap; + UINT8 i; + for (i = 0; i < NUM_THINKERLISTS; i++) + thlist[i].prev = thlist[i].next = &thlist[i]; } -// -// P_AddThinker // Adds a new thinker at the end of the list. -// -void P_AddThinker(thinker_t *thinker) +void P_AddThinker(const thinklistnum_t n, thinker_t *thinker) { - thinkercap.prev->next = thinker; - thinker->next = &thinkercap; - thinker->prev = thinkercap.prev; - thinkercap.prev = thinker; +#ifdef PARANOIA + I_Assert(n < NUM_THINKERLISTS); +#endif + + thlist[n].prev->next = thinker; + thinker->next = &thlist[n]; + thinker->prev = thlist[n].prev; + thlist[n].prev = thinker; thinker->references = 0; // killough 11/98: init reference counter to 0 } @@ -213,22 +226,33 @@ static thinker_t *currentthinker; // remove it, and set currentthinker to one node preceeding it, so // that the next step in P_RunThinkers() will get its successor. // -void P_RemoveThinkerDelayed(void *pthinker) +void P_RemoveThinkerDelayed(thinker_t *thinker) { - thinker_t *thinker = pthinker; - if (!thinker->references) + thinker_t *next; +#ifdef PARANOIA +#define BEENAROUNDBIT (0x40000000) // has to be sufficiently high that it's unlikely to happen in regular gameplay. If you change this, pay attention to the bit pattern of INT32_MIN. + if (thinker->references & ~BEENAROUNDBIT) { - { - /* Remove from main thinker list */ - thinker_t *next = thinker->next; - /* Note that currentthinker is guaranteed to point to us, - * and since we're freeing our memory, we had better change that. So - * point it to thinker->prev, so the iterator will correctly move on to - * thinker->prev->next = thinker->next */ - (next->prev = currentthinker = thinker->prev)->next = next; - } - Z_Free(thinker); + if (thinker->references & BEENAROUNDBIT) // Usually gets cleared up in one frame; what's going on here, then? + CONS_Printf("Number of potentially faulty references: %d\n", (thinker->references & ~BEENAROUNDBIT)); + thinker->references |= BEENAROUNDBIT; + return; } +#undef BEENAROUNDBIT +#else + if (thinker->references) + return; +#endif + + /* Remove from main thinker list */ + next = thinker->next; + /* Note that currentthinker is guaranteed to point to us, + * and since we're freeing our memory, we had better change that. So + * point it to thinker->prev, so the iterator will correctly move on to + * thinker->prev->next = thinker->next */ + (next->prev = currentthinker = thinker->prev)->next = next; + + Z_Free(thinker); } // @@ -245,10 +269,8 @@ void P_RemoveThinkerDelayed(void *pthinker) // void P_RemoveThinker(thinker_t *thinker) { -#ifdef HAVE_BLUA LUA_InvalidateUserdata(thinker); -#endif - thinker->function.acp1 = P_RemoveThinkerDelayed; + thinker->function.acp1 = (actionf_p1)P_RemoveThinkerDelayed; } /* @@ -296,11 +318,18 @@ if ((*mop = targ) != NULL) // Set new target and if non-NULL, increase its count // static inline void P_RunThinkers(void) { - for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) + size_t i; + for (i = 0; i < NUM_THINKERLISTS; i++) { - if (currentthinker->function.acp1) + for (currentthinker = thlist[i].next; currentthinker != &thlist[i]; currentthinker = currentthinker->next) + { +#ifdef PARANOIA + I_Assert(currentthinker->function.acp1 != NULL); +#endif currentthinker->function.acp1(currentthinker); + } } + } // @@ -359,7 +388,7 @@ static void P_DoAutobalanceTeams(void) totalred = red + redflagcarrier; totalblue = blue + blueflagcarrier; - if ((abs(totalred - totalblue) > cv_autobalance.value)) + if ((abs(totalred - totalblue) > max(1, (totalred + totalblue) / 8))) { if (totalred > totalblue) { @@ -372,8 +401,7 @@ static void P_DoAutobalanceTeams(void) usvalue = SHORT(NetPacket.value.l|NetPacket.value.b); SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } - - if (totalblue > totalred) + else //if (totalblue > totalred) { i = M_RandomKey(blue); NetPacket.packet.newteam = 1; @@ -425,7 +453,7 @@ void P_DoTeamscrambling(void) static inline void P_DoSpecialStageStuff(void) { - boolean inwater = false; + boolean stillalive = false; INT32 i; // Can't drown in a special stage @@ -437,69 +465,60 @@ static inline void P_DoSpecialStageStuff(void) players[i].powers[pw_underwater] = players[i].powers[pw_spacetime] = 0; } - if (sstimer < 15*TICRATE+6 && sstimer > 7 && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) - S_SpeedMusic(1.4f); + //if (sstimer < 15*TICRATE+6 && sstimer > 7 && (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC)) + //S_SpeedMusic(1.4f); - if (sstimer < 7 && sstimer > 0) // The special stage time is up! + if (sstimer && !objectplacing) { - sstimer = 0; - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - { - players[i].exiting = (14*TICRATE)/5 + 1; - players[i].pflags &= ~PF_GLIDING; - } - - if (i == consoleplayer) - S_StartSound(NULL, sfx_lose); - } - - if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) - S_SpeedMusic(1.0f); - - stagefailed = true; - } - - if (sstimer > 1) // As long as time isn't up... - { - UINT32 ssrings = 0; + UINT16 countspheres = 0; // Count up the rings of all the players and see if // they've collected the required amount. for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) { - ssrings += (players[i].mo->health-1); + tic_t oldnightstime = players[i].nightstime; + countspheres += players[i].spheres; + + if (!oldnightstime) + continue; // If in water, deplete timer 6x as fast. - if ((players[i].mo->eflags & MFE_TOUCHWATER) - || (players[i].mo->eflags & MFE_UNDERWATER)) - inwater = true; + if (players[i].mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER) && !(players[i].powers[pw_shield] & SH_PROTECTWATER)) + players[i].nightstime -= 5; + if (--players[i].nightstime > 6) + { + if (P_IsLocalPlayer(&players[i]) && oldnightstime > 10*TICRATE && players[i].nightstime <= 10*TICRATE) + S_ChangeMusicInternal("_drown", false); + stillalive = true; + } + else if (!players[i].exiting) + { + players[i].exiting = (14*TICRATE)/5 + 1; + players[i].pflags &= ~(PF_GLIDING|PF_BOUNCING); + players[i].nightstime = 0; + if (P_IsLocalPlayer(&players[i])) + S_StartSound(NULL, sfx_s3k66); + } } - if (ssrings >= totalrings && totalrings > 0) + if (stillalive) { - // Halt all the players - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - { - players[i].mo->momx = players[i].mo->momy = 0; - players[i].exiting = (14*TICRATE)/5 + 1; - } - + if (countspheres >= ssspheres) + { + // Halt all the players + for (i = 0; i < MAXPLAYERS; i++) + if (playeringame[i] && !players[i].exiting) + { + players[i].mo->momx = players[i].mo->momy = 0; + players[i].exiting = (14*TICRATE)/5 + 1; + } + sstimer = 0; + P_GiveEmerald(true); + P_RestoreMusic(&players[consoleplayer]); + } + } + else sstimer = 0; - - P_GiveEmerald(true); - } - - // Decrement the timer - if (!objectplacing) - { - if (inwater) - sstimer -= 6; - else - sstimer--; - } } } @@ -534,7 +553,7 @@ static inline void P_DoTagStuff(void) for (i=0; i < MAXPLAYERS; i++) { if (playeringame[i] && !players[i].spectator && players[i].playerstate == PST_LIVE - && !(players[i].pflags & (PF_TAGIT|PF_TAGGED))) + && !(players[i].pflags & (PF_TAGIT|PF_GAMETYPEOVER))) //points given is the number of participating players divided by two. P_AddPlayerScore(&players[i], participants/2); } @@ -569,10 +588,24 @@ void P_Ticker(boolean run) { INT32 i; - //Increment jointime even if paused. + // Increment jointime and quittime even if paused for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) - ++players[i].jointime; + { + players[i].jointime++; + + if (players[i].quittime) + { + players[i].quittime++; + + if (players[i].quittime == 30 * TICRATE && G_TagGametype()) + P_CheckSurvivors(); + + if (server && players[i].quittime >= (tic_t)FixedMul(cv_rejointimeout.value, 60 * TICRATE) + && !(players[i].quittime % TICRATE)) + SendKick(i, KICK_MSG_PLAYER_QUIT); + } + } if (objectplacing) { @@ -582,13 +615,20 @@ void P_Ticker(boolean run) OP_ObjectplaceMovement(&players[0]); P_MoveChaseCamera(&players[0], &camera, false); P_MapEnd(); + S_SetStackAdjustmentStart(); return; } } // Check for pause or menu up in single player if (paused || P_AutoPause()) + { + S_SetStackAdjustmentStart(); return; + } + + if (!S_MusicPaused()) + S_AdjustMusicStackTics(); postimgtype = postimgtype2 = postimg_none; @@ -601,6 +641,8 @@ void P_Ticker(boolean run) if (demoplayback) G_ReadDemoTiccmd(&players[consoleplayer].cmd, 0); + LUAh_PreThinkFrame(); + for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerThink(&players[i]); @@ -610,7 +652,7 @@ void P_Ticker(boolean run) if (!demoplayback) // Don't increment if a demo is playing. totalplaytime++; - if (!useNightsSS && G_IsSpecialStage(gamemap)) + if (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap)) P_DoSpecialStageStuff(); if (runemeraldmanager) @@ -625,9 +667,7 @@ void P_Ticker(boolean run) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); -#ifdef HAVE_BLUA LUAh_ThinkFrame(); -#endif } // Run shield positioning @@ -652,7 +692,7 @@ void P_Ticker(boolean run) if (run) { - if (countdowntimer && --countdowntimer <= 0) + if (countdowntimer && G_PlatformGametype() && (gametype == GT_COOP || leveltime >= 4*TICRATE) && !stoppedclock && --countdowntimer <= 0) { countdowntimer = 0; countdowntimeup = true; @@ -664,7 +704,9 @@ void P_Ticker(boolean run) if (!players[i].mo) continue; - P_DamageMobj(players[i].mo, NULL, NULL, 10000); + if (multiplayer || netgame) + players[i].exiting = 0; + P_DamageMobj(players[i].mo, NULL, NULL, 1, DMG_INSTAKILL); } } @@ -696,6 +738,8 @@ void P_Ticker(boolean run) G_ConsGhostTic(); if (modeattacking) G_GhostTicker(); + + LUAh_PostThinkFrame(); } P_MapEnd(); @@ -715,6 +759,8 @@ void P_PreTicker(INT32 frames) { P_MapStart(); + LUAh_PreThinkFrame(); + for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) { @@ -738,9 +784,7 @@ void P_PreTicker(INT32 frames) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); -#ifdef HAVE_BLUA LUAh_ThinkFrame(); -#endif // Run shield positioning P_RunShields(); @@ -749,6 +793,8 @@ void P_PreTicker(INT32 frames) P_UpdateSpecials(); P_RespawnSpecials(); + LUAh_PostThinkFrame(); + P_MapEnd(); } } diff --git a/src/p_tick.h b/src/p_tick.h index 169c54c8e..1fb88f3f2 100644 --- a/src/p_tick.h +++ b/src/p_tick.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,7 +27,7 @@ void Command_CountMobjs_f(void); void P_Ticker(boolean run); void P_PreTicker(INT32 frames); void P_DoTeamscrambling(void); -void P_RemoveThinkerDelayed(void *pthinker); //killed +void P_RemoveThinkerDelayed(thinker_t *thinker); //killed mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98 #endif diff --git a/src/p_user.c b/src/p_user.c index e4cb01f63..19b53e16f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -22,7 +22,7 @@ #include "p_local.h" #include "r_main.h" #include "s_sound.h" -#include "r_things.h" +#include "r_skins.h" #include "d_think.h" #include "r_sky.h" #include "p_setup.h" @@ -42,6 +42,8 @@ #include "b_bot.h" // Objectplace #include "m_cheat.h" +// Thok camera snap (ctrl-f "chalupa") +#include "g_input.h" #ifdef HW3SOUND #include "hardware/hw3sound.h" @@ -56,6 +58,29 @@ static void P_NukeAllPlayers(player_t *player); #endif +// +// Jingle stuff. +// + +jingle_t jingleinfo[NUMJINGLES] = { + // {musname, looping, reset, nest} + {"" , false}, // JT_NONE + {"" , false}, // JT_OTHER + {"" , false}, // JT_MASTER + {"_1up" , false}, + {"_shoes" , true}, + {"_inv" , false}, + {"_minv" , false}, + {"_drown" , false}, + {"_super" , true}, + {"_gover" , false}, + {"_ntime" , false}, // JT_NIGHTSTIMEOUT + {"_drown" , false} // JT_SSTIMEOUT + // {"_clear" , false}, + // {"_inter" , true}, + // {"_conti" , true} +}; + // // Movement. // @@ -165,10 +190,10 @@ fixed_t P_ReturnThrustY(mobj_t *mo, angle_t angle, fixed_t move) boolean P_AutoPause(void) { // Don't pause even on menu-up or focus-lost in netgames or record attack - if (netgame || modeattacking) + if (netgame || modeattacking || gamestate == GS_TITLESCREEN) return false; - return (menuactive || window_notinfocus); + return (menuactive || ( window_notinfocus && cv_pauseifunfocused.value )); } // @@ -188,11 +213,12 @@ void P_CalcHeight(player_t *player) // Note: a LUT allows for effects // like a ramp with low health. - player->bob = (FixedMul(player->rmomx,player->rmomx) - + FixedMul(player->rmomy,player->rmomy))>>2; + player->bob = FixedMul(cv_movebob.value, + (FixedMul(player->rmomx,player->rmomx) + + FixedMul(player->rmomy,player->rmomy))>>2); - if (player->bob > FixedMul(MAXBOB, mo->scale)) - player->bob = FixedMul(MAXBOB, mo->scale); + if (player->bob > FixedMul(cv_movebob.value, FixedMul(MAXBOB, mo->scale))) + player->bob = FixedMul(cv_movebob.value, FixedMul(MAXBOB, mo->scale)); if (!P_IsObjectOnGround(mo)) { @@ -215,7 +241,7 @@ void P_CalcHeight(player_t *player) bob = FixedMul(player->bob/2, FINESINE(angle)); // move viewheight - pviewheight = FixedMul(cv_viewheight.value << FRACBITS, mo->scale); // default eye view height + pviewheight = FixedMul(41*player->height/48, mo->scale); // default eye view height if (player->playerstate == PST_LIVE) { @@ -282,22 +308,11 @@ boolean P_PlayerMoving(INT32 pnum) // UINT8 P_GetNextEmerald(void) { - if (!useNightsSS) // In order - { - if (!(emeralds & EMERALD1)) return 0; - if (!(emeralds & EMERALD2)) return 1; - if (!(emeralds & EMERALD3)) return 2; - if (!(emeralds & EMERALD4)) return 3; - if (!(emeralds & EMERALD5)) return 4; - if (!(emeralds & EMERALD6)) return 5; - return 6; - } - else // Depends on stage - { - if (gamemap < sstage_start || gamemap > sstage_end) - return 0; + if (gamemap >= sstage_start && gamemap <= sstage_end) return (UINT8)(gamemap - sstage_start); - } + if (gamemap >= smpstage_start || gamemap <= smpstage_end) + return (UINT8)(gamemap - smpstage_start); + return 0; } // @@ -308,23 +323,84 @@ UINT8 P_GetNextEmerald(void) // void P_GiveEmerald(boolean spawnObj) { - INT32 i; - UINT8 em; + UINT8 em = P_GetNextEmerald(); S_StartSound(NULL, sfx_cgot); // Got the emerald! - em = P_GetNextEmerald(); emeralds |= (1 << em); + stagefailed = false; if (spawnObj) { + // The Chaos Emerald begins to orbit us! + // Only visibly give it to ONE person! + UINT8 i, pnum = ((playeringame[consoleplayer]) && (!players[consoleplayer].spectator) && (players[consoleplayer].mo)) ? consoleplayer : 255; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]) - P_SetMobjState(P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_GOTEMERALD), - mobjinfo[MT_GOTEMERALD].spawnstate + em); + { + mobj_t *emmo; + if (!playeringame[i]) + continue; + if (players[i].spectator) + continue; + if (!players[i].mo) + continue; + emmo = P_SpawnMobjFromMobj(players[i].mo, 0, 0, players[i].mo->height, MT_GOTEMERALD); + if (!emmo) + continue; + P_SetTarget(&emmo->target, players[i].mo); + P_SetMobjState(emmo, mobjinfo[MT_GOTEMERALD].meleestate + em); + + // Make sure we're not being carried before our tracer is changed + if (players[i].powers[pw_carry] != CR_NIGHTSMODE) + players[i].powers[pw_carry] = CR_NONE; + + P_SetTarget(&players[i].mo->tracer, emmo); + + if (pnum == 255) + { + pnum = i; + continue; + } + + if (i == pnum) + continue; + + emmo->flags2 |= MF2_DONTDRAW; + } } } +// +// P_GiveFinishFlags +// +// Give the player visual indicators +// that they've finished the map. +// +void P_GiveFinishFlags(player_t *player) +{ + angle_t angle = FixedAngle(player->mo->angle << FRACBITS); + UINT8 i; + + if (!player->mo) + return; + + if (!(netgame||multiplayer)) + return; + + for (i = 0; i < 3; i++) + { + angle_t fa = (angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t xoffs = FINECOSINE(fa); + fixed_t yoffs = FINESINE(fa); + mobj_t* flag = P_SpawnMobjFromMobj(player->mo, xoffs, yoffs, 0, MT_FINISHFLAG); + flag->angle = angle; + angle += FixedAngle(120*FRACUNIT); + + P_SetTarget(&flag->target, player->mo); + } +} + +#if 0 // // P_ResetScore // @@ -335,6 +411,7 @@ void P_ResetScore(player_t *player) player->scoreadd = 0; } +#endif // // P_FindLowestMare @@ -347,19 +424,23 @@ UINT8 P_FindLowestMare(void) mobj_t *mo2; UINT8 mare = UINT8_MAX; - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) return 0; // scan the thinkers // to find the egg capsule with the lowest mare - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_EGGCAPSULE && mo2->health > 0) + if (mo2->type != MT_EGGCAPSULE) + continue; + if (mo2->health <= 0) + continue; + { const UINT8 threshold = (UINT8)mo2->threshold; if (mare == 255) @@ -396,37 +477,39 @@ boolean P_TransferToNextMare(player_t *player) CONS_Debug(DBG_NIGHTS, "Mare is %d\n", mare); player->mare = mare; + player->marelap = 0; + player->marebonuslap = 0; // scan the thinkers // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_AXIS) - { - if (mo2->threshold == mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - lowestaxisnum = mo2->health; - dist2 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; - } - else if (mo2->health < lowestaxisnum) - { - dist1 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; + if (mo2->type != MT_AXIS) + continue; - if (dist1 < dist2) - { - closestaxis = mo2; - lowestaxisnum = mo2->health; - dist2 = dist1; - } - } + if (mo2->threshold != mare) + continue; + + if (closestaxis == NULL) + { + closestaxis = mo2; + lowestaxisnum = mo2->health; + dist2 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y) - mo2->radius; + } + else if (mo2->health < lowestaxisnum) + { + dist1 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y) - mo2->radius; + + if (dist1 < dist2) + { + closestaxis = mo2; + lowestaxisnum = mo2->health; + dist2 = dist1; } } } @@ -450,9 +533,9 @@ static mobj_t *P_FindAxis(INT32 mare, INT32 axisnum) // scan the thinkers // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -461,11 +544,13 @@ static mobj_t *P_FindAxis(INT32 mare, INT32 axisnum) if (!(mo2->flags2 & MF2_AXIS)) return NULL; - if (mo2->type == MT_AXIS) - { - if (mo2->health == axisnum && mo2->threshold == mare) - return mo2; - } + if (mo2->type != MT_AXIS) + continue; + if (mo2->health != axisnum) + continue; + if (mo2->threshold != mare) + continue; + return mo2; } return NULL; @@ -483,9 +568,9 @@ static mobj_t *P_FindAxisTransfer(INT32 mare, INT32 axisnum, mobjtype_t type) // scan the thinkers // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -494,11 +579,13 @@ static mobj_t *P_FindAxisTransfer(INT32 mare, INT32 axisnum, mobjtype_t type) if (!(mo2->flags2 & MF2_AXIS)) return NULL; - if (mo2->type == type) - { - if (mo2->health == axisnum && mo2->threshold == mare) - return mo2; - } + if (mo2->type != type) + continue; + if (mo2->health != axisnum) + continue; + if (mo2->threshold != mare) + continue; + return mo2; } return NULL; @@ -522,32 +609,33 @@ void P_TransferToAxis(player_t *player, INT32 axisnum) // scan the thinkers // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_AXIS) - { - if (mo2->health == axisnum && mo2->threshold == mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - dist2 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; - } - else - { - dist1 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y)-mo2->radius; + if (mo2->type != MT_AXIS) + continue; + if (mo2->health != axisnum) + continue; + if (mo2->threshold != mare) + continue; - if (dist1 < dist2) - { - closestaxis = mo2; - dist2 = dist1; - } - } + if (closestaxis == NULL) + { + closestaxis = mo2; + dist2 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y) - mo2->radius; + } + else + { + dist1 = R_PointToDist2(player->mo->x, player->mo->y, mo2->x, mo2->y) - mo2->radius; + + if (dist1 < dist2) + { + closestaxis = mo2; + dist2 = dist1; } } } @@ -574,25 +662,30 @@ static void P_DeNightserizePlayer(player_t *player) thinker_t *th; mobj_t *mo2; - player->pflags &= ~PF_NIGHTSMODE; - - //if (player->mo->tracer) - //P_RemoveMobj(player->mo->tracer); + player->powers[pw_carry] = CR_NIGHTSFALL; player->powers[pw_underwater] = 0; - player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_THOKKED|PF_SPINNING|PF_DRILLING|PF_TRANSFERTOCLOSEST); + player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_STARTJUMP|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED|PF_SPINNING|PF_DRILLING|PF_TRANSFERTOCLOSEST); player->secondjump = 0; - player->jumping = 0; player->homing = 0; player->climbing = 0; player->mo->fuse = 0; player->speed = 0; + player->marelap = 0; + player->marebonuslap = 0; + player->flyangle = 0; + player->anotherflyangle = 0; + player->mo->rollangle = 0; + P_SetTarget(&player->mo->target, NULL); P_SetTarget(&player->axis1, P_SetTarget(&player->axis2, NULL)); player->mo->flags &= ~MF_NOGRAVITY; - player->mo->flags2 &= ~MF2_DONTDRAW; + player->mo->skin = &skins[player->skin]; + player->followitem = skins[player->skin].followitem; + player->mo->color = player->skincolor; + G_GhostAddColor(GHC_RETURNSKIN); // Restore aiming angle if (player == &players[consoleplayer]) @@ -600,85 +693,140 @@ static void P_DeNightserizePlayer(player_t *player) else if (player == &players[secondarydisplayplayer]) localaiming2 = 0; - // If you screwed up, kiss your score goodbye. - player->marescore = 0; - - if (player->mo->tracer) - P_RemoveMobj(player->mo->tracer); - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - player->pflags |= PF_NIGHTSFALL; + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); // If in a special stage, add some preliminary exit time. if (G_IsSpecialStage(gamemap)) { INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) players[i].nightstime = 1; // force everyone else to fall too. player->exiting = 3*TICRATE; - stagefailed = true; // NIGHT OVER + + // If you screwed up, kiss your score and ring bonus goodbye. + // But only do this in special stage (and instakill!) In regular stages, wait til we hit the ground. + player->marescore = player->spheres =\ + player->rings = 0; } // Check to see if the player should be killed. - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; if (!(mo2->type == MT_NIGHTSDRONE)) continue; - if (mo2->flags & MF_AMBUSH) - P_DamageMobj(player->mo, NULL, NULL, 10000); + if (mo2->flags2 & MF2_AMBUSH) + { + player->marescore = player->spheres =\ + player->rings = 0; + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_INSTAKILL); + + // Reset music to beginning if MIXNIGHTSCOUNTDOWN + if ((mapheaderinfo[gamemap-1]->levelflags & LF_MIXNIGHTSCOUNTDOWN) +#ifdef _WIN32 + && S_MusicType() != MU_MID +#endif + ) + S_SetMusicPosition(0); + } break; } + if (player->mo->scale != player->oldscale) + player->mo->destscale = player->oldscale; + player->oldscale = 0; + // Restore from drowning music - P_RestoreMusic(player); + if ((mapheaderinfo[gamemap-1]->levelflags & LF_MIXNIGHTSCOUNTDOWN) +#ifdef _WIN32 + && S_MusicType() != MU_MID +#endif + ) + { + S_StopSoundByNum(sfx_timeup); + S_StopFadingMusic(); + S_SetInternalMusicVolume(100); + + // Reset the music if you did not destroy all the capsules, because you failed. + // Why make the all-capsules exception: because it's your reward for nearly finishing the level! + // (unless the player auto-loses upon denightserizing; for death case, see above.) + if (P_FindLowestMare() != UINT8_MAX || G_IsSpecialStage(gamemap)) + S_SetMusicPosition(0); + } + else + { + music_stack_fadein = 0; // HACK: Change fade-in for restore music + P_RestoreMusic(player); + } + + P_RunDeNightserizeExecutors(player->mo); } + // // P_NightserizePlayer // // NiGHTS Time! void P_NightserizePlayer(player_t *player, INT32 nighttime) { - INT32 oldmare; + UINT8 oldmare, oldmarelap, oldmarebonuslap; - // Bots can't be super, silly!1 :P + // Bots can't be NiGHTSerized, silly!1 :P if (player->bot) return; - if (!(player->pflags & PF_NIGHTSMODE)) + if (player->powers[pw_carry] != CR_NIGHTSMODE) { - P_SetTarget(&player->mo->tracer, P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NIGHTSCHAR)); - player->mo->tracer->destscale = player->mo->scale; - P_SetScale(player->mo->tracer, player->mo->scale); - player->mo->tracer->eflags = (player->mo->tracer->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); - player->mo->height = player->mo->tracer->height; + player->mo->height = P_GetPlayerHeight(player); // Just to make sure jumping into the drone doesn't result in a squashed hitbox. + player->oldscale = player->mo->scale; + + if (skins[player->skin].sprites[SPR2_NFLY].numframes == 0) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. + { + player->mo->skin = &skins[DEFAULTNIGHTSSKIN]; + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + player->mo->color = skins[DEFAULTNIGHTSSKIN].prefcolor; + player->followitem = skins[DEFAULTNIGHTSSKIN].followitem; + G_GhostAddColor(GHC_NIGHTSSKIN); + } } - player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_THOKKED|PF_SPINNING|PF_DRILLING); + player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED|PF_SHIELDABILITY|PF_SPINNING|PF_DRILLING); player->homing = 0; player->mo->fuse = 0; player->speed = 0; player->climbing = 0; player->secondjump = 0; + player->flyangle = 0; + player->anotherflyangle = 0; + player->mo->rollangle = 0; player->powers[pw_shield] = SH_NONE; + player->powers[pw_super] = 0; player->mo->flags |= MF_NOGRAVITY; - player->mo->flags2 |= MF2_DONTDRAW; - - player->nightstime = player->startedtime = nighttime*TICRATE; + player->nightstime = player->startedtime = player->lapstartedtime = nighttime*TICRATE; player->bonustime = false; - P_RestoreMusic(player); - P_SetMobjState(player->mo->tracer, S_SUPERTRANS1); + // Restore from drowning music + if (mapheaderinfo[gamemap-1]->levelflags & LF_MIXNIGHTSCOUNTDOWN) + { + S_StopSoundByNum(sfx_timeup); + S_StopFadingMusic(); + S_SetInternalMusicVolume(100); + } + else + { + music_stack_fadein = 0; // HACK: Change fade-in for restore music + P_RestoreMusic(player); + } - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) { if (player->drillmeter < 48*20) player->drillmeter = 48*20; @@ -690,10 +838,13 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) } oldmare = player->mare; + oldmarelap = player->marelap; + oldmarebonuslap = player->marebonuslap; - if (P_TransferToNextMare(player) == false) + if (!P_TransferToNextMare(player)) { INT32 i; + INT32 total_spheres = 0; INT32 total_rings = 0; P_SetTarget(&player->mo->target, NULL); @@ -701,8 +852,11 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) if (G_IsSpecialStage(gamemap)) { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i]/* && players[i].pflags & PF_NIGHTSMODE*/) - total_rings += players[i].health-1; + if (playeringame[i]/* && players[i].powers[pw_carry] == CR_NIGHTSMODE*/) + { + total_spheres += players[i].spheres; + total_rings += players[i].rings; + } } for (i = 0; i < MAXPLAYERS; i++) @@ -713,15 +867,19 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) players[i].texttimer = (3 * TICRATE) - 10; players[i].textvar = 4; // Score and grades players[i].lastmare = players[i].mare; + players[i].lastmarelap = players[i].marelap; + players[i].lastmarebonuslap = players[i].marebonuslap; if (G_IsSpecialStage(gamemap)) { + players[i].finishedspheres = (INT16)total_spheres; players[i].finishedrings = (INT16)total_rings; - P_AddPlayerScore(player, total_rings * 50); + P_AddPlayerScore(player, total_spheres * 50); } else { - players[i].finishedrings = (INT16)(players[i].health - 1); - P_AddPlayerScore(&players[i], (players[i].health - 1) * 50); + players[i].finishedspheres = (INT16)(players[i].spheres); + players[i].finishedrings = (INT16)(players[i].rings); + P_AddPlayerScore(&players[i], (players[i].spheres) * 50); } // Add score to leaderboards now @@ -729,34 +887,40 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) G_AddTempNightsRecords(players[i].marescore, leveltime - player->marebegunat, players[i].mare + 1); // transfer scores anyway + players[i].totalmarescore += players[i].marescore; players[i].lastmarescore = players[i].marescore; players[i].marescore = 0; - players[i].mo->health = players[i].health = 1; + players[i].spheres = players[i].rings = 0; P_DoPlayerExit(&players[i]); } } else if (oldmare != player->mare) { /// \todo Handle multi-mare special stages. - // Ring bonus - P_AddPlayerScore(player, (player->health - 1) * 50); + // Spheres bonus + P_AddPlayerScore(player, (player->spheres) * 50); - player->lastmare = (UINT8)oldmare; + player->lastmare = oldmare; + player->lastmarelap = oldmarelap; + player->lastmarebonuslap = oldmarebonuslap; player->texttimer = 4*TICRATE; player->textvar = 4; // Score and grades - player->finishedrings = (INT16)(player->health - 1); + player->finishedspheres = (INT16)(player->spheres); + player->finishedrings = (INT16)(player->rings); // Add score to temp leaderboards if (!(netgame||multiplayer) && P_IsLocalPlayer(player)) G_AddTempNightsRecords(player->marescore, leveltime - player->marebegunat, (UINT8)(oldmare + 1)); // Starting a new mare, transfer scores + player->totalmarescore += player->marescore; player->lastmarescore = player->marescore; player->marescore = 0; player->marebegunat = leveltime; + player->lapbegunat = leveltime; - player->mo->health = player->health = 1; + player->spheres = player->rings = 0; } else { @@ -765,11 +929,36 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) // Don't show before title card // Not consistency safe, but this only affects drawing - if (timeinmap + 40 < 110) - player->texttimer = (UINT8)(110 - timeinmap); + if (timeinmap + 40 < (110 - 70)) + player->texttimer = (UINT8)((110 - 70) - timeinmap); } - player->pflags |= PF_NIGHTSMODE; + if (player->drone && player->drone->scale != player->mo->scale) + player->mo->destscale = player->drone->scale; + + // force NiGHTS to face forward or backward + if (player->mo->target) + { + player->angle_pos = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); + player->drawangle = player->angle_pos + + ((player->mo->target->flags2 & MF2_AMBUSH) ? // if axis is invert, take the opposite right angle + -ANGLE_90 : ANGLE_90); // flyangle is always 0 here, below is kept for posterity + /*(player->flyangle > 90 && player->flyangle < 270 ? ANGLE_90 : -ANGLE_90) + : (player->flyangle > 90 && player->flyangle < 270 ? -ANGLE_90 : ANGLE_90));*/ + } + + // Do this before setting CR_NIGHTSMODE so we can tell if player was non-NiGHTS + P_RunNightserizeExecutors(player->mo); + + player->powers[pw_carry] = CR_NIGHTSMODE; + P_SetPlayerMobjState(player->mo, S_PLAY_NIGHTS_TRANS1); +} + +pflags_t P_GetJumpFlags(player_t *player) +{ + if (player->charflags & SF_NOJUMPDAMAGE) + return (PF_JUMPED|PF_NOJUMPDAMAGE); + return PF_JUMPED; } // @@ -784,6 +973,9 @@ boolean P_PlayerInPain(player_t *player) if (!(player->pflags & PF_SLIDING) && player->mo->state == &states[player->mo->info->painstate] && player->powers[pw_flashing]) return true; + if (player->mo->state == &states[S_PLAY_STUN]) + return true; + return false; } @@ -795,62 +987,71 @@ boolean P_PlayerInPain(player_t *player) // void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) { - angle_t ang; - fixed_t fallbackspeed; - - if (player->mo->eflags & MFE_VERTICALFLIP) - player->mo->z--; - else - player->mo->z++; - - if (player->mo->eflags & MFE_UNDERWATER) - P_SetObjectMomZ(player->mo, FixedDiv(10511*FRACUNIT,2600*FRACUNIT), false); - else - P_SetObjectMomZ(player->mo, FixedDiv(69*FRACUNIT,10*FRACUNIT), false); - - if (inflictor) - { - ang = R_PointToAngle2(inflictor->x-inflictor->momx, inflictor->y - inflictor->momy, player->mo->x - player->mo->momx, player->mo->y - player->mo->momy); - - // explosion and rail rings send you farther back, making it more difficult - // to recover - if ((inflictor->flags2 & MF2_SCATTER) && source) - { - fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); - - dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4; - - if (dist < FixedMul(4*FRACUNIT, inflictor->scale)) - dist = FixedMul(4*FRACUNIT, inflictor->scale); - - fallbackspeed = dist; - } - else if (inflictor->flags2 & MF2_EXPLOSION) - { - if (inflictor->flags2 & MF2_RAILRING) - fallbackspeed = FixedMul(38*FRACUNIT, inflictor->scale); // 7x - else - fallbackspeed = FixedMul(30*FRACUNIT, inflictor->scale); // 5x - } - else if (inflictor->flags2 & MF2_RAILRING) - fallbackspeed = FixedMul(45*FRACUNIT, inflictor->scale); // 4x - else - fallbackspeed = FixedMul(4*FRACUNIT, inflictor->scale); // the usual amount of force - } - else - { - ang = R_PointToAngle2(player->mo->momx, player->mo->momy, 0, 0); - fallbackspeed = FixedMul(4*FRACUNIT, player->mo->scale); - } - - P_InstaThrust(player->mo, ang, fallbackspeed); - - if (player->pflags & PF_ROPEHANG) + if (player->powers[pw_carry] == CR_ROPEHANG) P_SetTarget(&player->mo->tracer, NULL); + { + angle_t ang; + fixed_t fallbackspeed; + + P_ResetPlayer(player); + P_SetPlayerMobjState(player->mo, player->mo->info->painstate); + + if (player->mo->eflags & MFE_VERTICALFLIP) + player->mo->z--; + else + player->mo->z++; + + if (player->mo->eflags & MFE_UNDERWATER) + P_SetObjectMomZ(player->mo, FixedDiv(10511*FRACUNIT,2600*FRACUNIT), false); + else + P_SetObjectMomZ(player->mo, FixedDiv(69*FRACUNIT,10*FRACUNIT), false); + + if (inflictor) + { + if (inflictor->type == MT_WALLSPIKE) + ang = inflictor->angle; + else + ang = R_PointToAngle2(inflictor->x-inflictor->momx, inflictor->y - inflictor->momy, player->mo->x - player->mo->momx, player->mo->y - player->mo->momy); + + // explosion and rail rings send you farther back, making it more difficult + // to recover + if ((inflictor->flags2 & MF2_SCATTER) && source) + { + fixed_t dist = P_AproxDistance(P_AproxDistance(source->x-player->mo->x, source->y-player->mo->y), source->z-player->mo->z); + + dist = FixedMul(128*FRACUNIT, inflictor->scale) - dist/4; + + if (dist < FixedMul(4*FRACUNIT, inflictor->scale)) + dist = FixedMul(4*FRACUNIT, inflictor->scale); + + fallbackspeed = dist; + } + else if (inflictor->flags2 & MF2_EXPLOSION) + { + if (inflictor->flags2 & MF2_RAILRING) + fallbackspeed = FixedMul(38*FRACUNIT, inflictor->scale); // 7x + else + fallbackspeed = FixedMul(30*FRACUNIT, inflictor->scale); // 5x + } + else if (inflictor->flags2 & MF2_RAILRING) + fallbackspeed = FixedMul(45*FRACUNIT, inflictor->scale); // 4x + else + fallbackspeed = FixedMul(4*FRACUNIT, inflictor->scale); // the usual amount of force + } + else + { + ang = ((player->mo->momx || player->mo->momy) ? R_PointToAngle2(player->mo->momx, player->mo->momy, 0, 0) : player->drawangle); + fallbackspeed = FixedMul(4*FRACUNIT, player->mo->scale); + } + + player->drawangle = ang + ANGLE_180; + P_InstaThrust(player->mo, ang, fallbackspeed); + } + // Point penalty for hitting a hazard during tag. // Discourages players from intentionally hurting themselves to avoid being tagged. - if (gametype == GT_TAG && (!(player->pflags & PF_TAGGED) && !(player->pflags & PF_TAGIT))) + if (gametype == GT_TAG && (!(player->pflags & PF_GAMETYPEOVER) && !(player->pflags & PF_TAGIT))) { if (player->score >= 50) player->score -= 50; @@ -858,8 +1059,6 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) player->score = 0; } - P_ResetPlayer(player); - P_SetPlayerMobjState(player->mo, player->mo->info->painstate); player->powers[pw_flashing] = flashingtics; if (player->timeshit != UINT8_MAX) @@ -872,8 +1071,22 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) // Useful when you want to kill everything the player is doing. void P_ResetPlayer(player_t *player) { - player->pflags &= ~(PF_ROPEHANG|PF_ITEMHANG|PF_MACESPIN|PF_SPINNING|PF_JUMPED|PF_GLIDING|PF_THOKKED|PF_CARRIED); - player->jumping = 0; + player->pflags &= ~(PF_SPINNING|PF_STARTDASH|PF_STARTJUMP|PF_JUMPED|PF_NOJUMPDAMAGE|PF_GLIDING|PF_THOKKED|PF_CANCARRY|PF_SHIELDABILITY|PF_BOUNCING); + + if (player->powers[pw_carry] == CR_ROLLOUT) + { + if (player->mo->tracer && !P_MobjWasRemoved(player->mo->tracer)) + { + player->mo->tracer->flags |= MF_PUSHABLE; + P_SetTarget(&player->mo->tracer->tracer, NULL); + } + P_SetTarget(&player->mo->tracer, NULL); + player->powers[pw_carry] = CR_NONE; + } + + if (!(player->powers[pw_carry] == CR_NIGHTSMODE || player->powers[pw_carry] == CR_NIGHTSFALL || player->powers[pw_carry] == CR_BRAKGOOP || player->powers[pw_carry] == CR_MINECART)) + player->powers[pw_carry] = CR_NONE; + player->secondjump = 0; player->glidetime = 0; player->homing = 0; @@ -882,47 +1095,121 @@ void P_ResetPlayer(player_t *player) player->onconveyor = 0; player->skidtime = 0; if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } +// P_PlayerCanDamage +// +// Can player do damage? +// +boolean P_PlayerCanDamage(player_t *player, mobj_t *thing) +{ + fixed_t bottomheight, topheight; + + if (!player->mo || player->spectator || !thing || P_MobjWasRemoved(thing)) + return false; + + { + UINT8 shouldCollide = LUAh_PlayerCanDamage(player, thing); + if (P_MobjWasRemoved(thing)) + return false; // removed??? + if (shouldCollide == 1) + return true; // force yes + else if (shouldCollide == 2) + return false; // force no + } + + // Invinc/super. Not for Monitors. + if (!(thing->flags & MF_MONITOR) && (player->powers[pw_invulnerability] || player->powers[pw_super])) + return true; + + // NiGHTS drill. Wasn't originally for monitors, but that's more an oversight being corrected than anything else. + if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (player->pflags & PF_DRILLING)) + return true; + + // Jumping. + if ((player->pflags & PF_JUMPED) + && (!(player->pflags & PF_NOJUMPDAMAGE) + || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY))) + return true; + + // Spinning. + if (player->pflags & PF_SPINNING) + return true; + + if (player->dashmode >= DASHMODE_THRESHOLD && (player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) + return true; + + // From the front. + if (((player->pflags & PF_GLIDING) || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) + && (player->drawangle - R_PointToAngle2(player->mo->x - player->mo->momx, player->mo->y - player->mo->momy, thing->x, thing->y) + + ANGLE_90) < ANGLE_180) + return true; + + // From the top/bottom. + bottomheight = player->mo->z; + topheight = player->mo->z + player->mo->height; + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + fixed_t swap = bottomheight; + bottomheight = topheight; + topheight = swap; + } + + if (P_MobjFlip(player->mo)*(bottomheight - (thing->z + thing->height/2)) > 0) + { + if ((player->charflags & SF_STOMPDAMAGE || player->pflags & PF_BOUNCING) && (P_MobjFlip(player->mo)*(player->mo->momz - thing->momz) < 0)) + return true; + } + else if (P_MobjFlip(player->mo)*(topheight - (thing->z + thing->height/2)) < 0) + { + if (player->charability == CA_FLY && player->panim == PA_ABILITY && !(player->mo->eflags & MFE_UNDERWATER) && (P_MobjFlip(player->mo)*(player->mo->momz - thing->momz) > 0)) + return true; + } + + // Shield stomp. + if (((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL || (player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) && (player->pflags & PF_SHIELDABILITY)) + return true; + + return false; +} + + + // // P_GivePlayerRings // // Gives rings to the player, and does any special things required. // Call this function when you want to increment the player's health. // + void P_GivePlayerRings(player_t *player, INT32 num_rings) { + if (!player) + return; + if (player->bot) player = &players[consoleplayer]; if (!player->mo) return; - player->mo->health += num_rings; - player->health += num_rings; + player->rings += num_rings; - if (!G_IsSpecialStage(gamemap) || !useNightsSS) - player->totalring += num_rings; + player->totalring += num_rings; // Can only get up to 9999 rings, sorry! - if (player->mo->health > 10000) - { - player->mo->health = 10000; - player->health = 10000; - } - else if (player->mo->health < 1) - { - player->mo->health = 1; - player->health = 1; - } + if (player->rings > 9999) + player->rings = 9999; + else if (player->rings < 0) + player->rings = 0; // Now extra life bonuses are handled here instead of in P_MovePlayer, since why not? - if (!ultimatemode && !modeattacking && !G_IsSpecialStage(gamemap) && G_GametypeUsesLives()) + if (!ultimatemode && !modeattacking && !G_IsSpecialStage(gamemap) && G_GametypeUsesLives() && player->lives != INFLIVES) { INT32 gainlives = 0; - while (player->xtralife < maxXtraLife && player->health > 100 * (player->xtralife+1)) + while (player->xtralife < maxXtraLife && player->rings >= 100 * (player->xtralife+1)) { ++gainlives; ++player->xtralife; @@ -930,12 +1217,37 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) if (gainlives) { - P_GivePlayerLives(player, gainlives); + player->lives += gainlives; + if (player->lives > 99) + player->lives = 99; + else if (player->lives < 1) + player->lives = 1; + P_PlayLivesJingle(player); } } } +void P_GivePlayerSpheres(player_t *player, INT32 num_spheres) +{ + if (!player) + return; + + if (player->bot) + player = &players[consoleplayer]; + + if (!player->mo) + return; + + player->spheres += num_spheres; + + // Can only get up to 9999 spheres, sorry! + if (player->spheres > 9999) + player->spheres = 9999; + else if (player->spheres < 0) + player->spheres = 0; +} + // // P_GivePlayerLives // @@ -944,12 +1256,71 @@ void P_GivePlayerRings(player_t *player, INT32 num_rings) // void P_GivePlayerLives(player_t *player, INT32 numlives) { + UINT8 prevlives = player->lives; + if (!player) + return; + + if (player->bot) + player = &players[consoleplayer]; + + if (gamestate == GS_LEVEL) + { + if (player->lives == INFLIVES || !(gametyperules & GTR_LIVES)) + { + P_GivePlayerRings(player, 100*numlives); + return; + } + + if ((netgame || multiplayer) && G_GametypeUsesCoopLives() && cv_cooplives.value == 0) + { + P_GivePlayerRings(player, 100*numlives); + if (player->lives - prevlives >= numlives) + goto docooprespawn; + + numlives = (numlives + prevlives - player->lives); + } + } + else if (player->lives == INFLIVES) + return; + player->lives += numlives; if (player->lives > 99) player->lives = 99; else if (player->lives < 1) player->lives = 1; + +docooprespawn: + if (cv_coopstarposts.value) + return; + if (prevlives > 0) + return; + if (!player->spectator) + return; + P_SpectatorJoinGame(player); +} + +void P_GiveCoopLives(player_t *player, INT32 numlives, boolean sound) +{ + if (!((netgame || multiplayer) && G_GametypeUsesCoopLives())) + { + P_GivePlayerLives(player, numlives); + if (sound) + P_PlayLivesJingle(player); + } + else + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + P_GivePlayerLives(&players[i], numlives); + if (sound) + P_PlayLivesJingle(&players[i]); + } + } } // @@ -960,23 +1331,17 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) { player->powers[pw_super] = 1; if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC) && P_IsLocalPlayer(player)) - { - S_StopMusic(); - S_ChangeMusicInternal("supers", true); - } + P_PlayJingle(player, JT_SUPER); S_StartSound(NULL, sfx_supert); //let all players hear it -mattw_cfi - // Transformation animation - P_SetPlayerMobjState(player->mo, S_PLAY_SUPERTRANS1); + player->mo->momx = player->mo->momy = player->mo->momz = player->cmomx = player->cmomy = player->rmomx = player->rmomy = 0; - player->mo->momx = player->mo->momy = player->mo->momz = 0; + // Transformation animation + P_SetPlayerMobjState(player->mo, S_PLAY_SUPER_TRANS1); if (giverings) - { - player->mo->health = 51; - player->health = player->mo->health; - } + player->rings = 50; // Just in case. if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) @@ -995,6 +1360,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings) P_PlayerFlagBurst(player, false); } + // Adds to the player's score void P_AddPlayerScore(player_t *player, UINT32 amount) { @@ -1010,7 +1376,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) { // Pseudo-shared score for multiplayer special stages. INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) { oldscore = players[i].marescore; @@ -1028,7 +1394,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) players[i].continues += 1; players[i].gotcontinue = true; if (P_IsLocalPlayer(player)) - S_StartSound(NULL, sfx_flgcap); + S_StartSound(NULL, sfx_s3kac); } */ } } @@ -1048,7 +1414,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) player->continues += 1; player->gotcontinue = true; if (P_IsLocalPlayer(player)) - S_StartSound(NULL, sfx_flgcap); + S_StartSound(NULL, sfx_s3kac); } } @@ -1059,13 +1425,12 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) oldscore = player->score; // Don't go above MAXSCORE. - if (player->score + amount < MAXSCORE) - player->score += amount; - else + player->score += amount; + if (player->score > MAXSCORE) player->score = MAXSCORE; // check for extra lives every 50000 pts - if (!ultimatemode && !modeattacking && player->score > oldscore && player->score % 50000 < amount && (gametype == GT_COMPETITION || gametype == GT_COOP)) + if (!ultimatemode && !modeattacking && player->score > oldscore && player->score % 50000 < amount && (gametyperules & GTR_LIVES)) { P_GivePlayerLives(player, (player->score/50000) - (oldscore/50000)); P_PlayLivesJingle(player); @@ -1081,6 +1446,42 @@ void P_AddPlayerScore(player_t *player, UINT32 amount) } } +// Steals from every enemy's score. +void P_StealPlayerScore(player_t *player, UINT32 amount) +{ + boolean teams = G_GametypeHasTeams(); + UINT32 stolen = 0; + int i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (&players[i] == player + || (teams && players[i].ctfteam == player->ctfteam)) + continue; + if (players[i].score >= amount) + { + stolen += amount; + players[i].score -= amount; + } + else + { + stolen += players[i].score; + players[i].score = 0; + } + } + if (stolen > 0) + { + // In team match, all stolen points are removed from the enemy team's running score. + if (gametype == GT_TEAMMATCH) + { + if (player->ctfteam == 1) + bluescore -= amount; + else if (player->ctfteam == 2) + redscore -= amount; + } + P_AddPlayerScore(player, stolen); + } +} + // // P_PlayLivesJingle // @@ -1093,15 +1494,128 @@ void P_PlayLivesJingle(player_t *player) S_StartSound(NULL, sfx_oneup); else if (mariomode) S_StartSound(NULL, sfx_marioa); + else if (cv_1upsound.value) + { + if (S_sfx[sfx_oneup].lumpnum != LUMPERROR) + S_StartSound(NULL, sfx_oneup); + else + S_StartSound(NULL, sfx_chchng);/* at least play something! */ + } else { + P_PlayJingle(player, JT_1UP); if (player) player->powers[pw_extralife] = extralifetics + 1; - S_StopMusic(); // otherwise it won't restart if this is done twice in a row - S_ChangeMusicInternal("xtlife", false); + strlcpy(S_sfx[sfx_None].caption, "One-up", 7); + S_StartCaption(sfx_None, -1, extralifetics+1); } } +void P_PlayJingle(player_t *player, jingletype_t jingletype) +{ + const char *musname = jingleinfo[jingletype].musname; + UINT16 musflags = 0; + boolean looping = jingleinfo[jingletype].looping; + + char newmusic[7]; + strncpy(newmusic, musname, 7); +#ifdef HAVE_LUA_MUSICPLUS + if(LUAh_MusicJingle(jingletype, newmusic, &musflags, &looping)) + return; +#endif + newmusic[6] = 0; + + P_PlayJingleMusic(player, newmusic, musflags, looping, jingletype); +} + +// +// P_PlayJingleMusic +// +void P_PlayJingleMusic(player_t *player, const char *musname, UINT16 musflags, boolean looping, UINT16 status) +{ + // If gamestate != GS_LEVEL, always play the jingle (1-up intermission) + if (gamestate == GS_LEVEL && player && !P_IsLocalPlayer(player)) + return; + + S_RetainMusic(musname, musflags, looping, 0, status); + S_StopMusic(); + S_ChangeMusicInternal(musname, looping); +} + +boolean P_EvaluateMusicStatus(UINT16 status, const char *musname) +{ + // \todo lua hook + int i; + boolean result = false; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!P_IsLocalPlayer(&players[i])) + continue; + + switch(status) + { + case JT_1UP: // Extra life + result = (players[i].powers[pw_extralife] > 1); + break; + + case JT_SHOES: // Speed shoes + if (players[i].powers[pw_sneakers] > 1 && !players[i].powers[pw_super]) + { + //strlcpy(S_sfx[sfx_None].caption, "Speed shoes", 12); + //S_StartCaption(sfx_None, -1, players[i].powers[pw_sneakers]); + result = true; + } + else + result = false; + break; + + case JT_INV: // Invincibility + case JT_MINV: // Mario Invincibility + if (players[i].powers[pw_invulnerability] > 1) + { + //strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14); + //S_StartCaption(sfx_None, -1, players[i].powers[pw_invulnerability]); + result = true; + } + else + result = false; + break; + + case JT_DROWN: // Drowning + result = (players[i].powers[pw_underwater] && players[i].powers[pw_underwater] <= 11*TICRATE + 1); + break; + + case JT_SUPER: // Super Sonic + result = (players[i].powers[pw_super] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)); + break; + + case JT_GOVER: // Game Over + result = (players[i].lives <= 0); + break; + + case JT_NIGHTSTIMEOUT: // NiGHTS Time Out (10 seconds) + case JT_SSTIMEOUT: + result = (players[i].nightstime && players[i].nightstime <= 10*TICRATE); + break; + + case JT_OTHER: // Other state + result = LUAh_ShouldJingleContinue(&players[i], musname); + break; + + case JT_NONE: // Null state + case JT_MASTER: // Main level music + default: + result = true; + } + + if (result) + break; + } + + return result; + } + // // P_RestoreMusic // @@ -1112,25 +1626,50 @@ void P_RestoreMusic(player_t *player) if (!P_IsLocalPlayer(player)) // Only applies to a local player return; + S_SpeedMusic(1.0f); + + // Jingles have a priority in this order, so follow it + // and as a default case, go down the music stack. + + // Extra life if (player->powers[pw_extralife] > 1) return; - S_SpeedMusic(1.0f); - if (player->powers[pw_super] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) - S_ChangeMusicInternal("supers", true); - else if (player->powers[pw_invulnerability] > 1) - S_ChangeMusicInternal((mariomode) ? "minvnc" : "invinc", false); + + // Super + else if (player->powers[pw_super] && !(mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC) + && !S_RecallMusic(JT_SUPER, false)) + P_PlayJingle(player, JT_SUPER); + + // Invulnerability + else if (player->powers[pw_invulnerability] > 1 && !player->powers[pw_super]) + { + strlcpy(S_sfx[sfx_None].caption, "Invincibility", 14); + S_StartCaption(sfx_None, -1, player->powers[pw_invulnerability]); + if (!S_RecallMusic(JT_INV, false) && !S_RecallMusic(JT_MINV, false)) + P_PlayJingle(player, (mariomode) ? JT_MINV : JT_INV); + } + + // Shoes else if (player->powers[pw_sneakers] > 1 && !player->powers[pw_super]) { + strlcpy(S_sfx[sfx_None].caption, "Speed shoes", 12); + S_StartCaption(sfx_None, -1, player->powers[pw_sneakers]); if (mapheaderinfo[gamemap-1]->levelflags & LF_SPEEDMUSIC) { S_SpeedMusic(1.4f); - S_ChangeMusic(mapmusname, mapmusflags, true); + if (!S_RecallMusic(JT_MASTER, true)) + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); } - else - S_ChangeMusicInternal("shoes", true); + else if (!S_RecallMusic(JT_SHOES, false)) + P_PlayJingle(player, JT_SHOES); } - else - S_ChangeMusic(mapmusname, mapmusflags, true); + + // Default + else if (!S_RecallMusic(JT_NONE, false)) // go down the stack + { + CONS_Debug(DBG_BASIC, "Cannot find any music in resume stack!\n"); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + } } // @@ -1159,7 +1698,7 @@ boolean P_IsObjectInGoop(mobj_t *mo) // boolean P_IsObjectOnGround(mobj_t *mo) { - if (P_IsObjectInGoop(mo)) + if (P_IsObjectInGoop(mo) && !(mo->player && mo->player->pflags & PF_BOUNCING)) { /* // It's a crazy hack that checking if you're on the ground @@ -1298,28 +1837,6 @@ void P_SetObjectMomZ(mobj_t *mo, fixed_t value, boolean relative) mo->momz = value; } -// -// P_GetPlayerHeight -// -// Returns the height -// of the player. -// -fixed_t P_GetPlayerHeight(player_t *player) -{ - return FixedMul(player->mo->info->height, player->mo->scale); -} - -// -// P_GetPlayerSpinHeight -// -// Returns the 'spin height' -// of the player. -// -fixed_t P_GetPlayerSpinHeight(player_t *player) -{ - return FixedMul(FixedMul(player->mo->info->height, player->mo->scale),2*FRACUNIT/3); -} - // // P_IsLocalPlayer // @@ -1349,33 +1866,46 @@ void P_SpawnShieldOrb(player_t *player) I_Error("P_SpawnShieldOrb: player->mo is NULL!\n"); #endif + if (LUAh_ShieldSpawn(player)) + return; + if (player->powers[pw_shield] & SH_FORCE) - orbtype = MT_BLUEORB; + orbtype = MT_FORCE_ORB; else switch (player->powers[pw_shield] & SH_NOSTACK) { - case SH_JUMP: - orbtype = MT_WHITEORB; + case SH_WHIRLWIND: + orbtype = MT_WHIRLWIND_ORB; break; case SH_ATTRACT: - orbtype = MT_YELLOWORB; + orbtype = MT_ATTRACT_ORB; break; case SH_ELEMENTAL: - orbtype = MT_GREENORB; + orbtype = MT_ELEMENTAL_ORB; break; - case SH_BOMB: - orbtype = MT_BLACKORB; + case SH_ARMAGEDDON: + orbtype = MT_ARMAGEDDON_ORB; break; case SH_PITY: - orbtype = MT_PITYORB; + case SH_PINK: // PITY IN PINK + orbtype = MT_PITY_ORB; + break; + case SH_FLAMEAURA: + orbtype = MT_FLAMEAURA_ORB; + break; + case SH_BUBBLEWRAP: + orbtype = MT_BUBBLEWRAP_ORB; + break; + case SH_THUNDERCOIN: + orbtype = MT_THUNDERCOIN_ORB; break; default: return; } // blaze through the thinkers to see if an orb already exists! - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; shieldobj = (mobj_t *)th; @@ -1385,14 +1915,23 @@ void P_SpawnShieldOrb(player_t *player) } shieldobj = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, orbtype); + shieldobj->flags2 |= MF2_SHIELD; P_SetTarget(&shieldobj->target, player->mo); - shieldobj->color = (UINT8)shieldobj->info->painchance; + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) + { + shieldobj->color = SKINCOLOR_PINK; + shieldobj->colorized = true; + } + else + shieldobj->color = (UINT8)shieldobj->info->painchance; + shieldobj->threshold = (player->powers[pw_shield] & SH_FORCE) ? SH_FORCE : (player->powers[pw_shield] & SH_NOSTACK); if (shieldobj->info->seestate) { ov = P_SpawnMobj(shieldobj->x, shieldobj->y, shieldobj->z, MT_OVERLAY); P_SetTarget(&ov->target, shieldobj); P_SetMobjState(ov, shieldobj->info->seestate); + P_SetTarget(&shieldobj->tracer, ov); } if (shieldobj->info->meleestate) { @@ -1409,7 +1948,7 @@ void P_SpawnShieldOrb(player_t *player) if (player->powers[pw_shield] & SH_FORCE) { //Copy and pasted from P_ShieldLook in p_mobj.c - shieldobj->movecount = (player->powers[pw_shield] & 0xFF); + shieldobj->movecount = (player->powers[pw_shield] & SH_FORCEHP); if (shieldobj->movecount < 1) { if (shieldobj->info->painstate) @@ -1420,6 +1959,60 @@ void P_SpawnShieldOrb(player_t *player) } } +// +// P_SwitchShield +// +// Handles the possibility of switching between +// the non-stack layer of shields thoroughly, +// then adds the desired one. +// +void P_SwitchShield(player_t *player, UINT16 shieldtype) +{ + boolean donthavealready; + + // If you already have a bomb shield, use it! + if ((shieldtype == SH_ARMAGEDDON) && (player->powers[pw_shield] & SH_NOSTACK) == SH_ARMAGEDDON) + P_BlackOw(player); + + donthavealready = (shieldtype & SH_FORCE) + ? (!(player->powers[pw_shield] & SH_FORCE) || (player->powers[pw_shield] & SH_FORCEHP) < (shieldtype & ~SH_FORCE)) + : ((player->powers[pw_shield] & SH_NOSTACK) != shieldtype); + + if (donthavealready) + { + boolean stopshieldability = (shieldtype & SH_FORCE) + ? (!(player->powers[pw_shield] & SH_FORCE)) + : true; + + // Just in case. + if (stopshieldability && player->pflags & PF_SHIELDABILITY) + { + player->pflags &= ~(PF_SPINNING|PF_SHIELDABILITY); // They'll still have PF_THOKKED... + player->homing = 0; + } + + player->powers[pw_shield] = shieldtype|(player->powers[pw_shield] & SH_STACK); + P_SpawnShieldOrb(player); + + if (shieldtype & SH_PROTECTWATER) + { + if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) + { + player->powers[pw_underwater] = 0; + P_RestoreMusic(player); + } + else + player->powers[pw_underwater] = 0; + + if (player->powers[pw_spacetime] > 1) + { + player->powers[pw_spacetime] = 0; + P_RestoreMusic(player); + } + } + } +} + // // P_SpawnGhostMobj // @@ -1427,9 +2020,7 @@ void P_SpawnShieldOrb(player_t *player) // mobj_t *P_SpawnGhostMobj(mobj_t *mobj) { - mobj_t *ghost; - - ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); + mobj_t *ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); P_SetScale(ghost, mobj->scale); ghost->destscale = mobj->scale; @@ -1441,9 +2032,11 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) } ghost->color = mobj->color; + ghost->colorized = mobj->colorized; // alternatively, "true" for sonic advance style colourisation - ghost->angle = mobj->angle; + ghost->angle = (mobj->player ? mobj->player->drawangle : mobj->angle); ghost->sprite = mobj->sprite; + ghost->sprite2 = mobj->sprite2; ghost->frame = mobj->frame; ghost->tics = -1; ghost->frame &= ~FF_TRANSMASK; @@ -1454,6 +2047,14 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) if (mobj->flags2 & MF2_OBJECTFLIP) ghost->flags |= MF2_OBJECTFLIP; + if (mobj->player && mobj->player->followmobj) + { + mobj_t *ghost2 = P_SpawnGhostMobj(mobj->player->followmobj); + P_SetTarget(&ghost2->tracer, ghost); + P_SetTarget(&ghost->tracer, ghost2); + ghost2->flags2 |= (mobj->player->followmobj->flags2 & MF2_LINKDRAW); + } + return ghost; } @@ -1474,6 +2075,9 @@ void P_SpawnThokMobj(player_t *player) if (player->spectator) return; + if (!type) + return; + if (type == MT_GHOST) mobj = P_SpawnGhostMobj(player->mo); // virtually does everything here for us else @@ -1491,7 +2095,7 @@ void P_SpawnThokMobj(player_t *player) mobj = P_SpawnMobj(player->mo->x, player->mo->y, zheight, type); // set to player's angle, just in case - mobj->angle = player->mo->angle; + mobj->angle = player->drawangle; // color and skin mobj->color = player->mo->color; @@ -1503,13 +2107,17 @@ void P_SpawnThokMobj(player_t *player) mobj->eflags |= (player->mo->eflags & MFE_VERTICALFLIP); // scale - P_SetScale(mobj, player->mo->scale); - mobj->destscale = player->mo->scale; + P_SetScale(mobj, (mobj->destscale = player->mo->scale)); + + if (type == MT_THOK) // spintrail-specific modification for MT_THOK + { + mobj->frame = FF_TRANS70; + mobj->fuse = mobj->tics; + } } P_SetTarget(&mobj->target, player->mo); // the one thing P_SpawnGhostMobj doesn't do - if (demorecording) - G_GhostAddThok(); + G_GhostAddThok(); } // @@ -1528,6 +2136,9 @@ void P_SpawnSpinMobj(player_t *player, mobjtype_t type) if (player->spectator) return; + if (!type) + return; + if (type == MT_GHOST) mobj = P_SpawnGhostMobj(player->mo); // virtually does everything here for us else @@ -1545,7 +2156,7 @@ void P_SpawnSpinMobj(player_t *player, mobjtype_t type) mobj = P_SpawnMobj(player->mo->x, player->mo->y, zheight, type); // set to player's angle, just in case - mobj->angle = player->mo->angle; + mobj->angle = player->drawangle; // color and skin mobj->color = player->mo->color; @@ -1559,11 +2170,46 @@ void P_SpawnSpinMobj(player_t *player, mobjtype_t type) // scale P_SetScale(mobj, player->mo->scale); mobj->destscale = player->mo->scale; + + if (type == MT_THOK) // spintrail-specific modification for MT_THOK + { + mobj->frame = FF_TRANS70; + mobj->fuse = mobj->tics; + } } P_SetTarget(&mobj->target, player->mo); // the one thing P_SpawnGhostMobj doesn't do } +/** Called when \p player finishes the level. + * + * Only use for cases where the player should be able to move + * while waiting for others to finish. Otherwise, use P_DoPlayerExit(). + * + * In single player or if ::cv_exitmove is disabled, this will also cause + * P_PlayerThink() to call P_DoPlayerExit(), so you do not need to + * make a special cases for those. + * + * \param player The player who finished the level. + * \sa P_DoPlayerExit + * + */ +void P_DoPlayerFinish(player_t *player) +{ + if (player->pflags & PF_FINISHED) + return; + + player->pflags |= PF_FINISHED; + P_GiveFinishFlags(player); + + if (netgame) + CONS_Printf(M_GetText("%s has completed the level.\n"), player_names[player-players]); + + player->powers[pw_underwater] = 0; + player->powers[pw_spacetime] = 0; + P_RestoreMusic(player); +} + // // P_DoPlayerExit // @@ -1575,10 +2221,10 @@ void P_DoPlayerExit(player_t *player) if (cv_allowexitlevel.value == 0 && !G_PlatformGametype()) return; - else if (gametype == GT_RACE || gametype == GT_COMPETITION) // If in Race Mode, allow + else if (gametyperules & GTR_RACE) // If in Race Mode, allow { if (!countdown) // a 60-second wait ala Sonic 2. - countdown = cv_countdowntime.value*TICRATE + 1; // Use cv_countdowntime + countdown = (cv_countdowntime.value - 1)*TICRATE + 1; // Use cv_countdowntime player->exiting = 3*TICRATE; @@ -1595,15 +2241,17 @@ void P_DoPlayerExit(player_t *player) if (player->climbing) { player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); + } + else if (player->pflags & PF_STARTDASH) + { + player->pflags &= ~PF_STARTDASH; + P_SetPlayerMobjState(player->mo, S_PLAY_STND); } player->powers[pw_underwater] = 0; player->powers[pw_spacetime] = 0; P_RestoreMusic(player); - - if (playeringame[player-players] && netgame && !circuitmap) - CONS_Printf(M_GetText("%s has completed the level.\n"), player_names[player-players]); } #define SPACESPECIAL 12 @@ -1647,6 +2295,209 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space return false; // No vacuum here, Captain! } +// +// P_PlayerHitFloor +// +// Handles player hitting floor surface. +// Returns whether to clip momz. +boolean P_PlayerHitFloor(player_t *player, boolean dorollstuff) +{ + boolean clipmomz; + + I_Assert(player->mo != NULL); + + if (player->powers[pw_carry] == CR_NIGHTSMODE) + return true; + + if ((clipmomz = !(P_CheckDeathPitCollide(player->mo))) && player->mo->health && !player->spectator) + { + if (dorollstuff) + { + if ((player->charability2 == CA2_SPINDASH) && !((player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_THOKKED) && (player->cmd.buttons & BT_USE) && (FixedHypot(player->mo->momx, player->mo->momy) > (5*player->mo->scale))) + player->pflags = (player->pflags|PF_SPINNING) & ~PF_THOKKED; + else if (!(player->pflags & PF_STARTDASH)) + player->pflags &= ~PF_SPINNING; + } + + if (player->pflags & PF_BOUNCING) + { + if (dorollstuff && player->mo->state-states != S_PLAY_BOUNCE_LANDING) + { + P_MobjCheckWater(player->mo); + player->mo->momz *= -1; + P_DoAbilityBounce(player, true); + if (player->scoreadd) + player->scoreadd--; + } + clipmomz = false; + } + else + { + if (player->pflags & PF_SPINNING) + { + if (player->mo->state-states != S_PLAY_ROLL && !(player->pflags & PF_STARTDASH)) + { + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + S_StartSound(player->mo, sfx_spin); + } + } + else if (player->pflags & PF_GLIDING) // ground gliding + { + if (dorollstuff) + { + player->skidtime = TICRATE; + player->mo->tics = -1; + } + else if (!player->skidtime) + player->pflags &= ~PF_GLIDING; + } + else if (player->charability == CA_GLIDEANDCLIMB && player->pflags & PF_THOKKED && !(player->pflags & (PF_JUMPED|PF_SHIELDABILITY)) && player->mo->state-states == S_PLAY_FALL) + { + if (player->mo->state-states != S_PLAY_GLIDE_LANDING) + { + P_ResetPlayer(player); + P_SetPlayerMobjState(player->mo, S_PLAY_GLIDE_LANDING); + S_StartSound(player->mo, sfx_s3k4c); + player->pflags |= PF_STASIS; + player->mo->momx = ((player->mo->momx - player->cmomx)/3) + player->cmomx; + player->mo->momy = ((player->mo->momy - player->cmomy)/3) + player->cmomy; + } + } + else if (player->charability2 == CA2_MELEE + && ((player->panim == PA_ABILITY2) || (player->charability == CA_TWINSPIN && player->panim == PA_ABILITY && player->cmd.buttons & (BT_JUMP|BT_USE)))) + { + if (player->mo->state-states != S_PLAY_MELEE_LANDING) + { + mobjtype_t type = player->revitem; + P_SetPlayerMobjState(player->mo, S_PLAY_MELEE_LANDING); + player->mo->tics = (player->mo->movefactor == FRACUNIT) ? TICRATE/2 : (FixedDiv(35<<(FRACBITS-1), FixedSqrt(player->mo->movefactor)))>>FRACBITS; + S_StartSound(player->mo, sfx_s3k8b); + player->pflags |= PF_FULLSTASIS; + + // hearticles + if (type) + { + UINT8 i = 0; + angle_t throwang = -(2*ANG30); + fixed_t xo = P_ReturnThrustX(player->mo, player->drawangle, 16*player->mo->scale); + fixed_t yo = P_ReturnThrustY(player->mo, player->drawangle, 16*player->mo->scale); + fixed_t zo = 6*player->mo->scale; + fixed_t mu = FixedMul(player->maxdash, player->mo->scale); + fixed_t mu2 = FixedHypot(player->mo->momx, player->mo->momy); + fixed_t ev; + mobj_t *missile = NULL; + if (mu2 < mu) + mu2 = mu; + ev = (50*FRACUNIT - (mu/25))/50; + while (i < 5) + { + missile = P_SpawnMobjFromMobj(player->mo, xo, yo, zo, type); + P_SetTarget(&missile->target, player->mo); + missile->angle = throwang + player->drawangle; + P_Thrust(missile, player->drawangle + ANGLE_90, + P_ReturnThrustY(missile, throwang, mu)); // side to side component + P_Thrust(missile, player->drawangle, mu2); // forward component + P_SetObjectMomZ(missile, (4 + ((i&1)<<1))*FRACUNIT, true); + missile->momz += player->mo->pmomz; + missile->fuse = TICRATE/2; + missile->extravalue2 = ev; + + i++; + throwang += ANG30; + } + if (mobjinfo[type].seesound && missile) + S_StartSound(missile, missile->info->seesound); + } + } + } + else if (player->charability == CA_GLIDEANDCLIMB && (player->mo->state-states == S_PLAY_GLIDE_LANDING)) + ; + else if (player->charability2 == CA2_GUNSLINGER && player->panim == PA_ABILITY2) + ; + else if (player->panim != PA_IDLE && player->panim != PA_WALK && player->panim != PA_RUN && player->panim != PA_DASH) + { + fixed_t runspd = FixedMul(player->runspeed, player->mo->scale); + + // See comments in P_MovePlayer for explanation of changes. + + if (player->powers[pw_super]) + runspd = FixedMul(runspd, 5*FRACUNIT/3); + + runspd = FixedMul(runspd, player->mo->movefactor); + + if (maptol & TOL_2D) + runspd = FixedMul(runspd, 2*FRACUNIT/3); + + if (player->cmomx || player->cmomy) + { + if (player->charflags & SF_DASHMODE && player->dashmode >= DASHMODE_THRESHOLD && player->panim != PA_DASH) + P_SetPlayerMobjState(player->mo, S_PLAY_DASH); + else if (player->speed >= runspd + && (player->panim != PA_RUN || player->mo->state-states == S_PLAY_FLOAT_RUN)) + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + else if ((player->rmomx || player->rmomy) + && (player->panim != PA_WALK || player->mo->state-states == S_PLAY_FLOAT)) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else if (!player->rmomx && !player->rmomy && player->panim != PA_IDLE) + P_SetPlayerMobjState(player->mo, S_PLAY_STND); + } + else + { + if (player->charflags & SF_DASHMODE && player->dashmode >= DASHMODE_THRESHOLD && player->panim != PA_DASH) + P_SetPlayerMobjState(player->mo, S_PLAY_DASH); + else if (player->speed >= runspd + && (player->panim != PA_RUN || player->mo->state-states == S_PLAY_FLOAT_RUN)) + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + else if ((player->mo->momx || player->mo->momy) + && (player->panim != PA_WALK || player->mo->state-states == S_PLAY_FLOAT)) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else if (!player->mo->momx && !player->mo->momy && player->panim != PA_IDLE) + P_SetPlayerMobjState(player->mo, S_PLAY_STND); + } + } + + if (!(player->pflags & PF_GLIDING)) + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE); + player->pflags &= ~(PF_STARTJUMP|PF_THOKKED|PF_CANCARRY/*|PF_GLIDING*/); + player->secondjump = 0; + player->glidetime = 0; + player->climbing = 0; + player->powers[pw_tailsfly] = 0; + + if (player->pflags & PF_SHIELDABILITY) + { + player->pflags &= ~PF_SHIELDABILITY; + + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL) // Elemental shield's stomp attack. + { + if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) // play a blunt sound + S_StartSound(player->mo, sfx_s3k4c); + else // create a fire pattern on the ground + { + S_StartSound(player->mo, sfx_s3k47); + P_ElementalFire(player, true); + } + P_SetObjectMomZ(player->mo, + (player->mo->eflags & MFE_UNDERWATER) + ? 6*FRACUNIT/5 + : 5*FRACUNIT/2, + false); + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + player->mo->momx = player->mo->momy = 0; + clipmomz = false; + } + else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP) // Bubble shield's bounce attack. + { + P_DoBubbleBounce(player); + clipmomz = false; + } + } + } + } + + return clipmomz; +} + boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand { sector_t *sector = mo->subsector->sector; @@ -1699,10 +2550,13 @@ static void P_CheckBustableBlocks(player_t *player) oldx = player->mo->x; oldy = player->mo->y; - P_UnsetThingPosition(player->mo); - player->mo->x += player->mo->momx; - player->mo->y += player->mo->momy; - P_SetThingPosition(player->mo); + if (!(player->pflags & PF_BOUNCING)) // Bouncers only get to break downwards, not sideways + { + P_UnsetThingPosition(player->mo); + player->mo->x += player->mo->momx; + player->mo->y += player->mo->momy; + P_SetThingPosition(player->mo); + } for (node = player->mo->touching_sectorlist; node; node = node->m_sectorlist_next) { @@ -1720,27 +2574,52 @@ static void P_CheckBustableBlocks(player_t *player) if ((rover->flags & FF_BUSTUP)/* && !rover->master->frontsector->crumblestate*/) { - // If it's an FF_SPINBUST, you have to either be jumping, or coming down - // onto the top from a spin. - if (rover->flags & FF_SPINBUST && ((!(player->pflags & PF_JUMPED) && !(player->pflags & PF_SPINNING)) || (player->pflags & PF_STARTDASH))) + // If it's an FF_SHATTER, you can break it just by touching it. + if (rover->flags & FF_SHATTER) + goto bust; + + // If it's an FF_SPINBUST, you can break it if you are in your spinning frames + // (either from jumping or spindashing). + if (rover->flags & FF_SPINBUST + && (((player->pflags & PF_SPINNING) && !(player->pflags & PF_STARTDASH)) + || (player->pflags & PF_JUMPED && !(player->pflags & PF_NOJUMPDAMAGE)))) + goto bust; + + // You can always break it if you have CA_GLIDEANDCLIMB + // or if you are bouncing on it + // or you are using CA_TWINSPIN/CA2_MELEE. + if (player->charability == CA_GLIDEANDCLIMB + || (player->pflags & PF_BOUNCING) + || ((player->charability == CA_TWINSPIN) && (player->panim == PA_ABILITY)) + || (player->charability2 == CA2_MELEE && player->panim == PA_ABILITY2)) + goto bust; + + if (rover->flags & FF_STRONGBUST) continue; - // if it's not an FF_SHATTER, you must be spinning (and not jumping) - // or have Knuckles's abilities (or Super Sonic) - // ...or are drilling in NiGHTS (or Metal Sonic) - if (!(rover->flags & FF_SHATTER) && !(rover->flags & FF_SPINBUST) - && !((player->pflags & PF_SPINNING) && !(player->pflags & PF_JUMPED)) - && (player->charability != CA_GLIDEANDCLIMB && !player->powers[pw_super]) - && !(player->pflags & PF_DRILLING) && !metalrecording) - continue; - - // Only Knuckles can break this rock... - if (!(rover->flags & FF_SHATTER) && (rover->flags & FF_ONLYKNUX) && !(player->charability == CA_GLIDEANDCLIMB)) + // If it's not an FF_STRONGBUST, you can break if you are spinning (and not jumping) + // or you are super + // or you are in dashmode with SF_DASHMODE + // or you are drilling in NiGHTS + // or you are recording for Metal Sonic + if (!((player->pflags & PF_SPINNING) && !(player->pflags & PF_JUMPED)) + && !(player->powers[pw_super]) + && !(((player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) && (player->dashmode >= DASHMODE_THRESHOLD)) + && !(player->pflags & PF_DRILLING) + && !metalrecording) continue; + bust: topheight = P_GetFOFTopZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); bottomheight = P_GetFOFBottomZ(player->mo, node->m_sector, rover, player->mo->x, player->mo->y, NULL); + if (((player->charability == CA_TWINSPIN) && (player->panim == PA_ABILITY)) + || ((P_MobjFlip(player->mo)*player->mo->momz < 0) && (player->pflags & PF_BOUNCING || ((player->charability2 == CA2_MELEE) && (player->panim == PA_ABILITY2))))) + { + topheight -= player->mo->momz; + bottomheight -= player->mo->momz; + } + // Height checks if (rover->flags & FF_SHATTERBOTTOM) { @@ -1787,7 +2666,7 @@ static void P_CheckBustableBlocks(player_t *player) //if (metalrecording) // G_RecordBustup(rover); - EV_CrumbleChain(node->m_sector, rover); + EV_CrumbleChain(NULL, rover); // node->m_sector // Run a linedef executor?? if (rover->master->flags & ML_EFFECT5) @@ -1799,10 +2678,13 @@ static void P_CheckBustableBlocks(player_t *player) } } bustupdone: - P_UnsetThingPosition(player->mo); - player->mo->x = oldx; - player->mo->y = oldy; - P_SetThingPosition(player->mo); + if (!(player->pflags & PF_BOUNCING)) + { + P_UnsetThingPosition(player->mo); + player->mo->x = oldx; + player->mo->y = oldy; + P_SetThingPosition(player->mo); + } } static void P_CheckBouncySectors(player_t *player) @@ -1925,7 +2807,7 @@ static void P_CheckBouncySectors(player_t *player) if (player->pflags & PF_SPINNING) { player->pflags &= ~PF_SPINNING; - player->pflags |= PF_JUMPED; + player->pflags |= P_GetJumpFlags(player); player->pflags |= PF_THOKKED; } } @@ -1937,7 +2819,7 @@ static void P_CheckBouncySectors(player_t *player) if (player->pflags & PF_SPINNING) { player->pflags &= ~PF_SPINNING; - player->pflags |= PF_JUMPED; + player->pflags |= P_GetJumpFlags(player); player->pflags |= PF_THOKKED; } } @@ -1945,7 +2827,7 @@ static void P_CheckBouncySectors(player_t *player) if ((player->pflags & PF_SPINNING) && player->speed < FixedMul(1<mo->scale) && player->mo->momz) { player->pflags &= ~PF_SPINNING; - player->pflags |= PF_JUMPED; + player->pflags |= P_GetJumpFlags(player); } goto bouncydone; @@ -1999,6 +2881,9 @@ static void P_CheckQuicksand(player_t *player) if (player->mo->z + player->mo->height >= ceilingheight) player->mo->z = ceilingheight - player->mo->height; + + if (player->mo->momz <= 0) + P_PlayerHitFloor(player, false); } else { @@ -2008,6 +2893,9 @@ static void P_CheckQuicksand(player_t *player) if (player->mo->z <= floorheight) player->mo->z = floorheight; + + if (player->mo->momz >= 0) + P_PlayerHitFloor(player, false); } friction = abs(rover->master->v1->y - rover->master->v2->y)>>6; @@ -2025,10 +2913,6 @@ static void P_CheckQuicksand(player_t *player) // static void P_CheckSneakerAndLivesTimer(player_t *player) { - if ((player->powers[pw_underwater] <= 11*TICRATE + 1) - && (player->powers[pw_underwater] > 1)) - return; // don't restore music if drowning music is playing - if (player->powers[pw_extralife] == 1) // Extra Life! P_RestoreMusic(player); @@ -2043,111 +2927,83 @@ static void P_CheckSneakerAndLivesTimer(player_t *player) // static void P_CheckUnderwaterAndSpaceTimer(player_t *player) { - fixed_t height; - mobj_t *numbermobj = NULL; + tic_t timeleft = (player->powers[pw_spacetime]) ? player->powers[pw_spacetime] : player->powers[pw_underwater]; - if (player->mo->eflags & MFE_VERTICALFLIP) - height = player->mo->z - FixedMul(8*FRACUNIT - mobjinfo[MT_DROWNNUMBERS].height, player->mo->scale); - else - height = player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, player->mo->scale); + if (player->exiting || (player->pflags & PF_FINISHED)) + player->powers[pw_underwater] = player->powers[pw_spacetime] = 0; - if (player->powers[pw_underwater] == 11*TICRATE + 1 || player->powers[pw_spacetime] == 11*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+5); - } - else if (player->powers[pw_underwater] == 9*TICRATE + 1 || player->powers[pw_spacetime] == 9*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+4); - } - else if (player->powers[pw_underwater] == 7*TICRATE + 1 || player->powers[pw_spacetime] == 7*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+3); - } - else if (player->powers[pw_underwater] == 5*TICRATE + 1 || player->powers[pw_spacetime] == 5*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+2); - } - else if (player->powers[pw_underwater] == 3*TICRATE + 1 || player->powers[pw_spacetime] == 3*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_SetMobjState(numbermobj, numbermobj->info->spawnstate+1); - } - else if (player->powers[pw_underwater] == 1*TICRATE + 1 || player->powers[pw_spacetime] == 1*TICRATE + 1) - { - numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - //P_SetMobjState(numbermobj, numbermobj->info->spawnstate+0); - } - // Underwater timer runs out - else if (player->powers[pw_underwater] == 1) - { - mobj_t *killer; + timeleft--; // The original code was all n*TICRATE + 1, so let's remove 1 tic for simplicity - if ((netgame || multiplayer) && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); + if ((timeleft == 11*TICRATE) // 5 + || (timeleft == 9*TICRATE) // 4 + || (timeleft == 7*TICRATE) // 3 + || (timeleft == 5*TICRATE) // 2 + || (timeleft == 3*TICRATE) // 1 + || (timeleft == 1*TICRATE) // 0 + ) { + fixed_t height = (player->mo->eflags & MFE_VERTICALFLIP) + ? player->mo->z - FixedMul(8*FRACUNIT + mobjinfo[MT_DROWNNUMBERS].height, FixedMul(player->mo->scale, player->shieldscale)) + : player->mo->z + player->mo->height + FixedMul(8*FRACUNIT, FixedMul(player->mo->scale, player->shieldscale)); - killer = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NULL); - killer->threshold = 42; // Special flag that it was drowning which killed you. - P_DamageMobj(player->mo, killer, killer, 10000); - } - else if (player->powers[pw_spacetime] == 1) - { - if ((netgame || multiplayer) && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); + mobj_t *numbermobj = P_SpawnMobj(player->mo->x, player->mo->y, height, MT_DROWNNUMBERS); - P_DamageMobj(player->mo, NULL, NULL, 10000); - } + timeleft /= (2*TICRATE); // To be strictly accurate it'd need to be ((timeleft/TICRATE) - 1)/2, but integer division rounds down for us + + if (player->charflags & SF_MACHINE) + { + S_StartSound(player->mo, sfx_buzz1); + timeleft += 6; + } + else + S_StartSound(player->mo, sfx_dwnind); + + if (timeleft) // Don't waste time setting the state if the time is 0. + P_SetMobjState(numbermobj, numbermobj->info->spawnstate+timeleft); - if (numbermobj) - { P_SetTarget(&numbermobj->target, player->mo); numbermobj->threshold = 40; - S_StartSound(player->mo, sfx_dwnind); numbermobj->destscale = player->mo->scale; P_SetScale(numbermobj, player->mo->scale); } + // Underwater timer runs out + else if (timeleft == 1) + { + if ((netgame || multiplayer) && P_IsLocalPlayer(player)) + S_ChangeMusic(mapmusname, mapmusflags, true); + + if (player->powers[pw_spacetime] == 1) + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPACEDROWN); + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_DROWNED); + } if (!(player->mo->eflags & MFE_UNDERWATER) && player->powers[pw_underwater]) { if (player->powers[pw_underwater] <= 12*TICRATE + 1) + { + player->powers[pw_underwater] = 0; P_RestoreMusic(player); - - player->powers[pw_underwater] = 0; + } + else + player->powers[pw_underwater] = 0; } if (player->powers[pw_spacetime] > 1 && !P_InSpaceSector(player->mo)) - { - P_RestoreMusic(player); player->powers[pw_spacetime] = 0; - } // Underwater audio cues if (P_IsLocalPlayer(player) && !player->bot) { + if ((player->powers[pw_underwater] == 25*TICRATE + 1) + || (player->powers[pw_underwater] == 20*TICRATE + 1) + || (player->powers[pw_underwater] == 15*TICRATE + 1)) + S_StartSound(NULL, sfx_wtrdng); + if (player->powers[pw_underwater] == 11*TICRATE + 1 && player == &players[consoleplayer]) { - S_StopMusic(); - S_ChangeMusicInternal("drown", false); + P_PlayJingle(player, JT_DROWN); } - - if (player->powers[pw_underwater] == 25*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - else if (player->powers[pw_underwater] == 20*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - else if (player->powers[pw_underwater] == 15*TICRATE + 1) - S_StartSound(NULL, sfx_wtrdng); - } - - if (player->exiting) - { - if (player->powers[pw_underwater] > 1) - player->powers[pw_underwater] = 0; - - player->powers[pw_spacetime] = 0; } } @@ -2162,7 +3018,7 @@ static void P_CheckInvincibilityTimer(player_t *player) return; if (mariomode && !player->powers[pw_super]) - player->mo->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + player->mo->color = (UINT8)(SKINCOLOR_RUBY + (leveltime % (MAXSKINCOLORS - SKINCOLOR_RUBY))); // Passes through all saturated colours else if (leveltime % (TICRATE/7) == 0) { mobj_t *sparkle = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_IVSP); @@ -2177,7 +3033,7 @@ static void P_CheckInvincibilityTimer(player_t *player) { if (mariomode) { - if (player->powers[pw_shield] & SH_FIREFLOWER) + if ((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) { player->mo->color = SKINCOLOR_WHITE; G_GhostAddColor(GHC_FIREFLOWER); @@ -2193,10 +3049,6 @@ static void P_CheckInvincibilityTimer(player_t *player) P_SpawnShieldOrb(player); } - if ((player->powers[pw_underwater] <= 11*TICRATE + 1) - && (player->powers[pw_underwater] > 1)) - return; // don't restore music if drowning music is playing - if (!player->powers[pw_super] || (mapheaderinfo[gamemap-1]->levelflags & LF_NOSSMUSIC)) P_RestoreMusic(player); } @@ -2209,21 +3061,39 @@ static void P_CheckInvincibilityTimer(player_t *player) // static void P_DoBubbleBreath(player_t *player) { - fixed_t zh; + fixed_t x = player->mo->x; + fixed_t y = player->mo->y; + fixed_t z = player->mo->z; mobj_t *bubble = NULL; - if (player->mo->eflags & MFE_VERTICALFLIP) - zh = player->mo->z + player->mo->height - FixedDiv(player->mo->height,5*(FRACUNIT/4)); - else - zh = player->mo->z + FixedDiv(player->mo->height,5*(FRACUNIT/4)); - - if (!(player->mo->eflags & MFE_UNDERWATER) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !(player->pflags & PF_NIGHTSMODE)) || player->spectator) + if (!(player->mo->eflags & MFE_UNDERWATER) || ((player->powers[pw_shield] & SH_PROTECTWATER) && !(player->powers[pw_carry] == CR_NIGHTSMODE)) || player->spectator) return; - if (P_RandomChance(FRACUNIT/16)) - bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_SMALLBUBBLE); - else if (P_RandomChance(3*FRACUNIT/256)) - bubble = P_SpawnMobj(player->mo->x, player->mo->y, zh, MT_MEDIUMBUBBLE); + if (player->charflags & SF_MACHINE) + { + if (player->powers[pw_underwater] && P_RandomChance((128-(player->powers[pw_underwater]/4))*FRACUNIT/256)) + { + fixed_t r = player->mo->radius>>FRACBITS; + x += (P_RandomRange(r, -r)<mo->height>>FRACBITS)<mo->eflags & MFE_VERTICALFLIP) + z += player->mo->height - FixedDiv(player->mo->height,5*(FRACUNIT/4)); + else + z += FixedDiv(player->mo->height,5*(FRACUNIT/4)); + + if (P_RandomChance(FRACUNIT/16)) + bubble = P_SpawnMobj(x, y, z, MT_SMALLBUBBLE); + else if (P_RandomChance(3*FRACUNIT/256)) + bubble = P_SpawnMobj(x, y, z, MT_MEDIUMBUBBLE); + } + if (bubble) { bubble->threshold = 42; @@ -2231,22 +3101,19 @@ static void P_DoBubbleBreath(player_t *player) P_SetScale(bubble, bubble->destscale); } - if (player->pflags & PF_NIGHTSMODE) // NiGHTS Super doesn't spawn flight bubbles - return; - // Tails stirs up the water while flying in it if (player->powers[pw_tailsfly] && (leveltime & 1) && player->charability != CA_SWIM) { - fixed_t radius = (3*player->mo->radius)>>1; + fixed_t radius = player->mo->radius; angle_t fa = ((leveltime%45)*FINEANGLES/8) & FINEMASK; fixed_t stirwaterx = FixedMul(FINECOSINE(fa),radius); fixed_t stirwatery = FixedMul(FINESINE(fa),radius); fixed_t stirwaterz; if (player->mo->eflags & MFE_VERTICALFLIP) - stirwaterz = player->mo->z + player->mo->height - FixedDiv(player->mo->height,3*FRACUNIT/2); + stirwaterz = player->mo->z + player->mo->height - (4<mo->z + FixedDiv(player->mo->height,3*FRACUNIT/2); + stirwaterz = player->mo->z + (4<mo->x + stirwaterx, @@ -2276,7 +3143,7 @@ static void P_DoPlayerHeadSigns(player_t *player) // If you're "IT", show a big "IT" over your head for others to see. if (player->pflags & PF_TAGIT) { - if (!(player == &players[consoleplayer] || player == &players[secondarydisplayplayer] || player == &players[displayplayer])) // Don't display it on your own view. + if (!P_IsLocalPlayer(player)) // Don't display it on your own view. { if (!(player->mo->eflags & MFE_VERTICALFLIP)) P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height, MT_TAG); @@ -2285,33 +3152,26 @@ static void P_DoPlayerHeadSigns(player_t *player) } } } - else if (gametype == GT_CTF) + else if ((gametyperules & GTR_TEAMFLAGS) && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) // If you have the flag (duh). { - if (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG)) // If you have the flag (duh). + // Spawn a got-flag message over the head of the player that + // has it (but not on your own screen if you have the flag). + if (splitscreen || player != &players[consoleplayer]) { - // Spawn a got-flag message over the head of the player that - // has it (but not on your own screen if you have the flag). - if (splitscreen || player != &players[consoleplayer]) + mobj_t *sign = P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, + player->mo->z+player->mo->momz, MT_GOTFLAG); + if (player->mo->eflags & MFE_VERTICALFLIP) { - if (player->gotflag & GF_REDFLAG) - { - if (!(player->mo->eflags & MFE_VERTICALFLIP)) - P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, - player->mo->z+P_GetPlayerHeight(player)+FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG); - else - P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, - player->mo->z+player->mo->height-P_GetPlayerHeight(player)-mobjinfo[MT_GOTFLAG].height-FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG)->eflags |= MFE_VERTICALFLIP; - } - if (player->gotflag & GF_BLUEFLAG) - { - if (!(player->mo->eflags & MFE_VERTICALFLIP)) - P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, - player->mo->z+P_GetPlayerHeight(player)+FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG2); - else - P_SpawnMobj(player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, - player->mo->z+player->mo->height-P_GetPlayerHeight(player)-mobjinfo[MT_GOTFLAG2].height-FixedMul(16*FRACUNIT, player->mo->scale)+player->mo->momz, MT_GOTFLAG2)->eflags |= MFE_VERTICALFLIP; - } + sign->z += player->mo->height-P_GetPlayerHeight(player)-mobjinfo[MT_GOTFLAG].height-FixedMul(16*FRACUNIT, player->mo->scale); + sign->eflags |= MFE_VERTICALFLIP; } + else + sign->z += P_GetPlayerHeight(player)+FixedMul(16*FRACUNIT, player->mo->scale); + + if (player->gotflag & GF_REDFLAG) + sign->frame = 1|FF_FULLBRIGHT; + else //if (player->gotflag & GF_BLUEFLAG) + sign->frame = 2|FF_FULLBRIGHT; } } } @@ -2332,9 +3192,8 @@ static void P_DoClimbing(player_t *player) platx = P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); platy = P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius + FixedMul(8*FRACUNIT, player->mo->scale)); - glidesector = R_IsPointInSubsector(player->mo->x + platx, player->mo->y + platy); + glidesector = R_PointInSubsectorOrNull(player->mo->x + platx, player->mo->y + platy); - if (!glidesector || glidesector->sector != player->mo->subsector->sector) { boolean floorclimb = false; boolean thrust = false; @@ -2654,7 +3513,7 @@ static void P_DoClimbing(player_t *player) angle_t sideangle; fixed_t dx, dy; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MAIN].next; think != &thlist[THINK_MAIN]; think = think->next) { if (think->function.acp1 != (actionf_p1)T_Scroll) continue; @@ -2710,36 +3569,34 @@ static void P_DoClimbing(player_t *player) climb = false; if (player->climbing && climb && (player->mo->momx || player->mo->momy || player->mo->momz) - && !(player->mo->state >= &states[S_PLAY_CLIMB2] && player->mo->state <= &states[S_PLAY_CLIMB5])) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB2); - else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state != &states[S_PLAY_CLIMB1]) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB1); + && player->mo->state-states != S_PLAY_CLIMB) + P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB); + else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state-states != S_PLAY_CLING) + P_SetPlayerMobjState(player->mo, S_PLAY_CLING); if (!floorclimb) { if (boostup) + { P_SetObjectMomZ(player->mo, 2*FRACUNIT, true); + if (cmd->forwardmove) + player->mo->momz = 2*player->mo->momz/3; + } if (thrust) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(4*FRACUNIT, player->mo->scale)); // Lil' boost up. + P_Thrust(player->mo, player->mo->angle, FixedMul(4*FRACUNIT, player->mo->scale)); // Lil' boost up. player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); } if (skyclimber) { player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); } } - else - { - player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } if (cmd->sidemove != 0 || cmd->forwardmove != 0) climb = true; @@ -2747,30 +3604,43 @@ static void P_DoClimbing(player_t *player) climb = false; if (player->climbing && climb && (player->mo->momx || player->mo->momy || player->mo->momz) - && !(player->mo->state >= &states[S_PLAY_CLIMB2] && player->mo->state <= &states[S_PLAY_CLIMB5])) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB2); - else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state != &states[S_PLAY_CLIMB1]) - P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB1); + && player->mo->state-states != S_PLAY_CLIMB) + P_SetPlayerMobjState(player->mo, S_PLAY_CLIMB); + else if ((!(player->mo->momx || player->mo->momy || player->mo->momz) || !climb) && player->mo->state-states != S_PLAY_CLING) + P_SetPlayerMobjState(player->mo, S_PLAY_CLING); if (cmd->buttons & BT_USE && !(player->pflags & PF_JUMPSTASIS)) { player->climbing = 0; - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); P_SetObjectMomZ(player->mo, 4*FRACUNIT, false); - P_InstaThrust(player->mo, player->mo->angle, FixedMul(-4*FRACUNIT, player->mo->scale)); + P_Thrust(player->mo, player->mo->angle, FixedMul(-4*FRACUNIT, player->mo->scale)); } - if (!demoplayback || P_AnalogMove(player)) +#define CLIMBCONEMAX FixedAngle(90*FRACUNIT) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) - localangle = player->mo->angle; + { + angle_t angdiff = localangle - player->mo->angle; + if (angdiff < ANGLE_180 && angdiff > CLIMBCONEMAX) + localangle = player->mo->angle + CLIMBCONEMAX; + else if (angdiff > ANGLE_180 && angdiff < InvAngle(CLIMBCONEMAX)) + localangle = player->mo->angle - CLIMBCONEMAX; + } else if (player == &players[secondarydisplayplayer]) - localangle2 = player->mo->angle; + { + angle_t angdiff = localangle2 - player->mo->angle; + if (angdiff < ANGLE_180 && angdiff > CLIMBCONEMAX) + localangle2 = player->mo->angle + CLIMBCONEMAX; + else if (angdiff > ANGLE_180 && angdiff < InvAngle(CLIMBCONEMAX)) + localangle2 = player->mo->angle - CLIMBCONEMAX; + } } if (player->climbing == 0) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); if (player->climbing && P_IsObjectOnGround(player->mo)) { @@ -2961,7 +3831,7 @@ static void P_DoTeeter(player_t *player) bottomheight = *rover->bottomheight; #endif - if (P_CheckSolidLava(player->mo, rover)) + if (P_CheckSolidLava(rover)) ; else if (!(rover->flags & FF_BLOCKPLAYER || rover->flags & FF_QUICKSAND)) continue; // intangible 3d floor @@ -3129,7 +3999,8 @@ static void P_DoTeeter(player_t *player) if (teeter) // only bother with objects as a last resort if you were already teetering { mobj_t *oldtmthing = tmthing; - tmthing = teeterer = player->mo; + teeterer = player->mo; + P_SetTarget(&tmthing, teeterer); teeterxl = teeterxh = player->mo->x; teeteryl = teeteryh = player->mo->y; couldteeter = false; @@ -3143,15 +4014,15 @@ static void P_DoTeeter(player_t *player) } teeterdone: teeter = solidteeter; - tmthing = oldtmthing; // restore old tmthing, goodness knows what the game does with this before mobj thinkers + P_SetTarget(&tmthing, oldtmthing); // restore old tmthing, goodness knows what the game does with this before mobj thinkers } } if (teeter) { - if ((player->mo->state == &states[S_PLAY_STND] || player->mo->state == &states[S_PLAY_TAP1] || player->mo->state == &states[S_PLAY_TAP2] || player->mo->state == &states[S_PLAY_SUPERSTAND])) - P_SetPlayerMobjState(player->mo, S_PLAY_TEETER1); + if (player->panim == PA_IDLE) + P_SetPlayerMobjState(player->mo, S_PLAY_EDGE); } - else if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER])) + else if (player->panim == PA_EDGE) P_SetPlayerMobjState(player->mo, S_PLAY_STND); } @@ -3173,6 +4044,33 @@ static void P_SetWeaponDelay(player_t *player, INT32 delay) } } +// +// P_DrainWeaponAmmo +// +// Reduces rings and weapon ammo. Also penalizes the player +// for using weapon rings with no normal rings! >:V +// +static void P_DrainWeaponAmmo (player_t *player, INT32 power) +{ + player->powers[power]--; + + if (player->rings < 1) + { + player->ammoremovalweapon = player->currentweapon; + player->ammoremovaltimer = ammoremovaltics; + + if (player->powers[power] > 0) // can't take a ring that doesn't exist + { + player->powers[power]--; + player->ammoremoval = 2; + } + else + player->ammoremoval = 1; + } + else + player->rings--; +} + // // P_DoFiring() // @@ -3181,213 +4079,188 @@ static void P_SetWeaponDelay(player_t *player, INT32 delay) static void P_DoFiring(player_t *player, ticcmd_t *cmd) { INT32 i; + mobj_t *mo = NULL; I_Assert(player != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); - if (cmd->buttons & BT_ATTACK || cmd->buttons & BT_FIRENORMAL) + if (!(cmd->buttons & (BT_ATTACK|BT_FIRENORMAL))) { - if (!(player->pflags & PF_ATTACKDOWN) && player->powers[pw_shield] & SH_FIREFLOWER && !player->climbing) - { - player->pflags |= PF_ATTACKDOWN; - P_SpawnPlayerMissile(player->mo, MT_FIREBALL, 0); - S_StartSound(player->mo, sfx_mario7); - } - else if (G_RingSlingerGametype() && (!G_TagGametype() || player->pflags & PF_TAGIT) - && !player->weapondelay && !player->climbing - && !(player->pflags & PF_ATTACKDOWN)) - { - mobj_t *mo = NULL; - player->pflags |= PF_ATTACKDOWN; - - if (cmd->buttons & BT_FIRENORMAL) // No powers, just a regular ring. - goto firenormal; //code repetition sucks. - // Bounce ring - else if (player->currentweapon == WEP_BOUNCE && player->powers[pw_bouncering]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNBOUNCE, MF2_BOUNCERING); - - if (mo) - mo->fuse = 3*TICRATE; // Bounce Ring time - - player->powers[pw_bouncering]--; - player->mo->health--; - player->health--; - } - // Rail ring - else if (player->currentweapon == WEP_RAIL && player->powers[pw_railring]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (3*TICRATE)/2); - - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, MF2_RAILRING|MF2_DONTDRAW); - - // Rail has no unique thrown object, therefore its sound plays here. - S_StartSound(player->mo, sfx_rail1); - - player->powers[pw_railring]--; - player->mo->health--; - player->health--; - } - // Automatic - else if (player->currentweapon == WEP_AUTO && player->powers[pw_automaticring]) - { - if (player->health <= 1) - return; - player->pflags &= ~PF_ATTACKDOWN; - P_SetWeaponDelay(player, 2); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNAUTOMATIC, MF2_AUTOMATIC); - - player->powers[pw_automaticring]--; - player->mo->health--; - player->health--; - } - // Explosion - else if (player->currentweapon == WEP_EXPLODE && player->powers[pw_explosionring]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (3*TICRATE)/2); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNEXPLOSION, MF2_EXPLOSION); - - player->powers[pw_explosionring]--; - player->mo->health--; - player->health--; - } - // Grenade - else if (player->currentweapon == WEP_GRENADE && player->powers[pw_grenadering]) - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/3); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNGRENADE, MF2_EXPLOSION); - - if (mo) - { - //P_InstaThrust(mo, player->mo->angle, FixedMul(mo->info->speed, player->mo->scale)); - mo->fuse = mo->info->mass; - } - - player->powers[pw_grenadering]--; - player->mo->health--; - player->health--; - } - // Scatter - // Note: Ignores MF2_RAILRING - else if (player->currentweapon == WEP_SCATTER && player->powers[pw_scatterring]) - { - fixed_t oldz = player->mo->z; - angle_t shotangle = player->mo->angle; - angle_t oldaiming = player->aiming; - - if (player->health <= 1) - return; - P_SetWeaponDelay(player, (2*TICRATE)/3); - - // Center - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNSCATTER, MF2_SCATTER); - if (mo) - shotangle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y); - - // Left - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle-ANG2, true, MF2_SCATTER); - - // Right - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle+ANG2, true, MF2_SCATTER); - - // Down - player->mo->z += FixedMul(12*FRACUNIT, player->mo->scale); - player->aiming += ANG1; - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); - - // Up - player->mo->z -= FixedMul(24*FRACUNIT, player->mo->scale); - player->aiming -= ANG2; - mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); - - player->mo->z = oldz; - player->aiming = oldaiming; - - player->powers[pw_scatterring]--; - player->mo->health--; - player->health--; - return; - } - // No powers, just a regular ring. - else - { -firenormal: - // Infinity ring was selected. - // Mystic wants this ONLY to happen specifically if it's selected, - // and to not be able to get around it EITHER WAY with firenormal. - - // Infinity Ring - if (player->currentweapon == 0 - && player->powers[pw_infinityring]) - { - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_THROWNINFINITY, 0); - - player->powers[pw_infinityring]--; - } - // Red Ring - else - { - if (player->health <= 1) - return; - P_SetWeaponDelay(player, TICRATE/4); - - mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, 0); - - if (mo) - P_ColorTeamMissile(mo, player); - - player->mo->health--; - player->health--; - } - } - - if (mo) - { - if (mo->flags & MF_MISSILE && mo->flags2 & MF2_RAILRING) - { - const boolean nblockmap = !(mo->flags & MF_NOBLOCKMAP); - for (i = 0; i < 256; i++) - { - if (nblockmap) - { - P_UnsetThingPosition(mo); - mo->flags |= MF_NOBLOCKMAP; - P_SetThingPosition(mo); - } - - if (i&1) - P_SpawnMobj(mo->x, mo->y, mo->z, MT_SPARK); - - if (P_RailThinker(mo)) - break; // mobj was removed (missile hit a wall) or couldn't move - } - - // Other rail sound plays at contact point. - S_StartSound(mo, sfx_rail2); - } - } - } + // Not holding any firing buttons anymore. + // Release the grenade / whatever. + player->pflags &= ~PF_ATTACKDOWN; return; } - // Not holding any firing buttons anymore. - // Release the grenade / whatever. - player->pflags &= ~PF_ATTACKDOWN; + if (player->pflags & PF_ATTACKDOWN || player->climbing || (G_TagGametype() && !(player->pflags & PF_TAGIT))) + return; + + if (((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) && !(player->weapondelay)) + { + player->pflags |= PF_ATTACKDOWN; + mo = P_SpawnPlayerMissile(player->mo, MT_FIREBALL, 0); + if (mo) + P_InstaThrust(mo, player->mo->angle, ((mo->info->speed>>FRACBITS)*player->mo->scale) + player->speed); + S_StartSound(player->mo, sfx_mario7); + P_SetWeaponDelay(player, TICRATE); // Short delay between fireballs so you can't spam them everywhere + return; + } + + if (!G_RingSlingerGametype() || player->weapondelay) + return; + + player->pflags |= PF_ATTACKDOWN; + + if (cmd->buttons & BT_FIRENORMAL) // No powers, just a regular ring. + goto firenormal; //code repetition sucks. + // Bounce ring + else if (player->currentweapon == WEP_BOUNCE && player->powers[pw_bouncering]) + { + P_DrainWeaponAmmo(player, pw_bouncering); + P_SetWeaponDelay(player, TICRATE/4); + + mo = P_SpawnPlayerMissile(player->mo, MT_THROWNBOUNCE, MF2_BOUNCERING); + + if (mo) + mo->fuse = 3*TICRATE; // Bounce Ring time + } + // Rail ring + else if (player->currentweapon == WEP_RAIL && player->powers[pw_railring]) + { + P_DrainWeaponAmmo(player, pw_railring); + P_SetWeaponDelay(player, (3*TICRATE)/2); + + mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, MF2_RAILRING|MF2_DONTDRAW); + + // Rail has no unique thrown object, therefore its sound plays here. + S_StartSound(player->mo, sfx_rail1); + } + // Automatic + else if (player->currentweapon == WEP_AUTO && player->powers[pw_automaticring]) + { + P_DrainWeaponAmmo(player, pw_automaticring); + player->pflags &= ~PF_ATTACKDOWN; + P_SetWeaponDelay(player, 2); + + mo = P_SpawnPlayerMissile(player->mo, MT_THROWNAUTOMATIC, MF2_AUTOMATIC); + } + // Explosion + else if (player->currentweapon == WEP_EXPLODE && player->powers[pw_explosionring]) + { + P_DrainWeaponAmmo(player, pw_explosionring); + P_SetWeaponDelay(player, (3*TICRATE)/2); + + mo = P_SpawnPlayerMissile(player->mo, MT_THROWNEXPLOSION, MF2_EXPLOSION); + } + // Grenade + else if (player->currentweapon == WEP_GRENADE && player->powers[pw_grenadering]) + { + P_DrainWeaponAmmo(player, pw_grenadering); + P_SetWeaponDelay(player, TICRATE/3); + + mo = P_SpawnPlayerMissile(player->mo, MT_THROWNGRENADE, MF2_EXPLOSION); + + if (mo) + { + //P_InstaThrust(mo, player->mo->angle, FixedMul(mo->info->speed, player->mo->scale)); + mo->fuse = mo->info->reactiontime; + } + } + // Scatter + // Note: Ignores MF2_RAILRING + else if (player->currentweapon == WEP_SCATTER && player->powers[pw_scatterring]) + { + fixed_t oldz = player->mo->z; + angle_t shotangle = player->mo->angle; + angle_t oldaiming = player->aiming; + + P_DrainWeaponAmmo(player, pw_scatterring); + P_SetWeaponDelay(player, (2*TICRATE)/3); + + // Center + mo = P_SpawnPlayerMissile(player->mo, MT_THROWNSCATTER, MF2_SCATTER); + if (mo) + shotangle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y); + + // Left + mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle-ANG2, true, MF2_SCATTER); + + // Right + mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle+ANG2, true, MF2_SCATTER); + + // Down + player->mo->z += FixedMul(12*FRACUNIT, player->mo->scale); + player->aiming += ANG1; + mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); + + // Up + player->mo->z -= FixedMul(24*FRACUNIT, player->mo->scale); + player->aiming -= ANG2; + mo = P_SPMAngle(player->mo, MT_THROWNSCATTER, shotangle, true, MF2_SCATTER); + + player->mo->z = oldz; + player->aiming = oldaiming; + return; + } + // No powers, just a regular ring. + else + { +firenormal: + // Infinity ring was selected. + // Mystic wants this ONLY to happen specifically if it's selected, + // and to not be able to get around it EITHER WAY with firenormal. + + // Infinity Ring + if (player->currentweapon == 0 + && player->powers[pw_infinityring]) + { + P_SetWeaponDelay(player, TICRATE/4); + + mo = P_SpawnPlayerMissile(player->mo, MT_THROWNINFINITY, 0); + + player->powers[pw_infinityring]--; + } + // Red Ring + else + { + if (player->rings <= 0) + return; + P_SetWeaponDelay(player, TICRATE/4); + + mo = P_SpawnPlayerMissile(player->mo, MT_REDRING, 0); + + if (mo) + P_ColorTeamMissile(mo, player); + + player->rings--; + } + } + + if (mo) + { + if (mo->flags & MF_MISSILE && mo->flags2 & MF2_RAILRING) + { + const boolean nblockmap = !(mo->flags & MF_NOBLOCKMAP); + for (i = 0; i < 256; i++) + { + if (nblockmap) + { + P_UnsetThingPosition(mo); + mo->flags |= MF_NOBLOCKMAP; + P_SetThingPosition(mo); + } + + if (i&1) + P_SpawnMobj(mo->x, mo->y, mo->z, MT_SPARK); + + if (P_RailThinker(mo)) + break; // mobj was removed (missile hit a wall) or couldn't move + } + + // Other rail sound plays at contact point. + S_StartSound(mo, sfx_rail2); + } + } } // @@ -3399,30 +4272,30 @@ static void P_DoSuperStuff(player_t *player) { mobj_t *spark; ticcmd_t *cmd = &player->cmd; - if (player->mo->state >= &states[S_PLAY_SUPERTRANS1] && player->mo->state <= &states[S_PLAY_SUPERTRANS9]) + if (player->mo->state >= &states[S_PLAY_SUPER_TRANS1] + && player->mo->state < &states[S_PLAY_SUPER_TRANS6]) return; // don't do anything right now, we're in the middle of transforming! - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) return; // NiGHTS Super doesn't mix with normal super - // Does player have all emeralds? If so, flag the "Ready For Super!" - if ((ALL7EMERALDS(emeralds) || ALL7EMERALDS(player->powers[pw_emeralds])) && player->health > 50) - player->pflags |= PF_SUPERREADY; - else - player->pflags &= ~PF_SUPERREADY; - if (player->powers[pw_super]) { // If you're super and not Sonic, de-superize! - if (!((ALL7EMERALDS(emeralds)) && (player->charflags & SF_SUPER)) && !(ALL7EMERALDS(player->powers[pw_emeralds]))) + if (!(ALL7EMERALDS(emeralds) && player->charflags & SF_SUPER)) { player->powers[pw_super] = 0; P_SetPlayerMobjState(player->mo, S_PLAY_STND); + if (P_IsLocalPlayer(player)) + { + music_stack_noposition = true; // HACK: Do not reposition next music + music_stack_fadeout = MUSICRATE/2; // HACK: Fade out current music + } P_RestoreMusic(player); P_SpawnShieldOrb(player); // Restore color - if (player->powers[pw_shield] & SH_FIREFLOWER) + if ((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) { player->mo->color = SKINCOLOR_WHITE; G_GhostAddColor(GHC_FIREFLOWER); @@ -3442,23 +4315,20 @@ static void P_DoSuperStuff(player_t *player) return; } + player->mo->color = (player->pflags & PF_GODMODE && cv_debug == 0) + ? (SKINCOLOR_SUPERSILVER1 + 5*(((signed)leveltime >> 1) % 7)) // A wholesome easter egg. + : skins[player->skin].supercolor + abs( ( (player->powers[pw_super] >> 1) % 9) - 4); // This is where super flashing is handled. + + G_GhostAddColor(GHC_SUPER); + + if (player->mo->state == &states[S_PLAY_SUPER_TRANS6]) // stop here for now + return; + // Deplete one ring every second while super if ((leveltime % TICRATE == 0) && !(player->exiting)) - { - player->health--; - player->mo->health--; - } + player->rings--; - // future todo: a skin option for this, and possibly more colors - switch (player->skin) - { - case 1: /* Tails */ player->mo->color = SKINCOLOR_TSUPER1; break; - case 2: /* Knux */ player->mo->color = SKINCOLOR_KSUPER1; break; - default: /* everyone */ player->mo->color = SKINCOLOR_SUPER1; break; - } - player->mo->color += abs( ( (signed)( (unsigned)leveltime >> 1 ) % 9) - 4); - - if ((cmd->forwardmove != 0 || cmd->sidemove != 0 || player->pflags & (PF_CARRIED|PF_ROPEHANG|PF_ITEMHANG|PF_MACESPIN)) + if ((cmd->forwardmove != 0 || cmd->sidemove != 0 || player->powers[pw_carry]) && !(leveltime % TICRATE) && (player->mo->momx || player->mo->momy)) { spark = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_SUPERSPARK); @@ -3466,10 +4336,8 @@ static void P_DoSuperStuff(player_t *player) P_SetScale(spark, player->mo->scale); } - G_GhostAddColor(GHC_SUPER); - // Ran out of rings while super! - if (player->health <= 1 || player->exiting) + if (player->rings <= 0 || player->exiting) { player->powers[pw_emeralds] = 0; // lost the power stones P_SpawnGhostMobj(player->mo); @@ -3477,7 +4345,7 @@ static void P_DoSuperStuff(player_t *player) player->powers[pw_super] = 0; // Restore color - if (player->powers[pw_shield] & SH_FIREFLOWER) + if ((player->powers[pw_shield] & SH_STACK) == SH_FIREFLOWER) { player->mo->color = SKINCOLOR_WHITE; G_GhostAddColor(GHC_FIREFLOWER); @@ -3491,23 +4359,8 @@ static void P_DoSuperStuff(player_t *player) if (gametype != GT_COOP) player->powers[pw_flashing] = flashingtics-1; - if (player->mo->health > 0) - { - if ((player->pflags & PF_JUMPED) || (player->pflags & PF_SPINNING)) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - else if (player->panim == PA_RUN) - P_SetPlayerMobjState(player->mo, S_PLAY_SPD1); - else if (player->panim == PA_WALK) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else - P_SetPlayerMobjState(player->mo, S_PLAY_STND); - - if (!player->exiting) - { - player->health = 1; - player->mo->health = 1; - } - } + if (player->mo->sprite2 & FF_SPR2SUPER) + P_SetPlayerMobjState(player->mo, player->mo->state-states); // Inform the netgame that the champion has fallen in the heat of battle. if (gametype != GT_COOP) @@ -3519,6 +4372,11 @@ static void P_DoSuperStuff(player_t *player) } // Resume normal music if you're the console player + if (P_IsLocalPlayer(player)) + { + music_stack_noposition = true; // HACK: Do not reposition next music + music_stack_fadeout = MUSICRATE/2; // HACK: Fade out current music + } P_RestoreMusic(player); // If you had a shield, restore its visual significance. @@ -3534,12 +4392,15 @@ static void P_DoSuperStuff(player_t *player) // boolean P_SuperReady(player_t *player) { - if ((player->pflags & PF_SUPERREADY) && !player->powers[pw_super] && !player->powers[pw_tailsfly] - && !(player->powers[pw_shield] & SH_NOSTACK) + if (!player->powers[pw_super] && !player->powers[pw_invulnerability] - && !(maptol & TOL_NIGHTS) // don't turn 'regular super' in nights levels - && player->pflags & PF_JUMPED - && ((player->charflags & SF_SUPER) || ALL7EMERALDS(player->powers[pw_emeralds]))) + && !player->powers[pw_tailsfly] + && (player->charflags & SF_SUPER) + && (player->pflags & PF_JUMPED) + && !(player->powers[pw_shield] & SH_NOSTACK) + && !(maptol & TOL_NIGHTS) + && ALL7EMERALDS(emeralds) + && (player->rings >= 50)) return true; return false; @@ -3571,9 +4432,9 @@ void P_DoJump(player_t *player, boolean soundandstate) else player->mo->momz = 15*(FRACUNIT/4); - player->mo->angle = player->mo->angle - ANGLE_180; // Turn around from the wall you were climbing. + player->drawangle = player->mo->angle = player->mo->angle - ANGLE_180; // Turn around from the wall you were climbing. - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; // Adjust the local control angle. @@ -3595,28 +4456,53 @@ void P_DoJump(player_t *player, boolean soundandstate) else if (player->mo->momz < 0) // still descending? player->mo->momz = (39*(FRACUNIT/4))>>1; // just default to the jump height. } - else if (!(player->pflags & PF_JUMPED)) // Spin Attack + else if (!(player->pflags & PF_JUMPED)) // Jump { if (player->mo->ceilingz-player->mo->floorz <= player->mo->height-1) return; + if (player->powers[pw_carry] == CR_PTERABYTE) + { + S_StartSound(player->mo, sfx_s3kd7s); + player->mo->tracer->cusval += 10; + player->mo->tracer->watertop = P_RandomRange(-player->mo->tracer->cusval, player->mo->tracer->cusval) << (FRACBITS - 1); + player->mo->tracer->waterbottom = P_RandomRange(-player->mo->tracer->cusval, player->mo->tracer->cusval) << (FRACBITS - 1); + player->mo->tracer->cvmem = P_RandomRange(-player->mo->tracer->cusval, player->mo->tracer->cusval) << (FRACBITS - 1); + return; + } + // Jump this high. - if (player->pflags & PF_CARRIED) + if (player->powers[pw_carry] == CR_PLAYER) { player->mo->momz = 9*FRACUNIT; - player->pflags &= ~PF_CARRIED; + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer, NULL); if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } - else if (player->pflags & PF_ITEMHANG) + else if (player->powers[pw_carry] == CR_GENERIC) { player->mo->momz = 9*FRACUNIT; - player->pflags &= ~PF_ITEMHANG; + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer->target, NULL); + P_SetTarget(&player->mo->tracer, NULL); } - else if (player->pflags & PF_ROPEHANG) + else if (player->powers[pw_carry] == CR_ROPEHANG) { player->mo->momz = 12*FRACUNIT; - player->pflags &= ~PF_ROPEHANG; + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer, NULL); + } + else if (player->powers[pw_carry] == CR_ROLLOUT) + { + player->mo->momz = 9*FRACUNIT; + if (P_MobjFlip(player->mo->tracer)*player->mo->tracer->momz > 0) + player->mo->momz += player->mo->tracer->momz; + if (!P_IsObjectOnGround(player->mo->tracer)) + P_SetObjectMomZ(player->mo->tracer, -9*FRACUNIT, true); + player->powers[pw_carry] = CR_NONE; + player->mo->tracer->flags |= MF_PUSHABLE; + P_SetTarget(&player->mo->tracer->tracer, NULL); P_SetTarget(&player->mo->tracer, NULL); } else if (player->mo->eflags & MFE_GOOWATER) @@ -3624,50 +4510,33 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->momz = 7*FRACUNIT; if (player->charability == CA_JUMPBOOST && onground) { - if (player->charability2 == CA2_MULTIABILITY) + if (player->charflags & SF_MULTIABILITY) player->mo->momz += FixedMul(FRACUNIT/4, dist6); else player->mo->momz += FixedMul(FRACUNIT/8, dist6); } } else if (maptol & TOL_NIGHTS) - player->mo->momz = 24*FRACUNIT; + player->mo->momz = 18*FRACUNIT; else if (player->powers[pw_super]) { - if (player->charability == CA_FLOAT) - player->mo->momz = 28*FRACUNIT; //Obscene jump height anyone? - else if (player->charability == CA_SLOWFALL) - player->mo->momz = 37*(FRACUNIT/2); //Less obscene because during super, floating propells oneself upward. - else // Default super jump momentum. - player->mo->momz = 13*FRACUNIT; + player->mo->momz = 13*FRACUNIT; // Add a boost for super characters with float/slowfall and multiability. - if (player->charability2 == CA2_MULTIABILITY && - (player->charability == CA_FLOAT || player->charability == CA_SLOWFALL)) - player->mo->momz += 2*FRACUNIT; - else if (player->charability == CA_JUMPBOOST) + if (player->charability == CA_JUMPBOOST) { - if (player->charability2 == CA2_MULTIABILITY) + if (player->charflags & SF_MULTIABILITY) player->mo->momz += FixedMul(FRACUNIT/4, dist6); else player->mo->momz += FixedMul(FRACUNIT/8, dist6); } } - else if (player->charability2 == CA2_MULTIABILITY && - (player->charability == CA_DOUBLEJUMP || player->charability == CA_FLOAT || player->charability == CA_SLOWFALL)) - { - // Multiability exceptions, since some abilities cannot effectively use it and need a boost. - if (player->charability == CA_DOUBLEJUMP) - player->mo->momz = 23*(FRACUNIT/2); // Increased jump height instead of infinite jumps. - else if (player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) - player->mo->momz = 12*FRACUNIT; // Increased jump height due to ineffective repeat. - } else { player->mo->momz = 39*(FRACUNIT/4); // Default jump momentum. if (player->charability == CA_JUMPBOOST && onground) { - if (player->charability2 == CA2_MULTIABILITY) + if (player->charflags & SF_MULTIABILITY) player->mo->momz += FixedMul(FRACUNIT/4, dist6); else player->mo->momz += FixedMul(FRACUNIT/8, dist6); @@ -3678,7 +4547,7 @@ void P_DoJump(player_t *player, boolean soundandstate) if (player->mo->eflags & MFE_UNDERWATER) player->mo->momz = FixedMul(player->mo->momz, FixedDiv(117*FRACUNIT, 200*FRACUNIT)); - player->jumping = 1; + player->pflags |= PF_STARTJUMP; } factor = player->jumpfactor; @@ -3686,6 +4555,12 @@ void P_DoJump(player_t *player, boolean soundandstate) if (twodlevel || (player->mo->flags2 & MF2_TWOD)) factor += player->jumpfactor / 10; + if (player->charflags & SF_MULTIABILITY && player->charability == CA_DOUBLEJUMP) + factor -= max(0, player->secondjump * player->jumpfactor / ((player->actionspd >> FRACBITS) + 1)); // Reduce the jump height each time + + //if (maptol & TOL_NIGHTS) + // factor = player->jumpfactor; // all skins jump the same. if you nerf jumping abilities, you may want this. + P_SetObjectMomZ(player->mo, FixedMul(factor, player->mo->momz), false); // Custom height // set just an eensy above the ground @@ -3694,112 +4569,285 @@ void P_DoJump(player_t *player, boolean soundandstate) player->mo->z--; if (player->mo->pmomz < 0) player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. - else - player->mo->pmomz = 0; + player->mo->pmomz = 0; } else { player->mo->z++; if (player->mo->pmomz > 0) player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. - else - player->mo->pmomz = 0; + player->mo->pmomz = 0; } player->mo->eflags &= ~MFE_APPLYPMOMZ; - player->pflags |= PF_JUMPED; + player->pflags |= P_GetJumpFlags(player);; if (soundandstate) { if (!player->spectator) S_StartSound(player->mo, sfx_jump); // Play jump sound! - if (!(player->charability2 == CA2_SPINDASH)) - P_SetPlayerMobjState(player->mo, S_PLAY_SPRING); - else - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); + } +} + +static void P_DoSpinDashDust(player_t *player) +{ + UINT32 i; + mobj_t *particle; + INT32 prandom[3]; + for (i = 0; i <= (leveltime%7)/2; i++) { // 1, 2, 3 or 4 particles + particle = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_SPINDUST); + + if (player->mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) // overrides fire version + P_SetMobjState(particle, S_SPINDUST_BUBBLE1); + else if (player->powers[pw_shield] == SH_ELEMENTAL) + P_SetMobjState(particle, S_SPINDUST_FIRE1); + + P_SetTarget(&particle->target, player->mo); + particle->destscale = (2*player->mo->scale)/3; + P_SetScale(particle, particle->destscale); + if (player->mo->eflags & MFE_VERTICALFLIP) // readjust z position if needed + particle->z = player->mo->z + player->mo->height - particle->height; + prandom[0] = P_RandomFixed()<<2; // P_RandomByte()<<10 + prandom[1] = P_RandomRange(-30, 30); // P_RandomRange(-ANG30/FRACUNIT, ANG30/FRACUNIT)*FRACUNIT + prandom[2] = P_RandomFixed()<<3; // P_RandomByte()<<11 + P_SetObjectMomZ(particle, player->dashspeed/50 + prandom[0], false); + P_InstaThrust(particle, + player->drawangle + (prandom[1]*ANG1), + -FixedMul(player->dashspeed/12 + FRACUNIT + prandom[2], player->mo->scale)); + P_TryMove(particle, particle->x+particle->momx, particle->y+particle->momy, true); } } // -// P_DoSpinDash +// P_DoSpinAbility // // Player spindash handling // -static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) +static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) { - if (player->pflags & PF_STASIS) + boolean canstand = true; // can we stand on the ground? (mostly relevant for slopes) + if (player->pflags & PF_STASIS + && (player->pflags & PF_JUMPSTASIS || player->mo->state-states != S_PLAY_GLIDE_LANDING)) return; -#ifdef HAVE_BLUA if (cmd->buttons & BT_USE) { if (LUAh_SpinSpecial(player)) return; } + +#ifdef ESLOPE + canstand = (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2); #endif - // Spinning and Spindashing - if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SLIDING) && !player->exiting - && !P_PlayerInPain(player)) // subsequent revs + /////////////////////////////// + // ability-specific behavior // + /////////////////////////////// + if (!(player->pflags & PF_SLIDING) && !player->exiting && !P_PlayerInPain(player)) { - if ((cmd->buttons & BT_USE) && player->speed < FixedMul(5<mo->scale) && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING) -#ifdef ESLOPE - && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) -#endif - ) + switch (player->charability2) { - player->mo->momx = player->cmomx; - player->mo->momy = player->cmomy; - player->pflags |= PF_STARTDASH|PF_SPINNING; - player->dashspeed = FixedMul(FRACUNIT, player->mo->scale); - player->dashtime = 0; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - player->pflags |= PF_USEDOWN; - } - else if ((cmd->buttons & BT_USE) && (player->pflags & PF_STARTDASH)) - { - player->dashspeed += FixedMul(FRACUNIT, player->mo->scale); + case CA2_SPINDASH: // Spinning and Spindashing + // Start revving + if ((cmd->buttons & BT_USE) && (player->speed < FixedMul(5<mo->scale) || player->mo->state - states == S_PLAY_GLIDE_LANDING) + && !player->mo->momz && onground && !(player->pflags & (PF_USEDOWN|PF_SPINNING)) + && canstand) + { + player->mo->momx = player->cmomx; + player->mo->momy = player->cmomy; + player->pflags |= (PF_USEDOWN|PF_STARTDASH|PF_SPINNING); + player->dashspeed = player->mindash; + P_SetPlayerMobjState(player->mo, S_PLAY_SPINDASH); + if (!player->spectator) + S_StartSound(player->mo, sfx_spndsh); // Make the rev sound! + } + // Revving + else if ((cmd->buttons & BT_USE) && (player->pflags & PF_STARTDASH)) + { + if (player->speed > 5*player->mo->scale) + { + player->pflags &= ~PF_STARTDASH; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + S_StartSound(player->mo, sfx_spin); + break; + } + if (player->dashspeed < player->mindash) + player->dashspeed = player->mindash; - if (!(player->dashtime++ % 5)) - { - if (!player->spectator && player->dashspeed < FixedMul(player->maxdash, player->mo->scale)) - S_StartSound(player->mo, sfx_spndsh); // Make the rev sound! + if (player->dashspeed > player->maxdash) + player->dashspeed = player->maxdash; - // Now spawn the color thok circle. - P_SpawnSpinMobj(player, player->revitem); - if (demorecording) - G_GhostAddRev(); - } - } - // If not moving up or down, and travelling faster than a speed of four while not holding - // down the spin button and not spinning. - // AKA Just go into a spin on the ground, you idiot. ;) - else if ((cmd->buttons & BT_USE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20)) - && !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<mo->scale) -#ifdef ESLOPE - || (player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) >= FRACUNIT/2) + if (player->dashspeed < player->maxdash && player->mindash != player->maxdash) + { +#define chargecalculation (6*(player->dashspeed - player->mindash))/(player->maxdash - player->mindash) + fixed_t soundcalculation = chargecalculation; + player->dashspeed += FRACUNIT; + if (!player->spectator && soundcalculation != chargecalculation) + S_StartSound(player->mo, sfx_spndsh); // Make the rev sound! +#undef chargecalculation + } + if (player->revitem && !(leveltime % 5)) // Now spawn the color thok circle. + { + P_SpawnSpinMobj(player, player->revitem); + G_GhostAddRev(); + } + } + // If not moving up or down, and travelling faster than a speed of five while not holding + // down the spin button and not spinning. + // AKA Just go into a spin on the ground, you idiot. ;) + else if ((cmd->buttons & BT_USE || ((twodlevel || (player->mo->flags2 & MF2_TWOD)) && cmd->forwardmove < -20)) + && !player->climbing && !player->mo->momz && onground && (player->speed > FixedMul(5<mo->scale) + || !canstand) && !(player->pflags & (PF_USEDOWN|PF_SPINNING))) + { + player->pflags |= (PF_USEDOWN|PF_SPINNING); + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + if (!player->spectator) + S_StartSound(player->mo, sfx_spin); + } + else + // Catapult the player from a spindash rev! + if (onground && !(player->pflags & PF_USEDOWN) && (player->pflags & PF_STARTDASH) && (player->pflags & PF_SPINNING)) + { + player->pflags &= ~PF_STARTDASH; + if (player->powers[pw_carry] == CR_BRAKGOOP) + player->dashspeed = 0; + + if (!((gametyperules & GTR_RACE) && leveltime < 4*TICRATE)) + { + if (player->dashspeed) + { + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + P_InstaThrust(player->mo, player->mo->angle, (player->speed = FixedMul(player->dashspeed, player->mo->scale))); // catapult forward ho!! + } + else + { + P_SetPlayerMobjState(player->mo, S_PLAY_STND); + player->pflags &= ~PF_SPINNING; + } + + if (!player->spectator) + S_StartSound(player->mo, sfx_zoom); + } + + player->dashspeed = 0; + } + break; + case CA2_GUNSLINGER: + if (!player->mo->momz && onground && !player->weapondelay && canstand) + { + if (player->speed > FixedMul(10<mo->scale)) + {} + else + { + mobj_t *lockon = P_LookForEnemies(player, false, true); + if (lockon) + { + if (P_IsLocalPlayer(player)) // Only display it on your own view. + { + mobj_t *visual = P_SpawnMobj(lockon->x, lockon->y, lockon->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&visual->target, lockon); + } + } + if ((cmd->buttons & BT_USE) && !(player->pflags & PF_USEDOWN)) + { + mobj_t *bullet; + + P_SetPlayerMobjState(player->mo, S_PLAY_FIRE); + +#define zpos(posmo) (posmo->z + (posmo->height - mobjinfo[player->revitem].height)/2) + if (lockon) + { + player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, lockon->x, lockon->y); + bullet = P_SpawnPointMissile(player->mo, lockon->x, lockon->y, zpos(lockon), player->revitem, player->mo->x, player->mo->y, zpos(player->mo)); + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) + { + if (player == &players[consoleplayer]) + localangle = player->mo->angle; + else if (player == &players[secondarydisplayplayer]) + localangle2 = player->mo->angle; + } + } + else + { + bullet = P_SpawnPointMissile(player->mo, player->mo->x + P_ReturnThrustX(NULL, player->mo->angle, FRACUNIT), player->mo->y + P_ReturnThrustY(NULL, player->mo->angle, FRACUNIT), zpos(player->mo), player->revitem, player->mo->x, player->mo->y, zpos(player->mo)); + if (bullet) + { + bullet->flags &= ~MF_NOGRAVITY; + bullet->momx >>= 1; + bullet->momy >>= 1; + } + } + player->drawangle = player->mo->angle; +#undef zpos + + player->mo->momx >>= 1; + player->mo->momy >>= 1; + player->pflags |= PF_USEDOWN; + P_SetWeaponDelay(player, TICRATE/2); + } + } + } + break; + case CA2_MELEE: // Melee attack + if (player->panim != PA_ABILITY2 && (cmd->buttons & BT_USE) + && !player->mo->momz && onground && !(player->pflags & PF_USEDOWN) + && canstand) + { + P_ResetPlayer(player); + player->pflags |= PF_THOKKED; +#if 0 + if ((player->charability == CA_TWINSPIN) && (player->speed > FixedMul(player->runspeed, player->mo->scale))) + { + P_DoJump(player, false); + player->pflags &= ~PF_STARTJUMP; + player->mo->momz = FixedMul(player->mo->momz, 3*FRACUNIT/2); // NOT 1.5 times the jump height, but 2.25 times. + P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN); + S_StartSound(player->mo, sfx_s3k8b); + } + else #endif - ) && !(player->pflags & PF_USEDOWN) && !(player->pflags & PF_SPINNING)) - { - player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - if (!player->spectator) - S_StartSound(player->mo, sfx_spin); - player->pflags |= PF_USEDOWN; + { + player->mo->z += P_MobjFlip(player->mo); + P_SetObjectMomZ(player->mo, player->mindash, false); + if (P_MobjFlip(player->mo)*player->mo->pmomz > 0) + player->mo->momz += player->mo->pmomz; // Add the platform's momentum to your jump. + else + player->mo->pmomz = 0; + if (player->mo->eflags & MFE_UNDERWATER) + player->mo->momz >>= 1; +#if 0 + if (FixedMul(player->speed, FINECOSINE(((player->mo->angle - R_PointToAngle2(0, 0, player->rmomx, player->rmomy)) >> ANGLETOFINESHIFT) & FINEMASK)) < FixedMul(player->maxdash, player->mo->scale)) +#else + if (player->speed < FixedMul(player->maxdash, player->mo->scale)) +#endif + { + if (player->panim == PA_IDLE) + player->drawangle = player->mo->angle; + P_InstaThrust(player->mo, player->drawangle, FixedMul(player->maxdash, player->mo->scale)); + } + player->mo->momx += player->cmomx; + player->mo->momy += player->cmomy; + P_SetPlayerMobjState(player->mo, S_PLAY_MELEE); + S_StartSound(player->mo, sfx_s3k42); + } + player->pflags |= PF_USEDOWN; + } + break; } } + /////////////////////////////// + // general spinning behavior // + /////////////////////////////// + // Rolling normally if (onground && player->pflags & PF_SPINNING && !(player->pflags & PF_STARTDASH) - && player->speed < FixedMul(5*FRACUNIT,player->mo->scale) -#ifdef ESLOPE - && (!player->mo->standingslope || (player->mo->standingslope->flags & SL_NOPHYSICS) || abs(player->mo->standingslope->zdelta) < FRACUNIT/2) -#endif - ) + && player->speed < 5*player->mo->scale && canstand) { if (GETSECSPECIAL(player->mo->subsector->sector->special, 4) == 7 || (player->mo->ceilingz - player->mo->floorz < P_GetPlayerHeight(player))) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(10*FRACUNIT, player->mo->scale)); + P_InstaThrust(player->mo, player->mo->angle, 10*player->mo->scale); else { player->skidtime = 0; @@ -3810,24 +4858,12 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) } } - // Catapult the player from a spindash rev! - if (onground && !(player->pflags & PF_USEDOWN) && player->dashspeed && (player->pflags & PF_STARTDASH) && (player->pflags & PF_SPINNING)) + if (onground && player->pflags & PF_STARTDASH) { - if (player->powers[pw_ingoop]) - player->dashspeed = 0; - - player->pflags &= ~PF_STARTDASH; - if (!((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE)) - { - P_InstaThrust(player->mo, player->mo->angle, player->dashspeed); // catapult forward ho!! - if (!player->spectator) - S_StartSound(player->mo, sfx_zoom); - } - player->dashspeed = 0; + // Spawn spin dash dust + if (!(player->charflags & SF_NOSPINDASHDUST) && !(player->mo->eflags & MFE_GOOWATER)) + P_DoSpinDashDust(player); } - - if (onground && (player->pflags & PF_SPINNING) && !(player->panim == PA_ROLL)) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); } // @@ -3837,18 +4873,141 @@ static void P_DoSpinDash(player_t *player, ticcmd_t *cmd) // void P_DoJumpShield(player_t *player) { + boolean electric = ((player->powers[pw_shield] & SH_PROTECTELECTRIC) == SH_PROTECTELECTRIC); + if (player->pflags & PF_THOKKED) return; player->pflags &= ~PF_JUMPED; P_DoJump(player, false); - player->pflags &= ~PF_JUMPED; player->secondjump = 0; - player->jumping = 0; + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + player->pflags &= ~(PF_STARTJUMP|PF_SPINNING|PF_BOUNCING); + if (electric) + { + mobj_t *spark; + INT32 i; +#define numangles 6 +#define limitangle (360/numangles) + const angle_t travelangle = player->mo->angle + P_RandomRange(-limitangle, limitangle)*ANG1; + for (i = 0; i < numangles; i++) + { + spark = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_THUNDERCOIN_SPARK); + P_InstaThrust(spark, travelangle + i*(ANGLE_MAX/numangles), FixedMul(4*FRACUNIT, spark->scale)); + if (i % 2) + P_SetObjectMomZ(spark, -4*FRACUNIT, false); + spark->fuse = 18; + } +#undef limitangle +#undef numangles + S_StartSound(player->mo, sfx_s3k45); + } + else + { + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE); + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + S_StartSound(player->mo, sfx_wdjump); + } +} + +// +// P_DoBubbleBounce +// +// Bubblewrap shield landing handling +// +void P_DoBubbleBounce(player_t *player) +{ + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SHIELDABILITY); + S_StartSound(player->mo, sfx_s3k44); + P_MobjCheckWater(player->mo); + P_DoJump(player, false); + if (player->charflags & SF_NOJUMPSPIN) + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + else + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); player->pflags |= PF_THOKKED; - player->pflags &= ~PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - S_StartSound(player->mo, sfx_wdjump); + player->pflags &= ~PF_STARTJUMP; + player->secondjump = UINT8_MAX; + player->mo->momz = FixedMul(player->mo->momz, 5*FRACUNIT/4); +} + +// +// P_DoAbilityBounce +// +// CA_BOUNCE landing handling +// +void P_DoAbilityBounce(player_t *player, boolean changemomz) +{ + fixed_t prevmomz; + if (player->mo->state-states == S_PLAY_BOUNCE_LANDING) + return; + if (changemomz) + { + fixed_t minmomz; + prevmomz = player->mo->momz; + if (P_MobjFlip(player->mo)*prevmomz < 0) + prevmomz = 0; + else if (player->mo->eflags & MFE_UNDERWATER) + prevmomz /= 2; + P_DoJump(player, false); + player->pflags &= ~(PF_STARTJUMP|PF_JUMPED); + minmomz = FixedMul(player->mo->momz, 3*FRACUNIT/2); + player->mo->momz = max(minmomz, (minmomz + prevmomz)/2); + } + S_StartSound(player->mo, sfx_boingf); + P_SetPlayerMobjState(player->mo, S_PLAY_BOUNCE_LANDING); + player->pflags |= PF_BOUNCING|PF_THOKKED; +} + +// +// P_TwinSpinRejuvenate +// +// CA_TWINSPIN landing handling +// +void P_TwinSpinRejuvenate(player_t *player, mobjtype_t type) +{ + fixed_t actionspd; + angle_t movang, ang, fa; + fixed_t v, h; + UINT8 i; + + if (!player->mo || !type) + return; + + actionspd = FixedMul(player->actionspd, player->mo->scale); + + fa = (R_PointToAngle2(0, 0, player->mo->momz, FixedHypot(player->mo->momx, player->mo->momy))>>ANGLETOFINESHIFT) & FINEMASK; + movang = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + ang = 0; + + v = FixedMul(actionspd, FINESINE(fa)); + h = actionspd - FixedMul(actionspd, FINECOSINE(fa)); + + // hearticles + for (i = 0; i <= 7; i++) + { + fixed_t side = actionspd - FixedMul(h, abs(FINESINE((ang>>ANGLETOFINESHIFT) & FINEMASK))); + fixed_t xo = P_ReturnThrustX(NULL, ang + movang, side); + fixed_t yo = P_ReturnThrustY(NULL, ang + movang, side); + fixed_t zo = -FixedMul(FINECOSINE(((ang>>ANGLETOFINESHIFT) & FINEMASK)), v); + mobj_t *missile = P_SpawnMobjFromMobj(player->mo, + xo, + yo, + player->mo->height/2 + zo, + type); + P_SetTarget(&missile->target, player->mo); + P_SetScale(missile, (missile->destscale >>= 1)); + missile->angle = ang + movang; + missile->fuse = TICRATE/2; + missile->extravalue2 = (99*FRACUNIT)/100; + missile->momx = xo; + missile->momy = yo; + missile->momz = zo; + + ang += ANGLE_45; + } + + player->pflags &= ~PF_THOKKED; } // @@ -3867,9 +5026,9 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range) if (player->powers[pw_super]) // increase range when super range *= 2; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -3910,46 +5069,179 @@ void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range) // static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { + mobj_t *lockonthok = NULL, *lockonshield = NULL, *visual = NULL; + if (player->pflags & PF_JUMPSTASIS) return; - if (cmd->buttons & BT_USE && !(player->pflags & PF_JUMPDOWN) && !player->exiting && !P_PlayerInPain(player)) + if ((player->charability == CA_HOMINGTHOK) && !player->homing && (player->pflags & PF_JUMPED) && (!(player->pflags & PF_THOKKED) || (player->charflags & SF_MULTIABILITY)) && (lockonthok = P_LookForEnemies(player, true, false))) { - if (onground || player->climbing || player->pflags & (PF_CARRIED|PF_ITEMHANG|PF_ROPEHANG)) - {} - else if (player->pflags & PF_MACESPIN && player->mo->tracer) - {} - else if (!(player->pflags & PF_SLIDING) && ((gametype != GT_CTF) || (!player->gotflag))) + if (P_IsLocalPlayer(player)) // Only display it on your own view. { -#ifdef HAVE_BLUA - if (!LUAh_JumpSpinSpecial(player)) -#endif - switch (player->charability) + visual = P_SpawnMobj(lockonthok->x, lockonthok->y, lockonthok->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&visual->target, lockonthok); + } + } + + ////////////////// + //SHIELD ACTIVES// + //& SUPER FLOAT!// + ////////////////// + + if ((player->pflags & PF_JUMPED) && !player->exiting && !P_PlayerInPain(player)) + { + if (onground || player->climbing || player->powers[pw_carry]) + ; + else if ((gametyperules & GTR_TEAMFLAGS) && player->gotflag) + ; + else if (player->pflags & (PF_GLIDING|PF_SLIDING|PF_SHIELDABILITY)) // If the player has used an ability previously + ; + else if ((player->powers[pw_shield] & SH_NOSTACK) && !player->powers[pw_super] && !(player->pflags & PF_USEDOWN) + && ((!(player->pflags & PF_THOKKED) || ((player->powers[pw_shield] & SH_NOSTACK) == SH_BUBBLEWRAP && player->secondjump == UINT8_MAX)))) // thokked is optional if you're bubblewrapped + { + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT) { - case CA_TELEKINESIS: - if (player->pflags & PF_JUMPED) + if ((lockonshield = P_LookForEnemies(player, false, false))) + { + if (P_IsLocalPlayer(player)) // Only display it on your own view. { - if (!(player->pflags & PF_THOKKED) || (player->charability2 == CA2_MULTIABILITY)) + boolean dovis = true; + if (lockonshield == lockonthok) + { + if (leveltime & 2) + dovis = false; + else if (visual) + P_RemoveMobj(visual); + } + if (dovis) + { + visual = P_SpawnMobj(lockonshield->x, lockonshield->y, lockonshield->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&visual->target, lockonshield); + P_SetMobjStateNF(visual, visual->info->spawnstate+1); + } + } + } + } + if (cmd->buttons & BT_USE && !LUAh_ShieldSpecial(player)) // Spin button effects + { + // Force stop + if ((player->powers[pw_shield] & ~(SH_FORCEHP|SH_STACK)) == SH_FORCE) + { + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + player->mo->momx = player->mo->momy = player->mo->momz = 0; + S_StartSound(player->mo, sfx_ngskid); + } + else + { + switch (player->powers[pw_shield] & SH_NOSTACK) + { + // Whirlwind jump/Thunder jump + case SH_WHIRLWIND: + case SH_THUNDERCOIN: + P_DoJumpShield(player); + break; + // Armageddon pow + case SH_ARMAGEDDON: + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + P_BlackOw(player); + break; + // Attraction blast + case SH_ATTRACT: + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + player->homing = 2; + P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, lockonshield)); + if (lockonshield) + { + player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, lockonshield->x, lockonshield->y); + player->pflags &= ~PF_NOJUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + S_StartSound(player->mo, sfx_s3k40); + player->homing = 3*TICRATE; + } + else + S_StartSound(player->mo, sfx_s3ka6); + break; + // Elemental stomp/Bubble bounce + case SH_ELEMENTAL: + case SH_BUBBLEWRAP: + { + boolean elem = ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL); + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + if (elem) + S_StartSound(player->mo, sfx_s3k43); + else + { + player->pflags &= ~PF_NOJUMPDAMAGE; + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + S_StartSound(player->mo, sfx_s3k44); + } + player->secondjump = 0; + player->mo->momx = player->mo->momy = 0; + P_SetObjectMomZ(player->mo, -24*FRACUNIT, false); + break; + } + // Flame burst + case SH_FLAMEAURA: + player->pflags |= PF_THOKKED|PF_SHIELDABILITY; + P_Thrust(player->mo, player->mo->angle, FixedMul(30*FRACUNIT - FixedSqrt(FixedDiv(player->speed, player->mo->scale)), player->mo->scale)); + player->drawangle = player->mo->angle; + S_StartSound(player->mo, sfx_s3k43); + default: + break; + } + } + } + } + else if ((cmd->buttons & BT_USE)) + { + if (!(player->pflags & PF_USEDOWN) && P_SuperReady(player)) + { + // If you can turn super and aren't already, + // and you don't have a shield, do it! + P_DoSuperTransformation(player, false); + } + else if (!LUAh_JumpSpinSpecial(player)) + switch (player->charability) + { + case CA_THOK: + if (player->powers[pw_super]) // Super Sonic float + { + if ((player->speed > 5*player->mo->scale) // FixedMul(5<mo->scale), but scale is FRACUNIT-based + && (P_MobjFlip(player->mo)*player->mo->momz <= 0)) + { + if (player->panim != PA_RUN && player->panim != PA_WALK) + { + if (player->speed >= FixedMul(player->runspeed, player->mo->scale)) + P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT_RUN); + else + P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT); + } + + player->mo->momz = 0; + player->pflags &= ~(PF_STARTJUMP|PF_SPINNING); + } + } + break; + case CA_TELEKINESIS: + if (!(player->pflags & (PF_THOKKED|PF_USEDOWN)) || (player->charflags & SF_MULTIABILITY)) { P_Telekinesis(player, -FixedMul(player->actionspd, player->mo->scale), // -ve thrust (pulling towards player) FixedMul(384*FRACUNIT, player->mo->scale)); } - } - break; - case CA_AIRDRILL: - if (player->pflags & PF_JUMPED) - { - if (player->pflags & PF_THOKKED) // speed up falling down + break; + case CA_TWINSPIN: + if ((player->charability2 == CA2_MELEE) && (!(player->pflags & (PF_THOKKED|PF_USEDOWN)) || player->charflags & SF_MULTIABILITY)) { - if (player->secondjump < 42) - player->secondjump ++; + player->pflags |= PF_THOKKED; + S_StartSound(player->mo, sfx_s3k42); + player->mo->frame = 0; + P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN); } - } - break; - default: - break; - } + break; + default: + break; + } } } @@ -3957,6 +5249,9 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) { if (player->pflags & PF_JUMPED) { + if (cmd->buttons & BT_USE && player->secondjump < 42) // speed up falling down + player->secondjump++; + if (player->flyangle > 0 && player->pflags & PF_THOKKED) { player->flyangle--; @@ -3969,53 +5264,55 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) P_InstaThrust(player->mo, player->mo->angle, FixedMul(player->normalspeed, player->mo->scale)*(80-player->flyangle - (player->actionspd>>FRACBITS)/2)/80); else P_InstaThrust(player->mo, player->mo->angle, ((FixedMul(player->normalspeed - player->actionspd/4, player->mo->scale))*2)/3); + + player->drawangle = player->mo->angle; } } } + /////////////// + // CHARACTER // + // ABILITIES!// + /////////////// + if (cmd->buttons & BT_JUMP && !player->exiting && !P_PlayerInPain(player)) { -#ifdef HAVE_BLUA if (LUAh_JumpSpecial(player)) ; - else -#endif - if (player->pflags & PF_JUMPDOWN) // all situations below this require jump button not to be pressed already + // all situations below this require jump button not to be pressed already + else if (player->pflags & PF_JUMPDOWN) ; - else // Jump S3&K style while in quicksand. - if (P_InQuicksand(player->mo)) + else if (P_InQuicksand(player->mo)) { P_DoJump(player, true); player->secondjump = 0; player->pflags &= ~PF_THOKKED; } - else - // can't jump while in air, can't jump while jumping - if (onground || player->climbing || player->pflags & (PF_CARRIED|PF_ITEMHANG|PF_ROPEHANG)) + else if (player->powers[pw_carry] == CR_MACESPIN && player->mo->tracer) { - P_DoJump(player, true); - player->secondjump = 0; - player->pflags &= ~PF_THOKKED; - } - else if (player->pflags & PF_MACESPIN && player->mo->tracer) - { - player->pflags &= ~PF_MACESPIN; + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer, NULL); player->powers[pw_flashing] = TICRATE/4; } - else if (player->pflags & PF_SLIDING || (gametype == GT_CTF && player->gotflag)) + // can't jump while in air, can't jump while jumping + else if (onground || player->climbing || player->powers[pw_carry]) + { + P_DoJump(player, true); + player->secondjump = 0; + player->pflags &= ~PF_THOKKED; + } + else if (player->pflags & PF_SLIDING || ((gametyperules & GTR_TEAMFLAGS) && player->gotflag) || player->pflags & PF_SHIELDABILITY) ; - else if (P_SuperReady(player)) + /*else if (P_SuperReady(player)) { // If you can turn super and aren't already, // and you don't have a shield, do it! P_DoSuperTransformation(player, false); - } + }*/ else if (player->pflags & PF_JUMPED) { -#ifdef HAVE_BLUA if (!LUAh_AbilitySpecial(player)) -#endif switch (player->charability) { case CA_THOK: @@ -4023,17 +5320,23 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) case CA_JUMPTHOK: // Credit goes to CZ64 and Sryder13 for the original // Now it's Sonic's abilities turn! // THOK! - if (!(player->pflags & PF_THOKKED) || (player->charability2 == CA2_MULTIABILITY)) + if (!(player->pflags & PF_THOKKED) || (player->charflags & SF_MULTIABILITY)) { // Catapult the player fixed_t actionspd = player->actionspd; + + if (player->charflags & SF_DASHMODE) + actionspd = max(player->normalspeed, FixedDiv(player->speed, player->mo->scale)); + if (player->mo->eflags & MFE_UNDERWATER) actionspd >>= 1; + if ((player->charability == CA_JUMPTHOK) && !(player->pflags & PF_THOKKED)) { player->pflags &= ~PF_JUMPED; P_DoJump(player, false); } + P_InstaThrust(player->mo, player->mo->angle, FixedMul(actionspd, player->mo->scale)); if (maptol & TOL_2D) @@ -4041,88 +5344,121 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->mo->momx /= 2; player->mo->momy /= 2; } - else if (player->charability == CA_HOMINGTHOK) + if (player->charability == CA_HOMINGTHOK) { - player->mo->momx /= 3; - player->mo->momy /= 3; + player->mo->momx /= 2; + player->mo->momy /= 2; } + if (player->charability == CA_HOMINGTHOK) + { + P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, lockonthok)); + if (lockonthok) + { + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, lockonthok->x, lockonthok->y); + player->homing = 3*TICRATE; + } + else + { + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + player->pflags &= ~PF_JUMPED; + player->mo->height = P_GetPlayerHeight(player); + } + player->pflags &= ~PF_NOJUMPDAMAGE; + } + + player->drawangle = player->mo->angle; + if (player->mo->info->attacksound && !player->spectator) S_StartSound(player->mo, player->mo->info->attacksound); // Play the THOK sound P_SpawnThokMobj(player); - if (player->charability == CA_HOMINGTHOK && !player->homing) - { - if (P_LookForEnemies(player)) - { - if (player->mo->tracer) - player->homing = 3*TICRATE; - } - } - player->pflags &= ~(PF_SPINNING|PF_STARTDASH); player->pflags |= PF_THOKKED; + + // Change localangle to match for simple controls? (P.S. chalupa) + // disabled because it seemed to disorient people and Z-targeting exists now + /*if (!demoplayback) + { + if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(gc_turnleft) || PLAYER1INPUTDOWN(gc_turnright))) + localangle = player->mo->angle; + else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(gc_turnleft) || PLAYER2INPUTDOWN(gc_turnright))) + localangle2 = player->mo->angle; + }*/ } break; case CA_FLY: - case CA_SWIM: // Swim + case CA_SWIM: // If currently in the air from a jump, and you pressed the // button again and have the ability to fly, do so! if (player->charability == CA_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) ; // Can't do anything if you're a fish out of water! else if (!(player->pflags & PF_THOKKED) && !(player->powers[pw_tailsfly])) { - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); // Change to the flying animation + P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer - player->pflags &= ~(PF_JUMPED|PF_SPINNING|PF_STARTDASH); - player->pflags |= PF_THOKKED; + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING|PF_STARTDASH); + if (player->bot == 1) + player->pflags |= PF_THOKKED; + else + player->pflags |= (PF_THOKKED|PF_CANCARRY); } break; case CA_GLIDEANDCLIMB: // Now Knuckles-type abilities are checked. - // If you can turn super and aren't already, - // and you don't have a shield, do it! - if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY) + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) { - INT32 glidespeed = player->actionspd; + fixed_t glidespeed = FixedMul(player->actionspd, player->mo->scale); + fixed_t playerspeed = player->speed; + + if (player->mo->eflags & MFE_UNDERWATER) + { + glidespeed >>= 1; + playerspeed >>= 1; + player->mo->momx = ((player->mo->momx - player->cmomx) >> 1) + player->cmomx; + player->mo->momy = ((player->mo->momy - player->cmomy) >> 1) + player->cmomy; + } player->pflags |= PF_GLIDING|PF_THOKKED; player->glidetime = 0; - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - { - // Glide at double speed while super. - glidespeed *= 2; - player->pflags &= ~PF_THOKKED; - } - - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - P_InstaThrust(player->mo, player->mo->angle, FixedMul(glidespeed, player->mo->scale)); + P_SetPlayerMobjState(player->mo, S_PLAY_GLIDE); + if (playerspeed < glidespeed) + P_Thrust(player->mo, player->mo->angle, glidespeed - playerspeed); player->pflags &= ~(PF_SPINNING|PF_STARTDASH); } break; case CA_DOUBLEJUMP: // Double-Jump - if (!(player->pflags & PF_THOKKED)) + if (!(player->pflags & PF_THOKKED) || ((player->charflags & SF_MULTIABILITY) && (player->secondjump < (player->actionspd >> FRACBITS)))) { + player->pflags |= PF_THOKKED; player->pflags &= ~PF_JUMPED; P_DoJump(player, true); - - // Allow infinite double jumping if super. - if (!player->powers[pw_super]) - player->pflags |= PF_THOKKED; + player->secondjump++; } break; case CA_FLOAT: // Float case CA_SLOWFALL: // Slow descent hover - if (!player->secondjump) + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) + { + if (player->charflags & SF_DASHMODE && player->dashmode >= DASHMODE_THRESHOLD) + P_SetPlayerMobjState(player->mo, S_PLAY_DASH); + else if (player->speed >= FixedMul(player->runspeed, player->mo->scale)) + P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT_RUN); + else + P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT); + player->pflags |= PF_THOKKED; + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE|PF_SPINNING); player->secondjump = 1; + } break; case CA_TELEKINESIS: - if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY) + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) { P_Telekinesis(player, FixedMul(player->actionspd, player->mo->scale), // +ve thrust (pushing away from player) @@ -4130,80 +5466,145 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) } break; case CA_FALLSWITCH: - if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY) + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) { player->mo->momz = -player->mo->momz; P_SpawnThokMobj(player); player->pflags |= PF_THOKKED; } break; - case CA_AIRDRILL: - if (!(player->pflags & PF_THOKKED) || player->charability2 == CA2_MULTIABILITY) + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) { player->flyangle = 56 + (60-(player->actionspd>>FRACBITS))/3; player->pflags |= PF_THOKKED; S_StartSound(player->mo, sfx_spndsh); } break; + case CA_BOUNCE: + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) + { + P_SetPlayerMobjState(player->mo, S_PLAY_BOUNCE); + player->pflags &= ~(PF_JUMPED|PF_NOJUMPDAMAGE); + player->pflags |= PF_THOKKED|PF_BOUNCING; + player->mo->momx >>= 1; + player->mo->momy >>= 1; + player->mo->momz >>= 1; + } + break; + case CA_TWINSPIN: + if (!(player->pflags & PF_THOKKED) || player->charflags & SF_MULTIABILITY) + { + player->pflags |= PF_THOKKED; + S_StartSound(player->mo, sfx_s3k42); + player->mo->frame = 0; + P_SetPlayerMobjState(player->mo, S_PLAY_TWINSPIN); + } + break; default: break; } } else if (player->pflags & PF_THOKKED) { -#ifdef HAVE_BLUA if (!LUAh_AbilitySpecial(player)) -#endif - switch (player->charability) - { - case CA_FLY: - case CA_SWIM: // Swim - if (player->charability == CA_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) - ; // Can't do anything if you're a fish out of water! - else if (player->powers[pw_tailsfly]) // If currently flying, give an ascend boost. - { - if (!player->fly1) + switch (player->charability) + { + case CA_FLY: + case CA_SWIM: // Swim + if (player->charability == CA_SWIM && !(player->mo->eflags & MFE_UNDERWATER)) + ; // Can't do anything if you're a fish out of water! + else if (player->powers[pw_tailsfly]) // If currently flying, give an ascend boost. + { player->fly1 = 20; - else - player->fly1 = 2; - if (player->charability == CA_SWIM) - player->fly1 /= 2; + if (player->charability == CA_SWIM) + player->fly1 /= 2; - // Slow down! - if (player->speed > FixedMul(8*FRACUNIT, player->mo->scale) && player->speed > FixedMul(player->normalspeed>>1, player->mo->scale)) - P_Thrust(player->mo, R_PointToAngle2(0,0,player->mo->momx,player->mo->momy), FixedMul(-4*FRACUNIT, player->mo->scale)); - } - break; - default: - break; - } + // Slow down! + if (player->speed > FixedMul(8*FRACUNIT, player->mo->scale) && player->speed > FixedMul(player->normalspeed>>1, player->mo->scale)) + P_Thrust(player->mo, R_PointToAngle2(0,0,player->mo->momx,player->mo->momy), FixedMul(-4*FRACUNIT, player->mo->scale)); + } + break; + default: + break; + } } - else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_JUMP && !player->powers[pw_super]) + else if ((player->powers[pw_shield] & SH_NOSTACK) == SH_WHIRLWIND && !player->powers[pw_super]) P_DoJumpShield(player); } + // HOMING option. + if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT // Sonic 3D Blast. + && player->pflags & PF_SHIELDABILITY) + { + if (player->homing && player->mo->tracer) + { + if (!P_HomingAttack(player->mo, player->mo->tracer)) + { + P_SetObjectMomZ(player->mo, 6*FRACUNIT, false); + if (player->mo->eflags & MFE_UNDERWATER) + player->mo->momz = FixedMul(player->mo->momz, FRACUNIT/3); + player->homing = 0; + } + } + + // If you're not jumping, then you obviously wouldn't be homing. + if (!(player->pflags & PF_JUMPED)) + player->homing = 0; + } + else if (player->charability == CA_HOMINGTHOK) // Sonic Adventure. + { + // If you've got a target, chase after it! + if (player->homing && player->mo->tracer) + { + P_SpawnThokMobj(player); + + // But if you don't, then stop homing. + if (!P_HomingAttack(player->mo, player->mo->tracer)) + { + if (player->mo->eflags & MFE_UNDERWATER) + P_SetObjectMomZ(player->mo, FixedDiv(457*FRACUNIT,72*FRACUNIT), false); + else + P_SetObjectMomZ(player->mo, 10*FRACUNIT, false); + + player->mo->momx = player->mo->momy = player->homing = 0; + + if (player->mo->tracer->flags2 & MF2_FRET) + P_InstaThrust(player->mo, player->mo->angle, -(player->speed>>3)); + + if (!(player->mo->tracer->flags & MF_BOSS)) + player->pflags &= ~PF_THOKKED; + + P_SetPlayerMobjState(player->mo, S_PLAY_SPRING); + player->pflags |= PF_NOJUMPDAMAGE; + } + } + + // If you're not jumping, then you obviously wouldn't be homing. + if (!(player->pflags & PF_JUMPED)) + player->homing = 0; + } + else + player->homing = 0; + if (cmd->buttons & BT_JUMP) { player->pflags |= PF_JUMPDOWN; - if ((gametype != GT_CTF || !player->gotflag) && !player->exiting) + if ((!(gametyperules & GTR_TEAMFLAGS) || !player->gotflag) && !player->exiting) { - if (player->secondjump == 1) + if (player->secondjump == 1 && player->charability != CA_DOUBLEJUMP) { - if (player->charability == CA_FLOAT) - player->mo->momz = 0; - else if (player->charability == CA_SLOWFALL) - { - if (player->powers[pw_super]) - { - if (P_MobjFlip(player->mo)*player->mo->momz < gravity*16) - player->mo->momz = P_MobjFlip(player->mo)*gravity*16; //Float upward 4x as fast while super. - } - else if (P_MobjFlip(player->mo)*player->mo->momz < -gravity*4) - player->mo->momz = P_MobjFlip(player->mo)*-gravity*4; - } + fixed_t potentialmomz; + if (player->charability == CA_SLOWFALL) + potentialmomz = -gravity*4; + else + potentialmomz = ((player->speed < 10*player->mo->scale) + ? (player->speed - 10*player->mo->scale)/5 + : -1); // Should be 0, but made negative to ensure P_PlayerHitFloor runs upon touching ground + if (P_MobjFlip(player->mo)*player->mo->momz < potentialmomz) + player->mo->momz = P_MobjFlip(player->mo)*potentialmomz; player->pflags &= ~PF_SPINNING; } } @@ -4213,27 +5614,28 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->pflags &= ~PF_JUMPDOWN; // Repeat abilities, but not double jump! - if ((player->charability2 == CA2_MULTIABILITY && player->charability != CA_DOUBLEJUMP) - || (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) - player->secondjump = 0; - else if (player->charability == CA_FLOAT && player->secondjump == 1) - player->secondjump = 2; + if (player->secondjump == 1 && player->charability != CA_DOUBLEJUMP && player->charability != CA_AIRDRILL) + { + if (player->charflags & SF_MULTIABILITY) + { + player->pflags |= (PF_JUMPED|PF_NOJUMPDAMAGE); + player->secondjump = 0; + } + else + player->secondjump = 2; + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + } // If letting go of the jump button while still on ascent, cut the jump height. - if (player->pflags & PF_JUMPED && P_MobjFlip(player->mo)*player->mo->momz > 0 && player->jumping == 1) + if (((player->pflags & (PF_JUMPED|PF_STARTJUMP)) == (PF_JUMPED|PF_STARTJUMP)) && (P_MobjFlip(player->mo)*player->mo->momz > 0)) { player->mo->momz >>= 1; - player->jumping = 0; + player->pflags &= ~PF_STARTJUMP; } } } -boolean P_AnalogMove(player_t *player) -{ - return player->pflags & PF_ANALOGMODE; -} - // // P_GetPlayerControlDirection // @@ -4272,7 +5674,7 @@ INT32 P_GetPlayerControlDirection(player_t *player) origtempangle = tempangle = 0; // relative to the axis rather than the player! controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); } - else if (P_AnalogMove(player) && thiscam->chase) + else if ((P_ControlStyle(player) & CS_LMAOGALOG) && thiscam->chase) { if (player->awayviewtics) origtempangle = tempangle = player->awayviewmobj->angle; @@ -4334,10 +5736,12 @@ static void P_2dMovement(player_t *player) else if (player->exiting) { player->pflags &= ~PF_GLIDING; - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); player->skidtime = 0; } } + if (player->pflags & PF_BOUNCING) + player->pflags &= ~PF_BOUNCING; if (player->pflags & PF_SPINNING && !player->exiting) { player->pflags &= ~PF_SPINNING; @@ -4456,10 +5860,7 @@ static void P_2dMovement(player_t *player) if (player->climbing) { if (cmd->forwardmove != 0) - P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT,10*FRACUNIT), false); - - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - player->mo->momz *= 2; + P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT, 15*FRACUNIT>>1), false); player->mo->momx = 0; } @@ -4473,7 +5874,7 @@ static void P_2dMovement(player_t *player) movepushforward >>= 1; // Proper air movement // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) + if ((player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING) { if (!(player->pflags & PF_STARTDASH)) movepushforward = movepushforward/48; @@ -4499,7 +5900,8 @@ static void P_3dMovement(player_t *player) INT32 mforward = 0, mbackward = 0; angle_t dangle; // replaces old quadrants bits fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale); - boolean analogmove = false; + controlstyle_e controlstyle; + boolean spin = ((onground = P_IsObjectOnGround(player->mo)) && (player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING && (player->rmomx || player->rmomy) && !(player->pflags & PF_STARTDASH)); fixed_t oldMagnitude, newMagnitude; #ifdef ESLOPE vector3_t totalthrust; @@ -4511,7 +5913,7 @@ static void P_3dMovement(player_t *player) // Get the old momentum; this will be needed at the end of the function! -SH oldMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0); - analogmove = P_AnalogMove(player); + controlstyle = P_ControlStyle(player); cmd = &player->cmd; @@ -4525,10 +5927,12 @@ static void P_3dMovement(player_t *player) else if (player->exiting) { player->pflags &= ~PF_GLIDING; - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); player->skidtime = 0; } } + if (player->pflags & PF_BOUNCING) + player->pflags &= ~PF_BOUNCING; if (player->pflags & PF_SPINNING && !player->exiting) { player->pflags &= ~PF_SPINNING; @@ -4536,7 +5940,7 @@ static void P_3dMovement(player_t *player) } } - if (analogmove) + if (controlstyle & CS_LMAOGALOG) { movepushangle = (cmd->angleturn<<16 /* not FRACBITS */); } @@ -4586,9 +5990,8 @@ static void P_3dMovement(player_t *player) // When sliding, don't allow forward/back if (player->pflags & PF_SLIDING) cmd->forwardmove = 0; - - // Do not let the player control movement if not onground. - onground = P_IsObjectOnGround(player->mo); + else if (onground && player->mo->state == states+S_PLAY_PAIN) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); player->aiming = cmd->aiming<powers[pw_super] || player->powers[pw_sneakers]) - { - thrustfactor = player->thrustfactor*2; - acceleration = player->accelstart/2 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration/2; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd * 2; - } else { - thrustfactor = player->thrustfactor; - acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) + if (player->powers[pw_super] || player->powers[pw_sneakers]) { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; + topspeed = 5 * normalspd / 3; // 1.67x + thrustfactor = player->thrustfactor*2; + acceleration = player->accelstart/2 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration/2; } else + { topspeed = normalspd; + thrustfactor = player->thrustfactor; + acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; + } + + if (player->powers[pw_tailsfly]) + topspeed >>= 1; + else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) + { + topspeed >>= 1; + acceleration = 2*acceleration/3; + } + } + + if (spin) // Prevent gaining speed whilst rolling! + { + const fixed_t ns = FixedDiv(549*ORIG_FRICTION,500*FRACUNIT); // P_XYFriction + topspeed = FixedMul(oldMagnitude, ns); } // Better maneuverability while flying - if(player->powers[pw_tailsfly]) + if (player->powers[pw_tailsfly]) { thrustfactor = player->thrustfactor*2; acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; } + else + { + if (player->pflags & PF_BOUNCING) + { + if (player->mo->state-states == S_PLAY_BOUNCE_LANDING) + { + thrustfactor = player->thrustfactor*8; + acceleration = player->accelstart/8 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration/8; + } + else + { + thrustfactor = (3*player->thrustfactor)/4; + acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; + } + } + + if (player->mo->movefactor != FRACUNIT) // Friction-scaled acceleration... + acceleration = FixedMul(acceleration<mo->movefactor)>>FRACBITS; + } // Forward movement if (player->climbing) { if (cmd->forwardmove) { - P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT, 10*FRACUNIT), false); - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - player->mo->momz *= 2; + if (player->mo->eflags & MFE_UNDERWATER) + P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT, 10*FRACUNIT), false); + else + P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT, 15*FRACUNIT>>1), false); } } - else if (!analogmove + else if (!(controlstyle == CS_LMAOGALOG) && cmd->forwardmove != 0 && !(player->pflags & PF_GLIDING || player->exiting || (P_PlayerInPain(player) && !onground))) { movepushforward = cmd->forwardmove * (thrustfactor * acceleration); - // allow very small movement while in air for gameplay - if (!onground) - movepushforward >>= 2; // proper air movement - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) + if ((player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING) { - if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0)) + if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0) + || (player->pflags & PF_STARTDASH)) movepushforward = 0; - else if (!(player->pflags & PF_STARTDASH)) - movepushforward = FixedDiv(movepushforward, 16*FRACUNIT); + else if (onground) + movepushforward >>= 4; else - movepushforward = 0; + movepushforward >>= 3; } + // allow very small movement while in air for gameplay + else if (!onground) + movepushforward >>= 2; // proper air movement movepushforward = FixedMul(movepushforward, player->mo->scale); @@ -4697,13 +6119,13 @@ static void P_3dMovement(player_t *player) // Sideways movement if (player->climbing) { - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedMul(FixedDiv(cmd->sidemove*FRACUNIT, 5*FRACUNIT), player->mo->scale)); + if (player->mo->eflags & MFE_UNDERWATER) + P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedDiv(cmd->sidemove*player->mo->scale, 10*FRACUNIT)); else - P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedMul(FixedDiv(cmd->sidemove*FRACUNIT, 10*FRACUNIT), player->mo->scale)); + P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedDiv(cmd->sidemove*player->mo->scale, 15*FRACUNIT>>1)); } // Analog movement control - else if (analogmove) + else if (controlstyle == CS_LMAOGALOG) { if (!(player->pflags & PF_GLIDING || player->exiting || P_PlayerInPain(player))) { @@ -4714,24 +6136,22 @@ static void P_3dMovement(player_t *player) // (Why was it so complicated before? ~Red) controldirection = R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT)+movepushangle; - movepushforward = max(abs(cmd->sidemove), abs(cmd->forwardmove)) * (thrustfactor * acceleration); - - // allow very small movement while in air for gameplay - if (!onground) - movepushforward >>= 2; // proper air movement + movepushforward = FixedHypot(cmd->sidemove, cmd->forwardmove) * (thrustfactor * acceleration); // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) + if ((player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING) { - // Stupid little movement prohibitor hack - // that REALLY shouldn't belong in analog code. - if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0)) + if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0) + || (player->pflags & PF_STARTDASH)) movepushforward = 0; - else if (!(player->pflags & PF_STARTDASH)) - movepushforward = FixedDiv(movepushforward, 16*FRACUNIT); + else if (onground) + movepushforward >>= 4; else - movepushforward = 0; + movepushforward >>= 3; } + // allow very small movement while in air for gameplay + else if (!onground) + movepushforward >>= 2; // proper air movement movepushsideangle = controldirection; @@ -4749,25 +6169,26 @@ static void P_3dMovement(player_t *player) { movepushside = cmd->sidemove * (thrustfactor * acceleration); + // allow very small movement while in air for gameplay if (!onground) { - movepushside >>= 2; - + movepushside >>= 2; // proper air movement // Reduce movepushslide even more if over "max" flight speed - if (player->powers[pw_tailsfly] && player->speed > topspeed) + if (((player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING) || (player->powers[pw_tailsfly] && player->speed > topspeed)) movepushside >>= 2; } - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) + else if ((player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING) { - if (!(player->pflags & PF_STARTDASH)) - movepushside = FixedDiv(movepushside,16*FRACUNIT); - else + if (player->pflags & PF_STARTDASH) movepushside = 0; + else if (onground) + movepushside >>= 4; + else + movepushside >>= 3; } - // Finally move the player now that his speed/direction has been decided. + // Finally move the player now that their speed/direction has been decided. movepushside = FixedMul(movepushside, player->mo->scale); #ifdef ESLOPE @@ -4814,7 +6235,7 @@ static void P_3dMovement(player_t *player) if (newMagnitude > topspeed) { fixed_t tempmomx, tempmomy; - if (oldMagnitude > topspeed) + if (oldMagnitude > topspeed && !spin) { if (newMagnitude > oldMagnitude) { @@ -4850,16 +6271,16 @@ static void P_SpectatorMovement(player_t *player) if (!(cmd->angleturn & TICCMD_RECEIVED)) ticmiss++; - if (player->mo->z > player->mo->ceilingz - player->mo->height) - player->mo->z = player->mo->ceilingz - player->mo->height; - if (player->mo->z < player->mo->floorz) - player->mo->z = player->mo->floorz; - if (cmd->buttons & BT_JUMP) player->mo->z += FRACUNIT*16; else if (cmd->buttons & BT_USE) player->mo->z -= FRACUNIT*16; + if (player->mo->z > player->mo->ceilingz - player->mo->height) + player->mo->z = player->mo->ceilingz - player->mo->height; + if (player->mo->z < player->mo->floorz) + player->mo->z = player->mo->floorz; + // Aiming needed for SEENAMES, etc. // We may not need to fire as a spectator, but this is still handy! player->aiming = cmd->aiming<exiting) return; - // You're welcome, Rob. (Now with slightly less horrendous hacking -Red - player->mo->tracer->flags &= ~MF_NOCLIP; - player->mo->tracer->z = player->mo->z; - if (!P_TryMove(player->mo->tracer, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, true)) { - player->mo->tracer->flags |= MF_NOCLIP; - return; + { + boolean notallowed; + mobj_t *hack = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_NULL); + hack->flags = MF_NOGRAVITY; + hack->radius = player->mo->radius; + hack->height = player->mo->height; + hack->z = player->mo->z; + P_SetThingPosition(hack); + notallowed = (!(P_TryMove(hack, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, true))); + P_RemoveMobj(hack); + if (notallowed) + return; } - player->mo->tracer->flags |= MF_NOCLIP; + { const INT32 sequence = player->mo->target->threshold; mobj_t *transfer1 = NULL; @@ -4984,12 +6411,12 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad boolean transfer1last = false; boolean transfer2last = false; vertex_t vertices[4]; - fixed_t truexspeed = xspeed*(!(player->pflags & PF_TRANSFERTOCLOSEST) && player->mo->target->flags & MF_AMBUSH ? -1 : 1); + fixed_t truexspeed = xspeed*(!(player->pflags & PF_TRANSFERTOCLOSEST) && player->mo->target->flags2 & MF2_AMBUSH ? -1 : 1); // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -4997,24 +6424,24 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad // Axis things are only at beginning of list. if (!(mo2->flags2 & MF2_AXIS)) break; + if (!(mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) + continue; + if (mo2->threshold != sequence) + continue; - if ((mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE) - && mo2->threshold == sequence) + if (player->pflags & PF_TRANSFERTOCLOSEST) { - if (player->pflags & PF_TRANSFERTOCLOSEST) - { - if (mo2->health == player->axis1->health) - transfer1 = mo2; - else if (mo2->health == player->axis2->health) - transfer2 = mo2; - } - else - { - if (mo2->health == player->mo->target->health) - transfer1 = mo2; - else if (mo2->health == player->mo->target->health + 1) - transfer2 = mo2; - } + if (mo2->health == player->axis1->health) + transfer1 = mo2; + else if (mo2->health == player->axis2->health) + transfer2 = mo2; + } + else + { + if (mo2->health == player->mo->target->health) + transfer1 = mo2; + else if (mo2->health == player->mo->target->health + 1) + transfer2 = mo2; } } @@ -5023,9 +6450,9 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad // Look for a wrapper point. if (!transfer1) { - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -5033,27 +6460,28 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad // Axis things are only at beginning of list. if (!(mo2->flags2 & MF2_AXIS)) break; + if (!(mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) + continue; + if (mo2->threshold != sequence) + continue; - if (mo2->threshold == sequence && (mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) + if (!transfer1) { - if (!transfer1) - { - transfer1 = mo2; - transfer1last = true; - } - else if (mo2->health > transfer1->health) - { - transfer1 = mo2; - transfer1last = true; - } + transfer1 = mo2; + transfer1last = true; + } + else if (mo2->health > transfer1->health) + { + transfer1 = mo2; + transfer1last = true; } } } if (!transfer2) { - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -5061,19 +6489,20 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad // Axis things are only at beginning of list. if (!(mo2->flags2 & MF2_AXIS)) break; + if (!(mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) + continue; + if (mo2->threshold != sequence) + continue; - if (mo2->threshold == sequence && (mo2->type == MT_AXISTRANSFER || mo2->type == MT_AXISTRANSFERLINE)) + if (!transfer2) { - if (!transfer2) - { - transfer2 = mo2; - transfer2last = true; - } - else if (mo2->health > transfer2->health) - { - transfer2 = mo2; - transfer2last = true; - } + transfer2 = mo2; + transfer2last = true; + } + else if (mo2->health > transfer2->health) + { + transfer2 = mo2; + transfer2last = true; } } } @@ -5359,13 +6788,10 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad // static void P_DoNiGHTSCapsule(player_t *player) { - INT32 i; + INT32 i, spherecount, totalduration, popduration, deductinterval, deductquantity, sphereresult, firstpoptic, startingspheres; + INT32 tictimer = ++player->capsule->extravalue2; - if ((player->pflags & PF_NIGHTSMODE) && (player->mo->tracer->state < &states[S_NIGHTSHURT1] - || player->mo->tracer->state > &states[S_NIGHTSHURT32])) - P_SetMobjState(player->mo->tracer, S_NIGHTSHURT1); - - if (abs(player->mo->x-player->capsule->x) <= 2*FRACUNIT) + if (abs(player->mo->x-player->capsule->x) <= 3*FRACUNIT) { P_UnsetThingPosition(player->mo); player->mo->x = player->capsule->x; @@ -5373,7 +6799,7 @@ static void P_DoNiGHTSCapsule(player_t *player) player->mo->momx = 0; } - if (abs(player->mo->y-player->capsule->y) <= 2*FRACUNIT) + if (abs(player->mo->y-player->capsule->y) <= 3*FRACUNIT) { P_UnsetThingPosition(player->mo); player->mo->y = player->capsule->y; @@ -5381,64 +6807,151 @@ static void P_DoNiGHTSCapsule(player_t *player) player->mo->momy = 0; } - if (abs(player->mo->z - (player->capsule->z+(player->capsule->height/3))) <= 2*FRACUNIT) + if (abs(player->mo->z - (player->capsule->z+(player->capsule->height/3))) <= 3*FRACUNIT) { player->mo->z = player->capsule->z+(player->capsule->height/3); player->mo->momz = 0; } if (player->mo->x > player->capsule->x) - player->mo->momx = -2*FRACUNIT; + player->mo->momx = -3*FRACUNIT; else if (player->mo->x < player->capsule->x) - player->mo->momx = 2*FRACUNIT; + player->mo->momx = 3*FRACUNIT; if (player->mo->y > player->capsule->y) - player->mo->momy = -2*FRACUNIT; + player->mo->momy = -3*FRACUNIT; else if (player->mo->y < player->capsule->y) - player->mo->momy = 2*FRACUNIT; + player->mo->momy = 3*FRACUNIT; if (player->mo->z > player->capsule->z+(player->capsule->height/3)) - player->mo->momz = -2*FRACUNIT; + player->mo->momz = -3*FRACUNIT; else if (player->mo->z < player->capsule->z+(player->capsule->height/3)) - player->mo->momz = 2*FRACUNIT; + player->mo->momz = 3*FRACUNIT; + + if (player->powers[pw_carry] == CR_NIGHTSMODE) + { + if (player->mo->momx || player->mo->momy || player->mo->momz) + { + if (player->mo->state != &states[S_PLAY_NIGHTS_PULL]) + P_SetPlayerMobjState(player->mo, S_PLAY_NIGHTS_PULL); + } + else if (player->mo->state != &states[S_PLAY_NIGHTS_ATTACK]) + { + S_StartSound(player->mo, sfx_spin); + P_SetPlayerMobjState(player->mo, S_PLAY_NIGHTS_ATTACK); + } + } + else + { + if (!(player->pflags & PF_JUMPED) && !(player->pflags & PF_SPINNING)) + player->pflags |= PF_JUMPED; + if (player->panim != PA_ROLL) + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); + } + + if (!(player->charflags & SF_NONIGHTSROTATION)) + { + if ((player->mo->state == &states[S_PLAY_NIGHTS_PULL]) + && (player->mo->sprite2 == SPR2_NPUL)) + player->mo->rollangle -= ANG30; + else + player->mo->rollangle = 0; + } if (G_IsSpecialStage(gamemap)) { // In special stages, share rings. Everyone gives up theirs to the capsule player always, because we can't have any individualism here! for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (&players[i] != player) && players[i].mo->health > 1) + if (playeringame[i] && (&players[i] != player) && players[i].spheres > 0) { - player->mo->health += players[i].mo->health-1; - player->health = player->mo->health; - players[i].mo->health = 1; - players[i].health = players[i].mo->health; + player->spheres += players[i].spheres; + players[i].spheres = 0; } } + if (player->capsule->extravalue2 <= 0 && player->capsule->health > 0) + P_RunNightsCapsuleTouchExecutors(player->mo, true, player->spheres >= player->capsule->health); // run capsule entrance executors + // Time to blow it up! if (player->mo->x == player->capsule->x && player->mo->y == player->capsule->y && player->mo->z == player->capsule->z+(player->capsule->height/3)) { - if (player->mo->health > 1) + if (player->capsule->lastlook < 0) { - player->mo->health--; - player->health--; - player->capsule->health--; - player->capsule->extravalue1++; + // Stretch the sphere deduction across the capsule time! + // 1. Force the remaining capsule time to `popduration` + // 2. Given `popduration` and `spherecount`, at what tic interval do we deduct spheres? `deductinterval` + // 3. And on each deduction, how many spheres do we deduct? `deductquantity` + // 4. Store the expected capsule health upon completion: `sphereresult` + spherecount = min(player->spheres, player->capsule->health); + totalduration = min(40 + spherecount, 60); - // Spawn a 'pop' for every 5 rings you deposit - if (!(player->capsule->extravalue1 % 5)) + popduration = player->capsule->extravalue1 = max(totalduration - tictimer, 1); + deductinterval = player->capsule->cvmem = max(FixedFloor(FixedDiv(popduration, spherecount))/FRACUNIT, 1); + deductquantity = player->capsule->cusval = max(FixedRound(FixedDiv(spherecount, popduration))/FRACUNIT, 1); + sphereresult = player->capsule->movecount = player->capsule->health - spherecount; + firstpoptic = player->capsule->lastlook = tictimer; + } + else + { + popduration = player->capsule->extravalue1; + deductinterval = player->capsule->cvmem; + deductquantity = player->capsule->cusval; + sphereresult = player->capsule->movecount; + firstpoptic = player->capsule->lastlook; + } + + if (tictimer - firstpoptic < popduration) + { + if (!((tictimer - firstpoptic) % deductinterval)) + { + // Did you somehow get more spheres during destruct? + if (player->capsule->health <= sphereresult && player->spheres > 0 && player->capsule->health > 0) + sphereresult = max(sphereresult - player->spheres, 0); + + if (player->capsule->health > sphereresult && player->spheres > 0) + { + player->spheres -= deductquantity; + player->capsule->health -= deductquantity; + } + + if (player->spheres < 0) + player->spheres = 0; + + if (player->capsule->health < sphereresult) + player->capsule->health = sphereresult; + } + + // Spawn a 'pop' for every 2 tics + if (!((tictimer - firstpoptic) % 2)) S_StartSound(P_SpawnMobj(player->capsule->x + ((P_SignedRandom()/2)<capsule->y + ((P_SignedRandom()/2)<capsule->z + (player->capsule->height/2) + ((P_SignedRandom()/2)<spheres != 0 && player->capsule->health > 0) + { + if (player->spheres < player->capsule->health) + { + player->capsule->health -= player->spheres; + player->spheres = 0; + } + else + { + startingspheres = player->spheres - player->capsule->health; + player->capsule->health = 0; + player->spheres = startingspheres; + } + } if (player->capsule->health <= 0) { player->capsule->flags &= ~MF_NOGRAVITY; player->capsule->momz = 5*FRACUNIT; player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; + tictimer = -1; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && !player->exiting && players[i].mare == player->mare) @@ -5454,9 +6967,6 @@ static void P_DoNiGHTSCapsule(player_t *player) if (G_IsSpecialStage(gamemap)) { - // The Chaos Emerald begins to orbit us! - mobj_t *emmo; - UINT8 em = P_GetNextEmerald(); tic_t lowest_time; /*for (i = 0; i < MAXPLAYERS; i++) @@ -5469,13 +6979,16 @@ static void P_DoNiGHTSCapsule(player_t *player) P_SetMobjState(emmo, mobjinfo[MT_GOTEMERALD].meleestate + em); }*/ - if (player->mo->tracer) + if (player->powers[pw_carry] == CR_NIGHTSMODE) { + // The Chaos Emerald begins to orbit us! + UINT8 em = P_GetNextEmerald(); // Only give it to ONE person, and THAT player has to get to the goal! - emmo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->info->height, MT_GOTEMERALD); + mobj_t *emmo = P_SpawnMobjFromMobj(player->mo, 0, 0, player->mo->height, MT_GOTEMERALD); + emmo->health = em; // for identification P_SetTarget(&emmo->target, player->mo); P_SetMobjState(emmo, mobjinfo[MT_GOTEMERALD].meleestate + em); - P_SetTarget(&player->mo->tracer->target, emmo); + P_SetTarget(&player->mo->tracer, emmo); } // Okay, we're doing this down here because we're handling time weirdly for co-op special stages @@ -5483,36 +6996,106 @@ static void P_DoNiGHTSCapsule(player_t *player) // Find the player with the lowest time remaining and award points based on that time instead. lowest_time = player->finishedtime; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) if (players[i].finishedtime < lowest_time) lowest_time = players[i].finishedtime; P_AddPlayerScore(player, (lowest_time/TICRATE) * 100); } else { - fixed_t z; + /*for (i = 0; i < 16; i++) + { + mobj_t *flicky = P_InternalFlickySpawn(player->capsule, 0, ((i%4) + 1)*2*FRACUNIT, true, 0); + flicky->z += player->capsule->height/2; + flicky->angle = (i*(ANGLE_MAX/16)); + P_InstaThrust(flicky, flicky->angle, 8*FRACUNIT); + }*/ + mobj_t *idya = P_SpawnMobjFromMobj(player->mo, 0, 0, player->mo->height, MT_GOTEMERALD); + idya->extravalue2 = player->mare/5; + idya->health = player->mare + 1; // for identification + P_SetTarget(&idya->target, player->mo); + P_SetMobjState(idya, mobjinfo[MT_GOTEMERALD].missilestate + ((player->mare + 1) % 5)); - z = player->capsule->z + player->capsule->height/2; - for (i = 0; i < 16; i++) - P_SpawnMobj(player->capsule->x, player->capsule->y, z, MT_BIRD); + if (player->mo->tracer) + { + P_SetTarget(&idya->hnext, player->mo->tracer); + idya->extravalue1 = (angle_t)(player->mo->tracer->extravalue1 - 72*ANG1); + if (idya->extravalue1 > player->mo->tracer->extravalue1) + idya->extravalue1 -= (72*ANG1)/idya->extravalue1; + } + P_SetTarget(&player->mo->tracer, idya); } for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i] && players[i].mare == player->mare) P_SetTarget(&players[i].capsule, NULL); // Remove capsule from everyone now that it is dead! S_StartScreamSound(player->mo, sfx_ngdone); + P_SwitchSpheresBonusMode(true); + P_RunNightsCapsuleTouchExecutors(player->mo, false, true); // run capsule exit executors, and we destroyed it + } + else + { + S_StartScreamSound(player->mo, sfx_lose); + player->texttimer = 4*TICRATE; + player->textvar = 3; // Get more rings! + player->capsule->reactiontime = 0; + player->capsule->extravalue1 = player->capsule->cvmem =\ + player->capsule->cusval = player->capsule->movecount =\ + player->capsule->lastlook = player->capsule->extravalue2 = -1; + P_RunNightsCapsuleTouchExecutors(player->mo, false, false); // run capsule exit executors, and we lacked rings } } + } + else if (player->capsule->lastlook > -1) + // We somehow moved out of the capsule (OBJECTPLACE?) + // So recalculate all the timings + player->capsule->lastlook = player->capsule->extravalue2 = -1; +} + +// +// P_MoveNiGHTSToDrone +// +// Pull NiGHTS to the drone during Nightserizing +// +static void P_MoveNiGHTSToDrone(player_t *player) +{ + boolean flip, topaligned, middlealigned, bottomoffsetted; + fixed_t droneboxmandiff, zofs; + + if (!player->drone) + return; + + flip = player->drone->flags2 & MF2_OBJECTFLIP; + topaligned = (player->drone->flags & MF_SLIDEME) && !(player->drone->flags & MF_GRENADEBOUNCE); + middlealigned = (player->drone->flags & MF_GRENADEBOUNCE) && !(player->drone->flags & MF_SLIDEME); + bottomoffsetted = !(player->drone->flags & MF_SLIDEME) && !(player->drone->flags & MF_GRENADEBOUNCE); + droneboxmandiff = max(player->drone->height - player->mo->height, 0); + + if (!flip) + { + if (topaligned) + zofs = droneboxmandiff; + else if (middlealigned) + zofs = droneboxmandiff / 2; + else if (bottomoffsetted) + zofs = FixedMul(24*FRACUNIT, player->drone->scale); else - { - S_StartScreamSound(player->mo, sfx_lose); - player->texttimer = 4*TICRATE; - player->textvar = 3; // Get more rings! - player->capsule->reactiontime = 0; - player->capsule->extravalue1 = -1; - } + zofs = 0; } else - player->capsule->extravalue1 = -1; + { + if (topaligned) + zofs = 0; + else if (middlealigned) + zofs = droneboxmandiff / 2; + else if (bottomoffsetted) + zofs = droneboxmandiff - FixedMul(24*FRACUNIT, player->drone->scale); + else + zofs = droneboxmandiff; + } + + player->mo->momx = player->mo->momy = player->mo->momz = 0; + P_TeleportMove(player->mo, player->drone->x, player->drone->y, player->drone->z + zofs); + P_SetTarget(&player->drone, NULL); } // @@ -5534,7 +7117,9 @@ static void P_NiGHTSMovement(player_t *player) ticcmd_t *cmd = &player->cmd; INT32 thrustfactor; INT32 i; - statenum_t flystate = S_NIGHTSFLY1A; + statenum_t flystate; + UINT16 visangle; + angle_t rollangle = 0; player->pflags &= ~PF_DRILLING; @@ -5553,7 +7138,7 @@ static void P_NiGHTSMovement(player_t *player) player->drillmeter = TICRATE/10; } - if (!player->mo->tracer) + if (!(player->powers[pw_carry] == CR_NIGHTSMODE)) { P_DeNightserizePlayer(player); return; @@ -5564,17 +7149,18 @@ static void P_NiGHTSMovement(player_t *player) boolean capsule = false; // NiGHTS special stages have a pseudo-shared timer, so check if ANYONE is feeding the capsule. for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] /*&& players[i].pflags & PF_NIGHTSMODE*/ + if (playeringame[i] /*&& players[i].powers[pw_carry] == CR_NIGHTSMODE*/ && (players[i].capsule && players[i].capsule->reactiontime)) capsule = true; if (!capsule - && !(player->mo->tracer->state >= &states[S_SUPERTRANS1] - && player->mo->tracer->state <= &states[S_SUPERTRANS9]) + && !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6]) && !player->exiting) player->nightstime--; } - else if (gametype != GT_RACE && gametype != GT_COMPETITION - && !(player->mo->tracer->state >= &states[S_SUPERTRANS1] && player->mo->tracer->state <= &states[S_SUPERTRANS9]) + else if (!(gametyperules & GTR_RACE) + && !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6]) && !(player->capsule && player->capsule->reactiontime) && !player->exiting) player->nightstime--; @@ -5583,15 +7169,18 @@ static void P_NiGHTSMovement(player_t *player) { P_DeNightserizePlayer(player); S_StartScreamSound(player->mo, sfx_s3k66); -// S_StopSoundByNum(sfx_timeup); // Kill the "out of time" music, if it's playing. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - P_RestoreMusic(player); // I have my doubts that this is the right place for this... - return; } else if (P_IsLocalPlayer(player) && player->nightstime == 10*TICRATE) -// S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. Dummied out, as some on the dev team thought it wasn't Sonic-y enough (Mystic, notably). Uncomment to restore. -SH - S_ChangeMusicInternal("drown",false); - + { + if (mapheaderinfo[gamemap-1]->levelflags & LF_MIXNIGHTSCOUNTDOWN) + { + S_FadeMusic(0, 10*MUSICRATE); + S_StartSound(NULL, sfx_timeup); // that creepy "out of time" music from NiGHTS. + } + else + P_PlayJingle(player, ((maptol & TOL_NIGHTS) && !G_IsSpecialStage(gamemap)) ? JT_NIGHTSTIMEOUT : JT_SSTIMEOUT); + } if (player->mo->z < player->mo->floorz) player->mo->z = player->mo->floorz; @@ -5608,36 +7197,34 @@ static void P_NiGHTSMovement(player_t *player) // scan the thinkers // to find the closest axis point - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_AXIS) - { - if (mo2->threshold == player->mare) - { - if (closestaxis == NULL) - { - closestaxis = mo2; - dist2 = R_PointToDist2(newx, newy, mo2->x, mo2->y)-mo2->radius; - } - else - { - dist1 = R_PointToDist2(newx, newy, mo2->x, mo2->y)-mo2->radius; + if (mo2->type != MT_AXIS) + continue; + if (mo2->threshold != player->mare) + continue; - if (dist1 < dist2) - { - closestaxis = mo2; - dist2 = dist1; - } - } + if (closestaxis == NULL) + { + closestaxis = mo2; + dist2 = R_PointToDist2(newx, newy, mo2->x, mo2->y) - mo2->radius; + } + else + { + dist1 = R_PointToDist2(newx, newy, mo2->x, mo2->y) - mo2->radius; + + if (dist1 < dist2) + { + closestaxis = mo2; + dist2 = dist1; } } } - P_SetTarget(&player->mo->target, closestaxis); } @@ -5649,7 +7236,7 @@ static void P_NiGHTSMovement(player_t *player) // The 'ambush' flag says you should rotate // the other way around the axis. - if (player->mo->target->flags & MF_AMBUSH) + if (player->mo->target->flags2 & MF2_AMBUSH) backwardaxis = true; player->angle_pos = R_PointToAngle2(player->mo->target->x, player->mo->target->y, player->mo->x, player->mo->y); @@ -5659,8 +7246,6 @@ static void P_NiGHTSMovement(player_t *player) radius = player->mo->target->radius; player->mo->flags |= MF_NOGRAVITY; - player->mo->flags2 |= MF2_DONTDRAW; - P_SetScale(player->mo->tracer, player->mo->scale); if (player->mo->eflags & MFE_VERTICALFLIP) cmd->forwardmove = (SINT8)(-cmd->forwardmove); @@ -5715,27 +7300,38 @@ static void P_NiGHTSMovement(player_t *player) return; } - if (player->mo->tracer->state >= &states[S_SUPERTRANS1] - && player->mo->tracer->state <= &states[S_SUPERTRANS9]) + if (player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6]) { player->mo->momx = player->mo->momy = player->mo->momz = 0; + player->mo->rollangle = 0; return; } - if (player->exiting > 0 && player->exiting < 2*TICRATE) + if (player->exiting > 0) // && player->exiting < 2*TICRATE) { player->mo->momx = player->mo->momy = 0; - if (gametype != GT_RACE && gametype != GT_COMPETITION) - P_SetObjectMomZ(player->mo, 30*FRACUNIT, false); + if (!(gametyperules & GTR_RACE)) + P_SetObjectMomZ(player->mo, FRACUNIT/2, (P_MobjFlip(player->mo)*player->mo->momz >= 0)); + else + player->mo->momz = 0; - player->mo->tracer->angle += ANGLE_11hh; +#if 0//def ROTSPRITE + if (!(player->charflags & SF_NONIGHTSROTATION) && player->mo->momz) + { + if (player->mo->state != &states[S_PLAY_NIGHTS_DRILL]) + P_SetPlayerMobjState(player->mo, S_PLAY_NIGHTS_DRILL); + player->mo->rollangle = ANGLE_90; + } + else +#endif + { + if (player->mo->state != &states[S_PLAY_NIGHTS_FLOAT]) + P_SetPlayerMobjState(player->mo, S_PLAY_NIGHTS_FLOAT); + player->drawangle += ANGLE_22h; + } - if (!(player->mo->tracer->state >= &states[S_NIGHTSDRONE1] - && player->mo->tracer->state <= &states[S_NIGHTSDRONE2])) - P_SetMobjState(player->mo->tracer, S_NIGHTSDRONE1); - - player->mo->tracer->flags |= MF_NOCLIPHEIGHT; player->mo->flags |= MF_NOCLIPHEIGHT; return; } @@ -5779,21 +7375,19 @@ static void P_NiGHTSMovement(player_t *player) if (player->bumpertime) { - player->jumping = 1; - player->pflags |= PF_DRILLING; + player->pflags |= (PF_STARTJUMP|PF_DRILLING); newangle = (INT16)player->flyangle; } else if (cmd->buttons & BT_JUMP && player->drillmeter && player->drilldelay == 0) { - if (!player->jumping) + if (!(player->pflags & PF_STARTJUMP)) firstdrill = true; - player->jumping = 1; - player->pflags |= PF_DRILLING; + player->pflags |= (PF_STARTJUMP|PF_DRILLING); } else { - player->jumping = 0; + player->pflags &= ~PF_STARTJUMP; if (cmd->sidemove != 0) moved = true; @@ -5855,6 +7449,8 @@ static void P_NiGHTSMovement(player_t *player) else // AngleFixed(R_PointToAngle2()) results in slight inaccuracy! Don't use it unless movement is on both axises. newangle = (INT16)FixedInt(AngleFixed(R_PointToAngle2(0,0, cmd->sidemove*FRACUNIT, cmd->forwardmove*FRACUNIT))); + newangle -= player->viewrollangle / ANG1; + if (newangle < 0 && moved) newangle = (INT16)(360+newangle); } @@ -5901,7 +7497,7 @@ static void P_NiGHTSMovement(player_t *player) && ((cmd->buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT) || (cmd->buttons & BT_USE))) { - if (!(player->pflags & PF_SKIDDOWN)) + if (!(player->pflags & PF_STARTDASH)) S_StartSound(player->mo, sfx_ngskid); // You can tap the button to only slow down a bit, @@ -5919,10 +7515,10 @@ static void P_NiGHTSMovement(player_t *player) } } - player->pflags |= PF_SKIDDOWN; + player->pflags |= PF_STARTDASH; } else - player->pflags &= ~PF_SKIDDOWN; + player->pflags &= ~PF_STARTDASH; { const angle_t fa = (FixedAngle(player->flyangle*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK; @@ -5960,10 +7556,13 @@ static void P_NiGHTSMovement(player_t *player) && player->mo->z + player->mo->height - P_GetPlayerHeight(player) <= player->mo->waterbottom && player->mo->z + player->mo->height >= player->mo->waterbottom)) && player->speed > 9000 && leveltime % (TICRATE/7) == 0 && !player->spectator) { + mobjtype_t splishtype = (player->mo->eflags & MFE_TOUCHLAVA) ? MT_LAVASPLISH : MT_SPLISH; mobj_t *water = P_SpawnMobj(player->mo->x, player->mo->y, - ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_SPLISH].height, player->mo->scale) : player->mo->watertop), MT_SPLISH); + ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[splishtype].height, player->mo->scale) : player->mo->watertop), splishtype); if (player->mo->eflags & MFE_GOOWATER) S_StartSound(water, sfx_ghit); + else if (player->mo->eflags & MFE_TOUCHLAVA) + S_StartSound(water, sfx_splash); else S_StartSound(water, sfx_wslap); if (player->mo->eflags & MFE_VERTICALFLIP) @@ -5976,7 +7575,10 @@ static void P_NiGHTSMovement(player_t *player) } if (player->mo->momx || player->mo->momy) + { player->mo->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + player->drawangle = player->mo->angle; + } if (still) { @@ -6002,74 +7604,66 @@ static void P_NiGHTSMovement(player_t *player) // NiGHTS flying state // Yep, I just ripped out almost 1000 lines of code. - if ((player->anotherflyangle >= 12 && player->anotherflyangle <= 33) // +x +y - || (player->anotherflyangle >= 147 && player->anotherflyangle <= 168)) // -x +y - flystate = S_NIGHTSFLY2A; - else if ((player->anotherflyangle >= 34 && player->anotherflyangle <= 56) // +x +y - || (player->anotherflyangle >= 124 && player->anotherflyangle <= 146)) // -x +y - flystate = S_NIGHTSFLY3A; - else if ((player->anotherflyangle >= 57 && player->anotherflyangle <= 79) // +x +y - || (player->anotherflyangle >= 102 && player->anotherflyangle <= 123)) // -x +y - flystate = S_NIGHTSFLY4A; - else if (player->anotherflyangle >= 80 && player->anotherflyangle <= 101) - flystate = S_NIGHTSFLY5A; - else if ((player->anotherflyangle >= 192 && player->anotherflyangle <= 213) // -x -y - || (player->anotherflyangle >= 327 && player->anotherflyangle <= 348)) // +x -y - flystate = S_NIGHTSFLY6A; - else if ((player->anotherflyangle >= 214 && player->anotherflyangle <= 236) // -x -y - || (player->anotherflyangle >= 305 && player->anotherflyangle <= 326)) // +x -y - flystate = S_NIGHTSFLY7A; - else if ((player->anotherflyangle >= 237 && player->anotherflyangle <= 258) // -x -y - || (player->anotherflyangle >= 282 && player->anotherflyangle <= 304)) // +x -y - flystate = S_NIGHTSFLY8A; - else if (player->anotherflyangle >= 259 && player->anotherflyangle <= 281) - flystate = S_NIGHTSFLY9A; + // (and then toast revamped the entire thing again to be better, but not by much) + if (still) + flystate = (P_IsObjectOnGround(player->mo)) ? S_PLAY_NIGHTS_STAND : S_PLAY_NIGHTS_FLOAT; else - flystate = S_NIGHTSFLY1A; - - if (player->mo->eflags & MFE_VERTICALFLIP) { - if (flystate >= S_NIGHTSFLY2A && flystate <= S_NIGHTSFLY5A) - flystate += 24; // shift to S_NIGHTSFLY6A - else if (flystate >= S_NIGHTSFLY6A && flystate <= S_NIGHTSFLY9A) - flystate -= 24; // shift to S_NIGHTSFLY2A - } - - if (player->pflags & PF_DRILLING) - { - const statenum_t drillstate = flystate + 2; - - if (!(player->mo->tracer->state >= &states[drillstate] - && player->mo->tracer->state <= &states[drillstate+4])) + flystate = (player->pflags & PF_DRILLING) ? S_PLAY_NIGHTS_DRILL : S_PLAY_NIGHTS_FLY; + if (player->charflags & SF_NONIGHTSROTATION) { - if (!(player->mo->tracer->state >= &states[S_NIGHTSFLY1A] - && player->mo->tracer->state <= &states[S_NIGHTSFLY9B])) - { - const INT32 framenum = player->mo->tracer->state->frame & 3; +#if 0 + visangle = ((player->anotherflyangle + 7) % 360)/15; + if (visangle > 18) // Over 270 degrees. + visangle = 30 - visangle; + else if (visangle > 12) // Over 180 degrees. + visangle -= 6; + else if (visangle > 6) // Over 90 degrees. + visangle = 12 - visangle; - if (framenum == 3) // Drilld special case - P_SetMobjStateNF(player->mo->tracer, drillstate); + if (player->mo->eflags & MFE_VERTICALFLIP && visangle) // S_PLAY_NIGHTS_FLY0 stays the same, even in reverse gravity + { + if (visangle > 6) + visangle -= 6; // shift to S_PLAY_NIGHTS_FLY1-6 else - P_SetMobjStateNF(player->mo->tracer, drillstate+framenum+1); + visangle += 6; // shift to S_PLAY_NIGHTS_FLY7-C } - else - P_SetMobjStateNF(player->mo->tracer, drillstate); + + flystate += (visangle*2); // S_PLAY_NIGHTS_FLY0-C - the *2 is to skip over drill states +#endif + } + else + { + angle_t a = R_PointToAngle(player->mo->x, player->mo->y) - player->mo->angle; + visangle = (player->flyangle % 360); + + if (player->flyangle >= 90 && player->flyangle <= 270) + { + if (player->flyangle == 270 && (a < ANGLE_180)) + ; + else if (player->flyangle == 90 && (a < ANGLE_180)) + ; + else + visangle += 180; + } + + rollangle = FixedAngle(visangle<mo->state != &states[flystate]) + P_SetPlayerMobjState(player->mo, flystate); + + if (player->charflags & SF_NONIGHTSROTATION) + player->mo->rollangle = 0; else - P_SetMobjStateNF(player->mo->tracer, leveltime & 1 ? flystate : flystate+1); + player->mo->rollangle = rollangle; if (player == &players[consoleplayer]) localangle = player->mo->angle; else if (player == &players[secondarydisplayplayer]) localangle2 = player->mo->angle; - if (still) - { - P_SetMobjStateNF(player->mo->tracer, S_NIGHTSDRONE1); - player->mo->tracer->angle = player->mo->angle; - } - // Check for crushing in our new location if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) && !(player->mo->flags & MF_NOCLIP)) @@ -6078,7 +7672,7 @@ static void P_NiGHTSMovement(player_t *player) if (player->powers[pw_flashing] == 1) player->powers[pw_flashing] = 3; else - P_DamageMobj(player->mo, NULL, NULL, 1); + P_DamageMobj(player->mo, NULL, NULL, 1, 0); } if (movingangle >= ANGLE_90 && movingangle <= ANGLE_180) @@ -6093,8 +7687,6 @@ static void P_NiGHTSMovement(player_t *player) else if (player == &players[secondarydisplayplayer]) localaiming2 = movingangle; - player->mo->tracer->angle = player->mo->angle; - if ((player->pflags & PF_DRILLING) && !player->bumpertime) { if (firstdrill) @@ -6102,7 +7694,18 @@ static void P_NiGHTSMovement(player_t *player) S_StartSound(player->mo, sfx_drill1); player->drilltimer = 32; } - else if (--player->drilltimer <= 0) + else if (player->drilltimer == 32) + { + // drill mash penalty + player->drilltimer = 31; + player->drillmeter -= TICRATE/2; + if (player->drillmeter <= 0) + player->drillmeter = TICRATE/10; + } + else if (--player->drilltimer == 11) + // give that drill mash penalty back (after 0.6 seconds) + player->drillmeter += TICRATE/2; + else if (player->drilltimer <= 0) { player->drilltimer = 10; S_StartSound(player->mo, sfx_drill2); @@ -6152,7 +7755,7 @@ static void P_PlayerDropWeapon(player_t *player) if (mo) { - player->mo->health--; + player->rings--; P_InstaThrust(mo, player->mo->angle-ANGLE_180, 8*FRACUNIT); P_SetObjectMomZ(mo, 4*FRACUNIT, false); mo->flags2 |= MF2_DONTRESPAWN; @@ -6177,7 +7780,7 @@ void P_BlackOw(player_t *player) player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; } -void P_ElementalFireTrail(player_t *player) +void P_ElementalFire(player_t *player, boolean cropcircle) { fixed_t newx; fixed_t newy; @@ -6195,40 +7798,69 @@ void P_ElementalFireTrail(player_t *player) else ground = player->mo->floorz; - travelangle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); + if (cropcircle) + ground += P_MobjFlip(player->mo); - for (i = 0; i < 2; i++) + if (cropcircle) { - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); -#ifdef ESLOPE - if (player->mo->standingslope) +#define numangles 8 +#define limitangle (180/numangles) + travelangle = player->mo->angle + P_RandomRange(-limitangle, limitangle)*ANG1; + for (i = 0; i < numangles; i++) { - ground = P_GetZAt(player->mo->standingslope, newx, newy); - if (player->mo->eflags & MFE_VERTICALFLIP) - ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale); + flame = P_SpawnMobj(player->mo->x, player->mo->y, ground, MT_SPINFIRE); + flame->flags &= ~MF_NOGRAVITY; + P_SetTarget(&flame->target, player->mo); + flame->angle = travelangle + i*(ANGLE_MAX/numangles); + flame->fuse = TICRATE*7; // takes about an extra second to hit the ground + flame->destscale = player->mo->scale; + P_SetScale(flame, player->mo->scale); + flame->flags2 = (flame->flags2 & ~MF2_OBJECTFLIP)|(player->mo->flags2 & MF2_OBJECTFLIP); + flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); + P_InstaThrust(flame, flame->angle, FixedMul(3*FRACUNIT, flame->scale)); + P_SetObjectMomZ(flame, 3*FRACUNIT, false); } -#endif - flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE); - P_SetTarget(&flame->target, player->mo); - flame->angle = travelangle; - flame->fuse = TICRATE*6; - flame->destscale = player->mo->scale; - P_SetScale(flame, player->mo->scale); - flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); - - flame->momx = 8; - P_XYMovement(flame); - if (P_MobjWasRemoved(flame)) - continue; - - if (player->mo->eflags & MFE_VERTICALFLIP) +#undef limitangle +#undef numangles + } + else + { + travelangle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); + for (i = 0; i < 2; i++) { - if (flame->z + flame->height < flame->ceilingz) + + newx = player->mo->x + P_ReturnThrustX(player->mo, (travelangle + ((i&1) ? -1 : 1)*ANGLE_135), FixedMul(24*FRACUNIT, player->mo->scale)); + newy = player->mo->y + P_ReturnThrustY(player->mo, (travelangle + ((i&1) ? -1 : 1)*ANGLE_135), FixedMul(24*FRACUNIT, player->mo->scale)); + +#ifdef ESLOPE + if (player->mo->standingslope) + { + ground = P_GetZAt(player->mo->standingslope, newx, newy); + if (player->mo->eflags & MFE_VERTICALFLIP) + ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale); + } +#endif + flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE); + P_SetTarget(&flame->target, player->mo); + flame->angle = travelangle; + flame->fuse = TICRATE*6; + flame->destscale = player->mo->scale; + P_SetScale(flame, player->mo->scale); + flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); + + flame->momx = 8; // this is a hack which is used to ensure it still behaves as a missile and can damage others + P_XYMovement(flame); + if (P_MobjWasRemoved(flame)) + continue; + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if (flame->z + flame->height < flame->ceilingz) + P_RemoveMobj(flame); + } + else if (flame->z > flame->floorz) P_RemoveMobj(flame); } - else if (flame->z > flame->floorz) - P_RemoveMobj(flame); } } @@ -6244,16 +7876,18 @@ static void P_SkidStuff(player_t *player) if (!onground) { player->skidtime = 0; - player->pflags &= ~(PF_GLIDING|PF_JUMPED); - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); + player->pflags &= ~(PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE); + player->pflags |= PF_THOKKED; // nice try, speedrunners (but for real this is just behavior from S3K) + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); } // Get up and brush yourself off, idiot. - else if (player->glidetime > 15) + else if (player->glidetime > 15 || !(player->cmd.buttons & BT_JUMP)) { P_ResetPlayer(player); - P_SetPlayerMobjState(player->mo, S_PLAY_STND); - player->mo->momx = player->cmomx; - player->mo->momy = player->cmomy; + P_SetPlayerMobjState(player->mo, S_PLAY_GLIDE_LANDING); + player->pflags |= PF_STASIS; + player->mo->momx = ((player->mo->momx - player->cmomx)/3) + player->cmomx; + player->mo->momy = ((player->mo->momy - player->cmomy)/3) + player->cmomy; } // Didn't stop yet? Skid FOREVER! else if (player->skidtime == 1) @@ -6261,16 +7895,19 @@ static void P_SkidStuff(player_t *player) // Spawn a particle every 3 tics. else if (!(player->skidtime % 3)) { - mobj_t *particle = P_SpawnMobj(player->mo->x + P_RandomRange(-player->mo->radius, player->mo->radius), player->mo->y + P_RandomRange(-player->mo->radius, player->mo->radius), - player->mo->z + (player->mo->eflags & MFE_VERTICALFLIP ? player->mo->height - mobjinfo[MT_PARTICLE].height : 0), - MT_PARTICLE); + fixed_t radius = player->mo->radius >> FRACBITS; + mobj_t *particle = P_SpawnMobjFromMobj(player->mo, P_RandomRange(-radius, radius) << FRACBITS, P_RandomRange(-radius, radius) << FRACBITS, 0, MT_SPINDUST); particle->tics = 10; - particle->eflags |= player->mo->eflags & MFE_VERTICALFLIP; - P_SetScale(particle, player->mo->scale >> 2); - particle->destscale = player->mo->scale << 2; - particle->scalespeed = FixedMul(particle->scalespeed, player->mo->scale); // scale the scaling speed! + particle->destscale = (2*player->mo->scale)/3; + P_SetScale(particle, particle->destscale); P_SetObjectMomZ(particle, FRACUNIT, false); + + if (player->mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) // overrides fire version + P_SetMobjState(particle, S_SPINDUST_BUBBLE1); + else if (player->powers[pw_shield] == SH_ELEMENTAL) + P_SetMobjState(particle, S_SPINDUST_FIRE1); + S_StartSound(player->mo, sfx_s3k7e); // the proper "Knuckles eats dirt" sfx. } } @@ -6282,16 +7919,17 @@ static void P_SkidStuff(player_t *player) // Spawn a particle every 3 tics. if (!(player->skidtime % 3)) { - mobj_t *particle = P_SpawnMobj(player->mo->x, player->mo->y, - player->mo->z + (player->mo->eflags & MFE_VERTICALFLIP ? player->mo->height - mobjinfo[MT_PARTICLE].height : 0), - MT_PARTICLE); + mobj_t *particle = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_SPINDUST); particle->tics = 10; - particle->eflags |= player->mo->eflags & MFE_VERTICALFLIP; - P_SetScale(particle, player->mo->scale >> 2); - particle->destscale = player->mo->scale << 2; - particle->scalespeed = FixedMul(particle->scalespeed, player->mo->scale); // scale the scaling speed! + particle->destscale = (2*player->mo->scale)/3; + P_SetScale(particle, particle->destscale); P_SetObjectMomZ(particle, FRACUNIT, false); + + if (player->mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) // overrides fire version + P_SetMobjState(particle, S_SPINDUST_BUBBLE1); + else if (player->powers[pw_shield] == SH_ELEMENTAL) + P_SetMobjState(particle, S_SPINDUST_FIRE1); } } else if (P_AproxDistance(pmx, pmy) >= FixedMul(player->runspeed/2, player->mo->scale) // if you were moving faster than half your run speed last frame @@ -6308,11 +7946,10 @@ static void P_SkidStuff(player_t *player) // If your push angle is more than this close to a full 180 degrees, trigger a skid. if (dang > ANGLE_157h) { - player->skidtime = TICRATE/2; + if (player->mo->state-states != S_PLAY_SKID) + P_SetPlayerMobjState(player->mo, S_PLAY_SKID); + player->mo->tics = player->skidtime = (player->mo->movefactor == FRACUNIT) ? TICRATE/2 : (FixedDiv(35<<(FRACBITS-1), FixedSqrt(player->mo->movefactor)))>>FRACBITS; S_StartSound(player->mo, sfx_skid); - if (player->panim != PA_WALK) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN4); // this switches to S_PLAY_SUPERWALK1 for superanims - player->mo->tics = player->skidtime; } } } @@ -6333,10 +7970,7 @@ static void P_MovePlayer(player_t *player) fixed_t runspd; - if (countdowntimeup) - return; - - if (player->mo->state >= &states[S_PLAY_SUPERTRANS1] && player->mo->state <= &states[S_PLAY_SUPERTRANS9]) + if (player->mo->state >= &states[S_PLAY_SUPER_TRANS1] && player->mo->state <= &states[S_PLAY_SUPER_TRANS6]) { player->mo->momx = player->mo->momy = player->mo->momz = 0; return; @@ -6345,10 +7979,19 @@ static void P_MovePlayer(player_t *player) cmd = &player->cmd; runspd = FixedMul(player->runspeed, player->mo->scale); + // This was done in Sonic 3 & Knuckles, but has been missed in Sonic Mania and the Taxman/Stealth mobile remakes. Thanks to NeoHazard for his 2017 blogpost on the matter, because this oversight otherwise almost made it all the way to 2.2's release. + //https://s3unlocked.blogspot.com/2017/12/over-threshold.html + if (player->powers[pw_super]) + runspd = FixedMul(runspd, 5*FRACUNIT/3); + + // Let's have some movement speed fun on low-friction surfaces, JUST for players... (high friction surfaces shouldn't have any adjustment, since the acceleration in this game is super high and that ends up cheesing high-friction surfaces.) + runspd = FixedMul(runspd, player->mo->movefactor); + // Control relinquishing stuff! - if (player->powers[pw_ingoop]) - player->pflags |= PF_FULLSTASIS; - else if (player->pflags & PF_GLIDING && player->skidtime) + if ((player->powers[pw_carry] == CR_BRAKGOOP) + || (player->pflags & PF_GLIDING && player->skidtime) + || (player->charability2 == CA2_GUNSLINGER && player->panim == PA_ABILITY2) + || (player->charability2 == CA2_MELEE && player->mo->state-states == S_PLAY_MELEE_LANDING)) player->pflags |= PF_FULLSTASIS; else if (player->powers[pw_nocontrol]) { @@ -6356,6 +7999,12 @@ static void P_MovePlayer(player_t *player) if (!(player->powers[pw_nocontrol] & (1<<15))) player->pflags |= PF_JUMPSTASIS; } + + if (player->charability == CA_GLIDEANDCLIMB && player->mo->state-states == S_PLAY_GLIDE_LANDING) + { + player->pflags |= PF_STASIS; + } + // note: don't unset stasis here if (!player->spectator && G_TagGametype()) @@ -6375,7 +8024,7 @@ static void P_MovePlayer(player_t *player) if (!(player->pflags & PF_TAGIT)) { forcestasis = true; - if (player->pflags & PF_TAGGED) // Already hit. + if (player->pflags & PF_GAMETYPEOVER) // Already hit. player->powers[pw_flashing] = 5; } } @@ -6392,6 +8041,7 @@ static void P_MovePlayer(player_t *player) if (player->spectator) { + player->mo->eflags &= ~MFE_VERTICALFLIP; // deflip... P_SpectatorMovement(player); return; } @@ -6399,14 +8049,30 @@ static void P_MovePlayer(player_t *player) // Locate the capsule for this mare. else if (maptol & TOL_NIGHTS) { + if ((player->powers[pw_carry] == CR_NIGHTSMODE) + && (player->exiting + || !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6]))) // Note the < instead of <= + { + skin_t *skin = ((skin_t *)(player->mo->skin)); + if (skin->flags & SF_SUPER) + { + player->mo->color = skin->supercolor + + ((player->nightstime == player->startedtime) + ? 4 + : abs((((signed)leveltime >> 1) % 9) - 4)); // This is where super flashing is handled. + G_GhostAddColor(GHC_SUPER); + } + } + if (!player->capsule && !player->bonustime) { thinker_t *th; mobj_t *mo2; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -6422,8 +8088,15 @@ static void P_MovePlayer(player_t *player) return; } + // Suck player into their drone + if (player->drone) + { + P_MoveNiGHTSToDrone(player); + return; + } + // Test revamped NiGHTS movement. - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) { P_NiGHTSMovement(player); // No more goto blockchecking, let's just do all that here =D @@ -6435,8 +8108,7 @@ static void P_MovePlayer(player_t *player) P_CheckQuicksand(player); return; } - - if (player->pflags & PF_NIGHTSFALL && P_IsObjectOnGround(player->mo)) + else if (player->powers[pw_carry] == CR_NIGHTSFALL && P_IsObjectOnGround(player->mo)) { if (G_IsSpecialStage(gamemap)) { @@ -6446,9 +8118,15 @@ static void P_MovePlayer(player_t *player) if (playeringame[i]) players[i].exiting = (14*TICRATE)/5 + 1; } - else if (player->health > 1) - P_DamageMobj(player->mo, NULL, NULL, 1); - player->pflags &= ~PF_NIGHTSFALL; + else { + // Damage whether or not we have spheres, as player should recoil upon losing points + P_DamageMobj(player->mo, NULL, NULL, 1, 0); + + // Now deduct our mare score! + player->marescore = player->spheres =\ + player->rings = 0; + } + player->powers[pw_carry] = CR_NONE; } } @@ -6460,8 +8138,33 @@ static void P_MovePlayer(player_t *player) P_2dMovement(player); else { - if (!player->climbing && (!P_AnalogMove(player))) - player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + if (!player->climbing) + { + switch (P_ControlStyle(player)) + { + case CS_LEGACY: + case CS_STANDARD: + player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + break; + + case CS_LMAOGALOG: + break; // handled elsewhere + + case CS_SIMPLE: + if (cmd->forwardmove || cmd->sidemove) + { + angle_t controlangle = R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); + player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */) + controlangle; + } + else + { + angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; + player->mo->angle = player->drawangle + drawangleoffset; + } + + break; + } + } ticruned++; if ((cmd->angleturn & TICCMD_RECEIVED) == 0) @@ -6479,35 +8182,68 @@ static void P_MovePlayer(player_t *player) // MOVEMENT ANIMATIONS // ///////////////////////// - if ((cmd->forwardmove != 0 || cmd->sidemove != 0) || (player->powers[pw_super] && player->mo->z > player->mo->floorz)) + if ((cmd->forwardmove != 0 || cmd->sidemove != 0) || (player->powers[pw_super] && !onground)) { + // If the player is in dashmode, here's their peelout. + if (player->charflags & SF_DASHMODE && player->dashmode >= DASHMODE_THRESHOLD && player->panim == PA_RUN && !player->skidtime && (onground || ((player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) && player->secondjump == 1) || player->powers[pw_super])) + P_SetPlayerMobjState (player->mo, S_PLAY_DASH); // If the player is moving fast enough, // break into a run! - if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime && (onground || player->powers[pw_super])) - P_SetPlayerMobjState (player->mo, S_PLAY_SPD1); + else if (player->speed >= runspd && player->panim == PA_WALK && !player->skidtime + && (onground || ((player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) && player->secondjump == 1) || player->powers[pw_super])) + { + if (!onground) + P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT_RUN); + else + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + } + + // Floating at slow speeds has its own special animation. + else if ((((player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) && player->secondjump == 1) || player->powers[pw_super]) && player->panim == PA_IDLE && !onground) + P_SetPlayerMobjState (player->mo, S_PLAY_FLOAT); // Otherwise, just walk. else if ((player->rmomx || player->rmomy) && player->panim == PA_IDLE) - P_SetPlayerMobjState (player->mo, S_PLAY_RUN1); + P_SetPlayerMobjState (player->mo, S_PLAY_WALK); } + // If your peelout animation is playing, and you're + // going too slow, switch back to the run. + if (player->charflags & SF_DASHMODE && player->panim == PA_DASH && player->dashmode < DASHMODE_THRESHOLD) + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + // If your running animation is playing, and you're // going too slow, switch back to the walking frames. if (player->panim == PA_RUN && player->speed < runspd) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); + { + if (!onground && (((player->charability == CA_FLOAT || player->charability == CA_SLOWFALL) && player->secondjump == 1) || player->powers[pw_super])) + P_SetPlayerMobjState(player->mo, S_PLAY_FLOAT); + else + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + } - // If Springing, but travelling DOWNWARD, change back! - if (player->mo->state == &states[S_PLAY_SPRING] && P_MobjFlip(player->mo)*player->mo->momz < 0) - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); - // If Springing but on the ground, change back! - else if (onground && (player->mo->state == &states[S_PLAY_SPRING] || player->panim == PA_FALL || player->mo->state == &states[S_PLAY_CARRY]) && !player->mo->momz) + // Correct floating when ending up on the ground. + if (onground) + { + if (player->mo->state-states == S_PLAY_FLOAT) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else if (player->mo->state-states == S_PLAY_FLOAT_RUN) + P_SetPlayerMobjState(player->mo, S_PLAY_RUN); + } + + // If Springing (or nojumpspinning), but travelling DOWNWARD, change back! + if ((player->panim == PA_SPRING && P_MobjFlip(player->mo)*player->mo->momz < 0) + || ((((player->charflags & SF_NOJUMPSPIN) && (player->pflags & PF_JUMPED) && player->panim == PA_JUMP)) + && (P_MobjFlip(player->mo)*player->mo->momz < 0))) + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + // If doing an air animation but on the ground, change back! + else if (onground && (player->panim == PA_SPRING || player->panim == PA_FALL || player->panim == PA_RIDE || player->panim == PA_JUMP) && !player->mo->momz) P_SetPlayerMobjState(player->mo, S_PLAY_STND); // If you are stopped and are still walking, stand still! if (!player->mo->momx && !player->mo->momy && !player->mo->momz && player->panim == PA_WALK) P_SetPlayerMobjState(player->mo, S_PLAY_STND); - ////////////////// //GAMEPLAY STUFF// ////////////////// @@ -6516,45 +8252,50 @@ static void P_MovePlayer(player_t *player) if (onground && player->pflags & PF_JUMPED && !(player->pflags & PF_GLIDING) && P_MobjFlip(player->mo)*player->mo->momz < 0) { - player->pflags &= ~PF_JUMPED; - player->jumping = 0; + player->pflags &= ~(PF_STARTJUMP|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED|PF_SHIELDABILITY); player->secondjump = 0; - player->pflags &= ~PF_THOKKED; P_SetPlayerMobjState(player->mo, S_PLAY_STND); } - // Cap the speed limit on a spindash - // Up the 60*FRACUNIT number to boost faster, you speed demon you! - if (player->dashspeed > FixedMul(player->maxdash, player->mo->scale)) - player->dashspeed = FixedMul(player->maxdash, player->mo->scale); - else if (player->dashspeed > 0 && player->dashspeed < FixedMul(player->mindash, player->mo->scale)) - player->dashspeed = FixedMul(player->mindash, player->mo->scale); - - if (!(player->charability == CA_GLIDEANDCLIMB) || player->gotflag) // If you can't glide, then why the heck would you be gliding? + if ((!(player->charability == CA_GLIDEANDCLIMB) || player->gotflag) // If you can't glide, then why the heck would you be gliding? + && (player->pflags & PF_GLIDING || player->climbing)) { - if (player->pflags & PF_GLIDING || player->climbing) + if (onground) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else { - if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else - { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - } + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); } player->pflags &= ~PF_GLIDING; player->glidetime = 0; player->climbing = 0; } + if ((!(player->charability == CA_BOUNCE) || player->gotflag) // If you can't bounce, then why the heck would you be bouncing? + && (player->pflags & PF_BOUNCING)) + { + if (onground) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else + { + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); + } + player->pflags &= ~PF_BOUNCING; + } + // Glide MOMZ // AKA my own gravity. =) if (player->pflags & PF_GLIDING) { - fixed_t leeway; + mobj_t *mo = player->mo; // seriously why isn't this at the top of the function hngngngng + fixed_t leeway = (P_ControlStyle(player) != CS_LMAOGALOG) ? FixedAngle(cmd->sidemove*(FRACUNIT)) : 0; fixed_t glidespeed = player->actionspd; + fixed_t momx = mo->momx - player->cmomx, momy = mo->momy - player->cmomy; + angle_t angle, moveangle = R_PointToAngle2(0, 0, momx, momy); - if (player->powers[pw_super]) + if (player->powers[pw_super] || player->powers[pw_sneakers]) glidespeed *= 2; if (player->mo->eflags & MFE_VERTICALFLIP) @@ -6569,22 +8310,45 @@ static void P_MovePlayer(player_t *player) } // Strafing while gliding. - leeway = FixedAngle(cmd->sidemove*(FRACUNIT/2)); + angle = mo->angle - leeway; - if (player->skidtime) // ground gliding + if (!player->skidtime) // TODO: make sure this works in 2D! { - fixed_t speed = FixedMul(glidespeed, FRACUNIT - (FRACUNIT>>2)); - if (player->mo->eflags & MFE_UNDERWATER) - speed >>= 1; - speed = FixedMul(speed - player->glidetime*FRACUNIT, player->mo->scale); - if (speed < 0) - speed = 0; - P_InstaThrust(player->mo, player->mo->angle-leeway, speed); + fixed_t speed, scale = mo->scale; + fixed_t newMagnitude, oldMagnitude = R_PointToDist2(momx, momy, 0, 0); + fixed_t accelfactor = 4*FRACUNIT - 3*FINECOSINE(((angle-moveangle) >> ANGLETOFINESHIFT) & FINEMASK); // mamgic number BAD but this feels right + + if (mo->eflags & MFE_UNDERWATER) + speed = FixedMul((glidespeed>>1) + player->glidetime*750, scale); + else + speed = FixedMul(glidespeed + player->glidetime*1500, scale); + + P_Thrust(mo, angle, FixedMul(accelfactor, scale)); + + newMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0); + if (newMagnitude > speed) + { + fixed_t tempmomx, tempmomy; + if (oldMagnitude > speed) + { + if (newMagnitude > oldMagnitude) + { + tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), oldMagnitude); + tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), oldMagnitude); + player->mo->momx = tempmomx + player->cmomx; + player->mo->momy = tempmomy + player->cmomy; + } + // else do nothing + } + else + { + tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), speed); + tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), speed); + player->mo->momx = tempmomx + player->cmomx; + player->mo->momy = tempmomy + player->cmomy; + } + } } - else if (player->mo->eflags & MFE_UNDERWATER) - P_InstaThrust(player->mo, player->mo->angle-leeway, FixedMul((glidespeed>>1) + player->glidetime*750, player->mo->scale)); - else - P_InstaThrust(player->mo, player->mo->angle-leeway, FixedMul(glidespeed + player->glidetime*1500, player->mo->scale)); player->glidetime++; @@ -6592,37 +8356,51 @@ static void P_MovePlayer(player_t *player) { P_ResetPlayer(player); // down, stop gliding. if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); - else if ((player->charability2 == CA2_MULTIABILITY) - || (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && player->charability == CA_GLIDEANDCLIMB)) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else if (player->charflags & SF_MULTIABILITY) { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); } else { player->pflags |= PF_THOKKED; player->mo->momx >>= 1; player->mo->momy >>= 1; - P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); } } } else if (player->climbing) // 'Deceleration' for climbing on walls. { - if (player->mo->momz > 0) + + if (!player->cmd.forwardmove) + player->mo->momz = 0; + } + else if (player->pflags & PF_BOUNCING) + { + if (!(player->pflags & PF_JUMPDOWN)) // If not holding the jump button { - player->mo->momz -= FixedMul(FRACUNIT/2, player->mo->scale); - if (player->mo->momz < 0) - player->mo->momz = 0; - } - else if (player->mo->momz < 0) - { - player->mo->momz += FixedMul(FRACUNIT/2, player->mo->scale); - if (player->mo->momz > 0) - player->mo->momz = 0; + P_ResetPlayer(player); // down, stop bouncing. + player->pflags |= PF_THOKKED; + if (onground) + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + else if (player->charflags & SF_MULTIABILITY) + { + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); + } + else + { + player->mo->momx >>= 1; + player->mo->momy >>= 1; + player->mo->momz >>= 1; + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + } } } + else if (player->mo->state-states == S_PLAY_BOUNCE) + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); // If you're running fast enough, you can create splashes as you run in shallow water. if (!player->climbing @@ -6631,10 +8409,13 @@ static void P_MovePlayer(player_t *player) && (player->speed > runspd || (player->pflags & PF_STARTDASH)) && leveltime % (TICRATE/7) == 0 && player->mo->momz == 0 && !(player->pflags & PF_SLIDING) && !player->spectator) { - mobj_t *water = P_SpawnMobj(player->mo->x, player->mo->y, - ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_SPLISH].height, player->mo->scale) : player->mo->watertop), MT_SPLISH); + mobjtype_t splishtype = (player->mo->eflags & MFE_TOUCHLAVA) ? MT_LAVASPLISH : MT_SPLISH; + mobj_t *water = P_SpawnMobj(player->mo->x - P_ReturnThrustX(NULL, player->mo->angle, player->mo->radius), player->mo->y - P_ReturnThrustY(NULL, player->mo->angle, player->mo->radius), + ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[splishtype].height, player->mo->scale) : player->mo->watertop), splishtype); if (player->mo->eflags & MFE_GOOWATER) S_StartSound(water, sfx_ghit); + else if (player->mo->eflags & MFE_TOUCHLAVA) + S_StartSound(water, sfx_splash); else S_StartSound(water, sfx_wslap); if (player->mo->eflags & MFE_VERTICALFLIP) @@ -6660,14 +8441,14 @@ static void P_MovePlayer(player_t *player) if (!(player->charability == CA_FLY || player->charability == CA_SWIM)) // why are you flying when you cannot fly?! { if (player->powers[pw_tailsfly] - || (player->mo->state >= &states[S_PLAY_SPC1] && player->mo->state <= &states[S_PLAY_SPC4])) + || player->mo->state-states == S_PLAY_FLY_TIRED) { if (onground) - P_SetPlayerMobjState(player->mo, S_PLAY_RUN1); + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); else { - player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); } } player->powers[pw_tailsfly] = 0; @@ -6687,7 +8468,7 @@ static void P_MovePlayer(player_t *player) { const fixed_t actionspd = player->actionspd/100; - if (player->charability2 == CA2_MULTIABILITY) + if (player->charflags & SF_MULTIABILITY) { // Adventure-style flying by just holding the button down if (cmd->buttons & BT_JUMP && !(player->pflags & PF_STASIS) && !player->exiting) @@ -6701,29 +8482,39 @@ static void P_MovePlayer(player_t *player) if (P_MobjFlip(player->mo)*player->mo->momz < FixedMul(5*actionspd, player->mo->scale)) P_SetObjectMomZ(player->mo, actionspd/2, true); + P_SetPlayerMobjState(player->mo, player->mo->state->nextstate); + player->fly1--; } } // Tails Put-Put noise - if (player->charability == CA_FLY && player->bot != 1 && leveltime % 10 == 0 && !player->spectator) + if (player->charability == CA_FLY + && (player->pflags & PF_CANCARRY) + && !(player->mo->eflags & MFE_UNDERWATER) + && leveltime % 10 == 0 + && !player->spectator) S_StartSound(player->mo, sfx_putput); // Descend - if (cmd->buttons & BT_USE && !(player->pflags & PF_STASIS) && !player->exiting) + if (cmd->buttons & BT_USE && !(player->pflags & PF_STASIS) && !player->exiting && !(player->mo->eflags & MFE_GOOWATER)) if (P_MobjFlip(player->mo)*player->mo->momz > -FixedMul(5*actionspd, player->mo->scale)) + { + if (player->fly1 > 2) + player->fly1 = 2; P_SetObjectMomZ(player->mo, -actionspd/2, true); + } } else { // Tails-gets-tired Stuff - if (player->panim == PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_SPC4); + if (player->panim == PA_ABILITY && player->mo->state-states != S_PLAY_FLY_TIRED) + P_SetPlayerMobjState(player->mo, S_PLAY_FLY_TIRED); if (player->charability == CA_FLY && (leveltime % 10 == 0) - && player->mo->state >= &states[S_PLAY_SPC1] - && player->mo->state <= &states[S_PLAY_SPC4] + && player->mo->state-states == S_PLAY_FLY_TIRED + && !(player->mo->eflags & MFE_UNDERWATER) && !player->spectator) S_StartSound(player->mo, sfx_pudpud); } @@ -6738,11 +8529,10 @@ static void P_MovePlayer(player_t *player) P_ResetScore(player); // Show the "THOK!" graphic when spinning quickly across the ground. (even applies to non-spinners, in the case of zoom tubes) - if (player->pflags & PF_SPINNING && player->speed > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) + if (player->pflags & PF_SPINNING && P_AproxDistance(player->speed, player->mo->momz) > FixedMul(15<mo->scale) && !(player->pflags & PF_JUMPED)) { P_SpawnSpinMobj(player, player->spinitem); - if (demorecording) - G_GhostAddSpin(); + G_GhostAddSpin(); } @@ -6751,7 +8541,7 @@ static void P_MovePlayer(player_t *player) //////////////////////////// // If the player isn't on the ground, make sure they aren't in a "starting dash" position. - if (!onground) + if (!onground && player->powers[pw_carry] != CR_NIGHTSMODE) { player->pflags &= ~PF_STARTDASH; player->dashspeed = 0; @@ -6760,15 +8550,15 @@ static void P_MovePlayer(player_t *player) if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && (player->pflags & PF_SPINNING) && player->speed > FixedMul(4<mo->scale) && onground && (leveltime & 1) && !(player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER))) - P_ElementalFireTrail(player); + P_ElementalFire(player, false); - P_DoSpinDash(player, cmd); + P_DoSpinAbility(player, cmd); // jumping P_DoJumpStuff(player, cmd); // If you're not spinning, you'd better not be spindashing! - if (!(player->pflags & PF_SPINNING)) + if (!(player->pflags & PF_SPINNING) && player->powers[pw_carry] != CR_NIGHTSMODE) player->pflags &= ~PF_STARTDASH; ////////////////// @@ -6776,7 +8566,7 @@ static void P_MovePlayer(player_t *player) ////////////////// // This really looks like it should be moved to P_3dMovement. -Red - if (P_AnalogMove(player) + if (P_ControlStyle(player) == CS_LMAOGALOG && (cmd->forwardmove != 0 || cmd->sidemove != 0) && !player->climbing && !twodlevel && !(player->mo->flags2 & MF2_TWOD)) { // If travelling slow enough, face the way the controls @@ -6817,8 +8607,8 @@ static void P_MovePlayer(player_t *player) #endif } // Otherwise, face the direction you're travelling. - else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_ROLL - || ((player->mo->state >= &states[S_PLAY_ABL1] && player->mo->state <= &states[S_PLAY_SPC4]) && player->charability == CA_FLY)) + else if (player->panim == PA_WALK || player->panim == PA_RUN || player->panim == PA_DASH || player->panim == PA_ROLL || player->panim == PA_JUMP + || (player->panim == PA_ABILITY && player->mo->state-states == S_PLAY_GLIDE)) player->mo->angle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); // Update the local angle control. @@ -6828,88 +8618,6 @@ static void P_MovePlayer(player_t *player) localangle2 = player->mo->angle; } - /////////////////////////// - //BOMB SHIELD ACTIVATION,// - //HOMING, AND OTHER COOL // - //STUFF! // - /////////////////////////// - - if (cmd->buttons & BT_USE) // Spin button effects - { - if (player->pflags & PF_JUMPED) // If the player is jumping - { - if (!(player->pflags & PF_USEDOWN)) // If the player is not holding down BT_USE - { - // Jump shield activation - if (!P_PlayerInPain(player) // If the player is not in pain - && !player->climbing // If the player is not climbing - && !(player->pflags & (PF_GLIDING|PF_SLIDING|PF_THOKKED)) // If the player is not gliding or sliding and hasn't used their ability - && !onground) // If the player isn't on the ground - { - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_JUMP && !player->powers[pw_super]) - P_DoJumpShield(player); - else if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]) && player->charability == CA_FLY) - { - P_DoJumpShield(player); - player->mo->momz *= 2; - } - } - // Bomb shield activation - if ((player->powers[pw_shield] & SH_NOSTACK) == SH_BOMB) - { - // Don't let Super Sonic or invincibility use it - if (!(player->powers[pw_super] || player->powers[pw_invulnerability])) - P_BlackOw(player); - } - } - // Super Sonic move - if (player->skin == 0 && player->powers[pw_super] && player->speed > FixedMul(5<mo->scale) - && P_MobjFlip(player->mo)*player->mo->momz <= 0) - { - if (player->panim == PA_ROLL || player->mo->state == &states[S_PLAY_PAIN]) - P_SetPlayerMobjState(player->mo, S_PLAY_SUPERWALK1); - - player->mo->momz = 0; - player->pflags &= ~PF_SPINNING; - player->jumping = 0; // don't cut jump height after bouncing off something - } - } - } - - // HOMING option. - if (player->charability == CA_HOMINGTHOK) - { - // If you've got a target, chase after it! - if (player->homing && player->mo->tracer) - { - P_SpawnThokMobj(player); - P_HomingAttack(player->mo, player->mo->tracer); - - // But if you don't, then stop homing. - if (player->mo->tracer->health <= 0 || (player->mo->tracer->flags2 & MF2_FRET)) - { - if (player->mo->eflags & MFE_UNDERWATER) - P_SetObjectMomZ(player->mo, FixedDiv(457*FRACUNIT,72*FRACUNIT), false); - else - P_SetObjectMomZ(player->mo, 10*FRACUNIT, false); - - player->mo->momx = player->mo->momy = player->homing = 0; - - if (player->mo->tracer->flags2 & MF2_FRET) - P_InstaThrust(player->mo, player->mo->angle, -(player->speed>>3)); - - if (!(player->mo->tracer->flags & MF_BOSS)) - player->pflags &= ~PF_THOKKED; - } - } - - // If you're not jumping, then you obviously wouldn't be homing. - if (!(player->pflags & PF_JUMPED)) - player->homing = 0; - } - else - player->homing = 0; - if (player->climbing == 1) P_DoClimbing(player); @@ -6926,13 +8634,13 @@ static void P_MovePlayer(player_t *player) } // Make sure you're not teetering when you shouldn't be. - if ((player->mo->state == &states[S_PLAY_TEETER1] || player->mo->state == &states[S_PLAY_TEETER2] || player->mo->state == &states[S_PLAY_SUPERTEETER]) + if (player->panim == PA_EDGE && (player->mo->momx || player->mo->momy || player->mo->momz)) P_SetPlayerMobjState(player->mo, S_PLAY_STND); // Check for teeter! if (!(player->mo->momz || player->mo->momx || player->mo->momy) && !(player->mo->eflags & MFE_GOOWATER) - && player->panim == PA_IDLE && !(player->pflags & (PF_CARRIED|PF_ITEMHANG|PF_ROPEHANG))) + && player->panim == PA_IDLE && !(player->powers[pw_carry])) P_DoTeeter(player); // Toss a flag @@ -6952,10 +8660,11 @@ static void P_MovePlayer(player_t *player) fixed_t oldheight = player->mo->height; // Less height while spinning. Good for spinning under things...? - if ((player->mo->state == &states[player->mo->info->painstate] || player->mo->state == &states[S_PLAY_SUPERHIT]) - || (player->charability2 == CA2_SPINDASH && (player->pflags & (PF_SPINNING|PF_JUMPED))) + if ((player->mo->state == &states[player->mo->info->painstate]) + || ((player->pflags & PF_JUMPED) && !(player->pflags & PF_NOJUMPDAMAGE)) + || (player->pflags & PF_SPINNING) || player->powers[pw_tailsfly] || player->pflags & PF_GLIDING - || (player->charability == CA_FLY && (player->mo->state >= &states[S_PLAY_SPC1] && player->mo->state <= &states[S_PLAY_SPC4]))) + || (player->charability == CA_FLY && player->mo->state-states == S_PLAY_FLY_TIRED)) player->mo->height = P_GetPlayerSpinHeight(player); else player->mo->height = P_GetPlayerHeight(player); @@ -6971,18 +8680,14 @@ static void P_MovePlayer(player_t *player) if ((player->charability2 == CA2_SPINDASH) && !(player->pflags & PF_SPINNING)) { player->pflags |= PF_SPINNING; - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); } else if (player->mo->ceilingz - player->mo->floorz < player->mo->height) { if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_SPECTATOR); // Respawn crushed spectators else - { - mobj_t *killer = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_NULL); - killer->threshold = 44; // Special flag that it was crushing which killed you. - P_DamageMobj(player->mo, killer, killer, 10000); - } + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_CRUSHED); if (player->playerstate == PST_DEAD) return; @@ -6990,7 +8695,7 @@ static void P_MovePlayer(player_t *player) } #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none && cv_grfovchange.value) + if (rendermode != render_soft && rendermode != render_none && cv_fovchange.value) { fixed_t speed; const fixed_t runnyspeed = 20*FRACUNIT; @@ -7099,6 +8804,9 @@ static void P_MovePlayer(player_t *player) // Look for Quicksand! if (CheckForQuicksand) P_CheckQuicksand(player); + + if (P_IsObjectOnGround(player->mo)) + player->mo->pmomz = 0; } static void P_DoZoomTube(player_t *player) @@ -7155,9 +8863,9 @@ static void P_DoZoomTube(player_t *player) CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n"); // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7165,15 +8873,17 @@ static void P_DoZoomTube(player_t *player) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == sequence) - { - if ((reverse && mo2->health == player->mo->tracer->health - 1) - || (!reverse && mo2->health == player->mo->tracer->health + 1)) - { - waypoint = mo2; - break; - } - } + if (mo2->threshold != sequence) + continue; + + if (reverse && mo2->health != player->mo->tracer->health - 1) + continue; + + if (!reverse && mo2->health != player->mo->tracer->health + 1) + continue; + + waypoint = mo2; + break; } if (waypoint) @@ -7197,6 +8907,7 @@ static void P_DoZoomTube(player_t *player) else { P_SetTarget(&player->mo->tracer, NULL); // Else, we just let them fly. + player->powers[pw_carry] = CR_NONE; CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, releasing from track...\n"); } @@ -7254,17 +8965,18 @@ static void P_DoRopeHang(player_t *player) if (player->cmd.buttons & BT_USE && !(player->pflags & PF_STASIS)) // Drop off of the rope { + player->pflags |= (P_GetJumpFlags(player)|PF_USEDOWN); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); + P_SetTarget(&player->mo->tracer, NULL); + player->powers[pw_carry] = CR_NONE; - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_ROPEHANG; - - if (!(player->pflags & PF_SLIDING) && (player->pflags & PF_JUMPED) - && !(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); return; } + if (player->mo->state-states != S_PLAY_RIDE) + P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); + // If not allowed to move, we're done here. if (!speed) return; @@ -7287,9 +8999,9 @@ static void P_DoRopeHang(player_t *player) CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n"); // Find next waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7297,14 +9009,14 @@ static void P_DoRopeHang(player_t *player) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == sequence) - { - if (mo2->health == player->mo->tracer->health + 1) - { - waypoint = mo2; - break; - } - } + if (mo2->threshold != sequence) + continue; + + if (mo2->health != player->mo->tracer->health + 1) + continue; + + waypoint = mo2; + break; } if (!(player->mo->tracer->flags & MF_SLIDEME) && !waypoint) @@ -7312,9 +9024,9 @@ static void P_DoRopeHang(player_t *player) CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, wrapping to start...\n"); // Wrap around back to first waypoint - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) // Not a mobj thinker + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7322,14 +9034,14 @@ static void P_DoRopeHang(player_t *player) if (mo2->type != MT_TUBEWAYPOINT) continue; - if (mo2->threshold == sequence) - { - if (mo2->health == 0) - { - waypoint = mo2; - break; - } - } + if (mo2->threshold != sequence) + continue; + + if (mo2->health != 0) + continue; + + waypoint = mo2; + break; } } @@ -7354,15 +9066,12 @@ static void P_DoRopeHang(player_t *player) { if (player->mo->tracer->flags & MF_SLIDEME) { - player->pflags |= PF_JUMPED; - player->pflags &= ~PF_ROPEHANG; - - if (!(player->pflags & PF_SLIDING) && (player->pflags & PF_JUMPED) - && !(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + player->pflags |= P_GetJumpFlags(player); + P_SetPlayerMobjState(player->mo, S_PLAY_JUMP); } P_SetTarget(&player->mo->tracer, NULL); + player->powers[pw_carry] = CR_NONE; CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found!\n"); } @@ -7379,25 +9088,22 @@ static void P_DoRopeHang(player_t *player) static void P_NukeAllPlayers(player_t *player) { mobj_t *mo; - thinker_t *think; + UINT8 i; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (i = 0; i < MAXPLAYERS; i++) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (!mo->player) + if (!playeringame[i]) + continue; + if (players[i].spectator) + continue; + if (!players[i].mo) + continue; + if (players[i].mo == player->mo) + continue; + if (players[i].mo->health <= 0) continue; - if (mo->health <= 0) // dead - continue; - - if (mo == player->mo) - continue; - - P_DamageMobj(mo, player->mo, player->mo, 1); + P_DamageMobj(players[i].mo, player->mo, player->mo, 1, 0); } CONS_Printf(M_GetText("%s caused a world of pain.\n"), player_names[player-players]); @@ -7429,10 +9135,10 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) } } - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; @@ -7452,61 +9158,213 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) continue; if (mo->type == MT_MINUS && !(mo->flags & (MF_SPECIAL|MF_SHOOTABLE))) - mo->flags |= MF_SPECIAL|MF_SHOOTABLE; + mo->flags = (mo->flags & ~MF_NOCLIPTHING)|MF_SPECIAL|MF_SHOOTABLE; if (mo->type == MT_EGGGUARD && mo->tracer) //nuke Egg Guard's shield! - P_KillMobj(mo->tracer, inflictor, source); + P_KillMobj(mo->tracer, inflictor, source, DMG_NUKE); if (mo->flags & MF_BOSS || mo->type == MT_PLAYER) //don't OHKO bosses nor players! - P_DamageMobj(mo, inflictor, source, 1); + P_DamageMobj(mo, inflictor, source, 1, DMG_NUKE); else - P_DamageMobj(mo, inflictor, source, 1000); + P_DamageMobj(mo, inflictor, source, 1000, DMG_NUKE); } } +// +// P_LookForFocusTarget +// Looks for a target for a player to focus on, for Z-targeting etc. +// exclude would be the current focus target, to ignore. +// direction, if set, requires the target to be to the left (1) or right (-1) of the angle +// mobjflags can be used to limit the flags of objects that can be focused +// +mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, UINT8 lockonflags) +{ + mobj_t *mo; + thinker_t *think; + mobj_t *closestmo = NULL; + const fixed_t maxdist = 2560*player->mo->scale; + const angle_t span = ANGLE_45; + fixed_t dist, closestdist = 0; + angle_t dangle, closestdangle = 0; + + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) + { + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)think; + + if (mo->flags & MF_NOCLIPTHING) + continue; + + if (mo == player->mo || mo == exclude) + continue; + + if (mo->health <= 0) // dead + continue; + + switch (mo->type) + { + case MT_TNTBARREL: + if (lockonflags & LOCK_INTERESTS) + break; + /*FALLTHRU*/ + case MT_PLAYER: // Don't chase other players! + case MT_DETON: + continue; // Don't be STUPID, Sonic! + + case MT_FAKEMOBILE: + if (!(lockonflags & LOCK_BOSS)) + continue; + break; + + case MT_EGGSHIELD: + if (!(lockonflags & LOCK_ENEMY)) + continue; + break; + + case MT_EGGSTATUE: + if (tutorialmode) + break; // Always focus egg statue in the tutorial + /*FALLTHRU*/ + default: + + if ((lockonflags & LOCK_BOSS) && ((mo->flags & (MF_BOSS|MF_SHOOTABLE)) == (MF_BOSS|MF_SHOOTABLE))) // allows if it has the flags desired XOR it has the invert aimable flag + { + if (mo->flags2 & MF2_FRET) + continue; + break; + } + + if ((lockonflags & LOCK_ENEMY) && (!((mo->flags & (MF_ENEMY|MF_SHOOTABLE)) == (MF_ENEMY|MF_SHOOTABLE)) != !(mo->flags2 & MF2_INVERTAIMABLE))) // allows if it has the flags desired XOR it has the invert aimable flag + break; + + if ((lockonflags & LOCK_INTERESTS) && (mo->flags & (MF_PUSHABLE|MF_MONITOR))) // allows if it has the flags desired XOR it has the invert aimable flag + break; + + continue; // not a valid object + } + + { + fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); + dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); + + if (abs(zdist) > dist) + continue; // Don't home outside of desired angle! + + dist = P_AproxDistance(dist, zdist); + if (dist > maxdist) + continue; // out of range + } + + if ((twodlevel || player->mo->flags2 & MF2_TWOD) + && abs(player->mo->y-mo->y) > player->mo->radius) + continue; // not in your 2d plane + + dangle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y) - ( + !exclude ? player->mo->angle : R_PointToAngle2(player->mo->x, player->mo->y, exclude->x, exclude->y) + ); + + if (direction) + { + if (direction == 1 && dangle > ANGLE_180) + continue; // To the right of the player + if (direction == -1 && dangle < ANGLE_180) + continue; // To the left of the player + } + + if (dangle > ANGLE_180) + dangle = InvAngle(dangle); + + if (dangle > span) + continue; // behind back + + // Inflate dist by angle difference to bias toward objects at a closer angle + dist = FixedDiv(dist, FINECOSINE(dangle>>ANGLETOFINESHIFT)*3); + + if (closestmo && (exclude ? (dangle > closestdangle) : (dist > closestdist))) + continue; + + if (!P_CheckSight(player->mo, mo)) + continue; // out of sight + + closestmo = mo; + closestdist = dist; + closestdangle = dangle; + } + + return closestmo; +} + // // P_LookForEnemies // Looks for something you can hit - Used for homing attack -// Includes monitors and springs! +// If nonenemies is true, includes monitors and springs! +// If bullet is true, you can look up and the distance is further, +// but your total angle span you can look is limited to compensate. (Also, allows monitors.) +// If you modify this, please also modify P_HomingAttack. // -boolean P_LookForEnemies(player_t *player) +mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet) { mobj_t *mo; thinker_t *think; mobj_t *closestmo = NULL; - angle_t an; + const fixed_t maxdist = FixedMul((bullet ? RING_DIST*2 : RING_DIST), player->mo->scale); + const angle_t span = (bullet ? ANG30 : ANGLE_90); + fixed_t dist, closestdist = 0; + const mobjflag_t nonenemiesdisregard = (bullet ? 0 : MF_MONITOR)|MF_SPRING; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; mo = (mobj_t *)think; - if (!(mo->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR|MF_SPRING))) - continue; // not a valid enemy + + if (mo->flags & MF_NOCLIPTHING) + continue; if (mo->health <= 0) // dead continue; + if (!((mo->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR) && (mo->flags & MF_SHOOTABLE)) || (mo->flags & MF_SPRING)) == !(mo->flags2 & MF2_INVERTAIMABLE)) // allows if it has the flags desired XOR it has the invert aimable flag + continue; // not a valid target + if (mo == player->mo) continue; if (mo->flags2 & MF2_FRET) continue; - if ((mo->flags & (MF_ENEMY|MF_BOSS)) && !(mo->flags & MF_SHOOTABLE)) // don't aim at something you can't shoot at anyway (see Egg Guard or Minus) + if (!nonenemies && mo->flags & nonenemiesdisregard) continue; - if (mo->type == MT_DETON) // Don't be STUPID, Sonic! + if (!bullet && mo->type == MT_DETON) // Don't be STUPID, Sonic! continue; - if (((mo->z > player->mo->z+FixedMul(MAXSTEPMOVE, player->mo->scale)) && !(player->mo->eflags & MFE_VERTICALFLIP)) - || ((mo->z+mo->height < player->mo->z+player->mo->height-FixedMul(MAXSTEPMOVE, player->mo->scale)) && (player->mo->eflags & MFE_VERTICALFLIP))) // Reverse gravity check - Flame. - continue; // Don't home upwards! + { + fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); + dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); + if (bullet) + { + if ((R_PointToAngle2(0, 0, dist, zdist) + span) > span*2) + continue; // Don't home outside of desired angle! + } + else // Don't home upwards! + { + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if (mo->z+mo->height < player->mo->z+player->mo->height-FixedMul(MAXSTEPMOVE, player->mo->scale)) + continue; + } + else if (mo->z > player->mo->z+FixedMul(MAXSTEPMOVE, player->mo->scale)) + continue; + } - if (P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y), - player->mo->z-mo->z) > FixedMul(RING_DIST, player->mo->scale)) - continue; // out of range + dist = P_AproxDistance(dist, zdist); + if (dist > maxdist) + continue; // out of range + } if ((twodlevel || player->mo->flags2 & MF2_TWOD) && abs(player->mo->y-mo->y) > player->mo->radius) @@ -7515,57 +9373,60 @@ boolean P_LookForEnemies(player_t *player) if (mo->type == MT_PLAYER) // Don't chase after other players! continue; - if (closestmo && P_AproxDistance(P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y), - player->mo->z-mo->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x, - player->mo->y-closestmo->y), player->mo->z-closestmo->z)) + if (closestmo && dist > closestdist) continue; - an = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y) - player->mo->angle; - - if (an > ANGLE_90 && an < ANGLE_270) + if ((R_PointToAngle2(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius), mo->x, mo->y) - player->mo->angle + span) > span*2) continue; // behind back if (!P_CheckSight(player->mo, mo)) continue; // out of sight closestmo = mo; + closestdist = dist; } - if (closestmo) - { - // Found a target monster - P_SetTarget(&player->mo->target, P_SetTarget(&player->mo->tracer, closestmo)); - player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, closestmo->x, closestmo->y); - return true; - } - - return false; + return closestmo; } -void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target +boolean P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target { + fixed_t zdist; fixed_t dist; fixed_t ns = 0; if (!enemy) - return; + return false; - if (!(enemy->health)) - return; + if (enemy->flags & MF_NOCLIPTHING) + return false; + + if (enemy->health <= 0) // dead + return false; + + if (!((enemy->flags & (MF_ENEMY|MF_BOSS|MF_MONITOR) && (enemy->flags & MF_SHOOTABLE)) || (enemy->flags & MF_SPRING)) == !(enemy->flags2 & MF2_INVERTAIMABLE)) // allows if it has the flags desired XOR it has the invert aimable flag + return false; + + if (enemy->flags2 & MF2_FRET) + return false; // change angle source->angle = R_PointToAngle2(source->x, source->y, enemy->x, enemy->y); - if (source->player && (!demoplayback || P_AnalogMove(source->player))) + if (source->player) { - if (source->player == &players[consoleplayer]) - localangle = source->angle; - else if (source->player == &players[secondarydisplayplayer]) - localangle2 = source->angle; + source->player->drawangle = source->angle; + if (!demoplayback || P_ControlStyle(source->player) == CS_LMAOGALOG) + { + if (source->player == &players[consoleplayer]) + localangle = source->angle; + else if (source->player == &players[secondarydisplayplayer]) + localangle2 = source->angle; + } } // change slope - dist = P_AproxDistance(P_AproxDistance(enemy->x - source->x, enemy->y - source->y), - enemy->z - source->z); + zdist = ((P_MobjFlip(source) == -1) ? (enemy->z + enemy->height) - (source->z + source->height) : (enemy->z - source->z)); + dist = P_AproxDistance(P_AproxDistance(enemy->x - source->x, enemy->y - source->y), zdist); if (dist < 1) dist = 1; @@ -7580,11 +9441,18 @@ void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target ns = FixedMul(source->info->speed, source->scale); } else if (source->player) - ns = FixedDiv(FixedMul(source->player->actionspd, source->scale), 3*FRACUNIT/2); + { + if (source->player->charability == CA_HOMINGTHOK && !(source->player->pflags & PF_SHIELDABILITY)) + ns = FixedDiv(FixedMul(source->player->actionspd, source->scale), 3*FRACUNIT/2); + else + ns = FixedMul(45*FRACUNIT, source->scale); + } source->momx = FixedMul(FixedDiv(enemy->x - source->x, dist), ns); source->momy = FixedMul(FixedDiv(enemy->y - source->y, dist), ns); - source->momz = FixedMul(FixedDiv(enemy->z - source->z, dist), ns); + source->momz = FixedMul(FixedDiv(zdist, dist), ns); + + return true; } // Search for emeralds @@ -7597,9 +9465,9 @@ void P_FindEmerald(void) // scan the remaining thinkers // to find all emeralds - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; @@ -7616,6 +9484,116 @@ void P_FindEmerald(void) return; } +// +// P_GetLives +// Get extra lives in new co-op if you're allowed to. +// + +boolean P_GetLives(player_t *player) +{ + INT32 i, maxlivesplayer = -1, livescheck = 1; + if (!(netgame || multiplayer) + || !G_GametypeUsesCoopLives() + || (player->lives == INFLIVES)) + return true; + + if (cv_cooplives.value == 0) // infinite lives + { + if (player->lives < 1) + player->lives = 1; + return true; + } + + if ((cv_cooplives.value == 2 || cv_cooplives.value == 1) && player->lives > 0) + return true; + + if (cv_cooplives.value == 1) + return false; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].lives > livescheck) + { + maxlivesplayer = i; + livescheck = players[i].lives; + } + } + if (maxlivesplayer != -1 && &players[maxlivesplayer] != player) + { + if (cv_cooplives.value == 2 && (P_IsLocalPlayer(player) || P_IsLocalPlayer(&players[maxlivesplayer]))) + S_StartSound(NULL, sfx_jshard); // placeholder + if (players[maxlivesplayer].lives != INFLIVES) + players[maxlivesplayer].lives--; + player->lives++; + if (player->lives < 1) + player->lives = 1; + return true; + } + return (player->lives > 0); +} + +// +// P_ConsiderAllGone +// Shamelessly lifted from TD. Thanks, Sryder! +// + +static void P_ConsiderAllGone(void) +{ + INT32 i, lastdeadplayer = -1, deadtimercheck = INT32_MAX; + + if (countdown2) + return; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].playerstate != PST_DEAD && !players[i].spectator && players[i].mo && players[i].mo->health) + break; + + if (players[i].spectator) + { + if (lastdeadplayer == -1) + lastdeadplayer = i; + } + else if (players[i].lives > 0) + { + lastdeadplayer = i; + if (players[i].deadtimer < deadtimercheck) + deadtimercheck = players[i].deadtimer; + } + } + + if (i == MAXPLAYERS && lastdeadplayer != -1 && deadtimercheck > 2*TICRATE) // the last killed player will reset the level in G_DoReborn + { + //players[lastdeadplayer].spectator = true; + players[lastdeadplayer].outofcoop = true; + players[lastdeadplayer].playerstate = PST_REBORN; + } +} + +void P_RestoreMultiMusic(player_t *player) +{ + if (netgame) + { + if (P_IsLocalPlayer(player)) + S_ChangeMusic(mapmusname, mapmusflags, true); + } + else if (multiplayer) // local multiplayer only + { + // Restore the other player's music once we're dead for long enough + // -- that is, as long as they aren't dead too + if (player == &players[displayplayer] && players[secondarydisplayplayer].lives > 0) + P_RestoreMusic(&players[secondarydisplayplayer]); + else if (player == &players[secondarydisplayplayer] && players[displayplayer].lives > 0) + P_RestoreMusic(&players[displayplayer]); + } +} + // // P_DeathThink // Fall on your face when dying. @@ -7624,6 +9602,8 @@ void P_FindEmerald(void) static void P_DeathThink(player_t *player) { + INT32 j = MAXPLAYERS; + ticcmd_t *cmd = &player->cmd; player->deltaviewheight = 0; @@ -7636,90 +9616,111 @@ static void P_DeathThink(player_t *player) // continue logic if (!(netgame || multiplayer) && player->lives <= 0) { - if (player->deadtimer > TICRATE && (cmd->buttons & BT_USE || cmd->buttons & BT_JUMP) && player->continues > 0) + if (player->deadtimer > (3*TICRATE) && (cmd->buttons & BT_USE || cmd->buttons & BT_JUMP) && player->continues > 0) G_UseContinue(); else if (player->deadtimer >= gameovertics) G_UseContinue(); // Even if we don't have one this handles ending the game } + if ((cv_cooplives.value != 1) + && (gametype == GT_COOP) + && (netgame || multiplayer) + && (player->lives <= 0)) + { + for (j = 0; j < MAXPLAYERS; j++) + { + if (!playeringame[j]) + continue; + + if (players[j].lives > 1) + break; + } + } + // Force respawn if idle for more than 30 seconds in shooter modes. if (player->deadtimer > 30*TICRATE && !G_PlatformGametype()) player->playerstate = PST_REBORN; - else if (player->lives > 0 && !G_IsSpecialStage(gamemap)) // Don't allow "click to respawn" in special stages! + else if ((player->lives > 0 || j != MAXPLAYERS) && !(!(netgame || multiplayer) && G_IsSpecialStage(gamemap))) // Don't allow "click to respawn" in special stages! { - // Respawn with jump button, force respawn time (3 second default, cheat protected) in shooter modes. - if ((cmd->buttons & BT_JUMP) && player->deadtimer > cv_respawntime.value*TICRATE - && gametype != GT_RACE && gametype != GT_COOP) - player->playerstate = PST_REBORN; - - // Instant respawn in race or if you're spectating. - if ((cmd->buttons & BT_JUMP) && (gametype == GT_RACE || player->spectator)) - player->playerstate = PST_REBORN; - - // One second respawn in coop. - if ((cmd->buttons & BT_JUMP) && player->deadtimer > TICRATE && (gametype == GT_COOP || gametype == GT_COMPETITION)) - player->playerstate = PST_REBORN; - - // Single player auto respawn - if (!(netgame || multiplayer) && player->deadtimer > 5*TICRATE) - player->playerstate = PST_REBORN; - } - else if ((netgame || multiplayer) && player->deadtimer == 8*TICRATE) - { - // In a net/multiplayer game, and out of lives - if (gametype == GT_COMPETITION) + if (G_GametypeUsesCoopStarposts() && (netgame || multiplayer) && cv_coopstarposts.value == 2) { - INT32 i; + P_ConsiderAllGone(); + if ((player->deadtimer > TICRATE<<1) || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE))) + { + //player->spectator = true; + player->outofcoop = true; + player->playerstate = PST_REBORN; + } + } + else + { + // Respawn with jump button, force respawn time (3 second default, cheat protected) in shooter modes. + if (cmd->buttons & BT_JUMP) + { + // You're a spectator, so respawn right away. + if ((gametyperules & GTR_SPECTATORS) && player->spectator) + player->playerstate = PST_REBORN; + else + { + // Give me one second. + INT32 respawndelay = TICRATE; + // Non-platform gametypes + if (gametyperules & GTR_RESPAWNDELAY) + respawndelay = (cv_respawntime.value*TICRATE); + + // You've been dead for enough time. + // You may now respawn. + if (player->deadtimer > respawndelay) + player->playerstate = PST_REBORN; + } + } + + // Single player auto respawn + if (!(netgame || multiplayer) && player->deadtimer > TICRATE<<1) + player->playerstate = PST_REBORN; + } + } + else if ((netgame || multiplayer) && player->deadtimer >= 8*TICRATE) + { + INT32 i, deadtimercheck = INT32_MAX; + + // In a net/multiplayer game, and out of lives + if (G_CompetitionGametype()) + { for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && !players[i].exiting && players[i].lives > 0) + { + if (!playeringame[i]) + continue; + if (!players[i].exiting && players[i].lives) break; + if (players[i].deadtimer < deadtimercheck) + deadtimercheck = players[i].deadtimer; + } - if (i == MAXPLAYERS) + if (i == MAXPLAYERS && deadtimercheck == 8*TICRATE) { // Everyone's either done with the race, or dead. if (!countdown2 || countdown2 > 1*TICRATE) countdown2 = 1*TICRATE; } } - - // In a coop game, and out of lives - if (gametype == GT_COOP) - { - INT32 i; - - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (players[i].exiting || players[i].lives > 0)) - break; - - if (i == MAXPLAYERS) - { - // They're dead, Jim. - //nextmapoverride = spstage_start; - nextmapoverride = gamemap; - countdown2 = 1*TICRATE; - skipstats = true; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - players[i].score = 0; - } - - //emeralds = 0; - tokenbits = 0; - tokenlist = 0; - token = 0; - } - } + //else if (gametype == GT_COOP) -- moved to G_DoReborn } - if (gametype == GT_RACE || gametype == GT_COMPETITION || (gametype == GT_COOP && (multiplayer || netgame))) + if (gametype == GT_COOP && (multiplayer || netgame) && (player->lives <= 0) && (player->deadtimer >= 8*TICRATE || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE)))) + { + //player->spectator = true; + player->outofcoop = true; + player->playerstate = PST_REBORN; + } + + if ((gametyperules & GTR_RACE) || (gametype == GT_COOP && (multiplayer || netgame))) { // Keep time rolling in race mode - if (!(countdown2 && !countdown) && !player->exiting && !(player->pflags & PF_TIMEOVER)) + if (!(countdown2 && !countdown) && !player->exiting && !(player->pflags & PF_GAMETYPEOVER) && !stoppedclock) { - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) { if (leveltime >= 4*TICRATE) player->realtime = leveltime - 4*TICRATE; @@ -7731,25 +9732,8 @@ static void P_DeathThink(player_t *player) } // Return to level music - if (player->lives <= 0) - { - if (netgame) - { - if (player->deadtimer == gameovertics && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - } - else if (multiplayer) // local multiplayer only - { - if (player->deadtimer != gameovertics) - ; - // Restore the other player's music once we're dead for long enough - // -- that is, as long as they aren't dead too - else if (player == &players[displayplayer] && players[secondarydisplayplayer].lives > 0) - P_RestoreMusic(&players[secondarydisplayplayer]); - else if (player == &players[secondarydisplayplayer] && players[displayplayer].lives > 0) - P_RestoreMusic(&players[displayplayer]); - } - } + if (gametype != GT_COOP && player->lives <= 0 && player->deadtimer == gameovertics) + P_RestoreMultiMusic(player); } notrealplayer: @@ -7783,21 +9767,64 @@ static void CV_CamRotate2_OnChange(void) } static CV_PossibleValue_t CV_CamSpeed[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t rotation_cons_t[] = {{1, "MIN"}, {45, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t rotation_cons_t[] = {{1, "MIN"}, {25, "MAX"}, {0, NULL}}; static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t multiplier_cons_t[] = {{0, "MIN"}, {3*FRACUNIT, "MAX"}, {0, NULL}}; -consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_height = {"cam_height", "25", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_dist = {"cam_curdist", "160", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_height = {"cam_curheight", "25", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_speed = {"cam_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_height = {"cam2_height", "25", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_turnmultiplier = {"cam_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_orbit = {"cam_orbit", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_adjust = {"cam_adjust", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_dist = {"cam2_curdist", "160", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_height = {"cam2_curheight", "25", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_speed = {"cam2_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotspeed = {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_turnmultiplier = {"cam2_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_orbit = {"cam2_orbit", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_adjust = {"cam2_adjust", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +// [standard vs simple][p1 or p2] +consvar_t cv_cam_savedist[2][2] = { + { // standard + {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + }, + { // simple + {"cam_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + + } +}; +consvar_t cv_cam_saveheight[2][2] = { + { // standard + {"cam_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + }, + { // simple + {"cam_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + + } +}; + +void CV_UpdateCamDist(void) +{ + CV_Set(&cv_cam_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_useranalog[0].value][0].value))); + CV_Set(&cv_cam_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_useranalog[0].value][0].value))); +} + +void CV_UpdateCam2Dist(void) +{ + CV_Set(&cv_cam2_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_useranalog[1].value][1].value))); + CV_Set(&cv_cam2_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_useranalog[1].value][1].value))); +} fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; @@ -7823,17 +9850,23 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) x = player->mo->x - P_ReturnThrustX(player->mo, thiscam->angle, player->mo->radius); y = player->mo->y - P_ReturnThrustY(player->mo, thiscam->angle, player->mo->radius); if (player->mo->eflags & MFE_VERTICALFLIP) - z = player->mo->z + player->mo->height - (cv_viewheight.value<mo->z + player->mo->height - (41*player->height/48) - 16*FRACUNIT; else - z = player->mo->z + (cv_viewheight.value<mo->z + (41*player->height/48); // set bits for the camera thiscam->x = x; thiscam->y = y; thiscam->z = z; - if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) - && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value))) + if ((thiscam == &camera && G_ControlStyle(1) == CS_SIMPLE) + || (thiscam == &camera2 && G_ControlStyle(2) == CS_SIMPLE)) + { + thiscam->angle = (thiscam == &camera) ? localangle : localangle2; + thiscam->aiming = (thiscam == &camera) ? localaiming : localaiming2; + } + else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog[0].value)) + && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog[1].value))) { thiscam->angle = player->mo->angle; thiscam->aiming = 0; @@ -7851,22 +9884,46 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled) { angle_t angle = 0, focusangle = 0, focusaiming = 0; - fixed_t x, y, z, dist, checkdist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; + fixed_t x, y, z, dist, distxy, distz, checkdist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight, slopez = 0; INT32 camrotate; - boolean camstill, cameranoclip; - mobj_t *mo; + boolean camstill, cameranoclip, camorbit; + mobj_t *mo, *sign = NULL; subsector_t *newsubsec; fixed_t f1, f2; + static fixed_t camsideshift[2] = {0, 0}; + fixed_t shiftx = 0, shifty = 0; + // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) return true; mo = player->mo; - cameranoclip = (player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! + if (player->playerstate == PST_REBORN) + { + P_CalcChasePostImg(player, thiscam); + return true; + } - if (!(player->climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD)) + if (player->exiting) + { + if (mo->target && mo->target->type == MT_SIGN && mo->target->spawnpoint + && !(gametype == GT_COOP && (netgame || multiplayer) && cv_exitmove.value) + && !(twodlevel || (mo->flags2 & MF2_TWOD))) + sign = mo->target; + else if ((player->powers[pw_carry] == CR_NIGHTSMODE) + && !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6])) + { + P_CalcChasePostImg(player, thiscam); + return true; + } + } + + cameranoclip = (sign || player->powers[pw_carry] == CR_NIGHTSMODE || player->pflags & PF_NOCLIP) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! + + if (!(player->climbing || (player->powers[pw_carry] == CR_NIGHTSMODE) || player->playerstate == PST_DEAD || tutorialmode)) { if (player->spectator) // force cam off for spectators return true; @@ -7905,11 +9962,16 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // if (leveltime > 0 && timeinmap <= 0) // return true; - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) { focusangle = mo->angle; focusaiming = 0; } + else if (sign) + { + focusangle = FixedAngle(sign->spawnpoint->angle << FRACBITS) + ANGLE_180; + focusaiming = 0; + } else if (player == &players[consoleplayer]) { focusangle = localangle; @@ -7922,17 +9984,28 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else { - focusangle = mo->angle; + focusangle = player->cmd.angleturn << 16; focusaiming = player->aiming; } if (P_CameraThinker(player, thiscam, resetcalled)) return true; - if (thiscam == &camera) + if (tutorialmode) + { + // force defaults because we have a camera look section + camspeed = (INT32)(atof(cv_cam_speed.defaultvalue) * FRACUNIT); + camstill = (!stricmp(cv_cam_still.defaultvalue, "off")) ? false : true; + camorbit = (!stricmp(cv_cam_orbit.defaultvalue, "off")) ? false : true; + camrotate = atoi(cv_cam_rotate.defaultvalue); + camdist = FixedMul((INT32)(atof(cv_cam_dist.defaultvalue) * FRACUNIT), mo->scale); + camheight = FixedMul((INT32)(atof(cv_cam_height.defaultvalue) * FRACUNIT), mo->scale); + } + else if (thiscam == &camera) { camspeed = cv_cam_speed.value; camstill = cv_cam_still.value; + camorbit = cv_cam_orbit.value; camrotate = cv_cam_rotate.value; camdist = FixedMul(cv_cam_dist.value, mo->scale); camheight = FixedMul(cv_cam_height.value, mo->scale); @@ -7941,13 +10014,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { camspeed = cv_cam2_speed.value; camstill = cv_cam2_still.value; + camorbit = cv_cam2_orbit.value; camrotate = cv_cam2_rotate.value; camdist = FixedMul(cv_cam2_dist.value, mo->scale); camheight = FixedMul(cv_cam2_height.value, mo->scale); } + if (!(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->powers[pw_carry] == CR_NIGHTSMODE)) + camheight = FixedMul(camheight, player->camerascale); + #ifdef REDSANALOG - if (P_AnalogMove(player) && (player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)) { + if (P_ControlStyle(player) == CS_LMAOGALOG && (player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)) { camstill = true; if (camspeed < 4*FRACUNIT/5) @@ -7962,7 +10039,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle = ANGLE_90; else if (camstill || resetcalled || player->playerstate == PST_DEAD) angle = thiscam->angle; - else if (player->pflags & PF_NIGHTSMODE) // NiGHTS Level + else if (player->powers[pw_carry] == CR_NIGHTSMODE) // NiGHTS Level { if ((player->pflags & PF_TRANSFERTOCLOSEST) && player->axis1 && player->axis2) { @@ -7971,13 +10048,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else if (mo->target) { - if (mo->target->flags & MF_AMBUSH) + if (mo->target->flags2 & MF2_AMBUSH) angle = R_PointToAngle2(mo->target->x, mo->target->y, mo->x, mo->y); else angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y); } } - else if (P_AnalogMove(player)) // Analog + else if (P_ControlStyle(player) == CS_LMAOGALOG && !sign) // Analog angle = R_PointToAngle2(thiscam->x, thiscam->y, mo->x, mo->y); else if (demoplayback) { @@ -7994,90 +10071,135 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else angle = focusangle + FixedAngle(camrotate*FRACUNIT); - if (!resetcalled && (cv_analog.value || demoplayback) && ((thiscam == &camera && t_cam_rotate != -42) || (thiscam == &camera2 + if (!resetcalled && (cv_analog[0].value || demoplayback) && ((thiscam == &camera && t_cam_rotate != -42) || (thiscam == &camera2 && t_cam2_rotate != -42))) { angle = FixedAngle(camrotate*FRACUNIT); thiscam->angle = angle; } - if (!objectplacing && !(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->pflags & PF_NIGHTSMODE) && displayplayer == consoleplayer) + if ((((thiscam == &camera) && cv_analog[0].value) || ((thiscam != &camera) && cv_analog[1].value) || demoplayback) && !sign && !objectplacing && !(twodlevel || (mo->flags2 & MF2_TWOD)) && (player->powers[pw_carry] != CR_NIGHTSMODE) && displayplayer == consoleplayer) { #ifdef REDSANALOG if ((player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)); else #endif - if (player->cmd.buttons & BT_CAMLEFT) + if (player->cmd.buttons & BT_CAMRIGHT) { if (thiscam == &camera) - { - if (cv_analog.value || demoplayback) - angle -= FixedAngle(cv_cam_rotspeed.value*FRACUNIT); - else - CV_SetValue(&cv_cam_rotate, camrotate == 0 ? 358 - : camrotate - 2); - } + angle -= FixedAngle(cv_cam_rotspeed.value*FRACUNIT); else - { - if (cv_analog2.value) - angle -= FixedAngle(cv_cam2_rotspeed.value*FRACUNIT); - else - CV_SetValue(&cv_cam2_rotate, camrotate == 0 ? 358 - : camrotate - 2); - } + angle -= FixedAngle(cv_cam2_rotspeed.value*FRACUNIT); } - else if (player->cmd.buttons & BT_CAMRIGHT) + else if (player->cmd.buttons & BT_CAMLEFT) { if (thiscam == &camera) - { - if (cv_analog.value || demoplayback) - angle += FixedAngle(cv_cam_rotspeed.value*FRACUNIT); - else - CV_SetValue(&cv_cam_rotate, camrotate + 2); - } + angle += FixedAngle(cv_cam_rotspeed.value*FRACUNIT); else - { - if (cv_analog2.value) - angle += FixedAngle(cv_cam2_rotspeed.value*FRACUNIT); - else - CV_SetValue(&cv_cam2_rotate, camrotate + 2); - } + angle += FixedAngle(cv_cam2_rotspeed.value*FRACUNIT); } } + if (G_ControlStyle((thiscam == &camera) ? 1 : 2) == CS_SIMPLE && !sign) + { + // Shift the camera slightly to the sides depending on the player facing direction + UINT8 forplayer = (thiscam == &camera) ? 0 : 1; + fixed_t shift = FixedMul(FINESINE((player->mo->angle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); + + if (player->powers[pw_carry] == CR_NIGHTSMODE) + { + fixed_t cos = FINECOSINE((angle_t) (player->flyangle * ANG1)>>ANGLETOFINESHIFT); + shift = FixedMul(shift, min(FRACUNIT, player->speed*abs(cos)/6000)); + shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>2)); + } + else if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1]) + shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed); + else + shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3)); + camsideshift[forplayer] = shift; + + shift = FixedMul(shift, camdist); + shiftx = -FixedMul(FINESINE(angle>>ANGLETOFINESHIFT), shift); + shifty = FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT), shift); + } + // sets ideal cam pos if (twodlevel || (mo->flags2 & MF2_TWOD)) dist = 480<pflags & PF_NIGHTSMODE) + else if (player->powers[pw_carry] == CR_NIGHTSMODE + || ((maptol & TOL_NIGHTS) && player->capsule && player->capsule->reactiontime > 0 && player == &players[player->capsule->reactiontime-1])) dist = 320<scale << 7; + camspeed = FRACUNIT/12; } - - // x1.2 dist for analog - if (P_AnalogMove(player)) + else if (P_ControlStyle(player) == CS_LMAOGALOG) // x1.2 dist for analog { dist = FixedMul(dist, 6*FRACUNIT/5); camheight = FixedMul(camheight, 6*FRACUNIT/5); } - if (player->climbing || player->exiting || player->playerstate == PST_DEAD || (player->pflags & (PF_MACESPIN|PF_ITEMHANG|PF_ROPEHANG))) + if (player->climbing || player->exiting || player->playerstate == PST_DEAD || (player->powers[pw_carry] == CR_ROPEHANG || player->powers[pw_carry] == CR_GENERIC || player->powers[pw_carry] == CR_MACESPIN)) dist <<= 1; } + if (!sign && !(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->powers[pw_carry] == CR_NIGHTSMODE)) + dist = FixedMul(dist, player->camerascale); + checkdist = dist; if (checkdist < 128*FRACUNIT) checkdist = 128*FRACUNIT; - x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); - y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + if (!(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->powers[pw_carry] == CR_NIGHTSMODE)) // This block here is like 90% Lach's work, thanks bud + { + if (!resetcalled && ((thiscam == &camera && cv_cam_adjust.value) || (thiscam == &camera2 && cv_cam2_adjust.value))) + { + if (!(mo->eflags & MFE_JUSTHITFLOOR) && (P_IsObjectOnGround(mo)) // Check that player is grounded + && thiscam->ceilingz - thiscam->floorz >= P_GetPlayerHeight(player)) // Check that camera's sector is large enough for the player to fit into, at least + { + if (mo->eflags & MFE_VERTICALFLIP) // if player is upside-down + { + //z = min(z, thiscam->ceilingz); // solution 1: change new z coordinate to be at LEAST its ground height + slopez += min(thiscam->ceilingz - mo->z, 0); // solution 2: change new z coordinate by the difference between camera's ground and top of player + } + else // player is not upside-down + { + //z = max(z, thiscam->floorz); // solution 1: change new z coordinate to be at LEAST its ground height + slopez += max(thiscam->floorz - mo->z - mo->height, 0); // solution 2: change new z coordinate by the difference between camera's ground and top of player + } + } + } + } + + if (camorbit) //Sev here, I'm guessing this is where orbital cam lives + { + if (rendermode == render_opengl) + distxy = FixedMul(dist, FINECOSINE((focusaiming>>ANGLETOFINESHIFT) & FINEMASK)); + else + distxy = dist; + distz = -FixedMul(dist, FINESINE((focusaiming>>ANGLETOFINESHIFT) & FINEMASK)) + slopez; + } + else + { + distxy = dist; + distz = slopez; + } + + if (sign) + { + x = sign->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); + y = sign->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); + } + else + { + x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); + y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy); + } #if 0 if (twodlevel || (mo->flags2 & MF2_TWOD)) @@ -8111,15 +10233,25 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } #endif // bad 2D camera code - pviewheight = FixedMul(cv_viewheight.value<scale); + pviewheight = FixedMul(41*player->height/48, mo->scale); - if (mo->eflags & MFE_VERTICALFLIP) - z = mo->z + mo->height - pviewheight - camheight; + if (sign) + { + if (sign->eflags & MFE_VERTICALFLIP) + z = sign->ceilingz - pviewheight - camheight; + else + z = sign->floorz + pviewheight + camheight; + } else - z = mo->z + pviewheight + camheight; + { + if (mo->eflags & MFE_VERTICALFLIP) + z = mo->z + mo->height - pviewheight - camheight + distz; + else + z = mo->z + pviewheight + camheight + distz; + } // move camera down to move under lower ceilings - newsubsec = R_IsPointInSubsector(((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1), ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1)); + newsubsec = R_PointInSubsectorOrNull(((mo->x>>FRACBITS) + (thiscam->x>>FRACBITS))<<(FRACBITS-1), ((mo->y>>FRACBITS) + (thiscam->y>>FRACBITS))<<(FRACBITS-1)); if (!newsubsec) newsubsec = thiscam->subsector; @@ -8322,15 +10454,20 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // point viewed by the camera // this point is just 64 unit forward the player dist = FixedMul(64 << FRACBITS, mo->scale); - viewpointx = mo->x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); - viewpointy = mo->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + if (sign) + { + viewpointx = sign->x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + viewpointy = sign->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + } + else + { + viewpointx = mo->x + shiftx + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + viewpointy = mo->y + shifty + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + } if (!camstill && !resetcalled && !paused) thiscam->angle = R_PointToAngle2(thiscam->x, thiscam->y, viewpointx, viewpointy); - viewpointx = mo->x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); - viewpointy = mo->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); - /* if (twodlevel || (mo->flags2 & MF2_TWOD)) thiscam->angle = angle; @@ -8366,6 +10503,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else thiscam->momz = FixedMul(z - thiscam->z, camspeed); + + thiscam->momx += FixedMul(shiftx, camspeed); + thiscam->momy += FixedMul(shifty, camspeed); } // compute aming to look the viewed point @@ -8374,10 +10514,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall dist = FixedHypot(f1, f2); if (mo->eflags & MFE_VERTICALFLIP) - angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - P_GetPlayerHeight(player)); + angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, (sign ? sign->ceilingz : mo->z + mo->height) - P_GetPlayerHeight(player)); else - angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + P_GetPlayerHeight(player)); - if (player->playerstate != PST_DEAD && !(player->pflags & PF_NIGHTSMODE && player->exiting)) + angle = R_PointToAngle2(0, thiscam->z, dist, (sign ? sign->floorz : mo->z) + P_GetPlayerHeight(player)); + if (player->playerstate != PST_DEAD) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' if (twodlevel || (mo->flags2 & MF2_TWOD) || !camstill) // Keep the view still... @@ -8391,13 +10531,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (!(multiplayer || netgame) && !splitscreen) { fixed_t vx = thiscam->x, vy = thiscam->y; + fixed_t vz = thiscam->z + thiscam->height / 2; if (player->awayviewtics && player->awayviewmobj != NULL && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { vx = player->awayviewmobj->x; vy = player->awayviewmobj->y; + vz = player->awayviewmobj->z + player->awayviewmobj->height / 2; } - if (P_AproxDistance(vx - mo->x, vy - mo->y) < FixedMul(48*FRACUNIT, mo->scale)) + /* check z distance too for orbital camera */ + if (P_AproxDistance(P_AproxDistance(vx - mo->x, vy - mo->y), + vz - ( mo->z + mo->height / 2 )) < FixedMul(48*FRACUNIT, mo->scale)) mo->flags2 |= MF2_SHADOW; else mo->flags2 &= ~MF2_SHADOW; @@ -8405,7 +10549,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else mo->flags2 &= ~MF2_SHADOW; -/* if (!resetcalled && (player->pflags & PF_NIGHTSMODE && player->exiting)) +/* if (!resetcalled && (player->powers[pw_carry] == CR_NIGHTSMODE && player->exiting)) { // Don't let the camera match your movement. thiscam->momz = 0; @@ -8429,18 +10573,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); + } -static boolean P_SpectatorJoinGame(player_t *player) +boolean P_SpectatorJoinGame(player_t *player) { - if (!G_GametypeHasSpectators() && G_IsSpecialStage(gamemap) && useNightsSS) // Special Stage spectators should NEVER be allowed to rejoin the game - { - if (P_IsLocalPlayer(player)) - CONS_Printf(M_GetText("You cannot enter the game while a special stage is in progress.\n")); - player->powers[pw_flashing] += 2*TICRATE; //to prevent message spam. - } - - else if (!cv_allowteamchange.value) + if (gametype != GT_COOP && !cv_allowteamchange.value) { if (P_IsLocalPlayer(player)) CONS_Printf(M_GetText("Server does not allow team change.\n")); @@ -8477,6 +10615,9 @@ static boolean P_SpectatorJoinGame(player_t *player) else changeto = (P_RandomFixed() & 1) + 1; + if (!LUAh_TeamSwitch(player, changeto, true, false, false)) + return false; + if (player->mo) { P_RemoveMobj(player->mo); @@ -8488,7 +10629,12 @@ static boolean P_SpectatorJoinGame(player_t *player) //Reset away view if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) + { + // Call ViewpointSwitch hooks here. + // The viewpoint was forcibly changed. + LUAh_ViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; + } if (changeto == 1) CONS_Printf(M_GetText("%s switched to the %c%s%c.\n"), player_names[player-players], '\x85', M_GetText("Red team"), '\x80'); @@ -8502,14 +10648,16 @@ static boolean P_SpectatorJoinGame(player_t *player) { // Exception for hide and seek. Don't join a game when you simply // respawn in place and sit there for the rest of the round. - if (!(gametype == GT_HIDEANDSEEK && leveltime > (hidetime * TICRATE))) + if (!((gametyperules & GTR_HIDEFROZEN) && leveltime > (hidetime * TICRATE))) { + if (!LUAh_TeamSwitch(player, 3, true, false, false)) + return false; if (player->mo) { P_RemoveMobj(player->mo); player->mo = NULL; } - player->spectator = false; + player->spectator = player->outofcoop = false; player->playerstate = PST_REBORN; if (gametype == GT_TAG) @@ -8526,9 +10674,15 @@ static boolean P_SpectatorJoinGame(player_t *player) //Reset away view if (P_IsLocalPlayer(player) && displayplayer != consoleplayer) + { + // Call ViewpointSwitch hooks here. + // The viewpoint was forcibly changed. + LUAh_ViewpointSwitch(player, &players[consoleplayer], true); displayplayer = consoleplayer; + } - CONS_Printf(M_GetText("%s entered the game.\n"), player_names[player-players]); + if (gametype != GT_COOP) + CONS_Printf(M_GetText("%s entered the game.\n"), player_names[player-players]); return true; // no more player->mo, cannot continue. } else @@ -8541,6 +10695,7 @@ static boolean P_SpectatorJoinGame(player_t *player) return false; } +// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam static void P_CalcPostImg(player_t *player) { sector_t *sector = player->mo->subsector->sector; @@ -8650,21 +10805,771 @@ void P_DoPityCheck(player_t *player) { // No pity outside of match or CTF. if (player->spectator - || !(gametype == GT_MATCH || gametype == GT_TEAMMATCH || gametype == GT_CTF)) + || !(gametyperules & GTR_PITYSHIELD)) return; // Apply pity shield if available. if ((player->pity >= 3 || player->pity < 0) && player->powers[pw_shield] == SH_NONE) { + P_SwitchShield(player, SH_PITY); + if (player->pity > 0) - S_StartSound(player->mo, mobjinfo[MT_PITYSHIELDICO].seesound); + S_StartSound(player->mo, mobjinfo[MT_PITY_ICON].seesound); player->pity = 0; - player->powers[pw_shield] = SH_PITY; - P_SpawnShieldOrb(player); } } + +static sector_t *P_GetMinecartSector(fixed_t x, fixed_t y, fixed_t z, fixed_t *nz) +{ + sector_t *sec = R_PointInSubsector(x, y)->sector; + + if ((sec->ceilingheight - sec->floorheight) < 64*FRACUNIT) + return NULL; + + if (sec->ffloors) + { + ffloor_t *rover; + for (rover = sec->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & (FF_EXISTS|FF_BLOCKOTHERS))) + continue; + + *nz = *rover->t_slope ? P_GetZAt(*rover->t_slope, x, y) : *rover->topheight; + if (abs(z - *nz) <= 56*FRACUNIT) + { + sec = §ors[rover->secnum]; + return sec; + } + } + + } + + *nz = sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : sec->floorheight; + if (abs(z - *nz) > 56*FRACUNIT) + return NULL; + + return sec; +} + +static INT32 P_GetMinecartSpecialLine(sector_t *sec) +{ + INT32 line = -1; + + if (!sec) + return line; + + if (sec->tag != 0) + line = P_FindSpecialLineFromTag(16, sec->tag, -1); + + // Also try for lines facing the sector itself, with tag 0. + { + UINT32 i; + for (i = 0; i < sec->linecount; i++) + { + line_t *li = sec->lines[i]; + if (li->tag == 0 && li->special == 16 && li->frontsector == sec) + line = li - lines; + } + } + + return line; +} + +// Get an axis of a certain ID number +static mobj_t *P_GetAxis(INT32 num) +{ + thinker_t *th; + mobj_t *mobj; + + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mobj = (mobj_t *)th; + + // NiGHTS axes spawn before anything else. If this mobj doesn't have MF2_AXIS, it means we reached the axes' end. + if (!(mobj->flags2 & MF2_AXIS)) + break; + + // Skip if this axis isn't the one we want. + if (mobj->health != num) + continue; + + return mobj; + } + + CONS_Alert(CONS_WARNING, "P_GetAxis: Track segment %d is missing!\n", num); + return NULL; +} + +// Auxiliary function. For a given position and axis, it calculates the nearest "valid" snap-on position. +static void P_GetAxisPosition(fixed_t x, fixed_t y, mobj_t *amo, fixed_t *newx, fixed_t *newy, angle_t *targetangle, angle_t *grind) +{ + fixed_t ax = amo->x; + fixed_t ay = amo->y; + angle_t ang; + angle_t gr = 0; + + if (amo->type == MT_AXISTRANSFERLINE) + { + ang = amo->angle; + // Extra security for cardinal directions. + if (ang == ANGLE_90 || ang == ANGLE_270) // Vertical lines + x = ax; + else if (ang == 0 || ang == ANGLE_180) // Horizontal lines + y = ay; + else // Diagonal lines + { + fixed_t distance = R_PointToDist2(ax, ay, x, y); + angle_t fad = ((R_PointToAngle2(ax, ay, x, y) - ang) >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t cosine = FINECOSINE(fad); + angle_t fa = (ang >> ANGLETOFINESHIFT) & FINEMASK; + distance = FixedMul(distance, cosine); + x = ax + FixedMul(distance, FINECOSINE(fa)); + y = ay + FixedMul(distance, FINESINE(fa)); + } + } + else // Keep minecart to circle + { + fixed_t rad = amo->radius; + fixed_t distfactor = FixedDiv(rad, R_PointToDist2(ax, ay, x, y)); + + gr = R_PointToAngle2(ax, ay, x, y); + ang = gr + ANGLE_90; + x = ax + FixedMul(x - ax, distfactor); + y = ay + FixedMul(y - ay, distfactor); + } + + *newx = x; + *newy = y; + *targetangle = ang; + *grind = gr; +} + +static void P_SpawnSparks(mobj_t *mo, angle_t maindir) +{ + angle_t fa = (mo->angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t c = FixedMul(FINECOSINE(fa), mo->radius); + fixed_t s = FixedMul(FINESINE(fa), mo->radius); + mobj_t *spark; + SINT8 b1 = (leveltime & 1) ? 1 : -1; + SINT8 b2 = (leveltime & 2) ? 1 : -1; + fixed_t r1 = FRACUNIT*P_RandomRange(-1, 1); + fixed_t r2 = FRACUNIT*P_RandomRange(-1, 1); + fixed_t r3 = FRACUNIT*P_RandomRange(-1, 1); + fixed_t fm = (maindir >> ANGLETOFINESHIFT) & FINEMASK; + + spark = P_SpawnMobj(mo->x - b2*s + b1*c, mo->y + b2*c + b1*s, mo->z, MT_MINECARTSPARK); + spark->momx = mo->momx + r1 + 8*FINECOSINE(fm); + spark->momy = mo->momy + r2 + 8*FINESINE(fm); + spark->momz = mo->momz + r3; + + P_Thrust(spark, R_PointToAngle2(mo->x, mo->y, spark->x, spark->y), 8*FRACUNIT); + P_SetScale(spark, FRACUNIT/4); + spark->destscale = spark->scale; + spark->fuse = TICRATE/3; +} + +// Performs a proximity check on a given direction looking for rails. +static mobj_t *P_LookForRails(mobj_t* mobj, fixed_t c, fixed_t s, angle_t targetangle, fixed_t xcom, fixed_t ycom) +{ + INT16 interval = 16; + INT16 fwooffset = FixedHypot(mobj->momx, mobj->momy) >> FRACBITS; + fixed_t x = mobj->x; + fixed_t y = mobj->y; + fixed_t z = mobj->z; + UINT8 i; + + for (i = 4; i <= 10; i++) + { + fixed_t nz; + INT32 lline; + + x += interval*xcom*i + fwooffset*c*i; + y += interval*ycom*i + fwooffset*s*i; + + lline = P_GetMinecartSpecialLine(P_GetMinecartSector(x, y, z, &nz)); + if (lline != -1) + { + fixed_t nx, ny; + angle_t nang, dummy, angdiff; + mobj_t *mark; + mobj_t *snax = P_GetAxis(sides[lines[lline].sidenum[0]].textureoffset >> FRACBITS); + if (!snax) + return NULL; + P_GetAxisPosition(x, y, snax, &nx, &ny, &nang, &dummy); + angdiff = ((nang - targetangle) + ANG10/2) & ~ANGLE_180; + //Axes must be directly parallel or antiparallel, give or take 5 degrees. + if (angdiff < ANG10) + { + mark = P_SpawnMobj(nx, ny, nz, (mobjtype_t)mobj->info->raisestate); + return mark; + } + } + } + return NULL; +} + +static void P_ParabolicMove(mobj_t *mo, fixed_t x, fixed_t y, fixed_t z, fixed_t g, fixed_t speed) +{ + fixed_t dx = x - mo->x; + fixed_t dy = y - mo->y; + fixed_t dz = z - mo->z; + fixed_t dh = P_AproxDistance(dx, dy); + fixed_t c = FixedDiv(dx, dh); + fixed_t s = FixedDiv(dy, dh); + fixed_t fixConst = FixedDiv(speed, g); + + mo->momx = FixedMul(c, speed); + mo->momy = FixedMul(s, speed); + mo->momz = FixedDiv(dh, 2*fixConst) + FixedDiv(dz, FixedDiv(dh, fixConst/2)); +} + +static void P_MinecartThink(player_t *player) +{ + mobj_t *minecart = player->mo->tracer; + angle_t fa; + + if (!minecart || P_MobjWasRemoved(minecart) || !minecart->health) + { + // Minecart died on you, so kill yourself. + P_KillMobj(player->mo, NULL, NULL, 0); + return; + } + + //Limit player's angle to a cone. +#define MINECARTCONEMAX FixedAngle(20*FRACUNIT) + { + angle_t angdiff = player->mo->angle - minecart->angle; + if (angdiff < ANGLE_180 && angdiff > MINECARTCONEMAX) + player->mo->angle = minecart->angle + MINECARTCONEMAX; + else if (angdiff > ANGLE_180 && angdiff < InvAngle(MINECARTCONEMAX)) + player->mo->angle = minecart->angle - MINECARTCONEMAX; + + if (angdiff + minecart->angle != player->mo->angle && (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG)) + { + angle_t *ang = NULL; + + if (player == &players[consoleplayer]) + ang = &localangle; + else if (player == &players[secondarydisplayplayer]) + ang = &localangle2; + + if (ang) + { + angdiff = *ang - minecart->angle; + if (angdiff < ANGLE_180 && angdiff > MINECARTCONEMAX) + *ang = minecart->angle + MINECARTCONEMAX; + else if (angdiff > ANGLE_180 && angdiff < InvAngle(MINECARTCONEMAX)) + *ang = minecart->angle - MINECARTCONEMAX; + } + } + } + + // Player holding jump? + if (!(player->cmd.buttons & BT_JUMP)) + player->pflags &= ~PF_JUMPDOWN; + + // Handle segments. + P_HandleMinecartSegments(minecart); + + // Force 0 friction. + minecart->friction = FRACUNIT; + + fa = (minecart->angle >> ANGLETOFINESHIFT) & FINEMASK; + if (!P_TryMove(minecart, minecart->x + FINECOSINE(fa), minecart->y + FINESINE(fa), true)) + { + P_KillMobj(minecart, NULL, NULL, 0); + return; + } + + if (P_IsObjectOnGround(minecart)) + { + sector_t *sec; + INT32 lnum = -1; + fixed_t dummy; + + // Just hit floor. + if (minecart->eflags & MFE_JUSTHITFLOOR) + { + S_StopSound(minecart); + S_StartSound(minecart, sfx_s3k96); + } + + sec = P_GetMinecartSector(minecart->x, minecart->y, minecart->z, &dummy); + + if (sec) + lnum = P_GetMinecartSpecialLine(sec); + + // Update axis if the cart is standing on a rail. + if (sec && lnum != -1) + { + mobj_t *axis = P_GetAxis(sides[lines[lnum].sidenum[0]].textureoffset >> FRACBITS); + fixed_t newx, newy; + angle_t targetangle, grind; + angle_t prevangle, angdiff; + mobj_t *detleft = NULL; + mobj_t *detright = NULL; + mobj_t *sidelock = NULL; + boolean jumped = false; + fixed_t currentSpeed; + + if (!axis) + { + P_KillMobj(minecart, NULL, NULL, 0); + return; + } + + minecart->movefactor = 0; + P_ResetScore(player); + // Handle angle and position + P_GetAxisPosition(minecart->x, minecart->y, axis, &newx, &newy, &targetangle, &grind); + if (axis->type != MT_AXISTRANSFERLINE) + P_SpawnSparks(minecart, grind); + P_TryMove(minecart, newx, newy, true); + + // Set angle based on target + prevangle = minecart->angle; + angdiff = targetangle - minecart->angle; + if (angdiff < ANGLE_90 + ANG2 || angdiff > ANGLE_270 - ANG2) + minecart->angle = targetangle; + else + minecart->angle = targetangle + ANGLE_180; + angdiff = (minecart->angle - prevangle); + if (angdiff && (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG)) // maintain relative angle on turns + { + player->mo->angle += angdiff; + if (player == &players[consoleplayer]) + localangle += angdiff; + else if (player == &players[secondarydisplayplayer]) + localangle2 += angdiff; + } + + // Sideways detection + if (minecart->flags2 & MF2_AMBUSH) + { + angle_t fa2 = (minecart->angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t c = FINECOSINE(fa2); + fixed_t s = FINESINE(fa2); + + detleft = P_LookForRails(minecart, c, s, targetangle, -s, c); + detright = P_LookForRails(minecart, c, s, targetangle, s, -c); + } + + // How fast are we going? + currentSpeed = FixedHypot(minecart->momx, minecart->momy); + angdiff = R_PointToAngle2(0, 0, minecart->momx, minecart->momy) - minecart->angle; + if (angdiff > ANGLE_90 && angdiff < ANGLE_270) + currentSpeed *= -1; + + // Player-specific behavior. + if (detleft && player->cmd.sidemove < 0) + sidelock = detleft; + else if (detright && player->cmd.sidemove > 0) + sidelock = detright; + + //if (player->cmd.buttons & BT_USE && currentSpeed > 4*FRACUNIT) + // currentSpeed -= FRACUNIT/8; + + // Jumping + if (sidelock || ((player->cmd.buttons & BT_JUMP) && !(player->pflags & PF_JUMPDOWN))) + { + player->pflags |= PF_JUMPDOWN; + + if (minecart->eflags & MFE_ONGROUND) + minecart->eflags &= ~MFE_ONGROUND; + minecart->z += P_MobjFlip(minecart); + if (sidelock) + P_ParabolicMove(minecart, sidelock->x, sidelock->y, sidelock->z, gravity, max(currentSpeed, 10 * FRACUNIT)); + else + minecart->momz = 10 * FRACUNIT; + + S_StartSound(minecart, sfx_s3k51); + jumped = true; + } + + if (!jumped) + { + // Natural acceleration and boosters + if (currentSpeed < minecart->info->speed) + currentSpeed += FRACUNIT/4; + + if (minecart->standingslope) + { + fixed_t fa2 = (minecart->angle >> ANGLETOFINESHIFT) & FINEMASK; + fixed_t front = P_GetZAt(minecart->standingslope, minecart->x, minecart->y); + fixed_t back = P_GetZAt(minecart->standingslope, minecart->x - FINECOSINE(fa2), minecart->y - FINESINE(fa2)); + + if (abs(front - back) < 3*FRACUNIT) + currentSpeed += (back - front)/3; + } + + // Go forward at our current speed + P_InstaThrust(minecart, minecart->angle, currentSpeed); + + // On-track ka-klong sound FX. + minecart->movecount += abs(currentSpeed); + if (minecart->movecount > 128*FRACUNIT) + { + minecart->movecount %= 128*FRACUNIT; + S_StartSound(minecart, minecart->info->activesound); + } + } + } + else + { + minecart->movefactor++; + if ((P_IsObjectOnGround(minecart) && minecart->movefactor >= 5) // off rail + || (abs(minecart->momx) < minecart->scale/2 && abs(minecart->momy) < minecart->scale/2)) // hit a wall + { + P_KillMobj(minecart, NULL, NULL, 0); + return; + } + } + } + + if (player->mo->state-states != S_PLAY_STND) + { + P_SetPlayerMobjState(player->mo, S_PLAY_STND); + player->mo->tics = -1; + } + + // Move player to minecart. + P_TeleportMove(player->mo, minecart->x - minecart->momx, minecart->y - minecart->momy, minecart->z + max(minecart->momz, 0) + 8*FRACUNIT); + if (player->powers[pw_carry] != CR_MINECART) + return; + player->mo->momx = player->mo->momy = player->mo->momz = 0; + P_TryMove(player->mo, player->mo->x + minecart->momx, player->mo->y + minecart->momy, true); + + if (player->powers[pw_flashing] == flashingtics) + player->powers[pw_flashing]--; +} + +// Handle Tails' fluff +static void P_DoTailsOverlay(player_t *player, mobj_t *tails) +{ + // init... + boolean smilesonground = P_IsObjectOnGround(player->mo); + angle_t horizangle = player->drawangle; + fixed_t zoffs = 0; + fixed_t backwards = -1*FRACUNIT; + boolean doswim = (player->panim == PA_ABILITY && (player->mo->eflags & MFE_UNDERWATER)); + boolean doroll = (player->panim == PA_ROLL || (player->panim == PA_JUMP && !(player->charflags & SF_NOJUMPSPIN)) || doswim); + angle_t rollangle; + boolean panimchange; + INT32 ticnum = 0; + statenum_t chosenstate; + + if (!tails->skin) + { + tails->skin = player->mo->skin; + P_SetMobjState(tails, S_TAILSOVERLAY_STAND); + tails->movecount = -1; + } + + panimchange = (tails->movecount != (INT32)player->panim); + + // initial position... + if (doroll) + { + fixed_t testval, zdist; + if (player->speed < FRACUNIT) + testval = FRACUNIT; + else + { + testval = (FixedMul(player->speed, FINECOSINE((horizangle - R_PointToAngle2(0, 0, player->rmomx, player->rmomy)) >> ANGLETOFINESHIFT))); + if (testval < FRACUNIT) + testval = FRACUNIT; + } + + if (doswim) + zdist = player->mo->momz<<1; + else if (smilesonground && !player->mo->reactiontime) + zdist = (player->mo->z - tails->threshold); + else + zdist = player->mo->momz; + + rollangle = R_PointToAngle2(0, 0, testval, -P_MobjFlip(player->mo)*zdist); + + if (!doswim) + { + zoffs = 3*FRACUNIT + 12*FINESINE(rollangle >> ANGLETOFINESHIFT); + backwards = -12*FINECOSINE(rollangle >> ANGLETOFINESHIFT); + } + } + else if (player->panim == PA_RUN) + backwards = -5*FRACUNIT; + else if (player->panim == PA_SPRING || player->panim == PA_JUMP) + { + zoffs += 4*FRACUNIT; + backwards /= 2; + } + else if (player->panim == PA_PAIN) + backwards /= 16; + else if (player->mo->state-states == S_PLAY_GASP) + { + backwards /= 16; + zoffs += 12*FRACUNIT; + } + else if (player->mo->state-states == S_PLAY_EDGE) + { + backwards /= 16; + zoffs = 3*FRACUNIT; + } + else if (player->panim == PA_ABILITY2) + { + zoffs = -7*FRACUNIT; + backwards = -9*FRACUNIT; + } + else if (player->panim == PA_ABILITY) + backwards = -5*FRACUNIT; + + // sprite... + if (doroll) + { + statenum_t add = ((rollangle > ANGLE_180) ? 2 : 0); + if (add) + rollangle = InvAngle(rollangle); + rollangle += ANG15; // modify the thresholds to be nice clean numbers + if (rollangle > ANG60) + chosenstate = S_TAILSOVERLAY_PLUS60DEGREES + add; + else if (rollangle > ANG30) + chosenstate = S_TAILSOVERLAY_PLUS30DEGREES + add; + else + chosenstate = S_TAILSOVERLAY_0DEGREES; + } + else if (player->panim == PA_SPRING || player->panim == PA_JUMP) + chosenstate = S_TAILSOVERLAY_MINUS60DEGREES; + else if (player->panim == PA_FALL || player->mo->state-states == S_PLAY_RIDE) + chosenstate = S_TAILSOVERLAY_PLUS60DEGREES; + else if (player->panim == PA_PAIN) + chosenstate = S_TAILSOVERLAY_PAIN; + else if (player->mo->state-states == S_PLAY_GASP) + chosenstate = S_TAILSOVERLAY_GASP; + else if (player->mo->state-states == S_PLAY_EDGE) + chosenstate = S_TAILSOVERLAY_EDGE; + else if (player->panim == PA_RUN) + chosenstate = S_TAILSOVERLAY_RUN; + else if (player->panim == PA_WALK) + { + if (!smilesonground || player->mo->state-states == S_PLAY_SKID) + chosenstate = S_TAILSOVERLAY_PLUS30DEGREES; + else if (player->speed >= FixedMul(player->runspeed/2, player->mo->scale)) + chosenstate = S_TAILSOVERLAY_0DEGREES; + else + chosenstate = S_TAILSOVERLAY_MINUS30DEGREES; + } + else if (player->mo->sprite2 == SPR2_FLY) + chosenstate = S_TAILSOVERLAY_FLY; + else if (player->mo->sprite2 == SPR2_SWIM) + chosenstate = S_TAILSOVERLAY_FLY; + else if (player->mo->sprite2 == SPR2_TIRE) + chosenstate = S_TAILSOVERLAY_TIRE; + else if (player->panim == PA_ABILITY2) + chosenstate = S_TAILSOVERLAY_PLUS30DEGREES; + else if (player->panim == PA_IDLE) + chosenstate = S_TAILSOVERLAY_STAND; + else + chosenstate = S_INVISIBLE; + + // state... + if (panimchange) + { + tails->sprite2 = -1; + P_SetMobjState(tails, chosenstate); + } + else + { + if (tails->state != states+chosenstate) + { + if (states[chosenstate].sprite == SPR_PLAY) + tails->sprite2 = P_GetSkinSprite2(((skin_t *)tails->skin), (states[chosenstate].frame & FF_FRAMEMASK), player); + P_SetMobjState(tails, chosenstate); + } + } + +#if 0 + if (player->fly1 != 0 && player->powers[pw_tailsfly] != 0 && !smilesonground) + P_SetMobjState(tails, chosenstate); +#endif + + // animation... + if (player->panim == PA_SPRING || player->panim == PA_FALL || player->mo->state-states == S_PLAY_RIDE) + { + if (FixedDiv(abs(player->mo->momz), player->mo->scale) < 20<panim == PA_PAIN) + ticnum = 2; + else if (player->mo->state-states == S_PLAY_GASP) + tails->tics = -1; + else if (player->mo->sprite2 == SPR2_TIRE) + ticnum = (doswim ? 2 : 4); + else if (player->panim != PA_IDLE) + ticnum = player->mo->tics; + + if (ticnum && tails->tics > ticnum) + tails->tics = ticnum; + + // final handling... + tails->color = player->mo->color; + tails->threshold = player->mo->z; + tails->movecount = player->panim; + tails->angle = horizangle; + P_SetScale(tails, player->mo->scale); + tails->destscale = player->mo->destscale; + tails->radius = player->mo->radius; + tails->height = player->mo->height; + zoffs = FixedMul(zoffs, tails->scale); + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + tails->eflags |= MFE_VERTICALFLIP; + tails->flags2 |= MF2_OBJECTFLIP; + zoffs = player->mo->height - tails->height - zoffs; + } + else + { + tails->eflags &= ~MFE_VERTICALFLIP; + tails->flags2 &= ~MF2_OBJECTFLIP; + } + + P_UnsetThingPosition(tails); + tails->x = player->mo->x + P_ReturnThrustX(tails, tails->angle, FixedMul(backwards, tails->scale)); + tails->y = player->mo->y + P_ReturnThrustY(tails, tails->angle, FixedMul(backwards, tails->scale)); + tails->z = player->mo->z + zoffs; + P_SetThingPosition(tails); +} + +// Metal Sonic's jet fume +static void P_DoMetalJetFume(player_t *player, mobj_t *fume) +{ + static const UINT8 FUME_SKINCOLORS[] = + { + SKINCOLOR_ICY, + SKINCOLOR_SKY, + SKINCOLOR_CYAN, + SKINCOLOR_WAVE, + SKINCOLOR_TEAL, + SKINCOLOR_AQUA, + SKINCOLOR_SEAFOAM, + SKINCOLOR_MINT, + SKINCOLOR_PERIDOT, + SKINCOLOR_LIME, + SKINCOLOR_YELLOW, + SKINCOLOR_SANDY, + SKINCOLOR_GOLD, + SKINCOLOR_APRICOT, + SKINCOLOR_SUNSET + }; + mobj_t *mo = player->mo; + angle_t angle = player->drawangle; + fixed_t dist; + panim_t panim = player->panim; + tic_t dashmode = player->dashmode; + boolean underwater = mo->eflags & MFE_UNDERWATER; + statenum_t stat = fume->state-states; + + if (panim != PA_WALK && panim != PA_RUN && panim != PA_DASH) // turn invisible when not in a coherent movement state + { + if (stat != fume->info->spawnstate) + P_SetMobjState(fume, fume->info->spawnstate); + return; + } + + if (underwater) // No fume underwater; spawn bubbles instead! + { + fume->movedir += FixedAngle(FixedDiv(2 * player->speed, 3 * mo->scale)); + fume->movefactor += player->speed; + + if (fume->movefactor > FixedDiv(2 * player->normalspeed, 3 * mo->scale)) + { + INT16 i; + fixed_t radiusV = 4*FRACUNIT; + fixed_t radiusX = P_ReturnThrustX(mo, angle, -mo->radius >> (panim == PA_WALK ? 1 : 0)); + fixed_t radiusY = P_ReturnThrustY(mo, angle, -mo->radius >> (panim == PA_WALK ? 1 : 0)); + fixed_t factorX = P_ReturnThrustX(mo, angle + ANGLE_90, mo->scale); + fixed_t factorY = P_ReturnThrustY(mo, angle + ANGLE_90, mo->scale); + fixed_t offsetH, offsetV, x, y, z; + + for (i = -1; i < 2; i += 2) + { + offsetH = i*P_ReturnThrustX(fume, fume->movedir, radiusV); + offsetV = i*P_ReturnThrustY(fume, fume->movedir, radiusV); + x = mo->x + radiusX + FixedMul(offsetH, factorX); + y = mo->y + radiusY + FixedMul(offsetH, factorY); + z = mo->z + (mo->height >> 1) + offsetV; + P_SpawnMobj(x, y, z, MT_SMALLBUBBLE)->scale = mo->scale >> 1; + } + + fume->movefactor = 0; + } + + if (panim == PA_WALK) + { + if (stat != fume->info->spawnstate) + { + fume->threshold = 0; + P_SetMobjState(fume, fume->info->spawnstate); + } + return; + } + } + + if (stat == fume->info->spawnstate) // If currently inivisble, activate! + { + P_SetMobjState(fume, (stat = fume->info->seestate)); + P_SetScale(fume, mo->scale); + } + + if (dashmode > DASHMODE_THRESHOLD && stat != fume->info->seestate) // If in dashmode, grow really big and flash + { + fume->destscale = mo->scale; + fume->flags2 ^= MF2_DONTDRAW; + fume->flags2 |= mo->flags2 & MF2_DONTDRAW; + } + else // Otherwise, pick a size and color depending on speed and proximity to dashmode + { + if (dashmode == DASHMODE_THRESHOLD && dashmode > (tic_t)fume->movecount) // If just about to enter dashmode, play the startup animation again + { + P_SetMobjState(fume, (stat = fume->info->seestate)); + P_SetScale(fume, mo->scale << 1); + } + fume->flags2 = (fume->flags2 & ~MF2_DONTDRAW) | (mo->flags2 & MF2_DONTDRAW); + fume->destscale = (mo->scale + FixedDiv(player->speed, player->normalspeed)) / (underwater ? 6 : 3); + fume->color = FUME_SKINCOLORS[(dashmode * sizeof(FUME_SKINCOLORS)) / (DASHMODE_MAX + 1)]; + + if (underwater) + { + fume->frame = (fume->frame & FF_FRAMEMASK) | FF_ANIMATE | (P_RandomRange(0, 9) * FF_TRANS10); + fume->threshold = 1; + } + else if (fume->threshold) + { + fume->frame = (fume->frame & FF_FRAMEMASK) | fume->state->frame; + fume->threshold = 0; + } + } + + fume->movecount = dashmode; // keeps track of previous dashmode value so we know whether Metal is entering or leaving it + fume->eflags = (fume->flags2 & ~MF2_OBJECTFLIP) | (mo->flags2 & MF2_OBJECTFLIP); // Make sure to flip in reverse gravity! + fume->eflags = (fume->eflags & ~MFE_VERTICALFLIP) | (mo->eflags & MFE_VERTICALFLIP); // Make sure to flip in reverse gravity! + + // Finally, set its position + dist = -mo->radius - FixedMul(fume->info->radius, fume->destscale - mo->scale/3); + + P_UnsetThingPosition(fume); + fume->x = mo->x + P_ReturnThrustX(fume, angle, dist); + fume->y = mo->y + P_ReturnThrustY(fume, angle, dist); + fume->z = mo->z + ((mo->height - fume->height) >> 1); + P_SetThingPosition(fume); +} + // // P_PlayerThink // @@ -8680,7 +11585,7 @@ void P_PlayerThink(player_t *player) #endif // todo: Figure out what is actually causing these problems in the first place... - if ((player->health <= 0 || player->mo->health <= 0) && player->playerstate == PST_LIVE) //you should be DEAD! + if (player->mo->health <= 0 && player->playerstate == PST_LIVE) //you should be DEAD! { CONS_Debug(DBG_GAMELOGIC, "P_PlayerThink: Player %s in PST_LIVE with 0 health. (\"Zombie bug\")\n", sizeu1(playeri)); player->playerstate = PST_DEAD; @@ -8688,10 +11593,16 @@ void P_PlayerThink(player_t *player) if (player->bot) { - if (player->playerstate == PST_LIVE && B_CheckRespawn(player)) - player->playerstate = PST_REBORN; + if (player->playerstate == PST_LIVE || player->playerstate == PST_DEAD) + { + if (B_CheckRespawn(player)) + player->playerstate = PST_REBORN; + } if (player->playerstate == PST_REBORN) + { + LUAh_PlayerThink(player); return; + } } #ifdef SEENAMES @@ -8727,25 +11638,11 @@ void P_PlayerThink(player_t *player) player->awayviewtics = 0; // reset to zero } - if (player->pflags & PF_GLIDING) - { - if (player->panim != PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - } - else if ((player->pflags & PF_JUMPED) && !player->powers[pw_super] && player->panim != PA_ROLL && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - if (player->flashcount) player->flashcount--; - // Re-fixed by Jimita (11-12-2018) - if (player->awayviewtics) - { + if (player->awayviewtics && player->awayviewtics != -1) player->awayviewtics--; - if (!player->awayviewtics) - player->awayviewtics = -1; - // The timer might've reached zero, but we'll run the remote view camera anyway by setting it to -1. - } /// \note do this in the cheat code if (player->pflags & PF_NOCLIP) @@ -8764,7 +11661,7 @@ void P_PlayerThink(player_t *player) I_Error("player %s is in PST_REBORN\n", sizeu1(playeri)); #endif - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) { INT32 i; @@ -8781,35 +11678,35 @@ void P_PlayerThink(player_t *player) if (i == MAXPLAYERS && player->exiting == 3*TICRATE) // finished player->exiting = (14*TICRATE)/5 + 1; - // If 10 seconds are left on the timer, + // If 11 seconds are left on the timer, // begin the drown music for countdown! - if (countdown == 11*TICRATE - 1) - { - if (P_IsLocalPlayer(player)) - S_ChangeMusicInternal("drown", false); - } + if (countdown == 11*TICRATE - 1 && P_IsLocalPlayer(player)) + P_PlayJingle(player, JT_DROWN); // If you've hit the countdown and you haven't made // it to the exit, you're a goner! else if (countdown == 1 && !player->exiting && player->lives > 0) { - if (netgame && player->health > 0) + if (netgame && player->mo->health > 0) CONS_Printf(M_GetText("%s ran out of time.\n"), player_names[player-players]); - player->pflags |= PF_TIMEOVER; + player->pflags |= PF_GAMETYPEOVER; - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) { P_DeNightserizePlayer(player); S_StartScreamSound(player->mo, sfx_s3k66); } player->lives = 2; // Don't start the game over music! - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_INSTAKILL); player->lives = 0; if (player->playerstate == PST_DEAD) + { + LUAh_PlayerThink(player); return; + } } } @@ -8821,9 +11718,20 @@ void P_PlayerThink(player_t *player) if (player->exiting && countdown2) player->exiting = 5; - if (player->exiting == 2 || countdown2 == 2) + // The following code is disabled for now as this causes the game to freeze sometimes + // Monster Iestyn -- 16/08/19 +#if 0 + // Same check as below, just at 1 second before + // so we can fade music + if (!exitfadestarted && + player->exiting > 0 && player->exiting <= 1*TICRATE && + (!multiplayer || gametype == GT_COOP ? !mapheaderinfo[gamemap-1]->musinterfadeout : true) && + // don't fade if we're fading during intermission. follows Y_StartIntermission intertype = int_coop + ((gametyperules & GTR_RACE) ? countdown2 == 0 : true) && // don't fade on timeout + player->lives > 0 && // don't fade on game over (competition) + P_IsLocalPlayer(player)) { - if (cv_playersforexit.value) // Count to be sure everyone's exited + if (cv_playersforexit.value) { INT32 i; @@ -8834,11 +11742,46 @@ void P_PlayerThink(player_t *player) if (players[i].lives <= 0) continue; - if (!players[i].exiting || players[i].exiting > 3) + if (!players[i].exiting || players[i].exiting > 1*TICRATE) break; } if (i == MAXPLAYERS) + { + exitfadestarted = true; + S_FadeOutStopMusic(1*MUSICRATE); + } + } + else + { + exitfadestarted = true; + S_FadeOutStopMusic(1*MUSICRATE); + } + } +#endif + + if (player->exiting == 2 || countdown2 == 2) + { + UINT8 numneeded = (G_IsSpecialStage(gamemap) ? 4 : cv_playersforexit.value); + if (numneeded) // Count to be sure everyone's exited + { + INT32 i, total = 0, exiting = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator || players[i].bot) + continue; + if (players[i].quittime > 30 * TICRATE) + continue; + if (players[i].lives <= 0) + continue; + + total++; + if (players[i].exiting && players[i].exiting < 4) + exiting++; + } + + if (!total || ((4*exiting)/total) >= numneeded) { if (server) SendNetXCmd(XD_EXITLEVEL, NULL, 0); @@ -8853,6 +11796,14 @@ void P_PlayerThink(player_t *player) } } + if (player->pflags & PF_FINISHED) + { + if ((gametype == GT_COOP && cv_exitmove.value) && !G_EnoughPlayersFinished()) + player->exiting = 0; + else + P_DoPlayerExit(player); + } + // check water content, set stuff in mobj P_MobjCheckWater(player->mo); @@ -8865,32 +11816,35 @@ void P_PlayerThink(player_t *player) if (!player->spectator) P_PlayerInSpecialSector(player); + else if ( +#else + if (player->spectator && #endif + G_GametypeUsesCoopStarposts() && (netgame || multiplayer) && cv_coopstarposts.value == 2) + P_ConsiderAllGone(); if (player->playerstate == PST_DEAD) { player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); - + LUAh_PlayerThink(player); return; } // Make sure spectators always have a score and ring count of 0. if (player->spectator) { - player->score = 0; - player->mo->health = 1; - player->health = 1; + if (gametype != GT_COOP) + player->score = 0; } - - if ((netgame || multiplayer) && player->lives <= 0) + else if ((netgame || multiplayer) && player->lives <= 0 && gametype != GT_COOP) { - // In Co-Op, replenish a user's lives if they are depleted. + // Outside of Co-Op, replenish a user's lives if they are depleted. // of course, this is just a cheap hack, meh... player->lives = cv_startinglives.value; } - if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) + if ((gametyperules & GTR_RACE) && leveltime < 4*TICRATE) { cmd->buttons &= BT_USE; // Remove all buttons except BT_USE cmd->forwardmove = 0; @@ -8898,9 +11852,9 @@ void P_PlayerThink(player_t *player) } // Synchronizes the "real" amount of time spent in the level. - if (!player->exiting) + if (!player->exiting && !stoppedclock) { - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) { if (leveltime >= 4*TICRATE) player->realtime = leveltime - 4*TICRATE; @@ -8911,15 +11865,18 @@ void P_PlayerThink(player_t *player) player->realtime = leveltime; } - if ((netgame || splitscreen) && player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing]) + if (player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing] && G_GametypeHasSpectators()) { if (P_SpectatorJoinGame(player)) + { + LUAh_PlayerThink(player); return; // player->mo was removed. + } } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. if (!objectplacing && !((netgame || multiplayer) && player->spectator) - && maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper])) + && maptol & TOL_NIGHTS && (player->powers[pw_carry] != CR_NIGHTSMODE || player->powers[pw_nights_helper])) { thinker_t *th; mobj_t *mo2; @@ -8927,15 +11884,19 @@ void P_PlayerThink(player_t *player) fixed_t y = player->mo->y; fixed_t z = player->mo->z; - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; mo2 = (mobj_t *)th; - if (!(mo2->type == MT_NIGHTSWING || mo2->type == MT_RING || mo2->type == MT_COIN - || mo2->type == MT_BLUEBALL)) + if (!(mo2->type == MT_RING || mo2->type == MT_COIN + || mo2->type == MT_BLUESPHERE || mo2->type == MT_BOMBSPHERE + || mo2->type == MT_NIGHTSCHIP || mo2->type == MT_NIGHTSSTAR)) + continue; + + if (mo2->flags2 & MF2_NIGHTSPULL) continue; if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) @@ -8944,6 +11905,9 @@ void P_PlayerThink(player_t *player) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; + // New NiGHTS attract speed dummied out because the older behavior + // is exploited as a mechanic. Uncomment to enable. + mo2->movefactor = 0; // 40*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, player->mo); } } @@ -8959,11 +11923,22 @@ void P_PlayerThink(player_t *player) // for a bit after a teleport. if (player->mo->reactiontime) player->mo->reactiontime--; - else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) + else if (player->powers[pw_carry] == CR_MINECART) { - if (player->pflags & PF_ROPEHANG) + if (P_ControlStyle(player) != CS_LMAOGALOG) + player->mo->angle = (cmd->angleturn << 16 /* not FRACBITS */); + + ticruned++; + if ((cmd->angleturn & TICCMD_RECEIVED) == 0) + ticmiss++; + + P_MinecartThink(player); + } + else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && (player->powers[pw_carry] == CR_ROPEHANG || player->powers[pw_carry] == CR_ZOOMTUBE)) + { + if (player->powers[pw_carry] == CR_ROPEHANG) { - if (!P_AnalogMove(player)) + if (P_ControlStyle(player) != CS_LMAOGALOG) player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); ticruned++; @@ -8971,23 +11946,223 @@ void P_PlayerThink(player_t *player) ticmiss++; P_DoRopeHang(player); - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); P_DoJumpStuff(player, &player->cmd); } - else + else //if (player->powers[pw_carry] == CR_ZOOMTUBE) { P_DoZoomTube(player); - if (!(player->panim == PA_ROLL) && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); + if (!(player->panim == PA_ROLL)) + P_SetPlayerMobjState(player->mo, S_PLAY_ROLL); } player->rmomx = player->rmomy = 0; // no actual momentum from your controls P_ResetScore(player); } else + { + if (player->bumpertime == TICRATE/2 && player->mo->hnext) + { + // Center player to NiGHTS bumper here because if you try to set player's position in + // P_TouchSpecialThing case MT_NIGHTSBUMPER, that position is fudged in the time + // between that routine in the previous tic + // and reaching here in the current tic + P_TeleportMove(player->mo, player->mo->hnext->x, player->mo->hnext->y + , player->mo->hnext->z + FixedMul(player->mo->hnext->height/4, player->mo->hnext->scale)); + P_SetTarget(&player->mo->hnext, NULL); + } P_MovePlayer(player); + } if (!player->mo) + { + LUAh_PlayerThink(player); return; // P_MovePlayer removed player->mo. + } + + // deez New User eXperiences. + { + angle_t oldang = player->drawangle, diff = 0; + UINT8 factor; + // Directionchar! + // Camera angle stuff. + if (player->exiting // no control, no modification + || player->powers[pw_carry] == CR_NIGHTSMODE) + ; + else if (!(player->pflags & PF_DIRECTIONCHAR) + || (player->climbing) // stuff where the direction is forced at all times + || (twodlevel || player->mo->flags2 & MF2_TWOD) // keep things synchronised up there, since the camera IS seperate from player motion when that happens + || G_RingSlingerGametype()) // no firing rings in directions your player isn't aiming + player->drawangle = player->mo->angle; + else if (P_PlayerInPain(player)) + ; + else if (player->powers[pw_justsprung]) // restricted, potentially by lua + { +#ifdef SPRINGSPIN + if (player->powers[pw_justsprung] & (1<<15)) + player->drawangle += (player->powers[pw_justsprung] & ~(1<<15))*(ANG2+ANG1); +#endif + } + else if (player->powers[pw_carry] && player->mo->tracer) // carry + { + switch (player->powers[pw_carry]) + { + case CR_PLAYER: + if (player->mo->tracer->player) + { + player->drawangle = player->mo->tracer->player->drawangle; + break; + } + /* FALLTHRU */ + case CR_MINECART: + case CR_GENERIC: + case CR_PTERABYTE: + player->drawangle = player->mo->tracer->angle; + break; + case CR_ROLLOUT: + if (cmd->forwardmove || cmd->sidemove) // only when you're pressing movement keys + { // inverse direction! + diff = (((player->cmd.angleturn<<16) + R_PointToAngle2(0, 0, -cmd->forwardmove<sidemove<drawangle); + factor = 4; + } + break; + /* -- in case we wanted to have the camera freely movable during zoom tubes + case CR_ZOOMTUBE:*/ + case CR_ROPEHANG: + if (player->mo->momx || player->mo->momy) + { + player->drawangle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + break; + } + /* FALLTHRU */ + default: + player->drawangle = player->mo->angle; + break; + } + } + else if ((player->skidtime > (TICRATE/2 - 2) || ((player->pflags & (PF_SPINNING|PF_STARTDASH)) == PF_SPINNING)) && (abs(player->rmomx) > 5*player->mo->scale || abs(player->rmomy) > 5*player->mo->scale)) // spin/skid force + player->drawangle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); + else if (((player->charability2 == CA2_GUNSLINGER || player->charability2 == CA2_MELEE) && player->panim == PA_ABILITY2) || player->pflags & PF_STASIS || player->skidtime) + ; + else + { + if (player->pflags & PF_GLIDING) + { + if (player->speed < player->mo->scale) + diff = player->mo->angle - player->drawangle; + else + diff = (R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - player->drawangle); + factor = 4; + } + else if (player->pflags & PF_SLIDING) + { +#if 0 // fun hydrocity style horizontal spin + if (player->mo->eflags & MFE_TOUCHWATER || player->powers[pw_flashing] > (flashingtics/4)*3) + { + diff = (player->mo->angle - player->drawangle); + factor = 16; + } + else + { + diff = factor = 0; + player->drawangle += ANGLE_22h; + } +#else + diff = (player->mo->angle - player->drawangle); + factor = 16; +#endif + } + else if (player->pflags & PF_STARTDASH) + { + diff = (player->mo->angle - player->drawangle); + factor = 4; + } + else if (cmd->forwardmove || cmd->sidemove) // only when you're pressing movement keys + { + diff = ((player->mo->angle + ((player->pflags & PF_ANALOGMODE) ? 0 : R_PointToAngle2(0, 0, cmd->forwardmove<sidemove<drawangle); + factor = 4; + } + else if (player->rmomx || player->rmomy) + diff = factor = 0; + else + { + diff = (player->mo->angle - player->drawangle); + factor = 8; + } + } + + if (diff) + { + if (diff > ANGLE_180) + diff = InvAngle(InvAngle(diff)/factor); + else + diff /= factor; + player->drawangle += diff; + } + + // reset from waiting to standing when turning on the spot + if (player->panim == PA_IDLE) + { + diff = player->drawangle - oldang; + if (diff > ANGLE_180) + diff = InvAngle(diff); + if (diff > ANG10/2) + { + statenum_t stat = player->mo->state-states; + if (stat == S_PLAY_WAIT) + P_SetPlayerMobjState(player->mo, S_PLAY_STND); + else if (stat == S_PLAY_STND && player->mo->tics != -1) + player->mo->tics++; + } + } + + // Autobrake! check ST_drawInput if you modify this + { + boolean currentlyonground = P_IsObjectOnGround(player->mo); + + if (player->powers[pw_noautobrake]) + ; + else if (!player->powers[pw_carry] && !player->powers[pw_nocontrol] + && ((player->pflags & (PF_AUTOBRAKE|PF_APPLYAUTOBRAKE|PF_STASIS)) == (PF_AUTOBRAKE|PF_APPLYAUTOBRAKE)) + && !(cmd->forwardmove || cmd->sidemove) + && (player->rmomx || player->rmomy) + && (!player->capsule || (player->capsule->reactiontime != (player-players)+1))) + { + fixed_t acceleration = (player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration) * player->thrustfactor * 20; + angle_t moveAngle = R_PointToAngle2(0, 0, player->rmomx, player->rmomy); + + if (!currentlyonground) + acceleration /= 2; + // fake skidding! see P_SkidStuff for reference on conditionals + else if (!player->skidtime && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID) && P_AproxDistance(player->mo->momx, player->mo->momy) >= FixedMul(player->runspeed, player->mo->scale)) // modified from player->runspeed/2 'cuz the skid was just TOO frequent ngl + { + if (player->mo->state-states != S_PLAY_SKID) + P_SetPlayerMobjState(player->mo, S_PLAY_SKID); + player->mo->tics = player->skidtime = (player->mo->movefactor == FRACUNIT) ? TICRATE/2 : (FixedDiv(35<<(FRACBITS-1), FixedSqrt(player->mo->movefactor)))>>FRACBITS; + + if (P_IsLocalPlayer(player)) // the sound happens way more frequently now, so give co-op players' ears a brake... + S_StartSound(player->mo, sfx_skid); + } + + if (player->mo->movefactor != FRACUNIT) // Friction-scaled acceleration... + acceleration = FixedMul(acceleration<mo->movefactor)>>FRACBITS; + + P_Thrust(player->mo, moveAngle, -acceleration); + } + + if (!(player->pflags & PF_AUTOBRAKE) + || player->powers[pw_carry] + || player->panim == PA_SPRING + || player->panim == PA_PAIN + || !player->mo->health + || player->climbing + || player->pflags & (PF_SPINNING|PF_SLIDING) + || player->bumpertime) + player->pflags &= ~PF_APPLYAUTOBRAKE; + else if (currentlyonground || player->powers[pw_tailsfly]) + player->pflags |= PF_APPLYAUTOBRAKE; + } + } + + player->mo->movefactor = FRACUNIT; // We're not going to do any more with this, so let's change it back for the next frame. // Unset statis flags after moving. // In other words, if you manually set stasis via code, @@ -8996,7 +12171,9 @@ void P_PlayerThink(player_t *player) #ifdef POLYOBJECTS if (player->onconveyor == 1) - player->cmomy = player->cmomx = 0; + player->onconveyor = 3; + else if (player->onconveyor == 3) + player->cmomy = player->cmomx = 0; #endif P_DoSuperStuff(player); @@ -9012,10 +12189,17 @@ void P_PlayerThink(player_t *player) { mobj_t *gmobj = P_SpawnGhostMobj(player->mo); gmobj->fuse = 2; + if (gmobj->tracer) + gmobj->tracer->fuse = 2; if (leveltime & 1) { gmobj->frame &= ~FF_TRANSMASK; gmobj->frame |= tr_trans70<tracer) + { + gmobj->tracer->frame &= ~FF_TRANSMASK; + gmobj->tracer->frame |= tr_trans70<pflags & PF_NIGHTSMODE)) + if (player->powers[pw_carry] != CR_NIGHTSMODE) { if (cmd->buttons & BT_USE) player->pflags |= PF_USEDOWN; else player->pflags &= ~PF_USEDOWN; } - else if (player->mo->tracer) // match tracer's position with yours when NiGHTS - { - P_UnsetThingPosition(player->mo->tracer); - player->mo->tracer->x = player->mo->x; - player->mo->tracer->y = player->mo->y; - if (player->mo->eflags & MFE_VERTICALFLIP) - player->mo->tracer->z = player->mo->z + player->mo->height - player->mo->tracer->height; - else - player->mo->tracer->z = player->mo->z; - player->mo->tracer->floorz = player->mo->floorz; - player->mo->tracer->ceilingz = player->mo->ceilingz; - P_SetThingPosition(player->mo->tracer); - } + + // IF PLAYER NOT HERE THEN FLASH END IF + if (player->quittime && player->powers[pw_flashing] < flashingtics - 1 + && !(G_TagGametype() && !(player->pflags & PF_TAGIT)) && !player->gotflag) + player->powers[pw_flashing] = flashingtics - 1; // Counters, time dependent power ups. // Time Bonus & Ring Bonus count settings + if (player->ammoremovaltimer) + { + if (--player->ammoremovaltimer == 0) + player->ammoremoval = 0; + } + // Strength counts up to diminish fade. if (player->powers[pw_sneakers] && player->powers[pw_sneakers] < UINT16_MAX) player->powers[pw_sneakers]--; @@ -9060,25 +12242,39 @@ void P_PlayerThink(player_t *player) if (player->powers[pw_invulnerability] && player->powers[pw_invulnerability] < UINT16_MAX) player->powers[pw_invulnerability]--; - if (player->powers[pw_flashing] && player->powers[pw_flashing] < UINT16_MAX && ((player->pflags & PF_NIGHTSMODE) || player->powers[pw_flashing] < flashingtics)) + if (player->powers[pw_flashing] && player->powers[pw_flashing] < UINT16_MAX && ((player->powers[pw_carry] == CR_NIGHTSMODE) || player->powers[pw_flashing] < flashingtics)) player->powers[pw_flashing]--; - if (player->powers[pw_tailsfly] && player->powers[pw_tailsfly] < UINT16_MAX && player->charability != CA_SWIM && !(player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) // tails fly counter + if (player->powers[pw_tailsfly] && player->powers[pw_tailsfly] < UINT16_MAX && player->charability != CA_SWIM) // tails fly counter player->powers[pw_tailsfly]--; - if (player->powers[pw_underwater] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)) + if (player->powers[pw_pushing] && player->powers[pw_pushing] < UINT16_MAX) + player->powers[pw_pushing]--; + + if (player->powers[pw_justsprung] & ((1<<15)-1) && player->powers[pw_justsprung] < UINT16_MAX) + player->powers[pw_justsprung]--; + else + player->powers[pw_justsprung] = 0; + + if (player->powers[pw_noautobrake] && player->powers[pw_noautobrake] < UINT16_MAX) + player->powers[pw_noautobrake]--; + + if (player->powers[pw_underwater] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_PROTECTWATER))) { if (player->powers[pw_underwater] <= 12*TICRATE+1) + { + player->powers[pw_underwater] = 0; P_RestoreMusic(player); //incase they were about to drown - - player->powers[pw_underwater] = 0; + } + else + player->powers[pw_underwater] = 0; } - else if (player->powers[pw_underwater] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && player->spectator)) // underwater timer + else if (player->powers[pw_underwater] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && (player->spectator || player->quittime))) // underwater timer player->powers[pw_underwater]--; - if (player->powers[pw_spacetime] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL)) + if (player->powers[pw_spacetime] && (player->pflags & PF_GODMODE || (player->powers[pw_shield] & SH_PROTECTWATER))) player->powers[pw_spacetime] = 0; - else if (player->powers[pw_spacetime] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && player->spectator)) // underwater timer + else if (player->powers[pw_spacetime] && !(maptol & TOL_NIGHTS) && !((netgame || multiplayer) && (player->spectator || player->quittime))) // underwater timer player->powers[pw_spacetime]--; if (player->powers[pw_gravityboots] && player->powers[pw_gravityboots] < UINT16_MAX) @@ -9102,15 +12298,25 @@ void P_PlayerThink(player_t *player) player->powers[pw_nocontrol] = 0; //pw_super acts as a timer now - if (player->powers[pw_super]) + if (player->powers[pw_super] + && (player->mo->state < &states[S_PLAY_SUPER_TRANS1] + || player->mo->state > &states[S_PLAY_SUPER_TRANS6])) player->powers[pw_super]++; - if (player->powers[pw_ingoop]) + if (player->powers[pw_carry] == CR_BRAKGOOP) { - if (player->mo->state == &states[S_PLAY_STND]) - player->mo->tics = 2; + if (!player->powers[pw_flashing]) + { + if (player->mo->state != &states[S_PLAY_STND]) + P_SetPlayerMobjState(player->mo, S_PLAY_STND); + else + player->mo->tics = 2; + } + else + P_SetTarget(&player->mo->tracer, NULL); - player->powers[pw_ingoop]--; + if (!player->mo->tracer) + player->powers[pw_carry] = CR_NONE; } if (player->bumpertime) @@ -9145,23 +12351,73 @@ void P_PlayerThink(player_t *player) player->losstime--; // Flash player after being hit. - if (!(player->pflags & PF_NIGHTSMODE)) - { - if (player->powers[pw_flashing] > 0 && player->powers[pw_flashing] < flashingtics && (leveltime & 1)) - player->mo->flags2 |= MF2_DONTDRAW; - else - player->mo->flags2 &= ~MF2_DONTDRAW; - } - else if (player->mo->tracer) - { - if (player->powers[pw_flashing] & 1) - player->mo->tracer->flags2 |= MF2_DONTDRAW; - else - player->mo->tracer->flags2 &= ~MF2_DONTDRAW; - } + if (player->powers[pw_flashing] > 0 && player->powers[pw_flashing] < flashingtics && (leveltime & 1)) + player->mo->flags2 |= MF2_DONTDRAW; + else + player->mo->flags2 &= ~MF2_DONTDRAW; player->pflags &= ~PF_SLIDING; +#define dashmode player->dashmode + // Dash mode - thanks be to VelocitOni + if ((player->charflags & SF_DASHMODE) && !player->gotflag && !player->powers[pw_carry] && !player->exiting && !(maptol & TOL_NIGHTS) && !metalrecording) // woo, dashmode! no nights tho. + { + boolean totallyradical = player->speed >= FixedMul(player->runspeed, player->mo->scale); + boolean floating = (player->secondjump == 1); + + if ((totallyradical && !floating) || (player->pflags & PF_STARTDASH)) + { + if (dashmode < DASHMODE_MAX) + dashmode++; // Counter. Adds 1 to dash mode per tic in top speed. + if (dashmode == DASHMODE_THRESHOLD) // This isn't in the ">=" equation because it'd cause the sound to play infinitely. + S_StartSound(player->mo, (player->charflags & SF_MACHINE) ? sfx_kc4d : sfx_cdfm40); // If the player enters dashmode, play this sound on the the tic it starts. + } + else if ((!totallyradical || !floating) && !(player->pflags & PF_SPINNING)) + { + if (dashmode > 3) + { + dashmode -= 3; // Rather than lose it all, it gently counts back down! + if ((dashmode+3) >= DASHMODE_THRESHOLD && dashmode < DASHMODE_THRESHOLD) + S_StartSound(player->mo, sfx_kc65); + } + else + dashmode = 0; + } + + if (dashmode < DASHMODE_THRESHOLD) // Exits Dash Mode if you drop below speed/dash counter tics. Not in the above block so it doesn't keep disabling in midair. + { + player->normalspeed = skins[player->skin].normalspeed; // Reset to default if not capable of entering dash mode. + player->jumpfactor = skins[player->skin].jumpfactor; + } + else if (P_IsObjectOnGround(player->mo)) // Activate dash mode if we're on the ground. + { + if (player->normalspeed < skins[player->skin].normalspeed*2) // If the player normalspeed is not currently at normalspeed*2 in dash mode, add speed each tic + player->normalspeed += FRACUNIT/5; // Enter Dash Mode smoothly. + + if (player->jumpfactor < FixedMul(skins[player->skin].jumpfactor, 5*FRACUNIT/4)) // Boost jump height. + player->jumpfactor += FRACUNIT/300; + } + + if (player->normalspeed >= skins[player->skin].normalspeed*2) + { + mobj_t *ghost = P_SpawnGhostMobj(player->mo); // Spawns afterimages + ghost->fuse = 2; // Makes the images fade quickly + } + } + else if (dashmode) + { + if (dashmode >= DASHMODE_THRESHOLD) // catch getting the flag! + { + player->normalspeed = skins[player->skin].normalspeed; + player->jumpfactor = skins[player->skin].jumpfactor; + S_StartSound(player->mo, sfx_kc65); + } + dashmode = 0; + } +#undef dashmode + + LUAh_PlayerThink(player); + /* // Colormap verification { @@ -9199,6 +12455,36 @@ void P_PlayerThink(player_t *player) }*/ } +// Checks if the mobj is above lava. Used by Pterabyte. +static boolean P_MobjAboveLava(mobj_t *mobj) +{ + sector_t *sector = mobj->subsector->sector; + + if (sector->ffloors) + { + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || GETSECSPECIAL(rover->master->frontsector->special, 1) != 3) + continue; + + if (mobj->eflags & MFE_VERTICALFLIP) + { + if (*rover->bottomheight <= mobj->ceilingz && *rover->bottomheight >= mobj->z) + return true; + } + else + { + if (*rover->topheight >= mobj->floorz && *rover->topheight <= mobj->z) + return true; + } + } + } + + return false; +} + // // P_PlayerAfterThink // @@ -9244,10 +12530,15 @@ void P_PlayerAfterThink(player_t *player) if (thiscam && thiscam->chase) P_MoveChaseCamera(player, thiscam, false); } + if (player->followmobj) + { + P_RemoveMobj(player->followmobj); + P_SetTarget(&player->followmobj, NULL); + } return; } - if (player->pflags & PF_NIGHTSMODE) + if (player->powers[pw_carry] == CR_NIGHTSMODE) { player->powers[pw_gravityboots] = 0; //player->mo->eflags &= ~MFE_VERTICALFLIP; @@ -9357,148 +12648,268 @@ void P_PlayerAfterThink(player_t *player) if (player->currentweapon == WEP_RAIL && (!(player->ringweapons & RW_RAIL) || !player->powers[pw_railring])) player->currentweapon = 0; - // If you're out of rings, but have Infinity Rings left, switch to that. - if (player->currentweapon != 0 && player->health <= 1 && player->powers[pw_infinityring]) - player->currentweapon = 0; - if (P_IsLocalPlayer(player) && (player->pflags & PF_WPNDOWN) && player->currentweapon != oldweapon) S_StartSound(NULL, sfx_wepchg); - if (player->pflags & PF_GLIDING) - { - if (player->panim != PA_ABILITY) - P_SetPlayerMobjState(player->mo, S_PLAY_ABL1); - } - else if (player->pflags & PF_SLIDING) + if ((player->pflags & PF_SLIDING) && ((player->pflags & (PF_JUMPED|PF_NOJUMPDAMAGE)) != PF_JUMPED)) P_SetPlayerMobjState(player->mo, player->mo->info->painstate); - else if (player->pflags & PF_JUMPED - && ((!player->powers[pw_super] && player->panim != PA_ROLL) - || player->mo->state == &states[player->mo->info->painstate]) - && player->charability2 == CA2_SPINDASH) - P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - if (player->pflags & PF_CARRIED && player->mo->tracer) + /* if (player->powers[pw_carry] == CR_NONE && player->mo->tracer && !player->homing) + P_SetTarget(&player->mo->tracer, NULL); + else */ + if (player->mo->tracer) { - player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT)); - - // State check for the carrier - Flame - // You are an IDIOT, those aren't even the right frames! >_> - JTE - if (player->mo->tracer->player - && !(player->mo->tracer->state >= &states[S_PLAY_ABL1] - && player->mo->tracer->state <= &states[S_PLAY_SPC4])) - player->pflags &= ~PF_CARRIED; - - if (player->mo->eflags & MFE_VERTICALFLIP) + switch (player->powers[pw_carry]) { - if ((player->mo->tracer->z + player->mo->tracer->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= player->mo->tracer->ceilingz - && (player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z + player->mo->tracer->height + FixedMul(FRACUNIT, player->mo->scale); - else - player->pflags &= ~PF_CARRIED; - } - else - { - if ((player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= player->mo->tracer->floorz - && !(player->mo->tracer->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame - player->mo->z = player->mo->tracer->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale); - else - player->pflags &= ~PF_CARRIED; - } - - if (player->mo->tracer->health <= 0) - player->pflags &= ~PF_CARRIED; - else - { - P_TryMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, true); - player->mo->momx = player->mo->tracer->momx; - player->mo->momy = player->mo->tracer->momy; - player->mo->momz = player->mo->tracer->momz; - } - - if (gametype == GT_COOP) - { - player->mo->angle = player->mo->tracer->angle; - - if (!demoplayback || P_AnalogMove(player)) + case CR_PLAYER: // being carried by a flying character (such as Tails) { - if (player == &players[consoleplayer]) - localangle = player->mo->angle; - else if (player == &players[secondarydisplayplayer]) - localangle2 = player->mo->angle; + mobj_t *tails = player->mo->tracer; + player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14*FRACUNIT,10*FRACUNIT)); + + if (tails->player && !(tails->player->pflags & PF_CANCARRY)) + player->powers[pw_carry] = CR_NONE; + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if ((tails->z + tails->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= tails->ceilingz + && (tails->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame + player->mo->z = tails->z + tails->height + 12*player->mo->scale; + else + player->powers[pw_carry] = CR_NONE; + } + else + { + if ((tails->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= tails->floorz + && !(tails->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame + player->mo->z = tails->z - player->mo->height - 12*player->mo->scale; + else + player->powers[pw_carry] = CR_NONE; + } + + if (tails->health <= 0) + player->powers[pw_carry] = CR_NONE; + else + { + P_TryMove(player->mo, tails->x + P_ReturnThrustX(tails, tails->player->drawangle, 4*FRACUNIT), tails->y + P_ReturnThrustY(tails, tails->player->drawangle, 4*FRACUNIT), true); + player->mo->momx = tails->momx; + player->mo->momy = tails->momy; + player->mo->momz = tails->momz; + } + + if (gametype == GT_COOP && (!tails->player || tails->player->bot != 1)) + { + player->mo->angle = tails->angle; + + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) + { + if (player == &players[consoleplayer]) + localangle = player->mo->angle; + else if (player == &players[secondarydisplayplayer]) + localangle2 = player->mo->angle; + } + } + + if (P_AproxDistance(player->mo->x - tails->x, player->mo->y - tails->y) > player->mo->radius) + player->powers[pw_carry] = CR_NONE; + + if (player->powers[pw_carry] != CR_NONE) + { + if (player->mo->state-states != S_PLAY_RIDE) + P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); + if ((tails->skin && ((skin_t *)(tails->skin))->sprites[SPR2_SWIM].numframes) && (tails->eflags & MFE_UNDERWATER)) + tails->player->powers[pw_tailsfly] = 0; + } + else + P_SetTarget(&player->mo->tracer, NULL); + + if (player-players == consoleplayer && botingame) + CV_SetValue(&cv_analog[1], (player->powers[pw_carry] != CR_PLAYER)); + break; } - } - - if (P_AproxDistance(player->mo->x - player->mo->tracer->x, player->mo->y - player->mo->tracer->y) > player->mo->radius) - player->pflags &= ~PF_CARRIED; - - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - - if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, !(player->pflags & PF_CARRIED)); - } - else if (player->pflags & PF_ITEMHANG && player->mo->tracer) - { - // tracer is what you're hanging onto - P_UnsetThingPosition(player->mo); - player->mo->x = player->mo->tracer->x; - player->mo->y = player->mo->tracer->y; - if (player->mo->eflags & MFE_VERTICALFLIP) - player->mo->z = player->mo->tracer->z + player->mo->tracer->height - FixedDiv(player->mo->height, 3*FRACUNIT); - else - player->mo->z = player->mo->tracer->z - FixedDiv(player->mo->height, 3*FRACUNIT/2); - player->mo->momx = player->mo->momy = player->mo->momz = 0; - P_SetThingPosition(player->mo); - P_SetPlayerMobjState(player->mo, S_PLAY_CARRY); - - // Controllable missile - if (player->mo->tracer->type == MT_BLACKEGGMAN_MISSILE) - { - if (cmd->forwardmove > 0) - player->mo->tracer->momz += FixedMul(FRACUNIT/4, player->mo->tracer->scale); - else if (cmd->forwardmove < 0) - player->mo->tracer->momz -= FixedMul(FRACUNIT/4, player->mo->tracer->scale); - - player->mo->tracer->angle = player->mo->angle; - P_InstaThrust(player->mo->tracer, player->mo->tracer->angle, FixedMul(player->mo->tracer->info->speed, player->mo->tracer->scale)); - - if (player->mo->z <= player->mo->floorz - || player->mo->tracer->health <= 0) + case CR_GENERIC: // being carried by some generic item { - player->pflags &= ~PF_ITEMHANG; + mobj_t *item = player->mo->tracer; + // tracer is what you're hanging onto + P_UnsetThingPosition(player->mo); + player->mo->x = item->x; + player->mo->y = item->y; + if (player->mo->eflags & MFE_VERTICALFLIP) + player->mo->z = item->z + item->height - FixedDiv(player->mo->height, 3*FRACUNIT); + else + player->mo->z = item->z - FixedDiv(player->mo->height, 3*FRACUNIT/2); + player->mo->momx = player->mo->momy = player->mo->momz = 0; + P_SetThingPosition(player->mo); + if (player->mo->state-states != S_PLAY_RIDE) + P_SetPlayerMobjState(player->mo, S_PLAY_RIDE); + + // Controllable missile + if (item->type == MT_BLACKEGGMAN_MISSILE) + { + if (cmd->forwardmove > 0) + item->momz += FixedMul(FRACUNIT/4, item->scale); + else if (cmd->forwardmove < 0) + item->momz -= FixedMul(FRACUNIT/4, item->scale); + + item->angle = player->mo->angle; + P_InstaThrust(item, item->angle, FixedMul(item->info->speed, item->scale)); + + if (player->mo->z <= player->mo->floorz || item->health <= 0) + { + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer, NULL); + } + } + break; + } + case CR_MACESPIN: // being carried by a spinning chain + { + mobj_t *chain; + mobj_t *macecenter; + if (!player->mo->tracer->tracer) // can't spin around a point if... there is no point in doing so + break; + chain = player->mo->tracer; + macecenter = player->mo->tracer->tracer; + + player->mo->height = P_GetPlayerSpinHeight(player); + // tracer is what you're hanging onto.... + player->mo->momx = (chain->x - player->mo->x)*2; + player->mo->momy = (chain->y - player->mo->y)*2; + player->mo->momz = (chain->z - (player->mo->height-chain->height/2) - player->mo->z)*2; + P_TeleportMove(player->mo, chain->x, chain->y, chain->z - (player->mo->height-chain->height/2)); + if (!player->powers[pw_flashing]) // handle getting hurt + { + player->pflags |= PF_JUMPED; + player->pflags &= ~PF_NOJUMPDAMAGE; + player->secondjump = 0; + player->pflags &= ~PF_THOKKED; + + if ((macecenter->flags & MF_SLIDEME) // Noclimb on chain parameters gives this + && !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode? + { + macecenter->angle += cmd->sidemove<mo->angle += cmd->sidemove< ANGLE_MAX + + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) + { + if (player == &players[consoleplayer]) + localangle = player->mo->angle; // Adjust the local control angle. + else if (player == &players[secondarydisplayplayer]) + localangle2 = player->mo->angle; + } + } + } + break; + } + case CR_ROLLOUT: + { + mobj_t *mo = player->mo, *rock = player->mo->tracer; + UINT8 walktics = mo->state->tics - P_GetPlayerControlDirection(player); + + if (!rock || P_MobjWasRemoved(rock)) + { + P_SetTarget(&player->mo->tracer, NULL); + player->powers[pw_carry] = CR_NONE; + break; + } + + if (player->cmd.forwardmove || player->cmd.sidemove) + { + rock->movedir = (player->cmd.angleturn << FRACBITS) + R_PointToAngle2(0, 0, player->cmd.forwardmove << FRACBITS, -player->cmd.sidemove << FRACBITS); + P_Thrust(rock, rock->movedir, rock->scale >> 1); + } + + mo->momx = rock->momx; + mo->momy = rock->momy; + mo->momz = 0; + + if (player->panim == PA_IDLE && (mo->momx || mo->momy)) + { + P_SetPlayerMobjState(player->mo, S_PLAY_WALK); + } + + if (player->panim == PA_WALK && mo->tics > walktics) + { + mo->tics = walktics; + } + + P_TeleportMove(player->mo, rock->x, rock->y, rock->z + rock->height); + break; + } + case CR_PTERABYTE: // being carried by a Pterabyte + { + mobj_t *ptera = player->mo->tracer; + mobj_t *spawnpoint = ptera->tracer->tracer; + player->mo->height = FixedDiv(P_GetPlayerHeight(player), FixedDiv(14 * FRACUNIT, 10 * FRACUNIT)); + + if (ptera->health <= 0) + goto dropoff; + + if (P_MobjAboveLava(ptera) && ptera->movefactor <= 3*TICRATE - 10) + goto dropoff; + + if (player->mo->eflags & MFE_VERTICALFLIP) + { + if ((ptera->z + ptera->height + player->mo->height + FixedMul(FRACUNIT, player->mo->scale)) <= ptera->ceilingz + && (ptera->eflags & MFE_VERTICALFLIP)) // Reverse gravity check for the carrier - Flame + player->mo->z = ptera->z + ptera->height + FixedMul(FRACUNIT, player->mo->scale); + + if (ptera->ceilingz - ptera->z > spawnpoint->ceilingz - spawnpoint->z + 512*FRACUNIT && ptera->movefactor <= 3 * TICRATE - 10) + goto dropoff; + } + else + { + if ((ptera->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale)) >= ptera->floorz + && !(ptera->eflags & MFE_VERTICALFLIP)) // Correct gravity check for the carrier - Flame + player->mo->z = ptera->z - player->mo->height - FixedMul(FRACUNIT, player->mo->scale); + + if (ptera->z - ptera->floorz > spawnpoint->z - spawnpoint->floorz + 512 * FRACUNIT && ptera->movefactor <= 3 * TICRATE - 10) + goto dropoff; + } + + ptera->movefactor--; + if (!ptera->movefactor) + goto dropoff; + + if (ptera->cusval >= 50) + { + player->powers[pw_carry] = CR_NONE; + P_SetTarget(&player->mo->tracer, NULL); + P_KillMobj(ptera, player->mo, player->mo, 0); + player->mo->momz = 9*FRACUNIT; + player->pflags |= PF_APPLYAUTOBRAKE|PF_JUMPED|PF_THOKKED; + P_SetMobjState(player->mo, S_PLAY_ROLL); + break; + } + + if (ptera->cusval) + ptera->cusval--; + + P_TryMove(player->mo, ptera->x + ptera->watertop, ptera->y + ptera->waterbottom, true); + player->mo->z += ptera->cvmem; + player->mo->momx = ptera->momx; + player->mo->momy = ptera->momy; + player->mo->momz = ptera->momz; + + if (P_AproxDistance(player->mo->x - ptera->x - ptera->watertop, player->mo->y - ptera->y - ptera->waterbottom) > player->mo->radius) + goto dropoff; + + ptera->watertop >>= 1; + ptera->waterbottom >>= 1; + ptera->cvmem >>= 1; + + if (player->mo->state-states != S_PLAY_FALL) + P_SetPlayerMobjState(player->mo, S_PLAY_FALL); + break; + + dropoff: + player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); + ptera->movefactor = TICRATE; + ptera->extravalue1 |= 4; + break; } - } - } - else if (player->pflags & PF_MACESPIN && player->mo->tracer && player->mo->tracer->target) - { - player->mo->height = P_GetPlayerSpinHeight(player); - // tracer is what you're hanging onto.... - player->mo->momx = (player->mo->tracer->x - player->mo->x)*2; - player->mo->momy = (player->mo->tracer->y - player->mo->y)*2; - player->mo->momz = (player->mo->tracer->z - (player->mo->height-player->mo->tracer->height/2) - player->mo->z)*2; - P_TeleportMove(player->mo, player->mo->tracer->x, player->mo->tracer->y, player->mo->tracer->z - (player->mo->height-player->mo->tracer->height/2)); - player->pflags |= PF_JUMPED; - player->secondjump = 0; - player->pflags &= ~PF_THOKKED; - - if (cmd->forwardmove > 0) - player->mo->tracer->target->lastlook += 2; - else if (cmd->forwardmove < 0 && player->mo->tracer->target->lastlook > player->mo->tracer->target->movecount) - player->mo->tracer->target->lastlook -= 2; - - if (!(player->mo->tracer->target->flags & MF_SLIDEME) // Noclimb on chain parameters gives this - && !(twodlevel || player->mo->flags2 & MF2_TWOD)) // why on earth would you want to turn them in 2D mode? - { - player->mo->tracer->target->health += cmd->sidemove; - player->mo->angle += cmd->sidemove< ANGLE_MAX - - if (!demoplayback || P_AnalogMove(player)) - { - if (player == &players[consoleplayer]) - localangle = player->mo->angle; // Adjust the local control angle. - else if (player == &players[secondarydisplayplayer]) - localangle2 = player->mo->angle; - } + default: + break; } } @@ -9513,7 +12924,7 @@ void P_PlayerAfterThink(player_t *player) { // defaults to make sure 1st person cam doesn't do anything weird on startup player->deltaviewheight = 0; - player->viewheight = FixedMul(cv_viewheight.value << FRACBITS, player->mo->scale); + player->viewheight = FixedMul(41*player->height/48, player->mo->scale); if (player->mo->eflags & MFE_VERTICALFLIP) player->viewz = player->mo->z + player->mo->height - player->viewheight; else @@ -9523,9 +12934,6 @@ void P_PlayerAfterThink(player_t *player) } } - if (player->awayviewtics < 0) - player->awayviewtics = 0; - // spectator invisibility and nogravity. if ((netgame || multiplayer) && player->spectator) { @@ -9533,6 +12941,50 @@ void P_PlayerAfterThink(player_t *player) player->mo->flags |= MF_NOGRAVITY; } - if (P_IsObjectOnGround(player->mo)) - player->mo->pmomz = 0; + if (player->followmobj && (player->spectator || player->mo->health <= 0 || player->followmobj->type != player->followitem)) + { + P_RemoveMobj(player->followmobj); + P_SetTarget(&player->followmobj, NULL); + } + + if (!player->spectator && player->mo->health && player->followitem) + { + if (!player->followmobj || P_MobjWasRemoved(player->followmobj)) + { + P_SetTarget(&player->followmobj, P_SpawnMobjFromMobj(player->mo, 0, 0, 0, player->followitem)); + P_SetTarget(&player->followmobj->tracer, player->mo); + switch (player->followmobj->type) + { + case MT_METALJETFUME: + player->followmobj->colorized = true; + break; + default: + player->followmobj->flags2 |= MF2_LINKDRAW; + break; + } + } + + if (player->followmobj) + { + if (LUAh_FollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj)) + {;} + else + { + switch (player->followmobj->type) + { + case MT_TAILSOVERLAY: // c: + P_DoTailsOverlay(player, player->followmobj); + break; + case MT_METALJETFUME: + P_DoMetalJetFume(player, player->followmobj); + break; + default: + var1 = 1; + var2 = 0; + A_CapeChase(player->followmobj); + break; + } + } + } + } } diff --git a/src/r_bsp.c b/src/r_bsp.c index 694e3c74c..69d3a2f47 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,6 +15,7 @@ #include "g_game.h" #include "r_local.h" #include "r_state.h" +#include "r_portal.h" // Add seg portals #include "r_splats.h" #include "p_local.h" // camera @@ -26,11 +27,11 @@ side_t *sidedef; line_t *linedef; sector_t *frontsector; sector_t *backsector; -boolean portalline; // is curline a portal seg? // very ugly realloc() of drawsegs at run-time, I upped it to 512 // instead of 256.. and someone managed to send me a level with // 896 drawsegs! So too bad here's a limit removal a-la-Boom +drawseg_t *curdrawsegs = NULL; /**< This is used to handle multiple lists for masked drawsegs. */ drawseg_t *drawsegs = NULL; drawseg_t *ds_p = NULL; @@ -220,10 +221,7 @@ static INT32 R_DoorClosed(void) // preserve a kind of transparent door/lift special effect: && (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture) - && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture) - - // properly render skies (consider door "open" if both ceilings are sky): - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum); + && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture); } // @@ -237,8 +235,6 @@ static INT32 R_DoorClosed(void) sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, INT32 *ceilinglightlevel, boolean back) { - INT32 mapnum = -1; - if (floorlightlevel) *floorlightlevel = sec->floorlightsec == -1 ? sec->lightlevel : sectors[sec->floorlightsec].lightlevel; @@ -247,10 +243,10 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, *ceilinglightlevel = sec->ceilinglightsec == -1 ? sec->lightlevel : sectors[sec->ceilinglightsec].lightlevel; - // If the sector has a midmap, it's probably from 280 type - if (sec->midmap != -1) - mapnum = sec->midmap; - else if (sec->heightsec != -1) + // if (sec->midmap != -1) + // mapnum = sec->midmap; + // In original colormap code, this block did not run if sec->midmap was set + if (!sec->extra_colormap && sec->heightsec != -1) { const sector_t *s = §ors[sec->heightsec]; mobj_t *viewmobj = viewplayer->mo; @@ -274,8 +270,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floorheight = s->floorheight; tempsec->ceilingheight = s->ceilingheight; - mapnum = s->midmap; - if ((underwater && (tempsec-> floorheight = sec->floorheight, tempsec->ceilingheight = s->floorheight - 1, !back)) || viewz <= s->floorheight) { // head-below-floor hack @@ -301,7 +295,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->ceiling_yoffs = s->ceiling_yoffs; tempsec->ceilingpic_angle = s->ceilingpic_angle; } - mapnum = s->bottommap; } tempsec->lightlevel = s->lightlevel; @@ -325,8 +318,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, tempsec->floor_yoffs = tempsec->ceiling_yoffs = s->ceiling_yoffs; tempsec->floorpic_angle = tempsec->ceilingpic_angle = s->ceilingpic_angle; - mapnum = s->topmap; - if (s->floorpic == skyflatnum) // SKYFIX? { tempsec->ceilingheight = tempsec->floorheight-1; @@ -357,11 +348,6 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, sec = tempsec; } - if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) - sec->extra_colormap = &extra_colormaps[mapnum]; - else - sec->extra_colormap = NULL; - return sec; } @@ -404,6 +390,7 @@ static void R_AddLine(seg_t *line) INT32 x1, x2; angle_t angle1, angle2, span, tspan; static sector_t tempsec; + boolean bothceilingssky = false, bothfloorssky = false; portalline = false; @@ -473,7 +460,7 @@ static void R_AddLine(seg_t *line) line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2); if (line2 >= 0) // found it! { - R_AddPortal(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering + Portal_Add2Lines(line->linedef-lines, line2, x1, x2); // Remember the lines for later rendering //return; // Don't fill in that space now! goto clipsolid; } @@ -490,6 +477,25 @@ static void R_AddLine(seg_t *line) doorclosed = 0; + if (backsector->ceilingpic == skyflatnum && frontsector->ceilingpic == skyflatnum) + bothceilingssky = true; + if (backsector->floorpic == skyflatnum && frontsector->floorpic == skyflatnum) + bothfloorssky = true; + + if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then + { + if ( +#ifdef POLYOBJECTS + !line->polyseg && +#endif + !line->sidedef->midtexture + && ((!frontsector->ffloors && !backsector->ffloors) + || (frontsector->tag == backsector->tag))) + return; // line is empty, don't even bother + + goto clippass; // treat like wide open window instead + } + // Closed door. #ifdef ESLOPE if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) @@ -508,48 +514,59 @@ static void R_AddLine(seg_t *line) SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector->floorheight) SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight) #undef SLOPEPARAMS - if ((backc1 <= frontf1 && backc2 <= frontf2) - || (backf1 >= frontc1 && backf2 >= frontc2)) + // if both ceilings are skies, consider it always "open" + // same for floors + if (!bothceilingssky && !bothfloorssky) { - goto clipsolid; + if ((backc1 <= frontf1 && backc2 <= frontf2) + || (backf1 >= frontc1 && backf2 >= frontc2)) + { + goto clipsolid; + } + + // Check for automap fix. Store in doorclosed for r_segs.c + doorclosed = (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture)); + + if (doorclosed) + goto clipsolid; } - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; - // Window. - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) - { - goto clippass; - } + if (!bothceilingssky) // ceilings are always the "same" when sky + if (backc1 != frontc1 || backc2 != frontc2) + goto clippass; + if (!bothfloorssky) // floors are always the "same" when sky + if (backf1 != frontf1 || backf2 != frontf2) + goto clippass; } else #endif { - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) + // if both ceilings are skies, consider it always "open" + // same for floors + if (!bothceilingssky && !bothfloorssky) { - goto clipsolid; - } + if (backsector->ceilingheight <= frontsector->floorheight + || backsector->floorheight >= frontsector->ceilingheight) + { + goto clipsolid; + } - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = R_DoorClosed(); - if (doorclosed) - goto clipsolid; + // Check for automap fix. Store in doorclosed for r_segs.c + doorclosed = R_DoorClosed(); + if (doorclosed) + goto clipsolid; + } // Window. - if (backsector->ceilingheight != frontsector->ceilingheight - || backsector->floorheight != frontsector->floorheight) - { - goto clippass; - } + if (!bothceilingssky) // ceilings are always the "same" when sky + if (backsector->ceilingheight != frontsector->ceilingheight) + goto clippass; + if (!bothfloorssky) // floors are always the "same" when sky + if (backsector->floorheight != frontsector->floorheight) + goto clippass; } // Reject empty lines used for triggers and special events. @@ -873,11 +890,11 @@ static void R_Subsector(size_t num) light = R_GetPlaneLight(frontsector, floorcenterz, false); if (frontsector->floorlightsec == -1) floorlightlevel = *frontsector->lightlist[light].lightlevel; - floorcolormap = frontsector->lightlist[light].extra_colormap; + floorcolormap = *frontsector->lightlist[light].extra_colormap; light = R_GetPlaneLight(frontsector, ceilingcenterz, false); if (frontsector->ceilinglightsec == -1) ceilinglightlevel = *frontsector->lightlist[light].lightlevel; - ceilingcolormap = frontsector->lightlist[light].extra_colormap; + ceilingcolormap = *frontsector->lightlist[light].extra_colormap; } sub->sector->extra_colormap = frontsector->extra_colormap; @@ -886,7 +903,8 @@ static void R_Subsector(size_t num) #ifdef ESLOPE frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : #endif - frontsector->floorheight) < viewz || (frontsector->heightsec != -1 + frontsector->floorheight) < viewz || frontsector->floorpic == skyflatnum + || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))) { floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, @@ -973,7 +991,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(*rover->bottomheight, *rover->bottompic, *frontsector->lightlist[light].lightlevel, *rover->bottomxoffs, - *rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover + *rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover #ifdef POLYOBJECTS_PLANES , NULL #endif @@ -1019,7 +1037,7 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = R_FindPlane(*rover->topheight, *rover->toppic, *frontsector->lightlist[light].lightlevel, *rover->topxoffs, *rover->topyoffs, *rover->topangle, - frontsector->lightlist[light].extra_colormap, rover + *frontsector->lightlist[light].extra_colormap, rover #ifdef POLYOBJECTS_PLANES , NULL #endif @@ -1068,29 +1086,11 @@ static void R_Subsector(size_t num) && polysec->floorheight >= floorcenterz && (viewz < polysec->floorheight)) { - fixed_t xoff, yoff; - xoff = polysec->floor_xoffs; - yoff = polysec->floor_yoffs; - - if (po->angle != 0) { - angle_t fineshift = po->angle >> ANGLETOFINESHIFT; - - xoff -= FixedMul(FINECOSINE(fineshift), po->centerPt.x)+FixedMul(FINESINE(fineshift), po->centerPt.y); - yoff -= FixedMul(FINESINE(fineshift), po->centerPt.x)-FixedMul(FINECOSINE(fineshift), po->centerPt.y); - } else { - xoff -= po->centerPt.x; - yoff += po->centerPt.y; - } - light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic, - polysec->lightlevel, xoff, yoff, - polysec->floorpic_angle-po->angle, - NULL, - NULL -#ifdef POLYOBJECTS_PLANES - , po -#endif + (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->floor_xoffs, polysec->floor_yoffs, + polysec->floorpic_angle-po->angle, + (light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po #ifdef ESLOPE , NULL // will ffloors be slopable eventually? #endif @@ -1115,27 +1115,10 @@ static void R_Subsector(size_t num) && polysec->ceilingheight <= ceilingcenterz && (viewz > polysec->ceilingheight)) { - fixed_t xoff, yoff; - xoff = polysec->ceiling_xoffs; - yoff = polysec->ceiling_yoffs; - - if (po->angle != 0) { - angle_t fineshift = po->angle >> ANGLETOFINESHIFT; - - xoff -= FixedMul(FINECOSINE(fineshift), po->centerPt.x)+FixedMul(FINESINE(fineshift), po->centerPt.y); - yoff -= FixedMul(FINESINE(fineshift), po->centerPt.x)-FixedMul(FINECOSINE(fineshift), po->centerPt.y); - } else { - xoff -= po->centerPt.x; - yoff += po->centerPt.y; - } - - light = R_GetPlaneLight(frontsector, polysec->ceilingheight, viewz < polysec->ceilingheight); + light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, - polysec->lightlevel, xoff, yoff, polysec->ceilingpic_angle-po->angle, - NULL, NULL -#ifdef POLYOBJECTS_PLANES - , po -#endif + (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceiling_xoffs, polysec->ceiling_yoffs, polysec->ceilingpic_angle-po->angle, + (light == -1 ? frontsector->extra_colormap : *frontsector->lightlist[light].extra_colormap), NULL, po #ifdef ESLOPE , NULL // will ffloors be slopable eventually? #endif @@ -1186,9 +1169,11 @@ static void R_Subsector(size_t num) while (count--) { // CONS_Debug(DBG_GAMELOGIC, "Adding normal line %d...(%d)\n", line->linedef-lines, leveltime); + if (!line->glseg #ifdef POLYOBJECTS - if (!line->polyseg) // ignore segs that belong to polyobjects + && !line->polyseg // ignore segs that belong to polyobjects #endif + ) R_AddLine(line); line++; curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so stuff doesn't try using it for other things */ @@ -1205,7 +1190,7 @@ void R_Prep3DFloors(sector_t *sector) ffloor_t *rover; ffloor_t *best; fixed_t bestheight, maxheight; - INT32 count, i, mapnum; + INT32 count, i; sector_t *sec; boolean doubleshadowbottom; // is this the bottom of a doubleshadow FOF? #ifdef ESLOPE @@ -1245,7 +1230,7 @@ void R_Prep3DFloors(sector_t *sector) #endif sector->lightlist[0].lightlevel = §or->lightlevel; sector->lightlist[0].caster = NULL; - sector->lightlist[0].extra_colormap = sector->extra_colormap; + sector->lightlist[0].extra_colormap = §or->extra_colormap; sector->lightlist[0].flags = 0; maxheight = INT32_MAX; @@ -1318,11 +1303,6 @@ void R_Prep3DFloors(sector_t *sector) sector->lightlist[i].slope = bestslope; #endif sec = §ors[best->secnum]; - mapnum = sec->midmap; - if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) - sec->extra_colormap = &extra_colormaps[mapnum]; - else - sec->extra_colormap = NULL; if (best->flags & FF_DOUBLESHADOW) { @@ -1345,12 +1325,12 @@ void R_Prep3DFloors(sector_t *sector) else if (best->flags & FF_COLORMAPONLY) { sector->lightlist[i].lightlevel = sector->lightlist[i-1].lightlevel; - sector->lightlist[i].extra_colormap = sec->extra_colormap; + sector->lightlist[i].extra_colormap = &sec->extra_colormap; } else { sector->lightlist[i].lightlevel = best->toplightlevel; - sector->lightlist[i].extra_colormap = sec->extra_colormap; + sector->lightlist[i].extra_colormap = &sec->extra_colormap; } } } diff --git a/src/r_bsp.h b/src/r_bsp.h index e3662e2e6..1562b79f6 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -29,6 +29,7 @@ extern boolean portalline; // is curline a portal seg? extern INT32 checkcoord[12][4]; +extern drawseg_t *curdrawsegs; extern drawseg_t *drawsegs; extern drawseg_t *ds_p; extern INT32 doorclosed; @@ -38,7 +39,6 @@ void R_ClearClipSegs(void); void R_PortalClearClipSegs(INT32 start, INT32 end); void R_ClearDrawSegs(void); void R_RenderBSPNode(INT32 bspnum); -void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2); #ifdef POLYOBJECTS void R_SortPolyObjects(subsector_t *sub); diff --git a/src/r_data.c b/src/r_data.c index a21ba49ae..3d80bbda3 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -2,14 +2,14 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- /// \file r_data.c -/// \brief Preparation of data for rendering,generation of lookups, caching, retrieval by name +/// \brief Preparation of data for rendering, generation of lookups, caching, retrieval by name #include "doomdef.h" #include "g_game.h" @@ -19,22 +19,29 @@ #include "p_local.h" #include "m_misc.h" #include "r_data.h" +#include "r_patch.h" #include "w_wad.h" #include "z_zone.h" #include "p_setup.h" // levelflats -#include "v_video.h" // pLocalPalette +#include "v_video.h" // pMasterPalette +#include "f_finale.h" // wipes +#include "byteptr.h" #include "dehacked.h" -#if defined (_WIN32) || defined (_WIN32_WCE) +#ifdef _WIN32 #include // alloca(sizeof) #endif +#ifdef HWRENDER +#include "hardware/hw_main.h" // HWR_LoadTextures +#endif + #if defined(_MSC_VER) #pragma pack(1) #endif // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog -#ifdef _WIN32_WCE +#if 0 #define AVOID_ERRNO #else #include @@ -98,12 +105,11 @@ INT32 numtextures = 0; // total number of textures found, // size of following tables texture_t **textures = NULL; +textureflat_t *texflats = NULL; static UINT32 **texturecolumnofs; // column offset lookup table for each texture static UINT8 **texturecache; // graphics data for each generated full-size texture -// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask -INT32 *texturewidthmask; - +INT32 *texturewidth; fixed_t *textureheight; // needed for texture pegging INT32 *texturetranslation; @@ -112,9 +118,10 @@ INT32 *texturetranslation; sprcache_t *spritecachedinfo; lighttable_t *colormaps; +lighttable_t *fadecolormap; // for debugging/info purposes -static size_t flatmemory, spritememory, texturememory; +size_t flatmemory, spritememory, texturememory; // highcolor stuff INT16 color8to16[256]; // remap color index to highcolor rgb value @@ -141,11 +148,14 @@ static INT32 tidcachelen = 0; // R_DrawColumnInCache // Clip and draw a column from a patch into a cached post. // -static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 originy, INT32 cacheheight) +static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) { INT32 count, position; UINT8 *source; INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; + + (void)patchheight; // This parameter is unused while (patch->topdelta != 0xff) { @@ -160,6 +170,7 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 orig if (position < 0) { count += position; + source -= position; // start further down the column position = 0; } @@ -173,13 +184,257 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 orig } } +// +// R_DrawFlippedColumnInCache +// Similar to R_DrawColumnInCache; it draws the column inverted, however. +// +static inline void R_DrawFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) +{ + INT32 count, position; + UINT8 *source, *dest; + INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; + + while (patch->topdelta != 0xff) + { + topdelta = patch->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + topdelta = patchheight-patch->length-topdelta; + source = (UINT8 *)patch + 2 + patch->length; // patch + 3 + (patch->length-1) + count = patch->length; + position = originy + topdelta; + + if (position < 0) + { + count += position; + source += position; // start further UP the column + position = 0; + } + + if (position + count > cacheheight) + count = cacheheight - position; + + dest = cache + position; + if (count > 0) + { + for (; dest < cache + position + count; --source) + *dest++ = *source; + } + + patch = (column_t *)((UINT8 *)patch + patch->length + 4); + } +} + +UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) +{ + RGBA_t output; + INT16 fullalpha = (alpha - (0xFF - foreground.s.alpha)); + if (style == AST_TRANSLUCENT) + { + if (fullalpha <= 0) + output.rgba = background.rgba; + else + { + // don't go too high + if (fullalpha >= 0xFF) + fullalpha = 0xFF; + alpha = (UINT8)fullalpha; + + // if the background pixel is empty, match software and don't blend anything + if (!background.s.alpha) + output.rgba = 0; + else + { + UINT8 beta = (0xFF - alpha); + output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF; + output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF; + output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF; + output.s.alpha = 0xFF; + } + } + return output.rgba; + } +#define clamp(c) max(min(c, 0xFF), 0x00); + else + { + float falpha = ((float)alpha / 256.0f); + float fr = ((float)foreground.s.red * falpha); + float fg = ((float)foreground.s.green * falpha); + float fb = ((float)foreground.s.blue * falpha); + if (style == AST_ADD) + { + output.s.red = clamp((int)(background.s.red + fr)); + output.s.green = clamp((int)(background.s.green + fg)); + output.s.blue = clamp((int)(background.s.blue + fb)); + } + else if (style == AST_SUBTRACT) + { + output.s.red = clamp((int)(background.s.red - fr)); + output.s.green = clamp((int)(background.s.green - fg)); + output.s.blue = clamp((int)(background.s.blue - fb)); + } + else if (style == AST_REVERSESUBTRACT) + { + output.s.red = clamp((int)((-background.s.red) + fr)); + output.s.green = clamp((int)((-background.s.green) + fg)); + output.s.blue = clamp((int)((-background.s.blue) + fb)); + } + else if (style == AST_MODULATE) + { + fr = ((float)foreground.s.red / 256.0f); + fg = ((float)foreground.s.green / 256.0f); + fb = ((float)foreground.s.blue / 256.0f); + output.s.red = clamp((int)(background.s.red * fr)); + output.s.green = clamp((int)(background.s.green * fg)); + output.s.blue = clamp((int)(background.s.blue * fb)); + } + // just copy the pixel + else if (style == AST_COPY) + output.rgba = foreground.rgba; + + output.s.alpha = 0xFF; + return output.rgba; + } +#undef clamp + return 0; +} + +UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha) +{ + // Alpha style set to translucent? + if (style == AST_TRANSLUCENT) + { + // Is the alpha small enough for translucency? + if (alpha <= (10*255/11)) + { + UINT8 *mytransmap; + // Is the patch way too translucent? Don't blend then. + if (alpha < 255/11) + return background; + // The equation's not exact but it works as intended. I'll call it a day for now. + mytransmap = transtables + ((8*(alpha) + 255/8)/(255 - 255/11) << FF_TRANSSHIFT); + if (background != 0xFF) + return *(mytransmap + (background<<8) + foreground); + } + else // just copy the pixel + return foreground; + } + // just copy the pixel + else if (style == AST_COPY) + return foreground; + // use ASTBlendPixel for all other blend modes + // and find the nearest colour in the palette + else if (style != AST_TRANSLUCENT) + { + RGBA_t texel; + RGBA_t bg = V_GetMasterColor(background); + RGBA_t fg = V_GetMasterColor(foreground); + texel.rgba = ASTBlendPixel(bg, fg, style, alpha); + return NearestColor(texel.s.red, texel.s.green, texel.s.blue); + } + // fallback if all above fails, somehow + // return the background pixel + return background; +} + +// +// R_DrawBlendColumnInCache +// Draws a translucent column into the cache, applying a half-cooked equation to get a proper translucency value (Needs code in R_GenerateTexture()). +// +static inline void R_DrawBlendColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) +{ + INT32 count, position; + UINT8 *source, *dest; + INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; + + (void)patchheight; // This parameter is unused + + while (patch->topdelta != 0xff) + { + topdelta = patch->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (UINT8 *)patch + 3; + count = patch->length; + position = originy + topdelta; + + if (position < 0) + { + count += position; + source -= position; // start further down the column + position = 0; + } + + if (position + count > cacheheight) + count = cacheheight - position; + + dest = cache + position; + if (count > 0) + { + for (; dest < cache + position + count; source++, dest++) + if (*source != 0xFF) + *dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha); + } + + patch = (column_t *)((UINT8 *)patch + patch->length + 4); + } +} + +// +// R_DrawBlendFlippedColumnInCache +// Similar to the one above except that the column is inverted. +// +static inline void R_DrawBlendFlippedColumnInCache(column_t *patch, UINT8 *cache, texpatch_t *originPatch, INT32 cacheheight, INT32 patchheight) +{ + INT32 count, position; + UINT8 *source, *dest; + INT32 topdelta, prevdelta = -1; + INT32 originy = originPatch->originy; + + while (patch->topdelta != 0xff) + { + topdelta = patch->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + topdelta = patchheight-patch->length-topdelta; + source = (UINT8 *)patch + 2 + patch->length; // patch + 3 + (patch->length-1) + count = patch->length; + position = originy + topdelta; + + if (position < 0) + { + count += position; + source += position; // start further UP the column + position = 0; + } + + if (position + count > cacheheight) + count = cacheheight - position; + + dest = cache + position; + if (count > 0) + { + for (; dest < cache + position + count; --source, dest++) + if (*source != 0xFF) + *dest = ASTBlendPixel_8bpp(*dest, *source, originPatch->style, originPatch->alpha); + } + + patch = (column_t *)((UINT8 *)patch + patch->length + 4); + } +} + // // R_GenerateTexture // // Allocate space for full size texture, either single patch or 'composite' // Build the full textures from patches. // The texture caching system is a little more hungry of memory, but has -// been simplified for the sake of highcolor, dynamic ligthing, & speed. +// been simplified for the sake of highcolor (lol), dynamic ligthing, & speed. // // This is not optimised, but it's supposed to be executed only once // per level, when enough memory is available. @@ -191,10 +446,15 @@ static UINT8 *R_GenerateTexture(size_t texnum) texture_t *texture; texpatch_t *patch; patch_t *realpatch; - int x, x1, x2, i; + UINT8 *pdata; + int x, x1, x2, i, width, height; size_t blocksize; column_t *patchcol; - UINT32 *colofs; + UINT8 *colofs; + + UINT16 wadnum; + lumpnum_t lumpnum; + size_t lumplength; I_Assert(texnum <= (size_t)numtextures); texture = textures[texnum]; @@ -210,15 +470,29 @@ static UINT8 *R_GenerateTexture(size_t texnum) { boolean holey = false; patch = texture->patches; - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + + wadnum = patch->wad; + lumpnum = patch->lump; + lumplength = W_LumpLengthPwad(wadnum, lumpnum); + pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + realpatch = (patch_t *)pdata; + +#ifndef NO_PNG_LUMPS + if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) + goto multipatch; +#endif +#ifdef WALLFLATS + if (texture->type == TEXTURETYPE_FLAT) + goto multipatch; +#endif // Check the patch for holes. if (texture->width > SHORT(realpatch->width) || texture->height > SHORT(realpatch->height)) holey = true; - colofs = (UINT32 *)realpatch->columnofs; + colofs = (UINT8 *)realpatch->columnofs; for (x = 0; x < texture->width && !holey; x++) { - column_t *col = (column_t *)((UINT8 *)realpatch + LONG(colofs[x])); + column_t *col = (column_t *)((UINT8 *)realpatch + LONG(*(UINT32 *)&colofs[x<<2])); INT32 topdelta, prevdelta = -1, y = 0; while (col->topdelta != 0xff) { @@ -239,18 +513,27 @@ static UINT8 *R_GenerateTexture(size_t texnum) if (holey) { texture->holes = true; - blocksize = W_LumpLengthPwad(patch->wad, patch->lump); + texture->flip = patch->flip; + blocksize = lumplength; block = Z_Calloc(blocksize, PU_STATIC, // will change tag at end of this function &texturecache[texnum]); M_Memcpy(block, realpatch, blocksize); texturememory += blocksize; // use the patch's column lookup - colofs = (UINT32 *)(void *)(block + 8); - texturecolumnofs[texnum] = colofs; + colofs = (block + 8); + texturecolumnofs[texnum] = (UINT32 *)colofs; blocktex = block; + if (patch->flip & 1) // flip the patch horizontally + { + UINT8 *realcolofs = (UINT8 *)realpatch->columnofs; + for (x = 0; x < texture->width; x++) + *(UINT32 *)&colofs[x<<2] = realcolofs[( texture->width-1-x )<<2]; // swap with the offset of the other side of the texture + } + // we can't as easily flip the patch vertically sadly though, + // we have wait until the texture itself is drawn to do that for (x = 0; x < texture->width; x++) - colofs[x] = LONG(LONG(colofs[x]) + 3); + *(UINT32 *)&colofs[x<<2] = LONG(LONG(*(UINT32 *)&colofs[x<<2]) + 3); goto done; } @@ -258,16 +541,18 @@ static UINT8 *R_GenerateTexture(size_t texnum) } // multi-patch textures (or 'composite') + multipatch: texture->holes = false; + texture->flip = 0; blocksize = (texture->width * 4) + (texture->width * texture->height); texturememory += blocksize; block = Z_Malloc(blocksize+1, PU_STATIC, &texturecache[texnum]); - memset(block, 0xF7, blocksize+1); // Transparency hack + memset(block, TRANSPARENTPIXEL, blocksize+1); // Transparency hack // columns lookup table - colofs = (UINT32 *)(void *)block; - texturecolumnofs[texnum] = colofs; + colofs = block; + texturecolumnofs[texnum] = (UINT32 *)colofs; // texture data after the lookup table blocktex = block + (texture->width*4); @@ -275,26 +560,73 @@ static UINT8 *R_GenerateTexture(size_t texnum) // Composite the columns together. for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { - realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); - x1 = patch->originx; - x2 = x1 + SHORT(realpatch->width); + boolean dealloc = true; + static void (*ColumnDrawerPointer)(column_t *, UINT8 *, texpatch_t *, INT32, INT32); // Column drawing function pointer. + if (patch->style != AST_COPY) + ColumnDrawerPointer = (patch->flip & 2) ? R_DrawBlendFlippedColumnInCache : R_DrawBlendColumnInCache; + else + ColumnDrawerPointer = (patch->flip & 2) ? R_DrawFlippedColumnInCache : R_DrawColumnInCache; + wadnum = patch->wad; + lumpnum = patch->lump; + pdata = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + lumplength = W_LumpLengthPwad(wadnum, lumpnum); + realpatch = (patch_t *)pdata; + dealloc = true; + +#ifndef NO_PNG_LUMPS + if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) + realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL); + else +#endif +#ifdef WALLFLATS + if (texture->type == TEXTURETYPE_FLAT) + realpatch = R_FlatToPatch(pdata, texture->width, texture->height, 0, 0, NULL, false); + else +#endif + { + (void)lumplength; + dealloc = false; + } + + x1 = patch->originx; + width = SHORT(realpatch->width); + height = SHORT(realpatch->height); + x2 = x1 + width; + + if (x1 > texture->width || x2 < 0) + continue; // patch not located within texture's x bounds, ignore + + if (patch->originy > texture->height || (patch->originy + height) < 0) + continue; // patch not located within texture's y bounds, ignore + + // patch is actually inside the texture! + // now check if texture is partly off-screen and adjust accordingly + + // left edge if (x1 < 0) x = 0; else x = x1; + // right edge if (x2 > texture->width) x2 = texture->width; for (; x < x2; x++) { - patchcol = (column_t *)((UINT8 *)realpatch + LONG(realpatch->columnofs[x-x1])); + if (patch->flip & 1) + patchcol = (column_t *)((UINT8 *)realpatch + LONG(realpatch->columnofs[(x1+width-1)-x])); + else + patchcol = (column_t *)((UINT8 *)realpatch + LONG(realpatch->columnofs[x-x1])); // generate column ofset lookup - colofs[x] = LONG((x * texture->height) + (texture->width*4)); - R_DrawColumnInCache(patchcol, block + LONG(colofs[x]), patch->originy, texture->height); + *(UINT32 *)&colofs[x<<2] = LONG((x * texture->height) + (texture->width*4)); + ColumnDrawerPointer(patchcol, block + LONG(*(UINT32 *)&colofs[x<<2]), patch, texture->height, height); } + + if (dealloc) + Z_Free(realpatch); } done: @@ -335,10 +667,14 @@ void R_CheckTextureCache(INT32 tex) UINT8 *R_GetColumn(fixed_t tex, INT32 col) { UINT8 *data; + INT32 width = texturewidth[tex]; + + if (width & (width - 1)) + col = (UINT32)col % width; + else + col &= (width - 1); - col &= texturewidthmask[tex]; data = texturecache[tex]; - if (!data) data = R_GenerateTexture(tex); @@ -368,20 +704,228 @@ void R_FlushTextureCache(void) int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum); void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *index); +#ifdef WALLFLATS +static INT32 +Rloadflats (INT32 i, INT32 w) +{ + UINT16 j; + UINT16 texstart, texend; + texture_t *texture; + texpatch_t *patch; + + // Yes + if (wadfiles[w]->type == RET_PK3) + { + texstart = W_CheckNumForFolderStartPK3("flats/", (UINT16)w, 0); + texend = W_CheckNumForFolderEndPK3("flats/", (UINT16)w, texstart); + } + else + { + texstart = W_CheckNumForNamePwad("F_START", (UINT16)w, 0); + texend = W_CheckNumForNamePwad("F_END", (UINT16)w, texstart); + } + + if (!( texstart == INT16_MAX || texend == INT16_MAX )) + { + texstart++; // Do not count the first marker + + // Work through each lump between the markers in the WAD. + for (j = 0; j < (texend - texstart); j++) + { + UINT8 *flatlump; + UINT16 wadnum = (UINT16)w; + lumpnum_t lumpnum = texstart + j; + size_t lumplength; + size_t flatsize = 0; + + if (wadfiles[w]->type == RET_PK3) + { + if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder + continue; // If it is then SKIP IT + } + + flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + lumplength = W_LumpLengthPwad(wadnum, lumpnum); + + switch (lumplength) + { + case 4194304: // 2048x2048 lump + flatsize = 2048; + break; + case 1048576: // 1024x1024 lump + flatsize = 1024; + break; + case 262144:// 512x512 lump + flatsize = 512; + break; + case 65536: // 256x256 lump + flatsize = 256; + break; + case 16384: // 128x128 lump + flatsize = 128; + break; + case 1024: // 32x32 lump + flatsize = 32; + break; + default: // 64x64 lump + flatsize = 64; + break; + } + + //CONS_Printf("\n\"%s\" is a flat, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),flatsize,flatsize); + texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); + + // Set texture properties. + M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); + +#ifndef NO_PNG_LUMPS + if (R_IsLumpPNG((UINT8 *)flatlump, lumplength)) + { + INT16 width, height; + R_PNGDimensions((UINT8 *)flatlump, &width, &height, lumplength); + texture->width = width; + texture->height = height; + } + else +#endif + texture->width = texture->height = flatsize; + + texture->type = TEXTURETYPE_FLAT; + texture->patchcount = 1; + texture->holes = false; + texture->flip = 0; + + // Allocate information for the texture's patches. + patch = &texture->patches[0]; + + patch->originx = patch->originy = 0; + patch->wad = (UINT16)w; + patch->lump = texstart + j; + patch->flip = 0; + + Z_Unlock(flatlump); + + texturewidth[i] = texture->width; + textureheight[i] = texture->height << FRACBITS; + i++; + } + } + + return i; +} +#endif/*WALLFLATS*/ + +#define TX_START "TX_START" +#define TX_END "TX_END" + +static INT32 +Rloadtextures (INT32 i, INT32 w) +{ + UINT16 j; + UINT16 texstart, texend, texturesLumpPos; + texture_t *texture; + patch_t *patchlump; + texpatch_t *patch; + + // Get the lump numbers for the markers in the WAD, if they exist. + if (wadfiles[w]->type == RET_PK3) + { + texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); + texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); + while (texturesLumpPos != INT16_MAX) + { + R_ParseTEXTURESLump(w, texturesLumpPos, &i); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1); + } + } + else + { + texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0); + texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); + texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); + if (texturesLumpPos != INT16_MAX) + R_ParseTEXTURESLump(w, texturesLumpPos, &i); + } + + if (!( texstart == INT16_MAX || texend == INT16_MAX )) + { + texstart++; // Do not count the first marker + + // Work through each lump between the markers in the WAD. + for (j = 0; j < (texend - texstart); j++) + { + UINT16 wadnum = (UINT16)w; + lumpnum_t lumpnum = texstart + j; +#ifndef NO_PNG_LUMPS + size_t lumplength; +#endif + + if (wadfiles[w]->type == RET_PK3) + { + if (W_IsLumpFolder(wadnum, lumpnum)) // Check if lump is a folder + continue; // If it is then SKIP IT + } + + patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); +#ifndef NO_PNG_LUMPS + lumplength = W_LumpLengthPwad(wadnum, lumpnum); +#endif + + //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); + texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); + + // Set texture properties. + M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); + +#ifndef NO_PNG_LUMPS + if (R_IsLumpPNG((UINT8 *)patchlump, lumplength)) + { + INT16 width, height; + R_PNGDimensions((UINT8 *)patchlump, &width, &height, lumplength); + texture->width = width; + texture->height = height; + } + else +#endif + { + texture->width = SHORT(patchlump->width); + texture->height = SHORT(patchlump->height); + } + + texture->type = TEXTURETYPE_SINGLEPATCH; + texture->patchcount = 1; + texture->holes = false; + texture->flip = 0; + + // Allocate information for the texture's patches. + patch = &texture->patches[0]; + + patch->originx = patch->originy = 0; + patch->wad = (UINT16)w; + patch->lump = texstart + j; + patch->flip = 0; + + Z_Unlock(patchlump); + + texturewidth[i] = texture->width; + textureheight[i] = texture->height << FRACBITS; + i++; + } + } + + return i; +} + // // R_LoadTextures // Initializes the texture list with the textures from the world map. // -#define TX_START "TX_START" -#define TX_END "TX_END" void R_LoadTextures(void) { - INT32 i, k, w; + INT32 i, w; UINT16 j; UINT16 texstart, texend, texturesLumpPos; - patch_t *patchlump; - texpatch_t *patch; - texture_t *texture; // Free previous memory before numtextures change. if (numtextures) @@ -393,6 +937,7 @@ void R_LoadTextures(void) } Z_Free(texturetranslation); Z_Free(textures); + Z_Free(texflats); } // Load patches and textures. @@ -404,17 +949,40 @@ void R_LoadTextures(void) // but the alternative is to spend a ton of time checking and re-checking all previous entries just to skip any potentially patched textures. for (w = 0, numtextures = 0; w < numwadfiles; w++) { +#ifdef WALLFLATS + // Count flats if (wadfiles[w]->type == RET_PK3) { - texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); - texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); + texstart = W_CheckNumForFolderStartPK3("flats/", (UINT16)w, 0); + texend = W_CheckNumForFolderEndPK3("flats/", (UINT16)w, texstart); } else { - texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1; - texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); + texstart = W_CheckNumForNamePwad("F_START", (UINT16)w, 0); + texend = W_CheckNumForNamePwad("F_END", (UINT16)w, texstart); } + if (!( texstart == INT16_MAX || texend == INT16_MAX )) + { + texstart++; // Do not count the first marker + + // PK3s have subfolders, so we can't just make a simple sum + if (wadfiles[w]->type == RET_PK3) + { + for (j = texstart; j < texend; j++) + { + if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it + numtextures++; + } + } + else // Add all the textures between F_START and F_END + { + numtextures += (UINT32)(texend - texstart); + } + } +#endif/*WALLFLATS*/ + + // Count the textures from TEXTURES lumps texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); while (texturesLumpPos != INT16_MAX) { @@ -422,30 +990,54 @@ void R_LoadTextures(void) texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1); } - // Add all the textures between TX_START and TX_END - if (texstart != INT16_MAX && texend != INT16_MAX) + // Count single-patch textures + if (wadfiles[w]->type == RET_PK3) + { + texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); + texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); + } + else + { + texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0); + texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); + } + + if (texstart == INT16_MAX || texend == INT16_MAX) + continue; + + texstart++; // Do not count the first marker + + // PK3s have subfolders, so we can't just make a simple sum + if (wadfiles[w]->type == RET_PK3) + { + for (j = texstart; j < texend; j++) + { + if (!W_IsLumpFolder((UINT16)w, j)) // Check if lump is a folder; if not, then count it + numtextures++; + } + } + else // Add all the textures between TX_START and TX_END { numtextures += (UINT32)(texend - texstart); } - - // If no textures found by this point, bomb out - if (!numtextures && w == (numwadfiles - 1)) - { - I_Error("No textures detected in any WADs!\n"); - } } + // If no textures found by this point, bomb out + if (!numtextures) + I_Error("No textures detected in any WADs!\n"); + // Allocate memory and initialize to 0 for all the textures we are initialising. // There are actually 5 buffers allocated in one for convenience. textures = Z_Calloc((numtextures * sizeof(void *)) * 5, PU_STATIC, NULL); + texflats = Z_Calloc((numtextures * sizeof(*texflats)), PU_STATIC, NULL); // Allocate texture column offset table. texturecolumnofs = (void *)((UINT8 *)textures + (numtextures * sizeof(void *))); // Allocate texture referencing cache. texturecache = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 2)); - // Allocate texture width mask table. - texturewidthmask = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3)); - // Allocate texture height mask table. + // Allocate texture width table. + texturewidth = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 3)); + // Allocate texture height table. textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4)); // Create translation table for global animation. texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL); @@ -455,73 +1047,16 @@ void R_LoadTextures(void) for (i = 0, w = 0; w < numwadfiles; w++) { - // Get the lump numbers for the markers in the WAD, if they exist. - if (wadfiles[w]->type == RET_PK3) - { - texstart = W_CheckNumForFolderStartPK3("textures/", (UINT16)w, 0); - texend = W_CheckNumForFolderEndPK3("textures/", (UINT16)w, texstart); - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); - while (texturesLumpPos != INT16_MAX) - { - R_ParseTEXTURESLump(w, texturesLumpPos, &i); - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, texturesLumpPos + 1); - } - } - else - { - texstart = W_CheckNumForNamePwad(TX_START, (UINT16)w, 0) + 1; - texend = W_CheckNumForNamePwad(TX_END, (UINT16)w, 0); - texturesLumpPos = W_CheckNumForNamePwad("TEXTURES", (UINT16)w, 0); - if (texturesLumpPos != INT16_MAX) - R_ParseTEXTURESLump(w, texturesLumpPos, &i); - } - - if (texstart == INT16_MAX || texend == INT16_MAX) - continue; - - // Work through each lump between the markers in the WAD. - for (j = 0; j < (texend - texstart); i++, j++) - { - patchlump = W_CacheLumpNumPwad((UINT16)w, texstart + j, PU_CACHE); - - // Then, check the lump directly to see if it's a texture SOC, - // and if it is, load it using dehacked instead. - if (strstr((const char *)patchlump, "TEXTURE")) - { - CONS_Alert(CONS_WARNING, "%s is a Texture SOC.\n", W_CheckNameForNumPwad((UINT16)w,texstart+j)); - Z_Unlock(patchlump); - DEH_LoadDehackedLumpPwad((UINT16)w, texstart + j); - } - else - { - //CONS_Printf("\n\"%s\" is a single patch, dimensions %d x %d",W_CheckNameForNumPwad((UINT16)w,texstart+j),patchlump->width, patchlump->height); - texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); - - // Set texture properties. - M_Memcpy(texture->name, W_CheckNameForNumPwad((UINT16)w, texstart + j), sizeof(texture->name)); - texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height); - texture->patchcount = 1; - texture->holes = false; - - // Allocate information for the texture's patches. - patch = &texture->patches[0]; - - patch->originx = patch->originy = 0; - patch->wad = (UINT16)w; - patch->lump = texstart + j; - - Z_Unlock(patchlump); - - k = 1; - while (k << 1 <= texture->width) - k <<= 1; - - texturewidthmask[i] = k - 1; - textureheight[i] = texture->height << FRACBITS; - } - } +#ifdef WALLFLATS + i = Rloadflats(i, w); +#endif + i = Rloadtextures(i, w); } + +#ifdef HWRENDER + if (rendermode == render_opengl) + HWR_LoadTextures(numtextures); +#endif } static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) @@ -532,6 +1067,9 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) char *patchName = NULL; INT16 patchXPos; INT16 patchYPos; + UINT8 flip = 0; + UINT8 alpha = 255; + enum patchalphastyle style = AST_COPY; texpatch_t *resultPatch = NULL; lumpnum_t patchLumpNum; @@ -628,6 +1166,68 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) } Z_Free(texturesToken); + // Patch parameters block (OPTIONAL) + // added by Monster Iestyn (22/10/16) + + // Left Curly Brace + texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) + ; // move on and ignore, R_ParseTextures will deal with this + else + { + if (strcmp(texturesToken,"{")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) + { + I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch \"%s\"'s parameters should be",patchName); + } + while (strcmp(texturesToken,"}")!=0) + { + if (stricmp(texturesToken, "ALPHA")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + alpha = 255*strtof(texturesToken, NULL); + } + else if (stricmp(texturesToken, "STYLE")==0) + { + Z_Free(texturesToken); + texturesToken = M_GetToken(NULL); + if (stricmp(texturesToken, "TRANSLUCENT")==0) + style = AST_TRANSLUCENT; + else if (stricmp(texturesToken, "ADD")==0) + style = AST_ADD; + else if (stricmp(texturesToken, "SUBTRACT")==0) + style = AST_SUBTRACT; + else if (stricmp(texturesToken, "REVERSESUBTRACT")==0) + style = AST_REVERSESUBTRACT; + else if (stricmp(texturesToken, "MODULATE")==0) + style = AST_MODULATE; + } + else if (stricmp(texturesToken, "FLIPX")==0) + flip |= 1; + else if (stricmp(texturesToken, "FLIPY")==0) + flip |= 2; + Z_Free(texturesToken); + + texturesToken = M_GetToken(NULL); + if (texturesToken == NULL) + { + I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch \"%s\"'s parameters or right curly brace should be",patchName); + } + } + } + else + { + // this is not what we wanted... + // undo last read so R_ParseTextures can re-get the token for its own purposes + M_UnGetToken(); + } + Z_Free(texturesToken); + } + if (actuallyLoadPatch == true) { // Check lump exists @@ -638,6 +1238,9 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) resultPatch->originy = patchYPos; resultPatch->lump = patchLumpNum & 65535; resultPatch->wad = patchLumpNum>>16; + resultPatch->flip = flip; + resultPatch->alpha = alpha; + resultPatch->style = style; // Clean up a little after ourselves Z_Free(patchName); // Then return it @@ -764,6 +1367,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) M_Memcpy(resultTexture->name, newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; + resultTexture->type = TEXTURETYPE_COMPOSITE; } Z_Free(texturesToken); texturesToken = M_GetToken(NULL); @@ -849,7 +1453,7 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum) texturesToken = M_GetToken(texturesText); while (texturesToken != NULL) { - if (stricmp(texturesToken, "WALLTEXTURE")==0) + if (stricmp(texturesToken, "WALLTEXTURE") == 0 || stricmp(texturesToken, "TEXTURE") == 0) { numTexturesInLump++; Z_Free(texturesToken); @@ -857,7 +1461,7 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum) } else { - I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken); + I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\" or \"TEXTURE\", got \"%s\"",texturesToken); } texturesToken = M_GetToken(NULL); } @@ -898,21 +1502,21 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex) texturesToken = M_GetToken(texturesText); while (texturesToken != NULL) { - if (stricmp(texturesToken, "WALLTEXTURE")==0) + if (stricmp(texturesToken, "WALLTEXTURE") == 0 || stricmp(texturesToken, "TEXTURE") == 0) { Z_Free(texturesToken); // Get the new texture newTexture = R_ParseTexture(true); // Store the new texture textures[*texindex] = newTexture; - texturewidthmask[*texindex] = newTexture->width - 1; + texturewidth[*texindex] = newTexture->width; textureheight[*texindex] = newTexture->height << FRACBITS; // Increment i back in R_LoadTextures() (*texindex)++; } else { - I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken); + I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\" or \"TEXTURE\", got \"%s\"",texturesToken); } texturesToken = M_GetToken(NULL); } @@ -920,6 +1524,10 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex) Z_Free((void *)texturesText); } +#ifdef EXTRACOLORMAPLUMPS +static lumplist_t *colormaplumps = NULL; ///\todo free leak +static size_t numcolormaplumps = 0; + static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list, size_t listsize) { size_t i; @@ -936,9 +1544,6 @@ static inline lumpnum_t R_CheckNumForNameList(const char *name, lumplist_t *list return LUMPERROR; } -static lumplist_t *colormaplumps = NULL; ///\todo free leak -static size_t numcolormaplumps = 0; - static void R_InitExtraColormaps(void) { lumpnum_t startnum, endnum; @@ -971,6 +1576,7 @@ static void R_InitExtraColormaps(void) } CONS_Printf(M_GetText("Number of Extra Colormaps: %s\n"), sizeu1(numcolormaplumps)); } +#endif // Search for flat name. lumpnum_t R_GetFlatNumForName(const char *name) @@ -1017,13 +1623,6 @@ lumpnum_t R_GetFlatNumForName(const char *name) lump = LUMPERROR; } - if (lump == LUMPERROR) - { - if (strcmp(name, SKYFLATNAME)) - CONS_Debug(DBG_SETUP, "R_GetFlatNumForName: Could not find flat %.8s\n", name); - lump = W_CheckNumForName("REDFLR"); - } - return lump; } @@ -1044,43 +1643,147 @@ static void R_InitSpriteLumps(void) Z_Malloc(max_spritelumps*sizeof(*spritecachedinfo), PU_STATIC, &spritecachedinfo); } +// +// R_CreateFadeColormaps +// + +static void R_CreateFadeColormaps(void) +{ + UINT8 px, fade; + RGBA_t rgba; + INT32 r, g, b; + size_t len, i; + + len = (256 * FADECOLORMAPROWS); + fadecolormap = Z_MallocAlign(len*2, PU_STATIC, NULL, 8); + for (i = 0; i < len*2; i++) + fadecolormap[i] = (i%256); + + // Load in the light tables, now 64k aligned for smokie... + { + lumpnum_t lump = W_CheckNumForName("FADECMAP"); + lumpnum_t wlump = W_CheckNumForName("FADEWMAP"); + + // to black + if (lump != LUMPERROR) + W_ReadLumpHeader(lump, fadecolormap, len, 0U); + // to white + if (wlump != LUMPERROR) + W_ReadLumpHeader(wlump, fadecolormap+len, len, 0U); + + // missing "to white" colormap lump + if (lump != LUMPERROR && wlump == LUMPERROR) + goto makewhite; + // missing "to black" colormap lump + else if (lump == LUMPERROR && wlump != LUMPERROR) + goto makeblack; + // both lumps found + else if (lump != LUMPERROR && wlump != LUMPERROR) + return; + } + +#define GETCOLOR \ + px = colormaps[i%256]; \ + fade = (i/256) * (256 / FADECOLORMAPROWS); \ + rgba = V_GetMasterColor(px); + + // to black + makeblack: + for (i = 0; i < len; i++) + { + // find pixel and fade amount + GETCOLOR; + + // subtractive color blending + r = rgba.s.red - FADEREDFACTOR*fade/10; + g = rgba.s.green - FADEGREENFACTOR*fade/10; + b = rgba.s.blue - FADEBLUEFACTOR*fade/10; + + // clamp values + if (r < 0) r = 0; + if (g < 0) g = 0; + if (b < 0) b = 0; + + // find nearest color in palette + fadecolormap[i] = NearestColor(r,g,b); + } + + // to white + makewhite: + for (i = len; i < len*2; i++) + { + // find pixel and fade amount + GETCOLOR; + + // additive color blending + r = rgba.s.red + FADEREDFACTOR*fade/10; + g = rgba.s.green + FADEGREENFACTOR*fade/10; + b = rgba.s.blue + FADEBLUEFACTOR*fade/10; + + // clamp values + if (r > 255) r = 255; + if (g > 255) g = 255; + if (b > 255) b = 255; + + // find nearest color in palette + fadecolormap[i] = NearestColor(r,g,b); + } +#undef GETCOLOR +} + // // R_InitColormaps // static void R_InitColormaps(void) { + size_t len; lumpnum_t lump; // Load in the light tables lump = W_GetNumForName("COLORMAP"); - colormaps = Z_MallocAlign(W_LumpLength (lump), PU_STATIC, NULL, 8); + len = W_LumpLength(lump); + colormaps = Z_MallocAlign(len, PU_STATIC, NULL, 8); W_ReadLump(lump, colormaps); + // Make colormap for fades + R_CreateFadeColormaps(); + // Init Boom colormaps. R_ClearColormaps(); +#ifdef EXTRACOLORMAPLUMPS R_InitExtraColormaps(); +#endif } void R_ReInitColormaps(UINT16 num) { char colormap[9] = "COLORMAP"; lumpnum_t lump; - + const lumpnum_t basecolormaplump = W_GetNumForName(colormap); if (num > 0 && num <= 10000) snprintf(colormap, 8, "CLM%04u", num-1); // Load in the light tables, now 64k aligned for smokie... lump = W_GetNumForName(colormap); if (lump == LUMPERROR) - lump = W_GetNumForName("COLORMAP"); - W_ReadLump(lump, colormaps); + lump = basecolormaplump; + else + { + if (W_LumpLength(lump) != W_LumpLength(basecolormaplump)) + { + CONS_Alert(CONS_WARNING, "%s lump size does not match COLORMAP, results may be unexpected.\n", colormap); + } + } + + W_ReadLumpHeader(lump, colormaps, W_LumpLength(basecolormaplump), 0U); + if (fadecolormap) + Z_Free(fadecolormap); + R_CreateFadeColormaps(); // Init Boom colormaps. R_ClearColormaps(); } -static lumpnum_t foundcolormaps[MAXCOLORMAPS]; - // // R_ClearColormaps // @@ -1088,49 +1791,264 @@ static lumpnum_t foundcolormaps[MAXCOLORMAPS]; // void R_ClearColormaps(void) { - size_t i; - - num_extra_colormaps = 0; - - for (i = 0; i < MAXCOLORMAPS; i++) - foundcolormaps[i] = LUMPERROR; - - memset(extra_colormaps, 0, sizeof (extra_colormaps)); + // Purged by PU_LEVEL, just overwrite the pointer + extra_colormaps = R_CreateDefaultColormap(true); } -INT32 R_ColormapNumForName(char *name) +// +// R_CreateDefaultColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! +// +extracolormap_t *R_CreateDefaultColormap(boolean lighttable) { - lumpnum_t lump, i; + extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + exc->fadestart = 0; + exc->fadeend = 31; + exc->flags = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; + exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL; +#ifdef EXTRACOLORMAPLUMPS + exc->lump = LUMPERROR; + exc->lumpname[0] = 0; +#endif + exc->next = exc->prev = NULL; + return exc; +} - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_ColormapNumForName: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); +// +// R_GetDefaultColormap() +// +extracolormap_t *R_GetDefaultColormap(void) +{ +#ifdef COLORMAPREVERSELIST + extracolormap_t *exc; +#endif + + if (!extra_colormaps) + return (extra_colormaps = R_CreateDefaultColormap(true)); + +#ifdef COLORMAPREVERSELIST + for (exc = extra_colormaps; exc->next; exc = exc->next); + return exc; +#else + return extra_colormaps; +#endif +} + +// +// R_CopyColormap() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! +// +extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable) +{ + extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + if (!extra_colormap) + extra_colormap = R_GetDefaultColormap(); + + *exc = *extra_colormap; + exc->next = exc->prev = NULL; + +#ifdef EXTRACOLORMAPLUMPS + strncpy(exc->lumpname, extra_colormap->lumpname, 9); + + if (exc->lump != LUMPERROR && lighttable) + { + // aligned on 8 bit for asm code + exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); + W_ReadLump(lump, exc->colormap); + } + else +#endif + if (lighttable) + exc->colormap = R_CreateLightTable(exc); + else + exc->colormap = NULL; + + return exc; +} + +// +// R_AddColormapToList +// +// Sets prev/next chain for extra_colormaps var +// Copypasta from P_AddFFloorToList +// +void R_AddColormapToList(extracolormap_t *extra_colormap) +{ +#ifndef COLORMAPREVERSELIST + extracolormap_t *exc; +#endif + + if (!extra_colormaps) + { + extra_colormaps = extra_colormap; + extra_colormap->next = 0; + extra_colormap->prev = 0; + return; + } + +#ifdef COLORMAPREVERSELIST + extra_colormaps->prev = extra_colormap; + extra_colormap->next = extra_colormaps; + extra_colormaps = extra_colormap; + extra_colormap->prev = 0; +#else + for (exc = extra_colormaps; exc->next; exc = exc->next); + + exc->next = extra_colormap; + extra_colormap->prev = exc; + extra_colormap->next = 0; +#endif +} + +// +// R_CheckDefaultColormapByValues() +// +#ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump) +#else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags) +#endif +{ + return ( + (!checkparams ? true : + (fadestart == 0 + && fadeend == 31 + && !flags) + ) + && (!checkrgba ? true : rgba == 0) + && (!checkfadergba ? true : fadergba == 0x19000000) +#ifdef EXTRACOLORMAPLUMPS + && lump == LUMPERROR + && extra_colormap->lumpname[0] == 0 +#endif + ); +} + +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + if (!extra_colormap) + return true; + +#ifdef EXTRACOLORMAPLUMPS + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags, extra_colormap->lump); +#else + return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags); +#endif +} + +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams) +{ + // Treat NULL as default colormap + // We need this because what if one exc is a default colormap, and the other is NULL? They're really both equal. + if (!exc_a) + exc_a = R_GetDefaultColormap(); + if (!exc_b) + exc_b = R_GetDefaultColormap(); + + if (exc_a == exc_b) + return true; + + return ( + (!checkparams ? true : + (exc_a->fadestart == exc_b->fadestart + && exc_a->fadeend == exc_b->fadeend + && exc_a->flags == exc_b->flags) + ) + && (!checkrgba ? true : exc_a->rgba == exc_b->rgba) + && (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba) +#ifdef EXTRACOLORMAPLUMPS + && exc_a->lump == exc_b->lump + && !strncmp(exc_a->lumpname, exc_b->lumpname, 9) +#endif + ); +} + +// +// R_GetColormapFromListByValues() +// NOTE: Returns NULL if no match is found +// +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump) +#else +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags) +#endif +{ + extracolormap_t *exc; + UINT32 dbg_i = 0; + + for (exc = extra_colormaps; exc; exc = exc->next) + { + if (rgba == exc->rgba + && fadergba == exc->fadergba + && fadestart == exc->fadestart + && fadeend == exc->fadeend + && flags == exc->flags +#ifdef EXTRACOLORMAPLUMPS + && (lump != LUMPERROR && lump == exc->lump) +#endif + ) + { + CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + dbg_i, R_GetRgbaR(rgba), R_GetRgbaG(rgba), R_GetRgbaB(rgba), R_GetRgbaA(rgba), + R_GetRgbaR(fadergba), R_GetRgbaG(fadergba), R_GetRgbaB(fadergba), R_GetRgbaA(fadergba)); + return exc; + } + dbg_i++; + } + return NULL; +} + +extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap) +{ +#ifdef EXTRACOLORMAPLUMPS + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags, extra_colormap->lump); +#else + return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->flags); +#endif +} + +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_ColormapForName(char *name) +{ + lumpnum_t lump; + extracolormap_t *exc; lump = R_CheckNumForNameList(name, colormaplumps, numcolormaplumps); if (lump == LUMPERROR) - I_Error("R_ColormapNumForName: Cannot find colormap lump %.8s\n", name); + I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name); - for (i = 0; i < num_extra_colormaps; i++) - if (lump == foundcolormaps[i]) - return i; + exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump); + if (exc) + return exc; - foundcolormaps[num_extra_colormaps] = lump; + exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL); + + exc->lump = lump; + strncpy(exc->lumpname, name, 9); + exc->lumpname[8] = 0; // aligned on 8 bit for asm code - extra_colormaps[num_extra_colormaps].colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); - W_ReadLump(lump, extra_colormaps[num_extra_colormaps].colormap); + exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16); + W_ReadLump(lump, exc->colormap); // We set all params of the colormap to normal because there // is no real way to tell how GL should handle a colormap lump anyway.. - extra_colormaps[num_extra_colormaps].maskcolor = 0xffff; - extra_colormaps[num_extra_colormaps].fadecolor = 0x0; - extra_colormaps[num_extra_colormaps].maskamt = 0x0; - extra_colormaps[num_extra_colormaps].fadestart = 0; - extra_colormaps[num_extra_colormaps].fadeend = 31; - extra_colormaps[num_extra_colormaps].fog = 0; + exc->fadestart = 0; + exc->fadeend = 31; + exc->flags = 0; + exc->rgba = 0; + exc->fadergba = 0x19000000; - num_extra_colormaps++; - return (INT32)num_extra_colormaps - 1; + R_AddColormapToList(exc); + + return exc; } +#endif // // R_CreateColormap @@ -1142,111 +2060,62 @@ INT32 R_ColormapNumForName(char *name) // static double deltas[256][3], map[256][3]; -static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b); static int RoundUp(double number); -INT32 R_CreateColormap(char *p1, char *p2, char *p3) +lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb; double maskamt = 0, othermask = 0; - int mask, fog = 0; - size_t mapnum = num_extra_colormaps; + + UINT8 cr = R_GetRgbaR(extra_colormap->rgba), + cg = R_GetRgbaG(extra_colormap->rgba), + cb = R_GetRgbaB(extra_colormap->rgba), + ca = R_GetRgbaA(extra_colormap->rgba), + cfr = R_GetRgbaR(extra_colormap->fadergba), + cfg = R_GetRgbaG(extra_colormap->fadergba), + cfb = R_GetRgbaB(extra_colormap->fadergba); +// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software + + UINT8 fadestart = extra_colormap->fadestart, + fadedist = extra_colormap->fadeend - extra_colormap->fadestart; + + lighttable_t *lighttable = NULL; size_t i; - UINT32 cr, cg, cb, maskcolor, fadecolor; - UINT32 fadestart = 0, fadeend = 31, fadedist = 31; -#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) - if (p1[0] == '#') - { - cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); - cmaskr = cr; - cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); - cmaskg = cg; - cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); - cmaskb = cb; - // Create a rough approximation of the color (a 16 bit color) - maskcolor = ((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11); - if (p1[7] >= 'a' && p1[7] <= 'z') - mask = (p1[7] - 'a'); - else if (p1[7] >= 'A' && p1[7] <= 'Z') - mask = (p1[7] - 'A'); - else - mask = 24; + ///////////////////// + // Calc the RGBA mask + ///////////////////// + cmaskr = cr; + cmaskg = cg; + cmaskb = cb; - maskamt = (double)(mask/24.0l); + maskamt = (double)(ca/24.0l); + othermask = 1 - maskamt; + maskamt /= 0xff; - othermask = 1 - maskamt; - maskamt /= 0xff; - cmaskr *= maskamt; - cmaskg *= maskamt; - cmaskb *= maskamt; - } - else - { - cmaskr = cmaskg = cmaskb = 0xff; - maskamt = 0; - maskcolor = ((0xff) >> 3) + (((0xff) >> 2) << 5) + (((0xff) >> 3) << 11); - } + cmaskr *= maskamt; + cmaskg *= maskamt; + cmaskb *= maskamt; -#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) - if (p2[0] == '#') - { - // Get parameters like fadestart, fadeend, and the fogflag - fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); - fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); - if (fadestart > 30) - fadestart = 0; - if (fadeend > 31 || fadeend < 1) - fadeend = 31; - fadedist = fadeend - fadestart; - fog = NUMFROMCHAR(p2[1]); - } -#undef NUMFROMCHAR + ///////////////////// + // Calc the RGBA fade mask + ///////////////////// + cdestr = cfr; + cdestg = cfg; + cdestb = cfb; - if (p3[0] == '#') - { - cdestr = cr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); - cdestg = cg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); - cdestb = cb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); - fadecolor = (((cb) >> 3) + (((cg) >> 2) << 5) + (((cr) >> 3) << 11)); - } - else - cdestr = cdestg = cdestb = fadecolor = 0; -#undef HEX2INT + // fade alpha unused in software + // maskamt = (double)(cfa/24.0l); + // othermask = 1 - maskamt; + // maskamt /= 0xff; - for (i = 0; i < num_extra_colormaps; i++) - { - if (foundcolormaps[i] != LUMPERROR) - continue; - if (maskcolor == extra_colormaps[i].maskcolor - && fadecolor == extra_colormaps[i].fadecolor - && fabs(maskamt - extra_colormaps[i].maskamt) < DBL_EPSILON - && fadestart == extra_colormaps[i].fadestart - && fadeend == extra_colormaps[i].fadeend - && fog == extra_colormaps[i].fog) - { - return (INT32)i; - } - } - - if (num_extra_colormaps == MAXCOLORMAPS) - I_Error("R_CreateColormap: Too many colormaps! the limit is %d\n", MAXCOLORMAPS); - - num_extra_colormaps++; - - foundcolormaps[mapnum] = LUMPERROR; - - // aligned on 8 bit for asm code - extra_colormaps[mapnum].colormap = NULL; - extra_colormaps[mapnum].maskcolor = (UINT16)maskcolor; - extra_colormaps[mapnum].fadecolor = (UINT16)fadecolor; - extra_colormaps[mapnum].maskamt = maskamt; - extra_colormaps[mapnum].fadestart = (UINT16)fadestart; - extra_colormaps[mapnum].fadeend = (UINT16)fadeend; - extra_colormaps[mapnum].fog = fog; + // cdestr *= maskamt; + // cdestg *= maskamt; + // cdestb *= maskamt; + ///////////////////// // This code creates the colormap array used by software renderer - if (rendermode == render_soft) + ///////////////////// { double r, g, b, cbrightness; int p; @@ -1259,9 +2128,9 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) // map[i]'s values are decremented by after each use for (i = 0; i < 256; i++) { - r = pLocalPalette[i].s.red; - g = pLocalPalette[i].s.green; - b = pLocalPalette[i].s.blue; + r = pMasterPalette[i].s.red; + g = pMasterPalette[i].s.green; + b = pMasterPalette[i].s.blue; cbrightness = sqrt((r*r) + (g*g) + (b*b)); map[i][0] = (cbrightness * cmaskr) + (r * othermask); @@ -1281,8 +2150,9 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } // Now allocate memory for the actual colormap array itself! + // aligned on 8 bit for asm code colormap_p = Z_MallocAlign((256 * 34) + 10, PU_LEVEL, NULL, 8); - extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p; + lighttable = (UINT8 *)colormap_p; // Calculate the palette index for each palette index, for each light level // (as well as the two unused colormap lines we inherited from Doom) @@ -1317,21 +2187,303 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } } - return (INT32)mapnum; + return lighttable; +} + +extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3) +{ + extracolormap_t *extra_colormap, *exc; + + // default values + UINT8 cr = 0, cg = 0, cb = 0, ca = 0, cfr = 0, cfg = 0, cfb = 0, cfa = 25; + UINT32 fadestart = 0, fadeend = 31; + UINT8 flags = 0; + INT32 rgba = 0, fadergba = 0x19000000; + +#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) +#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) + + // Get base colormap value + // First alpha-only, then full value + if (p1[0] >= 'a' && p1[0] <= 'z' && !p1[1]) + ca = (p1[0] - 'a'); + else if (p1[0] == '#' && p1[1] >= 'a' && p1[1] <= 'z' && !p1[2]) + ca = (p1[1] - 'a'); + else if (p1[0] >= 'A' && p1[0] <= 'Z' && !p1[1]) + ca = (p1[0] - 'A'); + else if (p1[0] == '#' && p1[1] >= 'A' && p1[1] <= 'Z' && !p1[2]) + ca = (p1[1] - 'A'); + else if (p1[0] == '#') + { + // For each subsequent value, the value before it must exist + // If we don't get every value, then set alpha to max + if (p1[1] && p1[2]) + { + cr = ((HEX2INT(p1[1]) * 16) + HEX2INT(p1[2])); + if (p1[3] && p1[4]) + { + cg = ((HEX2INT(p1[3]) * 16) + HEX2INT(p1[4])); + if (p1[5] && p1[6]) + { + cb = ((HEX2INT(p1[5]) * 16) + HEX2INT(p1[6])); + + if (p1[7] >= 'a' && p1[7] <= 'z') + ca = (p1[7] - 'a'); + else if (p1[7] >= 'A' && p1[7] <= 'Z') + ca = (p1[7] - 'A'); + else + ca = 25; + } + else + ca = 25; + } + else + ca = 25; + } + else + ca = 25; + } + +#define NUMFROMCHAR(c) (c >= '0' && c <= '9' ? c - '0' : 0) + + // Get parameters like fadestart, fadeend, and flags + if (p2[0] == '#') + { + if (p2[1]) + { + flags = NUMFROMCHAR(p2[1]); + if (p2[2] && p2[3]) + { + fadestart = NUMFROMCHAR(p2[3]) + (NUMFROMCHAR(p2[2]) * 10); + if (p2[4] && p2[5]) + fadeend = NUMFROMCHAR(p2[5]) + (NUMFROMCHAR(p2[4]) * 10); + } + } + + if (fadestart > 30) + fadestart = 0; + if (fadeend > 31 || fadeend < 1) + fadeend = 31; + } + +#undef NUMFROMCHAR + + // Get fade (dark) colormap value + // First alpha-only, then full value + if (p3[0] >= 'a' && p3[0] <= 'z' && !p3[1]) + cfa = (p3[0] - 'a'); + else if (p3[0] == '#' && p3[1] >= 'a' && p3[1] <= 'z' && !p3[2]) + cfa = (p3[1] - 'a'); + else if (p3[0] >= 'A' && p3[0] <= 'Z' && !p3[1]) + cfa = (p3[0] - 'A'); + else if (p3[0] == '#' && p3[1] >= 'A' && p3[1] <= 'Z' && !p3[2]) + cfa = (p3[1] - 'A'); + else if (p3[0] == '#') + { + // For each subsequent value, the value before it must exist + // If we don't get every value, then set alpha to max + if (p3[1] && p3[2]) + { + cfr = ((HEX2INT(p3[1]) * 16) + HEX2INT(p3[2])); + if (p3[3] && p3[4]) + { + cfg = ((HEX2INT(p3[3]) * 16) + HEX2INT(p3[4])); + if (p3[5] && p3[6]) + { + cfb = ((HEX2INT(p3[5]) * 16) + HEX2INT(p3[6])); + + if (p3[7] >= 'a' && p3[7] <= 'z') + cfa = (p3[7] - 'a'); + else if (p3[7] >= 'A' && p3[7] <= 'Z') + cfa = (p3[7] - 'A'); + else + cfa = 25; + } + else + cfa = 25; + } + else + cfa = 25; + } + else + cfa = 25; + } +#undef ALPHA2INT +#undef HEX2INT + + // Pack rgba values into combined var + // OpenGL also uses this instead of lighttables for rendering + rgba = R_PutRgbaRGBA(cr, cg, cb, ca); + fadergba = R_PutRgbaRGBA(cfr, cfg, cfb, cfa); + + // Did we just make a default colormap? +#ifdef EXTRACOLORMAPLUMPS + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, flags, LUMPERROR)) + return NULL; +#else + if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, flags)) + return NULL; +#endif + + // Look for existing colormaps +#ifdef EXTRACOLORMAPLUMPS + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags, LUMPERROR); +#else + exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, flags); +#endif + if (exc) + return exc; + + CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n", + cr, cg, cb, ca, cfr, cfg, cfb, cfa); + + extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL); + + extra_colormap->fadestart = (UINT16)fadestart; + extra_colormap->fadeend = (UINT16)fadeend; + extra_colormap->flags = flags; + + extra_colormap->rgba = rgba; + extra_colormap->fadergba = fadergba; + +#ifdef EXTRACOLORMAPLUMPS + extra_colormap->lump = LUMPERROR; + extra_colormap->lumpname[0] = 0; +#endif + + // Having lighttables for alpha-only entries is kind of pointless, + // but if there happens to be a matching rgba entry that is NOT alpha-only (but has same rgb values), + // then it needs this lighttable because we share matching entries. + extra_colormap->colormap = R_CreateLightTable(extra_colormap); + + R_AddColormapToList(extra_colormap); + + return extra_colormap; +} + +// +// R_AddColormaps() +// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself! +// +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFlags, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable) +{ + INT16 red, green, blue, alpha; + + // exc_augend is added (or subtracted) onto by exc_addend + // In Rennaisance times, the first number was considered the augend, the second number the addend + // But since the commutative property was discovered, today they're both called addends! + // So let's be Olde English for a hot second. + + exc_augend = R_CopyColormap(exc_augend, false); + if(!exc_addend) + exc_addend = R_GetDefaultColormap(); + + /////////////////// + // base rgba + /////////////////// + + red = max(min( + R_GetRgbaR(exc_augend->rgba) + + (subR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->rgba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->rgba) + + (subG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->rgba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->rgba) + + (subB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->rgba) + , 255), 0); + + alpha = useAltAlpha ? altAlpha : R_GetRgbaA(exc_addend->rgba); + alpha = max(min(R_GetRgbaA(exc_augend->rgba) + (subA ? -1 : 1) * alpha, 25), 0); + + exc_augend->rgba = R_PutRgbaRGBA(red, green, blue, alpha); + + /////////////////// + // fade/dark rgba + /////////////////// + + red = max(min( + R_GetRgbaR(exc_augend->fadergba) + + (subFadeR ? -1 : 1) // subtract R + * R_GetRgbaR(exc_addend->fadergba) + , 255), 0); + + green = max(min( + R_GetRgbaG(exc_augend->fadergba) + + (subFadeG ? -1 : 1) // subtract G + * R_GetRgbaG(exc_addend->fadergba) + , 255), 0); + + blue = max(min( + R_GetRgbaB(exc_augend->fadergba) + + (subFadeB ? -1 : 1) // subtract B + * R_GetRgbaB(exc_addend->fadergba) + , 255), 0); + + alpha = useAltAlpha ? altFadeAlpha : R_GetRgbaA(exc_addend->fadergba); + if (alpha == 25 && !useAltAlpha && !R_GetRgbaRGB(exc_addend->fadergba)) + alpha = 0; // HACK: fadergba A defaults at 25, so don't add anything in this case + alpha = max(min(R_GetRgbaA(exc_augend->fadergba) + (subFadeA ? -1 : 1) * alpha, 25), 0); + + exc_augend->fadergba = R_PutRgbaRGBA(red, green, blue, alpha); + + /////////////////// + // parameters + /////////////////// + + exc_augend->fadestart = max(min( + exc_augend->fadestart + + (subFadeStart ? -1 : 1) // subtract fadestart + * exc_addend->fadestart + , 31), 0); + + exc_augend->fadeend = max(min( + exc_augend->fadeend + + (subFadeEnd ? -1 : 1) // subtract fadeend + * (exc_addend->fadeend == 31 && !exc_addend->fadestart ? 0 : exc_addend->fadeend) + // HACK: fadeend defaults to 31, so don't add anything in this case + , 31), 0); + + if (!ignoreFlags) // overwrite flags with new value + exc_augend->flags = exc_addend->flags; + + /////////////////// + // put it together + /////////////////// + + exc_augend->colormap = lighttable ? R_CreateLightTable(exc_augend) : NULL; + exc_augend->next = exc_augend->prev = NULL; + return exc_augend; } // Thanks to quake2 source! // utils3/qdata/images.c -static UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b) +UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette) { int dr, dg, db; int distortion, bestdistortion = 256 * 256 * 4, bestcolor = 0, i; + // Use master palette if none specified + if (palette == NULL) + palette = pMasterPalette; + for (i = 0; i < 256; i++) { - dr = r - pLocalPalette[i].s.red; - dg = g - pLocalPalette[i].s.green; - db = b - pLocalPalette[i].s.blue; + dr = r - palette[i].s.red; + dg = g - palette[i].s.green; + db = b - palette[i].s.blue; distortion = dr*dr + dg*dg + db*db; if (distortion < bestdistortion) { @@ -1360,20 +2512,18 @@ static int RoundUp(double number) return (int)number; } -const char *R_ColormapNameForNum(INT32 num) +#ifdef EXTRACOLORMAPLUMPS +const char *R_NameForColormap(extracolormap_t *extra_colormap) { - if (num == -1) + if (!extra_colormap) return "NONE"; - if (num < 0 || num > MAXCOLORMAPS) - I_Error("R_ColormapNameForNum: num %d is invalid!\n", num); - - if (foundcolormaps[num] == LUMPERROR) + if (extra_colormap->lump == LUMPERROR) return "INLEVEL"; - return W_CheckNameForNum(foundcolormaps[num]); + return extra_colormap->lumpname; } - +#endif // // build a table for quick conversion from 8bpp to 15bpp @@ -1572,8 +2722,8 @@ void R_PrecacheLevel(void) spritepresent = calloc(numsprites, sizeof (*spritepresent)); if (spritepresent == NULL) I_Error("%s: Out of memory looking up sprites", "R_PrecacheLevel"); - for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) spritepresent[((mobj_t *)th)->sprite] = 1; spritememory = 0; @@ -1585,14 +2735,29 @@ void R_PrecacheLevel(void) for (j = 0; j < sprites[i].numframes; j++) { sf = &sprites[i].spriteframes[j]; - for (k = 0; k < 8; k++) +#define cacheang(a) {\ + lump = sf->lumppat[a];\ + if (devparm)\ + spritememory += W_LumpLength(lump);\ + W_CachePatchNum(lump, PU_PATCH);\ + } + // see R_InitSprites for more about lumppat,lumpid + switch (sf->rotate) { - // see R_InitSprites for more about lumppat,lumpid - lump = sf->lumppat[k]; - if (devparm) - spritememory += W_LumpLength(lump); - W_CachePatchNum(lump, PU_CACHE); + case SRF_SINGLE: + cacheang(0); + break; + case SRF_2D: + cacheang(2); + cacheang(6); + break; + default: + k = (sf->rotate & SRF_3DGE ? 16 : 8); + while (k--) + cacheang(k); + break; } +#undef cacheang } } free(spritepresent); diff --git a/src/r_data.h b/src/r_data.h index 5de51ccd4..78ce35a41 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -16,11 +16,20 @@ #include "r_defs.h" #include "r_state.h" +#include "p_setup.h" // levelflats #ifdef __GNUG__ #pragma interface #endif +// Possible alpha types for a patch. +enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; + +UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); +UINT8 ASTBlendPixel_8bpp(UINT8 background, UINT8 foreground, int style, UINT8 alpha); + +UINT8 NearestColor(UINT8 r, UINT8 g, UINT8 b); + // moved here for r_sky.c (texpatch_t is used) // A single patch from a texture definition, @@ -31,8 +40,22 @@ typedef struct // Block origin (always UL), which has already accounted for the internal origin of the patch. INT16 originx, originy; UINT16 wad, lump; + UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both + UINT8 alpha; // Translucency value + enum patchalphastyle style; } texpatch_t; +// texture type +enum +{ + TEXTURETYPE_UNKNOWN, + TEXTURETYPE_SINGLEPATCH, + TEXTURETYPE_COMPOSITE, +#ifdef WALLFLATS + TEXTURETYPE_FLAT, +#endif +}; + // A maptexturedef_t describes a rectangular texture, // which is composed of one or more mappatch_t structures // that arrange graphic patches. @@ -40,20 +63,27 @@ typedef struct { // Keep name for switch changing, etc. char name[8]; + UINT8 type; // TEXTURETYPE_ INT16 width, height; boolean holes; + UINT8 flip; // 1 = flipx, 2 = flipy, 3 = both // All the patches[patchcount] are drawn back to front into the cached texture. INT16 patchcount; texpatch_t patches[0]; } texture_t; +typedef struct +{ + UINT8 *flat; + INT16 width, height; +} textureflat_t; + // all loaded and prepared textures from the start of the game extern texture_t **textures; +extern textureflat_t *texflats; -// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask -extern INT32 *texturewidthmask; - +extern INT32 *texturewidth; extern fixed_t *textureheight; // needed for texture pegging extern INT16 color8to16[256]; // remap color index to highcolor @@ -61,7 +91,7 @@ extern INT16 *hicolormaps; // remap high colors to high colors.. extern CV_PossibleValue_t Color_cons_t[]; -// Load TEXTURE1/TEXTURE2/PNAMES definitions, create lookup tables +// Load TEXTURES definitions, create lookup tables void R_LoadTextures(void); void R_FlushTextureCache(void); @@ -70,18 +100,18 @@ void R_CheckTextureCache(INT32 tex); // Retrieve column data for span blitting. UINT8 *R_GetColumn(fixed_t tex, INT32 col); - UINT8 *R_GetFlat(lumpnum_t flatnum); // I/O, setting up the stuff. void R_InitData(void); void R_PrecacheLevel(void); +extern size_t flatmemory, spritememory, texturememory; + // Retrieval. // Floor/ceiling opaque texture tiles, // lookup by name. For animation? lumpnum_t R_GetFlatNumForName(const char *name); -#define R_FlatNumForName(x) R_GetFlatNumForName(x) // Called by P_Ticker for switches and animations, // returns the texture number for the texture name. @@ -89,11 +119,60 @@ void R_ClearTextureNumCache(boolean btell); INT32 R_TextureNumForName(const char *name); INT32 R_CheckTextureNumForName(const char *name); +// Extra Colormap lumps (C_START/C_END) are not used anywhere +// Uncomment to enable +//#define EXTRACOLORMAPLUMPS + +// Uncomment to make extra_colormaps order Newest -> Oldest +//#define COLORMAPREVERSELIST + void R_ReInitColormaps(UINT16 num); void R_ClearColormaps(void); -INT32 R_ColormapNumForName(char *name); -INT32 R_CreateColormap(char *p1, char *p2, char *p3); -const char *R_ColormapNameForNum(INT32 num); +extracolormap_t *R_CreateDefaultColormap(boolean lighttable); +extracolormap_t *R_GetDefaultColormap(void); +extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable); +void R_AddColormapToList(extracolormap_t *extra_colormap); + +#ifdef EXTRACOLORMAPLUMPS +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags, lumpnum_t lump); +#else +boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams, + INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags); +extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, UINT8 flags); +#endif +boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams); +boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams); +extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap); + +lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); +extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); +extracolormap_t *R_AddColormaps(extracolormap_t *exc_augend, extracolormap_t *exc_addend, + boolean subR, boolean subG, boolean subB, boolean subA, + boolean subFadeR, boolean subFadeG, boolean subFadeB, boolean subFadeA, + boolean subFadeStart, boolean subFadeEnd, boolean ignoreFlags, + boolean useAltAlpha, INT16 altAlpha, INT16 altFadeAlpha, + boolean lighttable); +#ifdef EXTRACOLORMAPLUMPS +extracolormap_t *R_ColormapForName(char *name); +const char *R_NameForColormap(extracolormap_t *extra_colormap); +#endif + +#define R_GetRgbaR(rgba) (rgba & 0xFF) +#define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF) +#define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF) +#define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF) +#define R_GetRgbaRGB(rgba) (rgba & 0xFFFFFF) +#define R_PutRgbaR(r) (r) +#define R_PutRgbaG(g) (g << 8) +#define R_PutRgbaB(b) (b << 16) +#define R_PutRgbaA(a) (a << 24) +#define R_PutRgbaRGB(r, g, b) (R_PutRgbaR(r) + R_PutRgbaG(g) + R_PutRgbaB(b)) +#define R_PutRgbaRGBA(r, g, b, a) (R_PutRgbaRGB(r, g, b) + R_PutRgbaA(a)) + +UINT8 NearestPaletteColor(UINT8 r, UINT8 g, UINT8 b, RGBA_t *palette); +#define NearestColor(r, g, b) NearestPaletteColor(r, g, b, NULL) extern INT32 numtextures; diff --git a/src/r_defs.h b/src/r_defs.h index 1cb4e0815..e6f1e4e7c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -24,6 +24,10 @@ #include "screen.h" // MAXVIDWIDTH, MAXVIDHEIGHT +#ifdef HWRENDER +#include "m_aatree.h" +#endif + #define POLYOBJECTS // @@ -49,19 +53,29 @@ typedef struct // Could even use more than 32 levels. typedef UINT8 lighttable_t; -// ExtraColormap type. Use for extra_colormaps from now on. -typedef struct -{ - UINT16 maskcolor, fadecolor; - double maskamt; - UINT16 fadestart, fadeend; - INT32 fog; +#define CMF_FADEFULLBRIGHTSPRITES 1 +#define CMF_FOG 4 - // rgba is used in hw mode for colored sector lighting +// ExtraColormap type. Use for extra_colormaps from now on. +typedef struct extracolormap_s +{ + UINT8 fadestart, fadeend; + UINT8 flags; + + // store rgba values in combined bitwise + // also used in OpenGL instead lighttables INT32 rgba; // similar to maskcolor in sw mode INT32 fadergba; // The colour the colourmaps fade to lighttable_t *colormap; + +#ifdef EXTRACOLORMAPLUMPS + lumpnum_t lump; // for colormap lump matching, init to LUMPERROR + char lumpname[9]; // for netsyncing +#endif + + struct extracolormap_s *next; + struct extracolormap_s *prev; } extracolormap_t; // @@ -72,7 +86,9 @@ typedef struct */ typedef struct { - fixed_t x, y, z; + fixed_t x, y; + boolean floorzset, ceilingzset; + fixed_t floorz, ceilingz; } vertex_t; // Forward of linedefs, for sectors. @@ -131,10 +147,10 @@ typedef enum FF_QUICKSAND = 0x1000000, ///< Quicksand! FF_PLATFORM = 0x2000000, ///< You can jump up through this to the top. FF_REVERSEPLATFORM = 0x4000000, ///< A fall-through floor in normal gravity, a platform in reverse gravity. - FF_INTANGABLEFLATS = 0x6000000, ///< Both flats are intangable, but the sides are still solid. - FF_SHATTER = 0x8000000, ///< Used with ::FF_BUSTUP. Thinks everyone's Knuckles. - FF_SPINBUST = 0x10000000, ///< Used with ::FF_BUSTUP. Jump or fall onto it while curled in a ball. - FF_ONLYKNUX = 0x20000000, ///< Used with ::FF_BUSTUP. Only Knuckles can break this rock. + FF_INTANGIBLEFLATS = 0x6000000, ///< Both flats are intangible, but the sides are still solid. + FF_SHATTER = 0x8000000, ///< Used with ::FF_BUSTUP. Bustable on mere touch. + FF_SPINBUST = 0x10000000, ///< Used with ::FF_BUSTUP. Also bustable if you're in your spinning frames. + FF_STRONGBUST = 0x20000000, ///< Used with ::FF_BUSTUP. Only bustable by "strong" characters (Knuckles) and abilities (bouncing, twinspin, melee). FF_RIPPLE = 0x40000000, ///< Ripple the flats FF_COLORMAPONLY = 0x80000000, ///< Only copy the colormap, not the lightlevel FF_GOOWATER = FF_SHATTERBOTTOM, ///< Used with ::FF_SWIMMABLE. Makes thick bouncey goop. @@ -177,6 +193,8 @@ typedef struct ffloor_s // these are saved for netgames, so do not let Lua touch these! ffloortype_e spawnflags; // flags the 3D floor spawned with INT32 spawnalpha; // alpha the 3D floor spawned with + + void *fadingdata; // fading FOF thinker } ffloor_t; @@ -187,7 +205,7 @@ typedef struct lightlist_s { fixed_t height; INT16 *lightlevel; - extracolormap_t *extra_colormap; + extracolormap_t **extra_colormap; // pointer-to-a-pointer, so we can react to colormap changes INT32 flags; ffloor_t *caster; #ifdef ESLOPE @@ -228,55 +246,41 @@ typedef struct linechain_s // Slopes #ifdef ESLOPE typedef enum { - SL_NOPHYSICS = 1, // Don't do momentum adjustment with this slope - SL_NODYNAMIC = 1<<1, // Slope will never need to move during the level, so don't fuss with recalculating it - SL_ANCHORVERTEX = 1<<2, // Slope is using a Slope Vertex Thing to anchor its position - SL_VERTEXSLOPE = 1<<3, // Slope is built from three Slope Vertex Things + SL_NOPHYSICS = 1, /// This plane will have no physics applied besides the positioning. + SL_DYNAMIC = 1<<1, /// This plane slope will be assigned a thinker to make it dynamic. } slopeflags_t; typedef struct pslope_s { UINT16 id; // The number of the slope, mostly used for netgame syncing purposes + struct pslope_s *next; // Make a linked list of dynamic slopes, for easy reference later - // --- Information used in clipping/projection --- - // Origin vector for the plane - vector3_t o; + // The plane's definition. + vector3_t o; /// Plane origin. + vector3_t normal; /// Plane normal. - // 2-Dimentional vector (x, y) normalized. Used to determine distance from - // the origin in 2d mapspace. (Basically a thrust of FRACUNIT in xydirection angle) - vector2_t d; - - // The rate at which z changes based on distance from the origin plane. - fixed_t zdelta; - - // The normal of the slope; will always point upward, and thus be inverted on ceilings. I think it's only needed for physics? -Red - vector3_t normal; - - // For comparing when a slope should be rendered - fixed_t lowz; - fixed_t highz; + vector2_t d; /// Precomputed normalized projection of the normal over XY. + fixed_t zdelta; /// Precomputed Z unit increase per XY unit. // This values only check and must be updated if the slope itself is modified - angle_t zangle; // Angle of the plane going up from the ground (not mesured in degrees) - angle_t xydirection; // The direction the slope is facing (north, west, south, etc.) - - struct line_s *sourceline; // The line that generated the slope - fixed_t extent; // Distance value used for recalculating zdelta - UINT8 refpos; // 1=front floor 2=front ceiling 3=back floor 4=back ceiling (used for dynamic sloping) + angle_t zangle; /// Precomputed angle of the plane going up from the ground (not measured in degrees). + angle_t xydirection;/// Precomputed angle of the normal's projection on the XY plane. UINT8 flags; // Slope options - mapthing_t **vertices; // List should be three long for slopes made by vertex things, or one long for slopes using one vertex thing to anchor - - struct pslope_s *next; // Make a linked list of dynamic slopes, for easy reference later } pslope_t; #endif typedef enum { - SF_FLIPSPECIAL_FLOOR = 1, - SF_FLIPSPECIAL_CEILING = 2, - SF_FLIPSPECIAL_BOTH = 3, - SF_TRIGGERSPECIAL_TOUCH = 4, + // flipspecial - planes with effect + SF_FLIPSPECIAL_FLOOR = 1, + SF_FLIPSPECIAL_CEILING = 1<<1, + SF_FLIPSPECIAL_BOTH = (SF_FLIPSPECIAL_FLOOR|SF_FLIPSPECIAL_CEILING), + // triggerspecial - conditions under which plane touch causes effect + SF_TRIGGERSPECIAL_TOUCH = 1<<2, + SF_TRIGGERSPECIAL_HEADBUMP = 1<<3, + // invertprecip - inverts presence of precipitation + SF_INVERTPRECIP = 1<<4, } sectorflags_t; // @@ -308,6 +312,7 @@ typedef struct sector_s void *floordata; // floor move thinker void *ceilingdata; // ceiling move thinker void *lightingdata; // lighting change thinker + void *fadecolormapdata; // fade colormap thinker // floor and ceiling texture offsets fixed_t floor_xoffs, floor_yoffs; @@ -323,8 +328,6 @@ typedef struct sector_s INT32 floorlightsec, ceilinglightsec; INT32 crumblestate; // used for crumbling and bobbing - INT32 bottommap, midmap, topmap; // dynamic colormaps - // list of mobjs that are at least partially in the sector // thinglist is a subset of touching_thinglist struct msecnode_s *touching_thinglist; @@ -383,16 +386,11 @@ typedef struct sector_s boolean hasslope; // The sector, or one of its visible FOFs, contains a slope #endif - // these are saved for netgames, so do not let Lua touch these! - INT32 spawn_nexttag, spawn_firsttag; // the actual nexttag/firsttag values may differ if the sector's tag was changed + // for fade thinker + INT16 spawn_lightlevel; - // offsets sector spawned with (via linedef type 7) - fixed_t spawn_flr_xoffs, spawn_flr_yoffs; - fixed_t spawn_ceil_xoffs, spawn_ceil_yoffs; - - // flag angles sector spawned with (via linedef type 7) - angle_t spawn_flrpic_angle; - angle_t spawn_ceilpic_angle; + // colormap structure + extracolormap_t *spawn_extra_colormap; } sector_t; // @@ -406,6 +404,8 @@ typedef enum ST_NEGATIVE } slopetype_t; +#define HORIZONSPECIAL 41 + typedef struct line_s { // Vertices, from v1 to v2. @@ -441,14 +441,10 @@ typedef struct line_s polyobj_t *polyobj; // Belongs to a polyobject? #endif - char *text; // a concatination of all front and back texture names, for linedef specials that require a string. + char *text; // a concatenation of all front and back texture names, for linedef specials that require a string. INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0 } line_t; -// -// The SideDef. -// - typedef struct { // add this to the calculated texture column @@ -461,13 +457,18 @@ typedef struct // We do not maintain names here. INT32 toptexture, bottomtexture, midtexture; - // Sector the SideDef is facing. + // Linedef the sidedef belongs to + line_t *line; + + // Sector the sidedef is facing. sector_t *sector; INT16 special; // the special of the linedef this side belongs to INT16 repeatcnt; // # of times to repeat midtexture - char *text; // a concatination of all top, bottom, and mid texture names, for linedef specials that require a string. + char *text; // a concatenation of all top, bottom, and mid texture names, for linedef specials that require a string. + + extracolormap_t *colormap_data; // storage for colormaps; not applied to sectors. } side_t; // @@ -590,6 +591,7 @@ typedef struct seg_s polyobj_t *polyseg; boolean dontrenderme; #endif + boolean glseg; } seg_t; // @@ -689,7 +691,7 @@ typedef enum // Patches. // A patch holds one or more columns. // Patches are used for sprites and all masked pictures, and we compose -// textures from the TEXTURE1 list of patches. +// textures from the TEXTURES list of patches. // // WARNING: this structure is cloned in GLPatch_t typedef struct @@ -726,30 +728,76 @@ typedef struct #pragma pack() #endif +// rotsprite +#ifdef ROTSPRITE +typedef struct +{ + patch_t *patch[16][ROTANGLES]; + UINT16 cached; +} rotsprite_t; +#endif/*ROTSPRITE*/ + +typedef enum +{ + SRF_SINGLE = 0, // 0-angle for all rotations + SRF_3D = 1, // Angles 1-8 + SRF_3DGE = 2, // 3DGE, ZDoom and Doom Legacy all have 16-angle support. Why not us? + SRF_3DMASK = SRF_3D|SRF_3DGE, // 3 + SRF_LEFT = 4, // Left side uses single patch + SRF_RIGHT = 8, // Right side uses single patch + SRF_2D = SRF_LEFT|SRF_RIGHT, // 12 + SRF_NONE = 0xff // Initial value +} spriterotateflags_t; // SRF's up! + +// Same as a patch_t, except just the header +// and the wadnum/lumpnum combination that points +// to wherever the patch is in memory. +struct patchinfo_s +{ + INT16 width; // bounding box size + INT16 height; + INT16 leftoffset; // pixels to the left of origin + INT16 topoffset; // pixels below the origin + + UINT16 wadnum; // the software patch lump num for when the patch + UINT16 lumpnum; // was flushed, and we need to re-create it + + // next patchinfo_t in memory + struct patchinfo_s *next; +}; +typedef struct patchinfo_s patchinfo_t; + // // Sprites are patches with a special naming convention so they can be // recognized by R_InitSprites. // The base name is NNNNFx or NNNNFxFx, with x indicating the rotation, -// x = 0, 1-7. +// x = 0, 1-8, 9+A-G, L/R // The sprite and frame specified by a thing_t is range checked at run time. // A sprite is a patch_t that is assumed to represent a three dimensional // object and may have multiple rotations predrawn. // Horizontal flipping is used to save space, thus NNNNF2F5 defines a mirrored patch. // Some sprites will only have one picture used for all views: NNNNF0 +// Some sprites will take the entirety of the left side: NNNNFL +// Or the right side: NNNNFR +// Or both, mirrored: NNNNFLFR // typedef struct { // If false use 0 for any position. // Note: as eight entries are available, we might as well insert the same // name eight times. - UINT8 rotate; + UINT8 rotate; // see spriterotateflags_t above - // Lump to use for view angles 0-7. - lumpnum_t lumppat[8]; // lump number 16 : 16 wad : lump - size_t lumpid[8]; // id in the spriteoffset, spritewidth, etc. tables + // Lump to use for view angles 0-7/15. + lumpnum_t lumppat[16]; // lump number 16 : 16 wad : lump + size_t lumpid[16]; // id in the spriteoffset, spritewidth, etc. tables - // Flip bits (1 = flip) to use for view angles 0-7. - UINT8 flip; + // Flip bits (1 = flip) to use for view angles 0-7/15. + UINT16 flip; + +#ifdef ROTSPRITE + rotsprite_t rotsprite; +#endif } spriteframe_t; // diff --git a/src/r_draw.c b/src/r_draw.c index bbc9a79b0..f46f4fb13 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -99,13 +99,16 @@ INT32 dc_numlights = 0, dc_maxlights, dc_texheight; INT32 ds_y, ds_x1, ds_x2; lighttable_t *ds_colormap; fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; +UINT16 ds_flatwidth, ds_flatheight; +boolean ds_powersoftwo; UINT8 *ds_source; // start of a 64*64 tile image UINT8 *ds_transmap; // one of the translucency tables #ifdef ESLOPE pslope_t *ds_slope; // Current slope being used -floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff? +floatv3_t ds_su[MAXVIDHEIGHT], ds_sv[MAXVIDHEIGHT], ds_sz[MAXVIDHEIGHT]; // Vectors for... stuff? +floatv3_t *ds_sup, *ds_svp, *ds_szp; float focallengthf, zeroheight; #endif @@ -126,73 +129,324 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; #define BOSS_TT_CACHE_INDEX (MAXSKINS + 1) #define METALSONIC_TT_CACHE_INDEX (MAXSKINS + 2) #define ALLWHITE_TT_CACHE_INDEX (MAXSKINS + 3) -#define SKIN_RAMP_LENGTH 16 -#define DEFAULT_STARTTRANSCOLOR 160 +#define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4) +#define BLINK_TT_CACHE_INDEX (MAXSKINS + 5) +#define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6) +#define DEFAULT_STARTTRANSCOLOR 96 #define NUM_PALETTE_ENTRIES 256 -static UINT8** translationtablecache[MAXSKINS + 4] = {NULL}; +static UINT8** translationtablecache[MAXSKINS + 7] = {NULL}; +const UINT8 Color_Index[MAXTRANSLATIONS-1][16] = { + // {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // SKINCOLOR_NONE + + // Greyscale ranges + {0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x11}, // SKINCOLOR_WHITE + {0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x11, 0x12}, // SKINCOLOR_BONE + {0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14}, // SKINCOLOR_CLOUDY + {0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18}, // SKINCOLOR_GREY + {0x02, 0x03, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13, 0x15, 0x17, 0x19, 0x1b, 0x1d, 0x1f}, // SKINCOLOR_SILVER + {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x16, 0x17, 0x17, 0x19, 0x19, 0x1a, 0x1a, 0x1b, 0x1c, 0x1d}, // SKINCOLOR_CARBON + {0x00, 0x05, 0x0a, 0x0f, 0x14, 0x19, 0x1a, 0x1b, 0x1c, 0x1e, 0x1e, 0x1e, 0x1f, 0x1f, 0x1f, 0x1f}, // SKINCOLOR_JET + {0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1b, 0x1b, 0x1c, 0x1d, 0x1d, 0x1e, 0x1e, 0x1f, 0x1f}, // SKINCOLOR_BLACK + + // Desaturated + {0x00, 0x00, 0x01, 0x02, 0x02, 0x03, 0x91, 0x91, 0x91, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xaf}, // SKINCOLOR_AETHER + {0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0xaa, 0xaa, 0xaa, 0xab, 0xac, 0xac, 0xad, 0xad, 0xae, 0xaf}, // SKINCOLOR_SLATE + {0x90, 0x91, 0x92, 0x93, 0x94, 0x94, 0x95, 0xac, 0xac, 0xad, 0xad, 0xa8, 0xa8, 0xa9, 0xfd, 0xfe}, // SKINCOLOR_BLUEBELL + {0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0xd3, 0xd3, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0x2b, 0x2c, 0x2e}, // SKINCOLOR_PINK + {0xd0, 0x30, 0xd8, 0xd9, 0xda, 0xdb, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe3, 0xe6, 0xe8, 0xe9}, // SKINCOLOR_YOGURT + {0xdf, 0xe0, 0xe1, 0xe2, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef}, // SKINCOLOR_BROWN + {0xde, 0xe0, 0xe1, 0xe4, 0xe7, 0xe9, 0xeb, 0xec, 0xed, 0xed, 0xed, 0x19, 0x19, 0x1b, 0x1d, 0x1e}, // SKINCOLOR_BRONZE + {0x51, 0x51, 0x54, 0x54, 0x55, 0x55, 0x56, 0x56, 0x56, 0x57, 0xf5, 0xf5, 0xf9, 0xf9, 0xed, 0xed}, // SKINCOLOR_TAN + {0x54, 0x55, 0x56, 0x56, 0xf2, 0xf3, 0xf3, 0xf4, 0xf5, 0xf6, 0xf8, 0xf9, 0xfa, 0xfb, 0xed, 0xed}, // SKINCOLOR_BEIGE + {0x58, 0x58, 0x59, 0x59, 0x5a, 0x5a, 0x5b, 0x5b, 0x5b, 0x5c, 0x5d, 0x5d, 0x5e, 0x5e, 0x5f, 0x5f}, // SKINCOLOR_MOSS + {0x90, 0x90, 0x91, 0x91, 0xaa, 0xaa, 0xab, 0xab, 0xab, 0xac, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf}, // SKINCOLOR_AZURE + {0xc0, 0xc0, 0xc1, 0xc1, 0xc2, 0xc2, 0xc3, 0xc3, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7}, // SKINCOLOR_LAVENDER + + // Viv's vivid colours (toast 21/07/17) + {0xb0, 0xb0, 0xc9, 0xca, 0xcc, 0x26, 0x27, 0x28, 0x29, 0x2a, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfd}, // SKINCOLOR_RUBY + {0xd0, 0xd0, 0xd1, 0xd2, 0x20, 0x21, 0x24, 0x25, 0x26, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e}, // SKINCOLOR_SALMON + {0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x47, 0x2e, 0x2f}, // SKINCOLOR_RED + {0x27, 0x27, 0x28, 0x28, 0x29, 0x2a, 0x2b, 0x2b, 0x2c, 0x2d, 0x2e, 0x2e, 0x2e, 0x2f, 0x2f, 0x1f}, // SKINCOLOR_CRIMSON + {0x31, 0x32, 0x33, 0x36, 0x22, 0x22, 0x25, 0x25, 0x25, 0xcd, 0xcf, 0xcf, 0xc5, 0xc5, 0xc7, 0xc7}, // SKINCOLOR_FLAME + {0x48, 0x49, 0x40, 0x33, 0x34, 0x36, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2b, 0x2c, 0x47, 0x2e, 0x2f}, // SKINCOLOR_KETCHUP + {0xd0, 0x30, 0x31, 0x31, 0x32, 0x32, 0xdc, 0xdc, 0xdc, 0xd3, 0xd4, 0xd4, 0xcc, 0xcd, 0xce, 0xcf}, // SKINCOLOR_PEACHY + {0xd8, 0xd9, 0xdb, 0xdc, 0xde, 0xdf, 0xd5, 0xd5, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0x1d, 0x1f}, // SKINCOLOR_QUAIL + {0x51, 0x52, 0x40, 0x40, 0x34, 0x36, 0xd5, 0xd5, 0xd6, 0xd7, 0xcf, 0xcf, 0xc6, 0xc6, 0xc7, 0xfe}, // SKINCOLOR_SUNSET + {0x58, 0x54, 0x40, 0x34, 0x35, 0x38, 0x3a, 0x3c, 0x3d, 0x2a, 0x2b, 0x2c, 0x2c, 0xba, 0xba, 0xbb}, // SKINCOLOR_COPPER + {0x00, 0xd8, 0xd9, 0xda, 0xdb, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e}, // SKINCOLOR_APRICOT + {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x2c}, // SKINCOLOR_ORANGE + {0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3c, 0x3d, 0x3d, 0x3d, 0x3f, 0x2c, 0x2d, 0x47, 0x2e, 0x2f, 0x2f}, // SKINCOLOR_RUST + {0x51, 0x51, 0x54, 0x54, 0x41, 0x42, 0x43, 0x43, 0x44, 0x45, 0x46, 0x3f, 0x2d, 0x2e, 0x2f, 0x2f}, // SKINCOLOR_GOLD + {0x53, 0x40, 0x41, 0x42, 0x43, 0xe6, 0xe9, 0xe9, 0xea, 0xec, 0xec, 0xc6, 0xc6, 0xc7, 0xc7, 0xfe}, // SKINCOLOR_SANDY + {0x52, 0x53, 0x49, 0x49, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4c, 0x4d, 0x4d, 0x4e, 0x4e, 0x4f, 0xed}, // SKINCOLOR_YELLOW + {0x4b, 0x4b, 0x4c, 0x4c, 0x4d, 0x4e, 0xe7, 0xe7, 0xe9, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7, 0xfd}, // SKINCOLOR_OLIVE + {0x50, 0x51, 0x52, 0x53, 0x48, 0xbc, 0xbd, 0xbe, 0xbe, 0xbf, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f}, // SKINCOLOR_LIME + {0x58, 0x58, 0xbc, 0xbc, 0xbd, 0xbd, 0xbe, 0xbe, 0xbe, 0xbf, 0x5e, 0x5e, 0x5f, 0x5f, 0x77, 0x77}, // SKINCOLOR_PERIDOT + {0x49, 0x49, 0xbc, 0xbd, 0xbe, 0xbe, 0xbe, 0x67, 0x69, 0x6a, 0x6b, 0x6b, 0x6c, 0x6d, 0x6d, 0x6d}, // SKINCOLOR_APPLE + {0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f}, // SKINCOLOR_GREEN + {0x65, 0x66, 0x67, 0x68, 0x69, 0x69, 0x6a, 0x6b, 0x6b, 0x6c, 0x6d, 0x6d, 0x6e, 0x6e, 0x6e, 0x6f}, // SKINCOLOR_FOREST + {0x70, 0x70, 0x71, 0x71, 0x72, 0x72, 0x73, 0x73, 0x73, 0x74, 0x75, 0x75, 0x76, 0x76, 0x77, 0x77}, // SKINCOLOR_EMERALD + {0x00, 0x00, 0x58, 0x58, 0x59, 0x62, 0x62, 0x62, 0x64, 0x67, 0x7e, 0x7e, 0x8f, 0x8f, 0x8a, 0x8a}, // SKINCOLOR_MINT + {0x01, 0x58, 0x59, 0x5a, 0x7d, 0x7d, 0x7e, 0x7e, 0x7e, 0x8f, 0x8f, 0x8a, 0x8a, 0x8a, 0xfd, 0xfd}, // SKINCOLOR_SEAFOAM + {0x78, 0x79, 0x7a, 0x7a, 0x7b, 0x7b, 0x7c, 0x7c, 0x7c, 0x7d, 0x7e, 0x7e, 0x7f, 0x7f, 0x76, 0x77}, // SKINCOLOR_AQUA + {0x78, 0x78, 0x8c, 0x8c, 0x8d, 0x8d, 0x8d, 0x8e, 0x8e, 0x8f, 0x8f, 0x8f, 0x8a, 0x8a, 0x8a, 0x8a}, // SKINCOLOR_TEAL + {0x00, 0x78, 0x78, 0x79, 0x8d, 0x87, 0x88, 0x89, 0x89, 0xae, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfd}, // SKINCOLOR_WAVE + {0x80, 0x81, 0xff, 0xff, 0x83, 0x83, 0x8d, 0x8d, 0x8d, 0x8e, 0x7e, 0x7f, 0x76, 0x76, 0x77, 0x6e}, // SKINCOLOR_CYAN + {0x80, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x85, 0x85, 0x86, 0x87, 0x88, 0x89, 0x89, 0x8a, 0x8b}, // SKINCOLOR_SKY + {0x85, 0x86, 0x87, 0x88, 0x88, 0x89, 0x89, 0x89, 0x8a, 0x8a, 0xfd, 0xfd, 0xfd, 0x1f, 0x1f, 0x1f}, // SKINCOLOR_CERULEAN + {0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x83, 0x83, 0x86, 0x87, 0x95, 0x95, 0xad, 0xad, 0xae, 0xaf}, // SKINCOLOR_ICY + {0x80, 0x83, 0x86, 0x87, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe}, // SKINCOLOR_SAPPHIRE + {0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x9a, 0x9c, 0x9d, 0x9d, 0x9e, 0x9e, 0x9e}, // SKINCOLOR_CORNFLOWER + {0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe}, // SKINCOLOR_BLUE + {0x93, 0x94, 0x95, 0x96, 0x98, 0x9a, 0x9b, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfd, 0xfe, 0xfe}, // SKINCOLOR_COBALT + {0x80, 0x81, 0x83, 0x86, 0x94, 0x94, 0xa3, 0xa3, 0xa4, 0xa6, 0xa6, 0xa6, 0xa8, 0xa8, 0xa9, 0xa9}, // SKINCOLOR_VAPOR + {0x92, 0x93, 0x94, 0x94, 0xac, 0xad, 0xad, 0xad, 0xae, 0xae, 0xaf, 0xaf, 0xa9, 0xa9, 0xfd, 0xfd}, // SKINCOLOR_DUSK + {0x90, 0x90, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, // SKINCOLOR_PASTEL + {0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa5, 0xa6, 0xa7, 0xa7, 0xa8, 0xa8, 0xa9, 0xa9}, // SKINCOLOR_PURPLE + {0x00, 0xd0, 0xd0, 0xc8, 0xc8, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8}, // SKINCOLOR_BUBBLEGUM + {0xb3, 0xb3, 0xb4, 0xb5, 0xb6, 0xb6, 0xb7, 0xb7, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb}, // SKINCOLOR_MAGENTA + {0xb3, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xbb, 0xc7, 0xc7, 0x1d, 0x1d, 0x1e}, // SKINCOLOR_NEON + {0xd0, 0xd1, 0xd2, 0xca, 0xcc, 0xb8, 0xb9, 0xb9, 0xba, 0xa8, 0xa8, 0xa9, 0xa9, 0xfd, 0xfe, 0xfe}, // SKINCOLOR_VIOLET + {0x00, 0xd0, 0xd1, 0xd2, 0xd3, 0xc1, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xfe, 0x1f}, // SKINCOLOR_LILAC + {0xc8, 0xd3, 0xd5, 0xd6, 0xd7, 0xce, 0xcf, 0xb9, 0xb9, 0xba, 0xba, 0xa9, 0xa9, 0xa9, 0xfd, 0xfe}, // SKINCOLOR_PLUM + {0xc8, 0xc9, 0xca, 0xcb, 0xcb, 0xcc, 0xcd, 0xcd, 0xce, 0xb9, 0xb9, 0xba, 0xba, 0xbb, 0xfe, 0xfe}, // SKINCOLOR_RASPBERRY + {0xfc, 0xc8, 0xc8, 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, 0xcd, 0xcd, 0xce, 0xce, 0xcf}, // SKINCOLOR_ROSY + + // {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, // SKINCOLOR_? + + // super + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03}, // SKINCOLOR_SUPERSILVER1 + {0x00, 0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07}, // SKINCOLOR_SUPERSILVER2 + {0x01, 0x02, 0x02, 0x03, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b}, // SKINCOLOR_SUPERSILVER3 + {0x02, 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11}, // SKINCOLOR_SUPERSILVER4 + {0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x0d, 0x0f, 0x11, 0x13}, // SKINCOLOR_SUPERSILVER5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2}, // SKINCOLOR_SUPERRED1 + {0x00, 0x00, 0x00, 0xd0, 0xd0, 0xd0, 0xd1, 0xd1, 0xd1, 0xd2, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21}, // SKINCOLOR_SUPERRED2 + {0x00, 0x00, 0xd0, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23}, // SKINCOLOR_SUPERRED3 + {0x00, 0xd0, 0xd1, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24}, // SKINCOLOR_SUPERRED4 + {0xd0, 0xd1, 0xd2, 0xd2, 0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23, 0x24, 0x24, 0x25, 0x25}, // SKINCOLOR_SUPERRED5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd0, 0x30, 0x31, 0x32, 0x33, 0x34}, // SKINCOLOR_SUPERORANGE1 + {0x00, 0x00, 0x00, 0x00, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34}, // SKINCOLOR_SUPERORANGE2 + {0x00, 0x00, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35}, // SKINCOLOR_SUPERORANGE3 + {0x00, 0xd0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x44, 0x45, 0x46}, // SKINCOLOR_SUPERORANGE4 + {0xd0, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x44, 0x45, 0x46, 0x47}, // SKINCOLOR_SUPERORANGE5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x51, 0x52, 0x53, 0x48}, // SKINCOLOR_SUPERGOLD1 + {0x00, 0x50, 0x51, 0x52, 0x53, 0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41}, // SKINCOLOR_SUPERGOLD2 + {0x51, 0x52, 0x53, 0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43}, // SKINCOLOR_SUPERGOLD3 + {0x53, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46}, // SKINCOLOR_SUPERGOLD4 + {0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47}, // SKINCOLOR_SUPERGOLD5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x58, 0x58, 0xbc, 0xbc, 0xbc}, // SKINCOLOR_SUPERPERIDOT1 + {0x00, 0x58, 0x58, 0x58, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe}, // SKINCOLOR_SUPERPERIDOT2 + {0x58, 0x58, 0xbc, 0xbc, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf}, // SKINCOLOR_SUPERPERIDOT3 + {0x58, 0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0x5e, 0x5e, 0x5f}, // SKINCOLOR_SUPERPERIDOT4 + {0xbc, 0xbc, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, 0xbf, 0x5e, 0x5e, 0x5f, 0x77}, // SKINCOLOR_SUPERPERIDOT5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x81, 0x82, 0x83, 0x84}, // SKINCOLOR_SUPERSKY1 + {0x00, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86}, // SKINCOLOR_SUPERSKY2 + {0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87}, // SKINCOLOR_SUPERSKY3 + {0x83, 0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8a}, // SKINCOLOR_SUPERSKY4 + {0x84, 0x84, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x86, 0x86, 0x87, 0x87, 0x88, 0x89, 0x8a, 0x8b}, // SKINCOLOR_SUPERSKY5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90, 0xa0, 0xa0, 0xa1, 0xa2}, // SKINCOLOR_SUPERPURPLE1 + {0x00, 0x90, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5}, // SKINCOLOR_SUPERPURPLE2 + {0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6}, // SKINCOLOR_SUPERPURPLE3 + {0xa1, 0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa9}, // SKINCOLOR_SUPERPURPLE4 + {0xa2, 0xa2, 0xa3, 0xa3, 0xa3, 0xa3, 0xa4, 0xa4, 0xa5, 0xa5, 0xa6, 0xa6, 0xa7, 0xa8, 0xa9, 0xfd}, // SKINCOLOR_SUPERPURPLE5 + + {0x00, 0xd0, 0xd0, 0xd0, 0x30, 0x30, 0x31, 0x32, 0x33, 0x37, 0x3a, 0x44, 0x45, 0x46, 0x47, 0x2e}, // SKINCOLOR_SUPERRUST1 + {0x30, 0x31, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38, 0x3a, 0x44, 0x45, 0x46, 0x47, 0x47, 0x2e}, // SKINCOLOR_SUPERRUST2 + {0x31, 0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x3a, 0x44, 0x45, 0x45, 0x46, 0x46, 0x47, 0x2e, 0x2e}, // SKINCOLOR_SUPERRUST3 + {0x48, 0x40, 0x41, 0x42, 0x43, 0x44, 0x44, 0x45, 0x45, 0x46, 0x46, 0x47, 0x47, 0x2e, 0x2e, 0x2e}, // SKINCOLOR_SUPERRUST4 + {0x41, 0x42, 0x43, 0x43, 0x44, 0x44, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xed, 0xee, 0xee, 0xef, 0xef}, // SKINCOLOR_SUPERRUST5 + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52}, // SKINCOLOR_SUPERTAN1 + {0x00, 0x50, 0x50, 0x51, 0x51, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5}, // SKINCOLOR_SUPERTAN2 + {0x50, 0x51, 0x51, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9}, // SKINCOLOR_SUPERTAN3 + {0x51, 0x52, 0x52, 0x52, 0x52, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9, 0xfb, 0xed}, // SKINCOLOR_SUPERTAN4 + {0x52, 0x52, 0x54, 0x54, 0x54, 0x55, 0x56, 0x57, 0xf5, 0xf7, 0xf9, 0xfb, 0xed, 0xee, 0xef, 0xef} // SKINCOLOR_SUPERTAN5 +}; // See also the enum skincolors_t // TODO Callum: Can this be translated? -const char *Color_Names[MAXSKINCOLORS] = +const char *Color_Names[MAXSKINCOLORS + NUMSUPERCOLORS] = { - "None", // SKINCOLOR_NONE - "White", // SKINCOLOR_WHITE - "Silver", // SKINCOLOR_SILVER - "Grey", // SKINCOLOR_GREY - "Black", // SKINCOLOR_BLACK - "Cyan", // SKINCOLOR_CYAN - "Teal", // SKINCOLOR_TEAL - "Steel_Blue",// SKINCOLOR_STEELBLUE - "Blue", // SKINCOLOR_BLUE - "Peach", // SKINCOLOR_PEACH - "Tan", // SKINCOLOR_TAN - "Pink", // SKINCOLOR_PINK - "Lavender", // SKINCOLOR_LAVENDER - "Purple", // SKINCOLOR_PURPLE - "Orange", // SKINCOLOR_ORANGE - "Rosewood", // SKINCOLOR_ROSEWOOD - "Beige", // SKINCOLOR_BEIGE - "Brown", // SKINCOLOR_BROWN - "Red", // SKINCOLOR_RED - "Dark_Red", // SKINCOLOR_DARKRED - "Neon_Green",// SKINCOLOR_NEONGREEN - "Green", // SKINCOLOR_GREEN - "Zim", // SKINCOLOR_ZIM - "Olive", // SKINCOLOR_OLIVE - "Yellow", // SKINCOLOR_YELLOW - "Gold" // SKINCOLOR_GOLD + "None", // SKINCOLOR_NONE, + + // Greyscale ranges + "White", // SKINCOLOR_WHITE, + "Bone", // SKINCOLOR_BONE, + "Cloudy", // SKINCOLOR_CLOUDY, + "Grey", // SKINCOLOR_GREY, + "Silver", // SKINCOLOR_SILVER, + "Carbon", // SKINCOLOR_CARBON, + "Jet", // SKINCOLOR_JET, + "Black", // SKINCOLOR_BLACK, + + // Desaturated + "Aether", // SKINCOLOR_AETHER, + "Slate", // SKINCOLOR_SLATE, + "Bluebell", // SKINCOLOR_BLUEBELL, + "Pink", // SKINCOLOR_PINK, + "Yogurt", // SKINCOLOR_YOGURT, + "Brown", // SKINCOLOR_BROWN, + "Bronze", // SKINCOLOR_BRONZE, + "Tan", // SKINCOLOR_TAN, + "Beige", // SKINCOLOR_BEIGE, + "Moss", // SKINCOLOR_MOSS, + "Azure", // SKINCOLOR_AZURE, + "Lavender", // SKINCOLOR_LAVENDER, + + // Viv's vivid colours (toast 21/07/17) + "Ruby", // SKINCOLOR_RUBY, + "Salmon", // SKINCOLOR_SALMON, + "Red", // SKINCOLOR_RED, + "Crimson", // SKINCOLOR_CRIMSON, + "Flame", // SKINCOLOR_FLAME, + "Ketchup", // SKINCOLOR_KETCHUP, + "Peachy", // SKINCOLOR_PEACHY, + "Quail", // SKINCOLOR_QUAIL, + "Sunset", // SKINCOLOR_SUNSET, + "Copper", // SKINCOLOR_COPPER, + "Apricot", // SKINCOLOR_APRICOT, + "Orange", // SKINCOLOR_ORANGE, + "Rust", // SKINCOLOR_RUST, + "Gold", // SKINCOLOR_GOLD, + "Sandy", // SKINCOLOR_SANDY, + "Yellow", // SKINCOLOR_YELLOW, + "Olive", // SKINCOLOR_OLIVE, + "Lime", // SKINCOLOR_LIME, + "Peridot", // SKINCOLOR_PERIDOT, + "Apple", // SKINCOLOR_APPLE, + "Green", // SKINCOLOR_GREEN, + "Forest", // SKINCOLOR_FOREST, + "Emerald", // SKINCOLOR_EMERALD, + "Mint", // SKINCOLOR_MINT, + "Seafoam", // SKINCOLOR_SEAFOAM, + "Aqua", // SKINCOLOR_AQUA, + "Teal", // SKINCOLOR_TEAL, + "Wave", // SKINCOLOR_WAVE, + "Cyan", // SKINCOLOR_CYAN, + "Sky", // SKINCOLOR_SKY, + "Cerulean", // SKINCOLOR_CERULEAN, + "Icy", // SKINCOLOR_ICY, + "Sapphire", // SKINCOLOR_SAPPHIRE, + "Cornflower", // SKINCOLOR_CORNFLOWER, + "Blue", // SKINCOLOR_BLUE, + "Cobalt", // SKINCOLOR_COBALT, + "Vapor", // SKINCOLOR_VAPOR, + "Dusk", // SKINCOLOR_DUSK, + "Pastel", // SKINCOLOR_PASTEL, + "Purple", // SKINCOLOR_PURPLE, + "Bubblegum", // SKINCOLOR_BUBBLEGUM, + "Magenta", // SKINCOLOR_MAGENTA, + "Neon", // SKINCOLOR_NEON, + "Violet", // SKINCOLOR_VIOLET, + "Lilac", // SKINCOLOR_LILAC, + "Plum", // SKINCOLOR_PLUM, + "Raspberry", // SKINCOLOR_RASPBERRY, + "Rosy", // SKINCOLOR_ROSY, + + // Super behaves by different rules (one name per 5 colours), and will be accessed exclusively via R_GetSuperColorByName instead of R_GetColorByName. + "Silver", // SKINCOLOR_SUPERSILVER1, + "Red", // SKINCOLOR_SUPERRED1, + "Orange", // SKINCOLOR_SUPERORANGE1, + "Gold", // SKINCOLOR_SUPERGOLD1, + "Peridot", // SKINCOLOR_SUPERPERIDOT1, + "Sky", // SKINCOLOR_SUPERSKY1, + "Purple", // SKINCOLOR_SUPERPURPLE1, + "Rust", // SKINCOLOR_SUPERRUST1, + "Tan" // SKINCOLOR_SUPERTAN1, }; -const UINT8 Color_Opposite[MAXSKINCOLORS*2] = +/* +A word of warning: If the following array is non-symmetrical, +A_SignPlayer's prefoppositecolor behaviour will break. +*/ +// [0] = opposite skin color, +// [1] = shade index used by signpost, 0-15 (actual sprite frame is 15 minus this value) +const UINT8 Color_Opposite[MAXSKINCOLORS - 1][2] = { - SKINCOLOR_NONE,8, // SKINCOLOR_NONE - SKINCOLOR_BLACK,10, // SKINCOLOR_WHITE - SKINCOLOR_GREY,4, // SKINCOLOR_SILVER - SKINCOLOR_SILVER,12,// SKINCOLOR_GREY - SKINCOLOR_WHITE,8, // SKINCOLOR_BLACK - SKINCOLOR_NONE,8, // SKINCOLOR_CYAN - SKINCOLOR_NONE,8, // SKINCOLOR_TEAL - SKINCOLOR_NONE,8, // SKINCOLOR_STEELBLUE - SKINCOLOR_ORANGE,9, // SKINCOLOR_BLUE - SKINCOLOR_NONE,8, // SKINCOLOR_PEACH - SKINCOLOR_NONE,8, // SKINCOLOR_TAN - SKINCOLOR_NONE,8, // SKINCOLOR_PINK - SKINCOLOR_NONE,8, // SKINCOLOR_LAVENDER - SKINCOLOR_NONE,8, // SKINCOLOR_PURPLE - SKINCOLOR_BLUE,12, // SKINCOLOR_ORANGE - SKINCOLOR_NONE,8, // SKINCOLOR_ROSEWOOD - SKINCOLOR_NONE,8, // SKINCOLOR_BEIGE - SKINCOLOR_NONE,8, // SKINCOLOR_BROWN - SKINCOLOR_GREEN,5, // SKINCOLOR_RED - SKINCOLOR_NONE,8, // SKINCOLOR_DARKRED - SKINCOLOR_NONE,8, // SKINCOLOR_NEONGREEN - SKINCOLOR_RED,11, // SKINCOLOR_GREEN - SKINCOLOR_PURPLE,3, // SKINCOLOR_ZIM - SKINCOLOR_NONE,8, // SKINCOLOR_OLIVE - SKINCOLOR_NONE,8, // SKINCOLOR_YELLOW - SKINCOLOR_NONE,8 // SKINCOLOR_GOLD + // {SKINCOLOR_NONE, 8}, // SKINCOLOR_NONE + + // Greyscale ranges + {SKINCOLOR_BLACK, 5}, // SKINCOLOR_WHITE, + {SKINCOLOR_JET, 7}, // SKINCOLOR_BONE, + {SKINCOLOR_CARBON, 7}, // SKINCOLOR_CLOUDY, + {SKINCOLOR_AETHER, 12}, // SKINCOLOR_GREY, + {SKINCOLOR_SLATE, 12}, // SKINCOLOR_SILVER, + {SKINCOLOR_CLOUDY, 7}, // SKINCOLOR_CARBON, + {SKINCOLOR_BONE, 7}, // SKINCOLOR_JET, + {SKINCOLOR_WHITE, 7}, // SKINCOLOR_BLACK, + + // Desaturated + {SKINCOLOR_GREY, 15}, // SKINCOLOR_AETHER, + {SKINCOLOR_SILVER, 12}, // SKINCOLOR_SLATE, + {SKINCOLOR_COPPER, 4}, // SKINCOLOR_BLUEBELL, + {SKINCOLOR_AZURE, 9}, // SKINCOLOR_PINK, + {SKINCOLOR_RUST, 7}, // SKINCOLOR_YOGURT, + {SKINCOLOR_TAN, 2}, // SKINCOLOR_BROWN, + {SKINCOLOR_KETCHUP, 0}, // SKINCOLOR_BRONZE, + {SKINCOLOR_BROWN, 12}, // SKINCOLOR_TAN, + {SKINCOLOR_MOSS, 5}, // SKINCOLOR_BEIGE, + {SKINCOLOR_BEIGE, 13}, // SKINCOLOR_MOSS, + {SKINCOLOR_PINK, 5}, // SKINCOLOR_AZURE, + {SKINCOLOR_GOLD, 4}, // SKINCOLOR_LAVENDER, + + // Viv's vivid colours (toast 21/07/17) + {SKINCOLOR_EMERALD, 10}, // SKINCOLOR_RUBY, + {SKINCOLOR_FOREST, 6}, // SKINCOLOR_SALMON, + {SKINCOLOR_GREEN, 10}, // SKINCOLOR_RED, + {SKINCOLOR_ICY, 10}, // SKINCOLOR_CRIMSON, + {SKINCOLOR_PURPLE, 8}, // SKINCOLOR_FLAME, + {SKINCOLOR_BRONZE, 8}, // SKINCOLOR_KETCHUP, + {SKINCOLOR_TEAL, 7}, // SKINCOLOR_PEACHY, + {SKINCOLOR_WAVE, 5}, // SKINCOLOR_QUAIL, + {SKINCOLOR_SAPPHIRE, 5}, // SKINCOLOR_SUNSET, + {SKINCOLOR_BLUEBELL, 5}, // SKINCOLOR_COPPER + {SKINCOLOR_CYAN, 4}, // SKINCOLOR_APRICOT, + {SKINCOLOR_BLUE, 4}, // SKINCOLOR_ORANGE, + {SKINCOLOR_YOGURT, 8}, // SKINCOLOR_RUST, + {SKINCOLOR_LAVENDER, 10}, // SKINCOLOR_GOLD, + {SKINCOLOR_SKY, 8}, // SKINCOLOR_SANDY, + {SKINCOLOR_CORNFLOWER, 8}, // SKINCOLOR_YELLOW, + {SKINCOLOR_DUSK, 3}, // SKINCOLOR_OLIVE, + {SKINCOLOR_MAGENTA, 9}, // SKINCOLOR_LIME, + {SKINCOLOR_COBALT, 2}, // SKINCOLOR_PERIDOT, + {SKINCOLOR_RASPBERRY, 13}, // SKINCOLOR_APPLE, + {SKINCOLOR_RED, 6}, // SKINCOLOR_GREEN, + {SKINCOLOR_SALMON, 9}, // SKINCOLOR_FOREST, + {SKINCOLOR_RUBY, 4}, // SKINCOLOR_EMERALD, + {SKINCOLOR_VIOLET, 5}, // SKINCOLOR_MINT, + {SKINCOLOR_PLUM, 6}, // SKINCOLOR_SEAFOAM, + {SKINCOLOR_ROSY, 7}, // SKINCOLOR_AQUA, + {SKINCOLOR_PEACHY, 7}, // SKINCOLOR_TEAL, + {SKINCOLOR_QUAIL, 5}, // SKINCOLOR_WAVE, + {SKINCOLOR_APRICOT, 6}, // SKINCOLOR_CYAN, + {SKINCOLOR_SANDY, 1}, // SKINCOLOR_SKY, + {SKINCOLOR_NEON, 4}, // SKINCOLOR_CERULEAN, + {SKINCOLOR_CRIMSON, 0}, // SKINCOLOR_ICY, + {SKINCOLOR_SUNSET, 5}, // SKINCOLOR_SAPPHIRE, + {SKINCOLOR_YELLOW, 4}, // SKINCOLOR_CORNFLOWER, + {SKINCOLOR_ORANGE, 5}, // SKINCOLOR_BLUE, + {SKINCOLOR_PERIDOT, 5}, // SKINCOLOR_COBALT, + {SKINCOLOR_LILAC, 4}, // SKINCOLOR_VAPOR, + {SKINCOLOR_OLIVE, 0}, // SKINCOLOR_DUSK, + {SKINCOLOR_BUBBLEGUM, 9}, // SKINCOLOR_PASTEL, + {SKINCOLOR_FLAME, 7}, // SKINCOLOR_PURPLE, + {SKINCOLOR_PASTEL, 8}, // SKINCOLOR_BUBBLEGUM, + {SKINCOLOR_LIME, 6}, // SKINCOLOR_MAGENTA, + {SKINCOLOR_CERULEAN, 2}, // SKINCOLOR_NEON, + {SKINCOLOR_MINT, 6}, // SKINCOLOR_VIOLET, + {SKINCOLOR_VAPOR, 4}, // SKINCOLOR_LILAC, + {SKINCOLOR_MINT, 7}, // SKINCOLOR_PLUM, + {SKINCOLOR_APPLE, 13}, // SKINCOLOR_RASPBERRY + {SKINCOLOR_AQUA, 1} // SKINCOLOR_ROSY, }; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; @@ -203,10 +457,6 @@ CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; */ void R_InitTranslationTables(void) { -#ifdef _NDS - // Ugly temporary NDS hack. - transtables = (UINT8*)0x2000000; -#else // Load here the transparency lookup tables 'TINTTAB' // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm // optimised code (in other words, transtables pointer low word is 0) @@ -222,7 +472,6 @@ void R_InitTranslationTables(void) W_ReadLump(W_GetNumForName("TRANS70"), transtables+0x60000); W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000); W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000); -#endif } @@ -234,267 +483,184 @@ void R_InitTranslationTables(void) \return void */ + +// Define for getting accurate color brightness readings according to how the human eye sees them. +// https://en.wikipedia.org/wiki/Relative_luminance +// 0.2126 to red +// 0.7152 to green +// 0.0722 to blue +// (See this same define in hw_md2.c!) +#define SETBRIGHTNESS(brightness,r,g,b) \ + brightness = (UINT8)(((1063*((UINT16)r)/5000) + (3576*((UINT16)g)/5000) + (361*((UINT16)b)/5000)) / 3) + +/** \brief Generates the rainbow colourmaps that are used when a player has the invincibility power... stolen from kart, with permission + + \param dest_colormap colormap to populate + \param skincolor translation color +*/ +static void R_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor) +{ + INT32 i; + RGBA_t color; + UINT8 brightness; + INT32 j; + UINT8 colorbrightnesses[16]; + UINT16 brightdif; + INT32 temp; + + // first generate the brightness of all the colours of that skincolour + for (i = 0; i < 16; i++) + { + color = V_GetColor(Color_Index[skincolor-1][i]); + SETBRIGHTNESS(colorbrightnesses[i], color.s.red, color.s.green, color.s.blue); + } + + // next, for every colour in the palette, choose the transcolor that has the closest brightness + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + { + if (i == 0 || i == 31) // pure black and pure white don't change + { + dest_colormap[i] = (UINT8)i; + continue; + } + color = V_GetColor(i); + SETBRIGHTNESS(brightness, color.s.red, color.s.green, color.s.blue); + brightdif = 256; + for (j = 0; j < 16; j++) + { + temp = abs((INT16)brightness - (INT16)colorbrightnesses[j]); + if (temp < brightdif) + { + brightdif = (UINT16)temp; + dest_colormap[i] = Color_Index[skincolor-1][j]; + } + } + } +} + +#undef SETBRIGHTNESS + static void R_GenerateTranslationColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color) { - // Table of indices into the palette of the first entries of each translated ramp - const UINT8 skinbasecolors[] = { - 0x00, // SKINCOLOR_WHITE - 0x03, // SKINCOLOR_SILVER - 0x08, // SKINCOLOR_GREY - 0x18, // SKINCOLOR_BLACK - 0xd0, // SKINCOLOR_CYAN - 0xdc, // SKINCOLOR_TEAL - 0xc8, // SKINCOLOR_STEELBLUE - 0xe2, // SKINCOLOR_BLUE - 0x40, // SKINCOLOR_PEACH - 0x48, // SKINCOLOR_TAN - 0x90, // SKINCOLOR_PINK - 0xf8, // SKINCOLOR_LAVENDER - 0xc0, // SKINCOLOR_PURPLE - 0x52, // SKINCOLOR_ORANGE - 0x5c, // SKINCOLOR_ROSEWOOD - 0x20, // SKINCOLOR_BEIGE - 0x30, // SKINCOLOR_BROWN - 0x7d, // SKINCOLOR_RED - 0x85, // SKINCOLOR_DARKRED - 0xb8, // SKINCOLOR_NEONGREEN - 0xa0, // SKINCOLOR_GREEN - 0xb0, // SKINCOLOR_ZIM - 0x69, // SKINCOLOR_OLIVE - 0x67, // SKINCOLOR_YELLOW - 0x70, // SKINCOLOR_GOLD - }; - INT32 i; - INT32 starttranscolor; + INT32 i, starttranscolor, skinramplength; // Handle a couple of simple special cases - if (skinnum == TC_BOSS || skinnum == TC_ALLWHITE || skinnum == TC_METALSONIC || color == SKINCOLOR_NONE) + if (skinnum < TC_DEFAULT) { - for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + switch (skinnum) { - if (skinnum == TC_ALLWHITE) dest_colormap[i] = 0; - else dest_colormap[i] = (UINT8)i; + case TC_ALLWHITE: + memset(dest_colormap, 0, NUM_PALETTE_ENTRIES * sizeof(UINT8)); + return; + case TC_RAINBOW: + if (color >= MAXTRANSLATIONS) + I_Error("Invalid skin color #%hu.", (UINT16)color); + if (color != SKINCOLOR_NONE) + { + R_RainbowColormap(dest_colormap, color); + return; + } + break; + case TC_BLINK: + if (color >= MAXTRANSLATIONS) + I_Error("Invalid skin color #%hu.", (UINT16)color); + if (color != SKINCOLOR_NONE) + { + memset(dest_colormap, Color_Index[color-1][3], NUM_PALETTE_ENTRIES * sizeof(UINT8)); + return; + } + break; + default: + break; } + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + dest_colormap[i] = (UINT8)i; + // White! if (skinnum == TC_BOSS) - dest_colormap[31] = 0; + { + for (i = 0; i < 16; i++) + dest_colormap[31-i] = i; + } else if (skinnum == TC_METALSONIC) - dest_colormap[239] = 0; + { + for (i = 0; i < 6; i++) + { + dest_colormap[Color_Index[SKINCOLOR_BLUE-1][12-i]] = Color_Index[SKINCOLOR_BLUE-1][i]; + } + dest_colormap[159] = dest_colormap[253] = dest_colormap[254] = 0; + for (i = 0; i < 16; i++) + dest_colormap[96+i] = dest_colormap[Color_Index[SKINCOLOR_COBALT-1][i]]; + } + else if (skinnum == TC_DASHMODE) // This is a long one, because MotorRoach basically hand-picked the indices + { + // greens -> ketchups + dest_colormap[96] = dest_colormap[97] = 48; + dest_colormap[98] = 49; + dest_colormap[99] = 51; + dest_colormap[100] = 52; + dest_colormap[101] = dest_colormap[102] = 54; + dest_colormap[103] = 34; + dest_colormap[104] = 37; + dest_colormap[105] = 39; + dest_colormap[106] = 41; + for (i = 0; i < 5; i++) + dest_colormap[107 + i] = 43 + i; + // reds -> steel blues + dest_colormap[32] = 146; + dest_colormap[33] = 147; + dest_colormap[34] = dest_colormap[35] = 170; + dest_colormap[36] = 171; + dest_colormap[37] = dest_colormap[38] = 172; + dest_colormap[39] = dest_colormap[40] = dest_colormap[41] = 173; + dest_colormap[42] = dest_colormap[43] = dest_colormap[44] = 174; + dest_colormap[45] = dest_colormap[46] = dest_colormap[47] = 175; + dest_colormap[71] = 139; + + // steel blues -> oranges + dest_colormap[170] = 52; + dest_colormap[171] = 54; + dest_colormap[172] = 56; + dest_colormap[173] = 42; + dest_colormap[174] = 45; + dest_colormap[175] = 47; + } + return; + } + else if (color == SKINCOLOR_NONE) + { + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + dest_colormap[i] = (UINT8)i; return; } + if (color >= MAXTRANSLATIONS) + I_Error("Invalid skin color #%hu.", (UINT16)color); + starttranscolor = (skinnum != TC_DEFAULT) ? skins[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; + if (starttranscolor >= NUM_PALETTE_ENTRIES) + I_Error("Invalid startcolor #%d.", starttranscolor); + // Fill in the entries of the palette that are fixed for (i = 0; i < starttranscolor; i++) dest_colormap[i] = (UINT8)i; - for (i = (UINT8)(starttranscolor + 16); i < NUM_PALETTE_ENTRIES; i++) - dest_colormap[i] = (UINT8)i; + i = starttranscolor + 16; + if (i < NUM_PALETTE_ENTRIES) + { + for (i = (UINT8)i; i < NUM_PALETTE_ENTRIES; i++) + dest_colormap[i] = (UINT8)i; + skinramplength = 16; + } + else + skinramplength = i - NUM_PALETTE_ENTRIES; // shouldn't this be NUM_PALETTE_ENTRIES - starttranscolor? // Build the translated ramp - switch (color) - { - case SKINCOLOR_SILVER: - case SKINCOLOR_GREY: - case SKINCOLOR_PEACH: - case SKINCOLOR_BEIGE: - case SKINCOLOR_BROWN: - case SKINCOLOR_RED: - case SKINCOLOR_GREEN: - case SKINCOLOR_BLUE: - // 16 color ramp - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + i); - break; - - case SKINCOLOR_ORANGE: - // 14 colors of orange + brown - for (i = 0; i < SKIN_RAMP_LENGTH-2; i++) - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + i); - for (i = 0; i < 2; i++) - dest_colormap[starttranscolor + (i+SKIN_RAMP_LENGTH-2)] = (UINT8)(152 + i); - break; - - case SKINCOLOR_CYAN: - // 12 color ramp - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + (12*i/SKIN_RAMP_LENGTH)); - break; - - case SKINCOLOR_WHITE: - case SKINCOLOR_BLACK: - case SKINCOLOR_STEELBLUE: - case SKINCOLOR_PINK: - case SKINCOLOR_LAVENDER: - case SKINCOLOR_PURPLE: - case SKINCOLOR_DARKRED: - case SKINCOLOR_ZIM: - case SKINCOLOR_YELLOW: - case SKINCOLOR_GOLD: - // 8 color ramp - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + (i >> 1)); - break; - - case SKINCOLOR_TEAL: - // 5 color ramp - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - { - if (5*i/16 == 0) - dest_colormap[starttranscolor + i] = 0xf7; - else - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + (5*i/SKIN_RAMP_LENGTH) - 1); - } - break; - - case SKINCOLOR_OLIVE: - // 7 color ramp - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + (7*i/SKIN_RAMP_LENGTH)); - break; - - case SKINCOLOR_TAN: - // 16 color ramp, from two color ranges - for (i = 0; i < SKIN_RAMP_LENGTH/2; i++) // Peach half - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + i); - for (i = 0; i < SKIN_RAMP_LENGTH/2; i++) // Brown half - dest_colormap[starttranscolor + (i+8)] = (UINT8)(48 + i); - break; - - case SKINCOLOR_ROSEWOOD: - // 12 color ramp, from two color ranges! - for (i = 0; i < 6; i++) // Orange ...third? - dest_colormap[starttranscolor + i] = (UINT8)(skinbasecolors[color - 1] + (12*i/SKIN_RAMP_LENGTH)); - for (i = 0; i < 10; i++) // Rosewood two-thirds-ish - dest_colormap[starttranscolor + (i+6)] = (UINT8)(152 + (12*i/SKIN_RAMP_LENGTH)); - break; - - case SKINCOLOR_NEONGREEN: - // Multi-color ramp - dest_colormap[starttranscolor] = 0xA0; // Brighter green - for (i = 0; i < SKIN_RAMP_LENGTH-1; i++) // Neon Green - dest_colormap[starttranscolor + (i+1)] = (UINT8)(skinbasecolors[color - 1] + (6*i/(SKIN_RAMP_LENGTH-1))); - break; - - // Super colors, from lightest to darkest! - case SKINCOLOR_SUPER1: - // Super White - for (i = 0; i < 10; i++) - dest_colormap[starttranscolor + i] = 120; // True white - for (; i < SKIN_RAMP_LENGTH; i++) // White-yellow fade - dest_colormap[starttranscolor + i] = (UINT8)(96 + (i-10)); - break; - - case SKINCOLOR_SUPER2: - // Super Bright - for (i = 0; i < 5; i++) // White-yellow fade - dest_colormap[starttranscolor + i] = (UINT8)(96 + i); - dest_colormap[starttranscolor + 5] = 112; // Golden shine - for (i = 0; i < 8; i++) // Yellow - dest_colormap[starttranscolor + (i+6)] = (UINT8)(101 + (i>>1)); - for (i = 0; i < 2; i++) // With a fine golden finish! :3 - dest_colormap[starttranscolor + (i+14)] = (UINT8)(113 + i); - break; - - case SKINCOLOR_SUPER3: - // Super Yellow - for (i = 0; i < 3; i++) // White-yellow fade - dest_colormap[starttranscolor + i] = (UINT8)(98 + i); - dest_colormap[starttranscolor + 3] = 112; // Golden shine - for (i = 0; i < 8; i++) // Yellow - dest_colormap[starttranscolor + (i+4)] = (UINT8)(101 + (i>>1)); - for (i = 0; i < 4; i++) // With a fine golden finish! :3 - dest_colormap[starttranscolor + (i+12)] = (UINT8)(113 + i); - break; - - case SKINCOLOR_SUPER4: - // "The SSNTails" - dest_colormap[starttranscolor] = 112; // Golden shine - for (i = 0; i < 8; i++) // Yellow - dest_colormap[starttranscolor + (i+1)] = (UINT8)(101 + (i>>1)); - for (i = 0; i < 7; i++) // With a fine golden finish! :3 - dest_colormap[starttranscolor + (i+9)] = (UINT8)(113 + i); - break; - - case SKINCOLOR_SUPER5: - // Golden Delicious - for (i = 0; i < 8; i++) // Yellow - dest_colormap[starttranscolor + i] = (UINT8)(101 + (i>>1)); - for (i = 0; i < 7; i++) // With a fine golden finish! :3 - dest_colormap[starttranscolor + (i+8)] = (UINT8)(113 + i); - dest_colormap[starttranscolor + 15] = 155; - break; - - // Super Tails - case SKINCOLOR_TSUPER1: - for (i = 0; i < 10; i++) // white - dest_colormap[starttranscolor + i] = 120; - for (; i < SKIN_RAMP_LENGTH; i++) // orange - dest_colormap[starttranscolor + i] = (UINT8)(80 + (i-10)); - break; - - case SKINCOLOR_TSUPER2: - for (i = 0; i < 4; i++) // white - dest_colormap[starttranscolor + i] = 120; - for (; i < SKIN_RAMP_LENGTH; i++) // orange - dest_colormap[starttranscolor + i] = (UINT8)(80 + ((i-4)>>1)); - break; - - case SKINCOLOR_TSUPER3: - dest_colormap[starttranscolor] = 120; // pure white - dest_colormap[starttranscolor+1] = 120; - for (i = 2; i < SKIN_RAMP_LENGTH; i++) // orange - dest_colormap[starttranscolor + i] = (UINT8)(80 + ((i-2)>>1)); - break; - - case SKINCOLOR_TSUPER4: - dest_colormap[starttranscolor] = 120; // pure white - for (i = 1; i < 9; i++) // orange - dest_colormap[starttranscolor + i] = (UINT8)(80 + (i-1)); - for (; i < SKIN_RAMP_LENGTH; i++) // gold - dest_colormap[starttranscolor + i] = (UINT8)(115 + (5*(i-9)/7)); - break; - - case SKINCOLOR_TSUPER5: - for (i = 0; i < 8; i++) // orange - dest_colormap[starttranscolor + i] = (UINT8)(80 + i); - for (; i < SKIN_RAMP_LENGTH; i++) // gold - dest_colormap[starttranscolor + i] = (UINT8)(115 + (5*(i-8)/8)); - break; - - // Super Knuckles - case SKINCOLOR_KSUPER1: - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(120 + (i >> 2)); - break; - - case SKINCOLOR_KSUPER2: - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(120 + (6*i/SKIN_RAMP_LENGTH)); - break; - - case SKINCOLOR_KSUPER3: - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(120 + (i >> 1)); - break; - - case SKINCOLOR_KSUPER4: - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(121 + (i >> 1)); - break; - - case SKINCOLOR_KSUPER5: - for (i = 0; i < SKIN_RAMP_LENGTH; i++) - dest_colormap[starttranscolor + i] = (UINT8)(122 + (i >> 1)); - break; - - default: - I_Error("Invalid skin color #%hu.", (UINT16)color); - break; - } + for (i = 0; i < skinramplength; i++) + dest_colormap[starttranscolor + i] = (UINT8)Color_Index[color-1][i]; } @@ -512,11 +678,17 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) INT32 skintableindex; // Adjust if we want the default colormap - if (skinnum == TC_DEFAULT) skintableindex = DEFAULT_TT_CACHE_INDEX; - else if (skinnum == TC_BOSS) skintableindex = BOSS_TT_CACHE_INDEX; - else if (skinnum == TC_METALSONIC) skintableindex = METALSONIC_TT_CACHE_INDEX; - else if (skinnum == TC_ALLWHITE) skintableindex = ALLWHITE_TT_CACHE_INDEX; - else skintableindex = skinnum; + switch (skinnum) + { + case TC_DEFAULT: skintableindex = DEFAULT_TT_CACHE_INDEX; break; + case TC_BOSS: skintableindex = BOSS_TT_CACHE_INDEX; break; + case TC_METALSONIC: skintableindex = METALSONIC_TT_CACHE_INDEX; break; + case TC_ALLWHITE: skintableindex = ALLWHITE_TT_CACHE_INDEX; break; + case TC_RAINBOW: skintableindex = RAINBOW_TT_CACHE_INDEX; break; + case TC_BLINK: skintableindex = BLINK_TT_CACHE_INDEX; break; + case TC_DASHMODE: skintableindex = DASHMODE_TT_CACHE_INDEX; break; + default: skintableindex = skinnum; break; + } if (flags & GTC_CACHE) { @@ -569,7 +741,18 @@ UINT8 R_GetColorByName(const char *name) for (color = 1; color < MAXSKINCOLORS; color++) if (!stricmp(Color_Names[color], name)) return color; - return 0; + return SKINCOLOR_GREEN; +} + +UINT8 R_GetSuperColorByName(const char *name) +{ + UINT8 color; /* = (UINT8)atoi(name); -- This isn't relevant to S_SKIN, which is the only way it's accessible right now. Let's simplify things. + if (color > MAXSKINCOLORS && color < MAXTRANSLATIONS && !((color - MAXSKINCOLORS) % 5)) + return color;*/ + for (color = 0; color < NUMSUPERCOLORS; color++) + if (!stricmp(Color_Names[color + MAXSKINCOLORS], name)) + return ((color*5) + MAXSKINCOLORS); + return SKINCOLOR_SUPERGOLD1; } // ========================================================================== @@ -796,6 +979,7 @@ void R_DrawViewBorder(void) // ========================================================================== #include "r_draw8.c" +#include "r_draw8_npo2.c" // ========================================================================== // INCLUDE 16bpp DRAWING CODE HERE diff --git a/src/r_draw.h b/src/r_draw.h index 12f556b7a..870d294c3 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -57,7 +57,9 @@ extern INT32 dc_texheight; extern INT32 ds_y, ds_x1, ds_x2; extern lighttable_t *ds_colormap; extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; -extern UINT8 *ds_source; // start of a 64*64 tile image +extern UINT16 ds_flatwidth, ds_flatheight; +extern boolean ds_powersoftwo; +extern UINT8 *ds_source; extern UINT8 *ds_transmap; #ifdef ESLOPE @@ -66,7 +68,8 @@ typedef struct { } floatv3_t; extern pslope_t *ds_slope; // Current slope being used -extern floatv3_t ds_su, ds_sv, ds_sz; // Vectors for... stuff? +extern floatv3_t ds_su[MAXVIDHEIGHT], ds_sv[MAXVIDHEIGHT], ds_sz[MAXVIDHEIGHT]; // Vectors for... stuff? +extern floatv3_t *ds_sup, *ds_svp, *ds_szp; extern float focallengthf, zeroheight; #endif @@ -105,12 +108,16 @@ extern lumpnum_t viewborderlump[8]; #define TC_BOSS -2 #define TC_METALSONIC -3 // For Metal Sonic battle #define TC_ALLWHITE -4 // For Cy-Brak-demon +#define TC_RAINBOW -5 // For single colour +#define TC_BLINK -6 // For item blinking, according to kart +#define TC_DASHMODE -7 // For Metal Sonic's dashmode // Initialize color translation tables, for player rendering etc. void R_InitTranslationTables(void); UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags); void R_FlushTranslationColormapCache(void); UINT8 R_GetColorByName(const char *name); +UINT8 R_GetSuperColorByName(const char *name); // Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); @@ -125,47 +132,72 @@ void R_FillBackScreen(void); void R_DrawViewBorder(void); #endif +#define TRANSPARENTPIXEL 255 + // ----------------- // 8bpp DRAWING CODE // ----------------- void R_DrawColumn_8(void); -#define R_DrawWallColumn_8 R_DrawColumn_8 void R_DrawShadeColumn_8(void); void R_DrawTranslucentColumn_8(void); +void R_DrawTranslatedColumn_8(void); +void R_DrawTranslatedTranslucentColumn_8(void); +void R_Draw2sMultiPatchColumn_8(void); +void R_Draw2sMultiPatchTranslucentColumn_8(void); +void R_DrawFogColumn_8(void); +void R_DrawColumnShadowed_8(void); + +void R_DrawSpan_8(void); +void R_DrawSplat_8(void); +void R_DrawTranslucentSpan_8(void); +void R_DrawTranslucentSplat_8(void); +#ifdef ESLOPE +void R_DrawTiltedSpan_8(void); +void R_DrawTiltedTranslucentSpan_8(void); +#ifndef NOWATER +void R_DrawTiltedTranslucentWaterSpan_8(void); +#endif +void R_DrawTiltedSplat_8(void); +void R_CalcTiltedLighting(fixed_t start, fixed_t end); +extern INT32 tiltlighting[MAXVIDWIDTH]; +#endif +#ifndef NOWATER +void R_DrawTranslucentWaterSpan_8(void); +extern INT32 ds_bgofs; +extern INT32 ds_waterofs; +#endif +void R_DrawFogSpan_8(void); + +// Lactozilla: Non-powers-of-two +void R_DrawSpan_NPO2_8(void); +void R_DrawTranslucentSpan_NPO2_8(void); +void R_DrawSplat_NPO2_8(void); +void R_DrawTranslucentSplat_NPO2_8(void); +#ifdef ESLOPE +void R_DrawTiltedSpan_NPO2_8(void); +void R_DrawTiltedTranslucentSpan_NPO2_8(void); +#ifndef NOWATER +void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void); +#endif +void R_DrawTiltedSplat_NPO2_8(void); +#endif +#ifndef NOWATER +void R_DrawTranslucentWaterSpan_NPO2_8(void); +#endif #ifdef USEASM void ASMCALL R_DrawColumn_8_ASM(void); -#define R_DrawWallColumn_8_ASM R_DrawColumn_8_ASM void ASMCALL R_DrawShadeColumn_8_ASM(void); void ASMCALL R_DrawTranslucentColumn_8_ASM(void); void ASMCALL R_Draw2sMultiPatchColumn_8_ASM(void); void ASMCALL R_DrawColumn_8_MMX(void); -#define R_DrawWallColumn_8_MMX R_DrawColumn_8_MMX void ASMCALL R_Draw2sMultiPatchColumn_8_MMX(void); void ASMCALL R_DrawSpan_8_MMX(void); #endif -void R_DrawTranslatedColumn_8(void); -void R_DrawTranslatedTranslucentColumn_8(void); -void R_DrawSpan_8(void); -#ifdef ESLOPE -void R_CalcTiltedLighting(fixed_t start, fixed_t end); -void R_DrawTiltedSpan_8(void); -void R_DrawTiltedTranslucentSpan_8(void); -void R_DrawTiltedSplat_8(void); -#endif -void R_DrawSplat_8(void); -void R_DrawTranslucentSplat_8(void); -void R_DrawTranslucentSpan_8(void); -void R_Draw2sMultiPatchColumn_8(void); -void R_Draw2sMultiPatchTranslucentColumn_8(void); -void R_DrawFogSpan_8(void); -void R_DrawFogColumn_8(void); -void R_DrawColumnShadowed_8(void); - // ------------------ // 16bpp DRAWING CODE // ------------------ diff --git a/src/r_draw16.c b/src/r_draw16.c index 918dd356c..8b1d29e8d 100644 --- a/src/r_draw16.c +++ b/src/r_draw16.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_draw8.c b/src/r_draw8.c index 886b72dae..fe0a23770 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -105,8 +105,6 @@ void R_DrawColumn_8(void) } } -#define TRANSPARENTPIXEL 247 - void R_Draw2sMultiPatchColumn_8(void) { INT32 count; @@ -543,16 +541,19 @@ void R_DrawTranslatedColumn_8(void) */ void R_DrawSpan_8 (void) { - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; UINT8 *source; UINT8 *colormap; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - size_t count; + size_t count = (ds_x2 - ds_x1 + 1); + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the @@ -561,13 +562,12 @@ void R_DrawSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; if (dest+8 > deststop) return; @@ -577,35 +577,35 @@ void R_DrawSpan_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[0] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[1] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[1] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[2] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[2] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[3] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[3] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[4] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[4] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[5] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[5] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[6] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[6] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; - dest[7] = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + dest[7] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; @@ -614,7 +614,7 @@ void R_DrawSpan_8 (void) } while (count-- && dest <= deststop) { - *dest++ = colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]]; + *dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; xposition += xstep; yposition += ystep; } @@ -623,7 +623,7 @@ void R_DrawSpan_8 (void) #ifdef ESLOPE // R_CalcTiltedLighting // Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly. -static INT32 tiltlighting[MAXVIDWIDTH]; +INT32 tiltlighting[MAXVIDWIDTH]; void R_CalcTiltedLighting(fixed_t start, fixed_t end) { // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version @@ -644,6 +644,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) } } +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) /** \brief The R_DrawTiltedSpan_8 function Draw slopes! Holy sheit! @@ -665,22 +666,22 @@ void R_DrawTiltedSpan_8(void) double endz, endu, endv; UINT32 stepu, stepv; - iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; - lightend = (iz + ds_sz.x*width) * planelightfloat; + lightend = (iz + ds_szp->x*width) * planelightfloat; lightstart = iz * planelightfloat; R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); } - uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx); - vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; @@ -699,9 +700,9 @@ void R_DrawTiltedSpan_8(void) *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; dest++; - iz += ds_sz.x; - uz += ds_su.x; - vz += ds_sv.x; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; } while (--width >= 0); #else #define SPANSIZE 16 @@ -711,9 +712,9 @@ void R_DrawTiltedSpan_8(void) startu = uz*startz; startv = vz*startz; - izstep = ds_sz.x * SPANSIZE; - uzstep = ds_su.x * SPANSIZE; - vzstep = ds_sv.x * SPANSIZE; + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; //x1 = 0; width++; @@ -755,9 +756,9 @@ void R_DrawTiltedSpan_8(void) else { double left = width; - iz += ds_sz.x * left; - uz += ds_su.x * left; - vz += ds_sv.x * left; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; endz = 1.f/iz; endu = uz*endz; @@ -801,22 +802,22 @@ void R_DrawTiltedTranslucentSpan_8(void) double endz, endu, endv; UINT32 stepu, stepv; - iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; - lightend = (iz + ds_sz.x*width) * planelightfloat; + lightend = (iz + ds_szp->x*width) * planelightfloat; lightstart = iz * planelightfloat; R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); } - uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx); - vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; @@ -834,9 +835,9 @@ void R_DrawTiltedTranslucentSpan_8(void) colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); dest++; - iz += ds_sz.x; - uz += ds_su.x; - vz += ds_sv.x; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; } while (--width >= 0); #else #define SPANSIZE 16 @@ -846,9 +847,9 @@ void R_DrawTiltedTranslucentSpan_8(void) startu = uz*startz; startv = vz*startz; - izstep = ds_sz.x * SPANSIZE; - uzstep = ds_su.x * SPANSIZE; - vzstep = ds_sv.x * SPANSIZE; + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; //x1 = 0; width++; @@ -890,9 +891,9 @@ void R_DrawTiltedTranslucentSpan_8(void) else { double left = width; - iz += ds_sz.x * left; - uz += ds_su.x * left; - vz += ds_sv.x * left; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; endz = 1.f/iz; endu = uz*endz; @@ -916,6 +917,145 @@ void R_DrawTiltedTranslucentSpan_8(void) #endif } +#ifndef NOWATER +/** \brief The R_DrawTiltedTranslucentWaterSpan_8 function + Like DrawTiltedTranslucentSpan, but for water +*/ +void R_DrawTiltedTranslucentWaterSpan_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + UINT8 *dsrc; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds_szp->x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + source = ds_source; + //colormap = ds_colormap; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z) + viewx; + v = (INT64)(vz*z) + viewy; + + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + dest++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + dest++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + dest++; + u += stepu; + v += stepv; + } + } + } +#endif +} +#endif // NOWATER + void R_DrawTiltedSplat_8(void) { // x1, x2 = ds_x1, ds_x2 @@ -935,22 +1075,22 @@ void R_DrawTiltedSplat_8(void) double endz, endu, endv; UINT32 stepu, stepv; - iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx); + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); // Lighting is simple. It's just linear interpolation from start to end { - float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f; + float planelightfloat = PLANELIGHTFLOAT; float lightstart, lightend; - lightend = (iz + ds_sz.x*width) * planelightfloat; + lightend = (iz + ds_szp->x*width) * planelightfloat; lightstart = iz * planelightfloat; R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); } - uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx); - vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx); + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; @@ -970,10 +1110,11 @@ void R_DrawTiltedSplat_8(void) val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; + dest++; - iz += ds_sz.x; - uz += ds_su.x; - vz += ds_sv.x; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; } while (--width >= 0); #else #define SPANSIZE 16 @@ -983,9 +1124,9 @@ void R_DrawTiltedSplat_8(void) startu = uz*startz; startv = vz*startz; - izstep = ds_sz.x * SPANSIZE; - uzstep = ds_su.x * SPANSIZE; - vzstep = ds_sv.x * SPANSIZE; + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; //x1 = 0; width++; @@ -1031,9 +1172,9 @@ void R_DrawTiltedSplat_8(void) else { double left = width; - iz += ds_sz.x * left; - uz += ds_su.x * left; - vz += ds_sv.x * left; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; endz = 1.f/iz; endu = uz*endz; @@ -1065,17 +1206,21 @@ void R_DrawTiltedSplat_8(void) */ void R_DrawSplat_8 (void) { - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; UINT8 *source; UINT8 *colormap; UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - size_t count; + size_t count = (ds_x2 - ds_x1 + 1); UINT32 val; + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -1083,13 +1228,12 @@ void R_DrawSplat_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; while (count >= 8) { @@ -1098,7 +1242,7 @@ void R_DrawSplat_8 (void) // need! // // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1106,7 +1250,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1114,7 +1258,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1122,7 +1266,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1130,7 +1274,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1138,7 +1282,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1146,7 +1290,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1154,7 +1298,7 @@ void R_DrawSplat_8 (void) xposition += xstep; yposition += ystep; - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); val &= 4194303; val = source[val]; if (val != TRANSPARENTPIXEL) @@ -1165,14 +1309,11 @@ void R_DrawSplat_8 (void) dest += 8; count -= 8; } - while (count--) + while (count-- && dest <= deststop) { - val = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); - val &= 4194303; - val = source[val]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = colormap[val]; - dest++; xposition += xstep; yposition += ystep; @@ -1184,16 +1325,20 @@ void R_DrawSplat_8 (void) */ void R_DrawTranslucentSplat_8 (void) { - UINT32 xposition; - UINT32 yposition; - UINT32 xstep, ystep; + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; UINT8 *source; UINT8 *colormap; UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - size_t count; - UINT8 val; + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the @@ -1202,62 +1347,61 @@ void R_DrawTranslucentSplat_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; - count = ds_x2 - ds_x1 + 1; while (count >= 8) { // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[0] = *(ds_transmap + (colormap[val] << 8) + dest[0]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[1] = *(ds_transmap + (colormap[val] << 8) + dest[1]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[2] = *(ds_transmap + (colormap[val] << 8) + dest[2]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[3] = *(ds_transmap + (colormap[val] << 8) + dest[3]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[4] = *(ds_transmap + (colormap[val] << 8) + dest[4]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[5] = *(ds_transmap + (colormap[val] << 8) + dest[5]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[6] = *(ds_transmap + (colormap[val] << 8) + dest[6]); xposition += xstep; yposition += ystep; - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) dest[7] = *(ds_transmap + (colormap[val] << 8) + dest[7]); xposition += xstep; @@ -1266,12 +1410,11 @@ void R_DrawTranslucentSplat_8 (void) dest += 8; count -= 8; } - while (count--) + while (count-- && dest <= deststop) { - val = source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]; + val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; if (val != TRANSPARENTPIXEL) *dest = *(ds_transmap + (colormap[val] << 8) + *dest); - dest++; xposition += xstep; yposition += ystep; @@ -1279,9 +1422,91 @@ void R_DrawTranslucentSplat_8 (void) } /** \brief The R_DrawTranslucentSpan_8 function - Draws the actual span with translucent. + Draws the actual span with translucency. */ void R_DrawTranslucentSpan_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest + // can be used for the fraction part. This allows calculation of the memory address in the + // texture with two shifts, an OR and one AND. (see below) + // for texture sizes > 64 the amount of precision we can allow will decrease, but only by one + // bit per power of two (obviously) + // Ok, because I was able to eliminate the variable spot below, this function is now FASTER + // than the original span renderer. Whodathunkit? + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count >= 8) + { + // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't + // have the uber complicated math to calculate it now, so that was a memory write we didn't + // need! + dest[0] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[0]); + xposition += xstep; + yposition += ystep; + + dest[1] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[1]); + xposition += xstep; + yposition += ystep; + + dest[2] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[2]); + xposition += xstep; + yposition += ystep; + + dest[3] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[3]); + xposition += xstep; + yposition += ystep; + + dest[4] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[4]); + xposition += xstep; + yposition += ystep; + + dest[5] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[5]); + xposition += xstep; + yposition += ystep; + + dest[6] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[6]); + xposition += xstep; + yposition += ystep; + + dest[7] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[7]); + xposition += xstep; + yposition += ystep; + + dest += 8; + count -= 8; + } + while (count-- && dest <= deststop) + { + val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest); + dest++; + xposition += xstep; + yposition += ystep; + } +} + +#ifndef NOWATER +void R_DrawTranslucentWaterSpan_8(void) { UINT32 xposition; UINT32 yposition; @@ -1290,6 +1515,7 @@ void R_DrawTranslucentSpan_8 (void) UINT8 *source; UINT8 *colormap; UINT8 *dest; + UINT8 *dsrc; size_t count; @@ -1300,12 +1526,13 @@ void R_DrawTranslucentSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; + xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup; xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; + dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; while (count >= 8) @@ -1313,35 +1540,35 @@ void R_DrawTranslucentSpan_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[0]); + dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[1] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[1]); + dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[2] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[2]); + dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[3] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[3]); + dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[4] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[4]); + dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[5] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[5]); + dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[6] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[6]); + dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; - dest[7] = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + dest[7]); + dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; @@ -1350,12 +1577,12 @@ void R_DrawTranslucentSpan_8 (void) } while (count--) { - *dest = *(ds_transmap + (colormap[source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)]] << 8) + *dest); - dest++; + *dest++ = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; xposition += xstep; yposition += ystep; } } +#endif /** \brief The R_DrawFogSpan_8 function Draws the actual span with fogging. @@ -1481,7 +1708,7 @@ void R_DrawColumnShadowed_8(void) if (dc_yh > realyh) dc_yh = realyh; - basecolfunc(); // R_DrawColumn_8 for the appropriate architecture + (colfuncs[BASEDRAWFUNC])(); // R_DrawColumn_8 for the appropriate architecture if (solid) dc_yl = bheight; else @@ -1491,5 +1718,5 @@ void R_DrawColumnShadowed_8(void) } dc_yh = realyh; if (dc_yl <= realyh) - walldrawerfunc(); // R_DrawWallColumn_8 for the appropriate architecture + (colfuncs[BASEDRAWFUNC])(); // R_DrawWallColumn_8 for the appropriate architecture } diff --git a/src/r_draw8_npo2.c b/src/r_draw8_npo2.c new file mode 100644 index 000000000..b91f492f2 --- /dev/null +++ b/src/r_draw8_npo2.c @@ -0,0 +1,1047 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_draw8_npo2.c +/// \brief 8bpp span drawer functions (for non-powers-of-two flat dimensions) +/// \note no includes because this is included as part of r_draw.c + +// ========================================================================== +// SPANS +// ========================================================================== + +/** \brief The R_DrawSpan_NPO2_8 function + Draws the actual span. +*/ +void R_DrawSpan_NPO2_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + if (dest+8 > deststop) + return; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest++ = colormap[source[((y * ds_flatwidth) + x)]]; + xposition += xstep; + yposition += ystep; + } +} + +#ifdef ESLOPE + +#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) + +/** \brief The R_DrawTiltedSpan_NPO2_8 function + Draw slopes! Holy sheit! +*/ +void R_DrawTiltedSpan_NPO2_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds_szp->x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = ds_source; + //colormap = ds_colormap; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z) + viewx; + v = (INT64)(vz*z) + viewy; + + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = colormap[source[((y * ds_flatwidth) + x)]]; + } + dest++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = colormap[source[((y * ds_flatwidth) + x)]]; + } + dest++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = colormap[source[((y * ds_flatwidth) + x)]]; + } + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = colormap[source[((y * ds_flatwidth) + x)]]; + } + dest++; + u += stepu; + v += stepv; + } + } + } +#endif +} + +/** \brief The R_DrawTiltedTranslucentSpan_NPO2_8 function + Like DrawTiltedSpan_NPO2, but translucent +*/ +void R_DrawTiltedTranslucentSpan_NPO2_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds_szp->x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = ds_source; + //colormap = ds_colormap; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z) + viewx; + v = (INT64)(vz*z) + viewy; + + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); + } + dest++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); + } + dest++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); + } + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); + } + dest++; + u += stepu; + v += stepv; + } + } + } +#endif +} + +void R_DrawTiltedSplat_NPO2_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + + UINT8 val; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds_szp->x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + source = ds_source; + //colormap = ds_colormap; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z) + viewx; + v = (INT64)(vz*z) + viewy; + + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + } + + if (val != TRANSPARENTPIXEL) + *dest = colormap[val]; + + dest++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + } + if (val != TRANSPARENTPIXEL) + *dest = colormap[val]; + dest++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + } + if (val != TRANSPARENTPIXEL) + *dest = colormap[val]; + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + } + if (val != TRANSPARENTPIXEL) + *dest = colormap[val]; + dest++; + u += stepu; + v += stepv; + } + } + } +#endif +} +#endif // ESLOPE + +/** \brief The R_DrawSplat_NPO2_8 function + Just like R_DrawSpan_NPO2_8, but skips transparent pixels. +*/ +void R_DrawSplat_NPO2_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val != TRANSPARENTPIXEL) + *dest = colormap[val]; + dest++; + xposition += xstep; + yposition += ystep; + } +} + +/** \brief The R_DrawTranslucentSplat_NPO2_8 function + Just like R_DrawSplat_NPO2_8, but is translucent! +*/ +void R_DrawTranslucentSplat_NPO2_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = source[((y * ds_flatwidth) + x)]; + if (val != TRANSPARENTPIXEL) + *dest = *(ds_transmap + (colormap[val] << 8) + *dest); + dest++; + xposition += xstep; + yposition += ystep; + } +} + +/** \brief The R_DrawTranslucentSpan_NPO2_8 function + Draws the actual span with translucency. +*/ +void R_DrawTranslucentSpan_NPO2_8 (void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + UINT32 val; + + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + val = ((y * ds_flatwidth) + x); + *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest); + dest++; + xposition += xstep; + yposition += ystep; + } +} + +#ifndef NOWATER +void R_DrawTranslucentWaterSpan_NPO2_8(void) +{ + fixed_t xposition; + fixed_t yposition; + fixed_t xstep, ystep; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + UINT8 *dsrc; + const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + + size_t count = (ds_x2 - ds_x1 + 1); + + xposition = ds_xfrac; yposition = (ds_yfrac + ds_waterofs); + xstep = ds_xstep; ystep = ds_ystep; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; + dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + + while (count-- && dest <= deststop) + { + fixed_t x = (xposition >> FRACBITS); + fixed_t y = (yposition >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)]; + xposition += xstep; + yposition += ystep; + } +} + +#ifdef ESLOPE +/** \brief The R_DrawTiltedTranslucentWaterSpan_NPO2_8 function + Like DrawTiltedTranslucentSpan_NPO2, but for water +*/ +void R_DrawTiltedTranslucentWaterSpan_NPO2_8(void) +{ + // x1, x2 = ds_x1, ds_x2 + int width = ds_x2 - ds_x1; + double iz, uz, vz; + UINT32 u, v; + int i; + + UINT8 *source; + UINT8 *colormap; + UINT8 *dest; + UINT8 *dsrc; + + double startz, startu, startv; + double izstep, uzstep, vzstep; + double endz, endu, endv; + UINT32 stepu, stepv; + + iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); + + // Lighting is simple. It's just linear interpolation from start to end + { + float planelightfloat = PLANELIGHTFLOAT; + float lightstart, lightend; + + lightend = (iz + ds_szp->x*width) * planelightfloat; + lightstart = iz * planelightfloat; + + R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend)); + //CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf); + } + + uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); + vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); + + dest = ylookup[ds_y] + columnofs[ds_x1]; + dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; + source = ds_source; + //colormap = ds_colormap; + +#if 0 // The "perfect" reference version of this routine. Pretty slow. + // Use it only to see how things are supposed to look. + i = 0; + do + { + double z = 1.f/iz; + u = (INT64)(uz*z) + viewx; + v = (INT64)(vz*z) + viewy; + + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); + } + dest++; + iz += ds_szp->x; + uz += ds_sup->x; + vz += ds_svp->x; + } while (--width >= 0); +#else +#define SPANSIZE 16 +#define INVSPAN 0.0625f + + startz = 1.f/iz; + startu = uz*startz; + startv = vz*startz; + + izstep = ds_szp->x * SPANSIZE; + uzstep = ds_sup->x * SPANSIZE; + vzstep = ds_svp->x * SPANSIZE; + //x1 = 0; + width++; + + while (width >= SPANSIZE) + { + iz += izstep; + uz += uzstep; + vz += vzstep; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + stepu = (INT64)((endu - startu) * INVSPAN); + stepv = (INT64)((endv - startv) * INVSPAN); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (i = SPANSIZE-1; i >= 0; i--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); + } + dest++; + u += stepu; + v += stepv; + } + startu = endu; + startv = endv; + width -= SPANSIZE; + } + if (width > 0) + { + if (width == 1) + { + u = (INT64)(startu); + v = (INT64)(startv); + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); + } + } + else + { + double left = width; + iz += ds_szp->x * left; + uz += ds_sup->x * left; + vz += ds_svp->x * left; + + endz = 1.f/iz; + endu = uz*endz; + endv = vz*endz; + left = 1.f/left; + stepu = (INT64)((endu - startu) * left); + stepv = (INT64)((endv - startv) * left); + u = (INT64)(startu) + viewx; + v = (INT64)(startv) + viewy; + + for (; width != 0; width--) + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + // Lactozilla: Non-powers-of-two + { + fixed_t x = (((fixed_t)u-viewx) >> FRACBITS); + fixed_t y = (((fixed_t)v-viewy) >> FRACBITS); + + // Carefully align all of my Friends. + if (x < 0) + x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth); + if (y < 0) + y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight); + + x %= ds_flatwidth; + y %= ds_flatheight; + + *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++); + } + dest++; + u += stepu; + v += stepv; + } + } + } +#endif +} +#endif // ESLOPE +#endif // NOWATER diff --git a/src/r_local.h b/src/r_local.h index 1d3187750..48044118d 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_main.c b/src/r_main.c index 94945af5b..409a82f28 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -19,6 +19,7 @@ #include "r_local.h" #include "r_splats.h" // faB(21jan): testing #include "r_sky.h" +#include "hu_stuff.h" #include "st_stuff.h" #include "p_local.h" #include "keys.h" @@ -28,8 +29,10 @@ #include "d_main.h" #include "v_video.h" #include "p_spec.h" // skyboxmo +#include "p_setup.h" #include "z_zone.h" #include "m_random.h" // quake camera shake +#include "r_portal.h" #ifdef HWRENDER #include "hardware/hw_main.h" @@ -56,6 +59,7 @@ INT32 centerx, centery; fixed_t centerxfrac, centeryfrac; fixed_t projection; fixed_t projectiony; // aspect ratio +fixed_t fovtan; // field of view // just for profiling purposes size_t framecount; @@ -65,36 +69,9 @@ size_t loopcount; fixed_t viewx, viewy, viewz; angle_t viewangle, aimingangle; fixed_t viewcos, viewsin; -boolean viewsky, skyVisible; -boolean skyVisible1, skyVisible2; // saved values of skyVisible for P1 and P2, for splitscreen sector_t *viewsector; player_t *viewplayer; - -// PORTALS! -// You can thank and/or curse JTE for these. -UINT8 portalrender; -sector_t *portalcullsector; -typedef struct portal_pair -{ - INT32 line1; - INT32 line2; - UINT8 pass; - struct portal_pair *next; - - fixed_t viewx; - fixed_t viewy; - fixed_t viewz; - angle_t viewangle; - - INT32 start; - INT32 end; - INT16 *ceilingclip; - INT16 *floorclip; - fixed_t *frontscale; -} portal_pair; -portal_pair *portal_base, *portal_cap; -line_t *portalclipline; -INT32 portalclipstart, portalclipend; +mobj_t *r_viewmobj; // // precalculated math tables @@ -118,19 +95,27 @@ lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; // Hack to support extra boom colormaps. -size_t num_extra_colormaps; -extracolormap_t extra_colormaps[MAXCOLORMAPS]; +extracolormap_t *extra_colormaps = NULL; static CV_PossibleValue_t drawdist_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; + +//static CV_PossibleValue_t precipdensity_cons_t[] = {{0, "None"}, {1, "Light"}, {2, "Moderate"}, {4, "Heavy"}, {6, "Thick"}, {8, "V.Thick"}, {0, NULL}}; + +static CV_PossibleValue_t drawdist_precip_cons_t[] = { + {256, "256"}, {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {0, "None"}, {0, NULL}}; + +static CV_PossibleValue_t fov_cons_t[] = {{60*FRACUNIT, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}}; +static void Fov_OnChange(void); static void ChaseCam_OnChange(void); static void ChaseCam2_OnChange(void); static void FlipCam_OnChange(void); @@ -144,10 +129,8 @@ consvar_t cv_chasecam2 = {"chasecam2", "On", CV_CALL, CV_OnOff, ChaseCam2_OnChan consvar_t cv_flipcam = {"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_flipcam2 = {"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shadow = {"shadow", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_shadow = {"shadow", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -155,8 +138,9 @@ consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_c consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +//consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; // Okay, whoever said homremoval causes a performance hit should be shot. consvar_t cv_homremoval = {"homremoval", "No", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -200,23 +184,31 @@ void SplitScreen_OnChange(void) } } } +static void Fov_OnChange(void) +{ + // Shouldn't be needed with render parity? + //if ((netgame || multiplayer) && !cv_debug && cv_fov.value != 90*FRACUNIT) + // CV_Set(&cv_fov, cv_fov.defaultvalue); + + R_SetViewSize(); +} static void ChaseCam_OnChange(void) { - if (!cv_chasecam.value || !cv_useranalog.value) - CV_SetValue(&cv_analog, 0); + if (!cv_chasecam.value || !cv_useranalog[0].value) + CV_SetValue(&cv_analog[0], 0); else - CV_SetValue(&cv_analog, 1); + CV_SetValue(&cv_analog[0], 1); } static void ChaseCam2_OnChange(void) { if (botingame) return; - if (!cv_chasecam2.value || !cv_useranalog2.value) - CV_SetValue(&cv_analog2, 0); + if (!cv_chasecam2.value || !cv_useranalog[1].value) + CV_SetValue(&cv_analog[1], 0); else - CV_SetValue(&cv_analog2, 1); + CV_SetValue(&cv_analog[1], 1); } static void FlipCam_OnChange(void) @@ -464,8 +456,8 @@ static void R_InitTextureMapping(void) // // Calc focallength // so FIELDOFVIEW angles covers SCREENWIDTH. - focallength = FixedDiv(centerxfrac, - FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2)); + focallength = FixedDiv(projection, + FINETANGENT(FINEANGLES/4+FIELDOFVIEW/2)); #ifdef ESLOPE focallengthf = FIXED_TO_FLOAT(focallength); @@ -473,9 +465,9 @@ static void R_InitTextureMapping(void) for (i = 0; i < FINEANGLES/2; i++) { - if (FINETANGENT(i) > FRACUNIT*2) + if (FINETANGENT(i) > fovtan*2) t = -1; - else if (FINETANGENT(i) < -FRACUNIT*2) + else if (FINETANGENT(i) < -fovtan*2) t = viewwidth+1; else { @@ -555,6 +547,303 @@ static inline void R_InitLightTables(void) } } +//#define WOUGHMP_WOUGHMP // I got a fish-eye lens - I'll make a rap video with a couple of friends +// it's kinda laggy sometimes + +static struct { + angle_t rollangle; // pre-shifted by fineshift +#ifdef WOUGHMP_WOUGHMP + fixed_t fisheye; +#endif + + fixed_t zoomneeded; + INT32 *scrmap; + INT32 scrmapsize; + + INT32 x1; // clip rendering horizontally for efficiency + INT16 ceilingclip[MAXVIDWIDTH], floorclip[MAXVIDWIDTH]; + + boolean use; +} viewmorph = { + 0, +#ifdef WOUGHMP_WOUGHMP + 0, +#endif + + FRACUNIT, + NULL, + 0, + + 0, + {}, {}, + + false +}; + +void R_CheckViewMorph(void) +{ + float zoomfactor, rollcos, rollsin; + float x1, y1, x2, y2; + fixed_t temp; + INT32 end, vx, vy, pos, usedpos; + INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; +#ifdef WOUGHMP_WOUGHMP + float fisheyemap[MAXVIDWIDTH/2 + 1]; +#endif + + angle_t rollangle = players[displayplayer].viewrollangle; +#ifdef WOUGHMP_WOUGHMP + fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value +#endif + + rollangle >>= ANGLETOFINESHIFT; + rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. + +#ifdef WOUGHMP_WOUGHMP + fisheye &= ~0x7FF; // Same +#endif + + if (rollangle == viewmorph.rollangle && +#ifdef WOUGHMP_WOUGHMP + fisheye == viewmorph.fisheye && +#endif + viewmorph.scrmapsize == vid.width*vid.height) + return; // No change + + viewmorph.rollangle = rollangle; +#ifdef WOUGHMP_WOUGHMP + viewmorph.fisheye = fisheye; +#endif + + if (viewmorph.rollangle == 0 +#ifdef WOUGHMP_WOUGHMP + && viewmorph.fisheye == 0 +#endif + ) + { + viewmorph.use = false; + viewmorph.x1 = 0; + if (viewmorph.zoomneeded != FRACUNIT) + R_SetViewSize(); + viewmorph.zoomneeded = FRACUNIT; + + return; + } + + if (viewmorph.scrmapsize != vid.width*vid.height) + { + if (viewmorph.scrmap) + free(viewmorph.scrmap); + viewmorph.scrmap = malloc(vid.width*vid.height * sizeof(INT32)); + viewmorph.scrmapsize = vid.width*vid.height; + } + + temp = FINECOSINE(rollangle); + rollcos = FIXED_TO_FLOAT(temp); + temp = FINESINE(rollangle); + rollsin = FIXED_TO_FLOAT(temp); + + // Calculate maximum zoom needed + x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width; + y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height; + +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + { + float f = FIXED_TO_FLOAT(fisheye); + for (vx = 0; vx <= halfwidth; vx++) + fisheyemap[vx] = 1.0f / cos(atan(vx * f / halfwidth)); + + f = cos(atan(f)); + if (f < 1.0f) + { + x1 /= f; + y1 /= f; + } + } +#endif + + temp = max(x1, y1)*FRACUNIT; + if (temp < FRACUNIT) + temp = FRACUNIT; + else + temp |= 0x3FFF; // Limit how many times the viewport needs to be recalculated + + //CONS_Printf("Setting zoom to %f\n", FIXED_TO_FLOAT(temp)); + + if (temp != viewmorph.zoomneeded) + { + viewmorph.zoomneeded = temp; + R_SetViewSize(); + } + + zoomfactor = FIXED_TO_FLOAT(viewmorph.zoomneeded); + + end = vid.width * vid.height - 1; + + pos = 0; + + // Pre-multiply rollcos and rollsin to use for positional stuff + rollcos /= zoomfactor; + rollsin /= zoomfactor; + + x1 = -(halfwidth * rollcos - halfheight * rollsin); + y1 = -(halfheight * rollcos + halfwidth * rollsin); + +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin)) * fisheyemap[halfwidth]); + else +#endif + viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin))); + //CONS_Printf("saving %d cols\n", viewmorph.x1); + + // Set ceilingclip and floorclip + for (vx = 0; vx < vid.width; vx++) + { + viewmorph.ceilingclip[vx] = vid.height; + viewmorph.floorclip[vx] = -1; + } + x2 = x1; + y2 = y1; + for (vx = 0; vx < vid.width; vx++) + { + INT16 xa, ya, xb, yb; + xa = x2+halfwidth; + ya = y2+halfheight-1; + xb = vid.width-1-xa; + yb = vid.height-1-ya; + + viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + x2 += rollcos; + y2 += rollsin; + } + x2 = x1; + y2 = y1; + for (vy = 0; vy < vid.height; vy++) + { + INT16 xa, ya, xb, yb; + xa = x2+halfwidth; + ya = y2+halfheight; + xb = vid.width-1-xa; + yb = vid.height-1-ya; + + viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya); + viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya); + viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb); + viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb); + x2 -= rollsin; + y2 += rollcos; + } + + //CONS_Printf("Top left corner is %f %f\n", x1, y1); + +#ifdef WOUGHMP_WOUGHMP + if (fisheye) + { + for (vy = 0; vy < halfheight; vy++) + { + x2 = x1; + y2 = y1; + x1 -= rollsin; + y1 += rollcos; + + for (vx = 0; vx < vid.width; vx++) + { + usedx = halfwidth + x2*fisheyemap[(int) floorf(fabsf(y2*zoomfactor))]; + usedy = halfheight + y2*fisheyemap[(int) floorf(fabsf(x2*zoomfactor))]; + + usedpos = usedx + usedy*vid.width; + + viewmorph.scrmap[pos] = usedpos; + viewmorph.scrmap[end-pos] = end-usedpos; + + x2 += rollcos; + y2 += rollsin; + pos++; + } + } + } + else + { +#endif + x1 += halfwidth; + y1 += halfheight; + + for (vy = 0; vy < halfheight; vy++) + { + x2 = x1; + y2 = y1; + x1 -= rollsin; + y1 += rollcos; + + for (vx = 0; vx < vid.width; vx++) + { + usedx = x2; + usedy = y2; + + usedpos = usedx + usedy*vid.width; + + viewmorph.scrmap[pos] = usedpos; + viewmorph.scrmap[end-pos] = end-usedpos; + + x2 += rollcos; + y2 += rollsin; + pos++; + } + } +#ifdef WOUGHMP_WOUGHMP + } +#endif + + viewmorph.use = true; +} + +void R_ApplyViewMorph(void) +{ + UINT8 *tmpscr = screens[4]; + UINT8 *srcscr = screens[0]; + INT32 p, end = vid.width * vid.height; + + if (!viewmorph.use) + return; + + if (cv_debug & DBG_VIEWMORPH) + { + UINT8 border = 32; + UINT8 grid = 160; + INT32 ws = vid.width / 4; + INT32 hs = vid.width * (vid.height / 4); + + memcpy(tmpscr, srcscr, vid.width*vid.height); + for (p = 0; p < vid.width; p++) + { + tmpscr[viewmorph.scrmap[p]] = border; + tmpscr[viewmorph.scrmap[p + hs]] = grid; + tmpscr[viewmorph.scrmap[p + hs*2]] = grid; + tmpscr[viewmorph.scrmap[p + hs*3]] = grid; + tmpscr[viewmorph.scrmap[end - 1 - p]] = border; + } + for (p = vid.width; p < end; p += vid.width) + { + tmpscr[viewmorph.scrmap[p]] = border; + tmpscr[viewmorph.scrmap[p + ws]] = grid; + tmpscr[viewmorph.scrmap[p + ws*2]] = grid; + tmpscr[viewmorph.scrmap[p + ws*3]] = grid; + tmpscr[viewmorph.scrmap[end - 1 - p]] = border; + } + } + else + for (p = 0; p < end; p++) + tmpscr[p] = srcscr[viewmorph.scrmap[p]]; + + VID_BlitLinearScreen(tmpscr, screens[0], + vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); +} + // // R_SetViewSize @@ -579,6 +868,7 @@ void R_ExecuteSetViewSize(void) INT32 j; INT32 level; INT32 startmapl; + angle_t fov; setsizeneeded = false; @@ -601,9 +891,12 @@ void R_ExecuteSetViewSize(void) centerxfrac = centerx<> ANGLETOFINESHIFT), viewmorph.zoomneeded); + if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view + fovtan = 17*fovtan/10; + + projection = projectiony = FixedDiv(centerxfrac, fovtan); R_InitViewBuffer(scaledviewwidth, viewheight); @@ -629,7 +922,7 @@ void R_ExecuteSetViewSize(void) for (i = 0; i < j; i++) { dy = ((i - viewheight*8)<numlines; i++) - //if (R_PointOnSegSide(x, y, &segs[ret->firstline + i])) -- breaks in ogl because polyvertex_t cast over vertex pointers - if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side) + for (i = 0, seg = &segs[ret->firstline]; i < ret->numlines; i++, seg++) + { + if (seg->glseg) + continue; + + //if (R_PointOnSegSide(x, y, seg)) -- breaks in ogl because polyvertex_t cast over vertex pointers + if (P_PointOnLineSide(x, y, seg->linedef) != seg->side) return 0; + } return ret; } @@ -741,10 +1040,8 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) // R_SetupFrame // -static mobj_t *viewmobj; - // WARNING: a should be unsigned but to add with 2048, it isn't! -#define AIMINGTODY(a) ((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS) +#define AIMINGTODY(a) ((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)/fovtan) // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). @@ -766,7 +1063,7 @@ static void R_SetupFreelook(void) #undef AIMINGTODY -void R_SetupFrame(player_t *player, boolean skybox) +void R_SetupFrame(player_t *player) { camera_t *thiscam; boolean chasecam = false; @@ -783,7 +1080,7 @@ void R_SetupFrame(player_t *player, boolean skybox) chasecam = (cv_chasecam.value != 0); } - if (player->climbing || (player->pflags & PF_NIGHTSMODE) || player->playerstate == PST_DEAD) + if (player->climbing || (player->powers[pw_carry] == CR_NIGHTSMODE) || player->playerstate == PST_DEAD || gamestate == GS_TITLESCREEN || tutorialmode) chasecam = true; // force chasecam on else if (player->spectator) // no spectator chasecam chasecam = false; // force chasecam off @@ -796,20 +1093,19 @@ void R_SetupFrame(player_t *player, boolean skybox) else if (!chasecam) thiscam->chase = false; - viewsky = !skybox; if (player->awayviewtics) { // cut-away view stuff - viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN - I_Assert(viewmobj != NULL); - viewz = viewmobj->z + 20*FRACUNIT; + r_viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN + I_Assert(r_viewmobj != NULL); + viewz = r_viewmobj->z + 20*FRACUNIT; aimingangle = player->awayviewaiming; - viewangle = viewmobj->angle; + viewangle = r_viewmobj->angle; } else if (!player->spectator && chasecam) // use outside cam view { - viewmobj = NULL; + r_viewmobj = NULL; viewz = thiscam->z + (thiscam->height>>1); aimingangle = thiscam->aiming; viewangle = thiscam->angle; @@ -819,11 +1115,11 @@ void R_SetupFrame(player_t *player, boolean skybox) { viewz = player->viewz; - viewmobj = player->mo; - I_Assert(viewmobj != NULL); + r_viewmobj = player->mo; + I_Assert(r_viewmobj != NULL); aimingangle = player->aiming; - viewangle = viewmobj->angle; + viewangle = r_viewmobj->angle; if (!demoplayback && player->playerstate != PST_DEAD) { @@ -857,13 +1153,13 @@ void R_SetupFrame(player_t *player, boolean skybox) } else { - viewx = viewmobj->x; - viewy = viewmobj->y; + viewx = r_viewmobj->x; + viewy = r_viewmobj->y; viewx += quake.x; viewy += quake.y; - if (viewmobj->subsector) - viewsector = viewmobj->subsector->sector; + if (r_viewmobj->subsector) + viewsector = r_viewmobj->subsector->sector; else viewsector = R_PointInSubsector(viewx, viewy)->sector; } @@ -885,13 +1181,12 @@ void R_SkyboxFrame(player_t *player) thiscam = &camera; // cut-away view stuff - viewsky = true; - viewmobj = skyboxmo[0]; + r_viewmobj = skyboxmo[0]; #ifdef PARANOIA - if (!viewmobj) + if (!r_viewmobj) { const size_t playeri = (size_t)(player - players); - I_Error("R_SkyboxFrame: viewmobj null (player %s)", sizeu1(playeri)); + I_Error("R_SkyboxFrame: r_viewmobj null (player %s)", sizeu1(playeri)); } #endif if (player->awayviewtics) @@ -922,167 +1217,87 @@ void R_SkyboxFrame(player_t *player) } } } - viewangle += viewmobj->angle; + viewangle += r_viewmobj->angle; viewplayer = player; - viewx = viewmobj->x; - viewy = viewmobj->y; - viewz = 0; - if (viewmobj->spawnpoint) - viewz = ((fixed_t)viewmobj->spawnpoint->angle)<x; + viewy = r_viewmobj->y; + viewz = r_viewmobj->z; // 26/04/17: use actual Z position instead of spawnpoint angle! if (mapheaderinfo[gamemap-1]) { mapheader_t *mh = mapheaderinfo[gamemap-1]; - if (player->awayviewtics) - { - if (skyboxmo[1]) - { - fixed_t x = 0, y = 0; - if (mh->skybox_scalex > 0) - x = (player->awayviewmobj->x - skyboxmo[1]->x) / mh->skybox_scalex; - else if (mh->skybox_scalex < 0) - x = (player->awayviewmobj->x - skyboxmo[1]->x) * -mh->skybox_scalex; + vector3_t campos = {0,0,0}; // Position of player's actual view point - if (mh->skybox_scaley > 0) - y = (player->awayviewmobj->y - skyboxmo[1]->y) / mh->skybox_scaley; - else if (mh->skybox_scaley < 0) - y = (player->awayviewmobj->y - skyboxmo[1]->y) * -mh->skybox_scaley; - - if (viewmobj->angle == 0) - { - viewx += x; - viewy += y; - } - else if (viewmobj->angle == ANGLE_90) - { - viewx -= y; - viewy += x; - } - else if (viewmobj->angle == ANGLE_180) - { - viewx -= x; - viewy -= y; - } - else if (viewmobj->angle == ANGLE_270) - { - viewx += y; - viewy -= x; - } - else - { - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT; - viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); - } - } - if (mh->skybox_scalez > 0) - viewz += (player->awayviewmobj->z + 20*FRACUNIT) / mh->skybox_scalez; - else if (mh->skybox_scalez < 0) - viewz += (player->awayviewmobj->z + 20*FRACUNIT) * -mh->skybox_scalez; + if (player->awayviewtics) { + campos.x = player->awayviewmobj->x; + campos.y = player->awayviewmobj->y; + campos.z = player->awayviewmobj->z + 20*FRACUNIT; + } else if (thiscam->chase) { + campos.x = thiscam->x; + campos.y = thiscam->y; + campos.z = thiscam->z + (thiscam->height>>1); + } else { + campos.x = player->mo->x; + campos.y = player->mo->y; + campos.z = player->viewz; } - else if (thiscam->chase) + + // Earthquake effects should be scaled in the skybox + // (if an axis isn't used, the skybox won't shake in that direction) + campos.x += quake.x; + campos.y += quake.y; + campos.z += quake.z; + + if (skyboxmo[1]) // Is there a viewpoint? { - if (skyboxmo[1]) + fixed_t x = 0, y = 0; + if (mh->skybox_scalex > 0) + x = (campos.x - skyboxmo[1]->x) / mh->skybox_scalex; + else if (mh->skybox_scalex < 0) + x = (campos.x - skyboxmo[1]->x) * -mh->skybox_scalex; + + if (mh->skybox_scaley > 0) + y = (campos.y - skyboxmo[1]->y) / mh->skybox_scaley; + else if (mh->skybox_scaley < 0) + y = (campos.y - skyboxmo[1]->y) * -mh->skybox_scaley; + + if (r_viewmobj->angle == 0) { - fixed_t x = 0, y = 0; - if (mh->skybox_scalex > 0) - x = (thiscam->x - skyboxmo[1]->x) / mh->skybox_scalex; - else if (mh->skybox_scalex < 0) - x = (thiscam->x - skyboxmo[1]->x) * -mh->skybox_scalex; - - if (mh->skybox_scaley > 0) - y = (thiscam->y - skyboxmo[1]->y) / mh->skybox_scaley; - else if (mh->skybox_scaley < 0) - y = (thiscam->y - skyboxmo[1]->y) * -mh->skybox_scaley; - - if (viewmobj->angle == 0) - { - viewx += x; - viewy += y; - } - else if (viewmobj->angle == ANGLE_90) - { - viewx -= y; - viewy += x; - } - else if (viewmobj->angle == ANGLE_180) - { - viewx -= x; - viewy -= y; - } - else if (viewmobj->angle == ANGLE_270) - { - viewx += y; - viewy -= x; - } - else - { - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT; - viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); - } + viewx += x; + viewy += y; } - if (mh->skybox_scalez > 0) - viewz += (thiscam->z + (thiscam->height>>1)) / mh->skybox_scalez; - else if (mh->skybox_scalez < 0) - viewz += (thiscam->z + (thiscam->height>>1)) * -mh->skybox_scalez; - } - else - { - if (skyboxmo[1]) + else if (r_viewmobj->angle == ANGLE_90) { - fixed_t x = 0, y = 0; - if (mh->skybox_scalex > 0) - x = (player->mo->x - skyboxmo[1]->x) / mh->skybox_scalex; - else if (mh->skybox_scalex < 0) - x = (player->mo->x - skyboxmo[1]->x) * -mh->skybox_scalex; - if (mh->skybox_scaley > 0) - y = (player->mo->y - skyboxmo[1]->y) / mh->skybox_scaley; - else if (mh->skybox_scaley < 0) - y = (player->mo->y - skyboxmo[1]->y) * -mh->skybox_scaley; - - if (viewmobj->angle == 0) - { - viewx += x; - viewy += y; - } - else if (viewmobj->angle == ANGLE_90) - { - viewx -= y; - viewy += x; - } - else if (viewmobj->angle == ANGLE_180) - { - viewx -= x; - viewy -= y; - } - else if (viewmobj->angle == ANGLE_270) - { - viewx += y; - viewy -= x; - } - else - { - angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT; - viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); - } + viewx -= y; + viewy += x; + } + else if (r_viewmobj->angle == ANGLE_180) + { + viewx -= x; + viewy -= y; + } + else if (r_viewmobj->angle == ANGLE_270) + { + viewx += y; + viewy -= x; + } + else + { + angle_t ang = r_viewmobj->angle>>ANGLETOFINESHIFT; + viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); + viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); } - if (mh->skybox_scalez > 0) - viewz += player->viewz / mh->skybox_scalez; - else if (mh->skybox_scalez < 0) - viewz += player->viewz * -mh->skybox_scalez; } + if (mh->skybox_scalez > 0) + viewz += campos.z / mh->skybox_scalez; + else if (mh->skybox_scalez < 0) + viewz += campos.z * -mh->skybox_scalez; } - if (viewmobj->subsector) - viewsector = viewmobj->subsector->sector; + if (r_viewmobj->subsector) + viewsector = r_viewmobj->subsector->sector; else viewsector = R_PointInSubsector(viewx, viewy)->sector; @@ -1092,17 +1307,8 @@ void R_SkyboxFrame(player_t *player) R_SetupFreelook(); } -#define ANGLED_PORTALS - -static void R_PortalFrame(line_t *start, line_t *dest, portal_pair *portal) +static void R_PortalFrame(portal_t *portal) { - vertex_t dest_c, start_c; -#ifdef ANGLED_PORTALS - // delta angle - angle_t dangle = R_PointToAngle2(0,0,dest->dx,dest->dy) - R_PointToAngle2(start->dx,start->dy,0,0); -#endif - - //R_SetupFrame(player, false); viewx = portal->viewx; viewy = portal->viewy; viewz = portal->viewz; @@ -1111,96 +1317,39 @@ static void R_PortalFrame(line_t *start, line_t *dest, portal_pair *portal) viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - portalcullsector = dest->frontsector; - viewsector = dest->frontsector; - portalclipline = dest; portalclipstart = portal->start; portalclipend = portal->end; - // Offset the portal view by the linedef centers - - // looking glass center - start_c.x = (start->v1->x + start->v2->x) / 2; - start_c.y = (start->v1->y + start->v2->y) / 2; - - // other side center - dest_c.x = (dest->v1->x + dest->v2->x) / 2; - dest_c.y = (dest->v1->y + dest->v2->y) / 2; - - // Heights! - viewz += dest->frontsector->floorheight - start->frontsector->floorheight; - - // calculate the difference in position and rotation! -#ifdef ANGLED_PORTALS - if (dangle == 0) -#endif - { // the entrance goes straight opposite the exit, so we just need to mess with the offset. - viewx += dest_c.x - start_c.x; - viewy += dest_c.y - start_c.y; - return; - } - -#ifdef ANGLED_PORTALS - viewangle += dangle; - viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - //CONS_Printf("dangle == %u\n", AngleFixed(dangle)>>FRACBITS); - - // ???? + if (portal->clipline != -1) { - fixed_t disttopoint; - angle_t angtopoint; - - disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); - angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); - angtopoint += dangle; - - viewx = dest_c.x+FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); - viewy = dest_c.y+FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); - } -#endif -} - -void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2) -{ - portal_pair *portal = Z_Malloc(sizeof(portal_pair), PU_LEVEL, NULL); - INT16 *ceilingclipsave = Z_Malloc(sizeof(INT16)*(x2-x1), PU_LEVEL, NULL); - INT16 *floorclipsave = Z_Malloc(sizeof(INT16)*(x2-x1), PU_LEVEL, NULL); - fixed_t *frontscalesave = Z_Malloc(sizeof(fixed_t)*(x2-x1), PU_LEVEL, NULL); - - portal->line1 = line1; - portal->line2 = line2; - portal->pass = portalrender+1; - portal->next = NULL; - - R_PortalStoreClipValues(x1, x2, ceilingclipsave, floorclipsave, frontscalesave); - - portal->ceilingclip = ceilingclipsave; - portal->floorclip = floorclipsave; - portal->frontscale = frontscalesave; - - portal->start = x1; - portal->end = x2; - - portalline = true; // this tells R_StoreWallRange that curline is a portal seg - - portal->viewx = viewx; - portal->viewy = viewy; - portal->viewz = viewz; - portal->viewangle = viewangle; - - if (!portal_base) - { - portal_base = portal; - portal_cap = portal; + portalclipline = &lines[portal->clipline]; + portalcullsector = portalclipline->frontsector; + viewsector = portalclipline->frontsector; } else { - portal_cap->next = portal; - portal_cap = portal; + portalclipline = NULL; + portalcullsector = NULL; + viewsector = R_PointInSubsector(viewx, viewy)->sector; } } +static void Mask_Pre (maskcount_t* m) +{ + m->drawsegs[0] = ds_p - drawsegs; + m->vissprites[0] = visspritecount; + m->viewx = viewx; + m->viewy = viewy; + m->viewz = viewz; + m->viewsector = viewsector; +} + +static void Mask_Post (maskcount_t* m) +{ + m->drawsegs[1] = ds_p - drawsegs; + m->vissprites[1] = visspritecount; +} + // ================ // R_RenderView // ================ @@ -1213,73 +1362,57 @@ void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2) void R_RenderPlayerView(player_t *player) { - portal_pair *portal; - const boolean skybox = (skyboxmo[0] && cv_skybox.value); + UINT8 nummasks = 1; + maskcount_t* masks = malloc(sizeof(maskcount_t)); if (cv_homremoval.value && player == &players[displayplayer]) // if this is display player 1 { if (cv_homremoval.value == 1) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // No HOM effect! else //'development' HOM removal -- makes it blindingly obvious if HOM is spotted. - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 128+(timeinmap&15)); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 32+(timeinmap&15)); } - // load previous saved value of skyVisible for the player - if (splitscreen && player == &players[secondarydisplayplayer]) - skyVisible = skyVisible2; - else - skyVisible = skyVisible1; - - portalrender = 0; - portal_base = portal_cap = NULL; - - if (skybox && skyVisible) - { - R_SkyboxFrame(player); - - R_ClearClipSegs(); - R_ClearDrawSegs(); - R_ClearPlanes(); - R_ClearSprites(); -#ifdef FLOORSPLATS - R_ClearVisibleFloorSplats(); -#endif - - R_RenderBSPNode((INT32)numnodes - 1); - R_ClipSprites(); - R_DrawPlanes(); -#ifdef FLOORSPLATS - R_DrawVisibleFloorSplats(); -#endif - R_DrawMasked(); - } - - R_SetupFrame(player, skybox); - skyVisible = false; + R_SetupFrame(player); framecount++; validcount++; // Clear buffers. - R_ClearClipSegs(); - R_ClearDrawSegs(); R_ClearPlanes(); + if (viewmorph.use) + { + portalclipstart = viewmorph.x1; + portalclipend = viewwidth-viewmorph.x1-1; + R_PortalClearClipSegs(portalclipstart, portalclipend); + memcpy(ceilingclip, viewmorph.ceilingclip, sizeof(INT16)*vid.width); + memcpy(floorclip, viewmorph.floorclip, sizeof(INT16)*vid.width); + } + else + { + portalclipstart = 0; + portalclipend = viewwidth-1; + R_ClearClipSegs(); + } + R_ClearDrawSegs(); R_ClearSprites(); #ifdef FLOORSPLATS R_ClearVisibleFloorSplats(); #endif + Portal_InitList(); // check for new console commands. NetUpdate(); // The head node is the last node output. + Mask_Pre(&masks[nummasks - 1]); + curdrawsegs = ds_p; //profile stuff --------------------------------------------------------- #ifdef TIMING mytotal = 0; ProfZeroTimer(); #endif R_RenderBSPNode((INT32)numnodes - 1); - R_ClipSprites(); #ifdef TIMING RDMSR(0x10, &mycount); mytotal += mycount; // 64bit add @@ -1287,54 +1420,86 @@ void R_RenderPlayerView(player_t *player) CONS_Debug(DBG_RENDER, "RenderBSPNode: 0x%d %d\n", *((INT32 *)&mytotal + 1), (INT32)mytotal); #endif //profile stuff --------------------------------------------------------- + Mask_Post(&masks[nummasks - 1]); - // PORTAL RENDERING - for(portal = portal_base; portal; portal = portal_base) + R_ClipSprites(drawsegs, NULL); + + + // Add skybox portals caused by sky visplanes. + if (cv_skybox.value && skyboxmo[0]) + Portal_AddSkyboxPortals(); + + // Portal rendering. Hijacks the BSP traversal. + if (portal_base) { - // render the portal - CONS_Debug(DBG_RENDER, "Rendering portal from line %d to %d\n", portal->line1, portal->line2); - portalrender = portal->pass; + portal_t *portal; - R_PortalFrame(&lines[portal->line1], &lines[portal->line2], portal); + for(portal = portal_base; portal; portal = portal_base) + { + portalrender = portal->pass; // Recursiveness depth. - R_PortalClearClipSegs(portal->start, portal->end); + R_ClearFFloorClips(); - R_PortalRestoreClipValues(portal->start, portal->end, portal->ceilingclip, portal->floorclip, portal->frontscale); + // Apply the viewpoint stored for the portal. + R_PortalFrame(portal); - validcount++; + // Hack in the clipsegs to delimit the starting + // clipping for sprites and possibly other similar + // future items. + R_PortalClearClipSegs(portal->start, portal->end); - R_RenderBSPNode((INT32)numnodes - 1); - R_ClipSprites(); - //R_DrawPlanes(); - //R_DrawMasked(); + // Hack in the top/bottom clip values for the window + // that were previously stored. + Portal_ClipApply(portal); - // okay done. free it. - portalcullsector = NULL; // Just in case... - portal_base = portal->next; - Z_Free(portal->ceilingclip); - Z_Free(portal->floorclip); - Z_Free(portal->frontscale); - Z_Free(portal); + validcount++; + + masks = realloc(masks, (++nummasks)*sizeof(maskcount_t)); + + Mask_Pre(&masks[nummasks - 1]); + curdrawsegs = ds_p; + + // Render the BSP from the new viewpoint, and clip + // any sprites with the new clipsegs and window. + R_RenderBSPNode((INT32)numnodes - 1); + Mask_Post(&masks[nummasks - 1]); + + R_ClipSprites(ds_p - (masks[nummasks - 1].drawsegs[1] - masks[nummasks - 1].drawsegs[0]), portal); + + Portal_Remove(portal); + } } - // END PORTAL RENDERING R_DrawPlanes(); #ifdef FLOORSPLATS R_DrawVisibleFloorSplats(); #endif + // draw mid texture and sprite // And now 3D floors/sides! - R_DrawMasked(); + R_DrawMasked(masks, nummasks); - // Check for new console commands. - NetUpdate(); + free(masks); +} - // save value to skyVisible1 or skyVisible2 - // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa - if (splitscreen && player == &players[secondarydisplayplayer]) - skyVisible2 = skyVisible; - else - skyVisible1 = skyVisible; +// Lactozilla: Renderer switching +#ifdef HWRENDER +void R_InitHardwareMode(void) +{ + HWR_AddSessionCommands(); + HWR_Switch(); + HWR_LoadTextures(numtextures); + if (gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction)) + HWR_SetupLevel(); +} +#endif + +void R_ReloadHUDGraphics(void) +{ + CONS_Debug(DBG_RENDER, "R_ReloadHUDGraphics()...\n"); + ST_LoadGraphics(); + HU_LoadGraphics(); + ST_ReloadSkinFaceGraphics(); } // ========================================================================= @@ -1345,7 +1510,6 @@ void R_RegisterEngineStuff(void) { CV_RegisterVar(&cv_gravity); CV_RegisterVar(&cv_tailspickup); - CV_RegisterVar(&cv_soniccd); CV_RegisterVar(&cv_allowmlook); CV_RegisterVar(&cv_homremoval); CV_RegisterVar(&cv_flipcam); @@ -1355,16 +1519,16 @@ void R_RegisterEngineStuff(void) if (dedicated) return; - CV_RegisterVar(&cv_precipdensity); CV_RegisterVar(&cv_translucency); CV_RegisterVar(&cv_drawdist); CV_RegisterVar(&cv_drawdist_nights); CV_RegisterVar(&cv_drawdist_precip); + CV_RegisterVar(&cv_fov); CV_RegisterVar(&cv_chasecam); CV_RegisterVar(&cv_chasecam2); + CV_RegisterVar(&cv_shadow); - CV_RegisterVar(&cv_shadowoffs); CV_RegisterVar(&cv_skybox); CV_RegisterVar(&cv_cam_dist); @@ -1373,6 +1537,9 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_speed); CV_RegisterVar(&cv_cam_rotate); CV_RegisterVar(&cv_cam_rotspeed); + CV_RegisterVar(&cv_cam_turnmultiplier); + CV_RegisterVar(&cv_cam_orbit); + CV_RegisterVar(&cv_cam_adjust); CV_RegisterVar(&cv_cam2_dist); CV_RegisterVar(&cv_cam2_still); @@ -1380,37 +1547,24 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam2_speed); CV_RegisterVar(&cv_cam2_rotate); CV_RegisterVar(&cv_cam2_rotspeed); + CV_RegisterVar(&cv_cam2_turnmultiplier); + CV_RegisterVar(&cv_cam2_orbit); + CV_RegisterVar(&cv_cam2_adjust); + + CV_RegisterVar(&cv_cam_savedist[0][0]); + CV_RegisterVar(&cv_cam_savedist[0][1]); + CV_RegisterVar(&cv_cam_savedist[1][0]); + CV_RegisterVar(&cv_cam_savedist[1][1]); + + CV_RegisterVar(&cv_cam_saveheight[0][0]); + CV_RegisterVar(&cv_cam_saveheight[0][1]); + CV_RegisterVar(&cv_cam_saveheight[1][0]); + CV_RegisterVar(&cv_cam_saveheight[1][1]); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); CV_RegisterVar(&cv_maxportals); - // Default viewheight is changeable, - // initialized to standard viewheight - CV_RegisterVar(&cv_viewheight); - -#ifdef HWRENDER - // GL-specific Commands - CV_RegisterVar(&cv_grgammablue); - CV_RegisterVar(&cv_grgammagreen); - CV_RegisterVar(&cv_grgammared); - CV_RegisterVar(&cv_grfovchange); - CV_RegisterVar(&cv_grfog); - CV_RegisterVar(&cv_voodoocompatibility); - CV_RegisterVar(&cv_grfogcolor); - CV_RegisterVar(&cv_grsoftwarefog); -#ifdef ALAM_LIGHTING - CV_RegisterVar(&cv_grstaticlighting); - CV_RegisterVar(&cv_grdynamiclighting); - CV_RegisterVar(&cv_grcoronas); - CV_RegisterVar(&cv_grcoronasize); -#endif - CV_RegisterVar(&cv_grmd2); -#endif - -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - HWR_AddCommands(); -#endif + CV_RegisterVar(&cv_movebob); } diff --git a/src/r_main.h b/src/r_main.h index 6ae5aa221..0a48df412 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -26,6 +26,7 @@ extern INT32 centerx, centery; extern fixed_t centerxfrac, centeryfrac; extern fixed_t projection, projectiony; +extern fixed_t fovtan; // field of view extern size_t validcount, linecount, loopcount, framecount; @@ -45,6 +46,8 @@ extern size_t validcount, linecount, loopcount, framecount; #define MAXLIGHTZ 128 #define LIGHTZSHIFT 20 +#define LIGHTRESOLUTIONFIX (640*fovtan/vid.width) + extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; extern lighttable_t *scalelightfixed[MAXLIGHTSCALE]; extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; @@ -64,7 +67,7 @@ fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); subsector_t *R_PointInSubsector(fixed_t x, fixed_t y); -subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); +subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y); boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph); @@ -76,14 +79,23 @@ extern consvar_t cv_showhud, cv_translucenthud; extern consvar_t cv_homremoval; extern consvar_t cv_chasecam, cv_chasecam2; extern consvar_t cv_flipcam, cv_flipcam2; -extern consvar_t cv_shadow, cv_shadowoffs; + +extern consvar_t cv_shadow; extern consvar_t cv_translucency; -extern consvar_t cv_precipdensity, cv_drawdist, cv_drawdist_nights, cv_drawdist_precip; +extern consvar_t cv_drawdist, cv_drawdist_nights, cv_drawdist_precip; +extern consvar_t cv_fov; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; // Called by startup code. void R_Init(void); +#ifdef HWRENDER +void R_InitHardwareMode(void); +#endif +void R_ReloadHUDGraphics(void); + +void R_CheckViewMorph(void); +void R_ApplyViewMorph(void); // just sets setsizeneeded true extern boolean setsizeneeded; @@ -94,7 +106,7 @@ void R_ExecuteSetViewSize(void); void R_SkyboxFrame(player_t *player); -void R_SetupFrame(player_t *player, boolean skybox); +void R_SetupFrame(player_t *player); // Called by G_Drawer. void R_RenderPlayerView(player_t *player); diff --git a/src/r_patch.c b/src/r_patch.c new file mode 100644 index 000000000..9e31d4d19 --- /dev/null +++ b/src/r_patch.c @@ -0,0 +1,1474 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 2005-2009 by Andrey "entryway" Budko. +// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_patch.c +/// \brief Patch generation. + +#include "byteptr.h" +#include "dehacked.h" +#include "i_video.h" +#include "r_data.h" +#include "r_draw.h" +#include "r_patch.h" +#include "r_things.h" +#include "z_zone.h" +#include "w_wad.h" + +#ifdef HWRENDER +#include "hardware/hw_glob.h" +#endif + +#ifdef HAVE_PNG + +#ifndef _MSC_VER +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE +#endif +#endif + +#ifndef _LFS64_LARGEFILE +#define _LFS64_LARGEFILE +#endif + +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 0 +#endif + +#include "png.h" +#ifndef PNG_READ_SUPPORTED +#undef HAVE_PNG +#endif +#endif + +static unsigned char imgbuf[1<<26]; + +// +// R_CheckIfPatch +// +// Returns true if the lump is a valid patch. +// +boolean R_CheckIfPatch(lumpnum_t lump) +{ + size_t size; + INT16 width, height; + patch_t *patch; + boolean result; + + size = W_LumpLength(lump); + + // minimum length of a valid Doom patch + if (size < 13) + return false; + + patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); + + width = SHORT(patch->width); + height = SHORT(patch->height); + + result = (height > 0 && height <= 16384 && width > 0 && width <= 16384 && width < (INT16)(size / 4)); + + if (result) + { + // The dimensions seem like they might be valid for a patch, so + // check the column directory for extra security. All columns + // must begin after the column directory, and none of them must + // point past the end of the patch. + INT16 x; + + for (x = 0; x < width; x++) + { + UINT32 ofs = LONG(patch->columnofs[x]); + + // Need one byte for an empty column (but there's patches that don't know that!) + if (ofs < (UINT32)width * 4 + 8 || ofs >= (UINT32)size) + { + result = false; + break; + } + } + } + + return result; +} + +// +// R_TextureToFlat +// +// Convert a texture to a flat. +// +void R_TextureToFlat(size_t tex, UINT8 *flat) +{ + texture_t *texture = textures[tex]; + + fixed_t col, ofs; + column_t *column; + UINT8 *desttop, *dest, *deststop; + UINT8 *source; + + // yea + R_CheckTextureCache(tex); + + desttop = flat; + deststop = desttop + (texture->width * texture->height); + + for (col = 0; col < texture->width; col++, desttop++) + { + // no post_t info + if (!texture->holes) + { + column = (column_t *)(R_GetColumn(tex, col)); + source = (UINT8 *)(column); + dest = desttop; + for (ofs = 0; dest < deststop && ofs < texture->height; ofs++) + { + if (source[ofs] != TRANSPARENTPIXEL) + *dest = source[ofs]; + dest += texture->width; + } + } + else + { + INT32 topdelta, prevdelta = -1; + column = (column_t *)((UINT8 *)R_GetColumn(tex, col) - 3); + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + + dest = desttop + (topdelta * texture->width); + source = (UINT8 *)column + 3; + for (ofs = 0; dest < deststop && ofs < column->length; ofs++) + { + if (source[ofs] != TRANSPARENTPIXEL) + *dest = source[ofs]; + dest += texture->width; + } + column = (column_t *)((UINT8 *)column + column->length + 4); + } + } + } +} + +// +// R_PatchToFlat +// +// Convert a patch to a flat. +// +void R_PatchToFlat(patch_t *patch, UINT8 *flat) +{ + fixed_t col, ofs; + column_t *column; + UINT8 *desttop, *dest, *deststop; + UINT8 *source; + + desttop = flat; + deststop = desttop + (SHORT(patch->width) * SHORT(patch->height)); + + for (col = 0; col < SHORT(patch->width); col++, desttop++) + { + INT32 topdelta, prevdelta = -1; + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[col])); + + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + + dest = desttop + (topdelta * SHORT(patch->width)); + source = (UINT8 *)(column) + 3; + for (ofs = 0; dest < deststop && ofs < column->length; ofs++) + { + *dest = source[ofs]; + dest += SHORT(patch->width); + } + column = (column_t *)((UINT8 *)column + column->length + 4); + } + } +} + +// +// R_PatchToMaskedFlat +// +// Convert a patch to a masked flat. +// Now, what is a "masked" flat anyway? +// It means the flat uses two bytes to store image data. +// The upper byte is used to store the transparent pixel, +// and the lower byte stores a palette index. +// +void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip) +{ + fixed_t col, ofs; + column_t *column; + UINT16 *desttop, *dest, *deststop; + UINT8 *source; + + desttop = raw; + deststop = desttop + (SHORT(patch->width) * SHORT(patch->height)); + + for (col = 0; col < SHORT(patch->width); col++, desttop++) + { + INT32 topdelta, prevdelta = -1; + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-col) : col])); + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + dest = desttop + (topdelta * SHORT(patch->width)); + source = (UINT8 *)(column) + 3; + for (ofs = 0; dest < deststop && ofs < column->length; ofs++) + { + *dest = source[ofs]; + dest += SHORT(patch->width); + } + column = (column_t *)((UINT8 *)column + column->length + 4); + } + } +} + +// +// R_FlatToPatch +// +// Convert a flat to a patch. +// +patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency) +{ + UINT32 x, y; + UINT8 *img; + UINT8 *imgptr = imgbuf; + UINT8 *colpointers, *startofspan; + size_t size = 0; + + if (!raw) + return NULL; + + // Write image size and offset + WRITEINT16(imgptr, width); + WRITEINT16(imgptr, height); + WRITEINT16(imgptr, leftoffset); + WRITEINT16(imgptr, topoffset); + + // Leave placeholder to column pointers + colpointers = imgptr; + imgptr += width*4; + + // Write columns + for (x = 0; x < width; x++) + { + int lastStartY = 0; + int spanSize = 0; + startofspan = NULL; + + // Write column pointer + WRITEINT32(colpointers, imgptr - imgbuf); + + // Write pixels + for (y = 0; y < height; y++) + { + UINT8 paletteIndex = raw[((y * width) + x)]; + boolean opaque = transparency ? (paletteIndex != TRANSPARENTPIXEL) : true; + + // End span if we have a transparent pixel + if (!opaque) + { + if (startofspan) + WRITEUINT8(imgptr, 0); + startofspan = NULL; + continue; + } + + // Start new column if we need to + if (!startofspan || spanSize == 255) + { + int writeY = y; + + // If we reached the span size limit, finish the previous span + if (startofspan) + WRITEUINT8(imgptr, 0); + + if (y > 254) + { + // Make sure we're aligned to 254 + if (lastStartY < 254) + { + WRITEUINT8(imgptr, 254); + WRITEUINT8(imgptr, 0); + imgptr += 2; + lastStartY = 254; + } + + // Write stopgap empty spans if needed + writeY = y - lastStartY; + + while (writeY > 254) + { + WRITEUINT8(imgptr, 254); + WRITEUINT8(imgptr, 0); + imgptr += 2; + writeY -= 254; + } + } + + startofspan = imgptr; + WRITEUINT8(imgptr, writeY); + imgptr += 2; + spanSize = 0; + + lastStartY = y; + } + + // Write the pixel + WRITEUINT8(imgptr, paletteIndex); + spanSize++; + startofspan[1] = spanSize; + } + + if (startofspan) + WRITEUINT8(imgptr, 0); + + WRITEUINT8(imgptr, 0xFF); + } + + size = imgptr-imgbuf; + img = Z_Malloc(size, PU_STATIC, NULL); + memcpy(img, imgbuf, size); + + Z_Free(raw); + + if (destsize != NULL) + *destsize = size; + return (patch_t *)img; +} + +// +// R_MaskedFlatToPatch +// +// Convert a masked flat to a patch. +// Explanation of "masked" flats in R_PatchToMaskedFlat. +// +patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) +{ + UINT32 x, y; + UINT8 *img; + UINT8 *imgptr = imgbuf; + UINT8 *colpointers, *startofspan; + size_t size = 0; + + if (!raw) + return NULL; + + // Write image size and offset + WRITEINT16(imgptr, width); + WRITEINT16(imgptr, height); + WRITEINT16(imgptr, leftoffset); + WRITEINT16(imgptr, topoffset); + + // Leave placeholder to column pointers + colpointers = imgptr; + imgptr += width*4; + + // Write columns + for (x = 0; x < width; x++) + { + int lastStartY = 0; + int spanSize = 0; + startofspan = NULL; + + // Write column pointer + WRITEINT32(colpointers, imgptr - imgbuf); + + // Write pixels + for (y = 0; y < height; y++) + { + UINT16 pixel = raw[((y * width) + x)]; + UINT8 paletteIndex = (pixel & 0xFF); + UINT8 opaque = (pixel != 0xFF00); // If 1, we have a pixel + + // End span if we have a transparent pixel + if (!opaque) + { + if (startofspan) + WRITEUINT8(imgptr, 0); + startofspan = NULL; + continue; + } + + // Start new column if we need to + if (!startofspan || spanSize == 255) + { + int writeY = y; + + // If we reached the span size limit, finish the previous span + if (startofspan) + WRITEUINT8(imgptr, 0); + + if (y > 254) + { + // Make sure we're aligned to 254 + if (lastStartY < 254) + { + WRITEUINT8(imgptr, 254); + WRITEUINT8(imgptr, 0); + imgptr += 2; + lastStartY = 254; + } + + // Write stopgap empty spans if needed + writeY = y - lastStartY; + + while (writeY > 254) + { + WRITEUINT8(imgptr, 254); + WRITEUINT8(imgptr, 0); + imgptr += 2; + writeY -= 254; + } + } + + startofspan = imgptr; + WRITEUINT8(imgptr, writeY); + imgptr += 2; + spanSize = 0; + + lastStartY = y; + } + + // Write the pixel + WRITEUINT8(imgptr, paletteIndex); + spanSize++; + startofspan[1] = spanSize; + } + + if (startofspan) + WRITEUINT8(imgptr, 0); + + WRITEUINT8(imgptr, 0xFF); + } + + size = imgptr-imgbuf; + img = Z_Malloc(size, PU_STATIC, NULL); + memcpy(img, imgbuf, size); + + if (destsize != NULL) + *destsize = size; + return (patch_t *)img; +} + +// +// R_IsLumpPNG +// +// Returns true if the lump is a valid PNG. +// +boolean R_IsLumpPNG(const UINT8 *d, size_t s) +{ + if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ + return false; + // Check for PNG file signature using memcmp + // As it may be faster on CPUs with slow unaligned memory access + // Ref: http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature + return (memcmp(&d[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0); +} + +#ifndef NO_PNG_LUMPS +#ifdef HAVE_PNG + +/*#if PNG_LIBPNG_VER_DLLNUM < 14 +typedef PNG_CONST png_byte *png_const_bytep; +#endif*/ +typedef struct +{ + const UINT8 *buffer; + UINT32 size; + UINT32 position; +} png_io_t; + +static void PNG_IOReader(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_io_t *f = png_get_io_ptr(png_ptr); + if (length > (f->size - f->position)) + png_error(png_ptr, "PNG_IOReader: buffer overrun"); + memcpy(data, f->buffer + f->position, length); + f->position += length; +} + +typedef struct +{ + char name[4]; + void *data; + size_t size; +} png_chunk_t; + +static png_byte *chunkname = NULL; +static png_chunk_t chunk; + +static int PNG_ChunkReader(png_structp png_ptr, png_unknown_chunkp chonk) +{ + (void)png_ptr; + if (!memcmp(chonk->name, chunkname, 4)) + { + memcpy(chunk.name, chonk->name, 4); + chunk.size = chonk->size; + chunk.data = Z_Malloc(chunk.size, PU_STATIC, NULL); + memcpy(chunk.data, chonk->data, chunk.size); + return 1; + } + return 0; +} + +static void PNG_error(png_structp PNG, png_const_charp pngtext) +{ + CONS_Debug(DBG_RENDER, "libpng error at %p: %s", PNG, pngtext); + //I_Error("libpng error at %p: %s", PNG, pngtext); +} + +static void PNG_warn(png_structp PNG, png_const_charp pngtext) +{ + CONS_Debug(DBG_RENDER, "libpng warning at %p: %s", PNG, pngtext); +} + +static png_bytep *PNG_Read(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +{ + png_structp png_ptr; + png_infop png_info_ptr; + png_uint_32 width, height; + int bit_depth, color_type; + png_uint_32 y; +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + + png_io_t png_io; + png_bytep *row_pointers; + + png_byte grAb_chunk[5] = {'g', 'r', 'A', 'b', (png_byte)'\0'}; + png_voidp *user_chunk_ptr; + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, PNG_error, PNG_warn); + if (!png_ptr) + { + CONS_Debug(DBG_RENDER, "PNG_Load: Error on initialize libpng\n"); + return NULL; + } + + png_info_ptr = png_create_info_struct(png_ptr); + if (!png_info_ptr) + { + CONS_Debug(DBG_RENDER, "PNG_Load: Error on allocate for libpng\n"); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return NULL; + } + +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_jmpbuf(png_ptr))) +#endif + { + //CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename); + png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); + return NULL; + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf); +#endif + + // set our own read function + png_io.buffer = png; + png_io.size = size; + png_io.position = 0; + png_set_read_fn(png_ptr, &png_io, PNG_IOReader); + + memset(&chunk, 0x00, sizeof(png_chunk_t)); + chunkname = grAb_chunk; // I want to read a grAb chunk + + user_chunk_ptr = png_get_user_chunk_ptr(png_ptr); + png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, PNG_ChunkReader); + png_set_keep_unknown_chunks(png_ptr, 2, chunkname, 1); + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_set_user_limits(png_ptr, 2048, 2048); +#endif + + png_read_info(png_ptr, png_info_ptr); + png_get_IHDR(png_ptr, png_info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); + + if (bit_depth == 16) + png_set_strip_16(png_ptr); + + if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + else if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + if (png_get_valid(png_ptr, png_info_ptr, PNG_INFO_tRNS)) + png_set_tRNS_to_alpha(png_ptr); + else if (color_type != PNG_COLOR_TYPE_RGB_ALPHA && color_type != PNG_COLOR_TYPE_GRAY_ALPHA) + { +#if PNG_LIBPNG_VER < 10207 + png_set_filler(png_ptr, 0xFF, PNG_FILLER_AFTER); +#else + png_set_add_alpha(png_ptr, 0xFF, PNG_FILLER_AFTER); +#endif + } + + png_read_update_info(png_ptr, png_info_ptr); + + // Read the image + row_pointers = (png_bytep*)malloc(sizeof(png_bytep) * height); + for (y = 0; y < height; y++) + row_pointers[y] = (png_byte*)malloc(png_get_rowbytes(png_ptr, png_info_ptr)); + png_read_image(png_ptr, row_pointers); + + // Read grAB chunk + if ((topoffset || leftoffset) && (chunk.data != NULL)) + { + INT32 *offsets = (INT32 *)chunk.data; + // read left offset + if (leftoffset != NULL) + *leftoffset = (INT16)BIGENDIAN_LONG(*offsets); + offsets++; + // read top offset + if (topoffset != NULL) + *topoffset = (INT16)BIGENDIAN_LONG(*offsets); + } + + // bye + png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); + if (chunk.data) + Z_Free(chunk.data); + + *w = (INT32)width; + *h = (INT32)height; + return row_pointers; +} + +// Convert a PNG to a raw image. +static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +{ + UINT8 *flat; + png_uint_32 x, y; + png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, size); + png_uint_32 width = *w, height = *h; + + if (!row_pointers) + I_Error("PNG_RawConvert: conversion failed"); + + // Convert the image to 8bpp + flat = Z_Malloc(width * height, PU_LEVEL, NULL); + memset(flat, TRANSPARENTPIXEL, width * height); + for (y = 0; y < height; y++) + { + png_bytep row = row_pointers[y]; + for (x = 0; x < width; x++) + { + png_bytep px = &(row[x * 4]); + if ((UINT8)px[3]) + flat[((y * width) + x)] = NearestColor((UINT8)px[0], (UINT8)px[1], (UINT8)px[2]); + } + } + free(row_pointers); + + return flat; +} + +// Convert a PNG with transparency to a raw image. +static UINT16 *PNG_MaskedRawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +{ + UINT16 *flat; + png_uint_32 x, y; + png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, size); + png_uint_32 width = *w, height = *h; + size_t flatsize, i; + + if (!row_pointers) + I_Error("PNG_MaskedRawConvert: conversion failed"); + + // Convert the image to 16bpp + flatsize = (width * height); + flat = Z_Malloc(flatsize * sizeof(UINT16), PU_LEVEL, NULL); + + // can't memset here + for (i = 0; i < flatsize; i++) + flat[i] = 0xFF00; + + for (y = 0; y < height; y++) + { + png_bytep row = row_pointers[y]; + for (x = 0; x < width; x++) + { + png_bytep px = &(row[x * 4]); + if ((UINT8)px[3]) + flat[((y * width) + x)] = NearestColor((UINT8)px[0], (UINT8)px[1], (UINT8)px[2]); + } + } + free(row_pointers); + + return flat; +} + +// +// R_PNGToFlat +// +// Convert a PNG to a flat. +// +UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size) +{ + return PNG_RawConvert(png, width, height, NULL, NULL, size); +} + +// +// R_PNGToPatch +// +// Convert a PNG to a patch. +// +patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) +{ + UINT16 width, height; + INT16 topoffset = 0, leftoffset = 0; + UINT16 *raw = PNG_MaskedRawConvert(png, &width, &height, &topoffset, &leftoffset, size); + + if (!raw) + I_Error("R_PNGToPatch: conversion failed"); + + return R_MaskedFlatToPatch(raw, width, height, leftoffset, topoffset, destsize); +} + +// +// R_PNGDimensions +// +// Get the dimensions of a PNG file. +// +boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size) +{ + png_structp png_ptr; + png_infop png_info_ptr; + png_uint_32 w, h; + int bit_depth, color_type; +#ifdef PNG_SETJMP_SUPPORTED +#ifdef USE_FAR_KEYWORD + jmp_buf jmpbuf; +#endif +#endif + + png_io_t png_io; + + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, + PNG_error, PNG_warn); + if (!png_ptr) + { + CONS_Debug(DBG_RENDER, "PNG_Load: Error on initialize libpng\n"); + return false; + } + + png_info_ptr = png_create_info_struct(png_ptr); + if (!png_info_ptr) + { + CONS_Debug(DBG_RENDER, "PNG_Load: Error on allocate for libpng\n"); + png_destroy_read_struct(&png_ptr, NULL, NULL); + return false; + } + +#ifdef USE_FAR_KEYWORD + if (setjmp(jmpbuf)) +#else + if (setjmp(png_jmpbuf(png_ptr))) +#endif + { + //CONS_Debug(DBG_RENDER, "libpng load error on %s\n", filename); + png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); + return false; + } +#ifdef USE_FAR_KEYWORD + png_memcpy(png_jmpbuf(png_ptr), jmpbuf, sizeof jmp_buf); +#endif + + // set our own read function + png_io.buffer = png; + png_io.size = size; + png_io.position = 0; + png_set_read_fn(png_ptr, &png_io, PNG_IOReader); + +#ifdef PNG_SET_USER_LIMITS_SUPPORTED + png_set_user_limits(png_ptr, 2048, 2048); +#endif + + png_read_info(png_ptr, png_info_ptr); + + png_get_IHDR(png_ptr, png_info_ptr, &w, &h, &bit_depth, &color_type, + NULL, NULL, NULL); + + // okay done. stop. + png_destroy_read_struct(&png_ptr, &png_info_ptr, NULL); + + *width = (INT32)w; + *height = (INT32)h; + return true; +} +#endif +#endif + +// +// R_ParseSpriteInfoFrame +// +// Parse a SPRTINFO frame. +// +static void R_ParseSpriteInfoFrame(spriteinfo_t *info) +{ + char *sprinfoToken; + size_t sprinfoTokenLength; + char *frameChar = NULL; + UINT8 frameFrame = 0xFF; + INT16 frameXPivot = 0; + INT16 frameYPivot = 0; + rotaxis_t frameRotAxis = 0; + + // Sprite identifier + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite frame should be"); + } + sprinfoTokenLength = strlen(sprinfoToken); + if (sprinfoTokenLength != 1) + { + I_Error("Error parsing SPRTINFO lump: Invalid frame \"%s\"",sprinfoToken); + } + else + frameChar = sprinfoToken; + + frameFrame = R_Char2Frame(frameChar[0]); + Z_Free(sprinfoToken); + + // Left Curly Brace + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + I_Error("Error parsing SPRTINFO lump: Missing sprite info"); + else + { + if (strcmp(sprinfoToken,"{")==0) + { + Z_Free(sprinfoToken); + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info should be"); + } + while (strcmp(sprinfoToken,"}")!=0) + { + if (stricmp(sprinfoToken, "XPIVOT")==0) + { + Z_Free(sprinfoToken); + sprinfoToken = M_GetToken(NULL); + frameXPivot = atoi(sprinfoToken); + } + else if (stricmp(sprinfoToken, "YPIVOT")==0) + { + Z_Free(sprinfoToken); + sprinfoToken = M_GetToken(NULL); + frameYPivot = atoi(sprinfoToken); + } + else if (stricmp(sprinfoToken, "ROTAXIS")==0) + { + Z_Free(sprinfoToken); + sprinfoToken = M_GetToken(NULL); + if ((stricmp(sprinfoToken, "X")==0) || (stricmp(sprinfoToken, "XAXIS")==0) || (stricmp(sprinfoToken, "ROLL")==0)) + frameRotAxis = ROTAXIS_X; + else if ((stricmp(sprinfoToken, "Y")==0) || (stricmp(sprinfoToken, "YAXIS")==0) || (stricmp(sprinfoToken, "PITCH")==0)) + frameRotAxis = ROTAXIS_Y; + else if ((stricmp(sprinfoToken, "Z")==0) || (stricmp(sprinfoToken, "ZAXIS")==0) || (stricmp(sprinfoToken, "YAW")==0)) + frameRotAxis = ROTAXIS_Z; + } + Z_Free(sprinfoToken); + + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info or right curly brace should be"); + } + } + } + Z_Free(sprinfoToken); + } + + // set fields + info->pivot[frameFrame].x = frameXPivot; + info->pivot[frameFrame].y = frameYPivot; + info->pivot[frameFrame].rotaxis = frameRotAxis; +} + +// +// R_ParseSpriteInfo +// +// Parse a SPRTINFO lump. +// +static void R_ParseSpriteInfo(boolean spr2) +{ + spriteinfo_t *info; + char *sprinfoToken; + size_t sprinfoTokenLength; + char newSpriteName[5]; // no longer dynamically allocated + spritenum_t sprnum = NUMSPRITES; + playersprite_t spr2num = NUMPLAYERSPRITES; + INT32 i; + INT32 skinnumbers[MAXSKINS]; + INT32 foundskins = 0; + + // Sprite name + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite name should be"); + } + sprinfoTokenLength = strlen(sprinfoToken); + if (sprinfoTokenLength != 4) + { + I_Error("Error parsing SPRTINFO lump: Sprite name \"%s\" isn't 4 characters long",sprinfoToken); + } + else + { + memset(&newSpriteName, 0, 5); + M_Memcpy(newSpriteName, sprinfoToken, sprinfoTokenLength); + // ^^ we've confirmed that the token is == 4 characters so it will never overflow a 5 byte char buffer + strupr(newSpriteName); // Just do this now so we don't have to worry about it + } + Z_Free(sprinfoToken); + + if (!spr2) + { + for (i = 0; i <= NUMSPRITES; i++) + { + if (i == NUMSPRITES) + I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName); + if (!memcmp(newSpriteName,sprnames[i],4)) + { + sprnum = i; + break; + } + } + } + else + { + for (i = 0; i <= NUMPLAYERSPRITES; i++) + { + if (i == NUMPLAYERSPRITES) + I_Error("Error parsing SPRTINFO lump: Unknown sprite2 name \"%s\"", newSpriteName); + if (!memcmp(newSpriteName,spr2names[i],4)) + { + spr2num = i; + break; + } + } + } + + // allocate a spriteinfo + info = Z_Calloc(sizeof(spriteinfo_t), PU_STATIC, NULL); + info->available = true; + +#ifdef ROTSPRITE + if ((sprites != NULL) && (!spr2)) + R_FreeSingleRotSprite(&sprites[sprnum]); +#endif + + // Left Curly Brace + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where open curly brace for sprite \"%s\" should be",newSpriteName); + } + if (strcmp(sprinfoToken,"{")==0) + { + Z_Free(sprinfoToken); + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where definition for sprite \"%s\" should be",newSpriteName); + } + while (strcmp(sprinfoToken,"}")!=0) + { + if (stricmp(sprinfoToken, "SKIN")==0) + { + INT32 skinnum; + char *skinName = NULL; + if (!spr2) + I_Error("Error parsing SPRTINFO lump: \"SKIN\" token found outside of a sprite2 definition"); + + Z_Free(sprinfoToken); + + // Skin name + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where skin frame should be"); + } + + // copy skin name yada yada + sprinfoTokenLength = strlen(sprinfoToken); + skinName = (char *)Z_Malloc((sprinfoTokenLength+1)*sizeof(char),PU_STATIC,NULL); + M_Memcpy(skinName,sprinfoToken,sprinfoTokenLength*sizeof(char)); + skinName[sprinfoTokenLength] = '\0'; + strlwr(skinName); + Z_Free(sprinfoToken); + + skinnum = R_SkinAvailable(skinName); + if (skinnum == -1) + I_Error("Error parsing SPRTINFO lump: Unknown skin \"%s\"", skinName); + + skinnumbers[foundskins] = skinnum; + foundskins++; + } + else if (stricmp(sprinfoToken, "FRAME")==0) + { + R_ParseSpriteInfoFrame(info); + Z_Free(sprinfoToken); + if (spr2) + { + if (!foundskins) + I_Error("Error parsing SPRTINFO lump: No skins specified in this sprite2 definition"); + for (i = 0; i < foundskins; i++) + { + size_t skinnum = skinnumbers[i]; + skin_t *skin = &skins[skinnum]; + spriteinfo_t *sprinfo = skin->sprinfo; +#ifdef ROTSPRITE + R_FreeSkinRotSprite(skinnum); +#endif + M_Memcpy(&sprinfo[spr2num], info, sizeof(spriteinfo_t)); + } + } + else + M_Memcpy(&spriteinfo[sprnum], info, sizeof(spriteinfo_t)); + } + else + { + I_Error("Error parsing SPRTINFO lump: Unknown keyword \"%s\" in sprite %s",sprinfoToken,newSpriteName); + } + + sprinfoToken = M_GetToken(NULL); + if (sprinfoToken == NULL) + { + I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info or right curly brace for sprite \"%s\" should be",newSpriteName); + } + } + } + else + { + I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken); + } + Z_Free(sprinfoToken); + Z_Free(info); +} + +// +// R_ParseSPRTINFOLump +// +// Read a SPRTINFO lump. +// +void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum) +{ + char *sprinfoLump; + size_t sprinfoLumpLength; + char *sprinfoText; + char *sprinfoToken; + + // Since lumps AREN'T \0-terminated like I'd assumed they should be, I'll + // need to make a space of memory where I can ensure that it will terminate + // correctly. Start by loading the relevant data from the WAD. + sprinfoLump = (char *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC); + // If that didn't exist, we have nothing to do here. + if (sprinfoLump == NULL) return; + // If we're still here, then it DOES exist; figure out how long it is, and allot memory accordingly. + sprinfoLumpLength = W_LumpLengthPwad(wadNum, lumpNum); + sprinfoText = (char *)Z_Malloc((sprinfoLumpLength+1)*sizeof(char),PU_STATIC,NULL); + // Now move the contents of the lump into this new location. + memmove(sprinfoText,sprinfoLump,sprinfoLumpLength); + // Make damn well sure the last character in our new memory location is \0. + sprinfoText[sprinfoLumpLength] = '\0'; + // Finally, free up the memory from the first data load, because we really + // don't need it. + Z_Free(sprinfoLump); + + sprinfoToken = M_GetToken(sprinfoText); + while (sprinfoToken != NULL) + { + if (!stricmp(sprinfoToken, "SPRITE")) + R_ParseSpriteInfo(false); + else if (!stricmp(sprinfoToken, "SPRITE2")) + R_ParseSpriteInfo(true); + else + I_Error("Error parsing SPRTINFO lump: Unknown keyword \"%s\"", sprinfoToken); + Z_Free(sprinfoToken); + sprinfoToken = M_GetToken(NULL); + } + Z_Free((void *)sprinfoText); +} + +// +// R_LoadSpriteInfoLumps +// +// Load and read every SPRTINFO lump from the specified file. +// +void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps) +{ + lumpinfo_t *lumpinfo = wadfiles[wadnum]->lumpinfo; + UINT16 i; + char *name; + + for (i = 0; i < numlumps; i++, lumpinfo++) + { + name = lumpinfo->name; + // Load SPRTINFO and SPR_ lumps as SpriteInfo + if (!memcmp(name, "SPRTINFO", 8) || !memcmp(name, "SPR_", 4)) + R_ParseSPRTINFOLump(wadnum, i); + } +} + +static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) +{ + fixed_t ofs; + column_t *column; + UINT8 *source; + + if (x >= 0 && x < SHORT(patch->width)) + { + INT32 topdelta, prevdelta = -1; + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-x) : x])); + while (column->topdelta != 0xff) + { + topdelta = column->topdelta; + if (topdelta <= prevdelta) + topdelta += prevdelta; + prevdelta = topdelta; + source = (UINT8 *)(column) + 3; + for (ofs = 0; ofs < column->length; ofs++) + { + if ((topdelta + ofs) == y) + return source[ofs]; + } + column = (column_t *)((UINT8 *)column + column->length + 4); + } + } + + return 0xFF00; +} + +#ifdef ROTSPRITE +// +// R_GetRollAngle +// +// Angles precalculated in R_InitSprites. +// +fixed_t rollcosang[ROTANGLES]; +fixed_t rollsinang[ROTANGLES]; +INT32 R_GetRollAngle(angle_t rollangle) +{ + INT32 ra = AngleFixed(rollangle)>>FRACBITS; +#if (ROTANGDIFF > 1) + ra += (ROTANGDIFF/2); +#endif + ra /= ROTANGDIFF; + ra %= ROTANGLES; + return ra; +} + +// +// R_CacheRotSprite +// +// Create a rotated sprite. +// +void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip) +{ + UINT32 i; + INT32 angle; + patch_t *patch; + patch_t *newpatch; + UINT16 *rawdst; + size_t size; + INT32 bflip = (flip != 0x00); + +#define SPRITE_XCENTER (leftoffset) +#define SPRITE_YCENTER (height / 2) +#define ROTSPRITE_XCENTER (newwidth / 2) +#define ROTSPRITE_YCENTER (newheight / 2) + + if (!(sprframe->rotsprite.cached & (1<lumppat[rot]; +#ifndef NO_PNG_LUMPS + size_t lumplength; +#endif + + if (lump == LUMPERROR) + return; + + patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); +#ifndef NO_PNG_LUMPS + lumplength = W_LumpLength(lump); + + if (R_IsLumpPNG((UINT8 *)patch, lumplength)) + patch = R_PNGToPatch((UINT8 *)patch, lumplength, NULL); + else +#endif + // Because there's something wrong with SPR_DFLM, I guess + if (!R_CheckIfPatch(lump)) + return; + + width = patch->width; + height = patch->height; + leftoffset = patch->leftoffset; + + // rotation pivot + px = SPRITE_XCENTER; + py = SPRITE_YCENTER; + + // get correct sprite info for sprite + if (sprinfo == NULL) + sprinfo = &spriteinfo[sprnum]; + if (sprinfo->available) + { + px = sprinfo->pivot[frame].x; + py = sprinfo->pivot[frame].y; + } + if (bflip) + { + px = width - px; + leftoffset = width - leftoffset; + } + + // Don't cache angle = 0 + for (angle = 1; angle < ROTANGLES; angle++) + { + INT32 newwidth, newheight; + + ca = rollcosang[angle]; + sa = rollsinang[angle]; + + // Find the dimensions of the rotated patch. + { + INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa)); + INT32 w2 = abs(FixedMul(-(width << FRACBITS), ca) - FixedMul(height << FRACBITS, sa)); + INT32 h1 = abs(FixedMul(width << FRACBITS, sa) + FixedMul(height << FRACBITS, ca)); + INT32 h2 = abs(FixedMul(-(width << FRACBITS), sa) + FixedMul(height << FRACBITS, ca)); + w1 = FixedInt(FixedCeil(w1 + (FRACUNIT/2))); + w2 = FixedInt(FixedCeil(w2 + (FRACUNIT/2))); + h1 = FixedInt(FixedCeil(h1 + (FRACUNIT/2))); + h2 = FixedInt(FixedCeil(h2 + (FRACUNIT/2))); + newwidth = max(width, max(w1, w2)); + newheight = max(height, max(h1, h2)); + } + + // check boundaries + { + fixed_t top[2][2]; + fixed_t bottom[2][2]; + + top[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + top[0][1] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + top[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + top[1][1] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + + bottom[0][0] = FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + bottom[0][1] = -FixedMul((-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + bottom[1][0] = FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, ca) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, sa) + (px << FRACBITS); + bottom[1][1] = -FixedMul((newwidth-ROTSPRITE_XCENTER) << FRACBITS, sa) + FixedMul((newheight-ROTSPRITE_YCENTER) << FRACBITS, ca) + (py << FRACBITS); + + top[0][0] >>= FRACBITS; + top[0][1] >>= FRACBITS; + top[1][0] >>= FRACBITS; + top[1][1] >>= FRACBITS; + + bottom[0][0] >>= FRACBITS; + bottom[0][1] >>= FRACBITS; + bottom[1][0] >>= FRACBITS; + bottom[1][1] >>= FRACBITS; + +#define BOUNDARYWCHECK(b) (b[0] < 0 || b[0] >= width) +#define BOUNDARYHCHECK(b) (b[1] < 0 || b[1] >= height) +#define BOUNDARYADJUST(x) x *= 2 + // top left/right + if (BOUNDARYWCHECK(top[0]) || BOUNDARYWCHECK(top[1])) + BOUNDARYADJUST(newwidth); + // bottom left/right + else if (BOUNDARYWCHECK(bottom[0]) || BOUNDARYWCHECK(bottom[1])) + BOUNDARYADJUST(newwidth); + // top left/right + if (BOUNDARYHCHECK(top[0]) || BOUNDARYHCHECK(top[1])) + BOUNDARYADJUST(newheight); + // bottom left/right + else if (BOUNDARYHCHECK(bottom[0]) || BOUNDARYHCHECK(bottom[1])) + BOUNDARYADJUST(newheight); +#undef BOUNDARYWCHECK +#undef BOUNDARYHCHECK +#undef BOUNDARYADJUST + } + + // Draw the rotated sprite to a temporary buffer. + size = (newwidth * newheight); + if (!size) + size = (width * height); + + rawdst = Z_Malloc(size * sizeof(UINT16), PU_STATIC, NULL); + for (i = 0; i < size; i++) + rawdst[i] = 0xFF00; + + for (dy = 0; dy < newheight; dy++) + { + for (dx = 0; dx < newwidth; dx++) + { + INT32 x = (dx-ROTSPRITE_XCENTER) << FRACBITS; + INT32 y = (dy-ROTSPRITE_YCENTER) << FRACBITS; + INT32 sx = FixedMul(x, ca) + FixedMul(y, sa) + (px << FRACBITS); + INT32 sy = -FixedMul(x, sa) + FixedMul(y, ca) + (py << FRACBITS); + sx >>= FRACBITS; + sy >>= FRACBITS; + if (sx >= 0 && sy >= 0 && sx < width && sy < height) + rawdst[(dy*newwidth)+dx] = GetPatchPixel(patch, sx, sy, bflip); + } + } + + // make patch + newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size); + { + newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); + newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); + } + + //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer + if (rendermode != render_none) // not for psprite + newpatch->topoffset += FEETADJUST>>FRACBITS; + + // P_PrecacheLevel + if (devparm) spritememory += size; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); + grPatch->rawpatch = newpatch; + sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch; + HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false); + } + else +#endif // HWRENDER + sprframe->rotsprite.patch[rot][angle] = newpatch; + + // free rotated image data + Z_Free(rawdst); + } + + // This rotation is cached now + sprframe->rotsprite.cached |= (1<numframes; frame++) + { + spriteframe_t *sprframe = &spritedef->spriteframes[frame]; + for (rot = 0; rot < 16; rot++) + { + if (sprframe->rotsprite.cached & (1<rotsprite.patch[rot][ang]; + if (rotsprite) + { +#ifdef HWRENDER + if (rendermode == render_opengl) + { + GLPatch_t *grPatch = (GLPatch_t *)rotsprite; + if (grPatch->rawpatch) + { + Z_Free(grPatch->rawpatch); + grPatch->rawpatch = NULL; + } + if (grPatch->mipmap) + { + if (grPatch->mipmap->grInfo.data) + { + Z_Free(grPatch->mipmap->grInfo.data); + grPatch->mipmap->grInfo.data = NULL; + } + Z_Free(grPatch->mipmap); + grPatch->mipmap = NULL; + } + } +#endif + Z_Free(rotsprite); + } + } + sprframe->rotsprite.cached &= ~(1<sprites; + for (i = 0; i < NUMPLAYERSPRITES*2; i++) + { + R_FreeSingleRotSprite(skinsprites); + skinsprites++; + } +} + +// +// R_FreeAllRotSprite +// +// Free ALL sprite rotation data from memory. +// +void R_FreeAllRotSprite(void) +{ + INT32 i; + size_t s; + for (s = 0; s < numsprites; s++) + R_FreeSingleRotSprite(&sprites[s]); + for (i = 0; i < numskins; ++i) + R_FreeSkinRotSprite(i); +} +#endif diff --git a/src/r_patch.h b/src/r_patch.h new file mode 100644 index 000000000..a2db6320c --- /dev/null +++ b/src/r_patch.h @@ -0,0 +1,74 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_patch.h +/// \brief Patch generation. + +#ifndef __R_PATCH__ +#define __R_PATCH__ + +#include "r_defs.h" +#include "doomdef.h" + +// Structs +typedef enum +{ + ROTAXIS_X, // Roll (the default) + ROTAXIS_Y, // Pitch + ROTAXIS_Z // Yaw +} rotaxis_t; + +typedef struct +{ + INT32 x, y; + rotaxis_t rotaxis; +} spriteframepivot_t; + +typedef struct +{ + spriteframepivot_t pivot[64]; + boolean available; +} spriteinfo_t; + +// Conversions between patches / flats / textures... +boolean R_CheckIfPatch(lumpnum_t lump); +void R_TextureToFlat(size_t tex, UINT8 *flat); +void R_PatchToFlat(patch_t *patch, UINT8 *flat); +void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); +patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); +patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); + +// Portable Network Graphics +boolean R_IsLumpPNG(const UINT8 *d, size_t s); +#define W_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic + +#ifndef NO_PNG_LUMPS +UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size); +patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize); +boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size); +#endif + +// SpriteInfo +extern spriteinfo_t spriteinfo[NUMSPRITES]; +void R_LoadSpriteInfoLumps(UINT16 wadnum, UINT16 numlumps); +void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); + +// Sprite rotation +#ifdef ROTSPRITE +INT32 R_GetRollAngle(angle_t rollangle); +void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, spriteframe_t *sprframe, INT32 rot, UINT8 flip); +void R_FreeSingleRotSprite(spritedef_t *spritedef); +void R_FreeSkinRotSprite(size_t skinnum); +extern fixed_t rollcosang[ROTANGLES]; +extern fixed_t rollsinang[ROTANGLES]; +void R_FreeAllRotSprite(void); +#endif + +#endif // __R_PATCH__ diff --git a/src/r_plane.c b/src/r_plane.c index 5cb53a530..e1e45517a 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -23,6 +23,8 @@ #include "r_state.h" #include "r_splats.h" // faB(21jan):testing #include "r_sky.h" +#include "r_portal.h" + #include "v_video.h" #include "w_wad.h" #include "z_zone.h" @@ -42,13 +44,9 @@ // Quincunx antialiasing of flats! //#define QUINCUNX -// good night sweet prince -#define SHITPLANESPARENCY - //SoM: 3/23/2000: Use Boom visplane hashing. -#define MAXVISPLANES 512 -static visplane_t *visplanes[MAXVISPLANES]; +visplane_t *visplanes[MAXVISPLANES]; static visplane_t *freetail; static visplane_t **freehead = &freetail; @@ -115,49 +113,34 @@ void R_InitPlanes(void) // FIXME: unused } -// R_PortalStoreClipValues -// Saves clipping values for later. -Red -void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale) -{ - INT32 i; - for (i = 0; i < end-start; i++) - { - *ceil = ceilingclip[start+i]; - ceil++; - *floor = floorclip[start+i]; - floor++; - *scale = frontscale[start+i]; - scale++; - } -} +// +// Water ripple effect!! +// Needs the height of the plane, and the vertical position of the span. +// Sets ripple_xfrac and ripple_yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted. +// -// R_PortalRestoreClipValues -// Inverse of the above. Restores the old value! -void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale) -{ - INT32 i; - for (i = 0; i < end-start; i++) - { - ceilingclip[start+i] = *ceil; - ceil++; - floorclip[start+i] = *floor; - floor++; - frontscale[start+i] = *scale; - scale++; - } +#ifndef NOWATER +INT32 ds_bgofs; +INT32 ds_waterofs; - // HACKS FOLLOW - for (i = 0; i < start; i++) - { - floorclip[i] = -1; - ceilingclip[i] = (INT16)viewheight; - } - for (i = end; i < vid.width; i++) - { - floorclip[i] = -1; - ceilingclip[i] = (INT16)viewheight; - } +static INT32 wtofs=0; +static boolean itswater; +static fixed_t ripple_xfrac; +static fixed_t ripple_yfrac; + +static void R_PlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight) +{ + fixed_t distance = FixedMul(plheight, yslope[y]); + const INT32 yay = (wtofs + (distance>>9) ) & 8191; + // ripples da water texture + angle_t angle = (plane->viewangle + plane->plangle)>>ANGLETOFINESHIFT; + ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; + + angle = (angle + 2048) & 8191; // 90 degrees + ripple_xfrac = FixedMul(FINECOSINE(angle), (ds_bgofs< 64 the amount of precision we can allow will decrease, but only by one - // bit per power of two (obviously) - // Ok, because I was able to eliminate the variable spot below, this function is now FASTER - // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + waterofs) << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; - dsrc = screens[1] + (ds_y+bgofs)*vid.width + ds_x1; - count = ds_x2 - ds_x1 + 1; - - while (count >= 8) - { - // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't - // have the uber complicated math to calculate it now, so that was a memory write we didn't - // need! - dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest += 8; - count -= 8; - } - while (count--) - { - *dest++ = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - } -} -#endif - void R_MapPlane(INT32 y, INT32 x1, INT32 x2) { angle_t angle, planecos, planesin; @@ -302,19 +199,27 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) #ifndef NOWATER if (itswater) { - const INT32 yay = (wtofs + (distance>>9) ) & 8191; - // ripples da water texture - bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS; - angle = (currentplane->viewangle + currentplane->plangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; + // Needed for ds_bgofs + R_PlaneRipple(currentplane, y, planeheight); - angle = (angle + 2048) & 8191; // 90 degrees - ds_xfrac += FixedMul(FINECOSINE(angle), (bgofs<slope) + { + ds_sup = &ds_su[y]; + ds_svp = &ds_sv[y]; + ds_szp = &ds_sz[y]; + } + else +#endif + { + ds_xfrac += ripple_xfrac; + ds_yfrac += ripple_yfrac; + } - if (y+bgofs>=viewheight) - bgofs = viewheight-y-1; - if (y+bgofs<0) - bgofs = -y; + if (y+ds_bgofs>=viewheight) + ds_bgofs = viewheight-y-1; + if (y+ds_bgofs<0) + ds_bgofs = -y; } #endif @@ -351,6 +256,23 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) #endif } +void R_ClearFFloorClips (void) +{ + INT32 i, p; + + // opening / clipping determination + for (i = 0; i < viewwidth; i++) + { + for (p = 0; p < MAXFFLOORS; p++) + { + ffloor[p].f_clip[i] = (INT16)viewheight; + ffloor[p].c_clip[i] = -1; + } + } + + numffloors = 0; +} + // // R_ClearPlanes // At begining of frame. @@ -373,8 +295,6 @@ void R_ClearPlanes(void) } } - numffloors = 0; - for (i = 0; i < MAXVISPLANES; i++) for (*freehead = visplanes[i], visplanes[i] = NULL; freehead && *freehead ;) @@ -436,19 +356,37 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, #ifdef ESLOPE if (slope); else // Don't mess with this right now if a slope is involved #endif - if (plangle != 0) - { - // Add the view offset, rotated by the plane angle. - angle_t angle = plangle>>ANGLETOFINESHIFT; - xoff += FixedMul(viewx,FINECOSINE(angle))-FixedMul(viewy,FINESINE(angle)); - yoff += -FixedMul(viewx,FINESINE(angle))-FixedMul(viewy,FINECOSINE(angle)); - } - else { xoff += viewx; yoff -= viewy; + if (plangle != 0) + { + // Add the view offset, rotated by the plane angle. + fixed_t cosinecomponent = FINECOSINE(plangle>>ANGLETOFINESHIFT); + fixed_t sinecomponent = FINESINE(plangle>>ANGLETOFINESHIFT); + fixed_t oldxoff = xoff; + xoff = FixedMul(xoff,cosinecomponent)+FixedMul(yoff,sinecomponent); + yoff = -FixedMul(oldxoff,sinecomponent)+FixedMul(yoff,cosinecomponent); + } } +#ifdef POLYOBJECTS_PLANES + if (polyobj) + { + if (polyobj->angle != 0) + { + angle_t fineshift = polyobj->angle >> ANGLETOFINESHIFT; + xoff -= FixedMul(FINECOSINE(fineshift), polyobj->centerPt.x)+FixedMul(FINESINE(fineshift), polyobj->centerPt.y); + yoff -= FixedMul(FINESINE(fineshift), polyobj->centerPt.x)-FixedMul(FINECOSINE(fineshift), polyobj->centerPt.y); + } + else + { + xoff -= polyobj->centerPt.x; + yoff += polyobj->centerPt.y; + } + } +#endif + // This appears to fix the Nimbus Ruins sky bug. if (picnum == skyflatnum && pfloor) { @@ -474,6 +412,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, && !pfloor && !check->ffloor && check->viewx == viewx && check->viewy == viewy && check->viewz == viewz && check->viewangle == viewangle + && check->plangle == plangle #ifdef ESLOPE && check->slope == slope #endif @@ -597,7 +536,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) // overlap. void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) { - INT32 unionl, unionh; +// INT32 unionl, unionh; // INT32 x; #ifdef POLYOBJECTS_PLANES @@ -606,6 +545,9 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) return; #endif + if (pl->minx > start) pl->minx = start; + if (pl->maxx < stop) pl->maxx = stop; +/* if (start < pl->minx) { unionl = start; @@ -623,15 +565,16 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop) { unionh = pl->maxx; } -/* for (x = start; x <= stop; x++) if (pl->top[x] != 0xffff || pl->bottom[x] != 0x0000) break; if (x <= stop) I_Error("R_ExpandPlane: planes in same subsector overlap?!\nminx: %d, maxx: %d, start: %d, stop: %d\n", pl->minx, pl->maxx, start, stop); -*/ + pl->minx = unionl, pl->maxx = unionh; +*/ + } // @@ -666,55 +609,16 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2) void R_DrawPlanes(void) { visplane_t *pl; - INT32 x; - INT32 angle; INT32 i; - spanfunc = basespanfunc; - wallcolfunc = walldrawerfunc; + // Note: are these two lines really needed? + // R_DrawSinglePlane and R_DrawSkyPlane do span/column drawer resets themselves anyway + spanfunc = spanfuncs[BASEDRAWFUNC]; for (i = 0; i < MAXVISPLANES; i++, pl++) { for (pl = visplanes[i]; pl; pl = pl->next) { - // sky flat - if (pl->picnum == skyflatnum) - { - if (!viewsky) - { - skyVisible = true; - continue; - } - - // use correct aspect ratio scale - dc_iscale = skyscale; - - // Sky is always drawn full bright, - // i.e. colormaps[0] is used. - // Because of this hack, sky is not affected - // by INVUL inverse mapping. - dc_colormap = colormaps; - dc_texturemid = skytexturemid; - dc_texheight = textureheight[skytexture] - >>FRACBITS; - for (x = pl->minx; x <= pl->maxx; x++) - { - dc_yl = pl->top[x]; - dc_yh = pl->bottom[x]; - - if (dc_yl <= dc_yh) - { - angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; - dc_x = x; - dc_source = - R_GetColumn(skytexture, - angle); - wallcolfunc(); - } - } - continue; - } - if (pl->ffloor != NULL #ifdef POLYOBJECTS_PLANES || pl->polyobj != NULL @@ -726,30 +630,359 @@ void R_DrawPlanes(void) } } #ifndef NOWATER - waterofs = (leveltime & 1)*16384; + ds_waterofs = (leveltime & 1)*16384; wtofs = leveltime * 140; #endif } +// R_DrawSkyPlane +// +// Draws the sky within the plane's top/bottom bounds +// Note: this uses column drawers instead of span drawers, since the sky is always a texture +// +static void R_DrawSkyPlane(visplane_t *pl) +{ + INT32 x; + INT32 angle; + + // Reset column drawer function (note: couldn't we just call walldrawerfunc directly?) + // (that is, unless we'll need to switch drawers in future for some reason) + colfunc = colfuncs[BASEDRAWFUNC]; + + // use correct aspect ratio scale + dc_iscale = skyscale; + + // Sky is always drawn full bright, + // i.e. colormaps[0] is used. + // Because of this hack, sky is not affected + // by sector colormaps (INVUL inverse mapping is not implemented in SRB2 so is irrelevant). + dc_colormap = colormaps; + dc_texturemid = skytexturemid; + dc_texheight = textureheight[skytexture] + >>FRACBITS; + for (x = pl->minx; x <= pl->maxx; x++) + { + dc_yl = pl->top[x]; + dc_yh = pl->bottom[x]; + + if (dc_yl <= dc_yh) + { + angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; + dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT)); + dc_x = x; + dc_source = + R_GetColumn(texturetranslation[skytexture], + -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 + colfunc(); + } + } +} + +// +// R_CheckPowersOfTwo +// +// Self-explanatory? +// +boolean R_CheckPowersOfTwo(void) +{ + boolean wpow2 = (!(ds_flatwidth & (ds_flatwidth - 1))); + boolean hpow2 = (!(ds_flatheight & (ds_flatheight - 1))); + + // Initially, the flat isn't powers-of-two-sized. + ds_powersoftwo = false; + + // But if the width and height are powers of two, + // and are EQUAL, then it's okay :] + if ((ds_flatwidth == ds_flatheight) && (wpow2 && hpow2)) + ds_powersoftwo = true; + + // Just return ds_powersoftwo. + return ds_powersoftwo; +} + +// +// R_CheckFlatLength +// +// Determine the flat's dimensions from the lump length. +// +void R_CheckFlatLength(size_t size) +{ + switch (size) + { + case 4194304: // 2048x2048 lump + nflatmask = 0x3FF800; + nflatxshift = 21; + nflatyshift = 10; + nflatshiftup = 5; + ds_flatwidth = ds_flatheight = 2048; + break; + case 1048576: // 1024x1024 lump + nflatmask = 0xFFC00; + nflatxshift = 22; + nflatyshift = 12; + nflatshiftup = 6; + ds_flatwidth = ds_flatheight = 1024; + break; + case 262144:// 512x512 lump + nflatmask = 0x3FE00; + nflatxshift = 23; + nflatyshift = 14; + nflatshiftup = 7; + ds_flatwidth = ds_flatheight = 512; + break; + case 65536: // 256x256 lump + nflatmask = 0xFF00; + nflatxshift = 24; + nflatyshift = 16; + nflatshiftup = 8; + ds_flatwidth = ds_flatheight = 256; + break; + case 16384: // 128x128 lump + nflatmask = 0x3F80; + nflatxshift = 25; + nflatyshift = 18; + nflatshiftup = 9; + ds_flatwidth = ds_flatheight = 128; + break; + case 1024: // 32x32 lump + nflatmask = 0x3E0; + nflatxshift = 27; + nflatyshift = 22; + nflatshiftup = 11; + ds_flatwidth = ds_flatheight = 32; + break; + default: // 64x64 lump + nflatmask = 0xFC0; + nflatxshift = 26; + nflatyshift = 20; + nflatshiftup = 10; + ds_flatwidth = ds_flatheight = 64; + break; + } +} + +// +// R_GenerateFlat +// +// Generate a flat from specified width and height. +// +static UINT8 *R_GenerateFlat(UINT16 width, UINT16 height) +{ + UINT8 *flat = Z_Malloc(width * height, PU_LEVEL, NULL); + memset(flat, TRANSPARENTPIXEL, width * height); + return flat; +} + +// +// R_GetTextureFlat +// +// Convert a texture or patch to a flat. +// +static UINT8 *R_GetTextureFlat(levelflat_t *levelflat, boolean leveltexture, boolean ispng) +{ + UINT8 *flat; + textureflat_t *texflat = &texflats[levelflat->u.texture.num]; + patch_t *patch = NULL; + boolean texturechanged = (leveltexture ? (levelflat->u.texture.num != levelflat->u.texture.lastnum) : false); + + (void)ispng; + + // Check if the texture changed. + if (leveltexture && (!texturechanged)) + { + if (texflat != NULL && texflat->flat) + { + flat = texflat->flat; + ds_flatwidth = texflat->width; + ds_flatheight = texflat->height; + texturechanged = false; + } + else + texturechanged = true; + } + + // If the texture changed, or the patch doesn't exist, convert either of them to a flat. + if (levelflat->flatpatch == NULL || texturechanged) + { + // Level texture + if (leveltexture) + { + texture_t *texture = textures[levelflat->u.texture.num]; + texflat->width = ds_flatwidth = texture->width; + texflat->height = ds_flatheight = texture->height; + + texflat->flat = R_GenerateFlat(ds_flatwidth, ds_flatheight); + R_TextureToFlat(levelflat->u.texture.num, texflat->flat); + flat = texflat->flat; + + levelflat->flatpatch = flat; + levelflat->width = ds_flatwidth; + levelflat->height = ds_flatheight; + } + // Patch (never happens yet) + else + { + patch = (patch_t *)ds_source; +#ifndef NO_PNG_LUMPS + if (ispng) + { + levelflat->flatpatch = R_PNGToFlat(&levelflat->width, &levelflat->height, ds_source, W_LumpLength(levelflat->u.flat.lumpnum)); + levelflat->topoffset = levelflat->leftoffset = 0; + ds_flatwidth = levelflat->width; + ds_flatheight = levelflat->height; + } + else +#endif + { + levelflat->width = ds_flatwidth = SHORT(patch->width); + levelflat->height = ds_flatheight = SHORT(patch->height); + + levelflat->topoffset = patch->topoffset * FRACUNIT; + levelflat->leftoffset = patch->leftoffset * FRACUNIT; + + levelflat->flatpatch = R_GenerateFlat(ds_flatwidth, ds_flatheight); + R_PatchToFlat(patch, levelflat->flatpatch); + } + flat = levelflat->flatpatch; + } + } + else + { + flat = levelflat->flatpatch; + ds_flatwidth = levelflat->width; + ds_flatheight = levelflat->height; + } + + xoffs += levelflat->leftoffset; + yoffs += levelflat->topoffset; + + levelflat->u.texture.lastnum = levelflat->u.texture.num; + return flat; +} + +#ifdef ESLOPE +static void R_SlopeVectors(visplane_t *pl, INT32 i, float fudge) +{ + // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! + // I copied ZDoom's code and adapted it to SRB2... -Red + floatv3_t p, m, n; + float ang; + float vx, vy, vz; + // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly + // use this as a temp var to store P_GetZAt's return value each time + fixed_t temp; + + vx = FIXED_TO_FLOAT(pl->viewx+xoffs); + vy = FIXED_TO_FLOAT(pl->viewy-yoffs); + vz = FIXED_TO_FLOAT(pl->viewz); + + temp = P_GetZAt(pl->slope, pl->viewx, pl->viewy); + zeroheight = FIXED_TO_FLOAT(temp); + + // p is the texture origin in view space + // Don't add in the offsets at this stage, because doing so can result in + // errors if the flat is rotated. + ang = ANG2RAD(ANGLE_270 - pl->viewangle); + p.x = vx * cos(ang) - vy * sin(ang); + p.z = vx * sin(ang) + vy * cos(ang); + temp = P_GetZAt(pl->slope, -xoffs, yoffs); + p.y = FIXED_TO_FLOAT(temp) - vz; + + // m is the v direction vector in view space + ang = ANG2RAD(ANGLE_180 - (pl->viewangle + pl->plangle)); + m.x = cos(ang); + m.z = sin(ang); + + // n is the u direction vector in view space + n.x = sin(ang); + n.z = -cos(ang); + + ang = ANG2RAD(pl->plangle); + temp = P_GetZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(sin(ang)), pl->viewy + FLOAT_TO_FIXED(cos(ang))); + m.y = FIXED_TO_FLOAT(temp) - zeroheight; + temp = P_GetZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(cos(ang)), pl->viewy - FLOAT_TO_FIXED(sin(ang))); + n.y = FIXED_TO_FLOAT(temp) - zeroheight; + + if (ds_powersoftwo) + { + m.x /= fudge; + m.y /= fudge; + m.z /= fudge; + + n.x *= fudge; + n.y *= fudge; + n.z *= fudge; + } + + // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. +#define CROSS(d, v1, v2) \ +d.x = (v1.y * v2.z) - (v1.z * v2.y);\ +d.y = (v1.z * v2.x) - (v1.x * v2.z);\ +d.z = (v1.x * v2.y) - (v1.y * v2.x) + CROSS(ds_su[i], p, m); + CROSS(ds_sv[i], p, n); + CROSS(ds_sz[i], m, n); +#undef CROSS + + ds_su[i].z *= focallengthf; + ds_sv[i].z *= focallengthf; + ds_sz[i].z *= focallengthf; + + // Premultiply the texture vectors with the scale factors +#define SFMULT 65536.f + if (ds_powersoftwo) + { + ds_su[i].x *= (SFMULT * (1<minx <= pl->maxx)) return; + // sky flat + if (pl->picnum == skyflatnum) + { + R_DrawSkyPlane(pl); + return; + } + #ifndef NOWATER itswater = false; #endif - spanfunc = basespanfunc; + spanfunc = spanfuncs[BASEDRAWFUNC]; #ifdef POLYOBJECTS_PLANES - if (pl->polyobj && pl->polyobj->translucency != 0) { - spanfunc = R_DrawTranslucentSpan_8; + if (pl->polyobj && pl->polyobj->translucency != 0) + { + spanfunctype = SPANDRAWFUNC_TRANS; // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) if (pl->polyobj->translucency >= 10) @@ -757,13 +990,9 @@ void R_DrawSinglePlane(visplane_t *pl) else if (pl->polyobj->translucency > 0) ds_transmap = transtables + ((pl->polyobj->translucency-1)<extra_colormap && pl->extra_colormap->fog)) -#else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) -#endif + if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); else light = LIGHTLEVELS-1; @@ -791,7 +1020,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->ffloor->flags & FF_TRANSLUCENT) { - spanfunc = R_DrawTranslucentSpan_8; + spanfunctype = SPANDRAWFUNC_TRANS; // Hacked up support for alpha value in software mode Tails 09-24-2002 if (pl->ffloor->alpha < 12) @@ -815,37 +1044,29 @@ void R_DrawSinglePlane(visplane_t *pl) else if (pl->ffloor->alpha < 243) ds_transmap = transtables + ((tr_trans10-1)<extra_colormap && pl->extra_colormap->fog)) -#else - if (!pl->extra_colormap || !(pl->extra_colormap->fog & 2)) -#endif + if ((spanfunctype == SPANDRAWFUNC_SPLAT) || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) light = (pl->lightlevel >> LIGHTSEGSHIFT); else light = LIGHTLEVELS-1; } else if (pl->ffloor->flags & FF_FOG) { - spanfunc = R_DrawFogSpan_8; + spanfunctype = SPANDRAWFUNC_FOG; light = (pl->lightlevel >> LIGHTSEGSHIFT); } else light = (pl->lightlevel >> LIGHTSEGSHIFT); #ifndef NOWATER - if (pl->ffloor->flags & FF_RIPPLE -#ifdef ESLOPE - && !pl->slope -#endif - ) + if (pl->ffloor->flags & FF_RIPPLE) { INT32 top, bottom; itswater = true; - if (spanfunc == R_DrawTranslucentSpan_8) + if (spanfunctype == SPANDRAWFUNC_TRANS) { - spanfunc = R_DrawTranslucentWaterSpan_8; + spanfunctype = SPANDRAWFUNC_WATER; // Copy the current scene, ugh top = pl->high-8; @@ -878,64 +1099,49 @@ void R_DrawSinglePlane(visplane_t *pl) viewangle = pl->viewangle+pl->plangle; } - currentplane = pl; - - ds_source = (UINT8 *) - W_CacheLumpNum(levelflats[pl->picnum].lumpnum, - PU_STATIC); // Stay here until Z_ChangeTag - - size = W_LumpLength(levelflats[pl->picnum].lumpnum); - - switch (size) - { - case 4194304: // 2048x2048 lump - nflatmask = 0x3FF800; - nflatxshift = 21; - nflatyshift = 10; - nflatshiftup = 5; - break; - case 1048576: // 1024x1024 lump - nflatmask = 0xFFC00; - nflatxshift = 22; - nflatyshift = 12; - nflatshiftup = 6; - break; - case 262144:// 512x512 lump' - nflatmask = 0x3FE00; - nflatxshift = 23; - nflatyshift = 14; - nflatshiftup = 7; - break; - case 65536: // 256x256 lump - nflatmask = 0xFF00; - nflatxshift = 24; - nflatyshift = 16; - nflatshiftup = 8; - break; - case 16384: // 128x128 lump - nflatmask = 0x3F80; - nflatxshift = 25; - nflatyshift = 18; - nflatshiftup = 9; - break; - case 1024: // 32x32 lump - nflatmask = 0x3E0; - nflatxshift = 27; - nflatyshift = 22; - nflatshiftup = 11; - break; - default: // 64x64 lump - nflatmask = 0xFC0; - nflatxshift = 26; - nflatyshift = 20; - nflatshiftup = 10; - break; - } - xoffs = pl->xoffs; yoffs = pl->yoffs; planeheight = abs(pl->height - pl->viewz); + currentplane = pl; + levelflat = &levelflats[pl->picnum]; + + /* :james: */ + type = levelflat->type; + switch (type) + { + case LEVELFLAT_NONE: + return; + case LEVELFLAT_FLAT: + ds_source = W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_CACHE); + R_CheckFlatLength(W_LumpLength(levelflat->u.flat.lumpnum)); + // Raw flats always have dimensions that are powers-of-two numbers. + ds_powersoftwo = true; + break; + default: + switch (type) + { + case LEVELFLAT_TEXTURE: + /* Textures get cached differently and don't need ds_source */ + ds_source = R_GetTextureFlat(levelflat, true, false); + break; + default: + ds_source = W_CacheLumpNum(levelflat->u.flat.lumpnum, PU_STATIC); + flat = R_GetTextureFlat(levelflat, false, +#ifndef NO_PNG_LUMPS + ( type == LEVELFLAT_PNG ) +#else + false +#endif + ); + Z_ChangeTag(ds_source, PU_CACHE); + ds_source = flat; + } + // Check if this texture or patch has power-of-two dimensions. + if (R_CheckPowersOfTwo()) + R_CheckFlatLength(ds_flatwidth * ds_flatheight); + } + if (light >= LIGHTLEVELS) light = LIGHTLEVELS-1; @@ -943,100 +1149,103 @@ void R_DrawSinglePlane(visplane_t *pl) light = 0; #ifdef ESLOPE - if (pl->slope) { - // Potentially override other stuff for now cus we're mean. :< But draw a slope plane! - // I copied ZDoom's code and adapted it to SRB2... -Red - floatv3_t p, m, n; - float ang; - float vx, vy, vz; - float fudge; - // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly - // use this as a temp var to store P_GetZAt's return value each time - fixed_t temp; + if (pl->slope) + { + float fudgecanyon = 0; + angle_t hack = (pl->plangle & (ANGLE_90-1)); - xoffs &= ((1 << (32-nflatshiftup))-1); - yoffs &= ((1 << (32-nflatshiftup))-1); + yoffs *= 1; - xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); - yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); + if (ds_powersoftwo) + { + fixed_t temp; + // Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red + fudgecanyon = ((1<>ANGLETOFINESHIFT); + const fixed_t sinecomponent = FINESINE(hack>>ANGLETOFINESHIFT); - // Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -Red - fudge = ((1<slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask); + fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask); - vx = FIXED_TO_FLOAT(pl->viewx+xoffs); - vy = FIXED_TO_FLOAT(pl->viewy-yoffs); - vz = FIXED_TO_FLOAT(pl->viewz); + temp = ox & modmask; + oy &= modmask; + ox = FixedMul(temp,cosinecomponent)+FixedMul(oy,-sinecomponent); // negative sine for opposite direction + oy = -FixedMul(temp,-sinecomponent)+FixedMul(oy,cosinecomponent); - temp = P_GetZAt(pl->slope, pl->viewx, pl->viewy); - zeroheight = FIXED_TO_FLOAT(temp); + temp = xoffs; + xoffs = (FixedMul(temp,cosinecomponent) & modmask) + (FixedMul(yoffs,sinecomponent) & modmask); + yoffs = (-FixedMul(temp,sinecomponent) & modmask) + (FixedMul(yoffs,cosinecomponent) & modmask); -#define ANG2RAD(angle) ((float)((angle)*M_PI)/ANGLE_180) + temp = xoffs & modmask; + yoffs &= modmask; + xoffs = FixedMul(temp,cosinecomponent)+FixedMul(yoffs,-sinecomponent); // ditto + yoffs = -FixedMul(temp,-sinecomponent)+FixedMul(yoffs,cosinecomponent); - // p is the texture origin in view space - // Don't add in the offsets at this stage, because doing so can result in - // errors if the flat is rotated. - ang = ANG2RAD(ANGLE_270 - pl->viewangle); - p.x = vx * cos(ang) - vy * sin(ang); - p.z = vx * sin(ang) + vy * cos(ang); - temp = P_GetZAt(pl->slope, -xoffs, yoffs); - p.y = FIXED_TO_FLOAT(temp) - vz; + xoffs -= (pl->slope->o.x - ox); + yoffs += (pl->slope->o.y + oy); + } + else + { + xoffs &= ((1 << (32-nflatshiftup))-1); + yoffs &= ((1 << (32-nflatshiftup))-1); + xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); + yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1); + } + xoffs = (fixed_t)(xoffs*fudgecanyon); + yoffs = (fixed_t)(yoffs/fudgecanyon); + } - // m is the v direction vector in view space - ang = ANG2RAD(ANGLE_180 - (pl->viewangle + pl->plangle)); - m.x = cos(ang); - m.z = sin(ang); + ds_sup = &ds_su[0]; + ds_svp = &ds_sv[0]; + ds_szp = &ds_sz[0]; - // n is the u direction vector in view space - n.x = sin(ang); - n.z = -cos(ang); +#ifndef NOWATER + if (itswater) + { + INT32 i; + fixed_t plheight = abs(P_GetZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); + fixed_t rxoffs = xoffs; + fixed_t ryoffs = yoffs; - ang = ANG2RAD(pl->plangle); - temp = P_GetZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(sin(ang)), pl->viewy + FLOAT_TO_FIXED(cos(ang))); - m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetZAt(pl->slope, pl->viewx + FLOAT_TO_FIXED(cos(ang)), pl->viewy - FLOAT_TO_FIXED(sin(ang))); - n.y = FIXED_TO_FLOAT(temp) - zeroheight; + R_PlaneBounds(pl); - m.x /= fudge; - m.y /= fudge; - m.z /= fudge; + for (i = pl->high; i < pl->low; i++) + { + R_PlaneRipple(pl, i, plheight); + xoffs = rxoffs + ripple_xfrac; + yoffs = ryoffs + ripple_yfrac; + R_SlopeVectors(pl, i, fudgecanyon); + } - n.x *= fudge; - n.y *= fudge; - n.z *= fudge; - - // Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using. -#define CROSS(d, v1, v2) \ - d.x = (v1.y * v2.z) - (v1.z * v2.y);\ - d.y = (v1.z * v2.x) - (v1.x * v2.z);\ - d.z = (v1.x * v2.y) - (v1.y * v2.x) - CROSS(ds_su, p, m); - CROSS(ds_sv, p, n); - CROSS(ds_sz, m, n); -#undef CROSS - - ds_su.z *= focallengthf; - ds_sv.z *= focallengthf; - ds_sz.z *= focallengthf; - - // Premultiply the texture vectors with the scale factors -#define SFMULT 65536.f*(1<top[pl->maxx+1] = 0xffff; pl->top[pl->minx-1] = 0xffff; @@ -1083,11 +1303,11 @@ a 'smoothing' of the texture while using the palette colors. */ #ifdef QUINCUNX - if (spanfunc == R_DrawSpan_8) + if (spanfunc == spanfuncs[BASEDRAWFUNC]) { INT32 i; ds_transmap = transtables + ((tr_trans50-1)<xoffs; @@ -1136,8 +1356,6 @@ using the palette colors. } } #endif - - Z_ChangeTag(ds_source, PU_CACHE); } void R_PlaneBounds(visplane_t *plane) diff --git a/src/r_plane.h b/src/r_plane.h index 6e6a6d49d..405dd9726 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -18,6 +18,8 @@ #include "r_data.h" #include "p_polyobj.h" +#define MAXVISPLANES 512 + // // Now what is a visplane, anyway? // Simple: kinda floor/ceiling polygon optimised for SRB2 rendering. @@ -53,6 +55,7 @@ typedef struct visplane_s #endif } visplane_t; +extern visplane_t *visplanes[MAXVISPLANES]; extern visplane_t *floorplane; extern visplane_t *ceilingplane; @@ -72,9 +75,8 @@ extern fixed_t *yslope; extern lighttable_t **planezlight; void R_InitPlanes(void); -void R_PortalStoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); -void R_PortalRestoreClipValues(INT32 start, INT32 end, INT16 *ceil, INT16 *floor, fixed_t *scale); void R_ClearPlanes(void); +void R_ClearFFloorClips (void); void R_MapPlane(INT32 y, INT32 x1, INT32 x2); void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2); @@ -94,6 +96,8 @@ void R_PlaneBounds(visplane_t *plane); // Draws a single visplane. void R_DrawSinglePlane(visplane_t *pl); +void R_CheckFlatLength(size_t size); +boolean R_CheckPowersOfTwo(void); typedef struct planemgr_s { @@ -122,4 +126,6 @@ typedef struct planemgr_s extern visffloor_t ffloor[MAXFFLOORS]; extern INT32 numffloors; + +void Portal_AddSkyboxPortals (void); #endif diff --git a/src/r_portal.c b/src/r_portal.c new file mode 100644 index 000000000..1aca145ec --- /dev/null +++ b/src/r_portal.c @@ -0,0 +1,334 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_portal.c +/// \brief Software renderer portals. + +#include "r_portal.h" +#include "r_plane.h" +#include "r_main.h" +#include "doomstat.h" +#include "p_spec.h" // Skybox viewpoints +#include "z_zone.h" +#include "r_things.h" +#include "r_sky.h" + +UINT8 portalrender; /**< When rendering a portal, it establishes the depth of the current BSP traversal. */ + +// Linked list for portals. +portal_t *portal_base, *portal_cap; + +line_t *portalclipline; +sector_t *portalcullsector; +INT32 portalclipstart, portalclipend; + +boolean portalline; // is curline a portal seg? + +void Portal_InitList (void) +{ + portalrender = 0; + portal_base = portal_cap = NULL; +} + +/** Store the clipping window for a portal in its given range. + * + * The window is copied from the current window at the time + * the function is called, so it is useful for converting one-sided + * lines into portals. + */ +void Portal_ClipRange (portal_t* portal) +{ + INT32 start = portal->start; + INT32 end = portal->end; + INT16 *ceil = portal->ceilingclip; + INT16 *floor = portal->floorclip; + fixed_t *scale = portal->frontscale; + + INT32 i; + for (i = 0; i < end-start; i++) + { + *ceil = ceilingclip[start+i]; + ceil++; + *floor = floorclip[start+i]; + floor++; + *scale = frontscale[start+i]; + scale++; + } +} + +/** Apply the clipping window from a portal. + */ +void Portal_ClipApply (const portal_t* portal) +{ + INT32 i; + INT32 start = portal->start; + INT32 end = portal->end; + INT16 *ceil = portal->ceilingclip; + INT16 *floor = portal->floorclip; + fixed_t *scale = portal->frontscale; + + for (i = 0; i < end-start; i++) + { + ceilingclip[start+i] = *ceil; + ceil++; + floorclip[start+i] = *floor; + floor++; + frontscale[start+i] = *scale; + scale++; + } + + // HACKS FOLLOW + for (i = 0; i < start; i++) + { + floorclip[i] = -1; + ceilingclip[i] = (INT16)viewheight; + } + for (i = end; i < vid.width; i++) + { + floorclip[i] = -1; + ceilingclip[i] = (INT16)viewheight; + } +} + +static portal_t* Portal_Add (const INT16 x1, const INT16 x2) +{ + portal_t *portal = Z_Malloc(sizeof(portal_t), PU_LEVEL, NULL); + INT16 *ceilingclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL); + INT16 *floorclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL); + fixed_t *frontscalesave = Z_Malloc(sizeof(fixed_t)*(x2-x1 + 1), PU_LEVEL, NULL); + + // Linked list. + if (!portal_base) + { + portal_base = portal; + portal_cap = portal; + } + else + { + portal_cap->next = portal; + portal_cap = portal; + } + portal->next = NULL; + + // Store clipping values so they can be restored once the portal is rendered. + portal->ceilingclip = ceilingclipsave; + portal->floorclip = floorclipsave; + portal->frontscale = frontscalesave; + portal->start = x1; + portal->end = x2; + + // Increase recursion level. + portal->pass = portalrender+1; + + return portal; +} + +void Portal_Remove (portal_t* portal) +{ + portal_base = portal->next; + Z_Free(portal->ceilingclip); + Z_Free(portal->floorclip); + Z_Free(portal->frontscale); + Z_Free(portal); +} + +/** Creates a portal out of two lines and a determined screen range. + * + * line1 determines the entrance, and line2 the exit. + * x1 and x2 determine the screen's column bounds. + + * The view's offset from the entry line center is obtained, + * and then rotated&translated to the exit line's center. + * When the portal renders, it will create the illusion of + * the two lines being seamed together. + */ +void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2) +{ + portal_t* portal = Portal_Add(x1, x2); + + // Offset the portal view by the linedef centers + line_t* start = &lines[line1]; + line_t* dest = &lines[line2]; + + angle_t dangle = R_PointToAngle2(0,0,dest->dx,dest->dy) - R_PointToAngle2(start->dx,start->dy,0,0); + + fixed_t disttopoint; + angle_t angtopoint; + + vertex_t dest_c, start_c; + + // looking glass center + start_c.x = (start->v1->x + start->v2->x) / 2; + start_c.y = (start->v1->y + start->v2->y) / 2; + + // other side center + dest_c.x = (dest->v1->x + dest->v2->x) / 2; + dest_c.y = (dest->v1->y + dest->v2->y) / 2; + + disttopoint = R_PointToDist2(start_c.x, start_c.y, viewx, viewy); + angtopoint = R_PointToAngle2(start_c.x, start_c.y, viewx, viewy); + angtopoint += dangle; + + portal->viewx = dest_c.x + FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); + portal->viewy = dest_c.y + FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint); + portal->viewz = viewz + dest->frontsector->floorheight - start->frontsector->floorheight; + portal->viewangle = viewangle + dangle; + + portal->clipline = line2; + + Portal_ClipRange(portal); + + portalline = true; // this tells R_StoreWallRange that curline is a portal seg +} + +/** Store the clipping window for a portal using a visplane. + * + * Since visplanes top/bottom windows work in an identical way, + * it can just be copied almost directly. + */ +static void Portal_ClipVisplane (const visplane_t* plane, portal_t* portal) +{ + INT16 start = portal->start; + INT16 end = portal->end; + INT32 i; + + for (i = 0; i < end - start; i++) + { + // Invalid column. + if (plane->top[i + start] == 65535) + { + portal->ceilingclip[i] = -1; + portal->floorclip[i] = -1; + continue; + } + portal->ceilingclip[i] = plane->top[i + start] - 1; + portal->floorclip[i] = plane->bottom[i + start] + 1; + portal->frontscale[i] = INT32_MAX; + } +} + +extern INT32 viewwidth; + +static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16* end) +{ + *start = plane->minx; + *end = plane->maxx + 1; + + // Visplanes have 1-px pads on their sides (extra columns). + // Trim them, else it may render out of bounds. + if (*end > viewwidth) + *end = viewwidth; + + if (!(*start < *end)) + return true; + + + /** Trims a visplane's horizontal gap to match its render area. + * + * Visplanes' minx/maxx may sometimes exceed the area they're + * covering. This merely adjusts the boundaries to the next + * valid area. + */ + + while (plane->bottom[*start] == 0 && plane->top[*start] == 65535 && *start < *end) + { + (*start)++; + } + + + while (plane->bottom[*end - 1] == 0 && plane->top[*start] == 65535 && *end > *start) + { + (*end)--; + } + + return false; +} + +/** Creates a skybox portal out of a visplane. + * + * Applies the necessary offsets and rotation to give + * a depth illusion to the skybox. + */ +void Portal_AddSkybox (const visplane_t* plane) +{ + INT16 start, end; + mapheader_t *mh; + portal_t* portal; + + if (TrimVisplaneBounds(plane, &start, &end)) + return; + + portal = Portal_Add(start, end); + + Portal_ClipVisplane(plane, portal); + + portal->viewx = skyboxmo[0]->x; + portal->viewy = skyboxmo[0]->y; + portal->viewz = skyboxmo[0]->z; + portal->viewangle = viewangle + skyboxmo[0]->angle; + + mh = mapheaderinfo[gamemap-1]; + + // If a relative viewpoint exists, offset the viewpoint. + if (skyboxmo[1]) + { + fixed_t x = 0, y = 0; + angle_t ang = skyboxmo[0]->angle>>ANGLETOFINESHIFT; + + if (mh->skybox_scalex > 0) + x = (viewx - skyboxmo[1]->x) / mh->skybox_scalex; + else if (mh->skybox_scalex < 0) + x = (viewx - skyboxmo[1]->x) * -mh->skybox_scalex; + + if (mh->skybox_scaley > 0) + y = (viewy - skyboxmo[1]->y) / mh->skybox_scaley; + else if (mh->skybox_scaley < 0) + y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley; + + // Apply transform to account for the skybox viewport angle. + portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); + portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); + } + + if (mh->skybox_scalez > 0) + portal->viewz += viewz / mh->skybox_scalez; + else if (mh->skybox_scalez < 0) + portal->viewz += viewz * -mh->skybox_scalez; + + portal->clipline = -1; +} + +/** Creates portals for the currently existing sky visplanes. + * The visplanes are also removed and cleared from the list. + */ +void Portal_AddSkyboxPortals (void) +{ + visplane_t *pl; + INT32 i; + UINT16 count = 0; + + for (i = 0; i < MAXVISPLANES; i++, pl++) + { + for (pl = visplanes[i]; pl; pl = pl->next) + { + if (pl->picnum == skyflatnum) + { + Portal_AddSkybox(pl); + + pl->minx = 0; + pl->maxx = -1; + + count++; + } + } + } + + CONS_Debug(DBG_RENDER, "Skybox portals: %d\n", count); +} diff --git a/src/r_portal.h b/src/r_portal.h new file mode 100644 index 000000000..406b98d10 --- /dev/null +++ b/src/r_portal.h @@ -0,0 +1,60 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_portal.h +/// \brief Software renderer portal struct, functions, linked list extern. + +#ifndef __R_PORTAL__ +#define __R_PORTAL__ + +#include "r_data.h" +#include "r_plane.h" // visplanes + +/** Portal structure for the software renderer. + */ +typedef struct portal_s +{ + struct portal_s *next; + + // Viewport. + fixed_t viewx; + fixed_t viewy; + fixed_t viewz; + angle_t viewangle; + + UINT8 pass; /**< Keeps track of the portal's recursion depth. */ + INT32 clipline; /**< Optional clipline for line-based portals. */ + + // Clipping information. + INT32 start; /**< First horizontal pixel coordinate to draw at. */ + INT32 end; /**< Last horizontal pixel coordinate to draw at. */ + INT16 *ceilingclip; /**< Temporary screen top clipping array. */ + INT16 *floorclip; /**< Temporary screen bottom clipping array. */ + fixed_t *frontscale;/**< Temporary screen bottom clipping array. */ +} portal_t; + +extern portal_t* portal_base; +extern portal_t* portal_cap; +extern UINT8 portalrender; + +extern line_t *portalclipline; +extern sector_t *portalcullsector; +extern INT32 portalclipstart, portalclipend; + +void Portal_InitList (void); +void Portal_Remove (portal_t* portal); +void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2); +void Portal_AddSkybox (const visplane_t* plane); + +void Portal_ClipRange (portal_t* portal); +void Portal_ClipApply (const portal_t* portal); + +void Portal_AddSkyboxPortals (void); +#endif diff --git a/src/r_segs.c b/src/r_segs.c index 7495d7889..0233b1161 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,6 +15,7 @@ #include "r_local.h" #include "r_sky.h" +#include "r_portal.h" #include "r_splats.h" #include "w_wad.h" @@ -164,7 +165,7 @@ static void R_DrawWallSplats(void) mfloorclip = floorclip; mceilingclip = ceilingclip; - patch = W_CachePatchNum(splat->patch, PU_CACHE); + patch = W_CachePatchNum(splat->patch, PU_PATCH); dc_texturemid = splat->top + (SHORT(patch->height)<<(FRACBITS-1)) - viewz; if (splat->yoffset) @@ -176,20 +177,20 @@ static void R_DrawWallSplats(void) switch (splat->flags & SPLATDRAWMODE_MASK) { case SPLATDRAWMODE_OPAQUE: - colfunc = basecolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; break; case SPLATDRAWMODE_TRANS: if (!cv_translucency.value) - colfunc = basecolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; else { dc_transmap = transtables + ((tr_trans50 - 1)<>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; dc_colormap = walllights[pindex]; @@ -225,7 +226,7 @@ static void R_DrawWallSplats(void) } } // next splat - colfunc = basecolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; } #endif //WALLSPLATS @@ -269,15 +270,22 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) { dc_source = (UINT8 *)column + 3; - if (colfunc == wallcolfunc) - twosmultipatchfunc(); - else if (colfunc == fuzzcolfunc) - twosmultipatchtransfunc(); + if (colfunc == colfuncs[BASEDRAWFUNC]) + (colfuncs[COLDRAWFUNC_TWOSMULTIPATCH])(); + else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY]) + (colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS])(); else colfunc(); } } +// quick wrapper for R_DrawFlippedMaskedColumn so it can be set as a colfunc_2s value +// uses column2s_length for texture->height as above +static void R_DrawFlippedMaskedSegColumn(column_t *column) +{ + R_DrawFlippedMaskedColumn(column, column2s_length); +} + void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { size_t pindex; @@ -300,6 +308,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // for horizontal / vertical / diagonal. Diagonal? // OPTIMIZE: get rid of LIGHTSEGSHIFT globally curline = ds->curline; + frontsector = curline->frontsector; backsector = curline->backsector; texnum = R_GetTextureNum(curline->sidedef->midtexture); @@ -319,15 +328,15 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) case 907: case 908: dc_transmap = transtables + ((ldef->special-900)<ceilingheight; windowbottom = frontsector->floorheight; break; default: - colfunc = wallcolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; break; } @@ -337,7 +346,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; dc_transmap = transtables + ((curline->polyseg->translucency-1)<holes) - colfunc_2s = R_DrawMaskedColumn; // render the usual 2sided single-patch packed texture + { + if (textures[texnum]->flip & 2) // vertically flipped? + { + colfunc_2s = R_DrawFlippedMaskedSegColumn; + column2s_length = textures[texnum]->height; + } + else + colfunc_2s = R_DrawMaskedColumn; // render the usual 2sided single-patch packed texture + } else { colfunc_2s = R_Render2sidedMultiPatchColumn; // render multipatch with no holes (no post_t info) @@ -398,17 +415,17 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) #endif rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; rlight->flags = light->flags; - if (rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) + if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) + || (rlight->flags & FF_FOG) + || (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG))) lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); - else if (colfunc == fuzzcolfunc) - lightnum = LIGHTLEVELS - 1; else - lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); + lightnum = LIGHTLEVELS - 1; - if (rlight->extra_colormap && rlight->extra_colormap->fog) + if (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG)) ; else if (curline->v1->y == curline->v2->y) lightnum--; @@ -420,18 +437,14 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else { - if (colfunc == fuzzcolfunc) - { - if (frontsector->extra_colormap && frontsector->extra_colormap->fog) - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - else - lightnum = LIGHTLEVELS - 1; - } - else + if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) + || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); + else + lightnum = LIGHTLEVELS - 1; - if (colfunc == R_DrawFogColumn_8 - || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) + if (colfunc == colfuncs[COLDRAWFUNC_FOG] + || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) ; else if (curline->v1->y == curline->v2->y) lightnum--; @@ -582,7 +595,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else xwalllights = scalelight[rlight->lightnum]; - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -627,7 +640,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } // calculate lighting - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -702,7 +715,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) spryscale += rw_scalestep; } } - colfunc = wallcolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; } // Loop through R_DrawMaskedColumn calls @@ -717,6 +730,14 @@ static void R_DrawRepeatMaskedColumn(column_t *col) } } +static void R_DrawRepeatFlippedMaskedColumn(column_t *col) +{ + do { + R_DrawFlippedMaskedColumn(col, column2s_length); + sprtopscreen += dc_texheight*spryscale; + } while (sprtopscreen < sprbotscreen); +} + // // R_RenderThickSideRange // Renders all the thick sides in the given range. @@ -765,7 +786,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector; texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); - colfunc = wallcolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; if (pfloor->master->flags & ML_TFERLINE) { @@ -803,10 +824,10 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fuzzy = false; // Opaque if (fuzzy) - colfunc = fuzzcolfunc; + colfunc = colfuncs[COLDRAWFUNC_FUZZY]; } else if (pfloor->flags & FF_FOG) - colfunc = R_DrawFogColumn_8; + colfunc = colfuncs[COLDRAWFUNC_FOG]; #ifdef ESLOPE range = max(ds->x2-ds->x1, 1); @@ -854,8 +875,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) { lightlist_t *nextlight = &frontsector->lightlist[i+1]; - if (nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height > pfloorleft - && nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height > pfloorright) + if ((nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height) > pfloorleft + && (nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height) > pfloorright) continue; } @@ -914,7 +935,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; // Check if the current light effects the colormap/lightlevel if (pfloor->flags & FF_FOG) @@ -922,7 +943,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else rlight->lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); - if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) + if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG))) ; else if (curline->v1->y == curline->v2->y) rlight->lightnum--; @@ -937,17 +958,17 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else { // Get correct light level! - if ((frontsector->extra_colormap && frontsector->extra_colormap->fog)) + if ((frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); else if (pfloor->flags & FF_FOG) lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT); - else if (colfunc == fuzzcolfunc) + else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY]) lightnum = LIGHTLEVELS-1; else lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false) ->lightlevel >> LIGHTSEGSHIFT; - if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog)); + if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))); else if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) @@ -1040,7 +1061,15 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) //faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures // are not stored per-column with post info anymore in Doom Legacy if (textures[texnum]->holes) - colfunc_2s = R_DrawRepeatMaskedColumn; //render the usual 2sided single-patch packed texture + { + if (textures[texnum]->flip & 2) // vertically flipped? + { + colfunc_2s = R_DrawRepeatFlippedMaskedColumn; + column2s_length = textures[texnum]->height; + } + else + colfunc_2s = R_DrawRepeatMaskedColumn; // render the usual 2sided single-patch packed texture + } else { colfunc_2s = R_Render2sidedMultiPatchColumn; //render multipatch with no holes (no post_t info) @@ -1155,7 +1184,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else xwalllights = scalelight[lightnum]; - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1248,7 +1277,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } // calculate lighting - pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE - 1; @@ -1265,12 +1294,24 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) spryscale += rw_scalestep; } } - colfunc = wallcolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; #undef CLAMPMAX #undef CLAMPMIN } +// R_ExpandPlaneY +// +// A simple function to modify a vsplane's top and bottom for a particular column +// Sort of like R_ExpandPlane in r_plane.c, except this is vertical expansion +static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bottom) +{ + // Expand the plane, don't shrink it! + // note: top and bottom default to 0xFFFF and 0x0000 respectively, which is totally compatible with this + if (pl->top[x] > top) pl->top[x] = top; + if (pl->bottom[x] < bottom) pl->bottom[x] = bottom; +} + // // R_RenderSegLoop // Draws zero, one, or two textures (and possibly a masked @@ -1294,7 +1335,6 @@ UINT32 nombre = 100000; #endif //profile stuff --------------------------------------------------------- - static void R_RenderSegLoop (void) { angle_t angle; @@ -1316,7 +1356,6 @@ static void R_RenderSegLoop (void) // mark floor / ceiling areas yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; - // no space above wall? top = ceilingclip[rw_x]+1; // no space above wall? @@ -1325,16 +1364,19 @@ static void R_RenderSegLoop (void) if (markceiling) { +#if 0 bottom = yl-1; if (bottom >= floorclip[rw_x]) bottom = floorclip[rw_x]-1; if (top <= bottom) - { - ceilingplane->top[rw_x] = (INT16)top; - ceilingplane->bottom[rw_x] = (INT16)bottom; - } +#else + bottom = yl > floorclip[rw_x] ? floorclip[rw_x] : yl; + + if (top <= --bottom && ceilingplane) +#endif + R_ExpandPlaneY(ceilingplane, rw_x, top, bottom); } @@ -1348,11 +1390,9 @@ static void R_RenderSegLoop (void) if (markfloor) { top = yh < ceilingclip[rw_x] ? ceilingclip[rw_x] : yh; + if (++top <= bottom && floorplane) - { - floorplane->top[rw_x] = (INT16)top; - floorplane->bottom[rw_x] = (INT16)bottom; - } + R_ExpandPlaneY(floorplane, rw_x, top, bottom); } if (numffloors) @@ -1366,14 +1406,6 @@ static void R_RenderSegLoop (void) #ifdef POLYOBJECTS_PLANES if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) continue; - - // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red - if (curline->polyseg) { - if (ffloor[i].plane->minx > rw_x) - ffloor[i].plane->minx = rw_x; - else if (ffloor[i].plane->maxx < rw_x) - ffloor[i].plane->maxx = rw_x; - } #endif if (ffloor[i].height < viewz) @@ -1389,8 +1421,9 @@ static void R_RenderSegLoop (void) #ifdef POLYOBJECTS_PLANES // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { - ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; + if (ffloor[i].polyobj && top_w >= bottom_w) { + ffloor[i].plane->top[rw_x] = 0xFFFF; + ffloor[i].plane->bottom[rw_x] = 0x0000; // fix for sky plane drawing crashes - Monster Iestyn 25/05/18 } else #endif @@ -1413,8 +1446,9 @@ static void R_RenderSegLoop (void) #ifdef POLYOBJECTS_PLANES // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { - ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; + if (ffloor[i].polyobj && top_w >= bottom_w) { + ffloor[i].plane->top[rw_x] = 0xFFFF; + ffloor[i].plane->bottom[rw_x] = 0x0000; // fix for sky plane drawing crashes - Monster Iestyn 25/05/18 } else #endif @@ -1448,7 +1482,7 @@ static void R_RenderSegLoop (void) if (segtextured) { // calculate lighting - pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1483,7 +1517,7 @@ static void R_RenderSegLoop (void) else xwalllights = scalelight[lightnum]; - pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT; + pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT; if (pindex >= MAXLIGHTSCALE) pindex = MAXLIGHTSCALE-1; @@ -1493,7 +1527,7 @@ static void R_RenderSegLoop (void) else dc_lightlist[i].rcolormap = xwalllights[pindex]; - colfunc = R_DrawColumnShadowed_8; + colfunc = colfuncs[COLDRAWFUNC_SHADOWED]; } } @@ -1699,8 +1733,11 @@ void R_StoreWallRange(INT32 start, INT32 stop) memset(&segright, 0x00, sizeof(segright)); #endif + colfunc = colfuncs[BASEDRAWFUNC]; + if (ds_p == drawsegs+maxdrawsegs) { + size_t curpos = curdrawsegs - drawsegs; size_t pos = ds_p - drawsegs; size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128; if (firstseg) @@ -1708,6 +1745,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) drawsegs = Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL); ds_p = drawsegs + pos; maxdrawsegs = newmax; + curdrawsegs = drawsegs + curpos; if (firstseg) firstseg = drawsegs + (size_t)firstseg; } @@ -1854,29 +1892,26 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } - if (frontsector->c_slope) { - worldtop = P_GetZAt(frontsector->c_slope, segleft.x, segleft.y) - viewz; - worldtopslope = P_GetZAt(frontsector->c_slope, segright.x, segright.y) - viewz; - } else { - worldtopslope = -#else - { -#endif - worldtop = frontsector->ceilingheight - viewz; - } +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + if (slope) { \ + end1 = P_GetZAt(slope, segleft.x, segleft.y); \ + end2 = P_GetZAt(slope, segright.x, segright.y); \ + } else \ + end1 = end2 = normalheight; -#ifdef ESLOPE - if (frontsector->f_slope) { - worldbottom = P_GetZAt(frontsector->f_slope, segleft.x, segleft.y) - viewz; - worldbottomslope = P_GetZAt(frontsector->f_slope, segright.x, segright.y) - viewz; - } else { - worldbottomslope = + SLOPEPARAMS(frontsector->c_slope, worldtop, worldtopslope, frontsector->ceilingheight) + SLOPEPARAMS(frontsector->f_slope, worldbottom, worldbottomslope, frontsector->floorheight) + // subtract viewz from these to turn them into + // positions relative to the camera's z position + worldtop -= viewz; + worldtopslope -= viewz; + worldbottom -= viewz; + worldbottomslope -= viewz; #else - { + worldtop = frontsector->ceilingheight - viewz; + worldbottom = frontsector->floorheight - viewz; #endif - worldbottom = frontsector->floorheight - viewz; - } midtexture = toptexture = bottomtexture = maskedtexture = 0; ds_p->maskedtexturecol = NULL; @@ -1978,125 +2013,128 @@ void R_StoreWallRange(INT32 start, INT32 stop) else { // two sided line + boolean bothceilingssky = false; // turned on if both back and front ceilings are sky + boolean bothfloorssky = false; // likewise, but for floors #ifdef ESLOPE - if (backsector->c_slope) { - worldhigh = P_GetZAt(backsector->c_slope, segleft.x, segleft.y) - viewz; - worldhighslope = P_GetZAt(backsector->c_slope, segright.x, segright.y) - viewz; - } else { - worldhighslope = + SLOPEPARAMS(backsector->c_slope, worldhigh, worldhighslope, backsector->ceilingheight) + SLOPEPARAMS(backsector->f_slope, worldlow, worldlowslope, backsector->floorheight) + worldhigh -= viewz; + worldhighslope -= viewz; + worldlow -= viewz; + worldlowslope -= viewz; #else - { + worldhigh = backsector->ceilingheight - viewz; + worldlow = backsector->floorheight - viewz; #endif - worldhigh = backsector->ceilingheight - viewz; - } - - -#ifdef ESLOPE - if (backsector->f_slope) { - worldlow = P_GetZAt(backsector->f_slope, segleft.x, segleft.y) - viewz; - worldlowslope = P_GetZAt(backsector->f_slope, segright.x, segright.y) - viewz; - } else { - worldlowslope = -#else - { -#endif - worldlow = backsector->floorheight - viewz; - } - // hack to allow height changes in outdoor areas + // This is what gets rid of the upper textures if there should be sky if (frontsector->ceilingpic == skyflatnum && backsector->ceilingpic == skyflatnum) { -#ifdef ESLOPE - worldtopslope = worldhighslope = -#endif - worldtop = worldhigh; + bothceilingssky = true; + } + + // likewise, but for floors and upper textures + if (frontsector->floorpic == skyflatnum + && backsector->floorpic == skyflatnum) + { + bothfloorssky = true; } ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; - if ( -#ifdef ESLOPE - worldbottomslope > worldlowslope || -#endif - worldbottom > worldlow) + if (!bothfloorssky) { - ds_p->silhouette = SIL_BOTTOM; + if ( #ifdef ESLOPE - if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + worldbottomslope > worldlowslope || +#endif + worldbottom > worldlow) + { + ds_p->silhouette = SIL_BOTTOM; +#ifdef ESLOPE + if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + ds_p->bsilheight = INT32_MAX; + else + ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); +#else + ds_p->bsilheight = frontsector->floorheight; +#endif + } +#ifdef ESLOPE + else if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) +#else + else if (backsector->floorheight > viewz) +#endif + { + ds_p->silhouette = SIL_BOTTOM; ds_p->bsilheight = INT32_MAX; - else - ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); -#else - ds_p->bsilheight = frontsector->floorheight; -#endif - } -#ifdef ESLOPE - else if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) -#else - else if (backsector->floorheight > viewz) -#endif - { - ds_p->silhouette = SIL_BOTTOM; - ds_p->bsilheight = INT32_MAX; - // ds_p->sprbottomclip = negonearray; + // ds_p->sprbottomclip = negonearray; + } } - if ( -#ifdef ESLOPE - worldtopslope < worldhighslope || -#endif - worldtop < worldhigh) + if (!bothceilingssky) { - ds_p->silhouette |= SIL_TOP; + if ( #ifdef ESLOPE - if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + worldtopslope < worldhighslope || +#endif + worldtop < worldhigh) + { + ds_p->silhouette |= SIL_TOP; +#ifdef ESLOPE + if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + ds_p->tsilheight = INT32_MIN; + else + ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); +#else + ds_p->tsilheight = frontsector->ceilingheight; +#endif + } +#ifdef ESLOPE + else if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) +#else + else if (backsector->ceilingheight < viewz) +#endif + { + ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = INT32_MIN; - else - ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); -#else - ds_p->tsilheight = frontsector->ceilingheight; -#endif - } -#ifdef ESLOPE - else if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) -#else - else if (backsector->ceilingheight < viewz) -#endif - { - ds_p->silhouette |= SIL_TOP; - ds_p->tsilheight = INT32_MIN; - // ds_p->sprtopclip = screenheightarray; + // ds_p->sprtopclip = screenheightarray; + } } -#ifdef ESLOPE - if (worldhigh <= worldbottom && worldhighslope <= worldbottomslope) -#else - if (worldhigh <= worldbottom) -#endif + if (!bothceilingssky && !bothfloorssky) { - ds_p->sprbottomclip = negonearray; - ds_p->bsilheight = INT32_MAX; - ds_p->silhouette |= SIL_BOTTOM; - } +#ifdef ESLOPE + if (worldhigh <= worldbottom && worldhighslope <= worldbottomslope) +#else + if (worldhigh <= worldbottom) +#endif + { + ds_p->sprbottomclip = negonearray; + ds_p->bsilheight = INT32_MAX; + ds_p->silhouette |= SIL_BOTTOM; + } #ifdef ESLOPE - if (worldlow >= worldtop && worldlowslope >= worldtopslope) + if (worldlow >= worldtop && worldlowslope >= worldtopslope) #else - if (worldlow >= worldtop) + if (worldlow >= worldtop) #endif - { - ds_p->sprtopclip = screenheightarray; - ds_p->tsilheight = INT32_MIN; - ds_p->silhouette |= SIL_TOP; + { + ds_p->sprtopclip = screenheightarray; + ds_p->tsilheight = INT32_MIN; + ds_p->silhouette |= SIL_TOP; + } } //SoM: 3/25/2000: This code fixes an automap bug that didn't check // frontsector->ceiling and backsector->floor to see if a door was closed. // Without the following code, sprites get displayed behind closed doors. + if (!bothceilingssky && !bothfloorssky) { #ifdef ESLOPE if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope)) @@ -2120,7 +2158,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } - if (worldlow != worldbottom + if (bothfloorssky) + { + // see double ceiling skies comment + // this is the same but for upside down thok barriers where the floor is sky and the ceiling is normal + markfloor = false; + } + else if (worldlow != worldbottom #ifdef ESLOPE || worldlowslope != worldbottomslope || backsector->f_slope != frontsector->f_slope @@ -2132,7 +2176,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) || backsector->floor_yoffs != frontsector->floor_yoffs || backsector->floorpic_angle != frontsector->floorpic_angle //SoM: 3/22/2000: Prevents bleeding. - || frontsector->heightsec != -1 + || (frontsector->heightsec != -1 && frontsector->floorpic != skyflatnum) || backsector->floorlightsec != frontsector->floorlightsec //SoM: 4/3/2000: Check for colormaps || frontsector->extra_colormap != backsector->extra_colormap @@ -2146,7 +2190,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) markfloor = false; } - if (worldhigh != worldtop + if (bothceilingssky) + { + // double ceiling skies are special + // we don't want to lower the ceiling clipping, (no new plane is drawn anyway) + // so we can see the floor of thok barriers always regardless of sector properties + markceiling = false; + } + else if (worldhigh != worldtop #ifdef ESLOPE || worldhighslope != worldtopslope || backsector->c_slope != frontsector->c_slope @@ -2172,19 +2223,28 @@ void R_StoreWallRange(INT32 start, INT32 stop) markceiling = false; } - if (backsector->ceilingheight <= frontsector->floorheight || - backsector->floorheight >= frontsector->ceilingheight) + if (!bothceilingssky && !bothfloorssky) { - // closed door - markceiling = markfloor = true; +#ifdef ESLOPE + if ((worldhigh <= worldbottom && worldhighslope <= worldbottomslope) + || (worldlow >= worldtop && worldlowslope >= worldtopslope)) +#else + if (backsector->ceilingheight <= frontsector->floorheight + || backsector->floorheight >= frontsector->ceilingheight) +#endif + { + // closed door + markceiling = markfloor = true; + } } // check TOP TEXTURE - if (worldhigh < worldtop + if (!bothceilingssky // never draw the top texture if on + && (worldhigh < worldtop #ifdef ESLOPE || worldhighslope < worldtopslope #endif - ) + )) { fixed_t texheight; // top texture @@ -2233,11 +2293,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } // check BOTTOM TEXTURE - if (worldlow > worldbottom + if (!bothfloorssky // never draw the bottom texture if on + && (worldlow > worldbottom #ifdef ESLOPE || worldlowslope > worldbottomslope #endif - ) //seulement si VISIBLE!!! + )) //seulement si VISIBLE!!! { // bottom texture bottomtexture = R_GetTextureNum(sidedef->bottomtexture); @@ -2310,16 +2371,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; #ifdef ESLOPE - if (*rover->t_slope) { - high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); - highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); - } else - high1 = highslope1 = *rover->topheight; - if (*rover->b_slope) { - low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); - lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); - } else - low1 = lowslope1 = *rover->bottomheight; + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; @@ -2351,16 +2404,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) } #ifdef ESLOPE - if (*r2->t_slope) { - high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); - highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); - } else - high2 = highslope2 = *r2->topheight; - if (*r2->b_slope) { - low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); - lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); - } else - low2 = lowslope2 = *r2->bottomheight; + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; @@ -2393,16 +2438,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; #ifdef ESLOPE - if (*rover->t_slope) { - high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); - highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); - } else - high1 = highslope1 = *rover->topheight; - if (*rover->b_slope) { - low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); - lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); - } else - low1 = lowslope1 = *rover->bottomheight; + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; @@ -2434,17 +2471,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) } #ifdef ESLOPE - if (*r2->t_slope) { - high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); - highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); - } else - high2 = highslope2 = *r2->topheight; - if (*r2->b_slope) { - low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); - lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); - } else - low2 = lowslope2 = *r2->bottomheight; - + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) +#undef SLOPEPARAMS if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; if ((high1 > high2 || highslope1 > highslope2) || (low1 < low2 || lowslope1 < lowslope2)) @@ -2633,7 +2662,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) // and doesn't need to be marked. if (frontsector->heightsec == -1) { - if (( + if (frontsector->floorpic != skyflatnum + && ( #ifdef ESLOPE frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : #endif @@ -2643,12 +2673,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) markfloor = false; } - if (( + if (frontsector->ceilingpic != skyflatnum + && ( #ifdef ESLOPE frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : #endif - frontsector->ceilingheight) <= viewz && - frontsector->ceilingpic != skyflatnum) + frontsector->ceilingheight) <= viewz) { // below view plane markceiling = false; @@ -2663,22 +2693,28 @@ void R_StoreWallRange(INT32 start, INT32 stop) worldbottomslope >>= 4; #endif - topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + if (linedef->special == HORIZONSPECIAL) { // HORIZON LINES + topstep = bottomstep = 0; + topfrac = bottomfrac = (centeryfrac>>4); + topfrac++; // Prevent 1px HOM + } else { + topstep = -FixedMul (rw_scalestep, worldtop); + topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); - bottomstep = -FixedMul (rw_scalestep,worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + bottomstep = -FixedMul (rw_scalestep,worldbottom); + bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); #ifdef ESLOPE - if (frontsector->c_slope) { - fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); - topstep = (topfracend-topfrac)/(range); - } - if (frontsector->f_slope) { - fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); - bottomstep = (bottomfracend-bottomfrac)/(range); - } + if (frontsector->c_slope) { + fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2); + topstep = (topfracend-topfrac)/(range); + } + if (frontsector->f_slope) { + fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2); + bottomstep = (bottomfracend-bottomfrac)/(range); + } #endif + } dc_numlights = 0; @@ -2773,7 +2809,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) } rlight->lightlevel = *light->lightlevel; - rlight->extra_colormap = light->extra_colormap; + rlight->extra_colormap = *light->extra_colormap; p++; } @@ -2787,12 +2823,23 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].f_pos >>= 4; #ifdef ESLOPE ffloor[i].f_pos_slope >>= 4; - ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); - ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(range); -#else - ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos); - ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); #endif + if (linedef->special == HORIZONSPECIAL) // Horizon lines extend FOFs in contact with them too. + { + ffloor[i].f_step = 0; + ffloor[i].f_frac = (centeryfrac>>4); + topfrac++; // Prevent 1px HOM + } + else + { +#ifdef ESLOPE + ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); + ffloor[i].f_step = ((centeryfrac>>4) - FixedMul(ffloor[i].f_pos_slope, ds_p->scale2) - ffloor[i].f_frac)/(range); +#else + ffloor[i].f_step = FixedMul(-rw_scalestep, ffloor[i].f_pos); + ffloor[i].f_frac = (centeryfrac>>4) - FixedMul(ffloor[i].f_pos, rw_scale); +#endif + } } } @@ -3106,6 +3153,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (i = 0; i < numffloors; i++) R_ExpandPlane(ffloor[i].plane, rw_x, rw_stopx - 1); } +#ifdef POLYOBJECTS_PLANES + // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red + if (curline->polyseg) + { + for (i = 0; i < numffloors; i++) + { + if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) + continue; + if (ffloor[i].plane->minx > rw_x) + ffloor[i].plane->minx = rw_x; + + if (ffloor[i].plane->maxx < rw_stopx - 1) + ffloor[i].plane->maxx = rw_stopx - 1; + } + } +#endif } #ifdef WALLSPLATS @@ -3122,7 +3185,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) else #endif R_RenderSegLoop(); - colfunc = wallcolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; if (portalline) // if curline is a portal, set portalrender for drawseg ds_p->portalpass = portalrender+1; diff --git a/src/r_segs.h b/src/r_segs.h index 92d0100e2..a61f1f921 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/r_skins.c b/src/r_skins.c new file mode 100644 index 000000000..2e9548bd7 --- /dev/null +++ b/src/r_skins.c @@ -0,0 +1,825 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_skins.c +/// \brief Loading skins + +#include "doomdef.h" +#include "console.h" +#include "g_game.h" +#include "r_local.h" +#include "st_stuff.h" +#include "w_wad.h" +#include "z_zone.h" +#include "m_misc.h" +#include "info.h" // spr2names +#include "i_video.h" // rendermode +#include "i_system.h" +#include "r_things.h" +#include "r_skins.h" +#include "p_local.h" +#include "dehacked.h" // get_number (for thok) +#include "m_cond.h" +#ifdef HWRENDER +#include "hardware/hw_md2.h" +#endif + +#ifdef PC_DOS +#include // for snprintf +int snprintf(char *str, size_t n, const char *fmt, ...); +//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); +#endif + +INT32 numskins = 0; +skin_t skins[MAXSKINS]; + +// FIXTHIS: don't work because it must be inistilised before the config load +//#define SKINVALUES +#ifdef SKINVALUES +CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; +#endif + +// +// P_GetSkinSprite2 +// For non-super players, tries each sprite2's immediate predecessor until it finds one with a number of frames or ends up at standing. +// For super players, does the same as above - but tries the super equivalent for each sprite2 before the non-super version. +// + +UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player) +{ + UINT8 super = 0, i = 0; + + if (!skin) + return 0; + + if ((playersprite_t)(spr2 & ~FF_SPR2SUPER) >= free_spr2) + return 0; + + while (!skin->sprites[spr2].numframes + && spr2 != SPR2_STND + && ++i < 32) // recursion limiter + { + if (spr2 & FF_SPR2SUPER) + { + super = FF_SPR2SUPER; + spr2 &= ~FF_SPR2SUPER; + continue; + } + + switch(spr2) + { + // Normal special cases. + case SPR2_JUMP: + spr2 = ((player + ? player->charflags + : skin->flags) + & SF_NOJUMPSPIN) ? SPR2_SPNG : SPR2_ROLL; + break; + case SPR2_TIRE: + spr2 = ((player + ? player->charability + : skin->ability) + == CA_SWIM) ? SPR2_SWIM : SPR2_FLY; + break; + // Use the handy list, that's what it's there for! + default: + spr2 = spr2defaults[spr2]; + break; + } + + spr2 |= super; + } + + if (i >= 32) // probably an infinite loop... + return 0; + + return spr2; +} + +static void Sk_SetDefaultValue(skin_t *skin) +{ + INT32 i; + // + // set default skin values + // + memset(skin, 0, sizeof (skin_t)); + snprintf(skin->name, + sizeof skin->name, "skin %u", (UINT32)(skin-skins)); + skin->name[sizeof skin->name - 1] = '\0'; + skin->wadnum = INT16_MAX; + + skin->flags = 0; + + strcpy(skin->realname, "Someone"); + strcpy(skin->hudname, "???"); + + skin->starttranscolor = 96; + skin->prefcolor = SKINCOLOR_GREEN; + skin->supercolor = SKINCOLOR_SUPERGOLD1; + skin->prefoppositecolor = 0; // use tables + + skin->normalspeed = 36<runspeed = 28<thrustfactor = 5; + skin->accelstart = 96; + skin->acceleration = 40; + + skin->ability = CA_NONE; + skin->ability2 = CA2_SPINDASH; + skin->jumpfactor = FRACUNIT; + skin->actionspd = 30<mindash = 15<maxdash = 70<radius = mobjinfo[MT_PLAYER].radius; + skin->height = mobjinfo[MT_PLAYER].height; + skin->spinheight = FixedMul(skin->height, 2*FRACUNIT/3); + + skin->shieldscale = FRACUNIT; + skin->camerascale = FRACUNIT; + + skin->thokitem = -1; + skin->spinitem = -1; + skin->revitem = -1; + skin->followitem = 0; + + skin->highresscale = FRACUNIT; + skin->contspeed = 17; + skin->contangle = 0; + + skin->availability = 0; + + for (i = 0; i < sfx_skinsoundslot0; i++) + if (S_sfx[i].skinsound != -1) + skin->soundsid[S_sfx[i].skinsound] = i; +} + +// +// Initialize the basic skins +// +void R_InitSkins(void) +{ +#ifdef SKINVALUES + INT32 i; + + for (i = 0; i <= MAXSKINS; i++) + { + skin_cons_t[i].value = 0; + skin_cons_t[i].strvalue = NULL; + } +#endif + + // no default skin! + numskins = 0; +} + +UINT32 R_GetSkinAvailabilities(void) +{ + INT32 s; + UINT32 response = 0; + + for (s = 0; s < MAXSKINS; s++) + { + if (skins[s].availability && unlockables[skins[s].availability - 1].unlocked) + response |= (1 << s); + } + return response; +} + +// returns true if available in circumstances, otherwise nope +// warning don't use with an invalid skinnum other than -1 which always returns true +boolean R_SkinUsable(INT32 playernum, INT32 skinnum) +{ + return ((skinnum == -1) // Simplifies things elsewhere, since there's already plenty of checks for less-than-0... + || (!skins[skinnum].availability) + || (((netgame || multiplayer) && playernum != -1) ? (players[playernum].availabilities & (1 << skinnum)) : (unlockables[skins[skinnum].availability - 1].unlocked)) + || (modeattacking) // If you have someone else's run you might as well take a look + || (Playing() && (R_SkinAvailable(mapheaderinfo[gamemap-1]->forcecharacter) == skinnum)) // Force 1. + || (netgame && (cv_forceskin.value == skinnum)) // Force 2. + || (metalrecording && skinnum == 5) // Force 3. + ); +} + +// returns true if the skin name is found (loaded from pwad) +// warning return -1 if not found +INT32 R_SkinAvailable(const char *name) +{ + INT32 i; + + for (i = 0; i < numskins; i++) + { + // search in the skin list + if (stricmp(skins[i].name,name)==0) + return i; + } + return -1; +} + +// network code calls this when a 'skin change' is received +void SetPlayerSkin(INT32 playernum, const char *skinname) +{ + INT32 i = R_SkinAvailable(skinname); + player_t *player = &players[playernum]; + + if ((i != -1) && R_SkinUsable(playernum, i)) + { + SetPlayerSkinByNum(playernum, i); + return; + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); + + SetPlayerSkinByNum(playernum, 0); +} + +// Same as SetPlayerSkin, but uses the skin #. +// network code calls this when a 'skin change' is received +void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) +{ + player_t *player = &players[playernum]; + skin_t *skin = &skins[skinnum]; + UINT8 newcolor = 0; + + if (skinnum >= 0 && skinnum < numskins && R_SkinUsable(playernum, skinnum)) // Make sure it exists! + { + player->skin = skinnum; + + player->camerascale = skin->camerascale; + player->shieldscale = skin->shieldscale; + + player->charability = (UINT8)skin->ability; + player->charability2 = (UINT8)skin->ability2; + + player->charflags = (UINT32)skin->flags; + + player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; + player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; + player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; + player->followitem = skin->followitem; + + if (((player->powers[pw_shield] & SH_NOSTACK) == SH_PINK) && (player->revitem == MT_LHRT || player->spinitem == MT_LHRT || player->thokitem == MT_LHRT)) // Healers can't keep their buff. + player->powers[pw_shield] &= SH_STACK; + + player->actionspd = skin->actionspd; + player->mindash = skin->mindash; + player->maxdash = skin->maxdash; + + player->normalspeed = skin->normalspeed; + player->runspeed = skin->runspeed; + player->thrustfactor = skin->thrustfactor; + player->accelstart = skin->accelstart; + player->acceleration = skin->acceleration; + + player->jumpfactor = skin->jumpfactor; + + player->height = skin->height; + player->spinheight = skin->spinheight; + + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + { + if (playernum == consoleplayer) + CV_StealthSetValue(&cv_playercolor, skin->prefcolor); + else if (playernum == secondarydisplayplayer) + CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); + player->skincolor = newcolor = skin->prefcolor; + } + + if (player->followmobj) + { + P_RemoveMobj(player->followmobj); + P_SetTarget(&player->followmobj, NULL); + } + + if (player->mo) + { + fixed_t radius = FixedMul(skin->radius, player->mo->scale); + if ((player->powers[pw_carry] == CR_NIGHTSMODE) && (skin->sprites[SPR2_NFLY].numframes == 0)) // If you don't have a sprite for flying horizontally, use the default NiGHTS skin. + { + skin = &skins[DEFAULTNIGHTSSKIN]; + player->followitem = skin->followitem; + if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) + newcolor = skin->prefcolor; // will be updated in thinker to flashing + } + player->mo->skin = skin; + if (newcolor) + player->mo->color = newcolor; + P_SetScale(player->mo, player->mo->scale); + player->mo->radius = radius; + + P_SetPlayerMobjState(player->mo, player->mo->state-states); // Prevent visual errors when switching between skins with differing number of frames + } + return; + } + + if (P_IsLocalPlayer(player)) + CONS_Alert(CONS_WARNING, M_GetText("Requested skin %d not found\n"), skinnum); + else if(server || IsPlayerAdmin(consoleplayer)) + CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); + SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin +} + +// +// Add skins from a pwad, each skin preceded by 'S_SKIN' marker +// + +// Does the same is in w_wad, but check only for +// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2.. +// for wad editors that don't like multiple resources of the same name) +// +static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) +{ + UINT16 i; + const char *S_SKIN = "S_SKIN"; + lumpinfo_t *lump_p; + + // scan forward, start at + if (startlump < wadfiles[wadid]->numlumps) + { + lump_p = wadfiles[wadid]->lumpinfo + startlump; + for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name,S_SKIN,6)==0) + return i; + } + return INT16_MAX; // not found +} + +#define HUDNAMEWRITE(value) STRBUFCPY(skin->hudname, value) + +// turn _ into spaces and . into katana dot +#define SYMBOLCONVERT(name) for (value = name; *value; value++)\ + {\ + if (*value == '_') *value = ' ';\ + else if (*value == '.') *value = '\x1E';\ + } + +// +// Patch skins from a pwad, each skin preceded by 'P_SKIN' marker +// + +// Does the same is in w_wad, but check only for +// the first 6 characters (this is so we can have P_SKIN1, P_SKIN2.. +// for wad editors that don't like multiple resources of the same name) +// +static UINT16 W_CheckForPatchSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) +{ + UINT16 i; + const char *P_SKIN = "P_SKIN"; + lumpinfo_t *lump_p; + + // scan forward, start at + if (startlump < wadfiles[wadid]->numlumps) + { + lump_p = wadfiles[wadid]->lumpinfo + startlump; + for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name,P_SKIN,6)==0) + return i; + } + return INT16_MAX; // not found +} + +static void R_LoadSkinSprites(UINT16 wadnum, UINT16 *lump, UINT16 *lastlump, skin_t *skin) +{ + UINT16 newlastlump; + UINT8 sprite2; + + *lump += 1; // start after S_SKIN + *lastlump = W_CheckNumForNamePwad("S_END",wadnum,*lump); // stop at S_END + + // old wadding practices die hard -- stop at S_SKIN (or P_SKIN) or S_START if they come before S_END. + newlastlump = W_CheckForSkinMarkerInPwad(wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; + newlastlump = W_CheckForPatchSkinMarkerInPwad(wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; + newlastlump = W_CheckNumForNamePwad("S_START",wadnum,*lump); + if (newlastlump < *lastlump) *lastlump = newlastlump; + + // ...and let's handle super, too + newlastlump = W_CheckNumForNamePwad("S_SUPER",wadnum,*lump); + if (newlastlump < *lastlump) + { + newlastlump++; + // load all sprite sets we are aware of... for super! + for (sprite2 = 0; sprite2 < free_spr2; sprite2++) + R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[FF_SPR2SUPER|sprite2], wadnum, newlastlump, *lastlump); + + newlastlump--; + *lastlump = newlastlump; // okay, make the normal sprite set loading end there + } + + // load all sprite sets we are aware of... for normal stuff. + for (sprite2 = 0; sprite2 < free_spr2; sprite2++) + R_AddSingleSpriteDef(spr2names[sprite2], &skin->sprites[sprite2], wadnum, *lump, *lastlump); + + if (skin->sprites[0].numframes == 0) + I_Error("R_LoadSkinSprites: no frames found for sprite SPR2_%s\n", spr2names[0]); +} + +// returns whether found appropriate property +static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value) +{ + // custom translation table + if (!stricmp(stoken, "startcolor")) + skin->starttranscolor = atoi(value); + +#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); + // character type identification + FULLPROCESS(flags) + FULLPROCESS(ability) + FULLPROCESS(ability2) + + FULLPROCESS(thokitem) + FULLPROCESS(spinitem) + FULLPROCESS(revitem) + FULLPROCESS(followitem) +#undef FULLPROCESS + +#define GETFRACBITS(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value)<field = atoi(value); + GETINT(thrustfactor) + GETINT(accelstart) + GETINT(acceleration) + GETINT(contspeed) + GETINT(contangle) +#undef GETINT + +#define GETSKINCOLOR(field) else if (!stricmp(stoken, #field)) skin->field = R_GetColorByName(value); + GETSKINCOLOR(prefcolor) + GETSKINCOLOR(prefoppositecolor) +#undef GETSKINCOLOR + else if (!stricmp(stoken, "supercolor")) + skin->supercolor = R_GetSuperColorByName(value); + +#define GETFLOAT(field) else if (!stricmp(stoken, #field)) skin->field = FLOAT_TO_FIXED(atof(value)); + GETFLOAT(jumpfactor) + GETFLOAT(highresscale) + GETFLOAT(shieldscale) + GETFLOAT(camerascale) +#undef GETFLOAT + +#define GETFLAG(field) else if (!stricmp(stoken, #field)) { \ + strupr(value); \ + if (atoi(value) || value[0] == 'T' || value[0] == 'Y') \ + skin->flags |= (SF_##field); \ + else \ + skin->flags &= ~(SF_##field); \ +} + // parameters for individual character flags + // these are uppercase so they can be concatenated with SF_ + // 1, true, yes are all valid values + GETFLAG(SUPER) + GETFLAG(NOSUPERSPIN) + GETFLAG(NOSPINDASHDUST) + GETFLAG(HIRES) + GETFLAG(NOSKID) + GETFLAG(NOSPEEDADJUST) + GETFLAG(RUNONWATER) + GETFLAG(NOJUMPSPIN) + GETFLAG(NOJUMPDAMAGE) + GETFLAG(STOMPDAMAGE) + GETFLAG(MARIODAMAGE) + GETFLAG(MACHINE) + GETFLAG(DASHMODE) + GETFLAG(FASTEDGE) + GETFLAG(MULTIABILITY) + GETFLAG(NONIGHTSROTATION) +#undef GETFLAG + + else // let's check if it's a sound, otherwise error out + { + boolean found = false; + sfxenum_t i; + size_t stokenadjust; + + // Remove the prefix. (We need to affect an adjusting variable so that we can print error messages if it's not actually a sound.) + if ((stoken[0] == 'D' || stoken[0] == 'd') && (stoken[1] == 'S' || stoken[1] == 's')) // DS* + stokenadjust = 2; + else // sfx_* + stokenadjust = 4; + + // Remove the prefix. (We can affect this directly since we're not going to use it again.) + if ((value[0] == 'D' || value[0] == 'd') && (value[1] == 'S' || value[1] == 's')) // DS* + value += 2; + else // sfx_* + value += 4; + + // copy name of sounds that are remapped + // for this skin + for (i = 0; i < sfx_skinsoundslot0; i++) + { + if (!S_sfx[i].name) + continue; + if (S_sfx[i].skinsound != -1 + && !stricmp(S_sfx[i].name, + stoken + stokenadjust)) + { + skin->soundsid[S_sfx[i].skinsound] = + S_AddSoundFx(value, S_sfx[i].singularity, S_sfx[i].pitch, true); + found = true; + } + } + return found; + } + return true; +} + +// +// Find skin sprites, sounds & optional status bar face, & add them +// +void R_AddSkins(UINT16 wadnum) +{ + UINT16 lump, lastlump = 0; + char *buf; + char *buf2; + char *stoken; + char *value; + size_t size; + skin_t *skin; + boolean hudname, realname; + + // + // search for all skin markers in pwad + // + + while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + { + // advance by default + lastlump = lump + 1; + + if (numskins >= MAXSKINS) + { + CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", MAXSKINS); + continue; // so we know how many skins couldn't be added + } + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lump); + + // for strtok + buf2 = malloc(size+1); + if (!buf2) + I_Error("R_AddSkins: No more free memory\n"); + M_Memcpy(buf2,buf,size); + buf2[size] = '\0'; + + // set defaults + skin = &skins[numskins]; + Sk_SetDefaultValue(skin); + skin->wadnum = wadnum; + hudname = realname = false; + // parse + stoken = strtok (buf2, "\r\n= "); + while (stoken) + { + if ((stoken[0] == '/' && stoken[1] == '/') + || (stoken[0] == '#'))// skip comments + { + stoken = strtok(NULL, "\r\n"); // skip end of line + goto next_token; // find the real next token + } + + value = strtok(NULL, "\r\n= "); + + if (!value) + I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + + // Some of these can't go in R_ProcessPatchableFields because they have side effects for future lines. + // Others can't go in there because we don't want them to be patchable. + if (!stricmp(stoken, "name")) + { + INT32 skinnum = R_SkinAvailable(value); + strlwr(value); + if (skinnum == -1) + STRBUFCPY(skin->name, value); + // the skin name must uniquely identify a single skin + // if the name is already used I make the name 'namex' + // using the default skin name's number set above + else + { + const size_t stringspace = + strlen(value) + sizeof (numskins) + 1; + char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); + snprintf(value2, stringspace, + "%s%d", value, numskins); + value2[stringspace - 1] = '\0'; + if (R_SkinAvailable(value2) == -1) + // I'm lazy so if NEW name is already used I leave the 'skin x' + // default skin name set in Sk_SetDefaultValue + STRBUFCPY(skin->name, value2); + Z_Free(value2); + } + + // copy to hudname and fullname as a default. + if (!realname) + { + STRBUFCPY(skin->realname, skin->name); + for (value = skin->realname; *value; value++) + { + if (*value == '_') *value = ' '; // turn _ into spaces. + else if (*value == '.') *value = '\x1E'; // turn . into katana dot. + } + } + if (!hudname) + { + HUDNAMEWRITE(skin->name); + strupr(skin->hudname); + SYMBOLCONVERT(skin->hudname) + } + } + else if (!stricmp(stoken, "realname")) + { // Display name (eg. "Knuckles") + realname = true; + STRBUFCPY(skin->realname, value); + SYMBOLCONVERT(skin->realname) + if (!hudname) + HUDNAMEWRITE(skin->realname); + } + else if (!stricmp(stoken, "hudname")) + { // Life icon name (eg. "K.T.E") + hudname = true; + HUDNAMEWRITE(value); + SYMBOLCONVERT(skin->hudname) + if (!realname) + STRBUFCPY(skin->realname, skin->hudname); + } + else if (!stricmp(stoken, "availability")) + { + skin->availability = atoi(value); + if (skin->availability >= MAXUNLOCKABLES) + skin->availability = 0; + } + else if (!R_ProcessPatchableFields(skin, stoken, value)) + CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); + +next_token: + stoken = strtok(NULL, "\r\n= "); + } + free(buf2); + + // Add sprites + R_LoadSkinSprites(wadnum, &lump, &lastlump, skin); + //ST_LoadFaceGraphics(numskins); -- nah let's do this elsewhere + + R_FlushTranslationColormapCache(); + + if (!skin->availability) // Safe to print... + CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); +#ifdef SKINVALUES + skin_cons_t[numskins].value = numskins; + skin_cons_t[numskins].strvalue = skin->name; +#endif + +#ifdef HWRENDER + if (rendermode == render_opengl) + HWR_AddPlayerModel(numskins); +#endif + + numskins++; + } + return; +} + +// +// Patch skin sprites +// +void R_PatchSkins(UINT16 wadnum) +{ + UINT16 lump, lastlump = 0; + char *buf; + char *buf2; + char *stoken; + char *value; + size_t size; + skin_t *skin; + boolean noskincomplain, realname, hudname; + + // + // search for all skin patch markers in pwad + // + + while ((lump = W_CheckForPatchSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) + { + INT32 skinnum = 0; + + // advance by default + lastlump = lump + 1; + + buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lump); + + // for strtok + buf2 = malloc(size+1); + if (!buf2) + I_Error("R_PatchSkins: No more free memory\n"); + M_Memcpy(buf2,buf,size); + buf2[size] = '\0'; + + skin = NULL; + noskincomplain = realname = hudname = false; + + /* + Parse. Has more phases than the parser in R_AddSkins because it needs to have the patching name first (no default skin name is acceptible for patching, unlike skin creation) + */ + + stoken = strtok(buf2, "\r\n= "); + while (stoken) + { + if ((stoken[0] == '/' && stoken[1] == '/') + || (stoken[0] == '#'))// skip comments + { + stoken = strtok(NULL, "\r\n"); // skip end of line + goto next_token; // find the real next token + } + + value = strtok(NULL, "\r\n= "); + + if (!value) + I_Error("R_PatchSkins: syntax error in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + + if (!skin) // Get the name! + { + if (!stricmp(stoken, "name")) + { + strlwr(value); + skinnum = R_SkinAvailable(value); + if (skinnum != -1) + skin = &skins[skinnum]; + else + { + CONS_Debug(DBG_SETUP, "R_PatchSkins: unknown skin name in P_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); + noskincomplain = true; + } + } + } + else // Get the properties! + { + // Some of these can't go in R_ProcessPatchableFields because they have side effects for future lines. + if (!stricmp(stoken, "realname")) + { // Display name (eg. "Knuckles") + realname = true; + STRBUFCPY(skin->realname, value); + SYMBOLCONVERT(skin->realname) + if (!hudname) + HUDNAMEWRITE(skin->realname); + } + else if (!stricmp(stoken, "hudname")) + { // Life icon name (eg. "K.T.E") + hudname = true; + HUDNAMEWRITE(value); + SYMBOLCONVERT(skin->hudname) + if (!realname) + STRBUFCPY(skin->realname, skin->hudname); + } + else if (!R_ProcessPatchableFields(skin, stoken, value)) + CONS_Debug(DBG_SETUP, "R_PatchSkins: Unknown keyword '%s' in P_SKIN lump #%d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); + } + + if (!skin) + break; + +next_token: + stoken = strtok(NULL, "\r\n= "); + } + free(buf2); + + if (!skin) // Didn't include a name parameter? What a waste. + { + if (!noskincomplain) + CONS_Debug(DBG_SETUP, "R_PatchSkins: no skin name given in P_SKIN lump #%d (WAD %s)\n", lump, wadfiles[wadnum]->filename); + continue; + } + + // Patch sprites + R_LoadSkinSprites(wadnum, &lump, &lastlump, skin); + //ST_LoadFaceGraphics(skinnum); -- nah let's do this elsewhere + + R_FlushTranslationColormapCache(); + + if (!skin->availability) // Safe to print... + CONS_Printf(M_GetText("Patched skin '%s'\n"), skin->name); + } + return; +} + +#undef HUDNAMEWRITE +#undef SYMBOLCONVERT diff --git a/src/r_skins.h b/src/r_skins.h new file mode 100644 index 000000000..96697b422 --- /dev/null +++ b/src/r_skins.h @@ -0,0 +1,103 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2020 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_skins.h +/// \brief Skins stuff + +#ifndef __R_SKINS__ +#define __R_SKINS__ + +#include "info.h" +#include "sounds.h" +#include "d_player.h" // skinflags +#include "r_patch.h" // spriteinfo_t +#include "r_defs.h" // spritedef_t + +/// Defaults +#define SKINNAMESIZE 16 +// should be all lowercase!! S_SKIN processing does a strlwr +#define DEFAULTSKIN "sonic" +#define DEFAULTSKIN2 "tails" // secondary player +#define DEFAULTNIGHTSSKIN 0 + +/// The skin_t struct +typedef struct +{ + char name[SKINNAMESIZE+1]; // INT16 descriptive name of the skin + UINT16 wadnum; + skinflags_t flags; + + char realname[SKINNAMESIZE+1]; // Display name for level completion. + char hudname[SKINNAMESIZE+1]; // HUD name to display (officially exactly 5 characters long) + + UINT8 ability; // ability definition + UINT8 ability2; // secondary ability definition + INT32 thokitem; + INT32 spinitem; + INT32 revitem; + INT32 followitem; + fixed_t actionspd; + fixed_t mindash; + fixed_t maxdash; + + fixed_t normalspeed; // Normal ground + fixed_t runspeed; // Speed that you break into your run animation + + UINT8 thrustfactor; // Thrust = thrustfactor * acceleration + UINT8 accelstart; // Acceleration if speed = 0 + UINT8 acceleration; // Acceleration + + fixed_t jumpfactor; // multiple of standard jump height + + fixed_t radius; // Bounding box changes. + fixed_t height; + fixed_t spinheight; + + fixed_t shieldscale; // no change to bounding box, but helps set the shield's sprite size + fixed_t camerascale; + + // Definable color translation table + UINT8 starttranscolor; + UINT8 prefcolor; + UINT8 supercolor; + UINT8 prefoppositecolor; // if 0 use tables instead + + fixed_t highresscale; // scale of highres, default is 0.5 + UINT8 contspeed; // continue screen animation speed + UINT8 contangle; // initial angle on continue screen + + // specific sounds per skin + sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table + + // contains super versions too + spritedef_t sprites[NUMPLAYERSPRITES*2]; + spriteinfo_t sprinfo[NUMPLAYERSPRITES*2]; + + UINT8 availability; // lock? +} skin_t; + +/// Externs +extern INT32 numskins; +extern skin_t skins[MAXSKINS]; + +/// Function prototypes +void R_InitSkins(void); + +void SetPlayerSkin(INT32 playernum,const char *skinname); +void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 +boolean R_SkinUsable(INT32 playernum, INT32 skinnum); +UINT32 R_GetSkinAvailabilities(void); +INT32 R_SkinAvailable(const char *name); +void R_PatchSkins(UINT16 wadnum); +void R_AddSkins(UINT16 wadnum); + +UINT8 P_GetSkinSprite2(skin_t *skin, UINT8 spr2, player_t *player); + +#endif //__R_SKINS__ diff --git a/src/r_sky.c b/src/r_sky.c index 2df6e4cd8..7cdcfa44d 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -64,10 +64,6 @@ void R_SetupSkyDraw(void) // the horizon line in a 256x128 sky texture skytexturemid = (textures[skytexture]->height/2)<flags = flags; // bad.. but will be needed for drawing anyway.. - patch = W_CachePatchNum(splat->patch, PU_CACHE); + patch = W_CachePatchNum(splat->patch, PU_PATCH); // offset needed by draw code for texture mapping linelength = P_SegLength((seg_t *)wallline); @@ -512,7 +512,7 @@ static void R_RenderFloorSplat(floorsplat_t *pSplat, vertex_t *verts, UINT8 *pTe ds_x1 = x1; ds_x2 = x2; ds_transmap = transtables + ((tr_trans50-1)< // for snprintf -int snprintf(char *str, size_t n, const char *fmt, ...); -//int vsnprintf(char *str, size_t n, const char *fmt, va_list ap); -#endif - -static void R_InitSkins(void); - #define MINZ (FRACUNIT*4) #define BASEYCENTER (BASEVIDHEIGHT/2) @@ -63,6 +62,8 @@ static lighttable_t **spritelights; INT16 negonearray[MAXVIDWIDTH]; INT16 screenheightarray[MAXVIDWIDTH]; +spriteinfo_t spriteinfo[NUMSPRITES]; + // // INITIALIZATION FUNCTIONS // @@ -93,49 +94,110 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch UINT8 rotation, UINT8 flipped) { - char cn = R_Frame2Char(frame); // for debugging + char cn = R_Frame2Char(frame), cr = R_Rotation2Char(rotation); // for debugging - INT32 r; + INT32 r, ang; lumpnum_t lumppat = wad; lumppat <<= 16; lumppat += lump; - if (frame >= 64 || rotation > 8) - I_Error("R_InstallSpriteLump: Bad frame characters in lump %s", W_CheckNameForNum(lumppat)); - if (maxframe ==(size_t)-1 || frame > maxframe) maxframe = frame; + // rotsprite +#ifdef ROTSPRITE + sprtemp[frame].rotsprite.cached = 0; + for (r = 0; r < 16; r++) + { + for (ang = 0; ang < ROTANGLES; ang++) + sprtemp[frame].rotsprite.patch[r][ang] = NULL; + } +#endif/*ROTSPRITE*/ + if (rotation == 0) { // the lump should be used for all rotations - if (sprtemp[frame].rotate == 0) + if (sprtemp[frame].rotate == SRF_SINGLE) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has multiple rot = 0 lump\n", spritename, cn); - - if (sprtemp[frame].rotate == 1) + else if (sprtemp[frame].rotate != SRF_NONE) // Let's bundle 1-8/16 and L/R rotations into one debug message. CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has rotations and a rot = 0 lump\n", spritename, cn); - sprtemp[frame].rotate = 0; - for (r = 0; r < 8; r++) + sprtemp[frame].rotate = SRF_SINGLE; + for (r = 0; r < 16; r++) { sprtemp[frame].lumppat[r] = lumppat; sprtemp[frame].lumpid[r] = lumpid; } - sprtemp[frame].flip = flipped ? UINT8_MAX : 0; + sprtemp[frame].flip = flipped ? 0xFFFF : 0; // 1111111111111111 in binary return; } - // the lump is only used for one rotation - if (sprtemp[frame].rotate == 0) - CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has rotations and a rot = 0 lump\n", spritename, cn); + if (rotation == ROT_L || rotation == ROT_R) + { + UINT8 rightfactor = ((rotation == ROT_R) ? 4 : 0); - sprtemp[frame].rotate = 1; + // the lump should be used for half of all rotations + if (sprtemp[frame].rotate == SRF_NONE) + sprtemp[frame].rotate = SRF_SINGLE; + else if (sprtemp[frame].rotate == SRF_SINGLE) + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has L/R rotations and a rot = 0 lump\n", spritename, cn); + else if (sprtemp[frame].rotate == SRF_3D) + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-8 rotations\n", spritename, cn); + else if (sprtemp[frame].rotate == SRF_3DGE) + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-G rotations\n", spritename, cn); + else if ((sprtemp[frame].rotate & SRF_LEFT) && (rotation == ROT_L)) + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has multiple L rotations\n", spritename, cn); + else if ((sprtemp[frame].rotate & SRF_RIGHT) && (rotation == ROT_R)) + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has multiple R rotations\n", spritename, cn); + + sprtemp[frame].rotate |= ((rotation == ROT_R) ? SRF_RIGHT : SRF_LEFT); + if ((sprtemp[frame].rotate & SRF_2D) == SRF_2D) + sprtemp[frame].rotate &= ~SRF_3DMASK; // SRF_3D|SRF_2D being enabled at the same time doesn't HURT in the current sprite angle implementation, but it DOES mean more to check in some of the helper functions. Let's not allow this scenario to happen. + + // load into every relevant angle, including the front one + for (r = 0; r < 4; r++) + { + sprtemp[frame].lumppat[r + rightfactor] = lumppat; + sprtemp[frame].lumpid[r + rightfactor] = lumpid; + sprtemp[frame].lumppat[r + rightfactor + 8] = lumppat; + sprtemp[frame].lumpid[r + rightfactor + 8] = lumpid; + + } + + if (flipped) + sprtemp[frame].flip |= (0x0F0F< 7) ? SRF_3DGE : (sprtemp[frame].rotate & SRF_3DMASK); + if (!threedrot) + threedrot = SRF_3D; + + if (rotation == 0 || rotation == 4) // Front or back... + sprtemp[frame].rotate = threedrot; // Prevent L and R changeover + else if ((rotation & 7) > 3) // Right side + sprtemp[frame].rotate = (threedrot | (sprtemp[frame].rotate & SRF_LEFT)); // Continue allowing L frame changeover + else // if ((rotation & 7) <= 3) // Left side + sprtemp[frame].rotate = (threedrot | (sprtemp[frame].rotate & SRF_RIGHT)); // Continue allowing R frame changeover + } + if (sprtemp[frame].lumppat[rotation] != LUMPERROR) - CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s: %c%c has two lumps mapped to it\n", spritename, cn, '1'+rotation); + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s: %c%c has two lumps mapped to it\n", spritename, cn, cr); // lumppat & lumpid are the same for original Doom, but different // when using sprites in pwad : the lumppat points the new graphics @@ -160,7 +222,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // // Returns true if the sprite was succesfully added // -static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) +boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) { UINT16 l; UINT8 frame; @@ -172,10 +234,15 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, memset(sprtemp,0xFF, sizeof (sprtemp)); maxframe = (size_t)-1; + spritename = sprname; + // are we 'patching' a sprite already loaded ? // if so, it might patch only certain frames, not all if (spritedef->numframes) // (then spriteframes is not null) { +#ifdef ROTSPRITE + R_FreeSingleRotSprite(spritedef); +#endif // copy the already defined sprite frames M_Memcpy(sprtemp, spritedef->spriteframes, spritedef->numframes * sizeof (spriteframe_t)); @@ -193,9 +260,9 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, if (memcmp(lumpinfo[l].name,sprname,4)==0) { frame = R_Char2Frame(lumpinfo[l].name[4]); - rotation = (UINT8)(lumpinfo[l].name[5] - '0'); + rotation = R_Char2Rotation(lumpinfo[l].name[5]); - if (frame >= 64 || rotation > 8) // Give an actual NAME error -_-... + if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-... { CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); continue; @@ -208,6 +275,19 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // store sprite info in lookup tables //FIXME : numspritelumps do not duplicate sprite replacements W_ReadLumpHeaderPwad(wadnum, l, &patch, sizeof (patch_t), 0); +#ifndef NO_PNG_LUMPS + { + patch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC); + size_t len = W_LumpLengthPwad(wadnum, l); + // lump is a png so convert it + if (R_IsLumpPNG((UINT8 *)png, len)) + { + png = R_PNGToPatch((UINT8 *)png, len, NULL); + M_Memcpy(&patch, png, sizeof(INT16)*4); + } + Z_Free(png); + } +#endif spritecachedinfo[numspritelumps].width = SHORT(patch.width)<0 && SHORT(patch.topoffset)>FRACBITS),SHORT(patch.height))<= 64 || rotation == 255) // Give an actual NAME error -_-... + { + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); + continue; + } R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); } @@ -278,23 +364,31 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, { switch (sprtemp[frame].rotate) { - case 0xff: + case SRF_NONE: // no rotations were found for that frame at all I_Error("R_AddSingleSpriteDef: No patches found for %.4s frame %c", sprname, R_Frame2Char(frame)); break; - case 0: + case SRF_SINGLE: // only the first rotation is needed break; - case 1: - // must have all 8 frames - for (rotation = 0; rotation < 8; rotation++) + case SRF_2D: // both Left and Right rotations + // we test to see whether the left and right slots are present + if ((sprtemp[frame].lumppat[2] == LUMPERROR) || (sprtemp[frame].lumppat[6] == LUMPERROR)) + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations (L-R mode)", + sprname, R_Frame2Char(frame)); + break; + + default: + // must have all 8/16 frames + rotation = ((sprtemp[frame].rotate & SRF_3DGE) ? 16 : 8); + while (rotation--) // we test the patch lump, or the id lump whatever // if it was not loaded the two are LUMPERROR if (sprtemp[frame].lumppat[rotation] == LUMPERROR) - I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", - sprname, R_Frame2Char(frame)); + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations (1-%c mode)", + sprname, R_Frame2Char(frame), ((sprtemp[frame].rotate & SRF_3DGE) ? 'G' : '8')); break; } } @@ -303,6 +397,9 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, if (spritedef->numframes && // has been allocated spritedef->numframes < maxframe) // more frames are defined ? { +#ifdef ROTSPRITE + R_FreeSingleRotSprite(spritedef); +#endif Z_Free(spritedef->spriteframes); spritedef->spriteframes = NULL; } @@ -327,16 +424,14 @@ void R_AddSpriteDefs(UINT16 wadnum) UINT16 start, end; char wadname[MAX_WADPATH]; + // Find the sprites section in this resource file. switch (wadfiles[wadnum]->type) { case RET_WAD: start = W_CheckNumForNamePwad("S_START", wadnum, 0); if (start == INT16_MAX) start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib. - if (start == INT16_MAX) - start = 0; //let say S_START is lump 0 - else - start++; // just after S_START + end = W_CheckNumForNamePwad("S_END",wadnum,start); if (end == INT16_MAX) end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib. @@ -349,31 +444,42 @@ void R_AddSpriteDefs(UINT16 wadnum) return; } - if (end == INT16_MAX) + if (start == INT16_MAX) + { + // ignore skin wads (we don't want skin sprites interfering with vanilla sprites) + if (W_CheckNumForNamePwad("S_SKIN", wadnum, 0) != UINT16_MAX) + return; + + start = 0; //let say S_START is lump 0 + } + else + start++; // just after S_START + + if (end == INT16_MAX || start >= end) { CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum); return; } + // // scan through lumps, for each sprite, find all the sprite frames // for (i = 0; i < numsprites; i++) { - spritename = sprnames[i]; - if (spritename[4] && wadnum >= (UINT16)spritename[4]) + if (sprnames[i][4] && wadnum >= (UINT16)sprnames[i][4]) continue; - if (R_AddSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) + if (R_AddSingleSpriteDef(sprnames[i], &sprites[i], wadnum, start, end)) { #ifdef HWRENDER if (rendermode == render_opengl) - HWR_AddSpriteMD2(i); + HWR_AddSpriteModel(i); #endif // if a new sprite was added (not just replaced) addsprites++; #ifndef ZDEBUG - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); + CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", sprnames[i], wadnum); #endif } } @@ -382,125 +488,13 @@ void R_AddSpriteDefs(UINT16 wadnum) CONS_Printf(M_GetText("%s added %d frames in %s sprites\n"), wadname, end-start, sizeu1(addsprites)); } -#ifdef DELFILE -static void R_RemoveSpriteLump(UINT16 wad, // graphics patch - UINT16 lump, - size_t lumpid, // identifier - UINT8 frame, - UINT8 rotation, - UINT8 flipped) -{ - (void)wad; /// \todo: how do I remove sprites? - (void)lump; - (void)lumpid; - (void)frame; - (void)rotation; - (void)flipped; -} - -static boolean R_DelSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 wadnum, UINT16 startlump, UINT16 endlump) -{ - UINT16 l; - UINT8 frame; - UINT8 rotation; - lumpinfo_t *lumpinfo; - - maxframe = (size_t)-1; - - // scan the lumps, - // filling in the frames for whatever is found - lumpinfo = wadfiles[wadnum]->lumpinfo; - if (endlump > wadfiles[wadnum]->numlumps) - endlump = wadfiles[wadnum]->numlumps; - - for (l = startlump; l < endlump; l++) - { - if (memcmp(lumpinfo[l].name,sprname,4)==0) - { - frame = (UINT8)(lumpinfo[l].name[4] - 'A'); - rotation = (UINT8)(lumpinfo[l].name[5] - '0'); - - // skip NULL sprites from very old dmadds pwads - if (W_LumpLengthPwad(wadnum,l)<=8) - continue; - - //---------------------------------------------------- - - R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 0); - - if (lumpinfo[l].name[6]) - { - frame = (UINT8)(lumpinfo[l].name[6] - 'A'); - rotation = (UINT8)(lumpinfo[l].name[7] - '0'); - R_RemoveSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); - } - } - } - - if (maxframe == (size_t)-1) - return false; - - spritedef->numframes = 0; - Z_Free(spritedef->spriteframes); - spritedef->spriteframes = NULL; - return true; -} - -void R_DelSpriteDefs(UINT16 wadnum) -{ - size_t i, delsprites = 0; - UINT16 start, end; - - // find the sprites section in this pwad - // we need at least the S_END - // (not really, but for speedup) - - start = W_CheckNumForNamePwad("S_START", wadnum, 0); - if (start == INT16_MAX) - start = W_CheckNumForNamePwad("SS_START", wadnum, 0); //deutex compatib. - if (start == INT16_MAX) - start = 0; //let say S_START is lump 0 - else - start++; // just after S_START - - end = W_CheckNumForNamePwad("S_END",wadnum,start); - if (end == INT16_MAX) - end = W_CheckNumForNamePwad("SS_END",wadnum,start); //deutex compatib. - if (end == INT16_MAX) - { - CONS_Debug(DBG_SETUP, "no sprites in pwad %d\n", wadnum); - return; - //I_Error("R_DelSpriteDefs: S_END, or SS_END missing for sprites " - // "in pwad %d\n",wadnum); - } - - // - // scan through lumps, for each sprite, find all the sprite frames - // - for (i = 0; i < numsprites; i++) - { - spritename = sprnames[i]; - - if (R_DelSingleSpriteDef(spritename, &sprites[i], wadnum, start, end)) - { - // if a new sprite was removed (not just replaced) - delsprites++; - CONS_Debug(DBG_SETUP, "sprite %s set in pwad %d\n", spritename, wadnum); - } - } - - CONS_Printf(M_GetText("%s sprites removed from file %s\n"), sizeu1(delsprites), wadfiles[wadnum]->filename); -} -#endif - // // GAME FUNCTIONS // -static UINT32 visspritecount; +UINT32 visspritecount; static UINT32 clippedvissprites; static vissprite_t *visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {NULL}; - // // R_InitSprites // Called at program start. @@ -508,11 +502,22 @@ static vissprite_t *visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {NULL void R_InitSprites(void) { size_t i; +#ifdef ROTSPRITE + INT32 angle; + float fa; +#endif for (i = 0; i < MAXVIDWIDTH; i++) - { negonearray[i] = -1; + +#ifdef ROTSPRITE + for (angle = 1; angle < ROTANGLES; angle++) + { + fa = ANG2RAD(FixedAngle((ROTANGDIFF * angle)<numlumps); + } + ST_ReloadSkinFaceGraphics(); // // check if all sprites have frames @@ -645,11 +655,7 @@ void R_DrawMaskedColumn(column_t *column) // quick fix... something more proper should be done!!! if (ylookup[dc_yl]) colfunc(); - else if (colfunc == R_DrawColumn_8 -#ifdef USEASM - || colfunc == R_DrawColumn_8_ASM || colfunc == R_DrawColumn_8_MMX -#endif - ) + else if (colfunc == colfuncs[COLDRAWFUNC_BASE]) { static INT32 first = 1; if (first) @@ -665,7 +671,7 @@ void R_DrawMaskedColumn(column_t *column) dc_texturemid = basetexturemid; } -static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) +void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) { INT32 topscreen; INT32 bottomscreen; @@ -716,11 +722,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) // Still drawn by R_DrawColumn. if (ylookup[dc_yl]) colfunc(); - else if (colfunc == R_DrawColumn_8 -#ifdef USEASM - || colfunc == R_DrawColumn_8_ASM || colfunc == R_DrawColumn_8_MMX -#endif - ) + else if (colfunc == colfuncs[COLDRAWFUNC_BASE]) { static INT32 first = 1; if (first) @@ -744,11 +746,9 @@ static void R_DrawFlippedMaskedColumn(column_t *column, INT32 texheight) static void R_DrawVisSprite(vissprite_t *vis) { column_t *column; -#ifdef RANGECHECK INT32 texturecolumn; -#endif fixed_t frac; - patch_t *patch = W_CacheLumpNum(vis->patch, PU_CACHE); + patch_t *patch = vis->patch; fixed_t this_scale = vis->mobj->scale; INT32 x1, x2; INT64 overflow_test; @@ -761,13 +761,20 @@ static void R_DrawVisSprite(vissprite_t *vis) if (overflow_test < 0) overflow_test = -overflow_test; if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // fixed point mult would overflow - colfunc = basecolfunc; // hack: this isn't resetting properly somewhere. - dc_colormap = vis->colormap; - if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash" + if (vis->scalestep) // handles right edge too { - // translate green skin to another color - colfunc = transcolfunc; - if (vis->mobj->type == MT_CYBRAKDEMON) + overflow_test = (INT64)centeryfrac - (((INT64)vis->texturemid*(vis->scale + (vis->scalestep*(vis->x2 - vis->x1))))>>FRACBITS); + if (overflow_test < 0) overflow_test = -overflow_test; + if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto + } + + colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere. + dc_colormap = vis->colormap; + if (!(vis->cut & SC_PRECIP) && (vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" + { + // translate certain pixels to white + colfunc = colfuncs[COLDRAWFUNC_TRANS]; + if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized) dc_translation = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); else if (vis->mobj->type == MT_METALSONIC_BATTLE) dc_translation = R_GetTranslationColormap(TC_METALSONIC, 0, GTC_CACHE); @@ -776,9 +783,21 @@ static void R_DrawVisSprite(vissprite_t *vis) } else if (vis->mobj->color && vis->transmap) // Color mapping { - colfunc = transtransfunc; + colfunc = colfuncs[COLDRAWFUNC_TRANSTRANS]; dc_transmap = vis->transmap; - if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> + if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) + dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + else if (!(vis->cut & SC_PRECIP) + && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD + && (vis->mobj->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) + { + if (vis->mobj->player->charflags & SF_MACHINE) + dc_translation = R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); + else + dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + } + else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // MT_GHOST LOOKS LIKE A PLAYER SO USE THE PLAYER TRANSLATION TABLES. >_> { size_t skinnum = (skin_t*)vis->mobj->skin-skins; dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); @@ -788,16 +807,28 @@ static void R_DrawVisSprite(vissprite_t *vis) } else if (vis->transmap) { - colfunc = fuzzcolfunc; + colfunc = colfuncs[COLDRAWFUNC_FUZZY]; dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table } else if (vis->mobj->color) { // translate green skin to another color - colfunc = transcolfunc; + colfunc = colfuncs[COLDRAWFUNC_TRANS]; // New colormap stuff for skins Tails 06-07-2002 - if (vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! + if (!(vis->cut & SC_PRECIP) && vis->mobj->colorized) + dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + else if (!(vis->cut & SC_PRECIP) + && vis->mobj->player && vis->mobj->player->dashmode >= DASHMODE_THRESHOLD + && (vis->mobj->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) + { + if (vis->mobj->player->charflags & SF_MACHINE) + dc_translation = R_GetTranslationColormap(TC_DASHMODE, 0, GTC_CACHE); + else + dc_translation = R_GetTranslationColormap(TC_RAINBOW, vis->mobj->color, GTC_CACHE); + } + else if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && vis->mobj->sprite == SPR_PLAY) // This thing is a player! { size_t skinnum = (skin_t*)vis->mobj->skin-skins; dc_translation = R_GetTranslationColormap((INT32)skinnum, vis->mobj->color, GTC_CACHE); @@ -807,7 +838,7 @@ static void R_DrawVisSprite(vissprite_t *vis) } else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. { - colfunc = transcolfunc; + colfunc = colfuncs[COLDRAWFUNC_TRANS]; dc_translation = R_GetTranslationColormap(TC_DEFAULT, SKINCOLOR_BLUE, GTC_CACHE); } @@ -821,68 +852,97 @@ static void R_DrawVisSprite(vissprite_t *vis) if (!dc_colormap) dc_colormap = colormaps; - dc_iscale = FixedDiv(FRACUNIT, vis->scale); dc_texturemid = vis->texturemid; dc_texheight = 0; frac = vis->startfrac; - spryscale = vis->scale; - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); windowtop = windowbottom = sprbotscreen = INT32_MAX; - if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) + if (!(vis->cut & SC_PRECIP) && vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale); if (this_scale <= 0) this_scale = 1; if (this_scale != FRACUNIT) { - if (!vis->isScaled) + if (!(vis->cut & SC_ISSCALED)) { vis->scale = FixedMul(vis->scale, this_scale); - spryscale = vis->scale; - dc_iscale = FixedDiv(FRACUNIT, vis->scale); + vis->scalestep = FixedMul(vis->scalestep, this_scale); vis->xiscale = FixedDiv(vis->xiscale,this_scale); - vis->isScaled = true; + vis->cut |= SC_ISSCALED; } dc_texturemid = FixedDiv(dc_texturemid,this_scale); + } - //Oh lordy, mercy me. Don't freak out if sprites go offscreen! - /*if (vis->xiscale > 0) - frac = FixedDiv(frac, this_scale); - else if (vis->x1 <= 0) - frac = (vis->x1 - vis->x2) * vis->xiscale;*/ + spryscale = vis->scale; + if (!(vis->scalestep)) + { sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); - //dc_hires = 1; + sprtopscreen += vis->shear.tan * vis->shear.offset; + dc_iscale = FixedDiv(FRACUNIT, vis->scale); } x1 = vis->x1; x2 = vis->x2; if (vis->x1 < 0) + { + spryscale += vis->scalestep*(-vis->x1); vis->x1 = 0; + } if (vis->x2 >= vid.width) vis->x2 = vid.width-1; - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + // Split drawing loops for paper and non-paper to reduce conditional checks per sprite + if (vis->scalestep) { -#ifdef RANGECHECK - texturecolumn = frac>>FRACBITS; + // Papersprite drawing loop - if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) - I_Error("R_DrawSpriteRange: bad texturecolumn"); - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += vis->scalestep) + { + angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF; + texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / this_scale; + + if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + continue; + + if (vis->xiscale < 0) // Flipped sprite + texturecolumn = SHORT(patch->width) - 1 - texturecolumn; + + sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); + dc_iscale = (0xffffffffu / (unsigned)spryscale); + + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); + + if (vis->cut & SC_VFLIP) + R_DrawFlippedMaskedColumn(column, patch->height); + else + R_DrawMaskedColumn(column); + } + } + else + { + // Non-paper drawing loop + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale, sprtopscreen += vis->shear.tan) + { +#ifdef RANGECHECK + texturecolumn = frac>>FRACBITS; + if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) + I_Error("R_DrawSpriteRange: bad texturecolumn at %d from end", vis->x2 - dc_x); + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); #else - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[frac>>FRACBITS])); #endif - if (vis->vflip) - R_DrawFlippedMaskedColumn(column, patch->height); - else - R_DrawMaskedColumn(column); + if (vis->cut & SC_VFLIP) + R_DrawFlippedMaskedColumn(column, patch->height); + else + R_DrawMaskedColumn(column); + } } - colfunc = basecolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; dc_hires = 0; vis->x1 = x1; @@ -901,7 +961,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) INT64 overflow_test; //Fab : R_InitSprites now sets a wad lump number - patch = W_CacheLumpNum(vis->patch, PU_CACHE); + patch = vis->patch; if (!patch) return; @@ -912,7 +972,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->transmap) { - colfunc = fuzzcolfunc; + colfunc = colfuncs[COLDRAWFUNC_FUZZY]; dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table } @@ -948,13 +1008,13 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) R_DrawMaskedColumn(column); } - colfunc = basecolfunc; + colfunc = colfuncs[BASEDRAWFUNC]; } // // R_SplitSprite -// runs through a sector's lightlist and -static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) +// runs through a sector's lightlist and Knuckles +static void R_SplitSprite(vissprite_t *sprite) { INT32 i, lightnum, lindex; INT16 cutfrac; @@ -980,7 +1040,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) if (testheight <= sprite->gz) return; - cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->scale))>>FRACBITS); + cutfrac = (INT16)((centeryfrac - FixedMul(testheight - viewz, sprite->sortscale))>>FRACBITS); if (cutfrac < 0) continue; if (cutfrac > viewheight) @@ -990,6 +1050,8 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) // adjust the heights. newsprite = M_Memcpy(R_NewVisSprite(), sprite, sizeof (vissprite_t)); + newsprite->cut |= (sprite->cut & SC_FLAGMASK); + sprite->cut |= SC_BOTTOM; sprite->gz = testheight; @@ -1020,19 +1082,12 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) else spritelights = scalelight[lightnum]; - newsprite->extra_colormap = sector->lightlist[i].extra_colormap; + newsprite->extra_colormap = *sector->lightlist[i].extra_colormap; -/* - if (thing->frame & FF_TRANSMASK) - ; - else if (thing->flags2 & MF2_SHADOW) - ; - else -*/ - if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) - && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) + if (!(newsprite->cut & SC_FULLBRIGHT) + || (newsprite->extra_colormap && (newsprite->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) { - lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); + lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; @@ -1043,6 +1098,256 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) } } +// +// R_GetShadowZ(thing, shadowslope) +// Get the first visible floor below the object for shadows +// shadowslope is filled with the floor's slope, if provided +// +fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) +{ + fixed_t z, floorz = INT32_MIN; + pslope_t *slope, *floorslope = NULL; + msecnode_t *node; + sector_t *sector; + ffloor_t *rover; + + for (node = thing->touching_sectorlist; node; node = node->m_sectorlist_next) + { + sector = node->m_sector; + + slope = (sector->heightsec != -1) ? NULL : sector->f_slope; + z = slope ? P_GetZAt(slope, thing->x, thing->y) : ( + (sector->heightsec != -1) ? sectors[sector->heightsec].floorheight : sector->floorheight + ); + + if (z < thing->z+thing->height/2 && z > floorz) + { + floorz = z; + floorslope = slope; + } + + if (sector->ffloors) + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || (rover->alpha < 90 && !(rover->flags & FF_SWIMMABLE))) + continue; + + z = *rover->t_slope ? P_GetZAt(*rover->t_slope, thing->x, thing->y) : *rover->topheight; + if (z < thing->z+thing->height/2 && z > floorz) + { + floorz = z; + floorslope = *rover->t_slope; + } + } + } + + if (thing->floorz > floorz + (!floorslope ? 0 : FixedMul(abs(floorslope->zdelta), thing->radius*3/2))) + { + floorz = thing->floorz; + floorslope = NULL; + } + +#if 0 // Unfortunately, this drops CEZ2 down to sub-17 FPS on my i7. +//#ifdef POLYOBJECTS + // Check polyobjects and see if floorz needs to be altered, for rings only because they don't update floorz + if (thing->type == MT_RING) + { + INT32 xl, xh, yl, yh, bx, by; + + xl = (unsigned)(thing->x - thing->radius - bmaporgx)>>MAPBLOCKSHIFT; + xh = (unsigned)(thing->x + thing->radius - bmaporgx)>>MAPBLOCKSHIFT; + yl = (unsigned)(thing->y - thing->radius - bmaporgy)>>MAPBLOCKSHIFT; + yh = (unsigned)(thing->y + thing->radius - bmaporgy)>>MAPBLOCKSHIFT; + + BMBOUNDFIX(xl, xh, yl, yh); + + validcount++; + + for (by = yl; by <= yh; by++) + for (bx = xl; bx <= xh; bx++) + { + INT32 offset; + polymaplink_t *plink; // haleyjd 02/22/06 + + if (bx < 0 || by < 0 || bx >= bmapwidth || by >= bmapheight) + continue; + + offset = by*bmapwidth + bx; + + // haleyjd 02/22/06: consider polyobject lines + plink = polyblocklinks[offset]; + + while (plink) + { + polyobj_t *po = plink->po; + + if (po->validcount != validcount) // if polyobj hasn't been checked + { + po->validcount = validcount; + + if (!P_MobjInsidePolyobj(po, thing) || !(po->flags & POF_RENDERPLANES)) + { + plink = (polymaplink_t *)(plink->link.next); + continue; + } + + // We're inside it! Yess... + z = po->lines[0]->backsector->ceilingheight; + + if (z < thing->z+thing->height/2 && z > floorz) + { + floorz = z; + floorslope = NULL; + } + } + plink = (polymaplink_t *)(plink->link.next); + } + } + } +#endif + + if (shadowslope != NULL) + *shadowslope = floorslope; + + return floorz; +} + +static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, fixed_t tx, fixed_t tz) +{ + vissprite_t *shadow; + patch_t *patch; + fixed_t xscale, yscale, shadowxscale, shadowyscale, shadowskew, x1, x2; + INT32 light = 0; + fixed_t scalemul; UINT8 trans; + fixed_t floordiff; + fixed_t floorz; + pslope_t *floorslope; + + floorz = R_GetShadowZ(thing, &floorslope); + + if (abs(floorz-viewz)/tz > 4) return; // Prevent stretchy shadows and possible crashes + + floordiff = abs(thing->z - floorz); + + trans = floordiff / (100*FRACUNIT) + 3; + if (trans >= 9) return; + + scalemul = FixedMul(FRACUNIT - floordiff/640, scale); + + patch = W_CachePatchName("DSHADOW", PU_CACHE); + xscale = FixedDiv(projection, tz); + yscale = FixedDiv(projectiony, tz); + shadowxscale = FixedMul(thing->radius*2, scalemul); + shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(floorz - viewz), tz)); + shadowyscale = min(shadowyscale, shadowxscale) / patch->height; + shadowxscale /= patch->width; + shadowskew = 0; + + if (floorslope) + { + // haha let's try some dumb stuff + fixed_t xslope, zslope; + angle_t sloperelang = (R_PointToAngle(thing->x, thing->y) - floorslope->xydirection) >> ANGLETOFINESHIFT; + + xslope = FixedMul(FINESINE(sloperelang), floorslope->zdelta); + zslope = FixedMul(FINECOSINE(sloperelang), floorslope->zdelta); + + //CONS_Printf("Shadow is sloped by %d %d\n", xslope, zslope); + + if (viewz < floorz) + shadowyscale += FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); + else + shadowyscale -= FixedMul(FixedMul(thing->radius*2 / patch->height, scalemul), zslope); + + shadowyscale = abs(shadowyscale); + + shadowskew = xslope; + } + + tx -= patch->width * shadowxscale/2; + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + if (x1 >= viewwidth) return; + + tx += patch->width * shadowxscale; + x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; + if (x2 < 0 || x2 <= x1) return; + + if (shadowyscale < FRACUNIT/patch->height) return; // fix some crashes? + + shadow = R_NewVisSprite(); + shadow->patch = patch; + shadow->heightsec = vis->heightsec; + + shadow->thingheight = FRACUNIT; + shadow->pz = floorz; + shadow->pzt = shadow->pz + shadow->thingheight; + + shadow->mobjflags = 0; + shadow->sortscale = vis->sortscale; + shadow->dispoffset = vis->dispoffset - 5; + shadow->gx = thing->x; + shadow->gy = thing->y; + shadow->gzt = shadow->pz + shadow->patch->height * shadowyscale / 2; + shadow->gz = shadow->gzt - shadow->patch->height * shadowyscale; + shadow->texturemid = FixedMul(thing->scale, FixedDiv(shadow->gzt - viewz, shadowyscale)); + if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) + shadow->texturemid = FixedMul(shadow->texturemid, ((skin_t *)thing->skin)->highresscale); + shadow->scalestep = 0; + shadow->shear.tan = shadowskew; // repurposed variable + + shadow->mobj = thing; // Easy access! Tails 06-07-2002 + + shadow->x1 = x1 < portalclipstart ? portalclipstart : x1; + shadow->x2 = x2 >= portalclipend ? portalclipend-1 : x2; + + shadow->xscale = FixedMul(xscale, shadowxscale); //SoM: 4/17/2000 + shadow->scale = FixedMul(yscale, shadowyscale); + shadow->sector = vis->sector; + shadow->szt = (INT16)((centeryfrac - FixedMul(shadow->gzt - viewz, yscale))>>FRACBITS); + shadow->sz = (INT16)((centeryfrac - FixedMul(shadow->gz - viewz, yscale))>>FRACBITS); + shadow->cut = SC_ISSCALED|SC_SHADOW; //check this + + shadow->startfrac = 0; + //shadow->xiscale = 0x7ffffff0 / (shadow->xscale/2); + shadow->xiscale = (patch->width<x1 > x1) + shadow->startfrac += shadow->xiscale*(shadow->x1-x1); + + // reusing x1 variable + x1 += (x2-x1)/2; + shadow->shear.offset = shadow->x1-x1; + + if (thing->subsector->sector->numlights) + { + INT32 lightnum; +#ifdef ESLOPE // R_GetPlaneLight won't work on sloped lights! + light = thing->subsector->sector->numlights - 1; + + for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { + fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, thing->x, thing->y) + : thing->subsector->sector->lightlist[lightnum].height; + if (h <= shadow->gzt) { + light = lightnum - 1; + break; + } + } +#else + light = R_GetPlaneLight(thing->subsector->sector, shadow->gzt, false); +#endif + } + + if (thing->subsector->sector->numlights) + shadow->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; + else + shadow->extra_colormap = thing->subsector->sector->extra_colormap; + + shadow->transmap = transtables + (trans<colormap = scalelight[0][0]; // full dark! + + objectsdrawn++; +} + // // R_ProjectSprite // Generates a vissprite for a thing @@ -1050,26 +1355,42 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) // static void R_ProjectSprite(mobj_t *thing) { + mobj_t *oldthing = thing; fixed_t tr_x, tr_y; fixed_t gxt, gyt; fixed_t tx, tz; - fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! + fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! INT32 x1, x2; spritedef_t *sprdef; spriteframe_t *sprframe; +#ifdef ROTSPRITE + spriteinfo_t *sprinfo; +#endif size_t lump; size_t rot; - UINT8 flip; + UINT16 flip; + boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); INT32 lindex; vissprite_t *vis; - angle_t ang; + spritecut_e cut = SC_NONE; + + angle_t ang = 0; // compiler complaints fixed_t iscale; + fixed_t scalestep; + fixed_t offset, offset2; + + fixed_t basetx; // drop shadows + + boolean papersprite = !!(thing->frame & FF_PAPERSPRITE); + fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; + + INT32 dispoffset = thing->info->dispoffset; //SoM: 3/17/2000 fixed_t gz, gzt; @@ -1077,6 +1398,14 @@ static void R_ProjectSprite(mobj_t *thing) INT32 light = 0; fixed_t this_scale = thing->scale; + // rotsprite + fixed_t spr_width, spr_height; + fixed_t spr_offset, spr_topoffset; +#ifdef ROTSPRITE + patch_t *rotsprite = NULL; + INT32 rollangle = 0; +#endif + // transform the origin point tr_x = thing->x - viewx; tr_y = thing->y - viewy; @@ -1087,20 +1416,20 @@ static void R_ProjectSprite(mobj_t *thing) tz = gxt-gyt; // thing is behind view plane? - if (tz < FixedMul(MINZ, this_scale)) + if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later return; gxt = -FixedMul(tr_x, viewsin); gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); + basetx = tx = -(gyt + gxt); // too far off the side? - if (abs(tx) > tz<<2) + if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later return; // aspect ratio stuff xscale = FixedDiv(projection, tz); - yscale = FixedDiv(projectiony, tz); + sortscale = FixedDiv(projectiony, tz); // decide which patch to use for sprite relative to player #ifdef RANGECHECK @@ -1113,25 +1442,41 @@ static void R_ProjectSprite(mobj_t *thing) //Fab : 02-08-98: 'skin' override spritedef currently used for skin if (thing->skin && thing->sprite == SPR_PLAY) { - sprdef = &((skin_t *)thing->skin)->spritedef; - if (rot >= sprdef->numframes) + sprdef = &((skin_t *)thing->skin)->sprites[thing->sprite2]; +#ifdef ROTSPRITE + sprinfo = &((skin_t *)thing->skin)->sprinfo[thing->sprite2]; +#endif + if (rot >= sprdef->numframes) { + CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid skins[\"%s\"].sprites[%sSPR2_%s] frame %s\n"), ((skin_t *)thing->skin)->name, ((thing->sprite2 & FF_SPR2SUPER) ? "FF_SPR2SUPER|": ""), spr2names[(thing->sprite2 & ~FF_SPR2SUPER)], sizeu5(rot)); + thing->sprite = states[S_UNKNOWN].sprite; + thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; +#ifdef ROTSPRITE + sprinfo = NULL; +#endif + rot = thing->frame&FF_FRAMEMASK; + } } else - sprdef = &sprites[thing->sprite]; - - if (rot >= sprdef->numframes) { - CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid sprite frame %s/%s for %s\n"), - sizeu1(rot), sizeu2(sprdef->numframes), sprnames[thing->sprite]); - thing->sprite = states[S_UNKNOWN].sprite; - thing->frame = states[S_UNKNOWN].frame; sprdef = &sprites[thing->sprite]; - rot = thing->frame&FF_FRAMEMASK; - if (!thing->skin) +#ifdef ROTSPRITE + sprinfo = NULL; +#endif + + if (rot >= sprdef->numframes) { - thing->state->sprite = thing->sprite; - thing->state->frame = thing->frame; + CONS_Alert(CONS_ERROR, M_GetText("R_ProjectSprite: invalid sprite frame %s/%s for %s\n"), + sizeu1(rot), sizeu2(sprdef->numframes), sprnames[thing->sprite]); + if (thing->sprite == thing->state->sprite && thing->frame == thing->state->frame) + { + thing->state->sprite = states[S_UNKNOWN].sprite; + thing->state->frame = states[S_UNKNOWN].frame; + } + thing->sprite = states[S_UNKNOWN].sprite; + thing->frame = states[S_UNKNOWN].frame; + sprdef = &sprites[thing->sprite]; + rot = thing->frame&FF_FRAMEMASK; } } @@ -1142,21 +1487,36 @@ static void R_ProjectSprite(mobj_t *thing) I_Error("R_ProjectSprite: sprframes NULL for sprite %d\n", thing->sprite); #endif - if (sprframe->rotate) - { - // choose a different rotation based on player view - ang = R_PointToAngle (thing->x, thing->y); - rot = (ang-thing->angle+ANGLE_202h)>>29; - //Fab: lumpid is the index for spritewidth,spriteoffset... tables - lump = sprframe->lumpid[rot]; - flip = sprframe->flip & (1<rotate != SRF_SINGLE || papersprite) + ang = R_PointToAngle (thing->x, thing->y) - (thing->player ? thing->player->drawangle : thing->angle); + + if (sprframe->rotate == SRF_SINGLE) { // use single rotation for all views rot = 0; //Fab: for vis->patch below lump = sprframe->lumpid[0]; //Fab: see note above - flip = sprframe->flip; // Will only be 0x00 or 0xFF + flip = sprframe->flip; // Will only be 0 or 0xFFFF + } + else + { + // choose a different rotation based on player view + //ang = R_PointToAngle (thing->x, thing->y) - thing->angle; + + if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right + rot = 6; // F7 slot + else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left + rot = 2; // F3 slot + else if (sprframe->rotate & SRF_3DGE) // 16-angle mode + { + rot = (ang+ANGLE_180+ANGLE_11hh)>>28; + rot = ((rot & 1)<<3)|(rot>>1); + } + else // Normal behaviour + rot = (ang+ANGLE_202h)>>29; + + //Fab: lumpid is the index for spritewidth,spriteoffset... tables + lump = sprframe->lumpid[rot]; + flip = sprframe->flip & (1<skin && ((skin_t *)thing->skin)->flags & SF_HIRES) this_scale = FixedMul(this_scale, ((skin_t *)thing->skin)->highresscale); + spr_width = spritecachedinfo[lump].width; + spr_height = spritecachedinfo[lump].height; + spr_offset = spritecachedinfo[lump].offset; + spr_topoffset = spritecachedinfo[lump].topoffset; + +#ifdef ROTSPRITE + if (thing->rollangle) + { + rollangle = R_GetRollAngle(thing->rollangle); + if (!(sprframe->rotsprite.cached & (1<sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip); + rotsprite = sprframe->rotsprite.patch[rot][rollangle]; + if (rotsprite != NULL) + { + spr_width = rotsprite->width << FRACBITS; + spr_height = rotsprite->height << FRACBITS; + spr_offset = rotsprite->leftoffset << FRACBITS; + spr_topoffset = rotsprite->topoffset << FRACBITS; + // flip -> rotate, not rotate -> flip + flip = 0; + } + } +#endif + // calculate edges of the shape if (flip) - tx -= FixedMul(spritecachedinfo[lump].width-spritecachedinfo[lump].offset, this_scale); + offset = spr_offset - spr_width; else - tx -= FixedMul(spritecachedinfo[lump].offset, this_scale); - x1 = (centerxfrac + FixedMul (tx,xscale)) >>FRACBITS; + offset = -spr_offset; + offset = FixedMul(offset, this_scale); + offset2 = FixedMul(spr_width, this_scale); - // off the right side? - if (x1 > viewwidth) - return; + if (papersprite) + { + fixed_t xscale2, yscale2, cosmul, sinmul, tx2, tz2; + INT32 range; - tx += FixedMul(spritecachedinfo[lump].width, this_scale); - x2 = ((centerxfrac + FixedMul (tx,xscale)) >>FRACBITS) - 1; + if (ang >= ANGLE_180) + { + offset *= -1; + offset2 *= -1; + } - // off the left side - if (x2 < 0) - return; + cosmul = FINECOSINE(thing->angle>>ANGLETOFINESHIFT); + sinmul = FINESINE(thing->angle>>ANGLETOFINESHIFT); + + tr_x += FixedMul(offset, cosmul); + tr_y += FixedMul(offset, sinmul); + gxt = FixedMul(tr_x, viewcos); + gyt = -FixedMul(tr_y, viewsin); + tz = gxt-gyt; + yscale = FixedDiv(projectiony, tz); + //if (yscale < 64) return; // Fix some funky visuals + + gxt = -FixedMul(tr_x, viewsin); + gyt = FixedMul(tr_y, viewcos); + tx = -(gyt + gxt); + xscale = FixedDiv(projection, tz); + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + + // Get paperoffset (offset) and paperoffset (distance) + paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); + paperdistance = -FixedMul(tr_x, sinmul) + FixedMul(tr_y, cosmul); + if (paperdistance < 0) + { + paperoffset = -paperoffset; + paperdistance = -paperdistance; + } + centerangle = viewangle - thing->angle; + + tr_x += FixedMul(offset2, cosmul); + tr_y += FixedMul(offset2, sinmul); + gxt = FixedMul(tr_x, viewcos); + gyt = -FixedMul(tr_y, viewsin); + tz2 = gxt-gyt; + yscale2 = FixedDiv(projectiony, tz2); + //if (yscale2 < 64) return; // ditto + + gxt = -FixedMul(tr_x, viewsin); + gyt = FixedMul(tr_y, viewcos); + tx2 = -(gyt + gxt); + xscale2 = FixedDiv(projection, tz2); + x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); + + if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier + return; + + // Needs partially clipped + if (tz < FixedMul(MINZ, this_scale)) + { + fixed_t div = FixedDiv(tz2-tz, FixedMul(MINZ, this_scale)-tz); + tx += FixedDiv(tx2-tx, div); + tz = FixedMul(MINZ, this_scale); + yscale = FixedDiv(projectiony, tz); + xscale = FixedDiv(projection, tz); + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + } + else if (tz2 < FixedMul(MINZ, this_scale)) + { + fixed_t div = FixedDiv(tz-tz2, FixedMul(MINZ, this_scale)-tz2); + tx2 += FixedDiv(tx-tx2, div); + tz2 = FixedMul(MINZ, this_scale); + yscale2 = FixedDiv(projectiony, tz2); + xscale2 = FixedDiv(projection, tz2); + x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS; + } + + // off the right side? + if (x1 > viewwidth) + return; + + // off the left side + if (x2 < 0) + return; + + if ((range = x2 - x1) <= 0) + return; + + range++; // fencepost problem + + scalestep = ((yscale2 - yscale)/range) ?: 1; + xscale = FixedDiv(range<>FRACBITS; + + // off the right side? + if (x1 > viewwidth) + return; + + tx += offset2; + x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; + + // off the left side + if (x2 < 0) + return; + } + + if ((thing->flags2 & MF2_LINKDRAW) && thing->tracer) // toast 16/09/16 (SYMMETRY) + { + fixed_t linkscale; + + thing = thing->tracer; + + if (! R_ThingVisible(thing)) + return; + + tr_x = thing->x - viewx; + tr_y = thing->y - viewy; + gxt = FixedMul(tr_x, viewcos); + gyt = -FixedMul(tr_y, viewsin); + tz = gxt-gyt; + linkscale = FixedDiv(projectiony, tz); + + if (tz < FixedMul(MINZ, this_scale)) + return; + + if (sortscale < linkscale) + dispoffset *= -1; // if it's physically behind, make sure it's ordered behind (if dispoffset > 0) + + sortscale = linkscale; // now make sure it's linked + cut = SC_LINKDRAW; + } // PORTAL SPRITE CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (x2 < portalclipstart || x1 > portalclipend) return; @@ -1193,18 +1707,18 @@ static void R_ProjectSprite(mobj_t *thing) } //SoM: 3/17/2000: Disregard sprites that are out of view.. - if (thing->eflags & MFE_VERTICALFLIP) + if (vflip) { // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. // remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes! - gz = thing->z + thing->height - FixedMul(spritecachedinfo[lump].topoffset, this_scale); - gzt = gz + FixedMul(spritecachedinfo[lump].height, this_scale); + gz = oldthing->z + oldthing->height - FixedMul(spr_topoffset, this_scale); + gzt = gz + FixedMul(spr_height, this_scale); } else { - gzt = thing->z + FixedMul(spritecachedinfo[lump].topoffset, this_scale); - gz = gzt - FixedMul(spritecachedinfo[lump].height, this_scale); + gzt = oldthing->z + FixedMul(spr_topoffset, this_scale); + gz = gzt - FixedMul(spr_height, this_scale); } if (thing->subsector->sector->cullheight) @@ -1263,7 +1777,8 @@ static void R_ProjectSprite(mobj_t *thing) vis->heightsec = heightsec; //SoM: 3/17/2000 vis->mobjflags = thing->flags; vis->scale = yscale; //<dispoffset = thing->info->dispoffset; // Monster Iestyn: 23/11/15 + vis->sortscale = sortscale; + vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 vis->gx = thing->x; vis->gy = thing->y; vis->gz = gz; @@ -1272,28 +1787,25 @@ static void R_ProjectSprite(mobj_t *thing) vis->pz = thing->z; vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; + vis->scalestep = scalestep; + vis->paperoffset = paperoffset; + vis->paperdistance = paperdistance; + vis->centerangle = centerangle; + vis->shear.tan = 0; + vis->shear.offset = 0; vis->mobj = thing; // Easy access! Tails 06-07-2002 - vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (vis->x1 < portalclipstart) - vis->x1 = portalclipstart; - if (vis->x2 > portalclipend) - vis->x2 = portalclipend; - } + vis->x1 = x1 < portalclipstart ? portalclipstart : x1; + vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; vis->xscale = xscale; //SoM: 4/17/2000 vis->sector = thing->subsector->sector; - vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, yscale))>>FRACBITS); - vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, yscale))>>FRACBITS); - vis->cut = SC_NONE; + vis->szt = (INT16)((centeryfrac - FixedMul(vis->gzt - viewz, sortscale))>>FRACBITS); + vis->sz = (INT16)((centeryfrac - FixedMul(vis->gz - viewz, sortscale))>>FRACBITS); + vis->cut = cut; if (thing->subsector->sector->numlights) - vis->extra_colormap = thing->subsector->sector->lightlist[light].extra_colormap; + vis->extra_colormap = *thing->subsector->sector->lightlist[light].extra_colormap; else vis->extra_colormap = thing->subsector->sector->extra_colormap; @@ -1301,7 +1813,7 @@ static void R_ProjectSprite(mobj_t *thing) if (flip) { - vis->startfrac = spritecachedinfo[lump].width-1; + vis->startfrac = spr_width-1; vis->xiscale = -iscale; } else @@ -1311,11 +1823,19 @@ static void R_ProjectSprite(mobj_t *thing) } if (vis->x1 > x1) + { vis->startfrac += FixedDiv(vis->xiscale, this_scale)*(vis->x1-x1); + vis->scale += scalestep*(vis->x1 - x1); + } //Fab: lumppat is the lump number of the patch to use, this is different // than lumpid for sprites-in-pwad : the graphics are patched - vis->patch = sprframe->lumppat[rot]; +#ifdef ROTSPRITE + if (rotsprite != NULL) + vis->patch = rotsprite; + else +#endif + vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); // // determine the colormap (lightlevel & special effects) @@ -1325,13 +1845,16 @@ static void R_ProjectSprite(mobj_t *thing) // specific translucency if (!cv_translucency.value) ; // no translucency - else if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) + else if (oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) vis->transmap = transtables + ((tr_trans80-1)<frame & FF_TRANSMASK) - vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000; + else if (oldthing->frame & FF_TRANSMASK) + vis->transmap = transtables + (oldthing->frame & FF_TRANSMASK) - 0x10000; - if (((thing->frame & FF_FULLBRIGHT) || (thing->flags2 & MF2_SHADOW)) - && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) + if (oldthing->frame & FF_FULLBRIGHT || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) + vis->cut |= SC_FULLBRIGHT; + + if (vis->cut & SC_FULLBRIGHT + && (!vis->extra_colormap || !(vis->extra_colormap->flags & CMF_FADEFULLBRIGHTSPRITES))) { // full bright: goggles vis->colormap = colormaps; @@ -1339,7 +1862,7 @@ static void R_ProjectSprite(mobj_t *thing) else { // diminished light - lindex = FixedMul(xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT); + lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); if (lindex >= MAXLIGHTSCALE) lindex = MAXLIGHTSCALE-1; @@ -1347,17 +1870,14 @@ static void R_ProjectSprite(mobj_t *thing) vis->colormap = spritelights[lindex]; } - vis->precip = false; - - if (thing->eflags & MFE_VERTICALFLIP) - vis->vflip = true; - else - vis->vflip = false; - - vis->isScaled = false; + if (vflip) + vis->cut |= SC_VFLIP; if (thing->subsector->sector->numlights) - R_SplitSprite(vis, thing); + R_SplitSprite(vis); + + if (oldthing->shadowscale && cv_shadow.value) + R_ProjectDropShadow(oldthing, vis, oldthing->shadowscale, basetx, tz); // Debug ++objectsdrawn; @@ -1381,7 +1901,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) fixed_t iscale; //SoM: 3/17/2000 - fixed_t gz ,gzt; + fixed_t gz, gzt; // transform the origin point tr_x = thing->x - viewx; @@ -1449,7 +1969,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; // PORTAL SPRITE CLIPPING - if (portalrender) + if (portalrender && portalclipline) { if (x2 < portalclipstart || x1 > portalclipend) return; @@ -1458,16 +1978,6 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } - // okay, we can't return now except for vertical clipping... this is a hack, but weather isn't networked, so it should be ok - if (!(thing->precipflags & PCF_THUNK)) - { - if (thing->precipflags & PCF_RAIN) - P_RainThinker(thing); - else - P_SnowThinker(thing); - thing->precipflags |= PCF_THUNK; - } - //SoM: 3/17/2000: Disregard sprites that are out of view.. gzt = thing->z + spritecachedinfo[lump].topoffset; @@ -1476,12 +1986,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) if (thing->subsector->sector->cullheight) { if (R_DoCulling(thing->subsector->sector->cullheight, viewsector->cullheight, viewz, gz, gzt)) - return; + goto weatherthink; } // store information in a vissprite vis = R_NewVisSprite(); - vis->scale = yscale; //<scale = vis->sortscale = yscale; //<dispoffset = 0; // Monster Iestyn: 23/11/15 vis->gx = thing->x; vis->gy = thing->y; @@ -1491,18 +2001,13 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->pz = thing->z; vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; + vis->scalestep = 0; + vis->paperdistance = 0; + vis->shear.tan = 0; + vis->shear.offset = 0; - vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - - // PORTAL SEMI-CLIPPING - if (portalrender) - { - if (vis->x1 < portalclipstart) - vis->x1 = portalclipstart; - if (vis->x2 > portalclipend) - vis->x2 = portalclipend; - } + vis->x1 = x1 < portalclipstart ? portalclipstart : x1; + vis->x2 = x2 >= portalclipend ? portalclipend-1 : x2; vis->xscale = xscale; //SoM: 4/17/2000 vis->sector = thing->subsector->sector; @@ -1519,7 +2024,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //Fab: lumppat is the lump number of the patch to use, this is different // than lumpid for sprites-in-pwad : the graphics are patched - vis->patch = sprframe->lumppat[0]; + vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); // specific translucency if (thing->frame & FF_TRANSMASK) @@ -1527,16 +2032,25 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) else vis->transmap = NULL; + vis->mobj = (mobj_t *)thing; vis->mobjflags = 0; - vis->cut = SC_NONE; + vis->cut = SC_PRECIP; vis->extra_colormap = thing->subsector->sector->extra_colormap; vis->heightsec = thing->subsector->sector->heightsec; // Fullbright vis->colormap = colormaps; - vis->precip = true; - vis->vflip = false; - vis->isScaled = false; + +weatherthink: + // okay... this is a hack, but weather isn't networked, so it should be ok + if (!(thing->precipflags & PCF_THUNK)) + { + if (thing->precipflags & PCF_RAIN) + P_RainThinker(thing); + else + P_SnowThinker(thing); + thing->precipflags |= PCF_THUNK; + } } // R_AddSprites @@ -1547,7 +2061,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) mobj_t *thing; precipmobj_t *precipthing; // Tails 08-25-2002 INT32 lightnum; - fixed_t approx_dist, limit_dist; + fixed_t limit_dist, hoop_limit_dist; if (rendermode != render_soft) return; @@ -1578,109 +2092,151 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - if ((limit_dist = (fixed_t)((maptol & TOL_NIGHTS) ? cv_drawdist_nights.value : cv_drawdist.value) << FRACBITS)) + limit_dist = (fixed_t)(cv_drawdist.value) << FRACBITS; + hoop_limit_dist = (fixed_t)(cv_drawdist_nights.value) << FRACBITS; + for (thing = sec->thinglist; thing; thing = thing->snext) { - for (thing = sec->thinglist; thing; thing = thing->snext) - { - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) - continue; - - approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - - if (approx_dist > limit_dist) - continue; - + if (R_ThingVisibleWithinDist(thing, limit_dist, hoop_limit_dist)) R_ProjectSprite(thing); - } - } - else - { - // Draw everything in sector, no checks - for (thing = sec->thinglist; thing; thing = thing->snext) - if (!(thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW)) - R_ProjectSprite(thing); } - // Someone seriously wants infinite draw distance for precipitation? + // no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off if ((limit_dist = (fixed_t)cv_drawdist_precip.value << FRACBITS)) { for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) { - if (precipthing->precipflags & PCF_INVISIBLE) - continue; - - approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); - - if (approx_dist > limit_dist) - continue; - - R_ProjectPrecipitationSprite(precipthing); - } - } - else - { - // Draw everything in sector, no checks - for (precipthing = sec->preciplist; precipthing; precipthing = precipthing->snext) - if (!(precipthing->precipflags & PCF_INVISIBLE)) + if (R_PrecipThingVisible(precipthing, limit_dist)) R_ProjectPrecipitationSprite(precipthing); + } } } // // R_SortVisSprites // -static vissprite_t vsprsortedhead; - -void R_SortVisSprites(void) +static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 end) { - UINT32 i; + UINT32 i, linkedvissprites = 0; vissprite_t *ds, *dsprev, *dsnext, *dsfirst; vissprite_t *best = NULL; vissprite_t unsorted; fixed_t bestscale; INT32 bestdispoffset; - if (!visspritecount) - return; - unsorted.next = unsorted.prev = &unsorted; - dsfirst = R_GetVisSprite(0); + dsfirst = R_GetVisSprite(start); // The first's prev and last's next will be set to // nonsense, but are fixed in a moment - for (i = 0, dsnext = dsfirst, ds = NULL; i < visspritecount; i++) + for (i = start, dsnext = dsfirst, ds = NULL; i < end; i++) { dsprev = ds; ds = dsnext; - if (i < visspritecount - 1) dsnext = R_GetVisSprite(i + 1); + if (i < end - 1) dsnext = R_GetVisSprite(i + 1); ds->next = dsnext; ds->prev = dsprev; + ds->linkdraw = NULL; } // Fix first and last. ds still points to the last one after the loop dsfirst->prev = &unsorted; unsorted.next = dsfirst; if (ds) + { ds->next = &unsorted; + ds->linkdraw = NULL; + } unsorted.prev = ds; + // bundle linkdraw + for (ds = unsorted.prev; ds != &unsorted; ds = ds->prev) + { + if (!(ds->cut & SC_LINKDRAW)) + continue; + + if (ds->cut & SC_SHADOW) + continue; + + // reuse dsfirst... + for (dsfirst = unsorted.prev; dsfirst != &unsorted; dsfirst = dsfirst->prev) + { + // don't connect if it's also a link + if (dsfirst->cut & SC_LINKDRAW) + continue; + + // don't connect to your shadow! + if (dsfirst->cut & SC_SHADOW) + continue; + + // don't connect if it's not the tracer + if (dsfirst->mobj != ds->mobj) + continue; + + // don't connect if the tracer's top is cut off, but lower than the link's top + if ((dsfirst->cut & SC_TOP) + && dsfirst->szt > ds->szt) + continue; + + // don't connect if the tracer's bottom is cut off, but higher than the link's bottom + if ((dsfirst->cut & SC_BOTTOM) + && dsfirst->sz < ds->sz) + continue; + + break; + } + + // remove from chain + ds->next->prev = ds->prev; + ds->prev->next = ds->next; + linkedvissprites++; + + if (dsfirst != &unsorted) + { + if (!(ds->cut & SC_FULLBRIGHT)) + ds->colormap = dsfirst->colormap; + ds->extra_colormap = dsfirst->extra_colormap; + + // reusing dsnext... + dsnext = dsfirst->linkdraw; + + if (!dsnext || ds->dispoffset < dsnext->dispoffset) + { + ds->next = dsnext; + dsfirst->linkdraw = ds; + } + else + { + for (; dsnext->next != NULL; dsnext = dsnext->next) + if (ds->dispoffset < dsnext->next->dispoffset) + break; + ds->next = dsnext->next; + dsnext->next = ds; + } + } + } + // pull the vissprites out by scale - vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; - for (i = 0; i < visspritecount; i++) + vsprsortedhead->next = vsprsortedhead->prev = vsprsortedhead; + for (i = start; i < end-linkedvissprites; i++) { bestscale = bestdispoffset = INT32_MAX; for (ds = unsorted.next; ds != &unsorted; ds = ds->next) { - if (ds->scale < bestscale) +#ifdef PARANOIA + if (ds->cut & SC_LINKDRAW) + I_Error("R_SortVisSprites: no link or discardal made for linkdraw!"); +#endif + + if (ds->sortscale < bestscale) { - bestscale = ds->scale; + bestscale = ds->sortscale; bestdispoffset = ds->dispoffset; best = ds; } // order visprites of same scale by dispoffset, smallest first - else if (ds->scale == bestscale && ds->dispoffset < bestdispoffset) + else if (ds->sortscale == bestscale && ds->dispoffset < bestdispoffset) { bestdispoffset = ds->dispoffset; best = ds; @@ -1688,10 +2244,10 @@ void R_SortVisSprites(void) } best->next->prev = best->prev; best->prev->next = best->next; - best->next = &vsprsortedhead; - best->prev = vsprsortedhead.prev; - vsprsortedhead.prev->next = best; - vsprsortedhead.prev = best; + best->next = vsprsortedhead; + best->prev = vsprsortedhead->prev; + vsprsortedhead->prev->next = best; + vsprsortedhead->prev = best; } } @@ -1701,28 +2257,28 @@ void R_SortVisSprites(void) static drawnode_t *R_CreateDrawNode(drawnode_t *link); static drawnode_t nodebankhead; -static drawnode_t nodehead; -static void R_CreateDrawNodes(void) +static void R_CreateDrawNodes(maskcount_t* mask, drawnode_t* head, boolean tempskip) { drawnode_t *entry; drawseg_t *ds; INT32 i, p, best, x1, x2; fixed_t bestdelta, delta; vissprite_t *rover; + static vissprite_t vsprsortedhead; drawnode_t *r2; visplane_t *plane; INT32 sintersect; fixed_t scale = 0; // Add the 3D floors, thicksides, and masked textures... - for (ds = ds_p; ds-- > drawsegs ;) + for (ds = drawsegs + mask->drawsegs[1]; ds-- > drawsegs + mask->drawsegs[0];) { if (ds->numthicksides) { for (i = 0; i < ds->numthicksides; i++) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->thickseg = ds; entry->ffloor = ds->thicksides[i]; } @@ -1737,7 +2293,7 @@ static void R_CreateDrawNodes(void) ; else { // Put it in! - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = plane; entry->seg = ds; } @@ -1746,7 +2302,7 @@ static void R_CreateDrawNodes(void) #endif if (ds->maskedtexturecol) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->seg = ds; } if (ds->numffloorplanes) @@ -1777,7 +2333,7 @@ static void R_CreateDrawNodes(void) } if (best != -1) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = ds->ffloorplanes[best]; entry->seg = ds; ds->ffloorplanes[best] = NULL; @@ -1788,6 +2344,9 @@ static void R_CreateDrawNodes(void) } } + if (tempskip) + return; + #ifdef POLYOBJECTS_PLANES // find all the remaining polyobject planes and add them on the end of the list // probably this is a terrible idea if we wanted them to be sorted properly @@ -1804,17 +2363,19 @@ static void R_CreateDrawNodes(void) PolyObjects[i].visplane = NULL; continue; } - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->plane = plane; // note: no seg is set, for what should be obvious reasons PolyObjects[i].visplane = NULL; } #endif - if (visspritecount == 0) + // No vissprites in this mask? + if (mask->vissprites[1] - mask->vissprites[0] == 0) return; - R_SortVisSprites(); + R_SortVisSprites(&vsprsortedhead, mask->vissprites[0], mask->vissprites[1]); + for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev) { if (rover->szt > vid.height || rover->sz < 0) @@ -1822,7 +2383,7 @@ static void R_CreateDrawNodes(void) sintersect = (rover->x1 + rover->x2) / 2; - for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) + for (r2 = head->next; r2 != head; r2 = r2->next) { if (r2->plane) { @@ -1871,7 +2432,7 @@ static void R_CreateDrawNodes(void) { for (i = x1; i <= x2; i++) { - if (r2->seg->frontscale[i] > rover->scale) + if (r2->seg->frontscale[i] > rover->sortscale) break; } if (i > x2) @@ -1891,10 +2452,10 @@ static void R_CreateDrawNodes(void) continue; scale = r2->thickseg->scale1 > r2->thickseg->scale2 ? r2->thickseg->scale1 : r2->thickseg->scale2; - if (scale <= rover->scale) + if (scale <= rover->sortscale) continue; scale = r2->thickseg->scale1 + (r2->thickseg->scalestep * (sintersect - r2->thickseg->x1)); - if (scale <= rover->scale) + if (scale <= rover->sortscale) continue; #ifdef ESLOPE @@ -1926,29 +2487,15 @@ static void R_CreateDrawNodes(void) } else if (r2->seg) { -#if 0 //#ifdef POLYOBJECTS_PLANES - if (r2->seg->curline->polyseg && rover->mobj && P_MobjInsidePolyobj(r2->seg->curline->polyseg, rover->mobj)) { - // Determine if we need to sort in front of the polyobj, based on the planes. This fixes the issue where - // polyobject planes render above the object standing on them. (A bit hacky... but it works.) -Red - mobj_t *mo = rover->mobj; - sector_t *po = r2->seg->curline->backsector; - - if (po->ceilingheight < viewz && mo->z+mo->height > po->ceilingheight) - continue; - - if (po->floorheight > viewz && mo->z < po->floorheight) - continue; - } -#endif if (rover->x1 > r2->seg->x2 || rover->x2 < r2->seg->x1) continue; scale = r2->seg->scale1 > r2->seg->scale2 ? r2->seg->scale1 : r2->seg->scale2; - if (scale <= rover->scale) + if (scale <= rover->sortscale) continue; scale = r2->seg->scale1 + (r2->seg->scalestep * (sintersect - r2->seg->x1)); - if (rover->scale < scale) + if (rover->sortscale < scale) { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry; @@ -1964,8 +2511,8 @@ static void R_CreateDrawNodes(void) if (r2->sprite->szt > rover->sz || r2->sprite->sz < rover->szt) continue; - if (r2->sprite->scale > rover->scale - || (r2->sprite->scale == rover->scale && r2->sprite->dispoffset > rover->dispoffset)) + if (r2->sprite->sortscale > rover->sortscale + || (r2->sprite->sortscale == rover->sortscale && r2->sprite->dispoffset > rover->dispoffset)) { entry = R_CreateDrawNode(NULL); (entry->prev = r2->prev)->next = entry; @@ -1975,9 +2522,9 @@ static void R_CreateDrawNodes(void) } } } - if (r2 == &nodehead) + if (r2 == head) { - entry = R_CreateDrawNode(&nodehead); + entry = R_CreateDrawNode(head); entry->sprite = rover; } } @@ -2019,25 +2566,24 @@ static void R_DoneWithNode(drawnode_t *node) (node->prev = &nodebankhead)->next = node; } -static void R_ClearDrawNodes(void) +static void R_ClearDrawNodes(drawnode_t* head) { drawnode_t *rover; drawnode_t *next; - for (rover = nodehead.next; rover != &nodehead ;) + for (rover = head->next; rover != head;) { next = rover->next; R_DoneWithNode(rover); rover = next; } - nodehead.next = nodehead.prev = &nodehead; + head->next = head->prev = head; } void R_InitDrawNodes(void) { nodebankhead.next = nodebankhead.prev = &nodebankhead; - nodehead.next = nodehead.prev = &nodehead; } // @@ -2063,10 +2609,10 @@ static void R_DrawPrecipitationSprite(vissprite_t *spr) // R_ClipSprites // Clips vissprites without drawing, so that portals can work. -Red -void R_ClipSprites(void) +void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) { vissprite_t *spr; - for (;clippedvissprites < visspritecount; clippedvissprites++) + for (; clippedvissprites < visspritecount; clippedvissprites++) { drawseg_t *ds; INT32 x; @@ -2089,7 +2635,7 @@ void R_ClipSprites(void) // and buggy, by going past LEFT end of array: // for (ds = ds_p-1; ds >= drawsegs; ds--) old buggy code - for (ds = ds_p; ds-- > drawsegs ;) + for (ds = ds_p; ds-- > dsstart;) { // determine if the drawseg obscures the sprite if (ds->x1 > spr->x2 || @@ -2101,34 +2647,37 @@ void R_ClipSprites(void) continue; } - if (ds->portalpass > 0 && ds->portalpass <= portalrender) - continue; // is a portal + if (ds->portalpass != 66) + { + if (ds->portalpass > 0 && ds->portalpass <= portalrender) + continue; // is a portal + + if (ds->scale1 > ds->scale2) + { + lowscale = ds->scale2; + scale = ds->scale1; + } + else + { + lowscale = ds->scale1; + scale = ds->scale2; + } + + if (scale < spr->sortscale || + (lowscale < spr->sortscale && + !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) + { + // masked mid texture? + /*if (ds->maskedtexturecol) + R_RenderMaskedSegRange (ds, r1, r2);*/ + // seg is behind sprite + continue; + } + } r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; - if (ds->scale1 > ds->scale2) - { - lowscale = ds->scale2; - scale = ds->scale1; - } - else - { - lowscale = ds->scale1; - scale = ds->scale2; - } - - if (scale < spr->scale || - (lowscale < spr->scale && - !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) - { - // masked mid texture? - /*if (ds->maskedtexturecol) - R_RenderMaskedSegRange (ds, r1, r2);*/ - // seg is behind sprite - continue; - } - // clip this piece of the sprite silhouette = ds->silhouette; @@ -2170,7 +2719,7 @@ void R_ClipSprites(void) fixed_t mh, h; INT32 phs = viewplayer->mo->subsector->sector->heightsec; if ((mh = sectors[spr->heightsec].floorheight) > spr->gz && - (h = centeryfrac - FixedMul(mh -= viewz, spr->scale)) >= 0 && + (h = centeryfrac - FixedMul(mh -= viewz, spr->sortscale)) >= 0 && (h >>= FRACBITS) < viewheight) { if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight)) @@ -2188,7 +2737,7 @@ void R_ClipSprites(void) } if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt && - (h = centeryfrac - FixedMul(mh-viewz, spr->scale)) >= 0 && + (h = centeryfrac - FixedMul(mh-viewz, spr->sortscale)) >= 0 && (h >>= FRACBITS) < viewheight) { if (phs != -1 && viewz >= sectors[phs].ceilingheight) @@ -2245,20 +2794,78 @@ void R_ClipSprites(void) //Fab : 26-04-98: was -1, now clips against console bottom spr->cliptop[x] = (INT16)con_clipviewtop; } + + if (portal) + { + for (x = spr->x1; x <= spr->x2; x++) + { + if (spr->clipbot[x] > portal->floorclip[x - portal->start]) + spr->clipbot[x] = portal->floorclip[x - portal->start]; + if (spr->cliptop[x] < portal->ceilingclip[x - portal->start]) + spr->cliptop[x] = portal->ceilingclip[x - portal->start]; + } + } } } +/* Check if thing may be drawn from our current view. */ +boolean R_ThingVisible (mobj_t *thing) +{ + return (!( + thing->sprite == SPR_NULL || + ( thing->flags2 & (MF2_DONTDRAW) ) || + thing == r_viewmobj + )); +} + +boolean R_ThingVisibleWithinDist (mobj_t *thing, + fixed_t limit_dist, + fixed_t hoop_limit_dist) +{ + fixed_t approx_dist; + + if (! R_ThingVisible(thing)) + return false; + + approx_dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); + + if (thing->sprite == SPR_HOOP) + { + if (hoop_limit_dist && approx_dist > hoop_limit_dist) + return false; + } + else + { + if (limit_dist && approx_dist > limit_dist) + return false; + } + + return true; +} + +/* Check if precipitation may be drawn from our current view. */ +boolean R_PrecipThingVisible (precipmobj_t *precipthing, + fixed_t limit_dist) +{ + fixed_t approx_dist; + + if (( precipthing->precipflags & PCF_INVISIBLE )) + return false; + + approx_dist = P_AproxDistance(viewx-precipthing->x, viewy-precipthing->y); + + return ( approx_dist <= limit_dist ); +} + // // R_DrawMasked // -void R_DrawMasked(void) +static void R_DrawMaskedList (drawnode_t* head) { drawnode_t *r2; drawnode_t *next; - R_CreateDrawNodes(); - - for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next) + for (r2 = head->next; r2 != head; r2 = r2->next) { if (r2->plane) { @@ -2287,590 +2894,63 @@ void R_DrawMasked(void) next = r2->prev; // Tails 08-18-2002 - if (r2->sprite->precip == true) + if (r2->sprite->cut & SC_PRECIP) R_DrawPrecipitationSprite(r2->sprite); - else + else if (!r2->sprite->linkdraw) R_DrawSprite(r2->sprite); + else // unbundle linkdraw + { + vissprite_t *ds = r2->sprite->linkdraw; + + for (; + (ds != NULL && r2->sprite->dispoffset > ds->dispoffset); + ds = ds->next) + R_DrawSprite(ds); + + R_DrawSprite(r2->sprite); + + for (; ds != NULL; ds = ds->next) + R_DrawSprite(ds); + } R_DoneWithNode(r2); r2 = next; } } - R_ClearDrawNodes(); } -// ========================================================================== -// -// SKINS CODE -// -// ========================================================================== - -INT32 numskins = 0; -skin_t skins[MAXSKINS+1]; -// FIXTHIS: don't work because it must be inistilised before the config load -//#define SKINVALUES -#ifdef SKINVALUES -CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; -#endif - -static void Sk_SetDefaultValue(skin_t *skin) +void R_DrawMasked(maskcount_t* masks, UINT8 nummasks) { - INT32 i; - // - // set default skin values - // - memset(skin, 0, sizeof (skin_t)); - snprintf(skin->name, - sizeof skin->name, "skin %u", (UINT32)(skin-skins)); - skin->name[sizeof skin->name - 1] = '\0'; - skin->wadnum = INT16_MAX; - strcpy(skin->sprite, ""); + drawnode_t *heads; /**< Drawnode lists; as many as number of views/portals. */ + SINT8 i; - skin->flags = 0; + heads = calloc(nummasks, sizeof(drawnode_t)); - strcpy(skin->realname, "Someone"); - strcpy(skin->hudname, "???"); - strncpy(skin->charsel, "CHRSONIC", 9); - strncpy(skin->face, "MISSING", 8); - strncpy(skin->superface, "MISSING", 8); - - skin->starttranscolor = 160; - skin->prefcolor = SKINCOLOR_GREEN; - - skin->normalspeed = 36<runspeed = 28<thrustfactor = 5; - skin->accelstart = 96; - skin->acceleration = 40; - - skin->ability = CA_NONE; - skin->ability2 = CA2_SPINDASH; - skin->jumpfactor = FRACUNIT; - skin->actionspd = 30<mindash = 15<maxdash = 90<thokitem = -1; - skin->spinitem = -1; - skin->revitem = -1; - - skin->highresscale = FRACUNIT>>1; - - for (i = 0; i < sfx_skinsoundslot0; i++) - if (S_sfx[i].skinsound != -1) - skin->soundsid[S_sfx[i].skinsound] = i; -} - -// -// Initialize the basic skins -// -void R_InitSkins(void) -{ - skin_t *skin; -#ifdef SKINVALUES - INT32 i; - - for (i = 0; i <= MAXSKINS; i++) + for (i = 0; i < nummasks; i++) { - skin_cons_t[i].value = 0; - skin_cons_t[i].strvalue = NULL; - } -#endif + heads[i].next = heads[i].prev = &heads[i]; - // skin[0] = Sonic skin - skin = &skins[0]; - numskins = 1; - Sk_SetDefaultValue(skin); + viewx = masks[i].viewx; + viewy = masks[i].viewy; + viewz = masks[i].viewz; + viewsector = masks[i].viewsector; - // Hardcoded S_SKIN customizations for Sonic. - strcpy(skin->name, DEFAULTSKIN); -#ifdef SKINVALUES - skin_cons_t[0].strvalue = skins[0].name; -#endif - skin->flags = SF_SUPER|SF_SUPERANIMS|SF_SUPERSPIN; - strcpy(skin->realname, "Sonic"); - strcpy(skin->hudname, "SONIC"); - - strncpy(skin->charsel, "CHRSONIC", 9); - strncpy(skin->face, "LIVSONIC", 9); - strncpy(skin->superface, "LIVSUPER", 9); - skin->prefcolor = SKINCOLOR_BLUE; - - skin->ability = CA_THOK; - skin->actionspd = 60<normalspeed = 36<runspeed = 28<thrustfactor = 5; - skin->accelstart = 96; - skin->acceleration = 40; - - skin->spritedef.numframes = sprites[SPR_PLAY].numframes; - skin->spritedef.spriteframes = sprites[SPR_PLAY].spriteframes; - ST_LoadFaceGraphics(skin->face, skin->superface, 0); - - //MD2 for sonic doesn't want to load in Linux. -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_AddPlayerMD2(0); -#endif -} - -// returns true if the skin name is found (loaded from pwad) -// warning return -1 if not found -INT32 R_SkinAvailable(const char *name) -{ - INT32 i; - - for (i = 0; i < numskins; i++) - { - if (stricmp(skins[i].name,name)==0) - return i; - } - return -1; -} - -// network code calls this when a 'skin change' is received -void SetPlayerSkin(INT32 playernum, const char *skinname) -{ - INT32 i; - player_t *player = &players[playernum]; - - for (i = 0; i < numskins; i++) - { - // search in the skin list - if (stricmp(skins[i].name, skinname) == 0) - { - SetPlayerSkinByNum(playernum, i); - return; - } + R_CreateDrawNodes(&masks[i], &heads[i], false); } - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); + //for (i = 0; i < nummasks; i++) + // CONS_Printf("Mask no.%d:\ndrawsegs: %d\n vissprites: %d\n\n", i, masks[i].drawsegs[1] - masks[i].drawsegs[0], masks[i].vissprites[1] - masks[i].vissprites[0]); - SetPlayerSkinByNum(playernum, 0); -} - -// Same as SetPlayerSkin, but uses the skin #. -// network code calls this when a 'skin change' is received -void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) -{ - player_t *player = &players[playernum]; - skin_t *skin = &skins[skinnum]; - - if (skinnum >= 0 && skinnum < numskins) // Make sure it exists! + for (; nummasks > 0; nummasks--) { - player->skin = skinnum; - if (player->mo) - player->mo->skin = skin; + viewx = masks[nummasks - 1].viewx; + viewy = masks[nummasks - 1].viewy; + viewz = masks[nummasks - 1].viewz; + viewsector = masks[nummasks - 1].viewsector; - player->charability = (UINT8)skin->ability; - player->charability2 = (UINT8)skin->ability2; - - player->charflags = (UINT32)skin->flags; - - player->thokitem = skin->thokitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].painchance : (UINT32)skin->thokitem; - player->spinitem = skin->spinitem < 0 ? (UINT32)mobjinfo[MT_PLAYER].damage : (UINT32)skin->spinitem; - player->revitem = skin->revitem < 0 ? (mobjtype_t)mobjinfo[MT_PLAYER].raisestate : (UINT32)skin->revitem; - - player->actionspd = skin->actionspd; - player->mindash = skin->mindash; - player->maxdash = skin->maxdash; - - player->normalspeed = skin->normalspeed; - player->runspeed = skin->runspeed; - player->thrustfactor = skin->thrustfactor; - player->accelstart = skin->accelstart; - player->acceleration = skin->acceleration; - - player->jumpfactor = skin->jumpfactor; - - if (!(cv_debug || devparm) && !(netgame || multiplayer || demoplayback)) - { - if (playernum == consoleplayer) - CV_StealthSetValue(&cv_playercolor, skin->prefcolor); - else if (playernum == secondarydisplayplayer) - CV_StealthSetValue(&cv_playercolor2, skin->prefcolor); - player->skincolor = skin->prefcolor; - if (player->mo) - player->mo->color = player->skincolor; - } - - if (player->mo) - P_SetScale(player->mo, player->mo->scale); - return; + R_DrawMaskedList(&heads[nummasks - 1]); + R_ClearDrawNodes(&heads[nummasks - 1]); } - if (P_IsLocalPlayer(player)) - CONS_Alert(CONS_WARNING, M_GetText("Skin %d not found\n"), skinnum); - else if(server || IsPlayerAdmin(consoleplayer)) - CONS_Alert(CONS_WARNING, "Player %d (%s) skin %d not found\n", playernum, player_names[playernum], skinnum); - SetPlayerSkinByNum(playernum, 0); // not found put the sonic skin + free(heads); } - -// -// Add skins from a pwad, each skin preceded by 'S_SKIN' marker -// - -// Does the same is in w_wad, but check only for -// the first 6 characters (this is so we can have S_SKIN1, S_SKIN2.. -// for wad editors that don't like multiple resources of the same name) -// -static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) -{ - UINT16 i; - const char *S_SKIN = "S_SKIN"; - lumpinfo_t *lump_p; - - // scan forward, start at - if (startlump < wadfiles[wadid]->numlumps) - { - lump_p = wadfiles[wadid]->lumpinfo + startlump; - for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) - if (memcmp(lump_p->name,S_SKIN,6)==0) - return i; - } - return INT16_MAX; // not found -} - -// -// Find skin sprites, sounds & optional status bar face, & add them -// -void R_AddSkins(UINT16 wadnum) -{ - UINT16 lump, lastlump = 0; - char *buf; - char *buf2; - char *stoken; - char *value; - size_t size; - skin_t *skin; - boolean hudname, realname, superface; - - // - // search for all skin markers in pwad - // - - while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) - { - // advance by default - lastlump = lump + 1; - - if (numskins > MAXSKINS) - { - CONS_Debug(DBG_RENDER, "ignored skin (%d skins maximum)\n", MAXSKINS); - continue; // so we know how many skins couldn't be added - } - buf = W_CacheLumpNumPwad(wadnum, lump, PU_CACHE); - size = W_LumpLengthPwad(wadnum, lump); - - // for strtok - buf2 = malloc(size+1); - if (!buf2) - I_Error("R_AddSkins: No more free memory\n"); - M_Memcpy(buf2,buf,size); - buf2[size] = '\0'; - - // set defaults - skin = &skins[numskins]; - Sk_SetDefaultValue(skin); - skin->wadnum = wadnum; - hudname = realname = superface = false; - // parse - stoken = strtok (buf2, "\r\n= "); - while (stoken) - { - if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#'))// skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - goto next_token; // find the real next token - } - - value = strtok(NULL, "\r\n= "); - - if (!value) - I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); - - if (!stricmp(stoken, "name")) - { - // the skin name must uniquely identify a single skin - // I'm lazy so if name is already used I leave the 'skin x' - // default skin name set in Sk_SetDefaultValue - if (R_SkinAvailable(value) == -1) - { - STRBUFCPY(skin->name, value); - strlwr(skin->name); - } - // I'm not lazy, so if the name is already used I make the name 'namex' - // using the default skin name's number set above - else - { - const size_t stringspace = - strlen(value) + sizeof (numskins) + 1; - char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); - snprintf(value2, stringspace, - "%s%d", value, numskins); - value2[stringspace - 1] = '\0'; - if (R_SkinAvailable(value2) == -1) - { - STRBUFCPY(skin->name, - value2); - strlwr(skin->name); - } - Z_Free(value2); - } - - // copy to hudname and fullname as a default. - if (!realname) - { - STRBUFCPY(skin->realname, skin->name); - for (value = skin->realname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - } - if (!hudname) - { - STRBUFCPY(skin->hudname, skin->name); - strupr(skin->hudname); - for (value = skin->hudname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - } - } - else if (!stricmp(stoken, "realname")) - { // Display name (eg. "Knuckles") - realname = true; - STRBUFCPY(skin->realname, value); - for (value = skin->realname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - if (!hudname) - STRBUFCPY(skin->hudname, skin->realname); - } - else if (!stricmp(stoken, "hudname")) - { // Life icon name (eg. "K.T.E") - hudname = true; - STRBUFCPY(skin->hudname, value); - for (value = skin->hudname; *value; value++) - if (*value == '_') *value = ' '; // turn _ into spaces. - if (!realname) - STRBUFCPY(skin->realname, skin->hudname); - } - - else if (!stricmp(stoken, "sprite")) - { - strupr(value); - strncpy(skin->sprite, value, sizeof skin->sprite); - } - else if (!stricmp(stoken, "charsel")) - { - strupr(value); - strncpy(skin->charsel, value, sizeof skin->charsel); - } - else if (!stricmp(stoken, "face")) - { - strupr(value); - strncpy(skin->face, value, sizeof skin->face); - if (!superface) - strncpy(skin->superface, value, sizeof skin->superface); - } - else if (!stricmp(stoken, "superface")) - { - superface = true; - strupr(value); - strncpy(skin->superface, value, sizeof skin->superface); - } - -#define FULLPROCESS(field) else if (!stricmp(stoken, #field)) skin->field = get_number(value); - // character type identification - FULLPROCESS(flags) - FULLPROCESS(ability) - FULLPROCESS(ability2) - - FULLPROCESS(thokitem) - FULLPROCESS(spinitem) - FULLPROCESS(revitem) -#undef FULLPROCESS - -#define GETSPEED(field) else if (!stricmp(stoken, #field)) skin->field = atoi(value)<field = atoi(value); - GETINT(thrustfactor) - GETINT(accelstart) - GETINT(acceleration) -#undef GETINT - - // custom translation table - else if (!stricmp(stoken, "startcolor")) - skin->starttranscolor = atoi(value); - - else if (!stricmp(stoken, "prefcolor")) - skin->prefcolor = R_GetColorByName(value); - else if (!stricmp(stoken, "jumpfactor")) - skin->jumpfactor = FLOAT_TO_FIXED(atof(value)); - else if (!stricmp(stoken, "highresscale")) - skin->highresscale = FLOAT_TO_FIXED(atof(value)); - else - { - INT32 found = false; - sfxenum_t i; - // copy name of sounds that are remapped - // for this skin - for (i = 0; i < sfx_skinsoundslot0; i++) - { - if (!S_sfx[i].name) - continue; - if (S_sfx[i].skinsound != -1 - && !stricmp(S_sfx[i].name, - stoken + 2)) - { - skin->soundsid[S_sfx[i].skinsound] = - S_AddSoundFx(value+2, S_sfx[i].singularity, S_sfx[i].pitch, true); - found = true; - } - } - if (!found) - CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); - } -next_token: - stoken = strtok(NULL, "\r\n= "); - } - free(buf2); - - lump++; // if no sprite defined use spirte just after this one - if (skin->sprite[0] == '\0') - { - const char *csprname = W_CheckNameForNumPwad(wadnum, lump); - - // skip to end of this skin's frames - lastlump = lump; - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0) - lastlump++; - // allocate (or replace) sprite frames, and set spritedef - R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); - } - else - { - // search in the normal sprite tables - size_t name; - boolean found = false; - const char *sprname = skin->sprite; - for (name = 0;sprnames[name][0] != '\0';name++) - if (strncmp(sprnames[name], sprname, 4) == 0) - { - found = true; - skin->spritedef = sprites[name]; - } - - // not found so make a new one - // go through the entire current wad looking for our sprite - // don't just mass add anything beginning with our four letters. - // "HOODFACE" is not a sprite name. - if (!found) - { - UINT16 localllump = 0, lstart = UINT16_MAX, lend = UINT16_MAX; - const char *lname; - - while ((lname = W_CheckNameForNumPwad(wadnum,localllump))) - { - // If this is a valid sprite... - if (!memcmp(lname,sprname,4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8') - { - if (lstart == UINT16_MAX) - lstart = localllump; - // If already set do nothing - } - else - { - if (lstart != UINT16_MAX) - { - lend = localllump; - break; - } - // If not already set do nothing - } - ++localllump; - } - - R_AddSingleSpriteDef(sprname, &skin->spritedef, wadnum, lstart, lend); - } - - // I don't particularly care about skipping to the end of the used frames. - // We could be using frames from ANYWHERE in the current WAD file, including - // right before us, which is a terrible idea. - // So just let the function in the while loop take care of it for us. - } - - R_FlushTranslationColormapCache(); - - CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); -#ifdef SKINVALUES - skin_cons_t[numskins].value = numskins; - skin_cons_t[numskins].strvalue = skin->name; -#endif - - // add face graphics - ST_LoadFaceGraphics(skin->face, skin->superface, numskins); - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_AddPlayerMD2(numskins); -#endif - - numskins++; - } - return; -} - -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum) -{ - UINT16 lump, lastlump = 0; - while ((lump = W_CheckForSkinMarkerInPwad(wadnum, lastlump)) != INT16_MAX) - { - if (skins[numskins].wadnum != wadnum) - break; - numskins--; - ST_UnLoadFaceGraphics(numskins); // only used by DELFILE - if (skins[numskins].sprite[0] != '\0') - { - const char *csprname = W_CheckNameForNumPwad(wadnum, lump); - - // skip to end of this skin's frames - lastlump = lump; - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),csprname,4)==0) - lastlump++; - // allocate (or replace) sprite frames, and set spritedef - R_DelSingleSpriteDef(csprname, &skins[numskins].spritedef, wadnum, lump, lastlump); - } - else - { - // search in the normal sprite tables - size_t name; - boolean found = false; - const char *sprname = skins[numskins].sprite; - for (name = 0;sprnames[name][0] != '\0';name++) - if (strcmp(sprnames[name], sprname) == 0) - { - found = true; - skins[numskins].spritedef = sprites[name]; - } - - // not found so make a new one - if (!found) - R_DelSingleSpriteDef(sprname, &skins[numskins].spritedef, wadnum, 0, INT16_MAX); - - while (W_CheckNameForNumPwad(wadnum,lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump),sprname,4)==0) - lastlump++; - } - CONS_Printf(M_GetText("Removed skin '%s'\n"), skins[numskins].name); - } -} -#endif diff --git a/src/r_things.h b/src/r_things.h index 6614e0aa4..05d6fb27b 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -14,21 +14,27 @@ #ifndef __R_THINGS__ #define __R_THINGS__ -#include "sounds.h" #include "r_plane.h" +#include "r_patch.h" +#include "r_portal.h" +#include "r_defs.h" +#include "r_skins.h" -// number of sprite lumps for spritewidth,offset,topoffset lookup tables -// Fab: this is a hack : should allocate the lookup tables per sprite -#define MAXVISSPRITES 2048 // added 2-2-98 was 128 +// -------------- +// SPRITE LOADING +// -------------- -#define VISSPRITECHUNKBITS 6 // 2^6 = 64 sprites per chunk -#define VISSPRITESPERCHUNK (1 << VISSPRITECHUNKBITS) -#define VISSPRITEINDEXMASK (VISSPRITESPERCHUNK - 1) +#define FEETADJUST (4<dispoffset, affects ordering but not drawing } vissprite_t; +extern UINT32 visspritecount; + +// ---------- +// DRAW NODES +// ---------- + // A drawnode is something that points to a 3D floor, 3D side, or masked // middle texture. This is used for sorting with sprites. typedef struct drawnode_s @@ -179,21 +201,11 @@ typedef struct drawnode_s struct drawnode_s *prev; } drawnode_t; -extern INT32 numskins; -extern skin_t skins[MAXSKINS + 1]; - -void SetPlayerSkin(INT32 playernum,const char *skinname); -void SetPlayerSkinByNum(INT32 playernum,INT32 skinnum); // Tails 03-16-2002 -INT32 R_SkinAvailable(const char *name); -void R_AddSkins(UINT16 wadnum); - -#ifdef DELFILE -void R_DelSkins(UINT16 wadnum); -#endif - void R_InitDrawNodes(void); -char *GetPlayerFacePic(INT32 skinnum); +// ----------------------- +// SPRITE FRAME CHARACTERS +// ----------------------- // Functions to go from sprite character ID to frame number // for 2.1 compatibility this still uses the old 'A' + frame code @@ -204,7 +216,7 @@ char *GetPlayerFacePic(INT32 skinnum); // Future: [[ ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@ ]] FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame) { -#if 1 // 2.1 compat +#if 0 // 2.1 compat return 'A' + frame; #else if (frame < 26) return 'A' + frame; @@ -218,11 +230,11 @@ FUNCMATH FUNCINLINE static ATTRINLINE char R_Frame2Char(UINT8 frame) FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn) { -#if 1 // 2.1 compat +#if 0 // 2.1 compat if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead return cn - 'A'; #else - if (cn >= 'A' && cn <= 'Z') return cn - 'A'; + if (cn >= 'A' && cn <= 'Z') return (cn - 'A'); if (cn >= '0' && cn <= '9') return (cn - '0') + 26; if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36; if (cn == '!') return 62; @@ -231,4 +243,26 @@ FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn) #endif } +// "Left" and "Right" character symbols for additional rotation functionality +#define ROT_L 17 +#define ROT_R 18 + +FUNCMATH FUNCINLINE static ATTRINLINE char R_Rotation2Char(UINT8 rot) +{ + if (rot <= 9) return '0' + rot; + if (rot <= 16) return 'A' + (rot - 10); + if (rot == ROT_L) return 'L'; + if (rot == ROT_R) return 'R'; + return '\xFF'; +} + +FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Rotation(char cn) +{ + if (cn >= '0' && cn <= '9') return (cn - '0'); + if (cn >= 'A' && cn <= 'G') return (cn - 'A') + 10; + if (cn == 'L') return ROT_L; + if (cn == 'R') return ROT_R; + return 255; +} + #endif //__R_THINGS__ diff --git a/src/s_sound.c b/src/s_sound.c index 0961a4427..0cc40a9ce 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,7 +27,7 @@ extern INT32 msg_id; #include "g_game.h" #include "m_argv.h" #include "r_main.h" // R_PointToAngle2() used to calc stereo sep. -#include "r_things.h" // for skins +#include "r_skins.h" // for skins #include "i_system.h" #include "i_sound.h" #include "s_sound.h" @@ -36,7 +36,13 @@ extern INT32 msg_id; #include "d_main.h" #include "r_sky.h" // skyflatnum #include "p_local.h" // camera info +#include "fastcmp.h" #include "m_misc.h" // for tunes command +#include "m_cond.h" // for conditionsets + +#ifdef HAVE_LUA_MUSICPLUS +#include "lua_hook.h" // MusicChange hook +#endif #ifdef HW3SOUND // 3D Sound Interface @@ -55,6 +61,14 @@ static void GameMIDIMusic_OnChange(void); static void GameSounds_OnChange(void); static void GameDigiMusic_OnChange(void); +#ifdef HAVE_OPENMPT +static void ModFilter_OnChange(void); +#endif + +static lumpnum_t S_GetMusicLumpNum(const char *mname); + +static boolean S_CheckQueue(void); + // commands for music and sound servers #ifdef MUSSERV consvar_t musserver_cmd = {"musserver_cmd", "musserver", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -69,12 +83,8 @@ consvar_t sndserver_arg = {"sndserver_arg", "-quiet", CV_SAVE, NULL, 0, NULL, NU #define SURROUND #endif -#if defined (_WIN32_WCE) || defined (DC) || defined(GP2X) -consvar_t cv_samplerate = {"samplerate", "11025", 0, CV_Unsigned, NULL, 11025, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? -#elif defined(_PSP) || defined(_WINDOWS) +#ifdef _WINDOWS consvar_t cv_samplerate = {"samplerate", "44100", 0, CV_Unsigned, NULL, 44100, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? -#elif defined(_WII) -consvar_t cv_samplerate = {"samplerate", "32000", 0, CV_Unsigned, NULL, 32000, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? #else consvar_t cv_samplerate = {"samplerate", "22050", 0, CV_Unsigned, NULL, 22050, NULL, NULL, 0, 0, NULL}; //Alam: For easy hacking? #endif @@ -89,21 +99,45 @@ static consvar_t precachesound = {"precachesound", "Off", CV_SAVE, CV_OnOff, NUL consvar_t cv_soundvolume = {"soundvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_digmusicvolume = {"digmusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static void Captioning_OnChange(void) +{ + S_ResetCaptions(); + if (cv_closedcaptioning.value) + S_StartSound(NULL, sfx_menu1); +} + +consvar_t cv_closedcaptioning = {"closedcaptioning", "Off", CV_SAVE|CV_CALL, CV_OnOff, Captioning_OnChange, 0, NULL, NULL, 0, 0, NULL}; + // number of channels available -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) -consvar_t cv_numChannels = {"snd_channels", "8", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_numChannels = {"snd_channels", "32", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL}; -#endif static consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_resetmusic = {"resetmusic", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_resetmusicbyheader = {"resetmusicbyheader", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t cons_1upsound_t[] = { + {0, "Jingle"}, + {1, "Sound"}, + {0, NULL} +}; +consvar_t cv_1upsound = {"1upsound", "Jingle", CV_SAVE, cons_1upsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; // Sound system toggles, saved into the config consvar_t cv_gamedigimusic = {"digimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameDigiMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamemidimusic = {"midimusic", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameMIDIMusic_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, GameSounds_OnChange, 0, NULL, NULL, 0, 0, NULL}; +// Window focus sound sytem toggles +consvar_t cv_playmusicifunfocused = {"playmusicifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playsoundsifunfocused = {"playsoundsifunfocused", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; + +#ifdef HAVE_OPENMPT +static CV_PossibleValue_t interpolationfilter_cons_t[] = {{0, "Default"}, {1, "None"}, {2, "Linear"}, {4, "Cubic"}, {8, "Windowed sinc"}, {0, NULL}}; +consvar_t cv_modfilter = {"modfilter", "0", CV_SAVE|CV_CALL, interpolationfilter_cons_t, ModFilter_OnChange, 0, NULL, NULL, 0, 0, NULL}; +#endif + #define S_MAX_VOLUME 127 // when to clip out sounds @@ -138,23 +172,24 @@ consvar_t cv_gamesounds = {"sounds", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, // percent attenuation from front to back #define S_IFRACVOL 30 -typedef struct -{ - // sound information (if null, channel avail.) - sfxinfo_t *sfxinfo; - - // origin of sound - const void *origin; - - // handle of the sound being played - INT32 handle; - -} channel_t; - // the set of channels available static channel_t *channels = NULL; static INT32 numofchannels = 0; +caption_t closedcaptions[NUMCAPTIONS]; + +void S_ResetCaptions(void) +{ + UINT8 i; + for (i = 0; i < NUMCAPTIONS; i++) + { + closedcaptions[i].c = NULL; + closedcaptions[i].s = NULL; + closedcaptions[i].t = 0; + closedcaptions[i].b = 0; + } +} + // // Internals. // @@ -258,14 +293,25 @@ void S_RegisterSoundStuff(void) CV_RegisterVar(&surround); CV_RegisterVar(&cv_samplerate); CV_RegisterVar(&cv_resetmusic); + CV_RegisterVar(&cv_resetmusicbyheader); + CV_RegisterVar(&cv_1upsound); + CV_RegisterVar(&cv_playsoundsifunfocused); + CV_RegisterVar(&cv_playmusicifunfocused); CV_RegisterVar(&cv_gamesounds); CV_RegisterVar(&cv_gamedigimusic); CV_RegisterVar(&cv_gamemidimusic); +#ifdef HAVE_OPENMPT + CV_RegisterVar(&cv_modfilter); +#endif +#ifdef HAVE_MIXERX + CV_RegisterVar(&cv_midiplayer); + CV_RegisterVar(&cv_midisoundfontpath); + CV_RegisterVar(&cv_miditimiditypath); +#endif COM_AddCommand("tunes", Command_Tunes_f); COM_AddCommand("restartaudio", Command_RestartAudio_f); - #if defined (macintosh) && !defined (HAVE_SDL) // mp3 playlist stuff { INT32 i; @@ -319,6 +365,8 @@ static void SetChannelsNum(void) // Free all channels for use for (i = 0; i < numofchannels; i++) channels[i].sfxinfo = 0; + + S_ResetCaptions(); } @@ -344,6 +392,18 @@ lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx) return W_GetNumForName("dsthok"); } +// +// Sound Status +// + +boolean S_SoundDisabled(void) +{ + return ( + sound_disabled || + ( window_notinfocus && ! cv_playsoundsifunfocused.value ) + ); +} + // Stop all sounds, load level info, THEN start sounds. void S_StopSounds(void) { @@ -361,6 +421,8 @@ void S_StopSounds(void) for (cnum = 0; cnum < numofchannels; cnum++) if (channels[cnum].sfxinfo) S_StopChannel(cnum); + + S_ResetCaptions(); } void S_StopSoundByID(void *origin, sfxenum_t sfx_id) @@ -409,9 +471,96 @@ void S_StopSoundByNum(sfxenum_t sfxnum) } } +void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan) +{ + UINT8 i, set, moveup, start; + boolean same = false; + sfxinfo_t *sfx; + + if (!cv_closedcaptioning.value) // no captions at all + return; + + // check for bogus sound # + // I_Assert(sfx_id >= 0); -- allowing sfx_None; this shouldn't be allowed directly if S_StartCaption is ever exposed to Lua by itself + I_Assert(sfx_id < NUMSFX); + + sfx = &S_sfx[sfx_id]; + + if (sfx->caption[0] == '/') // no caption for this one + return; + + start = ((closedcaptions[0].s && (closedcaptions[0].s-S_sfx == sfx_None)) ? 1 : 0); + + if (sfx_id) + { + for (i = start; i < (set = NUMCAPTIONS-1); i++) + { + same = ((sfx == closedcaptions[i].s) || (closedcaptions[i].s && fastcmp(sfx->caption, closedcaptions[i].s->caption))); + if (same) + { + set = i; + break; + } + } + } + else + { + set = 0; + same = (closedcaptions[0].s == sfx); + } + + moveup = 255; + + if (!same) + { + for (i = start; i < set; i++) + { + if (!(closedcaptions[i].c || closedcaptions[i].s) || (sfx->priority >= closedcaptions[i].s->priority)) + { + set = i; + if (closedcaptions[i].s && (sfx->priority >= closedcaptions[i].s->priority)) + moveup = i; + break; + } + } + for (i = NUMCAPTIONS-1; i > set; i--) + { + if (sfx == closedcaptions[i].s) + { + closedcaptions[i].c = NULL; + closedcaptions[i].s = NULL; + closedcaptions[i].t = 0; + closedcaptions[i].b = 0; + } + } + } + + if (moveup != 255) + { + for (i = moveup; i < NUMCAPTIONS-1; i++) + { + if (!(closedcaptions[i].c || closedcaptions[i].s)) + break; + } + for (; i > set; i--) + { + closedcaptions[i].c = closedcaptions[i-1].c; + closedcaptions[i].s = closedcaptions[i-1].s; + closedcaptions[i].t = closedcaptions[i-1].t; + closedcaptions[i].b = closedcaptions[i-1].b; + } + } + + closedcaptions[set].c = ((cnum == -1) ? NULL : &channels[cnum]); + closedcaptions[set].s = sfx; + closedcaptions[set].t = lifespan; + closedcaptions[set].b = 2; // bob +} + void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) { INT32 sep, pitch, priority, cnum; + const sfxenum_t actual_id = sfx_id; sfxinfo_t *sfx; const mobj_t *origin = (const mobj_t *)origin_p; @@ -422,7 +571,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) mobj_t *listenmobj = players[displayplayer].mo; mobj_t *listenmobj2 = NULL; - if (sound_disabled || !sound_started) + if (S_SoundDisabled() || !sound_started) return; // Don't want a sound? Okay then... @@ -549,6 +698,9 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) sep = (~sep) & 255; #endif + // Handle closed caption input. + S_StartCaption(actual_id, cnum, MAXCAPTIONTICS); + // Assigns the handle to one of the channels in the // mix/output buffer. channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); @@ -599,6 +751,9 @@ dontplay: sep = (~sep) & 255; #endif + // Handle closed caption input. + S_StartCaption(actual_id, cnum, MAXCAPTIONTICS); + // Assigns the handle to one of the channels in the // mix/output buffer. channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); @@ -606,7 +761,7 @@ dontplay: void S_StartSound(const void *origin, sfxenum_t sfx_id) { - if (sound_disabled) + if (S_SoundDisabled()) return; if (mariomode) // Sounds change in Mario mode! @@ -620,6 +775,7 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id) // sfx_id = sfx_mario8; // break; case sfx_thok: + case sfx_wepfir: sfx_id = sfx_mario7; break; case sfx_pop: @@ -629,6 +785,14 @@ void S_StartSound(const void *origin, sfxenum_t sfx_id) sfx_id = sfx_mario6; break; case sfx_shield: + case sfx_wirlsg: + case sfx_forcsg: + case sfx_elemsg: + case sfx_armasg: + case sfx_attrsg: + case sfx_s3k3e: + case sfx_s3k3f: + case sfx_s3k41: sfx_id = sfx_mario3; break; case sfx_itemup: @@ -733,9 +897,7 @@ void S_UpdateSounds(void) I_UpdateMumble(NULL, listener); #endif - // Stop cutting FMOD out. WE'RE sick of it. - I_UpdateSound(); - return; + goto notinlevel; } if (dedicated || sound_disabled) @@ -774,8 +936,7 @@ void S_UpdateSounds(void) if (hws_mode != HWS_DEFAULT_MODE) { HW3S_UpdateSources(); - I_UpdateSound(); - return; + goto notinlevel; } #endif @@ -863,9 +1024,36 @@ void S_UpdateSounds(void) } } +notinlevel: I_UpdateSound(); } +void S_UpdateClosedCaptions(void) +{ + UINT8 i; + boolean gamestopped = (paused || P_AutoPause()); + for (i = 0; i < NUMCAPTIONS; i++) // update captions + { + if (!closedcaptions[i].s) + continue; + + if (i == 0 && (closedcaptions[0].s-S_sfx == sfx_None) && gamestopped) + continue; + + if (!(--closedcaptions[i].t)) + { + closedcaptions[i].c = NULL; + closedcaptions[i].s = NULL; + } + else if (closedcaptions[i].c && !I_SoundIsPlaying(closedcaptions[i].c->handle)) + { + closedcaptions[i].c = NULL; + if (closedcaptions[i].t > CAPTIONFADETICS) + closedcaptions[i].t = CAPTIONFADETICS; + } + } +} + void S_SetSfxVolume(INT32 volume) { if (volume < 0 || volume > 31) @@ -1217,21 +1405,21 @@ void S_InitSfxChannels(INT32 sfxVolume) #ifdef MUSICSLOT_COMPATIBILITY const char *compat_special_music_slots[16] = { - "titles", // 1036 title screen - "read_m", // 1037 intro - "lclear", // 1038 level clear - "invinc", // 1039 invincibility - "shoes", // 1040 super sneakers - "minvnc", // 1041 Mario invincibility - "drown", // 1042 drowning - "gmover", // 1043 game over - "xtlife", // 1044 extra life - "contsc", // 1045 continue screen - "supers", // 1046 Super Sonic - "chrsel", // 1047 character select - "credit", // 1048 credits - "racent", // 1049 Race Results - "stjr", // 1050 Sonic Team Jr. Presents + "_title", // 1036 title screen + "_intro", // 1037 intro + "_clear", // 1038 level clear + "_inv", // 1039 invincibility + "_shoes", // 1040 super sneakers + "_minv", // 1041 Mario invincibility + "_drown", // 1042 drowning + "_gover", // 1043 game over + "_1up", // 1044 extra life + "_conti", // 1045 continue screen + "_super", // 1046 Super Sonic + "_chsel", // 1047 character select + "_creds", // 1048 credits + "_inter", // 1049 Race Results + "_stjr", // 1050 Sonic Team Jr. Presents "" }; #endif @@ -1241,6 +1429,374 @@ static void *music_data; static UINT16 music_flags; static boolean music_looping; +static char queue_name[7]; +static UINT16 queue_flags; +static boolean queue_looping; +static UINT32 queue_position; +static UINT32 queue_fadeinms; + +static tic_t pause_starttic; + +/// ------------------------ +/// Music Definitions +/// ------------------------ + +enum +{ + MUSICDEF_220, + MUSICDEF_221, +}; + +musicdef_t soundtestsfx = { + "_STSFX", // prevents exactly one valid track name from being used on the sound test + "Sound Effects", + "", + "SEGA, VAdaPEGA, other sources", + 1, // show on soundtest page 1 + 0, // with no conditions + 0, + 0, + false, + NULL +}; + +musicdef_t *musicdefstart = &soundtestsfx; + +// +// search for music definition in wad +// +static UINT16 W_CheckForMusicDefInPwad(UINT16 wadid) +{ + UINT16 i; + lumpinfo_t *lump_p; + + lump_p = wadfiles[wadid]->lumpinfo; + for (i = 0; i < wadfiles[wadid]->numlumps; i++, lump_p++) + if (memcmp(lump_p->name, "MUSICDEF", 8) == 0) + return i; + + return INT16_MAX; // not found +} + +static void +MusicDefStrcpy (char *p, const char *s, size_t n, int version) +{ + strlcpy(p, s, n); + if (version == MUSICDEF_220) + { + while (( p = strchr(p, '_') )) + *p++ = ' '; // turn _ into spaces. + } +} + +static boolean +ReadMusicDefFields (UINT16 wadnum, int line, boolean fields, char *stoken, + musicdef_t **defp, int *versionp) +{ + musicdef_t *def; + int version; + + char *value; + char *textline; + int i; + + if (!stricmp(stoken, "lump")) + { + value = strtok(NULL, " "); + if (!value) + { + CONS_Alert(CONS_WARNING, + "MUSICDEF: Field '%s' is missing name. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; + } + else + { + musicdef_t *prev = NULL; + def = musicdefstart; + + // Search if this is a replacement + //CONS_Printf("S_LoadMusicDefs: Searching for song replacement...\n"); + while (def) + { + if (!stricmp(def->name, value)) + { + //CONS_Printf("S_LoadMusicDefs: Found song replacement '%s'\n", def->name); + break; + } + + prev = def; + def = def->next; + } + + // Nothing found, add to the end. + if (!def) + { + def = Z_Calloc(sizeof (musicdef_t), PU_STATIC, NULL); + STRBUFCPY(def->name, value); + strlwr(def->name); + def->bpm = TICRATE<<(FRACBITS-1); // FixedDiv((60*TICRATE)<next = def; + //CONS_Printf("S_LoadMusicDefs: Added song '%s'\n", def->name); + } + + (*defp) = def; + } + } + else if (!stricmp(stoken, "version")) + { + if (fields)/* is this not the first field? */ + { + CONS_Alert(CONS_WARNING, + "MUSICDEF: Field '%s' must come first. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; + } + else + { + value = strtok(NULL, " "); + if (!value) + { + CONS_Alert(CONS_WARNING, + "MUSICDEF: Field '%s' is missing version. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; + } + else + { + if (strcasecmp(value, "2.2.0")) + (*versionp) = MUSICDEF_221; + } + } + } + else + { + version = (*versionp); + + if (version == MUSICDEF_220) + value = strtok(NULL, " ="); + else + { + value = strtok(NULL, ""); + + if (value) + { + // Find the equals sign. + value = strchr(value, '='); + } + } + + if (!value) + { + CONS_Alert(CONS_WARNING, + "MUSICDEF: Field '%s' is missing value. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; + } + else + { + def = (*defp); + + if (!def) + { + CONS_Alert(CONS_ERROR, + "MUSICDEF: No music definition before field '%s'. (file %s, line %d)\n", + stoken, wadfiles[wadnum]->filename, line); + return false; + } + + if (version != MUSICDEF_220) + { + // Skip the equals sign. + value++; + + // Now skip funny whitespace. + value += strspn(value, "\t "); + } + + textline = value; + i = atoi(value); + + /* based ignored lumps */ + if (!stricmp(stoken, "usage")) { +#if 0 // Ignore for now + STRBUFCPY(def->usage, textline); +#endif + } else if (!stricmp(stoken, "source")) { +#if 0 // Ignore for now + STRBUFCPY(def->source, textline); +#endif + } else if (!stricmp(stoken, "title")) { + MusicDefStrcpy(def->title, textline, + sizeof def->title, version); + } else if (!stricmp(stoken, "alttitle")) { + MusicDefStrcpy(def->alttitle, textline, + sizeof def->alttitle, version); + } else if (!stricmp(stoken, "authors")) { + MusicDefStrcpy(def->authors, textline, + sizeof def->authors, version); + } else if (!stricmp(stoken, "soundtestpage")) { + def->soundtestpage = (UINT8)i; + } else if (!stricmp(stoken, "soundtestcond")) { + // Convert to map number + if (textline[0] >= 'A' && textline[0] <= 'Z' && textline[2] == '\0') + i = M_MapNumber(textline[0], textline[1]); + def->soundtestcond = (INT16)i; + } else if (!stricmp(stoken, "stoppingtime")) { + double stoppingtime = atof(textline)*TICRATE; + def->stoppingtics = (tic_t)stoppingtime; + } else if (!stricmp(stoken, "bpm")) { + double bpm = atof(textline); + fixed_t bpmf = FLOAT_TO_FIXED(bpm); + if (bpmf > 0) + def->bpm = FixedDiv((60*TICRATE)<filename, line); + } + } + } + + return true; +} + +void S_LoadMusicDefs(UINT16 wadnum) +{ + UINT16 lumpnum; + char *lump; + char *musdeftext; + size_t size; + + char *lf; + char *stoken; + + size_t nlf; + size_t ncr; + + musicdef_t *def = NULL; + int version = MUSICDEF_220; + int line = 1; // for better error msgs + boolean fields = false; + + lumpnum = W_CheckForMusicDefInPwad(wadnum); + if (lumpnum == INT16_MAX) + return; + + lump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + size = W_LumpLengthPwad(wadnum, lumpnum); + + // Null-terminated MUSICDEF lump. + musdeftext = malloc(size+1); + if (!musdeftext) + I_Error("S_LoadMusicDefs: No more free memory for the parser\n"); + M_Memcpy(musdeftext, lump, size); + musdeftext[size] = '\0'; + + // Find music def + stoken = musdeftext; + for (;;) + { + lf = strpbrk(stoken, "\r\n"); + if (lf) + { + if (*lf == '\n') + nlf = 1; + else + nlf = 0; + *lf++ = '\0';/* now we can delimit to here */ + } + + stoken = strtok(stoken, " "); + if (stoken) + { + if (! ReadMusicDefFields(wadnum, line, fields, stoken, + &def, &version)) + break; + fields = true; + } + + if (lf) + { + do + { + line += nlf; + ncr = strspn(lf, "\r");/* skip CR */ + lf += ncr; + nlf = strspn(lf, "\n"); + lf += nlf; + } + while (nlf || ncr) ; + + stoken = lf;/* now the next nonempty line */ + } + else + break;/* EOF */ + } + + free(musdeftext); +} + +// +// S_InitMusicDefs +// +// Simply load music defs in all wads. +// +void S_InitMusicDefs(void) +{ + UINT16 i; + for (i = 0; i < numwadfiles; i++) + S_LoadMusicDefs(i); +} + +musicdef_t **soundtestdefs = NULL; +INT32 numsoundtestdefs = 0; +UINT8 soundtestpage = 1; + +// +// S_PrepareSoundTest +// +// Prepare sound test. What am I, your butler? +// +boolean S_PrepareSoundTest(void) +{ + musicdef_t *def; + INT32 pos = numsoundtestdefs = 0; + + for (def = musicdefstart; def; def = def->next) + { + if (!(def->soundtestpage & soundtestpage)) + continue; + def->allowed = false; + numsoundtestdefs++; + } + + if (!numsoundtestdefs) + return false; + + if (soundtestdefs) + Z_Free(soundtestdefs); + + if (!(soundtestdefs = Z_Malloc(numsoundtestdefs*sizeof(musicdef_t *), PU_STATIC, NULL))) + I_Error("S_PrepareSoundTest(): could not allocate soundtestdefs."); + + for (def = musicdefstart; def /*&& i < numsoundtestdefs*/; def = def->next) + { + if (!(def->soundtestpage & soundtestpage)) + continue; + soundtestdefs[pos++] = def; + if (def->soundtestcond > 0 && !(mapvisited[def->soundtestcond-1] & MV_BEATEN)) + continue; + if (def->soundtestcond < 0 && !M_Achieved(-1-def->soundtestcond)) + continue; + def->allowed = true; + } + + return true; +} + + /// ------------------------ /// Music Status /// ------------------------ @@ -1270,11 +1826,23 @@ boolean S_MusicPaused(void) return I_SongPaused(); } +boolean S_MusicNotInFocus(void) +{ + return ( + ( window_notinfocus && ! cv_playmusicifunfocused.value ) + ); +} + musictype_t S_MusicType(void) { return I_SongType(); } +const char *S_MusicName(void) +{ + return music_name; +} + boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) { if (!I_SongPlaying()) @@ -1305,10 +1873,334 @@ boolean S_SpeedMusic(float speed) return I_SetSongSpeed(speed); } +/// ------------------------ +/// Music Seeking +/// ------------------------ + +UINT32 S_GetMusicLength(void) +{ + return I_GetSongLength(); +} + +boolean S_SetMusicLoopPoint(UINT32 looppoint) +{ + return I_SetSongLoopPoint(looppoint); +} + +UINT32 S_GetMusicLoopPoint(void) +{ + return I_GetSongLoopPoint(); +} + +boolean S_SetMusicPosition(UINT32 position) +{ + return I_SetSongPosition(position); +} + +UINT32 S_GetMusicPosition(void) +{ + return I_GetSongPosition(); +} + +/// ------------------------ +/// Music Stacking (Jingles) +/// In this section: mazmazz doesn't know how to do dynamic arrays or struct pointers! +/// ------------------------ + +static musicstack_t *music_stacks = NULL; +static musicstack_t *last_music_stack = NULL; + +void S_SetStackAdjustmentStart(void) +{ + if (!pause_starttic) + pause_starttic = gametic; +} + +void S_AdjustMusicStackTics(void) +{ + if (pause_starttic) + { + musicstack_t *mst; + for (mst = music_stacks; mst; mst = mst->next) + mst->tic += gametic - pause_starttic; + pause_starttic = 0; + } +} + +static void S_ResetMusicStack(void) +{ + musicstack_t *mst, *mst_next; + for (mst = music_stacks; mst; mst = mst_next) + { + mst_next = mst->next; + Z_Free(mst); + } + music_stacks = last_music_stack = NULL; +} + +static void S_RemoveMusicStackEntry(musicstack_t *entry) +{ + musicstack_t *mst; + for (mst = music_stacks; mst; mst = mst->next) + { + if (mst == entry) + { + // Remove ourselves from the chain and link + // prev and next together + + if (mst->prev) + mst->prev->next = mst->next; + else + music_stacks = mst->next; + + if (mst->next) + mst->next->prev = mst->prev; + else + last_music_stack = mst->prev; + + break; + } + } + Z_Free(entry); +} + +static void S_RemoveMusicStackEntryByStatus(UINT16 status) +{ + musicstack_t *mst, *mst_next; + + if (!status) + return; + + for (mst = music_stacks; mst; mst = mst_next) + { + mst_next = mst->next; + if (mst->status == status) + S_RemoveMusicStackEntry(mst); + } +} + +static void S_AddMusicStackEntry(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status) +{ + musicstack_t *mst, *new_mst; + + // if the first entry is empty, force master onto it + if (!music_stacks) + { + music_stacks = Z_Calloc(sizeof (*mst), PU_MUSIC, NULL); + strncpy(music_stacks->musname, (status == JT_MASTER ? mname : (S_CheckQueue() ? queue_name : mapmusname)), 7); + music_stacks->musflags = (status == JT_MASTER ? mflags : (S_CheckQueue() ? queue_flags : mapmusflags)); + music_stacks->looping = (status == JT_MASTER ? looping : (S_CheckQueue() ? queue_looping : true)); + music_stacks->position = (status == JT_MASTER ? position : (S_CheckQueue() ? queue_position : S_GetMusicPosition())); + music_stacks->tic = gametic; + music_stacks->status = JT_MASTER; + music_stacks->mlumpnum = S_GetMusicLumpNum(music_stacks->musname); + music_stacks->noposition = S_CheckQueue(); + + if (status == JT_MASTER) + return; // we just added the user's entry here + } + + // look for an empty slot to park ourselves + for (mst = music_stacks; mst->next; mst = mst->next); + + // create our new entry + new_mst = Z_Calloc(sizeof (*new_mst), PU_MUSIC, NULL); + strncpy(new_mst->musname, mname, 7); + new_mst->musname[6] = 0; + new_mst->musflags = mflags; + new_mst->looping = looping; + new_mst->position = position; + new_mst->tic = gametic; + new_mst->status = status; + new_mst->mlumpnum = S_GetMusicLumpNum(new_mst->musname); + new_mst->noposition = false; + + mst->next = new_mst; + new_mst->prev = mst; + new_mst->next = NULL; + last_music_stack = new_mst; +} + +static musicstack_t *S_GetMusicStackEntry(UINT16 status, boolean fromfirst, INT16 startindex) +{ + musicstack_t *mst, *start_mst = NULL, *mst_next; + + // if the first entry is empty, force master onto it + // fixes a memory corruption bug + if (!music_stacks && status != JT_MASTER) + S_AddMusicStackEntry(mapmusname, mapmusflags, true, S_GetMusicPosition(), JT_MASTER); + + if (startindex >= 0) + { + INT16 i = 0; + for (mst = music_stacks; mst && i <= startindex; mst = mst->next, i++) + start_mst = mst; + } + else + start_mst = (fromfirst ? music_stacks : last_music_stack); + + for (mst = start_mst; mst; mst = mst_next) + { + mst_next = (fromfirst ? mst->next : mst->prev); + + if (!status || mst->status == status) + { + if (P_EvaluateMusicStatus(mst->status, mst->musname)) + { + if (!S_MusicExists(mst->musname, !midi_disabled, !digital_disabled)) // paranoia + S_RemoveMusicStackEntry(mst); // then continue + else + return mst; + } + else + S_RemoveMusicStackEntry(mst); // then continue + } + } + + return NULL; +} + +void S_RetainMusic(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status) +{ + musicstack_t *mst; + + if (!status) // we use this as a null indicator, don't push + { + CONS_Alert(CONS_ERROR, "Music stack entry must have a nonzero status.\n"); + return; + } + else if (status == JT_MASTER) // enforce only one JT_MASTER + { + for (mst = music_stacks; mst; mst = mst->next) + { + if (mst->status == JT_MASTER) + { + CONS_Alert(CONS_ERROR, "Music stack can only have one JT_MASTER entry.\n"); + return; + } + } + } + else // remove any existing status + S_RemoveMusicStackEntryByStatus(status); + + S_AddMusicStackEntry(mname, mflags, looping, position, status); +} + +boolean S_RecallMusic(UINT16 status, boolean fromfirst) +{ + UINT32 newpos = 0; + boolean mapmuschanged = false; + musicstack_t *result; + musicstack_t *entry = Z_Calloc(sizeof (*result), PU_MUSIC, NULL); + + if (status) + result = S_GetMusicStackEntry(status, fromfirst, -1); + else + result = S_GetMusicStackEntry(JT_NONE, false, -1); + + if (result && !S_MusicExists(result->musname, !midi_disabled, !digital_disabled)) + { + Z_Free(entry); + return false; // music doesn't exist, so don't do anything + } + + // make a copy of result, since we make modifications to our copy + if (result) + { + *entry = *result; + strncpy(entry->musname, result->musname, 7); + } + + // no result, just grab mapmusname + if (!result || !entry->musname[0] || ((status == JT_MASTER || (music_stacks ? !music_stacks->status : false)) && !entry->status)) + { + strncpy(entry->musname, mapmusname, 7); + entry->musflags = mapmusflags; + entry->looping = true; + entry->position = mapmusposition; + entry->tic = gametic; + entry->status = JT_MASTER; + entry->mlumpnum = S_GetMusicLumpNum(entry->musname); + entry->noposition = false; // don't set this until we do the mapmuschanged check, below. Else, this breaks some resumes. + } + + if (entry->status == JT_MASTER) + { + mapmuschanged = strnicmp(entry->musname, mapmusname, 7); + if (mapmuschanged) + { + strncpy(entry->musname, mapmusname, 7); + entry->musflags = mapmusflags; + entry->looping = true; + entry->position = mapmusposition; + entry->tic = gametic; + entry->status = JT_MASTER; + entry->mlumpnum = S_GetMusicLumpNum(entry->musname); + entry->noposition = true; + } + S_ResetMusicStack(); + } + else if (!entry->status) + { + Z_Free(entry); + return false; + } + + if (strncmp(entry->musname, S_MusicName(), 7)) // don't restart music if we're already playing it + { + if (music_stack_fadeout) + S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, music_stack_fadeout, 0); + else + { + S_ChangeMusicEx(entry->musname, entry->musflags, entry->looping, 0, 0, music_stack_fadein); + + if (!entry->noposition && !music_stack_noposition) // HACK: Global boolean to toggle position resuming, e.g., de-superize + { + UINT32 poslapse = 0; + + // To prevent the game from jumping past the end of the music, we need + // to check if we can get the song's length. Otherwise, if the lapsed resume time goes + // over a LOOPPOINT, mixer_sound.c will be unable to calculate the new resume position. + if (S_GetMusicLength()) + poslapse = (UINT32)((float)(gametic - entry->tic)/(float)TICRATE*(float)MUSICRATE); + + newpos = entry->position + poslapse; + } + + // If the newly recalled music lumpnum does not match the lumpnum that we stored in stack, + // then discard the new position. That way, we will not recall an invalid position + // when the music is replaced or digital/MIDI is toggled. + if (newpos > 0 && S_MusicPlaying() && S_GetMusicLumpNum(entry->musname) == entry->mlumpnum) + S_SetMusicPosition(newpos); + else + { + S_StopFadingMusic(); + S_SetInternalMusicVolume(100); + } + } + music_stack_noposition = false; + music_stack_fadeout = 0; + music_stack_fadein = JINGLEPOSTFADE; + } + + Z_Free(entry); + return true; +} + /// ------------------------ /// Music Playback /// ------------------------ +static lumpnum_t S_GetMusicLumpNum(const char *mname) +{ + if (!S_DigMusicDisabled() && S_DigExists(mname)) + return W_GetNumForName(va("o_%s", mname)); + else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname)) + return W_GetNumForName(va("d_%s", mname)); + else + return LUMPERROR; +} + static boolean S_LoadMusic(const char *mname) { lumpnum_t mlumpnum; @@ -1317,23 +2209,11 @@ static boolean S_LoadMusic(const char *mname) if (S_MusicDisabled()) return false; - if (!S_DigMusicDisabled() && S_DigExists(mname)) - mlumpnum = W_GetNumForName(va("o_%s", mname)); - else if (!S_MIDIMusicDisabled() && S_MIDIExists(mname)) - mlumpnum = W_GetNumForName(va("d_%s", mname)); - else if (S_DigMusicDisabled() && S_DigExists(mname)) + mlumpnum = S_GetMusicLumpNum(mname); + + if (mlumpnum == LUMPERROR) { - CONS_Alert(CONS_NOTICE, "Digital music is disabled!\n"); - return false; - } - else if (S_MIDIMusicDisabled() && S_MIDIExists(mname)) - { - CONS_Alert(CONS_NOTICE, "MIDI music is disabled!\n"); - return false; - } - else - { - CONS_Alert(CONS_ERROR, M_GetText("Music lump %.6s not found!\n"), mname); + CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: lump not found!\n", mname); return false; } @@ -1360,7 +2240,10 @@ static boolean S_LoadMusic(const char *mname) return true; } else + { + CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded: engine failure!\n", mname); return false; + } } static void S_UnloadMusic(void) @@ -1377,57 +2260,114 @@ static void S_UnloadMusic(void) music_looping = false; } -static boolean S_PlayMusic(boolean looping) +static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) { if (S_MusicDisabled()) return false; - if (!I_PlaySong(looping)) + if ((!fadeinms && !I_PlaySong(looping)) || + (fadeinms && !I_FadeInPlaySong(fadeinms, looping))) { + CONS_Alert(CONS_ERROR, "Music %.6s could not be played: engine failure!\n", music_name); S_UnloadMusic(); return false; } S_InitMusicVolume(); // switch between digi and sequence volume + + if (S_MusicNotInFocus()) + S_PauseAudio(); + return true; } -void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping) +static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms) { -#if defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined(GP2X) - S_ClearSfx(); -#endif + strncpy(queue_name, mmusic, 7); + queue_flags = mflags; + queue_looping = looping; + queue_position = position; + queue_fadeinms = fadeinms; +} + +static boolean S_CheckQueue(void) +{ + return queue_name[0]; +} + +static void S_ClearQueue(void) +{ + queue_name[0] = queue_flags = queue_looping = queue_position = queue_fadeinms = 0; +} + +static void S_ChangeMusicToQueue(void) +{ + S_ChangeMusicEx(queue_name, queue_flags, queue_looping, queue_position, 0, queue_fadeinms); + S_ClearQueue(); +} + +void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) +{ + char newmusic[7]; if (S_MusicDisabled()) return; - // No Music (empty string) - if (mmusic[0] == 0) - { - S_StopMusic(); + strncpy(newmusic, mmusic, 7); +#ifdef HAVE_LUA_MUSICPLUS + if(LUAh_MusicChange(music_name, newmusic, &mflags, &looping, &position, &prefadems, &fadeinms)) + return; +#endif + newmusic[6] = 0; + + // No Music (empty string) + if (newmusic[0] == 0) + { + if (prefadems) + I_FadeSong(0, prefadems, &S_StopMusic); + else + S_StopMusic(); return; } - if (strnicmp(music_name, mmusic, 6)) + if (prefadems) // queue music change for after fade // allow even if the music is the same + // && S_MusicPlaying() // Let the delay happen even if we're not playing music { - S_StopMusic(); // shutdown old music + CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name); + S_QueueMusic(newmusic, mflags, looping, position, fadeinms); + I_FadeSong(0, prefadems, S_ChangeMusicToQueue); + return; + } + else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) + { + CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); - if (!S_LoadMusic(mmusic)) - { - CONS_Alert(CONS_ERROR, "Music %.6s could not be loaded!\n", mmusic); + S_StopMusic(); + + if (!S_LoadMusic(newmusic)) return; - } music_flags = mflags; music_looping = looping; - if (!S_PlayMusic(looping)) - { - CONS_Alert(CONS_ERROR, "Music %.6s could not be played!\n", mmusic); + if (!S_PlayMusic(looping, fadeinms)) return; - } + + if (position) + I_SetSongPosition(position); + + I_SetSongTrack(mflags & MUSIC_TRACKMASK); + } + else if (fadeinms) // let fades happen with same music + { + I_SetSongPosition(position); + I_FadeSong(100, fadeinms, NULL); + } + else // reset volume to 100 with same music + { + I_StopFadingSong(); + I_FadeSong(100, 500, NULL); } - I_SetSongTrack(mflags & MUSIC_TRACKMASK); } void S_StopMusic(void) @@ -1441,6 +2381,22 @@ void S_StopMusic(void) S_SpeedMusic(1.0f); I_StopSong(); S_UnloadMusic(); // for now, stopping also means you unload the song + + if (cv_closedcaptioning.value) + { + if (closedcaptions[0].s-S_sfx == sfx_None) + { + if (gamestate != wipegamestate) + { + closedcaptions[0].c = NULL; + closedcaptions[0].s = NULL; + closedcaptions[0].t = 0; + closedcaptions[0].b = 0; + } + else + closedcaptions[0].t = CAPTIONFADETICS; + } + } } // @@ -1457,15 +2413,22 @@ void S_PauseAudio(void) #else I_StopCD(); #endif + + S_SetStackAdjustmentStart(); } void S_ResumeAudio(void) { + if (S_MusicNotInFocus()) + return; + if (I_SongPlaying() && I_SongPaused()) I_ResumeSong(); // resume cd music I_ResumeCD(); + + S_AdjustMusicStackTics(); } void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) @@ -1492,6 +2455,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) switch(I_SongType()) { case MU_MID: + case MU_MID_EX: //case MU_MOD: //case MU_GME: I_SetMusicVolume(seqvolume&31); @@ -1502,6 +2466,32 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) } } +/// ------------------------ +/// Music Fading +/// ------------------------ + +void S_SetInternalMusicVolume(INT32 volume) +{ + I_SetInternalMusicVolume(min(max(volume, 0), 100)); +} + +void S_StopFadingMusic(void) +{ + I_StopFadingSong(); +} + +boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms) +{ + if (source_volume < 0) + return I_FadeSong(target_volume, ms, NULL); + else + return I_FadeSongFromVolume(target_volume, source_volume, ms, NULL); +} + +boolean S_FadeOutStopMusic(UINT32 ms) +{ + return I_FadeSong(0, ms, &S_StopMusic); +} /// ------------------------ /// Init & Others @@ -1512,29 +2502,36 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume) // Kills playing sounds at start of level, // determines music if any, changes music. // -void S_Start(void) +void S_StartEx(boolean reset) { if (mapmusflags & MUSIC_RELOADRESET) { strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); mapmusname[6] = 0; mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusposition = mapheaderinfo[gamemap-1]->muspos; } - if (cv_resetmusic.value) + if (RESETMUSIC || reset) S_StopMusic(); - S_ChangeMusic(mapmusname, mapmusflags, true); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + + S_ResetMusicStack(); + music_stack_noposition = false; + music_stack_fadeout = 0; + music_stack_fadein = JINGLEPOSTFADE; } static void Command_Tunes_f(void) { const char *tunearg; UINT16 tunenum, track = 0; + UINT32 position = 0; const size_t argc = COM_Argc(); if (argc < 2) //tunes slot ... { - CONS_Printf("tunes [track] [speed] / <-show> / <-default> / <-none>:\n"); + CONS_Printf("tunes [track] [speed] [position] / <-show> / <-default> / <-none>:\n"); CONS_Printf(M_GetText("Play an arbitrary music lump. If a map number is used, 'MAP##M' is played.\n")); CONS_Printf(M_GetText("If the format supports multiple songs, you can specify which one to play.\n\n")); CONS_Printf(M_GetText("* With \"-show\", shows the currently playing tune and track.\n")); @@ -1581,10 +2578,15 @@ static void Command_Tunes_f(void) snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); else strncpy(mapmusname, tunearg, 7); + + if (argc > 4) + position = (UINT32)atoi(COM_Argv(4)); + mapmusname[6] = 0; mapmusflags = (track & MUSIC_TRACKMASK); + mapmusposition = position; - S_ChangeMusic(mapmusname, mapmusflags, true); + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); if (argc > 3) { @@ -1613,12 +2615,13 @@ static void Command_RestartAudio_f(void) void GameSounds_OnChange(void) { - if (M_CheckParm("-nosound")) + if (M_CheckParm("-nosound") || M_CheckParm("-noaudio")) return; if (sound_disabled) { sound_disabled = false; + I_StartupSound(); // will return early if initialised S_InitSfxChannels(cv_soundvolume.value); S_StartSound(NULL, sfx_strpst); } @@ -1631,7 +2634,7 @@ void GameSounds_OnChange(void) void GameDigiMusic_OnChange(void) { - if (M_CheckParm("-nomusic")) + if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio")) return; else if (M_CheckParm("-nodigmusic")) return; @@ -1639,12 +2642,13 @@ void GameDigiMusic_OnChange(void) if (digital_disabled) { digital_disabled = false; + I_StartupSound(); // will return early if initialised I_InitMusic(); S_StopMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); else - S_ChangeMusicInternal("lclear", false); + S_ChangeMusicInternal("_clear", false); } else { @@ -1673,7 +2677,7 @@ void GameDigiMusic_OnChange(void) void GameMIDIMusic_OnChange(void) { - if (M_CheckParm("-nomusic")) + if (M_CheckParm("-nomusic") || M_CheckParm("-noaudio")) return; else if (M_CheckParm("-nomidimusic")) return; @@ -1681,16 +2685,17 @@ void GameMIDIMusic_OnChange(void) if (midi_disabled) { midi_disabled = false; + I_StartupSound(); // will return early if initialised I_InitMusic(); if (Playing()) P_RestoreMusic(&players[consoleplayer]); else - S_ChangeMusicInternal("lclear", false); + S_ChangeMusicInternal("_clear", false); } else { midi_disabled = true; - if (S_MusicType() == MU_MID) + if (S_MusicType() == MU_MID || S_MusicType() == MU_MID_EX) { if (digital_disabled) S_StopMusic(); @@ -1711,3 +2716,11 @@ void GameMIDIMusic_OnChange(void) } } } + +#ifdef HAVE_OPENMPT +void ModFilter_OnChange(void) +{ + if (openmpt_mhandle) + openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); +} +#endif diff --git a/src/s_sound.h b/src/s_sound.h index 821746074..d7e0c46ab 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -20,17 +20,46 @@ #include "command.h" #include "tables.h" // angle_t +#ifdef HAVE_OPENMPT +#include "libopenmpt/libopenmpt.h" +openmpt_module *openmpt_mhandle; +#endif + // mask used to indicate sound origin is player item pickup #define PICKUP_SOUND 0x8000 extern consvar_t stereoreverse; -extern consvar_t cv_soundvolume, cv_digmusicvolume, cv_midimusicvolume; +extern consvar_t cv_soundvolume, cv_closedcaptioning, cv_digmusicvolume, cv_midimusicvolume; extern consvar_t cv_numChannels; + extern consvar_t cv_resetmusic; +extern consvar_t cv_resetmusicbyheader; + +extern consvar_t cv_1upsound; + +#define RESETMUSIC (!modeattacking && \ + (cv_resetmusicbyheader.value ? \ + (mapheaderinfo[gamemap-1]->musforcereset != -1 ? mapheaderinfo[gamemap-1]->musforcereset : cv_resetmusic.value) \ + : cv_resetmusic.value) \ + ) + extern consvar_t cv_gamedigimusic; extern consvar_t cv_gamemidimusic; extern consvar_t cv_gamesounds; +extern consvar_t cv_playmusicifunfocused; +extern consvar_t cv_playsoundsifunfocused; + +#ifdef HAVE_OPENMPT +extern consvar_t cv_modfilter; +#endif + +#ifdef HAVE_MIXERX +extern consvar_t cv_midiplayer; +extern consvar_t cv_midisoundfontpath; +extern consvar_t cv_miditimiditypath; +#endif + #ifdef SNDSERV extern consvar_t sndserver_cmd, sndserver_arg; #endif @@ -69,6 +98,34 @@ typedef struct { angle_t angle; } listener_t; +typedef struct +{ + // sound information (if null, channel avail.) + sfxinfo_t *sfxinfo; + + // origin of sound + const void *origin; + + // handle of the sound being played + INT32 handle; + +} channel_t; + +typedef struct { + channel_t *c; + sfxinfo_t *s; + UINT16 t; + UINT8 b; +} caption_t; + +#define NUMCAPTIONS 8 +#define MAXCAPTIONTICS (2*TICRATE) +#define CAPTIONFADETICS 20 + +extern caption_t closedcaptions[NUMCAPTIONS]; +void S_StartCaption(sfxenum_t sfx_id, INT32 cnum, UINT16 lifespan); +void S_ResetCaptions(void); + // register sound vars and commands at game startup void S_RegisterSoundStuff(void); @@ -84,13 +141,20 @@ void S_InitSfxChannels(INT32 sfxVolume); // void S_StopSounds(void); void S_ClearSfx(void); -void S_Start(void); +void S_StartEx(boolean reset); +#define S_Start() S_StartEx(false) // // Basically a W_GetNumForName that adds "ds" at the beginning of the string. Returns a lumpnum. // lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx); +// +// Sound Status +// + +boolean S_SoundDisabled(void); + // // Start sound for thing at using from sounds.h // @@ -111,30 +175,113 @@ boolean S_MIDIMusicDisabled(void); boolean S_MusicDisabled(void); boolean S_MusicPlaying(void); boolean S_MusicPaused(void); +boolean S_MusicNotInFocus(void); musictype_t S_MusicType(void); +const char *S_MusicName(void); boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping); boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi); #define S_DigExists(a) S_MusicExists(a, false, true) #define S_MIDIExists(a) S_MusicExists(a, true, false) - // -// Music Properties +// Music Effects // // Set Speed of Music boolean S_SpeedMusic(float speed); +// Music definitions +typedef struct musicdef_s +{ + char name[7]; + char title[32]; + char alttitle[64]; + char authors[256]; + //char usage[256]; -- probably never going to be relevant to vanilla + /* + the trouble here is that kart combines what we call "title" + and "authors" into one string. we need to split it for sound + test reasons. they might split it later like we did, but... + */ + //char source[256]; + UINT8 soundtestpage; + INT16 soundtestcond; // +ve for map, -ve for conditionset, 0 for already here + tic_t stoppingtics; + fixed_t bpm; + boolean allowed; // question marks or listenable on sound test? + struct musicdef_s *next; +} musicdef_t; + +extern musicdef_t soundtestsfx; +extern musicdef_t *musicdefstart; +extern musicdef_t **soundtestdefs; +extern INT32 numsoundtestdefs; +extern UINT8 soundtestpage; + +void S_LoadMusicDefs(UINT16 wadnum); +void S_InitMusicDefs(void); + +boolean S_PrepareSoundTest(void); + // -// Music Routines +// Music Seeking +// + +// Get Length of Music +UINT32 S_GetMusicLength(void); + +// Set LoopPoint of Music +boolean S_SetMusicLoopPoint(UINT32 looppoint); + +// Get LoopPoint of Music +UINT32 S_GetMusicLoopPoint(void); + +// Set Position of Music +boolean S_SetMusicPosition(UINT32 position); + +// Get Position of Music +UINT32 S_GetMusicPosition(void); + +// +// Music Stacking (Jingles) +// + +typedef struct musicstack_s +{ + char musname[7]; + UINT16 musflags; + boolean looping; + UINT32 position; + tic_t tic; + UINT16 status; + lumpnum_t mlumpnum; + boolean noposition; // force music stack resuming from zero (like music_stack_noposition) + + struct musicstack_s *prev; + struct musicstack_s *next; +} musicstack_t; + +char music_stack_nextmusname[7]; +boolean music_stack_noposition; +UINT32 music_stack_fadeout; +UINT32 music_stack_fadein; + +void S_SetStackAdjustmentStart(void); +void S_AdjustMusicStackTics(void); +void S_RetainMusic(const char *mname, UINT16 mflags, boolean looping, UINT32 position, UINT16 status); +boolean S_RecallMusic(UINT16 status, boolean fromfirst); + +// +// Music Playback // // Start music track, arbitrary, given its name, and set whether looping // note: music flags 12 bits for tracknum (gme, other formats with more than one track) // 13-15 aren't used yet // and the last bit we ignore (internal game flag for resetting music on reload) -#define S_ChangeMusicInternal(a,b) S_ChangeMusic(a,0,b) -void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping); +void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms); +#define S_ChangeMusicInternal(a,b) S_ChangeMusicEx(a,0,b,0,0,0) +#define S_ChangeMusic(a,b,c) S_ChangeMusicEx(a,b,c,0,0,0) // Stops the music. void S_StopMusic(void); @@ -143,10 +290,22 @@ void S_StopMusic(void); void S_PauseAudio(void); void S_ResumeAudio(void); +// +// Music Fading +// + +void S_SetInternalMusicVolume(INT32 volume); +void S_StopFadingMusic(void); +boolean S_FadeMusicFromVolume(UINT8 target_volume, INT16 source_volume, UINT32 ms); +#define S_FadeMusic(a, b) S_FadeMusicFromVolume(a, -1, b) +#define S_FadeInChangeMusic(a,b,c,d) S_ChangeMusicEx(a,b,c,0,0,d) +boolean S_FadeOutStopMusic(UINT32 ms); + // // Updates music & sounds // void S_UpdateSounds(void); +void S_UpdateClosedCaptions(void); FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2); diff --git a/src/screen.c b/src/screen.c index af6aed03c..7ebe34635 100644 --- a/src/screen.c +++ b/src/screen.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -28,6 +28,10 @@ #include "d_main.h" #include "d_clisrv.h" #include "f_finale.h" +#include "i_sound.h" // closed captions +#include "s_sound.h" // ditto +#include "g_game.h" // ditto +#include "p_local.h" // P_AutoPause() #if defined (USEASM) && !defined (NORUSEASM)//&& (!defined (_MSC_VER) || (_MSC_VER <= 1200)) @@ -37,41 +41,39 @@ // -------------------------------------------- // assembly or c drawer routines for 8bpp/16bpp // -------------------------------------------- -void (*wallcolfunc)(void); // new wall column drawer to draw posts >128 high -void (*colfunc)(void); // standard column, up to 128 high posts +void (*colfunc)(void); +void (*colfuncs[COLDRAWFUNC_MAX])(void); -void (*basecolfunc)(void); -void (*fuzzcolfunc)(void); // standard fuzzy effect column drawer -void (*transcolfunc)(void); // translation column drawer -void (*shadecolfunc)(void); // smokie test.. -void (*spanfunc)(void); // span drawer, use a 64x64 tile -void (*splatfunc)(void); // span drawer w/ transparency -void (*basespanfunc)(void); // default span func for color mode -void (*transtransfunc)(void); // translucent translated column drawer -void (*twosmultipatchfunc)(void); // for cols with transparent pixels -void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND translucency +void (*spanfunc)(void); +void (*spanfuncs[SPANDRAWFUNC_MAX])(void); +void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); // ------------------ // global video state // ------------------ viddef_t vid; INT32 setmodeneeded; //video mode change needed if > 0 (the mode number to set + 1) +UINT8 setrenderneeded = 0; static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"}, {24, "24 bits"}, {32, "32 bits"}, {0, NULL}}; //added : 03-02-98: default screen mode, as loaded/saved in config -#ifdef WII -consvar_t cv_scr_width = {"scr_width", "640", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scr_height = {"scr_height", "480", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static void SCR_ChangeFullscreen (void); +static void SCR_ActuallyChangeRenderer(void); +CV_PossibleValue_t cv_renderer_t[] = { + {1, "Software"}, +#ifdef HWRENDER + {2, "OpenGL"}, +#endif + {0, NULL} +}; +consvar_t cv_renderer = {"renderer", "Software", CV_SAVE|CV_NOLUA|CV_CALL, cv_renderer_t, SCR_ChangeRenderer, 0, NULL, NULL, 0, 0, NULL}; + +static void SCR_ChangeFullscreen(void); consvar_t cv_fullscreen = {"fullscreen", "Yes", CV_SAVE|CV_CALL, CV_YesNo, SCR_ChangeFullscreen, 0, NULL, NULL, 0, 0, NULL}; @@ -96,54 +98,79 @@ boolean R_3DNow = false; boolean R_MMXExt = false; boolean R_SSE2 = false; - -void SCR_SetMode(void) +void SCR_SetDrawFuncs(void) { - if (dedicated) - return; - - if (!setmodeneeded || WipeInAction) - return; // should never happen and don't change it during a wipe, BAD! - - VID_SetMode(--setmodeneeded); - - V_SetPalette(0); - // // setup the right draw routines for either 8bpp or 16bpp // if (true)//vid.bpp == 1) //Always run in 8bpp. todo: remove all 16bpp code? { - spanfunc = basespanfunc = R_DrawSpan_8; - splatfunc = R_DrawSplat_8; - transcolfunc = R_DrawTranslatedColumn_8; - transtransfunc = R_DrawTranslatedTranslucentColumn_8; + colfuncs[BASEDRAWFUNC] = R_DrawColumn_8; + spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8; + + colfunc = colfuncs[BASEDRAWFUNC]; + spanfunc = spanfuncs[BASEDRAWFUNC]; + + colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8; + colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_8; + colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8; + colfuncs[COLDRAWFUNC_SHADOWED] = R_DrawColumnShadowed_8; + colfuncs[COLDRAWFUNC_TRANSTRANS] = R_DrawTranslatedTranslucentColumn_8; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS] = R_Draw2sMultiPatchTranslucentColumn_8; + colfuncs[COLDRAWFUNC_FOG] = R_DrawFogColumn_8; + + spanfuncs[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_8; + spanfuncs[SPANDRAWFUNC_SPLAT] = R_DrawSplat_8; + spanfuncs[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_8; + spanfuncs[SPANDRAWFUNC_FOG] = R_DrawFogSpan_8; +#ifndef NOWATER + spanfuncs[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_8; +#endif +#ifdef ESLOPE + spanfuncs[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_8; + spanfuncs[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_8; +#ifndef NOWATER + spanfuncs[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_8; +#endif + spanfuncs[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_8; +#endif + + // Lactozilla: Non-powers-of-two + spanfuncs_npo2[BASEDRAWFUNC] = R_DrawSpan_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TRANS] = R_DrawTranslucentSpan_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_SPLAT] = R_DrawSplat_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TRANSSPLAT] = R_DrawTranslucentSplat_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed +#ifndef NOWATER + spanfuncs_npo2[SPANDRAWFUNC_WATER] = R_DrawTranslucentWaterSpan_NPO2_8; +#endif +#ifdef ESLOPE + spanfuncs_npo2[SPANDRAWFUNC_TILTED] = R_DrawTiltedSpan_NPO2_8; + spanfuncs_npo2[SPANDRAWFUNC_TILTEDTRANS] = R_DrawTiltedTranslucentSpan_NPO2_8; +#ifndef NOWATER + spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_NPO2_8; +#endif + spanfuncs_npo2[SPANDRAWFUNC_TILTEDSPLAT] = R_DrawTiltedSplat_NPO2_8; +#endif - colfunc = basecolfunc = R_DrawColumn_8; - shadecolfunc = R_DrawShadeColumn_8; - fuzzcolfunc = R_DrawTranslucentColumn_8; - walldrawerfunc = R_DrawWallColumn_8; - twosmultipatchfunc = R_Draw2sMultiPatchColumn_8; - twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8; #ifdef RUSEASM if (R_ASM) { if (R_MMX) { - colfunc = basecolfunc = R_DrawColumn_8_MMX; - //shadecolfunc = R_DrawShadeColumn_8_ASM; - //fuzzcolfunc = R_DrawTranslucentColumn_8_ASM; - walldrawerfunc = R_DrawWallColumn_8_MMX; - twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_MMX; - spanfunc = basespanfunc = R_DrawSpan_8_MMX; + colfuncs[BASEDRAWFUNC] = R_DrawColumn_8_MMX; + //colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM; + //colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_MMX; + spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8_MMX; } else { - colfunc = basecolfunc = R_DrawColumn_8_ASM; - //shadecolfunc = R_DrawShadeColumn_8_ASM; - //fuzzcolfunc = R_DrawTranslucentColumn_8_ASM; - walldrawerfunc = R_DrawWallColumn_8_ASM; - twosmultipatchfunc = R_Draw2sMultiPatchColumn_8_ASM; + colfuncs[BASEDRAWFUNC] = R_DrawColumn_8_ASM; + //colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM; + //colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM; + colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_ASM; } } #endif @@ -162,12 +189,41 @@ void SCR_SetMode(void) }*/ else I_Error("unknown bytes per pixel mode %d\n", vid.bpp); -/*#if !defined (DC) && !defined (WII) +/* if (SCR_IsAspectCorrect(vid.width, vid.height)) CONS_Alert(CONS_WARNING, M_GetText("Resolution is not aspect-correct!\nUse a multiple of %dx%d\n"), BASEVIDWIDTH, BASEVIDHEIGHT); -#endif*/ +*/ +} + +void SCR_SetMode(void) +{ + if (dedicated) + return; + + if (!(setmodeneeded || setrenderneeded) || WipeInAction) + return; // should never happen and don't change it during a wipe, BAD! + + // Lactozilla: Renderer switching + if (setrenderneeded) + { + Z_PreparePatchFlush(); + needpatchflush = true; + needpatchrecache = true; + VID_CheckRenderer(); + if (!setmodeneeded) + VID_SetMode(vid.modenum); + } + + if (setmodeneeded) + VID_SetMode(--setmodeneeded); + + V_SetPalette(0); + + SCR_SetDrawFuncs(); + // set the apprpriate drawer for the sky (tall or INT16) setmodeneeded = 0; + setrenderneeded = 0; } // do some initial settings for the game loading screen @@ -304,10 +360,13 @@ void SCR_Recalc(void) vid.fsmalldupy = vid.smalldupy*FRACUNIT; #endif - // toggle off automap because some screensize-dependent values will + // toggle off (then back on) the automap because some screensize-dependent values will // be calculated next time the automap is activated. if (automapactive) - AM_Stop(); + { + am_recalc = true; + AM_Start(); + } // set the screen[x] ptrs on the new vidbuffers V_Init(); @@ -355,6 +414,8 @@ void SCR_CheckDefaultMode(void) // see note above setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; } + + SCR_ActuallyChangeRenderer(); } // sets the modenum as the new default video mode to be saved in the config file @@ -384,6 +445,69 @@ void SCR_ChangeFullscreen(void) #endif } +static int target_renderer = 0; + +void SCR_ActuallyChangeRenderer(void) +{ + setrenderneeded = target_renderer; + +#ifdef HWRENDER + // Well, it didn't even load anyway. + if ((hwrenderloaded == -1) && (setrenderneeded == render_opengl)) + { + if (M_CheckParm("-nogl")) + CONS_Alert(CONS_ERROR, "OpenGL rendering was disabled!\n"); + else + CONS_Alert(CONS_ERROR, "OpenGL never loaded\n"); + setrenderneeded = 0; + return; + } +#endif + + // setting the same renderer twice WILL crash your game, so let's not, please + if (rendermode == setrenderneeded) + setrenderneeded = 0; +} + +// Lactozilla: Renderer switching +void SCR_ChangeRenderer(void) +{ + setrenderneeded = 0; + + if (con_startup) + { + target_renderer = cv_renderer.value; +#ifdef HWRENDER + if (M_CheckParm("-opengl") && (hwrenderloaded == 1)) + target_renderer = rendermode = render_opengl; + else +#endif + if (M_CheckParm("-software")) + target_renderer = rendermode = render_soft; + // set cv_renderer back + SCR_ChangeRendererCVars(rendermode); + return; + } + + if (cv_renderer.value == 1) + target_renderer = render_soft; + else if (cv_renderer.value == 2) + target_renderer = render_opengl; + SCR_ActuallyChangeRenderer(); +} + +void SCR_ChangeRendererCVars(INT32 mode) +{ + // set cv_renderer back + if (mode == render_soft) + CV_StealthSetValue(&cv_renderer, 1); + else if (mode == render_opengl) + CV_StealthSetValue(&cv_renderer, 2); +#ifdef HWRENDER + CV_StealthSetValue(&cv_newrenderer, cv_renderer.value); +#endif +} + boolean SCR_IsAspectCorrect(INT32 width, INT32 height) { return @@ -404,6 +528,7 @@ void SCR_DisplayTicRate(void) tic_t ontic = I_GetTime(); tic_t totaltics = 0; INT32 ticcntcolor = 0; + const INT32 h = vid.height-(8*vid.dupy); for (i = lasttic + 1; i < TICRATE+lasttic && i < ontic; ++i) fpsgraph[i % TICRATE] = false; @@ -417,10 +542,78 @@ void SCR_DisplayTicRate(void) if (totaltics <= TICRATE/2) ticcntcolor = V_REDMAP; else if (totaltics == TICRATE) ticcntcolor = V_GREENMAP; - V_DrawString(vid.width-(24*vid.dupx), vid.height-(16*vid.dupy), - V_YELLOWMAP|V_NOSCALESTART, "FPS"); - V_DrawString(vid.width-(40*vid.dupx), vid.height-( 8*vid.dupy), - ticcntcolor|V_NOSCALESTART, va("%02d/%02u", totaltics, TICRATE)); + V_DrawString(vid.width-(72*vid.dupx), h, + V_YELLOWMAP|V_NOSCALESTART|V_USERHUDTRANS, "FPS:"); + V_DrawString(vid.width-(40*vid.dupx), h, + ticcntcolor|V_NOSCALESTART|V_USERHUDTRANS, va("%02d/%02u", totaltics, TICRATE)); lasttic = ontic; } + +void SCR_DisplayLocalPing(void) +{ + UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P + if (cv_showping.value == 1 || (cv_showping.value == 2 && servermaxping && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level + { + INT32 dispy = cv_ticrate.value ? 180 : 189; + HU_drawPing(307, dispy, ping, true, V_SNAPTORIGHT | V_SNAPTOBOTTOM); + } +} + + +void SCR_ClosedCaptions(void) +{ + UINT8 i; + boolean gamestopped = (paused || P_AutoPause()); + INT32 basey = BASEVIDHEIGHT; + + if (gamestate != wipegamestate) + return; + + if (gamestate == GS_LEVEL) + { + if (promptactive) + basey -= 42; + else if (splitscreen) + basey -= 8; + else if ((modeattacking == ATTACKING_NIGHTS) + || (!(maptol & TOL_NIGHTS) + && ((cv_powerupdisplay.value == 2) // "Always" + || (cv_powerupdisplay.value == 1 && !camera.chase)))) // "First-person only" + basey -= 16; + } + + for (i = 0; i < NUMCAPTIONS; i++) + { + INT32 flags, y; + char dot; + boolean music; + + if (!closedcaptions[i].s) + continue; + + music = (closedcaptions[i].s-S_sfx == sfx_None); + + if (music && !gamestopped && (closedcaptions[i].t < flashingtics) && (closedcaptions[i].t & 1)) + continue; + + flags = V_SNAPTORIGHT|V_SNAPTOBOTTOM|V_ALLOWLOWERCASE; + y = basey-((i + 2)*10); + + if (closedcaptions[i].b) + y -= (closedcaptions[i].b--)*vid.dupy; + + if (closedcaptions[i].t < CAPTIONFADETICS) + flags |= (((CAPTIONFADETICS-closedcaptions[i].t)/2)*V_10TRANS); + + if (music) + dot = '\x19'; + else if (closedcaptions[i].c && closedcaptions[i].c->origin) + dot = '\x1E'; + else + dot = ' '; + + V_DrawRightAlignedString(BASEVIDWIDTH - 20, y, flags, + va("%c [%s]", dot, (closedcaptions[i].s->caption[0] ? closedcaptions[i].s->caption : closedcaptions[i].s->name))); + } +} diff --git a/src/screen.h b/src/screen.h index 9ad254d3f..717ce9adc 100644 --- a/src/screen.h +++ b/src/screen.h @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,20 +15,16 @@ #include "command.h" -#if (defined (_WIN32) || defined (_WIN32_WCE)) && !defined (__CYGWIN__) && !defined (_XBOX) -#if defined (_WIN32_WCE) && defined (__GNUC__) -#include -#else +#if defined (_WIN32) && !defined (__CYGWIN__) #define RPC_NO_WINDOWS_H #include -#endif #define DNWH HWND #else #define DNWH void * // unused in DOS version #endif // quickhack for V_Init()... to be cleaned up -#if defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined (NOPOSTPROCESSING) +#ifdef NOPOSTPROCESSING #define NUMSCREENS 2 #else #define NUMSCREENS 5 @@ -43,19 +39,8 @@ // we try to re-allocate a minimum of buffers for stability of the memory, // so all the small-enough tables based on screen size, are allocated once // and for all at the maximum size. -#if defined (_WIN32_WCE) || defined (DC) || defined (_PSP) || defined (_NDS) -#define MAXVIDWIDTH 320 -#define MAXVIDHEIGHT 200 -#elif defined (GP2X) -#define MAXVIDWIDTH 320 //720 -#define MAXVIDHEIGHT 240 //576 -#elif defined (WII) // Wii, VGA/640x480 -#define MAXVIDWIDTH 640 -#define MAXVIDHEIGHT 480 -#else #define MAXVIDWIDTH 1920 // don't set this too high because actually #define MAXVIDHEIGHT 1200 // lots of tables are allocated with the MAX size. -#endif #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original #define BASEVIDHEIGHT 200 // resolution of the graphics. @@ -110,7 +95,7 @@ typedef struct vmode_s INT32 windowed; // if true this is a windowed mode INT32 numpages; vesa_extra_t *pextradata; // vesa mode extra data -#if defined (_WIN32) && !defined (_XBOX) +#ifdef _WIN32 INT32 (WINAPI *setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); #else INT32 (*setmode)(viddef_t *lvid, struct vmode_s *pcurrentmode); @@ -125,18 +110,51 @@ extern vmode_t specialmodes[NUMSPECIALMODES]; // color mode dependent drawer function pointers // --------------------------------------------- -extern void (*wallcolfunc)(void); +#define BASEDRAWFUNC 0 + +enum +{ + COLDRAWFUNC_BASE = BASEDRAWFUNC, + COLDRAWFUNC_FUZZY, + COLDRAWFUNC_TRANS, + COLDRAWFUNC_SHADE, + COLDRAWFUNC_SHADOWED, + COLDRAWFUNC_TRANSTRANS, + COLDRAWFUNC_TWOSMULTIPATCH, + COLDRAWFUNC_TWOSMULTIPATCHTRANS, + COLDRAWFUNC_FOG, + + COLDRAWFUNC_MAX +}; + extern void (*colfunc)(void); -extern void (*basecolfunc)(void); -extern void (*fuzzcolfunc)(void); -extern void (*transcolfunc)(void); -extern void (*shadecolfunc)(void); +extern void (*colfuncs[COLDRAWFUNC_MAX])(void); + +enum +{ + SPANDRAWFUNC_BASE = BASEDRAWFUNC, + SPANDRAWFUNC_TRANS, + SPANDRAWFUNC_SPLAT, + SPANDRAWFUNC_TRANSSPLAT, + SPANDRAWFUNC_FOG, +#ifndef NOWATER + SPANDRAWFUNC_WATER, +#endif +#ifdef ESLOPE + SPANDRAWFUNC_TILTED, + SPANDRAWFUNC_TILTEDTRANS, + SPANDRAWFUNC_TILTEDSPLAT, +#ifndef NOWATER + SPANDRAWFUNC_TILTEDWATER, +#endif +#endif + + SPANDRAWFUNC_MAX +}; + extern void (*spanfunc)(void); -extern void (*basespanfunc)(void); -extern void (*splatfunc)(void); -extern void (*transtransfunc)(void); -extern void (*twosmultipatchfunc)(void); -extern void (*twosmultipatchtransfunc)(void); +extern void (*spanfuncs[SPANDRAWFUNC_MAX])(void); +extern void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); // ----- // CPUID @@ -152,21 +170,29 @@ extern boolean R_SSE2; // ---------------- // screen variables // ---------------- + extern viddef_t vid; extern INT32 setmodeneeded; // mode number to set if needed, or 0 +void SCR_ChangeRenderer(void); +void SCR_ChangeRendererCVars(INT32 mode); +extern UINT8 setrenderneeded; + extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders -extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_fullscreen; +extern CV_PossibleValue_t cv_renderer_t[]; + +extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_renderer, cv_fullscreen; +#ifdef HWRENDER +extern consvar_t cv_newrenderer; +#endif // wait for page flipping to end or not extern consvar_t cv_vidwait; -// quick fix for tall/short skies, depending on bytesperpixel -extern void (*walldrawerfunc)(void); - // Change video mode, only at the start of a refresh. void SCR_SetMode(void); +void SCR_SetDrawFuncs(void); // Recalc screen size dependent stuff void SCR_Recalc(void); // Check parms once at startup @@ -180,5 +206,7 @@ FUNCMATH boolean SCR_IsAspectCorrect(INT32 width, INT32 height); // move out to main code for consistency void SCR_DisplayTicRate(void); +void SCR_ClosedCaptions(void); +void SCR_DisplayLocalPing(void); #undef DNWH #endif //__SCREEN_H__ diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 7f8f052ba..38d557a3f 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -140,7 +140,13 @@ if(${SDL2_FOUND}) endif() add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES}) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME ${SRB2_SDL2_EXE_NAME}) + if(${CMAKE_SYSTEM} MATCHES Windows) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2win) + elseif(${CMAKE_SYSTEM} MATCHES Linux) + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME lsdlsrb2) + else() + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2) + endif() if(${CMAKE_SYSTEM} MATCHES Darwin) find_library(CORE_LIB CoreFoundation) @@ -149,16 +155,18 @@ if(${SDL2_FOUND}) SDL2 SDL2_mixer ${GME_LIBRARIES} + ${OPENMPT_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${OPENGL_LIBRARIES} ) - set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "Sonic Robo Blast 2") + set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") else() target_link_libraries(SRB2SDL2 PRIVATE ${SDL2_LIBRARIES} ${SDL2_MIXER_LIBRARIES} ${GME_LIBRARIES} + ${OPENMPT_LIBRARIES} ${PNG_LIBRARIES} ${ZLIB_LIBRARIES} ${OPENGL_LIBRARIES} @@ -238,6 +246,7 @@ if(${SDL2_FOUND}) ${SDL2_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS} ${GME_INCLUDE_DIRS} + ${OPENMPT_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIRS} @@ -284,12 +293,14 @@ if(${SDL2_FOUND}) HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/x86_64-w64-mingw32/bin + HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw ) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/bin HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/i686-w64-mingw32/bin + HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw ) endif() else() @@ -298,12 +309,14 @@ if(${SDL2_FOUND}) HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/x86_64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x64 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x64 + HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86_64/mingw ) else() find_library(SRB2_SDL2_DLL_${dllname} "${defaultname}" HINTS ${CMAKE_SOURCE_DIR}/libs/dll-binaries/i686 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2/lib/x86 HINTS ${CMAKE_SOURCE_DIR}/libs/SDL2_mixer/lib/x86 + HINTS ${CMAKE_SOURCE_DIR}/libs/libopenmpt/bin/x86/mingw ) endif() endif() @@ -324,6 +337,9 @@ if(${SDL2_FOUND}) if(${SRB2_CONFIG_HAVE_GME}) getwinlib(libgme "libgme.dll") endif() + if(${SRB2_CONFIG_HAVE_OPENMPT}) + getwinlib(libopenmpt "libopenmpt.dll") + endif() install(PROGRAMS ${win_extra_dll_list} @@ -337,10 +353,19 @@ if(${SDL2_FOUND}) # Mac bundle fixup + # HACK: THIS IS IMPORTANT! See the escaped \${CMAKE_INSTALL_PREFIX}? This + # makes it so that var is evaluated LATER during cpack, not right now! + # This fixes the quirk where the bundled libraries don't land in the final package + # https://cmake.org/pipermail/cmake/2011-March/043532.html + # + # HOWEVER: ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} is NOT escaped, because that var + # is only available to us at this step. Read the link: ${CMAKE_INSTALL_PREFIX} at + # this current step points to the CMAKE build folder, NOT the folder that CPACK uses. + # Therefore, it makes sense to escape that var, but not the other. if(${CMAKE_SYSTEM} MATCHES Darwin) install(CODE " include(BundleUtilities) - fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/Sonic Robo Blast 2.app\" + fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${CPACK_PACKAGE_DESCRIPTION_SUMMARY}.app\" \"\" /Library/Frameworks )" diff --git a/src/sdl/IMG_xpm.c b/src/sdl/IMG_xpm.c index af76ec1dd..458131620 100644 --- a/src/sdl/IMG_xpm.c +++ b/src/sdl/IMG_xpm.c @@ -1,6 +1,6 @@ /* SDL_image: An example image loading library for use with SDL - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2019 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -34,7 +34,7 @@ * * Besides the standard API, also provides * - * SDL_Surface *IMG_ReadXPMFromArray(char **xpm) + * SDL_Surface *IMG_ReadXPMFromArray(const char **xpm) * * that reads the image data from an XPM file included in the C source. * @@ -88,8 +88,8 @@ struct color_hash { struct hash_entry **table; struct hash_entry *entries; /* array of all entries */ struct hash_entry *next_free; - int size; - int maxnum; + size_t size; + size_t maxnum; }; static int hash_key(const char *key, int cpp, int size) @@ -103,14 +103,14 @@ static int hash_key(const char *key, int cpp, int size) return hash & (size - 1); } -static struct color_hash *create_colorhash(int maxnum) +static struct color_hash *create_colorhash(size_t maxnum) { - int bytes, s; + size_t bytes, s; struct color_hash *hash; /* we know how many entries we need, so we can allocate everything here */ - hash = (struct color_hash *)SDL_malloc(sizeof *hash); + hash = (struct color_hash *)SDL_calloc(1, sizeof(*hash)); if (!hash) return NULL; @@ -119,15 +119,29 @@ static struct color_hash *create_colorhash(int maxnum) ; hash->size = s; hash->maxnum = maxnum; + bytes = hash->size * sizeof(struct hash_entry **); - hash->entries = NULL; /* in case malloc fails */ - hash->table = (struct hash_entry **)SDL_malloc(bytes); + /* Check for overflow */ + if ((bytes / sizeof(struct hash_entry **)) != hash->size) { + IMG_SetError("memory allocation overflow"); + SDL_free(hash); + return NULL; + } + hash->table = (struct hash_entry **)SDL_calloc(1, bytes); if (!hash->table) { SDL_free(hash); return NULL; } - SDL_memset(hash->table, 0, bytes); - hash->entries = (struct hash_entry *)SDL_malloc(maxnum * sizeof(struct hash_entry)); + + bytes = maxnum * sizeof(struct hash_entry); + /* Check for overflow */ + if ((bytes / sizeof(struct hash_entry)) != maxnum) { + IMG_SetError("memory allocation overflow"); + SDL_free(hash->table); + SDL_free(hash); + return NULL; + } + hash->entries = (struct hash_entry *)SDL_calloc(1, bytes); if (!hash->entries) { SDL_free(hash->table); SDL_free(hash); @@ -138,7 +152,7 @@ static struct color_hash *create_colorhash(int maxnum) } static int add_colorhash(struct color_hash *hash, - char *key, int cpp, Uint32 color) + const char *key, int cpp, Uint32 color) { int index = hash_key(key, cpp, hash->size); struct hash_entry *e = hash->next_free++; @@ -995,10 +1009,11 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src) { Sint64 start = 0; SDL_Surface *image = NULL; - int index; + size_t index; int x, y; - int w, h, ncolors, cpp; - int indexed; + int w, h, cpp; + long unsigned int ncolors; + size_t indexed; Uint8 *dst; struct color_hash *colors = NULL; SDL_Color *im_colors = NULL; @@ -1029,12 +1044,17 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src) * Right now we don't use the hotspots but it should be handled * one day. */ - if (SDL_sscanf(line, "%d %d %d %d", &w, &h, &ncolors, &cpp) != 4 + if (SDL_sscanf(line, "%d %d %lu %d", &w, &h, &ncolors, &cpp) != 4 || w <= 0 || h <= 0 || ncolors <= 0 || cpp <= 0) { error = "Invalid format description"; goto done; } + /* Check for allocation overflow */ + if ((size_t)(ncolors * cpp)/cpp != ncolors) { + error = "Invalid color specification"; + goto done; + } keystrings = (char *)SDL_malloc(ncolors * cpp); if (!keystrings) { error = "Out of memory"; @@ -1102,8 +1122,9 @@ static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src) c->g = (Uint8)(rgb >> 8); c->b = (Uint8)(rgb); pixel = index; - } else + } else { pixel = rgb; + } add_colorhash(colors, nextkey, cpp, pixel); nextkey += cpp; if (rgb == 0xffffffff) @@ -1192,7 +1213,7 @@ SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) return(NULL); } -SDL_Surface *IMG_ReadXPMFromArray(char **xpm) +SDL_Surface *IMG_ReadXPMFromArray(const char **xpm) { return NULL; } diff --git a/src/sdl/Makefile.cfg b/src/sdl/Makefile.cfg index 58c4d0861..05b60f7a3 100644 --- a/src/sdl/Makefile.cfg +++ b/src/sdl/Makefile.cfg @@ -80,8 +80,13 @@ ifdef NOMIXER else i_sound_o=$(OBJDIR)/mixer_sound.o OPTS+=-DHAVE_MIXER +ifdef HAVE_MIXERX + OPTS+=-DHAVE_MIXERX + SDL_LDFLAGS+=-lSDL2_mixer_ext +else SDL_LDFLAGS+=-lSDL2_mixer endif +endif ifdef SDL_TTF OPTS+=-DHAVE_TTF diff --git a/src/sdl/SDL_icon.xpm b/src/sdl/SDL_icon.xpm index 1d0f9d314..2180d782c 100644 --- a/src/sdl/SDL_icon.xpm +++ b/src/sdl/SDL_icon.xpm @@ -1,163 +1,99 @@ /* XPM */ -const char * SDL_icon_xpm[] = { -"96 96 64 1", +static const char *SDL_icon_xpm[] = { +"64 64 32 1", " c None", -". c #040656", -"+ c #0100B2", -"@ c #04056E", -"# c #0000BD", -"$ c #0B0C09", -"% c #0B0D26", -"& c #090C42", -"* c #060AA7", -"= c #1604DA", -"- c #020CD5", -"; c #100F8D", -"> c #040DE4", -", c #11129B", -"' c #1D1A83", -") c #2A10FD", -"! c #1318FA", -"~ c #25225B", -"{ c #252271", -"] c #312E2B", -"^ c #33334D", -"/ c #363775", -"( c #3D3B69", -"_ c #3A3B8B", -": c #373AFF", -"< c #4142AA", -"[ c #4B4864", -"} c #4D4B4A", -"| c #60492F", -"1 c #4F4C57", -"2 c #4A4A9E", -"3 c #4F4E85", -"4 c #474ADE", -"5 c #4E4FFE", -"6 c #5D5CB3", -"7 c #686663", -"8 c #666682", -"9 c #676875", -"0 c #66659E", -"a c #8B6538", -"b c #6465D5", -"c c #7F694F", -"d c #6767FF", -"e c #7272FF", -"f c #91795C", -"g c #7677FD", -"h c #828396", -"i c #A78153", -"j c #888989", -"k c #8D897E", -"l c #9190FD", -"m c #CA9048", -"n c #C09968", -"o c #A9A8A1", -"p c #A6A8B0", -"q c #B0B1FB", -"r c #EEAC61", -"s c #E3B478", -"t c #C3C4BE", -"u c #FFC68C", -"v c #FCCD90", -"w c #D4D7D3", -"x c #E3E5E0", -"y c #FCFFFB", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ", -" ttj7777777joot ", -" 9hh8830000088hh9 ", -" 9888(//__-*{^kt ", -" &,5b60^ (02*{} ", -" tp,-)!5egb3} ~_<4dgggeeeeeeeeeeeeeegb6/_2[amusf'#!<_'>))))))))))))!)>+{~ ", -" p;-))!5gb2^^'#5eggeeeeeeeeeeeeeeegg6/_23amrusi{#!+;;>))))))))))))))!!-'8p ", -" tp'#!)):d6(@*>5egeeeeeeeeeeeeeeeegg6_/<(amrrvvn{+)-,;>))))))!!!!!!)))!!>,~j ", -" p;#!))-'{'+-5eggeeeeeeeeeeeeeeeegb222(cmrruvvn{+)>,@>!)!!)!!>>>>======>-,/8 ", -" ;#)!-*.;-!5eggeeeeeeeeeeeeeeeegb2_<6|mrrsvvvn{+)!,.-!!!!>>=--######+++-#@(k ", -" h@-)+@.*>!5egeeeeeeeeeeeeeeeeeegb_>--###++++++###+;@{(9j ", -" kh,#+@@,>!:dggeeeeeeeeeeeeeeeeeeebbb_]mrruuvvsf'#)!*.+-###+++++++##+*;'3(&^9 ", -" 8*,@@*)):dggeeeeeeeeeeeeeeeeeeeeggg<(|iruvvvsc,=!!*.;*++++++++###+,@&1o ", -" 8@@@-!)!5eeeeeeeeeeeeeeeeeeeeeeeeeggb2[csvvvn^#)!!+@;*#+++++###*@~[ ", -" 9&@*!)):5geeeeeeeeeeeeeeeeeeeeeeeeegge637nsvf{>))!+;;*-######*;{.^ ", -" 9%;!!)):dgeeeeeeeeeeeeeeeeeeeeeeeeeeeggb_1ir7;>))!+;;,++++++*'(} ", -" 9{+!))!5egeeeeeeeeeeeeeeeeeddddeeeeeeeege2}|~#!))!#;@...@@@.^hp ", -" 8,=!))):dggeeeeeeeeeeeeeeeeggggeeeeeeeeggb_~,>!))!+@@@;;;;@&^o ", -" }(-)))))!:eegeeeeeeeeeeeeeegllllgeeeeeeeegd5+=))))!+;,#>--#,'/hj ", -" o8.>))))))!:dgggeeeeeeeeeeellqqqqlgeeeeggg5:!!!)))))-*+>)!:55db631 ", -" p8<*!)))))))!:5deggggggeeeegqqqqqqqqlggged5:!))))))))>->!!:5ddeegb3/ ", -" oh'#!))))))))))!:ddeeeeeeeeglqqqqqqqqlgedd:!)))))))))))))!:dggggeggg239 ", -" ^*>!))!)))))))))!::55dddeegglll600333_4:!!)))))))))))))):dggeeeeeeggb6(9o ", -" ~+=-+#>))))))))))!!!:::::5554<3889988[/,=)))))))))))))):5gggeeeeeeeggb6087 ", -" ~**@~'+>!))))))))))))))))!!>*{1kkooook7(,-!)))))))))))!:5deeeeeeeeeeeggb289 ", -" ~,'1o7(*>!))))))))))))))))=,[jtttwxxxwto^;>!))))))))))!!!::5deggeeeeeeegbb3] ", -" ~@/oxt7'#))))))))))))))))=,3ktwxxyyyyyyxk/+!))))))))))))))!:::5degggeeegggb3^ ", -" ^&8xyyt^,)))))))))))))))>,3otwxyyyyyyyyyxh'>)))))))))))))))))):5ddeeeeeeeggb3^ ", -" 771pyyyx7'=!)))))))))))!!#(jtxxyyyyyyyyyyyt3-)))))))))))))))))))!!::degggeeegb2[o ", -" 77tyyyxk/+!!)))))))))))-;9owxyyyyyyyyyyyywh*>)))))))))))))))))))))!::5ddgggggb68j ", -" owyyyyt8;>))))))))))))*(otwyyyyyyyyyyyyyxp'-)))))))))))))))))))))))!!:5deeeggg_8j ", -" jtxyyyyxh'>)))))))))!!#_ktxyyyyyyyyyyyyyyyt_+))))))))))))))))))))))))))!!:5deggg63j ", -" 7jwyyyyyyp/=))))))))))>,3owxyyyyyyyyyyyyyyyw/+))))))))))))))))))))))))))))!::5degb689 ", -" 7xyyyyyyo[#))))))))))-/jtwyyyyyyyyyyyyyyyyw/*)))))))))))))))))))))))))))))))!:5dgg_/ ", -" }xyyyyyyt9*=))))))))=*9owyyyyyyyyyyyyyyyyyw/*)))))))))))))))))))))))))))))))))!!:5d3} ", -" }xyyyyyywj'#!))))))!#@7oxyyyyyyyyyyyyyyyyyw/*)))))))))))))))))))))))))))))))))))!!:4/7 ", -" 7xyyyyyyxj&,!!))))!!,%}oyyyyyyyyyyyyyyyyyyw/*))))))))))))))))))))))))))))))))))))))>487 ", -" 7xyyyyyywk$@!!)))!!-.$]oyyyyyyyyyyyyyyyyyyw/+))))))))))))))))))))))))))))))!!!!))))!>' ", -" }xyyyyyywj$&+!!)!)>;%$]jyyyyyyyyyyyyyyyyyyt{#)))))))))))))))))))))!!!!!!))!)!!!!!!))!#' ", -" 7xyyyyyyt7$%@-!)!>*[]$$jyyyyyyyyyyyyyyyyyxp;-))))))))))))))))))!!!!!!!!!!!!>>>>>>>>>>!,^ ", -" 7xyyyyyyt}$][;-)=,(o7$$7yyyyyyyyyyyyyyyyyxp,-)))))))))))!!!!)!!!!>>>>=-----########--=+'9 ", -" jwyyyyyyo}$}o(';@~7wj$$7yyyyyyyyyyyyyyyyywh*>)))))))))))!>>>=>=---#####+########+++***;@17 ", -" otxyyyyyt}$7t7}1}7kw7$$7yyyyyyyyyyyyyyyyyt0-)))))))))!!!>--####+++++++++++++##+***,;''.&] ", -" ooowyyyyyt}$}j7owwojo}$$jyyyyyyyyyyyyyyyyyp2>)))))))!!!=##++++++++++++++###+*;@.~[8[9hph ", -" ojtyyyyywj$$}jwyyxo}$$]jyyyyyyyyyyyyyyyyyp'>))))))!>>-#++++++++++++####+,;'_3/&^}77kot ", -" 7tyyyyyxo]$$oxyyyt]$$}tyyyyyyyyyyyyyyyyx0*!)))!!!>-#++++++++++++#+##+*;.&1ko ", -" 7tyyyyyyx7]}xyyyyxj}]oxyyyyyyyyyyyyyyyyp<=)!!!!>-#++++++++++++####*;.(8h ", -" owxyxxyytooywptwwtppxyyyyyyyyyyyyyyyxp3,-=!)!>-#++++++++++###+*,'_{&1k ", -" jtwwttwtwwtj7kjowxyyyyyyyyyyyyyyyyxt7~'',+>=#+++++++++++###*;@&^j ", -" ]joojj7}]}]|innfc7jtwyyyyyyyyyyyxtjcfnnnf[@*#+++++++++###+@.&%% ", -" ]$}77}}$$$$]fsssnnifkkotwwwwwwwtpjkfinvvvsi}@*#++++++###*;@.@@&[ ", -" o7$]]]]]$$]|isvvvvvusifckopppopok7cisvvvvvvvn(,#++++++#+*@.&@*#;3o ", -" }}$]|||fnnsvvvuvvvuuvvsniffffffnnsvvvvuuuvvvc{*+#++##*@&.@*+#--<7 ", -" }]cninsuvvvvuuuuuuvvvvusnnnnnssuvvvvvuuuuvvc~*+#+++*@.@;*##=>>,^ ", -" 7fvvvvvvuuuuuuuuuuuuvvvvvvvvvvvuuuuuuuuuvvc~*+#+#+,.@*###->!!*~ ", -" pkivvvvuuuuuuuuuuuuuuuvvvvvvvvuuuvsnsuuuvvf~*+#++++*+++->!!)!#. ", -" kfsuvvuuuuuuuuuuuuuuuuuuuuuuuuuvvnfsuvuvvc{++#++++###->!!))!-;h ", -" kisvvvuuuuuuuuuuuuuuuuuuuuuuuvvvicsvvvvs1@##+++++++#>!!))))=,ho ", -" 7imuvvvuuuuuuuuuuuuuuuuuuuuvusfcivvuvvn~;##+++++++#>!!))))!#8k ", -" cimruuuuuvuuuuuuuuuuuuuuuuvsnfisuvvvsc@*#+++++++++#>!!))))-3} ", -" 7amrruuuuuuuuuuuuuuuuuuuuvsnnsvvuvvi^,##++++++++++#>!!)))>/^ ", -" kfamrruuuuvvvuuuuuuuuuuuuuvvvvvvvn1@+#++++++++++++#>!)))>{~ ", -" 7|iimrrruuuuuuuuuuuuuuuuvvvvuusn1'+#########++++++->!))>; ", -" 7cammrrrrruuuuuuvvvvvuuuuurrm|.*-#+#######+###+++->!!!*' ", -" ookcaimmrrrrrruuuuurrrrrmi|]%.@@@@@;,*,*+########->!!*6o ", -" p7}|ainiimmmmmmmmmmminnia|$%.....{3322_{''',,**+#=!!#6k ", -" j7||aaiiiiiaa||7j ookok711^&.';,*+=!>> c #2325EC", +", c #3C3883", +"' c #3D3A9E", +") c #5B5170", +"! c #4B4CFF", +"~ c #795339", +"{ c #5E5B5C", +"] c #5F5ED3", +"^ c #5E5EFB", +"/ c #7271FF", +"( c #B37F5D", +"_ c #8F8883", +": c #8887FF", +"< c #D59E76", +"[ c #ABABA9", +"} c #A9AAFF", +"| c #C1C3C1", +"1 c #FAC296", +"2 c #D4D6D3", +"3 c #F9FCF8", +" ", +" ", +" #***,,,**** ", +" *,,]]]]]]]]]]]]]',,** ", +" *,']//////////////////]]',* ", +" *,']/////////////////////////]'% ", +" *,]////////////////////^^!!>>>>>>>$+ ", +" *,]////////////////////!>---------->=@% ", +" * ,]///////////////////]^>------->==@@@$.# ", +" +', *']//////////////////],,,=---->=@@@@@$.% ", +" #.=^'* ,]//////////////////],']^]$--=@@@@@@@$+# ", +" %$=-^'* ,]/////////////////],]/!>-^'=@@@@@@@$.% ", +" +$=->/,*,//////////////////]'/^!,$-!,$@@@@@@$+* ", +" +@=--!''/////////////////]']^!,(()->%$@@@@@$+# ", +" +@=--='/////////////////]']^${(<<)->,$@@@@$% ", +" +@=->']/////////:::////]]/^'(<111)->,$@@@$% ", +" #+@@>$]////////::}}}://///!,(<1111)--%$@@.% ", +" #+@@$$^////////:}}}}}://^>$(<<1111)--+$@.% ", +" +@$.>^///////:}}}}}}:/^>->,(<111<'--+$$*# ", +" +$.=-!///////:}}}}}:^!-----@(111<@--+$,'],,* ", +" %+%=->^///////:}}}:!--------@(11(=--$=^////],* ", +" ,]]'>->^//////^^!!-----------'<1_>--@-!//////]'* ", +" '!->@--->>>>>>--->===>--------)<,-->@->^///////]', ", +" *$--->----------='){__{'>------>'=--=@-->!^///////],* ", +" %$.=---------->$)[22332[)=----------=>----->^^//////], ", +" %$_,--------->'_|3333333['----------=--------->!^////],# ", +" *'[{=--------'_2333333333_=---------------------->!^///,* ", +" #)[_@-------@_|33333333332,------------------------->!^/'* ", +" #)2[$------=)|333332|23333{>--------------------------->^'* ", +" {2|,------$[233333___3333_=----------------------------->$ ", +" ;22)=---->)|333332{2_2333[@-------------------------------$ ", +" &22{@----$_233333|{2||333|'--------------------------------$ ", +" &|3_.----,|333333[;2|[333|'--------------------------------=+ ", +" [3_%=--={2333333[&___333|'-------------------->>>====>>----@ ", +" _3[#$=@.[2333333[&&&_333[$------------->>==@@@@@@@@@@@@@@@==+", +" {3|;+$$)|3333333[&&&[333_=-------->==@@@@@@@@@@@@@@@$$$$.+++%", +" {23{*$${23333333|;&&|332)>----->=@@@@@@@@@@@@@@$$$.++%** ", +";{{;[3{&*)[333333333{&&|332,=---==@@@@@@@@@@@@$$.++%* ", +"{22_{|[;_|2333333333_&;233_$@@@@@@@@@@@@@@@@$$+%* ", +"&_|2{;{{[233333333332_[33[,$@@@@@@@@@@@@@$$+%# ", +" &;{&&&;~(_|3333333333332)$@@@@@@@@@@@@$.+%# ", +" &&&&&;(11([33333333332{$@@@@@@@@@@@$...$@$* ", +" &~((1111<[333333332{%.$@@@@@@@@@$$$$@=--$ ", +" ~<<11111<[33333|[_(<~,$@@@@@@@@@@@@@>-->. ", +" ;(<111111<(____(11111(+@@@@@@@@@@@@=----=% ", +" ~(<11111111<11111<(<<;$@@$$@@@@@@@=-----. ", +" ~(<1111111111111(~<1{$$$.$@@@@@@@=-----= ", +" ~(<1111111<<(((<11<*$+.$@@@@@@@@@>---->+ ", +" ;(<1111111<<1111<~%+$@@@@@@@@@@@=-----$ ", +" ~(<<111111111(~&*+$$$@@@@@@@@@@=----=% ", +" ;~((<<<<(~~; *%+$$@@@@@@@@@>----+ ", +" ;;; #%+$$@@@@@@@----. ", +" *+$$@@@@@=---@ ", +" *+$@@@@@>--= ", +" *.$@@@@-->% ", +" #%.$@@=->+ ", +" *+$@@>-$ ", +" %$@=-$ ", +" %.@>@ ", +" +=@ ", +" .. ", +" * ", +" ", +" "}; diff --git a/src/sdl/Srb2SDL-vc10.vcxproj b/src/sdl/Srb2SDL-vc10.vcxproj index e43772179..7e260f4c0 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj +++ b/src/sdl/Srb2SDL-vc10.vcxproj @@ -93,6 +93,8 @@ + + @@ -227,6 +229,10 @@ + + + + @@ -275,7 +281,10 @@ + + + @@ -365,8 +374,12 @@ + + + + @@ -426,9 +439,15 @@ true + + true + + + + @@ -478,4 +497,4 @@ - \ No newline at end of file + diff --git a/src/sdl/Srb2SDL-vc10.vcxproj.filters b/src/sdl/Srb2SDL-vc10.vcxproj.filters index d67ac6308..21820551a 100644 --- a/src/sdl/Srb2SDL-vc10.vcxproj.filters +++ b/src/sdl/Srb2SDL-vc10.vcxproj.filters @@ -246,6 +246,18 @@ Hw_Hardware + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + I_Interface @@ -405,6 +417,9 @@ R_Rend + + R_Rend + R_Rend @@ -450,6 +465,15 @@ SDLApp + + Hw_Hardware + + + R_Rend + + + R_Rend + @@ -624,9 +648,21 @@ Hw_Hardware + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + Hw_Hardware + + Hw_Hardware + I_Interface @@ -804,6 +840,9 @@ R_Rend + + R_Rend + R_Rend @@ -813,6 +852,9 @@ R_Rend + + R_Rend + R_Rend @@ -888,10 +930,20 @@ SDLApp + + Hw_Hardware + + + + R_Rend + + + R_Rend + SDLApp - \ No newline at end of file + diff --git a/src/sdl/Srb2SDL-vc9.vcproj b/src/sdl/Srb2SDL-vc9.vcproj index 3898aeba4..9ef4301cc 100644 --- a/src/sdl/Srb2SDL-vc9.vcproj +++ b/src/sdl/Srb2SDL-vc9.vcproj @@ -50,7 +50,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -145,7 +145,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="_DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="1" @@ -248,7 +248,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="true" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" StringPooling="true" RuntimeLibrary="0" PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch" @@ -350,7 +350,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="true" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" StringPooling="true" RuntimeLibrary="0" PrecompiledHeaderFile=".\..\..\objs\VC9\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch" diff --git a/src/sdl/Srb2SDL.ico b/src/sdl/Srb2SDL.ico index 700276fd4..3b37433db 100644 Binary files a/src/sdl/Srb2SDL.ico and b/src/sdl/Srb2SDL.ico differ diff --git a/src/sdl/Srb2SDL.props b/src/sdl/Srb2SDL.props index 260f81eed..17b41bddc 100644 --- a/src/sdl/Srb2SDL.props +++ b/src/sdl/Srb2SDL.props @@ -5,7 +5,10 @@ - USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) + + HAVE_ZLIB;HAVE_LIBGME;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_OPENMPT;SDLMAIN;%(PreprocessorDefinitions) + + USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;SDLMAIN;%(PreprocessorDefinitions) diff --git a/src/sdl/hwsym_sdl.c b/src/sdl/hwsym_sdl.c index 05ac6450e..5f040023a 100644 --- a/src/sdl/hwsym_sdl.c +++ b/src/sdl/hwsym_sdl.c @@ -79,6 +79,7 @@ void *hwSym(const char *funcName,void *handle) GETFUNC(Init); GETFUNC(Draw2DLine); GETFUNC(DrawPolygon); + GETFUNC(RenderSkyDome); GETFUNC(SetBlend); GETFUNC(ClearBuffer); GETFUNC(SetTexture); @@ -87,13 +88,11 @@ void *hwSym(const char *funcName,void *handle) GETFUNC(ClearMipMapCache); GETFUNC(SetSpecialState); GETFUNC(GetTextureUsed); - GETFUNC(DrawMD2); - GETFUNC(DrawMD2i); + GETFUNC(DrawModel); + GETFUNC(CreateModelVBOs); GETFUNC(SetTransform); GETFUNC(GetRenderVersion); -#ifdef SHUFFLE GETFUNC(PostImgRedraw); -#endif //SHUFFLE GETFUNC(FlushScreenTextures); GETFUNC(StartScreenWipe); GETFUNC(EndScreenWipe); diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index f54f0d7c5..5d0009927 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -20,12 +20,19 @@ #include "../doomdef.h" #include "../m_argv.h" #include "../d_main.h" +#include "../m_misc.h"/* path shit */ #include "../i_system.h" -#ifdef __GNUC__ +#if defined (__GNUC__) || defined (__unix__) #include #endif +#ifdef __unix__ +#include +#endif + +#include "time.h" // For log timestamps + #ifdef HAVE_SDL #ifdef HAVE_TTF @@ -45,6 +52,7 @@ extern int SDL_main(int argc, char *argv[]); #ifdef LOGMESSAGES FILE *logstream = NULL; +char logfilename[1024]; #endif #ifndef DOXYGEN @@ -125,16 +133,91 @@ int main(int argc, char **argv) #endif #endif - logdir = D_Home(); - #ifdef LOGMESSAGES + if (!M_CheckParm("-nolog")) + { + time_t my_time; + struct tm * timeinfo; + const char *format; + const char *reldir; + int left; + boolean fileabs; +#ifdef __unix__ + const char *link; +#endif + + logdir = D_Home(); + + my_time = time(NULL); + timeinfo = localtime(&my_time); + + if (M_CheckParm("-logfile") && M_IsNextParm()) + { + format = M_GetNextParm(); + fileabs = M_IsPathAbsolute(format); + } + else + { + format = "log-%Y-%m-%d_%H-%M-%S.txt"; + fileabs = false; + } + + if (fileabs) + { + strftime(logfilename, sizeof logfilename, format, timeinfo); + } + else + { + if (M_CheckParm("-logdir") && M_IsNextParm()) + reldir = M_GetNextParm(); + else + reldir = "logs"; + + if (M_IsPathAbsolute(reldir)) + { + left = snprintf(logfilename, sizeof logfilename, + "%s"PATHSEP, reldir); + } + else #ifdef DEFAULTDIR - if (logdir) - logstream = fopen(va("%s/"DEFAULTDIR"/log.txt",logdir), "wt"); - else -#endif - logstream = fopen("./log.txt", "wt"); -#endif + if (logdir) + { + left = snprintf(logfilename, sizeof logfilename, + "%s"PATHSEP DEFAULTDIR PATHSEP"%s"PATHSEP, logdir, reldir); + } + else +#endif/*DEFAULTDIR*/ + { + left = snprintf(logfilename, sizeof logfilename, + "."PATHSEP"%s"PATHSEP, reldir); + } +#endif/*LOGMESSAGES*/ + + strftime(&logfilename[left], sizeof logfilename - left, + format, timeinfo); + } + + M_MkdirEachUntil(logfilename, + M_PathParts(logdir) - 1, + M_PathParts(logfilename) - 1, 0755); + +#ifdef __unix__ + logstream = fopen(logfilename, "w"); +#ifdef DEFAULTDIR + if (logdir) + link = va("%s/"DEFAULTDIR"/latest-log.txt", logdir); + else +#endif/*DEFAULTDIR*/ + link = "latest-log.txt"; + unlink(link); + if (symlink(logfilename, link) == -1) + { + I_OutputMsg("Error symlinking latest-log.txt: %s\n", strerror(errno)); + } +#else/*__unix__*/ + logstream = fopen("latest-log.txt", "wt+"); +#endif/*__unix__*/ + } //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); @@ -157,9 +240,14 @@ int main(int argc, char **argv) #endif MakeCodeWritable(); #endif + // startup SRB2 CONS_Printf("Setting up SRB2...\n"); D_SRB2Main(); +#ifdef LOGMESSAGES + if (!M_CheckParm("-nolog")) + CONS_Printf("Logfile: %s\n", logfilename); +#endif CONS_Printf("Entering main game loop...\n"); // never return D_SRB2Loop(); diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 517c183ee..a86af316e 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -5,7 +5,7 @@ // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -102,6 +102,12 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #endif #endif +#if (defined (__unix__) && !defined (_MSDOS)) || defined (UNIXCOMMON) +#include +#include +#define NEWSIGNALHANDLER +#endif + #ifndef NOMUMBLE #ifdef __linux__ // need -lrt #include @@ -131,7 +137,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif -// Locations for searching the srb2.srb +// Locations for searching the srb2.pk3 #if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) #define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" #define DEFAULTWADLOCATION2 "/usr/local/games/SRB2" @@ -149,8 +155,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); /** \brief WAD file to look for */ -#define WADKEYWORD1 "srb2.srb" -#define WADKEYWORD2 "srb2.wad" +#define WADKEYWORD1 "srb2.pk3" /** \brief holds wad path */ static char returnWadPath[256]; @@ -230,13 +235,11 @@ SDL_bool framebuffer = SDL_FALSE; UINT8 keyboard_started = false; -FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) +static void I_ReportSignal(int num, int coredumped) { //static char msg[] = "oh no! back to reality!\r\n"; const char * sigmsg; - char sigdef[32]; - - D_QuitNetGame(); // Fix server freezes + char msg[128]; switch (num) { @@ -262,20 +265,41 @@ FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) sigmsg = "SIGABRT - abnormal termination triggered by abort call"; break; default: - sprintf(sigdef,"signal number %d", num); - sigmsg = sigdef; + sprintf(msg,"signal number %d", num); + if (coredumped) + sigmsg = 0; + else + sigmsg = msg; } - I_OutputMsg("\nsignal_handler() error: %s\n", sigmsg); + if (coredumped) + { + if (sigmsg) + sprintf(msg, "%s (core dumped)", sigmsg); + else + strcat(msg, " (core dumped)"); + + sigmsg = msg; + } + + I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, - "Signal caught", + "Process killed by signal", sigmsg, NULL); +} + +#ifndef NEWSIGNALHANDLER +FUNCNORETURN static ATTRNORETURN void signal_handler(INT32 num) +{ + D_QuitNetGame(); // Fix server freezes + I_ReportSignal(num, 0); I_ShutdownSystem(); signal(num, SIG_DFL); //default signal action raise(num); I_Quit(); } +#endif FUNCNORETURN static ATTRNORETURN void quit_handler(int num) { @@ -531,7 +555,7 @@ static void Impl_HandleKeyboardConsoleEvent(KEY_EVENT_RECORD evt, HANDLE co) break; case VK_RETURN: entering_con_command = false; - // Fall through. + /* FALLTHRU */ default: event.data1 = MapVirtualKey(evt.wVirtualKeyCode,2); // convert in to char } @@ -651,7 +675,7 @@ static inline void I_ShutdownConsole(void){} // // StartupKeyboard // -void I_StartupKeyboard (void) +static void I_RegisterSignals (void) { #ifdef SIGINT signal(SIGINT , quit_handler); @@ -665,10 +689,12 @@ void I_StartupKeyboard (void) // If these defines don't exist, // then compilation would have failed above us... +#ifndef NEWSIGNALHANDLER signal(SIGILL , signal_handler); signal(SIGSEGV , signal_handler); signal(SIGABRT , signal_handler); signal(SIGFPE , signal_handler); +#endif } // @@ -677,7 +703,7 @@ void I_StartupKeyboard (void) void I_OutputMsg(const char *fmt, ...) { size_t len; - XBOXSTATIC char txt[8192]; + char txt[8192]; va_list argptr; va_start(argptr,fmt); @@ -828,6 +854,23 @@ void I_JoyScale2(void) JoyInfo2.scale = Joystick2.bGamepadStyle?1:cv_joyscale2.value; } +// Cheat to get the device index for a joystick handle +INT32 I_GetJoystickDeviceIndex(SDL_Joystick *dev) +{ + INT32 i, count = SDL_NumJoysticks(); + + for (i = 0; dev && i < count; i++) + { + SDL_Joystick *test = SDL_JoystickOpen(i); + if (test && test == dev) + return i; + else if (JoyInfo.dev != test && JoyInfo2.dev != test) + SDL_JoystickClose(test); + } + + return -1; +} + /** \brief Joystick 1 buttons states */ static UINT64 lastjoybuttons = 0; @@ -843,7 +886,7 @@ static UINT64 lastjoyhats = 0; */ -static void I_ShutdownJoystick(void) +void I_ShutdownJoystick(void) { INT32 i; event_t event; @@ -877,14 +920,8 @@ static void I_ShutdownJoystick(void) joystick_started = 0; JoyReset(&JoyInfo); - if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) - { - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - if (cv_usejoystick.value == 0) - { - I_OutputMsg("I_Joystick: SDL's Joystick system has been shutdown\n"); - } - } + + // don't shut down the subsystem here, because hotplugging } void I_GetJoystickEvents(void) @@ -1025,74 +1062,66 @@ void I_GetJoystickEvents(void) */ -static int joy_open(const char *fname) +static int joy_open(int joyindex) { - int joyindex = atoi(fname); + SDL_Joystick *newdev = NULL; int num_joy = 0; - int i; - if (joystick_started == 0 && joystick2_started == 0) + if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) - { - CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); - return -1; - } - else - { - num_joy = SDL_NumJoysticks(); - } + CONS_Printf(M_GetText("Joystick subsystem not started\n")); + return -1; + } - if (num_joy < joyindex) - { - CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i)); - I_ShutdownJoystick(); - return -1; - } - } - else - { - JoyReset(&JoyInfo); - //I_ShutdownJoystick(); - //joy_open(fname); - } + if (joyindex <= 0) + return -1; num_joy = SDL_NumJoysticks(); - if (joyindex <= 0 || num_joy == 0 || JoyInfo.oldjoy == joyindex) + if (num_joy == 0) { -// I_OutputMsg("Unable to use that joystick #(%s), non-number\n",fname); - if (num_joy != 0) - { - CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i)); - } - else - CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); - if (joyindex <= 0 || num_joy == 0) return 0; + CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); + return -1; } - JoyInfo.dev = SDL_JoystickOpen(joyindex-1); + newdev = SDL_JoystickOpen(joyindex-1); + + // Handle the edge case where the device <-> joystick index assignment can change due to hotplugging + // This indexing is SDL's responsibility and there's not much we can do about it. + // + // Example: + // 1. Plug Controller A -> Index 0 opened + // 2. Plug Controller B -> Index 1 opened + // 3. Unplug Controller A -> Index 0 closed, Index 1 active + // 4. Unplug Controller B -> Index 0 inactive, Index 1 closed + // 5. Plug Controller B -> Index 0 opened + // 6. Plug Controller A -> Index 0 REPLACED, opened as Controller A; Index 1 is now Controller B + if (JoyInfo.dev) + { + if (JoyInfo.dev == newdev // same device, nothing to do + || (newdev == NULL && SDL_JoystickGetAttached(JoyInfo.dev))) // we failed, but already have a working device + return JoyInfo.axises; + // Else, we're changing devices, so send neutral joy events + CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n"); + I_ShutdownJoystick(); + } + + JoyInfo.dev = newdev; if (JoyInfo.dev == NULL) { - CONS_Printf(M_GetText("Couldn't open joystick: %s\n"), SDL_GetError()); - I_ShutdownJoystick(); + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: Couldn't open device - %s\n"), SDL_GetError()); return -1; } else { - CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(JoyInfo.dev)); + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick1: %s\n"), SDL_JoystickName(JoyInfo.dev)); JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev); if (JoyInfo.axises > JOYAXISSET*2) JoyInfo.axises = JOYAXISSET*2; -/* if (joyaxes<2) + /* if (joyaxes<2) { I_OutputMsg("Not enought axes?\n"); - I_ShutdownJoystick(); return 0; }*/ @@ -1127,7 +1156,7 @@ static UINT64 lastjoy2hats = 0; \return void */ -static void I_ShutdownJoystick2(void) +void I_ShutdownJoystick2(void) { INT32 i; event_t event; @@ -1161,14 +1190,8 @@ static void I_ShutdownJoystick2(void) joystick2_started = 0; JoyReset(&JoyInfo2); - if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) - { - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - if (cv_usejoystick2.value == 0) - { - DEBFILE("I_Joystick2: SDL's Joystick system has been shutdown\n"); - } - } + + // don't shut down the subsystem here, because hotplugging } void I_GetJoystick2Events(void) @@ -1311,72 +1334,66 @@ void I_GetJoystick2Events(void) */ -static int joy_open2(const char *fname) +static int joy_open2(int joyindex) { - int joyindex = atoi(fname); + SDL_Joystick *newdev = NULL; int num_joy = 0; - int i; - if (joystick_started == 0 && joystick2_started == 0) + if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) - { - CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); - return -1; - } - else - num_joy = SDL_NumJoysticks(); + CONS_Printf(M_GetText("Joystick subsystem not started\n")); + return -1; + } - if (num_joy < joyindex) - { - CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i)); - I_ShutdownJoystick2(); - return -1; - } - } - else - { - JoyReset(&JoyInfo2); - //I_ShutdownJoystick(); - //joy_open(fname); - } + if (joyindex <= 0) + return -1; num_joy = SDL_NumJoysticks(); - if (joyindex <= 0 || num_joy == 0 || JoyInfo2.oldjoy == joyindex) + if (num_joy == 0) { -// I_OutputMsg("Unable to use that joystick #(%s), non-number\n",fname); - if (num_joy != 0) - { - CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickNameForIndex(i)); - } - else - CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); - if (joyindex <= 0 || num_joy == 0) return 0; + CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); + return -1; } - JoyInfo2.dev = SDL_JoystickOpen(joyindex-1); + newdev = SDL_JoystickOpen(joyindex-1); - if (!JoyInfo2.dev) + // Handle the edge case where the device <-> joystick index assignment can change due to hotplugging + // This indexing is SDL's responsibility and there's not much we can do about it. + // + // Example: + // 1. Plug Controller A -> Index 0 opened + // 2. Plug Controller B -> Index 1 opened + // 3. Unplug Controller A -> Index 0 closed, Index 1 active + // 4. Unplug Controller B -> Index 0 inactive, Index 1 closed + // 5. Plug Controller B -> Index 0 opened + // 6. Plug Controller A -> Index 0 REPLACED, opened as Controller A; Index 1 is now Controller B + if (JoyInfo2.dev) { - CONS_Printf(M_GetText("Couldn't open joystick2: %s\n"), SDL_GetError()); + if (JoyInfo2.dev == newdev // same device, nothing to do + || (newdev == NULL && SDL_JoystickGetAttached(JoyInfo2.dev))) // we failed, but already have a working device + return JoyInfo.axises; + // Else, we're changing devices, so send neutral joy events + CONS_Debug(DBG_GAMELOGIC, "Joystick2 device is changing; resetting events...\n"); I_ShutdownJoystick2(); + } + + JoyInfo2.dev = newdev; + + if (JoyInfo2.dev == NULL) + { + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick2: couldn't open device - %s\n"), SDL_GetError()); return -1; } else { - CONS_Printf(M_GetText("Joystick2: %s\n"), SDL_JoystickName(JoyInfo2.dev)); + CONS_Debug(DBG_GAMELOGIC, M_GetText("Joystick2: %s\n"), SDL_JoystickName(JoyInfo2.dev)); JoyInfo2.axises = SDL_JoystickNumAxes(JoyInfo2.dev); if (JoyInfo2.axises > JOYAXISSET*2) JoyInfo2.axises = JOYAXISSET*2; -/* if (joyaxes < 2) +/* if (joyaxes<2) { I_OutputMsg("Not enought axes?\n"); - I_ShutdownJoystick2(); return 0; }*/ @@ -1401,7 +1418,11 @@ static int joy_open2(const char *fname) // void I_InitJoystick(void) { - I_ShutdownJoystick(); + SDL_Joystick *newjoy = NULL; + + //I_ShutdownJoystick(); + if (M_CheckParm("-nojoy")) + return; if (M_CheckParm("-noxinput")) SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); @@ -1409,21 +1430,48 @@ void I_InitJoystick(void) if (M_CheckParm("-nohidapi")) SDL_SetHintWithPriority("SDL_JOYSTICK_HIDAPI", "0", SDL_HINT_OVERRIDE); - if (!strcmp(cv_usejoystick.string, "0") || M_CheckParm("-nojoy")) - return; - if (joy_open(cv_usejoystick.string) != -1) - JoyInfo.oldjoy = atoi(cv_usejoystick.string); + if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) + { + CONS_Printf("I_InitJoystick()...\n"); + + if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) + { + CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); + return; + } + } + + if (cv_usejoystick.value) + newjoy = SDL_JoystickOpen(cv_usejoystick.value-1); + + if (newjoy && JoyInfo2.dev == newjoy) // don't override an active device + cv_usejoystick.value = I_GetJoystickDeviceIndex(JoyInfo.dev) + 1; + else if (newjoy && joy_open(cv_usejoystick.value) != -1) + { + // SDL's device indexes are unstable, so cv_usejoystick may not match + // the actual device index. So let's cheat a bit and find the device's current index. + JoyInfo.oldjoy = I_GetJoystickDeviceIndex(JoyInfo.dev) + 1; + joystick_started = 1; + } else { + if (JoyInfo.oldjoy) + I_ShutdownJoystick(); cv_usejoystick.value = 0; - return; + joystick_started = 0; } - joystick_started = 1; + + if (JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy) + SDL_JoystickClose(newjoy); } void I_InitJoystick2(void) { - I_ShutdownJoystick2(); + SDL_Joystick *newjoy = NULL; + + //I_ShutdownJoystick2(); + if (M_CheckParm("-nojoy")) + return; if (M_CheckParm("-noxinput")) SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); @@ -1431,60 +1479,73 @@ void I_InitJoystick2(void) if (M_CheckParm("-nohidapi")) SDL_SetHintWithPriority("SDL_JOYSTICK_HIDAPI", "0", SDL_HINT_OVERRIDE); - if (!strcmp(cv_usejoystick2.string, "0") || M_CheckParm("-nojoy")) - return; - if (joy_open2(cv_usejoystick2.string) != -1) - JoyInfo2.oldjoy = atoi(cv_usejoystick2.string); + if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) + { + CONS_Printf("I_InitJoystick2()...\n"); + + if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) + { + CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); + return; + } + } + + if (cv_usejoystick2.value) + newjoy = SDL_JoystickOpen(cv_usejoystick2.value-1); + + if (newjoy && JoyInfo.dev == newjoy) // don't override an active device + cv_usejoystick2.value = I_GetJoystickDeviceIndex(JoyInfo2.dev) + 1; + else if (newjoy && joy_open2(cv_usejoystick2.value) != -1) + { + // SDL's device indexes are unstable, so cv_usejoystick may not match + // the actual device index. So let's cheat a bit and find the device's current index. + JoyInfo2.oldjoy = I_GetJoystickDeviceIndex(JoyInfo2.dev) + 1; + joystick2_started = 1; + } else { + if (JoyInfo2.oldjoy) + I_ShutdownJoystick2(); cv_usejoystick2.value = 0; - return; + joystick2_started = 0; } - joystick2_started = 1; + + if (JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy) + SDL_JoystickClose(newjoy); } static void I_ShutdownInput(void) { + // Yes, the name is misleading: these send neutral events to + // clean up the unplugged joystick's input + // Note these methods are internal to this file, not called elsewhere. + I_ShutdownJoystick(); + I_ShutdownJoystick2(); + if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) { - JoyReset(&JoyInfo); - JoyReset(&JoyInfo2); + CONS_Printf("Shutting down joy system\n"); SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + I_OutputMsg("I_Joystick: SDL's Joystick system has been shutdown\n"); } - } INT32 I_NumJoys(void) { INT32 numjoy = 0; - if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) - { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1) - numjoy = SDL_NumJoysticks(); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } - else + if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) numjoy = SDL_NumJoysticks(); return numjoy; } -static char joyname[255]; // MAX_PATH; joystick name is straight from the driver +static char joyname[255]; // joystick name is straight from the driver const char *I_GetJoyName(INT32 joyindex) { const char *tempname = NULL; + joyname[0] = 0; joyindex--; //SDL's Joystick System starts at 0, not 1 - if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) - { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1) - { - tempname = SDL_JoystickNameForIndex(joyindex); - if (tempname) - strncpy(joyname, tempname, 255); - } - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } - else + if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) { tempname = SDL_JoystickNameForIndex(joyindex); if (tempname) @@ -2043,7 +2104,7 @@ static void I_ShutdownTimer(void) pfntimeGetTime = NULL; if (winmm) { - p_timeEndPeriod pfntimeEndPeriod = (p_timeEndPeriod)GetProcAddress(winmm, "timeEndPeriod"); + p_timeEndPeriod pfntimeEndPeriod = (p_timeEndPeriod)(LPVOID)GetProcAddress(winmm, "timeEndPeriod"); if (pfntimeEndPeriod) pfntimeEndPeriod(1); FreeLibrary(winmm); @@ -2088,10 +2149,10 @@ void I_StartupTimer(void) winmm = LoadLibraryA("winmm.dll"); if (winmm) { - p_timeEndPeriod pfntimeBeginPeriod = (p_timeEndPeriod)GetProcAddress(winmm, "timeBeginPeriod"); + p_timeEndPeriod pfntimeBeginPeriod = (p_timeEndPeriod)(LPVOID)GetProcAddress(winmm, "timeBeginPeriod"); if (pfntimeBeginPeriod) pfntimeBeginPeriod(1); - pfntimeGetTime = (p_timeGetTime)GetProcAddress(winmm, "timeGetTime"); + pfntimeGetTime = (p_timeGetTime)(LPVOID)GetProcAddress(winmm, "timeGetTime"); } I_AddExitFunc(I_ShutdownTimer); #endif @@ -2105,6 +2166,85 @@ void I_Sleep(void) SDL_Delay(cv_sleep.value); } +#ifdef NEWSIGNALHANDLER +static void newsignalhandler_Warn(const char *pr) +{ + char text[128]; + + snprintf(text, sizeof text, + "Error while setting up signal reporting: %s: %s", + pr, + strerror(errno) + ); + + I_OutputMsg("%s\n", text); + + SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, + "Startup error", + text, NULL); + + I_ShutdownConsole(); + exit(-1); +} + +static void I_Fork(void) +{ + int child; + int status; + int signum; + int c; + + child = fork(); + + switch (child) + { + case -1: + newsignalhandler_Warn("fork()"); + break; + case 0: + break; + default: + if (logstream) + fclose(logstream);/* the child has this */ + + c = wait(&status); + +#ifdef LOGMESSAGES + /* By the way, exit closes files. */ + logstream = fopen(logfilename, "at"); +#else + logstream = 0; +#endif + + if (c == -1) + { + kill(child, SIGKILL); + newsignalhandler_Warn("wait()"); + } + else + { + if (WIFSIGNALED (status)) + { + signum = WTERMSIG (status); +#ifdef WCOREDUMP + I_ReportSignal(signum, WCOREDUMP (status)); +#else + I_ReportSignal(signum, 0); +#endif + status = 128 + signum; + } + else if (WIFEXITED (status)) + { + status = WEXITSTATUS (status); + } + + I_ShutdownConsole(); + exit(status); + } + } +} +#endif/*NEWSIGNALHANDLER*/ + INT32 I_StartupSystem(void) { SDL_version SDLcompiled; @@ -2112,6 +2252,10 @@ INT32 I_StartupSystem(void) SDL_VERSION(&SDLcompiled) SDL_GetVersion(&SDLlinked); I_StartupConsole(); +#ifdef NEWSIGNALHANDLER + I_Fork(); +#endif + I_RegisterSignals(); I_OutputMsg("Compiled for SDL version: %d.%d.%d\n", SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); I_OutputMsg("Linked with SDL version: %d.%d.%d\n", @@ -2135,7 +2279,6 @@ void I_Quit(void) if (quiting) goto death; SDLforceUngrabMouse(); quiting = SDL_FALSE; - I_ShutdownConsole(); M_SaveConfig(NULL); //save game config, cvars.. #ifndef NONET D_SaveBan(); // save the ban list @@ -2147,7 +2290,7 @@ void I_Quit(void) if (demorecording) G_CheckDemoStatus(); if (metalrecording) - G_StopMetalRecording(); + G_StopMetalRecording(false); D_QuitNetGame(); I_ShutdownMusic(); @@ -2253,8 +2396,6 @@ void I_Error(const char *error, ...) I_OutputMsg("\nI_Error(): %s\n", buffer); // --- - I_ShutdownConsole(); - M_SaveConfig(NULL); // save game config, cvars.. #ifndef NONET D_SaveBan(); // save the ban list @@ -2265,7 +2406,7 @@ void I_Error(const char *error, ...) if (demorecording) G_CheckDemoStatus(); if (metalrecording) - G_StopMetalRecording(); + G_StopMetalRecording(false); D_QuitNetGame(); I_ShutdownMusic(); @@ -2343,6 +2484,48 @@ void I_RemoveExitFunc(void (*func)()) } } +#ifndef __unix__ +static void Shittycopyerror(const char *name) +{ + I_OutputMsg( + "Error copying log file: %s: %s\n", + name, + strerror(errno) + ); +} + +static void Shittylogcopy(void) +{ + char buf[8192]; + FILE *fp; + size_t r; + if (fseek(logstream, 0, SEEK_SET) == -1) + { + Shittycopyerror("fseek"); + } + else if (( fp = fopen(logfilename, "wt") )) + { + while (( r = fread(buf, 1, sizeof buf, logstream) )) + { + if (fwrite(buf, 1, r, fp) < r) + { + Shittycopyerror("fwrite"); + break; + } + } + if (ferror(logstream)) + { + Shittycopyerror("fread"); + } + fclose(fp); + } + else + { + Shittycopyerror(logfilename); + } +} +#endif/*__unix__*/ + // // Closes down everything. This includes restoring the initial // palette and video mode, and removing whatever mouse, keyboard, and @@ -2354,6 +2537,10 @@ void I_ShutdownSystem(void) { INT32 c; +#ifndef NEWSIGNALHANDLER + I_ShutdownConsole(); +#endif + for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) if (quit_funcs[c]) (*quit_funcs[c])(); @@ -2361,6 +2548,9 @@ void I_ShutdownSystem(void) if (logstream) { I_OutputMsg("I_ShutdownSystem(): end of logstream.\n"); +#ifndef __unix__ + Shittylogcopy(); +#endif fclose(logstream); logstream = NULL; } @@ -2390,7 +2580,7 @@ void I_GetDiskFreeSpace(INT64 *freespace) if (!testwin95) { - pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); + pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); testwin95 = true; } if (pfnGetDiskFreeSpaceEx) @@ -2414,7 +2604,7 @@ void I_GetDiskFreeSpace(INT64 *freespace) char *I_GetUserName(void) { - static char username[MAXPLAYERNAME]; + static char username[MAXPLAYERNAME+1]; char *p; #ifdef _WIN32 DWORD i = MAXPLAYERNAME; @@ -2451,7 +2641,7 @@ char *I_GetUserName(void) INT32 I_mkdir(const char *dirname, INT32 unixright) { //[segabor] -#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (__CYGWIN__) || defined (__OS2__) +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (__CYGWIN__) return mkdir(dirname, unixright); #elif defined (_WIN32) UNREFERENCED_PARAMETER(unixright); /// \todo should implement ntright under nt... @@ -2545,14 +2735,6 @@ static boolean isWadPathOk(const char *path) return true; } - sprintf(wad3path, pandf, path, WADKEYWORD2); - - if (FIL_ReadFileOK(wad3path)) - { - free(wad3path); - return true; - } - free(wad3path); return false; } @@ -2570,7 +2752,7 @@ static void pathonly(char *s) } } -/** \brief search for srb2.srb in the given path +/** \brief search for srb2.pk3 in the given path \param searchDir starting path @@ -2591,19 +2773,12 @@ static const char *searchWad(const char *searchDir) return tempsw; } - strcpy(tempsw, WADKEYWORD2); - fstemp = filesearch(tempsw, searchDir, NULL, true, 20); - if (fstemp == FS_FOUND) - { - pathonly(tempsw); - return tempsw; - } return NULL; } -/** \brief go through all possible paths and look for srb2.srb +/** \brief go through all possible paths and look for srb2.pk3 - \return path to srb2.srb if any + \return path to srb2.pk3 if any */ static const char *locateWad(void) { @@ -2732,7 +2907,7 @@ const char *I_LocateWad(void) if (waddir) { - // change to the directory where we found srb2.srb + // change to the directory where we found srb2.pk3 #if defined (_WIN32) SetCurrentDirectoryA(waddir); #else @@ -2823,16 +2998,6 @@ UINT32 I_GetFreeMem(UINT32 *total) if (total) *total = (UINT32)info.dwTotalPhys; return (UINT32)info.dwAvailPhys; -#elif defined (__OS2__) - UINT32 pr_arena; - - if (total) - DosQuerySysInfo( QSV_TOTPHYSMEM, QSV_TOTPHYSMEM, - (PVOID) total, sizeof (UINT32)); - DosQuerySysInfo( QSV_MAXPRMEM, QSV_MAXPRMEM, - (PVOID) &pr_arena, sizeof (UINT32)); - - return pr_arena; #elif defined (__linux__) /* Linux */ char buf[1024]; @@ -2910,7 +3075,7 @@ const CPUInfoFlags *I_CPUInfo(void) #if defined (_WIN32) static CPUInfoFlags WIN_CPUInfo; SYSTEM_INFO SI; - p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); + p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); ZeroMemory(&WIN_CPUInfo,sizeof (WIN_CPUInfo)); if (pfnCPUID) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index dbaa7037a..c2f492000 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -4,7 +4,7 @@ // // Copyright (C) 1993-1996 by id Software, Inc. // Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -32,6 +32,7 @@ #include "SDL.h" #ifdef _MSC_VER +#include #pragma warning(default : 4214 4244) #endif @@ -41,7 +42,7 @@ #ifdef HAVE_IMAGE #include "SDL_image.h" -#elif 1 +#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) // Windows doesn't need this, as SDL will do it for us. #define LOAD_XPM //I want XPM! #include "IMG_xpm.c" //Alam: I don't want to add SDL_Image.dll/so #define HAVE_IMAGE //I have SDL_Image, sortof @@ -64,13 +65,14 @@ #include "../m_menu.h" #include "../d_main.h" #include "../s_sound.h" -#include "../i_sound.h" // midi pause/unpause #include "../i_joy.h" #include "../st_stuff.h" +#include "../hu_stuff.h" #include "../g_game.h" #include "../i_video.h" #include "../console.h" #include "../command.h" +#include "../r_main.h" #include "sdlmain.h" #ifdef HWRENDER #include "../hardware/hw_main.h" @@ -91,15 +93,18 @@ static INT32 numVidModes = -1; */ static char vidModeName[33][32]; // allow 33 different modes -rendermode_t rendermode=render_soft; +rendermode_t rendermode = render_soft; +static rendermode_t chosenrendermode = render_soft; // set by command line arguments boolean highcolor = false; // synchronize page flipping with screen refresh consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; UINT8 graphics_started = 0; // Is used in console.c and screen.c +INT32 hwrenderloaded = 0; // To disable fullscreen at startup; is set in VID_PrepareModeList boolean allow_fullscreen = false; @@ -171,7 +176,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); //static void Impl_SetWindowName(const char *title); static void Impl_SetWindowIcon(void); -static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) +static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition) { static SDL_bool wasfullscreen = SDL_FALSE; Uint32 rmask; @@ -200,10 +205,13 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) } // Reposition window only in windowed mode SDL_SetWindowSize(window, width, height); - SDL_SetWindowPosition(window, - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), - SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) - ); + if (reposition) + { + SDL_SetWindowPosition(window, + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)), + SDL_WINDOWPOS_CENTERED_DISPLAY(SDL_GetWindowDisplayIndex(window)) + ); + } } } else @@ -358,6 +366,25 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) return 0; } +static boolean IgnoreMouse(void) +{ + if (cv_alwaysgrabmouse.value) + return false; + if (menuactive) + return !M_MouseNeeded(); + if (paused || con_destlines || chat_on || gamestate != GS_LEVEL) + return true; + return false; +} + +static void SDLdoGrabMouse(void) +{ + SDL_ShowCursor(SDL_DISABLE); + SDL_SetWindowGrab(window, SDL_TRUE); + if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful + wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? +} + static void SDLdoUngrabMouse(void) { SDL_ShowCursor(SDL_ENABLE); @@ -369,12 +396,15 @@ static void SDLdoUngrabMouse(void) void SDLforceUngrabMouse(void) { if (SDL_WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO && window != NULL) - { - SDL_ShowCursor(SDL_ENABLE); - SDL_SetWindowGrab(window, SDL_FALSE); - wrapmouseok = SDL_FALSE; - SDL_SetRelativeMouseMode(SDL_FALSE); - } + SDLdoUngrabMouse(); +} + +void I_UpdateMouseGrab(void) +{ + if (SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO && window != NULL + && SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window + && USE_MOUSEINPUT && !IgnoreMouse()) + SDLdoGrabMouse(); } static void VID_Command_NumModes_f (void) @@ -573,7 +603,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) // Tell game we got focus back, resume music if necessary window_notinfocus = false; if (!paused) - I_ResumeSong(); //resume it + S_ResumeAudio(); //resume it if (!firsttimeonmouse) { @@ -581,13 +611,17 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) } //else firsttimeonmouse = SDL_FALSE; - capslock = !!( SDL_GetModState() & KMOD_CAPS );// in case CL changes + if (USE_MOUSEINPUT && !IgnoreMouse()) + SDLdoGrabMouse(); } else if (!mousefocus && !kbfocus) { // Tell game we lost focus, pause music window_notinfocus = true; - I_PauseSong(); + if (! cv_playmusicifunfocused.value) + S_PauseAudio(); + if (! cv_playsoundsifunfocused.value) + S_StopSounds(); if (!disable_mouse) { @@ -624,11 +658,14 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) { + static boolean firstmove = true; + if (USE_MOUSEINPUT) { - if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window)) + if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window) || (IgnoreMouse() && !firstmove)) { SDLdoUngrabMouse(); + firstmove = false; return; } @@ -642,6 +679,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) mousemovey += -evt.yrel; SDL_SetWindowGrab(window, SDL_TRUE); } + firstmove = false; return; } @@ -649,6 +687,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // of the screen then ignore it. if ((evt.x == realwidth/2) && (evt.y == realheight/2)) { + firstmove = false; return; } @@ -658,11 +697,11 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // -- Monster Iestyn if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) { - SDL_SetWindowGrab(window, SDL_TRUE); - if (SDL_SetRelativeMouseMode(SDL_TRUE) == 0) // already warps mouse if successful - wrapmouseok = SDL_TRUE; // TODO: is wrapmouseok or HalfWarpMouse needed anymore? + SDLdoGrabMouse(); } } + + firstmove = false; } static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) @@ -676,7 +715,7 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) // this apparently makes a mouse button down event but not a mouse button up event, // resulting in whatever key was pressed down getting "stuck" if we don't ignore it. // -- Monster Iestyn (28/05/18) - if (SDL_GetMouseFocus() != window) + if (SDL_GetMouseFocus() != window || IgnoreMouse()) return; /// \todo inputEvent.button.which @@ -889,6 +928,136 @@ void I_GetEvent(void) case SDL_JOYBUTTONDOWN: Impl_HandleJoystickButtonEvent(evt.jbutton, evt.type); break; + case SDL_JOYDEVICEADDED: + { + SDL_Joystick *newjoy = SDL_JoystickOpen(evt.jdevice.which); + + CONS_Debug(DBG_GAMELOGIC, "Joystick device index %d added\n", evt.jdevice.which + 1); + + // Because SDL's device index is unstable, we're going to cheat here a bit: + // For the first joystick setting that is NOT active: + // 1. Set cv_usejoystickX.value to the new device index (this does not change what is written to config.cfg) + // 2. Set OTHERS' cv_usejoystickX.value to THEIR new device index, because it likely changed + // * If device doesn't exist, switch cv_usejoystick back to default value (.string) + // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! + if (newjoy && (!JoyInfo.dev || !SDL_JoystickGetAttached(JoyInfo.dev)) + && JoyInfo2.dev != newjoy) // don't override a currently active device + { + cv_usejoystick.value = evt.jdevice.which + 1; + + if (JoyInfo2.dev) + cv_usejoystick2.value = I_GetJoystickDeviceIndex(JoyInfo2.dev) + 1; + else if (atoi(cv_usejoystick2.string) != JoyInfo.oldjoy + && atoi(cv_usejoystick2.string) != cv_usejoystick.value) + cv_usejoystick2.value = atoi(cv_usejoystick2.string); + else if (atoi(cv_usejoystick.string) != JoyInfo.oldjoy + && atoi(cv_usejoystick.string) != cv_usejoystick.value) + cv_usejoystick2.value = atoi(cv_usejoystick.string); + else // we tried... + cv_usejoystick2.value = 0; + } + else if (newjoy && (!JoyInfo2.dev || !SDL_JoystickGetAttached(JoyInfo2.dev)) + && JoyInfo.dev != newjoy) // don't override a currently active device + { + cv_usejoystick2.value = evt.jdevice.which + 1; + + if (JoyInfo.dev) + cv_usejoystick.value = I_GetJoystickDeviceIndex(JoyInfo.dev) + 1; + else if (atoi(cv_usejoystick.string) != JoyInfo2.oldjoy + && atoi(cv_usejoystick.string) != cv_usejoystick2.value) + cv_usejoystick.value = atoi(cv_usejoystick.string); + else if (atoi(cv_usejoystick2.string) != JoyInfo2.oldjoy + && atoi(cv_usejoystick2.string) != cv_usejoystick2.value) + cv_usejoystick.value = atoi(cv_usejoystick2.string); + else // we tried... + cv_usejoystick.value = 0; + } + + // Was cv_usejoystick disabled in settings? + if (!strcmp(cv_usejoystick.string, "0") || !cv_usejoystick.value) + cv_usejoystick.value = 0; + else if (atoi(cv_usejoystick.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick.value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick, cv_usejoystick.value); + + if (!strcmp(cv_usejoystick2.string, "0") || !cv_usejoystick2.value) + cv_usejoystick2.value = 0; + else if (atoi(cv_usejoystick2.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick2.value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick2, cv_usejoystick2.value); + + // Update all joysticks' init states + // This is a little wasteful since cv_usejoystick already calls this, but + // we need to do this in case CV_SetValue did nothing because the string was already same. + // if the device is already active, this should do nothing, effectively. + I_InitJoystick(); + I_InitJoystick2(); + + CONS_Debug(DBG_GAMELOGIC, "Joystick1 device index: %d\n", JoyInfo.oldjoy); + CONS_Debug(DBG_GAMELOGIC, "Joystick2 device index: %d\n", JoyInfo2.oldjoy); + + // update the menu + if (currentMenu == &OP_JoystickSetDef) + M_SetupJoystickMenu(0); + + if (JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy) + SDL_JoystickClose(newjoy); + } + break; + case SDL_JOYDEVICEREMOVED: + if (JoyInfo.dev && !SDL_JoystickGetAttached(JoyInfo.dev)) + { + CONS_Debug(DBG_GAMELOGIC, "Joystick1 removed, device index: %d\n", JoyInfo.oldjoy); + I_ShutdownJoystick(); + } + + if (JoyInfo2.dev && !SDL_JoystickGetAttached(JoyInfo2.dev)) + { + CONS_Debug(DBG_GAMELOGIC, "Joystick2 removed, device index: %d\n", JoyInfo2.oldjoy); + I_ShutdownJoystick2(); + } + + // Update the device indexes, because they likely changed + // * If device doesn't exist, switch cv_usejoystick back to default value (.string) + // * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value! + if (JoyInfo.dev) + cv_usejoystick.value = JoyInfo.oldjoy = I_GetJoystickDeviceIndex(JoyInfo.dev) + 1; + else if (atoi(cv_usejoystick.string) != JoyInfo2.oldjoy) + cv_usejoystick.value = atoi(cv_usejoystick.string); + else if (atoi(cv_usejoystick2.string) != JoyInfo2.oldjoy) + cv_usejoystick.value = atoi(cv_usejoystick2.string); + else // we tried... + cv_usejoystick.value = 0; + + if (JoyInfo2.dev) + cv_usejoystick2.value = JoyInfo2.oldjoy = I_GetJoystickDeviceIndex(JoyInfo2.dev) + 1; + else if (atoi(cv_usejoystick2.string) != JoyInfo.oldjoy) + cv_usejoystick2.value = atoi(cv_usejoystick2.string); + else if (atoi(cv_usejoystick.string) != JoyInfo.oldjoy) + cv_usejoystick2.value = atoi(cv_usejoystick.string); + else // we tried... + cv_usejoystick2.value = 0; + + // Was cv_usejoystick disabled in settings? + if (!strcmp(cv_usejoystick.string, "0")) + cv_usejoystick.value = 0; + else if (atoi(cv_usejoystick.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick.value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick, cv_usejoystick.value); + + if (!strcmp(cv_usejoystick2.string, "0")) + cv_usejoystick2.value = 0; + else if (atoi(cv_usejoystick2.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys + && cv_usejoystick2.value) // update the cvar ONLY if a device exists + CV_SetValue(&cv_usejoystick2, cv_usejoystick2.value); + + CONS_Debug(DBG_GAMELOGIC, "Joystick1 device index: %d\n", JoyInfo.oldjoy); + CONS_Debug(DBG_GAMELOGIC, "Joystick2 device index: %d\n", JoyInfo2.oldjoy); + + // update the menu + if (currentMenu == &OP_JoystickSetDef) + M_SetupJoystickMenu(0); + break; case SDL_QUIT: I_Quit(); M_QuitResponse('y'); @@ -928,8 +1097,8 @@ void I_StartupMouse(void) } else firsttimeonmouse = SDL_FALSE; - if (cv_usemouse.value) - return; + if (cv_usemouse.value && !IgnoreMouse()) + SDLdoGrabMouse(); else SDLdoUngrabMouse(); } @@ -939,6 +1108,8 @@ void I_StartupMouse(void) // void I_OsPolling(void) { + SDL_Keymod mod; + if (consolevent) I_GetConsoleEvents(); if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) @@ -951,6 +1122,18 @@ void I_OsPolling(void) I_GetMouseEvents(); I_GetEvent(); + + mod = SDL_GetModState(); + /* Handle here so that our state is always synched with the system. */ + shiftdown = ctrldown = altdown = 0; + capslock = false; + if (mod & KMOD_LSHIFT) shiftdown |= 1; + if (mod & KMOD_RSHIFT) shiftdown |= 2; + if (mod & KMOD_LCTRL) ctrldown |= 1; + if (mod & KMOD_RCTRL) ctrldown |= 2; + if (mod & KMOD_LALT) altdown |= 1; + if (mod & KMOD_RALT) altdown |= 2; + if (mod & KMOD_CAPS) capslock = true; } // @@ -984,6 +1167,7 @@ void I_UpdateNoBlit(void) // from PrBoom's src/SDL/i_video.c static inline boolean I_SkipFrame(void) { +#if 0 static boolean skip = false; if (rendermode != render_soft) @@ -997,12 +1181,14 @@ static inline boolean I_SkipFrame(void) if (!paused) return false; /* FALLTHRU */ - case GS_TIMEATTACK: + //case GS_TIMEATTACK: -- sorry optimisation but now we have a cool level platter and that being laggardly looks terrible case GS_WAITINGPLAYERS: return skip; // Skip odd frames default: return false; } +#endif + return false; } // @@ -1016,9 +1202,16 @@ void I_FinishUpdate(void) if (I_SkipFrame()) return; + // draw captions if enabled + if (cv_closedcaptioning.value) + SCR_ClosedCaptions(); + if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + if (rendermode == render_soft && screens[0]) { SDL_Rect rect; @@ -1044,7 +1237,6 @@ void I_FinishUpdate(void) SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); } - #ifdef HWRENDER else if (rendermode == render_opengl) { @@ -1244,39 +1436,96 @@ void VID_PrepareModeList(void) #endif } -INT32 VID_SetMode(INT32 modeNum) +static SDL_bool Impl_CreateContext(void) { - SDLdoUngrabMouse(); - - vid.recalc = 1; - vid.bpp = 1; - - if (modeNum >= 0 && modeNum < MAXWINMODES) + // Renderer-specific stuff +#ifdef HWRENDER + if ((rendermode == render_opengl) && (hwrenderloaded != -1)) { - vid.width = windowedModes[modeNum][0]; - vid.height = windowedModes[modeNum][1]; - vid.modenum = modeNum; + if (!sdlglcontext) + sdlglcontext = SDL_GL_CreateContext(window); + if (sdlglcontext == NULL) + { + SDL_DestroyWindow(window); + I_Error("Failed to create a GL context: %s\n", SDL_GetError()); + } + SDL_GL_MakeCurrent(window, sdlglcontext); } else +#endif + if (rendermode == render_soft) { - // just set the desktop resolution as a fallback - SDL_DisplayMode mode; - SDL_GetWindowDisplayMode(window, &mode); - if (mode.w >= 2048) - { - vid.width = 1920; - vid.height = 1200; - } - else - { - vid.width = mode.w; - vid.height = mode.h; - } - vid.modenum = -1; - } - //Impl_SetWindowName("SRB2 "VERSIONSTRING); + int flags = 0; // Use this to set SDL_RENDERER_* flags now + if (usesdl2soft) + flags |= SDL_RENDERER_SOFTWARE; + else if (cv_vidwait.value) + flags |= SDL_RENDERER_PRESENTVSYNC; - SDLSetMode(vid.width, vid.height, USE_FULLSCREEN); + if (!renderer) + renderer = SDL_CreateRenderer(window, -1, flags); + if (renderer == NULL) + { + CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); + return SDL_FALSE; + } + SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); + } + return SDL_TRUE; +} + +#ifdef HWRENDER +static void VID_CheckGLLoaded(rendermode_t oldrender) +{ + if (hwrenderloaded == -1) // Well, it didn't work the first time anyway. + { + rendermode = oldrender; + if (chosenrendermode == render_opengl) // fallback to software + rendermode = render_soft; + if (setrenderneeded) + { + CV_StealthSetValue(&cv_renderer, oldrender); + CV_StealthSetValue(&cv_newrenderer, oldrender); + setrenderneeded = 0; + } + } +} +#endif + +void VID_CheckRenderer(void) +{ + SDL_bool rendererchanged = SDL_FALSE; + rendermode_t oldrenderer = rendermode; + + if (dedicated) + return; + +#ifdef HWRENDER + if (!graphics_started) + VID_CheckGLLoaded(oldrenderer); +#endif + + if (setrenderneeded) + { + rendermode = setrenderneeded; + rendererchanged = SDL_TRUE; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + VID_CheckGLLoaded(oldrenderer); + // Initialise OpenGL before calling SDLSetMode!!! + if (hwrenderloaded != 1) + I_StartupHardwareGraphics(); + else if (hwrenderloaded == -1) + rendererchanged = SDL_FALSE; + } +#endif + + Impl_CreateContext(); + } + + SDLSetMode(vid.width, vid.height, USE_FULLSCREEN, (rendererchanged ? SDL_FALSE : SDL_TRUE)); + Impl_VideoSetupBuffer(); if (rendermode == render_soft) { @@ -1285,10 +1534,38 @@ INT32 VID_SetMode(INT32 modeNum) SDL_FreeSurface(bufSurface); bufSurface = NULL; } - - Impl_VideoSetupBuffer(); +#ifdef HWRENDER + if (hwrenderloaded == 1) // Only if OpenGL ever loaded! + HWR_FreeTextureCache(); +#endif + SCR_SetDrawFuncs(); } +#ifdef HWRENDER + else if (rendermode == render_opengl) + R_InitHardwareMode(); +#else + (void)oldrenderer; +#endif +} +INT32 VID_SetMode(INT32 modeNum) +{ + SDLdoUngrabMouse(); + + vid.recalc = 1; + vid.bpp = 1; + + if (modeNum < 0) + modeNum = 0; + if (modeNum >= MAXWINMODES) + modeNum = MAXWINMODES-1; + + vid.width = windowedModes[modeNum][0]; + vid.height = windowedModes[modeNum][1]; + vid.modenum = modeNum; + + //Impl_SetWindowName("SRB2 "VERSIONSTRING); + VID_CheckRenderer(); return SDL_TRUE; } @@ -1309,7 +1586,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) flags |= SDL_WINDOW_BORDERLESS; #ifdef HWRENDER - if (rendermode == render_opengl) + if (hwrenderloaded != -1) flags |= SDL_WINDOW_OPENGL; #endif @@ -1323,38 +1600,7 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) return SDL_FALSE; } - // Renderer-specific stuff -#ifdef HWRENDER - if (rendermode == render_opengl) - { - sdlglcontext = SDL_GL_CreateContext(window); - if (sdlglcontext == NULL) - { - SDL_DestroyWindow(window); - I_Error("Failed to create a GL context: %s\n", SDL_GetError()); - } - SDL_GL_MakeCurrent(window, sdlglcontext); - } - else -#endif - if (rendermode == render_soft) - { - flags = 0; // Use this to set SDL_RENDERER_* flags now - if (usesdl2soft) - flags |= SDL_RENDERER_SOFTWARE; - else if (cv_vidwait.value) - flags |= SDL_RENDERER_PRESENTVSYNC; - - renderer = SDL_CreateRenderer(window, -1, flags); - if (renderer == NULL) - { - CONS_Printf(M_GetText("Couldn't create rendering context: %s\n"), SDL_GetError()); - return SDL_FALSE; - } - SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); - } - - return SDL_TRUE; + return Impl_CreateContext(); } /* @@ -1409,17 +1655,14 @@ static void Impl_VideoSetupSDLBuffer(void) static void Impl_VideoSetupBuffer(void) { // Set up game's software render buffer - if (rendermode == render_soft) + vid.rowbytes = vid.width * vid.bpp; + vid.direct = NULL; + if (vid.buffer) + free(vid.buffer); + vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS); + if (!vid.buffer) { - vid.rowbytes = vid.width * vid.bpp; - vid.direct = NULL; - if (vid.buffer) - free(vid.buffer); - vid.buffer = calloc(vid.rowbytes*vid.height, NUMSCREENS); - if (!vid.buffer) - { - I_Error("%s", M_GetText("Not enough memory for video buffer\n")); - } + I_Error("%s", M_GetText("Not enough memory for video buffer\n")); } } @@ -1439,6 +1682,7 @@ void I_StartupGraphics(void) COM_AddCommand ("vid_mode", VID_Command_Mode_f); CV_RegisterVar (&cv_vidwait); CV_RegisterVar (&cv_stretch); + CV_RegisterVar (&cv_alwaysgrabmouse); disable_mouse = M_CheckParm("-nomouse"); disable_fullscreen = M_CheckParm("-win") ? 1 : 0; @@ -1463,10 +1707,13 @@ void I_StartupGraphics(void) )) framebuffer = SDL_TRUE; } - if (M_CheckParm("-software")) - { - rendermode = render_soft; - } + +#ifdef HWRENDER + if (M_CheckParm("-opengl")) + chosenrendermode = rendermode = render_opengl; + else if (M_CheckParm("-software")) +#endif + chosenrendermode = rendermode = render_soft; usesdl2soft = M_CheckParm("-softblit"); borderlesswindow = M_CheckParm("-borderless"); @@ -1474,45 +1721,10 @@ void I_StartupGraphics(void) //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2); VID_Command_ModeList_f(); #ifdef HWRENDER - if (M_CheckParm("-opengl") || rendermode == render_opengl) - { - rendermode = render_opengl; - HWD.pfnInit = hwSym("Init",NULL); - HWD.pfnFinishUpdate = NULL; - HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL); - HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL); - HWD.pfnSetBlend = hwSym("SetBlend",NULL); - HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL); - HWD.pfnSetTexture = hwSym("SetTexture",NULL); - HWD.pfnReadRect = hwSym("ReadRect",NULL); - HWD.pfnGClipRect = hwSym("GClipRect",NULL); - HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); - HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); - HWD.pfnSetPalette = hwSym("SetPalette",NULL); - HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); - HWD.pfnDrawMD2 = hwSym("DrawMD2",NULL); - HWD.pfnDrawMD2i = hwSym("DrawMD2i",NULL); - HWD.pfnSetTransform = hwSym("SetTransform",NULL); - HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL); -#ifdef SHUFFLE - HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL); -#endif - HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL); - HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL); - HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL); - HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL); - HWD.pfnDrawIntermissionBG=hwSym("DrawIntermissionBG",NULL); - HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL); - HWD.pfnMakeScreenFinalTexture=hwSym("MakeScreenFinalTexture",NULL); - HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL); - // check gl renderer lib - if (HWD.pfnGetRenderVersion() != VERSION) - I_Error("%s", M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n")); - if (!HWD.pfnInit(I_Error)) // let load the OpenGL library - { - rendermode = render_soft; - } - } + if (M_CheckParm("-nogl")) + hwrenderloaded = -1; // Don't call SDL_GL_LoadLibrary + else + I_StartupHardwareGraphics(); #endif // Fury: we do window initialization after GL setup to allow @@ -1562,16 +1774,64 @@ void I_StartupGraphics(void) SDL_RaiseWindow(window); if (mousegrabok && !disable_mouse) - { - SDL_ShowCursor(SDL_DISABLE); - SDL_SetRelativeMouseMode(SDL_TRUE); - wrapmouseok = SDL_TRUE; - SDL_SetWindowGrab(window, SDL_TRUE); - } + SDLdoGrabMouse(); graphics_started = true; } +void I_StartupHardwareGraphics(void) +{ +#ifdef HWRENDER + static boolean glstartup = false; + if (!glstartup) + { + HWD.pfnInit = hwSym("Init",NULL); + HWD.pfnFinishUpdate = NULL; + HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL); + HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL); + HWD.pfnRenderSkyDome = hwSym("RenderSkyDome",NULL); + HWD.pfnSetBlend = hwSym("SetBlend",NULL); + HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL); + HWD.pfnSetTexture = hwSym("SetTexture",NULL); + HWD.pfnReadRect = hwSym("ReadRect",NULL); + HWD.pfnGClipRect = hwSym("GClipRect",NULL); + HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); + HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); + HWD.pfnSetPalette = hwSym("SetPalette",NULL); + HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); + HWD.pfnDrawModel = hwSym("DrawModel",NULL); + HWD.pfnCreateModelVBOs = hwSym("CreateModelVBOs",NULL); + HWD.pfnSetTransform = hwSym("SetTransform",NULL); + HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL); + HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL); + HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL); + HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL); + HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL); + HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL); + HWD.pfnDrawIntermissionBG=hwSym("DrawIntermissionBG",NULL); + HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL); + HWD.pfnMakeScreenFinalTexture=hwSym("MakeScreenFinalTexture",NULL); + HWD.pfnDrawScreenFinalTexture=hwSym("DrawScreenFinalTexture",NULL); + + // check gl renderer lib + if (HWD.pfnGetRenderVersion() != VERSION) + { + CONS_Alert(CONS_ERROR, M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n")); + hwrenderloaded = -1; + } + else + hwrenderloaded = HWD.pfnInit(I_Error) ? 1 : -1; // let load the OpenGL library + + if (hwrenderloaded == -1) + { + rendermode = render_soft; + setrenderneeded = 0; + } + glstartup = true; + } +#endif +} + void I_ShutdownGraphics(void) { const rendermode_t oldrendermode = rendermode; diff --git a/src/sdl/macosx/Srb2mac.icns b/src/sdl/macosx/Srb2mac.icns index 96cb8a36d..a3e37aab3 100644 Binary files a/src/sdl/macosx/Srb2mac.icns and b/src/sdl/macosx/Srb2mac.icns differ diff --git a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj index a8ecbf7f8..182220265 100644 --- a/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj +++ b/src/sdl/macosx/Srb2mac.xcodeproj/project.pbxproj @@ -1219,7 +1219,7 @@ C01FCF4B08A954540054247B /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; + CURRENT_PROJECT_VERSION = 2.2.2; GCC_PREPROCESSOR_DEFINITIONS = ( "$(inherited)", NORMALSRB2, @@ -1231,7 +1231,7 @@ C01FCF4C08A954540054247B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; + CURRENT_PROJECT_VERSION = 2.2.2; GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_PREPROCESSOR_DEFINITIONS = ( @@ -1272,7 +1272,6 @@ HAVE_SDL, HAVE_MIXER, HAVE_PNG, - HAVE_BLUA, LUA_USE_POSIX, COMPVERSION, HWRENDER, @@ -1395,7 +1394,6 @@ HAVE_SDL, HAVE_MIXER, HAVE_PNG, - HAVE_BLUA, LUA_USE_POSIX, COMPVERSION, HWRENDER, diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index 6e90a6e06..9a713608c 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2014-2018 by Sonic Team Junior. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -9,7 +9,28 @@ /// \file /// \brief SDL Mixer interface for sound +#ifdef HAVE_LIBGME +#ifdef HAVE_ZLIB +#ifndef _MSC_VER +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE +#endif +#endif + +#ifndef _LFS64_LARGEFILE +#define _LFS64_LARGEFILE +#endif + +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 0 +#endif + +#include +#endif // HAVE_ZLIB +#endif // HAVE_LIBGME + #include "../doomdef.h" +#include "../doomstat.h" // menuactive #if defined(HAVE_SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER @@ -28,7 +49,11 @@ #pragma warning(default : 4214 4244) #endif +#ifdef HAVE_MIXERX +#include "SDL_mixer_ext.h" +#else #include "SDL_mixer.h" +#endif /* This is the version number macro for the current SDL_mixer version: */ #ifndef SDL_MIXER_COMPILEDVERSION @@ -52,45 +77,157 @@ #include "gme/gme.h" #define GME_TREBLE 5.0f #define GME_BASS 1.0f - -#ifdef HAVE_ZLIB -#ifndef _MSC_VER -#ifndef _LARGEFILE64_SOURCE -#define _LARGEFILE64_SOURCE -#endif -#endif - -#ifndef _LFS64_LARGEFILE -#define _LFS64_LARGEFILE -#endif - -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 0 -#endif - -#include "zlib.h" -#endif // HAVE_ZLIB #endif // HAVE_LIBGME +static UINT16 BUFFERSIZE = 2048; +static UINT16 SAMPLERATE = 44100; + +#ifdef HAVE_OPENMPT +#include "libopenmpt/libopenmpt.h" +#endif + +/// ------------------------ +/// Audio Declarations +/// ------------------------ + UINT8 sound_started = false; static Mix_Music *music; -static UINT8 music_volume, sfx_volume; +static UINT8 music_volume, sfx_volume, internal_volume; static float loop_point; +static float song_length; // length in seconds static boolean songpaused; +static UINT32 music_bytes; +static boolean is_looping; + +// fading +static boolean is_fading; +static UINT8 fading_source; +static UINT8 fading_target; +static UINT32 fading_timer; +static UINT32 fading_duration; +static INT32 fading_id; +static void (*fading_callback)(void); +static boolean fading_nocleanup; #ifdef HAVE_LIBGME static Music_Emu *gme; -static INT32 current_track; +static UINT16 current_track; #endif +#ifdef HAVE_OPENMPT +static int mod_err = OPENMPT_ERROR_OK; +static const char *mod_err_str; +static UINT16 current_subsong; +static size_t probesize; +static int result; +#endif + +#ifdef HAVE_MIXERX +static void Midiplayer_Onchange(void) +{ + boolean restart = false; + + if (I_SongType() != MU_NONE && I_SongType() != MU_MID_EX && I_SongType() != MU_MID) + return; + + if (Mix_GetMidiPlayer() != cv_midiplayer.value) + { + if (Mix_SetMidiPlayer(cv_midiplayer.value)) // <> 0 means error + CONS_Alert(CONS_ERROR, "Midi player error: %s", Mix_GetError()); + else + restart = true; + } + + if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string)) + { + if (!Mix_SetSoundFonts(cv_midisoundfontpath.string)) // == 0 means error + CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError()); + else + restart = true; + } + + Mix_Timidity_addToPathList(cv_miditimiditypath.string); + + if (restart) + S_StartEx(true); +} + +static void MidiSoundfontPath_Onchange(void) +{ + if (Mix_GetMidiPlayer() != MIDI_Fluidsynth || (I_SongType() != MU_NONE && I_SongType() != MU_MID_EX)) + return; + + if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string)) + { + char *miditoken; + char *source = strdup(cv_midisoundfontpath.string); + boolean proceed = true; + // check if file exists; menu calls this method at every keystroke + + // get first token + miditoken = strtok(source, ";"); + + while (miditoken != NULL) + { + SDL_RWops *rw = SDL_RWFromFile(miditoken, "r"); + if (rw != NULL) + SDL_RWclose(rw); + else + { + proceed = false; + break; + } + miditoken = strtok(NULL, ";"); + } + + free(source); + + if (proceed) + { + if (!Mix_SetSoundFonts(cv_midisoundfontpath.string)) + CONS_Alert(CONS_ERROR, "Sound font error: %s", Mix_GetError()); + else + S_StartEx(true); + } + } +} + +// make sure that s_sound.c does not already verify these +// which happens when: defined(HAVE_MIXERX) && !defined(HAVE_MIXER) +static CV_PossibleValue_t midiplayer_cons_t[] = {{MIDI_OPNMIDI, "OPNMIDI"}, {MIDI_Fluidsynth, "Fluidsynth"}, {MIDI_Timidity, "Timidity"}, {MIDI_Native, "Native"}, {0, NULL}}; +consvar_t cv_midiplayer = {"midiplayer", "OPNMIDI" /*MIDI_OPNMIDI*/, CV_CALL|CV_NOINIT|CV_SAVE, midiplayer_cons_t, Midiplayer_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_midisoundfontpath = {"midisoundfont", "sf2/8bitsf.SF2", CV_CALL|CV_NOINIT|CV_SAVE, NULL, MidiSoundfontPath_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_miditimiditypath = {"midisoundbank", "./timidity", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +#endif + +static void var_cleanup(void) +{ + song_length = loop_point = 0.0f; + music_bytes = fading_source = fading_target =\ + fading_timer = fading_duration = 0; + + songpaused = is_looping =\ + is_fading = false; + + // HACK: See music_loop, where we want the fade timing to proceed after a non-looping + // song has stopped playing + if (!fading_nocleanup) + fading_callback = NULL; + else + fading_nocleanup = false; // use it once, set it back immediately + + internal_volume = 100; +} /// ------------------------ /// Audio System /// ------------------------ void I_StartupSound(void) { - I_Assert(!sound_started); + //I_Assert(!sound_started); + if (sound_started) + return; #ifdef _WIN32 // Force DirectSound instead of WASAPI @@ -111,20 +248,34 @@ void I_StartupSound(void) return; } + fading_nocleanup = false; + + var_cleanup(); + music = NULL; music_volume = sfx_volume = 0; +#ifdef HAVE_MIXERX + Mix_SetMidiPlayer(cv_midiplayer.value); + Mix_SetSoundFonts(cv_midisoundfontpath.string); + Mix_Timidity_addToPathList(cv_miditimiditypath.string); +#endif #if SDL_MIXER_VERSION_ATLEAST(1,2,11) - Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG); + Mix_Init(MIX_INIT_FLAC|MIX_INIT_MP3|MIX_INIT_OGG|MIX_INIT_MOD); #endif - if (Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 2048) < 0) + if (Mix_OpenAudio(SAMPLERATE, AUDIO_S16SYS, 2, BUFFERSIZE) < 0) { CONS_Alert(CONS_ERROR, "Error starting SDL_Mixer: %s\n", Mix_GetError()); // call to start audio failed -- we do not have it return; } +#ifdef HAVE_OPENMPT + CONS_Printf("libopenmpt version: %s\n", openmpt_get_string("library_version")); + CONS_Printf("libopenmpt build date: %s\n", openmpt_get_string("build")); +#endif + sound_started = true; songpaused = false; Mix_AllocateChannels(256); @@ -147,6 +298,10 @@ void I_ShutdownSound(void) if (gme) gme_delete(gme); #endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + openmpt_module_destroy(openmpt_mhandle); +#endif } void I_UpdateSound(void) @@ -334,8 +489,9 @@ void *I_GetSfx(sfxinfo_t *sfx) gme_track_info(emu, &info, 0); len = (info->play_length * 441 / 10) << 2; - mem = malloc(len); + mem = Z_Malloc(len, PU_SOUND, 0); gme_play(emu, len >> 1, mem); + gme_free_info(info); gme_delete(emu); return Mix_QuickLoad_RAW((Uint8 *)mem, len); @@ -406,8 +562,9 @@ void *I_GetSfx(sfxinfo_t *sfx) gme_track_info(emu, &info, 0); len = (info->play_length * 441 / 10) << 2; - mem = malloc(len); + mem = Z_Malloc(len, PU_SOUND, 0); gme_play(emu, len >> 1, mem); + gme_free_info(info); gme_delete(emu); return Mix_QuickLoad_RAW((Uint8 *)mem, len); @@ -482,14 +639,110 @@ void I_SetSfxVolume(UINT8 volume) sfx_volume = volume; } +/// ------------------------ +/// Music Utilities +/// ------------------------ + +static UINT32 get_real_volume(UINT8 volume) +{ +#ifdef _WIN32 + if (I_SongType() == MU_MID) + // HACK: Until we stop using native MIDI, + // disable volume changes + return ((UINT32)31*128/31); // volume = 31 + else +#endif + // convert volume to mixer's 128 scale + // then apply internal_volume as a percentage + return ((UINT32)volume*128/31) * (UINT32)internal_volume / 100; +} + +static UINT32 get_adjusted_position(UINT32 position) +{ + // all in milliseconds + UINT32 length = I_GetSongLength(); + UINT32 looppoint = I_GetSongLoopPoint(); + if (length) + return position >= length ? (position % (length-looppoint)) : position; + else + return position; +} + +static void do_fading_callback(void) +{ + if (fading_callback) + (*fading_callback)(); + fading_callback = NULL; +} + /// ------------------------ /// Music Hooks /// ------------------------ +static void count_music_bytes(int chan, void *stream, int len, void *udata) +{ + (void)chan; + (void)stream; + (void)udata; + + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return; + music_bytes += len; +} + static void music_loop(void) { - Mix_PlayMusic(music, 0); - Mix_SetMusicPosition(loop_point); + if (is_looping) + { + Mix_PlayMusic(music, 0); + Mix_SetMusicPosition(loop_point); + music_bytes = (UINT32)(loop_point*44100.0L*4); //assume 44.1khz, 4-byte length (see I_GetSongPosition) + } + else + { + // HACK: Let fade timing proceed beyond the end of a + // non-looping song. This is a specific case where the timing + // should persist after stopping a song, so I don't believe + // this should apply every time the user stops a song. + // This is auto-unset in var_cleanup, called by I_StopSong + fading_nocleanup = true; + I_StopSong(); + } +} + +static UINT32 music_fade(UINT32 interval, void *param) +{ + (void)param; + + if (!is_fading || + internal_volume == fading_target || + fading_duration == 0) + { + I_StopFadingSong(); + do_fading_callback(); + return 0; + } + else if (songpaused) // don't decrement timer + return interval; + else if ((fading_timer -= 10) <= 0) + { + internal_volume = fading_target; + Mix_VolumeMusic(get_real_volume(music_volume)); + I_StopFadingSong(); + do_fading_callback(); + return 0; + } + else + { + UINT8 delta = abs(fading_target - fading_source); + fixed_t factor = FixedDiv(fading_duration - fading_timer, fading_duration); + if (fading_target < fading_source) + internal_volume = max(min(internal_volume, fading_source - FixedMul(delta, factor)), fading_target); + else if (fading_target > fading_source) + internal_volume = min(max(internal_volume, fading_source + FixedMul(delta, factor)), fading_target); + Mix_VolumeMusic(get_real_volume(music_volume)); + return interval; + } } #ifdef HAVE_LIBGME @@ -507,12 +760,39 @@ static void mix_gme(void *udata, Uint8 *stream, int len) // play gme into stream gme_play(gme, len/2, (short *)stream); + // Limiter to prevent music from being disorted with some formats + if (music_volume >= 18) + music_volume = 18; + // apply volume to stream for (i = 0, p = (short *)stream; i < len/2; i++, p++) - *p = ((INT32)*p) * music_volume*2 / 42; + *p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40; } #endif +#ifdef HAVE_OPENMPT +static void mix_openmpt(void *udata, Uint8 *stream, int len) +{ + int i; + short *p; + + (void)udata; + + if (!openmpt_mhandle || songpaused) + return; + + // Play module into stream + openmpt_module_read_interleaved_stereo(openmpt_mhandle, SAMPLERATE, BUFFERSIZE, (short *)stream); + + // Limiter to prevent music from being disorted with some formats + if (music_volume >= 18) + music_volume = 18; + + // apply volume to stream + for (i = 0, p = (short *)stream; i < len/2; i++, p++) + *p = ((INT32)*p) * (music_volume*internal_volume/100)*2 / 40; +} +#endif /// ------------------------ /// Music System @@ -537,11 +817,22 @@ musictype_t I_SongType(void) if (gme) return MU_GME; else +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + return MU_MOD_EX; #endif if (!music) return MU_NONE; else if (Mix_GetMusicType(music) == MUS_MID) + { +#ifdef HAVE_MIXERX + if (Mix_GetMidiPlayer() != MIDI_Native) + return MU_MID_EX; + else +#endif return MU_MID; + } else if (Mix_GetMusicType(music) == MUS_MOD || Mix_GetMusicType(music) == MUS_MODPLUG) return MU_MOD; else if (Mix_GetMusicType(music) == MUS_MP3 || Mix_GetMusicType(music) == MUS_MP3_MAD) @@ -555,6 +846,9 @@ boolean I_SongPlaying(void) return ( #ifdef HAVE_LIBGME (I_SongType() == MU_GME && gme) || +#endif +#ifdef HAVE_OPENMPT + (I_SongType() == MU_MOD_EX && openmpt_mhandle) || #endif music != NULL ); @@ -581,12 +875,250 @@ boolean I_SetSongSpeed(float speed) SDL_UnlockAudio(); return true; } + else +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + { + char modspd[13]; + + if (speed > 4.0f) + speed = 4.0f; // Limit this to 4x to prevent crashing, stupid fix but... ~SteelT 27/9/19 + + sprintf(modspd, "%g", speed); + openmpt_module_ctl_set(openmpt_mhandle, "play.tempo_factor", modspd); + return true; + } #else (void)speed; + return false; #endif return false; } +/// ------------------------ +/// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + INT32 length; + +#ifdef HAVE_LIBGME + if (gme) + { + gme_info_t *info; + gme_err_t gme_e = gme_track_info(gme, &info, current_track); + + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + length = 0; + } + else + { + // reconstruct info->play_length, from GME source + // we only want intro + 1 loop, not 2 + length = info->length; + if (length <= 0) + { + length = info->intro_length + info->loop_length; // intro + 1 loop + if (length <= 0) + length = 150 * 1000; // 2.5 minutes + } + } + + gme_free_info(info); + return max(length, 0); + } + else +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + return (UINT32)(openmpt_module_get_duration_seconds(openmpt_mhandle) * 1000.); + else +#endif + if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return 0; + else + { +#ifdef HAVE_MIXERX + double xlength = Mix_GetMusicTotalTime(music); + if (xlength >= 0) + return (UINT32)(xlength*1000); +#endif + // VERY IMPORTANT to set your LENGTHMS= in your song files, folks! + // SDL mixer can't read music length itself. + length = (UINT32)(song_length*1000); + if (!length) + CONS_Debug(DBG_DETAILED, "Getting music length: music is missing LENGTHMS= tag. Needed for seeking.\n"); + return length; + } +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + if (!music || I_SongType() == MU_GME || I_SongType() == MU_MOD || I_SongType() == MU_MID || !is_looping) + return false; + else + { + UINT32 length = I_GetSongLength(); + + if (length > 0) + looppoint %= length; + + loop_point = max((float)(looppoint / 1000.0L), 0); + return true; + } +} + +UINT32 I_GetSongLoopPoint(void) +{ +#ifdef HAVE_LIBGME + if (gme) + { + INT32 looppoint; + gme_info_t *info; + gme_err_t gme_e = gme_track_info(gme, &info, current_track); + + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + looppoint = 0; + } + else + looppoint = info->intro_length > 0 ? info->intro_length : 0; + + gme_free_info(info); + return max(looppoint, 0); + } + else +#endif + if (!music || I_SongType() == MU_MOD || I_SongType() == MU_MID) + return 0; + else + return (UINT32)(loop_point * 1000); +} + +boolean I_SetSongPosition(UINT32 position) +{ + UINT32 length; +#ifdef HAVE_LIBGME + if (gme) + { + // this is unstable, so fail silently + return true; + // this isn't required technically, but GME thread-locks for a second + // if you seek too high from the counter + // length = I_GetSongLength(); + // if (length) + // position = get_adjusted_position(position); + + // SDL_LockAudio(); + // gme_err_t gme_e = gme_seek(gme, position); + // SDL_UnlockAudio(); + + // if (gme_e != NULL) + // { + // CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + // return false; + // } + // else + // return true; + } + else +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + { + // This isn't 100% correct because we don't account for loop points because we can't get them. + // But if you seek past end of song, OpenMPT seeks to 0. So adjust the position anyway. + openmpt_module_set_position_seconds(openmpt_mhandle, (double)(get_adjusted_position(position)/1000.0L)); // returns new position + return true; + } + else +#endif + if (!music || I_SongType() == MU_MID) + return false; + else if (I_SongType() == MU_MOD) + return Mix_SetMusicPosition(position); // Goes by channels + else + { + // Because SDL mixer can't identify song length, if you have + // a position input greater than the real length, then + // music_bytes becomes inaccurate. + + length = I_GetSongLength(); // get it in MS + if (length) + position = get_adjusted_position(position); + + Mix_RewindMusic(); // needed for mp3 + if(Mix_SetMusicPosition((float)(position/1000.0L)) == 0) + music_bytes = (UINT32)(position/1000.0L*44100.0L*4); //assume 44.1khz, 4-byte length (see I_GetSongPosition) + else + // NOTE: This block fires on incorrect song format, + // NOT if position input is greater than song length. + music_bytes = 0; + + return true; + } +} + +UINT32 I_GetSongPosition(void) +{ +#ifdef HAVE_LIBGME + if (gme) + { + INT32 position = gme_tell(gme); + + gme_info_t *info; + gme_err_t gme_e = gme_track_info(gme, &info, current_track); + + if (gme_e != NULL) + { + CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); + return position; + } + else + { + // adjust position, since GME's counter keeps going past loop + if (info->length > 0) + position %= info->length; + else if (info->intro_length + info->loop_length > 0) + position = position >= (info->intro_length + info->loop_length) ? (position % info->loop_length) : position; + else + position %= 150 * 1000; // 2.5 minutes + } + + gme_free_info(info); + return max(position, 0); + } + else +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + // This will be incorrect if we adjust for length because we can't get loop points. + // So return unadjusted. See note in SetMusicPosition: we adjust for that. + return (UINT32)(openmpt_module_get_position_seconds(openmpt_mhandle)*1000.); + //return get_adjusted_position((UINT32)(openmpt_module_get_position_seconds(openmpt_mhandle)*1000.)); + else +#endif + if (!music || I_SongType() == MU_MID) + return 0; + else + { +#ifdef HAVE_MIXERX + double xposition = Mix_GetMusicPosition(music); + if (xposition >= 0) + return (UINT32)(xposition*1000); +#endif + return (UINT32)(music_bytes/44100.0L*1000.0L/4); //assume 44.1khz + // 4 = byte length for 16-bit samples (AUDIO_S16SYS), stereo (2-channel) + // This is hardcoded in I_StartupSound. Other formats for factor: + // 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4 + } +} + /// ------------------------ /// Music Playback /// ------------------------ @@ -605,10 +1137,16 @@ boolean I_LoadSong(char *data, size_t len) if (music #ifdef HAVE_LIBGME || gme +#endif +#ifdef HAVE_OPENMPT + || openmpt_mhandle #endif ) I_UnloadSong(); + // always do this whether or not a music already exists + var_cleanup(); + #ifdef HAVE_LIBGME if ((UINT8)data[0] == 0x1F && (UINT8)data[1] == 0x8B) @@ -705,8 +1243,45 @@ boolean I_LoadSong(char *data, size_t len) } #endif +#ifdef HAVE_MIXERX + if (Mix_GetMidiPlayer() != cv_midiplayer.value) + Mix_SetMidiPlayer(cv_midiplayer.value); + if (stricmp(Mix_GetSoundFonts(), cv_midisoundfontpath.string)) + Mix_SetSoundFonts(cv_midisoundfontpath.string); + Mix_Timidity_addToPathList(cv_miditimiditypath.string); // this overwrites previous custom path +#endif + +#ifdef HAVE_OPENMPT + /* + If the size of the data to be checked is bigger than the recommended size (> 2048 bytes) + Let's just set the probe size to the recommended size + Otherwise let's give it the full data size + */ + + if (len > openmpt_probe_file_header_get_recommended_size()) + probesize = openmpt_probe_file_header_get_recommended_size(); + else + probesize = len; + + result = openmpt_probe_file_header(OPENMPT_PROBE_FILE_HEADER_FLAGS_DEFAULT, data, probesize, len, NULL, NULL, NULL, NULL, NULL, NULL); + + if (result == OPENMPT_PROBE_FILE_HEADER_RESULT_SUCCESS) // We only cared if it succeeded, continue on if not. + { + openmpt_mhandle = openmpt_module_create_from_memory2(data, len, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + if (!openmpt_mhandle) // Failed to create module handle? Show error and return! + { + mod_err = openmpt_module_error_get_last(openmpt_mhandle); + mod_err_str = openmpt_error_string(mod_err); + CONS_Alert(CONS_ERROR, "openmpt_module_create_from_memory2: %s\n", mod_err_str); + return false; + } + else + return true; // All good and we're ready for music playback! + } +#endif + + // Let's see if Mixer is able to load this. rw = SDL_RWFromMem(data, len); - if (rw != NULL) { music = Mix_LoadMUS_RW(rw, 1); } @@ -718,30 +1293,35 @@ boolean I_LoadSong(char *data, size_t len) // Find the OGG loop point. loop_point = 0.0f; + song_length = 0.0f; while ((UINT32)(p - data) < len) { - if (strncmp(p++, key1, key1len)) - continue; - p += key1len-1; // skip OOP (the L was skipped in strncmp) - if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? + if (fpclassify(loop_point) == FP_ZERO && !strncmp(p, key1, key1len)) { - p += key2len; // skip POINT= - loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. - // because SDL_Mixer is USELESS and can't even tell us - // something simple like the frequency of the streaming music, - // we are unfortunately forced to assume that ALL MUSIC is 44100hz. - // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. + p += key1len; // skip LOOP + if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? + { + p += key2len; // skip POINT= + loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. + // because SDL_Mixer is USELESS and can't even tell us + // something simple like the frequency of the streaming music, + // we are unfortunately forced to assume that ALL MUSIC is 44100hz. + // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. + } + else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? + { + p += key3len; // skip MS= + loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds. + // Everything that uses LOOPMS will work perfectly with SDL_Mixer. + } } - else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? - { - p += key3len; // skip MS= - loop_point = (float)(atoi(p) / 1000.0L); // LOOPMS works by real time, as miliseconds. - // Everything that uses LOOPMS will work perfectly with SDL_Mixer. - } - // Neither?! Continue searching. - } + if (fpclassify(loop_point) != FP_ZERO) // Got what we needed + break; + else // continue searching + p++; + } return true; } @@ -755,6 +1335,13 @@ void I_UnloadSong(void) gme_delete(gme); gme = NULL; } +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + { + openmpt_module_destroy(openmpt_mhandle); + openmpt_mhandle = NULL; + } #endif if (music) { @@ -765,7 +1352,6 @@ void I_UnloadSong(void) boolean I_PlaySong(boolean looping) { - boolean lpz = fpclassify(loop_point) == FP_ZERO; #ifdef HAVE_LIBGME if (gme) { @@ -775,47 +1361,107 @@ boolean I_PlaySong(boolean looping) return true; } else +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + { + openmpt_module_select_subsong(openmpt_mhandle, 0); + openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value); + if (looping) + openmpt_module_set_repeat_count(openmpt_mhandle, -1); // Always repeat + current_subsong = 0; + Mix_HookMusic(mix_openmpt, openmpt_mhandle); + return true; + } + else #endif if (!music) return false; + if (fpclassify(song_length) == FP_ZERO && (I_SongType() == MU_OGG || I_SongType() == MU_MP3 || I_SongType() == MU_FLAC)) + CONS_Debug(DBG_DETAILED, "This song is missing a LENGTHMS= tag! Required to make seeking work properly.\n"); - if (Mix_PlayMusic(music, looping && lpz ? -1 : 0) == -1) + if (I_SongType() != MU_MOD && I_SongType() != MU_MID && Mix_PlayMusic(music, 0) == -1) + { + CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); + return false; + } + else if ((I_SongType() == MU_MOD || I_SongType() == MU_MID || I_SongType() == MU_MID_EX) && Mix_PlayMusic(music, looping ? -1 : 0) == -1) // if MOD, loop forever { CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); return false; } - Mix_VolumeMusic((UINT32)music_volume*128/31); - if (!lpz) - Mix_HookMusicFinished(music_loop); + is_looping = looping; + + I_SetMusicVolume(music_volume); + + if (I_SongType() != MU_MOD && I_SongType() != MU_MID && I_SongType() != MU_MID_EX) + Mix_HookMusicFinished(music_loop); // don't bother counting if MOD + + if(I_SongType() != MU_MOD && I_SongType() != MU_MID && I_SongType() != MU_MID_EX && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL)) + CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError()); + return true; } void I_StopSong(void) { + // HACK: See music_loop on why we want fade timing to proceed + // after end of song + if (!fading_nocleanup) + I_StopFadingSong(); + #ifdef HAVE_LIBGME if (gme) { Mix_HookMusic(NULL, NULL); current_track = -1; } +#endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + { + Mix_HookMusic(NULL, NULL); + current_subsong = -1; + } #endif if (music) { + Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes); Mix_HookMusicFinished(NULL); Mix_HaltMusic(); } + + var_cleanup(); } void I_PauseSong(void) { + if(I_SongType() == MU_MID) // really, SDL Mixer? why can't you pause MIDI??? + return; + + if(I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID) + Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes); + Mix_PauseMusic(); songpaused = true; } void I_ResumeSong(void) { + if (I_SongType() == MU_MID) + return; + + if (I_SongType() != MU_GME && I_SongType() != MU_MOD && I_SongType() != MU_MID) + { + while(Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes) != 0) { } + // HACK: fixes issue of multiple effect callbacks being registered + + if(music && I_SongType() != MU_MOD && I_SongType() != MU_MID && !Mix_RegisterEffect(MIX_CHANNEL_POST, count_music_bytes, NULL, NULL)) + CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError()); + } + Mix_ResumeMusic(); songpaused = false; } @@ -834,21 +1480,19 @@ void I_SetMusicVolume(UINT8 volume) #endif music_volume = volume; - Mix_VolumeMusic((UINT32)music_volume*128/31); + Mix_VolumeMusic(get_real_volume(music_volume)); } boolean I_SetSongTrack(int track) { #ifdef HAVE_LIBGME - if (current_track == track) - return false; - // If the specified track is within the number of tracks playing, then change it if (gme) { + if (current_track == track) + return false; SDL_LockAudio(); - if (track >= 0 - && track < gme_track_count(gme)) + if (track >= 0 && track < gme_track_count(gme)-1) { gme_err_t gme_e = gme_start_track(gme, track); if (gme_e != NULL) @@ -863,9 +1507,120 @@ boolean I_SetSongTrack(int track) SDL_UnlockAudio(); return false; } + else #endif +#ifdef HAVE_OPENMPT + if (openmpt_mhandle) + { + if (current_subsong == track) + return false; + SDL_LockAudio(); + if (track >= 0 && track < openmpt_module_get_num_subsongs(openmpt_mhandle)) + { + openmpt_module_select_subsong(openmpt_mhandle, track); + current_subsong = track; + SDL_UnlockAudio(); + return true; + } + SDL_UnlockAudio(); + + return false; + } +#endif + if (I_SongType() == MU_MOD) + return !Mix_SetMusicPosition(track); (void)track; return false; } +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + internal_volume = volume; + if (!I_SongPlaying()) + return; + Mix_VolumeMusic(get_real_volume(music_volume)); +} + +void I_StopFadingSong(void) +{ + if (fading_id) + SDL_RemoveTimer(fading_id); + is_fading = false; + fading_source = fading_target = fading_timer = fading_duration = fading_id = 0; + // don't unset fading_nocleanup here just yet; fading_callback is cleaned up + // in var_cleanup() +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)) +{ + INT16 volume_delta; + + source_volume = min(source_volume, 100); + volume_delta = (INT16)(target_volume - source_volume); + + I_StopFadingSong(); + + if (!ms && volume_delta) + { + I_SetInternalMusicVolume(target_volume); + if (callback) + (*callback)(); + return true; + + } + else if (!volume_delta) + { + if (callback) + (*callback)(); + return true; + } + + // Round MS to nearest 10 + // If n - lower > higher - n, then round up + ms = (ms - ((ms / 10) * 10) > (((ms / 10) * 10) + 10) - ms) ? + (((ms / 10) * 10) + 10) // higher + : ((ms / 10) * 10); // lower + + if (!ms) + I_SetInternalMusicVolume(target_volume); + else if (source_volume != target_volume) + { + fading_id = SDL_AddTimer(10, music_fade, NULL); + if (fading_id) + { + is_fading = true; + fading_timer = fading_duration = ms; + fading_source = source_volume; + fading_target = target_volume; + fading_callback = callback; + + if (internal_volume != source_volume) + I_SetInternalMusicVolume(source_volume); + } + } + + return is_fading; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) +{ + return I_FadeSongFromVolume(target_volume, internal_volume, ms, callback); +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + return I_FadeSongFromVolume(0, internal_volume, ms, &I_StopSong); +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + if (I_PlaySong(looping)) + return I_FadeSongFromVolume(100, 0, ms, NULL); + else + return false; +} #endif diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 4347b35b2..8da2126c8 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -2,6 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -94,10 +95,10 @@ boolean LoadGL(void) if (SDL_GL_LoadLibrary(OGLLibname) != 0) { - I_OutputMsg("Could not load OpenGL Library: %s\n" + CONS_Alert(CONS_ERROR, "Could not load OpenGL Library: %s\n" "Falling back to Software mode.\n", SDL_GetError()); if (!M_CheckParm ("-OGLlib")) - I_OutputMsg("If you know what is the OpenGL library's name, use -OGLlib\n"); + CONS_Alert(CONS_ERROR, "If you know what is the OpenGL library's name, use -OGLlib\n"); return 0; } @@ -127,15 +128,15 @@ boolean LoadGL(void) return SetupGLfunc(); else { - I_OutputMsg("Could not load GLU Library: %s\n", GLULibname); + CONS_Alert(CONS_ERROR, "Could not load GLU Library: %s\n", GLULibname); if (!M_CheckParm ("-GLUlib")) - I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n"); + CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n"); } } else { - I_OutputMsg("Could not load GLU Library\n"); - I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n"); + CONS_Alert(CONS_ERROR, "Could not load GLU Library\n"); + CONS_Alert(CONS_ERROR, "If you know what is the GLU library's name, use -GLUlib\n"); } #endif return SetupGLfunc(); @@ -221,20 +222,15 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_DrawScreenFinalTexture(realwidth, realheight); } -EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma) +EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette) { - INT32 i = -1; - UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green, - bluegamma = pgamma->s.blue; - - for (i = 0; i < 256; i++) + size_t palsize = (sizeof(RGBA_t) * 256); + // on a palette change, you have to reload all of the textures + if (memcmp(&myPaletteData, palette, palsize)) { - myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255); - myPaletteData[i].s.green = (UINT8)MIN((palette[i].s.green * greengamma)/127, 255); - myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255); - myPaletteData[i].s.alpha = palette[i].s.alpha; + memcpy(&myPaletteData, palette, palsize); + Flush(); } - Flush(); } #endif //HWRENDER diff --git a/src/sdl/ogl_sdl.h b/src/sdl/ogl_sdl.h index 2d6209f2b..748e30bae 100644 --- a/src/sdl/ogl_sdl.h +++ b/src/sdl/ogl_sdl.h @@ -2,6 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -30,5 +31,5 @@ extern Uint16 realwidth; extern Uint16 realheight; #ifdef _CREATE_DLL_ -EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma); +EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette); #endif diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 412102790..86e294fb5 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -2,6 +2,7 @@ //----------------------------------------------------------------------------- // // Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 2014-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -32,7 +33,7 @@ #endif #ifdef HAVE_MIXER -#include "SDL_mixer.h" +#include /* This is the version number macro for the current SDL_mixer version: */ #ifndef SDL_MIXER_COMPILEDVERSION #define SDL_MIXER_COMPILEDVERSION \ @@ -1375,6 +1376,37 @@ boolean I_SetSongSpeed(float speed) return false; } +/// ------------------------ +// MUSIC SEEKING +/// ------------------------ + +UINT32 I_GetSongLength(void) +{ + return 0; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + (void)position; + return false; +} + +UINT32 I_GetSongPosition(void) +{ + return 0; +} + /// ------------------------ // MUSIC PLAYBACK /// ------------------------ @@ -1400,6 +1432,8 @@ static void I_ResumeGME(void) boolean I_LoadSong(char *data, size_t len) { + (void)data; + (void)len; return false; } @@ -1443,6 +1477,49 @@ boolean I_SetSongTrack(int track) return false; } +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)) +{ + (void)target_volume; + (void)source_volume; + (void)ms; + (void)callback; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) +{ + (void)target_volume; + (void)ms; + (void)callback; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} + /// ------------------------ // MUSIC LOADING AND CLEANUP // \todo Split logic between loading and playing, @@ -1505,4 +1582,4 @@ static boolean I_StartGMESong(const char *musicname, boolean looping) } #endif -#endif //HAVE_SDL \ No newline at end of file +#endif //HAVE_SDL diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index d12daaa8a..e35506114 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// Copyright (C) 2006-2018 by Sonic Team Jr. +// Copyright (C) 2006-2020 by Sonic Team Junior. // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -31,6 +31,9 @@ extern SDL_bool framebuffer; #define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__) #endif +// So m_menu knows whether to store cv_usejoystick value or string +#define JOYSTICK_HOTPLUG + /** \brief The JoyInfo_s struct info about joystick @@ -67,6 +70,13 @@ extern SDLJoyInfo_t JoyInfo; */ extern SDLJoyInfo_t JoyInfo2; +// So we can call this from i_video event loop +void I_ShutdownJoystick(void); +void I_ShutdownJoystick2(void); + +// Cheat to get the device index for a joystick handle +INT32 I_GetJoystickDeviceIndex(SDL_Joystick *dev); + void I_GetConsoleEvents(void); void SDLforceUngrabMouse(void); diff --git a/src/sdl/srb2icon.png b/src/sdl/srb2icon.png deleted file mode 100644 index cdee18a84..000000000 Binary files a/src/sdl/srb2icon.png and /dev/null differ diff --git a/src/sdl12/IMG_xpm.c b/src/sdl12/IMG_xpm.c deleted file mode 100644 index e08736d66..000000000 --- a/src/sdl12/IMG_xpm.c +++ /dev/null @@ -1,506 +0,0 @@ -/* - SDL_image: An example image loading library for use with SDL - Copyright (C) 1999-2004 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* $Id: IMG_xpm.c,v 1.10 2004/01/04 22:04:38 slouken Exp $ */ - -/* - * XPM (X PixMap) image loader: - * - * Supports the XPMv3 format, EXCEPT: - * - hotspot coordinates are ignored - * - only colour ('c') colour symbols are used - * - rgb.txt is not used (for portability), so only RGB colours - * are recognized (#rrggbb etc) - only a few basic colour names are - * handled - * - * The result is an 8bpp indexed surface if possible, otherwise 32bpp. - * The colourkey is correctly set if transparency is used. - * - * Besides the standard API, also provides - * - * SDL_Surface *IMG_ReadXPMFromArray(char **xpm) - * - * that reads the image data from an XPM file included in the C source. - * - * TODO: include rgb.txt here. The full table (from solaris 2.6) only - * requires about 13K in binary form. - */ - -#include -#include -#include -#include - -//#include "SDL_image.h" - - -#ifdef LOAD_XPM - -/* See if an image is contained in a data source */ -#if 0 -int IMG_isXPM(SDL_RWops *src) -{ - char magic[9]; - - return (SDL_RWread(src, magic, sizeof (magic), 1) - && memcmp(magic, "/* XPM */", 9) == 0); -} -#endif - -/* Hash table to look up colors from pixel strings */ -#define STARTING_HASH_SIZE 256 - -struct hash_entry { - char *key; - Uint32 color; - struct hash_entry *next; -}; - -struct color_hash { - struct hash_entry **table; - struct hash_entry *entries; /* array of all entries */ - struct hash_entry *next_free; - size_t size; - int maxnum; -}; - -static int hash_key(const char *key, int cpp, size_t size) -{ - int hash; - - hash = 0; - while ( cpp-- > 0 ) { - hash = hash * 33 + *key++; - } - return (int)(hash & (size - 1)); -} - -static struct color_hash *create_colorhash(int maxnum) -{ - size_t bytes; - int s; - struct color_hash *hash; - - /* we know how many entries we need, so we can allocate - everything here */ - hash = malloc(sizeof *hash); - if (!hash) - return NULL; - - /* use power-of-2 sized hash table for decoding speed */ - for (s = STARTING_HASH_SIZE; s < maxnum; s <<= 1) - ; - hash->size = s; - hash->maxnum = maxnum; - bytes = hash->size * sizeof (struct hash_entry **); - hash->entries = NULL; /* in case malloc fails */ - hash->table = malloc(bytes); - if (!hash->table) - return NULL; - memset(hash->table, 0, bytes); - hash->entries = malloc(maxnum * sizeof (struct hash_entry)); - if (!hash->entries) - { - free(hash->table); - return NULL; - } - hash->next_free = hash->entries; - return hash; -} - -static int add_colorhash(struct color_hash *hash, - char *key, int cpp, Uint32 color) -{ - const int indexkey = hash_key(key, cpp, hash->size); - struct hash_entry *e = hash->next_free++; - e->color = color; - e->key = key; - e->next = hash->table[indexkey]; - hash->table[indexkey] = e; - return 1; -} - -/* fast lookup that works if cpp == 1 */ -#define QUICK_COLORHASH(hash, key) ((hash)->table[*(const Uint8 *)(key)]->color) - -static Uint32 get_colorhash(struct color_hash *hash, const char *key, int cpp) -{ - struct hash_entry *entry = hash->table[hash_key(key, cpp, hash->size)]; - while (entry) { - if (memcmp(key, entry->key, cpp) == 0) - return entry->color; - entry = entry->next; - } - return 0; /* garbage in - garbage out */ -} - -static void free_colorhash(struct color_hash *hash) -{ - if (hash && hash->table) { - free(hash->table); - free(hash->entries); - free(hash); - } -} - -/* portable case-insensitive string comparison */ -static int string_equal(const char *a, const char *b, size_t n) -{ - while (*a && *b && n) { - if (toupper((unsigned char)*a) != toupper((unsigned char)*b)) - return 0; - a++; - b++; - n--; - } - return *a == *b; -} - -#undef ARRAYSIZE -#define ARRAYSIZE(a) (int)(sizeof (a) / sizeof ((a)[0])) - -/* - * convert colour spec to RGB (in 0xrrggbb format). - * return 1 if successful. - */ -static int color_to_rgb(const char *spec, size_t speclen, Uint32 *rgb) -{ - /* poor man's rgb.txt */ - static struct { const char *name; Uint32 rgb; } known[] = { - {"none", 0xffffffff}, - {"black", 0x00000000}, - {"white", 0x00ffffff}, - {"red", 0x00ff0000}, - {"green", 0x0000ff00}, - {"blue", 0x000000ff} - }; - - if (spec[0] == '#') { - char buf[7]; - switch (speclen) { - case 4: - buf[0] = buf[1] = spec[1]; - buf[2] = buf[3] = spec[2]; - buf[4] = buf[5] = spec[3]; - break; - case 7: - memcpy(buf, spec + 1, 6); - break; - case 13: - buf[0] = spec[1]; - buf[1] = spec[2]; - buf[2] = spec[5]; - buf[3] = spec[6]; - buf[4] = spec[9]; - buf[5] = spec[10]; - break; - } - buf[6] = '\0'; - *rgb = (Uint32)strtol(buf, NULL, 16); - return 1; - } else { - int i; - for (i = 0; i < ARRAYSIZE(known); i++) - if (string_equal(known[i].name, spec, speclen)) { - *rgb = known[i].rgb; - return 1; - } - return 0; - } -} - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -static char *linebuf; -static int buflen; -static const char *error; - -/* - * Read next line from the source. - * If len > 0, it's assumed to be at least len chars (for efficiency). - * Return NULL and set error upon EOF or parse error. - */ -static const char *get_next_line(const char ***lines, SDL_RWops *src, int len) -{ - char *linebufnew; - if (lines) { - return *(*lines)++; - } else { - char c; - int n; - do { - if (SDL_RWread(src, &c, 1, 1) <= 0) { - error = "Premature end of data"; - return NULL; - } - } while (c != '"'); - if (len) { - len += 4; /* "\",\n\0" */ - if (len > buflen){ - buflen = len; - linebufnew = realloc(linebuf, buflen); - if(!linebufnew) { - free(linebuf); - error = "Out of memory"; - return NULL; - } - linebuf = linebufnew; - } - if (SDL_RWread(src, linebuf, len - 1, 1) <= 0) { - error = "Premature end of data"; - return NULL; - } - n = len - 2; - } else { - n = 0; - do { - if (n >= buflen - 1) { - if (buflen == 0) - buflen = 16; - buflen *= 2; - linebufnew = realloc(linebuf, buflen); - if(!linebufnew) { - free(linebuf); - error = "Out of memory"; - return NULL; - } - linebuf = linebufnew; - } - if (SDL_RWread(src, linebuf + n, 1, 1) <= 0) { - error = "Premature end of data"; - return NULL; - } - } while (linebuf[n++] != '"'); - n--; - } - linebuf[n] = '\0'; - return linebuf; - } -} - -#define SKIPSPACE(p) \ -do { \ - while (isspace((unsigned char)*(p))) \ - ++(p); \ -} while (0) - -#define SKIPNONSPACE(p) \ -do { \ - while (!isspace((unsigned char)*(p)) && *p) \ - ++(p); \ -} while (0) - -/* read XPM from either array or RWops */ -static SDL_Surface *load_xpm(const char **xpm, SDL_RWops *src) -{ - SDL_Surface *image = NULL; - int indexc; - int x, y; - int w, h, ncolors, cpp; - int indexed; - Uint8 *dst; - struct color_hash *colors = NULL; - SDL_Color *im_colors = NULL; - char *keystrings = NULL, *nextkey; - const char *line; - const char ***xpmlines = NULL; - int pixels_len; - - error = NULL; - linebuf = NULL; - buflen = 0; - - if (xpm) - xpmlines = &xpm; - - line = get_next_line(xpmlines, src, 0); - if (!line) - goto done; - /* - * The header string of an XPMv3 image has the format - * - * [ ] - * - * where the hotspot coords are intended for mouse cursors. - * Right now we don't use the hotspots but it should be handled - * one day. - */ - if (sscanf(line, "%d %d %d %d", &w, &h, &ncolors, &cpp) != 4 - || w <= 0 || h <= 0 || ncolors <= 0 || cpp <= 0) { - error = "Invalid format description"; - goto done; - } - - keystrings = malloc(ncolors * cpp); - if (!keystrings) { - error = "Out of memory"; - goto done; - } - nextkey = keystrings; - - /* Create the new surface */ - if (ncolors <= 256) { - indexed = 1; - image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 8, - 0, 0, 0, 0); - im_colors = image->format->palette->colors; - image->format->palette->ncolors = ncolors; - } else { - indexed = 0; - image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, - 0xff0000, 0x00ff00, 0x0000ff, 0); - } - if (!image) { - /* Hmm, some SDL error (out of memory?) */ - goto done; - } - - /* Read the colors */ - colors = create_colorhash(ncolors); - if (!colors) { - error = "Out of memory"; - goto done; - } - for (indexc = 0; indexc < ncolors; ++indexc ) { - const char *p; - line = get_next_line(xpmlines, src, 0); - if (!line) - goto done; - - p = line + cpp + 1; - - /* parse a colour definition */ - for (;;) { - char nametype; - const char *colname; - Uint32 rgb, pixel; - - SKIPSPACE(p); - if (!*p) { - error = "colour parse error"; - goto done; - } - nametype = *p; - SKIPNONSPACE(p); - SKIPSPACE(p); - colname = p; - SKIPNONSPACE(p); - if (nametype == 's') - continue; /* skip symbolic colour names */ - - if (!color_to_rgb(colname, p - colname, &rgb)) - continue; - - memcpy(nextkey, line, cpp); - if (indexed) { - SDL_Color *c = im_colors + indexc; - c->r = (Uint8)(rgb >> 16); - c->g = (Uint8)(rgb >> 8); - c->b = (Uint8)(rgb); - pixel = indexc; - } else - pixel = rgb; - add_colorhash(colors, nextkey, cpp, pixel); - nextkey += cpp; - if (rgb == 0xffffffff) - SDL_SetColorKey(image, SDL_SRCCOLORKEY, pixel); - break; - } - } - - /* Read the pixels */ - pixels_len = w * cpp; - dst = image->pixels; - for (y = 0; y < h; y++) { - line = get_next_line(xpmlines, src, pixels_len); - if (indexed) { - /* optimization for some common cases */ - if (cpp == 1) - for (x = 0; x < w; x++) - dst[x] = (Uint8)QUICK_COLORHASH(colors, - line + x); - else - for (x = 0; x < w; x++) - dst[x] = (Uint8)get_colorhash(colors, - line + x * cpp, - cpp); - } else { - for (x = 0; x < w; x++) - ((Uint32*)dst)[x] = get_colorhash(colors, - line + x * cpp, - cpp); - } - dst += image->pitch; - } - -done: - if (error) { - SDL_FreeSurface(image); - image = NULL; - SDL_SetError(error); - } - free(keystrings); - free_colorhash(colors); - free(linebuf); - return(image); -} - -/* Load a XPM type image from an RWops datasource */ -#if 0 -SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) -{ - if ( !src ) { - /* The error message has been set in SDL_RWFromFile */ - return NULL; - } - return load_xpm(NULL, src); -} -#endif - -static inline SDL_Surface *IMG_ReadXPMFromArray(const char **xpm) -{ - return load_xpm(xpm, NULL); -} - -#else /* not LOAD_XPM */ - -/* See if an image is contained in a data source */ -#if 0 -int IMG_isXPM(SDL_RWops *src) -{ - return(0); -} - -/* Load a XPM type image from an SDL datasource */ -SDL_Surface *IMG_LoadXPM_RW(SDL_RWops *src) -{ - return(NULL); -} -#endif - -static inline SDL_Surface *IMG_ReadXPMFromArray(const char **xpm) -{ - return NULL; -} -#endif /* not LOAD_XPM */ diff --git a/src/sdl12/MakeCYG.cfg b/src/sdl12/MakeCYG.cfg deleted file mode 100644 index b55d9dc50..000000000 --- a/src/sdl12/MakeCYG.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# -# sdl12/makeCYG.cfg for SRB2/Cygwin -# - -# -#Cygwin, for debugging - - NOHW=1 - NOHS=1 - NOASM=1 - - OPTS+=-DLINUX - - i_system_o+=$(OBJDIR)/SRB2.res - - # name of the exefile - EXENAME?=lsdlsrb2.exe diff --git a/src/sdl12/MakeNIX.cfg b/src/sdl12/MakeNIX.cfg deleted file mode 100644 index 1278aaf06..000000000 --- a/src/sdl12/MakeNIX.cfg +++ /dev/null @@ -1,92 +0,0 @@ -# -# sdl12/makeNIX.cfg for SRB2/?nix -# - -#Valgrind support -ifdef VALGRIND -VALGRIND_PKGCONFIG?=valgrind -VALGRIND_CFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --cflags) -VALGRIND_LDFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --libs) -ZDEBUG=1 -LIBS+=$(VALGRIND_LDFLAGS) -ifdef GCC46 -WFLAGS+=-Wno-error=unused-but-set-variable -WFLAGS+=-Wno-unused-but-set-variable -endif -endif - -# -#here is GNU/Linux and other -# - - OPTS=-DUNIXCOMMON - - #LDFLAGS = -L/usr/local/lib - LIBS=-lm -ifdef LINUX - LIBS+=-lrt -ifdef NOTERMIOS - OPTS+=-DNOTERMIOS -endif -endif - -# -#here is Solaris -# -ifdef SOLARIS - NOIPX=1 - NOASM=1 - OPTS+=-DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP - OPTS+=-I/usr/local/include -I/opt/sfw/include - LDFLAGS+=-L/opt/sfw/lib - LIBS+=-lsocket -lnsl -endif - -# -#here is FreeBSD -# -ifdef FREEBSD - OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include - SDL_CONFIG?=sdl11-config - LDFLAGS+=-L/usr/X11R6/lib - LIBS+=-lipx -lkvm -endif - -# -#here is GP2x (arm-gp2x-linux) -# -ifdef GP2X - PNG_CONFIG?=$(PREFIX)-libpng12-config -ifdef STATIC #need a better setting name - CFLAGS+=-I$(OPEN2X)/include -ifndef NOMIXER - LIBS+=-lvorbisidec -ifdef MIKMOD - LIBS+=-lmikmod -endif -ifdef SMPEGLIB - LIBS+=-lsmpeg - LD=$(CXX) -endif -endif - NONET=1 -endif -ifndef ARCHNAME -"error" -endif - NONX86=1 - NOHW=1 - NOHS=1 - NOMD5=1 - WFLAGS+=-O0 - OPTS+=-DGP2X -ffast-math -mcpu=arm920t - EXENAME?=SRB2GP2X.gpe -endif - -ifndef NOHW - OPTS+=-I/usr/X11R6/include - LDFLAGS+=-L/usr/X11R6/lib -endif - - # name of the exefile - EXENAME?=lsdlsrb2 diff --git a/src/sdl12/Makefile.cfg b/src/sdl12/Makefile.cfg deleted file mode 100644 index 8d9ebc35c..000000000 --- a/src/sdl12/Makefile.cfg +++ /dev/null @@ -1,163 +0,0 @@ -# -# sdl12/makefile.cfg for SRB2/SDL -# - -# -#SDL...., *looks at Alam*, THIS IS A MESS! -# - -ifdef UNIXCOMMON -include sdl12/MakeNIX.cfg -endif - -ifdef PANDORA -include sdl12/SRB2Pandora/Makefile.cfg -endif #ifdef PANDORA - -ifdef DC -include sdl12/SRB2DC/Makefile.cfg -endif #ifdef DC - -ifdef PS3N -include sdl12/SRB2PS3/Makefile.cfg -endif #ifdef PS3N - -ifdef PSP -include sdl12/SRB2PSP/Makefile.cfg -endif #ifdef PSP - -ifdef XBOX -include sdl12/SRB2XBOX/Makefile.cfg -endif #ifdef XBOX - -ifdef WINCE -include sdl12/SRB2CE/Makefile.cfg -endif #ifef WINCE - -ifdef CYGWIN32 -include sdl12/MakeCYG.cfg -endif #ifdef CYGWIN32 - -ifdef SDL_PKGCONFIG -SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags) -SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs) -else -ifdef PREFIX - SDL_CONFIG?=$(PREFIX)-sdl-config -else - SDL_CONFIG?=sdl-config -endif - -ifdef STATIC - SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) - SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --static-libs) -else - SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) - SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --libs) -endif -endif - - - #use the x86 asm code -ifndef CYGWIN32 -ifndef NOASM - USEASM=1 -endif -endif - - OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o - - OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL - -ifndef NOHW - OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o -endif - -ifndef NOHS -ifdef OPENAL - OBJS+=$(OBJDIR)/s_openal.o - OPTS+=-DSTATIC3DS - STATICHS=1 -else -ifdef FMOD - OBJS+=$(OBJDIR)/s_fmod.o - OPTS+=-DSTATIC3DS - STATICHS=1 -else -ifdef MINGW -ifdef DS3D - OBJS+=$(OBJDIR)/s_ds3d.o - OPTS+=-DSTATIC3DS - STATICHS=1 -endif -endif -endif -endif -endif - -ifdef FILTERS - OBJS+=$(OBJDIR)/filters.o $(OBJDIR)/hq2x.o $(OBJDIR)/lq2x.o - OPTS+=-DHAVE_FILTER -endif - -ifdef NOMIXER - i_sound_o=$(OBJDIR)/sdl_sound.o -else - i_sound_o=$(OBJDIR)/mixer_sound.o - OPTS+=-DHAVE_MIXER - SDL_LDFLAGS+=-lSDL_mixer -endif - -ifdef SDL_TTF - OPTS+=-DHAVE_TTF - SDL_LDFLAGS+=-lSDL_ttf -lfreetype -lz - OBJS+=$(OBJDIR)/i_ttf.o -endif - -#ifdef SDL_IMAGE -# OPTS+=-DHAVE_IMAGE -# SDL_LDFLAGS+=-lSDL_image -#endif - -ifdef SDL_NET - OPTS+=-DHAVE_SDLNET - SDL_LDFLAGS+=-lSDL_net -endif - -ifdef SDLMAIN - OPTS+=-DSDLMAIN -else -ifdef MINGW - SDL_CFLAGS+=-Umain - SDL_LDFLAGS+=-mconsole -endif -endif - -ifndef NOHW -ifdef OPENAL -ifdef MINGW - LIBS:=-lopenal32 $(LIBS) -else - LIBS:=-lopenal $(LIBS) -endif -else -ifdef MINGW -ifdef DS3D - LIBS:=-ldsound -luuid $(LIBS) -endif -endif -endif -endif - -# FIXME: DevkitPPC and ready-compiled SDL Wii require these things to be in a silly order -ifdef WII -include sdl12/SRB2WII/Makefile.cfg -endif #ifdef WII - -CFLAGS+=$(SDL_CFLAGS) -LIBS:=$(SDL_LDFLAGS) $(LIBS) -ifndef WII -ifdef STATIC - LIBS+=$(shell $(SDL_CONFIG) --static-libs) -endif -endif diff --git a/src/sdl12/SDL_icon.xpm b/src/sdl12/SDL_icon.xpm deleted file mode 100644 index cf72960df..000000000 --- a/src/sdl12/SDL_icon.xpm +++ /dev/null @@ -1,425 +0,0 @@ -/* XPM */ -static char * C:\Repo\srb2\src\sdl\SDL_icon_xpm[] = { -"32 32 390 2", -" c None", -". c #4F4F70", -"+ c #4D4D87", -"@ c #4D4D84", -"# c #4E4E6C", -"$ c #6C6C95", -"% c #5E5EB2", -"& c #6B6BE7", -"* c #7373F9", -"= c #7C7CFF", -"- c #6F70E7", -"; c #494BB2", -"> c #4F4FA3", -", c #6464D4", -"' c #7979F5", -") c #5F5FCA", -"! c #5D5D93", -"~ c #3A3A9F", -"{ c #6060AC", -"] c #777793", -"^ c #5C5CB3", -"/ c #7373EA", -"( c #7A7AFF", -"_ c #7575FF", -": c #7979FF", -"< c #6264DD", -"[ c #47478C", -"} c #564567", -"| c #4647D0", -"1 c #5C5CAE", -"2 c #5E5EFF", -"3 c #2929FF", -"4 c #1D1DFF", -"5 c #1919D1", -"6 c #4F4F90", -"7 c #1E1ECE", -"8 c #5858FF", -"9 c #6767A8", -"0 c #4949A0", -"a c #7070FB", -"b c #7D7DFF", -"c c #7777FF", -"d c #7373FF", -"e c #7272FF", -"f c #7878FF", -"g c #6465D8", -"h c #363886", -"i c #9F7655", -"j c #C89B5C", -"k c #1D1CB7", -"l c #3031B1", -"m c #1919F4", -"n c #1111FF", -"o c #1818FF", -"p c #1B1BFF", -"q c #1C1CFF", -"r c #2626B3", -"s c #1E1EC8", -"t c #1A1AE8", -"u c #24249F", -"v c #2F2FD2", -"w c #7676FF", -"x c #6869E2", -"y c #414290", -"z c #8C6751", -"A c #FCBA68", -"B c #E9BD7D", -"C c #201EB8", -"D c #090AB8", -"E c #1616EB", -"F c #1818FD", -"G c #1414EE", -"H c #1010E1", -"I c #0E0EE2", -"J c #0E0EF4", -"K c #0606B2", -"L c #7A7A89", -"M c #0C0C9A", -"N c #0A0AA7", -"O c #2424E4", -"P c #6669E6", -"Q c #4F4A8F", -"R c #BF853B", -"S c #FFD98D", -"T c #CDAB76", -"U c #1717C4", -"V c #0F10BA", -"W c #0909B6", -"X c #0505C3", -"Y c #0000B6", -"Z c #0000BE", -"` c #0000AD", -" . c #1D1D83", -".. c #63638E", -"+. c #090975", -"@. c #1414F3", -"#. c #5B5BFF", -"$. c #7B7BFF", -"%. c #7070FF", -"&. c #6E6EFF", -"*. c #7172F6", -"=. c #625DAF", -"-. c #BA9E6C", -";. c #887167", -">. c #090DF2", -",. c #1313BE", -"'. c #000085", -"). c #0000AC", -"!. c #0202AA", -"~. c #242488", -"{. c #1414C7", -"]. c #1717FF", -"^. c #5959FF", -"/. c #7F7FFF", -"(. c #7474FF", -"_. c #7171FF", -":. c #8686FF", -"<. c #7574FF", -"[. c #797CFF", -"}. c #5756B8", -"|. c #1C19A4", -"1. c #1617FF", -"2. c #1212BD", -"3. c #040485", -"4. c #0707A4", -"5. c #1B1B71", -"6. c #373797", -"7. c #1616FF", -"8. c #5050FF", -"9. c #8080FF", -"0. c #AAAAFF", -"a. c #AEAEF6", -"b. c #8A8AEF", -"c. c #6969FB", -"d. c #2728FF", -"e. c #1314FF", -"f. c #1919FF", -"g. c #1313E8", -"h. c #1F1FF4", -"i. c #5454FF", -"j. c #6D6DF0", -"k. c #6868B5", -"l. c #0B0BB8", -"m. c #1212C5", -"n. c #1616FC", -"o. c #1515FF", -"p. c #1212FF", -"q. c #2323FF", -"r. c #3636FF", -"s. c #4040FF", -"t. c #4343F9", -"u. c #5D5DB8", -"v. c #7F7F92", -"w. c #878793", -"x. c #4B4B94", -"y. c #0B0CE2", -"z. c #1313FF", -"A. c #4C4CFF", -"B. c #8282FF", -"C. c #7171ED", -"D. c #636394", -"E. c #575785", -"F. c #A9A99C", -"G. c #1414BC", -"H. c #1414FF", -"I. c #0707FD", -"J. c #2525AA", -"K. c #A8A8A4", -"L. c #EBEBE2", -"M. c #F9F9F2", -"N. c #E1E1CC", -"O. c #4D4D9F", -"P. c #0B0BF7", -"Q. c #2121FF", -"R. c #3232FF", -"S. c #5555FF", -"T. c #6161B4", -"U. c #B5B5B2", -"V. c #FFFFF8", -"W. c #4F4F9A", -"X. c #0B0BF5", -"Y. c #1616C5", -"Z. c #A8A8A1", -"`. c #FFFFFC", -" + c #FFFFFF", -".+ c #C0C0C4", -"++ c #1212D4", -"@+ c #4444FF", -"#+ c #6464FF", -"$+ c #8383FF", -"%+ c #6767C3", -"&+ c #E4E4E4", -"*+ c #9494AE", -"=+ c #0808DF", -"-+ c #0D0DF2", -";+ c #61619A", -">+ c #F1F1E0", -",+ c #E8E8DD", -"'+ c #2424BB", -")+ c #1010FF", -"!+ c #3434FF", -"~+ c #6161FF", -"{+ c #6969D2", -"]+ c #EFEFF0", -"^+ c #C2C2BA", -"/+ c #1010B6", -"(+ c #0909AC", -"_+ c #A4A49A", -":+ c #EAEADE", -"<+ c #2525B8", -"[+ c #2F2FFF", -"}+ c #3C3CB5", -"|+ c #EEEEEE", -"1+ c #BBBBAD", -"2+ c #0B0B56", -"3+ c #0B0BFC", -"4+ c #1212EF", -"5+ c #0C0C3E", -"6+ c #919187", -"7+ c #DEDED6", -"8+ c #1F1FC0", -"9+ c #1A1AFF", -"0+ c #1717FA", -"a+ c #1515F8", -"b+ c #1111FC", -"c+ c #494992", -"d+ c #999998", -"e+ c #3E3E3B", -"f+ c #3C3C99", -"g+ c #535397", -"h+ c #5A5A4D", -"i+ c #6F6F70", -"j+ c #BFBFC9", -"k+ c #1111D6", -"l+ c #1515F1", -"m+ c #0F0FE2", -"n+ c #0D0DD9", -"o+ c #0909CD", -"p+ c #0808C7", -"q+ c #0505C7", -"r+ c #0303CB", -"s+ c #0101C0", -"t+ c #0202AF", -"u+ c #0606AC", -"v+ c #121283", -"w+ c #BBBBBB", -"x+ c #BEBEBE", -"y+ c #2F2F2E", -"z+ c #C7C8BB", -"A+ c #D8DAD1", -"B+ c #272828", -"C+ c #929292", -"D+ c #8688C7", -"E+ c #0506F6", -"F+ c #1616F5", -"G+ c #0B0BD3", -"H+ c #0202B6", -"I+ c #0000AF", -"J+ c #0000B4", -"K+ c #0000BD", -"L+ c #0000BB", -"M+ c #00009E", -"N+ c #2C2C7E", -"O+ c #6A6A8B", -"P+ c #959595", -"Q+ c #F0F0F1", -"R+ c #E1E1E1", -"S+ c #8C8E90", -"T+ c #BEBEBF", -"U+ c #C9C7C5", -"V+ c #939699", -"W+ c #E7EAED", -"X+ c #CBCBC7", -"Y+ c #413B9B", -"Z+ c #0607DD", -"`+ c #0C0CE2", -" @ c #0303B9", -".@ c #0000A8", -"+@ c #181888", -"@@ c #6A6A6A", -"#@ c #626263", -"$@ c #4B4B4C", -"%@ c #3E3B36", -"&@ c #9B805C", -"*@ c #D9B07D", -"=@ c #C9AE89", -"-@ c #B9AF9E", -";@ c #C7C5C4", -">@ c #CBCCCF", -",@ c #C7C6C6", -"'@ c #AEA59A", -")@ c #B69974", -"!@ c #D8B87F", -"~@ c #9B8272", -"{@ c #0E0B9B", -"]@ c #0000B7", -"^@ c #0000B8", -"/@ c #000082", -"(@ c #00007A", -"_@ c #636379", -":@ c #62533E", -"<@ c #B59B6C", -"[@ c #DEB07B", -"}@ c #FECC90", -"|@ c #FFCE92", -"1@ c #FEC98C", -"2@ c #F1BD82", -"3@ c #D1A979", -"4@ c #BC9E73", -"5@ c #CCA777", -"6@ c #EAB980", -"7@ c #FFCD90", -"8@ c #FFD595", -"9@ c #FDD782", -"0@ c #413678", -"a@ c #0000AE", -"b@ c #000077", -"c@ c #010193", -"d@ c #0C0CE4", -"e@ c #38389E", -"f@ c #EEC585", -"g@ c #FFDA9D", -"h@ c #FFC992", -"i@ c #FFC88F", -"j@ c #FFC990", -"k@ c #FFCE93", -"l@ c #FFD094", -"m@ c #FFCC92", -"n@ c #C9A174", -"o@ c #EDBD88", -"p@ c #FAD287", -"q@ c #3A2F7F", -"r@ c #0000BA", -"s@ c #0000B0", -"t@ c #0101B2", -"u@ c #1111ED", -"v@ c #1919C1", -"w@ c #95887C", -"x@ c #DCAC6E", -"y@ c #FFD393", -"z@ c #FFCD94", -"A@ c #FFCA93", -"B@ c #FFC991", -"C@ c #FFC78E", -"D@ c #FFCB91", -"E@ c #E0B581", -"F@ c #BB9A6F", -"G@ c #FFDC97", -"H@ c #C1A173", -"I@ c #0E0B9A", -"J@ c #0000B5", -"K@ c #0101B6", -"L@ c #1010E0", -"M@ c #1616EC", -"N@ c #A68156", -"O@ c #E7AC6B", -"P@ c #FFC582", -"Q@ c #FFCF8F", -"R@ c #FFD195", -"S@ c #FFD296", -"T@ c #FFD396", -"U@ c #FFD193", -"V@ c #FFD28F", -"W@ c #D2A96B", -"X@ c #2F2482", -"Y@ c #0000C1", -"Z@ c #0000C0", -"`@ c #0000BF", -" # c #0101BF", -".# c #1212F0", -"+# c #767698", -"@# c #9C866E", -"## c #A9865D", -"$# c #C0915D", -"%# c #C89760", -"&# c #C29360", -"*# c #AD8A61", -"=# c #9D8971", -"-# c #7F7A7A", -";# c #70708F", -"># c #6F6F91", -",# c #575788", -"'# c #464687", -")# c #2F2F87", -"!# c #15158F", -"~# c #0101A8", -"{# c #1313FB", -"]# c #57579F", -"^# c #343487", -"/# c #434388", -" ", -" ", -" ", -" . + @ # ", -" $ % & * = - ; > , ' ) ! ", -" ~ { ] ^ / = ( _ : < [ } | 1 2 3 4 5 6 ", -" 7 8 9 0 a b c d e f g h i j k l m n o p q r ", -" s t u v _ f d d d w x y z A B C D E F G H I J K L ", -" M N O _ c e d d d _ P Q R S T U V W X Y Z ` ... ", -" +.@.#.$.d d d d %.&._ *.=.-.;.>.,.'.).!.~. ", -" {.].^./.(.d d _.$.:._ <.[.}.|.1.2.3.4.5. ", -" 6.7.7.4 8.e : w 9.0.a.b.c.2 d.e.f.g.h.i.j.k. ", -" l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.o o z.A.B./.b C.D. ", -" E.F.G.].o H.z.I.J.K.L.M.N.O.P.o o o Q.R.S._.b B.T. ", -" U.V.W.X.f.f.7.Y.Z.`. + + +.+++].o o o.n z.q.@+#+$+%+ ", -" &+ +*+=+].o -+;+>+ + + + +,+'+H.o o o o o H.)+o !+~+{+ ", -" ]+ +^+/+H.o.(+_+ + + + + +:+<+z.o o o o o o o 7.n H.[+}+ ", -" |+ +1+2+3+4+5+6+ + + + + +7+8+H.o o f.9+f.9+f.F 0+a+b+o.c+ ", -" &+ +d+e+f+g+h+i+ + + + + +j+k+].f.9+l+m+n+o+p+q+r+s+t+u+v+ ", -" w+ +x+y+z+A+B+C+ + + + + +D+E+9+F+G+H+I+J+K+L+M+N+O+ ", -" P+Q+R+S+T+U+V+W+ + + + +X+Y+Z+`+ @I+J+Z .@+@E. ", -" @@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@I+/@(@_@ ", -" :@<@[@}@|@1@2@3@4@5@6@7@8@9@0@L+a@b@c@d@e@ ", -" f@g@h@i@i@j@k@l@|@m@n@o@p@q@r@s@t@u@p v@ ", -" w@x@y@z@A@B@i@C@D@E@F@G@H@I@L+J@K@L@p M@ ", -" N@O@P@Q@R@S@T@U@V@W@X@Y@Z@Y@`@ #.#p +# ", -" @###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]# ", -" ^#/# ", -" ", -" ", -" ", -" "}; diff --git a/src/sdl12/SDL_main/SDL_dummy_main.c b/src/sdl12/SDL_main/SDL_dummy_main.c deleted file mode 100644 index d8cfdd5bb..000000000 --- a/src/sdl12/SDL_main/SDL_dummy_main.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Include the SDL main definition header */ -#include "SDL_main.h" - -#ifdef main -#undef main -int main(int argc, char *argv[]) -{ - return(SDL_main(argc, argv)); -} -#else -/* Nothing to do on this platform */; -#endif diff --git a/src/sdl12/SDL_main/SDL_macosx_main.h b/src/sdl12/SDL_main/SDL_macosx_main.h deleted file mode 100644 index 4683df57a..000000000 --- a/src/sdl12/SDL_main/SDL_macosx_main.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SDLMain.m - main entry point for our Cocoa-ized SDL app - Initial Version: Darrell Walisser - Non-NIB-Code & other changes: Max Horn - - Feel free to customize this file to suit your needs -*/ - -#import - -@interface SDLMain : NSObject -@end diff --git a/src/sdl12/SDL_main/SDL_macosx_main.m b/src/sdl12/SDL_main/SDL_macosx_main.m deleted file mode 100644 index 226afe13d..000000000 --- a/src/sdl12/SDL_main/SDL_macosx_main.m +++ /dev/null @@ -1,374 +0,0 @@ -/* SDLMain.m - main entry point for our Cocoa-ized SDL app - Initial Version: Darrell Walisser - Non-NIB-Code & other changes: Max Horn - - Feel free to customize this file to suit your needs -*/ - -#import "SDL.h" -#import "SDL_macosx_main.h" -#import /* for MAXPATHLEN */ -#import - -/* For some reaon, Apple removed setAppleMenu from the headers in 10.4, - but the method still is there and works. To avoid warnings, we declare - it ourselves here. */ -@interface NSApplication(SDL_Missing_Methods) -- (void)setAppleMenu:(NSMenu *)menu; -@end - -/* Use this flag to determine whether we use SDLMain.nib or not */ -#define SDL_USE_NIB_FILE 0 - -/* Use this flag to determine whether we use CPS (docking) or not */ -#define SDL_USE_CPS 1 -#if SDL_USE_CPS -/* Portions of CPS.h */ -typedef struct CPSProcessSerNum -{ - UInt32 lo; - UInt32 hi; -} CPSProcessSerNum; - -extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn); -extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5); -extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn); - -#endif /* SDL_USE_CPS */ - -static int gArgc; -static char **gArgv; -static BOOL gFinderLaunch; - -static void addArgument(const char *value) -{ - if(!gArgc) - gArgv = (char **)malloc(sizeof(*gArgv)); - else - { - char **newgArgv = (char **)realloc(gArgv, sizeof(*gArgv) * (gArgc + 1)); - if (!newgArgv) - { - newgArgv = malloc(sizeof(*gArgv) * (gArgc + 1)); - memcpy(newgArgv, gArgv, sizeof(*gArgv) * gArgc); - free(gArgv); - } - gArgv = newgArgv; - } - gArgc++; - gArgv[gArgc - 1] = (char *)malloc(sizeof(char) * (strlen(value) + 1)); - strcpy(gArgv[gArgc - 1], value); -} - -static NSString *getApplicationName(void) -{ - NSDictionary *dict; - NSString *appName = NULL; - - /* Determine the application name */ - dict = ( NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle()); - if (dict) - appName = [dict objectForKey: @"CFBundleName"]; - - if (![appName length]) - appName = [[NSProcessInfo processInfo] processName]; - - return appName; -} - -#if SDL_USE_NIB_FILE -/* A helper category for NSString */ -@interface NSString (ReplaceSubString) -- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; -@end -#endif - -@interface SDLApplication : NSApplication -@end - -@implementation SDLApplication -/* Invoked from the Quit menu item */ -- (void)terminate:(id)sender -{ -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) - (void)sender; -#endif - /* Post a SDL_QUIT event */ - SDL_Event event; - event.type = SDL_QUIT; - SDL_PushEvent(&event); -} -@end - -/* The main class of the application, the application's delegate */ -@implementation SDLMain - -/* Set the working directory to the .app's parent directory */ -- (void) setupWorkingDirectory:(BOOL)shouldChdir -{ - if (shouldChdir) - { - char parentdir[MAXPATHLEN]; - CFURLRef url = CFBundleCopyBundleURL(CFBundleGetMainBundle()); - CFURLRef url2 = CFURLCreateCopyDeletingLastPathComponent(0, url); - if (CFURLGetFileSystemRepresentation(url2, true, (UInt8 *)parentdir, MAXPATHLEN)) - { - assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ - } - CFRelease(url); - CFRelease(url2); - } - -} - -#if SDL_USE_NIB_FILE - -/* Fix menu to contain the real app name instead of "SDL App" */ -- (void)fixMenu:(NSMenu *)aMenu withAppName:(NSString *)appName -{ - NSRange aRange; - NSEnumerator *enumerator; - NSMenuItem *menuItem; - - aRange = [[aMenu title] rangeOfString:@"SDL App"]; - if (aRange.length != 0) - [aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:appName]]; - - enumerator = [[aMenu itemArray] objectEnumerator]; - while ((menuItem = [enumerator nextObject])) - { - aRange = [[menuItem title] rangeOfString:@"SDL App"]; - if (aRange.length != 0) - [menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:appName]]; - if ([menuItem hasSubmenu]) - [self fixMenu:[menuItem submenu] withAppName:appName]; - } - [ aMenu sizeToFit ]; -} - -#else - -static void setApplicationMenu(void) -{ - /* warning: this code is very odd */ - NSMenu *appleMenu; - NSMenuItem *menuItem; - NSString *title; - NSString *appName; - - appName = getApplicationName(); - appleMenu = [[NSMenu alloc] initWithTitle:@""]; - - /* Add menu items */ - title = [@"About " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; - - [appleMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Hide " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; - - menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; - [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; - - [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; - - [appleMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Quit " stringByAppendingString:appName]; - [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; - - - /* Put menu into the menubar */ - menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; - [menuItem setSubmenu:appleMenu]; - [[NSApp mainMenu] addItem:menuItem]; - - /* Tell the application object that this is now the application menu */ - [NSApp setAppleMenu:appleMenu]; - - /* Finally give up our references to the objects */ - [appleMenu release]; - [menuItem release]; -} - -/* Create a window menu */ -static void setupWindowMenu(void) -{ - NSMenu *windowMenu; - NSMenuItem *windowMenuItem; - NSMenuItem *menuItem; - - windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; - - /* "Minimize" item */ - menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; - [windowMenu addItem:menuItem]; - [menuItem release]; - - /* Put menu into the menubar */ - windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; - [windowMenuItem setSubmenu:windowMenu]; - [[NSApp mainMenu] addItem:windowMenuItem]; - - /* Tell the application object that this is now the window menu */ - [NSApp setWindowsMenu:windowMenu]; - - /* Finally give up our references to the objects */ - [windowMenu release]; - [windowMenuItem release]; -} - -/* Replacement for NSApplicationMain */ -static void CustomApplicationMain (int argc, char **argv) -{ -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) - (void)argc; - (void)argv; -#endif - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - SDLMain *sdlMain; - - /* Ensure the application object is initialised */ - [SDLApplication sharedApplication]; - -#if SDL_USE_CPS - { - CPSProcessSerNum PSN; - /* Tell the dock about us */ - if (!CPSGetCurrentProcess(&PSN)) - if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) - if (!CPSSetFrontProcess(&PSN)) - [SDLApplication sharedApplication]; - } -#endif /* SDL_USE_CPS */ - - /* Set up the menubar */ - [NSApp setMainMenu:[[NSMenu alloc] init]]; - setApplicationMenu(); - setupWindowMenu(); - - /* Create SDLMain and make it the app delegate */ - sdlMain = [[SDLMain alloc] init]; - [NSApp setDelegate:sdlMain]; - - /* Start the main event loop */ - [NSApp run]; - - [sdlMain release]; - [pool release]; -} - -#endif - -- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename -{ -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) - (void)theApplication; -#endif - addArgument("-iwad"); - addArgument([filename UTF8String]); - return YES; -} - -/* Called when the internal event loop has just started running */ -- (void) applicationDidFinishLaunching: (NSNotification *) note -{ -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) - (void)note; -#endif - int status; - - /* Set the working directory to the .app's parent directory */ - [self setupWorkingDirectory:gFinderLaunch]; - -#if SDL_USE_NIB_FILE - /* Set the main menu to contain the real app name instead of "SDL App" */ - [self fixMenu:[NSApp mainMenu] withAppName:getApplicationName()]; -#endif - - if (!getenv("SRB2WADDIR")) - setenv("SRB2WADDIR", [[[NSBundle mainBundle] resourcePath] UTF8String], 1); - - /* Hand off to main application code */ - status = SDL_main (gArgc, gArgv); - - /* We're done, thank you for playing */ - exit(status); -} -@end - - -@implementation NSString (ReplaceSubString) - -- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString -{ - size_t bufferSize; - size_t selfLen = [self length]; - size_t aStringLen = [aString length]; - unichar *buffer; - NSRange localRange; - NSString *result; - - bufferSize = selfLen + aStringLen - aRange.length; - buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar)); - - /* Get first part into buffer */ - localRange.location = 0; - localRange.length = aRange.location; - [self getCharacters:buffer range:localRange]; - - /* Get middle part into buffer */ - localRange.location = 0; - localRange.length = aStringLen; - [aString getCharacters:(buffer+aRange.location) range:localRange]; - - /* Get last part into buffer */ - localRange.location = aRange.location + aRange.length; - localRange.length = selfLen - localRange.location; - [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; - - /* Build output string */ - result = [NSString stringWithCharacters:buffer length:bufferSize]; - - NSDeallocateMemoryPages(buffer, bufferSize); - - return result; -} - -@end - - - -#ifdef main -# undef main -#endif - - -/* Main entry point to executable - should *not* be SDL_main! */ -int main (int argc, char **argv) -{ - - /* Copy the arguments into a global variable */ - - /* This is passed if we are launched by double-clicking */ - if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { - gArgc = 1; - gFinderLaunch = YES; - } else { - gArgc = argc; - gFinderLaunch = NO; - } - gArgv = argv; - - /* Some additional arguments we always want to run with. */ - //addArgument("-opengl"); - -#if SDL_USE_NIB_FILE - [SDLApplication poseAsClass:[NSApplication class]]; - NSApplicationMain (argc, argv); -#else - CustomApplicationMain (argc, argv); -#endif - return 0; -} diff --git a/src/sdl12/SDL_main/SDL_openxdk_main.c b/src/sdl12/SDL_main/SDL_openxdk_main.c deleted file mode 100644 index 63db8da2d..000000000 --- a/src/sdl12/SDL_main/SDL_openxdk_main.c +++ /dev/null @@ -1,7 +0,0 @@ -/* Include the SDL main definition header */ -#include "SDL_main.h" - -void XBoxStartup() -{ - SDL_main(0, NULL); /// \todo ? -} diff --git a/src/sdl12/SDL_main/SDL_win32_main.c b/src/sdl12/SDL_main/SDL_win32_main.c deleted file mode 100644 index 46b20d0bd..000000000 --- a/src/sdl12/SDL_main/SDL_win32_main.c +++ /dev/null @@ -1,406 +0,0 @@ -/* - SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98 - - The WinMain function -- calls your program's main() function -*/ - -#include -#include -#include -#include -#define RPC_NO_WINDOWS_H -#include -#include /* For _alloca() */ - -#include - -#ifdef _WIN32_WCE -# define DIR_SEPERATOR TEXT("\\") -# define _tgetcwd(str,len) wcscpy(str,TEXT("")) -# define setbuf(f,b) -# define setvbuf(w,x,y,z) -# define _tremove(x) DeleteFile(x) -#else -# define DIR_SEPERATOR TEXT("/") -# include -#endif - -/* Include the SDL main definition header */ -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif -#include "SDL.h" -#include "SDL_main.h" -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif -#include "../../win32/win_dbg.h" -#define USE_MESSAGEBOX - -#ifdef main -# ifndef _WIN32_WCE_EMULATION -# undef main -# endif /* _WIN32_WCE_EMULATION */ -#endif /* main */ - -/* The standard output files */ -//#ifdef _WIN32_WCE -//#define STDOUT_FILE TEXT("/Storage Card/SRB2DEMO/stdout.txt") -//#define STDERR_FILE TEXT("/Storage Card/SRB2DEMO/stderr.txt") -//#else -#define STDOUT_FILE TEXT("stdout.txt") -#define STDERR_FILE TEXT("stderr.txt") -//#endif - -#ifndef NO_STDIO_REDIRECT - static TCHAR stdoutPath[MAX_PATH]; - static TCHAR stderrPath[MAX_PATH]; -#endif - -#if defined(_WIN32_WCE) && _WIN32_WCE < 300 -/* seems to be undefined in Win CE although in online help */ -#define isspace(a) (((CHAR)a == ' ') || ((CHAR)a == '\t')) - -/* seems to be undefined in Win CE although in online help */ -char *strrchr(char *str, int c) -{ - char *p; - - /* Skip to the end of the string */ - p=str; - while (*p) - p++; - - /* Look for the given character */ - while ( (p >= str) && (*p != (CHAR)c) ) - p--; - - /* Return NULL if character not found */ - if ( p < str ) { - p = NULL; - } - return p; -} -#endif /* _WIN32_WCE < 300 */ - -/* Parse a command line buffer into arguments */ -static int ParseCommandLine(char *cmdline, char **argv) -{ - char *bufp; - int argc; - - argc = 0; - for ( bufp = cmdline; *bufp; ) { - /* Skip leading whitespace */ - while ( isspace(*bufp) ) { - ++bufp; - } - /* Skip over argument */ - if ( *bufp == '"' ) { - ++bufp; - if ( *bufp ) { - if ( argv ) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while ( *bufp && (*bufp != '"') ) { - ++bufp; - } - } else { - if ( *bufp ) { - if ( argv ) { - argv[argc] = bufp; - } - ++argc; - } - /* Skip over word */ - while ( *bufp && ! isspace(*bufp) ) { - ++bufp; - } - } - if ( *bufp ) { - if ( argv ) { - *bufp = '\0'; - } - ++bufp; - } - } - if ( argv ) { - argv[argc] = NULL; - } - return(argc); -} - -/* Show an error message */ -static void ShowError(const char *title, const char *message) -{ -/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */ -#ifdef USE_MESSAGEBOX - MessageBoxA(NULL, - message, - title, - MB_ICONEXCLAMATION|MB_OK); -#else - fprintf(stderr, "%s: %s\n", title, message); -#endif -} - -/* Pop up an out of memory message, returns to Windows */ -static BOOL OutOfMemory(void) -{ - ShowError("Fatal Error", "Out of memory - aborting"); - return FALSE; -} - -/* Remove the output files if there was no output written */ -static void __cdecl cleanup_output(void) -{ -#ifndef NO_STDIO_REDIRECT - FILE *file; - int empty; -#endif - - /* Flush the output in case anything is queued */ - fclose(stdout); - fclose(stderr); - -#ifndef NO_STDIO_REDIRECT - /* See if the files have any output in them */ - if ( stdoutPath[0] ) { - file = _tfopen(stdoutPath, TEXT("rb")); - if ( file ) { - empty = (fgetc(file) == EOF) ? 1 : 0; - fclose(file); - if ( empty ) { - _tremove(stdoutPath); - } - } - } - if ( stderrPath[0] ) { - file = _tfopen(stderrPath, TEXT("rb")); - if ( file ) { - empty = (fgetc(file) == EOF) ? 1 : 0; - fclose(file); - if ( empty ) { - _tremove(stderrPath); - } - } - } -#endif -} - -#if defined(_MSC_VER) && !defined(_WIN32_WCE) -/* The VC++ compiler needs main defined */ -#define console_main main -#endif - -/* This is where execution begins [console apps] */ -int console_main(int argc, char *argv[]) -{ - size_t n; - int st; - char *bufp, *appname; - - /* Get the class name from argv[0] */ - appname = argv[0]; - if ( (bufp=strrchr(argv[0], '\\')) != NULL ) { - appname = bufp+1; - } else - if ( (bufp=strrchr(argv[0], '/')) != NULL ) { - appname = bufp+1; - } - - if ( (bufp=strrchr(appname, '.')) == NULL ) - n = strlen(appname); - else - n = (bufp-appname); - - bufp = (char *)alloca(n+1); - if ( bufp == NULL ) { - return OutOfMemory(); - } - strncpy(bufp, appname, n); - bufp[n] = '\0'; - appname = bufp; - - /* Load SDL dynamic link library */ - if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) { - ShowError("WinMain() error", SDL_GetError()); - return(FALSE); - } - atexit(cleanup_output); - atexit(SDL_Quit); - -#ifndef DISABLE_VIDEO -#if 0 - /* Create and register our class * - DJM: If we do this here, the user nevers gets a chance to - putenv(SDL_WINDOWID). This is already called later by - the (DIB|DX5)_CreateWindow function, so it should be - safe to comment it out here. - if ( SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT, - GetModuleHandle(NULL)) < 0 ) { - ShowError("WinMain() error", SDL_GetError()); - exit(1); - }*/ -#else - /* Sam: - We still need to pass in the application handle so that - DirectInput will initialize properly when SDL_RegisterApp() - is called later in the video initialization. - */ - SDL_SetModuleHandle(GetModuleHandle(NULL)); -#endif /* 0 */ -#endif /* !DISABLE_VIDEO */ - - /* Run the application main() code */ - st = SDL_main(argc, argv); - - /* Exit cleanly, calling atexit() functions */ - //exit(0); - cleanup_output(); - SDL_Quit(); - - /* Hush little compiler, don't you cry... */ - return st; -} - -/* This is where execution begins [windowed apps] */ -#ifdef _WIN32_WCE -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPWSTR szCmdLine, int sw) -#else -int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) -#endif -{ - HINSTANCE handle; - int Result = -1; - char **argv; - int argc; - LPSTR cmdline; -#ifdef _WIN32_WCE - size_t nLen; - LPTSTR bufp; -#else - LPSTR bufp; -#endif -#ifndef NO_STDIO_REDIRECT - FILE *newfp; -#endif - - /* Start up DDHELP.EXE before opening any files, so DDHELP doesn't - keep them open. This is a hack.. hopefully it will be fixed - someday. DDHELP.EXE starts up the first time DDRAW.DLL is loaded. - */ - hPrev = hInst = NULL; - sw = 0; - handle = LoadLibrary(TEXT("DDRAW.DLL")); - if ( handle != NULL ) { - FreeLibrary(handle); - } - -#ifndef NO_STDIO_REDIRECT - _tgetcwd( stdoutPath, sizeof( stdoutPath ) ); - _tcscat( stdoutPath, DIR_SEPERATOR STDOUT_FILE ); - - /* Redirect standard input and standard output */ - newfp = _tfreopen(stdoutPath, TEXT("w"), stdout); - -#ifndef _WIN32_WCE - if ( newfp == NULL ) { /* This happens on NT */ -#if !defined(stdout) - stdout = _tfopen(stdoutPath, TEXT("w")); -#else - newfp = _tfopen(stdoutPath, TEXT("w")); - if ( newfp ) { - *stdout = *newfp; - } -#endif - } -#endif /* _WIN32_WCE */ - - _tgetcwd( stderrPath, sizeof( stderrPath ) ); - _tcscat( stderrPath, DIR_SEPERATOR STDERR_FILE ); - - newfp = _tfreopen(stderrPath, TEXT("w"), stderr); -#ifndef _WIN32_WCE - if ( newfp == NULL ) { /* This happens on NT */ -#if !defined(stderr) - stderr = _tfopen(stderrPath, TEXT("w")); -#else - newfp = _tfopen(stderrPath, TEXT("w")); - if ( newfp ) { - *stderr = *newfp; - } -#endif - } -#endif /* _WIN32_WCE */ - - setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Line buffered */ - setbuf(stderr, NULL); /* No buffering */ -#endif /* !NO_STDIO_REDIRECT */ - -#ifdef _WIN32_WCE - nLen = wcslen(szCmdLine)+128+1; - bufp = (wchar_t *)alloca(nLen*2); - wcscpy (bufp, TEXT("\"")); - GetModuleFileName(NULL, bufp+1, 128-3); - wcscpy (bufp+wcslen(bufp), TEXT("\" ")); - wcsncpy(bufp+wcslen(bufp), szCmdLine,nLen-wcslen(bufp)); - nLen = wcslen(bufp)+1; - cmdline = (char *)alloca(nLen); - if ( cmdline == NULL ) { - return OutOfMemory(); - } - WideCharToMultiByte(CP_ACP, 0, bufp, -1, cmdline, nLen, NULL, NULL); -#else - szCmdLine = NULL; - /* Grab the command line (use alloca() on Windows) */ - bufp = GetCommandLineA(); - cmdline = (LPSTR)alloca(strlen(bufp)+1); - if ( cmdline == NULL ) { - return OutOfMemory(); - } - strcpy(cmdline, bufp); -#endif - - /* Parse it into argv and argc */ - argc = ParseCommandLine(cmdline, NULL); - argv = (char **)alloca((argc+1)*(sizeof *argv)); - if ( argv == NULL ) { - return OutOfMemory(); - } - ParseCommandLine(cmdline, argv); - -#ifdef BUGTRAP - /* Try BugTrap. */ - if(InitBugTrap()) - Result = console_main(argc, argv); - else - { -#endif - - /* Run the main program (after a little SDL initialization) */ -#ifndef _WIN32_WCE - __try -#endif - { - Result = console_main(argc, argv); - } -#ifndef _WIN32_WCE - __except ( RecordExceptionInfo(GetExceptionInformation())) - { - SetUnhandledExceptionFilter(EXCEPTION_CONTINUE_SEARCH); //Do nothing here. - } -#endif - -#ifdef BUGTRAP - } /* BT failure clause. */ - - /* This is safe even if BT didn't start. */ - ShutdownBugTrap(); -#endif - - return Result; -} diff --git a/src/sdl12/SRB2CE/Makefile.cfg b/src/sdl12/SRB2CE/Makefile.cfg deleted file mode 100644 index 8d4ae3e48..000000000 --- a/src/sdl12/SRB2CE/Makefile.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# -# Makefile.cfg for WinCE with GCC -# - -OPTS+=-D_WIN32_WCE -D_UNICODE -SDL_CFLAGS?= -SDL_LDFLAGS?= -NOHS=1 -NOHW=1 -NONET=1 -NOMIXER=1 -NOPNG=1 diff --git a/src/sdl12/SRB2CE/SRB2CE.zip b/src/sdl12/SRB2CE/SRB2CE.zip deleted file mode 100644 index 3ac8530dc..000000000 Binary files a/src/sdl12/SRB2CE/SRB2CE.zip and /dev/null differ diff --git a/src/sdl12/SRB2CE/cehelp.c b/src/sdl12/SRB2CE/cehelp.c deleted file mode 100644 index 13505cff7..000000000 --- a/src/sdl12/SRB2CE/cehelp.c +++ /dev/null @@ -1,446 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2004-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// stub and replacement "ANSI" C functions for use under Windows CE -// -//----------------------------------------------------------------------------- - -#include "../../doomdef.h" -#include "cehelp.h" - -#define _SEC_IN_MINUTE 60 -#define _SEC_IN_HOUR 3600 -#define _SEC_IN_DAY 86400 - -static const int DAYS_IN_MONTH[12] = -{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - -#define _DAYS_IN_MONTH(x) ((x == 1) ? days_in_feb : DAYS_IN_MONTH[x]) - -static const int _DAYS_BEFORE_MONTH[12] = -{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; - -#define _ISLEAP(y) (((y) % 4) == 0 && (((y) % 100) != 0 || (((y)+1900) % 400) == 0)) -#define _DAYS_IN_YEAR(year) (_ISLEAP(year) ? 366 : 365) - -char *strerror(int ecode) -{ - static char buff[1024 + 1]; - DWORD dwMsgLen = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, - ecode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &buff[0], 1024, NULL); - return buff; -} - -int unlink( const char *filename ) -{ - return remove(filename); -} - -int remove( const char *path ) -{ - return DeleteFileA(path)-1; -} - -int rename( const char *oldname, const char *newname ) -{ - return MoveFileA(oldname, newname)!=0; -} - -static inline void STToTM(const SYSTEMTIME *st, struct tm *tm) -{ - if (!st || !tm) return; - tm->tm_sec = st->wSecond; - tm->tm_min = st->wMinute; - tm->tm_hour = st->wHour; - tm->tm_mday = st->wDay; - tm->tm_mon = st->wMonth - 1; - tm->tm_year = st->wYear - 1900; - tm->tm_wday = st->wDayOfWeek; - tm->tm_yday = 0; - tm->tm_isdst = 0; -} - -time_t time(time_t *T) -{ - time_t returntime; - SYSTEMTIME st; - struct tm stft; - GetSystemTime(&st); - STToTM(&st,&stft); - returntime = mktime(&stft); - if (T) *T = returntime; - return returntime; -} - -static inline UINT64 TTtoFT(const time_t wt, FILETIME *ft) -{ - UINT64 temptime = wt; // FILETIME: 1/(10^7) secs since January 1, 1601 - temptime *= 10000000; // time_t : 1 secs since January 1, 1970 - // 369 years * 365 days * 24 hours * 60 mins * 60 secs * 10 - // 123 leaps days * 24 hours * 60 mins * 60 secs * 10 - temptime += 116444736000000000; - if (ft) CopyMemory(ft,&temptime,sizeof (ULARGE_INTEGER)); - return temptime; -} - -static struct tm cehelptm; - -struct tm * localtime(const time_t *CLOCK) -{ - SYSTEMTIME st; - FILETIME stft; - UINT64 ftli = 0; - if (CLOCK) ftli = TTtoFT(*CLOCK, &stft); - if (ftli) - FileTimeToSystemTime(&stft,&st); - else - GetSystemTime(&st); - STToTM(&st,&cehelptm); - if (st.wYear >= 1970) - return &cehelptm; - else - return NULL; -} - -static void validate_structure (struct tm *tim_p) // from newlib -{ - div_t res; - int days_in_feb = 28; - - /* calculate time & date to account for out of range values */ - if (tim_p->tm_sec < 0 || tim_p->tm_sec > 59) - { - res = div (tim_p->tm_sec, 60); - tim_p->tm_min += res.quot; - if ((tim_p->tm_sec = res.rem) < 0) - { - tim_p->tm_sec += 60; - --tim_p->tm_min; - } - } - - if (tim_p->tm_min < 0 || tim_p->tm_min > 59) - { - res = div (tim_p->tm_min, 60); - tim_p->tm_hour += res.quot; - if ((tim_p->tm_min = res.rem) < 0) - { - tim_p->tm_min += 60; - --tim_p->tm_hour; - } - } - - if (tim_p->tm_hour < 0 || tim_p->tm_hour > 23) - { - res = div (tim_p->tm_hour, 24); - tim_p->tm_mday += res.quot; - if ((tim_p->tm_hour = res.rem) < 0) - { - tim_p->tm_hour += 24; - --tim_p->tm_mday; - } - } - - if (tim_p->tm_mon > 11) - { - res = div (tim_p->tm_mon, 12); - tim_p->tm_year += res.quot; - if ((tim_p->tm_mon = res.rem) < 0) - { - tim_p->tm_mon += 12; - --tim_p->tm_year; - } - } - - if (_DAYS_IN_YEAR (tim_p->tm_year) == 366) - days_in_feb = 29; - - if (tim_p->tm_mday <= 0) - { - while (tim_p->tm_mday <= 0) - { - if (--tim_p->tm_mon == -1) - { - tim_p->tm_year--; - tim_p->tm_mon = 11; - days_in_feb = - ((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? - 29 : 28); - } - tim_p->tm_mday += _DAYS_IN_MONTH (tim_p->tm_mon); - } - } - else - { - while (tim_p->tm_mday > _DAYS_IN_MONTH (tim_p->tm_mon)) - { - tim_p->tm_mday -= _DAYS_IN_MONTH (tim_p->tm_mon); - if (++tim_p->tm_mon == 12) - { - tim_p->tm_year++; - tim_p->tm_mon = 0; - days_in_feb = - ((_DAYS_IN_YEAR (tim_p->tm_year) == 366) ? - 29 : 28); - } - } - } -} - -time_t mktime (struct tm *tim_p) // from newlib -{ - time_t tim = 0; - long days = 0; - int year; - - /* validate structure */ - validate_structure (tim_p); - - /* compute hours, minutes, seconds */ - tim += tim_p->tm_sec + (tim_p->tm_min * _SEC_IN_MINUTE) + - (tim_p->tm_hour * _SEC_IN_HOUR); - - /* compute days in year */ - days += tim_p->tm_mday - 1; - days += _DAYS_BEFORE_MONTH[tim_p->tm_mon]; - if (tim_p->tm_mon > 1 && _DAYS_IN_YEAR (tim_p->tm_year) == 366) - days++; - - /* compute day of the year */ - tim_p->tm_yday = days; - - if (tim_p->tm_year > 10000 - || tim_p->tm_year < -10000) - { - return (time_t) -1; - } - - /* compute days in other years */ - if (tim_p->tm_year > 70) - { - for (year = 70; year < tim_p->tm_year; year++) - days += _DAYS_IN_YEAR (year); - } - else if (tim_p->tm_year < 70) - { - for (year = 69; year > tim_p->tm_year; year--) - days -= _DAYS_IN_YEAR (year); - days -= _DAYS_IN_YEAR (year); - } - - /* compute day of the week */ - if ((tim_p->tm_wday = (days + 4) % 7) < 0) - tim_p->tm_wday += 7; - - /* compute total seconds */ - tim += (days * _SEC_IN_DAY); - - return tim; -} - -#undef WINAPI -#define WINAPI __stdcall //__delcspec(dllexport) - -#ifdef _MSC_VER -//#pragma warning(disable : 4273) -#endif - - -static __forceinline int STRtoWSTR(LPCSTR lpMultiByteStr, int cchMultiByte, - LPWSTR lpWideCharStr, int cchWideChar) -{ - return MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,lpMultiByteStr, - cchMultiByte,lpWideCharStr,cchWideChar); -} - -static __forceinline int WSTRtoSTR(LPCWSTR lpWideCharStr, int cchWideChar, - LPSTR lpMultiByteStr, int cbMultiByte) -{ - return WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK|WC_SEPCHARS, - lpWideCharStr,cchWideChar,lpMultiByteStr,cbMultiByte,NULL,NULL); -} - -DWORD WINAPI FormatMessageA( - DWORD dwFlags, - LPCVOID lpSource, - DWORD dwMessageId, - DWORD dwLanguageId, - LPSTR lpBuffer, - DWORD nSize, - va_list *Arguments) -{ - const int nSizeW = STRtoWSTR(lpBuffer,nSize,NULL,0); - int nSizeF = 0; - LPWSTR lpBufferW = alloca(sizeof (wchar_t)*nSizeW); - LPWSTR lpSourceW = NULL; - - if (!lpBufferW) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - ZeroMemory(lpBuffer,nSize); - return nSizeF; - } - - if (dwFlags & FORMAT_MESSAGE_FROM_STRING) - { - const int sLen = STRtoWSTR(lpSource, -1, NULL, 0); - lpSourceW = alloca(sizeof (wchar_t)*sLen); - - if (lpSourceW) - STRtoWSTR(lpSource, -1, lpSourceW, sLen); - else - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return nSizeF; - } - } - - if (lpSourceW) - nSizeF = FormatMessageW(dwFlags, lpSourceW, dwMessageId, dwLanguageId, - lpBufferW, nSizeW, Arguments); - else - nSizeF = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, - lpBufferW, nSizeW, Arguments); - - return WSTRtoSTR(lpBufferW, nSizeF, lpBuffer, nSize); -} - -BOOL WINAPI DeleteFileA( - LPCSTR lpFileName) -{ - const int sLen = STRtoWSTR(lpFileName, -1, NULL, 0); - LPWSTR lpFileNameW = alloca(sizeof (wchar_t)*sLen); - - if (lpFileNameW) - STRtoWSTR(lpFileName, -1, lpFileNameW, sLen); - else - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - return DeleteFileW(lpFileNameW); -} - -BOOL WINAPI MoveFileA( - LPCSTR lpExistingFileName, - LPCSTR lpNewFileName -) -{ - const int sLen1 = STRtoWSTR(lpExistingFileName, -1, NULL, 0); - LPWSTR lpExistingFileNameW = alloca(sizeof (wchar_t)*sLen1); - - const int sLen2 = STRtoWSTR(lpNewFileName, -1, NULL, 0); - LPWSTR lpNewFileNameW = alloca(sizeof (wchar_t)*sLen2); - - - if (!lpExistingFileNameW || !lpNewFileNameW) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - STRtoWSTR(lpExistingFileName, -1, lpExistingFileNameW, sLen1); - STRtoWSTR(lpNewFileName, -1, lpNewFileNameW, sLen2); - - return MoveFileW(lpExistingFileNameW, lpNewFileNameW); -} - - -HANDLE WINAPI CreateFileA( - LPCSTR lpFileName, - DWORD dwDesiredAccess, - DWORD dwShareMode, - LPSECURITY_ATTRIBUTES lpSecurityAttributes, - DWORD dwCreationDisposition, - DWORD dwFlagsAndAttributes, - HANDLE hTemplateFile) -{ - const int sLen = STRtoWSTR(lpFileName, -1, NULL, 0); - LPWSTR lpFileNameW = alloca(sizeof (wchar_t)*sLen); - - if (lpFileNameW) - STRtoWSTR(lpFileName, -1, lpFileNameW, sLen); - else - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return INVALID_HANDLE_VALUE; - } - - return CreateFileW(lpFileNameW, dwDesiredAccess, dwShareMode, - lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, - hTemplateFile); -} - -BOOL WINAPI CreateDirectoryA( - LPCSTR lpPathName, - LPSECURITY_ATTRIBUTES lpSecurityAttributes) -{ - const int sLen = STRtoWSTR(lpPathName, -1, NULL, 0); - LPWSTR lpPathNameW = alloca(sizeof (wchar_t)*sLen); - - if (lpPathNameW) - STRtoWSTR(lpPathName, -1, lpPathNameW, sLen); - else - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - return CreateDirectoryW(lpPathNameW, lpSecurityAttributes); -} - -int WINAPI MessageBoxA( - HWND hWnd , - LPCSTR lpText, - LPCSTR lpCaption, - UINT uType) -{ - const int sLen1 = STRtoWSTR(lpText, -1, NULL, 0); - LPWSTR lpTextW = alloca(sizeof (wchar_t)*sLen1); - - const int sLen2 = STRtoWSTR(lpCaption, -1, NULL, 0); - LPWSTR lpCaptionW = alloca(sizeof (wchar_t)*sLen2); - - - if (!lpTextW || !lpCaptionW) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - STRtoWSTR(lpText, -1, lpTextW, sLen1); - STRtoWSTR(lpCaption, -1, lpCaptionW, sLen2); - - return MessageBoxW(hWnd, lpTextW, lpCaptionW, uType); -} - -VOID WINAPI OutputDebugStringA( - LPCSTR lpOutputString) -{ - const int sLen = STRtoWSTR(lpOutputString, -1, NULL, 0); - LPWSTR lpOutputStringW = alloca(sizeof (wchar_t)*sLen); - - if (lpOutputStringW) - STRtoWSTR(lpOutputString, -1, lpOutputStringW, sLen); - else - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return; - } - - OutputDebugStringW(lpOutputStringW); -} diff --git a/src/sdl12/SRB2CE/cehelp.h b/src/sdl12/SRB2CE/cehelp.h deleted file mode 100644 index 3ed0d9dd4..000000000 --- a/src/sdl12/SRB2CE/cehelp.h +++ /dev/null @@ -1,63 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2004-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// stub and replacement "ANSI" C functions for use under Windows CE -// -//----------------------------------------------------------------------------- - -#ifndef __I_WINCE__ -#define __I_WINCE__ - -#ifdef USEASMCE -#define USEASM // Remline if NASM doesn't work on x86 targets -#endif - -char *strerror(int ecode); -int access(const char *path, int amode); -int unlink( const char *filename ); -int remove( const char *path ); -int rename( const char *oldname, const char *newname ); -//CreateDirectoryEx( const char *currectpath, const char *path,SECURITY_ATTRIBUTES) - -#ifndef _TIME_T_DEFINED -typedef long time_t; /* time value */ -#define _TIME_T_DEFINED /* avoid multiple def's of time_t */ -#endif - -time_t time(time_t *T); - -#ifndef __GNUC__ -#ifndef _TM_DEFINED -struct tm { - int tm_sec; /* seconds after the minute - [0,59] */ - int tm_min; /* minutes after the hour - [0,59] */ - int tm_hour; /* hours since midnight - [0,23] */ - int tm_mday; /* day of the month - [1,31] */ - int tm_mon; /* months since January - [0,11] */ - int tm_year; /* years since 1900 */ - int tm_wday; /* days since Sunday - [0,6] */ - int tm_yday; /* days since January 1 - [0,365] */ - int tm_isdst; /* daylight savings time flag */ - }; -#define _TM_DEFINED -#endif - -struct tm * localtime(const time_t *CLOCK); - -time_t mktime (struct tm *tim_p); -#endif - -#endif diff --git a/src/sdl12/SRB2DC/.gitignore b/src/sdl12/SRB2DC/.gitignore deleted file mode 100644 index a966585d4..000000000 --- a/src/sdl12/SRB2DC/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/scramble diff --git a/src/sdl12/SRB2DC/IP.BIN b/src/sdl12/SRB2DC/IP.BIN deleted file mode 100644 index c3366213b..000000000 Binary files a/src/sdl12/SRB2DC/IP.BIN and /dev/null differ diff --git a/src/sdl12/SRB2DC/Makefile.cfg b/src/sdl12/SRB2DC/Makefile.cfg deleted file mode 100644 index 3edaf8a16..000000000 --- a/src/sdl12/SRB2DC/Makefile.cfg +++ /dev/null @@ -1,53 +0,0 @@ -# -# Makefile.cfg for SRB2/Dreamcast -# - -#include $(KOS_BASE)/Makefile.rules - -# -#hmmm, the Dreamcast -# - - HOSTCC:=$(CC) - CC=$(KOS_CC) - PREFIX=$(KOS_CC_BASE)/bin/$(KOS_CC_PREFIX) - OBJDUMP=$(PREFIX)-objdump - OBJCOPY=$(PREFIX)-objcopy - - #NOHW=1 #No working MiniGL right now - NOHS=1 #No HWSound right now -ifndef LWIP - NONET=1 #No LWIP -endif - #i_net_o=$(OBJDIR)/i_udp.o #use KOS's UDP - #NOMIXER=1 #Basic sound only - NOIPX=1 #No IPX network code - NOPNG=1 #No Screenshot - - OPTS=$(KOS_CFLAGS) -DUNIXCOMMON -DDC -ifndef NOHW - OPTS+=-DSTATIC_OPENGL -DMINI_GL_COMPATIBILITY -DKOS_GL_COMPATIBILITY -endif - SDL_CFLAGS?=-I$(KOS_BASE)/addons/include/SDL - SDL_LDFLAGS?=-lSDL - LDFLAGS=$(KOS_LDFLAGS) - LIBS:=$(KOS_LIBS) -lconio -lm -ifndef NOMIXER - LIBS:=-loggvorbisplay -lSDL $(LIBS) -endif - -ifdef LWIP - OPTS+=-I$(KOS_BASE)/../kos-ports/lwip/kos/include -I$(KOS_BASE)/../kos-ports/lwip/lwip/src/include/ipv4 -I$(KOS_BASE)/../kos-ports/lwip/lwip/src/include -DIPv4 - LIBS:=-llwip4 -lkosutils $(LIBS) - OPTS+=-DHAVE_LWIP -endif -ifndef NOHW - LIBS+=-lgl -endif - - i_system_o+=$(OBJDIR)/dchelp.o - i_main_o=$(KOS_START) $(OBJDIR)/i_main.o $(OBJEXTRA) - - # name of the exefile - EXENAME?=SRB2.elf - BINNAME?=SRB2.BIN diff --git a/src/sdl12/SRB2DC/SELFBOOT.BIN b/src/sdl12/SRB2DC/SELFBOOT.BIN deleted file mode 100644 index a87ee3869..000000000 Binary files a/src/sdl12/SRB2DC/SELFBOOT.BIN and /dev/null differ diff --git a/src/sdl12/SRB2DC/VMU.xbm b/src/sdl12/SRB2DC/VMU.xbm deleted file mode 100644 index 0d56985f3..000000000 --- a/src/sdl12/SRB2DC/VMU.xbm +++ /dev/null @@ -1,19 +0,0 @@ -#define VMU_width 48 -#define VMU_height 32 -static unsigned char VMU_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, - 0x00, 0x00, 0x58, 0x75, 0x00, 0x00, 0x00, 0x00, 0xee, 0xaa, 0x00, 0x00, - 0x00, 0x86, 0x55, 0x55, 0x01, 0x00, 0x00, 0xda, 0xc8, 0xaf, 0x00, 0x00, - 0x00, 0x62, 0x55, 0x54, 0x00, 0x00, 0x00, 0x32, 0xa2, 0x6c, 0x00, 0x00, - 0x00, 0x5c, 0x55, 0xfd, 0x01, 0x00, 0x00, 0xac, 0x88, 0xaa, 0x02, 0x00, - 0x00, 0x54, 0x75, 0x55, 0x05, 0x00, 0x00, 0xac, 0xbf, 0xaa, 0x0a, 0x00, - 0x00, 0xd6, 0x61, 0x55, 0x15, 0x00, 0x00, 0xe9, 0xc0, 0xaa, 0x2a, 0x00, - 0x00, 0x39, 0x40, 0x55, 0x55, 0x00, 0x00, 0x6d, 0xc0, 0xaa, 0xbe, 0x00, - 0x00, 0x6d, 0x40, 0xd5, 0xc3, 0x00, 0x00, 0x6d, 0xc0, 0xea, 0x00, 0x00, - 0x00, 0x29, 0x60, 0xf5, 0x00, 0x00, 0x00, 0x26, 0xe0, 0xfa, 0x00, 0x00, - 0x00, 0x58, 0xb8, 0xbd, 0x00, 0x00, 0x00, 0x84, 0x07, 0xdf, 0x00, 0x00, - 0x00, 0x08, 0x20, 0xae, 0x00, 0x00, 0x00, 0x30, 0xc0, 0x5f, 0x01, 0x00, - 0x00, 0xc0, 0x3f, 0xb8, 0x01, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; diff --git a/src/sdl12/SRB2DC/dchelp.c b/src/sdl12/SRB2DC/dchelp.c deleted file mode 100644 index 1468baa8b..000000000 --- a/src/sdl12/SRB2DC/dchelp.c +++ /dev/null @@ -1,134 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2006-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// stub and replacement "ANSI" C functions for use on Dreamcast/KOS -// -//----------------------------------------------------------------------------- -#include -#include -#ifndef HAVE_LWIP -#include -#endif -#include "../../doomdef.h" -#include "dchelp.h" - -int access(const char *path, int amode) -{ - file_t handle = FILEHND_INVALID; - - if (amode == F_OK || amode == R_OK) - handle=fs_open(path,O_RDONLY); - else if (amode == (R_OK|W_OK)) - handle=fs_open(path,O_RDWR); - else if (amode == W_OK) - handle=fs_open(path,O_WRONLY); - - if (handle != FILEHND_INVALID) - { - fs_close(handle); - return 0; - } - - return -1; -} - -double hypot(double x, double y) -{ - double ax, yx, yx2, yx1; - if (abs(y) > abs(x)) // |y|>|x| - { - ax = abs(y); // |y| => ax - yx = (x/y); - } - else // |x|>|y| - { - ax = abs(x); // |x| => ax - yx = (x/y); - } - yx2 = yx*yx; // (x/y)^2 - yx1 = sqrt(1+yx2); // (1 + (x/y)^2)^1/2 - return ax*yx1; // |x|*((1 + (x/y)^2)^1/2) -} - -#if !(defined (NONET) || defined (NOMD5)) -#ifdef HAVE_LWIP - -#include - -static uint8 ip[4]; -static char *h_addr_listtmp[2] = {ip, NULL}; -static struct hostent hostenttmp = {NULL, NULL, 0, 1, h_addr_listtmp}; - -struct hostent *gethostbyname(const char *name) -{ - struct sockaddr_in dnssrv; - dnssrv.sin_family = AF_INET; - dnssrv.sin_port = htons(53); - dnssrv.sin_addr.s_addr = htonl(0x0a030202); ///< what? - if (lwip_gethostbyname(&dnssrv, name, ip) < 0) - return NULL; - else - return &hostenttmp; -} -#else - -struct hostent *gethostbyname(const char *name) -{ - (void)name; - return NULL; -} - -int ioctl(int s, long cmd, void *argp) -{ - return fs_ioctl(s, argp, cmd); //FIONBIO? -} - -int select(int maxfdp1, void *readset, void *writeset, void *exceptset, - void *timeout) -{ - (void)maxfdp1; - (void)readset; - (void)writeset; - (void)exceptset; - (void)timeout; - errno = EAFNOSUPPORT; - return -1; -} - -int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) -{ - (void)s; - (void)level; //SOL_SOCKET - (void)optname; //SO_RCVBUF, SO_ERROR - (void)optval; - (void)optlen; - errno = EAFNOSUPPORT; - return -1; -} - -int setsockopt (int s, int level, int optname, void *optval, socklen_t optlen) -{ - (void)s; - (void)level; //SOL_SOCKET - (void)optname; //SO_REUSEADDR, SO_BROADCAST, SO_RCVBUF - (void)optval; - (void)optlen; - errno = EAFNOSUPPORT; - return -1; -} - -#endif -#endif diff --git a/src/sdl12/SRB2DC/dchelp.h b/src/sdl12/SRB2DC/dchelp.h deleted file mode 100644 index 3647f9c89..000000000 --- a/src/sdl12/SRB2DC/dchelp.h +++ /dev/null @@ -1,51 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2006-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// stub and replacement "ANSI" C functions for use on Dreamcast/KOS -// -//----------------------------------------------------------------------------- - -#ifndef __I_DREAMCAST__ -#define __I_DREAMCAST__ - -struct hostent -{ - char *h_name; /* Official name of host. */ - char **h_aliases; /* Alias list. */ - int h_addrtype; /* Host address type. */ - int h_length; /* Length of address. */ - char **h_addr_list; /* List of addresses from name server. */ -#define h_addr h_addr_list[0] /* Address, for backward compatibility. */ -}; - -struct hostent *gethostbyname(const char *name); - -#ifndef HAVE_LWIP -#define INADDR_NONE ((uint32) 0xffffffff) -#define INADDR_LOOPBACK ((uint32) 0x7f000001) -#define SOCK_STREAM 1 -#define FIONBIO 0 -#define SOL_SOCKET 0 -#define SO_ERROR 0 -#define SO_REUSEADDR 0 -#define SO_BROADCAST 0 -#define SO_RCVBUF 0 -int ioctl(int s, long cmd, void *argp); -int select(int maxfdp1, void *readset, void *writeset, void *exceptset, void *timeout); -int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen); -int setsockopt(int s, int level, int optname, void *optval, socklen_t optlen); -#endif -#endif diff --git a/src/sdl12/SRB2DC/i_udp.c b/src/sdl12/SRB2DC/i_udp.c deleted file mode 100644 index cf7654c10..000000000 --- a/src/sdl12/SRB2DC/i_udp.c +++ /dev/null @@ -1,455 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 2005-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief KOS UDP network interface - -#include "../../doomdef.h" - -#include "../../i_system.h" -#include "../../d_event.h" -#include "../../d_net.h" -#include "../../m_argv.h" - -#include "../../doomstat.h" - -#include "../../i_net.h" - -#include "../../z_zone.h" - -#include "../../i_tcp.h" - -#include -//#include -#define NET_NONE 0x00000000 -#define NET_LOCAL 0x0100007F -#define NET_ANY 0xFFFFFFFF - -#define MAXBANS 20 - -typedef struct -{ - uint32 host; - uint16 port; -} IPaddress; - -static IPaddress clientaddress[MAXNETNODES+1]; -static boolean nodeconnected[MAXNETNODES+1]; - -static int mysocket = 0; -static boolean init_KOSUDP_driver = false; - -static size_t numbans = 0; -static IPaddress banned[MAXBANS]; -static boolean KOSUDP_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? - -static inline int net_udp_sendto(int sock, const uint8 *data, int size, uint16 rem_port, uint32 rem_addr) -{ - uint8 dst_ip[4] = {((uint8*)(&(rem_addr)))[0], - ((uint8*)(&(rem_addr)))[1], - ((uint8*)(&(rem_addr)))[2], - ((uint8*)(&(rem_addr)))[3]}; - return net_udp_send_raw(net_default_dev, clientaddress[0].port, rem_port, dst_ip, data, size); - (void)sock; -} - -static inline int net_udp_recvfrom(int sock, uint8 *buf, int size, uint16 *rem_port, uint32 *rem_addr) -{ - return net_udp_recv(sock, buf, size); - (void)rem_port; - (void)rem_addr; -} - -static const char *KOSUDP_AddrToStr(IPaddress* sk) -{ - static char s[22]; // 255.255.255.255:65535 - sprintf(s,"%d.%d.%d.%d:%d", - ((uint8*)(&(sk->host)))[3], - ((uint8*)(&(sk->host)))[2], - ((uint8*)(&(sk->host)))[1], - ((uint8*)(&(sk->host)))[0], - net_ntohs(sk->port)); - return s; -} - -static const char *KOSUDP_GetNodeAddress(int node) -{ - if (!nodeconnected[node]) - return NULL; - return KOSUDP_AddrToStr(&clientaddress[node]); -} - -static const char *KOSUDP_GetBanAddress(size_t ban) -{ - if (ban > numbans) - return NULL; - return KOSUDP_AddrToStr(&banned[ban]); -} - -static boolean KOSUDP_cmpaddr(IPaddress* a, IPaddress* b) -{ - return (a->host == b->host && (b->port == 0 || a->port == b->port)); -} - -static SINT8 getfreenode(void) -{ - SINT8 j; - - for (j = 0; j < MAXNETNODES; j++) - if (!nodeconnected[j]) - { - nodeconnected[j] = true; - return j; - } - return -1; -} - -static void KOSUDP_Get(void) -{ - int size; - size_t i; - SINT8 j; - IPaddress temp = {clientaddress[BROADCASTADDR].host,clientaddress[BROADCASTADDR].port}; - - size = net_udp_recvfrom(mysocket,(char *)&doomcom->data, MAXPACKETLENGTH, &temp.port, &temp.host); - if (size == 0) - { - doomcom->remotenode = -1; // no packet - return; - } - - // find remote node number - for (i = 0; i < MAXNETNODES; i++) - if (KOSUDP_cmpaddr(&temp, &(clientaddress[i]))) - { - doomcom->remotenode = (INT16)i; // good packet from a game player - doomcom->datalength = (INT16)size; - return; - } - - // not found - - // find a free slot - j = getfreenode(); - if (j > 0) - { - M_Memcpy(&clientaddress[j], &temp, sizeof (temp)); - DEBFILE(va("New node detected: node:%d address:%s\n", j, - KOSUDP_GetNodeAddress(j))); - doomcom->remotenode = (INT16)j; // good packet from a game player - doomcom->datalength = (INT16)size; - // check if it's a banned dude so we can send a refusal later - for (i = 0; i < numbans; i++) - if (KOSUDP_cmpaddr(&temp, &banned[i])) - { - KOSUDP_bannednode[j] = true; - DEBFILE("This dude has been banned\n"); - break; - } - if (i == numbans) - KOSUDP_bannednode[j] = false; - return; - } - - DEBFILE("New node detected: No more free slots\n"); - doomcom->remotenode = -1; // no packet -} - -#if 0 -static boolean KOSUDP_CanSend(void) -{ - return true; -} -#endif - -static void KOSUDP_Send(void) -{ - const IPaddress *nodeinfo; - - if (!doomcom->remotenode || !nodeconnected[doomcom->remotenode]) - return; - - nodeinfo = clientaddress + doomcom->remotenode; - - if (net_udp_sendto(mysocket, (char *)&doomcom->data, doomcom->datalength, nodeinfo->port, nodeinfo->host) == -1) - { - CONS_Printf("KOSUDP: error sending data\n"); - } -} - -static void KOSUDP_FreeNodenum(int numnode) -{ - // can't disconnect from self :) - if (!numnode) - return; - - DEBFILE(va("Free node %d (%s)\n", numnode, KOSUDP_GetNodeAddress(numnode))); - - nodeconnected[numnode] = false; - - memset(&clientaddress[numnode], 0, sizeof (IPaddress)); -} - -static int KOSUDP_Socket(void) -{ - int temp = 0; - uint16 portnum = 0; - const uint32 hostip = net_default_dev?net_ntohl(net_ipv4_address(net_default_dev->ip_addr)):NET_LOCAL; - //Hurdler: I'd like to put a server and a client on the same computer - //Logan: Me too - //BP: in fact for client we can use any free port we want i have read - // in some doc that connect in udp can do it for us... - //Alam: where? - if (M_CheckParm("-clientport")) - { - if (!M_IsNextParm()) - I_Error("syntax: -clientport "); - portnum = net_ntohs(atoi(M_GetNextParm())); - } - else - portnum = net_ntohs(sock_port); - - temp = net_udp_sock_open(portnum, hostip, portnum, NET_NONE); - if (temp) - { - int btemp = net_udp_sock_open(portnum, hostip, portnum, NET_ANY); - clientaddress[0].port = portnum; - clientaddress[0].host = NET_NONE; - if (btemp) - { - clientaddress[BROADCASTADDR].port = net_ntohs(sock_port); - clientaddress[BROADCASTADDR].host = NET_ANY; - } - else - { - CONS_Printf("KOSUDP: can't setup broadcast sock\n"); - net_udp_sock_close(temp); - return 0; - } - } - else - { - CONS_Printf("KOSUDP: can't setup main sock\n"); - return 0; - } - - doomcom->extratics = 1; // internet is very high ping - - return temp; -} - -static void I_ShutdownKOSUDPDriver(void) -{ - //net_shutdown(); - init_KOSUDP_driver = false; -} - -static void I_InitKOSUDPDriver(void) -{ - if (init_KOSUDP_driver) - I_ShutdownKOSUDPDriver(); - else - net_init(); - D_SetDoomcom(); - memset(&clientaddress,0,sizeof (clientaddress)); - init_KOSUDP_driver = true; -} - -static void KOSUDP_CloseSocket(void) -{ - if (mysocket) - net_udp_sock_close(mysocket); - mysocket = 0; -} - -static SINT8 KOSUDP_NetMakeNodewPort(const char *hostname, const char* port) -{ - SINT8 newnode; - uint16 portnum = net_ntohs(sock_port); - - if (port && !port[0]) - portnum = net_ntohs((UINT16)atoi(port)); - - newnode = getfreenode(); - if (newnode == -1) - return -1; - // find ip of the server - clientaddress[newnode].port = portnum; - clientaddress[newnode].host = inet_addr(hostname); - - if (clientaddress[newnode].host == NET_NONE) - { - free(hostname); - return -1; - } - return newnode; -} - -static boolean KOSUDP_OpenSocket(void) -{ - size_t i; - - memset(clientaddress, 0, sizeof (clientaddress)); - - for (i = 0; i < MAXNETNODES; i++) - nodeconnected[i] = false; - - //CONS_Printf("KOSUDP Code starting up\n"); - - nodeconnected[0] = true; // always connected to self - nodeconnected[BROADCASTADDR] = true; - I_NetSend = KOSUDP_Send; - I_NetGet = KOSUDP_Get; - I_NetCloseSocket = KOSUDP_CloseSocket; - I_NetFreeNodenum = KOSUDP_FreeNodenum; - I_NetMakeNodewPort = KOSUDP_NetMakeNodewPort; - - //I_NetCanSend = KOSUDP_CanSend; - - // build the socket but close it first - KOSUDP_CloseSocket(); - mysocket = KOSUDP_Socket(); - - if (mysocket) - { -#if 0 - // for select - myset = SDLNet_AllocSocketSet(1); - if (!myset) - { - CONS_Printf("SDL_Net: %s",SDLNet_GetError()); - return false; - } - if (SDLNet_UDP_AddSocket(myset,mysocket) == -1) - { - CONS_Printf("SDL_Net: %s",SDLNet_GetError()); - return false; - } -#endif - return true; - } - return false; -} - -static boolean KOSUDP_Ban(int node) -{ - if (numbans == MAXBANS) - return false; - - M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); - banned[numbans].port = 0' - numbans++; - return true; -} - -static void KOSUDP_ClearBans(void) -{ - numbans = 0; -} - -// -// I_InitNetwork -// Only required for DOS, so this is more a dummy -// -boolean I_InitNetwork(void) -{ - char serverhostname[255]; - boolean ret = false; - //if (!M_CheckParm ("-kosnet")) - // return false; - // initilize the driver - I_InitKOSUDPDriver(); - I_AddExitFunc(I_ShutdownKOSUDPDriver); - if (!init_KOSUDP_driver) - return false; - - if (M_CheckParm("-udpport")) - { - if (M_IsNextParm()) - sock_port = (UINT16)atoi(M_GetNextParm()); - else - sock_port = 0; - } - - // parse network game options, - if (M_CheckParm("-server") || dedicated) - { - server = true; - - // If a number of clients (i.e. nodes) is specified, the server will wait for the clients - // to connect before starting. - // If no number is specified here, the server starts with 1 client, and others can join - // in-game. - // Since Boris has implemented join in-game, there is no actual need for specifying a - // particular number here. - // FIXME: for dedicated server, numnodes needs to be set to 0 upon start -/* if (M_IsNextParm()) - doomcom->numnodes = (INT16)atoi(M_GetNextParm()); - else */if (dedicated) - doomcom->numnodes = 0; - else - doomcom->numnodes = 1; - - if (doomcom->numnodes < 0) - doomcom->numnodes = 0; - if (doomcom->numnodes > MAXNETNODES) - doomcom->numnodes = MAXNETNODES; - - // server - servernode = 0; - // FIXME: - // ??? and now ? - // server on a big modem ??? 4*isdn - net_bandwidth = 16000; - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - - ret = true; - } - else if (M_CheckParm("-connect")) - { - if (M_IsNextParm()) - strcpy(serverhostname, M_GetNextParm()); - else - serverhostname[0] = 0; // assuming server in the LAN, use broadcast to detect it - - // server address only in ip - if (serverhostname[0]) - { - COM_BufAddText("connect \""); - COM_BufAddText(serverhostname); - COM_BufAddText("\"\n"); - - // probably modem - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - } - else - { - // so we're on a LAN - COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - } - } - - I_NetOpenSocket = KOSUDP_OpenSocket; - I_Ban = KOSUDP_Ban; - I_ClearBans = KOSUDP_ClearBans; - I_GetNodeAddress = KOSUDP_GetNodeAddress; - I_GetBanAddress = KOSUDP_GetBanAddress; - bannednode = KOSUDP_bannednode; - - return ret; -} diff --git a/src/sdl12/SRB2DC/scramble.c b/src/sdl12/SRB2DC/scramble.c deleted file mode 100644 index a3483b00d..000000000 --- a/src/sdl12/SRB2DC/scramble.c +++ /dev/null @@ -1,259 +0,0 @@ -#include -#include - -#define MAXCHUNK (2048*1024) - -static unsigned int seed; - -void my_srand(unsigned int n) -{ - seed = n & 0xffff; -} - -unsigned int my_rand() -{ - seed = (seed * 2109 + 9273) & 0x7fff; - return (seed + 0xc000) & 0xffff; -} - -void load(FILE *fh, unsigned char *ptr, unsigned long sz) -{ - if (fread(ptr, 1, sz, fh) != sz) - { - fprintf(stderr, "Read error!\n"); - exit(1); - } -} - -void load_chunk(FILE *fh, unsigned char *ptr, unsigned long sz) -{ - static int idx[MAXCHUNK/32]; - int i; - - /* Convert chunk size to number of slices */ - sz /= 32; - - /* Initialize index table with unity, - so that each slice gets loaded exactly once */ - for (i = 0; i < sz; i++) - idx[i] = i; - - for (i = sz-1; i >= 0; --i) - { - /* Select a replacement index */ - int x = (my_rand() * i) >> 16; - - /* Swap */ - int tmp = idx[i]; - idx[i] = idx[x]; - idx[x] = tmp; - - /* Load resulting slice */ - load(fh, ptr+32*idx[i], 32); - } -} - -void load_file(FILE *fh, unsigned char *ptr, unsigned long filesz) -{ - unsigned long chunksz; - - my_srand(filesz); - - /* Descramble 2 meg blocks for as long as possible, then - gradually reduce the window down to 32 bytes (1 slice) */ - for (chunksz = MAXCHUNK; chunksz >= 32; chunksz >>= 1) - while (filesz >= chunksz) - { - load_chunk(fh, ptr, chunksz); - filesz -= chunksz; - ptr += chunksz; - } - - /* Load final incomplete slice */ - if (filesz) - load(fh, ptr, filesz); -} - -void read_file(char *filename, unsigned char **ptr, unsigned long *sz) -{ - FILE *fh = fopen(filename, "rb"); - if (fh == NULL) - { - fprintf(stderr, "Can't open \"%s\".\n", filename); - exit(1); - } - if (fseek(fh, 0, SEEK_END)<0) - { - fprintf(stderr, "Seek error.\n"); - exit(1); - } - *sz = ftell(fh); - *ptr = malloc(*sz); - if ( *ptr == NULL ) - { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } - if (fseek(fh, 0, SEEK_SET)<0) - { - fprintf(stderr, "Seek error.\n"); - exit(1); - } - load_file(fh, *ptr, *sz); - fclose(fh); -} - -void save(FILE *fh, unsigned char *ptr, unsigned long sz) -{ - if (fwrite(ptr, 1, sz, fh) != sz) - { - fprintf(stderr, "Write error!\n"); - exit(1); - } -} - -void save_chunk(FILE *fh, unsigned char *ptr, unsigned long sz) -{ - static int idx[MAXCHUNK/32]; - int i; - - /* Convert chunk size to number of slices */ - sz /= 32; - - /* Initialize index table with unity, - so that each slice gets saved exactly once */ - for (i = 0; i < sz; i++) - idx[i] = i; - - for (i = sz-1; i >= 0; --i) - { - /* Select a replacement index */ - int x = (my_rand() * i) >> 16; - - /* Swap */ - int tmp = idx[i]; - idx[i] = idx[x]; - idx[x] = tmp; - - /* Save resulting slice */ - save(fh, ptr+32*idx[i], 32); - } -} - -void save_file(FILE *fh, unsigned char *ptr, unsigned long filesz) -{ - unsigned long chunksz; - - my_srand(filesz); - - /* Descramble 2 meg blocks for as long as possible, then - gradually reduce the window down to 32 bytes (1 slice) */ - for (chunksz = MAXCHUNK; chunksz >= 32; chunksz >>= 1) - while (filesz >= chunksz) - { - save_chunk(fh, ptr, chunksz); - filesz -= chunksz; - ptr += chunksz; - } - - /* Save final incomplete slice */ - if (filesz) - save(fh, ptr, filesz); -} - -void write_file(char *filename, unsigned char *ptr, unsigned long sz) -{ - FILE *fh = fopen(filename, "wb"); - if (fh == NULL) - { - fprintf(stderr, "Can't open \"%s\".\n", filename); - exit(1); - } - save_file(fh, ptr, sz); - fclose(fh); -} - -void descramble(char *src, char *dst) -{ - unsigned char *ptr = NULL; - unsigned long sz = 0; - FILE *fh; - - read_file(src, &ptr, &sz); - - fh = fopen(dst, "wb"); - if (fh == NULL) - { - fprintf(stderr, "Can't open \"%s\".\n", dst); - exit(1); - } - if ( fwrite(ptr, 1, sz, fh) != sz ) - { - fprintf(stderr, "Write error.\n"); - exit(1); - } - fclose(fh); - free(ptr); -} - -void scramble(char *src, char *dst) -{ - unsigned char *ptr = NULL; - unsigned long sz = 0; - FILE *fh; - - fh = fopen(src, "rb"); - if (fh == NULL) - { - fprintf(stderr, "Can't open \"%s\".\n", src); - exit(1); - } - if (fseek(fh, 0, SEEK_END)<0) - { - fprintf(stderr, "Seek error.\n"); - exit(1); - } - sz = ftell(fh); - ptr = malloc(sz); - if ( ptr == NULL ) - { - fprintf(stderr, "Out of memory.\n"); - exit(1); - } - if (fseek(fh, 0, SEEK_SET)<0) - { - fprintf(stderr, "Seek error.\n"); - exit(1); - } - if ( fread(ptr, 1, sz, fh) != sz ) - { - fprintf(stderr, "Read error.\n"); - exit(1); - } - fclose(fh); - - write_file(dst, ptr, sz); - - free(ptr); -} - -int main(int argc, char *argv[]) -{ - int opt = 0; - - if (argc > 1 && !strcmp(argv[1], "-d")) - opt ++; - - if (argc != 3+opt) - { - fprintf(stderr, "Usage: %s [-d] from to\n", argv[0]); - exit(1); - } - - if (opt) - descramble(argv[2], argv[3]); - else - scramble(argv[1], argv[2]); - - return 0; -} diff --git a/src/sdl12/SRB2PS3/ICON0.png b/src/sdl12/SRB2PS3/ICON0.png deleted file mode 100644 index 140230c1e..000000000 Binary files a/src/sdl12/SRB2PS3/ICON0.png and /dev/null differ diff --git a/src/sdl12/SRB2PS3/Makefile.cfg b/src/sdl12/SRB2PS3/Makefile.cfg deleted file mode 100644 index 80f8db7bc..000000000 --- a/src/sdl12/SRB2PS3/Makefile.cfg +++ /dev/null @@ -1,139 +0,0 @@ -# -# Makefile.cfg for SRB2 for the PlayStation 3 using PSL1GHT -# - -# Check if PS3DEV and PSL1GHT is set in the environment. If so, continue with compilation. -.SUFFIXES: - -ifeq ($(strip $(PS3DEV)),) -$(error "Please set PS3DEV in your environment. export PS3DEV=ps3dev-toolchain") -endif - -ifeq ($(strip $(PSL1GHT)),) -$(error "Please set PSL1GHT in your environment. export PSL1GHT=PSL1GHT") -endif - -# Set compiler flags - -# Disable same warning flags -WFLAGS+=-Wno-shadow -Wno-char-subscripts -Wno-format - -ifdef JAILBREAK -EXENAME?=SRB2PS3-jb.elf -PKGNAME?=SRB2PS3-jb.pkg -else -EXENAME?=SRB2PS3.elf -PKGNAME?=SRB2PS3.pkg -endif -DGBNAME?=$(EXENAME).debug - -SRB2PS3DIR=sdl12/SRB2PS3 -ICON0?=$(SRB2PS3DIR)/ICON0.png -SFOXML?=sfo.xml -SRB2TTF?=sdl12/srb2.ttf - -TITLE=Sonic Robo Blast 2 v2.0.6 -APPID=SRB2-PS3 -CONTENTID=UP0001-$(APPID)_00-0000000000000000 - -FSELF=$(PS3DEV)/bin/fself.py -MAKE_SELF_NPDRM=$(PS3DEV)/ps3publictools/make_self_npdrm -FINALIZE=$(PS3DEV)/ps3publictools/package_finalize -SFO=$(PS3DEV)/bin/sfo.py -PKG=$(PS3DEV)/bin/pkg.py -PS3LOADEXE=$(PS3DEV)/ps3tools/ps3load -SED=sed -MV=mv -XARGS=xargs -FOR=for -SHXARGS:=$(XARGS) -SHSED:=$(SED) -SPRXLINKER=$(PS3DEV)/bin/sprxlinker - -ifdef JAILBREAK -PKGDIR=$(BIN)/pkg-jb -else -PKGDIR=$(BIN)/pkg -endif -USRDIR=$(PKGDIR)/USRDIR -ETCDIR=$(USRDIR)/etc -WGET=wget -P $(ETCDIR) -c -nc - -ifndef ECHO - FSELF:=@$(FSELF) - MAKE_SELF_NPDRM:=@$(MAKE_SELF_NPDRM) - FINALIZE:=@$(FINALIZE) - SFO:=@$(SFO) - PKG:=@$(PKG) - PS3LOADEXE:=@$(PS3LOADEXE) - SED:=@$(SED) - MV:=@$(MV) - SPRXLINKER:=@$(SPRXLINKER) - XARGS:=@$(XARGS) - FOR:=@(FOR) -endif - -# SRB2PS3 needs SDL_ttf to display any console text -SDL_TTF=1 - -# newlib has no support for networking -#NONET=1 - -# use absolute paths because changing PATH variable breaks distcc -PREFIX := $(PS3DEV)/ppu/bin/$(PREFIX) - -# PS3DEV toolchain libdir and includedir -PS3DEV_INC := $(PS3DEV)/ppu/include -PS3DEV_LIB := $(PS3DEV)/ppu/lib - -# PSL1GHT libdir and includedir -PSL1GHT_INC := $(PSL1GHT)/ppu/include -PSL1GHT_LIB := $(PSL1GHT)/ppu/lib - -PS3PORTS := $(PS3DEV)/portlibs -PS3PORTS_BIN := $(PS3PORTS)/ppu/bin -PS3PORTS_INC := $(PS3PORTS)/ppu/include - -PNG_CONFIG := $(PS3PORTS_BIN)/libpng-config -# static compilation -PNG_STATIC=1 - -SDL_CONFIG := $(PS3PORTS_BIN)/sdl-config - -INCLUDE := -I$(PSL1GHT_INC) -I$(PS3DEV_INC) -I$(PS3PORTS_INC) - -OPTS+=-D_PS3 -DUNIXCOMMON -CFLAGS+= -g $(INCLUDE) -L$(PSL1GHT_LIB) -L$(PS3DEV_LIB) -L$(PS3DEV)/lib -CXXFLAGS+=$(CFLAGS) -LDFLAGS+= -B$(PSL1GHT_LIB) -B$(PS3DEV_LIB) -B$(PS3DEV)/lib -LIBS+=-lrsx -ifndef NONET -LIBS+=-lnet -lsysmodule -endif - -$(BIN)/$(PKGNAME): $(OBJS) $(BIN)/$(EXENAME) - @echo Linking $(PKGNAME)... - -$(MKDIR) $(ETCDIR) - $(CP) $(ICON0) $(PKGDIR) - $(CP) $(SRB2TTF) $(ETCDIR) -ifdef WITHDATA - $(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) 's/\.srb/\.wad/' | $(SHXARGS) -n 1 basename); do \ - $(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \ - done -endif - $(SPRXLINKER) $(BIN)/$(EXENAME) -ifdef JAILBREAK - $(SED) 's/@@PS3_SYSTEM_VER@@/3.41/' $(SRB2PS3DIR)/$(SFOXML) > $(BIN)/$(SFOXML) - $(FSELF) -n $(BIN)/$(EXENAME) $(USRDIR)/EBOOT.BIN -else - $(SED) 's/@@PS3_SYSTEM_VER@@/3.55/' $(SRB2PS3DIR)/$(SFOXML) > $(BIN)/$(SFOXML) - $(MAKE_SELF_NPDRM) $(BIN)/$(EXENAME) $(USRDIR)/EBOOT.BIN $(CONTENTID) -endif - $(SFO) --title "$(TITLE)" --appid "$(APPID)" -f $(BIN)/$(SFOXML) $(PKGDIR)/PARAM.SFO - $(PKG) --contentid $(CONTENTID) $(PKGDIR)/ $(BIN)/$(PKGNAME) -ifndef JAILBREAK - $(FINALIZE) $(BIN)/$(PKGNAME) -endif - -run: $(BIN)/$(EXENAME) - $(PS3LOADEXE) $(USRDIR)/EBOOT.BIN diff --git a/src/sdl12/SRB2PS3/sfo.xml b/src/sdl12/SRB2PS3/sfo.xml deleted file mode 100644 index d7719b540..000000000 --- a/src/sdl12/SRB2PS3/sfo.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - 02.06 - - - 0 - - - 1 - - - HG - - - This application was created with the official non-official SDK called PSL1GHT, for more information visit http://www.psl1ght.com/ . This is in no way associated with Sony Computer Entertainment Inc., please do not contact them for help, they will not be able to provide it. - - - 0 - - - 0@@PS3_SYSTEM_VER@@00 - - - 63 - - - 279 - - - Sonic Robo Blast 2 - - - SRB200000 - - - 02.06 - - diff --git a/src/sdl12/SRB2PSP/ICON0.png b/src/sdl12/SRB2PSP/ICON0.png deleted file mode 100644 index 140230c1e..000000000 Binary files a/src/sdl12/SRB2PSP/ICON0.png and /dev/null differ diff --git a/src/sdl12/SRB2PSP/Makefile.cfg b/src/sdl12/SRB2PSP/Makefile.cfg deleted file mode 100644 index 5e4c0ba2f..000000000 --- a/src/sdl12/SRB2PSP/Makefile.cfg +++ /dev/null @@ -1,126 +0,0 @@ -# -# Makefile.cfg for SRB2/PSP -# - -# -#hmmm, the PSP -# - - PSPSDK=$(shell psp-config -p) - PSPDEV=$(shell psp-config -d) - PSPPREFIX=$(shell psp-config -P) - STRIP=psp-strip - MKSFO?=mksfoex -d MEMSIZE=1 - #MKSFO=mksfo - PACK_PBP=pack-pbp - FIXUP=psp-fixup-imports - HOSTCC:=$(CC) - CC=$(PSPDEV)/bin/psp-gcc - OBJCOPY=psp-objcopy - OBJDUMP=psp-objdump -ifdef FIXEDPRX - PRXGEN=psp-prxgen -else - PRXGEN=$(OBJCOPY) -endif -ifndef PRXSIGN - SIGNER:=$(PSPDEV)/bin/$(OBJCOPY) -endif - -ifndef ECHO - MKSFO:=@$(MKSFO) - PACK_PBP:=@$(PACK_PBP) - FIXUP:=@$(FIXUP) - PRXGEN:=@$(PRXGEN) -endif - - PSP_EBOOT_TITLE=SRB2-PSP vME - PSP_EBOOT_SFO=$(BIN)/PARAM.SFO - PSP_EBOOT_ICON=sdl12/SRB2PSP/ICON0.png - PSP_EBOOT_ICON1=NULL - PSP_EBOOT_UNKPNG=NULL - PSP_EBOOT_PIC1=sdl12/SRB2PSP/PIC1.png - PSP_EBOOT_SND0=NULL - PSP_EBOOT_PSAR=NULL - - SIGNER?=sdl12/SRB2PSP/psp-prxsign/psp-prxsign - - SDL=1 - PREFIX=psp - NONX86=1 - #NOHW=1 - NOHS=1 - NOMD5=1 - NONET=1 #No TCPIP code - NOPNG=1 #No Screenshot - - OPTS=-I$(PSPPREFIX)/include -I$(PSPSDK)/include - OPTS+=-DUNIXCOMMON -DFORCESDLMAIN -G0 - WFLAGS+=-Wno-undef - WFLAGS+=-O1 - LIBS=-lm - SDL_CONFIG?=$(PSPPREFIX)/bin/sdl-config - #SDL_CFLAGS?=-I$(PSPDEV)/psp/include/SDL - #SDL_LDFLAGS?=-lSDLmain -lSDL -lglut -lGLU -lGL -lpspgu -lpspaudiolib -lpspaudio -lpsphprm -lpspvfpu -lpsprtc -ifndef NOMIXER - LIBS:=-liberty -lvorbisfile -lvorbis -logg -lSDL $(LIBS) -endif -ifndef NOHW - OPTS+=-DSTATIC_OPENGL -DMINI_GL_COMPATIBILITY - LIBS+=-lGLU -lGL -lm -endif - #PSPSDK_LIBS=-L$(PSPSDK)/lib -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk - #LIBS+=$(PSPSDK_LIBS) -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -ifdef FIXEDPRX - LDFLAGS := -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS) - LIBS+=$(PSPSDK)/lib/prxexports.o -endif - -ifeq ($(PSP_FW_VERSION),) -PSP_FW_VERSION=150 -endif - - CPPFLAGS:=-D_PSP_FW_VERSION=$(PSP_FW_VERSION) $(CPPFLAGS) - - - # name of the exefile - EXENAME?=SRB2PSP.elf - PRXNAME?=SRB2PSP.prx - DBGNAME?=SRB2PSP.debug - -post-build: $(BIN)/EBOOT.PBP - -kxploit: $(BIN)/$(EXENAME) $(PSP_EBOOT_SFO) - -$(MKDIR) "$(BIN)/kxploit/srb2" - @echo emitting kxploit/srb2/ - $(STRIP) $(BIN)/$(EXENAME) -o $(BIN)/kxploit/srb2/EBOOT.PBP - @echo emitting kxploit/srb2% - -$(MKDIR) "$(BIN)/kxploit/srb2%/" - $(PACK_PBP) "$(BIN)/kxploit/srb2%/EBOOT.PBP" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \ - $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \ - $(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR) - -sdl12/SRB2PSP/psp-prxsign/psp-prxsign: - -$(MAKE) -C sdl12/SRB2PSP/psp-prxsign CFLAGS=-pipe CC="$(HOSTCC)" - -fix-up: $(BIN)/$(EXENAME) - @echo Running psp-fixup-imports on $(EXENAME) - $(FIXUP) $(BIN)/$(EXENAME) - -$(BIN)/$(PRXNAME): $(BIN)/$(EXENAME) fix-up - @echo Building $(PRXNAME) out of $(EXENAME) - $(PRXGEN) $(BIN)/$(EXENAME) $@ - -$(BIN)/EBOOT.PBP: $(BIN)/$(PRXNAME) $(SIGNER) $(PSP_EBOOT_SFO) - @echo Signing and running pack-pbp to make PBP - $(SIGNER) $(BIN)/$(PRXNAME) $(BIN)/$(PRXNAME).sign - $(PACK_PBP) $@ $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \ - $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1) \ - $(PSP_EBOOT_SND0) $(BIN)/$(PRXNAME).sign $(PSP_EBOOT_PSAR) - $(REMOVE) $(BIN)/$(PRXNAME).sign - -$(PSP_EBOOT_SFO): - -$(MKDIR) $(BIN) - $(MKSFO) '$(PSP_EBOOT_TITLE)' $@ - -#include $(PSPSDK)/lib/build.mak diff --git a/src/sdl12/SRB2PSP/PIC1.png b/src/sdl12/SRB2PSP/PIC1.png deleted file mode 100644 index 0722a96bc..000000000 Binary files a/src/sdl12/SRB2PSP/PIC1.png and /dev/null differ diff --git a/src/sdl12/SRB2PSP/psp-prxsign/.gitignore b/src/sdl12/SRB2PSP/psp-prxsign/.gitignore deleted file mode 100644 index 6a07f1a5a..000000000 --- a/src/sdl12/SRB2PSP/psp-prxsign/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/psp-prxsign -/psp-prxsign.exe diff --git a/src/sdl12/SRB2PSP/psp-prxsign/Makefile b/src/sdl12/SRB2PSP/psp-prxsign/Makefile deleted file mode 100644 index 4a9b7da0f..000000000 --- a/src/sdl12/SRB2PSP/psp-prxsign/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -EXE=psp-prxsign -SRC=main.c cmac.c -OBJ=$(SRC:.c=.o)# replaces the .c from SRC with .o - -OPENSSL_PKGCONFIG?=openssl -OPENSSL_CFLAGS?=$(shell pkg-config $(OPENSSL_PKGCONFIG) --cflags) -OPENSSL_LDFLAGS?=$(shell pkg-config $(OPENSSL_PKGCONFIG) --libs) - -CFLAGS+=$(OPENSSL_CFLAGS) -LDFLAGS+=$(OPENSSL_LDFLAGS) - -.PHONY : all # .PHONY ignores files named all - -all: $(EXE) # all is dependent on $(BIN) to be complete - - -$(EXE): $(OBJ) # $(EXE) is dependent on all of the files in $(OBJ) to exist - $(CC) $^ $(LDFLAGS) -o $@ - -.PHONY : clean # .PHONY ignores files named clean -clean: - -$(RM) $(OBJ) $(EXE) diff --git a/src/sdl12/SRB2PSP/psp-prxsign/cmac.c b/src/sdl12/SRB2PSP/psp-prxsign/cmac.c deleted file mode 100644 index f527f7a71..000000000 --- a/src/sdl12/SRB2PSP/psp-prxsign/cmac.c +++ /dev/null @@ -1,130 +0,0 @@ -#include "cmac.h" - -#define AES_128 0 -unsigned char const_Rb[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87 -}; -unsigned char const_Zero[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -void xor_128(unsigned char *a, unsigned char *b, unsigned char *out) -{ - int i; - for (i=0;i<16; i++) - { - out[i] = a[i] ^ b[i]; - } -} - -/* AES-CMAC Generation Function */ - -static inline void leftshift_onebit(unsigned char *input,unsigned char *output) -{ - int i; - unsigned char overflow = 0; - - for ( i=15; i>=0; i-- ) - { - output[i] = input[i] << 1; - output[i] |= overflow; - overflow = (input[i] & 0x80)?1:0; - } -} - -void generate_subkey(unsigned char *key, unsigned char *K1, unsigned char *K2) -{ - unsigned char L[16]; - unsigned char Z[16]; - unsigned char tmp[16]; - int i; - - for ( i=0; i<16; i++ ) Z[i] = 0; - - AES_KEY aes; - AES_set_encrypt_key(key, 128, &aes); - - AES_encrypt(Z, L, &aes); - - if ( (L[0] & 0x80) == 0 ) /* If MSB(L) = 0, then K1 = L << 1 */ - { - leftshift_onebit(L,K1); - } else { /* Else K1 = ( L << 1 ) (+) Rb */ - leftshift_onebit(L,tmp); - xor_128(tmp,const_Rb,K1); - } - - if ( (K1[0] & 0x80) == 0 ) - { - leftshift_onebit(K1,K2); - } else { - leftshift_onebit(K1,tmp); - xor_128(tmp,const_Rb,K2); - } -} - -static inline void padding ( unsigned char *lastb, unsigned char *pad, int length ) -{ - int j; - - /* original last block */ - for ( j=0; j<16; j++ ) - { - if ( j < length ) - { - pad[j] = lastb[j]; - } else if ( j == length ) { - pad[j] = 0x80; - } else { - pad[j] = 0x00; - } - } -} - -void AES_CMAC ( unsigned char *key, unsigned char *input, int length, unsigned char *mac ) -{ - unsigned char X[16],Y[16], M_last[16], padded[16]; - unsigned char K1[16], K2[16]; - int n, i, flag; - generate_subkey(key,K1,K2); - - n = (length+15) / 16; /* n is number of rounds */ - - if ( n == 0 ) - { - n = 1; - flag = 0; - } else { - if ( (length%16) == 0 ) { /* last block is a complete block */ - flag = 1; - } else { /* last block is not complete block */ - flag = 0; - } - - } - - if ( flag ) { /* last block is complete block */ - xor_128(&input[16*(n-1)],K1,M_last); - } else { - padding(&input[16*(n-1)],padded,length%16); - xor_128(padded,K2,M_last); - } - AES_KEY aes; - AES_set_encrypt_key(key, 128, &aes); - - for ( i=0; i<16; i++ ) X[i] = 0; - for ( i=0; i -#include - -void xor_128(unsigned char *a, unsigned char *b, unsigned char *out); -void generate_subkey(unsigned char *key, unsigned char *K1, unsigned char *K2); -void AES_CMAC(unsigned char *key, unsigned char *input, int length, unsigned char *mac); - -#endif diff --git a/src/sdl12/SRB2PSP/psp-prxsign/kirk_header.h b/src/sdl12/SRB2PSP/psp-prxsign/kirk_header.h deleted file mode 100644 index 76c921ef0..000000000 --- a/src/sdl12/SRB2PSP/psp-prxsign/kirk_header.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __kirk_header__ -#define __kirk_header__ - -static unsigned int size_kirk_header = 272; -static unsigned char kirk_header[] __attribute__((aligned(16))) = { - 0x2a, 0x4f, 0x3c, 0x49, 0x8a, 0x73, 0x4e, 0xd1, 0xf4, 0x55, 0x93, 0x0b, 0x9b, 0x69, 0xdc, 0x65, - 0x73, 0x22, 0x69, 0xd3, 0x73, 0x96, 0x7a, 0x60, 0x66, 0x8c, 0x88, 0xcf, 0x2f, 0x83, 0x58, 0xbc, - 0xb2, 0x00, 0x0a, 0x11, 0x72, 0x43, 0xc5, 0xde, 0xef, 0xbb, 0x2c, 0xbf, 0x97, 0x79, 0x6b, 0x9c, - 0x10, 0x1e, 0x7c, 0x57, 0x0e, 0xdb, 0x1d, 0x61, 0x6e, 0xb5, 0xf9, 0x3d, 0x35, 0xe9, 0x5c, 0xd8, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x33, 0x55, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x7e, 0x50, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x22, 0x74, 0x69, 0x66, 0x70, 0x73, - 0x70, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x33, 0x55, 0x00, 0x50, 0x34, 0x55, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x67, 0x3d, 0x00, 0x50, 0x55, 0x0a, 0x01, 0x10, 0x00, 0x40, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x6b, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x4c, 0x6b, 0x3d, 0x00, 0xcc, 0xbb, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, -}; - -#endif diff --git a/src/sdl12/SRB2PSP/psp-prxsign/main.c b/src/sdl12/SRB2PSP/psp-prxsign/main.c deleted file mode 100644 index a970ae6c1..000000000 --- a/src/sdl12/SRB2PSP/psp-prxsign/main.c +++ /dev/null @@ -1,190 +0,0 @@ -#include -#include -#include -#include -#include -#include "cmac.h" -#include "kirk_header.h" -#include "psp_header.h" - -typedef unsigned char byte; - -typedef struct { - byte key[16]; - byte ckey[16]; - byte head_hash[16]; - byte data_hash[16]; - byte unused[32]; - int unk1; // 1 - int unk2; // 0 - int unk3[2]; - int datasize; - int dataoffset; - int unk4[6]; -} kirk1head_t; - -// secret kirk command 1 key -byte kirk_key[] = { - 0x98, 0xc9, 0x40, 0x97, 0x5c, 0x1d, 0x10, 0xe8, 0x7f, 0xe6, 0x0e, 0xa3, 0xfd, 0x03, 0xa8, 0xba -}; - -int main(int argc, char **argv) -{ - int i, relrem, size, fullsize, blocks, datasize; - size_t j; - kirk1head_t kirk; - byte iv[16]; - byte cmac[32]; - byte subk[32]; - byte psph[0x150]; - byte *datablob; - byte *filebuff; - FILE *f; - AES_KEY aesKey; - Elf32_Ehdr *ehdr; - Elf32_Shdr *shdr; - Elf32_Rel *relo; - - if(argc < 3) { - printf("Usage: %s unsigned.prx signed.prx\n", argv[0]); - return 1; - } - - // clean kirk header, use modified PRXdecrypter to get it - /*f = fopen(argv[1], "rb"); - if(!f) { - printf("failed to open %s\n", argv[1]); - return 1; - } - fread(&kirk, 1, sizeof(kirk1head_t), f); - fclose(f);*/ - //memcpy(&kirk, kirk_header, size_kirk_header); - memcpy(&kirk, kirk_header, sizeof(kirk1head_t)); - - datasize = kirk.datasize; - if(datasize % 16) datasize += 16 - (datasize % 16); - - // original ~PSP header - /*f = fopen(argv[2], "rb"); - if(!f) { - free(datablob); - printf("failed to open %s\n", argv[2]); - return 1; - } - fread(psph, 1, 0x150, f); - fclose(f);*/ - memcpy(&psph, psp_header, size_psp_header); - - // file to encrypt - f = fopen(argv[1], "rb"); - if(!f) { - printf("psp-prxsign: Unable to open PRX\n"); - return 1; - } - fseek(f, 0, SEEK_END); - size = ftell(f); - if(size > datasize - 16) { - fclose(f); - printf("psp-prxsign: PRX is too large\n"); - return 1; - } - printf("%s : %i\n", argv[1], size); - fseek(f, 0, SEEK_SET); - - fullsize = datasize + 0x30 + kirk.dataoffset; - - // datablob holds everything needed to calculate data HASH - datablob = malloc(fullsize); - if(!datablob) { - fclose(f); - printf("psp-prxsign: Failed to allocate memory for blob\n"); - return 1; - } - memset(datablob, 0, fullsize); - memcpy(datablob, &kirk.unk1, 0x30); - memcpy(datablob + 0x30, psph, kirk.dataoffset); - filebuff = datablob + 0x30 + kirk.dataoffset; - - int whocares = fread(filebuff, 1, size, f); - (void)whocares; - fclose(f); - - // remove relocations type 7 - relrem = 0; - ehdr = (void *)filebuff; - if(!memcmp(ehdr->e_ident, ELFMAG, 4) && ehdr->e_shnum) { - shdr = (void *)(filebuff + ehdr->e_shoff); - for(i = 0; i < ehdr->e_shnum; i++) { - if(shdr[i].sh_type == 0x700000A0) { - relo = (void *)(filebuff + shdr[i].sh_offset); - for(j = 0; j < shdr[i].sh_size / sizeof(Elf32_Rel); j++) { - if((relo[j].r_info & 0xFF) == 7) { - relo[j].r_info = 0; - relrem++; - } - } - } - } - } - //printf("%i relocations type 7 removed\ncalculating ...\n", relrem); - - // get AES/CMAC key - AES_set_decrypt_key(kirk_key, 128, &aesKey); - memset(iv, 0, 16); - AES_cbc_encrypt(kirk.key, kirk.key, 32, &aesKey, iv, AES_DECRYPT); - - // check header hash, optional - // if you take correct kirk header, hash is always correct -/* AES_CMAC(kirk.ckey, datablob, 0x30, cmac); - if(memcmp(cmac, kirk.head_hash, 16)) { - free(datablob); - printf("header hash invalid\n"); - return 1; - } -*/ - - // encrypt input file - AES_set_encrypt_key(kirk.key, 128, &aesKey); - memset(iv, 0, 16); - AES_cbc_encrypt(filebuff, filebuff, datasize, &aesKey, iv, AES_ENCRYPT); - - // make CMAC correct - generate_subkey(kirk.ckey, subk, subk + 16); - AES_set_encrypt_key(kirk.ckey, 128, &aesKey); - blocks = fullsize / 16; - memset(cmac, 0, 16); - for(i = 0; i < blocks - 1; i++) { - xor_128(cmac, &datablob[16 * i], cmac + 16); - AES_encrypt(cmac + 16, cmac, &aesKey); - } - - AES_set_decrypt_key(kirk.ckey, 128, &aesKey); - AES_decrypt(kirk.data_hash, iv, &aesKey); - xor_128(cmac, iv, iv); - xor_128(iv, subk, &datablob[16 * (blocks-1)]); - // check it, optional - // it works, this is only if you want to change something -/* AES_CMAC(kirk.ckey, datablob, fullsize, cmac); - if(memcmp(cmac, kirk.data_hash, 16)) { - fclose(f); - free(datablob); - printf("data hash calculation error\n"); - return 1; - } -*/ - f = fopen(argv[2], "wb"); - if(!f) { - free(datablob); - printf("psp-prxsign: Failed to write signed PRX\n"); - return 1; - } - //printf("saving ...\n"); - // save ~PSP header - fwrite(psph, 1, 0x150, f); - // save encrypted file - fwrite(filebuff, 1, fullsize - 0x30 - kirk.dataoffset, f); - fclose(f); - free(datablob); - //printf("everything done\n"); - return 0; -} diff --git a/src/sdl12/SRB2PSP/psp-prxsign/psp_header.h b/src/sdl12/SRB2PSP/psp-prxsign/psp_header.h deleted file mode 100644 index 7faef832c..000000000 --- a/src/sdl12/SRB2PSP/psp-prxsign/psp_header.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef __psp_header__ -#define __psp_header__ - -static unsigned int size_psp_header = 336; -static unsigned char psp_header[] __attribute__((aligned(16))) = { - 0x7e, 0x50, 0x53, 0x50, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x22, 0x74, 0x69, 0x66, 0x70, 0x73, - 0x70, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x33, 0x55, 0x00, 0x50, 0x34, 0x55, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x40, 0x67, 0x3d, 0x00, 0x50, 0x55, 0x0a, 0x01, 0x10, 0x00, 0x40, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x6b, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x4c, 0x6b, 0x3d, 0x00, 0xcc, 0xbb, 0x11, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x90, 0x82, 0x4c, 0x48, 0xa3, 0x53, 0xb2, 0x1b, 0x13, 0x95, 0x2f, 0xf1, 0x0b, 0x90, 0x9c, 0x11, - 0x61, 0x40, 0x20, 0x67, 0xf8, 0xdb, 0xfc, 0x95, 0x5c, 0xbe, 0x8c, 0x80, 0xf3, 0x92, 0x03, 0x01, - 0xb0, 0xbe, 0xf5, 0xf8, 0xa1, 0xaf, 0xaf, 0xa8, 0x38, 0x26, 0x63, 0x09, 0x26, 0x0e, 0xb7, 0xd5, - 0x00, 0x33, 0x55, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x5c, 0x3e, 0x03, 0x22, 0xe5, 0x7d, 0xb9, 0xd1, 0x13, 0x67, 0x97, 0xa3, 0x5b, 0xd8, 0x77, 0x1f, - 0xf0, 0x05, 0xf3, 0xad, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x87, 0x4a, 0xd7, 0x37, - 0xc2, 0x8f, 0x15, 0x43, 0x33, 0x93, 0x4d, 0x5b, 0xc0, 0x6e, 0xe4, 0x00, 0xc6, 0x0a, 0x71, 0x11, - 0x98, 0xb6, 0xc3, 0xb7, 0x59, 0x66, 0x21, 0xa8, 0x65, 0xf6, 0x53, 0xa9, 0x7a, 0x48, 0x17, 0xb6, -}; - -#endif diff --git a/src/sdl12/SRB2Pandora/Makefile.cfg b/src/sdl12/SRB2Pandora/Makefile.cfg deleted file mode 100644 index 1f057a212..000000000 --- a/src/sdl12/SRB2Pandora/Makefile.cfg +++ /dev/null @@ -1,39 +0,0 @@ -# Quick Pandora target to make a compliant SRB2 PND file. - -PNDNAME=SRB2.pnd -PNDDIR=$(BIN)/pnd -ICON=sdl12/SRB2Pandora/icon.png -PXML=sdl12/SRB2Pandora/PXML.xml - -SED=sed -CAT=cat -CP=cp -XARGS=xargs -FOR=for -WGET=wget -P $(PNDDIR) -c -nc - -SHXARGS:=$(XARGS) -SHSED:=$(SED) - -ifndef ECHO - CP:=@$(CP) - CAT:=@$(CAT) - SED:=@$(SED) - XARGS:=@$(XARGS) - FOR:=@(FOR) -endif - -$(BIN)/$(PNDNAME): $(BIN)/$(EXENAME) - @echo Linking $(PNDNAME)... - $(MKDIR) $(PNDDIR) - $(CP) $(BIN)/$(EXENAME) $(PNDDIR) - $(CP) $(ICON) $(PNDDIR) - $(CP) $(PXML) $(PNDDIR) -ifdef WITHDATA - $(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) 's/\.srb/\.wad/' | $(SHXARGS) -n 1 basename); do \ - $(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \ - done -endif - $(MKISOFS) -l -r -o $@ $(PNDDIR) - $(CAT) $(PXML) >> $@ - $(REMOVE) -r $(PNDDIR) diff --git a/src/sdl12/SRB2Pandora/PXML.xml b/src/sdl12/SRB2Pandora/PXML.xml deleted file mode 100644 index 33a9587db..000000000 --- a/src/sdl12/SRB2Pandora/PXML.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - Sonic Robo Blast 2 - ソニック・ロボ・ブラスト・2 - A 3D Sonic fangame with a huge fanbase developing custom content, including characters, levels, and even large-scale modifications - - - - - - - - - - - diff --git a/src/sdl12/SRB2Pandora/icon.png b/src/sdl12/SRB2Pandora/icon.png deleted file mode 100644 index 63af73ac3..000000000 Binary files a/src/sdl12/SRB2Pandora/icon.png and /dev/null differ diff --git a/src/sdl12/SRB2WII/Makefile.cfg b/src/sdl12/SRB2WII/Makefile.cfg deleted file mode 100644 index 778d2c3d6..000000000 --- a/src/sdl12/SRB2WII/Makefile.cfg +++ /dev/null @@ -1,124 +0,0 @@ -# -# Makefile.cfg for SRB2Wii native using libogc -# - -# Check if DEVKITPPC is set in the environment. If so, continue with compilation. -.SUFFIXES: - -ifeq ($(strip $(DEVKITPPC)),) -$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") -endif - -# Set compiler flags - -SRB2NAME?=srb2wii -EXENAME?=$(SRB2NAME).elf -DBGNAME?=$(SRB2NAME).elf.debug -DOLNAME?=$(SRB2NAME).dol - -ICONPNG?=sdl12/SRB2WII/icon.png -METAXML?=sdl12/SRB2WII/meta.xml - -APPDIR=apps/$(SRB2NAME) -ZIPNAME=$(SRB2NAME).zip - -ELF2DOL=$(DEVKITPPC)/bin/elf2dol -WIILOADEXE=$(DEVKITPPC)/bin/wiiload -ZIP=zip -r -9 -WGET=wget -P srb2wii -c -nc -SED=sed -XARGS=xargs -SHXARGS:=$(XARGS) -SHSED:=$(SED) -FOR=for - -ifndef ECHO - ELF2DOL:=@$(ELF2DOL) - WIILOADEXE:=@$(WIILOADEXE) - ZIP:=@$(ZIP) - SED:=@$(SED) - XARGS:=@$(XARGS) - FOR:=@$(FOR) -endif - -# Disable same warning flags -WFLAGS+=-Wno-shadow -Wno-char-subscripts -Wno-old-style-definition -Wno-unsuffixed-float-constants - -# newlib has no support for networking -NONET=1 - -# use pkgconfig for PKG -PNG_PKGCONFIG=libpng - -# use absolute paths because changing PATH variable breaks distcc -PREFIX := $(DEVKITPPC)/bin/$(PREFIX) - -# FIXME: DevkitPPC and ready-compiled SDL Wii require these things to be in a silly order -# libogc/DevkitPro required stuff -LIBOGC := $(DEVKITPRO)/libogc -LIBOGC_INC := $(LIBOGC)/include -LIBOGC_LIB := $(LIBOGC)/lib - -PORTLIBS := $(DEVKITPRO)/portlibs/ppc -PORTLIBS_INC := $(PORTLIBS)/include -PORTLIBS_LIB := $(PORTLIBS)/lib - -SDL_CPPFLAGS := -I$(LIBOGC_INC)/SDL -SDL_LIB := $(DEVKITPRO)/libogc/lib/wii -INCLUDE := -I$(LIBOGC_INC) $(SDL_CPPFLAGS) -I$(PORTLIBS_INC) - -PKG_CONFIG_PATH := $(PORTLIBS)/lib/pkgconfig -PKG_BROKEN_SWTICH := --static --define-variable=DEVKITPRO=$(DEVKITPRO) -PNG_PKGCONFIG := $(PKG_CONFIG_PATH)/libpng.pc $(PKG_BROKEN_SWTICH) -ZLIB_PKGCONFIG := $(PKG_CONFIG_PATH)/zlib.pc $(PKG_BROKEN_SWTICH) - -ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) -ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) - -ifdef RDB - LIBS+=-ldb - OPTS+=-DREMOTE_DEBUGGING=$(RDB) -endif - -LIBS+= -L$(SDL_LIB) -ifndef NOMIXER - LD=$(CXX) - LIBS+=-lSDL_mixer -lvorbisidec -lsmpeg -endif -LIBS+=-lSDL - -LIBS+=$(ZLIB_LDFLAGS) -lfat -lwiiuse -lbte -logc -lm -lwiikeyboard -L$(LIBOGC_LIB) - -MACHDEP = -DGEKKO -mrvl -mcpu=750 -meabi -mhard-float -OPTS+=-DWII -D_WII -DUNIXCOMMON -CFLAGS+=-D__BIG_ENDIAN__ -g -O3 -fsigned-char $(MACHDEP) $(INCLUDE) -CXXFLAGS+=$(CFLAGS) -LDFLAGS+=-g $(MACHDEP) -Wl,-Map,$(notdir $@).map - -SDL_CONFIG=/bin/true -SDL_CFLAGS= -SDL_LDFLAGS= - -$(BIN)/$(DOLNAME): $(BIN)/$(EXENAME) - @echo Linking $(DOLNAME)... - $(ELF2DOL) $(BIN)/$(EXENAME) $(BIN)/$(DOLNAME) - @echo Creating /apps/$(SRB2NAME)... - $(MKDIR) $(APPDIR) - $(CP) $(BIN)/$(DOLNAME) $(APPDIR)/boot.dol - $(CP) $(ICONPNG) $(APPDIR) - $(CP) $(METAXML) $(APPDIR) -ifdef WITHDATA - $(MKDIR) srb2wii - $(FOR) datafile in $(shell echo $(D_FILES) | $(SHSED) -e 's/\.srb/\.wad/' -e 's/music.dta//' | $(SHXARGS) -n 1 basename); do \ - $(WGET) http://alam.srb2.org/SRB2/2.0.6-Final/Resources/$$datafile; \ - done - # downsampled music.dta specially for SRB2Wii - $(WGET) http://repos.srb2.org/srb2ports/music.dta - $(ZIP) $(BIN)/$(ZIPNAME) $(APPDIR) srb2wii -else - $(ZIP) $(BIN)/$(ZIPNAME) $(APPDIR) -endif - $(REMOVE) -r $(APPDIR) - -run: $(BIN)/$(EXENAME) - $(WIILOADEXE) $(BIN)/$(DBGNAME) diff --git a/src/sdl12/SRB2WII/icon.png b/src/sdl12/SRB2WII/icon.png deleted file mode 100644 index d22324bc6..000000000 Binary files a/src/sdl12/SRB2WII/icon.png and /dev/null differ diff --git a/src/sdl12/SRB2WII/meta.xml b/src/sdl12/SRB2WII/meta.xml deleted file mode 100644 index 843176d3a..000000000 --- a/src/sdl12/SRB2WII/meta.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - SRB2Wii - Callum - 2.0.6 - 20101207 - A 3D Sonic fangame - Sonic Robo Blast 2 is a 3D fangame by a small group called -Sonic Team Junior, using the Doom engine as a base. -The game has been worked on for almost 11 years so far, and -it is still being very much developed today, with a huge -fanbase developing custom content, including characters, -levels, and even large-scale modifications that play out -a brand new adventure. -Based on the Doom II engine, SRB2's system requirements -are very low, even the oldest computers can play it at a -decent speed. - diff --git a/src/sdl12/SRB2XBOX/Makefile.cfg b/src/sdl12/SRB2XBOX/Makefile.cfg deleted file mode 100644 index 56966d438..000000000 --- a/src/sdl12/SRB2XBOX/Makefile.cfg +++ /dev/null @@ -1,44 +0,0 @@ -# -# Makefile.cfg for SRB2/XBOX -# - -# -#hmmm, the XBOX -# - - NOHW=1 #No working OpenGL right now - NOHS=1 #No HWSound right now - NOASM=1 #No Fast code - NONET=1 #No network code - NOMD5=1 #No Slow MD5 - NOPNG=1 #No Screenshot - #SDLMAIN=1 #SDLMain! - -ifndef OPENXDK - OPENXDK=/usr/local/openxdk -endif - - CXBE=$(OPENXDK)/bin/cxbe - -ifdef ECHO - CXBE:=@$(CXBE) -endif - -ifndef NOHW - OPTS+=-DMINI_GL_COMPATIBILITY -endif - - BUILTLM=-fno-builtin - CFLAGS+=-D_XBOX -std=gnu99 -ffreestanding $(BUILTLM) -fno-exceptions - CFLAGS+=-I$(OPENXDK)/i386-pc-xbox/include -I$(OPENXDK)/include - OPTS+=-nostdlib -mno-cygwin -march=i386 - LDFLAGS+=-nostdlib -Wl,--file-alignment,0x20 -Wl,--section-alignment,0x20 -shared -Wl,--entry,_WinMainCRTStartup -Wl,--strip-all -L$(OPENXDK)/i386-pc-xbox/lib -L$(OPENXDK)/lib - LIBS=-lg -lc -lm - SDL_CFLAGS?=-I$(OPENXDK)/include/SDL - SDL_LDFLAGS?=-lSDL -lopenxdk -lhal -lc -lhal -lusb -lhal -lc -lxboxkrnl - - i_system_o+=$(OBJDIR)/xboxhelp.o - - # name of the exefile - EXENAME?=SRB2XBOX.EXE - BINNAME?=default.xbe diff --git a/src/sdl12/SRB2XBOX/xboxhelp.c b/src/sdl12/SRB2XBOX/xboxhelp.c deleted file mode 100644 index 05b6c5e68..000000000 --- a/src/sdl12/SRB2XBOX/xboxhelp.c +++ /dev/null @@ -1,91 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2004-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// stub and replacement "ANSI" C functions for use under OpenXDK -// -//----------------------------------------------------------------------------- - -#include "../../doomdef.h" -#include "xboxhelp.h" -#ifdef __GNUC__ -#include -#else -#include -#endif - -char *getcwd(char *_buf, size_t _size ) -{ - (void)_buf; - (void)_size; - return _buf; -} - -#ifdef _MSC_VER -int mkdir(const char *path) -{ - (void)path; - return 0; -} -#elif 0 //__GNUC__? -int mkdir(const char *path, mode_t _mode) -{ - (void)path; - (void)_mode; - return 0; -} -#endif - -int chdir (const char *__path ) -{ - (void)__path; - return 0; -} - -time_t time(time_t *T) -{ - long returntime = 0; - (void)T; -/* - SYSTEMTIME st; - FILETIME stft; - INT64 ftli; - if (!T) return returntime; - GetSystemTime(&st); - SystemTimeToFileTime(&st,&stft); - CopyMemory(&ftli,&stft,sizeof (LARGE_INTEGER)); - returntime = (long)ftli; - *T = returntime; -*/ - return returntime; -} - -#ifdef _MSC_VER -#include -void __cdecl _RTC_Initialize(void) -{ -} -char *getenv(const char *__env) -{ - __env = NULL; - return NULL; -} - -int putenv(const char *__env) -{ - __env = NULL; - return 0; -} -#endif diff --git a/src/sdl12/SRB2XBOX/xboxhelp.h b/src/sdl12/SRB2XBOX/xboxhelp.h deleted file mode 100644 index 97ef0a3be..000000000 --- a/src/sdl12/SRB2XBOX/xboxhelp.h +++ /dev/null @@ -1,6 +0,0 @@ -#if defined (_MSC_VER) -int access(const char *path, int amode); -char *getcwd(char *_buf, size_t _size ); -int mkdir(const char *path); -int chdir (const char *__path ); -#endif diff --git a/src/sdl12/Srb2SDL-vc10.vcxproj b/src/sdl12/Srb2SDL-vc10.vcxproj deleted file mode 100644 index 99916f58d..000000000 --- a/src/sdl12/Srb2SDL-vc10.vcxproj +++ /dev/null @@ -1,1475 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - Srb2SDL - {61BA7D3C-F77D-4D31-B718-1177FE482CF2} - Srb2SDL - - - - Application - false - - - Application - false - - - Application - false - - - Application - false - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - .\..\..\bin\VC10\$(Platform)\$(Configuration)\ - .\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\ - true - .\..\..\bin\VC10\$(Platform)\$(Configuration)\ - .\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\ - true - .\..\..\bin\VC10\$(Platform)\$(Configuration)\ - .\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\ - false - .\..\..\bin\VC10\$(Platform)\$(Configuration)\ - .\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\ - false - $(SDL12_PREFIX)\include;$(SDL12_MIXER_PREFIX)\include;$(FMOD3_PREFIX)api\inc;$(IncludePath) - $(SDL12_PREFIX)\include;$(SDL12_MIXER_PREFIX)\include;$(FMOD3_PREFIX)api\inc;$(IncludePath) - $(SDL12_PREFIX)\include;$(SDL12_MIXER_PREFIX)\include;$(FMOD3_PREFIX)api\inc;$(IncludePath) - $(SDL12_PREFIX)\include;$(SDL12_MIXER_PREFIX)\include;$(FMOD3_PREFIX)api\inc;$(IncludePath) - $(SDL12_PREFIX)\lib;$(SDL12_MIXER_PREFIX)\lib;$(LibraryPath) - $(SDL12_PREFIX)\lib;$(SDL12_MIXER_PREFIX)\lib;$(LibraryPath) - $(SDL12_PREFIX)\lib\x64;$(SDL12_MIXER_PREFIX)\lib\x64;$(LibraryPath) - $(SDL12_PREFIX)\lib\x64;$(SDL12_MIXER_PREFIX)\lib\x64;$(LibraryPath) - - - - Getting revision number from the SCM system - "$(ProjectDir)..\..\comptime.bat" "$(ProjectDir).." - - - .\..\..\bin\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.tlb - - - - - Disabled - $(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories) - _DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - $(IntDir) - $(IntDir)Srb2SDL.pdb - true - Level4 - true - true - EditAndContinue - CompileAsC - 4121;%(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - SDL.lib;SDL_mixer.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)srb2sdl.exe - true - true - $(OutDir)srb2sdl.pdb - Console - false - - - MachineX86 - - - true - $(OutDir)Srb2sdl.bsc - - - - - Getting revision number from the SCM system - "$(ProjectDir)..\..\comptime.bat" "$(ProjectDir).." - - - X64 - .\..\..\bin\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.tlb - - - - - Disabled - $(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories) - _DEBUG;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - $(IntDir) - $(IntDir)Srb2SDL.pdb - true - Level4 - true - true - ProgramDatabase - CompileAsC - 4121;%(DisableSpecificWarnings) - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - SDL.lib;SDL_mixer.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)srb2sdl.exe - true - true - $(OutDir)srb2sdl.pdb - Console - false - - - MachineX64 - - - true - $(OutDir)Srb2sdl.bsc - - - - - Getting revision number from the SCM system - "$(ProjectDir)..\..\comptime.bat" "$(ProjectDir).." - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\..\..\bin\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.tlb - - - - - /MP %(AdditionalOptions) - Disabled - OnlyExplicitInline - true - Speed - true - $(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories) - NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - true - MultiThreaded - .\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch - $(IntDir) - $(IntDir)Srb2SDL.pdb - true - Level3 - true - ProgramDatabase - CompileAsC - 4121;%(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - SDL.lib;SDL_mixer.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)srb2sdl.exe - true - true - $(OutDir)srb2sdl.pdb - Windows - false - - - MachineX86 - - - true - $(OutDir)Srb2sdl.bsc - - - - - Getting revision number from the SCM system - "$(ProjectDir)..\..\comptime.bat" "$(ProjectDir).." - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\..\..\bin\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.tlb - - - - - /MP %(AdditionalOptions) - Disabled - OnlyExplicitInline - true - Speed - true - $(ProjectDir)..\..\libs\libpng-src;$(ProjectDir)..\..\libs\zlib;%(AdditionalIncludeDirectories) - NDEBUG;SDLMAIN;NO_STDIO_REDIRECT;USE_WGL_SWAP;DIRECTFULLSCREEN;HAVE_SDL;HWRENDER;HW3SOUND;HAVE_FILTER;HAVE_MIXER;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - true - MultiThreaded - .\..\..\objs\VC10\$(Platform)\$(Configuration)\SDL\Srb2SDL-vc9.pch - $(IntDir) - $(IntDir)Srb2SDL.pdb - true - Level3 - true - ProgramDatabase - CompileAsC - 4121;%(DisableSpecificWarnings) - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - SDL.lib;SDL_mixer.lib;ws2_32.lib;%(AdditionalDependencies) - $(OutDir)srb2sdl.exe - true - true - $(OutDir)srb2sdl.pdb - Windows - false - - - MachineX64 - - - true - $(OutDir)Srb2sdl.bsc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - true - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - %(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - true - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - true - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - - - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - true - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - true - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - - - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - true - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - true - Compiling %(Filename).nas with NASM... - nasm -g -o $(IntDir)%(Filename).obj -f win32 "%(FullPath)" - $(IntDir)%(Filename).obj;%(Outputs) - - - - - - - - - - %(PreprocessorDefinitions) - \Users\alam\svn\srb2mods\SRB2\branches\ALAM\src\win32;%(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - \Users\alam\svn\srb2mods\SRB2\branches\ALAM\src\win32;%(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - \Users\alam\svn\srb2mods\SRB2\branches\ALAM\src\win32;%(AdditionalIncludeDirectories) - %(PreprocessorDefinitions) - \Users\alam\svn\srb2mods\SRB2\branches\ALAM\src\win32;%(AdditionalIncludeDirectories) - - - - - {72b01aca-7a1a-4f7b-acef-2607299cf052} - false - - - {73a5729c-7323-41d4-ab48-8a03c9f81603} - false - - - - - - diff --git a/src/sdl12/Srb2SDL-vc9.vcproj b/src/sdl12/Srb2SDL-vc9.vcproj deleted file mode 100644 index fa386e381..000000000 --- a/src/sdl12/Srb2SDL-vc9.vcproj +++ /dev/null @@ -1,5889 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/sdl12/Srb2SDL.dsp b/src/sdl12/Srb2SDL.dsp deleted file mode 100644 index 879113ca2..000000000 --- a/src/sdl12/Srb2SDL.dsp +++ /dev/null @@ -1,1057 +0,0 @@ -# Microsoft Developer Studio Project File - Name="Srb2SDL" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=Srb2SDL - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "Srb2SDL.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "Srb2SDL.mak" CFG="Srb2SDL - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "Srb2SDL - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "Srb2SDL - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "..\..\bin\VC\Release\SDL" -# PROP Intermediate_Dir "..\..\objs\VC\Release\SDL" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G5 /W3 /GX /Zi /Ot /Og /Oi /Op /Oy /Ob1 /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "NDEBUG" /D "SDLMAIN" /D "NO_STDIO_REDIRECT" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GF /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -# SUBTRACT RSC /x -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o"..\..\objs\SDL\Release\SRB2.bsc" -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 -# ADD LINK32 SDL.lib SDL_mixer.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:windows /pdb:"C:\srb2demo2\srb2sdl.pdb" /debug /machine:I386 /out:"C:\srb2demo2\srb2sdl.exe" -# SUBTRACT LINK32 /profile /pdb:none /incremental:yes - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "..\..\bin\VC\Debug\SDL" -# PROP Intermediate_Dir "..\..\objs\VC\Debug\SDL" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -MTL=midl.exe -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /W4 /WX /Gm /GX /ZI /Od /Op /I "..\..\libs\libpng-src" /I "..\..\libs\zlib" /D "_DEBUG" /D "USE_WGL_SWAP" /D "DIRECTFULLSCREEN" /D "HAVE_SDL" /D "HWRENDER" /D "HW3SOUND" /D "HAVE_FILTER" /D "HAVE_MIXER" /D "USEASM" /D "HAVE_PNG" /FR /FD /GZ /c -# SUBTRACT CPP /YX -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -# SUBTRACT RSC /x -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o"..\..\objs\SDL\Debug\SRB2.bsc" -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 SDL.lib SDL_mixer.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /pdb:"C:\srb2demo2\srb2sdldebug.pdb" /debug /machine:I386 /out:"C:\srb2demo2\srb2sdldebug.exe" /pdbtype:sept -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "Srb2SDL - Win32 Release" -# Name "Srb2SDL - Win32 Debug" -# Begin Group "SDLapp" - -# PROP Default_Filter "" -# Begin Group "filter" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\filter\filters.c -# End Source File -# Begin Source File - -SOURCE=.\filter\filters.h -# End Source File -# Begin Source File - -SOURCE=.\filter\hq2x.c -# End Source File -# Begin Source File - -SOURCE=.\filter\hq2x.h -# End Source File -# Begin Source File - -SOURCE=.\filter\interp.h -# End Source File -# Begin Source File - -SOURCE=.\filter\lq2x.c -# End Source File -# Begin Source File - -SOURCE=.\filter\lq2x.h -# End Source File -# End Group -# Begin Source File - -SOURCE=.\dosstr.c -# End Source File -# Begin Source File - -SOURCE=.\endtxt.c -# End Source File -# Begin Source File - -SOURCE=.\endtxt.h -# End Source File -# Begin Source File - -SOURCE=..\filesrch.c -# End Source File -# Begin Source File - -SOURCE=..\filesrch.h -# End Source File -# Begin Source File - -SOURCE=.\hwsym_sdl.c -# End Source File -# Begin Source File - -SOURCE=.\hwsym_sdl.h -# End Source File -# Begin Source File - -SOURCE=.\i_cdmus.c -# End Source File -# Begin Source File - -SOURCE=.\i_main.c -# End Source File -# Begin Source File - -SOURCE=.\i_net.c -# End Source File -# Begin Source File - -SOURCE=.\i_sound.c -# End Source File -# Begin Source File - -SOURCE=.\i_system.c -# End Source File -# Begin Source File - -SOURCE=.\i_video.c -# End Source File -# Begin Source File - -SOURCE=.\IMG_xpm.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=.\ogl_sdl.c -# End Source File -# Begin Source File - -SOURCE=.\ogl_sdl.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\r_opengl\r_opengl.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\r_opengl\r_opengl.h -# End Source File -# Begin Source File - -SOURCE=.\SDL_icon.xpm -# End Source File -# Begin Source File - -SOURCE=.\SDL_main\SDL_win32_main.c - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP Exclude_From_Build 1 - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\sdlmain.h -# End Source File -# Begin Source File - -SOURCE=..\win32\Srb2win.rc -# End Source File -# Begin Source File - -SOURCE=..\win32\win_dbg.c -# End Source File -# Begin Source File - -SOURCE=..\win32\win_dbg.h -# End Source File -# Begin Source File - -SOURCE=..\win32\win_main.h -# End Source File -# End Group -# Begin Group "A_Asm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\p5prof.h -# End Source File -# Begin Source File - -SOURCE=..\tmap.nas - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Release\SDL -InputPath=..\tmap.nas -InputName=tmap - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Debug\SDL -InputPath=..\tmap.nas -InputName=tmap - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\tmap_mmx.nas - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Release\SDL -InputPath=..\tmap_mmx.nas -InputName=tmap_mmx - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build - Compiling $(InputName).nas with NASM... - -IntDir=.\..\..\objs\VC\Debug\SDL -InputPath=..\tmap_mmx.nas -InputName=tmap_mmx - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=..\tmap_vc.nas - -!IF "$(CFG)" == "Srb2SDL - Win32 Release" - -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Release\SDL -InputPath=..\tmap_vc.nas -InputName=tmap_vc - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ELSEIF "$(CFG)" == "Srb2SDL - Win32 Debug" - -# Begin Custom Build - Compiling $(InputName).nas with NASM... -IntDir=.\..\..\objs\VC\Debug\SDL -InputPath=..\tmap_vc.nas -InputName=tmap_vc - -"$(IntDir)/$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - nasm -g -o $(IntDir)/$(InputName).obj -f win32 $(InputPath) - -# End Custom Build - -!ENDIF - -# End Source File -# End Group -# Begin Group "D_Doom" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\comptime.c -# End Source File -# Begin Source File - -SOURCE=..\d_clisrv.c -# End Source File -# Begin Source File - -SOURCE=..\d_clisrv.h -# End Source File -# Begin Source File - -SOURCE=..\d_event.h -# End Source File -# Begin Source File - -SOURCE=..\d_main.c -# End Source File -# Begin Source File - -SOURCE=..\d_main.h -# End Source File -# Begin Source File - -SOURCE=..\d_net.c -# End Source File -# Begin Source File - -SOURCE=..\d_net.h -# End Source File -# Begin Source File - -SOURCE=..\d_netcmd.c -# End Source File -# Begin Source File - -SOURCE=..\d_netcmd.h -# End Source File -# Begin Source File - -SOURCE=..\d_netfil.c -# End Source File -# Begin Source File - -SOURCE=..\d_netfil.h -# End Source File -# Begin Source File - -SOURCE=..\d_player.h -# End Source File -# Begin Source File - -SOURCE=..\d_think.h -# End Source File -# Begin Source File - -SOURCE=..\d_ticcmd.h -# End Source File -# Begin Source File - -SOURCE=..\dehacked.c -# End Source File -# Begin Source File - -SOURCE=..\dehacked.h -# End Source File -# Begin Source File - -SOURCE=..\doomdata.h -# End Source File -# Begin Source File - -SOURCE=..\doomdef.h -# End Source File -# Begin Source File - -SOURCE=..\doomstat.h -# End Source File -# Begin Source File - -SOURCE=..\doomtype.h -# End Source File -# Begin Source File - -SOURCE=..\z_zone.c -# End Source File -# Begin Source File - -SOURCE=..\z_zone.h -# End Source File -# End Group -# Begin Group "F_Frame" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\f_finale.c -# End Source File -# Begin Source File - -SOURCE=..\f_finale.h -# End Source File -# Begin Source File - -SOURCE=..\f_wipe.c -# End Source File -# End Group -# Begin Group "G_Game" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\g_game.c -# End Source File -# Begin Source File - -SOURCE=..\g_game.h -# End Source File -# Begin Source File - -SOURCE=..\g_input.c -# End Source File -# Begin Source File - -SOURCE=..\g_input.h -# End Source File -# Begin Source File - -SOURCE=..\g_state.h -# End Source File -# End Group -# Begin Group "H_Hud" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\am_map.c -# End Source File -# Begin Source File - -SOURCE=..\am_map.h -# End Source File -# Begin Source File - -SOURCE=..\command.c -# End Source File -# Begin Source File - -SOURCE=..\command.h -# End Source File -# Begin Source File - -SOURCE=..\console.c -# End Source File -# Begin Source File - -SOURCE=..\console.h -# End Source File -# Begin Source File - -SOURCE=..\hu_stuff.c -# End Source File -# Begin Source File - -SOURCE=..\hu_stuff.h -# End Source File -# Begin Source File - -SOURCE=..\st_stuff.c -# End Source File -# Begin Source File - -SOURCE=..\st_stuff.h -# End Source File -# Begin Source File - -SOURCE=..\y_inter.c -# End Source File -# Begin Source File - -SOURCE=..\y_inter.h -# End Source File -# End Group -# Begin Group "Hw_Hardware" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\hardware\hw3dsdrv.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw3sound.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw3sound.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_bsp.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_cache.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_data.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_defs.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_dll.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_draw.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_drv.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_glide.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_glob.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_light.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_light.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_main.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_main.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_md2.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_md2.h -# End Source File -# Begin Source File - -SOURCE=..\hardware\hw_trick.c -# End Source File -# Begin Source File - -SOURCE=..\hardware\hws_data.h -# End Source File -# End Group -# Begin Group "I_Interface" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\byteptr.h -# End Source File -# Begin Source File - -SOURCE=..\i_joy.h -# End Source File -# Begin Source File - -SOURCE=..\i_net.h -# End Source File -# Begin Source File - -SOURCE=..\i_sound.h -# End Source File -# Begin Source File - -SOURCE=..\i_system.h -# End Source File -# Begin Source File - -SOURCE=..\i_tcp.c -# End Source File -# Begin Source File - -SOURCE=..\i_tcp.h -# End Source File -# Begin Source File - -SOURCE=..\i_video.h -# End Source File -# Begin Source File - -SOURCE=..\keys.h -# End Source File -# Begin Source File - -SOURCE=..\mserv.c -# End Source File -# Begin Source File - -SOURCE=..\mserv.h -# End Source File -# End Group -# Begin Group "M_Misc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\m_argv.c -# End Source File -# Begin Source File - -SOURCE=..\m_argv.h -# End Source File -# Begin Source File - -SOURCE=..\m_bbox.c -# End Source File -# Begin Source File - -SOURCE=..\m_bbox.h -# End Source File -# Begin Source File - -SOURCE=..\m_cheat.c -# End Source File -# Begin Source File - -SOURCE=..\m_cheat.h -# End Source File -# Begin Source File - -SOURCE=..\m_dllist.h -# End Source File -# Begin Source File - -SOURCE=..\m_fixed.c -# End Source File -# Begin Source File - -SOURCE=..\m_fixed.h -# End Source File -# Begin Source File - -SOURCE=..\m_menu.c -# End Source File -# Begin Source File - -SOURCE=..\m_menu.h -# End Source File -# Begin Source File - -SOURCE=..\m_misc.c -# End Source File -# Begin Source File - -SOURCE=..\m_misc.h -# End Source File -# Begin Source File - -SOURCE=..\m_queue.c -# End Source File -# Begin Source File - -SOURCE=..\m_queue.h -# End Source File -# Begin Source File - -SOURCE=..\m_random.c -# End Source File -# Begin Source File - -SOURCE=..\m_random.h -# End Source File -# Begin Source File - -SOURCE=..\m_swap.h -# End Source File -# Begin Source File - -SOURCE=..\string.c -# End Source File -# End Group -# Begin Group "P_Play" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\info.c -# End Source File -# Begin Source File - -SOURCE=..\info.h -# End Source File -# Begin Source File - -SOURCE=..\p_ceilng.c -# End Source File -# Begin Source File - -SOURCE=..\p_enemy.c -# End Source File -# Begin Source File - -SOURCE=..\p_fab.c -# End Source File -# Begin Source File - -SOURCE=..\p_floor.c -# End Source File -# Begin Source File - -SOURCE=..\p_inter.c -# End Source File -# Begin Source File - -SOURCE=..\p_lights.c -# End Source File -# Begin Source File - -SOURCE=..\p_local.h -# End Source File -# Begin Source File - -SOURCE=..\p_map.c -# End Source File -# Begin Source File - -SOURCE=..\p_maputl.c -# End Source File -# Begin Source File - -SOURCE=..\p_maputl.h -# End Source File -# Begin Source File - -SOURCE=..\p_mobj.c -# End Source File -# Begin Source File - -SOURCE=..\p_mobj.h -# End Source File -# Begin Source File - -SOURCE=..\p_polyobj.c -# End Source File -# Begin Source File - -SOURCE=..\p_polyobj.h -# End Source File -# Begin Source File - -SOURCE=..\p_pspr.h -# End Source File -# Begin Source File - -SOURCE=..\p_saveg.c -# End Source File -# Begin Source File - -SOURCE=..\p_saveg.h -# End Source File -# Begin Source File - -SOURCE=..\p_setup.c -# End Source File -# Begin Source File - -SOURCE=..\p_setup.h -# End Source File -# Begin Source File - -SOURCE=..\p_sight.c -# End Source File -# Begin Source File - -SOURCE=..\p_spec.c -# End Source File -# Begin Source File - -SOURCE=..\p_spec.h -# End Source File -# Begin Source File - -SOURCE=..\p_telept.c -# End Source File -# Begin Source File - -SOURCE=..\p_tick.c -# End Source File -# Begin Source File - -SOURCE=..\p_tick.h -# End Source File -# Begin Source File - -SOURCE=..\p_user.c -# End Source File -# Begin Source File - -SOURCE=..\tables.c -# End Source File -# Begin Source File - -SOURCE=..\tables.h -# End Source File -# End Group -# Begin Group "R_Rend" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\r_bsp.c -# End Source File -# Begin Source File - -SOURCE=..\r_bsp.h -# End Source File -# Begin Source File - -SOURCE=..\r_data.c -# End Source File -# Begin Source File - -SOURCE=..\r_data.h -# End Source File -# Begin Source File - -SOURCE=..\r_defs.h -# End Source File -# Begin Source File - -SOURCE=..\r_draw.c -# End Source File -# Begin Source File - -SOURCE=..\r_draw.h -# End Source File -# Begin Source File - -SOURCE=..\r_draw16.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=..\r_draw8.c -# PROP Exclude_From_Build 1 -# End Source File -# Begin Source File - -SOURCE=..\r_local.h -# End Source File -# Begin Source File - -SOURCE=..\r_main.c -# End Source File -# Begin Source File - -SOURCE=..\r_main.h -# End Source File -# Begin Source File - -SOURCE=..\r_plane.c -# End Source File -# Begin Source File - -SOURCE=..\r_plane.h -# End Source File -# Begin Source File - -SOURCE=..\r_segs.c -# End Source File -# Begin Source File - -SOURCE=..\r_segs.h -# End Source File -# Begin Source File - -SOURCE=..\r_sky.c -# End Source File -# Begin Source File - -SOURCE=..\r_sky.h -# End Source File -# Begin Source File - -SOURCE=..\r_splats.c -# End Source File -# Begin Source File - -SOURCE=..\r_splats.h -# End Source File -# Begin Source File - -SOURCE=..\r_state.h -# End Source File -# Begin Source File - -SOURCE=..\r_things.c -# End Source File -# Begin Source File - -SOURCE=..\r_things.h -# End Source File -# Begin Source File - -SOURCE=..\screen.c -# End Source File -# Begin Source File - -SOURCE=..\screen.h -# End Source File -# Begin Source File - -SOURCE=..\v_video.c -# End Source File -# Begin Source File - -SOURCE=..\v_video.h -# End Source File -# End Group -# Begin Group "S_Sounds" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\s_sound.c -# End Source File -# Begin Source File - -SOURCE=..\s_sound.h -# End Source File -# Begin Source File - -SOURCE=..\sounds.c -# End Source File -# Begin Source File - -SOURCE=..\sounds.h -# End Source File -# End Group -# Begin Group "W_Wad" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\lzf.c -# End Source File -# Begin Source File - -SOURCE=..\lzf.h -# End Source File -# Begin Source File - -SOURCE=..\md5.c -# End Source File -# Begin Source File - -SOURCE=..\md5.h -# End Source File -# Begin Source File - -SOURCE=..\w_wad.c -# End Source File -# Begin Source File - -SOURCE=..\w_wad.h -# End Source File -# End Group -# Begin Group "Docs" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\doc\copying -# End Source File -# Begin Source File - -SOURCE=..\..\doc\faq.txt -# End Source File -# Begin Source File - -SOURCE=..\..\readme.txt -# End Source File -# Begin Source File - -SOURCE=..\..\doc\source.txt -# End Source File -# End Group -# Begin Source File - -SOURCE=..\win32\Srb2win.ico -# End Source File -# End Target -# End Project diff --git a/src/sdl12/Srb2SDL.dsw b/src/sdl12/Srb2SDL.dsw deleted file mode 100644 index 4f8f7bdce..000000000 --- a/src/sdl12/Srb2SDL.dsw +++ /dev/null @@ -1,74 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "Srb2SDL"=.\Srb2SDL.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libpng - End Project Dependency - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "libpng"="..\..\libs\libpng-src\projects\visualc6\libpng.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "s_openal"=..\hardware\s_openal\s_openal.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "zlib"=..\..\libs\zlib\projects\visualc6\zlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/src/sdl12/Srb2SDL.ico b/src/sdl12/Srb2SDL.ico deleted file mode 100644 index 700276fd4..000000000 Binary files a/src/sdl12/Srb2SDL.ico and /dev/null differ diff --git a/src/sdl12/dosstr.c b/src/sdl12/dosstr.c deleted file mode 100644 index f9bbee9b4..000000000 --- a/src/sdl12/dosstr.c +++ /dev/null @@ -1,38 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// This file is in the public domain. -// (Re)written by Graue in 2006. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief String uppercasing/lowercasing functions for non-DOS non-Win32 -/// systems - -#include "../doomtype.h" - -#ifndef HAVE_DOSSTR_FUNCS - -#include - -int strupr(char *n) -{ - while (*n != '\0') - { - *n = toupper(*n); - n++; - } - return 1; -} - -int strlwr(char *n) -{ - while (*n != '\0') - { - *n = tolower(*n); - n++; - } - return 1; -} - -#endif diff --git a/src/sdl12/endtxt.c b/src/sdl12/endtxt.c deleted file mode 100644 index 1d7756b4d..000000000 --- a/src/sdl12/endtxt.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Function to write the SRB2 end message text - * - * Copyright (C) 1998 by Udo Munk - * - * This code is provided AS IS and there are no guarantees, none. - * Feel free to share and modify. - */ -//----------------------------------------------------------------------------- -/// \file -/// \brief Support to show ENDOOM text -/// -/// Loads the lump ENDOOM, set up the console to print -/// out the colors and text - -#include -#include - -// need this 19990118 by Kin -#include "../doomdef.h" -#include "../w_wad.h" -#include "../z_zone.h" -#include "endtxt.h" -/** \brief The ShowEndTxt function - - - Prints out the ENDOOM the way DOOM.EXE/DOOM2.EXE did for Win32 or Linux/GNU - - \return void - - -*/ - -void ShowEndTxt(void) -{ -#if !(defined (_WIN32_WCE) || defined (_XBOX) || defined (_arch_dreamcast)) - INT32 i; - UINT16 j, att = 0; - INT32 nlflag = 1; -#ifdef _WIN32 - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD mode, bytesWritten; - CONSOLE_SCREEN_BUFFER_INFO backupcon; - COORD resizewin = {80,-1}; - CHAR let = 0; -#endif - UINT16 *ptext; - void *data; - lumpnum_t endoomnum = W_GetNumForName("ENDOOM"); - //char *col; - - /* if the xterm has more then 80 columns we need to add nl's */ - /* doesn't work, COLUMNS is not in the environment at this time ??? - col = I_getenv("COLUMNS"); - if (col) { - if (atoi(col) > 80) - nlflag++; - } - */ - - /* get the lump with the text */ - data = ptext = W_CacheLumpNum(endoomnum, PU_CACHE); - -#ifdef _WIN32 - if (co == INVALID_HANDLE_VALUE || GetFileType(co) != FILE_TYPE_CHAR || !GetConsoleMode(co, &mode)) // test if it a good handle - { - Z_Free(data); - return; - } - - backupcon.wAttributes = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE; // Just in case - GetConsoleScreenBufferInfo(co, &backupcon); //Store old state - resizewin.Y = backupcon.dwSize.Y; - if (backupcon.dwSize.X < resizewin.X) - SetConsoleScreenBufferSize(co, resizewin); - - for (i=1; i<=80*25; i++) // print 80x25 text and deal with the attributes too - { - j = (UINT16)(*ptext >> 8); // attribute first - let = (char)(*ptext & 0xff); // text second - if (j != att) // attribute changed? - { - att = j; // save current attribute - SetConsoleTextAttribute(co, j); //set fg and bg color for buffer - } - - WriteConsoleA(co, &let, 1, &bytesWritten, NULL); // now the text - - if (nlflag && !(i % 80) && backupcon.dwSize.X > resizewin.X) // do we need a nl? - { - att = backupcon.wAttributes; - SetConsoleTextAttribute(co, att); // all attributes off - WriteConsoleA(co, "\n", 1, &bytesWritten, NULL); // newline to console - } - ptext++; - } - SetConsoleTextAttribute(co, backupcon.wAttributes); // all attributes off -#else - /* print 80x25 text and deal with the attributes too */ - for (i=1; i<=80*25; i++) { - /* attribute first */ - /* attribute changed? */ - if ((j = *ptext >> 8) != att) { - /* save current attribute */ - att = j; - /* set new attribute, forground color first */ - printf("\033["); - switch (j & 0x0f) { - case 0: /* black */ - printf("30"); - break; - case 1: /* blue */ - printf("34"); - break; - case 2: /* green */ - printf("32"); - break; - case 3: /* cyan */ - printf("36"); - break; - case 4: /* red */ - printf("31"); - break; - case 5: /* magenta */ - printf("35"); - break; - case 6: /* brown */ - printf("33"); - break; - case 7: /* bright grey */ - printf("37"); - break; - case 8: /* dark grey */ - printf("1;30"); - break; - case 9: /* bright blue */ - printf("1;34"); - break; - case 10: /* bright green */ - printf("1;32"); - break; - case 11: /* bright cyan */ - printf("1;36"); - break; - case 12: /* bright red */ - printf("1;31"); - break; - case 13: /* bright magenta */ - printf("1;35"); - break; - case 14: /* yellow */ - printf("1;33"); - break; - case 15: /* white */ - printf("1;37"); - break; - } - printf("m"); - /* now background color */ - printf("\033["); - switch ((j >> 4) & 0x0f) { - case 0: /* black */ - printf("40"); - break; - case 1: /* blue */ - printf("44"); - break; - case 2: /* green */ - printf("42"); - break; - case 3: /* cyan */ - printf("46"); - break; - case 4: /* red */ - printf("41"); - break; - case 5: /* magenta */ - printf("45"); - break; - case 6: /* brown */ - printf("43"); - break; - case 7: /* bright grey */ - printf("47"); - break; - case 8: /* dark grey */ - printf("1;40"); - break; - case 9: /* bright blue */ - printf("1;44"); - break; - case 10: /* bright green */ - printf("1;42"); - break; - case 11: /* bright cyan */ - printf("1;46"); - break; - case 12: /* bright red */ - printf("1;41"); - break; - case 13: /* bright magenta */ - printf("1;45"); - break; - case 14: /* yellow */ - printf("1;43"); - break; - case 15: /* white */ - printf("1;47"); - break; - } - printf("m"); - } - - /* now the text */ - printf("%c",*ptext++ & 0xff); - - /* do we need a nl? */ - if (nlflag) - { - if (!(i % 80)) - { - printf("\033[0m"); - att = 0; - printf("\n"); - } - } - } - /* all attributes off */ - printf("\033[0m"); -#endif - if (nlflag) - printf("\n"); - - Z_Free(data); -#endif -} diff --git a/src/sdl12/endtxt.h b/src/sdl12/endtxt.h deleted file mode 100644 index 41f8e51ad..000000000 --- a/src/sdl12/endtxt.h +++ /dev/null @@ -1,24 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Support to show ENDOOM text - -#ifndef __ENDTXT__ -#define __ENDTXT__ - -void ShowEndTxt (void); - -#endif diff --git a/src/sdl12/filter/filters.c b/src/sdl12/filter/filters.c deleted file mode 100644 index 1b2346e8e..000000000 --- a/src/sdl12/filter/filters.c +++ /dev/null @@ -1,1000 +0,0 @@ -#include -#include "filters.h" - -//Alam_GBC: C file based on sms_sdl's filter.c - -/* 2X SAI Filter */ -static Uint32 colorMask = 0xF7DEF7DE; -static Uint32 lowPixelMask = 0x08210821; -static Uint32 qcolorMask = 0xE79CE79C; -static Uint32 qlowpixelMask = 0x18631863; -static Uint32 redblueMask = 0xF81F; -static Uint32 greenMask = 0x7E0; - -SDL_Surface *filter_2x(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter) -{ - return filter_2xe(src,srcclp,filter,0,0,0); -} - -SDL_Surface *filter_2xe(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter,Uint8 R, Uint8 G, Uint8 B) -{ - SDL_Surface *srcfilter = NULL; - SDL_Rect dstclp = {0,3,0,0}; - SDL_Surface *dstfilter = NULL; - Uint32 Fillcolor = 0; - if(!src || !filter) return NULL; // Need src and filter - if(srcclp) // size by clp - { - dstclp.w = srcclp->w; //clp's width - dstclp.h = srcclp->h; //clp's height - } - else // size by src - { - dstclp.w = (Uint16)src->w; //src's width - dstclp.h = (Uint16)src->h; //src's height - } - if(filter == hq2x32 || filter == lq2x32) // src 0888 surface - srcfilter = SDL_CreateRGBSurface(SDL_SWSURFACE,dstclp.w,dstclp.h+6,32,0x00FF0000,0x0000FF00,0x000000FF,0x00); - else // src 565 surface - srcfilter = SDL_CreateRGBSurface(SDL_SWSURFACE,dstclp.w,dstclp.h+6,16,0x0000F800,0x000007E0,0x0000001F,0x00); - if(!srcfilter) return NULL; //No Memory? - Fillcolor = SDL_MapRGB(srcfilter->format,R,G,B); //Choose color - SDL_FillRect(srcfilter,NULL,Fillcolor); //fill it - if(filter == filter_hq2x || filter == hq2x32 || filter == lq2x32) // dst 0888 surface - dstfilter = SDL_CreateRGBSurface(SDL_SWSURFACE,dstclp.w*2,dstclp.h*2,32,0x00FF0000,0x0000FF00,0x000000FF,0x00); - else // dst 565 surface - dstfilter = SDL_CreateRGBSurface(SDL_SWSURFACE,dstclp.w*2,dstclp.h*2,16,0x0000F800,0x000007E0,0x0000001F,0x00); - if(!dstfilter || SDL_BlitSurface(src,srcclp,srcfilter,&dstclp) == -1) // No dstfilter or Blit failed - { - SDL_FreeSurface(srcfilter); // Free memory - return NULL; //No Memory? - } - else // have dstfilter ready and srcfilter done - { - SDL_FillRect(dstfilter,NULL,Fillcolor); //fill it too - filter(FILTER(srcfilter,dstfilter)); //filtering - SDL_FreeSurface(srcfilter); //almost - } - return dstfilter; //done -} - - -int filter_init_2xsai(SDL_PixelFormat *BitFormat) -{ - if (!BitFormat || BitFormat->BytesPerPixel != 2 ||BitFormat->Amask != 0x0) - { - return 0; - } - else if (BitFormat->Rmask == 0xF800 && BitFormat->Gmask == 0x7E0 - && BitFormat->Bmask == 0x1F && BitFormat->BitsPerPixel == 16) //565 - { - colorMask = 0xF7DEF7DE; - lowPixelMask = 0x08210821; - qcolorMask = 0xE79CE79C; - qlowpixelMask = 0x18631863; - redblueMask = 0xF81F; - greenMask = 0x7E0; - } - else if (BitFormat->Rmask == 0x7C00 && BitFormat->Gmask == 0x3E0 - && BitFormat->Bmask == 0x1F && BitFormat->BitsPerPixel == 15) //555 - { - colorMask = 0x7BDE7BDE; - lowPixelMask = 0x04210421; - qcolorMask = 0x739C739C; - qlowpixelMask = 0x0C630C63; - redblueMask = 0x7C1F; - greenMask = 0x3E0; - } - else - { - return 0; - } -#ifdef MMX - if(BitFormat->Gmask == 0x7E0) Init_2xSaIMMX(565); - else Init_2xSaIMMX(555); -#endif - return 1; -} - - -FUNCINLINE static ATTRINLINE int GetResult1 (Uint32 A, Uint32 B, Uint32 C, Uint32 D, Uint32 E) -{ - int x = 0; - int y = 0; - int r = 0; - (void)E; - - if (A == C) - x += 1; - else if (B == C) - y += 1; - if (A == D) - x += 1; - else if (B == D) - y += 1; - if (x <= 1) - r += 1; - if (y <= 1) - r -= 1; - return r; -} - -FUNCINLINE static ATTRINLINE int GetResult2 (Uint32 A, Uint32 B, Uint32 C, Uint32 D, Uint32 E) -{ - int x = 0; - int y = 0; - int r = 0; - (void)E; - - if (A == C) - x += 1; - else if (B == C) - y += 1; - if (A == D) - x += 1; - else if (B == D) - y += 1; - if (x <= 1) - r -= 1; - if (y <= 1) - r += 1; - return r; -} - -FUNCINLINE static ATTRINLINE int GetResult (Uint32 A, Uint32 B, Uint32 C, Uint32 D) -{ - int x = 0; - int y = 0; - int r = 0; - - if (A == C) - x += 1; - else if (B == C) - y += 1; - if (A == D) - x += 1; - else if (B == D) - y += 1; - if (x <= 1) - r += 1; - if (y <= 1) - r -= 1; - return r; -} - -FUNCINLINE static ATTRINLINE Uint32 INTERPOLATE (Uint32 A, Uint32 B) -{ - if (A != B) - { - return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) + - (A & B & lowPixelMask)); - } - else - return A; -} - -FUNCINLINE static ATTRINLINE Uint32 Q_INTERPOLATE (Uint32 A, Uint32 B, Uint32 C, Uint32 D) -{ - register Uint32 x = ((A & qcolorMask) >> 2) + - ((B & qcolorMask) >> 2) + - ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2); - register Uint32 y = (A & qlowpixelMask) + - (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask); - y = (y >> 2) & qlowpixelMask; - return x + y; -} - -#define BLUE_MASK565 0x001F001F -#define RED_MASK565 0xF800F800 -#define GREEN_MASK565 0x07E007E0 - -#define BLUE_MASK555 0x001F001F -#define RED_MASK555 0x7C007C00 -#define GREEN_MASK555 0x03E003E0 - -void filter_super2xsai(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - Uint16 *bP; - Uint8 *dP; - Uint32 inc_bP; - Uint32 Nextline = srcPitch >> 1; - - Uint32 finish; - inc_bP = 1; - - for (; height; height--) - { - bP = (Uint16 *) srcPtr; - dP = (Uint8 *) dstPtr; - - for (finish = width; finish; finish -= inc_bP) - { - Uint32 color4, color5, color6; - Uint32 color1, color2, color3; - Uint32 colorA0, colorA1, colorA2, colorA3, - colorB0, colorB1, colorB2, colorB3, colorS1, colorS2; - Uint32 product1a, product1b, product2a, product2b; - -//--------------------------------------- B1 B2 -// 4 5 6 S2 -// 1 2 3 S1 -// A1 A2 - - colorB0 = *(bP - Nextline - 1); - colorB1 = *(bP - Nextline); - colorB2 = *(bP - Nextline + 1); - colorB3 = *(bP - Nextline + 2); - - color4 = *(bP - 1); - color5 = *(bP); - color6 = *(bP + 1); - colorS2 = *(bP + 2); - - color1 = *(bP + Nextline - 1); - color2 = *(bP + Nextline); - color3 = *(bP + Nextline + 1); - colorS1 = *(bP + Nextline + 2); - - colorA0 = *(bP + Nextline + Nextline - 1); - colorA1 = *(bP + Nextline + Nextline); - colorA2 = *(bP + Nextline + Nextline + 1); - colorA3 = *(bP + Nextline + Nextline + 2); - -//-------------------------------------- - if (color2 == color6 && color5 != color3) - { - product2b = product1b = color2; - } - else if (color5 == color3 && color2 != color6) - { - product2b = product1b = color5; - } - else if (color5 == color3 && color2 == color6) - { - register int r = 0; - - r += GetResult (color6, color5, color1, colorA1); - r += GetResult (color6, color5, color4, colorB1); - r += GetResult (color6, color5, colorA2, colorS1); - r += GetResult (color6, color5, colorB2, colorS2); - - if (r > 0) - product2b = product1b = color6; - else if (r < 0) - product2b = product1b = color5; - else - { - product2b = product1b = INTERPOLATE (color5, color6); - } - } - else - { - if (color6 == color3 && color3 == colorA1 - && color2 != colorA2 && color3 != colorA0) - product2b = - Q_INTERPOLATE (color3, color3, color3, color2); - else if (color5 == color2 && color2 == colorA2 - && colorA1 != color3 && color2 != colorA3) - product2b = - Q_INTERPOLATE (color2, color2, color2, color3); - else - product2b = INTERPOLATE (color2, color3); - - if (color6 == color3 && color6 == colorB1 - && color5 != colorB2 && color6 != colorB0) - product1b = - Q_INTERPOLATE (color6, color6, color6, color5); - else if (color5 == color2 && color5 == colorB2 - && colorB1 != color6 && color5 != colorB3) - product1b = - Q_INTERPOLATE (color6, color5, color5, color5); - else - product1b = INTERPOLATE (color5, color6); - } - - if (color5 == color3 && color2 != color6 && color4 == color5 - && color5 != colorA2) - product2a = INTERPOLATE (color2, color5); - else - if (color5 == color1 && color6 == color5 - && color4 != color2 && color5 != colorA0) - product2a = INTERPOLATE (color2, color5); - else - product2a = color2; - - if (color2 == color6 && color5 != color3 && color1 == color2 - && color2 != colorB2) - product1a = INTERPOLATE (color2, color5); - else - if (color4 == color2 && color3 == color2 - && color1 != color5 && color2 != colorB0) - product1a = INTERPOLATE (color2, color5); - else - product1a = color5; - -#ifdef LSB_FIRST - product1a = product1a | (product1b << 16); - product2a = product2a | (product2b << 16); -#else - product1a = (product1a << 16) | product1b; - product2a = (product2a << 16) | product2b; -#endif - *((Uint32 *) dP) = product1a; - *((Uint32 *) (dP + dstPitch)) = product2a; - - bP += inc_bP; - dP += sizeof (Uint32); - } // end of for ( finish= width etc..) - - srcPtr += srcPitch; - dstPtr += dstPitch * 2; - } // endof: for (; height; height--) -} - -void filter_supereagle(Uint8 *srcPtr, Uint32 srcPitch, /* Uint8 *deltaPtr, */ - Uint8 *dstPtr, Uint32 dstPitch, int width, int height) -{ - Uint8 *dP; - Uint16 *bP; - Uint32 inc_bP; - - - - Uint32 finish; - Uint32 Nextline = srcPitch >> 1; - - inc_bP = 1; - - for (; height ; height--) - { - bP = (Uint16 *) srcPtr; - dP = dstPtr; - for (finish = width; finish; finish -= inc_bP) - { - Uint32 color4, color5, color6; - Uint32 color1, color2, color3; - Uint32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2; - Uint32 product1a, product1b, product2a, product2b; - colorB1 = *(bP - Nextline); - colorB2 = *(bP - Nextline + 1); - - color4 = *(bP - 1); - color5 = *(bP); - color6 = *(bP + 1); - colorS2 = *(bP + 2); - - color1 = *(bP + Nextline - 1); - color2 = *(bP + Nextline); - color3 = *(bP + Nextline + 1); - colorS1 = *(bP + Nextline + 2); - - colorA1 = *(bP + Nextline + Nextline); - colorA2 = *(bP + Nextline + Nextline + 1); - // -------------------------------------- - if (color2 == color6 && color5 != color3) - { - product1b = product2a = color2; - if ((color1 == color2) || (color6 == colorB2)) - { - product1a = INTERPOLATE (color2, color5); - product1a = INTERPOLATE (color2, product1a); -// product1a = color2; - } - else - { - product1a = INTERPOLATE (color5, color6); - } - - if ((color6 == colorS2) || (color2 == colorA1)) - { - product2b = INTERPOLATE (color2, color3); - product2b = INTERPOLATE (color2, product2b); -// product2b = color2; - } - else - { - product2b = INTERPOLATE (color2, color3); - } - } - else if (color5 == color3 && color2 != color6) - { - product2b = product1a = color5; - - if ((colorB1 == color5) || (color3 == colorS1)) - { - product1b = INTERPOLATE (color5, color6); - product1b = INTERPOLATE (color5, product1b); -// product1b = color5; - } - else - { - product1b = INTERPOLATE (color5, color6); - } - - if ((color3 == colorA2) || (color4 == color5)) - { - product2a = INTERPOLATE (color5, color2); - product2a = INTERPOLATE (color5, product2a); -// product2a = color5; - } - else - { - product2a = INTERPOLATE (color2, color3); - } - - } - else if (color5 == color3 && color2 == color6) - { - register int r = 0; - - r += GetResult (color6, color5, color1, colorA1); - r += GetResult (color6, color5, color4, colorB1); - r += GetResult (color6, color5, colorA2, colorS1); - r += GetResult (color6, color5, colorB2, colorS2); - - if (r > 0) - { - product1b = product2a = color2; - product1a = product2b = INTERPOLATE (color5, color6); - } - else if (r < 0) - { - product2b = product1a = color5; - product1b = product2a = INTERPOLATE (color5, color6); - } - else - { - product2b = product1a = color5; - product1b = product2a = color2; - } - } - else - { - product2b = product1a = INTERPOLATE (color2, color6); - product2b = - Q_INTERPOLATE (color3, color3, color3, product2b); - product1a = - Q_INTERPOLATE (color5, color5, color5, product1a); - - product2a = product1b = INTERPOLATE (color5, color3); - product2a = - Q_INTERPOLATE (color2, color2, color2, product2a); - product1b = - Q_INTERPOLATE (color6, color6, color6, product1b); - -// product1a = color5; -// product1b = color6; -// product2a = color2; -// product2b = color3; - } -#ifdef LSB_FIRST - product1a = product1a | (product1b << 16); - product2a = product2a | (product2b << 16); -#else - product1a = (product1a << 16) | product1b; - product2a = (product2a << 16) | product2b; -#endif - - *((Uint32 *) dP) = product1a; - *((Uint32 *) (dP + dstPitch)) = product2a; - - bP += inc_bP; - dP += sizeof (Uint32); - } // end of for ( finish= width etc..) - srcPtr += srcPitch; - dstPtr += dstPitch * 2; - } // endof: for (height; height; height--) -} - -void filter_2xsai (Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, int width, int height) -{ - Uint8 *dP; - Uint16 *bP; - Uint32 inc_bP; - - - Uint32 finish; - Uint32 Nextline = srcPitch >> 1; - inc_bP = 1; - - - for (; height; height--) - { - bP = (Uint16 *) srcPtr; - dP = dstPtr; - - for (finish = width; finish; finish -= inc_bP) - { - - register Uint32 colorA, colorB; - Uint32 colorC, colorD, - colorE, colorF, colorG, colorH, - colorI, colorJ, colorK, colorL, - - colorM, colorN, colorO, colorP; - Uint32 product, product1, product2; - -//--------------------------------------- -// Map of the pixels: I|E F|J -// G|A B|K -// H|C D|L -// M|N O|P - colorI = *(bP - Nextline - 1); - colorE = *(bP - Nextline); - colorF = *(bP - Nextline + 1); - colorJ = *(bP - Nextline + 2); - - colorG = *(bP - 1); - colorA = *(bP); - colorB = *(bP + 1); - colorK = *(bP + 2); - - colorH = *(bP + Nextline - 1); - colorC = *(bP + Nextline); - colorD = *(bP + Nextline + 1); - colorL = *(bP + Nextline + 2); - - colorM = *(bP + Nextline + Nextline - 1); - colorN = *(bP + Nextline + Nextline); - colorO = *(bP + Nextline + Nextline + 1); - colorP = *(bP + Nextline + Nextline + 2); - - if ((colorA == colorD) && (colorB != colorC)) - { - if (((colorA == colorE) && (colorB == colorL)) || - ((colorA == colorC) && (colorA == colorF) - && (colorB != colorE) && (colorB == colorJ))) - { - product = colorA; - } - else - { - product = INTERPOLATE (colorA, colorB); - } - - if (((colorA == colorG) && (colorC == colorO)) || - ((colorA == colorB) && (colorA == colorH) - && (colorG != colorC) && (colorC == colorM))) - { - product1 = colorA; - } - else - { - product1 = INTERPOLATE (colorA, colorC); - } - product2 = colorA; - } - else if ((colorB == colorC) && (colorA != colorD)) - { - if (((colorB == colorF) && (colorA == colorH)) || - ((colorB == colorE) && (colorB == colorD) - && (colorA != colorF) && (colorA == colorI))) - { - product = colorB; - } - else - { - product = INTERPOLATE (colorA, colorB); - } - - if (((colorC == colorH) && (colorA == colorF)) || - ((colorC == colorG) && (colorC == colorD) - && (colorA != colorH) && (colorA == colorI))) - { - product1 = colorC; - } - else - { - product1 = INTERPOLATE (colorA, colorC); - } - product2 = colorB; - } - else if ((colorA == colorD) && (colorB == colorC)) - { - if (colorA == colorB) - { - product = colorA; - product1 = colorA; - product2 = colorA; - } - else - { - register int r = 0; - - product1 = INTERPOLATE (colorA, colorC); - product = INTERPOLATE (colorA, colorB); - - r += - GetResult1 (colorA, colorB, colorG, colorE, - colorI); - r += - GetResult2 (colorB, colorA, colorK, colorF, - colorJ); - r += - GetResult2 (colorB, colorA, colorH, colorN, - colorM); - r += - GetResult1 (colorA, colorB, colorL, colorO, - colorP); - - if (r > 0) - product2 = colorA; - else if (r < 0) - product2 = colorB; - else - { - product2 = - Q_INTERPOLATE (colorA, colorB, colorC, - colorD); - } - } - } - else - { - product2 = Q_INTERPOLATE (colorA, colorB, colorC, colorD); - - if ((colorA == colorC) && (colorA == colorF) - && (colorB != colorE) && (colorB == colorJ)) - { - product = colorA; - } - else - if ((colorB == colorE) && (colorB == colorD) - && (colorA != colorF) && (colorA == colorI)) - { - product = colorB; - } - else - { - product = INTERPOLATE (colorA, colorB); - } - - if ((colorA == colorB) && (colorA == colorH) - && (colorG != colorC) && (colorC == colorM)) - { - product1 = colorA; - } - else - if ((colorC == colorG) && (colorC == colorD) - && (colorA != colorH) && (colorA == colorI)) - { - product1 = colorC; - } - else - { - product1 = INTERPOLATE (colorA, colorC); - } - } -#ifdef LSB_FIRST - product = colorA | (product << 16); - product1 = product1 | (product2 << 16); -#else - product = (colorA << 16) | product; - product1 = (product1 << 16) | product2; -#endif - *((Uint32 *) dP) = product; - *((Uint32 *) (dP + dstPitch)) = product1; - - bP += inc_bP; - dP += sizeof (Uint32); - } // end of for ( finish= width etc..) - - srcPtr += srcPitch; - dstPtr += dstPitch * 2; - } // endof: for (height; height; height--) -} - -#if 0 -static inline Uint32 Bilinear(Uint32 A, Uint32 B, Uint32 x) -{ - unsigned long areaA, areaB; - unsigned long result; - - if (A == B) - return A; - - areaB = (x >> 11) & 0x1f; // reduce 16 bit fraction to 5 bits - areaA = 0x20 - areaB; - - A = (A & redblueMask) | ((A & greenMask) << 16); - B = (B & redblueMask) | ((B & greenMask) << 16); - - result = ((areaA * A) + (areaB * B)) >> 5; - - return (result & redblueMask) | ((result >> 16) & greenMask); - -} - -static inline Uint32 Bilinear4 (Uint32 A, Uint32 B, Uint32 C, Uint32 D, Uint32 x, - Uint32 y) -{ - unsigned long areaA, areaB, areaC, areaD; - unsigned long result, xy; - - x = (x >> 11) & 0x1f; - y = (y >> 11) & 0x1f; - xy = (x * y) >> 5; - - A = (A & redblueMask) | ((A & greenMask) << 16); - B = (B & redblueMask) | ((B & greenMask) << 16); - C = (C & redblueMask) | ((C & greenMask) << 16); - D = (D & redblueMask) | ((D & greenMask) << 16); - - areaA = 0x20 + xy - x - y; - areaB = x - xy; - areaC = y - xy; - areaD = xy; - - result = ((areaA * A) + (areaB * B) + (areaC * C) + (areaD * D)) >> 5; - - return (result & redblueMask) | ((result >> 16) & greenMask); -} -#endif - - -void filter_advmame2x(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(short); - short *p = (short *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof(short); - short *q = (short *)dstPtr; - - while(height--) { - int i = 0, j = 0; - for(i = 0; i < width; ++i, j += 2) { - short B = *(p + i - nextlineSrc); - short D = *(p + i - 1); - short E = *(p + i); - short F = *(p + i + 1); - short H = *(p + i + nextlineSrc); - - *(q + j) = (short)(D == B && B != F && D != H ? D : E); - *(q + j + 1) = (short)(B == F && B != D && F != H ? F : E); - *(q + j + nextlineDst) = (short)(D == H && D != B && H != F ? D : E); - *(q + j + nextlineDst + 1) = (short)(H == F && D != H && B != F ? F : E); - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - - -void filter_tv2x(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - - while(height--) { - int i = 0, j = 0; - for(; i < width; ++i, j += 2) { - Uint16 p1 = *(p + i); - Uint32 pi; - - pi = (((p1 & redblueMask) * 7) >> 3) & redblueMask; - pi |= (((p1 & greenMask) * 7) >> 3) & greenMask; - - *(q + j) = (Uint16)p1; - *(q + j + 1) = (Uint16)p1; - *(q + j + nextlineDst) = (Uint16)pi; - *(q + j + nextlineDst + 1) = (Uint16)pi; - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - -void filter_normal2x(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - - while(height--) { - int i = 0, j = 0; - for(; i < width; ++i, j += 2) { - Uint16 color = *(p + i); - - *(q + j) = color; - *(q + j + 1) = color; - *(q + j + nextlineDst) = color; - *(q + j + nextlineDst + 1) = color; - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - -void filter_scan50(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - - while(height--) { - int i = 0, j = 0; - for(; i < width; ++i, j += 2) { - Uint16 p1 = *(p + i); - Uint16 p2 = *(p + i + nextlineSrc); - // 0111 1011 1110 1111 == 0x7BEF - Uint16 pm = (Uint16)(((p1 + p2) >> 2) & 0x7BEF); - - *(q + j) = p1; - *(q + j + 1) = p1; - *(q + j + nextlineDst) = pm; - *(q + j + nextlineDst + 1) = pm; - - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - - -void filter_scan100(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - - while(height--) { - int i = 0, j = 0; - for(; i < width; ++i, j += 2) { - *(q + j) = *(q + j + 1) = *(p + i); - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - - -FUNCINLINE static ATTRINLINE Uint16 DOT_16(Uint16 c, int j, int i) { - static const Uint16 dotmatrix[16] = { - 0x01E0, 0x0007, 0x3800, 0x0000, - 0x39E7, 0x0000, 0x39E7, 0x0000, - 0x3800, 0x0000, 0x01E0, 0x0007, - 0x39E7, 0x0000, 0x39E7, 0x0000 - }; - return (Uint16)(c - ((c >> 2) & *(dotmatrix + ((j & 3) << 2) + (i & 3)))); -} - -void filter_dotmatrix(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - - int i, ii, j, jj; - for(j = 0, jj = 0; j < height; ++j, jj += 2) { - for(i = 0, ii = 0; i < width; ++i, ii += 2) { - Uint16 c = *(p + i); - *(q + ii) = DOT_16(c, jj, ii); - *(q + ii + 1) = DOT_16(c, jj, ii + 1); - *(q + ii + nextlineDst) = DOT_16(c, jj + 1, ii); - *(q + ii + nextlineDst + 1) = DOT_16(c, jj + 1, ii + 1); - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - - -void filter_bilinear(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - - while(height--) { - int i, ii; - for(i = 0, ii = 0; i < width; ++i, ii += 2) { - Uint16 A = *(p + i); - Uint16 B = *(p + i + 1); - Uint16 C = *(p + i + nextlineSrc); - Uint16 D = *(p + i + nextlineSrc + 1); - *(q + ii) = A; - *(q + ii + 1) = (Uint16)INTERPOLATE(A, B); - *(q + ii + nextlineDst) = (Uint16)INTERPOLATE(A, C); - *(q + ii + nextlineDst + 1) = (Uint16)Q_INTERPOLATE(A, B, C, D); - } - p += nextlineSrc; - q += nextlineDst << 1; - } -} - - -// NEED_OPTIMIZE -static void MULT(Uint16 c, float* r, float* g, float* b, float alpha) { - *r += alpha * ((c & RED_MASK565 ) >> 11); - *g += alpha * ((c & GREEN_MASK565) >> 5); - *b += alpha * ((c & BLUE_MASK565 ) >> 0); -} - -static Uint16 MAKE_RGB565(float r, float g, float b) { - return (Uint16) - (((((Uint8)r) << 11) & RED_MASK565 ) | - ((((Uint8)g) << 5) & GREEN_MASK565) | - ((((Uint8)b) << 0) & BLUE_MASK565 )); -} - -FUNCINLINE static ATTRINLINE float CUBIC_WEIGHT(float x) { - // P(x) = { x, x>0 | 0, x<=0 } - // P(x + 2) ^ 3 - 4 * P(x + 1) ^ 3 + 6 * P(x) ^ 3 - 4 * P(x - 1) ^ 3 - double r = 0.; - if(x + 2 > 0) r += pow(x + 2, 3); - if(x + 1 > 0) r += -4 * pow(x + 1, 3); - if(x > 0) r += 6 * pow(x , 3); - if(x - 1 > 0) r += -4 * pow(x - 1, 3); - return (float)r / 6; -} - -void filter_bicubic(Uint8 *srcPtr, Uint32 srcPitch, - Uint8 *dstPtr, Uint32 dstPitch, - int width, int height) -{ - unsigned int nextlineSrc = srcPitch / sizeof(Uint16); - Uint16 *p = (Uint16 *)srcPtr; - unsigned int nextlineDst = dstPitch / sizeof(Uint16); - Uint16 *q = (Uint16 *)dstPtr; - int dx = width << 1, dy = height << 1; - float fsx = (float)width / dx; - float fsy = (float)height / dy; - float v = 0.0f; - int j = 0; - for(; j < dy; ++j) { - float u = 0.0f; - int iv = (int)v; - float decy = v - iv; - int i = 0; - for(; i < dx; ++i) { - int iu = (int)u; - float decx = u - iu; - float r, g, b; - int m; - r = g = b = 0.; - for(m = -1; m <= 2; ++m) { - float r1 = CUBIC_WEIGHT(decy - m); - int n; - for(n = -1; n <= 2; ++n) { - float r2 = CUBIC_WEIGHT(n - decx); - Uint16* pIn = p + (iu + n) + (iv + m) * nextlineSrc; - MULT(*pIn, &r, &g, &b, r1 * r2); - } - } - *(q + i) = MAKE_RGB565(r, g, b); - u += fsx; - } - q += nextlineDst; - v += fsy; - } -} diff --git a/src/sdl12/filter/filters.h b/src/sdl12/filter/filters.h deleted file mode 100644 index c4a84b4c9..000000000 --- a/src/sdl12/filter/filters.h +++ /dev/null @@ -1,212 +0,0 @@ -#ifndef __FILTERS_H__ -#define __FILTERS_H__ - -#ifdef _MSC_VER -#pragma warning(disable : 4514 4214 4244) -#endif - -#include "SDL.h" - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -typedef enum { - FILTER_2XSAI = 0, - FILTER_SUPER2XSAI, - FILTER_SUPEREAGLE, - FILTER_ADVMAME2X , - FILTER_TV2X , - FILTER_NORMAL2X , - FILTER_BILINEAR , - FILTER_DOTMATRIX , - FILTER_NUM , -} t_filter; - -typedef void (*filter_2)(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -SDL_Surface *filter_2x(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter); -SDL_Surface *filter_2xe(SDL_Surface *src, SDL_Rect *srcclp, filter_2 filter,Uint8 R, Uint8 G, Uint8 B); -//Alam_GBC: Header file based on sms_sdl's filter.h -//Note: need 3 lines at the bottom and top? - -//int filter_init_2xsai(SDL_PixelFormat *BitFormat); -#define FILTER(src,dst) (Uint8 *)(src->pixels)+src->pitch*3, (Uint32)src->pitch, (Uint8 *)dst->pixels, (Uint32)dst->pitch, src->w, src->h-6 -#define SDLFILTER(src,dst) (Uint8 *)src->pixels, (Uint32)src->pitch, (Uint8 *)dst->pixels, (Uint32)dst->pitch, src->w, src->h -int filter_init_2xsai(SDL_PixelFormat *BitFormat); //unless? -void filter_scan50(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_scan100(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); - -void filter_2xsai(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_super2xsai(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_supereagle(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_advmame2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_tv2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_normal2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_bilinear(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_dotmatrix(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void filter_bicubic(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void lq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void hq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); - -void filter_hq2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void lq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); -void hq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height); - -#ifdef FILTERS -typedef struct filter_s { filter_2 filter; int bpp; } filter_t; -#define NUMFILTERS 13 -static filter_t filtermode[NUMFILTERS+1] = { - {NULL , 0}, //None - {filter_normal2x , 16}, //2xNormal - {filter_advmame2x , 16}, //AdvMAME2x - {filter_tv2x , 16}, //TV2x - {filter_bilinear , 16}, //Bilinear - {filter_dotmatrix , 16}, //DotMatrix - {lq2x16 , 16}, //16LQ2x - {hq2x16 , 16}, //16HQ2x - {lq2x32 , 32}, //32LQ2x - {hq2x32 , 32}, //32HQ2x -// {filter_bicubic , 16}, //Slow Bicubic - // BAD - {filter_2xsai , 16}, //2xSAI - {filter_super2xsai, 16}, //Super2xSAI - {filter_supereagle, 16}, //SuperEagle -}; -CV_PossibleValue_t CV_Filters[] = {{ 0, "None"}, { 1, "2xNormal"}, - { 2, "AdvMAME2x"}, { 3, "TV2x"}, { 4, "Bilinear"} , { 5, "DotMatrix"}, - { 6, "16LQ2x"}, { 7, "16HQ2x"}, { 8, "32LQ2x"} , { 9, "32HQ2x"}, - {10, "2xSAI"}, {11, "Super2xSAI"}, {12, "SuperEagle"}, {0, NULL},}; -static void Filterchange(void); -consvar_t cv_filter = {"filter", "None", CV_CALL|CV_NOINIT, CV_Filters,Filterchange,0,NULL,NULL,0,0,NULL}; -static filter_2 blitfilter = NULL; -static SDL_Surface *preSurface = NULL; -static SDL_Surface *f2xSurface = NULL; - -static void Filterchange(void) -{ - if(blitfilter) // only filtering? - { - int i=0; - for(;i < NUMFILTERS; i++)//find old filter - { - if(filtermode[i].filter == blitfilter) //Found it - break; //Stop - } - if(i < NUMFILTERS && filtermode[i].bpp == filtermode[cv_filter.value].bpp) //Easy to swap? - blitfilter = filtermode[cv_filter.value].filter; // Swap with new filter - } -} - -FUNCINLINE static ATTRINLINE void FilterBlit(SDL_Surface *froSurface) -{ - if(froSurface && blitfilter && preSurface && f2xSurface) - { - SDL_Rect dstclp = {0,3,0,0}; - int lockedpre = 0, lockedf2x = 0, blitpre = 0; - blitpre = SDL_BlitSurface(froSurface,NULL,preSurface,&dstclp); - if(SDL_MUSTLOCK(preSurface)) lockedpre = SDL_LockSurface(preSurface); - if(SDL_MUSTLOCK(f2xSurface)) lockedf2x = SDL_LockSurface(f2xSurface); - if(lockedpre == 0 && preSurface->pixels && lockedf2x == 0 && f2xSurface->pixels && blitpre == 0) - { - blitfilter(FILTER(preSurface,f2xSurface)); - if(SDL_MUSTLOCK(preSurface)) SDL_UnlockSurface(preSurface); - if(SDL_MUSTLOCK(f2xSurface)) SDL_UnlockSurface(f2xSurface); - } - } - else - { - blitfilter = NULL; - if(preSurface) SDL_FreeSurface(preSurface); - preSurface = NULL; - if(f2xSurface) SDL_FreeSurface(f2xSurface); - f2xSurface = NULL; - } -} - -FUNCINLINE static ATTRINLINE int Setupf2x(int width, int height, int bpp) -{ - blitfilter = NULL; - if(preSurface) SDL_FreeSurface(preSurface); - preSurface = NULL; - if(f2xSurface) SDL_FreeSurface(f2xSurface); - f2xSurface = NULL; - if( !(width%2) && !(height%2) && width >= BASEVIDWIDTH*2 && height >= BASEVIDHEIGHT*2 && cv_filter.value - && cv_filter.value <= NUMFILTERS && filtermode[cv_filter.value].filter && filtermode[cv_filter.value].bpp) - { - int hwidth = width/2 + 6; - int heighth = height/2 + 6; - int hbpp = filtermode[cv_filter.value].bpp; - switch(hbpp) - { - case 8: - preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth, 8,0x00000000,0x00000000,0x00000000,0x00); - f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height , 8,0x00000000,0x00000000,0x00000000,0x00); - case 15: - preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,15,0x00007C00,0x000003E0,0x0000001F,0x00); - f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,15,0x00007C00,0x000003E0,0x0000001F,0x00); - break; - case 16: - preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,16,0x0000F800,0x000007E0,0x0000001F,0x00); - f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,16,0x0000F800,0x000007E0,0x0000001F,0x00); - break; - case 24: - preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,24,0x00FF0000,0x0000FF00,0x000000FF,0x00); - f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,24,0x00FF0000,0x0000FF00,0x000000FF,0x00); - break; - case 32: - preSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,hwidth,heighth,32,0x00FF0000,0x0000FF00,0x000000FF,0x00); - f2xSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, width,height ,32,0x00FF0000,0x0000FF00,0x000000FF,0x00); - break; - default: - //I_Error("Filter help"); - break; - } - if(preSurface && f2xSurface) - { - blitfilter = filtermode[cv_filter.value].filter; - if(bpp < hbpp) bpp = hbpp; - } - else - { - if(preSurface) SDL_FreeSurface(preSurface); - preSurface = NULL; - if(f2xSurface) SDL_FreeSurface(f2xSurface); - f2xSurface = NULL; - } - } - return bpp; -} -#else - -#ifdef __GNUC__ // __attribute__ ((X)) -#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) -#define FUNCINLINE __attribute__((always_inline)) -#endif -#define FUNCNOINLINE __attribute__((noinline)) -#elif defined(_MSC_VER) -#define inline __inline -#define ATTRNORETURN __declspec(noreturn) -#define ATTRINLINE __forceinline -#if _MSC_VER > 1200 -#define ATTRNOINLINE __declspec(noinline) -#endif -#endif - - - -#ifndef FUNCINLINE -#define FUNCINLINE -#endif -#ifndef FUNCNOINLINE -#define FUNCNOINLINE -#endif -#ifndef ATTRINLINE -#define ATTRINLINE inline -#endif -#ifndef ATTRNOINLINE -#define ATTRNOINLINE -#endif - -#endif - -#endif diff --git a/src/sdl12/filter/hq2x.c b/src/sdl12/filter/hq2x.c deleted file mode 100644 index acdbcb168..000000000 --- a/src/sdl12/filter/hq2x.c +++ /dev/null @@ -1,3125 +0,0 @@ -//hq2x filter demo program -//---------------------------------------------------------- -//Copyright (C) 2003 MaxSt ( maxst@hiend3d.com ) - -//This program is free software; you can redistribute it and/or -//modify it under the terms of the GNU Lesser General Public -//License as published by the Free Software Foundation; either -//version 2.1 of the License, or (at your option) any later version. -// -//This program is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -//Lesser General Public License for more details. -// -//You should have received a copy of the GNU Lesser General Public -//License along with this program; if not, write to the Free Software -//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -#include "filters.h" -#include -#ifdef __GNUC__ -#include -#endif - - -#if (defined(__GNUC__) && defined(__i386__)) || (defined(_MSC_VER) && defined(_X86_)) -#define HQ2XASM -#endif - -#ifdef _MSC_VER -//#define HQ2XMMXASM -#endif - -static int LUT16to32[65536]; -static int RGBtoYUV[65536]; -#ifdef HQ2XMMXASM -#include "SDL_cpuinfo.h" -static SDL_bool hasMMX = 0; -const Sint64 reg_blank = 0; -const Sint64 const3 = 0x0000000300030003; -const Sint64 const5 = 0x0000000500050005; -const Sint64 const6 = 0x0000000600060006; -const Sint64 const14 = 0x0000000E000E000E; -const Sint64 tr3eshold = 0x0000000000300706; -#endif -static int YUV1, YUV2; -const int Ymask = 0x00FF0000; -const int Umask = 0x0000FF00; -const int Vmask = 0x000000FF; -const int trY = 0x00300000; -const int trU = 0x00000700; -const int trV = 0x00000006; - -FUNCINLINE static ATTRINLINE void Interp1(Uint8 * pc, int c1, int c2) -{ -#ifdef HQ2XASM - //*((int*)pc) = (c1*3+c2)/4; -#ifdef __GNUC__ - int c3 = c1; - __asm__("shl $2, %1; add %2, %1; sub %3, %1; shr $2, %1":"=d"(*((int*)pc)):"d"(c1),"r"(c2),"r"(c3):"memory"); -#else - __asm - { - mov eax, pc - mov edx, c1 - shl edx, 2 - add edx, c2 - sub edx, c1 - shr edx, 2 - mov [eax], edx - } -#endif -#else - *((int*)pc) = (c1*3+c2) >> 2; -#endif -} - -FUNCINLINE static ATTRINLINE void Interp2(Uint8 * pc, int c1, int c2, int c3) -{ -#ifdef HQ2XASM -// *((int*)pc) = (c1*2+c2+c3) >> 2; -#ifdef __GNUC__ - __asm__("shl $1, %1; add %2, %1; add %3, %1; shr $2, %1":"=d"(*((int*)pc)):"d"(c1),"r"(c2),"r"(c3):"memory"); -#else - __asm - { - mov eax, pc - mov edx, c1 - shl edx, 1 - add edx, c2 - add edx, c3 - shr edx, 2 - mov [eax], edx - } -#endif -#else - *((int*)pc) = (c1*2+c2+c3) >> 2; -#endif -} - -#if 0 -static inline void Interp5(Uint8 * pc, int c1, int c2) -{ -#ifdef HQ2XASM - //*((int*)pc) = (c1+c2)/2; -#ifdef __GNUC__ - __asm__("add %2, %1; shr $1, %1":"=d"(*((int*)pc)):"d"(c1),"r"(c2):"memory"); -#else - __asm - { - mov eax, pc - mov edx, c1 - add edx, c2 - shr edx, 1 - mov [eax], edx - } -#endif -#else - *((int*)pc) = (c1+c2) >> 1; -#endif -} -#endif - -FUNCINLINE static ATTRINLINE void Interp6(Uint8 * pc, int c1, int c2, int c3) -{ -#ifdef HQ2XMMXASM - //*((int*)pc) = (c1*5+c2*2+c3)/8; - if(hasMMX) -#ifdef __GNUC__ - __asm__("movd %1, %%mm1; movd %2, %%mm2, movd %3, %%mm3; punpcklbw $_reg_blank, %%mm1; punpcklbw $_reg_blank, %%mm2; punpcklbw $_reg_blank, %%mm3; pmullw $_const5, %%mm1; psllw $1, %%mm2; paddw %%mm3, %%mm1; paddw %%mm2, %%mm1; psrlw $3, %%mm1; packuswb $_reg_blank, %%mm1; movd %%mm1, %0" : "=r"(*((int*)pc)) : "r" (c1),"r" (c2),"r" (c3) : "memory"); -#else - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const5 - psllw mm2, 1 - paddw mm1, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -#endif - else -#endif - *((int*)pc) = ((((c1 & 0x00FF00)*5 + (c2 & 0x00FF00)*2 + (c3 & 0x00FF00) ) & 0x0007F800) + - (((c1 & 0xFF00FF)*5 + (c2 & 0xFF00FF)*2 + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3; -} - -FUNCINLINE static ATTRINLINE void Interp7(Uint8 * pc, int c1, int c2, int c3) -{ -#ifdef HQ2XMMXASM - //*((int*)pc) = (c1*6+c2+c3)/8; - if(hasMMX) -#ifdef __GNUC__ - __asm__("movd %1, %%mm1; movd %2, %%mm2, movd %3, %%mm3; punpcklbw $_reg_blank, %%mm1; punpcklbw $_reg_blank, %%mm2; punpcklbw $_reg_blank, %%mm3; pmull2 $_const6, %%mm1; padw %%mm3, %%mm2; paddw %%mm2, %%mm1; psrlw $3, %%mm1; packuswb $_reg_blank, %%mm1; movd %%mm1, %0 " : "=r" (*((int*)pc)): "r"(c1), "r"(c2), "r"(c3) : "memory"); -#else - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const6 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -#endif - else -#endif - *((int*)pc) = ((((c1 & 0x00FF00)*6 + (c2 & 0x00FF00) + (c3 & 0x00FF00) ) & 0x0007F800) + - (((c1 & 0xFF00FF)*6 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x07F807F8)) >> 3; -} - -FUNCINLINE static ATTRINLINE void Interp9(Uint8 * pc, int c1, int c2, int c3) -{ -#ifdef HQ2XMMXASM - //*((int*)pc) = (c1*2+(c2+c3)*3)/8; - if(hasMMX) -#ifdef __GNUC__ - __asm__("movd %1, %%mm1; movd %2, %%mm2, movd %3, %%mm3; punpcklbw $_reg_blank, %%mm1; punpcklbw $_reg_blank, %%mm2; punpcklbw $_reg_blank, %%mm3; psllw $1, %%mm1; paddw %%mm3, %%mm2; pmullw $_const3, %%mm2; padw %%mm2, %%mm1; psrlw $3, %%mm1; packuswb $_reg_blank, %%mm1; movd %%mm1, %0;" : "=r"(*((int*)pc)) : "r" (c1),"r" (c2),"r" (c3) : "memory"); -#else - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - psllw mm1, 1 - paddw mm2, mm3 - pmullw mm2, const3 - paddw mm1, mm2 - psrlw mm1, 3 - packuswb mm1, reg_blank - movd [eax], mm1 - } -#endif - else -#endif - *((int*)pc) = ((((c1 & 0x00FF00)*2 + ((c2 & 0x00FF00) + (c3 & 0x00FF00))*3 ) & 0x0007F800) + - (((c1 & 0xFF00FF)*2 + ((c2 & 0xFF00FF) + (c3 & 0xFF00FF))*3 ) & 0x07F807F8)) >> 3; -} - -FUNCINLINE static ATTRINLINE void Interp10(Uint8 * pc, int c1, int c2, int c3) -{ -#ifdef HQ2XMMXASM - //*((int*)pc) = (c1*14+c2+c3)/16; - if(hasMMX) -#ifdef __GNUC__ - __asm__("movd %1, %%mm1; movd %2, %%mm2, movd %3, %%mm3; punpcklbw $_reg_blank, %%mm1; punpcklbw $_reg_blank, %%mm2; punpcklbw $_reg_blank, %%mm3; pmullw $_const14, %%mm1; paddw %%mm3, %%mm2; paddw %%mm2, %%mm1; psrlw $4, %%mm1; packuswb $_req_blank, %%mm1; movd %%mm1, %0;" : "=r"(*((int*)pc)) : "r" (c1),"r" (c2),"r" (c3) : "memory"); -#else - __asm - { - mov eax, pc - movd mm1, c1 - movd mm2, c2 - movd mm3, c3 - punpcklbw mm1, reg_blank - punpcklbw mm2, reg_blank - punpcklbw mm3, reg_blank - pmullw mm1, const14 - paddw mm2, mm3 - paddw mm1, mm2 - psrlw mm1, 4 - packuswb mm1, reg_blank - movd [eax], mm1 - } -#endif - else -#endif - *((int*)pc) = ((((c1 & 0x00FF00)*14 + (c2 & 0x00FF00) + (c3 & 0x00FF00) ) & 0x000FF000) + - (((c1 & 0xFF00FF)*14 + (c2 & 0xFF00FF) + (c3 & 0xFF00FF) ) & 0x0FF00FF0)) >> 4; -} -#define PIXEL00_0 *((int*)(pOut)) = c[5]; -#define PIXEL00_10 Interp1(pOut, c[5], c[1]); -#define PIXEL00_11 Interp1(pOut, c[5], c[4]); -#define PIXEL00_12 Interp1(pOut, c[5], c[2]); -#define PIXEL00_20 Interp2(pOut, c[5], c[4], c[2]); -#define PIXEL00_21 Interp2(pOut, c[5], c[1], c[2]); -#define PIXEL00_22 Interp2(pOut, c[5], c[1], c[4]); -#define PIXEL00_60 Interp6(pOut, c[5], c[2], c[4]); -#define PIXEL00_61 Interp6(pOut, c[5], c[4], c[2]); -#define PIXEL00_70 Interp7(pOut, c[5], c[4], c[2]); -#define PIXEL00_90 Interp9(pOut, c[5], c[4], c[2]); -#define PIXEL00_100 Interp10(pOut, c[5], c[4], c[2]); -#define PIXEL01_0 *((int*)(pOut+4)) = c[5]; -#define PIXEL01_10 Interp1(pOut+4, c[5], c[3]); -#define PIXEL01_11 Interp1(pOut+4, c[5], c[2]); -#define PIXEL01_12 Interp1(pOut+4, c[5], c[6]); -#define PIXEL01_20 Interp2(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_21 Interp2(pOut+4, c[5], c[3], c[6]); -#define PIXEL01_22 Interp2(pOut+4, c[5], c[3], c[2]); -#define PIXEL01_60 Interp6(pOut+4, c[5], c[6], c[2]); -#define PIXEL01_61 Interp6(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_70 Interp7(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_90 Interp9(pOut+4, c[5], c[2], c[6]); -#define PIXEL01_100 Interp10(pOut+4, c[5], c[2], c[6]); -#define PIXEL10_0 *((int*)(pOut+BpL)) = c[5]; -#define PIXEL10_10 Interp1(pOut+BpL, c[5], c[7]); -#define PIXEL10_11 Interp1(pOut+BpL, c[5], c[8]); -#define PIXEL10_12 Interp1(pOut+BpL, c[5], c[4]); -#define PIXEL10_20 Interp2(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_21 Interp2(pOut+BpL, c[5], c[7], c[4]); -#define PIXEL10_22 Interp2(pOut+BpL, c[5], c[7], c[8]); -#define PIXEL10_60 Interp6(pOut+BpL, c[5], c[4], c[8]); -#define PIXEL10_61 Interp6(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_70 Interp7(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_90 Interp9(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL10_100 Interp10(pOut+BpL, c[5], c[8], c[4]); -#define PIXEL11_0 *((int*)(pOut+BpL+4)) = c[5]; -#define PIXEL11_10 Interp1(pOut+BpL+4, c[5], c[9]); -#define PIXEL11_11 Interp1(pOut+BpL+4, c[5], c[6]); -#define PIXEL11_12 Interp1(pOut+BpL+4, c[5], c[8]); -#define PIXEL11_20 Interp2(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_21 Interp2(pOut+BpL+4, c[5], c[9], c[8]); -#define PIXEL11_22 Interp2(pOut+BpL+4, c[5], c[9], c[6]); -#define PIXEL11_60 Interp6(pOut+BpL+4, c[5], c[8], c[6]); -#define PIXEL11_61 Interp6(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_70 Interp7(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_90 Interp9(pOut+BpL+4, c[5], c[6], c[8]); -#define PIXEL11_100 Interp10(pOut+BpL+4, c[5], c[6], c[8]); - -#ifdef _MSC_VER -#pragma warning(disable: 4035) -#endif - -FUNCINLINE static ATTRINLINE int Diff(Uint32 w1, Uint32 w2) -{ -#ifdef HQ2XMMXASM - if(hasMMX) - { -#ifdef __GNUC__ - int diffresult = 0; - if(w1 != w2) - __asm__("movd %3+%1*4, %%mm1; movq %%mm1, %%mm5; movd %3+%2*4, %%mm2; psubusb %%mm2, %%mm1; psubusb %%mm5, %%mm2; por %%mm2, %%mm1; psubusb $_treshold, %%mm1; movd %%mm1, %0" : "=c" (diffresult):"d" (w1),"q" (w2),"c" (RGBtoYUV) : "memory"); - return diffresult; -#else - __asm - { - xor eax,eax - mov ebx,w1 - mov edx,w2 - cmp ebx,edx - je FIN - mov ecx,offset RGBtoYUV - movd mm1,[ecx + ebx*4] - movq mm5,mm1 - movd mm2,[ecx + edx*4] - psubusb mm1,mm2 - psubusb mm2,mm5 - por mm1,mm2 - psubusb mm1,treshold - movd eax,mm1 -FIN: - }// returns result in eax register -#endif - } - else -#endif - { - YUV1 = RGBtoYUV[w1]; - YUV2 = RGBtoYUV[w2]; - return ( ( abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY ) || - ( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || - ( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ); - } -} - - -#ifdef _MSC_VER -#pragma warning(default: 4035) -#endif - - -static void hq2x_32( Uint8 * pIn, Uint8 * pOut, int Xres, int Yres, int BpL ) -{ - int i, j, k; - int prevline, nextline; - int w[10]; - int c[10]; - - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ - - for (j=0; j0) prevline = -Xres*2; else prevline = 0; - if (j0) - { - w[1] = *((Uint16*)(pIn + prevline - 2)); - w[4] = *((Uint16*)(pIn - 2)); - w[7] = *((Uint16*)(pIn + nextline - 2)); - } - else - { - w[1] = w[2]; - w[4] = w[5]; - w[7] = w[8]; - } - - if (i trY ) || - ( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || - ( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) - pattern |= flag; - } - flag <<= 1; - } - } - - for (k=1; k<=9; k++) - c[k] = LUT16to32[w[k]]; - - switch (pattern) - { - case 0: - case 1: - case 4: - case 32: - case 128: - case 5: - case 132: - case 160: - case 33: - case 129: - case 36: - case 133: - case 164: - case 161: - case 37: - case 165: - { - PIXEL00_20 - PIXEL01_20 - PIXEL10_20 - PIXEL11_20 - break; - } - case 2: - case 34: - case 130: - case 162: - { - PIXEL00_22 - PIXEL01_21 - PIXEL10_20 - PIXEL11_20 - break; - } - case 16: - case 17: - case 48: - case 49: - { - PIXEL00_20 - PIXEL01_22 - PIXEL10_20 - PIXEL11_21 - break; - } - case 64: - case 65: - case 68: - case 69: - { - PIXEL00_20 - PIXEL01_20 - PIXEL10_21 - PIXEL11_22 - break; - } - case 8: - case 12: - case 136: - case 140: - { - PIXEL00_21 - PIXEL01_20 - PIXEL10_22 - PIXEL11_20 - break; - } - case 3: - case 35: - case 131: - case 163: - { - PIXEL00_11 - PIXEL01_21 - PIXEL10_20 - PIXEL11_20 - break; - } - case 6: - case 38: - case 134: - case 166: - { - PIXEL00_22 - PIXEL01_12 - PIXEL10_20 - PIXEL11_20 - break; - } - case 20: - case 21: - case 52: - case 53: - { - PIXEL00_20 - PIXEL01_11 - PIXEL10_20 - PIXEL11_21 - break; - } - case 144: - case 145: - case 176: - case 177: - { - PIXEL00_20 - PIXEL01_22 - PIXEL10_20 - PIXEL11_12 - break; - } - case 192: - case 193: - case 196: - case 197: - { - PIXEL00_20 - PIXEL01_20 - PIXEL10_21 - PIXEL11_11 - break; - } - case 96: - case 97: - case 100: - case 101: - { - PIXEL00_20 - PIXEL01_20 - PIXEL10_12 - PIXEL11_22 - break; - } - case 40: - case 44: - case 168: - case 172: - { - PIXEL00_21 - PIXEL01_20 - PIXEL10_11 - PIXEL11_20 - break; - } - case 9: - case 13: - case 137: - case 141: - { - PIXEL00_12 - PIXEL01_20 - PIXEL10_22 - PIXEL11_20 - break; - } - case 18: - case 50: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_20 - } - PIXEL10_20 - PIXEL11_21 - break; - } - case 80: - case 81: - { - PIXEL00_20 - PIXEL01_22 - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_20 - } - break; - } - case 72: - case 76: - { - PIXEL00_21 - PIXEL01_20 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_20 - } - PIXEL11_22 - break; - } - case 10: - case 138: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_20 - } - PIXEL01_21 - PIXEL10_22 - PIXEL11_20 - break; - } - case 66: - { - PIXEL00_22 - PIXEL01_21 - PIXEL10_21 - PIXEL11_22 - break; - } - case 24: - { - PIXEL00_21 - PIXEL01_22 - PIXEL10_22 - PIXEL11_21 - break; - } - case 7: - case 39: - case 135: - { - PIXEL00_11 - PIXEL01_12 - PIXEL10_20 - PIXEL11_20 - break; - } - case 148: - case 149: - case 180: - { - PIXEL00_20 - PIXEL01_11 - PIXEL10_20 - PIXEL11_12 - break; - } - case 224: - case 228: - case 225: - { - PIXEL00_20 - PIXEL01_20 - PIXEL10_12 - PIXEL11_11 - break; - } - case 41: - case 169: - case 45: - { - PIXEL00_12 - PIXEL01_20 - PIXEL10_11 - PIXEL11_20 - break; - } - case 22: - case 54: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_20 - PIXEL11_21 - break; - } - case 208: - case 209: - { - PIXEL00_20 - PIXEL01_22 - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 104: - case 108: - { - PIXEL00_21 - PIXEL01_20 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_22 - break; - } - case 11: - case 139: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_21 - PIXEL10_22 - PIXEL11_20 - break; - } - case 19: - case 51: - { - if (Diff(w[2], w[6])) - { - PIXEL00_11 - PIXEL01_10 - } - else - { - PIXEL00_60 - PIXEL01_90 - } - PIXEL10_20 - PIXEL11_21 - break; - } - case 146: - case 178: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - PIXEL11_12 - } - else - { - PIXEL01_90 - PIXEL11_61 - } - PIXEL10_20 - break; - } - case 84: - case 85: - { - PIXEL00_20 - if (Diff(w[6], w[8])) - { - PIXEL01_11 - PIXEL11_10 - } - else - { - PIXEL01_60 - PIXEL11_90 - } - PIXEL10_21 - break; - } - case 112: - case 113: - { - PIXEL00_20 - PIXEL01_22 - if (Diff(w[6], w[8])) - { - PIXEL10_12 - PIXEL11_10 - } - else - { - PIXEL10_61 - PIXEL11_90 - } - break; - } - case 200: - case 204: - { - PIXEL00_21 - PIXEL01_20 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - PIXEL11_11 - } - else - { - PIXEL10_90 - PIXEL11_60 - } - break; - } - case 73: - case 77: - { - if (Diff(w[8], w[4])) - { - PIXEL00_12 - PIXEL10_10 - } - else - { - PIXEL00_61 - PIXEL10_90 - } - PIXEL01_20 - PIXEL11_22 - break; - } - case 42: - case 170: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - PIXEL10_11 - } - else - { - PIXEL00_90 - PIXEL10_60 - } - PIXEL01_21 - PIXEL11_20 - break; - } - case 14: - case 142: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - PIXEL01_12 - } - else - { - PIXEL00_90 - PIXEL01_61 - } - PIXEL10_22 - PIXEL11_20 - break; - } - case 67: - { - PIXEL00_11 - PIXEL01_21 - PIXEL10_21 - PIXEL11_22 - break; - } - case 70: - { - PIXEL00_22 - PIXEL01_12 - PIXEL10_21 - PIXEL11_22 - break; - } - case 28: - { - PIXEL00_21 - PIXEL01_11 - PIXEL10_22 - PIXEL11_21 - break; - } - case 152: - { - PIXEL00_21 - PIXEL01_22 - PIXEL10_22 - PIXEL11_12 - break; - } - case 194: - { - PIXEL00_22 - PIXEL01_21 - PIXEL10_21 - PIXEL11_11 - break; - } - case 98: - { - PIXEL00_22 - PIXEL01_21 - PIXEL10_12 - PIXEL11_22 - break; - } - case 56: - { - PIXEL00_21 - PIXEL01_22 - PIXEL10_11 - PIXEL11_21 - break; - } - case 25: - { - PIXEL00_12 - PIXEL01_22 - PIXEL10_22 - PIXEL11_21 - break; - } - case 26: - case 31: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_22 - PIXEL11_21 - break; - } - case 82: - case 214: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 88: - case 248: - { - PIXEL00_21 - PIXEL01_22 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 74: - case 107: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_21 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_22 - break; - } - case 27: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_10 - PIXEL10_22 - PIXEL11_21 - break; - } - case 86: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_21 - PIXEL11_10 - break; - } - case 216: - { - PIXEL00_21 - PIXEL01_22 - PIXEL10_10 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 106: - { - PIXEL00_10 - PIXEL01_21 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_22 - break; - } - case 30: - { - PIXEL00_10 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_22 - PIXEL11_21 - break; - } - case 210: - { - PIXEL00_22 - PIXEL01_10 - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 120: - { - PIXEL00_21 - PIXEL01_22 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_10 - break; - } - case 75: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_21 - PIXEL10_10 - PIXEL11_22 - break; - } - case 29: - { - PIXEL00_12 - PIXEL01_11 - PIXEL10_22 - PIXEL11_21 - break; - } - case 198: - { - PIXEL00_22 - PIXEL01_12 - PIXEL10_21 - PIXEL11_11 - break; - } - case 184: - { - PIXEL00_21 - PIXEL01_22 - PIXEL10_11 - PIXEL11_12 - break; - } - case 99: - { - PIXEL00_11 - PIXEL01_21 - PIXEL10_12 - PIXEL11_22 - break; - } - case 57: - { - PIXEL00_12 - PIXEL01_22 - PIXEL10_11 - PIXEL11_21 - break; - } - case 71: - { - PIXEL00_11 - PIXEL01_12 - PIXEL10_21 - PIXEL11_22 - break; - } - case 156: - { - PIXEL00_21 - PIXEL01_11 - PIXEL10_22 - PIXEL11_12 - break; - } - case 226: - { - PIXEL00_22 - PIXEL01_21 - PIXEL10_12 - PIXEL11_11 - break; - } - case 60: - { - PIXEL00_21 - PIXEL01_11 - PIXEL10_11 - PIXEL11_21 - break; - } - case 195: - { - PIXEL00_11 - PIXEL01_21 - PIXEL10_21 - PIXEL11_11 - break; - } - case 102: - { - PIXEL00_22 - PIXEL01_12 - PIXEL10_12 - PIXEL11_22 - break; - } - case 153: - { - PIXEL00_12 - PIXEL01_22 - PIXEL10_22 - PIXEL11_12 - break; - } - case 58: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_11 - PIXEL11_21 - break; - } - case 83: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 92: - { - PIXEL00_21 - PIXEL01_11 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 202: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - PIXEL01_21 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - PIXEL11_11 - break; - } - case 78: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - PIXEL11_22 - break; - } - case 154: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_22 - PIXEL11_12 - break; - } - case 114: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 89: - { - PIXEL00_12 - PIXEL01_22 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 90: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 55: - case 23: - { - if (Diff(w[2], w[6])) - { - PIXEL00_11 - PIXEL01_0 - } - else - { - PIXEL00_60 - PIXEL01_90 - } - PIXEL10_20 - PIXEL11_21 - break; - } - case 182: - case 150: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - PIXEL11_12 - } - else - { - PIXEL01_90 - PIXEL11_61 - } - PIXEL10_20 - break; - } - case 213: - case 212: - { - PIXEL00_20 - if (Diff(w[6], w[8])) - { - PIXEL01_11 - PIXEL11_0 - } - else - { - PIXEL01_60 - PIXEL11_90 - } - PIXEL10_21 - break; - } - case 241: - case 240: - { - PIXEL00_20 - PIXEL01_22 - if (Diff(w[6], w[8])) - { - PIXEL10_12 - PIXEL11_0 - } - else - { - PIXEL10_61 - PIXEL11_90 - } - break; - } - case 236: - case 232: - { - PIXEL00_21 - PIXEL01_20 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - PIXEL11_11 - } - else - { - PIXEL10_90 - PIXEL11_60 - } - break; - } - case 109: - case 105: - { - if (Diff(w[8], w[4])) - { - PIXEL00_12 - PIXEL10_0 - } - else - { - PIXEL00_61 - PIXEL10_90 - } - PIXEL01_20 - PIXEL11_22 - break; - } - case 171: - case 43: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL10_11 - } - else - { - PIXEL00_90 - PIXEL10_60 - } - PIXEL01_21 - PIXEL11_20 - break; - } - case 143: - case 15: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_12 - } - else - { - PIXEL00_90 - PIXEL01_61 - } - PIXEL10_22 - PIXEL11_20 - break; - } - case 124: - { - PIXEL00_21 - PIXEL01_11 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_10 - break; - } - case 203: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_21 - PIXEL10_10 - PIXEL11_11 - break; - } - case 62: - { - PIXEL00_10 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_11 - PIXEL11_21 - break; - } - case 211: - { - PIXEL00_11 - PIXEL01_10 - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 118: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_12 - PIXEL11_10 - break; - } - case 217: - { - PIXEL00_12 - PIXEL01_22 - PIXEL10_10 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 110: - { - PIXEL00_10 - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_22 - break; - } - case 155: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_10 - PIXEL10_22 - PIXEL11_12 - break; - } - case 188: - { - PIXEL00_21 - PIXEL01_11 - PIXEL10_11 - PIXEL11_12 - break; - } - case 185: - { - PIXEL00_12 - PIXEL01_22 - PIXEL10_11 - PIXEL11_12 - break; - } - case 61: - { - PIXEL00_12 - PIXEL01_11 - PIXEL10_11 - PIXEL11_21 - break; - } - case 157: - { - PIXEL00_12 - PIXEL01_11 - PIXEL10_22 - PIXEL11_12 - break; - } - case 103: - { - PIXEL00_11 - PIXEL01_12 - PIXEL10_12 - PIXEL11_22 - break; - } - case 227: - { - PIXEL00_11 - PIXEL01_21 - PIXEL10_12 - PIXEL11_11 - break; - } - case 230: - { - PIXEL00_22 - PIXEL01_12 - PIXEL10_12 - PIXEL11_11 - break; - } - case 199: - { - PIXEL00_11 - PIXEL01_12 - PIXEL10_21 - PIXEL11_11 - break; - } - case 220: - { - PIXEL00_21 - PIXEL01_11 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 158: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_22 - PIXEL11_12 - break; - } - case 234: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - PIXEL01_21 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_11 - break; - } - case 242: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 59: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_11 - PIXEL11_21 - break; - } - case 121: - { - PIXEL00_12 - PIXEL01_22 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 87: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 79: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - PIXEL11_22 - break; - } - case 122: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 94: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 218: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 91: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 229: - { - PIXEL00_20 - PIXEL01_20 - PIXEL10_12 - PIXEL11_11 - break; - } - case 167: - { - PIXEL00_11 - PIXEL01_12 - PIXEL10_20 - PIXEL11_20 - break; - } - case 173: - { - PIXEL00_12 - PIXEL01_20 - PIXEL10_11 - PIXEL11_20 - break; - } - case 181: - { - PIXEL00_20 - PIXEL01_11 - PIXEL10_20 - PIXEL11_12 - break; - } - case 186: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_11 - PIXEL11_12 - break; - } - case 115: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 93: - { - PIXEL00_12 - PIXEL01_11 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 206: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - PIXEL11_11 - break; - } - case 205: - case 201: - { - PIXEL00_12 - PIXEL01_20 - if (Diff(w[8], w[4])) - { - PIXEL10_10 - } - else - { - PIXEL10_70 - } - PIXEL11_11 - break; - } - case 174: - case 46: - { - if (Diff(w[4], w[2])) - { - PIXEL00_10 - } - else - { - PIXEL00_70 - } - PIXEL01_12 - PIXEL10_11 - PIXEL11_20 - break; - } - case 179: - case 147: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_10 - } - else - { - PIXEL01_70 - } - PIXEL10_20 - PIXEL11_12 - break; - } - case 117: - case 116: - { - PIXEL00_20 - PIXEL01_11 - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_10 - } - else - { - PIXEL11_70 - } - break; - } - case 189: - { - PIXEL00_12 - PIXEL01_11 - PIXEL10_11 - PIXEL11_12 - break; - } - case 231: - { - PIXEL00_11 - PIXEL01_12 - PIXEL10_12 - PIXEL11_11 - break; - } - case 126: - { - PIXEL00_10 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_10 - break; - } - case 219: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_10 - PIXEL10_10 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 125: - { - if (Diff(w[8], w[4])) - { - PIXEL00_12 - PIXEL10_0 - } - else - { - PIXEL00_61 - PIXEL10_90 - } - PIXEL01_11 - PIXEL11_10 - break; - } - case 221: - { - PIXEL00_12 - if (Diff(w[6], w[8])) - { - PIXEL01_11 - PIXEL11_0 - } - else - { - PIXEL01_60 - PIXEL11_90 - } - PIXEL10_10 - break; - } - case 207: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_12 - } - else - { - PIXEL00_90 - PIXEL01_61 - } - PIXEL10_10 - PIXEL11_11 - break; - } - case 238: - { - PIXEL00_10 - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - PIXEL11_11 - } - else - { - PIXEL10_90 - PIXEL11_60 - } - break; - } - case 190: - { - PIXEL00_10 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - PIXEL11_12 - } - else - { - PIXEL01_90 - PIXEL11_61 - } - PIXEL10_11 - break; - } - case 187: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL10_11 - } - else - { - PIXEL00_90 - PIXEL10_60 - } - PIXEL01_10 - PIXEL11_12 - break; - } - case 243: - { - PIXEL00_11 - PIXEL01_10 - if (Diff(w[6], w[8])) - { - PIXEL10_12 - PIXEL11_0 - } - else - { - PIXEL10_61 - PIXEL11_90 - } - break; - } - case 119: - { - if (Diff(w[2], w[6])) - { - PIXEL00_11 - PIXEL01_0 - } - else - { - PIXEL00_60 - PIXEL01_90 - } - PIXEL10_12 - PIXEL11_10 - break; - } - case 237: - case 233: - { - PIXEL00_12 - PIXEL01_20 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - PIXEL11_11 - break; - } - case 175: - case 47: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - PIXEL01_12 - PIXEL10_11 - PIXEL11_20 - break; - } - case 183: - case 151: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - PIXEL10_20 - PIXEL11_12 - break; - } - case 245: - case 244: - { - PIXEL00_20 - PIXEL01_11 - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - case 250: - { - PIXEL00_10 - PIXEL01_10 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 123: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_10 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_10 - break; - } - case 95: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_10 - PIXEL11_10 - break; - } - case 222: - { - PIXEL00_10 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_10 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 252: - { - PIXEL00_21 - PIXEL01_11 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - case 249: - { - PIXEL00_12 - PIXEL01_22 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 235: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_21 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - PIXEL11_11 - break; - } - case 111: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_22 - break; - } - case 63: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_11 - PIXEL11_21 - break; - } - case 159: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - PIXEL10_22 - PIXEL11_12 - break; - } - case 215: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - PIXEL10_21 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 246: - { - PIXEL00_22 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - case 254: - { - PIXEL00_10 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - case 253: - { - PIXEL00_12 - PIXEL01_11 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - case 251: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_10 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 239: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - PIXEL01_12 - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - PIXEL11_11 - break; - } - case 127: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_20 - } - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_20 - } - PIXEL11_10 - break; - } - case 191: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - PIXEL10_11 - PIXEL11_12 - break; - } - case 223: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - PIXEL10_10 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_20 - } - break; - } - case 247: - { - PIXEL00_11 - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - PIXEL10_12 - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - case 255: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_100 - } - if (Diff(w[2], w[6])) - { - PIXEL01_0 - } - else - { - PIXEL01_100 - } - if (Diff(w[8], w[4])) - { - PIXEL10_0 - } - else - { - PIXEL10_100 - } - if (Diff(w[6], w[8])) - { - PIXEL11_0 - } - else - { - PIXEL11_100 - } - break; - } - } - pIn+=2; - pOut+=8; - } - pOut+=BpL; - } -} - -FUNCINLINE static ATTRINLINE void InitLUTs(void) -{ - int i, j, k, r, g, b, Y, u, v; - -#ifdef HQ2XMMXASM - hasMMX = SDL_HasMMX(); -#endif - - for (i=0; i<65536; i++) - LUT16to32[i] = ((i & 0xF800) << 8) + ((i & 0x07E0) << 5) + ((i & 0x001F) << 3); - - for (i=0; i<32; i++) - for (j=0; j<64; j++) - for (k=0; k<32; k++) - { - r = i << 3; - g = j << 2; - b = k << 3; - Y = (r + g + b) >> 2; - u = 128 + ((r - b) >> 2); - v = 128 + ((-r + 2*g -b)>>3); - RGBtoYUV[ (i << 11) + (j << 5) + k ] = (Y<<16) + (u<<8) + v; - } -} - -void filter_hq2x(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, Uint32 dstPitch, int width, int height) -{ - static Uint8 doneLUT = 1; - (void)srcPitch; - if(doneLUT) InitLUTs(); - else doneLUT = 0; - hq2x_32( srcPtr, dstPtr, width, height, dstPitch ); -} diff --git a/src/sdl12/filter/hq2x.h b/src/sdl12/filter/hq2x.h deleted file mode 100644 index 49c0b2687..000000000 --- a/src/sdl12/filter/hq2x.h +++ /dev/null @@ -1,1824 +0,0 @@ -case 0 : -case 1 : -case 4 : -case 5 : -case 32 : -case 33 : -case 36 : -case 37 : -case 128 : -case 129 : -case 132 : -case 133 : -case 160 : -case 161 : -case 164 : -case 165 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 2 : -case 34 : -case 130 : -case 162 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 3 : -case 35 : -case 131 : -case 163 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 6 : -case 38 : -case 134 : -case 166 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 7 : -case 39 : -case 135 : -case 167 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 8 : -case 12 : -case 136 : -case 140 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); -} break; -case 9 : -case 13 : -case 137 : -case 141 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); -} break; -case 10 : -case 138 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 11 : -case 139 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 14 : -case 142 : -{ - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 15 : -case 143 : -{ - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 16 : -case 17 : -case 48 : -case 49 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); -} break; -case 18 : -case 50 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 19 : -case 51 : -{ - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P0 = I31(4, 3); - P1 = I31(4, 2); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 20 : -case 21 : -case 52 : -case 53 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); -} break; -case 22 : -case 54 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 23 : -case 55 : -{ - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P0 = I31(4, 3); - P1 = IC(4); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 24 : -case 66 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 25 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 26 : -case 31 : -case 95 : -{ - P2 = I31(4, 6); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 27 : -case 75 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 28 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 29 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 30 : -case 86 : -{ - P0 = I31(4, 0); - P2 = I31(4, 6); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 40 : -case 44 : -case 168 : -case 172 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); -} break; -case 41 : -case 45 : -case 169 : -case 173 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); -} break; -case 42 : -case 170 : -{ - P1 = I31(4, 2); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 43 : -case 171 : -{ - P1 = I31(4, 2); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 46 : -case 174 : -{ - P1 = I31(4, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 47 : -case 175 : -{ - P1 = I31(4, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 56 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 57 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 58 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 59 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 60 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 61 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 62 : -{ - P0 = I31(4, 0); - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 63 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 64 : -case 65 : -case 68 : -case 69 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 67 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 70 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 71 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 72 : -case 76 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 73 : -case 77 : -{ - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P0 = I31(4, 1); - P2 = I31(4, 6); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 74 : -case 107 : -case 123 : -{ - P1 = I31(4, 2); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 78 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 79 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 80 : -case 81 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 82 : -case 214 : -case 222 : -{ - P0 = I31(4, 0); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 83 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 84 : -case 85 : -{ - P0 = I211(4, 1, 3); - P2 = I31(4, 6); - if (MDR) { - P1 = I31(4, 1); - P3 = I31(4, 8); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 87 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 88 : -case 248 : -case 250 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 89 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 90 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 91 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 92 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 93 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 94 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 96 : -case 97 : -case 100 : -case 101 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 98 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 99 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 102 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 103 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 104 : -case 108 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 105 : -case 109 : -{ - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P0 = I31(4, 1); - P2 = IC(4); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 106 : -case 120 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 110 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 111 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 112 : -case 113 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - if (MDR) { - P2 = I31(4, 3); - P3 = I31(4, 8); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 114 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 115 : -{ - P0 = I31(4, 3); - P2 = I31(4, 3); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 116 : -case 117 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I31(4, 3); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 118 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 119 : -{ - P2 = I31(4, 3); - P3 = I31(4, 8); - if (MUR) { - P0 = I31(4, 3); - P1 = IC(4); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 121 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 122 : -{ - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 124 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 125 : -{ - P1 = I31(4, 1); - P3 = I31(4, 8); - if (MDL) { - P0 = I31(4, 1); - P2 = IC(4); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 126 : -{ - P0 = I31(4, 0); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 127 : -{ - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 144 : -case 145 : -case 176 : -case 177 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); -} break; -case 146 : -case 178 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - if (MUR) { - P1 = I31(4, 2); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 147 : -case 179 : -{ - P0 = I31(4, 3); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 148 : -case 149 : -case 180 : -case 181 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); -} break; -case 150 : -case 182 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - if (MUR) { - P1 = IC(4); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 151 : -case 183 : -{ - P0 = I31(4, 3); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 152 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 153 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 154 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 155 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 156 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 157 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 158 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 159 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 184 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 185 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 186 : -{ - P2 = I31(4, 7); - P3 = I31(4, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 187 : -{ - P1 = I31(4, 2); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 188 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 189 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 190 : -{ - P0 = I31(4, 0); - P2 = I31(4, 7); - if (MUR) { - P1 = IC(4); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 191 : -{ - P2 = I31(4, 7); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 192 : -case 193 : -case 196 : -case 197 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 194 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 195 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 198 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 199 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 200 : -case 204 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - if (MDL) { - P2 = I31(4, 6); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 201 : -case 205 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } -} break; -case 202 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 203 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 206 : -{ - P1 = I31(4, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 207 : -{ - P2 = I31(4, 6); - P3 = I31(4, 5); - if (MUL) { - P0 = IC(4); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 208 : -case 209 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 210 : -case 216 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 211 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 212 : -case 213 : -{ - P0 = I211(4, 1, 3); - P2 = I31(4, 6); - if (MDR) { - P1 = I31(4, 1); - P3 = IC(4); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 215 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 217 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 218 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 219 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 220 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 221 : -{ - P0 = I31(4, 1); - P2 = I31(4, 6); - if (MDR) { - P1 = I31(4, 1); - P3 = IC(4); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 223 : -{ - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 224 : -case 225 : -case 228 : -case 229 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 226 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 227 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 230 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 231 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 232 : -case 236 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - if (MDL) { - P2 = IC(4); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 233 : -case 237 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } -} break; -case 234 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 235 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 238 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - if (MDL) { - P2 = IC(4); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 239 : -{ - P1 = I31(4, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 240 : -case 241 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - if (MDR) { - P2 = I31(4, 3); - P3 = IC(4); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 242 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 243 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - if (MDR) { - P2 = I31(4, 3); - P3 = IC(4); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 244 : -case 245 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 246 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 247 : -{ - P0 = I31(4, 3); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 249 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 251 : -{ - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 252 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 253 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 254 : -{ - P0 = I31(4, 0); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 255 : -{ - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; diff --git a/src/sdl12/filter/interp.h b/src/sdl12/filter/interp.h deleted file mode 100644 index e994387fb..000000000 --- a/src/sdl12/filter/interp.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * This file is part of the Advance project. - * - * Copyright (C) 2003 Andrea Mazzoleni - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * In addition, as a special exception, Andrea Mazzoleni - * gives permission to link the code of this program with - * the MAME library (or with modified versions of MAME that use the - * same license as MAME), and distribute linked combinations including - * the two. You must obey the GNU General Public License in all - * respects for all of the code used other than MAME. If you modify - * this file, you may extend this exception to your version of the - * file, but you are not obligated to do so. If you do not wish to - * do so, delete this exception statement from your version. - */ - -#ifndef __INTERP_H -#define __INTERP_H - -/***************************************************************************/ -/* Basic types */ - -/***************************************************************************/ -/* interpolation */ - -static Uint32 interp_mask[2] = {0xF81F,0x07E0}; -static Uint32 interp_bits_per_pixel = 16; - -#define INTERP_16_MASK_1(v) (v & interp_mask[0]) -#define INTERP_16_MASK_2(v) (v & interp_mask[1]) - -FUNCINLINE static ATTRINLINE Uint16 interp_16_521(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_332(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_611(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8)); -} - -/* -FUNCINLINE static ATTRINLINE Uint16 interp_16_71(Uint16 p1, Uint16 p2) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8)); -} -*/ - -FUNCINLINE static ATTRINLINE Uint16 interp_16_211(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4)); -} - -/* -FUNCINLINE static ATTRINLINE Uint16 interp_16_772(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16) - | INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_11(Uint16 p1, Uint16 p2) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2)); -} -*/ - -FUNCINLINE static ATTRINLINE Uint16 interp_16_31(Uint16 p1, Uint16 p2) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_1411(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16)); -} - -/* -FUNCINLINE static ATTRINLINE Uint16 interp_16_431(Uint16 p1, Uint16 p2, Uint16 p3) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_53(Uint16 p1, Uint16 p2) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_151(Uint16 p1, Uint16 p2) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16)); -} - -FUNCINLINE static ATTRINLINE Uint16 interp_16_97(Uint16 p1, Uint16 p2) -{ - return (Uint16)(INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16)); -} -*/ - -#define INTERP_32_MASK_1(v) (v & 0xFF00FF) -#define INTERP_32_MASK_2(v) (v & 0x00FF00) - -FUNCINLINE static ATTRINLINE Uint32 interp_32_521(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_332(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_211(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_611(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8); -} - -/* -FUNCINLINE static ATTRINLINE Uint32 interp_32_71(Uint32 p1, Uint32 p2) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_772(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16) - | INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_11(Uint32 p1, Uint32 p2) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2); -} -*/ - -FUNCINLINE static ATTRINLINE Uint32 interp_32_31(Uint32 p1, Uint32 p2) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_1411(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16); -} - -/* -FUNCINLINE static ATTRINLINE Uint32 interp_32_431(Uint32 p1, Uint32 p2, Uint32 p3) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_53(Uint32 p1, Uint32 p2) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_151(Uint32 p1, Uint32 p2) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16); -} - -FUNCINLINE static ATTRINLINE Uint32 interp_32_97(Uint32 p1, Uint32 p2) -{ - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16); -} -*/ - -/***************************************************************************/ -/* diff */ - -#define INTERP_Y_LIMIT (0x30*4) -#define INTERP_U_LIMIT (0x07*4) -#define INTERP_V_LIMIT (0x06*8) - -static int interp_16_diff(Uint16 p1, Uint16 p2) -{ - int r, g, b; - int y, u, v; - - if (p1 == p2) - return 0; - - if (interp_bits_per_pixel == 16) { - b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; - g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3; - r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8; - } else { - b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; - g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2; - r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7; - } - - y = r + g + b; - u = r - b; - v = -r + 2*g - b; - - if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) - return 1; - - if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) - return 1; - - if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) - return 1; - - return 0; -} - -static int interp_32_diff(Uint32 p1, Uint32 p2) -{ - int r, g, b; - int y, u, v; - - if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8)) - return 0; - - b = (int)((p1 & 0xFF) - (p2 & 0xFF)); - g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8; - r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16; - - y = r + g + b; - u = r - b; - v = -r + 2*g - b; - - if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) - return 1; - - if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) - return 1; - - if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) - return 1; - - return 0; -} - -/* -static void interp_set(Uint32 bits_per_pixel) -{ - interp_bits_per_pixel = bits_per_pixel; - - switch (bits_per_pixel) { - case 15 : - interp_mask[0] = 0x7C1F; - interp_mask[1] = 0x03E0; - break; - case 16 : - interp_mask[0] = 0xF81F; - interp_mask[1] = 0x07E0; - break; - case 32 : - interp_mask[0] = 0xFF00FF; - interp_mask[1] = 0x00FF00; - break; - } -} -*/ - -#endif diff --git a/src/sdl12/filter/lq2x.c b/src/sdl12/filter/lq2x.c deleted file mode 100644 index 8d06fa8cc..000000000 --- a/src/sdl12/filter/lq2x.c +++ /dev/null @@ -1,564 +0,0 @@ -#include "filters.h" -#include "interp.h" - -static void hq2x_16_def(Uint16* dst0, Uint16* dst1, const Uint16* src0, const Uint16* src1, const Uint16* src2, Uint32 count) -{ - Uint32 i; - - for(i=0;i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } - - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } - - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } - - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } - - if (i> 1); - - Uint16 *src0 = (Uint16 *)srcPtr; - Uint16 *src1 = src0 + (srcPitch >> 1); - Uint16 *src2 = src1 + (srcPitch >> 1); - int count = height-2; - - hq2x_16_def(dst0, dst1, src0, src0, src1, width); - - while(count) { - dst0 += dstPitch; - dst1 += dstPitch; - hq2x_16_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 1; - --count; - } - dst0 += dstPitch; - dst1 += dstPitch; - hq2x_16_def(dst0, dst1, src0, src1, src1, width); -} - -void hq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, - Uint32 dstPitch, int width, int height) -{ - Uint32 *dst0 = (Uint32 *)dstPtr; - Uint32 *dst1 = dst0 + (dstPitch >> 2); - - Uint32 *src0 = (Uint32 *)srcPtr; - Uint32 *src1 = src0 + (srcPitch >> 2); - Uint32 *src2 = src1 + (srcPitch >> 2); - int count = height-2; - - hq2x_32_def(dst0, dst1, src0, src0, src1, width); - - while(count) { - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - hq2x_32_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 2; - --count; - } - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - hq2x_32_def(dst0, dst1, src0, src1, src1, width); -} - -void lq2x16(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, - Uint32 dstPitch, int width, int height) -{ - Uint16 *dst0 = (Uint16 *)dstPtr; - Uint16 *dst1 = dst0 + (dstPitch >> 1); - - Uint16 *src0 = (Uint16 *)srcPtr; - Uint16 *src1 = src0 + (srcPitch >> 1); - Uint16 *src2 = src1 + (srcPitch >> 1); - int count = height-2; - - lq2x_16_def(dst0, dst1, src0, src0, src1, width); - - while(count) { - dst0 += dstPitch; - dst1 += dstPitch; - lq2x_16_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 1; - --count; - } - dst0 += dstPitch; - dst1 += dstPitch; - lq2x_16_def(dst0, dst1, src0, src1, src1, width); -} - -void lq2x32(Uint8 *srcPtr, Uint32 srcPitch, Uint8 *dstPtr, - Uint32 dstPitch, int width, int height) -{ - Uint32 *dst0 = (Uint32 *)dstPtr; - Uint32 *dst1 = dst0 + (dstPitch >> 2); - - Uint32 *src0 = (Uint32 *)srcPtr; - Uint32 *src1 = src0 + (srcPitch >> 2); - Uint32 *src2 = src1 + (srcPitch >> 2); - int count = height-2; - - lq2x_32_def(dst0, dst1, src0, src0, src1, width); - - while(count) { - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - lq2x_32_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 2; - --count; - } - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - lq2x_32_def(dst0, dst1, src0, src1, src1, width); -} - -/* -static inline void hq2x_init(Uint32 bits_per_pixel) -{ - interp_set(bits_per_pixel); -} -*/ diff --git a/src/sdl12/filter/lq2x.h b/src/sdl12/filter/lq2x.h deleted file mode 100644 index 094c2b5ae..000000000 --- a/src/sdl12/filter/lq2x.h +++ /dev/null @@ -1,1284 +0,0 @@ -case 0 : -case 2 : -case 4 : -case 6 : -case 8 : -case 12 : -case 16 : -case 20 : -case 24 : -case 28 : -case 32 : -case 34 : -case 36 : -case 38 : -case 40 : -case 44 : -case 48 : -case 52 : -case 56 : -case 60 : -case 64 : -case 66 : -case 68 : -case 70 : -case 96 : -case 98 : -case 100 : -case 102 : -case 128 : -case 130 : -case 132 : -case 134 : -case 136 : -case 140 : -case 144 : -case 148 : -case 152 : -case 156 : -case 160 : -case 162 : -case 164 : -case 166 : -case 168 : -case 172 : -case 176 : -case 180 : -case 184 : -case 188 : -case 192 : -case 194 : -case 196 : -case 198 : -case 224 : -case 226 : -case 228 : -case 230 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); -} break; -case 1 : -case 5 : -case 9 : -case 13 : -case 17 : -case 21 : -case 25 : -case 29 : -case 33 : -case 37 : -case 41 : -case 45 : -case 49 : -case 53 : -case 57 : -case 61 : -case 65 : -case 69 : -case 97 : -case 101 : -case 129 : -case 133 : -case 137 : -case 141 : -case 145 : -case 149 : -case 153 : -case 157 : -case 161 : -case 165 : -case 169 : -case 173 : -case 177 : -case 181 : -case 185 : -case 189 : -case 193 : -case 197 : -case 225 : -case 229 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - P3 = IC(1); -} break; -case 3 : -case 35 : -case 67 : -case 99 : -case 131 : -case 163 : -case 195 : -case 227 : -{ - P0 = IC(2); - P1 = IC(2); - P2 = IC(2); - P3 = IC(2); -} break; -case 7 : -case 39 : -case 71 : -case 103 : -case 135 : -case 167 : -case 199 : -case 231 : -{ - P0 = IC(3); - P1 = IC(3); - P2 = IC(3); - P3 = IC(3); -} break; -case 10 : -case 138 : -{ - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } -} break; -case 11 : -case 27 : -case 75 : -case 139 : -case 155 : -case 203 : -{ - P1 = IC(2); - P2 = IC(2); - P3 = IC(2); - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 14 : -case 142 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - P1 = IC(0); - } else { - P0 = I332(1, 3, 0); - P1 = I31(0, 1); - } -} break; -case 15 : -case 143 : -case 207 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - P1 = IC(4); - } else { - P0 = I332(1, 3, 4); - P1 = I31(4, 1); - } -} break; -case 18 : -case 22 : -case 30 : -case 50 : -case 54 : -case 62 : -case 86 : -case 118 : -{ - P0 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 19 : -case 51 : -{ - P2 = IC(2); - P3 = IC(2); - if (MUR) { - P0 = IC(2); - P1 = IC(2); - } else { - P0 = I31(2, 1); - P1 = I332(1, 5, 2); - } -} break; -case 23 : -case 55 : -case 119 : -{ - P2 = IC(3); - P3 = IC(3); - if (MUR) { - P0 = IC(3); - P1 = IC(3); - } else { - P0 = I31(3, 1); - P1 = I332(1, 5, 3); - } -} break; -case 26 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 31 : -case 95 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 42 : -case 170 : -{ - P1 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - P2 = IC(0); - } else { - P0 = I332(1, 3, 0); - P2 = I31(0, 3); - } -} break; -case 43 : -case 171 : -case 187 : -{ - P1 = IC(2); - P3 = IC(2); - if (MUL) { - P0 = IC(2); - P2 = IC(2); - } else { - P0 = I332(1, 3, 2); - P2 = I31(2, 3); - } -} break; -case 46 : -case 174 : -{ - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 47 : -case 175 : -{ - P1 = IC(4); - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 58 : -case 154 : -case 186 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 59 : -{ - P2 = IC(2); - P3 = IC(2); - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 63 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 72 : -case 76 : -case 104 : -case 106 : -case 108 : -case 110 : -case 120 : -case 124 : -{ - P0 = IC(0); - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } -} break; -case 73 : -case 77 : -case 105 : -case 109 : -case 125 : -{ - P1 = IC(1); - P3 = IC(1); - if (MDL) { - P0 = IC(1); - P2 = IC(1); - } else { - P0 = I31(1, 3); - P2 = I332(3, 7, 1); - } -} break; -case 74 : -{ - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } -} break; -case 78 : -case 202 : -case 206 : -{ - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 79 : -{ - P1 = IC(4); - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 80 : -case 208 : -case 210 : -case 216 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 81 : -case 209 : -case 217 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (MDR) { - P3 = IC(1); - } else { - P3 = I211(1, 5, 7); - } -} break; -case 82 : -case 214 : -case 222 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 83 : -case 115 : -{ - P0 = IC(2); - P2 = IC(2); - if (MDR) { - P3 = IC(2); - } else { - P3 = I611(2, 5, 7); - } - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 84 : -case 212 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P1 = IC(0); - P3 = IC(0); - } else { - P1 = I31(0, 5); - P3 = I332(5, 7, 0); - } -} break; -case 85 : -case 213 : -case 221 : -{ - P0 = IC(1); - P2 = IC(1); - if (MDR) { - P1 = IC(1); - P3 = IC(1); - } else { - P1 = I31(1, 5); - P3 = I332(5, 7, 1); - } -} break; -case 87 : -{ - P0 = IC(3); - P2 = IC(3); - if (MDR) { - P3 = IC(3); - } else { - P3 = I611(3, 5, 7); - } - if (MUR) { - P1 = IC(3); - } else { - P1 = I211(3, 1, 5); - } -} break; -case 88 : -case 248 : -case 250 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 89 : -case 93 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I611(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 90 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 91 : -{ - if (MDL) { - P2 = IC(2); - } else { - P2 = I611(2, 3, 7); - } - if (MDR) { - P3 = IC(2); - } else { - P3 = I611(2, 5, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 92 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } -} break; -case 94 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 107 : -case 123 : -{ - P1 = IC(2); - P3 = IC(2); - if (MDL) { - P2 = IC(2); - } else { - P2 = I211(2, 3, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 111 : -{ - P1 = IC(4); - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 112 : -case 240 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDR) { - P2 = IC(0); - P3 = IC(0); - } else { - P2 = I31(0, 7); - P3 = I332(5, 7, 0); - } -} break; -case 113 : -case 241 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDR) { - P2 = IC(1); - P3 = IC(1); - } else { - P2 = I31(1, 7); - P3 = I332(5, 7, 1); - } -} break; -case 114 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 116 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } -} break; -case 117 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 121 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I211(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 122 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 126 : -{ - P0 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 127 : -{ - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 146 : -case 150 : -case 178 : -case 182 : -case 190 : -{ - P0 = IC(0); - P2 = IC(0); - if (MUR) { - P1 = IC(0); - P3 = IC(0); - } else { - P1 = I332(1, 5, 0); - P3 = I31(0, 5); - } -} break; -case 147 : -case 179 : -{ - P0 = IC(2); - P2 = IC(2); - P3 = IC(2); - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 151 : -case 183 : -{ - P0 = IC(3); - P2 = IC(3); - P3 = IC(3); - if (MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 158 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 159 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 191 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 200 : -case 204 : -case 232 : -case 236 : -case 238 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - P3 = IC(0); - } else { - P2 = I332(3, 7, 0); - P3 = I31(0, 7); - } -} break; -case 201 : -case 205 : -{ - P0 = IC(1); - P1 = IC(1); - P3 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I611(1, 3, 7); - } -} break; -case 211 : -{ - P0 = IC(2); - P1 = IC(2); - P2 = IC(2); - if (MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } -} break; -case 215 : -{ - P0 = IC(3); - P2 = IC(3); - if (MDR) { - P3 = IC(3); - } else { - P3 = I211(3, 5, 7); - } - if (MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 218 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 219 : -{ - P1 = IC(2); - P2 = IC(2); - if (MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 220 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 223 : -{ - P2 = IC(4); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 233 : -case 237 : -{ - P0 = IC(1); - P1 = IC(1); - P3 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } -} break; -case 234 : -{ - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 235 : -{ - P1 = IC(2); - P3 = IC(2); - if (MDL) { - P2 = IC(2); - } else { - P2 = I1411(2, 3, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 239 : -{ - P1 = IC(4); - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 242 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 243 : -{ - P0 = IC(2); - P1 = IC(2); - if (MDR) { - P2 = IC(2); - P3 = IC(2); - } else { - P2 = I31(2, 7); - P3 = I332(5, 7, 2); - } -} break; -case 244 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } -} break; -case 245 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (MDR) { - P3 = IC(1); - } else { - P3 = I1411(1, 5, 7); - } -} break; -case 246 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 247 : -{ - P0 = IC(3); - P2 = IC(3); - if (MDR) { - P3 = IC(3); - } else { - P3 = I1411(3, 5, 7); - } - if (MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 249 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I211(1, 5, 7); - } -} break; -case 251 : -{ - P1 = IC(2); - if (MDL) { - P2 = IC(2); - } else { - P2 = I1411(2, 3, 7); - } - if (MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 252 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } -} break; -case 253 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I1411(1, 5, 7); - } -} break; -case 254 : -{ - P0 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 255 : -{ - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; diff --git a/src/sdl12/filter/main.c b/src/sdl12/filter/main.c deleted file mode 100644 index 98ab1541c..000000000 --- a/src/sdl12/filter/main.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "filters.h" - -int main(int argc, char *argv[]) -{ - SDL_Surface *src = NULL; - SDL_Surface *dst = NULL; - src = SDL_LoadBMP("src.bmp"); //load - if(!src) return -1; //check - dst = filter_2x(src, NULL, hq2x32); //prcoess - SDL_FreeSurface(src); //free - if(!dst) return 0; //error - SDL_SaveBMP(dst, "dst.bmp"); //save - SDL_FreeSurface(dst); //free - return 1; //good -} diff --git a/src/sdl12/hwsym_sdl.c b/src/sdl12/hwsym_sdl.c deleted file mode 100644 index 49340138f..000000000 --- a/src/sdl12/hwsym_sdl.c +++ /dev/null @@ -1,186 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -/// \file -/// \brief Tool for dynamic referencing of hardware rendering functions -/// -/// Declaration and definition of the HW rendering -/// functions do have the same name. Originally, the -/// implementation was stored in a separate library. -/// For SDL, we need some function to return the addresses, -/// otherwise we have a conflict with the compiler. - -#include "hwsym_sdl.h" -#include "../doomdef.h" - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - -#ifdef HAVE_SDL - -#include "SDL.h" - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#if defined (_XBOX) || defined (_arch_dreamcast) || defined(GP2X) -#define NOLOADSO -#endif - -#if SDL_VERSION_ATLEAST(1,2,6) && !defined (NOLOADSO) -#include "SDL_loadso.h" // 1.2.6+ -#elif !defined (NOLOADSO) -#define NOLOADSO -#endif - -#define _CREATE_DLL_ // necessary for Unix AND Windows - -#ifdef HWRENDER -#include "../hardware/hw_drv.h" -#include "ogl_sdl.h" -#ifdef STATIC_OPENGL -#include "../hardware/r_opengl/r_opengl.h" -#endif -#endif - -#ifdef HW3SOUND -#include "../hardware/hw3dsdrv.h" -#endif - -#define GETFUNC(func) \ - else if (0 == strcmp(#func, funcName)) \ - funcPointer = &func \ -// -// -/** \brief The *hwSym function - - Stupid function to return function addresses - - \param funcName the name of the function - \param handle an object to look in(NULL for self) - - \return void -*/ -// -void *hwSym(const char *funcName,void *handle) -{ - void *funcPointer = NULL; -#ifdef HWRENDER - if (0 == strcmp("SetPalette", funcName)) - funcPointer = &OglSdlSetPalette; - GETFUNC(Init); - GETFUNC(Draw2DLine); - GETFUNC(DrawPolygon); - GETFUNC(SetBlend); - GETFUNC(ClearBuffer); - GETFUNC(SetTexture); - GETFUNC(ReadRect); - GETFUNC(GClipRect); - GETFUNC(ClearMipMapCache); - GETFUNC(SetSpecialState); - GETFUNC(GetTextureUsed); - GETFUNC(DrawMD2); - GETFUNC(DrawMD2i); - GETFUNC(SetTransform); - GETFUNC(GetRenderVersion); -#ifdef SHUFFLE - GETFUNC(PostImgRedraw); -#endif //SHUFFLE - GETFUNC(FlushScreenTextures); - GETFUNC(StartScreenWipe); - GETFUNC(EndScreenWipe); - GETFUNC(DoScreenWipe); - GETFUNC(DrawIntermissionBG); - GETFUNC(MakeScreenTexture); - GETFUNC(MakeScreenFinalTexture); - GETFUNC(DrawScreenFinalTexture); -#else //HWRENDER - if (0 == strcmp("FinishUpdate", funcName)) - return funcPointer; //&FinishUpdate; -#endif //!HWRENDER -#ifdef STATIC3DS - GETFUNC(Startup); - GETFUNC(AddSfx); - GETFUNC(AddSource); - GETFUNC(StartSource); - GETFUNC(StopSource); - GETFUNC(GetHW3DSVersion); - GETFUNC(BeginFrameUpdate); - GETFUNC(EndFrameUpdate); - GETFUNC(IsPlaying); - GETFUNC(UpdateListener); - GETFUNC(UpdateSourceParms); - GETFUNC(SetGlobalSfxVolume); - GETFUNC(SetCone); - GETFUNC(Update3DSource); - GETFUNC(ReloadSource); - GETFUNC(KillSource); - GETFUNC(Shutdown); - GETFUNC(GetHW3DSTitle); -#endif -#ifdef NOLOADSO - else - funcPointer = handle; -#else - else if (handle) - funcPointer = SDL_LoadFunction(handle,funcName); -#endif - if (!funcPointer) - I_OutputMsg("hwSym for %s: %s\n", funcName, SDL_GetError()); - return funcPointer; -} - -/** \brief The *hwOpen function - - \param hwfile Open a handle to the SO - - \return Handle to SO - - -*/ - -void *hwOpen(const char *hwfile) -{ -#ifdef NOLOADSO - (void)hwfile; - return NULL; -#else - void *tempso = NULL; - tempso = SDL_LoadObject(hwfile); - if (!tempso) I_OutputMsg("hwOpen of %s: %s\n", hwfile, SDL_GetError()); - return tempso; -#endif -} - -/** \brief The hwClose function - - \param handle Close the handle of the SO - - \return void - - -*/ - -void hwClose(void *handle) -{ -#ifdef NOLOADSO - (void)handle; -#else - SDL_UnloadObject(handle); -#endif -} -#endif diff --git a/src/sdl12/hwsym_sdl.h b/src/sdl12/hwsym_sdl.h deleted file mode 100644 index 7297587bf..000000000 --- a/src/sdl12/hwsym_sdl.h +++ /dev/null @@ -1,23 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Tool for dynamic referencing of hardware rendering/3D sound functions - -void *hwSym(const char *funcName,void *handle); - -void *hwOpen(const char *hwfile); - -void hwClose(void *handle); diff --git a/src/sdl12/i_cdmus.c b/src/sdl12/i_cdmus.c deleted file mode 100644 index b3490592e..000000000 --- a/src/sdl12/i_cdmus.c +++ /dev/null @@ -1,588 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief cd music interface -/// - -#ifdef HAVE_SDL - -#if defined (DC) || defined (_WIN32_WCE) || defined(GP2X) || defined(_PS3) -#define NOSDLCD -#endif - -#include -#ifndef NOSDLCD - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - -#include "SDL.h" - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#endif - -#include "../doomtype.h" -#include "../i_sound.h" -#include "../command.h" -#include "../m_argv.h" -#include "../s_sound.h" - -#define MAX_CD_TRACKS 256 - -#ifdef _XBOX -INT32 SDL_SYS_CDInit(void) -{ - return(0); -} - -void SDL_SYS_CDQuit(void) -{ - return; -} -#endif - -UINT8 cdaudio_started = 0; // for system startup/shutdown - -consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; - -#ifndef NOSDLCD -static SDL_bool cdValid = SDL_FALSE; -static SDL_bool cdPlaying = SDL_FALSE; -static SDL_bool wasPlaying = SDL_FALSE; -static SDL_bool cdEnabled = SDL_FALSE; -static SDL_bool playLooping = SDL_FALSE; -static Uint8 playTrack = 0; -static Uint8 maxTrack = MAX_CD_TRACKS-1; -static Uint8 cdRemap[MAX_CD_TRACKS]; -static INT32 cdvolume = -1; -static SDL_CD *cdrom = NULL; -static CDstatus cdStatus = CD_ERROR; - -/************************************************************************** - * - * function: CDAudio_GetAudioDiskInfo - * - * description: - * set number of tracks if CD is available - * - **************************************************************************/ -static INT32 CDAudio_GetAudioDiskInfo(void) -{ - cdValid = SDL_FALSE; - maxTrack = 0; - - if (!cdrom) - return 0;//Alam: Lies! - - cdStatus = SDL_CDStatus(cdrom); - - if (!CD_INDRIVE(cdStatus)) - { - CONS_Printf("%s", M_GetText("No CD in drive\n")); - return -1; - } - - if (cdStatus == CD_ERROR) - { - CONS_Printf(M_GetText("CD Error: %s\n"), SDL_GetError()); - return -1; - } - - cdValid = SDL_TRUE; - maxTrack = (Uint8)cdrom->numtracks; - - return 0; -} - - -/************************************************************************** - * - * function: I_EjectCD - * - * description: - * - * - **************************************************************************/ -static void I_EjectCD(void) -{ - if (!cdrom || !cdEnabled) - return; // no cd init'd - - I_StopCD(); - - if (SDL_CDEject(cdrom)) - CONS_Printf("%s", M_GetText("CD eject failed\n")); -} - -/************************************************************************** - * - * function: Command_Cd_f - * - * description: - * handles all CD commands from the console - * - **************************************************************************/ -static void Command_Cd_f (void) -{ - const char *command; - size_t ret, n; - - if (!cdaudio_started) - return; - - if (COM_Argc() < 2) - { - CONS_Printf ("%s", M_GetText("cd [on] [off] [remap] [reset] [select]\n" - " [open] [info] [play ] [resume]\n" - " [stop] [pause] [loop ]\n")); - return; - } - - command = COM_Argv (1); - - if (!strncmp(command, "on", 2)) - { - cdEnabled = SDL_TRUE; - return; - } - - if (!strncmp(command, "off", 3)) - { - I_StopCD(); - cdEnabled = SDL_FALSE; - return; - } - - if (!strncmp(command, "select", 6)) - { - INT32 newcddrive; - newcddrive = atoi(COM_Argv(2)); - command = SDL_CDName(newcddrive); - I_StopCD(); - cdEnabled = SDL_FALSE; - SDL_CDClose(cdrom); - cdrom = SDL_CDOpen(newcddrive); - if (cdrom) - { - cdEnabled = SDL_TRUE; - CONS_Printf(M_GetText("Opened CD-ROM drive %s\n"), command ? command : COM_Argv(2)); - } - else CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), command ? command : COM_Argv(2), SDL_GetError()); - return; - } - - if (!strncmp(command, "remap", 5)) - { - ret = COM_Argc() - 2; - if (ret <= 0) - { - for (n = 1; n < MAX_CD_TRACKS; n++) - { - if (cdRemap[n] != n) - CONS_Printf(" %s -> %u\n", sizeu1(n), cdRemap[n]); - } - return; - } - for (n = 1; n <= ret; n++) - cdRemap[n] = (Uint8)atoi(COM_Argv (n+1)); - return; - } - - if (!strncmp(command, "reset", 5)) - { - if (!cdrom) return; - cdEnabled = SDL_TRUE; - I_StopCD(); - for (n = 0; n < MAX_CD_TRACKS; n++) - cdRemap[n] = (Uint8)n; - CDAudio_GetAudioDiskInfo(); - return; - } - - if (!cdValid) - { - if (CDAudio_GetAudioDiskInfo()==-1 && !cdValid) - { - CONS_Printf("%s", M_GetText("No CD in drive\n")); - return; - } - } - - if (!strncmp(command, "open", 4)) - { - I_EjectCD(); - cdValid = SDL_FALSE; - return; - } - - if (!strncmp(command, "info", 4)) - { - CONS_Printf(M_GetText("%u tracks\n"), maxTrack); - if (cdPlaying) - CONS_Printf(M_GetText("Currently %s track %u\n"), playLooping ? M_GetText("looping") : M_GetText("playing"), playTrack); - else if (wasPlaying) - CONS_Printf(M_GetText("Paused %s track %u\n"), playLooping ? M_GetText("looping") : M_GetText("playing"), playTrack); - CONS_Printf(M_GetText("Volume is %d\n"), cdvolume); - return; - } - - if (!strncmp(command, "play", 4)) - { - I_PlayCD((UINT8)atoi(COM_Argv (2)), SDL_FALSE); - return; - } - - if (!strncmp(command, "loop", 4)) - { - I_PlayCD((UINT8)atoi(COM_Argv (2)), true); - return; - } - - if (!strncmp(command, "stop", 4)) - { - I_StopCD(); - return; - } - if (!strncmp(command, "pause", 5)) - { - I_PauseCD(); - return; - } - - if (!strncmp(command, "resume", 6)) - { - I_ResumeCD(); - return; - } - - CONS_Printf(M_GetText("Invalid CD command \"CD %s\"\n"), COM_Argv(1)); -} -#endif - -/************************************************************************** - * - * function: StopCD - * - * description: - * - * - **************************************************************************/ -void I_StopCD(void) -{ -#ifndef NOSDLCD - if (!cdrom || !cdEnabled) - return; - - if (!(cdPlaying || wasPlaying)) - return; - - if (SDL_CDStop(cdrom)) - I_OutputMsg("cdromstop failed\n"); - - wasPlaying = SDL_FALSE; - cdPlaying = SDL_FALSE; -#endif -} - -/************************************************************************** - * - * function: PauseCD - * - * description: - * - * - **************************************************************************/ -void I_PauseCD (void) -{ -#ifndef NOSDLCD - if (!cdrom || !cdEnabled) - return; - - if (!cdPlaying) - return; - - if (SDL_CDPause(cdrom)) - I_OutputMsg("cdrompause failed\n"); - - wasPlaying = cdPlaying; - cdPlaying = SDL_FALSE; -#endif -} - -/************************************************************************** - * - * function: ResumeCD - * - * description: - * - * - **************************************************************************/ -// continue after a pause -void I_ResumeCD (void) -{ -#ifndef NOSDLCD - if (!cdrom || !cdEnabled) - return; - - if (!cdValid) - return; - - if (!wasPlaying) - return; - - if (cd_volume.value == 0) - return; - - if (SDL_CDResume(cdrom)) - I_OutputMsg("cdromresume failed\n"); - - cdPlaying = SDL_TRUE; - wasPlaying = SDL_FALSE; -#endif -} - - -/************************************************************************** - * - * function: ShutdownCD - * - * description: - * - * - **************************************************************************/ -void I_ShutdownCD (void) -{ -#ifndef NOSDLCD - if (!cdaudio_started) - return; - - I_StopCD(); - - CONS_Printf("I_ShutdownCD: "); - SDL_CDClose(cdrom); - cdrom = NULL; - cdaudio_started = false; - CONS_Printf("%s", M_GetText("shut down\n")); - SDL_QuitSubSystem(SDL_INIT_CDROM); - cdEnabled = SDL_FALSE; -#endif -} - -/************************************************************************** - * - * function: InitCD - * - * description: - * Initialize the first CD drive SDL detects and add console command 'cd' - * - **************************************************************************/ -void I_InitCD (void) -{ -#ifndef NOSDLCD - INT32 i; - - // Has been checked in d_main.c, but doesn't hurt here - if (M_CheckParm ("-nocd")) - return; - - CONS_Printf("%s", M_GetText("I_InitCD: Init CD audio\n")); - - // Initialize SDL first - if (SDL_InitSubSystem(SDL_INIT_CDROM) < 0) - { - CONS_Printf(M_GetText("Couldn't initialize SDL CDROM: %s\n"), SDL_GetError()); - return; - } - - // Open drive - cdrom = SDL_CDOpen(0); - - if (!cdrom) - { - const char *cdName = SDL_CDName(0); - if (!cdName) - CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), "\b", SDL_GetError()); - else - CONS_Printf(M_GetText("Couldn't open CD-ROM drive %s: %s\n"), cdName, SDL_GetError()); - //return; - } - - for (i = 0; i < MAX_CD_TRACKS; i++) - cdRemap[i] = (Uint8)i; - - cdaudio_started = true; - if (cdrom) cdEnabled = SDL_TRUE; - - if (CDAudio_GetAudioDiskInfo()==-1) - { - CONS_Printf("%s", M_GetText("No CD in drive\n")); - cdValid = SDL_FALSE; - } - - COM_AddCommand ("cd", Command_Cd_f); - - CONS_Printf("%s", M_GetText("CD audio Initialized\n")); -#endif -} - - - -// -/************************************************************************** - * - * function: UpdateCD - * - * description: - * sets CD volume (may have changed) and initiates play evey 2 seconds - * in case the song has elapsed - * - **************************************************************************/ -void I_UpdateCD (void) -{ -#ifndef NOSDLCD - static Uint32 lastchk = 0; - - if (!cdEnabled || !cdrom) - return; - - I_SetVolumeCD(cd_volume.value); - - if (cdPlaying && lastchk < SDL_GetTicks()) - { - lastchk = SDL_GetTicks() + 2000; //two seconds between chks - - if (CDAudio_GetAudioDiskInfo()==-1) - { - cdPlaying = SDL_FALSE; - return; - } - - if (cdStatus != CD_PLAYING && cdStatus != CD_PAUSED) - { - cdPlaying = SDL_FALSE; - if (playLooping) - I_PlayCD(playTrack, true); - } - } -#endif -} - - - -/************************************************************************** - * - * function: PlayCD - * - * description: - * play the requested track and set the looping flag - * pauses the CD if volume is 0 - * - **************************************************************************/ - -void I_PlayCD (UINT8 track, UINT8 looping) -{ -#ifdef NOSDLCD - (void)track; - (void)looping; -#else - if (!cdrom || !cdEnabled) - return; - - if (!cdValid) - { - CDAudio_GetAudioDiskInfo(); - if (!cdValid) - return; - } - - track = cdRemap[track]; - - if (track < 1 || track > maxTrack) - { - CONS_Printf(M_GetText("Bad track number %u.\n"), track); - return; - } - - // don't try to play a non-audio track - if (cdrom->track[track].type == SDL_DATA_TRACK) - { - CONS_Printf(M_GetText("Track %u is not audio\n"), track); - return; - } - - if (cdPlaying) - { - if (playTrack == track) - return; - I_StopCD(); - } - - if (SDL_CDPlayTracks(cdrom, track, 0, 1, 0)) - { - CONS_Printf(M_GetText("Error playing track %d: %s\n"), track, SDL_GetError()); - return; - } - - playLooping = looping; - playTrack = (Uint8)track; - cdPlaying = SDL_TRUE; - - if (cd_volume.value == 0) - I_PauseCD(); -#endif -} - - -/************************************************************************** - * - * function: SetVolumeCD - * - * description: - * SDL does not support setting the CD volume - * use pause instead and toggle between full and no music - * - **************************************************************************/ - -boolean I_SetVolumeCD (INT32 volume) -{ -#ifdef NOSDLCD - (void)volume; -#else - if (volume != cdvolume) - { - if (volume > 0 && volume < 16) - { - CV_SetValue(&cd_volume, 31); - cdvolume = 31; - I_ResumeCD(); - } - else if (volume > 15 && volume < 31) - { - CV_SetValue(&cd_volume, 0); - cdvolume = 0; - I_PauseCD(); - } - } -#endif - return false; -} - -#endif diff --git a/src/sdl12/i_main.c b/src/sdl12/i_main.c deleted file mode 100644 index 1c438e083..000000000 --- a/src/sdl12/i_main.c +++ /dev/null @@ -1,247 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Main program, simply calls D_SRB2Main and D_SRB2Loop, the high level loop. - -#include "../doomdef.h" -#include "../m_argv.h" -#include "../d_main.h" -#include "../i_system.h" - -#ifdef __GNUC__ -#include -#endif - -#ifdef _WII -#include -#include -#include -#ifdef REMOTE_DEBUGGING -#include -#endif -static char wiicwd[PATH_MAX] = "sd:/"; -static char localip[16] = {0}; -static char gateway[16] = {0}; -static char netmask[16] = {0}; -#endif - -#ifdef _PSP -#include -#include -PSP_HEAP_SIZE_KB(24*1024); -PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER | PSP_THREAD_ATTR_VFPU); -PSP_MAIN_THREAD_NAME("SRB2"); -PSP_MAIN_THREAD_STACK_SIZE_KB(256); -#endif - -#ifdef HAVE_SDL - -#ifdef HAVE_TTF -#include "SDL.h" -#include "i_ttf.h" -#endif - -#ifdef SDLMAIN -#include "SDL_main.h" -#elif defined(FORCESDLMAIN) -extern int SDL_main(int argc, char *argv[]); -#endif - -#ifdef LOGMESSAGES -FILE *logstream = NULL; -#endif - -#ifndef DOXYGEN -#ifndef O_TEXT -#define O_TEXT 0 -#endif - -#ifndef O_SEQUENTIAL -#define O_SEQUENTIAL 0 -#endif -#endif - -#if defined (_WIN32) && !defined (_XBOX) -#include "../win32/win_dbg.h" -typedef BOOL (WINAPI *p_IsDebuggerPresent)(VOID); -#endif - -#ifdef _arch_dreamcast -#include -KOS_INIT_FLAGS(INIT_DEFAULT -//| INIT_NET -//| INIT_MALLOCSTATS -//| INIT_QUIET -//| INIT_OCRAM -//| INIT_NO_DCLOAD -); -#endif - -#if defined (_WIN32) && !defined (_XBOX) && !defined (_WIN32_WCE) -static inline VOID MakeCodeWritable(VOID) -{ -#ifdef USEASM // Disable write-protection of code segment - DWORD OldRights; - const DWORD NewRights = PAGE_EXECUTE_READWRITE; - PBYTE pBaseOfImage = (PBYTE)GetModuleHandle(NULL); - PIMAGE_DOS_HEADER dosH =(PIMAGE_DOS_HEADER)pBaseOfImage; - PIMAGE_NT_HEADERS ntH = (PIMAGE_NT_HEADERS)(pBaseOfImage + dosH->e_lfanew); - PIMAGE_OPTIONAL_HEADER oH = (PIMAGE_OPTIONAL_HEADER) - ((PBYTE)ntH + sizeof (IMAGE_NT_SIGNATURE) + sizeof (IMAGE_FILE_HEADER)); - LPVOID pA = pBaseOfImage+oH->BaseOfCode; - SIZE_T pS = oH->SizeOfCode; -#if 1 // try to find the text section - PIMAGE_SECTION_HEADER ntS = IMAGE_FIRST_SECTION (ntH); - WORD s; - for (s = 0; s < ntH->FileHeader.NumberOfSections; s++) - { - if (memcmp (ntS[s].Name, ".text\0\0", 8) == 0) - { - pA = pBaseOfImage+ntS[s].VirtualAddress; - pS = ntS[s].Misc.VirtualSize; - break; - } - } -#endif - - if (!VirtualProtect(pA,pS,NewRights,&OldRights)) - I_Error("Could not make code writable\n"); -#endif -} -#endif - - -/** \brief The main function - - \param argc number of arg - \param *argv string table - - \return int -*/ -FUNCNORETURN -#if defined (_XBOX) && defined (__GNUC__) -void XBoxStartup() -{ - const char *logdir = NULL; - myargc = -1; - myargv = NULL; -#else -#ifdef FORCESDLMAIN -int SDL_main(int argc, char **argv) -#else -int main(int argc, char **argv) -#endif -{ - const char *logdir = NULL; - myargc = argc; - myargv = argv; /// \todo pull out path to exe from this string -#endif - -#ifdef HAVE_TTF -#ifdef _PS3 - // apparently there is a bug in SDL_PSL1GHT which needs this to be set to work around - SDL_setenv("SDL_VIDEODRIVER", "psl1ght", 1); - I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE|SDL_DOUBLEBUF); -#elif defined(_WIN32) - I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO|SDL_INIT_AUDIO, SDL_SWSURFACE); -#else - I_StartupTTF(FONTPOINTSIZE, SDL_INIT_VIDEO, SDL_SWSURFACE); -#endif -#endif - -#ifdef _PS3 - // initialise controllers. - //ioPadInit(7); -#endif - -// init Wii-specific stuff -#ifdef _WII - // Start network - if_config(localip, netmask, gateway, TRUE); - -#ifdef REMOTE_DEBUGGING -#if REMOTE_DEBUGGING == 0 - DEBUG_Init(GDBSTUB_DEVICE_TCP, GDBSTUB_DEF_TCPPORT); // Port 2828 -#elif REMOTE_DEBUGGING > 2 - DEBUG_Init(GDBSTUB_DEVICE_TCP, REMOTE_DEBUGGING); // Custom Port -#elif REMOTE_DEBUGGING < 0 - DEBUG_Init(GDBSTUB_DEVICE_USB, GDBSTUB_DEF_CHANNEL); // Slot 1 -#else - DEBUG_Init(GDBSTUB_DEVICE_USB, REMOTE_DEBUGGING-1); // Custom Slot -#endif -#endif - // Start FAT filesystem - fatInitDefault(); - - if (getcwd(wiicwd, PATH_MAX)) - I_PutEnv(va("HOME=%ssrb2wii", wiicwd)); -#endif - - logdir = D_Home(); - -#ifdef LOGMESSAGES -#if defined(_WIN32_WCE) || defined(GP2X) - logstream = fopen(va("%s.log",argv[0]), "a"); -#elif defined (_WII) - logstream = fopen(va("%s/srb2log.txt",logdir), "a"); -#elif defined (DEFAULTDIR) - if (logdir) - logstream = fopen(va("%s/"DEFAULTDIR"/srb2log.txt",logdir), "a"); - else -#endif - logstream = fopen("./srb2log.txt", "a"); -#endif - - //I_OutputMsg("I_StartupSystem() ...\n"); - I_StartupSystem(); -#if defined (_WIN32) && !defined (_XBOX) -#ifndef _WIN32_WCE - { - p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); - if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) -#ifdef BUGTRAP - && !InitBugTrap() -#endif - ) - { - LoadLibraryA("exchndl.dll"); - } - } -#endif - prevExceptionFilter = SetUnhandledExceptionFilter(RecordExceptionInfo); -#ifndef _WIN32_WCE - MakeCodeWritable(); -#endif -#endif - // startup SRB2 - CONS_Printf("%s", M_GetText("Setting up SRB2...\n")); - D_SRB2Main(); - CONS_Printf("%s", M_GetText("Entering main game loop...\n")); - // never return - D_SRB2Loop(); - -#ifdef BUGTRAP - // This is safe even if BT didn't start. - ShutdownBugTrap(); -#endif - - // return to OS -#ifndef __GNUC__ - return 0; -#endif -} -#endif diff --git a/src/sdl12/i_net.c b/src/sdl12/i_net.c deleted file mode 100644 index ee4a34c13..000000000 --- a/src/sdl12/i_net.c +++ /dev/null @@ -1,442 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL network interface - -#include "../doomdef.h" - -#include "../i_system.h" -#include "../d_event.h" -#include "../d_net.h" -#include "../m_argv.h" - -#include "../doomstat.h" - -#include "../i_net.h" - -#include "../z_zone.h" - -#include "../i_tcp.h" - -#ifdef HAVE_SDL - -#ifdef HAVE_SDLNET - -#include "SDL_net.h" - -#define MAXBANS 20 - -static IPaddress clientaddress[MAXNETNODES+1]; -static IPaddress banned[MAXBANS]; - -static UDPpacket mypacket; -static UDPsocket mysocket = NULL; -static SDLNet_SocketSet myset = NULL; - -static size_t numbans = 0; -static boolean NET_bannednode[MAXNETNODES+1]; /// \note do we really need the +1? -static boolean init_SDLNet_driver = false; - -static const char *NET_AddrToStr(IPaddress* sk) -{ - static char s[22]; // 255.255.255.255:65535 - strcpy(s, SDLNet_ResolveIP(sk)); - if (sk->port != 0) strcat(s, va(":%d", sk->port)); - return s; -} - -static const char *NET_GetNodeAddress(INT32 node) -{ - if (!nodeconnected[node]) - return NULL; - return NET_AddrToStr(&clientaddress[node]); -} - -static const char *NET_GetBanAddress(size_t ban) -{ - if (ban > numbans) - return NULL; - return NET_AddrToStr(&banned[ban]); -} - -static boolean NET_cmpaddr(IPaddress* a, IPaddress* b) -{ - return (a->host == b->host && (b->port == 0 || a->port == b->port)); -} - -static boolean NET_CanGet(void) -{ - return myset?(SDLNet_CheckSockets(myset,0) == 1):false; -} - -static void NET_Get(void) -{ - INT32 mystatus; - INT32 newnode; - mypacket.len = MAXPACKETLENGTH; - if (!NET_CanGet()) - { - doomcom->remotenode = -1; // no packet - return; - } - mystatus = SDLNet_UDP_Recv(mysocket,&mypacket); - if (mystatus != -1) - { - if (mypacket.channel != -1) - { - doomcom->remotenode = mypacket.channel+1; // good packet from a game player - doomcom->datalength = mypacket.len; - return; - } - newnode = SDLNet_UDP_Bind(mysocket,-1,&mypacket.address); - if (newnode != -1) - { - size_t i; - newnode++; - M_Memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress)); - DEBFILE(va("New node detected: node:%d address:%s\n", newnode, - NET_GetNodeAddress(newnode))); - doomcom->remotenode = newnode; // good packet from a game player - doomcom->datalength = mypacket.len; - for (i = 0; i < numbans; i++) - { - if (NET_cmpaddr(&mypacket.address, &banned[i])) - { - DEBFILE("This dude has been banned\n"); - NET_bannednode[newnode] = true; - break; - } - } - if (i == numbans) - NET_bannednode[newnode] = false; - return; - } - else - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } - else if (mystatus == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } - - DEBFILE("New node detected: No more free slots\n"); - doomcom->remotenode = -1; // no packet -} - -#if 0 -static boolean NET_CanSend(void) -{ - return true; -} -#endif - -static void NET_Send(void) -{ - if (!doomcom->remotenode) - return; - mypacket.len = doomcom->datalength; - if (SDLNet_UDP_Send(mysocket,doomcom->remotenode-1,&mypacket) == 0) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - } -} - -static void NET_FreeNodenum(INT32 numnode) -{ - // can't disconnect from self :) - if (!numnode) - return; - - DEBFILE(va("Free node %d (%s)\n", numnode, NET_GetNodeAddress(numnode))); - - SDLNet_UDP_Unbind(mysocket,numnode-1); - - memset(&clientaddress[numnode], 0, sizeof (IPaddress)); -} - -static UDPsocket NET_Socket(void) -{ - UDPsocket temp = NULL; - Uint16 portnum = 0; - IPaddress tempip = {INADDR_BROADCAST,0}; - //Hurdler: I'd like to put a server and a client on the same computer - //Logan: Me too - //BP: in fact for client we can use any free port we want i have read - // in some doc that connect in udp can do it for us... - //Alam: where? - if (M_CheckParm("-clientport")) - { - if (!M_IsNextParm()) - I_Error("syntax: -clientport "); - portnum = atoi(M_GetNextParm()); - } - else - portnum = sock_port; - temp = SDLNet_UDP_Open(portnum); - if (!temp) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return NULL; - } - if (SDLNet_UDP_Bind(temp,BROADCASTADDR-1,&tempip) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - SDLNet_UDP_Close(temp); - return NULL; - } - clientaddress[BROADCASTADDR].port = sock_port; - clientaddress[BROADCASTADDR].host = INADDR_BROADCAST; - - doomcom->extratics = 1; // internet is very high ping - - return temp; -} - -static void I_ShutdownSDLNetDriver(void) -{ - if (myset) SDLNet_FreeSocketSet(myset); - myset = NULL; - SDLNet_Quit(); - init_SDLNet_driver = false; -} - -static void I_InitSDLNetDriver(void) -{ - if (init_SDLNet_driver) - I_ShutdownSDLNetDriver(); - if (SDLNet_Init() == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return; // No good! - } - D_SetDoomcom(); - mypacket.data = doomcom->data; - init_SDLNet_driver = true; -} - -static void NET_CloseSocket(void) -{ - if (mysocket) - SDLNet_UDP_Close(mysocket); - mysocket = NULL; -} - -static SINT8 NET_NetMakeNodewPort(const char *hostname, const char *port) -{ - INT32 newnode; - UINT16 portnum = sock_port; - IPaddress hostnameIP; - - // retrieve portnum from address! - if (port && !port[0]) - portnum = atoi(port); - - if (SDLNet_ResolveHost(&hostnameIP,hostname,portnum) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return -1; - } - newnode = SDLNet_UDP_Bind(mysocket,-1,&hostnameIP); - if (newnode == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return newnode; - } - newnode++; - M_Memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress)); - return (SINT8)newnode; -} - - -static boolean NET_OpenSocket(void) -{ - memset(clientaddress, 0, sizeof (clientaddress)); - - //I_OutputMsg("SDL_Net Code starting up\n"); - - I_NetSend = NET_Send; - I_NetGet = NET_Get; - I_NetCloseSocket = NET_CloseSocket; - I_NetFreeNodenum = NET_FreeNodenum; - I_NetMakeNodewPort = NET_NetMakeNodewPort; - - //I_NetCanSend = NET_CanSend; - - // build the socket but close it first - NET_CloseSocket(); - mysocket = NET_Socket(); - - if (!mysocket) - return false; - - // for select - myset = SDLNet_AllocSocketSet(1); - if (!myset) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return false; - } - if (SDLNet_UDP_AddSocket(myset,mysocket) == -1) - { - I_OutputMsg("SDL_Net: %s",SDLNet_GetError()); - return false; - } - return true; -} - -static boolean NET_Ban(INT32 node) -{ - if (numbans == MAXBANS) - return false; - - M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); - banned[numbans].port = 0; - numbans++; - return true; -} - -static boolean NET_SetBanAddress(const char *address, const char *mask) -{ - (void)mask; - if (bans == MAXBANS) - return false; - - if (SDLNet_ResolveHost(&banned[numbans], address, 0) == -1) - return false; - numbans++; - return true; -} - -static void NET_ClearBans(void) -{ - numbans = 0; -} -#endif - -// -// I_InitNetwork -// Only required for DOS, so this is more a dummy -// -boolean I_InitNetwork(void) -{ -#ifdef HAVE_SDLNET - char serverhostname[255]; - boolean ret = false; - SDL_version SDLcompiled; - const SDL_version *SDLlinked = SDLNet_Linked_Version(); - SDL_NET_VERSION(&SDLcompiled) - I_OutputMsg("Compiled for SDL_Net version: %d.%d.%d\n", - SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); - I_OutputMsg("Linked with SDL_Net version: %d.%d.%d\n", - SDLlinked->major, SDLlinked->minor, SDLlinked->patch); - //if (!M_CheckParm ("-sdlnet")) - // return false; - // initilize the driver - I_InitSDLNetDriver(); - I_AddExitFunc(I_ShutdownSDLNetDriver); - if (!init_SDLNet_driver) - return false; - - if (M_CheckParm("-udpport")) - { - if (M_IsNextParm()) - sock_port = (UINT16)atoi(M_GetNextParm()); - else - sock_port = 0; - } - - // parse network game options, - if (M_CheckParm("-server") || dedicated) - { - server = true; - - // If a number of clients (i.e. nodes) is specified, the server will wait for the clients - // to connect before starting. - // If no number is specified here, the server starts with 1 client, and others can join - // in-game. - // Since Boris has implemented join in-game, there is no actual need for specifying a - // particular number here. - // FIXME: for dedicated server, numnodes needs to be set to 0 upon start -/* if (M_IsNextParm()) - doomcom->numnodes = (INT16)atoi(M_GetNextParm()); - else */if (dedicated) - doomcom->numnodes = 0; - else - doomcom->numnodes = 1; - - if (doomcom->numnodes < 0) - doomcom->numnodes = 0; - if (doomcom->numnodes > MAXNETNODES) - doomcom->numnodes = MAXNETNODES; - - // server - servernode = 0; - // FIXME: - // ??? and now ? - // server on a big modem ??? 4*isdn - net_bandwidth = 16000; - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - - ret = true; - } - else if (M_CheckParm("-connect")) - { - if (M_IsNextParm()) - strcpy(serverhostname, M_GetNextParm()); - else - serverhostname[0] = 0; // assuming server in the LAN, use broadcast to detect it - - // server address only in ip - if (serverhostname[0]) - { - COM_BufAddText("connect \""); - COM_BufAddText(serverhostname); - COM_BufAddText("\"\n"); - - // probably modem - hardware_MAXPACKETLENGTH = INETPACKETLENGTH; - } - else - { - // so we're on a LAN - COM_BufAddText("connect any\n"); - - net_bandwidth = 800000; - hardware_MAXPACKETLENGTH = MAXPACKETLENGTH; - } - } - - mypacket.maxlen = hardware_MAXPACKETLENGTH; - I_NetOpenSocket = NET_OpenSocket; - I_Ban = NET_Ban; - I_ClearBans = NET_ClearBans; - I_GetNodeAddress = NET_GetNodeAddress; - I_GetBenAddress = NET_GetBenAddress; - I_SetBanAddress = NET_SetBanAddress; - bannednode = NET_bannednode; - - return ret; -#else - if ( M_CheckParm ("-net") ) - { - I_Error("-net not supported, use -server and -connect\n" - "see docs for more\n"); - } - return false; -#endif -} -#endif diff --git a/src/sdl12/i_system.c b/src/sdl12/i_system.c deleted file mode 100644 index 10fbc50ee..000000000 --- a/src/sdl12/i_system.c +++ /dev/null @@ -1,3139 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// Changes by Graue are in the public domain. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief SRB2 system stuff for SDL - -#ifndef _WIN32_WCE -#include -#endif - -#ifdef _XBOX -#include "SRB2XBOX/xboxhelp.h" -#endif - -#if defined (_WIN32) && !defined (_XBOX) -#define RPC_NO_WINDOWS_H -#include -#include "../doomtype.h" -#ifndef _WIN32_WCE -typedef BOOL (WINAPI *p_GetDiskFreeSpaceExA)(LPCSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); -typedef BOOL (WINAPI *p_IsProcessorFeaturePresent) (DWORD); -typedef DWORD (WINAPI *p_timeGetTime) (void); -typedef UINT (WINAPI *p_timeEndPeriod) (UINT); -typedef HANDLE (WINAPI *p_OpenFileMappingA) (DWORD, BOOL, LPCSTR); -typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); -typedef HANDLE (WINAPI *p_GetCurrentProcess) (VOID); -typedef BOOL (WINAPI *p_GetProcessAffinityMask) (HANDLE, PDWORD_PTR, PDWORD_PTR); -typedef BOOL (WINAPI *p_SetProcessAffinityMask) (HANDLE, DWORD_PTR); -#endif -#endif -#include -#include -#include -#ifdef __GNUC__ -#include -#elif defined (_MSC_VER) -#include -#endif -#if defined (__unix__) || defined (UNIXCOMMON) -#include -#endif - -#ifdef _arch_dreamcast -#include -#include -#include -#include -void __set_fpscr(long); // in libgcc / kernel's startup.s? -#else -#include -#if defined (_WIN32) && !defined (_WIN32_WCE) && !defined (_XBOX) -#include -#endif -#endif - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - -#ifdef HAVE_SDL - -#include "SDL.h" - -#ifdef HAVE_TTF -#include "i_ttf.h" -#endif - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#if SDL_VERSION_ATLEAST(1,2,7) && !defined (DC) -#include "SDL_cpuinfo.h" // 1.2.7 or greater -#define HAVE_SDLCPUINFO -#endif - -#ifdef _PSP -//#include -#elif !defined(_PS3) -#if defined (__unix__) || defined(__APPLE__) || (defined (UNIXCOMMON) && !defined (_arch_dreamcast) && !defined (__HAIKU__) && !defined (_WII)) -#if defined (__linux__) -#include -#else -#include -#include -/*For meminfo*/ -#include -#ifdef FREEBSD -#include -#endif -#include -#include -#endif -#endif -#endif - -#ifndef _PS3 -#if defined (__linux__) || (defined (UNIXCOMMON) && !defined (_arch_dreamcast) && !defined (_PSP) && !defined (__HAIKU__) && !defined (_WII)) -#ifndef NOTERMIOS -#include -#include // ioctl -#define HAVE_TERMIOS -#endif -#endif -#endif - -#ifndef NOMUMBLE -#if defined (__linux__) && !defined(_PS3) // need -lrt -#include -#ifdef MAP_FAILED -#define HAVE_SHM -#endif -#include -#endif - -#if defined (_WIN32) && !defined (_WIN32_WCE) && !defined (_XBOX) -#define HAVE_MUMBLE -#define WINMUMBLE -#elif defined (HAVE_SHM) -#define HAVE_MUMBLE -#endif -#endif // NOMUMBLE - -#ifdef _WIN32_WCE -#include "SRB2CE/cehelp.h" -#endif - -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -// Locations for searching the srb2.srb -#ifdef _arch_dreamcast -#define DEFAULTWADLOCATION1 "/cd" -#define DEFAULTWADLOCATION2 "/pc" -#define DEFAULTWADLOCATION3 "/pc/home/alam/srb2code/data" -#define DEFAULTSEARCHPATH1 "/cd" -#define DEFAULTSEARCHPATH2 "/pc" -//#define DEFAULTSEARCHPATH3 "/pc/home/alam/srb2code/data" -#elif defined (GP2X) -#define DEFAULTWADLOCATION1 "/mnt/sd" -#define DEFAULTWADLOCATION2 "/mnt/sd/SRB2" -#define DEFAULTWADLOCATION3 "/tmp/mnt/sd" -#define DEFAULTWADLOCATION4 "/tmp/mnt/sd/SRB2" -#define DEFAULTSEARCHPATH1 "/mnt/sd" -#define DEFAULTSEARCHPATH2 "/tmp/mnt/sd" -#elif defined (_WII) -#define NOCWD -#define NOHOME -#define NEED_SDL_GETENV -#define DEFAULTWADLOCATION1 "sd:/srb2wii" -#define DEFAULTWADLOCATION2 "usb:/srb2wii" -#define DEFAULTSEARCHPATH1 "sd:/srb2wii" -#define DEFAULTSEARCHPATH2 "usb:/srb2wii" -// PS3: TODO: this will need modification most likely -#elif defined (_PS3) -#define NOCWD -#define NOHOME -#define DEFAULTWADLOCATION1 "/dev_hdd0/game/SRB2-PS3_/USRDIR/etc" -#define DEFAULTWADLOCATION2 "/dev_usb/SRB2PS3" -#define DEFAULTSEARCHPATH1 "/dev_hdd0/game/SRB2-PS3_/USRDIR/etc" -#define DEFAULTSEARCHPATH2 "/dev_usb/SRB2PS3" -#elif defined (_PSP) -#define NOCWD -#define NOHOME -#define DEFAULTWADLOCATION1 "host0:/bin/Resources" -#define DEFAULTWADLOCATION2 "ms0:/PSP/GAME/SRB2PSP" -#define DEFAULTSEARCHPATH1 "host0:/" -#define DEFAULTSEARCHPATH2 "ms0:/PSP/GAME/SRB2PSP" -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#define DEFAULTWADLOCATION1 "/usr/local/share/games/SRB2" -#define DEFAULTWADLOCATION2 "/usr/local/games/SRB2" -#define DEFAULTWADLOCATION3 "/usr/share/games/SRB2" -#define DEFAULTWADLOCATION4 "/usr/games/SRB2" -#define DEFAULTSEARCHPATH1 "/usr/local/games" -#define DEFAULTSEARCHPATH2 "/usr/games" -#define DEFAULTSEARCHPATH3 "/usr/local" -#elif defined (_XBOX) -#define NOCWD -#ifdef __GNUC__ -#include -#endif -#define DEFAULTWADLOCATION1 "c:\\srb2" -#define DEFAULTWADLOCATION2 "d:\\srb2" -#define DEFAULTWADLOCATION3 "e:\\srb2" -#define DEFAULTWADLOCATION4 "f:\\srb2" -#define DEFAULTWADLOCATION5 "g:\\srb2" -#define DEFAULTWADLOCATION6 "h:\\srb2" -#define DEFAULTWADLOCATION7 "i:\\srb2" -#elif defined (_WIN32_WCE) -#define NOCWD -#define NOHOME -#define DEFAULTWADLOCATION1 "\\Storage Card\\SRB2DEMO" -#define DEFAULTSEARCHPATH1 "\\Storage Card" -#elif defined (_WIN32) -#define DEFAULTWADLOCATION1 "c:\\games\\srb2" -#define DEFAULTWADLOCATION2 "\\games\\srb2" -#define DEFAULTSEARCHPATH1 "c:\\games" -#define DEFAULTSEARCHPATH2 "\\games" -#endif - -/** \brief WAD file to look for -*/ -#define WADKEYWORD1 "srb2.srb" -#define WADKEYWORD2 "srb2.wad" -/** \brief holds wad path -*/ -static char returnWadPath[256]; - -//Alam_GBC: SDL - -#include "../doomdef.h" -#include "../m_misc.h" -#include "../i_video.h" -#include "../i_sound.h" -#include "../i_system.h" -#include "../screen.h" //vid.WndParent -#include "../d_net.h" -#include "../g_game.h" -#include "../filesrch.h" -#include "endtxt.h" -#include "sdlmain.h" - -#include "../i_joy.h" - -#include "../m_argv.h" - -#ifdef MAC_ALERT -#include "macosx/mac_alert.h" -#endif - -#include "../d_main.h" - -#if !defined(NOMUMBLE) && defined(HAVE_MUMBLE) -// Mumble context string -#include "../d_clisrv.h" -#include "../byteptr.h" -#endif - -/** \brief The JoyReset function - - \param JoySet Joystick info to reset - - \return void -*/ -static void JoyReset(SDLJoyInfo_t *JoySet) -{ - if (JoySet->dev) - { -#ifdef GP2X //GP2X's SDL does an illegal free on the 1st joystick... - if (SDL_JoystickIndex(JoySet->dev) != 0) -#endif - SDL_JoystickClose(JoySet->dev); - } - JoySet->dev = NULL; - JoySet->oldjoy = -1; - JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0; - //JoySet->scale -} - -/** \brief First joystick up and running -*/ -static INT32 joystick_started = 0; - -/** \brief SDL info about joystick 1 -*/ -SDLJoyInfo_t JoyInfo; - - -/** \brief Second joystick up and running -*/ -static INT32 joystick2_started = 0; - -/** \brief SDL inof about joystick 2 -*/ -SDLJoyInfo_t JoyInfo2; - -#ifdef HAVE_TERMIOS -static INT32 fdmouse2 = -1; -static INT32 mouse2_started = 0; -#endif - -SDL_bool consolevent = SDL_FALSE; -SDL_bool framebuffer = SDL_FALSE; - -UINT8 keyboard_started = false; - -#if 0 -static void signal_handler(INT32 num) -{ - //static char msg[] = "oh no! back to reality!\r\n"; - char * sigmsg; - char sigdef[32]; - - switch (num) - { - case SIGINT: - sigmsg = "interrupt"; - break; - case SIGILL: - sigmsg = "illegal instruction - invalid function image"; - break; - case SIGFPE: - sigmsg = "floating point exception"; - break; - case SIGSEGV: - sigmsg = "segment violation"; - break; - case SIGTERM: - sigmsg = "Software termination signal from kill"; - break; -#if !(defined (__unix_) || defined (UNIXCOMMON)) - case SIGBREAK: - sigmsg = "Ctrl-Break sequence"; - break; -#endif - case SIGABRT: - sigmsg = "abnormal termination triggered by abort call"; - break; - default: - sprintf(sigdef,"signal number %d", num); - sigmsg = sigdef; - } - - I_OutputMsg("signal_handler() error: %s\n", sigmsg); - signal(num, SIG_DFL); //default signal action - raise(num); - I_Quit(); -} -#endif - -#if defined (NDEBUG) && !defined (DC) && !defined (_WIN32_WCE) -FUNCNORETURN static ATTRNORETURN void quit_handler(int num) -{ - signal(num, SIG_DFL); //default signal action - raise(num); - I_Quit(); -} -#endif - -#ifdef HAVE_TERMIOS -// TERMIOS console code from Quake3: thank you! -SDL_bool stdin_active = SDL_TRUE; - -typedef struct -{ - size_t cursor; - char buffer[256]; -} feild_t; - -feild_t tty_con; - -// when printing general stuff to stdout stderr (Sys_Printf) -// we need to disable the tty console stuff -// this increments so we can recursively disable -static INT32 ttycon_hide = 0; -// some key codes that the terminal may be using -// TTimo NOTE: I'm not sure how relevant this is -static INT32 tty_erase; -static INT32 tty_eof; - -static struct termios tty_tc; - -// ============================================================= -// tty console routines -// NOTE: if the user is editing a line when something gets printed to the early console then it won't look good -// so we provide tty_Clear and tty_Show to be called before and after a stdout or stderr output -// ============================================================= - -// flush stdin, I suspect some terminals are sending a LOT of garbage -// FIXME TTimo relevant? -#if 0 -static inline void tty_FlushIn(void) -{ - char key; - while (read(STDIN_FILENO, &key, 1)!=-1); -} -#endif - -// do a backspace -// TTimo NOTE: it seems on some terminals just sending '\b' is not enough -// so for now, in any case we send "\b \b" .. yeah well .. -// (there may be a way to find out if '\b' alone would work though) -static void tty_Back(void) -{ - char key; - ssize_t d; - key = '\b'; - d = write(STDOUT_FILENO, &key, 1); - key = ' '; - d = write(STDOUT_FILENO, &key, 1); - key = '\b'; - d = write(STDOUT_FILENO, &key, 1); - (void)d; -} - -static void tty_Clear(void) -{ - size_t i; - if (tty_con.cursor>0) - { - for (i=0; i0); - ttycon_hide--; - if (ttycon_hide == 0 && tty_con.cursor) - { - for (i=0; i 0) - { - tty_con.cursor--; - tty_con.buffer[tty_con.cursor] = '\0'; - tty_Back(); - } - ev.data1 = KEY_BACKSPACE; - } - else if (key < ' ') // check if this is a control char - { - if (key == '\n') - { - tty_Clear(); - tty_con.cursor = 0; - ev.data1 = KEY_ENTER; - } - else return; - } - else - { - // push regular character - ev.data1 = tty_con.buffer[tty_con.cursor] = key; - tty_con.cursor++; - // print the current line (this is differential) - d = write(STDOUT_FILENO, &key, 1); - } - if (ev.data1) D_PostEvent(&ev); - //tty_FlushIn(); - (void)d; -} - -#elif defined (_WIN32) && !(defined (_XBOX) || defined (_WIN32_WCE)) -static BOOL I_ReadyConsole(HANDLE ci) -{ - DWORD gotinput; - if (ci == INVALID_HANDLE_VALUE) return FALSE; - if (WaitForSingleObject(ci,0) != WAIT_OBJECT_0) return FALSE; - if (GetFileType(ci) != FILE_TYPE_CHAR) return FALSE; - if (!GetConsoleMode(ci, &gotinput)) return FALSE; - return (GetNumberOfConsoleInputEvents(ci, &gotinput) && gotinput); -} - -static boolean entering_con_command = false; - -void I_GetConsoleEvents(void) -{ - event_t ev = {0,0,0,0}; - HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - CONSOLE_SCREEN_BUFFER_INFO CSBI; - INPUT_RECORD input; - DWORD t; - - while (I_ReadyConsole(ci) && ReadConsoleInput(ci, &input, 1, &t) && t) - { - memset(&ev,0x00,sizeof (ev)); - switch (input.EventType) - { - case KEY_EVENT: - if (input.Event.KeyEvent.bKeyDown) - { - ev.type = ev_console; - entering_con_command = true; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_ESCAPE: - case VK_TAB: - ev.data1 = KEY_NULL; - break; - case VK_SHIFT: - ev.data1 = KEY_LSHIFT; - break; - case VK_RETURN: - entering_con_command = false; - // Fall through. - default: - ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char - } - if (co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &t)) - { - if (ev.data1 && ev.data1 != KEY_LSHIFT && ev.data1 != KEY_RSHIFT) - { -#ifdef _UNICODE - WriteConsole(co, &input.Event.KeyEvent.uChar.UnicodeChar, 1, &t, NULL); -#else - WriteConsole(co, &input.Event.KeyEvent.uChar.AsciiChar, 1 , &t, NULL); -#endif - } - if (input.Event.KeyEvent.wVirtualKeyCode == VK_BACK - && GetConsoleScreenBufferInfo(co,&CSBI)) - { - WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t); - } - } - } - else - { - ev.type = ev_keyup; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_SHIFT: - ev.data1 = KEY_LSHIFT; - break; - default: - break; - } - } - if (ev.data1) D_PostEvent(&ev); - break; - case MOUSE_EVENT: - case WINDOW_BUFFER_SIZE_EVENT: - case MENU_EVENT: - case FOCUS_EVENT: - break; - } - } -} - -static void I_StartupConsole(void) -{ - HANDLE ci, co; - const INT32 ded = M_CheckParm("-dedicated"); -#ifdef SDLMAIN - BOOL gotConsole = FALSE; - if (M_CheckParm("-console") || ded) - gotConsole = AllocConsole(); -#else - BOOL gotConsole = TRUE; - if (M_CheckParm("-detachconsole")) - { - FreeConsole(); - gotConsole = AllocConsole(); - } -#ifdef _DEBUG - else if (M_CheckParm("-noconsole") && !ded) -#else - else if (!M_CheckParm("-console") && !ded) -#endif - { - FreeConsole(); - gotConsole = FALSE; - } -#endif - - if (gotConsole) - { - SetConsoleTitleA("SRB2 Console"); - consolevent = SDL_TRUE; - } - - //Let get the real console HANDLE, because Mingw's Bash is bad! - ci = CreateFile(TEXT("CONIN$") , GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - co = CreateFile(TEXT("CONOUT$"), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (ci != INVALID_HANDLE_VALUE) - { - const DWORD CM = ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_INPUT; - SetStdHandle(STD_INPUT_HANDLE, ci); - if (GetFileType(ci) == FILE_TYPE_CHAR) - SetConsoleMode(ci, CM); //default mode but no ENABLE_MOUSE_INPUT - } - if (co != INVALID_HANDLE_VALUE) - { - SetStdHandle(STD_OUTPUT_HANDLE, co); - SetStdHandle(STD_ERROR_HANDLE, co); - } -} -static inline void I_ShutdownConsole(void){} -#else -void I_GetConsoleEvents(void){} -static inline void I_StartupConsole(void) -{ -#ifdef _arch_dreamcast - char title[] = "SRB2 for Dreamcast!\n"; - __set_fpscr(0x00040000); /* ignore FPU underflow */ - //printf("\nHello world!\n\n"); - pvr_init_defaults(); - conio_init(CONIO_TTY_PVR, CONIO_INPUT_LINE); - conio_set_theme(CONIO_THEME_MATRIX); - conio_clear(); - conio_putstr(title); - //printf("\nHello world!\n\n"); -#endif -#ifdef _DEBUG - consolevent = !M_CheckParm("-noconsole"); -#else - consolevent = M_CheckParm("-console"); -#endif - - framebuffer = M_CheckParm("-framebuffer"); - - if (framebuffer) - consolevent = SDL_FALSE; -} -static inline void I_ShutdownConsole(void){} -#endif - -// -// StartupKeyboard -// -void I_StartupKeyboard (void) -{ -#if defined (NDEBUG) && !defined (DC) -#ifdef SIGILL -// signal(SIGILL , signal_handler); -#endif -#ifdef SIGINT - signal(SIGINT , quit_handler); -#endif -#ifdef SIGSEGV -// signal(SIGSEGV , signal_handler); -#endif -#ifdef SIGBREAK - signal(SIGBREAK , quit_handler); -#endif -#ifdef SIGABRT -// signal(SIGABRT , signal_handler); -#endif -#ifdef SIGTERM - signal(SIGTERM , quit_handler); -#endif -#endif -} - -// -//I_OutputMsg -// -void I_OutputMsg(const char *fmt, ...) -{ - size_t len; - XBOXSTATIC char txt[8192]; - va_list argptr; - -#ifdef _arch_dreamcast - if (!keyboard_started) conio_printf(fmt); -#endif - - va_start(argptr,fmt); - vsprintf(txt, fmt, argptr); - va_end(argptr); - -#ifdef HAVE_TTF - if (TTF_WasInit()) I_TTFDrawText(currentfont, solid, DEFAULTFONTFGR, DEFAULTFONTFGG, DEFAULTFONTFGB, DEFAULTFONTFGA, - DEFAULTFONTBGR, DEFAULTFONTBGG, DEFAULTFONTBGB, DEFAULTFONTBGA, txt); -#endif - -#if defined (_WIN32) && !defined (_XBOX) && defined (_MSC_VER) - OutputDebugStringA(txt); -#endif - - len = strlen(txt); - -#ifdef LOGMESSAGES - if (logstream) - { - size_t d = fwrite(txt, len, 1, logstream); - fflush(logstream); - (void)d; - } -#endif - -#if defined (_WIN32) && !defined (_XBOX) && !defined(_WIN32_WCE) -#ifdef DEBUGFILE - if (debugfile != stderr) -#endif - { - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD bytesWritten; - - if (co == INVALID_HANDLE_VALUE) - return; - - if (GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &bytesWritten)) - { - static COORD coordNextWrite = {0,0}; - LPVOID oldLines = NULL; - INT oldLength; - CONSOLE_SCREEN_BUFFER_INFO csbi; - - // Save the lines that we're going to obliterate. - GetConsoleScreenBufferInfo(co, &csbi); - oldLength = csbi.dwSize.X * (csbi.dwCursorPosition.Y - coordNextWrite.Y) + csbi.dwCursorPosition.X - coordNextWrite.X; - - if (oldLength > 0) - { - LPVOID blank = malloc(oldLength); - if (!blank) return; - memset(blank, ' ', oldLength); // Blank out. - oldLines = malloc(oldLength*sizeof(TCHAR)); - if (!oldLines) - { - free(blank); - return; - } - - ReadConsoleOutputCharacter(co, oldLines, oldLength, coordNextWrite, &bytesWritten); - - // Move to where we what to print - which is where we would've been, - // had console input not been in the way, - SetConsoleCursorPosition(co, coordNextWrite); - - WriteConsoleA(co, blank, oldLength, &bytesWritten, NULL); - free(blank); - - // And back to where we want to print again. - SetConsoleCursorPosition(co, coordNextWrite); - } - - // Actually write the string now! - WriteConsoleA(co, txt, (DWORD)len, &bytesWritten, NULL); - - // Next time, output where we left off. - GetConsoleScreenBufferInfo(co, &csbi); - coordNextWrite = csbi.dwCursorPosition; - - // Restore what was overwritten. - if (oldLines && entering_con_command) - WriteConsole(co, oldLines, oldLength, &bytesWritten, NULL); - if (oldLines) free(oldLines); - } - else // Redirected to a file. - WriteFile(co, txt, (DWORD)len, &bytesWritten, NULL); - } -#else -#ifdef HAVE_TERMIOS - if (consolevent) - { - tty_Hide(); - } -#endif - - if (!framebuffer) - fprintf(stderr, "%s", txt); -#ifdef HAVE_TERMIOS - if (consolevent) - { - tty_Show(); - } -#endif - - // 2004-03-03 AJR Since not all messages end in newline, some were getting displayed late. - if (!framebuffer) - fflush(stderr); - -#endif -} - -// -// I_GetKey -// -INT32 I_GetKey (void) -{ - // Warning: I_GetKey empties the event queue till next keypress - event_t *ev; - INT32 rc = 0; - - // return the first keypress from the event queue - for (; eventtail != eventhead; eventtail = (eventtail+1)&(MAXEVENTS-1)) - { - ev = &events[eventtail]; - if (ev->type == ev_keydown || ev->type == ev_console) - { - rc = ev->data1; - continue; - } - } - - return rc; -} - -// -// I_JoyScale -// -void I_JoyScale(void) -{ -#ifdef GP2X - if (JoyInfo.dev && SDL_JoystickIndex(JoyInfo.dev) == 0) - Joystick.bGamepadStyle = true; - else -#endif - Joystick.bGamepadStyle = cv_joyscale.value==0; - JoyInfo.scale = Joystick.bGamepadStyle?1:cv_joyscale.value; -} - -void I_JoyScale2(void) -{ -#ifdef GP2X - if (JoyInfo2.dev && SDL_JoystickIndex(JoyInfo2.dev) == 0) - Joystick.bGamepadStyle = true; - else -#endif - Joystick2.bGamepadStyle = cv_joyscale2.value==0; - JoyInfo2.scale = Joystick2.bGamepadStyle?1:cv_joyscale2.value; -} - -/** \brief Joystick 1 buttons states -*/ -static UINT64 lastjoybuttons = 0; - -/** \brief Joystick 1 hats state -*/ -static UINT64 lastjoyhats = 0; - -/** \brief Shuts down joystick 1 - - - \return void - - -*/ -static void I_ShutdownJoystick(void) -{ - INT32 i; - event_t event; - event.type=ev_keyup; - event.data2 = 0; - event.data3 = 0; - - lastjoybuttons = lastjoyhats = 0; - - // emulate the up of all joystick buttons - for (i=0;i= 0; i--) - { - joybuttons <<= 1; - if (SDL_JoystickGetButton(JoyInfo.dev,i)) - joybuttons |= 1; - } - - if (joybuttons != lastjoybuttons) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newbuttons = joybuttons ^ lastjoybuttons; - lastjoybuttons = joybuttons; - - for (i = 0; i < JOYBUTTONS; i++, j <<= 1) - { - if (newbuttons & j) // button changed state? - { - if (joybuttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; -#ifdef _PSP - if (i == 12) - event.data1 = KEY_ESCAPE; - else -#endif - event.data1 = KEY_JOY1 + i; - D_PostEvent(&event); - } - } - } -#endif - - for (i = JoyInfo.hats - 1; i >= 0; i--) - { - Uint8 hat = SDL_JoystickGetHat(JoyInfo.dev, i); - - if (hat & SDL_HAT_UP ) joyhats|=(UINT64)0x1<<(0 + 4*i); - if (hat & SDL_HAT_DOWN ) joyhats|=(UINT64)0x1<<(1 + 4*i); - if (hat & SDL_HAT_LEFT ) joyhats|=(UINT64)0x1<<(2 + 4*i); - if (hat & SDL_HAT_RIGHT) joyhats|=(UINT64)0x1<<(3 + 4*i); - } - - if (joyhats != lastjoyhats) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newhats = joyhats ^ lastjoyhats; - lastjoyhats = joyhats; - - for (i = 0; i < JOYHATS*4; i++, j <<= 1) - { - if (newhats & j) // hat changed state? - { - if (joyhats & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_HAT1 + i; - D_PostEvent(&event); - } - } - } - -#if 0 - // send joystick axis positions - event.type = ev_joystick; - - for (i = JOYAXISSET - 1; i >= 0; i--) - { - event.data1 = i; - if (i*2 + 1 <= JoyInfo.axises) - axisx = SDL_JoystickGetAxis(JoyInfo.dev, i*2 + 0); - else axisx = 0; - if (i*2 + 2 <= JoyInfo.axises) - axisy = SDL_JoystickGetAxis(JoyInfo.dev, i*2 + 1); - else axisy = 0; - -#ifdef _arch_dreamcast // -128 to 127 - axisx = axisx*8; - axisy = axisy*8; -#else // -32768 to 32767 - axisx = axisx/32; - axisy = axisy/32; -#endif - - if (Joystick.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (axisx < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (axisx > (JOYAXISRANGE/2)) - event.data2 = 1; - else event.data2 = 0; - if (axisy < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (axisy > (JOYAXISRANGE/2)) - event.data3 = 1; - else event.data3 = 0; - } - else - { - - axisx = JoyInfo.scale?((axisx/JoyInfo.scale)*JoyInfo.scale):axisx; - axisy = JoyInfo.scale?((axisy/JoyInfo.scale)*JoyInfo.scale):axisy; - -#ifdef SDL_JDEADZONE - if (-SDL_JDEADZONE <= axisx && axisx <= SDL_JDEADZONE) axisx = 0; - if (-SDL_JDEADZONE <= axisy && axisy <= SDL_JDEADZONE) axisy = 0; -#endif - - // analog control style , just send the raw data - event.data2 = axisx; // x axis - event.data3 = axisy; // y axis - } - D_PostEvent(&event); - } -#endif -} - -/** \brief Open joystick handle - - \param fname name of joystick - - \return axises - - -*/ -static int joy_open(const char *fname) -{ - int joyindex = atoi(fname); - int num_joy = 0; - int i; - - if (joystick_started == 0 && joystick2_started == 0) - { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) - { - CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); - return -1; - } - else - { - num_joy = SDL_NumJoysticks(); - } - - if (num_joy < joyindex) - { - CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i)); - I_ShutdownJoystick(); - return -1; - } - } - else - { - JoyReset(&JoyInfo); - //I_ShutdownJoystick(); - //joy_open(fname); - } - - num_joy = SDL_NumJoysticks(); - - if (joyindex <= 0 || num_joy == 0 || JoyInfo.oldjoy == joyindex) - { -// I_OutputMsg("Unable to use that joystick #(%s), non-number\n",fname); - if (num_joy != 0) - { - CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i)); - } - else - CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); - if (joyindex <= 0 || num_joy == 0) return 0; - } - - JoyInfo.dev = SDL_JoystickOpen(joyindex-1); - CONS_Printf(M_GetText("Joystick: %s\n"), SDL_JoystickName(joyindex-1)); - - if (JoyInfo.dev == NULL) - { - CONS_Printf(M_GetText("Couldn't open joystick: %s\n"), SDL_GetError()); - I_ShutdownJoystick(); - return -1; - } - else - { - JoyInfo.axises = SDL_JoystickNumAxes(JoyInfo.dev); - if (JoyInfo.axises > JOYAXISSET*2) - JoyInfo.axises = JOYAXISSET*2; -/* if (joyaxes<2) - { - I_OutputMsg("Not enought axes?\n"); - I_ShutdownJoystick(); - return 0; - }*/ - - JoyInfo.buttons = SDL_JoystickNumButtons(JoyInfo.dev); - if (JoyInfo.buttons > JOYBUTTONS) - JoyInfo.buttons = JOYBUTTONS; - -#ifdef DC - JoyInfo.hats = 0; -#else - JoyInfo.hats = SDL_JoystickNumHats(JoyInfo.dev); - if (JoyInfo.hats > JOYHATS) - JoyInfo.hats = JOYHATS; - - JoyInfo.balls = SDL_JoystickNumBalls(JoyInfo.dev); -#endif - - //Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(SDL_JoystickIndex(JoyInfo.dev)), "pad"); - - return JoyInfo.axises; - } -} - -//Joystick2 - -/** \brief Joystick 2 buttons states -*/ -static UINT64 lastjoy2buttons = 0; - -/** \brief Joystick 2 hats state -*/ -static UINT64 lastjoy2hats = 0; - -/** \brief Shuts down joystick 2 - - - \return void -*/ -static void I_ShutdownJoystick2(void) -{ - INT32 i; - event_t event; - event.type = ev_keyup; - event.data2 = 0; - event.data3 = 0; - - lastjoy2buttons = lastjoy2hats = 0; - - // emulate the up of all joystick buttons - for (i = 0; i < JOYBUTTONS; i++) - { - event.data1 = KEY_2JOY1 + i; - D_PostEvent(&event); - } - - // emulate the up of all joystick hats - for (i = 0; i < JOYHATS*4; i++) - { - event.data1 = KEY_2HAT1 + i; - D_PostEvent(&event); - } - - // reset joystick position - event.type = ev_joystick2; - for (i = 0; i < JOYAXISSET; i++) - { - event.data1 = i; - D_PostEvent(&event); - } - - JoyReset(&JoyInfo2); - if (!joystick_started && !joystick2_started && SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) - { - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - if (cv_usejoystick2.value == 0) - { - DEBFILE("I_Joystick2: SDL's Joystick system has been shutdown\n"); - } - } -} - -void I_GetJoystick2Events(void) -{ - static event_t event = {0,0,0,0}; - INT32 i = 0; - UINT64 joyhats = 0; -#if 0 - INT64 joybuttons = 0; - INT32 axisx, axisy; -#endif - - if (!joystick2_started) - return; - - if (!JoyInfo2.dev) //I_ShutdownJoystick2(); - return; - - -#if 0 - //faB: look for as much buttons as g_input code supports, - // we don't use the others - for (i = JoyInfo2.buttons - 1; i >= 0; i--) - { - joybuttons <<= 1; - if (SDL_JoystickGetButton(JoyInfo2.dev,i)) - joybuttons |= 1; - } - - if (joybuttons != lastjoy2buttons) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newbuttons = joybuttons ^ lastjoy2buttons; - lastjoy2buttons = joybuttons; - - for (i = 0; i < JOYBUTTONS; i++, j <<= 1) - { - if (newbuttons & j) // button changed state? - { - if (joybuttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2JOY1 + i; - D_PostEvent(&event); - } - } - } -#endif - - for (i = JoyInfo2.hats - 1; i >= 0; i--) - { - Uint8 hat = SDL_JoystickGetHat(JoyInfo2.dev, i); - - if (hat & SDL_HAT_UP ) joyhats|=(UINT64)0x1<<(0 + 4*i); - if (hat & SDL_HAT_DOWN ) joyhats|=(UINT64)0x1<<(1 + 4*i); - if (hat & SDL_HAT_LEFT ) joyhats|=(UINT64)0x1<<(2 + 4*i); - if (hat & SDL_HAT_RIGHT) joyhats|=(UINT64)0x1<<(3 + 4*i); - } - - if (joyhats != lastjoy2hats) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newhats = joyhats ^ lastjoy2hats; - lastjoy2hats = joyhats; - - for (i = 0; i < JOYHATS*4; i++, j <<= 1) - { - if (newhats & j) // hat changed state? - { - if (joyhats & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2HAT1 + i; - D_PostEvent(&event); - } - } - } - -#if 0 - // send joystick axis positions - event.type = ev_joystick2; - - for (i = JOYAXISSET - 1; i >= 0; i--) - { - event.data1 = i; - if (i*2 + 1 <= JoyInfo2.axises) - axisx = SDL_JoystickGetAxis(JoyInfo2.dev, i*2 + 0); - else axisx = 0; - if (i*2 + 2 <= JoyInfo2.axises) - axisy = SDL_JoystickGetAxis(JoyInfo2.dev, i*2 + 1); - else axisy = 0; - -#ifdef _arch_dreamcast // -128 to 127 - axisx = axisx*8; - axisy = axisy*8; -#else // -32768 to 32767 - axisx = axisx/32; - axisy = axisy/32; -#endif - - if (Joystick2.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (axisx < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (axisx > (JOYAXISRANGE/2)) - event.data2 = 1; - else - event.data2 = 0; - if (axisy < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (axisy > (JOYAXISRANGE/2)) - event.data3 = 1; - else - event.data3 = 0; - } - else - { - - axisx = JoyInfo2.scale?((axisx/JoyInfo2.scale)*JoyInfo2.scale):axisx; - axisy = JoyInfo2.scale?((axisy/JoyInfo2.scale)*JoyInfo2.scale):axisy; - -#ifdef SDL_JDEADZONE - if (-SDL_JDEADZONE <= axisx && axisx <= SDL_JDEADZONE) axisx = 0; - if (-SDL_JDEADZONE <= axisy && axisy <= SDL_JDEADZONE) axisy = 0; -#endif - - // analog control style , just send the raw data - event.data2 = axisx; // x axis - event.data3 = axisy; // y axis - } - D_PostEvent(&event); - } -#endif - -} - -/** \brief Open joystick handle - - \param fname name of joystick - - \return axises - - -*/ -static int joy_open2(const char *fname) -{ - int joyindex = atoi(fname); - int num_joy = 0; - int i; - - if (joystick_started == 0 && joystick2_started == 0) - { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) - { - CONS_Printf(M_GetText("Couldn't initialize joystick: %s\n"), SDL_GetError()); - return -1; - } - else - num_joy = SDL_NumJoysticks(); - - if (num_joy < joyindex) - { - CONS_Printf(M_GetText("Cannot use joystick #%d/(%s), it doesn't exist\n"),joyindex,fname); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i)); - I_ShutdownJoystick2(); - return -1; - } - } - else - { - JoyReset(&JoyInfo2); - //I_ShutdownJoystick(); - //joy_open(fname); - } - - num_joy = SDL_NumJoysticks(); - - if (joyindex <= 0 || num_joy == 0 || JoyInfo2.oldjoy == joyindex) - { -// I_OutputMsg("Unable to use that joystick #(%s), non-number\n",fname); - if (num_joy != 0) - { - CONS_Printf(M_GetText("Found %d joysticks on this system\n"), num_joy); - for (i = 0; i < num_joy; i++) - CONS_Printf("#%d/(%s)\n", i+1, SDL_JoystickName(i)); - } - else - CONS_Printf("%s", M_GetText("Found no joysticks on this system\n")); - if (joyindex <= 0 || num_joy == 0) return 0; - } - - JoyInfo2.dev = SDL_JoystickOpen(joyindex-1); - CONS_Printf(M_GetText("Joystick2: %s\n"), SDL_JoystickName(joyindex-1)); - - if (!JoyInfo2.dev) - { - CONS_Printf(M_GetText("Couldn't open joystick2: %s\n"), SDL_GetError()); - I_ShutdownJoystick2(); - return -1; - } - else - { - JoyInfo2.axises = SDL_JoystickNumAxes(JoyInfo2.dev); - if (JoyInfo2.axises > JOYAXISSET*2) - JoyInfo2.axises = JOYAXISSET*2; -/* if (joyaxes < 2) - { - I_OutputMsg("Not enought axes?\n"); - I_ShutdownJoystick2(); - return 0; - }*/ - - JoyInfo2.buttons = SDL_JoystickNumButtons(JoyInfo2.dev); - if (JoyInfo2.buttons > JOYBUTTONS) - JoyInfo2.buttons = JOYBUTTONS; - -#ifdef DC - JoyInfo2.hats = 0; -#else - JoyInfo2.hats = SDL_JoystickNumHats(JoyInfo2.dev); - if (JoyInfo2.hats > JOYHATS) - JoyInfo2.hats = JOYHATS; - - JoyInfo2.balls = SDL_JoystickNumBalls(JoyInfo2.dev); -#endif - - //Joystick.bGamepadStyle = !stricmp(SDL_JoystickName(SDL_JoystickIndex(JoyInfo2.dev)), "pad"); - - return JoyInfo2.axises; - } -} - -// -// I_InitJoystick -// -void I_InitJoystick(void) -{ - I_ShutdownJoystick(); - if (!strcmp(cv_usejoystick.string, "0") || M_CheckParm("-nojoy")) - return; - if (joy_open(cv_usejoystick.string) != -1) - JoyInfo.oldjoy = atoi(cv_usejoystick.string); - else - { - cv_usejoystick.value = 0; - return; - } - joystick_started = 1; -} - -void I_InitJoystick2(void) -{ - I_ShutdownJoystick2(); - if (!strcmp(cv_usejoystick2.string, "0") || M_CheckParm("-nojoy")) - return; - if (joy_open2(cv_usejoystick2.string) != -1) - JoyInfo2.oldjoy = atoi(cv_usejoystick2.string); - else - { - cv_usejoystick2.value = 0; - return; - } - joystick2_started = 1; -} - -static void I_ShutdownInput(void) -{ - if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) - { - JoyReset(&JoyInfo); - JoyReset(&JoyInfo2); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } - -} - -INT32 I_NumJoys(void) -{ - INT32 numjoy = 0; - if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) - { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1) - numjoy = SDL_NumJoysticks(); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } - else - numjoy = SDL_NumJoysticks(); - return numjoy; -} - -static char joyname[255]; // MAX_PATH; joystick name is straight from the driver - -const char *I_GetJoyName(INT32 joyindex) -{ - const char *tempname = NULL; - joyindex--; //SDL's Joystick System starts at 0, not 1 - if (SDL_WasInit(SDL_INIT_JOYSTICK) == 0) - { - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != -1) - { - tempname = SDL_JoystickNameForIndex(joyindex); - if (tempname) - strncpy(joyname, tempname, 255); - } - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - } - else - { - tempname = SDL_JoystickNameForIndex(joyindex); - if (tempname) - strncpy(joyname, tempname, 255); - } - return joyname; -} - -#ifndef NOMUMBLE -#ifdef HAVE_MUMBLE -// Best Mumble positional audio settings: -// Minimum distance 3.0 m -// Bloom 175% -// Maximum distance 80.0 m -// Minimum volume 50% -#define DEG2RAD (0.017453292519943295769236907684883l) // TAU/360 or PI/180 -#define MUMBLEUNIT (64.0f) // FRACUNITS in a Meter - -static struct { -#ifdef WINMUMBLE - UINT32 uiVersion; - DWORD uiTick; -#else - Uint32 uiVersion; - Uint32 uiTick; -#endif - float fAvatarPosition[3]; - float fAvatarFront[3]; - float fAvatarTop[3]; // defaults to Y-is-up (only used for leaning) - wchar_t name[256]; // game name - float fCameraPosition[3]; - float fCameraFront[3]; - float fCameraTop[3]; // defaults to Y-is-up (only used for leaning) - wchar_t identity[256]; // player id -#ifdef WINMUMBLE - UINT32 context_len; -#else - Uint32 context_len; -#endif - unsigned char context[256]; // server/team - wchar_t description[2048]; // game description -} *mumble = NULL; -#endif // HAVE_MUMBLE - -static void I_SetupMumble(void) -{ -#ifdef WINMUMBLE - HANDLE hMap = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); - if (!hMap) - return; - - mumble = MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(*mumble)); - if (!mumble) - CloseHandle(hMap); -#elif defined (HAVE_SHM) - int shmfd; - char memname[256]; - - snprintf(memname, 256, "/MumbleLink.%d", getuid()); - shmfd = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR); - - if(shmfd < 0) - return; - - mumble = mmap(NULL, sizeof(*mumble), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0); - if (mumble == MAP_FAILED) - mumble = NULL; -#endif -} - -void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) -{ -#ifdef HAVE_MUMBLE - double angle; - fixed_t anglef; - - if (!mumble) - return; - - if(mumble->uiVersion != 2) { - wcsncpy(mumble->name, L"SRB2 "VERSIONSTRING, 256); - wcsncpy(mumble->description, L"Sonic Robo Blast 2 with integrated Mumble Link support.", 2048); - mumble->uiVersion = 2; - } - mumble->uiTick++; - - if (!netgame || gamestate != GS_LEVEL) { // Zero out, but never delink. - mumble->fAvatarPosition[0] = mumble->fAvatarPosition[1] = mumble->fAvatarPosition[2] = 0.0f; - mumble->fAvatarFront[0] = 1.0f; - mumble->fAvatarFront[1] = mumble->fAvatarFront[2] = 0.0f; - mumble->fCameraPosition[0] = mumble->fCameraPosition[1] = mumble->fCameraPosition[2] = 0.0f; - mumble->fCameraFront[0] = 1.0f; - mumble->fCameraFront[1] = mumble->fCameraFront[2] = 0.0f; - return; - } - - { - UINT8 *p = mumble->context; - WRITEMEM(p, server_context, 8); - WRITEINT16(p, gamemap); - mumble->context_len = p - mumble->context; - } - - if (mobj) { - mumble->fAvatarPosition[0] = FIXED_TO_FLOAT(mobj->x) / MUMBLEUNIT; - mumble->fAvatarPosition[1] = FIXED_TO_FLOAT(mobj->z) / MUMBLEUNIT; - mumble->fAvatarPosition[2] = FIXED_TO_FLOAT(mobj->y) / MUMBLEUNIT; - - anglef = AngleFixed(mobj->angle); - angle = FIXED_TO_FLOAT(anglef)*DEG2RAD; - mumble->fAvatarFront[0] = (float)cos(angle); - mumble->fAvatarFront[1] = 0.0f; - mumble->fAvatarFront[2] = (float)sin(angle); - } else { - mumble->fAvatarPosition[0] = mumble->fAvatarPosition[1] = mumble->fAvatarPosition[2] = 0.0f; - mumble->fAvatarFront[0] = 1.0f; - mumble->fAvatarFront[1] = mumble->fAvatarFront[2] = 0.0f; - } - - mumble->fCameraPosition[0] = FIXED_TO_FLOAT(listener.x) / MUMBLEUNIT; - mumble->fCameraPosition[1] = FIXED_TO_FLOAT(listener.z) / MUMBLEUNIT; - mumble->fCameraPosition[2] = FIXED_TO_FLOAT(listener.y) / MUMBLEUNIT; - - anglef = AngleFixed(listener.angle); - angle = FIXED_TO_FLOAT(anglef)*DEG2RAD; - mumble->fCameraFront[0] = (float)cos(angle); - mumble->fCameraFront[1] = 0.0f; - mumble->fCameraFront[2] = (float)sin(angle); -#else - (void)mobj; - (void)listener; -#endif // HAVE_MUMBLE -} -#undef WINMUMBLE -#endif // NOMUMBLE - -#ifdef HAVE_TERMIOS - -void I_GetMouseEvents(void) -{ - static UINT8 mdata[5]; - static INT32 i = 0,om2b = 0; - INT32 di, j, mlp, button; - event_t event; - const INT32 mswap[8] = {0, 4, 1, 5, 2, 6, 3, 7}; - - if (!mouse2_started) return; - for (mlp = 0; mlp < 20; mlp++) - { - for (; i < 5; i++) - { - di = read(fdmouse2, mdata+i, 1); - if (di == -1) return; - } - if ((mdata[0] & 0xf8) != 0x80) - { - for (j = 1; j < 5; j++) - if ((mdata[j] & 0xf8) == 0x80) - for (i = 0; i < 5-j; i++) // shift - mdata[i] = mdata[i+j]; - if (i < 5) continue; - } - else - { - button = mswap[~mdata[0] & 0x07]; - for (j = 0; j < MOUSEBUTTONS; j++) - { - if (om2b & (1<> 4); - } - else if (bytenum == 3) - { - dx = (char)((combytes[0] & 3) << 6); - dy = (char)((combytes[0] & 12) << 4); - dx = (char)(dx + combytes[1]); - dy = (char)(dy + combytes[2]); - handlermouse2x+= dx; - handlermouse2y+= dy; - } - else if (bytenum == 4) // fourth UINT8 (logitech mouses) - { - if (buffer[i] & 32) - handlermouse2buttons |= 4; - else - handlermouse2buttons &= ~4; - } - } -} - -void I_GetMouseEvents(void) -{ - static UINT8 lastbuttons2 = 0; //mouse movement - event_t event; - - if (mouse2filehandle == INVALID_HANDLE_VALUE) - return; - - I_PoolMouse2(); - // post key event for buttons - if (handlermouse2buttons != lastbuttons2) - { - INT32 i, j = 1, k; - k = (handlermouse2buttons ^ lastbuttons2); // only changed bit to 1 - lastbuttons2 = (UINT8)handlermouse2buttons; - - for (i = 0; i < MOUSEBUTTONS; i++, j <<= 1) - if (k & j) - { - if (handlermouse2buttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2MOUSE1+i; - D_PostEvent(&event); - } - } - - if (handlermouse2x != 0 || handlermouse2y != 0) - { - event.type = ev_mouse2; - event.data1 = 0; -// event.data1 = buttons; // not needed - event.data2 = handlermouse2x << 1; - event.data3 = -handlermouse2y << 1; - handlermouse2x = 0; - handlermouse2y = 0; - - D_PostEvent(&event); - } -} -#else -void I_GetMouseEvents(void){}; -#endif - -// -// I_StartupMouse2 -// -void I_StartupMouse2(void) -{ -#ifdef HAVE_TERMIOS - struct termios m2tio; - size_t i; - INT32 dtr = -1, rts = -1;; - I_ShutdownMouse2(); - if (cv_usemouse2.value == 0) return; - if ((fdmouse2 = open(cv_mouse2port.string, O_RDONLY|O_NONBLOCK|O_NOCTTY)) == -1) - { - CONS_Printf(M_GetText("Error opening %s!\n"), cv_mouse2port.string); - return; - } - tcflush(fdmouse2, TCIOFLUSH); - m2tio.c_iflag = IGNBRK; - m2tio.c_oflag = 0; - m2tio.c_cflag = CREAD|CLOCAL|HUPCL|CS8|CSTOPB|B1200; - m2tio.c_lflag = 0; - m2tio.c_cc[VTIME] = 0; - m2tio.c_cc[VMIN] = 1; - tcsetattr(fdmouse2, TCSANOW, &m2tio); - for (i = 0; i < strlen(cv_mouse2opt.string); i++) - { - if (toupper(cv_mouse2opt.string[i]) == 'D') - { - if (cv_mouse2opt.string[i+1] == '-') - dtr = 0; - else - dtr = 1; - } - if (toupper(cv_mouse2opt.string[i]) == 'R') - { - if (cv_mouse2opt.string[i+1] == '-') - rts = 0; - else - rts = 1; - } - if (dtr != -1 || rts != -1) - { - INT32 c; - if (!ioctl(fdmouse2, TIOCMGET, &c)) - { - if (!dtr) - c &= ~TIOCM_DTR; - else if (dtr > 0) - c |= TIOCM_DTR; - } - if (!rts) - c &= ~TIOCM_RTS; - else if (rts > 0) - c |= TIOCM_RTS; - ioctl(fdmouse2, TIOCMSET, &c); - } - } - mouse2_started = 1; - I_AddExitFunc(I_ShutdownMouse2); -#elif defined (_WIN32) && !defined (_XBOX) - DCB dcb; - - if (mouse2filehandle != INVALID_HANDLE_VALUE) - I_ShutdownMouse2(); - - if (cv_usemouse2.value == 0) - return; - - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - // COM file handle - mouse2filehandle = CreateFileA(cv_mouse2port.string, GENERIC_READ | GENERIC_WRITE, - 0, // exclusive access - NULL, // no security attrs - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - INT32 e = GetLastError(); - if (e == 5) - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s: Access denied\n"), cv_mouse2port.string); - else - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s: error %d\n"), cv_mouse2port.string, e); - return; - } - } - - // getevent when somthing happens - //SetCommMask(mouse2filehandle, EV_RXCHAR); - - // buffers - SetupComm(mouse2filehandle, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); - - // purge buffers - PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT - | PURGE_TXCLEAR | PURGE_RXCLEAR); - - // setup port to 1200 7N1 - dcb.DCBlength = sizeof (DCB); - - GetCommState(mouse2filehandle, &dcb); - - dcb.BaudRate = CBR_1200; - dcb.ByteSize = 7; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - - dcb.fDtrControl = DTR_CONTROL_ENABLE; - dcb.fRtsControl = RTS_CONTROL_ENABLE; - - dcb.fBinary = TRUE; - dcb.fParity = TRUE; - - SetCommState(mouse2filehandle, &dcb); - I_AddExitFunc(I_ShutdownMouse2); -#endif -} - -// -// I_Tactile -// -void I_Tactile(FFType pFFType, const JoyFF_t *FFEffect) -{ - // UNUSED. - (void)pFFType; - (void)FFEffect; -} - -void I_Tactile2(FFType pFFType, const JoyFF_t *FFEffect) -{ - // UNUSED. - (void)pFFType; - (void)FFEffect; -} - -/** \brief empty ticcmd for player 1 -*/ -static ticcmd_t emptycmd; - -ticcmd_t *I_BaseTiccmd(void) -{ - return &emptycmd; -} - -/** \brief empty ticcmd for player 2 -*/ -static ticcmd_t emptycmd2; - -ticcmd_t *I_BaseTiccmd2(void) -{ - return &emptycmd2; -} - -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) -static HMODULE winmm = NULL; -static DWORD starttickcount = 0; // hack for win2k time bug -static p_timeGetTime pfntimeGetTime = NULL; - -// --------- -// I_GetTime -// Use the High Resolution Timer if available, -// else use the multimedia timer which has 1 millisecond precision on Windowz 95, -// but lower precision on Windows NT -// --------- - -tic_t I_GetTime(void) -{ - tic_t newtics = 0; - - if (!starttickcount) // high precision timer - { - LARGE_INTEGER currtime; // use only LowPart if high resolution counter is not available - static LARGE_INTEGER basetime = {{0, 0}}; - - // use this if High Resolution timer is found - static LARGE_INTEGER frequency; - - if (!basetime.LowPart) - { - if (!QueryPerformanceFrequency(&frequency)) - frequency.QuadPart = 0; - else - QueryPerformanceCounter(&basetime); - } - - if (frequency.LowPart && QueryPerformanceCounter(&currtime)) - { - newtics = (INT32)((currtime.QuadPart - basetime.QuadPart) * NEWTICRATE - / frequency.QuadPart); - } - else if (pfntimeGetTime) - { - currtime.LowPart = pfntimeGetTime(); - if (!basetime.LowPart) - basetime.LowPart = currtime.LowPart; - newtics = ((currtime.LowPart - basetime.LowPart)/(1000/NEWTICRATE)); - } - } - else - newtics = (GetTickCount() - starttickcount)/(1000/NEWTICRATE); - - return newtics; -} - -static void I_ShutdownTimer(void) -{ - pfntimeGetTime = NULL; - if (winmm) - { - p_timeEndPeriod pfntimeEndPeriod = (p_timeEndPeriod)GetProcAddress(winmm, "timeEndPeriod"); - if (pfntimeEndPeriod) - pfntimeEndPeriod(1); - FreeLibrary(winmm); - winmm = NULL; - } -} -#else -// -// I_GetTime -// returns time in 1/TICRATE second tics -// -tic_t I_GetTime (void) -{ -#ifdef _arch_dreamcast - static Uint64 basetime = 0; - Uint64 ticks = timer_ms_gettime64(); //using timer_ms_gettime64 instand of SDL_GetTicks for the Dreamcast -#else - static Uint32 basetime = 0; - Uint32 ticks = SDL_GetTicks(); -#endif - - if (!basetime) - basetime = ticks; - - ticks -= basetime; - - ticks = (ticks*TICRATE); - -#if 0 //#ifdef _WIN32_WCE - ticks = (ticks/10); -#else - ticks = (ticks/1000); -#endif - - return (tic_t)ticks; -} -#endif - -// -//I_StartupTimer -// -void I_StartupTimer(void) -{ -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) - // for win2k time bug - if (M_CheckParm("-gettickcount")) - { - starttickcount = GetTickCount(); - CONS_Printf("%s", M_GetText("Using GetTickCount()\n")); - } - winmm = LoadLibraryA("winmm.dll"); - if (winmm) - { - p_timeEndPeriod pfntimeBeginPeriod = (p_timeEndPeriod)GetProcAddress(winmm, "timeBeginPeriod"); - if (pfntimeBeginPeriod) - pfntimeBeginPeriod(1); - pfntimeGetTime = (p_timeGetTime)GetProcAddress(winmm, "timeGetTime"); - } - I_AddExitFunc(I_ShutdownTimer); -#elif 0 //#elif !defined (_arch_dreamcast) && !defined(GP2X) // the DC have it own timer and GP2X have broken pthreads? - if (SDL_InitSubSystem(SDL_INIT_TIMER) < 0) - I_Error("SRB2: Needs SDL_Timer, Error: %s", SDL_GetError()); -#endif -} - - - -void I_Sleep(void) -{ -#if !(defined (_arch_dreamcast) || defined (_XBOX)) - if (cv_sleep.value != -1) - SDL_Delay(cv_sleep.value); -#endif -} - -INT32 I_StartupSystem(void) -{ - SDL_version SDLcompiled; - const SDL_version *SDLlinked; -#ifdef _XBOX -#ifdef __GNUC__ - char DP[] =" Sonic Robo Blast 2!\n"; - debugPrint(DP); -#endif - unlink("e:/Games/SRB2/stdout.txt"); - freopen("e:/Games/SRB2/stdout.txt", "w+", stdout); - unlink("e:/Games/SRB2/stderr.txt"); - freopen("e:/Games/SRB2/stderr.txt", "w+", stderr); -#endif -#ifdef _arch_dreamcast -#ifdef _DEBUG - //gdb_init(); -#endif - printf(__FILE__":%i\n",__LINE__); -#ifdef _DEBUG - //gdb_breakpoint(); -#endif -#endif - SDL_VERSION(&SDLcompiled) - SDLlinked = SDL_Linked_Version(); - I_StartupConsole(); - I_OutputMsg("Compiled for SDL version: %d.%d.%d\n", - SDLcompiled.major, SDLcompiled.minor, SDLcompiled.patch); - I_OutputMsg("Linked with SDL version: %d.%d.%d\n", - SDLlinked->major, SDLlinked->minor, SDLlinked->patch); -#if 0 //#ifdef GP2X //start up everything - if (SDL_Init(SDL_INIT_NOPARACHUTE|SDL_INIT_EVERYTHING) < 0) -#else - if (SDL_Init(SDL_INIT_NOPARACHUTE) < 0) -#endif - I_Error("SRB2: SDL System Error: %s", SDL_GetError()); //Alam: Oh no.... -#ifndef NOMUMBLE - I_SetupMumble(); -#endif - return 0; -} - - -// -// I_Quit -// -void I_Quit(void) -{ - static SDL_bool quiting = SDL_FALSE; - - /* prevent recursive I_Quit() */ - if (quiting) goto death; - SDLforceUngrabMouse(); - quiting = SDL_FALSE; - I_ShutdownConsole(); - M_SaveConfig(NULL); //save game config, cvars.. -#ifndef NONET - D_SaveBan(); // save the ban list -#endif - G_SaveGameData(); // Tails 12-08-2002 - //added:16-02-98: when recording a demo, should exit using 'q' key, - // but sometimes we forget and use 'F10'.. so save here too. - - if (demorecording) - G_CheckDemoStatus(); - if (metalrecording) - G_StopMetalRecording(); - - D_QuitNetGame(); - I_ShutdownMusic(); - I_ShutdownSound(); - I_ShutdownCD(); - // use this for 1.28 19990220 by Kin - I_ShutdownGraphics(); - I_ShutdownInput(); - I_ShutdownSystem(); -#ifndef _arch_dreamcast - SDL_Quit(); -#endif - /* if option -noendtxt is set, don't print the text */ - if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM") != LUMPERROR) - { - printf("\r"); - ShowEndTxt(); - } - if (myargmalloc) - free(myargv); // Deallocate allocated memory -death: - W_Shutdown(); -#ifdef GP2X - chdir("/usr/gp2x"); - execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL); -#endif - exit(0); -} - -void I_WaitVBL(INT32 count) -{ - count = 1; - SDL_Delay(count); -} - -void I_BeginRead(void) -{ -} - -void I_EndRead(void) -{ -} - -// -// I_Error -// -/** \brief phuck recursive errors -*/ -static INT32 errorcount = 0; - -/** \brief recursive error detecting -*/ -static boolean shutdowning = false; - -void I_Error(const char *error, ...) -{ - va_list argptr; -#if (defined (MAC_ALERT) || defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) - char buffer[8192]; -#endif - - // recursive error detecting - if (shutdowning) - { - errorcount++; - if (errorcount == 1) - SDLforceUngrabMouse(); - // try to shutdown each subsystem separately - if (errorcount == 2) - I_ShutdownMusic(); - if (errorcount == 3) - I_ShutdownSound(); - if (errorcount == 4) - I_ShutdownCD(); - if (errorcount == 5) - I_ShutdownGraphics(); - if (errorcount == 6) - I_ShutdownInput(); - if (errorcount == 7) - I_ShutdownSystem(); -#ifndef _arch_dreamcast - if (errorcount == 8) - SDL_Quit(); -#endif - if (errorcount == 9) - { - M_SaveConfig(NULL); - G_SaveGameData(); - } - if (errorcount > 20) - { -#ifdef MAC_ALERT - va_start(argptr, error); - vsprintf(buffer, error, argptr); - va_end(argptr); - // 2004-03-03 AJR Since the Mac user is most likely double clicking to run the game, give them a panel. - MacShowAlert("Recursive Error", buffer, "Quit", NULL, NULL); -#elif (defined (_WIN32) || (defined (_WIN32_WCE)) && !defined (__GNUC__)) && !defined (_XBOX) - va_start(argptr,error); - vsprintf(buffer, error, argptr); - va_end(argptr); -#ifndef _WIN32_WCE - { - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD bytesWritten; - if (co != INVALID_HANDLE_VALUE) - { - if (GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &bytesWritten)) - WriteConsoleA(co, buffer, (DWORD)strlen(buffer), NULL, NULL); - else - WriteFile(co, buffer, (DWORD)strlen(buffer), &bytesWritten, NULL); - } - } -#endif - OutputDebugStringA(buffer); - MessageBoxA(vid.WndParent, buffer, "SRB2 Recursive Error", MB_OK|MB_ICONERROR); -#else - // Don't print garbage - va_start(argptr, error); - if (!framebuffer) - vfprintf (stderr, error, argptr); - va_end(argptr); -#endif - W_Shutdown(); -#ifdef GP2X - chdir("/usr/gp2x"); - execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL); -#endif - exit(-1); // recursive errors detected - } - } - shutdowning = true; - I_ShutdownConsole(); -#ifndef MAC_ALERT - // Message first. - va_start(argptr,error); - if (!framebuffer) - { - fprintf(stderr, "Error: "); - vfprintf(stderr,error,argptr); - fprintf(stderr, "\n"); - } - va_end(argptr); - - if (!framebuffer) - fflush(stderr); -#endif - M_SaveConfig(NULL); // save game config, cvars.. -#ifndef NONET - D_SaveBan(); // save the ban list -#endif - G_SaveGameData(); // Tails 12-08-2002 - - // Shutdown. Here might be other errors. - if (demorecording) - G_CheckDemoStatus(); - if (metalrecording) - G_StopMetalRecording(); - - D_QuitNetGame(); - I_ShutdownMusic(); - I_ShutdownSound(); - I_ShutdownCD(); - // use this for 1.28 19990220 by Kin - I_ShutdownGraphics(); - I_ShutdownInput(); - I_ShutdownSystem(); -#ifndef _arch_dreamcast - SDL_Quit(); -#endif -#ifdef MAC_ALERT - va_start(argptr, error); - vsprintf(buffer, error, argptr); - va_end(argptr); - // 2004-03-03 AJR Since the Mac user is most likely double clicking to run the game, give them a panel. - MacShowAlert("Critical Error", buffer, "Quit", NULL, NULL); -#endif - W_Shutdown(); -#if defined (PARANOIA) && defined (__CYGWIN__) - *(INT32 *)2 = 4; //Alam: Debug! -#endif -#ifdef GP2X - chdir("/usr/gp2x"); - execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL); -#endif - exit(-1); -} - -/** \brief quit function table -*/ -static quitfuncptr quit_funcs[MAX_QUIT_FUNCS]; /* initialized to all bits 0 */ - -// -// Adds a function to the list that need to be called by I_SystemShutdown(). -// -void I_AddExitFunc(void (*func)()) -{ - INT32 c; - - for (c = 0; c < MAX_QUIT_FUNCS; c++) - { - if (!quit_funcs[c]) - { - quit_funcs[c] = func; - break; - } - } -} - - -// -// Removes a function from the list that need to be called by -// I_SystemShutdown(). -// -void I_RemoveExitFunc(void (*func)()) -{ - INT32 c; - - for (c = 0; c < MAX_QUIT_FUNCS; c++) - { - if (quit_funcs[c] == func) - { - while (c < MAX_QUIT_FUNCS-1) - { - quit_funcs[c] = quit_funcs[c+1]; - c++; - } - quit_funcs[MAX_QUIT_FUNCS-1] = NULL; - break; - } - } -} - -// -// Closes down everything. This includes restoring the initial -// palette and video mode, and removing whatever mouse, keyboard, and -// timer routines have been installed. -// -// NOTE: Shutdown user funcs are effectively called in reverse order. -// -void I_ShutdownSystem(void) -{ - INT32 c; - - for (c = MAX_QUIT_FUNCS-1; c >= 0; c--) - if (quit_funcs[c]) - (*quit_funcs[c])(); -#ifdef LOGMESSAGES - if (logstream) - { - fclose(logstream); - logstream = NULL; - } -#endif - -} - -void I_GetDiskFreeSpace(INT64 *freespace) -{ -#if defined (_arch_dreamcast) || defined (_PSP) - *freespace = 0; -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#if defined (SOLARIS) || defined (__HAIKU__) || defined (_WII) || defined (_PS3) - *freespace = INT32_MAX; - return; -#else // Both Linux and BSD have this, apparently. - struct statfs stfs; - if (statfs(".", &stfs) == -1) - { - *freespace = INT32_MAX; - return; - } - *freespace = stfs.f_bavail * stfs.f_bsize; -#endif -#elif (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) - static p_GetDiskFreeSpaceExA pfnGetDiskFreeSpaceEx = NULL; - static boolean testwin95 = false; - ULARGE_INTEGER usedbytes, lfreespace; - - if (!testwin95) - { - pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); - testwin95 = true; - } - if (pfnGetDiskFreeSpaceEx) - { - if (pfnGetDiskFreeSpaceEx(NULL, &lfreespace, &usedbytes, NULL)) - *freespace = lfreespace.QuadPart; - else - *freespace = INT32_MAX; - } - else - { - DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters; - GetDiskFreeSpace(NULL, &SectorsPerCluster, &BytesPerSector, - &NumberOfFreeClusters, &TotalNumberOfClusters); - *freespace = BytesPerSector*SectorsPerCluster*NumberOfFreeClusters; - } -#else // Dummy for platform independent; 1GB should be enough - *freespace = 1024*1024*1024; -#endif -} - -char *I_GetUserName(void) -{ -#ifdef GP2X - static char username[MAXPLAYERNAME] = "GP2XUSER"; - return username; -#elif defined (PSP) - static char username[MAXPLAYERNAME] = "PSPUSER"; - return username; -#elif !(defined (_WIN32_WCE) || defined (_XBOX)) - static char username[MAXPLAYERNAME]; - char *p; -#ifdef _WIN32 - DWORD i = MAXPLAYERNAME; - - if (!GetUserNameA(username, &i)) -#endif - { - p = I_GetEnv("USER"); - if (!p) - { - p = I_GetEnv("user"); - if (!p) - { - p = I_GetEnv("USERNAME"); - if (!p) - { - p = I_GetEnv("username"); - if (!p) - { - return NULL; - } - } - } - } - strncpy(username, p, MAXPLAYERNAME); - } - - - if (strcmp(username, "") != 0) - return username; -#endif - return NULL; // dummy for platform independent version -} - -INT32 I_mkdir(const char *dirname, INT32 unixright) -{ -//[segabor] -#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) || defined (__CYGWIN__) || defined (__OS2__) - return mkdir(dirname, unixright); -#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) - UNREFERENCED_PARAMETER(unixright); /// \todo should implement ntright under nt... - return CreateDirectoryA(dirname, NULL); -#else - (void)dirname; - (void)unixright; - return false; -#endif -} - -char *I_GetEnv(const char *name) -{ -#ifdef NEED_SDL_GETENV - return SDL_getenv(name); -#elif defined(_WIN32_WCE) - (void)name; - return NULL; -#else - return getenv(name); -#endif -} - -INT32 I_PutEnv(char *variable) -{ -#ifdef NEED_SDL_GETENV - return SDL_putenv(variable); -#elif defined(_WIN32_WCE) - return ((variable)?-1:0); -#else - return putenv(variable); -#endif -} - -INT32 I_ClipboardCopy(const char *data, size_t size) -{ - (void)data; - (void)size; - return -1; -} - -char *I_ClipboardPaste(void) -{ - return NULL; -} - -/** \brief The isWadPathOk function - - \param path string path to check - - \return if true, wad file found - - -*/ -static boolean isWadPathOk(const char *path) -{ - char *wad3path = malloc(256); - - if (!wad3path) - return false; - - sprintf(wad3path, pandf, path, WADKEYWORD1); - - if (FIL_ReadFileOK(wad3path)) - { - free(wad3path); - return true; - } - - sprintf(wad3path, pandf, path, WADKEYWORD2); - - if (FIL_ReadFileOK(wad3path)) - { - free(wad3path); - return true; - } - - free(wad3path); - return false; -} - -static void pathonly(char *s) -{ - size_t j; - - for (j = strlen(s); j != (size_t)-1; j--) - if ((s[j] == '\\') || (s[j] == ':') || (s[j] == '/')) - { - if (s[j] == ':') s[j+1] = 0; - else s[j] = 0; - return; - } -} - -/** \brief search for srb2.srb in the given path - - \param searchDir starting path - - \return WAD path if not NULL - - -*/ -static const char *searchWad(const char *searchDir) -{ - static char tempsw[256] = ""; - filestatus_t fstemp; - - strcpy(tempsw, WADKEYWORD1); - fstemp = filesearch(tempsw,searchDir,NULL,true,20); - if (fstemp == FS_FOUND) - { - pathonly(tempsw); - return tempsw; - } - - strcpy(tempsw, WADKEYWORD2); - fstemp = filesearch(tempsw, searchDir, NULL, true, 20); - if (fstemp == FS_FOUND) - { - pathonly(tempsw); - return tempsw; - } - return NULL; -} - -/** \brief go through all possible paths and look for srb2.srb - - \return path to srb2.srb if any -*/ -static const char *locateWad(void) -{ - const char *envstr; - const char *WadPath; - - I_OutputMsg("SRB2WADDIR"); - // does SRB2WADDIR exist? - if (((envstr = I_GetEnv("SRB2WADDIR")) != NULL) && isWadPathOk(envstr)) - return envstr; - -#if defined(_WIN32_WCE) || defined(_PS3) || defined(_PSP) - // examine argv[0] - strcpy(returnWadPath, myargv[0]); - pathonly(returnWadPath); - I_PutEnv(va("HOME=%s",returnWadPath)); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif - -#ifndef NOCWD - I_OutputMsg(",."); - // examine current dir - strcpy(returnWadPath, "."); - if (isWadPathOk(returnWadPath)) - return NULL; -#endif - - // examine default dirs -#ifdef DEFAULTWADLOCATION1 - I_OutputMsg(","DEFAULTWADLOCATION1); - strcpy(returnWadPath, DEFAULTWADLOCATION1); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifdef DEFAULTWADLOCATION2 - I_OutputMsg(","DEFAULTWADLOCATION2); - strcpy(returnWadPath, DEFAULTWADLOCATION2); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifdef DEFAULTWADLOCATION3 - I_OutputMsg(","DEFAULTWADLOCATION3); - strcpy(returnWadPath, DEFAULTWADLOCATION3); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifdef DEFAULTWADLOCATION4 - I_OutputMsg(","DEFAULTWADLOCATION4); - strcpy(returnWadPath, DEFAULTWADLOCATION4); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifdef DEFAULTWADLOCATION5 - I_OutputMsg(","DEFAULTWADLOCATION5); - strcpy(returnWadPath, DEFAULTWADLOCATION5); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifdef DEFAULTWADLOCATION6 - I_OutputMsg(","DEFAULTWADLOCATION6); - strcpy(returnWadPath, DEFAULTWADLOCATION6); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifdef DEFAULTWADLOCATION7 - I_OutputMsg(","DEFAULTWADLOCATION7); - strcpy(returnWadPath, DEFAULTWADLOCATION7); - if (isWadPathOk(returnWadPath)) - return returnWadPath; -#endif -#ifndef NOHOME - // find in $HOME - I_OutputMsg(",HOME"); - if ((envstr = I_GetEnv("HOME")) != NULL) - { - WadPath = searchWad(envstr); - if (WadPath) - return WadPath; - } -#endif -#ifdef DEFAULTSEARCHPATH1 - // find in /usr/local - I_OutputMsg(", in:"DEFAULTSEARCHPATH1); - WadPath = searchWad(DEFAULTSEARCHPATH1); - if (WadPath) - return WadPath; -#endif -#ifdef DEFAULTSEARCHPATH2 - // find in /usr/games - I_OutputMsg(", in:"DEFAULTSEARCHPATH2); - WadPath = searchWad(DEFAULTSEARCHPATH2); - if (WadPath) - return WadPath; -#endif -#ifdef DEFAULTSEARCHPATH3 - // find in ??? - I_OutputMsg(", in:"DEFAULTSEARCHPATH3); - WadPath = searchWad(DEFAULTSEARCHPATH3); - if (WadPath) - return WadPath; -#endif - // if nothing was found - return NULL; -} - -const char *I_LocateWad(void) -{ - const char *waddir; - - I_OutputMsg("Looking for WADs in: "); - waddir = locateWad(); - I_OutputMsg("\n"); - - if (waddir) - { - // change to the directory where we found srb2.srb -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) - SetCurrentDirectoryA(waddir); -#elif !defined (_WIN32_WCE) && !defined (_PS3) - if (chdir(waddir) == -1) - I_OutputMsg("Couldn't change working directory\n"); -#endif - } - return waddir; -} - -#ifdef LINUX -#define MEMINFO_FILE "/proc/meminfo" -#define MEMTOTAL "MemTotal:" -#define MEMFREE "MemFree:" -#endif - -// quick fix for compil -UINT32 I_GetFreeMem(UINT32 *total) -{ -#if defined (_arch_dreamcast) - //Dreamcast! - if (total) - *total = 16<<20; - return 8<<20; -#elif defined (_PSP) - // PSP - if (total) - *total = 32<<20; - return 16<<20; -#elif defined (FREEBSD) - struct vmmeter sum; - kvm_t *kd; - struct nlist namelist[] = - { -#define X_SUM 0 - {"_cnt"}, - {NULL} - }; - if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) - { - *total = 0L; - return 0; - } - if (kvm_nlist(kd, namelist) != 0) - { - kvm_close (kd); - *total = 0L; - return 0; - } - if (kvm_read(kd, namelist[X_SUM].n_value, &sum, - sizeof (sum)) != sizeof (sum)) - { - kvm_close(kd); - *total = 0L; - return 0; - } - kvm_close(kd); - - if (total) - *total = sum.v_page_count * sum.v_page_size; - return sum.v_free_count * sum.v_page_size; -#elif defined (SOLARIS) - /* Just guess */ - if (total) - *total = 32 << 20; - return 32 << 20; -#elif defined (LINUX) - /* Linux */ - char buf[1024]; - char *memTag; - UINT32 freeKBytes; - UINT32 totalKBytes; - INT32 n; - INT32 meminfo_fd = -1; - - meminfo_fd = open(MEMINFO_FILE, O_RDONLY); - n = read(meminfo_fd, buf, 1023); - close(meminfo_fd); - - if (n < 0) - { - // Error - *total = 0L; - return 0; - } - - buf[n] = '\0'; - if (NULL == (memTag = strstr(buf, MEMTOTAL))) - { - // Error - *total = 0L; - return 0; - } - - memTag += sizeof (MEMTOTAL); - totalKBytes = atoi(memTag); - - if (NULL == (memTag = strstr(buf, MEMFREE))) - { - // Error - *total = 0L; - return 0; - } - - memTag += sizeof (MEMFREE); - freeKBytes = atoi(memTag); - - if (total) - *total = totalKBytes << 10; - return freeKBytes << 10; -#elif (defined (_WIN32) || (defined (_WIN32_WCE) && !defined (__GNUC__))) && !defined (_XBOX) - MEMORYSTATUS info; - - info.dwLength = sizeof (MEMORYSTATUS); - GlobalMemoryStatus( &info ); - if (total) - *total = (UINT32)info.dwTotalPhys; - return (UINT32)info.dwAvailPhys; -#elif defined (__OS2__) - UINT32 pr_arena; - - if (total) - DosQuerySysInfo( QSV_TOTPHYSMEM, QSV_TOTPHYSMEM, - (PVOID) total, sizeof (UINT32)); - DosQuerySysInfo( QSV_MAXPRMEM, QSV_MAXPRMEM, - (PVOID) &pr_arena, sizeof (UINT32)); - - return pr_arena; -#else - // Guess 48 MB. - if (total) - *total = 48<<20; - return 48<<20; -#endif /* LINUX */ -} - -const CPUInfoFlags *I_CPUInfo(void) -{ -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) - static CPUInfoFlags WIN_CPUInfo; - SYSTEM_INFO SI; - p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); - - ZeroMemory(&WIN_CPUInfo,sizeof (WIN_CPUInfo)); - if (pfnCPUID) - { - WIN_CPUInfo.FPPE = pfnCPUID( 0); //PF_FLOATING_POINT_PRECISION_ERRATA - WIN_CPUInfo.FPE = pfnCPUID( 1); //PF_FLOATING_POINT_EMULATED - WIN_CPUInfo.cmpxchg = pfnCPUID( 2); //PF_COMPARE_EXCHANGE_DOUBLE - WIN_CPUInfo.MMX = pfnCPUID( 3); //PF_MMX_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.PPCMM64 = pfnCPUID( 4); //PF_PPC_MOVEMEM_64BIT_OK - WIN_CPUInfo.ALPHAbyte = pfnCPUID( 5); //PF_ALPHA_BYTE_INSTRUCTIONS - WIN_CPUInfo.SSE = pfnCPUID( 6); //PF_XMMI_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.AMD3DNow = pfnCPUID( 7); //PF_3DNOW_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.RDTSC = pfnCPUID( 8); //PF_RDTSC_INSTRUCTION_AVAILABLE - WIN_CPUInfo.PAE = pfnCPUID( 9); //PF_PAE_ENABLED - WIN_CPUInfo.SSE2 = pfnCPUID(10); //PF_XMMI64_INSTRUCTIONS_AVAILABLE - //WIN_CPUInfo.blank = pfnCPUID(11); //PF_SSE_DAZ_MODE_AVAILABLE - WIN_CPUInfo.DEP = pfnCPUID(12); //PF_NX_ENABLED - WIN_CPUInfo.SSE3 = pfnCPUID(13); //PF_SSE3_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.cmpxchg16b = pfnCPUID(14); //PF_COMPARE_EXCHANGE128 - WIN_CPUInfo.cmp8xchg16 = pfnCPUID(15); //PF_COMPARE64_EXCHANGE128 - WIN_CPUInfo.PFC = pfnCPUID(16); //PF_CHANNELS_ENABLED - } -#ifdef HAVE_SDLCPUINFO - else - { - WIN_CPUInfo.RDTSC = SDL_HasRDTSC(); - WIN_CPUInfo.MMX = SDL_HasMMX(); - WIN_CPUInfo.AMD3DNow = SDL_Has3DNow(); - WIN_CPUInfo.SSE = SDL_HasSSE(); - WIN_CPUInfo.SSE2 = SDL_HasSSE2(); - WIN_CPUInfo.AltiVec = SDL_HasAltiVec(); - } - WIN_CPUInfo.MMXExt = SDL_HasMMXExt(); - WIN_CPUInfo.AMD3DNowExt = SDL_Has3DNowExt(); -#endif - GetSystemInfo(&SI); - WIN_CPUInfo.CPUs = SI.dwNumberOfProcessors; - WIN_CPUInfo.IA64 = (SI.dwProcessorType == 2200); // PROCESSOR_INTEL_IA64 - WIN_CPUInfo.AMD64 = (SI.dwProcessorType == 8664); // PROCESSOR_AMD_X8664 - return &WIN_CPUInfo; -#elif defined (HAVE_SDLCPUINFO) - static CPUInfoFlags SDL_CPUInfo; - memset(&SDL_CPUInfo,0,sizeof (CPUInfoFlags)); - SDL_CPUInfo.RDTSC = SDL_HasRDTSC(); - SDL_CPUInfo.MMX = SDL_HasMMX(); - SDL_CPUInfo.MMXExt = SDL_HasMMXExt(); - SDL_CPUInfo.AMD3DNow = SDL_Has3DNow(); - SDL_CPUInfo.AMD3DNowExt = SDL_Has3DNowExt(); - SDL_CPUInfo.SSE = SDL_HasSSE(); - SDL_CPUInfo.SSE2 = SDL_HasSSE2(); - SDL_CPUInfo.AltiVec = SDL_HasAltiVec(); - return &SDL_CPUInfo; -#else - return NULL; /// \todo CPUID asm -#endif -} - -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) -static void CPUAffinity_OnChange(void); -static consvar_t cv_cpuaffinity = {"cpuaffinity", "-1", CV_SAVE | CV_CALL, NULL, CPUAffinity_OnChange, 0, NULL, NULL, 0, 0, NULL}; - -static p_GetCurrentProcess pfnGetCurrentProcess = NULL; -static p_GetProcessAffinityMask pfnGetProcessAffinityMask = NULL; -static p_SetProcessAffinityMask pfnSetProcessAffinityMask = NULL; - -static inline VOID GetAffinityFuncs(VOID) -{ - HMODULE h = GetModuleHandleA("kernel32.dll"); - pfnGetCurrentProcess = (p_GetCurrentProcess)GetProcAddress(h, "GetCurrentProcess"); - pfnGetProcessAffinityMask = (p_GetProcessAffinityMask)GetProcAddress(h, "GetProcessAffinityMask"); - pfnSetProcessAffinityMask = (p_SetProcessAffinityMask)GetProcAddress(h, "SetProcessAffinityMask"); -} - -static void CPUAffinity_OnChange(void) -{ - DWORD_PTR dwProcMask, dwSysMask; - HANDLE selfpid; - - if (!pfnGetCurrentProcess || !pfnGetProcessAffinityMask || !pfnSetProcessAffinityMask) - return; - else - selfpid = pfnGetCurrentProcess(); - - pfnGetProcessAffinityMask(selfpid, &dwProcMask, &dwSysMask); - - /* If resulting mask is zero, don't change anything and fall back to - * actual mask. - */ - if(dwSysMask & cv_cpuaffinity.value) - { - pfnSetProcessAffinityMask(selfpid, dwSysMask & cv_cpuaffinity.value); - CV_StealthSetValue(&cv_cpuaffinity, (INT32)(dwSysMask & cv_cpuaffinity.value)); - } - else - CV_StealthSetValue(&cv_cpuaffinity, (INT32)dwProcMask); -} -#endif - -void I_RegisterSysCommands(void) -{ -#if (defined (_WIN32) && !defined (_WIN32_WCE)) && !defined (_XBOX) - GetAffinityFuncs(); - CV_RegisterVar(&cv_cpuaffinity); -#endif -} -#endif diff --git a/src/sdl12/i_ttf.c b/src/sdl12/i_ttf.c deleted file mode 100644 index 770a81d98..000000000 --- a/src/sdl12/i_ttf.c +++ /dev/null @@ -1,340 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2011 by Callum Dickinson. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL_ttf interface code. Necessary for platforms with no framebuffer console systems. - -#if defined(SDL) && defined(HAVE_TTF) -#include "SDL.h" -#include "SDL_ttf.h" -#include "../doomdef.h" -#include "../doomstat.h" -#include "../d_netfil.h" -#include "../filesrch.h" -#include "i_ttf.h" - -// Search directories to find aforementioned TTF file. -#ifdef _PS3 -#include -#define FONTSEARCHPATH1 "/dev_hdd0/game/SRB2-PS3_/USRDIR/etc" -#elif defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#define FONTSEARCHPATH1 "/usr/share/fonts" -#define FONTSEARCHPATH2 "/usr/local/share/fonts" -#define FONTSEARCHPATH3 "/usr/games/SRB2" -#define FONTSEARCHPATH4 "/usr/local/games/SRB2" -#define FONTSEARCHPATH5 "/usr/local/share/games/SRB2" -#else -#define FONTSEARCHPATH1 "." -#endif - -#define FONTHANDLE -1 - -// Renduring surfaces. -SDL_Surface *TTFSurface = NULL; -SDL_Surface *TTFRendSurface = NULL; -// Text box. -SDL_Rect TTFRect; -// Temporary storage for the new TTFRect, used to check for -// line wrapping. -SDL_Rect TTFRectCheck; -// Text rendering resolution. -videoResolution res; -// Text storage buffer, the contents get printed to the SDL surface. -char textbuffer[8192]; - -// look for default ttf file in given directory -static char *searchFont(const char *fontsearchDir) -{ - static char tempsw[256] = ""; - filestatus_t fstemp; - - strcpy(tempsw, FONTFILE); - fstemp = filesearch(tempsw, fontsearchDir, NULL, true, 20); - if (fstemp == FS_FOUND) - { - return tempsw; - } - return NULL; -} - -// Load TTF font from file. -INT32 I_TTFLoadFont(const char *file, UINT32 ptsize) -{ - TTF_Font *tmpfont = NULL; - float fontsize; - - // If a font is currently loaded, unload it. - if (currentfont) - { - TTF_CloseFont(currentfont); - } - - // Scale the specified font point size for the current resolution. - fontsize = (ptsize * 0.005f) * (res.width - res.height); - - tmpfont = TTF_OpenFont(file, fontsize); - - if (!tmpfont) - return FONTHANDLE; - - // set pointer for current font - currentfont = tmpfont; - - // set current font point size - currentfontpoint = ptsize; - - // get font properties, and set them - currentfontstyle = TTF_GetFontStyle(currentfont); - TTF_SetFontStyle(currentfont, currentfontstyle); - - // these functions only exist in SDL_ttf 2.0.10 onwards -#if SDL_TTF_VERSION_ATLEAST(2,0,10) - currentfontkerning = TTF_GetFontKerning(currentfont); - TTF_SetFontKerning(currentfont, currentfontkerning); - - currentfonthinting = TTF_GetFontHinting(currentfont); - TTF_SetFontHinting(currentfont, currentfonthinting); - - currentfontoutline = TTF_GetFontOutline(currentfont); - TTF_SetFontOutline(currentfont, currentfontoutline); -#endif - - return 0; -} - -static void I_TTFRendSurface(const char *textmsg, TTF_Font *font, TextQuality quality, SDL_Color fontfgcolor, SDL_Color fontbgcolor) -{ - // Print text in the buffer. - // SDL_ttf has three modes to draw text. - // Solid rendering is quick, but dirty. Use it if you need speed more than quality. - switch (quality) - { - case solid: - TTFRendSurface = TTF_RenderText_Solid(font, textmsg, fontfgcolor); - break; - // Shaded rendering adds a background to the rendered text. Because of this, I_TTFDrawText - // takes an extra color more than the other styles to be a background color. - // Shaded is supposedly as fast as solid rendering and about as good quality as blended. - case shaded: - TTFRendSurface = TTF_RenderText_Shaded(font, textmsg, fontfgcolor, fontbgcolor); - break; - // Blended rendering is the opposite of solid. Good quality, but slow. - case blended: - TTFRendSurface = TTF_RenderText_Blended(font, textmsg, fontfgcolor); - break; - } - - // Get SDL to update the main surface. - SDL_BlitSurface(TTFRendSurface, NULL, TTFSurface, &TTFRect); - SDL_Flip(TTFSurface); -} - -// Draw text to screen. It will accept four colour vales (red, green, blue and alpha) -// with foreground for draw modes Solid and Blended, and an extra four values for background -// colour with draw type Shaded. -void I_TTFDrawText(TTF_Font *font, TextQuality quality, INT32 fgR, INT32 fgG, INT32 fgB, INT32 fgA, INT32 bgR, INT32 bgG, INT32 bgB, INT32 bgA, const char *textmsg) -{ - // Temporary small buffer to store character to process. - // NULL pointer to prevc to kill warning - char c, prevc = 0x0; - // hack to allow TTF_SizeText to work properly. - char linebuffer[2]; - // Don't need h, but TTF_SizeText needs a height parameter - INT32 w, h; - - // Globally declare foreground and background text colours, - // text drawing mode and the font to draw. - SDL_Color fontfgcolor = {fgR, fgG, fgB, fgA}; - SDL_Color fontbgcolor = {bgR, bgG, bgB, bgA}; - - // Keep on processing until the null terminator in the text buffer is reached. - while (*textmsg != '\0') - { - // Copy pointer for current character into the temporary buffer. - c = *textmsg; - // If c is a newline, move to the next available line. - if (c == '\n') - { - TTFRectCheck.x = 0; - TTFRectCheck.y += (currentfontpoint + 1); - } - // Otherwise... - else - { - // If the previous character was a newline, actually move to the next line. - if (prevc == '\n') - { - if (textbuffer != NULL) - { - // Render cached text to the SDL surface. - I_TTFRendSurface(textbuffer, font, quality, fontfgcolor, fontbgcolor); - // Empty text buffer. - memset(textbuffer, '\0', 1); - } - TTFRect.x = TTFRectCheck.x; - TTFRect.y = TTFRectCheck.y; - } - // Copy the character to the text buffer. - sprintf(textbuffer, "%s%c", textbuffer, c); - // Hack to allow TTF_SizeText to work properly. - sprintf(linebuffer, "%c", c); - // If we have reached the end of the screen, move to the next available line. - TTF_SizeText(currentfont, linebuffer, &w, &h); - TTFRectCheck.x += w; - if (TTFRectCheck.x >= res.width) - { - // Render cached text to the SDL surface. - I_TTFRendSurface(textbuffer, font, quality, fontfgcolor, fontbgcolor); - // Empty text buffer. - memset(textbuffer, '\0', 1); - // Move to the next line. - TTFRectCheck.x = 0; - TTFRectCheck.y += (currentfontpoint + 1); - // Set stored co-ordinates for next line. - TTFRect.x = TTFRectCheck.x; - TTFRect.y = TTFRectCheck.y; - } - } - // Add 1 to the pointer reference for the character to process. - textmsg++; - // Copy contents of the now-old buffer to somewhere else, so it can be referenced in next loop. - prevc = c; - } - - // If the buffer was previously emptied by a line wrapping operation and - // no text came after that, don't print anything. Otherwise, print everything - // still in the buffer. - if (textbuffer != NULL) - { - // Render cached text to the SDL surface. - I_TTFRendSurface(textbuffer, font, quality, fontfgcolor, fontbgcolor); - // Empty text buffer. - memset(textbuffer, '\0', 1); - // Set stored co-ordinates for next line. - TTFRect.x = TTFRectCheck.x; - TTFRect.y = TTFRectCheck.y; - } -} - -// Initialise SDL_ttf. -void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags) -{ - char *fontpath = NULL; - INT32 fontstatus = -1; -#ifdef _PS3 - videoState state; - videoGetState(0, 0, &state); - videoGetResolution(state.displayMode.resolution, &res); - bitsperpixel = 24; -#else - res.width = 320; - res.height = 200; - bitsperpixel = 8; -#endif - - // what's the point of trying to display an error? - // SDL_ttf is not started, can't display anything to screen (presumably)... - if (SDL_InitSubSystem(initflags) < 0) - I_Error("Couldn't initialize SDL: %s\n", SDL_GetError()); - - TTFSurface = SDL_SetVideoMode(res.width, res.height, bitsperpixel, vidmodeflags); - if (!TTFSurface) - I_Error("Couldn't set SDL Video resolution: %s\n", SDL_GetError()); - - if (TTF_Init() < 0) - I_Error("Couldn't start SDL_ttf: %s\n", TTF_GetError()); - - // look for default font in many directories -#ifdef FONTSEARCHPATH1 - fontpath = searchFont(FONTSEARCHPATH1); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); -#endif -#ifdef FONTSEARCHPATH2 - if (fontstatus < 0) - { - fontpath = searchFont(FONTSEARCHPATH2); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); - } -#endif -#ifdef FONTSEARCHPATH3 - if (fontstatus < 0) - { - fontpath = searchFont(FONTSEARCHPATH3); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); - } -#endif -#ifdef FONTSEARCHPATH4 - if (fontstatus < 0) - { - fontpath = searchFont(FONTSEARCHPATH4); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); - } -#endif -#ifdef FONTSEARCHPATH5 - if (fontstatus < 0) - { - fontpath = searchFont(FONTSEARCHPATH5); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); - } -#endif -#ifdef FONTSEARCHPATH6 - if (fontstatus < 0) - { - fontpath = searchFont(FONTSEARCHPATH6); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); - } -#endif -#ifdef FONTSEARCHPATH7 - if (fontstatus < 0) - { - fontpath = searchFont(FONTSEARCHPATH7); - if (fontpath) fontstatus = I_TTFLoadFont(fontpath, fontpointsize); - } -#endif - // argh! no font file found! disable SDL_ttf code - if (fontstatus < 0) - { - I_ShutdownTTF(); - CONS_Printf("Unable to find default font files! Not loading SDL_ttf\n"); - } - else - { - // Get SDL_ttf compiled and linked version - SDL_version TTFcompiled; - const SDL_version *TTFlinked; - - SDL_TTF_VERSION(&TTFcompiled); - TTFlinked = TTF_Linked_Version(); - - // Display it on screen - CONS_Printf("Compiled for SDL_ttf version: %d.%d.%d\n", - TTFcompiled.major, TTFcompiled.minor, TTFcompiled.patch); - CONS_Printf("Linked with SDL_ttf version: %d.%d.%d\n", - TTFlinked->major, TTFlinked->minor, TTFlinked->patch); - } -} - -void I_ShutdownTTF(void) -{ - // close current font - TTF_CloseFont(currentfont); - // shutdown SDL_ttf - TTF_Quit(); - - // Free TTF rendering surfaces. - SDL_FreeSurface(TTFSurface); - SDL_FreeSurface(TTFRendSurface); -} -#endif diff --git a/src/sdl12/i_ttf.h b/src/sdl12/i_ttf.h deleted file mode 100644 index 929c8021c..000000000 --- a/src/sdl12/i_ttf.h +++ /dev/null @@ -1,88 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2011 by Callum Dickinson. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL_ttf interface code. Necessary for platforms with SDL inits that need to run immediately. - -#ifndef __I_TTF__ -#define __I_TTF__ - -#include "../doomdef.h" -#include "SDL_ttf.h" - -// Default name for standard TTF file. -#define FONTFILE "srb2.ttf" -#define FONTPOINTSIZE 12 - -// Default font foreground colours -#define DEFAULTFONTFGR 255 -#define DEFAULTFONTFGG 255 -#define DEFAULTFONTFGB 255 -#define DEFAULTFONTFGA 255 - -// Default font background colours -#define DEFAULTFONTBGR 0 -#define DEFAULTFONTBGG 0 -#define DEFAULTFONTBGB 0 -#define DEFAULTFONTBGA 255 - -#ifndef SDL_TTF_COMPILEDVERSION -#define SDL_TTF_COMPILEDVERSION \ - SDL_VERSIONNUM(TTF_MAJOR_VERSION, TTF_MINOR_VERSION, TTF_PATCHLEVEL) -#endif - -#ifndef SDL_TTF_VERSION_ATLEAST -#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \ - (SDL_TTF_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) -#endif - -TTF_Font* currentfont; -int currentfontpoint; -int currentfontstyle; -#if SDL_TTF_VERSION_ATLEAST(2,0,10) -int currentfontkerning; -int currentfonthinting; -int currentfontoutline; -#endif - -#ifndef _PS3 -typedef struct -{ - UINT16 width; - UINT16 height; -} VideoResolution; -#endif -UINT8 bitsperpixel; - -typedef enum -{ - solid, - shaded, - blended -} TextQuality; - -// Load TTF font from file. -INT32 I_TTFLoadFont(const char *file, UINT32 ptsize); - -// Draw TTF text to screen. It will accept four colour vales (red, green, blue and alpha) -// with foreground for draw modes Solid and Blended, and an extra four values for background -// colour with draw type Shaded. -void I_TTFDrawText(TTF_Font *font, TextQuality quality, INT32 fgR, INT32 fgG, INT32 fgB, INT32 fgA, INT32 bgR, INT32 bgG, INT32 bgB, INT32 bgA, const char *textmsg); - -// Initialise SDL_ttf. -void I_StartupTTF(UINT32 fontpointsize, Uint32 initflags, Uint32 vidmodeflags); - -void I_ShutdownTTF(void); -#endif diff --git a/src/sdl12/i_video.c b/src/sdl12/i_video.c deleted file mode 100644 index 349e06cba..000000000 --- a/src/sdl12/i_video.c +++ /dev/null @@ -1,2101 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SRB2 graphics stuff for SDL - -#include - -#ifndef _WIN32_WCE -#include -#endif - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - -#ifdef HAVE_SDL - -#include "SDL.h" - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#if SDL_VERSION_ATLEAST(1,2,9) && defined (_arch_dreamcast) -#define HAVE_DCSDL -#include "SDL_dreamcast.h" -#endif - -#if SDL_VERSION_ATLEAST(1,2,9) && defined (GP2X) -#define HAVE_GP2XSDL -#include "SDL_gp2x.h" -#endif - -#if SDL_VERSION_ATLEAST(1,3,0) -#define SDLK_EQUALS SDLK_KP_EQUALSAS400 -#define SDLK_LMETA SDLK_LGUI -#define SDLK_RMETA SDLK_RGUI -#else -#define HAVE_SDLMETAKEYS -#endif - -#ifdef HAVE_TTF -#include "i_ttf.h" -#endif - -#ifdef HAVE_IMAGE -#include "SDL_image.h" -#elseif !(defined (DC) || defined (_WIN32_WCE) || defined (PSP) || defined(GP2X)) -#define LOAD_XPM //I want XPM! -#include "IMG_xpm.c" //Alam: I don't want to add SDL_Image.dll/so -#define HAVE_IMAGE //I have SDL_Image, sortof -#endif - -#ifdef HAVE_IMAGE -#include "SDL_icon.xpm" -#endif - -#include "../doomdef.h" - -#if defined (_WIN32) && !defined (_XBOX) -#include "SDL_syswm.h" -#endif - -#ifdef _arch_dreamcast -#include -#include -#include -//#include "SRB2DC/VMU.xbm" -//#include -//#define malloc pvr_mem_malloc -//#define free pvr_mem_free -#endif - -#if defined (_XBOX) && defined (__GNUC__) -#include -#endif - -#include "../doomstat.h" -#include "../i_system.h" -#include "../v_video.h" -#include "../m_argv.h" -#include "../m_menu.h" -#include "../d_main.h" -#include "../s_sound.h" -#include "../i_sound.h" // midi pause/unpause -#include "../i_joy.h" -#include "../st_stuff.h" -#include "../g_game.h" -#include "../i_video.h" -#include "../console.h" -#include "../command.h" -#include "sdlmain.h" -#ifdef HWRENDER -#include "../hardware/hw_main.h" -#include "../hardware/hw_drv.h" -// For dynamic referencing of HW rendering functions -#include "hwsym_sdl.h" -#include "ogl_sdl.h" -#endif - -#ifdef REMOTE_DEBUGGING -#ifdef _WII -#include -#endif -#endif - -#ifdef HAVE_FILTER -#define FILTERS -#include "filter/filters.h" -#endif - -// maximum number of windowed modes (see windowedModes[][]) -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) -#define MAXWINMODES (1) -#elif defined (WII) -#define MAXWINMODES (8) -#elif defined (_PS3) -#define MAXWINMODES (26) -#else -#define MAXWINMODES (27) -#endif - -/** \brief -*/ -static INT32 numVidModes = -1; - -/** \brief -*/ -static char vidModeName[33][32]; // allow 33 different modes - -rendermode_t rendermode=render_soft; - -boolean highcolor = false; - -// synchronize page flipping with screen refresh -#if defined(DC) || (defined(GP2X) && !defined(HAVE_GP2XSDL)) -consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif -static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -UINT8 graphics_started = 0; // Is used in console.c and screen.c - -// To disable fullscreen at startup; is set in VID_PrepareModeList -boolean allow_fullscreen = false; -static SDL_bool disable_fullscreen = SDL_FALSE; -#define USE_FULLSCREEN (disable_fullscreen||!allow_fullscreen)?0:cv_fullscreen.value -static SDL_bool disable_mouse = SDL_FALSE; -#define USE_MOUSEINPUT (!disable_mouse && cv_usemouse.value && SDL_GetAppState() & SDL_APPACTIVE) -#define MOUSE_MENU false //(!disable_mouse && cv_usemouse.value && menuactive && !USE_FULLSCREEN) -#define MOUSEBUTTONS_MAX MOUSEBUTTONS - -// first entry in the modelist which is not bigger than MAXVIDWIDTHxMAXVIDHEIGHT -static INT32 firstEntry = 0; - -// SDL vars -#ifndef HWRENDER //[segabor] !!! I had problem compiling this source with gcc 3.3 -static SDL_Surface *vidSurface = NULL; -#endif -static SDL_Surface *bufSurface = NULL; -static SDL_Surface *icoSurface = NULL; -static SDL_Color localPalette[256]; -static SDL_Rect **modeList = NULL; -#ifdef DC -static Uint8 BitsPerPixel = 15; -#else -static Uint8 BitsPerPixel = 16; -#endif -static Uint16 realwidth = BASEVIDWIDTH; -static Uint16 realheight = BASEVIDHEIGHT; -#ifdef _WIN32_WCE -static const Uint32 surfaceFlagsW = SDL_HWPALETTE; //Can't handle WinCE changing sides -#else -static const Uint32 surfaceFlagsW = SDL_HWPALETTE/*|SDL_RESIZABLE*/; -#endif -#ifdef _PSP -static const Uint32 surfaceFlagsF = SDL_HWSURFACE|SDL_FULLSCREEN; -#else -static const Uint32 surfaceFlagsF = SDL_HWPALETTE|SDL_FULLSCREEN; -#endif -static SDL_bool mousegrabok = SDL_TRUE; -#define HalfWarpMouse(x,y) SDL_WarpMouse((Uint16)(x/2),(Uint16)(y/2)) -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) -static SDL_bool videoblitok = SDL_TRUE; -#else -static SDL_bool videoblitok = SDL_FALSE; -#endif -static SDL_bool exposevideo = SDL_FALSE; - -// windowed video modes from which to choose from. -static INT32 windowedModes[MAXWINMODES][2] = -{ -#if !(defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined (GP2X)) -#ifndef WII -#ifndef _PS3 - {1920,1200}, // 1.60,6.00 -#endif - {1680,1050}, // 1.60,5.25 - {1600,1200}, // 1.33,5.00 - {1600,1000}, // 1.60,5.00 - {1536,1152}, // 1.33,4.80 - {1536, 960}, // 1.60,4.80 - {1440, 900}, // 1.60,4.50 - {1400,1050}, // 1.33,4.375 - {1400, 875}, // 1.60,4.375 - {1360, 850}, // 1.60,4.25 - {1280, 960}, // 1.33,4.00 - {1280, 800}, // 1.60,4.00 - {1152, 864}, // 1.33,3.60 - {1120, 700}, // 1.60,3.50 - {1024, 768}, // 1.33,3.20 - { 960, 720}, // 1.33,3.00 - { 960, 600}, // 1.60,3.00 - { 800, 600}, // 1.33,2.50 - { 800, 500}, // 1.60,2.50 -#endif - { 640, 480}, // 1.33,2.00 - { 640, 400}, // 1.60,2.00 - { 576, 432}, // 1.33,1.80 - { 512, 384}, // 1.33,1.60 - { 416, 312}, // 1.33,1.30 - { 400, 300}, // 1.33,1.25 - { 320, 240}, // 1.33,1.00 -#endif - { 320, 200}, // 1.60,1.00 -}; - -static void SDLSetMode(INT32 width, INT32 height, INT32 bpp, Uint32 flags) -{ - const char *SDLVD = I_GetEnv("SDL_VIDEODRIVER"); -#ifdef _WIN32_WCE - if (bpp < 16) - bpp = 16; // 256 mode poo -#endif -#ifdef _WII - bpp = 16; // 8-bit mode poo -#endif -#ifdef DC - if (bpp < 15) - bpp = 15; - height = 240; -#endif -#ifdef PSP - bpp = 16; -#endif -#ifdef GP2X - bpp = 16; -#ifdef HAVE_GP2XSDL - height = 240; -#endif -#endif -#ifdef FILTERS - bpp = Setupf2x(width, height, bpp); -#endif - if (SDLVD && strncasecmp(SDLVD,"glSDL",6) == 0) //for glSDL videodriver - vidSurface = SDL_SetVideoMode(width, height,0,SDL_DOUBLEBUF); -#ifdef _WII // don't want it to use HWSURFACE, so make it first here - else if (SDL_VideoModeOK(width, height, bpp, flags|SDL_SWSURFACE|SDL_DOUBLEBUF) >= bpp) // SDL Wii uses double buffering - vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_SWSURFACE|SDL_DOUBLEBUF); -#endif - else if (cv_vidwait.value && videoblitok && SDL_VideoModeOK(width, height, bpp, flags|SDL_HWSURFACE|SDL_DOUBLEBUF) >= bpp) - vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_HWSURFACE|SDL_DOUBLEBUF); - else if (videoblitok && SDL_VideoModeOK(width, height, bpp, flags|SDL_HWSURFACE) >= bpp) - vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_HWSURFACE); - else if (SDL_VideoModeOK(width, height, bpp, flags|SDL_SWSURFACE) >= bpp) - vidSurface = SDL_SetVideoMode(width, height, bpp, flags|SDL_SWSURFACE); - else return; - realwidth = (Uint16)width; - realheight = (Uint16)height; -#ifdef HAVE_DCSDL - //SDL_DC_SetWindow(320,200); - SDL_DC_EmulateMouse(SDL_FALSE); - SDL_DC_EmulateKeyboard(SDL_TRUE); -#endif -#ifdef HAVE_GP2XSDL - SDL_ShowCursor(SDL_DISABLE); //For GP2X Open2x -#endif -#ifdef FILTERS - if (vidSurface && preSurface && f2xSurface) - { - vid.width = width/2; - vid.height = height/2; - } -#endif -} - -// -// Translates the SDL key into SRB2 key -// - -static INT32 SDLatekey(SDLKey sym) -{ - INT32 rc = sym + 0x80; - -#ifdef _WIN32_WCE - if (sym == SDLK_KP8) - sym = SDLK_UP; - else if (sym == SDLK_KP4) - sym = SDLK_LEFT; - else if (sym == SDLK_KP6) - sym = SDLK_RIGHT; - else if (sym == SDLK_KP2) - sym = SDLK_DOWN; -#endif - - switch (sym) - { - case SDLK_LEFT: - rc = KEY_LEFTARROW; - break; - case SDLK_RIGHT: - rc = KEY_RIGHTARROW; - break; - case SDLK_DOWN: - rc = KEY_DOWNARROW; - break; - case SDLK_UP: - rc = KEY_UPARROW; - break; - - case SDLK_ESCAPE: - rc = KEY_ESCAPE; - break; - case SDLK_SPACE: - rc = KEY_SPACE; - break; - case SDLK_RETURN: - case SDLK_KP_ENTER: - rc = KEY_ENTER; - break; - case SDLK_TAB: - rc = KEY_TAB; - break; - case SDLK_F1: - rc = KEY_F1; - break; - case SDLK_F2: - rc = KEY_F2; - break; - case SDLK_F3: - rc = KEY_F3; - break; - case SDLK_F4: - rc = KEY_F4; - break; - case SDLK_F5: - rc = KEY_F5; - break; - case SDLK_F6: - rc = KEY_F6; - break; - case SDLK_F7: - rc = KEY_F7; - break; - case SDLK_F8: - rc = KEY_F8; - break; - case SDLK_F9: - rc = KEY_F9; - break; - case SDLK_F10: - rc = KEY_F10; - break; - case SDLK_F11: - rc = KEY_F11; - break; - case SDLK_F12: - rc = KEY_F12; - break; - - case SDLK_BACKSPACE: - rc = KEY_BACKSPACE; - break; - case SDLK_DELETE: - rc = KEY_DEL; - break; - - case SDLK_KP_EQUALS: //Alam & Logan: WTF? Mac KB haves one! XD - case SDLK_PAUSE: - rc = KEY_PAUSE; - break; - - case SDLK_EQUALS: - case SDLK_PLUS: - rc = KEY_EQUALS; - break; - - case SDLK_MINUS: - rc = KEY_MINUS; - break; - - case SDLK_LSHIFT: - rc = KEY_LSHIFT; - break; - - case SDLK_RSHIFT: - rc = KEY_RSHIFT; - break; - - case SDLK_CAPSLOCK: - rc = KEY_CAPSLOCK; - break; - - case SDLK_LCTRL: - rc = KEY_LCTRL; - break; - case SDLK_RCTRL: - rc = KEY_RCTRL; - break; - - case SDLK_LALT: - rc = KEY_LALT; - break; - case SDLK_RALT: - rc = KEY_RALT; - break; - - case SDLK_NUMLOCK: - rc = KEY_NUMLOCK; - break; - case SDLK_SCROLLOCK: - rc = KEY_SCROLLLOCK; - break; - - case SDLK_PAGEUP: - rc = KEY_PGUP; - break; - case SDLK_PAGEDOWN: - rc = KEY_PGDN; - break; - case SDLK_END: - rc = KEY_END; - break; - case SDLK_HOME: - rc = KEY_HOME; - break; - case SDLK_INSERT: - rc = KEY_INS; - break; - - case SDLK_KP0: - rc = KEY_KEYPAD0; - break; - case SDLK_KP1: - rc = KEY_KEYPAD1; - break; - case SDLK_KP2: - rc = KEY_KEYPAD2; - break; - case SDLK_KP3: - rc = KEY_KEYPAD3; - break; - case SDLK_KP4: - rc = KEY_KEYPAD4; - break; - case SDLK_KP5: - rc = KEY_KEYPAD5; - break; - case SDLK_KP6: - rc = KEY_KEYPAD6; - break; - case SDLK_KP7: - rc = KEY_KEYPAD7; - break; - case SDLK_KP8: - rc = KEY_KEYPAD8; - break; - case SDLK_KP9: - rc = KEY_KEYPAD9; - break; - - case SDLK_KP_PERIOD: - rc = KEY_KPADDEL; - break; - case SDLK_KP_DIVIDE: - rc = KEY_KPADSLASH; - break; - case SDLK_KP_MULTIPLY: - rc = '*'; - break; - case SDLK_KP_MINUS: - rc = KEY_MINUSPAD; - break; - case SDLK_KP_PLUS: - rc = KEY_PLUSPAD; - break; - -#ifndef _arch_dreamcast - case SDLK_LSUPER: -#ifdef HAVE_SDLMETAKEYS - case SDLK_LMETA: -#endif - rc = KEY_LEFTWIN; - break; - case SDLK_RSUPER: -#ifdef HAVE_SDLMETAKEYS - case SDLK_RMETA: -#endif - rc = KEY_RIGHTWIN; - break; - - case SDLK_MENU: - rc = KEY_MENU; - break; -#endif - - default: - if (sym >= SDLK_SPACE && sym <= SDLK_DELETE) - rc = sym - SDLK_SPACE + ' '; - else if (sym >= 'A' && sym <= 'Z') - rc = sym - 'A' + 'a'; - else if (sym) - { - I_OutputMsg("Unknown Keycode %i, Name: %s\n",sym, SDL_GetKeyName( sym )); - } - else if (!sym) rc = 0; - break; - } - - return rc; -} - -static void SDLdoUngrabMouse(void) -{ - if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY)) - { - SDL_WM_GrabInput(SDL_GRAB_OFF); - } -} - -void SDLforceUngrabMouse(void) -{ - if (SDL_WasInit(SDL_INIT_VIDEO)==SDL_INIT_VIDEO) - SDL_WM_GrabInput(SDL_GRAB_OFF); -} - -static void VID_Command_NumModes_f (void) -{ - CONS_Printf(M_GetText("%d video mode(s) available(s)\n"), VID_NumModes()); -} - -static void SurfaceInfo(const SDL_Surface *infoSurface, const char *SurfaceText) -{ - INT32 vfBPP; - const SDL_Surface *VidSur = SDL_GetVideoSurface(); - - if (!infoSurface) - return; - - if (!SurfaceText) - SurfaceText = M_GetText("Unknown Surface"); - - vfBPP = infoSurface->format?infoSurface->format->BitsPerPixel:0; - - CONS_Printf("\x82" "%s\n", SurfaceText); - CONS_Printf(M_GetText(" %ix%i at %i bit color\n"), infoSurface->w, infoSurface->h, vfBPP); - - if (infoSurface->flags&SDL_HWSURFACE) - CONS_Printf("%s", M_GetText(" Stored in video memory\n")); - else if (infoSurface->flags&SDL_OPENGL) - CONS_Printf("%s", M_GetText(" Stored in an OpenGL context\n")); - else if (infoSurface->flags&SDL_PREALLOC) - CONS_Printf("%s", M_GetText(" Uses preallocated memory\n")); - else - CONS_Printf("%s", M_GetText(" Stored in system memory\n")); - - if (infoSurface->flags&SDL_ASYNCBLIT) - CONS_Printf("%s", M_GetText(" Uses asynchronous blits if possible\n")); - else - CONS_Printf("%s", M_GetText(" Uses synchronous blits if possible\n")); - - if (infoSurface->flags&SDL_ANYFORMAT) - CONS_Printf("%s", M_GetText(" Allows any pixel-format\n")); - - if (infoSurface->flags&SDL_HWPALETTE) - CONS_Printf("%s", M_GetText(" Has exclusive palette access\n")); - else if (VidSur == infoSurface) - CONS_Printf("%s", M_GetText(" Has nonexclusive palette access\n")); - - if (infoSurface->flags&SDL_DOUBLEBUF) - CONS_Printf("%s", M_GetText(" Double buffered\n")); - else if (VidSur == infoSurface) - CONS_Printf("%s", M_GetText(" No hardware flipping\n")); - - if (infoSurface->flags&SDL_FULLSCREEN) - CONS_Printf("%s", M_GetText(" Full screen\n")); - else if (infoSurface->flags&SDL_RESIZABLE) - CONS_Printf("%s", M_GetText(" Resizable window\n")); - else if (VidSur == infoSurface) - CONS_Printf("%s", M_GetText(" Nonresizable window\n")); - - if (infoSurface->flags&SDL_HWACCEL) - CONS_Printf("%s", M_GetText(" Uses hardware acceleration blit\n")); - if (infoSurface->flags&SDL_SRCCOLORKEY) - CONS_Printf("%s", M_GetText(" Use colorkey blitting\n")); - if (infoSurface->flags&SDL_RLEACCEL) - CONS_Printf("%s", M_GetText(" Colorkey RLE acceleration blit\n")); - if (infoSurface->flags&SDL_SRCALPHA) - CONS_Printf("%s", M_GetText(" Use alpha blending acceleration blit\n")); - -} - -static void VID_Command_Info_f (void) -{ - const SDL_VideoInfo *videoInfo; - videoInfo = SDL_GetVideoInfo(); //Alam: Double-Check - if (videoInfo) - { - CONS_Printf("%s", M_GetText("Video Interface Capabilities:\n")); - if (videoInfo->hw_available) - CONS_Printf("%s", M_GetText(" Hardware surfaces\n")); - if (videoInfo->wm_available) - CONS_Printf("%s", M_GetText(" Window manager\n")); - //UnusedBits1 :6 - //UnusedBits2 :1 - if (videoInfo->blit_hw) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW\n")); - if (videoInfo->blit_hw_CC) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW with Colorkey\n")); - if (videoInfo->wm_available) - CONS_Printf("%s", M_GetText(" Accelerated blits HW-2-HW with Alpha\n")); - if (videoInfo->blit_sw) - { - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW\n")); - if (!M_CheckParm("-noblit")) videoblitok = SDL_TRUE; - } - if (videoInfo->blit_sw_CC) - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW with Colorkey\n")); - if (videoInfo->blit_sw_A) - CONS_Printf("%s", M_GetText(" Accelerated blits SW-2-HW with Alpha\n")); - if (videoInfo->blit_fill) - CONS_Printf("%s", M_GetText(" Accelerated Color filling\n")); - //UnusedBits3 :16 - if (videoInfo->video_mem) - CONS_Printf(M_GetText(" There is %i KB of video memory\n"), videoInfo->video_mem); - else - CONS_Printf("%s", M_GetText(" There no video memory for SDL\n")); - //*vfmt - } - SurfaceInfo(bufSurface, M_GetText("Current Engine Mode")); -#ifdef FILTERS - SurfaceInfo(preSurface, M_GetText("Prebuffer Mode")); - SurfaceInfo(f2xSurface, M_GetText("Postbuffer Mode")); -#endif - SurfaceInfo(vidSurface, M_GetText("Current Video Mode")); -} - -static void VID_Command_ModeList_f(void) -{ -#if !defined (DC) && !defined (_WIN32_WCE) && !defined (_PSP) && !defined(GP2X) - INT32 i; -#ifdef HWRENDER - if (rendermode == render_opengl) - modeList = SDL_ListModes(NULL, SDL_OPENGL|SDL_FULLSCREEN); - else -#endif - modeList = SDL_ListModes(NULL, surfaceFlagsF|SDL_HWSURFACE); //Alam: At least hardware surface - - if (modeList == (SDL_Rect **)0 && cv_fullscreen.value) - { - CONS_Printf("%s", M_GetText("No video modes present\n")); - cv_fullscreen.value = 0; - } - else if (modeList != (SDL_Rect **)0) - { - numVidModes = 0; - if (modeList == (SDL_Rect **)-1) - numVidModes = -1; // should not happen with fullscreen modes - else while (modeList[numVidModes]) - numVidModes++; - } - CONS_Printf(M_GetText("Found %d FullScreen Video Modes:\n"), numVidModes); - for (i=0 ; i= numVidModes) - break; - - CONS_Printf(M_GetText("%dx%d and "), - modeList[modeNum]->w, - modeList[modeNum]->h); - } - CONS_Printf("%s", M_GetText("None\n")); -#endif -} - -static void VID_Command_Mode_f (void) -{ - INT32 modenum; - - if (COM_Argc()!= 2) - { - CONS_Printf(M_GetText("vid_mode : set video mode, current video mode %i\n"), vid.modenum); - return; - } - - modenum = atoi(COM_Argv(1)); - - if (modenum >= VID_NumModes()) - CONS_Printf(M_GetText("Video mode not present\n")); - else - setmodeneeded = modenum+1; // request vid mode change -} - -#if defined(RPC_NO_WINDOWS_H) && !defined(_WIN32_WCE) -static VOID MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - UNREFERENCED_PARAMETER(hWnd); - UNREFERENCED_PARAMETER(message); - UNREFERENCED_PARAMETER(wParam); - switch (message) - { - case WM_SETTEXT: - COM_BufAddText((LPCSTR)lParam); - break; - } -} -#endif - -#if 0 //#ifdef _WIN32 - // Disable Composition in Vista DWM (Desktop Window Manager) ---------------- -static HMODULE DMdll = NULL; -typedef HRESULT (CALLBACK *P_DwmIsCompositionEnabled) (BOOL *pfEnabled); -static P_DwmIsCompositionEnabled pfnDwmIsCompositionEnabled = NULL; -typedef HRESULT (CALLBACK *P_DwmEnableComposition) (BOOL fEnable); -static P_DwmEnableComposition pfnDwmEnableComposition = NULL; -static BOOL AeroWasEnabled = FALSE; - -static inline VOID UnloadDM(VOID) -{ - pfnDwmEnableComposition = NULL; - pfnDwmIsCompositionEnabled = NULL; - if (DMdll) FreeLibrary(DMdll); - DMdll = NULL; -} - -static inline BOOL LoadDM(VOID) -{ - if (DMdll) - return TRUE; - - DMdll = LoadLibraryA("dwmapi.dll"); - if (DMdll) - I_OutputMsg("dmwapi.dll loaded, Vista's Desktop Window Manager API\n"); - else - return FALSE; - - pfnDwmIsCompositionEnabled = (P_DwmIsCompositionEnabled)GetProcAddress(DMdll, "DwmIsCompositionEnabled"); - if (pfnDwmIsCompositionEnabled) - I_OutputMsg("Composition Aero API found, DwmIsCompositionEnabled\n"); - - pfnDwmEnableComposition = (P_DwmEnableComposition)GetProcAddress(DMdll, "DwmEnableComposition"); - if (pfnDwmEnableComposition) - I_OutputMsg("Composition Aero API found, DwmEnableComposition\n"); - - return TRUE; -} - -static inline VOID DisableAero(VOID) -{ - BOOL pfnDwmEnableCompositiond = FALSE; - AeroWasEnabled = FALSE; - - if (!LoadDM()) - return; - - if (pfnDwmIsCompositionEnabled && SUCCEEDED(pfnDwmIsCompositionEnabled(&pfnDwmEnableCompositiond))) - I_OutputMsg("Got the result of DwmIsCompositionEnabled, %i\n", pfnDwmEnableCompositiond); - else - return; - - if ((AeroWasEnabled = pfnDwmEnableCompositiond)) - I_OutputMsg("Disable the Aero rendering\n"); - else - return; - - if (pfnDwmEnableComposition && SUCCEEDED(pfnDwmEnableComposition(FALSE))) - I_OutputMsg("Aero rendering disabled\n"); - else - I_OutputMsg("We failed to disable the Aero rendering\n"); -} - -static inline VOID ResetAero(VOID) -{ - if (pfnDwmEnableComposition && AeroWasEnabled) - { - if (SUCCEEDED(pfnDwmEnableComposition(AeroWasEnabled))) - I_OutputMsg("Aero rendering setting restored\n"); - else - I_OutputMsg("We failed to restore Aero rendering\n"); - } - UnloadDM(); -} -#endif - -static inline void SDLJoyRemap(event_t *event) -{ -#if defined(GP2X) -#define GP2X_BUTTON_UP (0) -#define GP2X_BUTTON_DOWN (4) -#define GP2X_BUTTON_LEFT (2) -#define GP2X_BUTTON_RIGHT (6) -#define GP2X_BUTTON_UPLEFT (1) -#define GP2X_BUTTON_UPRIGHT (7) -#define GP2X_BUTTON_DOWNLEFT (3) -#define GP2X_BUTTON_DOWNRIGHT (5) -#define GP2X_BUTTON_CLICK (18) -#define GP2X_BUTTON_A (12) -#define GP2X_BUTTON_B (13) -#define GP2X_BUTTON_X (14) -#define GP2X_BUTTON_Y (15) -#define GP2X_BUTTON_L (10) -#define GP2X_BUTTON_R (11) -#define GP2X_BUTTON_START (8) -#define GP2X_BUTTON_SELECT (9) -#define GP2X_BUTTON_VOLUP (16) -#define GP2X_BUTTON_VOLDOWN (17) - if ((event->type == ev_keydown || event->type == ev_keyup) && (KEY_JOY1 <= event->data1 && event->data1 <= KEY_JOY1+JOYBUTTONS)) - { - INT32 button = event->data1-KEY_JOY1; - if (button <= 7) - { - static UINT8 DPAD = 0; - if (event->type == ev_keyup) - { - event->type = ev_console; - DPAD &= ~(1<type = ev_joystick; - DPAD |= 1<data2 = event->data3 = INT32_MAX; - if ((DPAD & (1<type = ev_joystick; - event->data2 = event->data3 = 0; - } - else switch (button) - { - case GP2X_BUTTON_UP: - event->data3 = -1; - break; - case GP2X_BUTTON_DOWN: - event->data3 = 1; - break; - case GP2X_BUTTON_LEFT: - event->data2 = -1; - break; - case GP2X_BUTTON_RIGHT: - event->data2 = 1; - break; - case GP2X_BUTTON_UPLEFT: - event->data2 = -1; - event->data3 = -1; - break; - case GP2X_BUTTON_UPRIGHT: - event->data2 = 1; - event->data3 = -1; - break; - case GP2X_BUTTON_DOWNLEFT: - event->data2 = -1; - event->data3 = 1; - break; - case GP2X_BUTTON_DOWNRIGHT: - event->data2 = 1; - event->data3 = 1; - default: - break; - } - event->data1 = 0; - return; - } - else switch (button) - { - case GP2X_BUTTON_CLICK: - event->data1 = KEY_ENTER; - break; - case GP2X_BUTTON_A: - event->data1 = KEY_JOY1+0; - break; - case GP2X_BUTTON_B: - event->data1 = KEY_JOY1+2; - break; - case GP2X_BUTTON_X: - event->data1 = KEY_JOY1+3; - break; - case GP2X_BUTTON_Y: - event->data1 = KEY_JOY1+1; - break; - case GP2X_BUTTON_L: - event->data1 = KEY_JOY1+4; - break; - case GP2X_BUTTON_R: - event->data1 = KEY_JOY1+5; - break; - case GP2X_BUTTON_START: - event->data1 = KEY_ESCAPE; - break; - case GP2X_BUTTON_SELECT: - event->data1 = KEY_JOY1+8; - break; - case GP2X_BUTTON_VOLUP: - event->data1 = KEY_JOY1+6; - break; - case GP2X_BUTTON_VOLDOWN: - event->data1 = KEY_JOY1+7; - break; - default: - break; - } - //I_OutputMsg("Button %i: event key %i and type: %i\n", button, event->data1, event->type); - } -#elif defined(_PSP) - if (event->data1 > KEY_JOY1 + 9 + 2) // All button after D-Pad and Select/Start - event->data1 -= 4; // remap D-pad to Hats, offset of -4 - else if (event->data1 == KEY_JOY1 + 6) // Down - event->data1 = KEY_HAT1+1; - else if (event->data1 == KEY_JOY1 + 7) // Left - event->data1 = KEY_HAT1+2; - else if (event->data1 == KEY_JOY1 + 8) // Up - event->data1 = KEY_HAT1+0; - else if (event->data1 == KEY_JOY1 + 9) // Right - event->data1 = KEY_HAT1+3; - else if (event->data1 == KEY_JOY1 + 10) // Select - event->data1 = KEY_TAB; - else if (event->data1 == KEY_JOY1 + 11) // Start - event->data1 = KEY_ESCAPE; -#else - (void)event; -#endif -} - -static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) -{ -#ifdef _arch_dreamcast // -128 to 127 SDL for DC have give us a smaller range - INT32 raxis = axis*8; -#else // -32768 to 32767 - INT32 raxis = axis/32; -#endif - if (which == ev_joystick) - { - if (Joystick.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (raxis < -(JOYAXISRANGE/2)) - raxis = -1; - else if (raxis > (JOYAXISRANGE/2)) - raxis = 1; - else - raxis = 0; - } - else - { - raxis = JoyInfo.scale!=1?((raxis/JoyInfo.scale)*JoyInfo.scale):raxis; - -#ifdef SDL_JDEADZONE - if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) - raxis = 0; -#endif - } - } - else if (which == ev_joystick2) - { - if (Joystick2.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (raxis < -(JOYAXISRANGE/2)) - raxis = -1; - else if (raxis > (JOYAXISRANGE/2)) - raxis = 1; - else raxis = 0; - } - else - { - raxis = JoyInfo2.scale!=1?((raxis/JoyInfo2.scale)*JoyInfo2.scale):raxis; - -#ifdef SDL_JDEADZONE - if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE) - raxis = 0; -#endif - } - } - return raxis; -} - -void I_GetEvent(void) -{ - SDL_Event inputEvent; - static SDL_bool sdlquit = SDL_FALSE; //Alam: once, just once - event_t event; - - if (!graphics_started) - return; - - memset(&inputEvent, 0x00, sizeof(inputEvent)); - while (SDL_PollEvent(&inputEvent)) - { - memset(&event,0x00,sizeof (event_t)); - switch (inputEvent.type) - { - case SDL_ACTIVEEVENT: - if (inputEvent.active.state & (SDL_APPACTIVE|SDL_APPINPUTFOCUS)) - { - // pause music when alt-tab - if (inputEvent.active.gain /*&& !paused */) - { - static SDL_bool firsttimeonmouse = SDL_TRUE; - if (!firsttimeonmouse) - { - if (cv_usemouse.value) I_StartupMouse(); - } - else firsttimeonmouse = SDL_FALSE; - //if (!netgame && !con_destlines) paused = false; - if (gamestate == GS_LEVEL) - if (!paused) I_ResumeSong(0); //resume it - } - else /*if (!paused)*/ - { - if (!disable_mouse) - SDLforceUngrabMouse(); - if (!netgame && gamestate == GS_LEVEL) paused = true; - memset(gamekeydown, 0, NUMKEYS); - //S_PauseSound(); - if (gamestate == GS_LEVEL) - I_PauseSong(0); //pause it - } - } - if (MOUSE_MENU) - { - SDLdoUngrabMouse(); - break; - } - if ((SDL_APPMOUSEFOCUS&inputEvent.active.state) && USE_MOUSEINPUT && inputEvent.active.gain) - HalfWarpMouse(realwidth, realheight); - break; - case SDL_KEYDOWN: - case SDL_KEYUP: - /// \todo inputEvent.key.which? - if (inputEvent.type == SDL_KEYUP) - event.type = ev_keyup; - else if (inputEvent.type == SDL_KEYDOWN) - event.type = ev_keydown; - else break; - event.data1 = SDLatekey(inputEvent.key.keysym.sym); - if (event.data1) D_PostEvent(&event); - break; - case SDL_MOUSEMOTION: - /// \todo inputEvent.motion.which - if (MOUSE_MENU) - { - SDLdoUngrabMouse(); - break; - } - if (USE_MOUSEINPUT) - { - // If the event is from warping the pointer back to middle - // of the screen then ignore it. - if ((inputEvent.motion.x == realwidth/2) && - (inputEvent.motion.y == realheight/2)) - { - break; - } - else - { - event.data2 = +inputEvent.motion.xrel; - event.data3 = -inputEvent.motion.yrel; - } - event.type = ev_mouse; - D_PostEvent(&event); - // Warp the pointer back to the middle of the window - // or we cannot move any further if it's at a border. - if ((inputEvent.motion.x < (realwidth/2 )-(realwidth/4 )) || - (inputEvent.motion.y < (realheight/2)-(realheight/4)) || - (inputEvent.motion.x > (realwidth/2 )+(realwidth/4 )) || - (inputEvent.motion.y > (realheight/2)+(realheight/4) ) ) - { - //if (SDL_GRAB_ON == SDL_WM_GrabInput(SDL_GRAB_QUERY) || !mousegrabok) - HalfWarpMouse(realwidth, realheight); - } - } - break; - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - /// \todo inputEvent.button.which - if (USE_MOUSEINPUT) - { - if (inputEvent.type == SDL_MOUSEBUTTONUP) - event.type = ev_keyup; - else if (inputEvent.type == SDL_MOUSEBUTTONDOWN) - event.type = ev_keydown; - else break; - if (inputEvent.button.button==SDL_BUTTON_WHEELUP || inputEvent.button.button==SDL_BUTTON_WHEELDOWN) - { - if (inputEvent.type == SDL_MOUSEBUTTONUP) - event.data1 = 0; //Alam: dumb! this could be a real button with some mice - else - event.data1 = KEY_MOUSEWHEELUP + inputEvent.button.button - SDL_BUTTON_WHEELUP; - } - else if (inputEvent.button.button == SDL_BUTTON_MIDDLE) - event.data1 = KEY_MOUSE1+2; - else if (inputEvent.button.button == SDL_BUTTON_RIGHT) - event.data1 = KEY_MOUSE1+1; - else if (inputEvent.button.button <= MOUSEBUTTONS) - event.data1 = KEY_MOUSE1 + inputEvent.button.button - SDL_BUTTON_LEFT; - if (event.data1) D_PostEvent(&event); - } - break; - case SDL_JOYAXISMOTION: - inputEvent.jaxis.which++; - inputEvent.jaxis.axis++; - event.data1 = event.data2 = event.data3 = INT32_MAX; - if (cv_usejoystick.value == inputEvent.jaxis.which) - { - event.type = ev_joystick; - } - else if (cv_usejoystick.value == inputEvent.jaxis.which) - { - event.type = ev_joystick2; - } - else break; - //axis - if (inputEvent.jaxis.axis > JOYAXISSET*2) - break; - //vaule - if (inputEvent.jaxis.axis%2) - { - event.data1 = inputEvent.jaxis.axis / 2; - event.data2 = SDLJoyAxis(inputEvent.jaxis.value, event.type); - } - else - { - inputEvent.jaxis.axis--; - event.data1 = inputEvent.jaxis.axis / 2; - event.data3 = SDLJoyAxis(inputEvent.jaxis.value, event.type); - } - D_PostEvent(&event); - break; - case SDL_JOYBALLMOTION: - case SDL_JOYHATMOTION: - break; //NONE - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: - inputEvent.jbutton.which++; - if (cv_usejoystick.value == inputEvent.jbutton.which) - event.data1 = KEY_JOY1; - else if (cv_usejoystick.value == inputEvent.jbutton.which) - event.data1 = KEY_2JOY1; - else break; - if (inputEvent.type == SDL_JOYBUTTONUP) - event.type = ev_keyup; - else if (inputEvent.type == SDL_JOYBUTTONDOWN) - event.type = ev_keydown; - else break; - if (inputEvent.jbutton.button < JOYBUTTONS) - event.data1 += inputEvent.jbutton.button; - else - break; - SDLJoyRemap(&event); - if (event.type != ev_console) D_PostEvent(&event); - break; -#ifndef _WIN32_WCE - case SDL_QUIT: - if (!sdlquit) - { - sdlquit = SDL_TRUE; - M_QuitResponse('y'); - } - break; -#endif -#if defined(RPC_NO_WINDOWS_H) && !defined(_WIN32_WCE) - case SDL_SYSWMEVENT: - MainWndproc(inputEvent.syswm.msg->hwnd, - inputEvent.syswm.msg->msg, - inputEvent.syswm.msg->wParam, - inputEvent.syswm.msg->lParam); - break; -#endif - case SDL_VIDEORESIZE: - if (gamestate == GS_LEVEL || gamestate == GS_TITLESCREEN || gamestate == GS_EVALUATION) - setmodeneeded = VID_GetModeForSize(inputEvent.resize.w,inputEvent.resize.h)+1; - if (render_soft == rendermode) - { -#ifdef FILTERS - INT32 filtervalue = cv_filter.value; - if (blitfilter) CV_SetValue(&cv_filter,1); -#endif - SDLSetMode(realwidth, realheight, vid.bpp*8, surfaceFlagsW); - if (vidSurface) SDL_SetColors(vidSurface, localPalette, 0, 256); -#ifdef FILTERS - CV_SetValue(&cv_filter,filtervalue); -#endif - } - else - SDLSetMode(realwidth, realheight, vid.bpp*8, surfaceFlagsW); - if (!vidSurface) - I_Error("Could not reset vidmode: %s\n",SDL_GetError()); - break; - case SDL_VIDEOEXPOSE: - exposevideo = SDL_TRUE; - break; - default: - break; - } - } - //reset wheel like in win32, I don't understand it but works - gamekeydown[KEY_MOUSEWHEELDOWN] = gamekeydown[KEY_MOUSEWHEELUP] = 0; -} - -void I_StartupMouse(void) -{ - static SDL_bool firsttimeonmouse = SDL_TRUE; - - if (disable_mouse) - return; - - if (!firsttimeonmouse) - HalfWarpMouse(realwidth, realheight); // warp to center - else - firsttimeonmouse = SDL_FALSE; - if (cv_usemouse.value) - return; - else - SDLdoUngrabMouse(); -} - -// -// I_OsPolling -// -void I_OsPolling(void) -{ - if (consolevent) - I_GetConsoleEvents(); - if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) - { - SDL_JoystickUpdate(); - I_GetJoystickEvents(); - I_GetJoystick2Events(); - } -#ifdef _arch_dreamcast - //vmu_set_icon(VMU_bits); -#endif - - I_GetMouseEvents(); - - I_GetEvent(); -} - -// -// I_UpdateNoBlit -// -void I_UpdateNoBlit(void) -{ - if (!vidSurface) - return; -#ifdef HWRENDER - if (rendermode != render_soft) - OglSdlFinishUpdate(cv_vidwait.value); - else -#endif - if (vidSurface->flags&SDL_DOUBLEBUF) - SDL_Flip(vidSurface); - else if (exposevideo) - SDL_UpdateRect(vidSurface, 0, 0, 0, 0); - exposevideo = SDL_FALSE; -} - -// I_SkipFrame -// -// Returns true if it thinks we can afford to skip this frame -// from PrBoom's src/SDL/i_video.c -static inline boolean I_SkipFrame(void) -{ - static boolean skip = false; - - if (render_soft != rendermode) - return false; - - skip = !skip; - -#if 0 //(defined (GP2X) || defined (PSP) || defined (_arch_dreamcast)) - return skip; -#endif - - switch (gamestate) - { - case GS_LEVEL: - if (!paused) - return false; - case GS_TIMEATTACK: - case GS_WAITINGPLAYERS: - return skip; // Skip odd frames - default: - return false; - } -} - -static inline SDL_bool SDLmatchVideoformat(void) -{ - const SDL_PixelFormat *vidformat = vidSurface->format; - const INT32 vfBPP = vidformat?vidformat->BitsPerPixel:0; - return (((vfBPP == 8 && vid.bpp == 1 && - !vidformat->Rmask && !vidformat->Gmask && !vidformat->Bmask) || - (vfBPP == 15 && vid.bpp == 2 && vidformat->Rmask == 0x7C00 && - vidformat->Gmask == 0x03E0 && vidformat->Bmask == 0x001F )) && - !vidformat->Amask && (vidSurface->flags & SDL_RLEACCEL) == 0); -} - -// -// I_FinishUpdate -// -void I_FinishUpdate(void) -{ - if (!vidSurface) - return; //Alam: No software or OpenGl surface - - if (I_SkipFrame()) - return; - - if (cv_ticrate.value) - SCR_DisplayTicRate(); - - if (render_soft == rendermode && screens[0]) - { - SDL_Rect *dstrect = NULL; - SDL_Rect rect = {0, 0, 0, 0}; - SDL_PixelFormat *vidformat = vidSurface->format; - int lockedsf = 0, blited = 0; - - rect.w = (Sint16)vid.width; - rect.h = (Sint16)vid.height; - - if (vidSurface->h > vid.height) - rect.y = (Sint16)((vidSurface->h-vid.height)/2); - - dstrect = ▭ - - - if (!bufSurface && !vid.direct) //Double-Check - { - if (vid.bpp == 1) bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.width,vid.height,8, - (int)vid.rowbytes,0x00000000,0x00000000,0x00000000,0x00000000); // 256 mode - else if (vid.bpp == 2) bufSurface = SDL_CreateRGBSurfaceFrom(screens[0],vid.width,vid.height,15, - (int)vid.rowbytes,0x00007C00,0x000003E0,0x0000001F,0x00000000); // 555 mode - if (bufSurface) SDL_SetColors(bufSurface, localPalette, 0, 256); - else I_OutputMsg("No system memory for SDL buffer surface\n"); - } - -#ifdef FILTERS - FilterBlit(bufSurface); - if (f2xSurface) //Alam: filter! - { - //I_OutputMsg("2x Filter Code\n"); - blited = SDL_BlitSurface(f2xSurface,NULL,vidSurface,NULL); - } - else -#endif -#if 0 - if (SDLmatchVideoformat() && !vid.direct)//Alam: DOS Way - { - if (SDL_MUSTLOCK(vidSurface)) lockedsf = SDL_LockSurface(vidSurface); - if (lockedsf == 0) - { - if (vidSurface->pixels > vid.height) - { - UINT8 *ptr = vidSurface->pixels; - size_t half_excess = vidSurface->pitch*(vidSurface->height-vid.height)/2; - memset(ptr, 0x1F, half_excess); - ptr += half_excess; - VID_BlitLinearScreen(screens[0], ptr, vid.width*vid.bpp, vid.height, - vid.rowbytes, vidSurface->pitch); - ptr += vid.height*vidSurface->pitch; - memset(ptr, 0x1F, half_excess); - } - else - VID_BlitLinearScreen(screens[0], vidSurface->pixels, vid.width*vid.bpp, - vid.height, vid.rowbytes, vidSurface->pitch ); - if (SDL_MUSTLOCK(vidSurface)) SDL_UnlockSurface(vidSurface); - } - } - else -#endif - if (bufSurface) //Alam: New Way to send video data - { - blited = SDL_BlitSurface(bufSurface,NULL,vidSurface,dstrect); - } - else if (vid.bpp == 1 && !vid.direct) - { - Uint8 *bP,*vP; //Src, Dst - Uint16 bW, vW; // Pitch Remainder - Sint32 pH, pW; //Height, Width - bP = (Uint8 *)screens[0]; - bW = (Uint16)(vid.rowbytes - vid.width); - //I_OutputMsg("Old Copy Code\n"); - if (SDL_MUSTLOCK(vidSurface)) lockedsf = SDL_LockSurface(vidSurface); - vP = (Uint8 *)vidSurface->pixels; - vW = (Uint16)(vidSurface->pitch - vidSurface->w*vidformat->BytesPerPixel); - if (vidSurface->h > vid.height) - vP += vidSurface->pitch*(vidSurface->h-vid.height)/2; - if (lockedsf == 0 && vidSurface->pixels) - { - if (vidformat->BytesPerPixel == 2) - { - for (pH=0;pH < vidSurface->h;pH++) - { - for (pW=0;pW < vidSurface->w;pW++) - { - *((Uint16 *)(void *)vP) = (Uint16)SDL_MapRGB(vidformat, - localPalette[*bP].r,localPalette[*bP].g,localPalette[*bP].b); - bP++; - vP += 2; - } - bP += bW; - vP += vW; - } - } - else if (vidformat->BytesPerPixel == 3) - { - for (pH=0;pH < vidSurface->h;pH++) - { - for (pW=0;pW < vidSurface->w;pW++) - { - *((Uint32 *)(void *)vP) = SDL_MapRGB(vidformat, - localPalette[*bP].r,localPalette[*bP].g,localPalette[*bP].b); - bP++; - vP += 3; - } - bP += bW; - vP += vW; - } - } - else if (vidformat->BytesPerPixel == 4) - { - for (pH=0;pH < vidSurface->h;pH++) - { - for (pW=0;pW < vidSurface->w;pW++) - { - *((Uint32 *)(void *)vP) = SDL_MapRGB(vidformat, - localPalette[*bP].r,localPalette[*bP].g,localPalette[*bP].b); - bP++; - vP += 4; - } - bP += bW; - vP += vW; - } - } - else - { - ;//NOP - } - } - if (SDL_MUSTLOCK(vidSurface)) SDL_UnlockSurface(vidSurface); - } - else /// \todo 15t15,15tN, others? - { - ;//NOP - } - -#ifdef HAVE_GP2XSDL - //if (blited == 0) - SDL_GP2X_WaitForBlitter(); -#endif - - if (lockedsf == 0 && blited == 0 && vidSurface->flags&SDL_DOUBLEBUF) - SDL_Flip(vidSurface); - else if (blited != -2 && lockedsf == 0) //Alam: -2 for Win32 Direct, yea, i know - SDL_UpdateRect(vidSurface, rect.x, rect.y, 0, 0); //Alam: almost always - else - I_OutputMsg("%s\n",SDL_GetError()); - } -#ifdef HWRENDER - else - { - OglSdlFinishUpdate(cv_vidwait.value); - } -#endif - exposevideo = SDL_FALSE; -} - -// -// I_UpdateNoVsync -// -void I_UpdateNoVsync(void) -{ - INT32 real_vidwait = cv_vidwait.value; - cv_vidwait.value = 0; - I_FinishUpdate(); - cv_vidwait.value = real_vidwait; -} - -// -// I_ReadScreen -// -void I_ReadScreen(UINT8 *scr) -{ - if (rendermode != render_soft) - I_Error ("I_ReadScreen: called while in non-software mode"); - else - VID_BlitLinearScreen(screens[0], scr, - vid.width*vid.bpp, vid.height, - vid.rowbytes, vid.rowbytes); -} - -// -// I_SetPalette -// -void I_SetPalette(RGBA_t *palette) -{ - size_t i; - for (i=0; i<256; i++) - { - localPalette[i].r = palette[i].s.red; - localPalette[i].g = palette[i].s.green; - localPalette[i].b = palette[i].s.blue; - } - if (vidSurface) SDL_SetColors(vidSurface, localPalette, 0, 256); - if (bufSurface) SDL_SetColors(bufSurface, localPalette, 0, 256); -} - -// return number of fullscreen + X11 modes -INT32 VID_NumModes(void) -{ - if (USE_FULLSCREEN && numVidModes != -1) - return numVidModes - firstEntry; - else - return MAXWINMODES; -} - -const char *VID_GetModeName(INT32 modeNum) -{ - if (USE_FULLSCREEN && numVidModes != -1) // fullscreen modes - { - modeNum += firstEntry; - if (modeNum >= numVidModes) - return NULL; - - sprintf(&vidModeName[modeNum][0], "%dx%d", - modeList[modeNum]->w, - modeList[modeNum]->h); - } - else // windowed modes - { - if (modeNum > MAXWINMODES) - return NULL; - - sprintf(&vidModeName[modeNum][0], "%dx%d", - windowedModes[modeNum][0], - windowedModes[modeNum][1]); - } - return &vidModeName[modeNum][0]; -} - -INT32 VID_GetModeForSize(INT32 w, INT32 h) -{ - INT32 matchMode = -1, i; - VID_PrepareModeList(); - if (USE_FULLSCREEN && numVidModes != -1) - { - for (i=firstEntry; iw == w && - modeList[i]->h == h) - { - matchMode = i; - break; - } - } - if (-1 == matchMode) // use smaller mode - { - w -= w%BASEVIDWIDTH; - h -= h%BASEVIDHEIGHT; - for (i=firstEntry; iw == w && - modeList[i]->h == h) - { - matchMode = i; - break; - } - } - if (-1 == matchMode) // use smallest mode - matchMode = numVidModes-1; - } - matchMode -= firstEntry; - } - else - { - for (i=0; iw <= MAXVIDWIDTH && - modeList[i]->h <= MAXVIDHEIGHT) - { - firstEntry = i; - break; - } - } - } - } - allow_fullscreen = true; -} - -static inline void SDLESSet(void) -{ -#ifdef HAVE_DCSDL - INT32 j; - SDL_DC_SetVideoDriver(SDL_DC_DIRECT_VIDEO); //SDL_DC_DMA_VIDEO - for (j=0;j<4;j++) - { - SDL_DC_MapKey(j,SDL_DC_START,SDLK_ESCAPE); - SDL_DC_MapKey(j,SDL_DC_A,SDLK_UNKNOWN); - SDL_DC_MapKey(j,SDL_DC_B,SDLK_UNKNOWN); - SDL_DC_MapKey(j,SDL_DC_X,SDLK_UNKNOWN); - SDL_DC_MapKey(j,SDL_DC_Y,SDLK_UNKNOWN); - SDL_DC_MapKey(j,SDL_DC_L,SDLK_UNKNOWN); - SDL_DC_MapKey(j,SDL_DC_R,SDLK_UNKNOWN); - //SDL_DC_MapKey(j,SDL_DC_LEFT,SDLK_UNKNOWN); - //SDL_DC_MapKey(j,SDL_DC_RIGHT,SDLK_UNKNOWN); - //SDL_DC_MapKey(j,SDL_DC_UP,SDLK_UNKNOWN); - //SDL_DC_MapKey(j,SDL_DC_DOWN,SDLK_UNKNOWN); - } - //SDL_DC_MapKey(0,SDL_DC_L,SDLK_LEFTBRACKET); - //SDL_DC_MapKey(0,SDL_DC_R,SDLK_RIGHTBRACKET); - //SDL_DC_MapKey(0,SDL_DC_START,SDLK_UNKNOWN); - //SDL_DC_MapKey(1,SDL_DC_L,SDLK_z); - //SDL_DC_MapKey(1,SDL_DC_R,SDLK_x); -#endif -#ifdef HAVE_GP2XSDL - SDL_GP2X_MiniDisplay(0,0); - //SDL_GP2X_DenyGfxMemory(NULL, 0); - SDL_GP2X_AllowGfxMemory(NULL, 0); -#endif -} - -static void SDLWMSet(void) -{ -#ifdef RPC_NO_WINDOWS_H - SDL_SysWMinfo SDLWM; - memset(&SDLWM,0,sizeof (SDL_SysWMinfo)); - SDL_VERSION(&SDLWM.version) - if (SDL_GetWMInfo(&SDLWM)) - vid.WndParent = SDLWM.window; - else - vid.WndParent = INVALID_HANDLE_VALUE; - if (vid.WndParent != INVALID_HANDLE_VALUE) - { - SetFocus(vid.WndParent); - ShowWindow(vid.WndParent, SW_SHOW); - } -#ifndef _WIN32_WCE - SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); -#endif -#endif - SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE); -} - -static void* SDLGetDirect(void) -{ -#if 0 //#ifndef __MACH__ // Do not directly access the MacOSX's OpenGL memory - if (!SDL_MUSTLOCK(vidSurface) && SDLmatchVideoformat()) - { - vid.rowbytes = vidSurface->pitch; - return vidSurface->pixels; - } -#endif // you can not use the video memory in pixels member in fullscreen mode - return NULL; -} - -INT32 VID_SetMode(INT32 modeNum) -{ -#ifdef _WIN32_WCE - (void)modeNum; -#else - SDLdoUngrabMouse(); - vid.recalc = true; - BitsPerPixel = (Uint8)cv_scr_depth.value; - //vid.bpp = BitsPerPixel==8?1:2; - // Window title - SDL_WM_SetCaption("SRB2 "VERSIONSTRING, "SRB2"); - - if (render_soft == rendermode) - { - //Alam: SDL_Video system free vidSurface for me - if (vid.buffer) free(vid.buffer); - vid.buffer = NULL; - if (bufSurface) SDL_FreeSurface(bufSurface); - bufSurface = NULL; - } - - if (USE_FULLSCREEN) - { - if (numVidModes != -1) - { - modeNum += firstEntry; - vid.width = modeList[modeNum]->w; - vid.height = modeList[modeNum]->h; - } - else - { - vid.width = windowedModes[modeNum][0]; - vid.height = windowedModes[modeNum][1]; - } - if (render_soft == rendermode) - { - SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsF); - - if (!vidSurface) - { - cv_fullscreen.value = 0; - modeNum = VID_GetModeForSize(vid.width,vid.height); - vid.width = windowedModes[modeNum][0]; - vid.height = windowedModes[modeNum][1]; - SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsW); - if (!vidSurface) - I_Error("Could not set vidmode: %s\n",SDL_GetError()); - } - } -#ifdef HWRENDER - else // (render_soft != rendermode) - { - if (!OglSdlSurface(vid.width, vid.height, true)) - { - cv_fullscreen.value = 0; - modeNum = VID_GetModeForSize(vid.width,vid.height); - vid.width = windowedModes[modeNum][0]; - vid.height = windowedModes[modeNum][1]; - if (!OglSdlSurface(vid.width, vid.height,false)) - I_Error("Could not set vidmode: %s\n",SDL_GetError()); - } - - realwidth = (Uint16)vid.width; - realheight = (Uint16)vid.height; - } -#endif - } - else //(cv_fullscreen.value) - { - vid.width = windowedModes[modeNum][0]; - vid.height = windowedModes[modeNum][1]; - - if (render_soft == rendermode) - { - SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsW); - if (!vidSurface) - I_Error("Could not set vidmode: %s\n",SDL_GetError()); - } -#ifdef HWRENDER - else //(render_soft != rendermode) - { - if (!OglSdlSurface(vid.width, vid.height, false)) - I_Error("Could not set vidmode: %s\n",SDL_GetError()); - realwidth = (Uint16)vid.width; - realheight = (Uint16)vid.height; - } -#endif - } - - vid.modenum = VID_GetModeForSize(vidSurface->w,vidSurface->h); - - if (render_soft == rendermode) - { - vid.rowbytes = vid.width*vid.bpp; - vid.direct = SDLGetDirect(); - vid.buffer = malloc(vid.rowbytes*vid.height*NUMSCREENS); - if (vid.buffer) memset(vid.buffer,0x00,vid.rowbytes*vid.height*NUMSCREENS); - else I_Error ("Not enough memory for video buffer\n"); - } - -#if 0 // broken - if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT)) - vid.height = (INT32)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match -#endif -#endif - I_StartupMouse(); - - SDLWMSet(); - - return true; -} - -void I_StartupGraphics(void) -{ - static char SDLNOMOUSE[] = "SDL_NOMOUSE=1"; - static char SDLVIDEOMID[] = "SDL_VIDEO_CENTERED=center"; - - if (dedicated) - { - rendermode = render_none; - return; - } - if (graphics_started) - return; - - COM_AddCommand ("vid_nummodes", VID_Command_NumModes_f); - COM_AddCommand ("vid_info", VID_Command_Info_f); - COM_AddCommand ("vid_modelist", VID_Command_ModeList_f); - COM_AddCommand ("vid_mode", VID_Command_Mode_f); - CV_RegisterVar (&cv_vidwait); - CV_RegisterVar (&cv_stretch); -#ifdef FILTERS - CV_RegisterVar (&cv_filter); -#endif -#ifdef _PSP // pitch is 0, mod of 0 crash - disable_mouse = true; -#else - disable_mouse = M_CheckParm("-nomouse"); -#endif - if (disable_mouse) - I_PutEnv(SDLNOMOUSE); - if (!I_GetEnv("SDL_VIDEO_CENTERED")) - I_PutEnv(SDLVIDEOMID); - disable_fullscreen = M_CheckParm("-win"); - - keyboard_started = true; -#ifdef _arch_dreamcast - conio_shutdown(); -#endif - -#if !defined(HAVE_TTF) -#ifdef _WIN32 // Initialize Audio as well, otherwise Win32's DirectX can not use audio - if (SDL_InitSubSystem(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0) -#else //SDL_OpenAudio will do SDL_InitSubSystem(SDL_INIT_AUDIO) - if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) -#endif - { -#ifdef _WIN32 - if (SDL_WasInit(SDL_INIT_AUDIO)==0) - CONS_Printf(M_GetText("Couldn't initialize SDL's Audio System with Video System: %s\n"), SDL_GetError()); - if (SDL_WasInit(SDL_INIT_VIDEO)==0) -#endif - { - CONS_Printf(M_GetText("Couldn't initialize SDL's Video System: %s\n"), SDL_GetError()); - return; - } - } -#ifdef REMOTE_DEBUGGING -#ifdef _WII - _break(); // break for debugger -#endif -#endif -#endif - { - char vd[100]; //stack space for video name - CONS_Printf(M_GetText("Starting up with video driver : %s\n"), SDL_VideoDriverName(vd,100)); - if (strncasecmp(vd, "gcvideo", 8) == 0 || strncasecmp(vd, "fbcon", 6) == 0 || strncasecmp(vd, "wii", 4) == 0 || strncasecmp(vd, "psl1ght", 8) == 0) - framebuffer = SDL_TRUE; - } - if (M_CheckParm("-software")) - rendermode = render_soft; - SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY>>1,SDL_DEFAULT_REPEAT_INTERVAL<<2); - SDLESSet(); - VID_Command_ModeList_f(); - vid.buffer = NULL; // For software mode - vid.width = BASEVIDWIDTH; // Default size for startup - vid.height = BASEVIDHEIGHT; // BitsPerPixel is the SDL interface's - vid.recalc = true; // Set up the console stufff - vid.direct = NULL; // Maybe direct access? - vid.bpp = 1; // This is the game engine's Bpp - vid.WndParent = NULL; //For the window? - -#ifdef HAVE_TTF - I_ShutdownTTF(); -#endif - - // Window title -#ifdef _WIN32_WCE - SDL_WM_SetCaption("SRB2 "VERSIONSTRING, "SRB2"); -#else - SDL_WM_SetCaption("SRB2: Starting up", "SRB2"); -#endif - - // Window icon -#ifdef HAVE_IMAGE - icoSurface = IMG_ReadXPMFromArray(SDL_icon_xpm); -#endif - SDL_WM_SetIcon(icoSurface, NULL); - -#ifdef _WIN32 - //DisableAero(); //also disable Aero on Vista -#endif - -#ifdef HWRENDER - if (M_CheckParm("-opengl") || rendermode == render_opengl) - { - rendermode = render_opengl; - HWD.pfnInit = hwSym("Init",NULL); - HWD.pfnFinishUpdate = NULL; - HWD.pfnDraw2DLine = hwSym("Draw2DLine",NULL); - HWD.pfnDrawPolygon = hwSym("DrawPolygon",NULL); - HWD.pfnSetBlend = hwSym("SetBlend",NULL); - HWD.pfnClearBuffer = hwSym("ClearBuffer",NULL); - HWD.pfnSetTexture = hwSym("SetTexture",NULL); - HWD.pfnReadRect = hwSym("ReadRect",NULL); - HWD.pfnGClipRect = hwSym("GClipRect",NULL); - HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache",NULL); - HWD.pfnSetSpecialState = hwSym("SetSpecialState",NULL); - HWD.pfnSetPalette = hwSym("SetPalette",NULL); - HWD.pfnGetTextureUsed = hwSym("GetTextureUsed",NULL); - HWD.pfnDrawMD2 = hwSym("DrawMD2",NULL); - HWD.pfnDrawMD2i = hwSym("DrawMD2i",NULL); - HWD.pfnSetTransform = hwSym("SetTransform",NULL); - HWD.pfnGetRenderVersion = hwSym("GetRenderVersion",NULL); -#ifdef SHUFFLE - HWD.pfnPostImgRedraw = hwSym("PostImgRedraw",NULL); -#endif - HWD.pfnFlushScreenTextures=hwSym("FlushScreenTextures",NULL); - HWD.pfnStartScreenWipe = hwSym("StartScreenWipe",NULL); - HWD.pfnEndScreenWipe = hwSym("EndScreenWipe",NULL); - HWD.pfnDoScreenWipe = hwSym("DoScreenWipe",NULL); - HWD.pfnDrawIntermissionBG=hwSym("DrawIntermissionBG",NULL); - HWD.pfnMakeScreenTexture= hwSym("MakeScreenTexture",NULL); - // check gl renderer lib - if (HWD.pfnGetRenderVersion() != VERSION) - I_Error("%s", M_GetText("The version of the renderer doesn't match the version of the executable\nBe sure you have installed SRB2 properly.\n")); -#if 1 //#ifdef _WIN32_WCE - vid.width = BASEVIDWIDTH; - vid.height = BASEVIDHEIGHT; -#else - vid.width = 640; // hack to make voodoo cards work in 640x480 - vid.height = 480; -#endif - if (HWD.pfnInit(I_Error)) // let load the OpenGL library - { - /* - * We want at least 1 bit R, G, and B, - * and at least 16 bpp. Why 1 bit? May be more? - */ - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 1); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 1); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 1); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); - if (!OglSdlSurface(vid.width, vid.height, (USE_FULLSCREEN))) - if (!OglSdlSurface(vid.width, vid.height, !(USE_FULLSCREEN))) - rendermode = render_soft; - } - else - rendermode = render_soft; - } -#else - rendermode = render_soft; //force software mode when there no HWRENDER code -#endif - if (render_soft == rendermode) - { -#if defined(_WII) - vid.width = 640; - vid.height = 480; -#elif defined(_PS3) - vid.width = 720; - vid.height = 480; -#else - vid.width = BASEVIDWIDTH; - vid.height = BASEVIDHEIGHT; -#endif - SDLSetMode(vid.width, vid.height, BitsPerPixel, surfaceFlagsW); - if (!vidSurface) - { - CONS_Printf(M_GetText("Could not set vidmode: %s\n") ,SDL_GetError()); - vid.rowbytes = 0; - graphics_started = true; - return; - } - vid.rowbytes = vid.width * vid.bpp; - vid.direct = SDLGetDirect(); - vid.buffer = malloc(vid.rowbytes*vid.height*NUMSCREENS); - if (vid.buffer) memset(vid.buffer,0x00,vid.rowbytes*vid.height*NUMSCREENS); - else CONS_Printf("%s", M_GetText("Not enough memory for video buffer\n")); - } - if (M_CheckParm("-nomousegrab")) - mousegrabok = SDL_FALSE; -#ifdef _DEBUG - else - { - char videodriver[4] = {'S','D','L',0}; - if (!M_CheckParm("-mousegrab") && - SDL_VideoDriverName(videodriver,4) && - strncasecmp("X11",videodriver,4) == 0) - mousegrabok = SDL_FALSE; //X11's XGrabPointer not good - } -#endif - realwidth = (Uint16)vid.width; - realheight = (Uint16)vid.height; - - VID_Command_Info_f(); - if (!disable_mouse) SDL_ShowCursor(SDL_DISABLE); - SDLdoUngrabMouse(); - - SDLWMSet(); - - graphics_started = true; -} - -void I_ShutdownGraphics(void) -{ - const rendermode_t oldrendermode = rendermode; - - rendermode = render_none; - if (icoSurface) SDL_FreeSurface(icoSurface); - icoSurface = NULL; - if (render_soft == oldrendermode) - { - vidSurface = NULL; //Alam: SDL_Video system free vidSurface for me - if (vid.buffer) free(vid.buffer); - vid.buffer = NULL; - if (bufSurface) SDL_FreeSurface(bufSurface); - bufSurface = NULL; -#ifdef FILTERS - if (preSurface) SDL_FreeSurface(preSurface); - preSurface = NULL; - if (f2xSurface) SDL_FreeSurface(f2xSurface); - f2xSurface = NULL; -#endif - } - - // was graphics initialized anyway? - if (!graphics_started) - return; - CONS_Printf("I_ShutdownGraphics: "); -#ifdef _WIN32 - //ResetAero(); -#endif - graphics_started = false; - CONS_Printf("%s", M_GetText("shut down\n")); -#ifdef HWRENDER - if (GLUhandle) - hwClose(GLUhandle); -#endif -#ifndef _arch_dreamcast - SDL_QuitSubSystem(SDL_INIT_VIDEO); -#endif - framebuffer = SDL_FALSE; -} -#endif diff --git a/src/sdl12/macosx/English.lproj/InfoPlist.strings b/src/sdl12/macosx/English.lproj/InfoPlist.strings deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/sdl12/macosx/Info.plist b/src/sdl12/macosx/Info.plist deleted file mode 100644 index ae0ce24de..000000000 --- a/src/sdl12/macosx/Info.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - Srb2mac.icns - CFBundleIdentifier - com.yourcompany.Srb2mac - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - NSMainNibFile - SDLMain - NSPrincipalClass - NSApplication - - diff --git a/src/sdl12/macosx/Srb2mac.icns b/src/sdl12/macosx/Srb2mac.icns deleted file mode 100644 index 96cb8a36d..000000000 Binary files a/src/sdl12/macosx/Srb2mac.icns and /dev/null differ diff --git a/src/sdl12/macosx/Srb2mac.pbproj/project.pbxproj b/src/sdl12/macosx/Srb2mac.pbproj/project.pbxproj deleted file mode 100644 index 1f8e3276a..000000000 --- a/src/sdl12/macosx/Srb2mac.pbproj/project.pbxproj +++ /dev/null @@ -1,3560 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 38; - objects = { - 6726EB5E10190F860074DCBA = { - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 7; - files = ( - 6755C8D0101802C300A80195, - 6755C8D1101802C300A80195, - 6755C8D2101802C300A80195, - 6755C8D3101802C300A80195, - 6755C8D4101802C300A80195, - 6755C8D5101802C300A80195, - 6755C8D6101802C300A80195, - 6755C8D7101802C300A80195, - 6755C8D8101802C300A80195, - ); - isa = PBXCopyFilesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 6726EB5F10190FFC0074DCBA = { - buildActionMask = 2147483647; - files = ( - ); - generatedFileNames = ( - ); - isa = PBXShellScriptBuildPhase; - neededFileNames = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "touch -c $SRCROOT/../../comptime.c"; - }; - 6755C7A91017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = lzf.c; - path = ../../lzf.c; - refType = 2; - }; - 6755C7AA1017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = lzf.h; - path = ../../lzf.h; - refType = 2; - }; - 6755C7AB1017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_dllist.h; - path = ../../m_dllist.h; - refType = 2; - }; - 6755C7AC1017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_queue.c; - path = ../../m_queue.c; - refType = 2; - }; - 6755C7AD1017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_queue.h; - path = ../../m_queue.h; - refType = 2; - }; - 6755C7AE1017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_polyobj.c; - path = ../../p_polyobj.c; - refType = 2; - }; - 6755C7AF1017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_polyobj.h; - path = ../../p_polyobj.h; - refType = 2; - }; - 6755C7B11017FE2500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = string.c; - path = ../../string.c; - refType = 2; - }; - 6755C7B21017FE2500A80195 = { - fileRef = 6755C7A91017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7B31017FE2500A80195 = { - fileRef = 6755C7AA1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7B51017FE2500A80195 = { - fileRef = 6755C7AC1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7B71017FE2500A80195 = { - fileRef = 6755C7AE1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7B81017FE2500A80195 = { - fileRef = 6755C7AF1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7BB1017FE2500A80195 = { - fileRef = 6755C7A91017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7BC1017FE2500A80195 = { - fileRef = 6755C7AA1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7BD1017FE2500A80195 = { - fileRef = 6755C7AB1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7BE1017FE2500A80195 = { - fileRef = 6755C7AC1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7BF1017FE2500A80195 = { - fileRef = 6755C7AD1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7C01017FE2500A80195 = { - fileRef = 6755C7AE1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7C11017FE2500A80195 = { - fileRef = 6755C7AF1017FE2500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C7C41017FE4400A80195 = { - children = ( - 6755C7FA1017FE4500A80195, - 6755C7FB1017FE4500A80195, - ); - isa = PBXGroup; - name = macosx; - path = ""; - refType = 2; - }; - 6755C7FA1017FE4500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - path = mac_alert.c; - refType = 2; - }; - 6755C7FB1017FE4500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - path = mac_alert.h; - refType = 2; - }; - 6755C82A1017FE4500A80195 = { - fileEncoding = 30; - isa = PBXFileReference; - name = sdlmain.h; - path = ../sdlmain.h; - refType = 2; - }; - 6755C84B1017FE4500A80195 = { - fileRef = 6755C7FA1017FE4500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8651017FE4500A80195 = { - fileRef = 6755C82A1017FE4500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8861017FE4500A80195 = { - fileRef = 6755C7FA1017FE4500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8871017FE4500A80195 = { - fileRef = 6755C7FB1017FE4500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8A01017FE4500A80195 = { - fileRef = 6755C82A1017FE4500A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8A41017FE8000A80195 = { - children = ( - 84177748085A1097000C01D8, - 84177749085A1097000C01D8, - 8417774A085A1097000C01D8, - 8417774B085A1097000C01D8, - 8417774C085A1097000C01D8, - 8417774D085A1097000C01D8, - 8417774E085A1097000C01D8, - 8417774F085A1097000C01D8, - 84177750085A1097000C01D8, - 84177751085A1097000C01D8, - 84177752085A1097000C01D8, - 84177753085A1097000C01D8, - 84177754085A1097000C01D8, - 84177755085A10AA000C01D8, - 84177756085A10AA000C01D8, - 6755C82A1017FE4500A80195, - 84177757085A10AA000C01D8, - 6755C7C41017FE4400A80195, - ); - isa = PBXGroup; - name = SDL; - path = ""; - refType = 2; - }; - 6755C8BE101802C300A80195 = { - isa = PBXFileReference; - name = drill.dta; - path = ../../../bin/Resources/drill.dta; - refType = 2; - }; - 6755C8BF101802C300A80195 = { - isa = PBXFileReference; - name = fmod.dll; - path = ../../../bin/Resources/fmod.dll; - refType = 2; - }; - 6755C8C0101802C300A80195 = { - isa = PBXFileReference; - name = knux.plr; - path = ../../../bin/Resources/knux.plr; - refType = 2; - }; - 6755C8C1101802C300A80195 = { - isa = PBXFileReference; - name = music.dta; - path = ../../../bin/Resources/music.dta; - refType = 2; - }; - 6755C8C2101802C300A80195 = { - isa = PBXFileReference; - name = rings.wpn; - path = ../../../bin/Resources/rings.wpn; - refType = 2; - }; - 6755C8C3101802C300A80195 = { - isa = PBXFileReference; - name = soar.dta; - path = ../../../bin/Resources/soar.dta; - refType = 2; - }; - 6755C8C4101802C300A80195 = { - isa = PBXFileReference; - name = sonic.plr; - path = ../../../bin/Resources/sonic.plr; - refType = 2; - }; - 6755C8C5101802C300A80195 = { - isa = PBXFileReference; - name = srb2.wad; - path = ../../../bin/Resources/srb2.wad; - refType = 2; - }; - 6755C8C6101802C300A80195 = { - isa = PBXFileReference; - name = tails.plr; - path = ../../../bin/Resources/tails.plr; - refType = 2; - }; - 6755C8C7101802C300A80195 = { - fileRef = 6755C8BE101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8C8101802C300A80195 = { - fileRef = 6755C8BF101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8C9101802C300A80195 = { - fileRef = 6755C8C0101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8CA101802C300A80195 = { - fileRef = 6755C8C1101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8CB101802C300A80195 = { - fileRef = 6755C8C2101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8CC101802C300A80195 = { - fileRef = 6755C8C3101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8CD101802C300A80195 = { - fileRef = 6755C8C4101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8CE101802C300A80195 = { - fileRef = 6755C8C5101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8CF101802C300A80195 = { - fileRef = 6755C8C6101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D0101802C300A80195 = { - fileRef = 6755C8BE101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D1101802C300A80195 = { - fileRef = 6755C8BF101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D2101802C300A80195 = { - fileRef = 6755C8C0101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D3101802C300A80195 = { - fileRef = 6755C8C1101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D4101802C300A80195 = { - fileRef = 6755C8C2101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D5101802C300A80195 = { - fileRef = 6755C8C3101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D6101802C300A80195 = { - fileRef = 6755C8C4101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D7101802C300A80195 = { - fileRef = 6755C8C5101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 6755C8D8101802C300A80195 = { - fileRef = 6755C8C6101802C300A80195; - isa = PBXBuildFile; - settings = { - }; - }; - 677B5EC810180D4E00A80195 = { - fileRef = 84177758085A10D2000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 677B5EC910180D6600A80195 = { - children = ( - 84177758085A10D2000C01D8, - ); - isa = PBXGroup; - name = r_opengl; - refType = 4; - }; - 677B5ECA10180D7100A80195 = { - children = ( - 84F202CA08A92AA0000C01D8, - ); - isa = PBXGroup; - name = s_openal; - refType = 4; - }; - 67B2D0C91018779900A80195 = { - fileRef = 84177748085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 67B2D0CA1018779D00A80195 = { - fileRef = 84177748085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; -//670 -//671 -//672 -//673 -//674 -//840 -//841 -//842 -//843 -//844 - 840CE6B009198AA7000C01D8 = { - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 840CE6B309198ABB000C01D8, - 840CE6B409198ABB000C01D8, - 849BD32D0A7E471D000C01D8, - ); - isa = PBXCopyFilesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 840CE6B309198ABB000C01D8 = { - fileRef = 84C4E04B08620A46000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 840CE6B409198ABB000C01D8 = { - fileRef = 84C4E04C08620A46000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 841776FE085A0C64000C01D8 = { - children = ( - 84C4E00D0862063C000C01D8, - 84177705085A0CDB000C01D8, - 84177706085A0D9D000C01D8, - 84177708085A0DB5000C01D8, - 84177709085A0DD1000C01D8, - 84177712085A0EB5000C01D8, - 8417770B085A0E17000C01D8, - 8417770C085A0E40000C01D8, - 8417770D085A0E4E000C01D8, - 8417770E085A0E5B000C01D8, - 8417770F085A0E66000C01D8, - 84177710085A0E71000C01D8, - 84177711085A0E77000C01D8, - 841779E2085A138F000C01D8, - 84F202C708A92A5D000C01D8, - 84C4E03F0862096F000C01D8, - 84C4E0420862098A000C01D8, - 84C4E045086209D3000C01D8, - 84C4E048086209FF000C01D8, - 84C4E04C08620A46000C01D8, - 84C4E04B08620A46000C01D8, - 849BD31C0A7E45B3000C01D8, - ); - isa = PBXGroup; - refType = 4; - }; - 84177700085A0C64000C01D8 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = NO; - }; - isa = PBXBuildStyle; - name = Development; - }; - 84177701085A0C64000C01D8 = { - buildRules = ( - ); - buildSettings = { - COPY_PHASE_STRIP = YES; - }; - isa = PBXBuildStyle; - name = Deployment; - }; - 84177702085A0C64000C01D8 = { - buildStyles = ( - 84177700085A0C64000C01D8, - 84177701085A0C64000C01D8, - ); - hasScannedForEncodings = 1; - isa = PBXProject; - mainGroup = 841776FE085A0C64000C01D8; - productRefGroup = 841779E2085A138F000C01D8; - projectDirPath = ""; - targets = ( - 841779E0085A138F000C01D8, - 841779E9085A13B1000C01D8, - ); - }; - 84177705085A0CDB000C01D8 = { - children = ( - 849603A80A791C11000C01D8, - 84177713085A0FCE000C01D8, - 84177714085A0FCE000C01D8, - 84177716085A0FCE000C01D8, - 84177717085A0FCE000C01D8, - 84177718085A0FCE000C01D8, - 84177719085A0FCE000C01D8, - 8417771A085A0FCE000C01D8, - 8417771B085A0FCE000C01D8, - 8417771C085A0FCE000C01D8, - 8417771D085A0FCE000C01D8, - 8417771E085A0FCE000C01D8, - 8417771F085A0FCE000C01D8, - 84177720085A0FCE000C01D8, - 84177721085A0FCE000C01D8, - 84177722085A0FCE000C01D8, - 84177723085A0FCE000C01D8, - 84177724085A0FF2000C01D8, - 84177725085A0FF2000C01D8, - 84177726085A0FF2000C01D8, - 84177727085A0FF2000C01D8, - 6755C7B11017FE2500A80195, - ); - isa = PBXGroup; - name = D_SRB2; - path = ""; - refType = 2; - }; - 84177706085A0D9D000C01D8 = { - children = ( - 8417772A085A100E000C01D8, - 8417772B085A100E000C01D8, - 8417772C085A100E000C01D8, - ); - isa = PBXGroup; - name = F_Frame; - path = ""; - refType = 2; - }; - 84177708085A0DB5000C01D8 = { - children = ( - 841779DA085A1347000C01D8, - 841778C6085A1295000C01D8, - 841778C4085A1295000C01D8, - 841778C5085A1295000C01D8, - 8417772D085A1029000C01D8, - 8417772E085A1029000C01D8, - 8417772F085A1029000C01D8, - 84177730085A1029000C01D8, - 84177731085A1029000C01D8, - 841779D4085A1296000C01D8, - 841779D5085A1296000C01D8, - ); - isa = PBXGroup; - name = G_Game; - path = ""; - refType = 2; - }; - 84177709085A0DD1000C01D8 = { - children = ( - 841778BE085A1295000C01D8, - 841778BF085A1295000C01D8, - 841778C2085A1295000C01D8, - 841778C3085A1295000C01D8, - 841778C0085A1295000C01D8, - 841778C1085A1295000C01D8, - 84177732085A1040000C01D8, - 84177733085A1040000C01D8, - 841779D2085A1296000C01D8, - 841779D3085A1296000C01D8, - 841779D8085A1296000C01D8, - 8490D433085DF537000C01D8, - ); - isa = PBXGroup; - name = H_Hud; - path = ""; - refType = 2; - }; - 8417770B085A0E17000C01D8 = { - children = ( - 6755C8A41017FE8000A80195, - 84177759085A10D2000C01D8, - 841777A4085A1200000C01D8, - 841777A5085A1200000C01D8, - 841777A6085A1200000C01D8, - 841777A8085A1200000C01D8, - 841777A9085A1200000C01D8, - 841777AA085A1200000C01D8, - 841777AB085A1200000C01D8, - 841777AC085A1200000C01D8, - 841777AD085A1200000C01D8, - 841777AE085A1200000C01D8, - ); - isa = PBXGroup; - name = I_Interface; - path = ""; - refType = 2; - }; - 8417770C085A0E40000C01D8 = { - children = ( - 8417775A085A10EB000C01D8, - 8417775B085A10EB000C01D8, - 8417775C085A10EB000C01D8, - 8417775D085A10EB000C01D8, - 8417775E085A10EB000C01D8, - 8417775F085A10EB000C01D8, - 6755C7AB1017FE2500A80195, - 84177760085A10EB000C01D8, - 84177761085A10EB000C01D8, - 84177762085A10EB000C01D8, - 84177763085A10EB000C01D8, - 84177764085A10EB000C01D8, - 84177765085A10EB000C01D8, - 6755C7AC1017FE2500A80195, - 6755C7AD1017FE2500A80195, - 84177766085A10EB000C01D8, - 84177767085A10EB000C01D8, - 84177768085A10EB000C01D8, - ); - isa = PBXGroup; - name = M_Misc; - path = ""; - refType = 2; - }; - 8417770D085A0E4E000C01D8 = { - children = ( - 84177769085A1104000C01D8, - 8417776A085A1104000C01D8, - 8417776B085A1104000C01D8, - 8417776C085A1104000C01D8, - 8417776D085A1104000C01D8, - 8417776E085A1104000C01D8, - 8417776F085A1104000C01D8, - 84177770085A1104000C01D8, - 84177771085A1104000C01D8, - 84177772085A1104000C01D8, - 84177773085A1104000C01D8, - 84177774085A1104000C01D8, - 6755C7AE1017FE2500A80195, - 6755C7AF1017FE2500A80195, - 84177775085A1104000C01D8, - 84177776085A1104000C01D8, - 84177777085A1104000C01D8, - 84177778085A1104000C01D8, - 84177779085A1104000C01D8, - 8417777A085A1104000C01D8, - 8417777B085A1104000C01D8, - 8417777C085A1104000C01D8, - 8417777D085A1104000C01D8, - 8417777E085A1104000C01D8, - 8417777F085A1104000C01D8, - 84177780085A1104000C01D8, - ); - isa = PBXGroup; - name = P_Play; - path = ""; - refType = 2; - }; - 8417770E085A0E5B000C01D8 = { - children = ( - 84177781085A111B000C01D8, - 84177782085A111B000C01D8, - 84177783085A111B000C01D8, - 84177784085A111B000C01D8, - 84177785085A111B000C01D8, - 84177786085A111B000C01D8, - 84177787085A111B000C01D8, - 84177788085A111B000C01D8, - 84177789085A111B000C01D8, - 8417778A085A111B000C01D8, - 8417778B085A111B000C01D8, - 8417778C085A111B000C01D8, - 8417778D085A111B000C01D8, - 8417778E085A111B000C01D8, - 8417778F085A111B000C01D8, - 84177790085A111B000C01D8, - 84177791085A111B000C01D8, - 84177792085A111B000C01D8, - 84177793085A111B000C01D8, - 84177794085A111B000C01D8, - 84177795085A111B000C01D8, - 84177796085A111B000C01D8, - 84177797085A111B000C01D8, - 841777A2085A1197000C01D8, - 841777A3085A1197000C01D8, - 8490D436085DF57B000C01D8, - 841779D7085A1296000C01D8, - ); - isa = PBXGroup; - name = R_Rend; - path = ""; - refType = 2; - }; - 8417770F085A0E66000C01D8 = { - children = ( - 84177798085A1138000C01D8, - 84177799085A1138000C01D8, - 8417779A085A1138000C01D8, - 8417779B085A1138000C01D8, - ); - isa = PBXGroup; - name = S_Sounds; - path = ""; - refType = 2; - }; - 84177710085A0E71000C01D8 = { - children = ( - 8417779C085A114C000C01D8, - 8417779D085A114C000C01D8, - 8417779E085A116B000C01D8, - 8417779F085A116B000C01D8, - ); - isa = PBXGroup; - name = SDL_main; - path = ""; - refType = 2; - }; - 84177711085A0E77000C01D8 = { - children = ( - 6755C7A91017FE2500A80195, - 6755C7AA1017FE2500A80195, - 841777AF085A1228000C01D8, - 841777B0085A1228000C01D8, - 841777A0085A117F000C01D8, - 841777A1085A117F000C01D8, - 841778BC085A122A000C01D8, - 841778BD085A122A000C01D8, - ); - isa = PBXGroup; - name = W_Wad; - path = ""; - refType = 2; - }; - 84177712085A0EB5000C01D8 = { - children = ( - 677B5EC910180D6600A80195, - 677B5ECA10180D7100A80195, - 84177734085A106C000C01D8, - 84177735085A106C000C01D8, - 84177736085A106C000C01D8, - 84177737085A106C000C01D8, - 84177738085A106C000C01D8, - 84177739085A106C000C01D8, - 8417773A085A106C000C01D8, - 8417773B085A106C000C01D8, - 8417773C085A106C000C01D8, - 8417773D085A106C000C01D8, - 8417773E085A106C000C01D8, - 8417773F085A106C000C01D8, - 84177740085A106C000C01D8, - 84177741085A106C000C01D8, - 84177742085A106C000C01D8, - 84177743085A106C000C01D8, - 84177744085A106C000C01D8, - 84177745085A106C000C01D8, - 84177746085A106C000C01D8, - 84177747085A106C000C01D8, - ); - isa = PBXGroup; - name = Hw_Hardware; - path = ""; - refType = 2; - }; - 84177713085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_clisrv.c; - path = ../../d_clisrv.c; - refType = 2; - }; - 84177714085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_clisrv.h; - path = ../../d_clisrv.h; - refType = 2; - }; - 84177716085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_event.h; - path = ../../d_event.h; - refType = 2; - }; - 84177717085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_main.c; - path = ../../d_main.c; - refType = 2; - }; - 84177718085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_main.h; - path = ../../d_main.h; - refType = 2; - }; - 84177719085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_net.c; - path = ../../d_net.c; - refType = 2; - }; - 8417771A085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_net.h; - path = ../../d_net.h; - refType = 2; - }; - 8417771B085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_netcmd.c; - path = ../../d_netcmd.c; - refType = 2; - }; - 8417771C085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_netcmd.h; - path = ../../d_netcmd.h; - refType = 2; - }; - 8417771D085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_netfil.c; - path = ../../d_netfil.c; - refType = 2; - }; - 8417771E085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_netfil.h; - path = ../../d_netfil.h; - refType = 2; - }; - 8417771F085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_player.h; - path = ../../d_player.h; - refType = 2; - }; - 84177720085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_think.h; - path = ../../d_think.h; - refType = 2; - }; - 84177721085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = d_ticcmd.h; - path = ../../d_ticcmd.h; - refType = 2; - }; - 84177722085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = dehacked.c; - path = ../../dehacked.c; - refType = 2; - }; - 84177723085A0FCE000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = dehacked.h; - path = ../../dehacked.h; - refType = 2; - }; - 84177724085A0FF2000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = doomdata.h; - path = ../../doomdata.h; - refType = 2; - }; - 84177725085A0FF2000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = doomdef.h; - path = ../../doomdef.h; - refType = 2; - }; - 84177726085A0FF2000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = doomstat.h; - path = ../../doomstat.h; - refType = 2; - }; - 84177727085A0FF2000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = doomtype.h; - path = ../../doomtype.h; - refType = 2; - }; - 8417772A085A100E000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = f_finale.c; - path = ../../f_finale.c; - refType = 2; - }; - 8417772B085A100E000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = f_finale.h; - path = ../../f_finale.h; - refType = 2; - }; - 8417772C085A100E000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = f_wipe.c; - path = ../../f_wipe.c; - refType = 2; - }; - 8417772D085A1029000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = g_game.c; - path = ../../g_game.c; - refType = 2; - }; - 8417772E085A1029000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = g_game.h; - path = ../../g_game.h; - refType = 2; - }; - 8417772F085A1029000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = g_input.c; - path = ../../g_input.c; - refType = 2; - }; - 84177730085A1029000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = g_input.h; - path = ../../g_input.h; - refType = 2; - }; - 84177731085A1029000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = g_state.h; - path = ../../g_state.h; - refType = 2; - }; - 84177732085A1040000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hu_stuff.c; - path = ../../hu_stuff.c; - refType = 2; - }; - 84177733085A1040000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hu_stuff.h; - path = ../../hu_stuff.h; - refType = 2; - }; - 84177734085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_bsp.c; - path = ../../hardware/hw_bsp.c; - refType = 2; - }; - 84177735085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_cache.c; - path = ../../hardware/hw_cache.c; - refType = 2; - }; - 84177736085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_data.h; - path = ../../hardware/hw_data.h; - refType = 2; - }; - 84177737085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_defs.h; - path = ../../hardware/hw_defs.h; - refType = 2; - }; - 84177738085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_dll.h; - path = ../../hardware/hw_dll.h; - refType = 2; - }; - 84177739085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_draw.c; - path = ../../hardware/hw_draw.c; - refType = 2; - }; - 8417773A085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_drv.h; - path = ../../hardware/hw_drv.h; - refType = 2; - }; - 8417773B085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_glide.h; - path = ../../hardware/hw_glide.h; - refType = 2; - }; - 8417773C085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_glob.h; - path = ../../hardware/hw_glob.h; - refType = 2; - }; - 8417773D085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_light.c; - path = ../../hardware/hw_light.c; - refType = 2; - }; - 8417773E085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_light.h; - path = ../../hardware/hw_light.h; - refType = 2; - }; - 8417773F085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_main.c; - path = ../../hardware/hw_main.c; - refType = 2; - }; - 84177740085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_main.h; - path = ../../hardware/hw_main.h; - refType = 2; - }; - 84177741085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_md2.c; - path = ../../hardware/hw_md2.c; - refType = 2; - }; - 84177742085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_md2.h; - path = ../../hardware/hw_md2.h; - refType = 2; - }; - 84177743085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw_trick.c; - path = ../../hardware/hw_trick.c; - refType = 2; - }; - 84177744085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw3dsdrv.h; - path = ../../hardware/hw3dsdrv.h; - refType = 2; - }; - 84177745085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw3sound.c; - path = ../../hardware/hw3sound.c; - refType = 2; - }; - 84177746085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hw3sound.h; - path = ../../hardware/hw3sound.h; - refType = 2; - }; - 84177747085A106C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hws_data.h; - path = ../../hardware/hws_data.h; - refType = 2; - }; - 84177748085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = dosstr.c; - path = ../dosstr.c; - refType = 2; - }; - 84177749085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = endtxt.c; - path = ../endtxt.c; - refType = 2; - }; - 8417774A085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = endtxt.h; - path = ../endtxt.h; - refType = 2; - }; - 8417774B085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = filesrch.c; - path = ../../filesrch.c; - refType = 2; - }; - 8417774C085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hwsym_sdl.c; - path = ../hwsym_sdl.c; - refType = 2; - }; - 8417774D085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = hwsym_sdl.h; - path = ../hwsym_sdl.h; - refType = 2; - }; - 8417774E085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_cdmus.c; - path = ../i_cdmus.c; - refType = 2; - }; - 8417774F085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_main.c; - path = ../i_main.c; - refType = 2; - }; - 84177750085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_net.c; - path = ../i_net.c; - refType = 2; - }; - 84177751085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_sound.c; - path = ../i_sound.c; - refType = 2; - }; - 84177752085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_system.c; - path = ../i_system.c; - refType = 2; - }; - 84177753085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_video.c; - path = ../i_video.c; - refType = 2; - }; - 84177754085A1097000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = IMG_xpm.c; - path = ../IMG_xpm.c; - refType = 2; - }; - 84177755085A10AA000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = ogl_sdl.c; - path = ../ogl_sdl.c; - refType = 2; - }; - 84177756085A10AA000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = ogl_sdl.h; - path = ../ogl_sdl.h; - refType = 2; - }; - 84177757085A10AA000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = SDL_icon.xpm; - path = ../SDL_icon.xpm; - refType = 2; - }; - 84177758085A10D2000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_opengl.c; - path = ../../hardware/r_opengl/r_opengl.c; - refType = 2; - }; - 84177759085A10D2000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_opengl.h; - path = ../../hardware/r_opengl/r_opengl.h; - refType = 2; - }; - 8417775A085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_argv.c; - path = ../../m_argv.c; - refType = 2; - }; - 8417775B085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_argv.h; - path = ../../m_argv.h; - refType = 2; - }; - 8417775C085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_bbox.c; - path = ../../m_bbox.c; - refType = 2; - }; - 8417775D085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_bbox.h; - path = ../../m_bbox.h; - refType = 2; - }; - 8417775E085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_cheat.c; - path = ../../m_cheat.c; - refType = 2; - }; - 8417775F085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_cheat.h; - path = ../../m_cheat.h; - refType = 2; - }; - 84177760085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_fixed.c; - path = ../../m_fixed.c; - refType = 2; - }; - 84177761085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_fixed.h; - path = ../../m_fixed.h; - refType = 2; - }; - 84177762085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_menu.c; - path = ../../m_menu.c; - refType = 2; - }; - 84177763085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_menu.h; - path = ../../m_menu.h; - refType = 2; - }; - 84177764085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_misc.c; - path = ../../m_misc.c; - refType = 2; - }; - 84177765085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_misc.h; - path = ../../m_misc.h; - refType = 2; - }; - 84177764085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = apng.c; - path = ../../apng.c; - refType = 2; - }; - 84177765085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_misc.h; - path = ../../apng.h; - refType = 2; - }; - 84177766085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_random.c; - path = ../../m_random.c; - refType = 2; - }; - 84177767085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_random.h; - path = ../../m_random.h; - refType = 2; - }; - 84177768085A10EB000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = m_swap.h; - path = ../../m_swap.h; - refType = 2; - }; - 84177769085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_ceilng.c; - path = ../../p_ceilng.c; - refType = 2; - }; - 8417776A085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_enemy.c; - path = ../../p_enemy.c; - refType = 2; - }; - 8417776B085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_fab.c; - path = ../../p_fab.c; - refType = 2; - }; - 8417776C085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_floor.c; - path = ../../p_floor.c; - refType = 2; - }; - 8417776D085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_inter.c; - path = ../../p_inter.c; - refType = 2; - }; - 8417776E085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_lights.c; - path = ../../p_lights.c; - refType = 2; - }; - 8417776F085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_local.h; - path = ../../p_local.h; - refType = 2; - }; - 84177770085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_map.c; - path = ../../p_map.c; - refType = 2; - }; - 84177771085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_maputl.c; - path = ../../p_maputl.c; - refType = 2; - }; - 84177772085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_maputl.h; - path = ../../p_maputl.h; - refType = 2; - }; - 84177773085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_mobj.c; - path = ../../p_mobj.c; - refType = 2; - }; - 84177774085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_mobj.h; - path = ../../p_mobj.h; - refType = 2; - }; - 84177775085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_pspr.h; - path = ../../p_pspr.h; - refType = 2; - }; - 84177776085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_saveg.c; - path = ../../p_saveg.c; - refType = 2; - }; - 84177777085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_saveg.h; - path = ../../p_saveg.h; - refType = 2; - }; - 84177778085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_setup.c; - path = ../../p_setup.c; - refType = 2; - }; - 84177779085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_setup.h; - path = ../../p_setup.h; - refType = 2; - }; - 8417777A085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_sight.c; - path = ../../p_sight.c; - refType = 2; - }; - 8417777B085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_spec.c; - path = ../../p_spec.c; - refType = 2; - }; - 8417777C085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_spec.h; - path = ../../p_spec.h; - refType = 2; - }; - 8417777D085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_telept.c; - path = ../../p_telept.c; - refType = 2; - }; - 8417777E085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_tick.c; - path = ../../p_tick.c; - refType = 2; - }; - 8417777F085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_tick.h; - path = ../../p_tick.h; - refType = 2; - }; - 84177780085A1104000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = p_user.c; - path = ../../p_user.c; - refType = 2; - }; - 84177781085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_bsp.c; - path = ../../r_bsp.c; - refType = 2; - }; - 84177782085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_bsp.h; - path = ../../r_bsp.h; - refType = 2; - }; - 84177783085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_data.c; - path = ../../r_data.c; - refType = 2; - }; - 84177784085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_data.h; - path = ../../r_data.h; - refType = 2; - }; - 84177785085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_defs.h; - path = ../../r_defs.h; - refType = 2; - }; - 84177786085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_draw.c; - path = ../../r_draw.c; - refType = 2; - }; - 84177787085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_draw.h; - path = ../../r_draw.h; - refType = 2; - }; - 84177788085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_draw8.c; - path = ../../r_draw8.c; - refType = 2; - }; - 84177789085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_draw16.c; - path = ../../r_draw16.c; - refType = 2; - }; - 8417778A085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_local.h; - path = ../../r_local.h; - refType = 2; - }; - 8417778B085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_main.c; - path = ../../r_main.c; - refType = 2; - }; - 8417778C085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_main.h; - path = ../../r_main.h; - refType = 2; - }; - 8417778D085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_plane.c; - path = ../../r_plane.c; - refType = 2; - }; - 8417778E085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_plane.h; - path = ../../r_plane.h; - refType = 2; - }; - 8417778F085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_segs.c; - path = ../../r_segs.c; - refType = 2; - }; - 84177790085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_segs.h; - path = ../../r_segs.h; - refType = 2; - }; - 84177791085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_sky.c; - path = ../../r_sky.c; - refType = 2; - }; - 84177792085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_sky.h; - path = ../../r_sky.h; - refType = 2; - }; - 84177793085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_splats.c; - path = ../../r_splats.c; - refType = 2; - }; - 84177794085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_splats.h; - path = ../../r_splats.h; - refType = 2; - }; - 84177795085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_state.h; - path = ../../r_state.h; - refType = 2; - }; - 84177796085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_things.c; - path = ../../r_things.c; - refType = 2; - }; - 84177797085A111B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = r_things.h; - path = ../../r_things.h; - refType = 2; - }; - 84177798085A1138000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = s_sound.c; - path = ../../s_sound.c; - refType = 2; - }; - 84177799085A1138000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = s_sound.h; - path = ../../s_sound.h; - refType = 2; - }; - 8417779A085A1138000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = sounds.c; - path = ../../sounds.c; - refType = 2; - }; - 8417779B085A1138000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = sounds.h; - path = ../../sounds.h; - refType = 2; - }; - 8417779C085A114C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - path = mac_alert.c; - refType = 2; - }; - 8417779D085A114C000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - path = mac_alert.h; - refType = 2; - }; - 8417779E085A116B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = SDL_macosx_main.h; - path = ../SDL_main/SDL_macosx_main.h; - refType = 2; - }; - 8417779F085A116B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = SDL_macosx_main.m; - path = ../SDL_main/SDL_macosx_main.m; - refType = 2; - }; - 841777A0085A117F000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = w_wad.c; - path = ../../w_wad.c; - refType = 2; - }; - 841777A1085A117F000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = w_wad.h; - path = ../../w_wad.h; - refType = 2; - }; - 841777A2085A1197000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = screen.c; - path = ../../screen.c; - refType = 2; - }; - 841777A3085A1197000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = screen.h; - path = ../../screen.h; - refType = 2; - }; - 841777A4085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = filesrch.h; - path = ../../filesrch.h; - refType = 2; - }; - 841777A5085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_joy.h; - path = ../../i_joy.h; - refType = 2; - }; - 841777A6085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_net.h; - path = ../../i_net.h; - refType = 2; - }; - 841777A8085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_sound.h; - path = ../../i_sound.h; - refType = 2; - }; - 841777A9085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_system.h; - path = ../../i_system.h; - refType = 2; - }; - 841777AA085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_tcp.c; - path = ../../i_tcp.c; - refType = 2; - }; - 841777AB085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_tcp.h; - path = ../../i_tcp.h; - refType = 2; - }; - 841777AC085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = i_video.h; - path = ../../i_video.h; - refType = 2; - }; - 841777AD085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = mserv.c; - path = ../../mserv.c; - refType = 2; - }; - 841777AE085A1200000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = mserv.h; - path = ../../mserv.h; - refType = 2; - }; - 841777AF085A1228000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = md5.c; - path = ../../md5.c; - refType = 2; - }; - 841777B0085A1228000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = md5.h; - path = ../../md5.h; - refType = 2; - }; - 841778BC085A122A000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = z_zone.c; - path = ../../z_zone.c; - refType = 2; - }; - 841778BD085A122A000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = z_zone.h; - path = ../../z_zone.h; - refType = 2; - }; - 841778BE085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = am_map.c; - path = ../../am_map.c; - refType = 2; - }; - 841778BF085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = am_map.h; - path = ../../am_map.h; - refType = 2; - }; - 841778C0085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = command.c; - path = ../../command.c; - refType = 2; - }; - 841778C1085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = command.h; - path = ../../command.h; - refType = 2; - }; - 841778C2085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = console.c; - path = ../../console.c; - refType = 2; - }; - 841778C3085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = console.h; - path = ../../console.h; - refType = 2; - }; - 841778C4085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = info.c; - path = ../../info.c; - refType = 2; - }; - 841778C5085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = info.h; - path = ../../info.h; - refType = 2; - }; - 841778C6085A1295000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = keys.h; - path = ../../keys.h; - refType = 2; - }; - 841779D2085A1296000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = st_stuff.c; - path = ../../st_stuff.c; - refType = 2; - }; - 841779D3085A1296000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = st_stuff.h; - path = ../../st_stuff.h; - refType = 2; - }; - 841779D4085A1296000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = tables.c; - path = ../../tables.c; - refType = 2; - }; - 841779D5085A1296000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = tables.h; - path = ../../tables.h; - refType = 2; - }; - 841779D7085A1296000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = v_video.h; - path = ../../v_video.h; - refType = 2; - }; - 841779D8085A1296000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = y_inter.c; - path = ../../y_inter.c; - refType = 2; - }; - 841779DA085A1347000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = byteptr.h; - path = ../../byteptr.h; - refType = 2; - }; - 841779DC085A138F000C01D8 = { - buildActionMask = 2147483647; - files = ( - 6755C8C7101802C300A80195, - 6755C8C8101802C300A80195, - 6755C8C9101802C300A80195, - 6755C8CA101802C300A80195, - 6755C8CB101802C300A80195, - 6755C8CC101802C300A80195, - 6755C8CD101802C300A80195, - 6755C8CE101802C300A80195, - 6755C8CF101802C300A80195, - ); - isa = PBXResourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 841779DD085A138F000C01D8 = { - buildActionMask = 2147483647; - files = ( - 84177A2A085A18A8000C01D8, - 84177A2E085A18D2000C01D8, - 84177A30085A18D3000C01D8, - 84177A32085A18D4000C01D8, - 84177A34085A18D5000C01D8, - 84177A39085A18D8000C01D8, - 84177A3F085A18DC000C01D8, - 84177A41085A18E0000C01D8, - 84177A43085A18E1000C01D8, - 84177A46085A18E8000C01D8, - 84177A4A085A18EA000C01D8, - 84177A4E085A18EC000C01D8, - 84177A50085A18F2000C01D8, - 84177A52085A193F000C01D8, - 84177A53085A1940000C01D8, - 84177A54085A1942000C01D8, - 84177A55085A1943000C01D8, - 84177A56085A195A000C01D8, - 84177A57085A195B000C01D8, - 84177A58085A1968000C01D8, - 84177A59085A1969000C01D8, - 84177A5A085A196B000C01D8, - 84177A5B085A197A000C01D8, - 84177A5C085A197C000C01D8, - 84177A5D085A197D000C01D8, - 84177A5E085A197E000C01D8, - 84177A5F085A1980000C01D8, - 84177A61085A1985000C01D8, - 84177A62085A1986000C01D8, - 84177A63085A1988000C01D8, - 84177A64085A1989000C01D8, - 84177A65085A198A000C01D8, - 84177A66085A198A000C01D8, - 84177A67085A198B000C01D8, - 84177A68085A198C000C01D8, - 84177A69085A198E000C01D8, - 84177A6B085A1994000C01D8, - 84177A6C085A1995000C01D8, - 84177A6D085A199D000C01D8, - 84177A6E085A19A0000C01D8, - 84177A6F085A19A1000C01D8, - 84177A70085A19A2000C01D8, - 84177A71085A19A4000C01D8, - 84177A72085A19A5000C01D8, - 84177A73085A19A6000C01D8, - 84177A74085A19A7000C01D8, - 84177A75085A19AC000C01D8, - 84177A76085A19AD000C01D8, - 84177A77085A19AE000C01D8, - 84177A78085A19AE000C01D8, - 84177A79085A19AF000C01D8, - 84177A7A085A19B0000C01D8, - 84177A7B085A19B3000C01D8, - 84177A7C085A19B4000C01D8, - 84177A7D085A19B5000C01D8, - 84177A7E085A19B7000C01D8, - 84177A7F085A19B8000C01D8, - 84177A80085A19B9000C01D8, - 84177A81085A19BA000C01D8, - 84177A82085A19BB000C01D8, - 84177A83085A19BB000C01D8, - 84177A84085A19BC000C01D8, - 84177A85085A19C1000C01D8, - 84177A86085A19C2000C01D8, - 84177A87085A19C3000C01D8, - 84177A88085A19C6000C01D8, - 84177A89085A19C7000C01D8, - 84177A8A085A19C9000C01D8, - 84177A8B085A19CC000C01D8, - 84177A8C085A19CD000C01D8, - 84177A8D085A19CF000C01D8, - 84177A8E085A19D0000C01D8, - 84177A90085A19D8000C01D8, - 84177A91085A19D9000C01D8, - 84177A92085A19DD000C01D8, - 84177A93085A19DF000C01D8, - 84177A94085A19E1000C01D8, - 84177A95085A19E3000C01D8, - 84177A96085A19E6000C01D8, - 8490D438085DF57B000C01D8, - 849603AA0A791C11000C01D8, - 6755C7B21017FE2500A80195, - 6755C7B31017FE2500A80195, - 6755C7B51017FE2500A80195, - 6755C7B71017FE2500A80195, - 6755C7B81017FE2500A80195, - 6755C84B1017FE4500A80195, - 6755C8651017FE4500A80195, - 677B5EC810180D4E00A80195, - 67B2D0C91018779900A80195, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 841779DE085A138F000C01D8 = { - buildActionMask = 2147483647; - files = ( - 84C4E0410862096F000C01D8, - 84C4E0440862098A000C01D8, - 84C4E047086209D3000C01D8, - 84C4E04A086209FF000C01D8, - 84C4E04F08620A46000C01D8, - 84C4E05008620A46000C01D8, - 849BD31E0A7E45B3000C01D8, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 841779E0085A138F000C01D8 = { - buildPhases = ( - 841779DC085A138F000C01D8, - 841779DD085A138F000C01D8, - 841779DE085A138F000C01D8, - ); - buildSettings = { - DEBUGGING_SYMBOLS = NO; - FRAMEWORK_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks\""; - HEADER_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_mixer.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/OpenAL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/libpng.framework/Headers\""; - INSTALL_PATH = "$(HOME)/Applications"; - JAVA_COMPILER_DEBUGGING_SYMBOLS = NO; - OPTIMIZATION_CFLAGS = "-O2"; - OTHER_CFLAGS = "-DMAC_ALERT -DUNIXCOMMON -DSDLMAIN -DHAVE_MIXER -DHAVE_PNG -D_BIG_ENDIAN -DSTDC_HEADERS -DSDL -Wall -Winline -fno-strict-aliasing"; - OTHER_REZFLAGS = ""; - PREBINDING = NO; - PRODUCT_NAME = Srb2; - SECTORDER_FLAGS = ""; - USE_GCC3_PFE_SUPPORT = NO; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas -Wno-long-double"; - WRAPPER_EXTENSION = app; - }; - dependencies = ( - ); - isa = PBXApplicationTarget; - name = Srb2; - productInstallPath = "$(HOME)/Applications"; - productName = Srb2; - productReference = 841779E1085A138F000C01D8; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Srb2 - CFBundleGetInfoString - - CFBundleIconFile - Srb2mac - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Sonic Robo Blast 2 - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.09 - CFBundleSignature - ???? - CFBundleVersion - 1.09 - NSMainNibFile - SDL_Main.nib - NSPrincipalClass - NSApplication - - -"; - }; - 841779E1085A138F000C01D8 = { - isa = PBXApplicationReference; - path = Srb2.app; - refType = 3; - }; - 841779E2085A138F000C01D8 = { - children = ( - 841779E1085A138F000C01D8, - 841779EA085A13B1000C01D8, - ); - isa = PBXGroup; - name = Products; - refType = 4; - }; - 841779E6085A13B1000C01D8 = { - buildActionMask = 2147483647; - files = ( - 84177A98085A1A0B000C01D8, - 84177A99085A1A0E000C01D8, - 84177A9A085A1A0F000C01D8, - 84177A9B085A1A11000C01D8, - 84177A9C085A1A12000C01D8, - 84177A9D085A1A14000C01D8, - 84177A9E085A1A16000C01D8, - 84177A9F085A1A1E000C01D8, - 84177AA0085A1A1F000C01D8, - 84177AA1085A1A24000C01D8, - 84177AA2085A1A25000C01D8, - 84177AA3085A1A27000C01D8, - 84177AA4085A1A28000C01D8, - 84177AA5085A1A2B000C01D8, - 84177AA6085A1A2C000C01D8, - 84177AA7085A1A2D000C01D8, - 84177AA8085A1A2F000C01D8, - 84177AA9085A1A30000C01D8, - 84177AAA085A1A31000C01D8, - 84177AB4085A1A5E000C01D8, - 84177AB5085A1A60000C01D8, - 84177AB8085A1A65000C01D8, - 84177AB9085A1A65000C01D8, - 84177ABA085A1A66000C01D8, - 84177ABB085A1A67000C01D8, - 84177ABC085A1A67000C01D8, - 84177ABD085A1A68000C01D8, - 84177AC1085A1A70000C01D8, - 84177AC2085A1A72000C01D8, - 84177AC3085A1A77000C01D8, - 84177AC4085A1A78000C01D8, - 84177AC5085A1A7A000C01D8, - 84177AC6085A1A7B000C01D8, - 84177AC7085A1A7C000C01D8, - 84177AC8085A1A7D000C01D8, - 84177AC9085A1A7F000C01D8, - 84177ACA085A1A87000C01D8, - 84177ACB085A1A88000C01D8, - 84177ACC085A1A88000C01D8, - 84177ACD085A1A89000C01D8, - 84177ACE085A1A8A000C01D8, - 84177ACF085A1A8B000C01D8, - 84177AD0085A1A8C000C01D8, - 84177AD1085A1A8D000C01D8, - 84177AD2085A1A90000C01D8, - 84177AD4085A1A92000C01D8, - 84177AD5085A1A93000C01D8, - 84177AD6085A1A94000C01D8, - 84177AD7085A1A97000C01D8, - 84177AD8085A1A97000C01D8, - 84177AD9085A1A99000C01D8, - 84177ADA085A1A9F000C01D8, - 84177ADB085A1AA0000C01D8, - 84177ADC085A1AA2000C01D8, - 84177ADF085A1AA4000C01D8, - 84177AE0085A1AA6000C01D8, - 84177AE1085A1AA7000C01D8, - 84177AE2085A1AA8000C01D8, - 84177AE3085A1AA9000C01D8, - 84177AE4085A1AAA000C01D8, - 84177AE5085A1AAE000C01D8, - 84177AE7085A1AB5000C01D8, - 84177AE8085A1AB6000C01D8, - 84177AEB085A1ABD000C01D8, - 84177AEC085A1ABF000C01D8, - 84177AED085A1ABF000C01D8, - 8490D432085DF3D6000C01D8, - 8490D437085DF57B000C01D8, - 8490D43C085E0518000C01D8, - 8490D43D085E05F6000C01D8, - 8490D43E085E05F7000C01D8, - 8490D43F085E05F8000C01D8, - 8490D440085E05FA000C01D8, - 8490D441085E05FB000C01D8, - 8490D442085E05FC000C01D8, - 8490D443085E05FE000C01D8, - 8490D444085E05FF000C01D8, - 8490D445085E0606000C01D8, - 8490D446085E060A000C01D8, - 8490D447085E060B000C01D8, - 8490D448085E067E000C01D8, - 849603A90A791C11000C01D8, - 6755C7BB1017FE2500A80195, - 6755C7BC1017FE2500A80195, - 6755C7BD1017FE2500A80195, - 6755C7BE1017FE2500A80195, - 6755C7BF1017FE2500A80195, - 6755C7C01017FE2500A80195, - 6755C7C11017FE2500A80195, - 6755C8861017FE4500A80195, - 6755C8871017FE4500A80195, - 6755C8A01017FE4500A80195, - 67B2D0CA1018779D00A80195, - ); - isa = PBXSourcesBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 841779E7085A13B1000C01D8 = { - buildActionMask = 2147483647; - files = ( - 84C4E0400862096F000C01D8, - 84C4E0430862098A000C01D8, - 84C4E046086209D3000C01D8, - 84C4E049086209FF000C01D8, - 84C4E04E08620A46000C01D8, - 8494DFE80886EA0D000C01D8, - 849BD31D0A7E45B3000C01D8, - ); - isa = PBXFrameworksBuildPhase; - runOnlyForDeploymentPostprocessing = 0; - }; - 841779E9085A13B1000C01D8 = { - buildPhases = ( - 840CE6B009198AA7000C01D8, - 6726EB5E10190F860074DCBA, - 6726EB5F10190FFC0074DCBA, - 841779E6085A13B1000C01D8, - 841779E7085A13B1000C01D8, - ); - buildSettings = { - FRAMEWORK_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks\""; - HEADER_SEARCH_PATHS = "\"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/SDL_mixer.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/OpenAL.framework/Headers\" \"$(LOCAL_LIBRARY_DIR)/Frameworks/libpng.framework/Headers\""; - INSTALL_PATH = "$(HOME)/Applications"; - OPTIMIZATION_CFLAGS = "-O0"; - OTHER_CFLAGS = "-DMAC_ALERT -DUNIXCOMMON -DSDLMAIN -DHAVE_MIXER -DHAVE_PNG -D_BIG_ENDIAN -DSTDC_HEADERS -DSDL -Wall -W -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wwrite-strings -Wsign-compare -Waggregate-return -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -fno-strict-aliasing -fno-exceptions -D_DEBUG"; - OTHER_REZFLAGS = ""; - PREBINDING = NO; - PRODUCT_NAME = Srb2Debug; - SECTORDER_FLAGS = ""; - USE_GCC3_PFE_SUPPORT = NO; - WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas -Wno-long-double"; - WRAPPER_EXTENSION = app; - }; - dependencies = ( - ); - isa = PBXApplicationTarget; - name = Srb2Debug; - productInstallPath = "$(HOME)/Applications"; - productName = Srb2Debug; - productReference = 841779EA085A13B1000C01D8; - productSettingsXML = " - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Srb2Debug - CFBundleGetInfoString - - CFBundleIconFile - srb2mac - CFBundleIdentifier - - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Sonic Robo Blast 2 - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.09 - CFBundleSignature - ???? - CFBundleVersion - 1.09 Debug - NSMainNibFile - SDL_Main.nib - NSPrincipalClass - NSApplication - - -"; - }; - 841779EA085A13B1000C01D8 = { - isa = PBXApplicationReference; - path = Srb2Debug.app; - refType = 3; - }; - 84177A2A085A18A8000C01D8 = { - fileRef = 84177713085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A2E085A18D2000C01D8 = { - fileRef = 84177717085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A30085A18D3000C01D8 = { - fileRef = 84177719085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A32085A18D4000C01D8 = { - fileRef = 8417771B085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A34085A18D5000C01D8 = { - fileRef = 8417771D085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A39085A18D8000C01D8 = { - fileRef = 84177722085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A41085A18E0000C01D8 = { - fileRef = 8417772A085A100E000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A43085A18E1000C01D8 = { - fileRef = 8417772C085A100E000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A46085A18E8000C01D8 = { - fileRef = 841778C4085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A4A085A18EA000C01D8 = { - fileRef = 8417772D085A1029000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A4E085A18EC000C01D8 = { - fileRef = 841779D4085A1296000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A50085A18F2000C01D8 = { - fileRef = 8417772F085A1029000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A52085A193F000C01D8 = { - fileRef = 841778C2085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A53085A1940000C01D8 = { - fileRef = 841778C0085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A54085A1942000C01D8 = { - fileRef = 841778BE085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A55085A1943000C01D8 = { - fileRef = 84177732085A1040000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A56085A195A000C01D8 = { - fileRef = 841779D2085A1296000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A57085A195B000C01D8 = { - fileRef = 841779D8085A1296000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A58085A1968000C01D8 = { - fileRef = 84177734085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A59085A1969000C01D8 = { - fileRef = 84177735085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A5A085A196B000C01D8 = { - fileRef = 84177739085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A5B085A197A000C01D8 = { - fileRef = 8417773D085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A5C085A197C000C01D8 = { - fileRef = 8417773F085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A5D085A197D000C01D8 = { - fileRef = 84177741085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A5E085A197E000C01D8 = { - fileRef = 84177743085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A5F085A1980000C01D8 = { - fileRef = 84177745085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A61085A1985000C01D8 = { - fileRef = 84177749085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A62085A1986000C01D8 = { - fileRef = 8417774B085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A63085A1988000C01D8 = { - fileRef = 8417774E085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A64085A1989000C01D8 = { - fileRef = 8417774F085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A65085A198A000C01D8 = { - fileRef = 84177750085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A66085A198A000C01D8 = { - fileRef = 84177751085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A67085A198B000C01D8 = { - fileRef = 84177752085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A68085A198C000C01D8 = { - fileRef = 84177753085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A69085A198E000C01D8 = { - fileRef = 84177755085A10AA000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A6B085A1994000C01D8 = { - fileRef = 841777AA085A1200000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A6C085A1995000C01D8 = { - fileRef = 841777AD085A1200000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A6D085A199D000C01D8 = { - fileRef = 8417774C085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A6E085A19A0000C01D8 = { - fileRef = 8417775A085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A6F085A19A1000C01D8 = { - fileRef = 8417775C085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A70085A19A2000C01D8 = { - fileRef = 8417775E085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A71085A19A4000C01D8 = { - fileRef = 84177760085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A72085A19A5000C01D8 = { - fileRef = 84177762085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A73085A19A6000C01D8 = { - fileRef = 84177764085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A74085A19A7000C01D8 = { - fileRef = 84177766085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A75085A19AC000C01D8 = { - fileRef = 84177769085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A76085A19AD000C01D8 = { - fileRef = 8417776A085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A77085A19AE000C01D8 = { - fileRef = 8417776B085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A78085A19AE000C01D8 = { - fileRef = 8417776C085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A79085A19AF000C01D8 = { - fileRef = 8417776D085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A7A085A19B0000C01D8 = { - fileRef = 8417776E085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A7B085A19B3000C01D8 = { - fileRef = 84177770085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A7C085A19B4000C01D8 = { - fileRef = 84177771085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A7D085A19B5000C01D8 = { - fileRef = 84177773085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A7E085A19B7000C01D8 = { - fileRef = 84177776085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A7F085A19B8000C01D8 = { - fileRef = 84177778085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A80085A19B9000C01D8 = { - fileRef = 8417777A085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A81085A19BA000C01D8 = { - fileRef = 8417777B085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A82085A19BB000C01D8 = { - fileRef = 8417777D085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A83085A19BB000C01D8 = { - fileRef = 8417777E085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A84085A19BC000C01D8 = { - fileRef = 84177780085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A85085A19C1000C01D8 = { - fileRef = 84177781085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A86085A19C2000C01D8 = { - fileRef = 84177783085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A87085A19C3000C01D8 = { - fileRef = 84177786085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A88085A19C6000C01D8 = { - fileRef = 8417778B085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A89085A19C7000C01D8 = { - fileRef = 8417778D085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A8A085A19C9000C01D8 = { - fileRef = 8417778F085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A8B085A19CC000C01D8 = { - fileRef = 84177791085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A8C085A19CD000C01D8 = { - fileRef = 84177793085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A8D085A19CF000C01D8 = { - fileRef = 84177796085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A8E085A19D0000C01D8 = { - fileRef = 841777A2085A1197000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A90085A19D8000C01D8 = { - fileRef = 84177798085A1138000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A91085A19D9000C01D8 = { - fileRef = 8417779A085A1138000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A92085A19DD000C01D8 = { - fileRef = 8417779C085A114C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A93085A19DF000C01D8 = { - fileRef = 8417779F085A116B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A94085A19E1000C01D8 = { - fileRef = 841777A0085A117F000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A95085A19E3000C01D8 = { - fileRef = 841777AF085A1228000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A96085A19E6000C01D8 = { - fileRef = 841778BC085A122A000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A98085A1A0B000C01D8 = { - fileRef = 84177713085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A99085A1A0E000C01D8 = { - fileRef = 84177717085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A9A085A1A0F000C01D8 = { - fileRef = 84177719085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A9B085A1A11000C01D8 = { - fileRef = 8417771B085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A9C085A1A12000C01D8 = { - fileRef = 8417771D085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A9D085A1A14000C01D8 = { - fileRef = 84177722085A0FCE000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177A9F085A1A1E000C01D8 = { - fileRef = 8417772A085A100E000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA0085A1A1F000C01D8 = { - fileRef = 8417772C085A100E000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA1085A1A24000C01D8 = { - fileRef = 841778C4085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA2085A1A25000C01D8 = { - fileRef = 8417772D085A1029000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA3085A1A27000C01D8 = { - fileRef = 8417772F085A1029000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA4085A1A28000C01D8 = { - fileRef = 841779D4085A1296000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA5085A1A2B000C01D8 = { - fileRef = 841778BE085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA6085A1A2C000C01D8 = { - fileRef = 841778C2085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA7085A1A2D000C01D8 = { - fileRef = 841778C0085A1295000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA8085A1A2F000C01D8 = { - fileRef = 84177732085A1040000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AA9085A1A30000C01D8 = { - fileRef = 841779D2085A1296000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AAA085A1A31000C01D8 = { - fileRef = 841779D8085A1296000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AB4085A1A5E000C01D8 = { - fileRef = 84177749085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AB5085A1A60000C01D8 = { - fileRef = 8417774B085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AB8085A1A65000C01D8 = { - fileRef = 8417774E085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AB9085A1A65000C01D8 = { - fileRef = 8417774F085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ABA085A1A66000C01D8 = { - fileRef = 84177750085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ABB085A1A67000C01D8 = { - fileRef = 84177751085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ABC085A1A67000C01D8 = { - fileRef = 84177752085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ABD085A1A68000C01D8 = { - fileRef = 84177753085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC1085A1A70000C01D8 = { - fileRef = 841777AA085A1200000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC2085A1A72000C01D8 = { - fileRef = 841777AD085A1200000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC3085A1A77000C01D8 = { - fileRef = 8417775A085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC4085A1A78000C01D8 = { - fileRef = 8417775C085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC5085A1A7A000C01D8 = { - fileRef = 8417775E085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC6085A1A7B000C01D8 = { - fileRef = 84177760085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC7085A1A7C000C01D8 = { - fileRef = 84177762085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC8085A1A7D000C01D8 = { - fileRef = 84177764085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AC9085A1A7F000C01D8 = { - fileRef = 84177766085A10EB000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ACA085A1A87000C01D8 = { - fileRef = 84177769085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ACB085A1A88000C01D8 = { - fileRef = 8417776A085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ACC085A1A88000C01D8 = { - fileRef = 8417776B085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ACD085A1A89000C01D8 = { - fileRef = 8417776C085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ACE085A1A8A000C01D8 = { - fileRef = 8417776D085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ACF085A1A8B000C01D8 = { - fileRef = 8417776E085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD0085A1A8C000C01D8 = { - fileRef = 84177770085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD1085A1A8D000C01D8 = { - fileRef = 84177771085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD2085A1A90000C01D8 = { - fileRef = 84177773085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD4085A1A92000C01D8 = { - fileRef = 84177778085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD5085A1A93000C01D8 = { - fileRef = 8417777A085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD6085A1A94000C01D8 = { - fileRef = 8417777B085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD7085A1A97000C01D8 = { - fileRef = 8417777D085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD8085A1A97000C01D8 = { - fileRef = 8417777E085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AD9085A1A99000C01D8 = { - fileRef = 84177780085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ADA085A1A9F000C01D8 = { - fileRef = 84177781085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ADB085A1AA0000C01D8 = { - fileRef = 84177783085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ADC085A1AA2000C01D8 = { - fileRef = 84177786085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177ADF085A1AA4000C01D8 = { - fileRef = 8417778B085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE0085A1AA6000C01D8 = { - fileRef = 8417778D085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE1085A1AA7000C01D8 = { - fileRef = 8417778F085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE2085A1AA8000C01D8 = { - fileRef = 84177791085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE3085A1AA9000C01D8 = { - fileRef = 84177793085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE4085A1AAA000C01D8 = { - fileRef = 84177796085A111B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE5085A1AAE000C01D8 = { - fileRef = 841777A2085A1197000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE7085A1AB5000C01D8 = { - fileRef = 84177798085A1138000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AE8085A1AB6000C01D8 = { - fileRef = 8417779A085A1138000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AEB085A1ABD000C01D8 = { - fileRef = 841777AF085A1228000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AEC085A1ABF000C01D8 = { - fileRef = 841777A0085A117F000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84177AED085A1ABF000C01D8 = { - fileRef = 841778BC085A122A000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D432085DF3D6000C01D8 = { - fileRef = 84177776085A1104000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D433085DF537000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = y_inter.h; - path = ../../y_inter.h; - refType = 2; - }; - 8490D436085DF57B000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = v_video.c; - path = ../../v_video.c; - refType = 2; - }; - 8490D437085DF57B000C01D8 = { - fileRef = 8490D436085DF57B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D438085DF57B000C01D8 = { - fileRef = 8490D436085DF57B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D43C085E0518000C01D8 = { - fileRef = 8417779F085A116B000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D43D085E05F6000C01D8 = { - fileRef = 84177734085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D43E085E05F7000C01D8 = { - fileRef = 84177735085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D43F085E05F8000C01D8 = { - fileRef = 84177739085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D440085E05FA000C01D8 = { - fileRef = 8417773D085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D441085E05FB000C01D8 = { - fileRef = 8417773F085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D442085E05FC000C01D8 = { - fileRef = 84177741085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D443085E05FE000C01D8 = { - fileRef = 84177743085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D444085E05FF000C01D8 = { - fileRef = 84177745085A106C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D445085E0606000C01D8 = { - fileRef = 8417774C085A1097000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D446085E060A000C01D8 = { - fileRef = 84177755085A10AA000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D447085E060B000C01D8 = { - fileRef = 84177758085A10D2000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8490D448085E067E000C01D8 = { - fileRef = 8417779C085A114C000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 8494DFE80886EA0D000C01D8 = { - fileRef = 84C4E04B08620A46000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 849603A80A791C11000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = comptime.c; - path = ../../comptime.c; - refType = 2; - }; - 849603A90A791C11000C01D8 = { - fileRef = 849603A80A791C11000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 849603AA0A791C11000C01D8 = { - fileRef = 849603A80A791C11000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 849BD31C0A7E45B3000C01D8 = { - isa = PBXFrameworkReference; - name = libpng.framework; - path = /Library/Frameworks/libpng.framework; - refType = 0; - }; - 849BD31D0A7E45B3000C01D8 = { - fileRef = 849BD31C0A7E45B3000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 849BD31E0A7E45B3000C01D8 = { - fileRef = 849BD31C0A7E45B3000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 849BD32D0A7E471D000C01D8 = { - fileRef = 849BD31C0A7E45B3000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E00D0862063C000C01D8 = { - children = ( - 6755C8BE101802C300A80195, - 6755C8BF101802C300A80195, - 6755C8C0101802C300A80195, - 6755C8C1101802C300A80195, - 6755C8C2101802C300A80195, - 6755C8C3101802C300A80195, - 6755C8C4101802C300A80195, - 6755C8C5101802C300A80195, - 6755C8C6101802C300A80195, - ); - isa = PBXGroup; - name = Data; - refType = 4; - }; - 84C4E03F0862096F000C01D8 = { - isa = PBXFrameworkReference; - name = AppKit.framework; - path = /System/Library/Frameworks/AppKit.framework; - refType = 0; - }; - 84C4E0400862096F000C01D8 = { - fileRef = 84C4E03F0862096F000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E0410862096F000C01D8 = { - fileRef = 84C4E03F0862096F000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E0420862098A000C01D8 = { - isa = PBXFrameworkReference; - name = Foundation.framework; - path = /System/Library/Frameworks/Foundation.framework; - refType = 0; - }; - 84C4E0430862098A000C01D8 = { - fileRef = 84C4E0420862098A000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E0440862098A000C01D8 = { - fileRef = 84C4E0420862098A000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E045086209D3000C01D8 = { - isa = PBXFrameworkReference; - name = CoreFoundation.framework; - path = /System/Library/Frameworks/CoreFoundation.framework; - refType = 0; - }; - 84C4E046086209D3000C01D8 = { - fileRef = 84C4E045086209D3000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E047086209D3000C01D8 = { - fileRef = 84C4E045086209D3000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E048086209FF000C01D8 = { - isa = PBXFrameworkReference; - name = ApplicationServices.framework; - path = /System/Library/Frameworks/ApplicationServices.framework; - refType = 0; - }; - 84C4E049086209FF000C01D8 = { - fileRef = 84C4E048086209FF000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E04A086209FF000C01D8 = { - fileRef = 84C4E048086209FF000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E04B08620A46000C01D8 = { - isa = PBXFrameworkReference; - name = SDL_mixer.framework; - path = /Library/Frameworks/SDL_mixer.framework; - refType = 0; - }; - 84C4E04C08620A46000C01D8 = { - isa = PBXFrameworkReference; - name = SDL.framework; - path = /Library/Frameworks/SDL.framework; - refType = 0; - }; - 84C4E04E08620A46000C01D8 = { - fileRef = 84C4E04C08620A46000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E04F08620A46000C01D8 = { - fileRef = 84C4E04B08620A46000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84C4E05008620A46000C01D8 = { - fileRef = 84C4E04C08620A46000C01D8; - isa = PBXBuildFile; - settings = { - }; - }; - 84F202C708A92A5D000C01D8 = { - isa = PBXFrameworkReference; - name = OpenAL.framework; - path = /Library/Frameworks/OpenAL.framework; - refType = 0; - }; - 84F202CA08A92AA0000C01D8 = { - fileEncoding = 30; - isa = PBXFileReference; - name = s_openal.c; - path = ../../hardware/s_openal/s_openal.c; - refType = 2; - }; - }; - rootObject = 84177702085A0C64000C01D8; -} diff --git a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj b/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj deleted file mode 100644 index 69c544c56..000000000 --- a/src/sdl12/macosx/Srb2mac.xcodeproj/project.pbxproj +++ /dev/null @@ -1,1515 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 44; - objects = { - -/* Begin PBXBuildFile section */ - 002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; }; - 002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 002F39F909D0881F00EBEB88 /* SDL.framework */; }; - 1E308E720B71172D0015728C /* lzf.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44B2240B67EADE00BAD059 /* lzf.c */; }; - 1E32C4290B6E6D5D0029E058 /* libpng.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E32C4140B6E6D5D0029E058 /* libpng.framework */; }; - 1E32C42B0B6E6D6E0029E058 /* libpng.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 1E32C4140B6E6D5D0029E058 /* libpng.framework */; }; - 1E44AE750B67CC2B00BAD059 /* hw_bsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE610B67CC2B00BAD059 /* hw_bsp.c */; }; - 1E44AE770B67CC2B00BAD059 /* hw3sound.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE630B67CC2B00BAD059 /* hw3sound.c */; }; - 1E44AE780B67CC2B00BAD059 /* hw_cache.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE640B67CC2B00BAD059 /* hw_cache.c */; }; - 1E44AE7C0B67CC2B00BAD059 /* hw_light.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE680B67CC2B00BAD059 /* hw_light.c */; }; - 1E44AE800B67CC2B00BAD059 /* hw_draw.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE6C0B67CC2B00BAD059 /* hw_draw.c */; }; - 1E44AE820B67CC2B00BAD059 /* hw_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE6E0B67CC2B00BAD059 /* hw_main.c */; }; - 1E44AE840B67CC2B00BAD059 /* hw_md2.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE700B67CC2B00BAD059 /* hw_md2.c */; }; - 1E44AE860B67CC2B00BAD059 /* hw_trick.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE720B67CC2B00BAD059 /* hw_trick.c */; }; - 1E44AEA40B67CC8500BAD059 /* d_clisrv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE8D0B67CC8400BAD059 /* d_clisrv.c */; }; - 1E44AEA70B67CC8500BAD059 /* d_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE900B67CC8400BAD059 /* d_main.c */; }; - 1E44AEA80B67CC8500BAD059 /* d_net.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE910B67CC8500BAD059 /* d_net.c */; }; - 1E44AEAB0B67CC8500BAD059 /* d_netfil.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE940B67CC8500BAD059 /* d_netfil.c */; }; - 1E44AEAF0B67CC8500BAD059 /* d_netcmd.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE980B67CC8500BAD059 /* d_netcmd.c */; }; - 1E44AEB30B67CC8500BAD059 /* dehacked.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AE9C0B67CC8500BAD059 /* dehacked.c */; }; - 1E44AEBF0B67CCA900BAD059 /* f_wipe.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEBC0B67CCA900BAD059 /* f_wipe.c */; }; - 1E44AEC00B67CCA900BAD059 /* f_finale.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEBD0B67CCA900BAD059 /* f_finale.c */; }; - 1E44AEC80B67CCC600BAD059 /* g_game.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEC30B67CCC600BAD059 /* g_game.c */; }; - 1E44AECC0B67CCC600BAD059 /* g_input.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEC70B67CCC600BAD059 /* g_input.c */; }; - 1E44AED00B67CCEE00BAD059 /* hu_stuff.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AECE0B67CCEE00BAD059 /* hu_stuff.c */; }; - 1E44AEDC0B67CD1300BAD059 /* i_tcp.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AED50B67CD1200BAD059 /* i_tcp.c */; }; - 1E44AEE30B67CD2B00BAD059 /* am_map.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEE10B67CD2B00BAD059 /* am_map.c */; }; - 1E44AEE90B67CD3F00BAD059 /* command.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEE70B67CD3F00BAD059 /* command.c */; }; - 1E44AEEC0B67CD4400BAD059 /* comptime.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEEB0B67CD4400BAD059 /* comptime.c */; }; - 1E44AEEF0B67CD5400BAD059 /* console.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEED0B67CD5400BAD059 /* console.c */; }; - 1E44AEF30B67CD7F00BAD059 /* filesrch.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEF10B67CD7F00BAD059 /* filesrch.c */; }; - 1E44AF070B67CDE900BAD059 /* m_argv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEF80B67CDE900BAD059 /* m_argv.c */; }; - 1E44AF0A0B67CDE900BAD059 /* m_cheat.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEFB0B67CDE900BAD059 /* m_cheat.c */; }; - 1E44AF0B0B67CDE900BAD059 /* m_bbox.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEFC0B67CDE900BAD059 /* m_bbox.c */; }; - 1E44AF0D0B67CDE900BAD059 /* m_fixed.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AEFE0B67CDE900BAD059 /* m_fixed.c */; }; - 1E44AF0F0B67CDE900BAD059 /* m_menu.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF000B67CDE900BAD059 /* m_menu.c */; }; - 1E44AF110B67CDE900BAD059 /* m_misc.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF020B67CDE900BAD059 /* m_misc.c */; }; - 1E44AF110B67CDE900BAD059 /* apng.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF020B67CDE900BAD059 /* apng.c */; }; - 1E44AF130B67CDE900BAD059 /* m_random.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF040B67CDE900BAD059 /* m_random.c */; }; - 1E44AF1A0B67CE2A00BAD059 /* info.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF180B67CE2A00BAD059 /* info.c */; }; - 1E44AF1E0B67CE3600BAD059 /* md5.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF1C0B67CE3600BAD059 /* md5.c */; }; - 1E44AF220B67CE4100BAD059 /* mserv.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF200B67CE4100BAD059 /* mserv.c */; }; - 1E44AF3C0B67CE5F00BAD059 /* p_enemy.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF240B67CE5F00BAD059 /* p_enemy.c */; }; - 1E44AF3D0B67CE5F00BAD059 /* p_inter.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF250B67CE5F00BAD059 /* p_inter.c */; }; - 1E44AF3E0B67CE5F00BAD059 /* p_fab.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF260B67CE5F00BAD059 /* p_fab.c */; }; - 1E44AF3F0B67CE5F00BAD059 /* p_lights.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF270B67CE5F00BAD059 /* p_lights.c */; }; - 1E44AF400B67CE5F00BAD059 /* p_map.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF280B67CE5F00BAD059 /* p_map.c */; }; - 1E44AF410B67CE5F00BAD059 /* p_maputl.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF290B67CE5F00BAD059 /* p_maputl.c */; }; - 1E44AF430B67CE5F00BAD059 /* p_mobj.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF2B0B67CE5F00BAD059 /* p_mobj.c */; }; - 1E44AF450B67CE5F00BAD059 /* p_floor.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF2D0B67CE5F00BAD059 /* p_floor.c */; }; - 1E44AF480B67CE5F00BAD059 /* p_saveg.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF300B67CE5F00BAD059 /* p_saveg.c */; }; - 1E44AF4A0B67CE5F00BAD059 /* p_setup.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF320B67CE5F00BAD059 /* p_setup.c */; }; - 1E44AF4C0B67CE5F00BAD059 /* p_sight.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF340B67CE5F00BAD059 /* p_sight.c */; }; - 1E44AF4D0B67CE5F00BAD059 /* p_spec.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF350B67CE5F00BAD059 /* p_spec.c */; }; - 1E44AF4F0B67CE5F00BAD059 /* p_telept.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF370B67CE5F00BAD059 /* p_telept.c */; }; - 1E44AF500B67CE5F00BAD059 /* p_tick.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF380B67CE5F00BAD059 /* p_tick.c */; }; - 1E44AF520B67CE5F00BAD059 /* p_user.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF3A0B67CE5F00BAD059 /* p_user.c */; }; - 1E44AF530B67CE5F00BAD059 /* p_ceilng.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF3B0B67CE5F00BAD059 /* p_ceilng.c */; }; - 1E44AF6C0B67CEC200BAD059 /* r_bsp.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF550B67CEC100BAD059 /* r_bsp.c */; }; - 1E44AF6F0B67CEC200BAD059 /* r_data.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF580B67CEC100BAD059 /* r_data.c */; }; - 1E44AF700B67CEC200BAD059 /* r_draw.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF590B67CEC100BAD059 /* r_draw.c */; }; - 1E44AF730B67CEC200BAD059 /* r_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF5C0B67CEC100BAD059 /* r_main.c */; }; - 1E44AF780B67CEC200BAD059 /* r_plane.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF610B67CEC100BAD059 /* r_plane.c */; }; - 1E44AF7A0B67CEC200BAD059 /* r_segs.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF630B67CEC100BAD059 /* r_segs.c */; }; - 1E44AF7C0B67CEC200BAD059 /* r_sky.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF650B67CEC200BAD059 /* r_sky.c */; }; - 1E44AF7E0B67CEC200BAD059 /* r_splats.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF670B67CEC200BAD059 /* r_splats.c */; }; - 1E44AF810B67CEC200BAD059 /* r_things.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF6A0B67CEC200BAD059 /* r_things.c */; }; - 1E44AF870B67CEE000BAD059 /* s_sound.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF850B67CEE000BAD059 /* s_sound.c */; }; - 1E44AF8B0B67CEE900BAD059 /* screen.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF890B67CEE900BAD059 /* screen.c */; }; - 1E44AF8F0B67CEF000BAD059 /* sounds.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF8D0B67CEF000BAD059 /* sounds.c */; }; - 1E44AF930B67CEFF00BAD059 /* st_stuff.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF910B67CEFF00BAD059 /* st_stuff.c */; }; - 1E44AF9B0B67CF2E00BAD059 /* tables.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AF990B67CF2E00BAD059 /* tables.c */; }; - 1E44AFA50B67CF5D00BAD059 /* v_video.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFA30B67CF5D00BAD059 /* v_video.c */; }; - 1E44AFA90B67CF6400BAD059 /* w_wad.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFA70B67CF6400BAD059 /* w_wad.c */; }; - 1E44AFAD0B67CF6F00BAD059 /* y_inter.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFAB0B67CF6F00BAD059 /* y_inter.c */; }; - 1E44AFB10B67CF7A00BAD059 /* z_zone.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFAF0B67CF7A00BAD059 /* z_zone.c */; }; - 1E44AFC40B67CFDC00BAD059 /* dosstr.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFB40B67CFDC00BAD059 /* dosstr.c */; }; - 1E44AFC50B67CFDC00BAD059 /* endtxt.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFB50B67CFDC00BAD059 /* endtxt.c */; }; - 1E44AFC70B67CFDC00BAD059 /* hwsym_sdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFB70B67CFDC00BAD059 /* hwsym_sdl.c */; }; - 1E44AFC90B67CFDC00BAD059 /* i_cdmus.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFB90B67CFDC00BAD059 /* i_cdmus.c */; }; - 1E44AFCA0B67CFDC00BAD059 /* i_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFBA0B67CFDC00BAD059 /* i_main.c */; }; - 1E44AFCB0B67CFDC00BAD059 /* i_net.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFBB0B67CFDC00BAD059 /* i_net.c */; }; - 1E44AFCD0B67CFDC00BAD059 /* i_system.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFBD0B67CFDC00BAD059 /* i_system.c */; }; - 1E44AFCE0B67CFDC00BAD059 /* i_video.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFBE0B67CFDC00BAD059 /* i_video.c */; }; - 1E44AFD00B67CFDC00BAD059 /* ogl_sdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFC00B67CFDC00BAD059 /* ogl_sdl.c */; }; - 1E44AFEA0B67D06200BAD059 /* Srb2mac.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1E44AFE70B67D06200BAD059 /* Srb2mac.icns */; }; - 1E44AFEB0B67D06200BAD059 /* mac_alert.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFE80B67D06200BAD059 /* mac_alert.c */; }; - 1E44AFED0B67D0AB00BAD059 /* r_opengl.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E44AFEC0B67D0AB00BAD059 /* r_opengl.c */; }; - 1E44B0590B67D81E00BAD059 /* SDL_macosx_main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E44B0570B67D81E00BAD059 /* SDL_macosx_main.m */; }; - 1E66921C0B690C5B00B7313A /* SDL_mixer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E66921B0B690C5B00B7313A /* SDL_mixer.framework */; }; - 1E66921D0B690C6B00B7313A /* SDL_mixer.framework in Copy Frameworks into .app bundle */ = {isa = PBXBuildFile; fileRef = 1E66921B0B690C5B00B7313A /* SDL_mixer.framework */; }; - 67259DFD18D2687D00F02971 /* lua_hudlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67259DFB18D2687D00F02971 /* lua_hudlib.c */; }; - 67259DFE18D2687D00F02971 /* lua_skinlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67259DFC18D2687D00F02971 /* lua_skinlib.c */; }; - 67259E0118D268AE00F02971 /* m_anigif.c in Sources */ = {isa = PBXBuildFile; fileRef = 67259DFF18D268AE00F02971 /* m_anigif.c */; }; - 67259E0618D268F700F02971 /* i_ttf.c in Sources */ = {isa = PBXBuildFile; fileRef = 67259E0218D268F600F02971 /* i_ttf.c */; }; - 67259E0718D268F700F02971 /* mixer_sound.c in Sources */ = {isa = PBXBuildFile; fileRef = 67259E0418D268F600F02971 /* mixer_sound.c */; }; - 67259E0818D268F700F02971 /* sdl_sound.c in Sources */ = {isa = PBXBuildFile; fileRef = 67259E0518D268F600F02971 /* sdl_sound.c */; }; - 67259E2E18D26D5700F02971 /* patch.dta in Resources */ = {isa = PBXBuildFile; fileRef = 67259E2B18D26D5700F02971 /* patch.dta */; }; - 67259E2F18D26D5700F02971 /* rings.dta in Resources */ = {isa = PBXBuildFile; fileRef = 67259E2C18D26D5700F02971 /* rings.dta */; }; - 67259E3018D26D5700F02971 /* srb2.srb in Resources */ = {isa = PBXBuildFile; fileRef = 67259E2D18D26D5700F02971 /* srb2.srb */; }; - 67259E3218D26DD200F02971 /* music.dta in Resources */ = {isa = PBXBuildFile; fileRef = 1E44AE440B67CBE800BAD059 /* music.dta */; }; - 67259E3318D26DD300F02971 /* player.dta in Resources */ = {isa = PBXBuildFile; fileRef = 67A1F91813FAD026009FA3E5 /* player.dta */; }; - 67259E3518D26DD500F02971 /* zones.dta in Resources */ = {isa = PBXBuildFile; fileRef = 6766C0AE11B057E50065F389 /* zones.dta */; }; - 676BB5200E0DE06100C95963 /* m_queue.c in Sources */ = {isa = PBXBuildFile; fileRef = 676BB51C0E0DE06100C95963 /* m_queue.c */; }; - 676BB5220E0DE06100C95963 /* p_polyobj.c in Sources */ = {isa = PBXBuildFile; fileRef = 676BB51E0E0DE06100C95963 /* p_polyobj.c */; }; - 67B83BFA14F57EAB00AAAE4E /* lapi.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BCB14F57EAB00AAAE4E /* lapi.c */; }; - 67B83BFB14F57EAB00AAAE4E /* lauxlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BCD14F57EAB00AAAE4E /* lauxlib.c */; }; - 67B83BFC14F57EAB00AAAE4E /* lbaselib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BCF14F57EAB00AAAE4E /* lbaselib.c */; }; - 67B83BFD14F57EAB00AAAE4E /* lcode.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BD014F57EAB00AAAE4E /* lcode.c */; }; - 67B83BFE14F57EAB00AAAE4E /* ldebug.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BD214F57EAB00AAAE4E /* ldebug.c */; }; - 67B83BFF14F57EAB00AAAE4E /* ldo.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BD414F57EAB00AAAE4E /* ldo.c */; }; - 67B83C0014F57EAB00AAAE4E /* ldump.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BD614F57EAB00AAAE4E /* ldump.c */; }; - 67B83C0114F57EAB00AAAE4E /* lfunc.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BD714F57EAB00AAAE4E /* lfunc.c */; }; - 67B83C0214F57EAB00AAAE4E /* lgc.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BD914F57EAB00AAAE4E /* lgc.c */; }; - 67B83C0314F57EAB00AAAE4E /* linit.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BDB14F57EAB00AAAE4E /* linit.c */; }; - 67B83C0414F57EAB00AAAE4E /* llex.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BDC14F57EAB00AAAE4E /* llex.c */; }; - 67B83C0514F57EAB00AAAE4E /* lmem.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BDF14F57EAB00AAAE4E /* lmem.c */; }; - 67B83C0614F57EAB00AAAE4E /* lobject.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BE114F57EAB00AAAE4E /* lobject.c */; }; - 67B83C0714F57EAB00AAAE4E /* lopcodes.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BE314F57EAB00AAAE4E /* lopcodes.c */; }; - 67B83C0814F57EAB00AAAE4E /* lparser.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BE514F57EAB00AAAE4E /* lparser.c */; }; - 67B83C0914F57EAB00AAAE4E /* lstate.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BE714F57EAB00AAAE4E /* lstate.c */; }; - 67B83C0A14F57EAB00AAAE4E /* lstring.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BE914F57EAB00AAAE4E /* lstring.c */; }; - 67B83C0B14F57EAB00AAAE4E /* lstrlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BEB14F57EAB00AAAE4E /* lstrlib.c */; }; - 67B83C0C14F57EAB00AAAE4E /* ltable.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BEC14F57EAB00AAAE4E /* ltable.c */; }; - 67B83C0D14F57EAB00AAAE4E /* ltablib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BEE14F57EAB00AAAE4E /* ltablib.c */; }; - 67B83C0E14F57EAB00AAAE4E /* ltm.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BEF14F57EAB00AAAE4E /* ltm.c */; }; - 67B83C0F14F57EAB00AAAE4E /* lundump.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BF414F57EAB00AAAE4E /* lundump.c */; }; - 67B83C1014F57EAB00AAAE4E /* lvm.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BF614F57EAB00AAAE4E /* lvm.c */; }; - 67B83C1114F57EAB00AAAE4E /* lzio.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83BF814F57EAB00AAAE4E /* lzio.c */; }; - 67B83C1414F57ECA00AAAE4E /* b_bot.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1214F57ECA00AAAE4E /* b_bot.c */; }; - 67B83C2214F57EE600AAAE4E /* lua_baselib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1514F57EE600AAAE4E /* lua_baselib.c */; }; - 67B83C2314F57EE600AAAE4E /* lua_consolelib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1614F57EE600AAAE4E /* lua_consolelib.c */; }; - 67B83C2414F57EE600AAAE4E /* lua_hooklib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1814F57EE600AAAE4E /* lua_hooklib.c */; }; - 67B83C2514F57EE600AAAE4E /* lua_infolib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1914F57EE600AAAE4E /* lua_infolib.c */; }; - 67B83C2614F57EE600AAAE4E /* lua_maplib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1B14F57EE600AAAE4E /* lua_maplib.c */; }; - 67B83C2714F57EE600AAAE4E /* lua_mathlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1C14F57EE600AAAE4E /* lua_mathlib.c */; }; - 67B83C2814F57EE600AAAE4E /* lua_mobjlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1D14F57EE600AAAE4E /* lua_mobjlib.c */; }; - 67B83C2914F57EE600AAAE4E /* lua_playerlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1E14F57EE600AAAE4E /* lua_playerlib.c */; }; - 67B83C2A14F57EE600AAAE4E /* lua_script.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C1F14F57EE600AAAE4E /* lua_script.c */; }; - 67B83C2B14F57EE600AAAE4E /* lua_thinkerlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C2114F57EE600AAAE4E /* lua_thinkerlib.c */; }; - 67B83C3314F57F1500AAAE4E /* m_cond.c in Sources */ = {isa = PBXBuildFile; fileRef = 67B83C2F14F57F1500AAAE4E /* m_cond.c */; }; - 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 12; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 1E32C42B0B6E6D6E0029E058 /* libpng.framework in Copy Frameworks into .app bundle */, - 1E66921D0B690C6B00B7313A /* SDL_mixer.framework in Copy Frameworks into .app bundle */, - 002F3A0009D0884600EBEB88 /* SDL.framework in Copy Frameworks into .app bundle */, - ); - name = "Copy Frameworks into .app bundle"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 002F39F909D0881F00EBEB88 /* SDL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL.framework; path = /Library/Frameworks/SDL.framework; sourceTree = ""; }; - 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 1E32C4140B6E6D5D0029E058 /* libpng.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libpng.framework; path = /Library/Frameworks/libpng.framework; sourceTree = ""; }; - 1E44AE440B67CBE800BAD059 /* music.dta */ = {isa = PBXFileReference; lastKnownFileType = text; name = music.dta; path = ../../../bin/Resources/music.dta; sourceTree = SOURCE_ROOT; }; - 1E44AE4B0B67CBE800BAD059 /* srb2.wad */ = {isa = PBXFileReference; lastKnownFileType = text; name = srb2.wad; path = ../../../bin/Resources/srb2.wad; sourceTree = SOURCE_ROOT; }; - 1E44AE600B67CC2B00BAD059 /* hw3dsdrv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3dsdrv.h; path = ../../hardware/hw3dsdrv.h; sourceTree = SOURCE_ROOT; }; - 1E44AE610B67CC2B00BAD059 /* hw_bsp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_bsp.c; path = ../../hardware/hw_bsp.c; sourceTree = SOURCE_ROOT; }; - 1E44AE620B67CC2B00BAD059 /* hw_defs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_defs.h; path = ../../hardware/hw_defs.h; sourceTree = SOURCE_ROOT; }; - 1E44AE630B67CC2B00BAD059 /* hw3sound.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw3sound.c; path = ../../hardware/hw3sound.c; sourceTree = SOURCE_ROOT; }; - 1E44AE640B67CC2B00BAD059 /* hw_cache.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_cache.c; path = ../../hardware/hw_cache.c; sourceTree = SOURCE_ROOT; }; - 1E44AE650B67CC2B00BAD059 /* hw_dll.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_dll.h; path = ../../hardware/hw_dll.h; sourceTree = SOURCE_ROOT; }; - 1E44AE660B67CC2B00BAD059 /* hw_drv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_drv.h; path = ../../hardware/hw_drv.h; sourceTree = SOURCE_ROOT; }; - 1E44AE670B67CC2B00BAD059 /* hw_glide.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_glide.h; path = ../../hardware/hw_glide.h; sourceTree = SOURCE_ROOT; }; - 1E44AE680B67CC2B00BAD059 /* hw_light.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_light.c; path = ../../hardware/hw_light.c; sourceTree = SOURCE_ROOT; }; - 1E44AE690B67CC2B00BAD059 /* hw_light.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_light.h; path = ../../hardware/hw_light.h; sourceTree = SOURCE_ROOT; }; - 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw3sound.h; path = ../../hardware/hw3sound.h; sourceTree = SOURCE_ROOT; }; - 1E44AE6B0B67CC2B00BAD059 /* hw_data.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_data.h; path = ../../hardware/hw_data.h; sourceTree = SOURCE_ROOT; }; - 1E44AE6C0B67CC2B00BAD059 /* hw_draw.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_draw.c; path = ../../hardware/hw_draw.c; sourceTree = SOURCE_ROOT; }; - 1E44AE6D0B67CC2B00BAD059 /* hw_glob.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_glob.h; path = ../../hardware/hw_glob.h; sourceTree = SOURCE_ROOT; }; - 1E44AE6E0B67CC2B00BAD059 /* hw_main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_main.c; path = ../../hardware/hw_main.c; sourceTree = SOURCE_ROOT; }; - 1E44AE6F0B67CC2B00BAD059 /* hw_main.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_main.h; path = ../../hardware/hw_main.h; sourceTree = SOURCE_ROOT; }; - 1E44AE700B67CC2B00BAD059 /* hw_md2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_md2.c; path = ../../hardware/hw_md2.c; sourceTree = SOURCE_ROOT; }; - 1E44AE710B67CC2B00BAD059 /* hw_md2.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hw_md2.h; path = ../../hardware/hw_md2.h; sourceTree = SOURCE_ROOT; }; - 1E44AE720B67CC2B00BAD059 /* hw_trick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hw_trick.c; path = ../../hardware/hw_trick.c; sourceTree = SOURCE_ROOT; }; - 1E44AE730B67CC2B00BAD059 /* hws_data.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hws_data.h; path = ../../hardware/hws_data.h; sourceTree = SOURCE_ROOT; }; - 1E44AE8A0B67CC6000BAD059 /* asm_defs.inc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.pascal; name = asm_defs.inc; path = ../../asm_defs.inc; sourceTree = SOURCE_ROOT; }; - 1E44AE8D0B67CC8400BAD059 /* d_clisrv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = d_clisrv.c; path = ../../d_clisrv.c; sourceTree = SOURCE_ROOT; }; - 1E44AE8E0B67CC8400BAD059 /* d_clisrv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_clisrv.h; path = ../../d_clisrv.h; sourceTree = SOURCE_ROOT; }; - 1E44AE8F0B67CC8400BAD059 /* d_event.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_event.h; path = ../../d_event.h; sourceTree = SOURCE_ROOT; }; - 1E44AE900B67CC8400BAD059 /* d_main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = d_main.c; path = ../../d_main.c; sourceTree = SOURCE_ROOT; }; - 1E44AE910B67CC8500BAD059 /* d_net.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = d_net.c; path = ../../d_net.c; sourceTree = SOURCE_ROOT; }; - 1E44AE920B67CC8500BAD059 /* d_net.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_net.h; path = ../../d_net.h; sourceTree = SOURCE_ROOT; }; - 1E44AE930B67CC8500BAD059 /* d_netcmd.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_netcmd.h; path = ../../d_netcmd.h; sourceTree = SOURCE_ROOT; }; - 1E44AE940B67CC8500BAD059 /* d_netfil.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = d_netfil.c; path = ../../d_netfil.c; sourceTree = SOURCE_ROOT; }; - 1E44AE950B67CC8500BAD059 /* d_player.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_player.h; path = ../../d_player.h; sourceTree = SOURCE_ROOT; }; - 1E44AE960B67CC8500BAD059 /* d_think.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_think.h; path = ../../d_think.h; sourceTree = SOURCE_ROOT; }; - 1E44AE980B67CC8500BAD059 /* d_netcmd.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = d_netcmd.c; path = ../../d_netcmd.c; sourceTree = SOURCE_ROOT; }; - 1E44AE990B67CC8500BAD059 /* d_ticcmd.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_ticcmd.h; path = ../../d_ticcmd.h; sourceTree = SOURCE_ROOT; }; - 1E44AE9A0B67CC8500BAD059 /* d_main.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_main.h; path = ../../d_main.h; sourceTree = SOURCE_ROOT; }; - 1E44AE9B0B67CC8500BAD059 /* d_netfil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = d_netfil.h; path = ../../d_netfil.h; sourceTree = SOURCE_ROOT; }; - 1E44AE9C0B67CC8500BAD059 /* dehacked.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dehacked.c; path = ../../dehacked.c; sourceTree = SOURCE_ROOT; }; - 1E44AE9D0B67CC8500BAD059 /* dehacked.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = dehacked.h; path = ../../dehacked.h; sourceTree = SOURCE_ROOT; }; - 1E44AE9E0B67CC8500BAD059 /* doomdata.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = doomdata.h; path = ../../doomdata.h; sourceTree = SOURCE_ROOT; }; - 1E44AE9F0B67CC8500BAD059 /* doomdef.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = doomdef.h; path = ../../doomdef.h; sourceTree = SOURCE_ROOT; }; - 1E44AEA00B67CC8500BAD059 /* doomstat.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = doomstat.h; path = ../../doomstat.h; sourceTree = SOURCE_ROOT; }; - 1E44AEA10B67CC8500BAD059 /* doomtype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = doomtype.h; path = ../../doomtype.h; sourceTree = SOURCE_ROOT; }; - 1E44AEBC0B67CCA900BAD059 /* f_wipe.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = f_wipe.c; path = ../../f_wipe.c; sourceTree = SOURCE_ROOT; }; - 1E44AEBD0B67CCA900BAD059 /* f_finale.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = f_finale.c; path = ../../f_finale.c; sourceTree = SOURCE_ROOT; }; - 1E44AEBE0B67CCA900BAD059 /* f_finale.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = f_finale.h; path = ../../f_finale.h; sourceTree = SOURCE_ROOT; }; - 1E44AEC30B67CCC600BAD059 /* g_game.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = g_game.c; path = ../../g_game.c; sourceTree = SOURCE_ROOT; }; - 1E44AEC40B67CCC600BAD059 /* g_game.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = g_game.h; path = ../../g_game.h; sourceTree = SOURCE_ROOT; }; - 1E44AEC50B67CCC600BAD059 /* g_input.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = g_input.h; path = ../../g_input.h; sourceTree = SOURCE_ROOT; }; - 1E44AEC60B67CCC600BAD059 /* g_state.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = g_state.h; path = ../../g_state.h; sourceTree = SOURCE_ROOT; }; - 1E44AEC70B67CCC600BAD059 /* g_input.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = g_input.c; path = ../../g_input.c; sourceTree = SOURCE_ROOT; }; - 1E44AECE0B67CCEE00BAD059 /* hu_stuff.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hu_stuff.c; path = ../../hu_stuff.c; sourceTree = SOURCE_ROOT; }; - 1E44AECF0B67CCEE00BAD059 /* hu_stuff.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hu_stuff.h; path = ../../hu_stuff.h; sourceTree = SOURCE_ROOT; }; - 1E44AED30B67CD1200BAD059 /* i_net.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = i_net.h; path = ../../i_net.h; sourceTree = SOURCE_ROOT; }; - 1E44AED40B67CD1200BAD059 /* i_sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = i_sound.h; path = ../../i_sound.h; sourceTree = SOURCE_ROOT; }; - 1E44AED50B67CD1200BAD059 /* i_tcp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = i_tcp.c; path = ../../i_tcp.c; sourceTree = SOURCE_ROOT; }; - 1E44AED60B67CD1200BAD059 /* i_tcp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = i_tcp.h; path = ../../i_tcp.h; sourceTree = SOURCE_ROOT; }; - 1E44AED70B67CD1200BAD059 /* i_system.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = i_system.h; path = ../../i_system.h; sourceTree = SOURCE_ROOT; }; - 1E44AED80B67CD1200BAD059 /* i_video.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = i_video.h; path = ../../i_video.h; sourceTree = SOURCE_ROOT; }; - 1E44AED90B67CD1300BAD059 /* i_joy.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = i_joy.h; path = ../../i_joy.h; sourceTree = SOURCE_ROOT; }; - 1E44AEE10B67CD2B00BAD059 /* am_map.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = am_map.c; path = ../../am_map.c; sourceTree = SOURCE_ROOT; }; - 1E44AEE20B67CD2B00BAD059 /* am_map.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = am_map.h; path = ../../am_map.h; sourceTree = SOURCE_ROOT; }; - 1E44AEE50B67CD3200BAD059 /* byteptr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = byteptr.h; path = ../../byteptr.h; sourceTree = SOURCE_ROOT; }; - 1E44AEE70B67CD3F00BAD059 /* command.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = command.c; path = ../../command.c; sourceTree = SOURCE_ROOT; }; - 1E44AEE80B67CD3F00BAD059 /* command.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = command.h; path = ../../command.h; sourceTree = SOURCE_ROOT; }; - 1E44AEEB0B67CD4400BAD059 /* comptime.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = comptime.c; path = ../../comptime.c; sourceTree = SOURCE_ROOT; }; - 1E44AEED0B67CD5400BAD059 /* console.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = console.c; path = ../../console.c; sourceTree = SOURCE_ROOT; }; - 1E44AEEE0B67CD5400BAD059 /* console.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = console.h; path = ../../console.h; sourceTree = SOURCE_ROOT; }; - 1E44AEF10B67CD7F00BAD059 /* filesrch.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = filesrch.c; path = ../../filesrch.c; sourceTree = SOURCE_ROOT; }; - 1E44AEF20B67CD7F00BAD059 /* filesrch.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = filesrch.h; path = ../../filesrch.h; sourceTree = SOURCE_ROOT; }; - 1E44AEF50B67CD9F00BAD059 /* keys.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = keys.h; path = ../../keys.h; sourceTree = SOURCE_ROOT; }; - 1E44AEF80B67CDE900BAD059 /* m_argv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_argv.c; path = ../../m_argv.c; sourceTree = SOURCE_ROOT; }; - 1E44AEF90B67CDE900BAD059 /* m_bbox.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_bbox.h; path = ../../m_bbox.h; sourceTree = SOURCE_ROOT; }; - 1E44AEFA0B67CDE900BAD059 /* m_argv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_argv.h; path = ../../m_argv.h; sourceTree = SOURCE_ROOT; }; - 1E44AEFB0B67CDE900BAD059 /* m_cheat.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_cheat.c; path = ../../m_cheat.c; sourceTree = SOURCE_ROOT; }; - 1E44AEFC0B67CDE900BAD059 /* m_bbox.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_bbox.c; path = ../../m_bbox.c; sourceTree = SOURCE_ROOT; }; - 1E44AEFD0B67CDE900BAD059 /* m_cheat.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_cheat.h; path = ../../m_cheat.h; sourceTree = SOURCE_ROOT; }; - 1E44AEFE0B67CDE900BAD059 /* m_fixed.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_fixed.c; path = ../../m_fixed.c; sourceTree = SOURCE_ROOT; }; - 1E44AEFF0B67CDE900BAD059 /* m_fixed.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_fixed.h; path = ../../m_fixed.h; sourceTree = SOURCE_ROOT; }; - 1E44AF000B67CDE900BAD059 /* m_menu.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_menu.c; path = ../../m_menu.c; sourceTree = SOURCE_ROOT; }; - 1E44AF010B67CDE900BAD059 /* m_menu.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_menu.h; path = ../../m_menu.h; sourceTree = SOURCE_ROOT; }; - 1E44AF020B67CDE900BAD059 /* m_misc.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_misc.c; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; }; - 1E44AF030B67CDE900BAD059 /* m_misc.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_misc.h; path = ../../m_misc.h; sourceTree = SOURCE_ROOT; }; - 1E44AF020B67CDE900BAD059 /* apng.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = apng.c; path = ../../m_misc.c; sourceTree = SOURCE_ROOT; }; - 1E44AF030B67CDE900BAD059 /* apng.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = apng.h; path = ../../m_misc.h; sourceTree = SOURCE_ROOT; }; - 1E44AF040B67CDE900BAD059 /* m_random.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = m_random.c; path = ../../m_random.c; sourceTree = SOURCE_ROOT; }; - 1E44AF050B67CDE900BAD059 /* m_random.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_random.h; path = ../../m_random.h; sourceTree = SOURCE_ROOT; }; - 1E44AF060B67CDE900BAD059 /* m_swap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = m_swap.h; path = ../../m_swap.h; sourceTree = SOURCE_ROOT; }; - 1E44AF180B67CE2A00BAD059 /* info.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = info.c; path = ../../info.c; sourceTree = SOURCE_ROOT; }; - 1E44AF190B67CE2A00BAD059 /* info.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = info.h; path = ../../info.h; sourceTree = SOURCE_ROOT; }; - 1E44AF1C0B67CE3600BAD059 /* md5.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = md5.c; path = ../../md5.c; sourceTree = SOURCE_ROOT; }; - 1E44AF1D0B67CE3600BAD059 /* md5.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = md5.h; path = ../../md5.h; sourceTree = SOURCE_ROOT; }; - 1E44AF200B67CE4100BAD059 /* mserv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = mserv.c; path = ../../mserv.c; sourceTree = SOURCE_ROOT; }; - 1E44AF210B67CE4100BAD059 /* mserv.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = mserv.h; path = ../../mserv.h; sourceTree = SOURCE_ROOT; }; - 1E44AF240B67CE5F00BAD059 /* p_enemy.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_enemy.c; path = ../../p_enemy.c; sourceTree = SOURCE_ROOT; }; - 1E44AF250B67CE5F00BAD059 /* p_inter.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_inter.c; path = ../../p_inter.c; sourceTree = SOURCE_ROOT; }; - 1E44AF260B67CE5F00BAD059 /* p_fab.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_fab.c; path = ../../p_fab.c; sourceTree = SOURCE_ROOT; }; - 1E44AF270B67CE5F00BAD059 /* p_lights.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_lights.c; path = ../../p_lights.c; sourceTree = SOURCE_ROOT; }; - 1E44AF280B67CE5F00BAD059 /* p_map.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_map.c; path = ../../p_map.c; sourceTree = SOURCE_ROOT; }; - 1E44AF290B67CE5F00BAD059 /* p_maputl.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_maputl.c; path = ../../p_maputl.c; sourceTree = SOURCE_ROOT; }; - 1E44AF2A0B67CE5F00BAD059 /* p_maputl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_maputl.h; path = ../../p_maputl.h; sourceTree = SOURCE_ROOT; }; - 1E44AF2B0B67CE5F00BAD059 /* p_mobj.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_mobj.c; path = ../../p_mobj.c; sourceTree = SOURCE_ROOT; }; - 1E44AF2C0B67CE5F00BAD059 /* p_mobj.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_mobj.h; path = ../../p_mobj.h; sourceTree = SOURCE_ROOT; }; - 1E44AF2D0B67CE5F00BAD059 /* p_floor.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_floor.c; path = ../../p_floor.c; sourceTree = SOURCE_ROOT; }; - 1E44AF2E0B67CE5F00BAD059 /* p_local.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_local.h; path = ../../p_local.h; sourceTree = SOURCE_ROOT; }; - 1E44AF2F0B67CE5F00BAD059 /* p_pspr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_pspr.h; path = ../../p_pspr.h; sourceTree = SOURCE_ROOT; }; - 1E44AF300B67CE5F00BAD059 /* p_saveg.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_saveg.c; path = ../../p_saveg.c; sourceTree = SOURCE_ROOT; }; - 1E44AF310B67CE5F00BAD059 /* p_saveg.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_saveg.h; path = ../../p_saveg.h; sourceTree = SOURCE_ROOT; }; - 1E44AF320B67CE5F00BAD059 /* p_setup.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_setup.c; path = ../../p_setup.c; sourceTree = SOURCE_ROOT; }; - 1E44AF330B67CE5F00BAD059 /* p_setup.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_setup.h; path = ../../p_setup.h; sourceTree = SOURCE_ROOT; }; - 1E44AF340B67CE5F00BAD059 /* p_sight.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_sight.c; path = ../../p_sight.c; sourceTree = SOURCE_ROOT; }; - 1E44AF350B67CE5F00BAD059 /* p_spec.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_spec.c; path = ../../p_spec.c; sourceTree = SOURCE_ROOT; }; - 1E44AF360B67CE5F00BAD059 /* p_spec.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_spec.h; path = ../../p_spec.h; sourceTree = SOURCE_ROOT; }; - 1E44AF370B67CE5F00BAD059 /* p_telept.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_telept.c; path = ../../p_telept.c; sourceTree = SOURCE_ROOT; }; - 1E44AF380B67CE5F00BAD059 /* p_tick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_tick.c; path = ../../p_tick.c; sourceTree = SOURCE_ROOT; }; - 1E44AF390B67CE5F00BAD059 /* p_tick.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = p_tick.h; path = ../../p_tick.h; sourceTree = SOURCE_ROOT; }; - 1E44AF3A0B67CE5F00BAD059 /* p_user.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_user.c; path = ../../p_user.c; sourceTree = SOURCE_ROOT; }; - 1E44AF3B0B67CE5F00BAD059 /* p_ceilng.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = p_ceilng.c; path = ../../p_ceilng.c; sourceTree = SOURCE_ROOT; }; - 1E44AF550B67CEC100BAD059 /* r_bsp.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_bsp.c; path = ../../r_bsp.c; sourceTree = SOURCE_ROOT; }; - 1E44AF560B67CEC100BAD059 /* r_bsp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_bsp.h; path = ../../r_bsp.h; sourceTree = SOURCE_ROOT; }; - 1E44AF570B67CEC100BAD059 /* r_defs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_defs.h; path = ../../r_defs.h; sourceTree = SOURCE_ROOT; }; - 1E44AF580B67CEC100BAD059 /* r_data.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_data.c; path = ../../r_data.c; sourceTree = SOURCE_ROOT; }; - 1E44AF590B67CEC100BAD059 /* r_draw.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_draw.c; path = ../../r_draw.c; sourceTree = SOURCE_ROOT; }; - 1E44AF5A0B67CEC100BAD059 /* r_draw16.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_draw16.c; path = ../../r_draw16.c; sourceTree = SOURCE_ROOT; }; - 1E44AF5B0B67CEC100BAD059 /* r_draw8.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_draw8.c; path = ../../r_draw8.c; sourceTree = SOURCE_ROOT; }; - 1E44AF5C0B67CEC100BAD059 /* r_main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_main.c; path = ../../r_main.c; sourceTree = SOURCE_ROOT; }; - 1E44AF5D0B67CEC100BAD059 /* r_main.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_main.h; path = ../../r_main.h; sourceTree = SOURCE_ROOT; }; - 1E44AF5E0B67CEC100BAD059 /* r_data.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_data.h; path = ../../r_data.h; sourceTree = SOURCE_ROOT; }; - 1E44AF5F0B67CEC100BAD059 /* r_draw.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_draw.h; path = ../../r_draw.h; sourceTree = SOURCE_ROOT; }; - 1E44AF600B67CEC100BAD059 /* r_local.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_local.h; path = ../../r_local.h; sourceTree = SOURCE_ROOT; }; - 1E44AF610B67CEC100BAD059 /* r_plane.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_plane.c; path = ../../r_plane.c; sourceTree = SOURCE_ROOT; }; - 1E44AF620B67CEC100BAD059 /* r_plane.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_plane.h; path = ../../r_plane.h; sourceTree = SOURCE_ROOT; }; - 1E44AF630B67CEC100BAD059 /* r_segs.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_segs.c; path = ../../r_segs.c; sourceTree = SOURCE_ROOT; }; - 1E44AF640B67CEC100BAD059 /* r_segs.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_segs.h; path = ../../r_segs.h; sourceTree = SOURCE_ROOT; }; - 1E44AF650B67CEC200BAD059 /* r_sky.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_sky.c; path = ../../r_sky.c; sourceTree = SOURCE_ROOT; }; - 1E44AF660B67CEC200BAD059 /* r_sky.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_sky.h; path = ../../r_sky.h; sourceTree = SOURCE_ROOT; }; - 1E44AF670B67CEC200BAD059 /* r_splats.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_splats.c; path = ../../r_splats.c; sourceTree = SOURCE_ROOT; }; - 1E44AF680B67CEC200BAD059 /* r_splats.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_splats.h; path = ../../r_splats.h; sourceTree = SOURCE_ROOT; }; - 1E44AF690B67CEC200BAD059 /* r_state.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_state.h; path = ../../r_state.h; sourceTree = SOURCE_ROOT; }; - 1E44AF6A0B67CEC200BAD059 /* r_things.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_things.c; path = ../../r_things.c; sourceTree = SOURCE_ROOT; }; - 1E44AF6B0B67CEC200BAD059 /* r_things.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = r_things.h; path = ../../r_things.h; sourceTree = SOURCE_ROOT; }; - 1E44AF850B67CEE000BAD059 /* s_sound.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = s_sound.c; path = ../../s_sound.c; sourceTree = SOURCE_ROOT; }; - 1E44AF860B67CEE000BAD059 /* s_sound.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = s_sound.h; path = ../../s_sound.h; sourceTree = SOURCE_ROOT; }; - 1E44AF890B67CEE900BAD059 /* screen.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = screen.c; path = ../../screen.c; sourceTree = SOURCE_ROOT; }; - 1E44AF8A0B67CEE900BAD059 /* screen.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = screen.h; path = ../../screen.h; sourceTree = SOURCE_ROOT; }; - 1E44AF8D0B67CEF000BAD059 /* sounds.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = sounds.c; path = ../../sounds.c; sourceTree = SOURCE_ROOT; }; - 1E44AF8E0B67CEF000BAD059 /* sounds.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = sounds.h; path = ../../sounds.h; sourceTree = SOURCE_ROOT; }; - 1E44AF910B67CEFF00BAD059 /* st_stuff.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = st_stuff.c; path = ../../st_stuff.c; sourceTree = SOURCE_ROOT; }; - 1E44AF920B67CEFF00BAD059 /* st_stuff.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = st_stuff.h; path = ../../st_stuff.h; sourceTree = SOURCE_ROOT; }; - 1E44AF950B67CF1300BAD059 /* string.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = string.c; path = ../../string.c; sourceTree = SOURCE_ROOT; }; - 1E44AF990B67CF2E00BAD059 /* tables.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = tables.c; path = ../../tables.c; sourceTree = SOURCE_ROOT; }; - 1E44AF9A0B67CF2E00BAD059 /* tables.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = tables.h; path = ../../tables.h; sourceTree = SOURCE_ROOT; }; - 1E44AF9D0B67CF3D00BAD059 /* tmap.nas */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = tmap.nas; path = ../../tmap.nas; sourceTree = SOURCE_ROOT; }; - 1E44AF9F0B67CF4900BAD059 /* tmap_mmx.nas */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = tmap_mmx.nas; path = ../../tmap_mmx.nas; sourceTree = SOURCE_ROOT; }; - 1E44AFA00B67CF4900BAD059 /* tmap_vc.nas */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = tmap_vc.nas; path = ../../tmap_vc.nas; sourceTree = SOURCE_ROOT; }; - 1E44AFA30B67CF5D00BAD059 /* v_video.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = v_video.c; path = ../../v_video.c; sourceTree = SOURCE_ROOT; }; - 1E44AFA40B67CF5D00BAD059 /* v_video.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = v_video.h; path = ../../v_video.h; sourceTree = SOURCE_ROOT; }; - 1E44AFA70B67CF6400BAD059 /* w_wad.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = w_wad.c; path = ../../w_wad.c; sourceTree = SOURCE_ROOT; }; - 1E44AFA80B67CF6400BAD059 /* w_wad.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = w_wad.h; path = ../../w_wad.h; sourceTree = SOURCE_ROOT; }; - 1E44AFAB0B67CF6F00BAD059 /* y_inter.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = y_inter.c; path = ../../y_inter.c; sourceTree = SOURCE_ROOT; }; - 1E44AFAC0B67CF6F00BAD059 /* y_inter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = y_inter.h; path = ../../y_inter.h; sourceTree = SOURCE_ROOT; }; - 1E44AFAF0B67CF7A00BAD059 /* z_zone.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = z_zone.c; path = ../../z_zone.c; sourceTree = SOURCE_ROOT; }; - 1E44AFB00B67CF7A00BAD059 /* z_zone.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = z_zone.h; path = ../../z_zone.h; sourceTree = SOURCE_ROOT; }; - 1E44AFB40B67CFDC00BAD059 /* dosstr.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dosstr.c; path = ../dosstr.c; sourceTree = SOURCE_ROOT; }; - 1E44AFB50B67CFDC00BAD059 /* endtxt.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = endtxt.c; path = ../endtxt.c; sourceTree = SOURCE_ROOT; }; - 1E44AFB60B67CFDC00BAD059 /* endtxt.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = endtxt.h; path = ../endtxt.h; sourceTree = SOURCE_ROOT; }; - 1E44AFB70B67CFDC00BAD059 /* hwsym_sdl.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hwsym_sdl.c; path = ../hwsym_sdl.c; sourceTree = SOURCE_ROOT; }; - 1E44AFB80B67CFDC00BAD059 /* hwsym_sdl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hwsym_sdl.h; path = ../hwsym_sdl.h; sourceTree = SOURCE_ROOT; }; - 1E44AFB90B67CFDC00BAD059 /* i_cdmus.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = i_cdmus.c; path = ../i_cdmus.c; sourceTree = SOURCE_ROOT; }; - 1E44AFBA0B67CFDC00BAD059 /* i_main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = i_main.c; path = ../i_main.c; sourceTree = SOURCE_ROOT; }; - 1E44AFBB0B67CFDC00BAD059 /* i_net.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = i_net.c; path = ../i_net.c; sourceTree = SOURCE_ROOT; }; - 1E44AFBD0B67CFDC00BAD059 /* i_system.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = i_system.c; path = ../i_system.c; sourceTree = SOURCE_ROOT; }; - 1E44AFBE0B67CFDC00BAD059 /* i_video.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = i_video.c; path = ../i_video.c; sourceTree = SOURCE_ROOT; }; - 1E44AFBF0B67CFDC00BAD059 /* IMG_xpm.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = IMG_xpm.c; path = ../IMG_xpm.c; sourceTree = SOURCE_ROOT; }; - 1E44AFC00B67CFDC00BAD059 /* ogl_sdl.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = ogl_sdl.c; path = ../ogl_sdl.c; sourceTree = SOURCE_ROOT; }; - 1E44AFC10B67CFDC00BAD059 /* ogl_sdl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ogl_sdl.h; path = ../ogl_sdl.h; sourceTree = SOURCE_ROOT; }; - 1E44AFC20B67CFDC00BAD059 /* SDL_icon.xpm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = SDL_icon.xpm; path = ../SDL_icon.xpm; sourceTree = SOURCE_ROOT; }; - 1E44AFC30B67CFDC00BAD059 /* sdlmain.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = sdlmain.h; path = ../sdlmain.h; sourceTree = SOURCE_ROOT; }; - 1E44AFD50B67D03100BAD059 /* filters.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = filters.c; path = ../filter/filters.c; sourceTree = SOURCE_ROOT; }; - 1E44AFD60B67D03100BAD059 /* filters.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = filters.h; path = ../filter/filters.h; sourceTree = SOURCE_ROOT; }; - 1E44AFD70B67D03100BAD059 /* hq2x.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = hq2x.c; path = ../filter/hq2x.c; sourceTree = SOURCE_ROOT; }; - 1E44AFD80B67D03100BAD059 /* hq2x.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = hq2x.h; path = ../filter/hq2x.h; sourceTree = SOURCE_ROOT; }; - 1E44AFD90B67D03100BAD059 /* interp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = interp.h; path = ../filter/interp.h; sourceTree = SOURCE_ROOT; }; - 1E44AFDA0B67D03100BAD059 /* lq2x.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lq2x.c; path = ../filter/lq2x.c; sourceTree = SOURCE_ROOT; }; - 1E44AFDB0B67D03100BAD059 /* lq2x.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = lq2x.h; path = ../filter/lq2x.h; sourceTree = SOURCE_ROOT; }; - 1E44AFDC0B67D03100BAD059 /* main.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../filter/main.c; sourceTree = SOURCE_ROOT; }; - 1E44AFE60B67D06200BAD059 /* mac_alert.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = mac_alert.h; sourceTree = SOURCE_ROOT; }; - 1E44AFE70B67D06200BAD059 /* Srb2mac.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Srb2mac.icns; sourceTree = SOURCE_ROOT; }; - 1E44AFE80B67D06200BAD059 /* mac_alert.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = mac_alert.c; sourceTree = SOURCE_ROOT; }; - 1E44AFEC0B67D0AB00BAD059 /* r_opengl.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = r_opengl.c; path = ../../hardware/r_opengl/r_opengl.c; sourceTree = SOURCE_ROOT; }; - 1E44B0560B67D81E00BAD059 /* SDL_macosx_main.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SDL_macosx_main.h; path = ../SDL_main/SDL_macosx_main.h; sourceTree = SOURCE_ROOT; }; - 1E44B0570B67D81E00BAD059 /* SDL_macosx_main.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SDL_macosx_main.m; path = ../SDL_main/SDL_macosx_main.m; sourceTree = SOURCE_ROOT; }; - 1E44B2240B67EADE00BAD059 /* lzf.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lzf.c; path = ../../lzf.c; sourceTree = SOURCE_ROOT; }; - 1E44B2250B67EADE00BAD059 /* lzf.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = lzf.h; path = ../../lzf.h; sourceTree = SOURCE_ROOT; }; - 1E66921B0B690C5B00B7313A /* SDL_mixer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL_mixer.framework; path = /Library/Frameworks/SDL_mixer.framework; sourceTree = ""; }; - 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; - 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = ""; }; - 67259DFA18D2687D00F02971 /* lua_hud.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua_hud.h; path = ../../lua_hud.h; sourceTree = SOURCE_ROOT; }; - 67259DFB18D2687D00F02971 /* lua_hudlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_hudlib.c; path = ../../lua_hudlib.c; sourceTree = SOURCE_ROOT; }; - 67259DFC18D2687D00F02971 /* lua_skinlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_skinlib.c; path = ../../lua_skinlib.c; sourceTree = SOURCE_ROOT; }; - 67259DFF18D268AE00F02971 /* m_anigif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = m_anigif.c; path = ../../m_anigif.c; sourceTree = SOURCE_ROOT; }; - 67259E0018D268AE00F02971 /* m_anigif.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = m_anigif.h; path = ../../m_anigif.h; sourceTree = SOURCE_ROOT; }; - 67259E0218D268F600F02971 /* i_ttf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = i_ttf.c; path = ../i_ttf.c; sourceTree = SOURCE_ROOT; }; - 67259E0318D268F600F02971 /* i_ttf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = i_ttf.h; path = ../i_ttf.h; sourceTree = SOURCE_ROOT; }; - 67259E0418D268F600F02971 /* mixer_sound.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mixer_sound.c; path = ../mixer_sound.c; sourceTree = SOURCE_ROOT; }; - 67259E0518D268F600F02971 /* sdl_sound.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = sdl_sound.c; path = ../sdl_sound.c; sourceTree = SOURCE_ROOT; }; - 67259E2B18D26D5700F02971 /* patch.dta */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = patch.dta; path = ../../../bin/Resources/patch.dta; sourceTree = SOURCE_ROOT; }; - 67259E2C18D26D5700F02971 /* rings.dta */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rings.dta; path = ../../../bin/Resources/rings.dta; sourceTree = SOURCE_ROOT; }; - 67259E2D18D26D5700F02971 /* srb2.srb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = srb2.srb; path = ../../../bin/Resources/srb2.srb; sourceTree = SOURCE_ROOT; }; - 6766C0AE11B057E50065F389 /* zones.dta */ = {isa = PBXFileReference; lastKnownFileType = text; name = zones.dta; path = ../../../bin/Resources/zones.dta; sourceTree = SOURCE_ROOT; }; - 676BB51C0E0DE06100C95963 /* m_queue.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = m_queue.c; path = ../../m_queue.c; sourceTree = SOURCE_ROOT; }; - 676BB51D0E0DE06100C95963 /* m_queue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = m_queue.h; path = ../../m_queue.h; sourceTree = SOURCE_ROOT; }; - 676BB51E0E0DE06100C95963 /* p_polyobj.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = p_polyobj.c; path = ../../p_polyobj.c; sourceTree = SOURCE_ROOT; }; - 676BB51F0E0DE06100C95963 /* p_polyobj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = p_polyobj.h; path = ../../p_polyobj.h; sourceTree = SOURCE_ROOT; }; - 67A1F91813FAD026009FA3E5 /* player.dta */ = {isa = PBXFileReference; lastKnownFileType = text; name = player.dta; path = ../../../bin/Resources/player.dta; sourceTree = SOURCE_ROOT; }; - 67B2071C1180FA8200E93654 /* vid_copy.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = vid_copy.s; path = ../../vid_copy.s; sourceTree = SOURCE_ROOT; }; - 67B83BCB14F57EAB00AAAE4E /* lapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lapi.c; path = ../../blua/lapi.c; sourceTree = SOURCE_ROOT; }; - 67B83BCC14F57EAB00AAAE4E /* lapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lapi.h; path = ../../blua/lapi.h; sourceTree = SOURCE_ROOT; }; - 67B83BCD14F57EAB00AAAE4E /* lauxlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lauxlib.c; path = ../../blua/lauxlib.c; sourceTree = SOURCE_ROOT; }; - 67B83BCE14F57EAB00AAAE4E /* lauxlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lauxlib.h; path = ../../blua/lauxlib.h; sourceTree = SOURCE_ROOT; }; - 67B83BCF14F57EAB00AAAE4E /* lbaselib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lbaselib.c; path = ../../blua/lbaselib.c; sourceTree = SOURCE_ROOT; }; - 67B83BD014F57EAB00AAAE4E /* lcode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lcode.c; path = ../../blua/lcode.c; sourceTree = SOURCE_ROOT; }; - 67B83BD114F57EAB00AAAE4E /* lcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lcode.h; path = ../../blua/lcode.h; sourceTree = SOURCE_ROOT; }; - 67B83BD214F57EAB00AAAE4E /* ldebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ldebug.c; path = ../../blua/ldebug.c; sourceTree = SOURCE_ROOT; }; - 67B83BD314F57EAB00AAAE4E /* ldebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ldebug.h; path = ../../blua/ldebug.h; sourceTree = SOURCE_ROOT; }; - 67B83BD414F57EAB00AAAE4E /* ldo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ldo.c; path = ../../blua/ldo.c; sourceTree = SOURCE_ROOT; }; - 67B83BD514F57EAB00AAAE4E /* ldo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ldo.h; path = ../../blua/ldo.h; sourceTree = SOURCE_ROOT; }; - 67B83BD614F57EAB00AAAE4E /* ldump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ldump.c; path = ../../blua/ldump.c; sourceTree = SOURCE_ROOT; }; - 67B83BD714F57EAB00AAAE4E /* lfunc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lfunc.c; path = ../../blua/lfunc.c; sourceTree = SOURCE_ROOT; }; - 67B83BD814F57EAB00AAAE4E /* lfunc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lfunc.h; path = ../../blua/lfunc.h; sourceTree = SOURCE_ROOT; }; - 67B83BD914F57EAB00AAAE4E /* lgc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lgc.c; path = ../../blua/lgc.c; sourceTree = SOURCE_ROOT; }; - 67B83BDA14F57EAB00AAAE4E /* lgc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lgc.h; path = ../../blua/lgc.h; sourceTree = SOURCE_ROOT; }; - 67B83BDB14F57EAB00AAAE4E /* linit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = linit.c; path = ../../blua/linit.c; sourceTree = SOURCE_ROOT; }; - 67B83BDC14F57EAB00AAAE4E /* llex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = llex.c; path = ../../blua/llex.c; sourceTree = SOURCE_ROOT; }; - 67B83BDD14F57EAB00AAAE4E /* llex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = llex.h; path = ../../blua/llex.h; sourceTree = SOURCE_ROOT; }; - 67B83BDE14F57EAB00AAAE4E /* llimits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = llimits.h; path = ../../blua/llimits.h; sourceTree = SOURCE_ROOT; }; - 67B83BDF14F57EAB00AAAE4E /* lmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lmem.c; path = ../../blua/lmem.c; sourceTree = SOURCE_ROOT; }; - 67B83BE014F57EAB00AAAE4E /* lmem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lmem.h; path = ../../blua/lmem.h; sourceTree = SOURCE_ROOT; }; - 67B83BE114F57EAB00AAAE4E /* lobject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lobject.c; path = ../../blua/lobject.c; sourceTree = SOURCE_ROOT; }; - 67B83BE214F57EAB00AAAE4E /* lobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lobject.h; path = ../../blua/lobject.h; sourceTree = SOURCE_ROOT; }; - 67B83BE314F57EAB00AAAE4E /* lopcodes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lopcodes.c; path = ../../blua/lopcodes.c; sourceTree = SOURCE_ROOT; }; - 67B83BE414F57EAB00AAAE4E /* lopcodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lopcodes.h; path = ../../blua/lopcodes.h; sourceTree = SOURCE_ROOT; }; - 67B83BE514F57EAB00AAAE4E /* lparser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lparser.c; path = ../../blua/lparser.c; sourceTree = SOURCE_ROOT; }; - 67B83BE614F57EAB00AAAE4E /* lparser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lparser.h; path = ../../blua/lparser.h; sourceTree = SOURCE_ROOT; }; - 67B83BE714F57EAB00AAAE4E /* lstate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lstate.c; path = ../../blua/lstate.c; sourceTree = SOURCE_ROOT; }; - 67B83BE814F57EAB00AAAE4E /* lstate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lstate.h; path = ../../blua/lstate.h; sourceTree = SOURCE_ROOT; }; - 67B83BE914F57EAB00AAAE4E /* lstring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lstring.c; path = ../../blua/lstring.c; sourceTree = SOURCE_ROOT; }; - 67B83BEA14F57EAB00AAAE4E /* lstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lstring.h; path = ../../blua/lstring.h; sourceTree = SOURCE_ROOT; }; - 67B83BEB14F57EAB00AAAE4E /* lstrlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lstrlib.c; path = ../../blua/lstrlib.c; sourceTree = SOURCE_ROOT; }; - 67B83BEC14F57EAB00AAAE4E /* ltable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ltable.c; path = ../../blua/ltable.c; sourceTree = SOURCE_ROOT; }; - 67B83BED14F57EAB00AAAE4E /* ltable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ltable.h; path = ../../blua/ltable.h; sourceTree = SOURCE_ROOT; }; - 67B83BEE14F57EAB00AAAE4E /* ltablib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ltablib.c; path = ../../blua/ltablib.c; sourceTree = SOURCE_ROOT; }; - 67B83BEF14F57EAB00AAAE4E /* ltm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ltm.c; path = ../../blua/ltm.c; sourceTree = SOURCE_ROOT; }; - 67B83BF014F57EAB00AAAE4E /* ltm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ltm.h; path = ../../blua/ltm.h; sourceTree = SOURCE_ROOT; }; - 67B83BF114F57EAB00AAAE4E /* lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua.h; path = ../../blua/lua.h; sourceTree = SOURCE_ROOT; }; - 67B83BF214F57EAB00AAAE4E /* luaconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = luaconf.h; path = ../../blua/luaconf.h; sourceTree = SOURCE_ROOT; }; - 67B83BF314F57EAB00AAAE4E /* lualib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lualib.h; path = ../../blua/lualib.h; sourceTree = SOURCE_ROOT; }; - 67B83BF414F57EAB00AAAE4E /* lundump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lundump.c; path = ../../blua/lundump.c; sourceTree = SOURCE_ROOT; }; - 67B83BF514F57EAB00AAAE4E /* lundump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lundump.h; path = ../../blua/lundump.h; sourceTree = SOURCE_ROOT; }; - 67B83BF614F57EAB00AAAE4E /* lvm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lvm.c; path = ../../blua/lvm.c; sourceTree = SOURCE_ROOT; }; - 67B83BF714F57EAB00AAAE4E /* lvm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lvm.h; path = ../../blua/lvm.h; sourceTree = SOURCE_ROOT; }; - 67B83BF814F57EAB00AAAE4E /* lzio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lzio.c; path = ../../blua/lzio.c; sourceTree = SOURCE_ROOT; }; - 67B83BF914F57EAB00AAAE4E /* lzio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lzio.h; path = ../../blua/lzio.h; sourceTree = SOURCE_ROOT; }; - 67B83C1214F57ECA00AAAE4E /* b_bot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = b_bot.c; path = ../../b_bot.c; sourceTree = SOURCE_ROOT; }; - 67B83C1314F57ECA00AAAE4E /* b_bot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = b_bot.h; path = ../../b_bot.h; sourceTree = SOURCE_ROOT; }; - 67B83C1514F57EE600AAAE4E /* lua_baselib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_baselib.c; path = ../../lua_baselib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1614F57EE600AAAE4E /* lua_consolelib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_consolelib.c; path = ../../lua_consolelib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1714F57EE600AAAE4E /* lua_hook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua_hook.h; path = ../../lua_hook.h; sourceTree = SOURCE_ROOT; }; - 67B83C1814F57EE600AAAE4E /* lua_hooklib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_hooklib.c; path = ../../lua_hooklib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1914F57EE600AAAE4E /* lua_infolib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_infolib.c; path = ../../lua_infolib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1A14F57EE600AAAE4E /* lua_libs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua_libs.h; path = ../../lua_libs.h; sourceTree = SOURCE_ROOT; }; - 67B83C1B14F57EE600AAAE4E /* lua_maplib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_maplib.c; path = ../../lua_maplib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1C14F57EE600AAAE4E /* lua_mathlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_mathlib.c; path = ../../lua_mathlib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1D14F57EE600AAAE4E /* lua_mobjlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_mobjlib.c; path = ../../lua_mobjlib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1E14F57EE600AAAE4E /* lua_playerlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_playerlib.c; path = ../../lua_playerlib.c; sourceTree = SOURCE_ROOT; }; - 67B83C1F14F57EE600AAAE4E /* lua_script.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_script.c; path = ../../lua_script.c; sourceTree = SOURCE_ROOT; }; - 67B83C2014F57EE600AAAE4E /* lua_script.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = lua_script.h; path = ../../lua_script.h; sourceTree = SOURCE_ROOT; }; - 67B83C2114F57EE600AAAE4E /* lua_thinkerlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lua_thinkerlib.c; path = ../../lua_thinkerlib.c; sourceTree = SOURCE_ROOT; }; - 67B83C2C14F57F1500AAAE4E /* fastcmp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fastcmp.h; path = ../../fastcmp.h; sourceTree = SOURCE_ROOT; }; - 67B83C2D14F57F1500AAAE4E /* i_addrinfo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = i_addrinfo.c; path = ../../i_addrinfo.c; sourceTree = SOURCE_ROOT; }; - 67B83C2E14F57F1500AAAE4E /* i_addrinfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = i_addrinfo.h; path = ../../i_addrinfo.h; sourceTree = SOURCE_ROOT; }; - 67B83C2F14F57F1500AAAE4E /* m_cond.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = m_cond.c; path = ../../m_cond.c; sourceTree = SOURCE_ROOT; }; - 67B83C3014F57F1500AAAE4E /* m_cond.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = m_cond.h; path = ../../m_cond.h; sourceTree = SOURCE_ROOT; }; - 67B83C3114F57F1500AAAE4E /* m_dllist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = m_dllist.h; path = ../../m_dllist.h; sourceTree = SOURCE_ROOT; }; - 8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; - 8D1107320486CEB800E47090 /* Srb2mac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Srb2mac.app; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8D11072E0486CEB800E47090 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */, - 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, - 1E66921C0B690C5B00B7313A /* SDL_mixer.framework in Frameworks */, - 1E32C4290B6E6D5D0029E058 /* libpng.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 080E96DDFE201D6D7F000001 /* Classes */ = { - isa = PBXGroup; - children = ( - 1E44AE890B67CC4E00BAD059 /* A_Asm */, - 67B83BCA14F57DD400AAAE4E /* B_Bot */, - 67B83BC914F57D7F00AAAE4E /* BLUA */, - 1E44AE8C0B67CC6500BAD059 /* D_Doom */, - 1E44AEBB0B67CC9800BAD059 /* F_Frame */, - 1E44AEC20B67CCB500BAD059 /* G_Game */, - 1E44AECD0B67CCD200BAD059 /* H_Hud */, - 1E44AE5C0B67CC0F00BAD059 /* Hw_Hardware */, - 1E44AED20B67CCF600BAD059 /* I_Interface */, - 67B83BC814F57D6E00AAAE4E /* LUA */, - 1E44AEF70B67CDA900BAD059 /* M_Misc */, - 1E44AF160B67CDFB00BAD059 /* P_Play */, - 1E44AF540B67CE8C00BAD059 /* R_Render */, - 1E44AF830B67CEC900BAD059 /* S_Sound */, - 1E44AF170B67CE1000BAD059 /* W_Wad */, - ); - name = Classes; - sourceTree = ""; - }; - 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { - isa = PBXGroup; - children = ( - 1E32C4140B6E6D5D0029E058 /* libpng.framework */, - 1E66921B0B690C5B00B7313A /* SDL_mixer.framework */, - 002F39F909D0881F00EBEB88 /* SDL.framework */, - 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, - ); - name = "Linked Frameworks"; - sourceTree = ""; - }; - 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = { - isa = PBXGroup; - children = ( - 29B97324FDCFA39411CA2CEA /* AppKit.framework */, - 29B97325FDCFA39411CA2CEA /* Foundation.framework */, - ); - name = "Other Frameworks"; - sourceTree = ""; - }; - 19C28FACFE9D520D11CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - 8D1107320486CEB800E47090 /* Srb2mac.app */, - ); - name = Products; - sourceTree = ""; - }; - 1E44AE5C0B67CC0F00BAD059 /* Hw_Hardware */ = { - isa = PBXGroup; - children = ( - 1E44AE600B67CC2B00BAD059 /* hw3dsdrv.h */, - 1E44AE610B67CC2B00BAD059 /* hw_bsp.c */, - 1E44AE620B67CC2B00BAD059 /* hw_defs.h */, - 1E44AE630B67CC2B00BAD059 /* hw3sound.c */, - 1E44AE640B67CC2B00BAD059 /* hw_cache.c */, - 1E44AE650B67CC2B00BAD059 /* hw_dll.h */, - 1E44AE660B67CC2B00BAD059 /* hw_drv.h */, - 1E44AE670B67CC2B00BAD059 /* hw_glide.h */, - 1E44AE680B67CC2B00BAD059 /* hw_light.c */, - 1E44AE690B67CC2B00BAD059 /* hw_light.h */, - 1E44AE6A0B67CC2B00BAD059 /* hw3sound.h */, - 1E44AE6B0B67CC2B00BAD059 /* hw_data.h */, - 1E44AE6C0B67CC2B00BAD059 /* hw_draw.c */, - 1E44AE6D0B67CC2B00BAD059 /* hw_glob.h */, - 1E44AE6E0B67CC2B00BAD059 /* hw_main.c */, - 1E44AE6F0B67CC2B00BAD059 /* hw_main.h */, - 1E44AE700B67CC2B00BAD059 /* hw_md2.c */, - 1E44AE710B67CC2B00BAD059 /* hw_md2.h */, - 1E44AE720B67CC2B00BAD059 /* hw_trick.c */, - 1E44AE730B67CC2B00BAD059 /* hws_data.h */, - ); - name = Hw_Hardware; - sourceTree = ""; - }; - 1E44AE890B67CC4E00BAD059 /* A_Asm */ = { - isa = PBXGroup; - children = ( - 67B2071C1180FA8200E93654 /* vid_copy.s */, - 1E44AE8A0B67CC6000BAD059 /* asm_defs.inc */, - 1E44AF9D0B67CF3D00BAD059 /* tmap.nas */, - 1E44AF9F0B67CF4900BAD059 /* tmap_mmx.nas */, - 1E44AFA00B67CF4900BAD059 /* tmap_vc.nas */, - ); - name = A_Asm; - sourceTree = ""; - }; - 1E44AE8C0B67CC6500BAD059 /* D_Doom */ = { - isa = PBXGroup; - children = ( - 1E44AEEB0B67CD4400BAD059 /* comptime.c */, - 1E44AE8D0B67CC8400BAD059 /* d_clisrv.c */, - 1E44AE8E0B67CC8400BAD059 /* d_clisrv.h */, - 1E44AE8F0B67CC8400BAD059 /* d_event.h */, - 1E44AE900B67CC8400BAD059 /* d_main.c */, - 1E44AE910B67CC8500BAD059 /* d_net.c */, - 1E44AE920B67CC8500BAD059 /* d_net.h */, - 1E44AE930B67CC8500BAD059 /* d_netcmd.h */, - 1E44AE940B67CC8500BAD059 /* d_netfil.c */, - 1E44AE950B67CC8500BAD059 /* d_player.h */, - 1E44AE960B67CC8500BAD059 /* d_think.h */, - 1E44AE980B67CC8500BAD059 /* d_netcmd.c */, - 1E44AE990B67CC8500BAD059 /* d_ticcmd.h */, - 1E44AE9A0B67CC8500BAD059 /* d_main.h */, - 1E44AE9B0B67CC8500BAD059 /* d_netfil.h */, - 1E44AE9C0B67CC8500BAD059 /* dehacked.c */, - 1E44AE9D0B67CC8500BAD059 /* dehacked.h */, - 1E44AE9E0B67CC8500BAD059 /* doomdata.h */, - 1E44AE9F0B67CC8500BAD059 /* doomdef.h */, - 1E44AEA00B67CC8500BAD059 /* doomstat.h */, - 1E44AEA10B67CC8500BAD059 /* doomtype.h */, - 1E44AFAF0B67CF7A00BAD059 /* z_zone.c */, - 1E44AFB00B67CF7A00BAD059 /* z_zone.h */, - ); - name = D_Doom; - sourceTree = ""; - }; - 1E44AEBB0B67CC9800BAD059 /* F_Frame */ = { - isa = PBXGroup; - children = ( - 1E44AEBC0B67CCA900BAD059 /* f_wipe.c */, - 1E44AEBD0B67CCA900BAD059 /* f_finale.c */, - 1E44AEBE0B67CCA900BAD059 /* f_finale.h */, - 1E44AFAB0B67CF6F00BAD059 /* y_inter.c */, - 1E44AFAC0B67CF6F00BAD059 /* y_inter.h */, - ); - name = F_Frame; - sourceTree = ""; - }; - 1E44AEC20B67CCB500BAD059 /* G_Game */ = { - isa = PBXGroup; - children = ( - 1E44AEC30B67CCC600BAD059 /* g_game.c */, - 1E44AEC40B67CCC600BAD059 /* g_game.h */, - 1E44AEC50B67CCC600BAD059 /* g_input.h */, - 1E44AEC60B67CCC600BAD059 /* g_state.h */, - 1E44AEC70B67CCC600BAD059 /* g_input.c */, - ); - name = G_Game; - sourceTree = ""; - }; - 1E44AECD0B67CCD200BAD059 /* H_Hud */ = { - isa = PBXGroup; - children = ( - 1E44AEE10B67CD2B00BAD059 /* am_map.c */, - 1E44AEE20B67CD2B00BAD059 /* am_map.h */, - 1E44AEE70B67CD3F00BAD059 /* command.c */, - 1E44AEE80B67CD3F00BAD059 /* command.h */, - 1E44AEED0B67CD5400BAD059 /* console.c */, - 1E44AEEE0B67CD5400BAD059 /* console.h */, - 1E44AECE0B67CCEE00BAD059 /* hu_stuff.c */, - 1E44AECF0B67CCEE00BAD059 /* hu_stuff.h */, - 1E44AF000B67CDE900BAD059 /* m_menu.c */, - 1E44AF010B67CDE900BAD059 /* m_menu.h */, - 1E44AF910B67CEFF00BAD059 /* st_stuff.c */, - 1E44AF920B67CEFF00BAD059 /* st_stuff.h */, - ); - name = H_Hud; - sourceTree = ""; - }; - 1E44AED20B67CCF600BAD059 /* I_Interface */ = { - isa = PBXGroup; - children = ( - 67259E0218D268F600F02971 /* i_ttf.c */, - 67259E0318D268F600F02971 /* i_ttf.h */, - 67259E0418D268F600F02971 /* mixer_sound.c */, - 67259E0518D268F600F02971 /* sdl_sound.c */, - 1E44AFB30B67CF8500BAD059 /* SDL */, - 67B83C2D14F57F1500AAAE4E /* i_addrinfo.c */, - 67B83C2E14F57F1500AAAE4E /* i_addrinfo.h */, - 1E44AEE50B67CD3200BAD059 /* byteptr.h */, - 1E44AEF10B67CD7F00BAD059 /* filesrch.c */, - 1E44AEF20B67CD7F00BAD059 /* filesrch.h */, - 1E44AED30B67CD1200BAD059 /* i_net.h */, - 1E44AED40B67CD1200BAD059 /* i_sound.h */, - 1E44AED50B67CD1200BAD059 /* i_tcp.c */, - 1E44AED60B67CD1200BAD059 /* i_tcp.h */, - 1E44AED70B67CD1200BAD059 /* i_system.h */, - 1E44AED80B67CD1200BAD059 /* i_video.h */, - 1E44AED90B67CD1300BAD059 /* i_joy.h */, - 1E44AEF50B67CD9F00BAD059 /* keys.h */, - 1E44AF200B67CE4100BAD059 /* mserv.c */, - 1E44AF210B67CE4100BAD059 /* mserv.h */, - ); - name = I_Interface; - sourceTree = ""; - }; - 1E44AEF70B67CDA900BAD059 /* M_Misc */ = { - isa = PBXGroup; - children = ( - 67259DFF18D268AE00F02971 /* m_anigif.c */, - 67259E0018D268AE00F02971 /* m_anigif.h */, - 1E44AEF80B67CDE900BAD059 /* m_argv.c */, - 1E44AEFA0B67CDE900BAD059 /* m_argv.h */, - 1E44AEFC0B67CDE900BAD059 /* m_bbox.c */, - 1E44AEF90B67CDE900BAD059 /* m_bbox.h */, - 1E44AEFB0B67CDE900BAD059 /* m_cheat.c */, - 1E44AEFD0B67CDE900BAD059 /* m_cheat.h */, - 67B83C2F14F57F1500AAAE4E /* m_cond.c */, - 67B83C3014F57F1500AAAE4E /* m_cond.h */, - 67B83C3114F57F1500AAAE4E /* m_dllist.h */, - 1E44AEFE0B67CDE900BAD059 /* m_fixed.c */, - 1E44AEFF0B67CDE900BAD059 /* m_fixed.h */, - 1E44AF020B67CDE900BAD059 /* m_misc.c */, - 1E44AF030B67CDE900BAD059 /* m_misc.h */, - 1E44AF020B67CDE900BAD059 /* apng.c */, - 1E44AF030B67CDE900BAD059 /* apng.h */, - 676BB51C0E0DE06100C95963 /* m_queue.c */, - 676BB51D0E0DE06100C95963 /* m_queue.h */, - 1E44AF040B67CDE900BAD059 /* m_random.c */, - 1E44AF050B67CDE900BAD059 /* m_random.h */, - 1E44AF060B67CDE900BAD059 /* m_swap.h */, - 1E44AF950B67CF1300BAD059 /* string.c */, - ); - name = M_Misc; - sourceTree = ""; - }; - 1E44AF160B67CDFB00BAD059 /* P_Play */ = { - isa = PBXGroup; - children = ( - 1E44AF180B67CE2A00BAD059 /* info.c */, - 1E44AF190B67CE2A00BAD059 /* info.h */, - 1E44AF3B0B67CE5F00BAD059 /* p_ceilng.c */, - 1E44AF240B67CE5F00BAD059 /* p_enemy.c */, - 1E44AF250B67CE5F00BAD059 /* p_inter.c */, - 1E44AF260B67CE5F00BAD059 /* p_fab.c */, - 1E44AF270B67CE5F00BAD059 /* p_lights.c */, - 1E44AF280B67CE5F00BAD059 /* p_map.c */, - 1E44AF290B67CE5F00BAD059 /* p_maputl.c */, - 1E44AF2A0B67CE5F00BAD059 /* p_maputl.h */, - 1E44AF2B0B67CE5F00BAD059 /* p_mobj.c */, - 1E44AF2C0B67CE5F00BAD059 /* p_mobj.h */, - 1E44AF2D0B67CE5F00BAD059 /* p_floor.c */, - 1E44AF2E0B67CE5F00BAD059 /* p_local.h */, - 676BB51E0E0DE06100C95963 /* p_polyobj.c */, - 676BB51F0E0DE06100C95963 /* p_polyobj.h */, - 1E44AF2F0B67CE5F00BAD059 /* p_pspr.h */, - 1E44AF300B67CE5F00BAD059 /* p_saveg.c */, - 1E44AF310B67CE5F00BAD059 /* p_saveg.h */, - 1E44AF320B67CE5F00BAD059 /* p_setup.c */, - 1E44AF330B67CE5F00BAD059 /* p_setup.h */, - 1E44AF340B67CE5F00BAD059 /* p_sight.c */, - 1E44AF350B67CE5F00BAD059 /* p_spec.c */, - 1E44AF360B67CE5F00BAD059 /* p_spec.h */, - 1E44AF370B67CE5F00BAD059 /* p_telept.c */, - 1E44AF380B67CE5F00BAD059 /* p_tick.c */, - 1E44AF390B67CE5F00BAD059 /* p_tick.h */, - 1E44AF3A0B67CE5F00BAD059 /* p_user.c */, - 1E44AF990B67CF2E00BAD059 /* tables.c */, - 1E44AF9A0B67CF2E00BAD059 /* tables.h */, - ); - name = P_Play; - sourceTree = ""; - }; - 1E44AF170B67CE1000BAD059 /* W_Wad */ = { - isa = PBXGroup; - children = ( - 1E44B2240B67EADE00BAD059 /* lzf.c */, - 1E44B2250B67EADE00BAD059 /* lzf.h */, - 1E44AF1C0B67CE3600BAD059 /* md5.c */, - 1E44AF1D0B67CE3600BAD059 /* md5.h */, - 1E44AFA70B67CF6400BAD059 /* w_wad.c */, - 1E44AFA80B67CF6400BAD059 /* w_wad.h */, - ); - name = W_Wad; - sourceTree = ""; - }; - 1E44AF540B67CE8C00BAD059 /* R_Render */ = { - isa = PBXGroup; - children = ( - 1E44AF550B67CEC100BAD059 /* r_bsp.c */, - 1E44AF560B67CEC100BAD059 /* r_bsp.h */, - 1E44AF570B67CEC100BAD059 /* r_defs.h */, - 1E44AF580B67CEC100BAD059 /* r_data.c */, - 1E44AF590B67CEC100BAD059 /* r_draw.c */, - 1E44AF5A0B67CEC100BAD059 /* r_draw16.c */, - 1E44AF5B0B67CEC100BAD059 /* r_draw8.c */, - 1E44AF5C0B67CEC100BAD059 /* r_main.c */, - 1E44AF5D0B67CEC100BAD059 /* r_main.h */, - 1E44AF5E0B67CEC100BAD059 /* r_data.h */, - 1E44AF5F0B67CEC100BAD059 /* r_draw.h */, - 1E44AF600B67CEC100BAD059 /* r_local.h */, - 1E44AF610B67CEC100BAD059 /* r_plane.c */, - 1E44AF620B67CEC100BAD059 /* r_plane.h */, - 1E44AF630B67CEC100BAD059 /* r_segs.c */, - 1E44AF640B67CEC100BAD059 /* r_segs.h */, - 1E44AF650B67CEC200BAD059 /* r_sky.c */, - 1E44AF660B67CEC200BAD059 /* r_sky.h */, - 1E44AF670B67CEC200BAD059 /* r_splats.c */, - 1E44AF680B67CEC200BAD059 /* r_splats.h */, - 1E44AF690B67CEC200BAD059 /* r_state.h */, - 1E44AF6A0B67CEC200BAD059 /* r_things.c */, - 1E44AF6B0B67CEC200BAD059 /* r_things.h */, - 1E44AF890B67CEE900BAD059 /* screen.c */, - 1E44AF8A0B67CEE900BAD059 /* screen.h */, - 1E44AFA30B67CF5D00BAD059 /* v_video.c */, - 1E44AFA40B67CF5D00BAD059 /* v_video.h */, - ); - name = R_Render; - sourceTree = ""; - }; - 1E44AF830B67CEC900BAD059 /* S_Sound */ = { - isa = PBXGroup; - children = ( - 1E44AF850B67CEE000BAD059 /* s_sound.c */, - 1E44AF860B67CEE000BAD059 /* s_sound.h */, - 1E44AF8D0B67CEF000BAD059 /* sounds.c */, - 1E44AF8E0B67CEF000BAD059 /* sounds.h */, - ); - name = S_Sound; - sourceTree = ""; - }; - 1E44AFB30B67CF8500BAD059 /* SDL */ = { - isa = PBXGroup; - children = ( - 1E44AFE50B67D04900BAD059 /* macosx */, - 1E44AFD40B67D03100BAD059 /* filter */, - 1E44AFB40B67CFDC00BAD059 /* dosstr.c */, - 1E44AFB50B67CFDC00BAD059 /* endtxt.c */, - 1E44AFB60B67CFDC00BAD059 /* endtxt.h */, - 1E44AFB70B67CFDC00BAD059 /* hwsym_sdl.c */, - 1E44AFB80B67CFDC00BAD059 /* hwsym_sdl.h */, - 1E44AFB90B67CFDC00BAD059 /* i_cdmus.c */, - 1E44AFBA0B67CFDC00BAD059 /* i_main.c */, - 1E44AFBB0B67CFDC00BAD059 /* i_net.c */, - 1E44AFBD0B67CFDC00BAD059 /* i_system.c */, - 1E44AFBE0B67CFDC00BAD059 /* i_video.c */, - 1E44AFBF0B67CFDC00BAD059 /* IMG_xpm.c */, - 1E44AFEC0B67D0AB00BAD059 /* r_opengl.c */, - 1E44AFC00B67CFDC00BAD059 /* ogl_sdl.c */, - 1E44AFC10B67CFDC00BAD059 /* ogl_sdl.h */, - 1E44AFC20B67CFDC00BAD059 /* SDL_icon.xpm */, - 1E44AFC30B67CFDC00BAD059 /* sdlmain.h */, - ); - name = SDL; - sourceTree = ""; - }; - 1E44AFD40B67D03100BAD059 /* filter */ = { - isa = PBXGroup; - children = ( - 1E44AFD50B67D03100BAD059 /* filters.c */, - 1E44AFD60B67D03100BAD059 /* filters.h */, - 1E44AFD70B67D03100BAD059 /* hq2x.c */, - 1E44AFD80B67D03100BAD059 /* hq2x.h */, - 1E44AFD90B67D03100BAD059 /* interp.h */, - 1E44AFDA0B67D03100BAD059 /* lq2x.c */, - 1E44AFDB0B67D03100BAD059 /* lq2x.h */, - 1E44AFDC0B67D03100BAD059 /* main.c */, - ); - name = filter; - path = ../filter; - sourceTree = SOURCE_ROOT; - }; - 1E44AFE50B67D04900BAD059 /* macosx */ = { - isa = PBXGroup; - children = ( - 1E44AFE60B67D06200BAD059 /* mac_alert.h */, - 1E44AFE70B67D06200BAD059 /* Srb2mac.icns */, - 1E44AFE80B67D06200BAD059 /* mac_alert.c */, - 1E44B0560B67D81E00BAD059 /* SDL_macosx_main.h */, - 1E44B0570B67D81E00BAD059 /* SDL_macosx_main.m */, - ); - name = macosx; - sourceTree = ""; - }; - 29B97314FDCFA39411CA2CEA /* Srb2mac */ = { - isa = PBXGroup; - children = ( - 080E96DDFE201D6D7F000001 /* Classes */, - 29B97315FDCFA39411CA2CEA /* Other Sources */, - 29B97317FDCFA39411CA2CEA /* Resources */, - 29B97323FDCFA39411CA2CEA /* Frameworks */, - 19C28FACFE9D520D11CA2CBB /* Products */, - ); - name = Srb2mac; - sourceTree = ""; - }; - 29B97315FDCFA39411CA2CEA /* Other Sources */ = { - isa = PBXGroup; - children = ( - ); - name = "Other Sources"; - sourceTree = ""; - }; - 29B97317FDCFA39411CA2CEA /* Resources */ = { - isa = PBXGroup; - children = ( - 67259E2B18D26D5700F02971 /* patch.dta */, - 67259E2C18D26D5700F02971 /* rings.dta */, - 67259E2D18D26D5700F02971 /* srb2.srb */, - 67A1F91813FAD026009FA3E5 /* player.dta */, - 6766C0AE11B057E50065F389 /* zones.dta */, - 1E44AE440B67CBE800BAD059 /* music.dta */, - 1E44AE4B0B67CBE800BAD059 /* srb2.wad */, - 8D1107310486CEB800E47090 /* Info.plist */, - 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, - ); - name = Resources; - sourceTree = ""; - }; - 29B97323FDCFA39411CA2CEA /* Frameworks */ = { - isa = PBXGroup; - children = ( - 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */, - 1058C7A2FEA54F0111CA2CBB /* Other Frameworks */, - ); - name = Frameworks; - sourceTree = ""; - }; - 67B83BC814F57D6E00AAAE4E /* LUA */ = { - isa = PBXGroup; - children = ( - 67259DFA18D2687D00F02971 /* lua_hud.h */, - 67259DFB18D2687D00F02971 /* lua_hudlib.c */, - 67259DFC18D2687D00F02971 /* lua_skinlib.c */, - 67B83C2C14F57F1500AAAE4E /* fastcmp.h */, - 67B83C1514F57EE600AAAE4E /* lua_baselib.c */, - 67B83C1614F57EE600AAAE4E /* lua_consolelib.c */, - 67B83C1714F57EE600AAAE4E /* lua_hook.h */, - 67B83C1814F57EE600AAAE4E /* lua_hooklib.c */, - 67B83C1914F57EE600AAAE4E /* lua_infolib.c */, - 67B83C1A14F57EE600AAAE4E /* lua_libs.h */, - 67B83C1B14F57EE600AAAE4E /* lua_maplib.c */, - 67B83C1C14F57EE600AAAE4E /* lua_mathlib.c */, - 67B83C1D14F57EE600AAAE4E /* lua_mobjlib.c */, - 67B83C1E14F57EE600AAAE4E /* lua_playerlib.c */, - 67B83C1F14F57EE600AAAE4E /* lua_script.c */, - 67B83C2014F57EE600AAAE4E /* lua_script.h */, - 67B83C2114F57EE600AAAE4E /* lua_thinkerlib.c */, - ); - name = LUA; - sourceTree = ""; - }; - 67B83BC914F57D7F00AAAE4E /* BLUA */ = { - isa = PBXGroup; - children = ( - 67B83BCB14F57EAB00AAAE4E /* lapi.c */, - 67B83BCC14F57EAB00AAAE4E /* lapi.h */, - 67B83BCD14F57EAB00AAAE4E /* lauxlib.c */, - 67B83BCE14F57EAB00AAAE4E /* lauxlib.h */, - 67B83BCF14F57EAB00AAAE4E /* lbaselib.c */, - 67B83BD014F57EAB00AAAE4E /* lcode.c */, - 67B83BD114F57EAB00AAAE4E /* lcode.h */, - 67B83BD214F57EAB00AAAE4E /* ldebug.c */, - 67B83BD314F57EAB00AAAE4E /* ldebug.h */, - 67B83BD414F57EAB00AAAE4E /* ldo.c */, - 67B83BD514F57EAB00AAAE4E /* ldo.h */, - 67B83BD614F57EAB00AAAE4E /* ldump.c */, - 67B83BD714F57EAB00AAAE4E /* lfunc.c */, - 67B83BD814F57EAB00AAAE4E /* lfunc.h */, - 67B83BD914F57EAB00AAAE4E /* lgc.c */, - 67B83BDA14F57EAB00AAAE4E /* lgc.h */, - 67B83BDB14F57EAB00AAAE4E /* linit.c */, - 67B83BDC14F57EAB00AAAE4E /* llex.c */, - 67B83BDD14F57EAB00AAAE4E /* llex.h */, - 67B83BDE14F57EAB00AAAE4E /* llimits.h */, - 67B83BDF14F57EAB00AAAE4E /* lmem.c */, - 67B83BE014F57EAB00AAAE4E /* lmem.h */, - 67B83BE114F57EAB00AAAE4E /* lobject.c */, - 67B83BE214F57EAB00AAAE4E /* lobject.h */, - 67B83BE314F57EAB00AAAE4E /* lopcodes.c */, - 67B83BE414F57EAB00AAAE4E /* lopcodes.h */, - 67B83BE514F57EAB00AAAE4E /* lparser.c */, - 67B83BE614F57EAB00AAAE4E /* lparser.h */, - 67B83BE714F57EAB00AAAE4E /* lstate.c */, - 67B83BE814F57EAB00AAAE4E /* lstate.h */, - 67B83BE914F57EAB00AAAE4E /* lstring.c */, - 67B83BEA14F57EAB00AAAE4E /* lstring.h */, - 67B83BEB14F57EAB00AAAE4E /* lstrlib.c */, - 67B83BEC14F57EAB00AAAE4E /* ltable.c */, - 67B83BED14F57EAB00AAAE4E /* ltable.h */, - 67B83BEE14F57EAB00AAAE4E /* ltablib.c */, - 67B83BEF14F57EAB00AAAE4E /* ltm.c */, - 67B83BF014F57EAB00AAAE4E /* ltm.h */, - 67B83BF114F57EAB00AAAE4E /* lua.h */, - 67B83BF214F57EAB00AAAE4E /* luaconf.h */, - 67B83BF314F57EAB00AAAE4E /* lualib.h */, - 67B83BF414F57EAB00AAAE4E /* lundump.c */, - 67B83BF514F57EAB00AAAE4E /* lundump.h */, - 67B83BF614F57EAB00AAAE4E /* lvm.c */, - 67B83BF714F57EAB00AAAE4E /* lvm.h */, - 67B83BF814F57EAB00AAAE4E /* lzio.c */, - 67B83BF914F57EAB00AAAE4E /* lzio.h */, - ); - name = BLUA; - sourceTree = ""; - }; - 67B83BCA14F57DD400AAAE4E /* B_Bot */ = { - isa = PBXGroup; - children = ( - 67B83C1214F57ECA00AAAE4E /* b_bot.c */, - 67B83C1314F57ECA00AAAE4E /* b_bot.h */, - ); - name = B_Bot; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8D1107260486CEB800E47090 /* Srb2mac */ = { - isa = PBXNativeTarget; - buildConfigurationList = C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Srb2mac" */; - buildPhases = ( - 8D1107290486CEB800E47090 /* Resources */, - 677E4CB30E1765500034519D /* Get SCM Info */, - 8D11072C0486CEB800E47090 /* Sources */, - 8D11072E0486CEB800E47090 /* Frameworks */, - 002F39FD09D0883400EBEB88 /* Copy Frameworks into .app bundle */, - 679B708A102B872300AA9E4C /* Make DMG */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Srb2mac; - productInstallPath = "$(HOME)/Applications"; - productName = Srb2mac; - productReference = 8D1107320486CEB800E47090 /* Srb2mac.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 29B97313FDCFA39411CA2CEA /* Project object */ = { - isa = PBXProject; - buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Srb2mac" */; - compatibilityVersion = "Xcode 2.4"; - hasScannedForEncodings = 1; - mainGroup = 29B97314FDCFA39411CA2CEA /* Srb2mac */; - projectDirPath = ""; - projectRoot = ../../..; - targets = ( - 8D1107260486CEB800E47090 /* Srb2mac */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 8D1107290486CEB800E47090 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, - 1E44AFEA0B67D06200BAD059 /* Srb2mac.icns in Resources */, - 67259E2E18D26D5700F02971 /* patch.dta in Resources */, - 67259E2F18D26D5700F02971 /* rings.dta in Resources */, - 67259E3018D26D5700F02971 /* srb2.srb in Resources */, - 67259E3218D26DD200F02971 /* music.dta in Resources */, - 67259E3318D26DD300F02971 /* player.dta in Resources */, - 67259E3518D26DD500F02971 /* zones.dta in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 677E4CB30E1765500034519D /* Get SCM Info */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - comments = "update the time and date stamps in src/comptime.c"; - files = ( - ); - inputPaths = ( - ); - name = "Get SCM Info"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "PATH=\"/usr/local/bin:$PATH\" $SRCROOT/../../../comptime.sh $SRCROOT/../../"; - }; - 679B708A102B872300AA9E4C /* Make DMG */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - comments = "make DMG file for Release builds"; - files = ( - ); - inputPaths = ( - $BUILT_PRODUCTS_DIR/$WRAPPER_NAME, - ); - name = "Make DMG"; - outputPaths = ( - $BUILT_PRODUCTS_DIR/$TARGET_NAME.nodata.dmg, - $BUILT_PRODUCTS_DIR/$TARGET_NAME.dmg, - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "set -ex\n\n[ \"$ACTION\" = build ] || exit 0\n[ \"$CURRENT_VARIANT\" = \"normal\" ] || exit 0\n[ \"$BUILD_STYLE\" = \"Release\" ] || exit 0\n\ndir=\"$TEMP_FILES_DIR/$TARGET_NAME.disk\"\ndmg=\"$BUILT_PRODUCTS_DIR/$TARGET_NAME.dmg\"\ndmg_nodata=\"$BUILT_PRODUCTS_DIR/$TARGET_NAME.nodata.dmg\"\n\nrm -rf -- \"$dir\"\nmkdir \"$dir\"\ncp -R \"$BUILT_PRODUCTS_DIR/$WRAPPER_NAME\" \"$dir\"\nrm -f -- \"$dmg\"\nhdiutil create -ov -fs HFS+ -srcfolder \"$dir\" -volname \"$TARGET_NAME\" \"$dmg\"\nhdiutil internet-enable -yes \"$dmg\"\ncd \"$dir/$WRAPPER_NAME/Contents/Resources\"\nrm -f -- *.wad\nrm -f -- *.dta\nrm -f -- *.plr\nrm -f -- *.wpn\nrm -f -- *.srb2\ncd \"$OLDPWD\"\nrm -f -- \"$dmg_nodata\"\nhdiutil create -ov -fs HFS+ -srcfolder \"$dir\" -volname \"$TARGET_NAME Lite\" \"$dmg_nodata\"\nhdiutil internet-enable -yes \"$dmg_nodata\"\nrm -rf -- \"$dir\""; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 8D11072C0486CEB800E47090 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 1E44AE750B67CC2B00BAD059 /* hw_bsp.c in Sources */, - 1E44AE770B67CC2B00BAD059 /* hw3sound.c in Sources */, - 1E44AE780B67CC2B00BAD059 /* hw_cache.c in Sources */, - 1E44AE7C0B67CC2B00BAD059 /* hw_light.c in Sources */, - 1E44AE800B67CC2B00BAD059 /* hw_draw.c in Sources */, - 1E44AE820B67CC2B00BAD059 /* hw_main.c in Sources */, - 1E44AE840B67CC2B00BAD059 /* hw_md2.c in Sources */, - 1E44AE860B67CC2B00BAD059 /* hw_trick.c in Sources */, - 1E44AEA40B67CC8500BAD059 /* d_clisrv.c in Sources */, - 1E44AEA70B67CC8500BAD059 /* d_main.c in Sources */, - 1E44AEA80B67CC8500BAD059 /* d_net.c in Sources */, - 1E44AEAB0B67CC8500BAD059 /* d_netfil.c in Sources */, - 1E44AEAF0B67CC8500BAD059 /* d_netcmd.c in Sources */, - 1E44AEB30B67CC8500BAD059 /* dehacked.c in Sources */, - 1E44AEBF0B67CCA900BAD059 /* f_wipe.c in Sources */, - 1E44AEC00B67CCA900BAD059 /* f_finale.c in Sources */, - 1E44AEC80B67CCC600BAD059 /* g_game.c in Sources */, - 1E44AECC0B67CCC600BAD059 /* g_input.c in Sources */, - 1E44AED00B67CCEE00BAD059 /* hu_stuff.c in Sources */, - 1E44AEDC0B67CD1300BAD059 /* i_tcp.c in Sources */, - 1E44AEE30B67CD2B00BAD059 /* am_map.c in Sources */, - 1E44AEE90B67CD3F00BAD059 /* command.c in Sources */, - 1E44AEEC0B67CD4400BAD059 /* comptime.c in Sources */, - 1E44AEEF0B67CD5400BAD059 /* console.c in Sources */, - 1E44AEF30B67CD7F00BAD059 /* filesrch.c in Sources */, - 1E44AF070B67CDE900BAD059 /* m_argv.c in Sources */, - 1E44AF0A0B67CDE900BAD059 /* m_cheat.c in Sources */, - 1E44AF0B0B67CDE900BAD059 /* m_bbox.c in Sources */, - 1E44AF0D0B67CDE900BAD059 /* m_fixed.c in Sources */, - 1E44AF0F0B67CDE900BAD059 /* m_menu.c in Sources */, - 1E44AF110B67CDE900BAD059 /* m_misc.c in Sources */, - 1E44AF130B67CDE900BAD059 /* m_random.c in Sources */, - 1E44AF1A0B67CE2A00BAD059 /* info.c in Sources */, - 1E44AF1E0B67CE3600BAD059 /* md5.c in Sources */, - 1E44AF220B67CE4100BAD059 /* mserv.c in Sources */, - 1E44AF3C0B67CE5F00BAD059 /* p_enemy.c in Sources */, - 1E44AF3D0B67CE5F00BAD059 /* p_inter.c in Sources */, - 1E44AF3E0B67CE5F00BAD059 /* p_fab.c in Sources */, - 1E44AF3F0B67CE5F00BAD059 /* p_lights.c in Sources */, - 1E44AF400B67CE5F00BAD059 /* p_map.c in Sources */, - 1E44AF410B67CE5F00BAD059 /* p_maputl.c in Sources */, - 1E44AF430B67CE5F00BAD059 /* p_mobj.c in Sources */, - 1E44AF450B67CE5F00BAD059 /* p_floor.c in Sources */, - 1E44AF480B67CE5F00BAD059 /* p_saveg.c in Sources */, - 1E44AF4A0B67CE5F00BAD059 /* p_setup.c in Sources */, - 1E44AF4C0B67CE5F00BAD059 /* p_sight.c in Sources */, - 1E44AF4D0B67CE5F00BAD059 /* p_spec.c in Sources */, - 1E44AF4F0B67CE5F00BAD059 /* p_telept.c in Sources */, - 1E44AF500B67CE5F00BAD059 /* p_tick.c in Sources */, - 1E44AF520B67CE5F00BAD059 /* p_user.c in Sources */, - 1E44AF530B67CE5F00BAD059 /* p_ceilng.c in Sources */, - 1E44AF6C0B67CEC200BAD059 /* r_bsp.c in Sources */, - 1E44AF6F0B67CEC200BAD059 /* r_data.c in Sources */, - 1E44AF700B67CEC200BAD059 /* r_draw.c in Sources */, - 1E44AF730B67CEC200BAD059 /* r_main.c in Sources */, - 1E44AF780B67CEC200BAD059 /* r_plane.c in Sources */, - 1E44AF7A0B67CEC200BAD059 /* r_segs.c in Sources */, - 1E44AF7C0B67CEC200BAD059 /* r_sky.c in Sources */, - 1E44AF7E0B67CEC200BAD059 /* r_splats.c in Sources */, - 1E44AF810B67CEC200BAD059 /* r_things.c in Sources */, - 1E44AF870B67CEE000BAD059 /* s_sound.c in Sources */, - 1E44AF8B0B67CEE900BAD059 /* screen.c in Sources */, - 1E44AF8F0B67CEF000BAD059 /* sounds.c in Sources */, - 1E44AF930B67CEFF00BAD059 /* st_stuff.c in Sources */, - 1E44AF9B0B67CF2E00BAD059 /* tables.c in Sources */, - 1E44AFA50B67CF5D00BAD059 /* v_video.c in Sources */, - 1E44AFA90B67CF6400BAD059 /* w_wad.c in Sources */, - 1E44AFAD0B67CF6F00BAD059 /* y_inter.c in Sources */, - 1E44AFB10B67CF7A00BAD059 /* z_zone.c in Sources */, - 1E44AFC40B67CFDC00BAD059 /* dosstr.c in Sources */, - 1E44AFC50B67CFDC00BAD059 /* endtxt.c in Sources */, - 1E44AFC70B67CFDC00BAD059 /* hwsym_sdl.c in Sources */, - 1E44AFC90B67CFDC00BAD059 /* i_cdmus.c in Sources */, - 1E44AFCA0B67CFDC00BAD059 /* i_main.c in Sources */, - 1E44AFCB0B67CFDC00BAD059 /* i_net.c in Sources */, - 1E44AFCD0B67CFDC00BAD059 /* i_system.c in Sources */, - 1E44AFCE0B67CFDC00BAD059 /* i_video.c in Sources */, - 1E44AFD00B67CFDC00BAD059 /* ogl_sdl.c in Sources */, - 1E44AFEB0B67D06200BAD059 /* mac_alert.c in Sources */, - 1E44AFED0B67D0AB00BAD059 /* r_opengl.c in Sources */, - 1E44B0590B67D81E00BAD059 /* SDL_macosx_main.m in Sources */, - 1E308E720B71172D0015728C /* lzf.c in Sources */, - 676BB5200E0DE06100C95963 /* m_queue.c in Sources */, - 676BB5220E0DE06100C95963 /* p_polyobj.c in Sources */, - 67B83BFA14F57EAB00AAAE4E /* lapi.c in Sources */, - 67B83BFB14F57EAB00AAAE4E /* lauxlib.c in Sources */, - 67B83BFC14F57EAB00AAAE4E /* lbaselib.c in Sources */, - 67B83BFD14F57EAB00AAAE4E /* lcode.c in Sources */, - 67B83BFE14F57EAB00AAAE4E /* ldebug.c in Sources */, - 67B83BFF14F57EAB00AAAE4E /* ldo.c in Sources */, - 67B83C0014F57EAB00AAAE4E /* ldump.c in Sources */, - 67B83C0114F57EAB00AAAE4E /* lfunc.c in Sources */, - 67B83C0214F57EAB00AAAE4E /* lgc.c in Sources */, - 67B83C0314F57EAB00AAAE4E /* linit.c in Sources */, - 67B83C0414F57EAB00AAAE4E /* llex.c in Sources */, - 67B83C0514F57EAB00AAAE4E /* lmem.c in Sources */, - 67B83C0614F57EAB00AAAE4E /* lobject.c in Sources */, - 67B83C0714F57EAB00AAAE4E /* lopcodes.c in Sources */, - 67B83C0814F57EAB00AAAE4E /* lparser.c in Sources */, - 67B83C0914F57EAB00AAAE4E /* lstate.c in Sources */, - 67B83C0A14F57EAB00AAAE4E /* lstring.c in Sources */, - 67B83C0B14F57EAB00AAAE4E /* lstrlib.c in Sources */, - 67B83C0C14F57EAB00AAAE4E /* ltable.c in Sources */, - 67B83C0D14F57EAB00AAAE4E /* ltablib.c in Sources */, - 67B83C0E14F57EAB00AAAE4E /* ltm.c in Sources */, - 67B83C0F14F57EAB00AAAE4E /* lundump.c in Sources */, - 67B83C1014F57EAB00AAAE4E /* lvm.c in Sources */, - 67B83C1114F57EAB00AAAE4E /* lzio.c in Sources */, - 67B83C1414F57ECA00AAAE4E /* b_bot.c in Sources */, - 67B83C2214F57EE600AAAE4E /* lua_baselib.c in Sources */, - 67B83C2314F57EE600AAAE4E /* lua_consolelib.c in Sources */, - 67B83C2414F57EE600AAAE4E /* lua_hooklib.c in Sources */, - 67B83C2514F57EE600AAAE4E /* lua_infolib.c in Sources */, - 67B83C2614F57EE600AAAE4E /* lua_maplib.c in Sources */, - 67B83C2714F57EE600AAAE4E /* lua_mathlib.c in Sources */, - 67B83C2814F57EE600AAAE4E /* lua_mobjlib.c in Sources */, - 67B83C2914F57EE600AAAE4E /* lua_playerlib.c in Sources */, - 67B83C2A14F57EE600AAAE4E /* lua_script.c in Sources */, - 67B83C2B14F57EE600AAAE4E /* lua_thinkerlib.c in Sources */, - 67B83C3314F57F1500AAAE4E /* m_cond.c in Sources */, - 67259DFD18D2687D00F02971 /* lua_hudlib.c in Sources */, - 67259DFE18D2687D00F02971 /* lua_skinlib.c in Sources */, - 67259E0118D268AE00F02971 /* m_anigif.c in Sources */, - 67259E0618D268F700F02971 /* i_ttf.c in Sources */, - 67259E0718D268F700F02971 /* mixer_sound.c in Sources */, - 67259E0818D268F700F02971 /* sdl_sound.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 089C165DFE840E0CC02AAC07 /* English */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - C01FCF4B08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - NORMALSRB2, - ); - PRODUCT_NAME = Srb2mac; - }; - name = Debug; - }; - C01FCF4C08A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CURRENT_PROJECT_VERSION = 2.1.23; - GCC_ENABLE_FIX_AND_CONTINUE = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_PREPROCESSOR_DEFINITIONS = ( - "$(inherited)", - NORMALSRB2, - ); - PRODUCT_NAME = Srb2mac; - }; - name = Release; - }; - C01FCF4F08A954540054247B /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - ); - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.0.0; - DEBUG_INFORMATION_FORMAT = dwarf; - DSTROOT = "$(HOME)/Applications"; - FRAMEWORK_SEARCH_PATHS = ( - "$(HOME)/Library/Frameworks", - /Library/Frameworks, - "$(FRAMEWORK_SEARCH_PATHS)", - ); - GCC_ENABLE_CPP_EXCEPTIONS = NO; - GCC_ENABLE_CPP_RTTI = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; - GCC_ENABLE_OBJC_EXCEPTIONS = NO; - GCC_ENABLE_PASCAL_STRINGS = NO; - GCC_FAST_OBJC_DISPATCH = NO; - "GCC_MODEL_TUNING[arch=ppc]" = G3; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - MAC_ALERT, - SDLMAIN, - HAVE_SDL, - HAVE_MIXER, - HAVE_PNG, - HAVE_BLUA, - LUA_USE_POSIX, - COMPVERSION, - ); - GCC_THREADSAFE_STATICS = NO; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_VERSION_i386 = 4.0; - GCC_VERSION_ppc0 = 3.3; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_GLOBAL_CONSTRUCTORS = YES; - GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = NO; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = NO; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = NO; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_LABEL = YES; - GCC_WARN_UNUSED_PARAMETER = YES; - GCC_WARN_UNUSED_VALUE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - GGG_MODEL_TUNING_ppc = G3; - HEADER_SEARCH_PATHS = ( - "$(HOME)/Library/Frameworks/SDL.framework/Headers", - /Library/Frameworks/SDL.framework/Headers, - "$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers", - /Library/Frameworks/SDL_mixer.framework/Headers, - "$(HOME)/Library/Frameworks/libz.framework/Headers", - /Library/Frameworks/libz.framework/Headers, - "$(HOME)/Library/Frameworks/libpng.framework/Headers", - /Library/Frameworks/libpng.framework/Headers, - "$(HEADER_SEARCH_PATHS)", - ); - INFOPLIST_FILE = Info.plist; - MACH_O_TYPE = mh_execute; - MACOSX_DEPLOYMENT_TARGET = 10.4; - "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; - "MACOSX_DEPLOYMENT_TARGET[arch=ppc64]" = 10.5; - "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.2; - "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; - MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; - MACOSX_DEPLOYMENT_TARGET_ppc = 10.2; - OBJROOT = "$(inherited)/$(PRODUCT_NAME)/$(CURRENT_PROJECT_VERSION)"; - OTHER_CFLAGS_normal = "-D_DEBUG -DPARANOIA -DRANGECHECK"; - PREBINDING = NO; - PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO; - PRODUCT_NAME = SRB2dummy; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - "SDKROOT[arch=i386]" = macosx10.4; - "SDKROOT[arch=ppc]" = macosx10.3.9; - SDKROOT_i386 = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - STRIP_INSTALLED_PRODUCT = NO; - SYMROOT = "$(inherited)/$(PRODUCT_NAME)/$(CURRENT_PROJECT_VERSION)"; - WARNING_CFLAGS = ( - "-Wall", - "-W", - "-Wno-undef", - "-Wpointer-arith", - "-Wbad-function-cast", - "-Wno-cast-qual", - "-Wcast-align", - "-Wwrite-strings", - "-Waggregate-return", - "-Wmissing-prototypes", - "-Wmissing-declarations", - "-Wno-missing-noreturn", - "-Wnested-externs", - "-Winline", - ); - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - C01FCF5008A954540054247B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ARCHS = ( - i386, - ppc, - ); - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.0.0; - DSTROOT = "$(HOME)/Applications"; - FRAMEWORK_SEARCH_PATHS = ( - "$(HOME)/Library/Frameworks", - /Library/Frameworks, - "$(FRAMEWORK_SEARCH_PATHS)", - ); - GCC_ENABLE_CPP_EXCEPTIONS = NO; - GCC_ENABLE_CPP_RTTI = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = NO; - GCC_ENABLE_PASCAL_STRINGS = NO; - GCC_FAST_OBJC_DISPATCH = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - "GCC_MODEL_TUNING[arch=ppc]" = G3; - GCC_OPTIMIZATION_LEVEL = 2; - GCC_PREPROCESSOR_DEFINITIONS = ( - MAC_ALERT, - SDLMAIN, - HAVE_SDL, - HAVE_MIXER, - HAVE_PNG, - HAVE_BLUA, - LUA_USE_POSIX, - COMPVERSION, - ); - GCC_THREADSAFE_STATICS = NO; - GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; - GCC_TREAT_NONCONFORMANT_CODE_ERRORS_AS_WARNINGS = YES; - GCC_TREAT_WARNINGS_AS_ERRORS = YES; - GCC_VERSION_i386 = 4.0; - GCC_VERSION_ppc0 = 3.3; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_GLOBAL_CONSTRUCTORS = YES; - GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES; - GCC_WARN_ABOUT_MISSING_NEWLINE = YES; - GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES; - GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES; - GCC_WARN_CHECK_SWITCH_STATEMENTS = YES; - GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES; - GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; - GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; - GCC_WARN_INHIBIT_ALL_WARNINGS = NO; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; - GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; - GCC_WARN_PEDANTIC = NO; - GCC_WARN_PROTOTYPE_CONVERSION = NO; - GCC_WARN_SHADOW = NO; - GCC_WARN_SIGN_COMPARE = YES; - GCC_WARN_STRICT_SELECTOR_MATCH = YES; - GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNKNOWN_PRAGMAS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_LABEL = YES; - GCC_WARN_UNUSED_PARAMETER = YES; - GCC_WARN_UNUSED_VALUE = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - GGG_MODEL_TUNING_ppc = G3; - HEADER_SEARCH_PATHS = ( - "$(HOME)/Library/Frameworks/SDL.framework/Headers", - /Library/Frameworks/SDL.framework/Headers, - "$(HOME)/Library/Frameworks/SDL_mixer.framework/Headers", - /Library/Frameworks/SDL_mixer.framework/Headers, - "$(HOME)/Library/Frameworks/libz.framework/Headers", - /Library/Frameworks/libz.framework/Headers, - "$(HOME)/Library/Frameworks/libpng.framework/Headers", - /Library/Frameworks/libpng.framework/Headers, - "$(HEADER_SEARCH_PATHS)", - ); - INFOPLIST_FILE = Info.plist; - MACH_O_TYPE = mh_execute; - MACOSX_DEPLOYMENT_TARGET = 10.4; - "MACOSX_DEPLOYMENT_TARGET[arch=i386]" = 10.4; - "MACOSX_DEPLOYMENT_TARGET[arch=ppc64]" = 10.5; - "MACOSX_DEPLOYMENT_TARGET[arch=ppc]" = 10.2; - "MACOSX_DEPLOYMENT_TARGET[arch=x86_64]" = 10.5; - MACOSX_DEPLOYMENT_TARGET_i386 = 10.4; - MACOSX_DEPLOYMENT_TARGET_ppc = 10.2; - OBJROOT = "$(inherited)/$(PRODUCT_NAME)/$(CURRENT_PROJECT_VERSION)"; - OTHER_CFLAGS_normal = "-DNDEBUG"; - PREBINDING = NO; - PRECOMPS_INCLUDE_HEADERS_FROM_BUILT_PRODUCTS_DIR = NO; - PRODUCT_NAME = SRB2dummy; - SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - "SDKROOT[arch=i386]" = macosx10.4; - "SDKROOT[arch=ppc]" = macosx10.3.9; - SDKROOT_i386 = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; - SDKROOT_ppc = "$(DEVELOPER_SDK_DIR)/MacOSX10.3.9.sdk"; - STRIP_INSTALLED_PRODUCT = NO; - SYMROOT = "$(inherited)/$(PRODUCT_NAME)/$(CURRENT_PROJECT_VERSION)"; - WARNING_CFLAGS = ( - "-Wall", - "-W", - "-Wno-undef", - "-Wpointer-arith", - "-Wbad-function-cast", - "-Wno-cast-qual", - "-Wcast-align", - "-Wwrite-strings", - "-Waggregate-return", - "-Wmissing-prototypes", - "-Wmissing-declarations", - "-Wno-missing-noreturn", - "-Wnested-externs", - "-Winline", - "-Wno-aggregate-return", - ); - WRAPPER_EXTENSION = app; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "Srb2mac" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4B08A954540054247B /* Debug */, - C01FCF4C08A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Debug; - }; - C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Srb2mac" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C01FCF4F08A954540054247B /* Debug */, - C01FCF5008A954540054247B /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Debug; - }; -/* End XCConfigurationList section */ - }; - rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; -} diff --git a/src/sdl12/macosx/mac_alert.c b/src/sdl12/macosx/mac_alert.c deleted file mode 100644 index 455e36509..000000000 --- a/src/sdl12/macosx/mac_alert.c +++ /dev/null @@ -1,45 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Graphical Alerts for MacOSX -/// -/// Shows alerts, since we can't just print these to the screen when -/// launched graphically on a mac. - -#ifdef __APPLE_CC__ - -#include "mac_alert.h" -#include - -int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3) -{ - CFOptionFlags results; - - CFUserNotificationDisplayAlert(0, - kCFUserNotificationStopAlertLevel | kCFUserNotificationNoDefaultButtonFlag, - NULL, NULL, NULL, - CFStringCreateWithCString(NULL, title, kCFStringEncodingASCII), - CFStringCreateWithCString(NULL, message, kCFStringEncodingASCII), - button1 != NULL ? CFStringCreateWithCString(NULL, button1, kCFStringEncodingASCII) : NULL, - button2 != NULL ? CFStringCreateWithCString(NULL, button2, kCFStringEncodingASCII) : NULL, - button3 != NULL ? CFStringCreateWithCString(NULL, button3, kCFStringEncodingASCII) : NULL, - &results); - - return (int)results; -} - -#endif diff --git a/src/sdl12/macosx/mac_alert.h b/src/sdl12/macosx/mac_alert.h deleted file mode 100644 index 82a28d120..000000000 --- a/src/sdl12/macosx/mac_alert.h +++ /dev/null @@ -1,27 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// Portions Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Graphical Alerts for MacOSX -/// -/// Shows alerts, since we can't just print these to the screen when -/// launched graphically on a mac. - -#ifdef __APPLE_CC__ - -extern int MacShowAlert(const char *title, const char *message, const char *button1, const char *button2, const char *button3); - -#endif diff --git a/src/sdl12/mixer_sound.c b/src/sdl12/mixer_sound.c deleted file mode 100644 index dcae19b05..000000000 --- a/src/sdl12/mixer_sound.c +++ /dev/null @@ -1,832 +0,0 @@ -// SONIC ROBO BLAST 2 -//----------------------------------------------------------------------------- -// Copyright (C) 2008-2018 by Sonic Team Junior. -// -// This program is free software distributed under the -// terms of the GNU General Public License, version 2. -// See the 'LICENSE' file for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL Mixer interface for sound - -#include "../doomdef.h" - -#if defined(HAVE_SDL) && defined(HAVE_MIXER) && SOUND==SOUND_MIXER - -#include "../sounds.h" -#include "../s_sound.h" -#include "../i_sound.h" -#include "../w_wad.h" -#include "../z_zone.h" -#include "../byteptr.h" - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif -#include "SDL.h" -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#include "SDL_mixer.h" - -/* This is the version number macro for the current SDL_mixer version: */ -#ifndef SDL_MIXER_COMPILEDVERSION -#define SDL_MIXER_COMPILEDVERSION \ - SDL_VERSIONNUM(MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL) -#endif - -/* This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z */ -#ifndef SDL_MIXER_VERSION_ATLEAST -#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ - (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) -#endif - -#ifdef HAVE_LIBGME -#include "gme/gme.h" -#define GME_TREBLE 5.0 -#define GME_BASS 1.0 -#ifdef HAVE_PNG /// TODO: compile with zlib support without libpng - -#define HAVE_ZLIB - -#ifndef _MSC_VER -#ifndef _WII -#ifndef _LARGEFILE64_SOURCE -#define _LARGEFILE64_SOURCE -#endif -#endif -#endif - -#ifndef _LFS64_LARGEFILE -#define _LFS64_LARGEFILE -#endif - -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 0 -#endif - -#include "zlib.h" -#endif -#endif - -UINT8 sound_started = false; - -static boolean midimode; -static Mix_Music *music; -static UINT8 music_volume, midi_volume, sfx_volume; -static float loop_point; - -#ifdef HAVE_LIBGME -static Music_Emu *gme; -static INT32 current_track; -#endif - -void I_StartupSound(void) -{ - I_Assert(!sound_started); - sound_started = true; - - midimode = false; - music = NULL; - music_volume = midi_volume = sfx_volume = 0; - -#if SDL_MIXER_VERSION_ATLEAST(1,2,11) - Mix_Init(MIX_INIT_FLAC|MIX_INIT_MOD|MIX_INIT_MP3|MIX_INIT_OGG); -#endif - Mix_OpenAudio(44100, AUDIO_S16LSB, 2, 2048); - Mix_AllocateChannels(256); -} - -void I_ShutdownSound(void) -{ - I_Assert(sound_started); - sound_started = false; - - Mix_CloseAudio(); -#if SDL_MIXER_VERSION_ATLEAST(1,2,11) - Mix_Quit(); -#endif -#ifdef HAVE_LIBGME - if (gme) - gme_delete(gme); -#endif -} - -void I_UpdateSound(void) -{ -} - -// this is as fast as I can possibly make it. -// sorry. more asm needed. -static Mix_Chunk *ds2chunk(void *stream) -{ - UINT16 ver,freq; - UINT32 samples, i, newsamples; - UINT8 *sound; - - SINT8 *s; - INT16 *d; - INT16 o; - fixed_t step, frac; - - // lump header - ver = READUINT16(stream); // sound version format? - if (ver != 3) // It should be 3 if it's a doomsound... - return NULL; // onos! it's not a doomsound! - freq = READUINT16(stream); - samples = READUINT32(stream); - - // convert from signed 8bit ???hz to signed 16bit 44100hz. - switch(freq) - { - case 44100: - if (samples >= UINT32_MAX>>2) - return NULL; // would wrap, can't store. - newsamples = samples; - break; - case 22050: - if (samples >= UINT32_MAX>>3) - return NULL; // would wrap, can't store. - newsamples = samples<<1; - break; - case 11025: - if (samples >= UINT32_MAX>>4) - return NULL; // would wrap, can't store. - newsamples = samples<<2; - break; - default: - frac = (44100 << FRACBITS) / (UINT32)freq; - if (!(frac & 0xFFFF)) // other solid multiples (change if FRACBITS != 16) - newsamples = samples * (frac >> FRACBITS); - else // strange and unusual fractional frequency steps, plus anything higher than 44100hz. - newsamples = FixedMul(FixedDiv(samples, freq), 44100) + 1; // add 1 to counter truncation. - if (newsamples >= UINT32_MAX>>2) - return NULL; // would and/or did wrap, can't store. - break; - } - sound = Z_Malloc(newsamples<<2, PU_SOUND, NULL); // samples * frequency shift * bytes per sample * channels - - s = (SINT8 *)stream; - d = (INT16 *)sound; - - i = 0; - switch(freq) - { - case 44100: // already at the same rate? well that makes it simple. - while(i++ < samples) - { - o = ((INT16)(*s++)+0x80)<<8; // changed signedness and shift up to 16 bits - *d++ = o; // left channel - *d++ = o; // right channel - } - break; - case 22050: // unwrap 2x - while(i++ < samples) - { - o = ((INT16)(*s++)+0x80)<<8; // changed signedness and shift up to 16 bits - *d++ = o; // left channel - *d++ = o; // right channel - *d++ = o; // left channel - *d++ = o; // right channel - } - break; - case 11025: // unwrap 4x - while(i++ < samples) - { - o = ((INT16)(*s++)+0x80)<<8; // changed signedness and shift up to 16 bits - *d++ = o; // left channel - *d++ = o; // right channel - *d++ = o; // left channel - *d++ = o; // right channel - *d++ = o; // left channel - *d++ = o; // right channel - *d++ = o; // left channel - *d++ = o; // right channel - } - break; - default: // convert arbitrary hz to 44100. - step = 0; - frac = ((UINT32)freq << FRACBITS) / 44100; - while (i < samples) - { - o = (INT16)(*s+0x80)<<8; // changed signedness and shift up to 16 bits - while (step < FRACUNIT) // this is as fast as I can make it. - { - *d++ = o; // left channel - *d++ = o; // right channel - step += frac; - } - do { - i++; s++; - step -= FRACUNIT; - } while (step >= FRACUNIT); - } - break; - } - - // return Mixer Chunk. - return Mix_QuickLoad_RAW(sound, (UINT8*)d-sound); -} - -void *I_GetSfx(sfxinfo_t *sfx) -{ - void *lump; - Mix_Chunk *chunk; -#ifdef HAVE_LIBGME - Music_Emu *emu; - gme_info_t *info; -#endif - - if (sfx->lumpnum == LUMPERROR) - sfx->lumpnum = S_GetSfxLumpNum(sfx); - sfx->length = W_LumpLength(sfx->lumpnum); - - lump = W_CacheLumpNum(sfx->lumpnum, PU_SOUND); - - // convert from standard DoomSound format. - chunk = ds2chunk(lump); - if (chunk) - { - Z_Free(lump); - return chunk; - } - - // Not a doom sound? Try something else. -#ifdef HAVE_LIBGME - // VGZ format - if (((UINT8 *)lump)[0] == 0x1F - && ((UINT8 *)lump)[1] == 0x8B) - { -#ifdef HAVE_ZLIB - UINT8 *inflatedData; - size_t inflatedLen; - z_stream stream; - int zErr; // Somewhere to handle any error messages zlib tosses out - - memset(&stream, 0x00, sizeof (z_stream)); // Init zlib stream - // Begin the inflation process - inflatedLen = *(UINT32 *)lump + (sfx->length-4); // Last 4 bytes are the decompressed size, typically - inflatedData = (UINT8 *)Z_Malloc(inflatedLen, PU_SOUND, NULL); // Make room for the decompressed data - stream.total_in = stream.avail_in = sfx->length; - stream.total_out = stream.avail_out = inflatedLen; - stream.next_in = (UINT8 *)lump; - stream.next_out = inflatedData; - - zErr = inflateInit2(&stream, 32 + MAX_WBITS); - if (zErr == Z_OK) // We're good to go - { - zErr = inflate(&stream, Z_FINISH); - if (zErr == Z_STREAM_END) { - // Run GME on new data - if (!gme_open_data(inflatedData, inflatedLen, &emu, 44100)) - { - short *mem; - UINT32 len; - gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; - - Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around - Z_Free(lump); // We're done with the uninflated lump now, too. - - gme_start_track(emu, 0); - gme_set_equalizer(emu, &eq); - gme_track_info(emu, &info, 0); - - len = (info->play_length * 441 / 10) << 2; - mem = Z_Malloc(len, PU_SOUND, NULL); - gme_play(emu, len >> 1, mem); - gme_delete(emu); - - return Mix_QuickLoad_RAW((Uint8 *)mem, len); - } - } - else - { - const char *errorType; - switch (zErr) - { - case Z_ERRNO: - errorType = "Z_ERRNO"; break; - case Z_STREAM_ERROR: - errorType = "Z_STREAM_ERROR"; break; - case Z_DATA_ERROR: - errorType = "Z_DATA_ERROR"; break; - case Z_MEM_ERROR: - errorType = "Z_MEM_ERROR"; break; - case Z_BUF_ERROR: - errorType = "Z_BUF_ERROR"; break; - case Z_VERSION_ERROR: - errorType = "Z_VERSION_ERROR"; break; - default: - errorType = "unknown error"; - } - CONS_Alert(CONS_ERROR,"Encountered %s when running inflate: %s\n", errorType, stream.msg); - } - (void)inflateEnd(&stream); - } - else // Hold up, zlib's got a problem - { - const char *errorType; - switch (zErr) - { - case Z_ERRNO: - errorType = "Z_ERRNO"; break; - case Z_STREAM_ERROR: - errorType = "Z_STREAM_ERROR"; break; - case Z_DATA_ERROR: - errorType = "Z_DATA_ERROR"; break; - case Z_MEM_ERROR: - errorType = "Z_MEM_ERROR"; break; - case Z_BUF_ERROR: - errorType = "Z_BUF_ERROR"; break; - case Z_VERSION_ERROR: - errorType = "Z_VERSION_ERROR"; break; - default: - errorType = "unknown error"; - } - CONS_Alert(CONS_ERROR,"Encountered %s when running inflateInit: %s\n", errorType, stream.msg); - } - Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up -#else - //CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); -#endif - } - // Try to read it as a GME sound - else if (!gme_open_data(lump, sfx->length, &emu, 44100)) - { - short *mem; - UINT32 len; - gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; - - Z_Free(lump); - - gme_start_track(emu, 0); - gme_set_equalizer(emu, &eq); - gme_track_info(emu, &info, 0); - - len = (info->play_length * 441 / 10) << 2; - mem = Z_Malloc(len, PU_SOUND, NULL); - gme_play(emu, len >> 1, mem); - gme_delete(emu); - - return Mix_QuickLoad_RAW((Uint8 *)mem, len); - } -#endif - - // Try to load it as a WAVE or OGG using Mixer. - return Mix_LoadWAV_RW(SDL_RWFromMem(lump, sfx->length), 1); -} - -void I_FreeSfx(sfxinfo_t *sfx) -{ - if (sfx->data) - Mix_FreeChunk(sfx->data); - sfx->data = NULL; -} - -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) -{ - UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127 - INT32 handle = Mix_PlayChannel(channel, S_sfx[id].data, 0); - Mix_Volume(handle, volume); - Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff)); - (void)pitch; // Mixer can't handle pitch - (void)priority; // priority and channel management is handled by SRB2... - return handle; -} - -void I_StopSound(INT32 handle) -{ - Mix_HaltChannel(handle); -} - -boolean I_SoundIsPlaying(INT32 handle) -{ - return Mix_Playing(handle); -} - -void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch) -{ - UINT8 volume = (((UINT16)vol + 1) * (UINT16)sfx_volume) / 62; // (256 * 31) / 62 == 127 - Mix_Volume(handle, volume); - Mix_SetPanning(handle, min((UINT16)(0xff-sep)<<1, 0xff), min((UINT16)(sep)<<1, 0xff)); - (void)pitch; -} - -void I_SetSfxVolume(UINT8 volume) -{ - sfx_volume = volume; -} - -// -// Music -// - -// Music hooks -static void music_loop(void) -{ - Mix_PlayMusic(music, 0); - Mix_SetMusicPosition(loop_point); -} - -#ifdef HAVE_LIBGME -static void mix_gme(void *udata, Uint8 *stream, int len) -{ - int i; - short *p; - - (void)udata; - - // no gme? no music. - if (!gme || gme_track_ended(gme)) - return; - - // play gme into stream - gme_play(gme, len/2, (short *)stream); - - // apply volume to stream - for (i = 0, p = (short *)stream; i < len/2; i++, p++) - *p = ((INT32)*p) * music_volume / 31; -} -#endif - -void I_InitMusic(void) -{ -} - -void I_ShutdownMusic(void) -{ - I_ShutdownDigMusic(); - I_ShutdownMIDIMusic(); -} - -void I_PauseSong(INT32 handle) -{ - (void)handle; - Mix_PauseMusic(); -} - -void I_ResumeSong(INT32 handle) -{ - (void)handle; - Mix_ResumeMusic(); -} - -// -// Digital Music -// - -void I_InitDigMusic(void) -{ -#ifdef HAVE_LIBGME - gme = NULL; - current_track = -1; -#endif -} - -void I_ShutdownDigMusic(void) -{ - if (midimode) - return; -#ifdef HAVE_LIBGME - if (gme) - { - Mix_HookMusic(NULL, NULL); - gme_delete(gme); - gme = NULL; - } -#endif - if (!music) - return; - Mix_HookMusicFinished(NULL); - Mix_FreeMusic(music); - music = NULL; -} - -boolean I_StartDigSong(const char *musicname, boolean looping) -{ - char *data; - size_t len; - lumpnum_t lumpnum = W_CheckNumForName(va("O_%s",musicname)); - - I_Assert(!music); -#ifdef HAVE_LIBGME - I_Assert(!gme); -#endif - - if (lumpnum == LUMPERROR) - { - lumpnum = W_CheckNumForName(va("D_%s",musicname)); - if (lumpnum == LUMPERROR) - return false; - midimode = true; - } - else - midimode = false; - - data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC); - len = W_LumpLength(lumpnum); - -#ifdef HAVE_LIBGME - if ((UINT8)data[0] == 0x1F - && (UINT8)data[1] == 0x8B) - { -#ifdef HAVE_ZLIB - UINT8 *inflatedData; - size_t inflatedLen; - z_stream stream; - int zErr; // Somewhere to handle any error messages zlib tosses out - - memset(&stream, 0x00, sizeof (z_stream)); // Init zlib stream - // Begin the inflation process - inflatedLen = *(UINT32 *)(data + (len-4)); // Last 4 bytes are the decompressed size, typically - inflatedData = (UINT8 *)Z_Calloc(inflatedLen, PU_MUSIC, NULL); // Make room for the decompressed data - stream.total_in = stream.avail_in = len; - stream.total_out = stream.avail_out = inflatedLen; - stream.next_in = (UINT8 *)data; - stream.next_out = inflatedData; - - zErr = inflateInit2(&stream, 32 + MAX_WBITS); - if (zErr == Z_OK) // We're good to go - { - zErr = inflate(&stream, Z_FINISH); - if (zErr == Z_STREAM_END) { - // Run GME on new data - if (!gme_open_data(inflatedData, inflatedLen, &gme, 44100)) - { - gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; - gme_start_track(gme, 0); - current_track = 0; - gme_set_equalizer(gme, &eq); - Mix_HookMusic(mix_gme, gme); - Z_Free(inflatedData); // GME supposedly makes a copy for itself, so we don't need this lying around - return true; - } - } - else - { - const char *errorType; - switch (zErr) - { - case Z_ERRNO: - errorType = "Z_ERRNO"; break; - case Z_STREAM_ERROR: - errorType = "Z_STREAM_ERROR"; break; - case Z_DATA_ERROR: - errorType = "Z_DATA_ERROR"; break; - case Z_MEM_ERROR: - errorType = "Z_MEM_ERROR"; break; - case Z_BUF_ERROR: - errorType = "Z_BUF_ERROR"; break; - case Z_VERSION_ERROR: - errorType = "Z_VERSION_ERROR"; break; - default: - errorType = "unknown error"; - } - CONS_Alert(CONS_ERROR,"Encountered %s when running inflate: %s\n", errorType, stream.msg); - } - (void)inflateEnd(&stream); - } - else // Hold up, zlib's got a problem - { - const char *errorType; - switch (zErr) - { - case Z_ERRNO: - errorType = "Z_ERRNO"; break; - case Z_STREAM_ERROR: - errorType = "Z_STREAM_ERROR"; break; - case Z_DATA_ERROR: - errorType = "Z_DATA_ERROR"; break; - case Z_MEM_ERROR: - errorType = "Z_MEM_ERROR"; break; - case Z_BUF_ERROR: - errorType = "Z_BUF_ERROR"; break; - case Z_VERSION_ERROR: - errorType = "Z_VERSION_ERROR"; break; - default: - errorType = "unknown error"; - } - CONS_Alert(CONS_ERROR,"Encountered %s when running inflateInit: %s\n", errorType, stream.msg); - } - Z_Free(inflatedData); // GME didn't open jack, but don't let that stop us from freeing this up -#else - //CONS_Alert(CONS_ERROR,"Cannot decompress VGZ; no zlib support\n"); -#endif - } - else if (!gme_open_data(data, len, &gme, 44100)) - { - gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; - gme_start_track(gme, 0); - current_track = 0; - gme_set_equalizer(gme, &eq); - Mix_HookMusic(mix_gme, gme); - return true; - } -#endif - - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len)); - if (!music) - { - CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); - return true; - } - - // Find the OGG loop point. - loop_point = 0.0f; - if (looping) - { - const char *key1 = "LOOP"; - const char *key2 = "POINT="; - const char *key3 = "MS="; - const UINT8 key1len = strlen(key1); - const UINT8 key2len = strlen(key2); - const UINT8 key3len = strlen(key3); - char *p = data; - while ((UINT32)(p - data) < len) - { - if (strncmp(p++, key1, key1len)) - continue; - p += key1len-1; // skip OOP (the L was skipped in strncmp) - if (!strncmp(p, key2, key2len)) // is it LOOPPOINT=? - { - p += key2len; // skip POINT= - loop_point = (float)((44.1L+atoi(p)) / 44100.0L); // LOOPPOINT works by sample count. - // because SDL_Mixer is USELESS and can't even tell us - // something simple like the frequency of the streaming music, - // we are unfortunately forced to assume that ALL MUSIC is 44100hz. - // This means a lot of tracks that are only 22050hz for a reasonable downloadable file size will loop VERY badly. - } - else if (!strncmp(p, key3, key3len)) // is it LOOPMS=? - { - p += key3len; // skip MS= - loop_point = atoi(p) / 1000.0L; // LOOPMS works by real time, as miliseconds. - // Everything that uses LOOPMS will work perfectly with SDL_Mixer. - } - // Neither?! Continue searching. - } - } - - if (Mix_PlayMusic(music, looping && loop_point == 0.0f ? -1 : 0) == -1) - { - CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); - return true; - } - if (midimode) - Mix_VolumeMusic((UINT32)midi_volume*128/31); - else - Mix_VolumeMusic((UINT32)music_volume*128/31); - - if (loop_point != 0.0f) - Mix_HookMusicFinished(music_loop); - return true; -} - -void I_StopDigSong(void) -{ - if (midimode) - return; -#ifdef HAVE_LIBGME - if (gme) - { - Mix_HookMusic(NULL, NULL); - gme_delete(gme); - gme = NULL; - current_track = -1; - return; - } -#endif - if (!music) - return; - Mix_HookMusicFinished(NULL); - Mix_FreeMusic(music); - music = NULL; -} - -void I_SetDigMusicVolume(UINT8 volume) -{ - music_volume = volume; - if (midimode || !music) - return; - Mix_VolumeMusic((UINT32)volume*128/31); -} - -boolean I_SetSongSpeed(float speed) -{ - if (speed > 250.0f) - speed = 250.0f; //limit speed up to 250x -#ifdef HAVE_LIBGME - if (gme) - { - SDL_LockAudio(); - gme_set_tempo(gme, speed); - SDL_UnlockAudio(); - return true; - } -#else - (void)speed; -#endif - return false; -} - -boolean I_SetSongTrack(int track) -{ -#ifdef HAVE_LIBGME - if (current_track == track) - return false; - - // If the specified track is within the number of tracks playing, then change it - if (gme) - { - SDL_LockAudio(); - if (track >= 0 - && track < gme_track_count(gme)) - { - gme_err_t gme_e = gme_start_track(gme, track); - if (gme_e != NULL) - { - CONS_Alert(CONS_ERROR, "GME error: %s\n", gme_e); - return false; - } - current_track = track; - SDL_UnlockAudio(); - return true; - } - SDL_UnlockAudio(); - return false; - } -#endif - (void)track; - return false; -} - -// -// MIDI Music -// - -void I_InitMIDIMusic(void) -{ -} - -void I_ShutdownMIDIMusic(void) -{ - if (!midimode || !music) - return; - Mix_FreeMusic(music); - music = NULL; -} - -void I_SetMIDIMusicVolume(UINT8 volume) -{ - midi_volume = volume; - if (!midimode || !music) - return; - Mix_VolumeMusic((UINT32)volume*128/31); -} - -INT32 I_RegisterSong(void *data, size_t len) -{ - music = Mix_LoadMUS_RW(SDL_RWFromMem(data, len)); - if (!music) - { - CONS_Alert(CONS_ERROR, "Mix_LoadMUS_RW: %s\n", Mix_GetError()); - return -1; - } - return 1337; -} - -boolean I_PlaySong(INT32 handle, boolean looping) -{ - (void)handle; - - midimode = true; - - if (Mix_PlayMusic(music, looping ? -1 : 0) == -1) - { - CONS_Alert(CONS_ERROR, "Mix_PlayMusic: %s\n", Mix_GetError()); - return false; - } - Mix_VolumeMusic((UINT32)music_volume*128/31); - return true; -} - -void I_StopSong(INT32 handle) -{ - if (!midimode || !music) - return; - - (void)handle; - Mix_HaltMusic(); -} - -void I_UnRegisterSong(INT32 handle) -{ - if (!midimode || !music) - return; - - (void)handle; - Mix_FreeMusic(music); - music = NULL; -} - -#endif diff --git a/src/sdl12/ogl_sdl.c b/src/sdl12/ogl_sdl.c deleted file mode 100644 index eb7e9996d..000000000 --- a/src/sdl12/ogl_sdl.c +++ /dev/null @@ -1,317 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL specific part of the OpenGL API for SRB2 - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - -#ifdef HAVE_SDL - -#include "SDL.h" - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#include "../doomdef.h" - -#ifdef HWRENDER -#include "../hardware/r_opengl/r_opengl.h" -#include "ogl_sdl.h" -#include "../i_system.h" -#include "hwsym_sdl.h" -#include "../m_argv.h" - -#ifdef DEBUG_TO_FILE -#include -#if defined (_WIN32) && !defined (__CYGWIN__) -#include -#else -#include -#endif -#include -#include -#endif - -#ifdef USE_WGL_SWAP -PFNWGLEXTSWAPCONTROLPROC wglSwapIntervalEXT = NULL; -#else -typedef int (*PFNGLXSWAPINTERVALPROC) (int); -PFNGLXSWAPINTERVALPROC glXSwapIntervalSGIEXT = NULL; -#endif - -#ifndef STATIC_OPENGL -PFNglClear pglClear; -PFNglGetIntegerv pglGetIntegerv; -PFNglGetString pglGetString; -#endif - -#ifdef _PSP -static const Uint32 WOGLFlags = SDL_HWSURFACE|SDL_OPENGL/*|SDL_RESIZABLE*/; -static const Uint32 FOGLFlags = SDL_HWSURFACE|SDL_OPENGL|SDL_FULLSCREEN; -#else -static const Uint32 WOGLFlags = SDL_OPENGL/*|SDL_RESIZABLE*/; -static const Uint32 FOGLFlags = SDL_OPENGL|SDL_FULLSCREEN; -#endif - -/** \brief SDL video display surface -*/ -SDL_Surface *vidSurface = NULL; -INT32 oglflags = 0; -void *GLUhandle = NULL; - -#ifndef STATIC_OPENGL -void *GetGLFunc(const char *proc) -{ - if (strncmp(proc, "glu", 3) == 0) - { - if (GLUhandle) - return hwSym(proc, GLUhandle); - else - return NULL; - } - return SDL_GL_GetProcAddress(proc); -} -#endif - -boolean LoadGL(void) -{ -#ifndef STATIC_OPENGL - const char *OGLLibname = NULL; - const char *GLULibname = NULL; - - if (M_CheckParm ("-OGLlib") && M_IsNextParm()) - OGLLibname = M_GetNextParm(); - - if (SDL_GL_LoadLibrary(OGLLibname) != 0) - { - I_OutputMsg("Could not load OpenGL Library: %s\n" - "Falling back to Software mode.\n", SDL_GetError()); - if (!M_CheckParm ("-OGLlib")) - I_OutputMsg("If you know what is the OpenGL library's name, use -OGLlib\n"); - return 0; - } - -#if 0 - GLULibname = "/proc/self/exe"; -#elif defined (_WIN32) - GLULibname = "GLU32.DLL"; -#elif defined (__MACH__) - GLULibname = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGLU.dylib"; -#elif defined (macintos) - GLULibname = "OpenGLLibrary"; -#elif defined (__unix__) - GLULibname = "libGLU.so.1"; -#elif defined (__HAIKU__) - GLULibname = "libGLU.so"; -#else - GLULibname = NULL; -#endif - - if (M_CheckParm ("-GLUlib") && M_IsNextParm()) - GLULibname = M_GetNextParm(); - - if (GLULibname) - { - GLUhandle = hwOpen(GLULibname); - if (GLUhandle) - return SetupGLfunc(); - else - { - I_OutputMsg("Could not load GLU Library: %s\n", GLULibname); - if (!M_CheckParm ("-GLUlib")) - I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n"); - } - } - else - { - I_OutputMsg("Could not load GLU Library\n"); - I_OutputMsg("If you know what is the GLU library's name, use -GLUlib\n"); - } -#endif - return SetupGLfunc(); -} - -/** \brief The OglSdlSurface function - - \param w width - \param h height - \param isFullscreen if true, go fullscreen - - \return if true, changed video mode -*/ -boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen) -{ - INT32 cbpp; - Uint32 OGLFlags; - const GLvoid *glvendor = NULL, *glrenderer = NULL, *glversion = NULL; - - cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value; - - if (vidSurface) - { - //Alam: SDL_Video system free vidSurface for me -#ifdef VOODOOSAFESWITCHING - SDL_QuitSubSystem(SDL_INIT_VIDEO); - SDL_InitSubSystem(SDL_INIT_VIDEO); -#endif - } - - if (isFullscreen) - OGLFlags = FOGLFlags; - else - OGLFlags = WOGLFlags; - - cbpp = SDL_VideoModeOK(w, h, cbpp, OGLFlags); - if (cbpp < 16) - return true; //Alam: Let just say we did, ok? - - vidSurface = SDL_SetVideoMode(w, h, cbpp, OGLFlags); - if (!vidSurface) - return false; - - glvendor = pglGetString(GL_VENDOR); - // Get info and extensions. - //BP: why don't we make it earlier ? - //Hurdler: we cannot do that before intialising gl context - glrenderer = pglGetString(GL_RENDERER); - glversion = pglGetString(GL_VERSION); - gl_extensions = pglGetString(GL_EXTENSIONS); - - DBG_Printf("Vendor : %s\n", glvendor); - DBG_Printf("Renderer : %s\n", glrenderer); - DBG_Printf("Version : %s\n", glversion); - DBG_Printf("Extensions : %s\n", gl_extensions); - oglflags = 0; - -#ifdef _WIN32 - // BP: disable advenced feature that don't work on somes hardware - // Hurdler: Now works on G400 with bios 1.6 and certified drivers 6.04 - if (strstr(glrenderer, "810")) oglflags |= GLF_NOZBUFREAD; -#elif defined (unix) || defined (UNIXCOMMON) - // disable advanced features not working on somes hardware - if (strstr(glrenderer, "G200")) oglflags |= GLF_NOTEXENV; - if (strstr(glrenderer, "G400")) oglflags |= GLF_NOTEXENV; -#endif - DBG_Printf("oglflags : 0x%X\n", oglflags ); - -#ifdef USE_PALETTED_TEXTURE - if (isExtAvailable("GL_EXT_paletted_texture", gl_extensions)) - glColorTableEXT = SDL_GL_GetProcAddress("glColorTableEXT"); - else - glColorTableEXT = NULL; -#endif - -#ifdef USE_WGL_SWAP - if (isExtAvailable("WGL_EXT_swap_control", gl_extensions)) - wglSwapIntervalEXT = SDL_GL_GetProcAddress("wglSwapIntervalEXT"); - else - wglSwapIntervalEXT = NULL; -#else - if (isExtAvailable("GLX_SGI_swap_control", gl_extensions)) - glXSwapIntervalSGIEXT = SDL_GL_GetProcAddress("glXSwapIntervalSGI"); - else - glXSwapIntervalSGIEXT = NULL; -#endif - -#ifndef KOS_GL_COMPATIBILITY - if (isExtAvailable("GL_EXT_texture_filter_anisotropic", gl_extensions)) - pglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy); - else -#endif - maximumAnisotropy = 0; - - SetupGLFunc13(); - - granisotropicmode_cons_t[1].value = maximumAnisotropy; - - SetModelView(w, h); - SetStates(); - pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); - - HWR_Startup(); -#ifdef KOS_GL_COMPATIBILITY - textureformatGL = GL_ARGB4444; -#else - textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1; -#endif - - return true; -} - -/** \brief The OglSdlFinishUpdate function - - \param vidwait wait for video sync - - \return void -*/ -void OglSdlFinishUpdate(boolean waitvbl) -{ - static boolean oldwaitvbl = false; - if (oldwaitvbl != waitvbl) - { -#ifdef USE_WGL_SWAP - if (wglSwapIntervalEXT) - wglSwapIntervalEXT(waitvbl); -#else - if (glXSwapIntervalSGIEXT) - glXSwapIntervalSGIEXT(waitvbl); -#endif - } - oldwaitvbl = waitvbl; - - SDL_GL_SwapBuffers(); -} - -EXPORT void HWRAPI( OglSdlSetPalette) (RGBA_t *palette, RGBA_t *pgamma) -{ - INT32 i = -1; - UINT32 redgamma = pgamma->s.red, greengamma = pgamma->s.green, - bluegamma = pgamma->s.blue; - -#if 0 // changing the gamma to 127 is a bad idea - i = SDL_SetGamma(byteasfloat(redgamma), byteasfloat(greengamma), byteasfloat(bluegamma)); -#endif - if (i == 0) redgamma = greengamma = bluegamma = 0x7F; //Alam: cool - for (i = 0; i < 256; i++) - { - myPaletteData[i].s.red = (UINT8)MIN((palette[i].s.red * redgamma) /127, 255); - myPaletteData[i].s.green = (UINT8)MIN((palette[i].s.green * greengamma)/127, 255); - myPaletteData[i].s.blue = (UINT8)MIN((palette[i].s.blue * bluegamma) /127, 255); - myPaletteData[i].s.alpha = palette[i].s.alpha; - } -#ifdef USE_PALETTED_TEXTURE - if (glColorTableEXT) - { - for (i = 0; i < 256; i++) - { - palette_tex[(3*i)+0] = palette[i].s.red; - palette_tex[(3*i)+1] = palette[i].s.green; - palette_tex[(3*i)+2] = palette[i].s.blue; - } - glColorTableEXT(GL_TEXTURE_2D, GL_RGB8, 256, GL_RGB, GL_UNSIGNED_BYTE, palette_tex); - } -#endif - // on a chang�de palette, il faut recharger toutes les textures - // jaja, und noch viel mehr ;-) - Flush(); -} - -#endif //HWRENDER -#endif //SDL diff --git a/src/sdl12/ogl_sdl.h b/src/sdl12/ogl_sdl.h deleted file mode 100644 index 43c28fa42..000000000 --- a/src/sdl12/ogl_sdl.h +++ /dev/null @@ -1,30 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL specific part of the OpenGL API for SRB2 - -#include "../v_video.h" - -extern SDL_Surface *vidSurface; -extern void *GLUhandle; - -boolean OglSdlSurface(INT32 w, INT32 h, boolean isFullscreen); - -void OglSdlFinishUpdate(boolean vidwait); - -#ifdef _CREATE_DLL_ -EXPORT void HWRAPI( OglSdlSetPalette ) (RGBA_t *palette, RGBA_t *pgamma); -#endif diff --git a/src/sdl12/sdl_sound.c b/src/sdl12/sdl_sound.c deleted file mode 100644 index ed1afd8e2..000000000 --- a/src/sdl12/sdl_sound.c +++ /dev/null @@ -1,2031 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// The source is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief SDL interface for sound - -#include -#include "../doomdef.h" - -#ifdef _MSC_VER -#pragma warning(disable : 4214 4244) -#endif - -#if defined(HAVE_SDL) && SOUND==SOUND_SDL - -#include "SDL.h" - -#ifdef _MSC_VER -#pragma warning(default : 4214 4244) -#endif - -#ifdef HAVE_MIXER -#include "SDL_mixer.h" -/* This is the version number macro for the current SDL_mixer version: */ -#ifndef SDL_MIXER_COMPILEDVERSION -#define SDL_MIXER_COMPILEDVERSION \ - SDL_VERSIONNUM(MIX_MAJOR_VERSION, MIX_MINOR_VERSION, MIX_PATCHLEVEL) -#endif - -/* This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z */ -#ifndef SDL_MIXER_VERSION_ATLEAST -#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ - (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) -#endif - -#else -#define MIX_CHANNELS 8 -#endif - -#if defined (_WIN32) && !defined (_WIN32_WCE) && !defined (_XBOX) -#include -#elif defined (__GNUC__) -#include -#endif -#include "../z_zone.h" - -#include "../m_swap.h" -#include "../i_system.h" -#include "../i_sound.h" -#include "../m_argv.h" -#include "../m_misc.h" -#include "../w_wad.h" -#include "../screen.h" //vid.WndParent -#include "../doomdef.h" -#include "../doomstat.h" -#include "../s_sound.h" - -#include "../d_main.h" - -#ifdef HW3SOUND -#include "../hardware/hw3dsdrv.h" -#include "../hardware/hw3sound.h" -#include "hwsym_sdl.h" -#endif - -#ifdef HAVE_LIBGME -#include "gme/gme.h" -#endif - -// The number of internal mixing channels, -// the samples calculated for each mixing step, -// the size of the 16bit, 2 hardware channel (stereo) -// mixing buffer, and the samplerate of the raw data. - -// Needed for calling the actual sound output. -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) || defined(GP2X) -#define NUM_CHANNELS MIX_CHANNELS -#else -#define NUM_CHANNELS MIX_CHANNELS*4 -#endif - -#define INDEXOFSFX(x) ((sfxinfo_t *)x - S_sfx) - -#if defined (_WIN32_WCE) || defined (DC) || defined (PSP) -static Uint16 samplecount = 512; //Alam: .5KB samplecount at 11025hz is 46.439909297052154195011337868481ms of buffer -#elif defined(GP2X) -static Uint16 samplecount = 128; -#else -static Uint16 samplecount = 1024; //Alam: 1KB samplecount at 22050hz is 46.439909297052154195011337868481ms of buffer -#endif - -typedef struct chan_struct -{ - // The channel data pointers, start and end. - Uint8 *data; //static unsigned char *channels[NUM_CHANNELS]; - Uint8 *end; //static unsigned char *channelsend[NUM_CHANNELS]; - - // pitch - Uint32 realstep; // The channel step amount... - Uint32 step; //static UINT32 channelstep[NUM_CHANNELS]; - Uint32 stepremainder; //static UINT32 channelstepremainder[NUM_CHANNELS]; - Uint32 samplerate; // ... and a 0.16 bit remainder of last step. - - // Time/gametic that the channel started playing, - // used to determine oldest, which automatically - // has lowest priority. - tic_t starttic; //static INT32 channelstart[NUM_CHANNELS]; - - // The sound handle, determined on registration, - // used to unregister/stop/modify, - INT32 handle; //static INT32 channelhandles[NUM_CHANNELS]; - - // SFX id of the playing sound effect. - void *id; // Used to catch duplicates (like chainsaw). - sfxenum_t sfxid; //static INT32 channelids[NUM_CHANNELS]; - INT32 vol; //the channel volume - INT32 sep; //the channel pan - - // Hardware left and right channel volume lookup. - Sint16* leftvol_lookup; //static INT32 *channelleftvol_lookup[NUM_CHANNELS]; - Sint16* rightvol_lookup; //static INT32 *channelrightvol_lookup[NUM_CHANNELS]; -} chan_t; - -static chan_t channels[NUM_CHANNELS]; - -// Pitch to stepping lookup -static INT32 steptable[256]; - -// Volume lookups. -static Sint16 vol_lookup[128 * 256]; - -UINT8 sound_started = false; -static SDL_mutex *Snd_Mutex = NULL; - -//SDL's Audio -static SDL_AudioSpec audio; - -static SDL_bool musicStarted = SDL_FALSE; -#ifdef HAVE_MIXER -static SDL_mutex *Msc_Mutex = NULL; -/* FIXME: Make this file instance-specific */ -#ifdef _arch_dreamcast -#define MIDI_PATH "/ram" -#elif defined(GP2X) -#define MIDI_PATH "/mnt/sd/srb2" -#define MIDI_PATH2 "/tmp/mnt/sd/srb2" -#else -#define MIDI_PATH srb2home -#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) -#define MIDI_PATH2 "/tmp" -#endif -#endif -#define MIDI_TMPFILE "srb2music" -#define MIDI_TMPFILE2 "srb2wav" -static INT32 musicvol = 62; - -#if SDL_MIXER_VERSION_ATLEAST(1,2,2) -#define MIXER_POS //Mix_FadeInMusicPos in 1.2.2+ -static void SDLCALL I_FinishMusic(void); -static double loopstartDig = 0.0l; -static SDL_bool loopingDig = SDL_FALSE; -static SDL_bool canlooping = SDL_TRUE; -#endif - -#if SDL_MIXER_VERSION_ATLEAST(1,2,7) -#define USE_RWOPS // ok, USE_RWOPS is in here -#if defined (DC) || defined (_WIN32_WCE) || defined (_XBOX) //|| defined(_WIN32) || defined(GP2X) -#undef USE_RWOPS -#endif -#endif - -#if SDL_MIXER_VERSION_ATLEAST(1,2,10) -//#define MIXER_INIT -#endif - -#ifdef USE_RWOPS -static void * Smidi[2] = { NULL, NULL }; -static SDL_bool canuseRW = SDL_TRUE; -#endif -static const char *fmidi[2] = { MIDI_TMPFILE, MIDI_TMPFILE2}; - -static const INT32 MIDIfade = 500; -static const INT32 Digfade = 0; - -static Mix_Music *music[2] = { NULL, NULL }; -#endif - -typedef struct srb2audio_s { - void *userdata; -#ifdef HAVE_LIBGME - Music_Emu *gme_emu; - UINT8 gme_pause; - UINT8 gme_loop; -#endif -} srb2audio_t; - -static srb2audio_t localdata; - -static void Snd_LockAudio(void) //Alam: Lock audio data and uninstall audio callback -{ - if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); - else if (nosound) return; - else if (nomidimusic && nodigimusic -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) SDL_LockAudio(); -#ifdef HAVE_MIXER - else if (musicStarted) Mix_SetPostMix(NULL, NULL); -#endif -} - -static void Snd_UnlockAudio(void) //Alam: Unlock audio data and reinstall audio callback -{ - if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); - else if (nosound) return; - else if (nomidimusic && nodigimusic -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) SDL_UnlockAudio(); -#ifdef HAVE_MIXER - else if (musicStarted) Mix_SetPostMix(audio.callback, audio.userdata); -#endif -} - -static inline Uint16 Snd_LowerRate(Uint16 sr) -{ - if (sr <= audio.freq) // already lowered rate? - return sr; // good then - for (;sr > audio.freq;) // not good? - { // then let see... - if (sr % 2) // can we div by half? - return sr; // no, just use the currect rate - sr /= 2; // we can? wonderful - } // let start over again - if (sr == audio.freq) // did we drop to the desired rate? - return sr; // perfect! but if not - return sr*2; // just keep it just above the output sample rate -} - -#ifdef _MSC_VER -#pragma warning(disable : 4200) -#pragma pack(1) -#endif - -typedef struct -{ - Uint16 header; // 3? - Uint16 samplerate; // 11025+ - Uint16 samples; // number of samples - Uint16 dummy; // 0 - Uint8 data[0]; // data; -} ATTRPACK dssfx_t; - -#ifdef _MSC_VER -#pragma pack() -#pragma warning(default : 4200) -#endif - -// -// This function loads the sound data from the WAD lump, -// for single sound. -// -static void *getsfx(lumpnum_t sfxlump, size_t *len) -{ - dssfx_t *sfx, *paddedsfx; - Uint16 sr , csr; - size_t size = *len; - SDL_AudioCVT sfxcvt; - - sfx = (dssfx_t *)malloc(size); - if (sfx) W_ReadLump(sfxlump, (void *)sfx); - else return NULL; - sr = SHORT(sfx->samplerate); - csr = Snd_LowerRate(sr); - - if (sr > csr && SDL_BuildAudioCVT(&sfxcvt, AUDIO_U8, 1, sr, AUDIO_U8, 1, csr)) - {//Alam: Setup the AudioCVT for the SFX - - sfxcvt.len = (INT32)size-8; //Alam: Chop off the header - sfxcvt.buf = malloc(sfxcvt.len * sfxcvt.len_mult); //Alam: make room - if (sfxcvt.buf) M_Memcpy(sfxcvt.buf, &(sfx->data), sfxcvt.len); //Alam: copy the sfx sample - - if (sfxcvt.buf && SDL_ConvertAudio(&sfxcvt) == 0) //Alam: let convert it! - { - size = sfxcvt.len_cvt + 8; - *len = sfxcvt.len_cvt; - - // Allocate from zone memory. - paddedsfx = (dssfx_t *) Z_Malloc(size, PU_SOUND, NULL); - - // Now copy and pad. - M_Memcpy(paddedsfx->data, sfxcvt.buf, sfxcvt.len_cvt); - free(sfxcvt.buf); - M_Memcpy(paddedsfx,sfx,8); - paddedsfx->samplerate = SHORT(csr); // new freq - } - else //Alam: the convert failed, not needed or I couldn't malloc the buf - { - if (sfxcvt.buf) free(sfxcvt.buf); - *len = size - 8; - - // Allocate from zone memory then copy and pad - paddedsfx = (dssfx_t *)M_Memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); - } - } - else - { - // Pads the sound effect out to the mixing buffer size. - // The original realloc would interfere with zone memory. - *len = size - 8; - - // Allocate from zone memory then copy and pad - paddedsfx = (dssfx_t *)M_Memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); - } - - // Remove the cached lump. - free(sfx); - - // Return allocated padded data. - return paddedsfx; -} - -// used to (re)calculate channel params based on vol, sep, pitch -static void I_SetChannelParams(chan_t *c, INT32 vol, INT32 sep, INT32 step) -{ - INT32 leftvol; - INT32 rightvol; - c->vol = vol; - c->sep = sep; - c->step = c->realstep = step; - - if (step != steptable[128]) - c->step += (((c->samplerate<<16)/audio.freq)-65536); - else if (c->samplerate != (unsigned)audio.freq) - c->step = ((c->samplerate<<16)/audio.freq); - // x^2 separation, that is, orientation/stereo. - // range is: 0 (left) - 255 (right) - - // Volume arrives in range 0..255 and it must be in 0..cv_soundvolume... - vol = (vol * cv_soundvolume.value) >> 7; - // note: >> 6 would use almost the entire dynamical range, but - // then there would be no "dynamical room" for other sounds :-/ - - leftvol = vol - ((vol*sep*sep) >> 16); ///(256*256); - sep = 255 - sep; - rightvol = vol - ((vol*sep*sep) >> 16); - - // Sanity check, clamp volume. - if (rightvol < 0) - rightvol = 0; - else if (rightvol > 127) - rightvol = 127; - if (leftvol < 0) - leftvol = 0; - else if (leftvol > 127) - leftvol = 127; - - // Get the proper lookup table piece - // for this volume level - c->leftvol_lookup = &vol_lookup[leftvol*256]; - c->rightvol_lookup = &vol_lookup[rightvol*256]; -} - -static INT32 FindChannel(INT32 handle) -{ - INT32 i; - - for (i = 0; i < NUM_CHANNELS; i++) - if (channels[i].handle == handle) - return i; - - // not found - return -1; -} - -// -// This function adds a sound to the -// list of currently active sounds, -// which is maintained as a given number -// (eight, usually) of internal channels. -// Returns a handle. -// -static INT32 addsfx(sfxenum_t sfxid, INT32 volume, INT32 step, INT32 seperation) -{ - static UINT16 handlenums = 0; - INT32 i, slot, oldestnum = 0; - tic_t oldest = gametic; - - // Play these sound effects only one at a time. -#if 1 - if ( -#if 0 - sfxid == sfx_stnmov || sfxid == sfx_sawup || sfxid == sfx_sawidl || sfxid == sfx_sawful || sfxid == sfx_sawhit || sfxid == sfx_pistol -#else - ( sfx_litng1 <= sfxid && sfxid >= sfx_litng4 ) - || sfxid == sfx_trfire || sfxid == sfx_alarm || sfxid == sfx_spin - || sfxid == sfx_athun1 || sfxid == sfx_athun2 || sfxid == sfx_rainin -#endif - ) - { - // Loop all channels, check. - for (i = 0; i < NUM_CHANNELS; i++) - { - // Active, and using the same SFX? - if ((channels[i].end) && (channels[i].sfxid == sfxid)) - { - // Reset. - channels[i].end = NULL; - // We are sure that iff, - // there will only be one. - break; - } - } - } -#endif - - // Loop all channels to find oldest SFX. - for (i = 0; (i < NUM_CHANNELS) && (channels[i].end); i++) - { - if (channels[i].starttic < oldest) - { - oldestnum = i; - oldest = channels[i].starttic; - } - } - - // Tales from the cryptic. - // If we found a channel, fine. - // If not, we simply overwrite the first one, 0. - // Probably only happens at startup. - if (i == NUM_CHANNELS) - slot = oldestnum; - else - slot = i; - - channels[slot].end = NULL; - // Okay, in the less recent channel, - // we will handle the new SFX. - // Set pointer to raw data. - channels[slot].data = (Uint8 *)S_sfx[sfxid].data; - channels[slot].samplerate = (channels[slot].data[3]<<8)+channels[slot].data[2]; - channels[slot].data += 8; //Alam: offset of the sound header - - while (FindChannel(handlenums)!=-1) - { - handlenums++; - // Reset current handle number, limited to 0..65535. - if (handlenums == UINT16_MAX) - handlenums = 0; - } - - // Assign current handle number. - // Preserved so sounds could be stopped. - channels[slot].handle = handlenums; - - // Restart steper - channels[slot].stepremainder = 0; - // Should be gametic, I presume. - channels[slot].starttic = gametic; - - I_SetChannelParams(&channels[slot], volume, seperation, step); - - // Preserve sound SFX id, - // e.g. for avoiding duplicates of chainsaw. - channels[slot].id = S_sfx[sfxid].data; - - channels[slot].sfxid = sfxid; - - // Set pointer to end of raw data. - channels[slot].end = channels[slot].data + S_sfx[sfxid].length; - - - // You tell me. - return handlenums; -} - -// -// SFX API -// Note: this was called by S_Init. -// However, whatever they did in the -// old DPMS based DOS version, this -// were simply dummies in the Linux -// version. -// See soundserver initdata(). -// -// Well... To keep compatibility with legacy doom, I have to call this in -// I_InitSound since it is not called in S_Init... (emanne@absysteme.fr) - -static inline void I_SetChannels(void) -{ - // Init internal lookups (raw data, mixing buffer, channels). - // This function sets up internal lookups used during - // the mixing process. - INT32 i; - INT32 j; - - INT32 *steptablemid = steptable + 128; - - if (nosound) - return; - - // This table provides step widths for pitch parameters. - for (i = -128; i < 128; i++) - { - const double po = pow((double)(2.0l), (double)(i / 64.0l)); - steptablemid[i] = (INT32)(po * 65536.0l); - } - - // Generates volume lookup tables - // which also turn the unsigned samples - // into signed samples. - for (i = 0; i < 128; i++) - for (j = 0; j < 256; j++) - { - //From PrDoom - // proff - made this a little bit softer, because with - // full volume the sound clipped badly - vol_lookup[i * 256 + j] = (Sint16)((i * (j - 128) * 256) / 127); - } -} - -void I_SetSfxVolume(UINT8 volume) -{ - INT32 i; - - (void)volume; - //Snd_LockAudio(); - - for (i = 0; i < NUM_CHANNELS; i++) - if (channels[i].end) I_SetChannelParams(&channels[i], channels[i].vol, channels[i].sep, channels[i].realstep); - - //Snd_UnlockAudio(); -} - -void *I_GetSfx(sfxinfo_t *sfx) -{ - if (sfx->lumpnum == LUMPERROR) - sfx->lumpnum = S_GetSfxLumpNum(sfx); -// else if (sfx->lumpnum != S_GetSfxLumpNum(sfx)) -// I_FreeSfx(sfx); - -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - return HW3S_GetSfx(sfx); -#endif - - if (sfx->data) - return sfx->data; //Alam: I have it done! - - sfx->length = W_LumpLength(sfx->lumpnum); - - return getsfx(sfx->lumpnum, &sfx->length); - -} - -void I_FreeSfx(sfxinfo_t * sfx) -{ -// if (sfx->lumpnum<0) -// return; - -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_FreeSfx(sfx); - } - else -#endif - { - size_t i; - - for (i = 1; i < NUMSFX; i++) - { - // Alias? Example is the chaingun sound linked to pistol. - if (S_sfx[i].data == sfx->data) - { - if (S_sfx+i != sfx) S_sfx[i].data = NULL; - S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].length = 0; - } - } - //Snd_LockAudio(); //Alam: too much? - // Loop all channels, check. - for (i = 0; i < NUM_CHANNELS; i++) - { - // Active, and using the same SFX? - if (channels[i].end && channels[i].id == sfx->data) - { - channels[i].end = NULL; // Reset. - } - } - //Snd_UnlockAudio(); //Alam: too much? - Z_Free(sfx->data); - } - sfx->data = NULL; - sfx->lumpnum = LUMPERROR; -} - -// -// Starting a sound means adding it -// to the current list of active sounds -// in the internal channels. -// As the SFX info struct contains -// e.g. a pointer to the raw data, -// it is ignored. -// As our sound handling does not handle -// priority, it is ignored. -// Pitching (that is, increased speed of playback) -// is set, but currently not used by mixing. -// -INT32 I_StartSound(sfxenum_t id, UINT8 vol, UINT8 sep, UINT8 pitch, UINT8 priority, INT32 channel) -{ - (void)priority; - (void)pitch; - (void)channel; - - if (nosound) - return 0; - - if (S_sfx[id].data == NULL) return -1; - - Snd_LockAudio(); - id = addsfx(id, vol, steptable[pitch], sep); - Snd_UnlockAudio(); - - return id; // Returns a handle (not used). -} - -void I_StopSound(INT32 handle) -{ - // You need the handle returned by StartSound. - // Would be looping all channels, - // tracking down the handle, - // an setting the channel to zero. - INT32 i; - - i = FindChannel(handle); - - if (i != -1) - { - //Snd_LockAudio(); //Alam: too much? - channels[i].end = NULL; - //Snd_UnlockAudio(); //Alam: too much? - channels[i].handle = -1; - channels[i].starttic = 0; - } - -} - -boolean I_SoundIsPlaying(INT32 handle) -{ - boolean isplaying = false; - int chan = FindChannel(handle); - if (chan != -1) - isplaying = (channels[chan].end != NULL); - return isplaying; -} - -FUNCINLINE static ATTRINLINE void I_UpdateStream8S(Uint8 *stream, int len) -{ - // Mix current sound data. - // Data, from raw sound - register Sint16 dr; // Right 8bit stream - register Uint8 sample; // Center 8bit sfx - register Sint16 dl; // Left 8bit stream - - // Pointers in audio stream - Sint8 *rightout = (Sint8 *)stream; // currect right - Sint8 *leftout = rightout + 1;// currect left - const Uint8 step = 2; // Step in stream, left and right, thus two. - - INT32 chan; // Mixing channel index. - - // Determine end of the stream - len /= 2; // not 8bit mono samples, 8bit stereo ones - - if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); - - // Mix sounds into the mixing buffer. - // Loop over len - while (len--) - { - // Reset left/right value. - dl = *leftout; - dr = *rightout; - - // Love thy L2 cache - made this a loop. - // Now more channels could be set at compile time - // as well. Thus loop those channels. - for (chan = 0; chan < NUM_CHANNELS; chan++) - { - // Check channel, if active. - if (channels[chan].end) - { -#if 1 - // Get the raw data from the channel. - sample = channels[chan].data[0]; -#else - // linear filtering from PrDoom - sample = (((Uint32)channels[chan].data[0] *(0x10000 - channels[chan].stepremainder)) - + ((Uint32)channels[chan].data[1]) * (channels[chan].stepremainder))) >> 16; -#endif - // Add left and right part - // for this channel (sound) - // to the current data. - // Adjust volume accordingly. - dl = (Sint16)(dl+(channels[chan].leftvol_lookup[sample]>>8)); - dr = (Sint16)(dr+(channels[chan].rightvol_lookup[sample]>>8)); - // Increment stepage - channels[chan].stepremainder += channels[chan].step; - // Check whether we are done. - if (channels[chan].data + (channels[chan].stepremainder >> 16) >= channels[chan].end) - channels[chan].end = NULL; - else - { - // step to next sample - channels[chan].data += (channels[chan].stepremainder >> 16); - // Limit to LSB??? - channels[chan].stepremainder &= 0xffff; - } - } - } - - // Clamp to range. Left hardware channel. - // Has been char instead of short. - - if (dl > 0x7f) - *leftout = 0x7f; - else if (dl < -0x80) - *leftout = -0x80; - else - *leftout = (Sint8)dl; - - // Same for right hardware channel. - if (dr > 0x7f) - *rightout = 0x7f; - else if (dr < -0x80) - *rightout = -0x80; - else - *rightout = (Sint8)dr; - - // Increment current pointers in stream - leftout += step; - rightout += step; - - } - if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); -} - -FUNCINLINE static ATTRINLINE void I_UpdateStream8M(Uint8 *stream, int len) -{ - // Mix current sound data. - // Data, from raw sound - register Sint16 d; // Mono 8bit stream - register Uint8 sample; // Center 8bit sfx - - // Pointers in audio stream - Sint8 *monoout = (Sint8 *)stream; // currect mono - const Uint8 step = 1; // Step in stream, left and right, thus two. - - INT32 chan; // Mixing channel index. - - // Determine end of the stream - //len /= 1; // not 8bit mono samples, 8bit mono ones? - - if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); - - // Mix sounds into the mixing buffer. - // Loop over len - while (len--) - { - // Reset left/right value. - d = *monoout; - - // Love thy L2 cache - made this a loop. - // Now more channels could be set at compile time - // as well. Thus loop those channels. - for (chan = 0; chan < NUM_CHANNELS; chan++) - { - // Check channel, if active. - if (channels[chan].end) - { -#if 1 - // Get the raw data from the channel. - sample = channels[chan].data[0]; -#else - // linear filtering from PrDoom - sample = (((Uint32)channels[chan].data[0] *(0x10000 - channels[chan].stepremainder)) - + ((Uint32)channels[chan].data[1]) * (channels[chan].stepremainder))) >> 16; -#endif - // Add left and right part - // for this channel (sound) - // to the current data. - // Adjust volume accordingly. - d = (Sint16)(d+((channels[chan].leftvol_lookup[sample] + channels[chan].rightvol_lookup[sample])>>9)); - // Increment stepage - channels[chan].stepremainder += channels[chan].step; - // Check whether we are done. - if (channels[chan].data + (channels[chan].stepremainder >> 16) >= channels[chan].end) - channels[chan].end = NULL; - else - { - // step to next sample - channels[chan].data += (channels[chan].stepremainder >> 16); - // Limit to LSB??? - channels[chan].stepremainder &= 0xffff; - } - } - } - - // Clamp to range. Left hardware channel. - // Has been char instead of short. - - if (d > 0x7f) - *monoout = 0x7f; - else if (d < -0x80) - *monoout = -0x80; - else - *monoout = (Sint8)d; - - // Increment current pointers in stream - monoout += step; - } - if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); -} - -FUNCINLINE static ATTRINLINE void I_UpdateStream16S(Uint8 *stream, int len) -{ - // Mix current sound data. - // Data, from raw sound - register Sint32 dr; // Right 16bit stream - register Uint8 sample; // Center 8bit sfx - register Sint32 dl; // Left 16bit stream - - // Pointers in audio stream - Sint16 *rightout = (Sint16 *)(void *)stream; // currect right - Sint16 *leftout = rightout + 1;// currect left - const Uint8 step = 2; // Step in stream, left and right, thus two. - - INT32 chan; // Mixing channel index. - - // Determine end of the stream - len /= 4; // not 8bit mono samples, 16bit stereo ones - - if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); - - // Mix sounds into the mixing buffer. - // Loop over len - while (len--) - { - // Reset left/right value. - dl = *leftout; - dr = *rightout; - - // Love thy L2 cache - made this a loop. - // Now more channels could be set at compile time - // as well. Thus loop those channels. - for (chan = 0; chan < NUM_CHANNELS; chan++) - { - // Check channel, if active. - if (channels[chan].end) - { -#if 1 - // Get the raw data from the channel. - sample = channels[chan].data[0]; -#else - // linear filtering from PrDoom - sample = (((Uint32)channels[chan].data[0] *(0x10000 - channels[chan].stepremainder)) - + ((Uint32)channels[chan].data[1]) * (channels[chan].stepremainder))) >> 16; -#endif - // Add left and right part - // for this channel (sound) - // to the current data. - // Adjust volume accordingly. - dl += channels[chan].leftvol_lookup[sample]; - dr += channels[chan].rightvol_lookup[sample]; - // Increment stepage - channels[chan].stepremainder += channels[chan].step; - // Check whether we are done. - if (channels[chan].data + (channels[chan].stepremainder >> 16) >= channels[chan].end) - channels[chan].end = NULL; - else - { - // step to next sample - channels[chan].data += (channels[chan].stepremainder >> 16); - // Limit to LSB??? - channels[chan].stepremainder &= 0xffff; - } - } - } - - // Clamp to range. Left hardware channel. - // Has been char instead of short. - - if (dl > 0x7fff) - *leftout = 0x7fff; - else if (dl < -0x8000) - *leftout = -0x8000; - else - *leftout = (Sint16)dl; - - // Same for right hardware channel. - if (dr > 0x7fff) - *rightout = 0x7fff; - else if (dr < -0x8000) - *rightout = -0x8000; - else - *rightout = (Sint16)dr; - - // Increment current pointers in stream - leftout += step; - rightout += step; - - } - if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); -} - -FUNCINLINE static ATTRINLINE void I_UpdateStream16M(Uint8 *stream, int len) -{ - // Mix current sound data. - // Data, from raw sound - register Sint32 d; // Mono 16bit stream - register Uint8 sample; // Center 8bit sfx - - // Pointers in audio stream - Sint16 *monoout = (Sint16 *)(void *)stream; // currect mono - const Uint8 step = 1; // Step in stream, left and right, thus two. - - INT32 chan; // Mixing channel index. - - // Determine end of the stream - len /= 2; // not 8bit mono samples, 16bit mono ones - - if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); - - // Mix sounds into the mixing buffer. - // Loop over len - while (len--) - { - // Reset left/right value. - d = *monoout; - - // Love thy L2 cache - made this a loop. - // Now more channels could be set at compile time - // as well. Thus loop those channels. - for (chan = 0; chan < NUM_CHANNELS; chan++) - { - // Check channel, if active. - if (channels[chan].end) - { -#if 1 - // Get the raw data from the channel. - sample = channels[chan].data[0]; -#else - // linear filtering from PrDoom - sample = (((Uint32)channels[chan].data[0] *(0x10000 - channels[chan].stepremainder)) - + ((Uint32)channels[chan].data[1]) * (channels[chan].stepremainder))) >> 16; -#endif - // Add left and right part - // for this channel (sound) - // to the current data. - // Adjust volume accordingly. - d += (channels[chan].leftvol_lookup[sample] + channels[chan].rightvol_lookup[sample])>>1; - // Increment stepage - channels[chan].stepremainder += channels[chan].step; - // Check whether we are done. - if (channels[chan].data + (channels[chan].stepremainder >> 16) >= channels[chan].end) - channels[chan].end = NULL; - else - { - // step to next sample - channels[chan].data += (channels[chan].stepremainder >> 16); - // Limit to LSB??? - channels[chan].stepremainder &= 0xffff; - } - } - } - - // Clamp to range. Left hardware channel. - // Has been char instead of short. - - if (d > 0x7fff) - *monoout = 0x7fff; - else if (d < -0x8000) - *monoout = -0x8000; - else - *monoout = (Sint16)d; - - // Increment current pointers in stream - monoout += step; - } - if (Snd_Mutex) SDL_UnlockMutex(Snd_Mutex); -} - -#ifdef HAVE_LIBGME -static void I_UpdateSteamGME(Music_Emu *emu, INT16 *stream, int len, UINT8 looping) -{ - #define GME_BUFFER_LEN 44100*2048 - // Mix current sound data. - // Data, from raw sound - register Sint32 da; - - static short gme_buffer[GME_BUFFER_LEN]; // a large buffer for gme - Sint16 *in = gme_buffer; - - do - { - int out = min(GME_BUFFER_LEN, len); - if ( gme_play( emu, len, gme_buffer ) ) { } // ignore error - len -= out; - while (out--) - { - //Left - da = *in; - in++; - da += *stream; - stream++; - //Right - da = *in; - in++; - da += *stream; - stream++; - } - if (gme_track_ended( emu )) - { - if (looping) - gme_seek( emu, 0); - else - break; - } - } while ( len ); - #undef GME_BUFFER_LEN -} -#endif - -static void SDLCALL I_UpdateStream(void *userdata, Uint8 *stream, int len) -{ - if (!sound_started || !userdata) - return; - -#if SDL_VERSION_ATLEAST(1,3,0) - if (musicStarted) - memset(stream, 0x00, len); // only work in !AUDIO_U8, that needs 0x80 -#endif - - if ((audio.channels != 1 && audio.channels != 2) || - (audio.format != AUDIO_S8 && audio.format != AUDIO_S16SYS)) - ; // no function to encode this type of stream - else if (audio.channels == 1 && audio.format == AUDIO_S8) - I_UpdateStream8M(stream, len); - else if (audio.channels == 2 && audio.format == AUDIO_S8) - I_UpdateStream8S(stream, len); - else if (audio.channels == 1 && audio.format == AUDIO_S16SYS) - I_UpdateStream16M(stream, len); - else if (audio.channels == 2 && audio.format == AUDIO_S16SYS) - { - I_UpdateStream16S(stream, len); -#ifdef HAVE_LIBGME - if (userdata) - { - srb2audio_t *sa_userdata = userdata; - if (!sa_userdata->gme_pause) - I_UpdateSteamGME(sa_userdata->gme_emu, (INT16 *)stream, len/4, sa_userdata->gme_loop); - } -#endif - - } -} - -void I_UpdateSoundParams(INT32 handle, UINT8 vol, UINT8 sep, UINT8 pitch) -{ - // Would be using the handle to identify - // on which channel the sound might be active, - // and resetting the channel parameters. - - INT32 i = FindChannel(handle); - - if (i != -1 && channels[i].end) - { - //Snd_LockAudio(); //Alam: too much? - I_SetChannelParams(&channels[i], vol, sep, steptable[pitch]); - //Snd_UnlockAudio(); //Alam: too much? - } - -} - -#ifdef HW3SOUND - -static void *soundso = NULL; - -static INT32 Init3DSDriver(const char *soName) -{ - if (soName) soundso = hwOpen(soName); -#if defined (_WIN32) && defined (_X86_) && !defined (STATIC3DS) - HW3DS.pfnStartup = hwSym("Startup@8",soundso); - HW3DS.pfnShutdown = hwSym("Shutdown@0",soundso); - HW3DS.pfnAddSfx = hwSym("AddSfx@4",soundso); - HW3DS.pfnAddSource = hwSym("AddSource@8",soundso); - HW3DS.pfnStartSource = hwSym("StartSource@4",soundso); - HW3DS.pfnStopSource = hwSym("StopSource@4",soundso); - HW3DS.pfnGetHW3DSVersion = hwSym("GetHW3DSVersion@0",soundso); - HW3DS.pfnBeginFrameUpdate = hwSym("BeginFrameUpdate@0",soundso); - HW3DS.pfnEndFrameUpdate = hwSym("EndFrameUpdate@0",soundso); - HW3DS.pfnIsPlaying = hwSym("IsPlaying@4",soundso); - HW3DS.pfnUpdateListener = hwSym("UpdateListener@8",soundso); - HW3DS.pfnUpdateSourceParms = hwSym("UpdateSourceParms@12",soundso); - HW3DS.pfnSetCone = hwSym("SetCone@8",soundso); - HW3DS.pfnSetGlobalSfxVolume = hwSym("SetGlobalSfxVolume@4",soundso); - HW3DS.pfnUpdate3DSource = hwSym("Update3DSource@8",soundso); - HW3DS.pfnReloadSource = hwSym("ReloadSource@8",soundso); - HW3DS.pfnKillSource = hwSym("KillSource@4",soundso); - HW3DS.pfnKillSfx = hwSym("KillSfx@4",soundso); - HW3DS.pfnGetHW3DSTitle = hwSym("GetHW3DSTitle@8",soundso); -#else - HW3DS.pfnStartup = hwSym("Startup",soundso); - HW3DS.pfnShutdown = hwSym("Shutdown",soundso); - HW3DS.pfnAddSfx = hwSym("AddSfx",soundso); - HW3DS.pfnAddSource = hwSym("AddSource",soundso); - HW3DS.pfnStartSource = hwSym("StartSource",soundso); - HW3DS.pfnStopSource = hwSym("StopSource",soundso); - HW3DS.pfnGetHW3DSVersion = hwSym("GetHW3DSVersion",soundso); - HW3DS.pfnBeginFrameUpdate = hwSym("BeginFrameUpdate",soundso); - HW3DS.pfnEndFrameUpdate = hwSym("EndFrameUpdate",soundso); - HW3DS.pfnIsPlaying = hwSym("IsPlaying",soundso); - HW3DS.pfnUpdateListener = hwSym("UpdateListener",soundso); - HW3DS.pfnUpdateSourceParms = hwSym("UpdateSourceParms",soundso); - HW3DS.pfnSetCone = hwSym("SetCone",soundso); - HW3DS.pfnSetGlobalSfxVolume = hwSym("SetGlobalSfxVolume",soundso); - HW3DS.pfnUpdate3DSource = hwSym("Update3DSource",soundso); - HW3DS.pfnReloadSource = hwSym("ReloadSource",soundso); - HW3DS.pfnKillSource = hwSym("KillSource",soundso); - HW3DS.pfnKillSfx = hwSym("KillSfx",soundso); - HW3DS.pfnGetHW3DSTitle = hwSym("GetHW3DSTitle",soundso); -#endif - -// if (HW3DS.pfnUpdateListener2 && HW3DS.pfnUpdateListener2 != soundso) - return true; -// else -// return false; -} -#endif - -void I_ShutdownSound(void) -{ - if (nosound || !sound_started) - return; - - CONS_Printf("I_ShutdownSound: "); - -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_Shutdown(); - hwClose(soundso); - return; - } -#endif - - if (nomidimusic && nodigimusic) - SDL_CloseAudio(); - CONS_Printf("%s", M_GetText("shut down\n")); - sound_started = false; - SDL_QuitSubSystem(SDL_INIT_AUDIO); - if (Snd_Mutex) - SDL_DestroyMutex(Snd_Mutex); - Snd_Mutex = NULL; -} - -void I_UpdateSound(void) -{ -} - -void I_StartupSound(void) -{ -#ifdef HW3SOUND - const char *sdrv_name = NULL; -#endif -#ifndef HAVE_MIXER - nomidimusic = nodigimusic = true; -#endif -#ifdef DC - //nosound = true; -#ifdef HAVE_MIXER - nomidimusic = true; - nodigimusic = true; -#endif -#endif - - memset(channels, 0, sizeof (channels)); //Alam: Clean it - - audio.format = AUDIO_S16SYS; - audio.channels = 2; - audio.callback = I_UpdateStream; - audio.userdata = &localdata; - - if (dedicated) - { - nosound = nomidimusic = nodigimusic = true; - return; - } - - // Configure sound device - CONS_Printf("I_StartupSound:\n"); - - // Open the audio device - if (M_CheckParm ("-freq") && M_IsNextParm()) - { - audio.freq = atoi(M_GetNextParm()); - if (!audio.freq) audio.freq = cv_samplerate.value; - audio.samples = (Uint16)((samplecount/2)*(INT32)(audio.freq/11025)); //Alam: to keep it around the same XX ms - CONS_Printf (M_GetText(" requested frequency of %d hz\n"), audio.freq); - } - else - { - audio.samples = samplecount; - audio.freq = cv_samplerate.value; - } - - if (M_CheckParm ("-mono")) - { - audio.channels = 1; - audio.samples /= 2; - } - -#if defined (_PSP) && defined (HAVE_MIXER) // Bug in PSP's SDL_OpenAudio, can not open twice - I_SetChannels(); - sound_started = true; - Snd_Mutex = SDL_CreateMutex(); -#else - if (nosound) -#endif - return; - -#ifdef HW3SOUND -#ifdef STATIC3DS - if (M_CheckParm("-3dsound") || M_CheckParm("-ds3d")) - { - hws_mode = HWS_OPENAL; - } -#elif defined (_WIN32) - if (M_CheckParm("-ds3d")) - { - hws_mode = HWS_DS3D; - sdrv_name = "s_ds3d.dll"; - } - else if (M_CheckParm("-fmod3d")) - { - hws_mode = HWS_FMOD3D; - sdrv_name = "s_fmod.dll"; - } - else if (M_CheckParm("-openal")) - { - hws_mode = HWS_OPENAL; - sdrv_name = "s_openal.dll"; - } -#else - if (M_CheckParm("-fmod3d")) - { - hws_mode = HWS_FMOD3D; - sdrv_name = "./s_fmod.so"; - } - else if (M_CheckParm("-openal")) - { - hws_mode = HWS_OPENAL; - sdrv_name = "./s_openal.so"; - } -#endif - else if (M_CheckParm("-sounddriver") && M_IsNextParm()) - { - hws_mode = HWS_OTHER; - sdrv_name = M_GetNextParm(); - } - if (hws_mode != HWS_DEFAULT_MODE) - { - if (Init3DSDriver(sdrv_name)) - { - snddev_t snddev; - - //nosound = true; - //I_AddExitFunc(I_ShutdownSound); - snddev.bps = 16; - snddev.sample_rate = audio.freq; - snddev.numsfxs = NUMSFX; -#if defined (_WIN32) && !defined (_XBOX) - snddev.cooplevel = 0x00000002; - snddev.hWnd = vid.WndParent; -#endif - if (HW3S_Init(I_Error, &snddev)) - { - audio.userdata = NULL; - CONS_Printf("%s", M_GetText(" Using 3D sound driver\n")); - return; - } - CONS_Printf("%s", M_GetText(" Failed loading 3D sound driver\n")); - // Falls back to default sound system - HW3S_Shutdown(); - hwClose(soundso); - } - CONS_Printf("%s", M_GetText(" Failed loading 3D sound driver\n")); - hws_mode = HWS_DEFAULT_MODE; - } -#endif - if (!musicStarted && SDL_OpenAudio(&audio, &audio) < 0) - { - CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n")); - nosound = true; - return; - } - else - { - char ad[100]; - CONS_Printf(M_GetText(" Starting up with audio driver : %s\n"), SDL_AudioDriverName(ad, (int)sizeof ad)); - } - samplecount = audio.samples; - CV_SetValue(&cv_samplerate, audio.freq); - CONS_Printf(M_GetText(" configured audio device with %d samples/slice at %ikhz(%dms buffer)\n"), samplecount, audio.freq/1000, (INT32) (((float)audio.samples * 1000.0f) / audio.freq)); - // Finished initialization. - CONS_Printf("%s", M_GetText(" Sound module ready\n")); - //[segabor] - if (!musicStarted) SDL_PauseAudio(0); - //Mix_Pause(0); - I_SetChannels(); - sound_started = true; - Snd_Mutex = SDL_CreateMutex(); -} - -// -// MUSIC API. -// - -void I_ShutdownMIDIMusic(void) -{ - nomidimusic = false; - if (nodigimusic) I_ShutdownMusic(); -} - -#ifdef HAVE_LIBGME -static void I_ShutdownGMEMusic(void) -{ - Snd_LockAudio(); - if (localdata.gme_emu) - gme_delete(localdata.gme_emu); - localdata.gme_emu = NULL; - Snd_UnlockAudio(); -} -#endif - -void I_ShutdownDigMusic(void) -{ - nodigimusic = false; - if (nomidimusic) I_ShutdownMusic(); -} - -#ifdef HAVE_MIXER -static boolean LoadSong(void *data, size_t lumplength, size_t selectpos) -{ - FILE *midfile; - const char *tempname; -#ifdef USE_RWOPS - if (canuseRW) - { - SDL_RWops *SDLRW; - void *olddata = Smidi[selectpos]; //quick shortcut to set - - Z_Free(olddata); //free old memory - Smidi[selectpos] = NULL; - - if (!data) - return olddata != NULL; //was there old data? - - SDLRW = SDL_RWFromConstMem(data, (int)lumplength); //new RWops from Z_zone - if (!SDLRW) //ERROR while making RWops! - { - CONS_Printf(M_GetText("Couldn't load music lump: %s\n"), SDL_GetError()); - Z_Free(data); - return false; - } - - music[selectpos] = Mix_LoadMUS_RW(SDLRW); // new Mix_Chuck from RWops - if (music[selectpos]) - Smidi[selectpos] = data; //all done - else //ERROR while making Mix_Chuck - { - CONS_Printf(M_GetText("Couldn't load music data: %s\n"), Mix_GetError()); - Z_Free(data); - SDL_RWclose(SDLRW); - Smidi[selectpos] = NULL; - } - return true; - } -#endif - tempname = va("%s/%s", MIDI_PATH, fmidi[selectpos]); - - if (!data) - { - if (FIL_FileExists(tempname)) - return unlink(tempname)+1; -#ifdef MIDI_PATH2 - else if (FIL_FileExists(tempname = va("%s/%s", MIDI_PATH2, fmidi[selectpos]))) - return unlink(tempname)+1; -#endif - else - return false; - } - - midfile = fopen(tempname, "wb"); - -#ifdef MIDI_PATH2 - if (!midfile) - { - tempname = va("%s/%s", MIDI_PATH2, fmidi[selectpos]); - midfile = fopen(tempname, "wb"); - } -#endif - - if (!midfile) - { - CONS_Printf(M_GetText("Couldn't open file %s to write music in\n"), tempname); - Z_Free(data); - return false; - } - - if (fwrite(data, lumplength, 1, midfile) == 0) - { - CONS_Printf(M_GetText("Couldn't write music into file %s because %s\n"), tempname, strerror(ferror(midfile))); - Z_Free(data); - fclose(midfile); - return false; - } - - fclose(midfile); - - Z_Free(data); - - music[selectpos] = Mix_LoadMUS(tempname); - if (!music[selectpos]) //ERROR while making Mix_Chuck - { - CONS_Printf(M_GetText("Couldn't load music file %s: %s\n"), tempname, Mix_GetError()); - return false; - } - return true; -} -#endif - - -void I_ShutdownMusic(void) -{ -#ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) - return; - - CONS_Printf("%s", M_GetText("I_ShutdownMusic: ")); - - I_UnRegisterSong(0); - I_StopDigSong(); - Mix_CloseAudio(); -#ifdef MIX_INIT - Mix_Quit(); -#endif - CONS_Printf("%s", M_GetText("shut down\n")); - musicStarted = SDL_FALSE; - if (Msc_Mutex) - SDL_DestroyMutex(Msc_Mutex); - Msc_Mutex = NULL; -#endif -} - -void I_InitMIDIMusic(void) -{ - if (nodigimusic) I_InitMusic(); -} - -void I_InitDigMusic(void) -{ - if (nomidimusic) I_InitMusic(); -} - -void I_InitMusic(void) -{ -#ifdef HAVE_MIXER - char ad[100]; - SDL_version MIXcompiled; - const SDL_version *MIXlinked; -#ifdef MIXER_INIT - const int mixstart = MIX_INIT_OGG; - int mixflags; -#endif -#endif -#ifdef HAVE_LIBGME - I_AddExitFunc(I_ShutdownGMEMusic); -#endif - - if ((nomidimusic && nodigimusic) || dedicated) - return; - -#ifdef HAVE_MIXER - MIX_VERSION(&MIXcompiled) - MIXlinked = Mix_Linked_Version(); - I_OutputMsg("Compiled for SDL_mixer version: %d.%d.%d\n", - MIXcompiled.major, MIXcompiled.minor, MIXcompiled.patch); -#ifdef MIXER_POS -#ifndef _WII - if (MIXlinked->major == 1 && MIXlinked->minor == 2 && MIXlinked->patch < 7) -#endif - canlooping = SDL_FALSE; -#endif -#ifdef USE_RWOPS - if (M_CheckParm("-noRW")) - canuseRW = SDL_FALSE; -#endif - I_OutputMsg("Linked with SDL_mixer version: %d.%d.%d\n", - MIXlinked->major, MIXlinked->minor, MIXlinked->patch); -#if !(defined (DC) || defined (PSP) || defined(GP2X) || defined (WII)) - if (audio.freq < 44100 && !M_CheckParm ("-freq")) //I want atleast 44Khz - { - audio.samples = (Uint16)(audio.samples*(INT32)(44100/audio.freq)); - audio.freq = 44100; //Alam: to keep it around the same XX ms - } -#endif - - if (sound_started -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) - { - I_OutputMsg("Temp Shutdown of SDL Audio System"); - SDL_CloseAudio(); - I_OutputMsg(" Done\n"); - } - - CONS_Printf("%s", M_GetText("I_InitMusic:")); - -#ifdef MIXER_INIT - mixflags = Mix_Init(mixstart); - if ((mixstart & MIX_INIT_FLAC) != (mixflags & MIX_INIT_FLAC)) - { - CONS_Printf("%s", M_GetText(" Unable to load FLAC support\n")); - } - if ((mixstart & MIX_INIT_MOD ) != (mixflags & MIX_INIT_MOD )) - { - CONS_Printf("%s", M_GetText(" Unable to load MOD support\n")); - } - if ((mixstart & MIX_INIT_MP3 ) != (mixflags & MIX_INIT_MP3 )) - { - CONS_Printf("%s", M_GetText(" Unable to load MP3 support\n")); - } - if ((mixstart & MIX_INIT_OGG ) != (mixflags & MIX_INIT_OGG )) - { - CONS_Printf("%s", M_GetText(" Unable to load OGG support\n")); - } -#endif - - if (Mix_OpenAudio(audio.freq, audio.format, audio.channels, audio.samples) < 0) //open_music(&audio) - { - CONS_Printf(M_GetText(" Unable to open music: %s\n"), Mix_GetError()); - nomidimusic = nodigimusic = true; - if (sound_started -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) - { - if (SDL_OpenAudio(&audio, NULL) < 0) //retry - { - CONS_Printf("%s", M_GetText(" couldn't open audio with desired format\n")); - nosound = true; - sound_started = false; - } - else - { - CONS_Printf(M_GetText(" Starting with audio driver : %s\n"), SDL_AudioDriverName(ad, (int)sizeof ad)); - } - } - return; - } - else - CONS_Printf(M_GetText(" Starting up with audio driver : %s with SDL_Mixer\n"), SDL_AudioDriverName(ad, (int)sizeof ad)); - - samplecount = audio.samples; - CV_SetValue(&cv_samplerate, audio.freq); - if (sound_started -#ifdef HW3SOUND - && hws_mode == HWS_DEFAULT_MODE -#endif - ) - I_OutputMsg(" Reconfigured SDL Audio System"); - else I_OutputMsg(" Configured SDL_Mixer System"); - I_OutputMsg(" with %d samples/slice at %ikhz(%dms buffer)\n", samplecount, audio.freq/1000, (INT32) ((audio.samples * 1000.0f) / audio.freq)); - Mix_SetPostMix(audio.callback, audio.userdata); // after mixing music, add sound effects - Mix_Resume(-1); - CONS_Printf("%s", M_GetText("Music initialized\n")); - musicStarted = SDL_TRUE; - Msc_Mutex = SDL_CreateMutex(); -#endif -} - -boolean I_PlaySong(INT32 handle, boolean looping) -{ - (void)handle; -#ifdef HAVE_MIXER - if (nomidimusic || !musicStarted || !music[handle]) - return false; - -#ifdef MIXER_POS - if (canlooping) - Mix_HookMusicFinished(NULL); -#endif - - if (Mix_FadeInMusic(music[handle], looping ? -1 : 0, MIDIfade) == -1) - CONS_Printf(M_GetText("Couldn't play song because %s\n"), Mix_GetError()); - else - { - Mix_VolumeMusic(musicvol); - return true; - } -#else - (void)looping; -#endif - return false; -} - -static void I_PauseGME(void) -{ -#ifdef HAVE_LIBGME - localdata.gme_pause = true; -#endif -} - -void I_PauseSong(INT32 handle) -{ - (void)handle; - I_PauseGME(); -#ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) - return; - - Mix_PauseMusic(); - //I_StopSong(handle); -#endif -} - -static void I_ResumeGME(void) -{ -#ifdef HAVE_LIBGME - localdata.gme_pause = false; -#endif -} - -void I_ResumeSong(INT32 handle) -{ - (void)handle; - I_ResumeGME(); -#ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) - return; - - Mix_VolumeMusic(musicvol); - Mix_ResumeMusic(); - //I_PlaySong(handle, true); -#endif -} - -void I_StopSong(INT32 handle) -{ - (void)handle; -#ifdef HAVE_MIXER - if (nomidimusic || !musicStarted) - return; - Mix_FadeOutMusic(MIDIfade); -#endif -} - -void I_UnRegisterSong(INT32 handle) -{ -#ifdef HAVE_MIXER - - if (nomidimusic || !musicStarted) - return; - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[handle]) - Mix_FreeMusic(music[handle]); - music[handle] = NULL; - LoadSong(NULL, 0, handle); -#else - (void)handle; -#endif -} - -INT32 I_RegisterSong(void *data, size_t len) -{ -#ifdef HAVE_MIXER - if (nomidimusic || !musicStarted) - return false; - - if (!LoadSong(data, len, 0)) - return false; - - if (music[0]) - return true; - - CONS_Printf(M_GetText("Couldn't load MIDI: %s\n"), Mix_GetError()); -#else - (void)len; - (void)data; -#endif - return false; -} - -void I_SetMIDIMusicVolume(UINT8 volume) -{ -#ifdef HAVE_MIXER - if ((nomidimusic && nodigimusic) || !musicStarted) - return; - - if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); - musicvol = volume * 2; - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - Mix_VolumeMusic(musicvol); -#else - (void)volume; -#endif -} - -#ifdef HAVE_LIBGME -static void I_CleanupGME(void *userdata) -{ - Z_Free(userdata); -} -#endif - -static boolean I_StartGMESong(const char *musicname, boolean looping) -{ -#ifdef HAVE_LIBGME - XBOXSTATIC char filename[9]; - void *data; - lumpnum_t lumpnum; - size_t lumplength; - Music_Emu *emu; - const char* gme_err; - - Snd_LockAudio(); - if (localdata.gme_emu) - gme_delete(localdata.gme_emu); - localdata.gme_emu = NULL; - Snd_UnlockAudio(); - - snprintf(filename, sizeof filename, "o_%s", musicname); - - lumpnum = W_CheckNumForName(filename); - - if (lumpnum == LUMPERROR) - { - return false; // No music found. Oh well! - } - else - lumplength = W_LumpLength(lumpnum); - - data = W_CacheLumpNum(lumpnum, PU_MUSIC); - - gme_err = gme_open_data(data, (long)lumplength, &emu, audio.freq); - if (gme_err != NULL) { - //I_OutputMsg("I_StartGMESong: error %s\n",gme_err); - return false; - } - gme_set_user_data(emu, data); - gme_set_user_cleanup(emu, I_CleanupGME); - gme_start_track(emu, 0); - gme_set_fade(emu, Digfade); - - Snd_LockAudio(); - localdata.gme_emu = emu; - localdata.gme_pause = false; - localdata.gme_loop = (UINT8)looping; - Snd_UnlockAudio(); - - return true; -#else - (void)musicname; - (void)looping; -#endif - return false; -} - -boolean I_StartDigSong(const char *musicname, boolean looping) -{ -#ifdef HAVE_MIXER - XBOXSTATIC char filename[9]; - void *data; - lumpnum_t lumpnum; - size_t lumplength; -#endif - - if(I_StartGMESong(musicname, looping)) - return true; - -#ifdef HAVE_MIXER - if (nodigimusic) - return false; - - snprintf(filename, sizeof filename, "o_%s", musicname); - - lumpnum = W_CheckNumForName(filename); - - I_StopDigSong(); - - if (lumpnum == LUMPERROR) - { - // Alam_GBC: like in win32/win_snd.c: Graue 02-29-2004: don't worry about missing music, there might still be a MIDI - //I_OutputMsg("Music lump %s not found!\n", filename); - return false; // No music found. Oh well! - } - else - lumplength = W_LumpLength(lumpnum); - - data = W_CacheLumpNum(lumpnum, PU_MUSIC); - - if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); - -#ifdef MIXER_POS - if (canlooping && (loopingDig = looping) == SDL_TRUE && strcmp(data, "OggS") == 0) - looping = false; // Only on looping Ogg files, will we will do our own looping - - // Scan the Ogg Vorbis file for the COMMENT= field for a custom - // loop point - if (!looping && loopingDig) - { - size_t scan; - const char *dataum = data; - XBOXSTATIC char looplength[64]; - UINT32 loopstart = 0; - UINT8 newcount = 0; - - Mix_HookMusicFinished(I_FinishMusic); - - for (scan = 0; scan < lumplength; scan++) - { - if (*dataum++ == 'C'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'M'){ - if (*dataum++ == 'M'){ - if (*dataum++ == 'E'){ - if (*dataum++ == 'N'){ - if (*dataum++ == 'T'){ - if (*dataum++ == '='){ - if (*dataum++ == 'L'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'P'){ - if (*dataum++ == 'P'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'I'){ - if (*dataum++ == 'N'){ - if (*dataum++ == 'T'){ - if (*dataum++ == '=') - { - - while (*dataum != 1 && newcount != 63) - looplength[newcount++] = *dataum++; - - looplength[newcount] = '\0'; - - loopstart = atoi(looplength); - - } - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - } - - if (loopstart > 0) - { - loopstartDig = (double)((44.1l+loopstart) / 44100.0l); //8 PCM chucks off and PCM to secs -//#ifdef GP2X//#ifdef PARANOIA - //I_OutputMsg("I_StartDigSong: setting looping point to %ul PCMs(%f seconds)\n", loopstart, loopstartDig); -//#endif - } - else - { - looping = true; // loopingDig true, but couldn't find start loop point - } - } - else - loopstartDig = 0.0l; -#else - if (looping && strcmp(data, "OggS") == 0) - I_OutputMsg("I_StartDigSong: SRB2 was not compiled with looping music support(no Mix_FadeInMusicPos)\n"); -#endif - - if (!LoadSong(data, lumplength, 1)) - { - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - return false; - } - - // Note: LoadSong() frees the data. Let's make sure - // we don't try to use the data again. - data = NULL; - - if (Mix_FadeInMusic(music[1], looping ? -1 : 0, Digfade) == -1) - { - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - I_OutputMsg("I_StartDigSong: Couldn't play song %s because %s\n", musicname, Mix_GetError()); - return false; - } - Mix_VolumeMusic(musicvol); - - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); - return true; -#else - (void)looping; - (void)musicname; - return false; -#endif -} - -static void I_StopGME(void) -{ -#ifdef HAVE_LIBGME - Snd_LockAudio(); - gme_seek(localdata.gme_emu, 0); - Snd_UnlockAudio(); -#endif -} - -void I_StopDigSong(void) -{ - I_StopGME(); -#ifdef HAVE_MIXER - if (nodigimusic) - return; - -#ifdef MIXER_POS - if (canlooping) - Mix_HookMusicFinished(NULL); -#endif - - Mix_HaltMusic(); - while (Mix_PlayingMusic()) - ; - - if (music[1]) - Mix_FreeMusic(music[1]); - music[1] = NULL; - LoadSong(NULL, 0, 1); -#endif -} - -void I_SetDigMusicVolume(UINT8 volume) -{ - I_SetMIDIMusicVolume(volume); -} - -boolean I_SetSongSpeed(float speed) -{ - - (void)speed; - return false; -} - -boolean I_SetSongTrack(int track) -{ - (void)track; - return false; -} - -#ifdef MIXER_POS -static void SDLCALL I_FinishMusic(void) -{ - if (!music[1]) - return; - else if (Msc_Mutex) SDL_LockMutex(Msc_Mutex); -// I_OutputMsg("I_FinishMusic: Loopping song to %g seconds\n", loopstartDig); - - if (Mix_FadeInMusicPos(music[1], loopstartDig ? 0 : -1, Digfade, loopstartDig) == 0) - Mix_VolumeMusic(musicvol); - else - I_OutputMsg("I_FinishMusic: Couldn't loop song because %s\n", Mix_GetError()); - - if (Msc_Mutex) SDL_UnlockMutex(Msc_Mutex); -} -#endif -#endif //HAVE_SDL diff --git a/src/sdl12/sdlmain.h b/src/sdl12/sdlmain.h deleted file mode 100644 index d08236bdd..000000000 --- a/src/sdl12/sdlmain.h +++ /dev/null @@ -1,65 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 2006-2018 by Sonic Team Jr. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief System specific interface stuff. - -#ifndef __sdlmain__ -#define __sdlmain__ - -extern SDL_bool consolevent; -extern SDL_bool framebuffer; - -/** \brief The JoyInfo_s struct - - info about joystick -*/ -typedef struct SDLJoyInfo_s -{ - /// Joystick handle - SDL_Joystick *dev; - /// number of old joystick - int oldjoy; - /// number of axies - int axises; - /// scale of axises - INT32 scale; - /// number of buttons - int buttons; - /// number of hats - int hats; - /// number of balls - int balls; - -} SDLJoyInfo_t; - -/** \brief SDL info about joystick 1 -*/ -extern SDLJoyInfo_t JoyInfo; - -/** \brief joystick axis deadzone -*/ -#define SDL_JDEADZONE 153 -#undef SDL_JDEADZONE - -/** \brief SDL inof about joystick 2 -*/ -extern SDLJoyInfo_t JoyInfo2; - -void I_GetConsoleEvents(void); - -void SDLforceUngrabMouse(void); - -#endif diff --git a/src/sdl12/srb2.ttf b/src/sdl12/srb2.ttf deleted file mode 100644 index 53f4c6a28..000000000 Binary files a/src/sdl12/srb2.ttf and /dev/null differ diff --git a/src/sounds.c b/src/sounds.c index 47dc28178..ca943c2d0 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,7 +15,7 @@ #include "i_sound.h" #include "sounds.h" #include "r_defs.h" -#include "r_things.h" +#include "r_skins.h" #include "z_zone.h" #include "w_wad.h" #include "lua_script.h" @@ -32,439 +32,795 @@ sfxinfo_t S_sfx[NUMSFX] = various flags. See soundflags_t. *****/ // S_sfx[0] needs to be a dummy for odd reasons. (don't modify this comment) -// name, singularity, priority, pitch, volume, data, length, skinsound, usefulness, lumpnum - {"none" , false, 0, 0, -1, NULL, 0, -1, -1, LUMPERROR}, +// name, singularity, priority, pitch, volume, data, length, skinsound, usefulness, lumpnum, caption + {"none" , false, 0, 0, -1, NULL, 0, -1, -1, LUMPERROR, "///////////////////////////////"}, // maximum length + + // A HUMBLE REQUEST FROM YOUR FRIENDLY NEIGHBORHOOD toaster! + // + // If you see a caption that's just "" (shows the lumpname in-game), + // and you intend to use the sound associated with it in a mod, + // PLEASE give it a caption through SOC or Lua. + // + // If the first character of the caption is '/', no caption will be + // produced; only do this for "unimportant" sounds that aren't used + // to indicate gameplay. + // + // (to whomstever updates the sounds list wiki page for 2.2, please + // either copy this comment across, or make sure its desire is + // codified in the initial paragraph of the page.) + // + // Closed Captioning may be a niche feature, but it's an important one. + // Thank you! ^u^ // Skin Sounds - {"altdi1", false, 192, 16, -1, NULL, 0, SKSPLDET1, -1, LUMPERROR}, - {"altdi2", false, 192, 16, -1, NULL, 0, SKSPLDET2, -1, LUMPERROR}, - {"altdi3", false, 192, 16, -1, NULL, 0, SKSPLDET3, -1, LUMPERROR}, - {"altdi4", false, 192, 16, -1, NULL, 0, SKSPLDET4, -1, LUMPERROR}, - {"altow1", false, 192, 16, -1, NULL, 0, SKSPLPAN1, -1, LUMPERROR}, - {"altow2", false, 192, 16, -1, NULL, 0, SKSPLPAN2, -1, LUMPERROR}, - {"altow3", false, 192, 16, -1, NULL, 0, SKSPLPAN3, -1, LUMPERROR}, - {"altow4", false, 192, 16, -1, NULL, 0, SKSPLPAN4, -1, LUMPERROR}, - {"victr1", false, 64, 16, -1, NULL, 0, SKSPLVCT1, -1, LUMPERROR}, - {"victr2", false, 64, 16, -1, NULL, 0, SKSPLVCT2, -1, LUMPERROR}, - {"victr3", false, 64, 16, -1, NULL, 0, SKSPLVCT3, -1, LUMPERROR}, - {"victr4", false, 64, 16, -1, NULL, 0, SKSPLVCT4, -1, LUMPERROR}, - {"gasp" , false, 64, 0, -1, NULL, 0, SKSGASP, -1, LUMPERROR}, - {"jump" , false, 140, 0, -1, NULL, 0, SKSJUMP, -1, LUMPERROR}, - {"pudpud", false, 64, 0, -1, NULL, 0, SKSPUDPUD, -1, LUMPERROR}, - {"putput", false, 64, 0, -1, NULL, 0, SKSPUTPUT, -1, LUMPERROR}, // not as high a priority - {"spin" , false, 100, 0, -1, NULL, 0, SKSSPIN, -1, LUMPERROR}, - {"spndsh", false, 64, 1, -1, NULL, 0, SKSSPNDSH, -1, LUMPERROR}, - {"thok" , false, 96, 0, -1, NULL, 0, SKSTHOK, -1, LUMPERROR}, - {"zoom" , false, 120, 1, -1, NULL, 0, SKSZOOM, -1, LUMPERROR}, - {"skid", false, 64, 32, -1, NULL, 0, SKSSKID, -1, LUMPERROR}, + {"altdi1", false, 192, 16, -1, NULL, 0, SKSPLDET1, -1, LUMPERROR, "Dying"}, + {"altdi2", false, 192, 16, -1, NULL, 0, SKSPLDET2, -1, LUMPERROR, "Dying"}, + {"altdi3", false, 192, 16, -1, NULL, 0, SKSPLDET3, -1, LUMPERROR, "Dying"}, + {"altdi4", false, 192, 16, -1, NULL, 0, SKSPLDET4, -1, LUMPERROR, "Dying"}, + {"altow1", false, 192, 16, -1, NULL, 0, SKSPLPAN1, -1, LUMPERROR, "Ring loss"}, + {"altow2", false, 192, 16, -1, NULL, 0, SKSPLPAN2, -1, LUMPERROR, "Ring loss"}, + {"altow3", false, 192, 16, -1, NULL, 0, SKSPLPAN3, -1, LUMPERROR, "Ring loss"}, + {"altow4", false, 192, 16, -1, NULL, 0, SKSPLPAN4, -1, LUMPERROR, "Ring loss"}, + {"victr1", false, 64, 16, -1, NULL, 0, SKSPLVCT1, -1, LUMPERROR, "/"}, + {"victr2", false, 64, 16, -1, NULL, 0, SKSPLVCT2, -1, LUMPERROR, "/"}, + {"victr3", false, 64, 16, -1, NULL, 0, SKSPLVCT3, -1, LUMPERROR, "/"}, + {"victr4", false, 64, 16, -1, NULL, 0, SKSPLVCT4, -1, LUMPERROR, "/"}, + {"gasp" , false, 64, 0, -1, NULL, 0, SKSGASP, -1, LUMPERROR, "Bubble gasp"}, + {"jump" , false, 140, 0, -1, NULL, 0, SKSJUMP, -1, LUMPERROR, "Jump"}, + {"pudpud", false, 64, 0, -1, NULL, 0, SKSPUDPUD, -1, LUMPERROR, "Tired flight"}, + {"putput", false, 64, 0, -1, NULL, 0, SKSPUTPUT, -1, LUMPERROR, "Flight"}, // not as high a priority + {"spin" , false, 100, 0, -1, NULL, 0, SKSSPIN, -1, LUMPERROR, "Spin"}, + {"spndsh", false, 64, 1, -1, NULL, 0, SKSSPNDSH, -1, LUMPERROR, "Spindash"}, + {"thok" , false, 96, 0, -1, NULL, 0, SKSTHOK, -1, LUMPERROR, "Thok"}, + {"zoom" , false, 120, 1, -1, NULL, 0, SKSZOOM, -1, LUMPERROR, "Spin launch"}, + {"skid", false, 64, 32, -1, NULL, 0, SKSSKID, -1, LUMPERROR, "Skid"}, // Ambience/background objects/etc - {"ambint", true, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"ambint", true, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Obnoxious disco music"}, - {"alarm", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"buzz1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"buzz2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"buzz3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"buzz4", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"crumbl", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Platform Crumble Tails 03-16-2001 - {"fire", false, 8, 32, -1, NULL, 0, -1, -1, LUMPERROR}, - {"grind", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"laser", true, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mswing", false, 16, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"pstart", false, 100, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"pstop", false, 100, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"steam1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Tails 06-19-2001 - {"steam2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Tails 06-19-2001 - {"wbreak", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"alarm", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Alarm"}, + {"buzz1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Electric zap"}, + {"buzz2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Electric zap"}, + {"buzz3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Wacky worksurface"}, + {"buzz4", true, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Buzz"}, + {"crumbl", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crumbling"}, // Platform Crumble Tails 03-16-2001 + {"fire", false, 8, 32, -1, NULL, 0, -1, -1, LUMPERROR, "Flamethrower"}, + {"grind", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Metallic grinding"}, + {"laser", true, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Laser hum"}, + {"mswing", false, 16, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Swinging mace"}, + {"pstart", false, 100, 0, -1, NULL, 0, -1, -1, LUMPERROR, "/"}, + {"pstop", false, 100, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crusher stomp"}, + {"steam1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Steam jet"}, // Tails 06-19-2001 + {"steam2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Steam jet"}, // Tails 06-19-2001 + {"wbreak", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Wood breaking"}, + {"ambmac", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Machinery"}, + {"spsmsh", true, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy impact"}, - {"rainin", true, 24, 4, -1, NULL, 0, -1, -1, LUMPERROR}, - {"litng1", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"litng2", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"litng3", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"litng4", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"athun1", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"athun2", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR}, + {"rainin", true, 24, 4, -1, NULL, 0, -1, -1, LUMPERROR, "Rain"}, + {"litng1", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Lightning"}, + {"litng2", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Lightning"}, + {"litng3", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Lightning"}, + {"litng4", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Lightning"}, + {"athun1", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Thunder"}, + {"athun2", false, 16, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Thunder"}, - {"amwtr1", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr2", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr3", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr4", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr5", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr6", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr7", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"amwtr8", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bubbl1", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bubbl2", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bubbl3", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bubbl4", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bubbl5", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"floush", false, 16, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"splash", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"splish", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Splish Tails 12-08-2000 - {"wdrip1", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip2", false, 8 , 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip3", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip4", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip5", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip6", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip7", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdrip8", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wslap", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Water Slap Tails 12-13-2000 + {"amwtr1", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr2", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr3", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr4", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr5", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr6", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr7", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"amwtr8", false, 12, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stream"}, + {"bubbl1", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"bubbl2", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"bubbl3", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"bubbl4", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"bubbl5", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"floush", false, 16, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"splash", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, // labeling sfx_splash as "glub" and sfx_splish as "splash" seems wrong but isn't + {"splish", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, // Splish Tails 12-08-2000 + {"wdrip1", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip2", false, 8 , 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip3", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip4", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip5", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip6", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip7", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wdrip8", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, + {"wslap", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, // Water Slap Tails 12-13-2000 - {"doora1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"doorb1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"doorc1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"doorc2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"doord1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"doord2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"eleva1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"eleva2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"eleva3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"elevb1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"elevb2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"elevb3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"doora1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sliding open"}, + {"doorb1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sliding open"}, + {"doorc1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Wooden door opening"}, + {"doorc2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Slamming shut"}, + {"doord1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Creaking open"}, + {"doord2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Slamming shut"}, + {"eleva1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Starting elevator"}, + {"eleva2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Moving elevator"}, + {"eleva3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stopping elevator"}, + {"elevb1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Starting elevator"}, + {"elevb2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Moving elevator"}, + {"elevb3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Stopping elevator"}, - {"ambin2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"lavbub", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rocks1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rocks2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rocks3", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rocks4", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rumbam", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rumble", false, 64, 24, -1, NULL, 0, -1, -1, LUMPERROR}, + {"ambin2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Natural vibrations"}, + {"lavbub", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Bubbling lava"}, + {"rocks1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Falling rocks"}, + {"rocks2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Falling rocks"}, + {"rocks3", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Falling rocks"}, + {"rocks4", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Falling rocks"}, + {"rumbam", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, + {"rumble", false, 64, 24, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, // Game objects, etc - {"appear", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bkpoof", false, 70, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bnce1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Boing! - {"bnce2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Boing! - {"cannon", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"cgot" , true, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Got Emerald! Tails 09-02-2001 - {"cybdth", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"deton", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"ding", false, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"dmpain", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"drown", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"fizzle", false, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"gbeep", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Grenade beep - {"gclose", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"ghit" , false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"gloop", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"gspray", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"gravch", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"itemup", true, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"jet", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"jshard", true, 167, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"lose" , false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"lvpass", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mindig", false, 8, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mixup", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"pogo" , false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"pop" , false, 78, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rail1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rail2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"rlaunc", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"shield", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"shldls", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"spdpad", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"spkdth", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"spring", false, 112, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"statu1", true, 64, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"statu2", true, 64, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"strpst", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Starpost Sound Tails 07-04-2002 - {"supert", true, 127, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"telept", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"tink" , false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"token" , true, 224, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // SS token - {"trfire", true, 60, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"trpowr", true, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"turhit", false, 40, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wdjump", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mswarp", false, 60, 16, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mspogo", false, 60, 8, -1, NULL, 0, -1, -1, LUMPERROR}, + {"appear", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Appearing platform"}, + {"bkpoof", false, 70, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Armageddon pow"}, + {"bnce1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bounce"}, // Boing! + {"bnce2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Scatter"}, // Boing! + {"cannon", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Powerful shot"}, + {"cgot" , true, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got Emerald"}, // Got Emerald! Tails 09-02-2001 + {"cybdth", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Explosion"}, + {"deton", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Threatening beeping"}, + {"ding", false, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Ding"}, + {"dmpain", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Machine damage"}, + {"drown", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drowning"}, + {"fizzle", false, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Electric fizzle"}, + {"gbeep", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Threatening beeping"}, // Grenade beep + {"wepfir", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing weapon"}, // defaults to thok + {"ghit" , false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Goop splash"}, + {"gloop", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, + {"gspray", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Goop sling"}, + {"gravch", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Recycler"}, + {"itemup", true, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sparkle"}, + {"jet", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Jet engine"}, + {"jshard", true, 167, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Life transfer"}, // placeholder repurpose; original string was "Got Shard" + {"lose" , false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Failure"}, + {"lvpass", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spinning signpost"}, + {"mindig", false, 8, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Tunnelling"}, + {"mixup", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Teleport"}, + {"monton", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Golden Monitor activated"}, + {"pogo" , false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical pogo"}, + {"pop" , false, 78, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pop"}, + {"rail1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing rail"}, + {"rail2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crashing rail"}, + {"rlaunc", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing"}, + {"shield", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pity Shield"}, // generic GET! + {"wirlsg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Whirlwind Shield"}, // Whirlwind GET! + {"forcsg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Force Shield"}, // Force GET! + {"frcssg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Weak Force Shield"}, // Force GET...? (consider making a custom shield with this instead of a single-hit force shield!) + {"elemsg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Elemental Shield"}, // Elemental GET! + {"armasg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Armageddon Shield"}, // Armaggeddon GET! + {"attrsg", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Attraction Shield"}, // Attract GET! + {"shldls", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hurt"}, // You LOSE! + {"spdpad", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Speedpad"}, + {"spkdth", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spiked"}, + {"spring", false, 112, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spring"}, + {"statu1", true, 64, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Pushing a statue"}, + {"statu2", true, 64, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Pushing a statue"}, + {"strpst", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Starpost"}, + {"supert", true, 127, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Transformation"}, + {"telept", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Dash"}, + {"tink" , false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Tink"}, + {"token" , true, 224, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got Token"}, + {"trfire", true, 60, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Laser fired"}, + {"trpowr", true, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Powering up"}, + {"turhit", false, 40, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Laser hit"}, + {"wdjump", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Whirlwind jump"}, + {"shrpsp", true, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spincushion"}, + {"shrpgo", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Launch"}, + {"mswarp", false, 60, 16, -1, NULL, 0, -1, -1, LUMPERROR, "Spinning out"}, + {"mspogo", true, 60, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Breaking through"}, + {"boingf", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bouncing"}, + {"corkp", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Cork fired"}, + {"corkh", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Cork hit"}, + {"alart", false, 200, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Caught red handed!"}, + {"vwre", false, 200, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Clone fighter!"}, + {"bowl", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bowling"}, + {"chuchu", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Train horn"}, + {"bsnipe", false, 200, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Home-run smash"}, + {"sprong", false, 112, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Power spring"}, + {"lvfal1", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rumble"}, + {"pscree", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "SCREE!"}, + {"iceb", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ice crack"}, + {"shattr", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Shattering"}, + {"antiri", true, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Depletion"}, // Menu, interface - {"chchng", false, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"dwnind", false, 212, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"emfind", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"flgcap", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"menu1", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"oneup", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"ptally", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Point tally is identical to menu for now - {"radio", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"wepchg", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Weapon switch is identical to menu for now - {"wtrdng", true, 212, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // make sure you can hear the DING DING! Tails 03-08-2000 - {"zelda", false, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"chchng", false, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Score"}, + {"dwnind", false, 212, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Thinking about air"}, + {"emfind", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Radar beep"}, + {"flgcap", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flag captured"}, + {"menu1", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Menu beep"}, + {"oneup", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "One-up"}, + {"ptally", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Tally"}, // Point tally is identical to menu for now + {"radio", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Notification"}, + {"wepchg", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Weapon change"}, // Weapon switch is identical to menu for now + {"wtrdng", true, 212, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aquaphobia"}, // make sure you can hear the DING DING! Tails 03-08-2000 + {"zelda", false, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Discovery"}, + {"adderr", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Error"}, + {"notadd", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Reject"}, + {"addfil", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Accept"}, // NiGHTS - {"ideya", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"xideya", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Xmas - {"nbmper", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"nxbump", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Xmas - {"ncitem", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"nxitem", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Xmas - {"ngdone", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"nxdone", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Xmas - {"drill1", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"drill2", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"ncspec", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Tails 12-15-2003 - {"nghurt", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"ngskid", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"hoop1", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"hoop2", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"hoop3", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"hidden", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"prloop", false, 104, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"timeup", true, 256, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"ideya", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Success"}, + {"xideya", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Success"}, // Xmas + {"nbmper", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bumper"}, + {"nxbump", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bumper"}, // Xmas + {"ncchip", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got chip"}, + {"ncitem", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got special"}, + {"nxitem", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got special"}, // Xmas + {"ngdone", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bonus time start"}, + {"nxdone", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bonus time start"}, // Xmas + {"drill1", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drill"}, + {"drill2", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drill"}, + {"ncspec", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Power-up"}, // Tails 12-15-2003 + {"nghurt", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hurt"}, + {"ngskid", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Force stop"}, + {"hoop1", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hoop"}, + {"hoop2", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hoop+"}, + {"hoop3", false, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hoop++"}, + {"hidden", false, 204, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Discovery"}, + {"prloop", false, 104, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Gust of wind"}, + {"timeup", true, 256, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous Countdown"}, + {"ngjump", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Jump"}, + {"peww", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pew"}, + + // Halloween + {"lntsit", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Cacolantern awake"}, + {"lntdie", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Cacolantern death"}, + {"pumpkn", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pumpkin smash"}, // idspispopd + {"ghosty", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Laughter"}, // Mario - {"koopfr" , true, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario1", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario2", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario3", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario4", true, 78, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario5", false, 78, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario6", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario7", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario8", false, 48, 8, -1, NULL, 0, -1, -1, LUMPERROR}, - {"mario9", true, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"marioa", true, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"thwomp", true, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR}, + {"koopfr" , true, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Fire"}, + {"mario1", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hit"}, + {"mario2", false, 127, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bonk"}, + {"mario3", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Power-up"}, + {"mario4", true, 78, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got coin"}, + {"mario5", false, 78, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Boot-stomp"}, + {"mario6", false, 60, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Jump"}, + {"mario7", false, 32, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Fire"}, + {"mario8", false, 48, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Hurt"}, + {"mario9", true, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Emerging power-up"}, + {"marioa", true, 192, 0, -1, NULL, 0, -1, -1, LUMPERROR, "One-up"}, + {"thwomp", true, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Thwomp"}, // Black Eggman - {"bebomb", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bechrg", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"becrsh", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bedeen", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bedie1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bedie2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"beeyow", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"befall", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"befire", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"beflap", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"begoop", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"begrnd", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"behurt", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bejet1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"belnch", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"beoutb", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"beragh", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"beshot", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bestep", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bestp2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bewar1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bewar2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bewar3", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bewar4", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bexpld", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"bgxpld", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, + {"bebomb", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Big explosion"}, + {"bechrg", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Powering up"}, + {"becrsh", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Crash"}, + {"bedeen", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Metallic crash"}, + {"bedie1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman crying"}, + {"bedie2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman crying"}, + {"beeyow", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Failing machinery"}, + {"befall", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Metallic slam"}, + {"befire", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Firing goop"}, + {"beflap", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical jump"}, + {"begoop", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Powerful shot"}, + {"begrnd", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Metallic grinding"}, + {"behurt", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman shocked"}, + {"bejet1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Jetpack charge"}, + {"belnch", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical jump"}, + {"beoutb", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Failed shot"}, + {"beragh", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman screaming"}, + {"beshot", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Firing missile"}, + {"bestep", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical stomp"}, + {"bestp2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical stomp"}, + {"bewar1", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman laughing"}, + {"bewar2", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman laughing"}, + {"bewar3", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman laughing"}, + {"bewar4", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Eggman laughing"}, + {"bexpld", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Explosion"}, + {"bgxpld", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Explosion"}, // Cybrakdemon - {"beelec", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"brakrl", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, - {"brakrx", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, + {"beelec", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Electricity"}, + {"brakrl", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Rocket launch"}, + {"brakrx", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Rocket explosion"}, + + // Sonic 1 sounds + {"s1a0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1a9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1aa", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ab", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ac", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ad", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ae", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1af", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1b9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ba", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1bb", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1bc", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1bd", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1be", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1bf", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1c9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ca", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1cb", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1cc", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1cd", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1ce", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s1cf", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + + // Sonic 2 sounds + {"s220", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s221", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s222", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s223", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s224", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s225", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s226", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s227", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s228", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s229", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s22a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s22b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s22c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s22d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s22e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s22f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s230", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s231", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s232", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s233", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s234", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s235", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s236", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s237", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s238", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s239", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s23a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s23b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s23c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s23d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s23e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s23f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s240", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s241", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s242", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s243", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s244", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s245", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s246", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s247", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s248", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s249", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s24a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s24b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s24c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s24d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s24e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s24f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s250", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s251", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s252", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s253", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s254", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s255", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s256", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s257", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s258", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s259", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s25a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s25b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s25c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s25d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s25e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s25f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s260", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // S3&K sounds - {"s3k33", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k34", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k35", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k36", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k37", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k38", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k39", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k3a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k3b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k3c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k3d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k3e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k3f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k40", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k41", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k42", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k43", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k44", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k45", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k46", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k47", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k48", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k49", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k4a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k4b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k4c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k4d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k4e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k4f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k50", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k51", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k52", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k53", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k54", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, // MetalSonic shot fire - {"s3k55", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k56", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k57", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k58", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k59", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k5a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k5b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k5c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k5d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k5e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k5f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k60", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k61", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k62", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k63", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k64", false, 64, 2, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k65", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR}, // Blue Spheres - {"s3k66", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k67", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k68", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k69", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k6a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k6b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k6c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k6d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k6e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k6f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k70", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k71", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k72", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k73", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k74", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k75", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k76", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k77", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k78", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k79", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k7a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k7b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k7c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k7d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k7e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k7f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k80", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k81", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k82", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k83", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k84", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k85", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k86", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k87", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k88", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k89", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k8a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k8b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k8c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k8d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k8e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k8f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k90", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k91", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k92", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k93", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k94", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k95", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k96", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k97", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k98", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k99", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k9a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k9b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k9c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k9d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k9e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3k9f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3ka9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kaa", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kab", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kac", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kad", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kae", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kaf", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kb9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kba", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbb", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbcs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbcl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbds", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbdl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbes", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbel", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbfs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kbfl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc0s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc0l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc1s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc1l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc2s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc2l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc3s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc3l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc4s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc4l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc5s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc5l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc6s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc6l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc8s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc8l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc9s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kc9l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcas", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcal", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcbs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcbl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kccs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kccl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcds", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcdl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kces", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcel", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcfs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kcfl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd0s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd0l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd1s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd1l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd2s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd2l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd3s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd3l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd4s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd4l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd5s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd5l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd6s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd6l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd7s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd7l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd8s", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR}, // Sharp Spin (maybe use the long/L version?) - {"s3kd8l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd9s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kd9l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kdas", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kdal", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kdbs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, - {"s3kdbl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR}, + {"s3k2b", true, 120, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got Emerald"}, // Got Emerald! + {"s3k33", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sparkle"}, // stereo in original game, identical to latter + {"s3k34", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sparkle"}, // mono in original game, identical to previous + {"s3k35", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Hurt"}, + {"s3k36", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Skid"}, + {"s3k37", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spiked"}, + {"s3k38", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bubble gasp"}, + {"s3k39", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, + {"s3k3a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Shield"}, + {"s3k3b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drowning"}, + {"s3k3c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spin"}, + {"s3k3d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pop"}, + {"s3k3e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flame Shield"}, + {"s3k3f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bubble Shield"}, + {"s3k40", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Attraction blast"}, + {"s3k41", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Thunder Shield"}, + {"s3k42", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Twinspin"}, + {"s3k43", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flame burst"}, + {"s3k44", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bubble bounce"}, + {"s3k45", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Lightning zap"}, + {"s3k46", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Transformation"}, + {"s3k47", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rising dust"}, + {"s3k48", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pulse"}, + {"s3k49", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Impact"}, + {"s3k4a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Grab"}, + {"s3k4b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, + {"s3k4c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy hit"}, + {"s3k4d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing bullet"}, + {"s3k4e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Big explosion"}, + {"s3k4f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flamethrower"}, + {"s3k50", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Siren"}, + {"s3k51", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Falling"}, + {"s3k52", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spike"}, + {"s3k53", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Powering up"}, + {"s3k54", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Firing"}, // MetalSonic shot fire + {"s3k55", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical movement"}, + {"s3k56", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy landing"}, + {"s3k57", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Burst"}, + {"s3k58", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical movement"}, + {"s3k59", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crumbling"}, + {"s3k5a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aiming"}, + {"s3k5b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Menu beep"}, + {"s3k5c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Electric spark"}, + {"s3k5d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Heavy hit"}, + {"s3k5e", false, 127, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Releasing charge"}, + {"s3k5f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crusher stomp"}, + {"s3k60", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Accelerating"}, + {"s3k61", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drilling"}, + {"s3k62", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Jump"}, + {"s3k63", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Starpost"}, + {"s3k64", false, 64, 2, -1, NULL, 0, -1, -1, LUMPERROR, "Clatter"}, + {"s3k65", false, 255, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got sphere"}, // Blue Spheres + {"s3k66", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Special stage end"}, + {"s3k67", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing missile"}, + {"s3k68", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Discovery"}, + {"s3k69", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Switch click"}, + {"s3k6a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Special stage clear"}, + {"s3k6b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Punch"}, + {"s3k6c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Burst"}, + {"s3k6d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3k6e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Mechanical damage"}, + {"s3k6f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, + {"s3k70", true, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Burst"}, + {"s3k71", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Basic Shield"}, + {"s3k72", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Movement"}, + {"s3k73", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Warp"}, + {"s3k74", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Gong"}, + {"s3k75", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rising"}, + {"s3k76", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Click"}, + {"s3k77", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Balloon pop"}, + {"s3k78", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Magnet"}, + {"s3k79", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Electric charge"}, + {"s3k7a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rising from lava"}, + {"s3k7b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Soft bounce"}, + {"s3k7c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Magnet"}, + {"s3k7d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3k7e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Dust"}, + {"s3k7f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Freeze"}, + {"s3k80", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ice spike burst"}, + {"s3k81", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Burst"}, + {"s3k82", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Burst"}, + {"s3k83", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Collapsing"}, + {"s3k84", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Powering up"}, + {"s3k85", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Powering down"}, + {"s3k86", false, 128, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Alarm"}, + {"s3k87", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bounce"}, + {"s3k88", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Metallic squeak"}, + {"s3k89", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Advanced tech"}, + {"s3k8a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Boing"}, + {"s3k8b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Powerful hit"}, + {"s3k8c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Humming power"}, + {"s3k8d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3k8e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Accelerating"}, + {"s3k8f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Opening"}, + {"s3k90", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Impact"}, + {"s3k91", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Closed"}, + {"s3k92", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ghost"}, + {"s3k93", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Gas release"}, + {"s3k94", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spike"}, + {"s3k95", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Lava burst"}, + {"s3k96", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Landing"}, + {"s3k97", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Wind"}, + {"s3k98", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Falling spike"}, + {"s3k99", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bounce"}, + {"s3k9a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Click"}, + {"s3k9b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Crusher stomp"}, + {"s3k9c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got Super Emerald"}, + {"s3k9d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Targeting"}, + {"s3k9e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Wham"}, + {"s3k9f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Transformation"}, + {"s3ka0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Launch"}, + {"s3ka1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3ka2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Launch"}, + {"s3ka3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rising charge"}, + {"s3ka4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Powering up"}, + {"s3ka5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3ka6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Attraction fizzle"}, + {"s3ka7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Countdown beep"}, + {"s3ka8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Energy"}, + {"s3ka9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aquaphobia"}, + {"s3kaa", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bumper"}, + {"s3kab", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kab9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kaba", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kabb", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kabc", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kabd", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kabe", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kabf", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spindash"}, + {"s3kac", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Got Continue"}, + {"s3kad", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "GO!"}, + {"s3kae", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pinball flipper"}, + {"s3kaf", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "To Special Stage"}, + {"s3kb0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Score"}, + {"s3kb1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spring"}, + {"s3kb2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Failure"}, + {"s3kb3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Warp"}, + {"s3kb4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Explosion"}, + {"s3kb5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Clink"}, + {"s3kb6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spin launch"}, + {"s3kb7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Tumbler"}, + {"s3kb8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spinning signpost"}, + {"s3kb9", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ring loss"}, + {"s3kba", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flight"}, + {"s3kbb", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Tired flight"}, + {"s3kbcs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3kbcl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // long version of previous + {"s3kbds", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flying fortress"}, + {"s3kbdl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flying fortress"}, // ditto + {"s3kbes", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flying"}, + {"s3kbel", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flying"}, // ditto + {"s3kbfs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Turbine"}, + {"s3kbfl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Turbine"}, // ditto + {"s3kc0s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Turbine"}, + {"s3kc0l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Turbine"}, // ditto + {"s3kc1s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Fan"}, + {"s3kc1l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Fan"}, // ditto + {"s3kc2s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flamethrower"}, + {"s3kc2l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Flamethrower"}, // ditto + {"s3kc3s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Levitation"}, + {"s3kc3l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Levitation"}, // ditto + {"s3kc4s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing laser"}, + {"s3kc4l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Firing laser"}, // ditto + {"s3kc5s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Revving up"}, + {"s3kc5l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Revving up"}, // ditto + {"s3kc6s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Orbiting"}, + {"s3kc6l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Orbiting"}, // ditto + {"s3kc7s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aiming"}, + {"s3kc7l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aiming"}, // ditto + {"s3kc8s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sliding"}, + {"s3kc8l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sliding"}, // ditto + {"s3kc9s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Swinging"}, + {"s3kc9l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Swinging"}, // ditto + {"s3kcas", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Energy"}, + {"s3kcal", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Energy"}, // ditto + {"s3kcbs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, + {"s3kcbl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, // ditto + {"s3kccs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bursting"}, + {"s3kccl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bursting"}, // ditto + {"s3kcds", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, + {"s3kcdl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ominous rumbling"}, // ditto + {"s3kces", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Wind tunnel"}, + {"s3kcel", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Dust devil"}, // ditto + {"s3kcfs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3kcfl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // ditto + {"s3kd0s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rising"}, + {"s3kd0l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Rising"}, // ditto + {"s3kd1s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3kd1l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // ditto + {"s3kd2s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Turning"}, + {"s3kd2l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Moving chain"}, // ditto + {"s3kd3s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Digging"}, + {"s3kd3l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Digging"}, // ditto + {"s3kd4s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Engine"}, + {"s3kd4l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Engine"}, // ditto + {"s3kd5s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Falling lava"}, + {"s3kd5l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Falling lava"}, // ditto + {"s3kd6s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"s3kd6l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // ditto + {"s3kd7s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Movement"}, + {"s3kd7l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Movement"}, // ditto + {"s3kd8s", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, "Acceleration"}, // Sharp Spin (maybe use the long/L version?) + {"s3kd8l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Acceleration"}, // ditto + {"s3kd9s", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Magnetism"}, + {"s3kd9l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Magnetism"}, // ditto + {"s3kdas", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Click"}, + {"s3kdal", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Click"}, // ditto + {"s3kdbs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Running on water"}, + {"s3kdbl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Running on water"}, // ditto + + // 3D Blast sounds (the "missing" ones are direct copies of S3K's, no minor differences what-so-ever) + {"3db06", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Collection"}, + {"3db09", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Peep"}, + {"3db14", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Chirp"}, + {"3db16", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + + // Sonic CD sounds + {"cdfm00", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Skid"}, + {"cdfm01", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm02", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Jump"}, + {"cdfm03", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Dying"}, + {"cdfm04", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ring loss"}, + {"cdfm05", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Sparkle"}, + {"cdfm06", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pop"}, + {"cdfm07", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Shield"}, + {"cdfm08", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Spring"}, + {"cdfm09", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm10", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm11", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm12", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm13", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm14", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm15", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm16", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm17", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm18", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm19", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm20", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm21", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm22", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm23", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm24", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm25", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm26", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm27", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm28", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm29", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Bubble gasp"}, + {"cdfm30", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Starpost"}, + {"cdfm31", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Warp"}, + {"cdfm32", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm33", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm34", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm35", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm36", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm37", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm38", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drowning"}, + {"cdfm39", false, 128, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm40", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Power up"}, + {"cdfm41", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm42", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm43", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm44", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Extra time"}, + {"cdfm45", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm46", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm47", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm48", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm49", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Aquaphobia"}, + {"cdfm50", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm51", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm52", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm53", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm54", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm55", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm56", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Warp"}, + {"cdfm57", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm58", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm59", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm60", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm61", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm62", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Speed boost"}, + {"cdfm63", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm64", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm65", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm66", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm67", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm68", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm69", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm70", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm71", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm72", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm73", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm74", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm75", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm76", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm77", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm78", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdfm79", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdpcm0", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Future."}, + {"cdpcm1", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Past."}, + {"cdpcm2", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "All right!"}, + {"cdpcm3", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "I'm outta here..."}, + {"cdpcm4", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Yes!"}, + {"cdpcm5", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Yeah!"}, + {"cdpcm6", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Giggles"}, + {"cdpcm7", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Eep!"}, + {"cdpcm8", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"cdpcm9", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Bumper"}, + + // Knuckles Chaotix sounds + {"kc2a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc2b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc2c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc2d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc2e", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc2f", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc30", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc31", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc32", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc33", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc34", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc35", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc36", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc37", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc38", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc39", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc3a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc3b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc3c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc3d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc3e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc3f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc40", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc41", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc42", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Confirm"}, + {"kc43", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc44", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc45", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc46", false, 96, 8, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc47", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc48", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Select"}, + {"kc49", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc4a", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc4b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc4c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Pop-shot"}, + {"kc4d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Power up"}, + {"kc4e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc4f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc50", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc51", false, 64, 64, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc52", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc53", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc54", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc55", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc56", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc57", false, 128, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Sheer terror"}, + {"kc58", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc59", false, 128, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Shrink"}, + {"kc5a", false, 128, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Grow"}, + {"kc5b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc5c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc5d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc5e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc5f", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc60", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc61", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc62", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc63", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc64", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Terrifying rumble"}, + {"kc65", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Power down"}, + {"kc66", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc67", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc68", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc69", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc6b", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Ascending"}, + {"kc6c", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc6d", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"kc6e", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // skin sounds free slots to add sounds at run time (Boris HACK!!!) // initialized to NULL @@ -504,38 +860,50 @@ void S_InitRuntimeSounds (void) S_sfx[i].skinsound = -1; S_sfx[i].usefulness = -1; S_sfx[i].lumpnum = LUMPERROR; + //strlcpy(S_sfx[i].caption, "", 1); + S_sfx[i].caption[0] = '\0'; } } +sfxenum_t sfxfree = sfx_freeslot0; + // Add a new sound fx into a free sfx slot. // sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound) { - sfxenum_t i, slot; + sfxenum_t i; if (skinsound) - slot = sfx_skinsoundslot0; - else - slot = sfx_freeslot0; - - for (i = slot; i < NUMSFX; i++) { - if (!S_sfx[i].priority) + for (i = sfx_skinsoundslot0; i < NUMSFX; i++) { - strncpy(freeslotnames[i-sfx_freeslot0], name, 6); - S_sfx[i].singularity = singular; - S_sfx[i].priority = 60; - S_sfx[i].pitch = flags; - S_sfx[i].volume = -1; - S_sfx[i].lumpnum = LUMPERROR; - S_sfx[i].skinsound = -1; - S_sfx[i].usefulness = -1; - - /// \todo if precached load it here - S_sfx[i].data = NULL; - return i; + if (S_sfx[i].priority) + continue; + break; } } + else + i = sfxfree; + + if (i < NUMSFX) + { + strncpy(freeslotnames[i-sfx_freeslot0], name, 6); + S_sfx[i].singularity = singular; + S_sfx[i].priority = 60; + S_sfx[i].pitch = flags; + S_sfx[i].volume = -1; + S_sfx[i].lumpnum = LUMPERROR; + S_sfx[i].skinsound = -1; + S_sfx[i].usefulness = -1; + + /// \todo if precached load it here + S_sfx[i].data = NULL; + + if (!skinsound) + sfxfree++; + + return i; + } CONS_Alert(CONS_WARNING, M_GetText("No more free sound slots\n")); return 0; } diff --git a/src/sounds.h b/src/sounds.h index 495a55a1e..e49dd2f3e 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -42,7 +42,7 @@ typedef enum } skinsound_t; // free sfx for S_AddSoundFx() -#define NUMSFXFREESLOTS 800 // Matches SOC Editor. +#define NUMSFXFREESLOTS 1600 // Matches SOC Editor. #define NUMSKINSFXSLOTS (MAXSKINS*NUMSKINSOUNDS) // @@ -84,6 +84,9 @@ struct sfxinfo_struct // lump number of sfx lumpnum_t lumpnum; + + // closed caption info/wiki table bait + char caption[32]; }; // the complete set of sound effects @@ -139,6 +142,8 @@ typedef enum sfx_steam1, sfx_steam2, sfx_wbreak, + sfx_ambmac, + sfx_spsmsh, sfx_rainin, sfx_litng1, @@ -210,7 +215,7 @@ typedef enum sfx_drown, sfx_fizzle, sfx_gbeep, - sfx_gclose, + sfx_wepfir, sfx_ghit, sfx_gloop, sfx_gspray, @@ -222,12 +227,19 @@ typedef enum sfx_lvpass, sfx_mindig, sfx_mixup, + sfx_monton, sfx_pogo, sfx_pop, sfx_rail1, sfx_rail2, sfx_rlaunc, sfx_shield, + sfx_wirlsg, + sfx_forcsg, + sfx_frcssg, + sfx_elemsg, + sfx_armasg, + sfx_attrsg, sfx_shldls, sfx_spdpad, sfx_spkdth, @@ -243,8 +255,24 @@ typedef enum sfx_trpowr, sfx_turhit, sfx_wdjump, + sfx_shrpsp, + sfx_shrpgo, sfx_mswarp, sfx_mspogo, + sfx_boingf, + sfx_corkp, + sfx_corkh, + sfx_alart, + sfx_vwre, + sfx_bowl, + sfx_chuchu, + sfx_bsnipe, + sfx_sprong, + sfx_lvfal1, + sfx_pscree, + sfx_iceb, + sfx_shattr, + sfx_antiri, // Menu, interface sfx_chchng, @@ -258,12 +286,16 @@ typedef enum sfx_wepchg, sfx_wtrdng, sfx_zelda, + sfx_adderr, + sfx_notadd, + sfx_addfil, // NiGHTS sfx_ideya, sfx_xideya, // Xmas sfx_nbmper, sfx_nxbump, // Xmas + sfx_ncchip, sfx_ncitem, sfx_nxitem, // Xmas sfx_ngdone, @@ -278,7 +310,15 @@ typedef enum sfx_hoop3, sfx_hidden, sfx_prloop, - sfx_timeup, // Was gonna be played when less than ten seconds are on the clock; uncomment uses of this to see it in-context + sfx_timeup, + sfx_ngjump, + sfx_peww, + + // Halloween + sfx_lntsit, + sfx_lntdie, + sfx_pumpkn, + sfx_ghosty, // Mario sfx_koopfr, @@ -327,7 +367,125 @@ typedef enum sfx_brakrl, // Rocket launcher sfx_brakrx, // Rocket explodes + // S1 sounds + sfx_s1a0, + sfx_s1a1, + sfx_s1a2, + sfx_s1a3, + sfx_s1a4, + sfx_s1a5, + sfx_s1a6, + sfx_s1a7, + sfx_s1a8, + sfx_s1a9, + sfx_s1aa, + sfx_s1ab, + sfx_s1ac, + sfx_s1ad, + sfx_s1ae, + sfx_s1af, + sfx_s1b0, + sfx_s1b1, + sfx_s1b2, + sfx_s1b3, + sfx_s1b4, + sfx_s1b5, + sfx_s1b6, + sfx_s1b7, + sfx_s1b8, + sfx_s1b9, + sfx_s1ba, + sfx_s1bb, + sfx_s1bc, + sfx_s1bd, + sfx_s1be, + sfx_s1bf, + sfx_s1c0, + sfx_s1c1, + sfx_s1c2, + sfx_s1c3, + sfx_s1c4, + sfx_s1c5, + sfx_s1c6, + sfx_s1c7, + sfx_s1c8, + sfx_s1c9, + sfx_s1ca, + sfx_s1cb, + sfx_s1cc, + sfx_s1cd, + sfx_s1ce, + sfx_s1cf, + + // S2 sounds + sfx_s220, + sfx_s221, + sfx_s222, + sfx_s223, + sfx_s224, + sfx_s225, + sfx_s226, + sfx_s227, + sfx_s228, + sfx_s229, + sfx_s22a, + sfx_s22b, + sfx_s22c, + sfx_s22d, + sfx_s22e, + sfx_s22f, + sfx_s230, + sfx_s231, + sfx_s232, + sfx_s233, + sfx_s234, + sfx_s235, + sfx_s236, + sfx_s237, + sfx_s238, + sfx_s239, + sfx_s23a, + sfx_s23b, + sfx_s23c, + sfx_s23d, + sfx_s23e, + sfx_s23f, + sfx_s240, + sfx_s241, + sfx_s242, + sfx_s243, + sfx_s244, + sfx_s245, + sfx_s246, + sfx_s247, + sfx_s248, + sfx_s249, + sfx_s24a, + sfx_s24b, + sfx_s24c, + sfx_s24d, + sfx_s24e, + sfx_s24f, + sfx_s250, + sfx_s251, + sfx_s252, + sfx_s253, + sfx_s254, + sfx_s255, + sfx_s256, + sfx_s257, + sfx_s258, + sfx_s259, + sfx_s25a, + sfx_s25b, + sfx_s25c, + sfx_s25d, + sfx_s25e, + sfx_s25f, + sfx_s260, + // S3&K sounds + sfx_s3k2b, sfx_s3k33, sfx_s3k34, sfx_s3k35, @@ -449,6 +607,21 @@ typedef enum sfx_s3ka9, sfx_s3kaa, sfx_s3kab, + sfx_s3kab1, + sfx_s3kab2, + sfx_s3kab3, + sfx_s3kab4, + sfx_s3kab5, + sfx_s3kab6, + sfx_s3kab7, + sfx_s3kab8, + sfx_s3kab9, + sfx_s3kaba, + sfx_s3kabb, + sfx_s3kabc, + sfx_s3kabd, + sfx_s3kabe, + sfx_s3kabf, sfx_s3kac, sfx_s3kad, sfx_s3kae, @@ -487,7 +660,8 @@ typedef enum sfx_s3kc5l, sfx_s3kc6s, sfx_s3kc6l, - sfx_s3kc7, + sfx_s3kc7s, + sfx_s3kc7l, sfx_s3kc8s, sfx_s3kc8l, sfx_s3kc9s, @@ -529,6 +703,174 @@ typedef enum sfx_s3kdbs, sfx_s3kdbl, + // 3DB sounds + sfx_3db06, + sfx_3db09, + sfx_3db14, + sfx_3db16, + + // SCD sounds + sfx_cdfm00, + sfx_cdfm01, + sfx_cdfm02, + sfx_cdfm03, + sfx_cdfm04, + sfx_cdfm05, + sfx_cdfm06, + sfx_cdfm07, + sfx_cdfm08, + sfx_cdfm09, + sfx_cdfm10, + sfx_cdfm11, + sfx_cdfm12, + sfx_cdfm13, + sfx_cdfm14, + sfx_cdfm15, + sfx_cdfm16, + sfx_cdfm17, + sfx_cdfm18, + sfx_cdfm19, + sfx_cdfm20, + sfx_cdfm21, + sfx_cdfm22, + sfx_cdfm23, + sfx_cdfm24, + sfx_cdfm25, + sfx_cdfm26, + sfx_cdfm27, + sfx_cdfm28, + sfx_cdfm29, + sfx_cdfm30, + sfx_cdfm31, + sfx_cdfm32, + sfx_cdfm33, + sfx_cdfm34, + sfx_cdfm35, + sfx_cdfm36, + sfx_cdfm37, + sfx_cdfm38, + sfx_cdfm39, + sfx_cdfm40, + sfx_cdfm41, + sfx_cdfm42, + sfx_cdfm43, + sfx_cdfm44, + sfx_cdfm45, + sfx_cdfm46, + sfx_cdfm47, + sfx_cdfm48, + sfx_cdfm49, + sfx_cdfm50, + sfx_cdfm51, + sfx_cdfm52, + sfx_cdfm53, + sfx_cdfm54, + sfx_cdfm55, + sfx_cdfm56, + sfx_cdfm57, + sfx_cdfm58, + sfx_cdfm59, + sfx_cdfm60, + sfx_cdfm61, + sfx_cdfm62, + sfx_cdfm63, + sfx_cdfm64, + sfx_cdfm65, + sfx_cdfm66, + sfx_cdfm67, + sfx_cdfm68, + sfx_cdfm69, + sfx_cdfm70, + sfx_cdfm71, + sfx_cdfm72, + sfx_cdfm73, + sfx_cdfm74, + sfx_cdfm75, + sfx_cdfm76, + sfx_cdfm77, + sfx_cdfm78, + sfx_cdfm79, + sfx_cdpcm0, + sfx_cdpcm1, + sfx_cdpcm2, + sfx_cdpcm3, + sfx_cdpcm4, + sfx_cdpcm5, + sfx_cdpcm6, + sfx_cdpcm7, + sfx_cdpcm8, + sfx_cdpcm9, + + // KC sounds + sfx_kc2a, + sfx_kc2b, + sfx_kc2c, + sfx_kc2d, + sfx_kc2e, + sfx_kc2f, + sfx_kc30, + sfx_kc31, + sfx_kc32, + sfx_kc33, + sfx_kc34, + sfx_kc35, + sfx_kc36, + sfx_kc37, + sfx_kc38, + sfx_kc39, + sfx_kc3a, + sfx_kc3b, + sfx_kc3c, + sfx_kc3d, + sfx_kc3e, + sfx_kc3f, + sfx_kc40, + sfx_kc41, + sfx_kc42, + sfx_kc43, + sfx_kc44, + sfx_kc45, + sfx_kc46, + sfx_kc47, + sfx_kc48, + sfx_kc49, + sfx_kc4a, + sfx_kc4b, + sfx_kc4c, + sfx_kc4d, + sfx_kc4e, + sfx_kc4f, + sfx_kc50, + sfx_kc51, + sfx_kc52, + sfx_kc53, + sfx_kc54, + sfx_kc55, + sfx_kc56, + sfx_kc57, + sfx_kc58, + sfx_kc59, + sfx_kc5a, + sfx_kc5b, + sfx_kc5c, + sfx_kc5d, + sfx_kc5e, + sfx_kc5f, + sfx_kc60, + sfx_kc61, + sfx_kc62, + sfx_kc63, + sfx_kc64, + sfx_kc65, + sfx_kc66, + sfx_kc67, + sfx_kc68, + sfx_kc69, + sfx_kc6b, + sfx_kc6c, + sfx_kc6d, + sfx_kc6e, + // free slots for S_AddSoundFx() at run-time -------------------- sfx_freeslot0, // @@ -545,6 +887,7 @@ typedef enum void S_InitRuntimeSounds(void); sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean skinsound); +extern sfxenum_t sfxfree; // sound test and slotting void S_RemoveSoundFx(sfxenum_t id); #endif diff --git a/src/st_stuff.c b/src/st_stuff.c index 1f8dbbf61..ee7fc3f21 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -23,10 +23,13 @@ #include "v_video.h" #include "z_zone.h" #include "hu_stuff.h" +#include "console.h" #include "s_sound.h" #include "i_system.h" #include "m_menu.h" #include "m_cheat.h" +#include "m_misc.h" // moviemode +#include "m_anigif.h" // cv_gif_downscale #include "p_setup.h" // NiGHTS grading //random index @@ -39,9 +42,7 @@ #include "hardware/hw_main.h" #endif -#ifdef HAVE_BLUA #include "lua_hud.h" -#endif UINT16 objectsdrawn = 0; @@ -62,12 +63,14 @@ patch_t *sbotime; // Time logo patch_t *sbocolon; // Colon for time patch_t *sboperiod; // Period for time centiseconds patch_t *livesback; // Lives icon background +patch_t *stlivex; static patch_t *nrec_timer; // Timer for NiGHTS records static patch_t *sborings; -static patch_t *sboover; -static patch_t *timeover; -static patch_t *stlivex; -static patch_t *rrings; +static patch_t *slidgame; +static patch_t *slidtime; +static patch_t *slidover; +static patch_t *sboredrings; +static patch_t *sboredtime; static patch_t *getall; // Special Stage HUD static patch_t *timeup; // Special Stage HUD static patch_t *hunthoming[6]; @@ -76,14 +79,7 @@ static patch_t *race1; static patch_t *race2; static patch_t *race3; static patch_t *racego; -static patch_t *ttlnum; static patch_t *nightslink; -static patch_t *count5; -static patch_t *count4; -static patch_t *count3; -static patch_t *count2; -static patch_t *count1; -static patch_t *count0; static patch_t *curweapon; static patch_t *normring; static patch_t *bouncering; @@ -99,18 +95,26 @@ static patch_t *ringshield; static patch_t *watershield; static patch_t *bombshield; static patch_t *pityshield; +static patch_t *pinkshield; +static patch_t *flameshield; +static patch_t *bubbleshield; +static patch_t *thundershield; static patch_t *invincibility; static patch_t *sneakers; static patch_t *gravboots; static patch_t *nonicon; +static patch_t *nonicon2; static patch_t *bluestat; static patch_t *byelstat; static patch_t *orngstat; static patch_t *redstat; static patch_t *yelstat; static patch_t *nbracket; +static patch_t *nring; static patch_t *nhud[12]; static patch_t *nsshud; +static patch_t *nbon[12]; +static patch_t *nssbon; static patch_t *narrow[9]; static patch_t *nredar[8]; // Red arrow static patch_t *drillbar; @@ -122,46 +126,38 @@ static patch_t *minus5sec; static patch_t *minicaps; static patch_t *gotrflag; static patch_t *gotbflag; +static patch_t *fnshico; static boolean facefreed[MAXPLAYERS]; hudinfo_t hudinfo[NUMHUDITEMS] = { - { 34, 176}, // HUD_LIVESNAME - { 16, 176}, // HUD_LIVESPIC - { 74, 184}, // HUD_LIVESNUM - { 38, 186}, // HUD_LIVESX + { 16, 176, V_SNAPTOLEFT|V_SNAPTOBOTTOM}, // HUD_LIVES - { 16, 42}, // HUD_RINGS - { 220, 10}, // HUD_RINGSSPLIT - { 112, 42}, // HUD_RINGSNUM - { 288, 10}, // HUD_RINGSNUMSPLIT + { 16, 42, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_RINGS + { 96, 42, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_RINGSNUM + { 120, 42, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_RINGSNUMTICS - { 16, 10}, // HUD_SCORE - { 128, 10}, // HUD_SCORENUM + { 16, 10, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SCORE + { 120, 10, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SCORENUM - { 17, 26}, // HUD_TIME - { 136, 10}, // HUD_TIMESPLIT - { 88, 26}, // HUD_MINUTES - { 188, 10}, // HUD_MINUTESSPLIT - { 88, 26}, // HUD_TIMECOLON - { 188, 10}, // HUD_TIMECOLONSPLIT - { 112, 26}, // HUD_SECONDS - { 212, 10}, // HUD_SECONDSSPLIT - { 112, 26}, // HUD_TIMETICCOLON - { 136, 26}, // HUD_TICS + { 16, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TIME + { 72, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_MINUTES + { 72, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TIMECOLON + { 96, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SECONDS + { 96, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TIMETICCOLON + { 120, 26, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_TICS - { 112, 56}, // HUD_SS_TOTALRINGS - { 288, 40}, // HUD_SS_TOTALRINGS_SPLIT + { 0, 56, V_SNAPTOLEFT|V_SNAPTOTOP}, // HUD_SS_TOTALRINGS - { 110, 93}, // HUD_GETRINGS - { 160, 93}, // HUD_GETRINGSNUM - { 124, 160}, // HUD_TIMELEFT - { 168, 176}, // HUD_TIMELEFTNUM - { 130, 93}, // HUD_TIMEUP - { 152, 168}, // HUD_HUNTPICS - { 152, 24}, // HUD_GRAVBOOTSICO - { 240, 160}, // HUD_LAP + { 110, 93, 0}, // HUD_GETRINGS + { 160, 93, 0}, // HUD_GETRINGSNUM + { 124, 160, 0}, // HUD_TIMELEFT + { 168, 176, 0}, // HUD_TIMELEFTNUM + { 130, 93, 0}, // HUD_TIMEUP + { 152, 168, 0}, // HUD_HUNTPICS + + { 288, 176, V_SNAPTORIGHT|V_SNAPTOBOTTOM}, // HUD_POWERUPS }; // @@ -190,14 +186,18 @@ boolean ST_SameTeam(player_t *a, player_t *b) static boolean st_stopped = true; -void ST_Ticker(void) +void ST_Ticker(boolean run) { if (st_stopped) return; + + if (run) + ST_runTitleCard(); } // 0 is default, any others are special palettes. -static INT32 st_palette = 0; +INT32 st_palette = 0; +INT32 st_translucency = 10; void ST_doPaletteStuff(void) { @@ -232,7 +232,7 @@ void ST_doPaletteStuff(void) void ST_UnloadGraphics(void) { - Z_FreeTags(PU_HUDGFX, PU_HUDGFX); + Z_FreeTag(PU_HUDGFX); } void ST_LoadGraphics(void) @@ -248,16 +248,22 @@ void ST_LoadGraphics(void) // but load them in R_AddSkins, that gets called // first anyway // cache the status bar overlay icons (fullscreen mode) - sborings = W_CachePatchName("SBORINGS", PU_HUDGFX); - sboscore = W_CachePatchName("SBOSCORE", PU_HUDGFX); - sboover = W_CachePatchName("SBOOVER", PU_HUDGFX); - timeover = W_CachePatchName("TIMEOVER", PU_HUDGFX); + + // Prefix "STT" is whitelisted (doesn't trigger ISGAMEMODIFIED), btw + sborings = W_CachePatchName("STTRINGS", PU_HUDGFX); + sboredrings = W_CachePatchName("STTRRING", PU_HUDGFX); + sboscore = W_CachePatchName("STTSCORE", PU_HUDGFX); + sbotime = W_CachePatchName("STTTIME", PU_HUDGFX); // Time logo + sboredtime = W_CachePatchName("STTRTIME", PU_HUDGFX); + sbocolon = W_CachePatchName("STTCOLON", PU_HUDGFX); // Colon for time + sboperiod = W_CachePatchName("STTPERIO", PU_HUDGFX); // Period for time centiseconds + + slidgame = W_CachePatchName("SLIDGAME", PU_HUDGFX); + slidtime = W_CachePatchName("SLIDTIME", PU_HUDGFX); + slidover = W_CachePatchName("SLIDOVER", PU_HUDGFX); + stlivex = W_CachePatchName("STLIVEX", PU_HUDGFX); livesback = W_CachePatchName("STLIVEBK", PU_HUDGFX); - rrings = W_CachePatchName("RRINGS", PU_HUDGFX); - sbotime = W_CachePatchName("SBOTIME", PU_HUDGFX); // Time logo - sbocolon = W_CachePatchName("SBOCOLON", PU_HUDGFX); // Colon for time - sboperiod = W_CachePatchName("SBOPERIO", PU_HUDGFX); // Period for time centiseconds nrec_timer = W_CachePatchName("NGRTIMER", PU_HUDGFX); // Timer for NiGHTS getall = W_CachePatchName("GETALL", PU_HUDGFX); // Special Stage HUD timeup = W_CachePatchName("TIMEUP", PU_HUDGFX); // Special Stage HUD @@ -266,12 +272,6 @@ void ST_LoadGraphics(void) race3 = W_CachePatchName("RACE3", PU_HUDGFX); racego = W_CachePatchName("RACEGO", PU_HUDGFX); nightslink = W_CachePatchName("NGHTLINK", PU_HUDGFX); - count5 = W_CachePatchName("DRWNF0", PU_HUDGFX); - count4 = W_CachePatchName("DRWNE0", PU_HUDGFX); - count3 = W_CachePatchName("DRWND0", PU_HUDGFX); - count2 = W_CachePatchName("DRWNC0", PU_HUDGFX); - count1 = W_CachePatchName("DRWNB0", PU_HUDGFX); - count0 = W_CachePatchName("DRWNA0", PU_HUDGFX); for (i = 0; i < 6; ++i) { @@ -288,15 +288,19 @@ void ST_LoadGraphics(void) scatterring = W_CachePatchName("SCATIND", PU_HUDGFX); grenadering = W_CachePatchName("GRENIND", PU_HUDGFX); railring = W_CachePatchName("RAILIND", PU_HUDGFX); - jumpshield = W_CachePatchName("WHTVB0", PU_HUDGFX); - forceshield = W_CachePatchName("BLTVB0", PU_HUDGFX); - ringshield = W_CachePatchName("YLTVB0", PU_HUDGFX); - watershield = W_CachePatchName("ELTVB0", PU_HUDGFX); - bombshield = W_CachePatchName("BKTVB0", PU_HUDGFX); - pityshield = W_CachePatchName("GRTVB0", PU_HUDGFX); - invincibility = W_CachePatchName("PINVB0", PU_HUDGFX); - sneakers = W_CachePatchName("SHTVB0", PU_HUDGFX); - gravboots = W_CachePatchName("GBTVB0", PU_HUDGFX); + jumpshield = W_CachePatchName("TVWWICON", PU_HUDGFX); + forceshield = W_CachePatchName("TVFOICON", PU_HUDGFX); + ringshield = W_CachePatchName("TVATICON", PU_HUDGFX); + watershield = W_CachePatchName("TVELICON", PU_HUDGFX); + bombshield = W_CachePatchName("TVARICON", PU_HUDGFX); + pityshield = W_CachePatchName("TVPIICON", PU_HUDGFX); + pinkshield = W_CachePatchName("TVPPICON", PU_HUDGFX); + flameshield = W_CachePatchName("TVFLICON", PU_HUDGFX); + bubbleshield = W_CachePatchName("TVBBICON", PU_HUDGFX); + thundershield = W_CachePatchName("TVZPICON", PU_HUDGFX); + invincibility = W_CachePatchName("TVIVICON", PU_HUDGFX); + sneakers = W_CachePatchName("TVSSICON", PU_HUDGFX); + gravboots = W_CachePatchName("TVGVICON", PU_HUDGFX); tagico = W_CachePatchName("TAGICO", PU_HUDGFX); rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); @@ -305,7 +309,9 @@ void ST_LoadGraphics(void) bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); gotrflag = W_CachePatchName("GOTRFLAG", PU_HUDGFX); gotbflag = W_CachePatchName("GOTBFLAG", PU_HUDGFX); + fnshico = W_CachePatchName("FNSHICO", PU_HUDGFX); nonicon = W_CachePatchName("NONICON", PU_HUDGFX); + nonicon2 = W_CachePatchName("NONICON2", PU_HUDGFX); // NiGHTS HUD things bluestat = W_CachePatchName("BLUESTAT", PU_HUDGFX); @@ -314,9 +320,14 @@ void ST_LoadGraphics(void) redstat = W_CachePatchName("REDSTAT", PU_HUDGFX); yelstat = W_CachePatchName("YELSTAT", PU_HUDGFX); nbracket = W_CachePatchName("NBRACKET", PU_HUDGFX); + nring = W_CachePatchName("NRNG1", PU_HUDGFX); for (i = 0; i < 12; ++i) + { nhud[i] = W_CachePatchName(va("NHUD%d", i+1), PU_HUDGFX); + nbon[i] = W_CachePatchName(va("NBON%d", i+1), PU_HUDGFX); + } nsshud = W_CachePatchName("NSSHUD", PU_HUDGFX); + nssbon = W_CachePatchName("NSSBON", PU_HUDGFX); minicaps = W_CachePatchName("MINICAPS", PU_HUDGFX); for (i = 0; i < 8; ++i) @@ -340,28 +351,33 @@ void ST_LoadGraphics(void) } // made separate so that skins code can reload custom face graphics -void ST_LoadFaceGraphics(char *facestr, char *superstr, INT32 skinnum) +void ST_LoadFaceGraphics(INT32 skinnum) { - faceprefix[skinnum] = W_CachePatchName(facestr, PU_HUDGFX); - superprefix[skinnum] = W_CachePatchName(superstr, PU_HUDGFX); + if (skins[skinnum].sprites[SPR2_XTRA].numframes > XTRA_LIFEPIC) + { + spritedef_t *sprdef = &skins[skinnum].sprites[SPR2_XTRA]; + spriteframe_t *sprframe = &sprdef->spriteframes[XTRA_LIFEPIC]; + faceprefix[skinnum] = W_CachePatchNum(sprframe->lumppat[0], PU_HUDGFX); + if (skins[skinnum].sprites[(SPR2_XTRA|FF_SPR2SUPER)].numframes > XTRA_LIFEPIC) + { + sprdef = &skins[skinnum].sprites[SPR2_XTRA|FF_SPR2SUPER]; + sprframe = &sprdef->spriteframes[0]; + superprefix[skinnum] = W_CachePatchNum(sprframe->lumppat[0], PU_HUDGFX); + } + else + superprefix[skinnum] = faceprefix[skinnum]; // not manually freed, okay to set to same pointer + } + else + faceprefix[skinnum] = superprefix[skinnum] = W_CachePatchName("MISSING", PU_HUDGFX); // ditto facefreed[skinnum] = false; } -#ifdef DELFILE -void ST_UnLoadFaceGraphics(INT32 skinnum) -{ - Z_Free(faceprefix[skinnum]); - Z_Free(superprefix[skinnum]); - facefreed[skinnum] = true; -} -#endif - void ST_ReloadSkinFaceGraphics(void) { INT32 i; for (i = 0; i < numskins; i++) - ST_LoadFaceGraphics(skins[i].face, skins[i].superface, i); + ST_LoadFaceGraphics(i); } static inline void ST_InitData(void) @@ -427,98 +443,22 @@ void ST_changeDemoView(void) boolean st_overlay; -static INT32 SCZ(INT32 z) -{ - return FixedInt(FixedMul(z<>= 1; - if (stplyr != &players[displayplayer]) - y += vid.height / 2; - } - return y; -} - -static INT32 STRINGY(INT32 y) -{ - //31/10/99: fixed by Hurdler so it _works_ also in hardware mode - // do not scale to resolution for hardware accelerated - // because these modes always scale by default - if (splitscreen) - { - y >>= 1; - if (stplyr != &players[displayplayer]) - y += BASEVIDHEIGHT / 2; - } - return y; -} - -static INT32 SPLITFLAGS(INT32 f) -{ - // Pass this V_SNAPTO(TOP|BOTTOM) and it'll trim them to account for splitscreen! -Red - if (splitscreen) - { - if (stplyr != &players[displayplayer]) - f &= ~V_SNAPTOTOP; - else - f &= ~V_SNAPTOBOTTOM; - } - return f; -} - -static INT32 SCX(INT32 x) -{ - return FixedInt(FixedMul(x<>= 1; - if (stplyr != &players[displayplayer]) - y += vid.height / 2; - } - return FixedInt(FixedDiv(y, vid.fdupy)); -} -#endif - // ========================================================================= // INTERNAL DRAWING // ========================================================================= -#define ST_DrawOverlayNum(x,y,n) V_DrawTallNum(x, y, V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPaddedOverlayNum(x,y,n,d) V_DrawPaddedTallNum(x, y, V_NOSCALESTART|V_HUDTRANS, n, d) -#define ST_DrawOverlayPatch(x,y,p) V_DrawScaledPatch(x, y, V_NOSCALESTART|V_HUDTRANS, p) -#define ST_DrawMappedOverlayPatch(x,y,p,c) V_DrawMappedScaledPatch(x, y, V_NOSCALESTART|V_HUDTRANS, p, c) -#define ST_DrawNumFromHud(h,n) V_DrawTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPadNumFromHud(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, n, q) -#define ST_DrawPatchFromHud(h,p) V_DrawScaledPatch(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART|V_HUDTRANS, p) -#define ST_DrawNumFromHudWS(h,n) V_DrawTallNum(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n) -#define ST_DrawPadNumFromHudWS(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, n, q) -#define ST_DrawPatchFromHudWS(h,p) V_DrawScaledPatch(SCX(hudinfo[h+!!splitscreen].x), SCY(hudinfo[h+!!splitscreen].y), V_NOSCALESTART|V_HUDTRANS, p) +#define ST_DrawTopLeftOverlayPatch(x,y,p) V_DrawScaledPatch(x, y, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, p) +#define ST_DrawNumFromHud(h,n,flags) V_DrawTallNum(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f|V_PERPLAYER|flags, n) +#define ST_DrawPadNumFromHud(h,n,q,flags) V_DrawPaddedTallNum(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f|V_PERPLAYER|flags, n, q) +#define ST_DrawPatchFromHud(h,p,flags) V_DrawScaledPatch(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f|V_PERPLAYER|flags, p) // Draw a number, scaled, over the view, maybe with set translucency // Always draw the number completely since it's overlay // // Supports different colors! woo! -static void ST_DrawNightsOverlayNum(INT32 x /* right border */, INT32 y, INT32 a, - INT32 num, patch_t **numpat, skincolors_t colornum) +static void ST_DrawNightsOverlayNum(fixed_t x /* right border */, fixed_t y, fixed_t s, INT32 a, + UINT32 num, patch_t **numpat, skincolors_t colornum) { - INT32 w = SHORT(numpat[0]->width); + fixed_t w = SHORT(numpat[0]->width)*s; const UINT8 *colormap; // I want my V_SNAPTOx flags. :< -Red @@ -529,65 +469,60 @@ static void ST_DrawNightsOverlayNum(INT32 x /* right border */, INT32 y, INT32 a else // Uses the player colors. colormap = R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE); - I_Assert(num >= 0); // this function does not draw negative numbers + //I_Assert(num >= 0); // this function does not draw negative numbers // draw the number do { x -= w; - V_DrawTranslucentMappedPatch(x, y, a, numpat[num % 10], colormap); + V_DrawFixedPatch(x, y, s, a, numpat[num % 10], colormap); num /= 10; } while (num); // Sorry chum, this function only draws UNSIGNED values! + // then why is num not UINT32? ~toast } // Devmode information static void ST_drawDebugInfo(void) { - INT32 height = 192; + INT32 height = 0, h = 8, w = 18, lowh; + void (*textfunc)(INT32, INT32, INT32, const char *); - if (!stplyr->mo) + if (!(stplyr->mo && cv_debug)) return; - if (cv_debug & DBG_BASIC) - { - const fixed_t d = AngleFixed(stplyr->mo->angle); - V_DrawRightAlignedString(320, 168, V_MONOSPACE, va("X: %6d", stplyr->mo->x>>FRACBITS)); - V_DrawRightAlignedString(320, 176, V_MONOSPACE, va("Y: %6d", stplyr->mo->y>>FRACBITS)); - V_DrawRightAlignedString(320, 184, V_MONOSPACE, va("Z: %6d", stplyr->mo->z>>FRACBITS)); - V_DrawRightAlignedString(320, 192, V_MONOSPACE, va("A: %6d", FixedInt(d))); +#define VFLAGS V_MONOSPACE|V_SNAPTOTOP|V_SNAPTORIGHT - height = 152; + if ((moviemode == MM_GIF && cv_gif_downscale.value) || vid.dupx == 1) + { + textfunc = V_DrawRightAlignedString; + lowh = ((vid.height/vid.dupy) - 16); + } + else + { + textfunc = V_DrawRightAlignedSmallString; + h /= 2; + w /= 2; + lowh = 0; } - if (cv_debug & DBG_DETAILED) +#define V_DrawDebugLine(str) if (lowh && (height > lowh))\ + {\ + V_DrawRightAlignedThinString(320, 8+lowh, VFLAGS|V_REDMAP, "SOME INFO NOT VISIBLE");\ + return;\ + }\ + textfunc(320, height, VFLAGS, str);\ + height += h; + +#define V_DrawDebugFlag(f, str) textfunc(width, height, VFLAGS|f, str);\ + width -= w + + if (cv_debug & DBG_MEMORY) { - V_DrawRightAlignedString(320, height - 104, V_MONOSPACE, va("SHIELD: %5x", stplyr->powers[pw_shield])); - V_DrawRightAlignedString(320, height - 96, V_MONOSPACE, va("SCALE: %5d%%", (stplyr->mo->scale*100)/FRACUNIT)); - V_DrawRightAlignedString(320, height - 88, V_MONOSPACE, va("DASH: %3d/%3d", stplyr->dashspeed>>FRACBITS, FixedMul(stplyr->maxdash,stplyr->mo->scale)>>FRACBITS)); - V_DrawRightAlignedString(320, height - 80, V_MONOSPACE, va("AIR: %4d, %3d", stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime])); + V_DrawDebugLine(va("Heap: %8sKB", sizeu1(Z_TotalUsage()>>10))); - // Flags - V_DrawRightAlignedString(304-64, height - 72, V_MONOSPACE, "Flags:"); - V_DrawString(304-60, height - 72, (stplyr->jumping) ? V_GREENMAP : V_REDMAP, "JM"); - V_DrawString(304-40, height - 72, (stplyr->pflags & PF_JUMPED) ? V_GREENMAP : V_REDMAP, "JD"); - V_DrawString(304-20, height - 72, (stplyr->pflags & PF_SPINNING) ? V_GREENMAP : V_REDMAP, "SP"); - V_DrawString(304, height - 72, (stplyr->pflags & PF_STARTDASH) ? V_GREENMAP : V_REDMAP, "ST"); - - V_DrawRightAlignedString(320, height - 64, V_MONOSPACE, va("CEILZ: %6d", stplyr->mo->ceilingz>>FRACBITS)); - V_DrawRightAlignedString(320, height - 56, V_MONOSPACE, va("FLOORZ: %6d", stplyr->mo->floorz>>FRACBITS)); - - V_DrawRightAlignedString(320, height - 48, V_MONOSPACE, va("CNVX: %6d", stplyr->cmomx>>FRACBITS)); - V_DrawRightAlignedString(320, height - 40, V_MONOSPACE, va("CNVY: %6d", stplyr->cmomy>>FRACBITS)); - V_DrawRightAlignedString(320, height - 32, V_MONOSPACE, va("PLTZ: %6d", stplyr->mo->pmomz>>FRACBITS)); - - V_DrawRightAlignedString(320, height - 24, V_MONOSPACE, va("MOMX: %6d", stplyr->rmomx>>FRACBITS)); - V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("MOMY: %6d", stplyr->rmomy>>FRACBITS)); - V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("MOMZ: %6d", stplyr->mo->momz>>FRACBITS)); - V_DrawRightAlignedString(320, height, V_MONOSPACE, va("SPEED: %6d", stplyr->speed>>FRACBITS)); - - height -= 120; + height += h/2; } if (cv_debug & DBG_RANDOMIZER) // randomizer testing @@ -596,40 +531,158 @@ static void ST_drawDebugInfo(void) peekres *= 10000; // Change from fixed point peekres >>= FRACBITS; // to displayable decimal - V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Init: %08x", P_GetInitSeed())); - V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Seed: %08x", P_GetRandSeed())); - V_DrawRightAlignedString(320, height, V_MONOSPACE, va("== : .%04d", peekres)); + V_DrawDebugLine(va("Init: %08x", P_GetInitSeed())); + V_DrawDebugLine(va("Seed: %08x", P_GetRandSeed())); + V_DrawDebugLine(va("== : .%04d", peekres)); - height -= 32; + height += h/2; } - if (cv_debug & DBG_MEMORY) + if (cv_debug & DBG_PLAYER) { - V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10))); + INT32 width = 320; + const fixed_t d = AngleFixed(stplyr->drawangle); + + V_DrawDebugLine(va("SHIELD: %5x", stplyr->powers[pw_shield])); + V_DrawDebugLine(va("SCALE: %5d%%", (stplyr->mo->scale*100)>>FRACBITS)); + V_DrawDebugLine(va("CARRY: %5x", stplyr->powers[pw_carry])); + V_DrawDebugLine(va("AIR: %4d, %3d", stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime])); + V_DrawDebugLine(va("ABILITY: %3d, %3d", stplyr->charability, stplyr->charability2)); + V_DrawDebugLine(va("ACTIONSPD: %5d", stplyr->actionspd>>FRACBITS)); + V_DrawDebugLine(va("PEEL: %3d", stplyr->dashmode)); + V_DrawDebugLine(va("SCOREADD: %3d", stplyr->scoreadd)); + + // Flags + V_DrawDebugFlag(((stplyr->pflags & PF_SHIELDABILITY) ? V_GREENMAP : V_REDMAP), "SH"); + V_DrawDebugFlag(((stplyr->pflags & PF_THOKKED) ? V_GREENMAP : V_REDMAP), "TH"); + V_DrawDebugFlag(((stplyr->pflags & PF_STARTDASH) ? V_GREENMAP : V_REDMAP), "ST"); + V_DrawDebugFlag(((stplyr->pflags & PF_SPINNING) ? V_GREENMAP : V_REDMAP), "SP"); + V_DrawDebugFlag(((stplyr->pflags & PF_NOJUMPDAMAGE) ? V_GREENMAP : V_REDMAP), "ND"); + V_DrawDebugFlag(((stplyr->pflags & PF_JUMPED) ? V_GREENMAP : V_REDMAP), "JD"); + V_DrawDebugFlag(((stplyr->pflags & PF_STARTJUMP) ? V_GREENMAP : V_REDMAP), "SJ"); + V_DrawDebugFlag(0, "PF/SF:"); + height += h; + width = 320; + V_DrawDebugFlag(((stplyr->pflags & PF_INVIS) ? V_GREENMAP : V_REDMAP), "*I"); + V_DrawDebugFlag(((stplyr->pflags & PF_NOCLIP) ? V_GREENMAP : V_REDMAP), "*C"); + V_DrawDebugFlag(((stplyr->pflags & PF_GODMODE) ? V_GREENMAP : V_REDMAP), "*G"); + V_DrawDebugFlag(((stplyr->charflags & SF_SUPER) ? V_GREENMAP : V_REDMAP), "SU"); + V_DrawDebugFlag(((stplyr->pflags & PF_APPLYAUTOBRAKE) ? V_GREENMAP : V_REDMAP), "AA"); + V_DrawDebugFlag(((stplyr->pflags & PF_SLIDING) ? V_GREENMAP : V_REDMAP), "SL"); + V_DrawDebugFlag(((stplyr->pflags & PF_BOUNCING) ? V_GREENMAP : V_REDMAP), "BO"); + V_DrawDebugFlag(((stplyr->pflags & PF_GLIDING) ? V_GREENMAP : V_REDMAP), "GL"); + height += h; + + V_DrawDebugLine(va("DRAWANGLE: %6d", FixedInt(d))); + + height += h/2; } + + if (cv_debug & DBG_DETAILED) + { + INT32 width = 320; + + V_DrawDebugLine(va("CEILINGZ: %6d", stplyr->mo->ceilingz>>FRACBITS)); + V_DrawDebugLine(va("FLOORZ: %6d", stplyr->mo->floorz>>FRACBITS)); + + V_DrawDebugLine(va("CMOMX: %6d", stplyr->cmomx>>FRACBITS)); + V_DrawDebugLine(va("CMOMY: %6d", stplyr->cmomy>>FRACBITS)); + V_DrawDebugLine(va("PMOMZ: %6d", stplyr->mo->pmomz>>FRACBITS)); + + width = 320; + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_APPLYPMOMZ) ? V_GREENMAP : V_REDMAP), "AP"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_SPRUNG) ? V_GREENMAP : V_REDMAP), "SP"); + //V_DrawDebugFlag(((stplyr->mo->eflags & MFE_PUSHED) ? V_GREENMAP : V_REDMAP), "PU"); -- not relevant to players + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_GOOWATER) ? V_GREENMAP : V_REDMAP), "GW"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_VERTICALFLIP) ? V_GREENMAP : V_REDMAP), "VF"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_JUSTSTEPPEDDOWN) ? V_GREENMAP : V_REDMAP), "JS"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_UNDERWATER) ? V_GREENMAP : V_REDMAP), "UW"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_TOUCHWATER) ? V_GREENMAP : V_REDMAP), "TW"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_JUSTHITFLOOR) ? V_GREENMAP : V_REDMAP), "JH"); + V_DrawDebugFlag(((stplyr->mo->eflags & MFE_ONGROUND) ? V_GREENMAP : V_REDMAP), "OG"); + V_DrawDebugFlag(0, "MFE:"); + height += h; + + V_DrawDebugLine(va("MOMX: %6d", stplyr->rmomx>>FRACBITS)); + V_DrawDebugLine(va("MOMY: %6d", stplyr->rmomy>>FRACBITS)); + V_DrawDebugLine(va("MOMZ: %6d", stplyr->mo->momz>>FRACBITS)); + + V_DrawDebugLine(va("SPEED: %6d", stplyr->speed>>FRACBITS)); + + height += h/2; + } + + if (cv_debug & DBG_BASIC) + { + const fixed_t d = AngleFixed(stplyr->mo->angle); + V_DrawDebugLine(va("X: %6d", stplyr->mo->x>>FRACBITS)); + V_DrawDebugLine(va("Y: %6d", stplyr->mo->y>>FRACBITS)); + V_DrawDebugLine(va("Z: %6d", stplyr->mo->z>>FRACBITS)); + V_DrawDebugLine(va("A: %6d", FixedInt(d))); + + //height += h/2; + } + +#undef V_DrawDebugFlag +#undef V_DrawDebugLine +#undef VFLAGS } static void ST_drawScore(void) { + if (F_GetPromptHideHud(hudinfo[HUD_SCORE].y)) + return; + // SCORE: - ST_DrawPatchFromHud(HUD_SCORE, sboscore); + ST_DrawPatchFromHud(HUD_SCORE, sboscore, V_HUDTRANS); if (objectplacing) { if (op_displayflags > UINT16_MAX) - ST_DrawOverlayPatch(SCX(hudinfo[HUD_SCORENUM].x-tallminus->width), SCY(hudinfo[HUD_SCORENUM].y), tallminus); + ST_DrawTopLeftOverlayPatch((hudinfo[HUD_SCORENUM].x-tallminus->width), hudinfo[HUD_SCORENUM].y, tallminus); else - ST_DrawNumFromHud(HUD_SCORENUM, op_displayflags); + ST_DrawNumFromHud(HUD_SCORENUM, op_displayflags, V_HUDTRANS); } else - ST_DrawNumFromHud(HUD_SCORENUM, stplyr->score); + ST_DrawNumFromHud(HUD_SCORENUM, stplyr->score, V_HUDTRANS); +} + +static void ST_drawRaceNum(INT32 time) +{ + INT32 height, bounce; + patch_t *racenum; + + time += TICRATE; + height = ((3*BASEVIDHEIGHT)>>2) - 8; + bounce = TICRATE - (1 + (time % TICRATE)); + + switch (time/TICRATE) + { + case 3: + racenum = race3; + break; + case 2: + racenum = race2; + break; + case 1: + racenum = race1; + break; + default: + racenum = racego; + break; + } + if (bounce < 3) + { + height -= (2 - bounce); + if (!(P_AutoPause() || paused) && !bounce) + S_StartSound(0, ((racenum == racego) ? sfx_s3kad : sfx_s3ka7)); + } + V_DrawScaledPatch(((BASEVIDWIDTH - SHORT(racenum->width))/2), height, V_PERPLAYER, racenum); } static void ST_drawTime(void) { INT32 seconds, minutes, tictrn, tics; - - // TIME: - ST_DrawPatchFromHudWS(HUD_TIME, sbotime); + boolean downwards = false; if (objectplacing) { @@ -640,481 +693,1133 @@ static void ST_drawTime(void) } else { - tics = stplyr->realtime; - seconds = G_TicsToSeconds(tics); + // Counting down the hidetime? + if ((gametyperules & GTR_STARTCOUNTDOWN) && (stplyr->realtime <= (hidetime*TICRATE))) + { + tics = (hidetime*TICRATE - stplyr->realtime); + if (tics < 3*TICRATE) + ST_drawRaceNum(tics); + tics += (TICRATE-1); // match the race num + downwards = true; + } + else + { + // Hidetime finish! + if ((gametyperules & GTR_STARTCOUNTDOWN) && (stplyr->realtime < ((hidetime+1)*TICRATE))) + ST_drawRaceNum(hidetime*TICRATE - stplyr->realtime); + + // Time limit? + if ((gametyperules & GTR_TIMELIMIT) && cv_timelimit.value && timelimitintics > 0) + { + if (timelimitintics > stplyr->realtime) + { + tics = (timelimitintics - stplyr->realtime); + if (tics < 3*TICRATE) + ST_drawRaceNum(tics); + tics += (TICRATE-1); // match the race num + } + else // Overtime! + tics = 0; + downwards = true; + } + // Post-hidetime normal. + else if (gametyperules & GTR_STARTCOUNTDOWN) + tics = stplyr->realtime - hidetime*TICRATE; + // "Shadow! What are you doing? Hurry and get back here + // right now before the island blows up with you on it!" + // "Blows up??" *awkward silence* "I've got to get outta + // here and find Amy and Tails right away!" + else if (mapheaderinfo[gamemap-1]->countdown) + { + tics = countdowntimer; + downwards = true; + } + // Normal. + else + tics = stplyr->realtime; + } + minutes = G_TicsToMinutes(tics, true); + seconds = G_TicsToSeconds(tics); tictrn = G_TicsToCentiseconds(tics); } - if (cv_timetic.value == 1) // Tics only -- how simple is this? - ST_DrawNumFromHudWS(HUD_SECONDS, tics); + if (F_GetPromptHideHud(hudinfo[HUD_TIME].y)) + return; + + downwards = (downwards && (tics < 30*TICRATE) && (leveltime/5 & 1) && !stoppedclock); // overtime? + + // TIME: + ST_DrawPatchFromHud(HUD_TIME, (downwards ? sboredtime : sbotime), V_HUDTRANS); + + if (downwards) // overtime! + return; + + if (cv_timetic.value == 3) // Tics only -- how simple is this? + ST_DrawNumFromHud(HUD_SECONDS, tics, V_HUDTRANS); else { - ST_DrawNumFromHudWS(HUD_MINUTES, minutes); // Minutes - ST_DrawPatchFromHudWS(HUD_TIMECOLON, sbocolon); // Colon - ST_DrawPadNumFromHudWS(HUD_SECONDS, seconds, 2); // Seconds + ST_DrawNumFromHud(HUD_MINUTES, minutes, V_HUDTRANS); // Minutes + ST_DrawPatchFromHud(HUD_TIMECOLON, sbocolon, V_HUDTRANS); // Colon + ST_DrawPadNumFromHud(HUD_SECONDS, seconds, 2, V_HUDTRANS); // Seconds - if (!splitscreen && (cv_timetic.value == 2 || modeattacking)) // there's not enough room for tics in splitscreen, don't even bother trying! + if (cv_timetic.value == 1 || cv_timetic.value == 2 || modeattacking) // there's not enough room for tics in splitscreen, don't even bother trying! { - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics + ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod, V_HUDTRANS); // Period + ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2, V_HUDTRANS); // Tics } } } static inline void ST_drawRings(void) { - INT32 ringnum = max(stplyr->health-1, 0); + INT32 ringnum; - ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->health <= 1 && leveltime/5 & 1) ? rrings : sborings)); + if (F_GetPromptHideHud(hudinfo[HUD_RINGS].y)) + return; + + ST_DrawPatchFromHud(HUD_RINGS, ((!stplyr->spectator && stplyr->rings <= 0 && leveltime/5 & 1) ? sboredrings : sborings), ((stplyr->spectator) ? V_HUDTRANSHALF : V_HUDTRANS)); if (objectplacing) ringnum = op_currentdoomednum; - else if (!useNightsSS && G_IsSpecialStage(gamemap)) - { - INT32 i; + else if (stplyr->rings < 0 || stplyr->spectator || stplyr->playerstate == PST_REBORN) ringnum = 0; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].mo->health > 1) - ringnum += players[i].mo->health - 1; - } + else + ringnum = stplyr->rings; - ST_DrawNumFromHudWS(HUD_RINGSNUM, ringnum); + if (cv_timetic.value == 2) // Yes, even in modeattacking + ST_DrawNumFromHud(HUD_RINGSNUMTICS, ringnum, V_PERPLAYER|((stplyr->spectator) ? V_HUDTRANSHALF : V_HUDTRANS)); + else + ST_DrawNumFromHud(HUD_RINGSNUM, ringnum, V_PERPLAYER|((stplyr->spectator) ? V_HUDTRANSHALF : V_HUDTRANS)); } -static void ST_drawLives(void) +static void ST_drawLivesArea(void) { - const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayer] ? V_SPLITSCREEN : 0); + INT32 v_colmap = V_YELLOWMAP, livescount; + boolean notgreyedout; if (!stplyr->skincolor) return; // Just joined a server, skin isn't loaded yet! + if (F_GetPromptHideHud(hudinfo[HUD_LIVES].y)) + return; + // face background - V_DrawSmallScaledPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, livesback); + V_DrawSmallScaledPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, + hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, livesback); // face - if (stplyr->mo && stplyr->mo->color) + if (stplyr->spectator) + { + // spectator face + UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, SKINCOLOR_CLOUDY, GTC_CACHE); + V_DrawSmallMappedPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, + hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANSHALF, faceprefix[stplyr->skin], colormap); + } + else if (stplyr->mo && stplyr->mo->color) { // skincolor face/super UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->mo->color, GTC_CACHE); patch_t *face = faceprefix[stplyr->skin]; - if (stplyr->powers[pw_super] || stplyr->pflags & PF_NIGHTSMODE) + if (stplyr->powers[pw_super]) face = superprefix[stplyr->skin]; - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,face, colormap); + V_DrawSmallMappedPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, + hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, face, colormap); + if (st_translucency == 10 && stplyr->powers[pw_super] == 1 && stplyr->mo->tracer) + { + INT32 v_supertrans = (stplyr->mo->tracer->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; + if (v_supertrans < 10) + { + v_supertrans <<= V_ALPHASHIFT; + colormap = R_GetTranslationColormap(stplyr->skin, stplyr->mo->tracer->color, GTC_CACHE); + V_DrawSmallMappedPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, + hudinfo[HUD_LIVES].f|V_PERPLAYER|v_supertrans, face, colormap); + } + } } else if (stplyr->skincolor) { // skincolor face UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,faceprefix[stplyr->skin], colormap); + V_DrawSmallMappedPatch(hudinfo[HUD_LIVES].x, hudinfo[HUD_LIVES].y, + hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, faceprefix[stplyr->skin], colormap); + } + + // Metal Sonic recording + if (metalrecording) + { + if (((2*leveltime)/TICRATE) & 1) + V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, + hudinfo[HUD_LIVES].f|V_PERPLAYER|V_REDMAP|V_HUDTRANS, "REC"); + } + // Spectator + else if (stplyr->spectator) + v_colmap = V_GRAYMAP; + // Tag + else if (gametyperules & GTR_TAG) + { + if (stplyr->pflags & PF_TAGIT) + { + V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "IT!"); + v_colmap = V_ORANGEMAP; + } + } + // Team name + else if (G_GametypeHasTeams()) + { + if (stplyr->ctfteam == 1) + { + V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "RED"); + v_colmap = V_REDMAP; + } + else if (stplyr->ctfteam == 2) + { + V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, "BLUE"); + v_colmap = V_BLUEMAP; + } + } + // Lives number + else + { + boolean candrawlives = true; + + // Co-op and Competition, normal life counter + if (G_GametypeUsesLives()) + { + // Handle cooplives here + if ((netgame || multiplayer) && G_GametypeUsesCoopLives() && cv_cooplives.value == 3) + { + INT32 i; + livescount = 0; + notgreyedout = (stplyr->lives > 0); + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (players[i].lives < 1) + continue; + + if (players[i].lives > 1) + notgreyedout = true; + + if (players[i].lives == INFLIVES) + { + livescount = INFLIVES; + break; + } + else if (livescount < 99) + livescount += (players[i].lives); + } + } + else + { + livescount = (((netgame || multiplayer) && G_GametypeUsesCoopLives() && cv_cooplives.value == 0) ? INFLIVES : stplyr->lives); + notgreyedout = true; + } + } + // Infinity symbol (Race) + else if (G_PlatformGametype() && !(gametyperules & GTR_LIVES)) + { + livescount = INFLIVES; + notgreyedout = true; + } + // Otherwise nothing, sorry. + // Special Stages keep not showing lives, + // as G_GametypeUsesLives() returns false in + // Special Stages, and the infinity symbol + // cannot show up because Special Stages + // still have the GTR_LIVES gametype rule + // by default. + else + candrawlives = false; + + // Draw the lives counter here. + if (candrawlives) + { + // x + V_DrawScaledPatch(hudinfo[HUD_LIVES].x+22, hudinfo[HUD_LIVES].y+10, hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, stlivex); + if (livescount == INFLIVES) + V_DrawCharacter(hudinfo[HUD_LIVES].x+50, hudinfo[HUD_LIVES].y+8, + '\x16' | 0x80 | hudinfo[HUD_LIVES].f|V_PERPLAYER|V_HUDTRANS, false); + else + { + if (stplyr->playerstate == PST_DEAD && !(stplyr->spectator) && (livescount || stplyr->deadtimer < (TICRATE<<1)) && !(stplyr->pflags & PF_FINISHED)) + livescount++; + if (livescount > 99) + livescount = 99; + V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y+8, + hudinfo[HUD_LIVES].f|V_PERPLAYER|(notgreyedout ? V_HUDTRANS : V_HUDTRANSHALF), va("%d",livescount)); + } + } +#undef ST_drawLivesX } // name - if (strlen(skins[stplyr->skin].hudname) > 8) - V_DrawThinString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); + v_colmap |= (V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER); + if (strlen(skins[stplyr->skin].hudname) <= 5) + V_DrawRightAlignedString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y, v_colmap, skins[stplyr->skin].hudname); + else if (V_StringWidth(skins[stplyr->skin].hudname, v_colmap) <= 48) + V_DrawString(hudinfo[HUD_LIVES].x+18, hudinfo[HUD_LIVES].y, v_colmap, skins[stplyr->skin].hudname); + else if (V_ThinStringWidth(skins[stplyr->skin].hudname, v_colmap) <= 40) + V_DrawRightAlignedThinString(hudinfo[HUD_LIVES].x+58, hudinfo[HUD_LIVES].y, v_colmap, skins[stplyr->skin].hudname); else - V_DrawString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - // x - V_DrawScaledPatch(hudinfo[HUD_LIVESX].x, hudinfo[HUD_LIVESX].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, stlivex); - // lives - V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, va("%d",stplyr->lives)); + V_DrawThinString(hudinfo[HUD_LIVES].x+18, hudinfo[HUD_LIVES].y, v_colmap, skins[stplyr->skin].hudname); + + // Power Stones collected + if (G_RingSlingerGametype() && LUA_HudEnabled(hud_powerstones)) + { + INT32 workx = hudinfo[HUD_LIVES].x+1, j; + if ((leveltime & 1) && stplyr->powers[pw_invulnerability] && (stplyr->powers[pw_sneakers] == stplyr->powers[pw_invulnerability])) // hack; extremely unlikely to be activated unintentionally + { + for (j = 0; j < 7; ++j) // "super" indicator + { + V_DrawScaledPatch(workx, hudinfo[HUD_LIVES].y-9, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, emeraldpics[1][j]); + workx += 8; + } + } + else + { + for (j = 0; j < 7; ++j) // powerstones + { + if (stplyr->powers[pw_emeralds] & (1 << j)) + V_DrawScaledPatch(workx, hudinfo[HUD_LIVES].y-9, V_HUDTRANS|hudinfo[HUD_LIVES].f|V_PERPLAYER, emeraldpics[1][j]); + workx += 8; + } + } + } } -static void ST_drawLevelTitle(void) +static void ST_drawInput(void) +{ + const INT32 accent = V_SNAPTOLEFT|V_SNAPTOBOTTOM|(stplyr->skincolor ? Color_Index[stplyr->skincolor-1][4] : 0); + INT32 col; + UINT8 offs; + + INT32 x = hudinfo[HUD_LIVES].x, y = hudinfo[HUD_LIVES].y; + + if (stplyr->powers[pw_carry] == CR_NIGHTSMODE) + y -= 16; + + if (F_GetPromptHideHud(y)) + return; + + // O backing + V_DrawFill(x, y-1, 16, 16, hudinfo[HUD_LIVES].f|20); + V_DrawFill(x, y+15, 16, 1, hudinfo[HUD_LIVES].f|29); + + if (cv_showinputjoy.value) // joystick render! + { + /*V_DrawFill(x , y , 16, 1, hudinfo[HUD_LIVES].f|16); + V_DrawFill(x , y+15, 16, 1, hudinfo[HUD_LIVES].f|16); + V_DrawFill(x , y+ 1, 1, 14, hudinfo[HUD_LIVES].f|16); + V_DrawFill(x+15, y+ 1, 1, 14, hudinfo[HUD_LIVES].f|16); -- red's outline*/ + if (stplyr->cmd.sidemove || stplyr->cmd.forwardmove) + { + // joystick hole + V_DrawFill(x+5, y+4, 6, 6, hudinfo[HUD_LIVES].f|29); + // joystick top + V_DrawFill(x+3+stplyr->cmd.sidemove/12, + y+2-stplyr->cmd.forwardmove/12, + 10, 10, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+3+stplyr->cmd.sidemove/9, + y+1-stplyr->cmd.forwardmove/9, + 10, 10, accent); + } + else + { + // just a limited, greyed out joystick top + V_DrawFill(x+3, y+11, 10, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+3, + y+1, + 10, 10, hudinfo[HUD_LIVES].f|16); + } + } + else // arrows! + { + // < + if (stplyr->cmd.sidemove < 0) + { + offs = 0; + col = accent; + } + else + { + offs = 1; + col = hudinfo[HUD_LIVES].f|16; + V_DrawFill(x- 2, y+10, 6, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+ 4, y+ 9, 1, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+ 5, y+ 8, 1, 1, hudinfo[HUD_LIVES].f|29); + } + V_DrawFill(x- 2, y+ 5-offs, 6, 6, col); + V_DrawFill(x+ 4, y+ 6-offs, 1, 4, col); + V_DrawFill(x+ 5, y+ 7-offs, 1, 2, col); + + // ^ + if (stplyr->cmd.forwardmove > 0) + { + offs = 0; + col = accent; + } + else + { + offs = 1; + col = hudinfo[HUD_LIVES].f|16; + V_DrawFill(x+ 5, y+ 3, 1, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+ 6, y+ 4, 1, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+ 7, y+ 5, 2, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+ 9, y+ 4, 1, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+10, y+ 3, 1, 1, hudinfo[HUD_LIVES].f|29); + } + V_DrawFill(x+ 5, y- 2-offs, 6, 6, col); + V_DrawFill(x+ 6, y+ 4-offs, 4, 1, col); + V_DrawFill(x+ 7, y+ 5-offs, 2, 1, col); + + // > + if (stplyr->cmd.sidemove > 0) + { + offs = 0; + col = accent; + } + else + { + offs = 1; + col = hudinfo[HUD_LIVES].f|16; + V_DrawFill(x+12, y+10, 6, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+11, y+ 9, 1, 1, hudinfo[HUD_LIVES].f|29); + V_DrawFill(x+10, y+ 8, 1, 1, hudinfo[HUD_LIVES].f|29); + } + V_DrawFill(x+12, y+ 5-offs, 6, 6, col); + V_DrawFill(x+11, y+ 6-offs, 1, 4, col); + V_DrawFill(x+10, y+ 7-offs, 1, 2, col); + + // v + if (stplyr->cmd.forwardmove < 0) + { + offs = 0; + col = accent; + } + else + { + offs = 1; + col = hudinfo[HUD_LIVES].f|16; + V_DrawFill(x+ 5, y+17, 6, 1, hudinfo[HUD_LIVES].f|29); + } + V_DrawFill(x+ 5, y+12-offs, 6, 6, col); + V_DrawFill(x+ 6, y+11-offs, 4, 1, col); + V_DrawFill(x+ 7, y+10-offs, 2, 1, col); + } + +#define drawbutt(xoffs, yoffs, butt, symb)\ + if (stplyr->cmd.buttons & butt)\ + {\ + offs = 0;\ + col = accent;\ + }\ + else\ + {\ + offs = 1;\ + col = hudinfo[HUD_LIVES].f|16;\ + V_DrawFill(x+16+(xoffs), y+9+(yoffs), 10, 1, hudinfo[HUD_LIVES].f|29);\ + }\ + V_DrawFill(x+16+(xoffs), y+(yoffs)-offs, 10, 10, col);\ + V_DrawCharacter(x+16+1+(xoffs), y+1+(yoffs)-offs, hudinfo[HUD_LIVES].f|symb, false) + + drawbutt( 4,-3, BT_JUMP, 'J'); + drawbutt(15,-3, BT_USE, 'S'); + + V_DrawFill(x+16+4, y+8, 21, 10, hudinfo[HUD_LIVES].f|20); // sundial backing + if (stplyr->mo) + { + UINT8 i, precision; + angle_t ang = (stplyr->powers[pw_carry] == CR_NIGHTSMODE) + ? (FixedAngle((stplyr->flyangle-90)<>ANGLETOFINESHIFT) + : (stplyr->mo->angle - R_PointToAngle(stplyr->mo->x, stplyr->mo->y))>>ANGLETOFINESHIFT; + fixed_t xcomp = FINESINE(ang)>>13; + fixed_t ycomp = FINECOSINE(ang)>>14; + if (ycomp == 4) + ycomp = 3; + + if (ycomp > 0) + V_DrawFill(x+16+13-xcomp, y+11-ycomp, 3, 3, accent); // point (behind) + + precision = max(3, abs(xcomp)); + for (i = 0; i < precision; i++) // line + { + V_DrawFill(x+16+14-(i*xcomp)/precision, + y+12-(i*ycomp)/precision, + 1, 1, hudinfo[HUD_LIVES].f|16); + } + + if (ycomp <= 0) + V_DrawFill(x+16+13-xcomp, y+11-ycomp, 3, 3, accent); // point (in front) + } + +#undef drawbutt + + // text above + x -= 2; + y -= 13; + if (stplyr->powers[pw_carry] != CR_NIGHTSMODE) + { + if (stplyr->pflags & PF_AUTOBRAKE) + { + V_DrawThinString(x, y, + hudinfo[HUD_LIVES].f| + ((!stplyr->powers[pw_carry] + && (stplyr->pflags & PF_APPLYAUTOBRAKE) + && !(stplyr->cmd.sidemove || stplyr->cmd.forwardmove) + && (stplyr->rmomx || stplyr->rmomy) + && (!stplyr->capsule || (stplyr->capsule->reactiontime != (stplyr-players)+1))) + ? 0 : V_GRAYMAP), + "AUTOBRAKE"); + y -= 8; + } + switch (P_ControlStyle(stplyr)) + { + case CS_LMAOGALOG: + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "ANALOG"); + y -= 8; + break; + + case CS_SIMPLE: + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "SIMPLE"); + y -= 8; + break; + + default: + break; + } + } + if (!demosynced) // should always be last, so it doesn't push anything else around + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f|((leveltime & 4) ? V_YELLOWMAP : V_REDMAP), "BAD DEMO!!"); +} + +static patch_t *lt_patches[3]; +static INT32 lt_scroll = 0; +static INT32 lt_mom = 0; +static INT32 lt_zigzag = 0; + +tic_t lt_ticker = 0, lt_lasttic = 0; +tic_t lt_exitticker = 0, lt_endtime = 0; + +// +// Load the graphics for the title card. +// Don't let LJ see this +// +static void ST_cacheLevelTitle(void) +{ +#define SETPATCH(default, warning, custom, idx) \ +{ \ + lumpnum_t patlumpnum = LUMPERROR; \ + if (mapheaderinfo[gamemap-1]->custom[0] != '\0') \ + { \ + patlumpnum = W_CheckNumForName(mapheaderinfo[gamemap-1]->custom); \ + if (patlumpnum != LUMPERROR) \ + lt_patches[idx] = (patch_t *)W_CachePatchNum(patlumpnum, PU_HUDGFX); \ + } \ + if (patlumpnum == LUMPERROR) \ + { \ + if (!(mapheaderinfo[gamemap-1]->levelflags & LF_WARNINGTITLE)) \ + lt_patches[idx] = (patch_t *)W_CachePatchName(default, PU_HUDGFX); \ + else \ + lt_patches[idx] = (patch_t *)W_CachePatchName(warning, PU_HUDGFX); \ + } \ +} + + SETPATCH("LTACTBLU", "LTACTRED", ltactdiamond, 0) + SETPATCH("LTZIGZAG", "LTZIGRED", ltzzpatch, 1) + SETPATCH("LTZZTEXT", "LTZZWARN", ltzztext, 2) + +#undef SETPATCH +} + +// +// Start the title card. +// +void ST_startTitleCard(void) +{ + // cache every HUD patch used + ST_cacheLevelTitle(); + + // initialize HUD variables + lt_ticker = lt_exitticker = lt_lasttic = 0; + lt_endtime = 2*TICRATE + (10*NEWTICRATERATIO); + lt_scroll = BASEVIDWIDTH * FRACUNIT; + lt_zigzag = -((lt_patches[1])->width * FRACUNIT); + lt_mom = 0; +} + +// +// What happens before drawing the title card. +// Which is just setting the HUD translucency. +// +void ST_preDrawTitleCard(void) +{ + if (!G_IsTitleCardAvailable()) + return; + + if (lt_ticker >= (lt_endtime + TICRATE)) + return; + + if (!lt_exitticker) + st_translucency = 0; + else + st_translucency = max(0, min((INT32)lt_exitticker-4, cv_translucenthud.value)); +} + +// +// Run the title card. +// Called from ST_Ticker. +// +void ST_runTitleCard(void) +{ + boolean run = !(paused || P_AutoPause()); + + if (!G_IsTitleCardAvailable()) + return; + + if (lt_ticker >= (lt_endtime + TICRATE)) + return; + + if (run || (lt_ticker < PRELEVELTIME)) + { + // tick + lt_ticker++; + if (lt_ticker >= lt_endtime) + lt_exitticker++; + + // scroll to screen (level title) + if (!lt_exitticker) + { + if (abs(lt_scroll) > FRACUNIT) + lt_scroll -= (lt_scroll>>2); + else + lt_scroll = 0; + } + // scroll away from screen (level title) + else + { + lt_mom -= FRACUNIT*6; + lt_scroll += lt_mom; + } + + // scroll to screen (zigzag) + if (!lt_exitticker) + { + if (abs(lt_zigzag) > FRACUNIT) + lt_zigzag -= (lt_zigzag>>2); + else + lt_zigzag = 0; + } + // scroll away from screen (zigzag) + else + lt_zigzag += lt_mom; + } +} + +// +// Draw the title card itself. +// +void ST_drawTitleCard(void) { char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl; char *subttl = mapheaderinfo[gamemap-1]->subttl; INT32 actnum = mapheaderinfo[gamemap-1]->actnum; - INT32 lvlttlxpos; + INT32 lvlttlxpos, ttlnumxpos, zonexpos; INT32 subttlxpos = BASEVIDWIDTH/2; - INT32 ttlnumxpos; - INT32 zonexpos; + INT32 ttlscroll = FixedInt(lt_scroll); + INT32 zzticker; + patch_t *actpat, *zigzag, *zztext; - INT32 lvlttly; - INT32 zoney; - - if (!(timeinmap > 2 && timeinmap-3 < 110)) + if (!G_IsTitleCardAvailable()) return; + if (!LUA_HudEnabled(hud_stagetitle)) + goto luahook; + + if (lt_ticker >= (lt_endtime + TICRATE)) + goto luahook; + + if ((lt_ticker-lt_lasttic) > 1) + lt_ticker = lt_lasttic+1; + + ST_cacheLevelTitle(); + actpat = lt_patches[0]; + zigzag = lt_patches[1]; + zztext = lt_patches[2]; + + lvlttlxpos = ((BASEVIDWIDTH/2) - (V_LevelNameWidth(lvlttl)/2)); + if (actnum > 0) - { - ttlnum = W_CachePatchName(va("TTL%.2d", actnum), PU_CACHE); - lvlttlxpos = ((BASEVIDWIDTH/2) - (V_LevelNameWidth(lvlttl)/2)) - SHORT(ttlnum->width); - } - else - lvlttlxpos = ((BASEVIDWIDTH/2) - (V_LevelNameWidth(lvlttl)/2)); + lvlttlxpos -= V_LevelActNumWidth(actnum); ttlnumxpos = lvlttlxpos + V_LevelNameWidth(lvlttl); - zonexpos = ttlnumxpos - V_LevelNameWidth(M_GetText("ZONE")); + zonexpos = ttlnumxpos - V_LevelNameWidth(M_GetText("Zone")); + ttlnumxpos++; if (lvlttlxpos < 0) lvlttlxpos = 0; - // There's no consistent algorithm that can accurately define the old positions - // so I just ended up resorting to a single switct statement to define them - switch (timeinmap-3) + if (!splitscreen || (splitscreen && stplyr == &players[displayplayer])) { - case 0: zoney = 200; lvlttly = 0; break; - case 1: zoney = 188; lvlttly = 12; break; - case 2: zoney = 176; lvlttly = 24; break; - case 3: zoney = 164; lvlttly = 36; break; - case 4: zoney = 152; lvlttly = 48; break; - case 5: zoney = 140; lvlttly = 60; break; - case 6: zoney = 128; lvlttly = 72; break; - case 105: zoney = 80; lvlttly = 104; break; - case 106: zoney = 56; lvlttly = 128; break; - case 107: zoney = 32; lvlttly = 152; break; - case 108: zoney = 8; lvlttly = 176; break; - case 109: zoney = 0; lvlttly = 200; break; - default: zoney = 104; lvlttly = 80; break; + zzticker = lt_ticker; + V_DrawScaledPatch(FixedInt(lt_zigzag), (-zzticker) % zigzag->height, V_SNAPTOTOP|V_SNAPTOLEFT, zigzag); + V_DrawScaledPatch(FixedInt(lt_zigzag), (zigzag->height-zzticker) % zigzag->height, V_SNAPTOTOP|V_SNAPTOLEFT, zigzag); + V_DrawScaledPatch(FixedInt(lt_zigzag), (-zigzag->height+zzticker) % zztext->height, V_SNAPTOTOP|V_SNAPTOLEFT, zztext); + V_DrawScaledPatch(FixedInt(lt_zigzag), (zzticker) % zztext->height, V_SNAPTOTOP|V_SNAPTOLEFT, zztext); } if (actnum) - V_DrawScaledPatch(ttlnumxpos, zoney, 0, ttlnum); - - V_DrawLevelTitle(lvlttlxpos, lvlttly, 0, lvlttl); + { + if (!splitscreen) + V_DrawScaledPatch(ttlnumxpos + ttlscroll, 104 - ttlscroll, 0, actpat); + V_DrawLevelActNum(ttlnumxpos + ttlscroll, 104, V_PERPLAYER, actnum); + } + V_DrawLevelTitle(lvlttlxpos - ttlscroll, 80, V_PERPLAYER, lvlttl); if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - V_DrawLevelTitle(zonexpos, zoney, 0, M_GetText("ZONE")); + V_DrawLevelTitle(zonexpos + ttlscroll, 104, V_PERPLAYER, M_GetText("Zone")); + V_DrawCenteredString(subttlxpos - ttlscroll, 135, V_PERPLAYER|V_ALLOWLOWERCASE, subttl); - if (lvlttly+48 < 200) - V_DrawCenteredString(subttlxpos, lvlttly+48, V_ALLOWLOWERCASE, subttl); + lt_lasttic = lt_ticker; + +luahook: + LUAh_TitleCardHUD(stplyr); +} + +// +// Drawer for G_PreLevelTitleCard. +// +void ST_preLevelTitleCardDrawer(void) +{ + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); + ST_drawWipeTitleCard(); + I_OsPolling(); + I_UpdateNoBlit(); +} + +// +// Draw the title card while on a wipe. +// Also used in G_PreLevelTitleCard. +// +void ST_drawWipeTitleCard(void) +{ + stplyr = &players[consoleplayer]; + ST_preDrawTitleCard(); + ST_drawTitleCard(); + if (splitscreen) + { + stplyr = &players[secondarydisplayplayer]; + ST_preDrawTitleCard(); + ST_drawTitleCard(); + } +} + +static void ST_drawPowerupHUD(void) +{ + patch_t *p = NULL; + UINT16 invulntime = 0; + INT32 offs = hudinfo[HUD_POWERUPS].x; + const UINT8 q = ((splitscreen && stplyr == &players[secondarydisplayplayer]) ? 1 : 0); + static INT32 flagoffs[2] = {0, 0}, shieldoffs[2] = {0, 0}, finishoffs[2] = {0, 0}; +#define ICONSEP (16+4) // matches weapon rings HUD + + if (F_GetPromptHideHud(hudinfo[HUD_POWERUPS].y)) + return; + + if (stplyr->spectator || stplyr->playerstate != PST_LIVE) + return; + +// --------- +// Finish icon +// --------- + + // Let's have a power-like icon to represent finishing the level! + if (stplyr->pflags & PF_FINISHED && cv_exitmove.value) + { + finishoffs[q] = ICONSEP; + V_DrawSmallScaledPatch(offs, hudinfo[HUD_POWERUPS].y, V_PERPLAYER|hudinfo[HUD_POWERUPS].f|V_HUDTRANS, fnshico); + } + else if (finishoffs[q]) + { + if (finishoffs[q] > 1) + finishoffs[q] = 2*finishoffs[q]/3; + else + finishoffs[q] = 0; + } + + offs -= finishoffs[q]; + +// ------- +// Shields +// ------- + + // Graue 06-18-2004: no V_NOSCALESTART, no SCX, no SCY, snap to right + if (stplyr->powers[pw_shield] & SH_NOSTACK) + { + shieldoffs[q] = ICONSEP; + + if ((stplyr->powers[pw_shield] & SH_NOSTACK & ~SH_FORCEHP) == SH_FORCE) + { + UINT8 i, max = (stplyr->powers[pw_shield] & SH_FORCEHP); + for (i = 0; i <= max; i++) + { + V_DrawSmallScaledPatch(offs-(i<<1), hudinfo[HUD_POWERUPS].y-(i<<1), (V_PERPLAYER|hudinfo[HUD_POWERUPS].f)|((i == max) ? V_HUDTRANS : V_HUDTRANSHALF), forceshield); + } + } + else + { + switch (stplyr->powers[pw_shield] & SH_NOSTACK) + { + case SH_WHIRLWIND: p = jumpshield; break; + case SH_ELEMENTAL: p = watershield; break; + case SH_ARMAGEDDON: p = bombshield; break; + case SH_ATTRACT: p = ringshield; break; + case SH_PITY: p = pityshield; break; + case SH_PINK: p = pinkshield; break; + case SH_FLAMEAURA: p = flameshield; break; + case SH_BUBBLEWRAP: p = bubbleshield; break; + case SH_THUNDERCOIN: p = thundershield; break; + default: break; + } + + if (p) + V_DrawSmallScaledPatch(offs, hudinfo[HUD_POWERUPS].y, V_PERPLAYER|hudinfo[HUD_POWERUPS].f|V_HUDTRANS, p); + } + } + else if (shieldoffs[q]) + { + if (shieldoffs[q] > 1) + shieldoffs[q] = 2*shieldoffs[q]/3; + else + shieldoffs[q] = 0; + } + + offs -= shieldoffs[q]; + +// --------- +// CTF flags +// --------- + + // YOU have a flag. Display a monitor-like icon for it. + if (stplyr->gotflag) + { + flagoffs[q] = ICONSEP; + p = (stplyr->gotflag & GF_REDFLAG) ? gotrflag : gotbflag; + V_DrawSmallScaledPatch(offs, hudinfo[HUD_POWERUPS].y, V_PERPLAYER|hudinfo[HUD_POWERUPS].f|V_HUDTRANS, p); + } + else if (flagoffs[q]) + { + if (flagoffs[q] > 1) + flagoffs[q] = 2*flagoffs[q]/3; + else + flagoffs[q] = 0; + } + + offs -= flagoffs[q]; + +// -------------------- +// Timer-based powerups +// -------------------- + +#define DRAWTIMERICON(patch, timer) \ + V_DrawSmallScaledPatch(offs, hudinfo[HUD_POWERUPS].y, V_PERPLAYER|hudinfo[HUD_POWERUPS].f|V_HUDTRANS, patch); \ + V_DrawRightAlignedThinString(offs + 16, hudinfo[HUD_POWERUPS].y + 8, V_PERPLAYER|hudinfo[HUD_POWERUPS].f, va("%d", timer/TICRATE)); + + // Invincibility, both from monitor and after being hit + invulntime = stplyr->powers[pw_flashing] ? stplyr->powers[pw_flashing] : stplyr->powers[pw_invulnerability]; + // Note: pw_flashing always makes the icon flicker regardless of time, unlike pw_invulnerability + if (stplyr->powers[pw_invulnerability] > 3*TICRATE || (invulntime && leveltime & 1)) + { + DRAWTIMERICON(invincibility, invulntime) + } + + if (invulntime > 7) + offs -= ICONSEP; + else + { + UINT8 a = ICONSEP, b = 7-invulntime; + while (b--) + a = 2*a/3; + offs -= a; + } + + // Super Sneakers + if (stplyr->powers[pw_sneakers] > 3*TICRATE || (stplyr->powers[pw_sneakers] && leveltime & 1)) + { + DRAWTIMERICON(sneakers, stplyr->powers[pw_sneakers]) + } + + if (stplyr->powers[pw_sneakers] > 7) + offs -= ICONSEP; + else + { + UINT8 a = ICONSEP, b = 7-stplyr->powers[pw_sneakers]; + while (b--) + a = 2*a/3; + offs -= a; + } + + // Gravity Boots + if (stplyr->powers[pw_gravityboots] > 3*TICRATE || (stplyr->powers[pw_gravityboots] && leveltime & 1)) + { + DRAWTIMERICON(gravboots, stplyr->powers[pw_gravityboots]) + } + +#undef DRAWTIMERICON +#undef ICONSEP } static void ST_drawFirstPersonHUD(void) { - player_t *player = stplyr; patch_t *p = NULL; - UINT16 invulntime = 0; + UINT32 airtime; + spriteframe_t *sprframe; + // If both air timers are active, use the air timer with the least time left + if (stplyr->powers[pw_underwater] && stplyr->powers[pw_spacetime]) + airtime = min(stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime]); + else // Use whichever one is active otherwise + airtime = (stplyr->powers[pw_spacetime]) ? stplyr->powers[pw_spacetime] : stplyr->powers[pw_underwater]; - if (player->playerstate != PST_LIVE) - return; + if (airtime < 1) + return; // No air timers are active, nothing would be drawn anyway - // Graue 06-18-2004: no V_NOSCALESTART, no SCX, no SCY, snap to right - if (player->powers[pw_shield] & SH_FORCE) - { - if ((player->powers[pw_shield] & 0xFF) > 0 || leveltime & 1) - p = forceshield; - } - else switch (player->powers[pw_shield] & SH_NOSTACK) - { - case SH_JUMP: p = jumpshield; break; - case SH_ELEMENTAL: p = watershield; break; - case SH_BOMB: p = bombshield; break; - case SH_ATTRACT: p = ringshield; break; - case SH_PITY: p = pityshield; break; - default: break; - } + airtime--; // The original code was all n*TICRATE + 1, so let's remove 1 tic for simplicity - if (p) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24), V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - else - V_DrawScaledPatch(304, 24, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - } + if (airtime > 11*TICRATE) + return; // Not time to draw any drown numbers yet - // pw_flashing just sets the icon to flash no matter what. - invulntime = player->powers[pw_flashing] ? 1 : player->powers[pw_invulnerability]; - if (invulntime > 3*TICRATE || (invulntime && leveltime & 1)) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 14, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, invincibility); - else - V_DrawScaledPatch(304, 24 + 28, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, invincibility); - } + if (!((airtime > 10*TICRATE - 5) + || (airtime <= 9*TICRATE && airtime > 8*TICRATE - 5) + || (airtime <= 7*TICRATE && airtime > 6*TICRATE - 5) + || (airtime <= 5*TICRATE && airtime > 4*TICRATE - 5) + || (airtime <= 3*TICRATE && airtime > 2*TICRATE - 5) + || (airtime <= 1*TICRATE))) + return; // Don't draw anything between numbers - if (player->powers[pw_sneakers] > 3*TICRATE || (player->powers[pw_sneakers] && leveltime & 1)) - { - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 28, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, sneakers); - else - V_DrawScaledPatch(304, 24 + 56, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, sneakers); - } + if (!((airtime % 10) < 5)) + return; // Keep in line with the flashing thing from third person. - p = NULL; + airtime /= (2*TICRATE); // To be strictly accurate it'd need to be ((airtime/TICRATE) - 1)/2, but integer division rounds down for us + + if (stplyr->charflags & SF_MACHINE) + airtime += 6; // Robots use different drown numbers + + // Get the front angle patch for the frame + sprframe = &sprites[SPR_DRWN].spriteframes[airtime]; + p = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); // Display the countdown drown numbers! - if ((player->powers[pw_underwater] <= 11*TICRATE + 1 - && player->powers[pw_underwater] >= 10*TICRATE + 1) - || (player->powers[pw_spacetime] <= 11*TICRATE + 1 - && player->powers[pw_spacetime] >= 10*TICRATE + 1)) - { - p = count5; - } - else if ((player->powers[pw_underwater] <= 9*TICRATE + 1 - && player->powers[pw_underwater] >= 8*TICRATE + 1) - || (player->powers[pw_spacetime] <= 9*TICRATE + 1 - && player->powers[pw_spacetime] >= 8*TICRATE + 1)) - { - p = count4; - } - else if ((player->powers[pw_underwater] <= 7*TICRATE + 1 - && player->powers[pw_underwater] >= 6*TICRATE + 1) - || (player->powers[pw_spacetime] <= 7*TICRATE + 1 - && player->powers[pw_spacetime] >= 6*TICRATE + 1)) - { - p = count3; - } - else if ((player->powers[pw_underwater] <= 5*TICRATE + 1 - && player->powers[pw_underwater] >= 4*TICRATE + 1) - || (player->powers[pw_spacetime] <= 5*TICRATE + 1 - && player->powers[pw_spacetime] >= 4*TICRATE + 1)) - { - p = count2; - } - else if ((player->powers[pw_underwater] <= 3*TICRATE + 1 - && player->powers[pw_underwater] >= 2*TICRATE + 1) - || (player->powers[pw_spacetime] <= 3*TICRATE + 1 - && player->powers[pw_spacetime] >= 2*TICRATE + 1)) - { - p = count1; - } - else if ((player->powers[pw_underwater] <= 1*TICRATE + 1 - && player->powers[pw_underwater] > 1) - || (player->powers[pw_spacetime] <= 1*TICRATE + 1 - && player->powers[pw_spacetime] > 1)) - { - p = count0; - } - - if (p) - V_DrawScaledPatch(SCX((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset)), SCY(60 - SHORT(p->topoffset)), - V_NOSCALESTART|V_OFFSET|V_TRANSLUCENT, p); + if (p && !F_GetPromptHideHud(60 - SHORT(p->topoffset))) + V_DrawScaledPatch((BASEVIDWIDTH/2) - (SHORT(p->width)/2) + SHORT(p->leftoffset), 60 - SHORT(p->topoffset), + V_PERPLAYER|V_PERPLAYER|V_TRANSLUCENT, p); } -// [21:42] <+Rob> Beige - Lavender - Steel Blue - Peach - Orange - Purple - Silver - Yellow - Pink - Red - Blue - Green - Cyan - Gold -static skincolors_t linkColor[14] = -{SKINCOLOR_BEIGE, SKINCOLOR_LAVENDER, SKINCOLOR_STEELBLUE, SKINCOLOR_PEACH, SKINCOLOR_ORANGE, - SKINCOLOR_PURPLE, SKINCOLOR_SILVER, SKINCOLOR_SUPER4, SKINCOLOR_PINK, SKINCOLOR_RED, - SKINCOLOR_BLUE, SKINCOLOR_GREEN, SKINCOLOR_CYAN, SKINCOLOR_GOLD}; - static void ST_drawNightsRecords(void) { - INT32 aflag = 0; + INT32 aflag = V_PERPLAYER; if (!stplyr->texttimer) return; if (stplyr->texttimer < TICRATE/2) - aflag = (9 - 9*stplyr->texttimer/(TICRATE/2)) << V_ALPHASHIFT; + aflag |= (9 - 9*stplyr->texttimer/(TICRATE/2)) << V_ALPHASHIFT; - // A "Bonus Time Start" by any other name... - if (stplyr->textvar == 1) + switch (stplyr->textvar) { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(52), V_GREENMAP|aflag, M_GetText("GET TO THE GOAL!")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), aflag, M_GetText("SCORE MULTIPLIER START!")); - - if (stplyr->finishedtime) + case 1: // A "Bonus Time Start" by any other name... { - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(140), aflag, "TIME:"); - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(148), aflag, "BONUS:"); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(140), V_ORANGEMAP|aflag, va("%d", (stplyr->startedtime - stplyr->finishedtime)/TICRATE)); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(148), V_ORANGEMAP|aflag, va("%d", (stplyr->finishedtime/TICRATE) * 100)); + V_DrawCenteredString(BASEVIDWIDTH/2, 52, V_GREENMAP|aflag, M_GetText("GET TO THE GOAL!")); + V_DrawCenteredString(BASEVIDWIDTH/2, 60, aflag, M_GetText("SCORE MULTIPLIER START!")); + + if (stplyr->finishedtime) + { + V_DrawString(BASEVIDWIDTH/2 - 48, 140, aflag, "TIME:"); + V_DrawString(BASEVIDWIDTH/2 - 48, 148, aflag, "BONUS:"); + V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, 140, V_ORANGEMAP|aflag, va("%d", (stplyr->startedtime - stplyr->finishedtime)/TICRATE)); + V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, 148, V_ORANGEMAP|aflag, va("%d", (stplyr->finishedtime/TICRATE) * 100)); + } + break; } - } - - // Get n [more] Spheres - else if (stplyr->textvar <= 3 && stplyr->textvar >= 2) - { - if (!stplyr->capsule) - return; - - // Yes, this string is an abomination. - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), aflag, - va(M_GetText("\x80GET\x82 %d\x80 %s%s%s!"), stplyr->capsule->health, - (stplyr->textvar == 3) ? M_GetText("MORE ") : "", - (G_IsSpecialStage(gamemap)) ? "SPHERE" : "RING", - (stplyr->capsule->health > 1) ? "S" : "")); - } - - // End Bonus - else if (stplyr->textvar == 4) - { - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(140), aflag, (G_IsSpecialStage(gamemap)) ? "ORBS:" : "RINGS:"); - V_DrawString(BASEVIDWIDTH/2 - 48, STRINGY(148), aflag, "BONUS:"); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(140), V_ORANGEMAP|aflag, va("%d", stplyr->finishedrings)); - V_DrawRightAlignedString(BASEVIDWIDTH/2 + 48, STRINGY(148), V_ORANGEMAP|aflag, va("%d", stplyr->finishedrings * 50)); - ST_DrawNightsOverlayNum(BASEVIDWIDTH/2 + 48, STRINGY(160), aflag, stplyr->lastmarescore, nightsnum, SKINCOLOR_STEELBLUE); - - // If new record, say so! - if (!(netgame || multiplayer) && G_GetBestNightsScore(gamemap, stplyr->lastmare + 1) <= stplyr->lastmarescore) + case 2: // Get n Spheres + case 3: // Get n more Spheres { - if (stplyr->texttimer & 16) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), V_YELLOWMAP|aflag, "* NEW RECORD *"); - } + if (!stplyr->capsule) + return; - if (P_HasGrades(gamemap, stplyr->lastmare + 1)) - { - if (aflag) - V_DrawTranslucentPatch(BASEVIDWIDTH/2 + 60, STRINGY(160), aflag, - ngradeletters[P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare)]); - else - V_DrawScaledPatch(BASEVIDWIDTH/2 + 60, STRINGY(160), 0, - ngradeletters[P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare)]); + // Yes, this string is an abomination. + V_DrawCenteredString(BASEVIDWIDTH/2, 60, aflag, + va(M_GetText("\x80GET\x82 %d\x80 %s%s%s!"), stplyr->capsule->health, + (stplyr->textvar == 3) ? M_GetText("MORE ") : "", + (G_IsSpecialStage(gamemap)) ? "SPHERE" : "CHIP", + (stplyr->capsule->health > 1) ? "S" : "")); + break; } + case 4: // End Bonus + { + V_DrawString(BASEVIDWIDTH/2 - 56, 140, aflag, (G_IsSpecialStage(gamemap)) ? "SPHERES:" : "CHIPS:"); + V_DrawString(BASEVIDWIDTH/2 - 56, 148, aflag, "BONUS:"); + V_DrawRightAlignedString(BASEVIDWIDTH/2 + 56, 140, V_ORANGEMAP|aflag, va("%d", stplyr->finishedspheres)); + V_DrawRightAlignedString(BASEVIDWIDTH/2 + 56, 148, V_ORANGEMAP|aflag, va("%d", stplyr->finishedspheres * 50)); + ST_DrawNightsOverlayNum((BASEVIDWIDTH/2 + 56)<lastmarescore, nightsnum, SKINCOLOR_AZURE); + + // If new record, say so! + if (!(netgame || multiplayer) && G_GetBestNightsScore(gamemap, stplyr->lastmare + 1) <= stplyr->lastmarescore) + { + if (stplyr->texttimer & 16) + V_DrawCenteredString(BASEVIDWIDTH/2, 184, V_YELLOWMAP|aflag, "* NEW RECORD *"); + } + + if (P_HasGrades(gamemap, stplyr->lastmare + 1)) + { + UINT8 grade = P_GetGrade(stplyr->lastmarescore, gamemap, stplyr->lastmare); + if (modeattacking || grade >= GRADE_A) + V_DrawTranslucentPatch(BASEVIDWIDTH/2 + 60, 160, aflag, ngradeletters[grade]); + } + break; + } + default: + break; } } +// 2.0-1: [21:42] <+Rob> Beige - Lavender - Steel Blue - Peach - Orange - Purple - Silver - Yellow - Pink - Red - Blue - Green - Cyan - Gold +/*#define NUMLINKCOLORS 14 +static skincolors_t linkColor[NUMLINKCOLORS] = +{SKINCOLOR_BEIGE, SKINCOLOR_LAVENDER, SKINCOLOR_AZURE, SKINCOLOR_PEACH, SKINCOLOR_ORANGE, + SKINCOLOR_MAGENTA, SKINCOLOR_SILVER, SKINCOLOR_SUPERGOLD4, SKINCOLOR_PINK, SKINCOLOR_RED, + SKINCOLOR_BLUE, SKINCOLOR_GREEN, SKINCOLOR_CYAN, SKINCOLOR_GOLD};*/ + +// 2.2 indev list: (unix time 1470866042) Emerald, Aqua, Cyan, Blue, Pastel, Purple, Magenta, Rosy, Red, Orange, Gold, Yellow, Peridot +/*#define NUMLINKCOLORS 13 +static skincolors_t linkColor[NUMLINKCOLORS] = +{SKINCOLOR_EMERALD, SKINCOLOR_AQUA, SKINCOLOR_CYAN, SKINCOLOR_BLUE, SKINCOLOR_PASTEL, + SKINCOLOR_PURPLE, SKINCOLOR_MAGENTA, SKINCOLOR_ROSY, SKINCOLOR_RED, SKINCOLOR_ORANGE, + SKINCOLOR_GOLD, SKINCOLOR_YELLOW, SKINCOLOR_PERIDOT};*/ + +// 2.2 indev list again: [19:59:52] Ruby > Red > Flame > Sunset > Orange > Gold > Yellow > Lime > Green > Aqua > cyan > Sky > Blue > Pastel > Purple > Bubblegum > Magenta > Rosy > repeat +// [20:00:25] Also Icy for the link freeze text color +// [20:04:03] I would start it on lime +/*#define NUMLINKCOLORS 18 +static skincolors_t linkColor[NUMLINKCOLORS] = +{SKINCOLOR_LIME, SKINCOLOR_EMERALD, SKINCOLOR_AQUA, SKINCOLOR_CYAN, SKINCOLOR_SKY, + SKINCOLOR_SAPPHIRE, SKINCOLOR_PASTEL, SKINCOLOR_PURPLE, SKINCOLOR_BUBBLEGUM, SKINCOLOR_MAGENTA, + SKINCOLOR_ROSY, SKINCOLOR_RUBY, SKINCOLOR_RED, SKINCOLOR_FLAME, SKINCOLOR_SUNSET, + SKINCOLOR_ORANGE, SKINCOLOR_GOLD, SKINCOLOR_YELLOW};*/ + +// 2.2+ list for real this time: https://wiki.srb2.org/wiki/User:Rob/Sandbox (check history around 31/10/17, spoopy) +#define NUMLINKCOLORS 12 +static skincolors_t linkColor[2][NUMLINKCOLORS] = { +{SKINCOLOR_EMERALD, SKINCOLOR_AQUA, SKINCOLOR_SKY, SKINCOLOR_BLUE, SKINCOLOR_PURPLE, SKINCOLOR_MAGENTA, + SKINCOLOR_ROSY, SKINCOLOR_RED, SKINCOLOR_ORANGE, SKINCOLOR_GOLD, SKINCOLOR_YELLOW, SKINCOLOR_PERIDOT}, +{SKINCOLOR_SEAFOAM, SKINCOLOR_CYAN, SKINCOLOR_WAVE, SKINCOLOR_SAPPHIRE, SKINCOLOR_VAPOR, SKINCOLOR_BUBBLEGUM, + SKINCOLOR_VIOLET, SKINCOLOR_RUBY, SKINCOLOR_FLAME, SKINCOLOR_SUNSET, SKINCOLOR_SANDY, SKINCOLOR_LIME}}; + +static void ST_drawNiGHTSLink(void) +{ + static INT32 prevsel[2] = {0, 0}, prevtime[2] = {0, 0}; + const UINT8 q = ((splitscreen && stplyr == &players[secondarydisplayplayer]) ? 1 : 0); + INT32 sel = ((stplyr->linkcount-1) / 5) % NUMLINKCOLORS, aflag = V_PERPLAYER, mag = ((stplyr->linkcount-1 >= 300) ? 1 : 0); + skincolors_t colornum; + fixed_t x, y, scale; + + if (sel != prevsel[q]) + { + prevsel[q] = sel; + prevtime[q] = 2 + mag; + } + + if (stplyr->powers[pw_nights_linkfreeze] && (!(stplyr->powers[pw_nights_linkfreeze] & 2) || (stplyr->powers[pw_nights_linkfreeze] > flashingtics))) + colornum = SKINCOLOR_ICY; + else + colornum = linkColor[mag][sel]; + + aflag |= ((stplyr->linktimer < (UINT32)nightslinktics/3) + ? (9 - 9*stplyr->linktimer/(nightslinktics/3)) << V_ALPHASHIFT + : 0); + + y = (160+11)<linkcount-1), nightsnum, colornum); + V_DrawFixedPatch(x+(4*scale), y, scale, aflag, nightslink, + colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); + + // Show remaining link time left in debug + if (cv_debug & DBG_NIGHTSBASIC) + V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_SNAPTOBOTTOM, va("End in %d.%02d", stplyr->linktimer/TICRATE, G_TicsToCentiseconds(stplyr->linktimer))); +} + + static void ST_drawNiGHTSHUD(void) { INT32 origamount; - INT32 minlink = 1; - INT32 total_ringcount; - boolean nosshack = false; - - // When debugging, show "0 Link". - if (cv_debug & DBG_NIGHTSBASIC) - minlink = 0; - - // Cheap hack: don't display when the score is showing (it popping up for a split second when exiting a map is intentional) - if (stplyr->texttimer && stplyr->textvar == 4) - minlink = INT32_MAX; - - if (G_IsSpecialStage(gamemap)) - { // Since special stages share score, time, rings, etc. - // disable splitscreen mode for its HUD. - if (stplyr != &players[displayplayer]) - return; - nosshack = splitscreen; - splitscreen = false; - } - - // Link drawing - if ( -#ifdef HAVE_BLUA - LUA_HudEnabled(hud_nightslink) && -#endif - stplyr->linkcount > minlink) - { - skincolors_t colornum = linkColor[((stplyr->linkcount-1) / 5) % (sizeof(linkColor) / sizeof(skincolors_t))]; - if (stplyr->powers[pw_nights_linkfreeze]) - colornum = SKINCOLOR_WHITE; - - if (stplyr->linktimer < 2*TICRATE/3) - { - INT32 linktrans = (9 - 9*stplyr->linktimer/(2*TICRATE/3)) << V_ALPHASHIFT; - - if (splitscreen) - { - ST_DrawNightsOverlayNum(256, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT|linktrans, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawTranslucentMappedPatch(264, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT|linktrans, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - else - { - ST_DrawNightsOverlayNum(160, 160, V_SNAPTOBOTTOM|linktrans, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawTranslucentMappedPatch(168, 160, V_SNAPTOBOTTOM|linktrans, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - } - else // normal, fullbright - { -#if 0 // Cool but silly number effect where the previous link number fades away - if (stplyr->linkcount > 2 && stplyr->linktimer > (2*TICRATE) - 9) - { - INT32 offs = 10 - (stplyr->linktimer - (2*TICRATE - 9)); - INT32 ghosttrans = offs << V_ALPHASHIFT; - ST_DrawNightsOverlayNum(160, STRINGY(160+offs), SPLITFLAGS(V_SNAPTOBOTTOM)|ghosttrans, (stplyr->linkcount-2), - nightsnum, colornum); - } -#endif - - if (splitscreen) - { - ST_DrawNightsOverlayNum(256, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawMappedPatch(264, STRINGY(152), SPLITFLAGS(V_SNAPTOBOTTOM)|V_SNAPTORIGHT, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - else - { - ST_DrawNightsOverlayNum(160, 160, V_SNAPTOBOTTOM, (stplyr->linkcount-1), nightsnum, colornum); - V_DrawMappedPatch(168, 160, V_SNAPTOBOTTOM, nightslink, - colornum == 0 ? colormaps : R_GetTranslationColormap(TC_DEFAULT, colornum, GTC_CACHE)); - } - } - - // Show remaining link time left in debug - if (cv_debug & DBG_NIGHTSBASIC) - V_DrawCenteredString(BASEVIDWIDTH/2, 180, V_SNAPTOBOTTOM, va("End in %d.%02d", stplyr->linktimer/TICRATE, G_TicsToCentiseconds(stplyr->linktimer))); - } + INT32 total_spherecount, total_ringcount; + const boolean oldspecialstage = (G_IsSpecialStage(gamemap) && !(maptol & TOL_NIGHTS)); // Drill meter - if ( -#ifdef HAVE_BLUA - LUA_HudEnabled(hud_nightsdrill) && -#endif - stplyr->pflags & PF_NIGHTSMODE) + if (LUA_HudEnabled(hud_nightsdrill) && stplyr->powers[pw_carry] == CR_NIGHTSMODE) { - INT32 locx, locy; + INT32 locx = 16, locy = 180; INT32 dfill; UINT8 fillpatch; - if (splitscreen || nosshack) - { - locx = 110; - locy = 188; - } - else - { - locx = 16; - locy = 180; - } - // Use which patch? if (stplyr->pflags & PF_DRILLING) fillpatch = (stplyr->drillmeter & 1) + 1; else fillpatch = 0; - if (splitscreen) - { // 11-5-14 Replaced the old hack with a slightly better hack. -Red - V_DrawScaledPatch(locx, STRINGY(locy)-3, SPLITFLAGS(V_SNAPTOBOTTOM)|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), SPLITFLAGS(V_SNAPTOBOTTOM)|V_HUDTRANS, drillfill[fillpatch]); - } - else if (nosshack) - { // Even dirtier hack-of-a-hack to draw seperate drill meters in splitscreen special stages but nothing else. - splitscreen = true; - V_DrawScaledPatch(locx, STRINGY(locy)-3, V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_HUDTRANS, drillfill[fillpatch]); - stplyr = &players[secondarydisplayplayer]; - if (stplyr->pflags & PF_DRILLING) - fillpatch = (stplyr->drillmeter & 1) + 1; - else - fillpatch = 0; - V_DrawScaledPatch(locx, STRINGY(locy-3), V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, STRINGY(locy + 3), V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); - stplyr = &players[displayplayer]; - splitscreen = false; - } - else - { // Draw normally. <:3 - V_DrawScaledPatch(locx, locy, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); - for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) - V_DrawScaledPatch(locx + 2 + dfill, locy + 3, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); - } + V_DrawScaledPatch(locx, locy, V_PERPLAYER|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillbar); + for (dfill = 0; dfill < stplyr->drillmeter/20 && dfill < 96; ++dfill) + V_DrawScaledPatch(locx + 2 + dfill, locy + 3, V_PERPLAYER|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS, drillfill[fillpatch]); // Display actual drill amount and bumper time - if (cv_debug & DBG_NIGHTSBASIC) + if (!splitscreen && (cv_debug & DBG_NIGHTSBASIC)) { if (stplyr->bumpertime) - V_DrawString(SCX(locx), SCY(locy - 8), V_NOSCALESTART|V_REDMAP|V_MONOSPACE, va("BUMPER: 0.%02d", G_TicsToCentiseconds(stplyr->bumpertime))); + V_DrawString(locx, locy - 8, V_REDMAP|V_MONOSPACE, va("BUMPER: 0.%02d", G_TicsToCentiseconds(stplyr->bumpertime))); else - V_DrawString(SCX(locx), SCY(locy - 8), V_NOSCALESTART|V_MONOSPACE, va("Drill: %3d%%", (stplyr->drillmeter*100)/(96*20))); + V_DrawString(locx, locy - 8, V_MONOSPACE, va("Drill: %3d%%", (stplyr->drillmeter*100)/(96*20))); } } - if (gametype == GT_RACE || gametype == GT_COMPETITION) + /*if (G_IsSpecialStage(gamemap)) + { // Since special stages share score, time, rings, etc. + // disable splitscreen mode for its HUD. + // -------------------------------------- + // NOPE! Consistency between different splitscreen stuffs + // now we've got the screen squashing instead. ~toast + if (stplyr != &players[displayplayer]) + return; + nosshack = splitscreen; + splitscreen = false; + }*/ + + // Link drawing + if (!oldspecialstage + // Don't display when the score is showing (it popping up for a split second when exiting a map is intentional) + && !(stplyr->texttimer && stplyr->textvar == 4) + && LUA_HudEnabled(hud_nightslink) + && ((cv_debug & DBG_NIGHTSBASIC) || stplyr->linkcount > 1)) // When debugging, show "0 Link". + { + ST_drawNiGHTSLink(); + } + + if (gametyperules & GTR_RACE) { ST_drawScore(); ST_drawTime(); @@ -1122,26 +1827,32 @@ static void ST_drawNiGHTSHUD(void) } // Begin drawing brackets/chip display -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_nightsrings)) + if (LUA_HudEnabled(hud_nightsspheres)) { -#endif - ST_DrawOverlayPatch(SCX(16), SCY(8), nbracket); + ST_DrawTopLeftOverlayPatch(16, 8, nbracket); if (G_IsSpecialStage(gamemap)) - ST_DrawOverlayPatch(SCX(24), SCY(8) + SCZ(8), nsshud); + ST_DrawTopLeftOverlayPatch(24, 16, ( + (stplyr->bonustime && (leveltime & 4) && (states[S_BLUESPHEREBONUS].frame & FF_ANIMATE)) ? nssbon : nsshud)); else - ST_DrawOverlayPatch(SCX(24), SCY(8) + SCZ(8), nhud[(leveltime/2)%12]); + ST_DrawTopLeftOverlayPatch(24, 16, *(((stplyr->bonustime) ? nbon : nhud)+((leveltime/2)%12))); if (G_IsSpecialStage(gamemap)) { INT32 i; - total_ringcount = 0; + total_spherecount = total_ringcount = 0; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] /*&& players[i].pflags & PF_NIGHTSMODE*/ && players[i].health) - total_ringcount += players[i].health - 1; + { + if (!playeringame[i]) + continue; + total_spherecount += players[i].spheres; + total_ringcount += players[i].rings; + } } else - total_ringcount = stplyr->health-1; + { + total_spherecount = stplyr->spheres; + total_ringcount = stplyr->spheres; + } if (stplyr->capsule) { @@ -1151,8 +1862,8 @@ static void ST_drawNiGHTSHUD(void) origamount = stplyr->capsule->spawnpoint->angle; I_Assert(origamount > 0); // should not happen now - ST_DrawOverlayPatch(SCX(72), SCY(8), nbracket); - ST_DrawOverlayPatch(SCX(74), SCY(8) + SCZ(4), minicaps); + ST_DrawTopLeftOverlayPatch(72, 8, nbracket); + ST_DrawTopLeftOverlayPatch(74, 8 + 4, minicaps); if (stplyr->capsule->reactiontime != 0) { @@ -1161,10 +1872,10 @@ static void ST_drawNiGHTSHUD(void) for (r = 0; r < 5; r++) { - ST_DrawOverlayPatch(SCX(230 - (7*r)), SCY(144), redstat); - ST_DrawOverlayPatch(SCX(188 - (7*r)), SCY(144), orngstat); - ST_DrawOverlayPatch(SCX(146 - (7*r)), SCY(144), yelstat); - ST_DrawOverlayPatch(SCX(104 - (7*r)), SCY(144), byelstat); + V_DrawScaledPatch(230 - (7*r), 144, V_PERPLAYER|V_HUDTRANS, redstat); + V_DrawScaledPatch(188 - (7*r), 144, V_PERPLAYER|V_HUDTRANS, orngstat); + V_DrawScaledPatch(146 - (7*r), 144, V_PERPLAYER|V_HUDTRANS, yelstat); + V_DrawScaledPatch(104 - (7*r), 144, V_PERPLAYER|V_HUDTRANS, byelstat); } amount = (origamount - stplyr->capsule->health); @@ -1183,7 +1894,7 @@ static void ST_drawNiGHTSHUD(void) if (r > 10) ++t; if (r > 5) ++t; - ST_DrawOverlayPatch(SCX(69 + (7*t)), SCY(144), bluestat); + V_DrawScaledPatch(69 + (7*t), 144, V_PERPLAYER|V_HUDTRANS, bluestat); } } } @@ -1192,99 +1903,124 @@ static void ST_drawNiGHTSHUD(void) INT32 cfill; // Lil' white box! - V_DrawScaledPatch(15, STRINGY(8) + 34, V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulebar); + V_DrawScaledPatch(15, 8 + 34, V_PERPLAYER|V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulebar); amount = (origamount - stplyr->capsule->health); amount = (amount * length)/origamount; - for (cfill = 0; cfill < amount && cfill < 88; ++cfill) - V_DrawScaledPatch(15 + cfill + 1, STRINGY(8) + 35, V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulefill); + for (cfill = 0; cfill < amount && cfill < length; ++cfill) + V_DrawScaledPatch(15 + cfill + 1, 8 + 35, V_PERPLAYER|V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulefill); } - if (total_ringcount >= stplyr->capsule->health) - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), nredar[leveltime%8]); + if (total_spherecount >= stplyr->capsule->health) + ST_DrawTopLeftOverlayPatch(40, 8 + 5, nredar[leveltime&7]); else - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), narrow[(leveltime/2)%8]); + ST_DrawTopLeftOverlayPatch(40, 8 + 5, narrow[(leveltime/2)&7]); } - else - ST_DrawOverlayPatch(SCX(40), SCY(8) + SCZ(5), narrow[8]); + else if (oldspecialstage && total_spherecount < (INT32)ssspheres) + { + INT32 cfill, amount; + const INT32 length = 88; + UINT8 em = P_GetNextEmerald(); + ST_DrawTopLeftOverlayPatch(72, 8, nbracket); - if (total_ringcount >= 100) - ST_DrawOverlayNum((total_ringcount >= 1000) ? SCX(76) : SCX(72), SCY(8) + SCZ(11), total_ringcount); - else - ST_DrawOverlayNum(SCX(68), SCY(8) + SCZ(11), total_ringcount); -#ifdef HAVE_BLUA + if (em <= 7) + ST_DrawTopLeftOverlayPatch(80, 8 + 8, emeraldpics[0][em]); + + ST_DrawTopLeftOverlayPatch(40, 8 + 5, narrow[(leveltime/2)&7]); + + // Lil' white box! + V_DrawScaledPatch(15, 8 + 34, V_PERPLAYER|V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulebar); + + amount = (total_spherecount * length)/ssspheres; + + for (cfill = 0; cfill < amount && cfill < length; ++cfill) + V_DrawScaledPatch(15 + cfill + 1, 8 + 35, V_PERPLAYER|V_SNAPTOLEFT|V_SNAPTOTOP|V_HUDTRANS, capsulefill); + } + else + ST_DrawTopLeftOverlayPatch(40, 8 + 5, narrow[8]); + + if (oldspecialstage) + { + // invert for s3k style junk + total_spherecount = ssspheres - total_spherecount; + if (total_spherecount < 0) + total_spherecount = 0; + + if (nummaprings > 0) // don't count down if there ISN'T a valid maximum number of rings, like sonic 3 + { + total_ringcount = nummaprings - total_ringcount; + if (total_ringcount < 0) + total_ringcount = 0; + } + + // now rings! you know, for that perfect bonus. + V_DrawScaledPatch(272, 8, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS, nbracket); + V_DrawScaledPatch(280, 16+1, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS, nring); + V_DrawScaledPatch(280, 8+5, V_FLIP|V_PERPLAYER|V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS, narrow[8]); + V_DrawTallNum(272, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTORIGHT|V_HUDTRANS, total_ringcount); + } + + if (total_spherecount >= 100) + V_DrawTallNum((total_spherecount >= 1000) ? 76 : 72, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, total_spherecount); + else + V_DrawTallNum(68, 8 + 11, V_PERPLAYER|V_SNAPTOTOP|V_SNAPTOLEFT|V_HUDTRANS, total_spherecount); } -#endif // Score - if (!stplyr->exiting -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_nightsscore) -#endif - ) - { - ST_DrawNightsOverlayNum(304, STRINGY(16), SPLITFLAGS(V_SNAPTOTOP)|V_SNAPTORIGHT, stplyr->marescore, nightsnum, SKINCOLOR_STEELBLUE); - } + if (!stplyr->exiting && !oldspecialstage && LUA_HudEnabled(hud_nightsscore)) + ST_DrawNightsOverlayNum(304<marescore, nightsnum, SKINCOLOR_AZURE); - if (!stplyr->exiting -#ifdef HAVE_BLUA // TODO give this its own section for Lua - && LUA_HudEnabled(hud_nightsscore) -#endif - ) + if (!stplyr->exiting && LUA_HudEnabled(hud_nightsscore)) { if (modeattacking == ATTACKING_NIGHTS) { INT32 maretime = max(stplyr->realtime - stplyr->marebegunat, 0); - fixed_t cornerx = vid.width, cornery = vid.height-SCZ(20); -#define ASSISHHUDFIX(n) (n*vid.dupx) - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(22), cornery, W_CachePatchName("NGRTIMER", PU_HUDGFX)); - ST_DrawPaddedOverlayNum(cornerx-ASSISHHUDFIX(22), cornery, G_TicsToCentiseconds(maretime), 2); - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(46), cornery, sboperiod); +#define VFLAGS V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_PERPLAYER|V_HUDTRANS + V_DrawScaledPatch(BASEVIDWIDTH-22, BASEVIDHEIGHT-20, VFLAGS, W_CachePatchName("NGRTIMER", PU_HUDGFX)); + V_DrawPaddedTallNum(BASEVIDWIDTH-22, BASEVIDHEIGHT-20, VFLAGS, G_TicsToCentiseconds(maretime), 2); + V_DrawScaledPatch(BASEVIDWIDTH-46, BASEVIDHEIGHT-20, VFLAGS, sboperiod); if (maretime < 60*TICRATE) - ST_DrawOverlayNum(cornerx-ASSISHHUDFIX(46), cornery, G_TicsToSeconds(maretime)); + V_DrawTallNum(BASEVIDWIDTH-46, BASEVIDHEIGHT-20, VFLAGS, G_TicsToSeconds(maretime)); else { - ST_DrawPaddedOverlayNum(cornerx-ASSISHHUDFIX(46), cornery, G_TicsToSeconds(maretime), 2); - ST_DrawOverlayPatch(cornerx-ASSISHHUDFIX(70), cornery, sbocolon); - ST_DrawOverlayNum(cornerx-ASSISHHUDFIX(70), cornery, G_TicsToMinutes(maretime, true)); + V_DrawPaddedTallNum(BASEVIDWIDTH-46, BASEVIDHEIGHT-20, VFLAGS, G_TicsToSeconds(maretime), 2); + V_DrawScaledPatch(BASEVIDWIDTH-70, BASEVIDHEIGHT-20, VFLAGS, sbocolon); + V_DrawTallNum(BASEVIDWIDTH-70, BASEVIDHEIGHT-20, VFLAGS, G_TicsToMinutes(maretime, true)); } +#undef VFLAGS } -#undef ASSISHHUDFIX } // Ideya time remaining - if (!stplyr->exiting && stplyr->nightstime > 0 -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_nightstime) -#endif - ) + if (!stplyr->exiting && stplyr->nightstime > 0 && LUA_HudEnabled(hud_nightstime)) { INT32 realnightstime = stplyr->nightstime/TICRATE; INT32 numbersize; + UINT8 col = ((realnightstime < 10) ? SKINCOLOR_RED : SKINCOLOR_SUPERGOLD4); if (G_IsSpecialStage(gamemap)) { tic_t lowest_time = stplyr->nightstime; INT32 i; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE && players[i].nightstime < lowest_time) + if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE && players[i].nightstime < lowest_time) lowest_time = players[i].nightstime; realnightstime = lowest_time/TICRATE; } - if (stplyr->powers[pw_flashing] > TICRATE ) // was hit + if (stplyr->powers[pw_flashing] > TICRATE) // was hit { UINT16 flashingLeft = stplyr->powers[pw_flashing]-(TICRATE); if (flashingLeft < TICRATE/2) // Start fading out { UINT32 fadingFlag = (9 - 9*flashingLeft/(TICRATE/2)) << V_ALPHASHIFT; - V_DrawTranslucentPatch(SCX(160 - (minus5sec->width/2)), SCY(28), V_NOSCALESTART|fadingFlag, minus5sec); + V_DrawTranslucentPatch(160 - (minus5sec->width/2), 28, V_PERPLAYER|fadingFlag, minus5sec); } else - V_DrawScaledPatch(SCX(160 - (minus5sec->width/2)), SCY(28), V_NOSCALESTART, minus5sec); + V_DrawScaledPatch(160 - (minus5sec->width/2), 28, V_PERPLAYER, minus5sec); } if (realnightstime < 10) @@ -1294,56 +2030,90 @@ static void ST_drawNiGHTSHUD(void) else numbersize = 48/2; - if (realnightstime < 10) - ST_DrawNightsOverlayNum(160 + numbersize, STRINGY(12), SPLITFLAGS(V_SNAPTOTOP), realnightstime, - nightsnum, SKINCOLOR_RED); - else - ST_DrawNightsOverlayNum(160 + numbersize, STRINGY(12), SPLITFLAGS(V_SNAPTOTOP), realnightstime, - nightsnum, SKINCOLOR_SUPER4); + if ((oldspecialstage && leveltime & 2) + && (stplyr->mo->eflags & (MFE_TOUCHWATER|MFE_UNDERWATER)) + && !(stplyr->powers[pw_shield] & SH_PROTECTWATER)) + col = SKINCOLOR_ORANGE; + + ST_DrawNightsOverlayNum((160 + numbersize)<nightstime))); } - // Show pickup durations - if (cv_debug & DBG_NIGHTSBASIC) + if (oldspecialstage) { - UINT16 pwr; - - if (stplyr->powers[pw_nights_superloop]) + if (leveltime < 5*TICRATE) { - pwr = stplyr->powers[pw_nights_superloop]; - V_DrawSmallScaledPatch(SCX(110), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUA0",PU_CACHE)); - V_DrawThinString(SCX(106), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - - if (stplyr->powers[pw_nights_helper]) - { - pwr = stplyr->powers[pw_nights_helper]; - V_DrawSmallScaledPatch(SCX(150), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUC0",PU_CACHE)); - V_DrawThinString(SCX(146), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); - } - - if (stplyr->powers[pw_nights_linkfreeze]) - { - pwr = stplyr->powers[pw_nights_linkfreeze]; - V_DrawSmallScaledPatch(SCX(190), SCY(44), V_NOSCALESTART, W_CachePatchName("NPRUE0",PU_CACHE)); - V_DrawThinString(SCX(186), SCY(52), V_NOSCALESTART|V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); + INT32 aflag = V_PERPLAYER; + tic_t drawtime = (5*TICRATE) - leveltime; + if (drawtime < TICRATE/2) + aflag |= (9 - 9*drawtime/(TICRATE/2)) << V_ALPHASHIFT; + // This one, not quite as much so. + V_DrawCenteredString(BASEVIDWIDTH/2, 60, aflag, + va(M_GetText("\x80GET\x82 %d\x80 SPHERE%s!"), ssspheres, + (ssspheres > 1) ? "S" : "")); } } + else + { + // Show pickup durations + if (cv_debug & DBG_NIGHTSBASIC) + { + UINT16 pwr; - // Records/extra text -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_nightsrecords)) -#endif - ST_drawNightsRecords(); + if (stplyr->powers[pw_nights_superloop]) + { + pwr = stplyr->powers[pw_nights_superloop]; + V_DrawSmallScaledPatch(110, 44, 0, W_CachePatchName("NPRUA0",PU_CACHE)); + V_DrawThinString(106, 52, V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); + } - if (nosshack) - splitscreen = true; + if (stplyr->powers[pw_nights_helper]) + { + pwr = stplyr->powers[pw_nights_helper]; + V_DrawSmallScaledPatch(150, 44, 0, W_CachePatchName("NPRUC0",PU_CACHE)); + V_DrawThinString(146, 52, V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); + } + + if (stplyr->powers[pw_nights_linkfreeze]) + { + pwr = stplyr->powers[pw_nights_linkfreeze]; + V_DrawSmallScaledPatch(190, 44, 0, W_CachePatchName("NPRUE0",PU_CACHE)); + V_DrawThinString(186, 52, V_MONOSPACE, va("%2d.%02d", pwr/TICRATE, G_TicsToCentiseconds(pwr))); + } + } + + // Records/extra text + if (LUA_HudEnabled(hud_nightsrecords)) + ST_drawNightsRecords(); + } } -static void ST_drawWeaponRing(powertype_t weapon, INT32 rwflag, INT32 wepflag, INT32 xoffs, patch_t *pat) +static void ST_drawWeaponSelect(INT32 xoffs, INT32 y) +{ + INT32 q = stplyr->weapondelay, del = 0, p = 16; + while (q) + { + if (q > p) + { + del += p; + q -= p; + q /= 2; + if (p > 1) + p /= 2; + } + else + { + del += q; + break; + } + } + V_DrawScaledPatch(6 + xoffs, y-2 - del/2, V_PERPLAYER|V_SNAPTOBOTTOM, curweapon); +} + +static void ST_drawWeaponRing(powertype_t weapon, INT32 rwflag, INT32 wepflag, INT32 xoffs, INT32 y, patch_t *pat) { INT32 txtflags = 0, patflags = 0; @@ -1353,31 +2123,32 @@ static void ST_drawWeaponRing(powertype_t weapon, INT32 rwflag, INT32 wepflag, I txtflags |= V_YELLOWMAP; if (weapon == pw_infinityring - || (stplyr->ringweapons & rwflag && stplyr->health > 1)) - txtflags |= V_20TRANS; + || (stplyr->ringweapons & rwflag)) + ; //txtflags |= V_20TRANS; else { txtflags |= V_TRANSLUCENT; patflags = V_80TRANS; } - V_DrawScaledPatch(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|patflags, pat); - - if (stplyr->powers[weapon] > 99) - V_DrawThinString(8 + xoffs + 1, STRINGY(162), V_SNAPTOLEFT|txtflags, va("%d", stplyr->powers[weapon])); - else - V_DrawString(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|txtflags, va("%d", stplyr->powers[weapon])); + V_DrawScaledPatch(8 + xoffs, y, V_PERPLAYER|V_SNAPTOBOTTOM|patflags, pat); + V_DrawRightAlignedThinString(24 + xoffs, y + 8, V_PERPLAYER|V_SNAPTOBOTTOM|txtflags, va("%d", stplyr->powers[weapon])); if (stplyr->currentweapon == wepflag) - V_DrawScaledPatch(6 + xoffs, STRINGY(162 - (splitscreen ? 4 : 2)), V_SNAPTOLEFT, curweapon); + ST_drawWeaponSelect(xoffs, y); } else if (stplyr->ringweapons & rwflag) - V_DrawScaledPatch(8 + xoffs, STRINGY(162), V_SNAPTOLEFT|V_TRANSLUCENT, pat); + V_DrawScaledPatch(8 + xoffs, y, V_PERPLAYER|V_SNAPTOBOTTOM|V_TRANSLUCENT, pat); } static void ST_drawMatchHUD(void) { - INT32 offset = (BASEVIDWIDTH / 2) - (NUM_WEAPONS * 10); + char penaltystr[7]; + const INT32 y = 176; // HUD_LIVES + INT32 offset = (BASEVIDWIDTH / 2) - (NUM_WEAPONS * 10) - 6; + + if (F_GetPromptHideHud(y)) + return; if (!G_RingSlingerGametype()) return; @@ -1385,234 +2156,295 @@ static void ST_drawMatchHUD(void) if (G_TagGametype() && !(stplyr->pflags & PF_TAGIT)) return; -#ifdef HAVE_BLUA - if (LUA_HudEnabled(hud_weaponrings)) { -#endif + { + if (stplyr->powers[pw_infinityring]) + ST_drawWeaponRing(pw_infinityring, 0, 0, offset, y, infinityring); + else + { + if (stplyr->rings > 0) + V_DrawScaledPatch(8 + offset, y, V_PERPLAYER|V_SNAPTOBOTTOM, normring); + else + V_DrawTranslucentPatch(8 + offset, y, V_PERPLAYER|V_SNAPTOBOTTOM|V_80TRANS, normring); - if (stplyr->powers[pw_infinityring]) - ST_drawWeaponRing(pw_infinityring, 0, 0, offset, infinityring); - else if (stplyr->health > 1) - V_DrawScaledPatch(8 + offset, STRINGY(162), V_SNAPTOLEFT, normring); - else - V_DrawTranslucentPatch(8 + offset, STRINGY(162), V_SNAPTOLEFT|V_80TRANS, normring); + if (!stplyr->currentweapon) + ST_drawWeaponSelect(offset, y); + } - if (!stplyr->currentweapon) - V_DrawScaledPatch(6 + offset, STRINGY(162 - (splitscreen ? 4 : 2)), V_SNAPTOLEFT, curweapon); + ST_drawWeaponRing(pw_automaticring, RW_AUTO, WEP_AUTO, offset + 20, y, autoring); + ST_drawWeaponRing(pw_bouncering, RW_BOUNCE, WEP_BOUNCE, offset + 40, y, bouncering); + ST_drawWeaponRing(pw_scatterring, RW_SCATTER, WEP_SCATTER, offset + 60, y, scatterring); + ST_drawWeaponRing(pw_grenadering, RW_GRENADE, WEP_GRENADE, offset + 80, y, grenadering); + ST_drawWeaponRing(pw_explosionring, RW_EXPLODE, WEP_EXPLODE, offset + 100, y, explosionring); + ST_drawWeaponRing(pw_railring, RW_RAIL, WEP_RAIL, offset + 120, y, railring); - offset += 20; - ST_drawWeaponRing(pw_automaticring, RW_AUTO, WEP_AUTO, offset, autoring); - offset += 20; - ST_drawWeaponRing(pw_bouncering, RW_BOUNCE, WEP_BOUNCE, offset, bouncering); - offset += 20; - ST_drawWeaponRing(pw_scatterring, RW_SCATTER, WEP_SCATTER, offset, scatterring); - offset += 20; - ST_drawWeaponRing(pw_grenadering, RW_GRENADE, WEP_GRENADE, offset, grenadering); - offset += 20; - ST_drawWeaponRing(pw_explosionring, RW_EXPLODE, WEP_EXPLODE, offset, explosionring); - offset += 20; - ST_drawWeaponRing(pw_railring, RW_RAIL, WEP_RAIL, offset, railring); + if (stplyr->ammoremovaltimer && leveltime % 8 < 4) + { + sprintf(penaltystr, "-%d", stplyr->ammoremoval); + V_DrawString(offset + 8 + stplyr->ammoremovalweapon * 20, y, + V_REDMAP, penaltystr); + } -#ifdef HAVE_BLUA } - - if (LUA_HudEnabled(hud_powerstones)) { -#endif - - // Power Stones collected - offset = 136; // Used for Y now - - if (stplyr->powers[pw_emeralds] & EMERALD1) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[0]); - - offset += 8; - - if (stplyr->powers[pw_emeralds] & EMERALD2) - V_DrawScaledPatch(40, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[1]); - - if (stplyr->powers[pw_emeralds] & EMERALD6) - V_DrawScaledPatch(16, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[5]); - - offset += 16; - - if (stplyr->powers[pw_emeralds] & EMERALD3) - V_DrawScaledPatch(40, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[2]); - - if (stplyr->powers[pw_emeralds] & EMERALD5) - V_DrawScaledPatch(16, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[4]); - - offset += 8; - - if (stplyr->powers[pw_emeralds] & EMERALD4) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[3]); - - offset -= 16; - - if (stplyr->powers[pw_emeralds] & EMERALD7) - V_DrawScaledPatch(28, STRINGY(offset), V_SNAPTOLEFT, tinyemeraldpics[6]); - -#ifdef HAVE_BLUA - } -#endif } -static inline void ST_drawRaceHUD(void) +static void ST_drawTextHUD(void) { - if (leveltime > TICRATE && leveltime <= 2*TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race3->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race3); - else if (leveltime > 2*TICRATE && leveltime <= 3*TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race2->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race2); - else if (leveltime > 3*TICRATE && leveltime <= 4*TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(race1->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, race1); - else if (leveltime > 4*TICRATE && leveltime <= 5*TICRATE) - V_DrawScaledPatch(SCX((BASEVIDWIDTH - SHORT(racego->width))/2), (INT32)(SCY(BASEVIDHEIGHT/2)), V_NOSCALESTART, racego); + INT32 y = 42 + 16; // HUD_RINGS + boolean donef12 = false; + +#define textHUDdraw(str) \ +{\ + V_DrawThinString(16, y, V_PERPLAYER|V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOTOP, str);\ + y += 8;\ +} + + if (F_GetPromptHideHud(y)) + return; + + if (stplyr->spectator && (gametype != GT_COOP || stplyr->playerstate == PST_LIVE)) + textHUDdraw(M_GetText("\x86""Spectator mode:")) if (circuitmap) { if (stplyr->exiting) - V_DrawString(hudinfo[HUD_LAP].x, STRINGY(hudinfo[HUD_LAP].y), V_YELLOWMAP, "FINISHED!"); + textHUDdraw(M_GetText("\x82""FINISHED!")) else - V_DrawString(hudinfo[HUD_LAP].x, STRINGY(hudinfo[HUD_LAP].y), 0, va("Lap: %u/%d", stplyr->laps+1, cv_numlaps.value)); + textHUDdraw(va("Lap:""\x82 %u/%d", stplyr->laps+1, cv_numlaps.value)) } -} -static void ST_drawTagHUD(void) -{ - char pstime[33] = ""; - char pstext[33] = ""; - - // Figure out what we're going to print. - if (leveltime < hidetime * TICRATE) //during the hide time, the seeker and hiders have different messages on their HUD. + if (gametype != GT_COOP && (stplyr->exiting || (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1))) { - if (hidetime) - sprintf(pstime, "%d", (hidetime - leveltime/TICRATE)); //hide time is in seconds, not tics. - - if (stplyr->pflags & PF_TAGIT && !stplyr->spectator) - sprintf(pstext, "%s", M_GetText("WAITING FOR PLAYERS TO HIDE...")); - else + if (!splitscreen && !donef12) { - if (!stplyr->spectator) //spectators get a generic HUD message rather than a gametype specific one. + textHUDdraw(M_GetText("\x82""VIEWPOINT:""\x80 Switch view")) + donef12 = true; + } + } + else if ((gametyperules & GTR_RESPAWNDELAY) && stplyr->playerstate == PST_DEAD && stplyr->lives) // Death overrides spectator text. + { + INT32 respawntime = cv_respawntime.value - stplyr->deadtimer/TICRATE; + + if (respawntime > 0 && !stplyr->spectator) + textHUDdraw(va(M_GetText("Respawn in %d..."), respawntime)) + else + textHUDdraw(M_GetText("\x82""JUMP:""\x80 Respawn")) + } + else if (stplyr->spectator && (gametype != GT_COOP || stplyr->playerstate == PST_LIVE)) + { + if (!splitscreen && !donef12) + { + textHUDdraw(M_GetText("\x82""VIEWPOINT:""\x80 Switch view")) + donef12 = true; + } + + textHUDdraw(M_GetText("\x82""JUMP:""\x80 Rise")) + textHUDdraw(M_GetText("\x82""SPIN:""\x80 Lower")) + + if (G_IsSpecialStage(gamemap)) + textHUDdraw(M_GetText("\x82""Wait for the stage to end...")) + else if (G_PlatformGametype()) + { + if (G_GametypeUsesCoopLives()) { - if (gametype == GT_HIDEANDSEEK) //hide and seek. - sprintf(pstext, "%s", M_GetText("HIDE BEFORE TIME RUNS OUT!")); - else //default - sprintf(pstext, "%s", M_GetText("FLEE BEFORE YOU ARE HUNTED!")); + if (stplyr->lives <= 0 + && cv_cooplives.value == 2 + && (netgame || multiplayer)) + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (&players[i] == stplyr) + continue; + + if (players[i].lives > 1) + break; + } + + if (i != MAXPLAYERS) + textHUDdraw(M_GetText("You'll steal a life on respawn...")) + else + textHUDdraw(M_GetText("Wait to respawn...")) + } + else + textHUDdraw(M_GetText("Wait to respawn...")) } + } + else if (G_GametypeHasSpectators()) + textHUDdraw(M_GetText("\x82""FIRE:""\x80 Enter game")) + } + + if (gametype == GT_COOP && (!stplyr->spectator || (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap))) && (stplyr->exiting || (stplyr->pflags & PF_FINISHED))) + { + UINT8 numneeded = (G_IsSpecialStage(gamemap) ? 4 : cv_playersforexit.value); + if (numneeded) + { + INT32 i, total = 0, exiting = 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + if (players[i].lives <= 0) + continue; + + total++; + if (players[i].exiting || (players[i].pflags & PF_FINISHED)) + exiting++; + } + + if (numneeded != 4) + { + total *= cv_playersforexit.value; + if (total & 3) + total += 4; // round up + total /= 4; + } + + if (exiting < total) + { + if (!splitscreen && !donef12) + { + textHUDdraw(M_GetText("\x82""VIEWPOINT:""\x80 Switch view")) + donef12 = true; + } + total -= exiting; + textHUDdraw(va(M_GetText("%d player%s remaining"), total, ((total == 1) ? "" : "s"))) + } + } + } + else if ((gametyperules & GTR_TAG) && (!stplyr->spectator)) + { + if (leveltime < hidetime * TICRATE) + { + if (stplyr->pflags & PF_TAGIT) + { + if (gametyperules & GTR_BLINDFOLDED) + textHUDdraw(M_GetText("\x82""You are blindfolded!")) + textHUDdraw(M_GetText("Waiting for players to hide...")) + } + else if (gametype == GT_HIDEANDSEEK) + textHUDdraw(M_GetText("Hide before time runs out!")) else - sprintf(pstext, "%s", M_GetText("HIDE TIME REMAINING:")); + textHUDdraw(M_GetText("Flee before you are hunted!")) + } + else if (gametype == GT_HIDEANDSEEK && !(stplyr->pflags & PF_TAGIT)) + { + if (!splitscreen && !donef12) + { + textHUDdraw(M_GetText("\x82""VIEWPOINT:""\x80 Switch view")) + donef12 = true; + } + if (gametyperules & GTR_HIDEFROZEN) + textHUDdraw(M_GetText("You cannot move while hiding.")) } } + +#undef textHUDdraw + +} + +static inline void ST_drawRaceHUD(void) +{ + if (leveltime > TICRATE && leveltime <= 5*TICRATE) + ST_drawRaceNum(4*TICRATE - leveltime); +} + +static void ST_drawTeamHUD(void) +{ + patch_t *p; +#define SEP 20 + + if (F_GetPromptHideHud(0)) // y base is 0 + return; + + if (gametyperules & GTR_TEAMFLAGS) + p = bflagico; else - { - if (cv_timelimit.value && timelimitintics >= leveltime) - sprintf(pstime, "%d", (timelimitintics-leveltime)/TICRATE); + p = bmatcico; - if (stplyr->pflags & PF_TAGIT) - sprintf(pstext, "%s", M_GetText("YOU'RE IT!")); - else - { - if (cv_timelimit.value) - sprintf(pstext, "%s", M_GetText("TIME REMAINING:")); - else //Since having no hud message in tag is not characteristic: - sprintf(pstext, "%s", M_GetText("NO TIME LIMIT")); - } - } + if (LUA_HudEnabled(hud_teamscores)) + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); - // Print the stuff. - if (pstext[0]) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(168), 0, pstext); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, pstext); - } - if (pstime[0]) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, pstime); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(192), 0, pstime); - } -} - -static void ST_drawCTFHUD(void) -{ - INT32 i; - UINT16 whichflag = 0; - - // Draw the flags - V_DrawSmallScaledPatch(256, (splitscreen) ? STRINGY(160) : STRINGY(176), V_HUDTRANS, rflagico); - V_DrawSmallScaledPatch(288, (splitscreen) ? STRINGY(160) : STRINGY(176), V_HUDTRANS, bflagico); - - for (i = 0; i < MAXPLAYERS; i++) - { - if (players[i].gotflag & GF_REDFLAG) // Red flag isn't at base - V_DrawScaledPatch(256, (splitscreen) ? STRINGY(156) : STRINGY(174), V_HUDTRANS, nonicon); - else if (players[i].gotflag & GF_BLUEFLAG) // Blue flag isn't at base - V_DrawScaledPatch(288, (splitscreen) ? STRINGY(156) : STRINGY(174), V_HUDTRANS, nonicon); - - whichflag |= players[i].gotflag; - if ((whichflag & (GF_REDFLAG|GF_BLUEFLAG)) == (GF_REDFLAG|GF_BLUEFLAG)) - break; // both flags were found, let's stop early - } - - // YOU have a flag. Display a monitor-like icon for it. - if (stplyr->gotflag) - { - patch_t *p = (stplyr->gotflag & GF_REDFLAG) ? gotrflag : gotbflag; - - if (splitscreen) - V_DrawSmallScaledPatch(312, STRINGY(24) + 42, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - else - V_DrawScaledPatch(304, 24 + 84, V_SNAPTORIGHT|V_SNAPTOTOP|V_HUDTRANS, p); - } - - // Display a countdown timer showing how much time left until the flag your team dropped returns to base. - { - char timeleft[33]; - if (redflag && redflag->fuse > 1) - { - sprintf(timeleft, "%u", (redflag->fuse / TICRATE)); - V_DrawCenteredString(268, STRINGY(184), V_YELLOWMAP|V_HUDTRANS, timeleft); - } - - if (blueflag && blueflag->fuse > 1) - { - sprintf(timeleft, "%u", (blueflag->fuse / TICRATE)); - V_DrawCenteredString(300, STRINGY(184), V_YELLOWMAP|V_HUDTRANS, timeleft); - } - } -} - -// Draws "Red Team", "Blue Team", or "Spectator" for team gametypes. -static inline void ST_drawTeamName(void) -{ - if (stplyr->ctfteam == 1) - V_DrawString(256, (splitscreen) ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "RED TEAM"); - else if (stplyr->ctfteam == 2) - V_DrawString(248, (splitscreen) ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "BLUE TEAM"); + if (gametyperules & GTR_TEAMFLAGS) + p = rflagico; else - V_DrawString(244, (splitscreen) ? STRINGY(184) : STRINGY(192), V_HUDTRANSHALF, "SPECTATOR"); + p = rmatcico; + + if (LUA_HudEnabled(hud_teamscores)) + V_DrawSmallScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(p->width)/4, 4, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, p); + + if (!(gametyperules & GTR_TEAMFLAGS)) + goto num; + { + INT32 i; + UINT16 whichflag = 0; + + // Show which flags aren't at base. + for (i = 0; i < MAXPLAYERS; i++) + { + // Blue flag isn't at base + if (players[i].gotflag & GF_BLUEFLAG && LUA_HudEnabled(hud_teamscores)) + V_DrawScaledPatch(BASEVIDWIDTH/2 - SEP - SHORT(nonicon->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon); + + // Red flag isn't at base + if (players[i].gotflag & GF_REDFLAG && LUA_HudEnabled(hud_teamscores)) + V_DrawScaledPatch(BASEVIDWIDTH/2 + SEP - SHORT(nonicon2->width)/2, 0, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, nonicon2); + + whichflag |= players[i].gotflag; + + if ((whichflag & (GF_REDFLAG|GF_BLUEFLAG)) == (GF_REDFLAG|GF_BLUEFLAG)) + break; // both flags were found, let's stop early + } + + // Display a countdown timer showing how much time left until the flag returns to base. + { + if (blueflag && blueflag->fuse > 1 && LUA_HudEnabled(hud_teamscores)) + V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (blueflag->fuse / TICRATE))); + + if (redflag && redflag->fuse > 1 && LUA_HudEnabled(hud_teamscores)) + V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 8, V_YELLOWMAP|V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", (redflag->fuse / TICRATE))); + } + } + +num: + if (LUA_HudEnabled(hud_teamscores)) + V_DrawCenteredString(BASEVIDWIDTH/2 - SEP, 16, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", bluescore)); + + if (LUA_HudEnabled(hud_teamscores)) + V_DrawCenteredString(BASEVIDWIDTH/2 + SEP, 16, V_HUDTRANS|V_PERPLAYER|V_SNAPTOTOP, va("%u", redscore)); + +#undef SEP } -static void ST_drawSpecialStageHUD(void) +/*static void ST_drawSpecialStageHUD(void) { - if (totalrings > 0) - ST_DrawNumFromHudWS(HUD_SS_TOTALRINGS, totalrings); - - if (leveltime < 5*TICRATE && totalrings > 0) + if (ssspheres > 0) { - ST_DrawPatchFromHud(HUD_GETRINGS, getall); - ST_DrawNumFromHud(HUD_GETRINGSNUM, totalrings); + if (hudinfo[HUD_SS_TOTALRINGS].x) + ST_DrawNumFromHud(HUD_SS_TOTALRINGS, ssspheres, V_HUDTRANS); + else if (cv_timetic.value == 2) + V_DrawTallNum(hudinfo[HUD_RINGSNUMTICS].x, hudinfo[HUD_SS_TOTALRINGS].y, hudinfo[HUD_RINGSNUMTICS].f|V_PERPLAYER|V_HUDTRANS, ssspheres); + else + V_DrawTallNum(hudinfo[HUD_RINGSNUM].x, hudinfo[HUD_SS_TOTALRINGS].y, hudinfo[HUD_RINGSNUM].f|V_PERPLAYER|V_HUDTRANS, ssspheres); + } + + if (leveltime < 5*TICRATE && ssspheres > 0) + { + ST_DrawPatchFromHud(HUD_GETRINGS, getall, V_HUDTRANS); + ST_DrawNumFromHud(HUD_GETRINGSNUM, ssspheres, V_HUDTRANS); } if (sstimer) { - V_DrawString(hudinfo[HUD_TIMELEFT].x, STRINGY(hudinfo[HUD_TIMELEFT].y), V_HUDTRANS, M_GetText("TIME LEFT")); - ST_DrawNumFromHud(HUD_TIMELEFTNUM, sstimer/TICRATE); + V_DrawString(hudinfo[HUD_TIMELEFT].x, hudinfo[HUD_TIMELEFT].y, hudinfo[HUD_TIMELEFT].f|V_PERPLAYER|V_HUDTRANS, M_GetText("TIME LEFT")); + ST_DrawNumFromHud(HUD_TIMELEFTNUM, sstimer/TICRATE, V_HUDTRANS); } else - ST_DrawPatchFromHud(HUD_TIMEUP, timeup); -} + ST_DrawPatchFromHud(HUD_TIMEUP, timeup, V_HUDTRANS); +}*/ static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offset) { @@ -1650,7 +2482,8 @@ static INT32 ST_drawEmeraldHuntIcon(mobj_t *hunt, patch_t **patches, INT32 offse interval = 0; } - V_DrawScaledPatch(hudinfo[HUD_HUNTPICS].x+offset, STRINGY(hudinfo[HUD_HUNTPICS].y), V_HUDTRANS, patches[i]); + if (!F_GetPromptHideHud(hudinfo[HUD_HUNTPICS].y)) + V_DrawScaledPatch(hudinfo[HUD_HUNTPICS].x+offset, hudinfo[HUD_HUNTPICS].y, hudinfo[HUD_HUNTPICS].f|V_PERPLAYER|V_HUDTRANS, patches[i]); return interval; } @@ -1709,123 +2542,153 @@ static void ST_doItemFinderIconsAndSound(void) return; // Scan thinkers to find emblem mobj with these ids - for (th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) continue; + mo2 = (mobj_t *)th; - if (mo2->type == MT_EMBLEM) + if (mo2->type != MT_EMBLEM) + continue; + + if (!(mo2->flags & MF_SPECIAL)) + continue; + + for (i = 0; i < stemblems; ++i) { - if (!(mo2->flags & MF_SPECIAL)) - continue; - - for (i = 0; i < stemblems; ++i) + if (mo2->health == emblems[i] + 1) { - if (mo2->health == emblems[i]+1) - { - soffset = (i * 20) - ((stemblems-1) * 10); + soffset = (i * 20) - ((stemblems - 1) * 10); - newinterval = ST_drawEmeraldHuntIcon(mo2, itemhoming, soffset); - if (newinterval && (!interval || newinterval < interval)) - interval = newinterval; + newinterval = ST_drawEmeraldHuntIcon(mo2, itemhoming, soffset); + if (newinterval && (!interval || newinterval < interval)) + interval = newinterval; - break; - } + break; } } + } if (!(P_AutoPause() || paused) && interval > 0 && leveltime && leveltime % interval == 0) S_StartSound(NULL, sfx_emfind); } +// // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // static void ST_overlayDrawer(void) { - //hu_showscores = auto hide score/time/rings when tab rankings are shown + // Decide whether to draw the stage title or not + boolean stagetitle = false; + + // Check for a valid level title + // If the HUD is enabled + // And, if Lua is running, if the HUD library has the stage title enabled + if (G_IsTitleCardAvailable() && *mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer))) + { + stagetitle = true; + ST_preDrawTitleCard(); + } + + // hu_showscores = auto hide score/time/rings when tab rankings are shown if (!(hu_showscores && (netgame || multiplayer))) { - if (maptol & TOL_NIGHTS) + if ((maptol & TOL_NIGHTS || G_IsSpecialStage(gamemap)) && + !F_GetPromptHideHudAll()) ST_drawNiGHTSHUD(); else { -#ifdef HAVE_BLUA if (LUA_HudEnabled(hud_score)) -#endif - ST_drawScore(); -#ifdef HAVE_BLUA + ST_drawScore(); if (LUA_HudEnabled(hud_time)) -#endif - ST_drawTime(); -#ifdef HAVE_BLUA + ST_drawTime(); if (LUA_HudEnabled(hud_rings)) -#endif - ST_drawRings(); - if (G_GametypeUsesLives() -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_lives) -#endif - ) - ST_drawLives(); + ST_drawRings(); + + if (!modeattacking && LUA_HudEnabled(hud_lives)) + ST_drawLivesArea(); } } - // GAME OVER pic - if (G_GametypeUsesLives() && stplyr->lives <= 0 && !(hu_showscores && (netgame || multiplayer))) + // GAME OVER hud + if ((gametype == GT_COOP) + && (netgame || multiplayer) + && (cv_cooplives.value == 0)) + ; + else if ((G_GametypeUsesLives() || gametype == GT_RACE) && stplyr->lives <= 0 && !(hu_showscores && (netgame || multiplayer))) { - patch_t *p; + INT32 i = MAXPLAYERS; + INT32 deadtimer = stplyr->spectator ? TICRATE : (stplyr->deadtimer-(TICRATE<<1)); - if (countdown == 1) - p = timeover; - else - p = sboover; + if (G_GametypeUsesCoopLives() + && (netgame || multiplayer) + && (cv_cooplives.value != 1)) + { + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; - V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, STRINGY(BASEVIDHEIGHT/2 - (SHORT(p->height)/2)), 0, p); + if (&players[i] == stplyr) + continue; + + if (players[i].lives > 0) + break; + } + } + + if (i == MAXPLAYERS && deadtimer >= 0) + { + INT32 lvlttlx = min(6*deadtimer, BASEVIDWIDTH/2); + UINT32 flags = V_PERPLAYER|(stplyr->spectator ? V_HUDTRANSHALF : V_HUDTRANS); + + V_DrawScaledPatch(lvlttlx - 8, BASEVIDHEIGHT/2, flags, (countdown == 1 ? slidtime : slidgame)); + V_DrawScaledPatch(BASEVIDWIDTH + 8 - lvlttlx, BASEVIDHEIGHT/2, flags, slidover); + } } + if (G_GametypeHasTeams()) + ST_drawTeamHUD(); if (!hu_showscores) // hide the following if TAB is held { // Countdown timer for Race Mode - if (countdown) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(176), 0, va("%d", countdown/TICRATE)); + if (countdown > 1) + { + tic_t time = countdown/TICRATE + 1; + if (time < 4) + ST_drawRaceNum(countdown); + else + { + tic_t num = time; + INT32 sz = SHORT(tallnum[0]->width)/2, width = 0; + do + { + width += sz; + num /= 10; + } while (num); + V_DrawTallNum((BASEVIDWIDTH/2) + width, ((3*BASEVIDHEIGHT)>>2) - 7, V_PERPLAYER, time); + //V_DrawCenteredString(BASEVIDWIDTH/2, 176, V_PERPLAYER, va("%d", countdown/TICRATE + 1)); + } + } // If you are in overtime, put a big honkin' flashin' message on the screen. - if (G_RingSlingerGametype() && cv_overtime.value - && (leveltime > (timelimitintics + TICRATE/2)) && cv_timelimit.value && (leveltime/TICRATE % 2 == 0)) - { - if (splitscreen) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(168), 0, M_GetText("OVERTIME!")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(184), 0, M_GetText("OVERTIME!")); - } + if (((gametyperules & GTR_TIMELIMIT) && (gametyperules & GTR_OVERTIME)) && cv_overtime.value + && (leveltime > (timelimitintics + TICRATE/2)) && cv_timelimit.value && (leveltime/TICRATE % 2 == 0)) + V_DrawCenteredString(BASEVIDWIDTH/2, 184, V_PERPLAYER, M_GetText("OVERTIME!")); // Draw Match-related stuff //\note Match HUD is drawn no matter what gametype. // ... just not if you're a spectator. - if (!stplyr->spectator) + if (!stplyr->spectator && LUA_HudEnabled(hud_weaponrings)) ST_drawMatchHUD(); // Race HUD Stuff - if (gametype == GT_RACE || gametype == GT_COMPETITION) + if (gametyperules & GTR_RACE) ST_drawRaceHUD(); - // Tag HUD Stuff - else if (gametype == GT_TAG || gametype == GT_HIDEANDSEEK) - ST_drawTagHUD(); - // CTF HUD Stuff - else if (gametype == GT_CTF) - ST_drawCTFHUD(); - - // Team names for team gametypes - if (G_GametypeHasTeams()) - ST_drawTeamName(); - - // Special Stage HUD - if (!useNightsSS && G_IsSpecialStage(gamemap) && stplyr == &players[displayplayer]) - ST_drawSpecialStageHUD(); // Emerald Hunt Indicators if (cv_itemfinder.value && M_SecretUnlocked(SECRET_ITEMFINDER)) @@ -1833,9 +2696,6 @@ static void ST_overlayDrawer(void) else ST_doHuntIconsAndSound(); - if (stplyr->powers[pw_gravityboots] > 3*TICRATE || (stplyr->powers[pw_gravityboots] && leveltime & 1)) - V_DrawScaledPatch(hudinfo[HUD_GRAVBOOTSICO].x, STRINGY(hudinfo[HUD_GRAVBOOTSICO].y), V_SNAPTORIGHT, gravboots); - if(!P_IsLocalPlayer(stplyr)) { char name[MAXPLAYERNAME+1]; @@ -1848,79 +2708,66 @@ static void ST_overlayDrawer(void) } // This is where we draw all the fun cheese if you have the chasecam off! - if ((stplyr == &players[displayplayer] && !camera.chase) - || ((splitscreen && stplyr == &players[secondarydisplayplayer]) && !camera2.chase)) + if (!(maptol & TOL_NIGHTS)) { - ST_drawFirstPersonHUD(); + if ((stplyr == &players[displayplayer] && !camera.chase) + || ((splitscreen && stplyr == &players[secondarydisplayplayer]) && !camera2.chase)) + { + ST_drawFirstPersonHUD(); + if (cv_powerupdisplay.value) + ST_drawPowerupHUD(); // same as it ever was... + } + else if (cv_powerupdisplay.value == 2) + ST_drawPowerupHUD(); // same as it ever was... } } + else if (!(netgame || multiplayer) && cv_powerupdisplay.value == 2) + ST_drawPowerupHUD(); // same as it ever was... -#ifdef HAVE_BLUA if (!(netgame || multiplayer) || !hu_showscores) LUAh_GameHUD(stplyr); -#endif // draw level title Tails - if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)) -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_stagetitle) -#endif - ) - ST_drawLevelTitle(); + if (stagetitle && (!WipeInAction) && (!WipeStageTitle)) + ST_drawTitleCard(); - if (!hu_showscores && !splitscreen && netgame && displayplayer == consoleplayer) - { - if (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press Viewpoint Key to watch a player.")); - else if (gametype == GT_HIDEANDSEEK && - (!stplyr->spectator && !(stplyr->pflags & PF_TAGIT)) && (leveltime > hidetime * TICRATE)) - { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(116), 0, M_GetText("You cannot move while hiding.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press Viewpoint Key to watch a player.")); - } - else if (!G_PlatformGametype() && stplyr->playerstate == PST_DEAD && stplyr->lives) //Death overrides spectator text. - { - INT32 respawntime = cv_respawntime.value - stplyr->deadtimer/TICRATE; - if (respawntime > 0 && !stplyr->spectator) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, va(M_GetText("Respawn in: %d second%s."), respawntime, respawntime == 1 ? "" : "s")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Jump to respawn.")); - } - else if (stplyr->spectator -#ifdef HAVE_BLUA - && LUA_HudEnabled(hud_textspectator) -#endif - ) - { - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), V_HUDTRANSHALF, M_GetText("You are a spectator.")); - if (G_GametypeHasTeams()) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Fire to be assigned to a team.")); - else if (G_IsSpecialStage(gamemap) && useNightsSS) - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("You cannot join the game until the stage has ended.")); - else - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Fire to enter the game.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(148), V_HUDTRANSHALF, M_GetText("Press Viewpoint Key to watch a player.")); - V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(164), V_HUDTRANSHALF, M_GetText("Press Jump to float and Spin to sink.")); - } - } + if (!hu_showscores && (netgame || multiplayer) && LUA_HudEnabled(hud_textspectator)) + ST_drawTextHUD(); + + if (modeattacking && !(demoplayback && hu_showscores)) + ST_drawInput(); ST_drawDebugInfo(); } void ST_Drawer(void) { + if (needpatchrecache) + R_ReloadHUDGraphics(); + #ifdef SEENAMES if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo) { - if (cv_seenames.value == 1) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]); - else if (cv_seenames.value == 2) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, - va("%s%s", G_GametypeHasTeams() ? ((seenplayer->ctfteam == 1) ? "\x85" : "\x84") : "", player_names[seenplayer-players])); - else //if (cv_seenames.value == 3) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, - va("%s%s", !G_RingSlingerGametype() || (G_GametypeHasTeams() && players[consoleplayer].ctfteam == seenplayer->ctfteam) - ? "\x83" : "\x85", player_names[seenplayer-players])); + INT32 c = 0; + switch (cv_seenames.value) + { + case 1: // Colorless + break; + case 2: // Team + if (G_GametypeHasTeams()) + c = (seenplayer->ctfteam == 1) ? V_REDMAP : V_BLUEMAP; + break; + case 3: // Ally/Foe + default: + // Green = Ally, Red = Foe + if (G_GametypeHasTeams()) + c = (players[consoleplayer].ctfteam == seenplayer->ctfteam) ? V_GREENMAP : V_REDMAP; + else // Everyone is an ally, or everyone is a foe! + c = (G_RingSlingerGametype()) ? V_REDMAP : V_GREENMAP; + break; + } + + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF|c, player_names[seenplayer-players]); } #endif @@ -1941,6 +2788,24 @@ void ST_Drawer(void) #endif if (rendermode != render_none) ST_doPaletteStuff(); + // Blindfold! + if ((gametyperules & GTR_BLINDFOLDED) + && (leveltime < hidetime * TICRATE)) + { + if (players[displayplayer].pflags & PF_TAGIT) + { + stplyr = &players[displayplayer]; + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31|V_PERPLAYER); + } + else if (splitscreen && players[secondarydisplayplayer].pflags & PF_TAGIT) + { + stplyr = &players[secondarydisplayplayer]; + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31|V_PERPLAYER); + } + } + + st_translucency = cv_translucenthud.value; + if (st_overlay) { // No deadview! diff --git a/src/st_stuff.h b/src/st_stuff.h index 6c4140ce3..4ea307d2b 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -24,7 +24,7 @@ // // Called by main loop. -void ST_Ticker(void); +void ST_Ticker(boolean run); // Called by main loop. void ST_Drawer(void); @@ -42,14 +42,22 @@ void ST_UnloadGraphics(void); void ST_LoadGraphics(void); // face load graphics, called when skin changes -void ST_LoadFaceGraphics(char *facestr, char *superstr, INT32 playernum); +void ST_LoadFaceGraphics(INT32 playernum); void ST_ReloadSkinFaceGraphics(void); -#ifdef DELFILE -void ST_UnLoadFaceGraphics(INT32 skinnum); -#endif void ST_doPaletteStuff(void); +// title card +void ST_startTitleCard(void); +void ST_runTitleCard(void); +void ST_drawTitleCard(void); +void ST_preDrawTitleCard(void); +void ST_preLevelTitleCardDrawer(void); +void ST_drawWipeTitleCard(void); + +extern tic_t lt_ticker, lt_lasttic; +extern tic_t lt_exitticker, lt_endtime; + // return if player a is in the same team as player b boolean ST_SameTeam(player_t *a, player_t *b); @@ -58,6 +66,8 @@ boolean ST_SameTeam(player_t *a, player_t *b); //-------------------- extern boolean st_overlay; // sb overlay on or off when fullscreen +extern INT32 st_palette; // 0 is default, any others are special palettes. +extern INT32 st_translucency; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission @@ -69,43 +79,35 @@ extern patch_t *sboperiod; extern patch_t *faceprefix[MAXSKINS]; // face status patches extern patch_t *superprefix[MAXSKINS]; // super face status patches extern patch_t *livesback; +extern patch_t *stlivex; extern patch_t *ngradeletters[7]; /** HUD location information (don't move this comment) */ typedef struct { - INT32 x, y; + INT32 x, y, f; } hudinfo_t; typedef enum { - HUD_LIVESNAME, - HUD_LIVESPIC, - HUD_LIVESNUM, - HUD_LIVESX, + HUD_LIVES, HUD_RINGS, - HUD_RINGSSPLIT, HUD_RINGSNUM, - HUD_RINGSNUMSPLIT, + HUD_RINGSNUMTICS, HUD_SCORE, HUD_SCORENUM, HUD_TIME, - HUD_TIMESPLIT, HUD_MINUTES, - HUD_MINUTESSPLIT, HUD_TIMECOLON, - HUD_TIMECOLONSPLIT, HUD_SECONDS, - HUD_SECONDSSPLIT, HUD_TIMETICCOLON, HUD_TICS, HUD_SS_TOTALRINGS, - HUD_SS_TOTALRINGS_SPLIT, HUD_GETRINGS, HUD_GETRINGSNUM, @@ -113,8 +115,7 @@ typedef enum HUD_TIMELEFTNUM, HUD_TIMEUP, HUD_HUNTPICS, - HUD_GRAVBOOTSICO, - HUD_LAP, + HUD_POWERUPS, NUMHUDITEMS } hudnum_t; diff --git a/src/strcasestr.c b/src/strcasestr.c new file mode 100644 index 000000000..b266278ed --- /dev/null +++ b/src/strcasestr.c @@ -0,0 +1,111 @@ +/* +strcasestr -- case insensitive substring searching function. +*/ +/* +Copyright 2019-2020 James R. +All rights reserved. + +Redistribution and use in source forms, with or without modification, is +permitted provided that the following condition is met: + +1. Redistributions of source code must retain the above copyright notice, this + condition and the following disclaimer. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +static inline int +trycmp (char **pp, char *cp, + const char *q, size_t qn) +{ + char *p; + p = (*pp); + if (strncasecmp(p, q, qn) == 0) + return 0; + (*pp) = strchr(&p[1], (*cp)); + return 1; +} + +static inline void +swapp (char ***ppap, char ***ppbp, char **cpap, char **cpbp) +{ + char **pp; + char *p; + + pp = *ppap; + *ppap = *ppbp; + *ppbp = pp; + + p = *cpap; + *cpap = *cpbp; + *cpbp = p; +} + +char * +strcasestr (const char *s, const char *q) +{ + size_t qn; + + char uc; + char lc; + + char *up; + char *lp; + + char **ppa; + char **ppb; + + char *cpa; + char *cpb; + + uc = toupper(*q); + lc = tolower(*q); + + up = strchr(s, uc); + lp = strchr(s, lc); + + if (!( (intptr_t)up|(intptr_t)lp )) + return 0; + + if (!lp || ( up && up < lp )) + { + ppa = &up; + ppb = &lp; + + cpa = &uc; + cpb = &lc; + } + else + { + ppa = &lp; + ppb = &up; + + cpa = &lc; + cpb = &uc; + } + + qn = strlen(q); + + for (;;) + { + if (trycmp(ppa, cpa, q, qn) == 0) + return (*ppa); + + if (!( (intptr_t)up|(intptr_t)lp )) + break; + + if (!(*ppa) || ( (*ppb) && (*ppb) < (*ppa) )) + swapp(&ppa, &ppb, &cpa, &cpb); + } + + return 0; +} diff --git a/src/string.c b/src/string.c index 2a03e8729..e430c5cc3 100644 --- a/src/string.c +++ b/src/string.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by Graue. -// Copyright (C) 2006-2018 by Sonic Team Junior. +// Copyright (C) 2006-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -50,3 +50,5 @@ size_t strlcpy(char *dst, const char *src, size_t siz) } #endif + +#include "strcasestr.c" diff --git a/src/tables.c b/src/tables.c index 7d5137075..00424db22 100644 --- a/src/tables.c +++ b/src/tables.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -168,12 +168,10 @@ angle_t FixedAngle(fixed_t fa) } -#if !(defined _NDS) || !(defined NONET) #include "t_ftan.c" #include "t_fsin.c" fixed_t *finecosine = &finesine[FINEANGLES/4]; -#endif #include "t_tan2a.c" diff --git a/src/tables.h b/src/tables.h index e82b147df..953d891ce 100644 --- a/src/tables.h +++ b/src/tables.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -25,7 +25,6 @@ #define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000 #define FINEANGLE_C(x) ((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK) // ((x*(ANGLE_45/45))>>ANGLETOFINESHIFT) & FINEMASK -#if !(defined _NDS) || !(defined NONET) // Effective size is 10240. extern fixed_t finesine[5*FINEANGLES/4]; @@ -34,7 +33,6 @@ extern fixed_t *finecosine; // Effective size is 4096. extern fixed_t finetangent[FINEANGLES/2]; -#endif #define ANG1 0x00B60B61 //0.B6~ #define ANG2 0x016C16C1 //.6C1~ @@ -114,17 +112,9 @@ void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z); // The table values in tables.c are calculated with this many fractional bits. #define FINE_FRACBITS 16 -#if (defined _NDS) && (defined NONET) -// Use the NDS's trig functions. This would break netplay, so we only do -// it if NONET is defined. -#define FINESINE(n) ((fixed_t)sinLerp((INT16)(((INT32)(n))<<(ANGLETOFINESHIFT-17))) << (FRACBITS - 12)) -#define FINECOSINE(n) ((fixed_t)cosLerp((INT16)(((INT32)(n))<<(ANGLETOFINESHIFT-17))) << (FRACBITS - 12)) -#define FINETANGENT(n) ((fixed_t)tanLerp((INT16)(((INT32)(n)-(FINEANGLES>>2))<<(ANGLETOFINESHIFT-17))) << (FRACBITS - 12)) -#else // These macros should be used in case FRACBITS < FINE_FRACBITS. #define FINESINE(n) (finesine[n]>>(FINE_FRACBITS-FRACBITS)) #define FINECOSINE(n) (finecosine[n]>>(FINE_FRACBITS-FRACBITS)) #define FINETANGENT(n) (finetangent[n]>>(FINE_FRACBITS-FRACBITS)) -#endif #endif diff --git a/src/tmap.nas b/src/tmap.nas index 78840106f..106f38e96 100644 --- a/src/tmap.nas +++ b/src/tmap.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DooM Legacy Team. -;; Copyright (C) 1999-2018 by Sonic Team Junior. +;; Copyright (C) 1999-2020 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. @@ -17,7 +17,7 @@ [BITS 32] %define FRACBITS 16 -%define TRANSPARENTPIXEL 247 +%define TRANSPARENTPIXEL 255 %ifdef LINUX %macro cextern 1 diff --git a/src/tmap.s b/src/tmap.s index babd4ec1a..3a4cf2e1a 100644 --- a/src/tmap.s +++ b/src/tmap.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -60,7 +60,7 @@ C(vidwidth): .long 0 //use this one out of the inner loops //so you don't need to patch everywhere... #ifdef USEASM -#if !defined( LINUX) && !defined( __OS2__) +#if !defined( LINUX) .text #endif .globl C(ASM_PatchRowBytes) @@ -616,7 +616,7 @@ vskydone: ystep: .long 0 xstep: .long 0 C(texwidth): .long 64 // texture width -#if !defined( LINUX) && !defined( __OS2__) +#if !defined( LINUX) .text #endif #ifdef LINUX @@ -1338,7 +1338,7 @@ wdone: .data advancetable: .long 0, 0 -#if !defined( LINUX) && !defined( __OS2__) +#if !defined( LINUX) .text #endif #ifdef LINUX diff --git a/src/tmap_asm.s b/src/tmap_asm.s index 99cb0b627..3cd0f87cc 100644 --- a/src/tmap_asm.s +++ b/src/tmap_asm.s @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. diff --git a/src/tmap_mmx.nas b/src/tmap_mmx.nas index 39380a065..15b97499d 100644 --- a/src/tmap_mmx.nas +++ b/src/tmap_mmx.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DOSDOOM. -;; Copyright (C) 2010-2018 by Sonic Team Junior. +;; Copyright (C) 2010-2020 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. @@ -18,7 +18,7 @@ [BITS 32] %define FRACBITS 16 -%define TRANSPARENTPIXEL 247 +%define TRANSPARENTPIXEL 255 %ifdef LINUX %macro cextern 1 diff --git a/src/tmap_vc.nas b/src/tmap_vc.nas index e943d48d8..49eb21a6d 100644 --- a/src/tmap_vc.nas +++ b/src/tmap_vc.nas @@ -1,7 +1,7 @@ ;; SONIC ROBO BLAST 2 ;;----------------------------------------------------------------------------- ;; Copyright (C) 1998-2000 by DooM Legacy Team. -;; Copyright (C) 1999-2018 by Sonic Team Junior. +;; Copyright (C) 1999-2020 by Sonic Team Junior. ;; ;; This program is free software distributed under the ;; terms of the GNU General Public License, version 2. diff --git a/src/v_video.c b/src/v_video.c index cfe7d0360..2d1014c23 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,8 +15,12 @@ #include "doomdef.h" #include "r_local.h" +#include "p_local.h" // stplyr +#include "g_game.h" // players #include "v_video.h" +#include "st_stuff.h" #include "hu_stuff.h" +#include "f_finale.h" #include "r_draw.h" #include "console.h" @@ -38,11 +42,39 @@ UINT8 *screens[5]; // screens[3] = fade screen start // screens[4] = fade screen end, postimage tempoarary buffer -static CV_PossibleValue_t gamma_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}}; -static void CV_usegamma_OnChange(void); - consvar_t cv_ticrate = {"showfps", "No", 0, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_usegamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_usegamma_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +static void CV_palette_OnChange(void); + +static CV_PossibleValue_t gamma_cons_t[] = {{-15, "MIN"}, {5, "MAX"}, {0, NULL}}; +consvar_t cv_globalgamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +static CV_PossibleValue_t saturation_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; +consvar_t cv_globalsaturation = {"saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +#define huecoloursteps 4 + +static CV_PossibleValue_t hue_cons_t[] = {{0, "MIN"}, {(huecoloursteps*6)-1, "MAX"}, {0, NULL}}; +consvar_t cv_rhue = {"rhue", "0", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_yhue = {"yhue", "4", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ghue = {"ghue", "8", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_chue = {"chue", "12", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_bhue = {"bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mhue = {"mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_rgamma = {"rgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ygamma = {"ygamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ggamma = {"ggamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cgamma = {"cgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_bgamma = {"bgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_mgamma = {"mgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_rsaturation = {"rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_ysaturation = {"ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gsaturation = {"gsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_csaturation = {"csaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_bsaturation = {"bsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_msaturation = {"msaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allcaps = {"allcaps", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -52,39 +84,212 @@ static CV_PossibleValue_t constextsize_cons_t[] = { static void CV_constextsize_OnChange(void); consvar_t cv_constextsize = {"con_textsize", "Medium", CV_SAVE|CV_CALL, constextsize_cons_t, CV_constextsize_OnChange, 0, NULL, NULL, 0, 0, NULL}; -#ifdef HWRENDER -static void CV_Gammaxxx_ONChange(void); -// Saved hardware mode variables -// - You can change them in software, -// but they won't do anything. -static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "LightPlanes"}, {0, NULL}}; +// local copy of the palette for V_GetColor() +RGBA_t *pLocalPalette = NULL; +RGBA_t *pMasterPalette = NULL; -consvar_t cv_voodoocompatibility = {"gr_voodoocompatibility", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfog = {"gr_fog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfogcolor = {"gr_fogcolor", "AAAAAA", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grsoftwarefog = {"gr_softwarefog", "Off", CV_SAVE, grsoftwarefog_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grgammared = {"gr_gammared", "127", CV_SAVE|CV_CALL, grgamma_cons_t, - CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grgammagreen = {"gr_gammagreen", "127", CV_SAVE|CV_CALL, grgamma_cons_t, - CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grgammablue = {"gr_gammablue", "127", CV_SAVE|CV_CALL, grgamma_cons_t, - CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL}; -#ifdef ALAM_LIGHTING -consvar_t cv_grdynamiclighting = {"gr_dynamiclighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grstaticlighting = {"gr_staticlighting", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grcoronas = {"gr_coronas", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE| CV_FLOAT, 0, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif +/* +The following was an extremely helpful resource when developing my Colour Cube LUT. +http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html +Please check it out if you're trying to maintain this. +toast 18/04/17 +*/ +float Cubepal[2][2][2][3]; +boolean Cubeapply = false; -static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}}; -// console variables in development -consvar_t cv_grmd2 = {"gr_md2", "Off", CV_SAVE, CV_MD2, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif - -const UINT8 gammatable[5][256] = +// returns whether to apply cube, selectively avoiding expensive operations +static boolean InitCube(void) { + boolean apply = false; + UINT8 q; + float working[2][2][2][3] = // the initial positions of the corners of the colour cube! + { + { + { + {0.0, 0.0, 0.0}, // black corner + {0.0, 0.0, 1.0} // blue corner + }, + { + {0.0, 1.0, 0.0}, // green corner + {0.0, 1.0, 1.0} // cyan corner + } + }, + { + { + {1.0, 0.0, 0.0}, // red corner + {1.0, 0.0, 1.0} // magenta corner + }, + { + {1.0, 1.0, 0.0}, // yellow corner + {1.0, 1.0, 1.0} // white corner + } + } + }; + float desatur[3]; // grey + float globalgammamul, globalgammaoffs; + boolean doinggamma; + +#define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) + + doinggamma = diffcons(cv_globalgamma); + +#define gammascale 8 + globalgammamul = (cv_globalgamma.value ? ((255 - (gammascale*abs(cv_globalgamma.value)))/255.0) : 1.0); + globalgammaoffs = ((cv_globalgamma.value > 0) ? ((gammascale*cv_globalgamma.value)/255.0) : 0.0); + desatur[0] = desatur[1] = desatur[2] = globalgammaoffs + (0.33*globalgammamul); + + if (doinggamma + || diffcons(cv_rhue) + || diffcons(cv_yhue) + || diffcons(cv_ghue) + || diffcons(cv_chue) + || diffcons(cv_bhue) + || diffcons(cv_mhue) + || diffcons(cv_rgamma) + || diffcons(cv_ygamma) + || diffcons(cv_ggamma) + || diffcons(cv_cgamma) + || diffcons(cv_bgamma) + || diffcons(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later) + { + float mod, tempgammamul, tempgammaoffs; + + apply = true; + + working[0][0][0][0] = working[0][0][0][1] = working[0][0][0][2] = globalgammaoffs; + working[1][1][1][0] = working[1][1][1][1] = working[1][1][1][2] = globalgammaoffs+globalgammamul; + +#define dohue(hue, gamma, loc) \ + tempgammamul = (gamma ? ((255 - (gammascale*abs(gamma)))/255.0)*globalgammamul : globalgammamul);\ + tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0) + globalgammaoffs : globalgammaoffs);\ + mod = ((hue % huecoloursteps)*(tempgammamul)/huecoloursteps);\ + switch (hue/huecoloursteps)\ + {\ + case 0:\ + default:\ + loc[0] = tempgammaoffs+tempgammamul;\ + loc[1] = tempgammaoffs+mod;\ + loc[2] = tempgammaoffs;\ + break;\ + case 1:\ + loc[0] = tempgammaoffs+tempgammamul-mod;\ + loc[1] = tempgammaoffs+tempgammamul;\ + loc[2] = tempgammaoffs;\ + break;\ + case 2:\ + loc[0] = tempgammaoffs;\ + loc[1] = tempgammaoffs+tempgammamul;\ + loc[2] = tempgammaoffs+mod;\ + break;\ + case 3:\ + loc[0] = tempgammaoffs;\ + loc[1] = tempgammaoffs+tempgammamul-mod;\ + loc[2] = tempgammaoffs+tempgammamul;\ + break;\ + case 4:\ + loc[0] = tempgammaoffs+mod;\ + loc[1] = tempgammaoffs;\ + loc[2] = tempgammaoffs+tempgammamul;\ + break;\ + case 5:\ + loc[0] = tempgammaoffs+tempgammamul;\ + loc[1] = tempgammaoffs;\ + loc[2] = tempgammaoffs+tempgammamul-mod;\ + break;\ + } + dohue(cv_rhue.value, cv_rgamma.value, working[1][0][0]); + dohue(cv_yhue.value, cv_ygamma.value, working[1][1][0]); + dohue(cv_ghue.value, cv_ggamma.value, working[0][1][0]); + dohue(cv_chue.value, cv_cgamma.value, working[0][1][1]); + dohue(cv_bhue.value, cv_bgamma.value, working[0][0][1]); + dohue(cv_mhue.value, cv_mgamma.value, working[1][0][1]); +#undef dohue + } + +#define dosaturation(a, e) a = ((1 - work)*e + work*a) +#define docvsat(cv_sat, hue, gamma, r, g, b) \ + if diffcons(cv_sat)\ + {\ + float work, mod, tempgammamul, tempgammaoffs;\ + apply = true;\ + work = (cv_sat.value/10.0);\ + mod = ((hue % huecoloursteps)*(1.0)/huecoloursteps);\ + if (hue & huecoloursteps)\ + mod = 2-mod;\ + else\ + mod += 1;\ + tempgammamul = (gamma ? ((255 - (gammascale*abs(gamma)))/255.0)*globalgammamul : globalgammamul);\ + tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0) + globalgammaoffs : globalgammaoffs);\ + for (q = 0; q < 3; q++)\ + dosaturation(working[r][g][b][q], (tempgammaoffs+(desatur[q]*mod*tempgammamul)));\ + } + + docvsat(cv_rsaturation, cv_rhue.value, cv_rgamma.value, 1, 0, 0); + docvsat(cv_ysaturation, cv_yhue.value, cv_ygamma.value, 1, 1, 0); + docvsat(cv_gsaturation, cv_ghue.value, cv_ggamma.value, 0, 1, 0); + docvsat(cv_csaturation, cv_chue.value, cv_cgamma.value, 0, 1, 1); + docvsat(cv_bsaturation, cv_bhue.value, cv_bgamma.value, 0, 0, 1); + docvsat(cv_msaturation, cv_mhue.value, cv_mgamma.value, 1, 0, 1); + +#undef gammascale + + if diffcons(cv_globalsaturation) + { + float work = (cv_globalsaturation.value/10.0); + + apply = true; + + for (q = 0; q < 3; q++) + { + dosaturation(working[1][0][0][q], desatur[q]); + dosaturation(working[0][1][0][q], desatur[q]); + dosaturation(working[0][0][1][q], desatur[q]); + + dosaturation(working[1][1][0][q], 2*desatur[q]); + dosaturation(working[0][1][1][q], 2*desatur[q]); + dosaturation(working[1][0][1][q], 2*desatur[q]); + } + } + +#undef dosaturation + +#undef diffcons + + if (!apply) + return false; + +#define dowork(i, j, k, l) \ + if (working[i][j][k][l] > 1.0)\ + working[i][j][k][l] = 1.0;\ + else if (working[i][j][k][l] < 0.0)\ + working[i][j][k][l] = 0.0;\ + Cubepal[i][j][k][l] = working[i][j][k][l] + for (q = 0; q < 3; q++) + { + dowork(0, 0, 0, q); + dowork(1, 0, 0, q); + dowork(0, 1, 0, q); + dowork(1, 1, 0, q); + dowork(0, 0, 1, q); + dowork(1, 0, 1, q); + dowork(0, 1, 1, q); + dowork(1, 1, 1, q); + } +#undef dowork + + return true; +} + +#ifdef BACKWARDSCOMPATCORRECTION +/* +So it turns out that the way gamma was implemented previously, the default +colour profile of the game was messed up. Since this bad decision has been +around for a long time, and the intent is to keep the base game looking the +same, I'm not gonna be the one to remove this base modification. +toast 20/04/17 +... welp yes i am (27/07/19, see the ifdef around it) +*/ +const UINT8 correctiontable[256] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, 17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48, @@ -100,98 +305,84 @@ const UINT8 gammatable[5][256] = 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, - 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}, - - {2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31, - 32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55, - 56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77, - 78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98, - 99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114, - 115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,129, - 130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145, - 146,147,148,148,149,150,151,152,153,154,155,156,157,158,159,160, - 161,162,163,163,164,165,166,167,168,169,170,171,172,173,174,175, - 175,176,177,178,179,180,181,182,183,184,185,186,186,187,188,189, - 190,191,192,193,194,195,196,196,197,198,199,200,201,202,203,204, - 205,205,206,207,208,209,210,211,212,213,214,214,215,216,217,218, - 219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232, - 233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246, - 247,248,249,250,251,252,252,253,254,255}, - - {4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42, - 43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69, - 70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93, - 94,95,96,97,98,100,101,102,103,104,105,106,107,108,109,110,111,112, - 113,114,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128, - 129,130,131,132,133,133,134,135,136,137,138,139,140,141,142,143,144, - 144,145,146,147,148,149,150,151,152,153,153,154,155,156,157,158,159, - 160,160,161,162,163,164,165,166,166,167,168,169,170,171,172,172,173, - 174,175,176,177,178,178,179,180,181,182,183,183,184,185,186,187,188, - 188,189,190,191,192,193,193,194,195,196,197,197,198,199,200,201,201, - 202,203,204,205,206,206,207,208,209,210,210,211,212,213,213,214,215, - 216,217,217,218,219,220,221,221,222,223,224,224,225,226,227,228,228, - 229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241, - 242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254, - 255}, - - {8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55, - 57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85, - 86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107, - 108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124, - 125,126,127,128,129,130,131,132,133,134,135,135,136,137,138,139,140, - 141,142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155, - 155,156,157,158,159,160,160,161,162,163,164,165,165,166,167,168,169, - 169,170,171,172,173,173,174,175,176,176,177,178,179,180,180,181,182, - 183,183,184,185,186,186,187,188,189,189,190,191,192,192,193,194,195, - 195,196,197,197,198,199,200,200,201,202,202,203,204,205,205,206,207, - 207,208,209,210,210,211,212,212,213,214,214,215,216,216,217,218,219, - 219,220,221,221,222,223,223,224,225,225,226,227,227,228,229,229,230, - 231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241, - 242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252, - 253,253,254,254,255}, - - {16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76, - 78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106, - 107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124, - 125,126,128,128,129,130,131,132,133,134,135,136,137,138,139,140,141, - 142,143,143,144,145,146,147,148,149,150,150,151,152,153,154,155,155, - 156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169, - 169,170,171,172,172,173,174,175,175,176,177,177,178,179,180,180,181, - 182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193, - 193,194,195,195,196,196,197,198,198,199,200,200,201,202,202,203,203, - 204,205,205,206,207,207,208,208,209,210,210,211,211,212,213,213,214, - 214,215,216,216,217,217,218,219,219,220,220,221,221,222,223,223,224, - 224,225,225,226,227,227,228,228,229,229,230,230,231,232,232,233,233, - 234,234,235,235,236,236,237,237,238,239,239,240,240,241,241,242,242, - 243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251, - 251,252,252,253,254,254,255,255} -}; - -// local copy of the palette for V_GetColor() -RGBA_t *pLocalPalette = NULL; + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}; +#endif // keep a copy of the palette so that we can get the RGB value for a color index at any time. static void LoadPalette(const char *lumpname) { - const UINT8 *usegamma = gammatable[cv_usegamma.value]; lumpnum_t lumpnum = W_GetNumForName(lumpname); size_t i, palsize = W_LumpLength(lumpnum)/3; UINT8 *pal; + Cubeapply = InitCube(); + Z_Free(pLocalPalette); + Z_Free(pMasterPalette); pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL); + pMasterPalette = Z_Malloc(sizeof (*pMasterPalette)*palsize, PU_STATIC, NULL); pal = W_CacheLumpNum(lumpnum, PU_CACHE); for (i = 0; i < palsize; i++) { - pLocalPalette[i].s.red = usegamma[*pal++]; - pLocalPalette[i].s.green = usegamma[*pal++]; - pLocalPalette[i].s.blue = usegamma[*pal++]; - pLocalPalette[i].s.alpha = 0xFF; +#ifdef BACKWARDSCOMPATCORRECTION + pMasterPalette[i].s.red = pLocalPalette[i].s.red = correctiontable[*pal++]; + pMasterPalette[i].s.green = pLocalPalette[i].s.green = correctiontable[*pal++]; + pMasterPalette[i].s.blue = pLocalPalette[i].s.blue = correctiontable[*pal++]; +#else + pMasterPalette[i].s.red = pLocalPalette[i].s.red = *pal++; + pMasterPalette[i].s.green = pLocalPalette[i].s.green = *pal++; + pMasterPalette[i].s.blue = pLocalPalette[i].s.blue = *pal++; +#endif + pMasterPalette[i].s.alpha = pLocalPalette[i].s.alpha = 0xFF; + + // lerp of colour cubing! if you want, make it smoother yourself + if (Cubeapply) + V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); } } +void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) +{ + float working[4][3]; + float linear; + UINT8 q; + + if (!Cubeapply) + return; + + linear = (*red/255.0); +#define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2) + for (q = 0; q < 3; q++) + { + working[0][q] = dolerp(Cubepal[0][0][0][q], Cubepal[1][0][0][q]); + working[1][q] = dolerp(Cubepal[0][1][0][q], Cubepal[1][1][0][q]); + working[2][q] = dolerp(Cubepal[0][0][1][q], Cubepal[1][0][1][q]); + working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]); + } + linear = (*green/255.0); + for (q = 0; q < 3; q++) + { + working[0][q] = dolerp(working[0][q], working[1][q]); + working[1][q] = dolerp(working[2][q], working[3][q]); + } + linear = (*blue/255.0); + for (q = 0; q < 3; q++) + { + working[0][q] = 255*dolerp(working[0][q], working[1][q]); + if (working[0][q] > 255.0) + working[0][q] = 255.0; + else if (working[0][q] < 0.0) + working[0][q] = 0.0; + } +#undef dolerp + + *red = (UINT8)(working[0][0]); + *green = (UINT8)(working[0][1]); + *blue = (UINT8)(working[0][2]); +} + const char *R_GetPalname(UINT16 num) { static char palname[9]; @@ -250,23 +441,13 @@ void V_SetPaletteLump(const char *pal) I_SetPalette(pLocalPalette); } -static void CV_usegamma_OnChange(void) +static void CV_palette_OnChange(void) { // reload palette LoadMapPalette(); V_SetPalette(0); } -// change the palette directly to see the change -#ifdef HWRENDER -static void CV_Gammaxxx_ONChange(void) -{ - if (rendermode != render_soft && rendermode != render_none) - V_SetPalette(0); -} -#endif - - #if defined (__GNUC__) && defined (__i386__) && !defined (NOASM) && !defined (__APPLE__) && !defined (NORUSEASM) void VID_BlitLinearScreen_ASM(const UINT8 *srcptr, UINT8 *destptr, INT32 width, INT32 height, size_t srcrowbytes, size_t destrowbytes); @@ -327,12 +508,12 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix } // Draws a patch scaled to arbitrary size. -void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) +void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); UINT32 alphalevel = 0; - fixed_t col, ofs, colfrac, rowfrac, fdup; + fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; INT32 dupx, dupy; const column_t *column; UINT8 *desttop, *dest, *deststart, *destend; @@ -340,6 +521,8 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t fixed_t pwidth; // patch width fixed_t offx = 0; // x offset + UINT8 perplayershuffle = 0; + if (rendermode == render_none) return; @@ -347,7 +530,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t //if (rendermode != render_soft && !con_startup) // Why? if (rendermode != render_soft) { - HWR_DrawFixedPatch((GLPatch_t *)patch, x, y, pscale, scrn, colormap); + HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap); return; } #endif @@ -358,19 +541,20 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) { if (alphalevel == 13) - alphalevel = hudminusalpha[cv_translucenthud.value]; + alphalevel = hudminusalpha[st_translucency]; else if (alphalevel == 14) - alphalevel = 10 - cv_translucenthud.value; + alphalevel = 10 - st_translucency; else if (alphalevel == 15) - alphalevel = hudplusalpha[cv_translucenthud.value]; + alphalevel = hudplusalpha[st_translucency]; if (alphalevel >= 10) return; // invis - } - if (alphalevel) - { - v_translevel = transtables + ((alphalevel-1)<topoffset)<topoffset)<>=1; + if (splitscreen && (scrn & V_PERPLAYER)) + { + fixed_t adjusty = ((scrn & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)<<(FRACBITS-1); + vdup >>= 1; + rowfrac <<= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((scrn & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)<<(FRACBITS-1)); + fdup >>= 1; + colfrac <<= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + scrn &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + scrn &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + scrn &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + scrn &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle = 1; + scrn &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle = 2; + y += adjusty; + scrn &= ~V_SNAPTOTOP; + } + } + } desttop = screens[scrn&V_PARAMMASK]; @@ -459,13 +712,17 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t // Center it if necessary if (!(scrn & V_SCALEPATCHMASK)) { - // if it's meant to cover the whole screen, black out the rest + // if it's meant to cover the whole screen, black out the rest (ONLY IF TOP LEFT ISN'T TRANSPARENT) if (x == 0 && SHORT(patch->width) == BASEVIDWIDTH && y == 0 && SHORT(patch->height) == BASEVIDHEIGHT) { column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[0])); - source = (const UINT8 *)(column) + 3; - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); + if (!column->topdelta) + { + source = (const UINT8 *)(column) + 3; + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, source[0]); + } } + if (vid.width != BASEVIDWIDTH * dupx) { // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, @@ -474,20 +731,26 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t x += (vid.width - (BASEVIDWIDTH * dupx)); else if (!(scrn & V_SNAPTOLEFT)) x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + x -= (vid.width - (BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 4; } if (vid.height != BASEVIDHEIGHT * dupy) { // same thing here - if ((scrn & (V_SPLITSCREEN|V_SNAPTOBOTTOM)) == (V_SPLITSCREEN|V_SNAPTOBOTTOM)) - y += (vid.height/2 - (BASEVIDHEIGHT/2 * dupy)); - else if (scrn & V_SNAPTOBOTTOM) + if (scrn & V_SNAPTOBOTTOM) y += (vid.height - (BASEVIDHEIGHT * dupy)); else if (!(scrn & V_SNAPTOTOP)) y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + y -= (vid.height - (BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 4; } - - desttop += (y*vid.width) + x; } + + desttop += (y*vid.width) + x; } if (pscale != FRACUNIT) // scale width properly @@ -532,7 +795,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t dest = desttop; if (scrn & V_FLIP) dest = deststart + (destend - desttop); - dest += FixedInt(FixedMul(topdelta<>FRACBITS) < column->length; ofs += rowfrac) { @@ -548,24 +811,52 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t // Draws a patch cropped and scaled to arbitrary size. void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t *patch, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h) { + UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); + UINT32 alphalevel = 0; + // boolean flip = false; + fixed_t col, ofs, colfrac, rowfrac, fdup; INT32 dupx, dupy; const column_t *column; UINT8 *desttop, *dest; const UINT8 *source, *deststop; + UINT8 perplayershuffle = 0; + if (rendermode == render_none) return; #ifdef HWRENDER - // Done - if (rendermode != render_soft && !con_startup) + //if (rendermode != render_soft && !con_startup) // Not this again + if (rendermode != render_soft) { HWR_DrawCroppedPatch((GLPatch_t*)patch,x,y,pscale,scrn,sx,sy,w,h); return; } #endif + patchdrawfunc = standardpdraw; + + v_translevel = NULL; + if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + { + if (alphalevel == 13) + alphalevel = hudminusalpha[st_translucency]; + else if (alphalevel == 14) + alphalevel = 10 - st_translucency; + else if (alphalevel == 15) + alphalevel = hudplusalpha[st_translucency]; + + if (alphalevel >= 10) + return; // invis + + if (alphalevel) + { + v_translevel = transtables + ((alphalevel-1)<topoffset)<leftoffset)<>= 1; + rowfrac <<= 1; + y >>= 1; + sy >>= 1; + h >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((scrn & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)<<(FRACBITS-1)); + colfrac <<= 1; + x >>= 1; + sx >>= 1; + w >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + scrn &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + sx += adjustx; + scrn &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + sy += adjusty; + scrn &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(scrn & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + sx += adjustx; + y += adjusty; + sy += adjusty; + scrn &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + scrn &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(scrn & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + sy += adjusty; + scrn &= ~V_SNAPTOTOP; + } + } + } + desttop = screens[scrn&V_PARAMMASK]; if (!desttop) @@ -598,12 +967,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (!(scrn & V_SCALEPATCHMASK)) { // if it's meant to cover the whole screen, black out the rest - if (x == 0 && SHORT(patch->width) == BASEVIDWIDTH && y == 0 && SHORT(patch->height) == BASEVIDHEIGHT) - { - column = (const column_t *)((const UINT8 *)(patch) + LONG(patch->columnofs[0])); - source = (const UINT8 *)(column) + 3; - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, (column->topdelta == 0xff ? 31 : source[0])); - } + // no the patch is cropped do not do this ever + if (vid.width != BASEVIDWIDTH * dupx) { // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, @@ -612,6 +977,10 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ x += (vid.width - (BASEVIDWIDTH * dupx)); else if (!(scrn & V_SNAPTOLEFT)) x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + x -= (vid.width - (BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 4; } if (vid.height != BASEVIDHEIGHT * dupy) { @@ -620,13 +989,17 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ y += (vid.height - (BASEVIDHEIGHT * dupy)); else if (!(scrn & V_SNAPTOTOP)) y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + y -= (vid.height - (BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 4; } } desttop += (y*vid.width) + x; } - for (col = sx<>FRACBITS) < SHORT(patch->width) && (col>>FRACBITS) < w; col += colfrac, ++x, desttop++) + for (col = sx<>FRACBITS) < SHORT(patch->width) && ((col>>FRACBITS) - sx) < w; col += colfrac, ++x, desttop++) { INT32 topdelta, prevdelta = -1; if (x < 0) // don't draw off the left of the screen (WRAP PREVENTION) @@ -643,12 +1016,18 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ prevdelta = topdelta; source = (const UINT8 *)(column) + 3; dest = desttop; - dest += FixedInt(FixedMul(topdelta< 0) + { + dest += FixedInt(FixedMul((topdelta-sy)<>FRACBITS) < column->length && (ofs>>FRACBITS) < h; ofs += rowfrac) + for (; dest < deststop && (ofs>>FRACBITS) < column->length && (((ofs>>FRACBITS) - sy) + topdelta) < h; ofs += rowfrac) { if (dest >= screens[scrn&V_PARAMMASK]) // don't draw off the top of the screen (CRASH PREVENTION) - *dest = source[ofs>>FRACBITS]; + *dest = patchdrawfunc(dest, source, ofs); dest += vid.width; } column = (const column_t *)((const UINT8 *)column + column->length + 4); @@ -662,17 +1041,17 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ // void V_DrawContinueIcon(INT32 x, INT32 y, INT32 flags, INT32 skinnum, UINT8 skincolor) { - if (skinnum < 0 || skinnum >= numskins || (skins[skinnum].flags & SF_HIRES)) - V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_CACHE)); // Draw a star - else - { // Find front angle of the first waiting frame of the character's actual sprites - spriteframe_t *sprframe = &skins[skinnum].spritedef.spriteframes[2 & FF_FRAMEMASK]; - patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); + if (skinnum >= 0 && skinnum < numskins && skins[skinnum].sprites[SPR2_XTRA].numframes > XTRA_CONTINUE) + { + spritedef_t *sprdef = &skins[skinnum].sprites[SPR2_XTRA]; + spriteframe_t *sprframe = &sprdef->spriteframes[XTRA_CONTINUE]; + patch_t *patch = W_CachePatchNum(sprframe->lumppat[0], PU_PATCH); const UINT8 *colormap = R_GetTranslationColormap(skinnum, skincolor, GTC_CACHE); - // No variant for translucency - V_DrawTinyMappedPatch(x, y, flags, patch, colormap); + V_DrawMappedPatch(x, y, flags, patch, colormap); } + else + V_DrawScaledPatch(x - 10, y - 14, flags, W_CachePatchName("CONTINS", PU_PATCH)); } // @@ -766,17 +1145,88 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) UINT8 *dest; const UINT8 *deststop; + UINT8 perplayershuffle = 0; + if (rendermode == render_none) return; #ifdef HWRENDER - if (rendermode != render_soft && !con_startup) + //if (rendermode != render_soft && !con_startup) // Not this again + if (rendermode != render_soft) { HWR_DrawFill(x, y, w, h, c); return; } #endif + if (splitscreen && (c & V_PERPLAYER)) + { + fixed_t adjusty = ((c & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)>>1; + h >>= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((c & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)>>1; + w >>= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + c &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + c &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + c &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + c &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + c &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + c &= ~V_SNAPTOTOP; + } + } + } + if (!(c & V_NOSCALESTART)) { INT32 dupx = vid.dupx, dupy = vid.dupy; @@ -801,6 +1251,10 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) x += (vid.width - (BASEVIDWIDTH * dupx)); else if (!(c & V_SNAPTOLEFT)) x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + x -= (vid.width - (BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 4; } if (vid.height != BASEVIDHEIGHT * dupy) { @@ -809,6 +1263,10 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) y += (vid.height - (BASEVIDHEIGHT * dupy)); else if (!(c & V_SNAPTOTOP)) y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + y -= (vid.height - (BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 4; } } @@ -849,7 +1307,7 @@ static UINT32 V_GetHWConsBackColor(void) switch (cons_backcolor.value) { case 0: hwcolor = 0xffffff00; break; // White - case 1: hwcolor = 0x80808000; break; // Gray + case 1: hwcolor = 0x80808000; break; // Black case 2: hwcolor = 0xdeb88700; break; // Sepia case 3: hwcolor = 0x40201000; break; // Brown case 4: hwcolor = 0xfa807200; break; // Pink @@ -876,13 +1334,16 @@ static UINT32 V_GetHWConsBackColor(void) // THANK YOU MPC!!! +// and thanks toaster for cleaning it up. void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) { UINT8 *dest; - INT32 u, v; + const UINT8 *deststop; + INT32 u; UINT8 *fadetable; UINT32 alphalevel = 0; + UINT8 perplayershuffle = 0; if (rendermode == render_none) return; @@ -891,21 +1352,96 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) if (rendermode != render_soft && rendermode != render_none) { UINT32 hwcolor = V_GetHWConsBackColor(); - HWR_DrawConsoleFill(x, y, w, h, hwcolor, c); // we still use the regular color stuff but only for flags. actual draw color is "hwcolor" for this. + HWR_DrawConsoleFill(x, y, w, h, c, hwcolor); // we still use the regular color stuff but only for flags. actual draw color is "hwcolor" for this. return; } #endif + if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) + { + if (alphalevel == 13) + alphalevel = hudminusalpha[st_translucency]; + else if (alphalevel == 14) + alphalevel = 10 - st_translucency; + else if (alphalevel == 15) + alphalevel = hudplusalpha[st_translucency]; + + if (alphalevel >= 10) + return; // invis + } + + if (splitscreen && (c & V_PERPLAYER)) + { + fixed_t adjusty = ((c & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)>>1; + h >>= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((c & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)>>1; + w >>= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + c &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + c &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + c &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + c &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + c &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + c &= ~V_SNAPTOTOP; + } + } + } + if (!(c & V_NOSCALESTART)) { INT32 dupx = vid.dupx, dupy = vid.dupy; - if (x == 0 && y == 0 && w == BASEVIDWIDTH && h == BASEVIDHEIGHT) - { // Clear the entire screen, from dest to deststop. Yes, this really works. - memset(screens[0], (UINT8)(c&255), vid.width * vid.height * vid.bpp); - return; - } - x *= dupx; y *= dupy; w *= dupx; @@ -920,6 +1456,10 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) x += (vid.width - (BASEVIDWIDTH * dupx)); else if (!(c & V_SNAPTOLEFT)) x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + x -= (vid.width - (BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 4; } if (vid.height != BASEVIDHEIGHT * dupy) { @@ -928,6 +1468,10 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) y += (vid.height - (BASEVIDHEIGHT * dupy)); else if (!(c & V_SNAPTOTOP)) y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + y -= (vid.height - (BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 4; } } @@ -950,34 +1494,206 @@ void V_DrawFillConsoleMap(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c) h = vid.height-y; dest = screens[0] + y*vid.width + x; - - if ((alphalevel = ((c & V_ALPHAMASK) >> V_ALPHASHIFT))) - { - if (alphalevel == 13) - alphalevel = hudminusalpha[cv_translucenthud.value]; - else if (alphalevel == 14) - alphalevel = 10 - cv_translucenthud.value; - else if (alphalevel == 15) - alphalevel = hudplusalpha[cv_translucenthud.value]; - - if (alphalevel >= 10) - return; // invis - } + deststop = screens[0] + vid.rowbytes * vid.height; c &= 255; // Jimita (12-04-2018) - w = min(w, vid.width); - h = min(h, vid.height); - fadetable = ((UINT8 *)transtables + ((alphalevel-1)<= 0) && dest < deststop; dest += vid.width) { - if (!alphalevel) - dest[u] = consolebgmap[dest[u]]; - else + u = 0; + while (u < w) + { dest[u] = fadetable[consolebgmap[dest[u]]]; + u++; + } } + } + else + { + for (;(--h >= 0) && dest < deststop; dest += vid.width) + { + u = 0; + while (u < w) + { + dest[u] = consolebgmap[dest[u]]; + u++; + } + } + } +} + +// +// If color is 0x00 to 0xFF, draw transtable (strength range 0-9). +// Else, use COLORMAP lump (strength range 0-31). +// c is not color, it is for flags only. transparency flags will be ignored. +// IF YOU ARE NOT CAREFUL, THIS CAN AND WILL CRASH! +// I have kept the safety checks for strength out of this function; +// I don't trust Lua users with it, so it doesn't matter. +// +void V_DrawFadeFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c, UINT16 color, UINT8 strength) +{ + UINT8 *dest; + const UINT8 *deststop; + INT32 u; + UINT8 *fadetable; + UINT8 perplayershuffle = 0; + + if (rendermode == render_none) + return; + +#ifdef HWRENDER + if (rendermode != render_soft && rendermode != render_none) + { + // ughhhhh please can someone else do this? thanks ~toast 25/7/19 in 38 degrees centigrade w/o AC + HWR_DrawFadeFill(x, y, w, h, c, color, strength); // toast two days later - left above comment in 'cause it's funny + return; + } +#endif + + if (splitscreen && (c & V_PERPLAYER)) + { + fixed_t adjusty = ((c & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)>>1; + h >>= 1; + y >>= 1; +#ifdef QUADS + if (splitscreen > 1) // 3 or 4 players + { + fixed_t adjustx = ((c & V_NOSCALESTART) ? vid.height : BASEVIDHEIGHT)>>1; + w >>= 1; + x >>= 1; + if (stplyr == &players[displayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + c &= ~V_SNAPTOBOTTOM|V_SNAPTORIGHT; + } + else if (stplyr == &players[secondarydisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + c &= ~V_SNAPTOBOTTOM|V_SNAPTOLEFT; + } + else if (stplyr == &players[thirddisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 4; + y += adjusty; + c &= ~V_SNAPTOTOP|V_SNAPTORIGHT; + } + else //if (stplyr == &players[fourthdisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + if (!(c & (V_SNAPTOLEFT|V_SNAPTORIGHT))) + perplayershuffle |= 8; + x += adjustx; + y += adjusty; + c &= ~V_SNAPTOTOP|V_SNAPTOLEFT; + } + } + else +#endif + // 2 players + { + if (stplyr == &players[displayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 1; + c &= ~V_SNAPTOBOTTOM; + } + else //if (stplyr == &players[secondarydisplayplayer]) + { + if (!(c & (V_SNAPTOTOP|V_SNAPTOBOTTOM))) + perplayershuffle |= 2; + y += adjusty; + c &= ~V_SNAPTOTOP; + } + } + } + + if (!(c & V_NOSCALESTART)) + { + INT32 dupx = vid.dupx, dupy = vid.dupy; + + x *= dupx; + y *= dupy; + w *= dupx; + h *= dupy; + + // Center it if necessary + if (vid.width != BASEVIDWIDTH * dupx) + { + // dupx adjustments pretend that screen width is BASEVIDWIDTH * dupx, + // so center this imaginary screen + if (c & V_SNAPTORIGHT) + x += (vid.width - (BASEVIDWIDTH * dupx)); + else if (!(c & V_SNAPTOLEFT)) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 2; + if (perplayershuffle & 4) + x -= (vid.width - (BASEVIDWIDTH * dupx)) / 4; + else if (perplayershuffle & 8) + x += (vid.width - (BASEVIDWIDTH * dupx)) / 4; + } + if (vid.height != BASEVIDHEIGHT * dupy) + { + // same thing here + if (c & V_SNAPTOBOTTOM) + y += (vid.height - (BASEVIDHEIGHT * dupy)); + else if (!(c & V_SNAPTOTOP)) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 2; + if (perplayershuffle & 1) + y -= (vid.height - (BASEVIDHEIGHT * dupy)) / 4; + else if (perplayershuffle & 2) + y += (vid.height - (BASEVIDHEIGHT * dupy)) / 4; + } + } + + if (x >= vid.width || y >= vid.height) + return; // off the screen + if (x < 0) { + w += x; + x = 0; + } + if (y < 0) { + h += y; + y = 0; + } + + if (w <= 0 || h <= 0) + return; // zero width/height wouldn't draw anything + if (x + w > vid.width) + w = vid.width-x; + if (y + h > vid.height) + h = vid.height-y; + + dest = screens[0] + y*vid.width + x; + deststop = screens[0] + vid.rowbytes * vid.height; + + c &= 255; + + fadetable = ((color & 0xFF00) // Color is not palette index? + ? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade. + : ((UINT8 *)transtables + ((9-strength)<= 0) && dest < deststop; dest += vid.width) + { + u = 0; + while (u < w) + { + dest[u] = fadetable[dest[u]]; + u++; + } + } } // @@ -1093,25 +1809,36 @@ void V_DrawPatchFill(patch_t *pat) // // Fade all the screen buffer, so that the menu is more readable, // especially now that we use the small hufont in the menus... +// If color is 0x00 to 0xFF, draw transtable (strength range 0-9). +// Else, use COLORMAP lump (strength range 0-31). +// IF YOU ARE NOT CAREFUL, THIS CAN AND WILL CRASH! +// I have kept the safety checks out of this function; +// the v.fadeScreen Lua interface handles those. // -void V_DrawFadeScreen(void) +void V_DrawFadeScreen(UINT16 color, UINT8 strength) { - const UINT8 *fadetable = (UINT8 *)colormaps + 16*256; - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; - UINT8 *buf = screens[0]; - #ifdef HWRENDER if (rendermode != render_soft && rendermode != render_none) { - HWR_FadeScreenMenuBack(0x01010160, 0); // hack, 0 means full height + HWR_FadeScreenMenuBack(color, strength); return; } #endif - // heavily simplified -- we don't need to know x or y - // position when we're doing a full screen fade - for (; buf < deststop; ++buf) - *buf = fadetable[*buf]; + { + const UINT8 *fadetable = ((color & 0xFF00) // Color is not palette index? + ? ((UINT8 *)(((color & 0x0F00) == 0x0A00) ? fadecolormap // Do fadecolormap fade. + : (((color & 0x0F00) == 0x0B00) ? fadecolormap + (256 * FADECOLORMAPROWS) // Do white fadecolormap fade. + : colormaps)) + strength*256) // Do COLORMAP fade. + : ((UINT8 *)transtables + ((9-strength)<= 256 && color < 512) + { + boxheight = ((boxheight * 4) + (boxheight/2)*5); + V_DrawFill((BASEVIDWIDTH-(vid.width/vid.dupx))/2, BASEVIDHEIGHT-boxheight, (vid.width/vid.dupx),boxheight, (color-256)|V_SNAPTOBOTTOM); + return; + } + + boxheight *= vid.dupy; + + if (color == INT32_MAX) + color = cons_backcolor.value; + +#ifdef HWRENDER + if (rendermode != render_soft && rendermode != render_none) + { + UINT32 hwcolor; + switch (color) + { + case 0: hwcolor = 0xffffff00; break; // White + case 1: hwcolor = 0x00000000; break; // Black // Note this is different from V_DrawFadeConsBack + case 2: hwcolor = 0xdeb88700; break; // Sepia + case 3: hwcolor = 0x40201000; break; // Brown + case 4: hwcolor = 0xfa807200; break; // Pink + case 5: hwcolor = 0xff69b400; break; // Raspberry + case 6: hwcolor = 0xff000000; break; // Red + case 7: hwcolor = 0xffd68300; break; // Creamsicle + case 8: hwcolor = 0xff800000; break; // Orange + case 9: hwcolor = 0xdaa52000; break; // Gold + case 10: hwcolor = 0x80800000; break; // Yellow + case 11: hwcolor = 0x00ff0000; break; // Emerald + case 12: hwcolor = 0x00800000; break; // Green + case 13: hwcolor = 0x4080ff00; break; // Cyan + case 14: hwcolor = 0x4682b400; break; // Steel + case 15: hwcolor = 0x1e90ff00; break; // Periwinkle + case 16: hwcolor = 0x0000ff00; break; // Blue + case 17: hwcolor = 0xff00ff00; break; // Purple + case 18: hwcolor = 0xee82ee00; break; // Lavender + // Default green + default: hwcolor = 0x00800000; break; + } + HWR_DrawTutorialBack(hwcolor, boxheight); + return; + } +#endif + + CON_SetupBackColormapEx(color, true); + + // heavily simplified -- we don't need to know x or y position, + // just the start and stop positions + deststop = screens[0] + vid.rowbytes * vid.height; + buf = deststop - vid.rowbytes * ((boxheight * 4) + (boxheight/2)*5); // 4 lines of space plus gaps between and some leeway + for (; buf < deststop; ++buf) + *buf = promptbgmap[*buf]; +} + // Gets string colormap, used for 0x80 color codes // UINT8 *V_GetStringColormap(INT32 colorflags) { switch ((colorflags & V_CHARCOLORMASK) >> V_CHARCOLORSHIFT) { - case 1: // 0x81, purple - return purplemap; - case 2: // 0x82, yellow + case 1: // 0x81, magenta + return magentamap; + case 2: // 0x82, yellow return yellowmap; - case 3: // 0x83, lgreen + case 3: // 0x83, lgreen return lgreenmap; - case 4: // 0x84, blue + case 4: // 0x84, blue return bluemap; - case 5: // 0x85, red + case 5: // 0x85, red return redmap; - case 6: // 0x86, gray + case 6: // 0x86, gray return graymap; - case 7: // 0x87, orange + case 7: // 0x87, orange return orangemap; + case 8: // 0x88, sky + return skymap; + case 9: // 0x89, purple + return purplemap; + case 10: // 0x8A, aqua + return aquamap; + case 11: // 0x8B, peridot + return peridotmap; + case 12: // 0x8C, azure + return azuremap; + case 13: // 0x8D, brown + return brownmap; + case 14: // 0x8E, rosy + return rosymap; + case 15: // 0x8F, invert + return invertmap; default: // reset return NULL; } @@ -1246,7 +2049,7 @@ char *V_WordWrap(INT32 x, INT32 w, INT32 option, const char *string) for (i = 0; i < slen; ++i) { c = newstring[i]; - if ((UINT8)c >= 0x80 && (UINT8)c <= 0x89) //color parsing! -Inuyasha 2.16.09 + if ((UINT8)c & 0x80) //color parsing! -Inuyasha 2.16.09 continue; if (c == '\n') @@ -1289,7 +2092,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) { INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, center = 0, left = 0; const char *ch = string; - INT32 charflags = 0; + INT32 charflags = (option & V_CHARCOLORMASK); const UINT8 *colormap = NULL; INT32 spacewidth = 4, charwidth = 0; @@ -1310,8 +2113,6 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) scrwidth -= left; } - charflags = (option & V_CHARCOLORMASK); - switch (option & V_SPACINGMASK) { case V_MONOSPACE: @@ -1370,7 +2171,7 @@ void V_DrawString(INT32 x, INT32 y, INT32 option, const char *string) w = SHORT(hu_font[c]->width) * dupx; if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w; @@ -1482,8 +2283,9 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) } else w = SHORT(hu_font[c]->width) * dupx / 2; + if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w; @@ -1497,6 +2299,13 @@ void V_DrawSmallString(INT32 x, INT32 y, INT32 option, const char *string) } } +void V_DrawCenteredSmallString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x -= V_SmallStringWidth(string, option)/2; + V_DrawSmallString(x, y, option, string); +} + + void V_DrawRightAlignedSmallString(INT32 x, INT32 y, INT32 option, const char *string) { x -= V_SmallStringWidth(string, option); @@ -1588,7 +2397,7 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) w = (SHORT(tny_font[c]->width) * dupx); if (cx > scrwidth) - break; + continue; if (cx+left + w < 0) //left boundary check { cx += w; @@ -1602,18 +2411,52 @@ void V_DrawThinString(INT32 x, INT32 y, INT32 option, const char *string) } } +void V_DrawCenteredThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x -= V_ThinStringWidth(string, option)/2; + V_DrawThinString(x, y, option, string); +} + void V_DrawRightAlignedThinString(INT32 x, INT32 y, INT32 option, const char *string) { x -= V_ThinStringWidth(string, option); V_DrawThinString(x, y, option, string); } +// +// Write a string using the tny_font, 0.5x scale +// NOTE: the text is centered for screens larger than the base width +// +// Literally a wrapper. ~Golden +void V_DrawSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x <<= FRACBITS; + y <<= FRACBITS; + V_DrawSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string); +} + +void V_DrawCenteredSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x <<= FRACBITS; + y <<= FRACBITS; + V_DrawCenteredSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string); +} + +void V_DrawRightAlignedSmallThinString(INT32 x, INT32 y, INT32 option, const char *string) +{ + x <<= FRACBITS; + y <<= FRACBITS; + V_DrawRightAlignedSmallThinStringAtFixed((fixed_t)x, (fixed_t)y, option, string); +} + // Draws a string at a fixed_t location. void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) { fixed_t cx = x, cy = y; INT32 w, c, dupx, dupy, scrwidth, center = 0, left = 0; const char *ch = string; + INT32 charflags = 0; + const UINT8 *colormap = NULL; INT32 spacewidth = 4, charwidth = 0; INT32 lowercase = (option & V_ALLOWLOWERCASE); @@ -1633,6 +2476,8 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) scrwidth -= left; } + charflags = (option & V_CHARCOLORMASK); + switch (option & V_SPACINGMASK) { case V_MONOSPACE: @@ -1652,7 +2497,12 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) if (!*ch) break; if (*ch & 0x80) //color ignoring + { + // manually set flags override color codes + if (!(option & V_CHARCOLORMASK)) + charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; continue; + } if (*ch == '\n') { cx = x; @@ -1685,6 +2535,119 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) else w = SHORT(hu_font[c]->width) * dupx; + if ((cx>>FRACBITS) > scrwidth) + continue; + if ((cx>>FRACBITS)+left + w < 0) //left boundary check + { + cx += w<= HU_FONTSIZE || !hu_font[c]) + { + cx += (spacewidth * dupx)<width)*(dupx/4); + } + else + w = SHORT(hu_font[c]->width) * dupx / 2; + if ((cx>>FRACBITS) > scrwidth) break; if ((cx>>FRACBITS)+left + w < 0) //left boundary check @@ -1693,12 +2656,254 @@ void V_DrawStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) continue; } - V_DrawSciencePatch(cx + (center<= HU_FONTSIZE || !tny_font[c]) + { + cx += (spacewidth * dupx)<width)*(dupx/2); + } + else + w = SHORT(tny_font[c]->width) * dupx; + + if ((cx>>FRACBITS) > scrwidth) + break; + if ((cx>>FRACBITS)+left + w < 0) //left boundary check + { + cx += w<= HU_FONTSIZE || !tny_font[c]) + { + cx += FixedMul(spacewidth, dupx); + continue; + } + + if (charwidth) + { + w = FixedMul(charwidth, dupx); + center = w/2 - SHORT(tny_font[c]->width)*(dupx/4); + } + else + w = SHORT(tny_font[c]->width) * dupx / 2; + + if (cx > scrwidth) + break; + if (cx+left + w < 0) //left boundary check + { + cx += w; + continue; + } + + colormap = V_GetStringColormap(charflags); + + V_DrawFixedPatch(cx + center, cy, FRACUNIT/2, option, tny_font[c], colormap); + + cx += w; + } +} + +void V_DrawCenteredSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_SmallThinStringWidth(string, option)/4; + V_DrawSmallThinStringAtFixed(x, y, option, string); +} + +void V_DrawRightAlignedSmallThinStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *string) +{ + x -= V_SmallThinStringWidth(string, option)/2; + V_DrawSmallThinStringAtFixed(x, y, option, string); +} + // Draws a tallnum. Replaces two functions in y_inter and st_stuff void V_DrawTallNum(INT32 x, INT32 y, INT32 flags, INT32 num) { @@ -1745,6 +2950,16 @@ void V_DrawPaddedTallNum(INT32 x, INT32 y, INT32 flags, INT32 num, INT32 digits) } while (--digits); } +// Draw an act number for a level title +// Todo: actually draw two-digit numbers as two act num patches +void V_DrawLevelActNum(INT32 x, INT32 y, INT32 flags, INT32 num) +{ + if (num < 0 || num > 19) + return; // not supported + + V_DrawScaledPatch(x, y, flags, ttlnum[num]); +} + // Write a string using the credit font // NOTE: the text is centered for screens larger than the base width // @@ -1788,13 +3003,210 @@ void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string) w = SHORT(cred_font[c]->width) * dupx; if ((cx>>FRACBITS) > scrwidth) - break; + continue; V_DrawSciencePatch(cx, cy, option, cred_font[c], FRACUNIT); cx += w<= NT_FONTSIZE || !ntb_font[c] || !nto_font[c]) + { + cx += FixedMul((4 * dupx)*FRACUNIT, scale); + continue; + } + + w = FixedMul((SHORT(ntb_font[c]->width)+2 * dupx) * FRACUNIT, scale); + + if (FixedInt(cx) > scrwidth) + continue; + if (cx+(left*FRACUNIT) + w < 0) // left boundary check + { + cx += w; + continue; + } + + V_DrawFixedPatch(cx, cy, scale, option, nto_font[c], outlinecolormap); + V_DrawFixedPatch(cx, cy, scale, option, ntb_font[c], basecolormap); + + cx += w; + } +} + +// Looks familiar. +void V_DrawNameTag(INT32 x, INT32 y, INT32 option, fixed_t scale, UINT8 *basecolormap, UINT8 *outlinecolormap, const char *string) +{ + const char *text = string; + const char *first_token = text; + char *last_token = strchr(text, '\n'); + const INT32 lbreakheight = 21; + INT32 ntlines; + + if (option & V_CENTERNAMETAG) + { + ntlines = V_CountNameTagLines(string); + y -= FixedInt(FixedMul(((lbreakheight/2) * (ntlines-1))*FRACUNIT, scale)); + } + + // No line breaks? + // Draw entire string + if (!last_token) + V_DrawNameTagLine(x, y, option, scale, basecolormap, outlinecolormap, string); + // Split string by the line break character + else + { + char *str = NULL; + INT32 len; + while (true) + { + // There are still lines left to draw + if (last_token) + { + size_t shift = 0; + // Free this line + if (str) + Z_Free(str); + // Find string length, do a malloc... + len = (last_token-first_token)+1; + str = ZZ_Alloc(len); + // Copy the line + strncpy(str, first_token, len-1); + str[len-1] = '\0'; + // Don't leave a line break character + // at the start of the string! + if ((strlen(str) >= 2) && (string[0] == '\n') && (string[1] != '\n')) + shift++; + // Then draw it + V_DrawNameTagLine(x, y, option, scale, basecolormap, outlinecolormap, str+shift); + } + // No line break character was found + else + { + // Don't leave a line break character + // at the start of the string! + if ((strlen(first_token) >= 2) && (first_token[0] == '\n') && (first_token[1] != '\n')) + first_token++; + // Then draw it + V_DrawNameTagLine(x, y, option, scale, basecolormap, outlinecolormap, first_token); + break; + } + + // Next line + y += FixedInt(FixedMul(lbreakheight*FRACUNIT, scale)); + if ((last_token-text)+1 >= (signed)strlen(text)) + last_token = NULL; + else + { + first_token = last_token; + last_token = strchr(first_token+1, '\n'); + } + } + // Free this line + if (str) + Z_Free(str); + } +} + +// Count the amount of lines in name tag string +INT32 V_CountNameTagLines(const char *string) +{ + INT32 ntlines = 1; + const char *text = string; + const char *first_token = text; + char *last_token = strchr(text, '\n'); + + // No line breaks? + if (!last_token) + return ntlines; + // Split string by the line break character + else + { + while (true) + { + if (last_token) + ntlines++; + // No line break character was found + else + break; + + // Next line + if ((last_token-text)+1 >= (signed)strlen(text)) + last_token = NULL; + else + { + first_token = last_token; + last_token = strchr(first_token+1, '\n'); + } + } + } + return ntlines; +} + +INT32 V_NameTagWidth(const char *string) +{ + INT32 c, w = 0; + size_t i; + + // It's possible for string to be a null pointer + if (!string) + return 0; + + for (i = 0; i < strlen(string); i++) + { + c = toupper(string[i]) - NT_FONTSTART; + if (c < 0 || c >= NT_FONTSIZE || !ntb_font[c] || !nto_font[c]) + w += 4; + else + w += SHORT(ntb_font[c]->width)+2; + } + + return w; +} + // Find string width from cred_font chars // INT32 V_CreditStringWidth(const char *string) @@ -1825,6 +3237,8 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string) { INT32 w, c, cx = x, cy = y, dupx, dupy, scrwidth, left = 0; const char *ch = string; + INT32 charflags = (option & V_CHARCOLORMASK); + const UINT8 *colormap = NULL; if (option & V_NOSCALESTART) { @@ -1840,19 +3254,25 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string) scrwidth -= left; } - for (;;) + for (;;ch++) { - c = *ch++; - if (!c) + if (!*ch) break; - if (c == '\n') + if (*ch & 0x80) //color parsing -x 2.16.09 + { + // manually set flags override color codes + if (!(option & V_CHARCOLORMASK)) + charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + continue; + } + if (*ch == '\n') { cx = x; cy += 12*dupy; continue; } - c = toupper(c) - LT_FONTSTART; + c = *ch - LT_FONTSTART; if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) { cx += 16*dupx; @@ -1860,16 +3280,18 @@ void V_DrawLevelTitle(INT32 x, INT32 y, INT32 option, const char *string) } w = SHORT(lt_font[c]->width) * dupx; - if (cx > scrwidth) - break; - if (cx+left + w < 0) //left boundary check + if (cx > scrwidth) + continue; + if (cx+left + w < 0) //left boundary check { cx += w; continue; } - V_DrawScaledPatch(cx, cy, option, lt_font[c]); + colormap = V_GetStringColormap(charflags); + V_DrawFixedPatch(cx<= LT_FONTSIZE || !lt_font[c]) w += 16; else @@ -1902,7 +3326,7 @@ INT32 V_LevelNameHeight(const char *string) for (i = 0; i < strlen(string); i++) { - c = toupper(string[i]) - LT_FONTSTART; + c = string[i] - LT_FONTSTART; if (c < 0 || c >= LT_FONTSIZE || !lt_font[c]) continue; @@ -1913,6 +3337,16 @@ INT32 V_LevelNameHeight(const char *string) return w; } +// For ST_drawTitleCard +// Returns the width of the act num patch +INT32 V_LevelActNumWidth(INT32 num) +{ + if (num < 0 || num > 19) + return 0; // not a valid number + + return SHORT(ttlnum[num]->width); +} + // // Find string width from hu_font chars // @@ -1938,17 +3372,18 @@ INT32 V_StringWidth(const char *string, INT32 option) for (i = 0; i < strlen(string); i++) { - c = string[i]; - if ((UINT8)c >= 0x80 && (UINT8)c <= 0x89) //color parsing! -Inuyasha 2.16.09 + if (string[i] & 0x80) continue; - - c = toupper(c) - HU_FONTSTART; + c = toupper(string[i]) - HU_FONTSTART; if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else w += (charwidth ? charwidth : SHORT(hu_font[c]->width)); } + if (option & V_NOSCALESTART) + w *= vid.dupx; + return w; } @@ -1977,11 +3412,9 @@ INT32 V_SmallStringWidth(const char *string, INT32 option) for (i = 0; i < strlen(string); i++) { - c = string[i]; - if ((UINT8)c >= 0x80 && (UINT8)c <= 0x89) //color parsing! -Inuyasha 2.16.09 + if (string[i] & 0x80) continue; - - c = toupper(c) - HU_FONTSTART; + c = toupper(string[i]) - HU_FONTSTART; if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) w += spacewidth; else @@ -2016,11 +3449,9 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) for (i = 0; i < strlen(string); i++) { - c = string[i]; - if ((UINT8)c >= 0x80 && (UINT8)c <= 0x89) //color parsing! -Inuyasha 2.16.09 + if (string[i] & 0x80) continue; - - c = toupper(c) - HU_FONTSTART; + c = toupper(string[i]) - HU_FONTSTART; if (c < 0 || c >= HU_FONTSIZE || !tny_font[c]) w += spacewidth; else @@ -2030,6 +3461,15 @@ INT32 V_ThinStringWidth(const char *string, INT32 option) return w; } +// +// Find string width from tny_font chars, 0.5x scale +// +INT32 V_SmallThinStringWidth(const char *string, INT32 option) +{ + INT32 w = V_ThinStringWidth(string, option)< +#endif + #ifdef __GNUC__ #include #endif @@ -18,11 +36,7 @@ #define ZWAD #ifdef ZWAD -#ifdef _WIN32_WCE -#define AVOID_ERRNO -#else #include -#endif #include "lzf.h" #endif @@ -41,6 +55,7 @@ #include "dehacked.h" #include "d_clisrv.h" #include "r_defs.h" +#include "r_data.h" #include "i_system.h" #include "md5.h" #include "lua_script.h" @@ -65,24 +80,6 @@ int snprintf(char *str, size_t n, const char *fmt, ...); #define O_BINARY 0 #endif -#ifdef HAVE_ZLIB -#ifndef _MSC_VER -#ifndef _LARGEFILE64_SOURCE -#define _LARGEFILE64_SOURCE -#endif -#endif - -#ifndef _LFS64_LARGEFILE -#define _LFS64_LARGEFILE -#endif - -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 0 -#endif - -#include "zlib.h" -#endif - typedef struct { @@ -121,6 +118,7 @@ void W_Shutdown(void) Z_Free(wadfiles[numwadfiles]->filename); while (wadfiles[numwadfiles]->numlumps--) Z_Free(wadfiles[numwadfiles]->lumpinfo[wadfiles[numwadfiles]->numlumps].name2); + Z_Free(wadfiles[numwadfiles]->lumpinfo); Z_Free(wadfiles[numwadfiles]); } @@ -149,9 +147,15 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) { FILE *handle; - strncpy(filenamebuf, *filename, MAX_WADPATH); - filenamebuf[MAX_WADPATH - 1] = '\0'; - *filename = filenamebuf; + // Officially, strncpy should not have overlapping buffers, since W_VerifyNMUSlumps is called after this, and it + // changes filename to point at filenamebuf, it would technically be doing that. I doubt any issue will occur since + // they point to the same location, but it's better to be safe and this is a simple change. + if (filenamebuf != *filename) + { + strncpy(filenamebuf, *filename, MAX_WADPATH); + filenamebuf[MAX_WADPATH - 1] = '\0'; + *filename = filenamebuf; + } // open wad file if ((handle = fopen(*filename, "rb")) == NULL) @@ -182,24 +186,25 @@ FILE *W_OpenWadFile(const char **filename, boolean useerrors) } // Look for all DEHACKED and Lua scripts inside a PK3 archive. -static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) +static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum, boolean mainfile) { UINT16 posStart, posEnd; -#ifdef HAVE_BLUA + posStart = W_CheckNumForFolderStartPK3("Lua/", wadnum, 0); if (posStart != INT16_MAX) { posEnd = W_CheckNumForFolderEndPK3("Lua/", wadnum, posStart); - posStart++; + posStart++; // first "lump" will be "Lua/" folder itself, so ignore it for (; posStart < posEnd; posStart++) LUA_LoadLump(wadnum, posStart); } -#endif + posStart = W_CheckNumForFolderStartPK3("SOC/", wadnum, 0); if (posStart != INT16_MAX) { posEnd = W_CheckNumForFolderEndPK3("SOC/", wadnum, posStart); - posStart++; + + posStart++; // first "lump" will be "SOC/" folder itself, so ignore it for(; posStart < posEnd; posStart++) { lumpinfo_t *lump_p = &wadfiles[wadnum]->lumpinfo[posStart]; @@ -208,19 +213,17 @@ static inline void W_LoadDehackedLumpsPK3(UINT16 wadnum) sprintf(name, "%s|%s", wadfiles[wadnum]->filename, lump_p->name2); name[length] = '\0'; CONS_Printf(M_GetText("Loading SOC from %s\n"), name); - DEH_LoadDehackedLumpPwad(wadnum, posStart); + DEH_LoadDehackedLumpPwad(wadnum, posStart, mainfile); free(name); } - } } // search for all DEHACKED lump in all wads and load it -static inline void W_LoadDehackedLumps(UINT16 wadnum) +static inline void W_LoadDehackedLumps(UINT16 wadnum, boolean mainfile) { UINT16 lump; -#ifdef HAVE_BLUA // Find Lua scripts before SOCs to allow new A_Actions in SOC editing. { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; @@ -228,7 +231,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) if (memcmp(lump_p->name,"LUA_",4)==0) LUA_LoadLump(wadnum, lump); } -#endif { lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; @@ -241,18 +243,18 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) name[length] = '\0'; CONS_Printf(M_GetText("Loading SOC from %s\n"), name); - DEH_LoadDehackedLumpPwad(wadnum, lump); + DEH_LoadDehackedLumpPwad(wadnum, lump, mainfile); free(name); } else if (memcmp(lump_p->name,"MAINCFG",8)==0) // Check for MAINCFG { CONS_Printf(M_GetText("Loading main config from %s\n"), wadfiles[wadnum]->filename); - DEH_LoadDehackedLumpPwad(wadnum, lump); + DEH_LoadDehackedLumpPwad(wadnum, lump, mainfile); } else if (memcmp(lump_p->name,"OBJCTCFG",8)==0) // Check for OBJCTCFG { CONS_Printf(M_GetText("Loading object config from %s\n"), wadfiles[wadnum]->filename); - DEH_LoadDehackedLumpPwad(wadnum, lump); + DEH_LoadDehackedLumpPwad(wadnum, lump, mainfile); } } @@ -334,7 +336,6 @@ static restype_t ResourceFileDetect (const char* filename) static lumpinfo_t* ResGetLumpsStandalone (FILE* handle, UINT16* numlumps, const char* lumpname) { lumpinfo_t* lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); - lumpinfo = Z_Calloc(sizeof (*lumpinfo), PU_STATIC, NULL); lumpinfo->position = 0; fseek(handle, 0, SEEK_END); lumpinfo->size = ftell(handle); @@ -365,7 +366,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen // read the header if (fread(&header, 1, sizeof header, handle) < sizeof header) { - CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header because %s\n"), strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header because %s\n"), M_FileError(handle)); return NULL; } @@ -388,7 +389,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen if (fseek(handle, header.infotableofs, SEEK_SET) == -1 || fread(fileinfo, 1, i, handle) < i) { - CONS_Alert(CONS_ERROR, M_GetText("Corrupt wadfile directory (%s)\n"), strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, M_GetText("Corrupt wadfile directory (%s)\n"), M_FileError(handle)); free(fileinfov); return NULL; } @@ -409,7 +410,7 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen handle) < sizeof realsize) { I_Error("corrupt compressed file: %s; maybe %s", /// \todo Avoid the bailout? - filename, strerror(ferror(handle))); + filename, M_FileError(handle)); } realsize = LONG(realsize); if (realsize != 0) @@ -547,7 +548,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) fseek(handle, -4, SEEK_CUR); if (fread(&zend, 1, sizeof zend, handle) < sizeof zend) { - CONS_Alert(CONS_ERROR, "Corrupt central directory (%s)\n", strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, "Corrupt central directory (%s)\n", M_FileError(handle)); return NULL; } numlumps = zend.entries; @@ -564,16 +565,16 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) if (fread(zentry, 1, sizeof(zentry_t), handle) < sizeof(zentry_t)) { - CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, "Failed to read central directory (%s)\n", M_FileError(handle)); Z_Free(lumpinfo); - free(zentry); + free(zentries); return NULL; } if (memcmp(zentry->signature, pat_central, 4)) { CONS_Alert(CONS_ERROR, "Central directory is corrupt\n"); Z_Free(lumpinfo); - free(zentry); + free(zentries); return NULL; } @@ -584,9 +585,9 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) fullname = malloc(zentry->namelen + 1); if (fgets(fullname, zentry->namelen + 1, handle) != fullname) { - CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", strerror(ferror(handle))); + CONS_Alert(CONS_ERROR, "Unable to read lumpname (%s)\n", M_FileError(handle)); Z_Free(lumpinfo); - free(zentry); + free(zentries); free(fullname); return NULL; } @@ -628,10 +629,27 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) } } + free(zentries); + *nlmp = numlumps; return lumpinfo; } +static UINT16 W_InitFileError (const char *filename, boolean exitworthy) +{ + if (exitworthy) + { +#ifdef _DEBUG + CONS_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); +#else + I_Error("A WAD file was not found or not valid.\nCheck the log to see which ones.\n"); +#endif + } + else + CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), filename); + return INT16_MAX; +} + // Allocate a wadfile, setup the lumpinfo (directory) and // lumpcache, add the wadfile to the current active wadfiles // @@ -643,14 +661,16 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp) // // Can now load dehacked files (.soc) // -UINT16 W_InitFile(const char *filename) +UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup) { FILE *handle; lumpinfo_t *lumpinfo = NULL; wadfile_t *wadfile; restype_t type; UINT16 numlumps = 0; +#ifndef NOMD5 size_t i; +#endif size_t packetsize; UINT8 md5sum[16]; boolean important; @@ -676,12 +696,12 @@ UINT16 W_InitFile(const char *filename) { CONS_Alert(CONS_ERROR, M_GetText("Maximum wad files reached\n")); refreshdirmenu |= REFRESHDIR_MAX; - return INT16_MAX; + return W_InitFileError(filename, startup); } // open wad file if ((handle = W_OpenWadFile(&filename, true)) == NULL) - return INT16_MAX; + return W_InitFileError(filename, startup); // Check if wad files will overflow fileneededbuffer. Only the filename part // is send in the packet; cf. @@ -696,7 +716,7 @@ UINT16 W_InitFile(const char *filename) refreshdirmenu |= REFRESHDIR_MAX; if (handle) fclose(handle); - return INT16_MAX; + return W_InitFileError(filename, startup); } packetsizetally = packetsize; @@ -717,7 +737,7 @@ UINT16 W_InitFile(const char *filename) CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename); if (handle) fclose(handle); - return INT16_MAX; + return W_InitFileError(filename, false); } } #endif @@ -727,11 +747,9 @@ UINT16 W_InitFile(const char *filename) case RET_SOC: lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "OBJCTCFG"); break; -#ifdef HAVE_BLUA case RET_LUA: lumpinfo = ResGetLumpsStandalone(handle, &numlumps, "LUA_INIT"); break; -#endif case RET_PK3: lumpinfo = ResGetLumpsZip(handle, &numlumps); break; @@ -745,7 +763,7 @@ UINT16 W_InitFile(const char *filename) if (lumpinfo == NULL) { fclose(handle); - return INT16_MAX; + return W_InitFileError(filename, startup); } // @@ -753,6 +771,7 @@ UINT16 W_InitFile(const char *filename) // wadfile = Z_Malloc(sizeof (*wadfile), PU_STATIC, NULL); wadfile->filename = Z_StrDup(filename); + wadfile->type = type; wadfile->handle = handle; wadfile->numlumps = (UINT16)numlumps; wadfile->lumpinfo = lumpinfo; @@ -768,6 +787,7 @@ UINT16 W_InitFile(const char *filename) // set up caching // Z_Calloc(numlumps * sizeof (*wadfile->lumpcache), PU_STATIC, &wadfile->lumpcache); + Z_Calloc(numlumps * sizeof (*wadfile->patchcache), PU_STATIC, &wadfile->patchcache); #ifdef HWRENDER // allocates GLPatch info structures and store them in a tree @@ -785,20 +805,18 @@ UINT16 W_InitFile(const char *filename) switch (wadfile->type) { case RET_WAD: - W_LoadDehackedLumps(numwadfiles - 1); + W_LoadDehackedLumps(numwadfiles - 1, mainfile); break; case RET_PK3: - W_LoadDehackedLumpsPK3(numwadfiles - 1); + W_LoadDehackedLumpsPK3(numwadfiles - 1, mainfile); break; case RET_SOC: CONS_Printf(M_GetText("Loading SOC from %s\n"), wadfile->filename); - DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0); + DEH_LoadDehackedLumpPwad(numwadfiles - 1, 0, mainfile); break; -#ifdef HAVE_BLUA case RET_LUA: LUA_LoadLump(numwadfiles - 1, 0); break; -#endif default: break; } @@ -807,38 +825,6 @@ UINT16 W_InitFile(const char *filename) return wadfile->numlumps; } -#ifdef DELFILE -void W_UnloadWadFile(UINT16 num) -{ - INT32 i; - wadfile_t *delwad = wadfiles[num]; - lumpcache_t *lumpcache; - if (num == 0) - return; - CONS_Printf(M_GetText("Removing WAD %s...\n"), wadfiles[num]->filename); - - DEH_UnloadDehackedWad(num); - wadfiles[num] = NULL; - lumpcache = delwad->lumpcache; - numwadfiles--; -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - HWR_FreeTextureCache(); - M_AATreeFree(delwad->hwrcache); -#endif - if (*lumpcache) - { - for (i = 0;i < delwad->numlumps;i++) - Z_ChangeTag(lumpcache[i], PU_PURGELEVEL); - } - Z_Free(lumpcache); - fclose(delwad->handle); - Z_Free(delwad->filename); - Z_Free(delwad); - CONS_Printf(M_GetText("Done unloading WAD.\n")); -} -#endif - /** Tries to load a series of files. * All files are wads unless they have an extension of ".soc" or ".lua". * @@ -847,13 +833,9 @@ void W_UnloadWadFile(UINT16 num) * backwards, so a later file overrides all earlier ones. * * \param filenames A null-terminated list of files to use. - * \return 1 if all files were loaded, 0 if at least one was missing or - * invalid. */ -INT32 W_InitMultipleFiles(char **filenames) +void W_InitMultipleFiles(char **filenames, UINT16 mainfiles) { - INT32 rc = 1; - // open all the files, load headers, and count lumps numwadfiles = 0; @@ -861,13 +843,8 @@ INT32 W_InitMultipleFiles(char **filenames) for (; *filenames; filenames++) { //CONS_Debug(DBG_SETUP, "Loading %s\n", *filenames); - rc &= (W_InitFile(*filenames) != INT16_MAX) ? 1 : 0; + W_InitFile(*filenames, numwadfiles < mainfiles, true); } - - if (!numwadfiles) - I_Error("W_InitMultipleFiles: no files found"); - - return rc; } /** Make sure a lump number is valid. @@ -929,10 +906,8 @@ UINT16 W_CheckNumForNamePwad(const char *name, UINT16 wad, UINT16 startlump) { lumpinfo_t *lump_p = wadfiles[wad]->lumpinfo + startlump; for (i = startlump; i < wadfiles[wad]->numlumps; i++, lump_p++) - { if (memcmp(lump_p->name,uname,8) == 0) return i; - } } // not found. @@ -993,6 +968,9 @@ lumpnum_t W_CheckNumForName(const char *name) INT32 i; lumpnum_t check = INT16_MAX; + if (!*name) // some doofus gave us an empty string? + return LUMPERROR; + // Check the lumpnumcache first. Loop backwards so that we check // most recent entries first for (i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--) @@ -1152,11 +1130,27 @@ boolean W_IsLumpWad(lumpnum_t lumpnum) return false; // WADs should never be inside non-PK3s as far as SRB2 is concerned } +// +// W_IsLumpFolder +// Is the lump a folder? (in a PK3 obviously) +// +boolean W_IsLumpFolder(UINT16 wad, UINT16 lump) +{ + if (wadfiles[wad]->type == RET_PK3) + { + const char *name = wadfiles[wad]->lumpinfo[lump].name2; + + return (name[strlen(name)-1] == '/'); // folders end in '/' + } + + return false; // non-PK3s don't have folders +} + #ifdef HAVE_ZLIB /* report a zlib or i/o error */ void zerr(int ret) { - CONS_Printf("zpipe: "); + CONS_Printf("zpipe: "); switch (ret) { case Z_ERRNO: if (ferror(stdin)) @@ -1179,23 +1173,6 @@ void zerr(int ret) } #endif -#define NO_PNG_LUMPS - -#ifdef NO_PNG_LUMPS -static void ErrorIfPNG(UINT8 *d, size_t s, char *f, char *l) -{ - if (s < 67) // http://garethrees.org/2007/11/14/pngcrush/ - return; - // Check for PNG file signature using memcmp - // As it may be faster on CPUs with slow unaligned memory access - // Ref: http://www.libpng.org/pub/png/spec/1.2/PNG-Rationale.html#R.PNG-file-signature - if (memcmp(&d[0], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", 8) == 0) - { - I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .PNG - please convert to either Doom or Flat (raw) image format.", l, f); - } -} -#endif - /** Reads bytes from the head of a lump. * Note: If the lump is compressed, the whole thing has to be read anyway. * @@ -1238,7 +1215,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si #ifdef NO_PNG_LUMPS { size_t bytesread = fread(dest, 1, size, handle); - ErrorIfPNG(dest, bytesread, wadfiles[wad]->filename, l->name2); + if (R_IsLumpPNG((UINT8 *)dest, bytesread)) + W_ThrowPNGError(l->name2, wadfiles[wad]->filename); return bytesread; } #else @@ -1279,7 +1257,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(rawData); Z_Free(decData); #ifdef NO_PNG_LUMPS - ErrorIfPNG(dest, size, wadfiles[wad]->filename, l->name2); + if (R_IsLumpPNG((UINT8 *)dest, size)) + W_ThrowPNGError(l->name2, wadfiles[wad]->filename); #endif return size; #else @@ -1327,12 +1306,12 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si { size = 0; zerr(zErr); - (void)inflateEnd(&strm); } + + (void)inflateEnd(&strm); } else { - CONS_Printf("whopet\n"); size = 0; zerr(zErr); } @@ -1341,7 +1320,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si Z_Free(decData); #ifdef NO_PNG_LUMPS - ErrorIfPNG(dest, size, wadfiles[wad]->filename, l->name2); + if (R_IsLumpPNG((UINT8 *)dest, size)) + W_ThrowPNGError(l->name2, wadfiles[wad]->filename); #endif return size; } @@ -1349,7 +1329,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si default: I_Error("wad %d, lump %d: unsupported compression type!", wad, lump); } - return -1; + return 0; } size_t W_ReadLumpHeader(lumpnum_t lumpnum, void *dest, size_t size, size_t offset) @@ -1398,7 +1378,6 @@ void *W_CacheLumpNumPwad(UINT16 wad, UINT16 lump, INT32 tag) void *W_CacheLumpNum(lumpnum_t lumpnum, INT32 tag) { - return W_CacheLumpNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); } @@ -1456,6 +1435,53 @@ boolean W_IsLumpCached(lumpnum_t lumpnum, void *ptr) return W_IsLumpCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); } +// +// W_IsPatchCached +// +// If a patch is already cached return true, otherwise +// return false. +// +// no outside code uses the PWAD form, for now +static inline boolean W_IsPatchCachedPWAD(UINT16 wad, UINT16 lump, void *ptr) +{ + void *lcache; + + if (!TestValidLump(wad, lump)) + return false; + + lcache = wadfiles[wad]->patchcache[lump]; + + if (ptr) + { + if (ptr == lcache) + return true; + } + else if (lcache) + return true; + + return false; +} + +boolean W_IsPatchCached(lumpnum_t lumpnum, void *ptr) +{ + return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); +} + +void W_FlushCachedPatches(void) +{ + if (needpatchflush) + { + Z_FreeTag(PU_CACHE); + Z_FreeTag(PU_PATCH); + Z_FreeTag(PU_HUDGFX); + Z_FreeTag(PU_HWRPATCHINFO); + Z_FreeTag(PU_HWRMODELTEXTURE); + Z_FreeTag(PU_HWRCACHE); + Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRMODELTEXTURE_UNLOCKED); + } + needpatchflush = false; +} + // ========================================================================== // W_CacheLumpName // ========================================================================== @@ -1479,41 +1505,83 @@ void *W_CacheLumpName(const char *name, INT32 tag) // Cache a patch into heap memory, convert the patch format as necessary // -// Software-only compile cache the data without conversion -#ifdef HWRENDER -static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) +void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { +#ifdef HWRENDER GLPatch_t *grPatch; +#endif - if (rendermode == render_soft || rendermode == render_none) - return W_CacheLumpNumPwad(wad, lump, tag); + if (needpatchflush) + W_FlushCachedPatches(); if (!TestValidLump(wad, lump)) return NULL; +#ifdef HWRENDER + // Software-only compile cache the data without conversion + if (rendermode == render_soft || rendermode == render_none) +#endif + { + lumpcache_t *lumpcache = wadfiles[wad]->patchcache; + if (!lumpcache[lump]) + { + size_t len = W_LumpLengthPwad(wad, lump); + void *ptr, *lumpdata; +#ifndef NO_PNG_LUMPS + void *srcdata = NULL; +#endif + + ptr = Z_Malloc(len, tag, &lumpcache[lump]); + lumpdata = Z_Malloc(len, tag, NULL); + + // read the lump in full + W_ReadLumpHeaderPwad(wad, lump, lumpdata, 0, 0); + +#ifndef NO_PNG_LUMPS + // lump is a png so convert it + if (R_IsLumpPNG((UINT8 *)lumpdata, len)) + { + size_t newlen; + srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen); + ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]); + M_Memcpy(ptr, srcdata, newlen); + Z_Free(srcdata); + } + else // just copy it into the patch cache +#endif + M_Memcpy(ptr, lumpdata, len); + } + else + Z_ChangeTag(lumpcache[lump], tag); + + return lumpcache[lump]; + } +#ifdef HWRENDER + grPatch = HWR_GetCachedGLPatchPwad(wad, lump); - if (grPatch->mipmap.grInfo.data) + if (grPatch->mipmap->grInfo.data) { if (tag == PU_CACHE) tag = PU_HWRCACHE; - Z_ChangeTag(grPatch->mipmap.grInfo.data, tag); + Z_ChangeTag(grPatch->mipmap->grInfo.data, tag); } else { patch_t *ptr = NULL; // Only load the patch if we haven't initialised the grPatch yet - if (grPatch->mipmap.width == 0) + if (grPatch->mipmap->width == 0) ptr = W_CacheLumpNumPwad(grPatch->wadnum, grPatch->lumpnum, PU_STATIC); // Run HWR_MakePatch in all cases, to recalculate some things - HWR_MakePatch(ptr, grPatch, &grPatch->mipmap, false); + HWR_MakePatch(ptr, grPatch, grPatch->mipmap, false); Z_Free(ptr); } // return GLPatch_t, which can be casted to (patch_t) with valid patch header info return (void *)grPatch; +#endif } void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) @@ -1521,8 +1589,6 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) return W_CachePatchNumPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum),tag); } -#endif // HWRENDER - void W_UnlockCachedPatch(void *patch) { // The hardware code does its own memory management, as its patches @@ -1618,13 +1684,162 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5) #endif } +// Verify versions for different archive +// formats. checklist assumed to be valid. + +static int +W_VerifyName (const char *name, lumpchecklist_t *checklist, boolean status) +{ + size_t j; + for (j = 0; checklist[j].len && checklist[j].name; ++j) + { + if (( strncasecmp(name, checklist[j].name, + checklist[j].len) != false ) == status) + { + return true; + } + } + return false; +} + +static int +W_VerifyWAD (FILE *fp, lumpchecklist_t *checklist, boolean status) +{ + size_t i; + + // assume wad file + wadinfo_t header; + filelump_t lumpinfo; + + // read the header + if (fread(&header, 1, sizeof header, fp) == sizeof header + && header.numlumps < INT16_MAX + && strncmp(header.identification, "ZWAD", 4) + && strncmp(header.identification, "IWAD", 4) + && strncmp(header.identification, "PWAD", 4) + && strncmp(header.identification, "SDLL", 4)) + { + return true; + } + + header.numlumps = LONG(header.numlumps); + header.infotableofs = LONG(header.infotableofs); + + // let seek to the lumpinfo list + if (fseek(fp, header.infotableofs, SEEK_SET) == -1) + return true; + + for (i = 0; i < header.numlumps; i++) + { + // fill in lumpinfo for this wad file directory + if (fread(&lumpinfo, sizeof (lumpinfo), 1 , fp) != 1) + return true; + + lumpinfo.filepos = LONG(lumpinfo.filepos); + lumpinfo.size = LONG(lumpinfo.size); + + if (lumpinfo.size == 0) + continue; + + if (! W_VerifyName(lumpinfo.name, checklist, status)) + return false; + } + + return true; +} + +// List of blacklisted folders to use when checking the PK3 +static lumpchecklist_t folderblacklist[] = +{ + {"Lua/", 4}, + {"SOC/", 4}, + {"Sprites/", 8}, + {"Textures/", 9}, + {"Patches/", 8}, + {"Flats/", 6}, + {"Fades/", 6}, + {NULL, 0}, +}; + +static int +W_VerifyPK3 (FILE *fp, lumpchecklist_t *checklist, boolean status) +{ + zend_t zend; + zentry_t zentry; + + UINT16 numlumps; + size_t i; + + char pat_central[] = {0x50, 0x4b, 0x01, 0x02, 0x00}; + char pat_end[] = {0x50, 0x4b, 0x05, 0x06, 0x00}; + + char lumpname[9]; + + // Haha the ResGetLumpsZip function doesn't + // check for file errors, so neither will I. + + // Central directory bullshit + + fseek(fp, 0, SEEK_END); + if (!ResFindSignature(fp, pat_end, max(0, ftell(fp) - (22 + 65536)))) + return true; + + fseek(fp, -4, SEEK_CUR); + if (fread(&zend, 1, sizeof zend, fp) < sizeof zend) + return true; + + numlumps = zend.entries; + + fseek(fp, zend.cdiroffset, SEEK_SET); + for (i = 0; i < numlumps; i++) + { + char* fullname; + char* trimname; + char* dotpos; + + if (fread(&zentry, 1, sizeof(zentry_t), fp) < sizeof(zentry_t)) + return true; + if (memcmp(zentry.signature, pat_central, 4)) + return true; + + fullname = malloc(zentry.namelen + 1); + if (fgets(fullname, zentry.namelen + 1, fp) != fullname) + return true; + + // Strip away file address and extension for the 8char name. + if ((trimname = strrchr(fullname, '/')) != 0) + trimname++; + else + trimname = fullname; // Care taken for root files. + + if (*trimname) // Ignore directories, well kinda + { + if ((dotpos = strrchr(trimname, '.')) == 0) + dotpos = fullname + strlen(fullname); // Watch for files without extension. + + memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary? + strncpy(lumpname, trimname, min(8, dotpos - trimname)); + + if (! W_VerifyName(lumpname, checklist, status)) + return false; + + // Check for directories next, if it's blacklisted it will return false + if (W_VerifyName(fullname, folderblacklist, status)) + return false; + } + + free(fullname); + } + + return true; +} + // Note: This never opens lumps themselves and therefore doesn't have to // deal with compressed lumps. static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, boolean status) { FILE *handle; - size_t i, j; int goodfile = false; if (!checklist) @@ -1633,66 +1848,15 @@ static int W_VerifyFile(const char *filename, lumpchecklist_t *checklist, if ((handle = W_OpenWadFile(&filename, false)) == NULL) return -1; - // detect wad file by the absence of the other supported extensions - if (stricmp(&filename[strlen(filename) - 4], ".soc") -#ifdef HAVE_BLUA - && stricmp(&filename[strlen(filename) - 4], ".lua") -#endif - && stricmp(&filename[strlen(filename) - 4], ".pk3")) + if (stricmp(&filename[strlen(filename) - 4], ".pk3") == 0) + goodfile = W_VerifyPK3(handle, checklist, status); + else { - // assume wad file - wadinfo_t header; - filelump_t lumpinfo; - - // read the header - if (fread(&header, 1, sizeof header, handle) == sizeof header - && header.numlumps < INT16_MAX - && strncmp(header.identification, "ZWAD", 4) - && strncmp(header.identification, "IWAD", 4) - && strncmp(header.identification, "PWAD", 4) - && strncmp(header.identification, "SDLL", 4)) + // detect wad file by the absence of the other supported extensions + if (stricmp(&filename[strlen(filename) - 4], ".soc") + && stricmp(&filename[strlen(filename) - 4], ".lua")) { - fclose(handle); - return true; - } - - header.numlumps = LONG(header.numlumps); - header.infotableofs = LONG(header.infotableofs); - - // let seek to the lumpinfo list - if (fseek(handle, header.infotableofs, SEEK_SET) == -1) - { - fclose(handle); - return false; - } - - goodfile = true; - for (i = 0; i < header.numlumps; i++) - { - // fill in lumpinfo for this wad file directory - if (fread(&lumpinfo, sizeof (lumpinfo), 1 , handle) != 1) - { - fclose(handle); - return -1; - } - - lumpinfo.filepos = LONG(lumpinfo.filepos); - lumpinfo.size = LONG(lumpinfo.size); - - if (lumpinfo.size == 0) - continue; - - for (j = 0; j < NUMSPRITES; j++) - if (sprnames[j] && !strncmp(lumpinfo.name, sprnames[j], 4)) // Sprites - continue; - - goodfile = false; - for (j = 0; checklist[j].len && checklist[j].name && !goodfile; j++) - if ((strncmp(lumpinfo.name, checklist[j].name, checklist[j].len) != false) == status) - goodfile = true; - - if (!goodfile) - break; + goodfile = W_VerifyWAD(handle, checklist, status); } } fclose(handle); @@ -1717,16 +1881,126 @@ int W_VerifyNMUSlumps(const char *filename) // ENDOOM text and palette lumps lumpchecklist_t NMUSlist[] = { - {"D_", 2}, - {"O_", 2}, - {"DS", 2}, - {"ENDOOM", 6}, - {"PLAYPAL", 7}, - {"COLORMAP", 8}, - {"PAL", 3}, - {"CLM", 3}, - {"TRANS", 5}, + {"D_", 2}, // MIDI music + {"O_", 2}, // Digital music + {"DS", 2}, // Sound effects + + {"ENDOOM", 6}, // ENDOOM text lump + + {"PLAYPAL", 7}, // Palette changes + {"PAL", 3}, // Palette changes + {"COLORMAP", 8}, // Colormap changes + {"CLM", 3}, // Colormap changes + {"TRANS", 5}, // Translucency map changes + + {"LTFNT", 5}, // Level title font changes + {"TTL", 3}, // Act number changes + {"STCFN", 5}, // Console font changes + {"TNYFN", 5}, // Tiny console font changes + {"STT", 3}, // Acceptable HUD changes (Score Time Rings) + {"YB_", 3}, // Intermission graphics, goes with the above + {"M_", 2}, // As does menu stuff + {"MUSICDEF", 8}, // Song definitions (thanks kart) + {NULL, 0}, }; return W_VerifyFile(filename, NMUSlist, false); } + +/** \brief Generates a virtual resource used for level data loading. + * + * \param lumpnum_t reference + * \return Virtual resource + * + */ +virtres_t* vres_GetMap(lumpnum_t lumpnum) +{ + UINT32 i; + virtres_t* vres = NULL; + virtlump_t* vlumps = NULL; + size_t numlumps = 0; + + if (W_IsLumpWad(lumpnum)) + { + // Remember that we're assuming that the WAD will have a specific set of lumps in a specific order. + UINT8 *wadData = W_CacheLumpNum(lumpnum, PU_LEVEL); + filelump_t *fileinfo = (filelump_t *)(wadData + ((wadinfo_t *)wadData)->infotableofs); + numlumps = ((wadinfo_t *)wadData)->numlumps; + vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); + + // Build the lumps. + for (i = 0; i < numlumps; i++) + { + vlumps[i].size = (size_t)(((filelump_t *)(fileinfo + i))->size); + // Play it safe with the name in this case. + memcpy(vlumps[i].name, (fileinfo + i)->name, 8); + vlumps[i].name[8] = '\0'; + vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that. + memcpy(vlumps[i].data, wadData + (fileinfo + i)->filepos, vlumps[i].size); + } + + Z_Free(wadData); + } + else + { + // Count number of lumps until the end of resource OR up until next "MAPXX" lump. + lumpnum_t lumppos = lumpnum + 1; + for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++) + if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0) + break; + numlumps++; + + vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL); + for (i = 0; i < numlumps; i++, lumpnum++) + { + vlumps[i].size = W_LumpLength(lumpnum); + memcpy(vlumps[i].name, W_CheckNameForNum(lumpnum), 8); + vlumps[i].name[8] = '\0'; + vlumps[i].data = W_CacheLumpNum(lumpnum, PU_LEVEL); + } + } + vres = Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL); + vres->vlumps = vlumps; + vres->numlumps = numlumps; + + return vres; +} + +/** \brief Frees zone memory for a given virtual resource. + * + * \param Virtual resource + */ +void vres_Free(virtres_t* vres) +{ + while (vres->numlumps--) + Z_Free(vres->vlumps[vres->numlumps].data); + Z_Free(vres->vlumps); + Z_Free(vres); +} + +/** (Debug) Prints lumps from a virtual resource into console. + */ +/* +static void vres_Diag(const virtres_t* vres) +{ + UINT32 i; + for (i = 0; i < vres->numlumps; i++) + CONS_Printf("%s\n", vres->vlumps[i].name); +} +*/ + +/** \brief Finds a lump in a given virtual resource. + * + * \param Virtual resource + * \param Lump name to look for + * \return Virtual lump if found, NULL otherwise + * + */ +virtlump_t* vres_Find(const virtres_t* vres, const char* name) +{ + UINT32 i; + for (i = 0; i < vres->numlumps; i++) + if (fastcmp(name, vres->vlumps[i].name)) + return &vres->vlumps[i]; + return NULL; +} diff --git a/src/w_wad.h b/src/w_wad.h index e2e17740f..d598d9b39 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -72,6 +72,25 @@ typedef struct compmethod compression; // lump compression method } lumpinfo_t; +// ========================================================================= +// 'VIRTUAL' RESOURCES +// ========================================================================= + +typedef struct { + char name[9]; + UINT8* data; + size_t size; +} virtlump_t; + +typedef struct { + size_t numlumps; + virtlump_t* vlumps; +} virtres_t; + +virtres_t* vres_GetMap(lumpnum_t); +void vres_Free(virtres_t*); +virtlump_t* vres_Find(const virtres_t*, const char*); + // ========================================================================= // DYNAMIC WAD LOADING // ========================================================================= @@ -96,13 +115,13 @@ typedef enum restype RET_UNKNOWN, } restype_t; - typedef struct wadfile_s { char *filename; restype_t type; lumpinfo_t *lumpinfo; lumpcache_t *lumpcache; + lumpcache_t *patchcache; #ifdef HWRENDER aatree_t *hwrcache; // patches are cached in renderer's native format #endif @@ -110,7 +129,8 @@ typedef struct wadfile_s FILE *handle; UINT32 filesize; // for network UINT8 md5sum[16]; - boolean important; + + boolean important; // also network - !W_VerifyNMUSlumps } wadfile_t; #define WADFILENUM(lumpnum) (UINT16)((lumpnum)>>16) // wad flumpnum>>16) // wad file number in upper word @@ -126,14 +146,10 @@ void W_Shutdown(void); // Opens a WAD file. Returns the FILE * handle for the file, or NULL if not found or could not be opened FILE *W_OpenWadFile(const char **filename, boolean useerrors); // Load and add a wadfile to the active wad files, returns numbers of lumps, INT16_MAX on error -UINT16 W_InitFile(const char *filename); -#ifdef DELFILE -void W_UnloadWadFile(UINT16 num); -#endif +UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup); -// W_InitMultipleFiles returns 1 if all is okay, 0 otherwise, -// so that it stops with a message if a file was not found, but not if all is okay. -INT32 W_InitMultipleFiles(char **filenames); +// W_InitMultipleFiles exits if a file was not found, but not if all is okay. +void W_InitMultipleFiles(char **filenames, UINT16 mainfiles); const char *W_CheckNameForNumPwad(UINT16 wad, UINT16 lump); const char *W_CheckNameForNum(lumpnum_t lumpnum); @@ -154,6 +170,7 @@ size_t W_LumpLengthPwad(UINT16 wad, UINT16 lump); size_t W_LumpLength(lumpnum_t lumpnum); boolean W_IsLumpWad(lumpnum_t lumpnum); // for loading maps from WADs in PK3s +boolean W_IsLumpFolder(UINT16 wad, UINT16 lump); // for detecting folder "lumps" #ifdef HAVE_ZLIB void zerr(int ret); // zlib error checking @@ -169,19 +186,16 @@ void *W_CacheLumpNum(lumpnum_t lump, INT32 tag); void *W_CacheLumpNumForce(lumpnum_t lumpnum, INT32 tag); boolean W_IsLumpCached(lumpnum_t lump, void *ptr); +boolean W_IsPatchCached(lumpnum_t lump, void *ptr); void *W_CacheLumpName(const char *name, INT32 tag); void *W_CachePatchName(const char *name, INT32 tag); -#ifdef HWRENDER -//void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); // return a patch_t +void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag); // return a patch_t void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); // return a patch_t -#else -//#define W_CachePatchNumPwad(wad, lump, tag) W_CacheLumpNumPwad(wad, lump, tag) -#define W_CachePatchNum(lumpnum, tag) W_CacheLumpNum(lumpnum, tag) -#endif void W_UnlockCachedPatch(void *patch); +void W_FlushCachedPatches(void); void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg index def2fe682..27926b208 100644 --- a/src/win32/Makefile.cfg +++ b/src/win32/Makefile.cfg @@ -10,22 +10,44 @@ ifdef MINGW64 HAVE_LIBGME=1 LIBGME_CFLAGS=-I../libs/gme/include LIBGME_LDFLAGS=-L../libs/gme/win64 -lgme +ifdef HAVE_OPENMPT + LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc + LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64/mingw -lopenmpt +endif +ifndef NOMIXERX + HAVE_MIXERX=1 + SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main + SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDLMixerX/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows +else SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDL2_mixer/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows +endif else HAVE_LIBGME=1 LIBGME_CFLAGS=-I../libs/gme/include LIBGME_LDFLAGS=-L../libs/gme/win32 -lgme +ifdef HAVE_OPENMPT + LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc + LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86/mingw -lopenmpt +endif +ifndef NOMIXERX + HAVE_MIXERX=1 + SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main + SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDLMixerX/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows +else SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows endif +endif ifndef NOASM USEASM=1 endif +ifndef NONET ifndef MINGW64 #miniupnc is broken with MINGW64 HAVE_MINIUPNPC=1 +endif endif OPTS=-DSTDC_HEADERS @@ -34,10 +56,6 @@ ifndef GCC44 #OPTS+=-mms-bitfields endif -ifndef MINGW64 - OPTS+=-gdwarf-2 -endif - ifndef SDL OPTS+=-D_WINDOWS endif diff --git a/src/win32/Srb2win-vc10.vcxproj b/src/win32/Srb2win-vc10.vcxproj index 774ce5cbe..387d65da9 100644 --- a/src/win32/Srb2win-vc10.vcxproj +++ b/src/win32/Srb2win-vc10.vcxproj @@ -91,6 +91,7 @@ + @@ -230,7 +231,11 @@ + + + + @@ -290,8 +295,13 @@ true + + true + + + @@ -394,6 +404,10 @@ + + + + @@ -442,6 +456,8 @@ + + @@ -494,4 +510,4 @@ - \ No newline at end of file + diff --git a/src/win32/Srb2win-vc10.vcxproj.filters b/src/win32/Srb2win-vc10.vcxproj.filters index d20dd672b..2f380c473 100644 --- a/src/win32/Srb2win-vc10.vcxproj.filters +++ b/src/win32/Srb2win-vc10.vcxproj.filters @@ -369,6 +369,9 @@ R_Rend + + R_Rend + R_Rend @@ -453,6 +456,28 @@ M_Misc + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + + + + R_Rend + + + R_Rend + @@ -506,6 +531,15 @@ Hw_Hardware + + Hw_Hardware + + + Hw_Hardware + + + Hw_Hardware + Hw_Hardware @@ -515,6 +549,9 @@ Hw_Hardware + + Hw_Hardware + BLUA @@ -851,6 +888,16 @@ O_Other + + Hw_Hardware + + + + R_Rend + + + R_Rend + @@ -881,4 +928,4 @@ A_Asm - \ No newline at end of file + diff --git a/src/win32/Srb2win-vc9.vcproj b/src/win32/Srb2win-vc9.vcproj index a64b8638c..4c17bb6f7 100644 --- a/src/win32/Srb2win-vc9.vcproj +++ b/src/win32/Srb2win-vc9.vcproj @@ -55,7 +55,7 @@ Optimization="0" OmitFramePointers="false" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="_DEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="_DEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" MinimalRebuild="true" RuntimeLibrary="1" EnableFunctionLevelLinking="true" @@ -153,7 +153,7 @@ Optimization="0" OmitFramePointers="false" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="_DEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="_DEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" MinimalRebuild="true" BasicRuntimeChecks="3" SmallerTypeCheck="true" @@ -256,7 +256,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="true" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="NDEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="NDEBUG;_WINDOWS;USEASM;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -356,7 +356,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="true" AdditionalIncludeDirectories=""$(ProjectDir)..\..\libs\libpng-src";"$(ProjectDir)..\..\libs\zlib"" - PreprocessorDefinitions="NDEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;HAVE_BLUA;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="NDEBUG;_WINDOWS;HAVE_PNG;COMPVERSION;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="true" diff --git a/src/win32/Srb2win.ico b/src/win32/Srb2win.ico index 700276fd4..3b37433db 100644 Binary files a/src/win32/Srb2win.ico and b/src/win32/Srb2win.ico differ diff --git a/src/win32/Srb2win.props b/src/win32/Srb2win.props index 44a30d50d..fa152f0c9 100644 --- a/src/win32/Srb2win.props +++ b/src/win32/Srb2win.props @@ -5,7 +5,10 @@ - _WINDOWS;%(PreprocessorDefinitions) + + HAVE_ZLIB;HAVE_LIBGME;_WINDOWS;%(PreprocessorDefinitions) + + _WINDOWS;%(PreprocessorDefinitions) diff --git a/src/win32/Srb2win.rc b/src/win32/Srb2win.rc index b60ba750d..d7e3383b0 100644 --- a/src/win32/Srb2win.rc +++ b/src/win32/Srb2win.rc @@ -1,6 +1,7 @@ //Microsoft Developer Studio generated resource script. // #include "resource.h" +#include "winver.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// @@ -62,9 +63,11 @@ END // Version // +#include "../doomdef.h" // Needed for version string + VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,9,0 - PRODUCTVERSION 1,0,9,0 + FILEVERSION 2,2,0,0 + PRODUCTVERSION 2,2,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -82,14 +85,14 @@ BEGIN VALUE "Comments", "Visit our web site at www.srb2.org for news and updates!\0" VALUE "CompanyName", "Sonic Team Junior\0" VALUE "FileDescription", "Sonic Robo Blast 2\0" - VALUE "FileVersion", "1, 09\0" + VALUE "FileVersion", VERSIONSTRING VALUE "InternalName", "srb2\0" - VALUE "LegalCopyright", "Copyright � 1998-2018 by Sonic Team Junior\0" + VALUE "LegalCopyright", "Copyright 1998-2020 by Sonic Team Junior\0" VALUE "LegalTrademarks", "Sonic the Hedgehog and related characters are trademarks of Sega.\0" VALUE "OriginalFilename", "srb2win.exe\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "Sonic Robo Blast 2\0" - VALUE "ProductVersion", "1, 09\0" + VALUE "ProductVersion", VERSIONSTRING VALUE "SpecialBuild", "\0" END END diff --git a/src/win32/fabdxlib.c b/src/win32/fabdxlib.c index c19b036a0..45ec5d0d3 100644 --- a/src/win32/fabdxlib.c +++ b/src/win32/fabdxlib.c @@ -147,7 +147,7 @@ static inline BOOL LoadDirectDraw(VOID) DDrawDLL = LoadLibraryA("DDRAW.DLL"); if (DDrawDLL == NULL) return false; - pfnDirectDrawCreate = (DDCreate)GetProcAddress(DDrawDLL, "DirectDrawCreate"); + pfnDirectDrawCreate = (DDCreate)(LPVOID)GetProcAddress(DDrawDLL, "DirectDrawCreate"); if (pfnDirectDrawCreate == NULL) return false; return true; diff --git a/src/win32/win_dll.c b/src/win32/win_dll.c index 71eda0437..986eb32dc 100644 --- a/src/win32/win_dll.c +++ b/src/win32/win_dll.c @@ -98,10 +98,11 @@ static loadfunc_t hwdFuncTable[] = { {"Init@4", &hwdriver.pfnInit}, {"Shutdown@0", &hwdriver.pfnShutdown}, {"GetModeList@8", &hwdriver.pfnGetModeList}, - {"SetPalette@8", &hwdriver.pfnSetPalette}, + {"SetPalette@4", &hwdriver.pfnSetPalette}, {"FinishUpdate@4", &hwdriver.pfnFinishUpdate}, {"Draw2DLine@12", &hwdriver.pfnDraw2DLine}, {"DrawPolygon@16", &hwdriver.pfnDrawPolygon}, + {"RenderSkyDome@16", &hwdriver.pfnRenderSkyDome}, {"SetBlend@4", &hwdriver.pfnSetBlend}, {"ClearBuffer@12", &hwdriver.pfnClearBuffer}, {"SetTexture@4", &hwdriver.pfnSetTexture}, @@ -109,8 +110,7 @@ static loadfunc_t hwdFuncTable[] = { {"GClipRect@20", &hwdriver.pfnGClipRect}, {"ClearMipMapCache@0", &hwdriver.pfnClearMipMapCache}, {"SetSpecialState@8", &hwdriver.pfnSetSpecialState}, - {"DrawMD2@16", &hwdriver.pfnDrawMD2}, - {"DrawMD2i@36", &hwdriver.pfnDrawMD2i}, + {"DrawModel@16", &hwdriver.pfnDrawModel}, {"SetTransform@4", &hwdriver.pfnSetTransform}, {"GetTextureUsed@0", &hwdriver.pfnGetTextureUsed}, {"GetRenderVersion@0", &hwdriver.pfnGetRenderVersion}, @@ -133,6 +133,7 @@ static loadfunc_t hwdFuncTable[] = { {"FinishUpdate", &hwdriver.pfnFinishUpdate}, {"Draw2DLine", &hwdriver.pfnDraw2DLine}, {"DrawPolygon", &hwdriver.pfnDrawPolygon}, + {"RenderSkyDome", &hwdriver.pfnRenderSkyDome}, {"SetBlend", &hwdriver.pfnSetBlend}, {"ClearBuffer", &hwdriver.pfnClearBuffer}, {"SetTexture", &hwdriver.pfnSetTexture}, @@ -140,8 +141,7 @@ static loadfunc_t hwdFuncTable[] = { {"GClipRect", &hwdriver.pfnGClipRect}, {"ClearMipMapCache", &hwdriver.pfnClearMipMapCache}, {"SetSpecialState", &hwdriver.pfnSetSpecialState}, - {"DrawMD2", &hwdriver.pfnDrawMD2}, - {"DrawMD2i", &hwdriver.pfnDrawMD2i}, + {"DrawModel", &hwdriver.pfnDrawModel}, {"SetTransform", &hwdriver.pfnSetTransform}, {"GetTextureUsed", &hwdriver.pfnGetTextureUsed}, {"GetRenderVersion", &hwdriver.pfnGetRenderVersion}, diff --git a/src/win32/win_main.c b/src/win32/win_main.c index bfe620a43..8a29f7e18 100644 --- a/src/win32/win_main.c +++ b/src/win32/win_main.c @@ -42,7 +42,7 @@ #include "fabdxlib.h" #include "win_main.h" #include "win_dbg.h" -#include "../i_sound.h" // midi pause/unpause +#include "../s_sound.h" // pause sound with handling #include "../g_input.h" // KEY_MOUSEWHEELxxx #include "../screen.h" // for BASEVID* @@ -110,9 +110,9 @@ static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPAR // pause music when alt-tab if (appActive && !paused) - I_ResumeSong(); + S_ResumeAudio(); else if (!paused) - I_PauseSong(); + S_PauseAudio(); { HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); DWORD mode; diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 454c53e37..13f766728 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -815,6 +815,61 @@ void I_SetMusicVolume(UINT8 volume) FMR_MUSIC(FMOD_Channel_SetVolume(music_channel, music_volume / 31.0)); } +UINT32 I_GetSongLength(void) +{ + UINT32 length; + if (I_SongType() == MU_MID) + return 0; + FMR_MUSIC(FMOD_Sound_GetLength(music_stream, &length, FMOD_TIMEUNIT_MS)); + return length; +} + +boolean I_SetSongLoopPoint(UINT32 looppoint) +{ + (void)looppoint; + return false; +} + +UINT32 I_GetSongLoopPoint(void) +{ + return 0; +} + +boolean I_SetSongPosition(UINT32 position) +{ + FMOD_RESULT e; + if(I_SongType() == MU_MID) + // Dummy out; this works for some MIDI, but not others. + // SDL does not support this for any MIDI. + return false; + + e = FMOD_Channel_SetPosition(music_channel, position, FMOD_TIMEUNIT_MS); + if (e == FMOD_OK) + return true; + else if (e == FMOD_ERR_UNSUPPORTED // Only music modules, numbnuts! + || e == FMOD_ERR_INVALID_POSITION) // Out-of-bounds! + return false; + else // Congrats, you horribly broke it somehow + { + FMR_MUSIC(e); + return false; + } +} + +UINT32 I_GetSongPosition(void) +{ + FMOD_RESULT e; + unsigned int fmposition = 0; + if(I_SongType() == MU_MID) + // Dummy out because unsupported, even though FMOD does this correctly. + return 0; + e = FMOD_Channel_GetPosition(music_channel, &fmposition, FMOD_TIMEUNIT_MS); + if (e == FMOD_OK) + return (UINT32)fmposition; + else + return 0; +} + boolean I_SetSongTrack(INT32 track) { if (track != current_track) // If the track's already playing, then why bother? @@ -859,3 +914,46 @@ boolean I_SetSongTrack(INT32 track) } return false; } + +/// ------------------------ +/// MUSIC FADING +/// ------------------------ + +void I_SetInternalMusicVolume(UINT8 volume) +{ + (void)volume; +} + +void I_StopFadingSong(void) +{ +} + +boolean I_FadeSongFromVolume(UINT8 target_volume, UINT8 source_volume, UINT32 ms, void (*callback)(void)) +{ + (void)target_volume; + (void)source_volume; + (void)ms; + (void)callback; + return false; +} + +boolean I_FadeSong(UINT8 target_volume, UINT32 ms, void (*callback)(void)) +{ + (void)target_volume; + (void)ms; + (void)callback; + return false; +} + +boolean I_FadeOutStopSong(UINT32 ms) +{ + (void)ms; + return false; +} + +boolean I_FadeInPlaySong(UINT32 ms, boolean looping) +{ + (void)ms; + (void)looping; + return false; +} diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index 77a21f7f3..42733c309 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -327,7 +327,7 @@ static inline VOID I_GetConsoleEvents(VOID) break; case VK_RETURN: entering_con_command = false; - // Fall through. + /* FALLTHRU */ default: ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char } @@ -639,9 +639,6 @@ void I_Error(const char *error, ...) if (!errorcount) { M_SaveConfig(NULL); // save game config, cvars.. -#ifndef NONET - D_SaveBan(); // save the ban list -#endif G_SaveGameData(); } @@ -650,7 +647,7 @@ void I_Error(const char *error, ...) if (demorecording) G_CheckDemoStatus(); if (metalrecording) - G_StopMetalRecording(); + G_StopMetalRecording(false); D_QuitNetGame(); @@ -736,7 +733,7 @@ void I_Quit(void) if (demorecording) G_CheckDemoStatus(); if (metalrecording) - G_StopMetalRecording(); + G_StopMetalRecording(false); M_SaveConfig(NULL); // save game config, cvars.. #ifndef NONET @@ -1357,6 +1354,8 @@ getBufferedData: } } +void I_UpdateMouseGrab(void) {} + // =========================================================================================== // DIRECT INPUT JOYSTICK // =========================================================================================== @@ -3398,7 +3397,7 @@ BOOL LoadDirectInput(VOID) DInputDLL = LoadLibraryA("DINPUT.DLL"); if (DInputDLL == NULL) return false; - pfnDirectInputCreateA = (DICreateA)GetProcAddress(DInputDLL, "DirectInputCreateA"); + pfnDirectInputCreateA = (DICreateA)(LPVOID)GetProcAddress(DInputDLL, "DirectInputCreateA"); if (pfnDirectInputCreateA == NULL) return false; return true; @@ -3532,7 +3531,7 @@ void I_GetDiskFreeSpace(INT64* freespace) if (!testwin95) { - pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); + pfnGetDiskFreeSpaceEx = (p_GetDiskFreeSpaceExA)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetDiskFreeSpaceExA"); testwin95 = true; } if (pfnGetDiskFreeSpaceEx) @@ -3618,7 +3617,7 @@ const CPUInfoFlags *I_CPUInfo(void) { static CPUInfoFlags WIN_CPUInfo; SYSTEM_INFO SI; - p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); + p_IsProcessorFeaturePresent pfnCPUID = (p_IsProcessorFeaturePresent)(LPVOID)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsProcessorFeaturePresent"); ZeroMemory(&WIN_CPUInfo,sizeof (WIN_CPUInfo)); if (pfnCPUID) @@ -3661,9 +3660,9 @@ static p_SetProcessAffinityMask pfnSetProcessAffinityMask = NULL; static inline VOID GetAffinityFuncs(VOID) { HMODULE h = GetModuleHandleA("kernel32.dll"); - pfnGetCurrentProcess = (p_GetCurrentProcess)GetProcAddress(h, "GetCurrentProcess"); - pfnGetProcessAffinityMask = (p_GetProcessAffinityMask)GetProcAddress(h, "GetProcessAffinityMask"); - pfnSetProcessAffinityMask = (p_SetProcessAffinityMask)GetProcAddress(h, "SetProcessAffinityMask"); + pfnGetCurrentProcess = (p_GetCurrentProcess)(LPVOID)GetProcAddress(h, "GetCurrentProcess"); + pfnGetProcessAffinityMask = (p_GetProcessAffinityMask)(LPVOID)GetProcAddress(h, "GetProcessAffinityMask"); + pfnSetProcessAffinityMask = (p_SetProcessAffinityMask)(LPVOID)GetProcAddress(h, "SetProcessAffinityMask"); } static void CPUAffinity_OnChange(void) diff --git a/src/win32/win_vid.c b/src/win32/win_vid.c index cca7810b3..d0aab92b3 100644 --- a/src/win32/win_vid.c +++ b/src/win32/win_vid.c @@ -239,6 +239,11 @@ void I_StartupGraphics(void) if (!dedicated) graphics_started = true; } +void I_StartupHardwareGraphics(void) +{ + // oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo yeah oh yeah woo y +} + // ------------------ // I_ShutdownGraphics // Close the screen, restore previous video mode. @@ -322,9 +327,9 @@ static inline boolean I_SkipFrame(void) case GS_LEVEL: if (!paused) return false; - /* FALLTHRU */ - case GS_TIMEATTACK: + //case GS_TIMEATTACK: -- sorry optimisation but now we have a cool level platter and that being laggardly looks terrible #ifndef CLIENT_LOADINGSCREEN + /* FALLTHRU */ case GS_WAITINGPLAYERS: #endif return skip; // Skip odd frames @@ -363,10 +368,17 @@ void I_FinishUpdate(void) if (I_SkipFrame()) return; + // draw captions if enabled + if (cv_closedcaptioning.value) + SCR_ClosedCaptions(); + // display a graph of ticrate if (cv_ticrate.value) SCR_DisplayTicRate(); + if (cv_showping.value && netgame && consoleplayer != serverplayer) + SCR_DisplayLocalPing(); + // if (bDIBMode) { @@ -939,6 +951,11 @@ INT32 VID_SetMode(INT32 modenum) return 1; } +void VID_CheckRenderer(void) +{ + // .............. +} + // ======================================================================== // Free the video buffer of the last video mode, // allocate a new buffer for the video mode to set. diff --git a/src/win32ce/GameX.h b/src/win32ce/GameX.h deleted file mode 100644 index 241fdd5be..000000000 --- a/src/win32ce/GameX.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - - GameX - WindowsCE Game Library for High Performance. - - Copyright (C) 1999 Hayes C. Haugen, all rights reserved. - - */ - -/* - * Need better way for host app to keep track of direct vs blit - drawing. Right now GetFBAddress() is the way to do it. - - - */ - - -#pragma once -#include // For VK codes. - -// Defines - -// display property flags - -const unsigned long kfDPGrey = 0x0001; -const unsigned long kfDPGrey2Bit = 0x0002; -const unsigned long kfDPGrey4Bit = 0x0004; -const unsigned long kfDPColor = 0x0008; -const unsigned long kfDPColor8Bit = 0x0010; -const unsigned long kfDPColor16Bit = 0x0020; -const unsigned long kfDPColor24Bit = 0x0040; -const unsigned long kfDPColor32Bit = 0x0080; -const unsigned long kfDPFormatNormal = 0x0100; // fb start is upper left, inc goes across -const unsigned long kfDPFormatRot270 = 0x0200; // fb start is lower left, inc goes up - -// Machine property flags - -const unsigned long kfMPPSPC = 0x0001; // Palm Sized PC - 240 x 320 -const unsigned long kfMPPSPC1 = 0x0002; // 1st gen pspc -const unsigned long kfMPPSPC2 = 0x0004; // Wyverns -const unsigned long kfMPHPC = 0x0008; // Handheld PC -const unsigned long kfMPHPC1 = 0x0010; // HPC 1, 480 x 240 -const unsigned long kfMPHPC2 = 0x0020; // HPC 2, 640 x 240 -const unsigned long kfMPHPC3 = 0x0040; // HPC Pro, 640 x 240, big keys -const unsigned long kfMPPro = 0x0080; // -const unsigned long kfMPAutoPC = 0x0100; -const unsigned long kfMPHasKeyboard = 0x0200; -const unsigned long kfMPHasMouse = 0x0400; -const unsigned long kfMPHasRumble = 0x0800; -const unsigned long kfMPHasTouch = 0x1000; - -// Rotations - -const int kiRotate0 = 0; // no rotation -const int kiRotate90 = 1; // 90 degrees clockwise -const int kiRotate180 = 2; // 180 degrees clockwise (upside down, Rotate 0 flipped) -const int kiRotate270 = 3; // 270 degrees clockwise (Rotate 1 flipped) - -class GameX { -public: - HWND SetButtonNotificationWindow(HWND hWnd); - GameX(); - ~GameX(); - - bool OpenGraphics(); - bool OpenSound(); - bool OpenButtons(HWND hwndButtonNotify); // Window that will get button messages or NULL if you just want to use GetAsyncKeyState(); - bool CloseGraphics(); - bool CloseSound(); - bool CloseButtons(); - - bool IsColor(); - bool IsPSPC(); - bool IsHPC(); - bool IsHPCPro(); - bool HasMouse(); - bool HasKeyboard(); // better than inferring from hpc/pspc/etc. - bool HasRumble(); - bool HasTouch(); // for completeness. At least 1 doesn't. - - int IsForeground(); - bool Suspend(); // release buttons, don't draw, etc. - bool Resume(); // regrab buttons, etc. - - bool BeginDraw(); - bool EndDraw(); - bool FindFrameBuffer(); - void * GetFBAddress(); // simple way to get things that makes code - long GetFBModulo(); // more readable. - long GetFBBpp(); - bool GetScreenRect(RECT * prc); - unsigned long GetDisplayProperties(); - - bool GetButton(int VK); // buttons init themselves on first button call?? - unsigned short GetDefaultButtonID(long id, long rotate); // gets the best button for use as specified by need and rotation - bool ReleaseButton(int VK); - bool BeginDetectButtons(); // grabs all buttons so user can indicate a button in a config dialog - bool EndDetectButtons(); // releases all buttons (except GetButton() ones) - - bool Rumble(); - bool Backlight(bool fOn); -private: -// LRESULT CALLBACK TaskBarWndProc(HWND hWnd, UINT message, WPARAM uParam, LPARAM lParam); - -private: - int m_iMP; // index into amp table for current machine. - void * m_pvFrameBuffer; - long m_cbFBModulo; // count of bytes to next line - unsigned long m_ffMachineProperties; - unsigned long m_ffDisplayProperties; - int m_cBitsPP; - - long m_dwPrevMode; // for Begin/EndDraw() - bool m_fActive; // true if active (resume), false if inactive (suspend). - - HWND m_hwndTaskbar; // Taskbar is official cap, change TaskBar's -}; - - -/* - -kmtCasioE10 -kmtCasioE11 -kmtCasioE15 -kmtCasioE55 -kmtCasioE100 -kmtLGPhenomII - -stuff for memory size and presence/absence of CF - -// Rotations that make sense for this device or default rotation: - -Rotate0 // no rotation -Rotate1 // 90 degrees clockwise -Rotate2 // 180 degrees clockwise (upside down, Rotate 0 flipped) -Rotate3 // 270 degrees clockwise (Rotate 1 flipped) - -kmtAccessNone // no direct framebuffer access -kmtAccess1 // write to fixed address -kmtAccess2 // find framebuffer memory aperture in GWES.EXE memory space. - -OriginUpperLeft -OriginUpperRight -OriginLowerRight -OriginLowerLeft - -MappedHorizontal // increasing fb address goes across screen -MappedVertical // increasing fb address goes up/down screen (Compaq) - -A machine entry: -=========================================== - machine kmtCasioE10, - type kmtPSPC | kmtPSPC1, - displaytype kmtGrey | kmtGrey2Bit | kmtAccess1, - pvFrameBuffer 0xAA000000, - cbFBModulo 1024 // count of bytes to next line - cbppFB 2, // bits per pixel - cxDisp 240, - cyDisp 320, - format OriginUpperLeft, MappedHorizontal - - rotate0 // for rotate mode 0, these are the best keys - vkUp VK_UP - vkDown VK_DOWN - vkLeft 0xC1 - vkRight 0xC2 - vkA 0xC3 - vkB 0 - rotate1 - vkUp 0xC1 - vkDown 0xC2 - vkLeft VK_DOWN - ... - ...*/ - diff --git a/src/win32ce/SRB2CE.zip b/src/win32ce/SRB2CE.zip deleted file mode 100644 index 3ac8530dc..000000000 Binary files a/src/win32ce/SRB2CE.zip and /dev/null differ diff --git a/src/win32ce/Srb2win.ico b/src/win32ce/Srb2win.ico deleted file mode 100644 index 700276fd4..000000000 Binary files a/src/win32ce/Srb2win.ico and /dev/null differ diff --git a/src/win32ce/afxres.h b/src/win32ce/afxres.h deleted file mode 100644 index 7f5245404..000000000 --- a/src/win32ce/afxres.h +++ /dev/null @@ -1,17 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief needed if mfc not installed (if I remember well) diff --git a/src/win32ce/gapi_c.cpp b/src/win32ce/gapi_c.cpp deleted file mode 100644 index 60c7adfa2..000000000 --- a/src/win32ce/gapi_c.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include - -#define _USE_GAPI_ - - -#ifndef _USE_GAPI_ - #include "GameX.h" - -struct GXDisplayProperties -{ - DWORD cxWidth; - DWORD cyHeight; - long cbxPitch; - long cbyPitch; - long cBPP; - DWORD ffFormat; -}; - -#define kfPalette 0x10 // Pixel values are indexes into a palette -#define kfDirect565 0x80 // 5 red bits, 6 green bits and 5 blue bits per pixel - - - GameX* gx = new GameX; -#else - #include "gx.h" -#endif - -extern "C" -{ - #include "gapi_c.h" -} - -extern "C" int GXOPENDISPLAY(HWND hWnd, DWORD dwFlags) -{ - #ifndef _USE_GAPI_ - if(!gx) - return 0; - - //gx->OpenSound(); - if(!gx->OpenGraphics()) - { - delete gx; - gx = 0; - return 0; - } - - return TRUE; - - #else - return GXOpenDisplay(hWnd,dwFlags); - #endif -} - -extern "C" int GXCLOSEDISPLAY() -{ - #ifndef _USE_GAPI_ - gx->CloseGraphics(); - return TRUE; - #else - return GXCloseDisplay(); - #endif -} - -extern "C" void * GXBEGINDRAW() -{ - #ifndef _USE_GAPI_ - if(gx->BeginDraw()) - return gx->GetFBAddress(); - - return NULL; - #else - return GXBeginDraw(); - #endif -} - -extern "C" int GXENDDRAW() -{ - #ifndef _USE_GAPI_ - return gx->EndDraw(); - #else - return GXEndDraw(); - #endif - -} - -extern "C" struct GXDisplayProperties GXGETDISPLAYPROPERTIES() -{ - #ifndef _USE_GAPI_ - RECT r; - GXDisplayProperties gxdp; - - gxdp.cbyPitch = gx->GetFBModulo(); - gxdp.cBPP = gx->GetFBBpp(); - gxdp.cbxPitch = (gxdp.cBPP >> 3); - - gx->GetScreenRect(&r); - gxdp.cxWidth = (r.right - r.left); - gxdp.cyHeight = (r.bottom - r.top); - - if(gxdp.cBPP = 16) - gxdp.ffFormat = kfDirect565; - else if(gxdp.cBPP = 8) - gxdp.ffFormat = kfPalette; - - return gxdp; - - #else - return GXGetDisplayProperties(); - #endif -} - -extern "C" int GXSUSPEND() -{ - #ifndef _USE_GAPI_ - return gx->Suspend(); - #else - return GXSuspend(); - #endif -} - -extern "C" int GXRESUME() -{ - #ifndef _USE_GAPI_ - return gx->Resume(); - #else - return GXResume(); - #endif -} \ No newline at end of file diff --git a/src/win32ce/gapi_c.h b/src/win32ce/gapi_c.h deleted file mode 100644 index 40e7799ff..000000000 --- a/src/win32ce/gapi_c.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef GAPI_H -#define GAPI_H - -int GXOPENDISPLAY(HWND hWnd, DWORD dwFlags); -int GXCLOSEDISPLAY(); -void * GXBEGINDRAW(); -int GXENDDRAW(); -struct GXDisplayProperties GXGETDISPLAYPROPERTIES(); -int GXSUSPEND(); -int GXRESUME(); - -#endif \ No newline at end of file diff --git a/src/win32ce/gxgapilib.c b/src/win32ce/gxgapilib.c deleted file mode 100644 index 8ff57092d..000000000 --- a/src/win32ce/gxgapilib.c +++ /dev/null @@ -1,636 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -//----------------------------------------------------------------------------- -/// \file -/// \brief Zak Larue-Buckley's GX and GAPI library v1.0 - -#include "../doomdef.h" -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#include -#include "../i_system.h" -#include "dx_error.h" - -#include "fabdxlib.h" - -#define NT4COMPAT //always defined, always compatible - - -// globals - -IDirectDraw2* DDr2 = NULL; -IDirectDrawSurface* ScreenReal = NULL; // DirectDraw primary surface -IDirectDrawSurface* ScreenVirtual = NULL; // DirectDraw back surface -IDirectDrawPalette* DDPalette = NULL; // The primary surface palette -static IDirectDrawClipper *windclip = NULL; // clipper for windowed mode - -BOOL bAppFullScreen; // true for fullscreen exclusive mode, - -int windowPosX = 0; // current position in windowed mode -int windowPosY = 0; - -int ScreenWidth; -int ScreenHeight; -BOOL ScreenLocked; // Screen surface is being locked -int ScreenPitch; // offset from one line to the next -LPBYTE ScreenPtr; // memory of the surface - - -// -// CreateNewSurface -// -static inline IDirectDrawSurface* CreateNewSurface(int dwWidth, - int dwHeight, - int dwSurfaceCaps) -{ - DDSURFACEDESC ddsd; - HRESULT hr; - LPDIRECTDRAWSURFACE psurf; - - ZeroMemory(&ddsd, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH; - - ddsd.ddsCaps.dwCaps = dwSurfaceCaps; - - ddsd.dwHeight = dwHeight; - ddsd.dwWidth = dwWidth; - - hr = IDirectDraw2_CreateSurface (DDr2, &ddsd, &psurf, NULL); - - if (hr == DD_OK) - { - //DDCOLORKEY ddck; - IDirectDrawSurface_Restore(psurf); - - //hr = IDirectDrawSurface_GetColorKey(DDCKEY_SRCBLT, &ddck); - //psurf->SetColorKey(DDCKEY_SRCBLT, &ddck); - } - else - psurf = NULL; - - return psurf; -} - -// -// wow! from 320x200x8 up to 1600x1200x32 thanks Banshee! :) -// -static HRESULT WINAPI myEnumModesCallback (LPDDSURFACEDESC surf, LPVOID lpContext) -{ - APPENUMMODESCALLBACK pfnContext = lpContext; - - if (pfnContext) pfnContext(surf->dwWidth, - surf->dwHeight,surf->ddpfPixelFormat. -#ifdef DUMMYUNIONNAMEN - DUMMYUNIONNAMEN(1). -#endif - dwRGBBitCount - ); - - /*CONS_Printf ("%dx%dx%d bpp %d refresh\n", - surf->dwWidth, - surf->dwHeight, - surf->ddpfPixelFormat.dwRGBBitCount, - surf->dwRefreshRate);*/ - - return DDENUMRET_OK; -} - - -// -// Application call here to enumerate display modes -// -BOOL EnumDirectDrawDisplayModes (APPENUMMODESCALLBACK appFunc) -{ - LPVOID lpappFunc = appFunc; - - if (DDr2 == NULL) - return FALSE; - - // enumerate display modes - // Carl: DirectX 3.x apparently does not support VGA modes. Who cares. :) - // faB: removed DDEDM_REFRESHRATES, detects too many modes, plus we don't care of refresh rate. - if (bDX0300) - IDirectDraw2_EnumDisplayModes (DDr2, 0 /*| DDEDM_REFRESHRATES*/, - NULL, lpappFunc, myEnumModesCallback); - else - IDirectDraw2_EnumDisplayModes (DDr2, DDEDM_STANDARDVGAMODES /*| DDEDM_REFRESHRATES*/, - NULL, lpappFunc, myEnumModesCallback); - return TRUE; -} - - -// -// Create the DirectDraw object for later -// -BOOL CreateDirectDrawInstance (VOID) -{ - HRESULT hr; - IDirectDraw* DDr; - IDirectDraw** rp = &DDr; - IDirectDraw2** rp2 = &DDr2; - LPVOID *tp = (LPVOID *)rp2; - - // - // create an instance of DirectDraw object - // - if (FAILED(hr = DirectDrawCreate(NULL, rp, NULL))) - I_Error("DirectDrawCreate FAILED: %s", DXErrorToString(hr)); - - // change interface to IDirectDraw2 - if (FAILED(hr = IDirectDraw_QueryInterface (DDr, &IID_IDirectDraw2, tp))) - I_Error("Failed to query DirectDraw2 interface: %s", DXErrorToString(hr)); - - // release the interface we don't need - IDirectDraw_Release (DDr); - return TRUE; -} - - -// -// - returns true if DirectDraw was initialized properly -// -int InitDirectDrawe (HWND appWin, int width, int height, int bpp, int fullScr) -{ - DDSURFACEDESC ddsd; // DirectDraw surface description for allocating - DDSCAPS ddscaps; - HRESULT ddrval; - - DWORD dwStyle; - RECT rect; - - // enumerate directdraw devices - //if (FAILED(DirectDrawEnumerate (myEnumDDDevicesCallback, NULL))) - // I_Error("Error with DirectDrawEnumerate"); - - if (!DDr2) - CreateDirectDrawInstance(); - - // remember what screen mode we are in - bAppFullScreen = fullScr; - ScreenHeight = height; - ScreenWidth = width; - - if (bAppFullScreen) - { - // Change window attributes - dwStyle = WS_POPUP | WS_VISIBLE; - SetWindowLong (appWin, GWL_STYLE, dwStyle); - SetWindowPos(appWin, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | - SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); - - // Get exclusive mode - ddrval = IDirectDraw2_SetCooperativeLevel(DDr2, appWin, DDSCL_EXCLUSIVE | - DDSCL_FULLSCREEN | - DDSCL_ALLOWREBOOT); - if (ddrval != DD_OK) - I_Error("SetCooperativeLevel FAILED: %s\n", DXErrorToString(ddrval)); - - // Switch from windows desktop to fullscreen - -#ifdef NT4COMPAT - ddrval = IDirectDraw2_SetDisplayMode(DDr2, width, height, bpp, 0, 0); -#else - ddrval = IDirectDraw2_SetDisplayMode(DDr2, width, height, bpp, 0, DDSDM_STANDARDVGAMODE); -#endif - if (ddrval != DD_OK) - I_Error("SetDisplayMode FAILED: %s\n", DXErrorToString(ddrval)); - - // This is not really needed, except in certain cases. One case - // is while using MFC. When the desktop is initally at 16bpp, a mode - // switch to 8bpp somehow causes the MFC window to not fully initialize - // and a CreateSurface will fail with DDERR_NOEXCLUSIVEMODE. This will - // ensure that the window is initialized properly after a mode switch. - - ShowWindow(appWin, SW_SHOW); - - // Create the primary surface with 1 back buffer. Always zero the - // DDSURFACEDESC structure and set the dwSize member! - - ZeroMemory(&ddsd, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX; - - // for fullscreen we use page flipping, for windowed mode, we blit the hidden surface to - // the visible surface, in both cases we have a visible (or 'real') surface, and a hidden - // (or 'virtual', or 'backbuffer') surface. - ddsd.dwBackBufferCount = 1; - - ddrval = IDirectDraw2_CreateSurface(DDr2,&ddsd, &ScreenReal, NULL); - if (ddrval != DD_OK) - I_Error("CreateSurface Primary Screen FAILED"); - - // Get a pointer to the back buffer - - ddscaps.dwCaps = DDSCAPS_BACKBUFFER; - ddrval = IDirectDrawSurface_GetAttachedSurface(ScreenReal,&ddscaps, &ScreenVirtual); - if (ddrval != DD_OK) - I_Error("GetAttachedSurface FAILED"); - } - else - { - rect.top = 0; - rect.left = 0; - rect.bottom = height-1; - rect.right = width-1; - - // Change window attributes - - dwStyle = GetWindowStyle(appWin); - dwStyle &= ~WS_POPUP; - dwStyle |= WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION; - - SetWindowLong(appWin, GWL_STYLE, dwStyle); - - // Resize the window so that the client area is the requested width/height - - AdjustWindowRectEx(&rect, GetWindowStyle(appWin), GetMenu(appWin) != NULL, - GetWindowExStyle(appWin)); - - // Just in case the window was moved off the visible area of the - // screen. - - SetWindowPos(appWin, NULL, 0, 0, rect.right-rect.left, - rect.bottom-rect.top, SWP_NOMOVE | SWP_NOZORDER | - SWP_NOACTIVATE); - - SetWindowPos(appWin, HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); - - // Exclusive mode is normal since it's in windowed mode and needs - // to cooperate with GDI - - ddrval = IDirectDraw2_SetCooperativeLevel(DDr2,appWin, DDSCL_NORMAL); - if (ddrval != DD_OK) - I_Error("SetCooperativeLevel FAILED"); - - // Always zero the DDSURFACEDESC structure and set the dwSize member! - - ZeroMemory(&ddsd, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - - // Create the primary surface - - ddrval = IDirectDraw2_CreateSurface(DDr2,&ddsd, &ScreenReal, NULL); - if (ddrval != DD_OK) - I_Error("CreateSurface Primary Screen FAILED"); - - // Create a back buffer for offscreen rendering, this will be used to - // blt to the primary - - ScreenVirtual = CreateNewSurface(width, height, DDSCAPS_OFFSCREENPLAIN | - DDSCAPS_SYSTEMMEMORY); - if (ScreenVirtual == NULL) - I_Error("CreateSurface Secondary Screen FAILED"); - - /// \todo get the desktop bit depth, and build a lookup table - /// for quick conversions of 8bit color indexes 0-255 to desktop colors - /// eg: 256 entries of equivalent of palette colors 0-255 in 15,16,24,32 bit format - /// when blit virtual to real, convert pixels through lookup table.. - - // Use a clipper object for clipping when in windowed mode - // (make sure our drawing doesn't affect other windows) - - ddrval = IDirectDraw2_CreateClipper (DDr2, 0, &windclip, 0); - if (ddrval != DD_OK) - I_Error("CreateClipper FAILED"); - - // Associate the clipper with the window. - ddrval = IDirectDrawClipper_SetHWnd (windclip,0, appWin); - if (ddrval != DD_OK) - I_Error("Clipper -> SetHWnd FAILED"); - - // Attach the clipper to the surface. - ddrval = IDirectDrawSurface_SetClipper (ScreenReal,windclip); - if (ddrval != DD_OK) - I_Error("PrimaryScreen -> SetClipperClipper FAILED"); - } - - return TRUE; -} - - -// -// Free all memory -// -VOID CloseDirectDraw (VOID) -{ - ReleaseChtuff(); - if (DDr2) - { - IDirectDraw2_Release(DDr2); - DDr2 = NULL; - } -} - - -// -// Release DirectDraw stuff before display mode change -// -VOID ReleaseChtuff (VOID) -{ - if (!DDr2) - return; - if (windclip) - { - IDirectDrawClipper_Release(windclip); - windclip = NULL; - } - if (DDPalette) - { - IDirectDrawPalette_Release(DDPalette); - DDPalette = NULL; - } - // If the app is fullscreen, the back buffer is attached to the - // primary. Releasing the primary buffer will also release any - // attached buffers, so explicitly releasing the back buffer is not - // necessary. - - if (!bAppFullScreen && ScreenVirtual) - { - IDirectDrawSurface_Release(ScreenVirtual); // release hidden surface - ScreenVirtual = NULL; - } - if (ScreenReal) - { - IDirectDrawSurface_Release(ScreenReal); // and attached backbuffers for bAppFullScreen mode - ScreenReal = NULL; - } -} - - -// -// Clear the surface to color -// -VOID ClearSurface(IDirectDrawSurface* surface, int color) -{ - DDBLTFX ddbltfx; - - // Use the blter to do a color fill to clear the back buffer - ddbltfx.dwSize = sizeof (ddbltfx); - ddbltfx. -#ifdef DUMMYUNIONNAMEN - DUMMYUNIONNAMEN(5). -#endif - dwFillColor = color; - IDirectDrawSurface_Blt(surface,NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); - -} - -// -// Flip the real page with virtual page -// - in bAppFullScreen mode, do page flipping -// - in windowed mode, copy the hidden surface to the visible surface -// -// waitflip : if not 0, wait for page flip to end -BOOL ScreenFlip(int waitflip) -{ - HRESULT hr; - RECT rect; - - waitflip = 0; - if (bAppFullScreen) - { - //hr = IDirectDrawSurface_GetFlipStatus (ScreenReal, DDGFS_); - - // In full-screen exclusive mode, do a hardware flip. - hr = IDirectDrawSurface_Flip(ScreenReal, NULL, DDFLIP_WAIT); //return immediately - - // If the surface was lost, restore it. - if (hr == DDERR_SURFACELOST) - { - IDirectDrawSurface_Restore(ScreenReal); - - // The restore worked, so try the flip again. - hr = IDirectDrawSurface_Flip(ScreenReal, 0, DDFLIP_WAIT); - } - } - else - { - rect.left = windowPosX; - rect.top = windowPosY; - rect.right = windowPosX + ScreenWidth - 1; - rect.bottom = windowPosY + ScreenHeight - 1; - - // Copy the back buffer to front. - hr = IDirectDrawSurface_Blt(ScreenReal, &rect, ScreenVirtual, 0, DDBLT_WAIT, 0); - - if (hr != DD_OK) - { - // If the surfaces were lost, restore them. - if (IDirectDrawSurface_IsLost(ScreenReal) == DDERR_SURFACELOST) - IDirectDrawSurface_Restore(ScreenReal); - - if (IDirectDrawSurface_IsLost(ScreenVirtual) == DDERR_SURFACELOST) - IDirectDrawSurface_Restore(ScreenVirtual); - - // Retry the copy. - hr = IDirectDrawSurface_Blt(ScreenReal,&rect, ScreenVirtual, 0, DDBLT_WAIT, 0); - } - } - - if (hr != DD_OK) - I_Error("ScreenFlip() : couldn't Flip surfaces"); - - return FALSE; -} - -// -// Print a text to the surface -// -VOID TextPrint(int x, int y, LPCSTR message) -{ - HRESULT hr; - HDC hdc = NULL; - - // Get the device context handle. - hr = IDirectDrawSurface_GetDC(ScreenVirtual,&hdc); - if (hr != DD_OK) - return; - - // Write the message. - SetBkMode(hdc, TRANSPARENT); - SetTextColor(hdc, RGB(255, 255, 255)); - TextOutA(hdc, x, y, message, (int)strlen(message)); - - // Release the device context. - hr = IDirectDrawSurface_ReleaseDC(ScreenVirtual,hdc); -} - -// -// Lock surface before multiple drawings by hand, for speed -// -boolean LockScreen(VOID) -{ - DDSURFACEDESC ddsd; - HRESULT ddrval; - - ZeroMemory(&ddsd, sizeof (ddsd)); - ddsd.dwSize = sizeof (ddsd); - - // attempt to Lock the surface - ddrval = IDirectDrawSurface_Lock(ScreenVirtual, NULL, &ddsd, DDLOCK_WAIT, NULL); - - // Always, always check for errors with DirectX! - // If the surface was lost, restore it. - if (ddrval == DDERR_SURFACELOST) - { - ddrval = IDirectDrawSurface_Restore(ScreenReal); - - // now retry to get the lock - ddrval = IDirectDrawSurface_Lock(ScreenVirtual, NULL, &ddsd, DDLOCK_WAIT, NULL); - } - - if (ddrval == DD_OK) - { - ScreenLocked = TRUE; - ScreenPtr = (LPBYTE)ddsd.lpSurface; - ScreenPitch = ddsd. -#ifdef DUMMYUNIONNAMEN - DUMMYUNIONNAMEN(1). -#endif - lPitch; - } - else - { - ScreenLocked = FALSE; - ScreenPtr = NULL; - ScreenPitch = 0; - //I_Error("LockScreen() : couldn't restore the surface."); - return false; - } - return true; -} - -// -// Unlock surface -// -VOID UnlockScreen(VOID) -{ - if (DD_OK != IDirectDrawSurface_Unlock(ScreenVirtual,NULL)) - I_Error("Couldn't UnLock the renderer!"); - - ScreenLocked = FALSE; - ScreenPtr = NULL; - ScreenPitch = 0; -} - -// Blit virtual screen to real screen -//faB: note: testing 14/03/1999, see if it is faster than memcopy of virtual to -/* -static LPDIRECTDRAWSURFACE lpDDS = NULL; -VOID BlitScreen(VOID) -{ - HRESULT hr; - - if (!lpDDS) - I_Error("lpDDS NULL"); - - hr = IDirectDrawSurface_BltFast(ScreenVirtual, - 0, 0, // Upper left xy of destination - lpDDS, // Source surface - NULL, // Source rectangle = entire surface - DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY); - if (FAILED(hr)) - I_Error("BltFast FAILED"); -} - -VOID MakeScreen(int width, int height, BYTE* lpSurface) -{ - HRESULT hr; - DDSURFACEDESC ddsd; - - // Initialize the surface description. - ZeroMemory (&ddsd, sizeof ddsd); - ZeroMemory (&ddsd.ddpfPixelFormat, sizeof (DDPIXELFORMAT)); - ddsd.dwSize = sizeof ddsd; - ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | //DDSD_LPSURFACE | - DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_CAPS; - ddsd.dwWidth = width; - ddsd.dwHeight= height; - ddsd.lPitch = width; - ddsd.lpSurface = lpSurface; - ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; - - // Set up the pixel format for 8-bit - ddsd.ddpfPixelFormat.dwSize = sizeof (DDPIXELFORMAT); - ddsd.ddpfPixelFormat.dwFlags= DDPF_RGB | DDPF_PALETTEINDEXED8; - ddsd.ddpfPixelFormat.dwRGBBitCount = 8; - - // - ddsd.ddpfPixelFormat.dwRGBBitCount = (DWORD)DEPTH*8; - ddsd.ddpfPixelFormat.dwRBitMask = 0x00FF0000; - ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00; - ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF; - - // Create the surface - hr = IDirectDraw2_CreateSurface(DDr2, &ddsd, &lpDDS, NULL); - if (FAILED(hr)) - I_Error("MakeScreen FAILED: %s",DDError(hr)); - //ddsd.lpSurface = lpSurface; -} -*/ - -// -// Create a palette object -// -VOID CreateDDPalette (PALETTEENTRY* colorTable) -{ - HRESULT ddrval; - ddrval = IDirectDraw2_CreatePalette(DDr2,DDPCAPS_8BIT|DDPCAPS_ALLOW256, colorTable, &DDPalette, NULL); - if (ddrval != DD_OK) - I_Error("couldn't CreatePalette"); -}; - - -// -// Free the palette object -// -VOID DestroyDDPalette (VOID) -{ - if (DDPalette) - { - IDirectDrawPalette_Release(DDPalette); - DDPalette = NULL; - } -} - -// -// Set a a full palette of 256 PALETTEENTRY entries -// -VOID SetDDPalette(PALETTEENTRY* pal) -{ - // create palette first time - if (DDPalette == NULL) - CreateDDPalette(pal); - else - IDirectDrawPalette_SetEntries(DDPalette, 0, 0, 256, pal); - // setting the same palette to the same surface again does not increase - // the reference count - IDirectDrawSurface_SetPalette(ScreenReal, DDPalette); -} - -// -// Wait for vsync, gross -// -VOID WaitVbl(VOID) -{ - IDirectDraw2_WaitForVerticalBlank(DDr2, DDWAITVB_BLOCKBEGIN, NULL); -} diff --git a/src/win32ce/gxgapilib.h b/src/win32ce/gxgapilib.h deleted file mode 100644 index 189cc15b8..000000000 --- a/src/win32ce/gxgapilib.h +++ /dev/null @@ -1,81 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Zak Larue-Buckley's GX and GAPI library v1.0 - -#ifndef _H_GXGAPILIB_ -#define _H_GXGAPILIB_ - -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#ifdef __MINGW32__ -//#define NONAMELESSUNION -#endif -#ifdef _MSC_VER -#pragma warning(disable : 4201) -#endif -#include -#if (defined (DIRECTDRAW_VERSION) && (DIRECTDRAW_VERSION >= 0x0700)) -#undef DUMMYUNIONNAMEN -#endif -// format of function in app called with width,height -typedef BOOL (*APPENUMMODESCALLBACK)(int width, int height, int bpp); - - -// globals -extern IDirectDraw2* DDr2; -extern IDirectDrawSurface* ScreenReal; -extern IDirectDrawSurface* ScreenVirtual; -extern IDirectDrawPalette* DDPalette; - -extern BOOL bAppFullScreen; // main code might need this to know the current - // fullscreen or windowed state - -extern int windowPosX; // current position in windowed mode -extern int windowPosY; - -extern int ScreenWidth; -extern int ScreenHeight; -extern BOOL ScreenLocked; // Screen surface is being locked -extern int ScreenPitch; // offset from one line to the next -extern LPBYTE ScreenPtr; // memory of the surface - -extern BOOL bDX0300; - -BOOL EnumDirectDrawDisplayModes (APPENUMMODESCALLBACK appFunc); -BOOL CreateDirectDrawInstance (VOID); - -int InitDirectDrawe (HWND appWin, int width, int height, int bpp, int fullScr); -VOID CloseDirectDraw (VOID); - -VOID ReleaseChtuff (VOID); - -VOID ClearSurface (IDirectDrawSurface* surface, int color); -BOOL ScreenFlip (int wait); -VOID TextPrint (int x, int y, LPCSTR message); - -VOID CreateDDPalette (PALETTEENTRY* colorTable); -VOID DestroyDDPalette (VOID); -VOID SetDDPalette (PALETTEENTRY* pal); - -VOID WaitVbl (VOID); - -boolean LockScreen (VOID); -VOID UnlockScreen (VOID); - - -#endif /* _H_FABDXLIB_ */ diff --git a/src/win32ce/midstuff.h b/src/win32ce/midstuff.h deleted file mode 100644 index 08ee80add..000000000 --- a/src/win32ce/midstuff.h +++ /dev/null @@ -1,150 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief MIDI structures and definitions -/// used by the MSTREAM sample application in -/// converting a MID file to a MIDI stream for -/// playback using the midiStream API. -/// Inpired by DirectX5 SDK examples - -#ifndef __MIDSTUFF_H__ -#define __MIDSTUFF_H__ - -// MIDI file constants -// -#define MThd 0x6468544D // Start of file -#define MTrk 0x6B72544D // Start of track - -#define MIDI_SYSEX ((BYTE)0xF0) // SysEx begin -#define MIDI_SYSEXEND ((BYTE)0xF7) // SysEx begin -#define MIDI_META ((BYTE)0xFF) // Meta event begin -#define MIDI_META_TEMPO ((BYTE)0x51) // Tempo change -#define MIDI_META_EOT ((BYTE)0x2F) // End-of-track - -#define MIDI_NOTEOFF ((BYTE)0x80) // + note + velocity -#define MIDI_NOTEON ((BYTE)0x90) // + note + velocity -#define MIDI_POLYPRESS ((BYTE)0xA0) // + pressure (2 bytes) -#define MIDI_CTRLCHANGE ((BYTE)0xB0) // + ctrlr + value -#define MIDI_PRGMCHANGE ((BYTE)0xC0) // + new patch -#define MIDI_CHANPRESS ((BYTE)0xD0) // + pressure (1 byte) -#define MIDI_PITCHBEND ((BYTE)0xE0) // + pitch bend (2 bytes) - -#define NUM_CHANNELS 16 - -#define MIDICTRL_VOLUME ((BYTE)0x07) -#define MIDICTRL_VOLUME_LSB ((BYTE)0x27) -#define MIDICTRL_PAN ((BYTE)0x0A) - -#define MIDIEVENT_CHANNEL(dw) (dw & 0x0000000F) -#define MIDIEVENT_TYPE(dw) (dw & 0x000000F0) -#define MIDIEVENT_DATA1(dw) ((dw & 0x0000FF00) >> 8) -#define MIDIEVENT_VOLUME(dw) ((dw & 0x007F0000) >> 16) - -// Macros for swapping hi/lo-endian data -// -#define WORDSWAP(w) (((w) >> 8) | \ - (((w) << 8) & 0xFF00)) - -#define DWORDSWAP(dw) (((dw) >> 24) | \ - (((dw) >> 8) & 0x0000FF00) | \ - (((dw) << 8) & 0x00FF0000) | \ - (((dw) << 24) & 0xFF000000)) - -// In debug builds, TRACKERR will show us where the parser died -// -//#define TRACKERR(p,sz) ShowTrackError(p,sz); -#define TRACKERR(p,sz) - - -// Make a little distinction here so the various structure members are a bit -// more clearly labelled -- we have offsets and byte counts to keep track of -// that deal with both in-memory buffers and the file on disk - -#define FILEOFF DWORD - - -// These structures are stored in MIDI files; they need to be byte aligned. -// -#if defined(_MSC_VER) -#pragma pack(1) -#endif - -// Chunk header. dwTag is either MTrk or MThd. -// -typedef struct -{ - DWORD dwTag; // Type - DWORD dwChunkLength; // Length (hi-lo) -} ATTRPACK MIDICHUNK; - -// Contents of MThd chunk. -typedef struct -{ - WORD wFormat; // Format (hi-lo) - WORD wTrackCount; // # tracks (hi-lo) - WORD wTimeDivision; // Time division (hi-lo) -} ATTRPACK MIDIFILEHDR; - -#if defined(_MSC_VER) -#pragma pack() // End of need for byte-aligned structures -#endif - - -// Temporary event structure which stores event data until we're ready to -// dump it into a stream buffer -// -typedef struct -{ - DWORD tkEvent; // Absolute time of event - BYTE byShortData[4]; // Event type and parameters if channel msg - DWORD dwEventLength; // Length of data which follows if meta or sysex - LPBYTE pLongData; // -> Event data if applicable -} TEMPEVENT, *PTEMPEVENT; - -#define ITS_F_ENDOFTRK 0x00000001 - -// Description of a track open for read -// -typedef struct -{ - DWORD fdwTrack; // Track status - DWORD dwTrackLength; // Total bytes in track - DWORD dwLeftInBuffer; // Bytes left unread in track buffer - LPBYTE pTrackStart; // -> start of track data buffer - LPBYTE pTrackCurrent; // -> next byte to read in buffer - DWORD tkNextEventDue; // Absolute time of next event in track - BYTE byRunningStatus;// Running status from last channel msg - - FILEOFF foTrackStart; // Start of track -- used for walking the file - FILEOFF foNextReadStart;// File offset of next read from disk - DWORD dwLeftOnDisk; // Bytes left unread on disk -#ifdef DEBUG - DWORD nTrack; // # of this track for debugging -#endif -} INTRACKSTATE, *PINTRACKSTATE; - -// Description of the input MIDI file -// -typedef struct -{ - DWORD cbFileLength; // Total bytes in file - DWORD dwTimeDivision; // Original time division - DWORD dwFormat; // Original format - DWORD dwTrackCount; // Track count (specifies pitsTracks size) - INTRACKSTATE *pitsTracks; // -> array of tracks in this file -} INFILESTATE, *PINFILESTATE; - -#endif //__MIDSTUFF_H__ diff --git a/src/win32ce/resource.h b/src/win32ce/resource.h deleted file mode 100644 index a712f14d6..000000000 --- a/src/win32ce/resource.h +++ /dev/null @@ -1,18 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by Srb2win.rc -// -#define IDI_DLICON1 101 -#define IDC_DLCURSOR1 103 -#define IDI_ICON1 106 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 114 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/src/win32ce/win_cd.c b/src/win32ce/win_cd.c deleted file mode 100644 index 940f59ff2..000000000 --- a/src/win32ce/win_cd.c +++ /dev/null @@ -1,529 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief cd music interface (uses MCI). - -#include "../doomdef.h" -#include "win_main.h" -#include - -#include "../command.h" -#include "../doomtype.h" -#include "../i_sound.h" -#include "../i_system.h" - -#include "../s_sound.h" - -#define MAX_CD_TRACKS 255 - -typedef struct { - BOOL IsAudio; - DWORD Start, End; - DWORD Length; // minutes -} CDTrack; - -// ------- -// private -// ------- -static CDTrack m_nTracks[MAX_CD_TRACKS]; -static int m_nTracksCount; // up to MAX_CD_TRACKS -static MCI_STATUS_PARMS m_MCIStatus; -static MCI_OPEN_PARMS m_MCIOpen; - -// ------ -// protos -// ------ -static void Command_Cd_f (void); - - -// ------------------- -// MCIErrorMessageBox -// Retrieve error message corresponding to return value from -// mciSendCommand() or mciSenString() -// ------------------- -static VOID MCIErrorMessageBox (MCIERROR iErrorCode) -{ - char szErrorText[128]; - if (!mciGetErrorStringA (iErrorCode, szErrorText, sizeof (szErrorText))) - wsprintfA(szErrorText,"MCI CD Audio Unknow Error #%d\n", iErrorCode); - CONS_Printf (szErrorText); - /*MessageBox (GetActiveWindow(), szTemp+1, "LEGACY", - MB_OK | MB_ICONSTOP);*/ -} - - -// -------- -// CD_Reset -// -------- -static void CD_Reset (void) -{ - // no win32 equivalent - //faB: for DOS, some odd drivers like to be reset sometimes.. useless in MCI I guess -} - - -// ---------------- -// CD_ReadTrackInfo -// Read in number of tracks, and length of each track in minutes/seconds -// returns true if error -// ---------------- -static BOOL CD_ReadTrackInfo (void) -{ - int i; - int nTrackLength; - MCIERROR iErr; - - m_nTracksCount = 0; - - m_MCIStatus.dwItem = MCI_STATUS_NUMBER_OF_TRACKS; - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM|MCI_WAIT, (DWORD_PTR)&m_MCIStatus); - if (iErr) - { - MCIErrorMessageBox (iErr); - return FALSE; - } - m_nTracksCount = (int)m_MCIStatus.dwReturn; - if (m_nTracksCount > MAX_CD_TRACKS) - m_nTracksCount = MAX_CD_TRACKS; - - for (i = 0; i < m_nTracksCount; i++) - { - m_MCIStatus.dwTrack = (DWORD)(i+1); - m_MCIStatus.dwItem = MCI_STATUS_LENGTH; - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_STATUS, MCI_TRACK|MCI_STATUS_ITEM|MCI_WAIT, (DWORD_PTR)&m_MCIStatus); - if (iErr) - { - MCIErrorMessageBox (iErr); - return FALSE; - } - nTrackLength = (DWORD)(MCI_MSF_MINUTE(m_MCIStatus.dwReturn)*60 + MCI_MSF_SECOND(m_MCIStatus.dwReturn)); - m_nTracks[i].Length = nTrackLength; - - m_MCIStatus.dwItem = MCI_CDA_STATUS_TYPE_TRACK; - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_STATUS, MCI_TRACK|MCI_STATUS_ITEM|MCI_WAIT, (DWORD_PTR)&m_MCIStatus); - if (iErr) - { - MCIErrorMessageBox (iErr); - return FALSE; - } - m_nTracks[i].IsAudio = (m_MCIStatus.dwReturn == MCI_CDA_TRACK_AUDIO); - } - - return TRUE; -} - - -// ------------ -// CD_TotalTime -// returns total time for all audio tracks in seconds -// ------------ -static int CD_TotalTime (void) -{ - int nTotalLength = 0; - int nTrack; - for (nTrack = 0; nTrack < m_nTracksCount; nTrack++) - { - if (m_nTracks[nTrack].IsAudio) - nTotalLength = nTotalLength + m_nTracks[nTrack].Length; - } - return nTotalLength; -} - - -//====================================================================== -// CD AUDIO MUSIC SUBSYSTEM -//====================================================================== - -UINT8 cdaudio_started = 0; // for system startup/shutdown - -static boolean cdPlaying = false; -static int cdPlayTrack; // when cdPlaying is true -static boolean cdLooping = false; -static UINT8 cdRemap[MAX_CD_TRACKS]; -static boolean cdEnabled = true; // cd info available -static boolean cdValid; // true when last cd audio info was ok -static boolean wasPlaying; -//static int cdVolume = 0; // current cd volume (0-31) - -// 0-31 like Music & Sfx, though CD hardware volume is 0-255. -consvar_t cd_volume = {"cd_volume","18",CV_SAVE,soundvolume_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; - -// allow Update for next/loop track -// some crap cd drivers take up to -// a second for a simple 'busy' check.. -// (on those Update can be disabled) -consvar_t cdUpdate = {"cd_update","1",CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; - -// hour,minutes,seconds -static char *hms(int seconds) -{ - int hours, minutes; - static char s[9]; - - minutes = seconds / 60; - seconds %= 60; - hours = minutes / 60; - minutes %= 60; - if (hours > 0) - sprintf (s, "%d:%02d:%02d", hours, minutes, seconds); - else - sprintf (s, "%2d:%02d", minutes, seconds); - return s; -} - -static void Command_Cd_f (void) -{ - LPCSTR s; - int i,j; - - if (!cdaudio_started) - return; - - if (COM_Argc()<2) - { - CONS_Printf ("cd [on] [off] [remap] [reset] [open]\n" - " [info] [play ] [loop ]\n" - " [stop] [resume]\n"); - return; - } - - s = COM_Argv(1); - - // activate cd music - if (!strncmp(s,"on",2)) - { - cdEnabled = true; - return; - } - - // stop/deactivate cd music - if (!strncmp(s,"off",3)) - { - if (cdPlaying) - I_StopCD (); - cdEnabled = false; - return; - } - - // remap tracks - if (!strncmp(s,"remap",5)) - { - i = (int)COM_Argc() - 2; - if (i <= 0) - { - CONS_Printf ("CD tracks remapped in that order :\n"); - for (j = 1; j < MAX_CD_TRACKS; j++) - if (cdRemap[j] != j) - CONS_Printf (" %2d -> %2d\n", j, cdRemap[j]); - return; - } - for (j = 1; j <= i; j++) - cdRemap[j] = (UINT8)atoi (COM_Argv (j+1)); - return; - } - - // reset the CD driver, useful on some odd cd's - if (!strncmp(s,"reset",5)) - { - cdEnabled = true; - if (cdPlaying) - I_StopCD (); - for (i = 0; i < MAX_CD_TRACKS; i++) - cdRemap[i] = (UINT8)i; - CD_Reset(); - cdValid = CD_ReadTrackInfo(); - return; - } - - // any other command is not allowed until we could retrieve cd information - if (!cdValid) - { - CONS_Printf ("CD is not ready.\n"); - return; - } - - /* faB: not with MCI, didn't find it, useless anyway - if (!strncmp(s,"open",4)) - { - if (cdPlaying) - I_StopCD (); - bcd_open_door(); - cdValid = false; - return; - }*/ - - if (!strncmp(s,"info",4)) - { - if (!CD_ReadTrackInfo()) - { - cdValid = false; - return; - } - - cdValid = true; - - if (m_nTracksCount <= 0) - CONS_Printf ("No audio tracks\n"); - else - { - // display list of tracks - // highlight current playing track - for (i = 0; i < m_nTracksCount; i++) - { - CONS_Printf("%s%2d. %s %s\n", - cdPlaying && (cdPlayTrack == i) ? "\2 " : " ", - i+1, m_nTracks[i].IsAudio ? "audio" : "data ", - hms(m_nTracks[i].Length)); - } - CONS_Printf ("\2Total time : %s\n", hms(CD_TotalTime())); - } - if (cdPlaying) - { - CONS_Printf ("%s track : %d\n", cdLooping ? "looping" : "playing", - cdPlayTrack); - } - return; - } - - if (!strncmp(s,"play",4)) - { - I_PlayCD ((UINT8)atoi(COM_Argv (2)), false); - return; - } - - if (!strncmp(s,"stop",4)) - { - I_StopCD (); - return; - } - - if (!strncmp(s,"loop",4)) - { - I_PlayCD ((UINT8)atoi(COM_Argv (2)), true); - return; - } - - if (!strncmp(s,"resume",4)) - { - I_ResumeCD (); - return; - } - - CONS_Printf ("cd command '%s' unknown\n", s); -} - - -// ------------ -// I_ShutdownCD -// Shutdown CD Audio subsystem, release whatever was allocated -// ------------ -void I_ShutdownCD (void) -{ - MCIERROR iErr; - - if (!cdaudio_started) - return; - - CONS_Printf("I_ShutdownCD()\n"); - - I_StopCD(); - - // closes MCI CD - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_CLOSE, 0, 0); - if (iErr) - MCIErrorMessageBox (iErr); -} - - -// -------- -// I_InitCD -// Init CD Audio subsystem -// -------- -void I_InitCD (void) -{ - MCI_SET_PARMS mciSet; - MCIERROR iErr; - int i; - - // We don't have an open device yet - m_MCIOpen.wDeviceID = 0; - m_nTracksCount = 0; - - cdaudio_started = false; - - m_MCIOpen.lpstrDeviceType = (LPCTSTR)MCI_DEVTYPE_CD_AUDIO; - iErr = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID, (DWORD_PTR)&m_MCIOpen); - if (iErr) - { - MCIErrorMessageBox (iErr); - return; - } - - // Set the time format to track/minute/second/frame (TMSF). - mciSet.dwTimeFormat = MCI_FORMAT_TMSF; - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_SET, MCI_SET_TIME_FORMAT, (DWORD_PTR)&mciSet); - if (iErr) - { - MCIErrorMessageBox (iErr); - mciSendCommand(m_MCIOpen.wDeviceID, MCI_CLOSE, 0, 0); - return; - } - - I_AddExitFunc (I_ShutdownCD); - cdaudio_started = true; - - CONS_Printf("I_InitCD: Init CD audio\n"); - - // last saved in config.cfg - i = cd_volume.value; - //I_SetVolumeCD (0); // initialize to 0 for some odd cd drivers - I_SetVolumeCD (i); // now set the last saved volume - - for (i = 0; i < MAX_CD_TRACKS; i++) - cdRemap[i] = (UINT8)i; - - if (!CD_ReadTrackInfo()) - { - CONS_Printf("\2I_InitCD: no CD in player.\n"); - cdEnabled = false; - cdValid = false; - } - else - { - cdEnabled = true; - cdValid = true; - } - - COM_AddCommand ("cd", Command_Cd_f); -} - - - -// loop/go to next track when track is finished (if cd_update var is true) -// update the volume when it has changed (from console/menu) -void I_UpdateCD (void) -{ - /// \todo check for cd change and restart music ? -} - - -// -void I_PlayCD (UINT8 nTrack, UINT8 bLooping) -{ - MCI_PLAY_PARMS mciPlay; - MCIERROR iErr; - - if (!cdaudio_started || !cdEnabled) - return; - - //faB: try again if it didn't work (just free the user of typing 'cd reset' command) - if (!cdValid) - cdValid = CD_ReadTrackInfo(); - if (!cdValid) - return; - - // tracks start at 0 in the code.. - nTrack--; - if (nTrack < 0 || nTrack >= m_nTracksCount) - nTrack = nTrack % m_nTracksCount; - - nTrack = cdRemap[nTrack]; - - if (cdPlaying) - { - if (cdPlayTrack == nTrack) - return; - I_StopCD (); - } - - cdPlayTrack = nTrack; - - if (!m_nTracks[nTrack].IsAudio) - { - //CONS_Printf ("\2CD Play: not an audio track\n"); // Tails 03-25-2001 - return; - } - - cdLooping = bLooping; - - //faB: stop MIDI music, MIDI music will restart if volume is upped later - cv_digmusicvolume.value = 0; - cv_midimusicvolume.value = 0; - I_StopSong (0); - - //faB: I don't use the notify message, I'm trying to minimize the delay - mciPlay.dwCallback = (DWORD_PTR)((size_t)hWndMain); - mciPlay.dwFrom = MCI_MAKE_TMSF(nTrack+1, 0, 0, 0); - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_PLAY, MCI_FROM|MCI_NOTIFY, (DWORD_PTR)&mciPlay); - if (iErr) - { - MCIErrorMessageBox (iErr); - cdValid = false; - cdPlaying = false; - return; - } - - cdPlaying = true; -} - - -// pause cd music -void I_StopCD (void) -{ - MCIERROR iErr; - - if (!cdaudio_started || !cdEnabled) - return; - - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_PAUSE, MCI_WAIT, 0); - if (iErr) - MCIErrorMessageBox (iErr); - else - { - wasPlaying = cdPlaying; - cdPlaying = false; - } -} - - -// continue after a pause -void I_ResumeCD (void) -{ - MCIERROR iErr; - - if (!cdaudio_started || !cdEnabled) - return; - - if (!cdValid) - return; - - if (!wasPlaying) - return; - - iErr = mciSendCommand(m_MCIOpen.wDeviceID, MCI_RESUME, MCI_WAIT, 0); - if (iErr) - MCIErrorMessageBox (iErr); - else - cdPlaying = true; -} - - -// volume : logical cd audio volume 0-31 (hardware is 0-255) -int I_SetVolumeCD (int volume) -{ - (void)volume; - return 1; -} diff --git a/src/win32ce/win_dbg.c b/src/win32ce/win_dbg.c deleted file mode 100644 index 9cfe77636..000000000 --- a/src/win32ce/win_dbg.c +++ /dev/null @@ -1,629 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Sources from GameDeveloper magazine article, January 1998, by Bruce Dawson. -/// this source file contains the exception handler for recording error -/// information after crashes. - -#include -#include "win_main.h" -#include "../doomdef.h" //just for VERSION -#include "win_dbg.h" -#include "../m_argv.h" //print the parameter in the log - - -#define NumCodeBytes 16 // Number of code bytes to record. -#define MaxStackDump 2048 // Maximum number of DWORDS in stack dumps. -#define StackColumns 8 // Number of columns in stack dump. - -#define ONEK 1024 -#define SIXTYFOURK (64*ONEK) -#define ONEM (ONEK*ONEK) -#define ONEG (ONEK*ONEK*ONEK) - - -// -------------------------------------------------------------------------- -// return a description for an ExceptionCode -// -------------------------------------------------------------------------- -static LPCSTR GetExceptionDescription (DWORD ExceptionCode) -{ - unsigned int i; - - struct ExceptionNames - { - DWORD ExceptionCode; - LPCSTR ExceptionName; - }; - - struct ExceptionNames ExceptionMap[] = - { - {EXCEPTION_ACCESS_VIOLATION, "an Access Violation"}, - {EXCEPTION_ARRAY_BOUNDS_EXCEEDED, "a Array Bounds Exceeded"}, - {EXCEPTION_BREAKPOINT, "a Breakpoint"}, - {EXCEPTION_DATATYPE_MISALIGNMENT, "a Datatype Misalignment"}, - {EXCEPTION_FLT_DENORMAL_OPERAND, "a Float Denormal Operand"}, - {EXCEPTION_FLT_DIVIDE_BY_ZERO, "a Float Divide By Zero"}, - {EXCEPTION_FLT_INEXACT_RESULT, "a Float Inexact Result"}, - {EXCEPTION_FLT_INVALID_OPERATION, "a Float Invalid Operation"}, - {EXCEPTION_FLT_OVERFLOW, "a Float Overflow"}, - {EXCEPTION_FLT_STACK_CHECK, "a Float Stack Check"}, - {EXCEPTION_FLT_UNDERFLOW, "a Float Underflow"}, - {EXCEPTION_ILLEGAL_INSTRUCTION, "an Illegal Instruction"}, - {EXCEPTION_IN_PAGE_ERROR, "an In Page Error"}, - {EXCEPTION_INT_DIVIDE_BY_ZERO, "an Integer Divide By Zero"}, - {EXCEPTION_INT_OVERFLOW, "an Integer Overflow"}, - {EXCEPTION_INVALID_DISPOSITION, "an Invalid Disposition"}, - {EXCEPTION_NONCONTINUABLE_EXCEPTION, "Noncontinuable Exception"}, - {EXCEPTION_PRIV_INSTRUCTION, "a Privileged Instruction"}, - {EXCEPTION_SINGLE_STEP, "a Single Step"}, - {EXCEPTION_STACK_OVERFLOW, "a Stack Overflow"}, - {0x40010005, "a Control-C"}, - {0x40010008, "a Control-Break"}, - {0xc0000006, "an In Page Error"}, - {0xc0000017, "a No Memory"}, - {0xc000001d, "an Illegal Instruction"}, - {0xc0000025, "a Noncontinuable Exception"}, - {0xc0000142, "a DLL Initialization Failed"}, - {0xe06d7363, "a Microsoft C++ Exception"}, - }; - - for (i = 0; i < (sizeof (ExceptionMap) / sizeof (ExceptionMap[0])); i++) - if (ExceptionCode == ExceptionMap[i].ExceptionCode) - return ExceptionMap[i].ExceptionName; - - return "Unknown exception type"; -} - - -// -------------------------------------------------------------------------- -// Directly output a formatted string to the errorlog file, using win32 funcs -// -------------------------------------------------------------------------- -static VOID FPrintf (HANDLE fileHandle, LPCSTR lpFmt, ...) -{ - CHAR str[1999]; - va_list arglist; - DWORD bytesWritten; - - va_start (arglist, lpFmt); - vsprintf (str, lpFmt, arglist); - va_end (arglist); - - WriteFile (fileHandle, str, (DWORD)strlen(str), &bytesWritten, NULL); -} - -// -------------------------------------------------------------------------- -// Print the specified FILETIME to output in a human readable format, -// without using the C run time. -// -------------------------------------------------------------------------- -static VOID PrintTime (LPSTR output, FILETIME TimeToPrint) -{ - WORD Date, Time; - if (FileTimeToLocalFileTime (&TimeToPrint, &TimeToPrint) && - FileTimeToDosDateTime (&TimeToPrint, &Date, &Time)) - { - // What a silly way to print out the file date/time. - wsprintfA(output, "%d/%d/%d %02d:%02d:%02d", - (Date / 32) & 15, Date & 31, (Date / 512) + 1980, - (Time / 2048), (Time / 32) & 63, (Time & 31) * 2); - } - else - output[0] = 0; -} - - -static LPTSTR GetFilePart(LPTSTR source) -{ - LPTSTR result = _tcsrchr(source, '\\'); - if (result) - result++; - else - result = source; - return result; -} - -// -------------------------------------------------------------------------- -// Print information about a code module (DLL or EXE) such as its size, -// location, time stamp, etc. -// -------------------------------------------------------------------------- -static VOID ShowModuleInfo(HANDLE LogFile, HMODULE ModuleHandle) -{ - CHAR ModName[MAX_PATH]; - IMAGE_DOS_HEADER *DosHeader; - IMAGE_NT_HEADERS *NTHeader; - HANDLE ModuleFile; - CHAR TimeBuffer[100] = ""; - DWORD FileSize = 0; -#ifdef NO_SEH_MINGW - __try1(EXCEPTION_EXECUTE_HANDLER) -#else - __try -#endif - { - if (GetModuleFileNameA(ModuleHandle, ModName, sizeof (ModName)) > 0) - { - // If GetModuleFileName returns greater than zero then this must - // be a valid code module address. Therefore we can try to walk - // our way through its structures to find the link time stamp. - DosHeader = (IMAGE_DOS_HEADER*)ModuleHandle; - if (IMAGE_DOS_SIGNATURE != DosHeader->e_magic) - return; - NTHeader = (IMAGE_NT_HEADERS*)((char *)DosHeader - + DosHeader->e_lfanew); - if (IMAGE_NT_SIGNATURE != NTHeader->Signature) - return; - // Open the code module file so that we can get its file date - // and size. - ModuleFile = CreateFileA(ModName, GENERIC_READ, - FILE_SHARE_READ, 0, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, 0); - if (ModuleFile != INVALID_HANDLE_VALUE) - { - FILETIME LastWriteTime; - FileSize = GetFileSize(ModuleFile, 0); - if (GetFileTime(ModuleFile, 0, 0, &LastWriteTime)) - { - wsprintfA(TimeBuffer, " - file date is "); - PrintTime(TimeBuffer + strlen(TimeBuffer), LastWriteTime); - } - CloseHandle(ModuleFile); - } - FPrintf (LogFile, "%s, loaded at 0x%08x - %d bytes - %08x%s\r\n", - ModName, ModuleHandle, FileSize, - NTHeader->FileHeader.TimeDateStamp, TimeBuffer); - } - } - // Handle any exceptions by continuing from this point. -#ifdef NO_SEH_MINGW - __except1 -#else - __except(EXCEPTION_EXECUTE_HANDLER) -#endif - { - } -} - -// -------------------------------------------------------------------------- -// Scan memory looking for code modules (DLLs or EXEs). VirtualQuery is used -// to find all the blocks of address space that were reserved or committed, -// and ShowModuleInfo will display module information if they are code -// modules. -// -------------------------------------------------------------------------- -static VOID RecordModuleList(HANDLE LogFile) -{ - SYSTEM_INFO SystemInfo; - size_t PageSize; - size_t NumPages; - size_t pageNum = 0; - LPVOID LastAllocationBase = 0; - - FPrintf (LogFile, "\r\n" - "\tModule list: names, addresses, sizes, time stamps " - "and file times:\r\n"); - - // Set NumPages to the number of pages in the 4GByte address space, - // while being careful to avoid overflowing ints. - GetSystemInfo(&SystemInfo); - PageSize = SystemInfo.dwPageSize; - NumPages = 4 * (unsigned int)(ONEG / PageSize); - while (pageNum < NumPages) - { - MEMORY_BASIC_INFORMATION MemInfo; - if (VirtualQuery((LPVOID)(pageNum * PageSize), &MemInfo, - sizeof (MemInfo))) - { - if (MemInfo.RegionSize > 0) - { - // Adjust the page number to skip over this block of memory. - pageNum += MemInfo.RegionSize / PageSize; - if (MemInfo.State == MEM_COMMIT && MemInfo.AllocationBase > - LastAllocationBase) - { - // Look for new blocks of committed memory, and try - // recording their module names - this will fail - // gracefully if they aren't code modules. - LastAllocationBase = MemInfo.AllocationBase; - ShowModuleInfo(LogFile, (HMODULE)LastAllocationBase); - } - } - else - pageNum += SIXTYFOURK / PageSize; - } - else - pageNum += SIXTYFOURK / PageSize; - // If VirtualQuery fails we advance by 64K because that is the - // granularity of address space doled out by VirtualAlloc(). - } -} - - -// -------------------------------------------------------------------------- -// Record information about the user's system, such as processor type, amount -// of memory, etc. -// -------------------------------------------------------------------------- -static VOID RecordSystemInformation(HANDLE fileHandle) -{ - FILETIME CurrentTime; - CHAR TimeBuffer[100]; - CHAR ModuleName[MAX_PATH]; - CHAR UserName[200]; - DWORD UserNameSize; - SYSTEM_INFO SystemInfo; - MEMORYSTATUS MemInfo; - - GetSystemTimeAsFileTime (&CurrentTime); - PrintTime (TimeBuffer, CurrentTime); - FPrintf(fileHandle, "Error occurred at %s.\r\n", TimeBuffer); - - if (GetModuleFileNameA(NULL, ModuleName, sizeof (ModuleName)) <= 0) - strcpy (ModuleName, "Unknown"); - UserNameSize = sizeof (UserName); - if (!GetUserNameA(UserName, &UserNameSize)) - strcpy (UserName, "Unknown"); - FPrintf(fileHandle, "%s, run by %s.\r\n", ModuleName, UserName); - - GetSystemInfo (&SystemInfo); - FPrintf (fileHandle, "%d processor(s), type %d %d.%d.\r\n" - "Program Memory from 0x%p to 0x%p\r\n", - SystemInfo.dwNumberOfProcessors, - SystemInfo.dwProcessorType, - SystemInfo.wProcessorLevel, - SystemInfo.wProcessorRevision, - SystemInfo.lpMinimumApplicationAddress, - SystemInfo.lpMaximumApplicationAddress); - - MemInfo.dwLength = sizeof (MemInfo); - GlobalMemoryStatus(&MemInfo); - // Print out the amount of physical memory, rounded up. - FPrintf(fileHandle, "%d MBytes physical memory.\r\n", (MemInfo.dwTotalPhys + - ONEM - 1) / ONEM); -} - -// -------------------------------------------------------------------------- -// What we do here is trivial : open a file, write out the register information -// from the PEXCEPTION_POINTERS structure, then return EXCEPTION_CONTINUE_SEARCH -// whose magic value tells Win32 to proceed with its normal error handling -// mechanism. This is important : an error dialog will popup if possible and -// the debugger will hopefully coexist peacefully with the structured exception -// handler. -// -------------------------------------------------------------------------- -int __cdecl RecordExceptionInfo (PEXCEPTION_POINTERS data/*, LPCSTR Message, LPSTR lpCmdLine*/) -{ - PEXCEPTION_RECORD Exception; - PCONTEXT Context; - TCHAR ModuleName[MAX_PATH]; - TCHAR FileName[MAX_PATH] = TEXT("Unknown"); - LPTSTR FilePart, lastperiod; - TCHAR CrashModulePathName[MAX_PATH]; - LPCTSTR CrashModuleFileName = TEXT("Unknown"); - MEMORY_BASIC_INFORMATION MemInfo; - static int BeenHere = false; - HANDLE fileHandle; - UINT8 *code; - int codebyte,i; - - if (data) - { - Exception = data->ExceptionRecord; - Context = data->ContextRecord; - } - else - { - return EXCEPTION_CONTINUE_SEARCH; - } - - if (BeenHere) // Going recursive! That must mean this routine crashed! - return EXCEPTION_CONTINUE_SEARCH; - BeenHere = true; - - // Create a filename to record the error information to. - // Store it in the executable directory. - if (GetModuleFileName(NULL, ModuleName, sizeof (ModuleName)) <= 0) - ModuleName[0] = 0; - FilePart = GetFilePart(ModuleName); - - // Extract the file name portion and remove it's file extension. We'll - // use that name shortly. - lstrcpy (FileName, FilePart); - lastperiod = _tcsrchr (FileName, '.'); - if (lastperiod) - lastperiod[0] = 0; - // Replace the executable filename with our error log file name. - lstrcpy (FilePart, TEXT("errorlog.txt")); - fileHandle = CreateFile (ModuleName, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL); - if (fileHandle == INVALID_HANDLE_VALUE) - { - OutputDebugString (TEXT("Error creating exception report")); - return EXCEPTION_CONTINUE_SEARCH; - } - - // Append to the error log. - SetFilePointer (fileHandle, 0, 0, FILE_END); - - // Print out some blank lines to separate this error log from any previous ones. - FPrintf (fileHandle, "Email Sonic Team Junior so we can fix the bugs\r\n"); // Tails - FPrintf (fileHandle, "Make sure you tell us what you were doing to cause the crash, and if possible, record a demo!\r\n"); // Tails - FPrintf (fileHandle, "\r\n\r\n\r\n\r\n"); - FPrintf (fileHandle, "SRB2 %s -ERROR LOG-\r\n\r\n", VERSIONSTRING); - FPrintf (fileHandle, "\r\n"); - // VirtualQuery can be used to get the allocation base associated with a - // code address, which is the same as the ModuleHandle. This can be used - // to get the filename of the module that the crash happened in. - if (VirtualQuery ((LPVOID)(size_t)Context->Eip, &MemInfo, sizeof (MemInfo)) && - GetModuleFileName ((HMODULE)MemInfo.AllocationBase, - CrashModulePathName, - sizeof (CrashModulePathName)) > 0) - CrashModuleFileName = GetFilePart(CrashModulePathName); - - // Print out the beginning of the error log in a Win95 error window - // compatible format. - FPrintf (fileHandle, "%s caused an %s in module %s at %04x:%08x.\r\n", - FileName, GetExceptionDescription(Exception->ExceptionCode), - CrashModuleFileName, Context->SegCs, Context->Eip); - //if (&Message = Null) - FPrintf (fileHandle, "Exception handler called in %s.\r\n", "main thread"); - //else - //FPrintf (fileHandle, "Exception handler called in %s.\r\n", Message); - - RecordSystemInformation (fileHandle); - - // If the exception was an access violation, print out some additional - // information, to the error log and the debugger. - if (Exception->ExceptionCode == STATUS_ACCESS_VIOLATION && - Exception->NumberParameters >= 2) - { - TCHAR DebugMessage[1000]; - LPCTSTR readwrite = TEXT("Read from"); - if (Exception->ExceptionInformation[0]) - readwrite = TEXT("Write to"); - wsprintf(DebugMessage, TEXT("%s location %08x caused an access violation.\r\n"), - readwrite, Exception->ExceptionInformation[1]); -#ifdef _DEBUG - // The VisualC++ debugger doesn't actually tell you whether a read - // or a write caused the access violation, nor does it tell what - // address was being read or written. So I fixed that. - OutputDebugString(TEXT("Exception handler: ")); - OutputDebugString(DebugMessage); -#endif - FPrintf(fileHandle, "%s", DebugMessage); - } - - FPrintf(fileHandle, "\r\n"); - - // Print out the register values in a Win95 error window compatible format. - if ((Context->ContextFlags & CONTEXT_FULL) == CONTEXT_FULL) - { - FPrintf (fileHandle, "Registers:\r\n"); - FPrintf (fileHandle, "EAX=%.8lx CS=%.4x EIP=%.8lx EFLGS=%.8lx\r\n", - Context->Eax,Context->SegCs,Context->Eip,Context->EFlags); - FPrintf (fileHandle, "EBX=%.8lx SS=%.4x ESP=%.8lx EBP=%.8lx\r\n", - Context->Ebx,Context->SegSs,Context->Esp,Context->Ebp); - FPrintf (fileHandle, "ECX=%.8lx DS=%.4x ESI=%.8lx FS=%.4x\r\n", - Context->Ecx,Context->SegDs,Context->Esi,Context->SegFs); - FPrintf (fileHandle, "EDX=%.8lx ES=%.4x EDI=%.8lx GS=%.4x\r\n", - Context->Edx,Context->SegEs,Context->Edi,Context->SegGs); - } - - // moved down because it was causing the printout to stop - FPrintf (fileHandle, "Command Line parameters: "); - for (i = 1;i < myargc;i++) - FPrintf (fileHandle, "%s ", myargv[i]); - - FPrintf (fileHandle, "Bytes at CS : EIP:\r\n"); - - // Print out the bytes of code at the instruction pointer. Since the - // crash may have been caused by an instruction pointer that was bad, - // this code needs to be wrapped in an exception handler, in case there - // is no memory to read. If the dereferencing of code[] fails, the - // exception handler will print '??'. - code = (UINT8 *)(size_t)Context->Eip; - for (codebyte = 0; codebyte < NumCodeBytes; codebyte++) - { -#ifdef NO_SEH_MINGW - __try1(EXCEPTION_EXECUTE_HANDLER) -#else - __try -#endif - { - FPrintf (fileHandle, "%02x ", code[codebyte]); - } -#ifdef NO_SEH_MINGW - __except1 -#else - __except(EXCEPTION_EXECUTE_HANDLER) -#endif - { - FPrintf (fileHandle, "?? "); - } - } - - // Time to print part or all of the stack to the error log. This allows - // us to figure out the call stack, parameters, local variables, etc. - FPrintf (fileHandle, "\r\n" - "Stack dump:\r\n"); -#ifdef NO_SEH_MINGW - __try1(EXCEPTION_EXECUTE_HANDLER) -#else - __try -#endif - { - // Esp contains the bottom of the stack, or at least the bottom of - // the currently used area. - DWORD* pStack = (DWORD *)(size_t)Context->Esp; - DWORD* pStackTop = NULL; - size_t Count = 0; - TCHAR buffer[1000] = TEXT(""); - const int safetyzone = 50; - LPTSTR nearend = buffer + sizeof (buffer) - safetyzone*sizeof (TCHAR); - LPTSTR output = buffer; - const void *Suffix; - - // Load the top (highest address) of the stack from the - // thread information block. It will be found there in - // Win9x and Windows NT. -#ifdef __GNUC__ - __asm__("movl %%fs : 4, %%eax": "=a"(pStackTop)); -#else - __asm - { - mov eax, fs:[4] - mov pStackTop, eax - } -#endif - if (pStackTop == NULL) - goto StackSkip; - else if (pStackTop > pStack + MaxStackDump) - pStackTop = pStack + MaxStackDump; - // Too many calls to WriteFile can take a long time, causing - // confusing delays when programs crash. Therefore I implemented - // simple buffering for the stack dumping code instead of calling - // FPrintf directly. - while (pStack + 1 <= pStackTop) - { - if ((Count % StackColumns) == 0) - output += wsprintf(output, TEXT("%08x: "), pStack); - if ((++Count % StackColumns) == 0 || pStack + 2 > pStackTop) - Suffix = TEXT("\r\n"); - else - Suffix = TEXT(" "); - output += wsprintf(output, TEXT("%08x%s"), *pStack, Suffix); - pStack++; - // Check for when the buffer is almost full, and flush it to disk. - if (output > nearend) - { - FPrintf (fileHandle, "%s", buffer); - buffer[0] = 0; - output = buffer; - } - } - // Print out any final characters from the cache. - StackSkip: - FPrintf (fileHandle, "%s", buffer); - } -#ifdef NO_SEH_MINGW - __except1 -#else - __except(EXCEPTION_EXECUTE_HANDLER) -#endif - { - FPrintf(fileHandle, "Exception encountered during stack dump.\r\n"); - } - - RecordModuleList (fileHandle); - - CloseHandle (fileHandle); - - // Return the magic value which tells Win32 that this handler didn't - // actually handle the exception - so that things will proceed as per - // normal. - //BP: should put message for end user to send this file to fix any bug - return EXCEPTION_CONTINUE_SEARCH; -} - - /* - // - //FPrintf ("e-mail this file to legacy@newdoom.com, so that we can fix the problem.\r\n\r\n"); - - FPrintf ("Exception handler called in %s.\r\n", Message); - - GetSystemTime (&systemTime); - FPrintf ("Error occured at %02d/%02d/%04d %02d:%02d:%02d.\r\n", - systemTime.wMonth, systemTime.wDay, systemTime.wYear, - systemTime.wHour, systemTime.wMinute, systemTime.wSecond); - - - FPrintf ("%s\r\n", filename); - FPrintf ("Cmd-line: %s\r\n", lpCmdLine); - - // Nested exceptions can occur, get info for each one - - nER = 1; - while (ER) - { - if (nER++>1) - FPrintf ("Exception Record %d.\r\n", nER); - - FPrintf ("application caused an %s", GetExceptionCodeStr(Exception->ExceptionCode)); - - if (Context->ContextFlags & CONTEXT_CONTROL) - FPrintf (" at %.4x:%.8x.\r\n", Context->SegCs, Context->Eip); - - // in case of.. - if (Context->Eip != (unsigned long)Exception->ExceptionAddress) - FPrintf ("Exception Address = %.8x\r\n", Exception->ExceptionAddress); - - if (Exception->ExceptionCode == EXCEPTION_ACCESS_VIOLATION) - { - FPrintf ("\r\n%s location 0x%x caused an access violation.\r\n", - (Exception->ExceptionInformation[0] ? "Write to" : "Read from"), - Exception->ExceptionInformation[1]); - } - - ER = Exception->ExceptionRecord; - } - - - if (Context->ContextFlags & CONTEXT_DEBUG_REGISTERS) - { - FPrintf ("\r\nDebug Registers:\r\n"); - FPrintf ("Dr0=%.8x Dr1=%.8x Dr2=%.8x\r\n" - "Dr3=%.8x Dr6=%.8x Dr7=%.8x\r\n", - Context->Dr0, Context->Dr1, Context->Dr2, - Context->Dr3, Context->Dr6, Context->Dr7); - } - - if (Context->ContextFlags & CONTEXT_FLOATING_POINT) - { - FPrintf ("\r\nFloating Save Area:\r\n"); - FPrintf ("ControlWord =%.8x TagWord =%.8x ErrorSelector=%.8x DataSelector =%.8x\r\n" - "StatusWord =%.8x ErrorOffset =%.8x DataOffset =%.8x Cr0NpxState =%.8x\r\n", - Context->FloatSave.ControlWord, Context->FloatSave.TagWord, Context->FloatSave.ErrorSelector, Context->FloatSave.DataSelector, - Context->FloatSave.StatusWord, Context->FloatSave.ErrorOffset, Context->FloatSave.DataOffset, Context->FloatSave.Cr0NpxState - ); - - //BYTE RegisterArea[SIZE_OF_80387_REGISTERS]; - } - - - // in case of... - if ((Context->ContextFlags & CONTEXT_FULL) != CONTEXT_FULL) - { - if (!(Context->ContextFlags & CONTEXT_SEGMENTS)) - FPrintf ("Note! GS,FS,ES,DS are unspecified\r\n"); - if (!(Context->ContextFlags & CONTEXT_INTEGER)) - FPrintf ("Note! EDI,ESI,EBX,EDX,ECX,EAX are unspecified\r\n"); - if (!(Context->ContextFlags & CONTEXT_CONTROL)) - FPrintf ("Note! EBP,CS : EIP,EFlags,SS : ESP are unspecified\r\n"); - } - - FPrintf ("\r\nBytes at CS : EIP:\r\n"); - ucptr = (UINT8 *)Context->Eip; - for (i = 0; i < 16; i++) - FPrintf ("%.2x ", *ucptr++); - - FPrintf ("\r\n\r\nStack dump:\r\n"); - ulptr = (unsigned long*)Context->Esp; - for (i = 0; i < 16; i++) - FPrintf ("%.8x ", *ulptr++); - - //FPrintf ("Bytes at CS : EIP:\r\n"); - //FPrintf ("%.2x %.2x %.2x %.2x %.2x %.2x %.2x %.2x "); - - for (i = 0; i < 16; i++) - { - FPrintf ("%x - } -*/ diff --git a/src/win32ce/win_dbg.h b/src/win32ce/win_dbg.h deleted file mode 100644 index acee896e6..000000000 --- a/src/win32ce/win_dbg.h +++ /dev/null @@ -1,54 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief exception handler - -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include - -// called in the exception filter of the __try block, writes all useful debugging information -// to a file, using only win32 functions in case the C runtime is in a bad state. -int __cdecl RecordExceptionInfo (PEXCEPTION_POINTERS data/*, LPCSTR Message, LPSTR lpCmdLine*/); - -#ifdef __MINGW32__ - -#include - -#ifndef TRYLEVEL_NONE - -#define NO_SEH_MINGW //Alam:? -FUNCINLINE static ATTRINLINE struct _EXCEPTION_POINTERS *GetExceptionInformation(VOID) -{ - LPVOID SEHINFO = NULL; - //__asm__("movl -20(%%ebp), %%eax": "=a"(SEHINFO)); - return SEHINFO; -} - -//Alam_GBC: use __try1(seh) -#ifndef __try -#define __try -#endif //__try - -//#undef NO_SEH_MINGW //Alam: win_dbg's code not working with MINGW -//Alam_GBC: use __except1 -#ifndef __except -#define __except(x) if (0) -#endif //__except - -#endif // !__TRYLEVEL_NONE - -#endif // __MINGW32__ diff --git a/src/win32ce/win_dll.c b/src/win32ce/win_dll.c deleted file mode 100644 index 8b88f84dd..000000000 --- a/src/win32ce/win_dll.c +++ /dev/null @@ -1,164 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief load and initialise the 3D driver DLL - -#include "../doomdef.h" -#ifdef HWRENDER -#include "../hardware/hw_drv.h" // get the standard 3D Driver DLL exports prototypes -#endif - -#ifdef HW3SOUND -#include "../hardware/hw3dsdrv.h" // get the 3D sound driver DLL export prototypes -#endif - -#include "win_dll.h" -#include "win_main.h" // I_GetLastErrorMsgBox() - -#if defined(HWRENDER) || defined(HW3SOUND) -typedef struct loadfunc_s { - LPCSTR fnName; - LPVOID fnPointer; -} loadfunc_t; - -// -------------------------------------------------------------------------- -// Load a DLL, returns the HMODULE handle or NULL -// -------------------------------------------------------------------------- -static inline HMODULE LoadDLL (LPCSTR dllName, loadfunc_t *funcTable) -{ - LPVOID funcPtr; - loadfunc_t *loadfunc; - HMODULE hModule; - - if ((hModule = LoadLibraryA(dllName)) != NULL) - { - // get function pointers for all functions we use - for (loadfunc = funcTable; loadfunc->fnName != NULL; loadfunc++) - { - funcPtr = GetProcAddress(hModule, loadfunc->fnName); - if (!funcPtr) { - //I_GetLastErrorMsgBox (); - MessageBoxA(NULL, va("The '%s' haven't the good specification (function %s missing)\n\n" - "You must use dll from the same zip of this exe\n", dllName, loadfunc->fnName), - "Error", MB_OK|MB_ICONINFORMATION); - return FALSE; - } - // store function address - *((LPVOID*)loadfunc->fnPointer) = funcPtr; - } - } - else - { - MessageBoxA(NULL, va("LoadLibrary() FAILED : couldn't load '%s'\r\n", dllName), "Warning", MB_OK|MB_ICONINFORMATION); - //I_GetLastErrorMsgBox (); - } - - return hModule; -} - - -// -------------------------------------------------------------------------- -// Unload the DLL -// -------------------------------------------------------------------------- -static inline VOID UnloadDLL (HMODULE* pModule) -{ - if (FreeLibrary(*pModule)) - *pModule = NULL; - else - I_GetLastErrorMsgBox (); -} -#endif - -// ========================================================================== -// STANDARD 3D DRIVER DLL FOR DOOM LEGACY -// ========================================================================== - -// note : the 3D driver loading should be put somewhere else.. - -#ifdef HWRENDER -static HMODULE hwdModule = NULL; - -static loadfunc_t hwdFuncTable[] = { - {"_Init@4", &hwdriver.pfnInit}, - {"_Shutdown@0", &hwdriver.pfnShutdown}, - {"_GetModeList@8", &hwdriver.pfnGetModeList}, - {"_SetPalette@8", &hwdriver.pfnSetPalette}, - {"_FinishUpdate@4", &hwdriver.pfnFinishUpdate}, - {"_Draw2DLine@12", &hwdriver.pfnDraw2DLine}, - {"_DrawPolygon@16", &hwdriver.pfnDrawPolygon}, - {"_SetBlend@4", &hwdriver.pfnSetBlend}, - {"_ClearBuffer@12", &hwdriver.pfnClearBuffer}, - {"_SetTexture@4", &hwdriver.pfnSetTexture}, - {"_ReadRect@24", &hwdriver.pfnReadRect}, - {"_GClipRect@20", &hwdriver.pfnGClipRect}, - {"_ClearMipMapCache@0",&hwdriver.pfnClearMipMapCache}, - {"_SetSpecialState@8", &hwdriver.pfnSetSpecialState}, - {"_DrawMD2@16", &hwdriver.pfnDrawMD2}, - {"_SetTransform@4", &hwdriver.pfnSetTransform}, - {"_GetTextureUsed@0", &hwdriver.pfnGetTextureUsed}, - {"_GetRenderVersion@0",&hwdriver.pfnGetRenderVersion}, - {NULL,NULL} -}; - -BOOL Init3DDriver (LPCSTR dllName) -{ - hwdModule = LoadDLL(dllName, hwdFuncTable); - return (hwdModule != NULL); -} - -VOID Shutdown3DDriver (VOID) -{ - UnloadDLL(&hwdModule); -} -#endif - -#ifdef HW3SOUND -static HMODULE hwsModule = NULL; - -static loadfunc_t hwsFuncTable[] = { - {"_Startup@8", &hw3ds_driver.pfnStartup}, - {"_Shutdown@0", &hw3ds_driver.pfnShutdown}, - {"_AddSfx@4", &hw3ds_driver.pfnAddSfx}, - {"_AddSource@8", &hw3ds_driver.pfnAddSource}, - {"_StartSource@4", &hw3ds_driver.pfnStartSource}, - {"_StopSource@4", &hw3ds_driver.pfnStopSource}, - {"_GetHW3DSVersion@0", &hw3ds_driver.pfnGetHW3DSVersion}, - {"_BeginFrameUpdate@0", &hw3ds_driver.pfnBeginFrameUpdate}, - {"_EndFrameUpdate@0", &hw3ds_driver.pfnEndFrameUpdate}, - {"_IsPlaying@4", &hw3ds_driver.pfnIsPlaying}, - {"_UpdateListener@8", &hw3ds_driver.pfnUpdateListener}, - {"_UpdateSourceParms@12", &hw3ds_driver.pfnUpdateSourceParms}, - {"_SetCone@8", &hw3ds_driver.pfnSetCone}, - {"_SetGlobalSfxVolume@4", &hw3ds_driver.pfnSetGlobalSfxVolume}, - {"_Update3DSource@8", &hw3ds_driver.pfnUpdate3DSource}, - {"_ReloadSource@8", &hw3ds_driver.pfnReloadSource}, - {"_KillSource@4", &hw3ds_driver.pfnKillSource}, - {"_KillSfx@4", &hw3ds_driver.pfnKillSfx}, - {"_GetHW3DSTitle@8", &hw3ds_driver.pfnGetHW3DSTitle}, - {NULL, NULL} -}; - -BOOL Init3DSDriver(LPCSTR dllName) -{ - hwsModule = LoadDLL(dllName, hwsFuncTable); - return (hwsModule != NULL); -} - -VOID Shutdown3DSDriver (VOID) -{ - UnloadDLL(&hwsModule); -} -#endif diff --git a/src/win32ce/win_dll.h b/src/win32ce/win_dll.h deleted file mode 100644 index b4b259587..000000000 --- a/src/win32ce/win_dll.h +++ /dev/null @@ -1,31 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief load/unload a DLL at run-time - -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include - -#ifdef HWRENDER -BOOL Init3DDriver (LPCSTR dllName); -VOID Shutdown3DDriver (VOID); -#endif - -#ifdef HW3SOUND -BOOL Init3DSDriver(LPCSTR dllName); -VOID Shutdown3DSDriver(VOID); -#endif diff --git a/src/win32ce/win_file.c b/src/win32ce/win_file.c deleted file mode 100644 index f9f621011..000000000 --- a/src/win32ce/win_file.c +++ /dev/null @@ -1,123 +0,0 @@ -#include -#include -#include "win_file.h" - - -int FileAccess(LPCTSTR FileName, DWORD mode) -{ - HANDLE hFile; - - hFile = CreateFile( FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - - if (hFile == INVALID_HANDLE_VALUE) - return -1; - else - { - FileClose(hFile); - return 0; - } -} - -HANDLE FileCreate(LPCTSTR FileName) -{ - HANDLE hFile; - - if (FileAccess( FileName, 0) == 0) - hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - else - hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); - - return hFile; -} - -void FileClose(HANDLE hFile) -{ - CloseHandle(hFile); -} - -DWORD FileLength(HANDLE hFile) -{ - return GetFileSize(hFile, NULL); -} - -HANDLE FileOpen(LPCTSTR FileName) -{ - HANDLE hFile; - - hFile = CreateFile( FileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - - return hFile; -} - -HANDLE FileAppend(LPCTSTR FileName) -{ - HANDLE hFile; - - hFile = CreateFile( FileName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - FileSeek(hFile, 0, FILE_END ); - - return hFile; -} - -DWORD FileRead(HANDLE hFile, LPVOID data, DWORD size) -{ - DWORD readin = 0; - - ReadFile(hFile, data, size, &readin, NULL); - - return readin; -} - -DWORD FileSeek(HANDLE hFile, LONG distance, DWORD method) -{ - DWORD position; - - position = SetFilePointer(hFile, distance, NULL, method); - - return position; -} - -DWORD FileWrite(HANDLE hFile, LPCVOID data, DWORD size) -{ - DWORD written = 0; - - WriteFile(hFile, data, size, &written, NULL); - - return written; -} - -//These functions are provided as CRT replacements. (missing from WinCE) - -int access(char* file,int type) -{ - FILE* file_access = 0; - - file_access = fopen(file,"rb"); - - if(file_access) - { - fclose(file_access); - return 0; - } - - return -1; -} - -unsigned int file_len(char* file) -{ - FILE* file_access; - unsigned int len = 0; - - file_access = fopen(file,"rb"); - - if(!file_access) - return 0; - - fseek(file_access,0,SEEK_END); - - len = ftell(file_access); - - fclose(file_access); - - return len; -} diff --git a/src/win32ce/win_file.h b/src/win32ce/win_file.h deleted file mode 100644 index d1dc5e9c7..000000000 --- a/src/win32ce/win_file.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef FILE_H -#define FILE_H - -// New File I/O functions - -int FileAccess(LPCTSTR, DWORD); -HANDLE FileAppend(LPCTSTR FileName); -void FileClose(HANDLE); -HANDLE FileCreate(LPCTSTR); -DWORD FileLength(HANDLE); -HANDLE FileOpen(LPCTSTR); -DWORD FileRead(HANDLE, LPCVOID, DWORD); -DWORD FileSeek(HANDLE hFile, LONG distance, DWORD method); -DWORD FileWrite(HANDLE, LPCVOID, DWORD); - -int access(char* file,int type); -unsigned int file_len(char* file); - -#endif \ No newline at end of file diff --git a/src/win32ce/win_main.c b/src/win32ce/win_main.c deleted file mode 100644 index a8a5c7cf2..000000000 --- a/src/win32ce/win_main.c +++ /dev/null @@ -1,539 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Win32 WinMain Entry Point -/// -/// Win32 Sonic Robo Blast 2 -/// -/// NOTE: -/// To compile WINDOWS SRB2 version : define a '_WINDOWS' symbol. -/// to do this go to Project/Settings/ menu, click C/C++ tab, in -/// 'Preprocessor definitions:' add '_WINDOWS' - -#include "../doomdef.h" -#include - -#include "../doomstat.h" // netgame -#include "resource.h" - -#include "../m_argv.h" -#include "../d_main.h" -#include "../i_system.h" - -#include "../keys.h" //hack quick test - -#include "../console.h" - -#include "fabdxlib.h" -#include "win_main.h" -#include "win_dbg.h" -#include "../i_sound.h" // midi pause/unpause -#include "../g_input.h" // KEY_MOUSEWHEELxxx - -// MSWheel support for Win95/NT3.51 -#include - -#ifndef WM_XBUTTONDOWN -#define WM_XBUTTONDOWN 523 -#endif -#ifndef WM_XBUTTONUP -#define WM_XBUTTONUP 524 -#endif -#ifndef MK_XBUTTON1 -#define MK_XBUTTON1 32 -#endif -#ifndef MK_XBUTTON2 -#define MK_XBUTTON2 64 -#endif - -typedef BOOL (WINAPI *MyFunc)(VOID); - -HINSTANCE myInstance = NULL; -HWND hWndMain = NULL; -static HCURSOR windowCursor = NULL; // main window cursor - -boolean appActive = false; // app window is active - -#ifdef LOGMESSAGES -// this is were I log debug text, cons_printf, I_error ect for window port debugging -HANDLE logstream; -#endif - -BOOL nodinput = FALSE; - -static LRESULT CALLBACK MainWndproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - event_t ev; //Doom input event - int mouse_keys; - - // judgecutor: - // Response MSH Mouse Wheel event - - if (message == MSHWheelMessage) - { - message = WM_MOUSEWHEEL; - if (win9x) - wParam <<= 16; - } - - - switch (message) - { - case WM_CREATE: - nodinput = M_CheckParm("-nodinput"); - break; - - case WM_ACTIVATEAPP: // Handle task switching - appActive = (int)wParam; - // pause music when alt-tab - if (appActive && !paused) - I_ResumeSong(0); - else if (!paused) - I_PauseSong(0); - { - HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); - if (ci != INVALID_HANDLE_VALUE && GetFileType(ci) == FILE_TYPE_CHAR) - appActive = true; - } - InvalidateRect (hWnd, NULL, TRUE); - break; - - //for MIDI music - case WM_MSTREAM_UPDATEVOLUME: - I_SetMidiChannelVolume((DWORD)wParam, dwVolumePercent); - break; - - case WM_PAINT: - if (!appActive && !bAppFullScreen && !netgame) - // app becomes inactive (if windowed) - { - // Paint "Game Paused" in the middle of the screen - PAINTSTRUCT ps; - RECT rect; - HDC hdc = BeginPaint (hWnd, &ps); - GetClientRect (hWnd, &rect); - DrawText (hdc, TEXT("Game Paused"), -1, &rect, - DT_SINGLELINE | DT_CENTER | DT_VCENTER); - EndPaint (hWnd, &ps); - return 0; - } - break; - - //case WM_RBUTTONDOWN: - //case WM_LBUTTONDOWN: - - case WM_MOVE: - if (bAppFullScreen) - { - SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - return 0; - } - else - { - windowPosX = (SHORT) LOWORD(lParam); // horizontal position - windowPosY = (SHORT) HIWORD(lParam); // vertical position - break; - } - break; - - // This is where switching windowed/fullscreen is handled. DirectDraw - // objects must be destroyed, recreated, and artwork reloaded. - - case WM_DISPLAYCHANGE: - case WM_SIZE: - break; - - case WM_SETCURSOR: - if (bAppFullScreen) - SetCursor(NULL); - else - SetCursor(windowCursor); - return TRUE; - - case WM_KEYUP: - ev.type = ev_keyup; - goto handleKeyDoom; - break; - - case WM_KEYDOWN: - ev.type = ev_keydown; - - handleKeyDoom: - ev.data1 = 0; - if (wParam == VK_PAUSE) - // intercept PAUSE key - { - ev.data1 = KEY_PAUSE; - } - else if (!keyboard_started) - // post some keys during the game startup - // (allow escaping from network synchronization, or pressing enter after - // an error message in the console) - { - switch (wParam) - { - case VK_ESCAPE: ev.data1 = KEY_ESCAPE; break; - case VK_RETURN: ev.data1 = KEY_ENTER; break; - default: ev.data1 = MapVirtualKey((DWORD)wParam,2); // convert in to char - } - } - - if (ev.data1) - D_PostEvent (&ev); - - return 0; - break; - - // judgecutor: - // Handle mouse events - case WM_LBUTTONDOWN: - case WM_LBUTTONUP: - case WM_RBUTTONDOWN: - case WM_RBUTTONUP: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - case WM_XBUTTONDOWN: - case WM_XBUTTONUP: - case WM_MOUSEMOVE: - if (nodinput) - { - mouse_keys = 0; - if (wParam & MK_LBUTTON) - mouse_keys |= 1; - if (wParam & MK_RBUTTON) - mouse_keys |= 2; - if (wParam & MK_MBUTTON) - mouse_keys |= 4; - if (wParam & MK_XBUTTON1) - mouse_keys |= 8; - if (wParam & MK_XBUTTON2) - mouse_keys |= 16; - I_GetSysMouseEvents(mouse_keys); - } - break; - - - case WM_MOUSEWHEEL: - //CONS_Printf("MW_WHEEL dispatched.\n"); - ev.type = ev_keydown; - if ((INT16)HIWORD(wParam) > 0) - ev.data1 = KEY_MOUSEWHEELUP; - else - ev.data1 = KEY_MOUSEWHEELDOWN; - D_PostEvent(&ev); - break; - - case WM_SETTEXT: - COM_BufAddText((LPCSTR)lParam); - return TRUE; - break; - - case WM_CLOSE: - PostQuitMessage(0); //to quit while in-game - ev.data1 = KEY_ESCAPE; //to exit network synchronization - ev.type = ev_keydown; - D_PostEvent (&ev); - return 0; - case WM_DESTROY: - //faB: main app loop will exit the loop and proceed with I_Quit() - PostQuitMessage(0); - break; - - default: - break; - } - - return DefWindowProc(hWnd, message, wParam, lParam); -} - - -static inline VOID OpenTextConsole(void) -{ - HANDLE ci, co; - const BOOL tco = M_CheckParm("-console") != 0; - dedicated = M_CheckParm("-dedicated") != 0; - if (!(dedicated || tco)) - return; - FreeConsole(); - AllocConsole(); //Let get the real console HANDLE, because Mingw's Bash is bad! - ci = CreateFile(TEXT("CONIN$") , GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - co = CreateFile(TEXT("CONOUT$"), GENERIC_WRITE|GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (ci != (HANDLE)-1) - { - const DWORD CM = ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_INPUT; - SetStdHandle(STD_INPUT_HANDLE,ci); - if(GetFileType(ci) == FILE_TYPE_CHAR) - SetConsoleMode(ci,CM); //default mode but no ENABLE_MOUSE_INPUT - } - if(co != (HANDLE)-1) - { - SetStdHandle(STD_OUTPUT_HANDLE,co); - SetStdHandle(STD_ERROR_HANDLE,co); //maybe logstream? - } -} - -// -// Do that Windows initialization stuff... -// -static HWND OpenMainWindow (HINSTANCE hInstance, int nCmdShow, LPSTR wTitle) -{ - HWND hWnd; - WNDCLASS wc; - - // Set up and register window class - nCmdShow = 0; - wc.style = CS_HREDRAW | CS_VREDRAW /*| CS_DBLCLKS*/; - wc.lpfnWndProc = MainWndproc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_DLICON1)); - windowCursor = LoadCursor(NULL, IDC_WAIT); //LoadCursor(hInstance, MAKEINTRESOURCE(IDC_DLCURSOR1)); - wc.hCursor = windowCursor; - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszMenuName = NULL; - wc.lpszClassName = TEXT("SRB2WC"); - if (!RegisterClass(&wc)) - return (HANDLE)-1; - - // Create a window - // CreateWindowEx - seems to create just the interior, not the borders - - hWnd = CreateWindowExA( -#ifdef _DEBUG - 0, //ExStyle -#else - dedicated ? 0:WS_EX_TOPMOST, //ExStyle -#endif - "SRB2WC", //Classname - wTitle, //Windowname - WS_CAPTION|WS_POPUP|WS_SYSMENU, //dwStyle //WS_VISIBLE|WS_POPUP for bAppFullScreen - 0, - 0, - dedicated ? 0:BASEVIDWIDTH, //GetSystemMetrics(SM_CXSCREEN), - dedicated ? 0:BASEVIDHEIGHT, //GetSystemMetrics(SM_CYSCREEN), - NULL, //hWnd Parent - NULL, //hMenu Menu - hInstance, - NULL); - - return hWnd; -} - - -static inline BOOL tlErrorMessage(const TCHAR *err) -{ - /* make the cursor visible */ - SetCursor(LoadCursor(NULL, IDC_ARROW)); - - // - // warn user if there is one - // - printf("Error %s..\n", err); - fflush(stdout); - - MessageBox(hWndMain, err, TEXT("ERROR"), MB_OK); - return FALSE; -} - - -// ------------------ -// Command line stuff -// ------------------ -#define MAXCMDLINEARGS 64 -static char * myWargv[MAXCMDLINEARGS+1]; -static char myCmdline[512]; - -static VOID GetArgcArgv (LPSTR cmdline) -{ - LPSTR token; - size_t i = 0, len; - char cSep = ' '; - BOOL bCvar = FALSE, prevCvar = FALSE; - - // split arguments of command line into argv - strncpy (myCmdline, cmdline, 511); // in case window's cmdline is in protected memory..for strtok - len = strlen (myCmdline); - - myargc = 0; - while (myargc < MAXCMDLINEARGS) - { - // get token - while (myCmdline[i] == cSep) - i++; - if (i >= len) - break; - token = myCmdline + i; - if (myCmdline[i] == '"') - { - cSep = '"'; - i++; - if (!prevCvar) //cvar leave the "" in - token++; - } - else - cSep = ' '; - - //cvar - if (myCmdline[i] == '+' && cSep == ' ') //a + begins a cvarname, but not after quotes - bCvar = TRUE; - else - bCvar = FALSE; - - while (myCmdline[i] && - myCmdline[i] != cSep) - i++; - - if (myCmdline[i] == '"') - { - cSep = ' '; - if (prevCvar) - i++; // get ending " quote in arg - } - - prevCvar = bCvar; - - if (myCmdline + i > token) - { - myWargv[myargc++] = token; - } - - if (!myCmdline[i] || i >= len) - break; - - myCmdline[i++] = '\0'; - } - myWargv[myargc] = NULL; - - // m_argv.c uses myargv[], we used myWargv because we fill the arguments ourselves - // and myargv is just a pointer, so we set it to point myWargv - myargv = myWargv; -} - - -static inline VOID MakeCodeWritable(VOID) -{ -#ifdef USEASM - // Disable write-protection of code segment - DWORD OldRights; - BYTE *pBaseOfImage = (BYTE *)GetModuleHandle(NULL); - IMAGE_OPTIONAL_HEADER *pHeader = (IMAGE_OPTIONAL_HEADER *) - (pBaseOfImage + ((IMAGE_DOS_HEADER*)pBaseOfImage)->e_lfanew + - sizeof (IMAGE_NT_SIGNATURE) + sizeof (IMAGE_FILE_HEADER)); - if (!VirtualProtect(pBaseOfImage+pHeader->BaseOfCode,pHeader->SizeOfCode,PAGE_EXECUTE_READWRITE,&OldRights)) - I_Error("Could not make code writable\n"); -#endif -} - - - - -// ----------------------------------------------------------------------------- -// HandledWinMain : called by exception handler -// ----------------------------------------------------------------------------- -static int WINAPI HandledWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - int i; - LPSTR args; - - lpCmdLine = NULL; - hPrevInstance = NULL; -#ifdef LOGMESSAGES - // DEBUG!!! - set logstream to NULL to disable debug log - logstream = INVALID_HANDLE_VALUE; - - logstream = CreateFile (TEXT("log.txt"), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); //file flag writethrough? -#endif - - // fill myargc,myargv for m_argv.c retrieval of cmdline arguments - CONS_Printf("GetArgcArgv() ...\n"); - args = GetCommandLineA(); - CONS_Printf("lpCmdLine is '%s'\n", args); - GetArgcArgv(args); - // Create a text console window - OpenTextConsole(); - - CONS_Printf("Myargc: %d\n", myargc); - for (i = 0; i < myargc; i++) - CONS_Printf("myargv[%d] : '%s'\n", i, myargv[i]); - - // store for later use, will we need it ? - myInstance = hInstance; - - // open a dummy window, both OpenGL and DirectX need one. - if ((hWndMain = OpenMainWindow(hInstance,nCmdShow, - va("SRB2 "VERSIONSTRING))) == (HANDLE)-1) - { - tlErrorMessage(TEXT("Couldn't open window")); - return FALSE; - } - - // currently starts DirectInput - CONS_Printf("I_StartupSystem() ...\n"); - I_StartupSystem(); - MakeCodeWritable(); - - // startup SRB2 - CONS_Printf("D_SRB2Main() ...\n"); - D_SRB2Main(); - CONS_Printf("Entering main app loop...\n"); - // never return - D_SRB2Loop(); - - // back to Windoze - return 0; -} - -// ----------------------------------------------------------------------------- -// Exception handler calls WinMain for catching exceptions -// ----------------------------------------------------------------------------- -int WINAPI WinMain (HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - int Result = -1; -#if 1 - HMODULE h = GetModuleHandleA("kernel32.dll"); - MyFunc pfnIsDebuggerPresent = NULL; - if (h) - pfnIsDebuggerPresent = (MyFunc)GetProcAddress(h,"IsDebuggerPresent"); - if (!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) - LoadLibrary("exchndl.dll"); -#endif -#ifdef NO_SEH_MINGW - __try1(RecordExceptionInfo(GetExceptionInformation()/*, "main thread", lpCmdLine*/)) -#else - __try -#endif - { - Result = HandledWinMain (hInstance, hPrevInstance, lpCmdLine, nCmdShow); - } -#ifdef NO_SEH_MINGW - __except1 -#else - __except (RecordExceptionInfo(GetExceptionInformation()/*, "main thread", lpCmdLine*/)) -#endif - { - SetUnhandledExceptionFilter(EXCEPTION_CONTINUE_SEARCH); //Do nothing here. - } - - return Result; -} diff --git a/src/win32ce/win_main.h b/src/win32ce/win_main.h deleted file mode 100644 index fef25327d..000000000 --- a/src/win32ce/win_main.h +++ /dev/null @@ -1,55 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Win32 Sharing - -//#define WIN32_LEAN_AND_MEAN -#define RPC_NO_WINDOWS_H -#include -#include - -extern HINSTANCE myInstance; -extern HWND hWndMain; - -// debugging CONS_Printf to file -#ifdef LOGMESSAGES -extern HANDLE logstream; -#endif -extern int appActive; - -// the MIDI callback is another thread, and Midi volume is delayed here in window proc -VOID I_SetMidiChannelVolume(DWORD dwChannel, DWORD dwVolumePercent); -extern DWORD dwVolumePercent; - -VOID I_GetSysMouseEvents(int mouse_state); -extern unsigned int MSHWheelMessage; - -extern BOOL nodinput; -extern BOOL win9x; - -//faB: midi channel Volume set is delayed by the MIDI stream callback thread, see win_snd.c -#define WM_MSTREAM_UPDATEVOLUME (WM_USER + 101) - -// defined in win_sys.c -VOID I_BeginProfile(VOID); //for timing code -DWORD I_EndProfile(VOID); - -VOID I_GetLastErrorMsgBox(VOID); -VOID I_LoadingScreen (LPCSTR msg); - -void I_RestartSysMouse(void); -void I_DoStartupMouse(void); -BOOL I_SaveMemToFile(const void *pData, size_t iLength, const char *sFileName); diff --git a/src/win32ce/win_net.c b/src/win32ce/win_net.c deleted file mode 100644 index dac1bed53..000000000 --- a/src/win32ce/win_net.c +++ /dev/null @@ -1,39 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief Win32 network interface - -#include "../doomdef.h" -#include "../m_argv.h" -#include "../i_net.h" - -// -// NETWORKING -// - -// -// I_InitNetwork -// -boolean I_InitNetwork (void) -{ - if (M_CheckParm ("-net")) - { - I_Error("The Win32 version of SRB2 doesn't work with external drivers like ipxsetup, sersetup, or doomatic\n" - "Read the documentation about \"-server\" and \"-connect\" parameters or just use the launcher\n"); - } - - return false; -} diff --git a/src/win32ce/win_snd.c b/src/win32ce/win_snd.c deleted file mode 100644 index 14ce4add4..000000000 --- a/src/win32ce/win_snd.c +++ /dev/null @@ -1,2408 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief interface level code for sound -/// -/// Uses the midiStream* Win32 functions to play MIDI data -/// with low latency and low processor overhead. -#include "../doomdef.h" - -#include "win_main.h" -#include -#define DIRECTSOUND_VERSION 0x0600 /* version 6.0 */ -#define DIRECTINPUT_VERSION 0x0700 -#define DXVERSION_NTCOMPATIBLE 0x0300 -#ifdef _MSC_VER -#pragma warning(disable : 4201) -#endif -#include - -#include "../command.h" -#include "../i_sound.h" -#include "../s_sound.h" -#include "../i_system.h" -#include "../m_argv.h" -#include "../w_wad.h" -#include "../z_zone.h" -#include "../doomstat.h" - -#include "dx_error.h" - -#include "mid2strm.h" - -#ifdef HW3SOUND -#include "../hardware/hw3dsdrv.h" -#include "../hardware/hw3sound.h" -#include "win_dll.h" -#endif - -#ifndef SURROUND -#define SURROUND // comment out this to disable the SurroundSound code -#endif - -#ifdef SURROUND -ATTRNOINLINE static FUNCNOINLINE void CopyAndInvertMemory(void *dest, void *src, int bytes); //Can't inline ASM that haves lables -#endif - -#define FMODSOUND // comment out this to disable MOD/IT/MP3/OGG music playback - -/////////////////////////////////////////////////////////// -#ifdef FMODSOUND -#ifdef __MINGW32__ -#include -#else -#include -#endif -#ifdef FSOUND_INIT_DONTLATENCYADJUST //Alam: why didn't I think about this before? :) -#define FSOUND_Stream_OpenFile(name,mode,length) FSOUND_Stream_Open(name,mode,0,length) -#else -#define FSOUND_INIT_DONTLATENCYADJUST 0 -#endif -#ifdef __MINGW32__ -#include -#else -#include /* optional */ -#endif -//#include -#endif -///////////////////////////////////////////////////////// - -//#define TESTCODE // remove this for release version - -/* briefly described here for convenience: -typedef struct { - WORD wFormatTag; // WAVE_FORMAT_PCM is the only format accepted for DirectSound: - // this tag indicates Pulse Code Modulation (PCM), an uncompressed format - // in which each samples represents the amplitude of the signal at the time - // of sampling. - WORD nChannels; // either one (mono) or two (stereo) - DWORD nSamplesPerSec; // the sampling rate, or frequency, in hertz. - // Typical values are 11,025, 22,050, and 44,100 - DWORD nAvgBytesPerSec; // nAvgBytesPerSec is the product of nBlockAlign and nSamplesPerSec - WORD nBlockAlign; // the number of bytes required for each complete sample, for PCM formats - // is equal to (wBitsPerSample * nChannels / 8). - WORD wBitsPerSample; // gives the size of each sample, generally 8 or 16 bits - WORD cbSize; // cbSize gives the size of any extra fields required to describe a - // specialized wave format. This member is always zero for PCM formats. -} WAVEFORMATEX; -*/ - -// Tails 11-21-2002 -#ifdef FMODSOUND -static FMUSIC_MODULE *mod = NULL; -static int fsoundchannel = -1; -static int fsoundfreq = 0; -static int fmodvol = 127; -static FSOUND_STREAM *fmus = NULL; -#endif - -// -------------------------------------------------------------------------- -// DirectSound stuff -// -------------------------------------------------------------------------- -static LPDIRECTSOUND DSnd = NULL; -static LPDIRECTSOUNDBUFFER DSndPrimary = NULL; ; - -// Stack sounds means sounds put on top of each other, since DirectSound can't play -// the same sound buffer at different locations at the same time, we need to dupli- -// cate existing buffers to play multiple instances of the same sound in the same -// time frame. A duplicate sound is freed when it is no more used. The priority that -// comes from the s_sound engine, is kept so that the lowest priority sounds are -// stopped to make place for the new sound, unless the new sound has a lower priority -// than all playing sounds, in which case the sound is not started. -#define MAXSTACKSOUNDS 32 // this is the absolute number of sounds that - // can play simultaneously, whatever the value - // of cv_numChannels -typedef struct { - LPDIRECTSOUNDBUFFER lpSndBuf; -#ifdef SURROUND - // judgecutor: - // Need for produce surround sound - LPDIRECTSOUNDBUFFER lpSurround; -#endif - int priority; - boolean duplicate; -} StackSound_t; -static StackSound_t StackSounds[MAXSTACKSOUNDS]; - -// -------------------------------------------------------------------------- -// Fill the DirectSoundBuffer with data from a sample, made separate so that -// sound data cna be reloaded if a sound buffer was lost. -// -------------------------------------------------------------------------- -static boolean CopySoundData (LPDIRECTSOUNDBUFFER dsbuffer, LPBYTE data, DWORD length) -{ - LPVOID lpvAudio1; // receives address of lock start - DWORD dwBytes1; // receives number of bytes locked - LPVOID lpvAudio2; // receives address of lock start - DWORD dwBytes2; // receives number of bytes locked - HRESULT hr; - - // Obtain memory address of write block. - hr = IDirectSoundBuffer_Lock (dsbuffer, 0, length, &lpvAudio1, &dwBytes1, &lpvAudio2, &dwBytes2, 0); - - // If DSERR_BUFFERLOST is returned, restore and retry lock. - if (hr == DSERR_BUFFERLOST) - { - hr = IDirectSoundBuffer_Restore (dsbuffer); - if (FAILED (hr)) - I_Error("Restore fail on %x, %s\n",dsbuffer,DXErrorToString(hr)); - hr = IDirectSoundBuffer_Lock (dsbuffer, 0, length, &lpvAudio1, &dwBytes1, &lpvAudio2, &dwBytes2, 0); - if (FAILED (hr)) - I_Error("Lock fail(2) on %x, %s\n",dsbuffer,DXErrorToString(hr)); - } - else - if (FAILED (hr)) - I_Error("Lock fail(1) on %x, %s\n",dsbuffer,DXErrorToString(hr)); - - // copy wave data into the buffer (note: dwBytes1 should equal to dsbdesc->dwBufferBytes ...) - CopyMemory (lpvAudio1, data, dwBytes1); - - if (dwBytes2 && lpvAudio2) - CopyMemory(lpvAudio2, data+dwBytes1, dwBytes2); - - // finally, unlock the buffer - hr = IDirectSoundBuffer_Unlock (dsbuffer, lpvAudio1, dwBytes1, lpvAudio2, dwBytes2); - - if (FAILED (hr)) - I_Error("Unlock fail on %x, %s\n",dsbuffer,DXErrorToString(hr)); - - return true; -} - -#ifdef SURROUND -// judgecutor: -// Hmmm... May be this function is not too good... -static void CopyAndInvertMemory(void *dest, void *src, int bytes) -{ -#ifdef __GNUC__ - __asm__("CAIM:;lodsb;neg %%al;stosb;loop CAIM;"::"c"(bytes),"D"(dest),"S"(src): "memory","cc"); -#else - _asm - { - push esi - push edi - push ecx - mov ecx,bytes - mov esi,src - mov edi,dest -a: - lodsb - neg al - stosb - loop a - pop ecx - pop edi - pop esi - } -#endif -} - -// judgecutor: -// Like normal CopySoundData but sound data will be inverted -static boolean CopyAndInvertSoundData(LPDIRECTSOUNDBUFFER dsbuffer, LPBYTE data, DWORD length) -{ - LPVOID lpvAudio1 = NULL; // receives address of lock start - DWORD dwBytes1 = 0; // receives number of bytes locked - LPVOID lpvAudio2 = NULL; - DWORD dwBytes2 = 0; - HRESULT hr; - - // Obtain memory address of write block. - hr = IDirectSoundBuffer_Lock (dsbuffer, 0, length, &lpvAudio1, &dwBytes1, &lpvAudio2, &dwBytes2, 0); - - // If DSERR_BUFFERLOST is returned, restore and retry lock. - if (hr == DSERR_BUFFERLOST) - { - hr = IDirectSoundBuffer_Restore (dsbuffer); - if (FAILED (hr)) - I_Error("CopyAndInvert: Restore fail on %x, %s\n",dsbuffer,DXErrorToString(hr)); - hr = IDirectSoundBuffer_Lock (dsbuffer, 0, length, &lpvAudio1, &dwBytes1, &lpvAudio2, &dwBytes2, 0); - if (FAILED (hr)) - I_Error("CopyAndInvert: Lock fail(2) on %x, %s\n",dsbuffer,DXErrorToString(hr)); - } else if (FAILED (hr)) - I_Error("CopyAndInvetrt: Lock fail(1) on %x, %s\n",dsbuffer,DXErrorToString(hr)); - - // copy wave data into the buffer (note: dwBytes1 should equal to dsbdesc->dwBufferBytes ...) - CopyAndInvertMemory (lpvAudio1, data, dwBytes1); - - if (dwBytes2 && lpvAudio2) - CopyAndInvertMemory(lpvAudio2, data+dwBytes1, dwBytes2); - - hr = IDirectSoundBuffer_Unlock (dsbuffer, lpvAudio1, dwBytes1, lpvAudio2, dwBytes2); - if (FAILED (hr)) - I_Error("CopyAndInvert: Unlock fail on %x, %s\n",dsbuffer,DXErrorToString(hr)); - - return false; -} -#endif - -static DWORD sound_buffer_flags = DSBCAPS_CTRLPAN | - DSBCAPS_CTRLVOLUME | - DSBCAPS_STICKYFOCUS | - //DSBCAPS_LOCSOFTWARE | - DSBCAPS_STATIC; - -// -------------------------------------------------------------------------- -// raw2DS : convert a raw sound data, returns a LPDIRECTSOUNDBUFFER -// -------------------------------------------------------------------------- -// dsdata points a 4 UINT16 header: -// +0 : value 3 what does it mean? -// +2 : sample rate, either 11025 or 22050. -// +4 : number of samples, each sample is a single byte since it's 8bit -// +6 : value 0 -// -#ifdef SURROUND -// judgecutor: -// We need an another function definition for supporting the surround sound -// Invert just cause to copy an inverted sound data -static LPDIRECTSOUNDBUFFER raw2DS(LPBYTE *dsdata, size_t len, UINT8 invert) -#else -static LPDIRECTSOUNDBUFFER raw2DS(LPBYTE *dsdata, size_t len) -#endif -{ - HRESULT hr; - WAVEFORMATEX wfm; - DSBUFFERDESC dsbdesc; - LPDIRECTSOUNDBUFFER dsbuffer; - - // initialise WAVEFORMATEX structure describing the wave format - ZeroMemory (&wfm, sizeof (WAVEFORMATEX)); - wfm.wFormatTag = WAVE_FORMAT_PCM; - wfm.nChannels = 1; - wfm.nSamplesPerSec = (dsdata[3]<<8)+dsdata[2]; //mostly 11025, but some at 22050. - wfm.wBitsPerSample = 8; - wfm.nBlockAlign = (WORD)(wfm.wBitsPerSample / 8 * wfm.nChannels); - wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign; - - // Set up DSBUFFERDESC structure. - ZeroMemory (&dsbdesc, sizeof (DSBUFFERDESC)); - dsbdesc.dwSize = sizeof (DSBUFFERDESC); -/* dsbdesc.dwFlags = DSBCAPS_CTRLPAN | - DSBCAPS_CTRLVOLUME | - DSBCAPS_STICKYFOCUS | - //DSBCAPS_LOCSOFTWARE | - DSBCAPS_STATIC - | DSBCAPS_CTRLFREQUENCY; // This one for pitching -*/ - dsbdesc.dwFlags = sound_buffer_flags; - dsbdesc.dwBufferBytes = len-8; - dsbdesc.lpwfxFormat = &wfm; // pointer to WAVEFORMATEX structure - - // Create the sound buffer - hr = IDirectSound_CreateSoundBuffer (DSnd, &dsbdesc, &dsbuffer, NULL); - - if (hr == DSERR_CONTROLUNAVAIL) - { - CONS_Printf("\tSoundBufferCreate error - a buffer control is not available.\n\tTrying to disable frequency control.\n"); - - sound_buffer_flags &= ~DSBCAPS_CTRLFREQUENCY; - dsbdesc.dwFlags = sound_buffer_flags; - - hr = IDirectSound_CreateSoundBuffer (DSnd, &dsbdesc, &dsbuffer, NULL); - } - - if (FAILED(hr)) - I_Error("CreateSoundBuffer() FAILED: %s\n", DXErrorToString(hr)); - -#ifdef SURROUND - if (invert) - // just invert a sound data for producing the surround sound - CopyAndInvertSoundData(dsbuffer, (LPBYTE)dsdata + 8, dsbdesc.dwBufferBytes); - else - // Do a normal operation -#endif - // fill the DirectSoundBuffer waveform data - CopySoundData (dsbuffer, (LPBYTE)dsdata + 8, dsbdesc.dwBufferBytes); - - return dsbuffer; -} - - -// -------------------------------------------------------------------------- -// This function loads the sound data from the WAD lump, for single sound. -// -------------------------------------------------------------------------- -void *I_GetSfx (sfxinfo_t * sfx) -{ - LPBYTE dssfx; - - if (sfx->lumpnum < 0) - sfx->lumpnum = S_GetSfxLumpNum (sfx); - -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - return HW3S_GetSfx(sfx); -#endif - - sfx->length = W_LumpLength (sfx->lumpnum); - - // PU_CACHE because the data is copied to the DIRECTSOUNDBUFFER, the one here will not be used - dssfx = (LPBYTE) W_CacheLumpNum (sfx->lumpnum, PU_CACHE); - -#ifdef SURROUND - // Make a normal (not inverted) sound buffer - return (void *)raw2DS (dssfx, sfx->length, FALSE); -#else - // return the LPDIRECTSOUNDBUFFER, which will be stored in S_sfx[].data - return (void *)raw2DS (dssfx, sfx->length); -#endif -} - - -// -------------------------------------------------------------------------- -// Free all allocated resources for a single sound -// -------------------------------------------------------------------------- -void I_FreeSfx (sfxinfo_t *sfx) -{ - LPDIRECTSOUNDBUFFER dsbuffer; - - if (sfx->lumpnum < 0) - return; - -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_FreeSfx(sfx); - } - else -#endif - { - //CONS_Printf("I_FreeSfx(%d)\n", sfx->lumpnum); - - // free DIRECTSOUNDBUFFER - dsbuffer = (LPDIRECTSOUNDBUFFER) sfx->data; - if (dsbuffer) - { - size_t i; - for (i = 0; i < MAXSTACKSOUNDS; i++) - { - if (StackSounds[i].lpSndBuf == dsbuffer) - { - StackSounds[i].lpSndBuf = NULL; -#ifdef SURROUND - if (StackSounds[i].lpSurround) - { - IDirectSoundBuffer_Stop(StackSounds[i].lpSurround); - IDirectSoundBuffer_Release(StackSounds[i].lpSurround); - } - StackSounds[i].lpSurround = NULL; -#endif - } - } - IDirectSoundBuffer_Stop (dsbuffer); - IDirectSoundBuffer_Release (dsbuffer); - } - } - sfx->data = NULL; - sfx->lumpnum = -1; -} - - -// -------------------------------------------------------------------------- -// Set the global volume for sound effects -// -------------------------------------------------------------------------- -void I_SetSfxVolume(INT32 volume) -{ - int vol; - HRESULT hr; - - if (nosound || !sound_started) - return; - - // use the last quarter of volume range - if (volume) - vol = (volume * ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)) / 31 + - (DSBVOLUME_MAX - ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)); - else - vol = DSBVOLUME_MIN; // make sure 0 is silence - //CONS_Printf("setvolume to %d\n", vol); - hr = IDirectSoundBuffer_SetVolume (DSndPrimary, vol); - //if (FAILED(hr)) - // CONS_Printf("setvolumne failed\n"); -} - - -// -------------------------------------------------------------------------- -// Update the volume for a secondary buffer, make sure it was created with -// DSBCAPS_CTRLVOLUME -// -------------------------------------------------------------------------- -static void I_UpdateSoundVolume (LPDIRECTSOUNDBUFFER lpSnd, int volume) -{ - HRESULT hr; - volume = (volume * ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)) / 256 + - (DSBVOLUME_MAX - ((DSBVOLUME_MAX-DSBVOLUME_MIN)/4)); - hr = IDirectSoundBuffer_SetVolume (lpSnd, volume); - //if (FAILED(hr)) - // CONS_Printf("\2SetVolume FAILED\n"); -} - - -// -------------------------------------------------------------------------- -// Update the panning for a secondary buffer, make sure it was created with -// DSBCAPS_CTRLPAN -// -------------------------------------------------------------------------- -#define DSBPAN_RANGE (DSBPAN_RIGHT-(DSBPAN_LEFT)) -#define SEP_RANGE 256 //Doom sounds pan range 0-255 (128 is centre) -static void I_UpdateSoundPanning (LPDIRECTSOUNDBUFFER lpSnd, int sep) -{ - HRESULT hr; - hr = IDirectSoundBuffer_SetPan (lpSnd, (sep * DSBPAN_RANGE)/SEP_RANGE - DSBPAN_RIGHT); - //if (FAILED(hr)) - // CONS_Printf("SetPan FAILED for sep %d pan %d\n", sep, (sep * DSBPAN_RANGE)/SEP_RANGE - DSBPAN_RIGHT); -} - -// search a free slot in the stack, free it if needed -static int GetFreeStackNum(int newpriority) -{ - int lowestpri = 256,lowestprihandle = 0; - int i; - // DirectSound can't play multiple instances of the same sound buffer - // unless they are duplicated, so if the sound buffer is in use, make a duplicate - for (i = 0; i < MAXSTACKSOUNDS; i++) - { - // find a free 'playing sound slot' to use - if (StackSounds[i].lpSndBuf == NULL) - { - //CONS_Printf("\t\tfound free slot %d\n", i); - return i; - } - else if (!I_SoundIsPlaying(i)) // check for sounds that finished playing, and can be freed - { - //CONS_Printf("\t\tfinished sound in slot %d\n", i); - //stop sound and free the 'slot' - I_StopSound (i); - // we can use this one since it's now freed - return i; - } - else if (StackSounds[i].priority < lowestpri) //remember lowest priority sound - { - lowestpri = StackSounds[i].priority; - lowestprihandle = i; - } - } - - // the maximum of sounds playing at the same time is reached, if we have at least - // one sound playing with a lower priority, stop it and replace it with the new one - - //CONS_Printf("\t\tall slots occupied..\n"); - if (newpriority >= lowestpri) - { - I_StopSound (lowestprihandle); - return lowestprihandle; - //CONS_Printf(" kicking out lowest priority slot: %d pri: %d, my priority: %d\n", - // handle, lowestpri, priority); - } - - return -1; -} - -#ifdef SURROUND -static LPDIRECTSOUNDBUFFER CreateInvertedSound(int id) -{ - lumpnnum_t lumpnum; - LBYPTE dsdata; - - lumpnum = S_sfx[id].lumpnum; - if (lumpnum < 0) - lumpnum = S_GetSfxLumpNum (&S_sfx[id]); - dsdata = W_CacheLumpNum (lumpnum, PU_CACHE); - return raw2DS(dsdata, S_sfx[id].length, TRUE); -} -#endif - -// Calculate internal pitch from Doom pitch -#if 0 -static float recalc_pitch(int doom_pitch) -{ - return doom_pitch < NORMAL_PITCH ? - (float)(doom_pitch + NORMAL_PITCH) / (NORMAL_PITCH * 2) - :(float)doom_pitch / (float)NORMAL_PITCH; -} -#endif - -// -------------------------------------------------------------------------- -// Start the given S_sfx[id] sound with given properties (panning, volume..) -// -------------------------------------------------------------------------- -INT32 I_StartSound (sfxenum_t id, - INT32 vol, - INT32 sep, - INT32 pitch, - INT32 priority, - INT32 channel) -{ - HRESULT hr; - LPDIRECTSOUNDBUFFER dsbuffer; - DWORD dwStatus; - int handle; - int i; - //DWORD freq; -#ifdef SURROUND - LPDIRECTSOUNDBUFFER dssurround; -#endif - (void)channel; - - if (nosound) - return -1; - - //CONS_Printf("I_StartSound:\n\t\tS_sfx[%d]\n", id); - handle = GetFreeStackNum(priority); - if (handle < 0) - return -1; - - //CONS_Printf("\t\tusing handle %d\n", handle); - - // if the original buffer is playing, duplicate it (DirectSound specific) - // else, use the original buffer - dsbuffer = (LPDIRECTSOUNDBUFFER) S_sfx[id].data; - IDirectSoundBuffer_GetStatus (dsbuffer, &dwStatus); - if (dwStatus & (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)) - { - //CONS_Printf("\t\toriginal sound S_sfx[%d] is playing, duplicating.. ", id); - hr = IDirectSound_DuplicateSoundBuffer(DSnd, (LPDIRECTSOUNDBUFFER) S_sfx[id].data, &dsbuffer); - if (FAILED(hr)) - { - //CONS_Printf("Cound't duplicate sound buffer\n"); - // re-use the original then.. - dsbuffer = (LPDIRECTSOUNDBUFFER) S_sfx[id].data; - // clean up stacksounds info - for (i = 0; i < MAXSTACKSOUNDS; i++) - if (handle != i && - StackSounds[i].lpSndBuf == dsbuffer) - { - StackSounds[i].lpSndBuf = NULL; - } - } - // stop the duplicate or the re-used original - IDirectSoundBuffer_Stop (dsbuffer); - } - - //judgecutor: Sound pitching -#if 0 - if (cv_rndsoundpitch.value) - { - // At first reset the buffer back to original frequency - hr = IDirectSoundBuffer_SetFrequency(dsbuffer, DSBFREQUENCY_ORIGINAL); - if (SUCCEEDED (hr)) - { - - IDirectSoundBuffer_GetFrequency(dsbuffer, &freq); - - // Now pitch it - freq *= recalc_pitch(pitch); - IDirectSoundBuffer_SetFrequency(dsbuffer, freq); - } - else - cv_rndsoundpitch = 0; - } -#else - pitch = 0; -#endif - // store information on the playing sound - StackSounds[handle].lpSndBuf = dsbuffer; - StackSounds[handle].priority = priority; - StackSounds[handle].duplicate = (dsbuffer != (LPDIRECTSOUNDBUFFER)S_sfx[id].data); - - //CONS_Printf("StackSounds[%d].lpSndBuf is %s\n", handle, StackSounds[handle].lpSndBuf == NULL ? "Null":"valid"); - //CONS_Printf("StackSounds[%d].priority is %d\n", handle, StackSounds[handle].priority); - //CONS_Printf("StackSounds[%d].duplicate is %s\n", handle, StackSounds[handle].duplicate ? "TRUE":"FALSE"); - - I_UpdateSoundVolume (dsbuffer, vol); - -#ifdef SURROUND - // Prepare the surround sound buffer - // Use a normal sound data for the left channel (with pan == 0) - // and an inverted sound data for the right channel (with pan == 255) - - dssurround = CreateInvertedSound(id); - - // Surround must be pitched too -#if 0 - if (cv_rndsoundpitch.value) - IDirectSoundBuffer_SetFrequency(dssurround, freq); -#endif - if (sep == -128) - { - I_UpdateSoundPanning(dssurround, 255); - I_UpdateSoundVolume(dssurround, vol); - I_UpdateSoundPanning(dsbuffer, 0); - IDirectSoundBuffer_SetCurrentPosition(dssurround, 0); - } - else - // Perform normal operation -#endif - - I_UpdateSoundPanning (dsbuffer, sep); - - IDirectSoundBuffer_SetCurrentPosition (dsbuffer, 0); - - hr = IDirectSoundBuffer_Play (dsbuffer, 0, 0, 0); - if (hr == DSERR_BUFFERLOST) - { - //CONS_Printf("buffer lost\n"); - // restores the buffer memory and all other settings for the buffer - hr = IDirectSoundBuffer_Restore (dsbuffer); - if (SUCCEEDED (hr)) - { - LPBYTE dsdata; - // reload sample data here - int lumpnum = S_sfx[id].lumpnum; - if (lumpnum < 0) - lumpnum = S_GetSfxLumpNum (&S_sfx[id]); - dsdata = W_CacheLumpNum (lumpnum, PU_CACHE); - - // Well... Data lenght must be -8!!! - CopySoundData (dsbuffer, dsdata + 8, S_sfx[id].length - 8); - - // play - hr = IDirectSoundBuffer_Play (dsbuffer, 0, 0, 0); - } - else - I_Error("I_StartSound : ->Restore FAILED, %s",DXErrorToString(hr)); - } - -#ifdef SURROUND - if (sep == -128) - { - hr = IDirectSoundBuffer_Play (dssurround, 0, 0, 0); - //CONS_Printf("Surround playback\n"); - if (hr == DSERR_BUFFERLOST) - { - // restores the buffer memory and all other settings for the surround buffer - hr = IDirectSoundBuffer_Restore (dssurround); - if (SUCCEEDED (hr)) - { - LPBYTE dsdata; - lumpnumt_t lumpnum = S_sfx[id].lumpnum; - - if (lumpnum < 0) - lumpnum = S_GetSfxLumpNum (&S_sfx[id]); - dsdata = W_CacheLumpNum (lumpnum, PU_CACHE); - CopyAndInvertSoundData (dssurround, (LPBYTE)dsdata + 8, S_sfx[id].length - 8); - - hr = IDirectSoundBuffer_Play (dssurround, 0, 0, 0); - } - else - I_Error("I_StartSound : ->Restore FAILED, %s",DXErrorToString(hr)); - } - } - StackSounds[handle].lpSurround = dssurround; -#endif - - // Returns a handle - return handle; -} - - -// -------------------------------------------------------------------------- -// Stop a sound if it is playing, -// free the corresponding 'playing sound slot' in StackSounds[] -// -------------------------------------------------------------------------- -void I_StopSound (INT32 handle) -{ - LPDIRECTSOUNDBUFFER dsbuffer; - HRESULT hr; - - if (nosound || handle < 0) - return; - - //CONS_Printf("I_StopSound (%d)\n", handle); - - dsbuffer = StackSounds[handle].lpSndBuf; - hr = IDirectSoundBuffer_Stop (dsbuffer); - - // free duplicates of original sound buffer (DirectSound hassles) - if (StackSounds[handle].duplicate) - { - //CONS_Printf("\t\trelease a duplicate..\n"); - IDirectSoundBuffer_Release (dsbuffer); - } - -#ifdef SURROUND - // Stop and release the surround sound buffer - dsbuffer = StackSounds[handle].lpSurround; - if (dsbuffer != NULL) - { - IDirectSoundBuffer_Stop(dsbuffer); - IDirectSoundBuffer_Release(dsbuffer); - } - StackSounds[handle].lpSurround = NULL; -#endif - - StackSounds[handle].lpSndBuf = NULL; -} - - -// -------------------------------------------------------------------------- -// Returns whether the sound is currently playing or not -// -------------------------------------------------------------------------- -INT32 I_SoundIsPlaying(INT32 handle) -{ - LPDIRECTSOUNDBUFFER dsbuffer; - DWORD dwStatus; - - if (nosound || handle == -1) - return FALSE; - - dsbuffer = StackSounds[handle].lpSndBuf; - if (dsbuffer) - { - IDirectSoundBuffer_GetStatus (dsbuffer, &dwStatus); - if (dwStatus & (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)) - return TRUE; - } - - return FALSE; -} - - -// -------------------------------------------------------------------------- -// Update properties of a sound currently playing -// -------------------------------------------------------------------------- -void I_UpdateSoundParams(INT32 handle, - INT32 vol, - INT32 sep, - INT32 pitch) -{ - LPDIRECTSOUNDBUFFER dsbuffer; -#ifdef SURROUND - LPDIRECTSOUNDBUFFER dssurround; - DWORD dwStatus; - DWORD pos; - boolean surround_inuse = FALSE; -#endif - - if (nosound) - return; - - pitch = 0; /// \todo pitch setup - dsbuffer = StackSounds[handle].lpSndBuf; - -#ifdef SURROUND - if (dsbuffer == NULL) - return; - - dssurround = StackSounds[handle].lpSurround; - if (dssurround) - { - IDirectSoundBuffer_GetStatus(dssurround, &dwStatus); - surround_inuse = (dwStatus & (DSBSTATUS_PLAYING | DSBSTATUS_LOOPING)); - } - // If pan changed to stereo... - if (sep != -128) - { - if (surround_inuse) - { - IDirectSoundBuffer_Stop(dssurround); - surround_inuse = FALSE; - } - } - else if (!surround_inuse) // Just update volumes and start the surround if need - { - I_UpdateSoundVolume(dssurround, vol); - I_UpdateSoundPanning(dsbuffer, 0); - IDirectSoundBuffer_GetCurrentPosition(dsbuffer, &pos, NULL); - IDirectSoundBuffer_SetCurrentPosition(dssurround, pos); - IDirectSoundBuffer_Play(dssurround, 0, 0, 0); - surround_inuse = TRUE; - } - else - I_UpdateSoundVolume(dssurround, vol); - I_UpdateSoundVolume(dsbuffer, vol); - - if (!surround_inuse) - I_UpdateSoundPanning(dsbuffer, sep); -#else - if (dsbuffer) - { - I_UpdateSoundVolume (dsbuffer, vol); - I_UpdateSoundPanning (dsbuffer, sep); - } -#endif -} - - -// -// Shutdown DirectSound -// -void I_ShutdownSound(void) -{ - int i; - - CONS_Printf("I_ShutdownSound()\n"); - -#ifdef HW3SOUND - if (hws_mode != HWS_DEFAULT_MODE) - { - HW3S_Shutdown(); - Shutdown3DSDriver(); - return; - } -#endif - // release any temporary 'duplicated' secondary buffers - for (i = 0; i < MAXSTACKSOUNDS; i++) - if (StackSounds[i].lpSndBuf) - // stops the sound and release it if it is a duplicate - I_StopSound (i); - - if (DSnd) - { - IDirectSound_Release(DSnd); - DSnd = NULL; - } -} - - -// ========================================================================== -// Startup DirectSound -// ========================================================================== -void I_StartupSound(void) -{ - HRESULT hr; - LPDIRECTSOUNDBUFFER lpDsb; - DSBUFFERDESC dsbdesc; - WAVEFORMATEX wfm; - int cooplevel; - int frequency; - -#ifdef HW3SOUND - const char *sdrv_name = NULL; - snddev_t snddev; -#endif - - sound_started = false; - - if (dedicated) - return; - - if (nosound) - return; - - // Secure and configure sound device first. - CONS_Printf("I_StartupSound: "); - - // frequency of primary buffer may be set at cmd-line - if (M_CheckParm ("-freq") && M_IsNextParm()) - { - frequency = atoi(M_GetNextParm()); - CONS_Printf(" requested frequency of %d hz\n", frequency); - CV_SetValue(&cv_samplerate,frequency); - } - else - frequency = cv_samplerate.value; - - // Set cooperative level - // Cooperative sound with other applications can be requested at cmd-line - if (M_CheckParm("-coopsound")) - cooplevel = DSSCL_PRIORITY; - else - cooplevel = DSSCL_EXCLUSIVE; - -#ifdef HW3SOUND - if (M_CheckParm("-ds3d")) - { - hws_mode = HWS_DS3D; - sdrv_name = "s_ds3d.dll"; - } -#if 1 - else if (M_CheckParm("-fmod3d")) - { - hws_mode = HWS_FMOD3D; - sdrv_name = "s_fmod.dll"; - } - else if (M_CheckParm("-sounddriver") && M_IsNextParm()) - { - hws_mode = HWS_OTHER; - sdrv_name = M_GetNextParm(); - } -#else - else if (M_CheckParm("-sounddriver") && M_IsNextParm()) - { - hws_mode = HWS_OTHER; - sdrv_name = M_GetNextParm(); - } - else if (!M_CheckParm("-nosd")) - { - hws_mode = HWS_FMOD3D; - sdrv_name = "s_fmod.dll"; - } -#endif - - // There must be further sound drivers (such as A3D and EAX)!!! - - if (hws_mode != HWS_DEFAULT_MODE && sdrv_name != NULL) - { - if (Init3DSDriver(sdrv_name)) - { - //nosound = true; - snddev.sample_rate = frequency; - snddev.bps = 16; - snddev.numsfxs = NUMSFX; - snddev.cooplevel = cooplevel; - snddev.hWnd = hWndMain; - if (HW3S_Init(I_Error, &snddev)) - { - CONS_Printf("Using external sound driver %s\n", sdrv_name); - I_AddExitFunc(I_ShutdownSound); - return; - } - // Falls back to default sound system - CONS_Printf("Not using external sound driver %s\n", sdrv_name); - HW3S_Shutdown(); - Shutdown3DSDriver(); - } - hws_mode = HWS_DEFAULT_MODE; - } -#endif - - // Create DirectSound, use the default sound device - hr = DirectSoundCreate(NULL, &DSnd, NULL); - if (FAILED(hr)) - { - CONS_Printf(" DirectSoundCreate FAILED\n" - " there is no sound device or the sound device is under\n" - " the control of another application\n"); - nosound = true; - return; - } - - // register exit code, now that we have at least DirectSound to close - I_AddExitFunc(I_ShutdownSound); - hr = IDirectSound_SetCooperativeLevel (DSnd, hWndMain, cooplevel); - if (FAILED(hr)) - { - CONS_Printf(" SetCooperativeLevel FAILED\n"); - nosound = true; - return; - } - - // Set up DSBUFFERDESC structure. - ZeroMemory (&dsbdesc, sizeof (DSBUFFERDESC)); - dsbdesc.dwSize = sizeof (DSBUFFERDESC); - dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER | - DSBCAPS_CTRLVOLUME; - dsbdesc.dwBufferBytes = 0; // Must be 0 for primary buffer - dsbdesc.lpwfxFormat = NULL; // Must be NULL for primary buffer - - // Set up structure for the desired format - ZeroMemory (&wfm, sizeof (WAVEFORMATEX)); - wfm.wFormatTag = WAVE_FORMAT_PCM; - wfm.nChannels = 2; //STEREO SOUND! - wfm.nSamplesPerSec = frequency; - wfm.wBitsPerSample = 16; - wfm.nBlockAlign = (WORD)(wfm.wBitsPerSample / 8 * wfm.nChannels); - wfm.nAvgBytesPerSec = wfm.nSamplesPerSec * wfm.nBlockAlign; - - // Gain access to the primary buffer - hr = IDirectSound_CreateSoundBuffer (DSnd, &dsbdesc, &lpDsb, NULL); - if (FAILED(hr)) - { - CONS_Printf("CreateSoundBuffer FAILED: %s (ErrNo %d)\n", DXErrorToString(hr), hr); - nosound = true; - return; - } - - // Set the primary buffer to the desired format, - // but only if we are allowed to do it - if (cooplevel >= DSSCL_PRIORITY) - { - if (SUCCEEDED (hr)) - { - // Set primary buffer to the desired format. If this fails, - // we'll just ignore and go with the default. - hr = IDirectSoundBuffer_SetFormat (lpDsb, &wfm); - if (FAILED(hr)) - CONS_Printf("I_StartupSound : couldn't set primary buffer format.\n"); - else - CV_SetValue(&cv_samplerate,wfm.nSamplesPerSec); - } - // move any on-board sound memory into a contiguous block - // to make the largest portion of free memory available. - - CONS_Printf(" Compacting onboard sound-memory..."); - hr = IDirectSound_Compact (DSnd); - CONS_Printf(" %s\n", SUCCEEDED(hr) ? "Done\n" : "Failed\n")); - } - - // set the primary buffer to play continuously, for performance - // "... this method will ensure that the primary buffer is playing even when no secondary - // buffers are playing; in that case, silence will be played. This can reduce processing - // overhead when sounds are started and stopped in sequence, because the primary buffer - // will be playing continuously rather than stopping and starting between secondary buffers." - hr = IDirectSoundBuffer_Play (lpDsb, 0, 0, DSBPLAY_LOOPING); - if (FAILED (hr)) - CONS_Printf(" Primary buffer continuous play FAILED\n"); - -#ifdef DEBUGSOUND - { - DSCAPS DSCaps; - DSCaps.dwSize = sizeof (DSCAPS); - hr = IDirectSound_GetCaps (DSnd, &DSCaps); - if (SUCCEEDED (hr)) - { - if (DSCaps.dwFlags & DSCAPS_CERTIFIED) - CONS_Printf("This driver has been certified by Microsoft\n"); - if (DSCaps.dwFlags & DSCAPS_EMULDRIVER) - CONS_Printf("No driver with DirectSound support installed (no hardware mixing)\n"); - if (DSCaps.dwFlags & DSCAPS_PRIMARY16BIT) - CONS_Printf("Supports 16-bit primary buffer\n"); - if (DSCaps.dwFlags & DSCAPS_PRIMARY8BIT) - CONS_Printf("Supports 8-bit primary buffer\n"); - if (DSCaps.dwFlags & DSCAPS_SECONDARY16BIT) - CONS_Printf("Supports 16-bit, hardware-mixed secondary buffers\n"); - if (DSCaps.dwFlags & DSCAPS_SECONDARY8BIT) - CONS_Printf("Supports 8-bit, hardware-mixed secondary buffers\n"); - - CONS_Printf("Maximum number of hardware buffers: %d\n", DSCaps.dwMaxHwMixingStaticBuffers); - CONS_Printf("Size of total hardware memory: %d\n", DSCaps.dwTotalHwMemBytes); - CONS_Printf("Size of free hardware memory= %d\n", DSCaps.dwFreeHwMemBytes); - CONS_Printf("Play Cpu Overhead (%% cpu cycles): %d\n", DSCaps.dwPlayCpuOverheadSwBuffers); - } - else - CONS_Printf(" couldn't get sound device caps.\n"); - } -#endif - - // save pointer to the primary DirectSound buffer for volume changes - DSndPrimary = lpDsb; - - ZeroMemory (StackSounds, sizeof (StackSounds)); - - CONS_Printf("sound initialised.\n"); - sound_started = true; -} - - -// ========================================================================== -// -// MUSIC API using MidiStream -// -// ========================================================================== - -#define SPECIAL_HANDLE_CLEANMIDI -1999 // tell I_StopSong() to do a full (slow) midiOutReset() on exit - -static BOOL bMusicStarted; - -static UINT uMIDIDeviceID, uCallbackStatus; -static HMIDISTRM hStream; -static HANDLE hBufferReturnEvent; // for synch between the callback thread and main program thread - // (we need to synch when we decide to stop/free stream buffers) - -static int nCurrentBuffer = 0, nEmptyBuffers; - -static BOOL bBuffersPrepared = FALSE; -static DWORD dwVolCache[MAX_MIDI_IN_TRACKS]; - DWORD dwVolumePercent; // accessed by win_main.c - - // this is accessed by mid2strm.c conversion code - BOOL bMidiLooped = FALSE; -static BOOL bMidiPlaying = FALSE; -static BOOL bMidiPaused = FALSE; -static CONVERTINFO ciStreamBuffers[NUM_STREAM_BUFFERS]; - -#define STATUS_KILLCALLBACK 100 // Signals that the callback should die -#define STATUS_CALLBACKDEAD 200 // Signals callback is done processing -#define STATUS_WAITINGFOREND 300 // Callback's waiting for buffers to play - -#define DEBUG_CALLBACK_TIMEOUT 2000 // Wait 2 seconds for callback - // faB: don't freeze the main code if we debug.. - -#define VOL_CACHE_INIT 127 // for dwVolCache[] - -static BOOL bMidiCanSetVolume; // midi caps - -static void Mid2StreamFreeBuffers(void); -static void CALLBACK MidiStreamCallback (HMIDIIN hMidi, UINT uMsg, DWORD dwInstance, - DWORD dwParam1, DWORD dwParam2); -static BOOL StreamBufferSetup(LPBYTE pMidiData, size_t iMidiSize); - -// ------------------- -// MidiErrorMessageBox -// Calls the midiOutGetErrorText() function and displays the text which -// corresponds to a midi subsystem error code. -// ------------------- -static void MidiErrorMessageBox(MMRESULT mmr) -{ - char szTemp[256] = ""; - - /*szTemp[0] = '\2'; //white text to stand out*/ - if((MMSYSERR_NOERROR == midiOutGetErrorTextA(mmr, szTemp/*+1*/, sizeof (szTemp))) && *szTemp) - CONS_Printf("%s\n",szTemp); - /*MessageBox (GetActiveWindow(), szTemp+1, "LEGACY", - MB_OK | MB_ICONSTOP);*/ - //wsprintf(szDebug, "Midi subsystem error: %s", szTemp); -} - - -// ---------------- -// I_InitAudioMixer -// ---------------- -#ifdef TESTCODE -void I_InitAudioMixer (void) -{ - UINT cMixerDevs = mixerGetNumDevs(); - CONS_Printf("%d mixer devices available\n", cMixerDevs); -} -#endif - -// ----------- -// I_InitDigMusic -// Startup Digital device for streaming output -// ----------- -void I_InitDigMusic(void) -{ - if (dedicated) - nodigimusic = true; - else - CONS_Printf("I_InitDigMusic()\n"); - -#ifdef FMODSOUND - if (!nodigimusic) - { - // Tails 11-21-2002 - if (FSOUND_GetVersion() < FMOD_VERSION) - { - //I_Error("FMOD Error : You are using the wrong DLL version!\nYou should be using FMOD %s\n", "FMOD_VERSION"); - CONS_Printf("FMOD Error : You are using the wrong DLL version!\nYou should be using FMOD %s\n", "FMOD_VERSION"); - nodigimusic = true; - } - - /* - INITIALIZE - */ -#if 1 - if (!FSOUND_SetHWND(hWndMain)) - { -// I_Error("FMOD(Init,FSOUND_SetHWND): %s\n", FMOD_ErrorString(FSOUND_GetError())); - //FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND); - } - //else -#endif - - if (!FSOUND_Init(44100, 32, FSOUND_INIT_DONTLATENCYADJUST)) - { - //I_Error("FMOD(Init,FSOUND_Init): %s\n", FMOD_ErrorString(FSOUND_GetError())); - CONS_Printf("FMOD(Init,FSOUND_Init): %s\n", FMOD_ErrorString(FSOUND_GetError())); - nodigimusic = true; - } - else - I_AddExitFunc(I_ShutdownDigMusic); - } -#endif -} - -// ----------- -// I_InitMIDIMusic -// Startup Midi device for streaming output -// ----------- -void I_InitMIDIMusic(void) -{ - DWORD idx; - MMRESULT mmrRetVal; - UINT cMidiDevs; - MIDIOUTCAPS MidiOutCaps; - const char *szTechnology; - - bMusicStarted = false; - - if (dedicated) - nomidimusic = true; - else - CONS_Printf("I_InitMIDIMusic()\n"); - - if (nomidimusic) - return; - - // check out number of MIDI devices available - // - cMidiDevs = midiOutGetNumDevs(); - if (!cMidiDevs) - { - CONS_Printf("No MIDI devices available, music is disabled\n"); - nomidimusic = true; - return; - } -#ifdef DEBUGMIDISTREAM - else - { - CONS_Printf("%d MIDI devices available\n", cMidiDevs); - } -#endif - - if (M_CheckParm("-winmidi") && M_IsNextParm()) - uMIDIDeviceID = atoi(M_GetNextParm()); - else - uMIDIDeviceID = MIDI_MAPPER; - - // get MIDI device caps - // - if ((mmrRetVal = midiOutGetDevCaps (uMIDIDeviceID, &MidiOutCaps, sizeof (MIDIOUTCAPS))) != - MMSYSERR_NOERROR) - { - CONS_Printf("midiOutGetCaps FAILED : \n"); - MidiErrorMessageBox (mmrRetVal); - } - else - { - CONS_Printf("MIDI product name: %s\n", MidiOutCaps.szPname); - switch (MidiOutCaps.wTechnology) - { - case MOD_FMSYNTH: szTechnology = "FM Synth"; break; - case MOD_MAPPER: szTechnology = "Microsoft MIDI Mapper"; break; - case MOD_MIDIPORT: szTechnology = "MIDI hardware port"; break; - case MOD_SQSYNTH: szTechnology = "Square wave synthesizer"; break; - case MOD_SYNTH: szTechnology = "Synthesizer"; break; - default: szTechnology = "unknown"; break; - } - CONS_Printf("MIDI technology: %s\n", szTechnology); - CONS_Printf("MIDI caps:\n"); - if (MidiOutCaps.dwSupport & MIDICAPS_CACHE) - CONS_Printf("-Patch caching\n"); - if (MidiOutCaps.dwSupport & MIDICAPS_LRVOLUME) - CONS_Printf("-Separate left and right volume control\n"); - if (MidiOutCaps.dwSupport & MIDICAPS_STREAM) - CONS_Printf("-Direct support for midiStreamOut()\n"); - if (MidiOutCaps.dwSupport & MIDICAPS_VOLUME) - CONS_Printf("-Volume control\n"); - bMidiCanSetVolume = ((MidiOutCaps.dwSupport & MIDICAPS_VOLUME)!=0); - } - -#ifdef TESTCODE - I_InitAudioMixer (); -#endif - - // ---------------------------------------------------------------------- - // Midi2Stream initialization - // ---------------------------------------------------------------------- - - // create event for synch'ing the callback thread to main program thread - // when we will need it - hBufferReturnEvent = CreateEvent(NULL, FALSE, FALSE, - TEXT("SRB2 Midi Playback: Wait For Buffer Return")); - - if (!hBufferReturnEvent) - { - I_GetLastErrorMsgBox(); - nomidimusic = true; - return; - } - - if ((mmrRetVal = midiStreamOpen(&hStream, - &uMIDIDeviceID, - (DWORD)1, (DWORD_PTR)MidiStreamCallback/*NULL*/, - (DWORD)0, - CALLBACK_FUNCTION /*CALLBACK_NULL*/)) != MMSYSERR_NOERROR) - { - CONS_Printf("I_RegisterSong: midiStreamOpen FAILED\n"); - MidiErrorMessageBox(mmrRetVal); - nomidimusic = true; - return; - } - - // stream buffers are initially unallocated (set em NULL) - for (idx = 0; idx < NUM_STREAM_BUFFERS; idx++) - ZeroMemory (&ciStreamBuffers[idx].mhBuffer, sizeof (MIDIHDR)); - // ---------------------------------------------------------------------- - - // register exit code - I_AddExitFunc(I_ShutdownMIDIMusic); - - bMusicStarted = true; -} - -// --------------- -// I_InitMusic -// --------------- -void I_InitMusic(void) -{ - I_InitDigMusic(); - I_InitMIDIMusic(); -} - -// --------------- -// I_ShutdownDigMusic -// --------------- -void I_ShutdownDigMusic(void) -{ - CONS_Printf("I_ShutdownDigMusic: \n"); - -#ifdef FMODSOUND - if (!nodigimusic && FSOUND_GetError() != FMOD_ERR_UNINITIALIZED) - { - if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_CHANNEL_ALLOC && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) - if (devparm) CONS_Printf("FMOD(Shutdown,Unknown): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (mod) - { - if (FMUSIC_IsPlaying(mod)) - if (!FMUSIC_StopSong(mod)) - if (devparm) CONS_Printf("FMOD(Shutdown,FMUSIC_StopSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (!FMUSIC_FreeSong(mod)) - if (devparm) CONS_Printf("FMOD(Shutdown,FMUSIC_FreeSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - if (fmus) - { - if (FSOUND_IsPlaying(fsoundchannel)) - if (!FSOUND_Stream_Stop(fmus)) - if (devparm) CONS_Printf("FMOD(Shutdown,FSOUND_Stream_Stop): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (!FSOUND_Stream_Close(fmus)) - if (devparm) CONS_Printf("FMOD(Shutdown,FSOUND_Stream_Close): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - FSOUND_Close(); - remove("fmod.tmp"); // Delete the temp file - //if (!FSOUND_StopSound(FSOUND_ALL)) - //if (FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) CONS_Printf("FMOD(Shutdown,FSOUND_StopSound): %s\n", FMOD_ErrorString(FSOUND_GetError())); - //FMUSIC_StopAllSongs(); - //if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) CONS_Printf("FMOD(Shutdown,FMUSIC_StopAllSongs): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } -#endif -} - -// --------------- -// I_ShutdownMIDIMusic -// --------------- -void I_ShutdownMIDIMusic(void) -{ - DWORD idx; - MMRESULT mmrRetVal; - HGLOBAL lp = NULL; - - CONS_Printf("I_ShutdownMIDIMusic: \n"); - - if (nomidimusic) - return; - - if (!bMusicStarted) - return; - - if (hStream) - { - I_StopSong (SPECIAL_HANDLE_CLEANMIDI); - } - - Mid2StreamConverterCleanup(); - Mid2StreamFreeBuffers(); - - // Free our stream buffers - for (idx = 0; idx < NUM_STREAM_BUFFERS; idx++) - { - if (ciStreamBuffers[idx].mhBuffer.lpData) - { - //GlobalFreePtr(ciStreamBuffers[idx].mhBuffer.lpData); - lp = GlobalPtrHandle(ciStreamBuffers[idx].mhBuffer.lpData); - GlobalUnlock(lp); - GlobalFree(lp); - ciStreamBuffers[idx].mhBuffer.lpData = NULL; - } - } - - if (hStream) - { - if ((mmrRetVal = midiStreamClose(hStream)) != MMSYSERR_NOERROR) - MidiErrorMessageBox(mmrRetVal); - hStream = NULL; - } - - CloseHandle(hBufferReturnEvent); - - bMusicStarted = false; -} - -// --------------- -// I_ShutdownMusic -// --------------- -void I_ShutdownMusic(void) -{ - if (!nodigimusic) - I_ShutdownDigMusic(); - - if (!nomidimusic) - I_ShutdownMIDIMusic(); -} - -// -------------------- -// SetAllChannelVolumes -// Given a percent in tenths of a percent, sets volume on all channels to -// reflect the new value. -// -------------------- -static void SetAllChannelVolumes(DWORD dwVolumePercent) -{ - DWORD dwEvent, dwStatus, dwVol, idx; - MMRESULT mmrRetVal; - - if (!bMidiPlaying) - return; - - for (idx = 0, dwStatus = MIDI_CTRLCHANGE; idx < MAX_MIDI_IN_TRACKS; idx++, dwStatus++) - { - dwVol = (dwVolCache[idx] * dwVolumePercent) / 1000; - //CONS_Printf("channel %d vol %d\n", idx, dwVol); - dwEvent = dwStatus | ((DWORD)MIDICTRL_VOLUME << 8) - | ((DWORD)dwVol << 16); - if ((mmrRetVal = midiOutShortMsg((HMIDIOUT)hStream, dwEvent)) - != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - return; - } - } -} - - -// ---------------- -// I_SetMusicVolume -// Set the midi output volume -// ---------------- -void I_SetMIDIMusicVolume(INT32 volume) -{ - MMRESULT mmrRetVal; - int iVolume; - - if (nomidimusic) - return; - - if (bMidiCanSetVolume) - { - // method A - // current volume is 0-31, we need 0-0xFFFF in each word (left/right channel) - iVolume = (volume << 11) | (volume << 27); - if ((mmrRetVal = midiOutSetVolume ((HMIDIOUT)(size_t)uMIDIDeviceID, iVolume)) != MMSYSERR_NOERROR) - { - CONS_Printf("I_SetMusicVolume: couldn't set volume\n"); - MidiErrorMessageBox(mmrRetVal); - } - } - else - { - // method B - dwVolumePercent = (volume * 1000) / 32; - SetAllChannelVolumes (dwVolumePercent); - } -} - -void I_SetDigMusicVolume(INT32 volume) -{ -#ifdef FMODSOUND - if (volume != -1) - fmodvol = (volume<<3)+(volume>>2); - if (!nodigimusic) - { - if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_CHANNEL_ALLOC && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) - if (devparm) CONS_Printf("FMOD(Volume,Unknown): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (mod) - { - if (FMUSIC_GetType(mod) != FMUSIC_TYPE_NONE) - { - if (!FMUSIC_SetMasterVolume(mod, fmodvol) && devparm) - CONS_Printf("FMOD(Volume,FMUSIC_SetMasterVolume): %s\n", - FMOD_ErrorString(FSOUND_GetError())); - } - else if (devparm) - CONS_Printf("FMOD(Volume,FMUSIC_GetType): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - if (fmus) - { - if (!FSOUND_SetVolume(fsoundchannel, fmodvol)) - if (devparm) CONS_Printf("FMOD(Volume,FSOUND_SetVolume): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - } -#else - (void)volume; -#endif -} - - -// ---------- -// I_PlaySong -// Note: doesn't use the handle, would be useful to switch between mid's after -// some trigger (would do several RegisterSong, then PlaySong the chosen one) -// ---------- -boolean I_PlaySong(INT32 handle, INT32 bLooping) -{ - MMRESULT mmrRetVal; - - if (nomidimusic) - return false; - -#ifdef DEBUGMIDISTREAM - CONS_Printf("I_PlaySong: looping %d\n", bLooping); -#endif - - // unpause the song first if it was paused - if (bMidiPaused) - I_PauseSong(handle); - - // Clear the status of our callback so it will handle - // MOM_DONE callbacks once more - uCallbackStatus = 0; - bMidiPlaying = FALSE; - if ((mmrRetVal = midiStreamRestart(hStream)) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - Mid2StreamConverterCleanup(); - Mid2StreamFreeBuffers(); - midiStreamClose(hStream); - //I_Error("I_PlaySong: midiStreamRestart error"); - midiStreamOpen(&hStream, &uMIDIDeviceID, (DWORD)1, - (DWORD_PTR)MidiStreamCallback/*NULL*/, - (DWORD)0, CALLBACK_FUNCTION /*CALLBACK_NULL*/); - } - else bMidiPlaying = TRUE; - bMidiLooped = bLooping; - return bMidiPlaying; -} - - -// ----------- -// I_PauseSong -// calls midiStreamPause() to pause the midi playback -// ----------- -void I_PauseSong (INT32 handle) -{ - (void)handle; -#ifdef FMODSOUND - if (!nodigimusic) - { - if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_CHANNEL_ALLOC && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) - if (devparm) CONS_Printf("FMOD(Pause,Unknown): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (mod) - { - if (!FMUSIC_GetPaused(mod)) - if (!FMUSIC_SetPaused(mod, true)) - if (devparm) CONS_Printf("FMOD(Pause,FMUSIC_SetPaused): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - if (fmus) - { - if (!FSOUND_GetPaused(fsoundchannel)) - if (!FSOUND_SetPaused(fsoundchannel, true)) - if (devparm) CONS_Printf("FMOD(Pause,FSOUND_SetPaused): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - } -#endif - - if (nomidimusic) - return; - -#ifdef DEBUGMIDISTREAM - CONS_Printf("I_PauseSong: \n"); -#endif - - if (!bMidiPaused) - { - midiStreamPause(hStream); - bMidiPaused = true; - } -} - - -// ------------ -// I_ResumeSong -// un-pause the midi song with midiStreamRestart -// ------------ -void I_ResumeSong (INT32 handle) -{ - (void)handle; -#ifdef FMODSOUND - if (!nodigimusic) - { - if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_CHANNEL_ALLOC && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) - if (devparm) CONS_Printf("FMOD(Resume,Unknown): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (mod != NULL) - { - if (FMUSIC_GetPaused(mod)) - if (!FMUSIC_SetPaused(mod, false)) - if (devparm) CONS_Printf("FMOD(Resume,FMUSIC_SetPaused): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - if (fmus != NULL) - { - if (FSOUND_GetPaused(fsoundchannel)) - if (!FSOUND_SetPaused(fsoundchannel, false)) - if (devparm) CONS_Printf("FMOD(Resume,FSOUND_SetPaused): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - } -#endif - - if (nomidimusic) - return; - -#ifdef DEBUGMIDISTREAM - CONS_Printf("I_ResumeSong: \n"); -#endif - - if (bMidiPaused) - { - midiStreamRestart(hStream); - bMidiPaused = false; - } -} - - -// ---------- -// I_StopSong -// ---------- -// faB: -1999 is a special handle here, it means we stop the midi when exiting -// Legacy, this will do a midiOutReset() for a more 'sure' midi off. -void I_StopSong(INT32 handle) -{ - MMRESULT mmrRetVal; - - if (nomidimusic) - return; - -#ifdef DEBUGMIDISTREAM - CONS_Printf("I_StopSong: \n"); -#endif - - if (bMidiPlaying || (uCallbackStatus != STATUS_CALLBACKDEAD)) - { - bMidiPlaying = bMidiPaused = FALSE; - if (uCallbackStatus != STATUS_CALLBACKDEAD && - uCallbackStatus != STATUS_WAITINGFOREND) - uCallbackStatus = STATUS_KILLCALLBACK; - - //CONS_Printf("a: %d\n",I_GetTime()); - if ((mmrRetVal = midiStreamStop(hStream)) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - return; - } - - //faB: if we don't call midiOutReset() seems we have to stop the buffers - // ourselves (or it doesn't play anymore) - if (!bMidiPaused && (handle != SPECIAL_HANDLE_CLEANMIDI)) - { - midiStreamPause(hStream); - } - //CONS_Printf("b: %d\n",I_GetTime()); - else - //faB: this damn call takes 1 second and a half !!! still do it on exit - // to be sure everything midi is cleaned as much as possible - if (handle == SPECIAL_HANDLE_CLEANMIDI) - { - if ((mmrRetVal = midiOutReset((HMIDIOUT)hStream)) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - return; - } - } - //CONS_Printf("c: %d\n",I_GetTime()); - - // Wait for the callback thread to release this thread, which it will do by - // calling SetEvent() once all buffers are returned to it - if ((devparm) - && (WaitForSingleObject(hBufferReturnEvent, DEBUG_CALLBACK_TIMEOUT) - == WAIT_TIMEOUT)) - { - // Note, this is a risky move because the callback may be genuinely busy, but - // when we're debugging, it's safer and faster than freezing the application, - // which leaves the MIDI device locked up and forces a system reset... - CONS_Printf("Timed out waiting for MIDI callback\n"); - uCallbackStatus = STATUS_CALLBACKDEAD; - } - //CONS_Printf("d: %d\n",I_GetTime()); - } - - if (uCallbackStatus == STATUS_CALLBACKDEAD) - { - uCallbackStatus = 0; - Mid2StreamConverterCleanup(); - Mid2StreamFreeBuffers(); - //faB: we could close the stream here and re-open later to avoid - // a little quirk in mmsystem (see DirectX6 mstream note) - midiStreamClose(hStream); - midiStreamOpen(&hStream, &uMIDIDeviceID, (DWORD)1, - (DWORD_PTR)MidiStreamCallback/*NULL*/, - (DWORD)0, CALLBACK_FUNCTION /*CALLBACK_NULL*/); - } -} - -void I_StopDigSong(void) -{ -#ifdef FMODSOUND - if (!nodigimusic) - { - if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_INVALID_PARAM && FSOUND_GetError() != FMOD_ERR_CHANNEL_ALLOC && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) - if (devparm) CONS_Printf("FMOD(Stop,Unknown): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (mod) - { - if (FMUSIC_IsPlaying(mod)) - { - if (!FMUSIC_StopSong(mod)) - if (devparm) CONS_Printf("FMOD(Stop,FMUSIC_StopSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - } - if (fmus) - { - if (FSOUND_IsPlaying(fsoundchannel)) - { - if (!FSOUND_Stream_Stop(fmus)) - if (devparm) CONS_Printf("FMOD(Stop,FSOUND_Stream_Stop): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - } - //if (!FSOUND_StopSound(FSOUND_ALL)) - //if (FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) CONS_Printf("FMOD(Stop,FSOUND_StopSound): %s\n", FMOD_ErrorString(FSOUND_GetError())); - //FMUSIC_StopAllSongs(); - //if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) CONS_Printf("FMOD(Stop,FMUSIC_StopAllSongs): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } -#endif -} - -void I_UnRegisterSong(INT32 handle) -{ - handle = 0; - if (nomidimusic) - return; - - //faB: we might free here whatever is allocated per-music - // (but we don't cause I hate malloc's) - Mid2StreamConverterCleanup(); - -#ifdef DEBUGMIDISTREAM - CONS_Printf("I_UnregisterSong: \n"); -#endif -} - -int I_SetSongSpeed(unsigned int speed) -{ -#ifdef FMODSOUND - if (music_disabled || nodigimusic) - return 0; //there no music or FMOD is not loaded - - if((!fmus || !FSOUND_IsPlaying(fsoundchannel)) && (!mod || !FMUSIC_IsPlaying(mod))) - return 0; //there no FMOD music playing - - if (speed == 0) - return 1; //yes, we can set the speed - - if (fmus) - { - if (FSOUND_IsPlaying(fsoundchannel) - && !FSOUND_SetFrequency(fsoundchannel,(int)(((float)speed*(float)fsoundfreq)/100.0f))) - { - if (devparm) - CONS_Printf("FMOD(ChangeSpeed,FSOUND_SetFrequency): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - else - return 1; - } - else if (mod) - { - if (FMUSIC_IsPlaying(mod) - && !FMUSIC_SetMasterSpeed(mod,(float)speed/100.0f)) - { - if (devparm) - CONS_Printf("FMOD(ChangeSpeed,FMUSIC_SetMasterSpeed): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - else - return 1; - } -#else - (void)speed; -#endif - return 0; -} - -// Special FMOD support Tails 11-21-2002 -boolean I_StartDigSong(const char *musicname, INT32 looping) -{ -#ifdef FMODSOUND - char filename[9]; - void *data; - int lumpnum; - - if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_CHANNEL_ALLOC && - FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER && FSOUND_GetError() != FMOD_ERR_INVALID_PARAM) - if (devparm) CONS_Printf("FMOD(Start,Unknown): %s\n", FMOD_ErrorString(FSOUND_GetError())); - - if (fmus) - { - if (FSOUND_IsPlaying(fsoundchannel)) - if (!FSOUND_Stream_Stop(fmus)) - if (devparm) CONS_Printf("FMOD(Start,FSOUND_Stream_Stop): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (!FSOUND_Stream_Close(fmus)) - if (devparm) CONS_Printf("FMOD(Start,FSOUND_Stream_Close): %s\n", FMOD_ErrorString(FSOUND_GetError())); - fsoundchannel = -1; - fmus = NULL; - } - if (mod) - { - if (FMUSIC_IsPlaying(mod)) - if (!FMUSIC_StopSong(mod)) - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_StopSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (!FMUSIC_FreeSong(mod)) - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_FreeSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - mod = NULL; - } - //if (!FSOUND_StopSound(FSOUND_ALL)) - //if (FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) CONS_Printf("FMOD(Start,FSOUND_StopSound): %s\n", FMOD_ErrorString(FSOUND_GetError())); - //FMUSIC_StopAllSongs(); - //if (FSOUND_GetError() != FMOD_ERR_NONE && FSOUND_GetError() != FMOD_ERR_MEDIAPLAYER) CONS_Printf("FMOD(Start,FMUSIC_StopAllSongs): %s\n", FMOD_ErrorString(FSOUND_GetError())); - - // Create the filename we need - sprintf(filename, "o_%s", musicname); - - lumpnum = W_CheckNumForName(filename); - - if (lumpnum == -1) - { - // Graue 02-29-2004: don't worry about missing music, there might still be a MIDI - return false; // No music found. Oh well! - } - - data = W_CacheLumpName (filename, PU_CACHE); - - I_SaveMemToFile (data, W_LumpLength(lumpnum), "fmod.tmp"); - - Z_Free(data); - - mod = FMUSIC_LoadSong("fmod.tmp"); - - if (FSOUND_GetError() != FMOD_ERR_NONE) - { - if (FSOUND_GetError() != FMOD_ERR_FILE_FORMAT) - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_LoadSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - - if (mod) - { - if (FMUSIC_IsPlaying(mod)) - if (!FMUSIC_StopSong(mod)) - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_StopSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - if (!FMUSIC_FreeSong(mod)) - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_FreeSong): %s\n", FMOD_ErrorString(FSOUND_GetError())); - mod = NULL; - } - } - - if (mod) - { - if (!FMUSIC_SetLooping(mod, (signed char)looping)) - { - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_SetLooping): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } -// else if (FMUSIC_GetType(mod) == FMUSIC_TYPE_MOD || FMUSIC_GetType(mod) == FMUSIC_TYPE_S3M) -// { -// if (!FMUSIC_SetPanSeperation(mod, 0.85f)) /* 15% crossover */ -// CONS_Printf("FMOD(Start,FMUSIC_SetPanSeperation): %s\n", FMOD_ErrorString(FSOUND_GetError())); -// } - else if (!FMUSIC_SetPanSeperation(mod, 0.0f)) - { - if (devparm) CONS_Printf("FMOD(Start,FMUSIC_SetPanSeperation): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - } - else - { - fmus = FSOUND_Stream_OpenFile("fmod.tmp", ((looping) ? (FSOUND_LOOP_NORMAL) : (0)),0); - if (fmus == NULL) - { - if (devparm) CONS_Printf("FMOD(Start,FSOUND_Stream_Open): %s\n", FMOD_ErrorString(FSOUND_GetError())); - return false; - } - } - - // Scan the Ogg Vorbis file for the COMMENT= field for a custom loop point - if (fmus && looping) - { - int scan; - char *dataum; - char looplength[64]; - unsigned int loopstart = 0; - int newcount = 0; - const int freq = 44100; - int lumplength = W_LumpLength(lumpnum); - int length = FSOUND_Stream_GetLengthMs(fmus); - - if (length == 0) - { - if (devparm) CONS_Printf("FMOD(Start,FSOUND_Stream_GetLengthMs): %s\n", FMOD_ErrorString(FSOUND_GetError())); - } - else - { - //freq = FSOUND_GetFrequency(fsoundchannel); - - data = W_CacheLumpName (filename, PU_CACHE); - - dataum = (char *)data; - - for (scan = 0;scan < lumplength; scan++) - { - if (*dataum++ == 'C'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'M'){ - if (*dataum++ == 'M'){ - if (*dataum++ == 'E'){ - if (*dataum++ == 'N'){ - if (*dataum++ == 'T'){ - if (*dataum++ == '='){ - if (*dataum++ == 'L'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'P'){ - if (*dataum++ == 'P'){ - if (*dataum++ == 'O'){ - if (*dataum++ == 'I'){ - if (*dataum++ == 'N'){ - if (*dataum++ == 'T'){ - if (*dataum++ == '=') - { - - while (*dataum != 1 && newcount != 63) - { - looplength[newcount++] = *dataum++; - } - - looplength[newcount] = '\n'; - - loopstart = atoi(looplength); - } - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - else - dataum--;} - } - - Z_Free(data); - } - - if (loopstart > 0) - { - const unsigned int loopend = (unsigned int)((freq/1000.0f)*length-(freq/1000.0f)); - //const unsigned int loopend = (((freq/2)*length)/500)-8; - if (!FSOUND_Stream_SetLoopPoints(fmus, loopstart, loopend) && devparm) - CONS_Printf("FMOD(Start,FSOUND_Stream_SetLoopPoints): %s\n", - FMOD_ErrorString(FSOUND_GetError())); - } - } - - /* - PLAY SONG - */ - if (mod) - { - if (FMUSIC_PlaySong(mod)) - { - fsoundchannel = -1; - I_SetDigMusicVolume(-1); - return true; - } - else - { - if (devparm) - CONS_Printf("FMOD(Start,FMUSIC_PlaySong): %s\n", - FMOD_ErrorString(FSOUND_GetError())); - return false; - } - } - if (fmus) - { - fsoundchannel = FSOUND_Stream_PlayEx(FSOUND_FREE, fmus, NULL, TRUE); - - if (fsoundchannel == -1) - { - if (devparm) - CONS_Printf("FMOD(Start,FSOUND_Stream_PlayEx): %s\n", - FMOD_ErrorString(FSOUND_GetError())); - return false; - } - else if (!FSOUND_SetPaused(fsoundchannel, FALSE)) - { - if (devparm) - CONS_Printf("FMOD(Start,FSOUND_SetPaused): %s\n", - FMOD_ErrorString(FSOUND_GetError())); - return false; - } - - I_SetDigMusicVolume(-1); - fsoundfreq = FSOUND_GetFrequency(fsoundchannel); - return true; - } -#else - (void)musicname; - (void)looping; -#endif - return false; - -///////////////////////////////////////////////////////////////////////////////// -} - -// -------------- -// I_RegisterSong -// Prepare a song for playback -// - setup midi stream buffers, and activate the callback procedure -// which will continually fill the buffers with new data -// -------------- - -INT32 I_RegisterSong(void *data, int len) -{ - char *pMidiFileData = NULL; // MIDI music buffer to be played or NULL - - if (nomidimusic) - return 1; - if (!data || !len) - return 0; - -#ifdef DEBUGMIDISTREAM - CONS_Printf("I_RegisterSong: \n"); -#endif - // check for MID format file - if (!memcmp(data, "MThd", 4)) - pMidiFileData = data; - else - { - CONS_Printf("Music lump is not MID music format\n"); - return 0; - } - -#ifdef DEBUGMIDISTREAM - I_SaveMemToFile(pMidiFileData, len, "debug.mid"); -#endif - - // setup midi stream buffer - if (StreamBufferSetup((LPBYTE)pMidiFileData, len)) - { - Mid2StreamConverterCleanup(); - I_Error("I_RegisterSong: StreamBufferSetup FAILED"); - } - - return 1; -} - -// ----------------- -// StreamBufferSetup -// This function uses the filename stored in the global character array to -// open a MIDI file. Then it goes about converting at least the first part of -// that file into a midiStream buffer for playback. -// ----------------- - -// ----------------- -// StreamBufferSetup -// - returns TRUE if a problem occurs -// ----------------- -static BOOL StreamBufferSetup(LPBYTE pMidiData, size_t iMidiSize) -{ - MMRESULT mmrRetVal; - MIDIPROPTIMEDIV mptd; - BOOL bFoundEnd = FALSE; - int dwConvertFlag, nChkErr, idx; - -#ifdef DEBUGMIDISTREAM - if (hStream == NULL) - I_Error("StreamBufferSetup: hStream is NULL!"); -#endif - - // pause midi stream before manipulating the buffers - midiStreamPause(hStream); - - // allocate the stream buffers (only once) - for (idx = 0; idx < NUM_STREAM_BUFFERS; idx++) - { - ciStreamBuffers[idx].mhBuffer.dwBufferLength = OUT_BUFFER_SIZE; - if (!ciStreamBuffers[idx].mhBuffer.lpData) - { - ciStreamBuffers[idx].mhBuffer.lpData = GlobalAllocPtr(GHND, OUT_BUFFER_SIZE); - if (!ciStreamBuffers[idx].mhBuffer.lpData) - return FALSE; - } - } - - // returns TRUE in case of conversion error - if (Mid2StreamConverterInit(pMidiData, iMidiSize)) - return TRUE; - - // Initialize the volume cache array to some pre-defined value - for (idx = 0; idx < MAX_MIDI_IN_TRACKS; idx++) - dwVolCache[idx] = VOL_CACHE_INIT; - - mptd.cbStruct = sizeof (mptd); - mptd.dwTimeDiv = ifs.dwTimeDivision; - if ((mmrRetVal = midiStreamProperty(hStream, (LPBYTE)&mptd, MIDIPROP_SET|MIDIPROP_TIMEDIV)) - != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - return TRUE; - } - - nEmptyBuffers = 0; - dwConvertFlag = CONVERTF_RESET; - - for (nCurrentBuffer = 0; nCurrentBuffer < NUM_STREAM_BUFFERS; nCurrentBuffer++) - { - // Tell the converter to convert up to one entire buffer's length of output - // data. Also, set a flag so it knows to reset any saved state variables it - // may keep from call to call. - ciStreamBuffers[nCurrentBuffer].dwStartOffset = 0; - ciStreamBuffers[nCurrentBuffer].dwMaxLength = OUT_BUFFER_SIZE; - ciStreamBuffers[nCurrentBuffer].tkStart = 0; - ciStreamBuffers[nCurrentBuffer].bTimesUp = FALSE; - - if ((nChkErr = Mid2StreamConvertToBuffer(dwConvertFlag, &ciStreamBuffers[nCurrentBuffer])) - != CONVERTERR_NOERROR) - { - if (nChkErr == CONVERTERR_DONE) - bFoundEnd = TRUE; - else - { - CONS_Printf("StreamBufferSetup: initial conversion pass failed\n"); - return TRUE; - } - } - ciStreamBuffers[nCurrentBuffer].mhBuffer.dwBytesRecorded - = ciStreamBuffers[nCurrentBuffer].dwBytesRecorded; - - if (!bBuffersPrepared) - { - if ((mmrRetVal = midiOutPrepareHeader((HMIDIOUT)hStream, - &ciStreamBuffers[nCurrentBuffer].mhBuffer, sizeof (MIDIHDR))) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - return TRUE; - } - } - if ((mmrRetVal = midiStreamOut(hStream, &ciStreamBuffers[nCurrentBuffer].mhBuffer, - sizeof (MIDIHDR))) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - break; - } - dwConvertFlag = 0; - - if (bFoundEnd) - break; - } - - bBuffersPrepared = TRUE; - nCurrentBuffer = 0; - - // MIDI volume - dwVolumePercent = (cv_midimusicvolume.value * 1000) / 32; - if (hStream) - SetAllChannelVolumes(dwVolumePercent); - - return FALSE; -} - -// ---------------- -// SetChannelVolume -// Call here delayed by MIDI stream callback, to adapt the volume event of the -// midi stream to our own set volume percentage. -// ---------------- -void I_SetMidiChannelVolume(DWORD dwChannel, DWORD dwVolumePercent) -{ - DWORD dwEvent, dwVol; - MMRESULT mmrRetVal; - - if (!bMidiPlaying) - return; - - dwVol = (dwVolCache[dwChannel] * dwVolumePercent) / 1000; - dwEvent = MIDI_CTRLCHANGE|dwChannel|((DWORD)MIDICTRL_VOLUME << 8)|((DWORD)dwVol << 16); - if ((mmrRetVal = midiOutShortMsg((HMIDIOUT)hStream, dwEvent)) != MMSYSERR_NOERROR) - { -#ifdef DEBUGMIDISTREAM - MidiErrorMessageBox(mmrRetVal); -#endif - return; - } -} - -// ------------------ -// MidiStreamCallback -// This is the callback handler which continually refills MIDI data buffers -// as they're returned to us from the audio subsystem. -// ------------------ -static void CALLBACK MidiStreamCallback(HMIDIIN hMidi, UINT uMsg, DWORD dwInstance, - DWORD dwParam1, DWORD dwParam2) -{ - MMRESULT mmrRetVal; - int nChkErr; - MIDIEVENT* pme; - MIDIHDR* pmh; - - hMidi = NULL; - dwParam1 = dwParam2 = dwInstance = 0; - switch (uMsg) - { - case MOM_DONE: - // dwParam1 is LPMIDIHDR - if (uCallbackStatus == STATUS_CALLBACKDEAD) - return; - - nEmptyBuffers++; - - // we reached end of song, but we wait until all the buffers are returned - if (uCallbackStatus == STATUS_WAITINGFOREND) - { - if (nEmptyBuffers < NUM_STREAM_BUFFERS) - return; - else - { - // stop the song when end reached (was not looping) - uCallbackStatus = STATUS_CALLBACKDEAD; - SetEvent(hBufferReturnEvent); - I_StopSong(0); - return; - } - } - - // This flag is set whenever the callback is waiting for all buffers to come back. - if (uCallbackStatus == STATUS_KILLCALLBACK) - { - // Count NUM_STREAM_BUFFERS-1 being returned for the last time - if (nEmptyBuffers < NUM_STREAM_BUFFERS) - return; - // Then send a stop message when we get the last buffer back... - else - { - // Change the status to callback dead - uCallbackStatus = STATUS_CALLBACKDEAD; - SetEvent(hBufferReturnEvent); - return; - } - } - - dwProgressBytes += ciStreamBuffers[nCurrentBuffer].mhBuffer.dwBytesRecorded; - - // ------------------------------------------------- - // Fill an available buffer with audio data again... - // ------------------------------------------------- - - if (bMidiPlaying && nEmptyBuffers) - { - ciStreamBuffers[nCurrentBuffer].dwStartOffset = 0; - ciStreamBuffers[nCurrentBuffer].dwMaxLength = OUT_BUFFER_SIZE; - ciStreamBuffers[nCurrentBuffer].tkStart = 0; - ciStreamBuffers[nCurrentBuffer].dwBytesRecorded = 0; - ciStreamBuffers[nCurrentBuffer].bTimesUp = FALSE; - - if ((nChkErr = Mid2StreamConvertToBuffer(0, &ciStreamBuffers[nCurrentBuffer])) - != CONVERTERR_NOERROR) - { - if (nChkErr == CONVERTERR_DONE) - { - // Don't include this one in the count - uCallbackStatus = STATUS_WAITINGFOREND; - return; - } - else - { - // We're not in the main thread, so we can't call I_Error() now. - // Log the error message out, and post exit message. - CONS_Printf("MidiStreamCallback(): conversion pass failed!\n"); - PostMessage(hWndMain, WM_CLOSE, 0, 0); - return; - } - } - - ciStreamBuffers[nCurrentBuffer].mhBuffer.dwBytesRecorded - = ciStreamBuffers[nCurrentBuffer].dwBytesRecorded; - - if ((mmrRetVal = midiStreamOut(hStream, &ciStreamBuffers[nCurrentBuffer].mhBuffer, - sizeof (MIDIHDR))) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - Mid2StreamConverterCleanup(); - return; - } - - nCurrentBuffer = (nCurrentBuffer + 1) % NUM_STREAM_BUFFERS; - nEmptyBuffers--; - } - - break; - case MOM_POSITIONCB: - pmh = (MIDIHDR*)(size_t)dwParam1; - pme = (MIDIEVENT*)(pmh->lpData + pmh->dwOffset); - if (MIDIEVENT_TYPE(pme->dwEvent) == MIDI_CTRLCHANGE) - { -#ifdef DEBUGMIDISTREAM - if (MIDIEVENT_DATA1(pme->dwEvent) == MIDICTRL_VOLUME_LSB) - { - CONS_Printf("Got an LSB volume event\n"); - PostMessage(hWndMain, WM_CLOSE, 0, 0); // can't I_Error() here - break; - } -#endif - // this is meant to respond to our own intention, from mid2strm.c - if (MIDIEVENT_DATA1(pme->dwEvent) != MIDICTRL_VOLUME) - break; - - // Mask off the channel number and cache the volume data byte - dwVolCache[MIDIEVENT_CHANNEL(pme->dwEvent)] = MIDIEVENT_VOLUME(pme->dwEvent); - // call SetChannelVolume() later to adjust MIDI volume control message to our - // own current volume level. - PostMessage(hWndMain, WM_MSTREAM_UPDATEVOLUME, - MIDIEVENT_CHANNEL(pme->dwEvent), 0L); - } - break; - default: - break; - } - - return; -} - -// --------------------- -// Mid2StreamFreeBuffers -// This function unprepares and frees all our buffers -- something we must -// do to work around a bug in MMYSYSTEM that prevents a device from playing -// back properly unless it is closed and reopened after each stop. -// --------------------- -static void Mid2StreamFreeBuffers(void) -{ - DWORD idx; - MMRESULT mmrRetVal; - - if (bBuffersPrepared) - { - for (idx = 0; idx < NUM_STREAM_BUFFERS; idx++) - { - if ((mmrRetVal = midiOutUnprepareHeader((HMIDIOUT)hStream, - &ciStreamBuffers[idx].mhBuffer, sizeof (MIDIHDR))) != MMSYSERR_NOERROR) - { - MidiErrorMessageBox(mmrRetVal); - } - } - bBuffersPrepared = FALSE; - } - - // Don't free the stream buffers here, but rather allocate them once at startup, - // and free them at shutdown. -} diff --git a/src/win32ce/win_sys.c b/src/win32ce/win_sys.c deleted file mode 100644 index 3b6a47258..000000000 --- a/src/win32ce/win_sys.c +++ /dev/null @@ -1,3542 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief win32 system i/o -/// -/// Startup & Shutdown routines for music,sound,timer,keyboard,... -/// Signal handler to trap errors and exit cleanly. - -#include "../doomdef.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "../m_misc.h" -#include "../i_video.h" -#include "../i_sound.h" -#include "../i_system.h" - -#include "../d_net.h" -#include "../g_game.h" - -#include "../d_main.h" - -#include "../m_argv.h" - -#include "../w_wad.h" -#include "../z_zone.h" -#include "../g_input.h" - -#include "../keys.h" - -#include "../screen.h" - -// Wheel support for Win95/WinNT3.51 -#include - -// Taken from Win98/NT4.0 -#ifndef SM_MOUSEWHEELPRESENT -#define SM_MOUSEWHEELPRESENT 75 -#endif - -#ifndef MSH_MOUSEWHEEL -#ifdef UNICODE -#define MSH_MOUSEWHEEL L"MSWHEEL_ROLLMSG" -#else -#define MSH_MOUSEWHEEL "MSWHEEL_ROLLMSG" -#endif -#endif - -#include "win_main.h" -#include "../i_joy.h" - -#define DIRECTINPUT_VERSION 0x700 -// Force dinput.h to generate old DX3 headers. -#define DXVERSION_NTCOMPATIBLE 0x0300 -#include - -#include "fabdxlib.h" - -#ifdef __DEBUG__ -#undef NDEBUG -#endif - -/// \brief max number of joystick buttons -#define JOYBUTTONS_MAX 32 // rgbButtons[32] -/// \brief max number of joystick button events -#define JOYBUTTONS_MIN min((JOYBUTTONS),(JOYBUTTONS_MAX)) - -/// \brief max number of joysick axies -#define JOYAXISSET_MAX 4 // (lX, lY), (lZ,lRx), (lRy, lRz), rglSlider[2] is very diff -/// \brief max number ofjoystick axis events -#define JOYAXISSET_MIN min((JOYAXISSET),(JOYAXISSET_MAX)) - -/// \brief max number of joystick hats -#define JOYHATS_MAX 4 // rgdwPOV[4]; -/// \brief max number of joystick hat events -#define JOYHATS_MIN min((JOYHATS),(JOYHATS_MAX)) - -/// \brief max number of mouse buttons -#define MOUSEBUTTONS_MAX 8 // 8 bit of BYTE and DIMOFS_BUTTON7 -/// \brief max number of muse button events -#define MOUSEBUTTONS_MIN min((MOUSEBUTTONS),(MOUSEBUTTONS_MAX)) - -// ================== -// DIRECT INPUT STUFF -// ================== -BOOL bDX0300; // if true, we created a DirectInput 0x0300 version -static LPDIRECTINPUT lpDI = NULL; -static LPDIRECTINPUTDEVICE lpDIK = NULL; // Keyboard -static LPDIRECTINPUTDEVICE lpDIM = NULL; // mice -static LPDIRECTINPUTDEVICE lpDIJ = NULL; // joystick 1P -static LPDIRECTINPUTEFFECT lpDIE[NumberofForces]; // joystick 1Es -static LPDIRECTINPUTDEVICE2 lpDIJA = NULL; // joystick 1I -static LPDIRECTINPUTDEVICE lpDIJ2 = NULL; // joystick 2P -static LPDIRECTINPUTEFFECT lpDIE2[NumberofForces]; // joystick 1Es -static LPDIRECTINPUTDEVICE2 lpDIJ2A = NULL;// joystick 2I - -// Do not execute cleanup code more than once. See Shutdown_xxx() routines. -UINT8 graphics_started = 0; -UINT8 keyboard_started = 0; -UINT8 sound_started = 0; -static boolean mouse_enabled = false; -static boolean joystick_detected = false; -static boolean joystick2_detected = false; - -static void I_ShutdownKeyboard(void); -static void I_GetKeyboardEvents(void); -static void I_ShutdownJoystick(void); -static void I_ShutdownJoystick2 (void); - -static boolean entering_con_command = false; - -// -// Why would this be system specific?? hmmmm.... -// -// it is for virtual reality system, next incoming feature :) -static ticcmd_t emptycmd; -ticcmd_t *I_BaseTiccmd(void) -{ - return &emptycmd; -} - -static ticcmd_t emptycmd2; -ticcmd_t *I_BaseTiccmd2(void) -{ - return &emptycmd2; -} - -// Allocates the base zone memory, -// this function returns a valid pointer and size, -// else it should interrupt the program immediately. -// -// now checks if mem could be allocated, this is still -// prehistoric... there's a lot to do here: memory locking, detection -// of win95 etc... -// - -BOOL win9x; - -/** \brief WinNT system platform -*/ -static BOOL winnt; - -static void I_DetectWin9x(void) -{ - OSVERSIONINFO osvi; - - osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); - GetVersionEx(&osvi); - - winnt = (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT); - // 95 or 98 what the hell - win9x = true; -} - -// return free and total memory in the system -UINT32 I_GetFreeMem(UINT32* total) -{ - MEMORYSTATUS info; - - info.dwLength = sizeof (MEMORYSTATUS); - GlobalMemoryStatus(&info); - if (total) - *total = (ULONG)info.dwTotalPhys; - return (ULONG)info.dwAvailPhys; -} - -// --------- -// I_Profile -// Two little functions to profile our code using the high resolution timer -// --------- -static LARGE_INTEGER ProfileCount; -void I_BeginProfile(void) -{ - if (!QueryPerformanceCounter(&ProfileCount)) - I_Error("I_BeginProfile failed"); // can't profile without the high res timer -} - -// we're supposed to use this to measure very small amounts of time, -// that's why we return a DWORD and not a 64bit value -DWORD I_EndProfile(void) -{ - LARGE_INTEGER CurrTime; - DWORD ret; - if (!QueryPerformanceCounter (&CurrTime)) - I_Error("I_EndProfile failed"); - if (CurrTime.QuadPart - ProfileCount.QuadPart > (LONGLONG)0xFFFFFFFFUL) - I_Error("I_EndProfile overflow"); - ret = (DWORD)(CurrTime.QuadPart - ProfileCount.QuadPart); - // we can call I_EndProfile() several time, I_BeginProfile() need be called just once - ProfileCount = CurrTime; - - return ret; -} - -// --------- -// I_GetTime -// Use the High Resolution Timer if available, -// else use the multimedia timer which has 1 millisecond precision on Windowz 95, -// but lower precision on Windows NT -// --------- -static long hacktics = 0; // used locally for keyboard repeat keys -static DWORD starttickcount = 0; // hack for win2k time bug - -tic_t I_GetTime(void) -{ - tic_t newtics = 0; - - if (!starttickcount) // high precision timer - { - LARGE_INTEGER currtime; // use only LowPart if high resolution counter is not available - static LARGE_INTEGER basetime = {{0, 0}}; - - // use this if High Resolution timer is found - static LARGE_INTEGER frequency; - - if (!basetime.LowPart) - { - if (!QueryPerformanceFrequency(&frequency)) - frequency.QuadPart = 0; - else - QueryPerformanceCounter(&basetime); - } - - if (frequency.LowPart && QueryPerformanceCounter(&currtime)) - { - newtics = (int)((currtime.QuadPart - basetime.QuadPart) * TICRATE - / frequency.QuadPart); - } - else - { - currtime.LowPart = timeGetTime(); - if (!basetime.LowPart) - basetime.LowPart = currtime.LowPart; - newtics = ((currtime.LowPart - basetime.LowPart)/(1000/TICRATE)); - } - } - else - newtics = (GetTickCount() - starttickcount)/(1000/TICRATE); - - hacktics = newtics; // a local counter for keyboard repeat key - return newtics; -} - - -void I_Sleep(void) -{ - if (cv_sleep.value != -1) - Sleep(cv_sleep.value); -} - - -// should move to i_video -void I_WaitVBL(INT32 count) -{ - count = 0; -} - -// this is probably to activate the 'loading' disc icon -// it should set a flag, that I_FinishUpdate uses to know -// whether it draws a small 'loading' disc icon on the screen or not -// -// also it should explicitly draw the disc because the screen is -// possibly not refreshed while loading -// -void I_BeginRead(void) {} - -// see above, end the 'loading' disc icon, set the flag false -// -void I_EndRead(void) {} - -// =========================================================================================== -// EVENTS -// =========================================================================================== -static inline BOOL I_ReadyConsole(HANDLE ci) -{ - DWORD gotinput; - if (ci == (HANDLE)-1) return FALSE; - if (WaitForSingleObject(ci,0) != WAIT_OBJECT_0) return FALSE; - if (GetFileType(ci) != FILE_TYPE_CHAR) return FALSE; - return (GetNumberOfConsoleInputEvents(ci, &gotinput) && gotinput); -} - -static inline VOID I_GetConsoleEvents(VOID) -{ - event_t ev = {0,0,0,0}; - HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - CONSOLE_SCREEN_BUFFER_INFO CSBI; - INPUT_RECORD input; - DWORD t; - - while (I_ReadyConsole(ci) && ReadConsoleInput(ci, &input, 1, &t) && t) - { - memset(&ev,0x00,sizeof (ev)); - switch (input.EventType) - { - case KEY_EVENT: - if (input.Event.KeyEvent.bKeyDown) - { - ev.type = ev_console; - entering_con_command = true; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_ESCAPE: - case VK_TAB: - ev.data1 = KEY_NULL; - break; - case VK_SHIFT: - ev.data1 = KEY_SHIFT; - break; - case VK_RETURN: - entering_con_command = false; - // Fall through. - default: - ev.data1 = MapVirtualKey(input.Event.KeyEvent.wVirtualKeyCode,2); // convert in to char - } - if (co != (HANDLE)-1 && GetFileType(co) == FILE_TYPE_CHAR) - { - if (ev.data1 && ev.data1 != KEY_SHIFT) - { -#ifdef _UNICODE - WriteConsole(co, &input.Event.KeyEvent.uChar.UnicodeChar, 1, &t, NULL); -#else - WriteConsole(co, &input.Event.KeyEvent.uChar.AsciiChar, 1, &t, NULL); -#endif - } - if (input.Event.KeyEvent.wVirtualKeyCode == VK_BACK - && GetConsoleScreenBufferInfo(co,&CSBI)) - { - WriteConsoleOutputCharacterA(co, " ",1, CSBI.dwCursorPosition, &t); - } - } - } - else - { - ev.type = ev_keyup; - switch (input.Event.KeyEvent.wVirtualKeyCode) - { - case VK_SHIFT: - ev.data1 = KEY_SHIFT; - break; - default: - break; - } - } - if (ev.data1) D_PostEvent(&ev); - break; - case MOUSE_EVENT: - case WINDOW_BUFFER_SIZE_EVENT: - case MENU_EVENT: - case FOCUS_EVENT: - break; - } - } -} - -// ---------- -// I_GetEvent -// Post new events for all sorts of user-input -// ---------- -void I_GetEvent(void) -{ - I_GetConsoleEvents(); - I_GetKeyboardEvents(); - I_GetMouseEvents(); - I_GetJoystickEvents(); - I_GetJoystick2Events(); -} - -// ---------- -// I_OsPolling -// ---------- -void I_OsPolling(void) -{ - MSG msg; - HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); - - // we need to dispatch messages to the window - // so the window procedure can respond to messages and PostEvent() for keys - // during D_SRB2Main startup. - // this one replaces the main loop of windows since I_OsPolling is called in the main loop - do - { - while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) - { - if (GetMessage(&msg, NULL, 0, 0)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - else // winspec : this is quit message - I_Quit(); - } - if (!appActive && !netgame && !I_ReadyConsole(ci)) - WaitMessage(); - } while (!appActive && !netgame && !I_ReadyConsole(ci)); - - // this is called by the network synchronization, - // check keys and allow escaping - I_GetEvent(); - - // reset "emulated keys" - gamekeydown[KEY_MOUSEWHEELUP] = 0; - gamekeydown[KEY_MOUSEWHEELDOWN] = 0; -} - -// =========================================================================================== -// TIMER -// =========================================================================================== - -static void I_ShutdownTimer(void) -{ - timeEndPeriod(1); -} - -// -// Installs the timer interrupt handler with timer speed as TICRATE. -// -#define TIMER_ID 1 -#define TIMER_RATE (1000/TICRATE) -void I_StartupTimer(void) -{ - // for win2k time bug - if (M_CheckParm("-gettickcount")) - { - starttickcount = GetTickCount(); - CONS_Printf("Using GetTickCount()\n"); - } - timeBeginPeriod(1); - I_AddExitFunc(I_ShutdownTimer); -} - -// =========================================================================================== -// EXIT CODE, ERROR HANDLING -// =========================================================================================== - -static int errorcount = 0; // phuck recursive errors -static int shutdowning = false; - -// -// Used to trap various signals, to make sure things get shut down cleanly. -// -#ifdef NDEBUG -static void signal_handler(int num) -{ - //static char msg[] = "oh no! back to reality!\r\n"; - const char *sigmsg; - char sigdef[64]; - - D_QuitNetGame(); // Fix server freezes - I_ShutdownSystem(); - - switch (num) - { - case SIGINT: - sigmsg = "interrupt"; - break; - case SIGILL: - sigmsg = "illegal instruction - invalid function image"; - break; - case SIGFPE: - sigmsg = "floating point exception"; - break; - case SIGSEGV: - sigmsg = "segment violation"; - break; - case SIGTERM: - sigmsg = "software termination signal from kill"; - break; - case SIGBREAK: - sigmsg = "Ctrl-Break sequence"; - break; - case SIGABRT: - sigmsg = "abnormal termination triggered by abort call"; - break; - default: - sprintf(sigdef, "signal number %d", num); - sigmsg = sigdef; - } - -#ifdef LOGMESSAGES - if (logstream != INVALID_HANDLE_VALUE) - { - I_OutputMsg("signal_handler() error: %s\r\n", sigmsg); - CloseHandle(logstream); - logstream = INVALID_HANDLE_VALUE; - } -#endif - - MessageBoxA(hWndMain, va("signal_handler(): %s", sigmsg), "SRB2 error", MB_OK|MB_ICONERROR); - - signal(num, SIG_DFL); // default signal action - raise(num); -} -#endif - -// -// put an error message (with format) on stderr -// -void I_OutputMsg(const char *fmt, ...) -{ - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD bytesWritten; - va_list argptr; - char txt[8192]; - - va_start(argptr,fmt); - vsprintf(txt, fmt, argptr); - va_end(argptr); - - OutputDebugStringA(txt); - if (co != (HANDLE)-1) - { - if (GetFileType(co) == FILE_TYPE_CHAR) - { - static COORD coordNextWrite = {0,0}; - char *oldLines = NULL; - DWORD oldLength = 0; - CONSOLE_SCREEN_BUFFER_INFO csbi; - - // Save the lines that we're going to obliterate. - GetConsoleScreenBufferInfo(co, &csbi); - oldLength = csbi.dwSize.X * (csbi.dwCursorPosition.Y - coordNextWrite.Y) + csbi.dwCursorPosition.X - coordNextWrite.X; - - if(oldLength > 0) - { - char *blank = malloc(oldLength); - oldLines = malloc(oldLength); - if(!oldLines || !blank) return; - - ReadConsoleOutputCharacterA(co, oldLines, oldLength, coordNextWrite, &bytesWritten); - - // Move to where we what to print - which is where we would've been, - // had console input not been in the way, - SetConsoleCursorPosition(co, coordNextWrite); - - // Blank out. - memset(blank, ' ', oldLength); - WriteConsoleA(co, blank, oldLength, &bytesWritten, NULL); - free(blank); - - // And back to where we want to print again. - SetConsoleCursorPosition(co, coordNextWrite); - } - - // Actually write the string now! - WriteConsoleA(co, txt, (DWORD)strlen(txt), &bytesWritten, NULL); - - // Next time, output where we left off. - GetConsoleScreenBufferInfo(co, &csbi); - coordNextWrite = csbi.dwCursorPosition; - - // Restore what was overwritten. - if(oldLines && entering_con_command) - { - WriteConsoleA(co, oldLines, oldLength, &bytesWritten, NULL); - free(oldLines); - } - } - else // Redirected to a file. - WriteFile(co, txt, (DWORD)strlen(txt), &bytesWritten, NULL); - } - -#ifdef LOGMESSAGES - if (logstream != (HANDLE)-1) - WriteFile (logstream, txt, (DWORD)strlen(txt), &bytesWritten, NULL); -#endif -} - -// display error messy after shutdowngfx -// -void I_Error(const char *error, ...) -{ - va_list argptr; - char txt[8192]; - - // added 11-2-98 recursive error detecting - if (shutdowning) - { - errorcount++; - // try to shutdown each subsystem separately - if (errorcount == 5) - I_ShutdownGraphics(); - if (errorcount == 6) - I_ShutdownSystem(); - if (errorcount == 7) - { - M_SaveConfig(NULL); - G_SaveGameData(); - } - if (errorcount > 20) - { - // Don't print garbage - va_start(argptr,error); - vsprintf(txt, error, argptr); - va_end(argptr); - - MessageBoxA(hWndMain, txt, "SRB2 Recursive Error", MB_OK|MB_ICONERROR); - exit(-1); // recursive errors detected - } - } - shutdowning = true; - - // put message to stderr - va_start(argptr, error); - wvsprintfA(txt, error, argptr); - va_end(argptr); - - CONS_Printf("I_Error(): %s\n", txt); - - // uncomment this line to print to stderr as well - //wsprintf(stderr, "I_Error(): %s\n", txt); - - // saving one time is enough! - if (!errorcount) - { - M_SaveConfig(NULL); // save game config, cvars.. - G_SaveGameData(); - } - - // save demo, could be useful for debug - // NOTE: demos are normally not saved here. - if (demorecording) - G_CheckDemoStatus(); - - D_QuitNetGame(); - - // shutdown everything that was started - I_ShutdownSystem(); - -#ifdef LOGMESSAGES - if (logstream != INVALID_HANDLE_VALUE) - { - CloseHandle(logstream); - logstream = INVALID_HANDLE_VALUE; - } -#endif - - MessageBoxA(hWndMain, txt, "SRB2 Error", MB_OK|MB_ICONERROR); - - exit(-1); -} - -static inline VOID ShowEndTxt(HANDLE co) -{ - int i; - UINT16 j, att = 0; - int nlflag = 1; - CONSOLE_SCREEN_BUFFER_INFO backupcon; - COORD resizewin = {80,-1}; - DWORD bytesWritten; - CHAR let = 0; - UINT16 *text; - void *data; - int endoomnum = W_GetNumForName("ENDOOM"); - //HANDLE ci = GetStdHandle(STD_INPUT_HANDLE); - - /* get the lump with the text */ - data = text = W_CacheLumpNum(endoomnum, PU_CACHE); - - backupcon.wAttributes = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE; // Just in case - GetConsoleScreenBufferInfo(co, &backupcon); //Store old state - resizewin.Y = backupcon.dwSize.Y; - if (backupcon.dwSize.X < resizewin.X) - SetConsoleScreenBufferSize(co, resizewin); - - for (i = 1; i <= 80*25; i++) // print 80x25 text and deal with the attributes too - { - j = (UINT16)(*text >> 8); // attribute first - if (j != att) // attribute changed? - { - att = j; // save current attribute - SetConsoleTextAttribute(co, j); //set fg and bg color for buffer - } - - let = (char)(*text++ & 0xff); // now the text - WriteConsoleA(co, &let, 1, &bytesWritten, NULL); - - if (nlflag && !(i % 80) && backupcon.dwSize.X > resizewin.X) // do we need a nl? - { - att = backupcon.wAttributes; - SetConsoleTextAttribute(co, att); // all attributes off - WriteConsoleA(co, "\n", 1, &bytesWritten, NULL); - } - } - SetConsoleTextAttribute(co, backupcon.wAttributes); // all attributes off - //if (nlflag) - // WriteConsoleA(co, "\n", 1, &bytesWritten, NULL); - - getchar(); //pause! - - Z_Free(data); -} - - -// -// I_Quit: shutdown everything cleanly, in reverse order of Startup. -// -void I_Quit(void) -{ - HANDLE co = GetStdHandle(STD_OUTPUT_HANDLE); - // when recording a demo, should exit using 'q', - // but sometimes we forget and use Alt+F4, so save here too. - if (demorecording) - G_CheckDemoStatus(); - - M_SaveConfig(NULL); // save game config, cvars.. - G_SaveGameData(); - - // maybe it needs that the ticcount continues, - // or something else that will be finished by I_ShutdownSystem(), - // so do it before. - D_QuitNetGame(); - - // shutdown everything that was started - I_ShutdownSystem(); - - if (shutdowning || errorcount) - I_Error("Error detected (%d)", errorcount); - -#ifdef LOGMESSAGES - if (logstream != INVALID_HANDLE_VALUE) - { - I_OutputMsg("I_Quit(): end of logstream.\r\n"); - CloseHandle(logstream); - logstream = INVALID_HANDLE_VALUE; - } -#endif - if (!M_CheckParm("-noendtxt") && W_CheckNumForName("ENDOOM")!=-1 - && co != INVALID_HANDLE_VALUE && GetFileType(co) == FILE_TYPE_CHAR) - { - printf("\r"); - ShowEndTxt(co); - } - fflush(stderr); - exit(0); -} - -// -------------------------------------------------------------------------- -// I_ShowLastError -// Displays a GetLastError() error message in a MessageBox -// -------------------------------------------------------------------------- -void I_GetLastErrorMsgBox(void) -{ - LPSTR lpMsgBuf = NULL; - - FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - lpMsgBuf, 0, NULL); - - // Display the string. - MessageBoxA(NULL, lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION); - - // put it in console too and log if any - CONS_Printf("Error: %s\n", lpMsgBuf); - - // Free the buffer. - LocalFree(lpMsgBuf); -} - -// =========================================================================================== -// CLEAN STARTUP & SHUTDOWN HANDLING, JUST CLOSE EVERYTHING YOU OPENED. -// =========================================================================================== -// -// -static quitfuncptr quit_funcs[MAX_QUIT_FUNCS] = -{ - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL -}; - -// Adds a function to the list that need to be called by I_SystemShutdown(). -// -void I_AddExitFunc(void (*func)()) -{ - int c; - - for (c = 0; c < MAX_QUIT_FUNCS; c++) - { - if (!quit_funcs[c]) - { - quit_funcs[c] = func; - break; - } - } -} - -// Removes a function from the list that need to be called by I_SystemShutdown(). -// -void I_RemoveExitFunc(void (*func)()) -{ - int c; - - for (c = 0; c < MAX_QUIT_FUNCS; c++) - { - if (quit_funcs[c] == func) - { - while (c < MAX_QUIT_FUNCS - 1) - { - quit_funcs[c] = quit_funcs[c+1]; - c++; - } - quit_funcs[MAX_QUIT_FUNCS-1] = NULL; - break; - } - } -} - -// =========================================================================================== -// DIRECT INPUT HELPER CODE -// =========================================================================================== - -// Create a DirectInputDevice interface, -// create a DirectInputDevice2 interface if possible -static void CreateDevice2(LPDIRECTINPUT di, REFGUID pguid, LPDIRECTINPUTDEVICE* lpDEV, - LPDIRECTINPUTDEVICE2* lpDEV2) -{ - HRESULT hr, hr2; - LPDIRECTINPUTDEVICE lpdid1; - LPDIRECTINPUTDEVICE2 lpdid2 = NULL; - - hr = IDirectInput_CreateDevice(di, pguid, &lpdid1, NULL); - - if (SUCCEEDED(hr)) - { - // get Device2 but only if we are not in DirectInput version 3 - if (!bDX0300 && lpDEV2) - { - LPDIRECTINPUTDEVICE2 *rp = &lpdid2; - LPVOID *tp = (LPVOID *)rp; - hr2 = IDirectInputDevice_QueryInterface(lpdid1, &IID_IDirectInputDevice2, tp); - if (FAILED(hr2)) - { - CONS_Printf("\2Could not create IDirectInput device 2"); - lpdid2 = NULL; - } - } - } - else - I_Error("Could not create IDirectInput device"); - - *lpDEV = lpdid1; - if (lpDEV2) // only if we requested it - *lpDEV2 = lpdid2; -} - -// =========================================================================================== -// DIRECT INPUT MOUSE -// =========================================================================================== - -#define DI_MOUSE_BUFFERSIZE 16 // number of data elements in mouse buffer - -// -// Initialise the mouse. -// -static void I_ShutdownMouse(void); - -void I_StartupMouse(void) -{ - // this gets called when cv_usemouse is initted - // for the win32 version, we want to startup the mouse later -} - -static HANDLE mouse2filehandle = INVALID_HANDLE_VALUE; - -static void I_ShutdownMouse2(void) -{ - if (mouse2filehandle != INVALID_HANDLE_VALUE) - { - event_t event; - int i; - - SetCommMask(mouse2filehandle, 0); - - EscapeCommFunction(mouse2filehandle, CLRDTR); - EscapeCommFunction(mouse2filehandle, CLRRTS); - - PurgeComm(mouse2filehandle, PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR); - - CloseHandle(mouse2filehandle); - - // emulate the up of all mouse buttons - for (i = 0; i < MOUSEBUTTONS; i++) - { - event.type = ev_keyup; - event.data1 = KEY_2MOUSE1 + i; - D_PostEvent(&event); - } - - mouse2filehandle = INVALID_HANDLE_VALUE; - } -} - -#define MOUSECOMBUFFERSIZE 256 -static int handlermouse2x, handlermouse2y, handlermouse2buttons; - -static void I_PoolMouse2(void) -{ - UINT8 buffer[MOUSECOMBUFFERSIZE]; - COMSTAT ComStat; - DWORD dwErrorFlags, dwLength; - char dx, dy; - - static int bytenum; - static UINT8 combytes[4]; - DWORD i; - - ClearCommError(mouse2filehandle, &dwErrorFlags, &ComStat); - dwLength = min(MOUSECOMBUFFERSIZE, ComStat.cbInQue); - - if (dwLength > 0) - { - if (!ReadFile(mouse2filehandle, buffer, dwLength, &dwLength, NULL)) - { - CONS_Printf("\2Read Error on secondary mouse port\n"); - return; - } - - // parse the mouse packets - for (i = 0; i < dwLength; i++) - { - if ((buffer[i] & 64) == 64) - bytenum = 0; - - if (bytenum < 4) - combytes[bytenum] = buffer[i]; - bytenum++; - - if (bytenum == 1) - { - handlermouse2buttons &= ~3; - handlermouse2buttons |= ((combytes[0] & (32+16)) >>4); - } - else if (bytenum == 3) - { - dx = (char)((combytes[0] & 3) << 6); - dy = (char)((combytes[0] & 12) << 4); - dx = (char)(dx + combytes[1]); - dy = (char)(dy + combytes[2]); - handlermouse2x += dx; - handlermouse2y += dy; - } - else if (bytenum == 4) // fourth byte (logitech mouses) - { - if (buffer[i] & 32) - handlermouse2buttons |= 4; - else - handlermouse2buttons &= ~4; - } - } - } -} - -// secondary mouse doesn't use DirectX, therefore forget all about grabbing, acquire, etc. -void I_StartupMouse2(void) -{ - DCB dcb; - - if (mouse2filehandle != INVALID_HANDLE_VALUE) - I_ShutdownMouse2(); - - if (!cv_usemouse2.value) - return; - - if (mouse2filehandle != INVALID_HANDLE_VALUE) - { - // COM file handle - mouse2filehandle = CreateFileA(cv_mouse2port.string, GENERIC_READ|GENERIC_WRITE, - 0, // exclusive access - NULL, // no security attrs - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - int e = GetLastError(); - if (e == 5) - CONS_Printf("\2Can't open %s: Access denied\n" - "The port is probably already used by another device (mouse, modem,...)\n", - cv_mouse2port.string); - else - CONS_Printf("\2Can't open %s: error %d\n", cv_mouse2port.string, e); - return; - } - } - - // buffers - SetupComm(mouse2filehandle, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); - - // purge buffers - PurgeComm(mouse2filehandle, PURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|PURGE_RXCLEAR); - - // setup port to 1200 7N1 - dcb.DCBlength = sizeof (DCB); - - GetCommState(mouse2filehandle, &dcb); - - dcb.BaudRate = CBR_1200; - dcb.ByteSize = 7; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - - dcb.fDtrControl = DTR_CONTROL_ENABLE; - dcb.fRtsControl = RTS_CONTROL_ENABLE; - - dcb.fBinary = dcb.fParity = TRUE; - - SetCommState(mouse2filehandle, &dcb); - - I_AddExitFunc(I_ShutdownMouse2); -} - -#define MAX_MOUSE_BTNS 5 -static int center_x, center_y; -static int old_mparms[3], new_mparms[3] = {0, 0, 1}; -static boolean restore_mouse = FALSE; -static int old_mouse_state = 0; -unsigned int MSHWheelMessage = 0; - -static void I_DoStartupSysMouse(void) -{ - boolean valid; - RECT w_rect; - - valid = SystemParametersInfo(SPI_GETMOUSE, 0, old_mparms, 0); - if (valid) - { - new_mparms[2] = old_mparms[2]; - restore_mouse = SystemParametersInfo(SPI_SETMOUSE, 0, new_mparms, 0); - } - - if (bAppFullScreen) - { - w_rect.top = 0; - w_rect.left = 0; - } - else - { - w_rect.top = windowPosY; - w_rect.left = windowPosX; - } - - w_rect.bottom = w_rect.top + VIDHEIGHT; - w_rect.right = w_rect.left + VIDWIDTH; - center_x = w_rect.left + (VIDWIDTH >> 1); - center_y = w_rect.top + (VIDHEIGHT >> 1); - SetCursor(NULL); - SetCursorPos(center_x, center_y); - SetCapture(hWndMain); - ClipCursor(&w_rect); -} - -static void I_ShutdownSysMouse(void) -{ - if (restore_mouse) - SystemParametersInfo(SPI_SETMOUSE, 0, old_mparms, 0); - ClipCursor(NULL); - ReleaseCapture(); -} - -void I_RestartSysMouse(void) -{ - if (nodinput) - { - I_ShutdownSysMouse(); - I_DoStartupSysMouse(); - } -} - -void I_GetSysMouseEvents(int mouse_state) -{ - int i; - event_t event; - int xmickeys = 0, ymickeys = 0; - POINT c_pos; - - for (i = 0; i < MAX_MOUSE_BTNS; i++) - { - // check if button pressed - if ((mouse_state & (1 << i)) && !(old_mouse_state & (1 << i))) - { - event.type = ev_keydown; - event.data1 = KEY_MOUSE1 + i; - D_PostEvent(&event); - } - // check if button released - if (!(mouse_state & (1 << i)) && (old_mouse_state & (1 << i))) - { - event.type = ev_keyup; - event.data1 = KEY_MOUSE1 + i; - D_PostEvent(&event); - } - } - old_mouse_state = mouse_state; - - // proceed mouse movements - GetCursorPos(&c_pos); - xmickeys = c_pos.x - center_x; - ymickeys = c_pos.y - center_y; - - if (xmickeys || ymickeys) - { - event.type = ev_mouse; - event.data1 = 0; - event.data2 = xmickeys; - event.data3 = -ymickeys; - D_PostEvent(&event); - SetCursorPos(center_x, center_y); - } -} - -// This is called just before entering the main game loop, -// when we are going fullscreen and the loading screen has finished. -void I_DoStartupMouse(void) -{ - DIPROPDWORD dip; - - // mouse detection may be skipped by setting usemouse false - if (!cv_usemouse.value || M_CheckParm("-nomouse")) - { - mouse_enabled = false; - return; - } - - if (nodinput) - { - CONS_Printf("\tMouse will not use DirectInput.\n"); - // System mouse input will be initiated by VID_SetMode - I_AddExitFunc(I_ShutdownMouse); - - MSHWheelMessage = RegisterWindowMessage(MSH_MOUSEWHEEL); - } - else if (!lpDIM) // acquire the mouse only once - { - CreateDevice2(lpDI, &GUID_SysMouse, &lpDIM, NULL); - - if (lpDIM) - { - if (FAILED(IDirectInputDevice_SetDataFormat(lpDIM, &c_dfDIMouse))) - I_Error("Couldn't set mouse data format"); - - // create buffer for buffered data - dip.diph.dwSize = sizeof (dip); - dip.diph.dwHeaderSize = sizeof (dip.diph); - dip.diph.dwObj = 0; - dip.diph.dwHow = DIPH_DEVICE; - dip.dwData = DI_MOUSE_BUFFERSIZE; - if (FAILED(IDirectInputDevice_SetProperty(lpDIM, DIPROP_BUFFERSIZE, &dip.diph))) - I_Error("Couldn't set mouse buffer size"); - - if (FAILED(IDirectInputDevice_SetCooperativeLevel(lpDIM, hWndMain, - DISCL_EXCLUSIVE|DISCL_FOREGROUND))) - { - I_Error("Couldn't set mouse coop level"); - } - I_AddExitFunc(I_ShutdownMouse); - } - else - I_Error("Couldn't create mouse input"); - } - - // if re-enabled while running, just set mouse_enabled true again, - // do not acquire the mouse more than once - mouse_enabled = true; -} - -// -// Shutdown Mouse DirectInput device -// -static void I_ShutdownMouse(void) -{ - int i; - event_t event; - - CONS_Printf("I_ShutdownMouse()\n"); - - if (lpDIM) - { - IDirectInputDevice_Unacquire(lpDIM); - IDirectInputDevice_Release(lpDIM); - lpDIM = NULL; - } - - // emulate the up of all mouse buttons - for (i = 0; i < MOUSEBUTTONS; i++) - { - event.type = ev_keyup; - event.data1 = KEY_MOUSE1 + i; - D_PostEvent(&event); - } - if (nodinput) - I_ShutdownSysMouse(); - - mouse_enabled = false; -} - -// -// Get buffered data from the mouse -// -void I_GetMouseEvents(void) -{ - DIDEVICEOBJECTDATA rgdod[DI_MOUSE_BUFFERSIZE]; - DWORD dwItems, d; - HRESULT hr; - - event_t event; - int xmickeys, ymickeys; - - if (mouse2filehandle != INVALID_HANDLE_VALUE) - { - //mouse movement - static UINT8 lastbuttons2 = 0; - - I_PoolMouse2(); - // post key event for buttons - if (handlermouse2buttons != lastbuttons2) - { - int i, j = 1, k; - k = handlermouse2buttons ^ lastbuttons2; // only changed bit to 1 - lastbuttons2 = (UINT8)handlermouse2buttons; - - for (i = 0; i < MOUSEBUTTONS; i++, j <<= 1) - if (k & j) - { - if (handlermouse2buttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2MOUSE1 + i; - D_PostEvent(&event); - } - } - - if (handlermouse2x || handlermouse2y) - { - event.type = ev_mouse2; - event.data1 = 0; - event.data2 = handlermouse2x<<1; - event.data3 = -handlermouse2y<<1; - handlermouse2x = 0; - handlermouse2y = 0; - - D_PostEvent(&event); - } - } - - if (!mouse_enabled || nodinput) - return; - -getBufferedData: - dwItems = DI_MOUSE_BUFFERSIZE; - hr = IDirectInputDevice_GetDeviceData(lpDIM, sizeof (DIDEVICEOBJECTDATA), rgdod, &dwItems, 0); - - // If data stream was interrupted, reacquire the device and try again. - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) - { - hr = IDirectInputDevice_Acquire(lpDIM); - if (SUCCEEDED(hr)) - goto getBufferedData; - } - - // We got buffered input, act on it - if (SUCCEEDED(hr)) - { - xmickeys = ymickeys = 0; - - // dwItems contains number of elements read (could be 0) - for (d = 0; d < dwItems; d++) - { - if (rgdod[d].dwOfs >= DIMOFS_BUTTON0 && - rgdod[d].dwOfs < DIMOFS_BUTTON0 + MOUSEBUTTONS) - { - if (rgdod[d].dwData & 0x80) // Button down - event.type = ev_keydown; - else - event.type = ev_keyup; // Button up - - event.data1 = rgdod[d].dwOfs - DIMOFS_BUTTON0 + KEY_MOUSE1; - D_PostEvent(&event); - } - else if (rgdod[d].dwOfs == DIMOFS_X) - xmickeys += rgdod[d].dwData; - else if (rgdod[d].dwOfs == DIMOFS_Y) - ymickeys += rgdod[d].dwData; - - else if (rgdod[d].dwOfs == DIMOFS_Z) - { - // z-axes the wheel - if ((int)rgdod[d].dwData > 0) - event.data1 = KEY_MOUSEWHEELUP; - else - event.data1 = KEY_MOUSEWHEELDOWN; - event.type = ev_keydown; - D_PostEvent(&event); - } - - } - - if (xmickeys || ymickeys) - { - event.type = ev_mouse; - event.data1 = 0; - event.data2 = xmickeys; - event.data3 = -ymickeys; - D_PostEvent(&event); - } - } -} - -// =========================================================================================== -// DIRECT INPUT JOYSTICK -// =========================================================================================== - -struct DIJoyInfo_s -{ - BYTE X,Y,Z,Rx,Ry,Rz,U,V; - LONG ForceAxises; -}; -typedef struct DIJoyInfo_s DIJoyInfo_t; - -// private info - static BYTE iJoyNum; // used by enumeration - static DIJoyInfo_t JoyInfo; - static BYTE iJoy2Num; - static DIJoyInfo_t JoyInfo2; - -//----------------------------------------------------------------------------- -// Name: EnumAxesCallback() -// Desc: Callback function for enumerating the axes on a joystick and counting -// each force feedback enabled axis -//----------------------------------------------------------------------------- -static BOOL CALLBACK EnumAxesCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext) -{ - DWORD* pdwNumForceFeedbackAxis = (DWORD*) pContext; - - if ((pdidoi->dwFlags & DIDOI_FFACTUATOR) != 0) - (*pdwNumForceFeedbackAxis)++; - - return DIENUM_CONTINUE; -} - - -static HRESULT SetupForceTacile(LPDIRECTINPUTDEVICE2 DJI, LPDIRECTINPUTEFFECT *DJE, DWORD FFAXIS, FFType EffectType,REFGUID EffectGUID) -{ - HRESULT hr; - DIEFFECT eff; - DWORD rgdwAxes[2] = { DIJOFS_X, DIJOFS_Y }; - LONG rglDirection[2] = { 0, 0 }; - DICONSTANTFORCE cf = { 0 }; // LONG lMagnitude - DIRAMPFORCE rf = {0,0}; // LONG lStart, lEnd; - DIPERIODIC pf = {0,0,0,0}; - ZeroMemory(&eff, sizeof (eff)); - if (FFAXIS > 2) - FFAXIS = 2; //up to 2 FFAXIS - eff.dwSize = sizeof (DIEFFECT); - eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; // Cartesian and data format offsets - eff.dwDuration = INFINITE; - eff.dwSamplePeriod = 0; - eff.dwGain = DI_FFNOMINALMAX; - eff.dwTriggerButton = DIEB_NOTRIGGER; - eff.dwTriggerRepeatInterval = 0; - eff.cAxes = FFAXIS; - eff.rgdwAxes = rgdwAxes; - eff.rglDirection = rglDirection; - eff.lpEnvelope = NULL; - eff.lpvTypeSpecificParams = NULL; - if (EffectType == ConstantForce) - { - eff.cbTypeSpecificParams = sizeof (cf); - eff.lpvTypeSpecificParams = &cf; - } - else if (EffectType == RampForce) - { - eff.cbTypeSpecificParams = sizeof (rf); - eff.lpvTypeSpecificParams = &rf; - } - else if (EffectType >= SquareForce && SawtoothDownForce >= EffectType) - { - eff.cbTypeSpecificParams = sizeof (pf); - eff.lpvTypeSpecificParams = &pf; - } -#if (DIRECTINPUT_VERSION >= 0x0600) - //eff.dwStartDelay = 0; -#endif - - // Create the prepared effect - if (FAILED(hr = IDirectInputDevice2_CreateEffect(DJI, EffectGUID, - &eff, DJE, NULL))) - { - return hr; - } - - if (NULL == *DJE) - return E_FAIL; - - return hr; -} - -static BOOL CALLBACK DIEnumEffectsCallback1(LPCDIEFFECTINFO pdei, LPVOID pvRef) -{ - LPDIRECTINPUTEFFECT *DJE = pvRef; - if (DIEFT_GETTYPE(pdei->dwEffType) == DIEFT_CONSTANTFORCE) - { - if (SUCCEEDED(SetupForceTacile(lpDIJA,DJE, JoyInfo.ForceAxises, ConstantForce, &pdei->guid))) - return DIENUM_STOP; - } - if (DIEFT_GETTYPE(pdei->dwEffType) == DIEFT_RAMPFORCE) - { - if (SUCCEEDED(SetupForceTacile(lpDIJA,DJE, JoyInfo.ForceAxises, RampForce, &pdei->guid))) - return DIENUM_STOP; - } - return DIENUM_CONTINUE; -} - -static BOOL CALLBACK DIEnumEffectsCallback2(LPCDIEFFECTINFO pdei, LPVOID pvRef) -{ - LPDIRECTINPUTEFFECT *DJE = pvRef; - if (DIEFT_GETTYPE(pdei->dwEffType) == DIEFT_CONSTANTFORCE) - { - if (SUCCEEDED(SetupForceTacile(lpDIJ2A,DJE, JoyInfo2.ForceAxises, ConstantForce, &pdei->guid))) - return DIENUM_STOP; - } - if (DIEFT_GETTYPE(pdei->dwEffType) == DIEFT_RAMPFORCE) - { - if (SUCCEEDED(SetupForceTacile(lpDIJ2A,DJE, JoyInfo2.ForceAxises, RampForce, &pdei->guid))) - return DIENUM_STOP; - } - return DIENUM_CONTINUE; -} - -static REFGUID DIETable[] = -{ - &GUID_ConstantForce, //ConstantForce - &GUID_RampForce, //RampForce - &GUID_Square, //SquareForce - &GUID_Sine, //SineForce - &GUID_Triangle, //TriangleForce - &GUID_SawtoothUp, //SawtoothUpForce - &GUID_SawtoothDown, //SawtoothDownForce - (REFGUID)-1, //NumberofForces -}; - -static HRESULT SetupAllForces(LPDIRECTINPUTDEVICE2 DJI, LPDIRECTINPUTEFFECT DJE[], DWORD FFAXIS) -{ - FFType ForceType = EvilForce; - if (DJI == lpDIJA) - { - IDirectInputDevice2_EnumEffects(DJI,DIEnumEffectsCallback1,&DJE[ConstantForce],DIEFT_CONSTANTFORCE); - IDirectInputDevice2_EnumEffects(DJI,DIEnumEffectsCallback1,&DJE[RampForce],DIEFT_RAMPFORCE); - } - else if (DJI == lpDIJA) - { - IDirectInputDevice2_EnumEffects(DJI,DIEnumEffectsCallback2,&DJE[ConstantForce],DIEFT_CONSTANTFORCE); - IDirectInputDevice2_EnumEffects(DJI,DIEnumEffectsCallback2,&DJE[RampForce],DIEFT_RAMPFORCE); - } - for (ForceType = SquareForce; ForceType > NumberofForces && DIETable[ForceType] != (REFGUID)-1; ForceType++) - if (DIETable[ForceType]) - SetupForceTacile(DJI,&DJE[ForceType], FFAXIS, ForceType, DIETable[ForceType]); - return S_OK; -} - -static void LimitEffect(LPDIEFFECT eff, FFType EffectType) -{ - LPDICONSTANTFORCE pCF = eff->lpvTypeSpecificParams; - LPDIPERIODIC pDP= eff->lpvTypeSpecificParams; - if (eff->rglDirection) - { - } -/* if (eff->dwDuration != INFINITE && eff->dwDuration < 0) - { - eff->dwDuration = 0; - }*/ - if (eff->dwGain != 0) - { - if (eff->dwGain > DI_FFNOMINALMAX) - eff->dwGain = DI_FFNOMINALMAX; - //else if (eff->dwGain < -DI_FFNOMINALMAX) - // eff->dwGain = DI_FFNOMINALMAX; - } - if (EffectType == ConstantForce && pCF->lMagnitude) - { - } - else if (EffectType >= SquareForce && SawtoothDownForce >= EffectType && pDP) - { - } - -} - -static HRESULT SetForceTacile(LPDIRECTINPUTEFFECT SDIE, const JoyFF_t *FF,DWORD FFAXIS, FFType EffectType) -{ - DIEFFECT eff; - HRESULT hr; - LONG Magnitude; - LONG rglDirection[2] = { 0, 0 }; - DICONSTANTFORCE cf = { 0 }; // LONG lMagnitude - DIRAMPFORCE rf = {0,0}; // LONG lStart, lEnd; - DIPERIODIC pf = {0,0,0,0}; - if (!FF) - IDirectInputEffect_Stop(SDIE); - Magnitude = FF->Magnitude; - ZeroMemory(&eff, sizeof (eff)); - eff.dwSize = sizeof (eff); - //DIEP_START - eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS; // Cartesian and data format offsets - //DIEP_DURATION - eff.dwDuration = FF->Duration; - //DIEP_GAIN - eff.dwGain = FF->Gain; - //DIEP_DIRECTION - eff.rglDirection = rglDirection; - //DIEP_TYPESPECIFICPARAMS - if (FFAXIS > 1) - { - double dMagnitude; - dMagnitude = (double)Magnitude; - dMagnitude = hypot(dMagnitude, dMagnitude); - Magnitude = (DWORD)dMagnitude; - rglDirection[0] = FF->ForceX; - rglDirection[1] = FF->ForceY; - } - if (EffectType == ConstantForce) - { - cf.lMagnitude = Magnitude; - eff.cbTypeSpecificParams = sizeof (cf); - eff.lpvTypeSpecificParams = &cf; - } - else if (EffectType == RampForce) - { - rf.lStart = FF->Start; - rf.lEnd = FF->End; - eff.cbTypeSpecificParams = sizeof (rf); - eff.lpvTypeSpecificParams = &rf; - } - else if (EffectType >= SquareForce && SawtoothDownForce >= EffectType) - { - pf.dwMagnitude = Magnitude; - pf.lOffset = FF->Offset; - pf.dwPhase = FF->Phase; - pf.dwPeriod = FF->Period; - eff.cbTypeSpecificParams = sizeof (pf); - eff.lpvTypeSpecificParams = &pf; - } - - LimitEffect(&eff, EffectType); - - hr = IDirectInputEffect_SetParameters(SDIE, &eff, - DIEP_START|DIEP_DURATION|DIEP_GAIN|DIEP_DIRECTION|DIEP_TYPESPECIFICPARAMS); - return hr; -} - -void I_Tactile(FFType Type, const JoyFF_t *Effect) -{ - if (!lpDIJA) return; - if (FAILED(IDirectInputDevice2_Acquire(lpDIJA))) - return; - if (Type == EvilForce) - IDirectInputDevice2_SendForceFeedbackCommand(lpDIJA,DISFFC_STOPALL); - if (Type <= EvilForce || Type > NumberofForces || !lpDIE[Type]) - return; - SetForceTacile(lpDIE[Type], Effect, JoyInfo.ForceAxises, Type); -} - -void I_Tactile2(FFType Type, const JoyFF_t *Effect) -{ - if (!lpDIJ2A) return; - if (FAILED(IDirectInputDevice2_Acquire(lpDIJ2A))) - return; - if (Type == EvilForce) - IDirectInputDevice2_SendForceFeedbackCommand(lpDIJ2A,DISFFC_STOPALL); - if (Type <= EvilForce || Type > NumberofForces || !lpDIE2[Type]) - return; - SetForceTacile(lpDIE2[Type],Effect, JoyInfo2.ForceAxises, Type); -} - -// ------------------ -// SetDIDwordProperty (HELPER) -// Set a DWORD property on a DirectInputDevice. -// ------------------ -static HRESULT SetDIDwordProperty(LPDIRECTINPUTDEVICE pdev, - REFGUID guidProperty, - DWORD dwObject, - DWORD dwHow, - DWORD dwValue) -{ - DIPROPDWORD dipdw; - - dipdw.diph.dwSize = sizeof (dipdw); - dipdw.diph.dwHeaderSize = sizeof (dipdw.diph); - dipdw.diph.dwObj = dwObject; - dipdw.diph.dwHow = dwHow; - dipdw.dwData = dwValue; - - return IDirectInputDevice_SetProperty(pdev, guidProperty, &dipdw.diph); -} - - -// --------------- -// DIEnumJoysticks -// There is no such thing as a 'system' joystick, contrary to mouse, -// we must enumerate and choose one joystick device to use -// --------------- -static BOOL CALLBACK DIEnumJoysticks (LPCDIDEVICEINSTANCE lpddi, - LPVOID pvRef) //cv_usejoystick -{ - LPDIRECTINPUTDEVICE pdev; - DIPROPRANGE diprg; - DIDEVCAPS caps; - BOOL bUseThisOne = FALSE; - - iJoyNum++; - - //faB: if cv holds a string description of joystick, the value from atoi() is 0 - // else, the value was probably set by user at console to one of the previously - // enumerated joysticks - if (((consvar_t *)pvRef)->value == iJoyNum -#ifndef _UNICODE - || !lstrcmpA(((consvar_t *)pvRef)->string, lpddi->tszProductName) -#endif - ) - bUseThisOne = TRUE; - - //CONS_Printf(" cv joy is %s\n", ((consvar_t *)pvRef)->string); - - // print out device name - CONS_Printf("%c%d: %s\n", - (bUseThisOne) ? '\2' : ' ', // show name in white if this is the one we will use - iJoyNum, - //(GET_DIDEVICE_SUBTYPE(lpddi->dwDevType) == DIDEVTYPEJOYSTICK_GAMEPAD) ? "Gamepad " : "Joystick", - lpddi->tszProductName); //, lpddi->tszInstanceName); - - // use specified joystick (cv_usejoystick.value in pvRef) - if (!bUseThisOne) - return DIENUM_CONTINUE; - - ((consvar_t *)pvRef)->value = iJoyNum; - if (IDirectInput_CreateDevice (lpDI, &lpddi->guidInstance, - &pdev, NULL) != DI_OK) - { - // if it failed, then we can't use this joystick for some - // bizarre reason. (Maybe the user unplugged it while we - // were in the middle of enumerating it.) So continue enumerating - CONS_Printf("DIEnumJoysticks(): CreateDevice FAILED\n"); - return DIENUM_CONTINUE; - } - - // get the Device capabilities - // - caps.dwSize = sizeof (DIDEVCAPS_DX3); - if (FAILED(IDirectInputDevice_GetCapabilities (pdev, &caps))) - { - CONS_Printf("DIEnumJoysticks(): GetCapabilities FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - if (!(caps.dwFlags & DIDC_ATTACHED)) // should be, since we enumerate only attached devices - return DIENUM_CONTINUE; - - Joystick.bJoyNeedPoll = ((caps.dwFlags & DIDC_POLLEDDATAFORMAT) != 0); - - if (caps.dwFlags & DIDC_FORCEFEEDBACK) - JoyInfo.ForceAxises = 0; - else - JoyInfo.ForceAxises = -1; - - Joystick.bGamepadStyle = (GET_DIDEVICE_SUBTYPE(caps.dwDevType) == DIDEVTYPEJOYSTICK_GAMEPAD); - //DEBUG CONS_Printf("Gamepad: %d\n", Joystick.bGamepadStyle); - - - CONS_Printf("Capabilities: %d axes, %d buttons, %d POVs, poll %d, Gamepad %d\n", - caps.dwAxes, caps.dwButtons, caps.dwPOVs, Joystick.bJoyNeedPoll, Joystick.bGamepadStyle); - - // Set the data format to "simple joystick" - a predefined data format - // - // A data format specifies which controls on a device we - // are interested in, and how they should be reported. - // - // This tells DirectInput that we will be passing a - // DIJOYSTATE structure to IDirectInputDevice::GetDeviceState. - if (IDirectInputDevice_SetDataFormat (pdev, &c_dfDIJoystick) != DI_OK) - { - CONS_Printf("DIEnumJoysticks(): SetDataFormat FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - - // Set the cooperativity level to let DirectInput know how - // this device should interact with the system and with other - // DirectInput applications. - if (IDirectInputDevice_SetCooperativeLevel (pdev, hWndMain, - DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) - { - CONS_Printf("DIEnumJoysticks(): SetCooperativeLevel FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - - // set the range of the joystick axis - diprg.diph.dwSize = sizeof (DIPROPRANGE); - diprg.diph.dwHeaderSize = sizeof (DIPROPHEADER); - diprg.diph.dwHow = DIPH_BYOFFSET; - diprg.lMin = -JOYAXISRANGE; // value for extreme left - diprg.lMax = +JOYAXISRANGE; // value for extreme right - - diprg.diph.dwObj = DIJOFS_X; // set the x-axis range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //goto SetPropFail; - JoyInfo.X = FALSE; - } - else JoyInfo.X = TRUE; - - diprg.diph.dwObj = DIJOFS_Y; // set the y-axis range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { -//SetPropFail: -// CONS_Printf("DIEnumJoysticks(): SetProperty FAILED\n"); -// IDirectInputDevice_Release (pdev); -// return DIENUM_CONTINUE; - JoyInfo.Y = FALSE; - } - else JoyInfo.Y = TRUE; - - diprg.diph.dwObj = DIJOFS_Z; // set the z-axis range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_Z not found\n"); - JoyInfo.Z = FALSE; - } - else JoyInfo.Z = TRUE; - - diprg.diph.dwObj = DIJOFS_RX; // set the x-rudder range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RX (x-rudder) not found\n"); - JoyInfo.Rx = FALSE; - } - else JoyInfo.Rx = TRUE; - - diprg.diph.dwObj = DIJOFS_RY; // set the y-rudder range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RY (y-rudder) not found\n"); - JoyInfo.Ry = FALSE; - } - else JoyInfo.Ry = TRUE; - - diprg.diph.dwObj = DIJOFS_RZ; // set the z-rudder range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RZ (z-rudder) not found\n"); - JoyInfo.Rz = FALSE; - } - else JoyInfo.Rz = TRUE; - diprg.diph.dwObj = DIJOFS_SLIDER(0); // set the x-misc range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RZ (x-misc) not found\n"); - JoyInfo.U = FALSE; - } - else JoyInfo.U = TRUE; - - diprg.diph.dwObj = DIJOFS_SLIDER(1); // set the y-misc range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RZ (y-misc) not found\n"); - JoyInfo.V = FALSE; - } - else JoyInfo.V = TRUE; - - // set X axis dead zone to 25% (to avoid accidental turning) - if (!Joystick.bGamepadStyle) - { - if (JoyInfo.X) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_X, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for X DEAD ZONE"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.Y) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_Y, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for Y DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.Z) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_Z, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for Z DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.Rx) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_RX, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for RX DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.Ry) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_RY, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for RY DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.Rz) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_RZ, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for RZ DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.U) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_SLIDER(0), - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for U DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo.V) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_SLIDER(1), - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks(): couldn't SetProperty for V DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - } - - // query for IDirectInputDevice2 - we need this to poll the joystick - if (bDX0300) - { - FFType i = EvilForce; - // we won't use the poll - lpDIJA = NULL; - for (i = 0; i > NumberofForces; i++) - lpDIE[i] = NULL; - } - else - { - LPDIRECTINPUTDEVICE2 *rp = &lpDIJA; - LPVOID *tp = (LPVOID *)rp; - if (FAILED(IDirectInputDevice_QueryInterface(pdev, &IID_IDirectInputDevice2, tp))) - { - CONS_Printf("DIEnumJoysticks(): QueryInterface FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - - if (lpDIJA && JoyInfo.ForceAxises != -1) - { - // Since we will be playing force feedback effects, we should disable the - // auto-centering spring. - if (FAILED(SetDIDwordProperty(pdev, DIPROP_AUTOCENTER, 0, DIPH_DEVICE, FALSE))) - { - //NOP - } - - // Enumerate and count the axes of the joystick - if (FAILED(IDirectInputDevice_EnumObjects(pdev, EnumAxesCallback, - (VOID*)&JoyInfo.ForceAxises, DIDFT_AXIS))) - { - JoyInfo.ForceAxises = -1; - } - else - { - SetupAllForces(lpDIJA,lpDIE,JoyInfo.ForceAxises); - } - } - } - - // we successfully created an IDirectInputDevice. So stop looking - // for another one. - lpDIJ = pdev; - return DIENUM_STOP; -} - -// -------------- -// I_InitJoystick -// This is called everytime the 'use_joystick' variable changes -// It is normally called at least once at startup when the config is loaded -// -------------- -void I_InitJoystick(void) -{ - HRESULT hr; - - // cleanup - I_ShutdownJoystick(); - - //joystick detection can be skipped by setting use_joystick to 0 - if (M_CheckParm("-nojoy")) - { - CONS_Printf("Joystick disabled\n"); - return; - } - else - // don't do anything at the registration of the joystick cvar, - // until config is loaded - if (!lstrcmpA(cv_usejoystick.string, "0")) - return; - - // acquire the joystick only once - if (!lpDIJ) - { - joystick_detected = false; - - CONS_Printf("Looking for joystick devices:\n"); - iJoyNum = 0; - hr = IDirectInput_EnumDevices(lpDI, DIDEVTYPE_JOYSTICK, DIEnumJoysticks, - (void *)&cv_usejoystick, // our user parameter is joystick number - DIEDFL_ATTACHEDONLY); - if (FAILED(hr)) - { - CONS_Printf("\nI_InitJoystick(): EnumDevices FAILED\n"); - cv_usejoystick.value = 0; - return; - } - - if (!lpDIJ) - { - if (!iJoyNum) - CONS_Printf("none found\n"); - else - { - CONS_Printf("none used\n"); - if (cv_usejoystick.value > 0 && cv_usejoystick.value > iJoyNum) - { - CONS_Printf("\2Set the use_joystick variable to one of the" - " enumerated joystick numbers\n"); - } - } - cv_usejoystick.value = 0; - return; - } - - I_AddExitFunc(I_ShutdownJoystick); - - // set coop level - if (FAILED(IDirectInputDevice_SetCooperativeLevel(lpDIJ, hWndMain, - DISCL_NONEXCLUSIVE|DISCL_FOREGROUND))) - { - I_Error("I_InitJoystick: SetCooperativeLevel FAILED"); - } - } - else - CONS_Printf("Joystick already initialized\n"); - - // we don't unacquire joystick, so let's just pretend we re-acquired it - joystick_detected = true; -} -//Joystick 2 - -// --------------- -// DIEnumJoysticks2 -// There is no such thing as a 'system' joystick, contrary to mouse, -// we must enumerate and choose one joystick device to use -// --------------- -static BOOL CALLBACK DIEnumJoysticks2 (LPCDIDEVICEINSTANCE lpddi, - LPVOID pvRef) //cv_usejoystick -{ - LPDIRECTINPUTDEVICE pdev; - DIPROPRANGE diprg; - DIDEVCAPS caps; - BOOL bUseThisOne = FALSE; - - iJoy2Num++; - - //faB: if cv holds a string description of joystick, the value from atoi() is 0 - // else, the value was probably set by user at console to one of the previsouly - // enumerated joysticks - if (((consvar_t *)pvRef)->value == iJoy2Num -#ifndef _UNICODE - || !lstrcmpA(((consvar_t *)pvRef)->string, lpddi->tszProductName) -#endif - ) - bUseThisOne = TRUE; - - //CONS_Printf(" cv joy2 is %s\n", ((consvar_t *)pvRef)->string); - - // print out device name - CONS_Printf("%c%d: %s\n", - (bUseThisOne) ? '\2' : ' ', // show name in white if this is the one we will use - iJoy2Num, - //(GET_DIDEVICE_SUBTYPE(lpddi->dwDevType) == DIDEVTYPEJOYSTICK_GAMEPAD) ? "Gamepad " : "Joystick", - lpddi->tszProductName); //, lpddi->tszInstanceName); - - // use specified joystick (cv_usejoystick.value in pvRef) - if (!bUseThisOne) - return DIENUM_CONTINUE; - - ((consvar_t *)pvRef)->value = iJoy2Num; - if (IDirectInput_CreateDevice (lpDI, &lpddi->guidInstance, - &pdev, NULL) != DI_OK) - { - // if it failed, then we can't use this joystick for some - // bizarre reason. (Maybe the user unplugged it while we - // were in the middle of enumerating it.) So continue enumerating - CONS_Printf("DIEnumJoysticks2(): CreateDevice FAILED\n"); - return DIENUM_CONTINUE; - } - - - // get the Device capabilities - // - caps.dwSize = sizeof (DIDEVCAPS_DX3); - if (FAILED(IDirectInputDevice_GetCapabilities (pdev, &caps))) - { - CONS_Printf("DIEnumJoysticks2(): GetCapabilities FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - if (!(caps.dwFlags & DIDC_ATTACHED)) // should be, since we enumerate only attached devices - return DIENUM_CONTINUE; - - Joystick2.bJoyNeedPoll = ((caps.dwFlags & DIDC_POLLEDDATAFORMAT) != 0); - - if (caps.dwFlags & DIDC_FORCEFEEDBACK) - JoyInfo2.ForceAxises = 0; - else - JoyInfo2.ForceAxises = -1; - - Joystick2.bGamepadStyle = (GET_DIDEVICE_SUBTYPE(caps.dwDevType) == DIDEVTYPEJOYSTICK_GAMEPAD); - //DEBUG CONS_Printf("Gamepad: %d\n", Joystick2.bGamepadStyle); - - - CONS_Printf("Capabilities: %d axes, %d buttons, %d POVs, poll %d, Gamepad %d\n", - caps.dwAxes, caps.dwButtons, caps.dwPOVs, Joystick2.bJoyNeedPoll, Joystick2.bGamepadStyle); - - - // Set the data format to "simple joystick" - a predefined data format - // - // A data format specifies which controls on a device we - // are interested in, and how they should be reported. - // - // This tells DirectInput that we will be passing a - // DIJOYSTATE structure to IDirectInputDevice::GetDeviceState. - if (IDirectInputDevice_SetDataFormat (pdev, &c_dfDIJoystick) != DI_OK) - { - CONS_Printf("DIEnumJoysticks2(): SetDataFormat FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - - // Set the cooperativity level to let DirectInput know how - // this device should interact with the system and with other - // DirectInput applications. - if (IDirectInputDevice_SetCooperativeLevel (pdev, hWndMain, - DISCL_EXCLUSIVE | DISCL_FOREGROUND) != DI_OK) - { - CONS_Printf("DIEnumJoysticks2(): SetCooperativeLevel FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - - // set the range of the joystick axis - diprg.diph.dwSize = sizeof (DIPROPRANGE); - diprg.diph.dwHeaderSize = sizeof (DIPROPHEADER); - diprg.diph.dwHow = DIPH_BYOFFSET; - diprg.lMin = -JOYAXISRANGE; // value for extreme left - diprg.lMax = +JOYAXISRANGE; // value for extreme right - - diprg.diph.dwObj = DIJOFS_X; // set the x-axis range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //goto SetPropFail; - JoyInfo2.X = FALSE; - } - else JoyInfo2.X = TRUE; - - diprg.diph.dwObj = DIJOFS_Y; // set the y-axis range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { -//SetPropFail: -// CONS_Printf("DIEnumJoysticks(): SetProperty FAILED\n"); -// IDirectInputDevice_Release (pdev); -// return DIENUM_CONTINUE; - JoyInfo2.Y = FALSE; - } - else JoyInfo2.Y = TRUE; - - diprg.diph.dwObj = DIJOFS_Z; // set the z-axis range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_Z not found\n"); - JoyInfo2.Z = FALSE; - } - else JoyInfo2.Z = TRUE; - - diprg.diph.dwObj = DIJOFS_RX; // set the x-rudder range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RX (x-rudder) not found\n"); - JoyInfo2.Rx = FALSE; - } - else JoyInfo2.Rx = TRUE; - - diprg.diph.dwObj = DIJOFS_RY; // set the y-rudder range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RY (y-rudder) not found\n"); - JoyInfo2.Ry = FALSE; - } - else JoyInfo2.Ry = TRUE; - - diprg.diph.dwObj = DIJOFS_RZ; // set the z-rudder range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RZ (z-rudder) not found\n"); - JoyInfo2.Rz = FALSE; - } - else JoyInfo2.Rz = TRUE; - diprg.diph.dwObj = DIJOFS_SLIDER(0); // set the x-misc range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RZ (x-misc) not found\n"); - JoyInfo2.U = FALSE; - } - else JoyInfo2.U = TRUE; - - diprg.diph.dwObj = DIJOFS_SLIDER(1); // set the y-misc range - if (FAILED(IDirectInputDevice_SetProperty(pdev, DIPROP_RANGE, &diprg.diph))) - { - //CONS_Printf("DIJOFS_RZ (y-misc) not found\n"); - JoyInfo2.V = FALSE; - } - else JoyInfo2.V = TRUE; - - // set X axis dead zone to 25% (to avoid accidental turning) - if (!Joystick2.bGamepadStyle) - { - if (JoyInfo2.X) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_X, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for X DEAD ZONE"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.Y) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_Y, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for Y DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.Z) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_Z, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for Z DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.Rx) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_RX, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for RX DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.Ry) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_RY, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for RY DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.Rz) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_RZ, - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for RZ DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.U) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_SLIDER(0), - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for U DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - if (JoyInfo2.V) - if (FAILED(SetDIDwordProperty (pdev, DIPROP_DEADZONE, DIJOFS_SLIDER(1), - DIPH_BYOFFSET, 2500))) - { - CONS_Printf("DIEnumJoysticks2(): couldn't SetProperty for V DEAD ZONE\n"); - //IDirectInputDevice_Release (pdev); - //return DIENUM_CONTINUE; - } - } - - // query for IDirectInputDevice2 - we need this to poll the joystick - if (bDX0300) - { - FFType i = EvilForce; - // we won't use the poll - lpDIJA = NULL; - for (i = 0; i > NumberofForces; i++) - lpDIE[i] = NULL; - } - else - { - LPDIRECTINPUTDEVICE2 *rp = &lpDIJ2A; - LPVOID *tp = (LPVOID *)rp; - if (FAILED(IDirectInputDevice_QueryInterface(pdev, &IID_IDirectInputDevice2, tp))) - { - CONS_Printf("DIEnumJoysticks2(): QueryInterface FAILED\n"); - IDirectInputDevice_Release (pdev); - return DIENUM_CONTINUE; - } - - if (lpDIJ2A && JoyInfo2.ForceAxises != -1) - { - // Since we will be playing force feedback effects, we should disable the - // auto-centering spring. - if (FAILED(SetDIDwordProperty(pdev, DIPROP_AUTOCENTER, 0, DIPH_DEVICE, FALSE))) - { - //NOP - } - - // Enumerate and count the axes of the joystick - if (FAILED(IDirectInputDevice_EnumObjects(pdev, EnumAxesCallback, - (VOID*)&JoyInfo2.ForceAxises, DIDFT_AXIS))) - { - JoyInfo2.ForceAxises = -1; - } - else - { - SetupAllForces(lpDIJ2A,lpDIE2,JoyInfo2.ForceAxises); - } - } - } - - // we successfully created an IDirectInputDevice. So stop looking - // for another one. - lpDIJ2 = pdev; - return DIENUM_STOP; -} - - -// -------------- -// I_InitJoystick2 -// This is called everytime the 'use_joystick2' variable changes -// It is normally called at least once at startup when the config is loaded -// -------------- -void I_InitJoystick2 (void) -{ - HRESULT hr; - - // cleanup - I_ShutdownJoystick2 (); - - joystick2_detected = false; - - // joystick detection can be skipped by setting use_joystick to 0 - if (M_CheckParm("-nojoy")) - { - CONS_Printf("Joystick2 disabled\n"); - return; - } - else - // don't do anything at the registration of the joystick cvar, - // until config is loaded - if (!lstrcmpA(cv_usejoystick2.string, "0")) - return; - - // acquire the joystick only once - if (!lpDIJ2) - { - joystick2_detected = false; - - CONS_Printf("Looking for joystick devices:\n"); - iJoy2Num = 0; - hr = IDirectInput_EnumDevices(lpDI, DIDEVTYPE_JOYSTICK, - DIEnumJoysticks2, - (void *)&cv_usejoystick2, // our user parameter is joystick number - DIEDFL_ATTACHEDONLY); - if (FAILED(hr)) - { - CONS_Printf("\nI_InitJoystick2(): EnumDevices FAILED\n"); - cv_usejoystick2.value = 0; - return; - } - - if (!lpDIJ2) - { - if (iJoy2Num == 0) - CONS_Printf("none found\n"); - else - { - CONS_Printf("none used\n"); - if (cv_usejoystick2.value > 0 && - cv_usejoystick2.value > iJoy2Num) - { - CONS_Printf("\2Set the use_joystick2 variable to one of the" - " enumerated joysticks number\n"); - } - } - cv_usejoystick2.value = 0; - return; - } - - I_AddExitFunc (I_ShutdownJoystick2); - - // set coop level - if (FAILED(IDirectInputDevice_SetCooperativeLevel (lpDIJ2, hWndMain, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND))) - I_Error("I_InitJoystick2: SetCooperativeLevel FAILED"); - - // later - //if (FAILED(IDirectInputDevice_Acquire (lpDIJ2))) - // I_Error("Couldn't acquire Joystick2"); - - joystick2_detected = true; - } - else - CONS_Printf("Joystick2 already initialized\n"); - - //faB: we don't unacquire joystick, so let's just pretend we re-acquired it - joystick2_detected = true; -} - -/** \brief Joystick 1 buttons states -*/ -static INT64 lastjoybuttons = 0; - -/** \brief Joystick 1 hats state -*/ -static INT64 lastjoyhats = 0; - -static void I_ShutdownJoystick(void) -{ - int i; - event_t event; - - lastjoybuttons = lastjoyhats = 0; - - event.type = ev_keyup; - - // emulate the up of all joystick buttons - for (i = 0;i < JOYBUTTONS;i++) - { - event.data1 = KEY_JOY1+i; - D_PostEvent(&event); - } - - // emulate the up of all joystick hats - for (i = 0;i < JOYHATS*4;i++) - { - event.data1 = KEY_HAT1+i; - D_PostEvent(&event); - } - - // reset joystick position - event.type = ev_joystick; - for (i = 0;i < JOYAXISSET; i++) - { - event.data1 = i; - D_PostEvent(&event); - } - - if (joystick_detected) - CONS_Printf("I_ShutdownJoystick()\n"); - - for (i = 0; i > NumberofForces; i++) - { - if (lpDIE[i]) - { - IDirectInputEffect_Release(lpDIE[i]); - lpDIE[i] = NULL; - - } - } - if (lpDIJ) - { - IDirectInputDevice_Unacquire(lpDIJ); - IDirectInputDevice_Release(lpDIJ); - lpDIJ = NULL; - } - if (lpDIJA) - { - IDirectInputDevice2_Release(lpDIJA); - lpDIJA = NULL; - } - joystick_detected = false; -} - -/** \brief Joystick 2 buttons states -*/ -static INT64 lastjoy2buttons = 0; - -/** \brief Joystick 2 hats state -*/ -static INT64 lastjoy2hats = 0; - -static void I_ShutdownJoystick2(void) -{ - int i; - event_t event; - - lastjoy2buttons = lastjoy2hats = 0; - - event.type = ev_keyup; - - // emulate the up of all joystick buttons - for (i = 0;i < JOYBUTTONS;i++) - { - event.data1 = KEY_2JOY1+i; - D_PostEvent(&event); - } - - // emulate the up of all joystick hats - for (i = 0;i < JOYHATS*4;i++) - { - event.data1 = KEY_2HAT1+i; - D_PostEvent(&event); - } - - // reset joystick position - event.type = ev_joystick2; - for (i = 0;i < JOYAXISSET; i++) - { - event.data1 = i; - D_PostEvent(&event); - } - - if (joystick2_detected) - CONS_Printf("I_ShutdownJoystick2()\n"); - - for (i = 0; i > NumberofForces; i++) - { - if (lpDIE2[i]) - { - IDirectInputEffect_Release(lpDIE2[i]); - lpDIE2[i] = NULL; - } - } - if (lpDIJ2) - { - IDirectInputDevice_Unacquire(lpDIJ2); - IDirectInputDevice_Release(lpDIJ2); - lpDIJ2 = NULL; - } - if (lpDIJ2A) - { - IDirectInputDevice2_Release(lpDIJ2A); - lpDIJ2A = NULL; - } - joystick2_detected = false; -} - -// ------------------- -// I_GetJoystickEvents -// Get current joystick axis and button states -// ------------------- -void I_GetJoystickEvents(void) -{ - HRESULT hr; - DIJOYSTATE js; // DirectInput joystick state - int i; - INT64 joybuttons = 0; - INT64 joyhats = 0; - event_t event; - - if (!lpDIJ) - return; - - // if input is lost then acquire and keep trying - for (;;) - { - // poll the joystick to read the current state - // if the device doesn't require polling, this function returns almost instantly - if (lpDIJA) - { - hr = IDirectInputDevice2_Poll(lpDIJA); - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) - goto acquire; - else if (FAILED(hr)) - { - CONS_Printf("I_GetJoystickEvents(): Poll FAILED\n"); - return; - } - } - - // get the input's device state, and put the state in dims - hr = IDirectInputDevice_GetDeviceState(lpDIJ, sizeof (DIJOYSTATE), &js); - - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) - { - // DirectInput is telling us that the input stream has - // been interrupted. We aren't tracking any state - // between polls, so we don't have any special reset - // that needs to be done. We just re-acquire and - // try again. - goto acquire; - } - else if (FAILED(hr)) - { - CONS_Printf("I_GetJoystickEvents(): GetDeviceState FAILED\n"); - return; - } - - break; -acquire: - if (FAILED(IDirectInputDevice_Acquire(lpDIJ))) - return; - } - - // look for as many buttons as g_input code supports, we don't use the others - for (i = JOYBUTTONS_MIN - 1; i >= 0; i--) - { - joybuttons <<= 1; - if (js.rgbButtons[i]) - joybuttons |= 1; - } - - for (i = JOYHATS_MIN -1; i >=0; i--) - { - if (js.rgdwPOV[i] != 0xffff && js.rgdwPOV[i] != 0xffffffff) - { - if (js.rgdwPOV[i] > 270 * DI_DEGREES || js.rgdwPOV[i] < 90 * DI_DEGREES) - joyhats |= 1<<(0 + 4*i); // UP - else if (js.rgdwPOV[i] > 90 * DI_DEGREES && js.rgdwPOV[i] < 270 * DI_DEGREES) - joyhats |= 1<<(1 + 4*i); // DOWN - if (js.rgdwPOV[i] > 0 * DI_DEGREES && js.rgdwPOV[i] < 180 * DI_DEGREES) - joyhats |= 1<<(3 + 4*i); // LEFT - else if (js.rgdwPOV[i] > 180 * DI_DEGREES && js.rgdwPOV[i] < 360 * DI_DEGREES) - joyhats |= 1<<(2 + 4*i); // RIGHT - } - } - - if (joybuttons != lastjoybuttons) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newbuttons = joybuttons ^ lastjoybuttons; - lastjoybuttons = joybuttons; - - for (i = 0; i < JOYBUTTONS && i < JOYBUTTONS_MAX; i++, j <<= 1) - { - if (newbuttons & j) // button changed state? - { - if (joybuttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_JOY1 + i; - D_PostEvent(&event); - } - } - } - - if (joyhats != lastjoyhats) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newhats = joyhats ^ lastjoyhats; - lastjoyhats = joyhats; - - for (i = 0; i < JOYHATS*4 && i < JOYHATS_MAX*4; i++, j <<= 1) - { - if (newhats & j) // button changed state? - { - if (joyhats & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_HAT1 + i; - D_PostEvent(&event); - } - } - - } - - // send joystick axis positions - event.type = ev_joystick; - event.data1 = event.data2 = event.data3 = 0; - - if (Joystick.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo.X) - { - if (js.lX < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.lX > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo.Y) - { - if (js.lY < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.lY > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo.X) event.data2 = js.lX; // x axis - if (JoyInfo.Y) event.data3 = js.lY; // y axis - } - - D_PostEvent(&event); -#if JOYAXISSET > 1 - event.data1 = 1; - event.data2 = event.data3 = 0; - - if (Joystick.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo.Z) - { - if (js.lZ < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.lZ > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo.Rx) - { - if (js.lRx < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.lRx > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo.Z) event.data2 = js.lZ; // z axis - if (JoyInfo.Rx) event.data3 = js.lRx; // rx axis - } - - D_PostEvent(&event); -#endif -#if JOYAXISSET > 2 - event.data1 = 2; - event.data2 = event.data3 = 0; - - if (Joystick.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo.Rx) - { - if (js.lRy < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.lRy > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo.Rz) - { - if (js.lRz < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.lRz > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo.Ry) event.data2 = js.lRy; // ry axis - if (JoyInfo.Rz) event.data3 = js.lRz; // rz axis - } - - D_PostEvent(&event); -#endif -#if JOYAXISSET > 3 - event.data1 = 3; - event.data2 = event.data3 = 0; - if (Joystick.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo.U) - { - if (js.rglSlider[0] < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.rglSlider[0] > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo.V) - { - if (js.rglSlider[1] < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.rglSlider[1] > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo.U) event.data2 = js.rglSlider[0]; // U axis - if (JoyInfo.V) event.data3 = js.rglSlider[1]; // V axis - } - D_PostEvent(&event); -#endif -} - -// ------------------- -// I_GetJoystickEvents -// Get current joystick axis and button states -// ------------------- -void I_GetJoystick2Events(void) -{ - HRESULT hr; - DIJOYSTATE js; // DirectInput joystick state - int i; - INT64 joybuttons = 0; - INT64 joyhats = 0; - event_t event; - - if (!lpDIJ2) - return; - - // if input is lost then acquire and keep trying - for (;;) - { - // poll the joystick to read the current state - // if the device doesn't require polling, this function returns almost instantly - if (lpDIJ2A) - { - hr = IDirectInputDevice2_Poll(lpDIJ2A); - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) - goto acquire; - else if (FAILED(hr)) - { - CONS_Printf("I_GetJoystick2Events(): Poll FAILED\n"); - return; - } - } - - // get the input's device state, and put the state in dims - hr = IDirectInputDevice_GetDeviceState(lpDIJ2, sizeof (DIJOYSTATE), &js); - - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) - { - // DirectInput is telling us that the input stream has - // been interrupted. We aren't tracking any state - // between polls, so we don't have any special reset - // that needs to be done. We just re-acquire and - // try again. - goto acquire; - } - else if (FAILED(hr)) - { - CONS_Printf("I_GetJoystickEvents2(): GetDeviceState FAILED\n"); - return; - } - - break; -acquire: - if (FAILED(IDirectInputDevice_Acquire(lpDIJ2))) - return; - } - - // look for as many buttons as g_input code supports, we don't use the others - for (i = JOYBUTTONS_MIN - 1; i >= 0; i--) - { - joybuttons <<= 1; - if (js.rgbButtons[i]) - joybuttons |= 1; - } - - for (i = JOYHATS_MIN -1; i >=0; i--) - { - if (js.rgdwPOV[i] != 0xffff && js.rgdwPOV[i] != 0xffffffff) - { - if (js.rgdwPOV[i] > 270 * DI_DEGREES || js.rgdwPOV[i] < 90 * DI_DEGREES) - joyhats |= 1<<(0 + 4*i); // UP - else if (js.rgdwPOV[i] > 90 * DI_DEGREES && js.rgdwPOV[i] < 270 * DI_DEGREES) - joyhats |= 1<<(1 + 4*i); // DOWN - if (js.rgdwPOV[i] > 0 * DI_DEGREES && js.rgdwPOV[i] < 180 * DI_DEGREES) - joyhats |= 1<<(3 + 4*i); // LEFT - else if (js.rgdwPOV[i] > 180 * DI_DEGREES && js.rgdwPOV[i] < 360 * DI_DEGREES) - joyhats |= 1<<(2 + 4*i); // RIGHT - } - } - - if (joybuttons != lastjoy2buttons) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newbuttons = joybuttons ^ lastjoy2buttons; - lastjoy2buttons = joybuttons; - - for (i = 0; i < JOYBUTTONS && i < JOYBUTTONS_MAX; i++, j <<= 1) - { - if (newbuttons & j) // button changed state? - { - if (joybuttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2JOY1 + i; - D_PostEvent(&event); - } - } - } - - if (joyhats != lastjoy2hats) - { - INT64 j = 1; // keep only bits that changed since last time - INT64 newhats = joyhats ^ lastjoy2hats; - lastjoy2hats = joyhats; - - for (i = 0; i < JOYHATS*4 && i < JOYHATS_MAX*4; i++, j <<= 1) - { - if (newhats & j) // button changed state? - { - if (joyhats & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2HAT1 + i; - D_PostEvent(&event); - } - } - - } - - // send joystick axis positions - event.type = ev_joystick2; - event.data1 = event.data2 = event.data3 = 0; - - if (Joystick2.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo2.X) - { - if (js.lX < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.lX > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo2.Y) - { - if (js.lY < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.lY > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo2.X) event.data2 = js.lX; // x axis - if (JoyInfo2.Y) event.data3 = js.lY; // y axis - } - - D_PostEvent(&event); -#if JOYAXISSET > 1 - event.data1 = 1; - event.data2 = event.data3 = 0; - - if (Joystick2.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo2.Z) - { - if (js.lZ < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.lZ > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo2.Rx) - { - if (js.lRx < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.lRx > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo2.Z) event.data2 = js.lZ; // z axis - if (JoyInfo2.Rx) event.data3 = js.lRx; // rx axis - } - - D_PostEvent(&event); -#endif -#if JOYAXISSET > 2 - event.data1 = 2; - event.data2 = event.data3 = 0; - - if (Joystick2.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo2.Rx) - { - if (js.lRy < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.lRy > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo2.Rz) - { - if (js.lRz < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.lRz > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo2.Ry) event.data2 = js.lRy; // ry axis - if (JoyInfo2.Rz) event.data3 = js.lRz; // rz axis - } - - D_PostEvent(&event); -#endif -#if JOYAXISSET > 3 - event.data1 = 3; - event.data2 = event.data3 = 0; - if (Joystick2.bGamepadStyle) - { - // gamepad control type, on or off, live or die - if (JoyInfo2.U) - { - if (js.rglSlider[0] < -(JOYAXISRANGE/2)) - event.data2 = -1; - else if (js.rglSlider[0] > JOYAXISRANGE/2) - event.data2 = 1; - } - if (JoyInfo2.V) - { - if (js.rglSlider[1] < -(JOYAXISRANGE/2)) - event.data3 = -1; - else if (js.rglSlider[1] > JOYAXISRANGE/2) - event.data3 = 1; - } - } - else - { - // analog control style, just send the raw data - if (JoyInfo2.U) event.data2 = js.rglSlider[0]; // U axis - if (JoyInfo2.V) event.data3 = js.rglSlider[1]; // V axis - } - D_PostEvent(&event); -#endif -} - -static int numofjoy = 0; -static char joyname[MAX_PATH]; -static int needjoy = -1; - -static BOOL CALLBACK DIEnumJoysticksCount (LPCDIDEVICEINSTANCE lpddi, - LPVOID pvRef) //joyname -{ - numofjoy++; - if (needjoy == numofjoy && pvRef && pvRef == (void *)joyname && lpddi - && lpddi->tszProductName) - { - sprintf(joyname,"%s",lpddi->tszProductName); - return DIENUM_STOP; - } - //else if (devparm) CONS_Printf("DIEnumJoysticksCount need help!"); - return DIENUM_CONTINUE; -} - -INT32 I_NumJoys(void) -{ - HRESULT hr; - needjoy = -1; - numofjoy = 0; - hr = IDirectInput_EnumDevices(lpDI, DIDEVTYPE_JOYSTICK, - DIEnumJoysticksCount, (void *)&numofjoy, DIEDFL_ATTACHEDONLY); - if (FAILED(hr)) - CONS_Printf("\nI_NumJoys(): EnumDevices FAILED\n"); - return numofjoy; - -} - -const char *I_GetJoyName(INT32 joyindex) -{ - HRESULT hr; - needjoy = joyindex; - numofjoy = 0; - ZeroMemory(joyname,sizeof (joyname)); - hr = IDirectInput_EnumDevices(lpDI, DIDEVTYPE_JOYSTICK, - DIEnumJoysticksCount, (void *)joyname, DIEDFL_ATTACHEDONLY); - if (FAILED(hr)) - CONS_Printf("\nI_GetJoyName(): EnumDevices FAILED\n"); - if (joyname[0] == 0) return NULL; - return joyname; -} - -// =========================================================================================== -// DIRECT INPUT KEYBOARD -// =========================================================================================== - -static UINT8 ASCIINames[256] = -{ - // 0 1 2 3 4 5 6 7 - // 8 9 A B C D E F - 0, 27, '1', '2', '3', '4', '5', '6', - '7', '8', '9', '0', KEY_MINUS,KEY_EQUALS,KEY_BACKSPACE, KEY_TAB, - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', - 'o', 'p', '[', ']', KEY_ENTER,KEY_CTRL,'a', 's', - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', - '\'', '`', KEY_SHIFT, '\\', 'z', 'x', 'c', 'v', - 'b', 'n', 'm', ',', '.', '/', KEY_SHIFT, '*', - KEY_ALT,KEY_SPACE,KEY_CAPSLOCK, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, - KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,KEY_NUMLOCK,KEY_SCROLLLOCK,KEY_KEYPAD7, - KEY_KEYPAD8,KEY_KEYPAD9,KEY_MINUSPAD,KEY_KEYPAD4,KEY_KEYPAD5,KEY_KEYPAD6,KEY_PLUSPAD,KEY_KEYPAD1, - KEY_KEYPAD2,KEY_KEYPAD3,KEY_KEYPAD0,KEY_KPADDEL,0,0,0, KEY_F11, - KEY_F12,0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - - // 0 1 2 3 4 5 6 7 - // 8 9 A B C D E F - - 0, 0, 0, 0, 0, 0, 0, 0, // 0x80 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, KEY_ENTER,KEY_CTRL, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, KEY_KPADDEL, 0,KEY_KPADSLASH,0, 0, - KEY_ALT,0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, KEY_HOME, // 0xc0 - KEY_UPARROW,KEY_PGUP,0,KEY_LEFTARROW,0,KEY_RIGHTARROW,0,KEY_END, - KEY_DOWNARROW,KEY_PGDN, KEY_INS,KEY_DEL,0,0,0,0, - 0, 0, 0,KEY_LEFTWIN,KEY_RIGHTWIN,KEY_MENU, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0 - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -// Return a key that has been pushed, or 0 (replace getchar() at game startup) -// -INT32 I_GetKey(void) -{ - event_t *ev; - - if (eventtail != eventhead) - { - ev = &events[eventtail]; - eventtail = (eventtail+1) & (MAXEVENTS-1); - if (ev->type == ev_keydown || ev->type == ev_console) - return ev->data1; - else - return 0; - } - return 0; -} - -// ----------------- -// I_StartupKeyboard -// Installs DirectInput keyboard -// ----------------- -#define DI_KEYBOARD_BUFFERSIZE 32 // number of data elements in keyboard buffer - -void I_StartupKeyboard(void) -{ - DIPROPDWORD dip; - - if (dedicated) - return; - - // make sure the app window has the focus or DirectInput acquire keyboard won't work - if (hWndMain) - { - SetFocus(hWndMain); - ShowWindow(hWndMain, SW_SHOW); - UpdateWindow(hWndMain); - } - - // detect error - if (lpDIK) - { - CONS_Printf("\2I_StartupKeyboard(): called twice\n"); - return; - } - - CreateDevice2(lpDI, &GUID_SysKeyboard, &lpDIK, NULL); - - if (lpDIK) - { - if (FAILED(IDirectInputDevice_SetDataFormat(lpDIK, &c_dfDIKeyboard))) - I_Error("Couldn't set keyboard data format"); - - // create buffer for buffered data - dip.diph.dwSize = sizeof (dip); - dip.diph.dwHeaderSize = sizeof (dip.diph); - dip.diph.dwObj = 0; - dip.diph.dwHow = DIPH_DEVICE; - dip.dwData = DI_KEYBOARD_BUFFERSIZE; - if (FAILED(IDirectInputDevice_SetProperty(lpDIK, DIPROP_BUFFERSIZE, &dip.diph))) - I_Error("Couldn't set keyboard buffer size"); - - if (FAILED(IDirectInputDevice_SetCooperativeLevel(lpDIK, hWndMain, - DISCL_NONEXCLUSIVE|DISCL_FOREGROUND))) - { - I_Error("Couldn't set keyboard coop level"); - } - } - else - I_Error("Couldn't create keyboard input"); - - I_AddExitFunc(I_ShutdownKeyboard); - hacktics = 0; // see definition - keyboard_started = true; -} - -// ------------------ -// I_ShutdownKeyboard -// Release DirectInput keyboard. -// ------------------ -static void I_ShutdownKeyboard(void) -{ - if (!keyboard_started) - return; - - CONS_Printf("I_ShutdownKeyboard()\n"); - - if (lpDIK) - { - IDirectInputDevice_Unacquire(lpDIK); - IDirectInputDevice_Release(lpDIK); - lpDIK = NULL; - } - - keyboard_started = false; -} - -// ------------------- -// I_GetKeyboardEvents -// Get buffered data from the keyboard -// ------------------- -static void I_GetKeyboardEvents(void) -{ - static boolean KeyboardLost = false; - - // simply repeat the last pushed key every xx tics, - // make more user friendly input for Console and game Menus -#define KEY_REPEAT_DELAY (TICRATE/17) // TICRATE tics, repeat every 1/3 second - static long RepeatKeyTics = 0; - static int RepeatKeyCode; - - DIDEVICEOBJECTDATA rgdod[DI_KEYBOARD_BUFFERSIZE]; - DWORD dwItems, d; - HRESULT hr; - int ch; - - event_t event; - ZeroMemory(&event,sizeof (event)); - - if (!keyboard_started) - return; - - if (!appActive && RepeatKeyCode) // Stop when lost focus - { - event.type = ev_keyup; - event.data1 = RepeatKeyCode; - D_PostEvent(&event); - RepeatKeyCode = 0; - } -getBufferedData: - dwItems = DI_KEYBOARD_BUFFERSIZE; - hr = IDirectInputDevice_GetDeviceData(lpDIK, sizeof (DIDEVICEOBJECTDATA), rgdod, &dwItems, 0); - - // If data stream was interrupted, reacquire the device and try again. - if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) - { - // why it succeeds to acquire just after I don't understand.. so I set the flag BEFORE - KeyboardLost = true; - - hr = IDirectInputDevice_Acquire(lpDIK); - if (SUCCEEDED(hr)) - goto getBufferedData; - return; - } - - // we lost data, get device actual state to recover lost information - if (hr == DI_BUFFEROVERFLOW) - { - /// \note either uncomment or delete block - //I_Error("DI buffer overflow (keyboard)"); - //I_RecoverKeyboardState (); - - //hr = IDirectInputDevice_GetDeviceState (lpDIM, sizeof (keys), &diMouseState); - } - - // We got buffered input, act on it - if (SUCCEEDED(hr)) - { - // if we previously lost keyboard data, recover its current state - if (KeyboardLost) - { - /// \bug hack simply clears the keys so we don't have the last pressed keys - /// still active.. to have to re-trigger it is not much trouble for the user. - ZeroMemory(gamekeydown, NUMKEYS); - KeyboardLost = false; - } - - // dwItems contains number of elements read (could be 0) - for (d = 0; d < dwItems; d++) - { - // dwOfs member is DIK_* value - // dwData member 0x80 bit set press down, clear is release - - if (rgdod[d].dwData & 0x80) - event.type = ev_keydown; - else - event.type = ev_keyup; - - ch = rgdod[d].dwOfs & UINT8_MAX; - if (ASCIINames[ch]) - event.data1 = ASCIINames[ch]; - else - event.data1 = 0x80; - - D_PostEvent(&event); - } - - // Key Repeat - if (dwItems) - { - // new key events, so stop repeating key - RepeatKeyCode = 0; - // delay is tripled for first repeating key - RepeatKeyTics = hacktics + (KEY_REPEAT_DELAY*2); - if (event.type == ev_keydown) // use the last event! - RepeatKeyCode = event.data1; - } - else - { - // no new keys, repeat last pushed key after some time - if (RepeatKeyCode && hacktics - RepeatKeyTics > KEY_REPEAT_DELAY) - { - event.type = ev_keydown; - event.data1 = RepeatKeyCode; - D_PostEvent(&event); - - RepeatKeyTics = hacktics; - } - } - } -} - -// -// Closes DirectInput -// -static void I_ShutdownDirectInput(void) -{ - if (lpDI) - IDirectInput_Release(lpDI); - lpDI = NULL; -} - -// This stuff should get rid of the exception and page faults when -// SRB2 bugs out with an error. Now it should exit cleanly. -// -INT32 I_StartupSystem(void) -{ - HRESULT hr; - - // some 'more global than globals' things to initialize here ? - graphics_started = keyboard_started = sound_started = cdaudio_started = false; - - I_DetectWin9x(); - - // check for OS type and version here? -#ifdef NDEBUG - signal(SIGABRT, signal_handler); - signal(SIGFPE, signal_handler); - signal(SIGILL, signal_handler); - signal(SIGSEGV, signal_handler); - signal(SIGTERM, signal_handler); - signal(SIGINT, signal_handler); -#endif - - // create DirectInput - so that I_StartupKeyboard/Mouse can be called later on - // from D_SRB2Main just like DOS version - hr = DirectInputCreate(myInstance, DIRECTINPUT_VERSION, &lpDI, NULL); - - if (SUCCEEDED(hr)) - bDX0300 = FALSE; - else - { - // try opening DirectX3 interface for NT compatibility - hr = DirectInputCreate(myInstance, DXVERSION_NTCOMPATIBLE, &lpDI, NULL); - - if (FAILED(hr)) - { - const char *sErr; - switch (hr) - { - case DIERR_BETADIRECTINPUTVERSION: - sErr = "DIERR_BETADIRECTINPUTVERSION"; - break; - case DIERR_INVALIDPARAM: - sErr = "DIERR_INVALIDPARAM"; - break; - case DIERR_OLDDIRECTINPUTVERSION : - sErr = "DIERR_OLDDIRECTINPUTVERSION"; - break; - case DIERR_OUTOFMEMORY: - sErr = "DIERR_OUTOFMEMORY"; - break; - default: - sErr = "UNKNOWN"; - break; - } - I_Error("Couldn't create DirectInput (reason: %s)", sErr); - } - else - CONS_Printf("\2Using DirectX3 interface\n"); - - // only use DirectInput3 compatible structures and calls - bDX0300 = TRUE; - } - I_AddExitFunc(I_ShutdownDirectInput); - return 0; -} - -// Closes down everything. This includes restoring the initial -// palette and video mode, and removing whatever mouse, keyboard, and -// timer routines have been installed. -// -/// \bug doesn't restore wave/midi device volume -// -// Shutdown user funcs are effectively called in reverse order. -// -void I_ShutdownSystem(void) -{ - int c; - - for (c = MAX_QUIT_FUNCS - 1; c >= 0; c--) - if (quit_funcs[c]) - (*quit_funcs[c])(); -} - -// --------------- -// I_SaveMemToFile -// Save as much as iLength bytes starting at pData, to -// a new file of given name. The file is overwritten if it is present. -// --------------- -BOOL I_SaveMemToFile(const void *pData, size_t iLength, const char *sFileName) -{ - HANDLE fileHandle; - DWORD bytesWritten; - - fileHandle = CreateFileA(sFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH, NULL); - if (fileHandle == (HANDLE)-1) - { - CONS_Printf("SaveMemToFile: Error opening file %s",sFileName); - return FALSE; - } - WriteFile(fileHandle, pData, (DWORD)iLength, &bytesWritten, NULL); - CloseHandle(fileHandle); - return TRUE; -} - -// my god how win32 suck -typedef BOOL (WINAPI *MyFunc)(LPCSTR RootName, PULARGE_INTEGER pulA, PULARGE_INTEGER pulB, PULARGE_INTEGER pulFreeBytes); - -void I_GetDiskFreeSpace(INT64* freespace) -{ - static MyFunc pfnGetDiskFreeSpaceEx = NULL; - static boolean testwin95 = false; - ULARGE_INTEGER usedbytes, lfrespace; - - if (!testwin95) - { - HMODULE h = GetModuleHandleA("kernel32.dll"); - - if (h) - pfnGetDiskFreeSpaceEx = (MyFunc)GetProcAddress(h, "GetDiskFreeSpaceExA"); - testwin95 = true; - } - if (pfnGetDiskFreeSpaceEx) - { - if (pfnGetDiskFreeSpaceEx(NULL, &lfreespace, &usedbytes, NULL)) - *freespace = lfreespace.QuadPart; - else - *freespace = INT32_MAX; - } - else - { - DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters; - GetDiskFreeSpace(NULL, &SectorsPerCluster, &BytesPerSector, - &NumberOfFreeClusters, &TotalNumberOfClusters); - *freespace = BytesPerSector * SectorsPerCluster * NumberOfFreeClusters; - } -} - -char *I_GetUserName(void) -{ - static char username[MAXPLAYERNAME+1]; - char *p; - DWORD i = MAXPLAYERNAME; - - if (!GetUserNameA(username, &i)) - { - p = getenv("USER"); - if (!p) - { - p = getenv("user"); - if (!p) - { - p = getenv("USERNAME"); - if (!p) - { - p = getenv("username"); - if (!p) - { - return NULL; - } - } - } - } - strncpy(username, p, MAXPLAYERNAME); - } - - if (!strlen(username)) - return NULL; - return username; -} - -INT32 I_mkdir(const char *dirname, INT32 unixright) -{ - (void)unixright; /// \todo should implement ntright under nt... - return CreateDirectoryA(dirname, NULL); -} - -char * I_GetEnv(const char *name) -{ - return getenv(name); -} - -INT32 I_PutEnv(char *variable) -{ - return putenv(variable); -} - -INT32 I_ClipboardCopy(const char *data, size_t size) -{ - (void)data; - (void)size; - return -1; -} - -char *I_ClipboardPaste(void) -{ - return NULL; -} - -typedef BOOL (WINAPI *MyFunc3) (DWORD); - -const CPUInfoFlags *I_CPUInfo(void) -{ - static CPUInfoFlags WIN_CPUInfo; - static MyFunc3 pfnCPUID = NULL; - SYSTEM_INFO SI; - HMODULE h = GetModuleHandleA("kernel32.dll"); - - if (h) - pfnCPUID = (MyFunc3)GetProcAddress(h, "IsProcessorFeaturePresent"); - ZeroMemory(&WIN_CPUInfo,sizeof (WIN_CPUInfo)); - if(pfnCPUID) - { - WIN_CPUInfo.FPPE = pfnCPUID( 0); //PF_FLOATING_POINT_PRECISION_ERRATA - WIN_CPUInfo.FPE = pfnCPUID( 1); //PF_FLOATING_POINT_EMULATED - WIN_CPUInfo.cmpxchg = pfnCPUID( 2); //PF_COMPARE_EXCHANGE_DOUBLE - WIN_CPUInfo.MMX = pfnCPUID( 3); //PF_MMX_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.PPCMM64 = pfnCPUID( 4); //PF_PPC_MOVEMEM_64BIT_OK - WIN_CPUInfo.ALPHAbyte = pfnCPUID( 5); //PF_ALPHA_BYTE_INSTRUCTIONS - WIN_CPUInfo.SSE = pfnCPUID( 6); //PF_XMMI_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.AMD3DNow = pfnCPUID( 7); //PF_3DNOW_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.RDTSC = pfnCPUID( 8); //PF_RDTSC_INSTRUCTION_AVAILABLE - WIN_CPUInfo.PAE = pfnCPUID( 9); //PF_PAE_ENABLED - WIN_CPUInfo.SSE2 = pfnCPUID(10); //PF_XMMI64_INSTRUCTIONS_AVAILABLE - //WIN_CPUInfo.blank = pfnCPUID(11); //PF_SSE_DAZ_MODE_AVAILABLE - WIN_CPUInfo.DEP = pfnCPUID(12); //PF_NX_ENABLED - WIN_CPUInfo.SSE3 = pfnCPUID(13); //PF_SSE3_INSTRUCTIONS_AVAILABLE - WIN_CPUInfo.cmpxchg16b = pfnCPUID(14); //PF_COMPARE_EXCHANGE128 - WIN_CPUInfo.cmp8xchg16 = pfnCPUID(15); //PF_COMPARE64_EXCHANGE128 - WIN_CPUInfo.PFC = pfnCPUID(15); //PF_CHANNELS_ENABLED - } - GetSystemInfo(&SI); - WIN_CPUInfo.CPUs = SI.dwNumberOfProcessors; - WIN_CPUInfo.IA64 = (SI.dwProcessorType == 2200); // PROCESSOR_INTEL_IA64 - WIN_CPUInfo.AMD64 = (SI.dwProcessorType == 8664); // PROCESSOR_AMD_X8664 - return &WIN_CPUInfo; -} - -UINT64 I_FileSize(const char *filename) -{ - HANDLE fileHandle; - DWORD dwSizeHigh, dwSizeLow; - UINT64 fileSize = (UINT64)-1; - - fileHandle = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, - 0, NULL); - if (fileHandle == (HANDLE)-1) - goto erroropening; - dwSizeLow = GetFileSize(fileHandle,&dwSizeHigh); - if (dwSizeLow == 0xFFFFFFFF && GetLastError() != NO_ERROR) - goto errorsizing; - fileSize = ((UINT64)(dwSizeHigh)<<32) + dwSizeLow; -errorsizing: - CloseHandle(fileHandle); -erroropening: - return fileSize; -} diff --git a/src/win32ce/win_vid.c b/src/win32ce/win_vid.c deleted file mode 100644 index b9c2e131f..000000000 --- a/src/win32ce/win_vid.c +++ /dev/null @@ -1,861 +0,0 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// Copyright (C) 1998-2000 by DooM Legacy Team. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -//----------------------------------------------------------------------------- -/// \file -/// \brief win32 video driver for Doom Legacy - -#include "../doomdef.h" - -#include -#include - -#include "../d_clisrv.h" -#include "../i_system.h" -#include "../m_argv.h" -#include "../v_video.h" -#include "../st_stuff.h" -#include "../i_video.h" -#include "../z_zone.h" -#include "fabdxlib.h" - -#include "win_main.h" -#include "../command.h" -#include "../screen.h" - -#ifdef HWRENDER -#include "win_dll.h" // loading the render DLL -#include "../hardware/hw_drv.h" // calling driver init & shutdown -#include "../hardware/hw_main.h" // calling HWR module init & shutdown -#endif - -// ------- -// Globals -// ------- - -// this is the CURRENT rendermode!! very important: used by w_wad, and much other code -rendermode_t rendermode = render_soft; - -// synchronize page flipping with screen refresh -consvar_t cv_vidwait = {"vid_wait", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static consvar_t cv_stretch = {"stretch", "On", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - -boolean highcolor; - -static BOOL bDIBMode; // means we are using DIB instead of DirectDraw surfaces -static BITMAPINFO* bmiMain = NULL; -static HDC hDCMain = NULL; - -// ----------------- -// Video modes stuff -// ----------------- - -#define MAX_EXTRA_MODES 36 -static vmode_t extra_modes[MAX_EXTRA_MODES] = {{NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, 0}}; -static char names[MAX_EXTRA_MODES][10]; - -static int numvidmodes; // total number of DirectDraw display modes -static vmode_t *pvidmodes; // start of videomodes list. -static vmode_t *pcurrentmode; // the current active videomode. -static BOOL bWinParm; -static int WINAPI VID_SetWindowedDisplayMode(viddef_t *lvid, vmode_t *pcurrentmode); - -// this holds description of the startup video mode, -// the resolution is 320x200, windowed on the desktop -#define NUMSPECIALMODES 1 -static char winmode1[] ="320x200W"; // W to make sure it's the windowed mode -static vmode_t specialmodes[NUMSPECIALMODES] = -{ - { - NULL, - winmode1, // hehe - 320, 200, //(200.0/320.0)*(320.0/240.0), - 320, 1, // rowbytes, bytes per pixel - 1, 2, // windowed (TRUE), numpages - NULL, - VID_SetWindowedDisplayMode, 0 - } -}; - -// ------ -// Protos -// ------ -static void VID_Command_NumModes_f(void); -static void VID_Command_ModeInfo_f(void); -static void VID_Command_ModeList_f(void); -static void VID_Command_Mode_f(void); -static int WINAPI VID_SetDirectDrawMode(viddef_t *lvid, vmode_t *pcurrentmode); -static vmode_t *VID_GetModePtr(int modenum); -static void VID_Init(void); -static BOOL VID_FreeAndAllocVidbuffer(viddef_t *lvid); - -// ----------------- -// I_StartupGraphics -// Initialize video mode, setup dynamic screen size variables, -// and allocate screens. -// ----------------- -void I_StartupGraphics(void) -{ - if (graphics_started) - return; - -#ifdef HWRENDER - if (M_CheckParm("-opengl")) - rendermode = render_opengl; - else - rendermode = render_soft; -#endif - - if (dedicated) - rendermode = render_none; - else - VID_Init(); - - // register exit code for graphics - I_AddExitFunc(I_ShutdownGraphics); - if (!dedicated) graphics_started = true; -} - -// ------------------ -// I_ShutdownGraphics -// Close the screen, restore previous video mode. -// ------------------ -void I_ShutdownGraphics(void) -{ - if (!graphics_started) - return; - - CONS_Printf("I_ShutdownGraphics()\n"); - - //FreeConsole(); - - // release windowed startup stuff - if (hDCMain) - { - ReleaseDC(hWndMain, hDCMain); - hDCMain = NULL; - } - if (bmiMain) - { - GlobalFree(bmiMain); - bmiMain = NULL; - } - -#ifdef HWRENDER - if (rendermode != render_soft) - { - HWR_Shutdown(); // free stuff from the hardware renderer - HWD.pfnShutdown(); // close 3d card display - Shutdown3DDriver(); // free the driver DLL - } -#endif - - // free the last video mode screen buffers - if (vid.buffer) - { - GlobalFree(vid.buffer); - vid.buffer = NULL; - } - -#ifdef HWRENDER - if (rendermode == render_soft) -#endif - CloseDirectDraw(); - - graphics_started = false; -} - -// -------------- -// I_UpdateNoBlit -// -------------- -void I_UpdateNoBlit(void) -{ - // what is this? -} - -// -------------- -// I_FinishUpdate -// -------------- -void I_FinishUpdate(void) -{ - int i; - - if (rendermode == render_none) - return; - - // display a graph of ticrate - if (cv_ticrate.value) - SCR_DisplayTicRate(); - - // - if (bDIBMode) - { - // paranoia - if (!hDCMain || !bmiMain || !vid.buffer) - return; - // main game loop, still in a window (-win parm) - SetDIBitsToDevice(hDCMain, 0, 0, 320, 200, 0, 0, 0, 200, vid.buffer, bmiMain, - DIB_RGB_COLORS); - } - else -#ifdef HWRENDER - if (rendermode != render_soft) - HWD.pfnFinishUpdate(cv_vidwait.value); - else -#endif - { - // DIRECT DRAW - // copy virtual screen to real screen - // can fail when not active (alt-tab) - if (LockScreen()) - { - /// \todo use directX blit here!!? a blit might use hardware with access - /// to main memory on recent hardware, and software blit of directX may be - /// optimized for p2 or mmx?? - VID_BlitLinearScreen(screens[0], ScreenPtr, vid.width*vid.bpp, vid.height, - vid.width*vid.bpp, ScreenPitch); - - UnlockScreen(); - - // swap screens - ScreenFlip(cv_vidwait.value); - } - } -} - -// -// This is meant to be called only by CONS_Printf() while game startup -// -void I_LoadingScreen(LPCSTR msg) -{ - RECT rect; - - // paranoia - if (!hDCMain || !bmiMain || !vid.buffer) - return; - - GetClientRect(vid.WndParent, &rect); - - SetDIBitsToDevice(hDCMain, 0, 0, 320, 200, 0, 0, 0, 200, vid.buffer, bmiMain, DIB_RGB_COLORS); - - if (msg) - { - if (rect.bottom - rect.top > 32) - rect.top = rect.bottom - 32; // put msg on bottom of window - SetBkMode(hDCMain, TRANSPARENT); - SetTextColor(hDCMain, RGB(0x00, 0x00, 0x00)); - DrawTextA(hDCMain, msg, -1, &rect, DT_WORDBREAK|DT_CENTER); - } -} - -// ------------ -// I_ReadScreen -// ------------ -void I_ReadScreen(UINT8 *scr) -{ - // DEBUGGING - if (rendermode != render_soft) - I_Error("I_ReadScreen: called while in non-software mode"); - VID_BlitLinearScreen(screens[0], scr, vid.width*vid.bpp, vid.height, vid.width*vid.bpp, - vid.rowbytes); -} - -// ------------ -// I_SetPalette -// ------------ -void I_SetPalette(RGBA_t *palette) -{ - int i; - - if (bDIBMode) - { - // set palette in RGBQUAD format, NOT THE SAME ORDER as PALETTEENTRY, grmpf! - RGBQUAD *pColors; - pColors = (RGBQUAD *)((char *)bmiMain + bmiMain->bmiHeader.biSize); - ZeroMemory(pColors, sizeof (RGBQUAD)*256); - for (i = 0; i < 256; i++, pColors++, palette++) - { - pColors->rgbRed = palette->s.red; - pColors->rgbGreen = palette->s.green; - pColors->rgbBlue = palette->s.blue; - } - } - else -#ifdef HWRENDER - if (rendermode == render_soft) -#endif - { - PALETTEENTRY mainpal[256]; - - // this clears the 'flag' for each color in palette - ZeroMemory(mainpal, sizeof mainpal); - - // set palette in PALETTEENTRY format - for (i = 0; i < 256; i++, palette++) - { - mainpal[i].peRed = palette->s.red; - mainpal[i].peGreen = palette->s.green; - mainpal[i].peBlue = palette->s.blue; - } - SetDDPalette(mainpal); // set DirectDraw palette - } -} - -// -// return number of video modes in pvidmodes list -// -INT32 VID_NumModes(void) -{ - return numvidmodes - NUMSPECIALMODES; //faB: dont accept the windowed mode 0 -} - -// return a video mode number from the dimensions -// returns any available video mode if the mode was not found -INT32 VID_GetModeForSize(INT32 w, INT32 h) -{ - vmode_t *pv = pvidmodes; - int modenum = 0; - - // skip the special modes so that it finds only fullscreen modes - for (; pv && modenum < NUMSPECIALMODES; pv = pv->pnext, ++modenum); - for (; pv; pv = pv->pnext, ++modenum) - if (pv->width == (unsigned)w && pv->height == (unsigned)h) - return modenum; - - // if not found, return the first mode available, - // preferably a full screen mode (all modes after the 'specialmodes') - if (numvidmodes > NUMSPECIALMODES) - return NUMSPECIALMODES; // use first full screen mode - - return 0; // no fullscreen mode, use windowed mode -} - -// -// Enumerate DirectDraw modes available -// -static int nummodes = 0; -static BOOL GetExtraModesCallback(int width, int height, int bpp) -{ - CONS_Printf("mode %d x %d x %d bpp\n", width, height, bpp); - - // skip all unwanted modes - if (highcolor && bpp != 15) - goto skip; - if (!highcolor && bpp != 8) - goto skip; - - if (bpp > 16 || width > MAXVIDWIDTH || height > MAXVIDHEIGHT) - goto skip; - - // check if we have space for this mode - if (nummodes >= MAX_EXTRA_MODES) - { - CONS_Printf("mode skipped (too many)\n"); - return FALSE; - } - - // store mode info - extra_modes[nummodes].pnext = &extra_modes[nummodes+1]; - memset(names[nummodes], 0, 10); - snprintf(names[nummodes], 9, "%dx%d", width, height); - - extra_modes[nummodes].name = names[nummodes]; - extra_modes[nummodes].width = width; - extra_modes[nummodes].height = height; - - // exactly, the current FinishUdpate() gets the rowbytes itself after locking the video buffer - // so for now we put anything here - extra_modes[nummodes].rowbytes = width; - extra_modes[nummodes].windowed = false; - extra_modes[nummodes].misc = 0; // unused - extra_modes[nummodes].pextradata = NULL; - extra_modes[nummodes].setmode = VID_SetDirectDrawMode; - - extra_modes[nummodes].numpages = 2; // double-buffer (but this value is unused) - - extra_modes[nummodes].bytesperpixel = (bpp+1)>>3; - - nummodes++; -skip: - return TRUE; -} - -// -// Collect info about DirectDraw display modes we use -// -static inline void VID_GetExtraModes(void) -{ - nummodes = 0; - EnumDirectDrawDisplayModes(GetExtraModesCallback); - - // add the extra modes (not 320x200) at the start of the mode list (if there are any) - if (nummodes) - { - extra_modes[nummodes-1].pnext = NULL; - pvidmodes = &extra_modes[0]; - numvidmodes += nummodes; - } -} - -// --------------- -// WindowMode_Init -// Add windowed modes to the start of the list, -// mode 0 is used for windowed console startup (works on all computers with no DirectX) -// --------------- -static void WindowMode_Init(void) -{ - specialmodes[NUMSPECIALMODES-1].pnext = pvidmodes; - pvidmodes = &specialmodes[0]; - numvidmodes += NUMSPECIALMODES; -} - -// ************************************************************************************* -// VID_Init -// Initialize Video modes subsystem -// ************************************************************************************* -static void VID_Init(void) -{ - vmode_t *pv; - int iMode; - - // if '-win' is specified on the command line, do not add DirectDraw modes - bWinParm = M_CheckParm("-win"); - - COM_AddCommand("vid_nummodes", VID_Command_NumModes_f); - COM_AddCommand("vid_modeinfo", VID_Command_ModeInfo_f); - COM_AddCommand("vid_modelist", VID_Command_ModeList_f); - COM_AddCommand("vid_mode", VID_Command_Mode_f); - - CV_RegisterVar(&cv_vidwait); - CV_RegisterVar(&cv_stretch); - - // setup the videmodes list, - // note that mode 0 must always be VGA mode 0x13 - pvidmodes = pcurrentmode = NULL; - numvidmodes = 0; - - // store the main window handle in viddef struct - SetWindowPos(hWndMain, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE|SWP_NOSENDCHANGING|SWP_NOSIZE|SWP_NOMOVE); - vid.WndParent = hWndMain; - vid.buffer = NULL; - - // we startup in windowed mode using DIB bitmap - // we will use DirectDraw when switching fullScreen and entering main game loop - bDIBMode = TRUE; - bAppFullScreen = FALSE; - -#ifdef HWRENDER - // initialize the appropriate display device - if (rendermode != render_soft) - { - const char *drvname = NULL; - - switch (rendermode) - { - case render_opengl: - drvname = "r_opengl.dll"; - break; - default: - I_Error("Unknown hardware render mode"); - } - - // load the DLL - if (drvname && Init3DDriver(drvname)) - { - int hwdversion = HWD.pfnGetRenderVersion(); - if (hwdversion != VERSION) - CONS_Printf("WARNING: This r_opengl version is not supported, use it at your own risk.\n"); - - // perform initialisations - HWD.pfnInit(I_Error); - // get available display modes for the device - HWD.pfnGetModeList(&pvidmodes, &numvidmodes); - } - else - { - switch (rendermode) - { - case render_opengl: - I_Error("Error initializing OpenGL"); - default: - break; - } - rendermode = render_soft; - } - } - - if (rendermode == render_soft) -#endif - if (!bWinParm) - { - if (!CreateDirectDrawInstance()) - I_Error("Error initializing DirectDraw"); - // get available display modes for the device - VID_GetExtraModes(); - } - - // the game boots in 320x200 standard VGA, but - // we need a highcolor mode to run the game in highcolor - if (highcolor && !numvidmodes) - I_Error("Cannot run in highcolor - No 15bit highcolor DirectX video mode found."); - - // add windowed mode at the start of the list, very important! - WindowMode_Init(); - - if (!numvidmodes) - I_Error("No display modes available."); - - // DEBUG - for (iMode = 0, pv = pvidmodes; pv; pv = pv->pnext, iMode++) - CONS_Printf("#%02d: %dx%dx%dbpp (desc: '%s')\n", iMode, pv->width, pv->height, - pv->bytesperpixel, pv->name); - - // set the startup screen in a window - VID_SetMode(0); -} - -// -------------------------- -// VID_SetWindowedDisplayMode -// Display the startup 320x200 console screen into a window on the desktop, -// switching to fullscreen display only when we will enter the main game loop. -// - we can display error message boxes for startup errors -// - we can set the last used resolution only once, when entering the main game loop -// -------------------------- -static int WINAPI VID_SetWindowedDisplayMode(viddef_t *lvid, vmode_t *pcurrentmode) -{ - int iScrWidth, iScrHeight, iWinWidth, iWinHeight; - - pcurrentmode = NULL; -#ifdef DEBUG - CONS_Printf("VID_SetWindowedDisplayMode()\n"); -#endif - - lvid->u.numpages = 1; // not used - lvid->direct = NULL; // DOS remains - lvid->buffer = NULL; - - // allocate screens - if (!VID_FreeAndAllocVidbuffer(lvid)) - return -1; - - // lvid->buffer should be NULL here! - - bmiMain = (void *)GlobalAlloc(GPTR, sizeof (BITMAPINFO) + (sizeof (RGBQUAD)*256)); - if (!bmiMain) - I_Error("VID_SWDM(): No mem"); - - // setup a BITMAPINFO to allow copying our video buffer to the desktop, - // with color conversion as needed - bmiMain->bmiHeader.biSize = sizeof (BITMAPINFOHEADER); - bmiMain->bmiHeader.biWidth = lvid->width; - bmiMain->bmiHeader.biHeight= -(lvid->height); - bmiMain->bmiHeader.biPlanes = 1; - bmiMain->bmiHeader.biBitCount = 8; - bmiMain->bmiHeader.biCompression = BI_RGB; - - // center window on the desktop - iScrWidth = GetSystemMetrics(SM_CXFULLSCREEN); - iScrHeight = GetSystemMetrics(SM_CYFULLSCREEN); - - iWinWidth = lvid->width; - iWinWidth += GetSystemMetrics(SM_CXFIXEDFRAME) * 2; - - iWinHeight = lvid->height; - iWinHeight += GetSystemMetrics(SM_CYCAPTION); - iWinHeight += GetSystemMetrics(SM_CYFIXEDFRAME) * 2; - - if (devparm) - MoveWindow(hWndMain, (iScrWidth - iWinWidth), (iScrHeight - iWinHeight), iWinWidth, iWinHeight, TRUE); - else - MoveWindow(hWndMain, (iScrWidth - iWinWidth)>>1, (iScrHeight - iWinHeight)>>1, iWinWidth, iWinHeight, TRUE); - - SetFocus(hWndMain); - ShowWindow(hWndMain, SW_SHOW); - - hDCMain = GetDC(hWndMain); - if (!hDCMain) - I_Error("VID_SWDM(): GetDC FAILED"); - - return 1; -} - -// ======================================================================== -// Returns a vmode_t from the video modes list, given a video mode number. -// ======================================================================== -vmode_t *VID_GetModePtr(int modenum) -{ - vmode_t *pv; - - pv = pvidmodes; - if (!pv) - I_Error("VID_error: No video mode found\n"); - - while (modenum--) - { - pv = pv->pnext; - if (!pv) - I_Error("VID_error: Mode not available\n"); - } - return pv; -} - -// -// return the name of a video mode -// -const char *VID_GetModeName(INT32 modenum) -{ - return (VID_GetModePtr(modenum))->name; -} - -// ======================================================================== -// Sets a video mode -// ======================================================================== -INT32 VID_SetMode(INT32 modenum) -{ - int stat; - vmode_t *pnewmode; - vmode_t *poldmode; - - if (dedicated) - return 0; - - CONS_Printf("VID_SetMode(%d)\n", modenum); - - // if mode 0 (windowed) we must not be fullscreen already, - // if other mode, check it is not mode 0 and existing - if (modenum >= numvidmodes) - { - if (!pcurrentmode) - modenum = 0; // revert to the default base vid mode - else - I_Error("Unknown video mode: %d\n", modenum); - } - else if (bAppFullScreen && modenum < NUMSPECIALMODES) - I_Error("Tried to switch from fullscreen back to windowed mode %d\n", modenum); - - pnewmode = VID_GetModePtr(modenum); - - // dont switch to the same display mode - if (pnewmode == pcurrentmode) - return 1; - - // initialize the new mode - poldmode = pcurrentmode; - pcurrentmode = pnewmode; - - // initialize vidbuffer size for setmode - vid.width = pcurrentmode->width; - vid.height = pcurrentmode->height; - vid.rowbytes = pcurrentmode->rowbytes; - vid.bpp = pcurrentmode->bytesperpixel; - if (modenum) // if not 320x200 windowed mode, it's actually a hack - { - if (rendermode == render_opengl) - { - // don't accept depth < 16 for OpenGL mode (too much ugly) - if (cv_scr_depth.value < 16) - CV_SetValue(&cv_scr_depth, 16); - vid.bpp = cv_scr_depth.value/8; - vid.u.windowed = (bWinParm || !cv_fullscreen.value); - pcurrentmode->bytesperpixel = vid.bpp; - pcurrentmode->windowed = vid.u.windowed; - } - } - - stat = (*pcurrentmode->setmode)(&vid, pcurrentmode); - - if (stat == -1) - I_Error("Not enough mem for VID_SetMode\n"); - else if (stat == -2) - I_Error("Couldn't set video mode because it failed the test\n"); - else if (stat == -3) - I_Error("Couldn't set video mode because it failed the change?\n"); - else if (!stat) - I_Error("Couldn't set video mode %d (%dx%d %d bits)\n", modenum, vid.width, vid.height, (vid.bpp*8));// hardware could not setup mode - else - CONS_Printf(M_GetText("Mode changed to %d (%s)\n"), modenum, pcurrentmode->name); - - vid.modenum = modenum; - - // tell game engine to recalc all tables and realloc buffers based on new values - vid.recalc = 1; - - if (modenum < NUMSPECIALMODES) - { - // we are in startup windowed mode - bAppFullScreen = FALSE; - bDIBMode = TRUE; - } - else - { - // we switch to fullscreen - bAppFullScreen = TRUE; - bDIBMode = FALSE; -#ifdef HWRENDER - if (rendermode != render_soft) - { - // purge all patch graphics stored in software format - //Z_FreeTags (PU_PURGELEVEL, PU_PURGELEVEL+100); - HWR_Startup(); - } -#endif - } - - I_RestartSysMouse(); - return 1; -} - -// ======================================================================== -// Free the video buffer of the last video mode, -// allocate a new buffer for the video mode to set. -// ======================================================================== -static BOOL VID_FreeAndAllocVidbuffer(viddef_t *lvid) -{ - const DWORD vidbuffersize = (lvid->width * lvid->height * lvid->bpp * NUMSCREENS); - - // free allocated buffer for previous video mode - if (lvid->buffer) - GlobalFree(lvid->buffer); - - // allocate & clear the new screen buffer - lvid->buffer = GlobalAlloc(GPTR, vidbuffersize); - if (!lvid->buffer) - return FALSE; - - ZeroMemory(lvid->buffer, vidbuffersize); -#ifdef DEBUG - CONS_Printf("VID_FreeAndAllocVidbuffer done, vidbuffersize: %x\n",vidbuffersize); -#endif - return TRUE; -} - -// ======================================================================== -// Set video mode routine for DirectDraw display modes -// Out: 1 ok, -// 0 hardware could not set mode, -// -1 no mem -// ======================================================================== -static int WINAPI VID_SetDirectDrawMode(viddef_t *lvid, vmode_t *pcurrentmode) -{ - pcurrentmode = NULL; -#ifdef DEBUG - CONS_Printf("VID_SetDirectDrawMode...\n"); -#endif - - // DD modes do double-buffer page flipping, but the game engine doesn't need this.. - lvid->u.numpages = 2; - - // release ddraw surfaces etc.. - ReleaseChtuff(); - - // clean up any old vid buffer lying around, alloc new if needed - if (!VID_FreeAndAllocVidbuffer(lvid)) - return -1; // no mem - - // should clear video mem here - - // note use lvid->bpp instead of 8...will this be needed? will we support other than 256color - // in software ? - if (!InitDirectDrawe(hWndMain, lvid->width, lvid->height, 8, TRUE)) // TRUE currently always full screen - return 0; // could not set mode - - // this is NOT used with DirectDraw modes, game engine should never use this directly - // but rather render to memory bitmap buffer - lvid->direct = NULL; - - if (!cv_stretch.value && (float)vid.width/vid.height != ((float)BASEVIDWIDTH/BASEVIDHEIGHT)) - vid.height = (int)(vid.width * ((float)BASEVIDHEIGHT/BASEVIDWIDTH));// Adjust the height to match - - return 1; -} - -// ======================================================================== -// VIDEO MODE CONSOLE COMMANDS -// ======================================================================== - -// vid_nummodes -// -static void VID_Command_NumModes_f(void) -{ - CONS_Printf(M_GetText("%d video mode(s) available(s)\n"), VID_NumModes()); -} - -// vid_modeinfo -// -static void VID_Command_ModeInfo_f(void) -{ - vmode_t *pv; - int modenum; - - if (COM_Argc() != 2) - modenum = vid.modenum; // describe the current mode - else - modenum = atoi(COM_Argv(1)); // the given mode number - - if (modenum >= VID_NumModes() || modenum < NUMSPECIALMODES) // don't accept the windowed mode 0 - { - CONS_Printf(M_GetText("Video mode not present\n")); - return; - } - - pv = VID_GetModePtr(modenum); - - CONS_Printf("%s\n", VID_GetModeName(modenum)); - CONS_Printf(M_GetText("width: %d\nheight: %d\n"), - pv->width, pv->height); - if (rendermode == render_soft) - CONS_Printf(M_GetText("bytes per scanline: %d\nbytes per pixel: %d\nnumpages: %d\n"), - pv->rowbytes, pv->bytesperpixel, pv->numpages); -} - -// vid_modelist -// -static void VID_Command_ModeList_f(void) -{ - int i, nummodes; - const char *pinfo; - vmode_t *pv; - - nummodes = VID_NumModes(); - for (i = NUMSPECIALMODES; i <= nummodes; i++) - { - pv = VID_GetModePtr(i); - pinfo = VID_GetModeName(i); - - if (pv->bytesperpixel == 1) - CONS_Printf("%d: %s\n", i, pinfo); - else - CONS_Printf("%d: %s (hicolor)\n", i, pinfo); - } -} - -// vid_mode -// -static void VID_Command_Mode_f(void) -{ - int modenum; - - if (COM_Argc() != 2) - { - CONS_Printf(M_GetText("vid_mode : set video mode, current video mode %i\n"), vid.modenum); - return; - } - - modenum = atoi(COM_Argv(1)); - - if (modenum >= VID_NumModes() || modenum < NUMSPECIALMODES) // don't accept the windowed mode 0 - CONS_Printf(M_GetText("Video mode not present\n")); - else - setmodeneeded = modenum + 1; // request vid mode change -} diff --git a/src/win32ce/wince_stuff.c b/src/win32ce/wince_stuff.c deleted file mode 100644 index eb02e8ae2..000000000 --- a/src/win32ce/wince_stuff.c +++ /dev/null @@ -1,135 +0,0 @@ -//It's 4am and im writing replacement string functions.... - -#include -#include -#include "wince_stuff.h" - -char* _strlwr( char *string ) -{ - int i; - - if(!string) - return NULL; - - for(i=0 ; i < strlen(string); i++) - { - if((*(string + i) >= 65) && (*(string + i) <= 90)) - *(string+i) = *(string+i) + 32; - } - - return string; -} - -int _strnicmp(const char *first,const char *last, size_t count ) -{ - int f, l; - - do - { - if ( ((f = (unsigned char)(*(first++))) >= 'A') && (f <= 'Z') ) - f -= 'A' - 'a'; - - if ( ((l = (unsigned char)(*(last++))) >= 'A') && (l <= 'Z') ) - l -= 'A' - 'a'; - - } while ( --count && f && (f == l) ); - - return ( f - l ); -} - - -int _stricmp( const char *dst, const char *src ) -{ - int f, l; - - do - { - if ( ((f = (unsigned char)(*(dst++))) >= 'A') && (f <= 'Z') ) - f -= 'A' - 'a'; - - if ( ((l = (unsigned char)(*(src++))) >= 'A') && (l <= 'Z') ) - l -= 'A' - 'a'; - - } while ( f && (f == l) ); - - return(f - l); -} - - -char* _strupr( char *string ) -{ - int i; - - if(!string) - return NULL; - - for(i=0 ; i < strlen(string); i++) - { - if((*(string + i) >= 97) && (*(string + i) <= 122)) - *(string + i) = *(string + i) - 32; - } - - return string; -} - - - - -int isprint( int c ) -{ - if(c <= 31) - return FALSE; - - return TRUE; -} - - - -char* _strdup (const char * string) -{ - char *memory = NULL; - - if (!string) - return(NULL); - - if (memory = malloc(strlen(string) + 1)) - return(strcpy(memory,string)); - - return(NULL); -} - - - -char* strrchr (const char * string,int ch) -{ - char *start = (char *)string; - - while (*string++) /* find end of string */ - ; - /* search towards front */ - while (--string != start && *string != (char)ch) - ; - - if (*string == (char)ch) /* char found ? */ - return( (char *)string ); - - return(NULL); -} - -char* GetMyCWD(void) -{ - TCHAR fn[MAX_PATH]; - char* my_cwd,*p; - - GetModuleFileName(NULL,fn,MAX_PATH); - - my_cwd = (char*)malloc(MAX_PATH*sizeof(char)); - - WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR | WC_SEPCHARS, fn, -1, my_cwd, MAX_PATH, NULL, NULL); - p = strrchr(my_cwd,'\\'); - - if(p) - *(p+1) = '\0'; - - return my_cwd; -} diff --git a/src/win32ce/wince_stuff.h b/src/win32ce/wince_stuff.h deleted file mode 100644 index 5eab74848..000000000 --- a/src/win32ce/wince_stuff.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef WINCE_STUFF_H -#define WINCE_STUFF_H - -/* -char* _strlwr(char *string); -int _strnicmp(const char *string1,const char *string2, size_t count ); -int _stricmp( const char *string1, const char *string2 ); -char* _strupr( char *string ); - -char *_strdup( const char *strSource ); -char *strrchr( const char *string, int c ); - -int isprint( int c ); -*/ -char* GetMyCWD(void); - -#endif \ No newline at end of file diff --git a/src/y_inter.c b/src/y_inter.c index 4b340cabd..94a289817 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004-2018 by Sonic Team Junior. +// Copyright (C) 2004-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -19,7 +19,7 @@ #include "i_video.h" #include "p_tick.h" #include "r_defs.h" -#include "r_things.h" +#include "r_skins.h" #include "s_sound.h" #include "st_stuff.h" #include "v_video.h" @@ -35,6 +35,9 @@ #include "p_local.h" #include "m_cond.h" // condition sets +#include "lua_hook.h" // IntermissionThinker hook + +#include "lua_hud.h" #ifdef HWRENDER #include "hardware/hw_main.h" @@ -70,15 +73,15 @@ typedef union UINT32 score, total; // fake score, total UINT32 tics; // time - patch_t *ttlnum; // act number being displayed + INT32 actnum; // act number being displayed patch_t *ptotal; // TOTAL UINT8 gotlife; // Number of extra lives obtained } coop; struct { - char passed1[29]; // KNUCKLES GOT / CRAWLA HONCHO - char passed2[17]; // A CHAOS EMERALD / GOT THEM ALL! + char passed1[29]; // KNUCKLES GOT / CRAWLA HONCHO + char passed2[17]; // A CHAOS EMERALD? / GOT THEM ALL! char passed3[15]; // CAN NOW BECOME char passed4[SKINNAMESIZE+7]; // SUPER CRAWLA HONCHO INT32 passedx1; @@ -86,8 +89,8 @@ typedef union INT32 passedx3; INT32 passedx4; - y_bonus_t bonus; - patch_t *bonuspatch; + y_bonus_t bonuses[2]; + patch_t *bonuspatches[2]; patch_t *pscore; // SCORE UINT32 score; // fake score @@ -142,36 +145,172 @@ static patch_t *widebgpatch = NULL; // INTERSCW static patch_t *bgtile = NULL; // SPECTILE/SRB2BACK static patch_t *interpic = NULL; // custom picture defined in map header static boolean usetile; -boolean usebuffer = false; -static boolean useinterpic; static INT32 timer; +typedef struct +{ + INT32 source_width, source_height; + INT32 source_bpp, source_rowbytes; + UINT8 *source_picture; + INT32 target_width, target_height; + INT32 target_bpp, target_rowbytes; + UINT8 *target_picture; +} y_buffer_t; + +boolean usebuffer = false; +static boolean useinterpic; +static boolean safetorender = true; +static y_buffer_t *y_buffer; + static INT32 intertic; +static INT32 tallydonetic = -1; static INT32 endtic = -1; intertype_t intertype = int_none; +intertype_t intermissiontypes[NUMGAMETYPES]; +static void Y_RescaleScreenBuffer(void); static void Y_AwardCoopBonuses(void); static void Y_AwardSpecialStageBonus(void); static void Y_CalculateCompetitionWinners(void); static void Y_CalculateTimeRaceWinners(void); static void Y_CalculateMatchWinners(void); -static void Y_FollowIntermission(void); static void Y_UnloadData(void); +static void Y_CleanupData(void); // Stuff copy+pasted from st_stuff.c -static INT32 SCX(INT32 x) +#define ST_DrawNumFromHud(h,n) V_DrawTallNum(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f, n) +#define ST_DrawPadNumFromHud(h,n,q) V_DrawPaddedTallNum(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f, n, q) +#define ST_DrawPatchFromHud(h,p) V_DrawScaledPatch(hudinfo[h].x, hudinfo[h].y, hudinfo[h].f, p) + +static void Y_IntermissionTokenDrawer(void) { - return FixedInt(FixedMul(x<height)/2; + + em = 0; + while (emeralds & (1 << em)) + if (++em == 7) + return; + + if (tallydonetic != -1) + { + offs = (intertic - tallydonetic)*2; + if (offs > 10) + offs = 8; + } + + V_DrawSmallScaledPatch(32, lowy-1, 0, emeraldpics[2][em]); // coinbox + + y = (lowy + offs + 1) - (temp + (token + 1)*8); + + for (tokencount = token; tokencount; tokencount--) + { + if (y >= -temp) + V_DrawSmallScaledPatch(32, y, 0, tokenicon); + y += 8; + } + + y += (offs*(temp - 1)/8); + calc = (lowy - y)*2; + + if (calc > 0) + V_DrawCroppedPatch(32<width), calc); } -#define ST_DrawNumFromHud(h,n) V_DrawTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART, n) -#define ST_DrawPadNumFromHud(h,n,q) V_DrawPaddedTallNum(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART, n, q) -#define ST_DrawPatchFromHud(h,p) V_DrawScaledPatch(SCX(hudinfo[h].x), SCY(hudinfo[h].y), V_NOSCALESTART, p) +// +// Y_ConsiderScreenBuffer +// +// Can we copy the current screen +// to a buffer? +// +void Y_ConsiderScreenBuffer(void) +{ + if (gameaction != ga_completed) + return; + + if (y_buffer == NULL) + y_buffer = Z_Calloc(sizeof(y_buffer_t), PU_STATIC, NULL); + else + return; + + y_buffer->source_width = vid.width; + y_buffer->source_height = vid.height; + y_buffer->source_bpp = vid.bpp; + y_buffer->source_rowbytes = vid.rowbytes; + y_buffer->source_picture = ZZ_Alloc(y_buffer->source_width*vid.bpp * y_buffer->source_height); + VID_BlitLinearScreen(screens[1], y_buffer->source_picture, vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); + + // Make the rescaled screen buffer + Y_RescaleScreenBuffer(); +} + +// +// Y_RescaleScreenBuffer +// +// Write the rescaled source picture, +// to the destination picture that +// has the current screen's resolutions. +// +static void Y_RescaleScreenBuffer(void) +{ + INT32 sx, sy; // source + INT32 dx, dy; // dest + fixed_t scalefac, yscalefac; + fixed_t rowfrac, colfrac; + UINT8 *dest; + + // Who knows? + if (y_buffer == NULL) + return; + + if (y_buffer->target_picture) + Z_Free(y_buffer->target_picture); + + y_buffer->target_width = vid.width; + y_buffer->target_height = vid.height; + y_buffer->target_rowbytes = vid.rowbytes; + y_buffer->target_bpp = vid.bpp; + y_buffer->target_picture = ZZ_Alloc(y_buffer->target_width*vid.bpp * y_buffer->target_height); + dest = y_buffer->target_picture; + + scalefac = FixedDiv(y_buffer->target_width*FRACUNIT, y_buffer->source_width*FRACUNIT); + yscalefac = FixedDiv(y_buffer->target_height*FRACUNIT, y_buffer->source_height*FRACUNIT); + + rowfrac = FixedDiv(FRACUNIT, yscalefac); + colfrac = FixedDiv(FRACUNIT, scalefac); + + for (sy = 0, dy = 0; sy < (y_buffer->source_height << FRACBITS) && dy < y_buffer->target_height; sy += rowfrac, dy++) + for (sx = 0, dx = 0; sx < (y_buffer->source_width << FRACBITS) && dx < y_buffer->target_width; sx += colfrac, dx += y_buffer->target_bpp) + dest[(dy * y_buffer->target_rowbytes) + dx] = y_buffer->source_picture[((sy>>FRACBITS) * y_buffer->source_width) + (sx>>FRACBITS)]; +} + +// +// Y_CleanupScreenBuffer +// +// Free all related memory. +// +void Y_CleanupScreenBuffer(void) +{ + // Who knows? + if (y_buffer == NULL) + return; + + if (y_buffer->target_picture) + Z_Free(y_buffer->target_picture); + + if (y_buffer->source_picture) + Z_Free(y_buffer->source_picture); + + Z_Free(y_buffer); + y_buffer = NULL; +} // // Y_IntermissionDrawer @@ -184,23 +323,51 @@ void Y_IntermissionDrawer(void) // Bonus loops INT32 i; - if (intertype == int_none || rendermode == render_none) + if (rendermode == render_none) return; + if (intertype == int_none) + { + LUAh_IntermissionHUD(); + return; + } + if (!usebuffer) + // Lactozilla: Renderer switching + if (needpatchrecache) + { + Y_CleanupData(); + safetorender = false; + } + + if (!usebuffer || !safetorender) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); + if (!safetorender) + goto dontdrawbg; + if (useinterpic) V_DrawScaledPatch(0, 0, 0, interpic); else if (!usetile) { if (rendermode == render_soft && usebuffer) - VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); -#ifdef HWRENDER - else if(rendermode != render_soft && usebuffer) { - HWR_DrawIntermissionBG(); + // no y_buffer + if (y_buffer == NULL) + VID_BlitLinearScreen(screens[1], screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); + else + { + // Maybe the resolution changed? + if ((y_buffer->target_width != vid.width) || (y_buffer->target_height != vid.height)) + Y_RescaleScreenBuffer(); + + // Blit the already-scaled screen buffer to the current screen + VID_BlitLinearScreen(y_buffer->target_picture, screens[0], vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.rowbytes); + } } +#ifdef HWRENDER + else if (rendermode != render_soft && usebuffer) + HWR_DrawIntermissionBG(); #endif else { @@ -213,55 +380,71 @@ void Y_IntermissionDrawer(void) else V_DrawPatchFill(bgtile); + LUAh_IntermissionHUD(); + if (!LUA_HudEnabled(hud_intermissiontally)) + goto skiptallydrawer; + +dontdrawbg: if (intertype == int_coop) { INT32 bonusy; - // draw score - ST_DrawPatchFromHud(HUD_SCORE, sboscore); - ST_DrawNumFromHud(HUD_SCORENUM, data.coop.score); + if (gottoken) // first to be behind everything else + Y_IntermissionTokenDrawer(); - // draw time - ST_DrawPatchFromHud(HUD_TIME, sbotime); - if (cv_timetic.value == 1) - ST_DrawNumFromHud(HUD_SECONDS, data.coop.tics); - else + if (!splitscreen) { - INT32 seconds, minutes, tictrn; + // draw score + ST_DrawPatchFromHud(HUD_SCORE, sboscore); + ST_DrawNumFromHud(HUD_SCORENUM, data.coop.score); - seconds = G_TicsToSeconds(data.coop.tics); - minutes = G_TicsToMinutes(data.coop.tics, true); - tictrn = G_TicsToCentiseconds(data.coop.tics); - - ST_DrawNumFromHud(HUD_MINUTES, minutes); // Minutes - ST_DrawPatchFromHud(HUD_TIMECOLON, sbocolon); // Colon - ST_DrawPadNumFromHud(HUD_SECONDS, seconds, 2); // Seconds - - // we should show centiseconds on the intermission screen too, if the conditions are right. - if (modeattacking || cv_timetic.value == 2) + // draw time + ST_DrawPatchFromHud(HUD_TIME, sbotime); + if (cv_timetic.value == 3) + ST_DrawNumFromHud(HUD_SECONDS, data.coop.tics); + else { - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics + INT32 seconds, minutes, tictrn; + + seconds = G_TicsToSeconds(data.coop.tics); + minutes = G_TicsToMinutes(data.coop.tics, true); + tictrn = G_TicsToCentiseconds(data.coop.tics); + + ST_DrawNumFromHud(HUD_MINUTES, minutes); // Minutes + ST_DrawPatchFromHud(HUD_TIMECOLON, sbocolon); // Colon + ST_DrawPadNumFromHud(HUD_SECONDS, seconds, 2); // Seconds + + if (cv_timetic.value == 1 || cv_timetic.value == 2 || modeattacking) // there's not enough room for tics in splitscreen, don't even bother trying! + { + ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period + ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics + } } } // draw the "got through act" lines and act number V_DrawLevelTitle(data.coop.passedx1, 49, 0, data.coop.passed1); - V_DrawLevelTitle(data.coop.passedx2, 49+V_LevelNameHeight(data.coop.passed2)+2, 0, data.coop.passed2); + { + INT32 h = V_LevelNameHeight(data.coop.passed2); + V_DrawLevelTitle(data.coop.passedx2, 49+h+2, 0, data.coop.passed2); - if (mapheaderinfo[gamemap-1]->actnum) - V_DrawScaledPatch(244, 57, 0, data.coop.ttlnum); + if (data.coop.actnum) + V_DrawLevelActNum(244, 42+h, 0, data.coop.actnum); + } bonusy = 150; // Total - V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal); - V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total); + if (safetorender) + { + V_DrawScaledPatch(152, bonusy, 0, data.coop.ptotal); + V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.total); + } bonusy -= (3*SHORT(tallnum[0]->height)/2) + 1; // Draw bonuses for (i = 3; i >= 0; --i) { - if (data.coop.bonuses[i].display) + if (data.coop.bonuses[i].display && safetorender) { V_DrawScaledPatch(152, bonusy, 0, data.coop.bonuspatches[i]); V_DrawTallNum(BASEVIDWIDTH - 68, bonusy + 1, 0, data.coop.bonuses[i].points); @@ -276,86 +459,208 @@ void Y_IntermissionDrawer(void) INT32 xoffset1 = 0; // Line 1 x offset INT32 xoffset2 = 0; // Line 2 x offset INT32 xoffset3 = 0; // Line 3 x offset + INT32 xoffset4 = 0; // Line 4 x offset + INT32 xoffset5 = 0; // Line 5 x offset + INT32 xoffset6 = 0; // Line 6 x offset UINT8 drawsection = 0; - // draw the header - if (intertic <= TICRATE) - animatetic = 0; - else if (!animatetic && data.spec.bonus.points == 0 && data.spec.passed3[0] != '\0') - animatetic = intertic; + if (gottoken) // first to be behind everything else + Y_IntermissionTokenDrawer(); - if (animatetic) + // draw the header + if (intertic <= 2*TICRATE) + animatetic = 0; + else if (!animatetic && data.spec.bonuses[0].points == 0 && data.spec.bonuses[1].points == 0 && data.spec.passed3[0] != '\0') + animatetic = intertic + TICRATE; + + if (animatetic && (tic_t)intertic >= animatetic) { + const INT32 scradjust = (vid.width/vid.dupx)>>3; // 40 for BASEVIDWIDTH INT32 animatetimer = (intertic - animatetic); - if (animatetimer <= 8) + if (animatetimer <= 16) { - xoffset1 = -(animatetimer * 40); - xoffset2 = -((animatetimer-2) * 40); + xoffset1 = -(animatetimer * scradjust); + xoffset2 = -((animatetimer- 2) * scradjust); + xoffset3 = -((animatetimer- 4) * scradjust); + xoffset4 = -((animatetimer- 6) * scradjust); + xoffset5 = -((animatetimer- 8) * scradjust); + xoffset6 = -((animatetimer-10) * scradjust); if (xoffset2 > 0) xoffset2 = 0; + if (xoffset3 > 0) xoffset3 = 0; + if (xoffset4 > 0) xoffset4 = 0; + if (xoffset5 > 0) xoffset5 = 0; + if (xoffset6 > 0) xoffset6 = 0; } - else if (animatetimer <= 19) + else if (animatetimer < 34) { drawsection = 1; - xoffset1 = (16-animatetimer) * 40; - xoffset2 = (18-animatetimer) * 40; - xoffset3 = (20-animatetimer) * 40; + xoffset1 = (24-animatetimer) * scradjust; + xoffset2 = (26-animatetimer) * scradjust; + xoffset3 = (28-animatetimer) * scradjust; + xoffset4 = (30-animatetimer) * scradjust; + xoffset5 = (32-animatetimer) * scradjust; + xoffset6 = (34-animatetimer) * scradjust; if (xoffset1 < 0) xoffset1 = 0; if (xoffset2 < 0) xoffset2 = 0; + if (xoffset3 < 0) xoffset3 = 0; + if (xoffset4 < 0) xoffset4 = 0; + if (xoffset5 < 0) xoffset5 = 0; } else + { drawsection = 1; + if (animatetimer == 32) + S_StartSound(NULL, sfx_s3k68); + } } if (drawsection == 1) { - ttheight = 16; + const char *ringtext = "\x82" "50 rings, no shield"; + const char *tut1text = "\x82" "press " "\x80" "spin"; + const char *tut2text = "\x82" "mid-" "\x80" "jump"; + ttheight = 8; V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); ttheight += V_LevelNameHeight(data.spec.passed3) + 2; V_DrawLevelTitle(data.spec.passedx3 + xoffset2, ttheight, 0, data.spec.passed3); ttheight += V_LevelNameHeight(data.spec.passed4) + 2; V_DrawLevelTitle(data.spec.passedx4 + xoffset3, ttheight, 0, data.spec.passed4); - } - else if (data.spec.passed1[0] != '\0') - { - ttheight = 24; - V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); - ttheight += V_LevelNameHeight(data.spec.passed2) + 2; - V_DrawLevelTitle(data.spec.passedx2 + xoffset2, ttheight, 0, data.spec.passed2); + + ttheight = 108; + V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset4 - (V_LevelNameWidth(ringtext)/2), ttheight, 0, ringtext); + ttheight += V_LevelNameHeight(tut1text) + 2; + V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset5 - (V_LevelNameWidth(tut1text)/2), ttheight, 0, tut1text); + ttheight += V_LevelNameHeight(tut2text) + 2; + V_DrawLevelTitle(BASEVIDWIDTH/2 + xoffset6 - (V_LevelNameWidth(tut2text)/2), ttheight, 0, tut2text); } else { - ttheight = 24 + (V_LevelNameHeight(data.spec.passed2)/2) + 2; - V_DrawLevelTitle(data.spec.passedx2 + xoffset1, ttheight, 0, data.spec.passed2); - } - - // draw the emeralds - if (intertic & 1) - { - INT32 emeraldx = 80; - for (i = 0; i < 7; ++i) + INT32 yoffset = 0; + if (data.spec.passed1[0] != '\0') { - if (emeralds & (1 << i)) - V_DrawScaledPatch(emeraldx, 74, 0, emeraldpics[i]); - emeraldx += 24; + ttheight = 24; + V_DrawLevelTitle(data.spec.passedx1 + xoffset1, ttheight, 0, data.spec.passed1); + ttheight += V_LevelNameHeight(data.spec.passed2) + 2; + V_DrawLevelTitle(data.spec.passedx2 + xoffset2, ttheight, 0, data.spec.passed2); + } + else + { + ttheight = 24 + (V_LevelNameHeight(data.spec.passed2)/2) + 2; + V_DrawLevelTitle(data.spec.passedx2 + xoffset1, ttheight, 0, data.spec.passed2); + } + + V_DrawScaledPatch(152 + xoffset3, 108, 0, data.spec.bonuspatches[0]); + V_DrawTallNum(BASEVIDWIDTH + xoffset3 - 68, 109, 0, data.spec.bonuses[0].points); + if (data.spec.bonuses[1].display) + { + V_DrawScaledPatch(152 + xoffset4, 124, 0, data.spec.bonuspatches[1]); + V_DrawTallNum(BASEVIDWIDTH + xoffset4 - 68, 125, 0, data.spec.bonuses[1].points); + yoffset = 16; + // hack; pass the buck along... + xoffset4 = xoffset5; + xoffset5 = xoffset6; + } + V_DrawScaledPatch(152 + xoffset4, 124+yoffset, 0, data.spec.pscore); + V_DrawTallNum(BASEVIDWIDTH + xoffset4 - 68, 125+yoffset, 0, data.spec.score); + + // Draw continues! + if (!multiplayer /* && (data.spec.continues & 0x80) */) // Always draw outside of netplay + { + UINT8 continues = data.spec.continues & 0x7F; + + V_DrawScaledPatch(152 + xoffset5, 150+yoffset, 0, data.spec.pcontinues); + if (continues > 5) + { + INT32 leftx = (continues >= 10) ? 216 : 224; + V_DrawContinueIcon(leftx + xoffset5, 162+yoffset, 0, *data.spec.playerchar, *data.spec.playercolor); + V_DrawScaledPatch(leftx + xoffset5 + 12, 160+yoffset, 0, stlivex); + if (!((data.spec.continues & 0x80) && !(endtic < 0 || intertic%20 < 10))) + V_DrawRightAlignedString(252 + xoffset5, 158+yoffset, 0, + va("%d",(((data.spec.continues & 0x80) && (endtic < 0)) ? continues-1 : continues))); + } + else + { + for (i = 0; i < continues; ++i) + { + if ((data.spec.continues & 0x80) && i == continues-1 && (endtic < 0 || intertic%20 < 10)) + break; + V_DrawContinueIcon(246 + xoffset5 - (i*20), 162+yoffset, 0, *data.spec.playerchar, *data.spec.playercolor); + } + } } } - V_DrawScaledPatch(152, 108, 0, data.spec.bonuspatch); - V_DrawTallNum(BASEVIDWIDTH - 68, 109, 0, data.spec.bonus.points); - V_DrawScaledPatch(152, 124, 0, data.spec.pscore); - V_DrawTallNum(BASEVIDWIDTH - 68, 125, 0, data.spec.score); - - // Draw continues! - if (!multiplayer /* && (data.spec.continues & 0x80) */) // Always draw outside of netplay + // draw the emeralds + //if (intertic & 1) { - UINT8 continues = data.spec.continues & 0x7F; + boolean drawthistic = !(ALL7EMERALDS(emeralds) && (intertic & 1)); + INT32 emeraldx = 152 - 3*28; + INT32 em = P_GetNextEmerald(); - V_DrawScaledPatch(152, 150, 0, data.spec.pcontinues); - for (i = 0; i < continues; ++i) + if (em == 7) { - if ((data.spec.continues & 0x80) && i == continues-1 && (endtic < 0 || intertic%20 < 10)) - break; - V_DrawContinueIcon(246 - (i*12), 162, 0, *data.spec.playerchar, *data.spec.playercolor); + if (!stagefailed) + { + fixed_t adjust = 2*(FINESINE(FixedAngle((intertic + 1)<<(FRACBITS-4)) & FINEMASK)); + V_DrawFixedPatch(152< 74) + { + S_StartSound(NULL, sfx_tink); // tink + emeraldbounces++; + emeraldmomy = -(emeraldmomy/2); + emeraldy = 74; + } + } + } + else + { + if (emeraldy < (vid.height/vid.dupy)+16) + { + emeraldy += (++emeraldmomy); + emeraldx += intertic - 6; + } + if (emeraldbounces < 1 && emeraldy > 74) + { + S_StartSound(NULL, sfx_shldls); // nope + emeraldbounces++; + emeraldmomy = -(emeraldmomy/2); + emeraldy = 74; + } + } + if (drawthistic) + V_DrawScaledPatch(emeraldx, emeraldy, 0, emeraldpics[0][em]); + } } } } @@ -368,7 +673,8 @@ void Y_IntermissionDrawer(void) char strtime[10]; // draw the header - V_DrawScaledPatch(112, 2, 0, data.match.result); + if (safetorender) + V_DrawScaledPatch(112, 2, 0, data.match.result); // draw the level name V_DrawCenteredString(BASEVIDWIDTH/2, 20, 0, data.match.levelstring); @@ -434,7 +740,7 @@ void Y_IntermissionDrawer(void) V_DrawRightAlignedString(x+152, y, 0, va("%i", data.match.scores[i])); else if (intertype == int_race) { - if (players[data.match.num[i]].pflags & PF_TIMEOVER) + if (players[data.match.num[i]].pflags & PF_GAMETYPEOVER) snprintf(strtime, sizeof strtime, "DNF"); else snprintf(strtime, sizeof strtime, @@ -452,7 +758,7 @@ void Y_IntermissionDrawer(void) V_DrawRightAlignedString(x+152+BASEVIDWIDTH/2, y, 0, va("%u", data.match.scores[i])); else if (intertype == int_race) { - if (players[data.match.num[i]].pflags & PF_TIMEOVER) + if (players[data.match.num[i]].pflags & PF_GAMETYPEOVER) snprintf(strtime, sizeof strtime, "DNF"); else snprintf(strtime, sizeof strtime, "%i:%02i.%02i", G_TicsToMinutes(data.match.scores[i], true), @@ -543,7 +849,7 @@ void Y_IntermissionDrawer(void) } } } - else if (intertype == int_classicrace) + else if (intertype == int_comp) { INT32 x = 4; INT32 y = 48; @@ -602,7 +908,7 @@ void Y_IntermissionDrawer(void) // already constrained to 8 characters V_DrawString(x+36, y, V_ALLOWLOWERCASE, data.competition.name[i]); - if (players[data.competition.num[i]].pflags & PF_TIMEOVER) + if (players[data.competition.num[i]].pflags & PF_GAMETYPEOVER) snprintf(sstrtime, sizeof sstrtime, "Time Over"); else if (players[data.competition.num[i]].lives <= 0) snprintf(sstrtime, sizeof sstrtime, "Game Over"); @@ -632,6 +938,10 @@ void Y_IntermissionDrawer(void) } } +skiptallydrawer: + if (!LUA_HudEnabled(hud_intermissionmessages)) + return; + if (timer) V_DrawCenteredString(BASEVIDWIDTH/2, 188, V_YELLOWMAP, va("start in %d seconds", timer/TICRATE)); @@ -655,6 +965,8 @@ void Y_Ticker(void) if (paused || P_AutoPause()) return; + LUAh_IntermissionThinker(); + intertic++; // Team scramble code for team match and CTF. @@ -673,7 +985,7 @@ void Y_Ticker(void) if (!--timer) { Y_EndIntermission(); - Y_FollowIntermission(); + G_AfterIntermission(); return; } } @@ -681,7 +993,7 @@ void Y_Ticker(void) else if (intertic == endtic) { Y_EndIntermission(); - Y_FollowIntermission(); + G_AfterIntermission(); return; } @@ -696,7 +1008,20 @@ void Y_Ticker(void) boolean anybonuses = false; if (!intertic) // first time only - S_ChangeMusicInternal("lclear", false); // don't loop it + { + if (mapheaderinfo[gamemap-1]->musinterfadeout +#ifdef _WIN32 + // can't fade midi due to win32 volume hack + && S_MusicType() != MU_MID +#endif + ) + S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout); + else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) + S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it + else + S_ChangeMusicInternal("_clear", false); // don't loop it + tallydonetic = -1; + } if (intertic < TICRATE) // one second pause before tally begins return; @@ -720,20 +1045,23 @@ void Y_Ticker(void) data.coop.total += data.coop.bonuses[i].points; data.coop.bonuses[i].points = 0; } + if (data.coop.score > MAXSCORE) + data.coop.score = MAXSCORE; if (data.coop.bonuses[i].points > 0) anybonuses = true; } if (!anybonuses) { + tallydonetic = intertic; endtic = intertic + 3*TICRATE; // 3 second pause after end of tally - S_StartSound(NULL, sfx_chchng); // cha-ching! + S_StartSound(NULL, (gottoken ? sfx_token : sfx_chchng)); // cha-ching! // Update when done with tally if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && !demoplayback) { if (M_UpdateUnlockablesAndExtraEmblems()) - S_StartSound(NULL, sfx_ncitem); + S_StartSound(NULL, sfx_s3k68); G_SaveGameData(); } @@ -752,55 +1080,80 @@ void Y_Ticker(void) { INT32 i; UINT32 oldscore = data.spec.score; - boolean skip = false; - static INT32 tallydonetic = 0; + boolean skip = false, super = false, anybonuses = false; if (!intertic) // first time only { - S_ChangeMusicInternal("lclear", false); // don't loop it - tallydonetic = 0; + if (mapheaderinfo[gamemap-1]->musinterfadeout +#ifdef _WIN32 + // can't fade midi due to win32 volume hack + && S_MusicType() != MU_MID +#endif + ) + S_FadeOutStopMusic(mapheaderinfo[gamemap-1]->musinterfadeout); + else if (mapheaderinfo[gamemap-1]->musintername[0] && S_MusicExists(mapheaderinfo[gamemap-1]->musintername, !midi_disabled, !digital_disabled)) + S_ChangeMusicInternal(mapheaderinfo[gamemap-1]->musintername, false); // don't loop it + else + S_ChangeMusicInternal("_clear", false); // don't loop it + tallydonetic = -1; } - if (intertic < TICRATE) // one second pause before tally begins + if (intertic < 2*TICRATE) // TWO second pause before tally begins, thank you mazmazz return; for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && (players[i].cmd.buttons & BT_USE)) - skip = true; + if (playeringame[i]) + { + if (players[i].cmd.buttons & BT_USE) + skip = true; + if (players[i].charflags & SF_SUPER) + super = true; + } - if (tallydonetic != 0) + if (tallydonetic != -1 && ((data.spec.continues & 0x80) || (super && ALL7EMERALDS(emeralds)))) { - if (intertic > tallydonetic) + if ((intertic - tallydonetic) > (3*TICRATE)/2) { endtic = intertic + 4*TICRATE; // 4 second pause after end of tally - S_StartSound(NULL, sfx_flgcap); // cha-ching! + if (data.spec.continues & 0x80) + S_StartSound(NULL, sfx_s3kac); // bingly-bingly-bing! + } return; } - // ring bonus counts down by 222 each tic - data.spec.bonus.points -= 222; - data.spec.score += 222; - if (data.spec.bonus.points < 0 || skip == true) // went too far + // bonuses count down by 222 each tic + for (i = 0; i < 2; ++i) { - data.spec.score += data.spec.bonus.points; - data.spec.bonus.points = 0; + if (!data.spec.bonuses[i].points) + continue; + + data.spec.bonuses[i].points -= 222; + data.spec.score += 222; + if (data.spec.bonuses[i].points < 0 || skip == true) // too far? + { + data.spec.score += data.spec.bonuses[i].points; + data.spec.bonuses[i].points = 0; + } + if (data.spec.score > MAXSCORE) + data.spec.score = MAXSCORE; + if (data.spec.bonuses[i].points > 0) + anybonuses = true; } - if (!data.spec.bonus.points) + if (!anybonuses) { - if (data.spec.continues & 0x80) // don't set endtic yet! - tallydonetic = intertic + (3*TICRATE)/2; - else // okay we're good. + tallydonetic = intertic; + if (!((data.spec.continues & 0x80) || (super && ALL7EMERALDS(emeralds)))) // don't set endtic yet! endtic = intertic + 4*TICRATE; // 4 second pause after end of tally - S_StartSound(NULL, sfx_chchng); // cha-ching! + S_StartSound(NULL, (gottoken ? sfx_token : sfx_chchng)); // cha-ching! // Update when done with tally if ((!modifiedgame || savemoddata) && !(netgame || multiplayer) && !demoplayback) { if (M_UpdateUnlockablesAndExtraEmblems()) - S_StartSound(NULL, sfx_ncitem); + S_StartSound(NULL, sfx_s3k68); G_SaveGameData(); } @@ -818,109 +1171,21 @@ void Y_Ticker(void) else if (intertype == int_match || intertype == int_ctf || intertype == int_teammatch) // match { if (!intertic) // first time only - S_ChangeMusicInternal("racent", true); // loop it + S_ChangeMusicInternal("_inter", true); // loop it // If a player has left or joined, recalculate scores. if (data.match.numplayers != D_NumPlayers()) Y_CalculateMatchWinners(); } - else if (intertype == int_race || intertype == int_classicrace) // race + else if (intertype == int_race || intertype == int_comp) // race { if (!intertic) // first time only - S_ChangeMusicInternal("racent", true); // loop it + S_ChangeMusicInternal("_inter", true); // loop it // Don't bother recalcing for race. It doesn't make as much sense. } } -// -// Y_UpdateRecordReplays -// -// Update replay files/data, etc. for Record Attack -// See G_SetNightsRecords for NiGHTS Attack. -// -static void Y_UpdateRecordReplays(void) -{ - const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; - char *gpath; - char lastdemo[256], bestdemo[256]; - UINT8 earnedEmblems; - - // Record new best time - if (!mainrecords[gamemap-1]) - G_AllocMainRecordData(gamemap-1); - - if (players[consoleplayer].score > mainrecords[gamemap-1]->score) - mainrecords[gamemap-1]->score = players[consoleplayer].score; - - if ((mainrecords[gamemap-1]->time == 0) || (players[consoleplayer].realtime < mainrecords[gamemap-1]->time)) - mainrecords[gamemap-1]->time = players[consoleplayer].realtime; - - if ((UINT16)(players[consoleplayer].health - 1) > mainrecords[gamemap-1]->rings) - mainrecords[gamemap-1]->rings = (UINT16)(players[consoleplayer].health - 1); - - // Save demo! - bestdemo[255] = '\0'; - lastdemo[255] = '\0'; - G_SetDemoTime(players[consoleplayer].realtime, players[consoleplayer].score, (UINT16)(players[consoleplayer].health-1)); - G_CheckDemoStatus(); - - I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); - I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); - - if ((gpath = malloc(glen)) == NULL) - I_Error("Out of memory for replay filepath\n"); - - sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_chooseskin.string); - - if (FIL_FileExists(lastdemo)) - { - UINT8 *buf; - size_t len = FIL_ReadFile(lastdemo, &buf); - - snprintf(bestdemo, 255, "%s-%s-time-best.lmp", gpath, cv_chooseskin.string); - if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) - { // Better time, save this demo. - if (FIL_FileExists(bestdemo)) - remove(bestdemo); - FIL_WriteFile(bestdemo, buf, len); - CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW RECORD TIME!"), M_GetText("Saved replay as"), bestdemo); - } - - snprintf(bestdemo, 255, "%s-%s-score-best.lmp", gpath, cv_chooseskin.string); - if (!FIL_FileExists(bestdemo) || (G_CmpDemoTime(bestdemo, lastdemo) & (1<<1))) - { // Better score, save this demo. - if (FIL_FileExists(bestdemo)) - remove(bestdemo); - FIL_WriteFile(bestdemo, buf, len); - CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW HIGH SCORE!"), M_GetText("Saved replay as"), bestdemo); - } - - snprintf(bestdemo, 255, "%s-%s-rings-best.lmp", gpath, cv_chooseskin.string); - if (!FIL_FileExists(bestdemo) || (G_CmpDemoTime(bestdemo, lastdemo) & (1<<2))) - { // Better rings, save this demo. - if (FIL_FileExists(bestdemo)) - remove(bestdemo); - FIL_WriteFile(bestdemo, buf, len); - CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW MOST RINGS!"), M_GetText("Saved replay as"), bestdemo); - } - - //CONS_Printf("%s '%s'\n", M_GetText("Saved replay as"), lastdemo); - - Z_Free(buf); - } - free(gpath); - - // Check emblems when level data is updated - if ((earnedEmblems = M_CheckLevelEmblems())) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for Record Attack records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); - - // Update timeattack menu's replay availability. - CV_AddValue(&cv_nextmap, 1); - CV_AddValue(&cv_nextmap, -1); -} - // // Y_StartIntermission // @@ -937,14 +1202,13 @@ void Y_StartIntermission(void) I_Error("endtic is dirty"); #endif + safetorender = true; + if (!multiplayer) { timer = 0; - if (G_IsSpecialStage(gamemap)) - intertype = (maptol & TOL_NIGHTS) ? int_nightsspec : int_spec; - else - intertype = (maptol & TOL_NIGHTS) ? int_nights : int_coop; + intertype = (G_IsSpecialStage(gamemap)) ? int_spec : int_coop; } else { @@ -958,15 +1222,10 @@ void Y_StartIntermission(void) timer = 1; } - if (gametype == GT_COOP) - { - // Nights intermission is single player only - // Don't add it here - if (G_IsSpecialStage(gamemap)) - intertype = int_spec; - else - intertype = int_coop; - } + if (intermissiontypes[gametype] != int_none) + intertype = intermissiontypes[gametype]; + else if (gametype == GT_COOP) + intertype = (G_IsSpecialStage(gamemap)) ? int_spec : int_coop; else if (gametype == GT_TEAMMATCH) intertype = int_teammatch; else if (gametype == GT_MATCH @@ -976,7 +1235,7 @@ void Y_StartIntermission(void) else if (gametype == GT_RACE) intertype = int_race; else if (gametype == GT_COMPETITION) - intertype = int_classicrace; + intertype = int_comp; else if (gametype == GT_CTF) intertype = int_ctf; } @@ -991,20 +1250,6 @@ void Y_StartIntermission(void) switch (intertype) { - case int_nights: - // Can't fail - G_SetNightsRecords(); - - // Check records - { - UINT8 earnedEmblems = M_CheckLevelEmblems(); - if (earnedEmblems) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for NiGHTS records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); - } - - // fall back into the coop intermission for now - intertype = int_coop; - /* FALLTHRU */ case int_coop: // coop or single player, normal level { // award time and ring bonuses @@ -1013,40 +1258,21 @@ void Y_StartIntermission(void) // setup time data data.coop.tics = players[consoleplayer].realtime; - if ((!modifiedgame || savemoddata) && !multiplayer && !demoplayback) - { - // Update visitation flags - mapvisited[gamemap-1] |= MV_BEATEN; - if (ALL7EMERALDS(emeralds)) - mapvisited[gamemap-1] |= MV_ALLEMERALDS; - if (ultimatemode) - mapvisited[gamemap-1] |= MV_ULTIMATE; - if (data.coop.gotperfbonus) - mapvisited[gamemap-1] |= MV_PERFECT; - - if (modeattacking == ATTACKING_RECORD) - Y_UpdateRecordReplays(); - } - for (i = 0; i < 4; ++i) - data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_STATIC); - data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_STATIC); + data.coop.bonuspatches[i] = W_CachePatchName(data.coop.bonuses[i].patch, PU_PATCH); + data.coop.ptotal = W_CachePatchName("YB_TOTAL", PU_PATCH); // get act number - if (mapheaderinfo[prevmap]->actnum) - data.coop.ttlnum = W_CachePatchName(va("TTL%.2d", mapheaderinfo[prevmap]->actnum), - PU_STATIC); - else - data.coop.ttlnum = W_CachePatchName("TTL01", PU_STATIC); + data.coop.actnum = mapheaderinfo[gamemap-1]->actnum; // get background patches - widebgpatch = W_CachePatchName("INTERSCW", PU_STATIC); - bgpatch = W_CachePatchName("INTERSCR", PU_STATIC); + widebgpatch = W_CachePatchName("INTERSCW", PU_PATCH); + bgpatch = W_CachePatchName("INTERSCR", PU_PATCH); // grab an interscreen if appropriate if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') { - interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_STATIC); + interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); useinterpic = true; usebuffer = false; } @@ -1064,21 +1290,21 @@ void Y_StartIntermission(void) // too long so just show "YOU GOT THROUGH THE ACT" if (strlen(skins[players[consoleplayer].skin].realname) > 13) { - strcpy(data.coop.passed1, "YOU GOT"); - strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "THROUGH ACT" : "THROUGH THE ACT"); + strcpy(data.coop.passed1, "you got"); + strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act"); } // long enough that "X GOT" won't fit so use "X PASSED THE ACT" else if (strlen(skins[players[consoleplayer].skin].realname) > 8) { strcpy(data.coop.passed1, skins[players[consoleplayer].skin].realname); - strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "PASSED ACT" : "PASSED THE ACT"); + strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "passed act" : "passed the act"); } // length is okay for normal use else { - snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s GOT", + snprintf(data.coop.passed1, sizeof data.coop.passed1, "%s got", skins[players[consoleplayer].skin].realname); - strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "THROUGH ACT" : "THROUGH THE ACT"); + strcpy(data.coop.passed2, (mapheaderinfo[gamemap-1]->actnum) ? "through act" : "through the act"); } // set X positions @@ -1098,50 +1324,24 @@ void Y_StartIntermission(void) break; } - case int_nightsspec: - if (modeattacking && stagefailed) - { - // Nuh-uh. Get out of here. - Y_EndIntermission(); - Y_FollowIntermission(); - break; - } - if (!stagefailed) - G_SetNightsRecords(); - - // Check records - { - UINT8 earnedEmblems = M_CheckLevelEmblems(); - if (earnedEmblems) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for NiGHTS records.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); - } - - // fall back into the special stage intermission for now - intertype = int_spec; - /* FALLTHRU */ case int_spec: // coop or single player, special stage { - // Update visitation flags? - if ((!modifiedgame || savemoddata) && !multiplayer && !demoplayback) - { - if (!stagefailed) - mapvisited[gamemap-1] |= MV_BEATEN; - } - // give out ring bonuses Y_AwardSpecialStageBonus(); - data.spec.bonuspatch = W_CachePatchName(data.spec.bonus.patch, PU_STATIC); - data.spec.pscore = W_CachePatchName("YB_SCORE", PU_STATIC); - data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_STATIC); + for (i = 0; i < 2; ++i) + data.spec.bonuspatches[i] = W_CachePatchName(data.spec.bonuses[i].patch, PU_PATCH); + + data.spec.pscore = W_CachePatchName("YB_SCORE", PU_PATCH); + data.spec.pcontinues = W_CachePatchName("YB_CONTI", PU_PATCH); // get background tile - bgtile = W_CachePatchName("SPECTILE", PU_STATIC); + bgtile = W_CachePatchName("SPECTILE", PU_PATCH); // grab an interscreen if appropriate if (mapheaderinfo[gamemap-1]->interscreen[0] != '#') { - interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_STATIC); + interpic = W_CachePatchName(mapheaderinfo[gamemap-1]->interscreen, PU_PATCH); useinterpic = true; } else @@ -1153,14 +1353,14 @@ void Y_StartIntermission(void) // get special stage specific patches /* if (!stagefailed && ALL7EMERALDS(emeralds)) { - data.spec.cemerald = W_CachePatchName("GOTEMALL", PU_STATIC); + data.spec.cemerald = W_CachePatchName("GOTEMALL", PU_PATCH); data.spec.headx = 70; data.spec.nowsuper = players[consoleplayer].skin - ? NULL : W_CachePatchName("NOWSUPER", PU_STATIC); + ? NULL : W_CachePatchName("NOWSUPER", PU_PATCH); } else { - data.spec.cemerald = W_CachePatchName("CEMERALD", PU_STATIC); + data.spec.cemerald = W_CachePatchName("CEMERALD", PU_PATCH); data.spec.headx = 48; data.spec.nowsuper = NULL; } */ @@ -1172,7 +1372,7 @@ void Y_StartIntermission(void) // set up the "got through act" message according to skin name if (stagefailed) { - strcpy(data.spec.passed2, "SPECIAL STAGE"); + strcpy(data.spec.passed2, "Special Stage"); data.spec.passed1[0] = '\0'; } else if (ALL7EMERALDS(emeralds)) @@ -1181,13 +1381,13 @@ void Y_StartIntermission(void) sizeof data.spec.passed1, "%s", skins[players[consoleplayer].skin].realname); data.spec.passed1[sizeof data.spec.passed1 - 1] = '\0'; - strcpy(data.spec.passed2, "GOT THEM ALL!"); + strcpy(data.spec.passed2, "got them all!"); - if (skins[players[consoleplayer].skin].flags & SF_SUPER) + if (players[consoleplayer].charflags & SF_SUPER) { - strcpy(data.spec.passed3, "CAN NOW BECOME"); + strcpy(data.spec.passed3, "can now become"); snprintf(data.spec.passed4, - sizeof data.spec.passed4, "SUPER %s", + sizeof data.spec.passed4, "Super %s", skins[players[consoleplayer].skin].realname); data.spec.passed4[sizeof data.spec.passed4 - 1] = '\0'; } @@ -1197,13 +1397,18 @@ void Y_StartIntermission(void) if (strlen(skins[players[consoleplayer].skin].realname) <= SKINNAMESIZE-5) { snprintf(data.spec.passed1, - sizeof data.spec.passed1, "%s GOT", + sizeof data.spec.passed1, "%s got", skins[players[consoleplayer].skin].realname); data.spec.passed1[sizeof data.spec.passed1 - 1] = '\0'; } else - strcpy(data.spec.passed1, "YOU GOT"); - strcpy(data.spec.passed2, "A CHAOS EMERALD"); + strcpy(data.spec.passed1, "You got"); + strcpy(data.spec.passed2, "a Chaos Emerald"); + if (P_GetNextEmerald() > 6) + { + data.spec.passed2[15] = '?'; + data.spec.passed2[16] = '\0'; + } } data.spec.passedx1 = (BASEVIDWIDTH - V_LevelNameWidth(data.spec.passed1))/2; data.spec.passedx2 = (BASEVIDWIDTH - V_LevelNameWidth(data.spec.passed2))/2; @@ -1233,9 +1438,9 @@ void Y_StartIntermission(void) // get RESULT header data.match.result = - W_CachePatchName("RESULT", PU_STATIC); + W_CachePatchName("RESULT", PU_PATCH); - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; @@ -1261,9 +1466,9 @@ void Y_StartIntermission(void) data.match.levelstring[sizeof data.match.levelstring - 1] = '\0'; // get RESULT header - data.match.result = W_CachePatchName("RESULT", PU_STATIC); + data.match.result = W_CachePatchName("RESULT", PU_PATCH); - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; @@ -1300,13 +1505,13 @@ void Y_StartIntermission(void) data.match.blueflag = bmatcico; } - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; } - case int_classicrace: // classic (full race) + case int_comp: // classic (full race) { // find out who won Y_CalculateCompetitionWinners(); @@ -1326,7 +1531,7 @@ void Y_StartIntermission(void) data.competition.levelstring[sizeof data.competition.levelstring - 1] = '\0'; // get background tile - bgtile = W_CachePatchName("SRB2BACK", PU_STATIC); + bgtile = W_CachePatchName("SRB2BACK", PU_PATCH); usetile = true; useinterpic = false; break; @@ -1455,11 +1660,14 @@ static void Y_CalculateCompetitionWinners(void) for (j = 0; j < 5; j++) bestat[j] = true; + if ((players[i].pflags & PF_GAMETYPEOVER) || players[i].lives <= 0) + players[i].rings = 0; + times[i] = players[i].realtime; - rings[i] = (UINT32)max(players[i].health-1, 0); + rings[i] = (UINT32)max(players[i].rings, 0); maxrings[i] = (UINT32)players[i].totalring; monitors[i] = (UINT32)players[i].numboxes; - scores[i] = (UINT32)min(players[i].score, 99999990); + scores[i] = (UINT32)min(players[i].score, MAXSCORE); for (j = 0; j < MAXPLAYERS; j++) { @@ -1471,7 +1679,7 @@ static void Y_CalculateCompetitionWinners(void) else bestat[0] = false; - if (max(players[i].health-1, 0) >= max(players[j].health-1, 0)) + if (max(players[i].rings, 0) >= max(players[j].rings, 0)) points[i]++; else bestat[1] = false; @@ -1571,8 +1779,7 @@ static void Y_SetTimeBonus(player_t *player, y_bonus_t *bstruct) // calculate time bonus secs = player->realtime / TICRATE; - if (secs < 30) /* :30 */ bonus = 100000; - else if (secs < 45) /* :45 */ bonus = 50000; + if (secs < 30) /* :30 */ bonus = 50000; else if (secs < 60) /* 1:00 */ bonus = 10000; else if (secs < 90) /* 1:30 */ bonus = 5000; else if (secs < 120) /* 2:00 */ bonus = 4000; @@ -1595,7 +1802,27 @@ static void Y_SetRingBonus(player_t *player, y_bonus_t *bstruct) { strncpy(bstruct->patch, "YB_RING", sizeof(bstruct->patch)); bstruct->display = true; - bstruct->points = max(0, (player->health-1) * 100); + bstruct->points = max(0, (player->rings) * 100); +} + +// +// Y_SetNightsBonus +// +static void Y_SetNightsBonus(player_t *player, y_bonus_t *bstruct) +{ + strncpy(bstruct->patch, "YB_NIGHT", sizeof(bstruct->patch)); + bstruct->display = true; + bstruct->points = player->totalmarescore; +} + +// +// Y_SetLapBonus +// +static void Y_SetLapBonus(player_t *player, y_bonus_t *bstruct) +{ + strncpy(bstruct->patch, "YB_LAP", sizeof(bstruct->patch)); + bstruct->display = true; + bstruct->points = max(0, player->totalmarebonuslap * 1000); } // @@ -1637,29 +1864,47 @@ static void Y_SetPerfectBonus(player_t *player, y_bonus_t *bstruct) memset(bstruct, 0, sizeof(y_bonus_t)); strncpy(bstruct->patch, "YB_PERFE", sizeof(bstruct->patch)); - if (data.coop.gotperfbonus == -1) + if (intertype != int_coop || data.coop.gotperfbonus == -1) { INT32 sharedringtotal = 0; for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i]) continue; - sharedringtotal += players[i].health - 1; + sharedringtotal += players[i].rings; } - if (!sharedringtotal || sharedringtotal < nummaprings) - data.coop.gotperfbonus = 0; + if (!sharedringtotal || nummaprings == -1 || sharedringtotal < nummaprings) + bstruct->display = false; else - data.coop.gotperfbonus = 1; + { + bstruct->display = true; + bstruct->points = 50000; + } } - if (!data.coop.gotperfbonus) + if (intertype != int_coop) return; + data.coop.gotperfbonus = (bstruct->display ? 1 : 0); +} + +static void Y_SetSpecialRingBonus(player_t *player, y_bonus_t *bstruct) +{ + INT32 i, sharedringtotal = 0; + + (void)player; + strncpy(bstruct->patch, "YB_RING", sizeof(bstruct->patch)); bstruct->display = true; - bstruct->points = 50000; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) continue; + sharedringtotal += players[i].rings; + } + bstruct->points = max(0, (sharedringtotal) * 100); } // This list can be extended in the future with SOC/Lua, perhaps. typedef void (*bonus_f)(player_t *, y_bonus_t *); -bonus_f bonuses_list[4][4] = { +bonus_f bonuses_list[6][4] = { { Y_SetNullBonus, Y_SetNullBonus, @@ -1684,6 +1929,18 @@ bonus_f bonuses_list[4][4] = { Y_SetRingBonus, Y_SetPerfectBonus, }, + { + Y_SetNullBonus, + Y_SetNightsBonus, + Y_SetLapBonus, + Y_SetNullBonus, + }, + { + Y_SetNullBonus, + Y_SetLinkBonus, + Y_SetLapBonus, + Y_SetNullBonus, + }, }; @@ -1718,15 +1975,19 @@ static void Y_AwardCoopBonuses(void) { (bonuses_list[bonusnum][j])(&players[i], &localbonuses[j]); players[i].score += localbonuses[j].points; + if (players[i].score > MAXSCORE) + players[i].score = MAXSCORE; } - ptlives = (!ultimatemode && !modeattacking) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; + ptlives = min( + (INT32)((!ultimatemode && !modeattacking && players[i].lives != INFLIVES) ? max((INT32)((players[i].score/50000) - (oldscore/50000)), (INT32)0) : 0), + (INT32)(mapheaderinfo[prevmap]->maxbonuslives < 0 ? INT32_MAX : mapheaderinfo[prevmap]->maxbonuslives)); if (ptlives) P_GivePlayerLives(&players[i], ptlives); if (i == consoleplayer) { - data.coop.gotlife = ptlives; + data.coop.gotlife = (((netgame || multiplayer) && G_GametypeUsesCoopLives() && cv_cooplives.value == 0) ? 0 : ptlives); M_Memcpy(&data.coop.bonuses, &localbonuses, sizeof(data.coop.bonuses)); } } @@ -1743,34 +2004,46 @@ static void Y_AwardCoopBonuses(void) static void Y_AwardSpecialStageBonus(void) { INT32 i, oldscore, ptlives; - y_bonus_t localbonus; + y_bonus_t localbonuses[2]; data.spec.score = players[consoleplayer].score; - memset(&data.spec.bonus, 0, sizeof(data.spec.bonus)); - data.spec.bonuspatch = NULL; + memset(data.spec.bonuses, 0, sizeof(data.spec.bonuses)); + memset(data.spec.bonuspatches, 0, sizeof(data.spec.bonuspatches)); for (i = 0; i < MAXPLAYERS; i++) { oldscore = players[i].score; if (!playeringame[i] || players[i].lives < 1) // not active or game over - Y_SetNullBonus(&players[i], &localbonus); - else if (useNightsSS) // Link instead of Score - Y_SetLinkBonus(&players[i], &localbonus); + { + Y_SetNullBonus(&players[i], &localbonuses[0]); + Y_SetNullBonus(&players[i], &localbonuses[1]); + } + else if (maptol & TOL_NIGHTS) // NiGHTS bonus score instead of Rings + { + Y_SetNightsBonus(&players[i], &localbonuses[0]); + Y_SetNullBonus(&players[i], &localbonuses[1]); + } else - Y_SetRingBonus(&players[i], &localbonus); - players[i].score += localbonus.points; + { + Y_SetSpecialRingBonus(&players[i], &localbonuses[0]); + Y_SetPerfectBonus(&players[i], &localbonuses[1]); + } + players[i].score += localbonuses[0].points; + players[i].score += localbonuses[1].points; + if (players[i].score > MAXSCORE) + players[i].score = MAXSCORE; // grant extra lives right away since tally is faked - ptlives = (!ultimatemode && !modeattacking) ? max((players[i].score/50000) - (oldscore/50000), 0) : 0; - if (ptlives) - P_GivePlayerLives(&players[i], ptlives); + ptlives = min( + (INT32)((!ultimatemode && !modeattacking && players[i].lives != INFLIVES) ? max((INT32)((players[i].score/50000) - (oldscore/50000)), (INT32)0) : 0), + (INT32)(mapheaderinfo[prevmap]->maxbonuslives < 0 ? INT32_MAX : mapheaderinfo[prevmap]->maxbonuslives)); + P_GivePlayerLives(&players[i], ptlives); if (i == consoleplayer) { - M_Memcpy(&data.spec.bonus, &localbonus, sizeof(data.spec.bonus)); - - data.spec.gotlife = ptlives; + data.spec.gotlife = (((netgame || multiplayer) && G_GametypeUsesCoopLives() && cv_cooplives.value == 0) ? 0 : ptlives); + M_Memcpy(&data.spec.bonuses, &localbonuses, sizeof(data.spec.bonuses)); // Continues related data.spec.continues = min(players[i].continues, 8); @@ -1796,24 +2069,8 @@ void Y_EndIntermission(void) usebuffer = false; } -// -// Y_FollowIntermission -// -static void Y_FollowIntermission(void) -{ - if (modeattacking) - { - M_EndModeAttackRun(); - return; - } - - // This handles whether to play a post-level cutscene, end the game, - // or simply go to the next level. - // No need to duplicate the code here! - G_AfterIntermission(); -} - -#define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL +#define UNLOAD(x) if (x) {Z_ChangeTag(x, PU_CACHE);} x = NULL; +#define CLEANUP(x) x = NULL; // // Y_UnloadData @@ -1835,7 +2092,6 @@ static void Y_UnloadData(void) { case int_coop: // unload the coop and single player patches - UNLOAD(data.coop.ttlnum); UNLOAD(data.coop.bonuspatches[3]); UNLOAD(data.coop.bonuspatches[2]); UNLOAD(data.coop.bonuspatches[1]); @@ -1846,7 +2102,8 @@ static void Y_UnloadData(void) // unload the special stage patches //UNLOAD(data.spec.cemerald); //UNLOAD(data.spec.nowsuper); - UNLOAD(data.spec.bonuspatch); + UNLOAD(data.spec.bonuspatches[1]); + UNLOAD(data.spec.bonuspatches[0]); UNLOAD(data.spec.pscore); UNLOAD(data.spec.pcontinues); break; @@ -1858,11 +2115,53 @@ static void Y_UnloadData(void) UNLOAD(data.match.blueflag); UNLOAD(data.match.redflag); break; + default: + //without this default, + //int_none, int_tag, int_chaos, and int_comp + //are not handled + break; + } +} + +static void Y_CleanupData(void) +{ + // unload the background patches + CLEANUP(bgpatch); + CLEANUP(widebgpatch); + CLEANUP(bgtile); + CLEANUP(interpic); + + switch (intertype) + { + case int_coop: + // unload the coop and single player patches + CLEANUP(data.coop.bonuspatches[3]); + CLEANUP(data.coop.bonuspatches[2]); + CLEANUP(data.coop.bonuspatches[1]); + CLEANUP(data.coop.bonuspatches[0]); + CLEANUP(data.coop.ptotal); + break; + case int_spec: + // unload the special stage patches + //CLEANUP(data.spec.cemerald); + //CLEANUP(data.spec.nowsuper); + CLEANUP(data.spec.bonuspatches[1]); + CLEANUP(data.spec.bonuspatches[0]); + CLEANUP(data.spec.pscore); + CLEANUP(data.spec.pcontinues); + break; + case int_match: + case int_race: + CLEANUP(data.match.result); + break; + case int_ctf: + CLEANUP(data.match.blueflag); + CLEANUP(data.match.redflag); + break; default: //without this default, //int_none, int_tag, int_chaos, and int_classicrace //are not handled break; } - } diff --git a/src/y_inter.h b/src/y_inter.h index 4c6ad2bdf..855844fcc 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2004-2018 by Sonic Team Junior. +// Copyright (C) 2004-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -15,6 +15,8 @@ void Y_IntermissionDrawer(void); void Y_Ticker(void); void Y_StartIntermission(void); void Y_EndIntermission(void); +void Y_ConsiderScreenBuffer(void); +void Y_CleanupScreenBuffer(void); typedef enum { @@ -25,9 +27,8 @@ typedef enum // int_tag, // Tag int_ctf, // CTF int_spec, // Special Stage - int_nights, // NiGHTS into Dreams - int_nightsspec,// NiGHTS special stage int_race, // Race - int_classicrace, // Competition + int_comp, // Competition } intertype_t; extern intertype_t intertype; +extern intertype_t intermissiontypes[NUMGAMETYPES]; diff --git a/src/z_zone.c b/src/z_zone.c index a3e13422f..96dcd0cba 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -1,7 +1,7 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2006 by Graue. -// Copyright (C) 2006-2018 by Sonic Team Junior. +// Copyright (C) 2006-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -27,6 +27,7 @@ #include "doomdef.h" #include "doomstat.h" +#include "r_patch.h" #include "i_system.h" // I_GetFreeMem #include "i_video.h" // rendermode #include "z_zone.h" @@ -82,6 +83,59 @@ typedef struct memblock_s struct memblock_s *next, *prev; } ATTRPACK memblock_t; +// both the head and tail of the zone memory block list +static memblock_t head; + +// +// Function prototypes +// +static void Command_Memfree_f(void); +#ifdef ZDEBUG +static void Command_Memdump_f(void); +#endif + +// -------------------------- +// Zone memory initialisation +// -------------------------- + +/** Initialises zone memory. + * Used at game startup. + * + * \sa I_GetFreeMem, Command_Memfree_f, Command_Memdump_f + */ +void Z_Init(void) +{ + UINT32 total, memfree; + + memset(&head, 0x00, sizeof(head)); + + head.next = head.prev = &head; + + memfree = I_GetFreeMem(&total)>>20; + CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree); + + // Note: This allocates memory. Watch out. + COM_AddCommand("memfree", Command_Memfree_f); + +#ifdef ZDEBUG + COM_AddCommand("memdump", Command_Memdump_f); +#endif +} + + +// ---------------------- +// Zone memory allocation +// ---------------------- + +/** Returns the corresponding memblock_t for a given memory block. + * + * \param ptr A pointer to allocated memory, + * assumed to have been allocated with Z_Malloc/Z_Calloc. + * \param func A string containing the name of the function that called this, + * to be printed if the function I_Errors + * \return A pointer to the memblock_t for the given memory. + * \sa Z_Free, Z_ReallocAlign + */ #ifdef ZDEBUG #define Ptr2Memblock(s, f) Ptr2Memblock2(s, f, __FILE__, __LINE__) static memblock_t *Ptr2Memblock2(void *ptr, const char* func, const char *file, INT32 line) @@ -131,32 +185,12 @@ static memblock_t *Ptr2Memblock(void *ptr, const char* func) } -static memblock_t head; - -static void Command_Memfree_f(void); -#ifdef ZDEBUG -static void Command_Memdump_f(void); -#endif - -void Z_Init(void) -{ - UINT32 total, memfree; - - memset(&head, 0x00, sizeof(head)); - - head.next = head.prev = &head; - - memfree = I_GetFreeMem(&total)>>20; - CONS_Printf("System memory: %uMB - Free: %uMB\n", total>>20, memfree); - - // Note: This allocates memory. Watch out. - COM_AddCommand("memfree", Command_Memfree_f); - -#ifdef ZDEBUG - COM_AddCommand("memdump", Command_Memdump_f); -#endif -} - +/** Frees allocated memory. + * + * \param ptr A pointer to allocated memory, + * assumed to have been allocated with Z_Malloc/Z_Calloc. + * \sa Z_FreeTags + */ #ifdef ZDEBUG void Z_Free2(void *ptr, const char *file, INT32 line) #else @@ -183,11 +217,9 @@ void Z_Free(void *ptr) CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line); #endif -#ifdef HAVE_BLUA // anything that isn't by lua gets passed to lua just in case. if (block->tag != PU_LUA) LUA_InvalidateUserdata(ptr); -#endif // TODO: if zdebugging, make sure no other block has a user // that is about to be freed. @@ -198,19 +230,27 @@ void Z_Free(void *ptr) // Free the memory and get rid of the block. free(block->real); - block->prev->next = block->next; - block->next->prev = block->prev; - free(block); #ifdef VALGRIND_DESTROY_MEMPOOL VALGRIND_DESTROY_MEMPOOL(block); #endif + block->prev->next = block->next; + block->next->prev = block->prev; + free(block); } -// malloc() that doesn't accept failure. +/** malloc() that doesn't accept failure. + * + * \param size Amount of memory to be allocated, in bytes. + * \return A pointer to the allocated memory. + */ static void *xm(size_t size) { const size_t padedsize = size+sizeof (size_t); - void *p = malloc(padedsize); + void *p; + + if (padedsize < size)/* overflow check */ + I_Error("You are allocating memory too large!"); + p = malloc(padedsize); if (p == NULL) { @@ -220,10 +260,6 @@ static void *xm(size_t size) if (p == NULL) { -#if defined (_NDS) | defined (_PSP) - // Temporary-ish debugging measure - Command_Memfree_f(); -#endif I_Error("Out of memory allocating %s bytes", sizeu1(size)); } } @@ -231,10 +267,18 @@ static void *xm(size_t size) return p; } -// Z_Malloc -// You can pass Z_Malloc() a NULL user if the tag is less than -// PU_PURGELEVEL. - +/** The Z_MallocAlign function. + * Allocates a block of memory, adds it to a linked list so we can keep track of it. + * + * \param size Amount of memory to be allocated, in bytes. + * \param tag Purge tag. + * \param user The address of a pointer to the memory to be allocated. + * When the memory is freed by Z_Free later, + * the pointer at this address will then be automatically set to NULL. + * \param alignbits The alignment of the memory to be allocated, in bits. Can be 0. + * \note You can pass Z_Malloc() a NULL user if the tag is less than PU_PURGELEVEL. + * \sa Z_CallocAlign, Z_ReallocAlign + */ #ifdef ZDEBUG void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) @@ -254,6 +298,9 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) CONS_Debug(DBG_MEMORY, "Z_Malloc %s:%d\n", file, line); #endif + if (blocksize < size)/* overflow check */ + I_Error("You are allocating memory too large!"); + block = xm(sizeof *block); #ifdef HAVE_VALGRIND padsize += (1<next = head.next; block->prev = &head; @@ -292,6 +335,13 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) block->size = blocksize; block->realsize = size; +#ifdef VALGRIND_CREATE_MEMPOOL + VALGRIND_CREATE_MEMPOOL(block, padsize, Z_calloc); +#endif +//#ifdef VALGRIND_MEMPOOL_ALLOC +// VALGRIND_MEMPOOL_ALLOC(block, hdr, size + sizeof *hdr); +//#endif + hdr->id = ZONEID; hdr->block = block; @@ -311,6 +361,19 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) return given; } +/** The Z_CallocAlign function. + * Allocates a block of memory, adds it to a linked list so we can keep track of it. + * Unlike Z_MallocAlign, this also initialises the bytes to zero. + * + * \param size Amount of memory to be allocated, in bytes. + * \param tag Purge tag. + * \param user The address of a pointer to the memory to be allocated. + * When the memory is freed by Z_Free later, + * the pointer at this address will then be automatically set to NULL. + * \param alignbits The alignment of the memory to be allocated, in bits. Can be 0. + * \note You can pass Z_Calloc() a NULL user if the tag is less than PU_PURGELEVEL. + * \sa Z_MallocAlign, Z_ReallocAlign + */ #ifdef ZDEBUG void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) #else @@ -327,10 +390,26 @@ void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) #endif } +/** The Z_ReallocAlign function. + * Reallocates a block of memory with a new size. + * + * \param ptr A pointer to allocated memory, + * assumed to have been allocated with Z_Malloc/Z_Calloc. + * If NULL, this function instead acts as a wrapper for Z_CallocAlign. + * \param size New size of memory block, in bytes. + * If zero, then the memory is freed and NULL is returned. + * \param tag New purge tag. + * \param user The address of a pointer to the memory to be reallocated. + * This can be a different user to the one originally assigned to the memory block. + * \param alignbits The alignment of the memory to be allocated, in bits. Can be 0. + * \return A pointer to the reallocated memory. Can be NULL if memory was freed. + * \note You can pass Z_Realloc() a NULL user if the tag is less than PU_PURGELEVEL. + * \sa Z_MallocAlign, Z_CallocAlign + */ #ifdef ZDEBUG void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) #else -void *Z_ReallocAlign(void *ptr, size_t size,INT32 tag, void *user, INT32 alignbits) +void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) #endif { void *rez; @@ -397,6 +476,11 @@ void *Z_ReallocAlign(void *ptr, size_t size,INT32 tag, void *user, INT32 alignb return rez; } +/** Frees all memory for a given set of tags. + * + * \param lowtag The lowest tag to consider. + * \param hightag The highest tag to consider. + */ void Z_FreeTags(INT32 lowtag, INT32 hightag) { memblock_t *block, *next; @@ -411,22 +495,55 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag) } } -// -// Z_CheckMemCleanup -// -// TODO: Currently blocks >= PU_PURGELEVEL are freed every -// CLEANUPCOUNT. It might be better to keep track of -// the total size of all purgable memory and free it when the -// size exceeds some value. -// -// This was in Z_Malloc, but was freeing data at -// unsafe times. Now it is only called when it is safe -// to cleanup memory. +// ----------------- +// Utility functions +// ----------------- +// for renderer switching, free a bunch of stuff +boolean needpatchflush = false; +boolean needpatchrecache = false; + +// flush all patches from memory +// (also frees memory tagged with PU_CACHE) +// (which are not necessarily patches but I don't care) +void Z_FlushCachedPatches(void) +{ + CONS_Debug(DBG_RENDER, "Z_FlushCachedPatches()...\n"); + Z_FreeTag(PU_CACHE); + Z_FreeTag(PU_PATCH); + Z_FreeTag(PU_HUDGFX); + Z_FreeTag(PU_HWRPATCHINFO); + Z_FreeTag(PU_HWRMODELTEXTURE); + Z_FreeTag(PU_HWRCACHE); + Z_FreeTag(PU_HWRCACHE_UNLOCKED); + Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED); + Z_FreeTag(PU_HWRMODELTEXTURE_UNLOCKED); +} + +// happens before a renderer switch +void Z_PreparePatchFlush(void) +{ + CONS_Debug(DBG_RENDER, "Z_PreparePatchFlush()...\n"); +#ifdef ROTSPRITE + R_FreeAllRotSprite(); +#endif +} + +// starting value of nextcleanup #define CLEANUPCOUNT 2000 +// number of function calls left before next cleanup static INT32 nextcleanup = CLEANUPCOUNT; +/** This was in Z_Malloc, but was freeing data at + * unsafe times. Now it is only called when it is safe + * to cleanup memory. + * + * \todo Currently blocks >= PU_PURGELEVEL are freed every + * CLEANUPCOUNT. It might be better to keep track of + * the total size of all purgable memory and free it when the + * size exceeds some value. + */ void Z_CheckMemCleanup(void) { if (nextcleanup-- == 0) @@ -542,10 +659,21 @@ void Z_CheckHeap(INT32 i) } } +// ------------------------ +// Zone memory modification +// ------------------------ + +/** Changes a memory block's purge tag. + * + * \param ptr A pointer to allocated memory, + * assumed to have been allocated with Z_Malloc/Z_Calloc. + * \param tag The new tag. + * \sa Z_SetUser + */ #ifdef PARANOIA void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line) #else -void Z_ChangeTag2(void *ptr, INT32 tag) +void Z_ChangeTag(void *ptr, INT32 tag) #endif { memblock_t *block; @@ -587,99 +715,17 @@ void Z_ChangeTag2(void *ptr, INT32 tag) block->tag = tag; } -/** Calculates memory usage for a given set of tags. - * \param lowtag The lowest tag to consider. - * \param hightag The highest tag to consider. - * \return Number of bytes currently allocated in the heap for the - * given tags. - * \sa Z_TagUsage +/** Changes a memory block's user. + * + * \param ptr A pointer to allocated memory, + * assumed to have been allocated with Z_Malloc/Z_Calloc. + * \param newuser The new user for the memory block. + * \sa Z_ChangeTag */ -size_t Z_TagsUsage(INT32 lowtag, INT32 hightag) -{ - size_t cnt = 0; - memblock_t *rover; - - for (rover = head.next; rover != &head; rover = rover->next) - { - if (rover->tag < lowtag || rover->tag > hightag) - continue; - cnt += rover->size + sizeof *rover; - } - - return cnt; -} - -size_t Z_TagUsage(INT32 tagnum) -{ - return Z_TagsUsage(tagnum, tagnum); -} - -void Command_Memfree_f(void) -{ - UINT32 freebytes, totalbytes; - - Z_CheckHeap(-1); - CONS_Printf("\x82%s", M_GetText("Memory Info\n")); - CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TagsUsage(0, INT32_MAX)>>10)); - CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); - CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); - CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); - CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10)); - CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10)); - CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); - CONS_Printf(M_GetText("All purgable : %7s KB\n"), - sizeu1(Z_TagsUsage(PU_PURGELEVEL, INT32_MAX)>>10)); - -#ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) - { - CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); - CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); - CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); - CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); - CONS_Printf(M_GetText("HW Texture used : %7d KB\n"), HWR_GetTextureUsed()>>10); - } -#endif - - CONS_Printf("\x82%s", M_GetText("System Memory Info\n")); - freebytes = I_GetFreeMem(&totalbytes); - CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10); - CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10); -} - -#ifdef ZDEBUG -static void Command_Memdump_f(void) -{ - memblock_t *block; - INT32 mintag = 0, maxtag = INT32_MAX; - INT32 i; - - if ((i = COM_CheckParm("-min"))) - mintag = atoi(COM_Argv(i + 1)); - - if ((i = COM_CheckParm("-max"))) - maxtag = atoi(COM_Argv(i + 1)); - - for (block = head.next; block != &head; block = block->next) - if (block->tag >= mintag && block->tag <= maxtag) - { - char *filename = strrchr(block->ownerfile, PATHSEP[0]); - CONS_Printf("[%3d] %s (%s) bytes @ %s:%d\n", block->tag, sizeu1(block->size), sizeu2(block->realsize), filename ? filename + 1 : block->ownerfile, block->ownerline); - } -} -#endif - -// Creates a copy of a string. -char *Z_StrDup(const char *s) -{ - return strcpy(ZZ_Alloc(strlen(s) + 1), s); -} - - #ifdef PARANOIA void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line) #else -void Z_SetUser2(void *ptr, void **newuser) +void Z_SetUser(void *ptr, void **newuser) #endif { memblock_t *block; @@ -711,3 +757,107 @@ void Z_SetUser2(void *ptr, void **newuser) block->user = (void*)newuser; *newuser = ptr; } + +// ----------------- +// Zone memory usage +// ----------------- + +/** Calculates memory usage for a given set of tags. + * + * \param lowtag The lowest tag to consider. + * \param hightag The highest tag to consider. + * \return Number of bytes currently allocated in the heap for the + * given tags. + */ +size_t Z_TagsUsage(INT32 lowtag, INT32 hightag) +{ + size_t cnt = 0; + memblock_t *rover; + + for (rover = head.next; rover != &head; rover = rover->next) + { + if (rover->tag < lowtag || rover->tag > hightag) + continue; + cnt += rover->size + sizeof *rover; + } + + return cnt; +} + +// ----------------------- +// Miscellaneous functions +// ----------------------- + +/** The function called by the "memfree" console command. + * Prints the memory being used by each part of the game to the console. + */ +static void Command_Memfree_f(void) +{ + UINT32 freebytes, totalbytes; + + Z_CheckHeap(-1); + CONS_Printf("\x82%s", M_GetText("Memory Info\n")); + CONS_Printf(M_GetText("Total heap used : %7s KB\n"), sizeu1(Z_TotalUsage()>>10)); + CONS_Printf(M_GetText("Static : %7s KB\n"), sizeu1(Z_TagUsage(PU_STATIC)>>10)); + CONS_Printf(M_GetText("Static (sound) : %7s KB\n"), sizeu1(Z_TagUsage(PU_SOUND)>>10)); + CONS_Printf(M_GetText("Static (music) : %7s KB\n"), sizeu1(Z_TagUsage(PU_MUSIC)>>10)); + CONS_Printf(M_GetText("Locked cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_CACHE)>>10)); + CONS_Printf(M_GetText("Level : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVEL)>>10)); + CONS_Printf(M_GetText("Special thinker : %7s KB\n"), sizeu1(Z_TagUsage(PU_LEVSPEC)>>10)); + CONS_Printf(M_GetText("All purgable : %7s KB\n"), + sizeu1(Z_TagsUsage(PU_PURGELEVEL, INT32_MAX)>>10)); + +#ifdef HWRENDER + if (rendermode != render_soft && rendermode != render_none) + { + CONS_Printf(M_GetText("Patch info headers: %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHINFO)>>10)); + CONS_Printf(M_GetText("Mipmap patches : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPATCHCOLMIPMAP)>>10)); + CONS_Printf(M_GetText("HW Texture cache : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRCACHE)>>10)); + CONS_Printf(M_GetText("Plane polygons : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRPLANE)>>10)); + CONS_Printf(M_GetText("HW model textures : %7s KB\n"), sizeu1(Z_TagUsage(PU_HWRMODELTEXTURE)>>10)); + CONS_Printf(M_GetText("HW Texture used : %7d KB\n"), HWR_GetTextureUsed()>>10); + } +#endif + + CONS_Printf("\x82%s", M_GetText("System Memory Info\n")); + freebytes = I_GetFreeMem(&totalbytes); + CONS_Printf(M_GetText(" Total physical memory: %7u KB\n"), totalbytes>>10); + CONS_Printf(M_GetText("Available physical memory: %7u KB\n"), freebytes>>10); +} + +#ifdef ZDEBUG +/** The function called by the "memdump" console command. + * Prints zone memory debugging information (i.e. tag, size, location in code allocated). + * Can be all memory allocated in game, or between a set of tags (if -min/-max args used). + * This command is available only if ZDEBUG is enabled. + */ +static void Command_Memdump_f(void) +{ + memblock_t *block; + INT32 mintag = 0, maxtag = INT32_MAX; + INT32 i; + + if ((i = COM_CheckParm("-min"))) + mintag = atoi(COM_Argv(i + 1)); + + if ((i = COM_CheckParm("-max"))) + maxtag = atoi(COM_Argv(i + 1)); + + for (block = head.next; block != &head; block = block->next) + if (block->tag >= mintag && block->tag <= maxtag) + { + char *filename = strrchr(block->ownerfile, PATHSEP[0]); + CONS_Printf("[%3d] %s (%s) bytes @ %s:%d\n", block->tag, sizeu1(block->size), sizeu2(block->realsize), filename ? filename + 1 : block->ownerfile, block->ownerline); + } +} +#endif + +/** Creates a copy of a string. + * + * \param s The string to be copied. + * \return A copy of the string, allocated in zone memory. + */ +char *Z_StrDup(const char *s) +{ + return strcpy(ZZ_Alloc(strlen(s) + 1), s); +} diff --git a/src/z_zone.h b/src/z_zone.h index 1424a3782..5cbcc6655 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 1999-2018 by Sonic Team Junior. +// Copyright (C) 1999-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. @@ -30,96 +30,124 @@ //#define ZDEBUG // -// ZONE MEMORY -// PU - purge tags. -// Tags < PU_LEVEL are not purged until freed explicitly. -#define PU_STATIC 1 // static entire execution time -#define PU_LUA 2 // static entire execution time -- used by lua so it doesn't get caught in loops forever +// Purge tags +// +// Now they are an enum! -- Monster Iestyn 15/02/18 +// +enum +{ + // Tags < PU_LEVEL are not purged until freed explicitly. + PU_STATIC = 1, // static entire execution time + PU_LUA = 2, // static entire execution time -- used by lua so it doesn't get caught in loops forever -#define PU_SOUND 11 // static while playing -#define PU_MUSIC 12 // static while playing -#define PU_HUDGFX 13 // static until WAD added + PU_SOUND = 11, // static while playing + PU_MUSIC = 12, // static while playing + PU_HUDGFX = 13, // static until WAD added + PU_PATCH = 14, // static until renderer change -#define PU_HWRPATCHINFO 21 // Hardware GLPatch_t struct for OpenGL texture cache -#define PU_HWRPATCHCOLMIPMAP 22 // Hardware GLMipmap_t struct colromap variation of patch + PU_HWRPATCHINFO = 21, // Hardware GLPatch_t struct for OpenGL texture cache + PU_HWRPATCHCOLMIPMAP = 22, // Hardware GLMipmap_t struct colormap variation of patch + PU_HWRMODELTEXTURE = 23, // Hardware model texture -#define PU_HWRCACHE 48 // static until unlocked -#define PU_CACHE 49 // static until unlocked + PU_HWRCACHE = 48, // static until unlocked + PU_CACHE = 49, // static until unlocked -// Tags s.t. PU_LEVEL <= tag < PU_PURGELEVEL are purged at level start -#define PU_LEVEL 50 // static until level exited -#define PU_LEVSPEC 51 // a special thinker in a level -#define PU_HWRPLANE 52 + // Tags s.t. PU_LEVEL <= tag < PU_PURGELEVEL are purged at level start + PU_LEVEL = 50, // static until level exited + PU_LEVSPEC = 51, // a special thinker in a level + PU_HWRPLANE = 52, // if ZPLANALLOC is enabled in hw_bsp.c, this is used to alloc polygons for OpenGL -// Tags >= PU_PURGELEVEL are purgable whenever needed -#define PU_PURGELEVEL 100 -#define PU_CACHE_UNLOCKED 101 -#define PU_HWRCACHE_UNLOCKED 102 // 'second-level' cache for graphics - // stored in hardware format and downloaded as needed -#define PU_HWRPATCHINFO_UNLOCKED 103 + // Tags >= PU_PURGELEVEL are purgable whenever needed + PU_PURGELEVEL = 100, // Note: this is never actually used as a tag + PU_CACHE_UNLOCKED = 101, // Note: unused + PU_HWRCACHE_UNLOCKED = 102, // 'unlocked' PU_HWRCACHE memory: + // 'second-level' cache for graphics + // stored in hardware format and downloaded as needed + PU_HWRPATCHINFO_UNLOCKED = 103, // 'unlocked' PU_HWRPATCHINFO memory + PU_HWRMODELTEXTURE_UNLOCKED = 104, // 'unlocked' PU_HWRMODELTEXTURE memory +}; +// +// Zone memory initialisation +// void Z_Init(void); -void Z_FreeTags(INT32 lowtag, INT32 hightag); -void Z_CheckMemCleanup(void); -void Z_CheckHeap(INT32 i); -#ifdef PARANOIA -void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line); -#else -void Z_ChangeTag2(void *ptr, INT32 tag); -#endif -#ifdef PARANOIA -void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line); -#else -void Z_SetUser2(void *ptr, void **newuser); -#endif +// +// Zone memory allocation +// +// enable ZDEBUG to get the file + line the functions were called from +// for ZZ_Alloc, see doomdef.h +// +// Z_Free and alloc with alignment #ifdef ZDEBUG -#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__) -void Z_Free2(void *ptr, const char *file, INT32 line); -#define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, 0, __FILE__, __LINE__) -#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__) -void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1); -#define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, 0, __FILE__, __LINE__) -#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__) -void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1); -#define Z_Realloc(p,s,t,u) Z_Realloc2(p, s, t, u, 0, __FILE__, __LINE__) +#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__) +#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__) +#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__) #define Z_ReallocAlign(p,s,t,u,a) Z_Realloc2(p,s, t, u, a, __FILE__, __LINE__) +void Z_Free2(void *ptr, const char *file, INT32 line); +void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1); +void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1); void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(2); #else void Z_Free(void *ptr); void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1); -#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, 0) void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1); -#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, 0) -void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2) ; -#define Z_Realloc(p, s,t,u) Z_ReallocAlign(p, s, t, u, 0) +void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2); #endif -size_t Z_TagUsage(INT32 tagnum); -size_t Z_TagsUsage(INT32 lowtag, INT32 hightag); +// Alloc with no alignment +#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, 0) +#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, 0) +#define Z_Realloc(p,s,t,u) Z_ReallocAlign(p, s, t, u, 0) -char *Z_StrDup(const char *in); +// Free all memory by tag +// these don't give line numbers for ZDEBUG currently though +// (perhaps this should be changed in future?) +#define Z_FreeTag(tagnum) Z_FreeTags(tagnum, tagnum) +void Z_FreeTags(INT32 lowtag, INT32 hightag); -// This is used to get the local FILE : LINE info from CPP -// prior to really call the function in question. +// +// Utility functions +// +void Z_CheckMemCleanup(void); +void Z_CheckHeap(INT32 i); + +// +// Zone memory modification +// +// enable PARANOIA to get the file + line the functions were called from // #ifdef PARANOIA #define Z_ChangeTag(p,t) Z_ChangeTag2(p, t, __FILE__, __LINE__) +#define Z_SetUser(p,u) Z_SetUser2(p, u, __FILE__, __LINE__) +void Z_ChangeTag2(void *ptr, INT32 tag, const char *file, INT32 line); +void Z_SetUser2(void *ptr, void **newuser, const char *file, INT32 line); #else -#define Z_ChangeTag(p,t) Z_ChangeTag2(p, t) +void Z_ChangeTag(void *ptr, INT32 tag); +void Z_SetUser(void *ptr, void **newuser); #endif -#ifdef PARANOIA -#define Z_SetUser(p,u) Z_SetUser2(p, u, __FILE__, __LINE__) -#else -#define Z_SetUser(p,u) Z_SetUser2(p, u) -#endif +// +// Zone memory usage +// +// Note: These give the memory used in bytes, +// shift down by 10 to convert to KB +// +#define Z_TagUsage(tagnum) Z_TagsUsage(tagnum, tagnum) +size_t Z_TagsUsage(INT32 lowtag, INT32 hightag); +#define Z_TotalUsage() Z_TagsUsage(0, INT32_MAX) -#ifdef _NDS ///TODO: need a lock reference system -#define Z_Unlock(p) Z_ChangeTag(p, PU_CACHE_UNLOCKED) -#else -#define Z_Unlock(p) (void)p -#endif +// +// Miscellaneous functions +// +char *Z_StrDup(const char *in); +#define Z_Unlock(p) (void)p // TODO: remove this now that NDS code has been removed + +// For renderer switching +extern boolean needpatchflush; +extern boolean needpatchrecache; +void Z_FlushCachedPatches(void); +void Z_PreparePatchFlush(void); #endif diff --git a/tools/flatb/Makefile b/tools/flatb/Makefile new file mode 100644 index 000000000..2134973e6 --- /dev/null +++ b/tools/flatb/Makefile @@ -0,0 +1,9 @@ +.PHONY : all clean + +all : flatb + +flatb.exe : flatb.c + i686-w64-mingw32-gcc $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $< + +clean : + $(RM) flatb flatb.exe diff --git a/tools/flatb/flatb.c b/tools/flatb/flatb.c new file mode 100644 index 000000000..edc089232 --- /dev/null +++ b/tools/flatb/flatb.c @@ -0,0 +1,566 @@ +#define HELP \ +"Usage: flatb WAD-file list-file" "\n"\ +"Replace flats and textures by name in a DOOM WAD." "\n"\ +"\n"\ +"list-file may have the following format:" "\n"\ +"\n"\ +"GFZFLR01 GFZFLR02" "\n"\ +"# Comment" "\n"\ +"GFZROCK GFZBLOCK" "\n"\ +"\n"\ +"The first name and second name may be delimited by any whitespace." "\n"\ +"\n"\ +"Copyright 2019 James R." "\n"\ +"All rights reserved." "\n" + +/* +Copyright 2019 James R. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include +#include + +#define cchar const char +#define cvoid const void + +#define LONG int32_t + +#define va_inline( __ap,__last, ... )\ +(\ + va_start (__ap,__last),\ + __VA_ARGS__,\ + va_end (__ap)\ +) + +#define DELIM "\t\n\r " + +typedef struct +{ + FILE * fp; + cchar * filename; +} +File; + +int (*le32)(cvoid *); + +void +Pexit (int c, cchar *s, ...) +{ + va_list ap; + va_inline (ap, s, + + vfprintf(stderr, s, ap) + + ); + exit(c); +} + +void +Prexit (cchar *pr, ...) +{ + va_list ap; + va_inline (ap, pr, + + vfprintf(stderr, pr, ap) + + ); + perror(""); + exit(-1); +} + +void +Fopen (File *f, cchar *filename, const char *mode) +{ + FILE *fp; + if (!( fp = fopen(filename, mode) )) + Prexit("%s", filename); + f->filename = filename; + f->fp = fp; +} + +void +Ferr (File *f) +{ + if (ferror(f->fp)) + Prexit("%s", f->filename); +} + +char * +Fgets (File *f, int b, char *p) +{ + if (!( p = fgets(p, b, f->fp) )) + Ferr(f); + return p; +} + +void +Fread (File *f, int b, void *p) +{ + if (fread(p, 1, b, f->fp) < b) + Ferr(f); +} + +void +Fwrite (File *f, int b, cvoid *s) +{ + if (fwrite(s, 1, b, f->fp) < b) + Ferr(f); +} + +void +Fseek (File *f, long o) +{ + if (fseek(f->fp, o, SEEK_SET) == -1) + Prexit("%s", f->filename); +} + +void * +Malloc (int b) +{ + void *p; + if (!( p = malloc(b) )) + Prexit("%d", b); + return p; +} + +void * +Calloc (int c, int b) +{ + void *p; + if (!( p = calloc(c, b) )) + Prexit("(%d)%d", c, b); + return p; +} + +void +Reallocp (void *pp, int b) +{ + void *p; + if (!( p = realloc((*(void **)pp), b) )) + Prexit("%d", b); + (*(void **)pp) = p; +} + +void +strucpy (char *p, cchar *s, int n) +{ + int c; + int i; + for (i = 0; i < n && ( c = s[i] ); ++i) + p[i] = toupper(c); +} + +int +e32 (cvoid *s) +{ + unsigned int c; + c = *(LONG *)s; + return ( + ( c >> 24 ) | + (( c >> 8 )& 0x00FF00 )| + (( c << 8 )& 0xFF0000 )| + ( c << 24 ) + ); +} + +int +n32 (cvoid *s) +{ + return *(LONG *)s; +} + +void +Ie () +{ + int c; + c = 1; + if (*(char *)&c == 1) + le32 = n32; + else + le32 = e32; +} + +File wad_file; +File list_file; + +int list_c; +char *** list_v; + +char * directory; +char * lump; +int lumpsize; + +char * sectors; +int sectors_c; + +char * sides; +int sides_c; + +int st_floors; +int st_ceilings; +int st_sectors; + +int st_sides; +int st_uppers; +int st_mids; +int st_lowers; + +/* this is horseshit */ +char * old; +char * new; +int did; + +void +Itable () +{ + char a[1024]; + + char ***ttt; + char ***ppp; + + char **pp; + + int c; + + while (Fgets(&list_file, sizeof a, a)) + { + c = a[0]; + if (!( + c == '\n' || + c == '#' + )) + { + list_c++; + } + } + + rewind(list_file.fp); + + list_v = Calloc(list_c, sizeof (char **)); + for ( + ttt = ( ppp = list_v ) + list_c; + ppp < ttt; + ++ppp + ) + { + (*ppp) = pp = Calloc(2, sizeof (char *)); + pp[0] = Malloc(9); + pp[1] = Malloc(9); + } +} + +void +Iwad () +{ + char buf[12]; + + char * t; + char * p; + int map; + + char *sector_p; + char * side_p; + + int n; + int h; + + Fread(&wad_file, 12, buf); + if ( + memcmp(buf, "IWAD", 4) != 0 && + memcmp(buf, "PWAD", 4) != 0 + ) + { + Pexit(-1,"%s: Not a WAD\n", wad_file.filename); + } + + Fseek(&wad_file, (*le32)(&buf[8])); + + n = (*le32)(&buf[4]) * 8; + h = n / 9; + n *= 2; + directory = Malloc(n); + /* minimum number of lumps for a map */ + sectors = Malloc(h); + sides = Malloc(h); + + Fread(&wad_file, n, directory); + + sector_p = sectors; + side_p = sides; + map = 3; + for (t = ( p = directory ) + n; p < t; p += 16) + { + /* looking for SECTORS? Hopefully order doesn't matter in real world. */ + /* also search for fucking SIDES MY SIDES AAAAAAAAAA */ + switch (map) + { + case 0: + case 2: + if (strncmp(&p[8], "SECTORS", 8) == 0) + { + /* copy file offset and size */ + memcpy(sector_p, p, 8); + sector_p += 8; + sectors_c++; + map |= 1; + } + case 1: + if (strncmp(&p[8], "SIDEDEFS", 8) == 0) + { + memcpy(side_p, p, 8); + side_p += 8; + sides_c++; + map |= 2; + } + } + if (map == 3) + { + /* MAP marker */ + if (p[13] == '\0' && strncmp(&p[8], "MAP", 3) == 0) + map = 0; + } + } +} + +void +Fuckyou (char *p, int f, int *st) +{ + if (strncmp(p, old, 8) == 0) + { + strncpy(p, new, 8); + (*st)++; + did |= f; + } +} + +void +Epic (char *p, char *t) +{ + char *top; + char *bot; + int i; + /* oh hi magic number! */ + for (; p < t; p += 26) + { + bot = &p [4]; + top = &p[12]; + did = 0; + for (i = 0; i < list_c; ++i) + { + old = list_v[i][0]; + new = list_v[i][1]; + switch (did) + { + case 0: + case 2: + Fuckyou(bot, 1, &st_floors); + case 1: + Fuckyou(top, 2, &st_ceilings); + } + if (did == 3) + break; + } + if (did) + st_sectors++; + } +} + +void +Epic2 (char *p, char *t) +{ + char *top; + char *mid; + char *bot; + int i; + for (; p < t; p += 30) + { + top = &p [4]; + bot = &p[12]; + mid = &p[20]; + did = 0; + for (i = 0; i < list_c; ++i) + { + old = list_v[i][0]; + new = list_v[i][1]; + switch (did) + { + case 0: + case 2: + case 4: + case 6: + Fuckyou(top, 1, &st_uppers); + case 1: + case 5: + Fuckyou(mid, 2, &st_mids); + case 3: + Fuckyou(bot, 4, &st_lowers); + } + if (did == 7) + break; + } + if (did) + st_sides++; + } +} + +void +Fuck (char *p, int c, void (*fn)(char *,char *)) +{ + char *t; + int offs; + int size; + for (t = p + c * 8; p < t; p += 8) + { + offs = (*le32)(p); + size = (*le32)(p + 4); + if (lumpsize < size) + { + Reallocp(&lump, size); + lumpsize = size; + } + Fseek(&wad_file, offs); + Fread(&wad_file, size, lump); + (*fn)(lump, lump + size); + Fseek(&wad_file, offs); + Fwrite(&wad_file, size, lump); + } +} + +void +Awad () +{ + Fuck (sectors, sectors_c, Epic); + Fuck (sides, sides_c, Epic2); +} + +void +Readtable () +{ + char a[1024]; + + int s; + char *old; + char *new; + + int c; + + s = 0; + + while (Fgets(&list_file, sizeof a, a)) + { + c = a[0]; + if (!( + c == '\n' || + c == '#' + )) + { + if ( + ( old = strtok(a, DELIM) ) && + ( new = strtok(0, DELIM) ) + ) + { + strucpy(list_v[s][0], old, 8); + strucpy(list_v[s][1], new, 8); + ++s; + } + } + } +} + +void +Cleanup () +{ + char ***ttt; + char ***ppp; + + char **pp; + + free(lump); + free(sides); + free(sectors); + free(directory); + + if (list_v) + { + for ( + ttt = ( ppp = list_v ) + list_c; + ppp < ttt && ( pp = (*ppp) ); + ++ppp + ) + { + free(pp[0]); + free(pp[1]); + free(pp); + } + free(list_v); + } +} + +int +main (int ac, char **av) +{ + int n; + + if (ac < 3) + Pexit(0,HELP); + + Fopen (& wad_file, av[1], "rb+"); + Fopen (&list_file, av[2], "r"); + + if (atexit(Cleanup) != 0) + Pexit(-1,"Failed to register cleanup function.\n"); + + Itable(); + Readtable(); + + Ie(); + + Iwad(); + Awad(); + + printf( + "%5d sectors changed.\n" + "%5d floors.\n" + "%5d ceilings.\n" + "\n" + "%5d sides.\n" + "%5d upper textures.\n" + "%5d mid textures.\n" + "%5d lower textures.\n", + + st_sectors, + + st_floors, + st_ceilings, + + st_sides, + + st_uppers, + st_mids, + st_lowers); + + return 0; +} diff --git a/tools/musicdef-2.2.1/Makefile b/tools/musicdef-2.2.1/Makefile new file mode 100644 index 000000000..403d27b04 --- /dev/null +++ b/tools/musicdef-2.2.1/Makefile @@ -0,0 +1 @@ +musicdef-2.2.1: diff --git a/tools/musicdef-2.2.1/musicdef-2.2.1.c b/tools/musicdef-2.2.1/musicdef-2.2.1.c new file mode 100644 index 000000000..65d434c8a --- /dev/null +++ b/tools/musicdef-2.2.1/musicdef-2.2.1.c @@ -0,0 +1,77 @@ +/* +Copyright 2020 James R. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#ifdef _WIN32 +#define strcasecmp _stricmp +#else +#include +#endif + +int +main (int ac, char **av) +{ + char line[256]; + char buf[256]; + char *var; + char *val; + char *p; + int n; + (void)ac; + (void)av; + fputs( + "Copyright 2020 James R.\n" + "All rights reserved.\n" + "\n" + "Usage: musicdef-2.2.1 < old-MUSICDEF > new-MUSICDEF\n" + "\n" + ,stderr); + while (fgets(line, sizeof line, stdin)) + { + memcpy(buf, line, sizeof buf); + if (( var = strtok(buf, " =") )) + { + if (!( + strcasecmp(var, "TITLE") && + strcasecmp(var, "ALTTITLE") && + strcasecmp(var, "AUTHORS") + )){ + if (( val = strtok(0, "") )) + { + for (p = val; ( p = strchr(p, '_') ); ) + { + n = strspn(p, "_"); + memset(p, ' ', n); + p += n; + } + printf("%s %s", var, val); + continue; + } + } + } + fputs(line, stdout); + } + return 0; +}